@multiplayer-app/ai-agent-react 0.1.0-beta.87 → 0.1.0-beta.88
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/ai-agent-react.cjs.js +2 -2
- package/dist/ai-agent-react.cjs.js.map +1 -1
- package/dist/ai-agent-react.es.js +4 -4
- package/dist/ai-agent-react.es.js.map +1 -1
- package/dist/components/ChatWindow/MessageList/MessageGroup.d.ts.map +1 -1
- package/dist/components/ChatWindow/MessageList/ToolCallCard/ToolApproval/ApprovalStatusInline.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -2
|
@@ -8293,7 +8293,7 @@
|
|
|
8293
8293
|
}`}),t]})},v3=()=>V.useContext(b3),l2="mp-agent-selected-model",ta="__auto__";function _3(e){return e.mode==="direct"?`${l2}-${e.mode}-${e.provider}`:`${l2}-${e.mode}`}function c2(e,t){try{const n=_3(e);localStorage.setItem(n,t)}catch(n){console.warn("Failed to save selected model to localStorage:",n)}}function E7e(e){try{const t=_3(e);return localStorage.getItem(t)}catch(t){return console.warn("Failed to load selected model from localStorage:",t),null}}function w3(e,t){return!e||e.length===0?[]:t.mode==="direct"&&t.provider!=="custom"?e.filter(n=>n.provider?n.provider===t.provider:!0):e}function M7e(e,t,n){const r=E7e(t);if(r){if(r===ta)return;if(w3(e,t).some(i=>i.id===r))return r}}const S7e="mp-agents-last-active-chat";function x3(e){return`${S7e}-${e}`}function E3(e){return typeof e=="string"&&e.length>0&&e.length<256}function N7e(e){if(typeof window>"u")return null;try{const t=localStorage.getItem(x3(e));return t&&E3(t)?t:null}catch{return null}}function A7e(e,t){if(!(typeof window>"u"))try{const n=x3(e);t&&E3(t)?localStorage.setItem(n,t):localStorage.removeItem(n)}catch{}}const wn=Object.create(null);wn.open="0";wn.close="1";wn.ping="2";wn.pong="3";wn.message="4";wn.upgrade="5";wn.noop="6";const bi=Object.create(null);Object.keys(wn).forEach(e=>{bi[wn[e]]=e});const ed={type:"error",data:"parser error"},M3=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",S3=typeof ArrayBuffer=="function",N3=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,ap=({type:e,data:t},n,r)=>M3&&t instanceof Blob?n?r(t):u2(t,r):S3&&(t instanceof ArrayBuffer||N3(t))?n?r(t):u2(new Blob([t]),r):r(wn[e]+(t||"")),u2=(e,t)=>{const n=new FileReader;return n.onload=function(){const r=n.result.split(",")[1];t("b"+(r||""))},n.readAsDataURL(e)};function d2(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let Xo;function T7e(e,t){if(M3&&e.data instanceof Blob)return e.data.arrayBuffer().then(d2).then(t);if(S3&&(e.data instanceof ArrayBuffer||N3(e.data)))return t(d2(e.data));ap(e,!1,n=>{Xo||(Xo=new TextEncoder),t(Xo.encode(n))})}const p2="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",na=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<p2.length;e++)na[p2.charCodeAt(e)]=e;const C7e=e=>{let t=e.length*.75,n=e.length,r,a=0,i,o,s,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);const u=new ArrayBuffer(t),d=new Uint8Array(u);for(r=0;r<n;r+=4)i=na[e.charCodeAt(r)],o=na[e.charCodeAt(r+1)],s=na[e.charCodeAt(r+2)],l=na[e.charCodeAt(r+3)],d[a++]=i<<2|o>>4,d[a++]=(o&15)<<4|s>>2,d[a++]=(s&3)<<6|l&63;return u},R7e=typeof ArrayBuffer=="function",ip=(e,t)=>{if(typeof e!="string")return{type:"message",data:A3(e,t)};const n=e.charAt(0);return n==="b"?{type:"message",data:I7e(e.substring(1),t)}:bi[n]?e.length>1?{type:bi[n],data:e.substring(1)}:{type:bi[n]}:ed},I7e=(e,t)=>{if(R7e){const n=C7e(e);return A3(n,t)}else return{base64:!0,data:e}},A3=(e,t)=>{switch(t){case"blob":return e instanceof Blob?e:new Blob([e]);case"arraybuffer":default:return e instanceof ArrayBuffer?e:e.buffer}},T3="",O7e=(e,t)=>{const n=e.length,r=new Array(n);let a=0;e.forEach((i,o)=>{ap(i,!1,s=>{r[o]=s,++a===n&&t(r.join(T3))})})},L7e=(e,t)=>{const n=e.split(T3),r=[];for(let a=0;a<n.length;a++){const i=ip(n[a],t);if(r.push(i),i.type==="error")break}return r};function D7e(){return new TransformStream({transform(e,t){T7e(e,n=>{const r=n.length;let a;if(r<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,r);else if(r<65536){a=new Uint8Array(3);const i=new DataView(a.buffer);i.setUint8(0,126),i.setUint16(1,r)}else{a=new Uint8Array(9);const i=new DataView(a.buffer);i.setUint8(0,127),i.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!="string"&&(a[0]|=128),t.enqueue(a),t.enqueue(n)})}})}let Qo;function Va(e){return e.reduce((t,n)=>t+n.length,0)}function Ga(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let a=0;a<t;a++)n[a]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function z7e(e,t){Qo||(Qo=new TextDecoder);const n=[];let r=0,a=-1,i=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(Va(n)<1)break;const l=Ga(n,1);i=(l[0]&128)===128,a=l[0]&127,a<126?r=3:a===126?r=1:r=2}else if(r===1){if(Va(n)<2)break;const l=Ga(n,2);a=new DataView(l.buffer,l.byteOffset,l.length).getUint16(0),r=3}else if(r===2){if(Va(n)<8)break;const l=Ga(n,8),u=new DataView(l.buffer,l.byteOffset,l.length),d=u.getUint32(0);if(d>Math.pow(2,21)-1){s.enqueue(ed);break}a=d*Math.pow(2,32)+u.getUint32(4),r=3}else{if(Va(n)<a)break;const l=Ga(n,a);s.enqueue(ip(i?l:Qo.decode(l),t)),r=0}if(a===0||a>e){s.enqueue(ed);break}}}})}const C3=4;function ct(e){if(e)return $7e(e)}function $7e(e){for(var t in ct.prototype)e[t]=ct.prototype[t];return e}ct.prototype.on=ct.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this};ct.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this};ct.prototype.off=ct.prototype.removeListener=ct.prototype.removeAllListeners=ct.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks["$"+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks["$"+e],this;for(var r,a=0;a<n.length;a++)if(r=n[a],r===t||r.fn===t){n.splice(a,1);break}return n.length===0&&delete this._callbacks["$"+e],this};ct.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,a=n.length;r<a;++r)n[r].apply(this,t)}return this};ct.prototype.emitReserved=ct.prototype.emit;ct.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]};ct.prototype.hasListeners=function(e){return!!this.listeners(e).length};const ho=typeof Promise=="function"&&typeof Promise.resolve=="function"?t=>Promise.resolve().then(t):(t,n)=>n(t,0),Qt=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),F7e="arraybuffer";function R3(e,...t){return t.reduce((n,r)=>(e.hasOwnProperty(r)&&(n[r]=e[r]),n),{})}const P7e=Qt.setTimeout,q7e=Qt.clearTimeout;function mo(e,t){t.useNativeTimers?(e.setTimeoutFn=P7e.bind(Qt),e.clearTimeoutFn=q7e.bind(Qt)):(e.setTimeoutFn=Qt.setTimeout.bind(Qt),e.clearTimeoutFn=Qt.clearTimeout.bind(Qt))}const B7e=1.33;function U7e(e){return typeof e=="string"?H7e(e):Math.ceil((e.byteLength||e.size)*B7e)}function H7e(e){let t=0,n=0;for(let r=0,a=e.length;r<a;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function I3(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function j7e(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}function V7e(e){let t={},n=e.split("&");for(let r=0,a=n.length;r<a;r++){let i=n[r].split("=");t[decodeURIComponent(i[0])]=decodeURIComponent(i[1])}return t}class G7e extends Error{constructor(t,n,r){super(t),this.description=n,this.context=r,this.type="TransportError"}}class op extends ct{constructor(t){super(),this.writable=!1,mo(this,t),this.opts=t,this.query=t.query,this.socket=t.socket,this.supportsBinary=!t.forceBase64}onError(t,n,r){return super.emitReserved("error",new G7e(t,n,r)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(t){this.readyState==="open"&&this.write(t)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(t){const n=ip(t,this.socket.binaryType);this.onPacket(n)}onPacket(t){super.emitReserved("packet",t)}onClose(t){this.readyState="closed",super.emitReserved("close",t)}pause(t){}createUri(t,n={}){return t+"://"+this._hostname()+this._port()+this.opts.path+this._query(n)}_hostname(){const t=this.opts.hostname;return t.indexOf(":")===-1?t:"["+t+"]"}_port(){return this.opts.port&&(this.opts.secure&&+(this.opts.port!==443)||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(t){const n=j7e(t);return n.length?"?"+n:""}}class W7e extends op{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(t){this.readyState="pausing";const n=()=>{this.readyState="paused",t()};if(this._polling||!this.writable){let r=0;this._polling&&(r++,this.once("pollComplete",function(){--r||n()})),this.writable||(r++,this.once("drain",function(){--r||n()}))}else n()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(t){const n=r=>{if(this.readyState==="opening"&&r.type==="open"&&this.onOpen(),r.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(r)};L7e(t,this.socket.binaryType).forEach(n),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const t=()=>{this.write([{type:"close"}])};this.readyState==="open"?t():this.once("open",t)}write(t){this.writable=!1,O7e(t,n=>{this.doWrite(n,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const t=this.opts.secure?"https":"http",n=this.query||{};return this.opts.timestampRequests!==!1&&(n[this.opts.timestampParam]=I3()),!this.supportsBinary&&!n.sid&&(n.b64=1),this.createUri(t,n)}}let O3=!1;try{O3=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const K7e=O3;function Y7e(){}class Z7e extends W7e{constructor(t){if(super(t),typeof location<"u"){const n=location.protocol==="https:";let r=location.port;r||(r=n?"443":"80"),this.xd=typeof location<"u"&&t.hostname!==location.hostname||r!==t.port}}doWrite(t,n){const r=this.request({method:"POST",data:t});r.on("success",n),r.on("error",(a,i)=>{this.onError("xhr post error",a,i)})}doPoll(){const t=this.request();t.on("data",this.onData.bind(this)),t.on("error",(n,r)=>{this.onError("xhr poll error",n,r)}),this.pollXhr=t}}class _n extends ct{constructor(t,n,r){super(),this.createRequest=t,mo(this,r),this._opts=r,this._method=r.method||"GET",this._uri=n,this._data=r.data!==void 0?r.data:null,this._create()}_create(){var t;const n=R3(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let a in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(a)&&r.setRequestHeader(a,this._opts.extraHeaders[a])}}catch{}if(this._method==="POST")try{r.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{r.setRequestHeader("Accept","*/*")}catch{}(t=this._opts.cookieJar)===null||t===void 0||t.addCookies(r),"withCredentials"in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var a;r.readyState===3&&((a=this._opts.cookieJar)===null||a===void 0||a.parseCookies(r.getResponseHeader("set-cookie"))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status=="number"?r.status:0)},0))},r.send(this._data)}catch(a){this.setTimeoutFn(()=>{this._onError(a)},0);return}typeof document<"u"&&(this._index=_n.requestsCount++,_n.requests[this._index]=this)}_onError(t){this.emitReserved("error",t,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Y7e,t)try{this._xhr.abort()}catch{}typeof document<"u"&&delete _n.requests[this._index],this._xhr=null}}_onLoad(){const t=this._xhr.responseText;t!==null&&(this.emitReserved("data",t),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}_n.requestsCount=0;_n.requests={};if(typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",h2);else if(typeof addEventListener=="function"){const e="onpagehide"in Qt?"pagehide":"unload";addEventListener(e,h2,!1)}}function h2(){for(let e in _n.requests)_n.requests.hasOwnProperty(e)&&_n.requests[e].abort()}const X7e=function(){const e=L3({xdomain:!1});return e&&e.responseType!==null}();class Q7e extends Z7e{constructor(t){super(t);const n=t&&t.forceBase64;this.supportsBinary=X7e&&!n}request(t={}){return Object.assign(t,{xd:this.xd},this.opts),new _n(L3,this.uri(),t)}}function L3(e){const t=e.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!t||K7e))return new XMLHttpRequest}catch{}if(!t)try{return new Qt[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const D3=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class J7e extends op{get name(){return"websocket"}doOpen(){const t=this.uri(),n=this.opts.protocols,r=D3?{}:R3(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(r.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(t,n,r)}catch(a){return this.emitReserved("error",a)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=t=>this.onClose({description:"websocket connection closed",context:t}),this.ws.onmessage=t=>this.onData(t.data),this.ws.onerror=t=>this.onError("websocket error",t)}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;ap(r,this.supportsBinary,i=>{try{this.doWrite(r,i)}catch{}a&&ho(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const t=this.opts.secure?"wss":"ws",n=this.query||{};return this.opts.timestampRequests&&(n[this.opts.timestampParam]=I3()),this.supportsBinary||(n.b64=1),this.createUri(t,n)}}const Jo=Qt.WebSocket||Qt.MozWebSocket;class e_e extends J7e{createSocket(t,n,r){return D3?new Jo(t,n,r):n?new Jo(t,n):new Jo(t)}doWrite(t,n){this.ws.send(n)}}class t_e extends op{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(t){return this.emitReserved("error",t)}this._transport.closed.then(()=>{this.onClose()}).catch(t=>{this.onError("webtransport error",t)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(t=>{const n=z7e(Number.MAX_SAFE_INTEGER,this.socket.binaryType),r=t.readable.pipeThrough(n).getReader(),a=D7e();a.readable.pipeTo(t.writable),this._writer=a.writable.getWriter();const i=()=>{r.read().then(({done:s,value:l})=>{s||(this.onPacket(l),i())}).catch(s=>{})};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(t){this.writable=!1;for(let n=0;n<t.length;n++){const r=t[n],a=n===t.length-1;this._writer.write(r).then(()=>{a&&ho(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var t;(t=this._transport)===null||t===void 0||t.close()}}const n_e={websocket:e_e,webtransport:t_e,polling:Q7e},r_e=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,a_e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function td(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let a=r_e.exec(e||""),i={},o=14;for(;o--;)i[a_e[o]]=a[o]||"";return n!=-1&&r!=-1&&(i.source=t,i.host=i.host.substring(1,i.host.length-1).replace(/;/g,":"),i.authority=i.authority.replace("[","").replace("]","").replace(/;/g,":"),i.ipv6uri=!0),i.pathNames=i_e(i,i.path),i.queryKey=o_e(i,i.query),i}function i_e(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");return(t.slice(0,1)=="/"||t.length===0)&&r.splice(0,1),t.slice(-1)=="/"&&r.splice(r.length-1,1),r}function o_e(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(r,a,i){a&&(n[a]=i)}),n}const nd=typeof addEventListener=="function"&&typeof removeEventListener=="function",ki=[];nd&&addEventListener("offline",()=>{ki.forEach(e=>e())},!1);class Qn extends ct{constructor(t,n){if(super(),this.binaryType=F7e,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,t&&typeof t=="object"&&(n=t,t=null),t){const r=td(t);n.hostname=r.host,n.secure=r.protocol==="https"||r.protocol==="wss",n.port=r.port,r.query&&(n.query=r.query)}else n.host&&(n.hostname=td(n.host).host);mo(this,n),this.secure=n.secure!=null?n.secure:typeof location<"u"&&location.protocol==="https:",n.hostname&&!n.port&&(n.port=this.secure?"443":"80"),this.hostname=n.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=n.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},n.transports.forEach(r=>{const a=r.prototype.name;this.transports.push(a),this._transportsByName[a]=r}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},n),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),typeof this.opts.query=="string"&&(this.opts.query=V7e(this.opts.query)),nd&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},ki.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(t){const n=Object.assign({},this.opts.query);n.EIO=C3,n.transport=t,this.id&&(n.sid=this.id);const r=Object.assign({},this.opts,{query:n,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[t]);return new this._transportsByName[t](r)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const t=this.opts.rememberUpgrade&&Qn.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"websocket":this.transports[0];this.readyState="opening";const n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(t){this.transport&&this.transport.removeAllListeners(),this.transport=t,t.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",n=>this._onClose("transport close",n))}onOpen(){this.readyState="open",Qn.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")switch(this.emitReserved("packet",t),this.emitReserved("heartbeat"),t.type){case"open":this.onHandshake(JSON.parse(t.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const n=new Error("server error");n.code=t.data,this._onError(n);break;case"message":this.emitReserved("data",t.data),this.emitReserved("message",t.data);break}}onHandshake(t){this.emitReserved("handshake",t),this.id=t.sid,this.transport.query.sid=t.sid,this._pingInterval=t.pingInterval,this._pingTimeout=t.pingTimeout,this._maxPayload=t.maxPayload,this.onOpen(),this.readyState!=="closed"&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const t=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+t,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},t),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const t=this._getWritablePackets();this.transport.send(t),this._prevBufferLen=t.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let n=1;for(let r=0;r<this.writeBuffer.length;r++){const a=this.writeBuffer[r].data;if(a&&(n+=U7e(a)),r>0&&n>this._maxPayload)return this.writeBuffer.slice(0,r);n+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const t=Date.now()>this._pingTimeoutTime;return t&&(this._pingTimeoutTime=0,ho(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),t}write(t,n,r){return this._sendPacket("message",t,n,r),this}send(t,n,r){return this._sendPacket("message",t,n,r),this}_sendPacket(t,n,r,a){if(typeof n=="function"&&(a=n,n=void 0),typeof r=="function"&&(a=r,r=null),this.readyState==="closing"||this.readyState==="closed")return;r=r||{},r.compress=r.compress!==!1;const i={type:t,data:n,options:r};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),a&&this.once("flush",a),this.flush()}close(){const t=()=>{this._onClose("forced close"),this.transport.close()},n=()=>{this.off("upgrade",n),this.off("upgradeError",n),t()},r=()=>{this.once("upgrade",n),this.once("upgradeError",n)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?r():t()}):this.upgrading?r():t()),this}_onError(t){if(Qn.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",t),this._onClose("transport error",t)}_onClose(t,n){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),nd&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const r=ki.indexOf(this._offlineEventListener);r!==-1&&ki.splice(r,1)}this.readyState="closed",this.id=null,this.emitReserved("close",t,n),this.writeBuffer=[],this._prevBufferLen=0}}}Qn.protocol=C3;class s_e extends Qn{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState==="open"&&this.opts.upgrade)for(let t=0;t<this._upgrades.length;t++)this._probe(this._upgrades[t])}_probe(t){let n=this.createTransport(t),r=!1;Qn.priorWebsocketSuccess=!1;const a=()=>{r||(n.send([{type:"ping",data:"probe"}]),n.once("packet",p=>{if(!r)if(p.type==="pong"&&p.data==="probe"){if(this.upgrading=!0,this.emitReserved("upgrading",n),!n)return;Qn.priorWebsocketSuccess=n.name==="websocket",this.transport.pause(()=>{r||this.readyState!=="closed"&&(d(),this.setTransport(n),n.send([{type:"upgrade"}]),this.emitReserved("upgrade",n),n=null,this.upgrading=!1,this.flush())})}else{const m=new Error("probe error");m.transport=n.name,this.emitReserved("upgradeError",m)}}))};function i(){r||(r=!0,d(),n.close(),n=null)}const o=p=>{const m=new Error("probe error: "+p);m.transport=n.name,i(),this.emitReserved("upgradeError",m)};function s(){o("transport closed")}function l(){o("socket closed")}function u(p){n&&p.name!==n.name&&i()}const d=()=>{n.removeListener("open",a),n.removeListener("error",o),n.removeListener("close",s),this.off("close",l),this.off("upgrading",u)};n.once("open",a),n.once("error",o),n.once("close",s),this.once("close",l),this.once("upgrading",u),this._upgrades.indexOf("webtransport")!==-1&&t!=="webtransport"?this.setTimeoutFn(()=>{r||n.open()},200):n.open()}onHandshake(t){this._upgrades=this._filterUpgrades(t.upgrades),super.onHandshake(t)}_filterUpgrades(t){const n=[];for(let r=0;r<t.length;r++)~this.transports.indexOf(t[r])&&n.push(t[r]);return n}}let l_e=class extends s_e{constructor(t,n={}){const r=typeof t=="object"?t:n;(!r.transports||r.transports&&typeof r.transports[0]=="string")&&(r.transports=(r.transports||["polling","websocket","webtransport"]).map(a=>n_e[a]).filter(a=>!!a)),super(t,r)}};function c_e(e,t="",n){let r=e;n=n||typeof location<"u"&&location,e==null&&(e=n.protocol+"//"+n.host),typeof e=="string"&&(e.charAt(0)==="/"&&(e.charAt(1)==="/"?e=n.protocol+e:e=n.host+e),/^(https?|wss?):\/\//.test(e)||(typeof n<"u"?e=n.protocol+"//"+e:e="https://"+e),r=td(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=r.host.indexOf(":")!==-1?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}const u_e=typeof ArrayBuffer=="function",d_e=e=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,z3=Object.prototype.toString,p_e=typeof Blob=="function"||typeof Blob<"u"&&z3.call(Blob)==="[object BlobConstructor]",h_e=typeof File=="function"||typeof File<"u"&&z3.call(File)==="[object FileConstructor]";function sp(e){return u_e&&(e instanceof ArrayBuffer||d_e(e))||p_e&&e instanceof Blob||h_e&&e instanceof File}function vi(e,t){if(!e||typeof e!="object")return!1;if(Array.isArray(e)){for(let n=0,r=e.length;n<r;n++)if(vi(e[n]))return!0;return!1}if(sp(e))return!0;if(e.toJSON&&typeof e.toJSON=="function"&&arguments.length===1)return vi(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&vi(e[n]))return!0;return!1}function m_e(e){const t=[],n=e.data,r=e;return r.data=rd(n,t),r.attachments=t.length,{packet:r,buffers:t}}function rd(e,t){if(!e)return e;if(sp(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=rd(e[r],t);return n}else if(typeof e=="object"&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=rd(e[r],t));return n}return e}function f_e(e,t){return e.data=ad(e.data,t),delete e.attachments,e}function ad(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num=="number"&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=ad(e[n],t);else if(typeof e=="object")for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=ad(e[n],t));return e}const g_e=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"],y_e=5;var Pe;(function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"})(Pe||(Pe={}));class b_e{constructor(t){this.replacer=t}encode(t){return(t.type===Pe.EVENT||t.type===Pe.ACK)&&vi(t)?this.encodeAsBinary({type:t.type===Pe.EVENT?Pe.BINARY_EVENT:Pe.BINARY_ACK,nsp:t.nsp,data:t.data,id:t.id}):[this.encodeAsString(t)]}encodeAsString(t){let n=""+t.type;return(t.type===Pe.BINARY_EVENT||t.type===Pe.BINARY_ACK)&&(n+=t.attachments+"-"),t.nsp&&t.nsp!=="/"&&(n+=t.nsp+","),t.id!=null&&(n+=t.id),t.data!=null&&(n+=JSON.stringify(t.data,this.replacer)),n}encodeAsBinary(t){const n=m_e(t),r=this.encodeAsString(n.packet),a=n.buffers;return a.unshift(r),a}}function m2(e){return Object.prototype.toString.call(e)==="[object Object]"}class lp extends ct{constructor(t){super(),this.reviver=t}add(t){let n;if(typeof t=="string"){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");n=this.decodeString(t);const r=n.type===Pe.BINARY_EVENT;r||n.type===Pe.BINARY_ACK?(n.type=r?Pe.EVENT:Pe.ACK,this.reconstructor=new k_e(n),n.attachments===0&&super.emitReserved("decoded",n)):super.emitReserved("decoded",n)}else if(sp(t)||t.base64)if(this.reconstructor)n=this.reconstructor.takeBinaryData(t),n&&(this.reconstructor=null,super.emitReserved("decoded",n));else throw new Error("got binary data when not reconstructing a packet");else throw new Error("Unknown type: "+t)}decodeString(t){let n=0;const r={type:Number(t.charAt(0))};if(Pe[r.type]===void 0)throw new Error("unknown packet type "+r.type);if(r.type===Pe.BINARY_EVENT||r.type===Pe.BINARY_ACK){const i=n+1;for(;t.charAt(++n)!=="-"&&n!=t.length;);const o=t.substring(i,n);if(o!=Number(o)||t.charAt(n)!=="-")throw new Error("Illegal attachments");r.attachments=Number(o)}if(t.charAt(n+1)==="/"){const i=n+1;for(;++n&&!(t.charAt(n)===","||n===t.length););r.nsp=t.substring(i,n)}else r.nsp="/";const a=t.charAt(n+1);if(a!==""&&Number(a)==a){const i=n+1;for(;++n;){const o=t.charAt(n);if(o==null||Number(o)!=o){--n;break}if(n===t.length)break}r.id=Number(t.substring(i,n+1))}if(t.charAt(++n)){const i=this.tryParse(t.substr(n));if(lp.isPayloadValid(r.type,i))r.data=i;else throw new Error("invalid payload")}return r}tryParse(t){try{return JSON.parse(t,this.reviver)}catch{return!1}}static isPayloadValid(t,n){switch(t){case Pe.CONNECT:return m2(n);case Pe.DISCONNECT:return n===void 0;case Pe.CONNECT_ERROR:return typeof n=="string"||m2(n);case Pe.EVENT:case Pe.BINARY_EVENT:return Array.isArray(n)&&(typeof n[0]=="number"||typeof n[0]=="string"&&g_e.indexOf(n[0])===-1);case Pe.ACK:case Pe.BINARY_ACK:return Array.isArray(n)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class k_e{constructor(t){this.packet=t,this.buffers=[],this.reconPack=t}takeBinaryData(t){if(this.buffers.push(t),this.buffers.length===this.reconPack.attachments){const n=f_e(this.reconPack,this.buffers);return this.finishedReconstruction(),n}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const v_e=Object.freeze(Object.defineProperty({__proto__:null,Decoder:lp,Encoder:b_e,get PacketType(){return Pe},protocol:y_e},Symbol.toStringTag,{value:"Module"}));function cn(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const __e=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class $3 extends ct{constructor(t,n,r){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=t,this.nsp=n,r&&r.auth&&(this.auth=r.auth),this._opts=Object.assign({},r),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const t=this.io;this.subs=[cn(t,"open",this.onopen.bind(this)),cn(t,"packet",this.onpacket.bind(this)),cn(t,"error",this.onerror.bind(this)),cn(t,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState==="open"&&this.onopen(),this)}open(){return this.connect()}send(...t){return t.unshift("message"),this.emit.apply(this,t),this}emit(t,...n){var r,a,i;if(__e.hasOwnProperty(t))throw new Error('"'+t.toString()+'" is a reserved event name');if(n.unshift(t),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(n),this;const o={type:Pe.EVENT,data:n};if(o.options={},o.options.compress=this.flags.compress!==!1,typeof n[n.length-1]=="function"){const d=this.ids++,p=n.pop();this._registerAckCallback(d,p),o.id=d}const s=(a=(r=this.io.engine)===null||r===void 0?void 0:r.transport)===null||a===void 0?void 0:a.writable,l=this.connected&&!(!((i=this.io.engine)===null||i===void 0)&&i._hasPingExpired());return this.flags.volatile&&!s||(l?(this.notifyOutgoingListeners(o),this.packet(o)):this.sendBuffer.push(o)),this.flags={},this}_registerAckCallback(t,n){var r;const a=(r=this.flags.timeout)!==null&&r!==void 0?r:this._opts.ackTimeout;if(a===void 0){this.acks[t]=n;return}const i=this.io.setTimeoutFn(()=>{delete this.acks[t];for(let s=0;s<this.sendBuffer.length;s++)this.sendBuffer[s].id===t&&this.sendBuffer.splice(s,1);n.call(this,new Error("operation has timed out"))},a),o=(...s)=>{this.io.clearTimeoutFn(i),n.apply(this,s)};o.withError=!0,this.acks[t]=o}emitWithAck(t,...n){return new Promise((r,a)=>{const i=(o,s)=>o?a(o):r(s);i.withError=!0,n.push(i),this.emit(t,...n)})}_addToQueue(t){let n;typeof t[t.length-1]=="function"&&(n=t.pop());const r={id:this._queueSeq++,tryCount:0,pending:!1,args:t,flags:Object.assign({fromQueue:!0},this.flags)};t.push((a,...i)=>r!==this._queue[0]?void 0:(a!==null?r.tryCount>this._opts.retries&&(this._queue.shift(),n&&n(a)):(this._queue.shift(),n&&n(null,...i)),r.pending=!1,this._drainQueue())),this._queue.push(r),this._drainQueue()}_drainQueue(t=!1){if(!this.connected||this._queue.length===0)return;const n=this._queue[0];n.pending&&!t||(n.pending=!0,n.tryCount++,this.flags=n.flags,this.emit.apply(this,n.args))}packet(t){t.nsp=this.nsp,this.io._packet(t)}onopen(){typeof this.auth=="function"?this.auth(t=>{this._sendConnectPacket(t)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(t){this.packet({type:Pe.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},t):t})}onerror(t){this.connected||this.emitReserved("connect_error",t)}onclose(t,n){this.connected=!1,delete this.id,this.emitReserved("disconnect",t,n),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(t=>{if(!this.sendBuffer.some(r=>String(r.id)===t)){const r=this.acks[t];delete this.acks[t],r.withError&&r.call(this,new Error("socket has been disconnected"))}})}onpacket(t){if(t.nsp===this.nsp)switch(t.type){case Pe.CONNECT:t.data&&t.data.sid?this.onconnect(t.data.sid,t.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case Pe.EVENT:case Pe.BINARY_EVENT:this.onevent(t);break;case Pe.ACK:case Pe.BINARY_ACK:this.onack(t);break;case Pe.DISCONNECT:this.ondisconnect();break;case Pe.CONNECT_ERROR:this.destroy();const r=new Error(t.data.message);r.data=t.data.data,this.emitReserved("connect_error",r);break}}onevent(t){const n=t.data||[];t.id!=null&&n.push(this.ack(t.id)),this.connected?this.emitEvent(n):this.receiveBuffer.push(Object.freeze(n))}emitEvent(t){if(this._anyListeners&&this._anyListeners.length){const n=this._anyListeners.slice();for(const r of n)r.apply(this,t)}super.emit.apply(this,t),this._pid&&t.length&&typeof t[t.length-1]=="string"&&(this._lastOffset=t[t.length-1])}ack(t){const n=this;let r=!1;return function(...a){r||(r=!0,n.packet({type:Pe.ACK,id:t,data:a}))}}onack(t){const n=this.acks[t.id];typeof n=="function"&&(delete this.acks[t.id],n.withError&&t.data.unshift(null),n.apply(this,t.data))}onconnect(t,n){this.id=t,this.recovered=n&&this._pid===n,this._pid=n,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(t=>this.emitEvent(t)),this.receiveBuffer=[],this.sendBuffer.forEach(t=>{this.notifyOutgoingListeners(t),this.packet(t)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(t=>t()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:Pe.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(t){return this.flags.compress=t,this}get volatile(){return this.flags.volatile=!0,this}timeout(t){return this.flags.timeout=t,this}onAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(t),this}prependAny(t){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(t),this}offAny(t){if(!this._anyListeners)return this;if(t){const n=this._anyListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(t),this}prependAnyOutgoing(t){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(t),this}offAnyOutgoing(t){if(!this._anyOutgoingListeners)return this;if(t){const n=this._anyOutgoingListeners;for(let r=0;r<n.length;r++)if(t===n[r])return n.splice(r,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(t){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const n=this._anyOutgoingListeners.slice();for(const r of n)r.apply(this,t.data)}}}function jr(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}jr.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0};jr.prototype.reset=function(){this.attempts=0};jr.prototype.setMin=function(e){this.ms=e};jr.prototype.setMax=function(e){this.max=e};jr.prototype.setJitter=function(e){this.jitter=e};class id extends ct{constructor(t,n){var r;super(),this.nsps={},this.subs=[],t&&typeof t=="object"&&(n=t,t=void 0),n=n||{},n.path=n.path||"/socket.io",this.opts=n,mo(this,n),this.reconnection(n.reconnection!==!1),this.reconnectionAttempts(n.reconnectionAttempts||1/0),this.reconnectionDelay(n.reconnectionDelay||1e3),this.reconnectionDelayMax(n.reconnectionDelayMax||5e3),this.randomizationFactor((r=n.randomizationFactor)!==null&&r!==void 0?r:.5),this.backoff=new jr({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(n.timeout==null?2e4:n.timeout),this._readyState="closed",this.uri=t;const a=n.parser||v_e;this.encoder=new a.Encoder,this.decoder=new a.Decoder,this._autoConnect=n.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(t){return arguments.length?(this._reconnection=!!t,t||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(t){return t===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=t,this)}reconnectionDelay(t){var n;return t===void 0?this._reconnectionDelay:(this._reconnectionDelay=t,(n=this.backoff)===null||n===void 0||n.setMin(t),this)}randomizationFactor(t){var n;return t===void 0?this._randomizationFactor:(this._randomizationFactor=t,(n=this.backoff)===null||n===void 0||n.setJitter(t),this)}reconnectionDelayMax(t){var n;return t===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=t,(n=this.backoff)===null||n===void 0||n.setMax(t),this)}timeout(t){return arguments.length?(this._timeout=t,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(t){if(~this._readyState.indexOf("open"))return this;this.engine=new l_e(this.uri,this.opts);const n=this.engine,r=this;this._readyState="opening",this.skipReconnect=!1;const a=cn(n,"open",function(){r.onopen(),t&&t()}),i=s=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",s),t?t(s):this.maybeReconnectOnOpen()},o=cn(n,"error",i);if(this._timeout!==!1){const s=this._timeout,l=this.setTimeoutFn(()=>{a(),i(new Error("timeout")),n.close()},s);this.opts.autoUnref&&l.unref(),this.subs.push(()=>{this.clearTimeoutFn(l)})}return this.subs.push(a),this.subs.push(o),this}connect(t){return this.open(t)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const t=this.engine;this.subs.push(cn(t,"ping",this.onping.bind(this)),cn(t,"data",this.ondata.bind(this)),cn(t,"error",this.onerror.bind(this)),cn(t,"close",this.onclose.bind(this)),cn(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(t){try{this.decoder.add(t)}catch(n){this.onclose("parse error",n)}}ondecoded(t){ho(()=>{this.emitReserved("packet",t)},this.setTimeoutFn)}onerror(t){this.emitReserved("error",t)}socket(t,n){let r=this.nsps[t];return r?this._autoConnect&&!r.active&&r.connect():(r=new $3(this,t,n),this.nsps[t]=r),r}_destroy(t){const n=Object.keys(this.nsps);for(const r of n)if(this.nsps[r].active)return;this._close()}_packet(t){const n=this.encoder.encode(t);for(let r=0;r<n.length;r++)this.engine.write(n[r],t.options)}cleanup(){this.subs.forEach(t=>t()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(t,n){var r;this.cleanup(),(r=this.engine)===null||r===void 0||r.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",t,n),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const t=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const n=this.backoff.duration();this._reconnecting=!0;const r=this.setTimeoutFn(()=>{t.skipReconnect||(this.emitReserved("reconnect_attempt",t.backoff.attempts),!t.skipReconnect&&t.open(a=>{a?(t._reconnecting=!1,t.reconnect(),this.emitReserved("reconnect_error",a)):t.onreconnect()}))},n);this.opts.autoUnref&&r.unref(),this.subs.push(()=>{this.clearTimeoutFn(r)})}}onreconnect(){const t=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",t)}}const Zr={};function _i(e,t){typeof e=="object"&&(t=e,e=void 0),t=t||{};const n=c_e(e,t.path||"/socket.io"),r=n.source,a=n.id,i=n.path,o=Zr[a]&&i in Zr[a].nsps,s=t.forceNew||t["force new connection"]||t.multiplex===!1||o;let l;return s?l=new id(r,t):(Zr[a]||(Zr[a]=new id(r,t)),l=Zr[a]),n.query&&!t.query&&(t.query=n.queryKey),l.socket(n.path,t)}Object.assign(_i,{Manager:id,Socket:$3,io:_i,connect:_i});const w_e=V.createContext(null),x_e=({children:e})=>{const t=Ue(),n=be(v=>v.upsertChat),r=be(v=>v.upsertChatState),a=be(v=>v.contextKey),i=be(v=>v.activeChatId),o=V.useMemo(()=>t.config.user?.id??Hr(),[t.config.user?.id]),s=t.config.transport,[l,u]=V.useState(null),[d,p]=V.useState(void 0),m=V.useRef(a),h=V.useRef(n),g=V.useRef(r),f=V.useRef(void 0);V.useEffect(()=>{m.current=a,h.current=n,g.current=r},[a,n,r]),V.useEffect(()=>{if(s.mode!=="proxy"){u(null),p(void 0),t.setSocketClient(null),t.transport instanceof Or&&t.transport.setSocketId(void 0);return}const v=s.baseUrl,k=new URL(v,window.location.origin),_=`${k.protocol}//${k.host}`,E=s.socketNamespace,S=E?`${_}${E}`:_,x={},D=s;D.headers&&Object.assign(x,D.headers);const P={},C=D.apiKey&&`Bearer ${D.apiKey}`||D.headers?.Authorization;C&&(P.authorization=C,x.Authorization=C);const L=s.socketPath??Ai.Path,G=_i(S,{path:L,auth:P,transports:["websocket","polling"],withCredentials:!0,...Object.keys(x).length>0&&{extraHeaders:x}});t.setSocketClient(G),u(G);const X=()=>{p(G.id),t.transport instanceof Or&&t.transport.setSocketId(G.id)},J=()=>{p(void 0),t.transport instanceof Or&&t.transport.setSocketId(void 0)},K=H=>{if(H.contextKey===m.current){h.current(H);const z=t.store.getState(),j=ze(z,H.id);g.current(H.id,{...j,status:Di(H.status)})}},R=H=>{const z=t.store.getState(),j=ze(z,H.chat),A=j.messages.findIndex(Y=>Y.id===H.id);if(A>=0){const Y=[...j.messages];Y[A]=H,g.current(H.chat,{...j,messages:Y});return}g.current(H.chat,{...j,messages:[...j.messages,H]})},U=H=>{h.current(H);const z=t.store.getState(),j=ze(z,H.id);g.current(H.id,{...j,status:Di(H.status)})};return G.on("connect",X),G.on("disconnect",J),G.on("connect_error",H=>{console.error("Socket.IO connection error:",H.message)}),G.on(fi.ChatNew,K),G.on(fi.MessageNew,R),G.on(fi.ChatUpdate,U),()=>{t.transport instanceof Or&&t.transport.setSocketId(void 0),t.setSocketClient(null),p(void 0),u(null),G.disconnect()}},[t,t.transport,s.mode,s.mode==="proxy"?s.baseUrl:void 0,s.mode==="proxy"?s.apiKey:void 0,s.mode==="proxy"?s.socketPath:void 0,s.mode==="proxy"?s.socketNamespace:void 0,s.mode==="proxy"?JSON.stringify(s.headers??{}):"",o]),V.useEffect(()=>{if(!l)return;const v=f.current;v&&v!==i&&l.emit("chat:unsubscribe",{chatId:v}),i&&i!==v&&(l.emit("chat:subscribe",{chatId:i}),f.current=i),i||(f.current=void 0)},[l,i]);const w=V.useMemo(()=>({socket:l,socketId:d}),[l,d]);return N.jsx(w_e.Provider,{value:w,children:e})},cp=V.createContext(null),E_e=({config:e,children:t})=>{const n=V.useRef();n.current||(n.current=new g3(e));const[,r]=V.useState(0);V.useEffect(()=>{const o=n.current,s=()=>r(l=>l+1);return o.events.addEventListener("runtime:transport-config-changed",s),()=>{o.events.removeEventListener("runtime:transport-config-changed",s)}},[]);const a=V.useRef();if(!a.current){const o=n.current.defaultContextKey??n.current.config.contextKeys[0]?.key??"default";a.current=m7e(o),n.current.attachStore(a.current);const s=M7e(n.current.config.models,n.current.config.transport);a.current.getState().setComposerOptions({model:s})}const i=V.useMemo(()=>({runtime:n.current,store:a.current}),[]);return V.useEffect(()=>{const o=a.current;if(!o)return;let s=o.getState().activeChatId;return o.subscribe(()=>{const l=o.getState().activeChatId;if(l===s)return;s=l;const u=n.current?.config.user?.id??Hr();A7e(u,l)})},[]),N.jsx(cp.Provider,{value:i,children:N.jsx(yt.QueryClientProvider,{client:i.runtime.queryClient,children:N.jsx(k3,{value:i.runtime.config.theme,children:N.jsx(x_e,{children:t})})})})},Ue=()=>{const e=V.useContext(cp);if(!e)throw new Error("useAgentRuntime must be used inside <AgentProvider />");return e.runtime},be=e=>{const t=V.useContext(cp);if(!t)throw new Error("useAgentStore must be used inside <AgentProvider />");return r5.useStore(t.store,e)},M_e=({initialSystemPrompt:e,composerFormRef:t,multiUser:n=!1,participantIds:r=[]})=>{const a=Ue(),{composer:i,contextKey:o,activeChatId:s,draftChatKey:l,queuedMessages:u,activeChatStatus:d,upsertChat:p,setChatStatus:m,setActiveChat:h,setComposerError:g,moveChatKeyState:f,removeQueuedMessage:w,setPendingAssistant:v,enqueueQueuedMessage:k,appendMessagesToChat:_,commitPendingAssistant:E,setPageContextDismissed:S}=be(j=>{const A=j.activeChatId??j.draftChatKey,Y=ze(j,A);return{composer:j.composer,contextKey:j.contextKey,activeChatId:j.activeChatId,draftChatKey:j.draftChatKey,queuedMessages:Y.messageQueue,activeChatStatus:Y.status,upsertChat:j.upsertChat,setActiveChat:j.setActiveChat,setChatStatus:j.setChatStatus,setComposerError:j.setComposerError,moveChatKeyState:j.moveChatKeyState,setPendingAssistant:j.setPendingAssistant,removeQueuedMessage:j.removeQueuedMessage,enqueueQueuedMessage:j.enqueueQueuedMessage,appendMessagesToChat:j.appendMessagesToChat,commitPendingAssistant:j.commitPendingAssistant,setPageContextDismissed:j.setPageContextDismissed}}),x=V.useCallback(j=>!j||j.length===0?!1:j.some(A=>A.type===exports.AgentAttachmentType.Context&&A?.metadata?.kind==="pageContext"),[]),D=V.useRef(!1),P=V.useRef(!1),C=V.useRef(void 0),L=V.useRef(new Set),G=s??l,X=V.useCallback(async(j,A)=>{if(!a.transport.generateTitle)return;const Y=a.config.features?.titleGeneration==="llm"?"llm":"local";let ee;try{ee=await a.transport.generateTitle({userId:A,content:j,strategy:Y,contextKey:o})}catch{}return ee},[a.transport,a.config.features?.titleGeneration,o]),J=V.useCallback(async(j,A=[])=>{const Y=a.config.user?.id??"guest",ee=!s,O=s??l,le={current:O};C.current=O;const fe={value:j,attachments:A};g(le.current,void 0);let ke;if(ee){const ce=await X(j,Y);ce&&ce.trim().length>0&&(ke={...ke??{},title:ce})}const Ce=a.store.getState(),$e=s?Ce.chats[s]:void 0,Ve=(s?Ce.chatState[s]:void 0)?.messages??[],ae=A.filter(ce=>F3(ce)?!S_e(Ve,ce):!0),Se=$e?.model,qe=i.model!==Se;let We,Ae=!1;qe?(We=i.model,Ae=!0):Se?(We=Se,Ae=!1):(We=void 0,Ae=!1);const ve=N_e(j),Ge={userId:Y,content:j,metadata:ke,contextKey:o,...ee?{}:{chatId:s},...Ae?{model:We??""}:{},...ae.length>0?{attachments:ae}:{},...n?{mentions:ve,participantIds:Array.from(new Set([Y,...r])),senderDisplayName:a.config.user?.displayName,senderAvatarUrl:a.config.user?.avatarUrl}:{}},de=()=>{v(le.current,void 0)},Ze=ce=>{if(ce?.name==="AbortError"){const Me=C.current??le.current;return L.current.has(Me)?(E(le.current),L.current.delete(Me)):(de(),t.current?.setDraft(fe)),{type:"aborted"}}throw ce},Ke=async()=>{m(le.current,vt.Sending);try{if(!a.transport.sendMultiUserMessage)throw new Error("Multi-user chat requires a transport that supports sendMultiUserMessage");const ce=await a.transport.sendMultiUserMessage(Ge);return p(ce.chat),ee&&(f(le.current,ce.chat.id),le.current=ce.chat.id,C.current=ce.chat.id,h(ce.chat.id)),_(ce.chat.id,[ce.message]),m(ce.chat.id,Di(ce.chat.status)),de(),{type:"success"}}catch(ce){return Ze(ce)}},He=async()=>{let ce=`pending-${Date.now()}`,Me="",ye;m(le.current,vt.Streaming),v(le.current,{id:ce,content:"",reasoning:"",toolCalls:[],attachments:[],chat:s||"",role:exports.MessageRole.Assistant,createdAt:new Date().toISOString()});try{let Fe=s;const q=ne=>{if(ne.type===exports.StreamChunkType.Chat&&ne.chat){p(ne.chat),Fe=ne.chat.id,ee&&(C.current=ne.chat.id,f(le.current,ne.chat.id),le.current=ne.chat.id,h(ne.chat.id));return}if(ne.type===exports.StreamChunkType.Reasoning&&ne.reasoning){Me+=ne.reasoning,ye={...ye??{id:ce,chat:Fe,role:exports.MessageRole.Assistant,content:"",createdAt:new Date().toISOString()},reasoning:Me},v(le.current,ye);return}if(ne.type===exports.StreamChunkType.Error&&ne.error)throw new Error(ne.error);if(ne.message&&ne.message.role===exports.MessageRole.User){_(ne.message.chat,[ne.message]);return}ne.message&&(ce=ne.message.id,ye={...ne.message,reasoning:Me||ne.message.reasoning},v(le.current,ye)),ne.done&&(ye&&_(le.current,[ye]),m(le.current,vt.Idle),de())},Z=await a.transport.streamMessage(Ge,q,{streamKey:C.current});if(Z){const ne=Z.messages.map(Le=>ye&&Le.id===ye.id&&Le.role===exports.MessageRole.Assistant?{...Le,reasoning:Me}:Le);_(Z.id,ne);const pe=a.store.getState();return(pe.activeChatId??pe.draftChatKey)===le.current&&h(Z.id),de(),{type:"success"}}return de(),{type:"success"}}catch(Fe){return Ze(Fe)}};try{const ce=await(n?Ke():He());return ce.type==="success"&&(D.current=!1),ce}catch(ce){de();const Me=ce?.chat;Me&&(p(Me),h(Me.id));const ye=ce instanceof Error?ce:new Error("Failed to send message");return g(le.current,ye.message||"Failed to send message"),m(le.current,vt.Idle),t.current?.setDraft(fe),D.current=!1,{type:"error",error:ye}}finally{P.current=!1,n||m(le.current,vt.Idle),C.current=void 0}},[s,o,i.model,n,r,a.transport,a.config.user?.displayName,a.config.user?.avatarUrl,a.config.user?.id,p,h,v,m,X,e,f,t,g]),K=V.useCallback(async()=>{if(d!==vt.Idle||P.current||!u.length||D.current)return;const j=u[0];P.current=!0,w(G,j.id);try{await J(j.content,j.attachments)}finally{P.current=!1}},[d,u,G,J,w]);V.useEffect(()=>{K()},[K]);const R=V.useCallback(async j=>{if(P.current)return;const A=u.find(Y=>Y.id===j);if(A){D.current=!1,P.current=!0,w(G,j);try{await J(A.content,A.attachments)}finally{P.current=!1}}},[u,G,w,J]),U=V.useCallback(async j=>{const Y=t.current.getDraft().attachments;if(!n&&d!==vt.Idle){k(G,j,Y),t.current?.clearDraft();return}D.current=!1,t.current?.clearDraft(),await J(j,Y)},[d,n,k,G,J,t,x,S]),H=V.useCallback(()=>{D.current=!0;const j=C.current??G;L.current.add(j),a.transport.cancelStream?.(j),E(j),m(j,vt.Idle)},[G,a.transport,E,m]),z=V.useCallback(async j=>{d===vt.Streaming&&H(),await R(j)},[d,H,R]);return{pendingKey:G,queuedMessages:u,activeChatStatus:n?vt.Idle:d,activeChatId:s,removeQueuedMessage:w,handleSubmit:U,handleStop:H,handleQueuedClick:z}},S_e=(e,t)=>{const n=JSON.stringify(t.metadata?.data);let r;for(let a=e.length-1;a>=0;a--){const o=e[a].attachments?.find(F3);if(o){r=o;break}}return!r||r.url!==t.url?!1:JSON.stringify(r.metadata?.data)===n},F3=e=>e.type===exports.AgentAttachmentType.Context&&e.metadata?.kind==="pageContext",N_e=e=>{const t=e.matchAll(/(^|[\s([{])@([a-zA-Z0-9_.-]+)/g),n=new Set,r=[];for(const a of t){const i=a[2],o=i.toLowerCase();n.has(o)||(n.add(o),r.push({type:o==="agent"?"agent":"user",name:i}))}return r.length>0?r:void 0},A_e=({queuedMessages:e,onSendQueued:t,onRemoveQueued:n})=>e.length?N.jsxs("div",{className:"mp-agent-composer-queue",children:[N.jsx("div",{className:"mp-agent-composer-queue-header",children:N.jsxs("span",{children:[e.length," message",e.length>1?"s":""," queued"]})}),N.jsx("div",{className:"mp-agent-composer-queue-items",children:e.map(r=>N.jsxs("div",{className:"mp-agent-composer-queue-item",children:[N.jsxs("span",{className:"mp-agent-composer-queue-item-text",children:[r.content,r.attachments?.length?N.jsxs("span",{style:{marginLeft:8,opacity:.7,display:"inline-flex",alignItems:"center",gap:4},children:[N.jsx(Qi,{size:12}),r.attachments.length]}):null]}),N.jsxs("div",{className:"mp-agent-composer-queue-item-actions",children:[N.jsx("button",{type:"button",className:"mp-agent-composer-queue-button",onClick:()=>t(r.id),"aria-label":"Send queued message",children:N.jsx(Dd,{size:12})}),N.jsx("button",{type:"button",className:"mp-agent-composer-queue-button",onClick:()=>n(r.id),"aria-label":"Remove queued message",children:N.jsx(v5,{size:12})})]})]},r.id))})]}):null;function T_e(e,t){return e.size>t.maxFileSize?{type:"size",message:`File "${e.name}" exceeds maximum size of ${up(t.maxFileSize)}`,fileName:e.name}:null}function C_e(e,t,n){if(e.length+t.filter(s=>s.type==="file").length>n.maxFilesPerMessage)return{type:"count",message:`Maximum ${n.maxFilesPerMessage} files per message allowed`};for(const s of e){const l=T_e(s,n);if(l)return l}const a=t.filter(s=>s.type==="file").reduce((s,l)=>{const u=l.metadata?.size||l.size||0;return s+u},0),i=e.reduce((s,l)=>s+l.size,0);return a+i>n.maxTotalAttachmentsSize?{type:"totalSize",message:`Total attachment size exceeds maximum of ${up(n.maxTotalAttachmentsSize)}`}:null}function up(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,r)*100)/100+" "+n[r]}function R_e(){return{maxFileSize:10*1024*1024,maxTotalAttachmentsSize:50*1024*1024,maxFilesPerMessage:10,allowedMimeTypes:void 0}}const P3=e=>{switch(e.type){case exports.AgentAttachmentType.Link:return N.jsx(g5,{size:12});case exports.AgentAttachmentType.Artifact:return N.jsx(Qi,{size:12});case exports.AgentAttachmentType.Context:switch(e?.metadata?.kind){case"pageContext":return N.jsx($d,{size:12});case"formSnapshot":case"formField":return N.jsx(f5,{size:12});default:return N.jsx(Fd,{size:12})}case exports.AgentAttachmentType.File:default:return N.jsx(m5,{size:12})}},I_e=({attachments:e})=>!e||e.length===0?null:N.jsx("div",{className:"mp-agent-message-attachments","aria-label":"Message attachments",children:e.map((t,n)=>{const r=N.jsxs(N.Fragment,{children:[N.jsx("span",{className:"mp-agent-message-attachment-icon",children:P3(t)}),N.jsx("span",{className:"mp-agent-message-attachment-name",children:t.name})]});return t.url?N.jsx("a",{className:"mp-agent-message-attachment",href:t.url,target:"_blank",rel:"noreferrer",title:t.url,children:r},t.id||n):N.jsx("span",{className:"mp-agent-message-attachment",title:t.mimeType??t.name,children:r},t.id||n)})}),O_e=({attachments:e,onRemove:t,uploadProgress:n,uploadErrors:r})=>{const a=Wt();return!e||e.length===0?null:N.jsx("div",{className:"mp-agent-composer-attachments","aria-label":a.attachments,children:e.map(i=>{const o=n?.get(i.id),s=r?.get(i.name),l=i.metadata?.size||i.size,u=l?` (${up(l)})`:"";return N.jsxs("span",{className:`mp-agent-attachment-chip ${s?"mp-agent-attachment-chip-error":""} ${o?.status==="uploading"?"mp-agent-attachment-chip-uploading":""}`,title:s||i.name,children:[N.jsx("span",{className:"mp-agent-attachment-chip-icon",children:P3(i)}),N.jsxs("span",{className:"mp-agent-attachment-chip-name",title:i.name,children:[i.name,u]}),o?.status==="uploading"&&N.jsxs("span",{className:"mp-agent-attachment-chip-progress",children:[o.progress,"%"]}),s&&N.jsx("span",{className:"mp-agent-attachment-chip-error-text",title:s,children:"⚠"}),t?N.jsx(nn,{size:"sm",icon:"X",type:"button",onClick:d=>{d.preventDefault(),d.stopPropagation(),t(i.id)},"aria-label":`Remove attachment ${i.name}`}):null]},i.id)})})},L_e=e=>{const t=e.trim();if(!t||/\s/.test(t))return;const n=i=>i.replace(/[)\].,;:!?]+$/,"");if(!/^https?:\/\//i.test(t))return;const r=i=>{try{const o=new URL(i);return o.protocol!=="http:"&&o.protocol!=="https:"?void 0:o.toString()}catch{return}},a=n(t);return r(a)},D_e=e=>{try{const t=new URL(e);return t.hostname+(t.pathname&&t.pathname!=="/"?t.pathname:"")}catch{return e}},od="mp-agent:locationchange",f2="__mp_agent_history_patched__",g2=()=>{try{window.dispatchEvent(new Event(od))}catch{}},z_e=()=>{if(typeof window>"u")return;const e=window;if(!e[f2]){e[f2]=!0;try{const t=history.pushState;history.pushState=function(...n){const r=t.apply(this,n);return g2(),r}}catch{}try{const t=history.replaceState;history.replaceState=function(...n){const r=t.apply(this,n);return g2(),r}}catch{}}},$_e=e=>{if(typeof window>"u")return()=>{};z_e();const t=()=>e();return window.addEventListener("popstate",t),window.addEventListener("hashchange",t),window.addEventListener(od,t),()=>{window.removeEventListener("popstate",t),window.removeEventListener("hashchange",t),window.removeEventListener(od,t)}};async function F_e(e,t,n,r){const a=await fetch(r.presignedUrlEndpoint,{method:"POST",credentials:"include",headers:{"Content-Type":"application/json",...r.getAuthHeaders?.()||{}},body:JSON.stringify({filename:e.name,mimeType:e.type||"application/octet-stream",size:e.size,chatId:t,userId:n})});if(!a.ok){const o=await a.text();throw new Error(`Failed to get presigned URL: ${a.status} ${o}`)}const i=await a.json();return{url:i.url,key:i.key}}async function P_e(e,t,n){return new Promise((r,a)=>{const i=new XMLHttpRequest;i.upload.addEventListener("progress",o=>{if(o.lengthComputable&&n){const s=Math.round(o.loaded/o.total*100);n(s)}}),i.addEventListener("load",()=>{i.status>=200&&i.status<300?r():a(new Error(`Upload failed: ${i.status} ${i.statusText}`))}),i.addEventListener("error",()=>{a(new Error("Upload failed: network error"))}),i.addEventListener("abort",()=>{a(new Error("Upload aborted"))}),i.open("PUT",t),i.setRequestHeader("Content-Type",e.type||"application/octet-stream"),i.send(e)})}async function q_e(e,t,n){const r=_t.nanoid(),a={fileId:r,fileName:e.name,progress:0,status:"pending"};try{n.onProgress?.({...a,status:"uploading",progress:0});const{url:i,key:o}=await F_e(e,n.chatId,n.userId,t);return await P_e(e,i,s=>{n.onProgress?.({...a,status:"uploading",progress:s})}),n.onProgress?.({...a,status:"completed",progress:100}),{id:r,type:exports.AgentAttachmentType.File,name:e.name,mimeType:e.type||void 0,size:e.size,metadata:{uploadedAt:new Date().toISOString(),s3Key:o,processingStatus:"pending",size:e.size,lastModified:e.lastModified}}}catch(i){const o=i instanceof Error?i.message:"Unknown error";throw n.onProgress?.({...a,status:"error",error:o}),i}}async function B_e(e,t,n){const r=await Promise.allSettled(e.map(o=>q_e(o,t,n))),a=[],i=[];if(r.forEach((o,s)=>{o.status==="fulfilled"?a.push(o.value):i.push(new Error(`Failed to process ${e[s].name}: ${o.reason}`))}),i.length>0&&a.length===0)throw i[0];return i.length>0&&console.warn("Some files failed to upload:",i),a}const U_e=({options:e,value:t,onChange:n,placeholder:r="Select...",disabled:a=!1,className:i="",triggerClassName:o="",placement:s="bottom-start",searchable:l=!1,searchPlaceholder:u="Search...",searchFilter:d})=>{const[p,m]=V.useState(!1),[h,g]=V.useState(null),[f,w]=V.useState(""),v=V.useRef([]),k=V.useRef(null),{refs:_,floatingStyles:E,context:S,isPositioned:x}=Zd({open:p,onOpenChange:m,placement:s,strategy:"absolute",whileElementsMounted:jd,middleware:[Vd(8),Wd({fallbackPlacements:["top-start","bottom-start","top-end","bottom-end"]}),Gd({padding:8})]}),D=Y5(S,{enabled:!a}),P=Yd(S),C=Qd(S),G=a7e(S,{listRef:v,activeIndex:h,onNavigate:g,enabled:p&&!l,virtual:!1}),{getReferenceProps:X,getFloatingProps:J,getItemProps:K}=Xd(l?[D,P,C]:[D,P,C,G]),R=e.findIndex(Y=>Y.value===t),U=R>=0?e[R]:void 0,H=V.useMemo(()=>{const Y=f.trim().toLowerCase();if(!l||!Y)return e;const O=d?le=>d(le,Y):le=>`${le.label} ${le.description??""}`.toLowerCase().includes(Y);return e.filter(O)},[e,f,l,d]);V.useEffect(()=>{if(!p){g(null),w("");return}l&&setTimeout(()=>k.current?.focus(),0);const Y=H.findIndex(ee=>ee.value===t);g(Y>=0?Y:0)},[p,l,t,H]),V.useEffect(()=>{p&&g(H.length>0?0:null)},[f,H.length,p]);const z=Y=>H.length===0?null:Y<0?H.length-1:Y>=H.length?0:Y,j=Y=>{Y!=null&&v.current[Y]?.scrollIntoView({block:"nearest"})},A=Y=>{n(Y),m(!1),g(null),w("")};return N.jsxs("div",{className:`mp-agent-dropdown ${i}`,children:[N.jsxs("button",{ref:_.setReference,type:"button",className:`mp-agent-dropdown-trigger ${o}`,disabled:a,"aria-expanded":p,"aria-haspopup":"listbox",...X(),children:[N.jsx("span",{className:"mp-agent-dropdown-trigger-content",children:U?N.jsxs(N.Fragment,{children:[U.icon&&N.jsx("span",{className:"mp-agent-dropdown-trigger-icon",children:U.icon}),N.jsx("span",{className:"mp-agent-dropdown-trigger-label",children:U.label})]}):N.jsx("span",{className:"mp-agent-dropdown-trigger-placeholder",children:r})}),N.jsx(zd,{size:16,className:`mp-agent-dropdown-chevron ${p?"open":""}`})]}),p&&N.jsxs("div",{role:"listbox",ref:_.setFloating,style:{...E,opacity:x?1:0,pointerEvents:x?"auto":"none",transition:x?"opacity 0.15s ease-out":"none"},className:"mp-agent-dropdown-menu",...J(),children:[l&&N.jsx("div",{className:"mp-agent-dropdown-search",onKeyDown:Y=>Y.stopPropagation(),children:N.jsx("input",{ref:k,className:"mp-agent-dropdown-search-input",value:f,placeholder:u,onChange:Y=>w(Y.target.value),onKeyDown:Y=>{if(Y.key==="Escape"){Y.preventDefault(),m(!1),w("");return}if(Y.key==="ArrowDown"||Y.key==="ArrowUp"){Y.preventDefault();const ee=Y.key==="ArrowDown"?1:-1,O=h??(ee>0?-1:0),le=z(O+ee);g(le),j(le);return}if(Y.key==="Enter"){if(h==null)return;const ee=H[h];if(!ee)return;Y.preventDefault(),A(ee.value)}}})}),N.jsxs("div",{className:"mp-agent-dropdown-list",children:[H.map((Y,ee)=>N.jsxs("button",{ref:O=>{v.current[ee]=O},type:"button",className:`mp-agent-dropdown-item ${t===Y.value?"selected":""} ${h===ee?"active":""}`,role:"option","aria-selected":t===Y.value,...K({onClick:()=>A(Y.value),onMouseEnter:()=>{g(ee)},onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),A(Y.value))}}),children:[Y.icon&&N.jsx("span",{className:"mp-agent-dropdown-item-icon",children:Y.icon}),N.jsxs("span",{className:"mp-agent-dropdown-item-content",children:[N.jsx("span",{className:"mp-agent-dropdown-item-label",children:Y.label}),Y.description&&N.jsx("span",{className:"mp-agent-dropdown-item-description",children:Y.description})]})]},Y.value)),l&&H.length===0&&N.jsx("div",{className:"mp-agent-dropdown-empty","aria-label":"No results",children:"No results"})]})]})]})},H_e=V.memo(()=>{const e=Ue(),t=be(p=>p.composer),n=be(p=>p.contextKey),r=be(p=>p.setComposerOptions),a=e.config.models,{data:i,isLoading:o}=a3(),s=V.useMemo(()=>{const p=i&&i.length>0?i:a;return w3(p,e.config.transport).filter(h=>!h.contexts?.length||h.contexts.includes(n))},[i,a,e.config.transport,n]),l=V.useMemo(()=>{const p=s.slice().sort((m,h)=>m.label.localeCompare(h.label,void 0,{sensitivity:"base"})).map(m=>({value:m.id,label:m.label}));return[{value:ta,label:"Auto"},...p]},[s]),u=V.useMemo(()=>t.model!==void 0?t.model:ta,[t.model]),d=V.useCallback(p=>{p===ta?(r({model:void 0}),c2(e.config.transport,ta)):(r({model:p}),c2(e.config.transport,p))},[r,e.config.transport]);return o&&!a?.length||l.length===0?null:N.jsx(U_e,{options:l,value:u,onChange:d,placeholder:"Select model...",searchable:!0,searchPlaceholder:"Search models...",placement:"top-start",triggerClassName:"mp-agent-model-selector-trigger"})}),j_e=e=>{if(!e)return"";let t=e.replace(/[_-]+/g," ");return t=t.replace(/([a-z0-9])([A-Z])/g,"$1 $2"),t=t.trim().replace(/\s+/g," "),t?t.charAt(0).toUpperCase()+t.slice(1):""},V_e=({checked:e,disabled:t,onChange:n,className:r="",...a})=>{const i=o=>{o.preventDefault(),!t&&n(!e)};return N.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:t,className:`mp-agent-switch ${e?"on":"off"} ${r}`.trim(),onClick:i,...a,children:N.jsx("span",{className:"mp-agent-switch-thumb"})})},y2=e=>e.reduce((t,n)=>(t[n.agentName]={...n.tools},t),{}),q3=({preferences:e,disabled:t})=>{const n=Wt(),{upsertSingle:r}=u3(),[a,i]=V.useState(()=>y2(e)),[o,s]=V.useState({});V.useEffect(()=>{i(y2(e))},[e]);const l=r.error?.message,u=V.useMemo(()=>e.some(p=>Object.keys(p.tools).length>0),[e]),d=(p,m,h)=>{i(g=>{const f=g[p]??{},w=f,v={...f,[m]:h},k={...g,[p]:v};return s(_=>({..._,[p]:{..._[p]??{},[m]:!0}})),r.mutate({agentName:p,input:{tools:v}},{onError:()=>{i(_=>({..._,[p]:w}))},onSettled:()=>{s(_=>{const E={..._[p]??{}};if(delete E[m],Object.keys(E).length===0){const{[p]:S,...x}=_;return x}return{..._,[p]:E}})}}),k})};return N.jsxs("div",{className:"mp-agent-preferences-panel",children:[!u&&N.jsx("div",{className:"mp-agent-preferences-empty",children:n.agentSettingsNoConfigurableTools}),e.map(p=>{const m=a[p.agentName]??{},h=Object.entries(m);return N.jsxs("div",{className:"mp-agent-preferences-agent",children:[N.jsx("div",{className:"mp-agent-preferences-agent-header",children:N.jsx("strong",{children:p.agentName})}),h.length===0?N.jsx("div",{className:"mp-agent-preferences-empty",children:n.agentSettingsNoToolsForAgent}):N.jsx("div",{className:"mp-agent-preferences-tools",children:h.map(([g,f])=>{const w=!!o[p.agentName]?.[g];return N.jsxs("label",{className:"mp-agent-preferences-tool",children:[N.jsx("span",{className:"mp-agent-preferences-tool-label",children:j_e(g)}),N.jsx(V_e,{checked:f,onChange:v=>d(p.agentName,g,v),disabled:!!t||w})]},`${p.agentName}:${g}`)})})]},p.agentName)}),l&&N.jsx("div",{className:"mp-agent-preferences-error",children:l})]})};function G_e(e){return e.map(t=>{const n=(t.tools??[]).reduce((r,a)=>(a.userConfigurable&&(r[a.title]=!a.disabledByDefault),r),{});return{agentName:t.name,tools:n}})}const W_e=()=>{const e=Wt(),t=Ue(),n=be(l=>l.contextKey),{data:r,isLoading:a,isError:i}=s3(n),o=V.useMemo(()=>G_e(r??[]),[r]),s=!!t.transport.upsertAgentPreferences&&!!t.transport.upsertAgentPreferencesBatch;return a?N.jsx(N.Fragment,{children:e.agentSettingsLoading}):i?N.jsx(N.Fragment,{children:e.agentSettingsError}):N.jsx(q3,{preferences:o,disabled:!s})},K_e=()=>{const[e,t]=V.useState(!1),n=Wt(),{refs:r,floatingStyles:a,context:i,isPositioned:o}=Zd({open:e,onOpenChange:t,placement:"top-start",strategy:"absolute",whileElementsMounted:jd,middleware:[Vd(8),Wd({fallbackPlacements:["bottom-start","top-end","bottom-end"]}),Gd({padding:8})]}),s=Y5(i),l=Yd(i),u=Qd(i),{getReferenceProps:d,getFloatingProps:p}=Xd([s,l,u]);return N.jsxs("div",{className:"mp-agent-tool-config-dropdown",children:[N.jsx(bn,{content:n.agentSettingsTooltip,children:N.jsx("button",{ref:r.setReference,type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button","aria-label":n.agentSettingsTooltip,...d(),children:N.jsx(y5,{size:16})})}),e&&N.jsx("div",{ref:r.setFloating,style:{...a,opacity:o?1:0,pointerEvents:o?"auto":"none",transition:o?"opacity 0.15s ease-out":"none"},className:"mp-agent-tool-config-panel",...p(),children:N.jsx(W_e,{})})]})},Y_e=V.forwardRef(({autoFocus:e,activeChatId:t,status:n,onStop:r,onSubmit:a},i)=>{const o=Wt(),s=Ue(),l=V.useRef(null),u=V.useRef(null),d=be(ae=>ae.activeChatId??ae.draftChatKey),p=be(ae=>ze(ae,d).composerDraft),m=be(ae=>ze(ae,d).composerError),h=be(ae=>ze(ae,d).pageContextDismissed),g=be(ae=>ae.setComposerValue),f=be(ae=>ae.setComposerDraft),w=be(ae=>ae.clearComposerDraft),v=be(ae=>ae.setComposerError),k=be(ae=>ae.addComposerAttachments),_=be(ae=>ae.removeComposerAttachment),E=be(ae=>ae.setPageContextDismissed),S=p.value,x=p.attachments,[D,P]=V.useState(new Map),[C,L]=V.useState(new Map),G=V.useRef(S),X=V.useRef(x),J=V.useRef(h),K=s.config.features?.pageContextAttachments!==!1,R=s.config.composerAttachmentActions,U=ae=>ae.type===exports.AgentAttachmentType.Context&&ae?.metadata?.kind==="pageContext",H=x.some(U),z=()=>{if(K)return s.buildPageContextAttachment()};V.useEffect(()=>{X.current=x},[x]),V.useEffect(()=>{G.current=S},[S]),V.useEffect(()=>{J.current=h},[h]),V.useEffect(()=>{if(!K||h||H)return;const ae=z();ae&&k(d,[ae])},[K,h,H,d,k]),V.useEffect(()=>{if(K&&!(typeof window>"u"))return $_e(()=>{if(J.current)return;const ae=X.current,Se=ae.find(U);if(!Se)return;const qe=z();if(!qe)return;const We={...qe,id:Se.id},Ae=ae.map(ve=>ve.id===Se.id?We:ve);f(d,{value:G.current,attachments:Ae})})},[K,d,f]),V.useImperativeHandle(i,()=>({setValue:ae=>{g(d,ae)},getDraft:()=>({value:S,attachments:x}),setDraft:ae=>{f(d,{value:ae.value,attachments:ae.attachments??[]})},clearDraft:()=>{w(d)},buildPageContextAttachment:()=>z()})),V.useEffect(()=>{const ae=l.current;ae&&(ae.style.height="auto",ae.style.height=`${Math.min(ae.scrollHeight,200)}px`)},[S]);const j=async ae=>{if(!ae||ae.length===0)return;const Se=Array.from(ae),qe=R_e(),We=C_e(Se,x,qe);if(We){L(Ae=>{const ve=new Map(Ae);return Se.forEach(Ge=>{ve.set(Ge.name,We.message)}),ve});return}L(Ae=>{const ve=new Map(Ae);return Se.forEach(Ge=>ve.delete(Ge.name)),ve});try{const Ae=s.config.transport;if(Ae.mode!=="proxy")throw new Error("File uploads are only supported with proxy transport");const ve={presignedUrlEndpoint:`${Ae.baseUrl}/files/upload/presigned`,getAuthHeaders:()=>{const de={};return Ae.headers?Ae.headers:(Ae.apiKey&&(de.Authorization=`Bearer ${Ae.apiKey}`),de)}},Ge=await B_e(Se,ve,{chatId:t,userId:s.config.user?.id,onProgress:de=>{P(Ze=>{const Ke=new Map(Ze);return Ke.set(de.fileId,de),Ke})}});k(d,Ge),setTimeout(()=>{P(de=>{const Ze=new Map(de);return Ge.forEach(Ke=>Ze.delete(Ke.id)),Ze})},2e3)}catch(Ae){const ve=Ae instanceof Error?Ae.message:"Failed to upload files";L(Ge=>{const de=new Map(Ge);return Se.forEach(Ze=>{de.set(Ze.name,ve)}),de})}},A=()=>{u.current?.click()},Y=ae=>{const Se=L_e(ae);if(!Se)return!1;if(x.some(Ae=>Ae.type===exports.AgentAttachmentType.Link&&Ae.url===Se))return!0;const qe=D_e(Se),We={id:_t.nanoid(),url:Se,name:qe,type:exports.AgentAttachmentType.Link};return k(d,[We]),!0},ee=async ae=>{await j(ae.target.files),ae.target.value=""},O=ae=>{const Se=x.find(qe=>qe.id===ae);Se&&U(Se)&&E(d,!0),_(d,ae)},le=()=>{if(typeof window>"u"||typeof document>"u")return!1;const ae=f3(),Se=ae?.selectedText??window.getSelection?.()?.toString()?.trim()??"";if(!Se)return!1;const qe=window.location?.href,We=Se.slice(0,20),Ae=Se.length>20?We+"...":Se,ve=po({kind:"webSnippet",url:qe,title:Ae,selectedText:Se,source:{app:"browser",url:qe},...ae?.target?{target:ae.target}:{}});return k(d,[ve]),!0},fe=ae=>{ae.preventDefault();const Se=S.trim();Se&&(v(d,void 0),a(Se))},ke=ae=>{ae.key==="Enter"&&!ae.shiftKey&&(ae.preventDefault(),fe(ae))},Ce=ae=>{m&&v(d,void 0),g(d,ae.target.value)},$e=ae=>{if(ae.nativeEvent.shiftKey)return;const Se=ae.clipboardData?.getData("text/plain")??"";if(!Se)return;Y(Se)&&ae.preventDefault()},Ve=!!S.trim();return N.jsxs(N.Fragment,{children:[N.jsxs("form",{onSubmit:fe,className:"mp-agent-composer-input-wrapper",id:"composer-form",children:[N.jsx("input",{ref:u,type:"file",multiple:!0,style:{display:"none"},onChange:ee}),N.jsx(O_e,{attachments:x,onRemove:O,uploadProgress:D,uploadErrors:C}),N.jsx("textarea",{rows:2,name:"message",ref:l,value:S,autoFocus:e,className:"mp-agent-composer-textarea",placeholder:t?o.followUp:o.newChat,onChange:Ce,onKeyDown:ke,onPaste:$e})]}),N.jsxs("div",{className:"mp-agent-composer-actions",children:[N.jsxs("div",{className:"mp-agent-composer-actions-left",children:[s.config.features?.modelSwitching&&N.jsx(H_e,{}),s.config.features?.toolConfiguration&&N.jsx(K_e,{}),s.config.features?.fileAttachments&&N.jsx(bn,{content:o.attachFiles,children:N.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:A,"aria-label":o.attachFiles,children:N.jsx(Qi,{size:16})})}),s.config.features?.selectionAttachments&&N.jsx(bn,{content:o.attachSelectionToContext,children:N.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:()=>{le()},"aria-label":o.attachSelectionToContext,children:N.jsx(Fd,{size:16})})}),K&&!H&&N.jsx(bn,{content:"Attach page context",children:N.jsx("button",{type:"button",className:"mp-agent-composer-button mp-agent-composer-tool-button",onClick:()=>{E(d,!1);const ae=z();ae&&k(d,[ae])},"aria-label":"Attach page context",children:N.jsx($d,{size:16})})}),R&&N.jsx(R,{chatKey:d,activeChatId:t,attachments:x,addAttachments:ae=>k(d,ae),removeAttachment:O})]}),N.jsx("div",{className:"mp-agent-composer-actions-right",children:n===vt.Streaming&&!Ve?N.jsx(bn,{content:o.stopStreaming,children:N.jsx("button",{type:"button",onClick:r,"aria-label":o.stopStreaming,className:"mp-agent-composer-button mp-agent-composer-send-button",children:N.jsx(k5,{size:12})})}):N.jsx(bn,{content:Ve?o.sendMessage:o.typeMessageToSend,children:N.jsx("button",{type:"submit",form:"composer-form",disabled:!Ve,"aria-label":o.sendMessage,className:"mp-agent-composer-button mp-agent-composer-send-button",children:N.jsx(Dd,{size:16})})})})]})]})}),B3=({autoFocus:e,multiUser:t=!1,participantIds:n})=>{const r=V.useRef({setValue:()=>{},getDraft:()=>({value:"",attachments:[]}),setDraft:()=>{},clearDraft:()=>{}}),{pendingKey:a,queuedMessages:i,activeChatStatus:o,activeChatId:s,handleSubmit:l,handleStop:u,handleQueuedClick:d,removeQueuedMessage:p}=M_e({composerFormRef:r,multiUser:t,participantIds:n});return N.jsx("div",{className:"mp-agent-composer-wrapper",children:N.jsxs("div",{className:"mp-agent-composer",children:[N.jsx(A_e,{queuedMessages:i,onSendQueued:d,onRemoveQueued:m=>p(a,m)}),N.jsx(Y_e,{status:o,ref:r,autoFocus:e,activeChatId:s,onStop:u,onSubmit:l})]})})};function xr(e,t,n){let r=n.initialDeps??[],a,i=!0;function o(){var s,l,u;let d;n.key&&((s=n.debug)!=null&&s.call(n))&&(d=Date.now());const p=e();if(!(p.length!==r.length||p.some((g,f)=>r[f]!==g)))return a;r=p;let h;if(n.key&&((l=n.debug)!=null&&l.call(n))&&(h=Date.now()),a=t(...p),n.key&&((u=n.debug)!=null&&u.call(n))){const g=Math.round((Date.now()-d)*100)/100,f=Math.round((Date.now()-h)*100)/100,w=f/16,v=(k,_)=>{for(k=String(k);k.length<_;)k=" "+k;return k};console.info(`%c⏱ ${v(f,5)} /${v(g,5)} ms`,`
|
|
8294
8294
|
font-size: .6rem;
|
|
8295
8295
|
font-weight: bold;
|
|
8296
|
-
color: hsl(${Math.max(0,Math.min(120-120*w,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(a),i=!1,a}return o.updateDeps=s=>{r=s},o}function b2(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Z_e=(e,t)=>Math.abs(e-t)<1.01,X_e=(e,t,n)=>{let r;return function(...a){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,a),n)}},k2=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Q_e=e=>e,J_e=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let a=t;a<=n;a++)r.push(a);return r},ewe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const a=o=>{const{width:s,height:l}=o;t({width:Math.round(s),height:Math.round(l)})};if(a(k2(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(o=>{const s=()=>{const l=o[0];if(l?.borderBoxSize){const u=l.borderBoxSize[0];if(u){a({width:u.inlineSize,height:u.blockSize});return}}a(k2(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},v2={passive:!0},_2=typeof window>"u"?!0:"onscrollend"in window,twe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let a=0;const i=e.options.useScrollendEvent&&_2?()=>{}:X_e(r,()=>{t(a,!1)},e.options.isScrollingResetDelay),o=d=>()=>{const{horizontal:p,isRtl:m}=e.options;a=p?n.scrollLeft*(m&&-1||1):n.scrollTop,i(),t(a,d)},s=o(!0),l=o(!1);n.addEventListener("scroll",s,v2);const u=e.options.useScrollendEvent&&_2;return u&&n.addEventListener("scrollend",l,v2),()=>{n.removeEventListener("scroll",s),u&&n.removeEventListener("scrollend",l)}},nwe=(e,t,n)=>{if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},rwe=(e,{adjustments:t=0,behavior:n},r)=>{var a,i;const o=e+t;(i=(a=r.scrollElement)==null?void 0:a.scrollTo)==null||i.call(a,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class awe{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,a;return((a=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:a.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(a=>{a.forEach(i=>{const o=()=>{const s=i.target,l=this.indexFromElement(s);if(!s.isConnected){this.observer.unobserve(s);return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(s,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var a;(a=r())==null||a.disconnect(),n=null},observe:a=>{var i;return(i=r())==null?void 0:i.observe(a,{box:"border-box"})},unobserve:a=>{var i;return(i=r())==null?void 0:i.unobserve(a)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,a])=>{typeof a>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Q_e,rangeExtractor:J_e,onChange:()=>{},measureElement:nwe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,a;(a=(r=this.options).onChange)==null||a.call(r,this,n)},this.maybeNotify=xr(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=i,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const a=new Map,i=new Map;for(let o=r-1;o>=0;o--){const s=n[o];if(a.has(s.lane))continue;const l=i.get(s.lane);if(l==null||s.end>l.end?i.set(s.lane,s):s.end<l.end&&a.set(s.lane,!0),a.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,s)=>o.end===s.end?o.index-s.index:o.end-s.end)[0]:void 0},this.getMeasurementOptions=xr(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(n,r,a,i,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==s&&(this.lanesChangedFlag=!0),this.prevLanes=s,this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:a,getItemKey:i,enabled:o,lanes:s}),{key:!1}),this.getMeasurements=xr(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:a,getItemKey:i,enabled:o,lanes:s},l)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const m of this.laneAssignments.keys())m>=n&&this.laneAssignments.delete(m);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(m=>{this.itemSizeCache.set(m.key,m.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const d=this.measurementsCache.slice(0,u),p=new Array(s).fill(void 0);for(let m=0;m<u;m++){const h=d[m];h&&(p[h.lane]=m)}for(let m=u;m<n;m++){const h=i(m),g=this.laneAssignments.get(m);let f,w;if(g!==void 0&&this.options.lanes>1){f=g;const E=p[f],S=E!==void 0?d[E]:void 0;w=S?S.end+this.options.gap:r+a}else{const E=this.options.lanes===1?d[m-1]:this.getFurthestMeasurement(d,m);w=E?E.end+this.options.gap:r+a,f=E?E.lane:m%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(m,f)}const v=l.get(h),k=typeof v=="number"?v:this.options.estimateSize(m),_=w+k;d[m]={index:m,start:w,size:k,end:_,key:h,lane:f},p[f]=m}return this.measurementsCache=d,d},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=xr(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,a,i)=>this.range=n.length>0&&r>0?iwe({measurements:n,outerSize:r,scrollOffset:a,lanes:i}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=xr(()=>{let n=null,r=null;const a=this.calculateRange();return a&&(n=a.startIndex,r=a.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,a,i,o)=>i===null||o===null?[]:n({startIndex:i,endIndex:o,overscan:r,count:a}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,a=n.getAttribute(r);return a?parseInt(a,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const a=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(a!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,a-i),s=Math.min(this.options.count-1,a+i);return n>=o&&n<=s}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,s)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(s))});return}const r=this.indexFromElement(n),a=this.options.getItemKey(r),i=this.elementsCache.get(a);i!==n&&(i&&this.observer.unobserve(i),this.observer.observe(n),this.elementsCache.set(a,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var a;const i=this.measurementsCache[n];if(!i)return;const o=this.itemSizeCache.get(i.key)??i.size,s=r-o;s!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,s,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",s),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=s,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,r)),this.notify(!1))},this.getVirtualItems=xr(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const a=[];for(let i=0,o=n.length;i<o;i++){const s=n[i],l=r[s];a.push(l)}return a},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return b2(r[U3(0,r.length-1,a=>b2(r[a]).start,n)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(n,r,a=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=n>=o+i?"end":"start"),r==="center"?n+=(a-i)/2:r==="end"&&(n-=i);const s=this.getMaxScrollOffset();return Math.max(Math.min(s,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getSize(),i=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(r==="auto")if(o.end>=i+a-this.options.scrollPaddingEnd)r="end";else if(o.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const s=r==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(s,r,o.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:a="auto"}={})=>{const i=this.getOffsetForAlignment(n,r),o=this.now();this.scrollState={index:null,align:r,behavior:a,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:a="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getOffsetForIndex(n,r);if(!i)return;const[o,s]=i,l=this.now();this.scrollState={index:n,align:s,behavior:a,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const a=this.getScrollOffset()+n,i=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1)a=((n=r[r.length-1])==null?void 0:n.end)??0;else{const i=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&i.some(s=>s===null);){const s=r[o];i[s.lane]===null&&(i[s.lane]=s.end),o--}a=Math.max(...i.filter(s=>s!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:a})=>{this.options.scrollToFn(n,{behavior:a,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,a=r?r[0]:this.scrollState.lastTargetOffset,i=1,o=a!==this.scrollState.lastTargetOffset;if(!o&&Z_e(a,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.scrollState=null;return}}else this.scrollState.stableFrames=0,o&&(this.scrollState.lastTargetOffset=a,this.scrollState.behavior="auto",this._scrollToOffset(a,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const U3=(e,t,n,r)=>{for(;e<=t;){const a=(e+t)/2|0,i=n(a);if(i<r)e=a+1;else if(i>r)t=a-1;else return a}return e>0?e-1:0};function iwe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const a=e.length-1,i=l=>e[l].start;if(e.length<=r)return{startIndex:0,endIndex:a};let o=U3(0,a,i,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){const l=Array(r).fill(0);for(;s<a&&l.some(d=>d<n+t);){const d=e[s];l[d.lane]=d.end,s++}const u=Array(r).fill(n+t);for(;o>=0&&u.some(d=>d>=n);){const d=e[o];u[d.lane]=d.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}const w2=typeof document<"u"?te.useLayoutEffect:te.useEffect;function owe({useFlushSync:e=!0,...t}){const n=te.useReducer(()=>({}),{})[1],r={...t,onChange:(i,o)=>{var s;e&&o?a5.flushSync(n):n(),(s=t.onChange)==null||s.call(t,i,o)}},[a]=te.useState(()=>new awe(r));return a.setOptions(r),w2(()=>a._didMount(),[]),w2(()=>a._willUpdate()),a}function swe(e){return owe({observeElementRect:ewe,observeElementOffset:twe,scrollToFn:rwe,...e})}const H3=V.memo(()=>{const e=be(n=>n.activeChatId??n.draftChatKey),t=be(n=>ze(n,e).composerError);return t?N.jsx("div",{className:"mp-agent-composer-error",children:t}):null});H3.displayName="ComposerError";const lwe=(e,t)=>{switch(e.status){case exports.AgentToolCallStatus.Running:return`Running ${t}...`;case exports.AgentToolCallStatus.Succeeded:return`Completed ${t}`;case exports.AgentToolCallStatus.Failed:return`Failed to run ${t}`;case exports.AgentToolCallStatus.Pending:return`Preparing ${t}...`;default:return`Running ${t}...`}},es=e=>{if(e===void 0)return"undefined";try{return JSON.stringify(e,null,2)??"undefined"}catch{try{return String(e)}catch{return"[unserializable]"}}},x2=({call:e})=>Ue().config.debug?N.jsxs("details",{className:"mp-agent-tool-debug-details",children:[N.jsx("summary",{className:"mp-agent-tool-debug-summary",children:"Details"}),N.jsxs("div",{className:"mp-agent-tool-debug-body",children:[N.jsxs("div",{className:"mp-agent-tool-debug-row",children:[N.jsx("div",{className:"mp-agent-tool-debug-label",children:"Tool"}),N.jsx("div",{className:"mp-agent-tool-debug-value",children:e.name})]}),N.jsxs("div",{className:"mp-agent-tool-debug-row",children:[N.jsx("div",{className:"mp-agent-tool-debug-label",children:"Status"}),N.jsx("div",{className:"mp-agent-tool-debug-value",children:e.status})]}),N.jsxs("details",{className:"mp-agent-tool-debug-section",children:[N.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Input"}),N.jsx("pre",{className:"mp-agent-tool-debug-code",children:N.jsx("code",{children:es(e.input)})})]}),N.jsxs("details",{className:"mp-agent-tool-debug-section",children:[N.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Output"}),N.jsx("pre",{className:"mp-agent-tool-debug-code",children:N.jsx("code",{children:es(e.output)})})]}),e.error&&N.jsxs("details",{className:"mp-agent-tool-debug-section",children:[N.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Error"}),N.jsx("pre",{className:"mp-agent-tool-debug-code",children:N.jsx("code",{children:es(e.error)})})]})]})]}):null,E2=({call:e,isExpandable:t=!1,isExpanded:n=!1,onToggleExpand:r})=>{const a=Ue(),i=V.useRef(!1),o=e.status===exports.AgentToolCallStatus.Succeeded||e.status===exports.AgentToolCallStatus.Failed,s=t||a.config.debug&&!o,l=s||t;if(V.useEffect(()=>{!t||o||n||i.current||(i.current=!0,r?.())},[t,o,n,r]),!l)return null;const d=a.tools.get(e.name)?.label??e.name,p=lwe(e,d);return N.jsxs("div",{className:"mp-agent-tool-header",children:[s&&N.jsx("div",{className:"mp-agent-tool-simple-message",children:p}),t&&N.jsx("button",{className:"mp-agent-subagent-preview-toggle",type:"button",onClick:r,"aria-expanded":n,children:n?N.jsx(h5,{size:14}):N.jsx(zd,{size:14})})]})};function cwe(e){try{const t=JSON.parse(e);return{question:typeof t.question=="string"?t.question:void 0,selectedOptions:Array.isArray(t.selectedOptions)?t.selectedOptions:void 0,freeText:typeof t.freeText=="string"?t.freeText:void 0}}catch{return e}}const j3=({call:e})=>{if(e.approved===void 0)return null;const t=e.userResponse?cwe(e.userResponse):null,n=()=>{if(!t)return null;if(typeof t=="string")return N.jsx("span",{className:"mp-agent-tool-approval-response",children:t});const r=t.freeText??t.selectedOptions?.map(a=>a.label).join(", ");return!t.question&&!r?null:N.jsxs("div",{className:"mp-agent-tool-approval-result",children:[t.question&&N.jsx("span",{className:"mp-agent-tool-approval-question",children:t.question}),r&&N.jsx("span",{className:"mp-agent-tool-approval-response",children:r})]})};return N.jsxs("div",{className:"mp-agent-tool-approval-status-inline",children:[e.approved?N.jsx("div",{className:"mp-agent-tool-approved",children:N.jsx("span",{children:"✓ Approved"})}):N.jsx("span",{className:"mp-agent-tool-denied",children:"✗ Denied"}),e.approved&&n()]})},uwe=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.question,n=e.selectionMode,r=e.options,a=e.allowFreeText;if(typeof t!="string"||t.trim().length<1||n!=="single"&&n!=="multiple"||!Array.isArray(r)||r.length<2||r.length>6)return null;const i=r.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))return null;const s=o.id,l=o.label,u=o.description;return typeof s!="string"||s.trim().length<1||typeof l!="string"||l.trim().length<1||u!==void 0&&typeof u!="string"?null:{id:s,label:l,...typeof u=="string"?{description:u}:{}}}).filter(o=>o!==null);return i.length!==r.length?null:{question:t,selectionMode:n,options:i,allowFreeText:typeof a=="boolean"?a:!1}},dwe=({callId:e,input:t,isSubmitting:n,onSubmit:r})=>{const[a,i]=V.useState([]),[o,s]=V.useState(""),[l,u]=V.useState(void 0),d=V.useMemo(()=>uwe(t),[t]);V.useEffect(()=>{i([]),s(""),u(void 0)},[e,t]);const p=h=>{if(d){if(u(void 0),d.selectionMode==="single"){i([h]);return}i(g=>g.includes(h)?g.filter(f=>f!==h):[...g,h])}},m=async()=>{if(!d)return;const h=o.trim(),g=a.length>0,f=d.allowFreeText&&h.length>0;if(!g&&!f){u(d.allowFreeText?"Select at least one option or provide a custom response.":"Select at least one option before submitting.");return}const w=d.options.filter(k=>a.includes(k.id)).map(({id:k,label:_,description:E})=>({id:k,label:_,...E?{description:E}:{}})),v={question:d.question,selectionMode:d.selectionMode,selectedOptionIds:a,selectedOptions:w,...h?{freeText:h}:{}};await r(JSON.stringify(v))};return d?N.jsxs("div",{className:"mp-agent-tool-user-action-form",children:[N.jsx("div",{className:"mp-agent-tool-user-action-question",children:d.question}),N.jsx("div",{className:"mp-agent-tool-user-action-options",children:d.options.map(h=>{const g=`${e}-${h.id}`,f=a.includes(h.id);return N.jsxs("label",{htmlFor:g,className:"mp-agent-tool-user-action-option",children:[N.jsx("input",{id:g,type:d.selectionMode==="single"?"radio":"checkbox",name:`mp-agent-tool-user-action-${e}`,checked:f,onChange:()=>p(h.id),disabled:n}),N.jsxs("span",{className:"mp-agent-tool-user-action-option-content",children:[N.jsx("span",{className:"mp-agent-tool-user-action-option-label",children:h.label}),h.description?N.jsx("span",{className:"mp-agent-tool-user-action-option-description",children:h.description}):null]})]},h.id)})}),d.allowFreeText?N.jsx("textarea",{className:"mp-agent-tool-user-action-free-text",value:o,onChange:h=>{s(h.target.value),l&&u(void 0)},placeholder:"Optional custom response",rows:3,disabled:n}):null,l?N.jsx("div",{className:"mp-agent-tool-input-error",children:l}):null,N.jsx("div",{className:"mp-agent-tool-approval-actions",children:N.jsx("button",{className:"mp-agent-tool-approve-button",onClick:m,disabled:n,children:n?"Submitting...":"Submit response"})})]}):N.jsx("div",{className:"mp-agent-tool-user-action-form",children:N.jsx("div",{className:"mp-agent-tool-input-error",children:"Invalid user action input schema in tool call."})})},pwe=({call:e,messageId:t,chatId:n,onApprovalSent:r})=>{const a=Ue(),i=a.tools.get(e.name)?.label??e.name,o=be(D=>D.appendMessagesToChat),[s,l]=V.useState(!1),[u,d]=V.useState(!1),[p,m]=V.useState(!1),[h,g]=V.useState(JSON.stringify(e.input??{},null,2)),[f,w]=V.useState(void 0),v=a.config.user?.id??"guest",k=e.requiresUserAction;V.useEffect(()=>{u||(g(JSON.stringify(e.input??{},null,2)),w(void 0))},[e.id,e.input,u]);const _=()=>{g(JSON.stringify(e.input??{},null,2)),w(void 0),d(!0)},E=()=>{g(JSON.stringify(e.input??{},null,2)),w(void 0),d(!1)},S=async()=>{if(!(!a.transport.updateToolCall||p||s)){w(void 0),m(!0);try{const D=JSON.parse(h);if(!D||typeof D!="object"||Array.isArray(D))throw new Error("Tool input must be a JSON object.");const P=await a.transport.updateToolCall({chatId:n,messageId:t,toolCallId:e.id,input:D});o(n,[P]),d(!1)}catch(D){w(D instanceof Error?D.message:"Failed to update tool input.")}finally{m(!1)}}},x=async(D,P)=>{if(!(!e.approvalId||s||p||u)){l(!0);try{const C={chatId:n,messageId:t,approvalId:e.approvalId,approved:D,...P?{userResponse:P}:{},userId:v},L=await a.transport.streamMessage(C,G=>{G.type===exports.StreamChunkType.Message&&G.message&&o(n,[G.message])},{streamKey:n});L?o(L.id,L.messages):r()}catch(C){console.error("Failed to send approval:",C)}finally{l(!1)}}};return e.approved!==void 0?N.jsx(j3,{call:e}):k?N.jsx(dwe,{callId:e.id,input:e.input,isSubmitting:s,onSubmit:D=>x(!0,D)}):N.jsxs("div",{className:"mp-agent-tool-approval-buttons",children:[N.jsxs("div",{className:"mp-agent-tool-approval-request-message",children:["Agent wants to execute tool ",i,"."]}),N.jsxs("div",{className:"mp-agent-tool-input-card",children:[N.jsxs("div",{className:"mp-agent-tool-input-card-header",children:[N.jsx("span",{className:"mp-agent-tool-input-card-title",children:"Tool input"}),u?N.jsxs("div",{className:"mp-agent-tool-input-actions",children:[N.jsx(nn,{icon:"Check",size:"sm",tooltip:"Save tool input",onClick:S,disabled:p||s,"aria-label":"Save tool input"}),N.jsx(nn,{icon:"X",size:"sm",tooltip:"Cancel input edit",onClick:E,disabled:p||s,"aria-label":"Cancel tool input edit"})]}):N.jsx(nn,{icon:"Pencil",size:"sm",tooltip:"Edit tool input",onClick:_,disabled:s||p,"aria-label":"Edit tool input"})]}),u?N.jsx("textarea",{className:"mp-agent-tool-input-editor",value:h,onChange:D=>{g(D.target.value),f&&w(void 0)},rows:8,spellCheck:!1,disabled:p||s}):N.jsx("pre",{className:"mp-agent-tool-input-preview",children:JSON.stringify(e.input??{},null,2)}),f&&N.jsx("div",{className:"mp-agent-tool-input-error",children:f})]}),N.jsxs("div",{className:"mp-agent-tool-approval-actions",children:[N.jsx("button",{className:"mp-agent-tool-approve-button",onClick:()=>x(!0),disabled:s||u||p,children:s?"Processing...":"Approve"}),N.jsx("button",{className:"mp-agent-tool-deny-button",onClick:()=>x(!1),disabled:s||p,children:s?"Processing...":"Deny"})]})]})},M2=({call:e,messageId:t,chatId:n})=>{const r=Ue(),a=be(d=>d.upsertChat),i=r.config.debug&&!!e.approvalId,o=e.requiresConfirmation&&e.approvalId||i,s=o&&e.approved===void 0,l=o&&e.approved!==void 0,u=async()=>{try{const d=await r.transport.getChat(n);a(d)}catch(d){console.error("Failed to refresh chat after approval:",d)}};return!s&&!l?null:N.jsxs("div",{className:"mp-agent-tool-approval",children:[s&&N.jsx(pwe,{call:e,messageId:t,chatId:n,onApprovalSent:u}),l&&N.jsx(j3,{call:e})]})},S2=({chatId:e,isExpanded:t})=>{const n=Ue(),r=be(l=>ze(l,e).messages),a=be(l=>ze(l,e).pendingAssistant),i=be(l=>l.chats[e]?.contextKey??l.contextKey),o=np(e),s=V.useMemo(()=>{const l=[...r].sort((d,p)=>d.createdAt.localeCompare(p.createdAt));if(n.config.debug)return l;const u=l.findIndex(d=>d.role===exports.MessageRole.User);return u===-1?l:l.filter((d,p)=>p!==u)},[r,n.config.debug]);return N.jsx("div",{className:"mp-agent-subagent-preview",children:t&&N.jsx("div",{className:"mp-agent-subagent-preview-body",children:s.length===0&&!a?N.jsx("div",{className:"mp-agent-subagent-preview-empty",children:o.isLoading?"Loading subagent chat...":"Subagent chat started."}):N.jsxs(N.Fragment,{children:[s.map(l=>N.jsx(Zi,{message:l,contextKey:i},l.id)),a&&N.jsx(Zi,{message:a,contextKey:i,isStreaming:!0})]})})})},hwe=({call:e,contextKey:t,messageId:n,chatId:r})=>{const a=Ue(),i=e.subagentChatId||(typeof e.input?.subagentChatId=="string"?e.input.subagentChatId:void 0),[o,s]=V.useState(!1),l=V.useMemo(()=>a.getToolRenderer(e),[a,e]);return l?N.jsxs("div",{className:"mp-agent-tool-panel",children:[i&&N.jsx(E2,{call:e,isExpandable:!0,isExpanded:o,onToggleExpand:()=>s(u=>!u)}),N.jsx(l,{call:e,contextKey:t,chatId:r}),N.jsx(M2,{call:e,messageId:n,chatId:r}),i&&N.jsx(S2,{chatId:i,isExpanded:o}),!i&&N.jsx(x2,{call:e})]}):N.jsxs("div",{className:"mp-agent-tool-panel",children:[N.jsx(E2,{call:e,isExpandable:!!i,isExpanded:o,onToggleExpand:()=>s(u=>!u)}),N.jsx(M2,{call:e,messageId:n,chatId:r}),i&&N.jsx(S2,{chatId:i,isExpanded:o}),!i&&N.jsx(x2,{call:e})]})},mwe=e=>{const t=e.sender?.displayName||e.sender?.id||e.agentName;if(!t)return e.role===exports.MessageRole.User?"You":"AI";const n=t.split(/\s+/).filter(Boolean);return n.length>=2?`${n[0][0]}${n[1][0]}`.toUpperCase():t.slice(0,2).toUpperCase()},dp=V.memo(({message:e,isGrouped:t})=>{if(t)return N.jsx("div",{className:"mp-agent-message-avatar-spacer"});const n=e.role===exports.MessageRole.User;return N.jsx("div",{className:`mp-agent-message-avatar ${n?"mp-agent-message-avatar-user":""}`,children:e.sender?.avatarUrl?N.jsx("img",{className:"mp-agent-message-avatar-image",src:e.sender.avatarUrl,alt:""}):N.jsx("div",{className:"mp-agent-message-avatar-icon",children:mwe(e)})})});dp.displayName="MessageAvatar";const fwe=e=>e?new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):"",gwe=e=>e.sender?.displayName?e.sender.displayName:e.sender?.id&&e.sender.id!=="guest"?e.sender.id:e.agentName?e.agentName:e.role===exports.MessageRole.User?"You":"Assistant",pp=V.memo(({message:e,isGrouped:t})=>{if(t)return null;const n=gwe(e);return N.jsxs("div",{className:"mp-agent-message-header",children:[N.jsx("span",{className:"mp-agent-message-role",children:n}),N.jsx("span",{className:"mp-agent-message-time",children:fwe(e.createdAt)})]})});pp.displayName="MessageHeader";function N2(e){const t=[],n=String(e||"");let r=n.indexOf(","),a=0,i=!1;for(;!i;){r===-1&&(r=n.length,i=!0);const o=n.slice(a,r).trim();(o||!i)&&t.push(o),a=r+1,r=n.indexOf(",",a)}return t}function ywe(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const bwe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kwe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vwe={};function A2(e,t){return(vwe.jsx?kwe:bwe).test(e)}const _we=/[ \t\n\f\r]/g;function wwe(e){return typeof e=="object"?e.type==="text"?T2(e.value):!1:T2(e)}function T2(e){return e.replace(_we,"")===""}let Ia=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Ia.prototype.normal={};Ia.prototype.property={};Ia.prototype.space=void 0;function V3(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Ia(n,r,t)}function ya(e){return e.toLowerCase()}let Ft=class{constructor(t,n){this.attribute=n,this.property=t}};Ft.prototype.attribute="";Ft.prototype.booleanish=!1;Ft.prototype.boolean=!1;Ft.prototype.commaOrSpaceSeparated=!1;Ft.prototype.commaSeparated=!1;Ft.prototype.defined=!1;Ft.prototype.mustUseProperty=!1;Ft.prototype.number=!1;Ft.prototype.overloadedBoolean=!1;Ft.prototype.property="";Ft.prototype.spaceSeparated=!1;Ft.prototype.space=void 0;let xwe=0;const Re=yr(),lt=yr(),sd=yr(),se=yr(),Qe=yr(),$r=yr(),Ut=yr();function yr(){return 2**++xwe}const ld=Object.freeze(Object.defineProperty({__proto__:null,boolean:Re,booleanish:lt,commaOrSpaceSeparated:Ut,commaSeparated:$r,number:se,overloadedBoolean:sd,spaceSeparated:Qe},Symbol.toStringTag,{value:"Module"})),ts=Object.keys(ld);let hp=class extends Ft{constructor(t,n,r,a){let i=-1;if(super(t,n),C2(this,"space",a),typeof r=="number")for(;++i<ts.length;){const o=ts[i];C2(this,ts[i],(r&ld[o])===ld[o])}}};hp.prototype.defined=!0;function C2(e,t,n){n&&(e[t]=n)}function Vr(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const i=new hp(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ya(r)]=r,n[ya(i.attribute)]=r}return new Ia(t,n,e.space)}const G3=Vr({properties:{ariaActiveDescendant:null,ariaAtomic:lt,ariaAutoComplete:null,ariaBusy:lt,ariaChecked:lt,ariaColCount:se,ariaColIndex:se,ariaColSpan:se,ariaControls:Qe,ariaCurrent:null,ariaDescribedBy:Qe,ariaDetails:null,ariaDisabled:lt,ariaDropEffect:Qe,ariaErrorMessage:null,ariaExpanded:lt,ariaFlowTo:Qe,ariaGrabbed:lt,ariaHasPopup:null,ariaHidden:lt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qe,ariaLevel:se,ariaLive:null,ariaModal:lt,ariaMultiLine:lt,ariaMultiSelectable:lt,ariaOrientation:null,ariaOwns:Qe,ariaPlaceholder:null,ariaPosInSet:se,ariaPressed:lt,ariaReadOnly:lt,ariaRelevant:null,ariaRequired:lt,ariaRoleDescription:Qe,ariaRowCount:se,ariaRowIndex:se,ariaRowSpan:se,ariaSelected:lt,ariaSetSize:se,ariaSort:null,ariaValueMax:se,ariaValueMin:se,ariaValueNow:se,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function W3(e,t){return t in e?e[t]:t}function K3(e,t){return W3(e,t.toLowerCase())}const Ewe=Vr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$r,acceptCharset:Qe,accessKey:Qe,action:null,allow:null,allowFullScreen:Re,allowPaymentRequest:Re,allowUserMedia:Re,alt:null,as:null,async:Re,autoCapitalize:null,autoComplete:Qe,autoFocus:Re,autoPlay:Re,blocking:Qe,capture:null,charSet:null,checked:Re,cite:null,className:Qe,cols:se,colSpan:null,content:null,contentEditable:lt,controls:Re,controlsList:Qe,coords:se|$r,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Re,defer:Re,dir:null,dirName:null,disabled:Re,download:sd,draggable:lt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Re,formTarget:null,headers:Qe,height:se,hidden:sd,high:se,href:null,hrefLang:null,htmlFor:Qe,httpEquiv:Qe,id:null,imageSizes:null,imageSrcSet:null,inert:Re,inputMode:null,integrity:null,is:null,isMap:Re,itemId:null,itemProp:Qe,itemRef:Qe,itemScope:Re,itemType:Qe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Re,low:se,manifest:null,max:null,maxLength:se,media:null,method:null,min:null,minLength:se,multiple:Re,muted:Re,name:null,nonce:null,noModule:Re,noValidate:Re,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:Re,optimum:se,pattern:null,ping:Qe,placeholder:null,playsInline:Re,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Re,referrerPolicy:null,rel:Qe,required:Re,reversed:Re,rows:se,rowSpan:se,sandbox:Qe,scope:null,scoped:Re,seamless:Re,selected:Re,shadowRootClonable:Re,shadowRootDelegatesFocus:Re,shadowRootMode:null,shape:null,size:se,sizes:null,slot:null,span:se,spellCheck:lt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:se,step:null,style:null,tabIndex:se,target:null,title:null,translate:null,type:null,typeMustMatch:Re,useMap:null,value:lt,width:se,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qe,axis:null,background:null,bgColor:null,border:se,borderColor:null,bottomMargin:se,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Re,declare:Re,event:null,face:null,frame:null,frameBorder:null,hSpace:se,leftMargin:se,link:null,longDesc:null,lowSrc:null,marginHeight:se,marginWidth:se,noResize:Re,noHref:Re,noShade:Re,noWrap:Re,object:null,profile:null,prompt:null,rev:null,rightMargin:se,rules:null,scheme:null,scrolling:lt,standby:null,summary:null,text:null,topMargin:se,valueType:null,version:null,vAlign:null,vLink:null,vSpace:se,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Re,disableRemotePlayback:Re,prefix:null,property:null,results:se,security:null,unselectable:null},space:"html",transform:K3}),Mwe=Vr({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:Ut,accentHeight:se,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:se,amplitude:se,arabicForm:null,ascent:se,attributeName:null,attributeType:null,azimuth:se,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:se,by:null,calcMode:null,capHeight:se,className:Qe,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:se,diffuseConstant:se,direction:null,display:null,dur:null,divisor:se,dominantBaseline:null,download:Re,dx:null,dy:null,edgeMode:null,editable:null,elevation:se,enableBackground:null,end:null,event:null,exponent:se,externalResourcesRequired:null,fill:null,fillOpacity:se,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:$r,g2:$r,glyphName:$r,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:se,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:se,horizOriginX:se,horizOriginY:se,id:null,ideographic:se,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:se,k:se,k1:se,k2:se,k3:se,k4:se,kernelMatrix:Ut,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:se,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:se,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:se,overlineThickness:se,paintOrder:null,panose1:null,path:null,pathLength:se,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Qe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:se,pointsAtY:se,pointsAtZ:se,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ut,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ut,rev:Ut,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ut,requiredFeatures:Ut,requiredFonts:Ut,requiredFormats:Ut,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:se,specularExponent:se,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:se,strikethroughThickness:se,string:null,stroke:null,strokeDashArray:Ut,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:se,strokeOpacity:se,strokeWidth:null,style:null,surfaceScale:se,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ut,tabIndex:se,tableValues:null,target:null,targetX:se,targetY:se,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ut,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:se,underlineThickness:se,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:se,values:null,vAlphabetic:se,vMathematical:se,vectorEffect:null,vHanging:se,vIdeographic:se,version:null,vertAdvY:se,vertOriginX:se,vertOriginY:se,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:se,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:W3}),Y3=Vr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Z3=Vr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:K3}),X3=Vr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Swe={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"},Nwe=/[A-Z]/g,R2=/-[a-z]/g,Awe=/^data[-\w.:]+$/i;function Q3(e,t){const n=ya(t);let r=t,a=Ft;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Awe.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(R2,Cwe);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!R2.test(i)){let o=i.replace(Nwe,Twe);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=hp}return new a(r,t)}function Twe(e){return"-"+e.toLowerCase()}function Cwe(e){return e.charAt(1).toUpperCase()}const J3=V3([G3,Ewe,Y3,Z3,X3],"html"),fo=V3([G3,Mwe,Y3,Z3,X3],"svg");function I2(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Rwe(e){return e.join(" ").trim()}var Jn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function go(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mp={},O2=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Iwe=/\n/g,Owe=/^\s*/,Lwe=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Dwe=/^:\s*/,zwe=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,$we=/^[;\s]*/,Fwe=/^\s+|\s+$/g,Pwe=`
|
|
8296
|
+
color: hsl(${Math.max(0,Math.min(120-120*w,120))}deg 100% 31%);`,n?.key)}return n?.onChange&&!(i&&n.skipInitialOnChange)&&n.onChange(a),i=!1,a}return o.updateDeps=s=>{r=s},o}function b2(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const Z_e=(e,t)=>Math.abs(e-t)<1.01,X_e=(e,t,n)=>{let r;return function(...a){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,a),n)}},k2=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Q_e=e=>e,J_e=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let a=t;a<=n;a++)r.push(a);return r},ewe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const a=o=>{const{width:s,height:l}=o;t({width:Math.round(s),height:Math.round(l)})};if(a(k2(n)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(o=>{const s=()=>{const l=o[0];if(l?.borderBoxSize){const u=l.borderBoxSize[0];if(u){a({width:u.inlineSize,height:u.blockSize});return}}a(k2(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()});return i.observe(n,{box:"border-box"}),()=>{i.unobserve(n)}},v2={passive:!0},_2=typeof window>"u"?!0:"onscrollend"in window,twe=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let a=0;const i=e.options.useScrollendEvent&&_2?()=>{}:X_e(r,()=>{t(a,!1)},e.options.isScrollingResetDelay),o=d=>()=>{const{horizontal:p,isRtl:m}=e.options;a=p?n.scrollLeft*(m&&-1||1):n.scrollTop,i(),t(a,d)},s=o(!0),l=o(!1);n.addEventListener("scroll",s,v2);const u=e.options.useScrollendEvent&&_2;return u&&n.addEventListener("scrollend",l,v2),()=>{n.removeEventListener("scroll",s),u&&n.removeEventListener("scrollend",l)}},nwe=(e,t,n)=>{if(t?.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},rwe=(e,{adjustments:t=0,behavior:n},r)=>{var a,i;const o=e+t;(i=(a=r.scrollElement)==null?void 0:a.scrollTo)==null||i.call(a,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class awe{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,a;return((a=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:a.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(a=>{a.forEach(i=>{const o=()=>{const s=i.target,l=this.indexFromElement(s);if(!s.isConnected){this.observer.unobserve(s);return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(s,i,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var a;(a=r())==null||a.disconnect(),n=null},observe:a=>{var i;return(i=r())==null?void 0:i.observe(a,{box:"border-box"})},unobserve:a=>{var i;return(i=r())==null?void 0:i.unobserve(a)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,a])=>{typeof a>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Q_e,rangeExtractor:J_e,onChange:()=>{},measureElement:nwe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,a;(a=(r=this.options).onChange)==null||a.call(r,this,n)},this.maybeNotify=xr(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=i,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const a=new Map,i=new Map;for(let o=r-1;o>=0;o--){const s=n[o];if(a.has(s.lane))continue;const l=i.get(s.lane);if(l==null||s.end>l.end?i.set(s.lane,s):s.end<l.end&&a.set(s.lane,!0),a.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((o,s)=>o.end===s.end?o.index-s.index:o.end-s.end)[0]:void 0},this.getMeasurementOptions=xr(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(n,r,a,i,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==s&&(this.lanesChangedFlag=!0),this.prevLanes=s,this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:a,getItemKey:i,enabled:o,lanes:s}),{key:!1}),this.getMeasurements=xr(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:a,getItemKey:i,enabled:o,lanes:s},l)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const m of this.laneAssignments.keys())m>=n&&this.laneAssignments.delete(m);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(m=>{this.itemSizeCache.set(m.key,m.size)}));const u=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const d=this.measurementsCache.slice(0,u),p=new Array(s).fill(void 0);for(let m=0;m<u;m++){const h=d[m];h&&(p[h.lane]=m)}for(let m=u;m<n;m++){const h=i(m),g=this.laneAssignments.get(m);let f,w;if(g!==void 0&&this.options.lanes>1){f=g;const E=p[f],S=E!==void 0?d[E]:void 0;w=S?S.end+this.options.gap:r+a}else{const E=this.options.lanes===1?d[m-1]:this.getFurthestMeasurement(d,m);w=E?E.end+this.options.gap:r+a,f=E?E.lane:m%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(m,f)}const v=l.get(h),k=typeof v=="number"?v:this.options.estimateSize(m),_=w+k;d[m]={index:m,start:w,size:k,end:_,key:h,lane:f},p[f]=m}return this.measurementsCache=d,d},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=xr(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,a,i)=>this.range=n.length>0&&r>0?iwe({measurements:n,outerSize:r,scrollOffset:a,lanes:i}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=xr(()=>{let n=null,r=null;const a=this.calculateRange();return a&&(n=a.startIndex,r=a.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,a,i,o)=>i===null||o===null?[]:n({startIndex:i,endIndex:o,overscan:r,count:a}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,a=n.getAttribute(r);return a?parseInt(a,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const a=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(a!==void 0&&this.range){const i=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),o=Math.max(0,a-i),s=Math.min(this.options.count-1,a+i);return n>=o&&n<=s}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((o,s)=>{o.isConnected||(this.observer.unobserve(o),this.elementsCache.delete(s))});return}const r=this.indexFromElement(n),a=this.options.getItemKey(r),i=this.elementsCache.get(a);i!==n&&(i&&this.observer.unobserve(i),this.observer.observe(n),this.elementsCache.set(a,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var a;const i=this.measurementsCache[n];if(!i)return;const o=this.itemSizeCache.get(i.key)??i.size,s=r-o;s!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,s,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",s),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=s,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,r)),this.notify(!1))},this.getVirtualItems=xr(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const a=[];for(let i=0,o=n.length;i<o;i++){const s=n[i],l=r[s];a.push(l)}return a},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return b2(r[U3(0,r.length-1,a=>b2(r[a]).start,n)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(n,r,a=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),o=this.getScrollOffset();r==="auto"&&(r=n>=o+i?"end":"start"),r==="center"?n+=(a-i)/2:r==="end"&&(n-=i);const s=this.getMaxScrollOffset();return Math.max(Math.min(s,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getSize(),i=this.getScrollOffset(),o=this.measurementsCache[n];if(!o)return;if(r==="auto")if(o.end>=i+a-this.options.scrollPaddingEnd)r="end";else if(o.start<=i+this.options.scrollPaddingStart)r="start";else return[i,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const s=r==="end"?o.end+this.options.scrollPaddingEnd:o.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(s,r,o.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:a="auto"}={})=>{const i=this.getOffsetForAlignment(n,r),o=this.now();this.scrollState={index:null,align:r,behavior:a,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:a="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.getOffsetForIndex(n,r);if(!i)return;const[o,s]=i,l=this.now();this.scrollState={index:n,align:s,behavior:a,startedAt:l,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const a=this.getScrollOffset()+n,i=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1)a=((n=r[r.length-1])==null?void 0:n.end)??0;else{const i=Array(this.options.lanes).fill(null);let o=r.length-1;for(;o>=0&&i.some(s=>s===null);){const s=r[o];i[s.lane]===null&&(i[s.lane]=s.end),o--}a=Math.max(...i.filter(s=>s!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:a})=>{this.options.scrollToFn(n,{behavior:a,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,a=r?r[0]:this.scrollState.lastTargetOffset,i=1,o=a!==this.scrollState.lastTargetOffset;if(!o&&Z_e(a,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=i){this.scrollState=null;return}}else this.scrollState.stableFrames=0,o&&(this.scrollState.lastTargetOffset=a,this.scrollState.behavior="auto",this._scrollToOffset(a,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const U3=(e,t,n,r)=>{for(;e<=t;){const a=(e+t)/2|0,i=n(a);if(i<r)e=a+1;else if(i>r)t=a-1;else return a}return e>0?e-1:0};function iwe({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const a=e.length-1,i=l=>e[l].start;if(e.length<=r)return{startIndex:0,endIndex:a};let o=U3(0,a,i,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){const l=Array(r).fill(0);for(;s<a&&l.some(d=>d<n+t);){const d=e[s];l[d.lane]=d.end,s++}const u=Array(r).fill(n+t);for(;o>=0&&u.some(d=>d>=n);){const d=e[o];u[d.lane]=d.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}const w2=typeof document<"u"?te.useLayoutEffect:te.useEffect;function owe({useFlushSync:e=!0,...t}){const n=te.useReducer(()=>({}),{})[1],r={...t,onChange:(i,o)=>{var s;e&&o?a5.flushSync(n):n(),(s=t.onChange)==null||s.call(t,i,o)}},[a]=te.useState(()=>new awe(r));return a.setOptions(r),w2(()=>a._didMount(),[]),w2(()=>a._willUpdate()),a}function swe(e){return owe({observeElementRect:ewe,observeElementOffset:twe,scrollToFn:rwe,...e})}const H3=V.memo(()=>{const e=be(n=>n.activeChatId??n.draftChatKey),t=be(n=>ze(n,e).composerError);return t?N.jsx("div",{className:"mp-agent-composer-error",children:t}):null});H3.displayName="ComposerError";const lwe=(e,t)=>{switch(e.status){case exports.AgentToolCallStatus.Running:return`Running ${t}...`;case exports.AgentToolCallStatus.Succeeded:return`Completed ${t}`;case exports.AgentToolCallStatus.Failed:return`Failed to run ${t}`;case exports.AgentToolCallStatus.Pending:return`Preparing ${t}...`;default:return`Running ${t}...`}},es=e=>{if(e===void 0)return"undefined";try{return JSON.stringify(e,null,2)??"undefined"}catch{try{return String(e)}catch{return"[unserializable]"}}},x2=({call:e})=>Ue().config.debug?N.jsxs("details",{className:"mp-agent-tool-debug-details",children:[N.jsx("summary",{className:"mp-agent-tool-debug-summary",children:"Details"}),N.jsxs("div",{className:"mp-agent-tool-debug-body",children:[N.jsxs("div",{className:"mp-agent-tool-debug-row",children:[N.jsx("div",{className:"mp-agent-tool-debug-label",children:"Tool"}),N.jsx("div",{className:"mp-agent-tool-debug-value",children:e.name})]}),N.jsxs("div",{className:"mp-agent-tool-debug-row",children:[N.jsx("div",{className:"mp-agent-tool-debug-label",children:"Status"}),N.jsx("div",{className:"mp-agent-tool-debug-value",children:e.status})]}),N.jsxs("details",{className:"mp-agent-tool-debug-section",children:[N.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Input"}),N.jsx("pre",{className:"mp-agent-tool-debug-code",children:N.jsx("code",{children:es(e.input)})})]}),N.jsxs("details",{className:"mp-agent-tool-debug-section",children:[N.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Output"}),N.jsx("pre",{className:"mp-agent-tool-debug-code",children:N.jsx("code",{children:es(e.output)})})]}),e.error&&N.jsxs("details",{className:"mp-agent-tool-debug-section",children:[N.jsx("summary",{className:"mp-agent-tool-debug-section-summary",children:"Error"}),N.jsx("pre",{className:"mp-agent-tool-debug-code",children:N.jsx("code",{children:es(e.error)})})]})]})]}):null,E2=({call:e,isExpandable:t=!1,isExpanded:n=!1,onToggleExpand:r})=>{const a=Ue(),i=V.useRef(!1),o=e.status===exports.AgentToolCallStatus.Succeeded||e.status===exports.AgentToolCallStatus.Failed,s=t||a.config.debug&&!o,l=s||t;if(V.useEffect(()=>{!t||o||n||i.current||(i.current=!0,r?.())},[t,o,n,r]),!l)return null;const d=a.tools.get(e.name)?.label??e.name,p=lwe(e,d);return N.jsxs("div",{className:"mp-agent-tool-header",children:[s&&N.jsx("div",{className:"mp-agent-tool-simple-message",children:p}),t&&N.jsx("button",{className:"mp-agent-subagent-preview-toggle",type:"button",onClick:r,"aria-expanded":n,children:n?N.jsx(h5,{size:14}):N.jsx(zd,{size:14})})]})};function cwe(e){try{const t=JSON.parse(e);return{question:typeof t.question=="string"?t.question:void 0,selectedOptions:Array.isArray(t.selectedOptions)?t.selectedOptions:void 0,freeText:typeof t.freeText=="string"?t.freeText:void 0}}catch{return e}}const j3=({call:e})=>{if(e.approved===void 0)return null;const t=e.userResponse?cwe(e.userResponse):null,n=()=>{if(!t)return null;if(typeof t=="string")return N.jsx("span",{className:"mp-agent-tool-approval-response",children:t});const r=t.freeText??t.selectedOptions?.map(a=>a.label).join(", ");return!t.question&&!r?null:N.jsxs("div",{className:"mp-agent-tool-approval-result",children:[t.question&&N.jsx("span",{className:"mp-agent-tool-approval-question",children:t.question}),r&&N.jsx("span",{className:"mp-agent-tool-approval-response",children:r})]})};return N.jsxs("div",{className:"mp-agent-tool-approval-status-inline",children:[e.approved&&n(),e.approved?N.jsx("div",{className:"mp-agent-tool-approved",children:N.jsx("span",{children:"✓ Approved"})}):N.jsx("span",{className:"mp-agent-tool-denied",children:"✗ Denied"})]})},uwe=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.question,n=e.selectionMode,r=e.options,a=e.allowFreeText;if(typeof t!="string"||t.trim().length<1||n!=="single"&&n!=="multiple"||!Array.isArray(r)||r.length<2||r.length>6)return null;const i=r.map(o=>{if(!o||typeof o!="object"||Array.isArray(o))return null;const s=o.id,l=o.label,u=o.description;return typeof s!="string"||s.trim().length<1||typeof l!="string"||l.trim().length<1||u!==void 0&&typeof u!="string"?null:{id:s,label:l,...typeof u=="string"?{description:u}:{}}}).filter(o=>o!==null);return i.length!==r.length?null:{question:t,selectionMode:n,options:i,allowFreeText:typeof a=="boolean"?a:!1}},dwe=({callId:e,input:t,isSubmitting:n,onSubmit:r})=>{const[a,i]=V.useState([]),[o,s]=V.useState(""),[l,u]=V.useState(void 0),d=V.useMemo(()=>uwe(t),[t]);V.useEffect(()=>{i([]),s(""),u(void 0)},[e,t]);const p=h=>{if(d){if(u(void 0),d.selectionMode==="single"){i([h]);return}i(g=>g.includes(h)?g.filter(f=>f!==h):[...g,h])}},m=async()=>{if(!d)return;const h=o.trim(),g=a.length>0,f=d.allowFreeText&&h.length>0;if(!g&&!f){u(d.allowFreeText?"Select at least one option or provide a custom response.":"Select at least one option before submitting.");return}const w=d.options.filter(k=>a.includes(k.id)).map(({id:k,label:_,description:E})=>({id:k,label:_,...E?{description:E}:{}})),v={question:d.question,selectionMode:d.selectionMode,selectedOptionIds:a,selectedOptions:w,...h?{freeText:h}:{}};await r(JSON.stringify(v))};return d?N.jsxs("div",{className:"mp-agent-tool-user-action-form",children:[N.jsx("div",{className:"mp-agent-tool-user-action-question",children:d.question}),N.jsx("div",{className:"mp-agent-tool-user-action-options",children:d.options.map(h=>{const g=`${e}-${h.id}`,f=a.includes(h.id);return N.jsxs("label",{htmlFor:g,className:"mp-agent-tool-user-action-option",children:[N.jsx("input",{id:g,type:d.selectionMode==="single"?"radio":"checkbox",name:`mp-agent-tool-user-action-${e}`,checked:f,onChange:()=>p(h.id),disabled:n}),N.jsxs("span",{className:"mp-agent-tool-user-action-option-content",children:[N.jsx("span",{className:"mp-agent-tool-user-action-option-label",children:h.label}),h.description?N.jsx("span",{className:"mp-agent-tool-user-action-option-description",children:h.description}):null]})]},h.id)})}),d.allowFreeText?N.jsx("textarea",{className:"mp-agent-tool-user-action-free-text",value:o,onChange:h=>{s(h.target.value),l&&u(void 0)},placeholder:"Optional custom response",rows:3,disabled:n}):null,l?N.jsx("div",{className:"mp-agent-tool-input-error",children:l}):null,N.jsx("div",{className:"mp-agent-tool-approval-actions",children:N.jsx("button",{className:"mp-agent-tool-approve-button",onClick:m,disabled:n,children:n?"Submitting...":"Submit response"})})]}):N.jsx("div",{className:"mp-agent-tool-user-action-form",children:N.jsx("div",{className:"mp-agent-tool-input-error",children:"Invalid user action input schema in tool call."})})},pwe=({call:e,messageId:t,chatId:n,onApprovalSent:r})=>{const a=Ue(),i=a.tools.get(e.name)?.label??e.name,o=be(D=>D.appendMessagesToChat),[s,l]=V.useState(!1),[u,d]=V.useState(!1),[p,m]=V.useState(!1),[h,g]=V.useState(JSON.stringify(e.input??{},null,2)),[f,w]=V.useState(void 0),v=a.config.user?.id??"guest",k=e.requiresUserAction;V.useEffect(()=>{u||(g(JSON.stringify(e.input??{},null,2)),w(void 0))},[e.id,e.input,u]);const _=()=>{g(JSON.stringify(e.input??{},null,2)),w(void 0),d(!0)},E=()=>{g(JSON.stringify(e.input??{},null,2)),w(void 0),d(!1)},S=async()=>{if(!(!a.transport.updateToolCall||p||s)){w(void 0),m(!0);try{const D=JSON.parse(h);if(!D||typeof D!="object"||Array.isArray(D))throw new Error("Tool input must be a JSON object.");const P=await a.transport.updateToolCall({chatId:n,messageId:t,toolCallId:e.id,input:D});o(n,[P]),d(!1)}catch(D){w(D instanceof Error?D.message:"Failed to update tool input.")}finally{m(!1)}}},x=async(D,P)=>{if(!(!e.approvalId||s||p||u)){l(!0);try{const C={chatId:n,messageId:t,approvalId:e.approvalId,approved:D,...P?{userResponse:P}:{},userId:v},L=await a.transport.streamMessage(C,G=>{G.type===exports.StreamChunkType.Message&&G.message&&o(n,[G.message])},{streamKey:n});L?o(L.id,L.messages):r()}catch(C){console.error("Failed to send approval:",C)}finally{l(!1)}}};return e.approved!==void 0?N.jsx(j3,{call:e}):k?N.jsx(dwe,{callId:e.id,input:e.input,isSubmitting:s,onSubmit:D=>x(!0,D)}):N.jsxs("div",{className:"mp-agent-tool-approval-buttons",children:[N.jsxs("div",{className:"mp-agent-tool-approval-request-message",children:["Agent wants to execute tool ",i,"."]}),N.jsxs("div",{className:"mp-agent-tool-input-card",children:[N.jsxs("div",{className:"mp-agent-tool-input-card-header",children:[N.jsx("span",{className:"mp-agent-tool-input-card-title",children:"Tool input"}),u?N.jsxs("div",{className:"mp-agent-tool-input-actions",children:[N.jsx(nn,{icon:"Check",size:"sm",tooltip:"Save tool input",onClick:S,disabled:p||s,"aria-label":"Save tool input"}),N.jsx(nn,{icon:"X",size:"sm",tooltip:"Cancel input edit",onClick:E,disabled:p||s,"aria-label":"Cancel tool input edit"})]}):N.jsx(nn,{icon:"Pencil",size:"sm",tooltip:"Edit tool input",onClick:_,disabled:s||p,"aria-label":"Edit tool input"})]}),u?N.jsx("textarea",{className:"mp-agent-tool-input-editor",value:h,onChange:D=>{g(D.target.value),f&&w(void 0)},rows:8,spellCheck:!1,disabled:p||s}):N.jsx("pre",{className:"mp-agent-tool-input-preview",children:JSON.stringify(e.input??{},null,2)}),f&&N.jsx("div",{className:"mp-agent-tool-input-error",children:f})]}),N.jsxs("div",{className:"mp-agent-tool-approval-actions",children:[N.jsx("button",{className:"mp-agent-tool-approve-button",onClick:()=>x(!0),disabled:s||u||p,children:s?"Processing...":"Approve"}),N.jsx("button",{className:"mp-agent-tool-deny-button",onClick:()=>x(!1),disabled:s||p,children:s?"Processing...":"Deny"})]})]})},M2=({call:e,messageId:t,chatId:n})=>{const r=Ue(),a=be(d=>d.upsertChat),i=r.config.debug&&!!e.approvalId,o=e.requiresConfirmation&&e.approvalId||i,s=o&&e.approved===void 0,l=o&&e.approved!==void 0,u=async()=>{try{const d=await r.transport.getChat(n);a(d)}catch(d){console.error("Failed to refresh chat after approval:",d)}};return!s&&!l?null:N.jsxs("div",{className:"mp-agent-tool-approval",children:[s&&N.jsx(pwe,{call:e,messageId:t,chatId:n,onApprovalSent:u}),l&&N.jsx(j3,{call:e})]})},S2=({chatId:e,isExpanded:t})=>{const n=Ue(),r=be(l=>ze(l,e).messages),a=be(l=>ze(l,e).pendingAssistant),i=be(l=>l.chats[e]?.contextKey??l.contextKey),o=np(e),s=V.useMemo(()=>{const l=[...r].sort((d,p)=>d.createdAt.localeCompare(p.createdAt));if(n.config.debug)return l;const u=l.findIndex(d=>d.role===exports.MessageRole.User);return u===-1?l:l.filter((d,p)=>p!==u)},[r,n.config.debug]);return N.jsx("div",{className:"mp-agent-subagent-preview",children:t&&N.jsx("div",{className:"mp-agent-subagent-preview-body",children:s.length===0&&!a?N.jsx("div",{className:"mp-agent-subagent-preview-empty",children:o.isLoading?"Loading subagent chat...":"Subagent chat started."}):N.jsxs(N.Fragment,{children:[s.map(l=>N.jsx(Zi,{message:l,contextKey:i},l.id)),a&&N.jsx(Zi,{message:a,contextKey:i,isStreaming:!0})]})})})},hwe=({call:e,contextKey:t,messageId:n,chatId:r})=>{const a=Ue(),i=e.subagentChatId||(typeof e.input?.subagentChatId=="string"?e.input.subagentChatId:void 0),[o,s]=V.useState(!1),l=V.useMemo(()=>a.getToolRenderer(e),[a,e]);return l?N.jsxs("div",{className:"mp-agent-tool-panel",children:[i&&N.jsx(E2,{call:e,isExpandable:!0,isExpanded:o,onToggleExpand:()=>s(u=>!u)}),N.jsx(l,{call:e,contextKey:t,chatId:r}),N.jsx(M2,{call:e,messageId:n,chatId:r}),i&&N.jsx(S2,{chatId:i,isExpanded:o}),!i&&N.jsx(x2,{call:e})]}):N.jsxs("div",{className:"mp-agent-tool-panel",children:[N.jsx(E2,{call:e,isExpandable:!!i,isExpanded:o,onToggleExpand:()=>s(u=>!u)}),N.jsx(M2,{call:e,messageId:n,chatId:r}),i&&N.jsx(S2,{chatId:i,isExpanded:o}),!i&&N.jsx(x2,{call:e})]})},mwe=e=>{const t=e.sender?.displayName||e.sender?.id||e.agentName;if(!t)return e.role===exports.MessageRole.User?"You":"AI";const n=t.split(/\s+/).filter(Boolean);return n.length>=2?`${n[0][0]}${n[1][0]}`.toUpperCase():t.slice(0,2).toUpperCase()},dp=V.memo(({message:e,isGrouped:t})=>{if(t)return N.jsx("div",{className:"mp-agent-message-avatar-spacer"});const n=e.role===exports.MessageRole.User;return N.jsx("div",{className:`mp-agent-message-avatar ${n?"mp-agent-message-avatar-user":""}`,children:e.sender?.avatarUrl?N.jsx("img",{className:"mp-agent-message-avatar-image",src:e.sender.avatarUrl,alt:""}):N.jsx("div",{className:"mp-agent-message-avatar-icon",children:mwe(e)})})});dp.displayName="MessageAvatar";const fwe=e=>e?new Date(e).toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit"}):"",gwe=e=>e.sender?.displayName?e.sender.displayName:e.sender?.id&&e.sender.id!=="guest"?e.sender.id:e.agentName?e.agentName:e.role===exports.MessageRole.User?"You":"Assistant",pp=V.memo(({message:e,isGrouped:t})=>{if(t)return null;const n=gwe(e);return N.jsxs("div",{className:"mp-agent-message-header",children:[N.jsx("span",{className:"mp-agent-message-role",children:n}),N.jsx("span",{className:"mp-agent-message-time",children:fwe(e.createdAt)})]})});pp.displayName="MessageHeader";function N2(e){const t=[],n=String(e||"");let r=n.indexOf(","),a=0,i=!1;for(;!i;){r===-1&&(r=n.length,i=!0);const o=n.slice(a,r).trim();(o||!i)&&t.push(o),a=r+1,r=n.indexOf(",",a)}return t}function ywe(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const bwe=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,kwe=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vwe={};function A2(e,t){return(vwe.jsx?kwe:bwe).test(e)}const _we=/[ \t\n\f\r]/g;function wwe(e){return typeof e=="object"?e.type==="text"?T2(e.value):!1:T2(e)}function T2(e){return e.replace(_we,"")===""}let Ia=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};Ia.prototype.normal={};Ia.prototype.property={};Ia.prototype.space=void 0;function V3(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new Ia(n,r,t)}function ya(e){return e.toLowerCase()}let Ft=class{constructor(t,n){this.attribute=n,this.property=t}};Ft.prototype.attribute="";Ft.prototype.booleanish=!1;Ft.prototype.boolean=!1;Ft.prototype.commaOrSpaceSeparated=!1;Ft.prototype.commaSeparated=!1;Ft.prototype.defined=!1;Ft.prototype.mustUseProperty=!1;Ft.prototype.number=!1;Ft.prototype.overloadedBoolean=!1;Ft.prototype.property="";Ft.prototype.spaceSeparated=!1;Ft.prototype.space=void 0;let xwe=0;const Re=yr(),lt=yr(),sd=yr(),se=yr(),Qe=yr(),$r=yr(),Ut=yr();function yr(){return 2**++xwe}const ld=Object.freeze(Object.defineProperty({__proto__:null,boolean:Re,booleanish:lt,commaOrSpaceSeparated:Ut,commaSeparated:$r,number:se,overloadedBoolean:sd,spaceSeparated:Qe},Symbol.toStringTag,{value:"Module"})),ts=Object.keys(ld);let hp=class extends Ft{constructor(t,n,r,a){let i=-1;if(super(t,n),C2(this,"space",a),typeof r=="number")for(;++i<ts.length;){const o=ts[i];C2(this,ts[i],(r&ld[o])===ld[o])}}};hp.prototype.defined=!0;function C2(e,t,n){n&&(e[t]=n)}function Vr(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const i=new hp(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ya(r)]=r,n[ya(i.attribute)]=r}return new Ia(t,n,e.space)}const G3=Vr({properties:{ariaActiveDescendant:null,ariaAtomic:lt,ariaAutoComplete:null,ariaBusy:lt,ariaChecked:lt,ariaColCount:se,ariaColIndex:se,ariaColSpan:se,ariaControls:Qe,ariaCurrent:null,ariaDescribedBy:Qe,ariaDetails:null,ariaDisabled:lt,ariaDropEffect:Qe,ariaErrorMessage:null,ariaExpanded:lt,ariaFlowTo:Qe,ariaGrabbed:lt,ariaHasPopup:null,ariaHidden:lt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qe,ariaLevel:se,ariaLive:null,ariaModal:lt,ariaMultiLine:lt,ariaMultiSelectable:lt,ariaOrientation:null,ariaOwns:Qe,ariaPlaceholder:null,ariaPosInSet:se,ariaPressed:lt,ariaReadOnly:lt,ariaRelevant:null,ariaRequired:lt,ariaRoleDescription:Qe,ariaRowCount:se,ariaRowIndex:se,ariaRowSpan:se,ariaSelected:lt,ariaSetSize:se,ariaSort:null,ariaValueMax:se,ariaValueMin:se,ariaValueNow:se,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function W3(e,t){return t in e?e[t]:t}function K3(e,t){return W3(e,t.toLowerCase())}const Ewe=Vr({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:$r,acceptCharset:Qe,accessKey:Qe,action:null,allow:null,allowFullScreen:Re,allowPaymentRequest:Re,allowUserMedia:Re,alt:null,as:null,async:Re,autoCapitalize:null,autoComplete:Qe,autoFocus:Re,autoPlay:Re,blocking:Qe,capture:null,charSet:null,checked:Re,cite:null,className:Qe,cols:se,colSpan:null,content:null,contentEditable:lt,controls:Re,controlsList:Qe,coords:se|$r,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Re,defer:Re,dir:null,dirName:null,disabled:Re,download:sd,draggable:lt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Re,formTarget:null,headers:Qe,height:se,hidden:sd,high:se,href:null,hrefLang:null,htmlFor:Qe,httpEquiv:Qe,id:null,imageSizes:null,imageSrcSet:null,inert:Re,inputMode:null,integrity:null,is:null,isMap:Re,itemId:null,itemProp:Qe,itemRef:Qe,itemScope:Re,itemType:Qe,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Re,low:se,manifest:null,max:null,maxLength:se,media:null,method:null,min:null,minLength:se,multiple:Re,muted:Re,name:null,nonce:null,noModule:Re,noValidate:Re,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:Re,optimum:se,pattern:null,ping:Qe,placeholder:null,playsInline:Re,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Re,referrerPolicy:null,rel:Qe,required:Re,reversed:Re,rows:se,rowSpan:se,sandbox:Qe,scope:null,scoped:Re,seamless:Re,selected:Re,shadowRootClonable:Re,shadowRootDelegatesFocus:Re,shadowRootMode:null,shape:null,size:se,sizes:null,slot:null,span:se,spellCheck:lt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:se,step:null,style:null,tabIndex:se,target:null,title:null,translate:null,type:null,typeMustMatch:Re,useMap:null,value:lt,width:se,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qe,axis:null,background:null,bgColor:null,border:se,borderColor:null,bottomMargin:se,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Re,declare:Re,event:null,face:null,frame:null,frameBorder:null,hSpace:se,leftMargin:se,link:null,longDesc:null,lowSrc:null,marginHeight:se,marginWidth:se,noResize:Re,noHref:Re,noShade:Re,noWrap:Re,object:null,profile:null,prompt:null,rev:null,rightMargin:se,rules:null,scheme:null,scrolling:lt,standby:null,summary:null,text:null,topMargin:se,valueType:null,version:null,vAlign:null,vLink:null,vSpace:se,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Re,disableRemotePlayback:Re,prefix:null,property:null,results:se,security:null,unselectable:null},space:"html",transform:K3}),Mwe=Vr({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:Ut,accentHeight:se,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:se,amplitude:se,arabicForm:null,ascent:se,attributeName:null,attributeType:null,azimuth:se,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:se,by:null,calcMode:null,capHeight:se,className:Qe,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:se,diffuseConstant:se,direction:null,display:null,dur:null,divisor:se,dominantBaseline:null,download:Re,dx:null,dy:null,edgeMode:null,editable:null,elevation:se,enableBackground:null,end:null,event:null,exponent:se,externalResourcesRequired:null,fill:null,fillOpacity:se,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:$r,g2:$r,glyphName:$r,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:se,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:se,horizOriginX:se,horizOriginY:se,id:null,ideographic:se,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:se,k:se,k1:se,k2:se,k3:se,k4:se,kernelMatrix:Ut,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:se,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:se,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:se,overlineThickness:se,paintOrder:null,panose1:null,path:null,pathLength:se,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Qe,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:se,pointsAtY:se,pointsAtZ:se,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ut,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ut,rev:Ut,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ut,requiredFeatures:Ut,requiredFonts:Ut,requiredFormats:Ut,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:se,specularExponent:se,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:se,strikethroughThickness:se,string:null,stroke:null,strokeDashArray:Ut,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:se,strokeOpacity:se,strokeWidth:null,style:null,surfaceScale:se,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ut,tabIndex:se,tableValues:null,target:null,targetX:se,targetY:se,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ut,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:se,underlineThickness:se,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:se,values:null,vAlphabetic:se,vMathematical:se,vectorEffect:null,vHanging:se,vIdeographic:se,version:null,vertAdvY:se,vertOriginX:se,vertOriginY:se,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:se,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:W3}),Y3=Vr({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),Z3=Vr({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:K3}),X3=Vr({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),Swe={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"},Nwe=/[A-Z]/g,R2=/-[a-z]/g,Awe=/^data[-\w.:]+$/i;function Q3(e,t){const n=ya(t);let r=t,a=Ft;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Awe.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(R2,Cwe);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!R2.test(i)){let o=i.replace(Nwe,Twe);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}a=hp}return new a(r,t)}function Twe(e){return"-"+e.toLowerCase()}function Cwe(e){return e.charAt(1).toUpperCase()}const J3=V3([G3,Ewe,Y3,Z3,X3],"html"),fo=V3([G3,Mwe,Y3,Z3,X3],"svg");function I2(e){const t=String(e||"").trim();return t?t.split(/[ \t\n\r\f]+/g):[]}function Rwe(e){return e.join(" ").trim()}var Jn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function go(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mp={},O2=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,Iwe=/\n/g,Owe=/^\s*/,Lwe=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,Dwe=/^:\s*/,zwe=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,$we=/^[;\s]*/,Fwe=/^\s+|\s+$/g,Pwe=`
|
|
8297
8297
|
`,L2="/",D2="*",dr="",qwe="comment",Bwe="declaration";function Uwe(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function a(g){var f=g.match(Iwe);f&&(n+=f.length);var w=g.lastIndexOf(Pwe);r=~w?g.length-w:r+g.length}function i(){var g={line:n,column:r};return function(f){return f.position=new o(g),u(),f}}function o(g){this.start=g,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function s(g){var f=new Error(t.source+":"+n+":"+r+": "+g);if(f.reason=g,f.filename=t.source,f.line=n,f.column=r,f.source=e,!t.silent)throw f}function l(g){var f=g.exec(e);if(f){var w=f[0];return a(w),e=e.slice(w.length),f}}function u(){l(Owe)}function d(g){var f;for(g=g||[];f=p();)f!==!1&&g.push(f);return g}function p(){var g=i();if(!(L2!=e.charAt(0)||D2!=e.charAt(1))){for(var f=2;dr!=e.charAt(f)&&(D2!=e.charAt(f)||L2!=e.charAt(f+1));)++f;if(f+=2,dr===e.charAt(f-1))return s("End of comment missing");var w=e.slice(2,f-2);return r+=2,a(w),e=e.slice(f),r+=2,g({type:qwe,comment:w})}}function m(){var g=i(),f=l(Lwe);if(f){if(p(),!l(Dwe))return s("property missing ':'");var w=l(zwe),v=g({type:Bwe,property:z2(f[0].replace(O2,dr)),value:w?z2(w[0].replace(O2,dr)):dr});return l($we),v}}function h(){var g=[];d(g);for(var f;f=m();)f!==!1&&(g.push(f),d(g));return g}return u(),h()}function z2(e){return e?e.replace(Fwe,dr):dr}var Hwe=Uwe,jwe=Jn&&Jn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(mp,"__esModule",{value:!0});mp.default=Gwe;const Vwe=jwe(Hwe);function Gwe(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,Vwe.default)(e),a=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:o,value:s}=i;a?t(o,s,i):s&&(n=n||{},n[o]=s)}),n}var yo={};Object.defineProperty(yo,"__esModule",{value:!0});yo.camelCase=void 0;var Wwe=/^--[a-zA-Z0-9_-]+$/,Kwe=/-([a-z])/g,Ywe=/^[^-]+$/,Zwe=/^-(webkit|moz|ms|o|khtml)-/,Xwe=/^-(ms)-/,Qwe=function(e){return!e||Ywe.test(e)||Wwe.test(e)},Jwe=function(e,t){return t.toUpperCase()},$2=function(e,t){return"".concat(t,"-")},exe=function(e,t){return t===void 0&&(t={}),Qwe(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(Xwe,$2):e=e.replace(Zwe,$2),e.replace(Kwe,Jwe))};yo.camelCase=exe;var txe=Jn&&Jn.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},nxe=txe(mp),rxe=yo;function cd(e,t){var n={};return!e||typeof e!="string"||(0,nxe.default)(e,function(r,a){r&&a&&(n[(0,rxe.camelCase)(r,t)]=a)}),n}cd.default=cd;var axe=cd;const ixe=go(axe),ev=tv("end"),fp=tv("start");function tv(e){return t;function t(n){const r=n&&n.position&&n.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 oxe(e){const t=fp(e),n=ev(e);if(t&&n)return{start:t,end:n}}function la(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?F2(e.position):"start"in e||"end"in e?F2(e):"line"in e||"column"in e?ud(e):""}function ud(e){return P2(e&&e.line)+":"+P2(e&&e.column)}function F2(e){return ud(e&&e.start)+"-"+ud(e&&e.end)}function P2(e){return e&&typeof e=="number"?e:1}class Et extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",i={},o=!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 t=="string"?a=t:!i.cause&&t&&(o=!0,a=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?i.ruleId=r:(i.source=r.slice(0,l),i.ruleId=r.slice(l+1))}if(!i.place&&i.ancestors&&i.ancestors){const l=i.ancestors[i.ancestors.length-1];l&&(i.place=l.position)}const s=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=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=s?s.line:void 0,this.name=la(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=o&&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}}Et.prototype.file="";Et.prototype.name="";Et.prototype.reason="";Et.prototype.message="";Et.prototype.stack="";Et.prototype.column=void 0;Et.prototype.line=void 0;Et.prototype.ancestors=void 0;Et.prototype.cause=void 0;Et.prototype.fatal=void 0;Et.prototype.place=void 0;Et.prototype.ruleId=void 0;Et.prototype.source=void 0;const gp={}.hasOwnProperty,sxe=new Map,lxe=/[A-Z]/g,cxe=new Set(["table","tbody","thead","tfoot","tr"]),uxe=new Set(["td","th"]),nv="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function dxe(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=kxe(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=bxe(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?fo:J3,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=rv(a,e,void 0);return i&&typeof i!="string"?i:a.create(e,a.Fragment,{children:i||void 0},void 0)}function rv(e,t,n){if(t.type==="element")return pxe(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return hxe(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return fxe(e,t,n);if(t.type==="mdxjsEsm")return mxe(e,t);if(t.type==="root")return gxe(e,t,n);if(t.type==="text")return yxe(e,t)}function pxe(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=fo,e.schema=a),e.ancestors.push(t);const i=iv(e,t.tagName,!1),o=vxe(e,t);let s=bp(e,t);return cxe.has(t.tagName)&&(s=s.filter(function(l){return typeof l=="string"?!wwe(l):!0})),av(e,o,i,t),yp(o,s),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function hxe(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}ba(e,t.position)}function mxe(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ba(e,t.position)}function fxe(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=fo,e.schema=a),e.ancestors.push(t);const i=t.name===null?e.Fragment:iv(e,t.name,!0),o=_xe(e,t),s=bp(e,t);return av(e,o,i,t),yp(o,s),e.ancestors.pop(),e.schema=r,e.create(t,i,o,n)}function gxe(e,t,n){const r={};return yp(r,bp(e,t)),e.create(t,e.Fragment,r,n)}function yxe(e,t){return t.value}function av(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function yp(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function bxe(e,t,n){return r;function r(a,i,o,s){const u=Array.isArray(o.children)?n:t;return s?u(i,o,s):u(i,o)}}function kxe(e,t){return n;function n(r,a,i,o){const s=Array.isArray(i.children),l=fp(r);return t(a,i,o,s,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function vxe(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&gp.call(t.properties,a)){const i=wxe(e,a,t.properties[a]);if(i){const[o,s]=i;e.tableCellAlignToStyle&&o==="align"&&typeof s=="string"&&uxe.has(t.tagName)?r=s:n[o]=s}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function _xe(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const o=i.expression;o.type;const s=o.properties[0];s.type,Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else ba(e,t.position);else{const a=r.name;let i;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const s=r.value.data.estree.body[0];s.type,i=e.evaluater.evaluateExpression(s.expression)}else ba(e,t.position);else i=r.value===null?!0:r.value;n[a]=i}return n}function bp(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:sxe;for(;++r<t.children.length;){const i=t.children[r];let o;if(e.passKeys){const l=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(l){const u=a.get(l)||0;o=l+"-"+u,a.set(l,u+1)}}const s=rv(e,i,o);s!==void 0&&n.push(s)}return n}function wxe(e,t,n){const r=Q3(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?ywe(n):Rwe(n)),r.property==="style"){let a=typeof n=="object"?n:xxe(e,String(n));return e.stylePropertyNameCase==="css"&&(a=Exe(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?Swe[r.property]||r.property:r.attribute,n]}}function xxe(e,t){try{return ixe(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new Et("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=nv+"#cannot-parse-style-attribute",a}}function iv(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let i=-1,o;for(;++i<a.length;){const s=A2(a[i])?{type:"Identifier",name:a[i]}:{type:"Literal",value:a[i]};o=o?{type:"MemberExpression",object:o,property:s,computed:!!(i&&s.type==="Literal"),optional:!1}:s}r=o}else r=A2(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return gp.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);ba(e)}function ba(e,t){const n=new Et("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=nv+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Exe(e){const t={};let n;for(n in e)gp.call(e,n)&&(t[Mxe(n)]=e[n]);return t}function Mxe(e){let t=e.replace(lxe,Sxe);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Sxe(e){return"-"+e.toLowerCase()}const ns={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"]},Nxe={};function kp(e,t){const n=Nxe,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return ov(e,r,a)}function ov(e,t,n){if(Axe(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return q2(e.children,t,n)}return Array.isArray(e)?q2(e,t,n):""}function q2(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=ov(e[a],t,n);return r.join("")}function Axe(e){return!!(e&&typeof e=="object")}const B2=document.createElement("i");function ka(e){const t="&"+e+";";B2.innerHTML=t;const n=B2.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Gt(e,t,n,r){const a=e.length;let i=0,o;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);i<r.length;)o=r.slice(i,i+1e4),o.unshift(t,0),e.splice(...o),i+=1e4,t+=1e4}function Jt(e,t){return e.length>0?(Gt(e,e.length,0,t),e):t}const U2={}.hasOwnProperty;function sv(e){const t={};let n=-1;for(;++n<e.length;)Txe(t,e[n]);return t}function Txe(e,t){let n;for(n in t){const a=(U2.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let o;if(i)for(o in i){U2.call(a,o)||(a[o]=[]);const s=i[o];Cxe(a[o],Array.isArray(s)?s:s?[s]:[])}}}function Cxe(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Gt(e,0,0,r)}function lv(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function pn(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Tt=ar(/[A-Za-z]/),wt=ar(/[\dA-Za-z]/),Rxe=ar(/[#-'*+\--9=?A-Z^-~]/);function zi(e){return e!==null&&(e<32||e===127)}const dd=ar(/\d/),Ixe=ar(/[\dA-Fa-f]/),Oxe=ar(/[!-/:-@[-`{-~]/);function he(e){return e!==null&&e<-2}function Be(e){return e!==null&&(e<0||e===32)}function Oe(e){return e===-2||e===-1||e===32}const er=ar(/\p{P}|\p{S}/u),hn=ar(/\s/);function ar(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Gr(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const i=e.charCodeAt(n);let o="";if(i===37&&wt(e.charCodeAt(n+1))&&wt(e.charCodeAt(n+2)))a=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(o=String.fromCharCode(i));else if(i>55295&&i<57344){const s=e.charCodeAt(n+1);i<56320&&s>56319&&s<57344?(o=String.fromCharCode(i,s),a=1):o="�"}else o=String.fromCharCode(i);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+a+1,o=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function Te(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let i=0;return o;function o(l){return Oe(l)?(e.enter(n),s(l)):t(l)}function s(l){return Oe(l)&&i++<a?(e.consume(l),s):(e.exit(n),t(l))}}const Lxe={tokenize:Dxe};function Dxe(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),Te(e,t,"linePrefix")}function a(s){return e.enter("paragraph"),i(s)}function i(s){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(s)}function o(s){if(s===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(s);return}return he(s)?(e.consume(s),e.exit("chunkText"),i):(e.consume(s),o)}}const zxe={tokenize:$xe},H2={tokenize:Fxe};function $xe(e){const t=this,n=[];let r=0,a,i,o;return s;function s(_){if(r<n.length){const E=n[r];return t.containerState=E[1],e.attempt(E[0].continuation,l,u)(_)}return u(_)}function l(_){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&k();const E=t.events.length;let S=E,x;for(;S--;)if(t.events[S][0]==="exit"&&t.events[S][1].type==="chunkFlow"){x=t.events[S][1].end;break}v(r);let D=E;for(;D<t.events.length;)t.events[D][1].end={...x},D++;return Gt(t.events,S+1,0,t.events.slice(E)),t.events.length=D,u(_)}return s(_)}function u(_){if(r===n.length){if(!a)return m(_);if(a.currentConstruct&&a.currentConstruct.concrete)return g(_);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(H2,d,p)(_)}function d(_){return a&&k(),v(r),m(_)}function p(_){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,g(_)}function m(_){return t.containerState={},e.attempt(H2,h,g)(_)}function h(_){return r++,n.push([t.currentConstruct,t.containerState]),m(_)}function g(_){if(_===null){a&&k(),v(0),e.consume(_);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:i}),f(_)}function f(_){if(_===null){w(e.exit("chunkFlow"),!0),v(0),e.consume(_);return}return he(_)?(e.consume(_),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,s):(e.consume(_),f)}function w(_,E){const S=t.sliceStream(_);if(E&&S.push(null),_.previous=i,i&&(i.next=_),i=_,a.defineSkip(_.start),a.write(S),t.parser.lazy[_.start.line]){let x=a.events.length;for(;x--;)if(a.events[x][1].start.offset<o&&(!a.events[x][1].end||a.events[x][1].end.offset>o))return;const D=t.events.length;let P=D,C,L;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){if(C){L=t.events[P][1].end;break}C=!0}for(v(r),x=D;x<t.events.length;)t.events[x][1].end={...L},x++;Gt(t.events,P+1,0,t.events.slice(D)),t.events.length=x}}function v(_){let E=n.length;for(;E-- >_;){const S=n[E];t.containerState=S[1],S[0].exit.call(t,e)}n.length=_}function k(){a.write([null]),i=void 0,a=void 0,t.containerState._closeFlow=void 0}}function Fxe(e,t,n){return Te(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Pr(e){if(e===null||Be(e)||hn(e))return 1;if(er(e))return 2}function bo(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const i=e[a].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const pd={name:"attention",resolveAll:Pxe,tokenize:qxe};function Pxe(e,t){let n=-1,r,a,i,o,s,l,u,d;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},m={...e[n][1].start};j2(p,-l),j2(m,l),o={type:l>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},s={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:m},i={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:l>1?"strong":"emphasis",start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Jt(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Jt(u,[["enter",a,t],["enter",o,t],["exit",o,t],["enter",i,t]]),u=Jt(u,bo(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Jt(u,[["exit",i,t],["enter",s,t],["exit",s,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(d=2,u=Jt(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):d=0,Gt(e,r-1,n-r+3,u),n=r+u.length-d-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function qxe(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=Pr(r);let i;return o;function o(l){return i=l,e.enter("attentionSequence"),s(l)}function s(l){if(l===i)return e.consume(l),s;const u=e.exit("attentionSequence"),d=Pr(l),p=!d||d===2&&a||n.includes(l),m=!a||a===2&&d||n.includes(r);return u._open=!!(i===42?p:p&&(a||!m)),u._close=!!(i===42?m:m&&(d||!p)),t(l)}}function j2(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Bxe={name:"autolink",tokenize:Uxe};function Uxe(e,t,n){let r=0;return a;function a(h){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(h){return Tt(h)?(e.consume(h),o):h===64?n(h):u(h)}function o(h){return h===43||h===45||h===46||wt(h)?(r=1,s(h)):u(h)}function s(h){return h===58?(e.consume(h),r=0,l):(h===43||h===45||h===46||wt(h))&&r++<32?(e.consume(h),s):(r=0,u(h))}function l(h){return h===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):h===null||h===32||h===60||zi(h)?n(h):(e.consume(h),l)}function u(h){return h===64?(e.consume(h),d):Rxe(h)?(e.consume(h),u):n(h)}function d(h){return wt(h)?p(h):n(h)}function p(h){return h===46?(e.consume(h),r=0,d):h===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(h),e.exit("autolinkMarker"),e.exit("autolink"),t):m(h)}function m(h){if((h===45||wt(h))&&r++<63){const g=h===45?m:p;return e.consume(h),g}return n(h)}}const Oa={partial:!0,tokenize:Hxe};function Hxe(e,t,n){return r;function r(i){return Oe(i)?Te(e,a,"linePrefix")(i):a(i)}function a(i){return i===null||he(i)?t(i):n(i)}}const cv={continuation:{tokenize:Vxe},exit:Gxe,name:"blockQuote",tokenize:jxe};function jxe(e,t,n){const r=this;return a;function a(o){if(o===62){const s=r.containerState;return s.open||(e.enter("blockQuote",{_container:!0}),s.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),i}return n(o)}function i(o){return Oe(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function Vxe(e,t,n){const r=this;return a;function a(o){return Oe(o)?Te(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):i(o)}function i(o){return e.attempt(cv,t,n)(o)}}function Gxe(e){e.exit("blockQuote")}const uv={name:"characterEscape",tokenize:Wxe};function Wxe(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),a}function a(i){return Oxe(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const dv={name:"characterReference",tokenize:Kxe};function Kxe(e,t,n){const r=this;let a=0,i,o;return s;function s(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),l}function l(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),i=31,o=wt,d(p))}function u(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,o=Ixe,d):(e.enter("characterReferenceValue"),i=7,o=dd,d(p))}function d(p){if(p===59&&a){const m=e.exit("characterReferenceValue");return o===wt&&!ka(r.sliceSerialize(m))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(p)&&a++<i?(e.consume(p),d):n(p)}}const V2={partial:!0,tokenize:Zxe},G2={concrete:!0,name:"codeFenced",tokenize:Yxe};function Yxe(e,t,n){const r=this,a={partial:!0,tokenize:S};let i=0,o=0,s;return l;function l(x){return u(x)}function u(x){const D=r.events[r.events.length-1];return i=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,s=x,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),d(x)}function d(x){return x===s?(o++,e.consume(x),d):o<3?n(x):(e.exit("codeFencedFenceSequence"),Oe(x)?Te(e,p,"whitespace")(x):p(x))}function p(x){return x===null||he(x)?(e.exit("codeFencedFence"),r.interrupt?t(x):e.check(V2,f,E)(x)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),m(x))}function m(x){return x===null||he(x)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(x)):Oe(x)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Te(e,h,"whitespace")(x)):x===96&&x===s?n(x):(e.consume(x),m)}function h(x){return x===null||he(x)?p(x):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(x))}function g(x){return x===null||he(x)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(x)):x===96&&x===s?n(x):(e.consume(x),g)}function f(x){return e.attempt(a,E,w)(x)}function w(x){return e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),v}function v(x){return i>0&&Oe(x)?Te(e,k,"linePrefix",i+1)(x):k(x)}function k(x){return x===null||he(x)?e.check(V2,f,E)(x):(e.enter("codeFlowValue"),_(x))}function _(x){return x===null||he(x)?(e.exit("codeFlowValue"),k(x)):(e.consume(x),_)}function E(x){return e.exit("codeFenced"),t(x)}function S(x,D,P){let C=0;return L;function L(R){return x.enter("lineEnding"),x.consume(R),x.exit("lineEnding"),G}function G(R){return x.enter("codeFencedFence"),Oe(R)?Te(x,X,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):X(R)}function X(R){return R===s?(x.enter("codeFencedFenceSequence"),J(R)):P(R)}function J(R){return R===s?(C++,x.consume(R),J):C>=o?(x.exit("codeFencedFenceSequence"),Oe(R)?Te(x,K,"whitespace")(R):K(R)):P(R)}function K(R){return R===null||he(R)?(x.exit("codeFencedFence"),D(R)):P(R)}}}function Zxe(e,t,n){const r=this;return a;function a(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const rs={name:"codeIndented",tokenize:Qxe},Xxe={partial:!0,tokenize:Jxe};function Qxe(e,t,n){const r=this;return a;function a(u){return e.enter("codeIndented"),Te(e,i,"linePrefix",5)(u)}function i(u){const d=r.events[r.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?o(u):n(u)}function o(u){return u===null?l(u):he(u)?e.attempt(Xxe,o,l)(u):(e.enter("codeFlowValue"),s(u))}function s(u){return u===null||he(u)?(e.exit("codeFlowValue"),o(u)):(e.consume(u),s)}function l(u){return e.exit("codeIndented"),t(u)}}function Jxe(e,t,n){const r=this;return a;function a(o){return r.parser.lazy[r.now().line]?n(o):he(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),a):Te(e,i,"linePrefix",5)(o)}function i(o){const s=r.events[r.events.length-1];return s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):he(o)?a(o):n(o)}}const e9e={name:"codeText",previous:n9e,resolve:t9e,tokenize:r9e};function t9e(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function n9e(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function r9e(e,t,n){let r=0,a,i;return o;function o(p){return e.enter("codeText"),e.enter("codeTextSequence"),s(p)}function s(p){return p===96?(e.consume(p),r++,s):(e.exit("codeTextSequence"),l(p))}function l(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),l):p===96?(i=e.enter("codeTextSequence"),a=0,d(p)):he(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),l):(e.enter("codeTextData"),u(p))}function u(p){return p===null||p===32||p===96||he(p)?(e.exit("codeTextData"),l(p)):(e.consume(p),u)}function d(p){return p===96?(e.consume(p),a++,d):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(i.type="codeTextData",u(p))}}class a9e{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const i=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&Xr(this.left,r),i.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Xr(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Xr(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Xr(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Xr(this.left,n.reverse())}}}function Xr(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function pv(e){const t={};let n=-1,r,a,i,o,s,l,u;const d=new a9e(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,i=0,i<l.length&&l[i][1].type==="lineEndingBlank"&&(i+=2),i<l.length&&l[i][1].type==="content"))for(;++i<l.length&&l[i][1].type!=="content";)l[i][1].type==="chunkText"&&(l[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,i9e(d,n)),n=t[n],u=!0);else if(r[1]._container){for(i=n,a=void 0;i--;)if(o=d.get(i),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(a&&(d.get(a)[1].type="lineEndingBlank"),o[1].type="lineEnding",a=i);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;a&&(r[1].end={...d.get(a)[1].start},s=d.slice(a,n),s.unshift(r),d.splice(a,n-a+1,s))}}return Gt(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!u}function i9e(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const i=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const s=o.events,l=[],u={};let d,p,m=-1,h=n,g=0,f=0;const w=[f];for(;h;){for(;e.get(++a)[1]!==h;);i.push(a),h._tokenizer||(d=r.sliceStream(h),h.next||d.push(null),p&&o.defineSkip(h.start),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(d),h._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),p=h,h=h.next}for(h=n;++m<s.length;)s[m][0]==="exit"&&s[m-1][0]==="enter"&&s[m][1].type===s[m-1][1].type&&s[m][1].start.line!==s[m][1].end.line&&(f=m+1,w.push(f),h._tokenizer=void 0,h.previous=void 0,h=h.next);for(o.events=[],h?(h._tokenizer=void 0,h.previous=void 0):w.pop(),m=w.length;m--;){const v=s.slice(w[m],w[m+1]),k=i.pop();l.push([k,k+v.length-1]),e.splice(k,2,v)}for(l.reverse(),m=-1;++m<l.length;)u[g+l[m][0]]=g+l[m][1],g+=l[m][1]-l[m][0]-1;return u}const o9e={resolve:l9e,tokenize:c9e},s9e={partial:!0,tokenize:u9e};function l9e(e){return pv(e),e}function c9e(e,t){let n;return r;function r(s){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(s)}function a(s){return s===null?i(s):he(s)?e.check(s9e,o,i)(s):(e.consume(s),a)}function i(s){return e.exit("chunkContent"),e.exit("content"),t(s)}function o(s){return e.consume(s),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,a}}function u9e(e,t,n){const r=this;return a;function a(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Te(e,i,"linePrefix")}function i(o){if(o===null||he(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&s[1].type==="linePrefix"&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function hv(e,t,n,r,a,i,o,s,l){const u=l||Number.POSITIVE_INFINITY;let d=0;return p;function p(v){return v===60?(e.enter(r),e.enter(a),e.enter(i),e.consume(v),e.exit(i),m):v===null||v===32||v===41||zi(v)?n(v):(e.enter(r),e.enter(o),e.enter(s),e.enter("chunkString",{contentType:"string"}),f(v))}function m(v){return v===62?(e.enter(i),e.consume(v),e.exit(i),e.exit(a),e.exit(r),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),h(v))}function h(v){return v===62?(e.exit("chunkString"),e.exit(s),m(v)):v===null||v===60||he(v)?n(v):(e.consume(v),v===92?g:h)}function g(v){return v===60||v===62||v===92?(e.consume(v),h):h(v)}function f(v){return!d&&(v===null||v===41||Be(v))?(e.exit("chunkString"),e.exit(s),e.exit(o),e.exit(r),t(v)):d<u&&v===40?(e.consume(v),d++,f):v===41?(e.consume(v),d--,f):v===null||v===32||v===40||zi(v)?n(v):(e.consume(v),v===92?w:f)}function w(v){return v===40||v===41||v===92?(e.consume(v),f):f(v)}}function mv(e,t,n,r,a,i){const o=this;let s=0,l;return u;function u(h){return e.enter(r),e.enter(a),e.consume(h),e.exit(a),e.enter(i),d}function d(h){return s>999||h===null||h===91||h===93&&!l||h===94&&!s&&"_hiddenFootnoteSupport"in o.parser.constructs?n(h):h===93?(e.exit(i),e.enter(a),e.consume(h),e.exit(a),e.exit(r),t):he(h)?(e.enter("lineEnding"),e.consume(h),e.exit("lineEnding"),d):(e.enter("chunkString",{contentType:"string"}),p(h))}function p(h){return h===null||h===91||h===93||he(h)||s++>999?(e.exit("chunkString"),d(h)):(e.consume(h),l||(l=!Oe(h)),h===92?m:p)}function m(h){return h===91||h===92||h===93?(e.consume(h),s++,p):p(h)}}function fv(e,t,n,r,a,i){let o;return s;function s(m){return m===34||m===39||m===40?(e.enter(r),e.enter(a),e.consume(m),e.exit(a),o=m===40?41:m,l):n(m)}function l(m){return m===o?(e.enter(a),e.consume(m),e.exit(a),e.exit(r),t):(e.enter(i),u(m))}function u(m){return m===o?(e.exit(i),l(o)):m===null?n(m):he(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),Te(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(m))}function d(m){return m===o||m===null||he(m)?(e.exit("chunkString"),u(m)):(e.consume(m),m===92?p:d)}function p(m){return m===o||m===92?(e.consume(m),d):d(m)}}function On(e,t){let n;return r;function r(a){return he(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):Oe(a)?Te(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const d9e={name:"definition",tokenize:h9e},p9e={partial:!0,tokenize:m9e};function h9e(e,t,n){const r=this;let a;return i;function i(h){return e.enter("definition"),o(h)}function o(h){return mv.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function s(h){return a=pn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),l):n(h)}function l(h){return Be(h)?On(e,u)(h):u(h)}function u(h){return hv(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(p9e,p,p)(h)}function p(h){return Oe(h)?Te(e,m,"whitespace")(h):m(h)}function m(h){return h===null||he(h)?(e.exit("definition"),r.parser.defined.push(a),t(h)):n(h)}}function m9e(e,t,n){return r;function r(s){return Be(s)?On(e,a)(s):n(s)}function a(s){return fv(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(s)}function i(s){return Oe(s)?Te(e,o,"whitespace")(s):o(s)}function o(s){return s===null||he(s)?t(s):n(s)}}const f9e={name:"hardBreakEscape",tokenize:g9e};function g9e(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),a}function a(i){return he(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const y9e={name:"headingAtx",resolve:b9e,tokenize:k9e};function b9e(e,t){let n=e.length-2,r=3,a,i;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Gt(e,r,n-r+1,[["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t]])),e}function k9e(e,t,n){let r=0;return a;function a(d){return e.enter("atxHeading"),i(d)}function i(d){return e.enter("atxHeadingSequence"),o(d)}function o(d){return d===35&&r++<6?(e.consume(d),o):d===null||Be(d)?(e.exit("atxHeadingSequence"),s(d)):n(d)}function s(d){return d===35?(e.enter("atxHeadingSequence"),l(d)):d===null||he(d)?(e.exit("atxHeading"),t(d)):Oe(d)?Te(e,s,"whitespace")(d):(e.enter("atxHeadingText"),u(d))}function l(d){return d===35?(e.consume(d),l):(e.exit("atxHeadingSequence"),s(d))}function u(d){return d===null||d===35||Be(d)?(e.exit("atxHeadingText"),s(d)):(e.consume(d),u)}}const v9e=["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"],W2=["pre","script","style","textarea"],_9e={concrete:!0,name:"htmlFlow",resolveTo:E9e,tokenize:M9e},w9e={partial:!0,tokenize:N9e},x9e={partial:!0,tokenize:S9e};function E9e(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function M9e(e,t,n){const r=this;let a,i,o,s,l;return u;function u(O){return d(O)}function d(O){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(O),p}function p(O){return O===33?(e.consume(O),m):O===47?(e.consume(O),i=!0,f):O===63?(e.consume(O),a=3,r.interrupt?t:A):Tt(O)?(e.consume(O),o=String.fromCharCode(O),w):n(O)}function m(O){return O===45?(e.consume(O),a=2,h):O===91?(e.consume(O),a=5,s=0,g):Tt(O)?(e.consume(O),a=4,r.interrupt?t:A):n(O)}function h(O){return O===45?(e.consume(O),r.interrupt?t:A):n(O)}function g(O){const le="CDATA[";return O===le.charCodeAt(s++)?(e.consume(O),s===le.length?r.interrupt?t:X:g):n(O)}function f(O){return Tt(O)?(e.consume(O),o=String.fromCharCode(O),w):n(O)}function w(O){if(O===null||O===47||O===62||Be(O)){const le=O===47,fe=o.toLowerCase();return!le&&!i&&W2.includes(fe)?(a=1,r.interrupt?t(O):X(O)):v9e.includes(o.toLowerCase())?(a=6,le?(e.consume(O),v):r.interrupt?t(O):X(O)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(O):i?k(O):_(O))}return O===45||wt(O)?(e.consume(O),o+=String.fromCharCode(O),w):n(O)}function v(O){return O===62?(e.consume(O),r.interrupt?t:X):n(O)}function k(O){return Oe(O)?(e.consume(O),k):L(O)}function _(O){return O===47?(e.consume(O),L):O===58||O===95||Tt(O)?(e.consume(O),E):Oe(O)?(e.consume(O),_):L(O)}function E(O){return O===45||O===46||O===58||O===95||wt(O)?(e.consume(O),E):S(O)}function S(O){return O===61?(e.consume(O),x):Oe(O)?(e.consume(O),S):_(O)}function x(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),l=O,D):Oe(O)?(e.consume(O),x):P(O)}function D(O){return O===l?(e.consume(O),l=null,C):O===null||he(O)?n(O):(e.consume(O),D)}function P(O){return O===null||O===34||O===39||O===47||O===60||O===61||O===62||O===96||Be(O)?S(O):(e.consume(O),P)}function C(O){return O===47||O===62||Oe(O)?_(O):n(O)}function L(O){return O===62?(e.consume(O),G):n(O)}function G(O){return O===null||he(O)?X(O):Oe(O)?(e.consume(O),G):n(O)}function X(O){return O===45&&a===2?(e.consume(O),U):O===60&&a===1?(e.consume(O),H):O===62&&a===4?(e.consume(O),Y):O===63&&a===3?(e.consume(O),A):O===93&&a===5?(e.consume(O),j):he(O)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(w9e,ee,J)(O)):O===null||he(O)?(e.exit("htmlFlowData"),J(O)):(e.consume(O),X)}function J(O){return e.check(x9e,K,ee)(O)}function K(O){return e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),R}function R(O){return O===null||he(O)?J(O):(e.enter("htmlFlowData"),X(O))}function U(O){return O===45?(e.consume(O),A):X(O)}function H(O){return O===47?(e.consume(O),o="",z):X(O)}function z(O){if(O===62){const le=o.toLowerCase();return W2.includes(le)?(e.consume(O),Y):X(O)}return Tt(O)&&o.length<8?(e.consume(O),o+=String.fromCharCode(O),z):X(O)}function j(O){return O===93?(e.consume(O),A):X(O)}function A(O){return O===62?(e.consume(O),Y):O===45&&a===2?(e.consume(O),A):X(O)}function Y(O){return O===null||he(O)?(e.exit("htmlFlowData"),ee(O)):(e.consume(O),Y)}function ee(O){return e.exit("htmlFlow"),t(O)}}function S9e(e,t,n){const r=this;return a;function a(o){return he(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):n(o)}function i(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function N9e(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Oa,t,n)}}const A9e={name:"htmlText",tokenize:T9e};function T9e(e,t,n){const r=this;let a,i,o;return s;function s(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),l}function l(A){return A===33?(e.consume(A),u):A===47?(e.consume(A),S):A===63?(e.consume(A),_):Tt(A)?(e.consume(A),P):n(A)}function u(A){return A===45?(e.consume(A),d):A===91?(e.consume(A),i=0,g):Tt(A)?(e.consume(A),k):n(A)}function d(A){return A===45?(e.consume(A),h):n(A)}function p(A){return A===null?n(A):A===45?(e.consume(A),m):he(A)?(o=p,H(A)):(e.consume(A),p)}function m(A){return A===45?(e.consume(A),h):p(A)}function h(A){return A===62?U(A):A===45?m(A):p(A)}function g(A){const Y="CDATA[";return A===Y.charCodeAt(i++)?(e.consume(A),i===Y.length?f:g):n(A)}function f(A){return A===null?n(A):A===93?(e.consume(A),w):he(A)?(o=f,H(A)):(e.consume(A),f)}function w(A){return A===93?(e.consume(A),v):f(A)}function v(A){return A===62?U(A):A===93?(e.consume(A),v):f(A)}function k(A){return A===null||A===62?U(A):he(A)?(o=k,H(A)):(e.consume(A),k)}function _(A){return A===null?n(A):A===63?(e.consume(A),E):he(A)?(o=_,H(A)):(e.consume(A),_)}function E(A){return A===62?U(A):_(A)}function S(A){return Tt(A)?(e.consume(A),x):n(A)}function x(A){return A===45||wt(A)?(e.consume(A),x):D(A)}function D(A){return he(A)?(o=D,H(A)):Oe(A)?(e.consume(A),D):U(A)}function P(A){return A===45||wt(A)?(e.consume(A),P):A===47||A===62||Be(A)?C(A):n(A)}function C(A){return A===47?(e.consume(A),U):A===58||A===95||Tt(A)?(e.consume(A),L):he(A)?(o=C,H(A)):Oe(A)?(e.consume(A),C):U(A)}function L(A){return A===45||A===46||A===58||A===95||wt(A)?(e.consume(A),L):G(A)}function G(A){return A===61?(e.consume(A),X):he(A)?(o=G,H(A)):Oe(A)?(e.consume(A),G):C(A)}function X(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),a=A,J):he(A)?(o=X,H(A)):Oe(A)?(e.consume(A),X):(e.consume(A),K)}function J(A){return A===a?(e.consume(A),a=void 0,R):A===null?n(A):he(A)?(o=J,H(A)):(e.consume(A),J)}function K(A){return A===null||A===34||A===39||A===60||A===61||A===96?n(A):A===47||A===62||Be(A)?C(A):(e.consume(A),K)}function R(A){return A===47||A===62||Be(A)?C(A):n(A)}function U(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),t):n(A)}function H(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),z}function z(A){return Oe(A)?Te(e,j,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):j(A)}function j(A){return e.enter("htmlTextData"),o(A)}}const vp={name:"labelEnd",resolveAll:O9e,resolveTo:L9e,tokenize:D9e},C9e={tokenize:z9e},R9e={tokenize:$9e},I9e={tokenize:F9e};function O9e(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&Gt(e,0,e.length,n),e}function L9e(e,t){let n=e.length,r=0,a,i,o,s;for(;n--;)if(a=e[n][1],i){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(i=n,a.type!=="labelLink")){r=2;break}}else a.type==="labelEnd"&&(o=n);const l={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[i][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[o-2][1].start}};return s=[["enter",l,t],["enter",u,t]],s=Jt(s,e.slice(i+1,i+r+3)),s=Jt(s,[["enter",d,t]]),s=Jt(s,bo(t.parser.constructs.insideSpan.null,e.slice(i+r+4,o-3),t)),s=Jt(s,[["exit",d,t],e[o-2],e[o-1],["exit",u,t]]),s=Jt(s,e.slice(o+1)),s=Jt(s,[["exit",l,t]]),Gt(e,i,e.length,s),e}function D9e(e,t,n){const r=this;let a=r.events.length,i,o;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){i=r.events[a][1];break}return s;function s(m){return i?i._inactive?p(m):(o=r.parser.defined.includes(pn(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(m),e.exit("labelMarker"),e.exit("labelEnd"),l):n(m)}function l(m){return m===40?e.attempt(C9e,d,o?d:p)(m):m===91?e.attempt(R9e,d,o?u:p)(m):o?d(m):p(m)}function u(m){return e.attempt(I9e,d,p)(m)}function d(m){return t(m)}function p(m){return i._balanced=!0,n(m)}}function z9e(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),a}function a(p){return Be(p)?On(e,i)(p):i(p)}function i(p){return p===41?d(p):hv(e,o,s,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function o(p){return Be(p)?On(e,l)(p):d(p)}function s(p){return n(p)}function l(p){return p===34||p===39||p===40?fv(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):d(p)}function u(p){return Be(p)?On(e,d)(p):d(p)}function d(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function $9e(e,t,n){const r=this;return a;function a(s){return mv.call(r,e,i,o,"reference","referenceMarker","referenceString")(s)}function i(s){return r.parser.defined.includes(pn(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(s):n(s)}function o(s){return n(s)}}function F9e(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),a}function a(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const P9e={name:"labelStartImage",resolveAll:vp.resolveAll,tokenize:q9e};function q9e(e,t,n){const r=this;return a;function a(s){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(s),e.exit("labelImageMarker"),i}function i(s){return s===91?(e.enter("labelMarker"),e.consume(s),e.exit("labelMarker"),e.exit("labelImage"),o):n(s)}function o(s){return s===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(s):t(s)}}const B9e={name:"labelStartLink",resolveAll:vp.resolveAll,tokenize:U9e};function U9e(e,t,n){const r=this;return a;function a(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),i}function i(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const as={name:"lineEnding",tokenize:H9e};function H9e(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Te(e,t,"linePrefix")}}const wi={name:"thematicBreak",tokenize:j9e};function j9e(e,t,n){let r=0,a;return i;function i(u){return e.enter("thematicBreak"),o(u)}function o(u){return a=u,s(u)}function s(u){return u===a?(e.enter("thematicBreakSequence"),l(u)):r>=3&&(u===null||he(u))?(e.exit("thematicBreak"),t(u)):n(u)}function l(u){return u===a?(e.consume(u),r++,l):(e.exit("thematicBreakSequence"),Oe(u)?Te(e,s,"whitespace")(u):s(u))}}const Dt={continuation:{tokenize:K9e},exit:Z9e,name:"list",tokenize:W9e},V9e={partial:!0,tokenize:X9e},G9e={partial:!0,tokenize:Y9e};function W9e(e,t,n){const r=this,a=r.events[r.events.length-1];let i=a&&a[1].type==="linePrefix"?a[2].sliceSerialize(a[1],!0).length:0,o=0;return s;function s(h){const g=r.containerState.type||(h===42||h===43||h===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||h===r.containerState.marker:dd(h)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),h===42||h===45?e.check(wi,n,u)(h):u(h);if(!r.interrupt||h===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(h)}return n(h)}function l(h){return dd(h)&&++o<10?(e.consume(h),l):(!r.interrupt||o<2)&&(r.containerState.marker?h===r.containerState.marker:h===41||h===46)?(e.exit("listItemValue"),u(h)):n(h)}function u(h){return e.enter("listItemMarker"),e.consume(h),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||h,e.check(Oa,r.interrupt?n:d,e.attempt(V9e,m,p))}function d(h){return r.containerState.initialBlankLine=!0,i++,m(h)}function p(h){return Oe(h)?(e.enter("listItemPrefixWhitespace"),e.consume(h),e.exit("listItemPrefixWhitespace"),m):n(h)}function m(h){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(h)}}function K9e(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Oa,a,i);function a(s){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Te(e,t,"listItemIndent",r.containerState.size+1)(s)}function i(s){return r.containerState.furtherBlankLines||!Oe(s)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(s)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(G9e,t,o)(s))}function o(s){return r.containerState._closeFlow=!0,r.interrupt=void 0,Te(e,e.attempt(Dt,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s)}}function Y9e(e,t,n){const r=this;return Te(e,a,"listItemIndent",r.containerState.size+1);function a(i){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(i):n(i)}}function Z9e(e){e.exit(this.containerState.type)}function X9e(e,t,n){const r=this;return Te(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(i){const o=r.events[r.events.length-1];return!Oe(i)&&o&&o[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const K2={name:"setextUnderline",resolveTo:Q9e,tokenize:J9e};function Q9e(e,t){let n=e.length,r,a,i;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!i&&e[n][1].type==="definition"&&(i=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[a][1].type="setextHeadingText",i?(e.splice(a,0,["enter",o,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function J9e(e,t,n){const r=this;let a;return i;function i(u){let d=r.events.length,p;for(;d--;)if(r.events[d][1].type!=="lineEnding"&&r.events[d][1].type!=="linePrefix"&&r.events[d][1].type!=="content"){p=r.events[d][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),a=u,o(u)):n(u)}function o(u){return e.enter("setextHeadingLineSequence"),s(u)}function s(u){return u===a?(e.consume(u),s):(e.exit("setextHeadingLineSequence"),Oe(u)?Te(e,l,"lineSuffix")(u):l(u))}function l(u){return u===null||he(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const eEe={tokenize:tEe};function tEe(e){const t=this,n=e.attempt(Oa,r,e.attempt(this.parser.constructs.flowInitial,a,Te(e,e.attempt(this.parser.constructs.flow,a,e.attempt(o9e,a)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function a(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const nEe={resolveAll:yv()},rEe=gv("string"),aEe=gv("text");function gv(e){return{resolveAll:yv(e==="text"?iEe:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],i=n.attempt(a,o,s);return o;function o(d){return u(d)?i(d):s(d)}function s(d){if(d===null){n.consume(d);return}return n.enter("data"),n.consume(d),l}function l(d){return u(d)?(n.exit("data"),i(d)):(n.consume(d),l)}function u(d){if(d===null)return!0;const p=a[d];let m=-1;if(p)for(;++m<p.length;){const h=p[m];if(!h.previous||h.previous.call(r,r.previous))return!0}return!1}}}function yv(e){return t;function t(n,r){let a=-1,i;for(;++a<=n.length;)i===void 0?n[a]&&n[a][1].type==="data"&&(i=a,a++):(!n[a]||n[a][1].type!=="data")&&(a!==i+2&&(n[i][1].end=n[a-1][1].end,n.splice(i+2,a-i-2),a=i+2),i=void 0);return e?e(n,r):n}}function iEe(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let i=a.length,o=-1,s=0,l;for(;i--;){const u=a[i];if(typeof u=="string"){for(o=u.length;u.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(u===-2)l=!0,s++;else if(u!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){const u={type:n===e.length||l||s<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?o:r.start._bufferIndex+o,_index:r.start._index+i,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const oEe={42:Dt,43:Dt,45:Dt,48:Dt,49:Dt,50:Dt,51:Dt,52:Dt,53:Dt,54:Dt,55:Dt,56:Dt,57:Dt,62:cv},sEe={91:d9e},lEe={[-2]:rs,[-1]:rs,32:rs},cEe={35:y9e,42:wi,45:[K2,wi],60:_9e,61:K2,95:wi,96:G2,126:G2},uEe={38:dv,92:uv},dEe={[-5]:as,[-4]:as,[-3]:as,33:P9e,38:dv,42:pd,60:[Bxe,A9e],91:B9e,92:[f9e,uv],93:vp,95:pd,96:e9e},pEe={null:[pd,nEe]},hEe={null:[42,95]},mEe={null:[]},fEe=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:hEe,contentInitial:sEe,disable:mEe,document:oEe,flow:cEe,flowInitial:lEe,insideSpan:pEe,string:uEe,text:dEe},Symbol.toStringTag,{value:"Module"}));function gEe(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},i=[];let o=[],s=[];const l={attempt:D(S),check:D(x),consume:k,enter:_,exit:E,interrupt:D(x,{interrupt:!0})},u={code:null,containerState:{},defineSkip:f,events:[],now:g,parser:e,previous:null,sliceSerialize:m,sliceStream:h,write:p};let d=t.tokenize.call(u,l);return t.resolveAll&&i.push(t),u;function p(G){return o=Jt(o,G),w(),o[o.length-1]!==null?[]:(P(t,0),u.events=bo(i,u.events,u),u.events)}function m(G,X){return bEe(h(G),X)}function h(G){return yEe(o,G)}function g(){const{_bufferIndex:G,_index:X,line:J,column:K,offset:R}=r;return{_bufferIndex:G,_index:X,line:J,column:K,offset:R}}function f(G){a[G.line]=G.column,L()}function w(){let G;for(;r._index<o.length;){const X=o[r._index];if(typeof X=="string")for(G=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===G&&r._bufferIndex<X.length;)v(X.charCodeAt(r._bufferIndex));else v(X)}}function v(G){d=d(G)}function k(G){he(G)?(r.line++,r.column=1,r.offset+=G===-3?2:1,L()):G!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=G}function _(G,X){const J=X||{};return J.type=G,J.start=g(),u.events.push(["enter",J,u]),s.push(J),J}function E(G){const X=s.pop();return X.end=g(),u.events.push(["exit",X,u]),X}function S(G,X){P(G,X.from)}function x(G,X){X.restore()}function D(G,X){return J;function J(K,R,U){let H,z,j,A;return Array.isArray(K)?ee(K):"tokenize"in K?ee([K]):Y(K);function Y(ke){return Ce;function Ce($e){const tt=$e!==null&&ke[$e],Ve=$e!==null&&ke.null,ae=[...Array.isArray(tt)?tt:tt?[tt]:[],...Array.isArray(Ve)?Ve:Ve?[Ve]:[]];return ee(ae)($e)}}function ee(ke){return H=ke,z=0,ke.length===0?U:O(ke[z])}function O(ke){return Ce;function Ce($e){return A=C(),j=ke,ke.partial||(u.currentConstruct=ke),ke.name&&u.parser.constructs.disable.null.includes(ke.name)?fe():ke.tokenize.call(X?Object.assign(Object.create(u),X):u,l,le,fe)($e)}}function le(ke){return G(j,A),R}function fe(ke){return A.restore(),++z<H.length?O(H[z]):U}}}function P(G,X){G.resolveAll&&!i.includes(G)&&i.push(G),G.resolve&&Gt(u.events,X,u.events.length-X,G.resolve(u.events.slice(X),u)),G.resolveTo&&(u.events=G.resolveTo(u.events,u))}function C(){const G=g(),X=u.previous,J=u.currentConstruct,K=u.events.length,R=Array.from(s);return{from:K,restore:U};function U(){r=G,u.previous=X,u.currentConstruct=J,u.events.length=K,s=R,L()}}function L(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function yEe(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,i=t.end._bufferIndex;let o;if(n===a)o=[e[n].slice(r,i)];else{if(o=e.slice(n,a),r>-1){const s=o[0];typeof s=="string"?o[0]=s.slice(r):o.shift()}i>0&&o.push(e[a].slice(0,i))}return o}function bEe(e,t){let n=-1;const r=[];let a;for(;++n<e.length;){const i=e[n];let o;if(typeof i=="string")o=i;else switch(i){case-5:{o="\r";break}case-4:{o=`
|
|
8298
8298
|
`;break}case-3:{o=`\r
|
|
8299
8299
|
`;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&a)continue;o=" ";break}default:o=String.fromCharCode(i)}a=i===-2,r.push(o)}return r.join("")}function kEe(e){const r={constructs:sv([fEe,...(e||{}).extensions||[]]),content:a(Lxe),defined:[],document:a(zxe),flow:a(eEe),lazy:{},string:a(rEe),text:a(aEe)};return r;function a(i){return o;function o(s){return gEe(r,i,s)}}}function vEe(e){for(;!pv(e););return e}const Y2=/[\0\t\n\r]/g;function _Ee(){let e=1,t="",n=!0,r;return a;function a(i,o,s){const l=[];let u,d,p,m,h;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(o||void 0).decode(i)),p=0,t="",n&&(i.charCodeAt(0)===65279&&p++,n=void 0);p<i.length;){if(Y2.lastIndex=p,u=Y2.exec(i),m=u&&u.index!==void 0?u.index:i.length,h=i.charCodeAt(m),!u){t=i.slice(p);break}if(h===10&&p===m&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),p<m&&(l.push(i.slice(p,m)),e+=m-p),h){case 0:{l.push(65533),e++;break}case 9:{for(d=Math.ceil(e/4)*4,l.push(-2);e++<d;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}p=m+1}return s&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const wEe=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function xEe(e){return e.replace(wEe,EEe)}function EEe(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),i=a===120||a===88;return lv(n.slice(i?2:1),i?16:10)}return ka(n)||e}const bv={}.hasOwnProperty;function MEe(e,t,n){return typeof t!="string"&&(n=t,t=void 0),SEe(n)(vEe(kEe(n).document().write(_Ee()(e,t,!0))))}function SEe(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(Ze),autolinkProtocol:C,autolinkEmail:C,atxHeading:i(Ae),blockQuote:i(Ve),characterEscape:C,characterReference:C,codeFenced:i(ae),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:i(ae,o),codeText:i(Se,o),codeTextData:C,data:C,codeFlowValue:C,definition:i(qe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:i(We),hardBreakEscape:i(ve),hardBreakTrailing:i(ve),htmlFlow:i(Ge,o),htmlFlowData:C,htmlText:i(Ge,o),htmlTextData:C,image:i(de),label:o,link:i(Ze),listItem:i(He),listItemValue:m,listOrdered:i(Ke,p),listUnordered:i(Ke),paragraph:i(ce),reference:O,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:i(Ae),strong:i(Me),thematicBreak:i(Fe)},exit:{atxHeading:l(),atxHeadingSequence:S,autolink:l(),autolinkEmail:tt,autolinkProtocol:$e,blockQuote:l(),characterEscapeValue:L,characterReferenceMarkerHexadecimal:fe,characterReferenceMarkerNumeric:fe,characterReferenceValue:ke,characterReference:Ce,codeFenced:l(w),codeFencedFence:f,codeFencedFenceInfo:h,codeFencedFenceMeta:g,codeFlowValue:L,codeIndented:l(v),codeText:l(R),codeTextData:L,data:L,definition:l(),definitionDestinationString:E,definitionLabelString:k,definitionTitleString:_,emphasis:l(),hardBreakEscape:l(X),hardBreakTrailing:l(X),htmlFlow:l(J),htmlFlowData:L,htmlText:l(K),htmlTextData:L,image:l(H),label:j,labelText:z,lineEnding:G,link:l(U),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:le,resourceDestinationString:A,resourceTitleString:Y,resource:ee,setextHeading:l(P),setextHeadingLineSequence:D,setextHeadingText:x,strong:l(),thematicBreak:l()}};kv(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(q){let Z={type:"root",children:[]};const ne={stack:[Z],tokenStack:[],config:t,enter:s,exit:u,buffer:o,resume:d,data:n},pe=[];let Ee=-1;for(;++Ee<q.length;)if(q[Ee][1].type==="listOrdered"||q[Ee][1].type==="listUnordered")if(q[Ee][0]==="enter")pe.push(Ee);else{const Le=pe.pop();Ee=a(q,Le,Ee)}for(Ee=-1;++Ee<q.length;){const Le=t[q[Ee][0]];bv.call(Le,q[Ee][1].type)&&Le[q[Ee][1].type].call(Object.assign({sliceSerialize:q[Ee][2].sliceSerialize},ne),q[Ee][1])}if(ne.tokenStack.length>0){const Le=ne.tokenStack[ne.tokenStack.length-1];(Le[1]||Z2).call(ne,void 0,Le[0])}for(Z.position={start:Vn(q.length>0?q[0][1].start:{line:1,column:1,offset:0}),end:Vn(q.length>0?q[q.length-2][1].end:{line:1,column:1,offset:0})},Ee=-1;++Ee<t.transforms.length;)Z=t.transforms[Ee](Z)||Z;return Z}function a(q,Z,ne){let pe=Z-1,Ee=-1,Le=!1,mt,bt,Hn,jn;for(;++pe<=ne;){const ht=q[pe];switch(ht[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ht[0]==="enter"?Ee++:Ee--,jn=void 0;break}case"lineEndingBlank":{ht[0]==="enter"&&(mt&&!jn&&!Ee&&!Hn&&(Hn=pe),jn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:jn=void 0}if(!Ee&&ht[0]==="enter"&&ht[1].type==="listItemPrefix"||Ee===-1&&ht[0]==="exit"&&(ht[1].type==="listUnordered"||ht[1].type==="listOrdered")){if(mt){let Mt=pe;for(bt=void 0;Mt--;){const It=q[Mt];if(It[1].type==="lineEnding"||It[1].type==="lineEndingBlank"){if(It[0]==="exit")continue;bt&&(q[bt][1].type="lineEndingBlank",Le=!0),It[1].type="lineEnding",bt=Mt}else if(!(It[1].type==="linePrefix"||It[1].type==="blockQuotePrefix"||It[1].type==="blockQuotePrefixWhitespace"||It[1].type==="blockQuoteMarker"||It[1].type==="listItemIndent"))break}Hn&&(!bt||Hn<bt)&&(mt._spread=!0),mt.end=Object.assign({},bt?q[bt][1].start:ht[1].end),q.splice(bt||pe,0,["exit",mt,ht[2]]),pe++,ne++}if(ht[1].type==="listItemPrefix"){const Mt={type:"listItem",_spread:!1,start:Object.assign({},ht[1].start),end:void 0};mt=Mt,q.splice(pe,0,["enter",Mt,ht[2]]),pe++,ne++,Hn=void 0,jn=!0}}}return q[Z][1]._spread=Le,ne}function i(q,Z){return ne;function ne(pe){s.call(this,q(pe),pe),Z&&Z.call(this,pe)}}function o(){this.stack.push({type:"fragment",children:[]})}function s(q,Z,ne){this.stack[this.stack.length-1].children.push(q),this.stack.push(q),this.tokenStack.push([Z,ne||void 0]),q.position={start:Vn(Z.start),end:void 0}}function l(q){return Z;function Z(ne){q&&q.call(this,ne),u.call(this,ne)}}function u(q,Z){const ne=this.stack.pop(),pe=this.tokenStack.pop();if(pe)pe[0].type!==q.type&&(Z?Z.call(this,q,pe[0]):(pe[1]||Z2).call(this,q,pe[0]));else throw new Error("Cannot close `"+q.type+"` ("+la({start:q.start,end:q.end})+"): it’s not open");ne.position.end=Vn(q.end)}function d(){return kp(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function m(q){if(this.data.expectingFirstListItemValue){const Z=this.stack[this.stack.length-2];Z.start=Number.parseInt(this.sliceSerialize(q),10),this.data.expectingFirstListItemValue=void 0}}function h(){const q=this.resume(),Z=this.stack[this.stack.length-1];Z.lang=q}function g(){const q=this.resume(),Z=this.stack[this.stack.length-1];Z.meta=q}function f(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const q=this.resume(),Z=this.stack[this.stack.length-1];Z.value=q.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const q=this.resume(),Z=this.stack[this.stack.length-1];Z.value=q.replace(/(\r?\n|\r)$/g,"")}function k(q){const Z=this.resume(),ne=this.stack[this.stack.length-1];ne.label=Z,ne.identifier=pn(this.sliceSerialize(q)).toLowerCase()}function _(){const q=this.resume(),Z=this.stack[this.stack.length-1];Z.title=q}function E(){const q=this.resume(),Z=this.stack[this.stack.length-1];Z.url=q}function S(q){const Z=this.stack[this.stack.length-1];if(!Z.depth){const ne=this.sliceSerialize(q).length;Z.depth=ne}}function x(){this.data.setextHeadingSlurpLineEnding=!0}function D(q){const Z=this.stack[this.stack.length-1];Z.depth=this.sliceSerialize(q).codePointAt(0)===61?1:2}function P(){this.data.setextHeadingSlurpLineEnding=void 0}function C(q){const ne=this.stack[this.stack.length-1].children;let pe=ne[ne.length-1];(!pe||pe.type!=="text")&&(pe=ye(),pe.position={start:Vn(q.start),end:void 0},ne.push(pe)),this.stack.push(pe)}function L(q){const Z=this.stack.pop();Z.value+=this.sliceSerialize(q),Z.position.end=Vn(q.end)}function G(q){const Z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ne=Z.children[Z.children.length-1];ne.position.end=Vn(q.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Z.type)&&(C.call(this,q),L.call(this,q))}function X(){this.data.atHardBreak=!0}function J(){const q=this.resume(),Z=this.stack[this.stack.length-1];Z.value=q}function K(){const q=this.resume(),Z=this.stack[this.stack.length-1];Z.value=q}function R(){const q=this.resume(),Z=this.stack[this.stack.length-1];Z.value=q}function U(){const q=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";q.type+="Reference",q.referenceType=Z,delete q.url,delete q.title}else delete q.identifier,delete q.label;this.data.referenceType=void 0}function H(){const q=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";q.type+="Reference",q.referenceType=Z,delete q.url,delete q.title}else delete q.identifier,delete q.label;this.data.referenceType=void 0}function z(q){const Z=this.sliceSerialize(q),ne=this.stack[this.stack.length-2];ne.label=xEe(Z),ne.identifier=pn(Z).toLowerCase()}function j(){const q=this.stack[this.stack.length-1],Z=this.resume(),ne=this.stack[this.stack.length-1];if(this.data.inReference=!0,ne.type==="link"){const pe=q.children;ne.children=pe}else ne.alt=Z}function A(){const q=this.resume(),Z=this.stack[this.stack.length-1];Z.url=q}function Y(){const q=this.resume(),Z=this.stack[this.stack.length-1];Z.title=q}function ee(){this.data.inReference=void 0}function O(){this.data.referenceType="collapsed"}function le(q){const Z=this.resume(),ne=this.stack[this.stack.length-1];ne.label=Z,ne.identifier=pn(this.sliceSerialize(q)).toLowerCase(),this.data.referenceType="full"}function fe(q){this.data.characterReferenceType=q.type}function ke(q){const Z=this.sliceSerialize(q),ne=this.data.characterReferenceType;let pe;ne?(pe=lv(Z,ne==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):pe=ka(Z);const Ee=this.stack[this.stack.length-1];Ee.value+=pe}function Ce(q){const Z=this.stack.pop();Z.position.end=Vn(q.end)}function $e(q){L.call(this,q);const Z=this.stack[this.stack.length-1];Z.url=this.sliceSerialize(q)}function tt(q){L.call(this,q);const Z=this.stack[this.stack.length-1];Z.url="mailto:"+this.sliceSerialize(q)}function Ve(){return{type:"blockquote",children:[]}}function ae(){return{type:"code",lang:null,meta:null,value:""}}function Se(){return{type:"inlineCode",value:""}}function qe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function We(){return{type:"emphasis",children:[]}}function Ae(){return{type:"heading",depth:0,children:[]}}function ve(){return{type:"break"}}function Ge(){return{type:"html",value:""}}function de(){return{type:"image",title:null,url:"",alt:null}}function Ze(){return{type:"link",title:null,url:"",children:[]}}function Ke(q){return{type:"list",ordered:q.type==="listOrdered",start:null,spread:q._spread,children:[]}}function He(q){return{type:"listItem",spread:q._spread,checked:null,children:[]}}function ce(){return{type:"paragraph",children:[]}}function Me(){return{type:"strong",children:[]}}function ye(){return{type:"text",value:""}}function Fe(){return{type:"thematicBreak"}}}function Vn(e){return{line:e.line,column:e.column,offset:e.offset}}function kv(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?kv(e,r):NEe(e,r)}}function NEe(e,t){let n;for(n in t)if(bv.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function Z2(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+la({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+la({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+la({start:t.start,end:t.end})+") is still open")}function AEe(e){const t=this;t.parser=n;function n(r){return MEe(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function TEe(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function CEe(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -8615,5 +8615,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
8615
8615
|
`).slice(0,100).map(n=>n.length)))<=DHe}function FHe(e){const t=e.split(`
|
|
8616
8616
|
`),n=t.length;return n>Yi?{truncated:t.slice(0,Yi).join(`
|
|
8617
8617
|
`),isTruncated:!0,totalLines:n}:e.length>Od?{truncated:e.slice(0,Od),isTruncated:!0,totalLines:n}:{truncated:e,isTruncated:!1,totalLines:n}}const PHe={margin:0,padding:"12px 16px",background:"var(--mp-agents-surface)",fontSize:"13px",lineHeight:"1.5",overflowX:"auto"},w7=V.memo(({code:e,lang:t,highlight:n,prismStyle:r})=>n?N.jsx(_7,{language:t,style:r,PreTag:zHe,customStyle:PHe,children:e}):N.jsx("pre",{className:"mp-agent-code-block-pre",children:N.jsx("code",{children:e})}));w7.displayName="CodeContent";const x7=V.memo(({lang:e="text",codeChildren:t,allowExecution:n=!1})=>{const{colorMode:r}=v3(),a=Ld(t).replace(/\n$/,""),i=r==="light"?OHe:IHe,{truncated:o,isTruncated:s,totalLines:l}=V.useMemo(()=>FHe(a),[a]),[u,d]=V.useState(!1),p=V.useCallback(()=>d(g=>!g),[]),m=u?a:o,h=V.useMemo(()=>$He(m),[m]);return N.jsxs("div",{className:"mp-agent-code-block-wrapper",children:[N.jsxs("div",{className:"mp-agent-code-block-header",children:[N.jsx("span",{className:"mp-agent-code-block-language",children:e}),N.jsx(Jd,{text:a})]}),N.jsx("div",{className:"mp-agent-code-block-body",children:N.jsx(w7,{code:m,lang:e,highlight:h,prismStyle:i})}),s&&N.jsx("button",{type:"button",className:"mp-agent-code-block-toggle",onClick:p,children:u?"Show less":`Show more (${l>Yi?`${l-Yi} more lines`:`${a.length-Od} more chars`})`})]})});x7.displayName="CodeBlock";const qHe=e=>V.isValidElement(e)?e.key?.startsWith("code-")??!1:!1,BHe=V.memo(({className:e,children:t})=>{const n=/language-(\w+)/.exec(e??""),r=n&&n[1],a=r==="math",i=typeof t=="string"&&t.split(`
|
|
8618
|
-
`).length===1;if(a)return N.jsx(N.Fragment,{children:t});if(i||!n){const o=s=>{const l=window.getSelection();if(l){const u=document.createRange();u.selectNodeContents(s.currentTarget),l.removeAllRanges(),l.addRange(u)}};return N.jsx("code",{onDoubleClick:o,className:e||"mp-agent-inline-code",children:t})}return N.jsx(x7,{lang:r||void 0,codeChildren:t,allowExecution:!1})}),UHe=V.memo(({children:e,...t})=>{const r=(Array.isArray(e)?e:[e]).find(qHe);return r?N.jsx(N.Fragment,{children:r}):N.jsx("pre",{className:"mp-agent-markdown-pre",...t,children:e})}),HHe=V.memo(({children:e,...t})=>N.jsx("div",{className:"mp-agent-markdown-p",...t,children:e})),jHe=V.memo(({href:e,children:t,...n})=>{const r=e?.startsWith("http"),a=r?"_blank":void 0,i=r?"noopener noreferrer":void 0;return N.jsx("a",{href:e||void 0,target:a,rel:i,className:"mp-agent-markdown-link",...n,children:t})}),VHe=V.memo(({src:e,alt:t,title:n,className:r,style:a,...i})=>e?N.jsx("img",{src:e||void 0,alt:t,title:n,style:a,loading:"lazy",className:r||"mp-agent-markdown-img",...i}):null),E7={code:BHe,pre:UHe,p:HHe,a:jHe,img:VHe},GHe=[Q6,e6,e8,[Z6,{singleDollarTextMath:!1}]],WHe=[c8,[P8,{detect:!0,ignoreMissing:!0}]],KHe=V.memo(({text:e})=>N.jsx(Tv,{className:"mp-agent-message-markdown",remarkPlugins:GHe,rehypePlugins:WHe,components:E7,children:e})),M7=({content:e,role:t})=>{const n=t===exports.MessageRole.User,r=t===exports.MessageRole.Error,a=t===exports.MessageRole.Reasoning;return n?N.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:e}):r?N.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:e}):a?N.jsx("pre",{style:{margin:0,fontSize:"13px",opacity:.8},children:e}):N.jsx(KHe,{text:e})},S7=({text:e,isReasoning:t})=>t?null:N.jsx("div",{className:"mp-agent-message-actions",children:N.jsx(Jd,{text:e})}),N7=({message:e,showParticipantChrome:t=!1})=>{const n=e.role===exports.MessageRole.User,r=e.role===exports.MessageRole.Error,a=e.role===exports.MessageRole.Reasoning,i=!!e.content,o=(e.attachments?.length??0)>0,s=t&&!!(e.sender||e.agentName);return N.jsxs("div",{className:`mp-agent-message-wrapper ${n?"mp-agent-message-user":r?"mp-agent-message-error":"mp-agent-message-assistant"}`,children:[s&&N.jsx(dp,{message:e}),N.jsxs("div",{className:"mp-agent-message-content-wrapper",children:[s&&N.jsx(pp,{message:e}),N.jsxs("div",{className:`mp-agent-message-bubble ${n?"mp-agent-message-bubble-user":r?"mp-agent-message-bubble-error":"mp-agent-message-bubble-assistant"}`,children:[N.jsxs("div",{className:"mp-agent-message-text",children:[o&&N.jsx(I_e,{attachments:e.attachments??[]}),i&&N.jsx(M7,{content:e.content,role:e.role})]}),!n&&i&&N.jsx(S7,{text:e.content,isReasoning:a})]})]})]})},YHe=[Q6,e6,e8,[Z6,{singleDollarTextMath:!1}]],ZHe=[c8,[P8,{detect:!0,ignoreMissing:!0}]],Th=V.memo(({reasoning:e,isStreaming:t})=>{const[n,r]=V.useState(!t),a=V.useRef(null);if(V.useEffect(()=>{r(!t)},[t]),V.useEffect(()=>{if(n)return;const o=a.current;o&&(o.scrollTop=o.scrollHeight)},[e,n,a]),!e||!e.trim())return null;const i=o=>{o.preventDefault(),o.stopPropagation(),r(s=>!s)};return N.jsxs("div",{className:`mp-agent-reasoning-panel ${n?"mp-agent-reasoning-collapsed":""}`,children:[N.jsxs("div",{className:"mp-agent-reasoning-header",children:[N.jsx("span",{className:`mp-agent-reasoning-label ${t?"mp-agent-reasoning-label-streaming":""}`,children:"Thinking"}),N.jsx(nn,{icon:n?"ChevronDown":"ChevronUp",size:"sm",onClick:i})]}),!n&&N.jsx("div",{className:"mp-agent-reasoning-body",children:N.jsx("div",{className:"mp-agent-reasoning-content",ref:a,children:N.jsx(Tv,{className:"mp-agent-message-markdown mp-agent-reasoning-markdown",remarkPlugins:YHe,rehypePlugins:ZHe,components:E7,children:e})})})]})});Th.displayName="ReasoningPanel";const A7=()=>N.jsxs("span",{className:"mp-agent-message-typing-bubble",children:[N.jsx("span",{className:"mp-agent-message-typing-dot"}),N.jsx("span",{className:"mp-agent-message-typing-dot"}),N.jsx("span",{className:"mp-agent-message-typing-dot"})]}),XHe=({message:e,contextKey:t,isStreaming:n,showParticipantChrome:r=!1})=>{const o=Ue().config.features?.reasoning!==!1&&e.role===exports.MessageRole.Assistant&&!!e.reasoning,s=e.role===exports.MessageRole.Assistant&&typeof e.content=="string"&&e.content.trim().length>0,l=!!(n&&!o&&!s),u=typeof e.content=="string"&&e.content.trim().length>0||(e.attachments?.length??0)>0,d=(()=>{const p=e.toolCalls??[];if(p.length<=1)return p;const m=new Map;for(const h of p)m.set(h.id,h);return Array.from(m.values())})();return N.jsxs("div",{className:"mp-agent-message-group",children:[o&&N.jsx(Th,{reasoning:e.reasoning,isStreaming:n}),l&&N.jsx(A7,{}),u&&N.jsx(N7,{message:e,showParticipantChrome:r}),!n&&d.map(p=>N.jsx(hwe,{call:p,contextKey:t,messageId:e.id,chatId:e.chat},p.id))]})},Zi=V.memo(XHe),n5=[],QHe=120,JHe=e=>{const t=e.activeChatId;return t?e.chatState[t]?.messages??n5:n5},T7=({showParticipantChrome:e=!1})=>{const t=Wt(),n=be(S=>S.contextKey),r=be(S=>S.draftChatKey),a=be(S=>S.activeChatId),i=be(JHe),o=a??r,s=np(a),l=be(S=>ze(S,o).pendingAssistant?.content?.length),u=be(S=>ze(S,o).pendingAssistant?.id),d=be(S=>ze(S,o).status),p=d===vt.Sending||d===vt.Streaming,m=V.useRef(null),h=V.useRef(!0),g=V.useRef(!1),f=V.useRef(!1),w=V.useRef(null),v=swe({count:i.length,getScrollElement:()=>m.current,estimateSize:()=>QHe,overscan:8,gap:16,getItemKey:S=>i[S]?.id??S}),k=v.getVirtualItems(),_=V.useCallback(()=>{const S=m.current;S&&(S.scrollTop=S.scrollHeight)},[]);V.useEffect(()=>{if(i.length!==0){if(!g.current){g.current=!0,f.current=!0,v.scrollToIndex(i.length-1,{align:"end"}),requestAnimationFrame(()=>{_(),requestAnimationFrame(()=>{_(),f.current=!1})});return}h.current&&requestAnimationFrame(_)}},[i.length,v,_]),V.useLayoutEffect(()=>{const S=w.current,x=m.current;!S||!x||s.isFetchingNextPage||i.length<=S.count||(f.current=!0,S.wasAtBottom?x.scrollTop=x.scrollHeight:x.scrollTop=S.scrollTop+(x.scrollHeight-S.scrollHeight),w.current=null,requestAnimationFrame(()=>{f.current=!1}))},[i.length,s.isFetchingNextPage]),V.useEffect(()=>{p&&h.current&&_()},[l,p,_]),V.useEffect(()=>{const S=m.current;if(!S)return;const x=()=>{if(f.current)return;const{scrollTop:D,scrollHeight:P,clientHeight:C}=S;h.current=P-D-C<150};return S.addEventListener("scroll",x,{passive:!0}),()=>S.removeEventListener("scroll",x)},[]);const E=k[0]?.index??Number.POSITIVE_INFINITY;return V.useEffect(()=>{if(!s.hasNextPage||s.isFetchingNextPage||E>1)return;const S=m.current;S&&(w.current={scrollHeight:S.scrollHeight,scrollTop:S.scrollTop,count:i.length,wasAtBottom:h.current}),s.fetchNextPage()},[E,s.hasNextPage,s.isFetchingNextPage,s.fetchNextPage,i.length]),!a&&i.length===0&&!u?N.jsx("div",{className:"mp-agent-messages-empty",children:N.jsxs("div",{className:"mp-agent-messages-empty-content",children:[N.jsx("h4",{children:t.helloThere}),N.jsx("p",{children:t.howCanIHelpYou})]})}):a&&i.length===0&&s.isLoading?N.jsx("div",{className:"mp-agent-messages-empty",children:N.jsx("div",{className:"mp-agent-messages-empty-content",children:N.jsx("p",{children:t.fetchingChats})})}):N.jsxs("div",{className:"mp-agent-messages",ref:m,children:[s.isFetchingNextPage&&N.jsx("div",{className:"mp-agent-messages-load-more",children:N.jsx("div",{className:"mp-agent-messages-load-more-text",children:t.fetchingChats})}),N.jsx("div",{className:"mp-agent-messages-virtual-list",style:{height:v.getTotalSize()},children:k.map(S=>{const x=i[S.index];return x?N.jsx("div",{ref:v.measureElement,"data-index":S.index,className:"mp-agent-messages-virtual-item",style:{transform:`translateY(${S.start}px)`},children:N.jsx(Zi,{message:x,contextKey:n,showParticipantChrome:e})},S.key):null})}),!!u&&N.jsx(eje,{pendingKey:o,contextKey:n,showParticipantChrome:e}),N.jsx(H3,{})]})},eje=V.memo(({pendingKey:e,contextKey:t,showParticipantChrome:n})=>{const r=be(s=>ze(s,e)),a=r.pendingAssistant,i=r.status;if(!a)return null;const o=i===vt.Sending||i===vt.Streaming;return N.jsx(Zi,{message:a,contextKey:t,isStreaming:o,showParticipantChrome:n},a.id)}),C7=({onClose:e,agentLogo:t})=>{const n=Wt(),a=Ue().config.features?.historySidebar!==!1,i=be(u=>u.isChatHistoryOpen),o=be(u=>u.setChatHistoryOpen),s=be(u=>u.setActiveChat),l=()=>{s(void 0)};return N.jsxs("div",{className:"mp-agent-agent-controls",children:[N.jsxs("div",{className:"mp-agent-agent-controls-left",children:[a&&N.jsx(nn,{onClick:()=>o(!i),icon:i?"PanelLeftClose":"PanelLeftOpen",tooltip:i?n.hideChatHistory:n.showChatHistory,"aria-label":i?n.hideChatHistory:n.showChatHistory}),N.jsx(nn,{onClick:l,icon:"SquarePen","aria-label":n.newChat,tooltip:n.newChat})]}),t&&N.jsx("div",{className:"mp-agent-agent-controls-logo",children:t}),n.panelTitle&&N.jsx("div",{className:"mp-agent-agent-controls-title",children:N.jsx("h4",{children:n.panelTitle})}),e&&N.jsx("div",{className:"mp-agent-agent-controls-right",children:N.jsx(nn,{onClick:e,icon:"X","aria-label":n.close,tooltip:n.close})})]})},R7=({fetchNextPage:e,hasNextPage:t,isFetchingNextPage:n,itemRenderer:r}={})=>{const a=Wt(),{deleteChat:i,isDeleting:o}=rp(),s=be(h=>h.chats),l=be(h=>h.activeChatId),u=be(h=>h.setActiveChat),d=V.useRef(null),p=V.useRef(null),m=V.useMemo(()=>Object.values(s).filter(h=>h.sessionKind!==exports.AgentSessionKind.SUBAGENT).sort((h,g)=>h.updatedAt===g.updatedAt?0:h.updatedAt<g.updatedAt?1:-1),[s]);return V.useEffect(()=>{const h=d.current,g=p.current;if(!h||!g||!e||!t)return;const f=new IntersectionObserver(w=>{w[0]?.isIntersecting&&t&&!n&&e()},{root:h,rootMargin:"100px",threshold:0});return f.observe(g),()=>f.disconnect()},[e,t,n]),N.jsxs("section",{className:"mp-agent-chat-history",children:[N.jsx("h4",{children:a.chats}),m.length===0?N.jsx("div",{className:"mp-agent-chat-history-empty",children:a.noChatsYet}):N.jsxs("ul",{ref:d,className:"mp-agent-chat-history-list",children:[m.map(h=>{const g=h.id===l;return r?N.jsx("li",{onClick:()=>u(h.id),className:`mp-agent-chat-history-item${g?" active":""}`,children:r(h)},h.id):N.jsxs("li",{onClick:()=>u(h.id),className:`mp-agent-chat-history-item${g?" active":""}`,children:[N.jsxs("div",{className:"mp-agent-chat-history-item-content",children:[N.jsx("span",{className:"mp-agent-chat-history-item-title",children:h.title||a.untitledChat}),N.jsx("span",{className:"mp-agent-chat-history-item-meta",children:new Date(h.updatedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),N.jsx("div",{className:"mp-agent-chat-history-item-actions",children:N.jsx(bn,{content:a.deleteChat,children:N.jsx(nn,{size:"sm",icon:"Archive","aria-label":a.deleteChat,disabled:o(h.id),onClick:f=>{f.stopPropagation(),i(h.id)}})})})]},h.id)}),t&&N.jsxs("li",{className:"mp-agent-chat-history-sentinel","aria-hidden":!0,children:[N.jsx("div",{ref:p,className:"mp-agent-chat-history-sentinel-inner"}),n&&N.jsx("div",{className:"mp-agent-chat-history-loading",children:a.fetchingChats})]})]})]})},I7=({loadChats:e=!0,multiUser:t=!1})=>{const n=Ue(),r=be(o=>o.isChatHistoryOpen),a=n.config.features?.historySidebar!==!1,i=tp({enabled:e&&a,multiUser:t});return!a||!r?null:N.jsx("div",{className:"mp-agent-chat-history-panel",children:N.jsx(R7,{fetchNextPage:i.fetchNextPage,hasNextPage:i.hasNextPage,isFetchingNextPage:i.isFetchingNextPage})})},tje=({children:e})=>{const t=be(n=>n.isChatHistoryOpen);return N.jsx("section",{className:`mp-agent-main ${t?"with-chat-history":""}`,children:e})},O7=({onToolSelected:e,onClose:t,agentLogo:n,multiUser:r=!1,participantIds:a,loadChats:i=!0,restoreLastActiveChat:o=!0})=>{const s=Wt(),l=Ue(),u=be(g=>g.activeChatId),d=be(g=>g.setActiveChat),{isLoading:p}=d3(),{isLoading:m,error:h}=tp({enabled:i,multiUser:r});return V.useLayoutEffect(()=>{if(!o)return;const g=l.config.user?.id??Hr(),f=N7e(g);f&&d(f)},[o,l.config.user?.id,d]),N.jsxs("div",{className:"mp-agent-shell mp-agent-shell-panel",children:[N.jsx(I7,{loadChats:i,multiUser:r}),N.jsxs(tje,{children:[N.jsx(C7,{onClose:t,agentLogo:n}),N.jsx("div",{className:"mp-agent-main-content",children:m||p?N.jsx("div",{style:{padding:24},children:s.fetchingChats}):h?N.jsx("div",{style:{padding:24,color:"var(--mp-agents-danger)"},children:s.fetchingChatError}):N.jsx(T7,{showParticipantChrome:r},u)}),N.jsx(B3,{onToolSelected:e,multiUser:r,participantIds:a})]})]})},nje=e=>N.jsx(O7,{...e,multiUser:!0}),rje=({enabled:e=!0,className:t,pageSize:n=uo,showDelete:r=!0,onChatSelect:a})=>{const i=Wt(),o=yt.useQueryClient(),{deleteChat:s,isDeleting:l}=rp(),u=be(_=>_.upsertChat),d=be(_=>_.activeChatId),p=be(_=>_.setActiveChat),m=ep({enabled:e,multiUser:!0,pageSize:n}),h=V.useMemo(()=>n3(m.data).filter(_=>_.sessionKind!==exports.AgentSessionKind.SUBAGENT),[m.data]),g=V.useRef(null),f=V.useRef(null);V.useEffect(()=>{const _=g.current,E=f.current,{fetchNextPage:S,hasNextPage:x,isFetchingNextPage:D}=m;if(!_||!E||!S||!x)return;const P=new IntersectionObserver(C=>{C[0]?.isIntersecting&&x&&!D&&S()},{root:_,rootMargin:"100px",threshold:0});return P.observe(E),()=>P.disconnect()},[m,m.fetchNextPage,m.hasNextPage,m.isFetchingNextPage]);const w=_=>{u(_),p(_.id),a?.(_)},v=async(_,E)=>{_.stopPropagation(),await s(E),o.invalidateQueries({queryKey:In.all})},k=["mp-agent-chat-history","mp-agent-multiuser-chat-list",t].filter(Boolean).join(" ");return m.isError?N.jsxs("section",{className:k,children:[N.jsx("h4",{children:i.multiUserChats}),N.jsx("div",{className:"mp-agent-chat-history-empty",role:"alert",children:i.fetchingChatError})]}):m.isLoading?N.jsxs("section",{className:k,children:[N.jsx("h4",{children:i.multiUserChats}),N.jsx("div",{className:"mp-agent-chat-history-empty",children:i.fetchingChats})]}):N.jsxs("section",{className:k,children:[N.jsx("h4",{children:i.multiUserChats}),h.length===0?N.jsx("div",{className:"mp-agent-chat-history-empty",children:i.noMultiUserChats}):N.jsxs("ul",{ref:g,className:"mp-agent-chat-history-list",children:[h.map(_=>{const E=_.id===d,S=_.participantIds?.length??0;return N.jsxs("li",{onClick:()=>w(_),className:`mp-agent-chat-history-item${E?" active":""}`,children:[N.jsxs("div",{className:"mp-agent-chat-history-item-content",children:[N.jsx("span",{className:"mp-agent-chat-history-item-title",children:_.title||i.untitledChat}),N.jsxs("span",{className:"mp-agent-chat-history-item-meta",children:[S>0?`${S} · `:"",new Date(_.updatedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]}),r?N.jsx("div",{className:"mp-agent-chat-history-item-actions",children:N.jsx(bn,{content:i.deleteChat,children:N.jsx(nn,{size:"sm",icon:"Archive","aria-label":i.deleteChat,disabled:l(_.id),onClick:x=>void v(x,_.id)})})}):null]},_.id)}),m.hasNextPage?N.jsxs("li",{className:"mp-agent-chat-history-sentinel","aria-hidden":!0,children:[N.jsx("div",{ref:f,className:"mp-agent-chat-history-sentinel-inner"}),m.isFetchingNextPage?N.jsx("div",{className:"mp-agent-chat-history-loading",children:i.fetchingChats}):null]}):null]})]})},L7=V.forwardRef(({attachment:e,context:t,onAdded:n,onClick:r,...a},i)=>{const{addAttachments:o}=o3(),s=l=>{if(r?.(l),l.defaultPrevented)return;const d=(typeof e=="function"?e():e)??(()=>{const p=typeof t=="function"?t():t;return p?po(p):void 0})();d&&(o([d]),n?.(d))};return N.jsx("button",{ref:i,type:"button",...a,onClick:s})});L7.displayName="AttachContextButton";exports.AgentAttachmentSchema=d5;exports.AgentControls=C7;exports.AgentPreferencesPanel=q3;exports.AgentProvider=E_e;exports.AgentRuntime=g3;exports.AgentThemeProvider=k3;exports.AttachContextButton=L7;exports.BuiltinContextAttachmentKinds=c5;exports.CHATS_PAGE_SIZE=uo;exports.ChatHistory=R7;exports.ChatHistoryPanel=I7;exports.ChatWindow=O7;exports.Composer=B3;exports.ContextAttachmentMetadataSchemaV1=u5;exports.DEFAULT_MESSAGES_PAGE_SIZE=p3;exports.FormApplyRequestedEventType=Pd;exports.FormProposalToolRenderer=h3;exports.HttpError=Gu;exports.MessageActions=S7;exports.MessageAvatar=dp;exports.MessageBubble=N7;exports.MessageContent=M7;exports.MessageHeader=pp;exports.MessageList=T7;exports.MessageTypingAnimation=A7;exports.MultiUserChatList=rje;exports.MultiUserChatWindow=nje;exports.ReasoningPanel=Th;exports.SendMessagePayloadSchema=V7;exports.SocketIOConfig=Ai;exports.SocketIOEvents=fi;exports.activityKeys=Ht;exports.captureTextSelectionTarget=f3;exports.chatKeys=In;exports.contextKeySchema=l5;exports.createContextAttachment=po;exports.createPageContextAttachment=m3;exports.defaultTranslations=Ni;exports.flattenInfiniteActivities=o7e;exports.flattenInfiniteChats=n3;exports.frontendConfigSchema=Wu;exports.themeTokenSchema=s5;exports.translationsSchema=z7;exports.useActivitiesInfiniteList=s7e;exports.useActivitiesList=l7e;exports.useActivity=c7e;exports.useActivitySourceTypes=d7e;exports.useActivitySummary=u7e;exports.useAgentConfigurations=s3;exports.useAgentPreferences=u3;exports.useAgentRuntime=Ue;exports.useAgentStore=be;exports.useAgentTheme=v3;exports.useAutoScroll=h7e;exports.useChatBootstrap=tp;exports.useChats=r3;exports.useChatsInfiniteList=ep;exports.useChatsList=p7e;exports.useComposerDraft=o3;exports.useDeleteChat=rp;exports.useEnsureActiveChat=d3;exports.useMessagesInfinite=np;exports.useModels=a3;exports.usePageContext=f7e;exports.useProposeFormValues=g7e;exports.useRuntimeEventEmitter=l3;exports.useRuntimeEventListener=c3;exports.useTranslations=Wt;
|
|
8618
|
+
`).length===1;if(a)return N.jsx(N.Fragment,{children:t});if(i||!n){const o=s=>{const l=window.getSelection();if(l){const u=document.createRange();u.selectNodeContents(s.currentTarget),l.removeAllRanges(),l.addRange(u)}};return N.jsx("code",{onDoubleClick:o,className:e||"mp-agent-inline-code",children:t})}return N.jsx(x7,{lang:r||void 0,codeChildren:t,allowExecution:!1})}),UHe=V.memo(({children:e,...t})=>{const r=(Array.isArray(e)?e:[e]).find(qHe);return r?N.jsx(N.Fragment,{children:r}):N.jsx("pre",{className:"mp-agent-markdown-pre",...t,children:e})}),HHe=V.memo(({children:e,...t})=>N.jsx("div",{className:"mp-agent-markdown-p",...t,children:e})),jHe=V.memo(({href:e,children:t,...n})=>{const r=e?.startsWith("http"),a=r?"_blank":void 0,i=r?"noopener noreferrer":void 0;return N.jsx("a",{href:e||void 0,target:a,rel:i,className:"mp-agent-markdown-link",...n,children:t})}),VHe=V.memo(({src:e,alt:t,title:n,className:r,style:a,...i})=>e?N.jsx("img",{src:e||void 0,alt:t,title:n,style:a,loading:"lazy",className:r||"mp-agent-markdown-img",...i}):null),E7={code:BHe,pre:UHe,p:HHe,a:jHe,img:VHe},GHe=[Q6,e6,e8,[Z6,{singleDollarTextMath:!1}]],WHe=[c8,[P8,{detect:!0,ignoreMissing:!0}]],KHe=V.memo(({text:e})=>N.jsx(Tv,{className:"mp-agent-message-markdown",remarkPlugins:GHe,rehypePlugins:WHe,components:E7,children:e})),M7=({content:e,role:t})=>{const n=t===exports.MessageRole.User,r=t===exports.MessageRole.Error,a=t===exports.MessageRole.Reasoning;return n?N.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:e}):r?N.jsx("p",{style:{margin:0,whiteSpace:"pre-wrap"},children:e}):a?N.jsx("pre",{style:{margin:0,fontSize:"13px",opacity:.8},children:e}):N.jsx(KHe,{text:e})},S7=({text:e,isReasoning:t})=>t?null:N.jsx("div",{className:"mp-agent-message-actions",children:N.jsx(Jd,{text:e})}),N7=({message:e,showParticipantChrome:t=!1})=>{const n=e.role===exports.MessageRole.User,r=e.role===exports.MessageRole.Error,a=e.role===exports.MessageRole.Reasoning,i=!!e.content,o=(e.attachments?.length??0)>0,s=t&&!!(e.sender||e.agentName);return N.jsxs("div",{className:`mp-agent-message-wrapper ${n?"mp-agent-message-user":r?"mp-agent-message-error":"mp-agent-message-assistant"}`,children:[s&&N.jsx(dp,{message:e}),N.jsxs("div",{className:"mp-agent-message-content-wrapper",children:[s&&N.jsx(pp,{message:e}),N.jsxs("div",{className:`mp-agent-message-bubble ${n?"mp-agent-message-bubble-user":r?"mp-agent-message-bubble-error":"mp-agent-message-bubble-assistant"}`,children:[N.jsxs("div",{className:"mp-agent-message-text",children:[o&&N.jsx(I_e,{attachments:e.attachments??[]}),i&&N.jsx(M7,{content:e.content,role:e.role})]}),!n&&i&&N.jsx(S7,{text:e.content,isReasoning:a})]})]})]})},YHe=[Q6,e6,e8,[Z6,{singleDollarTextMath:!1}]],ZHe=[c8,[P8,{detect:!0,ignoreMissing:!0}]],Th=V.memo(({reasoning:e,isStreaming:t})=>{const[n,r]=V.useState(!t),a=V.useRef(null);if(V.useEffect(()=>{r(!t)},[t]),V.useEffect(()=>{if(n)return;const o=a.current;o&&(o.scrollTop=o.scrollHeight)},[e,n,a]),!e||!e.trim())return null;const i=o=>{o.preventDefault(),o.stopPropagation(),r(s=>!s)};return N.jsxs("div",{className:`mp-agent-reasoning-panel ${n?"mp-agent-reasoning-collapsed":""}`,children:[N.jsxs("div",{className:"mp-agent-reasoning-header",children:[N.jsx("span",{className:`mp-agent-reasoning-label ${t?"mp-agent-reasoning-label-streaming":""}`,children:"Thinking"}),N.jsx(nn,{icon:n?"ChevronDown":"ChevronUp",size:"sm",onClick:i})]}),!n&&N.jsx("div",{className:"mp-agent-reasoning-body",children:N.jsx("div",{className:"mp-agent-reasoning-content",ref:a,children:N.jsx(Tv,{className:"mp-agent-message-markdown mp-agent-reasoning-markdown",remarkPlugins:YHe,rehypePlugins:ZHe,components:E7,children:e})})})]})});Th.displayName="ReasoningPanel";const A7=()=>N.jsxs("span",{className:"mp-agent-message-typing-bubble",children:[N.jsx("span",{className:"mp-agent-message-typing-dot"}),N.jsx("span",{className:"mp-agent-message-typing-dot"}),N.jsx("span",{className:"mp-agent-message-typing-dot"})]}),XHe=({message:e,contextKey:t,isStreaming:n,showParticipantChrome:r=!1})=>{const o=Ue().config.features?.reasoning!==!1&&e.role===exports.MessageRole.Assistant&&!!e.reasoning,s=e.role===exports.MessageRole.Assistant&&typeof e.content=="string"&&e.content.trim().length>0,l=!!(n&&!o&&!s),u=typeof e.content=="string"&&e.content.trim().length>0||(e.attachments?.length??0)>0,d=(()=>{const p=e.toolCalls??[];if(p.length<=1)return p;const m=new Map;for(const h of p)m.set(h.id,h);return Array.from(m.values())})();return N.jsxs("div",{className:"mp-agent-message-group",children:[o&&N.jsx(Th,{reasoning:e.reasoning,isStreaming:n}),l&&N.jsx(A7,{}),u&&N.jsx(N7,{message:e,showParticipantChrome:r}),!n&&N.jsx("div",{className:"mp-agent-tool-calls",children:d.map(p=>N.jsx(hwe,{call:p,contextKey:t,messageId:e.id,chatId:e.chat},p.id))})]})},Zi=V.memo(XHe),n5=[],QHe=120,JHe=e=>{const t=e.activeChatId;return t?e.chatState[t]?.messages??n5:n5},T7=({showParticipantChrome:e=!1})=>{const t=Wt(),n=be(S=>S.contextKey),r=be(S=>S.draftChatKey),a=be(S=>S.activeChatId),i=be(JHe),o=a??r,s=np(a),l=be(S=>ze(S,o).pendingAssistant?.content?.length),u=be(S=>ze(S,o).pendingAssistant?.id),d=be(S=>ze(S,o).status),p=d===vt.Sending||d===vt.Streaming,m=V.useRef(null),h=V.useRef(!0),g=V.useRef(!1),f=V.useRef(!1),w=V.useRef(null),v=swe({count:i.length,getScrollElement:()=>m.current,estimateSize:()=>QHe,overscan:8,gap:16,getItemKey:S=>i[S]?.id??S}),k=v.getVirtualItems(),_=V.useCallback(()=>{const S=m.current;S&&(S.scrollTop=S.scrollHeight)},[]);V.useEffect(()=>{if(i.length!==0){if(!g.current){g.current=!0,f.current=!0,v.scrollToIndex(i.length-1,{align:"end"}),requestAnimationFrame(()=>{_(),requestAnimationFrame(()=>{_(),f.current=!1})});return}h.current&&requestAnimationFrame(_)}},[i.length,v,_]),V.useLayoutEffect(()=>{const S=w.current,x=m.current;!S||!x||s.isFetchingNextPage||i.length<=S.count||(f.current=!0,S.wasAtBottom?x.scrollTop=x.scrollHeight:x.scrollTop=S.scrollTop+(x.scrollHeight-S.scrollHeight),w.current=null,requestAnimationFrame(()=>{f.current=!1}))},[i.length,s.isFetchingNextPage]),V.useEffect(()=>{p&&h.current&&_()},[l,p,_]),V.useEffect(()=>{const S=m.current;if(!S)return;const x=()=>{if(f.current)return;const{scrollTop:D,scrollHeight:P,clientHeight:C}=S;h.current=P-D-C<150};return S.addEventListener("scroll",x,{passive:!0}),()=>S.removeEventListener("scroll",x)},[]);const E=k[0]?.index??Number.POSITIVE_INFINITY;return V.useEffect(()=>{if(!s.hasNextPage||s.isFetchingNextPage||E>1)return;const S=m.current;S&&(w.current={scrollHeight:S.scrollHeight,scrollTop:S.scrollTop,count:i.length,wasAtBottom:h.current}),s.fetchNextPage()},[E,s.hasNextPage,s.isFetchingNextPage,s.fetchNextPage,i.length]),!a&&i.length===0&&!u?N.jsx("div",{className:"mp-agent-messages-empty",children:N.jsxs("div",{className:"mp-agent-messages-empty-content",children:[N.jsx("h4",{children:t.helloThere}),N.jsx("p",{children:t.howCanIHelpYou})]})}):a&&i.length===0&&s.isLoading?N.jsx("div",{className:"mp-agent-messages-empty",children:N.jsx("div",{className:"mp-agent-messages-empty-content",children:N.jsx("p",{children:t.fetchingChats})})}):N.jsxs("div",{className:"mp-agent-messages",ref:m,children:[s.isFetchingNextPage&&N.jsx("div",{className:"mp-agent-messages-load-more",children:N.jsx("div",{className:"mp-agent-messages-load-more-text",children:t.fetchingChats})}),N.jsx("div",{className:"mp-agent-messages-virtual-list",style:{height:v.getTotalSize()},children:k.map(S=>{const x=i[S.index];return x?N.jsx("div",{ref:v.measureElement,"data-index":S.index,className:"mp-agent-messages-virtual-item",style:{transform:`translateY(${S.start}px)`},children:N.jsx(Zi,{message:x,contextKey:n,showParticipantChrome:e})},S.key):null})}),!!u&&N.jsx(eje,{pendingKey:o,contextKey:n,showParticipantChrome:e}),N.jsx(H3,{})]})},eje=V.memo(({pendingKey:e,contextKey:t,showParticipantChrome:n})=>{const r=be(s=>ze(s,e)),a=r.pendingAssistant,i=r.status;if(!a)return null;const o=i===vt.Sending||i===vt.Streaming;return N.jsx(Zi,{message:a,contextKey:t,isStreaming:o,showParticipantChrome:n},a.id)}),C7=({onClose:e,agentLogo:t})=>{const n=Wt(),a=Ue().config.features?.historySidebar!==!1,i=be(u=>u.isChatHistoryOpen),o=be(u=>u.setChatHistoryOpen),s=be(u=>u.setActiveChat),l=()=>{s(void 0)};return N.jsxs("div",{className:"mp-agent-agent-controls",children:[N.jsxs("div",{className:"mp-agent-agent-controls-left",children:[a&&N.jsx(nn,{onClick:()=>o(!i),icon:i?"PanelLeftClose":"PanelLeftOpen",tooltip:i?n.hideChatHistory:n.showChatHistory,"aria-label":i?n.hideChatHistory:n.showChatHistory}),N.jsx(nn,{onClick:l,icon:"SquarePen","aria-label":n.newChat,tooltip:n.newChat})]}),t&&N.jsx("div",{className:"mp-agent-agent-controls-logo",children:t}),n.panelTitle&&N.jsx("div",{className:"mp-agent-agent-controls-title",children:N.jsx("h4",{children:n.panelTitle})}),e&&N.jsx("div",{className:"mp-agent-agent-controls-right",children:N.jsx(nn,{onClick:e,icon:"X","aria-label":n.close,tooltip:n.close})})]})},R7=({fetchNextPage:e,hasNextPage:t,isFetchingNextPage:n,itemRenderer:r}={})=>{const a=Wt(),{deleteChat:i,isDeleting:o}=rp(),s=be(h=>h.chats),l=be(h=>h.activeChatId),u=be(h=>h.setActiveChat),d=V.useRef(null),p=V.useRef(null),m=V.useMemo(()=>Object.values(s).filter(h=>h.sessionKind!==exports.AgentSessionKind.SUBAGENT).sort((h,g)=>h.updatedAt===g.updatedAt?0:h.updatedAt<g.updatedAt?1:-1),[s]);return V.useEffect(()=>{const h=d.current,g=p.current;if(!h||!g||!e||!t)return;const f=new IntersectionObserver(w=>{w[0]?.isIntersecting&&t&&!n&&e()},{root:h,rootMargin:"100px",threshold:0});return f.observe(g),()=>f.disconnect()},[e,t,n]),N.jsxs("section",{className:"mp-agent-chat-history",children:[N.jsx("h4",{children:a.chats}),m.length===0?N.jsx("div",{className:"mp-agent-chat-history-empty",children:a.noChatsYet}):N.jsxs("ul",{ref:d,className:"mp-agent-chat-history-list",children:[m.map(h=>{const g=h.id===l;return r?N.jsx("li",{onClick:()=>u(h.id),className:`mp-agent-chat-history-item${g?" active":""}`,children:r(h)},h.id):N.jsxs("li",{onClick:()=>u(h.id),className:`mp-agent-chat-history-item${g?" active":""}`,children:[N.jsxs("div",{className:"mp-agent-chat-history-item-content",children:[N.jsx("span",{className:"mp-agent-chat-history-item-title",children:h.title||a.untitledChat}),N.jsx("span",{className:"mp-agent-chat-history-item-meta",children:new Date(h.updatedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})})]}),N.jsx("div",{className:"mp-agent-chat-history-item-actions",children:N.jsx(bn,{content:a.deleteChat,children:N.jsx(nn,{size:"sm",icon:"Archive","aria-label":a.deleteChat,disabled:o(h.id),onClick:f=>{f.stopPropagation(),i(h.id)}})})})]},h.id)}),t&&N.jsxs("li",{className:"mp-agent-chat-history-sentinel","aria-hidden":!0,children:[N.jsx("div",{ref:p,className:"mp-agent-chat-history-sentinel-inner"}),n&&N.jsx("div",{className:"mp-agent-chat-history-loading",children:a.fetchingChats})]})]})]})},I7=({loadChats:e=!0,multiUser:t=!1})=>{const n=Ue(),r=be(o=>o.isChatHistoryOpen),a=n.config.features?.historySidebar!==!1,i=tp({enabled:e&&a,multiUser:t});return!a||!r?null:N.jsx("div",{className:"mp-agent-chat-history-panel",children:N.jsx(R7,{fetchNextPage:i.fetchNextPage,hasNextPage:i.hasNextPage,isFetchingNextPage:i.isFetchingNextPage})})},tje=({children:e})=>{const t=be(n=>n.isChatHistoryOpen);return N.jsx("section",{className:`mp-agent-main ${t?"with-chat-history":""}`,children:e})},O7=({onToolSelected:e,onClose:t,agentLogo:n,multiUser:r=!1,participantIds:a,loadChats:i=!0,restoreLastActiveChat:o=!0})=>{const s=Wt(),l=Ue(),u=be(g=>g.activeChatId),d=be(g=>g.setActiveChat),{isLoading:p}=d3(),{isLoading:m,error:h}=tp({enabled:i,multiUser:r});return V.useLayoutEffect(()=>{if(!o)return;const g=l.config.user?.id??Hr(),f=N7e(g);f&&d(f)},[o,l.config.user?.id,d]),N.jsxs("div",{className:"mp-agent-shell mp-agent-shell-panel",children:[N.jsx(I7,{loadChats:i,multiUser:r}),N.jsxs(tje,{children:[N.jsx(C7,{onClose:t,agentLogo:n}),N.jsx("div",{className:"mp-agent-main-content",children:m||p?N.jsx("div",{style:{padding:24},children:s.fetchingChats}):h?N.jsx("div",{style:{padding:24,color:"var(--mp-agents-danger)"},children:s.fetchingChatError}):N.jsx(T7,{showParticipantChrome:r},u)}),N.jsx(B3,{onToolSelected:e,multiUser:r,participantIds:a})]})]})},nje=e=>N.jsx(O7,{...e,multiUser:!0}),rje=({enabled:e=!0,className:t,pageSize:n=uo,showDelete:r=!0,onChatSelect:a})=>{const i=Wt(),o=yt.useQueryClient(),{deleteChat:s,isDeleting:l}=rp(),u=be(_=>_.upsertChat),d=be(_=>_.activeChatId),p=be(_=>_.setActiveChat),m=ep({enabled:e,multiUser:!0,pageSize:n}),h=V.useMemo(()=>n3(m.data).filter(_=>_.sessionKind!==exports.AgentSessionKind.SUBAGENT),[m.data]),g=V.useRef(null),f=V.useRef(null);V.useEffect(()=>{const _=g.current,E=f.current,{fetchNextPage:S,hasNextPage:x,isFetchingNextPage:D}=m;if(!_||!E||!S||!x)return;const P=new IntersectionObserver(C=>{C[0]?.isIntersecting&&x&&!D&&S()},{root:_,rootMargin:"100px",threshold:0});return P.observe(E),()=>P.disconnect()},[m,m.fetchNextPage,m.hasNextPage,m.isFetchingNextPage]);const w=_=>{u(_),p(_.id),a?.(_)},v=async(_,E)=>{_.stopPropagation(),await s(E),o.invalidateQueries({queryKey:In.all})},k=["mp-agent-chat-history","mp-agent-multiuser-chat-list",t].filter(Boolean).join(" ");return m.isError?N.jsxs("section",{className:k,children:[N.jsx("h4",{children:i.multiUserChats}),N.jsx("div",{className:"mp-agent-chat-history-empty",role:"alert",children:i.fetchingChatError})]}):m.isLoading?N.jsxs("section",{className:k,children:[N.jsx("h4",{children:i.multiUserChats}),N.jsx("div",{className:"mp-agent-chat-history-empty",children:i.fetchingChats})]}):N.jsxs("section",{className:k,children:[N.jsx("h4",{children:i.multiUserChats}),h.length===0?N.jsx("div",{className:"mp-agent-chat-history-empty",children:i.noMultiUserChats}):N.jsxs("ul",{ref:g,className:"mp-agent-chat-history-list",children:[h.map(_=>{const E=_.id===d,S=_.participantIds?.length??0;return N.jsxs("li",{onClick:()=>w(_),className:`mp-agent-chat-history-item${E?" active":""}`,children:[N.jsxs("div",{className:"mp-agent-chat-history-item-content",children:[N.jsx("span",{className:"mp-agent-chat-history-item-title",children:_.title||i.untitledChat}),N.jsxs("span",{className:"mp-agent-chat-history-item-meta",children:[S>0?`${S} · `:"",new Date(_.updatedAt).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})]})]}),r?N.jsx("div",{className:"mp-agent-chat-history-item-actions",children:N.jsx(bn,{content:i.deleteChat,children:N.jsx(nn,{size:"sm",icon:"Archive","aria-label":i.deleteChat,disabled:l(_.id),onClick:x=>void v(x,_.id)})})}):null]},_.id)}),m.hasNextPage?N.jsxs("li",{className:"mp-agent-chat-history-sentinel","aria-hidden":!0,children:[N.jsx("div",{ref:f,className:"mp-agent-chat-history-sentinel-inner"}),m.isFetchingNextPage?N.jsx("div",{className:"mp-agent-chat-history-loading",children:i.fetchingChats}):null]}):null]})]})},L7=V.forwardRef(({attachment:e,context:t,onAdded:n,onClick:r,...a},i)=>{const{addAttachments:o}=o3(),s=l=>{if(r?.(l),l.defaultPrevented)return;const d=(typeof e=="function"?e():e)??(()=>{const p=typeof t=="function"?t():t;return p?po(p):void 0})();d&&(o([d]),n?.(d))};return N.jsx("button",{ref:i,type:"button",...a,onClick:s})});L7.displayName="AttachContextButton";exports.AgentAttachmentSchema=d5;exports.AgentControls=C7;exports.AgentPreferencesPanel=q3;exports.AgentProvider=E_e;exports.AgentRuntime=g3;exports.AgentThemeProvider=k3;exports.AttachContextButton=L7;exports.BuiltinContextAttachmentKinds=c5;exports.CHATS_PAGE_SIZE=uo;exports.ChatHistory=R7;exports.ChatHistoryPanel=I7;exports.ChatWindow=O7;exports.Composer=B3;exports.ContextAttachmentMetadataSchemaV1=u5;exports.DEFAULT_MESSAGES_PAGE_SIZE=p3;exports.FormApplyRequestedEventType=Pd;exports.FormProposalToolRenderer=h3;exports.HttpError=Gu;exports.MessageActions=S7;exports.MessageAvatar=dp;exports.MessageBubble=N7;exports.MessageContent=M7;exports.MessageHeader=pp;exports.MessageList=T7;exports.MessageTypingAnimation=A7;exports.MultiUserChatList=rje;exports.MultiUserChatWindow=nje;exports.ReasoningPanel=Th;exports.SendMessagePayloadSchema=V7;exports.SocketIOConfig=Ai;exports.SocketIOEvents=fi;exports.activityKeys=Ht;exports.captureTextSelectionTarget=f3;exports.chatKeys=In;exports.contextKeySchema=l5;exports.createContextAttachment=po;exports.createPageContextAttachment=m3;exports.defaultTranslations=Ni;exports.flattenInfiniteActivities=o7e;exports.flattenInfiniteChats=n3;exports.frontendConfigSchema=Wu;exports.themeTokenSchema=s5;exports.translationsSchema=z7;exports.useActivitiesInfiniteList=s7e;exports.useActivitiesList=l7e;exports.useActivity=c7e;exports.useActivitySourceTypes=d7e;exports.useActivitySummary=u7e;exports.useAgentConfigurations=s3;exports.useAgentPreferences=u3;exports.useAgentRuntime=Ue;exports.useAgentStore=be;exports.useAgentTheme=v3;exports.useAutoScroll=h7e;exports.useChatBootstrap=tp;exports.useChats=r3;exports.useChatsInfiniteList=ep;exports.useChatsList=p7e;exports.useComposerDraft=o3;exports.useDeleteChat=rp;exports.useEnsureActiveChat=d3;exports.useMessagesInfinite=np;exports.useModels=a3;exports.usePageContext=f7e;exports.useProposeFormValues=g7e;exports.useRuntimeEventEmitter=l3;exports.useRuntimeEventListener=c3;exports.useTranslations=Wt;
|
|
8619
8619
|
//# sourceMappingURL=ai-agent-react.cjs.js.map
|