@applica-software-guru/persona-sdk 0.1.80 → 0.1.82

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.
@@ -1,4 +1,4 @@
1
- (function(G,K){typeof exports=="object"&&typeof module<"u"?K(exports,require("react"),require("@assistant-ui/react")):typeof define=="function"&&define.amd?define(["exports","react","@assistant-ui/react"],K):(G=typeof globalThis<"u"?globalThis:G||self,K(G.personaSDK={},G.React,G.AssistantUI))})(this,function(G,K,et){"use strict";var Hd=Object.defineProperty;var Kd=(G,K,et)=>K in G?Hd(G,K,{enumerable:!0,configurable:!0,writable:!0,value:et}):G[K]=et;var E=(G,K,et)=>Kd(G,typeof K!="symbol"?K+"":K,et);var jt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Lo(y){return y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y.default:y}var Ki={exports:{}},ne={};/**
1
+ (function(Y,B){typeof exports=="object"&&typeof module<"u"?B(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],B):(Y=typeof globalThis<"u"?globalThis:Y||self,B(Y.personaSDK={},Y.React))})(this,function(Y,B){"use strict";var Av=Object.defineProperty;var Cv=(Y,B,oe)=>B in Y?Av(Y,B,{enumerable:!0,configurable:!0,writable:!0,value:oe}):Y[B]=oe;var S=(Y,B,oe)=>Cv(Y,typeof B!="symbol"?B+"":B,oe);var Xt,Ue;var oe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $i(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var qi={exports:{}},yn={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,31 +6,35 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var Ji;function Oo(){if(Ji)return ne;Ji=1;var y=Symbol.for("react.transitional.element"),p=Symbol.for("react.fragment");function i(w,m,C){var b=null;if(C!==void 0&&(b=""+C),m.key!==void 0&&(b=""+m.key),"key"in m){C={};for(var I in m)I!=="key"&&(C[I]=m[I])}else C=m;return m=C.ref,{$$typeof:y,type:w,key:b,ref:m!==void 0?m:null,props:C}}return ne.Fragment=p,ne.jsx=i,ne.jsxs=i,ne}Ki.exports=Oo();var xr=Ki.exports;function Wo(y){return y.filter(p=>p.finishReason==="stop"?p.text!==null&&p.text.trim()!=="":!0)}function Yi(y){const p=[];let i=null;for(const m of y)if(m.type!=="transaction")if(m.file){i&&(p.push(i),i=null),p.push(m);continue}else m.functionCalls?(i&&p.push(i),p.push(m),i=null):m.functionResponse?p[p.length-1]={...p[p.length-1],functionResponse:m.functionResponse}:i&&m.type===i.type&&m.protocol===i.protocol&&i.role===m.role?(i.text+=m.text,i.file=i.file||m.file):(i&&p.push(i),i={...m,text:m.file?"":m.text,finishReason:m.file?void 0:m.finishReason});return i&&p.push(i),Wo(p)}function Mo(y){var i;const p=y.file?[{type:"file",data:y.file.url,mimeType:y.file.contentType}]:[];return y.role==="function"?{id:y.id,role:"assistant",status:(y==null?void 0:y.functionResponse)===null?{type:"running"}:{type:"complete",reason:"stop"},content:((i=y.functionCalls)==null?void 0:i.map(w=>{var m;return{type:"tool-call",toolName:w.name,toolCallId:w.id,args:w.args,result:(m=y.functionResponse)==null?void 0:m.result}}))??[]}:{id:y.id,role:y.role,content:y.type==="reasoning"?[{type:"reasoning",text:y.text},...p]:[{type:"text",text:y.text},...p]}}class te{constructor(){E(this,"statusChangeCallbacks",[]);E(this,"messageCallbacks",[])}addStatusChangeListener(p){this.statusChangeCallbacks.push(p)}addPacketListener(p){this.messageCallbacks.push(p)}async syncSession(p){this.session=p}async notifyPacket(p){this.messageCallbacks.forEach(i=>i(p))}async notifyPackets(p){p.forEach(i=>{this.messageCallbacks.forEach(w=>w(i))})}async setSession(p){this.session=p}async setStatus(p){const i=this.status!==p;this.status=p,i&&this.statusChangeCallbacks.forEach(w=>w(p))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}onTransaction(p){}}class Sr extends te{constructor(i){super();E(this,"status");E(this,"autostart");E(this,"session");E(this,"config");E(this,"notify",!0);E(this,"context",{});E(this,"tools",[]);this.config=i,this.status="disconnected",this.autostart=!0}getName(){return"rest"}getPriority(){return 100}async connect(i){return this.setStatus("connected"),i}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(i){this.session=i}async sendPacket(i){var $,rn,bn,un,Rn;const{apiUrl:w,apiKey:m,agentId:C}=this.config,b=this.session??"new";if(i.type==="command"&&(($=i==null?void 0:i.payload)==null?void 0:$.command)=="set_initial_context"){this.context=(rn=i==null?void 0:i.payload)==null?void 0:rn.arguments;return}else if(i.type==="command"&&((bn=i==null?void 0:i.payload)==null?void 0:bn.command)=="set_local_tools"){const pn=(un=i==null?void 0:i.payload)==null?void 0:un.arguments.tools;(pn==null?void 0:pn.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const I=i.payload;try{const Tn=await(await fetch(`${w}/sessions/${b}/messages`,{body:JSON.stringify({agentId:C,userMessage:I,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":m}})).json();this.notifyPackets(Tn.response.messages.map(gt=>({type:"message",payload:gt})))}catch(pn){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(Rn=this.config.logger)==null||Rn.error("Error sending packet:",pn)}}}class Ar extends te{constructor(i){super();E(this,"status");E(this,"autostart");E(this,"session");E(this,"config");E(this,"webSocket");this.config=i,this.status="disconnected",this.autostart=!0,this.session=null,this.webSocket=null}getName(){return"websocket"}getPriority(){return 500}async syncSession(i){var w;(w=this.config.logger)==null||w.debug("Syncing session with WebSocket protocol:",i),this.session=i,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(i))}connect(i){var I;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const w=i||this.session||"new";(I=this.config.logger)==null||I.debug("Connecting to WebSocket with sessionId:",w);const m=encodeURIComponent(this.config.apiKey),C=this.config.agentId,b=`${this.config.webSocketUrl}?sessionCode=${w}&agentId=${C}&apiKey=${m}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(b),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",$=>{const rn=JSON.parse($.data);this.notifyPacket(rn)}),this.webSocket.addEventListener("close",$=>{var rn;this.setStatus("disconnected"),this.webSocket=null,$.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(rn=this.config.logger)==null||rn.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var $;this.setStatus("disconnected"),this.webSocket=null,($=this.config.logger)==null||$.error("WebSocket connection error")}),Promise.resolve(w)}disconnect(){var i;return(i=this.config.logger)==null||i.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(i){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(i)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class Fo{constructor(p){E(this,"config");E(this,"pc",null);E(this,"ws",null);E(this,"localStream",null);E(this,"remoteStream",new MediaStream);E(this,"audioCtx",null);E(this,"localAnalyser",null);E(this,"remoteAnalyser",null);E(this,"analyzerFrame",null);E(this,"dataChannel",null);E(this,"isConnected",!1);E(this,"visualizerCallbacks",[]);E(this,"messageCallbacks",[]);E(this,"errorCallbacks",[]);E(this,"queuedMessages",[]);this.config=p}async connect(p){var w;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(m){(w=this.config.logger)==null||w.error("Error accessing microphone:",m);return}this.pc=new RTCPeerConnection({iceServers:this.config.iceServers||[{urls:"stun:34.38.108.251:3478"},{urls:"turn:34.38.108.251:3478",username:"webrtc",credential:"webrtc"}]}),this.localStream.getTracks().forEach(m=>{this.pc.addTrack(m,this.localStream)}),this.pc.ontrack=m=>{m.streams[0].getTracks().forEach(b=>{this.remoteStream.addTrack(b)}),this.audioCtx||this._startAnalyzers();const C=new Audio;C.srcObject=this.remoteStream,C.play().catch(b=>{var I;(I=this.config.logger)==null||I.error("Error playing remote audio:",b)})},this.pc.onicecandidate=m=>{var C;m.candidate&&((C=this.ws)==null?void 0:C.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:m.candidate}}))},this.pc.ondatachannel=m=>{const C=m.channel;C.onmessage=b=>{this.messageCallbacks.forEach(I=>{I(b)})},C.onopen=()=>{var b;for(;this.queuedMessages.length>0;){const I=this.queuedMessages.shift();I&&(C.send(JSON.stringify(I)),(b=this.config.logger)==null||b.info("Sent queued message:",I))}}};const i=this.config.webrtcUrl||"wss://persona.applica.guru/api/webrtc";this.ws=new WebSocket(`${i}?apiKey=${encodeURIComponent(this.config.apiKey)}`),this.ws.onopen=async()=>{var I,$;const m=await this.pc.createOffer();await this.pc.setLocalDescription(m);const C={apiKey:this.config.apiKey,agentId:this.config.agentId,sessionCode:p};(I=this.config.logger)==null||I.debug("Opening connection to WebRTC server: ",C);const b={type:"OFFER",src:(($=crypto.randomUUID)==null?void 0:$.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:m.sdp,type:m.type},connectionId:(Date.now()%1e6).toString(),metadata:C}};this.ws.send(JSON.stringify(b))},this.ws.onmessage=async m=>{var b;const C=JSON.parse(m.data);if(C.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(C.payload.sdp));else if(C.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(C.payload.candidate))}catch(I){(b=this.config.logger)==null||b.error("Error adding ICE candidate:",I)}},this.ws.onclose=m=>{m.code!==1e3&&this.errorCallbacks.forEach(C=>{C("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var p;this.isConnected&&(this.isConnected=!1,((p=this.ws)==null?void 0:p.readyState)===WebSocket.OPEN&&this.ws.close(),this.pc&&this.pc.close(),this.localStream&&this.localStream.getTracks().forEach(i=>i.stop()),this.remoteStream=new MediaStream,this.audioCtx&&(await this.audioCtx.close(),this.audioCtx=null),this._stopAnalyzers())}addVisualizerCallback(p){this.visualizerCallbacks.push(p)}addMessageCallback(p){this.messageCallbacks.push(p)}addErrorCallback(p){this.errorCallbacks.push(p)}createDataChannel(p="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(p),this.dataChannel.onopen=()=>{var i,w;for((i=this.config.logger)==null||i.info("Data channel opened");this.queuedMessages.length>0;){const m=this.queuedMessages.shift();m&&(this.dataChannel.send(JSON.stringify(m)),(w=this.config.logger)==null||w.info("Sent queued message:",m))}},this.dataChannel.onmessage=i=>{this.messageCallbacks.forEach(w=>{w(i)})})}sendPacket(p){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(p);return}this.dataChannel.send(JSON.stringify(p)),(i=this.config.logger)==null||i.info("Sent message:",p)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const p=this.audioCtx.createMediaStreamSource(this.localStream),i=this.audioCtx.createMediaStreamSource(this.remoteStream);this.localAnalyser=this.audioCtx.createAnalyser(),this.remoteAnalyser=this.audioCtx.createAnalyser(),this.localAnalyser.fftSize=256,this.remoteAnalyser.fftSize=256,p.connect(this.localAnalyser),i.connect(this.remoteAnalyser);const w=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const m=new Uint8Array(this.localAnalyser.frequencyBinCount),C=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(m),this.remoteAnalyser.getByteFrequencyData(C);const b=m.reduce(($,rn)=>$+rn,0)/m.length,I=C.reduce(($,rn)=>$+rn,0)/C.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach($=>{$({localAmplitude:b,remoteAmplitude:I})}),this.analyzerFrame=requestAnimationFrame(w)};this.analyzerFrame=requestAnimationFrame(w)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class Cr extends te{constructor(i){super();E(this,"status");E(this,"session");E(this,"autostart");E(this,"config");E(this,"webRTCClient");this.config=i,this.status="disconnected",this.session=null,this.autostart=(i==null?void 0:i.autostart)??!1,this.webRTCClient=new Fo(i),this.webRTCClient.addMessageCallback(w=>{const m=JSON.parse(w.data);this.notifyPacket(m)}),this.webRTCClient.addErrorCallback(w=>{var m;(m=this.config.logger)==null||m.error("WebRTC error:",w),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:w}})})}getName(){return"webrtc"}getPriority(){return 1e3}async syncSession(i){super.syncSession(i),this.status==="connected"&&(await this.disconnect(),await this.connect(i))}async connect(i){var w;return this.status==="connected"?Promise.resolve(this.session):(this.session=i||this.session||"new",this.setStatus("connecting"),(w=this.config.logger)==null||w.debug("Connecting to WebRTC with sessionId:",this.session),await this.webRTCClient.connect(this.session),this.setStatus("connected"),await this.webRTCClient.createDataChannel(),this.session)}async disconnect(){var i,w,m;if(this.status==="disconnected")return(i=this.config.logger)==null||i.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(m=(w=this.config)==null?void 0:w.logger)==null||m.debug("Disconnected from WebRTC")}sendPacket(i){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(i),Promise.resolve())}}var be={exports:{}};/**
9
+ */var zi;function dc(){if(zi)return yn;zi=1;var n=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function r(a,h,f){var p=null;if(f!==void 0&&(p=""+f),h.key!==void 0&&(p=""+h.key),"key"in h){f={};for(var m in h)m!=="key"&&(f[m]=h[m])}else f=h;return h=f.ref,{$$typeof:n,type:a,key:p,ref:h!==void 0?h:null,props:f}}return yn.Fragment=i,yn.jsx=r,yn.jsxs=r,yn}qi.exports=dc();var Ee=qi.exports,pc=n=>Array.from(n).map(r=>r.getModelContext()).sort((r,a)=>(a.priority??0)-(r.priority??0)).reduce((r,a)=>{var h;if(a.system&&(r.system?r.system+=`
10
+
11
+ ${a.system}`:r.system=a.system),a.tools)for(const[f,p]of Object.entries(a.tools)){const m=(h=r.tools)==null?void 0:h[f];if(m&&m!==p)throw new Error(`You tried to define a tool with the name ${f}, but it already exists.`);r.tools||(r.tools={}),r.tools[f]=p}return a.config&&(r.config={...r.config,...a.config}),a.callSettings&&(r.callSettings={...r.callSettings,...a.callSettings}),r},{}),Hi=class{constructor(){S(this,"_providers",new Set);S(this,"_subscribers",new Set)}getModelContext(){return pc(this._providers)}registerModelContextProvider(n){var r;this._providers.add(n);const i=(r=n.subscribe)==null?void 0:r.call(n,()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(n),i==null||i(),this.notifySubscribers()}}notifySubscribers(){for(const n of this._subscribers)n()}subscribe(n){return this._subscribers.add(n),()=>this._subscribers.delete(n)}},gc=class{constructor(){S(this,"_contextProvider",new Hi)}registerModelContextProvider(n){return this._contextProvider.registerModelContextProvider(n)}getModelContextProvider(){return this._contextProvider}},_c=class{constructor(){S(this,"_subscribers",new Set)}subscribe(n){return this._subscribers.add(n),()=>this._subscribers.delete(n)}waitForUpdate(){return new Promise(n=>{const i=this.subscribe(()=>{i(),n()})})}_notifySubscribers(){const n=[];for(const i of this._subscribers)try{i()}catch(r){n.push(r)}if(n.length>0)throw n.length===1?n[0]:new AggregateError(n)}},bc=n=>n.status.type==="complete",Ji=class extends _c{constructor(){super(...arguments);S(this,"isEditing",!0);S(this,"_attachments",[]);S(this,"_text","");S(this,"_role","user");S(this,"_runConfig",{});S(this,"_eventSubscribers",new Map)}get attachmentAccept(){var i;return((i=this.getAttachmentAdapter())==null?void 0:i.accept)??"*"}get attachments(){return this._attachments}setAttachments(i){this._attachments=i,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}get text(){return this._text}get role(){return this._role}get runConfig(){return this._runConfig}setText(i){this._text!==i&&(this._text=i,this._notifySubscribers())}setRole(i){this._role!==i&&(this._role=i,this._notifySubscribers())}setRunConfig(i){this._runConfig!==i&&(this._runConfig=i,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._notifySubscribers()}async _onClearAttachments(){const i=this.getAttachmentAdapter();i&&await Promise.all(this._attachments.map(r=>i.remove(r)))}async reset(){if(this._attachments.length===0&&this._text===""&&this._role==="user"&&Object.keys(this._runConfig).length===0)return;this._role="user",this._runConfig={};const i=this._onClearAttachments();this._emptyTextAndAttachments(),await i}async clearAttachments(){const i=this._onClearAttachments();this.setAttachments([]),await i}async send(){const i=this.getAttachmentAdapter(),r=i&&this.attachments.length>0?Promise.all(this.attachments.map(async f=>bc(f)?f:await i.send(f))):[],a=this.text;this._emptyTextAndAttachments();const h={createdAt:new Date,role:this.role,content:a?[{type:"text",text:a}]:[],attachments:await r,runConfig:this.runConfig,metadata:{custom:{}}};this.handleSend(h),this._notifyEventSubscribers("send")}cancel(){this.handleCancel()}async addAttachment(i){const r=this.getAttachmentAdapter();if(!r)throw new Error("Attachments are not supported");const a=f=>{const p=this._attachments.findIndex(m=>m.id===f.id);p!==-1?this._attachments=[...this._attachments.slice(0,p),f,...this._attachments.slice(p+1)]:this._attachments=[...this._attachments,f],this._notifySubscribers()},h=r.add({file:i});if(Symbol.asyncIterator in h)for await(const f of h)a(f);else a(await h);this._notifyEventSubscribers("attachment-add"),this._notifySubscribers()}async removeAttachment(i){const r=this.getAttachmentAdapter();if(!r)throw new Error("Attachments are not supported");const a=this._attachments.findIndex(f=>f.id===i);if(a===-1)throw new Error("Attachment not found");const h=this._attachments[a];await r.remove(h),this._attachments=[...this._attachments.slice(0,a),...this._attachments.slice(a+1)],this._notifySubscribers()}_notifyEventSubscribers(i){const r=this._eventSubscribers.get(i);if(r)for(const a of r)a()}unstable_on(i,r){const a=this._eventSubscribers.get(i);return a?a.add(r):this._eventSubscribers.set(i,new Set([r])),()=>{const h=this._eventSubscribers.get(i);h&&h.delete(r)}}},mc=class extends Ji{constructor(i){super();S(this,"_canCancel",!1);this.runtime=i,this.connect()}get canCancel(){return this._canCancel}get attachments(){return super.attachments}getAttachmentAdapter(){var i;return(i=this.runtime.adapters)==null?void 0:i.attachments}connect(){return this.runtime.subscribe(()=>{this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,this._notifySubscribers())})}async handleSend(i){var r;this.runtime.append({...i,parentId:((r=this.runtime.messages.at(-1))==null?void 0:r.id)??null,sourceId:null})}async handleCancel(){this.runtime.cancelRun()}},es=((n,i=21)=>(r=i)=>{let a="",h=r|0;for(;h--;)a+=n[Math.random()*n.length|0];return a})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),vc="__optimistic__",wc=()=>`${vc}${es()}`,Qe=Symbol("autoStatus"),yc=Object.freeze(Object.assign({type:"running"},{[Qe]:!0})),Sc=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[Qe]:!0}));Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[Qe]:!0})),Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[Qe]:!0}));var Ec=n=>n[Qe]===!0,Gi=(n,i,r,a,h)=>n&&h?Object.assign({type:"incomplete",reason:"error",error:h},{[Qe]:!0}):n&&i?yc:Sc,je={exports:{}};const xc=typeof Buffer<"u",Ki=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Yi=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function Vi(n,i,r){r==null&&i!==null&&typeof i=="object"&&(r=i,i=void 0),xc&&Buffer.isBuffer(n)&&(n=n.toString()),n&&n.charCodeAt(0)===65279&&(n=n.slice(1));const a=JSON.parse(n,i);if(a===null||typeof a!="object")return a;const h=r&&r.protoAction||"error",f=r&&r.constructorAction||"error";if(h==="ignore"&&f==="ignore")return a;if(h!=="ignore"&&f!=="ignore"){if(Ki.test(n)===!1&&Yi.test(n)===!1)return a}else if(h!=="ignore"&&f==="ignore"){if(Ki.test(n)===!1)return a}else if(Yi.test(n)===!1)return a;return Zi(a,{protoAction:h,constructorAction:f,safe:r&&r.safe})}function Zi(n,{protoAction:i="error",constructorAction:r="error",safe:a}={}){let h=[n];for(;h.length;){const f=h;h=[];for(const p of f){if(i!=="ignore"&&Object.prototype.hasOwnProperty.call(p,"__proto__")){if(a===!0)return null;if(i==="error")throw new SyntaxError("Object contains forbidden prototype property");delete p.__proto__}if(r!=="ignore"&&Object.prototype.hasOwnProperty.call(p,"constructor")&&p.constructor!==null&&typeof p.constructor=="object"&&Object.prototype.hasOwnProperty.call(p.constructor,"prototype")){if(a===!0)return null;if(r==="error")throw new SyntaxError("Object contains forbidden prototype property");delete p.constructor}for(const m in p){const w=p[m];w&&typeof w=="object"&&h.push(w)}}}return n}function ns(n,i,r){const{stackTraceLimit:a}=Error;Error.stackTraceLimit=0;try{return Vi(n,i,r)}finally{Error.stackTraceLimit=a}}function Tc(n,i){const{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return Vi(n,i,{safe:!0})}catch{return}finally{Error.stackTraceLimit=r}}je.exports=ns,je.exports.default=ns,je.exports.parse=ns,je.exports.safeParse=Tc,je.exports.scan=Zi;var Ac=je.exports;const Xi=$i(Ac);function Cc(n){const i=["ROOT"];let r=-1,a=null;const h=[];let f;function p(){f!==void 0&&(h.push(JSON.parse('"'+f+'"')),f=void 0)}function m(C,A,R){switch(C){case'"':{r=A,i.pop(),i.push(R),i.push("INSIDE_STRING"),p();break}case"f":case"t":case"n":{r=A,a=A,i.pop(),i.push(R),i.push("INSIDE_LITERAL");break}case"-":{i.pop(),i.push(R),i.push("INSIDE_NUMBER"),p();break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=A,i.pop(),i.push(R),i.push("INSIDE_NUMBER"),p();break}case"{":{r=A,i.pop(),i.push(R),i.push("INSIDE_OBJECT_START"),p();break}case"[":{r=A,i.pop(),i.push(R),i.push("INSIDE_ARRAY_START"),p();break}}}function w(C,A){switch(C){case",":{i.pop(),i.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=A,i.pop(),f=h.pop();break}}}function I(C,A){switch(C){case",":{i.pop(),i.push("INSIDE_ARRAY_AFTER_COMMA"),f=(Number(f)+1).toString();break}case"]":{r=A,i.pop(),f=h.pop();break}}}for(let C=0;C<n.length;C++){const A=n[C];switch(i[i.length-1]){case"ROOT":m(A,C,"FINISH");break;case"INSIDE_OBJECT_START":{switch(A){case'"':{i.pop(),i.push("INSIDE_OBJECT_KEY"),f="";break}case"}":{r=C,i.pop(),f=h.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(A){case'"':{i.pop(),i.push("INSIDE_OBJECT_KEY"),f="";break}}break}case"INSIDE_OBJECT_KEY":{switch(A){case'"':{i.pop(),i.push("INSIDE_OBJECT_AFTER_KEY");break}case"\\":{i.push("INSIDE_STRING_ESCAPE"),f+=A;break}default:{f+=A;break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(A){case":":{i.pop(),i.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{m(A,C,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{w(A,C);break}case"INSIDE_STRING":{switch(A){case'"':{i.pop(),r=C,f=h.pop();break}case"\\":{i.push("INSIDE_STRING_ESCAPE");break}default:r=C}break}case"INSIDE_ARRAY_START":{switch(A){case"]":{r=C,i.pop(),f=h.pop();break}default:{r=C,f="0",m(A,C,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(A){case",":{i.pop(),i.push("INSIDE_ARRAY_AFTER_COMMA"),f=(Number(f)+1).toString();break}case"]":{r=C,i.pop(),f=h.pop();break}default:{r=C;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{m(A,C,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{i.pop(),i[i.length-1]==="INSIDE_STRING"?r=C:i[i.length-1]==="INSIDE_OBJECT_KEY"&&(f+=A);break}case"INSIDE_NUMBER":{switch(A){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=C;break}case"e":case"E":case"-":case".":break;case",":{i.pop(),f=h.pop(),i[i.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&I(A,C),i[i.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&w(A,C);break}case"}":{i.pop(),f=h.pop(),i[i.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&w(A,C);break}case"]":{i.pop(),f=h.pop(),i[i.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&I(A,C);break}default:{i.pop(),f=h.pop();break}}break}case"INSIDE_LITERAL":{const K=n.substring(a,C+1);!"false".startsWith(K)&&!"true".startsWith(K)&&!"null".startsWith(K)?(i.pop(),i[i.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?w(A,C):i[i.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&I(A,C)):r=C;break}}}let P=n.slice(0,r+1);for(let C=i.length-1;C>=0;C--)switch(i[C]){case"INSIDE_STRING":{P+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{P+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{P+="]";break}case"INSIDE_LITERAL":{const R=n.substring(a,n.length);"true".startsWith(R)?P+="true".slice(R.length):"false".startsWith(R)?P+="false".slice(R.length):"null".startsWith(R)&&(P+="null".slice(R.length))}}return[P,h]}var rs=Symbol("aui.parse-partial-json-object.meta"),Ic=n=>{if(n.length===0)return{[rs]:{state:"partial",partialPath:[]}};try{const i=Xi.parse(n);if(typeof i!="object"||i===null)throw new Error("argsText is expected to be an object");return i[rs]={state:"complete",partialPath:[]},i}catch{try{const[i,r]=Cc(n),a=Xi.parse(i);if(typeof a!="object"||a===null)throw new Error("argsText is expected to be an object");return a[rs]={state:"partial",partialPath:r},a}catch{return}}},ss=(n,i,r)=>{const{role:a,id:h,createdAt:f,attachments:p,status:m,metadata:w}=n,I={id:h??i,createdAt:f??new Date},P=typeof n.content=="string"?[{type:"text",text:n.content}]:n.content,C=({image:A,...R})=>A.match(/^data:image\/(png|jpeg|jpg|gif|webp);base64,(.*)$/)?{...R,image:A}:(console.warn("Invalid image data format detected"),null);if(a!=="user"&&(p!=null&&p.length))throw new Error("attachments are only supported for user messages");if(a!=="assistant"&&m)throw new Error("status is only supported for assistant messages");if(a!=="assistant"&&(w!=null&&w.steps))throw new Error("metadata.steps is only supported for assistant messages");switch(a){case"assistant":return{...I,role:a,content:P.map(A=>{const R=A.type;switch(R){case"text":case"reasoning":return A.text.trim().length===0?null:A;case"file":case"source":return A;case"image":return C(A);case"data":return A;case"tool-call":{const{parentId:K,messages:At,...gt}=A,ct={...gt,toolCallId:A.toolCallId??`tool-${es()}`,...K!==void 0&&{parentId:K},...At!==void 0&&{messages:At}};return A.args?{...ct,args:A.args,argsText:A.argsText??JSON.stringify(A.args)}:{...ct,args:Ic(A.argsText??"")??{},argsText:A.argsText??""}}default:{const K=R;throw new Error(`Unsupported assistant message part type: ${K}`)}}}).filter(A=>!!A),status:m??r,metadata:{unstable_state:(w==null?void 0:w.unstable_state)??null,unstable_annotations:(w==null?void 0:w.unstable_annotations)??[],unstable_data:(w==null?void 0:w.unstable_data)??[],custom:(w==null?void 0:w.custom)??{},steps:(w==null?void 0:w.steps)??[],...(w==null?void 0:w.submittedFeedback)&&{submittedFeedback:w.submittedFeedback}}};case"user":return{...I,role:a,content:P.map(A=>{const R=A.type;switch(R){case"text":case"image":case"audio":case"file":return A;default:{const K=R;throw new Error(`Unsupported user message part type: ${K}`)}}}),attachments:p??[],metadata:{custom:(w==null?void 0:w.custom)??{}}};case"system":if(P.length!==1||P[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return{...I,role:a,content:P,metadata:{custom:(w==null?void 0:w.custom)??{}}};default:{const A=a;throw new Error(`Unknown message role: ${A}`)}}},is={fromArray:n=>{const i=n.map(r=>ss(r,es(),Gi(!1,!1,!1,!1,void 0)));return{messages:i.map((r,a)=>({parentId:a>0?i[a-1].id:null,message:r}))}}},Xn=n=>n.next?Xn(n.next):"current"in n?n:null,Rc=class{constructor(n){S(this,"_value",null);this.func=n}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},Qi=class{constructor(){S(this,"messages",new Map);S(this,"head",null);S(this,"root",{children:[],next:null});S(this,"_messages",new Rc(()=>{var i;const n=new Array((((i=this.head)==null?void 0:i.level)??-1)+1);for(let r=this.head;r;r=r.prev)n[r.level]=r.current;return n}))}updateLevels(n,i){n.level=i;for(const r of n.children){const a=this.messages.get(r);a&&this.updateLevels(a,i+1)}}performOp(n,i,r){const a=i.prev??this.root,h=n??this.root;if(!(r==="relink"&&a===h)){if(r!=="link"&&(a.children=a.children.filter(f=>f!==i.current.id),a.next===i)){const f=a.children.at(-1),p=f?this.messages.get(f):null;if(p===void 0)throw new Error("MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.");a.next=p}if(r!=="cut"){for(let p=n;p;p=p.prev)if(p.current.id===i.current.id)throw new Error("MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.");h.children=[...h.children,i.current.id],(Xn(i)===this.head||h.next===null)&&(h.next=i),i.prev=n;const f=n?n.level+1:0;this.updateLevels(i,f)}}}get headId(){var n;return((n=this.head)==null?void 0:n.current.id)??null}getMessages(n){var a;if(n===void 0||n===((a=this.head)==null?void 0:a.current.id))return this._messages.value;const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.");const r=new Array(i.level+1);for(let h=i;h;h=h.prev)r[h.level]=h.current;return r}addOrUpdateMessage(n,i){const r=this.messages.get(i.id),a=n?this.messages.get(n):null;if(a===void 0)throw new Error("MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.");if(r){r.current=i,this.performOp(a,r,"relink"),this._messages.dirty();return}const h={prev:a,current:i,next:null,children:[],level:a?a.level+1:0};this.messages.set(i.id,h),this.performOp(a,h,"link"),this.head===a&&(this.head=h),this._messages.dirty()}getMessage(n){var r;const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.");return{parentId:((r=i.prev)==null?void 0:r.current.id)??null,message:i.current,index:i.level}}appendOptimisticMessage(n,i){let r;do r=wc();while(this.messages.has(r));return this.addOrUpdateMessage(n,ss(i,r,{type:"running"})),r}deleteMessage(n,i){const r=this.messages.get(n);if(!r)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const a=i===void 0?r.prev:i===null?null:this.messages.get(i);if(a===void 0)throw new Error("MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.");for(const h of r.children){const f=this.messages.get(h);if(!f)throw new Error("MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.");this.performOp(a,f,"relink")}this.performOp(null,r,"cut"),this.messages.delete(n),this.head===r&&(this.head=Xn(a??this.root)),this._messages.dirty()}getBranches(n){const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.");const{children:r}=i.prev??this.root;return r}switchToBranch(n){const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.");const r=i.prev??this.root;r.next=i,this.head=Xn(i),this._messages.dirty()}resetHead(n){if(n===null){this.clear();return}const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.");if(i.children.length>0){const r=a=>{for(const h of a.children){const f=this.messages.get(h);f&&(r(f),this.messages.delete(h))}};r(i),i.children=[],i.next=null}this.head=i;for(let r=i;r;r=r.prev)r.prev&&(r.prev.next=r);this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){var i,r;const n=[];for(const[,a]of this.messages)n.push({message:a.current,parentId:((i=a.prev)==null?void 0:i.current.id)??null});return{headId:((r=this.head)==null?void 0:r.current.id)??null,messages:n}}import({headId:n,messages:i}){var r;for(const{message:a,parentId:h}of i)this.addOrUpdateMessage(h,a);this.resetHead(n??((r=i.at(-1))==null?void 0:r.message.id)??null)}},Qn=class{constructor(){S(this,"_subscriptions",new Set);S(this,"_connection")}get isConnected(){return!!this._connection}notifySubscribers(){for(const n of this._subscriptions)n()}_updateConnection(){var n;if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else(n=this._connection)==null||n.call(this),this._connection=void 0}subscribe(n){return this._subscriptions.add(n),this._updateConnection(),()=>{this._subscriptions.delete(n),this._updateConnection()}}},Yt=Symbol("skip-update"),os=class extends Qn{constructor(i){super();S(this,"_previousStateDirty",!0);S(this,"_previousState");S(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const i=this.binding.getState();i!==Yt&&(this._previousState=i),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState});this.binding=i}get path(){return this.binding.path}_connect(){const i=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(i)}},jn=class{constructor(n,i){this._core=n,this._threadListBinding=i,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(){const n=this._core.getState();return this._threadListBinding.switchToThread(n.id)}rename(n){const i=this._core.getState();return this._threadListBinding.rename(i.id,n)}archive(){const n=this._core.getState();return this._threadListBinding.archive(n.id)}unarchive(){const n=this._core.getState();return this._threadListBinding.unarchive(n.id)}delete(){const n=this._core.getState();return this._threadListBinding.delete(n.id)}initialize(){const n=this._core.getState();return this._threadListBinding.initialize(n.id)}generateTitle(){const n=this._core.getState();return this._threadListBinding.generateTitle(n.id)}unstable_on(n,i){let r=this._core.getState().isMain,a=this._core.getState().id;return this.subscribe(()=>{const h=this._core.getState(),f=h.isMain,p=h.id;r===f&&a===p||(r=f,a=p,!(n==="switched-to"&&!f)&&(n==="switched-away"&&f||i()))})}subscribe(n){return this._core.subscribe(n)}detach(){const n=this._core.getState();this._threadListBinding.detach(n.id)}__internal_getRuntime(){return this}};function Mc(n,i){if(n===void 0&&i===void 0)return!0;if(n===void 0||i===void 0)return!1;for(const r of Object.keys(n)){const a=n[r],h=i[r];if(!Object.is(a,h))return!1}return!0}var Vt=class extends Qn{constructor(i){super();S(this,"_previousState");S(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=i;const r=i.getState();if(r===Yt)throw new Error("Entry not available in the store");this._previousState=r}get path(){return this.binding.path}_syncState(){const i=this.binding.getState();return i===Yt||Mc(i,this._previousState)?!1:(this._previousState=i,!0)}_connect(){const i=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(i)}},tn=Symbol("innerMessage"),Pc=n=>n[tn],Sn=n=>n.content.filter(r=>r.type==="text").map(r=>r.text).join(`
12
+
13
+ `),ji=class{constructor(n){this._core=n,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(n){return this._core.subscribe(n)}},to=class extends ji{constructor(n,i){super(n),this._composerApi=i}remove(){const n=this._composerApi.getState();if(!n)throw new Error("Composer is not available");return n.removeAttachment(this.getState().id)}},Oc=class extends to{get source(){return"thread-composer"}},Lc=class extends to{get source(){return"edit-composer"}},Bc=class extends ji{get source(){return"message"}constructor(n){super(n)}remove(){throw new Error("Message attachments cannot be removed")}},eo=class extends Qn{constructor(n){super(),this.config=n}getState(){return this.config.binding.getState()}outerSubscribe(n){return this.config.binding.subscribe(n)}_connect(){const n=()=>{this.notifySubscribers()};let i=this.config.binding.getState(),r=i==null?void 0:i.unstable_on(this.config.event,n);const a=()=>{var p;const f=this.config.binding.getState();f!==i&&(i=f,r==null||r(),r=(p=this.config.binding.getState())==null?void 0:p.unstable_on(this.config.event,n))},h=this.outerSubscribe(a);return()=>{h==null||h(),r==null||r()}}},no=Object.freeze([]),ro=Object.freeze({}),kc=n=>Object.freeze({type:"thread",isEditing:(n==null?void 0:n.isEditing)??!1,canCancel:(n==null?void 0:n.canCancel)??!1,isEmpty:(n==null?void 0:n.isEmpty)??!0,attachments:(n==null?void 0:n.attachments)??no,text:(n==null?void 0:n.text)??"",role:(n==null?void 0:n.role)??"user",runConfig:(n==null?void 0:n.runConfig)??ro,attachmentAccept:(n==null?void 0:n.attachmentAccept)??"",value:(n==null?void 0:n.text)??""}),Dc=n=>Object.freeze({type:"edit",isEditing:(n==null?void 0:n.isEditing)??!1,canCancel:(n==null?void 0:n.canCancel)??!1,isEmpty:(n==null?void 0:n.isEmpty)??!0,text:(n==null?void 0:n.text)??"",role:(n==null?void 0:n.role)??"user",attachments:(n==null?void 0:n.attachments)??no,runConfig:(n==null?void 0:n.runConfig)??ro,attachmentAccept:(n==null?void 0:n.attachmentAccept)??"",value:(n==null?void 0:n.text)??""}),so=class{constructor(n){S(this,"_eventSubscriptionSubjects",new Map);this._core=n}get path(){return this._core.path}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");i.setText(n)}setRunConfig(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");i.setRunConfig(n)}addAttachment(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");return i.addAttachment(n)}reset(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");return n.reset()}clearAttachments(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");return n.clearAttachments()}send(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");n.send()}cancel(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");n.cancel()}setRole(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");i.setRole(n)}subscribe(n){return this._core.subscribe(n)}unstable_on(n,i){let r=this._eventSubscriptionSubjects.get(n);return r||(r=new eo({event:n,binding:this._core}),this._eventSubscriptionSubjects.set(n,r)),r.subscribe(i)}},Nc=class extends so{constructor(i){const r=new os({path:i.path,getState:()=>kc(i.getState()),subscribe:a=>i.subscribe(a)});super({path:i.path,getState:()=>i.getState(),subscribe:a=>r.subscribe(a)});S(this,"_getState");this._getState=r.getState.bind(r),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"thread"}getState(){return this._getState()}getAttachmentByIndex(i){return new Oc(new Vt({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:i},ref:`${this.path.ref}${this.path.ref}.attachments[${i}]`},getState:()=>{const a=this.getState().attachments[i];return a?{...a,source:"thread-composer"}:Yt},subscribe:r=>this._core.subscribe(r)}),this._core)}},Fc=class extends so{constructor(i,r){const a=new os({path:i.path,getState:()=>Dc(i.getState()),subscribe:h=>i.subscribe(h)});super({path:i.path,getState:()=>i.getState(),subscribe:h=>a.subscribe(h)});S(this,"_getState");this._beginEdit=r,this._getState=a.getState.bind(a),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"edit"}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(i){return new Lc(new Vt({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:i},ref:`${this.path.ref}${this.path.ref}.attachments[${i}]`},getState:()=>{const a=this.getState().attachments[i];return a?{...a,source:"edit-composer"}:Yt},subscribe:r=>this._core.subscribe(r)}),this._core)}},io=Symbol.for("aui.tool-response"),Uc=class Wi{constructor(i){S(this,"artifact");S(this,"result");S(this,"isError");i.artifact!==void 0&&(this.artifact=i.artifact),this.result=i.result,this.isError=i.isError??!1}get[io](){return!0}static[Symbol.hasInstance](i){return typeof i=="object"&&i!==null&&io in i}static toResponse(i){return i instanceof Wi?i:new Wi({result:i===void 0?"<no result>":i})}},oo=class{constructor(n,i,r){this.contentBinding=n,this.messageApi=i,this.threadApi=r,this.__internal_bindMethods()}get path(){return this.contentBinding.path}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(n){const i=this.contentBinding.getState();if(!i)throw new Error("Message part is not available");if(i.type!=="tool-call")throw new Error("Tried to add tool result to non-tool message part");if(!this.messageApi)throw new Error("Message API is not available. This is likely a bug in assistant-ui.");if(!this.threadApi)throw new Error("Thread API is not available");const r=this.messageApi.getState();if(!r)throw new Error("Message is not available");const a=i.toolName,h=i.toolCallId,f=Uc.toResponse(n);this.threadApi.getState().addToolResult({messageId:r.id,toolName:a,toolCallId:h,result:f.result,artifact:f.artifact,isError:f.isError})}resumeToolCall(n){const i=this.contentBinding.getState();if(!i)throw new Error("Message part is not available");if(i.type!=="tool-call")throw new Error("Tried to resume tool call on non-tool message part");if(!this.threadApi)throw new Error("Thread API is not available");const r=i.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:r,payload:n})}subscribe(n){return this.contentBinding.subscribe(n)}},tr=class extends Qn{constructor(n){super(),this.binding=n}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(n){return this.binding.subscribe(n)}_connect(){const n=()=>{this.notifySubscribers()};let i=this.binding.getState(),r=i==null?void 0:i.subscribe(n);const a=()=>{var p;const f=this.binding.getState();f!==i&&(i=f,r==null||r(),r=(p=this.binding.getState())==null?void 0:p.subscribe(n),n())},h=this.outerSubscribe(a);return()=>{h==null||h(),r==null||r()}}},er=Object.freeze({type:"complete"}),Wc=(n,i,r)=>{if(n.role!=="assistant")return er;if(r.type==="tool-call")return r.result?er:n.status;const a=i===Math.max(0,n.content.length-1);return n.status.type==="requires-action"?er:a?n.status:er},ao=(n,i)=>{const r=n.content[i];if(!r)return Yt;const a=Wc(n,i,r);return Object.freeze({...r,[tn]:r[tn],status:a})},$c=class{constructor(n,i){S(this,"composer");S(this,"_getEditComposerRuntimeCore",()=>this._threadBinding.getState().getEditComposer(this._core.getState().id));this._core=n,this._threadBinding=i,this.composer=new Fc(new tr({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"edit"},getState:this._getEditComposerRuntimeCore,subscribe:r=>this._threadBinding.subscribe(r)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.reload=this.reload.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}getState(){return this._core.getState()}reload(n={}){const i=this._getEditComposerRuntimeCore(),r=i??this._threadBinding.getState().composer,a=i??r,{runConfig:h=a.runConfig}=n,f=this._core.getState();if(f.role!=="assistant")throw new Error("Can only reload assistant messages");this._threadBinding.getState().startRun({parentId:f.parentId,sourceId:f.id,runConfig:h})}speak(){const n=this._core.getState();return this._threadBinding.getState().speak(n.id)}stopSpeaking(){var r;const n=this._core.getState();if(((r=this._threadBinding.getState().speech)==null?void 0:r.messageId)===n.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:n}){const i=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:i.id,type:n})}switchToBranch({position:n,branchId:i}){const r=this._core.getState();if(i&&n)throw new Error("May not specify both branchId and position");if(!i&&!n)throw new Error("Must specify either branchId or position");const h=this._threadBinding.getState().getBranches(r.id);let f=i;if(n==="previous"?f=h[r.branchNumber-2]:n==="next"&&(f=h[r.branchNumber]),!f)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(f)}unstable_getCopyText(){return Sn(this.getState())}subscribe(n){return this._core.subscribe(n)}getMessagePartByIndex(n){if(n<0)throw new Error("Message part index must be >= 0");return new oo(new Vt({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${n}]`,messagePartSelector:{type:"index",index:n}},getState:()=>ao(this.getState(),n),subscribe:i=>this._core.subscribe(i)}),this._core,this._threadBinding)}getMessagePartByToolCallId(n){return new oo(new Vt({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(n)}]`,messagePartSelector:{type:"toolCallId",toolCallId:n}},getState:()=>{const i=this._core.getState(),r=i.content.findIndex(a=>a.type==="tool-call"&&a.toolCallId===n);return r===-1?Yt:ao(i,r)},subscribe:i=>this._core.subscribe(i)}),this._core,this._threadBinding)}getAttachmentByIndex(n){return new Bc(new Vt({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${n}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:n}},getState:()=>{const i=this.getState().attachments,r=i==null?void 0:i[n];return r?{...r,source:"message"}:Yt},subscribe:i=>this._core.subscribe(i)}))}},qc=n=>({parentId:n.parentId??null,sourceId:n.sourceId??null,runConfig:n.runConfig??{},...n.stream?{stream:n.stream}:{}}),zc=n=>({parentId:n.parentId??null,sourceId:n.sourceId??null,runConfig:n.runConfig??{}}),Hc=(n,i)=>{var r,a;return typeof i=="string"?{createdAt:new Date,parentId:((r=n.at(-1))==null?void 0:r.id)??null,sourceId:null,runConfig:{},role:"user",content:[{type:"text",text:i}],attachments:[],metadata:{custom:{}}}:{createdAt:i.createdAt??new Date,parentId:i.parentId??((a=n.at(-1))==null?void 0:a.id)??null,sourceId:i.sourceId??null,role:i.role??"user",content:i.content,attachments:i.attachments??[],metadata:i.metadata??{custom:{}},runConfig:i.runConfig??{},startRun:i.startRun}},Jc=(n,i)=>{const r=n.messages.at(-1);return Object.freeze({threadId:i.id,metadata:i,capabilities:n.capabilities,isDisabled:n.isDisabled,isLoading:n.isLoading,isRunning:(r==null?void 0:r.role)!=="assistant"?!1:r.status.type==="running",messages:n.messages,state:n.state,suggestions:n.suggestions,extras:n.extras,speech:n.speech})},Gc=class{constructor(n,i){S(this,"_threadBinding");S(this,"composer");S(this,"_eventSubscriptionSubjects",new Map);const r=new Vt({path:n.path,getState:()=>Jc(n.getState(),i.getState()),subscribe:a=>{const h=n.subscribe(a),f=i.subscribe(a);return()=>{h(),f()}}});this._threadBinding={path:n.path,getState:()=>n.getState(),getStateState:()=>r.getState(),outerSubscribe:a=>n.outerSubscribe(a),subscribe:a=>n.subscribe(a)},this.composer=new Nc(new tr({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"thread"},getState:()=>this._threadBinding.getState().composer,subscribe:a=>this._threadBinding.subscribe(a)})),this.__internal_bindMethods()}get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}__internal_bindMethods(){this.append=this.append.bind(this),this.unstable_resumeRun=this.unstable_resumeRun.bind(this),this.unstable_loadExternalState=this.unstable_loadExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getModelConfig=this.getModelConfig.bind(this),this.getState=this.getState.bind(this)}getState(){return this._threadBinding.getStateState()}append(n){this._threadBinding.getState().append(Hc(this._threadBinding.getState().messages,n))}subscribe(n){return this._threadBinding.subscribe(n)}getModelContext(){return this._threadBinding.getState().getModelContext()}getModelConfig(){return this.getModelContext()}startRun(n){const i=n===null||typeof n=="string"?{parentId:n}:n;return this._threadBinding.getState().startRun(zc(i))}unstable_resumeRun(n){return this._threadBinding.getState().resumeRun(qc(n))}unstable_loadExternalState(n){this._threadBinding.getState().unstable_loadExternalState(n)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}export(){return this._threadBinding.getState().export()}import(n){this._threadBinding.getState().import(n)}reset(n){this._threadBinding.getState().reset(n)}getMessageByIndex(n){if(n<0)throw new Error("Message index must be >= 0");return this._getMessageRuntime({...this.path,ref:`${this.path.ref}${this.path.ref}.messages[${n}]`,messageSelector:{type:"index",index:n}},()=>{var a;const i=this._threadBinding.getState().messages,r=i[n];if(r)return{message:r,parentId:((a=i[n-1])==null?void 0:a.id)??null,index:n}})}getMessageById(n){return this._getMessageRuntime({...this.path,ref:this.path.ref+`${this.path.ref}.messages[messageId=${JSON.stringify(n)}]`,messageSelector:{type:"messageId",messageId:n}},()=>this._threadBinding.getState().getMessageById(n))}_getMessageRuntime(n,i){return new $c(new Vt({path:n,getState:()=>{var P;const{message:r,parentId:a,index:h}=i()??{},{messages:f,speech:p}=this._threadBinding.getState();if(!r||a===void 0||h===void 0)return Yt;const w=this._threadBinding.getState().getBranches(r.id),I=r.metadata.submittedFeedback;return{...r,[tn]:r[tn],index:h,isLast:((P=f.at(-1))==null?void 0:P.id)===r.id,parentId:a,branchNumber:w.indexOf(r.id)+1,branchCount:w.length,speech:(p==null?void 0:p.messageId)===r.id?p:void 0,submittedFeedback:I}},subscribe:r=>this._threadBinding.subscribe(r)}),this._threadBinding)}unstable_on(n,i){let r=this._eventSubscriptionSubjects.get(n);return r||(r=new eo({event:n,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(n,r)),r.subscribe(i)}},Kc=n=>({mainThreadId:n.mainThreadId,newThread:n.newThreadId,threads:n.threadIds,archivedThreads:n.archivedThreadIds,isLoading:n.isLoading,threadItems:n.threadData}),nr=(n,i)=>{if(i===void 0)return Yt;const r=n.getItemById(i);return r?{id:r.id,threadId:r.id,remoteId:r.remoteId,externalId:r.externalId,title:r.title,status:r.status,isMain:r.id===n.mainThreadId}:Yt},Yc=class{constructor(n,i=Gc){S(this,"_getState");S(this,"_mainThreadListItemRuntime");S(this,"main");this._core=n,this._runtimeFactory=i;const r=new os({path:{},getState:()=>Kc(n),subscribe:a=>n.subscribe(a)});this._getState=r.getState.bind(r),this._mainThreadListItemRuntime=new jn(new Vt({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>nr(this._core,this._core.mainThreadId),subscribe:a=>this._core.subscribe(a)}),this._core),this.main=new i(new tr({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>n.getMainThreadRuntimeCore(),subscribe:a=>n.subscribe(a)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(n){return this._core.switchToThread(n)}switchToNewThread(){return this._core.switchToNewThread()}getState(){return this._getState()}subscribe(n){return this._core.subscribe(n)}get mainItem(){return this._mainThreadListItemRuntime}getById(n){return new this._runtimeFactory(new tr({path:{ref:`threads[threadId=${JSON.stringify(n)}]`,threadSelector:{type:"threadId",threadId:n}},getState:()=>this._core.getThreadRuntimeCore(n),subscribe:i=>this._core.subscribe(i)}),this.mainItem)}getItemByIndex(n){return new jn(new Vt({path:{ref:`threadItems[${n}]`,threadSelector:{type:"index",index:n}},getState:()=>nr(this._core,this._core.threadIds[n]),subscribe:i=>this._core.subscribe(i)}),this._core)}getArchivedItemByIndex(n){return new jn(new Vt({path:{ref:`archivedThreadItems[${n}]`,threadSelector:{type:"archiveIndex",index:n}},getState:()=>nr(this._core,this._core.archivedThreadIds[n]),subscribe:i=>this._core.subscribe(i)}),this._core)}getItemById(n){return new jn(new Vt({path:{ref:`threadItems[threadId=${n}]`,threadSelector:{type:"threadId",threadId:n}},getState:()=>nr(this._core,n),subscribe:i=>this._core.subscribe(i)}),this._core)}},Vc=class{constructor(){S(this,"accept","image/*")}async add(n){return{id:n.file.name,type:"image",name:n.file.name,contentType:n.file.type,file:n.file,status:{type:"requires-action",reason:"composer-send"}}}async send(n){return{...n,status:{type:"complete"},content:[{type:"image",image:await Zc(n.file)}]}}async remove(){}},Zc=n=>new Promise((i,r)=>{const a=new FileReader;a.onload=()=>i(a.result),a.onerror=h=>r(h),a.readAsDataURL(n)});function as(n,i){if(i==="*")return!0;const r=i.split(",").map(f=>f.trim().toLowerCase()),a=`.${n.name.split(".").pop().toLowerCase()}`,h=n.type.toLowerCase();for(const f of r){if(f.startsWith(".")&&f===a||f.includes("/")&&f===h)return!0;if((f==="image/*"||f==="video/*"||f==="audio/*")&&f.endsWith("/*")){const p=f.split("/")[0];if(h.startsWith(`${p}/`))return!0}}return!1}var Xc=class{constructor(n){S(this,"_adapters");S(this,"accept");this._adapters=n;const i=n.findIndex(r=>r.accept==="*");if(i!==-1){if(i!==n.length-1)throw new Error("A wildcard adapter (handling all files) can only be specified as the last adapter.");this.accept="*"}else this.accept=n.map(r=>r.accept).join(",")}add(n){for(const i of this._adapters)if(as(n.file,i.accept))return i.add(n);throw new Error("No matching adapter found for file")}async send(n){const i=this._adapters.slice();for(const r of i)if(as(n.file,r.accept))return r.send(n);throw new Error("No matching adapter found for attachment")}async remove(n){const i=this._adapters.slice();for(const r of i)if(as({name:n.name,type:n.contentType},r.accept))return r.remove(n);throw new Error("No matching adapter found for attachment")}},Qc=B.createContext(null),jc=()=>B.useContext(Qc),ke=Object.freeze([]),De="DEFAULT_THREAD_ID",th=Object.freeze([De]),uo=Object.freeze({id:De,remoteId:void 0,externalId:void 0,status:"regular"}),eh=Promise.resolve(),co=Object.freeze({[De]:uo}),nh=class{constructor(n={},i){S(this,"_mainThreadId",De);S(this,"_threads",th);S(this,"_archivedThreads",ke);S(this,"_threadData",co);S(this,"_mainThread");S(this,"_subscriptions",new Set);this.adapter=n,this.threadFactory=i,this._mainThread=this.threadFactory(),this.__internal_setAdapter(n,!0)}get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadData(){return this._threadData}getLoadThreadsPromise(){return eh}get mainThreadId(){return this._mainThreadId}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getItemById(n){for(const i of this.adapter.threads??[])if(i.id===n)return i;for(const i of this.adapter.archivedThreads??[])if(i.id===n)return i;if(n===De)return uo}__internal_setAdapter(n,i=!1){var I,P,C,A;const r=this.adapter;this.adapter=n;const a=n.threadId??De,h=n.threads??ke,f=n.archivedThreads??ke,p=r.threadId??De,m=r.threads??ke,w=r.archivedThreads??ke;!i&&p===a&&m===h&&w===f||(this._threadData={...co,...Object.fromEntries(((I=n.threads)==null?void 0:I.map(R=>[R.id,{...R,remoteId:R.remoteId,externalId:R.externalId,status:"regular"}]))??[]),...Object.fromEntries(((P=n.archivedThreads)==null?void 0:P.map(R=>[R.id,{...R,remoteId:R.remoteId,externalId:R.externalId,status:"archived"}]))??[])},m!==h&&(this._threads=((C=this.adapter.threads)==null?void 0:C.map(R=>R.id))??ke),w!==f&&(this._archivedThreads=((A=this.adapter.archivedThreads)==null?void 0:A.map(R=>R.id))??ke),p!==a&&(this._mainThreadId=a,this._mainThread=this.threadFactory()),this._notifySubscribers())}async switchToThread(n){if(this._mainThreadId===n)return;const i=this.adapter.onSwitchToThread;if(!i)throw new Error("External store adapter does not support switching to thread");i(n)}async switchToNewThread(){const n=this.adapter.onSwitchToNewThread;if(!n)throw new Error("External store adapter does not support switching to new thread");n()}async rename(n,i){const r=this.adapter.onRename;if(!r)throw new Error("External store adapter does not support renaming");r(n,i)}async detach(){}async archive(n){const i=this.adapter.onArchive;if(!i)throw new Error("External store adapter does not support archiving");i(n)}async unarchive(n){const i=this.adapter.onUnarchive;if(!i)throw new Error("External store adapter does not support unarchiving");i(n)}async delete(n){const i=this.adapter.onDelete;if(!i)throw new Error("External store adapter does not support deleting");i(n)}initialize(n){return Promise.resolve({remoteId:n,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}subscribe(n){return this._subscriptions.add(n),()=>this._subscriptions.delete(n)}_notifySubscribers(){for(const n of this._subscriptions)n()}},ho=class{constructor(){S(this,"cache",new WeakMap)}convertMessages(n,i){return n.map((r,a)=>{const h=this.cache.get(r),f=i(h,r,a);return this.cache.set(r,f),f})}},rh=class extends Ji{constructor(i,r,{parentId:a,message:h}){super();S(this,"_nonTextParts");S(this,"_previousText");S(this,"_parentId");S(this,"_sourceId");this.runtime=i,this.endEditCallback=r,this._parentId=a,this._sourceId=h.id,this._previousText=Sn(h),this.setText(this._previousText),this.setRole(h.role),this.setAttachments(h.attachments??[]),this._nonTextParts=h.content.filter(f=>f.type!=="text"),this.setRunConfig({...i.composer.runConfig})}get canCancel(){return!0}getAttachmentAdapter(){var i;return(i=this.runtime.adapters)==null?void 0:i.attachments}async handleSend(i){Sn(i)!==this._previousText&&this.runtime.append({...i,content:[...i.content,...this._nonTextParts],parentId:this._parentId,sourceId:this._sourceId}),this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},sh=class{constructor(n){S(this,"_subscriptions",new Set);S(this,"_isInitialized",!1);S(this,"repository",new Qi);S(this,"composer",new mc(this));S(this,"_editComposers",new Map);S(this,"_stopSpeaking");S(this,"speech");S(this,"_eventSubscribers",new Map);this._contextProvider=n}get messages(){return this.repository.getMessages()}get state(){let n;for(const i of this.messages)if(i.role==="assistant"){n=i;break}return(n==null?void 0:n.metadata.unstable_state)??null}getModelContext(){return this._contextProvider.getModelContext()}getEditComposer(n){return this._editComposers.get(n)}beginEdit(n){if(this._editComposers.has(n))throw new Error("Edit already in progress");this._editComposers.set(n,new rh(this,()=>this._editComposers.delete(n),this.repository.getMessage(n))),this._notifySubscribers()}getMessageById(n){try{return this.repository.getMessage(n)}catch{return}}getBranches(n){return this.repository.getBranches(n)}switchToBranch(n){this.repository.switchToBranch(n),this._notifySubscribers()}_notifySubscribers(){for(const n of this._subscriptions)n()}_notifyEventSubscribers(n){const i=this._eventSubscribers.get(n);if(i)for(const r of i)r()}subscribe(n){return this._subscriptions.add(n),()=>this._subscriptions.delete(n)}submitFeedback({messageId:n,type:i}){var f;const r=(f=this.adapters)==null?void 0:f.feedback;if(!r)throw new Error("Feedback adapter not configured");const{message:a,parentId:h}=this.repository.getMessage(n);if(r.submit({message:a,type:i}),a.role==="assistant"){const p={...a,metadata:{...a.metadata,submittedFeedback:{type:i}}};this.repository.addOrUpdateMessage(h,p)}this._notifySubscribers()}speak(n){var f,p;const i=(f=this.adapters)==null?void 0:f.speech;if(!i)throw new Error("Speech adapter not configured");const{message:r}=this.repository.getMessage(n);(p=this._stopSpeaking)==null||p.call(this);const a=i.speak(Sn(r)),h=a.subscribe(()=>{a.status.type==="ended"?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:n,status:a.status},this._notifySubscribers()});this.speech={messageId:n,status:a.status},this._notifySubscribers(),this._stopSpeaking=()=>{a.cancel(),h(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");this._stopSpeaking(),this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers("initialize"))}export(){return this.repository.export()}import(n){this.ensureInitialized(),this.repository.clear(),this.repository.import(n),this._notifySubscribers()}reset(n){this.import(is.fromArray(n??[]))}unstable_on(n,i){var a,h;if(n==="model-context-update")return((h=(a=this._contextProvider).subscribe)==null?void 0:h.call(a,i))??(()=>{});const r=this._eventSubscribers.get(n);return r?r.add(i):this._eventSubscribers.set(n,new Set([i])),()=>{this._eventSubscribers.get(n).delete(i)}}},ih=Object.freeze([]),oh=(n,i)=>{var r;return n&&((r=i[i.length-1])==null?void 0:r.role)!=="assistant"},ah=class extends sh{constructor(i,r){super(i);S(this,"_assistantOptimisticId",null);S(this,"_capabilities",{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,attachments:!1,feedback:!1});S(this,"_messages");S(this,"isDisabled");S(this,"suggestions",[]);S(this,"extras");S(this,"_converter",new ho);S(this,"_store");S(this,"updateMessages",i=>{var a,h,f,p;this._store.convertMessage!==void 0?(h=(a=this._store).setMessages)==null||h.call(a,i.flatMap(Pc).filter(m=>m!=null)):(p=(f=this._store).setMessages)==null||p.call(f,i)});this.__internal_setAdapter(r)}get capabilities(){return this._capabilities}get isLoading(){return this._store.isLoading??!1}get messages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}beginEdit(i){if(!this._store.onEdit)throw new Error("Runtime does not support editing.");super.beginEdit(i)}__internal_setAdapter(i){var f,p,m,w,I,P;if(this._store===i)return;const r=i.isRunning??!1;this.isDisabled=i.isDisabled??!1;const a=this._store;this._store=i,this.extras=i.extras,this.suggestions=i.suggestions??ih,this._capabilities={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,reload:this._store.onReload!==void 0,cancel:this._store.onCancel!==void 0,speech:((f=this._store.adapters)==null?void 0:f.speech)!==void 0,unstable_copy:((p=this._store.unstable_capabilities)==null?void 0:p.copy)!==!1,attachments:!!((m=this._store.adapters)!=null&&m.attachments),feedback:!!((w=this._store.adapters)!=null&&w.feedback)};let h;if(i.messageRepository){if(a&&a.isRunning===i.isRunning&&a.messageRepository===i.messageRepository){this._notifySubscribers();return}this.repository.clear(),this._assistantOptimisticId=null,this.repository.import(i.messageRepository),h=this.repository.getMessages()}else if(i.messages){if(a){if(a.convertMessage!==i.convertMessage)this._converter=new ho;else if(a.isRunning===i.isRunning&&a.messages===i.messages){this._notifySubscribers();return}}h=i.convertMessage?this._converter.convertMessages(i.messages,(C,A,R)=>{if(!i.convertMessage)return A;const K=R===i.messages.length-1,At=Gi(K,r,!1,!1,void 0);if(C&&(C.role!=="assistant"||!Ec(C.status)||C.status===At))return C;const gt=i.convertMessage(A,R),ct=ss(gt,R.toString(),At);return ct[tn]=A,ct}):i.messages;for(let C=0;C<h.length;C++){const A=h[C],R=h[C-1];this.repository.addOrUpdateMessage((R==null?void 0:R.id)??null,A)}}else throw new Error("ExternalStoreAdapter must provide either 'messages' or 'messageRepository'");h.length>0&&this.ensureInitialized(),((a==null?void 0:a.isRunning)??!1)!==(i.isRunning??!1)&&(i.isRunning?this._notifyEventSubscribers("run-start"):this._notifyEventSubscribers("run-end")),this._assistantOptimisticId&&(this.repository.deleteMessage(this._assistantOptimisticId),this._assistantOptimisticId=null),oh(r,h)&&(this._assistantOptimisticId=this.repository.appendOptimisticMessage(((I=h.at(-1))==null?void 0:I.id)??null,{role:"assistant",content:[]})),this.repository.resetHead(this._assistantOptimisticId??((P=h.at(-1))==null?void 0:P.id)??null),this._messages=this.repository.getMessages(),this._notifySubscribers()}switchToBranch(i){if(!this._store.setMessages)throw new Error("Runtime does not support switching branches.");this._store.isRunning||(this.repository.switchToBranch(i),this.updateMessages(this.repository.getMessages()))}async append(i){var r;if(i.parentId!==(((r=this.messages.at(-1))==null?void 0:r.id)??null)){if(!this._store.onEdit)throw new Error("Runtime does not support editing messages.");await this._store.onEdit(i)}else await this._store.onNew(i)}async startRun(i){if(!this._store.onReload)throw new Error("Runtime does not support reloading messages.");await this._store.onReload(i.parentId,i)}async resumeRun(i){if(!this._store.onResume)throw new Error("Runtime does not support resuming runs.");await this._store.onResume(i)}unstable_loadExternalState(i){if(!this._store.onLoadExternalState)throw new Error("Runtime does not support importing states.");this._store.onLoadExternalState(i)}cancelRun(){var a;if(!this._store.onCancel)throw new Error("Runtime does not support cancelling runs.");this._store.onCancel(),this._assistantOptimisticId&&(this.repository.deleteMessage(this._assistantOptimisticId),this._assistantOptimisticId=null);let i=this.repository.getMessages();const r=i[i.length-1];(r==null?void 0:r.role)==="user"&&r.id===((a=i.at(-1))==null?void 0:a.id)?(this.repository.deleteMessage(r.id),this.composer.text.trim()||this.composer.setText(Sn(r)),i=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(i)},0)}addToolResult(i){var r,a;if(!this._store.onAddToolResult&&!this._store.onAddToolResult)throw new Error("Runtime does not support tool results.");(a=(r=this._store).onAddToolResult)==null||a.call(r,i)}resumeToolCall(i){if(!this._store.onResumeToolCall)throw new Error("Runtime does not support resuming tool calls.");this._store.onResumeToolCall(i)}reset(i){const r=new Qi;r.import(is.fromArray(i??[])),this.updateMessages(r.getMessages())}import(i){this._assistantOptimisticId=null,super.import(i),this._store.onImport&&this._store.onImport(this.repository.getMessages())}},lo=n=>{var i;return((i=n.adapters)==null?void 0:i.threadList)??{}},uh=class extends gc{constructor(i){super();S(this,"threads");this.threads=new nh(lo(i),()=>new ah(this._contextProvider,i))}setAdapter(i){this.threads.__internal_setAdapter(lo(i)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(i)}},ch=n=>{const[i]=B.useState(()=>new uh(n));B.useEffect(()=>{i.setAdapter(n)});const{modelContext:r}=jc()??{};return B.useEffect(()=>{if(r)return i.registerModelContextProvider(r)},[r,i]),B.useMemo(()=>new dl(i),[i])};function hh(n,i){n.commitTasks.forEach(r=>{const a=r.cellIndex,h=i.cells[a];if(h.type!=="effect")throw new Error("Cannot find effect cell");let f=!0;if(h.deps!==void 0&&r.deps!==void 0&&(f=h.deps.length!==r.deps.length||h.deps.some((p,m)=>!Object.is(p,r.deps[m]))),f){if(h.mounted){if(typeof h.deps!=typeof r.deps)throw new Error("tapEffect called with and without dependencies across re-renders");try{h.mounted&&h.cleanup&&h.cleanup()}finally{h.mounted=!1}}try{const p=r.effect();if(p!==void 0&&typeof p!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof p}`);h.mounted=!0,h.cleanup=typeof p=="function"?p:void 0,h.deps=r.deps}catch(p){throw p}}})}function lh(n){let i=null;for(let r=n.cells.length-1;r>=0;r--){const a=n.cells[r];if((a==null?void 0:a.type)==="effect"&&a.mounted&&a.cleanup)try{a.cleanup()}catch(h){i==null&&(i=h)}finally{a.mounted=!1}}if(i!=null)throw i}var En=null;function fh(n,i){n.currentIndex=0;const r=En;En=n;try{if(i(),n.isFirstRender=!1,n.cells.length!==n.currentIndex)throw new Error(`Rendered ${n.currentIndex} hooks but expected ${n.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{En=r}}function us(){if(!En)throw new Error("No resource fiber available");return En}function fo(n,i){const r=n[po];if(!r)throw new Error("ResourceElement.type is not a valid Resource");return r(i)}var po=Symbol("fnSymbol");function rr(n,i){return{resource:n,scheduleRerender:i,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function en(n){n.isMounted=!1,lh(n)}function xn(n,i){const r={commitTasks:[],props:i,state:void 0};return fh(n,()=>{n.renderContext=r;try{r.state=fo(n.resource,i)}finally{n.renderContext=void 0}}),r}function nn(n,i){n.isMounted=!0,n.isNeverMounted=!1,hh(i,n)}var dh=globalThis.__ASSISTANT_UI_DISABLE_LAYOUT_EFFECT__===!0,go=dh?B.useEffect:B.useLayoutEffect;function ph(n){const[,i]=B.useState({}),r=B.useMemo(()=>rr(n.type,()=>i({})),[n.type,i]),a=xn(r,n.props);return go(()=>()=>en(r),[]),go(()=>{nn(r,a)}),a.state}var _o=n=>typeof n=="string"?{scope:n.split(".")[0],event:n}:{scope:n.scope,event:n.event},cs=(n,i,r)=>i===n,rn,hs=()=>{if(rn)return rn;const n=()=>({apis:new Map,nextId:0,listeners:new Set});if(typeof window>"u")return rn=n(),rn;const i=window.__ASSISTANT_UI_DEVTOOLS_HOOK__;if(i)return rn=i,i;const r=n();return window.__ASSISTANT_UI_DEVTOOLS_HOOK__=r,rn=r,r},gh=(Xt=class{static register(i){var m,w;const r=hs();for(const I of r.apis.values())if(I.api===i)return()=>{};const a=r.nextId++,h={api:i,logs:[]},f=(m=i.on)==null?void 0:m.call(i,"*",I=>{const P=r.apis.get(a);P&&(P.logs.push({time:new Date,event:I.event,data:I.payload}),P.logs.length>Xt.MAX_EVENT_LOGS_PER_API&&(P.logs=P.logs.slice(-200)),Xt.notifyListeners(a))}),p=(w=i.subscribe)==null?void 0:w.call(i,()=>{Xt.notifyListeners(a)});return r.apis.set(a,h),Xt.notifyListeners(a),()=>{const I=hs();I.apis.get(a)&&(f==null||f(),p==null||p(),I.apis.delete(a),Xt.notifyListeners(a))}}static notifyListeners(i){hs().listeners.forEach(a=>a(i))}},S(Xt,"MAX_EVENT_LOGS_PER_API",200),Xt);function lt(n){const i=(r,a)=>({type:i,props:r,...(a==null?void 0:a.key)!==void 0&&{key:a.key}});return i[po]=n,i}var _h=n=>{if(n.renderContext)throw new Error("Resource updated during render");if(n.isNeverMounted)throw new Error("Resource updated before mount");n.isMounted&&n.scheduleRerender()};function bh(n){const i=us(),r=i.currentIndex++;if(!i.isFirstRender&&r>=i.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!i.cells[r]){const f={type:"state",value:typeof n=="function"?n():n,set:p=>{const m=f.value,w=typeof p=="function"?p(m):p;Object.is(m,w)||(f.value=w,_h(i))}};i.cells[r]=f}const a=i.cells[r];if(a.type!=="state")throw new Error("Hook order changed between renders");return a}function ae(n){const i=bh(n);return[i.value,i.set]}function mh(){const n=us(),i=n.currentIndex++;if(!n.isFirstRender&&i>=n.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!n.cells[i]){const a={type:"effect",mounted:!1};n.cells[i]=a}if(n.cells[i].type!=="effect")throw new Error("Hook order changed between renders");return i}function Pt(n,i){const r=us(),a=mh();r.renderContext.commitTasks.push({effect:n,deps:i,cellIndex:a})}function sr(n){const[i]=ae(()=>({current:n}));return i}var vh=(n,i)=>{if(n.length!==i.length)return!1;for(let r=0;r<n.length;r++)if(!Object.is(n[r],i[r]))return!1;return!0},rt=(n,i)=>{const r=sr();return r.current||(r.current={value:n(),deps:i}),vh(r.current.deps,i)||(r.current.value=n(),r.current.deps=i),r.current.value};function ls(n,i){const[r,a]=ae({}),h=rt(()=>rr(n.type,()=>a({})),[n.type]),f=i?rt(()=>n.props,i):n.props,p=rt(()=>xn(h,f),[h,f,r]);return Pt(()=>()=>en(h),[h]),Pt(()=>{nn(h,p)},[h,p]),p.state}function Zt(n){return fo(n.type,n.props)}function wh(n){const i=new Set;n.forEach((m,w)=>{if(m.key===void 0)throw new Error(`tapResources: All resource elements must have a key. Element at index ${w} is missing a key.`);if(i.has(m.key))throw new Error(`tapResources: Duplicate key "${m.key}" found. All keys must be unique.`);i.add(m.key)});const[r,a]=ae({}),h=rt(()=>new Map(n.map(m=>[m.key,m])),[n]),[f]=ae(()=>new Map),p=rt(()=>{const m=new Map,w=new Set;return h.forEach((I,P)=>{w.add(P);let C=f.get(P);(!C||C.resource!==I.type)&&(C&&en(C),C=rr(I.type,()=>a({})),f.set(P,C));const A=xn(C,I.props);m.set(P,A)}),f.forEach((I,P)=>{w.has(P)||(en(I),f.delete(P))}),m},[h,r]);return Pt(()=>{p.forEach((m,w)=>{const I=f.get(w);I&&nn(I,m)})},[p,f]),Pt(()=>()=>{f.forEach(m=>{en(m)}),f.clear()},[f]),rt(()=>n.map(m=>{var w;return(w=p.get(m.key))==null?void 0:w.state}),[n,p])}var fs=[],ds=!1;function yh(){ds=!1;const n=fs;fs=[];for(const i of n)try{i()}catch(r){console.error("Error in scheduled task:",r)}}function Sh(n){fs.push(n),ds||(ds=!0,queueMicrotask(yh))}var Eh=(Ue=class{constructor(i){S(this,"_isDirty",!1);S(this,"_hasScheduledTask",!1);S(this,"_isFlushing",!1);this._task=i}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,!(this._hasScheduledTask||this._isFlushing)&&(this._hasScheduledTask=!0,Sh(()=>{this._hasScheduledTask=!1,this.flushSync()}))}flushSync(){if(this._isFlushing)return;this._isFlushing=!0;let i=0;try{for(;this._isDirty;){if(i++,i>Ue.MAX_FLUSH_DEPTH)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside tapEffect.");this._isDirty=!1,this._task()}}finally{this._isFlushing=!1}}},S(Ue,"MAX_FLUSH_DEPTH",50),Ue),xh=lt(({element:n,onUpdateInput:i,onFlushSync:r,onDispose:a})=>{const[h,f]=ae(n.props),p=Zt({type:n.type,props:h}),m=sr(new Set).current,w=sr(p);return Pt(()=>{p!==w.current&&(w.current=p,m.forEach(P=>P()))}),rt(()=>({getState:()=>w.current,subscribe:P=>(m.add(P),()=>m.delete(P)),updateInput:P=>{i(),f(()=>P)},flushSync:r,dispose:a}),[])}),Th=(n,i=!1)=>{let r=!i;const a={element:n,onUpdateInput:()=>{r||(r=!0,nn(f,p))},onFlushSync:()=>{h.flushSync()},onDispose:()=>en(f)},h=new Eh(()=>{p=xn(f,a),r&&nn(f,p)}),f=rr(xh,()=>h.markDirty());let p=xn(f,a);return r&&nn(f,p),p.state},Tn=Symbol("tap.Context"),bo=n=>({[Tn]:n}),mo=(n,i,r)=>{const a=n[Tn];n[Tn]=i;try{return r()}finally{n[Tn]=a}},vo=n=>n[Tn];const wo=n=>{let i;const r=new Set,a=(I,P)=>{const C=typeof I=="function"?I(i):I;if(!Object.is(C,i)){const A=i;i=P??(typeof C!="object"||C===null)?C:Object.assign({},i,C),r.forEach(R=>R(i,A))}},h=()=>i,m={setState:a,getState:h,getInitialState:()=>w,subscribe:I=>(r.add(I),()=>r.delete(I))},w=i=n(a,h,m);return m},Ah=n=>n?wo(n):wo,Ch=n=>n;function Ih(n,i=Ch){const r=B.useSyncExternalStore(n.subscribe,B.useCallback(()=>i(n.getState()),[n,i]),B.useCallback(()=>i(n.getInitialState()),[n,i]));return B.useDebugValue(r),r}const yo=n=>{const i=Ah(n),r=a=>Ih(i,a);return Object.assign(r,i),r},Rh=n=>n?yo(n):yo;var Mh=lt(n=>{const i=rt(()=>Th(n,!0),[n.type]);return Pt(()=>{i.updateInput(n.props)}),i}),Ph=class{constructor(n){this.getApi=n}get(n,i){return this.getApi()[i]}ownKeys(){return Object.keys(this.getApi())}has(n,i){return i in this.getApi()}getOwnPropertyDescriptor(n,i){return Object.getOwnPropertyDescriptor(this.getApi(),i)}set(){return!1}defineProperty(){return!1}deleteProperty(){return!1}},ue=(n,i)=>{const r=sr(n);Pt(()=>{r.current=n});const a=rt(()=>new Proxy({},new Ph(()=>r.current)),[]),h=i==null?void 0:i.key,f=n.getState();return rt(()=>({key:h,state:f,api:a}),[f,h])},So=bo(null),Oh=(n,i)=>mo(So,n,i),Eo=()=>{const n=vo(So);if(!n)throw new Error("Model context is not available in this context");return n},Lh=lt(({toolkit:n})=>{const[i,r]=ae(()=>({tools:{}})),a=Eo();Pt(()=>{if(!n)return;const f=[];for(const[w,I]of Object.entries(n))I.render&&f.push(h(w,I.render));const p=Object.entries(n).reduce((w,[I,P])=>{const{render:C,...A}=P;return w[I]=A,w},{}),m={getModelContext:()=>({tools:p})};return f.push(a.register(m)),()=>{f.forEach(w=>w())}},[n,a]);const h=(f,p)=>(r(m=>({...m,tools:{...m.tools,[f]:[...m.tools[f]??[],p]}})),()=>{r(m=>{var w;return{...m,tools:{...m.tools,[f]:((w=m.tools[f])==null?void 0:w.filter(I=>I!==p))??[]}}})});return ue({getState:()=>i,setToolUI:h})}),Bh=lt(()=>rt(()=>{const i=new Map;return{on:(r,a)=>{i.has(r)||i.set(r,new Set);const h=i.get(r);return h.add(a),()=>{h.delete(a),h.size===0&&i.delete(r)}},emit:(r,a)=>{const h=i.get(r),f=i.get("*");!h&&!f||queueMicrotask(()=>{if(h)for(const p of h)p(a);if(f)for(const p of f)p({event:r,payload:a})})}}},[])),xo=bo(null),kh=(n,i)=>mo(xo,n,i),ps=()=>{const n=vo(xo);if(!n)throw new Error("Events context is not available");return n},Dh=lt(()=>{const[n]=ae(()=>({})),i=new Hi;return ue({getState:()=>n,getModelContext:()=>i.getModelContext(),subscribe:r=>i.subscribe(r),register:r=>i.registerModelContextProvider(r)})}),Nh=lt(({threads:n,modelContext:i,tools:r})=>{const a=Zt(Bh()),{threads:h,tools:f,modelContext:p}=kh(a,()=>{const w=ls(i??Dh(),[i]);return Oh(w.api,()=>({modelContext:w,tools:ls(r??Lh({}),[r]),threads:ls(n,[n])}))}),m=rt(()=>({threads:h.state,tools:f.state,modelContext:p.state}),[h.state,f.state,p.state]);return ue({getState:()=>m,threads:h.api,tools:f.api,modelContext:p.api,on:a.on})}),Fh=n=>{const i=()=>n.getState().api.threads.item("main");return{threads:yt({source:"root",query:{},get:()=>n.getState().api.threads}),tools:yt({source:"root",query:{},get:()=>n.getState().api.tools}),modelContext:yt({source:"root",query:{},get:()=>n.getState().api.modelContext}),thread:yt({source:"threads",query:{type:"main"},get:()=>n.getState().api.threads.thread("main")}),threadListItem:yt({source:"threads",query:{type:"main"},get:()=>i()}),composer:yt({source:"thread",query:{},get:()=>n.getState().api.threads.thread("main").composer}),on(r,a){const{event:h,scope:f}=_o(r);if(f==="*")return n.getState().api.on(h,a);if(cs("thread",f)||cs("thread-list-item",f)||cs("composer",f))return n.getState().api.on(h,p=>{p.threadId===i().getState().id&&a(p)});throw new Error(`Event scope is not available in this component: ${f}`)},subscribe:n.subscribe,flushSync:n.flushSync}},Uh=n=>{const i=Ao(),r=ph(Mh(Nh(n))),a=B.useMemo(()=>Fh(r),[r]);return B.useMemo(()=>Hh(i,a),[i,a])},yt=n=>{const i=n.get;return i.source=n.source,i.query=n.query,i},xe=()=>()=>{},To=B.createContext({threads:yt({source:null,query:{},get:()=>{throw new Error("Threads is only available inside <AssistantProvider />")}}),tools:yt({source:null,query:{},get:()=>{throw new Error("Tools is only available inside <AssistantProvider />")}}),modelContext:yt({source:null,query:{},get:()=>{throw new Error("ModelContext is only available inside <AssistantProvider />")}}),threadListItem:yt({source:null,query:{},get:()=>{throw new Error("ThreadListItem is only available inside <AssistantProvider />")}}),thread:yt({source:null,query:{},get:()=>{throw new Error("Thread is only available inside <AssistantProvider />")}}),composer:yt({source:null,query:{},get:()=>{throw new Error("Composer is only available inside <AssistantProvider />")}}),message:yt({source:null,query:{},get:()=>{throw new Error("Message is only available inside <ThreadPrimitive.Messages />")}}),part:yt({source:null,query:{},get:()=>{throw new Error("Part is only available inside <MessagePrimitive.Parts />")}}),attachment:yt({source:null,query:{},get:()=>{throw new Error("Attachment is only available inside <MessagePrimitive.Attachments /> or <ComposerPrimitive.Attachments />")}}),subscribe:xe,flushSync:xe,on:n=>{const{scope:i}=_o(n);throw new Error(`Event scope is not available in this component: ${i}`)}}),Ao=()=>B.useContext(To),Wh=n=>Uh(n);function $h(n){return n?Wh(n):Ao()}var qh=(n,i)=>n===xe?i:i===xe?n:(...r)=>{n(...r),i(...r)},zh=(n,i)=>n===xe?i:i===xe?n:(...r)=>{const a=n(...r),h=i(...r);return()=>{a(),h()}},Hh=(n,i)=>{const r=i.subscribe,a=i.flushSync;return{...n,...i,subscribe:zh(n.subscribe,r??xe),flushSync:qh(n.flushSync,a??xe)}},Jh=({api:n,children:i,devToolsVisible:r=!0})=>(B.useEffect(()=>{if(!(!r||!n.subscribe))return gh.register(n)},[n,r]),Ee.jsx(To.Provider,{value:n,children:i}));function Gh(n,i){function r(a){const h=B.useContext(n);if(!(a!=null&&a.optional)&&!h)throw new Error(`This component must be used within ${i}.`);return h}return r}function Kh(n,i){function r(h){const f=n(h);return f?f[i]:null}function a(h){let f=!1,p;typeof h=="function"?p=h:h&&typeof h=="object"&&(f=!!h.optional,p=h.selector);const m=r({optional:f});return m?p?m(p):m():null}return{[i]:a,[`${i}Store`]:r}}var Co=B.createContext(null),Yh=Gh(Co,"ThreadPrimitive.Viewport"),{useThreadViewportStore:Vh}=Kh(Yh,"useThreadViewport"),Ne=n=>{const[,i]=ae(n.getState);return Pt(()=>(i(n.getState()),n.subscribe(()=>{i(n.getState())})),[n]),n.getState()},Zh=lt(({runtime:n})=>{const i=Ne(n),r=ps();return Pt(()=>{const a=[],h=["switched-to","switched-away"];for(const f of h){const p=n.unstable_on(f,()=>{r.emit(`thread-list-item.${f}`,{threadId:n.getState().id})});a.push(p)}return()=>{for(const f of a)f()}},[n,r]),ue({getState:()=>i,switchTo:n.switchTo,rename:n.rename,archive:n.archive,unarchive:n.unarchive,delete:n.delete,generateTitle:n.generateTitle,initialize:n.initialize,detach:n.detach,__internal_getRuntime:()=>n},{key:i.id})}),An=n=>{const i=wh(n);return{state:i.map(r=>r.state),api:r=>{var h,f;const a="index"in r?(h=i[r.index])==null?void 0:h.api:(f=i.find(p=>p.key===r.key))==null?void 0:f.api;if(!a)throw new Error(`tapLookupResources: Resource not found for lookup: ${JSON.stringify(r)}`);return a}}},Io=lt(({runtime:n})=>{const i=Ne(n);return ue({getState:()=>i,remove:n.remove,__internal_getRuntime:()=>n},{key:i.id})}),Xh=lt(({runtime:n,index:i})=>{const r=rt(()=>n.getAttachmentByIndex(i),[n,i]);return Zt(Io({runtime:r}))}),Ro=lt(({threadIdRef:n,messageIdRef:i,runtime:r})=>{const a=Ne(r),h=ps();Pt(()=>{const m=[],w=["send","attachment-add"];for(const I of w){const P=r.unstable_on(I,()=>{h.emit(`composer.${I}`,{threadId:n.current,...i&&{messageId:i.current}})});m.push(P)}return()=>{for(const I of m)I()}},[r,h,n,i]);const f=An(a.attachments.map((m,w)=>Xh({runtime:r,index:w},{key:w}))),p=rt(()=>({text:a.text,role:a.role,attachments:f.state,runConfig:a.runConfig,isEditing:a.isEditing,canCancel:a.canCancel,attachmentAccept:a.attachmentAccept,isEmpty:a.isEmpty,type:a.type??"thread"}),[a,f.state]);return ue({getState:()=>p,setText:r.setText,setRole:r.setRole,setRunConfig:r.setRunConfig,addAttachment:r.addAttachment,reset:r.reset,clearAttachments:r.clearAttachments,send:r.send,cancel:r.cancel,beginEdit:r.beginEdit??(()=>{throw new Error("beginEdit is not supported in this runtime")}),attachment:m=>"id"in m?f.api({key:m.id}):f.api(m),__internal_getRuntime:()=>r})}),Qh=lt(({runtime:n})=>{const i=Ne(n);return ue({getState:()=>i,addToolResult:a=>n.addToolResult(a),resumeToolCall:a=>n.resumeToolCall(a),__internal_getRuntime:()=>n},{key:i.type==="tool-call"?`toolCallId-${i.toolCallId}`:void 0})}),jh=lt(({runtime:n,index:i})=>{const r=rt(()=>n.getAttachmentByIndex(i),[n,i]);return Zt(Io({runtime:r}))}),tl=lt(({runtime:n,index:i})=>{const r=rt(()=>n.getMessagePartByIndex(i),[n,i]);return Zt(Qh({runtime:r}))}),el=lt(({runtime:n,threadIdRef:i})=>{var A;const r=Ne(n),[a,h]=ae(!1),[f,p]=ae(!1),m=rt(()=>({get current(){return n.getState().id}}),[n]),w=Zt(Ro({runtime:n.composer,threadIdRef:i,messageIdRef:m})),I=An(r.content.map((R,K)=>tl({runtime:n,index:K},{key:K}))),P=An(((A=r.attachments)==null?void 0:A.map((R,K)=>jh({runtime:n,index:K},{key:K})))??[]),C=rt(()=>({...r,parts:I.state,composer:w.state,isCopied:a,isHovering:f}),[r,I.state,w.state,a,f]);return ue({getState:()=>C,composer:w.api,reload:R=>n.reload(R),speak:()=>n.speak(),stopSpeaking:()=>n.stopSpeaking(),submitFeedback:R=>n.submitFeedback(R),switchToBranch:R=>n.switchToBranch(R),getCopyText:()=>n.unstable_getCopyText(),part:R=>"index"in R?I.api({index:R.index}):I.api({key:`toolCallId-${R.toolCallId}`}),attachment:R=>"id"in R?P.api({key:R.id}):P.api(R),setIsCopied:h,setIsHovering:p,__internal_getRuntime:()=>n},{key:r.id})}),nl=lt(({runtime:n,id:i,threadIdRef:r})=>{const a=rt(()=>n.getMessageById(i),[n,i]);return Zt(el({runtime:a,threadIdRef:r}))}),rl=lt(({runtime:n})=>{const i=Ne(n),r=ps();Pt(()=>{const m=[],w=["run-start","run-end","initialize","model-context-update"];for(const I of w){const P=n.unstable_on(I,()=>{var A;const C=((A=n.getState())==null?void 0:A.threadId)||"unknown";r.emit(`thread.${I}`,{threadId:C})});m.push(P)}return()=>{for(const I of m)I()}},[n]);const a=rt(()=>({get current(){return n.getState().threadId}}),[n]),h=Zt(Ro({runtime:n.composer,threadIdRef:a})),f=An(i.messages.map(m=>nl({runtime:n,id:m.id,threadIdRef:a},{key:m.id}))),p=rt(()=>({isDisabled:i.isDisabled,isLoading:i.isLoading,isRunning:i.isRunning,capabilities:i.capabilities,state:i.state,suggestions:i.suggestions,extras:i.extras,speech:i.speech,composer:h.state,messages:f.state}),[i,f,h.state]);return ue({getState:()=>p,composer:h.api,append:n.append,startRun:n.startRun,unstable_resumeRun:n.unstable_resumeRun,cancelRun:n.cancelRun,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,startVoice:async()=>{throw new Error("startVoice is not supported in this runtime")},stopVoice:async()=>{throw new Error("stopVoice is not supported in this runtime")},message:m=>"id"in m?f.api({key:m.id}):f.api(m),__internal_getRuntime:()=>n})}),sl=lt(({runtime:n,id:i})=>{const r=rt(()=>n.getItemById(i),[n,i]);return Zt(Zh({runtime:r}))}),il=lt(({runtime:n,__internal_assistantRuntime:i})=>{const r=Ne(n),a=Zt(rl({runtime:n.main})),h=An(Object.keys(r.threadItems).map(p=>sl({runtime:n,id:p},{key:p}))),f=rt(()=>({mainThreadId:r.mainThreadId,newThreadId:r.newThread??null,isLoading:r.isLoading,threadIds:r.threads,archivedThreadIds:r.archivedThreads,threadItems:h.state,main:a.state}),[r,h.state,a.state]);return ue({getState:()=>f,thread:()=>a.api,item:p=>{if(p==="main")return h.api({key:f.mainThreadId});if("id"in p)return h.api({key:p.id});const{index:m,archived:w=!1}=p,I=w?f.archivedThreadIds[m]:f.threadIds[m];return h.api({key:I})},switchToThread:p=>{n.switchToThread(p)},switchToNewThread:()=>{n.switchToNewThread()},__internal_getAssistantRuntime:()=>i})}),ol=lt(n=>{const i=Eo();return Pt(()=>n.registerModelContextProvider(i),[n,i]),Zt(il({runtime:n.threads,__internal_assistantRuntime:n}))}),gs=n=>{const i=new Map,r=()=>{let a=0;for(const h of i.values())a+=h;n(a)};return{register:()=>{const a=Symbol();return i.set(a,0),{setHeight:h=>{i.get(a)!==h&&(i.set(a,h),r())},unregister:()=>{i.delete(a),r()}}}}},al=(n={})=>{const i=new Set,r=gs(p=>{f.setState({height:{...f.getState().height,viewport:p}})}),a=gs(p=>{f.setState({height:{...f.getState().height,inset:p}})}),h=gs(p=>{f.setState({height:{...f.getState().height,userMessage:p}})}),f=Rh(()=>({isAtBottom:!0,scrollToBottom:({behavior:p="auto"}={})=>{for(const m of i)m({behavior:p})},onScrollToBottom:p=>(i.add(p),()=>{i.delete(p)}),turnAnchor:n.turnAnchor??"bottom",height:{viewport:0,inset:0,userMessage:0},registerViewport:r.register,registerContentInset:a.register,registerUserMessageHeight:h.register}));return f},Mo=n=>n,ul=n=>{const i=Vh({optional:!0}),[r]=B.useState(()=>al(n));return B.useEffect(()=>i==null?void 0:i.getState().onScrollToBottom(()=>{r.getState().scrollToBottom()}),[i,r]),B.useEffect(()=>{if(i)return r.subscribe(a=>{i.getState().isAtBottom!==a.isAtBottom&&Mo(i).setState({isAtBottom:a.isAtBottom})})},[r,i]),B.useEffect(()=>{const a={turnAnchor:n.turnAnchor??"bottom"};r.getState().turnAnchor!==a.turnAnchor&&Mo(r).setState(a)},[r,n.turnAnchor]),r},cl=({children:n,options:i={}})=>{const r=ul(i),[a]=B.useState(()=>({useThreadViewport:r}));return Ee.jsx(Co.Provider,{value:a,children:n})},hl=n=>{var i;return(i=n._core)==null?void 0:i.RenderComponent},ll=({children:n,runtime:i})=>{const r=$h({threads:ol(i)}),a=hl(i);return Ee.jsxs(Jh,{api:r,children:[a&&Ee.jsx(a,{}),Ee.jsx(cl,{children:n})]})},fl=B.memo(ll),dl=class{constructor(n){S(this,"threads");S(this,"_thread");this._core=n,this.threads=new Yc(n.threads),this._thread=this.threads.main,this.__internal_bindMethods()}get threadList(){return this.threads}__internal_bindMethods(){this.switchToNewThread=this.switchToNewThread.bind(this),this.switchToThread=this.switchToThread.bind(this),this.registerModelContextProvider=this.registerModelContextProvider.bind(this),this.registerModelConfigProvider=this.registerModelConfigProvider.bind(this),this.reset=this.reset.bind(this)}get thread(){return this._thread}switchToNewThread(){return this._core.threads.switchToNewThread()}switchToThread(n){return this._core.threads.switchToThread(n)}registerModelContextProvider(n){return this._core.registerModelContextProvider(n)}registerModelConfigProvider(n){return this.registerModelContextProvider(n)}reset({initialMessages:n}={}){return this._core.threads.getMainThreadRuntimeCore().import(is.fromArray(n??[]))}};function pl(n){return n.filter(i=>i.finishReason==="stop"?i.text!==null&&i.text.trim()!=="":!0)}function Po(n){const i=[];let r=null;for(const h of n)if(h.type!=="transaction")if(h.file){r&&(i.push(r),r=null),i.push(h);continue}else h.functionCalls?(r&&i.push(r),i.push(h),r=null):h.functionResponse?i[i.length-1]={...i[i.length-1],functionResponse:h.functionResponse}:r&&h.type===r.type&&h.protocol===r.protocol&&r.role===h.role?(r.text+=h.text,r.file=r.file||h.file):(r&&i.push(r),r={...h,text:h.file?"":h.text,finishReason:h.file?void 0:h.finishReason});return r&&i.push(r),pl(i)}function gl(n){var r;const i=n.file?[{type:"file",data:n.file.url,mimeType:n.file.contentType}]:[];return n.role==="function"?{id:n.id,role:"assistant",status:(n==null?void 0:n.functionResponse)===null?{type:"running"}:{type:"complete",reason:"stop"},content:((r=n.functionCalls)==null?void 0:r.map(a=>{var h;return{type:"tool-call",toolName:a.name,toolCallId:a.id,args:a.args,result:(h=n.functionResponse)==null?void 0:h.result}}))??[]}:{id:n.id,role:n.role,content:n.type==="reasoning"?[{type:"reasoning",text:n.text},...i]:[{type:"text",text:n.text},...i]}}class Cn{constructor(){S(this,"statusChangeCallbacks",[]);S(this,"messageCallbacks",[])}addStatusChangeListener(i){this.statusChangeCallbacks.push(i)}addPacketListener(i){this.messageCallbacks.push(i)}async syncSession(i){this.session=i}async notifyPacket(i){this.messageCallbacks.forEach(r=>r(i))}async notifyPackets(i){i.forEach(r=>{this.messageCallbacks.forEach(a=>a(r))})}async setSession(i){this.session=i}async setStatus(i){const r=this.status!==i;this.status=i,r&&this.statusChangeCallbacks.forEach(a=>a(i))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}onTransaction(i){}}class _s extends Cn{constructor(r){super();S(this,"status");S(this,"autostart");S(this,"session");S(this,"config");S(this,"notify",!0);S(this,"context",{});S(this,"tools",[]);this.config=r,this.status="disconnected",this.autostart=!0}getName(){return"rest"}getPriority(){return 100}async connect(r){return this.setStatus("connected"),r}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(r){this.session=r}async sendPacket(r){var w,I,P,C,A;const{apiUrl:a,apiKey:h,agentId:f}=this.config,p=this.session??"new";if(r.type==="command"&&((w=r==null?void 0:r.payload)==null?void 0:w.command)=="set_initial_context"){this.context=(I=r==null?void 0:r.payload)==null?void 0:I.arguments;return}else if(r.type==="command"&&((P=r==null?void 0:r.payload)==null?void 0:P.command)=="set_local_tools"){const R=(C=r==null?void 0:r.payload)==null?void 0:C.arguments.tools;(R==null?void 0:R.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const m=r.payload;try{const K=await(await fetch(`${a}/sessions/${p}/messages`,{body:JSON.stringify({agentId:f,userMessage:m,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":h}})).json();this.notifyPackets(K.response.messages.map(At=>({type:"message",payload:At})))}catch(R){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(A=this.config.logger)==null||A.error("Error sending packet:",R)}}}class bs extends Cn{constructor(r){super();S(this,"status");S(this,"autostart");S(this,"session");S(this,"config");S(this,"webSocket");this.config=r,this.status="disconnected",this.autostart=!0,this.session=null,this.webSocket=null}getName(){return"websocket"}getPriority(){return 500}async syncSession(r){var a;(a=this.config.logger)==null||a.debug("Syncing session with WebSocket protocol:",r),this.session=r,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(r))}connect(r){var m;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const a=r||this.session||"new";(m=this.config.logger)==null||m.debug("Connecting to WebSocket with sessionId:",a);const h=encodeURIComponent(this.config.apiKey),f=this.config.agentId,p=`${this.config.webSocketUrl}?sessionCode=${a}&agentId=${f}&apiKey=${h}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(p),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",w=>{const I=JSON.parse(w.data);this.notifyPacket(I)}),this.webSocket.addEventListener("close",w=>{var I;this.setStatus("disconnected"),this.webSocket=null,w.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(I=this.config.logger)==null||I.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var w;this.setStatus("disconnected"),this.webSocket=null,(w=this.config.logger)==null||w.error("WebSocket connection error")}),Promise.resolve(a)}disconnect(){var r;return(r=this.config.logger)==null||r.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(r){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(r)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class _l{constructor(i){S(this,"config");S(this,"pc",null);S(this,"ws",null);S(this,"localStream",null);S(this,"remoteStream",new MediaStream);S(this,"audioCtx",null);S(this,"localAnalyser",null);S(this,"remoteAnalyser",null);S(this,"analyzerFrame",null);S(this,"dataChannel",null);S(this,"isConnected",!1);S(this,"visualizerCallbacks",[]);S(this,"messageCallbacks",[]);S(this,"errorCallbacks",[]);S(this,"queuedMessages",[]);this.config=i}async connect(i){var a;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(h){(a=this.config.logger)==null||a.error("Error accessing microphone:",h);return}this.pc=new RTCPeerConnection({iceServers:this.config.iceServers||[{urls:"stun:34.38.108.251:3478"},{urls:"turn:34.38.108.251:3478",username:"webrtc",credential:"webrtc"}]}),this.localStream.getTracks().forEach(h=>{this.pc.addTrack(h,this.localStream)}),this.pc.ontrack=h=>{h.streams[0].getTracks().forEach(p=>{this.remoteStream.addTrack(p)}),this.audioCtx||this._startAnalyzers();const f=new Audio;f.srcObject=this.remoteStream,f.play().catch(p=>{var m;(m=this.config.logger)==null||m.error("Error playing remote audio:",p)})},this.pc.onicecandidate=h=>{var f;h.candidate&&((f=this.ws)==null?void 0:f.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:h.candidate}}))},this.pc.ondatachannel=h=>{const f=h.channel;f.onmessage=p=>{this.messageCallbacks.forEach(m=>{m(p)})},f.onopen=()=>{var p;for(;this.queuedMessages.length>0;){const m=this.queuedMessages.shift();m&&(f.send(JSON.stringify(m)),(p=this.config.logger)==null||p.info("Sent queued message:",m))}}};const r=this.config.webrtcUrl||"wss://persona.applica.guru/api/webrtc";this.ws=new WebSocket(`${r}?apiKey=${encodeURIComponent(this.config.apiKey)}`),this.ws.onopen=async()=>{var m,w;const h=await this.pc.createOffer();await this.pc.setLocalDescription(h);const f={apiKey:this.config.apiKey,agentId:this.config.agentId,sessionCode:i};(m=this.config.logger)==null||m.debug("Opening connection to WebRTC server: ",f);const p={type:"OFFER",src:((w=crypto.randomUUID)==null?void 0:w.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:h.sdp,type:h.type},connectionId:(Date.now()%1e6).toString(),metadata:f}};this.ws.send(JSON.stringify(p))},this.ws.onmessage=async h=>{var p;const f=JSON.parse(h.data);if(f.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(f.payload.sdp));else if(f.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(f.payload.candidate))}catch(m){(p=this.config.logger)==null||p.error("Error adding ICE candidate:",m)}},this.ws.onclose=h=>{h.code!==1e3&&this.errorCallbacks.forEach(f=>{f("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var i;this.isConnected&&(this.isConnected=!1,((i=this.ws)==null?void 0:i.readyState)===WebSocket.OPEN&&this.ws.close(),this.pc&&this.pc.close(),this.localStream&&this.localStream.getTracks().forEach(r=>r.stop()),this.remoteStream=new MediaStream,this.audioCtx&&(await this.audioCtx.close(),this.audioCtx=null),this._stopAnalyzers())}addVisualizerCallback(i){this.visualizerCallbacks.push(i)}addMessageCallback(i){this.messageCallbacks.push(i)}addErrorCallback(i){this.errorCallbacks.push(i)}createDataChannel(i="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(i),this.dataChannel.onopen=()=>{var r,a;for((r=this.config.logger)==null||r.info("Data channel opened");this.queuedMessages.length>0;){const h=this.queuedMessages.shift();h&&(this.dataChannel.send(JSON.stringify(h)),(a=this.config.logger)==null||a.info("Sent queued message:",h))}},this.dataChannel.onmessage=r=>{this.messageCallbacks.forEach(a=>{a(r)})})}sendPacket(i){var r;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(i);return}this.dataChannel.send(JSON.stringify(i)),(r=this.config.logger)==null||r.info("Sent message:",i)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const i=this.audioCtx.createMediaStreamSource(this.localStream),r=this.audioCtx.createMediaStreamSource(this.remoteStream);this.localAnalyser=this.audioCtx.createAnalyser(),this.remoteAnalyser=this.audioCtx.createAnalyser(),this.localAnalyser.fftSize=256,this.remoteAnalyser.fftSize=256,i.connect(this.localAnalyser),r.connect(this.remoteAnalyser);const a=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const h=new Uint8Array(this.localAnalyser.frequencyBinCount),f=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(h),this.remoteAnalyser.getByteFrequencyData(f);const p=h.reduce((w,I)=>w+I,0)/h.length,m=f.reduce((w,I)=>w+I,0)/f.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(w=>{w({localAmplitude:p,remoteAmplitude:m})}),this.analyzerFrame=requestAnimationFrame(a)};this.analyzerFrame=requestAnimationFrame(a)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class ms extends Cn{constructor(r){super();S(this,"status");S(this,"session");S(this,"autostart");S(this,"config");S(this,"webRTCClient");this.config=r,this.status="disconnected",this.session=null,this.autostart=(r==null?void 0:r.autostart)??!1,this.webRTCClient=new _l(r),this.webRTCClient.addMessageCallback(a=>{const h=JSON.parse(a.data);this.notifyPacket(h)}),this.webRTCClient.addErrorCallback(a=>{var h;(h=this.config.logger)==null||h.error("WebRTC error:",a),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:a}})})}getName(){return"webrtc"}getPriority(){return 1e3}async syncSession(r){super.syncSession(r),this.status==="connected"&&(await this.disconnect(),await this.connect(r))}async connect(r){var a;return this.status==="connected"?Promise.resolve(this.session):(this.session=r||this.session||"new",this.setStatus("connecting"),(a=this.config.logger)==null||a.debug("Connecting to WebRTC with sessionId:",this.session),await this.webRTCClient.connect(this.session),this.setStatus("connected"),await this.webRTCClient.createDataChannel(),this.session)}async disconnect(){var r,a,h;if(this.status==="disconnected")return(r=this.config.logger)==null||r.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(h=(a=this.config)==null?void 0:a.logger)==null||h.debug("Disconnected from WebRTC")}sendPacket(r){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(r),Promise.resolve())}}var ir={exports:{}};/**
10
14
  * @license
11
15
  * Lodash <https://lodash.com/>
12
16
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
13
17
  * Released under MIT license <https://lodash.com/license>
14
18
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
15
19
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
16
- */be.exports,function(y,p){(function(){var i,w="4.17.21",m=200,C="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",b="Expected a function",I="Invalid `variable` option passed into `_.template`",$="__lodash_hash_undefined__",rn=500,bn="__lodash_placeholder__",un=1,Rn=2,pn=4,Tn=1,gt=2,mn=1,yn=2,Te=4,zn=8,bt=16,Hn=32,Rt=64,F=128,en=256,H=512,Mn=30,sn="...",Fn=800,V=16,dn=1,jo=2,na=3,Tt=1/0,pt=9007199254740991,ta=17976931348623157e292,Pe=NaN,Vn=4294967295,ea=Vn-1,ra=Vn>>>1,ia=[["ary",F],["bind",mn],["bindKey",yn],["curry",zn],["curryRight",bt],["flip",H],["partial",Hn],["partialRight",Rt],["rearg",en]],Dt="[object Arguments]",Ee="[object Array]",ua="[object AsyncFunction]",re="[object Boolean]",ie="[object Date]",sa="[object DOMException]",Ie="[object Error]",Le="[object Function]",ji="[object GeneratorFunction]",Kn="[object Map]",ue="[object Number]",oa="[object Null]",rt="[object Object]",nu="[object Promise]",aa="[object Proxy]",se="[object RegExp]",Jn="[object Set]",oe="[object String]",Oe="[object Symbol]",fa="[object Undefined]",ae="[object WeakMap]",la="[object WeakSet]",fe="[object ArrayBuffer]",Nt="[object DataView]",br="[object Float32Array]",Rr="[object Float64Array]",Tr="[object Int8Array]",Pr="[object Int16Array]",Er="[object Int32Array]",Ir="[object Uint8Array]",Lr="[object Uint8ClampedArray]",Or="[object Uint16Array]",Wr="[object Uint32Array]",ca=/\b__p \+= '';/g,ha=/\b(__p \+=) '' \+/g,ga=/(__e\(.*?\)|\b__t\)) \+\n'';/g,tu=/&(?:amp|lt|gt|quot|#39);/g,eu=/[&<>"']/g,pa=RegExp(tu.source),da=RegExp(eu.source),_a=/<%-([\s\S]+?)%>/g,va=/<%([\s\S]+?)%>/g,ru=/<%=([\s\S]+?)%>/g,wa=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ma=/^\w*$/,ya=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Mr=/[\\^$.*+?()[\]{}|]/g,xa=RegExp(Mr.source),Fr=/^\s+/,Sa=/\s/,Aa=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ca=/\{\n\/\* \[wrapped with (.+)\] \*/,ba=/,? & /,Ra=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ta=/[()=,{}\[\]\/\s]/,Pa=/\\(\\)?/g,Ea=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,iu=/\w*$/,Ia=/^[-+]0x[0-9a-f]+$/i,La=/^0b[01]+$/i,Oa=/^\[object .+?Constructor\]$/,Wa=/^0o[0-7]+$/i,Ma=/^(?:0|[1-9]\d*)$/,Fa=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,We=/($^)/,Ua=/['\n\r\u2028\u2029\\]/g,Me="\\ud800-\\udfff",Da="\\u0300-\\u036f",Na="\\ufe20-\\ufe2f",Ba="\\u20d0-\\u20ff",uu=Da+Na+Ba,su="\\u2700-\\u27bf",ou="a-z\\xdf-\\xf6\\xf8-\\xff",Ga="\\xac\\xb1\\xd7\\xf7",ka="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",$a="\\u2000-\\u206f",qa=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",au="A-Z\\xc0-\\xd6\\xd8-\\xde",fu="\\ufe0e\\ufe0f",lu=Ga+ka+$a+qa,Ur="['’]",za="["+Me+"]",cu="["+lu+"]",Fe="["+uu+"]",hu="\\d+",Ha="["+su+"]",gu="["+ou+"]",pu="[^"+Me+lu+hu+su+ou+au+"]",Dr="\\ud83c[\\udffb-\\udfff]",Ka="(?:"+Fe+"|"+Dr+")",du="[^"+Me+"]",Nr="(?:\\ud83c[\\udde6-\\uddff]){2}",Br="[\\ud800-\\udbff][\\udc00-\\udfff]",Bt="["+au+"]",_u="\\u200d",vu="(?:"+gu+"|"+pu+")",Ja="(?:"+Bt+"|"+pu+")",wu="(?:"+Ur+"(?:d|ll|m|re|s|t|ve))?",mu="(?:"+Ur+"(?:D|LL|M|RE|S|T|VE))?",yu=Ka+"?",xu="["+fu+"]?",Ya="(?:"+_u+"(?:"+[du,Nr,Br].join("|")+")"+xu+yu+")*",Za="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Xa="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Su=xu+yu+Ya,Qa="(?:"+[Ha,Nr,Br].join("|")+")"+Su,Va="(?:"+[du+Fe+"?",Fe,Nr,Br,za].join("|")+")",ja=RegExp(Ur,"g"),nf=RegExp(Fe,"g"),Gr=RegExp(Dr+"(?="+Dr+")|"+Va+Su,"g"),tf=RegExp([Bt+"?"+gu+"+"+wu+"(?="+[cu,Bt,"$"].join("|")+")",Ja+"+"+mu+"(?="+[cu,Bt+vu,"$"].join("|")+")",Bt+"?"+vu+"+"+wu,Bt+"+"+mu,Xa,Za,hu,Qa].join("|"),"g"),ef=RegExp("["+_u+Me+uu+fu+"]"),rf=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,uf=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],sf=-1,Z={};Z[br]=Z[Rr]=Z[Tr]=Z[Pr]=Z[Er]=Z[Ir]=Z[Lr]=Z[Or]=Z[Wr]=!0,Z[Dt]=Z[Ee]=Z[fe]=Z[re]=Z[Nt]=Z[ie]=Z[Ie]=Z[Le]=Z[Kn]=Z[ue]=Z[rt]=Z[se]=Z[Jn]=Z[oe]=Z[ae]=!1;var Y={};Y[Dt]=Y[Ee]=Y[fe]=Y[Nt]=Y[re]=Y[ie]=Y[br]=Y[Rr]=Y[Tr]=Y[Pr]=Y[Er]=Y[Kn]=Y[ue]=Y[rt]=Y[se]=Y[Jn]=Y[oe]=Y[Oe]=Y[Ir]=Y[Lr]=Y[Or]=Y[Wr]=!0,Y[Ie]=Y[Le]=Y[ae]=!1;var of={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},af={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ff={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},lf={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},cf=parseFloat,hf=parseInt,Au=typeof jt=="object"&&jt&&jt.Object===Object&&jt,gf=typeof self=="object"&&self&&self.Object===Object&&self,ln=Au||gf||Function("return this")(),kr=p&&!p.nodeType&&p,Pt=kr&&!0&&y&&!y.nodeType&&y,Cu=Pt&&Pt.exports===kr,$r=Cu&&Au.process,Un=function(){try{var l=Pt&&Pt.require&&Pt.require("util").types;return l||$r&&$r.binding&&$r.binding("util")}catch{}}(),bu=Un&&Un.isArrayBuffer,Ru=Un&&Un.isDate,Tu=Un&&Un.isMap,Pu=Un&&Un.isRegExp,Eu=Un&&Un.isSet,Iu=Un&&Un.isTypedArray;function Pn(l,g,h){switch(h.length){case 0:return l.call(g);case 1:return l.call(g,h[0]);case 2:return l.call(g,h[0],h[1]);case 3:return l.call(g,h[0],h[1],h[2])}return l.apply(g,h)}function pf(l,g,h,S){for(var L=-1,k=l==null?0:l.length;++L<k;){var on=l[L];g(S,on,h(on),l)}return S}function Dn(l,g){for(var h=-1,S=l==null?0:l.length;++h<S&&g(l[h],h,l)!==!1;);return l}function df(l,g){for(var h=l==null?0:l.length;h--&&g(l[h],h,l)!==!1;);return l}function Lu(l,g){for(var h=-1,S=l==null?0:l.length;++h<S;)if(!g(l[h],h,l))return!1;return!0}function dt(l,g){for(var h=-1,S=l==null?0:l.length,L=0,k=[];++h<S;){var on=l[h];g(on,h,l)&&(k[L++]=on)}return k}function Ue(l,g){var h=l==null?0:l.length;return!!h&&Gt(l,g,0)>-1}function qr(l,g,h){for(var S=-1,L=l==null?0:l.length;++S<L;)if(h(g,l[S]))return!0;return!1}function X(l,g){for(var h=-1,S=l==null?0:l.length,L=Array(S);++h<S;)L[h]=g(l[h],h,l);return L}function _t(l,g){for(var h=-1,S=g.length,L=l.length;++h<S;)l[L+h]=g[h];return l}function zr(l,g,h,S){var L=-1,k=l==null?0:l.length;for(S&&k&&(h=l[++L]);++L<k;)h=g(h,l[L],L,l);return h}function _f(l,g,h,S){var L=l==null?0:l.length;for(S&&L&&(h=l[--L]);L--;)h=g(h,l[L],L,l);return h}function Hr(l,g){for(var h=-1,S=l==null?0:l.length;++h<S;)if(g(l[h],h,l))return!0;return!1}var vf=Kr("length");function wf(l){return l.split("")}function mf(l){return l.match(Ra)||[]}function Ou(l,g,h){var S;return h(l,function(L,k,on){if(g(L,k,on))return S=k,!1}),S}function De(l,g,h,S){for(var L=l.length,k=h+(S?1:-1);S?k--:++k<L;)if(g(l[k],k,l))return k;return-1}function Gt(l,g,h){return g===g?Lf(l,g,h):De(l,Wu,h)}function yf(l,g,h,S){for(var L=h-1,k=l.length;++L<k;)if(S(l[L],g))return L;return-1}function Wu(l){return l!==l}function Mu(l,g){var h=l==null?0:l.length;return h?Yr(l,g)/h:Pe}function Kr(l){return function(g){return g==null?i:g[l]}}function Jr(l){return function(g){return l==null?i:l[g]}}function Fu(l,g,h,S,L){return L(l,function(k,on,J){h=S?(S=!1,k):g(h,k,on,J)}),h}function xf(l,g){var h=l.length;for(l.sort(g);h--;)l[h]=l[h].value;return l}function Yr(l,g){for(var h,S=-1,L=l.length;++S<L;){var k=g(l[S]);k!==i&&(h=h===i?k:h+k)}return h}function Zr(l,g){for(var h=-1,S=Array(l);++h<l;)S[h]=g(h);return S}function Sf(l,g){return X(g,function(h){return[h,l[h]]})}function Uu(l){return l&&l.slice(0,Gu(l)+1).replace(Fr,"")}function En(l){return function(g){return l(g)}}function Xr(l,g){return X(g,function(h){return l[h]})}function le(l,g){return l.has(g)}function Du(l,g){for(var h=-1,S=l.length;++h<S&&Gt(g,l[h],0)>-1;);return h}function Nu(l,g){for(var h=l.length;h--&&Gt(g,l[h],0)>-1;);return h}function Af(l,g){for(var h=l.length,S=0;h--;)l[h]===g&&++S;return S}var Cf=Jr(of),bf=Jr(af);function Rf(l){return"\\"+lf[l]}function Tf(l,g){return l==null?i:l[g]}function kt(l){return ef.test(l)}function Pf(l){return rf.test(l)}function Ef(l){for(var g,h=[];!(g=l.next()).done;)h.push(g.value);return h}function Qr(l){var g=-1,h=Array(l.size);return l.forEach(function(S,L){h[++g]=[L,S]}),h}function Bu(l,g){return function(h){return l(g(h))}}function vt(l,g){for(var h=-1,S=l.length,L=0,k=[];++h<S;){var on=l[h];(on===g||on===bn)&&(l[h]=bn,k[L++]=h)}return k}function Ne(l){var g=-1,h=Array(l.size);return l.forEach(function(S){h[++g]=S}),h}function If(l){var g=-1,h=Array(l.size);return l.forEach(function(S){h[++g]=[S,S]}),h}function Lf(l,g,h){for(var S=h-1,L=l.length;++S<L;)if(l[S]===g)return S;return-1}function Of(l,g,h){for(var S=h+1;S--;)if(l[S]===g)return S;return S}function $t(l){return kt(l)?Mf(l):vf(l)}function Yn(l){return kt(l)?Ff(l):wf(l)}function Gu(l){for(var g=l.length;g--&&Sa.test(l.charAt(g)););return g}var Wf=Jr(ff);function Mf(l){for(var g=Gr.lastIndex=0;Gr.test(l);)++g;return g}function Ff(l){return l.match(Gr)||[]}function Uf(l){return l.match(tf)||[]}var Df=function l(g){g=g==null?ln:qt.defaults(ln.Object(),g,qt.pick(ln,uf));var h=g.Array,S=g.Date,L=g.Error,k=g.Function,on=g.Math,J=g.Object,Vr=g.RegExp,Nf=g.String,Nn=g.TypeError,Be=h.prototype,Bf=k.prototype,zt=J.prototype,Ge=g["__core-js_shared__"],ke=Bf.toString,z=zt.hasOwnProperty,Gf=0,ku=function(){var n=/[^.]+$/.exec(Ge&&Ge.keys&&Ge.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),$e=zt.toString,kf=ke.call(J),$f=ln._,qf=Vr("^"+ke.call(z).replace(Mr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),qe=Cu?g.Buffer:i,wt=g.Symbol,ze=g.Uint8Array,$u=qe?qe.allocUnsafe:i,He=Bu(J.getPrototypeOf,J),qu=J.create,zu=zt.propertyIsEnumerable,Ke=Be.splice,Hu=wt?wt.isConcatSpreadable:i,ce=wt?wt.iterator:i,Et=wt?wt.toStringTag:i,Je=function(){try{var n=Mt(J,"defineProperty");return n({},"",{}),n}catch{}}(),zf=g.clearTimeout!==ln.clearTimeout&&g.clearTimeout,Hf=S&&S.now!==ln.Date.now&&S.now,Kf=g.setTimeout!==ln.setTimeout&&g.setTimeout,Ye=on.ceil,Ze=on.floor,jr=J.getOwnPropertySymbols,Jf=qe?qe.isBuffer:i,Ku=g.isFinite,Yf=Be.join,Zf=Bu(J.keys,J),an=on.max,hn=on.min,Xf=S.now,Qf=g.parseInt,Ju=on.random,Vf=Be.reverse,ni=Mt(g,"DataView"),he=Mt(g,"Map"),ti=Mt(g,"Promise"),Ht=Mt(g,"Set"),ge=Mt(g,"WeakMap"),pe=Mt(J,"create"),Xe=ge&&new ge,Kt={},jf=Ft(ni),nl=Ft(he),tl=Ft(ti),el=Ft(Ht),rl=Ft(ge),Qe=wt?wt.prototype:i,de=Qe?Qe.valueOf:i,Yu=Qe?Qe.toString:i;function s(n){if(j(n)&&!O(n)&&!(n instanceof N)){if(n instanceof Bn)return n;if(z.call(n,"__wrapped__"))return Zs(n)}return new Bn(n)}var Jt=function(){function n(){}return function(t){if(!Q(t))return{};if(qu)return qu(t);n.prototype=t;var e=new n;return n.prototype=i,e}}();function Ve(){}function Bn(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}s.templateSettings={escape:_a,evaluate:va,interpolate:ru,variable:"",imports:{_:s}},s.prototype=Ve.prototype,s.prototype.constructor=s,Bn.prototype=Jt(Ve.prototype),Bn.prototype.constructor=Bn;function N(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Vn,this.__views__=[]}function il(){var n=new N(this.__wrapped__);return n.__actions__=xn(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=xn(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=xn(this.__views__),n}function ul(){if(this.__filtered__){var n=new N(this);n.__dir__=-1,n.__filtered__=!0}else n=this.clone(),n.__dir__*=-1;return n}function sl(){var n=this.__wrapped__.value(),t=this.__dir__,e=O(n),r=t<0,u=e?n.length:0,o=wc(0,u,this.__views__),a=o.start,f=o.end,c=f-a,d=r?f:a-1,_=this.__iteratees__,v=_.length,x=0,A=hn(c,this.__takeCount__);if(!e||!r&&u==c&&A==c)return ws(n,this.__actions__);var T=[];n:for(;c--&&x<A;){d+=t;for(var M=-1,P=n[d];++M<v;){var D=_[M],B=D.iteratee,On=D.type,wn=B(P);if(On==jo)P=wn;else if(!wn){if(On==dn)continue n;break n}}T[x++]=P}return T}N.prototype=Jt(Ve.prototype),N.prototype.constructor=N;function It(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function ol(){this.__data__=pe?pe(null):{},this.size=0}function al(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}function fl(n){var t=this.__data__;if(pe){var e=t[n];return e===$?i:e}return z.call(t,n)?t[n]:i}function ll(n){var t=this.__data__;return pe?t[n]!==i:z.call(t,n)}function cl(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=pe&&t===i?$:t,this}It.prototype.clear=ol,It.prototype.delete=al,It.prototype.get=fl,It.prototype.has=ll,It.prototype.set=cl;function it(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function hl(){this.__data__=[],this.size=0}function gl(n){var t=this.__data__,e=je(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():Ke.call(t,e,1),--this.size,!0}function pl(n){var t=this.__data__,e=je(t,n);return e<0?i:t[e][1]}function dl(n){return je(this.__data__,n)>-1}function _l(n,t){var e=this.__data__,r=je(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}it.prototype.clear=hl,it.prototype.delete=gl,it.prototype.get=pl,it.prototype.has=dl,it.prototype.set=_l;function ut(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function vl(){this.size=0,this.__data__={hash:new It,map:new(he||it),string:new It}}function wl(n){var t=cr(this,n).delete(n);return this.size-=t?1:0,t}function ml(n){return cr(this,n).get(n)}function yl(n){return cr(this,n).has(n)}function xl(n,t){var e=cr(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}ut.prototype.clear=vl,ut.prototype.delete=wl,ut.prototype.get=ml,ut.prototype.has=yl,ut.prototype.set=xl;function Lt(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new ut;++t<e;)this.add(n[t])}function Sl(n){return this.__data__.set(n,$),this}function Al(n){return this.__data__.has(n)}Lt.prototype.add=Lt.prototype.push=Sl,Lt.prototype.has=Al;function Zn(n){var t=this.__data__=new it(n);this.size=t.size}function Cl(){this.__data__=new it,this.size=0}function bl(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}function Rl(n){return this.__data__.get(n)}function Tl(n){return this.__data__.has(n)}function Pl(n,t){var e=this.__data__;if(e instanceof it){var r=e.__data__;if(!he||r.length<m-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new ut(r)}return e.set(n,t),this.size=e.size,this}Zn.prototype.clear=Cl,Zn.prototype.delete=bl,Zn.prototype.get=Rl,Zn.prototype.has=Tl,Zn.prototype.set=Pl;function Zu(n,t){var e=O(n),r=!e&&Ut(n),u=!e&&!r&&At(n),o=!e&&!r&&!u&&Qt(n),a=e||r||u||o,f=a?Zr(n.length,Nf):[],c=f.length;for(var d in n)(t||z.call(n,d))&&!(a&&(d=="length"||u&&(d=="offset"||d=="parent")||o&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||ft(d,c)))&&f.push(d);return f}function Xu(n){var t=n.length;return t?n[hi(0,t-1)]:i}function El(n,t){return hr(xn(n),Ot(t,0,n.length))}function Il(n){return hr(xn(n))}function ei(n,t,e){(e!==i&&!Xn(n[t],e)||e===i&&!(t in n))&&st(n,t,e)}function _e(n,t,e){var r=n[t];(!(z.call(n,t)&&Xn(r,e))||e===i&&!(t in n))&&st(n,t,e)}function je(n,t){for(var e=n.length;e--;)if(Xn(n[e][0],t))return e;return-1}function Ll(n,t,e,r){return mt(n,function(u,o,a){t(r,u,e(u),a)}),r}function Qu(n,t){return n&&nt(t,fn(t),n)}function Ol(n,t){return n&&nt(t,An(t),n)}function st(n,t,e){t=="__proto__"&&Je?Je(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}function ri(n,t){for(var e=-1,r=t.length,u=h(r),o=n==null;++e<r;)u[e]=o?i:Di(n,t[e]);return u}function Ot(n,t,e){return n===n&&(e!==i&&(n=n<=e?n:e),t!==i&&(n=n>=t?n:t)),n}function Gn(n,t,e,r,u,o){var a,f=t&un,c=t&Rn,d=t&pn;if(e&&(a=u?e(n,r,u,o):e(n)),a!==i)return a;if(!Q(n))return n;var _=O(n);if(_){if(a=yc(n),!f)return xn(n,a)}else{var v=gn(n),x=v==Le||v==ji;if(At(n))return xs(n,f);if(v==rt||v==Dt||x&&!u){if(a=c||x?{}:Gs(n),!f)return c?fc(n,Ol(a,n)):ac(n,Qu(a,n))}else{if(!Y[v])return u?n:{};a=xc(n,v,f)}}o||(o=new Zn);var A=o.get(n);if(A)return A;o.set(n,a),_o(n)?n.forEach(function(P){a.add(Gn(P,t,e,P,n,o))}):go(n)&&n.forEach(function(P,D){a.set(D,Gn(P,t,e,D,n,o))});var T=d?c?Ai:Si:c?An:fn,M=_?i:T(n);return Dn(M||n,function(P,D){M&&(D=P,P=n[D]),_e(a,D,Gn(P,t,e,D,n,o))}),a}function Wl(n){var t=fn(n);return function(e){return Vu(e,n,t)}}function Vu(n,t,e){var r=e.length;if(n==null)return!r;for(n=J(n);r--;){var u=e[r],o=t[u],a=n[u];if(a===i&&!(u in n)||!o(a))return!1}return!0}function ju(n,t,e){if(typeof n!="function")throw new Nn(b);return Ae(function(){n.apply(i,e)},t)}function ve(n,t,e,r){var u=-1,o=Ue,a=!0,f=n.length,c=[],d=t.length;if(!f)return c;e&&(t=X(t,En(e))),r?(o=qr,a=!1):t.length>=m&&(o=le,a=!1,t=new Lt(t));n:for(;++u<f;){var _=n[u],v=e==null?_:e(_);if(_=r||_!==0?_:0,a&&v===v){for(var x=d;x--;)if(t[x]===v)continue n;c.push(_)}else o(t,v,r)||c.push(_)}return c}var mt=Rs(jn),ns=Rs(ui,!0);function Ml(n,t){var e=!0;return mt(n,function(r,u,o){return e=!!t(r,u,o),e}),e}function nr(n,t,e){for(var r=-1,u=n.length;++r<u;){var o=n[r],a=t(o);if(a!=null&&(f===i?a===a&&!Ln(a):e(a,f)))var f=a,c=o}return c}function Fl(n,t,e,r){var u=n.length;for(e=W(e),e<0&&(e=-e>u?0:u+e),r=r===i||r>u?u:W(r),r<0&&(r+=u),r=e>r?0:wo(r);e<r;)n[e++]=t;return n}function ts(n,t){var e=[];return mt(n,function(r,u,o){t(r,u,o)&&e.push(r)}),e}function cn(n,t,e,r,u){var o=-1,a=n.length;for(e||(e=Ac),u||(u=[]);++o<a;){var f=n[o];t>0&&e(f)?t>1?cn(f,t-1,e,r,u):_t(u,f):r||(u[u.length]=f)}return u}var ii=Ts(),es=Ts(!0);function jn(n,t){return n&&ii(n,t,fn)}function ui(n,t){return n&&es(n,t,fn)}function tr(n,t){return dt(t,function(e){return lt(n[e])})}function Wt(n,t){t=xt(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[tt(t[e++])];return e&&e==r?n:i}function rs(n,t,e){var r=t(n);return O(n)?r:_t(r,e(n))}function _n(n){return n==null?n===i?fa:oa:Et&&Et in J(n)?vc(n):Ic(n)}function si(n,t){return n>t}function Ul(n,t){return n!=null&&z.call(n,t)}function Dl(n,t){return n!=null&&t in J(n)}function Nl(n,t,e){return n>=hn(t,e)&&n<an(t,e)}function oi(n,t,e){for(var r=e?qr:Ue,u=n[0].length,o=n.length,a=o,f=h(o),c=1/0,d=[];a--;){var _=n[a];a&&t&&(_=X(_,En(t))),c=hn(_.length,c),f[a]=!e&&(t||u>=120&&_.length>=120)?new Lt(a&&_):i}_=n[0];var v=-1,x=f[0];n:for(;++v<u&&d.length<c;){var A=_[v],T=t?t(A):A;if(A=e||A!==0?A:0,!(x?le(x,T):r(d,T,e))){for(a=o;--a;){var M=f[a];if(!(M?le(M,T):r(n[a],T,e)))continue n}x&&x.push(T),d.push(A)}}return d}function Bl(n,t,e,r){return jn(n,function(u,o,a){t(r,e(u),o,a)}),r}function we(n,t,e){t=xt(t,n),n=zs(n,t);var r=n==null?n:n[tt($n(t))];return r==null?i:Pn(r,n,e)}function is(n){return j(n)&&_n(n)==Dt}function Gl(n){return j(n)&&_n(n)==fe}function kl(n){return j(n)&&_n(n)==ie}function me(n,t,e,r,u){return n===t?!0:n==null||t==null||!j(n)&&!j(t)?n!==n&&t!==t:$l(n,t,e,r,me,u)}function $l(n,t,e,r,u,o){var a=O(n),f=O(t),c=a?Ee:gn(n),d=f?Ee:gn(t);c=c==Dt?rt:c,d=d==Dt?rt:d;var _=c==rt,v=d==rt,x=c==d;if(x&&At(n)){if(!At(t))return!1;a=!0,_=!1}if(x&&!_)return o||(o=new Zn),a||Qt(n)?Ds(n,t,e,r,u,o):dc(n,t,c,e,r,u,o);if(!(e&Tn)){var A=_&&z.call(n,"__wrapped__"),T=v&&z.call(t,"__wrapped__");if(A||T){var M=A?n.value():n,P=T?t.value():t;return o||(o=new Zn),u(M,P,e,r,o)}}return x?(o||(o=new Zn),_c(n,t,e,r,u,o)):!1}function ql(n){return j(n)&&gn(n)==Kn}function ai(n,t,e,r){var u=e.length,o=u,a=!r;if(n==null)return!o;for(n=J(n);u--;){var f=e[u];if(a&&f[2]?f[1]!==n[f[0]]:!(f[0]in n))return!1}for(;++u<o;){f=e[u];var c=f[0],d=n[c],_=f[1];if(a&&f[2]){if(d===i&&!(c in n))return!1}else{var v=new Zn;if(r)var x=r(d,_,c,n,t,v);if(!(x===i?me(_,d,Tn|gt,r,v):x))return!1}}return!0}function us(n){if(!Q(n)||bc(n))return!1;var t=lt(n)?qf:Oa;return t.test(Ft(n))}function zl(n){return j(n)&&_n(n)==se}function Hl(n){return j(n)&&gn(n)==Jn}function Kl(n){return j(n)&&wr(n.length)&&!!Z[_n(n)]}function ss(n){return typeof n=="function"?n:n==null?Cn:typeof n=="object"?O(n)?fs(n[0],n[1]):as(n):Eo(n)}function fi(n){if(!Se(n))return Zf(n);var t=[];for(var e in J(n))z.call(n,e)&&e!="constructor"&&t.push(e);return t}function Jl(n){if(!Q(n))return Ec(n);var t=Se(n),e=[];for(var r in n)r=="constructor"&&(t||!z.call(n,r))||e.push(r);return e}function li(n,t){return n<t}function os(n,t){var e=-1,r=Sn(n)?h(n.length):[];return mt(n,function(u,o,a){r[++e]=t(u,o,a)}),r}function as(n){var t=bi(n);return t.length==1&&t[0][2]?$s(t[0][0],t[0][1]):function(e){return e===n||ai(e,n,t)}}function fs(n,t){return Ti(n)&&ks(t)?$s(tt(n),t):function(e){var r=Di(e,n);return r===i&&r===t?Ni(e,n):me(t,r,Tn|gt)}}function er(n,t,e,r,u){n!==t&&ii(t,function(o,a){if(u||(u=new Zn),Q(o))Yl(n,t,a,e,er,r,u);else{var f=r?r(Ei(n,a),o,a+"",n,t,u):i;f===i&&(f=o),ei(n,a,f)}},An)}function Yl(n,t,e,r,u,o,a){var f=Ei(n,e),c=Ei(t,e),d=a.get(c);if(d){ei(n,e,d);return}var _=o?o(f,c,e+"",n,t,a):i,v=_===i;if(v){var x=O(c),A=!x&&At(c),T=!x&&!A&&Qt(c);_=c,x||A||T?O(f)?_=f:nn(f)?_=xn(f):A?(v=!1,_=xs(c,!0)):T?(v=!1,_=Ss(c,!0)):_=[]:Ce(c)||Ut(c)?(_=f,Ut(f)?_=mo(f):(!Q(f)||lt(f))&&(_=Gs(c))):v=!1}v&&(a.set(c,_),u(_,c,r,o,a),a.delete(c)),ei(n,e,_)}function ls(n,t){var e=n.length;if(e)return t+=t<0?e:0,ft(t,e)?n[t]:i}function cs(n,t,e){t.length?t=X(t,function(o){return O(o)?function(a){return Wt(a,o.length===1?o[0]:o)}:o}):t=[Cn];var r=-1;t=X(t,En(R()));var u=os(n,function(o,a,f){var c=X(t,function(d){return d(o)});return{criteria:c,index:++r,value:o}});return xf(u,function(o,a){return oc(o,a,e)})}function Zl(n,t){return hs(n,t,function(e,r){return Ni(n,r)})}function hs(n,t,e){for(var r=-1,u=t.length,o={};++r<u;){var a=t[r],f=Wt(n,a);e(f,a)&&ye(o,xt(a,n),f)}return o}function Xl(n){return function(t){return Wt(t,n)}}function ci(n,t,e,r){var u=r?yf:Gt,o=-1,a=t.length,f=n;for(n===t&&(t=xn(t)),e&&(f=X(n,En(e)));++o<a;)for(var c=0,d=t[o],_=e?e(d):d;(c=u(f,_,c,r))>-1;)f!==n&&Ke.call(f,c,1),Ke.call(n,c,1);return n}function gs(n,t){for(var e=n?t.length:0,r=e-1;e--;){var u=t[e];if(e==r||u!==o){var o=u;ft(u)?Ke.call(n,u,1):di(n,u)}}return n}function hi(n,t){return n+Ze(Ju()*(t-n+1))}function Ql(n,t,e,r){for(var u=-1,o=an(Ye((t-n)/(e||1)),0),a=h(o);o--;)a[r?o:++u]=n,n+=e;return a}function gi(n,t){var e="";if(!n||t<1||t>pt)return e;do t%2&&(e+=n),t=Ze(t/2),t&&(n+=n);while(t);return e}function U(n,t){return Ii(qs(n,t,Cn),n+"")}function Vl(n){return Xu(Vt(n))}function jl(n,t){var e=Vt(n);return hr(e,Ot(t,0,e.length))}function ye(n,t,e,r){if(!Q(n))return n;t=xt(t,n);for(var u=-1,o=t.length,a=o-1,f=n;f!=null&&++u<o;){var c=tt(t[u]),d=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(u!=a){var _=f[c];d=r?r(_,c,f):i,d===i&&(d=Q(_)?_:ft(t[u+1])?[]:{})}_e(f,c,d),f=f[c]}return n}var ps=Xe?function(n,t){return Xe.set(n,t),n}:Cn,nc=Je?function(n,t){return Je(n,"toString",{configurable:!0,enumerable:!1,value:Gi(t),writable:!0})}:Cn;function tc(n){return hr(Vt(n))}function kn(n,t,e){var r=-1,u=n.length;t<0&&(t=-t>u?0:u+t),e=e>u?u:e,e<0&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var o=h(u);++r<u;)o[r]=n[r+t];return o}function ec(n,t){var e;return mt(n,function(r,u,o){return e=t(r,u,o),!e}),!!e}function rr(n,t,e){var r=0,u=n==null?r:n.length;if(typeof t=="number"&&t===t&&u<=ra){for(;r<u;){var o=r+u>>>1,a=n[o];a!==null&&!Ln(a)&&(e?a<=t:a<t)?r=o+1:u=o}return u}return pi(n,t,Cn,e)}function pi(n,t,e,r){var u=0,o=n==null?0:n.length;if(o===0)return 0;t=e(t);for(var a=t!==t,f=t===null,c=Ln(t),d=t===i;u<o;){var _=Ze((u+o)/2),v=e(n[_]),x=v!==i,A=v===null,T=v===v,M=Ln(v);if(a)var P=r||T;else d?P=T&&(r||x):f?P=T&&x&&(r||!A):c?P=T&&x&&!A&&(r||!M):A||M?P=!1:P=r?v<=t:v<t;P?u=_+1:o=_}return hn(o,ea)}function ds(n,t){for(var e=-1,r=n.length,u=0,o=[];++e<r;){var a=n[e],f=t?t(a):a;if(!e||!Xn(f,c)){var c=f;o[u++]=a===0?0:a}}return o}function _s(n){return typeof n=="number"?n:Ln(n)?Pe:+n}function In(n){if(typeof n=="string")return n;if(O(n))return X(n,In)+"";if(Ln(n))return Yu?Yu.call(n):"";var t=n+"";return t=="0"&&1/n==-Tt?"-0":t}function yt(n,t,e){var r=-1,u=Ue,o=n.length,a=!0,f=[],c=f;if(e)a=!1,u=qr;else if(o>=m){var d=t?null:gc(n);if(d)return Ne(d);a=!1,u=le,c=new Lt}else c=t?[]:f;n:for(;++r<o;){var _=n[r],v=t?t(_):_;if(_=e||_!==0?_:0,a&&v===v){for(var x=c.length;x--;)if(c[x]===v)continue n;t&&c.push(v),f.push(_)}else u(c,v,e)||(c!==f&&c.push(v),f.push(_))}return f}function di(n,t){return t=xt(t,n),n=zs(n,t),n==null||delete n[tt($n(t))]}function vs(n,t,e,r){return ye(n,t,e(Wt(n,t)),r)}function ir(n,t,e,r){for(var u=n.length,o=r?u:-1;(r?o--:++o<u)&&t(n[o],o,n););return e?kn(n,r?0:o,r?o+1:u):kn(n,r?o+1:0,r?u:o)}function ws(n,t){var e=n;return e instanceof N&&(e=e.value()),zr(t,function(r,u){return u.func.apply(u.thisArg,_t([r],u.args))},e)}function _i(n,t,e){var r=n.length;if(r<2)return r?yt(n[0]):[];for(var u=-1,o=h(r);++u<r;)for(var a=n[u],f=-1;++f<r;)f!=u&&(o[u]=ve(o[u]||a,n[f],t,e));return yt(cn(o,1),t,e)}function ms(n,t,e){for(var r=-1,u=n.length,o=t.length,a={};++r<u;){var f=r<o?t[r]:i;e(a,n[r],f)}return a}function vi(n){return nn(n)?n:[]}function wi(n){return typeof n=="function"?n:Cn}function xt(n,t){return O(n)?n:Ti(n,t)?[n]:Ys(q(n))}var rc=U;function St(n,t,e){var r=n.length;return e=e===i?r:e,!t&&e>=r?n:kn(n,t,e)}var ys=zf||function(n){return ln.clearTimeout(n)};function xs(n,t){if(t)return n.slice();var e=n.length,r=$u?$u(e):new n.constructor(e);return n.copy(r),r}function mi(n){var t=new n.constructor(n.byteLength);return new ze(t).set(new ze(n)),t}function ic(n,t){var e=t?mi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}function uc(n){var t=new n.constructor(n.source,iu.exec(n));return t.lastIndex=n.lastIndex,t}function sc(n){return de?J(de.call(n)):{}}function Ss(n,t){var e=t?mi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}function As(n,t){if(n!==t){var e=n!==i,r=n===null,u=n===n,o=Ln(n),a=t!==i,f=t===null,c=t===t,d=Ln(t);if(!f&&!d&&!o&&n>t||o&&a&&c&&!f&&!d||r&&a&&c||!e&&c||!u)return 1;if(!r&&!o&&!d&&n<t||d&&e&&u&&!r&&!o||f&&e&&u||!a&&u||!c)return-1}return 0}function oc(n,t,e){for(var r=-1,u=n.criteria,o=t.criteria,a=u.length,f=e.length;++r<a;){var c=As(u[r],o[r]);if(c){if(r>=f)return c;var d=e[r];return c*(d=="desc"?-1:1)}}return n.index-t.index}function Cs(n,t,e,r){for(var u=-1,o=n.length,a=e.length,f=-1,c=t.length,d=an(o-a,0),_=h(c+d),v=!r;++f<c;)_[f]=t[f];for(;++u<a;)(v||u<o)&&(_[e[u]]=n[u]);for(;d--;)_[f++]=n[u++];return _}function bs(n,t,e,r){for(var u=-1,o=n.length,a=-1,f=e.length,c=-1,d=t.length,_=an(o-f,0),v=h(_+d),x=!r;++u<_;)v[u]=n[u];for(var A=u;++c<d;)v[A+c]=t[c];for(;++a<f;)(x||u<o)&&(v[A+e[a]]=n[u++]);return v}function xn(n,t){var e=-1,r=n.length;for(t||(t=h(r));++e<r;)t[e]=n[e];return t}function nt(n,t,e,r){var u=!e;e||(e={});for(var o=-1,a=t.length;++o<a;){var f=t[o],c=r?r(e[f],n[f],f,e,n):i;c===i&&(c=n[f]),u?st(e,f,c):_e(e,f,c)}return e}function ac(n,t){return nt(n,Ri(n),t)}function fc(n,t){return nt(n,Ns(n),t)}function ur(n,t){return function(e,r){var u=O(e)?pf:Ll,o=t?t():{};return u(e,n,R(r,2),o)}}function Yt(n){return U(function(t,e){var r=-1,u=e.length,o=u>1?e[u-1]:i,a=u>2?e[2]:i;for(o=n.length>3&&typeof o=="function"?(u--,o):i,a&&vn(e[0],e[1],a)&&(o=u<3?i:o,u=1),t=J(t);++r<u;){var f=e[r];f&&n(t,f,r,o)}return t})}function Rs(n,t){return function(e,r){if(e==null)return e;if(!Sn(e))return n(e,r);for(var u=e.length,o=t?u:-1,a=J(e);(t?o--:++o<u)&&r(a[o],o,a)!==!1;);return e}}function Ts(n){return function(t,e,r){for(var u=-1,o=J(t),a=r(t),f=a.length;f--;){var c=a[n?f:++u];if(e(o[c],c,o)===!1)break}return t}}function lc(n,t,e){var r=t&mn,u=xe(n);function o(){var a=this&&this!==ln&&this instanceof o?u:n;return a.apply(r?e:this,arguments)}return o}function Ps(n){return function(t){t=q(t);var e=kt(t)?Yn(t):i,r=e?e[0]:t.charAt(0),u=e?St(e,1).join(""):t.slice(1);return r[n]()+u}}function Zt(n){return function(t){return zr(To(Ro(t).replace(ja,"")),n,"")}}function xe(n){return function(){var t=arguments;switch(t.length){case 0:return new n;case 1:return new n(t[0]);case 2:return new n(t[0],t[1]);case 3:return new n(t[0],t[1],t[2]);case 4:return new n(t[0],t[1],t[2],t[3]);case 5:return new n(t[0],t[1],t[2],t[3],t[4]);case 6:return new n(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var e=Jt(n.prototype),r=n.apply(e,t);return Q(r)?r:e}}function cc(n,t,e){var r=xe(n);function u(){for(var o=arguments.length,a=h(o),f=o,c=Xt(u);f--;)a[f]=arguments[f];var d=o<3&&a[0]!==c&&a[o-1]!==c?[]:vt(a,c);if(o-=d.length,o<e)return Ws(n,t,sr,u.placeholder,i,a,d,i,i,e-o);var _=this&&this!==ln&&this instanceof u?r:n;return Pn(_,this,a)}return u}function Es(n){return function(t,e,r){var u=J(t);if(!Sn(t)){var o=R(e,3);t=fn(t),e=function(f){return o(u[f],f,u)}}var a=n(t,e,r);return a>-1?u[o?t[a]:a]:i}}function Is(n){return at(function(t){var e=t.length,r=e,u=Bn.prototype.thru;for(n&&t.reverse();r--;){var o=t[r];if(typeof o!="function")throw new Nn(b);if(u&&!a&&lr(o)=="wrapper")var a=new Bn([],!0)}for(r=a?r:e;++r<e;){o=t[r];var f=lr(o),c=f=="wrapper"?Ci(o):i;c&&Pi(c[0])&&c[1]==(F|zn|Hn|en)&&!c[4].length&&c[9]==1?a=a[lr(c[0])].apply(a,c[3]):a=o.length==1&&Pi(o)?a[f]():a.thru(o)}return function(){var d=arguments,_=d[0];if(a&&d.length==1&&O(_))return a.plant(_).value();for(var v=0,x=e?t[v].apply(this,d):_;++v<e;)x=t[v].call(this,x);return x}})}function sr(n,t,e,r,u,o,a,f,c,d){var _=t&F,v=t&mn,x=t&yn,A=t&(zn|bt),T=t&H,M=x?i:xe(n);function P(){for(var D=arguments.length,B=h(D),On=D;On--;)B[On]=arguments[On];if(A)var wn=Xt(P),Wn=Af(B,wn);if(r&&(B=Cs(B,r,u,A)),o&&(B=bs(B,o,a,A)),D-=Wn,A&&D<d){var tn=vt(B,wn);return Ws(n,t,sr,P.placeholder,e,B,tn,f,c,d-D)}var Qn=v?e:this,ht=x?Qn[n]:n;return D=B.length,f?B=Lc(B,f):T&&D>1&&B.reverse(),_&&c<D&&(B.length=c),this&&this!==ln&&this instanceof P&&(ht=M||xe(ht)),ht.apply(Qn,B)}return P}function Ls(n,t){return function(e,r){return Bl(e,n,t(r),{})}}function or(n,t){return function(e,r){var u;if(e===i&&r===i)return t;if(e!==i&&(u=e),r!==i){if(u===i)return r;typeof e=="string"||typeof r=="string"?(e=In(e),r=In(r)):(e=_s(e),r=_s(r)),u=n(e,r)}return u}}function yi(n){return at(function(t){return t=X(t,En(R())),U(function(e){var r=this;return n(t,function(u){return Pn(u,r,e)})})})}function ar(n,t){t=t===i?" ":In(t);var e=t.length;if(e<2)return e?gi(t,n):t;var r=gi(t,Ye(n/$t(t)));return kt(t)?St(Yn(r),0,n).join(""):r.slice(0,n)}function hc(n,t,e,r){var u=t&mn,o=xe(n);function a(){for(var f=-1,c=arguments.length,d=-1,_=r.length,v=h(_+c),x=this&&this!==ln&&this instanceof a?o:n;++d<_;)v[d]=r[d];for(;c--;)v[d++]=arguments[++f];return Pn(x,u?e:this,v)}return a}function Os(n){return function(t,e,r){return r&&typeof r!="number"&&vn(t,e,r)&&(e=r=i),t=ct(t),e===i?(e=t,t=0):e=ct(e),r=r===i?t<e?1:-1:ct(r),Ql(t,e,r,n)}}function fr(n){return function(t,e){return typeof t=="string"&&typeof e=="string"||(t=qn(t),e=qn(e)),n(t,e)}}function Ws(n,t,e,r,u,o,a,f,c,d){var _=t&zn,v=_?a:i,x=_?i:a,A=_?o:i,T=_?i:o;t|=_?Hn:Rt,t&=~(_?Rt:Hn),t&Te||(t&=-4);var M=[n,t,u,A,v,T,x,f,c,d],P=e.apply(i,M);return Pi(n)&&Hs(P,M),P.placeholder=r,Ks(P,n,t)}function xi(n){var t=on[n];return function(e,r){if(e=qn(e),r=r==null?0:hn(W(r),292),r&&Ku(e)){var u=(q(e)+"e").split("e"),o=t(u[0]+"e"+(+u[1]+r));return u=(q(o)+"e").split("e"),+(u[0]+"e"+(+u[1]-r))}return t(e)}}var gc=Ht&&1/Ne(new Ht([,-0]))[1]==Tt?function(n){return new Ht(n)}:qi;function Ms(n){return function(t){var e=gn(t);return e==Kn?Qr(t):e==Jn?If(t):Sf(t,n(t))}}function ot(n,t,e,r,u,o,a,f){var c=t&yn;if(!c&&typeof n!="function")throw new Nn(b);var d=r?r.length:0;if(d||(t&=-97,r=u=i),a=a===i?a:an(W(a),0),f=f===i?f:W(f),d-=u?u.length:0,t&Rt){var _=r,v=u;r=u=i}var x=c?i:Ci(n),A=[n,t,e,r,u,_,v,o,a,f];if(x&&Pc(A,x),n=A[0],t=A[1],e=A[2],r=A[3],u=A[4],f=A[9]=A[9]===i?c?0:n.length:an(A[9]-d,0),!f&&t&(zn|bt)&&(t&=-25),!t||t==mn)var T=lc(n,t,e);else t==zn||t==bt?T=cc(n,t,f):(t==Hn||t==(mn|Hn))&&!u.length?T=hc(n,t,e,r):T=sr.apply(i,A);var M=x?ps:Hs;return Ks(M(T,A),n,t)}function Fs(n,t,e,r){return n===i||Xn(n,zt[e])&&!z.call(r,e)?t:n}function Us(n,t,e,r,u,o){return Q(n)&&Q(t)&&(o.set(t,n),er(n,t,i,Us,o),o.delete(t)),n}function pc(n){return Ce(n)?i:n}function Ds(n,t,e,r,u,o){var a=e&Tn,f=n.length,c=t.length;if(f!=c&&!(a&&c>f))return!1;var d=o.get(n),_=o.get(t);if(d&&_)return d==t&&_==n;var v=-1,x=!0,A=e&gt?new Lt:i;for(o.set(n,t),o.set(t,n);++v<f;){var T=n[v],M=t[v];if(r)var P=a?r(M,T,v,t,n,o):r(T,M,v,n,t,o);if(P!==i){if(P)continue;x=!1;break}if(A){if(!Hr(t,function(D,B){if(!le(A,B)&&(T===D||u(T,D,e,r,o)))return A.push(B)})){x=!1;break}}else if(!(T===M||u(T,M,e,r,o))){x=!1;break}}return o.delete(n),o.delete(t),x}function dc(n,t,e,r,u,o,a){switch(e){case Nt:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case fe:return!(n.byteLength!=t.byteLength||!o(new ze(n),new ze(t)));case re:case ie:case ue:return Xn(+n,+t);case Ie:return n.name==t.name&&n.message==t.message;case se:case oe:return n==t+"";case Kn:var f=Qr;case Jn:var c=r&Tn;if(f||(f=Ne),n.size!=t.size&&!c)return!1;var d=a.get(n);if(d)return d==t;r|=gt,a.set(n,t);var _=Ds(f(n),f(t),r,u,o,a);return a.delete(n),_;case Oe:if(de)return de.call(n)==de.call(t)}return!1}function _c(n,t,e,r,u,o){var a=e&Tn,f=Si(n),c=f.length,d=Si(t),_=d.length;if(c!=_&&!a)return!1;for(var v=c;v--;){var x=f[v];if(!(a?x in t:z.call(t,x)))return!1}var A=o.get(n),T=o.get(t);if(A&&T)return A==t&&T==n;var M=!0;o.set(n,t),o.set(t,n);for(var P=a;++v<c;){x=f[v];var D=n[x],B=t[x];if(r)var On=a?r(B,D,x,t,n,o):r(D,B,x,n,t,o);if(!(On===i?D===B||u(D,B,e,r,o):On)){M=!1;break}P||(P=x=="constructor")}if(M&&!P){var wn=n.constructor,Wn=t.constructor;wn!=Wn&&"constructor"in n&&"constructor"in t&&!(typeof wn=="function"&&wn instanceof wn&&typeof Wn=="function"&&Wn instanceof Wn)&&(M=!1)}return o.delete(n),o.delete(t),M}function at(n){return Ii(qs(n,i,Vs),n+"")}function Si(n){return rs(n,fn,Ri)}function Ai(n){return rs(n,An,Ns)}var Ci=Xe?function(n){return Xe.get(n)}:qi;function lr(n){for(var t=n.name+"",e=Kt[t],r=z.call(Kt,t)?e.length:0;r--;){var u=e[r],o=u.func;if(o==null||o==n)return u.name}return t}function Xt(n){var t=z.call(s,"placeholder")?s:n;return t.placeholder}function R(){var n=s.iteratee||ki;return n=n===ki?ss:n,arguments.length?n(arguments[0],arguments[1]):n}function cr(n,t){var e=n.__data__;return Cc(t)?e[typeof t=="string"?"string":"hash"]:e.map}function bi(n){for(var t=fn(n),e=t.length;e--;){var r=t[e],u=n[r];t[e]=[r,u,ks(u)]}return t}function Mt(n,t){var e=Tf(n,t);return us(e)?e:i}function vc(n){var t=z.call(n,Et),e=n[Et];try{n[Et]=i;var r=!0}catch{}var u=$e.call(n);return r&&(t?n[Et]=e:delete n[Et]),u}var Ri=jr?function(n){return n==null?[]:(n=J(n),dt(jr(n),function(t){return zu.call(n,t)}))}:zi,Ns=jr?function(n){for(var t=[];n;)_t(t,Ri(n)),n=He(n);return t}:zi,gn=_n;(ni&&gn(new ni(new ArrayBuffer(1)))!=Nt||he&&gn(new he)!=Kn||ti&&gn(ti.resolve())!=nu||Ht&&gn(new Ht)!=Jn||ge&&gn(new ge)!=ae)&&(gn=function(n){var t=_n(n),e=t==rt?n.constructor:i,r=e?Ft(e):"";if(r)switch(r){case jf:return Nt;case nl:return Kn;case tl:return nu;case el:return Jn;case rl:return ae}return t});function wc(n,t,e){for(var r=-1,u=e.length;++r<u;){var o=e[r],a=o.size;switch(o.type){case"drop":n+=a;break;case"dropRight":t-=a;break;case"take":t=hn(t,n+a);break;case"takeRight":n=an(n,t-a);break}}return{start:n,end:t}}function mc(n){var t=n.match(Ca);return t?t[1].split(ba):[]}function Bs(n,t,e){t=xt(t,n);for(var r=-1,u=t.length,o=!1;++r<u;){var a=tt(t[r]);if(!(o=n!=null&&e(n,a)))break;n=n[a]}return o||++r!=u?o:(u=n==null?0:n.length,!!u&&wr(u)&&ft(a,u)&&(O(n)||Ut(n)))}function yc(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&z.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Gs(n){return typeof n.constructor=="function"&&!Se(n)?Jt(He(n)):{}}function xc(n,t,e){var r=n.constructor;switch(t){case fe:return mi(n);case re:case ie:return new r(+n);case Nt:return ic(n,e);case br:case Rr:case Tr:case Pr:case Er:case Ir:case Lr:case Or:case Wr:return Ss(n,e);case Kn:return new r;case ue:case oe:return new r(n);case se:return uc(n);case Jn:return new r;case Oe:return sc(n)}}function Sc(n,t){var e=t.length;if(!e)return n;var r=e-1;return t[r]=(e>1?"& ":"")+t[r],t=t.join(e>2?", ":" "),n.replace(Aa,`{
17
- /* [wrapped with `+t+`] */
18
- `)}function Ac(n){return O(n)||Ut(n)||!!(Hu&&n&&n[Hu])}function ft(n,t){var e=typeof n;return t=t??pt,!!t&&(e=="number"||e!="symbol"&&Ma.test(n))&&n>-1&&n%1==0&&n<t}function vn(n,t,e){if(!Q(e))return!1;var r=typeof t;return(r=="number"?Sn(e)&&ft(t,e.length):r=="string"&&t in e)?Xn(e[t],n):!1}function Ti(n,t){if(O(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Ln(n)?!0:ma.test(n)||!wa.test(n)||t!=null&&n in J(t)}function Cc(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}function Pi(n){var t=lr(n),e=s[t];if(typeof e!="function"||!(t in N.prototype))return!1;if(n===e)return!0;var r=Ci(e);return!!r&&n===r[0]}function bc(n){return!!ku&&ku in n}var Rc=Ge?lt:Hi;function Se(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||zt;return n===e}function ks(n){return n===n&&!Q(n)}function $s(n,t){return function(e){return e==null?!1:e[n]===t&&(t!==i||n in J(e))}}function Tc(n){var t=_r(n,function(r){return e.size===rn&&e.clear(),r}),e=t.cache;return t}function Pc(n,t){var e=n[1],r=t[1],u=e|r,o=u<(mn|yn|F),a=r==F&&e==zn||r==F&&e==en&&n[7].length<=t[8]||r==(F|en)&&t[7].length<=t[8]&&e==zn;if(!(o||a))return n;r&mn&&(n[2]=t[2],u|=e&mn?0:Te);var f=t[3];if(f){var c=n[3];n[3]=c?Cs(c,f,t[4]):f,n[4]=c?vt(n[3],bn):t[4]}return f=t[5],f&&(c=n[5],n[5]=c?bs(c,f,t[6]):f,n[6]=c?vt(n[5],bn):t[6]),f=t[7],f&&(n[7]=f),r&F&&(n[8]=n[8]==null?t[8]:hn(n[8],t[8])),n[9]==null&&(n[9]=t[9]),n[0]=t[0],n[1]=u,n}function Ec(n){var t=[];if(n!=null)for(var e in J(n))t.push(e);return t}function Ic(n){return $e.call(n)}function qs(n,t,e){return t=an(t===i?n.length-1:t,0),function(){for(var r=arguments,u=-1,o=an(r.length-t,0),a=h(o);++u<o;)a[u]=r[t+u];u=-1;for(var f=h(t+1);++u<t;)f[u]=r[u];return f[t]=e(a),Pn(n,this,f)}}function zs(n,t){return t.length<2?n:Wt(n,kn(t,0,-1))}function Lc(n,t){for(var e=n.length,r=hn(t.length,e),u=xn(n);r--;){var o=t[r];n[r]=ft(o,e)?u[o]:i}return n}function Ei(n,t){if(!(t==="constructor"&&typeof n[t]=="function")&&t!="__proto__")return n[t]}var Hs=Js(ps),Ae=Kf||function(n,t){return ln.setTimeout(n,t)},Ii=Js(nc);function Ks(n,t,e){var r=t+"";return Ii(n,Sc(r,Oc(mc(r),e)))}function Js(n){var t=0,e=0;return function(){var r=Xf(),u=V-(r-e);if(e=r,u>0){if(++t>=Fn)return arguments[0]}else t=0;return n.apply(i,arguments)}}function hr(n,t){var e=-1,r=n.length,u=r-1;for(t=t===i?r:t;++e<t;){var o=hi(e,u),a=n[o];n[o]=n[e],n[e]=a}return n.length=t,n}var Ys=Tc(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(ya,function(e,r,u,o){t.push(u?o.replace(Pa,"$1"):r||e)}),t});function tt(n){if(typeof n=="string"||Ln(n))return n;var t=n+"";return t=="0"&&1/n==-Tt?"-0":t}function Ft(n){if(n!=null){try{return ke.call(n)}catch{}try{return n+""}catch{}}return""}function Oc(n,t){return Dn(ia,function(e){var r="_."+e[0];t&e[1]&&!Ue(n,r)&&n.push(r)}),n.sort()}function Zs(n){if(n instanceof N)return n.clone();var t=new Bn(n.__wrapped__,n.__chain__);return t.__actions__=xn(n.__actions__),t.__index__=n.__index__,t.__values__=n.__values__,t}function Wc(n,t,e){(e?vn(n,t,e):t===i)?t=1:t=an(W(t),0);var r=n==null?0:n.length;if(!r||t<1)return[];for(var u=0,o=0,a=h(Ye(r/t));u<r;)a[o++]=kn(n,u,u+=t);return a}function Mc(n){for(var t=-1,e=n==null?0:n.length,r=0,u=[];++t<e;){var o=n[t];o&&(u[r++]=o)}return u}function Fc(){var n=arguments.length;if(!n)return[];for(var t=h(n-1),e=arguments[0],r=n;r--;)t[r-1]=arguments[r];return _t(O(e)?xn(e):[e],cn(t,1))}var Uc=U(function(n,t){return nn(n)?ve(n,cn(t,1,nn,!0)):[]}),Dc=U(function(n,t){var e=$n(t);return nn(e)&&(e=i),nn(n)?ve(n,cn(t,1,nn,!0),R(e,2)):[]}),Nc=U(function(n,t){var e=$n(t);return nn(e)&&(e=i),nn(n)?ve(n,cn(t,1,nn,!0),i,e):[]});function Bc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),kn(n,t<0?0:t,r)):[]}function Gc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),t=r-t,kn(n,0,t<0?0:t)):[]}function kc(n,t){return n&&n.length?ir(n,R(t,3),!0,!0):[]}function $c(n,t){return n&&n.length?ir(n,R(t,3),!0):[]}function qc(n,t,e,r){var u=n==null?0:n.length;return u?(e&&typeof e!="number"&&vn(n,t,e)&&(e=0,r=u),Fl(n,t,e,r)):[]}function Xs(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=e==null?0:W(e);return u<0&&(u=an(r+u,0)),De(n,R(t,3),u)}function Qs(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=r-1;return e!==i&&(u=W(e),u=e<0?an(r+u,0):hn(u,r-1)),De(n,R(t,3),u,!0)}function Vs(n){var t=n==null?0:n.length;return t?cn(n,1):[]}function zc(n){var t=n==null?0:n.length;return t?cn(n,Tt):[]}function Hc(n,t){var e=n==null?0:n.length;return e?(t=t===i?1:W(t),cn(n,t)):[]}function Kc(n){for(var t=-1,e=n==null?0:n.length,r={};++t<e;){var u=n[t];r[u[0]]=u[1]}return r}function js(n){return n&&n.length?n[0]:i}function Jc(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=e==null?0:W(e);return u<0&&(u=an(r+u,0)),Gt(n,t,u)}function Yc(n){var t=n==null?0:n.length;return t?kn(n,0,-1):[]}var Zc=U(function(n){var t=X(n,vi);return t.length&&t[0]===n[0]?oi(t):[]}),Xc=U(function(n){var t=$n(n),e=X(n,vi);return t===$n(e)?t=i:e.pop(),e.length&&e[0]===n[0]?oi(e,R(t,2)):[]}),Qc=U(function(n){var t=$n(n),e=X(n,vi);return t=typeof t=="function"?t:i,t&&e.pop(),e.length&&e[0]===n[0]?oi(e,i,t):[]});function Vc(n,t){return n==null?"":Yf.call(n,t)}function $n(n){var t=n==null?0:n.length;return t?n[t-1]:i}function jc(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=r;return e!==i&&(u=W(e),u=u<0?an(r+u,0):hn(u,r-1)),t===t?Of(n,t,u):De(n,Wu,u,!0)}function nh(n,t){return n&&n.length?ls(n,W(t)):i}var th=U(no);function no(n,t){return n&&n.length&&t&&t.length?ci(n,t):n}function eh(n,t,e){return n&&n.length&&t&&t.length?ci(n,t,R(e,2)):n}function rh(n,t,e){return n&&n.length&&t&&t.length?ci(n,t,i,e):n}var ih=at(function(n,t){var e=n==null?0:n.length,r=ri(n,t);return gs(n,X(t,function(u){return ft(u,e)?+u:u}).sort(As)),r});function uh(n,t){var e=[];if(!(n&&n.length))return e;var r=-1,u=[],o=n.length;for(t=R(t,3);++r<o;){var a=n[r];t(a,r,n)&&(e.push(a),u.push(r))}return gs(n,u),e}function Li(n){return n==null?n:Vf.call(n)}function sh(n,t,e){var r=n==null?0:n.length;return r?(e&&typeof e!="number"&&vn(n,t,e)?(t=0,e=r):(t=t==null?0:W(t),e=e===i?r:W(e)),kn(n,t,e)):[]}function oh(n,t){return rr(n,t)}function ah(n,t,e){return pi(n,t,R(e,2))}function fh(n,t){var e=n==null?0:n.length;if(e){var r=rr(n,t);if(r<e&&Xn(n[r],t))return r}return-1}function lh(n,t){return rr(n,t,!0)}function ch(n,t,e){return pi(n,t,R(e,2),!0)}function hh(n,t){var e=n==null?0:n.length;if(e){var r=rr(n,t,!0)-1;if(Xn(n[r],t))return r}return-1}function gh(n){return n&&n.length?ds(n):[]}function ph(n,t){return n&&n.length?ds(n,R(t,2)):[]}function dh(n){var t=n==null?0:n.length;return t?kn(n,1,t):[]}function _h(n,t,e){return n&&n.length?(t=e||t===i?1:W(t),kn(n,0,t<0?0:t)):[]}function vh(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),t=r-t,kn(n,t<0?0:t,r)):[]}function wh(n,t){return n&&n.length?ir(n,R(t,3),!1,!0):[]}function mh(n,t){return n&&n.length?ir(n,R(t,3)):[]}var yh=U(function(n){return yt(cn(n,1,nn,!0))}),xh=U(function(n){var t=$n(n);return nn(t)&&(t=i),yt(cn(n,1,nn,!0),R(t,2))}),Sh=U(function(n){var t=$n(n);return t=typeof t=="function"?t:i,yt(cn(n,1,nn,!0),i,t)});function Ah(n){return n&&n.length?yt(n):[]}function Ch(n,t){return n&&n.length?yt(n,R(t,2)):[]}function bh(n,t){return t=typeof t=="function"?t:i,n&&n.length?yt(n,i,t):[]}function Oi(n){if(!(n&&n.length))return[];var t=0;return n=dt(n,function(e){if(nn(e))return t=an(e.length,t),!0}),Zr(t,function(e){return X(n,Kr(e))})}function to(n,t){if(!(n&&n.length))return[];var e=Oi(n);return t==null?e:X(e,function(r){return Pn(t,i,r)})}var Rh=U(function(n,t){return nn(n)?ve(n,t):[]}),Th=U(function(n){return _i(dt(n,nn))}),Ph=U(function(n){var t=$n(n);return nn(t)&&(t=i),_i(dt(n,nn),R(t,2))}),Eh=U(function(n){var t=$n(n);return t=typeof t=="function"?t:i,_i(dt(n,nn),i,t)}),Ih=U(Oi);function Lh(n,t){return ms(n||[],t||[],_e)}function Oh(n,t){return ms(n||[],t||[],ye)}var Wh=U(function(n){var t=n.length,e=t>1?n[t-1]:i;return e=typeof e=="function"?(n.pop(),e):i,to(n,e)});function eo(n){var t=s(n);return t.__chain__=!0,t}function Mh(n,t){return t(n),n}function gr(n,t){return t(n)}var Fh=at(function(n){var t=n.length,e=t?n[0]:0,r=this.__wrapped__,u=function(o){return ri(o,n)};return t>1||this.__actions__.length||!(r instanceof N)||!ft(e)?this.thru(u):(r=r.slice(e,+e+(t?1:0)),r.__actions__.push({func:gr,args:[u],thisArg:i}),new Bn(r,this.__chain__).thru(function(o){return t&&!o.length&&o.push(i),o}))});function Uh(){return eo(this)}function Dh(){return new Bn(this.value(),this.__chain__)}function Nh(){this.__values__===i&&(this.__values__=vo(this.value()));var n=this.__index__>=this.__values__.length,t=n?i:this.__values__[this.__index__++];return{done:n,value:t}}function Bh(){return this}function Gh(n){for(var t,e=this;e instanceof Ve;){var r=Zs(e);r.__index__=0,r.__values__=i,t?u.__wrapped__=r:t=r;var u=r;e=e.__wrapped__}return u.__wrapped__=n,t}function kh(){var n=this.__wrapped__;if(n instanceof N){var t=n;return this.__actions__.length&&(t=new N(this)),t=t.reverse(),t.__actions__.push({func:gr,args:[Li],thisArg:i}),new Bn(t,this.__chain__)}return this.thru(Li)}function $h(){return ws(this.__wrapped__,this.__actions__)}var qh=ur(function(n,t,e){z.call(n,e)?++n[e]:st(n,e,1)});function zh(n,t,e){var r=O(n)?Lu:Ml;return e&&vn(n,t,e)&&(t=i),r(n,R(t,3))}function Hh(n,t){var e=O(n)?dt:ts;return e(n,R(t,3))}var Kh=Es(Xs),Jh=Es(Qs);function Yh(n,t){return cn(pr(n,t),1)}function Zh(n,t){return cn(pr(n,t),Tt)}function Xh(n,t,e){return e=e===i?1:W(e),cn(pr(n,t),e)}function ro(n,t){var e=O(n)?Dn:mt;return e(n,R(t,3))}function io(n,t){var e=O(n)?df:ns;return e(n,R(t,3))}var Qh=ur(function(n,t,e){z.call(n,e)?n[e].push(t):st(n,e,[t])});function Vh(n,t,e,r){n=Sn(n)?n:Vt(n),e=e&&!r?W(e):0;var u=n.length;return e<0&&(e=an(u+e,0)),mr(n)?e<=u&&n.indexOf(t,e)>-1:!!u&&Gt(n,t,e)>-1}var jh=U(function(n,t,e){var r=-1,u=typeof t=="function",o=Sn(n)?h(n.length):[];return mt(n,function(a){o[++r]=u?Pn(t,a,e):we(a,t,e)}),o}),ng=ur(function(n,t,e){st(n,e,t)});function pr(n,t){var e=O(n)?X:os;return e(n,R(t,3))}function tg(n,t,e,r){return n==null?[]:(O(t)||(t=t==null?[]:[t]),e=r?i:e,O(e)||(e=e==null?[]:[e]),cs(n,t,e))}var eg=ur(function(n,t,e){n[e?0:1].push(t)},function(){return[[],[]]});function rg(n,t,e){var r=O(n)?zr:Fu,u=arguments.length<3;return r(n,R(t,4),e,u,mt)}function ig(n,t,e){var r=O(n)?_f:Fu,u=arguments.length<3;return r(n,R(t,4),e,u,ns)}function ug(n,t){var e=O(n)?dt:ts;return e(n,vr(R(t,3)))}function sg(n){var t=O(n)?Xu:Vl;return t(n)}function og(n,t,e){(e?vn(n,t,e):t===i)?t=1:t=W(t);var r=O(n)?El:jl;return r(n,t)}function ag(n){var t=O(n)?Il:tc;return t(n)}function fg(n){if(n==null)return 0;if(Sn(n))return mr(n)?$t(n):n.length;var t=gn(n);return t==Kn||t==Jn?n.size:fi(n).length}function lg(n,t,e){var r=O(n)?Hr:ec;return e&&vn(n,t,e)&&(t=i),r(n,R(t,3))}var cg=U(function(n,t){if(n==null)return[];var e=t.length;return e>1&&vn(n,t[0],t[1])?t=[]:e>2&&vn(t[0],t[1],t[2])&&(t=[t[0]]),cs(n,cn(t,1),[])}),dr=Hf||function(){return ln.Date.now()};function hg(n,t){if(typeof t!="function")throw new Nn(b);return n=W(n),function(){if(--n<1)return t.apply(this,arguments)}}function uo(n,t,e){return t=e?i:t,t=n&&t==null?n.length:t,ot(n,F,i,i,i,i,t)}function so(n,t){var e;if(typeof t!="function")throw new Nn(b);return n=W(n),function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=i),e}}var Wi=U(function(n,t,e){var r=mn;if(e.length){var u=vt(e,Xt(Wi));r|=Hn}return ot(n,r,t,e,u)}),oo=U(function(n,t,e){var r=mn|yn;if(e.length){var u=vt(e,Xt(oo));r|=Hn}return ot(t,r,n,e,u)});function ao(n,t,e){t=e?i:t;var r=ot(n,zn,i,i,i,i,i,t);return r.placeholder=ao.placeholder,r}function fo(n,t,e){t=e?i:t;var r=ot(n,bt,i,i,i,i,i,t);return r.placeholder=fo.placeholder,r}function lo(n,t,e){var r,u,o,a,f,c,d=0,_=!1,v=!1,x=!0;if(typeof n!="function")throw new Nn(b);t=qn(t)||0,Q(e)&&(_=!!e.leading,v="maxWait"in e,o=v?an(qn(e.maxWait)||0,t):o,x="trailing"in e?!!e.trailing:x);function A(tn){var Qn=r,ht=u;return r=u=i,d=tn,a=n.apply(ht,Qn),a}function T(tn){return d=tn,f=Ae(D,t),_?A(tn):a}function M(tn){var Qn=tn-c,ht=tn-d,Io=t-Qn;return v?hn(Io,o-ht):Io}function P(tn){var Qn=tn-c,ht=tn-d;return c===i||Qn>=t||Qn<0||v&&ht>=o}function D(){var tn=dr();if(P(tn))return B(tn);f=Ae(D,M(tn))}function B(tn){return f=i,x&&r?A(tn):(r=u=i,a)}function On(){f!==i&&ys(f),d=0,r=c=u=f=i}function wn(){return f===i?a:B(dr())}function Wn(){var tn=dr(),Qn=P(tn);if(r=arguments,u=this,c=tn,Qn){if(f===i)return T(c);if(v)return ys(f),f=Ae(D,t),A(c)}return f===i&&(f=Ae(D,t)),a}return Wn.cancel=On,Wn.flush=wn,Wn}var gg=U(function(n,t){return ju(n,1,t)}),pg=U(function(n,t,e){return ju(n,qn(t)||0,e)});function dg(n){return ot(n,H)}function _r(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new Nn(b);var e=function(){var r=arguments,u=t?t.apply(this,r):r[0],o=e.cache;if(o.has(u))return o.get(u);var a=n.apply(this,r);return e.cache=o.set(u,a)||o,a};return e.cache=new(_r.Cache||ut),e}_r.Cache=ut;function vr(n){if(typeof n!="function")throw new Nn(b);return function(){var t=arguments;switch(t.length){case 0:return!n.call(this);case 1:return!n.call(this,t[0]);case 2:return!n.call(this,t[0],t[1]);case 3:return!n.call(this,t[0],t[1],t[2])}return!n.apply(this,t)}}function _g(n){return so(2,n)}var vg=rc(function(n,t){t=t.length==1&&O(t[0])?X(t[0],En(R())):X(cn(t,1),En(R()));var e=t.length;return U(function(r){for(var u=-1,o=hn(r.length,e);++u<o;)r[u]=t[u].call(this,r[u]);return Pn(n,this,r)})}),Mi=U(function(n,t){var e=vt(t,Xt(Mi));return ot(n,Hn,i,t,e)}),co=U(function(n,t){var e=vt(t,Xt(co));return ot(n,Rt,i,t,e)}),wg=at(function(n,t){return ot(n,en,i,i,i,t)});function mg(n,t){if(typeof n!="function")throw new Nn(b);return t=t===i?t:W(t),U(n,t)}function yg(n,t){if(typeof n!="function")throw new Nn(b);return t=t==null?0:an(W(t),0),U(function(e){var r=e[t],u=St(e,0,t);return r&&_t(u,r),Pn(n,this,u)})}function xg(n,t,e){var r=!0,u=!0;if(typeof n!="function")throw new Nn(b);return Q(e)&&(r="leading"in e?!!e.leading:r,u="trailing"in e?!!e.trailing:u),lo(n,t,{leading:r,maxWait:t,trailing:u})}function Sg(n){return uo(n,1)}function Ag(n,t){return Mi(wi(t),n)}function Cg(){if(!arguments.length)return[];var n=arguments[0];return O(n)?n:[n]}function bg(n){return Gn(n,pn)}function Rg(n,t){return t=typeof t=="function"?t:i,Gn(n,pn,t)}function Tg(n){return Gn(n,un|pn)}function Pg(n,t){return t=typeof t=="function"?t:i,Gn(n,un|pn,t)}function Eg(n,t){return t==null||Vu(n,t,fn(t))}function Xn(n,t){return n===t||n!==n&&t!==t}var Ig=fr(si),Lg=fr(function(n,t){return n>=t}),Ut=is(function(){return arguments}())?is:function(n){return j(n)&&z.call(n,"callee")&&!zu.call(n,"callee")},O=h.isArray,Og=bu?En(bu):Gl;function Sn(n){return n!=null&&wr(n.length)&&!lt(n)}function nn(n){return j(n)&&Sn(n)}function Wg(n){return n===!0||n===!1||j(n)&&_n(n)==re}var At=Jf||Hi,Mg=Ru?En(Ru):kl;function Fg(n){return j(n)&&n.nodeType===1&&!Ce(n)}function Ug(n){if(n==null)return!0;if(Sn(n)&&(O(n)||typeof n=="string"||typeof n.splice=="function"||At(n)||Qt(n)||Ut(n)))return!n.length;var t=gn(n);if(t==Kn||t==Jn)return!n.size;if(Se(n))return!fi(n).length;for(var e in n)if(z.call(n,e))return!1;return!0}function Dg(n,t){return me(n,t)}function Ng(n,t,e){e=typeof e=="function"?e:i;var r=e?e(n,t):i;return r===i?me(n,t,i,e):!!r}function Fi(n){if(!j(n))return!1;var t=_n(n);return t==Ie||t==sa||typeof n.message=="string"&&typeof n.name=="string"&&!Ce(n)}function Bg(n){return typeof n=="number"&&Ku(n)}function lt(n){if(!Q(n))return!1;var t=_n(n);return t==Le||t==ji||t==ua||t==aa}function ho(n){return typeof n=="number"&&n==W(n)}function wr(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=pt}function Q(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function j(n){return n!=null&&typeof n=="object"}var go=Tu?En(Tu):ql;function Gg(n,t){return n===t||ai(n,t,bi(t))}function kg(n,t,e){return e=typeof e=="function"?e:i,ai(n,t,bi(t),e)}function $g(n){return po(n)&&n!=+n}function qg(n){if(Rc(n))throw new L(C);return us(n)}function zg(n){return n===null}function Hg(n){return n==null}function po(n){return typeof n=="number"||j(n)&&_n(n)==ue}function Ce(n){if(!j(n)||_n(n)!=rt)return!1;var t=He(n);if(t===null)return!0;var e=z.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&ke.call(e)==kf}var Ui=Pu?En(Pu):zl;function Kg(n){return ho(n)&&n>=-pt&&n<=pt}var _o=Eu?En(Eu):Hl;function mr(n){return typeof n=="string"||!O(n)&&j(n)&&_n(n)==oe}function Ln(n){return typeof n=="symbol"||j(n)&&_n(n)==Oe}var Qt=Iu?En(Iu):Kl;function Jg(n){return n===i}function Yg(n){return j(n)&&gn(n)==ae}function Zg(n){return j(n)&&_n(n)==la}var Xg=fr(li),Qg=fr(function(n,t){return n<=t});function vo(n){if(!n)return[];if(Sn(n))return mr(n)?Yn(n):xn(n);if(ce&&n[ce])return Ef(n[ce]());var t=gn(n),e=t==Kn?Qr:t==Jn?Ne:Vt;return e(n)}function ct(n){if(!n)return n===0?n:0;if(n=qn(n),n===Tt||n===-Tt){var t=n<0?-1:1;return t*ta}return n===n?n:0}function W(n){var t=ct(n),e=t%1;return t===t?e?t-e:t:0}function wo(n){return n?Ot(W(n),0,Vn):0}function qn(n){if(typeof n=="number")return n;if(Ln(n))return Pe;if(Q(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=Q(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=Uu(n);var e=La.test(n);return e||Wa.test(n)?hf(n.slice(2),e?2:8):Ia.test(n)?Pe:+n}function mo(n){return nt(n,An(n))}function Vg(n){return n?Ot(W(n),-pt,pt):n===0?n:0}function q(n){return n==null?"":In(n)}var jg=Yt(function(n,t){if(Se(t)||Sn(t)){nt(t,fn(t),n);return}for(var e in t)z.call(t,e)&&_e(n,e,t[e])}),yo=Yt(function(n,t){nt(t,An(t),n)}),yr=Yt(function(n,t,e,r){nt(t,An(t),n,r)}),np=Yt(function(n,t,e,r){nt(t,fn(t),n,r)}),tp=at(ri);function ep(n,t){var e=Jt(n);return t==null?e:Qu(e,t)}var rp=U(function(n,t){n=J(n);var e=-1,r=t.length,u=r>2?t[2]:i;for(u&&vn(t[0],t[1],u)&&(r=1);++e<r;)for(var o=t[e],a=An(o),f=-1,c=a.length;++f<c;){var d=a[f],_=n[d];(_===i||Xn(_,zt[d])&&!z.call(n,d))&&(n[d]=o[d])}return n}),ip=U(function(n){return n.push(i,Us),Pn(xo,i,n)});function up(n,t){return Ou(n,R(t,3),jn)}function sp(n,t){return Ou(n,R(t,3),ui)}function op(n,t){return n==null?n:ii(n,R(t,3),An)}function ap(n,t){return n==null?n:es(n,R(t,3),An)}function fp(n,t){return n&&jn(n,R(t,3))}function lp(n,t){return n&&ui(n,R(t,3))}function cp(n){return n==null?[]:tr(n,fn(n))}function hp(n){return n==null?[]:tr(n,An(n))}function Di(n,t,e){var r=n==null?i:Wt(n,t);return r===i?e:r}function gp(n,t){return n!=null&&Bs(n,t,Ul)}function Ni(n,t){return n!=null&&Bs(n,t,Dl)}var pp=Ls(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=$e.call(t)),n[t]=e},Gi(Cn)),dp=Ls(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=$e.call(t)),z.call(n,t)?n[t].push(e):n[t]=[e]},R),_p=U(we);function fn(n){return Sn(n)?Zu(n):fi(n)}function An(n){return Sn(n)?Zu(n,!0):Jl(n)}function vp(n,t){var e={};return t=R(t,3),jn(n,function(r,u,o){st(e,t(r,u,o),r)}),e}function wp(n,t){var e={};return t=R(t,3),jn(n,function(r,u,o){st(e,u,t(r,u,o))}),e}var mp=Yt(function(n,t,e){er(n,t,e)}),xo=Yt(function(n,t,e,r){er(n,t,e,r)}),yp=at(function(n,t){var e={};if(n==null)return e;var r=!1;t=X(t,function(o){return o=xt(o,n),r||(r=o.length>1),o}),nt(n,Ai(n),e),r&&(e=Gn(e,un|Rn|pn,pc));for(var u=t.length;u--;)di(e,t[u]);return e});function xp(n,t){return So(n,vr(R(t)))}var Sp=at(function(n,t){return n==null?{}:Zl(n,t)});function So(n,t){if(n==null)return{};var e=X(Ai(n),function(r){return[r]});return t=R(t),hs(n,e,function(r,u){return t(r,u[0])})}function Ap(n,t,e){t=xt(t,n);var r=-1,u=t.length;for(u||(u=1,n=i);++r<u;){var o=n==null?i:n[tt(t[r])];o===i&&(r=u,o=e),n=lt(o)?o.call(n):o}return n}function Cp(n,t,e){return n==null?n:ye(n,t,e)}function bp(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:ye(n,t,e,r)}var Ao=Ms(fn),Co=Ms(An);function Rp(n,t,e){var r=O(n),u=r||At(n)||Qt(n);if(t=R(t,4),e==null){var o=n&&n.constructor;u?e=r?new o:[]:Q(n)?e=lt(o)?Jt(He(n)):{}:e={}}return(u?Dn:jn)(n,function(a,f,c){return t(e,a,f,c)}),e}function Tp(n,t){return n==null?!0:di(n,t)}function Pp(n,t,e){return n==null?n:vs(n,t,wi(e))}function Ep(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:vs(n,t,wi(e),r)}function Vt(n){return n==null?[]:Xr(n,fn(n))}function Ip(n){return n==null?[]:Xr(n,An(n))}function Lp(n,t,e){return e===i&&(e=t,t=i),e!==i&&(e=qn(e),e=e===e?e:0),t!==i&&(t=qn(t),t=t===t?t:0),Ot(qn(n),t,e)}function Op(n,t,e){return t=ct(t),e===i?(e=t,t=0):e=ct(e),n=qn(n),Nl(n,t,e)}function Wp(n,t,e){if(e&&typeof e!="boolean"&&vn(n,t,e)&&(t=e=i),e===i&&(typeof t=="boolean"?(e=t,t=i):typeof n=="boolean"&&(e=n,n=i)),n===i&&t===i?(n=0,t=1):(n=ct(n),t===i?(t=n,n=0):t=ct(t)),n>t){var r=n;n=t,t=r}if(e||n%1||t%1){var u=Ju();return hn(n+u*(t-n+cf("1e-"+((u+"").length-1))),t)}return hi(n,t)}var Mp=Zt(function(n,t,e){return t=t.toLowerCase(),n+(e?bo(t):t)});function bo(n){return Bi(q(n).toLowerCase())}function Ro(n){return n=q(n),n&&n.replace(Fa,Cf).replace(nf,"")}function Fp(n,t,e){n=q(n),t=In(t);var r=n.length;e=e===i?r:Ot(W(e),0,r);var u=e;return e-=t.length,e>=0&&n.slice(e,u)==t}function Up(n){return n=q(n),n&&da.test(n)?n.replace(eu,bf):n}function Dp(n){return n=q(n),n&&xa.test(n)?n.replace(Mr,"\\$&"):n}var Np=Zt(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()}),Bp=Zt(function(n,t,e){return n+(e?" ":"")+t.toLowerCase()}),Gp=Ps("toLowerCase");function kp(n,t,e){n=q(n),t=W(t);var r=t?$t(n):0;if(!t||r>=t)return n;var u=(t-r)/2;return ar(Ze(u),e)+n+ar(Ye(u),e)}function $p(n,t,e){n=q(n),t=W(t);var r=t?$t(n):0;return t&&r<t?n+ar(t-r,e):n}function qp(n,t,e){n=q(n),t=W(t);var r=t?$t(n):0;return t&&r<t?ar(t-r,e)+n:n}function zp(n,t,e){return e||t==null?t=0:t&&(t=+t),Qf(q(n).replace(Fr,""),t||0)}function Hp(n,t,e){return(e?vn(n,t,e):t===i)?t=1:t=W(t),gi(q(n),t)}function Kp(){var n=arguments,t=q(n[0]);return n.length<3?t:t.replace(n[1],n[2])}var Jp=Zt(function(n,t,e){return n+(e?"_":"")+t.toLowerCase()});function Yp(n,t,e){return e&&typeof e!="number"&&vn(n,t,e)&&(t=e=i),e=e===i?Vn:e>>>0,e?(n=q(n),n&&(typeof t=="string"||t!=null&&!Ui(t))&&(t=In(t),!t&&kt(n))?St(Yn(n),0,e):n.split(t,e)):[]}var Zp=Zt(function(n,t,e){return n+(e?" ":"")+Bi(t)});function Xp(n,t,e){return n=q(n),e=e==null?0:Ot(W(e),0,n.length),t=In(t),n.slice(e,e+t.length)==t}function Qp(n,t,e){var r=s.templateSettings;e&&vn(n,t,e)&&(t=i),n=q(n),t=yr({},t,r,Fs);var u=yr({},t.imports,r.imports,Fs),o=fn(u),a=Xr(u,o),f,c,d=0,_=t.interpolate||We,v="__p += '",x=Vr((t.escape||We).source+"|"+_.source+"|"+(_===ru?Ea:We).source+"|"+(t.evaluate||We).source+"|$","g"),A="//# sourceURL="+(z.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++sf+"]")+`
19
- `;n.replace(x,function(P,D,B,On,wn,Wn){return B||(B=On),v+=n.slice(d,Wn).replace(Ua,Rf),D&&(f=!0,v+=`' +
20
- __e(`+D+`) +
21
- '`),wn&&(c=!0,v+=`';
22
- `+wn+`;
23
- __p += '`),B&&(v+=`' +
24
- ((__t = (`+B+`)) == null ? '' : __t) +
25
- '`),d=Wn+P.length,P}),v+=`';
26
- `;var T=z.call(t,"variable")&&t.variable;if(!T)v=`with (obj) {
27
- `+v+`
20
+ */ir.exports,function(n,i){(function(){var r,a="4.17.21",h=200,f="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",p="Expected a function",m="Invalid `variable` option passed into `_.template`",w="__lodash_hash_undefined__",I=500,P="__lodash_placeholder__",C=1,A=2,R=4,K=1,At=2,gt=1,ct=2,ar=4,Qt=8,We=16,jt=32,$e=64,q=128,ht=256,Q=512,Ft=30,ft="...",Ut=800,it=16,St=1,Bl=2,kl=3,qe=1/0,Te=9007199254740991,Dl=17976931348623157e292,ur=NaN,ce=4294967295,Nl=ce-1,Fl=ce>>>1,Ul=[["ary",q],["bind",gt],["bindKey",ct],["curry",Qt],["curryRight",We],["flip",Q],["partial",jt],["partialRight",$e],["rearg",ht]],sn="[object Arguments]",cr="[object Array]",Wl="[object AsyncFunction]",Rn="[object Boolean]",Mn="[object Date]",$l="[object DOMException]",hr="[object Error]",lr="[object Function]",Do="[object GeneratorFunction]",te="[object Map]",Pn="[object Number]",ql="[object Null]",de="[object Object]",No="[object Promise]",zl="[object Proxy]",On="[object RegExp]",ee="[object Set]",Ln="[object String]",fr="[object Symbol]",Hl="[object Undefined]",Bn="[object WeakMap]",Jl="[object WeakSet]",kn="[object ArrayBuffer]",on="[object DataView]",vs="[object Float32Array]",ws="[object Float64Array]",ys="[object Int8Array]",Ss="[object Int16Array]",Es="[object Int32Array]",xs="[object Uint8Array]",Ts="[object Uint8ClampedArray]",As="[object Uint16Array]",Cs="[object Uint32Array]",Gl=/\b__p \+= '';/g,Kl=/\b(__p \+=) '' \+/g,Yl=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Fo=/&(?:amp|lt|gt|quot|#39);/g,Uo=/[&<>"']/g,Vl=RegExp(Fo.source),Zl=RegExp(Uo.source),Xl=/<%-([\s\S]+?)%>/g,Ql=/<%([\s\S]+?)%>/g,Wo=/<%=([\s\S]+?)%>/g,jl=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,tf=/^\w*$/,ef=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Is=/[\\^$.*+?()[\]{}|]/g,nf=RegExp(Is.source),Rs=/^\s+/,rf=/\s/,sf=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,of=/\{\n\/\* \[wrapped with (.+)\] \*/,af=/,? & /,uf=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,cf=/[()=,{}\[\]\/\s]/,hf=/\\(\\)?/g,lf=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,$o=/\w*$/,ff=/^[-+]0x[0-9a-f]+$/i,df=/^0b[01]+$/i,pf=/^\[object .+?Constructor\]$/,gf=/^0o[0-7]+$/i,_f=/^(?:0|[1-9]\d*)$/,bf=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,dr=/($^)/,mf=/['\n\r\u2028\u2029\\]/g,pr="\\ud800-\\udfff",vf="\\u0300-\\u036f",wf="\\ufe20-\\ufe2f",yf="\\u20d0-\\u20ff",qo=vf+wf+yf,zo="\\u2700-\\u27bf",Ho="a-z\\xdf-\\xf6\\xf8-\\xff",Sf="\\xac\\xb1\\xd7\\xf7",Ef="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",xf="\\u2000-\\u206f",Tf=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Jo="A-Z\\xc0-\\xd6\\xd8-\\xde",Go="\\ufe0e\\ufe0f",Ko=Sf+Ef+xf+Tf,Ms="['’]",Af="["+pr+"]",Yo="["+Ko+"]",gr="["+qo+"]",Vo="\\d+",Cf="["+zo+"]",Zo="["+Ho+"]",Xo="[^"+pr+Ko+Vo+zo+Ho+Jo+"]",Ps="\\ud83c[\\udffb-\\udfff]",If="(?:"+gr+"|"+Ps+")",Qo="[^"+pr+"]",Os="(?:\\ud83c[\\udde6-\\uddff]){2}",Ls="[\\ud800-\\udbff][\\udc00-\\udfff]",an="["+Jo+"]",jo="\\u200d",ta="(?:"+Zo+"|"+Xo+")",Rf="(?:"+an+"|"+Xo+")",ea="(?:"+Ms+"(?:d|ll|m|re|s|t|ve))?",na="(?:"+Ms+"(?:D|LL|M|RE|S|T|VE))?",ra=If+"?",sa="["+Go+"]?",Mf="(?:"+jo+"(?:"+[Qo,Os,Ls].join("|")+")"+sa+ra+")*",Pf="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Of="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",ia=sa+ra+Mf,Lf="(?:"+[Cf,Os,Ls].join("|")+")"+ia,Bf="(?:"+[Qo+gr+"?",gr,Os,Ls,Af].join("|")+")",kf=RegExp(Ms,"g"),Df=RegExp(gr,"g"),Bs=RegExp(Ps+"(?="+Ps+")|"+Bf+ia,"g"),Nf=RegExp([an+"?"+Zo+"+"+ea+"(?="+[Yo,an,"$"].join("|")+")",Rf+"+"+na+"(?="+[Yo,an+ta,"$"].join("|")+")",an+"?"+ta+"+"+ea,an+"+"+na,Of,Pf,Vo,Lf].join("|"),"g"),Ff=RegExp("["+jo+pr+qo+Go+"]"),Uf=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Wf=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],$f=-1,et={};et[vs]=et[ws]=et[ys]=et[Ss]=et[Es]=et[xs]=et[Ts]=et[As]=et[Cs]=!0,et[sn]=et[cr]=et[kn]=et[Rn]=et[on]=et[Mn]=et[hr]=et[lr]=et[te]=et[Pn]=et[de]=et[On]=et[ee]=et[Ln]=et[Bn]=!1;var tt={};tt[sn]=tt[cr]=tt[kn]=tt[on]=tt[Rn]=tt[Mn]=tt[vs]=tt[ws]=tt[ys]=tt[Ss]=tt[Es]=tt[te]=tt[Pn]=tt[de]=tt[On]=tt[ee]=tt[Ln]=tt[fr]=tt[xs]=tt[Ts]=tt[As]=tt[Cs]=!0,tt[hr]=tt[lr]=tt[Bn]=!1;var qf={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},zf={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Hf={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Jf={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Gf=parseFloat,Kf=parseInt,oa=typeof oe=="object"&&oe&&oe.Object===Object&&oe,Yf=typeof self=="object"&&self&&self.Object===Object&&self,bt=oa||Yf||Function("return this")(),ks=i&&!i.nodeType&&i,ze=ks&&!0&&n&&!n.nodeType&&n,aa=ze&&ze.exports===ks,Ds=aa&&oa.process,Wt=function(){try{var _=ze&&ze.require&&ze.require("util").types;return _||Ds&&Ds.binding&&Ds.binding("util")}catch{}}(),ua=Wt&&Wt.isArrayBuffer,ca=Wt&&Wt.isDate,ha=Wt&&Wt.isMap,la=Wt&&Wt.isRegExp,fa=Wt&&Wt.isSet,da=Wt&&Wt.isTypedArray;function Ot(_,y,v){switch(v.length){case 0:return _.call(y);case 1:return _.call(y,v[0]);case 2:return _.call(y,v[0],v[1]);case 3:return _.call(y,v[0],v[1],v[2])}return _.apply(y,v)}function Vf(_,y,v,O){for(var F=-1,V=_==null?0:_.length;++F<V;){var dt=_[F];y(O,dt,v(dt),_)}return O}function $t(_,y){for(var v=-1,O=_==null?0:_.length;++v<O&&y(_[v],v,_)!==!1;);return _}function Zf(_,y){for(var v=_==null?0:_.length;v--&&y(_[v],v,_)!==!1;);return _}function pa(_,y){for(var v=-1,O=_==null?0:_.length;++v<O;)if(!y(_[v],v,_))return!1;return!0}function Ae(_,y){for(var v=-1,O=_==null?0:_.length,F=0,V=[];++v<O;){var dt=_[v];y(dt,v,_)&&(V[F++]=dt)}return V}function _r(_,y){var v=_==null?0:_.length;return!!v&&un(_,y,0)>-1}function Ns(_,y,v){for(var O=-1,F=_==null?0:_.length;++O<F;)if(v(y,_[O]))return!0;return!1}function nt(_,y){for(var v=-1,O=_==null?0:_.length,F=Array(O);++v<O;)F[v]=y(_[v],v,_);return F}function Ce(_,y){for(var v=-1,O=y.length,F=_.length;++v<O;)_[F+v]=y[v];return _}function Fs(_,y,v,O){var F=-1,V=_==null?0:_.length;for(O&&V&&(v=_[++F]);++F<V;)v=y(v,_[F],F,_);return v}function Xf(_,y,v,O){var F=_==null?0:_.length;for(O&&F&&(v=_[--F]);F--;)v=y(v,_[F],F,_);return v}function Us(_,y){for(var v=-1,O=_==null?0:_.length;++v<O;)if(y(_[v],v,_))return!0;return!1}var Qf=Ws("length");function jf(_){return _.split("")}function td(_){return _.match(uf)||[]}function ga(_,y,v){var O;return v(_,function(F,V,dt){if(y(F,V,dt))return O=V,!1}),O}function br(_,y,v,O){for(var F=_.length,V=v+(O?1:-1);O?V--:++V<F;)if(y(_[V],V,_))return V;return-1}function un(_,y,v){return y===y?fd(_,y,v):br(_,_a,v)}function ed(_,y,v,O){for(var F=v-1,V=_.length;++F<V;)if(O(_[F],y))return F;return-1}function _a(_){return _!==_}function ba(_,y){var v=_==null?0:_.length;return v?qs(_,y)/v:ur}function Ws(_){return function(y){return y==null?r:y[_]}}function $s(_){return function(y){return _==null?r:_[y]}}function ma(_,y,v,O,F){return F(_,function(V,dt,j){v=O?(O=!1,V):y(v,V,dt,j)}),v}function nd(_,y){var v=_.length;for(_.sort(y);v--;)_[v]=_[v].value;return _}function qs(_,y){for(var v,O=-1,F=_.length;++O<F;){var V=y(_[O]);V!==r&&(v=v===r?V:v+V)}return v}function zs(_,y){for(var v=-1,O=Array(_);++v<_;)O[v]=y(v);return O}function rd(_,y){return nt(y,function(v){return[v,_[v]]})}function va(_){return _&&_.slice(0,Ea(_)+1).replace(Rs,"")}function Lt(_){return function(y){return _(y)}}function Hs(_,y){return nt(y,function(v){return _[v]})}function Dn(_,y){return _.has(y)}function wa(_,y){for(var v=-1,O=_.length;++v<O&&un(y,_[v],0)>-1;);return v}function ya(_,y){for(var v=_.length;v--&&un(y,_[v],0)>-1;);return v}function sd(_,y){for(var v=_.length,O=0;v--;)_[v]===y&&++O;return O}var id=$s(qf),od=$s(zf);function ad(_){return"\\"+Jf[_]}function ud(_,y){return _==null?r:_[y]}function cn(_){return Ff.test(_)}function cd(_){return Uf.test(_)}function hd(_){for(var y,v=[];!(y=_.next()).done;)v.push(y.value);return v}function Js(_){var y=-1,v=Array(_.size);return _.forEach(function(O,F){v[++y]=[F,O]}),v}function Sa(_,y){return function(v){return _(y(v))}}function Ie(_,y){for(var v=-1,O=_.length,F=0,V=[];++v<O;){var dt=_[v];(dt===y||dt===P)&&(_[v]=P,V[F++]=v)}return V}function mr(_){var y=-1,v=Array(_.size);return _.forEach(function(O){v[++y]=O}),v}function ld(_){var y=-1,v=Array(_.size);return _.forEach(function(O){v[++y]=[O,O]}),v}function fd(_,y,v){for(var O=v-1,F=_.length;++O<F;)if(_[O]===y)return O;return-1}function dd(_,y,v){for(var O=v+1;O--;)if(_[O]===y)return O;return O}function hn(_){return cn(_)?gd(_):Qf(_)}function ne(_){return cn(_)?_d(_):jf(_)}function Ea(_){for(var y=_.length;y--&&rf.test(_.charAt(y)););return y}var pd=$s(Hf);function gd(_){for(var y=Bs.lastIndex=0;Bs.test(_);)++y;return y}function _d(_){return _.match(Bs)||[]}function bd(_){return _.match(Nf)||[]}var md=function _(y){y=y==null?bt:ln.defaults(bt.Object(),y,ln.pick(bt,Wf));var v=y.Array,O=y.Date,F=y.Error,V=y.Function,dt=y.Math,j=y.Object,Gs=y.RegExp,vd=y.String,qt=y.TypeError,vr=v.prototype,wd=V.prototype,fn=j.prototype,wr=y["__core-js_shared__"],yr=wd.toString,X=fn.hasOwnProperty,yd=0,xa=function(){var t=/[^.]+$/.exec(wr&&wr.keys&&wr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Sr=fn.toString,Sd=yr.call(j),Ed=bt._,xd=Gs("^"+yr.call(X).replace(Is,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Er=aa?y.Buffer:r,Re=y.Symbol,xr=y.Uint8Array,Ta=Er?Er.allocUnsafe:r,Tr=Sa(j.getPrototypeOf,j),Aa=j.create,Ca=fn.propertyIsEnumerable,Ar=vr.splice,Ia=Re?Re.isConcatSpreadable:r,Nn=Re?Re.iterator:r,He=Re?Re.toStringTag:r,Cr=function(){try{var t=Ve(j,"defineProperty");return t({},"",{}),t}catch{}}(),Td=y.clearTimeout!==bt.clearTimeout&&y.clearTimeout,Ad=O&&O.now!==bt.Date.now&&O.now,Cd=y.setTimeout!==bt.setTimeout&&y.setTimeout,Ir=dt.ceil,Rr=dt.floor,Ks=j.getOwnPropertySymbols,Id=Er?Er.isBuffer:r,Ra=y.isFinite,Rd=vr.join,Md=Sa(j.keys,j),pt=dt.max,vt=dt.min,Pd=O.now,Od=y.parseInt,Ma=dt.random,Ld=vr.reverse,Ys=Ve(y,"DataView"),Fn=Ve(y,"Map"),Vs=Ve(y,"Promise"),dn=Ve(y,"Set"),Un=Ve(y,"WeakMap"),Wn=Ve(j,"create"),Mr=Un&&new Un,pn={},Bd=Ze(Ys),kd=Ze(Fn),Dd=Ze(Vs),Nd=Ze(dn),Fd=Ze(Un),Pr=Re?Re.prototype:r,$n=Pr?Pr.valueOf:r,Pa=Pr?Pr.toString:r;function c(t){if(ot(t)&&!U(t)&&!(t instanceof J)){if(t instanceof zt)return t;if(X.call(t,"__wrapped__"))return Ou(t)}return new zt(t)}var gn=function(){function t(){}return function(e){if(!st(e))return{};if(Aa)return Aa(e);t.prototype=e;var s=new t;return t.prototype=r,s}}();function Or(){}function zt(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=r}c.templateSettings={escape:Xl,evaluate:Ql,interpolate:Wo,variable:"",imports:{_:c}},c.prototype=Or.prototype,c.prototype.constructor=c,zt.prototype=gn(Or.prototype),zt.prototype.constructor=zt;function J(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ce,this.__views__=[]}function Ud(){var t=new J(this.__wrapped__);return t.__actions__=Ct(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Ct(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Ct(this.__views__),t}function Wd(){if(this.__filtered__){var t=new J(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function $d(){var t=this.__wrapped__.value(),e=this.__dir__,s=U(t),o=e<0,u=s?t.length:0,l=jp(0,u,this.__views__),d=l.start,g=l.end,b=g-d,E=o?g:d-1,x=this.__iteratees__,T=x.length,M=0,L=vt(b,this.__takeCount__);if(!s||!o&&u==b&&L==b)return eu(t,this.__actions__);var D=[];t:for(;b--&&M<L;){E+=e;for(var $=-1,N=t[E];++$<T;){var H=x[$],G=H.iteratee,Dt=H.type,Tt=G(N);if(Dt==Bl)N=Tt;else if(!Tt){if(Dt==St)continue t;break t}}D[M++]=N}return D}J.prototype=gn(Or.prototype),J.prototype.constructor=J;function Je(t){var e=-1,s=t==null?0:t.length;for(this.clear();++e<s;){var o=t[e];this.set(o[0],o[1])}}function qd(){this.__data__=Wn?Wn(null):{},this.size=0}function zd(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}function Hd(t){var e=this.__data__;if(Wn){var s=e[t];return s===w?r:s}return X.call(e,t)?e[t]:r}function Jd(t){var e=this.__data__;return Wn?e[t]!==r:X.call(e,t)}function Gd(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=Wn&&e===r?w:e,this}Je.prototype.clear=qd,Je.prototype.delete=zd,Je.prototype.get=Hd,Je.prototype.has=Jd,Je.prototype.set=Gd;function pe(t){var e=-1,s=t==null?0:t.length;for(this.clear();++e<s;){var o=t[e];this.set(o[0],o[1])}}function Kd(){this.__data__=[],this.size=0}function Yd(t){var e=this.__data__,s=Lr(e,t);if(s<0)return!1;var o=e.length-1;return s==o?e.pop():Ar.call(e,s,1),--this.size,!0}function Vd(t){var e=this.__data__,s=Lr(e,t);return s<0?r:e[s][1]}function Zd(t){return Lr(this.__data__,t)>-1}function Xd(t,e){var s=this.__data__,o=Lr(s,t);return o<0?(++this.size,s.push([t,e])):s[o][1]=e,this}pe.prototype.clear=Kd,pe.prototype.delete=Yd,pe.prototype.get=Vd,pe.prototype.has=Zd,pe.prototype.set=Xd;function ge(t){var e=-1,s=t==null?0:t.length;for(this.clear();++e<s;){var o=t[e];this.set(o[0],o[1])}}function Qd(){this.size=0,this.__data__={hash:new Je,map:new(Fn||pe),string:new Je}}function jd(t){var e=Jr(this,t).delete(t);return this.size-=e?1:0,e}function tp(t){return Jr(this,t).get(t)}function ep(t){return Jr(this,t).has(t)}function np(t,e){var s=Jr(this,t),o=s.size;return s.set(t,e),this.size+=s.size==o?0:1,this}ge.prototype.clear=Qd,ge.prototype.delete=jd,ge.prototype.get=tp,ge.prototype.has=ep,ge.prototype.set=np;function Ge(t){var e=-1,s=t==null?0:t.length;for(this.__data__=new ge;++e<s;)this.add(t[e])}function rp(t){return this.__data__.set(t,w),this}function sp(t){return this.__data__.has(t)}Ge.prototype.add=Ge.prototype.push=rp,Ge.prototype.has=sp;function re(t){var e=this.__data__=new pe(t);this.size=e.size}function ip(){this.__data__=new pe,this.size=0}function op(t){var e=this.__data__,s=e.delete(t);return this.size=e.size,s}function ap(t){return this.__data__.get(t)}function up(t){return this.__data__.has(t)}function cp(t,e){var s=this.__data__;if(s instanceof pe){var o=s.__data__;if(!Fn||o.length<h-1)return o.push([t,e]),this.size=++s.size,this;s=this.__data__=new ge(o)}return s.set(t,e),this.size=s.size,this}re.prototype.clear=ip,re.prototype.delete=op,re.prototype.get=ap,re.prototype.has=up,re.prototype.set=cp;function Oa(t,e){var s=U(t),o=!s&&Xe(t),u=!s&&!o&&Be(t),l=!s&&!o&&!u&&vn(t),d=s||o||u||l,g=d?zs(t.length,vd):[],b=g.length;for(var E in t)(e||X.call(t,E))&&!(d&&(E=="length"||u&&(E=="offset"||E=="parent")||l&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||ve(E,b)))&&g.push(E);return g}function La(t){var e=t.length;return e?t[oi(0,e-1)]:r}function hp(t,e){return Gr(Ct(t),Ke(e,0,t.length))}function lp(t){return Gr(Ct(t))}function Zs(t,e,s){(s!==r&&!se(t[e],s)||s===r&&!(e in t))&&_e(t,e,s)}function qn(t,e,s){var o=t[e];(!(X.call(t,e)&&se(o,s))||s===r&&!(e in t))&&_e(t,e,s)}function Lr(t,e){for(var s=t.length;s--;)if(se(t[s][0],e))return s;return-1}function fp(t,e,s,o){return Me(t,function(u,l,d){e(o,u,s(u),d)}),o}function Ba(t,e){return t&&le(e,_t(e),t)}function dp(t,e){return t&&le(e,Rt(e),t)}function _e(t,e,s){e=="__proto__"&&Cr?Cr(t,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[e]=s}function Xs(t,e){for(var s=-1,o=e.length,u=v(o),l=t==null;++s<o;)u[s]=l?r:Pi(t,e[s]);return u}function Ke(t,e,s){return t===t&&(s!==r&&(t=t<=s?t:s),e!==r&&(t=t>=e?t:e)),t}function Ht(t,e,s,o,u,l){var d,g=e&C,b=e&A,E=e&R;if(s&&(d=u?s(t,o,u,l):s(t)),d!==r)return d;if(!st(t))return t;var x=U(t);if(x){if(d=eg(t),!g)return Ct(t,d)}else{var T=wt(t),M=T==lr||T==Do;if(Be(t))return su(t,g);if(T==de||T==sn||M&&!u){if(d=b||M?{}:Eu(t),!g)return b?Hp(t,dp(d,t)):zp(t,Ba(d,t))}else{if(!tt[T])return u?t:{};d=ng(t,T,g)}}l||(l=new re);var L=l.get(t);if(L)return L;l.set(t,d),Qu(t)?t.forEach(function(N){d.add(Ht(N,e,s,N,t,l))}):Zu(t)&&t.forEach(function(N,H){d.set(H,Ht(N,e,s,H,t,l))});var D=E?b?bi:_i:b?Rt:_t,$=x?r:D(t);return $t($||t,function(N,H){$&&(H=N,N=t[H]),qn(d,H,Ht(N,e,s,H,t,l))}),d}function pp(t){var e=_t(t);return function(s){return ka(s,t,e)}}function ka(t,e,s){var o=s.length;if(t==null)return!o;for(t=j(t);o--;){var u=s[o],l=e[u],d=t[u];if(d===r&&!(u in t)||!l(d))return!1}return!0}function Da(t,e,s){if(typeof t!="function")throw new qt(p);return Vn(function(){t.apply(r,s)},e)}function zn(t,e,s,o){var u=-1,l=_r,d=!0,g=t.length,b=[],E=e.length;if(!g)return b;s&&(e=nt(e,Lt(s))),o?(l=Ns,d=!1):e.length>=h&&(l=Dn,d=!1,e=new Ge(e));t:for(;++u<g;){var x=t[u],T=s==null?x:s(x);if(x=o||x!==0?x:0,d&&T===T){for(var M=E;M--;)if(e[M]===T)continue t;b.push(x)}else l(e,T,o)||b.push(x)}return b}var Me=cu(he),Na=cu(js,!0);function gp(t,e){var s=!0;return Me(t,function(o,u,l){return s=!!e(o,u,l),s}),s}function Br(t,e,s){for(var o=-1,u=t.length;++o<u;){var l=t[o],d=e(l);if(d!=null&&(g===r?d===d&&!kt(d):s(d,g)))var g=d,b=l}return b}function _p(t,e,s,o){var u=t.length;for(s=W(s),s<0&&(s=-s>u?0:u+s),o=o===r||o>u?u:W(o),o<0&&(o+=u),o=s>o?0:tc(o);s<o;)t[s++]=e;return t}function Fa(t,e){var s=[];return Me(t,function(o,u,l){e(o,u,l)&&s.push(o)}),s}function mt(t,e,s,o,u){var l=-1,d=t.length;for(s||(s=sg),u||(u=[]);++l<d;){var g=t[l];e>0&&s(g)?e>1?mt(g,e-1,s,o,u):Ce(u,g):o||(u[u.length]=g)}return u}var Qs=hu(),Ua=hu(!0);function he(t,e){return t&&Qs(t,e,_t)}function js(t,e){return t&&Ua(t,e,_t)}function kr(t,e){return Ae(e,function(s){return we(t[s])})}function Ye(t,e){e=Oe(e,t);for(var s=0,o=e.length;t!=null&&s<o;)t=t[fe(e[s++])];return s&&s==o?t:r}function Wa(t,e,s){var o=e(t);return U(t)?o:Ce(o,s(t))}function Et(t){return t==null?t===r?Hl:ql:He&&He in j(t)?Qp(t):lg(t)}function ti(t,e){return t>e}function bp(t,e){return t!=null&&X.call(t,e)}function mp(t,e){return t!=null&&e in j(t)}function vp(t,e,s){return t>=vt(e,s)&&t<pt(e,s)}function ei(t,e,s){for(var o=s?Ns:_r,u=t[0].length,l=t.length,d=l,g=v(l),b=1/0,E=[];d--;){var x=t[d];d&&e&&(x=nt(x,Lt(e))),b=vt(x.length,b),g[d]=!s&&(e||u>=120&&x.length>=120)?new Ge(d&&x):r}x=t[0];var T=-1,M=g[0];t:for(;++T<u&&E.length<b;){var L=x[T],D=e?e(L):L;if(L=s||L!==0?L:0,!(M?Dn(M,D):o(E,D,s))){for(d=l;--d;){var $=g[d];if(!($?Dn($,D):o(t[d],D,s)))continue t}M&&M.push(D),E.push(L)}}return E}function wp(t,e,s,o){return he(t,function(u,l,d){e(o,s(u),l,d)}),o}function Hn(t,e,s){e=Oe(e,t),t=Cu(t,e);var o=t==null?t:t[fe(Gt(e))];return o==null?r:Ot(o,t,s)}function $a(t){return ot(t)&&Et(t)==sn}function yp(t){return ot(t)&&Et(t)==kn}function Sp(t){return ot(t)&&Et(t)==Mn}function Jn(t,e,s,o,u){return t===e?!0:t==null||e==null||!ot(t)&&!ot(e)?t!==t&&e!==e:Ep(t,e,s,o,Jn,u)}function Ep(t,e,s,o,u,l){var d=U(t),g=U(e),b=d?cr:wt(t),E=g?cr:wt(e);b=b==sn?de:b,E=E==sn?de:E;var x=b==de,T=E==de,M=b==E;if(M&&Be(t)){if(!Be(e))return!1;d=!0,x=!1}if(M&&!x)return l||(l=new re),d||vn(t)?wu(t,e,s,o,u,l):Zp(t,e,b,s,o,u,l);if(!(s&K)){var L=x&&X.call(t,"__wrapped__"),D=T&&X.call(e,"__wrapped__");if(L||D){var $=L?t.value():t,N=D?e.value():e;return l||(l=new re),u($,N,s,o,l)}}return M?(l||(l=new re),Xp(t,e,s,o,u,l)):!1}function xp(t){return ot(t)&&wt(t)==te}function ni(t,e,s,o){var u=s.length,l=u,d=!o;if(t==null)return!l;for(t=j(t);u--;){var g=s[u];if(d&&g[2]?g[1]!==t[g[0]]:!(g[0]in t))return!1}for(;++u<l;){g=s[u];var b=g[0],E=t[b],x=g[1];if(d&&g[2]){if(E===r&&!(b in t))return!1}else{var T=new re;if(o)var M=o(E,x,b,t,e,T);if(!(M===r?Jn(x,E,K|At,o,T):M))return!1}}return!0}function qa(t){if(!st(t)||og(t))return!1;var e=we(t)?xd:pf;return e.test(Ze(t))}function Tp(t){return ot(t)&&Et(t)==On}function Ap(t){return ot(t)&&wt(t)==ee}function Cp(t){return ot(t)&&Qr(t.length)&&!!et[Et(t)]}function za(t){return typeof t=="function"?t:t==null?Mt:typeof t=="object"?U(t)?Ga(t[0],t[1]):Ja(t):lc(t)}function ri(t){if(!Yn(t))return Md(t);var e=[];for(var s in j(t))X.call(t,s)&&s!="constructor"&&e.push(s);return e}function Ip(t){if(!st(t))return hg(t);var e=Yn(t),s=[];for(var o in t)o=="constructor"&&(e||!X.call(t,o))||s.push(o);return s}function si(t,e){return t<e}function Ha(t,e){var s=-1,o=It(t)?v(t.length):[];return Me(t,function(u,l,d){o[++s]=e(u,l,d)}),o}function Ja(t){var e=vi(t);return e.length==1&&e[0][2]?Tu(e[0][0],e[0][1]):function(s){return s===t||ni(s,t,e)}}function Ga(t,e){return yi(t)&&xu(e)?Tu(fe(t),e):function(s){var o=Pi(s,t);return o===r&&o===e?Oi(s,t):Jn(e,o,K|At)}}function Dr(t,e,s,o,u){t!==e&&Qs(e,function(l,d){if(u||(u=new re),st(l))Rp(t,e,d,s,Dr,o,u);else{var g=o?o(Ei(t,d),l,d+"",t,e,u):r;g===r&&(g=l),Zs(t,d,g)}},Rt)}function Rp(t,e,s,o,u,l,d){var g=Ei(t,s),b=Ei(e,s),E=d.get(b);if(E){Zs(t,s,E);return}var x=l?l(g,b,s+"",t,e,d):r,T=x===r;if(T){var M=U(b),L=!M&&Be(b),D=!M&&!L&&vn(b);x=b,M||L||D?U(g)?x=g:at(g)?x=Ct(g):L?(T=!1,x=su(b,!0)):D?(T=!1,x=iu(b,!0)):x=[]:Zn(b)||Xe(b)?(x=g,Xe(g)?x=ec(g):(!st(g)||we(g))&&(x=Eu(b))):T=!1}T&&(d.set(b,x),u(x,b,o,l,d),d.delete(b)),Zs(t,s,x)}function Ka(t,e){var s=t.length;if(s)return e+=e<0?s:0,ve(e,s)?t[e]:r}function Ya(t,e,s){e.length?e=nt(e,function(l){return U(l)?function(d){return Ye(d,l.length===1?l[0]:l)}:l}):e=[Mt];var o=-1;e=nt(e,Lt(k()));var u=Ha(t,function(l,d,g){var b=nt(e,function(E){return E(l)});return{criteria:b,index:++o,value:l}});return nd(u,function(l,d){return qp(l,d,s)})}function Mp(t,e){return Va(t,e,function(s,o){return Oi(t,o)})}function Va(t,e,s){for(var o=-1,u=e.length,l={};++o<u;){var d=e[o],g=Ye(t,d);s(g,d)&&Gn(l,Oe(d,t),g)}return l}function Pp(t){return function(e){return Ye(e,t)}}function ii(t,e,s,o){var u=o?ed:un,l=-1,d=e.length,g=t;for(t===e&&(e=Ct(e)),s&&(g=nt(t,Lt(s)));++l<d;)for(var b=0,E=e[l],x=s?s(E):E;(b=u(g,x,b,o))>-1;)g!==t&&Ar.call(g,b,1),Ar.call(t,b,1);return t}function Za(t,e){for(var s=t?e.length:0,o=s-1;s--;){var u=e[s];if(s==o||u!==l){var l=u;ve(u)?Ar.call(t,u,1):ci(t,u)}}return t}function oi(t,e){return t+Rr(Ma()*(e-t+1))}function Op(t,e,s,o){for(var u=-1,l=pt(Ir((e-t)/(s||1)),0),d=v(l);l--;)d[o?l:++u]=t,t+=s;return d}function ai(t,e){var s="";if(!t||e<1||e>Te)return s;do e%2&&(s+=t),e=Rr(e/2),e&&(t+=t);while(e);return s}function z(t,e){return xi(Au(t,e,Mt),t+"")}function Lp(t){return La(wn(t))}function Bp(t,e){var s=wn(t);return Gr(s,Ke(e,0,s.length))}function Gn(t,e,s,o){if(!st(t))return t;e=Oe(e,t);for(var u=-1,l=e.length,d=l-1,g=t;g!=null&&++u<l;){var b=fe(e[u]),E=s;if(b==="__proto__"||b==="constructor"||b==="prototype")return t;if(u!=d){var x=g[b];E=o?o(x,b,g):r,E===r&&(E=st(x)?x:ve(e[u+1])?[]:{})}qn(g,b,E),g=g[b]}return t}var Xa=Mr?function(t,e){return Mr.set(t,e),t}:Mt,kp=Cr?function(t,e){return Cr(t,"toString",{configurable:!0,enumerable:!1,value:Bi(e),writable:!0})}:Mt;function Dp(t){return Gr(wn(t))}function Jt(t,e,s){var o=-1,u=t.length;e<0&&(e=-e>u?0:u+e),s=s>u?u:s,s<0&&(s+=u),u=e>s?0:s-e>>>0,e>>>=0;for(var l=v(u);++o<u;)l[o]=t[o+e];return l}function Np(t,e){var s;return Me(t,function(o,u,l){return s=e(o,u,l),!s}),!!s}function Nr(t,e,s){var o=0,u=t==null?o:t.length;if(typeof e=="number"&&e===e&&u<=Fl){for(;o<u;){var l=o+u>>>1,d=t[l];d!==null&&!kt(d)&&(s?d<=e:d<e)?o=l+1:u=l}return u}return ui(t,e,Mt,s)}function ui(t,e,s,o){var u=0,l=t==null?0:t.length;if(l===0)return 0;e=s(e);for(var d=e!==e,g=e===null,b=kt(e),E=e===r;u<l;){var x=Rr((u+l)/2),T=s(t[x]),M=T!==r,L=T===null,D=T===T,$=kt(T);if(d)var N=o||D;else E?N=D&&(o||M):g?N=D&&M&&(o||!L):b?N=D&&M&&!L&&(o||!$):L||$?N=!1:N=o?T<=e:T<e;N?u=x+1:l=x}return vt(l,Nl)}function Qa(t,e){for(var s=-1,o=t.length,u=0,l=[];++s<o;){var d=t[s],g=e?e(d):d;if(!s||!se(g,b)){var b=g;l[u++]=d===0?0:d}}return l}function ja(t){return typeof t=="number"?t:kt(t)?ur:+t}function Bt(t){if(typeof t=="string")return t;if(U(t))return nt(t,Bt)+"";if(kt(t))return Pa?Pa.call(t):"";var e=t+"";return e=="0"&&1/t==-qe?"-0":e}function Pe(t,e,s){var o=-1,u=_r,l=t.length,d=!0,g=[],b=g;if(s)d=!1,u=Ns;else if(l>=h){var E=e?null:Yp(t);if(E)return mr(E);d=!1,u=Dn,b=new Ge}else b=e?[]:g;t:for(;++o<l;){var x=t[o],T=e?e(x):x;if(x=s||x!==0?x:0,d&&T===T){for(var M=b.length;M--;)if(b[M]===T)continue t;e&&b.push(T),g.push(x)}else u(b,T,s)||(b!==g&&b.push(T),g.push(x))}return g}function ci(t,e){return e=Oe(e,t),t=Cu(t,e),t==null||delete t[fe(Gt(e))]}function tu(t,e,s,o){return Gn(t,e,s(Ye(t,e)),o)}function Fr(t,e,s,o){for(var u=t.length,l=o?u:-1;(o?l--:++l<u)&&e(t[l],l,t););return s?Jt(t,o?0:l,o?l+1:u):Jt(t,o?l+1:0,o?u:l)}function eu(t,e){var s=t;return s instanceof J&&(s=s.value()),Fs(e,function(o,u){return u.func.apply(u.thisArg,Ce([o],u.args))},s)}function hi(t,e,s){var o=t.length;if(o<2)return o?Pe(t[0]):[];for(var u=-1,l=v(o);++u<o;)for(var d=t[u],g=-1;++g<o;)g!=u&&(l[u]=zn(l[u]||d,t[g],e,s));return Pe(mt(l,1),e,s)}function nu(t,e,s){for(var o=-1,u=t.length,l=e.length,d={};++o<u;){var g=o<l?e[o]:r;s(d,t[o],g)}return d}function li(t){return at(t)?t:[]}function fi(t){return typeof t=="function"?t:Mt}function Oe(t,e){return U(t)?t:yi(t,e)?[t]:Pu(Z(t))}var Fp=z;function Le(t,e,s){var o=t.length;return s=s===r?o:s,!e&&s>=o?t:Jt(t,e,s)}var ru=Td||function(t){return bt.clearTimeout(t)};function su(t,e){if(e)return t.slice();var s=t.length,o=Ta?Ta(s):new t.constructor(s);return t.copy(o),o}function di(t){var e=new t.constructor(t.byteLength);return new xr(e).set(new xr(t)),e}function Up(t,e){var s=e?di(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}function Wp(t){var e=new t.constructor(t.source,$o.exec(t));return e.lastIndex=t.lastIndex,e}function $p(t){return $n?j($n.call(t)):{}}function iu(t,e){var s=e?di(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}function ou(t,e){if(t!==e){var s=t!==r,o=t===null,u=t===t,l=kt(t),d=e!==r,g=e===null,b=e===e,E=kt(e);if(!g&&!E&&!l&&t>e||l&&d&&b&&!g&&!E||o&&d&&b||!s&&b||!u)return 1;if(!o&&!l&&!E&&t<e||E&&s&&u&&!o&&!l||g&&s&&u||!d&&u||!b)return-1}return 0}function qp(t,e,s){for(var o=-1,u=t.criteria,l=e.criteria,d=u.length,g=s.length;++o<d;){var b=ou(u[o],l[o]);if(b){if(o>=g)return b;var E=s[o];return b*(E=="desc"?-1:1)}}return t.index-e.index}function au(t,e,s,o){for(var u=-1,l=t.length,d=s.length,g=-1,b=e.length,E=pt(l-d,0),x=v(b+E),T=!o;++g<b;)x[g]=e[g];for(;++u<d;)(T||u<l)&&(x[s[u]]=t[u]);for(;E--;)x[g++]=t[u++];return x}function uu(t,e,s,o){for(var u=-1,l=t.length,d=-1,g=s.length,b=-1,E=e.length,x=pt(l-g,0),T=v(x+E),M=!o;++u<x;)T[u]=t[u];for(var L=u;++b<E;)T[L+b]=e[b];for(;++d<g;)(M||u<l)&&(T[L+s[d]]=t[u++]);return T}function Ct(t,e){var s=-1,o=t.length;for(e||(e=v(o));++s<o;)e[s]=t[s];return e}function le(t,e,s,o){var u=!s;s||(s={});for(var l=-1,d=e.length;++l<d;){var g=e[l],b=o?o(s[g],t[g],g,s,t):r;b===r&&(b=t[g]),u?_e(s,g,b):qn(s,g,b)}return s}function zp(t,e){return le(t,wi(t),e)}function Hp(t,e){return le(t,yu(t),e)}function Ur(t,e){return function(s,o){var u=U(s)?Vf:fp,l=e?e():{};return u(s,t,k(o,2),l)}}function _n(t){return z(function(e,s){var o=-1,u=s.length,l=u>1?s[u-1]:r,d=u>2?s[2]:r;for(l=t.length>3&&typeof l=="function"?(u--,l):r,d&&xt(s[0],s[1],d)&&(l=u<3?r:l,u=1),e=j(e);++o<u;){var g=s[o];g&&t(e,g,o,l)}return e})}function cu(t,e){return function(s,o){if(s==null)return s;if(!It(s))return t(s,o);for(var u=s.length,l=e?u:-1,d=j(s);(e?l--:++l<u)&&o(d[l],l,d)!==!1;);return s}}function hu(t){return function(e,s,o){for(var u=-1,l=j(e),d=o(e),g=d.length;g--;){var b=d[t?g:++u];if(s(l[b],b,l)===!1)break}return e}}function Jp(t,e,s){var o=e&gt,u=Kn(t);function l(){var d=this&&this!==bt&&this instanceof l?u:t;return d.apply(o?s:this,arguments)}return l}function lu(t){return function(e){e=Z(e);var s=cn(e)?ne(e):r,o=s?s[0]:e.charAt(0),u=s?Le(s,1).join(""):e.slice(1);return o[t]()+u}}function bn(t){return function(e){return Fs(cc(uc(e).replace(kf,"")),t,"")}}function Kn(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var s=gn(t.prototype),o=t.apply(s,e);return st(o)?o:s}}function Gp(t,e,s){var o=Kn(t);function u(){for(var l=arguments.length,d=v(l),g=l,b=mn(u);g--;)d[g]=arguments[g];var E=l<3&&d[0]!==b&&d[l-1]!==b?[]:Ie(d,b);if(l-=E.length,l<s)return _u(t,e,Wr,u.placeholder,r,d,E,r,r,s-l);var x=this&&this!==bt&&this instanceof u?o:t;return Ot(x,this,d)}return u}function fu(t){return function(e,s,o){var u=j(e);if(!It(e)){var l=k(s,3);e=_t(e),s=function(g){return l(u[g],g,u)}}var d=t(e,s,o);return d>-1?u[l?e[d]:d]:r}}function du(t){return me(function(e){var s=e.length,o=s,u=zt.prototype.thru;for(t&&e.reverse();o--;){var l=e[o];if(typeof l!="function")throw new qt(p);if(u&&!d&&Hr(l)=="wrapper")var d=new zt([],!0)}for(o=d?o:s;++o<s;){l=e[o];var g=Hr(l),b=g=="wrapper"?mi(l):r;b&&Si(b[0])&&b[1]==(q|Qt|jt|ht)&&!b[4].length&&b[9]==1?d=d[Hr(b[0])].apply(d,b[3]):d=l.length==1&&Si(l)?d[g]():d.thru(l)}return function(){var E=arguments,x=E[0];if(d&&E.length==1&&U(x))return d.plant(x).value();for(var T=0,M=s?e[T].apply(this,E):x;++T<s;)M=e[T].call(this,M);return M}})}function Wr(t,e,s,o,u,l,d,g,b,E){var x=e&q,T=e&gt,M=e&ct,L=e&(Qt|We),D=e&Q,$=M?r:Kn(t);function N(){for(var H=arguments.length,G=v(H),Dt=H;Dt--;)G[Dt]=arguments[Dt];if(L)var Tt=mn(N),Nt=sd(G,Tt);if(o&&(G=au(G,o,u,L)),l&&(G=uu(G,l,d,L)),H-=Nt,L&&H<E){var ut=Ie(G,Tt);return _u(t,e,Wr,N.placeholder,s,G,ut,g,b,E-H)}var ie=T?s:this,Se=M?ie[t]:t;return H=G.length,g?G=fg(G,g):D&&H>1&&G.reverse(),x&&b<H&&(G.length=b),this&&this!==bt&&this instanceof N&&(Se=$||Kn(Se)),Se.apply(ie,G)}return N}function pu(t,e){return function(s,o){return wp(s,t,e(o),{})}}function $r(t,e){return function(s,o){var u;if(s===r&&o===r)return e;if(s!==r&&(u=s),o!==r){if(u===r)return o;typeof s=="string"||typeof o=="string"?(s=Bt(s),o=Bt(o)):(s=ja(s),o=ja(o)),u=t(s,o)}return u}}function pi(t){return me(function(e){return e=nt(e,Lt(k())),z(function(s){var o=this;return t(e,function(u){return Ot(u,o,s)})})})}function qr(t,e){e=e===r?" ":Bt(e);var s=e.length;if(s<2)return s?ai(e,t):e;var o=ai(e,Ir(t/hn(e)));return cn(e)?Le(ne(o),0,t).join(""):o.slice(0,t)}function Kp(t,e,s,o){var u=e&gt,l=Kn(t);function d(){for(var g=-1,b=arguments.length,E=-1,x=o.length,T=v(x+b),M=this&&this!==bt&&this instanceof d?l:t;++E<x;)T[E]=o[E];for(;b--;)T[E++]=arguments[++g];return Ot(M,u?s:this,T)}return d}function gu(t){return function(e,s,o){return o&&typeof o!="number"&&xt(e,s,o)&&(s=o=r),e=ye(e),s===r?(s=e,e=0):s=ye(s),o=o===r?e<s?1:-1:ye(o),Op(e,s,o,t)}}function zr(t){return function(e,s){return typeof e=="string"&&typeof s=="string"||(e=Kt(e),s=Kt(s)),t(e,s)}}function _u(t,e,s,o,u,l,d,g,b,E){var x=e&Qt,T=x?d:r,M=x?r:d,L=x?l:r,D=x?r:l;e|=x?jt:$e,e&=~(x?$e:jt),e&ar||(e&=-4);var $=[t,e,u,L,T,D,M,g,b,E],N=s.apply(r,$);return Si(t)&&Iu(N,$),N.placeholder=o,Ru(N,t,e)}function gi(t){var e=dt[t];return function(s,o){if(s=Kt(s),o=o==null?0:vt(W(o),292),o&&Ra(s)){var u=(Z(s)+"e").split("e"),l=e(u[0]+"e"+(+u[1]+o));return u=(Z(l)+"e").split("e"),+(u[0]+"e"+(+u[1]-o))}return e(s)}}var Yp=dn&&1/mr(new dn([,-0]))[1]==qe?function(t){return new dn(t)}:Ni;function bu(t){return function(e){var s=wt(e);return s==te?Js(e):s==ee?ld(e):rd(e,t(e))}}function be(t,e,s,o,u,l,d,g){var b=e&ct;if(!b&&typeof t!="function")throw new qt(p);var E=o?o.length:0;if(E||(e&=-97,o=u=r),d=d===r?d:pt(W(d),0),g=g===r?g:W(g),E-=u?u.length:0,e&$e){var x=o,T=u;o=u=r}var M=b?r:mi(t),L=[t,e,s,o,u,x,T,l,d,g];if(M&&cg(L,M),t=L[0],e=L[1],s=L[2],o=L[3],u=L[4],g=L[9]=L[9]===r?b?0:t.length:pt(L[9]-E,0),!g&&e&(Qt|We)&&(e&=-25),!e||e==gt)var D=Jp(t,e,s);else e==Qt||e==We?D=Gp(t,e,g):(e==jt||e==(gt|jt))&&!u.length?D=Kp(t,e,s,o):D=Wr.apply(r,L);var $=M?Xa:Iu;return Ru($(D,L),t,e)}function mu(t,e,s,o){return t===r||se(t,fn[s])&&!X.call(o,s)?e:t}function vu(t,e,s,o,u,l){return st(t)&&st(e)&&(l.set(e,t),Dr(t,e,r,vu,l),l.delete(e)),t}function Vp(t){return Zn(t)?r:t}function wu(t,e,s,o,u,l){var d=s&K,g=t.length,b=e.length;if(g!=b&&!(d&&b>g))return!1;var E=l.get(t),x=l.get(e);if(E&&x)return E==e&&x==t;var T=-1,M=!0,L=s&At?new Ge:r;for(l.set(t,e),l.set(e,t);++T<g;){var D=t[T],$=e[T];if(o)var N=d?o($,D,T,e,t,l):o(D,$,T,t,e,l);if(N!==r){if(N)continue;M=!1;break}if(L){if(!Us(e,function(H,G){if(!Dn(L,G)&&(D===H||u(D,H,s,o,l)))return L.push(G)})){M=!1;break}}else if(!(D===$||u(D,$,s,o,l))){M=!1;break}}return l.delete(t),l.delete(e),M}function Zp(t,e,s,o,u,l,d){switch(s){case on:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case kn:return!(t.byteLength!=e.byteLength||!l(new xr(t),new xr(e)));case Rn:case Mn:case Pn:return se(+t,+e);case hr:return t.name==e.name&&t.message==e.message;case On:case Ln:return t==e+"";case te:var g=Js;case ee:var b=o&K;if(g||(g=mr),t.size!=e.size&&!b)return!1;var E=d.get(t);if(E)return E==e;o|=At,d.set(t,e);var x=wu(g(t),g(e),o,u,l,d);return d.delete(t),x;case fr:if($n)return $n.call(t)==$n.call(e)}return!1}function Xp(t,e,s,o,u,l){var d=s&K,g=_i(t),b=g.length,E=_i(e),x=E.length;if(b!=x&&!d)return!1;for(var T=b;T--;){var M=g[T];if(!(d?M in e:X.call(e,M)))return!1}var L=l.get(t),D=l.get(e);if(L&&D)return L==e&&D==t;var $=!0;l.set(t,e),l.set(e,t);for(var N=d;++T<b;){M=g[T];var H=t[M],G=e[M];if(o)var Dt=d?o(G,H,M,e,t,l):o(H,G,M,t,e,l);if(!(Dt===r?H===G||u(H,G,s,o,l):Dt)){$=!1;break}N||(N=M=="constructor")}if($&&!N){var Tt=t.constructor,Nt=e.constructor;Tt!=Nt&&"constructor"in t&&"constructor"in e&&!(typeof Tt=="function"&&Tt instanceof Tt&&typeof Nt=="function"&&Nt instanceof Nt)&&($=!1)}return l.delete(t),l.delete(e),$}function me(t){return xi(Au(t,r,ku),t+"")}function _i(t){return Wa(t,_t,wi)}function bi(t){return Wa(t,Rt,yu)}var mi=Mr?function(t){return Mr.get(t)}:Ni;function Hr(t){for(var e=t.name+"",s=pn[e],o=X.call(pn,e)?s.length:0;o--;){var u=s[o],l=u.func;if(l==null||l==t)return u.name}return e}function mn(t){var e=X.call(c,"placeholder")?c:t;return e.placeholder}function k(){var t=c.iteratee||ki;return t=t===ki?za:t,arguments.length?t(arguments[0],arguments[1]):t}function Jr(t,e){var s=t.__data__;return ig(e)?s[typeof e=="string"?"string":"hash"]:s.map}function vi(t){for(var e=_t(t),s=e.length;s--;){var o=e[s],u=t[o];e[s]=[o,u,xu(u)]}return e}function Ve(t,e){var s=ud(t,e);return qa(s)?s:r}function Qp(t){var e=X.call(t,He),s=t[He];try{t[He]=r;var o=!0}catch{}var u=Sr.call(t);return o&&(e?t[He]=s:delete t[He]),u}var wi=Ks?function(t){return t==null?[]:(t=j(t),Ae(Ks(t),function(e){return Ca.call(t,e)}))}:Fi,yu=Ks?function(t){for(var e=[];t;)Ce(e,wi(t)),t=Tr(t);return e}:Fi,wt=Et;(Ys&&wt(new Ys(new ArrayBuffer(1)))!=on||Fn&&wt(new Fn)!=te||Vs&&wt(Vs.resolve())!=No||dn&&wt(new dn)!=ee||Un&&wt(new Un)!=Bn)&&(wt=function(t){var e=Et(t),s=e==de?t.constructor:r,o=s?Ze(s):"";if(o)switch(o){case Bd:return on;case kd:return te;case Dd:return No;case Nd:return ee;case Fd:return Bn}return e});function jp(t,e,s){for(var o=-1,u=s.length;++o<u;){var l=s[o],d=l.size;switch(l.type){case"drop":t+=d;break;case"dropRight":e-=d;break;case"take":e=vt(e,t+d);break;case"takeRight":t=pt(t,e-d);break}}return{start:t,end:e}}function tg(t){var e=t.match(of);return e?e[1].split(af):[]}function Su(t,e,s){e=Oe(e,t);for(var o=-1,u=e.length,l=!1;++o<u;){var d=fe(e[o]);if(!(l=t!=null&&s(t,d)))break;t=t[d]}return l||++o!=u?l:(u=t==null?0:t.length,!!u&&Qr(u)&&ve(d,u)&&(U(t)||Xe(t)))}function eg(t){var e=t.length,s=new t.constructor(e);return e&&typeof t[0]=="string"&&X.call(t,"index")&&(s.index=t.index,s.input=t.input),s}function Eu(t){return typeof t.constructor=="function"&&!Yn(t)?gn(Tr(t)):{}}function ng(t,e,s){var o=t.constructor;switch(e){case kn:return di(t);case Rn:case Mn:return new o(+t);case on:return Up(t,s);case vs:case ws:case ys:case Ss:case Es:case xs:case Ts:case As:case Cs:return iu(t,s);case te:return new o;case Pn:case Ln:return new o(t);case On:return Wp(t);case ee:return new o;case fr:return $p(t)}}function rg(t,e){var s=e.length;if(!s)return t;var o=s-1;return e[o]=(s>1?"& ":"")+e[o],e=e.join(s>2?", ":" "),t.replace(sf,`{
21
+ /* [wrapped with `+e+`] */
22
+ `)}function sg(t){return U(t)||Xe(t)||!!(Ia&&t&&t[Ia])}function ve(t,e){var s=typeof t;return e=e??Te,!!e&&(s=="number"||s!="symbol"&&_f.test(t))&&t>-1&&t%1==0&&t<e}function xt(t,e,s){if(!st(s))return!1;var o=typeof e;return(o=="number"?It(s)&&ve(e,s.length):o=="string"&&e in s)?se(s[e],t):!1}function yi(t,e){if(U(t))return!1;var s=typeof t;return s=="number"||s=="symbol"||s=="boolean"||t==null||kt(t)?!0:tf.test(t)||!jl.test(t)||e!=null&&t in j(e)}function ig(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Si(t){var e=Hr(t),s=c[e];if(typeof s!="function"||!(e in J.prototype))return!1;if(t===s)return!0;var o=mi(s);return!!o&&t===o[0]}function og(t){return!!xa&&xa in t}var ag=wr?we:Ui;function Yn(t){var e=t&&t.constructor,s=typeof e=="function"&&e.prototype||fn;return t===s}function xu(t){return t===t&&!st(t)}function Tu(t,e){return function(s){return s==null?!1:s[t]===e&&(e!==r||t in j(s))}}function ug(t){var e=Zr(t,function(o){return s.size===I&&s.clear(),o}),s=e.cache;return e}function cg(t,e){var s=t[1],o=e[1],u=s|o,l=u<(gt|ct|q),d=o==q&&s==Qt||o==q&&s==ht&&t[7].length<=e[8]||o==(q|ht)&&e[7].length<=e[8]&&s==Qt;if(!(l||d))return t;o&gt&&(t[2]=e[2],u|=s&gt?0:ar);var g=e[3];if(g){var b=t[3];t[3]=b?au(b,g,e[4]):g,t[4]=b?Ie(t[3],P):e[4]}return g=e[5],g&&(b=t[5],t[5]=b?uu(b,g,e[6]):g,t[6]=b?Ie(t[5],P):e[6]),g=e[7],g&&(t[7]=g),o&q&&(t[8]=t[8]==null?e[8]:vt(t[8],e[8])),t[9]==null&&(t[9]=e[9]),t[0]=e[0],t[1]=u,t}function hg(t){var e=[];if(t!=null)for(var s in j(t))e.push(s);return e}function lg(t){return Sr.call(t)}function Au(t,e,s){return e=pt(e===r?t.length-1:e,0),function(){for(var o=arguments,u=-1,l=pt(o.length-e,0),d=v(l);++u<l;)d[u]=o[e+u];u=-1;for(var g=v(e+1);++u<e;)g[u]=o[u];return g[e]=s(d),Ot(t,this,g)}}function Cu(t,e){return e.length<2?t:Ye(t,Jt(e,0,-1))}function fg(t,e){for(var s=t.length,o=vt(e.length,s),u=Ct(t);o--;){var l=e[o];t[o]=ve(l,s)?u[l]:r}return t}function Ei(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var Iu=Mu(Xa),Vn=Cd||function(t,e){return bt.setTimeout(t,e)},xi=Mu(kp);function Ru(t,e,s){var o=e+"";return xi(t,rg(o,dg(tg(o),s)))}function Mu(t){var e=0,s=0;return function(){var o=Pd(),u=it-(o-s);if(s=o,u>0){if(++e>=Ut)return arguments[0]}else e=0;return t.apply(r,arguments)}}function Gr(t,e){var s=-1,o=t.length,u=o-1;for(e=e===r?o:e;++s<e;){var l=oi(s,u),d=t[l];t[l]=t[s],t[s]=d}return t.length=e,t}var Pu=ug(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ef,function(s,o,u,l){e.push(u?l.replace(hf,"$1"):o||s)}),e});function fe(t){if(typeof t=="string"||kt(t))return t;var e=t+"";return e=="0"&&1/t==-qe?"-0":e}function Ze(t){if(t!=null){try{return yr.call(t)}catch{}try{return t+""}catch{}}return""}function dg(t,e){return $t(Ul,function(s){var o="_."+s[0];e&s[1]&&!_r(t,o)&&t.push(o)}),t.sort()}function Ou(t){if(t instanceof J)return t.clone();var e=new zt(t.__wrapped__,t.__chain__);return e.__actions__=Ct(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}function pg(t,e,s){(s?xt(t,e,s):e===r)?e=1:e=pt(W(e),0);var o=t==null?0:t.length;if(!o||e<1)return[];for(var u=0,l=0,d=v(Ir(o/e));u<o;)d[l++]=Jt(t,u,u+=e);return d}function gg(t){for(var e=-1,s=t==null?0:t.length,o=0,u=[];++e<s;){var l=t[e];l&&(u[o++]=l)}return u}function _g(){var t=arguments.length;if(!t)return[];for(var e=v(t-1),s=arguments[0],o=t;o--;)e[o-1]=arguments[o];return Ce(U(s)?Ct(s):[s],mt(e,1))}var bg=z(function(t,e){return at(t)?zn(t,mt(e,1,at,!0)):[]}),mg=z(function(t,e){var s=Gt(e);return at(s)&&(s=r),at(t)?zn(t,mt(e,1,at,!0),k(s,2)):[]}),vg=z(function(t,e){var s=Gt(e);return at(s)&&(s=r),at(t)?zn(t,mt(e,1,at,!0),r,s):[]});function wg(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),Jt(t,e<0?0:e,o)):[]}function yg(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),e=o-e,Jt(t,0,e<0?0:e)):[]}function Sg(t,e){return t&&t.length?Fr(t,k(e,3),!0,!0):[]}function Eg(t,e){return t&&t.length?Fr(t,k(e,3),!0):[]}function xg(t,e,s,o){var u=t==null?0:t.length;return u?(s&&typeof s!="number"&&xt(t,e,s)&&(s=0,o=u),_p(t,e,s,o)):[]}function Lu(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=s==null?0:W(s);return u<0&&(u=pt(o+u,0)),br(t,k(e,3),u)}function Bu(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=o-1;return s!==r&&(u=W(s),u=s<0?pt(o+u,0):vt(u,o-1)),br(t,k(e,3),u,!0)}function ku(t){var e=t==null?0:t.length;return e?mt(t,1):[]}function Tg(t){var e=t==null?0:t.length;return e?mt(t,qe):[]}function Ag(t,e){var s=t==null?0:t.length;return s?(e=e===r?1:W(e),mt(t,e)):[]}function Cg(t){for(var e=-1,s=t==null?0:t.length,o={};++e<s;){var u=t[e];o[u[0]]=u[1]}return o}function Du(t){return t&&t.length?t[0]:r}function Ig(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=s==null?0:W(s);return u<0&&(u=pt(o+u,0)),un(t,e,u)}function Rg(t){var e=t==null?0:t.length;return e?Jt(t,0,-1):[]}var Mg=z(function(t){var e=nt(t,li);return e.length&&e[0]===t[0]?ei(e):[]}),Pg=z(function(t){var e=Gt(t),s=nt(t,li);return e===Gt(s)?e=r:s.pop(),s.length&&s[0]===t[0]?ei(s,k(e,2)):[]}),Og=z(function(t){var e=Gt(t),s=nt(t,li);return e=typeof e=="function"?e:r,e&&s.pop(),s.length&&s[0]===t[0]?ei(s,r,e):[]});function Lg(t,e){return t==null?"":Rd.call(t,e)}function Gt(t){var e=t==null?0:t.length;return e?t[e-1]:r}function Bg(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=o;return s!==r&&(u=W(s),u=u<0?pt(o+u,0):vt(u,o-1)),e===e?dd(t,e,u):br(t,_a,u,!0)}function kg(t,e){return t&&t.length?Ka(t,W(e)):r}var Dg=z(Nu);function Nu(t,e){return t&&t.length&&e&&e.length?ii(t,e):t}function Ng(t,e,s){return t&&t.length&&e&&e.length?ii(t,e,k(s,2)):t}function Fg(t,e,s){return t&&t.length&&e&&e.length?ii(t,e,r,s):t}var Ug=me(function(t,e){var s=t==null?0:t.length,o=Xs(t,e);return Za(t,nt(e,function(u){return ve(u,s)?+u:u}).sort(ou)),o});function Wg(t,e){var s=[];if(!(t&&t.length))return s;var o=-1,u=[],l=t.length;for(e=k(e,3);++o<l;){var d=t[o];e(d,o,t)&&(s.push(d),u.push(o))}return Za(t,u),s}function Ti(t){return t==null?t:Ld.call(t)}function $g(t,e,s){var o=t==null?0:t.length;return o?(s&&typeof s!="number"&&xt(t,e,s)?(e=0,s=o):(e=e==null?0:W(e),s=s===r?o:W(s)),Jt(t,e,s)):[]}function qg(t,e){return Nr(t,e)}function zg(t,e,s){return ui(t,e,k(s,2))}function Hg(t,e){var s=t==null?0:t.length;if(s){var o=Nr(t,e);if(o<s&&se(t[o],e))return o}return-1}function Jg(t,e){return Nr(t,e,!0)}function Gg(t,e,s){return ui(t,e,k(s,2),!0)}function Kg(t,e){var s=t==null?0:t.length;if(s){var o=Nr(t,e,!0)-1;if(se(t[o],e))return o}return-1}function Yg(t){return t&&t.length?Qa(t):[]}function Vg(t,e){return t&&t.length?Qa(t,k(e,2)):[]}function Zg(t){var e=t==null?0:t.length;return e?Jt(t,1,e):[]}function Xg(t,e,s){return t&&t.length?(e=s||e===r?1:W(e),Jt(t,0,e<0?0:e)):[]}function Qg(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),e=o-e,Jt(t,e<0?0:e,o)):[]}function jg(t,e){return t&&t.length?Fr(t,k(e,3),!1,!0):[]}function t_(t,e){return t&&t.length?Fr(t,k(e,3)):[]}var e_=z(function(t){return Pe(mt(t,1,at,!0))}),n_=z(function(t){var e=Gt(t);return at(e)&&(e=r),Pe(mt(t,1,at,!0),k(e,2))}),r_=z(function(t){var e=Gt(t);return e=typeof e=="function"?e:r,Pe(mt(t,1,at,!0),r,e)});function s_(t){return t&&t.length?Pe(t):[]}function i_(t,e){return t&&t.length?Pe(t,k(e,2)):[]}function o_(t,e){return e=typeof e=="function"?e:r,t&&t.length?Pe(t,r,e):[]}function Ai(t){if(!(t&&t.length))return[];var e=0;return t=Ae(t,function(s){if(at(s))return e=pt(s.length,e),!0}),zs(e,function(s){return nt(t,Ws(s))})}function Fu(t,e){if(!(t&&t.length))return[];var s=Ai(t);return e==null?s:nt(s,function(o){return Ot(e,r,o)})}var a_=z(function(t,e){return at(t)?zn(t,e):[]}),u_=z(function(t){return hi(Ae(t,at))}),c_=z(function(t){var e=Gt(t);return at(e)&&(e=r),hi(Ae(t,at),k(e,2))}),h_=z(function(t){var e=Gt(t);return e=typeof e=="function"?e:r,hi(Ae(t,at),r,e)}),l_=z(Ai);function f_(t,e){return nu(t||[],e||[],qn)}function d_(t,e){return nu(t||[],e||[],Gn)}var p_=z(function(t){var e=t.length,s=e>1?t[e-1]:r;return s=typeof s=="function"?(t.pop(),s):r,Fu(t,s)});function Uu(t){var e=c(t);return e.__chain__=!0,e}function g_(t,e){return e(t),t}function Kr(t,e){return e(t)}var __=me(function(t){var e=t.length,s=e?t[0]:0,o=this.__wrapped__,u=function(l){return Xs(l,t)};return e>1||this.__actions__.length||!(o instanceof J)||!ve(s)?this.thru(u):(o=o.slice(s,+s+(e?1:0)),o.__actions__.push({func:Kr,args:[u],thisArg:r}),new zt(o,this.__chain__).thru(function(l){return e&&!l.length&&l.push(r),l}))});function b_(){return Uu(this)}function m_(){return new zt(this.value(),this.__chain__)}function v_(){this.__values__===r&&(this.__values__=ju(this.value()));var t=this.__index__>=this.__values__.length,e=t?r:this.__values__[this.__index__++];return{done:t,value:e}}function w_(){return this}function y_(t){for(var e,s=this;s instanceof Or;){var o=Ou(s);o.__index__=0,o.__values__=r,e?u.__wrapped__=o:e=o;var u=o;s=s.__wrapped__}return u.__wrapped__=t,e}function S_(){var t=this.__wrapped__;if(t instanceof J){var e=t;return this.__actions__.length&&(e=new J(this)),e=e.reverse(),e.__actions__.push({func:Kr,args:[Ti],thisArg:r}),new zt(e,this.__chain__)}return this.thru(Ti)}function E_(){return eu(this.__wrapped__,this.__actions__)}var x_=Ur(function(t,e,s){X.call(t,s)?++t[s]:_e(t,s,1)});function T_(t,e,s){var o=U(t)?pa:gp;return s&&xt(t,e,s)&&(e=r),o(t,k(e,3))}function A_(t,e){var s=U(t)?Ae:Fa;return s(t,k(e,3))}var C_=fu(Lu),I_=fu(Bu);function R_(t,e){return mt(Yr(t,e),1)}function M_(t,e){return mt(Yr(t,e),qe)}function P_(t,e,s){return s=s===r?1:W(s),mt(Yr(t,e),s)}function Wu(t,e){var s=U(t)?$t:Me;return s(t,k(e,3))}function $u(t,e){var s=U(t)?Zf:Na;return s(t,k(e,3))}var O_=Ur(function(t,e,s){X.call(t,s)?t[s].push(e):_e(t,s,[e])});function L_(t,e,s,o){t=It(t)?t:wn(t),s=s&&!o?W(s):0;var u=t.length;return s<0&&(s=pt(u+s,0)),jr(t)?s<=u&&t.indexOf(e,s)>-1:!!u&&un(t,e,s)>-1}var B_=z(function(t,e,s){var o=-1,u=typeof e=="function",l=It(t)?v(t.length):[];return Me(t,function(d){l[++o]=u?Ot(e,d,s):Hn(d,e,s)}),l}),k_=Ur(function(t,e,s){_e(t,s,e)});function Yr(t,e){var s=U(t)?nt:Ha;return s(t,k(e,3))}function D_(t,e,s,o){return t==null?[]:(U(e)||(e=e==null?[]:[e]),s=o?r:s,U(s)||(s=s==null?[]:[s]),Ya(t,e,s))}var N_=Ur(function(t,e,s){t[s?0:1].push(e)},function(){return[[],[]]});function F_(t,e,s){var o=U(t)?Fs:ma,u=arguments.length<3;return o(t,k(e,4),s,u,Me)}function U_(t,e,s){var o=U(t)?Xf:ma,u=arguments.length<3;return o(t,k(e,4),s,u,Na)}function W_(t,e){var s=U(t)?Ae:Fa;return s(t,Xr(k(e,3)))}function $_(t){var e=U(t)?La:Lp;return e(t)}function q_(t,e,s){(s?xt(t,e,s):e===r)?e=1:e=W(e);var o=U(t)?hp:Bp;return o(t,e)}function z_(t){var e=U(t)?lp:Dp;return e(t)}function H_(t){if(t==null)return 0;if(It(t))return jr(t)?hn(t):t.length;var e=wt(t);return e==te||e==ee?t.size:ri(t).length}function J_(t,e,s){var o=U(t)?Us:Np;return s&&xt(t,e,s)&&(e=r),o(t,k(e,3))}var G_=z(function(t,e){if(t==null)return[];var s=e.length;return s>1&&xt(t,e[0],e[1])?e=[]:s>2&&xt(e[0],e[1],e[2])&&(e=[e[0]]),Ya(t,mt(e,1),[])}),Vr=Ad||function(){return bt.Date.now()};function K_(t,e){if(typeof e!="function")throw new qt(p);return t=W(t),function(){if(--t<1)return e.apply(this,arguments)}}function qu(t,e,s){return e=s?r:e,e=t&&e==null?t.length:e,be(t,q,r,r,r,r,e)}function zu(t,e){var s;if(typeof e!="function")throw new qt(p);return t=W(t),function(){return--t>0&&(s=e.apply(this,arguments)),t<=1&&(e=r),s}}var Ci=z(function(t,e,s){var o=gt;if(s.length){var u=Ie(s,mn(Ci));o|=jt}return be(t,o,e,s,u)}),Hu=z(function(t,e,s){var o=gt|ct;if(s.length){var u=Ie(s,mn(Hu));o|=jt}return be(e,o,t,s,u)});function Ju(t,e,s){e=s?r:e;var o=be(t,Qt,r,r,r,r,r,e);return o.placeholder=Ju.placeholder,o}function Gu(t,e,s){e=s?r:e;var o=be(t,We,r,r,r,r,r,e);return o.placeholder=Gu.placeholder,o}function Ku(t,e,s){var o,u,l,d,g,b,E=0,x=!1,T=!1,M=!0;if(typeof t!="function")throw new qt(p);e=Kt(e)||0,st(s)&&(x=!!s.leading,T="maxWait"in s,l=T?pt(Kt(s.maxWait)||0,e):l,M="trailing"in s?!!s.trailing:M);function L(ut){var ie=o,Se=u;return o=u=r,E=ut,d=t.apply(Se,ie),d}function D(ut){return E=ut,g=Vn(H,e),x?L(ut):d}function $(ut){var ie=ut-b,Se=ut-E,fc=e-ie;return T?vt(fc,l-Se):fc}function N(ut){var ie=ut-b,Se=ut-E;return b===r||ie>=e||ie<0||T&&Se>=l}function H(){var ut=Vr();if(N(ut))return G(ut);g=Vn(H,$(ut))}function G(ut){return g=r,M&&o?L(ut):(o=u=r,d)}function Dt(){g!==r&&ru(g),E=0,o=b=u=g=r}function Tt(){return g===r?d:G(Vr())}function Nt(){var ut=Vr(),ie=N(ut);if(o=arguments,u=this,b=ut,ie){if(g===r)return D(b);if(T)return ru(g),g=Vn(H,e),L(b)}return g===r&&(g=Vn(H,e)),d}return Nt.cancel=Dt,Nt.flush=Tt,Nt}var Y_=z(function(t,e){return Da(t,1,e)}),V_=z(function(t,e,s){return Da(t,Kt(e)||0,s)});function Z_(t){return be(t,Q)}function Zr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new qt(p);var s=function(){var o=arguments,u=e?e.apply(this,o):o[0],l=s.cache;if(l.has(u))return l.get(u);var d=t.apply(this,o);return s.cache=l.set(u,d)||l,d};return s.cache=new(Zr.Cache||ge),s}Zr.Cache=ge;function Xr(t){if(typeof t!="function")throw new qt(p);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function X_(t){return zu(2,t)}var Q_=Fp(function(t,e){e=e.length==1&&U(e[0])?nt(e[0],Lt(k())):nt(mt(e,1),Lt(k()));var s=e.length;return z(function(o){for(var u=-1,l=vt(o.length,s);++u<l;)o[u]=e[u].call(this,o[u]);return Ot(t,this,o)})}),Ii=z(function(t,e){var s=Ie(e,mn(Ii));return be(t,jt,r,e,s)}),Yu=z(function(t,e){var s=Ie(e,mn(Yu));return be(t,$e,r,e,s)}),j_=me(function(t,e){return be(t,ht,r,r,r,e)});function tb(t,e){if(typeof t!="function")throw new qt(p);return e=e===r?e:W(e),z(t,e)}function eb(t,e){if(typeof t!="function")throw new qt(p);return e=e==null?0:pt(W(e),0),z(function(s){var o=s[e],u=Le(s,0,e);return o&&Ce(u,o),Ot(t,this,u)})}function nb(t,e,s){var o=!0,u=!0;if(typeof t!="function")throw new qt(p);return st(s)&&(o="leading"in s?!!s.leading:o,u="trailing"in s?!!s.trailing:u),Ku(t,e,{leading:o,maxWait:e,trailing:u})}function rb(t){return qu(t,1)}function sb(t,e){return Ii(fi(e),t)}function ib(){if(!arguments.length)return[];var t=arguments[0];return U(t)?t:[t]}function ob(t){return Ht(t,R)}function ab(t,e){return e=typeof e=="function"?e:r,Ht(t,R,e)}function ub(t){return Ht(t,C|R)}function cb(t,e){return e=typeof e=="function"?e:r,Ht(t,C|R,e)}function hb(t,e){return e==null||ka(t,e,_t(e))}function se(t,e){return t===e||t!==t&&e!==e}var lb=zr(ti),fb=zr(function(t,e){return t>=e}),Xe=$a(function(){return arguments}())?$a:function(t){return ot(t)&&X.call(t,"callee")&&!Ca.call(t,"callee")},U=v.isArray,db=ua?Lt(ua):yp;function It(t){return t!=null&&Qr(t.length)&&!we(t)}function at(t){return ot(t)&&It(t)}function pb(t){return t===!0||t===!1||ot(t)&&Et(t)==Rn}var Be=Id||Ui,gb=ca?Lt(ca):Sp;function _b(t){return ot(t)&&t.nodeType===1&&!Zn(t)}function bb(t){if(t==null)return!0;if(It(t)&&(U(t)||typeof t=="string"||typeof t.splice=="function"||Be(t)||vn(t)||Xe(t)))return!t.length;var e=wt(t);if(e==te||e==ee)return!t.size;if(Yn(t))return!ri(t).length;for(var s in t)if(X.call(t,s))return!1;return!0}function mb(t,e){return Jn(t,e)}function vb(t,e,s){s=typeof s=="function"?s:r;var o=s?s(t,e):r;return o===r?Jn(t,e,r,s):!!o}function Ri(t){if(!ot(t))return!1;var e=Et(t);return e==hr||e==$l||typeof t.message=="string"&&typeof t.name=="string"&&!Zn(t)}function wb(t){return typeof t=="number"&&Ra(t)}function we(t){if(!st(t))return!1;var e=Et(t);return e==lr||e==Do||e==Wl||e==zl}function Vu(t){return typeof t=="number"&&t==W(t)}function Qr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Te}function st(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}function ot(t){return t!=null&&typeof t=="object"}var Zu=ha?Lt(ha):xp;function yb(t,e){return t===e||ni(t,e,vi(e))}function Sb(t,e,s){return s=typeof s=="function"?s:r,ni(t,e,vi(e),s)}function Eb(t){return Xu(t)&&t!=+t}function xb(t){if(ag(t))throw new F(f);return qa(t)}function Tb(t){return t===null}function Ab(t){return t==null}function Xu(t){return typeof t=="number"||ot(t)&&Et(t)==Pn}function Zn(t){if(!ot(t)||Et(t)!=de)return!1;var e=Tr(t);if(e===null)return!0;var s=X.call(e,"constructor")&&e.constructor;return typeof s=="function"&&s instanceof s&&yr.call(s)==Sd}var Mi=la?Lt(la):Tp;function Cb(t){return Vu(t)&&t>=-Te&&t<=Te}var Qu=fa?Lt(fa):Ap;function jr(t){return typeof t=="string"||!U(t)&&ot(t)&&Et(t)==Ln}function kt(t){return typeof t=="symbol"||ot(t)&&Et(t)==fr}var vn=da?Lt(da):Cp;function Ib(t){return t===r}function Rb(t){return ot(t)&&wt(t)==Bn}function Mb(t){return ot(t)&&Et(t)==Jl}var Pb=zr(si),Ob=zr(function(t,e){return t<=e});function ju(t){if(!t)return[];if(It(t))return jr(t)?ne(t):Ct(t);if(Nn&&t[Nn])return hd(t[Nn]());var e=wt(t),s=e==te?Js:e==ee?mr:wn;return s(t)}function ye(t){if(!t)return t===0?t:0;if(t=Kt(t),t===qe||t===-qe){var e=t<0?-1:1;return e*Dl}return t===t?t:0}function W(t){var e=ye(t),s=e%1;return e===e?s?e-s:e:0}function tc(t){return t?Ke(W(t),0,ce):0}function Kt(t){if(typeof t=="number")return t;if(kt(t))return ur;if(st(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=st(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=va(t);var s=df.test(t);return s||gf.test(t)?Kf(t.slice(2),s?2:8):ff.test(t)?ur:+t}function ec(t){return le(t,Rt(t))}function Lb(t){return t?Ke(W(t),-Te,Te):t===0?t:0}function Z(t){return t==null?"":Bt(t)}var Bb=_n(function(t,e){if(Yn(e)||It(e)){le(e,_t(e),t);return}for(var s in e)X.call(e,s)&&qn(t,s,e[s])}),nc=_n(function(t,e){le(e,Rt(e),t)}),ts=_n(function(t,e,s,o){le(e,Rt(e),t,o)}),kb=_n(function(t,e,s,o){le(e,_t(e),t,o)}),Db=me(Xs);function Nb(t,e){var s=gn(t);return e==null?s:Ba(s,e)}var Fb=z(function(t,e){t=j(t);var s=-1,o=e.length,u=o>2?e[2]:r;for(u&&xt(e[0],e[1],u)&&(o=1);++s<o;)for(var l=e[s],d=Rt(l),g=-1,b=d.length;++g<b;){var E=d[g],x=t[E];(x===r||se(x,fn[E])&&!X.call(t,E))&&(t[E]=l[E])}return t}),Ub=z(function(t){return t.push(r,vu),Ot(rc,r,t)});function Wb(t,e){return ga(t,k(e,3),he)}function $b(t,e){return ga(t,k(e,3),js)}function qb(t,e){return t==null?t:Qs(t,k(e,3),Rt)}function zb(t,e){return t==null?t:Ua(t,k(e,3),Rt)}function Hb(t,e){return t&&he(t,k(e,3))}function Jb(t,e){return t&&js(t,k(e,3))}function Gb(t){return t==null?[]:kr(t,_t(t))}function Kb(t){return t==null?[]:kr(t,Rt(t))}function Pi(t,e,s){var o=t==null?r:Ye(t,e);return o===r?s:o}function Yb(t,e){return t!=null&&Su(t,e,bp)}function Oi(t,e){return t!=null&&Su(t,e,mp)}var Vb=pu(function(t,e,s){e!=null&&typeof e.toString!="function"&&(e=Sr.call(e)),t[e]=s},Bi(Mt)),Zb=pu(function(t,e,s){e!=null&&typeof e.toString!="function"&&(e=Sr.call(e)),X.call(t,e)?t[e].push(s):t[e]=[s]},k),Xb=z(Hn);function _t(t){return It(t)?Oa(t):ri(t)}function Rt(t){return It(t)?Oa(t,!0):Ip(t)}function Qb(t,e){var s={};return e=k(e,3),he(t,function(o,u,l){_e(s,e(o,u,l),o)}),s}function jb(t,e){var s={};return e=k(e,3),he(t,function(o,u,l){_e(s,u,e(o,u,l))}),s}var tm=_n(function(t,e,s){Dr(t,e,s)}),rc=_n(function(t,e,s,o){Dr(t,e,s,o)}),em=me(function(t,e){var s={};if(t==null)return s;var o=!1;e=nt(e,function(l){return l=Oe(l,t),o||(o=l.length>1),l}),le(t,bi(t),s),o&&(s=Ht(s,C|A|R,Vp));for(var u=e.length;u--;)ci(s,e[u]);return s});function nm(t,e){return sc(t,Xr(k(e)))}var rm=me(function(t,e){return t==null?{}:Mp(t,e)});function sc(t,e){if(t==null)return{};var s=nt(bi(t),function(o){return[o]});return e=k(e),Va(t,s,function(o,u){return e(o,u[0])})}function sm(t,e,s){e=Oe(e,t);var o=-1,u=e.length;for(u||(u=1,t=r);++o<u;){var l=t==null?r:t[fe(e[o])];l===r&&(o=u,l=s),t=we(l)?l.call(t):l}return t}function im(t,e,s){return t==null?t:Gn(t,e,s)}function om(t,e,s,o){return o=typeof o=="function"?o:r,t==null?t:Gn(t,e,s,o)}var ic=bu(_t),oc=bu(Rt);function am(t,e,s){var o=U(t),u=o||Be(t)||vn(t);if(e=k(e,4),s==null){var l=t&&t.constructor;u?s=o?new l:[]:st(t)?s=we(l)?gn(Tr(t)):{}:s={}}return(u?$t:he)(t,function(d,g,b){return e(s,d,g,b)}),s}function um(t,e){return t==null?!0:ci(t,e)}function cm(t,e,s){return t==null?t:tu(t,e,fi(s))}function hm(t,e,s,o){return o=typeof o=="function"?o:r,t==null?t:tu(t,e,fi(s),o)}function wn(t){return t==null?[]:Hs(t,_t(t))}function lm(t){return t==null?[]:Hs(t,Rt(t))}function fm(t,e,s){return s===r&&(s=e,e=r),s!==r&&(s=Kt(s),s=s===s?s:0),e!==r&&(e=Kt(e),e=e===e?e:0),Ke(Kt(t),e,s)}function dm(t,e,s){return e=ye(e),s===r?(s=e,e=0):s=ye(s),t=Kt(t),vp(t,e,s)}function pm(t,e,s){if(s&&typeof s!="boolean"&&xt(t,e,s)&&(e=s=r),s===r&&(typeof e=="boolean"?(s=e,e=r):typeof t=="boolean"&&(s=t,t=r)),t===r&&e===r?(t=0,e=1):(t=ye(t),e===r?(e=t,t=0):e=ye(e)),t>e){var o=t;t=e,e=o}if(s||t%1||e%1){var u=Ma();return vt(t+u*(e-t+Gf("1e-"+((u+"").length-1))),e)}return oi(t,e)}var gm=bn(function(t,e,s){return e=e.toLowerCase(),t+(s?ac(e):e)});function ac(t){return Li(Z(t).toLowerCase())}function uc(t){return t=Z(t),t&&t.replace(bf,id).replace(Df,"")}function _m(t,e,s){t=Z(t),e=Bt(e);var o=t.length;s=s===r?o:Ke(W(s),0,o);var u=s;return s-=e.length,s>=0&&t.slice(s,u)==e}function bm(t){return t=Z(t),t&&Zl.test(t)?t.replace(Uo,od):t}function mm(t){return t=Z(t),t&&nf.test(t)?t.replace(Is,"\\$&"):t}var vm=bn(function(t,e,s){return t+(s?"-":"")+e.toLowerCase()}),wm=bn(function(t,e,s){return t+(s?" ":"")+e.toLowerCase()}),ym=lu("toLowerCase");function Sm(t,e,s){t=Z(t),e=W(e);var o=e?hn(t):0;if(!e||o>=e)return t;var u=(e-o)/2;return qr(Rr(u),s)+t+qr(Ir(u),s)}function Em(t,e,s){t=Z(t),e=W(e);var o=e?hn(t):0;return e&&o<e?t+qr(e-o,s):t}function xm(t,e,s){t=Z(t),e=W(e);var o=e?hn(t):0;return e&&o<e?qr(e-o,s)+t:t}function Tm(t,e,s){return s||e==null?e=0:e&&(e=+e),Od(Z(t).replace(Rs,""),e||0)}function Am(t,e,s){return(s?xt(t,e,s):e===r)?e=1:e=W(e),ai(Z(t),e)}function Cm(){var t=arguments,e=Z(t[0]);return t.length<3?e:e.replace(t[1],t[2])}var Im=bn(function(t,e,s){return t+(s?"_":"")+e.toLowerCase()});function Rm(t,e,s){return s&&typeof s!="number"&&xt(t,e,s)&&(e=s=r),s=s===r?ce:s>>>0,s?(t=Z(t),t&&(typeof e=="string"||e!=null&&!Mi(e))&&(e=Bt(e),!e&&cn(t))?Le(ne(t),0,s):t.split(e,s)):[]}var Mm=bn(function(t,e,s){return t+(s?" ":"")+Li(e)});function Pm(t,e,s){return t=Z(t),s=s==null?0:Ke(W(s),0,t.length),e=Bt(e),t.slice(s,s+e.length)==e}function Om(t,e,s){var o=c.templateSettings;s&&xt(t,e,s)&&(e=r),t=Z(t),e=ts({},e,o,mu);var u=ts({},e.imports,o.imports,mu),l=_t(u),d=Hs(u,l),g,b,E=0,x=e.interpolate||dr,T="__p += '",M=Gs((e.escape||dr).source+"|"+x.source+"|"+(x===Wo?lf:dr).source+"|"+(e.evaluate||dr).source+"|$","g"),L="//# sourceURL="+(X.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++$f+"]")+`
23
+ `;t.replace(M,function(N,H,G,Dt,Tt,Nt){return G||(G=Dt),T+=t.slice(E,Nt).replace(mf,ad),H&&(g=!0,T+=`' +
24
+ __e(`+H+`) +
25
+ '`),Tt&&(b=!0,T+=`';
26
+ `+Tt+`;
27
+ __p += '`),G&&(T+=`' +
28
+ ((__t = (`+G+`)) == null ? '' : __t) +
29
+ '`),E=Nt+N.length,N}),T+=`';
30
+ `;var D=X.call(e,"variable")&&e.variable;if(!D)T=`with (obj) {
31
+ `+T+`
28
32
  }
29
- `;else if(Ta.test(T))throw new L(I);v=(c?v.replace(ca,""):v).replace(ha,"$1").replace(ga,"$1;"),v="function("+(T||"obj")+`) {
30
- `+(T?"":`obj || (obj = {});
31
- `)+"var __t, __p = ''"+(f?", __e = _.escape":"")+(c?`, __j = Array.prototype.join;
33
+ `;else if(cf.test(D))throw new F(m);T=(b?T.replace(Gl,""):T).replace(Kl,"$1").replace(Yl,"$1;"),T="function("+(D||"obj")+`) {
34
+ `+(D?"":`obj || (obj = {});
35
+ `)+"var __t, __p = ''"+(g?", __e = _.escape":"")+(b?`, __j = Array.prototype.join;
32
36
  function print() { __p += __j.call(arguments, '') }
33
37
  `:`;
34
- `)+v+`return __p
35
- }`;var M=Po(function(){return k(o,A+"return "+v).apply(i,a)});if(M.source=v,Fi(M))throw M;return M}function Vp(n){return q(n).toLowerCase()}function jp(n){return q(n).toUpperCase()}function nd(n,t,e){if(n=q(n),n&&(e||t===i))return Uu(n);if(!n||!(t=In(t)))return n;var r=Yn(n),u=Yn(t),o=Du(r,u),a=Nu(r,u)+1;return St(r,o,a).join("")}function td(n,t,e){if(n=q(n),n&&(e||t===i))return n.slice(0,Gu(n)+1);if(!n||!(t=In(t)))return n;var r=Yn(n),u=Nu(r,Yn(t))+1;return St(r,0,u).join("")}function ed(n,t,e){if(n=q(n),n&&(e||t===i))return n.replace(Fr,"");if(!n||!(t=In(t)))return n;var r=Yn(n),u=Du(r,Yn(t));return St(r,u).join("")}function rd(n,t){var e=Mn,r=sn;if(Q(t)){var u="separator"in t?t.separator:u;e="length"in t?W(t.length):e,r="omission"in t?In(t.omission):r}n=q(n);var o=n.length;if(kt(n)){var a=Yn(n);o=a.length}if(e>=o)return n;var f=e-$t(r);if(f<1)return r;var c=a?St(a,0,f).join(""):n.slice(0,f);if(u===i)return c+r;if(a&&(f+=c.length-f),Ui(u)){if(n.slice(f).search(u)){var d,_=c;for(u.global||(u=Vr(u.source,q(iu.exec(u))+"g")),u.lastIndex=0;d=u.exec(_);)var v=d.index;c=c.slice(0,v===i?f:v)}}else if(n.indexOf(In(u),f)!=f){var x=c.lastIndexOf(u);x>-1&&(c=c.slice(0,x))}return c+r}function id(n){return n=q(n),n&&pa.test(n)?n.replace(tu,Wf):n}var ud=Zt(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Bi=Ps("toUpperCase");function To(n,t,e){return n=q(n),t=e?i:t,t===i?Pf(n)?Uf(n):mf(n):n.match(t)||[]}var Po=U(function(n,t){try{return Pn(n,i,t)}catch(e){return Fi(e)?e:new L(e)}}),sd=at(function(n,t){return Dn(t,function(e){e=tt(e),st(n,e,Wi(n[e],n))}),n});function od(n){var t=n==null?0:n.length,e=R();return n=t?X(n,function(r){if(typeof r[1]!="function")throw new Nn(b);return[e(r[0]),r[1]]}):[],U(function(r){for(var u=-1;++u<t;){var o=n[u];if(Pn(o[0],this,r))return Pn(o[1],this,r)}})}function ad(n){return Wl(Gn(n,un))}function Gi(n){return function(){return n}}function fd(n,t){return n==null||n!==n?t:n}var ld=Is(),cd=Is(!0);function Cn(n){return n}function ki(n){return ss(typeof n=="function"?n:Gn(n,un))}function hd(n){return as(Gn(n,un))}function gd(n,t){return fs(n,Gn(t,un))}var pd=U(function(n,t){return function(e){return we(e,n,t)}}),dd=U(function(n,t){return function(e){return we(n,e,t)}});function $i(n,t,e){var r=fn(t),u=tr(t,r);e==null&&!(Q(t)&&(u.length||!r.length))&&(e=t,t=n,n=this,u=tr(t,fn(t)));var o=!(Q(e)&&"chain"in e)||!!e.chain,a=lt(n);return Dn(u,function(f){var c=t[f];n[f]=c,a&&(n.prototype[f]=function(){var d=this.__chain__;if(o||d){var _=n(this.__wrapped__),v=_.__actions__=xn(this.__actions__);return v.push({func:c,args:arguments,thisArg:n}),_.__chain__=d,_}return c.apply(n,_t([this.value()],arguments))})}),n}function _d(){return ln._===this&&(ln._=$f),this}function qi(){}function vd(n){return n=W(n),U(function(t){return ls(t,n)})}var wd=yi(X),md=yi(Lu),yd=yi(Hr);function Eo(n){return Ti(n)?Kr(tt(n)):Xl(n)}function xd(n){return function(t){return n==null?i:Wt(n,t)}}var Sd=Os(),Ad=Os(!0);function zi(){return[]}function Hi(){return!1}function Cd(){return{}}function bd(){return""}function Rd(){return!0}function Td(n,t){if(n=W(n),n<1||n>pt)return[];var e=Vn,r=hn(n,Vn);t=R(t),n-=Vn;for(var u=Zr(r,t);++e<n;)t(e);return u}function Pd(n){return O(n)?X(n,tt):Ln(n)?[n]:xn(Ys(q(n)))}function Ed(n){var t=++Gf;return q(n)+t}var Id=or(function(n,t){return n+t},0),Ld=xi("ceil"),Od=or(function(n,t){return n/t},1),Wd=xi("floor");function Md(n){return n&&n.length?nr(n,Cn,si):i}function Fd(n,t){return n&&n.length?nr(n,R(t,2),si):i}function Ud(n){return Mu(n,Cn)}function Dd(n,t){return Mu(n,R(t,2))}function Nd(n){return n&&n.length?nr(n,Cn,li):i}function Bd(n,t){return n&&n.length?nr(n,R(t,2),li):i}var Gd=or(function(n,t){return n*t},1),kd=xi("round"),$d=or(function(n,t){return n-t},0);function qd(n){return n&&n.length?Yr(n,Cn):0}function zd(n,t){return n&&n.length?Yr(n,R(t,2)):0}return s.after=hg,s.ary=uo,s.assign=jg,s.assignIn=yo,s.assignInWith=yr,s.assignWith=np,s.at=tp,s.before=so,s.bind=Wi,s.bindAll=sd,s.bindKey=oo,s.castArray=Cg,s.chain=eo,s.chunk=Wc,s.compact=Mc,s.concat=Fc,s.cond=od,s.conforms=ad,s.constant=Gi,s.countBy=qh,s.create=ep,s.curry=ao,s.curryRight=fo,s.debounce=lo,s.defaults=rp,s.defaultsDeep=ip,s.defer=gg,s.delay=pg,s.difference=Uc,s.differenceBy=Dc,s.differenceWith=Nc,s.drop=Bc,s.dropRight=Gc,s.dropRightWhile=kc,s.dropWhile=$c,s.fill=qc,s.filter=Hh,s.flatMap=Yh,s.flatMapDeep=Zh,s.flatMapDepth=Xh,s.flatten=Vs,s.flattenDeep=zc,s.flattenDepth=Hc,s.flip=dg,s.flow=ld,s.flowRight=cd,s.fromPairs=Kc,s.functions=cp,s.functionsIn=hp,s.groupBy=Qh,s.initial=Yc,s.intersection=Zc,s.intersectionBy=Xc,s.intersectionWith=Qc,s.invert=pp,s.invertBy=dp,s.invokeMap=jh,s.iteratee=ki,s.keyBy=ng,s.keys=fn,s.keysIn=An,s.map=pr,s.mapKeys=vp,s.mapValues=wp,s.matches=hd,s.matchesProperty=gd,s.memoize=_r,s.merge=mp,s.mergeWith=xo,s.method=pd,s.methodOf=dd,s.mixin=$i,s.negate=vr,s.nthArg=vd,s.omit=yp,s.omitBy=xp,s.once=_g,s.orderBy=tg,s.over=wd,s.overArgs=vg,s.overEvery=md,s.overSome=yd,s.partial=Mi,s.partialRight=co,s.partition=eg,s.pick=Sp,s.pickBy=So,s.property=Eo,s.propertyOf=xd,s.pull=th,s.pullAll=no,s.pullAllBy=eh,s.pullAllWith=rh,s.pullAt=ih,s.range=Sd,s.rangeRight=Ad,s.rearg=wg,s.reject=ug,s.remove=uh,s.rest=mg,s.reverse=Li,s.sampleSize=og,s.set=Cp,s.setWith=bp,s.shuffle=ag,s.slice=sh,s.sortBy=cg,s.sortedUniq=gh,s.sortedUniqBy=ph,s.split=Yp,s.spread=yg,s.tail=dh,s.take=_h,s.takeRight=vh,s.takeRightWhile=wh,s.takeWhile=mh,s.tap=Mh,s.throttle=xg,s.thru=gr,s.toArray=vo,s.toPairs=Ao,s.toPairsIn=Co,s.toPath=Pd,s.toPlainObject=mo,s.transform=Rp,s.unary=Sg,s.union=yh,s.unionBy=xh,s.unionWith=Sh,s.uniq=Ah,s.uniqBy=Ch,s.uniqWith=bh,s.unset=Tp,s.unzip=Oi,s.unzipWith=to,s.update=Pp,s.updateWith=Ep,s.values=Vt,s.valuesIn=Ip,s.without=Rh,s.words=To,s.wrap=Ag,s.xor=Th,s.xorBy=Ph,s.xorWith=Eh,s.zip=Ih,s.zipObject=Lh,s.zipObjectDeep=Oh,s.zipWith=Wh,s.entries=Ao,s.entriesIn=Co,s.extend=yo,s.extendWith=yr,$i(s,s),s.add=Id,s.attempt=Po,s.camelCase=Mp,s.capitalize=bo,s.ceil=Ld,s.clamp=Lp,s.clone=bg,s.cloneDeep=Tg,s.cloneDeepWith=Pg,s.cloneWith=Rg,s.conformsTo=Eg,s.deburr=Ro,s.defaultTo=fd,s.divide=Od,s.endsWith=Fp,s.eq=Xn,s.escape=Up,s.escapeRegExp=Dp,s.every=zh,s.find=Kh,s.findIndex=Xs,s.findKey=up,s.findLast=Jh,s.findLastIndex=Qs,s.findLastKey=sp,s.floor=Wd,s.forEach=ro,s.forEachRight=io,s.forIn=op,s.forInRight=ap,s.forOwn=fp,s.forOwnRight=lp,s.get=Di,s.gt=Ig,s.gte=Lg,s.has=gp,s.hasIn=Ni,s.head=js,s.identity=Cn,s.includes=Vh,s.indexOf=Jc,s.inRange=Op,s.invoke=_p,s.isArguments=Ut,s.isArray=O,s.isArrayBuffer=Og,s.isArrayLike=Sn,s.isArrayLikeObject=nn,s.isBoolean=Wg,s.isBuffer=At,s.isDate=Mg,s.isElement=Fg,s.isEmpty=Ug,s.isEqual=Dg,s.isEqualWith=Ng,s.isError=Fi,s.isFinite=Bg,s.isFunction=lt,s.isInteger=ho,s.isLength=wr,s.isMap=go,s.isMatch=Gg,s.isMatchWith=kg,s.isNaN=$g,s.isNative=qg,s.isNil=Hg,s.isNull=zg,s.isNumber=po,s.isObject=Q,s.isObjectLike=j,s.isPlainObject=Ce,s.isRegExp=Ui,s.isSafeInteger=Kg,s.isSet=_o,s.isString=mr,s.isSymbol=Ln,s.isTypedArray=Qt,s.isUndefined=Jg,s.isWeakMap=Yg,s.isWeakSet=Zg,s.join=Vc,s.kebabCase=Np,s.last=$n,s.lastIndexOf=jc,s.lowerCase=Bp,s.lowerFirst=Gp,s.lt=Xg,s.lte=Qg,s.max=Md,s.maxBy=Fd,s.mean=Ud,s.meanBy=Dd,s.min=Nd,s.minBy=Bd,s.stubArray=zi,s.stubFalse=Hi,s.stubObject=Cd,s.stubString=bd,s.stubTrue=Rd,s.multiply=Gd,s.nth=nh,s.noConflict=_d,s.noop=qi,s.now=dr,s.pad=kp,s.padEnd=$p,s.padStart=qp,s.parseInt=zp,s.random=Wp,s.reduce=rg,s.reduceRight=ig,s.repeat=Hp,s.replace=Kp,s.result=Ap,s.round=kd,s.runInContext=l,s.sample=sg,s.size=fg,s.snakeCase=Jp,s.some=lg,s.sortedIndex=oh,s.sortedIndexBy=ah,s.sortedIndexOf=fh,s.sortedLastIndex=lh,s.sortedLastIndexBy=ch,s.sortedLastIndexOf=hh,s.startCase=Zp,s.startsWith=Xp,s.subtract=$d,s.sum=qd,s.sumBy=zd,s.template=Qp,s.times=Td,s.toFinite=ct,s.toInteger=W,s.toLength=wo,s.toLower=Vp,s.toNumber=qn,s.toSafeInteger=Vg,s.toString=q,s.toUpper=jp,s.trim=nd,s.trimEnd=td,s.trimStart=ed,s.truncate=rd,s.unescape=id,s.uniqueId=Ed,s.upperCase=ud,s.upperFirst=Bi,s.each=ro,s.eachRight=io,s.first=js,$i(s,function(){var n={};return jn(s,function(t,e){z.call(s.prototype,e)||(n[e]=t)}),n}(),{chain:!1}),s.VERSION=w,Dn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){s[n].placeholder=s}),Dn(["drop","take"],function(n,t){N.prototype[n]=function(e){e=e===i?1:an(W(e),0);var r=this.__filtered__&&!t?new N(this):this.clone();return r.__filtered__?r.__takeCount__=hn(e,r.__takeCount__):r.__views__.push({size:hn(e,Vn),type:n+(r.__dir__<0?"Right":"")}),r},N.prototype[n+"Right"]=function(e){return this.reverse()[n](e).reverse()}}),Dn(["filter","map","takeWhile"],function(n,t){var e=t+1,r=e==dn||e==na;N.prototype[n]=function(u){var o=this.clone();return o.__iteratees__.push({iteratee:R(u,3),type:e}),o.__filtered__=o.__filtered__||r,o}}),Dn(["head","last"],function(n,t){var e="take"+(t?"Right":"");N.prototype[n]=function(){return this[e](1).value()[0]}}),Dn(["initial","tail"],function(n,t){var e="drop"+(t?"":"Right");N.prototype[n]=function(){return this.__filtered__?new N(this):this[e](1)}}),N.prototype.compact=function(){return this.filter(Cn)},N.prototype.find=function(n){return this.filter(n).head()},N.prototype.findLast=function(n){return this.reverse().find(n)},N.prototype.invokeMap=U(function(n,t){return typeof n=="function"?new N(this):this.map(function(e){return we(e,n,t)})}),N.prototype.reject=function(n){return this.filter(vr(R(n)))},N.prototype.slice=function(n,t){n=W(n);var e=this;return e.__filtered__&&(n>0||t<0)?new N(e):(n<0?e=e.takeRight(-n):n&&(e=e.drop(n)),t!==i&&(t=W(t),e=t<0?e.dropRight(-t):e.take(t-n)),e)},N.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},N.prototype.toArray=function(){return this.take(Vn)},jn(N.prototype,function(n,t){var e=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),u=s[r?"take"+(t=="last"?"Right":""):t],o=r||/^find/.test(t);u&&(s.prototype[t]=function(){var a=this.__wrapped__,f=r?[1]:arguments,c=a instanceof N,d=f[0],_=c||O(a),v=function(D){var B=u.apply(s,_t([D],f));return r&&x?B[0]:B};_&&e&&typeof d=="function"&&d.length!=1&&(c=_=!1);var x=this.__chain__,A=!!this.__actions__.length,T=o&&!x,M=c&&!A;if(!o&&_){a=M?a:new N(this);var P=n.apply(a,f);return P.__actions__.push({func:gr,args:[v],thisArg:i}),new Bn(P,x)}return T&&M?n.apply(this,f):(P=this.thru(v),T?r?P.value()[0]:P.value():P)})}),Dn(["pop","push","shift","sort","splice","unshift"],function(n){var t=Be[n],e=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);s.prototype[n]=function(){var u=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(O(o)?o:[],u)}return this[e](function(a){return t.apply(O(a)?a:[],u)})}}),jn(N.prototype,function(n,t){var e=s[t];if(e){var r=e.name+"";z.call(Kt,r)||(Kt[r]=[]),Kt[r].push({name:t,func:e})}}),Kt[sr(i,yn).name]=[{name:"wrapper",func:i}],N.prototype.clone=il,N.prototype.reverse=ul,N.prototype.value=sl,s.prototype.at=Fh,s.prototype.chain=Uh,s.prototype.commit=Dh,s.prototype.next=Nh,s.prototype.plant=Gh,s.prototype.reverse=kh,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=$h,s.prototype.first=s.prototype.head,ce&&(s.prototype[ce]=Bh),s},qt=Df();Pt?((Pt.exports=qt)._=qt,kr._=qt):ln._=qt}).call(jt)}(be,be.exports);var Uo=be.exports;const Do=Lo(Uo);class No{constructor(p){E(this,"config");this.config=p}async complete(p,i){var w;await this.persist(p,{...i,success:!0}),(w=this.config.logger)==null||w.debug("Transaction completed:",p)}async fail(p,i){var w;await this.persist(p,{...i,success:!1}),(w=this.config.logger)==null||w.debug("Transaction failed:",{...p,...i})}async persist(p,i){await fetch(`${this.config.apiUrl}/transactions/${p.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Bo{constructor(p,i){E(this,"transaction");E(this,"manager");this.transaction=p,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(p,i){var I;const w=this.transaction.functionCall;if(!w){await this.fail("No function call found");return}const m=w.name,C=w.args,b=p[m];if(!b){await this.fail(`Tool ${m} not found`);return}try{const $=Do.get(i,"schema.config.parameters.properties",{}),bn=($&&Object.keys($).length>0?Object.keys($):((I=b.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:I[1].split(",").map(Rn=>Rn.trim()).filter(Boolean))||[]).map(Rn=>C[Rn]),un=await b.apply(null,bn);await this.complete(un)}catch($){await this.fail(`Error executing tool ${m}: ${$}`)}}async complete(p){await this.manager.complete(this.transaction,{success:!0,output:p,error:null})}async fail(p){await this.manager.fail(this.transaction,{success:!1,output:null,error:p})}}class Zi extends te{constructor(i){super();E(this,"status");E(this,"autostart");E(this,"session");E(this,"config");E(this,"notify",!0);E(this,"_tools");E(this,"_toolSchema",{});if(this.config=i,this.status="disconnected",this.autostart=!0,Array.isArray(i.tools)){this._tools={};for(const w of i.tools)w.schema&&w.implementation&&(this._tools[w.schema.name]=w.implementation,this._toolSchema[w.schema.name]=w)}else this._tools=i.tools}getName(){return"transaction"}getPriority(){return 0}getToolInstance(i){return this._toolSchema[i]}async connect(i){return this.setStatus("connected"),i}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(i){this.session=i}async sendPacket(i){}onTransaction(i){const w=new No(this.config),m=new Bo(i,w);if(this.config.onTransaction)this.config.onTransaction(m);else{const C=i.functionCall?this.getToolInstance(i.functionCall.name):void 0;m.invoke(this._tools,C)}}getTools(){return this._tools}}const ee=K.createContext(void 0);function Go(y){return new Promise((p,i)=>{const w=new FileReader;w.readAsDataURL(y),w.onload=()=>{const C=w.result.split(";base64,")[1];p(C)},w.onerror=m=>{i(m)}})}function ko(y){const p={rest:i=>i.config.apiUrl,webrtc:i=>i.config.webrtcUrl.replace("/webrtc","").replace("ws://","http://").replace("wss://","https://"),websocket:i=>i.config.webSocketUrl.replace("/websocket","").replace("ws://","http://").replace("wss://","https://")};for(const i of y){const w=p[i.getName()];if(w)return w(i)}return null}function $o({dev:y=!1,baseUrl:p,protocols:i,logger:w,children:m,session:C="new",transformMessages:b,...I}){const[$,rn]=K.useState(!1),[bn,un]=K.useState([]),[Rn,pn]=K.useState(C),[Tn,gt]=K.useState(new Map),mn=K.useRef(!1),yn=K.useMemo(()=>{if(Array.isArray(i))return i;if(typeof i=="object"&&i!==null){const F=y?"localhost:8000":p||"persona.applica.guru/api",en=y?"http":"https",H=y?"ws":"wss";let Mn=Object.keys(i).map(sn=>{switch(sn){case"rest":const Fn=i[sn];return Fn===!0?new Sr({apiUrl:`${en}://${F}`,apiKey:I.apiKey,agentId:I.agentId,logger:w}):typeof Fn=="object"&&Fn!==null?new Sr(Fn):null;case"webrtc":const V=i[sn];return V===!0?new Cr({webrtcUrl:`${H}://${F}/webrtc`,apiKey:I.apiKey,agentId:I.agentId,logger:w}):typeof V=="object"&&V!==null?new Cr(V):null;case"websocket":const dn=i[sn];return dn===!0?new Ar({webSocketUrl:`${H}://${F}/websocket`,apiKey:I.apiKey,agentId:I.agentId,logger:w}):typeof dn=="object"&&dn!==null?new Ar(dn):null;default:throw new Error(`Unknown protocol: ${sn}`)}}).filter(sn=>sn!==null);return I.tools&&Mn.push(new Zi({apiUrl:`${en}://${F}`,apiKey:I.apiKey,agentId:I.agentId,tools:I.tools,logger:w})),Mn}throw new Error("Invalid protocols configuration")},[]);K.useEffect(()=>{mn.current||(mn.current=!0,w==null||w.debug("Initializing protocols: ",yn.map(F=>F.getName())),yn.forEach(F=>{F.setSession(Rn),F.clearListeners(),F.addStatusChangeListener(en=>{w==null||w.debug(`${F.getName()} has notified new status: ${en}`),Tn.set(F.getName(),en),en==="connected"&&(I.context&&F.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:I.context}}),I.tools&&Array.isArray(I.tools)&&F.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:I.tools.map(H=>H.schema)}}})),gt(new Map(Tn))}),F.addPacketListener(en=>{if(en.type==="message"){const H=en.payload;(H==null?void 0:H.finishReason)==="stop"&&!(H!=null&&H.functionResponse)&&!(H!=null&&H.thought)&&rn(!1),H.thought&&(H.type="reasoning"),un(Mn=>{const sn=Yi([...Mn,{...H,protocol:F.getName()}]);return b?b(sn):sn})}else if(en.type==="reasoning"){const Mn={type:"reasoning",text:en.payload.thought,role:"assistant",finishReason:"stop"};un(sn=>{const Fn=Yi([...sn,{...Mn,protocol:F.getName()}]);return b?b(Fn):Fn})}else en.type==="transaction"&&yn.filter(H=>H!==F).forEach(H=>H.onTransaction(en.payload))}),F.autostart&&F.status==="disconnected"&&(w==null||w.debug(`Connecting to protocol: ${F.getName()}`),F.connect(Rn),rn(!1))}))},[Rn,yn,w,Tn,b]);const Te=async F=>{var Fn;if(((Fn=F.content[0])==null?void 0:Fn.type)!=="text")throw new Error("Only text messages are supported");if(!yn.some(V=>V.getName()!=="transaction"&&V.status==="connected")){un(V=>{const dn=[...V,{role:"assistant",type:"text",text:"No protocol is connected."}];return b?b(dn):dn});return}const H=F.content[0].text;un(V=>{const dn=[...V,{role:"user",type:"text",text:H}];return b?b(dn):dn}),rn(!0);const Mn=yn.sort((V,dn)=>dn.getPriority()-V.getPriority()).find(V=>V.status==="connected"),sn=[];if(F.attachments)for(const V of F.attachments)V.contentType.startsWith("image/")&&V.file&&sn.push({role:"user",image:{contentType:V.contentType,content:await Go(V.file)},text:"",type:"text"});F.content&&sn.push({role:"user",text:F.content[0].text,type:"text"}),w==null||w.debug("Sending message:",sn),await(Mn==null?void 0:Mn.sendPacket({type:"request",payload:sn}))},zn=K.useCallback(()=>(rn(!1),un([]),pn("new"),Promise.resolve()),[]),bt=K.useCallback(()=>Promise.resolve(),[]),Hn=K.useCallback(()=>bn,[bn]),Rt=et.useExternalStoreRuntime({isRunning:$,messages:bn,convertMessage:Mo,onNew:Te,onCancel:zn,onReload:bt,adapters:{attachments:new et.CompositeAttachmentAdapter([new et.SimpleImageAttachmentAdapter])}});return xr.jsx(ee.Provider,{value:{protocols:yn,protocolsStatus:Tn,getMessages:Hn},children:xr.jsx(et.AssistantRuntimeProvider,{runtime:Rt,children:m})})}function qo({children:y,...p}){return xr.jsx($o,{...p,children:y})}function zo(){const y=K.useContext(ee);if(!y)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return y}function Xi(y){const p=K.useContext(ee);if(!p)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=p.protocols.find(m=>m.getName()===y);if(!i)return null;const w=p.protocolsStatus.get(i.getName());return{...i,connect:i.connect.bind(i),disconnect:i.disconnect.bind(i),sendPacket:i.sendPacket.bind(i),setSession:i.setSession.bind(i),addStatusChangeListener:i.addStatusChangeListener.bind(i),addPacketListener:i.addPacketListener.bind(i),getName:i.getName.bind(i),getPriority:i.getPriority.bind(i),status:w||i.status}}function Ho(){const y=K.useContext(ee);if(!y)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return ko(y.protocols)}function Ko(){return Xi("webrtc")}function Jo(){const y=K.useContext(ee);if(!y)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return y.getMessages()}class Yo{constructor(){E(this,"prefix","[Persona]")}log(p,...i){console.log(`${this.prefix} - ${p}`,...i)}info(p,...i){console.info(`${this.prefix} - ${p}`,...i)}warn(p,...i){console.warn(`${this.prefix} - ${p}`,...i)}error(p,...i){console.error(`${this.prefix} - ${p}`,...i)}debug(p,...i){console.debug(`${this.prefix} - ${p}`,...i)}}function Ct(y,p,i){return{type:y,description:p,...i}}function Qi(y){const p=Object.entries(y.parameters).filter(([i,w])=>w.required).map(([i])=>i);return{type:"local",name:y.name,description:y.description,config:{timeout:y.timeout||60,parameters:{type:"object",title:y.title||`${y.name} parameters`,required:p,properties:y.parameters},output:{type:"object",title:`${y.name} output`,properties:y.output}}}}function Re(y){return{schema:Qi(y),implementation:y.implementation}}function Vi(y,p,i,w,m,C){const b={name:y,description:p,title:C==null?void 0:C.title,timeout:C==null?void 0:C.timeout,parameters:w,output:m,implementation:i};return Re(b)}const Zo=Vi("sum","Sum two numbers",function(p,i){return{result:p+i}},{a:Ct("number","First number to sum",{required:!0}),b:Ct("number","Second number to sum",{required:!0})},{result:Ct("number","Sum of two numbers")}),Xo=Re({name:"navigate_to",description:"Allow agent to redirect user to specific sub page like /foo or #/foo or anything like that",title:"Sum two numbers",timeout:60,parameters:{a:Ct("number","First number to sum"),b:Ct("number","Seconth number to sum")},output:{result:Ct("number","Sum of two numbers")},implementation:function(p,i){return{result:p+i}}});function Qo(y){const p=[],i={};return y.forEach(w=>{const{schema:m,implementation:C}=Re(w);p.push(m),i[w.name]=C}),{schemas:p,implementations:i}}function Vo(y,p){const{required:i,properties:w}=p.config.parameters;for(const m of i)if(!(m in y))throw new Error(`Missing required parameter: ${m}`);for(const[m,C]of Object.entries(y)){const b=w[m];if(b){if(b.type==="number"&&typeof C!="number")throw new Error(`Parameter ${m} should be a number`);if(b.type==="string"&&typeof C!="string")throw new Error(`Parameter ${m} should be a string`);if(b.type==="boolean"&&typeof C!="boolean")throw new Error(`Parameter ${m} should be a boolean`)}}return!0}G.PersonaConsoleLogger=Yo,G.PersonaProtocolBase=te,G.PersonaRESTProtocol=Sr,G.PersonaRuntimeProvider=qo,G.PersonaTransactionProtocol=Zi,G.PersonaWebRTCProtocol=Cr,G.PersonaWebSocketProtocol=Ar,G.createParameter=Ct,G.createTool=Re,G.createToolFromFunction=Vi,G.createToolRegistry=Qo,G.generateToolSchema=Qi,G.navigateToToolExample=Xo,G.sumTool=Zo,G.usePersonaRuntime=zo,G.usePersonaRuntimeEndpoint=Ho,G.usePersonaRuntimeMessages=Jo,G.usePersonaRuntimeProtocol=Xi,G.usePersonaRuntimeWebRTCProtocol=Ko,G.validateToolParameters=Vo,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
38
+ `)+T+`return __p
39
+ }`;var $=hc(function(){return V(l,L+"return "+T).apply(r,d)});if($.source=T,Ri($))throw $;return $}function Lm(t){return Z(t).toLowerCase()}function Bm(t){return Z(t).toUpperCase()}function km(t,e,s){if(t=Z(t),t&&(s||e===r))return va(t);if(!t||!(e=Bt(e)))return t;var o=ne(t),u=ne(e),l=wa(o,u),d=ya(o,u)+1;return Le(o,l,d).join("")}function Dm(t,e,s){if(t=Z(t),t&&(s||e===r))return t.slice(0,Ea(t)+1);if(!t||!(e=Bt(e)))return t;var o=ne(t),u=ya(o,ne(e))+1;return Le(o,0,u).join("")}function Nm(t,e,s){if(t=Z(t),t&&(s||e===r))return t.replace(Rs,"");if(!t||!(e=Bt(e)))return t;var o=ne(t),u=wa(o,ne(e));return Le(o,u).join("")}function Fm(t,e){var s=Ft,o=ft;if(st(e)){var u="separator"in e?e.separator:u;s="length"in e?W(e.length):s,o="omission"in e?Bt(e.omission):o}t=Z(t);var l=t.length;if(cn(t)){var d=ne(t);l=d.length}if(s>=l)return t;var g=s-hn(o);if(g<1)return o;var b=d?Le(d,0,g).join(""):t.slice(0,g);if(u===r)return b+o;if(d&&(g+=b.length-g),Mi(u)){if(t.slice(g).search(u)){var E,x=b;for(u.global||(u=Gs(u.source,Z($o.exec(u))+"g")),u.lastIndex=0;E=u.exec(x);)var T=E.index;b=b.slice(0,T===r?g:T)}}else if(t.indexOf(Bt(u),g)!=g){var M=b.lastIndexOf(u);M>-1&&(b=b.slice(0,M))}return b+o}function Um(t){return t=Z(t),t&&Vl.test(t)?t.replace(Fo,pd):t}var Wm=bn(function(t,e,s){return t+(s?" ":"")+e.toUpperCase()}),Li=lu("toUpperCase");function cc(t,e,s){return t=Z(t),e=s?r:e,e===r?cd(t)?bd(t):td(t):t.match(e)||[]}var hc=z(function(t,e){try{return Ot(t,r,e)}catch(s){return Ri(s)?s:new F(s)}}),$m=me(function(t,e){return $t(e,function(s){s=fe(s),_e(t,s,Ci(t[s],t))}),t});function qm(t){var e=t==null?0:t.length,s=k();return t=e?nt(t,function(o){if(typeof o[1]!="function")throw new qt(p);return[s(o[0]),o[1]]}):[],z(function(o){for(var u=-1;++u<e;){var l=t[u];if(Ot(l[0],this,o))return Ot(l[1],this,o)}})}function zm(t){return pp(Ht(t,C))}function Bi(t){return function(){return t}}function Hm(t,e){return t==null||t!==t?e:t}var Jm=du(),Gm=du(!0);function Mt(t){return t}function ki(t){return za(typeof t=="function"?t:Ht(t,C))}function Km(t){return Ja(Ht(t,C))}function Ym(t,e){return Ga(t,Ht(e,C))}var Vm=z(function(t,e){return function(s){return Hn(s,t,e)}}),Zm=z(function(t,e){return function(s){return Hn(t,s,e)}});function Di(t,e,s){var o=_t(e),u=kr(e,o);s==null&&!(st(e)&&(u.length||!o.length))&&(s=e,e=t,t=this,u=kr(e,_t(e)));var l=!(st(s)&&"chain"in s)||!!s.chain,d=we(t);return $t(u,function(g){var b=e[g];t[g]=b,d&&(t.prototype[g]=function(){var E=this.__chain__;if(l||E){var x=t(this.__wrapped__),T=x.__actions__=Ct(this.__actions__);return T.push({func:b,args:arguments,thisArg:t}),x.__chain__=E,x}return b.apply(t,Ce([this.value()],arguments))})}),t}function Xm(){return bt._===this&&(bt._=Ed),this}function Ni(){}function Qm(t){return t=W(t),z(function(e){return Ka(e,t)})}var jm=pi(nt),tv=pi(pa),ev=pi(Us);function lc(t){return yi(t)?Ws(fe(t)):Pp(t)}function nv(t){return function(e){return t==null?r:Ye(t,e)}}var rv=gu(),sv=gu(!0);function Fi(){return[]}function Ui(){return!1}function iv(){return{}}function ov(){return""}function av(){return!0}function uv(t,e){if(t=W(t),t<1||t>Te)return[];var s=ce,o=vt(t,ce);e=k(e),t-=ce;for(var u=zs(o,e);++s<t;)e(s);return u}function cv(t){return U(t)?nt(t,fe):kt(t)?[t]:Ct(Pu(Z(t)))}function hv(t){var e=++yd;return Z(t)+e}var lv=$r(function(t,e){return t+e},0),fv=gi("ceil"),dv=$r(function(t,e){return t/e},1),pv=gi("floor");function gv(t){return t&&t.length?Br(t,Mt,ti):r}function _v(t,e){return t&&t.length?Br(t,k(e,2),ti):r}function bv(t){return ba(t,Mt)}function mv(t,e){return ba(t,k(e,2))}function vv(t){return t&&t.length?Br(t,Mt,si):r}function wv(t,e){return t&&t.length?Br(t,k(e,2),si):r}var yv=$r(function(t,e){return t*e},1),Sv=gi("round"),Ev=$r(function(t,e){return t-e},0);function xv(t){return t&&t.length?qs(t,Mt):0}function Tv(t,e){return t&&t.length?qs(t,k(e,2)):0}return c.after=K_,c.ary=qu,c.assign=Bb,c.assignIn=nc,c.assignInWith=ts,c.assignWith=kb,c.at=Db,c.before=zu,c.bind=Ci,c.bindAll=$m,c.bindKey=Hu,c.castArray=ib,c.chain=Uu,c.chunk=pg,c.compact=gg,c.concat=_g,c.cond=qm,c.conforms=zm,c.constant=Bi,c.countBy=x_,c.create=Nb,c.curry=Ju,c.curryRight=Gu,c.debounce=Ku,c.defaults=Fb,c.defaultsDeep=Ub,c.defer=Y_,c.delay=V_,c.difference=bg,c.differenceBy=mg,c.differenceWith=vg,c.drop=wg,c.dropRight=yg,c.dropRightWhile=Sg,c.dropWhile=Eg,c.fill=xg,c.filter=A_,c.flatMap=R_,c.flatMapDeep=M_,c.flatMapDepth=P_,c.flatten=ku,c.flattenDeep=Tg,c.flattenDepth=Ag,c.flip=Z_,c.flow=Jm,c.flowRight=Gm,c.fromPairs=Cg,c.functions=Gb,c.functionsIn=Kb,c.groupBy=O_,c.initial=Rg,c.intersection=Mg,c.intersectionBy=Pg,c.intersectionWith=Og,c.invert=Vb,c.invertBy=Zb,c.invokeMap=B_,c.iteratee=ki,c.keyBy=k_,c.keys=_t,c.keysIn=Rt,c.map=Yr,c.mapKeys=Qb,c.mapValues=jb,c.matches=Km,c.matchesProperty=Ym,c.memoize=Zr,c.merge=tm,c.mergeWith=rc,c.method=Vm,c.methodOf=Zm,c.mixin=Di,c.negate=Xr,c.nthArg=Qm,c.omit=em,c.omitBy=nm,c.once=X_,c.orderBy=D_,c.over=jm,c.overArgs=Q_,c.overEvery=tv,c.overSome=ev,c.partial=Ii,c.partialRight=Yu,c.partition=N_,c.pick=rm,c.pickBy=sc,c.property=lc,c.propertyOf=nv,c.pull=Dg,c.pullAll=Nu,c.pullAllBy=Ng,c.pullAllWith=Fg,c.pullAt=Ug,c.range=rv,c.rangeRight=sv,c.rearg=j_,c.reject=W_,c.remove=Wg,c.rest=tb,c.reverse=Ti,c.sampleSize=q_,c.set=im,c.setWith=om,c.shuffle=z_,c.slice=$g,c.sortBy=G_,c.sortedUniq=Yg,c.sortedUniqBy=Vg,c.split=Rm,c.spread=eb,c.tail=Zg,c.take=Xg,c.takeRight=Qg,c.takeRightWhile=jg,c.takeWhile=t_,c.tap=g_,c.throttle=nb,c.thru=Kr,c.toArray=ju,c.toPairs=ic,c.toPairsIn=oc,c.toPath=cv,c.toPlainObject=ec,c.transform=am,c.unary=rb,c.union=e_,c.unionBy=n_,c.unionWith=r_,c.uniq=s_,c.uniqBy=i_,c.uniqWith=o_,c.unset=um,c.unzip=Ai,c.unzipWith=Fu,c.update=cm,c.updateWith=hm,c.values=wn,c.valuesIn=lm,c.without=a_,c.words=cc,c.wrap=sb,c.xor=u_,c.xorBy=c_,c.xorWith=h_,c.zip=l_,c.zipObject=f_,c.zipObjectDeep=d_,c.zipWith=p_,c.entries=ic,c.entriesIn=oc,c.extend=nc,c.extendWith=ts,Di(c,c),c.add=lv,c.attempt=hc,c.camelCase=gm,c.capitalize=ac,c.ceil=fv,c.clamp=fm,c.clone=ob,c.cloneDeep=ub,c.cloneDeepWith=cb,c.cloneWith=ab,c.conformsTo=hb,c.deburr=uc,c.defaultTo=Hm,c.divide=dv,c.endsWith=_m,c.eq=se,c.escape=bm,c.escapeRegExp=mm,c.every=T_,c.find=C_,c.findIndex=Lu,c.findKey=Wb,c.findLast=I_,c.findLastIndex=Bu,c.findLastKey=$b,c.floor=pv,c.forEach=Wu,c.forEachRight=$u,c.forIn=qb,c.forInRight=zb,c.forOwn=Hb,c.forOwnRight=Jb,c.get=Pi,c.gt=lb,c.gte=fb,c.has=Yb,c.hasIn=Oi,c.head=Du,c.identity=Mt,c.includes=L_,c.indexOf=Ig,c.inRange=dm,c.invoke=Xb,c.isArguments=Xe,c.isArray=U,c.isArrayBuffer=db,c.isArrayLike=It,c.isArrayLikeObject=at,c.isBoolean=pb,c.isBuffer=Be,c.isDate=gb,c.isElement=_b,c.isEmpty=bb,c.isEqual=mb,c.isEqualWith=vb,c.isError=Ri,c.isFinite=wb,c.isFunction=we,c.isInteger=Vu,c.isLength=Qr,c.isMap=Zu,c.isMatch=yb,c.isMatchWith=Sb,c.isNaN=Eb,c.isNative=xb,c.isNil=Ab,c.isNull=Tb,c.isNumber=Xu,c.isObject=st,c.isObjectLike=ot,c.isPlainObject=Zn,c.isRegExp=Mi,c.isSafeInteger=Cb,c.isSet=Qu,c.isString=jr,c.isSymbol=kt,c.isTypedArray=vn,c.isUndefined=Ib,c.isWeakMap=Rb,c.isWeakSet=Mb,c.join=Lg,c.kebabCase=vm,c.last=Gt,c.lastIndexOf=Bg,c.lowerCase=wm,c.lowerFirst=ym,c.lt=Pb,c.lte=Ob,c.max=gv,c.maxBy=_v,c.mean=bv,c.meanBy=mv,c.min=vv,c.minBy=wv,c.stubArray=Fi,c.stubFalse=Ui,c.stubObject=iv,c.stubString=ov,c.stubTrue=av,c.multiply=yv,c.nth=kg,c.noConflict=Xm,c.noop=Ni,c.now=Vr,c.pad=Sm,c.padEnd=Em,c.padStart=xm,c.parseInt=Tm,c.random=pm,c.reduce=F_,c.reduceRight=U_,c.repeat=Am,c.replace=Cm,c.result=sm,c.round=Sv,c.runInContext=_,c.sample=$_,c.size=H_,c.snakeCase=Im,c.some=J_,c.sortedIndex=qg,c.sortedIndexBy=zg,c.sortedIndexOf=Hg,c.sortedLastIndex=Jg,c.sortedLastIndexBy=Gg,c.sortedLastIndexOf=Kg,c.startCase=Mm,c.startsWith=Pm,c.subtract=Ev,c.sum=xv,c.sumBy=Tv,c.template=Om,c.times=uv,c.toFinite=ye,c.toInteger=W,c.toLength=tc,c.toLower=Lm,c.toNumber=Kt,c.toSafeInteger=Lb,c.toString=Z,c.toUpper=Bm,c.trim=km,c.trimEnd=Dm,c.trimStart=Nm,c.truncate=Fm,c.unescape=Um,c.uniqueId=hv,c.upperCase=Wm,c.upperFirst=Li,c.each=Wu,c.eachRight=$u,c.first=Du,Di(c,function(){var t={};return he(c,function(e,s){X.call(c.prototype,s)||(t[s]=e)}),t}(),{chain:!1}),c.VERSION=a,$t(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){c[t].placeholder=c}),$t(["drop","take"],function(t,e){J.prototype[t]=function(s){s=s===r?1:pt(W(s),0);var o=this.__filtered__&&!e?new J(this):this.clone();return o.__filtered__?o.__takeCount__=vt(s,o.__takeCount__):o.__views__.push({size:vt(s,ce),type:t+(o.__dir__<0?"Right":"")}),o},J.prototype[t+"Right"]=function(s){return this.reverse()[t](s).reverse()}}),$t(["filter","map","takeWhile"],function(t,e){var s=e+1,o=s==St||s==kl;J.prototype[t]=function(u){var l=this.clone();return l.__iteratees__.push({iteratee:k(u,3),type:s}),l.__filtered__=l.__filtered__||o,l}}),$t(["head","last"],function(t,e){var s="take"+(e?"Right":"");J.prototype[t]=function(){return this[s](1).value()[0]}}),$t(["initial","tail"],function(t,e){var s="drop"+(e?"":"Right");J.prototype[t]=function(){return this.__filtered__?new J(this):this[s](1)}}),J.prototype.compact=function(){return this.filter(Mt)},J.prototype.find=function(t){return this.filter(t).head()},J.prototype.findLast=function(t){return this.reverse().find(t)},J.prototype.invokeMap=z(function(t,e){return typeof t=="function"?new J(this):this.map(function(s){return Hn(s,t,e)})}),J.prototype.reject=function(t){return this.filter(Xr(k(t)))},J.prototype.slice=function(t,e){t=W(t);var s=this;return s.__filtered__&&(t>0||e<0)?new J(s):(t<0?s=s.takeRight(-t):t&&(s=s.drop(t)),e!==r&&(e=W(e),s=e<0?s.dropRight(-e):s.take(e-t)),s)},J.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},J.prototype.toArray=function(){return this.take(ce)},he(J.prototype,function(t,e){var s=/^(?:filter|find|map|reject)|While$/.test(e),o=/^(?:head|last)$/.test(e),u=c[o?"take"+(e=="last"?"Right":""):e],l=o||/^find/.test(e);u&&(c.prototype[e]=function(){var d=this.__wrapped__,g=o?[1]:arguments,b=d instanceof J,E=g[0],x=b||U(d),T=function(H){var G=u.apply(c,Ce([H],g));return o&&M?G[0]:G};x&&s&&typeof E=="function"&&E.length!=1&&(b=x=!1);var M=this.__chain__,L=!!this.__actions__.length,D=l&&!M,$=b&&!L;if(!l&&x){d=$?d:new J(this);var N=t.apply(d,g);return N.__actions__.push({func:Kr,args:[T],thisArg:r}),new zt(N,M)}return D&&$?t.apply(this,g):(N=this.thru(T),D?o?N.value()[0]:N.value():N)})}),$t(["pop","push","shift","sort","splice","unshift"],function(t){var e=vr[t],s=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",o=/^(?:pop|shift)$/.test(t);c.prototype[t]=function(){var u=arguments;if(o&&!this.__chain__){var l=this.value();return e.apply(U(l)?l:[],u)}return this[s](function(d){return e.apply(U(d)?d:[],u)})}}),he(J.prototype,function(t,e){var s=c[e];if(s){var o=s.name+"";X.call(pn,o)||(pn[o]=[]),pn[o].push({name:e,func:s})}}),pn[Wr(r,ct).name]=[{name:"wrapper",func:r}],J.prototype.clone=Ud,J.prototype.reverse=Wd,J.prototype.value=$d,c.prototype.at=__,c.prototype.chain=b_,c.prototype.commit=m_,c.prototype.next=v_,c.prototype.plant=y_,c.prototype.reverse=S_,c.prototype.toJSON=c.prototype.valueOf=c.prototype.value=E_,c.prototype.first=c.prototype.head,Nn&&(c.prototype[Nn]=w_),c},ln=md();ze?((ze.exports=ln)._=ln,ks._=ln):bt._=ln}).call(oe)}(ir,ir.exports);var bl=ir.exports;const ml=$i(bl);class vl{constructor(i){S(this,"config");this.config=i}async complete(i,r){var a;await this.persist(i,{...r,success:!0}),(a=this.config.logger)==null||a.debug("Transaction completed:",i)}async fail(i,r){var a;await this.persist(i,{...r,success:!1}),(a=this.config.logger)==null||a.debug("Transaction failed:",{...i,...r})}async persist(i,r){await fetch(`${this.config.apiUrl}/transactions/${i.id}`,{body:JSON.stringify(r),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class wl{constructor(i,r){S(this,"transaction");S(this,"manager");this.transaction=i,this.manager=r}getFunctionCall(){return this.transaction.functionCall}async invoke(i,r){var m;const a=this.transaction.functionCall;if(!a){await this.fail("No function call found");return}const h=a.name,f=a.args,p=i[h];if(!p){await this.fail(`Tool ${h} not found`);return}try{const w=ml.get(r,"schema.config.parameters.properties",{}),P=(w&&Object.keys(w).length>0?Object.keys(w):((m=p.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:m[1].split(",").map(A=>A.trim()).filter(Boolean))||[]).map(A=>f[A]),C=await p.apply(null,P);await this.complete(C)}catch(w){await this.fail(`Error executing tool ${h}: ${w}`)}}async complete(i){await this.manager.complete(this.transaction,{success:!0,output:i,error:null})}async fail(i){await this.manager.fail(this.transaction,{success:!1,output:null,error:i})}}class Oo extends Cn{constructor(r){super();S(this,"status");S(this,"autostart");S(this,"session");S(this,"config");S(this,"notify",!0);S(this,"_tools");S(this,"_toolSchema",{});if(this.config=r,this.status="disconnected",this.autostart=!0,Array.isArray(r.tools)){this._tools={};for(const a of r.tools)a.schema&&a.implementation&&(this._tools[a.schema.name]=a.implementation,this._toolSchema[a.schema.name]=a)}else this._tools=r.tools}getName(){return"transaction"}getPriority(){return 0}getToolInstance(r){return this._toolSchema[r]}async connect(r){return this.setStatus("connected"),r}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(r){this.session=r}async sendPacket(r){}onTransaction(r){const a=new vl(this.config),h=new wl(r,a);if(this.config.onTransaction)this.config.onTransaction(h);else{const f=r.functionCall?this.getToolInstance(r.functionCall.name):void 0;h.invoke(this._tools,f)}}getTools(){return this._tools}}const In=B.createContext(void 0);function yl(n){return new Promise((i,r)=>{const a=new FileReader;a.readAsDataURL(n),a.onload=()=>{const f=a.result.split(";base64,")[1];i(f)},a.onerror=h=>{r(h)}})}function Sl(n){const i={rest:r=>r.config.apiUrl,webrtc:r=>r.config.webrtcUrl.replace("/webrtc","").replace("ws://","http://").replace("wss://","https://"),websocket:r=>r.config.webSocketUrl.replace("/websocket","").replace("ws://","http://").replace("wss://","https://")};for(const r of n){const a=i[r.getName()];if(a)return a(r)}return null}function El({dev:n=!1,baseUrl:i,protocols:r,logger:a,children:h,session:f="new",transformMessages:p,...m}){const[w,I]=B.useState(!1),[P,C]=B.useState([]),[A,R]=B.useState(f),[K,At]=B.useState(new Map),gt=B.useRef(!1),ct=B.useMemo(()=>{if(Array.isArray(r))return r;if(typeof r=="object"&&r!==null){const q=n?"localhost:8000":i||"persona.applica.guru/api",ht=n?"http":"https",Q=n?"ws":"wss";let Ft=Object.keys(r).map(ft=>{switch(ft){case"rest":const Ut=r[ft];return Ut===!0?new _s({apiUrl:`${ht}://${q}`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof Ut=="object"&&Ut!==null?new _s(Ut):null;case"webrtc":const it=r[ft];return it===!0?new ms({webrtcUrl:`${Q}://${q}/webrtc`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof it=="object"&&it!==null?new ms(it):null;case"websocket":const St=r[ft];return St===!0?new bs({webSocketUrl:`${Q}://${q}/websocket`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof St=="object"&&St!==null?new bs(St):null;default:throw new Error(`Unknown protocol: ${ft}`)}}).filter(ft=>ft!==null);return m.tools&&Ft.push(new Oo({apiUrl:`${ht}://${q}`,apiKey:m.apiKey,agentId:m.agentId,tools:m.tools,logger:a})),Ft}throw new Error("Invalid protocols configuration")},[]);B.useEffect(()=>{gt.current||(gt.current=!0,a==null||a.debug("Initializing protocols: ",ct.map(q=>q.getName())),ct.forEach(q=>{q.setSession(A),q.clearListeners(),q.addStatusChangeListener(ht=>{a==null||a.debug(`${q.getName()} has notified new status: ${ht}`),K.set(q.getName(),ht),ht==="connected"&&(m.context&&q.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:m.context}}),m.tools&&Array.isArray(m.tools)&&q.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:m.tools.map(Q=>Q.schema)}}})),At(new Map(K))}),q.addPacketListener(ht=>{if(ht.type==="message"){const Q=ht.payload;(Q==null?void 0:Q.finishReason)==="stop"&&!(Q!=null&&Q.functionResponse)&&!(Q!=null&&Q.thought)&&I(!1),Q.thought&&(Q.type="reasoning"),C(Ft=>{const ft=Po([...Ft,{...Q,protocol:q.getName()}]);return p?p(ft):ft})}else if(ht.type==="reasoning"){const Ft={type:"reasoning",text:ht.payload.thought,role:"assistant",finishReason:"stop"};C(ft=>{const Ut=Po([...ft,{...Ft,protocol:q.getName()}]);return p?p(Ut):Ut})}else ht.type==="transaction"&&ct.filter(Q=>Q!==q).forEach(Q=>Q.onTransaction(ht.payload))}),q.autostart&&q.status==="disconnected"&&(a==null||a.debug(`Connecting to protocol: ${q.getName()}`),q.connect(A),I(!1))}))},[A,ct,a,K,p]);const ar=async q=>{var Ut;if(((Ut=q.content[0])==null?void 0:Ut.type)!=="text")throw new Error("Only text messages are supported");if(!ct.some(it=>it.getName()!=="transaction"&&it.status==="connected")){C(it=>{const St=[...it,{role:"assistant",type:"text",text:"No protocol is connected."}];return p?p(St):St});return}const Q=q.content[0].text;C(it=>{const St=[...it,{role:"user",type:"text",text:Q}];return p?p(St):St}),I(!0);const Ft=ct.sort((it,St)=>St.getPriority()-it.getPriority()).find(it=>it.status==="connected"),ft=[];if(q.attachments)for(const it of q.attachments)it.contentType.startsWith("image/")&&it.file&&ft.push({role:"user",image:{contentType:it.contentType,content:await yl(it.file)},text:"",type:"text"});q.content&&ft.push({role:"user",text:q.content[0].text,type:"text"}),a==null||a.debug("Sending message:",ft),await(Ft==null?void 0:Ft.sendPacket({type:"request",payload:ft}))},Qt=B.useCallback(()=>(I(!1),C([]),R("new"),Promise.resolve()),[]),We=B.useCallback(()=>Promise.resolve(),[]),jt=B.useCallback(()=>P,[P]),$e=ch({isRunning:w,messages:P,convertMessage:gl,onNew:ar,onCancel:Qt,onReload:We,adapters:{attachments:new Xc([new Vc])}});return Ee.jsx(In.Provider,{value:{protocols:ct,protocolsStatus:K,getMessages:jt},children:Ee.jsx(fl,{runtime:$e,children:h})})}function xl({children:n,...i}){return Ee.jsx(El,{...i,children:n})}function Tl(){const n=B.useContext(In);if(!n)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return n}function Lo(n){const i=B.useContext(In);if(!i)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const r=i.protocols.find(h=>h.getName()===n);if(!r)return null;const a=i.protocolsStatus.get(r.getName());return{...r,connect:r.connect.bind(r),disconnect:r.disconnect.bind(r),sendPacket:r.sendPacket.bind(r),setSession:r.setSession.bind(r),addStatusChangeListener:r.addStatusChangeListener.bind(r),addPacketListener:r.addPacketListener.bind(r),getName:r.getName.bind(r),getPriority:r.getPriority.bind(r),status:a||r.status}}function Al(){const n=B.useContext(In);if(!n)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return Sl(n.protocols)}function Cl(){return Lo("webrtc")}function Il(){const n=B.useContext(In);if(!n)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return n.getMessages()}class Rl{constructor(){S(this,"prefix","[Persona]")}log(i,...r){console.log(`${this.prefix} - ${i}`,...r)}info(i,...r){console.info(`${this.prefix} - ${i}`,...r)}warn(i,...r){console.warn(`${this.prefix} - ${i}`,...r)}error(i,...r){console.error(`${this.prefix} - ${i}`,...r)}debug(i,...r){console.debug(`${this.prefix} - ${i}`,...r)}}function Fe(n,i,r){return{type:n,description:i,...r}}function Bo(n){const i=Object.entries(n.parameters).filter(([r,a])=>a.required).map(([r])=>r);return{type:"local",name:n.name,description:n.description,config:{timeout:n.timeout||60,parameters:{type:"object",title:n.title||`${n.name} parameters`,required:i,properties:n.parameters},output:{type:"object",title:`${n.name} output`,properties:n.output}}}}function or(n){return{schema:Bo(n),implementation:n.implementation}}function ko(n,i,r,a,h,f){const p={name:n,description:i,title:f==null?void 0:f.title,timeout:f==null?void 0:f.timeout,parameters:a,output:h,implementation:r};return or(p)}const Ml=ko("sum","Sum two numbers",function(i,r){return{result:i+r}},{a:Fe("number","First number to sum",{required:!0}),b:Fe("number","Second number to sum",{required:!0})},{result:Fe("number","Sum of two numbers")}),Pl=or({name:"navigate_to",description:"Allow agent to redirect user to specific sub page like /foo or #/foo or anything like that",title:"Sum two numbers",timeout:60,parameters:{a:Fe("number","First number to sum"),b:Fe("number","Seconth number to sum")},output:{result:Fe("number","Sum of two numbers")},implementation:function(i,r){return{result:i+r}}});function Ol(n){const i=[],r={};return n.forEach(a=>{const{schema:h,implementation:f}=or(a);i.push(h),r[a.name]=f}),{schemas:i,implementations:r}}function Ll(n,i){const{required:r,properties:a}=i.config.parameters;for(const h of r)if(!(h in n))throw new Error(`Missing required parameter: ${h}`);for(const[h,f]of Object.entries(n)){const p=a[h];if(p){if(p.type==="number"&&typeof f!="number")throw new Error(`Parameter ${h} should be a number`);if(p.type==="string"&&typeof f!="string")throw new Error(`Parameter ${h} should be a string`);if(p.type==="boolean"&&typeof f!="boolean")throw new Error(`Parameter ${h} should be a boolean`)}}return!0}Y.PersonaConsoleLogger=Rl,Y.PersonaProtocolBase=Cn,Y.PersonaRESTProtocol=_s,Y.PersonaRuntimeProvider=xl,Y.PersonaTransactionProtocol=Oo,Y.PersonaWebRTCProtocol=ms,Y.PersonaWebSocketProtocol=bs,Y.createParameter=Fe,Y.createTool=or,Y.createToolFromFunction=ko,Y.createToolRegistry=Ol,Y.generateToolSchema=Bo,Y.navigateToToolExample=Pl,Y.sumTool=Ml,Y.usePersonaRuntime=Tl,Y.usePersonaRuntimeEndpoint=Al,Y.usePersonaRuntimeMessages=Il,Y.usePersonaRuntimeProtocol=Lo,Y.usePersonaRuntimeWebRTCProtocol=Cl,Y.validateToolParameters=Ll,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
36
40
  //# sourceMappingURL=bundle.umd.js.map