@applica-software-guru/persona-sdk 0.1.68 → 0.1.70

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
- "use strict";var G=Object.defineProperty;var H=(o,t,e)=>t in o?G(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e;var i=(o,t,e)=>H(o,typeof t!="symbol"?t+"":t,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),v=require("@assistant-ui/react");var F={exports:{}},R={};/**
1
+ "use strict";var Ad=Object.defineProperty;var Cd=(y,g,i)=>g in y?Ad(y,g,{enumerable:!0,configurable:!0,writable:!0,value:i}):y[g]=i;var E=(y,g,i)=>Cd(y,typeof g!="symbol"?g+"":g,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const mn=require("react"),_r=require("@assistant-ui/react");var ve=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bd(y){return y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y.default:y}var bo={exports:{}},we={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,33 @@
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 W;function Q(){if(W)return R;W=1;var o=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function e(s,n,a){var r=null;if(a!==void 0&&(r=""+a),n.key!==void 0&&(r=""+n.key),"key"in n){a={};for(var c in n)c!=="key"&&(a[c]=n[c])}else a=n;return n=a.ref,{$$typeof:o,type:s,key:r,ref:n!==void 0?n:null,props:a}}return R.Fragment=t,R.jsx=e,R.jsxs=e,R}F.exports=Q();var M=F.exports;function X(o){return o.filter(t=>{var e;return t.finishReason==="stop"?t.text!==null&&((e=t.text)==null?void 0:e.trim())!=="":!0})}function _(o){const t=[];let e=null;for(const n of o)n.type!=="transaction"&&(n.type==="reasoning"?(e!=null&&(t.push(e),e=null),t.push(n)):n.functionCalls?(e&&t.push(e),t.push(n),e=null):n.functionResponse?t[t.length-1]={...t[t.length-1],functionResponse:n.functionResponse}:e&&n.protocol===e.protocol&&(e.role===n.role||n.finishReason==="stop")?(e.text+=n.text,e.files=[...e.files??[],...n.files??[]]):(e&&t.push(e),e={...n}));return e&&t.push(e),X(t)}function Z(o){var e,s;const t=((e=o.files)==null?void 0:e.map(n=>({type:"file",data:n.url,mimeType:n.contentType})))??[];return o.role==="function"?{id:o.id,role:"assistant",status:(o==null?void 0:o.functionResponse)===null?{type:"running"}:{type:"complete",reason:"stop"},content:((s=o.functionCalls)==null?void 0:s.map(n=>{var a;return{type:"tool-call",toolName:n.name,toolCallId:n.id,args:n.args,result:(a=o.functionResponse)==null?void 0:a.result}}))??[]}:{id:o.id,role:o.role,content:o.type==="reasoning"?[{type:"reasoning",text:o.text},...t]:[{type:"text",text:o.text},...t]}}class T{constructor(){i(this,"statusChangeCallbacks",[]);i(this,"messageCallbacks",[])}addStatusChangeListener(t){this.statusChangeCallbacks.push(t)}addPacketListener(t){this.messageCallbacks.push(t)}async syncSession(t){this.session=t}async notifyPacket(t){this.messageCallbacks.forEach(e=>e(t))}async notifyPackets(t){t.forEach(e=>{this.messageCallbacks.forEach(s=>s(e))})}async setSession(t){this.session=t}async setStatus(t){const e=this.status!==t;this.status=t,e&&this.statusChangeCallbacks.forEach(s=>s(t))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}onTransaction(t){}}class I extends T{constructor(e){super();i(this,"status");i(this,"autostart");i(this,"session");i(this,"config");i(this,"notify",!0);i(this,"context",{});i(this,"tools",[]);this.config=e,this.status="disconnected",this.autostart=!0}getName(){return"rest"}getPriority(){return 100}async connect(e){return this.setStatus("connected"),e}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(e){this.session=e}async sendPacket(e){var u,d,g,P;const{apiUrl:s,apiKey:n,agentId:a}=this.config,r=this.session??"new";if(e.type==="command"&&((u=e==null?void 0:e.payload)==null?void 0:u.command)=="set_initial_context"){this.context=(d=e==null?void 0:e.payload)==null?void 0:d.arguments;return}else if(e.type==="command"&&((g=e==null?void 0:e.payload)==null?void 0:g.command)=="set_local_tools"){this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const c=e.payload;try{const k=await(await fetch(`${s}/sessions/${r}/messages`,{body:JSON.stringify({agentId:a,userMessage:c,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":n}})).json();this.notifyPackets(k.response.messages.map(N=>({type:"message",payload:N})))}catch(A){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(P=this.config.logger)==null||P.error("Error sending packet:",A)}}}class q extends T{constructor(e){super();i(this,"status");i(this,"autostart");i(this,"session");i(this,"config");i(this,"webSocket");this.config=e,this.status="disconnected",this.autostart=!0,this.session=null,this.webSocket=null}getName(){return"websocket"}getPriority(){return 500}async syncSession(e){var s;(s=this.config.logger)==null||s.debug("Syncing session with WebSocket protocol:",e),this.session=e,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(e))}connect(e){var c;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const s=e||this.session||"new";(c=this.config.logger)==null||c.debug("Connecting to WebSocket with sessionId:",s);const n=encodeURIComponent(this.config.apiKey),a=this.config.agentId,r=`${this.config.webSocketUrl}?sessionCode=${s}&agentId=${a}&apiKey=${n}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(r),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",u=>{const d=JSON.parse(u.data);this.notifyPacket(d)}),this.webSocket.addEventListener("close",u=>{var d;this.setStatus("disconnected"),this.webSocket=null,u.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(d=this.config.logger)==null||d.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var u;this.setStatus("disconnected"),this.webSocket=null,(u=this.config.logger)==null||u.error("WebSocket connection error")}),Promise.resolve(s)}disconnect(){var e;return(e=this.config.logger)==null||e.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(e){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(e)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class ee{constructor(t){i(this,"config");i(this,"pc",null);i(this,"ws",null);i(this,"localStream",null);i(this,"remoteStream",new MediaStream);i(this,"audioCtx",null);i(this,"localAnalyser",null);i(this,"remoteAnalyser",null);i(this,"analyzerFrame",null);i(this,"dataChannel",null);i(this,"isConnected",!1);i(this,"visualizerCallbacks",[]);i(this,"messageCallbacks",[]);i(this,"errorCallbacks",[]);i(this,"queuedMessages",[]);this.config=t}async connect(t){var s;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(n){(s=this.config.logger)==null||s.error("Error accessing microphone:",n);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(n=>{this.pc.addTrack(n,this.localStream)}),this.pc.ontrack=n=>{n.streams[0].getTracks().forEach(r=>{this.remoteStream.addTrack(r)}),this.audioCtx||this._startAnalyzers();const a=new Audio;a.srcObject=this.remoteStream,a.play().catch(r=>{var c;(c=this.config.logger)==null||c.error("Error playing remote audio:",r)})},this.pc.onicecandidate=n=>{var a;n.candidate&&((a=this.ws)==null?void 0:a.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:n.candidate}}))},this.pc.ondatachannel=n=>{const a=n.channel;a.onmessage=r=>{this.messageCallbacks.forEach(c=>{c(r)})},a.onopen=()=>{var r;for(;this.queuedMessages.length>0;){const c=this.queuedMessages.shift();c&&(a.send(JSON.stringify(c)),(r=this.config.logger)==null||r.info("Sent queued message:",c))}}};const e=this.config.webrtcUrl||"wss://persona.applica.guru/api/webrtc";this.ws=new WebSocket(`${e}?apiKey=${encodeURIComponent(this.config.apiKey)}`),this.ws.onopen=async()=>{var c,u;const n=await this.pc.createOffer();await this.pc.setLocalDescription(n);const a={apiKey:this.config.apiKey,agentId:this.config.agentId,sessionCode:t};(c=this.config.logger)==null||c.debug("Opening connection to WebRTC server: ",a);const r={type:"OFFER",src:((u=crypto.randomUUID)==null?void 0:u.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:n.sdp,type:n.type},connectionId:(Date.now()%1e6).toString(),metadata:a}};this.ws.send(JSON.stringify(r))},this.ws.onmessage=async n=>{var r;const a=JSON.parse(n.data);if(a.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(a.payload.sdp));else if(a.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(a.payload.candidate))}catch(c){(r=this.config.logger)==null||r.error("Error adding ICE candidate:",c)}},this.ws.onclose=n=>{n.code!==1e3&&this.errorCallbacks.forEach(a=>{a("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var t;this.isConnected&&(this.isConnected=!1,((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN&&this.ws.close(),this.pc&&this.pc.close(),this.localStream&&this.localStream.getTracks().forEach(e=>e.stop()),this.remoteStream=new MediaStream,this.audioCtx&&(await this.audioCtx.close(),this.audioCtx=null),this._stopAnalyzers())}addVisualizerCallback(t){this.visualizerCallbacks.push(t)}addMessageCallback(t){this.messageCallbacks.push(t)}addErrorCallback(t){this.errorCallbacks.push(t)}createDataChannel(t="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(t),this.dataChannel.onopen=()=>{var e,s;for((e=this.config.logger)==null||e.info("Data channel opened");this.queuedMessages.length>0;){const n=this.queuedMessages.shift();n&&(this.dataChannel.send(JSON.stringify(n)),(s=this.config.logger)==null||s.info("Sent queued message:",n))}},this.dataChannel.onmessage=e=>{this.messageCallbacks.forEach(s=>{s(e)})})}sendPacket(t){var e;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(t);return}this.dataChannel.send(JSON.stringify(t)),(e=this.config.logger)==null||e.info("Sent message:",t)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const t=this.audioCtx.createMediaStreamSource(this.localStream),e=this.audioCtx.createMediaStreamSource(this.remoteStream);this.localAnalyser=this.audioCtx.createAnalyser(),this.remoteAnalyser=this.audioCtx.createAnalyser(),this.localAnalyser.fftSize=256,this.remoteAnalyser.fftSize=256,t.connect(this.localAnalyser),e.connect(this.remoteAnalyser);const s=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const n=new Uint8Array(this.localAnalyser.frequencyBinCount),a=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(n),this.remoteAnalyser.getByteFrequencyData(a);const r=n.reduce((u,d)=>u+d,0)/n.length,c=a.reduce((u,d)=>u+d,0)/a.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(u=>{u({localAmplitude:r,remoteAmplitude:c})}),this.analyzerFrame=requestAnimationFrame(s)};this.analyzerFrame=requestAnimationFrame(s)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class O extends T{constructor(e){super();i(this,"status");i(this,"session");i(this,"autostart");i(this,"config");i(this,"webRTCClient");this.config=e,this.status="disconnected",this.session=null,this.autostart=(e==null?void 0:e.autostart)??!1,this.webRTCClient=new ee(e),this.webRTCClient.addMessageCallback(s=>{const n=JSON.parse(s.data);this.notifyPacket(n)}),this.webRTCClient.addErrorCallback(s=>{var n;(n=this.config.logger)==null||n.error("WebRTC error:",s),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:s}})})}getName(){return"webrtc"}getPriority(){return 1e3}async syncSession(e){super.syncSession(e),this.status==="connected"&&(await this.disconnect(),await this.connect(e))}async connect(e){var s;return this.status==="connected"?Promise.resolve(this.session):(this.session=e||this.session||"new",this.setStatus("connecting"),(s=this.config.logger)==null||s.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 e,s,n;if(this.status==="disconnected")return(e=this.config.logger)==null||e.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(n=(s=this.config)==null?void 0:s.logger)==null||n.debug("Disconnected from WebRTC")}sendPacket(e){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(e),Promise.resolve())}}class te{constructor(t){i(this,"config");this.config=t}async complete(t,e){var s;await this.persist(t,{...e,success:!0}),(s=this.config.logger)==null||s.debug("Transaction completed:",t)}async fail(t,e){var s;await this.persist(t,{...e,success:!1}),(s=this.config.logger)==null||s.debug("Transaction failed:",{...t,...e})}async persist(t,e){await fetch(`${this.config.apiUrl}/transactions/${t.id}`,{body:JSON.stringify(e),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class se{constructor(t,e){i(this,"transaction");i(this,"manager");this.transaction=t,this.manager=e}getFunctionCall(){return this.transaction.functionCall}async invoke(t){var r;const e=this.transaction.functionCall;if(!e){await this.fail("No function call found");return}const s=e.name,n=e.args,a=t[s];if(!a){await this.fail(`Tool ${s} not found`);return}try{const u=(((r=a.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:r[1].split(",").map(g=>g.trim()).filter(Boolean))||[]).map(g=>n[g]),d=await a.apply(null,u);await this.complete(d)}catch(c){await this.fail(`Error executing tool ${s}: ${c}`)}}async complete(t){await this.manager.complete(this.transaction,{success:!0,output:t,error:null})}async fail(t){await this.manager.fail(this.transaction,{success:!1,output:null,error:t})}}class U extends T{constructor(e){super();i(this,"status");i(this,"autostart");i(this,"session");i(this,"config");i(this,"notify",!0);i(this,"_tools");if(this.config=e,this.status="disconnected",this.autostart=!0,Array.isArray(e.tools)){this._tools={};for(const s of e.tools)s.schema&&s.implementation&&(this._tools[s.schema.name]=s.implementation)}else this._tools=e.tools}getName(){return"transaction"}getPriority(){return 0}async connect(e){return this.setStatus("connected"),e}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(e){this.session=e}async sendPacket(e){}onTransaction(e){console.log("transaction received:",e);const s=new te(this.config),n=new se(e,s);this.config.onTransaction?this.config.onTransaction(n):n.invoke(this._tools)}getTools(){return this._tools}}const E=m.createContext(void 0);function ne(o){return new Promise((t,e)=>{const s=new FileReader;s.readAsDataURL(o),s.onload=()=>{const a=s.result.split(";base64,")[1];t(a)},s.onerror=n=>{e(n)}})}function oe({dev:o=!1,baseUrl:t,protocols:e,logger:s,children:n,session:a="new",...r}){const[c,u]=m.useState(!1),[d,g]=m.useState([]),[P,A]=m.useState(a),[k,N]=m.useState(new Map),j=m.useRef(!1),S=m.useMemo(()=>{if(Array.isArray(e))return e;if(typeof e=="object"&&e!==null){const l=o?"localhost:8000":t||"persona.applica.guru/api",f=o?"http":"https",p=o?"ws":"wss";let w=Object.keys(e).map(y=>{switch(y){case"rest":const b=e[y];return b===!0?new I({apiUrl:`${f}://${l}`,apiKey:r.apiKey,agentId:r.agentId,logger:s}):typeof b=="object"&&b!==null?new I(b):null;case"webrtc":const h=e[y];return h===!0?new O({webrtcUrl:`${p}://${l}/webrtc`,apiKey:r.apiKey,agentId:r.agentId,logger:s}):typeof h=="object"&&h!==null?new O(h):null;case"websocket":const x=e[y];return x===!0?new q({webSocketUrl:`${p}://${l}/websocket`,apiKey:r.apiKey,agentId:r.agentId,logger:s}):typeof x=="object"&&x!==null?new q(x):null;default:throw new Error(`Unknown protocol: ${y}`)}}).filter(y=>y!==null);return r.tools&&w.push(new U({apiUrl:`${f}://${l}`,apiKey:r.apiKey,agentId:r.agentId,tools:r.tools,logger:s})),w}throw new Error("Invalid protocols configuration")},[]);m.useEffect(()=>{j.current||(j.current=!0,s==null||s.debug("Initializing protocols: ",S.map(l=>l.getName())),S.forEach(l=>{l.setSession(P),l.clearListeners(),l.addStatusChangeListener(f=>{s==null||s.debug(`${l.getName()} has notified new status: ${f}`),k.set(l.getName(),f),f==="connected"&&(r.context&&l.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:r.context}}),r.tools&&Array.isArray(r.tools)&&l.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:r.tools.map(p=>p.schema)}}})),N(new Map(k))}),l.addPacketListener(f=>{if(f.type==="message"){const p=f.payload;g(w=>_([...w,{...p,protocol:l.getName()}]))}else if(f.type==="reasoning"){const p=f.payload;let w=p.thought;p.imageUrl&&(w+=`
9
+ */var Ao;function Rd(){if(Ao)return we;Ao=1;var y=Symbol.for("react.transitional.element"),g=Symbol.for("react.fragment");function i(w,m,C){var A=null;if(C!==void 0&&(A=""+C),m.key!==void 0&&(A=""+m.key),"key"in m){C={};for(var B in m)B!=="key"&&(C[B]=m[B])}else C=m;return m=C.ref,{$$typeof:y,type:w,key:A,ref:m!==void 0?m:null,props:C}}return we.Fragment=g,we.jsx=i,we.jsxs=i,we}bo.exports=Rd();var $i=bo.exports;function Td(y){return y.filter(g=>{var i;return g.finishReason==="stop"?g.text!==null&&((i=g.text)==null?void 0:i.trim())!=="":!0})}function Co(y){const g=[];let i=null;for(const m of y)m.type!=="transaction"&&(m.type==="reasoning"?(i!=null&&(g.push(i),i=null),g.push(m)):m.functionCalls?(i&&g.push(i),g.push(m),i=null):m.functionResponse?g[g.length-1]={...g[g.length-1],functionResponse:m.functionResponse}:i&&m.protocol===i.protocol&&(i.role===m.role||m.finishReason==="stop")?(i.text+=m.text,i.files=[...i.files??[],...m.files??[]]):(i&&g.push(i),i={...m}));return i&&g.push(i),Td(g)}function Pd(y){var i,w;const g=((i=y.files)==null?void 0:i.map(m=>({type:"file",data:m.url,mimeType:m.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:((w=y.functionCalls)==null?void 0:w.map(m=>{var C;return{type:"tool-call",toolName:m.name,toolCallId:m.id,args:m.args,result:(C=y.functionResponse)==null?void 0:C.result}}))??[]}:{id:y.id,role:y.role,content:y.type==="reasoning"?[{type:"reasoning",text:y.text},...g]:[{type:"text",text:y.text},...g]}}class me{constructor(){E(this,"statusChangeCallbacks",[]);E(this,"messageCallbacks",[])}addStatusChangeListener(g){this.statusChangeCallbacks.push(g)}addPacketListener(g){this.messageCallbacks.push(g)}async syncSession(g){this.session=g}async notifyPacket(g){this.messageCallbacks.forEach(i=>i(g))}async notifyPackets(g){g.forEach(i=>{this.messageCallbacks.forEach(w=>w(i))})}async setSession(g){this.session=g}async setStatus(g){const i=this.status!==g;this.status=g,i&&this.statusChangeCallbacks.forEach(w=>w(g))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}onTransaction(g){}}class qi extends me{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 N,on,dn,ln,Nn;const{apiUrl:w,apiKey:m,agentId:C}=this.config,A=this.session??"new";if(i.type==="command"&&((N=i==null?void 0:i.payload)==null?void 0:N.command)=="set_initial_context"){this.context=(on=i==null?void 0:i.payload)==null?void 0:on.arguments;return}else if(i.type==="command"&&((dn=i==null?void 0:i.payload)==null?void 0:dn.command)=="set_local_tools"){const an=(ln=i==null?void 0:i.payload)==null?void 0:ln.arguments.tools;(an==null?void 0:an.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const B=i.payload;try{const Yn=await(await fetch(`${w}/sessions/${A}/messages`,{body:JSON.stringify({agentId:C,userMessage:B,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":m}})).json();this.notifyPackets(Yn.response.messages.map(jn=>({type:"message",payload:jn})))}catch(an){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(Nn=this.config.logger)==null||Nn.error("Error sending packet:",an)}}}class Gi extends me{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 B;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const w=i||this.session||"new";(B=this.config.logger)==null||B.debug("Connecting to WebSocket with sessionId:",w);const m=encodeURIComponent(this.config.apiKey),C=this.config.agentId,A=`${this.config.webSocketUrl}?sessionCode=${w}&agentId=${C}&apiKey=${m}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(A),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",N=>{const on=JSON.parse(N.data);this.notifyPacket(on)}),this.webSocket.addEventListener("close",N=>{var on;this.setStatus("disconnected"),this.webSocket=null,N.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(on=this.config.logger)==null||on.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var N;this.setStatus("disconnected"),this.webSocket=null,(N=this.config.logger)==null||N.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 Ed{constructor(g){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=g}async connect(g){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(A=>{this.remoteStream.addTrack(A)}),this.audioCtx||this._startAnalyzers();const C=new Audio;C.srcObject=this.remoteStream,C.play().catch(A=>{var B;(B=this.config.logger)==null||B.error("Error playing remote audio:",A)})},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=A=>{this.messageCallbacks.forEach(B=>{B(A)})},C.onopen=()=>{var A;for(;this.queuedMessages.length>0;){const B=this.queuedMessages.shift();B&&(C.send(JSON.stringify(B)),(A=this.config.logger)==null||A.info("Sent queued message:",B))}}};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 B,N;const m=await this.pc.createOffer();await this.pc.setLocalDescription(m);const C={apiKey:this.config.apiKey,agentId:this.config.agentId,sessionCode:g};(B=this.config.logger)==null||B.debug("Opening connection to WebRTC server: ",C);const A={type:"OFFER",src:((N=crypto.randomUUID)==null?void 0:N.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(A))},this.ws.onmessage=async m=>{var A;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(B){(A=this.config.logger)==null||A.error("Error adding ICE candidate:",B)}},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 g;this.isConnected&&(this.isConnected=!1,((g=this.ws)==null?void 0:g.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(g){this.visualizerCallbacks.push(g)}addMessageCallback(g){this.messageCallbacks.push(g)}addErrorCallback(g){this.errorCallbacks.push(g)}createDataChannel(g="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(g),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(g){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(g);return}this.dataChannel.send(JSON.stringify(g)),(i=this.config.logger)==null||i.info("Sent message:",g)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const g=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,g.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 A=m.reduce((N,on)=>N+on,0)/m.length,B=C.reduce((N,on)=>N+on,0)/C.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(N=>{N({localAmplitude:A,remoteAmplitude:B})}),this.analyzerFrame=requestAnimationFrame(w)};this.analyzerFrame=requestAnimationFrame(w)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class ki extends me{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 Ed(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 vr={exports:{}};/**
10
+ * @license
11
+ * Lodash <https://lodash.com/>
12
+ * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
13
+ * Released under MIT license <https://lodash.com/license>
14
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
15
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
16
+ */vr.exports;(function(y,g){(function(){var i,w="4.17.21",m=200,C="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",A="Expected a function",B="Invalid `variable` option passed into `_.template`",N="__lodash_hash_undefined__",on=500,dn="__lodash_placeholder__",ln=1,Nn=2,an=4,Yn=1,jn=2,tn=1,lt=2,xe=4,Bn=8,xt=16,$n=32,en=64,$=128,V=256,X=512,rn=30,qn="...",J=800,ct=16,zi=1,Lo=2,Oo=3,Se=1/0,Ot=9007199254740991,Wo=17976931348623157e292,Ae=NaN,Zn=4294967295,Mo=Zn-1,Fo=Zn>>>1,Uo=[["ary",$],["bind",tn],["bindKey",lt],["curry",Bn],["curryRight",xt],["flip",X],["partial",$n],["partialRight",en],["rearg",V]],Wt="[object Arguments]",Ce="[object Array]",Do="[object AsyncFunction]",Zt="[object Boolean]",Xt="[object Date]",No="[object DOMException]",be="[object Error]",Re="[object Function]",Hi="[object GeneratorFunction]",Gn="[object Map]",Qt="[object Number]",Bo="[object Null]",nt="[object Object]",Ki="[object Promise]",$o="[object Proxy]",Vt="[object RegExp]",kn="[object Set]",jt="[object String]",Te="[object Symbol]",qo="[object Undefined]",ne="[object WeakMap]",Go="[object WeakSet]",te="[object ArrayBuffer]",Mt="[object DataView]",mr="[object Float32Array]",yr="[object Float64Array]",xr="[object Int8Array]",Sr="[object Int16Array]",Ar="[object Int32Array]",Cr="[object Uint8Array]",br="[object Uint8ClampedArray]",Rr="[object Uint16Array]",Tr="[object Uint32Array]",ko=/\b__p \+= '';/g,zo=/\b(__p \+=) '' \+/g,Ho=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ji=/&(?:amp|lt|gt|quot|#39);/g,Yi=/[&<>"']/g,Ko=RegExp(Ji.source),Jo=RegExp(Yi.source),Yo=/<%-([\s\S]+?)%>/g,Zo=/<%([\s\S]+?)%>/g,Zi=/<%=([\s\S]+?)%>/g,Xo=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qo=/^\w*$/,Vo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Pr=/[\\^$.*+?()[\]{}|]/g,jo=RegExp(Pr.source),Er=/^\s+/,na=/\s/,ta=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ea=/\{\n\/\* \[wrapped with (.+)\] \*/,ra=/,? & /,ia=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ua=/[()=,{}\[\]\/\s]/,sa=/\\(\\)?/g,oa=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Xi=/\w*$/,aa=/^[-+]0x[0-9a-f]+$/i,fa=/^0b[01]+$/i,la=/^\[object .+?Constructor\]$/,ca=/^0o[0-7]+$/i,ha=/^(?:0|[1-9]\d*)$/,ga=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Pe=/($^)/,pa=/['\n\r\u2028\u2029\\]/g,Ee="\\ud800-\\udfff",da="\\u0300-\\u036f",_a="\\ufe20-\\ufe2f",va="\\u20d0-\\u20ff",Qi=da+_a+va,Vi="\\u2700-\\u27bf",ji="a-z\\xdf-\\xf6\\xf8-\\xff",wa="\\xac\\xb1\\xd7\\xf7",ma="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ya="\\u2000-\\u206f",xa=" \\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",nu="A-Z\\xc0-\\xd6\\xd8-\\xde",tu="\\ufe0e\\ufe0f",eu=wa+ma+ya+xa,Ir="['’]",Sa="["+Ee+"]",ru="["+eu+"]",Ie="["+Qi+"]",iu="\\d+",Aa="["+Vi+"]",uu="["+ji+"]",su="[^"+Ee+eu+iu+Vi+ji+nu+"]",Lr="\\ud83c[\\udffb-\\udfff]",Ca="(?:"+Ie+"|"+Lr+")",ou="[^"+Ee+"]",Or="(?:\\ud83c[\\udde6-\\uddff]){2}",Wr="[\\ud800-\\udbff][\\udc00-\\udfff]",Ft="["+nu+"]",au="\\u200d",fu="(?:"+uu+"|"+su+")",ba="(?:"+Ft+"|"+su+")",lu="(?:"+Ir+"(?:d|ll|m|re|s|t|ve))?",cu="(?:"+Ir+"(?:D|LL|M|RE|S|T|VE))?",hu=Ca+"?",gu="["+tu+"]?",Ra="(?:"+au+"(?:"+[ou,Or,Wr].join("|")+")"+gu+hu+")*",Ta="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Pa="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",pu=gu+hu+Ra,Ea="(?:"+[Aa,Or,Wr].join("|")+")"+pu,Ia="(?:"+[ou+Ie+"?",Ie,Or,Wr,Sa].join("|")+")",La=RegExp(Ir,"g"),Oa=RegExp(Ie,"g"),Mr=RegExp(Lr+"(?="+Lr+")|"+Ia+pu,"g"),Wa=RegExp([Ft+"?"+uu+"+"+lu+"(?="+[ru,Ft,"$"].join("|")+")",ba+"+"+cu+"(?="+[ru,Ft+fu,"$"].join("|")+")",Ft+"?"+fu+"+"+lu,Ft+"+"+cu,Pa,Ta,iu,Ea].join("|"),"g"),Ma=RegExp("["+au+Ee+Qi+tu+"]"),Fa=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Ua=["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"],Da=-1,K={};K[mr]=K[yr]=K[xr]=K[Sr]=K[Ar]=K[Cr]=K[br]=K[Rr]=K[Tr]=!0,K[Wt]=K[Ce]=K[te]=K[Zt]=K[Mt]=K[Xt]=K[be]=K[Re]=K[Gn]=K[Qt]=K[nt]=K[Vt]=K[kn]=K[jt]=K[ne]=!1;var H={};H[Wt]=H[Ce]=H[te]=H[Mt]=H[Zt]=H[Xt]=H[mr]=H[yr]=H[xr]=H[Sr]=H[Ar]=H[Gn]=H[Qt]=H[nt]=H[Vt]=H[kn]=H[jt]=H[Te]=H[Cr]=H[br]=H[Rr]=H[Tr]=!0,H[be]=H[Re]=H[ne]=!1;var Na={À:"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"},Ba={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},$a={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},qa={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ga=parseFloat,ka=parseInt,du=typeof ve=="object"&&ve&&ve.Object===Object&&ve,za=typeof self=="object"&&self&&self.Object===Object&&self,cn=du||za||Function("return this")(),Fr=g&&!g.nodeType&&g,St=Fr&&!0&&y&&!y.nodeType&&y,_u=St&&St.exports===Fr,Ur=_u&&du.process,In=function(){try{var l=St&&St.require&&St.require("util").types;return l||Ur&&Ur.binding&&Ur.binding("util")}catch{}}(),vu=In&&In.isArrayBuffer,wu=In&&In.isDate,mu=In&&In.isMap,yu=In&&In.isRegExp,xu=In&&In.isSet,Su=In&&In.isTypedArray;function Cn(l,p,h){switch(h.length){case 0:return l.call(p);case 1:return l.call(p,h[0]);case 2:return l.call(p,h[0],h[1]);case 3:return l.call(p,h[0],h[1],h[2])}return l.apply(p,h)}function Ha(l,p,h,S){for(var I=-1,q=l==null?0:l.length;++I<q;){var un=l[I];p(S,un,h(un),l)}return S}function Ln(l,p){for(var h=-1,S=l==null?0:l.length;++h<S&&p(l[h],h,l)!==!1;);return l}function Ka(l,p){for(var h=l==null?0:l.length;h--&&p(l[h],h,l)!==!1;);return l}function Au(l,p){for(var h=-1,S=l==null?0:l.length;++h<S;)if(!p(l[h],h,l))return!1;return!0}function ht(l,p){for(var h=-1,S=l==null?0:l.length,I=0,q=[];++h<S;){var un=l[h];p(un,h,l)&&(q[I++]=un)}return q}function Le(l,p){var h=l==null?0:l.length;return!!h&&Ut(l,p,0)>-1}function Dr(l,p,h){for(var S=-1,I=l==null?0:l.length;++S<I;)if(h(p,l[S]))return!0;return!1}function Y(l,p){for(var h=-1,S=l==null?0:l.length,I=Array(S);++h<S;)I[h]=p(l[h],h,l);return I}function gt(l,p){for(var h=-1,S=p.length,I=l.length;++h<S;)l[I+h]=p[h];return l}function Nr(l,p,h,S){var I=-1,q=l==null?0:l.length;for(S&&q&&(h=l[++I]);++I<q;)h=p(h,l[I],I,l);return h}function Ja(l,p,h,S){var I=l==null?0:l.length;for(S&&I&&(h=l[--I]);I--;)h=p(h,l[I],I,l);return h}function Br(l,p){for(var h=-1,S=l==null?0:l.length;++h<S;)if(p(l[h],h,l))return!0;return!1}var Ya=$r("length");function Za(l){return l.split("")}function Xa(l){return l.match(ia)||[]}function Cu(l,p,h){var S;return h(l,function(I,q,un){if(p(I,q,un))return S=q,!1}),S}function Oe(l,p,h,S){for(var I=l.length,q=h+(S?1:-1);S?q--:++q<I;)if(p(l[q],q,l))return q;return-1}function Ut(l,p,h){return p===p?ff(l,p,h):Oe(l,bu,h)}function Qa(l,p,h,S){for(var I=h-1,q=l.length;++I<q;)if(S(l[I],p))return I;return-1}function bu(l){return l!==l}function Ru(l,p){var h=l==null?0:l.length;return h?Gr(l,p)/h:Ae}function $r(l){return function(p){return p==null?i:p[l]}}function qr(l){return function(p){return l==null?i:l[p]}}function Tu(l,p,h,S,I){return I(l,function(q,un,z){h=S?(S=!1,q):p(h,q,un,z)}),h}function Va(l,p){var h=l.length;for(l.sort(p);h--;)l[h]=l[h].value;return l}function Gr(l,p){for(var h,S=-1,I=l.length;++S<I;){var q=p(l[S]);q!==i&&(h=h===i?q:h+q)}return h}function kr(l,p){for(var h=-1,S=Array(l);++h<l;)S[h]=p(h);return S}function ja(l,p){return Y(p,function(h){return[h,l[h]]})}function Pu(l){return l&&l.slice(0,Ou(l)+1).replace(Er,"")}function bn(l){return function(p){return l(p)}}function zr(l,p){return Y(p,function(h){return l[h]})}function ee(l,p){return l.has(p)}function Eu(l,p){for(var h=-1,S=l.length;++h<S&&Ut(p,l[h],0)>-1;);return h}function Iu(l,p){for(var h=l.length;h--&&Ut(p,l[h],0)>-1;);return h}function nf(l,p){for(var h=l.length,S=0;h--;)l[h]===p&&++S;return S}var tf=qr(Na),ef=qr(Ba);function rf(l){return"\\"+qa[l]}function uf(l,p){return l==null?i:l[p]}function Dt(l){return Ma.test(l)}function sf(l){return Fa.test(l)}function of(l){for(var p,h=[];!(p=l.next()).done;)h.push(p.value);return h}function Hr(l){var p=-1,h=Array(l.size);return l.forEach(function(S,I){h[++p]=[I,S]}),h}function Lu(l,p){return function(h){return l(p(h))}}function pt(l,p){for(var h=-1,S=l.length,I=0,q=[];++h<S;){var un=l[h];(un===p||un===dn)&&(l[h]=dn,q[I++]=h)}return q}function We(l){var p=-1,h=Array(l.size);return l.forEach(function(S){h[++p]=S}),h}function af(l){var p=-1,h=Array(l.size);return l.forEach(function(S){h[++p]=[S,S]}),h}function ff(l,p,h){for(var S=h-1,I=l.length;++S<I;)if(l[S]===p)return S;return-1}function lf(l,p,h){for(var S=h+1;S--;)if(l[S]===p)return S;return S}function Nt(l){return Dt(l)?hf(l):Ya(l)}function zn(l){return Dt(l)?gf(l):Za(l)}function Ou(l){for(var p=l.length;p--&&na.test(l.charAt(p)););return p}var cf=qr($a);function hf(l){for(var p=Mr.lastIndex=0;Mr.test(l);)++p;return p}function gf(l){return l.match(Mr)||[]}function pf(l){return l.match(Wa)||[]}var df=function l(p){p=p==null?cn:Bt.defaults(cn.Object(),p,Bt.pick(cn,Ua));var h=p.Array,S=p.Date,I=p.Error,q=p.Function,un=p.Math,z=p.Object,Kr=p.RegExp,_f=p.String,On=p.TypeError,Me=h.prototype,vf=q.prototype,$t=z.prototype,Fe=p["__core-js_shared__"],Ue=vf.toString,k=$t.hasOwnProperty,wf=0,Wu=function(){var n=/[^.]+$/.exec(Fe&&Fe.keys&&Fe.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),De=$t.toString,mf=Ue.call(z),yf=cn._,xf=Kr("^"+Ue.call(k).replace(Pr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ne=_u?p.Buffer:i,dt=p.Symbol,Be=p.Uint8Array,Mu=Ne?Ne.allocUnsafe:i,$e=Lu(z.getPrototypeOf,z),Fu=z.create,Uu=$t.propertyIsEnumerable,qe=Me.splice,Du=dt?dt.isConcatSpreadable:i,re=dt?dt.iterator:i,At=dt?dt.toStringTag:i,Ge=function(){try{var n=Pt(z,"defineProperty");return n({},"",{}),n}catch{}}(),Sf=p.clearTimeout!==cn.clearTimeout&&p.clearTimeout,Af=S&&S.now!==cn.Date.now&&S.now,Cf=p.setTimeout!==cn.setTimeout&&p.setTimeout,ke=un.ceil,ze=un.floor,Jr=z.getOwnPropertySymbols,bf=Ne?Ne.isBuffer:i,Nu=p.isFinite,Rf=Me.join,Tf=Lu(z.keys,z),sn=un.max,gn=un.min,Pf=S.now,Ef=p.parseInt,Bu=un.random,If=Me.reverse,Yr=Pt(p,"DataView"),ie=Pt(p,"Map"),Zr=Pt(p,"Promise"),qt=Pt(p,"Set"),ue=Pt(p,"WeakMap"),se=Pt(z,"create"),He=ue&&new ue,Gt={},Lf=Et(Yr),Of=Et(ie),Wf=Et(Zr),Mf=Et(qt),Ff=Et(ue),Ke=dt?dt.prototype:i,oe=Ke?Ke.valueOf:i,$u=Ke?Ke.toString:i;function s(n){if(Q(n)&&!L(n)&&!(n instanceof U)){if(n instanceof Wn)return n;if(k.call(n,"__wrapped__"))return qs(n)}return new Wn(n)}var kt=function(){function n(){}return function(t){if(!Z(t))return{};if(Fu)return Fu(t);n.prototype=t;var e=new n;return n.prototype=i,e}}();function Je(){}function Wn(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}s.templateSettings={escape:Yo,evaluate:Zo,interpolate:Zi,variable:"",imports:{_:s}},s.prototype=Je.prototype,s.prototype.constructor=s,Wn.prototype=kt(Je.prototype),Wn.prototype.constructor=Wn;function U(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Zn,this.__views__=[]}function Uf(){var n=new U(this.__wrapped__);return n.__actions__=yn(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=yn(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=yn(this.__views__),n}function Df(){if(this.__filtered__){var n=new U(this);n.__dir__=-1,n.__filtered__=!0}else n=this.clone(),n.__dir__*=-1;return n}function Nf(){var n=this.__wrapped__.value(),t=this.__dir__,e=L(n),r=t<0,u=e?n.length:0,o=Xl(0,u,this.__views__),a=o.start,f=o.end,c=f-a,d=r?f:a-1,_=this.__iteratees__,v=_.length,x=0,b=gn(c,this.__takeCount__);if(!e||!r&&u==c&&b==c)return ls(n,this.__actions__);var T=[];n:for(;c--&&x<b;){d+=t;for(var W=-1,P=n[d];++W<v;){var F=_[W],D=F.iteratee,Pn=F.type,wn=D(P);if(Pn==Lo)P=wn;else if(!wn){if(Pn==zi)continue n;break n}}T[x++]=P}return T}U.prototype=kt(Je.prototype),U.prototype.constructor=U;function Ct(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 Bf(){this.__data__=se?se(null):{},this.size=0}function $f(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}function qf(n){var t=this.__data__;if(se){var e=t[n];return e===N?i:e}return k.call(t,n)?t[n]:i}function Gf(n){var t=this.__data__;return se?t[n]!==i:k.call(t,n)}function kf(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=se&&t===i?N:t,this}Ct.prototype.clear=Bf,Ct.prototype.delete=$f,Ct.prototype.get=qf,Ct.prototype.has=Gf,Ct.prototype.set=kf;function tt(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 zf(){this.__data__=[],this.size=0}function Hf(n){var t=this.__data__,e=Ye(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():qe.call(t,e,1),--this.size,!0}function Kf(n){var t=this.__data__,e=Ye(t,n);return e<0?i:t[e][1]}function Jf(n){return Ye(this.__data__,n)>-1}function Yf(n,t){var e=this.__data__,r=Ye(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}tt.prototype.clear=zf,tt.prototype.delete=Hf,tt.prototype.get=Kf,tt.prototype.has=Jf,tt.prototype.set=Yf;function et(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 Zf(){this.size=0,this.__data__={hash:new Ct,map:new(ie||tt),string:new Ct}}function Xf(n){var t=sr(this,n).delete(n);return this.size-=t?1:0,t}function Qf(n){return sr(this,n).get(n)}function Vf(n){return sr(this,n).has(n)}function jf(n,t){var e=sr(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}et.prototype.clear=Zf,et.prototype.delete=Xf,et.prototype.get=Qf,et.prototype.has=Vf,et.prototype.set=jf;function bt(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new et;++t<e;)this.add(n[t])}function nl(n){return this.__data__.set(n,N),this}function tl(n){return this.__data__.has(n)}bt.prototype.add=bt.prototype.push=nl,bt.prototype.has=tl;function Hn(n){var t=this.__data__=new tt(n);this.size=t.size}function el(){this.__data__=new tt,this.size=0}function rl(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}function il(n){return this.__data__.get(n)}function ul(n){return this.__data__.has(n)}function sl(n,t){var e=this.__data__;if(e instanceof tt){var r=e.__data__;if(!ie||r.length<m-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new et(r)}return e.set(n,t),this.size=e.size,this}Hn.prototype.clear=el,Hn.prototype.delete=rl,Hn.prototype.get=il,Hn.prototype.has=ul,Hn.prototype.set=sl;function qu(n,t){var e=L(n),r=!e&&It(n),u=!e&&!r&&yt(n),o=!e&&!r&&!u&&Jt(n),a=e||r||u||o,f=a?kr(n.length,_f):[],c=f.length;for(var d in n)(t||k.call(n,d))&&!(a&&(d=="length"||u&&(d=="offset"||d=="parent")||o&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||st(d,c)))&&f.push(d);return f}function Gu(n){var t=n.length;return t?n[si(0,t-1)]:i}function ol(n,t){return or(yn(n),Rt(t,0,n.length))}function al(n){return or(yn(n))}function Xr(n,t,e){(e!==i&&!Kn(n[t],e)||e===i&&!(t in n))&&rt(n,t,e)}function ae(n,t,e){var r=n[t];(!(k.call(n,t)&&Kn(r,e))||e===i&&!(t in n))&&rt(n,t,e)}function Ye(n,t){for(var e=n.length;e--;)if(Kn(n[e][0],t))return e;return-1}function fl(n,t,e,r){return _t(n,function(u,o,a){t(r,u,e(u),a)}),r}function ku(n,t){return n&&Qn(t,fn(t),n)}function ll(n,t){return n&&Qn(t,Sn(t),n)}function rt(n,t,e){t=="__proto__"&&Ge?Ge(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}function Qr(n,t){for(var e=-1,r=t.length,u=h(r),o=n==null;++e<r;)u[e]=o?i:Li(n,t[e]);return u}function Rt(n,t,e){return n===n&&(e!==i&&(n=n<=e?n:e),t!==i&&(n=n>=t?n:t)),n}function Mn(n,t,e,r,u,o){var a,f=t&ln,c=t&Nn,d=t&an;if(e&&(a=u?e(n,r,u,o):e(n)),a!==i)return a;if(!Z(n))return n;var _=L(n);if(_){if(a=Vl(n),!f)return yn(n,a)}else{var v=pn(n),x=v==Re||v==Hi;if(yt(n))return gs(n,f);if(v==nt||v==Wt||x&&!u){if(a=c||x?{}:Os(n),!f)return c?ql(n,ll(a,n)):$l(n,ku(a,n))}else{if(!H[v])return u?n:{};a=jl(n,v,f)}}o||(o=new Hn);var b=o.get(n);if(b)return b;o.set(n,a),oo(n)?n.forEach(function(P){a.add(Mn(P,t,e,P,n,o))}):uo(n)&&n.forEach(function(P,F){a.set(F,Mn(P,t,e,F,n,o))});var T=d?c?vi:_i:c?Sn:fn,W=_?i:T(n);return Ln(W||n,function(P,F){W&&(F=P,P=n[F]),ae(a,F,Mn(P,t,e,F,n,o))}),a}function cl(n){var t=fn(n);return function(e){return zu(e,n,t)}}function zu(n,t,e){var r=e.length;if(n==null)return!r;for(n=z(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 Hu(n,t,e){if(typeof n!="function")throw new On(A);return de(function(){n.apply(i,e)},t)}function fe(n,t,e,r){var u=-1,o=Le,a=!0,f=n.length,c=[],d=t.length;if(!f)return c;e&&(t=Y(t,bn(e))),r?(o=Dr,a=!1):t.length>=m&&(o=ee,a=!1,t=new bt(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 _t=ws(Xn),Ku=ws(jr,!0);function hl(n,t){var e=!0;return _t(n,function(r,u,o){return e=!!t(r,u,o),e}),e}function Ze(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&&!Tn(a):e(a,f)))var f=a,c=o}return c}function gl(n,t,e,r){var u=n.length;for(e=O(e),e<0&&(e=-e>u?0:u+e),r=r===i||r>u?u:O(r),r<0&&(r+=u),r=e>r?0:fo(r);e<r;)n[e++]=t;return n}function Ju(n,t){var e=[];return _t(n,function(r,u,o){t(r,u,o)&&e.push(r)}),e}function hn(n,t,e,r,u){var o=-1,a=n.length;for(e||(e=tc),u||(u=[]);++o<a;){var f=n[o];t>0&&e(f)?t>1?hn(f,t-1,e,r,u):gt(u,f):r||(u[u.length]=f)}return u}var Vr=ms(),Yu=ms(!0);function Xn(n,t){return n&&Vr(n,t,fn)}function jr(n,t){return n&&Yu(n,t,fn)}function Xe(n,t){return ht(t,function(e){return ot(n[e])})}function Tt(n,t){t=wt(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[Vn(t[e++])];return e&&e==r?n:i}function Zu(n,t,e){var r=t(n);return L(n)?r:gt(r,e(n))}function _n(n){return n==null?n===i?qo:Bo:At&&At in z(n)?Zl(n):ac(n)}function ni(n,t){return n>t}function pl(n,t){return n!=null&&k.call(n,t)}function dl(n,t){return n!=null&&t in z(n)}function _l(n,t,e){return n>=gn(t,e)&&n<sn(t,e)}function ti(n,t,e){for(var r=e?Dr:Le,u=n[0].length,o=n.length,a=o,f=h(o),c=1/0,d=[];a--;){var _=n[a];a&&t&&(_=Y(_,bn(t))),c=gn(_.length,c),f[a]=!e&&(t||u>=120&&_.length>=120)?new bt(a&&_):i}_=n[0];var v=-1,x=f[0];n:for(;++v<u&&d.length<c;){var b=_[v],T=t?t(b):b;if(b=e||b!==0?b:0,!(x?ee(x,T):r(d,T,e))){for(a=o;--a;){var W=f[a];if(!(W?ee(W,T):r(n[a],T,e)))continue n}x&&x.push(T),d.push(b)}}return d}function vl(n,t,e,r){return Xn(n,function(u,o,a){t(r,e(u),o,a)}),r}function le(n,t,e){t=wt(t,n),n=Us(n,t);var r=n==null?n:n[Vn(Un(t))];return r==null?i:Cn(r,n,e)}function Xu(n){return Q(n)&&_n(n)==Wt}function wl(n){return Q(n)&&_n(n)==te}function ml(n){return Q(n)&&_n(n)==Xt}function ce(n,t,e,r,u){return n===t?!0:n==null||t==null||!Q(n)&&!Q(t)?n!==n&&t!==t:yl(n,t,e,r,ce,u)}function yl(n,t,e,r,u,o){var a=L(n),f=L(t),c=a?Ce:pn(n),d=f?Ce:pn(t);c=c==Wt?nt:c,d=d==Wt?nt:d;var _=c==nt,v=d==nt,x=c==d;if(x&&yt(n)){if(!yt(t))return!1;a=!0,_=!1}if(x&&!_)return o||(o=new Hn),a||Jt(n)?Es(n,t,e,r,u,o):Jl(n,t,c,e,r,u,o);if(!(e&Yn)){var b=_&&k.call(n,"__wrapped__"),T=v&&k.call(t,"__wrapped__");if(b||T){var W=b?n.value():n,P=T?t.value():t;return o||(o=new Hn),u(W,P,e,r,o)}}return x?(o||(o=new Hn),Yl(n,t,e,r,u,o)):!1}function xl(n){return Q(n)&&pn(n)==Gn}function ei(n,t,e,r){var u=e.length,o=u,a=!r;if(n==null)return!o;for(n=z(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 Hn;if(r)var x=r(d,_,c,n,t,v);if(!(x===i?ce(_,d,Yn|jn,r,v):x))return!1}}return!0}function Qu(n){if(!Z(n)||rc(n))return!1;var t=ot(n)?xf:la;return t.test(Et(n))}function Sl(n){return Q(n)&&_n(n)==Vt}function Al(n){return Q(n)&&pn(n)==kn}function Cl(n){return Q(n)&&gr(n.length)&&!!K[_n(n)]}function Vu(n){return typeof n=="function"?n:n==null?An:typeof n=="object"?L(n)?ts(n[0],n[1]):ns(n):xo(n)}function ri(n){if(!pe(n))return Tf(n);var t=[];for(var e in z(n))k.call(n,e)&&e!="constructor"&&t.push(e);return t}function bl(n){if(!Z(n))return oc(n);var t=pe(n),e=[];for(var r in n)r=="constructor"&&(t||!k.call(n,r))||e.push(r);return e}function ii(n,t){return n<t}function ju(n,t){var e=-1,r=xn(n)?h(n.length):[];return _t(n,function(u,o,a){r[++e]=t(u,o,a)}),r}function ns(n){var t=mi(n);return t.length==1&&t[0][2]?Ms(t[0][0],t[0][1]):function(e){return e===n||ei(e,n,t)}}function ts(n,t){return xi(n)&&Ws(t)?Ms(Vn(n),t):function(e){var r=Li(e,n);return r===i&&r===t?Oi(e,n):ce(t,r,Yn|jn)}}function Qe(n,t,e,r,u){n!==t&&Vr(t,function(o,a){if(u||(u=new Hn),Z(o))Rl(n,t,a,e,Qe,r,u);else{var f=r?r(Ai(n,a),o,a+"",n,t,u):i;f===i&&(f=o),Xr(n,a,f)}},Sn)}function Rl(n,t,e,r,u,o,a){var f=Ai(n,e),c=Ai(t,e),d=a.get(c);if(d){Xr(n,e,d);return}var _=o?o(f,c,e+"",n,t,a):i,v=_===i;if(v){var x=L(c),b=!x&&yt(c),T=!x&&!b&&Jt(c);_=c,x||b||T?L(f)?_=f:j(f)?_=yn(f):b?(v=!1,_=gs(c,!0)):T?(v=!1,_=ps(c,!0)):_=[]:_e(c)||It(c)?(_=f,It(f)?_=lo(f):(!Z(f)||ot(f))&&(_=Os(c))):v=!1}v&&(a.set(c,_),u(_,c,r,o,a),a.delete(c)),Xr(n,e,_)}function es(n,t){var e=n.length;if(e)return t+=t<0?e:0,st(t,e)?n[t]:i}function rs(n,t,e){t.length?t=Y(t,function(o){return L(o)?function(a){return Tt(a,o.length===1?o[0]:o)}:o}):t=[An];var r=-1;t=Y(t,bn(R()));var u=ju(n,function(o,a,f){var c=Y(t,function(d){return d(o)});return{criteria:c,index:++r,value:o}});return Va(u,function(o,a){return Bl(o,a,e)})}function Tl(n,t){return is(n,t,function(e,r){return Oi(n,r)})}function is(n,t,e){for(var r=-1,u=t.length,o={};++r<u;){var a=t[r],f=Tt(n,a);e(f,a)&&he(o,wt(a,n),f)}return o}function Pl(n){return function(t){return Tt(t,n)}}function ui(n,t,e,r){var u=r?Qa:Ut,o=-1,a=t.length,f=n;for(n===t&&(t=yn(t)),e&&(f=Y(n,bn(e)));++o<a;)for(var c=0,d=t[o],_=e?e(d):d;(c=u(f,_,c,r))>-1;)f!==n&&qe.call(f,c,1),qe.call(n,c,1);return n}function us(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;st(u)?qe.call(n,u,1):fi(n,u)}}return n}function si(n,t){return n+ze(Bu()*(t-n+1))}function El(n,t,e,r){for(var u=-1,o=sn(ke((t-n)/(e||1)),0),a=h(o);o--;)a[r?o:++u]=n,n+=e;return a}function oi(n,t){var e="";if(!n||t<1||t>Ot)return e;do t%2&&(e+=n),t=ze(t/2),t&&(n+=n);while(t);return e}function M(n,t){return Ci(Fs(n,t,An),n+"")}function Il(n){return Gu(Yt(n))}function Ll(n,t){var e=Yt(n);return or(e,Rt(t,0,e.length))}function he(n,t,e,r){if(!Z(n))return n;t=wt(t,n);for(var u=-1,o=t.length,a=o-1,f=n;f!=null&&++u<o;){var c=Vn(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=Z(_)?_:st(t[u+1])?[]:{})}ae(f,c,d),f=f[c]}return n}var ss=He?function(n,t){return He.set(n,t),n}:An,Ol=Ge?function(n,t){return Ge(n,"toString",{configurable:!0,enumerable:!1,value:Mi(t),writable:!0})}:An;function Wl(n){return or(Yt(n))}function Fn(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 Ml(n,t){var e;return _t(n,function(r,u,o){return e=t(r,u,o),!e}),!!e}function Ve(n,t,e){var r=0,u=n==null?r:n.length;if(typeof t=="number"&&t===t&&u<=Fo){for(;r<u;){var o=r+u>>>1,a=n[o];a!==null&&!Tn(a)&&(e?a<=t:a<t)?r=o+1:u=o}return u}return ai(n,t,An,e)}function ai(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=Tn(t),d=t===i;u<o;){var _=ze((u+o)/2),v=e(n[_]),x=v!==i,b=v===null,T=v===v,W=Tn(v);if(a)var P=r||T;else d?P=T&&(r||x):f?P=T&&x&&(r||!b):c?P=T&&x&&!b&&(r||!W):b||W?P=!1:P=r?v<=t:v<t;P?u=_+1:o=_}return gn(o,Mo)}function os(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||!Kn(f,c)){var c=f;o[u++]=a===0?0:a}}return o}function as(n){return typeof n=="number"?n:Tn(n)?Ae:+n}function Rn(n){if(typeof n=="string")return n;if(L(n))return Y(n,Rn)+"";if(Tn(n))return $u?$u.call(n):"";var t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function vt(n,t,e){var r=-1,u=Le,o=n.length,a=!0,f=[],c=f;if(e)a=!1,u=Dr;else if(o>=m){var d=t?null:Hl(n);if(d)return We(d);a=!1,u=ee,c=new bt}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 fi(n,t){return t=wt(t,n),n=Us(n,t),n==null||delete n[Vn(Un(t))]}function fs(n,t,e,r){return he(n,t,e(Tt(n,t)),r)}function je(n,t,e,r){for(var u=n.length,o=r?u:-1;(r?o--:++o<u)&&t(n[o],o,n););return e?Fn(n,r?0:o,r?o+1:u):Fn(n,r?o+1:0,r?u:o)}function ls(n,t){var e=n;return e instanceof U&&(e=e.value()),Nr(t,function(r,u){return u.func.apply(u.thisArg,gt([r],u.args))},e)}function li(n,t,e){var r=n.length;if(r<2)return r?vt(n[0]):[];for(var u=-1,o=h(r);++u<r;)for(var a=n[u],f=-1;++f<r;)f!=u&&(o[u]=fe(o[u]||a,n[f],t,e));return vt(hn(o,1),t,e)}function cs(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 ci(n){return j(n)?n:[]}function hi(n){return typeof n=="function"?n:An}function wt(n,t){return L(n)?n:xi(n,t)?[n]:$s(G(n))}var Fl=M;function mt(n,t,e){var r=n.length;return e=e===i?r:e,!t&&e>=r?n:Fn(n,t,e)}var hs=Sf||function(n){return cn.clearTimeout(n)};function gs(n,t){if(t)return n.slice();var e=n.length,r=Mu?Mu(e):new n.constructor(e);return n.copy(r),r}function gi(n){var t=new n.constructor(n.byteLength);return new Be(t).set(new Be(n)),t}function Ul(n,t){var e=t?gi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}function Dl(n){var t=new n.constructor(n.source,Xi.exec(n));return t.lastIndex=n.lastIndex,t}function Nl(n){return oe?z(oe.call(n)):{}}function ps(n,t){var e=t?gi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}function ds(n,t){if(n!==t){var e=n!==i,r=n===null,u=n===n,o=Tn(n),a=t!==i,f=t===null,c=t===t,d=Tn(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 Bl(n,t,e){for(var r=-1,u=n.criteria,o=t.criteria,a=u.length,f=e.length;++r<a;){var c=ds(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 _s(n,t,e,r){for(var u=-1,o=n.length,a=e.length,f=-1,c=t.length,d=sn(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 vs(n,t,e,r){for(var u=-1,o=n.length,a=-1,f=e.length,c=-1,d=t.length,_=sn(o-f,0),v=h(_+d),x=!r;++u<_;)v[u]=n[u];for(var b=u;++c<d;)v[b+c]=t[c];for(;++a<f;)(x||u<o)&&(v[b+e[a]]=n[u++]);return v}function yn(n,t){var e=-1,r=n.length;for(t||(t=h(r));++e<r;)t[e]=n[e];return t}function Qn(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?rt(e,f,c):ae(e,f,c)}return e}function $l(n,t){return Qn(n,yi(n),t)}function ql(n,t){return Qn(n,Is(n),t)}function nr(n,t){return function(e,r){var u=L(e)?Ha:fl,o=t?t():{};return u(e,n,R(r,2),o)}}function zt(n){return M(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=z(t);++r<u;){var f=e[r];f&&n(t,f,r,o)}return t})}function ws(n,t){return function(e,r){if(e==null)return e;if(!xn(e))return n(e,r);for(var u=e.length,o=t?u:-1,a=z(e);(t?o--:++o<u)&&r(a[o],o,a)!==!1;);return e}}function ms(n){return function(t,e,r){for(var u=-1,o=z(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 Gl(n,t,e){var r=t&tn,u=ge(n);function o(){var a=this&&this!==cn&&this instanceof o?u:n;return a.apply(r?e:this,arguments)}return o}function ys(n){return function(t){t=G(t);var e=Dt(t)?zn(t):i,r=e?e[0]:t.charAt(0),u=e?mt(e,1).join(""):t.slice(1);return r[n]()+u}}function Ht(n){return function(t){return Nr(mo(wo(t).replace(La,"")),n,"")}}function ge(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=kt(n.prototype),r=n.apply(e,t);return Z(r)?r:e}}function kl(n,t,e){var r=ge(n);function u(){for(var o=arguments.length,a=h(o),f=o,c=Kt(u);f--;)a[f]=arguments[f];var d=o<3&&a[0]!==c&&a[o-1]!==c?[]:pt(a,c);if(o-=d.length,o<e)return bs(n,t,tr,u.placeholder,i,a,d,i,i,e-o);var _=this&&this!==cn&&this instanceof u?r:n;return Cn(_,this,a)}return u}function xs(n){return function(t,e,r){var u=z(t);if(!xn(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 Ss(n){return ut(function(t){var e=t.length,r=e,u=Wn.prototype.thru;for(n&&t.reverse();r--;){var o=t[r];if(typeof o!="function")throw new On(A);if(u&&!a&&ur(o)=="wrapper")var a=new Wn([],!0)}for(r=a?r:e;++r<e;){o=t[r];var f=ur(o),c=f=="wrapper"?wi(o):i;c&&Si(c[0])&&c[1]==($|Bn|$n|V)&&!c[4].length&&c[9]==1?a=a[ur(c[0])].apply(a,c[3]):a=o.length==1&&Si(o)?a[f]():a.thru(o)}return function(){var d=arguments,_=d[0];if(a&&d.length==1&&L(_))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 tr(n,t,e,r,u,o,a,f,c,d){var _=t&$,v=t&tn,x=t&lt,b=t&(Bn|xt),T=t&X,W=x?i:ge(n);function P(){for(var F=arguments.length,D=h(F),Pn=F;Pn--;)D[Pn]=arguments[Pn];if(b)var wn=Kt(P),En=nf(D,wn);if(r&&(D=_s(D,r,u,b)),o&&(D=vs(D,o,a,b)),F-=En,b&&F<d){var nn=pt(D,wn);return bs(n,t,tr,P.placeholder,e,D,nn,f,c,d-F)}var Jn=v?e:this,ft=x?Jn[n]:n;return F=D.length,f?D=fc(D,f):T&&F>1&&D.reverse(),_&&c<F&&(D.length=c),this&&this!==cn&&this instanceof P&&(ft=W||ge(ft)),ft.apply(Jn,D)}return P}function As(n,t){return function(e,r){return vl(e,n,t(r),{})}}function er(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=Rn(e),r=Rn(r)):(e=as(e),r=as(r)),u=n(e,r)}return u}}function pi(n){return ut(function(t){return t=Y(t,bn(R())),M(function(e){var r=this;return n(t,function(u){return Cn(u,r,e)})})})}function rr(n,t){t=t===i?" ":Rn(t);var e=t.length;if(e<2)return e?oi(t,n):t;var r=oi(t,ke(n/Nt(t)));return Dt(t)?mt(zn(r),0,n).join(""):r.slice(0,n)}function zl(n,t,e,r){var u=t&tn,o=ge(n);function a(){for(var f=-1,c=arguments.length,d=-1,_=r.length,v=h(_+c),x=this&&this!==cn&&this instanceof a?o:n;++d<_;)v[d]=r[d];for(;c--;)v[d++]=arguments[++f];return Cn(x,u?e:this,v)}return a}function Cs(n){return function(t,e,r){return r&&typeof r!="number"&&vn(t,e,r)&&(e=r=i),t=at(t),e===i?(e=t,t=0):e=at(e),r=r===i?t<e?1:-1:at(r),El(t,e,r,n)}}function ir(n){return function(t,e){return typeof t=="string"&&typeof e=="string"||(t=Dn(t),e=Dn(e)),n(t,e)}}function bs(n,t,e,r,u,o,a,f,c,d){var _=t&Bn,v=_?a:i,x=_?i:a,b=_?o:i,T=_?i:o;t|=_?$n:en,t&=~(_?en:$n),t&xe||(t&=-4);var W=[n,t,u,b,v,T,x,f,c,d],P=e.apply(i,W);return Si(n)&&Ds(P,W),P.placeholder=r,Ns(P,n,t)}function di(n){var t=un[n];return function(e,r){if(e=Dn(e),r=r==null?0:gn(O(r),292),r&&Nu(e)){var u=(G(e)+"e").split("e"),o=t(u[0]+"e"+(+u[1]+r));return u=(G(o)+"e").split("e"),+(u[0]+"e"+(+u[1]-r))}return t(e)}}var Hl=qt&&1/We(new qt([,-0]))[1]==Se?function(n){return new qt(n)}:Di;function Rs(n){return function(t){var e=pn(t);return e==Gn?Hr(t):e==kn?af(t):ja(t,n(t))}}function it(n,t,e,r,u,o,a,f){var c=t&lt;if(!c&&typeof n!="function")throw new On(A);var d=r?r.length:0;if(d||(t&=-97,r=u=i),a=a===i?a:sn(O(a),0),f=f===i?f:O(f),d-=u?u.length:0,t&en){var _=r,v=u;r=u=i}var x=c?i:wi(n),b=[n,t,e,r,u,_,v,o,a,f];if(x&&sc(b,x),n=b[0],t=b[1],e=b[2],r=b[3],u=b[4],f=b[9]=b[9]===i?c?0:n.length:sn(b[9]-d,0),!f&&t&(Bn|xt)&&(t&=-25),!t||t==tn)var T=Gl(n,t,e);else t==Bn||t==xt?T=kl(n,t,f):(t==$n||t==(tn|$n))&&!u.length?T=zl(n,t,e,r):T=tr.apply(i,b);var W=x?ss:Ds;return Ns(W(T,b),n,t)}function Ts(n,t,e,r){return n===i||Kn(n,$t[e])&&!k.call(r,e)?t:n}function Ps(n,t,e,r,u,o){return Z(n)&&Z(t)&&(o.set(t,n),Qe(n,t,i,Ps,o),o.delete(t)),n}function Kl(n){return _e(n)?i:n}function Es(n,t,e,r,u,o){var a=e&Yn,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,b=e&jn?new bt:i;for(o.set(n,t),o.set(t,n);++v<f;){var T=n[v],W=t[v];if(r)var P=a?r(W,T,v,t,n,o):r(T,W,v,n,t,o);if(P!==i){if(P)continue;x=!1;break}if(b){if(!Br(t,function(F,D){if(!ee(b,D)&&(T===F||u(T,F,e,r,o)))return b.push(D)})){x=!1;break}}else if(!(T===W||u(T,W,e,r,o))){x=!1;break}}return o.delete(n),o.delete(t),x}function Jl(n,t,e,r,u,o,a){switch(e){case Mt:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case te:return!(n.byteLength!=t.byteLength||!o(new Be(n),new Be(t)));case Zt:case Xt:case Qt:return Kn(+n,+t);case be:return n.name==t.name&&n.message==t.message;case Vt:case jt:return n==t+"";case Gn:var f=Hr;case kn:var c=r&Yn;if(f||(f=We),n.size!=t.size&&!c)return!1;var d=a.get(n);if(d)return d==t;r|=jn,a.set(n,t);var _=Es(f(n),f(t),r,u,o,a);return a.delete(n),_;case Te:if(oe)return oe.call(n)==oe.call(t)}return!1}function Yl(n,t,e,r,u,o){var a=e&Yn,f=_i(n),c=f.length,d=_i(t),_=d.length;if(c!=_&&!a)return!1;for(var v=c;v--;){var x=f[v];if(!(a?x in t:k.call(t,x)))return!1}var b=o.get(n),T=o.get(t);if(b&&T)return b==t&&T==n;var W=!0;o.set(n,t),o.set(t,n);for(var P=a;++v<c;){x=f[v];var F=n[x],D=t[x];if(r)var Pn=a?r(D,F,x,t,n,o):r(F,D,x,n,t,o);if(!(Pn===i?F===D||u(F,D,e,r,o):Pn)){W=!1;break}P||(P=x=="constructor")}if(W&&!P){var wn=n.constructor,En=t.constructor;wn!=En&&"constructor"in n&&"constructor"in t&&!(typeof wn=="function"&&wn instanceof wn&&typeof En=="function"&&En instanceof En)&&(W=!1)}return o.delete(n),o.delete(t),W}function ut(n){return Ci(Fs(n,i,zs),n+"")}function _i(n){return Zu(n,fn,yi)}function vi(n){return Zu(n,Sn,Is)}var wi=He?function(n){return He.get(n)}:Di;function ur(n){for(var t=n.name+"",e=Gt[t],r=k.call(Gt,t)?e.length:0;r--;){var u=e[r],o=u.func;if(o==null||o==n)return u.name}return t}function Kt(n){var t=k.call(s,"placeholder")?s:n;return t.placeholder}function R(){var n=s.iteratee||Fi;return n=n===Fi?Vu:n,arguments.length?n(arguments[0],arguments[1]):n}function sr(n,t){var e=n.__data__;return ec(t)?e[typeof t=="string"?"string":"hash"]:e.map}function mi(n){for(var t=fn(n),e=t.length;e--;){var r=t[e],u=n[r];t[e]=[r,u,Ws(u)]}return t}function Pt(n,t){var e=uf(n,t);return Qu(e)?e:i}function Zl(n){var t=k.call(n,At),e=n[At];try{n[At]=i;var r=!0}catch{}var u=De.call(n);return r&&(t?n[At]=e:delete n[At]),u}var yi=Jr?function(n){return n==null?[]:(n=z(n),ht(Jr(n),function(t){return Uu.call(n,t)}))}:Ni,Is=Jr?function(n){for(var t=[];n;)gt(t,yi(n)),n=$e(n);return t}:Ni,pn=_n;(Yr&&pn(new Yr(new ArrayBuffer(1)))!=Mt||ie&&pn(new ie)!=Gn||Zr&&pn(Zr.resolve())!=Ki||qt&&pn(new qt)!=kn||ue&&pn(new ue)!=ne)&&(pn=function(n){var t=_n(n),e=t==nt?n.constructor:i,r=e?Et(e):"";if(r)switch(r){case Lf:return Mt;case Of:return Gn;case Wf:return Ki;case Mf:return kn;case Ff:return ne}return t});function Xl(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=gn(t,n+a);break;case"takeRight":n=sn(n,t-a);break}}return{start:n,end:t}}function Ql(n){var t=n.match(ea);return t?t[1].split(ra):[]}function Ls(n,t,e){t=wt(t,n);for(var r=-1,u=t.length,o=!1;++r<u;){var a=Vn(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&&gr(u)&&st(a,u)&&(L(n)||It(n)))}function Vl(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&k.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Os(n){return typeof n.constructor=="function"&&!pe(n)?kt($e(n)):{}}function jl(n,t,e){var r=n.constructor;switch(t){case te:return gi(n);case Zt:case Xt:return new r(+n);case Mt:return Ul(n,e);case mr:case yr:case xr:case Sr:case Ar:case Cr:case br:case Rr:case Tr:return ps(n,e);case Gn:return new r;case Qt:case jt:return new r(n);case Vt:return Dl(n);case kn:return new r;case Te:return Nl(n)}}function nc(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(ta,`{
17
+ /* [wrapped with `+t+`] */
18
+ `)}function tc(n){return L(n)||It(n)||!!(Du&&n&&n[Du])}function st(n,t){var e=typeof n;return t=t??Ot,!!t&&(e=="number"||e!="symbol"&&ha.test(n))&&n>-1&&n%1==0&&n<t}function vn(n,t,e){if(!Z(e))return!1;var r=typeof t;return(r=="number"?xn(e)&&st(t,e.length):r=="string"&&t in e)?Kn(e[t],n):!1}function xi(n,t){if(L(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||Tn(n)?!0:Qo.test(n)||!Xo.test(n)||t!=null&&n in z(t)}function ec(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}function Si(n){var t=ur(n),e=s[t];if(typeof e!="function"||!(t in U.prototype))return!1;if(n===e)return!0;var r=wi(e);return!!r&&n===r[0]}function rc(n){return!!Wu&&Wu in n}var ic=Fe?ot:Bi;function pe(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||$t;return n===e}function Ws(n){return n===n&&!Z(n)}function Ms(n,t){return function(e){return e==null?!1:e[n]===t&&(t!==i||n in z(e))}}function uc(n){var t=cr(n,function(r){return e.size===on&&e.clear(),r}),e=t.cache;return t}function sc(n,t){var e=n[1],r=t[1],u=e|r,o=u<(tn|lt|$),a=r==$&&e==Bn||r==$&&e==V&&n[7].length<=t[8]||r==($|V)&&t[7].length<=t[8]&&e==Bn;if(!(o||a))return n;r&tn&&(n[2]=t[2],u|=e&tn?0:xe);var f=t[3];if(f){var c=n[3];n[3]=c?_s(c,f,t[4]):f,n[4]=c?pt(n[3],dn):t[4]}return f=t[5],f&&(c=n[5],n[5]=c?vs(c,f,t[6]):f,n[6]=c?pt(n[5],dn):t[6]),f=t[7],f&&(n[7]=f),r&$&&(n[8]=n[8]==null?t[8]:gn(n[8],t[8])),n[9]==null&&(n[9]=t[9]),n[0]=t[0],n[1]=u,n}function oc(n){var t=[];if(n!=null)for(var e in z(n))t.push(e);return t}function ac(n){return De.call(n)}function Fs(n,t,e){return t=sn(t===i?n.length-1:t,0),function(){for(var r=arguments,u=-1,o=sn(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),Cn(n,this,f)}}function Us(n,t){return t.length<2?n:Tt(n,Fn(t,0,-1))}function fc(n,t){for(var e=n.length,r=gn(t.length,e),u=yn(n);r--;){var o=t[r];n[r]=st(o,e)?u[o]:i}return n}function Ai(n,t){if(!(t==="constructor"&&typeof n[t]=="function")&&t!="__proto__")return n[t]}var Ds=Bs(ss),de=Cf||function(n,t){return cn.setTimeout(n,t)},Ci=Bs(Ol);function Ns(n,t,e){var r=t+"";return Ci(n,nc(r,lc(Ql(r),e)))}function Bs(n){var t=0,e=0;return function(){var r=Pf(),u=ct-(r-e);if(e=r,u>0){if(++t>=J)return arguments[0]}else t=0;return n.apply(i,arguments)}}function or(n,t){var e=-1,r=n.length,u=r-1;for(t=t===i?r:t;++e<t;){var o=si(e,u),a=n[o];n[o]=n[e],n[e]=a}return n.length=t,n}var $s=uc(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(Vo,function(e,r,u,o){t.push(u?o.replace(sa,"$1"):r||e)}),t});function Vn(n){if(typeof n=="string"||Tn(n))return n;var t=n+"";return t=="0"&&1/n==-1/0?"-0":t}function Et(n){if(n!=null){try{return Ue.call(n)}catch{}try{return n+""}catch{}}return""}function lc(n,t){return Ln(Uo,function(e){var r="_."+e[0];t&e[1]&&!Le(n,r)&&n.push(r)}),n.sort()}function qs(n){if(n instanceof U)return n.clone();var t=new Wn(n.__wrapped__,n.__chain__);return t.__actions__=yn(n.__actions__),t.__index__=n.__index__,t.__values__=n.__values__,t}function cc(n,t,e){(e?vn(n,t,e):t===i)?t=1:t=sn(O(t),0);var r=n==null?0:n.length;if(!r||t<1)return[];for(var u=0,o=0,a=h(ke(r/t));u<r;)a[o++]=Fn(n,u,u+=t);return a}function hc(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 gc(){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 gt(L(e)?yn(e):[e],hn(t,1))}var pc=M(function(n,t){return j(n)?fe(n,hn(t,1,j,!0)):[]}),dc=M(function(n,t){var e=Un(t);return j(e)&&(e=i),j(n)?fe(n,hn(t,1,j,!0),R(e,2)):[]}),_c=M(function(n,t){var e=Un(t);return j(e)&&(e=i),j(n)?fe(n,hn(t,1,j,!0),i,e):[]});function vc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:O(t),Fn(n,t<0?0:t,r)):[]}function wc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:O(t),t=r-t,Fn(n,0,t<0?0:t)):[]}function mc(n,t){return n&&n.length?je(n,R(t,3),!0,!0):[]}function yc(n,t){return n&&n.length?je(n,R(t,3),!0):[]}function xc(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),gl(n,t,e,r)):[]}function Gs(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=e==null?0:O(e);return u<0&&(u=sn(r+u,0)),Oe(n,R(t,3),u)}function ks(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=r-1;return e!==i&&(u=O(e),u=e<0?sn(r+u,0):gn(u,r-1)),Oe(n,R(t,3),u,!0)}function zs(n){var t=n==null?0:n.length;return t?hn(n,1):[]}function Sc(n){var t=n==null?0:n.length;return t?hn(n,Se):[]}function Ac(n,t){var e=n==null?0:n.length;return e?(t=t===i?1:O(t),hn(n,t)):[]}function Cc(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 Hs(n){return n&&n.length?n[0]:i}function bc(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=e==null?0:O(e);return u<0&&(u=sn(r+u,0)),Ut(n,t,u)}function Rc(n){var t=n==null?0:n.length;return t?Fn(n,0,-1):[]}var Tc=M(function(n){var t=Y(n,ci);return t.length&&t[0]===n[0]?ti(t):[]}),Pc=M(function(n){var t=Un(n),e=Y(n,ci);return t===Un(e)?t=i:e.pop(),e.length&&e[0]===n[0]?ti(e,R(t,2)):[]}),Ec=M(function(n){var t=Un(n),e=Y(n,ci);return t=typeof t=="function"?t:i,t&&e.pop(),e.length&&e[0]===n[0]?ti(e,i,t):[]});function Ic(n,t){return n==null?"":Rf.call(n,t)}function Un(n){var t=n==null?0:n.length;return t?n[t-1]:i}function Lc(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=r;return e!==i&&(u=O(e),u=u<0?sn(r+u,0):gn(u,r-1)),t===t?lf(n,t,u):Oe(n,bu,u,!0)}function Oc(n,t){return n&&n.length?es(n,O(t)):i}var Wc=M(Ks);function Ks(n,t){return n&&n.length&&t&&t.length?ui(n,t):n}function Mc(n,t,e){return n&&n.length&&t&&t.length?ui(n,t,R(e,2)):n}function Fc(n,t,e){return n&&n.length&&t&&t.length?ui(n,t,i,e):n}var Uc=ut(function(n,t){var e=n==null?0:n.length,r=Qr(n,t);return us(n,Y(t,function(u){return st(u,e)?+u:u}).sort(ds)),r});function Dc(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 us(n,u),e}function bi(n){return n==null?n:If.call(n)}function Nc(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:O(t),e=e===i?r:O(e)),Fn(n,t,e)):[]}function Bc(n,t){return Ve(n,t)}function $c(n,t,e){return ai(n,t,R(e,2))}function qc(n,t){var e=n==null?0:n.length;if(e){var r=Ve(n,t);if(r<e&&Kn(n[r],t))return r}return-1}function Gc(n,t){return Ve(n,t,!0)}function kc(n,t,e){return ai(n,t,R(e,2),!0)}function zc(n,t){var e=n==null?0:n.length;if(e){var r=Ve(n,t,!0)-1;if(Kn(n[r],t))return r}return-1}function Hc(n){return n&&n.length?os(n):[]}function Kc(n,t){return n&&n.length?os(n,R(t,2)):[]}function Jc(n){var t=n==null?0:n.length;return t?Fn(n,1,t):[]}function Yc(n,t,e){return n&&n.length?(t=e||t===i?1:O(t),Fn(n,0,t<0?0:t)):[]}function Zc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:O(t),t=r-t,Fn(n,t<0?0:t,r)):[]}function Xc(n,t){return n&&n.length?je(n,R(t,3),!1,!0):[]}function Qc(n,t){return n&&n.length?je(n,R(t,3)):[]}var Vc=M(function(n){return vt(hn(n,1,j,!0))}),jc=M(function(n){var t=Un(n);return j(t)&&(t=i),vt(hn(n,1,j,!0),R(t,2))}),nh=M(function(n){var t=Un(n);return t=typeof t=="function"?t:i,vt(hn(n,1,j,!0),i,t)});function th(n){return n&&n.length?vt(n):[]}function eh(n,t){return n&&n.length?vt(n,R(t,2)):[]}function rh(n,t){return t=typeof t=="function"?t:i,n&&n.length?vt(n,i,t):[]}function Ri(n){if(!(n&&n.length))return[];var t=0;return n=ht(n,function(e){if(j(e))return t=sn(e.length,t),!0}),kr(t,function(e){return Y(n,$r(e))})}function Js(n,t){if(!(n&&n.length))return[];var e=Ri(n);return t==null?e:Y(e,function(r){return Cn(t,i,r)})}var ih=M(function(n,t){return j(n)?fe(n,t):[]}),uh=M(function(n){return li(ht(n,j))}),sh=M(function(n){var t=Un(n);return j(t)&&(t=i),li(ht(n,j),R(t,2))}),oh=M(function(n){var t=Un(n);return t=typeof t=="function"?t:i,li(ht(n,j),i,t)}),ah=M(Ri);function fh(n,t){return cs(n||[],t||[],ae)}function lh(n,t){return cs(n||[],t||[],he)}var ch=M(function(n){var t=n.length,e=t>1?n[t-1]:i;return e=typeof e=="function"?(n.pop(),e):i,Js(n,e)});function Ys(n){var t=s(n);return t.__chain__=!0,t}function hh(n,t){return t(n),n}function ar(n,t){return t(n)}var gh=ut(function(n){var t=n.length,e=t?n[0]:0,r=this.__wrapped__,u=function(o){return Qr(o,n)};return t>1||this.__actions__.length||!(r instanceof U)||!st(e)?this.thru(u):(r=r.slice(e,+e+(t?1:0)),r.__actions__.push({func:ar,args:[u],thisArg:i}),new Wn(r,this.__chain__).thru(function(o){return t&&!o.length&&o.push(i),o}))});function ph(){return Ys(this)}function dh(){return new Wn(this.value(),this.__chain__)}function _h(){this.__values__===i&&(this.__values__=ao(this.value()));var n=this.__index__>=this.__values__.length,t=n?i:this.__values__[this.__index__++];return{done:n,value:t}}function vh(){return this}function wh(n){for(var t,e=this;e instanceof Je;){var r=qs(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 mh(){var n=this.__wrapped__;if(n instanceof U){var t=n;return this.__actions__.length&&(t=new U(this)),t=t.reverse(),t.__actions__.push({func:ar,args:[bi],thisArg:i}),new Wn(t,this.__chain__)}return this.thru(bi)}function yh(){return ls(this.__wrapped__,this.__actions__)}var xh=nr(function(n,t,e){k.call(n,e)?++n[e]:rt(n,e,1)});function Sh(n,t,e){var r=L(n)?Au:hl;return e&&vn(n,t,e)&&(t=i),r(n,R(t,3))}function Ah(n,t){var e=L(n)?ht:Ju;return e(n,R(t,3))}var Ch=xs(Gs),bh=xs(ks);function Rh(n,t){return hn(fr(n,t),1)}function Th(n,t){return hn(fr(n,t),Se)}function Ph(n,t,e){return e=e===i?1:O(e),hn(fr(n,t),e)}function Zs(n,t){var e=L(n)?Ln:_t;return e(n,R(t,3))}function Xs(n,t){var e=L(n)?Ka:Ku;return e(n,R(t,3))}var Eh=nr(function(n,t,e){k.call(n,e)?n[e].push(t):rt(n,e,[t])});function Ih(n,t,e,r){n=xn(n)?n:Yt(n),e=e&&!r?O(e):0;var u=n.length;return e<0&&(e=sn(u+e,0)),pr(n)?e<=u&&n.indexOf(t,e)>-1:!!u&&Ut(n,t,e)>-1}var Lh=M(function(n,t,e){var r=-1,u=typeof t=="function",o=xn(n)?h(n.length):[];return _t(n,function(a){o[++r]=u?Cn(t,a,e):le(a,t,e)}),o}),Oh=nr(function(n,t,e){rt(n,e,t)});function fr(n,t){var e=L(n)?Y:ju;return e(n,R(t,3))}function Wh(n,t,e,r){return n==null?[]:(L(t)||(t=t==null?[]:[t]),e=r?i:e,L(e)||(e=e==null?[]:[e]),rs(n,t,e))}var Mh=nr(function(n,t,e){n[e?0:1].push(t)},function(){return[[],[]]});function Fh(n,t,e){var r=L(n)?Nr:Tu,u=arguments.length<3;return r(n,R(t,4),e,u,_t)}function Uh(n,t,e){var r=L(n)?Ja:Tu,u=arguments.length<3;return r(n,R(t,4),e,u,Ku)}function Dh(n,t){var e=L(n)?ht:Ju;return e(n,hr(R(t,3)))}function Nh(n){var t=L(n)?Gu:Il;return t(n)}function Bh(n,t,e){(e?vn(n,t,e):t===i)?t=1:t=O(t);var r=L(n)?ol:Ll;return r(n,t)}function $h(n){var t=L(n)?al:Wl;return t(n)}function qh(n){if(n==null)return 0;if(xn(n))return pr(n)?Nt(n):n.length;var t=pn(n);return t==Gn||t==kn?n.size:ri(n).length}function Gh(n,t,e){var r=L(n)?Br:Ml;return e&&vn(n,t,e)&&(t=i),r(n,R(t,3))}var kh=M(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]]),rs(n,hn(t,1),[])}),lr=Af||function(){return cn.Date.now()};function zh(n,t){if(typeof t!="function")throw new On(A);return n=O(n),function(){if(--n<1)return t.apply(this,arguments)}}function Qs(n,t,e){return t=e?i:t,t=n&&t==null?n.length:t,it(n,$,i,i,i,i,t)}function Vs(n,t){var e;if(typeof t!="function")throw new On(A);return n=O(n),function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=i),e}}var Ti=M(function(n,t,e){var r=tn;if(e.length){var u=pt(e,Kt(Ti));r|=$n}return it(n,r,t,e,u)}),js=M(function(n,t,e){var r=tn|lt;if(e.length){var u=pt(e,Kt(js));r|=$n}return it(t,r,n,e,u)});function no(n,t,e){t=e?i:t;var r=it(n,Bn,i,i,i,i,i,t);return r.placeholder=no.placeholder,r}function to(n,t,e){t=e?i:t;var r=it(n,xt,i,i,i,i,i,t);return r.placeholder=to.placeholder,r}function eo(n,t,e){var r,u,o,a,f,c,d=0,_=!1,v=!1,x=!0;if(typeof n!="function")throw new On(A);t=Dn(t)||0,Z(e)&&(_=!!e.leading,v="maxWait"in e,o=v?sn(Dn(e.maxWait)||0,t):o,x="trailing"in e?!!e.trailing:x);function b(nn){var Jn=r,ft=u;return r=u=i,d=nn,a=n.apply(ft,Jn),a}function T(nn){return d=nn,f=de(F,t),_?b(nn):a}function W(nn){var Jn=nn-c,ft=nn-d,So=t-Jn;return v?gn(So,o-ft):So}function P(nn){var Jn=nn-c,ft=nn-d;return c===i||Jn>=t||Jn<0||v&&ft>=o}function F(){var nn=lr();if(P(nn))return D(nn);f=de(F,W(nn))}function D(nn){return f=i,x&&r?b(nn):(r=u=i,a)}function Pn(){f!==i&&hs(f),d=0,r=c=u=f=i}function wn(){return f===i?a:D(lr())}function En(){var nn=lr(),Jn=P(nn);if(r=arguments,u=this,c=nn,Jn){if(f===i)return T(c);if(v)return hs(f),f=de(F,t),b(c)}return f===i&&(f=de(F,t)),a}return En.cancel=Pn,En.flush=wn,En}var Hh=M(function(n,t){return Hu(n,1,t)}),Kh=M(function(n,t,e){return Hu(n,Dn(t)||0,e)});function Jh(n){return it(n,X)}function cr(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new On(A);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(cr.Cache||et),e}cr.Cache=et;function hr(n){if(typeof n!="function")throw new On(A);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 Yh(n){return Vs(2,n)}var Zh=Fl(function(n,t){t=t.length==1&&L(t[0])?Y(t[0],bn(R())):Y(hn(t,1),bn(R()));var e=t.length;return M(function(r){for(var u=-1,o=gn(r.length,e);++u<o;)r[u]=t[u].call(this,r[u]);return Cn(n,this,r)})}),Pi=M(function(n,t){var e=pt(t,Kt(Pi));return it(n,$n,i,t,e)}),ro=M(function(n,t){var e=pt(t,Kt(ro));return it(n,en,i,t,e)}),Xh=ut(function(n,t){return it(n,V,i,i,i,t)});function Qh(n,t){if(typeof n!="function")throw new On(A);return t=t===i?t:O(t),M(n,t)}function Vh(n,t){if(typeof n!="function")throw new On(A);return t=t==null?0:sn(O(t),0),M(function(e){var r=e[t],u=mt(e,0,t);return r&&gt(u,r),Cn(n,this,u)})}function jh(n,t,e){var r=!0,u=!0;if(typeof n!="function")throw new On(A);return Z(e)&&(r="leading"in e?!!e.leading:r,u="trailing"in e?!!e.trailing:u),eo(n,t,{leading:r,maxWait:t,trailing:u})}function ng(n){return Qs(n,1)}function tg(n,t){return Pi(hi(t),n)}function eg(){if(!arguments.length)return[];var n=arguments[0];return L(n)?n:[n]}function rg(n){return Mn(n,an)}function ig(n,t){return t=typeof t=="function"?t:i,Mn(n,an,t)}function ug(n){return Mn(n,ln|an)}function sg(n,t){return t=typeof t=="function"?t:i,Mn(n,ln|an,t)}function og(n,t){return t==null||zu(n,t,fn(t))}function Kn(n,t){return n===t||n!==n&&t!==t}var ag=ir(ni),fg=ir(function(n,t){return n>=t}),It=Xu(function(){return arguments}())?Xu:function(n){return Q(n)&&k.call(n,"callee")&&!Uu.call(n,"callee")},L=h.isArray,lg=vu?bn(vu):wl;function xn(n){return n!=null&&gr(n.length)&&!ot(n)}function j(n){return Q(n)&&xn(n)}function cg(n){return n===!0||n===!1||Q(n)&&_n(n)==Zt}var yt=bf||Bi,hg=wu?bn(wu):ml;function gg(n){return Q(n)&&n.nodeType===1&&!_e(n)}function pg(n){if(n==null)return!0;if(xn(n)&&(L(n)||typeof n=="string"||typeof n.splice=="function"||yt(n)||Jt(n)||It(n)))return!n.length;var t=pn(n);if(t==Gn||t==kn)return!n.size;if(pe(n))return!ri(n).length;for(var e in n)if(k.call(n,e))return!1;return!0}function dg(n,t){return ce(n,t)}function _g(n,t,e){e=typeof e=="function"?e:i;var r=e?e(n,t):i;return r===i?ce(n,t,i,e):!!r}function Ei(n){if(!Q(n))return!1;var t=_n(n);return t==be||t==No||typeof n.message=="string"&&typeof n.name=="string"&&!_e(n)}function vg(n){return typeof n=="number"&&Nu(n)}function ot(n){if(!Z(n))return!1;var t=_n(n);return t==Re||t==Hi||t==Do||t==$o}function io(n){return typeof n=="number"&&n==O(n)}function gr(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=Ot}function Z(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function Q(n){return n!=null&&typeof n=="object"}var uo=mu?bn(mu):xl;function wg(n,t){return n===t||ei(n,t,mi(t))}function mg(n,t,e){return e=typeof e=="function"?e:i,ei(n,t,mi(t),e)}function yg(n){return so(n)&&n!=+n}function xg(n){if(ic(n))throw new I(C);return Qu(n)}function Sg(n){return n===null}function Ag(n){return n==null}function so(n){return typeof n=="number"||Q(n)&&_n(n)==Qt}function _e(n){if(!Q(n)||_n(n)!=nt)return!1;var t=$e(n);if(t===null)return!0;var e=k.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Ue.call(e)==mf}var Ii=yu?bn(yu):Sl;function Cg(n){return io(n)&&n>=-9007199254740991&&n<=Ot}var oo=xu?bn(xu):Al;function pr(n){return typeof n=="string"||!L(n)&&Q(n)&&_n(n)==jt}function Tn(n){return typeof n=="symbol"||Q(n)&&_n(n)==Te}var Jt=Su?bn(Su):Cl;function bg(n){return n===i}function Rg(n){return Q(n)&&pn(n)==ne}function Tg(n){return Q(n)&&_n(n)==Go}var Pg=ir(ii),Eg=ir(function(n,t){return n<=t});function ao(n){if(!n)return[];if(xn(n))return pr(n)?zn(n):yn(n);if(re&&n[re])return of(n[re]());var t=pn(n),e=t==Gn?Hr:t==kn?We:Yt;return e(n)}function at(n){if(!n)return n===0?n:0;if(n=Dn(n),n===Se||n===-1/0){var t=n<0?-1:1;return t*Wo}return n===n?n:0}function O(n){var t=at(n),e=t%1;return t===t?e?t-e:t:0}function fo(n){return n?Rt(O(n),0,Zn):0}function Dn(n){if(typeof n=="number")return n;if(Tn(n))return Ae;if(Z(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=Z(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=Pu(n);var e=fa.test(n);return e||ca.test(n)?ka(n.slice(2),e?2:8):aa.test(n)?Ae:+n}function lo(n){return Qn(n,Sn(n))}function Ig(n){return n?Rt(O(n),-9007199254740991,Ot):n===0?n:0}function G(n){return n==null?"":Rn(n)}var Lg=zt(function(n,t){if(pe(t)||xn(t)){Qn(t,fn(t),n);return}for(var e in t)k.call(t,e)&&ae(n,e,t[e])}),co=zt(function(n,t){Qn(t,Sn(t),n)}),dr=zt(function(n,t,e,r){Qn(t,Sn(t),n,r)}),Og=zt(function(n,t,e,r){Qn(t,fn(t),n,r)}),Wg=ut(Qr);function Mg(n,t){var e=kt(n);return t==null?e:ku(e,t)}var Fg=M(function(n,t){n=z(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=Sn(o),f=-1,c=a.length;++f<c;){var d=a[f],_=n[d];(_===i||Kn(_,$t[d])&&!k.call(n,d))&&(n[d]=o[d])}return n}),Ug=M(function(n){return n.push(i,Ps),Cn(ho,i,n)});function Dg(n,t){return Cu(n,R(t,3),Xn)}function Ng(n,t){return Cu(n,R(t,3),jr)}function Bg(n,t){return n==null?n:Vr(n,R(t,3),Sn)}function $g(n,t){return n==null?n:Yu(n,R(t,3),Sn)}function qg(n,t){return n&&Xn(n,R(t,3))}function Gg(n,t){return n&&jr(n,R(t,3))}function kg(n){return n==null?[]:Xe(n,fn(n))}function zg(n){return n==null?[]:Xe(n,Sn(n))}function Li(n,t,e){var r=n==null?i:Tt(n,t);return r===i?e:r}function Hg(n,t){return n!=null&&Ls(n,t,pl)}function Oi(n,t){return n!=null&&Ls(n,t,dl)}var Kg=As(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=De.call(t)),n[t]=e},Mi(An)),Jg=As(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=De.call(t)),k.call(n,t)?n[t].push(e):n[t]=[e]},R),Yg=M(le);function fn(n){return xn(n)?qu(n):ri(n)}function Sn(n){return xn(n)?qu(n,!0):bl(n)}function Zg(n,t){var e={};return t=R(t,3),Xn(n,function(r,u,o){rt(e,t(r,u,o),r)}),e}function Xg(n,t){var e={};return t=R(t,3),Xn(n,function(r,u,o){rt(e,u,t(r,u,o))}),e}var Qg=zt(function(n,t,e){Qe(n,t,e)}),ho=zt(function(n,t,e,r){Qe(n,t,e,r)}),Vg=ut(function(n,t){var e={};if(n==null)return e;var r=!1;t=Y(t,function(o){return o=wt(o,n),r||(r=o.length>1),o}),Qn(n,vi(n),e),r&&(e=Mn(e,ln|Nn|an,Kl));for(var u=t.length;u--;)fi(e,t[u]);return e});function jg(n,t){return go(n,hr(R(t)))}var np=ut(function(n,t){return n==null?{}:Tl(n,t)});function go(n,t){if(n==null)return{};var e=Y(vi(n),function(r){return[r]});return t=R(t),is(n,e,function(r,u){return t(r,u[0])})}function tp(n,t,e){t=wt(t,n);var r=-1,u=t.length;for(u||(u=1,n=i);++r<u;){var o=n==null?i:n[Vn(t[r])];o===i&&(r=u,o=e),n=ot(o)?o.call(n):o}return n}function ep(n,t,e){return n==null?n:he(n,t,e)}function rp(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:he(n,t,e,r)}var po=Rs(fn),_o=Rs(Sn);function ip(n,t,e){var r=L(n),u=r||yt(n)||Jt(n);if(t=R(t,4),e==null){var o=n&&n.constructor;u?e=r?new o:[]:Z(n)?e=ot(o)?kt($e(n)):{}:e={}}return(u?Ln:Xn)(n,function(a,f,c){return t(e,a,f,c)}),e}function up(n,t){return n==null?!0:fi(n,t)}function sp(n,t,e){return n==null?n:fs(n,t,hi(e))}function op(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:fs(n,t,hi(e),r)}function Yt(n){return n==null?[]:zr(n,fn(n))}function ap(n){return n==null?[]:zr(n,Sn(n))}function fp(n,t,e){return e===i&&(e=t,t=i),e!==i&&(e=Dn(e),e=e===e?e:0),t!==i&&(t=Dn(t),t=t===t?t:0),Rt(Dn(n),t,e)}function lp(n,t,e){return t=at(t),e===i?(e=t,t=0):e=at(e),n=Dn(n),_l(n,t,e)}function cp(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=at(n),t===i?(t=n,n=0):t=at(t)),n>t){var r=n;n=t,t=r}if(e||n%1||t%1){var u=Bu();return gn(n+u*(t-n+Ga("1e-"+((u+"").length-1))),t)}return si(n,t)}var hp=Ht(function(n,t,e){return t=t.toLowerCase(),n+(e?vo(t):t)});function vo(n){return Wi(G(n).toLowerCase())}function wo(n){return n=G(n),n&&n.replace(ga,tf).replace(Oa,"")}function gp(n,t,e){n=G(n),t=Rn(t);var r=n.length;e=e===i?r:Rt(O(e),0,r);var u=e;return e-=t.length,e>=0&&n.slice(e,u)==t}function pp(n){return n=G(n),n&&Jo.test(n)?n.replace(Yi,ef):n}function dp(n){return n=G(n),n&&jo.test(n)?n.replace(Pr,"\\$&"):n}var _p=Ht(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()}),vp=Ht(function(n,t,e){return n+(e?" ":"")+t.toLowerCase()}),wp=ys("toLowerCase");function mp(n,t,e){n=G(n),t=O(t);var r=t?Nt(n):0;if(!t||r>=t)return n;var u=(t-r)/2;return rr(ze(u),e)+n+rr(ke(u),e)}function yp(n,t,e){n=G(n),t=O(t);var r=t?Nt(n):0;return t&&r<t?n+rr(t-r,e):n}function xp(n,t,e){n=G(n),t=O(t);var r=t?Nt(n):0;return t&&r<t?rr(t-r,e)+n:n}function Sp(n,t,e){return e||t==null?t=0:t&&(t=+t),Ef(G(n).replace(Er,""),t||0)}function Ap(n,t,e){return(e?vn(n,t,e):t===i)?t=1:t=O(t),oi(G(n),t)}function Cp(){var n=arguments,t=G(n[0]);return n.length<3?t:t.replace(n[1],n[2])}var bp=Ht(function(n,t,e){return n+(e?"_":"")+t.toLowerCase()});function Rp(n,t,e){return e&&typeof e!="number"&&vn(n,t,e)&&(t=e=i),e=e===i?Zn:e>>>0,e?(n=G(n),n&&(typeof t=="string"||t!=null&&!Ii(t))&&(t=Rn(t),!t&&Dt(n))?mt(zn(n),0,e):n.split(t,e)):[]}var Tp=Ht(function(n,t,e){return n+(e?" ":"")+Wi(t)});function Pp(n,t,e){return n=G(n),e=e==null?0:Rt(O(e),0,n.length),t=Rn(t),n.slice(e,e+t.length)==t}function Ep(n,t,e){var r=s.templateSettings;e&&vn(n,t,e)&&(t=i),n=G(n),t=dr({},t,r,Ts);var u=dr({},t.imports,r.imports,Ts),o=fn(u),a=zr(u,o),f,c,d=0,_=t.interpolate||Pe,v="__p += '",x=Kr((t.escape||Pe).source+"|"+_.source+"|"+(_===Zi?oa:Pe).source+"|"+(t.evaluate||Pe).source+"|$","g"),b="//# sourceURL="+(k.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Da+"]")+`
19
+ `;n.replace(x,function(P,F,D,Pn,wn,En){return D||(D=Pn),v+=n.slice(d,En).replace(pa,rf),F&&(f=!0,v+=`' +
20
+ __e(`+F+`) +
21
+ '`),wn&&(c=!0,v+=`';
22
+ `+wn+`;
23
+ __p += '`),D&&(v+=`' +
24
+ ((__t = (`+D+`)) == null ? '' : __t) +
25
+ '`),d=En+P.length,P}),v+=`';
26
+ `;var T=k.call(t,"variable")&&t.variable;if(!T)v=`with (obj) {
27
+ `+v+`
28
+ }
29
+ `;else if(ua.test(T))throw new I(B);v=(c?v.replace(ko,""):v).replace(zo,"$1").replace(Ho,"$1;"),v="function("+(T||"obj")+`) {
30
+ `+(T?"":`obj || (obj = {});
31
+ `)+"var __t, __p = ''"+(f?", __e = _.escape":"")+(c?`, __j = Array.prototype.join;
32
+ function print() { __p += __j.call(arguments, '') }
33
+ `:`;
34
+ `)+v+`return __p
35
+ }`;var W=yo(function(){return q(o,b+"return "+v).apply(i,a)});if(W.source=v,Ei(W))throw W;return W}function Ip(n){return G(n).toLowerCase()}function Lp(n){return G(n).toUpperCase()}function Op(n,t,e){if(n=G(n),n&&(e||t===i))return Pu(n);if(!n||!(t=Rn(t)))return n;var r=zn(n),u=zn(t),o=Eu(r,u),a=Iu(r,u)+1;return mt(r,o,a).join("")}function Wp(n,t,e){if(n=G(n),n&&(e||t===i))return n.slice(0,Ou(n)+1);if(!n||!(t=Rn(t)))return n;var r=zn(n),u=Iu(r,zn(t))+1;return mt(r,0,u).join("")}function Mp(n,t,e){if(n=G(n),n&&(e||t===i))return n.replace(Er,"");if(!n||!(t=Rn(t)))return n;var r=zn(n),u=Eu(r,zn(t));return mt(r,u).join("")}function Fp(n,t){var e=rn,r=qn;if(Z(t)){var u="separator"in t?t.separator:u;e="length"in t?O(t.length):e,r="omission"in t?Rn(t.omission):r}n=G(n);var o=n.length;if(Dt(n)){var a=zn(n);o=a.length}if(e>=o)return n;var f=e-Nt(r);if(f<1)return r;var c=a?mt(a,0,f).join(""):n.slice(0,f);if(u===i)return c+r;if(a&&(f+=c.length-f),Ii(u)){if(n.slice(f).search(u)){var d,_=c;for(u.global||(u=Kr(u.source,G(Xi.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(Rn(u),f)!=f){var x=c.lastIndexOf(u);x>-1&&(c=c.slice(0,x))}return c+r}function Up(n){return n=G(n),n&&Ko.test(n)?n.replace(Ji,cf):n}var Dp=Ht(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Wi=ys("toUpperCase");function mo(n,t,e){return n=G(n),t=e?i:t,t===i?sf(n)?pf(n):Xa(n):n.match(t)||[]}var yo=M(function(n,t){try{return Cn(n,i,t)}catch(e){return Ei(e)?e:new I(e)}}),Np=ut(function(n,t){return Ln(t,function(e){e=Vn(e),rt(n,e,Ti(n[e],n))}),n});function Bp(n){var t=n==null?0:n.length,e=R();return n=t?Y(n,function(r){if(typeof r[1]!="function")throw new On(A);return[e(r[0]),r[1]]}):[],M(function(r){for(var u=-1;++u<t;){var o=n[u];if(Cn(o[0],this,r))return Cn(o[1],this,r)}})}function $p(n){return cl(Mn(n,ln))}function Mi(n){return function(){return n}}function qp(n,t){return n==null||n!==n?t:n}var Gp=Ss(),kp=Ss(!0);function An(n){return n}function Fi(n){return Vu(typeof n=="function"?n:Mn(n,ln))}function zp(n){return ns(Mn(n,ln))}function Hp(n,t){return ts(n,Mn(t,ln))}var Kp=M(function(n,t){return function(e){return le(e,n,t)}}),Jp=M(function(n,t){return function(e){return le(n,e,t)}});function Ui(n,t,e){var r=fn(t),u=Xe(t,r);e==null&&!(Z(t)&&(u.length||!r.length))&&(e=t,t=n,n=this,u=Xe(t,fn(t)));var o=!(Z(e)&&"chain"in e)||!!e.chain,a=ot(n);return Ln(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__=yn(this.__actions__);return v.push({func:c,args:arguments,thisArg:n}),_.__chain__=d,_}return c.apply(n,gt([this.value()],arguments))})}),n}function Yp(){return cn._===this&&(cn._=yf),this}function Di(){}function Zp(n){return n=O(n),M(function(t){return es(t,n)})}var Xp=pi(Y),Qp=pi(Au),Vp=pi(Br);function xo(n){return xi(n)?$r(Vn(n)):Pl(n)}function jp(n){return function(t){return n==null?i:Tt(n,t)}}var nd=Cs(),td=Cs(!0);function Ni(){return[]}function Bi(){return!1}function ed(){return{}}function rd(){return""}function id(){return!0}function ud(n,t){if(n=O(n),n<1||n>Ot)return[];var e=Zn,r=gn(n,Zn);t=R(t),n-=Zn;for(var u=kr(r,t);++e<n;)t(e);return u}function sd(n){return L(n)?Y(n,Vn):Tn(n)?[n]:yn($s(G(n)))}function od(n){var t=++wf;return G(n)+t}var ad=er(function(n,t){return n+t},0),fd=di("ceil"),ld=er(function(n,t){return n/t},1),cd=di("floor");function hd(n){return n&&n.length?Ze(n,An,ni):i}function gd(n,t){return n&&n.length?Ze(n,R(t,2),ni):i}function pd(n){return Ru(n,An)}function dd(n,t){return Ru(n,R(t,2))}function _d(n){return n&&n.length?Ze(n,An,ii):i}function vd(n,t){return n&&n.length?Ze(n,R(t,2),ii):i}var wd=er(function(n,t){return n*t},1),md=di("round"),yd=er(function(n,t){return n-t},0);function xd(n){return n&&n.length?Gr(n,An):0}function Sd(n,t){return n&&n.length?Gr(n,R(t,2)):0}return s.after=zh,s.ary=Qs,s.assign=Lg,s.assignIn=co,s.assignInWith=dr,s.assignWith=Og,s.at=Wg,s.before=Vs,s.bind=Ti,s.bindAll=Np,s.bindKey=js,s.castArray=eg,s.chain=Ys,s.chunk=cc,s.compact=hc,s.concat=gc,s.cond=Bp,s.conforms=$p,s.constant=Mi,s.countBy=xh,s.create=Mg,s.curry=no,s.curryRight=to,s.debounce=eo,s.defaults=Fg,s.defaultsDeep=Ug,s.defer=Hh,s.delay=Kh,s.difference=pc,s.differenceBy=dc,s.differenceWith=_c,s.drop=vc,s.dropRight=wc,s.dropRightWhile=mc,s.dropWhile=yc,s.fill=xc,s.filter=Ah,s.flatMap=Rh,s.flatMapDeep=Th,s.flatMapDepth=Ph,s.flatten=zs,s.flattenDeep=Sc,s.flattenDepth=Ac,s.flip=Jh,s.flow=Gp,s.flowRight=kp,s.fromPairs=Cc,s.functions=kg,s.functionsIn=zg,s.groupBy=Eh,s.initial=Rc,s.intersection=Tc,s.intersectionBy=Pc,s.intersectionWith=Ec,s.invert=Kg,s.invertBy=Jg,s.invokeMap=Lh,s.iteratee=Fi,s.keyBy=Oh,s.keys=fn,s.keysIn=Sn,s.map=fr,s.mapKeys=Zg,s.mapValues=Xg,s.matches=zp,s.matchesProperty=Hp,s.memoize=cr,s.merge=Qg,s.mergeWith=ho,s.method=Kp,s.methodOf=Jp,s.mixin=Ui,s.negate=hr,s.nthArg=Zp,s.omit=Vg,s.omitBy=jg,s.once=Yh,s.orderBy=Wh,s.over=Xp,s.overArgs=Zh,s.overEvery=Qp,s.overSome=Vp,s.partial=Pi,s.partialRight=ro,s.partition=Mh,s.pick=np,s.pickBy=go,s.property=xo,s.propertyOf=jp,s.pull=Wc,s.pullAll=Ks,s.pullAllBy=Mc,s.pullAllWith=Fc,s.pullAt=Uc,s.range=nd,s.rangeRight=td,s.rearg=Xh,s.reject=Dh,s.remove=Dc,s.rest=Qh,s.reverse=bi,s.sampleSize=Bh,s.set=ep,s.setWith=rp,s.shuffle=$h,s.slice=Nc,s.sortBy=kh,s.sortedUniq=Hc,s.sortedUniqBy=Kc,s.split=Rp,s.spread=Vh,s.tail=Jc,s.take=Yc,s.takeRight=Zc,s.takeRightWhile=Xc,s.takeWhile=Qc,s.tap=hh,s.throttle=jh,s.thru=ar,s.toArray=ao,s.toPairs=po,s.toPairsIn=_o,s.toPath=sd,s.toPlainObject=lo,s.transform=ip,s.unary=ng,s.union=Vc,s.unionBy=jc,s.unionWith=nh,s.uniq=th,s.uniqBy=eh,s.uniqWith=rh,s.unset=up,s.unzip=Ri,s.unzipWith=Js,s.update=sp,s.updateWith=op,s.values=Yt,s.valuesIn=ap,s.without=ih,s.words=mo,s.wrap=tg,s.xor=uh,s.xorBy=sh,s.xorWith=oh,s.zip=ah,s.zipObject=fh,s.zipObjectDeep=lh,s.zipWith=ch,s.entries=po,s.entriesIn=_o,s.extend=co,s.extendWith=dr,Ui(s,s),s.add=ad,s.attempt=yo,s.camelCase=hp,s.capitalize=vo,s.ceil=fd,s.clamp=fp,s.clone=rg,s.cloneDeep=ug,s.cloneDeepWith=sg,s.cloneWith=ig,s.conformsTo=og,s.deburr=wo,s.defaultTo=qp,s.divide=ld,s.endsWith=gp,s.eq=Kn,s.escape=pp,s.escapeRegExp=dp,s.every=Sh,s.find=Ch,s.findIndex=Gs,s.findKey=Dg,s.findLast=bh,s.findLastIndex=ks,s.findLastKey=Ng,s.floor=cd,s.forEach=Zs,s.forEachRight=Xs,s.forIn=Bg,s.forInRight=$g,s.forOwn=qg,s.forOwnRight=Gg,s.get=Li,s.gt=ag,s.gte=fg,s.has=Hg,s.hasIn=Oi,s.head=Hs,s.identity=An,s.includes=Ih,s.indexOf=bc,s.inRange=lp,s.invoke=Yg,s.isArguments=It,s.isArray=L,s.isArrayBuffer=lg,s.isArrayLike=xn,s.isArrayLikeObject=j,s.isBoolean=cg,s.isBuffer=yt,s.isDate=hg,s.isElement=gg,s.isEmpty=pg,s.isEqual=dg,s.isEqualWith=_g,s.isError=Ei,s.isFinite=vg,s.isFunction=ot,s.isInteger=io,s.isLength=gr,s.isMap=uo,s.isMatch=wg,s.isMatchWith=mg,s.isNaN=yg,s.isNative=xg,s.isNil=Ag,s.isNull=Sg,s.isNumber=so,s.isObject=Z,s.isObjectLike=Q,s.isPlainObject=_e,s.isRegExp=Ii,s.isSafeInteger=Cg,s.isSet=oo,s.isString=pr,s.isSymbol=Tn,s.isTypedArray=Jt,s.isUndefined=bg,s.isWeakMap=Rg,s.isWeakSet=Tg,s.join=Ic,s.kebabCase=_p,s.last=Un,s.lastIndexOf=Lc,s.lowerCase=vp,s.lowerFirst=wp,s.lt=Pg,s.lte=Eg,s.max=hd,s.maxBy=gd,s.mean=pd,s.meanBy=dd,s.min=_d,s.minBy=vd,s.stubArray=Ni,s.stubFalse=Bi,s.stubObject=ed,s.stubString=rd,s.stubTrue=id,s.multiply=wd,s.nth=Oc,s.noConflict=Yp,s.noop=Di,s.now=lr,s.pad=mp,s.padEnd=yp,s.padStart=xp,s.parseInt=Sp,s.random=cp,s.reduce=Fh,s.reduceRight=Uh,s.repeat=Ap,s.replace=Cp,s.result=tp,s.round=md,s.runInContext=l,s.sample=Nh,s.size=qh,s.snakeCase=bp,s.some=Gh,s.sortedIndex=Bc,s.sortedIndexBy=$c,s.sortedIndexOf=qc,s.sortedLastIndex=Gc,s.sortedLastIndexBy=kc,s.sortedLastIndexOf=zc,s.startCase=Tp,s.startsWith=Pp,s.subtract=yd,s.sum=xd,s.sumBy=Sd,s.template=Ep,s.times=ud,s.toFinite=at,s.toInteger=O,s.toLength=fo,s.toLower=Ip,s.toNumber=Dn,s.toSafeInteger=Ig,s.toString=G,s.toUpper=Lp,s.trim=Op,s.trimEnd=Wp,s.trimStart=Mp,s.truncate=Fp,s.unescape=Up,s.uniqueId=od,s.upperCase=Dp,s.upperFirst=Wi,s.each=Zs,s.eachRight=Xs,s.first=Hs,Ui(s,function(){var n={};return Xn(s,function(t,e){k.call(s.prototype,e)||(n[e]=t)}),n}(),{chain:!1}),s.VERSION=w,Ln(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){s[n].placeholder=s}),Ln(["drop","take"],function(n,t){U.prototype[n]=function(e){e=e===i?1:sn(O(e),0);var r=this.__filtered__&&!t?new U(this):this.clone();return r.__filtered__?r.__takeCount__=gn(e,r.__takeCount__):r.__views__.push({size:gn(e,Zn),type:n+(r.__dir__<0?"Right":"")}),r},U.prototype[n+"Right"]=function(e){return this.reverse()[n](e).reverse()}}),Ln(["filter","map","takeWhile"],function(n,t){var e=t+1,r=e==zi||e==Oo;U.prototype[n]=function(u){var o=this.clone();return o.__iteratees__.push({iteratee:R(u,3),type:e}),o.__filtered__=o.__filtered__||r,o}}),Ln(["head","last"],function(n,t){var e="take"+(t?"Right":"");U.prototype[n]=function(){return this[e](1).value()[0]}}),Ln(["initial","tail"],function(n,t){var e="drop"+(t?"":"Right");U.prototype[n]=function(){return this.__filtered__?new U(this):this[e](1)}}),U.prototype.compact=function(){return this.filter(An)},U.prototype.find=function(n){return this.filter(n).head()},U.prototype.findLast=function(n){return this.reverse().find(n)},U.prototype.invokeMap=M(function(n,t){return typeof n=="function"?new U(this):this.map(function(e){return le(e,n,t)})}),U.prototype.reject=function(n){return this.filter(hr(R(n)))},U.prototype.slice=function(n,t){n=O(n);var e=this;return e.__filtered__&&(n>0||t<0)?new U(e):(n<0?e=e.takeRight(-n):n&&(e=e.drop(n)),t!==i&&(t=O(t),e=t<0?e.dropRight(-t):e.take(t-n)),e)},U.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},U.prototype.toArray=function(){return this.take(Zn)},Xn(U.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 U,d=f[0],_=c||L(a),v=function(F){var D=u.apply(s,gt([F],f));return r&&x?D[0]:D};_&&e&&typeof d=="function"&&d.length!=1&&(c=_=!1);var x=this.__chain__,b=!!this.__actions__.length,T=o&&!x,W=c&&!b;if(!o&&_){a=W?a:new U(this);var P=n.apply(a,f);return P.__actions__.push({func:ar,args:[v],thisArg:i}),new Wn(P,x)}return T&&W?n.apply(this,f):(P=this.thru(v),T?r?P.value()[0]:P.value():P)})}),Ln(["pop","push","shift","sort","splice","unshift"],function(n){var t=Me[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(L(o)?o:[],u)}return this[e](function(a){return t.apply(L(a)?a:[],u)})}}),Xn(U.prototype,function(n,t){var e=s[t];if(e){var r=e.name+"";k.call(Gt,r)||(Gt[r]=[]),Gt[r].push({name:t,func:e})}}),Gt[tr(i,lt).name]=[{name:"wrapper",func:i}],U.prototype.clone=Uf,U.prototype.reverse=Df,U.prototype.value=Nf,s.prototype.at=gh,s.prototype.chain=ph,s.prototype.commit=dh,s.prototype.next=_h,s.prototype.plant=wh,s.prototype.reverse=mh,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=yh,s.prototype.first=s.prototype.head,re&&(s.prototype[re]=vh),s},Bt=df();St?((St.exports=Bt)._=Bt,Fr._=Bt):cn._=Bt}).call(ve)})(vr,vr.exports);var Id=vr.exports;const Ld=bd(Id);class Od{constructor(g){E(this,"config");this.config=g}async complete(g,i){var w;await this.persist(g,{...i,success:!0}),(w=this.config.logger)==null||w.debug("Transaction completed:",g)}async fail(g,i){var w;await this.persist(g,{...i,success:!1}),(w=this.config.logger)==null||w.debug("Transaction failed:",{...g,...i})}async persist(g,i){await fetch(`${this.config.apiUrl}/transactions/${g.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Wd{constructor(g,i){E(this,"transaction");E(this,"manager");this.transaction=g,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(g,i){var B;const w=this.transaction.functionCall;if(!w){await this.fail("No function call found");return}const m=w.name,C=w.args,A=g[m];if(!A){await this.fail(`Tool ${m} not found`);return}try{const N=Ld.get(i,"schema.config.parameters.properties",{}),dn=(N&&Object.keys(N).length>0?Object.keys(N):((B=A.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:B[1].split(",").map(Nn=>Nn.trim()).filter(Boolean))||[]).map(Nn=>C[Nn]),ln=await A.apply(null,dn);await this.complete(ln)}catch(N){await this.fail(`Error executing tool ${m}: ${N}`)}}async complete(g){await this.manager.complete(this.transaction,{success:!0,output:g,error:null})}async fail(g){await this.manager.fail(this.transaction,{success:!1,output:null,error:g})}}class Ro extends me{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 Od(this.config),m=new Wd(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 ye=mn.createContext(void 0);function Md(y){return new Promise((g,i)=>{const w=new FileReader;w.readAsDataURL(y),w.onload=()=>{const C=w.result.split(";base64,")[1];g(C)},w.onerror=m=>{i(m)}})}function To(y){const g={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=g[i.getName()];if(w)return w(i)}return null}function Fd({dev:y=!1,baseUrl:g,protocols:i,logger:w,children:m,session:C="new",...A}){const[B,N]=mn.useState(!1),[on,dn]=mn.useState([]),[ln,Nn]=mn.useState(C),[an,Yn]=mn.useState(new Map),jn=mn.useRef(!1),tn=mn.useMemo(()=>{if(Array.isArray(i))return i;if(typeof i=="object"&&i!==null){const en=y?"localhost:8000":g||"persona.applica.guru/api",$=y?"http":"https",V=y?"ws":"wss";let X=Object.keys(i).map(rn=>{switch(rn){case"rest":const qn=i[rn];return qn===!0?new qi({apiUrl:`${$}://${en}`,apiKey:A.apiKey,agentId:A.agentId,logger:w}):typeof qn=="object"&&qn!==null?new qi(qn):null;case"webrtc":const J=i[rn];return J===!0?new ki({webrtcUrl:`${V}://${en}/webrtc`,apiKey:A.apiKey,agentId:A.agentId,logger:w}):typeof J=="object"&&J!==null?new ki(J):null;case"websocket":const ct=i[rn];return ct===!0?new Gi({webSocketUrl:`${V}://${en}/websocket`,apiKey:A.apiKey,agentId:A.agentId,logger:w}):typeof ct=="object"&&ct!==null?new Gi(ct):null;default:throw new Error(`Unknown protocol: ${rn}`)}}).filter(rn=>rn!==null);return A.tools&&X.push(new Ro({apiUrl:`${$}://${en}`,apiKey:A.apiKey,agentId:A.agentId,tools:A.tools,logger:w})),X}throw new Error("Invalid protocols configuration")},[]);mn.useEffect(()=>{if(jn.current)return;jn.current=!0,w==null||w.debug("Initializing protocols: ",tn.map($=>$.getName()));const en=To(tn);tn.forEach($=>{$.setSession(ln),$.clearListeners(),$.addStatusChangeListener(V=>{w==null||w.debug(`${$.getName()} has notified new status: ${V}`),an.set($.getName(),V),V==="connected"&&(A.context&&$.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:A.context}}),A.tools&&Array.isArray(A.tools)&&$.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:A.tools.map(X=>X.schema)}}})),Yn(new Map(an))}),$.addPacketListener(V=>{if(V.type==="message"){const X=V.payload;dn(rn=>Co([...rn,{...X,protocol:$.getName()}]))}else if(V.type==="reasoning"){const X=V.payload;let rn=X.thought;X.imageUrl&&(rn+=`
10
36
 
11
- ![image](https://persona.applica.guru/api/files/${p.imageUrl})`);const y={type:"reasoning",text:w,role:"assistant",finishReason:"stop"};g(b=>_([...b,{...y,protocol:l.getName()}]))}else f.type==="transaction"&&S.filter(p=>p!==l).forEach(p=>p.onTransaction(f.payload))}),l.autostart&&l.status==="disconnected"&&(s==null||s.debug(`Connecting to protocol: ${l.getName()}`),l.connect(P))}))},[P,S,s,k]);const J=async l=>{var b;if(((b=l.content[0])==null?void 0:b.type)!=="text")throw new Error("Only text messages are supported");if(!S.some(h=>h.getName()!=="transaction"&&h.status==="connected")){g(h=>[...h,{role:"assistant",type:"text",text:"No protocol is connected."}]);return}const p=l.content[0].text;g(h=>[...h,{role:"user",type:"text",text:p}]),u(!0);const w=S.sort((h,x)=>x.getPriority()-h.getPriority()).find(h=>h.status==="connected"),y=[];if(l.attachments)for(const h of l.attachments)h.contentType.startsWith("image/")&&h.file&&y.push({role:"user",image:{contentType:h.contentType,content:await ne(h.file)},text:"",type:"text"});l.content&&y.push({role:"user",text:l.content[0].text,type:"text"}),s==null||s.debug("Sending message:",y),await(w==null?void 0:w.sendPacket({type:"request",payload:y})),u(!1)},K=m.useCallback(()=>(u(!1),g([]),A("new"),Promise.resolve()),[]),B=m.useCallback(()=>Promise.resolve(),[]),V=m.useCallback(()=>d,[d]),Y=v.useExternalStoreRuntime({isRunning:c,messages:d,convertMessage:Z,onNew:J,onCancel:K,onReload:B,adapters:{attachments:new v.CompositeAttachmentAdapter([new v.SimpleImageAttachmentAdapter])}});return M.jsx(E.Provider,{value:{protocols:S,protocolsStatus:k,getMessages:V},children:M.jsx(v.AssistantRuntimeProvider,{runtime:Y,children:n})})}function ae({children:o,...t}){return M.jsx(oe,{...t,children:o})}function re(){const o=m.useContext(E);if(!o)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return o}function z(o){const t=m.useContext(E);if(!t)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const e=t.protocols.find(n=>n.getName()===o);if(!e)return null;const s=t.protocolsStatus.get(e.getName());return{...e,connect:e.connect.bind(e),disconnect:e.disconnect.bind(e),sendPacket:e.sendPacket.bind(e),setSession:e.setSession.bind(e),addStatusChangeListener:e.addStatusChangeListener.bind(e),addPacketListener:e.addPacketListener.bind(e),getName:e.getName.bind(e),getPriority:e.getPriority.bind(e),status:s||e.status}}function ie(){const o=m.useContext(E);if(!o)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");const t={rest:e=>e.config.apiUrl,webrtc:e=>e.config.webrtcUrl.replace("/webrtc","").replace("ws://","http://").replace("wss://","https://"),websocket:e=>e.config.webSocketUrl.replace("/websocket","").replace("ws://","http://").replace("wss://","https://")};for(const e of o.protocols){const s=t[e.getName()];if(s)return s(e)}return null}function ce(){return z("webrtc")}function le(){const o=m.useContext(E);if(!o)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return o.getMessages()}class ue{constructor(){i(this,"prefix","[Persona]")}log(t,...e){console.log(`${this.prefix} - ${t}`,...e)}info(t,...e){console.info(`${this.prefix} - ${t}`,...e)}warn(t,...e){console.warn(`${this.prefix} - ${t}`,...e)}error(t,...e){console.error(`${this.prefix} - ${t}`,...e)}debug(t,...e){console.debug(`${this.prefix} - ${t}`,...e)}}function C(o,t,e){return{type:o,description:t,...e}}function D(o){const t=Object.entries(o.parameters).filter(([e,s])=>s.required).map(([e])=>e);return{type:"local",name:o.name,description:o.description,config:{timeout:o.timeout||60,parameters:{type:"object",title:o.title||`${o.name} parameters`,required:t,properties:o.parameters},output:{type:"object",title:`${o.name} output`,properties:o.output}}}}function $(o){return{schema:D(o),implementation:o.implementation}}function L(o,t,e,s,n,a){const r={name:o,description:t,title:a==null?void 0:a.title,timeout:a==null?void 0:a.timeout,parameters:s,output:n,implementation:e};return $(r)}const he=L("sum","Sum two numbers",function(t,e){return{result:t+e}},{a:C("number","First number to sum",{required:!0}),b:C("number","Second number to sum",{required:!0})},{result:C("number","Sum of two numbers")}),de=$({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:C("number","First number to sum"),b:C("number","Seconth number to sum")},output:{result:C("number","Sum of two numbers")},implementation:function(t,e){return{result:t+e}}});function pe(o){const t=[],e={};return o.forEach(s=>{const{schema:n,implementation:a}=$(s);t.push(n),e[s.name]=a}),{schemas:t,implementations:e}}function me(o,t){const{required:e,properties:s}=t.config.parameters;for(const n of e)if(!(n in o))throw new Error(`Missing required parameter: ${n}`);for(const[n,a]of Object.entries(o)){const r=s[n];if(r){if(r.type==="number"&&typeof a!="number")throw new Error(`Parameter ${n} should be a number`);if(r.type==="string"&&typeof a!="string")throw new Error(`Parameter ${n} should be a string`);if(r.type==="boolean"&&typeof a!="boolean")throw new Error(`Parameter ${n} should be a boolean`)}}return!0}exports.PersonaConsoleLogger=ue;exports.PersonaProtocolBase=T;exports.PersonaRESTProtocol=I;exports.PersonaRuntimeProvider=ae;exports.PersonaTransactionProtocol=U;exports.PersonaWebRTCProtocol=O;exports.PersonaWebSocketProtocol=q;exports.createParameter=C;exports.createTool=$;exports.createToolFromFunction=L;exports.createToolRegistry=pe;exports.generateToolSchema=D;exports.navigateToToolExample=de;exports.sumTool=he;exports.usePersonaRuntime=re;exports.usePersonaRuntimeEndpoint=ie;exports.usePersonaRuntimeMessages=le;exports.usePersonaRuntimeProtocol=z;exports.usePersonaRuntimeWebRTCProtocol=ce;exports.validateToolParameters=me;
37
+ ![image](${en}/api/files/${X.imageUrl})`);const qn={type:"reasoning",text:rn,role:"assistant",finishReason:"stop"};dn(J=>Co([...J,{...qn,protocol:$.getName()}]))}else V.type==="transaction"&&tn.filter(X=>X!==$).forEach(X=>X.onTransaction(V.payload))}),$.autostart&&$.status==="disconnected"&&(w==null||w.debug(`Connecting to protocol: ${$.getName()}`),$.connect(ln))})},[ln,tn,w,an]);const lt=async en=>{var qn;if(((qn=en.content[0])==null?void 0:qn.type)!=="text")throw new Error("Only text messages are supported");if(!tn.some(J=>J.getName()!=="transaction"&&J.status==="connected")){dn(J=>[...J,{role:"assistant",type:"text",text:"No protocol is connected."}]);return}const V=en.content[0].text;dn(J=>[...J,{role:"user",type:"text",text:V}]),N(!0);const X=tn.sort((J,ct)=>ct.getPriority()-J.getPriority()).find(J=>J.status==="connected"),rn=[];if(en.attachments)for(const J of en.attachments)J.contentType.startsWith("image/")&&J.file&&rn.push({role:"user",image:{contentType:J.contentType,content:await Md(J.file)},text:"",type:"text"});en.content&&rn.push({role:"user",text:en.content[0].text,type:"text"}),w==null||w.debug("Sending message:",rn),await(X==null?void 0:X.sendPacket({type:"request",payload:rn})),N(!1)},xe=mn.useCallback(()=>(N(!1),dn([]),Nn("new"),Promise.resolve()),[]),Bn=mn.useCallback(()=>Promise.resolve(),[]),xt=mn.useCallback(()=>on,[on]),$n=_r.useExternalStoreRuntime({isRunning:B,messages:on,convertMessage:Pd,onNew:lt,onCancel:xe,onReload:Bn,adapters:{attachments:new _r.CompositeAttachmentAdapter([new _r.SimpleImageAttachmentAdapter])}});return $i.jsx(ye.Provider,{value:{protocols:tn,protocolsStatus:an,getMessages:xt},children:$i.jsx(_r.AssistantRuntimeProvider,{runtime:$n,children:m})})}function Ud({children:y,...g}){return $i.jsx(Fd,{...g,children:y})}function Dd(){const y=mn.useContext(ye);if(!y)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return y}function Po(y){const g=mn.useContext(ye);if(!g)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=g.protocols.find(m=>m.getName()===y);if(!i)return null;const w=g.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 Nd(){const y=mn.useContext(ye);if(!y)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return To(y.protocols)}function Bd(){return Po("webrtc")}function $d(){const y=mn.useContext(ye);if(!y)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return y.getMessages()}class qd{constructor(){E(this,"prefix","[Persona]")}log(g,...i){console.log(`${this.prefix} - ${g}`,...i)}info(g,...i){console.info(`${this.prefix} - ${g}`,...i)}warn(g,...i){console.warn(`${this.prefix} - ${g}`,...i)}error(g,...i){console.error(`${this.prefix} - ${g}`,...i)}debug(g,...i){console.debug(`${this.prefix} - ${g}`,...i)}}function Lt(y,g,i){return{type:y,description:g,...i}}function Eo(y){const g=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:g,properties:y.parameters},output:{type:"object",title:`${y.name} output`,properties:y.output}}}}function wr(y){return{schema:Eo(y),implementation:y.implementation}}function Io(y,g,i,w,m,C){const A={name:y,description:g,title:C==null?void 0:C.title,timeout:C==null?void 0:C.timeout,parameters:w,output:m,implementation:i};return wr(A)}const Gd=Io("sum","Sum two numbers",function(g,i){return{result:g+i}},{a:Lt("number","First number to sum",{required:!0}),b:Lt("number","Second number to sum",{required:!0})},{result:Lt("number","Sum of two numbers")}),kd=wr({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:Lt("number","First number to sum"),b:Lt("number","Seconth number to sum")},output:{result:Lt("number","Sum of two numbers")},implementation:function(g,i){return{result:g+i}}});function zd(y){const g=[],i={};return y.forEach(w=>{const{schema:m,implementation:C}=wr(w);g.push(m),i[w.name]=C}),{schemas:g,implementations:i}}function Hd(y,g){const{required:i,properties:w}=g.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 A=w[m];if(A){if(A.type==="number"&&typeof C!="number")throw new Error(`Parameter ${m} should be a number`);if(A.type==="string"&&typeof C!="string")throw new Error(`Parameter ${m} should be a string`);if(A.type==="boolean"&&typeof C!="boolean")throw new Error(`Parameter ${m} should be a boolean`)}}return!0}exports.PersonaConsoleLogger=qd;exports.PersonaProtocolBase=me;exports.PersonaRESTProtocol=qi;exports.PersonaRuntimeProvider=Ud;exports.PersonaTransactionProtocol=Ro;exports.PersonaWebRTCProtocol=ki;exports.PersonaWebSocketProtocol=Gi;exports.createParameter=Lt;exports.createTool=wr;exports.createToolFromFunction=Io;exports.createToolRegistry=zd;exports.generateToolSchema=Eo;exports.navigateToToolExample=kd;exports.sumTool=Gd;exports.usePersonaRuntime=Dd;exports.usePersonaRuntimeEndpoint=Nd;exports.usePersonaRuntimeMessages=$d;exports.usePersonaRuntimeProtocol=Po;exports.usePersonaRuntimeWebRTCProtocol=Bd;exports.validateToolParameters=Hd;
12
38
  //# sourceMappingURL=bundle.cjs.js.map