@applica-software-guru/persona-chat-sdk 0.1.113 → 0.1.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +7 -0
- package/dist/bundle.cjs.js +14 -14
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +2867 -2633
- package/dist/bundle.es.js.map +1 -1
- package/dist/bundle.iife.js +17 -17
- package/dist/bundle.iife.js.map +1 -1
- package/dist/bundle.umd.js +14 -14
- package/dist/bundle.umd.js.map +1 -1
- package/dist/protocol/rest.d.ts +1 -0
- package/dist/protocol/rest.d.ts.map +1 -1
- package/dist/runtime/context.d.ts +11 -1
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/handlers.d.ts +7 -6
- package/dist/runtime/handlers.d.ts.map +1 -1
- package/dist/runtime/listeners.d.ts +6 -3
- package/dist/runtime/listeners.d.ts.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/types.d.ts +68 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/playground/src/hooks/theme.ts +0 -1
- package/playground/src/tools.ts +4 -3
- package/src/protocol/rest.ts +134 -21
- package/src/runtime/context.ts +25 -1
- package/src/runtime/handlers.ts +70 -32
- package/src/runtime/listeners.ts +190 -18
- package/src/runtime.tsx +56 -26
- package/src/types.ts +88 -3
package/dist/bundle.iife.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
var personaChatSDK=function(Z,Jt,J,ue){"use strict";var l_=Object.defineProperty;var h_=(Z,Jt,J)=>Jt in Z?l_(Z,Jt,{enumerable:!0,configurable:!0,writable:!0,value:J}):Z[Jt]=J;var E=(Z,Jt,J)=>h_(Z,typeof Jt!="symbol"?Jt+"":Jt,J);function Mo(l){return new Promise((a,i)=>{const p=new FileReader;p.onload=()=>a(p.result),p.onerror=g=>i(g),p.readAsDataURL(l)})}class Ko{constructor(){E(this,"accept","*")}async add(a){return{id:a.file.name,type:"file",name:a.file.name,contentType:a.file.type||"application/octet-stream",file:a.file,status:{type:"requires-action",reason:"composer-send"}}}async send(a){const p=(await Mo(a.file)).split(";base64,")[1];return{...a,status:{type:"complete"},content:[{type:"file",data:p,mimeType:a.contentType||"application/octet-stream"}]}}async remove(a){}}function Ir(l){if(l==null||typeof l=="string")return l;if(Array.isArray(l))return l.map(Ir);if(typeof l=="object"){const a=l;return typeof a.contentType=="string"&&typeof a.content=="string"?{type:"image",contentType:a.contentType,note:"image content delivered separately"}:typeof a.name=="string"&&typeof a.contentType=="string"?{type:"file",name:a.name,url:a.url??null,contentType:a.contentType}:Object.fromEntries(Object.entries(a).map(([i,p])=>[i,Ir(p)]))}return l}let ko=0;function qo(){return`msg_${Date.now()}_${ko++}`}function Ho(l){return l.thought&&(l={...l,type:"reasoning"}),l.id?l.createdAt?l:{...l,createdAt:new Date}:{...l,id:qo(),createdAt:l.createdAt||new Date}}function zo(l){return l.filter(a=>!(a.role==="assistant"&&!a.functionCalls&&!a.file&&!a.image&&(!a.text||a.text.trim()==="")))}function Tn(l){const a=[];let i=null;for(let g of l)if(g=Ho(g),g.type!=="transaction")if(g.file){i&&(a.push(i),i=null),a.push(g);continue}else g.functionCalls?(i&&(i.role==="assistant"&&(!i.text||i.text.trim()==="")&&!i.file&&!i.image||a.push(i)),a.push(g),i=null):g.functionResponse?a[a.length-1]={...a[a.length-1],functionResponse:g.functionResponse}:i&&g.type===i.type&&g.protocol===i.protocol&&i.role===g.role&&(g.id===i.id||!i.finishReason)?(i.text+=g.text,i.file=i.file||g.file,i.finishReason=g.finishReason||i.finishReason,i.id=i.id||g.id,i.sources=i.sources?[...i.sources||[],...g.sources||[]]:g.sources):(i&&a.push(i),i={...g,text:g.file?"":g.text,finishReason:g.file?void 0:g.finishReason});return i&&a.push(i),zo(a)}function Go(l){var g,v,x;const a=l.file?[{type:"file",data:l.file.url,mimeType:l.file.contentType}]:[];let i;if((l.role==="assistant"||l.role==="function")&&(l.status?i=l.status:l.finishReason==="stop"?i={type:"complete",reason:"stop"}:l.finishReason==="function_call"?i={type:"complete",reason:"stop"}:l.finishReason||(i=void 0)),l.role==="function"){const T={id:l.id,role:"assistant",createdAt:l.createdAt,content:((g=l.functionCalls)==null?void 0:g.map(C=>{var K;return{type:"tool-call",toolName:C.name,toolCallId:C.id||`tool_${Date.now()}`,args:C.args,result:Ir((K=l.functionResponse)==null?void 0:K.result)}}))??[],metadata:{...l.metadata,custom:{protocol:l.protocol,sessionId:l.sessionId,sources:l.sources,...(v=l.metadata)==null?void 0:v.custom}}};return i?{...T,status:i}:T}const p={id:l.id,role:l.role,createdAt:l.createdAt,content:l.type==="reasoning"?[{type:"reasoning",text:l.text},...a]:[{type:"text",text:l.text},...a],metadata:{...l.metadata,custom:{protocol:l.protocol,sessionId:l.sessionId,sources:l.sources,type:l.type,...(x=l.metadata)==null?void 0:x.custom}}};return l.role==="assistant"&&i?{...p,status:i}:p}class oe{constructor(){E(this,"statusChangeCallbacks",[]);E(this,"messageCallbacks",[])}addStatusChangeListener(a){this.statusChangeCallbacks.push(a)}addPacketListener(a){this.messageCallbacks.push(a)}async syncSession(a){this.session=a}async notifyPacket(a){this.messageCallbacks.forEach(i=>i(a))}async notifyPackets(a){a.forEach(i=>{this.messageCallbacks.forEach(p=>p(i))})}async setSession(a){this.session=a}async setStatus(a){const i=this.status!==a;this.status=a,i&&this.statusChangeCallbacks.forEach(p=>p(a))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}setAgentContext(a){return this.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:a}})}onTransaction(a){}}class Rr extends oe{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 C,K,X,A,D;const{apiUrl:p,apiKey:g,agentId:v}=this.config,x=this.session??"new";if(i.type==="command"&&((C=i==null?void 0:i.payload)==null?void 0:C.command)=="set_initial_context"){this.context=(K=i==null?void 0:i.payload)==null?void 0:K.arguments;return}else if(i.type==="command"&&((X=i==null?void 0:i.payload)==null?void 0:X.command)=="set_local_tools"){const P=(A=i==null?void 0:i.payload)==null?void 0:A.arguments.tools;(P==null?void 0:P.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const T=i.payload;try{const N=await(await fetch(`${p}/sessions/${x}/messages`,{body:JSON.stringify({agentId:v,userMessage:T,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":g}})).json();this.notifyPackets(N.response.messages.map(tt=>({type:"message",payload:tt})))}catch(P){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(D=this.config.logger)==null||D.error("Error sending packet:",P)}}}class Er extends oe{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 p;(p=this.config.logger)==null||p.debug("Syncing session with WebSocket protocol:",i),this.session=i,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(i))}connect(i){var C;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const p=i||this.session||"new";(C=this.config.logger)==null||C.debug("Connecting to WebSocket with sessionId:",p);const g=encodeURIComponent(this.config.apiKey),v=this.config.agentId,x=this.config.userId||"anonymous",T=`${this.config.webSocketUrl}?sessionCode=${p}&agentId=${v}&apiKey=${g}&userId=${encodeURIComponent(x)}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(T),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",K=>{const X=JSON.parse(K.data);this.notifyPacket(X)}),this.webSocket.addEventListener("close",K=>{var X;this.setStatus("disconnected"),this.webSocket=null,K.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(X=this.config.logger)==null||X.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var K;this.setStatus("disconnected"),this.webSocket=null,(K=this.config.logger)==null||K.error("WebSocket connection error")}),Promise.resolve(p)}disconnect(){var i;return(i=this.config.logger)==null||i.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(1e3,"Normal closure"),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 Jo{constructor(a){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=a}async connect(a){var p;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(g){(p=this.config.logger)==null||p.error("Error accessing microphone:",g);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(g=>{this.pc.addTrack(g,this.localStream)}),this.pc.ontrack=g=>{g.streams[0].getTracks().forEach(x=>{this.remoteStream.addTrack(x)}),this.audioCtx||this._startAnalyzers();const v=new Audio;v.srcObject=this.remoteStream,v.play().catch(x=>{var T;(T=this.config.logger)==null||T.error("Error playing remote audio:",x)})},this.pc.onicecandidate=g=>{var v;g.candidate&&((v=this.ws)==null?void 0:v.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:g.candidate}}))},this.pc.ondatachannel=g=>{const v=g.channel;v.onmessage=x=>{this.messageCallbacks.forEach(T=>{T(x)})},v.onopen=()=>{var x;for(;this.queuedMessages.length>0;){const T=this.queuedMessages.shift();T&&(v.send(JSON.stringify(T)),(x=this.config.logger)==null||x.info("Sent queued message:",T))}}};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 T,C;const g=await this.pc.createOffer();await this.pc.setLocalDescription(g);const v={apiKey:this.config.apiKey,agentId:this.config.agentId,userId:this.config.userId||"anonymous",sessionCode:a};(T=this.config.logger)==null||T.debug("Opening connection to WebRTC server: ",v);const x={type:"OFFER",src:((C=crypto.randomUUID)==null?void 0:C.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:g.sdp,type:g.type},connectionId:(Date.now()%1e6).toString(),metadata:v}};this.ws.send(JSON.stringify(x))},this.ws.onmessage=async g=>{var x;const v=JSON.parse(g.data);if(v.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(v.payload.sdp));else if(v.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(v.payload.candidate))}catch(T){(x=this.config.logger)==null||x.error("Error adding ICE candidate:",T)}},this.ws.onclose=g=>{g.code!==1e3&&this.errorCallbacks.forEach(v=>{v("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var a;this.isConnected&&(this.isConnected=!1,((a=this.ws)==null?void 0:a.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(a){this.visualizerCallbacks.push(a)}addMessageCallback(a){this.messageCallbacks.push(a)}addErrorCallback(a){this.errorCallbacks.push(a)}createDataChannel(a="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(a),this.dataChannel.onopen=()=>{var i,p;for((i=this.config.logger)==null||i.info("Data channel opened");this.queuedMessages.length>0;){const g=this.queuedMessages.shift();g&&(this.dataChannel.send(JSON.stringify(g)),(p=this.config.logger)==null||p.info("Sent queued message:",g))}},this.dataChannel.onmessage=i=>{this.messageCallbacks.forEach(p=>{p(i)})})}sendPacket(a){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(a);return}this.dataChannel.send(JSON.stringify(a)),(i=this.config.logger)==null||i.info("Sent message:",a)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const a=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,a.connect(this.localAnalyser),i.connect(this.remoteAnalyser);const p=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const g=new Uint8Array(this.localAnalyser.frequencyBinCount),v=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(g),this.remoteAnalyser.getByteFrequencyData(v);const x=g.reduce((C,K)=>C+K,0)/g.length,T=v.reduce((C,K)=>C+K,0)/v.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(C=>{C({localAmplitude:x,remoteAmplitude:T})}),this.analyzerFrame=requestAnimationFrame(p)};this.analyzerFrame=requestAnimationFrame(p)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class Tr extends oe{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 Jo(i),this.webRTCClient.addMessageCallback(p=>{const g=JSON.parse(p.data);this.notifyPacket(g)}),this.webRTCClient.addErrorCallback(p=>{var g;(g=this.config.logger)==null||g.error("WebRTC error:",p),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:p}})})}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 p;return this.status==="connected"?Promise.resolve(this.session):(this.session=i||this.session||"new",this.setStatus("connecting"),(p=this.config.logger)==null||p.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,p,g;if(this.status==="disconnected")return(i=this.config.logger)==null||i.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(g=(p=this.config)==null?void 0:p.logger)==null||g.debug("Disconnected from WebRTC")}sendPacket(i){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(i),Promise.resolve())}}var ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Zo(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Te={exports:{}};/**
|
|
1
|
+
var personaChatSDK=function(J,Jt,q,cn){"use strict";var v_=Object.defineProperty;var y_=(J,Jt,q)=>Jt in J?v_(J,Jt,{enumerable:!0,configurable:!0,writable:!0,value:q}):J[Jt]=q;var O=(J,Jt,q)=>y_(J,typeof Jt!="symbol"?Jt+"":Jt,q);function Ba(l){return new Promise((o,i)=>{const h=new FileReader;h.onload=()=>o(h.result),h.onerror=g=>i(g),h.readAsDataURL(l)})}class ka{constructor(){O(this,"accept","*")}async add(o){return{id:o.file.name,type:"file",name:o.file.name,contentType:o.file.type||"application/octet-stream",file:o.file,status:{type:"requires-action",reason:"composer-send"}}}async send(o){const h=(await Ba(o.file)).split(";base64,")[1];return{...o,status:{type:"complete"},content:[{type:"file",data:h,mimeType:o.contentType||"application/octet-stream"}]}}async remove(o){}}function Rr(l){if(l==null||typeof l=="string")return l;if(Array.isArray(l))return l.map(Rr);if(typeof l=="object"){const o=l;return typeof o.contentType=="string"&&typeof o.content=="string"?{type:"image",contentType:o.contentType,note:"image content delivered separately"}:typeof o.name=="string"&&typeof o.contentType=="string"?{type:"file",name:o.name,url:o.url??null,contentType:o.contentType}:Object.fromEntries(Object.entries(o).map(([i,h])=>[i,Rr(h)]))}return l}let Ka=0;function qa(){return`msg_${Date.now()}_${Ka++}`}function Ha(l){return l.thought&&(l={...l,type:"reasoning"}),l.id?l.createdAt?l:{...l,createdAt:new Date}:{...l,id:qa(),createdAt:l.createdAt||new Date}}function Ga(l){return l.filter(o=>!(o.role==="assistant"&&!o.functionCalls&&!o.file&&!o.image&&(!o.text||o.text.trim()==="")))}function Ee(l){const o=[];let i=null;for(let g of l)if(g=Ha(g),g.type!=="transaction")if(g.file){i&&(o.push(i),i=null),o.push(g);continue}else g.functionCalls?(i&&(i.role==="assistant"&&(!i.text||i.text.trim()==="")&&!i.file&&!i.image||o.push(i)),o.push(g),i=null):g.functionResponse?o[o.length-1]={...o[o.length-1],functionResponse:g.functionResponse}:i&&g.type===i.type&&g.protocol===i.protocol&&i.role===g.role&&(g.id===i.id||!i.finishReason)?(i.text+=g.text,i.file=i.file||g.file,i.finishReason=g.finishReason||i.finishReason,i.id=i.id||g.id,i.sources=i.sources?[...i.sources||[],...g.sources||[]]:g.sources):(i&&o.push(i),i={...g,text:g.file?"":g.text,finishReason:g.file?void 0:g.finishReason});return i&&o.push(i),Ga(o)}function za(l){var g,v,S;const o=l.file?[{type:"file",data:l.file.url,mimeType:l.file.contentType}]:[];let i;if((l.role==="assistant"||l.role==="function")&&(l.status?i=l.status:l.finishReason==="stop"?i={type:"complete",reason:"stop"}:l.finishReason==="function_call"?i={type:"complete",reason:"stop"}:l.finishReason||(i=void 0)),l.role==="function"){const I={id:l.id,role:"assistant",createdAt:l.createdAt,content:((g=l.functionCalls)==null?void 0:g.map(b=>{var B;return{type:"tool-call",toolName:b.name,toolCallId:b.id||`tool_${Date.now()}`,args:b.args,result:Rr((B=l.functionResponse)==null?void 0:B.result)}}))??[],metadata:{...l.metadata,custom:{protocol:l.protocol,sessionId:l.sessionId,sources:l.sources,...(v=l.metadata)==null?void 0:v.custom}}};return i?{...I,status:i}:I}const h={id:l.id,role:l.role,createdAt:l.createdAt,content:l.type==="reasoning"?[{type:"reasoning",text:l.text},...o]:[{type:"text",text:l.text},...o],metadata:{...l.metadata,custom:{protocol:l.protocol,sessionId:l.sessionId,sources:l.sources,type:l.type,...(S=l.metadata)==null?void 0:S.custom}}};return l.role==="assistant"&&i?{...h,status:i}:h}class fn{constructor(){O(this,"statusChangeCallbacks",[]);O(this,"messageCallbacks",[])}addStatusChangeListener(o){this.statusChangeCallbacks.push(o)}addPacketListener(o){this.messageCallbacks.push(o)}async syncSession(o){this.session=o}async notifyPacket(o){this.messageCallbacks.forEach(i=>i(o))}async notifyPackets(o){o.forEach(i=>{this.messageCallbacks.forEach(h=>h(i))})}async setSession(o){this.session=o}async setStatus(o){const i=this.status!==o;this.status=o,i&&this.statusChangeCallbacks.forEach(h=>h(o))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}setAgentContext(o){return this.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:o}})}onTransaction(o){}}class Ir extends fn{constructor(i){super();O(this,"status");O(this,"autostart");O(this,"session");O(this,"config");O(this,"notify",!0);O(this,"context",{});O(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}buildHeaders(){return{"Content-Type":"application/json","x-persona-apikey":this.config.apiKey}}async sendPacket(i){var I,b,B,X,P,U;const{apiUrl:h,agentId:g}=this.config,v=this.session??"new";if(i.type==="command"){const A=i.payload;if(A.command==="set_initial_context"){this.context=A.arguments;return}if(A.command==="set_local_tools"){const T=(I=A.arguments)==null?void 0:I.tools;T!=null&&T.length&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}if(A.command==="cancel"){try{await fetch(`${h}/sessions/${encodeURIComponent(String(v))}/cancel`,{method:"POST",headers:this.buildHeaders()}),this.notifyPacket({type:"agent_end",payload:{sessionId:String(v),stopReason:"cancelled",totalTurns:0}})}catch(T){(b=this.config.logger)==null||b.error("Error cancelling via REST:",T)}return}if(A.command==="steer"){const T=((B=A.arguments)==null?void 0:B.text)||"";if(!T)return;try{const ft=await(await fetch(`${h}/sessions/${encodeURIComponent(String(v))}/steer`,{method:"POST",headers:this.buildHeaders(),body:JSON.stringify({text:T})})).json();this.notifyPacket({type:"steer_accepted",payload:ft})}catch(Z){(X=this.config.logger)==null||X.error("Error steering via REST:",Z)}return}if(A.command==="get_agent_state"){try{const Z=await(await fetch(`${h}/sessions/${encodeURIComponent(String(v))}/agent-state`,{method:"GET",headers:this.buildHeaders()})).json();this.notifyPacket({type:"command",payload:{command:"get_agent_state",arguments:Z}})}catch(T){(P=this.config.logger)==null||P.error("Error getting agent state via REST:",T)}return}return}if(i.type!=="request")return;const S=i.payload;this.notifyPacket({type:"agent_start",payload:{sessionId:String(v),agentId:g,timestamp:new Date().toISOString()}});try{const T=await(await fetch(`${h}/sessions/${encodeURIComponent(String(v))}/messages`,{body:JSON.stringify({agentId:g,userMessage:S,initialContext:this.context,tools:this.tools}),method:"POST",headers:this.buildHeaders()})).json();this.notifyPackets(T.response.messages.map(Z=>({type:"message",payload:Z}))),this.notifyPacket({type:"agent_end",payload:{sessionId:String(v),stopReason:"completed",totalTurns:1}}),T.sessionId&&T.sessionId!==v&&(this.session=T.sessionId,this.notifyPacket({type:"command",payload:{command:"set_initial_context",arguments:{sessionId:T.sessionId}}}))}catch(A){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),this.notifyPacket({type:"agent_end",payload:{sessionId:String(v),stopReason:"error",totalTurns:0,errorMessage:String(A)}}),(U=this.config.logger)==null||U.error("Error sending REST packet:",A)}}}class Er extends fn{constructor(i){super();O(this,"status");O(this,"autostart");O(this,"session");O(this,"config");O(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 h;(h=this.config.logger)==null||h.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 h=i||this.session||"new";(b=this.config.logger)==null||b.debug("Connecting to WebSocket with sessionId:",h);const g=encodeURIComponent(this.config.apiKey),v=this.config.agentId,S=this.config.userId||"anonymous",I=`${this.config.webSocketUrl}?sessionCode=${h}&agentId=${v}&apiKey=${g}&userId=${encodeURIComponent(S)}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(I),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",B=>{const X=JSON.parse(B.data);this.notifyPacket(X)}),this.webSocket.addEventListener("close",B=>{var X;this.setStatus("disconnected"),this.webSocket=null,B.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(X=this.config.logger)==null||X.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var B;this.setStatus("disconnected"),this.webSocket=null,(B=this.config.logger)==null||B.error("WebSocket connection error")}),Promise.resolve(h)}disconnect(){var i;return(i=this.config.logger)==null||i.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(1e3,"Normal closure"),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 Ja{constructor(o){O(this,"config");O(this,"pc",null);O(this,"ws",null);O(this,"localStream",null);O(this,"remoteStream",new MediaStream);O(this,"audioCtx",null);O(this,"localAnalyser",null);O(this,"remoteAnalyser",null);O(this,"analyzerFrame",null);O(this,"dataChannel",null);O(this,"isConnected",!1);O(this,"visualizerCallbacks",[]);O(this,"messageCallbacks",[]);O(this,"errorCallbacks",[]);O(this,"queuedMessages",[]);this.config=o}async connect(o){var h;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(g){(h=this.config.logger)==null||h.error("Error accessing microphone:",g);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(g=>{this.pc.addTrack(g,this.localStream)}),this.pc.ontrack=g=>{g.streams[0].getTracks().forEach(S=>{this.remoteStream.addTrack(S)}),this.audioCtx||this._startAnalyzers();const v=new Audio;v.srcObject=this.remoteStream,v.play().catch(S=>{var I;(I=this.config.logger)==null||I.error("Error playing remote audio:",S)})},this.pc.onicecandidate=g=>{var v;g.candidate&&((v=this.ws)==null?void 0:v.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:g.candidate}}))},this.pc.ondatachannel=g=>{const v=g.channel;v.onmessage=S=>{this.messageCallbacks.forEach(I=>{I(S)})},v.onopen=()=>{var S;for(;this.queuedMessages.length>0;){const I=this.queuedMessages.shift();I&&(v.send(JSON.stringify(I)),(S=this.config.logger)==null||S.info("Sent queued message:",I))}}};const i=this.config.webrtcUrl||"wss://persona.applica.guru/api/webrtc";this.ws=new WebSocket(`${i}?apiKey=${encodeURIComponent(this.config.apiKey)}`),this.ws.onopen=async()=>{var I,b;const g=await this.pc.createOffer();await this.pc.setLocalDescription(g);const v={apiKey:this.config.apiKey,agentId:this.config.agentId,userId:this.config.userId||"anonymous",sessionCode:o};(I=this.config.logger)==null||I.debug("Opening connection to WebRTC server: ",v);const S={type:"OFFER",src:((b=crypto.randomUUID)==null?void 0:b.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:g.sdp,type:g.type},connectionId:(Date.now()%1e6).toString(),metadata:v}};this.ws.send(JSON.stringify(S))},this.ws.onmessage=async g=>{var S;const v=JSON.parse(g.data);if(v.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(v.payload.sdp));else if(v.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(v.payload.candidate))}catch(I){(S=this.config.logger)==null||S.error("Error adding ICE candidate:",I)}},this.ws.onclose=g=>{g.code!==1e3&&this.errorCallbacks.forEach(v=>{v("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var o;this.isConnected&&(this.isConnected=!1,((o=this.ws)==null?void 0:o.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(o){this.visualizerCallbacks.push(o)}addMessageCallback(o){this.messageCallbacks.push(o)}addErrorCallback(o){this.errorCallbacks.push(o)}createDataChannel(o="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(o),this.dataChannel.onopen=()=>{var i,h;for((i=this.config.logger)==null||i.info("Data channel opened");this.queuedMessages.length>0;){const g=this.queuedMessages.shift();g&&(this.dataChannel.send(JSON.stringify(g)),(h=this.config.logger)==null||h.info("Sent queued message:",g))}},this.dataChannel.onmessage=i=>{this.messageCallbacks.forEach(h=>{h(i)})})}sendPacket(o){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(o);return}this.dataChannel.send(JSON.stringify(o)),(i=this.config.logger)==null||i.info("Sent message:",o)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const o=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,o.connect(this.localAnalyser),i.connect(this.remoteAnalyser);const h=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const g=new Uint8Array(this.localAnalyser.frequencyBinCount),v=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(g),this.remoteAnalyser.getByteFrequencyData(v);const S=g.reduce((b,B)=>b+B,0)/g.length,I=v.reduce((b,B)=>b+B,0)/v.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(b=>{b({localAmplitude:S,remoteAmplitude:I})}),this.analyzerFrame=requestAnimationFrame(h)};this.analyzerFrame=requestAnimationFrame(h)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class Tr extends fn{constructor(i){super();O(this,"status");O(this,"session");O(this,"autostart");O(this,"config");O(this,"webRTCClient");this.config=i,this.status="disconnected",this.session=null,this.autostart=(i==null?void 0:i.autostart)??!1,this.webRTCClient=new Ja(i),this.webRTCClient.addMessageCallback(h=>{const g=JSON.parse(h.data);this.notifyPacket(g)}),this.webRTCClient.addErrorCallback(h=>{var g;(g=this.config.logger)==null||g.error("WebRTC error:",h),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:h}})})}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 h;return this.status==="connected"?Promise.resolve(this.session):(this.session=i||this.session||"new",this.setStatus("connecting"),(h=this.config.logger)==null||h.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,h,g;if(this.status==="disconnected")return(i=this.config.logger)==null||i.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(g=(h=this.config)==null?void 0:h.logger)==null||g.debug("Disconnected from WebRTC")}sendPacket(i){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(i),Promise.resolve())}}var ln=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Za(l){return l&&l.__esModule&&Object.prototype.hasOwnProperty.call(l,"default")?l.default:l}var Ln={exports:{}};/**
|
|
2
2
|
* @license
|
|
3
3
|
* Lodash <https://lodash.com/>
|
|
4
4
|
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
5
5
|
* Released under MIT license <https://lodash.com/license>
|
|
6
6
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
7
7
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
8
|
-
*/Te.exports,function(l,a){(function(){var i,p="4.17.21",g=200,v="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",x="Expected a function",T="Invalid `variable` option passed into `_.template`",C="__lodash_hash_undefined__",K=500,X="__lodash_placeholder__",A=1,D=2,P=4,N=1,tt=2,q=1,yn=2,on=4,dt=8,_t=16,Zt=32,Ln=64,Nt=128,nn=256,Et=512,Le=30,fe="...",Tt=800,We=16,Wn=1,De=2,lt=3,an=1/0,en=9007199254740991,Lr=17976931348623157e292,Hn=NaN,Bt=4294967295,Wr=Bt-1,Fe=Bt>>>1,Dr=[["ary",Nt],["bind",q],["bindKey",yn],["curry",dt],["curryRight",_t],["flip",Et],["partial",Zt],["partialRight",Ln],["rearg",nn]],mn="[object Arguments]",B="[object Array]",at="[object AsyncFunction]",At="[object Boolean]",yt="[object Date]",Ue="[object DOMException]",bt="[object Error]",Ne="[object Function]",as="[object GeneratorFunction]",Yt="[object Map]",ce="[object Number]",Ia="[object Null]",fn="[object Object]",fs="[object Promise]",Ra="[object Proxy]",le="[object RegExp]",Xt="[object Set]",he="[object String]",Be="[object Symbol]",Ea="[object Undefined]",de="[object WeakMap]",Ta="[object WeakSet]",pe="[object ArrayBuffer]",zn="[object DataView]",Fr="[object Float32Array]",Ur="[object Float64Array]",Nr="[object Int8Array]",Br="[object Int16Array]",$r="[object Int32Array]",Mr="[object Uint8Array]",Kr="[object Uint8ClampedArray]",kr="[object Uint16Array]",qr="[object Uint32Array]",Oa=/\b__p \+= '';/g,La=/\b(__p \+=) '' \+/g,Wa=/(__e\(.*?\)|\b__t\)) \+\n'';/g,cs=/&(?:amp|lt|gt|quot|#39);/g,ls=/[&<>"']/g,Da=RegExp(cs.source),Fa=RegExp(ls.source),Ua=/<%-([\s\S]+?)%>/g,Na=/<%([\s\S]+?)%>/g,hs=/<%=([\s\S]+?)%>/g,Ba=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,$a=/^\w*$/,Ma=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Hr=/[\\^$.*+?()[\]{}|]/g,Ka=RegExp(Hr.source),zr=/^\s+/,ka=/\s/,qa=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Ha=/\{\n\/\* \[wrapped with (.+)\] \*/,za=/,? & /,Ga=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ja=/[()=,{}\[\]\/\s]/,Za=/\\(\\)?/g,Ya=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ds=/\w*$/,Xa=/^[-+]0x[0-9a-f]+$/i,Qa=/^0b[01]+$/i,Va=/^\[object .+?Constructor\]$/,ja=/^0o[0-7]+$/i,tf=/^(?:0|[1-9]\d*)$/,nf=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,$e=/($^)/,ef=/['\n\r\u2028\u2029\\]/g,Me="\\ud800-\\udfff",rf="\\u0300-\\u036f",sf="\\ufe20-\\ufe2f",uf="\\u20d0-\\u20ff",ps=rf+sf+uf,gs="\\u2700-\\u27bf",_s="a-z\\xdf-\\xf6\\xf8-\\xff",of="\\xac\\xb1\\xd7\\xf7",af="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",ff="\\u2000-\\u206f",cf=" \\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",vs="A-Z\\xc0-\\xd6\\xd8-\\xde",ws="\\ufe0e\\ufe0f",ys=of+af+ff+cf,Gr="['’]",lf="["+Me+"]",ms="["+ys+"]",Ke="["+ps+"]",xs="\\d+",hf="["+gs+"]",Ss="["+_s+"]",As="[^"+Me+ys+xs+gs+_s+vs+"]",Jr="\\ud83c[\\udffb-\\udfff]",df="(?:"+Ke+"|"+Jr+")",bs="[^"+Me+"]",Zr="(?:\\ud83c[\\udde6-\\uddff]){2}",Yr="[\\ud800-\\udbff][\\udc00-\\udfff]",Gn="["+vs+"]",Cs="\\u200d",Ps="(?:"+Ss+"|"+As+")",pf="(?:"+Gn+"|"+As+")",Is="(?:"+Gr+"(?:d|ll|m|re|s|t|ve))?",Rs="(?:"+Gr+"(?:D|LL|M|RE|S|T|VE))?",Es=df+"?",Ts="["+ws+"]?",gf="(?:"+Cs+"(?:"+[bs,Zr,Yr].join("|")+")"+Ts+Es+")*",_f="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",vf="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Os=Ts+Es+gf,wf="(?:"+[hf,Zr,Yr].join("|")+")"+Os,yf="(?:"+[bs+Ke+"?",Ke,Zr,Yr,lf].join("|")+")",mf=RegExp(Gr,"g"),xf=RegExp(Ke,"g"),Xr=RegExp(Jr+"(?="+Jr+")|"+yf+Os,"g"),Sf=RegExp([Gn+"?"+Ss+"+"+Is+"(?="+[ms,Gn,"$"].join("|")+")",pf+"+"+Rs+"(?="+[ms,Gn+Ps,"$"].join("|")+")",Gn+"?"+Ps+"+"+Is,Gn+"+"+Rs,vf,_f,xs,wf].join("|"),"g"),Af=RegExp("["+Cs+Me+ps+ws+"]"),bf=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Cf=["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"],Pf=-1,et={};et[Fr]=et[Ur]=et[Nr]=et[Br]=et[$r]=et[Mr]=et[Kr]=et[kr]=et[qr]=!0,et[mn]=et[B]=et[pe]=et[At]=et[zn]=et[yt]=et[bt]=et[Ne]=et[Yt]=et[ce]=et[fn]=et[le]=et[Xt]=et[he]=et[de]=!1;var nt={};nt[mn]=nt[B]=nt[pe]=nt[zn]=nt[At]=nt[yt]=nt[Fr]=nt[Ur]=nt[Nr]=nt[Br]=nt[$r]=nt[Yt]=nt[ce]=nt[fn]=nt[le]=nt[Xt]=nt[he]=nt[Be]=nt[Mr]=nt[Kr]=nt[kr]=nt[qr]=!0,nt[bt]=nt[Ne]=nt[de]=!1;var If={À:"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"},Rf={"&":"&","<":"<",">":">",'"':""","'":"'"},Ef={"&":"&","<":"<",">":">",""":'"',"'":"'"},Tf={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Of=parseFloat,Lf=parseInt,Ls=typeof ae=="object"&&ae&&ae.Object===Object&&ae,Wf=typeof self=="object"&&self&&self.Object===Object&&self,pt=Ls||Wf||Function("return this")(),Qr=a&&!a.nodeType&&a,Dn=Qr&&!0&&l&&!l.nodeType&&l,Ws=Dn&&Dn.exports===Qr,Vr=Ws&&Ls.process,$t=function(){try{var h=Dn&&Dn.require&&Dn.require("util").types;return h||Vr&&Vr.binding&&Vr.binding("util")}catch{}}(),Ds=$t&&$t.isArrayBuffer,Fs=$t&&$t.isDate,Us=$t&&$t.isMap,Ns=$t&&$t.isRegExp,Bs=$t&&$t.isSet,$s=$t&&$t.isTypedArray;function Ot(h,w,_){switch(_.length){case 0:return h.call(w);case 1:return h.call(w,_[0]);case 2:return h.call(w,_[0],_[1]);case 3:return h.call(w,_[0],_[1],_[2])}return h.apply(w,_)}function Df(h,w,_,I){for(var F=-1,Y=h==null?0:h.length;++F<Y;){var ft=h[F];w(I,ft,_(ft),h)}return I}function Mt(h,w){for(var _=-1,I=h==null?0:h.length;++_<I&&w(h[_],_,h)!==!1;);return h}function Ff(h,w){for(var _=h==null?0:h.length;_--&&w(h[_],_,h)!==!1;);return h}function Ms(h,w){for(var _=-1,I=h==null?0:h.length;++_<I;)if(!w(h[_],_,h))return!1;return!0}function xn(h,w){for(var _=-1,I=h==null?0:h.length,F=0,Y=[];++_<I;){var ft=h[_];w(ft,_,h)&&(Y[F++]=ft)}return Y}function ke(h,w){var _=h==null?0:h.length;return!!_&&Jn(h,w,0)>-1}function jr(h,w,_){for(var I=-1,F=h==null?0:h.length;++I<F;)if(_(w,h[I]))return!0;return!1}function rt(h,w){for(var _=-1,I=h==null?0:h.length,F=Array(I);++_<I;)F[_]=w(h[_],_,h);return F}function Sn(h,w){for(var _=-1,I=w.length,F=h.length;++_<I;)h[F+_]=w[_];return h}function ti(h,w,_,I){var F=-1,Y=h==null?0:h.length;for(I&&Y&&(_=h[++F]);++F<Y;)_=w(_,h[F],F,h);return _}function Uf(h,w,_,I){var F=h==null?0:h.length;for(I&&F&&(_=h[--F]);F--;)_=w(_,h[F],F,h);return _}function ni(h,w){for(var _=-1,I=h==null?0:h.length;++_<I;)if(w(h[_],_,h))return!0;return!1}var Nf=ei("length");function Bf(h){return h.split("")}function $f(h){return h.match(Ga)||[]}function Ks(h,w,_){var I;return _(h,function(F,Y,ft){if(w(F,Y,ft))return I=Y,!1}),I}function qe(h,w,_,I){for(var F=h.length,Y=_+(I?1:-1);I?Y--:++Y<F;)if(w(h[Y],Y,h))return Y;return-1}function Jn(h,w,_){return w===w?Qf(h,w,_):qe(h,ks,_)}function Mf(h,w,_,I){for(var F=_-1,Y=h.length;++F<Y;)if(I(h[F],w))return F;return-1}function ks(h){return h!==h}function qs(h,w){var _=h==null?0:h.length;return _?ii(h,w)/_:Hn}function ei(h){return function(w){return w==null?i:w[h]}}function ri(h){return function(w){return h==null?i:h[w]}}function Hs(h,w,_,I,F){return F(h,function(Y,ft,j){_=I?(I=!1,Y):w(_,Y,ft,j)}),_}function Kf(h,w){var _=h.length;for(h.sort(w);_--;)h[_]=h[_].value;return h}function ii(h,w){for(var _,I=-1,F=h.length;++I<F;){var Y=w(h[I]);Y!==i&&(_=_===i?Y:_+Y)}return _}function si(h,w){for(var _=-1,I=Array(h);++_<h;)I[_]=w(_);return I}function kf(h,w){return rt(w,function(_){return[_,h[_]]})}function zs(h){return h&&h.slice(0,Ys(h)+1).replace(zr,"")}function Lt(h){return function(w){return h(w)}}function ui(h,w){return rt(w,function(_){return h[_]})}function ge(h,w){return h.has(w)}function Gs(h,w){for(var _=-1,I=h.length;++_<I&&Jn(w,h[_],0)>-1;);return _}function Js(h,w){for(var _=h.length;_--&&Jn(w,h[_],0)>-1;);return _}function qf(h,w){for(var _=h.length,I=0;_--;)h[_]===w&&++I;return I}var Hf=ri(If),zf=ri(Rf);function Gf(h){return"\\"+Tf[h]}function Jf(h,w){return h==null?i:h[w]}function Zn(h){return Af.test(h)}function Zf(h){return bf.test(h)}function Yf(h){for(var w,_=[];!(w=h.next()).done;)_.push(w.value);return _}function oi(h){var w=-1,_=Array(h.size);return h.forEach(function(I,F){_[++w]=[F,I]}),_}function Zs(h,w){return function(_){return h(w(_))}}function An(h,w){for(var _=-1,I=h.length,F=0,Y=[];++_<I;){var ft=h[_];(ft===w||ft===X)&&(h[_]=X,Y[F++]=_)}return Y}function He(h){var w=-1,_=Array(h.size);return h.forEach(function(I){_[++w]=I}),_}function Xf(h){var w=-1,_=Array(h.size);return h.forEach(function(I){_[++w]=[I,I]}),_}function Qf(h,w,_){for(var I=_-1,F=h.length;++I<F;)if(h[I]===w)return I;return-1}function Vf(h,w,_){for(var I=_+1;I--;)if(h[I]===w)return I;return I}function Yn(h){return Zn(h)?tc(h):Nf(h)}function Qt(h){return Zn(h)?nc(h):Bf(h)}function Ys(h){for(var w=h.length;w--&&ka.test(h.charAt(w)););return w}var jf=ri(Ef);function tc(h){for(var w=Xr.lastIndex=0;Xr.test(h);)++w;return w}function nc(h){return h.match(Xr)||[]}function ec(h){return h.match(Sf)||[]}var rc=function h(w){w=w==null?pt:Xn.defaults(pt.Object(),w,Xn.pick(pt,Cf));var _=w.Array,I=w.Date,F=w.Error,Y=w.Function,ft=w.Math,j=w.Object,ai=w.RegExp,ic=w.String,Kt=w.TypeError,ze=_.prototype,sc=Y.prototype,Qn=j.prototype,Ge=w["__core-js_shared__"],Je=sc.toString,V=Qn.hasOwnProperty,uc=0,Xs=function(){var t=/[^.]+$/.exec(Ge&&Ge.keys&&Ge.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Ze=Qn.toString,oc=Je.call(j),ac=pt._,fc=ai("^"+Je.call(V).replace(Hr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ye=Ws?w.Buffer:i,bn=w.Symbol,Xe=w.Uint8Array,Qs=Ye?Ye.allocUnsafe:i,Qe=Zs(j.getPrototypeOf,j),Vs=j.create,js=Qn.propertyIsEnumerable,Ve=ze.splice,tu=bn?bn.isConcatSpreadable:i,_e=bn?bn.iterator:i,Fn=bn?bn.toStringTag:i,je=function(){try{var t=Mn(j,"defineProperty");return t({},"",{}),t}catch{}}(),cc=w.clearTimeout!==pt.clearTimeout&&w.clearTimeout,lc=I&&I.now!==pt.Date.now&&I.now,hc=w.setTimeout!==pt.setTimeout&&w.setTimeout,tr=ft.ceil,nr=ft.floor,fi=j.getOwnPropertySymbols,dc=Ye?Ye.isBuffer:i,nu=w.isFinite,pc=ze.join,gc=Zs(j.keys,j),ct=ft.max,vt=ft.min,_c=I.now,vc=w.parseInt,eu=ft.random,wc=ze.reverse,ci=Mn(w,"DataView"),ve=Mn(w,"Map"),li=Mn(w,"Promise"),Vn=Mn(w,"Set"),we=Mn(w,"WeakMap"),ye=Mn(j,"create"),er=we&&new we,jn={},yc=Kn(ci),mc=Kn(ve),xc=Kn(li),Sc=Kn(Vn),Ac=Kn(we),rr=bn?bn.prototype:i,me=rr?rr.valueOf:i,ru=rr?rr.toString:i;function u(t){if(st(t)&&!U(t)&&!(t instanceof z)){if(t instanceof kt)return t;if(V.call(t,"__wrapped__"))return io(t)}return new kt(t)}var te=function(){function t(){}return function(n){if(!it(n))return{};if(Vs)return Vs(n);t.prototype=n;var e=new t;return t.prototype=i,e}}();function ir(){}function kt(t,n){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=i}u.templateSettings={escape:Ua,evaluate:Na,interpolate:hs,variable:"",imports:{_:u}},u.prototype=ir.prototype,u.prototype.constructor=u,kt.prototype=te(ir.prototype),kt.prototype.constructor=kt;function z(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Bt,this.__views__=[]}function bc(){var t=new z(this.__wrapped__);return t.__actions__=Ct(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Ct(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Ct(this.__views__),t}function Cc(){if(this.__filtered__){var t=new z(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function Pc(){var t=this.__wrapped__.value(),n=this.__dir__,e=U(t),r=n<0,s=e?t.length:0,o=Bl(0,s,this.__views__),f=o.start,c=o.end,d=c-f,y=r?c:f-1,m=this.__iteratees__,S=m.length,b=0,R=vt(d,this.__takeCount__);if(!e||!r&&s==d&&R==d)return Iu(t,this.__actions__);var L=[];t:for(;d--&&b<R;){y+=n;for(var M=-1,W=t[y];++M<S;){var H=m[M],G=H.iteratee,Ft=H.type,St=G(W);if(Ft==De)W=St;else if(!St){if(Ft==Wn)continue t;break t}}L[b++]=W}return L}z.prototype=te(ir.prototype),z.prototype.constructor=z;function Un(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function Ic(){this.__data__=ye?ye(null):{},this.size=0}function Rc(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}function Ec(t){var n=this.__data__;if(ye){var e=n[t];return e===C?i:e}return V.call(n,t)?n[t]:i}function Tc(t){var n=this.__data__;return ye?n[t]!==i:V.call(n,t)}function Oc(t,n){var e=this.__data__;return this.size+=this.has(t)?0:1,e[t]=ye&&n===i?C:n,this}Un.prototype.clear=Ic,Un.prototype.delete=Rc,Un.prototype.get=Ec,Un.prototype.has=Tc,Un.prototype.set=Oc;function cn(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function Lc(){this.__data__=[],this.size=0}function Wc(t){var n=this.__data__,e=sr(n,t);if(e<0)return!1;var r=n.length-1;return e==r?n.pop():Ve.call(n,e,1),--this.size,!0}function Dc(t){var n=this.__data__,e=sr(n,t);return e<0?i:n[e][1]}function Fc(t){return sr(this.__data__,t)>-1}function Uc(t,n){var e=this.__data__,r=sr(e,t);return r<0?(++this.size,e.push([t,n])):e[r][1]=n,this}cn.prototype.clear=Lc,cn.prototype.delete=Wc,cn.prototype.get=Dc,cn.prototype.has=Fc,cn.prototype.set=Uc;function ln(t){var n=-1,e=t==null?0:t.length;for(this.clear();++n<e;){var r=t[n];this.set(r[0],r[1])}}function Nc(){this.size=0,this.__data__={hash:new Un,map:new(ve||cn),string:new Un}}function Bc(t){var n=vr(this,t).delete(t);return this.size-=n?1:0,n}function $c(t){return vr(this,t).get(t)}function Mc(t){return vr(this,t).has(t)}function Kc(t,n){var e=vr(this,t),r=e.size;return e.set(t,n),this.size+=e.size==r?0:1,this}ln.prototype.clear=Nc,ln.prototype.delete=Bc,ln.prototype.get=$c,ln.prototype.has=Mc,ln.prototype.set=Kc;function Nn(t){var n=-1,e=t==null?0:t.length;for(this.__data__=new ln;++n<e;)this.add(t[n])}function kc(t){return this.__data__.set(t,C),this}function qc(t){return this.__data__.has(t)}Nn.prototype.add=Nn.prototype.push=kc,Nn.prototype.has=qc;function Vt(t){var n=this.__data__=new cn(t);this.size=n.size}function Hc(){this.__data__=new cn,this.size=0}function zc(t){var n=this.__data__,e=n.delete(t);return this.size=n.size,e}function Gc(t){return this.__data__.get(t)}function Jc(t){return this.__data__.has(t)}function Zc(t,n){var e=this.__data__;if(e instanceof cn){var r=e.__data__;if(!ve||r.length<g-1)return r.push([t,n]),this.size=++e.size,this;e=this.__data__=new ln(r)}return e.set(t,n),this.size=e.size,this}Vt.prototype.clear=Hc,Vt.prototype.delete=zc,Vt.prototype.get=Gc,Vt.prototype.has=Jc,Vt.prototype.set=Zc;function iu(t,n){var e=U(t),r=!e&&kn(t),s=!e&&!r&&En(t),o=!e&&!r&&!s&&ie(t),f=e||r||s||o,c=f?si(t.length,ic):[],d=c.length;for(var y in t)(n||V.call(t,y))&&!(f&&(y=="length"||s&&(y=="offset"||y=="parent")||o&&(y=="buffer"||y=="byteLength"||y=="byteOffset")||gn(y,d)))&&c.push(y);return c}function su(t){var n=t.length;return n?t[Si(0,n-1)]:i}function Yc(t,n){return wr(Ct(t),Bn(n,0,t.length))}function Xc(t){return wr(Ct(t))}function hi(t,n,e){(e!==i&&!jt(t[n],e)||e===i&&!(n in t))&&hn(t,n,e)}function xe(t,n,e){var r=t[n];(!(V.call(t,n)&&jt(r,e))||e===i&&!(n in t))&&hn(t,n,e)}function sr(t,n){for(var e=t.length;e--;)if(jt(t[e][0],n))return e;return-1}function Qc(t,n,e,r){return Cn(t,function(s,o,f){n(r,s,e(s),f)}),r}function uu(t,n){return t&&sn(n,ht(n),t)}function Vc(t,n){return t&&sn(n,It(n),t)}function hn(t,n,e){n=="__proto__"&&je?je(t,n,{configurable:!0,enumerable:!0,value:e,writable:!0}):t[n]=e}function di(t,n){for(var e=-1,r=n.length,s=_(r),o=t==null;++e<r;)s[e]=o?i:Ji(t,n[e]);return s}function Bn(t,n,e){return t===t&&(e!==i&&(t=t<=e?t:e),n!==i&&(t=t>=n?t:n)),t}function qt(t,n,e,r,s,o){var f,c=n&A,d=n&D,y=n&P;if(e&&(f=s?e(t,r,s,o):e(t)),f!==i)return f;if(!it(t))return t;var m=U(t);if(m){if(f=Ml(t),!c)return Ct(t,f)}else{var S=wt(t),b=S==Ne||S==as;if(En(t))return Tu(t,c);if(S==fn||S==mn||b&&!s){if(f=d||b?{}:Yu(t),!c)return d?El(t,Vc(f,t)):Rl(t,uu(f,t))}else{if(!nt[S])return s?t:{};f=Kl(t,S,c)}}o||(o=new Vt);var R=o.get(t);if(R)return R;o.set(t,f),Co(t)?t.forEach(function(W){f.add(qt(W,n,e,W,t,o))}):Ao(t)&&t.forEach(function(W,H){f.set(H,qt(W,n,e,H,t,o))});var L=y?d?Wi:Li:d?It:ht,M=m?i:L(t);return Mt(M||t,function(W,H){M&&(H=W,W=t[H]),xe(f,H,qt(W,n,e,H,t,o))}),f}function jc(t){var n=ht(t);return function(e){return ou(e,t,n)}}function ou(t,n,e){var r=e.length;if(t==null)return!r;for(t=j(t);r--;){var s=e[r],o=n[s],f=t[s];if(f===i&&!(s in t)||!o(f))return!1}return!0}function au(t,n,e){if(typeof t!="function")throw new Kt(x);return Re(function(){t.apply(i,e)},n)}function Se(t,n,e,r){var s=-1,o=ke,f=!0,c=t.length,d=[],y=n.length;if(!c)return d;e&&(n=rt(n,Lt(e))),r?(o=jr,f=!1):n.length>=g&&(o=ge,f=!1,n=new Nn(n));t:for(;++s<c;){var m=t[s],S=e==null?m:e(m);if(m=r||m!==0?m:0,f&&S===S){for(var b=y;b--;)if(n[b]===S)continue t;d.push(m)}else o(n,S,r)||d.push(m)}return d}var Cn=Fu(rn),fu=Fu(gi,!0);function tl(t,n){var e=!0;return Cn(t,function(r,s,o){return e=!!n(r,s,o),e}),e}function ur(t,n,e){for(var r=-1,s=t.length;++r<s;){var o=t[r],f=n(o);if(f!=null&&(c===i?f===f&&!Dt(f):e(f,c)))var c=f,d=o}return d}function nl(t,n,e,r){var s=t.length;for(e=$(e),e<0&&(e=-e>s?0:s+e),r=r===i||r>s?s:$(r),r<0&&(r+=s),r=e>r?0:Io(r);e<r;)t[e++]=n;return t}function cu(t,n){var e=[];return Cn(t,function(r,s,o){n(r,s,o)&&e.push(r)}),e}function gt(t,n,e,r,s){var o=-1,f=t.length;for(e||(e=ql),s||(s=[]);++o<f;){var c=t[o];n>0&&e(c)?n>1?gt(c,n-1,e,r,s):Sn(s,c):r||(s[s.length]=c)}return s}var pi=Uu(),lu=Uu(!0);function rn(t,n){return t&&pi(t,n,ht)}function gi(t,n){return t&&lu(t,n,ht)}function or(t,n){return xn(n,function(e){return _n(t[e])})}function $n(t,n){n=In(n,t);for(var e=0,r=n.length;t!=null&&e<r;)t=t[un(n[e++])];return e&&e==r?t:i}function hu(t,n,e){var r=n(t);return U(t)?r:Sn(r,e(t))}function mt(t){return t==null?t===i?Ea:Ia:Fn&&Fn in j(t)?Nl(t):Xl(t)}function _i(t,n){return t>n}function el(t,n){return t!=null&&V.call(t,n)}function rl(t,n){return t!=null&&n in j(t)}function il(t,n,e){return t>=vt(n,e)&&t<ct(n,e)}function vi(t,n,e){for(var r=e?jr:ke,s=t[0].length,o=t.length,f=o,c=_(o),d=1/0,y=[];f--;){var m=t[f];f&&n&&(m=rt(m,Lt(n))),d=vt(m.length,d),c[f]=!e&&(n||s>=120&&m.length>=120)?new Nn(f&&m):i}m=t[0];var S=-1,b=c[0];t:for(;++S<s&&y.length<d;){var R=m[S],L=n?n(R):R;if(R=e||R!==0?R:0,!(b?ge(b,L):r(y,L,e))){for(f=o;--f;){var M=c[f];if(!(M?ge(M,L):r(t[f],L,e)))continue t}b&&b.push(L),y.push(R)}}return y}function sl(t,n,e,r){return rn(t,function(s,o,f){n(r,e(s),o,f)}),r}function Ae(t,n,e){n=In(n,t),t=ju(t,n);var r=t==null?t:t[un(zt(n))];return r==null?i:Ot(r,t,e)}function du(t){return st(t)&&mt(t)==mn}function ul(t){return st(t)&&mt(t)==pe}function ol(t){return st(t)&&mt(t)==yt}function be(t,n,e,r,s){return t===n?!0:t==null||n==null||!st(t)&&!st(n)?t!==t&&n!==n:al(t,n,e,r,be,s)}function al(t,n,e,r,s,o){var f=U(t),c=U(n),d=f?B:wt(t),y=c?B:wt(n);d=d==mn?fn:d,y=y==mn?fn:y;var m=d==fn,S=y==fn,b=d==y;if(b&&En(t)){if(!En(n))return!1;f=!0,m=!1}if(b&&!m)return o||(o=new Vt),f||ie(t)?Gu(t,n,e,r,s,o):Fl(t,n,d,e,r,s,o);if(!(e&N)){var R=m&&V.call(t,"__wrapped__"),L=S&&V.call(n,"__wrapped__");if(R||L){var M=R?t.value():t,W=L?n.value():n;return o||(o=new Vt),s(M,W,e,r,o)}}return b?(o||(o=new Vt),Ul(t,n,e,r,s,o)):!1}function fl(t){return st(t)&&wt(t)==Yt}function wi(t,n,e,r){var s=e.length,o=s,f=!r;if(t==null)return!o;for(t=j(t);s--;){var c=e[s];if(f&&c[2]?c[1]!==t[c[0]]:!(c[0]in t))return!1}for(;++s<o;){c=e[s];var d=c[0],y=t[d],m=c[1];if(f&&c[2]){if(y===i&&!(d in t))return!1}else{var S=new Vt;if(r)var b=r(y,m,d,t,n,S);if(!(b===i?be(m,y,N|tt,r,S):b))return!1}}return!0}function pu(t){if(!it(t)||zl(t))return!1;var n=_n(t)?fc:Va;return n.test(Kn(t))}function cl(t){return st(t)&&mt(t)==le}function ll(t){return st(t)&&wt(t)==Xt}function hl(t){return st(t)&&br(t.length)&&!!et[mt(t)]}function gu(t){return typeof t=="function"?t:t==null?Rt:typeof t=="object"?U(t)?wu(t[0],t[1]):vu(t):Bo(t)}function yi(t){if(!Ie(t))return gc(t);var n=[];for(var e in j(t))V.call(t,e)&&e!="constructor"&&n.push(e);return n}function dl(t){if(!it(t))return Yl(t);var n=Ie(t),e=[];for(var r in t)r=="constructor"&&(n||!V.call(t,r))||e.push(r);return e}function mi(t,n){return t<n}function _u(t,n){var e=-1,r=Pt(t)?_(t.length):[];return Cn(t,function(s,o,f){r[++e]=n(s,o,f)}),r}function vu(t){var n=Fi(t);return n.length==1&&n[0][2]?Qu(n[0][0],n[0][1]):function(e){return e===t||wi(e,t,n)}}function wu(t,n){return Ni(t)&&Xu(n)?Qu(un(t),n):function(e){var r=Ji(e,t);return r===i&&r===n?Zi(e,t):be(n,r,N|tt)}}function ar(t,n,e,r,s){t!==n&&pi(n,function(o,f){if(s||(s=new Vt),it(o))pl(t,n,f,e,ar,r,s);else{var c=r?r($i(t,f),o,f+"",t,n,s):i;c===i&&(c=o),hi(t,f,c)}},It)}function pl(t,n,e,r,s,o,f){var c=$i(t,e),d=$i(n,e),y=f.get(d);if(y){hi(t,e,y);return}var m=o?o(c,d,e+"",t,n,f):i,S=m===i;if(S){var b=U(d),R=!b&&En(d),L=!b&&!R&&ie(d);m=d,b||R||L?U(c)?m=c:ut(c)?m=Ct(c):R?(S=!1,m=Tu(d,!0)):L?(S=!1,m=Ou(d,!0)):m=[]:Ee(d)||kn(d)?(m=c,kn(c)?m=Ro(c):(!it(c)||_n(c))&&(m=Yu(d))):S=!1}S&&(f.set(d,m),s(m,d,r,o,f),f.delete(d)),hi(t,e,m)}function yu(t,n){var e=t.length;if(e)return n+=n<0?e:0,gn(n,e)?t[n]:i}function mu(t,n,e){n.length?n=rt(n,function(o){return U(o)?function(f){return $n(f,o.length===1?o[0]:o)}:o}):n=[Rt];var r=-1;n=rt(n,Lt(O()));var s=_u(t,function(o,f,c){var d=rt(n,function(y){return y(o)});return{criteria:d,index:++r,value:o}});return Kf(s,function(o,f){return Il(o,f,e)})}function gl(t,n){return xu(t,n,function(e,r){return Zi(t,r)})}function xu(t,n,e){for(var r=-1,s=n.length,o={};++r<s;){var f=n[r],c=$n(t,f);e(c,f)&&Ce(o,In(f,t),c)}return o}function _l(t){return function(n){return $n(n,t)}}function xi(t,n,e,r){var s=r?Mf:Jn,o=-1,f=n.length,c=t;for(t===n&&(n=Ct(n)),e&&(c=rt(t,Lt(e)));++o<f;)for(var d=0,y=n[o],m=e?e(y):y;(d=s(c,m,d,r))>-1;)c!==t&&Ve.call(c,d,1),Ve.call(t,d,1);return t}function Su(t,n){for(var e=t?n.length:0,r=e-1;e--;){var s=n[e];if(e==r||s!==o){var o=s;gn(s)?Ve.call(t,s,1):Ci(t,s)}}return t}function Si(t,n){return t+nr(eu()*(n-t+1))}function vl(t,n,e,r){for(var s=-1,o=ct(tr((n-t)/(e||1)),0),f=_(o);o--;)f[r?o:++s]=t,t+=e;return f}function Ai(t,n){var e="";if(!t||n<1||n>en)return e;do n%2&&(e+=t),n=nr(n/2),n&&(t+=t);while(n);return e}function k(t,n){return Mi(Vu(t,n,Rt),t+"")}function wl(t){return su(se(t))}function yl(t,n){var e=se(t);return wr(e,Bn(n,0,e.length))}function Ce(t,n,e,r){if(!it(t))return t;n=In(n,t);for(var s=-1,o=n.length,f=o-1,c=t;c!=null&&++s<o;){var d=un(n[s]),y=e;if(d==="__proto__"||d==="constructor"||d==="prototype")return t;if(s!=f){var m=c[d];y=r?r(m,d,c):i,y===i&&(y=it(m)?m:gn(n[s+1])?[]:{})}xe(c,d,y),c=c[d]}return t}var Au=er?function(t,n){return er.set(t,n),t}:Rt,ml=je?function(t,n){return je(t,"toString",{configurable:!0,enumerable:!1,value:Xi(n),writable:!0})}:Rt;function xl(t){return wr(se(t))}function Ht(t,n,e){var r=-1,s=t.length;n<0&&(n=-n>s?0:s+n),e=e>s?s:e,e<0&&(e+=s),s=n>e?0:e-n>>>0,n>>>=0;for(var o=_(s);++r<s;)o[r]=t[r+n];return o}function Sl(t,n){var e;return Cn(t,function(r,s,o){return e=n(r,s,o),!e}),!!e}function fr(t,n,e){var r=0,s=t==null?r:t.length;if(typeof n=="number"&&n===n&&s<=Fe){for(;r<s;){var o=r+s>>>1,f=t[o];f!==null&&!Dt(f)&&(e?f<=n:f<n)?r=o+1:s=o}return s}return bi(t,n,Rt,e)}function bi(t,n,e,r){var s=0,o=t==null?0:t.length;if(o===0)return 0;n=e(n);for(var f=n!==n,c=n===null,d=Dt(n),y=n===i;s<o;){var m=nr((s+o)/2),S=e(t[m]),b=S!==i,R=S===null,L=S===S,M=Dt(S);if(f)var W=r||L;else y?W=L&&(r||b):c?W=L&&b&&(r||!R):d?W=L&&b&&!R&&(r||!M):R||M?W=!1:W=r?S<=n:S<n;W?s=m+1:o=m}return vt(o,Wr)}function bu(t,n){for(var e=-1,r=t.length,s=0,o=[];++e<r;){var f=t[e],c=n?n(f):f;if(!e||!jt(c,d)){var d=c;o[s++]=f===0?0:f}}return o}function Cu(t){return typeof t=="number"?t:Dt(t)?Hn:+t}function Wt(t){if(typeof t=="string")return t;if(U(t))return rt(t,Wt)+"";if(Dt(t))return ru?ru.call(t):"";var n=t+"";return n=="0"&&1/t==-an?"-0":n}function Pn(t,n,e){var r=-1,s=ke,o=t.length,f=!0,c=[],d=c;if(e)f=!1,s=jr;else if(o>=g){var y=n?null:Wl(t);if(y)return He(y);f=!1,s=ge,d=new Nn}else d=n?[]:c;t:for(;++r<o;){var m=t[r],S=n?n(m):m;if(m=e||m!==0?m:0,f&&S===S){for(var b=d.length;b--;)if(d[b]===S)continue t;n&&d.push(S),c.push(m)}else s(d,S,e)||(d!==c&&d.push(S),c.push(m))}return c}function Ci(t,n){return n=In(n,t),t=ju(t,n),t==null||delete t[un(zt(n))]}function Pu(t,n,e,r){return Ce(t,n,e($n(t,n)),r)}function cr(t,n,e,r){for(var s=t.length,o=r?s:-1;(r?o--:++o<s)&&n(t[o],o,t););return e?Ht(t,r?0:o,r?o+1:s):Ht(t,r?o+1:0,r?s:o)}function Iu(t,n){var e=t;return e instanceof z&&(e=e.value()),ti(n,function(r,s){return s.func.apply(s.thisArg,Sn([r],s.args))},e)}function Pi(t,n,e){var r=t.length;if(r<2)return r?Pn(t[0]):[];for(var s=-1,o=_(r);++s<r;)for(var f=t[s],c=-1;++c<r;)c!=s&&(o[s]=Se(o[s]||f,t[c],n,e));return Pn(gt(o,1),n,e)}function Ru(t,n,e){for(var r=-1,s=t.length,o=n.length,f={};++r<s;){var c=r<o?n[r]:i;e(f,t[r],c)}return f}function Ii(t){return ut(t)?t:[]}function Ri(t){return typeof t=="function"?t:Rt}function In(t,n){return U(t)?t:Ni(t,n)?[t]:ro(Q(t))}var Al=k;function Rn(t,n,e){var r=t.length;return e=e===i?r:e,!n&&e>=r?t:Ht(t,n,e)}var Eu=cc||function(t){return pt.clearTimeout(t)};function Tu(t,n){if(n)return t.slice();var e=t.length,r=Qs?Qs(e):new t.constructor(e);return t.copy(r),r}function Ei(t){var n=new t.constructor(t.byteLength);return new Xe(n).set(new Xe(t)),n}function bl(t,n){var e=n?Ei(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.byteLength)}function Cl(t){var n=new t.constructor(t.source,ds.exec(t));return n.lastIndex=t.lastIndex,n}function Pl(t){return me?j(me.call(t)):{}}function Ou(t,n){var e=n?Ei(t.buffer):t.buffer;return new t.constructor(e,t.byteOffset,t.length)}function Lu(t,n){if(t!==n){var e=t!==i,r=t===null,s=t===t,o=Dt(t),f=n!==i,c=n===null,d=n===n,y=Dt(n);if(!c&&!y&&!o&&t>n||o&&f&&d&&!c&&!y||r&&f&&d||!e&&d||!s)return 1;if(!r&&!o&&!y&&t<n||y&&e&&s&&!r&&!o||c&&e&&s||!f&&s||!d)return-1}return 0}function Il(t,n,e){for(var r=-1,s=t.criteria,o=n.criteria,f=s.length,c=e.length;++r<f;){var d=Lu(s[r],o[r]);if(d){if(r>=c)return d;var y=e[r];return d*(y=="desc"?-1:1)}}return t.index-n.index}function Wu(t,n,e,r){for(var s=-1,o=t.length,f=e.length,c=-1,d=n.length,y=ct(o-f,0),m=_(d+y),S=!r;++c<d;)m[c]=n[c];for(;++s<f;)(S||s<o)&&(m[e[s]]=t[s]);for(;y--;)m[c++]=t[s++];return m}function Du(t,n,e,r){for(var s=-1,o=t.length,f=-1,c=e.length,d=-1,y=n.length,m=ct(o-c,0),S=_(m+y),b=!r;++s<m;)S[s]=t[s];for(var R=s;++d<y;)S[R+d]=n[d];for(;++f<c;)(b||s<o)&&(S[R+e[f]]=t[s++]);return S}function Ct(t,n){var e=-1,r=t.length;for(n||(n=_(r));++e<r;)n[e]=t[e];return n}function sn(t,n,e,r){var s=!e;e||(e={});for(var o=-1,f=n.length;++o<f;){var c=n[o],d=r?r(e[c],t[c],c,e,t):i;d===i&&(d=t[c]),s?hn(e,c,d):xe(e,c,d)}return e}function Rl(t,n){return sn(t,Ui(t),n)}function El(t,n){return sn(t,Ju(t),n)}function lr(t,n){return function(e,r){var s=U(e)?Df:Qc,o=n?n():{};return s(e,t,O(r,2),o)}}function ne(t){return k(function(n,e){var r=-1,s=e.length,o=s>1?e[s-1]:i,f=s>2?e[2]:i;for(o=t.length>3&&typeof o=="function"?(s--,o):i,f&&xt(e[0],e[1],f)&&(o=s<3?i:o,s=1),n=j(n);++r<s;){var c=e[r];c&&t(n,c,r,o)}return n})}function Fu(t,n){return function(e,r){if(e==null)return e;if(!Pt(e))return t(e,r);for(var s=e.length,o=n?s:-1,f=j(e);(n?o--:++o<s)&&r(f[o],o,f)!==!1;);return e}}function Uu(t){return function(n,e,r){for(var s=-1,o=j(n),f=r(n),c=f.length;c--;){var d=f[t?c:++s];if(e(o[d],d,o)===!1)break}return n}}function Tl(t,n,e){var r=n&q,s=Pe(t);function o(){var f=this&&this!==pt&&this instanceof o?s:t;return f.apply(r?e:this,arguments)}return o}function Nu(t){return function(n){n=Q(n);var e=Zn(n)?Qt(n):i,r=e?e[0]:n.charAt(0),s=e?Rn(e,1).join(""):n.slice(1);return r[t]()+s}}function ee(t){return function(n){return ti(Uo(Fo(n).replace(mf,"")),t,"")}}function Pe(t){return function(){var n=arguments;switch(n.length){case 0:return new t;case 1:return new t(n[0]);case 2:return new t(n[0],n[1]);case 3:return new t(n[0],n[1],n[2]);case 4:return new t(n[0],n[1],n[2],n[3]);case 5:return new t(n[0],n[1],n[2],n[3],n[4]);case 6:return new t(n[0],n[1],n[2],n[3],n[4],n[5]);case 7:return new t(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}var e=te(t.prototype),r=t.apply(e,n);return it(r)?r:e}}function Ol(t,n,e){var r=Pe(t);function s(){for(var o=arguments.length,f=_(o),c=o,d=re(s);c--;)f[c]=arguments[c];var y=o<3&&f[0]!==d&&f[o-1]!==d?[]:An(f,d);if(o-=y.length,o<e)return ku(t,n,hr,s.placeholder,i,f,y,i,i,e-o);var m=this&&this!==pt&&this instanceof s?r:t;return Ot(m,this,f)}return s}function Bu(t){return function(n,e,r){var s=j(n);if(!Pt(n)){var o=O(e,3);n=ht(n),e=function(c){return o(s[c],c,s)}}var f=t(n,e,r);return f>-1?s[o?n[f]:f]:i}}function $u(t){return pn(function(n){var e=n.length,r=e,s=kt.prototype.thru;for(t&&n.reverse();r--;){var o=n[r];if(typeof o!="function")throw new Kt(x);if(s&&!f&&_r(o)=="wrapper")var f=new kt([],!0)}for(r=f?r:e;++r<e;){o=n[r];var c=_r(o),d=c=="wrapper"?Di(o):i;d&&Bi(d[0])&&d[1]==(Nt|dt|Zt|nn)&&!d[4].length&&d[9]==1?f=f[_r(d[0])].apply(f,d[3]):f=o.length==1&&Bi(o)?f[c]():f.thru(o)}return function(){var y=arguments,m=y[0];if(f&&y.length==1&&U(m))return f.plant(m).value();for(var S=0,b=e?n[S].apply(this,y):m;++S<e;)b=n[S].call(this,b);return b}})}function hr(t,n,e,r,s,o,f,c,d,y){var m=n&Nt,S=n&q,b=n&yn,R=n&(dt|_t),L=n&Et,M=b?i:Pe(t);function W(){for(var H=arguments.length,G=_(H),Ft=H;Ft--;)G[Ft]=arguments[Ft];if(R)var St=re(W),Ut=qf(G,St);if(r&&(G=Wu(G,r,s,R)),o&&(G=Du(G,o,f,R)),H-=Ut,R&&H<y){var ot=An(G,St);return ku(t,n,hr,W.placeholder,e,G,ot,c,d,y-H)}var tn=S?e:this,wn=b?tn[t]:t;return H=G.length,c?G=Ql(G,c):L&&H>1&&G.reverse(),m&&d<H&&(G.length=d),this&&this!==pt&&this instanceof W&&(wn=M||Pe(wn)),wn.apply(tn,G)}return W}function Mu(t,n){return function(e,r){return sl(e,t,n(r),{})}}function dr(t,n){return function(e,r){var s;if(e===i&&r===i)return n;if(e!==i&&(s=e),r!==i){if(s===i)return r;typeof e=="string"||typeof r=="string"?(e=Wt(e),r=Wt(r)):(e=Cu(e),r=Cu(r)),s=t(e,r)}return s}}function Ti(t){return pn(function(n){return n=rt(n,Lt(O())),k(function(e){var r=this;return t(n,function(s){return Ot(s,r,e)})})})}function pr(t,n){n=n===i?" ":Wt(n);var e=n.length;if(e<2)return e?Ai(n,t):n;var r=Ai(n,tr(t/Yn(n)));return Zn(n)?Rn(Qt(r),0,t).join(""):r.slice(0,t)}function Ll(t,n,e,r){var s=n&q,o=Pe(t);function f(){for(var c=-1,d=arguments.length,y=-1,m=r.length,S=_(m+d),b=this&&this!==pt&&this instanceof f?o:t;++y<m;)S[y]=r[y];for(;d--;)S[y++]=arguments[++c];return Ot(b,s?e:this,S)}return f}function Ku(t){return function(n,e,r){return r&&typeof r!="number"&&xt(n,e,r)&&(e=r=i),n=vn(n),e===i?(e=n,n=0):e=vn(e),r=r===i?n<e?1:-1:vn(r),vl(n,e,r,t)}}function gr(t){return function(n,e){return typeof n=="string"&&typeof e=="string"||(n=Gt(n),e=Gt(e)),t(n,e)}}function ku(t,n,e,r,s,o,f,c,d,y){var m=n&dt,S=m?f:i,b=m?i:f,R=m?o:i,L=m?i:o;n|=m?Zt:Ln,n&=~(m?Ln:Zt),n&on||(n&=-4);var M=[t,n,s,R,S,L,b,c,d,y],W=e.apply(i,M);return Bi(t)&&to(W,M),W.placeholder=r,no(W,t,n)}function Oi(t){var n=ft[t];return function(e,r){if(e=Gt(e),r=r==null?0:vt($(r),292),r&&nu(e)){var s=(Q(e)+"e").split("e"),o=n(s[0]+"e"+(+s[1]+r));return s=(Q(o)+"e").split("e"),+(s[0]+"e"+(+s[1]-r))}return n(e)}}var Wl=Vn&&1/He(new Vn([,-0]))[1]==an?function(t){return new Vn(t)}:ji;function qu(t){return function(n){var e=wt(n);return e==Yt?oi(n):e==Xt?Xf(n):kf(n,t(n))}}function dn(t,n,e,r,s,o,f,c){var d=n&yn;if(!d&&typeof t!="function")throw new Kt(x);var y=r?r.length:0;if(y||(n&=-97,r=s=i),f=f===i?f:ct($(f),0),c=c===i?c:$(c),y-=s?s.length:0,n&Ln){var m=r,S=s;r=s=i}var b=d?i:Di(t),R=[t,n,e,r,s,m,S,o,f,c];if(b&&Zl(R,b),t=R[0],n=R[1],e=R[2],r=R[3],s=R[4],c=R[9]=R[9]===i?d?0:t.length:ct(R[9]-y,0),!c&&n&(dt|_t)&&(n&=-25),!n||n==q)var L=Tl(t,n,e);else n==dt||n==_t?L=Ol(t,n,c):(n==Zt||n==(q|Zt))&&!s.length?L=Ll(t,n,e,r):L=hr.apply(i,R);var M=b?Au:to;return no(M(L,R),t,n)}function Hu(t,n,e,r){return t===i||jt(t,Qn[e])&&!V.call(r,e)?n:t}function zu(t,n,e,r,s,o){return it(t)&&it(n)&&(o.set(n,t),ar(t,n,i,zu,o),o.delete(n)),t}function Dl(t){return Ee(t)?i:t}function Gu(t,n,e,r,s,o){var f=e&N,c=t.length,d=n.length;if(c!=d&&!(f&&d>c))return!1;var y=o.get(t),m=o.get(n);if(y&&m)return y==n&&m==t;var S=-1,b=!0,R=e&tt?new Nn:i;for(o.set(t,n),o.set(n,t);++S<c;){var L=t[S],M=n[S];if(r)var W=f?r(M,L,S,n,t,o):r(L,M,S,t,n,o);if(W!==i){if(W)continue;b=!1;break}if(R){if(!ni(n,function(H,G){if(!ge(R,G)&&(L===H||s(L,H,e,r,o)))return R.push(G)})){b=!1;break}}else if(!(L===M||s(L,M,e,r,o))){b=!1;break}}return o.delete(t),o.delete(n),b}function Fl(t,n,e,r,s,o,f){switch(e){case zn:if(t.byteLength!=n.byteLength||t.byteOffset!=n.byteOffset)return!1;t=t.buffer,n=n.buffer;case pe:return!(t.byteLength!=n.byteLength||!o(new Xe(t),new Xe(n)));case At:case yt:case ce:return jt(+t,+n);case bt:return t.name==n.name&&t.message==n.message;case le:case he:return t==n+"";case Yt:var c=oi;case Xt:var d=r&N;if(c||(c=He),t.size!=n.size&&!d)return!1;var y=f.get(t);if(y)return y==n;r|=tt,f.set(t,n);var m=Gu(c(t),c(n),r,s,o,f);return f.delete(t),m;case Be:if(me)return me.call(t)==me.call(n)}return!1}function Ul(t,n,e,r,s,o){var f=e&N,c=Li(t),d=c.length,y=Li(n),m=y.length;if(d!=m&&!f)return!1;for(var S=d;S--;){var b=c[S];if(!(f?b in n:V.call(n,b)))return!1}var R=o.get(t),L=o.get(n);if(R&&L)return R==n&&L==t;var M=!0;o.set(t,n),o.set(n,t);for(var W=f;++S<d;){b=c[S];var H=t[b],G=n[b];if(r)var Ft=f?r(G,H,b,n,t,o):r(H,G,b,t,n,o);if(!(Ft===i?H===G||s(H,G,e,r,o):Ft)){M=!1;break}W||(W=b=="constructor")}if(M&&!W){var St=t.constructor,Ut=n.constructor;St!=Ut&&"constructor"in t&&"constructor"in n&&!(typeof St=="function"&&St instanceof St&&typeof Ut=="function"&&Ut instanceof Ut)&&(M=!1)}return o.delete(t),o.delete(n),M}function pn(t){return Mi(Vu(t,i,oo),t+"")}function Li(t){return hu(t,ht,Ui)}function Wi(t){return hu(t,It,Ju)}var Di=er?function(t){return er.get(t)}:ji;function _r(t){for(var n=t.name+"",e=jn[n],r=V.call(jn,n)?e.length:0;r--;){var s=e[r],o=s.func;if(o==null||o==t)return s.name}return n}function re(t){var n=V.call(u,"placeholder")?u:t;return n.placeholder}function O(){var t=u.iteratee||Qi;return t=t===Qi?gu:t,arguments.length?t(arguments[0],arguments[1]):t}function vr(t,n){var e=t.__data__;return Hl(n)?e[typeof n=="string"?"string":"hash"]:e.map}function Fi(t){for(var n=ht(t),e=n.length;e--;){var r=n[e],s=t[r];n[e]=[r,s,Xu(s)]}return n}function Mn(t,n){var e=Jf(t,n);return pu(e)?e:i}function Nl(t){var n=V.call(t,Fn),e=t[Fn];try{t[Fn]=i;var r=!0}catch{}var s=Ze.call(t);return r&&(n?t[Fn]=e:delete t[Fn]),s}var Ui=fi?function(t){return t==null?[]:(t=j(t),xn(fi(t),function(n){return js.call(t,n)}))}:ts,Ju=fi?function(t){for(var n=[];t;)Sn(n,Ui(t)),t=Qe(t);return n}:ts,wt=mt;(ci&&wt(new ci(new ArrayBuffer(1)))!=zn||ve&&wt(new ve)!=Yt||li&&wt(li.resolve())!=fs||Vn&&wt(new Vn)!=Xt||we&&wt(new we)!=de)&&(wt=function(t){var n=mt(t),e=n==fn?t.constructor:i,r=e?Kn(e):"";if(r)switch(r){case yc:return zn;case mc:return Yt;case xc:return fs;case Sc:return Xt;case Ac:return de}return n});function Bl(t,n,e){for(var r=-1,s=e.length;++r<s;){var o=e[r],f=o.size;switch(o.type){case"drop":t+=f;break;case"dropRight":n-=f;break;case"take":n=vt(n,t+f);break;case"takeRight":t=ct(t,n-f);break}}return{start:t,end:n}}function $l(t){var n=t.match(Ha);return n?n[1].split(za):[]}function Zu(t,n,e){n=In(n,t);for(var r=-1,s=n.length,o=!1;++r<s;){var f=un(n[r]);if(!(o=t!=null&&e(t,f)))break;t=t[f]}return o||++r!=s?o:(s=t==null?0:t.length,!!s&&br(s)&&gn(f,s)&&(U(t)||kn(t)))}function Ml(t){var n=t.length,e=new t.constructor(n);return n&&typeof t[0]=="string"&&V.call(t,"index")&&(e.index=t.index,e.input=t.input),e}function Yu(t){return typeof t.constructor=="function"&&!Ie(t)?te(Qe(t)):{}}function Kl(t,n,e){var r=t.constructor;switch(n){case pe:return Ei(t);case At:case yt:return new r(+t);case zn:return bl(t,e);case Fr:case Ur:case Nr:case Br:case $r:case Mr:case Kr:case kr:case qr:return Ou(t,e);case Yt:return new r;case ce:case he:return new r(t);case le:return Cl(t);case Xt:return new r;case Be:return Pl(t)}}function kl(t,n){var e=n.length;if(!e)return t;var r=e-1;return n[r]=(e>1?"& ":"")+n[r],n=n.join(e>2?", ":" "),t.replace(qa,`{
|
|
9
|
-
/* [wrapped with `+
|
|
10
|
-
`)}function ql(t){return U(t)||kn(t)||!!(tu&&t&&t[tu])}function gn(t,n){var e=typeof t;return n=n??en,!!n&&(e=="number"||e!="symbol"&&tf.test(t))&&t>-1&&t%1==0&&t<n}function xt(t,n,e){if(!it(e))return!1;var r=typeof n;return(r=="number"?Pt(e)&&gn(n,e.length):r=="string"&&n in e)?jt(e[n],t):!1}function Ni(t,n){if(U(t))return!1;var e=typeof t;return e=="number"||e=="symbol"||e=="boolean"||t==null||Dt(t)?!0:$a.test(t)||!Ba.test(t)||n!=null&&t in j(n)}function Hl(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}function Bi(t){var n=_r(t),e=u[n];if(typeof e!="function"||!(n in z.prototype))return!1;if(t===e)return!0;var r=Di(e);return!!r&&t===r[0]}function zl(t){return!!Xs&&Xs in t}var Gl=Ge?_n:ns;function Ie(t){var n=t&&t.constructor,e=typeof n=="function"&&n.prototype||Qn;return t===e}function Xu(t){return t===t&&!it(t)}function Qu(t,n){return function(e){return e==null?!1:e[t]===n&&(n!==i||t in j(e))}}function Jl(t){var n=Sr(t,function(r){return e.size===K&&e.clear(),r}),e=n.cache;return n}function Zl(t,n){var e=t[1],r=n[1],s=e|r,o=s<(q|yn|Nt),f=r==Nt&&e==dt||r==Nt&&e==nn&&t[7].length<=n[8]||r==(Nt|nn)&&n[7].length<=n[8]&&e==dt;if(!(o||f))return t;r&q&&(t[2]=n[2],s|=e&q?0:on);var c=n[3];if(c){var d=t[3];t[3]=d?Wu(d,c,n[4]):c,t[4]=d?An(t[3],X):n[4]}return c=n[5],c&&(d=t[5],t[5]=d?Du(d,c,n[6]):c,t[6]=d?An(t[5],X):n[6]),c=n[7],c&&(t[7]=c),r&Nt&&(t[8]=t[8]==null?n[8]:vt(t[8],n[8])),t[9]==null&&(t[9]=n[9]),t[0]=n[0],t[1]=s,t}function Yl(t){var n=[];if(t!=null)for(var e in j(t))n.push(e);return n}function Xl(t){return Ze.call(t)}function Vu(t,n,e){return n=ct(n===i?t.length-1:n,0),function(){for(var r=arguments,s=-1,o=ct(r.length-n,0),f=_(o);++s<o;)f[s]=r[n+s];s=-1;for(var c=_(n+1);++s<n;)c[s]=r[s];return c[n]=e(f),Ot(t,this,c)}}function ju(t,n){return n.length<2?t:$n(t,Ht(n,0,-1))}function Ql(t,n){for(var e=t.length,r=vt(n.length,e),s=Ct(t);r--;){var o=n[r];t[r]=gn(o,e)?s[o]:i}return t}function $i(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}var to=eo(Au),Re=hc||function(t,n){return pt.setTimeout(t,n)},Mi=eo(ml);function no(t,n,e){var r=n+"";return Mi(t,kl(r,Vl($l(r),e)))}function eo(t){var n=0,e=0;return function(){var r=_c(),s=We-(r-e);if(e=r,s>0){if(++n>=Tt)return arguments[0]}else n=0;return t.apply(i,arguments)}}function wr(t,n){var e=-1,r=t.length,s=r-1;for(n=n===i?r:n;++e<n;){var o=Si(e,s),f=t[o];t[o]=t[e],t[e]=f}return t.length=n,t}var ro=Jl(function(t){var n=[];return t.charCodeAt(0)===46&&n.push(""),t.replace(Ma,function(e,r,s,o){n.push(s?o.replace(Za,"$1"):r||e)}),n});function un(t){if(typeof t=="string"||Dt(t))return t;var n=t+"";return n=="0"&&1/t==-an?"-0":n}function Kn(t){if(t!=null){try{return Je.call(t)}catch{}try{return t+""}catch{}}return""}function Vl(t,n){return Mt(Dr,function(e){var r="_."+e[0];n&e[1]&&!ke(t,r)&&t.push(r)}),t.sort()}function io(t){if(t instanceof z)return t.clone();var n=new kt(t.__wrapped__,t.__chain__);return n.__actions__=Ct(t.__actions__),n.__index__=t.__index__,n.__values__=t.__values__,n}function jl(t,n,e){(e?xt(t,n,e):n===i)?n=1:n=ct($(n),0);var r=t==null?0:t.length;if(!r||n<1)return[];for(var s=0,o=0,f=_(tr(r/n));s<r;)f[o++]=Ht(t,s,s+=n);return f}function th(t){for(var n=-1,e=t==null?0:t.length,r=0,s=[];++n<e;){var o=t[n];o&&(s[r++]=o)}return s}function nh(){var t=arguments.length;if(!t)return[];for(var n=_(t-1),e=arguments[0],r=t;r--;)n[r-1]=arguments[r];return Sn(U(e)?Ct(e):[e],gt(n,1))}var eh=k(function(t,n){return ut(t)?Se(t,gt(n,1,ut,!0)):[]}),rh=k(function(t,n){var e=zt(n);return ut(e)&&(e=i),ut(t)?Se(t,gt(n,1,ut,!0),O(e,2)):[]}),ih=k(function(t,n){var e=zt(n);return ut(e)&&(e=i),ut(t)?Se(t,gt(n,1,ut,!0),i,e):[]});function sh(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:$(n),Ht(t,n<0?0:n,r)):[]}function uh(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:$(n),n=r-n,Ht(t,0,n<0?0:n)):[]}function oh(t,n){return t&&t.length?cr(t,O(n,3),!0,!0):[]}function ah(t,n){return t&&t.length?cr(t,O(n,3),!0):[]}function fh(t,n,e,r){var s=t==null?0:t.length;return s?(e&&typeof e!="number"&&xt(t,n,e)&&(e=0,r=s),nl(t,n,e,r)):[]}function so(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var s=e==null?0:$(e);return s<0&&(s=ct(r+s,0)),qe(t,O(n,3),s)}function uo(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var s=r-1;return e!==i&&(s=$(e),s=e<0?ct(r+s,0):vt(s,r-1)),qe(t,O(n,3),s,!0)}function oo(t){var n=t==null?0:t.length;return n?gt(t,1):[]}function ch(t){var n=t==null?0:t.length;return n?gt(t,an):[]}function lh(t,n){var e=t==null?0:t.length;return e?(n=n===i?1:$(n),gt(t,n)):[]}function hh(t){for(var n=-1,e=t==null?0:t.length,r={};++n<e;){var s=t[n];r[s[0]]=s[1]}return r}function ao(t){return t&&t.length?t[0]:i}function dh(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var s=e==null?0:$(e);return s<0&&(s=ct(r+s,0)),Jn(t,n,s)}function ph(t){var n=t==null?0:t.length;return n?Ht(t,0,-1):[]}var gh=k(function(t){var n=rt(t,Ii);return n.length&&n[0]===t[0]?vi(n):[]}),_h=k(function(t){var n=zt(t),e=rt(t,Ii);return n===zt(e)?n=i:e.pop(),e.length&&e[0]===t[0]?vi(e,O(n,2)):[]}),vh=k(function(t){var n=zt(t),e=rt(t,Ii);return n=typeof n=="function"?n:i,n&&e.pop(),e.length&&e[0]===t[0]?vi(e,i,n):[]});function wh(t,n){return t==null?"":pc.call(t,n)}function zt(t){var n=t==null?0:t.length;return n?t[n-1]:i}function yh(t,n,e){var r=t==null?0:t.length;if(!r)return-1;var s=r;return e!==i&&(s=$(e),s=s<0?ct(r+s,0):vt(s,r-1)),n===n?Vf(t,n,s):qe(t,ks,s,!0)}function mh(t,n){return t&&t.length?yu(t,$(n)):i}var xh=k(fo);function fo(t,n){return t&&t.length&&n&&n.length?xi(t,n):t}function Sh(t,n,e){return t&&t.length&&n&&n.length?xi(t,n,O(e,2)):t}function Ah(t,n,e){return t&&t.length&&n&&n.length?xi(t,n,i,e):t}var bh=pn(function(t,n){var e=t==null?0:t.length,r=di(t,n);return Su(t,rt(n,function(s){return gn(s,e)?+s:s}).sort(Lu)),r});function Ch(t,n){var e=[];if(!(t&&t.length))return e;var r=-1,s=[],o=t.length;for(n=O(n,3);++r<o;){var f=t[r];n(f,r,t)&&(e.push(f),s.push(r))}return Su(t,s),e}function Ki(t){return t==null?t:wc.call(t)}function Ph(t,n,e){var r=t==null?0:t.length;return r?(e&&typeof e!="number"&&xt(t,n,e)?(n=0,e=r):(n=n==null?0:$(n),e=e===i?r:$(e)),Ht(t,n,e)):[]}function Ih(t,n){return fr(t,n)}function Rh(t,n,e){return bi(t,n,O(e,2))}function Eh(t,n){var e=t==null?0:t.length;if(e){var r=fr(t,n);if(r<e&&jt(t[r],n))return r}return-1}function Th(t,n){return fr(t,n,!0)}function Oh(t,n,e){return bi(t,n,O(e,2),!0)}function Lh(t,n){var e=t==null?0:t.length;if(e){var r=fr(t,n,!0)-1;if(jt(t[r],n))return r}return-1}function Wh(t){return t&&t.length?bu(t):[]}function Dh(t,n){return t&&t.length?bu(t,O(n,2)):[]}function Fh(t){var n=t==null?0:t.length;return n?Ht(t,1,n):[]}function Uh(t,n,e){return t&&t.length?(n=e||n===i?1:$(n),Ht(t,0,n<0?0:n)):[]}function Nh(t,n,e){var r=t==null?0:t.length;return r?(n=e||n===i?1:$(n),n=r-n,Ht(t,n<0?0:n,r)):[]}function Bh(t,n){return t&&t.length?cr(t,O(n,3),!1,!0):[]}function $h(t,n){return t&&t.length?cr(t,O(n,3)):[]}var Mh=k(function(t){return Pn(gt(t,1,ut,!0))}),Kh=k(function(t){var n=zt(t);return ut(n)&&(n=i),Pn(gt(t,1,ut,!0),O(n,2))}),kh=k(function(t){var n=zt(t);return n=typeof n=="function"?n:i,Pn(gt(t,1,ut,!0),i,n)});function qh(t){return t&&t.length?Pn(t):[]}function Hh(t,n){return t&&t.length?Pn(t,O(n,2)):[]}function zh(t,n){return n=typeof n=="function"?n:i,t&&t.length?Pn(t,i,n):[]}function ki(t){if(!(t&&t.length))return[];var n=0;return t=xn(t,function(e){if(ut(e))return n=ct(e.length,n),!0}),si(n,function(e){return rt(t,ei(e))})}function co(t,n){if(!(t&&t.length))return[];var e=ki(t);return n==null?e:rt(e,function(r){return Ot(n,i,r)})}var Gh=k(function(t,n){return ut(t)?Se(t,n):[]}),Jh=k(function(t){return Pi(xn(t,ut))}),Zh=k(function(t){var n=zt(t);return ut(n)&&(n=i),Pi(xn(t,ut),O(n,2))}),Yh=k(function(t){var n=zt(t);return n=typeof n=="function"?n:i,Pi(xn(t,ut),i,n)}),Xh=k(ki);function Qh(t,n){return Ru(t||[],n||[],xe)}function Vh(t,n){return Ru(t||[],n||[],Ce)}var jh=k(function(t){var n=t.length,e=n>1?t[n-1]:i;return e=typeof e=="function"?(t.pop(),e):i,co(t,e)});function lo(t){var n=u(t);return n.__chain__=!0,n}function td(t,n){return n(t),t}function yr(t,n){return n(t)}var nd=pn(function(t){var n=t.length,e=n?t[0]:0,r=this.__wrapped__,s=function(o){return di(o,t)};return n>1||this.__actions__.length||!(r instanceof z)||!gn(e)?this.thru(s):(r=r.slice(e,+e+(n?1:0)),r.__actions__.push({func:yr,args:[s],thisArg:i}),new kt(r,this.__chain__).thru(function(o){return n&&!o.length&&o.push(i),o}))});function ed(){return lo(this)}function rd(){return new kt(this.value(),this.__chain__)}function id(){this.__values__===i&&(this.__values__=Po(this.value()));var t=this.__index__>=this.__values__.length,n=t?i:this.__values__[this.__index__++];return{done:t,value:n}}function sd(){return this}function ud(t){for(var n,e=this;e instanceof ir;){var r=io(e);r.__index__=0,r.__values__=i,n?s.__wrapped__=r:n=r;var s=r;e=e.__wrapped__}return s.__wrapped__=t,n}function od(){var t=this.__wrapped__;if(t instanceof z){var n=t;return this.__actions__.length&&(n=new z(this)),n=n.reverse(),n.__actions__.push({func:yr,args:[Ki],thisArg:i}),new kt(n,this.__chain__)}return this.thru(Ki)}function ad(){return Iu(this.__wrapped__,this.__actions__)}var fd=lr(function(t,n,e){V.call(t,e)?++t[e]:hn(t,e,1)});function cd(t,n,e){var r=U(t)?Ms:tl;return e&&xt(t,n,e)&&(n=i),r(t,O(n,3))}function ld(t,n){var e=U(t)?xn:cu;return e(t,O(n,3))}var hd=Bu(so),dd=Bu(uo);function pd(t,n){return gt(mr(t,n),1)}function gd(t,n){return gt(mr(t,n),an)}function _d(t,n,e){return e=e===i?1:$(e),gt(mr(t,n),e)}function ho(t,n){var e=U(t)?Mt:Cn;return e(t,O(n,3))}function po(t,n){var e=U(t)?Ff:fu;return e(t,O(n,3))}var vd=lr(function(t,n,e){V.call(t,e)?t[e].push(n):hn(t,e,[n])});function wd(t,n,e,r){t=Pt(t)?t:se(t),e=e&&!r?$(e):0;var s=t.length;return e<0&&(e=ct(s+e,0)),Cr(t)?e<=s&&t.indexOf(n,e)>-1:!!s&&Jn(t,n,e)>-1}var yd=k(function(t,n,e){var r=-1,s=typeof n=="function",o=Pt(t)?_(t.length):[];return Cn(t,function(f){o[++r]=s?Ot(n,f,e):Ae(f,n,e)}),o}),md=lr(function(t,n,e){hn(t,e,n)});function mr(t,n){var e=U(t)?rt:_u;return e(t,O(n,3))}function xd(t,n,e,r){return t==null?[]:(U(n)||(n=n==null?[]:[n]),e=r?i:e,U(e)||(e=e==null?[]:[e]),mu(t,n,e))}var Sd=lr(function(t,n,e){t[e?0:1].push(n)},function(){return[[],[]]});function Ad(t,n,e){var r=U(t)?ti:Hs,s=arguments.length<3;return r(t,O(n,4),e,s,Cn)}function bd(t,n,e){var r=U(t)?Uf:Hs,s=arguments.length<3;return r(t,O(n,4),e,s,fu)}function Cd(t,n){var e=U(t)?xn:cu;return e(t,Ar(O(n,3)))}function Pd(t){var n=U(t)?su:wl;return n(t)}function Id(t,n,e){(e?xt(t,n,e):n===i)?n=1:n=$(n);var r=U(t)?Yc:yl;return r(t,n)}function Rd(t){var n=U(t)?Xc:xl;return n(t)}function Ed(t){if(t==null)return 0;if(Pt(t))return Cr(t)?Yn(t):t.length;var n=wt(t);return n==Yt||n==Xt?t.size:yi(t).length}function Td(t,n,e){var r=U(t)?ni:Sl;return e&&xt(t,n,e)&&(n=i),r(t,O(n,3))}var Od=k(function(t,n){if(t==null)return[];var e=n.length;return e>1&&xt(t,n[0],n[1])?n=[]:e>2&&xt(n[0],n[1],n[2])&&(n=[n[0]]),mu(t,gt(n,1),[])}),xr=lc||function(){return pt.Date.now()};function Ld(t,n){if(typeof n!="function")throw new Kt(x);return t=$(t),function(){if(--t<1)return n.apply(this,arguments)}}function go(t,n,e){return n=e?i:n,n=t&&n==null?t.length:n,dn(t,Nt,i,i,i,i,n)}function _o(t,n){var e;if(typeof n!="function")throw new Kt(x);return t=$(t),function(){return--t>0&&(e=n.apply(this,arguments)),t<=1&&(n=i),e}}var qi=k(function(t,n,e){var r=q;if(e.length){var s=An(e,re(qi));r|=Zt}return dn(t,r,n,e,s)}),vo=k(function(t,n,e){var r=q|yn;if(e.length){var s=An(e,re(vo));r|=Zt}return dn(n,r,t,e,s)});function wo(t,n,e){n=e?i:n;var r=dn(t,dt,i,i,i,i,i,n);return r.placeholder=wo.placeholder,r}function yo(t,n,e){n=e?i:n;var r=dn(t,_t,i,i,i,i,i,n);return r.placeholder=yo.placeholder,r}function mo(t,n,e){var r,s,o,f,c,d,y=0,m=!1,S=!1,b=!0;if(typeof t!="function")throw new Kt(x);n=Gt(n)||0,it(e)&&(m=!!e.leading,S="maxWait"in e,o=S?ct(Gt(e.maxWait)||0,n):o,b="trailing"in e?!!e.trailing:b);function R(ot){var tn=r,wn=s;return r=s=i,y=ot,f=t.apply(wn,tn),f}function L(ot){return y=ot,c=Re(H,n),m?R(ot):f}function M(ot){var tn=ot-d,wn=ot-y,$o=n-tn;return S?vt($o,o-wn):$o}function W(ot){var tn=ot-d,wn=ot-y;return d===i||tn>=n||tn<0||S&&wn>=o}function H(){var ot=xr();if(W(ot))return G(ot);c=Re(H,M(ot))}function G(ot){return c=i,b&&r?R(ot):(r=s=i,f)}function Ft(){c!==i&&Eu(c),y=0,r=d=s=c=i}function St(){return c===i?f:G(xr())}function Ut(){var ot=xr(),tn=W(ot);if(r=arguments,s=this,d=ot,tn){if(c===i)return L(d);if(S)return Eu(c),c=Re(H,n),R(d)}return c===i&&(c=Re(H,n)),f}return Ut.cancel=Ft,Ut.flush=St,Ut}var Wd=k(function(t,n){return au(t,1,n)}),Dd=k(function(t,n,e){return au(t,Gt(n)||0,e)});function Fd(t){return dn(t,Et)}function Sr(t,n){if(typeof t!="function"||n!=null&&typeof n!="function")throw new Kt(x);var e=function(){var r=arguments,s=n?n.apply(this,r):r[0],o=e.cache;if(o.has(s))return o.get(s);var f=t.apply(this,r);return e.cache=o.set(s,f)||o,f};return e.cache=new(Sr.Cache||ln),e}Sr.Cache=ln;function Ar(t){if(typeof t!="function")throw new Kt(x);return function(){var n=arguments;switch(n.length){case 0:return!t.call(this);case 1:return!t.call(this,n[0]);case 2:return!t.call(this,n[0],n[1]);case 3:return!t.call(this,n[0],n[1],n[2])}return!t.apply(this,n)}}function Ud(t){return _o(2,t)}var Nd=Al(function(t,n){n=n.length==1&&U(n[0])?rt(n[0],Lt(O())):rt(gt(n,1),Lt(O()));var e=n.length;return k(function(r){for(var s=-1,o=vt(r.length,e);++s<o;)r[s]=n[s].call(this,r[s]);return Ot(t,this,r)})}),Hi=k(function(t,n){var e=An(n,re(Hi));return dn(t,Zt,i,n,e)}),xo=k(function(t,n){var e=An(n,re(xo));return dn(t,Ln,i,n,e)}),Bd=pn(function(t,n){return dn(t,nn,i,i,i,n)});function $d(t,n){if(typeof t!="function")throw new Kt(x);return n=n===i?n:$(n),k(t,n)}function Md(t,n){if(typeof t!="function")throw new Kt(x);return n=n==null?0:ct($(n),0),k(function(e){var r=e[n],s=Rn(e,0,n);return r&&Sn(s,r),Ot(t,this,s)})}function Kd(t,n,e){var r=!0,s=!0;if(typeof t!="function")throw new Kt(x);return it(e)&&(r="leading"in e?!!e.leading:r,s="trailing"in e?!!e.trailing:s),mo(t,n,{leading:r,maxWait:n,trailing:s})}function kd(t){return go(t,1)}function qd(t,n){return Hi(Ri(n),t)}function Hd(){if(!arguments.length)return[];var t=arguments[0];return U(t)?t:[t]}function zd(t){return qt(t,P)}function Gd(t,n){return n=typeof n=="function"?n:i,qt(t,P,n)}function Jd(t){return qt(t,A|P)}function Zd(t,n){return n=typeof n=="function"?n:i,qt(t,A|P,n)}function Yd(t,n){return n==null||ou(t,n,ht(n))}function jt(t,n){return t===n||t!==t&&n!==n}var Xd=gr(_i),Qd=gr(function(t,n){return t>=n}),kn=du(function(){return arguments}())?du:function(t){return st(t)&&V.call(t,"callee")&&!js.call(t,"callee")},U=_.isArray,Vd=Ds?Lt(Ds):ul;function Pt(t){return t!=null&&br(t.length)&&!_n(t)}function ut(t){return st(t)&&Pt(t)}function jd(t){return t===!0||t===!1||st(t)&&mt(t)==At}var En=dc||ns,tp=Fs?Lt(Fs):ol;function np(t){return st(t)&&t.nodeType===1&&!Ee(t)}function ep(t){if(t==null)return!0;if(Pt(t)&&(U(t)||typeof t=="string"||typeof t.splice=="function"||En(t)||ie(t)||kn(t)))return!t.length;var n=wt(t);if(n==Yt||n==Xt)return!t.size;if(Ie(t))return!yi(t).length;for(var e in t)if(V.call(t,e))return!1;return!0}function rp(t,n){return be(t,n)}function ip(t,n,e){e=typeof e=="function"?e:i;var r=e?e(t,n):i;return r===i?be(t,n,i,e):!!r}function zi(t){if(!st(t))return!1;var n=mt(t);return n==bt||n==Ue||typeof t.message=="string"&&typeof t.name=="string"&&!Ee(t)}function sp(t){return typeof t=="number"&&nu(t)}function _n(t){if(!it(t))return!1;var n=mt(t);return n==Ne||n==as||n==at||n==Ra}function So(t){return typeof t=="number"&&t==$(t)}function br(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=en}function it(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}function st(t){return t!=null&&typeof t=="object"}var Ao=Us?Lt(Us):fl;function up(t,n){return t===n||wi(t,n,Fi(n))}function op(t,n,e){return e=typeof e=="function"?e:i,wi(t,n,Fi(n),e)}function ap(t){return bo(t)&&t!=+t}function fp(t){if(Gl(t))throw new F(v);return pu(t)}function cp(t){return t===null}function lp(t){return t==null}function bo(t){return typeof t=="number"||st(t)&&mt(t)==ce}function Ee(t){if(!st(t)||mt(t)!=fn)return!1;var n=Qe(t);if(n===null)return!0;var e=V.call(n,"constructor")&&n.constructor;return typeof e=="function"&&e instanceof e&&Je.call(e)==oc}var Gi=Ns?Lt(Ns):cl;function hp(t){return So(t)&&t>=-en&&t<=en}var Co=Bs?Lt(Bs):ll;function Cr(t){return typeof t=="string"||!U(t)&&st(t)&&mt(t)==he}function Dt(t){return typeof t=="symbol"||st(t)&&mt(t)==Be}var ie=$s?Lt($s):hl;function dp(t){return t===i}function pp(t){return st(t)&&wt(t)==de}function gp(t){return st(t)&&mt(t)==Ta}var _p=gr(mi),vp=gr(function(t,n){return t<=n});function Po(t){if(!t)return[];if(Pt(t))return Cr(t)?Qt(t):Ct(t);if(_e&&t[_e])return Yf(t[_e]());var n=wt(t),e=n==Yt?oi:n==Xt?He:se;return e(t)}function vn(t){if(!t)return t===0?t:0;if(t=Gt(t),t===an||t===-an){var n=t<0?-1:1;return n*Lr}return t===t?t:0}function $(t){var n=vn(t),e=n%1;return n===n?e?n-e:n:0}function Io(t){return t?Bn($(t),0,Bt):0}function Gt(t){if(typeof t=="number")return t;if(Dt(t))return Hn;if(it(t)){var n=typeof t.valueOf=="function"?t.valueOf():t;t=it(n)?n+"":n}if(typeof t!="string")return t===0?t:+t;t=zs(t);var e=Qa.test(t);return e||ja.test(t)?Lf(t.slice(2),e?2:8):Xa.test(t)?Hn:+t}function Ro(t){return sn(t,It(t))}function wp(t){return t?Bn($(t),-en,en):t===0?t:0}function Q(t){return t==null?"":Wt(t)}var yp=ne(function(t,n){if(Ie(n)||Pt(n)){sn(n,ht(n),t);return}for(var e in n)V.call(n,e)&&xe(t,e,n[e])}),Eo=ne(function(t,n){sn(n,It(n),t)}),Pr=ne(function(t,n,e,r){sn(n,It(n),t,r)}),mp=ne(function(t,n,e,r){sn(n,ht(n),t,r)}),xp=pn(di);function Sp(t,n){var e=te(t);return n==null?e:uu(e,n)}var Ap=k(function(t,n){t=j(t);var e=-1,r=n.length,s=r>2?n[2]:i;for(s&&xt(n[0],n[1],s)&&(r=1);++e<r;)for(var o=n[e],f=It(o),c=-1,d=f.length;++c<d;){var y=f[c],m=t[y];(m===i||jt(m,Qn[y])&&!V.call(t,y))&&(t[y]=o[y])}return t}),bp=k(function(t){return t.push(i,zu),Ot(To,i,t)});function Cp(t,n){return Ks(t,O(n,3),rn)}function Pp(t,n){return Ks(t,O(n,3),gi)}function Ip(t,n){return t==null?t:pi(t,O(n,3),It)}function Rp(t,n){return t==null?t:lu(t,O(n,3),It)}function Ep(t,n){return t&&rn(t,O(n,3))}function Tp(t,n){return t&&gi(t,O(n,3))}function Op(t){return t==null?[]:or(t,ht(t))}function Lp(t){return t==null?[]:or(t,It(t))}function Ji(t,n,e){var r=t==null?i:$n(t,n);return r===i?e:r}function Wp(t,n){return t!=null&&Zu(t,n,el)}function Zi(t,n){return t!=null&&Zu(t,n,rl)}var Dp=Mu(function(t,n,e){n!=null&&typeof n.toString!="function"&&(n=Ze.call(n)),t[n]=e},Xi(Rt)),Fp=Mu(function(t,n,e){n!=null&&typeof n.toString!="function"&&(n=Ze.call(n)),V.call(t,n)?t[n].push(e):t[n]=[e]},O),Up=k(Ae);function ht(t){return Pt(t)?iu(t):yi(t)}function It(t){return Pt(t)?iu(t,!0):dl(t)}function Np(t,n){var e={};return n=O(n,3),rn(t,function(r,s,o){hn(e,n(r,s,o),r)}),e}function Bp(t,n){var e={};return n=O(n,3),rn(t,function(r,s,o){hn(e,s,n(r,s,o))}),e}var $p=ne(function(t,n,e){ar(t,n,e)}),To=ne(function(t,n,e,r){ar(t,n,e,r)}),Mp=pn(function(t,n){var e={};if(t==null)return e;var r=!1;n=rt(n,function(o){return o=In(o,t),r||(r=o.length>1),o}),sn(t,Wi(t),e),r&&(e=qt(e,A|D|P,Dl));for(var s=n.length;s--;)Ci(e,n[s]);return e});function Kp(t,n){return Oo(t,Ar(O(n)))}var kp=pn(function(t,n){return t==null?{}:gl(t,n)});function Oo(t,n){if(t==null)return{};var e=rt(Wi(t),function(r){return[r]});return n=O(n),xu(t,e,function(r,s){return n(r,s[0])})}function qp(t,n,e){n=In(n,t);var r=-1,s=n.length;for(s||(s=1,t=i);++r<s;){var o=t==null?i:t[un(n[r])];o===i&&(r=s,o=e),t=_n(o)?o.call(t):o}return t}function Hp(t,n,e){return t==null?t:Ce(t,n,e)}function zp(t,n,e,r){return r=typeof r=="function"?r:i,t==null?t:Ce(t,n,e,r)}var Lo=qu(ht),Wo=qu(It);function Gp(t,n,e){var r=U(t),s=r||En(t)||ie(t);if(n=O(n,4),e==null){var o=t&&t.constructor;s?e=r?new o:[]:it(t)?e=_n(o)?te(Qe(t)):{}:e={}}return(s?Mt:rn)(t,function(f,c,d){return n(e,f,c,d)}),e}function Jp(t,n){return t==null?!0:Ci(t,n)}function Zp(t,n,e){return t==null?t:Pu(t,n,Ri(e))}function Yp(t,n,e,r){return r=typeof r=="function"?r:i,t==null?t:Pu(t,n,Ri(e),r)}function se(t){return t==null?[]:ui(t,ht(t))}function Xp(t){return t==null?[]:ui(t,It(t))}function Qp(t,n,e){return e===i&&(e=n,n=i),e!==i&&(e=Gt(e),e=e===e?e:0),n!==i&&(n=Gt(n),n=n===n?n:0),Bn(Gt(t),n,e)}function Vp(t,n,e){return n=vn(n),e===i?(e=n,n=0):e=vn(e),t=Gt(t),il(t,n,e)}function jp(t,n,e){if(e&&typeof e!="boolean"&&xt(t,n,e)&&(n=e=i),e===i&&(typeof n=="boolean"?(e=n,n=i):typeof t=="boolean"&&(e=t,t=i)),t===i&&n===i?(t=0,n=1):(t=vn(t),n===i?(n=t,t=0):n=vn(n)),t>n){var r=t;t=n,n=r}if(e||t%1||n%1){var s=eu();return vt(t+s*(n-t+Of("1e-"+((s+"").length-1))),n)}return Si(t,n)}var tg=ee(function(t,n,e){return n=n.toLowerCase(),t+(e?Do(n):n)});function Do(t){return Yi(Q(t).toLowerCase())}function Fo(t){return t=Q(t),t&&t.replace(nf,Hf).replace(xf,"")}function ng(t,n,e){t=Q(t),n=Wt(n);var r=t.length;e=e===i?r:Bn($(e),0,r);var s=e;return e-=n.length,e>=0&&t.slice(e,s)==n}function eg(t){return t=Q(t),t&&Fa.test(t)?t.replace(ls,zf):t}function rg(t){return t=Q(t),t&&Ka.test(t)?t.replace(Hr,"\\$&"):t}var ig=ee(function(t,n,e){return t+(e?"-":"")+n.toLowerCase()}),sg=ee(function(t,n,e){return t+(e?" ":"")+n.toLowerCase()}),ug=Nu("toLowerCase");function og(t,n,e){t=Q(t),n=$(n);var r=n?Yn(t):0;if(!n||r>=n)return t;var s=(n-r)/2;return pr(nr(s),e)+t+pr(tr(s),e)}function ag(t,n,e){t=Q(t),n=$(n);var r=n?Yn(t):0;return n&&r<n?t+pr(n-r,e):t}function fg(t,n,e){t=Q(t),n=$(n);var r=n?Yn(t):0;return n&&r<n?pr(n-r,e)+t:t}function cg(t,n,e){return e||n==null?n=0:n&&(n=+n),vc(Q(t).replace(zr,""),n||0)}function lg(t,n,e){return(e?xt(t,n,e):n===i)?n=1:n=$(n),Ai(Q(t),n)}function hg(){var t=arguments,n=Q(t[0]);return t.length<3?n:n.replace(t[1],t[2])}var dg=ee(function(t,n,e){return t+(e?"_":"")+n.toLowerCase()});function pg(t,n,e){return e&&typeof e!="number"&&xt(t,n,e)&&(n=e=i),e=e===i?Bt:e>>>0,e?(t=Q(t),t&&(typeof n=="string"||n!=null&&!Gi(n))&&(n=Wt(n),!n&&Zn(t))?Rn(Qt(t),0,e):t.split(n,e)):[]}var gg=ee(function(t,n,e){return t+(e?" ":"")+Yi(n)});function _g(t,n,e){return t=Q(t),e=e==null?0:Bn($(e),0,t.length),n=Wt(n),t.slice(e,e+n.length)==n}function vg(t,n,e){var r=u.templateSettings;e&&xt(t,n,e)&&(n=i),t=Q(t),n=Pr({},n,r,Hu);var s=Pr({},n.imports,r.imports,Hu),o=ht(s),f=ui(s,o),c,d,y=0,m=n.interpolate||$e,S="__p += '",b=ai((n.escape||$e).source+"|"+m.source+"|"+(m===hs?Ya:$e).source+"|"+(n.evaluate||$e).source+"|$","g"),R="//# sourceURL="+(V.call(n,"sourceURL")?(n.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Pf+"]")+`
|
|
11
|
-
`;t.replace(
|
|
8
|
+
*/Ln.exports,function(l,o){(function(){var i,h="4.17.21",g=200,v="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",S="Expected a function",I="Invalid `variable` option passed into `_.template`",b="__lodash_hash_undefined__",B=500,X="__lodash_placeholder__",P=1,U=2,A=4,T=1,Z=2,ft=1,ve=2,Wn=4,V=8,se=16,yt=32,Et=64,ht=128,Oe=256,hn=512,Un=30,He="...",Zt=800,Nn=16,Ge=1,Tt=2,Fn=3,Ft=1/0,Yt=9007199254740991,lt=17976931348623157e292,ze=NaN,Mt=4294967295,Lr=Mt-1,Dr=Mt>>>1,Wr=[["ary",ht],["bind",ft],["bindKey",ve],["curry",V],["curryRight",se],["flip",hn],["partial",yt],["partialRight",Et],["rearg",Oe]],ye="[object Arguments]",Le="[object Array]",Ur="[object AsyncFunction]",De="[object Boolean]",We="[object Date]",Nr="[object DOMException]",N="[object Error]",et="[object Function]",wt="[object GeneratorFunction]",at="[object Map]",we="[object Number]",Xt="[object Null]",ue="[object Object]",fs="[object Promise]",Wo="[object Proxy]",dn="[object RegExp]",Qt="[object Set]",pn="[object String]",Mn="[object Symbol]",Uo="[object Undefined]",gn="[object WeakMap]",No="[object WeakSet]",_n="[object ArrayBuffer]",Je="[object DataView]",Fr="[object Float32Array]",Mr="[object Float64Array]",$r="[object Int8Array]",Br="[object Int16Array]",kr="[object Int32Array]",Kr="[object Uint8Array]",qr="[object Uint8ClampedArray]",Hr="[object Uint16Array]",Gr="[object Uint32Array]",Fo=/\b__p \+= '';/g,Mo=/\b(__p \+=) '' \+/g,$o=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ls=/&(?:amp|lt|gt|quot|#39);/g,hs=/[&<>"']/g,Bo=RegExp(ls.source),ko=RegExp(hs.source),Ko=/<%-([\s\S]+?)%>/g,qo=/<%([\s\S]+?)%>/g,ds=/<%=([\s\S]+?)%>/g,Ho=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Go=/^\w*$/,zo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,zr=/[\\^$.*+?()[\]{}|]/g,Jo=RegExp(zr.source),Jr=/^\s+/,Zo=/\s/,Yo=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Xo=/\{\n\/\* \[wrapped with (.+)\] \*/,Qo=/,? & /,Vo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,jo=/[()=,{}\[\]\/\s]/,tc=/\\(\\)?/g,ec=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ps=/\w*$/,nc=/^[-+]0x[0-9a-f]+$/i,rc=/^0b[01]+$/i,ic=/^\[object .+?Constructor\]$/,sc=/^0o[0-7]+$/i,uc=/^(?:0|[1-9]\d*)$/,ac=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,$n=/($^)/,oc=/['\n\r\u2028\u2029\\]/g,Bn="\\ud800-\\udfff",cc="\\u0300-\\u036f",fc="\\ufe20-\\ufe2f",lc="\\u20d0-\\u20ff",gs=cc+fc+lc,_s="\\u2700-\\u27bf",vs="a-z\\xdf-\\xf6\\xf8-\\xff",hc="\\xac\\xb1\\xd7\\xf7",dc="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",pc="\\u2000-\\u206f",gc=" \\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",ys="A-Z\\xc0-\\xd6\\xd8-\\xde",ws="\\ufe0e\\ufe0f",ms=hc+dc+pc+gc,Zr="['’]",_c="["+Bn+"]",Ss="["+ms+"]",kn="["+gs+"]",xs="\\d+",vc="["+_s+"]",bs="["+vs+"]",As="[^"+Bn+ms+xs+_s+vs+ys+"]",Yr="\\ud83c[\\udffb-\\udfff]",yc="(?:"+kn+"|"+Yr+")",Ps="[^"+Bn+"]",Xr="(?:\\ud83c[\\udde6-\\uddff]){2}",Qr="[\\ud800-\\udbff][\\udc00-\\udfff]",Ze="["+ys+"]",Cs="\\u200d",Rs="(?:"+bs+"|"+As+")",wc="(?:"+Ze+"|"+As+")",Is="(?:"+Zr+"(?:d|ll|m|re|s|t|ve))?",Es="(?:"+Zr+"(?:D|LL|M|RE|S|T|VE))?",Ts=yc+"?",Os="["+ws+"]?",mc="(?:"+Cs+"(?:"+[Ps,Xr,Qr].join("|")+")"+Os+Ts+")*",Sc="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",xc="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Ls=Os+Ts+mc,bc="(?:"+[vc,Xr,Qr].join("|")+")"+Ls,Ac="(?:"+[Ps+kn+"?",kn,Xr,Qr,_c].join("|")+")",Pc=RegExp(Zr,"g"),Cc=RegExp(kn,"g"),Vr=RegExp(Yr+"(?="+Yr+")|"+Ac+Ls,"g"),Rc=RegExp([Ze+"?"+bs+"+"+Is+"(?="+[Ss,Ze,"$"].join("|")+")",wc+"+"+Es+"(?="+[Ss,Ze+Rs,"$"].join("|")+")",Ze+"?"+Rs+"+"+Is,Ze+"+"+Es,xc,Sc,xs,bc].join("|"),"g"),Ic=RegExp("["+Cs+Bn+gs+ws+"]"),Ec=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Tc=["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"],Oc=-1,rt={};rt[Fr]=rt[Mr]=rt[$r]=rt[Br]=rt[kr]=rt[Kr]=rt[qr]=rt[Hr]=rt[Gr]=!0,rt[ye]=rt[Le]=rt[_n]=rt[De]=rt[Je]=rt[We]=rt[N]=rt[et]=rt[at]=rt[we]=rt[ue]=rt[dn]=rt[Qt]=rt[pn]=rt[gn]=!1;var nt={};nt[ye]=nt[Le]=nt[_n]=nt[Je]=nt[De]=nt[We]=nt[Fr]=nt[Mr]=nt[$r]=nt[Br]=nt[kr]=nt[at]=nt[we]=nt[ue]=nt[dn]=nt[Qt]=nt[pn]=nt[Mn]=nt[Kr]=nt[qr]=nt[Hr]=nt[Gr]=!0,nt[N]=nt[et]=nt[gn]=!1;var Lc={À:"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"},Dc={"&":"&","<":"<",">":">",'"':""","'":"'"},Wc={"&":"&","<":"<",">":">",""":'"',"'":"'"},Uc={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Nc=parseFloat,Fc=parseInt,Ds=typeof ln=="object"&&ln&&ln.Object===Object&&ln,Mc=typeof self=="object"&&self&&self.Object===Object&&self,_t=Ds||Mc||Function("return this")(),jr=o&&!o.nodeType&&o,Ue=jr&&!0&&l&&!l.nodeType&&l,Ws=Ue&&Ue.exports===jr,ti=Ws&&Ds.process,$t=function(){try{var d=Ue&&Ue.require&&Ue.require("util").types;return d||ti&&ti.binding&&ti.binding("util")}catch{}}(),Us=$t&&$t.isArrayBuffer,Ns=$t&&$t.isDate,Fs=$t&&$t.isMap,Ms=$t&&$t.isRegExp,$s=$t&&$t.isSet,Bs=$t&&$t.isTypedArray;function Ot(d,y,_){switch(_.length){case 0:return d.call(y);case 1:return d.call(y,_[0]);case 2:return d.call(y,_[0],_[1]);case 3:return d.call(y,_[0],_[1],_[2])}return d.apply(y,_)}function $c(d,y,_,R){for(var F=-1,Y=d==null?0:d.length;++F<Y;){var dt=d[F];y(R,dt,_(dt),d)}return R}function Bt(d,y){for(var _=-1,R=d==null?0:d.length;++_<R&&y(d[_],_,d)!==!1;);return d}function Bc(d,y){for(var _=d==null?0:d.length;_--&&y(d[_],_,d)!==!1;);return d}function ks(d,y){for(var _=-1,R=d==null?0:d.length;++_<R;)if(!y(d[_],_,d))return!1;return!0}function me(d,y){for(var _=-1,R=d==null?0:d.length,F=0,Y=[];++_<R;){var dt=d[_];y(dt,_,d)&&(Y[F++]=dt)}return Y}function Kn(d,y){var _=d==null?0:d.length;return!!_&&Ye(d,y,0)>-1}function ei(d,y,_){for(var R=-1,F=d==null?0:d.length;++R<F;)if(_(y,d[R]))return!0;return!1}function it(d,y){for(var _=-1,R=d==null?0:d.length,F=Array(R);++_<R;)F[_]=y(d[_],_,d);return F}function Se(d,y){for(var _=-1,R=y.length,F=d.length;++_<R;)d[F+_]=y[_];return d}function ni(d,y,_,R){var F=-1,Y=d==null?0:d.length;for(R&&Y&&(_=d[++F]);++F<Y;)_=y(_,d[F],F,d);return _}function kc(d,y,_,R){var F=d==null?0:d.length;for(R&&F&&(_=d[--F]);F--;)_=y(_,d[F],F,d);return _}function ri(d,y){for(var _=-1,R=d==null?0:d.length;++_<R;)if(y(d[_],_,d))return!0;return!1}var Kc=ii("length");function qc(d){return d.split("")}function Hc(d){return d.match(Vo)||[]}function Ks(d,y,_){var R;return _(d,function(F,Y,dt){if(y(F,Y,dt))return R=Y,!1}),R}function qn(d,y,_,R){for(var F=d.length,Y=_+(R?1:-1);R?Y--:++Y<F;)if(y(d[Y],Y,d))return Y;return-1}function Ye(d,y,_){return y===y?nf(d,y,_):qn(d,qs,_)}function Gc(d,y,_,R){for(var F=_-1,Y=d.length;++F<Y;)if(R(d[F],y))return F;return-1}function qs(d){return d!==d}function Hs(d,y){var _=d==null?0:d.length;return _?ui(d,y)/_:ze}function ii(d){return function(y){return y==null?i:y[d]}}function si(d){return function(y){return d==null?i:d[y]}}function Gs(d,y,_,R,F){return F(d,function(Y,dt,tt){_=R?(R=!1,Y):y(_,Y,dt,tt)}),_}function zc(d,y){var _=d.length;for(d.sort(y);_--;)d[_]=d[_].value;return d}function ui(d,y){for(var _,R=-1,F=d.length;++R<F;){var Y=y(d[R]);Y!==i&&(_=_===i?Y:_+Y)}return _}function ai(d,y){for(var _=-1,R=Array(d);++_<d;)R[_]=y(_);return R}function Jc(d,y){return it(y,function(_){return[_,d[_]]})}function zs(d){return d&&d.slice(0,Xs(d)+1).replace(Jr,"")}function Lt(d){return function(y){return d(y)}}function oi(d,y){return it(y,function(_){return d[_]})}function vn(d,y){return d.has(y)}function Js(d,y){for(var _=-1,R=d.length;++_<R&&Ye(y,d[_],0)>-1;);return _}function Zs(d,y){for(var _=d.length;_--&&Ye(y,d[_],0)>-1;);return _}function Zc(d,y){for(var _=d.length,R=0;_--;)d[_]===y&&++R;return R}var Yc=si(Lc),Xc=si(Dc);function Qc(d){return"\\"+Uc[d]}function Vc(d,y){return d==null?i:d[y]}function Xe(d){return Ic.test(d)}function jc(d){return Ec.test(d)}function tf(d){for(var y,_=[];!(y=d.next()).done;)_.push(y.value);return _}function ci(d){var y=-1,_=Array(d.size);return d.forEach(function(R,F){_[++y]=[F,R]}),_}function Ys(d,y){return function(_){return d(y(_))}}function xe(d,y){for(var _=-1,R=d.length,F=0,Y=[];++_<R;){var dt=d[_];(dt===y||dt===X)&&(d[_]=X,Y[F++]=_)}return Y}function Hn(d){var y=-1,_=Array(d.size);return d.forEach(function(R){_[++y]=R}),_}function ef(d){var y=-1,_=Array(d.size);return d.forEach(function(R){_[++y]=[R,R]}),_}function nf(d,y,_){for(var R=_-1,F=d.length;++R<F;)if(d[R]===y)return R;return-1}function rf(d,y,_){for(var R=_+1;R--;)if(d[R]===y)return R;return R}function Qe(d){return Xe(d)?uf(d):Kc(d)}function Vt(d){return Xe(d)?af(d):qc(d)}function Xs(d){for(var y=d.length;y--&&Zo.test(d.charAt(y)););return y}var sf=si(Wc);function uf(d){for(var y=Vr.lastIndex=0;Vr.test(d);)++y;return y}function af(d){return d.match(Vr)||[]}function of(d){return d.match(Rc)||[]}var cf=function d(y){y=y==null?_t:Ve.defaults(_t.Object(),y,Ve.pick(_t,Tc));var _=y.Array,R=y.Date,F=y.Error,Y=y.Function,dt=y.Math,tt=y.Object,fi=y.RegExp,ff=y.String,kt=y.TypeError,Gn=_.prototype,lf=Y.prototype,je=tt.prototype,zn=y["__core-js_shared__"],Jn=lf.toString,j=je.hasOwnProperty,hf=0,Qs=function(){var t=/[^.]+$/.exec(zn&&zn.keys&&zn.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Zn=je.toString,df=Jn.call(tt),pf=_t._,gf=fi("^"+Jn.call(j).replace(zr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Yn=Ws?y.Buffer:i,be=y.Symbol,Xn=y.Uint8Array,Vs=Yn?Yn.allocUnsafe:i,Qn=Ys(tt.getPrototypeOf,tt),js=tt.create,tu=je.propertyIsEnumerable,Vn=Gn.splice,eu=be?be.isConcatSpreadable:i,yn=be?be.iterator:i,Ne=be?be.toStringTag:i,jn=function(){try{var t=ke(tt,"defineProperty");return t({},"",{}),t}catch{}}(),_f=y.clearTimeout!==_t.clearTimeout&&y.clearTimeout,vf=R&&R.now!==_t.Date.now&&R.now,yf=y.setTimeout!==_t.setTimeout&&y.setTimeout,tr=dt.ceil,er=dt.floor,li=tt.getOwnPropertySymbols,wf=Yn?Yn.isBuffer:i,nu=y.isFinite,mf=Gn.join,Sf=Ys(tt.keys,tt),pt=dt.max,mt=dt.min,xf=R.now,bf=y.parseInt,ru=dt.random,Af=Gn.reverse,hi=ke(y,"DataView"),wn=ke(y,"Map"),di=ke(y,"Promise"),tn=ke(y,"Set"),mn=ke(y,"WeakMap"),Sn=ke(tt,"create"),nr=mn&&new mn,en={},Pf=Ke(hi),Cf=Ke(wn),Rf=Ke(di),If=Ke(tn),Ef=Ke(mn),rr=be?be.prototype:i,xn=rr?rr.valueOf:i,iu=rr?rr.toString:i;function u(t){if(ut(t)&&!M(t)&&!(t instanceof G)){if(t instanceof Kt)return t;if(j.call(t,"__wrapped__"))return sa(t)}return new Kt(t)}var nn=function(){function t(){}return function(e){if(!st(e))return{};if(js)return js(e);t.prototype=e;var n=new t;return t.prototype=i,n}}();function ir(){}function Kt(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=i}u.templateSettings={escape:Ko,evaluate:qo,interpolate:ds,variable:"",imports:{_:u}},u.prototype=ir.prototype,u.prototype.constructor=u,Kt.prototype=nn(ir.prototype),Kt.prototype.constructor=Kt;function G(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Mt,this.__views__=[]}function Tf(){var t=new G(this.__wrapped__);return t.__actions__=Pt(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Pt(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Pt(this.__views__),t}function Of(){if(this.__filtered__){var t=new G(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function Lf(){var t=this.__wrapped__.value(),e=this.__dir__,n=M(t),r=e<0,s=n?t.length:0,a=Hl(0,s,this.__views__),c=a.start,f=a.end,p=f-c,w=r?f:c-1,m=this.__iteratees__,x=m.length,C=0,E=mt(p,this.__takeCount__);if(!n||!r&&s==p&&E==p)return Iu(t,this.__actions__);var D=[];t:for(;p--&&C<E;){w+=e;for(var k=-1,W=t[w];++k<x;){var H=m[k],z=H.iteratee,Ut=H.type,At=z(W);if(Ut==Tt)W=At;else if(!At){if(Ut==Ge)continue t;break t}}D[C++]=W}return D}G.prototype=nn(ir.prototype),G.prototype.constructor=G;function Fe(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Df(){this.__data__=Sn?Sn(null):{},this.size=0}function Wf(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}function Uf(t){var e=this.__data__;if(Sn){var n=e[t];return n===b?i:n}return j.call(e,t)?e[t]:i}function Nf(t){var e=this.__data__;return Sn?e[t]!==i:j.call(e,t)}function Ff(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=Sn&&e===i?b:e,this}Fe.prototype.clear=Df,Fe.prototype.delete=Wf,Fe.prototype.get=Uf,Fe.prototype.has=Nf,Fe.prototype.set=Ff;function ae(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Mf(){this.__data__=[],this.size=0}function $f(t){var e=this.__data__,n=sr(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():Vn.call(e,n,1),--this.size,!0}function Bf(t){var e=this.__data__,n=sr(e,t);return n<0?i:e[n][1]}function kf(t){return sr(this.__data__,t)>-1}function Kf(t,e){var n=this.__data__,r=sr(n,t);return r<0?(++this.size,n.push([t,e])):n[r][1]=e,this}ae.prototype.clear=Mf,ae.prototype.delete=$f,ae.prototype.get=Bf,ae.prototype.has=kf,ae.prototype.set=Kf;function oe(t){var e=-1,n=t==null?0:t.length;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function qf(){this.size=0,this.__data__={hash:new Fe,map:new(wn||ae),string:new Fe}}function Hf(t){var e=vr(this,t).delete(t);return this.size-=e?1:0,e}function Gf(t){return vr(this,t).get(t)}function zf(t){return vr(this,t).has(t)}function Jf(t,e){var n=vr(this,t),r=n.size;return n.set(t,e),this.size+=n.size==r?0:1,this}oe.prototype.clear=qf,oe.prototype.delete=Hf,oe.prototype.get=Gf,oe.prototype.has=zf,oe.prototype.set=Jf;function Me(t){var e=-1,n=t==null?0:t.length;for(this.__data__=new oe;++e<n;)this.add(t[e])}function Zf(t){return this.__data__.set(t,b),this}function Yf(t){return this.__data__.has(t)}Me.prototype.add=Me.prototype.push=Zf,Me.prototype.has=Yf;function jt(t){var e=this.__data__=new ae(t);this.size=e.size}function Xf(){this.__data__=new ae,this.size=0}function Qf(t){var e=this.__data__,n=e.delete(t);return this.size=e.size,n}function Vf(t){return this.__data__.get(t)}function jf(t){return this.__data__.has(t)}function tl(t,e){var n=this.__data__;if(n instanceof ae){var r=n.__data__;if(!wn||r.length<g-1)return r.push([t,e]),this.size=++n.size,this;n=this.__data__=new oe(r)}return n.set(t,e),this.size=n.size,this}jt.prototype.clear=Xf,jt.prototype.delete=Qf,jt.prototype.get=Vf,jt.prototype.has=jf,jt.prototype.set=tl;function su(t,e){var n=M(t),r=!n&&qe(t),s=!n&&!r&&Ie(t),a=!n&&!r&&!s&&an(t),c=n||r||s||a,f=c?ai(t.length,ff):[],p=f.length;for(var w in t)(e||j.call(t,w))&&!(c&&(w=="length"||s&&(w=="offset"||w=="parent")||a&&(w=="buffer"||w=="byteLength"||w=="byteOffset")||he(w,p)))&&f.push(w);return f}function uu(t){var e=t.length;return e?t[Ai(0,e-1)]:i}function el(t,e){return yr(Pt(t),$e(e,0,t.length))}function nl(t){return yr(Pt(t))}function pi(t,e,n){(n!==i&&!te(t[e],n)||n===i&&!(e in t))&&ce(t,e,n)}function bn(t,e,n){var r=t[e];(!(j.call(t,e)&&te(r,n))||n===i&&!(e in t))&&ce(t,e,n)}function sr(t,e){for(var n=t.length;n--;)if(te(t[n][0],e))return n;return-1}function rl(t,e,n,r){return Ae(t,function(s,a,c){e(r,s,n(s),c)}),r}function au(t,e){return t&&re(e,gt(e),t)}function il(t,e){return t&&re(e,Rt(e),t)}function ce(t,e,n){e=="__proto__"&&jn?jn(t,e,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[e]=n}function gi(t,e){for(var n=-1,r=e.length,s=_(r),a=t==null;++n<r;)s[n]=a?i:Yi(t,e[n]);return s}function $e(t,e,n){return t===t&&(n!==i&&(t=t<=n?t:n),e!==i&&(t=t>=e?t:e)),t}function qt(t,e,n,r,s,a){var c,f=e&P,p=e&U,w=e&A;if(n&&(c=s?n(t,r,s,a):n(t)),c!==i)return c;if(!st(t))return t;var m=M(t);if(m){if(c=zl(t),!f)return Pt(t,c)}else{var x=St(t),C=x==et||x==wt;if(Ie(t))return Ou(t,f);if(x==ue||x==ye||C&&!s){if(c=p||C?{}:Xu(t),!f)return p?Ul(t,il(c,t)):Wl(t,au(c,t))}else{if(!nt[x])return s?t:{};c=Jl(t,x,f)}}a||(a=new jt);var E=a.get(t);if(E)return E;a.set(t,c),Pa(t)?t.forEach(function(W){c.add(qt(W,e,n,W,t,a))}):ba(t)&&t.forEach(function(W,H){c.set(H,qt(W,e,n,H,t,a))});var D=w?p?Ui:Wi:p?Rt:gt,k=m?i:D(t);return Bt(k||t,function(W,H){k&&(H=W,W=t[H]),bn(c,H,qt(W,e,n,H,t,a))}),c}function sl(t){var e=gt(t);return function(n){return ou(n,t,e)}}function ou(t,e,n){var r=n.length;if(t==null)return!r;for(t=tt(t);r--;){var s=n[r],a=e[s],c=t[s];if(c===i&&!(s in t)||!a(c))return!1}return!0}function cu(t,e,n){if(typeof t!="function")throw new kt(S);return Tn(function(){t.apply(i,n)},e)}function An(t,e,n,r){var s=-1,a=Kn,c=!0,f=t.length,p=[],w=e.length;if(!f)return p;n&&(e=it(e,Lt(n))),r?(a=ei,c=!1):e.length>=g&&(a=vn,c=!1,e=new Me(e));t:for(;++s<f;){var m=t[s],x=n==null?m:n(m);if(m=r||m!==0?m:0,c&&x===x){for(var C=w;C--;)if(e[C]===x)continue t;p.push(m)}else a(e,x,r)||p.push(m)}return p}var Ae=Nu(ne),fu=Nu(vi,!0);function ul(t,e){var n=!0;return Ae(t,function(r,s,a){return n=!!e(r,s,a),n}),n}function ur(t,e,n){for(var r=-1,s=t.length;++r<s;){var a=t[r],c=e(a);if(c!=null&&(f===i?c===c&&!Wt(c):n(c,f)))var f=c,p=a}return p}function al(t,e,n,r){var s=t.length;for(n=$(n),n<0&&(n=-n>s?0:s+n),r=r===i||r>s?s:$(r),r<0&&(r+=s),r=n>r?0:Ra(r);n<r;)t[n++]=e;return t}function lu(t,e){var n=[];return Ae(t,function(r,s,a){e(r,s,a)&&n.push(r)}),n}function vt(t,e,n,r,s){var a=-1,c=t.length;for(n||(n=Yl),s||(s=[]);++a<c;){var f=t[a];e>0&&n(f)?e>1?vt(f,e-1,n,r,s):Se(s,f):r||(s[s.length]=f)}return s}var _i=Fu(),hu=Fu(!0);function ne(t,e){return t&&_i(t,e,gt)}function vi(t,e){return t&&hu(t,e,gt)}function ar(t,e){return me(e,function(n){return de(t[n])})}function Be(t,e){e=Ce(e,t);for(var n=0,r=e.length;t!=null&&n<r;)t=t[ie(e[n++])];return n&&n==r?t:i}function du(t,e,n){var r=e(t);return M(t)?r:Se(r,n(t))}function xt(t){return t==null?t===i?Uo:Xt:Ne&&Ne in tt(t)?ql(t):nh(t)}function yi(t,e){return t>e}function ol(t,e){return t!=null&&j.call(t,e)}function cl(t,e){return t!=null&&e in tt(t)}function fl(t,e,n){return t>=mt(e,n)&&t<pt(e,n)}function wi(t,e,n){for(var r=n?ei:Kn,s=t[0].length,a=t.length,c=a,f=_(a),p=1/0,w=[];c--;){var m=t[c];c&&e&&(m=it(m,Lt(e))),p=mt(m.length,p),f[c]=!n&&(e||s>=120&&m.length>=120)?new Me(c&&m):i}m=t[0];var x=-1,C=f[0];t:for(;++x<s&&w.length<p;){var E=m[x],D=e?e(E):E;if(E=n||E!==0?E:0,!(C?vn(C,D):r(w,D,n))){for(c=a;--c;){var k=f[c];if(!(k?vn(k,D):r(t[c],D,n)))continue t}C&&C.push(D),w.push(E)}}return w}function ll(t,e,n,r){return ne(t,function(s,a,c){e(r,n(s),a,c)}),r}function Pn(t,e,n){e=Ce(e,t),t=ta(t,e);var r=t==null?t:t[ie(Gt(e))];return r==null?i:Ot(r,t,n)}function pu(t){return ut(t)&&xt(t)==ye}function hl(t){return ut(t)&&xt(t)==_n}function dl(t){return ut(t)&&xt(t)==We}function Cn(t,e,n,r,s){return t===e?!0:t==null||e==null||!ut(t)&&!ut(e)?t!==t&&e!==e:pl(t,e,n,r,Cn,s)}function pl(t,e,n,r,s,a){var c=M(t),f=M(e),p=c?Le:St(t),w=f?Le:St(e);p=p==ye?ue:p,w=w==ye?ue:w;var m=p==ue,x=w==ue,C=p==w;if(C&&Ie(t)){if(!Ie(e))return!1;c=!0,m=!1}if(C&&!m)return a||(a=new jt),c||an(t)?Ju(t,e,n,r,s,a):kl(t,e,p,n,r,s,a);if(!(n&T)){var E=m&&j.call(t,"__wrapped__"),D=x&&j.call(e,"__wrapped__");if(E||D){var k=E?t.value():t,W=D?e.value():e;return a||(a=new jt),s(k,W,n,r,a)}}return C?(a||(a=new jt),Kl(t,e,n,r,s,a)):!1}function gl(t){return ut(t)&&St(t)==at}function mi(t,e,n,r){var s=n.length,a=s,c=!r;if(t==null)return!a;for(t=tt(t);s--;){var f=n[s];if(c&&f[2]?f[1]!==t[f[0]]:!(f[0]in t))return!1}for(;++s<a;){f=n[s];var p=f[0],w=t[p],m=f[1];if(c&&f[2]){if(w===i&&!(p in t))return!1}else{var x=new jt;if(r)var C=r(w,m,p,t,e,x);if(!(C===i?Cn(m,w,T|Z,r,x):C))return!1}}return!0}function gu(t){if(!st(t)||Ql(t))return!1;var e=de(t)?gf:ic;return e.test(Ke(t))}function _l(t){return ut(t)&&xt(t)==dn}function vl(t){return ut(t)&&St(t)==Qt}function yl(t){return ut(t)&&Ar(t.length)&&!!rt[xt(t)]}function _u(t){return typeof t=="function"?t:t==null?It:typeof t=="object"?M(t)?wu(t[0],t[1]):yu(t):Ma(t)}function Si(t){if(!En(t))return Sf(t);var e=[];for(var n in tt(t))j.call(t,n)&&n!="constructor"&&e.push(n);return e}function wl(t){if(!st(t))return eh(t);var e=En(t),n=[];for(var r in t)r=="constructor"&&(e||!j.call(t,r))||n.push(r);return n}function xi(t,e){return t<e}function vu(t,e){var n=-1,r=Ct(t)?_(t.length):[];return Ae(t,function(s,a,c){r[++n]=e(s,a,c)}),r}function yu(t){var e=Fi(t);return e.length==1&&e[0][2]?Vu(e[0][0],e[0][1]):function(n){return n===t||mi(n,t,e)}}function wu(t,e){return $i(t)&&Qu(e)?Vu(ie(t),e):function(n){var r=Yi(n,t);return r===i&&r===e?Xi(n,t):Cn(e,r,T|Z)}}function or(t,e,n,r,s){t!==e&&_i(e,function(a,c){if(s||(s=new jt),st(a))ml(t,e,c,n,or,r,s);else{var f=r?r(ki(t,c),a,c+"",t,e,s):i;f===i&&(f=a),pi(t,c,f)}},Rt)}function ml(t,e,n,r,s,a,c){var f=ki(t,n),p=ki(e,n),w=c.get(p);if(w){pi(t,n,w);return}var m=a?a(f,p,n+"",t,e,c):i,x=m===i;if(x){var C=M(p),E=!C&&Ie(p),D=!C&&!E&&an(p);m=p,C||E||D?M(f)?m=f:ot(f)?m=Pt(f):E?(x=!1,m=Ou(p,!0)):D?(x=!1,m=Lu(p,!0)):m=[]:On(p)||qe(p)?(m=f,qe(f)?m=Ia(f):(!st(f)||de(f))&&(m=Xu(p))):x=!1}x&&(c.set(p,m),s(m,p,r,a,c),c.delete(p)),pi(t,n,m)}function mu(t,e){var n=t.length;if(n)return e+=e<0?n:0,he(e,n)?t[e]:i}function Su(t,e,n){e.length?e=it(e,function(a){return M(a)?function(c){return Be(c,a.length===1?a[0]:a)}:a}):e=[It];var r=-1;e=it(e,Lt(L()));var s=vu(t,function(a,c,f){var p=it(e,function(w){return w(a)});return{criteria:p,index:++r,value:a}});return zc(s,function(a,c){return Dl(a,c,n)})}function Sl(t,e){return xu(t,e,function(n,r){return Xi(t,r)})}function xu(t,e,n){for(var r=-1,s=e.length,a={};++r<s;){var c=e[r],f=Be(t,c);n(f,c)&&Rn(a,Ce(c,t),f)}return a}function xl(t){return function(e){return Be(e,t)}}function bi(t,e,n,r){var s=r?Gc:Ye,a=-1,c=e.length,f=t;for(t===e&&(e=Pt(e)),n&&(f=it(t,Lt(n)));++a<c;)for(var p=0,w=e[a],m=n?n(w):w;(p=s(f,m,p,r))>-1;)f!==t&&Vn.call(f,p,1),Vn.call(t,p,1);return t}function bu(t,e){for(var n=t?e.length:0,r=n-1;n--;){var s=e[n];if(n==r||s!==a){var a=s;he(s)?Vn.call(t,s,1):Ri(t,s)}}return t}function Ai(t,e){return t+er(ru()*(e-t+1))}function bl(t,e,n,r){for(var s=-1,a=pt(tr((e-t)/(n||1)),0),c=_(a);a--;)c[r?a:++s]=t,t+=n;return c}function Pi(t,e){var n="";if(!t||e<1||e>Yt)return n;do e%2&&(n+=t),e=er(e/2),e&&(t+=t);while(e);return n}function K(t,e){return Ki(ju(t,e,It),t+"")}function Al(t){return uu(on(t))}function Pl(t,e){var n=on(t);return yr(n,$e(e,0,n.length))}function Rn(t,e,n,r){if(!st(t))return t;e=Ce(e,t);for(var s=-1,a=e.length,c=a-1,f=t;f!=null&&++s<a;){var p=ie(e[s]),w=n;if(p==="__proto__"||p==="constructor"||p==="prototype")return t;if(s!=c){var m=f[p];w=r?r(m,p,f):i,w===i&&(w=st(m)?m:he(e[s+1])?[]:{})}bn(f,p,w),f=f[p]}return t}var Au=nr?function(t,e){return nr.set(t,e),t}:It,Cl=jn?function(t,e){return jn(t,"toString",{configurable:!0,enumerable:!1,value:Vi(e),writable:!0})}:It;function Rl(t){return yr(on(t))}function Ht(t,e,n){var r=-1,s=t.length;e<0&&(e=-e>s?0:s+e),n=n>s?s:n,n<0&&(n+=s),s=e>n?0:n-e>>>0,e>>>=0;for(var a=_(s);++r<s;)a[r]=t[r+e];return a}function Il(t,e){var n;return Ae(t,function(r,s,a){return n=e(r,s,a),!n}),!!n}function cr(t,e,n){var r=0,s=t==null?r:t.length;if(typeof e=="number"&&e===e&&s<=Dr){for(;r<s;){var a=r+s>>>1,c=t[a];c!==null&&!Wt(c)&&(n?c<=e:c<e)?r=a+1:s=a}return s}return Ci(t,e,It,n)}function Ci(t,e,n,r){var s=0,a=t==null?0:t.length;if(a===0)return 0;e=n(e);for(var c=e!==e,f=e===null,p=Wt(e),w=e===i;s<a;){var m=er((s+a)/2),x=n(t[m]),C=x!==i,E=x===null,D=x===x,k=Wt(x);if(c)var W=r||D;else w?W=D&&(r||C):f?W=D&&C&&(r||!E):p?W=D&&C&&!E&&(r||!k):E||k?W=!1:W=r?x<=e:x<e;W?s=m+1:a=m}return mt(a,Lr)}function Pu(t,e){for(var n=-1,r=t.length,s=0,a=[];++n<r;){var c=t[n],f=e?e(c):c;if(!n||!te(f,p)){var p=f;a[s++]=c===0?0:c}}return a}function Cu(t){return typeof t=="number"?t:Wt(t)?ze:+t}function Dt(t){if(typeof t=="string")return t;if(M(t))return it(t,Dt)+"";if(Wt(t))return iu?iu.call(t):"";var e=t+"";return e=="0"&&1/t==-Ft?"-0":e}function Pe(t,e,n){var r=-1,s=Kn,a=t.length,c=!0,f=[],p=f;if(n)c=!1,s=ei;else if(a>=g){var w=e?null:$l(t);if(w)return Hn(w);c=!1,s=vn,p=new Me}else p=e?[]:f;t:for(;++r<a;){var m=t[r],x=e?e(m):m;if(m=n||m!==0?m:0,c&&x===x){for(var C=p.length;C--;)if(p[C]===x)continue t;e&&p.push(x),f.push(m)}else s(p,x,n)||(p!==f&&p.push(x),f.push(m))}return f}function Ri(t,e){return e=Ce(e,t),t=ta(t,e),t==null||delete t[ie(Gt(e))]}function Ru(t,e,n,r){return Rn(t,e,n(Be(t,e)),r)}function fr(t,e,n,r){for(var s=t.length,a=r?s:-1;(r?a--:++a<s)&&e(t[a],a,t););return n?Ht(t,r?0:a,r?a+1:s):Ht(t,r?a+1:0,r?s:a)}function Iu(t,e){var n=t;return n instanceof G&&(n=n.value()),ni(e,function(r,s){return s.func.apply(s.thisArg,Se([r],s.args))},n)}function Ii(t,e,n){var r=t.length;if(r<2)return r?Pe(t[0]):[];for(var s=-1,a=_(r);++s<r;)for(var c=t[s],f=-1;++f<r;)f!=s&&(a[s]=An(a[s]||c,t[f],e,n));return Pe(vt(a,1),e,n)}function Eu(t,e,n){for(var r=-1,s=t.length,a=e.length,c={};++r<s;){var f=r<a?e[r]:i;n(c,t[r],f)}return c}function Ei(t){return ot(t)?t:[]}function Ti(t){return typeof t=="function"?t:It}function Ce(t,e){return M(t)?t:$i(t,e)?[t]:ia(Q(t))}var El=K;function Re(t,e,n){var r=t.length;return n=n===i?r:n,!e&&n>=r?t:Ht(t,e,n)}var Tu=_f||function(t){return _t.clearTimeout(t)};function Ou(t,e){if(e)return t.slice();var n=t.length,r=Vs?Vs(n):new t.constructor(n);return t.copy(r),r}function Oi(t){var e=new t.constructor(t.byteLength);return new Xn(e).set(new Xn(t)),e}function Tl(t,e){var n=e?Oi(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}function Ol(t){var e=new t.constructor(t.source,ps.exec(t));return e.lastIndex=t.lastIndex,e}function Ll(t){return xn?tt(xn.call(t)):{}}function Lu(t,e){var n=e?Oi(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function Du(t,e){if(t!==e){var n=t!==i,r=t===null,s=t===t,a=Wt(t),c=e!==i,f=e===null,p=e===e,w=Wt(e);if(!f&&!w&&!a&&t>e||a&&c&&p&&!f&&!w||r&&c&&p||!n&&p||!s)return 1;if(!r&&!a&&!w&&t<e||w&&n&&s&&!r&&!a||f&&n&&s||!c&&s||!p)return-1}return 0}function Dl(t,e,n){for(var r=-1,s=t.criteria,a=e.criteria,c=s.length,f=n.length;++r<c;){var p=Du(s[r],a[r]);if(p){if(r>=f)return p;var w=n[r];return p*(w=="desc"?-1:1)}}return t.index-e.index}function Wu(t,e,n,r){for(var s=-1,a=t.length,c=n.length,f=-1,p=e.length,w=pt(a-c,0),m=_(p+w),x=!r;++f<p;)m[f]=e[f];for(;++s<c;)(x||s<a)&&(m[n[s]]=t[s]);for(;w--;)m[f++]=t[s++];return m}function Uu(t,e,n,r){for(var s=-1,a=t.length,c=-1,f=n.length,p=-1,w=e.length,m=pt(a-f,0),x=_(m+w),C=!r;++s<m;)x[s]=t[s];for(var E=s;++p<w;)x[E+p]=e[p];for(;++c<f;)(C||s<a)&&(x[E+n[c]]=t[s++]);return x}function Pt(t,e){var n=-1,r=t.length;for(e||(e=_(r));++n<r;)e[n]=t[n];return e}function re(t,e,n,r){var s=!n;n||(n={});for(var a=-1,c=e.length;++a<c;){var f=e[a],p=r?r(n[f],t[f],f,n,t):i;p===i&&(p=t[f]),s?ce(n,f,p):bn(n,f,p)}return n}function Wl(t,e){return re(t,Mi(t),e)}function Ul(t,e){return re(t,Zu(t),e)}function lr(t,e){return function(n,r){var s=M(n)?$c:rl,a=e?e():{};return s(n,t,L(r,2),a)}}function rn(t){return K(function(e,n){var r=-1,s=n.length,a=s>1?n[s-1]:i,c=s>2?n[2]:i;for(a=t.length>3&&typeof a=="function"?(s--,a):i,c&&bt(n[0],n[1],c)&&(a=s<3?i:a,s=1),e=tt(e);++r<s;){var f=n[r];f&&t(e,f,r,a)}return e})}function Nu(t,e){return function(n,r){if(n==null)return n;if(!Ct(n))return t(n,r);for(var s=n.length,a=e?s:-1,c=tt(n);(e?a--:++a<s)&&r(c[a],a,c)!==!1;);return n}}function Fu(t){return function(e,n,r){for(var s=-1,a=tt(e),c=r(e),f=c.length;f--;){var p=c[t?f:++s];if(n(a[p],p,a)===!1)break}return e}}function Nl(t,e,n){var r=e&ft,s=In(t);function a(){var c=this&&this!==_t&&this instanceof a?s:t;return c.apply(r?n:this,arguments)}return a}function Mu(t){return function(e){e=Q(e);var n=Xe(e)?Vt(e):i,r=n?n[0]:e.charAt(0),s=n?Re(n,1).join(""):e.slice(1);return r[t]()+s}}function sn(t){return function(e){return ni(Na(Ua(e).replace(Pc,"")),t,"")}}function In(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var n=nn(t.prototype),r=t.apply(n,e);return st(r)?r:n}}function Fl(t,e,n){var r=In(t);function s(){for(var a=arguments.length,c=_(a),f=a,p=un(s);f--;)c[f]=arguments[f];var w=a<3&&c[0]!==p&&c[a-1]!==p?[]:xe(c,p);if(a-=w.length,a<n)return qu(t,e,hr,s.placeholder,i,c,w,i,i,n-a);var m=this&&this!==_t&&this instanceof s?r:t;return Ot(m,this,c)}return s}function $u(t){return function(e,n,r){var s=tt(e);if(!Ct(e)){var a=L(n,3);e=gt(e),n=function(f){return a(s[f],f,s)}}var c=t(e,n,r);return c>-1?s[a?e[c]:c]:i}}function Bu(t){return le(function(e){var n=e.length,r=n,s=Kt.prototype.thru;for(t&&e.reverse();r--;){var a=e[r];if(typeof a!="function")throw new kt(S);if(s&&!c&&_r(a)=="wrapper")var c=new Kt([],!0)}for(r=c?r:n;++r<n;){a=e[r];var f=_r(a),p=f=="wrapper"?Ni(a):i;p&&Bi(p[0])&&p[1]==(ht|V|yt|Oe)&&!p[4].length&&p[9]==1?c=c[_r(p[0])].apply(c,p[3]):c=a.length==1&&Bi(a)?c[f]():c.thru(a)}return function(){var w=arguments,m=w[0];if(c&&w.length==1&&M(m))return c.plant(m).value();for(var x=0,C=n?e[x].apply(this,w):m;++x<n;)C=e[x].call(this,C);return C}})}function hr(t,e,n,r,s,a,c,f,p,w){var m=e&ht,x=e&ft,C=e&ve,E=e&(V|se),D=e&hn,k=C?i:In(t);function W(){for(var H=arguments.length,z=_(H),Ut=H;Ut--;)z[Ut]=arguments[Ut];if(E)var At=un(W),Nt=Zc(z,At);if(r&&(z=Wu(z,r,s,E)),a&&(z=Uu(z,a,c,E)),H-=Nt,E&&H<w){var ct=xe(z,At);return qu(t,e,hr,W.placeholder,n,z,ct,f,p,w-H)}var ee=x?n:this,ge=C?ee[t]:t;return H=z.length,f?z=rh(z,f):D&&H>1&&z.reverse(),m&&p<H&&(z.length=p),this&&this!==_t&&this instanceof W&&(ge=k||In(ge)),ge.apply(ee,z)}return W}function ku(t,e){return function(n,r){return ll(n,t,e(r),{})}}function dr(t,e){return function(n,r){var s;if(n===i&&r===i)return e;if(n!==i&&(s=n),r!==i){if(s===i)return r;typeof n=="string"||typeof r=="string"?(n=Dt(n),r=Dt(r)):(n=Cu(n),r=Cu(r)),s=t(n,r)}return s}}function Li(t){return le(function(e){return e=it(e,Lt(L())),K(function(n){var r=this;return t(e,function(s){return Ot(s,r,n)})})})}function pr(t,e){e=e===i?" ":Dt(e);var n=e.length;if(n<2)return n?Pi(e,t):e;var r=Pi(e,tr(t/Qe(e)));return Xe(e)?Re(Vt(r),0,t).join(""):r.slice(0,t)}function Ml(t,e,n,r){var s=e&ft,a=In(t);function c(){for(var f=-1,p=arguments.length,w=-1,m=r.length,x=_(m+p),C=this&&this!==_t&&this instanceof c?a:t;++w<m;)x[w]=r[w];for(;p--;)x[w++]=arguments[++f];return Ot(C,s?n:this,x)}return c}function Ku(t){return function(e,n,r){return r&&typeof r!="number"&&bt(e,n,r)&&(n=r=i),e=pe(e),n===i?(n=e,e=0):n=pe(n),r=r===i?e<n?1:-1:pe(r),bl(e,n,r,t)}}function gr(t){return function(e,n){return typeof e=="string"&&typeof n=="string"||(e=zt(e),n=zt(n)),t(e,n)}}function qu(t,e,n,r,s,a,c,f,p,w){var m=e&V,x=m?c:i,C=m?i:c,E=m?a:i,D=m?i:a;e|=m?yt:Et,e&=~(m?Et:yt),e&Wn||(e&=-4);var k=[t,e,s,E,x,D,C,f,p,w],W=n.apply(i,k);return Bi(t)&&ea(W,k),W.placeholder=r,na(W,t,e)}function Di(t){var e=dt[t];return function(n,r){if(n=zt(n),r=r==null?0:mt($(r),292),r&&nu(n)){var s=(Q(n)+"e").split("e"),a=e(s[0]+"e"+(+s[1]+r));return s=(Q(a)+"e").split("e"),+(s[0]+"e"+(+s[1]-r))}return e(n)}}var $l=tn&&1/Hn(new tn([,-0]))[1]==Ft?function(t){return new tn(t)}:es;function Hu(t){return function(e){var n=St(e);return n==at?ci(e):n==Qt?ef(e):Jc(e,t(e))}}function fe(t,e,n,r,s,a,c,f){var p=e&ve;if(!p&&typeof t!="function")throw new kt(S);var w=r?r.length:0;if(w||(e&=-97,r=s=i),c=c===i?c:pt($(c),0),f=f===i?f:$(f),w-=s?s.length:0,e&Et){var m=r,x=s;r=s=i}var C=p?i:Ni(t),E=[t,e,n,r,s,m,x,a,c,f];if(C&&th(E,C),t=E[0],e=E[1],n=E[2],r=E[3],s=E[4],f=E[9]=E[9]===i?p?0:t.length:pt(E[9]-w,0),!f&&e&(V|se)&&(e&=-25),!e||e==ft)var D=Nl(t,e,n);else e==V||e==se?D=Fl(t,e,f):(e==yt||e==(ft|yt))&&!s.length?D=Ml(t,e,n,r):D=hr.apply(i,E);var k=C?Au:ea;return na(k(D,E),t,e)}function Gu(t,e,n,r){return t===i||te(t,je[n])&&!j.call(r,n)?e:t}function zu(t,e,n,r,s,a){return st(t)&&st(e)&&(a.set(e,t),or(t,e,i,zu,a),a.delete(e)),t}function Bl(t){return On(t)?i:t}function Ju(t,e,n,r,s,a){var c=n&T,f=t.length,p=e.length;if(f!=p&&!(c&&p>f))return!1;var w=a.get(t),m=a.get(e);if(w&&m)return w==e&&m==t;var x=-1,C=!0,E=n&Z?new Me:i;for(a.set(t,e),a.set(e,t);++x<f;){var D=t[x],k=e[x];if(r)var W=c?r(k,D,x,e,t,a):r(D,k,x,t,e,a);if(W!==i){if(W)continue;C=!1;break}if(E){if(!ri(e,function(H,z){if(!vn(E,z)&&(D===H||s(D,H,n,r,a)))return E.push(z)})){C=!1;break}}else if(!(D===k||s(D,k,n,r,a))){C=!1;break}}return a.delete(t),a.delete(e),C}function kl(t,e,n,r,s,a,c){switch(n){case Je:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case _n:return!(t.byteLength!=e.byteLength||!a(new Xn(t),new Xn(e)));case De:case We:case we:return te(+t,+e);case N:return t.name==e.name&&t.message==e.message;case dn:case pn:return t==e+"";case at:var f=ci;case Qt:var p=r&T;if(f||(f=Hn),t.size!=e.size&&!p)return!1;var w=c.get(t);if(w)return w==e;r|=Z,c.set(t,e);var m=Ju(f(t),f(e),r,s,a,c);return c.delete(t),m;case Mn:if(xn)return xn.call(t)==xn.call(e)}return!1}function Kl(t,e,n,r,s,a){var c=n&T,f=Wi(t),p=f.length,w=Wi(e),m=w.length;if(p!=m&&!c)return!1;for(var x=p;x--;){var C=f[x];if(!(c?C in e:j.call(e,C)))return!1}var E=a.get(t),D=a.get(e);if(E&&D)return E==e&&D==t;var k=!0;a.set(t,e),a.set(e,t);for(var W=c;++x<p;){C=f[x];var H=t[C],z=e[C];if(r)var Ut=c?r(z,H,C,e,t,a):r(H,z,C,t,e,a);if(!(Ut===i?H===z||s(H,z,n,r,a):Ut)){k=!1;break}W||(W=C=="constructor")}if(k&&!W){var At=t.constructor,Nt=e.constructor;At!=Nt&&"constructor"in t&&"constructor"in e&&!(typeof At=="function"&&At instanceof At&&typeof Nt=="function"&&Nt instanceof Nt)&&(k=!1)}return a.delete(t),a.delete(e),k}function le(t){return Ki(ju(t,i,oa),t+"")}function Wi(t){return du(t,gt,Mi)}function Ui(t){return du(t,Rt,Zu)}var Ni=nr?function(t){return nr.get(t)}:es;function _r(t){for(var e=t.name+"",n=en[e],r=j.call(en,e)?n.length:0;r--;){var s=n[r],a=s.func;if(a==null||a==t)return s.name}return e}function un(t){var e=j.call(u,"placeholder")?u:t;return e.placeholder}function L(){var t=u.iteratee||ji;return t=t===ji?_u:t,arguments.length?t(arguments[0],arguments[1]):t}function vr(t,e){var n=t.__data__;return Xl(e)?n[typeof e=="string"?"string":"hash"]:n.map}function Fi(t){for(var e=gt(t),n=e.length;n--;){var r=e[n],s=t[r];e[n]=[r,s,Qu(s)]}return e}function ke(t,e){var n=Vc(t,e);return gu(n)?n:i}function ql(t){var e=j.call(t,Ne),n=t[Ne];try{t[Ne]=i;var r=!0}catch{}var s=Zn.call(t);return r&&(e?t[Ne]=n:delete t[Ne]),s}var Mi=li?function(t){return t==null?[]:(t=tt(t),me(li(t),function(e){return tu.call(t,e)}))}:ns,Zu=li?function(t){for(var e=[];t;)Se(e,Mi(t)),t=Qn(t);return e}:ns,St=xt;(hi&&St(new hi(new ArrayBuffer(1)))!=Je||wn&&St(new wn)!=at||di&&St(di.resolve())!=fs||tn&&St(new tn)!=Qt||mn&&St(new mn)!=gn)&&(St=function(t){var e=xt(t),n=e==ue?t.constructor:i,r=n?Ke(n):"";if(r)switch(r){case Pf:return Je;case Cf:return at;case Rf:return fs;case If:return Qt;case Ef:return gn}return e});function Hl(t,e,n){for(var r=-1,s=n.length;++r<s;){var a=n[r],c=a.size;switch(a.type){case"drop":t+=c;break;case"dropRight":e-=c;break;case"take":e=mt(e,t+c);break;case"takeRight":t=pt(t,e-c);break}}return{start:t,end:e}}function Gl(t){var e=t.match(Xo);return e?e[1].split(Qo):[]}function Yu(t,e,n){e=Ce(e,t);for(var r=-1,s=e.length,a=!1;++r<s;){var c=ie(e[r]);if(!(a=t!=null&&n(t,c)))break;t=t[c]}return a||++r!=s?a:(s=t==null?0:t.length,!!s&&Ar(s)&&he(c,s)&&(M(t)||qe(t)))}function zl(t){var e=t.length,n=new t.constructor(e);return e&&typeof t[0]=="string"&&j.call(t,"index")&&(n.index=t.index,n.input=t.input),n}function Xu(t){return typeof t.constructor=="function"&&!En(t)?nn(Qn(t)):{}}function Jl(t,e,n){var r=t.constructor;switch(e){case _n:return Oi(t);case De:case We:return new r(+t);case Je:return Tl(t,n);case Fr:case Mr:case $r:case Br:case kr:case Kr:case qr:case Hr:case Gr:return Lu(t,n);case at:return new r;case we:case pn:return new r(t);case dn:return Ol(t);case Qt:return new r;case Mn:return Ll(t)}}function Zl(t,e){var n=e.length;if(!n)return t;var r=n-1;return e[r]=(n>1?"& ":"")+e[r],e=e.join(n>2?", ":" "),t.replace(Yo,`{
|
|
9
|
+
/* [wrapped with `+e+`] */
|
|
10
|
+
`)}function Yl(t){return M(t)||qe(t)||!!(eu&&t&&t[eu])}function he(t,e){var n=typeof t;return e=e??Yt,!!e&&(n=="number"||n!="symbol"&&uc.test(t))&&t>-1&&t%1==0&&t<e}function bt(t,e,n){if(!st(n))return!1;var r=typeof e;return(r=="number"?Ct(n)&&he(e,n.length):r=="string"&&e in n)?te(n[e],t):!1}function $i(t,e){if(M(t))return!1;var n=typeof t;return n=="number"||n=="symbol"||n=="boolean"||t==null||Wt(t)?!0:Go.test(t)||!Ho.test(t)||e!=null&&t in tt(e)}function Xl(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Bi(t){var e=_r(t),n=u[e];if(typeof n!="function"||!(e in G.prototype))return!1;if(t===n)return!0;var r=Ni(n);return!!r&&t===r[0]}function Ql(t){return!!Qs&&Qs in t}var Vl=zn?de:rs;function En(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||je;return t===n}function Qu(t){return t===t&&!st(t)}function Vu(t,e){return function(n){return n==null?!1:n[t]===e&&(e!==i||t in tt(n))}}function jl(t){var e=xr(t,function(r){return n.size===B&&n.clear(),r}),n=e.cache;return e}function th(t,e){var n=t[1],r=e[1],s=n|r,a=s<(ft|ve|ht),c=r==ht&&n==V||r==ht&&n==Oe&&t[7].length<=e[8]||r==(ht|Oe)&&e[7].length<=e[8]&&n==V;if(!(a||c))return t;r&ft&&(t[2]=e[2],s|=n&ft?0:Wn);var f=e[3];if(f){var p=t[3];t[3]=p?Wu(p,f,e[4]):f,t[4]=p?xe(t[3],X):e[4]}return f=e[5],f&&(p=t[5],t[5]=p?Uu(p,f,e[6]):f,t[6]=p?xe(t[5],X):e[6]),f=e[7],f&&(t[7]=f),r&ht&&(t[8]=t[8]==null?e[8]:mt(t[8],e[8])),t[9]==null&&(t[9]=e[9]),t[0]=e[0],t[1]=s,t}function eh(t){var e=[];if(t!=null)for(var n in tt(t))e.push(n);return e}function nh(t){return Zn.call(t)}function ju(t,e,n){return e=pt(e===i?t.length-1:e,0),function(){for(var r=arguments,s=-1,a=pt(r.length-e,0),c=_(a);++s<a;)c[s]=r[e+s];s=-1;for(var f=_(e+1);++s<e;)f[s]=r[s];return f[e]=n(c),Ot(t,this,f)}}function ta(t,e){return e.length<2?t:Be(t,Ht(e,0,-1))}function rh(t,e){for(var n=t.length,r=mt(e.length,n),s=Pt(t);r--;){var a=e[r];t[r]=he(a,n)?s[a]:i}return t}function ki(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var ea=ra(Au),Tn=yf||function(t,e){return _t.setTimeout(t,e)},Ki=ra(Cl);function na(t,e,n){var r=e+"";return Ki(t,Zl(r,ih(Gl(r),n)))}function ra(t){var e=0,n=0;return function(){var r=xf(),s=Nn-(r-n);if(n=r,s>0){if(++e>=Zt)return arguments[0]}else e=0;return t.apply(i,arguments)}}function yr(t,e){var n=-1,r=t.length,s=r-1;for(e=e===i?r:e;++n<e;){var a=Ai(n,s),c=t[a];t[a]=t[n],t[n]=c}return t.length=e,t}var ia=jl(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(zo,function(n,r,s,a){e.push(s?a.replace(tc,"$1"):r||n)}),e});function ie(t){if(typeof t=="string"||Wt(t))return t;var e=t+"";return e=="0"&&1/t==-Ft?"-0":e}function Ke(t){if(t!=null){try{return Jn.call(t)}catch{}try{return t+""}catch{}}return""}function ih(t,e){return Bt(Wr,function(n){var r="_."+n[0];e&n[1]&&!Kn(t,r)&&t.push(r)}),t.sort()}function sa(t){if(t instanceof G)return t.clone();var e=new Kt(t.__wrapped__,t.__chain__);return e.__actions__=Pt(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}function sh(t,e,n){(n?bt(t,e,n):e===i)?e=1:e=pt($(e),0);var r=t==null?0:t.length;if(!r||e<1)return[];for(var s=0,a=0,c=_(tr(r/e));s<r;)c[a++]=Ht(t,s,s+=e);return c}function uh(t){for(var e=-1,n=t==null?0:t.length,r=0,s=[];++e<n;){var a=t[e];a&&(s[r++]=a)}return s}function ah(){var t=arguments.length;if(!t)return[];for(var e=_(t-1),n=arguments[0],r=t;r--;)e[r-1]=arguments[r];return Se(M(n)?Pt(n):[n],vt(e,1))}var oh=K(function(t,e){return ot(t)?An(t,vt(e,1,ot,!0)):[]}),ch=K(function(t,e){var n=Gt(e);return ot(n)&&(n=i),ot(t)?An(t,vt(e,1,ot,!0),L(n,2)):[]}),fh=K(function(t,e){var n=Gt(e);return ot(n)&&(n=i),ot(t)?An(t,vt(e,1,ot,!0),i,n):[]});function lh(t,e,n){var r=t==null?0:t.length;return r?(e=n||e===i?1:$(e),Ht(t,e<0?0:e,r)):[]}function hh(t,e,n){var r=t==null?0:t.length;return r?(e=n||e===i?1:$(e),e=r-e,Ht(t,0,e<0?0:e)):[]}function dh(t,e){return t&&t.length?fr(t,L(e,3),!0,!0):[]}function ph(t,e){return t&&t.length?fr(t,L(e,3),!0):[]}function gh(t,e,n,r){var s=t==null?0:t.length;return s?(n&&typeof n!="number"&&bt(t,e,n)&&(n=0,r=s),al(t,e,n,r)):[]}function ua(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var s=n==null?0:$(n);return s<0&&(s=pt(r+s,0)),qn(t,L(e,3),s)}function aa(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var s=r-1;return n!==i&&(s=$(n),s=n<0?pt(r+s,0):mt(s,r-1)),qn(t,L(e,3),s,!0)}function oa(t){var e=t==null?0:t.length;return e?vt(t,1):[]}function _h(t){var e=t==null?0:t.length;return e?vt(t,Ft):[]}function vh(t,e){var n=t==null?0:t.length;return n?(e=e===i?1:$(e),vt(t,e)):[]}function yh(t){for(var e=-1,n=t==null?0:t.length,r={};++e<n;){var s=t[e];r[s[0]]=s[1]}return r}function ca(t){return t&&t.length?t[0]:i}function wh(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var s=n==null?0:$(n);return s<0&&(s=pt(r+s,0)),Ye(t,e,s)}function mh(t){var e=t==null?0:t.length;return e?Ht(t,0,-1):[]}var Sh=K(function(t){var e=it(t,Ei);return e.length&&e[0]===t[0]?wi(e):[]}),xh=K(function(t){var e=Gt(t),n=it(t,Ei);return e===Gt(n)?e=i:n.pop(),n.length&&n[0]===t[0]?wi(n,L(e,2)):[]}),bh=K(function(t){var e=Gt(t),n=it(t,Ei);return e=typeof e=="function"?e:i,e&&n.pop(),n.length&&n[0]===t[0]?wi(n,i,e):[]});function Ah(t,e){return t==null?"":mf.call(t,e)}function Gt(t){var e=t==null?0:t.length;return e?t[e-1]:i}function Ph(t,e,n){var r=t==null?0:t.length;if(!r)return-1;var s=r;return n!==i&&(s=$(n),s=s<0?pt(r+s,0):mt(s,r-1)),e===e?rf(t,e,s):qn(t,qs,s,!0)}function Ch(t,e){return t&&t.length?mu(t,$(e)):i}var Rh=K(fa);function fa(t,e){return t&&t.length&&e&&e.length?bi(t,e):t}function Ih(t,e,n){return t&&t.length&&e&&e.length?bi(t,e,L(n,2)):t}function Eh(t,e,n){return t&&t.length&&e&&e.length?bi(t,e,i,n):t}var Th=le(function(t,e){var n=t==null?0:t.length,r=gi(t,e);return bu(t,it(e,function(s){return he(s,n)?+s:s}).sort(Du)),r});function Oh(t,e){var n=[];if(!(t&&t.length))return n;var r=-1,s=[],a=t.length;for(e=L(e,3);++r<a;){var c=t[r];e(c,r,t)&&(n.push(c),s.push(r))}return bu(t,s),n}function qi(t){return t==null?t:Af.call(t)}function Lh(t,e,n){var r=t==null?0:t.length;return r?(n&&typeof n!="number"&&bt(t,e,n)?(e=0,n=r):(e=e==null?0:$(e),n=n===i?r:$(n)),Ht(t,e,n)):[]}function Dh(t,e){return cr(t,e)}function Wh(t,e,n){return Ci(t,e,L(n,2))}function Uh(t,e){var n=t==null?0:t.length;if(n){var r=cr(t,e);if(r<n&&te(t[r],e))return r}return-1}function Nh(t,e){return cr(t,e,!0)}function Fh(t,e,n){return Ci(t,e,L(n,2),!0)}function Mh(t,e){var n=t==null?0:t.length;if(n){var r=cr(t,e,!0)-1;if(te(t[r],e))return r}return-1}function $h(t){return t&&t.length?Pu(t):[]}function Bh(t,e){return t&&t.length?Pu(t,L(e,2)):[]}function kh(t){var e=t==null?0:t.length;return e?Ht(t,1,e):[]}function Kh(t,e,n){return t&&t.length?(e=n||e===i?1:$(e),Ht(t,0,e<0?0:e)):[]}function qh(t,e,n){var r=t==null?0:t.length;return r?(e=n||e===i?1:$(e),e=r-e,Ht(t,e<0?0:e,r)):[]}function Hh(t,e){return t&&t.length?fr(t,L(e,3),!1,!0):[]}function Gh(t,e){return t&&t.length?fr(t,L(e,3)):[]}var zh=K(function(t){return Pe(vt(t,1,ot,!0))}),Jh=K(function(t){var e=Gt(t);return ot(e)&&(e=i),Pe(vt(t,1,ot,!0),L(e,2))}),Zh=K(function(t){var e=Gt(t);return e=typeof e=="function"?e:i,Pe(vt(t,1,ot,!0),i,e)});function Yh(t){return t&&t.length?Pe(t):[]}function Xh(t,e){return t&&t.length?Pe(t,L(e,2)):[]}function Qh(t,e){return e=typeof e=="function"?e:i,t&&t.length?Pe(t,i,e):[]}function Hi(t){if(!(t&&t.length))return[];var e=0;return t=me(t,function(n){if(ot(n))return e=pt(n.length,e),!0}),ai(e,function(n){return it(t,ii(n))})}function la(t,e){if(!(t&&t.length))return[];var n=Hi(t);return e==null?n:it(n,function(r){return Ot(e,i,r)})}var Vh=K(function(t,e){return ot(t)?An(t,e):[]}),jh=K(function(t){return Ii(me(t,ot))}),td=K(function(t){var e=Gt(t);return ot(e)&&(e=i),Ii(me(t,ot),L(e,2))}),ed=K(function(t){var e=Gt(t);return e=typeof e=="function"?e:i,Ii(me(t,ot),i,e)}),nd=K(Hi);function rd(t,e){return Eu(t||[],e||[],bn)}function id(t,e){return Eu(t||[],e||[],Rn)}var sd=K(function(t){var e=t.length,n=e>1?t[e-1]:i;return n=typeof n=="function"?(t.pop(),n):i,la(t,n)});function ha(t){var e=u(t);return e.__chain__=!0,e}function ud(t,e){return e(t),t}function wr(t,e){return e(t)}var ad=le(function(t){var e=t.length,n=e?t[0]:0,r=this.__wrapped__,s=function(a){return gi(a,t)};return e>1||this.__actions__.length||!(r instanceof G)||!he(n)?this.thru(s):(r=r.slice(n,+n+(e?1:0)),r.__actions__.push({func:wr,args:[s],thisArg:i}),new Kt(r,this.__chain__).thru(function(a){return e&&!a.length&&a.push(i),a}))});function od(){return ha(this)}function cd(){return new Kt(this.value(),this.__chain__)}function fd(){this.__values__===i&&(this.__values__=Ca(this.value()));var t=this.__index__>=this.__values__.length,e=t?i:this.__values__[this.__index__++];return{done:t,value:e}}function ld(){return this}function hd(t){for(var e,n=this;n instanceof ir;){var r=sa(n);r.__index__=0,r.__values__=i,e?s.__wrapped__=r:e=r;var s=r;n=n.__wrapped__}return s.__wrapped__=t,e}function dd(){var t=this.__wrapped__;if(t instanceof G){var e=t;return this.__actions__.length&&(e=new G(this)),e=e.reverse(),e.__actions__.push({func:wr,args:[qi],thisArg:i}),new Kt(e,this.__chain__)}return this.thru(qi)}function pd(){return Iu(this.__wrapped__,this.__actions__)}var gd=lr(function(t,e,n){j.call(t,n)?++t[n]:ce(t,n,1)});function _d(t,e,n){var r=M(t)?ks:ul;return n&&bt(t,e,n)&&(e=i),r(t,L(e,3))}function vd(t,e){var n=M(t)?me:lu;return n(t,L(e,3))}var yd=$u(ua),wd=$u(aa);function md(t,e){return vt(mr(t,e),1)}function Sd(t,e){return vt(mr(t,e),Ft)}function xd(t,e,n){return n=n===i?1:$(n),vt(mr(t,e),n)}function da(t,e){var n=M(t)?Bt:Ae;return n(t,L(e,3))}function pa(t,e){var n=M(t)?Bc:fu;return n(t,L(e,3))}var bd=lr(function(t,e,n){j.call(t,n)?t[n].push(e):ce(t,n,[e])});function Ad(t,e,n,r){t=Ct(t)?t:on(t),n=n&&!r?$(n):0;var s=t.length;return n<0&&(n=pt(s+n,0)),Pr(t)?n<=s&&t.indexOf(e,n)>-1:!!s&&Ye(t,e,n)>-1}var Pd=K(function(t,e,n){var r=-1,s=typeof e=="function",a=Ct(t)?_(t.length):[];return Ae(t,function(c){a[++r]=s?Ot(e,c,n):Pn(c,e,n)}),a}),Cd=lr(function(t,e,n){ce(t,n,e)});function mr(t,e){var n=M(t)?it:vu;return n(t,L(e,3))}function Rd(t,e,n,r){return t==null?[]:(M(e)||(e=e==null?[]:[e]),n=r?i:n,M(n)||(n=n==null?[]:[n]),Su(t,e,n))}var Id=lr(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]});function Ed(t,e,n){var r=M(t)?ni:Gs,s=arguments.length<3;return r(t,L(e,4),n,s,Ae)}function Td(t,e,n){var r=M(t)?kc:Gs,s=arguments.length<3;return r(t,L(e,4),n,s,fu)}function Od(t,e){var n=M(t)?me:lu;return n(t,br(L(e,3)))}function Ld(t){var e=M(t)?uu:Al;return e(t)}function Dd(t,e,n){(n?bt(t,e,n):e===i)?e=1:e=$(e);var r=M(t)?el:Pl;return r(t,e)}function Wd(t){var e=M(t)?nl:Rl;return e(t)}function Ud(t){if(t==null)return 0;if(Ct(t))return Pr(t)?Qe(t):t.length;var e=St(t);return e==at||e==Qt?t.size:Si(t).length}function Nd(t,e,n){var r=M(t)?ri:Il;return n&&bt(t,e,n)&&(e=i),r(t,L(e,3))}var Fd=K(function(t,e){if(t==null)return[];var n=e.length;return n>1&&bt(t,e[0],e[1])?e=[]:n>2&&bt(e[0],e[1],e[2])&&(e=[e[0]]),Su(t,vt(e,1),[])}),Sr=vf||function(){return _t.Date.now()};function Md(t,e){if(typeof e!="function")throw new kt(S);return t=$(t),function(){if(--t<1)return e.apply(this,arguments)}}function ga(t,e,n){return e=n?i:e,e=t&&e==null?t.length:e,fe(t,ht,i,i,i,i,e)}function _a(t,e){var n;if(typeof e!="function")throw new kt(S);return t=$(t),function(){return--t>0&&(n=e.apply(this,arguments)),t<=1&&(e=i),n}}var Gi=K(function(t,e,n){var r=ft;if(n.length){var s=xe(n,un(Gi));r|=yt}return fe(t,r,e,n,s)}),va=K(function(t,e,n){var r=ft|ve;if(n.length){var s=xe(n,un(va));r|=yt}return fe(e,r,t,n,s)});function ya(t,e,n){e=n?i:e;var r=fe(t,V,i,i,i,i,i,e);return r.placeholder=ya.placeholder,r}function wa(t,e,n){e=n?i:e;var r=fe(t,se,i,i,i,i,i,e);return r.placeholder=wa.placeholder,r}function ma(t,e,n){var r,s,a,c,f,p,w=0,m=!1,x=!1,C=!0;if(typeof t!="function")throw new kt(S);e=zt(e)||0,st(n)&&(m=!!n.leading,x="maxWait"in n,a=x?pt(zt(n.maxWait)||0,e):a,C="trailing"in n?!!n.trailing:C);function E(ct){var ee=r,ge=s;return r=s=i,w=ct,c=t.apply(ge,ee),c}function D(ct){return w=ct,f=Tn(H,e),m?E(ct):c}function k(ct){var ee=ct-p,ge=ct-w,$a=e-ee;return x?mt($a,a-ge):$a}function W(ct){var ee=ct-p,ge=ct-w;return p===i||ee>=e||ee<0||x&&ge>=a}function H(){var ct=Sr();if(W(ct))return z(ct);f=Tn(H,k(ct))}function z(ct){return f=i,C&&r?E(ct):(r=s=i,c)}function Ut(){f!==i&&Tu(f),w=0,r=p=s=f=i}function At(){return f===i?c:z(Sr())}function Nt(){var ct=Sr(),ee=W(ct);if(r=arguments,s=this,p=ct,ee){if(f===i)return D(p);if(x)return Tu(f),f=Tn(H,e),E(p)}return f===i&&(f=Tn(H,e)),c}return Nt.cancel=Ut,Nt.flush=At,Nt}var $d=K(function(t,e){return cu(t,1,e)}),Bd=K(function(t,e,n){return cu(t,zt(e)||0,n)});function kd(t){return fe(t,hn)}function xr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new kt(S);var n=function(){var r=arguments,s=e?e.apply(this,r):r[0],a=n.cache;if(a.has(s))return a.get(s);var c=t.apply(this,r);return n.cache=a.set(s,c)||a,c};return n.cache=new(xr.Cache||oe),n}xr.Cache=oe;function br(t){if(typeof t!="function")throw new kt(S);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function Kd(t){return _a(2,t)}var qd=El(function(t,e){e=e.length==1&&M(e[0])?it(e[0],Lt(L())):it(vt(e,1),Lt(L()));var n=e.length;return K(function(r){for(var s=-1,a=mt(r.length,n);++s<a;)r[s]=e[s].call(this,r[s]);return Ot(t,this,r)})}),zi=K(function(t,e){var n=xe(e,un(zi));return fe(t,yt,i,e,n)}),Sa=K(function(t,e){var n=xe(e,un(Sa));return fe(t,Et,i,e,n)}),Hd=le(function(t,e){return fe(t,Oe,i,i,i,e)});function Gd(t,e){if(typeof t!="function")throw new kt(S);return e=e===i?e:$(e),K(t,e)}function zd(t,e){if(typeof t!="function")throw new kt(S);return e=e==null?0:pt($(e),0),K(function(n){var r=n[e],s=Re(n,0,e);return r&&Se(s,r),Ot(t,this,s)})}function Jd(t,e,n){var r=!0,s=!0;if(typeof t!="function")throw new kt(S);return st(n)&&(r="leading"in n?!!n.leading:r,s="trailing"in n?!!n.trailing:s),ma(t,e,{leading:r,maxWait:e,trailing:s})}function Zd(t){return ga(t,1)}function Yd(t,e){return zi(Ti(e),t)}function Xd(){if(!arguments.length)return[];var t=arguments[0];return M(t)?t:[t]}function Qd(t){return qt(t,A)}function Vd(t,e){return e=typeof e=="function"?e:i,qt(t,A,e)}function jd(t){return qt(t,P|A)}function tp(t,e){return e=typeof e=="function"?e:i,qt(t,P|A,e)}function ep(t,e){return e==null||ou(t,e,gt(e))}function te(t,e){return t===e||t!==t&&e!==e}var np=gr(yi),rp=gr(function(t,e){return t>=e}),qe=pu(function(){return arguments}())?pu:function(t){return ut(t)&&j.call(t,"callee")&&!tu.call(t,"callee")},M=_.isArray,ip=Us?Lt(Us):hl;function Ct(t){return t!=null&&Ar(t.length)&&!de(t)}function ot(t){return ut(t)&&Ct(t)}function sp(t){return t===!0||t===!1||ut(t)&&xt(t)==De}var Ie=wf||rs,up=Ns?Lt(Ns):dl;function ap(t){return ut(t)&&t.nodeType===1&&!On(t)}function op(t){if(t==null)return!0;if(Ct(t)&&(M(t)||typeof t=="string"||typeof t.splice=="function"||Ie(t)||an(t)||qe(t)))return!t.length;var e=St(t);if(e==at||e==Qt)return!t.size;if(En(t))return!Si(t).length;for(var n in t)if(j.call(t,n))return!1;return!0}function cp(t,e){return Cn(t,e)}function fp(t,e,n){n=typeof n=="function"?n:i;var r=n?n(t,e):i;return r===i?Cn(t,e,i,n):!!r}function Ji(t){if(!ut(t))return!1;var e=xt(t);return e==N||e==Nr||typeof t.message=="string"&&typeof t.name=="string"&&!On(t)}function lp(t){return typeof t=="number"&&nu(t)}function de(t){if(!st(t))return!1;var e=xt(t);return e==et||e==wt||e==Ur||e==Wo}function xa(t){return typeof t=="number"&&t==$(t)}function Ar(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Yt}function st(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}function ut(t){return t!=null&&typeof t=="object"}var ba=Fs?Lt(Fs):gl;function hp(t,e){return t===e||mi(t,e,Fi(e))}function dp(t,e,n){return n=typeof n=="function"?n:i,mi(t,e,Fi(e),n)}function pp(t){return Aa(t)&&t!=+t}function gp(t){if(Vl(t))throw new F(v);return gu(t)}function _p(t){return t===null}function vp(t){return t==null}function Aa(t){return typeof t=="number"||ut(t)&&xt(t)==we}function On(t){if(!ut(t)||xt(t)!=ue)return!1;var e=Qn(t);if(e===null)return!0;var n=j.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&Jn.call(n)==df}var Zi=Ms?Lt(Ms):_l;function yp(t){return xa(t)&&t>=-Yt&&t<=Yt}var Pa=$s?Lt($s):vl;function Pr(t){return typeof t=="string"||!M(t)&&ut(t)&&xt(t)==pn}function Wt(t){return typeof t=="symbol"||ut(t)&&xt(t)==Mn}var an=Bs?Lt(Bs):yl;function wp(t){return t===i}function mp(t){return ut(t)&&St(t)==gn}function Sp(t){return ut(t)&&xt(t)==No}var xp=gr(xi),bp=gr(function(t,e){return t<=e});function Ca(t){if(!t)return[];if(Ct(t))return Pr(t)?Vt(t):Pt(t);if(yn&&t[yn])return tf(t[yn]());var e=St(t),n=e==at?ci:e==Qt?Hn:on;return n(t)}function pe(t){if(!t)return t===0?t:0;if(t=zt(t),t===Ft||t===-Ft){var e=t<0?-1:1;return e*lt}return t===t?t:0}function $(t){var e=pe(t),n=e%1;return e===e?n?e-n:e:0}function Ra(t){return t?$e($(t),0,Mt):0}function zt(t){if(typeof t=="number")return t;if(Wt(t))return ze;if(st(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=st(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=zs(t);var n=rc.test(t);return n||sc.test(t)?Fc(t.slice(2),n?2:8):nc.test(t)?ze:+t}function Ia(t){return re(t,Rt(t))}function Ap(t){return t?$e($(t),-Yt,Yt):t===0?t:0}function Q(t){return t==null?"":Dt(t)}var Pp=rn(function(t,e){if(En(e)||Ct(e)){re(e,gt(e),t);return}for(var n in e)j.call(e,n)&&bn(t,n,e[n])}),Ea=rn(function(t,e){re(e,Rt(e),t)}),Cr=rn(function(t,e,n,r){re(e,Rt(e),t,r)}),Cp=rn(function(t,e,n,r){re(e,gt(e),t,r)}),Rp=le(gi);function Ip(t,e){var n=nn(t);return e==null?n:au(n,e)}var Ep=K(function(t,e){t=tt(t);var n=-1,r=e.length,s=r>2?e[2]:i;for(s&&bt(e[0],e[1],s)&&(r=1);++n<r;)for(var a=e[n],c=Rt(a),f=-1,p=c.length;++f<p;){var w=c[f],m=t[w];(m===i||te(m,je[w])&&!j.call(t,w))&&(t[w]=a[w])}return t}),Tp=K(function(t){return t.push(i,zu),Ot(Ta,i,t)});function Op(t,e){return Ks(t,L(e,3),ne)}function Lp(t,e){return Ks(t,L(e,3),vi)}function Dp(t,e){return t==null?t:_i(t,L(e,3),Rt)}function Wp(t,e){return t==null?t:hu(t,L(e,3),Rt)}function Up(t,e){return t&&ne(t,L(e,3))}function Np(t,e){return t&&vi(t,L(e,3))}function Fp(t){return t==null?[]:ar(t,gt(t))}function Mp(t){return t==null?[]:ar(t,Rt(t))}function Yi(t,e,n){var r=t==null?i:Be(t,e);return r===i?n:r}function $p(t,e){return t!=null&&Yu(t,e,ol)}function Xi(t,e){return t!=null&&Yu(t,e,cl)}var Bp=ku(function(t,e,n){e!=null&&typeof e.toString!="function"&&(e=Zn.call(e)),t[e]=n},Vi(It)),kp=ku(function(t,e,n){e!=null&&typeof e.toString!="function"&&(e=Zn.call(e)),j.call(t,e)?t[e].push(n):t[e]=[n]},L),Kp=K(Pn);function gt(t){return Ct(t)?su(t):Si(t)}function Rt(t){return Ct(t)?su(t,!0):wl(t)}function qp(t,e){var n={};return e=L(e,3),ne(t,function(r,s,a){ce(n,e(r,s,a),r)}),n}function Hp(t,e){var n={};return e=L(e,3),ne(t,function(r,s,a){ce(n,s,e(r,s,a))}),n}var Gp=rn(function(t,e,n){or(t,e,n)}),Ta=rn(function(t,e,n,r){or(t,e,n,r)}),zp=le(function(t,e){var n={};if(t==null)return n;var r=!1;e=it(e,function(a){return a=Ce(a,t),r||(r=a.length>1),a}),re(t,Ui(t),n),r&&(n=qt(n,P|U|A,Bl));for(var s=e.length;s--;)Ri(n,e[s]);return n});function Jp(t,e){return Oa(t,br(L(e)))}var Zp=le(function(t,e){return t==null?{}:Sl(t,e)});function Oa(t,e){if(t==null)return{};var n=it(Ui(t),function(r){return[r]});return e=L(e),xu(t,n,function(r,s){return e(r,s[0])})}function Yp(t,e,n){e=Ce(e,t);var r=-1,s=e.length;for(s||(s=1,t=i);++r<s;){var a=t==null?i:t[ie(e[r])];a===i&&(r=s,a=n),t=de(a)?a.call(t):a}return t}function Xp(t,e,n){return t==null?t:Rn(t,e,n)}function Qp(t,e,n,r){return r=typeof r=="function"?r:i,t==null?t:Rn(t,e,n,r)}var La=Hu(gt),Da=Hu(Rt);function Vp(t,e,n){var r=M(t),s=r||Ie(t)||an(t);if(e=L(e,4),n==null){var a=t&&t.constructor;s?n=r?new a:[]:st(t)?n=de(a)?nn(Qn(t)):{}:n={}}return(s?Bt:ne)(t,function(c,f,p){return e(n,c,f,p)}),n}function jp(t,e){return t==null?!0:Ri(t,e)}function tg(t,e,n){return t==null?t:Ru(t,e,Ti(n))}function eg(t,e,n,r){return r=typeof r=="function"?r:i,t==null?t:Ru(t,e,Ti(n),r)}function on(t){return t==null?[]:oi(t,gt(t))}function ng(t){return t==null?[]:oi(t,Rt(t))}function rg(t,e,n){return n===i&&(n=e,e=i),n!==i&&(n=zt(n),n=n===n?n:0),e!==i&&(e=zt(e),e=e===e?e:0),$e(zt(t),e,n)}function ig(t,e,n){return e=pe(e),n===i?(n=e,e=0):n=pe(n),t=zt(t),fl(t,e,n)}function sg(t,e,n){if(n&&typeof n!="boolean"&&bt(t,e,n)&&(e=n=i),n===i&&(typeof e=="boolean"?(n=e,e=i):typeof t=="boolean"&&(n=t,t=i)),t===i&&e===i?(t=0,e=1):(t=pe(t),e===i?(e=t,t=0):e=pe(e)),t>e){var r=t;t=e,e=r}if(n||t%1||e%1){var s=ru();return mt(t+s*(e-t+Nc("1e-"+((s+"").length-1))),e)}return Ai(t,e)}var ug=sn(function(t,e,n){return e=e.toLowerCase(),t+(n?Wa(e):e)});function Wa(t){return Qi(Q(t).toLowerCase())}function Ua(t){return t=Q(t),t&&t.replace(ac,Yc).replace(Cc,"")}function ag(t,e,n){t=Q(t),e=Dt(e);var r=t.length;n=n===i?r:$e($(n),0,r);var s=n;return n-=e.length,n>=0&&t.slice(n,s)==e}function og(t){return t=Q(t),t&&ko.test(t)?t.replace(hs,Xc):t}function cg(t){return t=Q(t),t&&Jo.test(t)?t.replace(zr,"\\$&"):t}var fg=sn(function(t,e,n){return t+(n?"-":"")+e.toLowerCase()}),lg=sn(function(t,e,n){return t+(n?" ":"")+e.toLowerCase()}),hg=Mu("toLowerCase");function dg(t,e,n){t=Q(t),e=$(e);var r=e?Qe(t):0;if(!e||r>=e)return t;var s=(e-r)/2;return pr(er(s),n)+t+pr(tr(s),n)}function pg(t,e,n){t=Q(t),e=$(e);var r=e?Qe(t):0;return e&&r<e?t+pr(e-r,n):t}function gg(t,e,n){t=Q(t),e=$(e);var r=e?Qe(t):0;return e&&r<e?pr(e-r,n)+t:t}function _g(t,e,n){return n||e==null?e=0:e&&(e=+e),bf(Q(t).replace(Jr,""),e||0)}function vg(t,e,n){return(n?bt(t,e,n):e===i)?e=1:e=$(e),Pi(Q(t),e)}function yg(){var t=arguments,e=Q(t[0]);return t.length<3?e:e.replace(t[1],t[2])}var wg=sn(function(t,e,n){return t+(n?"_":"")+e.toLowerCase()});function mg(t,e,n){return n&&typeof n!="number"&&bt(t,e,n)&&(e=n=i),n=n===i?Mt:n>>>0,n?(t=Q(t),t&&(typeof e=="string"||e!=null&&!Zi(e))&&(e=Dt(e),!e&&Xe(t))?Re(Vt(t),0,n):t.split(e,n)):[]}var Sg=sn(function(t,e,n){return t+(n?" ":"")+Qi(e)});function xg(t,e,n){return t=Q(t),n=n==null?0:$e($(n),0,t.length),e=Dt(e),t.slice(n,n+e.length)==e}function bg(t,e,n){var r=u.templateSettings;n&&bt(t,e,n)&&(e=i),t=Q(t),e=Cr({},e,r,Gu);var s=Cr({},e.imports,r.imports,Gu),a=gt(s),c=oi(s,a),f,p,w=0,m=e.interpolate||$n,x="__p += '",C=fi((e.escape||$n).source+"|"+m.source+"|"+(m===ds?ec:$n).source+"|"+(e.evaluate||$n).source+"|$","g"),E="//# sourceURL="+(j.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Oc+"]")+`
|
|
11
|
+
`;t.replace(C,function(W,H,z,Ut,At,Nt){return z||(z=Ut),x+=t.slice(w,Nt).replace(oc,Qc),H&&(f=!0,x+=`' +
|
|
12
12
|
__e(`+H+`) +
|
|
13
|
-
'`),
|
|
14
|
-
`+
|
|
15
|
-
__p += '`),
|
|
16
|
-
((__t = (`+
|
|
17
|
-
'`),
|
|
18
|
-
`;var
|
|
19
|
-
`+
|
|
13
|
+
'`),At&&(p=!0,x+=`';
|
|
14
|
+
`+At+`;
|
|
15
|
+
__p += '`),z&&(x+=`' +
|
|
16
|
+
((__t = (`+z+`)) == null ? '' : __t) +
|
|
17
|
+
'`),w=Nt+W.length,W}),x+=`';
|
|
18
|
+
`;var D=j.call(e,"variable")&&e.variable;if(!D)x=`with (obj) {
|
|
19
|
+
`+x+`
|
|
20
20
|
}
|
|
21
|
-
`;else if(
|
|
22
|
-
`+(
|
|
23
|
-
`)+"var __t, __p = ''"+(
|
|
21
|
+
`;else if(jo.test(D))throw new F(I);x=(p?x.replace(Fo,""):x).replace(Mo,"$1").replace($o,"$1;"),x="function("+(D||"obj")+`) {
|
|
22
|
+
`+(D?"":`obj || (obj = {});
|
|
23
|
+
`)+"var __t, __p = ''"+(f?", __e = _.escape":"")+(p?`, __j = Array.prototype.join;
|
|
24
24
|
function print() { __p += __j.call(arguments, '') }
|
|
25
25
|
`:`;
|
|
26
|
-
`)+
|
|
27
|
-
}`;var M=No(function(){return Y(o,R+"return "+S).apply(i,f)});if(M.source=S,zi(M))throw M;return M}function wg(t){return Q(t).toLowerCase()}function yg(t){return Q(t).toUpperCase()}function mg(t,n,e){if(t=Q(t),t&&(e||n===i))return zs(t);if(!t||!(n=Wt(n)))return t;var r=Qt(t),s=Qt(n),o=Gs(r,s),f=Js(r,s)+1;return Rn(r,o,f).join("")}function xg(t,n,e){if(t=Q(t),t&&(e||n===i))return t.slice(0,Ys(t)+1);if(!t||!(n=Wt(n)))return t;var r=Qt(t),s=Js(r,Qt(n))+1;return Rn(r,0,s).join("")}function Sg(t,n,e){if(t=Q(t),t&&(e||n===i))return t.replace(zr,"");if(!t||!(n=Wt(n)))return t;var r=Qt(t),s=Gs(r,Qt(n));return Rn(r,s).join("")}function Ag(t,n){var e=Le,r=fe;if(it(n)){var s="separator"in n?n.separator:s;e="length"in n?$(n.length):e,r="omission"in n?Wt(n.omission):r}t=Q(t);var o=t.length;if(Zn(t)){var f=Qt(t);o=f.length}if(e>=o)return t;var c=e-Yn(r);if(c<1)return r;var d=f?Rn(f,0,c).join(""):t.slice(0,c);if(s===i)return d+r;if(f&&(c+=d.length-c),Gi(s)){if(t.slice(c).search(s)){var y,m=d;for(s.global||(s=ai(s.source,Q(ds.exec(s))+"g")),s.lastIndex=0;y=s.exec(m);)var S=y.index;d=d.slice(0,S===i?c:S)}}else if(t.indexOf(Wt(s),c)!=c){var b=d.lastIndexOf(s);b>-1&&(d=d.slice(0,b))}return d+r}function bg(t){return t=Q(t),t&&Da.test(t)?t.replace(cs,jf):t}var Cg=ee(function(t,n,e){return t+(e?" ":"")+n.toUpperCase()}),Yi=Nu("toUpperCase");function Uo(t,n,e){return t=Q(t),n=e?i:n,n===i?Zf(t)?ec(t):$f(t):t.match(n)||[]}var No=k(function(t,n){try{return Ot(t,i,n)}catch(e){return zi(e)?e:new F(e)}}),Pg=pn(function(t,n){return Mt(n,function(e){e=un(e),hn(t,e,qi(t[e],t))}),t});function Ig(t){var n=t==null?0:t.length,e=O();return t=n?rt(t,function(r){if(typeof r[1]!="function")throw new Kt(x);return[e(r[0]),r[1]]}):[],k(function(r){for(var s=-1;++s<n;){var o=t[s];if(Ot(o[0],this,r))return Ot(o[1],this,r)}})}function Rg(t){return jc(qt(t,A))}function Xi(t){return function(){return t}}function Eg(t,n){return t==null||t!==t?n:t}var Tg=$u(),Og=$u(!0);function Rt(t){return t}function Qi(t){return gu(typeof t=="function"?t:qt(t,A))}function Lg(t){return vu(qt(t,A))}function Wg(t,n){return wu(t,qt(n,A))}var Dg=k(function(t,n){return function(e){return Ae(e,t,n)}}),Fg=k(function(t,n){return function(e){return Ae(t,e,n)}});function Vi(t,n,e){var r=ht(n),s=or(n,r);e==null&&!(it(n)&&(s.length||!r.length))&&(e=n,n=t,t=this,s=or(n,ht(n)));var o=!(it(e)&&"chain"in e)||!!e.chain,f=_n(t);return Mt(s,function(c){var d=n[c];t[c]=d,f&&(t.prototype[c]=function(){var y=this.__chain__;if(o||y){var m=t(this.__wrapped__),S=m.__actions__=Ct(this.__actions__);return S.push({func:d,args:arguments,thisArg:t}),m.__chain__=y,m}return d.apply(t,Sn([this.value()],arguments))})}),t}function Ug(){return pt._===this&&(pt._=ac),this}function ji(){}function Ng(t){return t=$(t),k(function(n){return yu(n,t)})}var Bg=Ti(rt),$g=Ti(Ms),Mg=Ti(ni);function Bo(t){return Ni(t)?ei(un(t)):_l(t)}function Kg(t){return function(n){return t==null?i:$n(t,n)}}var kg=Ku(),qg=Ku(!0);function ts(){return[]}function ns(){return!1}function Hg(){return{}}function zg(){return""}function Gg(){return!0}function Jg(t,n){if(t=$(t),t<1||t>en)return[];var e=Bt,r=vt(t,Bt);n=O(n),t-=Bt;for(var s=si(r,n);++e<t;)n(e);return s}function Zg(t){return U(t)?rt(t,un):Dt(t)?[t]:Ct(ro(Q(t)))}function Yg(t){var n=++uc;return Q(t)+n}var Xg=dr(function(t,n){return t+n},0),Qg=Oi("ceil"),Vg=dr(function(t,n){return t/n},1),jg=Oi("floor");function t_(t){return t&&t.length?ur(t,Rt,_i):i}function n_(t,n){return t&&t.length?ur(t,O(n,2),_i):i}function e_(t){return qs(t,Rt)}function r_(t,n){return qs(t,O(n,2))}function i_(t){return t&&t.length?ur(t,Rt,mi):i}function s_(t,n){return t&&t.length?ur(t,O(n,2),mi):i}var u_=dr(function(t,n){return t*n},1),o_=Oi("round"),a_=dr(function(t,n){return t-n},0);function f_(t){return t&&t.length?ii(t,Rt):0}function c_(t,n){return t&&t.length?ii(t,O(n,2)):0}return u.after=Ld,u.ary=go,u.assign=yp,u.assignIn=Eo,u.assignInWith=Pr,u.assignWith=mp,u.at=xp,u.before=_o,u.bind=qi,u.bindAll=Pg,u.bindKey=vo,u.castArray=Hd,u.chain=lo,u.chunk=jl,u.compact=th,u.concat=nh,u.cond=Ig,u.conforms=Rg,u.constant=Xi,u.countBy=fd,u.create=Sp,u.curry=wo,u.curryRight=yo,u.debounce=mo,u.defaults=Ap,u.defaultsDeep=bp,u.defer=Wd,u.delay=Dd,u.difference=eh,u.differenceBy=rh,u.differenceWith=ih,u.drop=sh,u.dropRight=uh,u.dropRightWhile=oh,u.dropWhile=ah,u.fill=fh,u.filter=ld,u.flatMap=pd,u.flatMapDeep=gd,u.flatMapDepth=_d,u.flatten=oo,u.flattenDeep=ch,u.flattenDepth=lh,u.flip=Fd,u.flow=Tg,u.flowRight=Og,u.fromPairs=hh,u.functions=Op,u.functionsIn=Lp,u.groupBy=vd,u.initial=ph,u.intersection=gh,u.intersectionBy=_h,u.intersectionWith=vh,u.invert=Dp,u.invertBy=Fp,u.invokeMap=yd,u.iteratee=Qi,u.keyBy=md,u.keys=ht,u.keysIn=It,u.map=mr,u.mapKeys=Np,u.mapValues=Bp,u.matches=Lg,u.matchesProperty=Wg,u.memoize=Sr,u.merge=$p,u.mergeWith=To,u.method=Dg,u.methodOf=Fg,u.mixin=Vi,u.negate=Ar,u.nthArg=Ng,u.omit=Mp,u.omitBy=Kp,u.once=Ud,u.orderBy=xd,u.over=Bg,u.overArgs=Nd,u.overEvery=$g,u.overSome=Mg,u.partial=Hi,u.partialRight=xo,u.partition=Sd,u.pick=kp,u.pickBy=Oo,u.property=Bo,u.propertyOf=Kg,u.pull=xh,u.pullAll=fo,u.pullAllBy=Sh,u.pullAllWith=Ah,u.pullAt=bh,u.range=kg,u.rangeRight=qg,u.rearg=Bd,u.reject=Cd,u.remove=Ch,u.rest=$d,u.reverse=Ki,u.sampleSize=Id,u.set=Hp,u.setWith=zp,u.shuffle=Rd,u.slice=Ph,u.sortBy=Od,u.sortedUniq=Wh,u.sortedUniqBy=Dh,u.split=pg,u.spread=Md,u.tail=Fh,u.take=Uh,u.takeRight=Nh,u.takeRightWhile=Bh,u.takeWhile=$h,u.tap=td,u.throttle=Kd,u.thru=yr,u.toArray=Po,u.toPairs=Lo,u.toPairsIn=Wo,u.toPath=Zg,u.toPlainObject=Ro,u.transform=Gp,u.unary=kd,u.union=Mh,u.unionBy=Kh,u.unionWith=kh,u.uniq=qh,u.uniqBy=Hh,u.uniqWith=zh,u.unset=Jp,u.unzip=ki,u.unzipWith=co,u.update=Zp,u.updateWith=Yp,u.values=se,u.valuesIn=Xp,u.without=Gh,u.words=Uo,u.wrap=qd,u.xor=Jh,u.xorBy=Zh,u.xorWith=Yh,u.zip=Xh,u.zipObject=Qh,u.zipObjectDeep=Vh,u.zipWith=jh,u.entries=Lo,u.entriesIn=Wo,u.extend=Eo,u.extendWith=Pr,Vi(u,u),u.add=Xg,u.attempt=No,u.camelCase=tg,u.capitalize=Do,u.ceil=Qg,u.clamp=Qp,u.clone=zd,u.cloneDeep=Jd,u.cloneDeepWith=Zd,u.cloneWith=Gd,u.conformsTo=Yd,u.deburr=Fo,u.defaultTo=Eg,u.divide=Vg,u.endsWith=ng,u.eq=jt,u.escape=eg,u.escapeRegExp=rg,u.every=cd,u.find=hd,u.findIndex=so,u.findKey=Cp,u.findLast=dd,u.findLastIndex=uo,u.findLastKey=Pp,u.floor=jg,u.forEach=ho,u.forEachRight=po,u.forIn=Ip,u.forInRight=Rp,u.forOwn=Ep,u.forOwnRight=Tp,u.get=Ji,u.gt=Xd,u.gte=Qd,u.has=Wp,u.hasIn=Zi,u.head=ao,u.identity=Rt,u.includes=wd,u.indexOf=dh,u.inRange=Vp,u.invoke=Up,u.isArguments=kn,u.isArray=U,u.isArrayBuffer=Vd,u.isArrayLike=Pt,u.isArrayLikeObject=ut,u.isBoolean=jd,u.isBuffer=En,u.isDate=tp,u.isElement=np,u.isEmpty=ep,u.isEqual=rp,u.isEqualWith=ip,u.isError=zi,u.isFinite=sp,u.isFunction=_n,u.isInteger=So,u.isLength=br,u.isMap=Ao,u.isMatch=up,u.isMatchWith=op,u.isNaN=ap,u.isNative=fp,u.isNil=lp,u.isNull=cp,u.isNumber=bo,u.isObject=it,u.isObjectLike=st,u.isPlainObject=Ee,u.isRegExp=Gi,u.isSafeInteger=hp,u.isSet=Co,u.isString=Cr,u.isSymbol=Dt,u.isTypedArray=ie,u.isUndefined=dp,u.isWeakMap=pp,u.isWeakSet=gp,u.join=wh,u.kebabCase=ig,u.last=zt,u.lastIndexOf=yh,u.lowerCase=sg,u.lowerFirst=ug,u.lt=_p,u.lte=vp,u.max=t_,u.maxBy=n_,u.mean=e_,u.meanBy=r_,u.min=i_,u.minBy=s_,u.stubArray=ts,u.stubFalse=ns,u.stubObject=Hg,u.stubString=zg,u.stubTrue=Gg,u.multiply=u_,u.nth=mh,u.noConflict=Ug,u.noop=ji,u.now=xr,u.pad=og,u.padEnd=ag,u.padStart=fg,u.parseInt=cg,u.random=jp,u.reduce=Ad,u.reduceRight=bd,u.repeat=lg,u.replace=hg,u.result=qp,u.round=o_,u.runInContext=h,u.sample=Pd,u.size=Ed,u.snakeCase=dg,u.some=Td,u.sortedIndex=Ih,u.sortedIndexBy=Rh,u.sortedIndexOf=Eh,u.sortedLastIndex=Th,u.sortedLastIndexBy=Oh,u.sortedLastIndexOf=Lh,u.startCase=gg,u.startsWith=_g,u.subtract=a_,u.sum=f_,u.sumBy=c_,u.template=vg,u.times=Jg,u.toFinite=vn,u.toInteger=$,u.toLength=Io,u.toLower=wg,u.toNumber=Gt,u.toSafeInteger=wp,u.toString=Q,u.toUpper=yg,u.trim=mg,u.trimEnd=xg,u.trimStart=Sg,u.truncate=Ag,u.unescape=bg,u.uniqueId=Yg,u.upperCase=Cg,u.upperFirst=Yi,u.each=ho,u.eachRight=po,u.first=ao,Vi(u,function(){var t={};return rn(u,function(n,e){V.call(u.prototype,e)||(t[e]=n)}),t}(),{chain:!1}),u.VERSION=p,Mt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){u[t].placeholder=u}),Mt(["drop","take"],function(t,n){z.prototype[t]=function(e){e=e===i?1:ct($(e),0);var r=this.__filtered__&&!n?new z(this):this.clone();return r.__filtered__?r.__takeCount__=vt(e,r.__takeCount__):r.__views__.push({size:vt(e,Bt),type:t+(r.__dir__<0?"Right":"")}),r},z.prototype[t+"Right"]=function(e){return this.reverse()[t](e).reverse()}}),Mt(["filter","map","takeWhile"],function(t,n){var e=n+1,r=e==Wn||e==lt;z.prototype[t]=function(s){var o=this.clone();return o.__iteratees__.push({iteratee:O(s,3),type:e}),o.__filtered__=o.__filtered__||r,o}}),Mt(["head","last"],function(t,n){var e="take"+(n?"Right":"");z.prototype[t]=function(){return this[e](1).value()[0]}}),Mt(["initial","tail"],function(t,n){var e="drop"+(n?"":"Right");z.prototype[t]=function(){return this.__filtered__?new z(this):this[e](1)}}),z.prototype.compact=function(){return this.filter(Rt)},z.prototype.find=function(t){return this.filter(t).head()},z.prototype.findLast=function(t){return this.reverse().find(t)},z.prototype.invokeMap=k(function(t,n){return typeof t=="function"?new z(this):this.map(function(e){return Ae(e,t,n)})}),z.prototype.reject=function(t){return this.filter(Ar(O(t)))},z.prototype.slice=function(t,n){t=$(t);var e=this;return e.__filtered__&&(t>0||n<0)?new z(e):(t<0?e=e.takeRight(-t):t&&(e=e.drop(t)),n!==i&&(n=$(n),e=n<0?e.dropRight(-n):e.take(n-t)),e)},z.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},z.prototype.toArray=function(){return this.take(Bt)},rn(z.prototype,function(t,n){var e=/^(?:filter|find|map|reject)|While$/.test(n),r=/^(?:head|last)$/.test(n),s=u[r?"take"+(n=="last"?"Right":""):n],o=r||/^find/.test(n);s&&(u.prototype[n]=function(){var f=this.__wrapped__,c=r?[1]:arguments,d=f instanceof z,y=c[0],m=d||U(f),S=function(H){var G=s.apply(u,Sn([H],c));return r&&b?G[0]:G};m&&e&&typeof y=="function"&&y.length!=1&&(d=m=!1);var b=this.__chain__,R=!!this.__actions__.length,L=o&&!b,M=d&&!R;if(!o&&m){f=M?f:new z(this);var W=t.apply(f,c);return W.__actions__.push({func:yr,args:[S],thisArg:i}),new kt(W,b)}return L&&M?t.apply(this,c):(W=this.thru(S),L?r?W.value()[0]:W.value():W)})}),Mt(["pop","push","shift","sort","splice","unshift"],function(t){var n=ze[t],e=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);u.prototype[t]=function(){var s=arguments;if(r&&!this.__chain__){var o=this.value();return n.apply(U(o)?o:[],s)}return this[e](function(f){return n.apply(U(f)?f:[],s)})}}),rn(z.prototype,function(t,n){var e=u[n];if(e){var r=e.name+"";V.call(jn,r)||(jn[r]=[]),jn[r].push({name:n,func:e})}}),jn[hr(i,yn).name]=[{name:"wrapper",func:i}],z.prototype.clone=bc,z.prototype.reverse=Cc,z.prototype.value=Pc,u.prototype.at=nd,u.prototype.chain=ed,u.prototype.commit=rd,u.prototype.next=id,u.prototype.plant=ud,u.prototype.reverse=od,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=ad,u.prototype.first=u.prototype.head,_e&&(u.prototype[_e]=sd),u},Xn=rc();Dn?((Dn.exports=Xn)._=Xn,Qr._=Xn):pt._=Xn}).call(ae)}(Te,Te.exports);var Yo=Te.exports;const Xo=Zo(Yo);class Qo{constructor(a){E(this,"config");this.config=a}async complete(a,i){var p;await this.persist(a,{...i,success:!0}),(p=this.config.logger)==null||p.debug("Transaction completed:",a)}async fail(a,i){var p;await this.persist(a,{...i,success:!1}),(p=this.config.logger)==null||p.debug("Transaction failed:",{...a,...i})}async persist(a,i){await fetch(`${this.config.apiUrl}/transactions/${a.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Vo{constructor(a,i){E(this,"transaction");E(this,"manager");this.transaction=a,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(a,i){var T;const p=this.transaction.functionCall;if(!p){await this.fail("No function call found");return}const g=p.name,v=p.args,x=a[g];if(!x){await this.fail(`Tool ${g} not found`);return}try{const C=Xo.get(i,"schema.config.parameters.properties",{}),X=(C&&Object.keys(C).length>0?Object.keys(C):((T=x.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:T[1].split(",").map(D=>D.trim()).filter(Boolean))||[]).map(D=>v[D]),A=await x(...X);await this.complete(A)}catch(C){await this.fail(`Error executing tool ${g}: ${C}`)}}async complete(a){await this.manager.complete(this.transaction,{success:!0,output:a,error:null})}async fail(a){await this.manager.fail(this.transaction,{success:!1,output:null,error:a})}}class es extends oe{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 p of i.tools)p.schema&&p.implementation&&(this._tools[p.schema.name]=p.implementation,this._toolSchema[p.schema.name]=p)}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 p=new Qo(this.config),g=new Vo(i,p);if(this.config.onTransaction)this.config.onTransaction(g);else{const v=i.functionCall?this.getToolInstance(i.functionCall.name):void 0;g.invoke(this._tools,v)}}getTools(){return this._tools}}function jo(l,a){if(Array.isArray(l))return l;if(typeof l=="object"&&l!==null){const i=a.dev?"localhost:8000":a.baseUrl||"persona.applica.guru/api",p=a.dev?"http":"https",g=a.dev?"ws":"wss",v=Object.keys(l).map(x=>{switch(x){case"rest":return ta(l[x],{baseEndpointProtocol:p,baseEndpoint:i,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger});case"webrtc":return na(l[x],{baseWebSocketProtocol:g,baseEndpoint:i,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger});case"websocket":return ea(l[x],{baseWebSocketProtocol:g,baseEndpoint:i,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger});default:throw new Error(`Unknown protocol: ${x}`)}}).filter(x=>x!==null);return a.tools&&v.push(new es({apiUrl:`${p}://${i}`,apiKey:a.apiKey,agentId:a.agentId,tools:a.tools,logger:a.logger})),v}throw new Error("Invalid protocols configuration")}function ta(l,a){return l===!0?new Rr({apiUrl:`${a.baseEndpointProtocol}://${a.baseEndpoint}`,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger}):typeof l=="object"&&l!==null?new Rr(l):null}function na(l,a){return l===!0?new Tr({webrtcUrl:`${a.baseWebSocketProtocol}://${a.baseEndpoint}/webrtc`,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger}):typeof l=="object"&&l!==null?new Tr(l):null}function ea(l,a){return l===!0?new Er({webSocketUrl:`${a.baseWebSocketProtocol}://${a.baseEndpoint}/websocket`,apiKey:a.apiKey,agentId:a.agentId,userId:a.userId,logger:a.logger}):typeof l=="object"&&l!==null?new Er(l):null}function ra(l,a,i,p,g){return v=>{v.type==="message"?ia(v.payload,l,a,i,g):v.type==="reasoning"?sa(v.payload,l,a,g):v.type==="transaction"&&ua(v.payload,l,p)}}function ia(l,a,i,p,g){l.createdAt||(l.createdAt=new Date),(l==null?void 0:l.finishReason)==="stop"&&!(l!=null&&l.functionResponse)&&!(l!=null&&l.thought)&&p(!1),l.thought&&(l.type="reasoning"),l.protocol=a.getName(),i(v=>{const x=Tn([...v,l]);return g?g(x):x})}function sa(l,a,i,p){const g={type:"reasoning",text:l.thought,role:"assistant",finishReason:"stop",protocol:a.getName(),createdAt:new Date};i(v=>{const x=Tn([...v,g]);return p?p(x):x})}function ua(l,a,i){i.filter(p=>p!==a).forEach(p=>p.onTransaction(l))}function rs(l){return new Promise((a,i)=>{const p=new FileReader;p.readAsDataURL(l),p.onload=()=>{const v=p.result.split(";base64,")[1];a(v)},p.onerror=g=>{i(g)}})}function oa(l){const a={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 l){const p=a[i.getName()];if(p)return p(i)}return null}function aa(l,a,i,p,g){return async v=>{const x=v.content.find(P=>P.type==="text"),T=v.attachments&&v.attachments.length>0;if(!x&&!T)throw new Error("Message must contain text or attachments");if(!l.some(P=>P.getName()!=="transaction"&&P.status==="connected")){a(P=>{const N={role:"assistant",type:"text",text:"No protocol is connected.",createdAt:new Date,finishReason:"stop"},tt=[...P,N];return p?p(tt):tt});return}const K=(x==null?void 0:x.type)==="text"?x.text??"":"",X={role:"user",type:"text",text:K,createdAt:new Date};a(P=>{const N=Tn([...P,X]);return p?p(N):N}),i(!0);const A=l.sort((P,N)=>N.getPriority()-P.getPriority()).find(P=>P.status==="connected"),D=[];if(v.attachments)for(const P of v.attachments)if(P.contentType.startsWith("image/")&&P.file)D.push({role:"user",image:{contentType:P.contentType,content:await rs(P.file)},text:"",type:"text",createdAt:new Date});else if(P.content){const N=P.content.find(q=>q.type==="text");N&&"text"in N&&D.push({role:"user",file:{name:P.name,contentType:P.contentType},text:N.text,type:"text",createdAt:new Date});const tt=P.content.find(q=>q.type==="file");tt&&"data"in tt&&D.push({role:"user",file:{name:P.name,base64:tt.data,contentType:P.contentType},text:"",type:"text",createdAt:new Date})}else P.file&&D.push({role:"user",file:{name:P.name,base64:await rs(P.file),contentType:P.contentType||"application/octet-stream"},text:"",type:"text",createdAt:new Date});K&&D.push({role:"user",text:K,type:"text",createdAt:new Date}),g==null||g.debug("Sending message:",D),await(A==null?void 0:A.sendPacket({type:"request",payload:D}))}}function fa(l,a,i,p,g,v){return async x=>{var N;if(((N=x.content[0])==null?void 0:N.type)!=="text")throw new Error("Only text messages are supported");const T=l.sort((tt,q)=>q.getPriority()-tt.getPriority()).find(tt=>tt.status==="connected");if(!T){v==null||v.debug("No protocol available for edit");return}const C=x.parentId;if(!C){v==null||v.debug("No parent ID provided for edit");return}const K=a.findIndex(tt=>tt.id===C);if(K===-1){v==null||v.debug("Parent message not found:",C);return}const X=a.slice(0,K+1),A={role:"user",text:x.content[0].text,type:"text",createdAt:new Date},D=Tn([...X,A]);i(g?g(D):D),p(!0);const P=[{role:"user",text:x.content[0].text,type:"text",createdAt:new Date}];v==null||v.debug("Sending edited message:",P),await T.sendPacket({type:"request",payload:P})}}function ca(l,a,i,p,g,v){return async(x,T)=>{const C=l.sort((N,tt)=>tt.getPriority()-N.getPriority()).find(N=>N.status==="connected");if(!C){v==null||v.debug("No protocol available for reload");return}const K=T.parentId??x;if(!K){v==null||v.debug("No parent ID provided for reload");return}const X=a.findIndex(N=>N.id===K);if(X===-1){v==null||v.debug("Parent message not found:",K);return}const A=a[X];i(N=>{const tt=N.slice(0,X+1);return g?g(tt):tt});let D;if(A.role==="assistant"||A.role==="function"){for(let N=X-1;N>=0;N--)if(a[N].role==="user"){D=a[N];break}}else A.role==="user"&&(D=A);if(!D){v==null||v.debug("No user message found to regenerate from");return}p(!0);const P=[];D.image&&P.push({role:"user",image:D.image,text:"",type:"text",createdAt:new Date}),P.push({role:"user",text:D.text,type:"text",createdAt:new Date}),v==null||v.debug("Regenerating message with config:",{actualParentId:K,sourceId:T.sourceId,custom:T.runConfig.custom}),await C.sendPacket({type:"request",payload:P})}}function la(l,a,i,p){return()=>(i(!1),a(g=>{const v=g[g.length-1];if((v==null?void 0:v.role)==="assistant"&&!v.finishReason){const x=[...g];return x[x.length-1]={...v,finishReason:"stop",status:{type:"incomplete"}},p?p(x):x}return g}),l.forEach(g=>{g.status==="connected"&&g.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:{cancel:!0}}}).catch(()=>{})}),Promise.resolve())}const qn=J.createContext(void 0);function ha(){const l=J.useContext(qn);if(!l)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return l}function is(l){const a=J.useContext(qn);if(!a)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=a.protocols.find(g=>g.getName()===l);if(!i)return null;const p=a.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:p||i.status}}function da(){const l=J.useContext(qn);if(!l)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return oa(l.protocols)}function pa(){return is("webrtc")}function ga(){const l=J.useContext(qn);if(!l)throw new Error("usePersonaRenameThread must be used within a PersonaRuntimeProvider");return l.renameThread}function _a(){const l=J.useContext(qn);if(!l)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return l.getMessages()}const Or="DEFAULT_THREAD_ID";function va(){const l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let a="";for(let i=0;i<8;i++)a+=l.charAt(Math.floor(Math.random()*l.length));return a}function wa(l,a,i,p,g,v,x,T,C,K,X){return{threadId:l,threads:a.filter(A=>A.status==="regular").map(A=>({id:A.threadId,threadId:A.threadId,title:A.title||`Session ${A.threadId}`,status:A.status})),archivedThreads:a.filter(A=>A.status==="archived").map(A=>({id:A.threadId,threadId:A.threadId,title:A.title||`Archived Chat ${A.threadId}`,status:A.status})),onSwitchToNewThread:()=>{const A=va(),D={threadId:A,status:"regular",title:`Session ${A}`};p(P=>[D,...P]),i(A),v==null||v(A)},onSwitchToThread:A=>{i(A),x==null||x(A)},onArchive:A=>{p(D=>D.map(P=>P.threadId===A?{...P,status:"archived"}:P)),T==null||T(A),A!==Or&&g.archive(A)},onUnarchive:A=>{p(D=>D.map(P=>P.threadId===A?{...P,status:"regular"}:P)),C==null||C(A)},onRename:(A,D)=>{p(P=>P.map(N=>N.threadId===A?{...N,title:D}:N)),X==null||X(A,D),A!==Or&&g.rename(A,D)},onDelete:async A=>{if(p(D=>D.filter(P=>P.threadId!==A)),l===A){const D=a.filter(P=>P.threadId!==A&&P.status==="regular");D.length>0&&i(D[0].threadId)}K==null||K(A),A!==Or&&await g.delete(A)}}}class ss{constructor(a){E(this,"endpoint");E(this,"apiKey");E(this,"pageSize");E(this,"logger");this.endpoint=a.endpoint.replace(/\/$/,""),this.apiKey=a.apiKey,this.pageSize=a.pageSize??200,this.logger=a.logger}buildHeaders(){const a={"Content-Type":"application/json"};return this.apiKey&&(a["x-persona-apikey"]=this.apiKey),a}async sync(a){var p,g;if(!a)return[];const i=`${this.endpoint}/sessions/${encodeURIComponent(String(a))}/messages?page=1&size=${this.pageSize}`;try{const v=await fetch(i,{method:"GET",headers:this.buildHeaders()});if(!v.ok)return(p=this.logger)==null||p.warn("PersonaSessionStorage: failed to fetch messages",v.status,await v.text()),[];const x=await v.json();return Array.isArray(x.items)?x.items.map(C=>({id:C.id??C.messageId??void 0,protocol:C.protocol,thought:C.thought,text:C.text??"",image:C.image,type:C.type??"text",role:C.role??"assistant",file:C.file,sources:C.sources,sessionId:C.sessionId??a,finishReason:C.finishReason,functionCalls:C.functionCalls,functionResponse:C.functionResponse,status:C.status,createdAt:C.createdAt?new Date(C.createdAt):void 0,metadata:C.metadata})):[]}catch(v){return(g=this.logger)==null||g.warn("PersonaSessionStorage: error fetching messages",v),[]}}async archive(a){return this._visiblility(a,"archived")}async unarchive(a){return this._visiblility(a,"active")}async delete(a){return this._visiblility(a,"deleted")}async _visiblility(a,i){var x;if(!a)return;const p=`${this.endpoint}/sessions/${encodeURIComponent(String(a))}/visibility`,g=JSON.stringify({visibility:i}),v=await fetch(p,{method:"PUT",headers:this.buildHeaders(),body:g});if(!v.ok){const T=await v.text();throw(x=this.logger)==null||x.warn("PersonaSessionStorage: failed to set session visibility",v.status,T),new Error(`Failed to set session visibility: ${v.status}`)}}async rename(a,i){var v;if(!a)return;const p=`${this.endpoint}/sessions/${encodeURIComponent(String(a))}/name`,g=await fetch(p,{method:"PUT",headers:this.buildHeaders(),body:JSON.stringify({name:i})});if(!g.ok){const x=await g.text();throw(v=this.logger)==null||v.warn("PersonaSessionStorage: failed to rename session",g.status,x),new Error(`Failed to rename session: ${g.status}`)}}async clearAll(){return Promise.reject(new Error("PersonaAPIMessageStorage: clearAll not supported"))}async list(a,i){const p=new URLSearchParams({page:"1",size:"100",visibility:"active"});i&&p.set("userId",i),a&&p.set("agentId",a);const g=`${this.endpoint}/sessions?${p.toString()}`;try{const v=await fetch(g,{method:"GET",headers:this.buildHeaders()});if(!v.ok)return[];const x=await v.json();return Array.isArray(x.items)?x.items.map(C=>({threadId:C.code||C.id,title:C.name||`Session ${C.code||C.id}`,status:C.status==="archived"?"archived":"regular"})):[]}catch{return[]}}}function ya({dev:l=!1,baseUrl:a,protocols:i,logger:p,children:g,session:v="new",transformMessages:x,threads:T=!1,sessionStorage:C,onThreadCreate:K,onThreadSwitch:X,onThreadRename:A,onThreadArchive:D,onThreadUnarchive:P,onThreadDelete:N,enableAttachments:tt=!1,...q}){const[yn,on]=J.useState(!1),[dt,_t]=J.useState([]),[Zt,Ln]=J.useState(new Map),Nt=J.useRef(!1),nn=J.useRef(!1),Et=J.useMemo(()=>C||new ss({apiKey:q.apiKey,endpoint:a||"https://persona.applica.guru/api"}),[C,a,q.apiKey]),[Le,fe]=J.useState([]),[Tt,We]=J.useState(""),Wn=J.useRef(typeof v=="string"?v:"new"),De=J.useRef(!1);J.useEffect(()=>{!T||De.current||(De.current=!0,Et.list(q.agentId,q.userId).then(B=>{(B==null?void 0:B.length)>0&&(fe(B),We(B[0].threadId))}).catch(B=>p==null?void 0:p.error("Failed to load threads:",B)))},[T,Et,q.agentId,q.userId,p]);const lt=J.useMemo(()=>jo(i,{dev:l||!1,baseUrl:a,apiKey:q.apiKey,agentId:q.agentId,userId:q.userId,tools:q.tools,logger:p}),[i,l,a,q.apiKey,q.agentId,q.userId,q.tools,p]);J.useEffect(()=>{Nt.current||(Nt.current=!0,p==null||p.debug("Setting up protocols:",lt.map(B=>B.getName())),lt.forEach(B=>{B.setSession(Wn.current),B.clearListeners(),B.addStatusChangeListener(at=>{p==null||p.debug(`${B.getName()} status: ${at}`),Ln(At=>{const yt=new Map(At);return yt.set(B.getName(),at),yt}),at==="connected"&&!nn.current&&(q.context&&B.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:q.context}}).catch(()=>{}),q.tools&&Array.isArray(q.tools)&&B.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:q.tools.map(At=>At.schema)}}}).catch(()=>{}))}),B.addPacketListener(ra(B,_t,on,lt,x)),B.autostart&&B.status==="disconnected"&&(p==null||p.debug(`Auto-connecting protocol: ${B.getName()}`),B.connect(Wn.current).catch(()=>{}),on(!1))}))},[]),J.useEffect(()=>{T||!v||v==="new"||Et.sync(v).then(B=>{if(B.length>0){const at=Tn(B);_t(x?x(at):at),p==null||p.debug(`Loaded ${B.length} messages for session ${v}`)}}).catch(B=>{p==null||p.error("Failed to load session messages:",B)})},[]),J.useEffect(()=>{if(!T||!Tt){_t([]);return}if(nn.current||Tt===Wn.current)return;nn.current=!0,p==null||p.info("Switching to thread:",Tt),(async()=>{try{const at=lt.filter(bt=>bt.status==="connected");at.length>0&&await Promise.allSettled(at.map(bt=>bt.disconnect())),Wn.current=Tt,await Promise.allSettled(lt.map(bt=>bt.setSession(Tt)));const At=await Et.sync(Tt),yt=Tn(At);_t(x?x(yt):yt),p==null||p.debug(`Loaded ${At.length} messages for thread ${Tt}`);const Ue=lt.filter(bt=>bt.autostart);Ue.length>0&&await Promise.allSettled(Ue.map(bt=>bt.connect(Tt)))}catch(at){p==null||p.error("Failed to switch thread:",at),_t([])}finally{nn.current=!1}})()},[Tt,T,lt,Et,x,p]);const an=J.useCallback(aa(lt,_t,on,x,p),[lt,x,p]),en=J.useCallback(fa(lt,dt,_t,on,x,p),[lt,dt,x,p]),Lr=J.useCallback(ca(lt,dt,_t,on,x,p),[lt,dt,x,p]),Hn=J.useCallback(la(lt,_t,on,x),[lt,x]),Bt=J.useCallback(B=>{const at=Tn([...B]);_t(x?x(at):at)},[x]),Wr=J.useCallback(()=>dt,[dt]),Fe=J.useMemo(()=>{if(T)return wa(Tt,Le,We,fe,Et,K,X,D,P,N,A)},[T,Tt,Le,Et,K,X,D,P,N,A,p]),Dr=ue.useExternalStoreRuntime({isRunning:yn,messages:dt,convertMessage:Go,setMessages:Bt,onNew:an,onEdit:en,onCancel:Hn,onReload:Lr,adapters:{...tt?{attachments:new ue.CompositeAttachmentAdapter([new ue.SimpleImageAttachmentAdapter,new ue.SimpleTextAttachmentAdapter,new Ko])}:{},...Fe?{threadList:Fe}:{}}}),mn=J.useCallback((B,at)=>{fe(At=>At.map(yt=>yt.threadId===B?{...yt,title:at}:yt)),A==null||A(B,at),Et.rename(B,at)},[Et,A]);return Jt.jsx(qn.Provider,{value:{protocols:lt,protocolsStatus:Zt,getMessages:Wr,renameThread:mn},children:Jt.jsx(ue.AssistantRuntimeProvider,{runtime:Dr,children:g})})}function ma({children:l,...a}){return Jt.jsx(ya,{...a,children:l})}class xa{constructor(){E(this,"prefix","[Persona]")}log(a,...i){console.log(`${this.prefix} - ${a}`,...i)}info(a,...i){console.info(`${this.prefix} - ${a}`,...i)}warn(a,...i){console.warn(`${this.prefix} - ${a}`,...i)}error(a,...i){console.error(`${this.prefix} - ${a}`,...i)}debug(a,...i){console.debug(`${this.prefix} - ${a}`,...i)}}function On(l,a,i){return{type:l,description:a,...i}}function us(l){const a=Object.entries(l.parameters).filter(([i,p])=>p.required).map(([i])=>i);return{type:"local",name:l.name,description:l.description,config:{timeout:l.timeout||60,parameters:{type:"object",title:l.title||`${l.name} parameters`,required:a,properties:l.parameters},output:{type:"object",title:`${l.name} output`,properties:l.output}}}}function Oe(l){return{schema:us(l),implementation:l.implementation}}function os(l,a,i,p,g,v){const x={name:l,description:a,title:v==null?void 0:v.title,timeout:v==null?void 0:v.timeout,parameters:p,output:g,implementation:i};return Oe(x)}const Sa=os("sum","Sum two numbers",function(a,i){return{result:a+i}},{a:On("number","First number to sum",{required:!0}),b:On("number","Second number to sum",{required:!0})},{result:On("number","Sum of two numbers")}),Aa=Oe({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:On("number","First number to sum"),b:On("number","Seconth number to sum")},output:{result:On("number","Sum of two numbers")},implementation:function(a,i){return{result:a+i}}});function ba(l){const a=[],i={};return l.forEach(p=>{const{schema:g,implementation:v}=Oe(p);a.push(g),i[p.name]=v}),{schemas:a,implementations:i}}function Ca(l,a){const{required:i,properties:p}=a.config.parameters;for(const g of i)if(!(g in l))throw new Error(`Missing required parameter: ${g}`);for(const[g,v]of Object.entries(l)){const x=p[g];if(x){if(x.type==="number"&&typeof v!="number")throw new Error(`Parameter ${g} should be a number`);if(x.type==="string"&&typeof v!="string")throw new Error(`Parameter ${g} should be a string`);if(x.type==="boolean"&&typeof v!="boolean")throw new Error(`Parameter ${g} should be a boolean`)}}return!0}class Pa{constructor(a){E(this,"baseUrl");E(this,"apiKey");this.baseUrl=a.baseUrl.replace(/\/$/,""),this.apiKey=a.apiKey}async request(a,i){const p=await fetch(`${this.baseUrl}${a}`,{...i,headers:{"Content-Type":"application/json","x-persona-apikey":this.apiKey,...(i==null?void 0:i.headers)??{}}});if(!p.ok)throw new Error(await p.text());return await p.json()}async getSubscription(a){return this.request(`/projects/${a}/subscription`)}async changeSubscriptionPlan(a,i){return this.request(`/projects/${a}/subscription/actions/change-plan`,{method:"POST",body:JSON.stringify({toPlanType:i})})}async addSubscriptionCredits(a,i){return this.request(`/projects/${a}/subscription/actions/add-credits`,{method:"POST",body:JSON.stringify({credits:i})})}}return Z.PersonaConsoleLogger=xa,Z.PersonaProtocolBase=oe,Z.PersonaRESTProtocol=Rr,Z.PersonaRuntimeProvider=ma,Z.PersonaSessionStorage=ss,Z.PersonaTransactionProtocol=es,Z.PersonaWebRTCProtocol=Tr,Z.PersonaWebSocketProtocol=Er,Z.ProjectsApi=Pa,Z.createParameter=On,Z.createTool=Oe,Z.createToolFromFunction=os,Z.createToolRegistry=ba,Z.generateToolSchema=us,Z.navigateToToolExample=Aa,Z.sumTool=Sa,Z.usePersonaRenameThread=ga,Z.usePersonaRuntime=ha,Z.usePersonaRuntimeEndpoint=da,Z.usePersonaRuntimeMessages=_a,Z.usePersonaRuntimeProtocol=is,Z.usePersonaRuntimeWebRTCProtocol=pa,Z.validateToolParameters=Ca,Object.defineProperty(Z,Symbol.toStringTag,{value:"Module"}),Z}({},React,React,AssistantUI);
|
|
26
|
+
`)+x+`return __p
|
|
27
|
+
}`;var k=Fa(function(){return Y(a,E+"return "+x).apply(i,c)});if(k.source=x,Ji(k))throw k;return k}function Ag(t){return Q(t).toLowerCase()}function Pg(t){return Q(t).toUpperCase()}function Cg(t,e,n){if(t=Q(t),t&&(n||e===i))return zs(t);if(!t||!(e=Dt(e)))return t;var r=Vt(t),s=Vt(e),a=Js(r,s),c=Zs(r,s)+1;return Re(r,a,c).join("")}function Rg(t,e,n){if(t=Q(t),t&&(n||e===i))return t.slice(0,Xs(t)+1);if(!t||!(e=Dt(e)))return t;var r=Vt(t),s=Zs(r,Vt(e))+1;return Re(r,0,s).join("")}function Ig(t,e,n){if(t=Q(t),t&&(n||e===i))return t.replace(Jr,"");if(!t||!(e=Dt(e)))return t;var r=Vt(t),s=Js(r,Vt(e));return Re(r,s).join("")}function Eg(t,e){var n=Un,r=He;if(st(e)){var s="separator"in e?e.separator:s;n="length"in e?$(e.length):n,r="omission"in e?Dt(e.omission):r}t=Q(t);var a=t.length;if(Xe(t)){var c=Vt(t);a=c.length}if(n>=a)return t;var f=n-Qe(r);if(f<1)return r;var p=c?Re(c,0,f).join(""):t.slice(0,f);if(s===i)return p+r;if(c&&(f+=p.length-f),Zi(s)){if(t.slice(f).search(s)){var w,m=p;for(s.global||(s=fi(s.source,Q(ps.exec(s))+"g")),s.lastIndex=0;w=s.exec(m);)var x=w.index;p=p.slice(0,x===i?f:x)}}else if(t.indexOf(Dt(s),f)!=f){var C=p.lastIndexOf(s);C>-1&&(p=p.slice(0,C))}return p+r}function Tg(t){return t=Q(t),t&&Bo.test(t)?t.replace(ls,sf):t}var Og=sn(function(t,e,n){return t+(n?" ":"")+e.toUpperCase()}),Qi=Mu("toUpperCase");function Na(t,e,n){return t=Q(t),e=n?i:e,e===i?jc(t)?of(t):Hc(t):t.match(e)||[]}var Fa=K(function(t,e){try{return Ot(t,i,e)}catch(n){return Ji(n)?n:new F(n)}}),Lg=le(function(t,e){return Bt(e,function(n){n=ie(n),ce(t,n,Gi(t[n],t))}),t});function Dg(t){var e=t==null?0:t.length,n=L();return t=e?it(t,function(r){if(typeof r[1]!="function")throw new kt(S);return[n(r[0]),r[1]]}):[],K(function(r){for(var s=-1;++s<e;){var a=t[s];if(Ot(a[0],this,r))return Ot(a[1],this,r)}})}function Wg(t){return sl(qt(t,P))}function Vi(t){return function(){return t}}function Ug(t,e){return t==null||t!==t?e:t}var Ng=Bu(),Fg=Bu(!0);function It(t){return t}function ji(t){return _u(typeof t=="function"?t:qt(t,P))}function Mg(t){return yu(qt(t,P))}function $g(t,e){return wu(t,qt(e,P))}var Bg=K(function(t,e){return function(n){return Pn(n,t,e)}}),kg=K(function(t,e){return function(n){return Pn(t,n,e)}});function ts(t,e,n){var r=gt(e),s=ar(e,r);n==null&&!(st(e)&&(s.length||!r.length))&&(n=e,e=t,t=this,s=ar(e,gt(e)));var a=!(st(n)&&"chain"in n)||!!n.chain,c=de(t);return Bt(s,function(f){var p=e[f];t[f]=p,c&&(t.prototype[f]=function(){var w=this.__chain__;if(a||w){var m=t(this.__wrapped__),x=m.__actions__=Pt(this.__actions__);return x.push({func:p,args:arguments,thisArg:t}),m.__chain__=w,m}return p.apply(t,Se([this.value()],arguments))})}),t}function Kg(){return _t._===this&&(_t._=pf),this}function es(){}function qg(t){return t=$(t),K(function(e){return mu(e,t)})}var Hg=Li(it),Gg=Li(ks),zg=Li(ri);function Ma(t){return $i(t)?ii(ie(t)):xl(t)}function Jg(t){return function(e){return t==null?i:Be(t,e)}}var Zg=Ku(),Yg=Ku(!0);function ns(){return[]}function rs(){return!1}function Xg(){return{}}function Qg(){return""}function Vg(){return!0}function jg(t,e){if(t=$(t),t<1||t>Yt)return[];var n=Mt,r=mt(t,Mt);e=L(e),t-=Mt;for(var s=ai(r,e);++n<t;)e(n);return s}function t_(t){return M(t)?it(t,ie):Wt(t)?[t]:Pt(ia(Q(t)))}function e_(t){var e=++hf;return Q(t)+e}var n_=dr(function(t,e){return t+e},0),r_=Di("ceil"),i_=dr(function(t,e){return t/e},1),s_=Di("floor");function u_(t){return t&&t.length?ur(t,It,yi):i}function a_(t,e){return t&&t.length?ur(t,L(e,2),yi):i}function o_(t){return Hs(t,It)}function c_(t,e){return Hs(t,L(e,2))}function f_(t){return t&&t.length?ur(t,It,xi):i}function l_(t,e){return t&&t.length?ur(t,L(e,2),xi):i}var h_=dr(function(t,e){return t*e},1),d_=Di("round"),p_=dr(function(t,e){return t-e},0);function g_(t){return t&&t.length?ui(t,It):0}function __(t,e){return t&&t.length?ui(t,L(e,2)):0}return u.after=Md,u.ary=ga,u.assign=Pp,u.assignIn=Ea,u.assignInWith=Cr,u.assignWith=Cp,u.at=Rp,u.before=_a,u.bind=Gi,u.bindAll=Lg,u.bindKey=va,u.castArray=Xd,u.chain=ha,u.chunk=sh,u.compact=uh,u.concat=ah,u.cond=Dg,u.conforms=Wg,u.constant=Vi,u.countBy=gd,u.create=Ip,u.curry=ya,u.curryRight=wa,u.debounce=ma,u.defaults=Ep,u.defaultsDeep=Tp,u.defer=$d,u.delay=Bd,u.difference=oh,u.differenceBy=ch,u.differenceWith=fh,u.drop=lh,u.dropRight=hh,u.dropRightWhile=dh,u.dropWhile=ph,u.fill=gh,u.filter=vd,u.flatMap=md,u.flatMapDeep=Sd,u.flatMapDepth=xd,u.flatten=oa,u.flattenDeep=_h,u.flattenDepth=vh,u.flip=kd,u.flow=Ng,u.flowRight=Fg,u.fromPairs=yh,u.functions=Fp,u.functionsIn=Mp,u.groupBy=bd,u.initial=mh,u.intersection=Sh,u.intersectionBy=xh,u.intersectionWith=bh,u.invert=Bp,u.invertBy=kp,u.invokeMap=Pd,u.iteratee=ji,u.keyBy=Cd,u.keys=gt,u.keysIn=Rt,u.map=mr,u.mapKeys=qp,u.mapValues=Hp,u.matches=Mg,u.matchesProperty=$g,u.memoize=xr,u.merge=Gp,u.mergeWith=Ta,u.method=Bg,u.methodOf=kg,u.mixin=ts,u.negate=br,u.nthArg=qg,u.omit=zp,u.omitBy=Jp,u.once=Kd,u.orderBy=Rd,u.over=Hg,u.overArgs=qd,u.overEvery=Gg,u.overSome=zg,u.partial=zi,u.partialRight=Sa,u.partition=Id,u.pick=Zp,u.pickBy=Oa,u.property=Ma,u.propertyOf=Jg,u.pull=Rh,u.pullAll=fa,u.pullAllBy=Ih,u.pullAllWith=Eh,u.pullAt=Th,u.range=Zg,u.rangeRight=Yg,u.rearg=Hd,u.reject=Od,u.remove=Oh,u.rest=Gd,u.reverse=qi,u.sampleSize=Dd,u.set=Xp,u.setWith=Qp,u.shuffle=Wd,u.slice=Lh,u.sortBy=Fd,u.sortedUniq=$h,u.sortedUniqBy=Bh,u.split=mg,u.spread=zd,u.tail=kh,u.take=Kh,u.takeRight=qh,u.takeRightWhile=Hh,u.takeWhile=Gh,u.tap=ud,u.throttle=Jd,u.thru=wr,u.toArray=Ca,u.toPairs=La,u.toPairsIn=Da,u.toPath=t_,u.toPlainObject=Ia,u.transform=Vp,u.unary=Zd,u.union=zh,u.unionBy=Jh,u.unionWith=Zh,u.uniq=Yh,u.uniqBy=Xh,u.uniqWith=Qh,u.unset=jp,u.unzip=Hi,u.unzipWith=la,u.update=tg,u.updateWith=eg,u.values=on,u.valuesIn=ng,u.without=Vh,u.words=Na,u.wrap=Yd,u.xor=jh,u.xorBy=td,u.xorWith=ed,u.zip=nd,u.zipObject=rd,u.zipObjectDeep=id,u.zipWith=sd,u.entries=La,u.entriesIn=Da,u.extend=Ea,u.extendWith=Cr,ts(u,u),u.add=n_,u.attempt=Fa,u.camelCase=ug,u.capitalize=Wa,u.ceil=r_,u.clamp=rg,u.clone=Qd,u.cloneDeep=jd,u.cloneDeepWith=tp,u.cloneWith=Vd,u.conformsTo=ep,u.deburr=Ua,u.defaultTo=Ug,u.divide=i_,u.endsWith=ag,u.eq=te,u.escape=og,u.escapeRegExp=cg,u.every=_d,u.find=yd,u.findIndex=ua,u.findKey=Op,u.findLast=wd,u.findLastIndex=aa,u.findLastKey=Lp,u.floor=s_,u.forEach=da,u.forEachRight=pa,u.forIn=Dp,u.forInRight=Wp,u.forOwn=Up,u.forOwnRight=Np,u.get=Yi,u.gt=np,u.gte=rp,u.has=$p,u.hasIn=Xi,u.head=ca,u.identity=It,u.includes=Ad,u.indexOf=wh,u.inRange=ig,u.invoke=Kp,u.isArguments=qe,u.isArray=M,u.isArrayBuffer=ip,u.isArrayLike=Ct,u.isArrayLikeObject=ot,u.isBoolean=sp,u.isBuffer=Ie,u.isDate=up,u.isElement=ap,u.isEmpty=op,u.isEqual=cp,u.isEqualWith=fp,u.isError=Ji,u.isFinite=lp,u.isFunction=de,u.isInteger=xa,u.isLength=Ar,u.isMap=ba,u.isMatch=hp,u.isMatchWith=dp,u.isNaN=pp,u.isNative=gp,u.isNil=vp,u.isNull=_p,u.isNumber=Aa,u.isObject=st,u.isObjectLike=ut,u.isPlainObject=On,u.isRegExp=Zi,u.isSafeInteger=yp,u.isSet=Pa,u.isString=Pr,u.isSymbol=Wt,u.isTypedArray=an,u.isUndefined=wp,u.isWeakMap=mp,u.isWeakSet=Sp,u.join=Ah,u.kebabCase=fg,u.last=Gt,u.lastIndexOf=Ph,u.lowerCase=lg,u.lowerFirst=hg,u.lt=xp,u.lte=bp,u.max=u_,u.maxBy=a_,u.mean=o_,u.meanBy=c_,u.min=f_,u.minBy=l_,u.stubArray=ns,u.stubFalse=rs,u.stubObject=Xg,u.stubString=Qg,u.stubTrue=Vg,u.multiply=h_,u.nth=Ch,u.noConflict=Kg,u.noop=es,u.now=Sr,u.pad=dg,u.padEnd=pg,u.padStart=gg,u.parseInt=_g,u.random=sg,u.reduce=Ed,u.reduceRight=Td,u.repeat=vg,u.replace=yg,u.result=Yp,u.round=d_,u.runInContext=d,u.sample=Ld,u.size=Ud,u.snakeCase=wg,u.some=Nd,u.sortedIndex=Dh,u.sortedIndexBy=Wh,u.sortedIndexOf=Uh,u.sortedLastIndex=Nh,u.sortedLastIndexBy=Fh,u.sortedLastIndexOf=Mh,u.startCase=Sg,u.startsWith=xg,u.subtract=p_,u.sum=g_,u.sumBy=__,u.template=bg,u.times=jg,u.toFinite=pe,u.toInteger=$,u.toLength=Ra,u.toLower=Ag,u.toNumber=zt,u.toSafeInteger=Ap,u.toString=Q,u.toUpper=Pg,u.trim=Cg,u.trimEnd=Rg,u.trimStart=Ig,u.truncate=Eg,u.unescape=Tg,u.uniqueId=e_,u.upperCase=Og,u.upperFirst=Qi,u.each=da,u.eachRight=pa,u.first=ca,ts(u,function(){var t={};return ne(u,function(e,n){j.call(u.prototype,n)||(t[n]=e)}),t}(),{chain:!1}),u.VERSION=h,Bt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){u[t].placeholder=u}),Bt(["drop","take"],function(t,e){G.prototype[t]=function(n){n=n===i?1:pt($(n),0);var r=this.__filtered__&&!e?new G(this):this.clone();return r.__filtered__?r.__takeCount__=mt(n,r.__takeCount__):r.__views__.push({size:mt(n,Mt),type:t+(r.__dir__<0?"Right":"")}),r},G.prototype[t+"Right"]=function(n){return this.reverse()[t](n).reverse()}}),Bt(["filter","map","takeWhile"],function(t,e){var n=e+1,r=n==Ge||n==Fn;G.prototype[t]=function(s){var a=this.clone();return a.__iteratees__.push({iteratee:L(s,3),type:n}),a.__filtered__=a.__filtered__||r,a}}),Bt(["head","last"],function(t,e){var n="take"+(e?"Right":"");G.prototype[t]=function(){return this[n](1).value()[0]}}),Bt(["initial","tail"],function(t,e){var n="drop"+(e?"":"Right");G.prototype[t]=function(){return this.__filtered__?new G(this):this[n](1)}}),G.prototype.compact=function(){return this.filter(It)},G.prototype.find=function(t){return this.filter(t).head()},G.prototype.findLast=function(t){return this.reverse().find(t)},G.prototype.invokeMap=K(function(t,e){return typeof t=="function"?new G(this):this.map(function(n){return Pn(n,t,e)})}),G.prototype.reject=function(t){return this.filter(br(L(t)))},G.prototype.slice=function(t,e){t=$(t);var n=this;return n.__filtered__&&(t>0||e<0)?new G(n):(t<0?n=n.takeRight(-t):t&&(n=n.drop(t)),e!==i&&(e=$(e),n=e<0?n.dropRight(-e):n.take(e-t)),n)},G.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},G.prototype.toArray=function(){return this.take(Mt)},ne(G.prototype,function(t,e){var n=/^(?:filter|find|map|reject)|While$/.test(e),r=/^(?:head|last)$/.test(e),s=u[r?"take"+(e=="last"?"Right":""):e],a=r||/^find/.test(e);s&&(u.prototype[e]=function(){var c=this.__wrapped__,f=r?[1]:arguments,p=c instanceof G,w=f[0],m=p||M(c),x=function(H){var z=s.apply(u,Se([H],f));return r&&C?z[0]:z};m&&n&&typeof w=="function"&&w.length!=1&&(p=m=!1);var C=this.__chain__,E=!!this.__actions__.length,D=a&&!C,k=p&&!E;if(!a&&m){c=k?c:new G(this);var W=t.apply(c,f);return W.__actions__.push({func:wr,args:[x],thisArg:i}),new Kt(W,C)}return D&&k?t.apply(this,f):(W=this.thru(x),D?r?W.value()[0]:W.value():W)})}),Bt(["pop","push","shift","sort","splice","unshift"],function(t){var e=Gn[t],n=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",r=/^(?:pop|shift)$/.test(t);u.prototype[t]=function(){var s=arguments;if(r&&!this.__chain__){var a=this.value();return e.apply(M(a)?a:[],s)}return this[n](function(c){return e.apply(M(c)?c:[],s)})}}),ne(G.prototype,function(t,e){var n=u[e];if(n){var r=n.name+"";j.call(en,r)||(en[r]=[]),en[r].push({name:e,func:n})}}),en[hr(i,ve).name]=[{name:"wrapper",func:i}],G.prototype.clone=Tf,G.prototype.reverse=Of,G.prototype.value=Lf,u.prototype.at=ad,u.prototype.chain=od,u.prototype.commit=cd,u.prototype.next=fd,u.prototype.plant=hd,u.prototype.reverse=dd,u.prototype.toJSON=u.prototype.valueOf=u.prototype.value=pd,u.prototype.first=u.prototype.head,yn&&(u.prototype[yn]=ld),u},Ve=cf();Ue?((Ue.exports=Ve)._=Ve,jr._=Ve):_t._=Ve}).call(ln)}(Ln,Ln.exports);var Ya=Ln.exports;const Xa=Za(Ya);class Qa{constructor(o){O(this,"config");this.config=o}async complete(o,i){var h;await this.persist(o,{...i,success:!0}),(h=this.config.logger)==null||h.debug("Transaction completed:",o)}async fail(o,i){var h;await this.persist(o,{...i,success:!1}),(h=this.config.logger)==null||h.debug("Transaction failed:",{...o,...i})}async persist(o,i){await fetch(`${this.config.apiUrl}/transactions/${o.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Va{constructor(o,i){O(this,"transaction");O(this,"manager");this.transaction=o,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(o,i){var I;const h=this.transaction.functionCall;if(!h){await this.fail("No function call found");return}const g=h.name,v=h.args,S=o[g];if(!S){await this.fail(`Tool ${g} not found`);return}try{const b=Xa.get(i,"schema.config.parameters.properties",{}),X=(b&&Object.keys(b).length>0?Object.keys(b):((I=S.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:I[1].split(",").map(U=>U.trim()).filter(Boolean))||[]).map(U=>v[U]),P=await S(...X);await this.complete(P)}catch(b){await this.fail(`Error executing tool ${g}: ${b}`)}}async complete(o){await this.manager.complete(this.transaction,{success:!0,output:o,error:null})}async fail(o){await this.manager.fail(this.transaction,{success:!1,output:null,error:o})}}class is extends fn{constructor(i){super();O(this,"status");O(this,"autostart");O(this,"session");O(this,"config");O(this,"notify",!0);O(this,"_tools");O(this,"_toolSchema",{});if(this.config=i,this.status="disconnected",this.autostart=!0,Array.isArray(i.tools)){this._tools={};for(const h of i.tools)h.schema&&h.implementation&&(this._tools[h.schema.name]=h.implementation,this._toolSchema[h.schema.name]=h)}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 h=new Qa(this.config),g=new Va(i,h);if(this.config.onTransaction)this.config.onTransaction(g);else{const v=i.functionCall?this.getToolInstance(i.functionCall.name):void 0;g.invoke(this._tools,v)}}getTools(){return this._tools}}function ja(l,o){if(Array.isArray(l))return l;if(typeof l=="object"&&l!==null){const i=o.dev?"localhost:8000":o.baseUrl||"persona.applica.guru/api",h=o.dev?"http":"https",g=o.dev?"ws":"wss",v=Object.keys(l).map(S=>{switch(S){case"rest":return to(l[S],{baseEndpointProtocol:h,baseEndpoint:i,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger});case"webrtc":return eo(l[S],{baseWebSocketProtocol:g,baseEndpoint:i,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger});case"websocket":return no(l[S],{baseWebSocketProtocol:g,baseEndpoint:i,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger});default:throw new Error(`Unknown protocol: ${S}`)}}).filter(S=>S!==null);return o.tools&&v.push(new is({apiUrl:`${h}://${i}`,apiKey:o.apiKey,agentId:o.agentId,tools:o.tools,logger:o.logger})),v}throw new Error("Invalid protocols configuration")}function to(l,o){return l===!0?new Ir({apiUrl:`${o.baseEndpointProtocol}://${o.baseEndpoint}`,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger}):typeof l=="object"&&l!==null?new Ir(l):null}function eo(l,o){return l===!0?new Tr({webrtcUrl:`${o.baseWebSocketProtocol}://${o.baseEndpoint}/webrtc`,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger}):typeof l=="object"&&l!==null?new Tr(l):null}function no(l,o){return l===!0?new Er({webSocketUrl:`${o.baseWebSocketProtocol}://${o.baseEndpoint}/websocket`,apiKey:o.apiKey,agentId:o.agentId,userId:o.userId,logger:o.logger}):typeof l=="object"&&l!==null?new Er(l):null}function ro(l,o,i,h,g,v,S){return I=>{switch(I.type){case"agent_start":i("running");break;case"agent_end":{const b=I.payload;i("idle"),b.stopReason==="cancelled"?o(B=>[...B,{role:"assistant",type:"text",text:"⏹ Task cancelled",createdAt:new Date,finishReason:"stop",status:{type:"incomplete"}}]):b.stopReason==="error"&&o(B=>[...B,{role:"assistant",type:"text",text:`❌ Error: ${b.errorMessage||"Unknown error"}`,createdAt:new Date,finishReason:"stop",status:{type:"incomplete"}}]);break}case"turn_start":break;case"turn_end":break;case"tool_execution_start":ao(I.payload,l);break;case"tool_execution_update":oo(I.payload);break;case"tool_execution_end":co(I.payload,l);break;case"steer_accepted":v==null||v(I.payload);break;case"steer_processed":S==null||S(I.payload);break;case"message":io(I.payload,l,o,g);break;case"reasoning":so(I.payload,l,o,g);break;case"transaction":uo(I.payload,l,h);break}}}function io(l,o,i,h){l.createdAt||(l.createdAt=new Date),l.thought&&(l.type="reasoning"),l.protocol=o.getName(),i(g=>{const v=Ee([...g,l]);return h?h(v):v})}function so(l,o,i,h){const g={type:"reasoning",text:l.thought,role:"assistant",finishReason:"stop",protocol:o.getName(),createdAt:new Date};i(v=>{const S=Ee([...v,g]);return h?h(S):S})}function uo(l,o,i){i.filter(h=>h!==o).forEach(h=>h.onTransaction(l))}function ao(l,o,i){typeof window<"u"&&window.__PERSONA_DEBUG__&&console.debug(`[${o.getName()}] Tool start: ${l.toolName}`,l.args)}function oo(l,o){typeof window<"u"&&window.__PERSONA_DEBUG__&&console.debug(`Tool update: ${l.toolCallId}`,l.partialResult)}function co(l,o,i){typeof window<"u"&&window.__PERSONA_DEBUG__&&console.debug(`[${o.getName()}] Tool end: ${l.toolCallId}`,l.durationMs?`(${l.durationMs}ms)`:"",l.error?`ERROR: ${l.error}`:"")}function ss(l){return new Promise((o,i)=>{const h=new FileReader;h.readAsDataURL(l),h.onload=()=>{const v=h.result.split(";base64,")[1];o(v)},h.onerror=g=>{i(g)}})}function fo(l){const o={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 l){const h=o[i.getName()];if(h)return h(i)}return null}function lo(l,o,i,h,g){return async v=>{const S=v.content.find(A=>A.type==="text"),I=v.attachments&&v.attachments.length>0;if(!S&&!I)throw new Error("Message must contain text or attachments");const b=(S==null?void 0:S.type)==="text"?S.text??"":"";if(b.startsWith("/steer ")&&!I){const A=b.slice(7).trim();if(A)return ho(l,A,g)}if(!l.some(A=>A.getName()!=="transaction"&&A.status==="connected")){o(A=>{const T={role:"assistant",type:"text",text:"No protocol is connected.",createdAt:new Date,finishReason:"stop"},Z=[...A,T];return h?h(Z):Z});return}const X={role:"user",type:"text",text:b,createdAt:new Date};o(A=>{const T=Ee([...A,X]);return h?h(T):T}),i("running");const P=l.sort((A,T)=>T.getPriority()-A.getPriority()).find(A=>A.status==="connected"),U=[];if(v.attachments)for(const A of v.attachments)if(A.contentType.startsWith("image/")&&A.file)U.push({role:"user",image:{contentType:A.contentType,content:await ss(A.file)},text:"",type:"text",createdAt:new Date});else if(A.content){const T=A.content.find(ft=>ft.type==="text");T&&"text"in T&&U.push({role:"user",file:{name:A.name,contentType:A.contentType},text:T.text,type:"text",createdAt:new Date});const Z=A.content.find(ft=>ft.type==="file");Z&&"data"in Z&&U.push({role:"user",file:{name:A.name,base64:Z.data,contentType:A.contentType},text:"",type:"text",createdAt:new Date})}else A.file&&U.push({role:"user",file:{name:A.name,base64:await ss(A.file),contentType:A.contentType||"application/octet-stream"},text:"",type:"text",createdAt:new Date});b&&U.push({role:"user",text:b,type:"text",createdAt:new Date}),g==null||g.debug("Sending message:",U),await(P==null?void 0:P.sendPacket({type:"request",payload:U}))}}async function ho(l,o,i){const h=l.filter(g=>g.getName()!=="transaction"&&g.status==="connected");if(h.length===0){i==null||i.warn("No connected protocol available for steer");return}i==null||i.debug("Sending steer command:",o),await Promise.allSettled(h.map(g=>g.sendPacket({type:"command",payload:{command:"steer",arguments:{text:o}}})))}function po(l,o,i,h,g,v){return async S=>{var T;if(((T=S.content[0])==null?void 0:T.type)!=="text")throw new Error("Only text messages are supported");const I=l.sort((Z,ft)=>ft.getPriority()-Z.getPriority()).find(Z=>Z.status==="connected");if(!I){v==null||v.debug("No protocol available for edit");return}const b=S.parentId;if(!b){v==null||v.debug("No parent ID provided for edit");return}const B=o.findIndex(Z=>Z.id===b);if(B===-1){v==null||v.debug("Parent message not found:",b);return}const X=o.slice(0,B+1),P={role:"user",text:S.content[0].text,type:"text",createdAt:new Date},U=Ee([...X,P]);i(g?g(U):U),h("running");const A=[{role:"user",text:S.content[0].text,type:"text",createdAt:new Date}];v==null||v.debug("Sending edited message:",A),await I.sendPacket({type:"request",payload:A})}}function go(l,o,i,h,g,v){return async(S,I)=>{const b=l.sort((T,Z)=>Z.getPriority()-T.getPriority()).find(T=>T.status==="connected");if(!b){v==null||v.debug("No protocol available for reload");return}const B=I.parentId??S;if(!B){v==null||v.debug("No parent ID provided for reload");return}const X=o.findIndex(T=>T.id===B);if(X===-1){v==null||v.debug("Parent message not found:",B);return}const P=o[X];i(T=>{const Z=T.slice(0,X+1);return g?g(Z):Z});let U;if(P.role==="assistant"||P.role==="function"){for(let T=X-1;T>=0;T--)if(o[T].role==="user"){U=o[T];break}}else P.role==="user"&&(U=P);if(!U){v==null||v.debug("No user message found to regenerate from");return}h("running");const A=[];U.image&&A.push({role:"user",image:U.image,text:"",type:"text",createdAt:new Date}),A.push({role:"user",text:U.text,type:"text",createdAt:new Date}),v==null||v.debug("Regenerating message with config:",{actualParentId:B,sourceId:I.sourceId,custom:I.runConfig.custom}),await b.sendPacket({type:"request",payload:A})}}function _o(l,o,i){return()=>(o("cancelling"),i==null||i.debug("Sending cancel command to all connected protocols"),l.forEach(h=>{h.status==="connected"&&h.sendPacket({type:"command",payload:{command:"cancel",arguments:{}}}).catch(g=>{i==null||i.error("Failed to send cancel command:",g)})}),Promise.resolve())}const _e=q.createContext(void 0);function vo(){const l=q.useContext(_e);if(!l)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return l}function us(l){const o=q.useContext(_e);if(!o)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=o.protocols.find(g=>g.getName()===l);if(!i)return null;const h=o.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:h||i.status}}function yo(){const l=q.useContext(_e);if(!l)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return fo(l.protocols)}function wo(){return us("webrtc")}function mo(){const l=q.useContext(_e);if(!l)throw new Error("usePersonaRenameThread must be used within a PersonaRuntimeProvider");return l.renameThread}function So(){const l=q.useContext(_e);if(!l)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return l.getMessages()}function xo(){const l=q.useContext(_e);if(!l)throw new Error("useAgentState must be used within a PersonaRuntimeProvider");return l.agentState}function bo(){const l=q.useContext(_e);if(!l)throw new Error("useSteerAgent must be used within a PersonaRuntimeProvider");return l.steerAgent}const Or="DEFAULT_THREAD_ID";function Ao(){const l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let o="";for(let i=0;i<8;i++)o+=l.charAt(Math.floor(Math.random()*l.length));return o}function Po(l,o,i,h,g,v,S,I,b,B,X){return{threadId:l,threads:o.filter(P=>P.status==="regular").map(P=>({id:P.threadId,threadId:P.threadId,title:P.title||`Session ${P.threadId}`,status:P.status})),archivedThreads:o.filter(P=>P.status==="archived").map(P=>({id:P.threadId,threadId:P.threadId,title:P.title||`Archived Chat ${P.threadId}`,status:P.status})),onSwitchToNewThread:()=>{const P=Ao(),U={threadId:P,status:"regular",title:`Session ${P}`};h(A=>[U,...A]),i(P),v==null||v(P)},onSwitchToThread:P=>{i(P),S==null||S(P)},onArchive:P=>{h(U=>U.map(A=>A.threadId===P?{...A,status:"archived"}:A)),I==null||I(P),P!==Or&&g.archive(P)},onUnarchive:P=>{h(U=>U.map(A=>A.threadId===P?{...A,status:"regular"}:A)),b==null||b(P)},onRename:(P,U)=>{h(A=>A.map(T=>T.threadId===P?{...T,title:U}:T)),X==null||X(P,U),P!==Or&&g.rename(P,U)},onDelete:async P=>{if(h(U=>U.filter(A=>A.threadId!==P)),l===P){const U=o.filter(A=>A.threadId!==P&&A.status==="regular");U.length>0&&i(U[0].threadId)}B==null||B(P),P!==Or&&await g.delete(P)}}}class as{constructor(o){O(this,"endpoint");O(this,"apiKey");O(this,"pageSize");O(this,"logger");this.endpoint=o.endpoint.replace(/\/$/,""),this.apiKey=o.apiKey,this.pageSize=o.pageSize??200,this.logger=o.logger}buildHeaders(){const o={"Content-Type":"application/json"};return this.apiKey&&(o["x-persona-apikey"]=this.apiKey),o}async sync(o){var h,g;if(!o)return[];const i=`${this.endpoint}/sessions/${encodeURIComponent(String(o))}/messages?page=1&size=${this.pageSize}`;try{const v=await fetch(i,{method:"GET",headers:this.buildHeaders()});if(!v.ok)return(h=this.logger)==null||h.warn("PersonaSessionStorage: failed to fetch messages",v.status,await v.text()),[];const S=await v.json();return Array.isArray(S.items)?S.items.map(b=>({id:b.id??b.messageId??void 0,protocol:b.protocol,thought:b.thought,text:b.text??"",image:b.image,type:b.type??"text",role:b.role??"assistant",file:b.file,sources:b.sources,sessionId:b.sessionId??o,finishReason:b.finishReason,functionCalls:b.functionCalls,functionResponse:b.functionResponse,status:b.status,createdAt:b.createdAt?new Date(b.createdAt):void 0,metadata:b.metadata})):[]}catch(v){return(g=this.logger)==null||g.warn("PersonaSessionStorage: error fetching messages",v),[]}}async archive(o){return this._visiblility(o,"archived")}async unarchive(o){return this._visiblility(o,"active")}async delete(o){return this._visiblility(o,"deleted")}async _visiblility(o,i){var S;if(!o)return;const h=`${this.endpoint}/sessions/${encodeURIComponent(String(o))}/visibility`,g=JSON.stringify({visibility:i}),v=await fetch(h,{method:"PUT",headers:this.buildHeaders(),body:g});if(!v.ok){const I=await v.text();throw(S=this.logger)==null||S.warn("PersonaSessionStorage: failed to set session visibility",v.status,I),new Error(`Failed to set session visibility: ${v.status}`)}}async rename(o,i){var v;if(!o)return;const h=`${this.endpoint}/sessions/${encodeURIComponent(String(o))}/name`,g=await fetch(h,{method:"PUT",headers:this.buildHeaders(),body:JSON.stringify({name:i})});if(!g.ok){const S=await g.text();throw(v=this.logger)==null||v.warn("PersonaSessionStorage: failed to rename session",g.status,S),new Error(`Failed to rename session: ${g.status}`)}}async clearAll(){return Promise.reject(new Error("PersonaAPIMessageStorage: clearAll not supported"))}async list(o,i){const h=new URLSearchParams({page:"1",size:"100",visibility:"active"});i&&h.set("userId",i),o&&h.set("agentId",o);const g=`${this.endpoint}/sessions?${h.toString()}`;try{const v=await fetch(g,{method:"GET",headers:this.buildHeaders()});if(!v.ok)return[];const S=await v.json();return Array.isArray(S.items)?S.items.map(b=>({threadId:b.code||b.id,title:b.name||`Session ${b.code||b.id}`,status:b.status==="archived"?"archived":"regular"})):[]}catch{return[]}}}function Co({dev:l=!1,baseUrl:o,protocols:i,logger:h,children:g,session:v="new",transformMessages:S,threads:I=!1,sessionStorage:b,onThreadCreate:B,onThreadSwitch:X,onThreadRename:P,onThreadArchive:U,onThreadUnarchive:A,onThreadDelete:T,enableAttachments:Z=!1,enableSteer:ft=!1,onSteerAccepted:ve,onSteerProcessed:Wn,...V}){const[se,yt]=q.useState("idle"),[Et,ht]=q.useState([]),[Oe,hn]=q.useState(new Map),Un=q.useRef(!1),He=q.useRef(!1),Zt=q.useMemo(()=>b||new as({apiKey:V.apiKey,endpoint:o||"https://persona.applica.guru/api"}),[b,o,V.apiKey]),[Nn,Ge]=q.useState([]),[Tt,Fn]=q.useState(""),Ft=q.useRef(typeof v=="string"?v:"new"),Yt=q.useRef(!1);q.useEffect(()=>{!I||Yt.current||(Yt.current=!0,Zt.list(V.agentId,V.userId).then(N=>{(N==null?void 0:N.length)>0&&(Ge(N),Fn(N[0].threadId))}).catch(N=>h==null?void 0:h.error("Failed to load threads:",N)))},[I,Zt,V.agentId,V.userId,h]);const lt=q.useMemo(()=>ja(i,{dev:l||!1,baseUrl:o,apiKey:V.apiKey,agentId:V.agentId,userId:V.userId,tools:V.tools,logger:h}),[i,l,o,V.apiKey,V.agentId,V.userId,V.tools,h]);q.useEffect(()=>{Un.current||(Un.current=!0,h==null||h.debug("Setting up protocols:",lt.map(N=>N.getName())),lt.forEach(N=>{N.setSession(Ft.current),N.clearListeners(),N.addStatusChangeListener(et=>{h==null||h.debug(`${N.getName()} status: ${et}`),hn(wt=>{const at=new Map(wt);return at.set(N.getName(),et),at}),et==="connected"&&!He.current&&(V.context&&N.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:V.context}}).catch(()=>{}),V.tools&&Array.isArray(V.tools)&&N.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:V.tools.map(wt=>wt.schema)}}}).catch(()=>{}))}),N.addPacketListener(ro(N,ht,yt,lt,S,ve,Wn)),N.autostart&&N.status==="disconnected"&&(h==null||h.debug(`Auto-connecting protocol: ${N.getName()}`),N.connect(Ft.current).catch(()=>{}),yt("idle"))}))},[]),q.useEffect(()=>{I||!v||v==="new"||Zt.sync(v).then(N=>{if(N.length>0){const et=Ee(N);ht(S?S(et):et),h==null||h.debug(`Loaded ${N.length} messages for session ${v}`)}}).catch(N=>{h==null||h.error("Failed to load session messages:",N)})},[]),q.useEffect(()=>{if(!I||!Tt){ht([]);return}if(He.current||Tt===Ft.current)return;He.current=!0,h==null||h.info("Switching to thread:",Tt),(async()=>{try{const et=lt.filter(Xt=>Xt.status==="connected");et.length>0&&await Promise.allSettled(et.map(Xt=>Xt.disconnect())),Ft.current=Tt,await Promise.allSettled(lt.map(Xt=>Xt.setSession(Tt)));const wt=await Zt.sync(Tt),at=Ee(wt);ht(S?S(at):at),h==null||h.debug(`Loaded ${wt.length} messages for thread ${Tt}`);const we=lt.filter(Xt=>Xt.autostart);we.length>0&&await Promise.allSettled(we.map(Xt=>Xt.connect(Tt)))}catch(et){h==null||h.error("Failed to switch thread:",et),ht([])}finally{He.current=!1}})()},[Tt,I,lt,Zt,S,h]);const ze=q.useCallback(lo(lt,ht,yt,S,h),[lt,S,h]),Mt=q.useCallback(po(lt,Et,ht,yt,S,h),[lt,Et,S,h]),Lr=q.useCallback(go(lt,Et,ht,yt,S,h),[lt,Et,S,h]),Dr=q.useCallback(_o(lt,yt,h),[lt,h]),Wr=q.useCallback(N=>{const et=Ee([...N]);ht(S?S(et):et)},[S]),ye=q.useCallback(()=>Et,[Et]),Le=q.useMemo(()=>{if(I)return Po(Tt,Nn,Fn,Ge,Zt,B,X,U,A,T,P)},[I,Tt,Nn,Zt,B,X,U,A,T,P,h]),Ur=se==="running"||se==="cancelling",De=cn.useExternalStoreRuntime({isRunning:Ur,messages:Et,convertMessage:za,setMessages:Wr,onNew:ze,onEdit:Mt,onCancel:Dr,onReload:Lr,adapters:{...Z?{attachments:new cn.CompositeAttachmentAdapter([new cn.SimpleImageAttachmentAdapter,new cn.SimpleTextAttachmentAdapter,new ka])}:{},...Le?{threadList:Le}:{}}}),We=q.useCallback((N,et)=>{Ge(wt=>wt.map(at=>at.threadId===N?{...at,title:et}:at)),P==null||P(N,et),Zt.rename(N,et)},[Zt,P]),Nr=q.useCallback(async N=>{const et=lt.filter(wt=>wt.getName()!=="transaction"&&wt.status==="connected");if(et.length===0){h==null||h.warn("No connected protocol available for steer");return}h==null||h.debug("Sending steer command:",N),await Promise.allSettled(et.map(wt=>wt.sendPacket({type:"command",payload:{command:"steer",arguments:{text:N}}})))},[lt,h]);return Jt.jsx(_e.Provider,{value:{protocols:lt,protocolsStatus:Oe,agentState:se,getMessages:ye,renameThread:We,steerAgent:Nr},children:Jt.jsx(cn.AssistantRuntimeProvider,{runtime:De,children:g})})}function Ro({children:l,...o}){return Jt.jsx(Co,{...o,children:l})}class Io{constructor(){O(this,"prefix","[Persona]")}log(o,...i){console.log(`${this.prefix} - ${o}`,...i)}info(o,...i){console.info(`${this.prefix} - ${o}`,...i)}warn(o,...i){console.warn(`${this.prefix} - ${o}`,...i)}error(o,...i){console.error(`${this.prefix} - ${o}`,...i)}debug(o,...i){console.debug(`${this.prefix} - ${o}`,...i)}}function Te(l,o,i){return{type:l,description:o,...i}}function os(l){const o=Object.entries(l.parameters).filter(([i,h])=>h.required).map(([i])=>i);return{type:"local",name:l.name,description:l.description,config:{timeout:l.timeout||60,parameters:{type:"object",title:l.title||`${l.name} parameters`,required:o,properties:l.parameters},output:{type:"object",title:`${l.name} output`,properties:l.output}}}}function Dn(l){return{schema:os(l),implementation:l.implementation}}function cs(l,o,i,h,g,v){const S={name:l,description:o,title:v==null?void 0:v.title,timeout:v==null?void 0:v.timeout,parameters:h,output:g,implementation:i};return Dn(S)}const Eo=cs("sum","Sum two numbers",function(o,i){return{result:o+i}},{a:Te("number","First number to sum",{required:!0}),b:Te("number","Second number to sum",{required:!0})},{result:Te("number","Sum of two numbers")}),To=Dn({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:Te("number","First number to sum"),b:Te("number","Seconth number to sum")},output:{result:Te("number","Sum of two numbers")},implementation:function(o,i){return{result:o+i}}});function Oo(l){const o=[],i={};return l.forEach(h=>{const{schema:g,implementation:v}=Dn(h);o.push(g),i[h.name]=v}),{schemas:o,implementations:i}}function Lo(l,o){const{required:i,properties:h}=o.config.parameters;for(const g of i)if(!(g in l))throw new Error(`Missing required parameter: ${g}`);for(const[g,v]of Object.entries(l)){const S=h[g];if(S){if(S.type==="number"&&typeof v!="number")throw new Error(`Parameter ${g} should be a number`);if(S.type==="string"&&typeof v!="string")throw new Error(`Parameter ${g} should be a string`);if(S.type==="boolean"&&typeof v!="boolean")throw new Error(`Parameter ${g} should be a boolean`)}}return!0}class Do{constructor(o){O(this,"baseUrl");O(this,"apiKey");this.baseUrl=o.baseUrl.replace(/\/$/,""),this.apiKey=o.apiKey}async request(o,i){const h=await fetch(`${this.baseUrl}${o}`,{...i,headers:{"Content-Type":"application/json","x-persona-apikey":this.apiKey,...(i==null?void 0:i.headers)??{}}});if(!h.ok)throw new Error(await h.text());return await h.json()}async getSubscription(o){return this.request(`/projects/${o}/subscription`)}async changeSubscriptionPlan(o,i){return this.request(`/projects/${o}/subscription/actions/change-plan`,{method:"POST",body:JSON.stringify({toPlanType:i})})}async addSubscriptionCredits(o,i){return this.request(`/projects/${o}/subscription/actions/add-credits`,{method:"POST",body:JSON.stringify({credits:i})})}}return J.PersonaConsoleLogger=Io,J.PersonaProtocolBase=fn,J.PersonaRESTProtocol=Ir,J.PersonaRuntimeProvider=Ro,J.PersonaSessionStorage=as,J.PersonaTransactionProtocol=is,J.PersonaWebRTCProtocol=Tr,J.PersonaWebSocketProtocol=Er,J.ProjectsApi=Do,J.createParameter=Te,J.createTool=Dn,J.createToolFromFunction=cs,J.createToolRegistry=Oo,J.generateToolSchema=os,J.navigateToToolExample=To,J.sumTool=Eo,J.useAgentState=xo,J.usePersonaRenameThread=mo,J.usePersonaRuntime=vo,J.usePersonaRuntimeEndpoint=yo,J.usePersonaRuntimeMessages=So,J.usePersonaRuntimeProtocol=us,J.usePersonaRuntimeWebRTCProtocol=wo,J.useSteerAgent=bo,J.validateToolParameters=Lo,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"}),J}({},React,React,AssistantUI);
|
|
28
28
|
//# sourceMappingURL=bundle.iife.js.map
|