@applica-software-guru/persona-sdk 0.1.83 → 0.1.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,40 +1,28 @@
1
- (function(Y,B){typeof exports=="object"&&typeof module<"u"?B(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],B):(Y=typeof globalThis<"u"?globalThis:Y||self,B(Y.personaSDK={},Y.React))})(this,function(Y,B){"use strict";var Av=Object.defineProperty;var Cv=(Y,B,oe)=>B in Y?Av(Y,B,{enumerable:!0,configurable:!0,writable:!0,value:oe}):Y[B]=oe;var S=(Y,B,oe)=>Cv(Y,typeof B!="symbol"?B+"":B,oe);var Xt,Ue;var oe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function $i(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var qi={exports:{}},yn={};/**
2
- * @license React
3
- * react-jsx-runtime.production.js
4
- *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var zi;function dc(){if(zi)return yn;zi=1;var n=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function r(a,h,f){var p=null;if(f!==void 0&&(p=""+f),h.key!==void 0&&(p=""+h.key),"key"in h){f={};for(var m in h)m!=="key"&&(f[m]=h[m])}else f=h;return h=f.ref,{$$typeof:n,type:a,key:p,ref:h!==void 0?h:null,props:f}}return yn.Fragment=i,yn.jsx=r,yn.jsxs=r,yn}qi.exports=dc();var Ee=qi.exports,pc=n=>Array.from(n).map(r=>r.getModelContext()).sort((r,a)=>(a.priority??0)-(r.priority??0)).reduce((r,a)=>{var h;if(a.system&&(r.system?r.system+=`
10
-
11
- ${a.system}`:r.system=a.system),a.tools)for(const[f,p]of Object.entries(a.tools)){const m=(h=r.tools)==null?void 0:h[f];if(m&&m!==p)throw new Error(`You tried to define a tool with the name ${f}, but it already exists.`);r.tools||(r.tools={}),r.tools[f]=p}return a.config&&(r.config={...r.config,...a.config}),a.callSettings&&(r.callSettings={...r.callSettings,...a.callSettings}),r},{}),Hi=class{constructor(){S(this,"_providers",new Set);S(this,"_subscribers",new Set)}getModelContext(){return pc(this._providers)}registerModelContextProvider(n){var r;this._providers.add(n);const i=(r=n.subscribe)==null?void 0:r.call(n,()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(n),i==null||i(),this.notifySubscribers()}}notifySubscribers(){for(const n of this._subscribers)n()}subscribe(n){return this._subscribers.add(n),()=>this._subscribers.delete(n)}},gc=class{constructor(){S(this,"_contextProvider",new Hi)}registerModelContextProvider(n){return this._contextProvider.registerModelContextProvider(n)}getModelContextProvider(){return this._contextProvider}},_c=class{constructor(){S(this,"_subscribers",new Set)}subscribe(n){return this._subscribers.add(n),()=>this._subscribers.delete(n)}waitForUpdate(){return new Promise(n=>{const i=this.subscribe(()=>{i(),n()})})}_notifySubscribers(){const n=[];for(const i of this._subscribers)try{i()}catch(r){n.push(r)}if(n.length>0)throw n.length===1?n[0]:new AggregateError(n)}},bc=n=>n.status.type==="complete",Ji=class extends _c{constructor(){super(...arguments);S(this,"isEditing",!0);S(this,"_attachments",[]);S(this,"_text","");S(this,"_role","user");S(this,"_runConfig",{});S(this,"_eventSubscribers",new Map)}get attachmentAccept(){var i;return((i=this.getAttachmentAdapter())==null?void 0:i.accept)??"*"}get attachments(){return this._attachments}setAttachments(i){this._attachments=i,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}get text(){return this._text}get role(){return this._role}get runConfig(){return this._runConfig}setText(i){this._text!==i&&(this._text=i,this._notifySubscribers())}setRole(i){this._role!==i&&(this._role=i,this._notifySubscribers())}setRunConfig(i){this._runConfig!==i&&(this._runConfig=i,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text="",this._notifySubscribers()}async _onClearAttachments(){const i=this.getAttachmentAdapter();i&&await Promise.all(this._attachments.map(r=>i.remove(r)))}async reset(){if(this._attachments.length===0&&this._text===""&&this._role==="user"&&Object.keys(this._runConfig).length===0)return;this._role="user",this._runConfig={};const i=this._onClearAttachments();this._emptyTextAndAttachments(),await i}async clearAttachments(){const i=this._onClearAttachments();this.setAttachments([]),await i}async send(){const i=this.getAttachmentAdapter(),r=i&&this.attachments.length>0?Promise.all(this.attachments.map(async f=>bc(f)?f:await i.send(f))):[],a=this.text;this._emptyTextAndAttachments();const h={createdAt:new Date,role:this.role,content:a?[{type:"text",text:a}]:[],attachments:await r,runConfig:this.runConfig,metadata:{custom:{}}};this.handleSend(h),this._notifyEventSubscribers("send")}cancel(){this.handleCancel()}async addAttachment(i){const r=this.getAttachmentAdapter();if(!r)throw new Error("Attachments are not supported");const a=f=>{const p=this._attachments.findIndex(m=>m.id===f.id);p!==-1?this._attachments=[...this._attachments.slice(0,p),f,...this._attachments.slice(p+1)]:this._attachments=[...this._attachments,f],this._notifySubscribers()},h=r.add({file:i});if(Symbol.asyncIterator in h)for await(const f of h)a(f);else a(await h);this._notifyEventSubscribers("attachment-add"),this._notifySubscribers()}async removeAttachment(i){const r=this.getAttachmentAdapter();if(!r)throw new Error("Attachments are not supported");const a=this._attachments.findIndex(f=>f.id===i);if(a===-1)throw new Error("Attachment not found");const h=this._attachments[a];await r.remove(h),this._attachments=[...this._attachments.slice(0,a),...this._attachments.slice(a+1)],this._notifySubscribers()}_notifyEventSubscribers(i){const r=this._eventSubscribers.get(i);if(r)for(const a of r)a()}unstable_on(i,r){const a=this._eventSubscribers.get(i);return a?a.add(r):this._eventSubscribers.set(i,new Set([r])),()=>{const h=this._eventSubscribers.get(i);h&&h.delete(r)}}},mc=class extends Ji{constructor(i){super();S(this,"_canCancel",!1);this.runtime=i,this.connect()}get canCancel(){return this._canCancel}get attachments(){return super.attachments}getAttachmentAdapter(){var i;return(i=this.runtime.adapters)==null?void 0:i.attachments}connect(){return this.runtime.subscribe(()=>{this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,this._notifySubscribers())})}async handleSend(i){var r;this.runtime.append({...i,parentId:((r=this.runtime.messages.at(-1))==null?void 0:r.id)??null,sourceId:null})}async handleCancel(){this.runtime.cancelRun()}},es=((n,i=21)=>(r=i)=>{let a="",h=r|0;for(;h--;)a+=n[Math.random()*n.length|0];return a})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),vc="__optimistic__",wc=()=>`${vc}${es()}`,Qe=Symbol("autoStatus"),yc=Object.freeze(Object.assign({type:"running"},{[Qe]:!0})),Sc=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[Qe]:!0}));Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[Qe]:!0})),Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[Qe]:!0}));var Ec=n=>n[Qe]===!0,Gi=(n,i,r,a,h)=>n&&h?Object.assign({type:"incomplete",reason:"error",error:h},{[Qe]:!0}):n&&i?yc:Sc,je={exports:{}};const xc=typeof Buffer<"u",Ki=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Yi=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function Vi(n,i,r){r==null&&i!==null&&typeof i=="object"&&(r=i,i=void 0),xc&&Buffer.isBuffer(n)&&(n=n.toString()),n&&n.charCodeAt(0)===65279&&(n=n.slice(1));const a=JSON.parse(n,i);if(a===null||typeof a!="object")return a;const h=r&&r.protoAction||"error",f=r&&r.constructorAction||"error";if(h==="ignore"&&f==="ignore")return a;if(h!=="ignore"&&f!=="ignore"){if(Ki.test(n)===!1&&Yi.test(n)===!1)return a}else if(h!=="ignore"&&f==="ignore"){if(Ki.test(n)===!1)return a}else if(Yi.test(n)===!1)return a;return Zi(a,{protoAction:h,constructorAction:f,safe:r&&r.safe})}function Zi(n,{protoAction:i="error",constructorAction:r="error",safe:a}={}){let h=[n];for(;h.length;){const f=h;h=[];for(const p of f){if(i!=="ignore"&&Object.prototype.hasOwnProperty.call(p,"__proto__")){if(a===!0)return null;if(i==="error")throw new SyntaxError("Object contains forbidden prototype property");delete p.__proto__}if(r!=="ignore"&&Object.prototype.hasOwnProperty.call(p,"constructor")&&p.constructor!==null&&typeof p.constructor=="object"&&Object.prototype.hasOwnProperty.call(p.constructor,"prototype")){if(a===!0)return null;if(r==="error")throw new SyntaxError("Object contains forbidden prototype property");delete p.constructor}for(const m in p){const w=p[m];w&&typeof w=="object"&&h.push(w)}}}return n}function ns(n,i,r){const{stackTraceLimit:a}=Error;Error.stackTraceLimit=0;try{return Vi(n,i,r)}finally{Error.stackTraceLimit=a}}function Tc(n,i){const{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return Vi(n,i,{safe:!0})}catch{return}finally{Error.stackTraceLimit=r}}je.exports=ns,je.exports.default=ns,je.exports.parse=ns,je.exports.safeParse=Tc,je.exports.scan=Zi;var Ac=je.exports;const Xi=$i(Ac);function Cc(n){const i=["ROOT"];let r=-1,a=null;const h=[];let f;function p(){f!==void 0&&(h.push(JSON.parse('"'+f+'"')),f=void 0)}function m(C,A,R){switch(C){case'"':{r=A,i.pop(),i.push(R),i.push("INSIDE_STRING"),p();break}case"f":case"t":case"n":{r=A,a=A,i.pop(),i.push(R),i.push("INSIDE_LITERAL");break}case"-":{i.pop(),i.push(R),i.push("INSIDE_NUMBER"),p();break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=A,i.pop(),i.push(R),i.push("INSIDE_NUMBER"),p();break}case"{":{r=A,i.pop(),i.push(R),i.push("INSIDE_OBJECT_START"),p();break}case"[":{r=A,i.pop(),i.push(R),i.push("INSIDE_ARRAY_START"),p();break}}}function w(C,A){switch(C){case",":{i.pop(),i.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=A,i.pop(),f=h.pop();break}}}function I(C,A){switch(C){case",":{i.pop(),i.push("INSIDE_ARRAY_AFTER_COMMA"),f=(Number(f)+1).toString();break}case"]":{r=A,i.pop(),f=h.pop();break}}}for(let C=0;C<n.length;C++){const A=n[C];switch(i[i.length-1]){case"ROOT":m(A,C,"FINISH");break;case"INSIDE_OBJECT_START":{switch(A){case'"':{i.pop(),i.push("INSIDE_OBJECT_KEY"),f="";break}case"}":{r=C,i.pop(),f=h.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(A){case'"':{i.pop(),i.push("INSIDE_OBJECT_KEY"),f="";break}}break}case"INSIDE_OBJECT_KEY":{switch(A){case'"':{i.pop(),i.push("INSIDE_OBJECT_AFTER_KEY");break}case"\\":{i.push("INSIDE_STRING_ESCAPE"),f+=A;break}default:{f+=A;break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(A){case":":{i.pop(),i.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{m(A,C,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{w(A,C);break}case"INSIDE_STRING":{switch(A){case'"':{i.pop(),r=C,f=h.pop();break}case"\\":{i.push("INSIDE_STRING_ESCAPE");break}default:r=C}break}case"INSIDE_ARRAY_START":{switch(A){case"]":{r=C,i.pop(),f=h.pop();break}default:{r=C,f="0",m(A,C,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(A){case",":{i.pop(),i.push("INSIDE_ARRAY_AFTER_COMMA"),f=(Number(f)+1).toString();break}case"]":{r=C,i.pop(),f=h.pop();break}default:{r=C;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{m(A,C,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{i.pop(),i[i.length-1]==="INSIDE_STRING"?r=C:i[i.length-1]==="INSIDE_OBJECT_KEY"&&(f+=A);break}case"INSIDE_NUMBER":{switch(A){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=C;break}case"e":case"E":case"-":case".":break;case",":{i.pop(),f=h.pop(),i[i.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&I(A,C),i[i.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&w(A,C);break}case"}":{i.pop(),f=h.pop(),i[i.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&w(A,C);break}case"]":{i.pop(),f=h.pop(),i[i.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&I(A,C);break}default:{i.pop(),f=h.pop();break}}break}case"INSIDE_LITERAL":{const K=n.substring(a,C+1);!"false".startsWith(K)&&!"true".startsWith(K)&&!"null".startsWith(K)?(i.pop(),i[i.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?w(A,C):i[i.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&I(A,C)):r=C;break}}}let P=n.slice(0,r+1);for(let C=i.length-1;C>=0;C--)switch(i[C]){case"INSIDE_STRING":{P+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{P+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{P+="]";break}case"INSIDE_LITERAL":{const R=n.substring(a,n.length);"true".startsWith(R)?P+="true".slice(R.length):"false".startsWith(R)?P+="false".slice(R.length):"null".startsWith(R)&&(P+="null".slice(R.length))}}return[P,h]}var rs=Symbol("aui.parse-partial-json-object.meta"),Ic=n=>{if(n.length===0)return{[rs]:{state:"partial",partialPath:[]}};try{const i=Xi.parse(n);if(typeof i!="object"||i===null)throw new Error("argsText is expected to be an object");return i[rs]={state:"complete",partialPath:[]},i}catch{try{const[i,r]=Cc(n),a=Xi.parse(i);if(typeof a!="object"||a===null)throw new Error("argsText is expected to be an object");return a[rs]={state:"partial",partialPath:r},a}catch{return}}},ss=(n,i,r)=>{const{role:a,id:h,createdAt:f,attachments:p,status:m,metadata:w}=n,I={id:h??i,createdAt:f??new Date},P=typeof n.content=="string"?[{type:"text",text:n.content}]:n.content,C=({image:A,...R})=>A.match(/^data:image\/(png|jpeg|jpg|gif|webp);base64,(.*)$/)?{...R,image:A}:(console.warn("Invalid image data format detected"),null);if(a!=="user"&&(p!=null&&p.length))throw new Error("attachments are only supported for user messages");if(a!=="assistant"&&m)throw new Error("status is only supported for assistant messages");if(a!=="assistant"&&(w!=null&&w.steps))throw new Error("metadata.steps is only supported for assistant messages");switch(a){case"assistant":return{...I,role:a,content:P.map(A=>{const R=A.type;switch(R){case"text":case"reasoning":return A.text.trim().length===0?null:A;case"file":case"source":return A;case"image":return C(A);case"data":return A;case"tool-call":{const{parentId:K,messages:At,...gt}=A,ct={...gt,toolCallId:A.toolCallId??`tool-${es()}`,...K!==void 0&&{parentId:K},...At!==void 0&&{messages:At}};return A.args?{...ct,args:A.args,argsText:A.argsText??JSON.stringify(A.args)}:{...ct,args:Ic(A.argsText??"")??{},argsText:A.argsText??""}}default:{const K=R;throw new Error(`Unsupported assistant message part type: ${K}`)}}}).filter(A=>!!A),status:m??r,metadata:{unstable_state:(w==null?void 0:w.unstable_state)??null,unstable_annotations:(w==null?void 0:w.unstable_annotations)??[],unstable_data:(w==null?void 0:w.unstable_data)??[],custom:(w==null?void 0:w.custom)??{},steps:(w==null?void 0:w.steps)??[],...(w==null?void 0:w.submittedFeedback)&&{submittedFeedback:w.submittedFeedback}}};case"user":return{...I,role:a,content:P.map(A=>{const R=A.type;switch(R){case"text":case"image":case"audio":case"file":return A;default:{const K=R;throw new Error(`Unsupported user message part type: ${K}`)}}}),attachments:p??[],metadata:{custom:(w==null?void 0:w.custom)??{}}};case"system":if(P.length!==1||P[0].type!=="text")throw new Error("System messages must have exactly one text message part.");return{...I,role:a,content:P,metadata:{custom:(w==null?void 0:w.custom)??{}}};default:{const A=a;throw new Error(`Unknown message role: ${A}`)}}},is={fromArray:n=>{const i=n.map(r=>ss(r,es(),Gi(!1,!1,!1,!1,void 0)));return{messages:i.map((r,a)=>({parentId:a>0?i[a-1].id:null,message:r}))}}},Xn=n=>n.next?Xn(n.next):"current"in n?n:null,Rc=class{constructor(n){S(this,"_value",null);this.func=n}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},Qi=class{constructor(){S(this,"messages",new Map);S(this,"head",null);S(this,"root",{children:[],next:null});S(this,"_messages",new Rc(()=>{var i;const n=new Array((((i=this.head)==null?void 0:i.level)??-1)+1);for(let r=this.head;r;r=r.prev)n[r.level]=r.current;return n}))}updateLevels(n,i){n.level=i;for(const r of n.children){const a=this.messages.get(r);a&&this.updateLevels(a,i+1)}}performOp(n,i,r){const a=i.prev??this.root,h=n??this.root;if(!(r==="relink"&&a===h)){if(r!=="link"&&(a.children=a.children.filter(f=>f!==i.current.id),a.next===i)){const f=a.children.at(-1),p=f?this.messages.get(f):null;if(p===void 0)throw new Error("MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.");a.next=p}if(r!=="cut"){for(let p=n;p;p=p.prev)if(p.current.id===i.current.id)throw new Error("MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.");h.children=[...h.children,i.current.id],(Xn(i)===this.head||h.next===null)&&(h.next=i),i.prev=n;const f=n?n.level+1:0;this.updateLevels(i,f)}}}get headId(){var n;return((n=this.head)==null?void 0:n.current.id)??null}getMessages(n){var a;if(n===void 0||n===((a=this.head)==null?void 0:a.current.id))return this._messages.value;const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.");const r=new Array(i.level+1);for(let h=i;h;h=h.prev)r[h.level]=h.current;return r}addOrUpdateMessage(n,i){const r=this.messages.get(i.id),a=n?this.messages.get(n):null;if(a===void 0)throw new Error("MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.");if(r){r.current=i,this.performOp(a,r,"relink"),this._messages.dirty();return}const h={prev:a,current:i,next:null,children:[],level:a?a.level+1:0};this.messages.set(i.id,h),this.performOp(a,h,"link"),this.head===a&&(this.head=h),this._messages.dirty()}getMessage(n){var r;const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.");return{parentId:((r=i.prev)==null?void 0:r.current.id)??null,message:i.current,index:i.level}}appendOptimisticMessage(n,i){let r;do r=wc();while(this.messages.has(r));return this.addOrUpdateMessage(n,ss(i,r,{type:"running"})),r}deleteMessage(n,i){const r=this.messages.get(n);if(!r)throw new Error("MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.");const a=i===void 0?r.prev:i===null?null:this.messages.get(i);if(a===void 0)throw new Error("MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.");for(const h of r.children){const f=this.messages.get(h);if(!f)throw new Error("MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.");this.performOp(a,f,"relink")}this.performOp(null,r,"cut"),this.messages.delete(n),this.head===r&&(this.head=Xn(a??this.root)),this._messages.dirty()}getBranches(n){const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.");const{children:r}=i.prev??this.root;return r}switchToBranch(n){const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.");const r=i.prev??this.root;r.next=i,this.head=Xn(i),this._messages.dirty()}resetHead(n){if(n===null){this.clear();return}const i=this.messages.get(n);if(!i)throw new Error("MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.");if(i.children.length>0){const r=a=>{for(const h of a.children){const f=this.messages.get(h);f&&(r(f),this.messages.delete(h))}};r(i),i.children=[],i.next=null}this.head=i;for(let r=i;r;r=r.prev)r.prev&&(r.prev.next=r);this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){var i,r;const n=[];for(const[,a]of this.messages)n.push({message:a.current,parentId:((i=a.prev)==null?void 0:i.current.id)??null});return{headId:((r=this.head)==null?void 0:r.current.id)??null,messages:n}}import({headId:n,messages:i}){var r;for(const{message:a,parentId:h}of i)this.addOrUpdateMessage(h,a);this.resetHead(n??((r=i.at(-1))==null?void 0:r.message.id)??null)}},Qn=class{constructor(){S(this,"_subscriptions",new Set);S(this,"_connection")}get isConnected(){return!!this._connection}notifySubscribers(){for(const n of this._subscriptions)n()}_updateConnection(){var n;if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else(n=this._connection)==null||n.call(this),this._connection=void 0}subscribe(n){return this._subscriptions.add(n),this._updateConnection(),()=>{this._subscriptions.delete(n),this._updateConnection()}}},Yt=Symbol("skip-update"),os=class extends Qn{constructor(i){super();S(this,"_previousStateDirty",!0);S(this,"_previousState");S(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const i=this.binding.getState();i!==Yt&&(this._previousState=i),this._previousStateDirty=!1}if(this._previousState===void 0)throw new Error("Entry not available in the store");return this._previousState});this.binding=i}get path(){return this.binding.path}_connect(){const i=()=>{this._previousStateDirty=!0,this.notifySubscribers()};return this.binding.subscribe(i)}},jn=class{constructor(n,i){this._core=n,this._threadListBinding=i,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(){const n=this._core.getState();return this._threadListBinding.switchToThread(n.id)}rename(n){const i=this._core.getState();return this._threadListBinding.rename(i.id,n)}archive(){const n=this._core.getState();return this._threadListBinding.archive(n.id)}unarchive(){const n=this._core.getState();return this._threadListBinding.unarchive(n.id)}delete(){const n=this._core.getState();return this._threadListBinding.delete(n.id)}initialize(){const n=this._core.getState();return this._threadListBinding.initialize(n.id)}generateTitle(){const n=this._core.getState();return this._threadListBinding.generateTitle(n.id)}unstable_on(n,i){let r=this._core.getState().isMain,a=this._core.getState().id;return this.subscribe(()=>{const h=this._core.getState(),f=h.isMain,p=h.id;r===f&&a===p||(r=f,a=p,!(n==="switched-to"&&!f)&&(n==="switched-away"&&f||i()))})}subscribe(n){return this._core.subscribe(n)}detach(){const n=this._core.getState();this._threadListBinding.detach(n.id)}__internal_getRuntime(){return this}};function Mc(n,i){if(n===void 0&&i===void 0)return!0;if(n===void 0||i===void 0)return!1;for(const r of Object.keys(n)){const a=n[r],h=i[r];if(!Object.is(a,h))return!1}return!0}var Vt=class extends Qn{constructor(i){super();S(this,"_previousState");S(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=i;const r=i.getState();if(r===Yt)throw new Error("Entry not available in the store");this._previousState=r}get path(){return this.binding.path}_syncState(){const i=this.binding.getState();return i===Yt||Mc(i,this._previousState)?!1:(this._previousState=i,!0)}_connect(){const i=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(i)}},tn=Symbol("innerMessage"),Pc=n=>n[tn],Sn=n=>n.content.filter(r=>r.type==="text").map(r=>r.text).join(`
12
-
13
- `),ji=class{constructor(n){this._core=n,this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(n){return this._core.subscribe(n)}},to=class extends ji{constructor(n,i){super(n),this._composerApi=i}remove(){const n=this._composerApi.getState();if(!n)throw new Error("Composer is not available");return n.removeAttachment(this.getState().id)}},Oc=class extends to{get source(){return"thread-composer"}},Lc=class extends to{get source(){return"edit-composer"}},Bc=class extends ji{get source(){return"message"}constructor(n){super(n)}remove(){throw new Error("Message attachments cannot be removed")}},eo=class extends Qn{constructor(n){super(),this.config=n}getState(){return this.config.binding.getState()}outerSubscribe(n){return this.config.binding.subscribe(n)}_connect(){const n=()=>{this.notifySubscribers()};let i=this.config.binding.getState(),r=i==null?void 0:i.unstable_on(this.config.event,n);const a=()=>{var p;const f=this.config.binding.getState();f!==i&&(i=f,r==null||r(),r=(p=this.config.binding.getState())==null?void 0:p.unstable_on(this.config.event,n))},h=this.outerSubscribe(a);return()=>{h==null||h(),r==null||r()}}},no=Object.freeze([]),ro=Object.freeze({}),kc=n=>Object.freeze({type:"thread",isEditing:(n==null?void 0:n.isEditing)??!1,canCancel:(n==null?void 0:n.canCancel)??!1,isEmpty:(n==null?void 0:n.isEmpty)??!0,attachments:(n==null?void 0:n.attachments)??no,text:(n==null?void 0:n.text)??"",role:(n==null?void 0:n.role)??"user",runConfig:(n==null?void 0:n.runConfig)??ro,attachmentAccept:(n==null?void 0:n.attachmentAccept)??"",value:(n==null?void 0:n.text)??""}),Dc=n=>Object.freeze({type:"edit",isEditing:(n==null?void 0:n.isEditing)??!1,canCancel:(n==null?void 0:n.canCancel)??!1,isEmpty:(n==null?void 0:n.isEmpty)??!0,text:(n==null?void 0:n.text)??"",role:(n==null?void 0:n.role)??"user",attachments:(n==null?void 0:n.attachments)??no,runConfig:(n==null?void 0:n.runConfig)??ro,attachmentAccept:(n==null?void 0:n.attachmentAccept)??"",value:(n==null?void 0:n.text)??""}),so=class{constructor(n){S(this,"_eventSubscriptionSubjects",new Map);this._core=n}get path(){return this._core.path}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");i.setText(n)}setRunConfig(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");i.setRunConfig(n)}addAttachment(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");return i.addAttachment(n)}reset(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");return n.reset()}clearAttachments(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");return n.clearAttachments()}send(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");n.send()}cancel(){const n=this._core.getState();if(!n)throw new Error("Composer is not available");n.cancel()}setRole(n){const i=this._core.getState();if(!i)throw new Error("Composer is not available");i.setRole(n)}subscribe(n){return this._core.subscribe(n)}unstable_on(n,i){let r=this._eventSubscriptionSubjects.get(n);return r||(r=new eo({event:n,binding:this._core}),this._eventSubscriptionSubjects.set(n,r)),r.subscribe(i)}},Nc=class extends so{constructor(i){const r=new os({path:i.path,getState:()=>kc(i.getState()),subscribe:a=>i.subscribe(a)});super({path:i.path,getState:()=>i.getState(),subscribe:a=>r.subscribe(a)});S(this,"_getState");this._getState=r.getState.bind(r),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"thread"}getState(){return this._getState()}getAttachmentByIndex(i){return new Oc(new Vt({path:{...this.path,attachmentSource:"thread-composer",attachmentSelector:{type:"index",index:i},ref:`${this.path.ref}${this.path.ref}.attachments[${i}]`},getState:()=>{const a=this.getState().attachments[i];return a?{...a,source:"thread-composer"}:Yt},subscribe:r=>this._core.subscribe(r)}),this._core)}},Fc=class extends so{constructor(i,r){const a=new os({path:i.path,getState:()=>Dc(i.getState()),subscribe:h=>i.subscribe(h)});super({path:i.path,getState:()=>i.getState(),subscribe:h=>a.subscribe(h)});S(this,"_getState");this._beginEdit=r,this._getState=a.getState.bind(a),this.__internal_bindMethods()}get path(){return this._core.path}get type(){return"edit"}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(i){return new Lc(new Vt({path:{...this.path,attachmentSource:"edit-composer",attachmentSelector:{type:"index",index:i},ref:`${this.path.ref}${this.path.ref}.attachments[${i}]`},getState:()=>{const a=this.getState().attachments[i];return a?{...a,source:"edit-composer"}:Yt},subscribe:r=>this._core.subscribe(r)}),this._core)}},io=Symbol.for("aui.tool-response"),Uc=class Wi{constructor(i){S(this,"artifact");S(this,"result");S(this,"isError");i.artifact!==void 0&&(this.artifact=i.artifact),this.result=i.result,this.isError=i.isError??!1}get[io](){return!0}static[Symbol.hasInstance](i){return typeof i=="object"&&i!==null&&io in i}static toResponse(i){return i instanceof Wi?i:new Wi({result:i===void 0?"<no result>":i})}},oo=class{constructor(n,i,r){this.contentBinding=n,this.messageApi=i,this.threadApi=r,this.__internal_bindMethods()}get path(){return this.contentBinding.path}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(n){const i=this.contentBinding.getState();if(!i)throw new Error("Message part is not available");if(i.type!=="tool-call")throw new Error("Tried to add tool result to non-tool message part");if(!this.messageApi)throw new Error("Message API is not available. This is likely a bug in assistant-ui.");if(!this.threadApi)throw new Error("Thread API is not available");const r=this.messageApi.getState();if(!r)throw new Error("Message is not available");const a=i.toolName,h=i.toolCallId,f=Uc.toResponse(n);this.threadApi.getState().addToolResult({messageId:r.id,toolName:a,toolCallId:h,result:f.result,artifact:f.artifact,isError:f.isError})}resumeToolCall(n){const i=this.contentBinding.getState();if(!i)throw new Error("Message part is not available");if(i.type!=="tool-call")throw new Error("Tried to resume tool call on non-tool message part");if(!this.threadApi)throw new Error("Thread API is not available");const r=i.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:r,payload:n})}subscribe(n){return this.contentBinding.subscribe(n)}},tr=class extends Qn{constructor(n){super(),this.binding=n}get path(){return this.binding.path}getState(){return this.binding.getState()}outerSubscribe(n){return this.binding.subscribe(n)}_connect(){const n=()=>{this.notifySubscribers()};let i=this.binding.getState(),r=i==null?void 0:i.subscribe(n);const a=()=>{var p;const f=this.binding.getState();f!==i&&(i=f,r==null||r(),r=(p=this.binding.getState())==null?void 0:p.subscribe(n),n())},h=this.outerSubscribe(a);return()=>{h==null||h(),r==null||r()}}},er=Object.freeze({type:"complete"}),Wc=(n,i,r)=>{if(n.role!=="assistant")return er;if(r.type==="tool-call")return r.result?er:n.status;const a=i===Math.max(0,n.content.length-1);return n.status.type==="requires-action"?er:a?n.status:er},ao=(n,i)=>{const r=n.content[i];if(!r)return Yt;const a=Wc(n,i,r);return Object.freeze({...r,[tn]:r[tn],status:a})},$c=class{constructor(n,i){S(this,"composer");S(this,"_getEditComposerRuntimeCore",()=>this._threadBinding.getState().getEditComposer(this._core.getState().id));this._core=n,this._threadBinding=i,this.composer=new Fc(new tr({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"edit"},getState:this._getEditComposerRuntimeCore,subscribe:r=>this._threadBinding.subscribe(r)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}get path(){return this._core.path}__internal_bindMethods(){this.reload=this.reload.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}getState(){return this._core.getState()}reload(n={}){const i=this._getEditComposerRuntimeCore(),r=i??this._threadBinding.getState().composer,a=i??r,{runConfig:h=a.runConfig}=n,f=this._core.getState();if(f.role!=="assistant")throw new Error("Can only reload assistant messages");this._threadBinding.getState().startRun({parentId:f.parentId,sourceId:f.id,runConfig:h})}speak(){const n=this._core.getState();return this._threadBinding.getState().speak(n.id)}stopSpeaking(){var r;const n=this._core.getState();if(((r=this._threadBinding.getState().speech)==null?void 0:r.messageId)===n.id)this._threadBinding.getState().stopSpeaking();else throw new Error("Message is not being spoken")}submitFeedback({type:n}){const i=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:i.id,type:n})}switchToBranch({position:n,branchId:i}){const r=this._core.getState();if(i&&n)throw new Error("May not specify both branchId and position");if(!i&&!n)throw new Error("Must specify either branchId or position");const h=this._threadBinding.getState().getBranches(r.id);let f=i;if(n==="previous"?f=h[r.branchNumber-2]:n==="next"&&(f=h[r.branchNumber]),!f)throw new Error("Branch not found");this._threadBinding.getState().switchToBranch(f)}unstable_getCopyText(){return Sn(this.getState())}subscribe(n){return this._core.subscribe(n)}getMessagePartByIndex(n){if(n<0)throw new Error("Message part index must be >= 0");return new oo(new Vt({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${n}]`,messagePartSelector:{type:"index",index:n}},getState:()=>ao(this.getState(),n),subscribe:i=>this._core.subscribe(i)}),this._core,this._threadBinding)}getMessagePartByToolCallId(n){return new oo(new Vt({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(n)}]`,messagePartSelector:{type:"toolCallId",toolCallId:n}},getState:()=>{const i=this._core.getState(),r=i.content.findIndex(a=>a.type==="tool-call"&&a.toolCallId===n);return r===-1?Yt:ao(i,r)},subscribe:i=>this._core.subscribe(i)}),this._core,this._threadBinding)}getAttachmentByIndex(n){return new Bc(new Vt({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${n}]`,attachmentSource:"message",attachmentSelector:{type:"index",index:n}},getState:()=>{const i=this.getState().attachments,r=i==null?void 0:i[n];return r?{...r,source:"message"}:Yt},subscribe:i=>this._core.subscribe(i)}))}},qc=n=>({parentId:n.parentId??null,sourceId:n.sourceId??null,runConfig:n.runConfig??{},...n.stream?{stream:n.stream}:{}}),zc=n=>({parentId:n.parentId??null,sourceId:n.sourceId??null,runConfig:n.runConfig??{}}),Hc=(n,i)=>{var r,a;return typeof i=="string"?{createdAt:new Date,parentId:((r=n.at(-1))==null?void 0:r.id)??null,sourceId:null,runConfig:{},role:"user",content:[{type:"text",text:i}],attachments:[],metadata:{custom:{}}}:{createdAt:i.createdAt??new Date,parentId:i.parentId??((a=n.at(-1))==null?void 0:a.id)??null,sourceId:i.sourceId??null,role:i.role??"user",content:i.content,attachments:i.attachments??[],metadata:i.metadata??{custom:{}},runConfig:i.runConfig??{},startRun:i.startRun}},Jc=(n,i)=>{const r=n.messages.at(-1);return Object.freeze({threadId:i.id,metadata:i,capabilities:n.capabilities,isDisabled:n.isDisabled,isLoading:n.isLoading,isRunning:(r==null?void 0:r.role)!=="assistant"?!1:r.status.type==="running",messages:n.messages,state:n.state,suggestions:n.suggestions,extras:n.extras,speech:n.speech})},Gc=class{constructor(n,i){S(this,"_threadBinding");S(this,"composer");S(this,"_eventSubscriptionSubjects",new Map);const r=new Vt({path:n.path,getState:()=>Jc(n.getState(),i.getState()),subscribe:a=>{const h=n.subscribe(a),f=i.subscribe(a);return()=>{h(),f()}}});this._threadBinding={path:n.path,getState:()=>n.getState(),getStateState:()=>r.getState(),outerSubscribe:a=>n.outerSubscribe(a),subscribe:a=>n.subscribe(a)},this.composer=new Nc(new tr({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:"thread"},getState:()=>this._threadBinding.getState().composer,subscribe:a=>this._threadBinding.subscribe(a)})),this.__internal_bindMethods()}get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}__internal_bindMethods(){this.append=this.append.bind(this),this.unstable_resumeRun=this.unstable_resumeRun.bind(this),this.unstable_loadExternalState=this.unstable_loadExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getModelConfig=this.getModelConfig.bind(this),this.getState=this.getState.bind(this)}getState(){return this._threadBinding.getStateState()}append(n){this._threadBinding.getState().append(Hc(this._threadBinding.getState().messages,n))}subscribe(n){return this._threadBinding.subscribe(n)}getModelContext(){return this._threadBinding.getState().getModelContext()}getModelConfig(){return this.getModelContext()}startRun(n){const i=n===null||typeof n=="string"?{parentId:n}:n;return this._threadBinding.getState().startRun(zc(i))}unstable_resumeRun(n){return this._threadBinding.getState().resumeRun(qc(n))}unstable_loadExternalState(n){this._threadBinding.getState().unstable_loadExternalState(n)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}export(){return this._threadBinding.getState().export()}import(n){this._threadBinding.getState().import(n)}reset(n){this._threadBinding.getState().reset(n)}getMessageByIndex(n){if(n<0)throw new Error("Message index must be >= 0");return this._getMessageRuntime({...this.path,ref:`${this.path.ref}${this.path.ref}.messages[${n}]`,messageSelector:{type:"index",index:n}},()=>{var a;const i=this._threadBinding.getState().messages,r=i[n];if(r)return{message:r,parentId:((a=i[n-1])==null?void 0:a.id)??null,index:n}})}getMessageById(n){return this._getMessageRuntime({...this.path,ref:this.path.ref+`${this.path.ref}.messages[messageId=${JSON.stringify(n)}]`,messageSelector:{type:"messageId",messageId:n}},()=>this._threadBinding.getState().getMessageById(n))}_getMessageRuntime(n,i){return new $c(new Vt({path:n,getState:()=>{var P;const{message:r,parentId:a,index:h}=i()??{},{messages:f,speech:p}=this._threadBinding.getState();if(!r||a===void 0||h===void 0)return Yt;const w=this._threadBinding.getState().getBranches(r.id),I=r.metadata.submittedFeedback;return{...r,[tn]:r[tn],index:h,isLast:((P=f.at(-1))==null?void 0:P.id)===r.id,parentId:a,branchNumber:w.indexOf(r.id)+1,branchCount:w.length,speech:(p==null?void 0:p.messageId)===r.id?p:void 0,submittedFeedback:I}},subscribe:r=>this._threadBinding.subscribe(r)}),this._threadBinding)}unstable_on(n,i){let r=this._eventSubscriptionSubjects.get(n);return r||(r=new eo({event:n,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(n,r)),r.subscribe(i)}},Kc=n=>({mainThreadId:n.mainThreadId,newThread:n.newThreadId,threads:n.threadIds,archivedThreads:n.archivedThreadIds,isLoading:n.isLoading,threadItems:n.threadData}),nr=(n,i)=>{if(i===void 0)return Yt;const r=n.getItemById(i);return r?{id:r.id,threadId:r.id,remoteId:r.remoteId,externalId:r.externalId,title:r.title,status:r.status,isMain:r.id===n.mainThreadId}:Yt},Yc=class{constructor(n,i=Gc){S(this,"_getState");S(this,"_mainThreadListItemRuntime");S(this,"main");this._core=n,this._runtimeFactory=i;const r=new os({path:{},getState:()=>Kc(n),subscribe:a=>n.subscribe(a)});this._getState=r.getState.bind(r),this._mainThreadListItemRuntime=new jn(new Vt({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>nr(this._core,this._core.mainThreadId),subscribe:a=>this._core.subscribe(a)}),this._core),this.main=new i(new tr({path:{ref:"threads.main",threadSelector:{type:"main"}},getState:()=>n.getMainThreadRuntimeCore(),subscribe:a=>n.subscribe(a)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(n){return this._core.switchToThread(n)}switchToNewThread(){return this._core.switchToNewThread()}getState(){return this._getState()}subscribe(n){return this._core.subscribe(n)}get mainItem(){return this._mainThreadListItemRuntime}getById(n){return new this._runtimeFactory(new tr({path:{ref:`threads[threadId=${JSON.stringify(n)}]`,threadSelector:{type:"threadId",threadId:n}},getState:()=>this._core.getThreadRuntimeCore(n),subscribe:i=>this._core.subscribe(i)}),this.mainItem)}getItemByIndex(n){return new jn(new Vt({path:{ref:`threadItems[${n}]`,threadSelector:{type:"index",index:n}},getState:()=>nr(this._core,this._core.threadIds[n]),subscribe:i=>this._core.subscribe(i)}),this._core)}getArchivedItemByIndex(n){return new jn(new Vt({path:{ref:`archivedThreadItems[${n}]`,threadSelector:{type:"archiveIndex",index:n}},getState:()=>nr(this._core,this._core.archivedThreadIds[n]),subscribe:i=>this._core.subscribe(i)}),this._core)}getItemById(n){return new jn(new Vt({path:{ref:`threadItems[threadId=${n}]`,threadSelector:{type:"threadId",threadId:n}},getState:()=>nr(this._core,n),subscribe:i=>this._core.subscribe(i)}),this._core)}},Vc=class{constructor(){S(this,"accept","image/*")}async add(n){return{id:n.file.name,type:"image",name:n.file.name,contentType:n.file.type,file:n.file,status:{type:"requires-action",reason:"composer-send"}}}async send(n){return{...n,status:{type:"complete"},content:[{type:"image",image:await Zc(n.file)}]}}async remove(){}},Zc=n=>new Promise((i,r)=>{const a=new FileReader;a.onload=()=>i(a.result),a.onerror=h=>r(h),a.readAsDataURL(n)});function as(n,i){if(i==="*")return!0;const r=i.split(",").map(f=>f.trim().toLowerCase()),a=`.${n.name.split(".").pop().toLowerCase()}`,h=n.type.toLowerCase();for(const f of r){if(f.startsWith(".")&&f===a||f.includes("/")&&f===h)return!0;if((f==="image/*"||f==="video/*"||f==="audio/*")&&f.endsWith("/*")){const p=f.split("/")[0];if(h.startsWith(`${p}/`))return!0}}return!1}var Xc=class{constructor(n){S(this,"_adapters");S(this,"accept");this._adapters=n;const i=n.findIndex(r=>r.accept==="*");if(i!==-1){if(i!==n.length-1)throw new Error("A wildcard adapter (handling all files) can only be specified as the last adapter.");this.accept="*"}else this.accept=n.map(r=>r.accept).join(",")}add(n){for(const i of this._adapters)if(as(n.file,i.accept))return i.add(n);throw new Error("No matching adapter found for file")}async send(n){const i=this._adapters.slice();for(const r of i)if(as(n.file,r.accept))return r.send(n);throw new Error("No matching adapter found for attachment")}async remove(n){const i=this._adapters.slice();for(const r of i)if(as({name:n.name,type:n.contentType},r.accept))return r.remove(n);throw new Error("No matching adapter found for attachment")}},Qc=B.createContext(null),jc=()=>B.useContext(Qc),ke=Object.freeze([]),De="DEFAULT_THREAD_ID",th=Object.freeze([De]),uo=Object.freeze({id:De,remoteId:void 0,externalId:void 0,status:"regular"}),eh=Promise.resolve(),co=Object.freeze({[De]:uo}),nh=class{constructor(n={},i){S(this,"_mainThreadId",De);S(this,"_threads",th);S(this,"_archivedThreads",ke);S(this,"_threadData",co);S(this,"_mainThread");S(this,"_subscriptions",new Set);this.adapter=n,this.threadFactory=i,this._mainThread=this.threadFactory(),this.__internal_setAdapter(n,!0)}get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadData(){return this._threadData}getLoadThreadsPromise(){return eh}get mainThreadId(){return this._mainThreadId}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw new Error("Method not implemented.")}getItemById(n){for(const i of this.adapter.threads??[])if(i.id===n)return i;for(const i of this.adapter.archivedThreads??[])if(i.id===n)return i;if(n===De)return uo}__internal_setAdapter(n,i=!1){var I,P,C,A;const r=this.adapter;this.adapter=n;const a=n.threadId??De,h=n.threads??ke,f=n.archivedThreads??ke,p=r.threadId??De,m=r.threads??ke,w=r.archivedThreads??ke;!i&&p===a&&m===h&&w===f||(this._threadData={...co,...Object.fromEntries(((I=n.threads)==null?void 0:I.map(R=>[R.id,{...R,remoteId:R.remoteId,externalId:R.externalId,status:"regular"}]))??[]),...Object.fromEntries(((P=n.archivedThreads)==null?void 0:P.map(R=>[R.id,{...R,remoteId:R.remoteId,externalId:R.externalId,status:"archived"}]))??[])},m!==h&&(this._threads=((C=this.adapter.threads)==null?void 0:C.map(R=>R.id))??ke),w!==f&&(this._archivedThreads=((A=this.adapter.archivedThreads)==null?void 0:A.map(R=>R.id))??ke),p!==a&&(this._mainThreadId=a,this._mainThread=this.threadFactory()),this._notifySubscribers())}async switchToThread(n){if(this._mainThreadId===n)return;const i=this.adapter.onSwitchToThread;if(!i)throw new Error("External store adapter does not support switching to thread");i(n)}async switchToNewThread(){const n=this.adapter.onSwitchToNewThread;if(!n)throw new Error("External store adapter does not support switching to new thread");n()}async rename(n,i){const r=this.adapter.onRename;if(!r)throw new Error("External store adapter does not support renaming");r(n,i)}async detach(){}async archive(n){const i=this.adapter.onArchive;if(!i)throw new Error("External store adapter does not support archiving");i(n)}async unarchive(n){const i=this.adapter.onUnarchive;if(!i)throw new Error("External store adapter does not support unarchiving");i(n)}async delete(n){const i=this.adapter.onDelete;if(!i)throw new Error("External store adapter does not support deleting");i(n)}initialize(n){return Promise.resolve({remoteId:n,externalId:void 0})}generateTitle(){throw new Error("Method not implemented.")}subscribe(n){return this._subscriptions.add(n),()=>this._subscriptions.delete(n)}_notifySubscribers(){for(const n of this._subscriptions)n()}},ho=class{constructor(){S(this,"cache",new WeakMap)}convertMessages(n,i){return n.map((r,a)=>{const h=this.cache.get(r),f=i(h,r,a);return this.cache.set(r,f),f})}},rh=class extends Ji{constructor(i,r,{parentId:a,message:h}){super();S(this,"_nonTextParts");S(this,"_previousText");S(this,"_parentId");S(this,"_sourceId");this.runtime=i,this.endEditCallback=r,this._parentId=a,this._sourceId=h.id,this._previousText=Sn(h),this.setText(this._previousText),this.setRole(h.role),this.setAttachments(h.attachments??[]),this._nonTextParts=h.content.filter(f=>f.type!=="text"),this.setRunConfig({...i.composer.runConfig})}get canCancel(){return!0}getAttachmentAdapter(){var i;return(i=this.runtime.adapters)==null?void 0:i.attachments}async handleSend(i){Sn(i)!==this._previousText&&this.runtime.append({...i,content:[...i.content,...this._nonTextParts],parentId:this._parentId,sourceId:this._sourceId}),this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},sh=class{constructor(n){S(this,"_subscriptions",new Set);S(this,"_isInitialized",!1);S(this,"repository",new Qi);S(this,"composer",new mc(this));S(this,"_editComposers",new Map);S(this,"_stopSpeaking");S(this,"speech");S(this,"_eventSubscribers",new Map);this._contextProvider=n}get messages(){return this.repository.getMessages()}get state(){let n;for(const i of this.messages)if(i.role==="assistant"){n=i;break}return(n==null?void 0:n.metadata.unstable_state)??null}getModelContext(){return this._contextProvider.getModelContext()}getEditComposer(n){return this._editComposers.get(n)}beginEdit(n){if(this._editComposers.has(n))throw new Error("Edit already in progress");this._editComposers.set(n,new rh(this,()=>this._editComposers.delete(n),this.repository.getMessage(n))),this._notifySubscribers()}getMessageById(n){try{return this.repository.getMessage(n)}catch{return}}getBranches(n){return this.repository.getBranches(n)}switchToBranch(n){this.repository.switchToBranch(n),this._notifySubscribers()}_notifySubscribers(){for(const n of this._subscriptions)n()}_notifyEventSubscribers(n){const i=this._eventSubscribers.get(n);if(i)for(const r of i)r()}subscribe(n){return this._subscriptions.add(n),()=>this._subscriptions.delete(n)}submitFeedback({messageId:n,type:i}){var f;const r=(f=this.adapters)==null?void 0:f.feedback;if(!r)throw new Error("Feedback adapter not configured");const{message:a,parentId:h}=this.repository.getMessage(n);if(r.submit({message:a,type:i}),a.role==="assistant"){const p={...a,metadata:{...a.metadata,submittedFeedback:{type:i}}};this.repository.addOrUpdateMessage(h,p)}this._notifySubscribers()}speak(n){var f,p;const i=(f=this.adapters)==null?void 0:f.speech;if(!i)throw new Error("Speech adapter not configured");const{message:r}=this.repository.getMessage(n);(p=this._stopSpeaking)==null||p.call(this);const a=i.speak(Sn(r)),h=a.subscribe(()=>{a.status.type==="ended"?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:n,status:a.status},this._notifySubscribers()});this.speech={messageId:n,status:a.status},this._notifySubscribers(),this._stopSpeaking=()=>{a.cancel(),h(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw new Error("No message is being spoken");this._stopSpeaking(),this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers("initialize"))}export(){return this.repository.export()}import(n){this.ensureInitialized(),this.repository.clear(),this.repository.import(n),this._notifySubscribers()}reset(n){this.import(is.fromArray(n??[]))}unstable_on(n,i){var a,h;if(n==="model-context-update")return((h=(a=this._contextProvider).subscribe)==null?void 0:h.call(a,i))??(()=>{});const r=this._eventSubscribers.get(n);return r?r.add(i):this._eventSubscribers.set(n,new Set([i])),()=>{this._eventSubscribers.get(n).delete(i)}}},ih=Object.freeze([]),oh=(n,i)=>{var r;return n&&((r=i[i.length-1])==null?void 0:r.role)!=="assistant"},ah=class extends sh{constructor(i,r){super(i);S(this,"_assistantOptimisticId",null);S(this,"_capabilities",{switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,attachments:!1,feedback:!1});S(this,"_messages");S(this,"isDisabled");S(this,"suggestions",[]);S(this,"extras");S(this,"_converter",new ho);S(this,"_store");S(this,"updateMessages",i=>{var a,h,f,p;this._store.convertMessage!==void 0?(h=(a=this._store).setMessages)==null||h.call(a,i.flatMap(Pc).filter(m=>m!=null)):(p=(f=this._store).setMessages)==null||p.call(f,i)});this.__internal_setAdapter(r)}get capabilities(){return this._capabilities}get isLoading(){return this._store.isLoading??!1}get messages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}beginEdit(i){if(!this._store.onEdit)throw new Error("Runtime does not support editing.");super.beginEdit(i)}__internal_setAdapter(i){var f,p,m,w,I,P;if(this._store===i)return;const r=i.isRunning??!1;this.isDisabled=i.isDisabled??!1;const a=this._store;this._store=i,this.extras=i.extras,this.suggestions=i.suggestions??ih,this._capabilities={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,reload:this._store.onReload!==void 0,cancel:this._store.onCancel!==void 0,speech:((f=this._store.adapters)==null?void 0:f.speech)!==void 0,unstable_copy:((p=this._store.unstable_capabilities)==null?void 0:p.copy)!==!1,attachments:!!((m=this._store.adapters)!=null&&m.attachments),feedback:!!((w=this._store.adapters)!=null&&w.feedback)};let h;if(i.messageRepository){if(a&&a.isRunning===i.isRunning&&a.messageRepository===i.messageRepository){this._notifySubscribers();return}this.repository.clear(),this._assistantOptimisticId=null,this.repository.import(i.messageRepository),h=this.repository.getMessages()}else if(i.messages){if(a){if(a.convertMessage!==i.convertMessage)this._converter=new ho;else if(a.isRunning===i.isRunning&&a.messages===i.messages){this._notifySubscribers();return}}h=i.convertMessage?this._converter.convertMessages(i.messages,(C,A,R)=>{if(!i.convertMessage)return A;const K=R===i.messages.length-1,At=Gi(K,r,!1,!1,void 0);if(C&&(C.role!=="assistant"||!Ec(C.status)||C.status===At))return C;const gt=i.convertMessage(A,R),ct=ss(gt,R.toString(),At);return ct[tn]=A,ct}):i.messages;for(let C=0;C<h.length;C++){const A=h[C],R=h[C-1];this.repository.addOrUpdateMessage((R==null?void 0:R.id)??null,A)}}else throw new Error("ExternalStoreAdapter must provide either 'messages' or 'messageRepository'");h.length>0&&this.ensureInitialized(),((a==null?void 0:a.isRunning)??!1)!==(i.isRunning??!1)&&(i.isRunning?this._notifyEventSubscribers("run-start"):this._notifyEventSubscribers("run-end")),this._assistantOptimisticId&&(this.repository.deleteMessage(this._assistantOptimisticId),this._assistantOptimisticId=null),oh(r,h)&&(this._assistantOptimisticId=this.repository.appendOptimisticMessage(((I=h.at(-1))==null?void 0:I.id)??null,{role:"assistant",content:[]})),this.repository.resetHead(this._assistantOptimisticId??((P=h.at(-1))==null?void 0:P.id)??null),this._messages=this.repository.getMessages(),this._notifySubscribers()}switchToBranch(i){if(!this._store.setMessages)throw new Error("Runtime does not support switching branches.");this._store.isRunning||(this.repository.switchToBranch(i),this.updateMessages(this.repository.getMessages()))}async append(i){var r;if(i.parentId!==(((r=this.messages.at(-1))==null?void 0:r.id)??null)){if(!this._store.onEdit)throw new Error("Runtime does not support editing messages.");await this._store.onEdit(i)}else await this._store.onNew(i)}async startRun(i){if(!this._store.onReload)throw new Error("Runtime does not support reloading messages.");await this._store.onReload(i.parentId,i)}async resumeRun(i){if(!this._store.onResume)throw new Error("Runtime does not support resuming runs.");await this._store.onResume(i)}unstable_loadExternalState(i){if(!this._store.onLoadExternalState)throw new Error("Runtime does not support importing states.");this._store.onLoadExternalState(i)}cancelRun(){var a;if(!this._store.onCancel)throw new Error("Runtime does not support cancelling runs.");this._store.onCancel(),this._assistantOptimisticId&&(this.repository.deleteMessage(this._assistantOptimisticId),this._assistantOptimisticId=null);let i=this.repository.getMessages();const r=i[i.length-1];(r==null?void 0:r.role)==="user"&&r.id===((a=i.at(-1))==null?void 0:a.id)?(this.repository.deleteMessage(r.id),this.composer.text.trim()||this.composer.setText(Sn(r)),i=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(i)},0)}addToolResult(i){var r,a;if(!this._store.onAddToolResult&&!this._store.onAddToolResult)throw new Error("Runtime does not support tool results.");(a=(r=this._store).onAddToolResult)==null||a.call(r,i)}resumeToolCall(i){if(!this._store.onResumeToolCall)throw new Error("Runtime does not support resuming tool calls.");this._store.onResumeToolCall(i)}reset(i){const r=new Qi;r.import(is.fromArray(i??[])),this.updateMessages(r.getMessages())}import(i){this._assistantOptimisticId=null,super.import(i),this._store.onImport&&this._store.onImport(this.repository.getMessages())}},lo=n=>{var i;return((i=n.adapters)==null?void 0:i.threadList)??{}},uh=class extends gc{constructor(i){super();S(this,"threads");this.threads=new nh(lo(i),()=>new ah(this._contextProvider,i))}setAdapter(i){this.threads.__internal_setAdapter(lo(i)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(i)}},ch=n=>{const[i]=B.useState(()=>new uh(n));B.useEffect(()=>{i.setAdapter(n)});const{modelContext:r}=jc()??{};return B.useEffect(()=>{if(r)return i.registerModelContextProvider(r)},[r,i]),B.useMemo(()=>new dl(i),[i])};function hh(n,i){n.commitTasks.forEach(r=>{const a=r.cellIndex,h=i.cells[a];if(h.type!=="effect")throw new Error("Cannot find effect cell");let f=!0;if(h.deps!==void 0&&r.deps!==void 0&&(f=h.deps.length!==r.deps.length||h.deps.some((p,m)=>!Object.is(p,r.deps[m]))),f){if(h.mounted){if(typeof h.deps!=typeof r.deps)throw new Error("tapEffect called with and without dependencies across re-renders");try{h.mounted&&h.cleanup&&h.cleanup()}finally{h.mounted=!1}}try{const p=r.effect();if(p!==void 0&&typeof p!="function")throw new Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof p}`);h.mounted=!0,h.cleanup=typeof p=="function"?p:void 0,h.deps=r.deps}catch(p){throw p}}})}function lh(n){let i=null;for(let r=n.cells.length-1;r>=0;r--){const a=n.cells[r];if((a==null?void 0:a.type)==="effect"&&a.mounted&&a.cleanup)try{a.cleanup()}catch(h){i==null&&(i=h)}finally{a.mounted=!1}}if(i!=null)throw i}var En=null;function fh(n,i){n.currentIndex=0;const r=En;En=n;try{if(i(),n.isFirstRender=!1,n.cells.length!==n.currentIndex)throw new Error(`Rendered ${n.currentIndex} hooks but expected ${n.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{En=r}}function us(){if(!En)throw new Error("No resource fiber available");return En}function fo(n,i){const r=n[po];if(!r)throw new Error("ResourceElement.type is not a valid Resource");return r(i)}var po=Symbol("fnSymbol");function rr(n,i){return{resource:n,scheduleRerender:i,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function en(n){n.isMounted=!1,lh(n)}function xn(n,i){const r={commitTasks:[],props:i,state:void 0};return fh(n,()=>{n.renderContext=r;try{r.state=fo(n.resource,i)}finally{n.renderContext=void 0}}),r}function nn(n,i){n.isMounted=!0,n.isNeverMounted=!1,hh(i,n)}var dh=globalThis.__ASSISTANT_UI_DISABLE_LAYOUT_EFFECT__===!0,go=dh?B.useEffect:B.useLayoutEffect;function ph(n){const[,i]=B.useState({}),r=B.useMemo(()=>rr(n.type,()=>i({})),[n.type,i]),a=xn(r,n.props);return go(()=>()=>en(r),[]),go(()=>{nn(r,a)}),a.state}var _o=n=>typeof n=="string"?{scope:n.split(".")[0],event:n}:{scope:n.scope,event:n.event},cs=(n,i,r)=>i===n,rn,hs=()=>{if(rn)return rn;const n=()=>({apis:new Map,nextId:0,listeners:new Set});if(typeof window>"u")return rn=n(),rn;const i=window.__ASSISTANT_UI_DEVTOOLS_HOOK__;if(i)return rn=i,i;const r=n();return window.__ASSISTANT_UI_DEVTOOLS_HOOK__=r,rn=r,r},gh=(Xt=class{static register(i){var m,w;const r=hs();for(const I of r.apis.values())if(I.api===i)return()=>{};const a=r.nextId++,h={api:i,logs:[]},f=(m=i.on)==null?void 0:m.call(i,"*",I=>{const P=r.apis.get(a);P&&(P.logs.push({time:new Date,event:I.event,data:I.payload}),P.logs.length>Xt.MAX_EVENT_LOGS_PER_API&&(P.logs=P.logs.slice(-200)),Xt.notifyListeners(a))}),p=(w=i.subscribe)==null?void 0:w.call(i,()=>{Xt.notifyListeners(a)});return r.apis.set(a,h),Xt.notifyListeners(a),()=>{const I=hs();I.apis.get(a)&&(f==null||f(),p==null||p(),I.apis.delete(a),Xt.notifyListeners(a))}}static notifyListeners(i){hs().listeners.forEach(a=>a(i))}},S(Xt,"MAX_EVENT_LOGS_PER_API",200),Xt);function lt(n){const i=(r,a)=>({type:i,props:r,...(a==null?void 0:a.key)!==void 0&&{key:a.key}});return i[po]=n,i}var _h=n=>{if(n.renderContext)throw new Error("Resource updated during render");if(n.isNeverMounted)throw new Error("Resource updated before mount");n.isMounted&&n.scheduleRerender()};function bh(n){const i=us(),r=i.currentIndex++;if(!i.isFirstRender&&r>=i.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!i.cells[r]){const f={type:"state",value:typeof n=="function"?n():n,set:p=>{const m=f.value,w=typeof p=="function"?p(m):p;Object.is(m,w)||(f.value=w,_h(i))}};i.cells[r]=f}const a=i.cells[r];if(a.type!=="state")throw new Error("Hook order changed between renders");return a}function ae(n){const i=bh(n);return[i.value,i.set]}function mh(){const n=us(),i=n.currentIndex++;if(!n.isFirstRender&&i>=n.cells.length)throw new Error("Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.");if(!n.cells[i]){const a={type:"effect",mounted:!1};n.cells[i]=a}if(n.cells[i].type!=="effect")throw new Error("Hook order changed between renders");return i}function Pt(n,i){const r=us(),a=mh();r.renderContext.commitTasks.push({effect:n,deps:i,cellIndex:a})}function sr(n){const[i]=ae(()=>({current:n}));return i}var vh=(n,i)=>{if(n.length!==i.length)return!1;for(let r=0;r<n.length;r++)if(!Object.is(n[r],i[r]))return!1;return!0},rt=(n,i)=>{const r=sr();return r.current||(r.current={value:n(),deps:i}),vh(r.current.deps,i)||(r.current.value=n(),r.current.deps=i),r.current.value};function ls(n,i){const[r,a]=ae({}),h=rt(()=>rr(n.type,()=>a({})),[n.type]),f=i?rt(()=>n.props,i):n.props,p=rt(()=>xn(h,f),[h,f,r]);return Pt(()=>()=>en(h),[h]),Pt(()=>{nn(h,p)},[h,p]),p.state}function Zt(n){return fo(n.type,n.props)}function wh(n){const i=new Set;n.forEach((m,w)=>{if(m.key===void 0)throw new Error(`tapResources: All resource elements must have a key. Element at index ${w} is missing a key.`);if(i.has(m.key))throw new Error(`tapResources: Duplicate key "${m.key}" found. All keys must be unique.`);i.add(m.key)});const[r,a]=ae({}),h=rt(()=>new Map(n.map(m=>[m.key,m])),[n]),[f]=ae(()=>new Map),p=rt(()=>{const m=new Map,w=new Set;return h.forEach((I,P)=>{w.add(P);let C=f.get(P);(!C||C.resource!==I.type)&&(C&&en(C),C=rr(I.type,()=>a({})),f.set(P,C));const A=xn(C,I.props);m.set(P,A)}),f.forEach((I,P)=>{w.has(P)||(en(I),f.delete(P))}),m},[h,r]);return Pt(()=>{p.forEach((m,w)=>{const I=f.get(w);I&&nn(I,m)})},[p,f]),Pt(()=>()=>{f.forEach(m=>{en(m)}),f.clear()},[f]),rt(()=>n.map(m=>{var w;return(w=p.get(m.key))==null?void 0:w.state}),[n,p])}var fs=[],ds=!1;function yh(){ds=!1;const n=fs;fs=[];for(const i of n)try{i()}catch(r){console.error("Error in scheduled task:",r)}}function Sh(n){fs.push(n),ds||(ds=!0,queueMicrotask(yh))}var Eh=(Ue=class{constructor(i){S(this,"_isDirty",!1);S(this,"_hasScheduledTask",!1);S(this,"_isFlushing",!1);this._task=i}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,!(this._hasScheduledTask||this._isFlushing)&&(this._hasScheduledTask=!0,Sh(()=>{this._hasScheduledTask=!1,this.flushSync()}))}flushSync(){if(this._isFlushing)return;this._isFlushing=!0;let i=0;try{for(;this._isDirty;){if(i++,i>Ue.MAX_FLUSH_DEPTH)throw new Error("Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside tapEffect.");this._isDirty=!1,this._task()}}finally{this._isFlushing=!1}}},S(Ue,"MAX_FLUSH_DEPTH",50),Ue),xh=lt(({element:n,onUpdateInput:i,onFlushSync:r,onDispose:a})=>{const[h,f]=ae(n.props),p=Zt({type:n.type,props:h}),m=sr(new Set).current,w=sr(p);return Pt(()=>{p!==w.current&&(w.current=p,m.forEach(P=>P()))}),rt(()=>({getState:()=>w.current,subscribe:P=>(m.add(P),()=>m.delete(P)),updateInput:P=>{i(),f(()=>P)},flushSync:r,dispose:a}),[])}),Th=(n,i=!1)=>{let r=!i;const a={element:n,onUpdateInput:()=>{r||(r=!0,nn(f,p))},onFlushSync:()=>{h.flushSync()},onDispose:()=>en(f)},h=new Eh(()=>{p=xn(f,a),r&&nn(f,p)}),f=rr(xh,()=>h.markDirty());let p=xn(f,a);return r&&nn(f,p),p.state},Tn=Symbol("tap.Context"),bo=n=>({[Tn]:n}),mo=(n,i,r)=>{const a=n[Tn];n[Tn]=i;try{return r()}finally{n[Tn]=a}},vo=n=>n[Tn];const wo=n=>{let i;const r=new Set,a=(I,P)=>{const C=typeof I=="function"?I(i):I;if(!Object.is(C,i)){const A=i;i=P??(typeof C!="object"||C===null)?C:Object.assign({},i,C),r.forEach(R=>R(i,A))}},h=()=>i,m={setState:a,getState:h,getInitialState:()=>w,subscribe:I=>(r.add(I),()=>r.delete(I))},w=i=n(a,h,m);return m},Ah=n=>n?wo(n):wo,Ch=n=>n;function Ih(n,i=Ch){const r=B.useSyncExternalStore(n.subscribe,B.useCallback(()=>i(n.getState()),[n,i]),B.useCallback(()=>i(n.getInitialState()),[n,i]));return B.useDebugValue(r),r}const yo=n=>{const i=Ah(n),r=a=>Ih(i,a);return Object.assign(r,i),r},Rh=n=>n?yo(n):yo;var Mh=lt(n=>{const i=rt(()=>Th(n,!0),[n.type]);return Pt(()=>{i.updateInput(n.props)}),i}),Ph=class{constructor(n){this.getApi=n}get(n,i){return this.getApi()[i]}ownKeys(){return Object.keys(this.getApi())}has(n,i){return i in this.getApi()}getOwnPropertyDescriptor(n,i){return Object.getOwnPropertyDescriptor(this.getApi(),i)}set(){return!1}defineProperty(){return!1}deleteProperty(){return!1}},ue=(n,i)=>{const r=sr(n);Pt(()=>{r.current=n});const a=rt(()=>new Proxy({},new Ph(()=>r.current)),[]),h=i==null?void 0:i.key,f=n.getState();return rt(()=>({key:h,state:f,api:a}),[f,h])},So=bo(null),Oh=(n,i)=>mo(So,n,i),Eo=()=>{const n=vo(So);if(!n)throw new Error("Model context is not available in this context");return n},Lh=lt(({toolkit:n})=>{const[i,r]=ae(()=>({tools:{}})),a=Eo();Pt(()=>{if(!n)return;const f=[];for(const[w,I]of Object.entries(n))I.render&&f.push(h(w,I.render));const p=Object.entries(n).reduce((w,[I,P])=>{const{render:C,...A}=P;return w[I]=A,w},{}),m={getModelContext:()=>({tools:p})};return f.push(a.register(m)),()=>{f.forEach(w=>w())}},[n,a]);const h=(f,p)=>(r(m=>({...m,tools:{...m.tools,[f]:[...m.tools[f]??[],p]}})),()=>{r(m=>{var w;return{...m,tools:{...m.tools,[f]:((w=m.tools[f])==null?void 0:w.filter(I=>I!==p))??[]}}})});return ue({getState:()=>i,setToolUI:h})}),Bh=lt(()=>rt(()=>{const i=new Map;return{on:(r,a)=>{i.has(r)||i.set(r,new Set);const h=i.get(r);return h.add(a),()=>{h.delete(a),h.size===0&&i.delete(r)}},emit:(r,a)=>{const h=i.get(r),f=i.get("*");!h&&!f||queueMicrotask(()=>{if(h)for(const p of h)p(a);if(f)for(const p of f)p({event:r,payload:a})})}}},[])),xo=bo(null),kh=(n,i)=>mo(xo,n,i),ps=()=>{const n=vo(xo);if(!n)throw new Error("Events context is not available");return n},Dh=lt(()=>{const[n]=ae(()=>({})),i=new Hi;return ue({getState:()=>n,getModelContext:()=>i.getModelContext(),subscribe:r=>i.subscribe(r),register:r=>i.registerModelContextProvider(r)})}),Nh=lt(({threads:n,modelContext:i,tools:r})=>{const a=Zt(Bh()),{threads:h,tools:f,modelContext:p}=kh(a,()=>{const w=ls(i??Dh(),[i]);return Oh(w.api,()=>({modelContext:w,tools:ls(r??Lh({}),[r]),threads:ls(n,[n])}))}),m=rt(()=>({threads:h.state,tools:f.state,modelContext:p.state}),[h.state,f.state,p.state]);return ue({getState:()=>m,threads:h.api,tools:f.api,modelContext:p.api,on:a.on})}),Fh=n=>{const i=()=>n.getState().api.threads.item("main");return{threads:yt({source:"root",query:{},get:()=>n.getState().api.threads}),tools:yt({source:"root",query:{},get:()=>n.getState().api.tools}),modelContext:yt({source:"root",query:{},get:()=>n.getState().api.modelContext}),thread:yt({source:"threads",query:{type:"main"},get:()=>n.getState().api.threads.thread("main")}),threadListItem:yt({source:"threads",query:{type:"main"},get:()=>i()}),composer:yt({source:"thread",query:{},get:()=>n.getState().api.threads.thread("main").composer}),on(r,a){const{event:h,scope:f}=_o(r);if(f==="*")return n.getState().api.on(h,a);if(cs("thread",f)||cs("thread-list-item",f)||cs("composer",f))return n.getState().api.on(h,p=>{p.threadId===i().getState().id&&a(p)});throw new Error(`Event scope is not available in this component: ${f}`)},subscribe:n.subscribe,flushSync:n.flushSync}},Uh=n=>{const i=Ao(),r=ph(Mh(Nh(n))),a=B.useMemo(()=>Fh(r),[r]);return B.useMemo(()=>Hh(i,a),[i,a])},yt=n=>{const i=n.get;return i.source=n.source,i.query=n.query,i},xe=()=>()=>{},To=B.createContext({threads:yt({source:null,query:{},get:()=>{throw new Error("Threads is only available inside <AssistantProvider />")}}),tools:yt({source:null,query:{},get:()=>{throw new Error("Tools is only available inside <AssistantProvider />")}}),modelContext:yt({source:null,query:{},get:()=>{throw new Error("ModelContext is only available inside <AssistantProvider />")}}),threadListItem:yt({source:null,query:{},get:()=>{throw new Error("ThreadListItem is only available inside <AssistantProvider />")}}),thread:yt({source:null,query:{},get:()=>{throw new Error("Thread is only available inside <AssistantProvider />")}}),composer:yt({source:null,query:{},get:()=>{throw new Error("Composer is only available inside <AssistantProvider />")}}),message:yt({source:null,query:{},get:()=>{throw new Error("Message is only available inside <ThreadPrimitive.Messages />")}}),part:yt({source:null,query:{},get:()=>{throw new Error("Part is only available inside <MessagePrimitive.Parts />")}}),attachment:yt({source:null,query:{},get:()=>{throw new Error("Attachment is only available inside <MessagePrimitive.Attachments /> or <ComposerPrimitive.Attachments />")}}),subscribe:xe,flushSync:xe,on:n=>{const{scope:i}=_o(n);throw new Error(`Event scope is not available in this component: ${i}`)}}),Ao=()=>B.useContext(To),Wh=n=>Uh(n);function $h(n){return n?Wh(n):Ao()}var qh=(n,i)=>n===xe?i:i===xe?n:(...r)=>{n(...r),i(...r)},zh=(n,i)=>n===xe?i:i===xe?n:(...r)=>{const a=n(...r),h=i(...r);return()=>{a(),h()}},Hh=(n,i)=>{const r=i.subscribe,a=i.flushSync;return{...n,...i,subscribe:zh(n.subscribe,r??xe),flushSync:qh(n.flushSync,a??xe)}},Jh=({api:n,children:i,devToolsVisible:r=!0})=>(B.useEffect(()=>{if(!(!r||!n.subscribe))return gh.register(n)},[n,r]),Ee.jsx(To.Provider,{value:n,children:i}));function Gh(n,i){function r(a){const h=B.useContext(n);if(!(a!=null&&a.optional)&&!h)throw new Error(`This component must be used within ${i}.`);return h}return r}function Kh(n,i){function r(h){const f=n(h);return f?f[i]:null}function a(h){let f=!1,p;typeof h=="function"?p=h:h&&typeof h=="object"&&(f=!!h.optional,p=h.selector);const m=r({optional:f});return m?p?m(p):m():null}return{[i]:a,[`${i}Store`]:r}}var Co=B.createContext(null),Yh=Gh(Co,"ThreadPrimitive.Viewport"),{useThreadViewportStore:Vh}=Kh(Yh,"useThreadViewport"),Ne=n=>{const[,i]=ae(n.getState);return Pt(()=>(i(n.getState()),n.subscribe(()=>{i(n.getState())})),[n]),n.getState()},Zh=lt(({runtime:n})=>{const i=Ne(n),r=ps();return Pt(()=>{const a=[],h=["switched-to","switched-away"];for(const f of h){const p=n.unstable_on(f,()=>{r.emit(`thread-list-item.${f}`,{threadId:n.getState().id})});a.push(p)}return()=>{for(const f of a)f()}},[n,r]),ue({getState:()=>i,switchTo:n.switchTo,rename:n.rename,archive:n.archive,unarchive:n.unarchive,delete:n.delete,generateTitle:n.generateTitle,initialize:n.initialize,detach:n.detach,__internal_getRuntime:()=>n},{key:i.id})}),An=n=>{const i=wh(n);return{state:i.map(r=>r.state),api:r=>{var h,f;const a="index"in r?(h=i[r.index])==null?void 0:h.api:(f=i.find(p=>p.key===r.key))==null?void 0:f.api;if(!a)throw new Error(`tapLookupResources: Resource not found for lookup: ${JSON.stringify(r)}`);return a}}},Io=lt(({runtime:n})=>{const i=Ne(n);return ue({getState:()=>i,remove:n.remove,__internal_getRuntime:()=>n},{key:i.id})}),Xh=lt(({runtime:n,index:i})=>{const r=rt(()=>n.getAttachmentByIndex(i),[n,i]);return Zt(Io({runtime:r}))}),Ro=lt(({threadIdRef:n,messageIdRef:i,runtime:r})=>{const a=Ne(r),h=ps();Pt(()=>{const m=[],w=["send","attachment-add"];for(const I of w){const P=r.unstable_on(I,()=>{h.emit(`composer.${I}`,{threadId:n.current,...i&&{messageId:i.current}})});m.push(P)}return()=>{for(const I of m)I()}},[r,h,n,i]);const f=An(a.attachments.map((m,w)=>Xh({runtime:r,index:w},{key:w}))),p=rt(()=>({text:a.text,role:a.role,attachments:f.state,runConfig:a.runConfig,isEditing:a.isEditing,canCancel:a.canCancel,attachmentAccept:a.attachmentAccept,isEmpty:a.isEmpty,type:a.type??"thread"}),[a,f.state]);return ue({getState:()=>p,setText:r.setText,setRole:r.setRole,setRunConfig:r.setRunConfig,addAttachment:r.addAttachment,reset:r.reset,clearAttachments:r.clearAttachments,send:r.send,cancel:r.cancel,beginEdit:r.beginEdit??(()=>{throw new Error("beginEdit is not supported in this runtime")}),attachment:m=>"id"in m?f.api({key:m.id}):f.api(m),__internal_getRuntime:()=>r})}),Qh=lt(({runtime:n})=>{const i=Ne(n);return ue({getState:()=>i,addToolResult:a=>n.addToolResult(a),resumeToolCall:a=>n.resumeToolCall(a),__internal_getRuntime:()=>n},{key:i.type==="tool-call"?`toolCallId-${i.toolCallId}`:void 0})}),jh=lt(({runtime:n,index:i})=>{const r=rt(()=>n.getAttachmentByIndex(i),[n,i]);return Zt(Io({runtime:r}))}),tl=lt(({runtime:n,index:i})=>{const r=rt(()=>n.getMessagePartByIndex(i),[n,i]);return Zt(Qh({runtime:r}))}),el=lt(({runtime:n,threadIdRef:i})=>{var A;const r=Ne(n),[a,h]=ae(!1),[f,p]=ae(!1),m=rt(()=>({get current(){return n.getState().id}}),[n]),w=Zt(Ro({runtime:n.composer,threadIdRef:i,messageIdRef:m})),I=An(r.content.map((R,K)=>tl({runtime:n,index:K},{key:K}))),P=An(((A=r.attachments)==null?void 0:A.map((R,K)=>jh({runtime:n,index:K},{key:K})))??[]),C=rt(()=>({...r,parts:I.state,composer:w.state,isCopied:a,isHovering:f}),[r,I.state,w.state,a,f]);return ue({getState:()=>C,composer:w.api,reload:R=>n.reload(R),speak:()=>n.speak(),stopSpeaking:()=>n.stopSpeaking(),submitFeedback:R=>n.submitFeedback(R),switchToBranch:R=>n.switchToBranch(R),getCopyText:()=>n.unstable_getCopyText(),part:R=>"index"in R?I.api({index:R.index}):I.api({key:`toolCallId-${R.toolCallId}`}),attachment:R=>"id"in R?P.api({key:R.id}):P.api(R),setIsCopied:h,setIsHovering:p,__internal_getRuntime:()=>n},{key:r.id})}),nl=lt(({runtime:n,id:i,threadIdRef:r})=>{const a=rt(()=>n.getMessageById(i),[n,i]);return Zt(el({runtime:a,threadIdRef:r}))}),rl=lt(({runtime:n})=>{const i=Ne(n),r=ps();Pt(()=>{const m=[],w=["run-start","run-end","initialize","model-context-update"];for(const I of w){const P=n.unstable_on(I,()=>{var A;const C=((A=n.getState())==null?void 0:A.threadId)||"unknown";r.emit(`thread.${I}`,{threadId:C})});m.push(P)}return()=>{for(const I of m)I()}},[n]);const a=rt(()=>({get current(){return n.getState().threadId}}),[n]),h=Zt(Ro({runtime:n.composer,threadIdRef:a})),f=An(i.messages.map(m=>nl({runtime:n,id:m.id,threadIdRef:a},{key:m.id}))),p=rt(()=>({isDisabled:i.isDisabled,isLoading:i.isLoading,isRunning:i.isRunning,capabilities:i.capabilities,state:i.state,suggestions:i.suggestions,extras:i.extras,speech:i.speech,composer:h.state,messages:f.state}),[i,f,h.state]);return ue({getState:()=>p,composer:h.api,append:n.append,startRun:n.startRun,unstable_resumeRun:n.unstable_resumeRun,cancelRun:n.cancelRun,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,startVoice:async()=>{throw new Error("startVoice is not supported in this runtime")},stopVoice:async()=>{throw new Error("stopVoice is not supported in this runtime")},message:m=>"id"in m?f.api({key:m.id}):f.api(m),__internal_getRuntime:()=>n})}),sl=lt(({runtime:n,id:i})=>{const r=rt(()=>n.getItemById(i),[n,i]);return Zt(Zh({runtime:r}))}),il=lt(({runtime:n,__internal_assistantRuntime:i})=>{const r=Ne(n),a=Zt(rl({runtime:n.main})),h=An(Object.keys(r.threadItems).map(p=>sl({runtime:n,id:p},{key:p}))),f=rt(()=>({mainThreadId:r.mainThreadId,newThreadId:r.newThread??null,isLoading:r.isLoading,threadIds:r.threads,archivedThreadIds:r.archivedThreads,threadItems:h.state,main:a.state}),[r,h.state,a.state]);return ue({getState:()=>f,thread:()=>a.api,item:p=>{if(p==="main")return h.api({key:f.mainThreadId});if("id"in p)return h.api({key:p.id});const{index:m,archived:w=!1}=p,I=w?f.archivedThreadIds[m]:f.threadIds[m];return h.api({key:I})},switchToThread:p=>{n.switchToThread(p)},switchToNewThread:()=>{n.switchToNewThread()},__internal_getAssistantRuntime:()=>i})}),ol=lt(n=>{const i=Eo();return Pt(()=>n.registerModelContextProvider(i),[n,i]),Zt(il({runtime:n.threads,__internal_assistantRuntime:n}))}),gs=n=>{const i=new Map,r=()=>{let a=0;for(const h of i.values())a+=h;n(a)};return{register:()=>{const a=Symbol();return i.set(a,0),{setHeight:h=>{i.get(a)!==h&&(i.set(a,h),r())},unregister:()=>{i.delete(a),r()}}}}},al=(n={})=>{const i=new Set,r=gs(p=>{f.setState({height:{...f.getState().height,viewport:p}})}),a=gs(p=>{f.setState({height:{...f.getState().height,inset:p}})}),h=gs(p=>{f.setState({height:{...f.getState().height,userMessage:p}})}),f=Rh(()=>({isAtBottom:!0,scrollToBottom:({behavior:p="auto"}={})=>{for(const m of i)m({behavior:p})},onScrollToBottom:p=>(i.add(p),()=>{i.delete(p)}),turnAnchor:n.turnAnchor??"bottom",height:{viewport:0,inset:0,userMessage:0},registerViewport:r.register,registerContentInset:a.register,registerUserMessageHeight:h.register}));return f},Mo=n=>n,ul=n=>{const i=Vh({optional:!0}),[r]=B.useState(()=>al(n));return B.useEffect(()=>i==null?void 0:i.getState().onScrollToBottom(()=>{r.getState().scrollToBottom()}),[i,r]),B.useEffect(()=>{if(i)return r.subscribe(a=>{i.getState().isAtBottom!==a.isAtBottom&&Mo(i).setState({isAtBottom:a.isAtBottom})})},[r,i]),B.useEffect(()=>{const a={turnAnchor:n.turnAnchor??"bottom"};r.getState().turnAnchor!==a.turnAnchor&&Mo(r).setState(a)},[r,n.turnAnchor]),r},cl=({children:n,options:i={}})=>{const r=ul(i),[a]=B.useState(()=>({useThreadViewport:r}));return Ee.jsx(Co.Provider,{value:a,children:n})},hl=n=>{var i;return(i=n._core)==null?void 0:i.RenderComponent},ll=({children:n,runtime:i})=>{const r=$h({threads:ol(i)}),a=hl(i);return Ee.jsxs(Jh,{api:r,children:[a&&Ee.jsx(a,{}),Ee.jsx(cl,{children:n})]})},fl=B.memo(ll),dl=class{constructor(n){S(this,"threads");S(this,"_thread");this._core=n,this.threads=new Yc(n.threads),this._thread=this.threads.main,this.__internal_bindMethods()}get threadList(){return this.threads}__internal_bindMethods(){this.switchToNewThread=this.switchToNewThread.bind(this),this.switchToThread=this.switchToThread.bind(this),this.registerModelContextProvider=this.registerModelContextProvider.bind(this),this.registerModelConfigProvider=this.registerModelConfigProvider.bind(this),this.reset=this.reset.bind(this)}get thread(){return this._thread}switchToNewThread(){return this._core.threads.switchToNewThread()}switchToThread(n){return this._core.threads.switchToThread(n)}registerModelContextProvider(n){return this._core.registerModelContextProvider(n)}registerModelConfigProvider(n){return this.registerModelContextProvider(n)}reset({initialMessages:n}={}){return this._core.threads.getMainThreadRuntimeCore().import(is.fromArray(n??[]))}};function pl(n){return n.filter(i=>i.finishReason==="stop"?i.text!==null&&i.text.trim()!=="":!0)}function Po(n){const i=[];let r=null;for(const h of n)if(h.type!=="transaction")if(h.file){r&&(i.push(r),r=null),i.push(h);continue}else h.functionCalls?(r&&i.push(r),i.push(h),r=null):h.functionResponse?i[i.length-1]={...i[i.length-1],functionResponse:h.functionResponse}:r&&h.type===r.type&&h.protocol===r.protocol&&r.role===h.role?(r.text+=h.text,r.file=r.file||h.file):(r&&i.push(r),r={...h,text:h.file?"":h.text,finishReason:h.file?void 0:h.finishReason});return r&&i.push(r),pl(i)}function gl(n){var r;const i=n.file?[{type:"file",data:n.file.url,mimeType:n.file.contentType}]:[];return n.role==="function"?{id:n.id,role:"assistant",status:(n==null?void 0:n.functionResponse)===null?{type:"running"}:{type:"complete",reason:"stop"},content:((r=n.functionCalls)==null?void 0:r.map(a=>{var h;return{type:"tool-call",toolName:a.name,toolCallId:a.id,args:a.args,result:(h=n.functionResponse)==null?void 0:h.result}}))??[]}:{id:n.id,role:n.role,content:n.type==="reasoning"?[{type:"reasoning",text:n.text},...i]:[{type:"text",text:n.text},...i]}}class Cn{constructor(){S(this,"statusChangeCallbacks",[]);S(this,"messageCallbacks",[])}addStatusChangeListener(i){this.statusChangeCallbacks.push(i)}addPacketListener(i){this.messageCallbacks.push(i)}async syncSession(i){this.session=i}async notifyPacket(i){this.messageCallbacks.forEach(r=>r(i))}async notifyPackets(i){i.forEach(r=>{this.messageCallbacks.forEach(a=>a(r))})}async setSession(i){this.session=i}async setStatus(i){const r=this.status!==i;this.status=i,r&&this.statusChangeCallbacks.forEach(a=>a(i))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}onTransaction(i){}}class _s extends Cn{constructor(r){super();S(this,"status");S(this,"autostart");S(this,"session");S(this,"config");S(this,"notify",!0);S(this,"context",{});S(this,"tools",[]);this.config=r,this.status="disconnected",this.autostart=!0}getName(){return"rest"}getPriority(){return 100}async connect(r){return this.setStatus("connected"),r}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(r){this.session=r}async sendPacket(r){var w,I,P,C,A;const{apiUrl:a,apiKey:h,agentId:f}=this.config,p=this.session??"new";if(r.type==="command"&&((w=r==null?void 0:r.payload)==null?void 0:w.command)=="set_initial_context"){this.context=(I=r==null?void 0:r.payload)==null?void 0:I.arguments;return}else if(r.type==="command"&&((P=r==null?void 0:r.payload)==null?void 0:P.command)=="set_local_tools"){const R=(C=r==null?void 0:r.payload)==null?void 0:C.arguments.tools;(R==null?void 0:R.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const m=r.payload;try{const K=await(await fetch(`${a}/sessions/${p}/messages`,{body:JSON.stringify({agentId:f,userMessage:m,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":h}})).json();this.notifyPackets(K.response.messages.map(At=>({type:"message",payload:At})))}catch(R){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(A=this.config.logger)==null||A.error("Error sending packet:",R)}}}class bs extends Cn{constructor(r){super();S(this,"status");S(this,"autostart");S(this,"session");S(this,"config");S(this,"webSocket");this.config=r,this.status="disconnected",this.autostart=!0,this.session=null,this.webSocket=null}getName(){return"websocket"}getPriority(){return 500}async syncSession(r){var a;(a=this.config.logger)==null||a.debug("Syncing session with WebSocket protocol:",r),this.session=r,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(r))}connect(r){var m;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const a=r||this.session||"new";(m=this.config.logger)==null||m.debug("Connecting to WebSocket with sessionId:",a);const h=encodeURIComponent(this.config.apiKey),f=this.config.agentId,p=`${this.config.webSocketUrl}?sessionCode=${a}&agentId=${f}&apiKey=${h}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(p),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",w=>{const I=JSON.parse(w.data);this.notifyPacket(I)}),this.webSocket.addEventListener("close",w=>{var I;this.setStatus("disconnected"),this.webSocket=null,w.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(I=this.config.logger)==null||I.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var w;this.setStatus("disconnected"),this.webSocket=null,(w=this.config.logger)==null||w.error("WebSocket connection error")}),Promise.resolve(a)}disconnect(){var r;return(r=this.config.logger)==null||r.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(r){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(r)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class _l{constructor(i){S(this,"config");S(this,"pc",null);S(this,"ws",null);S(this,"localStream",null);S(this,"remoteStream",new MediaStream);S(this,"audioCtx",null);S(this,"localAnalyser",null);S(this,"remoteAnalyser",null);S(this,"analyzerFrame",null);S(this,"dataChannel",null);S(this,"isConnected",!1);S(this,"visualizerCallbacks",[]);S(this,"messageCallbacks",[]);S(this,"errorCallbacks",[]);S(this,"queuedMessages",[]);this.config=i}async connect(i){var a;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(h){(a=this.config.logger)==null||a.error("Error accessing microphone:",h);return}this.pc=new RTCPeerConnection({iceServers:this.config.iceServers||[{urls:"stun:34.38.108.251:3478"},{urls:"turn:34.38.108.251:3478",username:"webrtc",credential:"webrtc"}]}),this.localStream.getTracks().forEach(h=>{this.pc.addTrack(h,this.localStream)}),this.pc.ontrack=h=>{h.streams[0].getTracks().forEach(p=>{this.remoteStream.addTrack(p)}),this.audioCtx||this._startAnalyzers();const f=new Audio;f.srcObject=this.remoteStream,f.play().catch(p=>{var m;(m=this.config.logger)==null||m.error("Error playing remote audio:",p)})},this.pc.onicecandidate=h=>{var f;h.candidate&&((f=this.ws)==null?void 0:f.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:h.candidate}}))},this.pc.ondatachannel=h=>{const f=h.channel;f.onmessage=p=>{this.messageCallbacks.forEach(m=>{m(p)})},f.onopen=()=>{var p;for(;this.queuedMessages.length>0;){const m=this.queuedMessages.shift();m&&(f.send(JSON.stringify(m)),(p=this.config.logger)==null||p.info("Sent queued message:",m))}}};const r=this.config.webrtcUrl||"wss://persona.applica.guru/api/webrtc";this.ws=new WebSocket(`${r}?apiKey=${encodeURIComponent(this.config.apiKey)}`),this.ws.onopen=async()=>{var m,w;const h=await this.pc.createOffer();await this.pc.setLocalDescription(h);const f={apiKey:this.config.apiKey,agentId:this.config.agentId,sessionCode:i};(m=this.config.logger)==null||m.debug("Opening connection to WebRTC server: ",f);const p={type:"OFFER",src:((w=crypto.randomUUID)==null?void 0:w.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:h.sdp,type:h.type},connectionId:(Date.now()%1e6).toString(),metadata:f}};this.ws.send(JSON.stringify(p))},this.ws.onmessage=async h=>{var p;const f=JSON.parse(h.data);if(f.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(f.payload.sdp));else if(f.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(f.payload.candidate))}catch(m){(p=this.config.logger)==null||p.error("Error adding ICE candidate:",m)}},this.ws.onclose=h=>{h.code!==1e3&&this.errorCallbacks.forEach(f=>{f("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var i;this.isConnected&&(this.isConnected=!1,((i=this.ws)==null?void 0:i.readyState)===WebSocket.OPEN&&this.ws.close(),this.pc&&this.pc.close(),this.localStream&&this.localStream.getTracks().forEach(r=>r.stop()),this.remoteStream=new MediaStream,this.audioCtx&&(await this.audioCtx.close(),this.audioCtx=null),this._stopAnalyzers())}addVisualizerCallback(i){this.visualizerCallbacks.push(i)}addMessageCallback(i){this.messageCallbacks.push(i)}addErrorCallback(i){this.errorCallbacks.push(i)}createDataChannel(i="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(i),this.dataChannel.onopen=()=>{var r,a;for((r=this.config.logger)==null||r.info("Data channel opened");this.queuedMessages.length>0;){const h=this.queuedMessages.shift();h&&(this.dataChannel.send(JSON.stringify(h)),(a=this.config.logger)==null||a.info("Sent queued message:",h))}},this.dataChannel.onmessage=r=>{this.messageCallbacks.forEach(a=>{a(r)})})}sendPacket(i){var r;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(i);return}this.dataChannel.send(JSON.stringify(i)),(r=this.config.logger)==null||r.info("Sent message:",i)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const i=this.audioCtx.createMediaStreamSource(this.localStream),r=this.audioCtx.createMediaStreamSource(this.remoteStream);this.localAnalyser=this.audioCtx.createAnalyser(),this.remoteAnalyser=this.audioCtx.createAnalyser(),this.localAnalyser.fftSize=256,this.remoteAnalyser.fftSize=256,i.connect(this.localAnalyser),r.connect(this.remoteAnalyser);const a=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const h=new Uint8Array(this.localAnalyser.frequencyBinCount),f=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(h),this.remoteAnalyser.getByteFrequencyData(f);const p=h.reduce((w,I)=>w+I,0)/h.length,m=f.reduce((w,I)=>w+I,0)/f.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(w=>{w({localAmplitude:p,remoteAmplitude:m})}),this.analyzerFrame=requestAnimationFrame(a)};this.analyzerFrame=requestAnimationFrame(a)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class ms extends Cn{constructor(r){super();S(this,"status");S(this,"session");S(this,"autostart");S(this,"config");S(this,"webRTCClient");this.config=r,this.status="disconnected",this.session=null,this.autostart=(r==null?void 0:r.autostart)??!1,this.webRTCClient=new _l(r),this.webRTCClient.addMessageCallback(a=>{const h=JSON.parse(a.data);this.notifyPacket(h)}),this.webRTCClient.addErrorCallback(a=>{var h;(h=this.config.logger)==null||h.error("WebRTC error:",a),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:a}})})}getName(){return"webrtc"}getPriority(){return 1e3}async syncSession(r){super.syncSession(r),this.status==="connected"&&(await this.disconnect(),await this.connect(r))}async connect(r){var a;return this.status==="connected"?Promise.resolve(this.session):(this.session=r||this.session||"new",this.setStatus("connecting"),(a=this.config.logger)==null||a.debug("Connecting to WebRTC with sessionId:",this.session),await this.webRTCClient.connect(this.session),this.setStatus("connected"),await this.webRTCClient.createDataChannel(),this.session)}async disconnect(){var r,a,h;if(this.status==="disconnected")return(r=this.config.logger)==null||r.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(h=(a=this.config)==null?void 0:a.logger)==null||h.debug("Disconnected from WebRTC")}sendPacket(r){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(r),Promise.resolve())}}var ir={exports:{}};/**
1
+ (function($,pn){typeof exports=="object"&&typeof module<"u"?pn(exports,require("react/jsx-runtime"),require("react"),require("@assistant-ui/react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react","@assistant-ui/react"],pn):($=typeof globalThis<"u"?globalThis:$||self,pn($.personaSDK={},$.React,$.React,$.AssistantUI))})(this,function($,pn,tn,Ce){"use strict";var qd=Object.defineProperty;var Kd=($,pn,tn)=>pn in $?qd($,pn,{enumerable:!0,configurable:!0,writable:!0,value:tn}):$[pn]=tn;var E=($,pn,tn)=>Kd($,typeof pn!="symbol"?pn+"":pn,tn);function Po(y){return y.filter(p=>p.finishReason==="stop"?p.text!==null&&p.text.trim()!=="":!0)}function Hi(y){const p=[];let i=null;for(const m of y)if(m.type!=="transaction")if(m.file){i&&(p.push(i),i=null),p.push(m);continue}else m.functionCalls?(i&&p.push(i),p.push(m),i=null):m.functionResponse?p[p.length-1]={...p[p.length-1],functionResponse:m.functionResponse}:i&&m.type===i.type&&m.protocol===i.protocol&&i.role===m.role?(i.text+=m.text,i.file=i.file||m.file):(i&&p.push(i),i={...m,text:m.file?"":m.text,finishReason:m.file?void 0:m.finishReason});return i&&p.push(i),Po(p)}function Eo(y){var i;const p=y.file?[{type:"file",data:y.file.url,mimeType:y.file.contentType}]:[];return y.role==="function"?{id:y.id,role:"assistant",status:(y==null?void 0:y.functionResponse)===null?{type:"running"}:{type:"complete",reason:"stop"},content:((i=y.functionCalls)==null?void 0:i.map(w=>{var m;return{type:"tool-call",toolName:w.name,toolCallId:w.id,args:w.args,result:(m=y.functionResponse)==null?void 0:m.result}}))??[]}:{id:y.id,role:y.role,content:y.type==="reasoning"?[{type:"reasoning",text:y.text},...p]:[{type:"text",text:y.text},...p]}}class jt{constructor(){E(this,"statusChangeCallbacks",[]);E(this,"messageCallbacks",[])}addStatusChangeListener(p){this.statusChangeCallbacks.push(p)}addPacketListener(p){this.messageCallbacks.push(p)}async syncSession(p){this.session=p}async notifyPacket(p){this.messageCallbacks.forEach(i=>i(p))}async notifyPackets(p){p.forEach(i=>{this.messageCallbacks.forEach(w=>w(i))})}async setSession(p){this.session=p}async setStatus(p){const i=this.status!==p;this.status=p,i&&this.statusChangeCallbacks.forEach(w=>w(p))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}onTransaction(p){}}class xr extends jt{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 K,rn,Rn,un,Tn;const{apiUrl:w,apiKey:m,agentId:R}=this.config,C=this.session??"new";if(i.type==="command"&&((K=i==null?void 0:i.payload)==null?void 0:K.command)=="set_initial_context"){this.context=(rn=i==null?void 0:i.payload)==null?void 0:rn.arguments;return}else if(i.type==="command"&&((Rn=i==null?void 0:i.payload)==null?void 0:Rn.command)=="set_local_tools"){const dn=(un=i==null?void 0:i.payload)==null?void 0:un.arguments.tools;(dn==null?void 0:dn.length)>0&&this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:"Local tools with rest protocol are not supported."}});return}const O=i.payload;try{const Pn=await(await fetch(`${w}/sessions/${C}/messages`,{body:JSON.stringify({agentId:R,userMessage:O,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":m}})).json();this.notifyPackets(Pn.response.messages.map(gt=>({type:"message",payload:gt})))}catch(dn){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(Tn=this.config.logger)==null||Tn.error("Error sending packet:",dn)}}}class Sr extends jt{constructor(i){super();E(this,"status");E(this,"autostart");E(this,"session");E(this,"config");E(this,"webSocket");this.config=i,this.status="disconnected",this.autostart=!0,this.session=null,this.webSocket=null}getName(){return"websocket"}getPriority(){return 500}async syncSession(i){var w;(w=this.config.logger)==null||w.debug("Syncing session with WebSocket protocol:",i),this.session=i,this.webSocket&&this.status==="connected"&&(this.disconnect(),this.connect(i))}connect(i){var O;if(this.webSocket!==null&&this.status==="connected")return Promise.resolve(this.session);const w=i||this.session||"new";(O=this.config.logger)==null||O.debug("Connecting to WebSocket with sessionId:",w);const m=encodeURIComponent(this.config.apiKey),R=this.config.agentId,C=`${this.config.webSocketUrl}?sessionCode=${w}&agentId=${R}&apiKey=${m}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(C),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",K=>{const rn=JSON.parse(K.data);this.notifyPacket(rn)}),this.webSocket.addEventListener("close",K=>{var rn;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."}}),(rn=this.config.logger)==null||rn.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(w)}disconnect(){var i;return(i=this.config.logger)==null||i.debug("Disconnecting WebSocket"),this.webSocket&&this.status==="connected"&&(this.webSocket.close(),this.setStatus("disconnected"),this.webSocket=null),Promise.resolve()}sendPacket(i){return this.webSocket&&this.status==="connected"?(this.webSocket.send(JSON.stringify(i)),Promise.resolve()):Promise.reject(new Error("WebSocket is not connected"))}}class Io{constructor(p){E(this,"config");E(this,"pc",null);E(this,"ws",null);E(this,"localStream",null);E(this,"remoteStream",new MediaStream);E(this,"audioCtx",null);E(this,"localAnalyser",null);E(this,"remoteAnalyser",null);E(this,"analyzerFrame",null);E(this,"dataChannel",null);E(this,"isConnected",!1);E(this,"visualizerCallbacks",[]);E(this,"messageCallbacks",[]);E(this,"errorCallbacks",[]);E(this,"queuedMessages",[]);this.config=p}async connect(p){var w;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(m){(w=this.config.logger)==null||w.error("Error accessing microphone:",m);return}this.pc=new RTCPeerConnection({iceServers:this.config.iceServers||[{urls:"stun:34.38.108.251:3478"},{urls:"turn:34.38.108.251:3478",username:"webrtc",credential:"webrtc"}]}),this.localStream.getTracks().forEach(m=>{this.pc.addTrack(m,this.localStream)}),this.pc.ontrack=m=>{m.streams[0].getTracks().forEach(C=>{this.remoteStream.addTrack(C)}),this.audioCtx||this._startAnalyzers();const R=new Audio;R.srcObject=this.remoteStream,R.play().catch(C=>{var O;(O=this.config.logger)==null||O.error("Error playing remote audio:",C)})},this.pc.onicecandidate=m=>{var R;m.candidate&&((R=this.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:m.candidate}}))},this.pc.ondatachannel=m=>{const R=m.channel;R.onmessage=C=>{this.messageCallbacks.forEach(O=>{O(C)})},R.onopen=()=>{var C;for(;this.queuedMessages.length>0;){const O=this.queuedMessages.shift();O&&(R.send(JSON.stringify(O)),(C=this.config.logger)==null||C.info("Sent queued message:",O))}}};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 O,K;const m=await this.pc.createOffer();await this.pc.setLocalDescription(m);const R={apiKey:this.config.apiKey,agentId:this.config.agentId,sessionCode:p};(O=this.config.logger)==null||O.debug("Opening connection to WebRTC server: ",R);const C={type:"OFFER",src:((K=crypto.randomUUID)==null?void 0:K.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:m.sdp,type:m.type},connectionId:(Date.now()%1e6).toString(),metadata:R}};this.ws.send(JSON.stringify(C))},this.ws.onmessage=async m=>{var C;const R=JSON.parse(m.data);if(R.type==="ANSWER")await this.pc.setRemoteDescription(new RTCSessionDescription(R.payload.sdp));else if(R.type==="CANDIDATE")try{await this.pc.addIceCandidate(new RTCIceCandidate(R.payload.candidate))}catch(O){(C=this.config.logger)==null||C.error("Error adding ICE candidate:",O)}},this.ws.onclose=m=>{m.code!==1e3&&this.errorCallbacks.forEach(R=>{R("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var p;this.isConnected&&(this.isConnected=!1,((p=this.ws)==null?void 0:p.readyState)===WebSocket.OPEN&&this.ws.close(),this.pc&&this.pc.close(),this.localStream&&this.localStream.getTracks().forEach(i=>i.stop()),this.remoteStream=new MediaStream,this.audioCtx&&(await this.audioCtx.close(),this.audioCtx=null),this._stopAnalyzers())}addVisualizerCallback(p){this.visualizerCallbacks.push(p)}addMessageCallback(p){this.messageCallbacks.push(p)}addErrorCallback(p){this.errorCallbacks.push(p)}createDataChannel(p="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(p),this.dataChannel.onopen=()=>{var i,w;for((i=this.config.logger)==null||i.info("Data channel opened");this.queuedMessages.length>0;){const m=this.queuedMessages.shift();m&&(this.dataChannel.send(JSON.stringify(m)),(w=this.config.logger)==null||w.info("Sent queued message:",m))}},this.dataChannel.onmessage=i=>{this.messageCallbacks.forEach(w=>{w(i)})})}sendPacket(p){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(p);return}this.dataChannel.send(JSON.stringify(p)),(i=this.config.logger)==null||i.info("Sent message:",p)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const p=this.audioCtx.createMediaStreamSource(this.localStream),i=this.audioCtx.createMediaStreamSource(this.remoteStream);this.localAnalyser=this.audioCtx.createAnalyser(),this.remoteAnalyser=this.audioCtx.createAnalyser(),this.localAnalyser.fftSize=256,this.remoteAnalyser.fftSize=256,p.connect(this.localAnalyser),i.connect(this.remoteAnalyser);const w=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const m=new Uint8Array(this.localAnalyser.frequencyBinCount),R=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(m),this.remoteAnalyser.getByteFrequencyData(R);const C=m.reduce((K,rn)=>K+rn,0)/m.length,O=R.reduce((K,rn)=>K+rn,0)/R.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(K=>{K({localAmplitude:C,remoteAmplitude:O})}),this.analyzerFrame=requestAnimationFrame(w)};this.analyzerFrame=requestAnimationFrame(w)}_stopAnalyzers(){this.analyzerFrame&&(cancelAnimationFrame(this.analyzerFrame),this.analyzerFrame=null),this.localAnalyser=null,this.remoteAnalyser=null}}class Ar extends jt{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 Io(i),this.webRTCClient.addMessageCallback(w=>{const m=JSON.parse(w.data);this.notifyPacket(m)}),this.webRTCClient.addErrorCallback(w=>{var m;(m=this.config.logger)==null||m.error("WebRTC error:",w),this.notifyPacket({type:"message",payload:{type:"text",role:"assistant",text:w}})})}getName(){return"webrtc"}getPriority(){return 1e3}async syncSession(i){super.syncSession(i),this.status==="connected"&&(await this.disconnect(),await this.connect(i))}async connect(i){var w;return this.status==="connected"?Promise.resolve(this.session):(this.session=i||this.session||"new",this.setStatus("connecting"),(w=this.config.logger)==null||w.debug("Connecting to WebRTC with sessionId:",this.session),await this.webRTCClient.connect(this.session),this.setStatus("connected"),await this.webRTCClient.createDataChannel(),this.session)}async disconnect(){var i,w,m;if(this.status==="disconnected")return(i=this.config.logger)==null||i.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(m=(w=this.config)==null?void 0:w.logger)==null||m.debug("Disconnected from WebRTC")}sendPacket(i){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(i),Promise.resolve())}}var ne=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Lo(y){return y&&y.__esModule&&Object.prototype.hasOwnProperty.call(y,"default")?y.default:y}var be={exports:{}};/**
14
2
  * @license
15
3
  * Lodash <https://lodash.com/>
16
4
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
17
5
  * Released under MIT license <https://lodash.com/license>
18
6
  * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
19
7
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
20
- */ir.exports,function(n,i){(function(){var r,a="4.17.21",h=200,f="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",p="Expected a function",m="Invalid `variable` option passed into `_.template`",w="__lodash_hash_undefined__",I=500,P="__lodash_placeholder__",C=1,A=2,R=4,K=1,At=2,gt=1,ct=2,ar=4,Qt=8,We=16,jt=32,$e=64,q=128,ht=256,Q=512,Ft=30,ft="...",Ut=800,it=16,St=1,Bl=2,kl=3,qe=1/0,Te=9007199254740991,Dl=17976931348623157e292,ur=NaN,ce=4294967295,Nl=ce-1,Fl=ce>>>1,Ul=[["ary",q],["bind",gt],["bindKey",ct],["curry",Qt],["curryRight",We],["flip",Q],["partial",jt],["partialRight",$e],["rearg",ht]],sn="[object Arguments]",cr="[object Array]",Wl="[object AsyncFunction]",Rn="[object Boolean]",Mn="[object Date]",$l="[object DOMException]",hr="[object Error]",lr="[object Function]",Do="[object GeneratorFunction]",te="[object Map]",Pn="[object Number]",ql="[object Null]",de="[object Object]",No="[object Promise]",zl="[object Proxy]",On="[object RegExp]",ee="[object Set]",Ln="[object String]",fr="[object Symbol]",Hl="[object Undefined]",Bn="[object WeakMap]",Jl="[object WeakSet]",kn="[object ArrayBuffer]",on="[object DataView]",vs="[object Float32Array]",ws="[object Float64Array]",ys="[object Int8Array]",Ss="[object Int16Array]",Es="[object Int32Array]",xs="[object Uint8Array]",Ts="[object Uint8ClampedArray]",As="[object Uint16Array]",Cs="[object Uint32Array]",Gl=/\b__p \+= '';/g,Kl=/\b(__p \+=) '' \+/g,Yl=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Fo=/&(?:amp|lt|gt|quot|#39);/g,Uo=/[&<>"']/g,Vl=RegExp(Fo.source),Zl=RegExp(Uo.source),Xl=/<%-([\s\S]+?)%>/g,Ql=/<%([\s\S]+?)%>/g,Wo=/<%=([\s\S]+?)%>/g,jl=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,tf=/^\w*$/,ef=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Is=/[\\^$.*+?()[\]{}|]/g,nf=RegExp(Is.source),Rs=/^\s+/,rf=/\s/,sf=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,of=/\{\n\/\* \[wrapped with (.+)\] \*/,af=/,? & /,uf=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,cf=/[()=,{}\[\]\/\s]/,hf=/\\(\\)?/g,lf=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,$o=/\w*$/,ff=/^[-+]0x[0-9a-f]+$/i,df=/^0b[01]+$/i,pf=/^\[object .+?Constructor\]$/,gf=/^0o[0-7]+$/i,_f=/^(?:0|[1-9]\d*)$/,bf=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,dr=/($^)/,mf=/['\n\r\u2028\u2029\\]/g,pr="\\ud800-\\udfff",vf="\\u0300-\\u036f",wf="\\ufe20-\\ufe2f",yf="\\u20d0-\\u20ff",qo=vf+wf+yf,zo="\\u2700-\\u27bf",Ho="a-z\\xdf-\\xf6\\xf8-\\xff",Sf="\\xac\\xb1\\xd7\\xf7",Ef="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",xf="\\u2000-\\u206f",Tf=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Jo="A-Z\\xc0-\\xd6\\xd8-\\xde",Go="\\ufe0e\\ufe0f",Ko=Sf+Ef+xf+Tf,Ms="['’]",Af="["+pr+"]",Yo="["+Ko+"]",gr="["+qo+"]",Vo="\\d+",Cf="["+zo+"]",Zo="["+Ho+"]",Xo="[^"+pr+Ko+Vo+zo+Ho+Jo+"]",Ps="\\ud83c[\\udffb-\\udfff]",If="(?:"+gr+"|"+Ps+")",Qo="[^"+pr+"]",Os="(?:\\ud83c[\\udde6-\\uddff]){2}",Ls="[\\ud800-\\udbff][\\udc00-\\udfff]",an="["+Jo+"]",jo="\\u200d",ta="(?:"+Zo+"|"+Xo+")",Rf="(?:"+an+"|"+Xo+")",ea="(?:"+Ms+"(?:d|ll|m|re|s|t|ve))?",na="(?:"+Ms+"(?:D|LL|M|RE|S|T|VE))?",ra=If+"?",sa="["+Go+"]?",Mf="(?:"+jo+"(?:"+[Qo,Os,Ls].join("|")+")"+sa+ra+")*",Pf="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Of="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",ia=sa+ra+Mf,Lf="(?:"+[Cf,Os,Ls].join("|")+")"+ia,Bf="(?:"+[Qo+gr+"?",gr,Os,Ls,Af].join("|")+")",kf=RegExp(Ms,"g"),Df=RegExp(gr,"g"),Bs=RegExp(Ps+"(?="+Ps+")|"+Bf+ia,"g"),Nf=RegExp([an+"?"+Zo+"+"+ea+"(?="+[Yo,an,"$"].join("|")+")",Rf+"+"+na+"(?="+[Yo,an+ta,"$"].join("|")+")",an+"?"+ta+"+"+ea,an+"+"+na,Of,Pf,Vo,Lf].join("|"),"g"),Ff=RegExp("["+jo+pr+qo+Go+"]"),Uf=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Wf=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],$f=-1,et={};et[vs]=et[ws]=et[ys]=et[Ss]=et[Es]=et[xs]=et[Ts]=et[As]=et[Cs]=!0,et[sn]=et[cr]=et[kn]=et[Rn]=et[on]=et[Mn]=et[hr]=et[lr]=et[te]=et[Pn]=et[de]=et[On]=et[ee]=et[Ln]=et[Bn]=!1;var tt={};tt[sn]=tt[cr]=tt[kn]=tt[on]=tt[Rn]=tt[Mn]=tt[vs]=tt[ws]=tt[ys]=tt[Ss]=tt[Es]=tt[te]=tt[Pn]=tt[de]=tt[On]=tt[ee]=tt[Ln]=tt[fr]=tt[xs]=tt[Ts]=tt[As]=tt[Cs]=!0,tt[hr]=tt[lr]=tt[Bn]=!1;var qf={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},zf={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Hf={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},Jf={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Gf=parseFloat,Kf=parseInt,oa=typeof oe=="object"&&oe&&oe.Object===Object&&oe,Yf=typeof self=="object"&&self&&self.Object===Object&&self,bt=oa||Yf||Function("return this")(),ks=i&&!i.nodeType&&i,ze=ks&&!0&&n&&!n.nodeType&&n,aa=ze&&ze.exports===ks,Ds=aa&&oa.process,Wt=function(){try{var _=ze&&ze.require&&ze.require("util").types;return _||Ds&&Ds.binding&&Ds.binding("util")}catch{}}(),ua=Wt&&Wt.isArrayBuffer,ca=Wt&&Wt.isDate,ha=Wt&&Wt.isMap,la=Wt&&Wt.isRegExp,fa=Wt&&Wt.isSet,da=Wt&&Wt.isTypedArray;function Ot(_,y,v){switch(v.length){case 0:return _.call(y);case 1:return _.call(y,v[0]);case 2:return _.call(y,v[0],v[1]);case 3:return _.call(y,v[0],v[1],v[2])}return _.apply(y,v)}function Vf(_,y,v,O){for(var F=-1,V=_==null?0:_.length;++F<V;){var dt=_[F];y(O,dt,v(dt),_)}return O}function $t(_,y){for(var v=-1,O=_==null?0:_.length;++v<O&&y(_[v],v,_)!==!1;);return _}function Zf(_,y){for(var v=_==null?0:_.length;v--&&y(_[v],v,_)!==!1;);return _}function pa(_,y){for(var v=-1,O=_==null?0:_.length;++v<O;)if(!y(_[v],v,_))return!1;return!0}function Ae(_,y){for(var v=-1,O=_==null?0:_.length,F=0,V=[];++v<O;){var dt=_[v];y(dt,v,_)&&(V[F++]=dt)}return V}function _r(_,y){var v=_==null?0:_.length;return!!v&&un(_,y,0)>-1}function Ns(_,y,v){for(var O=-1,F=_==null?0:_.length;++O<F;)if(v(y,_[O]))return!0;return!1}function nt(_,y){for(var v=-1,O=_==null?0:_.length,F=Array(O);++v<O;)F[v]=y(_[v],v,_);return F}function Ce(_,y){for(var v=-1,O=y.length,F=_.length;++v<O;)_[F+v]=y[v];return _}function Fs(_,y,v,O){var F=-1,V=_==null?0:_.length;for(O&&V&&(v=_[++F]);++F<V;)v=y(v,_[F],F,_);return v}function Xf(_,y,v,O){var F=_==null?0:_.length;for(O&&F&&(v=_[--F]);F--;)v=y(v,_[F],F,_);return v}function Us(_,y){for(var v=-1,O=_==null?0:_.length;++v<O;)if(y(_[v],v,_))return!0;return!1}var Qf=Ws("length");function jf(_){return _.split("")}function td(_){return _.match(uf)||[]}function ga(_,y,v){var O;return v(_,function(F,V,dt){if(y(F,V,dt))return O=V,!1}),O}function br(_,y,v,O){for(var F=_.length,V=v+(O?1:-1);O?V--:++V<F;)if(y(_[V],V,_))return V;return-1}function un(_,y,v){return y===y?fd(_,y,v):br(_,_a,v)}function ed(_,y,v,O){for(var F=v-1,V=_.length;++F<V;)if(O(_[F],y))return F;return-1}function _a(_){return _!==_}function ba(_,y){var v=_==null?0:_.length;return v?qs(_,y)/v:ur}function Ws(_){return function(y){return y==null?r:y[_]}}function $s(_){return function(y){return _==null?r:_[y]}}function ma(_,y,v,O,F){return F(_,function(V,dt,j){v=O?(O=!1,V):y(v,V,dt,j)}),v}function nd(_,y){var v=_.length;for(_.sort(y);v--;)_[v]=_[v].value;return _}function qs(_,y){for(var v,O=-1,F=_.length;++O<F;){var V=y(_[O]);V!==r&&(v=v===r?V:v+V)}return v}function zs(_,y){for(var v=-1,O=Array(_);++v<_;)O[v]=y(v);return O}function rd(_,y){return nt(y,function(v){return[v,_[v]]})}function va(_){return _&&_.slice(0,Ea(_)+1).replace(Rs,"")}function Lt(_){return function(y){return _(y)}}function Hs(_,y){return nt(y,function(v){return _[v]})}function Dn(_,y){return _.has(y)}function wa(_,y){for(var v=-1,O=_.length;++v<O&&un(y,_[v],0)>-1;);return v}function ya(_,y){for(var v=_.length;v--&&un(y,_[v],0)>-1;);return v}function sd(_,y){for(var v=_.length,O=0;v--;)_[v]===y&&++O;return O}var id=$s(qf),od=$s(zf);function ad(_){return"\\"+Jf[_]}function ud(_,y){return _==null?r:_[y]}function cn(_){return Ff.test(_)}function cd(_){return Uf.test(_)}function hd(_){for(var y,v=[];!(y=_.next()).done;)v.push(y.value);return v}function Js(_){var y=-1,v=Array(_.size);return _.forEach(function(O,F){v[++y]=[F,O]}),v}function Sa(_,y){return function(v){return _(y(v))}}function Ie(_,y){for(var v=-1,O=_.length,F=0,V=[];++v<O;){var dt=_[v];(dt===y||dt===P)&&(_[v]=P,V[F++]=v)}return V}function mr(_){var y=-1,v=Array(_.size);return _.forEach(function(O){v[++y]=O}),v}function ld(_){var y=-1,v=Array(_.size);return _.forEach(function(O){v[++y]=[O,O]}),v}function fd(_,y,v){for(var O=v-1,F=_.length;++O<F;)if(_[O]===y)return O;return-1}function dd(_,y,v){for(var O=v+1;O--;)if(_[O]===y)return O;return O}function hn(_){return cn(_)?gd(_):Qf(_)}function ne(_){return cn(_)?_d(_):jf(_)}function Ea(_){for(var y=_.length;y--&&rf.test(_.charAt(y)););return y}var pd=$s(Hf);function gd(_){for(var y=Bs.lastIndex=0;Bs.test(_);)++y;return y}function _d(_){return _.match(Bs)||[]}function bd(_){return _.match(Nf)||[]}var md=function _(y){y=y==null?bt:ln.defaults(bt.Object(),y,ln.pick(bt,Wf));var v=y.Array,O=y.Date,F=y.Error,V=y.Function,dt=y.Math,j=y.Object,Gs=y.RegExp,vd=y.String,qt=y.TypeError,vr=v.prototype,wd=V.prototype,fn=j.prototype,wr=y["__core-js_shared__"],yr=wd.toString,X=fn.hasOwnProperty,yd=0,xa=function(){var t=/[^.]+$/.exec(wr&&wr.keys&&wr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Sr=fn.toString,Sd=yr.call(j),Ed=bt._,xd=Gs("^"+yr.call(X).replace(Is,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Er=aa?y.Buffer:r,Re=y.Symbol,xr=y.Uint8Array,Ta=Er?Er.allocUnsafe:r,Tr=Sa(j.getPrototypeOf,j),Aa=j.create,Ca=fn.propertyIsEnumerable,Ar=vr.splice,Ia=Re?Re.isConcatSpreadable:r,Nn=Re?Re.iterator:r,He=Re?Re.toStringTag:r,Cr=function(){try{var t=Ve(j,"defineProperty");return t({},"",{}),t}catch{}}(),Td=y.clearTimeout!==bt.clearTimeout&&y.clearTimeout,Ad=O&&O.now!==bt.Date.now&&O.now,Cd=y.setTimeout!==bt.setTimeout&&y.setTimeout,Ir=dt.ceil,Rr=dt.floor,Ks=j.getOwnPropertySymbols,Id=Er?Er.isBuffer:r,Ra=y.isFinite,Rd=vr.join,Md=Sa(j.keys,j),pt=dt.max,vt=dt.min,Pd=O.now,Od=y.parseInt,Ma=dt.random,Ld=vr.reverse,Ys=Ve(y,"DataView"),Fn=Ve(y,"Map"),Vs=Ve(y,"Promise"),dn=Ve(y,"Set"),Un=Ve(y,"WeakMap"),Wn=Ve(j,"create"),Mr=Un&&new Un,pn={},Bd=Ze(Ys),kd=Ze(Fn),Dd=Ze(Vs),Nd=Ze(dn),Fd=Ze(Un),Pr=Re?Re.prototype:r,$n=Pr?Pr.valueOf:r,Pa=Pr?Pr.toString:r;function c(t){if(ot(t)&&!U(t)&&!(t instanceof J)){if(t instanceof zt)return t;if(X.call(t,"__wrapped__"))return Ou(t)}return new zt(t)}var gn=function(){function t(){}return function(e){if(!st(e))return{};if(Aa)return Aa(e);t.prototype=e;var s=new t;return t.prototype=r,s}}();function Or(){}function zt(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=r}c.templateSettings={escape:Xl,evaluate:Ql,interpolate:Wo,variable:"",imports:{_:c}},c.prototype=Or.prototype,c.prototype.constructor=c,zt.prototype=gn(Or.prototype),zt.prototype.constructor=zt;function J(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ce,this.__views__=[]}function Ud(){var t=new J(this.__wrapped__);return t.__actions__=Ct(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=Ct(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=Ct(this.__views__),t}function Wd(){if(this.__filtered__){var t=new J(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function $d(){var t=this.__wrapped__.value(),e=this.__dir__,s=U(t),o=e<0,u=s?t.length:0,l=jp(0,u,this.__views__),d=l.start,g=l.end,b=g-d,E=o?g:d-1,x=this.__iteratees__,T=x.length,M=0,L=vt(b,this.__takeCount__);if(!s||!o&&u==b&&L==b)return eu(t,this.__actions__);var D=[];t:for(;b--&&M<L;){E+=e;for(var $=-1,N=t[E];++$<T;){var H=x[$],G=H.iteratee,Dt=H.type,Tt=G(N);if(Dt==Bl)N=Tt;else if(!Tt){if(Dt==St)continue t;break t}}D[M++]=N}return D}J.prototype=gn(Or.prototype),J.prototype.constructor=J;function Je(t){var e=-1,s=t==null?0:t.length;for(this.clear();++e<s;){var o=t[e];this.set(o[0],o[1])}}function qd(){this.__data__=Wn?Wn(null):{},this.size=0}function zd(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}function Hd(t){var e=this.__data__;if(Wn){var s=e[t];return s===w?r:s}return X.call(e,t)?e[t]:r}function Jd(t){var e=this.__data__;return Wn?e[t]!==r:X.call(e,t)}function Gd(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=Wn&&e===r?w:e,this}Je.prototype.clear=qd,Je.prototype.delete=zd,Je.prototype.get=Hd,Je.prototype.has=Jd,Je.prototype.set=Gd;function pe(t){var e=-1,s=t==null?0:t.length;for(this.clear();++e<s;){var o=t[e];this.set(o[0],o[1])}}function Kd(){this.__data__=[],this.size=0}function Yd(t){var e=this.__data__,s=Lr(e,t);if(s<0)return!1;var o=e.length-1;return s==o?e.pop():Ar.call(e,s,1),--this.size,!0}function Vd(t){var e=this.__data__,s=Lr(e,t);return s<0?r:e[s][1]}function Zd(t){return Lr(this.__data__,t)>-1}function Xd(t,e){var s=this.__data__,o=Lr(s,t);return o<0?(++this.size,s.push([t,e])):s[o][1]=e,this}pe.prototype.clear=Kd,pe.prototype.delete=Yd,pe.prototype.get=Vd,pe.prototype.has=Zd,pe.prototype.set=Xd;function ge(t){var e=-1,s=t==null?0:t.length;for(this.clear();++e<s;){var o=t[e];this.set(o[0],o[1])}}function Qd(){this.size=0,this.__data__={hash:new Je,map:new(Fn||pe),string:new Je}}function jd(t){var e=Jr(this,t).delete(t);return this.size-=e?1:0,e}function tp(t){return Jr(this,t).get(t)}function ep(t){return Jr(this,t).has(t)}function np(t,e){var s=Jr(this,t),o=s.size;return s.set(t,e),this.size+=s.size==o?0:1,this}ge.prototype.clear=Qd,ge.prototype.delete=jd,ge.prototype.get=tp,ge.prototype.has=ep,ge.prototype.set=np;function Ge(t){var e=-1,s=t==null?0:t.length;for(this.__data__=new ge;++e<s;)this.add(t[e])}function rp(t){return this.__data__.set(t,w),this}function sp(t){return this.__data__.has(t)}Ge.prototype.add=Ge.prototype.push=rp,Ge.prototype.has=sp;function re(t){var e=this.__data__=new pe(t);this.size=e.size}function ip(){this.__data__=new pe,this.size=0}function op(t){var e=this.__data__,s=e.delete(t);return this.size=e.size,s}function ap(t){return this.__data__.get(t)}function up(t){return this.__data__.has(t)}function cp(t,e){var s=this.__data__;if(s instanceof pe){var o=s.__data__;if(!Fn||o.length<h-1)return o.push([t,e]),this.size=++s.size,this;s=this.__data__=new ge(o)}return s.set(t,e),this.size=s.size,this}re.prototype.clear=ip,re.prototype.delete=op,re.prototype.get=ap,re.prototype.has=up,re.prototype.set=cp;function Oa(t,e){var s=U(t),o=!s&&Xe(t),u=!s&&!o&&Be(t),l=!s&&!o&&!u&&vn(t),d=s||o||u||l,g=d?zs(t.length,vd):[],b=g.length;for(var E in t)(e||X.call(t,E))&&!(d&&(E=="length"||u&&(E=="offset"||E=="parent")||l&&(E=="buffer"||E=="byteLength"||E=="byteOffset")||ve(E,b)))&&g.push(E);return g}function La(t){var e=t.length;return e?t[oi(0,e-1)]:r}function hp(t,e){return Gr(Ct(t),Ke(e,0,t.length))}function lp(t){return Gr(Ct(t))}function Zs(t,e,s){(s!==r&&!se(t[e],s)||s===r&&!(e in t))&&_e(t,e,s)}function qn(t,e,s){var o=t[e];(!(X.call(t,e)&&se(o,s))||s===r&&!(e in t))&&_e(t,e,s)}function Lr(t,e){for(var s=t.length;s--;)if(se(t[s][0],e))return s;return-1}function fp(t,e,s,o){return Me(t,function(u,l,d){e(o,u,s(u),d)}),o}function Ba(t,e){return t&&le(e,_t(e),t)}function dp(t,e){return t&&le(e,Rt(e),t)}function _e(t,e,s){e=="__proto__"&&Cr?Cr(t,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[e]=s}function Xs(t,e){for(var s=-1,o=e.length,u=v(o),l=t==null;++s<o;)u[s]=l?r:Pi(t,e[s]);return u}function Ke(t,e,s){return t===t&&(s!==r&&(t=t<=s?t:s),e!==r&&(t=t>=e?t:e)),t}function Ht(t,e,s,o,u,l){var d,g=e&C,b=e&A,E=e&R;if(s&&(d=u?s(t,o,u,l):s(t)),d!==r)return d;if(!st(t))return t;var x=U(t);if(x){if(d=eg(t),!g)return Ct(t,d)}else{var T=wt(t),M=T==lr||T==Do;if(Be(t))return su(t,g);if(T==de||T==sn||M&&!u){if(d=b||M?{}:Eu(t),!g)return b?Hp(t,dp(d,t)):zp(t,Ba(d,t))}else{if(!tt[T])return u?t:{};d=ng(t,T,g)}}l||(l=new re);var L=l.get(t);if(L)return L;l.set(t,d),Qu(t)?t.forEach(function(N){d.add(Ht(N,e,s,N,t,l))}):Zu(t)&&t.forEach(function(N,H){d.set(H,Ht(N,e,s,H,t,l))});var D=E?b?bi:_i:b?Rt:_t,$=x?r:D(t);return $t($||t,function(N,H){$&&(H=N,N=t[H]),qn(d,H,Ht(N,e,s,H,t,l))}),d}function pp(t){var e=_t(t);return function(s){return ka(s,t,e)}}function ka(t,e,s){var o=s.length;if(t==null)return!o;for(t=j(t);o--;){var u=s[o],l=e[u],d=t[u];if(d===r&&!(u in t)||!l(d))return!1}return!0}function Da(t,e,s){if(typeof t!="function")throw new qt(p);return Vn(function(){t.apply(r,s)},e)}function zn(t,e,s,o){var u=-1,l=_r,d=!0,g=t.length,b=[],E=e.length;if(!g)return b;s&&(e=nt(e,Lt(s))),o?(l=Ns,d=!1):e.length>=h&&(l=Dn,d=!1,e=new Ge(e));t:for(;++u<g;){var x=t[u],T=s==null?x:s(x);if(x=o||x!==0?x:0,d&&T===T){for(var M=E;M--;)if(e[M]===T)continue t;b.push(x)}else l(e,T,o)||b.push(x)}return b}var Me=cu(he),Na=cu(js,!0);function gp(t,e){var s=!0;return Me(t,function(o,u,l){return s=!!e(o,u,l),s}),s}function Br(t,e,s){for(var o=-1,u=t.length;++o<u;){var l=t[o],d=e(l);if(d!=null&&(g===r?d===d&&!kt(d):s(d,g)))var g=d,b=l}return b}function _p(t,e,s,o){var u=t.length;for(s=W(s),s<0&&(s=-s>u?0:u+s),o=o===r||o>u?u:W(o),o<0&&(o+=u),o=s>o?0:tc(o);s<o;)t[s++]=e;return t}function Fa(t,e){var s=[];return Me(t,function(o,u,l){e(o,u,l)&&s.push(o)}),s}function mt(t,e,s,o,u){var l=-1,d=t.length;for(s||(s=sg),u||(u=[]);++l<d;){var g=t[l];e>0&&s(g)?e>1?mt(g,e-1,s,o,u):Ce(u,g):o||(u[u.length]=g)}return u}var Qs=hu(),Ua=hu(!0);function he(t,e){return t&&Qs(t,e,_t)}function js(t,e){return t&&Ua(t,e,_t)}function kr(t,e){return Ae(e,function(s){return we(t[s])})}function Ye(t,e){e=Oe(e,t);for(var s=0,o=e.length;t!=null&&s<o;)t=t[fe(e[s++])];return s&&s==o?t:r}function Wa(t,e,s){var o=e(t);return U(t)?o:Ce(o,s(t))}function Et(t){return t==null?t===r?Hl:ql:He&&He in j(t)?Qp(t):lg(t)}function ti(t,e){return t>e}function bp(t,e){return t!=null&&X.call(t,e)}function mp(t,e){return t!=null&&e in j(t)}function vp(t,e,s){return t>=vt(e,s)&&t<pt(e,s)}function ei(t,e,s){for(var o=s?Ns:_r,u=t[0].length,l=t.length,d=l,g=v(l),b=1/0,E=[];d--;){var x=t[d];d&&e&&(x=nt(x,Lt(e))),b=vt(x.length,b),g[d]=!s&&(e||u>=120&&x.length>=120)?new Ge(d&&x):r}x=t[0];var T=-1,M=g[0];t:for(;++T<u&&E.length<b;){var L=x[T],D=e?e(L):L;if(L=s||L!==0?L:0,!(M?Dn(M,D):o(E,D,s))){for(d=l;--d;){var $=g[d];if(!($?Dn($,D):o(t[d],D,s)))continue t}M&&M.push(D),E.push(L)}}return E}function wp(t,e,s,o){return he(t,function(u,l,d){e(o,s(u),l,d)}),o}function Hn(t,e,s){e=Oe(e,t),t=Cu(t,e);var o=t==null?t:t[fe(Gt(e))];return o==null?r:Ot(o,t,s)}function $a(t){return ot(t)&&Et(t)==sn}function yp(t){return ot(t)&&Et(t)==kn}function Sp(t){return ot(t)&&Et(t)==Mn}function Jn(t,e,s,o,u){return t===e?!0:t==null||e==null||!ot(t)&&!ot(e)?t!==t&&e!==e:Ep(t,e,s,o,Jn,u)}function Ep(t,e,s,o,u,l){var d=U(t),g=U(e),b=d?cr:wt(t),E=g?cr:wt(e);b=b==sn?de:b,E=E==sn?de:E;var x=b==de,T=E==de,M=b==E;if(M&&Be(t)){if(!Be(e))return!1;d=!0,x=!1}if(M&&!x)return l||(l=new re),d||vn(t)?wu(t,e,s,o,u,l):Zp(t,e,b,s,o,u,l);if(!(s&K)){var L=x&&X.call(t,"__wrapped__"),D=T&&X.call(e,"__wrapped__");if(L||D){var $=L?t.value():t,N=D?e.value():e;return l||(l=new re),u($,N,s,o,l)}}return M?(l||(l=new re),Xp(t,e,s,o,u,l)):!1}function xp(t){return ot(t)&&wt(t)==te}function ni(t,e,s,o){var u=s.length,l=u,d=!o;if(t==null)return!l;for(t=j(t);u--;){var g=s[u];if(d&&g[2]?g[1]!==t[g[0]]:!(g[0]in t))return!1}for(;++u<l;){g=s[u];var b=g[0],E=t[b],x=g[1];if(d&&g[2]){if(E===r&&!(b in t))return!1}else{var T=new re;if(o)var M=o(E,x,b,t,e,T);if(!(M===r?Jn(x,E,K|At,o,T):M))return!1}}return!0}function qa(t){if(!st(t)||og(t))return!1;var e=we(t)?xd:pf;return e.test(Ze(t))}function Tp(t){return ot(t)&&Et(t)==On}function Ap(t){return ot(t)&&wt(t)==ee}function Cp(t){return ot(t)&&Qr(t.length)&&!!et[Et(t)]}function za(t){return typeof t=="function"?t:t==null?Mt:typeof t=="object"?U(t)?Ga(t[0],t[1]):Ja(t):lc(t)}function ri(t){if(!Yn(t))return Md(t);var e=[];for(var s in j(t))X.call(t,s)&&s!="constructor"&&e.push(s);return e}function Ip(t){if(!st(t))return hg(t);var e=Yn(t),s=[];for(var o in t)o=="constructor"&&(e||!X.call(t,o))||s.push(o);return s}function si(t,e){return t<e}function Ha(t,e){var s=-1,o=It(t)?v(t.length):[];return Me(t,function(u,l,d){o[++s]=e(u,l,d)}),o}function Ja(t){var e=vi(t);return e.length==1&&e[0][2]?Tu(e[0][0],e[0][1]):function(s){return s===t||ni(s,t,e)}}function Ga(t,e){return yi(t)&&xu(e)?Tu(fe(t),e):function(s){var o=Pi(s,t);return o===r&&o===e?Oi(s,t):Jn(e,o,K|At)}}function Dr(t,e,s,o,u){t!==e&&Qs(e,function(l,d){if(u||(u=new re),st(l))Rp(t,e,d,s,Dr,o,u);else{var g=o?o(Ei(t,d),l,d+"",t,e,u):r;g===r&&(g=l),Zs(t,d,g)}},Rt)}function Rp(t,e,s,o,u,l,d){var g=Ei(t,s),b=Ei(e,s),E=d.get(b);if(E){Zs(t,s,E);return}var x=l?l(g,b,s+"",t,e,d):r,T=x===r;if(T){var M=U(b),L=!M&&Be(b),D=!M&&!L&&vn(b);x=b,M||L||D?U(g)?x=g:at(g)?x=Ct(g):L?(T=!1,x=su(b,!0)):D?(T=!1,x=iu(b,!0)):x=[]:Zn(b)||Xe(b)?(x=g,Xe(g)?x=ec(g):(!st(g)||we(g))&&(x=Eu(b))):T=!1}T&&(d.set(b,x),u(x,b,o,l,d),d.delete(b)),Zs(t,s,x)}function Ka(t,e){var s=t.length;if(s)return e+=e<0?s:0,ve(e,s)?t[e]:r}function Ya(t,e,s){e.length?e=nt(e,function(l){return U(l)?function(d){return Ye(d,l.length===1?l[0]:l)}:l}):e=[Mt];var o=-1;e=nt(e,Lt(k()));var u=Ha(t,function(l,d,g){var b=nt(e,function(E){return E(l)});return{criteria:b,index:++o,value:l}});return nd(u,function(l,d){return qp(l,d,s)})}function Mp(t,e){return Va(t,e,function(s,o){return Oi(t,o)})}function Va(t,e,s){for(var o=-1,u=e.length,l={};++o<u;){var d=e[o],g=Ye(t,d);s(g,d)&&Gn(l,Oe(d,t),g)}return l}function Pp(t){return function(e){return Ye(e,t)}}function ii(t,e,s,o){var u=o?ed:un,l=-1,d=e.length,g=t;for(t===e&&(e=Ct(e)),s&&(g=nt(t,Lt(s)));++l<d;)for(var b=0,E=e[l],x=s?s(E):E;(b=u(g,x,b,o))>-1;)g!==t&&Ar.call(g,b,1),Ar.call(t,b,1);return t}function Za(t,e){for(var s=t?e.length:0,o=s-1;s--;){var u=e[s];if(s==o||u!==l){var l=u;ve(u)?Ar.call(t,u,1):ci(t,u)}}return t}function oi(t,e){return t+Rr(Ma()*(e-t+1))}function Op(t,e,s,o){for(var u=-1,l=pt(Ir((e-t)/(s||1)),0),d=v(l);l--;)d[o?l:++u]=t,t+=s;return d}function ai(t,e){var s="";if(!t||e<1||e>Te)return s;do e%2&&(s+=t),e=Rr(e/2),e&&(t+=t);while(e);return s}function z(t,e){return xi(Au(t,e,Mt),t+"")}function Lp(t){return La(wn(t))}function Bp(t,e){var s=wn(t);return Gr(s,Ke(e,0,s.length))}function Gn(t,e,s,o){if(!st(t))return t;e=Oe(e,t);for(var u=-1,l=e.length,d=l-1,g=t;g!=null&&++u<l;){var b=fe(e[u]),E=s;if(b==="__proto__"||b==="constructor"||b==="prototype")return t;if(u!=d){var x=g[b];E=o?o(x,b,g):r,E===r&&(E=st(x)?x:ve(e[u+1])?[]:{})}qn(g,b,E),g=g[b]}return t}var Xa=Mr?function(t,e){return Mr.set(t,e),t}:Mt,kp=Cr?function(t,e){return Cr(t,"toString",{configurable:!0,enumerable:!1,value:Bi(e),writable:!0})}:Mt;function Dp(t){return Gr(wn(t))}function Jt(t,e,s){var o=-1,u=t.length;e<0&&(e=-e>u?0:u+e),s=s>u?u:s,s<0&&(s+=u),u=e>s?0:s-e>>>0,e>>>=0;for(var l=v(u);++o<u;)l[o]=t[o+e];return l}function Np(t,e){var s;return Me(t,function(o,u,l){return s=e(o,u,l),!s}),!!s}function Nr(t,e,s){var o=0,u=t==null?o:t.length;if(typeof e=="number"&&e===e&&u<=Fl){for(;o<u;){var l=o+u>>>1,d=t[l];d!==null&&!kt(d)&&(s?d<=e:d<e)?o=l+1:u=l}return u}return ui(t,e,Mt,s)}function ui(t,e,s,o){var u=0,l=t==null?0:t.length;if(l===0)return 0;e=s(e);for(var d=e!==e,g=e===null,b=kt(e),E=e===r;u<l;){var x=Rr((u+l)/2),T=s(t[x]),M=T!==r,L=T===null,D=T===T,$=kt(T);if(d)var N=o||D;else E?N=D&&(o||M):g?N=D&&M&&(o||!L):b?N=D&&M&&!L&&(o||!$):L||$?N=!1:N=o?T<=e:T<e;N?u=x+1:l=x}return vt(l,Nl)}function Qa(t,e){for(var s=-1,o=t.length,u=0,l=[];++s<o;){var d=t[s],g=e?e(d):d;if(!s||!se(g,b)){var b=g;l[u++]=d===0?0:d}}return l}function ja(t){return typeof t=="number"?t:kt(t)?ur:+t}function Bt(t){if(typeof t=="string")return t;if(U(t))return nt(t,Bt)+"";if(kt(t))return Pa?Pa.call(t):"";var e=t+"";return e=="0"&&1/t==-qe?"-0":e}function Pe(t,e,s){var o=-1,u=_r,l=t.length,d=!0,g=[],b=g;if(s)d=!1,u=Ns;else if(l>=h){var E=e?null:Yp(t);if(E)return mr(E);d=!1,u=Dn,b=new Ge}else b=e?[]:g;t:for(;++o<l;){var x=t[o],T=e?e(x):x;if(x=s||x!==0?x:0,d&&T===T){for(var M=b.length;M--;)if(b[M]===T)continue t;e&&b.push(T),g.push(x)}else u(b,T,s)||(b!==g&&b.push(T),g.push(x))}return g}function ci(t,e){return e=Oe(e,t),t=Cu(t,e),t==null||delete t[fe(Gt(e))]}function tu(t,e,s,o){return Gn(t,e,s(Ye(t,e)),o)}function Fr(t,e,s,o){for(var u=t.length,l=o?u:-1;(o?l--:++l<u)&&e(t[l],l,t););return s?Jt(t,o?0:l,o?l+1:u):Jt(t,o?l+1:0,o?u:l)}function eu(t,e){var s=t;return s instanceof J&&(s=s.value()),Fs(e,function(o,u){return u.func.apply(u.thisArg,Ce([o],u.args))},s)}function hi(t,e,s){var o=t.length;if(o<2)return o?Pe(t[0]):[];for(var u=-1,l=v(o);++u<o;)for(var d=t[u],g=-1;++g<o;)g!=u&&(l[u]=zn(l[u]||d,t[g],e,s));return Pe(mt(l,1),e,s)}function nu(t,e,s){for(var o=-1,u=t.length,l=e.length,d={};++o<u;){var g=o<l?e[o]:r;s(d,t[o],g)}return d}function li(t){return at(t)?t:[]}function fi(t){return typeof t=="function"?t:Mt}function Oe(t,e){return U(t)?t:yi(t,e)?[t]:Pu(Z(t))}var Fp=z;function Le(t,e,s){var o=t.length;return s=s===r?o:s,!e&&s>=o?t:Jt(t,e,s)}var ru=Td||function(t){return bt.clearTimeout(t)};function su(t,e){if(e)return t.slice();var s=t.length,o=Ta?Ta(s):new t.constructor(s);return t.copy(o),o}function di(t){var e=new t.constructor(t.byteLength);return new xr(e).set(new xr(t)),e}function Up(t,e){var s=e?di(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}function Wp(t){var e=new t.constructor(t.source,$o.exec(t));return e.lastIndex=t.lastIndex,e}function $p(t){return $n?j($n.call(t)):{}}function iu(t,e){var s=e?di(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}function ou(t,e){if(t!==e){var s=t!==r,o=t===null,u=t===t,l=kt(t),d=e!==r,g=e===null,b=e===e,E=kt(e);if(!g&&!E&&!l&&t>e||l&&d&&b&&!g&&!E||o&&d&&b||!s&&b||!u)return 1;if(!o&&!l&&!E&&t<e||E&&s&&u&&!o&&!l||g&&s&&u||!d&&u||!b)return-1}return 0}function qp(t,e,s){for(var o=-1,u=t.criteria,l=e.criteria,d=u.length,g=s.length;++o<d;){var b=ou(u[o],l[o]);if(b){if(o>=g)return b;var E=s[o];return b*(E=="desc"?-1:1)}}return t.index-e.index}function au(t,e,s,o){for(var u=-1,l=t.length,d=s.length,g=-1,b=e.length,E=pt(l-d,0),x=v(b+E),T=!o;++g<b;)x[g]=e[g];for(;++u<d;)(T||u<l)&&(x[s[u]]=t[u]);for(;E--;)x[g++]=t[u++];return x}function uu(t,e,s,o){for(var u=-1,l=t.length,d=-1,g=s.length,b=-1,E=e.length,x=pt(l-g,0),T=v(x+E),M=!o;++u<x;)T[u]=t[u];for(var L=u;++b<E;)T[L+b]=e[b];for(;++d<g;)(M||u<l)&&(T[L+s[d]]=t[u++]);return T}function Ct(t,e){var s=-1,o=t.length;for(e||(e=v(o));++s<o;)e[s]=t[s];return e}function le(t,e,s,o){var u=!s;s||(s={});for(var l=-1,d=e.length;++l<d;){var g=e[l],b=o?o(s[g],t[g],g,s,t):r;b===r&&(b=t[g]),u?_e(s,g,b):qn(s,g,b)}return s}function zp(t,e){return le(t,wi(t),e)}function Hp(t,e){return le(t,yu(t),e)}function Ur(t,e){return function(s,o){var u=U(s)?Vf:fp,l=e?e():{};return u(s,t,k(o,2),l)}}function _n(t){return z(function(e,s){var o=-1,u=s.length,l=u>1?s[u-1]:r,d=u>2?s[2]:r;for(l=t.length>3&&typeof l=="function"?(u--,l):r,d&&xt(s[0],s[1],d)&&(l=u<3?r:l,u=1),e=j(e);++o<u;){var g=s[o];g&&t(e,g,o,l)}return e})}function cu(t,e){return function(s,o){if(s==null)return s;if(!It(s))return t(s,o);for(var u=s.length,l=e?u:-1,d=j(s);(e?l--:++l<u)&&o(d[l],l,d)!==!1;);return s}}function hu(t){return function(e,s,o){for(var u=-1,l=j(e),d=o(e),g=d.length;g--;){var b=d[t?g:++u];if(s(l[b],b,l)===!1)break}return e}}function Jp(t,e,s){var o=e&gt,u=Kn(t);function l(){var d=this&&this!==bt&&this instanceof l?u:t;return d.apply(o?s:this,arguments)}return l}function lu(t){return function(e){e=Z(e);var s=cn(e)?ne(e):r,o=s?s[0]:e.charAt(0),u=s?Le(s,1).join(""):e.slice(1);return o[t]()+u}}function bn(t){return function(e){return Fs(cc(uc(e).replace(kf,"")),t,"")}}function Kn(t){return function(){var e=arguments;switch(e.length){case 0:return new t;case 1:return new t(e[0]);case 2:return new t(e[0],e[1]);case 3:return new t(e[0],e[1],e[2]);case 4:return new t(e[0],e[1],e[2],e[3]);case 5:return new t(e[0],e[1],e[2],e[3],e[4]);case 6:return new t(e[0],e[1],e[2],e[3],e[4],e[5]);case 7:return new t(e[0],e[1],e[2],e[3],e[4],e[5],e[6])}var s=gn(t.prototype),o=t.apply(s,e);return st(o)?o:s}}function Gp(t,e,s){var o=Kn(t);function u(){for(var l=arguments.length,d=v(l),g=l,b=mn(u);g--;)d[g]=arguments[g];var E=l<3&&d[0]!==b&&d[l-1]!==b?[]:Ie(d,b);if(l-=E.length,l<s)return _u(t,e,Wr,u.placeholder,r,d,E,r,r,s-l);var x=this&&this!==bt&&this instanceof u?o:t;return Ot(x,this,d)}return u}function fu(t){return function(e,s,o){var u=j(e);if(!It(e)){var l=k(s,3);e=_t(e),s=function(g){return l(u[g],g,u)}}var d=t(e,s,o);return d>-1?u[l?e[d]:d]:r}}function du(t){return me(function(e){var s=e.length,o=s,u=zt.prototype.thru;for(t&&e.reverse();o--;){var l=e[o];if(typeof l!="function")throw new qt(p);if(u&&!d&&Hr(l)=="wrapper")var d=new zt([],!0)}for(o=d?o:s;++o<s;){l=e[o];var g=Hr(l),b=g=="wrapper"?mi(l):r;b&&Si(b[0])&&b[1]==(q|Qt|jt|ht)&&!b[4].length&&b[9]==1?d=d[Hr(b[0])].apply(d,b[3]):d=l.length==1&&Si(l)?d[g]():d.thru(l)}return function(){var E=arguments,x=E[0];if(d&&E.length==1&&U(x))return d.plant(x).value();for(var T=0,M=s?e[T].apply(this,E):x;++T<s;)M=e[T].call(this,M);return M}})}function Wr(t,e,s,o,u,l,d,g,b,E){var x=e&q,T=e&gt,M=e&ct,L=e&(Qt|We),D=e&Q,$=M?r:Kn(t);function N(){for(var H=arguments.length,G=v(H),Dt=H;Dt--;)G[Dt]=arguments[Dt];if(L)var Tt=mn(N),Nt=sd(G,Tt);if(o&&(G=au(G,o,u,L)),l&&(G=uu(G,l,d,L)),H-=Nt,L&&H<E){var ut=Ie(G,Tt);return _u(t,e,Wr,N.placeholder,s,G,ut,g,b,E-H)}var ie=T?s:this,Se=M?ie[t]:t;return H=G.length,g?G=fg(G,g):D&&H>1&&G.reverse(),x&&b<H&&(G.length=b),this&&this!==bt&&this instanceof N&&(Se=$||Kn(Se)),Se.apply(ie,G)}return N}function pu(t,e){return function(s,o){return wp(s,t,e(o),{})}}function $r(t,e){return function(s,o){var u;if(s===r&&o===r)return e;if(s!==r&&(u=s),o!==r){if(u===r)return o;typeof s=="string"||typeof o=="string"?(s=Bt(s),o=Bt(o)):(s=ja(s),o=ja(o)),u=t(s,o)}return u}}function pi(t){return me(function(e){return e=nt(e,Lt(k())),z(function(s){var o=this;return t(e,function(u){return Ot(u,o,s)})})})}function qr(t,e){e=e===r?" ":Bt(e);var s=e.length;if(s<2)return s?ai(e,t):e;var o=ai(e,Ir(t/hn(e)));return cn(e)?Le(ne(o),0,t).join(""):o.slice(0,t)}function Kp(t,e,s,o){var u=e&gt,l=Kn(t);function d(){for(var g=-1,b=arguments.length,E=-1,x=o.length,T=v(x+b),M=this&&this!==bt&&this instanceof d?l:t;++E<x;)T[E]=o[E];for(;b--;)T[E++]=arguments[++g];return Ot(M,u?s:this,T)}return d}function gu(t){return function(e,s,o){return o&&typeof o!="number"&&xt(e,s,o)&&(s=o=r),e=ye(e),s===r?(s=e,e=0):s=ye(s),o=o===r?e<s?1:-1:ye(o),Op(e,s,o,t)}}function zr(t){return function(e,s){return typeof e=="string"&&typeof s=="string"||(e=Kt(e),s=Kt(s)),t(e,s)}}function _u(t,e,s,o,u,l,d,g,b,E){var x=e&Qt,T=x?d:r,M=x?r:d,L=x?l:r,D=x?r:l;e|=x?jt:$e,e&=~(x?$e:jt),e&ar||(e&=-4);var $=[t,e,u,L,T,D,M,g,b,E],N=s.apply(r,$);return Si(t)&&Iu(N,$),N.placeholder=o,Ru(N,t,e)}function gi(t){var e=dt[t];return function(s,o){if(s=Kt(s),o=o==null?0:vt(W(o),292),o&&Ra(s)){var u=(Z(s)+"e").split("e"),l=e(u[0]+"e"+(+u[1]+o));return u=(Z(l)+"e").split("e"),+(u[0]+"e"+(+u[1]-o))}return e(s)}}var Yp=dn&&1/mr(new dn([,-0]))[1]==qe?function(t){return new dn(t)}:Ni;function bu(t){return function(e){var s=wt(e);return s==te?Js(e):s==ee?ld(e):rd(e,t(e))}}function be(t,e,s,o,u,l,d,g){var b=e&ct;if(!b&&typeof t!="function")throw new qt(p);var E=o?o.length:0;if(E||(e&=-97,o=u=r),d=d===r?d:pt(W(d),0),g=g===r?g:W(g),E-=u?u.length:0,e&$e){var x=o,T=u;o=u=r}var M=b?r:mi(t),L=[t,e,s,o,u,x,T,l,d,g];if(M&&cg(L,M),t=L[0],e=L[1],s=L[2],o=L[3],u=L[4],g=L[9]=L[9]===r?b?0:t.length:pt(L[9]-E,0),!g&&e&(Qt|We)&&(e&=-25),!e||e==gt)var D=Jp(t,e,s);else e==Qt||e==We?D=Gp(t,e,g):(e==jt||e==(gt|jt))&&!u.length?D=Kp(t,e,s,o):D=Wr.apply(r,L);var $=M?Xa:Iu;return Ru($(D,L),t,e)}function mu(t,e,s,o){return t===r||se(t,fn[s])&&!X.call(o,s)?e:t}function vu(t,e,s,o,u,l){return st(t)&&st(e)&&(l.set(e,t),Dr(t,e,r,vu,l),l.delete(e)),t}function Vp(t){return Zn(t)?r:t}function wu(t,e,s,o,u,l){var d=s&K,g=t.length,b=e.length;if(g!=b&&!(d&&b>g))return!1;var E=l.get(t),x=l.get(e);if(E&&x)return E==e&&x==t;var T=-1,M=!0,L=s&At?new Ge:r;for(l.set(t,e),l.set(e,t);++T<g;){var D=t[T],$=e[T];if(o)var N=d?o($,D,T,e,t,l):o(D,$,T,t,e,l);if(N!==r){if(N)continue;M=!1;break}if(L){if(!Us(e,function(H,G){if(!Dn(L,G)&&(D===H||u(D,H,s,o,l)))return L.push(G)})){M=!1;break}}else if(!(D===$||u(D,$,s,o,l))){M=!1;break}}return l.delete(t),l.delete(e),M}function Zp(t,e,s,o,u,l,d){switch(s){case on:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case kn:return!(t.byteLength!=e.byteLength||!l(new xr(t),new xr(e)));case Rn:case Mn:case Pn:return se(+t,+e);case hr:return t.name==e.name&&t.message==e.message;case On:case Ln:return t==e+"";case te:var g=Js;case ee:var b=o&K;if(g||(g=mr),t.size!=e.size&&!b)return!1;var E=d.get(t);if(E)return E==e;o|=At,d.set(t,e);var x=wu(g(t),g(e),o,u,l,d);return d.delete(t),x;case fr:if($n)return $n.call(t)==$n.call(e)}return!1}function Xp(t,e,s,o,u,l){var d=s&K,g=_i(t),b=g.length,E=_i(e),x=E.length;if(b!=x&&!d)return!1;for(var T=b;T--;){var M=g[T];if(!(d?M in e:X.call(e,M)))return!1}var L=l.get(t),D=l.get(e);if(L&&D)return L==e&&D==t;var $=!0;l.set(t,e),l.set(e,t);for(var N=d;++T<b;){M=g[T];var H=t[M],G=e[M];if(o)var Dt=d?o(G,H,M,e,t,l):o(H,G,M,t,e,l);if(!(Dt===r?H===G||u(H,G,s,o,l):Dt)){$=!1;break}N||(N=M=="constructor")}if($&&!N){var Tt=t.constructor,Nt=e.constructor;Tt!=Nt&&"constructor"in t&&"constructor"in e&&!(typeof Tt=="function"&&Tt instanceof Tt&&typeof Nt=="function"&&Nt instanceof Nt)&&($=!1)}return l.delete(t),l.delete(e),$}function me(t){return xi(Au(t,r,ku),t+"")}function _i(t){return Wa(t,_t,wi)}function bi(t){return Wa(t,Rt,yu)}var mi=Mr?function(t){return Mr.get(t)}:Ni;function Hr(t){for(var e=t.name+"",s=pn[e],o=X.call(pn,e)?s.length:0;o--;){var u=s[o],l=u.func;if(l==null||l==t)return u.name}return e}function mn(t){var e=X.call(c,"placeholder")?c:t;return e.placeholder}function k(){var t=c.iteratee||ki;return t=t===ki?za:t,arguments.length?t(arguments[0],arguments[1]):t}function Jr(t,e){var s=t.__data__;return ig(e)?s[typeof e=="string"?"string":"hash"]:s.map}function vi(t){for(var e=_t(t),s=e.length;s--;){var o=e[s],u=t[o];e[s]=[o,u,xu(u)]}return e}function Ve(t,e){var s=ud(t,e);return qa(s)?s:r}function Qp(t){var e=X.call(t,He),s=t[He];try{t[He]=r;var o=!0}catch{}var u=Sr.call(t);return o&&(e?t[He]=s:delete t[He]),u}var wi=Ks?function(t){return t==null?[]:(t=j(t),Ae(Ks(t),function(e){return Ca.call(t,e)}))}:Fi,yu=Ks?function(t){for(var e=[];t;)Ce(e,wi(t)),t=Tr(t);return e}:Fi,wt=Et;(Ys&&wt(new Ys(new ArrayBuffer(1)))!=on||Fn&&wt(new Fn)!=te||Vs&&wt(Vs.resolve())!=No||dn&&wt(new dn)!=ee||Un&&wt(new Un)!=Bn)&&(wt=function(t){var e=Et(t),s=e==de?t.constructor:r,o=s?Ze(s):"";if(o)switch(o){case Bd:return on;case kd:return te;case Dd:return No;case Nd:return ee;case Fd:return Bn}return e});function jp(t,e,s){for(var o=-1,u=s.length;++o<u;){var l=s[o],d=l.size;switch(l.type){case"drop":t+=d;break;case"dropRight":e-=d;break;case"take":e=vt(e,t+d);break;case"takeRight":t=pt(t,e-d);break}}return{start:t,end:e}}function tg(t){var e=t.match(of);return e?e[1].split(af):[]}function Su(t,e,s){e=Oe(e,t);for(var o=-1,u=e.length,l=!1;++o<u;){var d=fe(e[o]);if(!(l=t!=null&&s(t,d)))break;t=t[d]}return l||++o!=u?l:(u=t==null?0:t.length,!!u&&Qr(u)&&ve(d,u)&&(U(t)||Xe(t)))}function eg(t){var e=t.length,s=new t.constructor(e);return e&&typeof t[0]=="string"&&X.call(t,"index")&&(s.index=t.index,s.input=t.input),s}function Eu(t){return typeof t.constructor=="function"&&!Yn(t)?gn(Tr(t)):{}}function ng(t,e,s){var o=t.constructor;switch(e){case kn:return di(t);case Rn:case Mn:return new o(+t);case on:return Up(t,s);case vs:case ws:case ys:case Ss:case Es:case xs:case Ts:case As:case Cs:return iu(t,s);case te:return new o;case Pn:case Ln:return new o(t);case On:return Wp(t);case ee:return new o;case fr:return $p(t)}}function rg(t,e){var s=e.length;if(!s)return t;var o=s-1;return e[o]=(s>1?"& ":"")+e[o],e=e.join(s>2?", ":" "),t.replace(sf,`{
21
- /* [wrapped with `+e+`] */
22
- `)}function sg(t){return U(t)||Xe(t)||!!(Ia&&t&&t[Ia])}function ve(t,e){var s=typeof t;return e=e??Te,!!e&&(s=="number"||s!="symbol"&&_f.test(t))&&t>-1&&t%1==0&&t<e}function xt(t,e,s){if(!st(s))return!1;var o=typeof e;return(o=="number"?It(s)&&ve(e,s.length):o=="string"&&e in s)?se(s[e],t):!1}function yi(t,e){if(U(t))return!1;var s=typeof t;return s=="number"||s=="symbol"||s=="boolean"||t==null||kt(t)?!0:tf.test(t)||!jl.test(t)||e!=null&&t in j(e)}function ig(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Si(t){var e=Hr(t),s=c[e];if(typeof s!="function"||!(e in J.prototype))return!1;if(t===s)return!0;var o=mi(s);return!!o&&t===o[0]}function og(t){return!!xa&&xa in t}var ag=wr?we:Ui;function Yn(t){var e=t&&t.constructor,s=typeof e=="function"&&e.prototype||fn;return t===s}function xu(t){return t===t&&!st(t)}function Tu(t,e){return function(s){return s==null?!1:s[t]===e&&(e!==r||t in j(s))}}function ug(t){var e=Zr(t,function(o){return s.size===I&&s.clear(),o}),s=e.cache;return e}function cg(t,e){var s=t[1],o=e[1],u=s|o,l=u<(gt|ct|q),d=o==q&&s==Qt||o==q&&s==ht&&t[7].length<=e[8]||o==(q|ht)&&e[7].length<=e[8]&&s==Qt;if(!(l||d))return t;o&gt&&(t[2]=e[2],u|=s&gt?0:ar);var g=e[3];if(g){var b=t[3];t[3]=b?au(b,g,e[4]):g,t[4]=b?Ie(t[3],P):e[4]}return g=e[5],g&&(b=t[5],t[5]=b?uu(b,g,e[6]):g,t[6]=b?Ie(t[5],P):e[6]),g=e[7],g&&(t[7]=g),o&q&&(t[8]=t[8]==null?e[8]:vt(t[8],e[8])),t[9]==null&&(t[9]=e[9]),t[0]=e[0],t[1]=u,t}function hg(t){var e=[];if(t!=null)for(var s in j(t))e.push(s);return e}function lg(t){return Sr.call(t)}function Au(t,e,s){return e=pt(e===r?t.length-1:e,0),function(){for(var o=arguments,u=-1,l=pt(o.length-e,0),d=v(l);++u<l;)d[u]=o[e+u];u=-1;for(var g=v(e+1);++u<e;)g[u]=o[u];return g[e]=s(d),Ot(t,this,g)}}function Cu(t,e){return e.length<2?t:Ye(t,Jt(e,0,-1))}function fg(t,e){for(var s=t.length,o=vt(e.length,s),u=Ct(t);o--;){var l=e[o];t[o]=ve(l,s)?u[l]:r}return t}function Ei(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var Iu=Mu(Xa),Vn=Cd||function(t,e){return bt.setTimeout(t,e)},xi=Mu(kp);function Ru(t,e,s){var o=e+"";return xi(t,rg(o,dg(tg(o),s)))}function Mu(t){var e=0,s=0;return function(){var o=Pd(),u=it-(o-s);if(s=o,u>0){if(++e>=Ut)return arguments[0]}else e=0;return t.apply(r,arguments)}}function Gr(t,e){var s=-1,o=t.length,u=o-1;for(e=e===r?o:e;++s<e;){var l=oi(s,u),d=t[l];t[l]=t[s],t[s]=d}return t.length=e,t}var Pu=ug(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(ef,function(s,o,u,l){e.push(u?l.replace(hf,"$1"):o||s)}),e});function fe(t){if(typeof t=="string"||kt(t))return t;var e=t+"";return e=="0"&&1/t==-qe?"-0":e}function Ze(t){if(t!=null){try{return yr.call(t)}catch{}try{return t+""}catch{}}return""}function dg(t,e){return $t(Ul,function(s){var o="_."+s[0];e&s[1]&&!_r(t,o)&&t.push(o)}),t.sort()}function Ou(t){if(t instanceof J)return t.clone();var e=new zt(t.__wrapped__,t.__chain__);return e.__actions__=Ct(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}function pg(t,e,s){(s?xt(t,e,s):e===r)?e=1:e=pt(W(e),0);var o=t==null?0:t.length;if(!o||e<1)return[];for(var u=0,l=0,d=v(Ir(o/e));u<o;)d[l++]=Jt(t,u,u+=e);return d}function gg(t){for(var e=-1,s=t==null?0:t.length,o=0,u=[];++e<s;){var l=t[e];l&&(u[o++]=l)}return u}function _g(){var t=arguments.length;if(!t)return[];for(var e=v(t-1),s=arguments[0],o=t;o--;)e[o-1]=arguments[o];return Ce(U(s)?Ct(s):[s],mt(e,1))}var bg=z(function(t,e){return at(t)?zn(t,mt(e,1,at,!0)):[]}),mg=z(function(t,e){var s=Gt(e);return at(s)&&(s=r),at(t)?zn(t,mt(e,1,at,!0),k(s,2)):[]}),vg=z(function(t,e){var s=Gt(e);return at(s)&&(s=r),at(t)?zn(t,mt(e,1,at,!0),r,s):[]});function wg(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),Jt(t,e<0?0:e,o)):[]}function yg(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),e=o-e,Jt(t,0,e<0?0:e)):[]}function Sg(t,e){return t&&t.length?Fr(t,k(e,3),!0,!0):[]}function Eg(t,e){return t&&t.length?Fr(t,k(e,3),!0):[]}function xg(t,e,s,o){var u=t==null?0:t.length;return u?(s&&typeof s!="number"&&xt(t,e,s)&&(s=0,o=u),_p(t,e,s,o)):[]}function Lu(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=s==null?0:W(s);return u<0&&(u=pt(o+u,0)),br(t,k(e,3),u)}function Bu(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=o-1;return s!==r&&(u=W(s),u=s<0?pt(o+u,0):vt(u,o-1)),br(t,k(e,3),u,!0)}function ku(t){var e=t==null?0:t.length;return e?mt(t,1):[]}function Tg(t){var e=t==null?0:t.length;return e?mt(t,qe):[]}function Ag(t,e){var s=t==null?0:t.length;return s?(e=e===r?1:W(e),mt(t,e)):[]}function Cg(t){for(var e=-1,s=t==null?0:t.length,o={};++e<s;){var u=t[e];o[u[0]]=u[1]}return o}function Du(t){return t&&t.length?t[0]:r}function Ig(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=s==null?0:W(s);return u<0&&(u=pt(o+u,0)),un(t,e,u)}function Rg(t){var e=t==null?0:t.length;return e?Jt(t,0,-1):[]}var Mg=z(function(t){var e=nt(t,li);return e.length&&e[0]===t[0]?ei(e):[]}),Pg=z(function(t){var e=Gt(t),s=nt(t,li);return e===Gt(s)?e=r:s.pop(),s.length&&s[0]===t[0]?ei(s,k(e,2)):[]}),Og=z(function(t){var e=Gt(t),s=nt(t,li);return e=typeof e=="function"?e:r,e&&s.pop(),s.length&&s[0]===t[0]?ei(s,r,e):[]});function Lg(t,e){return t==null?"":Rd.call(t,e)}function Gt(t){var e=t==null?0:t.length;return e?t[e-1]:r}function Bg(t,e,s){var o=t==null?0:t.length;if(!o)return-1;var u=o;return s!==r&&(u=W(s),u=u<0?pt(o+u,0):vt(u,o-1)),e===e?dd(t,e,u):br(t,_a,u,!0)}function kg(t,e){return t&&t.length?Ka(t,W(e)):r}var Dg=z(Nu);function Nu(t,e){return t&&t.length&&e&&e.length?ii(t,e):t}function Ng(t,e,s){return t&&t.length&&e&&e.length?ii(t,e,k(s,2)):t}function Fg(t,e,s){return t&&t.length&&e&&e.length?ii(t,e,r,s):t}var Ug=me(function(t,e){var s=t==null?0:t.length,o=Xs(t,e);return Za(t,nt(e,function(u){return ve(u,s)?+u:u}).sort(ou)),o});function Wg(t,e){var s=[];if(!(t&&t.length))return s;var o=-1,u=[],l=t.length;for(e=k(e,3);++o<l;){var d=t[o];e(d,o,t)&&(s.push(d),u.push(o))}return Za(t,u),s}function Ti(t){return t==null?t:Ld.call(t)}function $g(t,e,s){var o=t==null?0:t.length;return o?(s&&typeof s!="number"&&xt(t,e,s)?(e=0,s=o):(e=e==null?0:W(e),s=s===r?o:W(s)),Jt(t,e,s)):[]}function qg(t,e){return Nr(t,e)}function zg(t,e,s){return ui(t,e,k(s,2))}function Hg(t,e){var s=t==null?0:t.length;if(s){var o=Nr(t,e);if(o<s&&se(t[o],e))return o}return-1}function Jg(t,e){return Nr(t,e,!0)}function Gg(t,e,s){return ui(t,e,k(s,2),!0)}function Kg(t,e){var s=t==null?0:t.length;if(s){var o=Nr(t,e,!0)-1;if(se(t[o],e))return o}return-1}function Yg(t){return t&&t.length?Qa(t):[]}function Vg(t,e){return t&&t.length?Qa(t,k(e,2)):[]}function Zg(t){var e=t==null?0:t.length;return e?Jt(t,1,e):[]}function Xg(t,e,s){return t&&t.length?(e=s||e===r?1:W(e),Jt(t,0,e<0?0:e)):[]}function Qg(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),e=o-e,Jt(t,e<0?0:e,o)):[]}function jg(t,e){return t&&t.length?Fr(t,k(e,3),!1,!0):[]}function t_(t,e){return t&&t.length?Fr(t,k(e,3)):[]}var e_=z(function(t){return Pe(mt(t,1,at,!0))}),n_=z(function(t){var e=Gt(t);return at(e)&&(e=r),Pe(mt(t,1,at,!0),k(e,2))}),r_=z(function(t){var e=Gt(t);return e=typeof e=="function"?e:r,Pe(mt(t,1,at,!0),r,e)});function s_(t){return t&&t.length?Pe(t):[]}function i_(t,e){return t&&t.length?Pe(t,k(e,2)):[]}function o_(t,e){return e=typeof e=="function"?e:r,t&&t.length?Pe(t,r,e):[]}function Ai(t){if(!(t&&t.length))return[];var e=0;return t=Ae(t,function(s){if(at(s))return e=pt(s.length,e),!0}),zs(e,function(s){return nt(t,Ws(s))})}function Fu(t,e){if(!(t&&t.length))return[];var s=Ai(t);return e==null?s:nt(s,function(o){return Ot(e,r,o)})}var a_=z(function(t,e){return at(t)?zn(t,e):[]}),u_=z(function(t){return hi(Ae(t,at))}),c_=z(function(t){var e=Gt(t);return at(e)&&(e=r),hi(Ae(t,at),k(e,2))}),h_=z(function(t){var e=Gt(t);return e=typeof e=="function"?e:r,hi(Ae(t,at),r,e)}),l_=z(Ai);function f_(t,e){return nu(t||[],e||[],qn)}function d_(t,e){return nu(t||[],e||[],Gn)}var p_=z(function(t){var e=t.length,s=e>1?t[e-1]:r;return s=typeof s=="function"?(t.pop(),s):r,Fu(t,s)});function Uu(t){var e=c(t);return e.__chain__=!0,e}function g_(t,e){return e(t),t}function Kr(t,e){return e(t)}var __=me(function(t){var e=t.length,s=e?t[0]:0,o=this.__wrapped__,u=function(l){return Xs(l,t)};return e>1||this.__actions__.length||!(o instanceof J)||!ve(s)?this.thru(u):(o=o.slice(s,+s+(e?1:0)),o.__actions__.push({func:Kr,args:[u],thisArg:r}),new zt(o,this.__chain__).thru(function(l){return e&&!l.length&&l.push(r),l}))});function b_(){return Uu(this)}function m_(){return new zt(this.value(),this.__chain__)}function v_(){this.__values__===r&&(this.__values__=ju(this.value()));var t=this.__index__>=this.__values__.length,e=t?r:this.__values__[this.__index__++];return{done:t,value:e}}function w_(){return this}function y_(t){for(var e,s=this;s instanceof Or;){var o=Ou(s);o.__index__=0,o.__values__=r,e?u.__wrapped__=o:e=o;var u=o;s=s.__wrapped__}return u.__wrapped__=t,e}function S_(){var t=this.__wrapped__;if(t instanceof J){var e=t;return this.__actions__.length&&(e=new J(this)),e=e.reverse(),e.__actions__.push({func:Kr,args:[Ti],thisArg:r}),new zt(e,this.__chain__)}return this.thru(Ti)}function E_(){return eu(this.__wrapped__,this.__actions__)}var x_=Ur(function(t,e,s){X.call(t,s)?++t[s]:_e(t,s,1)});function T_(t,e,s){var o=U(t)?pa:gp;return s&&xt(t,e,s)&&(e=r),o(t,k(e,3))}function A_(t,e){var s=U(t)?Ae:Fa;return s(t,k(e,3))}var C_=fu(Lu),I_=fu(Bu);function R_(t,e){return mt(Yr(t,e),1)}function M_(t,e){return mt(Yr(t,e),qe)}function P_(t,e,s){return s=s===r?1:W(s),mt(Yr(t,e),s)}function Wu(t,e){var s=U(t)?$t:Me;return s(t,k(e,3))}function $u(t,e){var s=U(t)?Zf:Na;return s(t,k(e,3))}var O_=Ur(function(t,e,s){X.call(t,s)?t[s].push(e):_e(t,s,[e])});function L_(t,e,s,o){t=It(t)?t:wn(t),s=s&&!o?W(s):0;var u=t.length;return s<0&&(s=pt(u+s,0)),jr(t)?s<=u&&t.indexOf(e,s)>-1:!!u&&un(t,e,s)>-1}var B_=z(function(t,e,s){var o=-1,u=typeof e=="function",l=It(t)?v(t.length):[];return Me(t,function(d){l[++o]=u?Ot(e,d,s):Hn(d,e,s)}),l}),k_=Ur(function(t,e,s){_e(t,s,e)});function Yr(t,e){var s=U(t)?nt:Ha;return s(t,k(e,3))}function D_(t,e,s,o){return t==null?[]:(U(e)||(e=e==null?[]:[e]),s=o?r:s,U(s)||(s=s==null?[]:[s]),Ya(t,e,s))}var N_=Ur(function(t,e,s){t[s?0:1].push(e)},function(){return[[],[]]});function F_(t,e,s){var o=U(t)?Fs:ma,u=arguments.length<3;return o(t,k(e,4),s,u,Me)}function U_(t,e,s){var o=U(t)?Xf:ma,u=arguments.length<3;return o(t,k(e,4),s,u,Na)}function W_(t,e){var s=U(t)?Ae:Fa;return s(t,Xr(k(e,3)))}function $_(t){var e=U(t)?La:Lp;return e(t)}function q_(t,e,s){(s?xt(t,e,s):e===r)?e=1:e=W(e);var o=U(t)?hp:Bp;return o(t,e)}function z_(t){var e=U(t)?lp:Dp;return e(t)}function H_(t){if(t==null)return 0;if(It(t))return jr(t)?hn(t):t.length;var e=wt(t);return e==te||e==ee?t.size:ri(t).length}function J_(t,e,s){var o=U(t)?Us:Np;return s&&xt(t,e,s)&&(e=r),o(t,k(e,3))}var G_=z(function(t,e){if(t==null)return[];var s=e.length;return s>1&&xt(t,e[0],e[1])?e=[]:s>2&&xt(e[0],e[1],e[2])&&(e=[e[0]]),Ya(t,mt(e,1),[])}),Vr=Ad||function(){return bt.Date.now()};function K_(t,e){if(typeof e!="function")throw new qt(p);return t=W(t),function(){if(--t<1)return e.apply(this,arguments)}}function qu(t,e,s){return e=s?r:e,e=t&&e==null?t.length:e,be(t,q,r,r,r,r,e)}function zu(t,e){var s;if(typeof e!="function")throw new qt(p);return t=W(t),function(){return--t>0&&(s=e.apply(this,arguments)),t<=1&&(e=r),s}}var Ci=z(function(t,e,s){var o=gt;if(s.length){var u=Ie(s,mn(Ci));o|=jt}return be(t,o,e,s,u)}),Hu=z(function(t,e,s){var o=gt|ct;if(s.length){var u=Ie(s,mn(Hu));o|=jt}return be(e,o,t,s,u)});function Ju(t,e,s){e=s?r:e;var o=be(t,Qt,r,r,r,r,r,e);return o.placeholder=Ju.placeholder,o}function Gu(t,e,s){e=s?r:e;var o=be(t,We,r,r,r,r,r,e);return o.placeholder=Gu.placeholder,o}function Ku(t,e,s){var o,u,l,d,g,b,E=0,x=!1,T=!1,M=!0;if(typeof t!="function")throw new qt(p);e=Kt(e)||0,st(s)&&(x=!!s.leading,T="maxWait"in s,l=T?pt(Kt(s.maxWait)||0,e):l,M="trailing"in s?!!s.trailing:M);function L(ut){var ie=o,Se=u;return o=u=r,E=ut,d=t.apply(Se,ie),d}function D(ut){return E=ut,g=Vn(H,e),x?L(ut):d}function $(ut){var ie=ut-b,Se=ut-E,fc=e-ie;return T?vt(fc,l-Se):fc}function N(ut){var ie=ut-b,Se=ut-E;return b===r||ie>=e||ie<0||T&&Se>=l}function H(){var ut=Vr();if(N(ut))return G(ut);g=Vn(H,$(ut))}function G(ut){return g=r,M&&o?L(ut):(o=u=r,d)}function Dt(){g!==r&&ru(g),E=0,o=b=u=g=r}function Tt(){return g===r?d:G(Vr())}function Nt(){var ut=Vr(),ie=N(ut);if(o=arguments,u=this,b=ut,ie){if(g===r)return D(b);if(T)return ru(g),g=Vn(H,e),L(b)}return g===r&&(g=Vn(H,e)),d}return Nt.cancel=Dt,Nt.flush=Tt,Nt}var Y_=z(function(t,e){return Da(t,1,e)}),V_=z(function(t,e,s){return Da(t,Kt(e)||0,s)});function Z_(t){return be(t,Q)}function Zr(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new qt(p);var s=function(){var o=arguments,u=e?e.apply(this,o):o[0],l=s.cache;if(l.has(u))return l.get(u);var d=t.apply(this,o);return s.cache=l.set(u,d)||l,d};return s.cache=new(Zr.Cache||ge),s}Zr.Cache=ge;function Xr(t){if(typeof t!="function")throw new qt(p);return function(){var e=arguments;switch(e.length){case 0:return!t.call(this);case 1:return!t.call(this,e[0]);case 2:return!t.call(this,e[0],e[1]);case 3:return!t.call(this,e[0],e[1],e[2])}return!t.apply(this,e)}}function X_(t){return zu(2,t)}var Q_=Fp(function(t,e){e=e.length==1&&U(e[0])?nt(e[0],Lt(k())):nt(mt(e,1),Lt(k()));var s=e.length;return z(function(o){for(var u=-1,l=vt(o.length,s);++u<l;)o[u]=e[u].call(this,o[u]);return Ot(t,this,o)})}),Ii=z(function(t,e){var s=Ie(e,mn(Ii));return be(t,jt,r,e,s)}),Yu=z(function(t,e){var s=Ie(e,mn(Yu));return be(t,$e,r,e,s)}),j_=me(function(t,e){return be(t,ht,r,r,r,e)});function tb(t,e){if(typeof t!="function")throw new qt(p);return e=e===r?e:W(e),z(t,e)}function eb(t,e){if(typeof t!="function")throw new qt(p);return e=e==null?0:pt(W(e),0),z(function(s){var o=s[e],u=Le(s,0,e);return o&&Ce(u,o),Ot(t,this,u)})}function nb(t,e,s){var o=!0,u=!0;if(typeof t!="function")throw new qt(p);return st(s)&&(o="leading"in s?!!s.leading:o,u="trailing"in s?!!s.trailing:u),Ku(t,e,{leading:o,maxWait:e,trailing:u})}function rb(t){return qu(t,1)}function sb(t,e){return Ii(fi(e),t)}function ib(){if(!arguments.length)return[];var t=arguments[0];return U(t)?t:[t]}function ob(t){return Ht(t,R)}function ab(t,e){return e=typeof e=="function"?e:r,Ht(t,R,e)}function ub(t){return Ht(t,C|R)}function cb(t,e){return e=typeof e=="function"?e:r,Ht(t,C|R,e)}function hb(t,e){return e==null||ka(t,e,_t(e))}function se(t,e){return t===e||t!==t&&e!==e}var lb=zr(ti),fb=zr(function(t,e){return t>=e}),Xe=$a(function(){return arguments}())?$a:function(t){return ot(t)&&X.call(t,"callee")&&!Ca.call(t,"callee")},U=v.isArray,db=ua?Lt(ua):yp;function It(t){return t!=null&&Qr(t.length)&&!we(t)}function at(t){return ot(t)&&It(t)}function pb(t){return t===!0||t===!1||ot(t)&&Et(t)==Rn}var Be=Id||Ui,gb=ca?Lt(ca):Sp;function _b(t){return ot(t)&&t.nodeType===1&&!Zn(t)}function bb(t){if(t==null)return!0;if(It(t)&&(U(t)||typeof t=="string"||typeof t.splice=="function"||Be(t)||vn(t)||Xe(t)))return!t.length;var e=wt(t);if(e==te||e==ee)return!t.size;if(Yn(t))return!ri(t).length;for(var s in t)if(X.call(t,s))return!1;return!0}function mb(t,e){return Jn(t,e)}function vb(t,e,s){s=typeof s=="function"?s:r;var o=s?s(t,e):r;return o===r?Jn(t,e,r,s):!!o}function Ri(t){if(!ot(t))return!1;var e=Et(t);return e==hr||e==$l||typeof t.message=="string"&&typeof t.name=="string"&&!Zn(t)}function wb(t){return typeof t=="number"&&Ra(t)}function we(t){if(!st(t))return!1;var e=Et(t);return e==lr||e==Do||e==Wl||e==zl}function Vu(t){return typeof t=="number"&&t==W(t)}function Qr(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Te}function st(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}function ot(t){return t!=null&&typeof t=="object"}var Zu=ha?Lt(ha):xp;function yb(t,e){return t===e||ni(t,e,vi(e))}function Sb(t,e,s){return s=typeof s=="function"?s:r,ni(t,e,vi(e),s)}function Eb(t){return Xu(t)&&t!=+t}function xb(t){if(ag(t))throw new F(f);return qa(t)}function Tb(t){return t===null}function Ab(t){return t==null}function Xu(t){return typeof t=="number"||ot(t)&&Et(t)==Pn}function Zn(t){if(!ot(t)||Et(t)!=de)return!1;var e=Tr(t);if(e===null)return!0;var s=X.call(e,"constructor")&&e.constructor;return typeof s=="function"&&s instanceof s&&yr.call(s)==Sd}var Mi=la?Lt(la):Tp;function Cb(t){return Vu(t)&&t>=-Te&&t<=Te}var Qu=fa?Lt(fa):Ap;function jr(t){return typeof t=="string"||!U(t)&&ot(t)&&Et(t)==Ln}function kt(t){return typeof t=="symbol"||ot(t)&&Et(t)==fr}var vn=da?Lt(da):Cp;function Ib(t){return t===r}function Rb(t){return ot(t)&&wt(t)==Bn}function Mb(t){return ot(t)&&Et(t)==Jl}var Pb=zr(si),Ob=zr(function(t,e){return t<=e});function ju(t){if(!t)return[];if(It(t))return jr(t)?ne(t):Ct(t);if(Nn&&t[Nn])return hd(t[Nn]());var e=wt(t),s=e==te?Js:e==ee?mr:wn;return s(t)}function ye(t){if(!t)return t===0?t:0;if(t=Kt(t),t===qe||t===-qe){var e=t<0?-1:1;return e*Dl}return t===t?t:0}function W(t){var e=ye(t),s=e%1;return e===e?s?e-s:e:0}function tc(t){return t?Ke(W(t),0,ce):0}function Kt(t){if(typeof t=="number")return t;if(kt(t))return ur;if(st(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=st(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=va(t);var s=df.test(t);return s||gf.test(t)?Kf(t.slice(2),s?2:8):ff.test(t)?ur:+t}function ec(t){return le(t,Rt(t))}function Lb(t){return t?Ke(W(t),-Te,Te):t===0?t:0}function Z(t){return t==null?"":Bt(t)}var Bb=_n(function(t,e){if(Yn(e)||It(e)){le(e,_t(e),t);return}for(var s in e)X.call(e,s)&&qn(t,s,e[s])}),nc=_n(function(t,e){le(e,Rt(e),t)}),ts=_n(function(t,e,s,o){le(e,Rt(e),t,o)}),kb=_n(function(t,e,s,o){le(e,_t(e),t,o)}),Db=me(Xs);function Nb(t,e){var s=gn(t);return e==null?s:Ba(s,e)}var Fb=z(function(t,e){t=j(t);var s=-1,o=e.length,u=o>2?e[2]:r;for(u&&xt(e[0],e[1],u)&&(o=1);++s<o;)for(var l=e[s],d=Rt(l),g=-1,b=d.length;++g<b;){var E=d[g],x=t[E];(x===r||se(x,fn[E])&&!X.call(t,E))&&(t[E]=l[E])}return t}),Ub=z(function(t){return t.push(r,vu),Ot(rc,r,t)});function Wb(t,e){return ga(t,k(e,3),he)}function $b(t,e){return ga(t,k(e,3),js)}function qb(t,e){return t==null?t:Qs(t,k(e,3),Rt)}function zb(t,e){return t==null?t:Ua(t,k(e,3),Rt)}function Hb(t,e){return t&&he(t,k(e,3))}function Jb(t,e){return t&&js(t,k(e,3))}function Gb(t){return t==null?[]:kr(t,_t(t))}function Kb(t){return t==null?[]:kr(t,Rt(t))}function Pi(t,e,s){var o=t==null?r:Ye(t,e);return o===r?s:o}function Yb(t,e){return t!=null&&Su(t,e,bp)}function Oi(t,e){return t!=null&&Su(t,e,mp)}var Vb=pu(function(t,e,s){e!=null&&typeof e.toString!="function"&&(e=Sr.call(e)),t[e]=s},Bi(Mt)),Zb=pu(function(t,e,s){e!=null&&typeof e.toString!="function"&&(e=Sr.call(e)),X.call(t,e)?t[e].push(s):t[e]=[s]},k),Xb=z(Hn);function _t(t){return It(t)?Oa(t):ri(t)}function Rt(t){return It(t)?Oa(t,!0):Ip(t)}function Qb(t,e){var s={};return e=k(e,3),he(t,function(o,u,l){_e(s,e(o,u,l),o)}),s}function jb(t,e){var s={};return e=k(e,3),he(t,function(o,u,l){_e(s,u,e(o,u,l))}),s}var tm=_n(function(t,e,s){Dr(t,e,s)}),rc=_n(function(t,e,s,o){Dr(t,e,s,o)}),em=me(function(t,e){var s={};if(t==null)return s;var o=!1;e=nt(e,function(l){return l=Oe(l,t),o||(o=l.length>1),l}),le(t,bi(t),s),o&&(s=Ht(s,C|A|R,Vp));for(var u=e.length;u--;)ci(s,e[u]);return s});function nm(t,e){return sc(t,Xr(k(e)))}var rm=me(function(t,e){return t==null?{}:Mp(t,e)});function sc(t,e){if(t==null)return{};var s=nt(bi(t),function(o){return[o]});return e=k(e),Va(t,s,function(o,u){return e(o,u[0])})}function sm(t,e,s){e=Oe(e,t);var o=-1,u=e.length;for(u||(u=1,t=r);++o<u;){var l=t==null?r:t[fe(e[o])];l===r&&(o=u,l=s),t=we(l)?l.call(t):l}return t}function im(t,e,s){return t==null?t:Gn(t,e,s)}function om(t,e,s,o){return o=typeof o=="function"?o:r,t==null?t:Gn(t,e,s,o)}var ic=bu(_t),oc=bu(Rt);function am(t,e,s){var o=U(t),u=o||Be(t)||vn(t);if(e=k(e,4),s==null){var l=t&&t.constructor;u?s=o?new l:[]:st(t)?s=we(l)?gn(Tr(t)):{}:s={}}return(u?$t:he)(t,function(d,g,b){return e(s,d,g,b)}),s}function um(t,e){return t==null?!0:ci(t,e)}function cm(t,e,s){return t==null?t:tu(t,e,fi(s))}function hm(t,e,s,o){return o=typeof o=="function"?o:r,t==null?t:tu(t,e,fi(s),o)}function wn(t){return t==null?[]:Hs(t,_t(t))}function lm(t){return t==null?[]:Hs(t,Rt(t))}function fm(t,e,s){return s===r&&(s=e,e=r),s!==r&&(s=Kt(s),s=s===s?s:0),e!==r&&(e=Kt(e),e=e===e?e:0),Ke(Kt(t),e,s)}function dm(t,e,s){return e=ye(e),s===r?(s=e,e=0):s=ye(s),t=Kt(t),vp(t,e,s)}function pm(t,e,s){if(s&&typeof s!="boolean"&&xt(t,e,s)&&(e=s=r),s===r&&(typeof e=="boolean"?(s=e,e=r):typeof t=="boolean"&&(s=t,t=r)),t===r&&e===r?(t=0,e=1):(t=ye(t),e===r?(e=t,t=0):e=ye(e)),t>e){var o=t;t=e,e=o}if(s||t%1||e%1){var u=Ma();return vt(t+u*(e-t+Gf("1e-"+((u+"").length-1))),e)}return oi(t,e)}var gm=bn(function(t,e,s){return e=e.toLowerCase(),t+(s?ac(e):e)});function ac(t){return Li(Z(t).toLowerCase())}function uc(t){return t=Z(t),t&&t.replace(bf,id).replace(Df,"")}function _m(t,e,s){t=Z(t),e=Bt(e);var o=t.length;s=s===r?o:Ke(W(s),0,o);var u=s;return s-=e.length,s>=0&&t.slice(s,u)==e}function bm(t){return t=Z(t),t&&Zl.test(t)?t.replace(Uo,od):t}function mm(t){return t=Z(t),t&&nf.test(t)?t.replace(Is,"\\$&"):t}var vm=bn(function(t,e,s){return t+(s?"-":"")+e.toLowerCase()}),wm=bn(function(t,e,s){return t+(s?" ":"")+e.toLowerCase()}),ym=lu("toLowerCase");function Sm(t,e,s){t=Z(t),e=W(e);var o=e?hn(t):0;if(!e||o>=e)return t;var u=(e-o)/2;return qr(Rr(u),s)+t+qr(Ir(u),s)}function Em(t,e,s){t=Z(t),e=W(e);var o=e?hn(t):0;return e&&o<e?t+qr(e-o,s):t}function xm(t,e,s){t=Z(t),e=W(e);var o=e?hn(t):0;return e&&o<e?qr(e-o,s)+t:t}function Tm(t,e,s){return s||e==null?e=0:e&&(e=+e),Od(Z(t).replace(Rs,""),e||0)}function Am(t,e,s){return(s?xt(t,e,s):e===r)?e=1:e=W(e),ai(Z(t),e)}function Cm(){var t=arguments,e=Z(t[0]);return t.length<3?e:e.replace(t[1],t[2])}var Im=bn(function(t,e,s){return t+(s?"_":"")+e.toLowerCase()});function Rm(t,e,s){return s&&typeof s!="number"&&xt(t,e,s)&&(e=s=r),s=s===r?ce:s>>>0,s?(t=Z(t),t&&(typeof e=="string"||e!=null&&!Mi(e))&&(e=Bt(e),!e&&cn(t))?Le(ne(t),0,s):t.split(e,s)):[]}var Mm=bn(function(t,e,s){return t+(s?" ":"")+Li(e)});function Pm(t,e,s){return t=Z(t),s=s==null?0:Ke(W(s),0,t.length),e=Bt(e),t.slice(s,s+e.length)==e}function Om(t,e,s){var o=c.templateSettings;s&&xt(t,e,s)&&(e=r),t=Z(t),e=ts({},e,o,mu);var u=ts({},e.imports,o.imports,mu),l=_t(u),d=Hs(u,l),g,b,E=0,x=e.interpolate||dr,T="__p += '",M=Gs((e.escape||dr).source+"|"+x.source+"|"+(x===Wo?lf:dr).source+"|"+(e.evaluate||dr).source+"|$","g"),L="//# sourceURL="+(X.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++$f+"]")+`
23
- `;t.replace(M,function(N,H,G,Dt,Tt,Nt){return G||(G=Dt),T+=t.slice(E,Nt).replace(mf,ad),H&&(g=!0,T+=`' +
24
- __e(`+H+`) +
25
- '`),Tt&&(b=!0,T+=`';
26
- `+Tt+`;
27
- __p += '`),G&&(T+=`' +
28
- ((__t = (`+G+`)) == null ? '' : __t) +
29
- '`),E=Nt+N.length,N}),T+=`';
30
- `;var D=X.call(e,"variable")&&e.variable;if(!D)T=`with (obj) {
31
- `+T+`
8
+ */be.exports,function(y,p){(function(){var i,w="4.17.21",m=200,R="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",C="Expected a function",O="Invalid `variable` option passed into `_.template`",K="__lodash_hash_undefined__",rn=500,Rn="__lodash_placeholder__",un=1,Tn=2,dn=4,Pn=1,gt=2,yn=1,xn=2,Te=4,Hn=8,bt=16,kn=32,Rt=64,F=128,en=256,H=512,Fn=30,sn="...",Un=800,Q=16,_n=1,Yo=2,Xo=3,Tt=1/0,pt=9007199254740991,Qo=17976931348623157e292,Pe=NaN,jn=4294967295,Vo=jn-1,jo=jn>>>1,na=[["ary",F],["bind",yn],["bindKey",xn],["curry",Hn],["curryRight",bt],["flip",H],["partial",kn],["partialRight",Rt],["rearg",en]],Dt="[object Arguments]",Ee="[object Array]",ta="[object AsyncFunction]",ee="[object Boolean]",re="[object Date]",ea="[object DOMException]",Ie="[object Error]",Le="[object Function]",Xi="[object GeneratorFunction]",Jn="[object Map]",ie="[object Number]",ra="[object Null]",rt="[object Object]",Qi="[object Promise]",ia="[object Proxy]",ue="[object RegExp]",Zn="[object Set]",se="[object String]",Oe="[object Symbol]",ua="[object Undefined]",oe="[object WeakMap]",sa="[object WeakSet]",ae="[object ArrayBuffer]",Nt="[object DataView]",Cr="[object Float32Array]",br="[object Float64Array]",Rr="[object Int8Array]",Tr="[object Int16Array]",Pr="[object Int32Array]",Er="[object Uint8Array]",Ir="[object Uint8ClampedArray]",Lr="[object Uint16Array]",Or="[object Uint32Array]",oa=/\b__p \+= '';/g,aa=/\b(__p \+=) '' \+/g,fa=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Vi=/&(?:amp|lt|gt|quot|#39);/g,ji=/[&<>"']/g,la=RegExp(Vi.source),ca=RegExp(ji.source),ha=/<%-([\s\S]+?)%>/g,ga=/<%([\s\S]+?)%>/g,nu=/<%=([\s\S]+?)%>/g,pa=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,da=/^\w*$/,_a=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Wr=/[\\^$.*+?()[\]{}|]/g,va=RegExp(Wr.source),Mr=/^\s+/,wa=/\s/,ma=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ya=/\{\n\/\* \[wrapped with (.+)\] \*/,xa=/,? & /,Sa=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Aa=/[()=,{}\[\]\/\s]/,Ca=/\\(\\)?/g,ba=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,tu=/\w*$/,Ra=/^[-+]0x[0-9a-f]+$/i,Ta=/^0b[01]+$/i,Pa=/^\[object .+?Constructor\]$/,Ea=/^0o[0-7]+$/i,Ia=/^(?:0|[1-9]\d*)$/,La=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,We=/($^)/,Oa=/['\n\r\u2028\u2029\\]/g,Me="\\ud800-\\udfff",Wa="\\u0300-\\u036f",Ma="\\ufe20-\\ufe2f",Fa="\\u20d0-\\u20ff",eu=Wa+Ma+Fa,ru="\\u2700-\\u27bf",iu="a-z\\xdf-\\xf6\\xf8-\\xff",Ua="\\xac\\xb1\\xd7\\xf7",Da="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Na="\\u2000-\\u206f",Ba=" \\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",uu="A-Z\\xc0-\\xd6\\xd8-\\xde",su="\\ufe0e\\ufe0f",ou=Ua+Da+Na+Ba,Fr="['’]",$a="["+Me+"]",au="["+ou+"]",Fe="["+eu+"]",fu="\\d+",qa="["+ru+"]",lu="["+iu+"]",cu="[^"+Me+ou+fu+ru+iu+uu+"]",Ur="\\ud83c[\\udffb-\\udfff]",Ka="(?:"+Fe+"|"+Ur+")",hu="[^"+Me+"]",Dr="(?:\\ud83c[\\udde6-\\uddff]){2}",Nr="[\\ud800-\\udbff][\\udc00-\\udfff]",Bt="["+uu+"]",gu="\\u200d",pu="(?:"+lu+"|"+cu+")",Ga="(?:"+Bt+"|"+cu+")",du="(?:"+Fr+"(?:d|ll|m|re|s|t|ve))?",_u="(?:"+Fr+"(?:D|LL|M|RE|S|T|VE))?",vu=Ka+"?",wu="["+su+"]?",za="(?:"+gu+"(?:"+[hu,Dr,Nr].join("|")+")"+wu+vu+")*",Ha="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ka="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",mu=wu+vu+za,Ja="(?:"+[qa,Dr,Nr].join("|")+")"+mu,Za="(?:"+[hu+Fe+"?",Fe,Dr,Nr,$a].join("|")+")",Ya=RegExp(Fr,"g"),Xa=RegExp(Fe,"g"),Br=RegExp(Ur+"(?="+Ur+")|"+Za+mu,"g"),Qa=RegExp([Bt+"?"+lu+"+"+du+"(?="+[au,Bt,"$"].join("|")+")",Ga+"+"+_u+"(?="+[au,Bt+pu,"$"].join("|")+")",Bt+"?"+pu+"+"+du,Bt+"+"+_u,ka,Ha,fu,Ja].join("|"),"g"),Va=RegExp("["+gu+Me+eu+su+"]"),ja=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nf=["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"],tf=-1,Z={};Z[Cr]=Z[br]=Z[Rr]=Z[Tr]=Z[Pr]=Z[Er]=Z[Ir]=Z[Lr]=Z[Or]=!0,Z[Dt]=Z[Ee]=Z[ae]=Z[ee]=Z[Nt]=Z[re]=Z[Ie]=Z[Le]=Z[Jn]=Z[ie]=Z[rt]=Z[ue]=Z[Zn]=Z[se]=Z[oe]=!1;var J={};J[Dt]=J[Ee]=J[ae]=J[Nt]=J[ee]=J[re]=J[Cr]=J[br]=J[Rr]=J[Tr]=J[Pr]=J[Jn]=J[ie]=J[rt]=J[ue]=J[Zn]=J[se]=J[Oe]=J[Er]=J[Ir]=J[Lr]=J[Or]=!0,J[Ie]=J[Le]=J[oe]=!1;var ef={À:"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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},uf={"&amp;":"&","&lt;":"<","&gt;":">","&quot;":'"',"&#39;":"'"},sf={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},of=parseFloat,af=parseInt,yu=typeof ne=="object"&&ne&&ne.Object===Object&&ne,ff=typeof self=="object"&&self&&self.Object===Object&&self,ln=yu||ff||Function("return this")(),$r=p&&!p.nodeType&&p,Pt=$r&&!0&&y&&!y.nodeType&&y,xu=Pt&&Pt.exports===$r,qr=xu&&yu.process,Dn=function(){try{var l=Pt&&Pt.require&&Pt.require("util").types;return l||qr&&qr.binding&&qr.binding("util")}catch{}}(),Su=Dn&&Dn.isArrayBuffer,Au=Dn&&Dn.isDate,Cu=Dn&&Dn.isMap,bu=Dn&&Dn.isRegExp,Ru=Dn&&Dn.isSet,Tu=Dn&&Dn.isTypedArray;function En(l,g,h){switch(h.length){case 0:return l.call(g);case 1:return l.call(g,h[0]);case 2:return l.call(g,h[0],h[1]);case 3:return l.call(g,h[0],h[1],h[2])}return l.apply(g,h)}function lf(l,g,h,S){for(var I=-1,q=l==null?0:l.length;++I<q;){var on=l[I];g(S,on,h(on),l)}return S}function Nn(l,g){for(var h=-1,S=l==null?0:l.length;++h<S&&g(l[h],h,l)!==!1;);return l}function cf(l,g){for(var h=l==null?0:l.length;h--&&g(l[h],h,l)!==!1;);return l}function Pu(l,g){for(var h=-1,S=l==null?0:l.length;++h<S;)if(!g(l[h],h,l))return!1;return!0}function dt(l,g){for(var h=-1,S=l==null?0:l.length,I=0,q=[];++h<S;){var on=l[h];g(on,h,l)&&(q[I++]=on)}return q}function Ue(l,g){var h=l==null?0:l.length;return!!h&&$t(l,g,0)>-1}function Kr(l,g,h){for(var S=-1,I=l==null?0:l.length;++S<I;)if(h(g,l[S]))return!0;return!1}function Y(l,g){for(var h=-1,S=l==null?0:l.length,I=Array(S);++h<S;)I[h]=g(l[h],h,l);return I}function _t(l,g){for(var h=-1,S=g.length,I=l.length;++h<S;)l[I+h]=g[h];return l}function Gr(l,g,h,S){var I=-1,q=l==null?0:l.length;for(S&&q&&(h=l[++I]);++I<q;)h=g(h,l[I],I,l);return h}function hf(l,g,h,S){var I=l==null?0:l.length;for(S&&I&&(h=l[--I]);I--;)h=g(h,l[I],I,l);return h}function zr(l,g){for(var h=-1,S=l==null?0:l.length;++h<S;)if(g(l[h],h,l))return!0;return!1}var gf=Hr("length");function pf(l){return l.split("")}function df(l){return l.match(Sa)||[]}function Eu(l,g,h){var S;return h(l,function(I,q,on){if(g(I,q,on))return S=q,!1}),S}function De(l,g,h,S){for(var I=l.length,q=h+(S?1:-1);S?q--:++q<I;)if(g(l[q],q,l))return q;return-1}function $t(l,g,h){return g===g?Tf(l,g,h):De(l,Iu,h)}function _f(l,g,h,S){for(var I=h-1,q=l.length;++I<q;)if(S(l[I],g))return I;return-1}function Iu(l){return l!==l}function Lu(l,g){var h=l==null?0:l.length;return h?Jr(l,g)/h:Pe}function Hr(l){return function(g){return g==null?i:g[l]}}function kr(l){return function(g){return l==null?i:l[g]}}function Ou(l,g,h,S,I){return I(l,function(q,on,k){h=S?(S=!1,q):g(h,q,on,k)}),h}function vf(l,g){var h=l.length;for(l.sort(g);h--;)l[h]=l[h].value;return l}function Jr(l,g){for(var h,S=-1,I=l.length;++S<I;){var q=g(l[S]);q!==i&&(h=h===i?q:h+q)}return h}function Zr(l,g){for(var h=-1,S=Array(l);++h<l;)S[h]=g(h);return S}function wf(l,g){return Y(g,function(h){return[h,l[h]]})}function Wu(l){return l&&l.slice(0,Du(l)+1).replace(Mr,"")}function In(l){return function(g){return l(g)}}function Yr(l,g){return Y(g,function(h){return l[h]})}function fe(l,g){return l.has(g)}function Mu(l,g){for(var h=-1,S=l.length;++h<S&&$t(g,l[h],0)>-1;);return h}function Fu(l,g){for(var h=l.length;h--&&$t(g,l[h],0)>-1;);return h}function mf(l,g){for(var h=l.length,S=0;h--;)l[h]===g&&++S;return S}var yf=kr(ef),xf=kr(rf);function Sf(l){return"\\"+sf[l]}function Af(l,g){return l==null?i:l[g]}function qt(l){return Va.test(l)}function Cf(l){return ja.test(l)}function bf(l){for(var g,h=[];!(g=l.next()).done;)h.push(g.value);return h}function Xr(l){var g=-1,h=Array(l.size);return l.forEach(function(S,I){h[++g]=[I,S]}),h}function Uu(l,g){return function(h){return l(g(h))}}function vt(l,g){for(var h=-1,S=l.length,I=0,q=[];++h<S;){var on=l[h];(on===g||on===Rn)&&(l[h]=Rn,q[I++]=h)}return q}function Ne(l){var g=-1,h=Array(l.size);return l.forEach(function(S){h[++g]=S}),h}function Rf(l){var g=-1,h=Array(l.size);return l.forEach(function(S){h[++g]=[S,S]}),h}function Tf(l,g,h){for(var S=h-1,I=l.length;++S<I;)if(l[S]===g)return S;return-1}function Pf(l,g,h){for(var S=h+1;S--;)if(l[S]===g)return S;return S}function Kt(l){return qt(l)?If(l):gf(l)}function Yn(l){return qt(l)?Lf(l):pf(l)}function Du(l){for(var g=l.length;g--&&wa.test(l.charAt(g)););return g}var Ef=kr(uf);function If(l){for(var g=Br.lastIndex=0;Br.test(l);)++g;return g}function Lf(l){return l.match(Br)||[]}function Of(l){return l.match(Qa)||[]}var Wf=function l(g){g=g==null?ln:Gt.defaults(ln.Object(),g,Gt.pick(ln,nf));var h=g.Array,S=g.Date,I=g.Error,q=g.Function,on=g.Math,k=g.Object,Qr=g.RegExp,Mf=g.String,Bn=g.TypeError,Be=h.prototype,Ff=q.prototype,zt=k.prototype,$e=g["__core-js_shared__"],qe=Ff.toString,z=zt.hasOwnProperty,Uf=0,Nu=function(){var n=/[^.]+$/.exec($e&&$e.keys&&$e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),Ke=zt.toString,Df=qe.call(k),Nf=ln._,Bf=Qr("^"+qe.call(z).replace(Wr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ge=xu?g.Buffer:i,wt=g.Symbol,ze=g.Uint8Array,Bu=Ge?Ge.allocUnsafe:i,He=Uu(k.getPrototypeOf,k),$u=k.create,qu=zt.propertyIsEnumerable,ke=Be.splice,Ku=wt?wt.isConcatSpreadable:i,le=wt?wt.iterator:i,Et=wt?wt.toStringTag:i,Je=function(){try{var n=Mt(k,"defineProperty");return n({},"",{}),n}catch{}}(),$f=g.clearTimeout!==ln.clearTimeout&&g.clearTimeout,qf=S&&S.now!==ln.Date.now&&S.now,Kf=g.setTimeout!==ln.setTimeout&&g.setTimeout,Ze=on.ceil,Ye=on.floor,Vr=k.getOwnPropertySymbols,Gf=Ge?Ge.isBuffer:i,Gu=g.isFinite,zf=Be.join,Hf=Uu(k.keys,k),an=on.max,hn=on.min,kf=S.now,Jf=g.parseInt,zu=on.random,Zf=Be.reverse,jr=Mt(g,"DataView"),ce=Mt(g,"Map"),ni=Mt(g,"Promise"),Ht=Mt(g,"Set"),he=Mt(g,"WeakMap"),ge=Mt(k,"create"),Xe=he&&new he,kt={},Yf=Ft(jr),Xf=Ft(ce),Qf=Ft(ni),Vf=Ft(Ht),jf=Ft(he),Qe=wt?wt.prototype:i,pe=Qe?Qe.valueOf:i,Hu=Qe?Qe.toString:i;function s(n){if(V(n)&&!L(n)&&!(n instanceof N)){if(n instanceof $n)return n;if(z.call(n,"__wrapped__"))return ks(n)}return new $n(n)}var Jt=function(){function n(){}return function(t){if(!X(t))return{};if($u)return $u(t);n.prototype=t;var e=new n;return n.prototype=i,e}}();function Ve(){}function $n(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}s.templateSettings={escape:ha,evaluate:ga,interpolate:nu,variable:"",imports:{_:s}},s.prototype=Ve.prototype,s.prototype.constructor=s,$n.prototype=Jt(Ve.prototype),$n.prototype.constructor=$n;function N(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=jn,this.__views__=[]}function nl(){var n=new N(this.__wrapped__);return n.__actions__=Sn(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=Sn(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=Sn(this.__views__),n}function tl(){if(this.__filtered__){var n=new N(this);n.__dir__=-1,n.__filtered__=!0}else n=this.clone(),n.__dir__*=-1;return n}function el(){var n=this.__wrapped__.value(),t=this.__dir__,e=L(n),r=t<0,u=e?n.length:0,o=pc(0,u,this.__views__),a=o.start,f=o.end,c=f-a,d=r?f:a-1,_=this.__iteratees__,v=_.length,x=0,A=hn(c,this.__takeCount__);if(!e||!r&&u==c&&A==c)return ds(n,this.__actions__);var T=[];n:for(;c--&&x<A;){d+=t;for(var M=-1,P=n[d];++M<v;){var D=_[M],B=D.iteratee,Wn=D.type,mn=B(P);if(Wn==Yo)P=mn;else if(!mn){if(Wn==_n)continue n;break n}}T[x++]=P}return T}N.prototype=Jt(Ve.prototype),N.prototype.constructor=N;function It(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function rl(){this.__data__=ge?ge(null):{},this.size=0}function il(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}function ul(n){var t=this.__data__;if(ge){var e=t[n];return e===K?i:e}return z.call(t,n)?t[n]:i}function sl(n){var t=this.__data__;return ge?t[n]!==i:z.call(t,n)}function ol(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=ge&&t===i?K:t,this}It.prototype.clear=rl,It.prototype.delete=il,It.prototype.get=ul,It.prototype.has=sl,It.prototype.set=ol;function it(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function al(){this.__data__=[],this.size=0}function fl(n){var t=this.__data__,e=je(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():ke.call(t,e,1),--this.size,!0}function ll(n){var t=this.__data__,e=je(t,n);return e<0?i:t[e][1]}function cl(n){return je(this.__data__,n)>-1}function hl(n,t){var e=this.__data__,r=je(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}it.prototype.clear=al,it.prototype.delete=fl,it.prototype.get=ll,it.prototype.has=cl,it.prototype.set=hl;function ut(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function gl(){this.size=0,this.__data__={hash:new It,map:new(ce||it),string:new It}}function pl(n){var t=cr(this,n).delete(n);return this.size-=t?1:0,t}function dl(n){return cr(this,n).get(n)}function _l(n){return cr(this,n).has(n)}function vl(n,t){var e=cr(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}ut.prototype.clear=gl,ut.prototype.delete=pl,ut.prototype.get=dl,ut.prototype.has=_l,ut.prototype.set=vl;function Lt(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new ut;++t<e;)this.add(n[t])}function wl(n){return this.__data__.set(n,K),this}function ml(n){return this.__data__.has(n)}Lt.prototype.add=Lt.prototype.push=wl,Lt.prototype.has=ml;function Xn(n){var t=this.__data__=new it(n);this.size=t.size}function yl(){this.__data__=new it,this.size=0}function xl(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}function Sl(n){return this.__data__.get(n)}function Al(n){return this.__data__.has(n)}function Cl(n,t){var e=this.__data__;if(e instanceof it){var r=e.__data__;if(!ce||r.length<m-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new ut(r)}return e.set(n,t),this.size=e.size,this}Xn.prototype.clear=yl,Xn.prototype.delete=xl,Xn.prototype.get=Sl,Xn.prototype.has=Al,Xn.prototype.set=Cl;function ku(n,t){var e=L(n),r=!e&&Ut(n),u=!e&&!r&&At(n),o=!e&&!r&&!u&&Qt(n),a=e||r||u||o,f=a?Zr(n.length,Mf):[],c=f.length;for(var d in n)(t||z.call(n,d))&&!(a&&(d=="length"||u&&(d=="offset"||d=="parent")||o&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||ft(d,c)))&&f.push(d);return f}function Ju(n){var t=n.length;return t?n[ci(0,t-1)]:i}function bl(n,t){return hr(Sn(n),Ot(t,0,n.length))}function Rl(n){return hr(Sn(n))}function ti(n,t,e){(e!==i&&!Qn(n[t],e)||e===i&&!(t in n))&&st(n,t,e)}function de(n,t,e){var r=n[t];(!(z.call(n,t)&&Qn(r,e))||e===i&&!(t in n))&&st(n,t,e)}function je(n,t){for(var e=n.length;e--;)if(Qn(n[e][0],t))return e;return-1}function Tl(n,t,e,r){return mt(n,function(u,o,a){t(r,u,e(u),a)}),r}function Zu(n,t){return n&&tt(t,fn(t),n)}function Pl(n,t){return n&&tt(t,Cn(t),n)}function st(n,t,e){t=="__proto__"&&Je?Je(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}function ei(n,t){for(var e=-1,r=t.length,u=h(r),o=n==null;++e<r;)u[e]=o?i:Ui(n,t[e]);return u}function Ot(n,t,e){return n===n&&(e!==i&&(n=n<=e?n:e),t!==i&&(n=n>=t?n:t)),n}function qn(n,t,e,r,u,o){var a,f=t&un,c=t&Tn,d=t&dn;if(e&&(a=u?e(n,r,u,o):e(n)),a!==i)return a;if(!X(n))return n;var _=L(n);if(_){if(a=_c(n),!f)return Sn(n,a)}else{var v=gn(n),x=v==Le||v==Xi;if(At(n))return ws(n,f);if(v==rt||v==Dt||x&&!u){if(a=c||x?{}:Ds(n),!f)return c?uc(n,Pl(a,n)):ic(n,Zu(a,n))}else{if(!J[v])return u?n:{};a=vc(n,v,f)}}o||(o=new Xn);var A=o.get(n);if(A)return A;o.set(n,a),ho(n)?n.forEach(function(P){a.add(qn(P,t,e,P,n,o))}):lo(n)&&n.forEach(function(P,D){a.set(D,qn(P,t,e,D,n,o))});var T=d?c?Si:xi:c?Cn:fn,M=_?i:T(n);return Nn(M||n,function(P,D){M&&(D=P,P=n[D]),de(a,D,qn(P,t,e,D,n,o))}),a}function El(n){var t=fn(n);return function(e){return Yu(e,n,t)}}function Yu(n,t,e){var r=e.length;if(n==null)return!r;for(n=k(n);r--;){var u=e[r],o=t[u],a=n[u];if(a===i&&!(u in n)||!o(a))return!1}return!0}function Xu(n,t,e){if(typeof n!="function")throw new Bn(C);return Se(function(){n.apply(i,e)},t)}function _e(n,t,e,r){var u=-1,o=Ue,a=!0,f=n.length,c=[],d=t.length;if(!f)return c;e&&(t=Y(t,In(e))),r?(o=Kr,a=!1):t.length>=m&&(o=fe,a=!1,t=new Lt(t));n:for(;++u<f;){var _=n[u],v=e==null?_:e(_);if(_=r||_!==0?_:0,a&&v===v){for(var x=d;x--;)if(t[x]===v)continue n;c.push(_)}else o(t,v,r)||c.push(_)}return c}var mt=As(nt),Qu=As(ii,!0);function Il(n,t){var e=!0;return mt(n,function(r,u,o){return e=!!t(r,u,o),e}),e}function nr(n,t,e){for(var r=-1,u=n.length;++r<u;){var o=n[r],a=t(o);if(a!=null&&(f===i?a===a&&!On(a):e(a,f)))var f=a,c=o}return c}function Ll(n,t,e,r){var u=n.length;for(e=W(e),e<0&&(e=-e>u?0:u+e),r=r===i||r>u?u:W(r),r<0&&(r+=u),r=e>r?0:po(r);e<r;)n[e++]=t;return n}function Vu(n,t){var e=[];return mt(n,function(r,u,o){t(r,u,o)&&e.push(r)}),e}function cn(n,t,e,r,u){var o=-1,a=n.length;for(e||(e=mc),u||(u=[]);++o<a;){var f=n[o];t>0&&e(f)?t>1?cn(f,t-1,e,r,u):_t(u,f):r||(u[u.length]=f)}return u}var ri=Cs(),ju=Cs(!0);function nt(n,t){return n&&ri(n,t,fn)}function ii(n,t){return n&&ju(n,t,fn)}function tr(n,t){return dt(t,function(e){return lt(n[e])})}function Wt(n,t){t=xt(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[et(t[e++])];return e&&e==r?n:i}function ns(n,t,e){var r=t(n);return L(n)?r:_t(r,e(n))}function vn(n){return n==null?n===i?ua:ra:Et&&Et in k(n)?gc(n):Rc(n)}function ui(n,t){return n>t}function Ol(n,t){return n!=null&&z.call(n,t)}function Wl(n,t){return n!=null&&t in k(n)}function Ml(n,t,e){return n>=hn(t,e)&&n<an(t,e)}function si(n,t,e){for(var r=e?Kr:Ue,u=n[0].length,o=n.length,a=o,f=h(o),c=1/0,d=[];a--;){var _=n[a];a&&t&&(_=Y(_,In(t))),c=hn(_.length,c),f[a]=!e&&(t||u>=120&&_.length>=120)?new Lt(a&&_):i}_=n[0];var v=-1,x=f[0];n:for(;++v<u&&d.length<c;){var A=_[v],T=t?t(A):A;if(A=e||A!==0?A:0,!(x?fe(x,T):r(d,T,e))){for(a=o;--a;){var M=f[a];if(!(M?fe(M,T):r(n[a],T,e)))continue n}x&&x.push(T),d.push(A)}}return d}function Fl(n,t,e,r){return nt(n,function(u,o,a){t(r,e(u),o,a)}),r}function ve(n,t,e){t=xt(t,n),n=qs(n,t);var r=n==null?n:n[et(Gn(t))];return r==null?i:En(r,n,e)}function ts(n){return V(n)&&vn(n)==Dt}function Ul(n){return V(n)&&vn(n)==ae}function Dl(n){return V(n)&&vn(n)==re}function we(n,t,e,r,u){return n===t?!0:n==null||t==null||!V(n)&&!V(t)?n!==n&&t!==t:Nl(n,t,e,r,we,u)}function Nl(n,t,e,r,u,o){var a=L(n),f=L(t),c=a?Ee:gn(n),d=f?Ee:gn(t);c=c==Dt?rt:c,d=d==Dt?rt:d;var _=c==rt,v=d==rt,x=c==d;if(x&&At(n)){if(!At(t))return!1;a=!0,_=!1}if(x&&!_)return o||(o=new Xn),a||Qt(n)?Ms(n,t,e,r,u,o):cc(n,t,c,e,r,u,o);if(!(e&Pn)){var A=_&&z.call(n,"__wrapped__"),T=v&&z.call(t,"__wrapped__");if(A||T){var M=A?n.value():n,P=T?t.value():t;return o||(o=new Xn),u(M,P,e,r,o)}}return x?(o||(o=new Xn),hc(n,t,e,r,u,o)):!1}function Bl(n){return V(n)&&gn(n)==Jn}function oi(n,t,e,r){var u=e.length,o=u,a=!r;if(n==null)return!o;for(n=k(n);u--;){var f=e[u];if(a&&f[2]?f[1]!==n[f[0]]:!(f[0]in n))return!1}for(;++u<o;){f=e[u];var c=f[0],d=n[c],_=f[1];if(a&&f[2]){if(d===i&&!(c in n))return!1}else{var v=new Xn;if(r)var x=r(d,_,c,n,t,v);if(!(x===i?we(_,d,Pn|gt,r,v):x))return!1}}return!0}function es(n){if(!X(n)||xc(n))return!1;var t=lt(n)?Bf:Pa;return t.test(Ft(n))}function $l(n){return V(n)&&vn(n)==ue}function ql(n){return V(n)&&gn(n)==Zn}function Kl(n){return V(n)&&wr(n.length)&&!!Z[vn(n)]}function rs(n){return typeof n=="function"?n:n==null?bn:typeof n=="object"?L(n)?ss(n[0],n[1]):us(n):Ro(n)}function ai(n){if(!xe(n))return Hf(n);var t=[];for(var e in k(n))z.call(n,e)&&e!="constructor"&&t.push(e);return t}function Gl(n){if(!X(n))return bc(n);var t=xe(n),e=[];for(var r in n)r=="constructor"&&(t||!z.call(n,r))||e.push(r);return e}function fi(n,t){return n<t}function is(n,t){var e=-1,r=An(n)?h(n.length):[];return mt(n,function(u,o,a){r[++e]=t(u,o,a)}),r}function us(n){var t=Ci(n);return t.length==1&&t[0][2]?Bs(t[0][0],t[0][1]):function(e){return e===n||oi(e,n,t)}}function ss(n,t){return Ri(n)&&Ns(t)?Bs(et(n),t):function(e){var r=Ui(e,n);return r===i&&r===t?Di(e,n):we(t,r,Pn|gt)}}function er(n,t,e,r,u){n!==t&&ri(t,function(o,a){if(u||(u=new Xn),X(o))zl(n,t,a,e,er,r,u);else{var f=r?r(Pi(n,a),o,a+"",n,t,u):i;f===i&&(f=o),ti(n,a,f)}},Cn)}function zl(n,t,e,r,u,o,a){var f=Pi(n,e),c=Pi(t,e),d=a.get(c);if(d){ti(n,e,d);return}var _=o?o(f,c,e+"",n,t,a):i,v=_===i;if(v){var x=L(c),A=!x&&At(c),T=!x&&!A&&Qt(c);_=c,x||A||T?L(f)?_=f:j(f)?_=Sn(f):A?(v=!1,_=ws(c,!0)):T?(v=!1,_=ms(c,!0)):_=[]:Ae(c)||Ut(c)?(_=f,Ut(f)?_=_o(f):(!X(f)||lt(f))&&(_=Ds(c))):v=!1}v&&(a.set(c,_),u(_,c,r,o,a),a.delete(c)),ti(n,e,_)}function os(n,t){var e=n.length;if(e)return t+=t<0?e:0,ft(t,e)?n[t]:i}function as(n,t,e){t.length?t=Y(t,function(o){return L(o)?function(a){return Wt(a,o.length===1?o[0]:o)}:o}):t=[bn];var r=-1;t=Y(t,In(b()));var u=is(n,function(o,a,f){var c=Y(t,function(d){return d(o)});return{criteria:c,index:++r,value:o}});return vf(u,function(o,a){return rc(o,a,e)})}function Hl(n,t){return fs(n,t,function(e,r){return Di(n,r)})}function fs(n,t,e){for(var r=-1,u=t.length,o={};++r<u;){var a=t[r],f=Wt(n,a);e(f,a)&&me(o,xt(a,n),f)}return o}function kl(n){return function(t){return Wt(t,n)}}function li(n,t,e,r){var u=r?_f:$t,o=-1,a=t.length,f=n;for(n===t&&(t=Sn(t)),e&&(f=Y(n,In(e)));++o<a;)for(var c=0,d=t[o],_=e?e(d):d;(c=u(f,_,c,r))>-1;)f!==n&&ke.call(f,c,1),ke.call(n,c,1);return n}function ls(n,t){for(var e=n?t.length:0,r=e-1;e--;){var u=t[e];if(e==r||u!==o){var o=u;ft(u)?ke.call(n,u,1):pi(n,u)}}return n}function ci(n,t){return n+Ye(zu()*(t-n+1))}function Jl(n,t,e,r){for(var u=-1,o=an(Ze((t-n)/(e||1)),0),a=h(o);o--;)a[r?o:++u]=n,n+=e;return a}function hi(n,t){var e="";if(!n||t<1||t>pt)return e;do t%2&&(e+=n),t=Ye(t/2),t&&(n+=n);while(t);return e}function U(n,t){return Ei($s(n,t,bn),n+"")}function Zl(n){return Ju(Vt(n))}function Yl(n,t){var e=Vt(n);return hr(e,Ot(t,0,e.length))}function me(n,t,e,r){if(!X(n))return n;t=xt(t,n);for(var u=-1,o=t.length,a=o-1,f=n;f!=null&&++u<o;){var c=et(t[u]),d=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(u!=a){var _=f[c];d=r?r(_,c,f):i,d===i&&(d=X(_)?_:ft(t[u+1])?[]:{})}de(f,c,d),f=f[c]}return n}var cs=Xe?function(n,t){return Xe.set(n,t),n}:bn,Xl=Je?function(n,t){return Je(n,"toString",{configurable:!0,enumerable:!1,value:Bi(t),writable:!0})}:bn;function Ql(n){return hr(Vt(n))}function Kn(n,t,e){var r=-1,u=n.length;t<0&&(t=-t>u?0:u+t),e=e>u?u:e,e<0&&(e+=u),u=t>e?0:e-t>>>0,t>>>=0;for(var o=h(u);++r<u;)o[r]=n[r+t];return o}function Vl(n,t){var e;return mt(n,function(r,u,o){return e=t(r,u,o),!e}),!!e}function rr(n,t,e){var r=0,u=n==null?r:n.length;if(typeof t=="number"&&t===t&&u<=jo){for(;r<u;){var o=r+u>>>1,a=n[o];a!==null&&!On(a)&&(e?a<=t:a<t)?r=o+1:u=o}return u}return gi(n,t,bn,e)}function gi(n,t,e,r){var u=0,o=n==null?0:n.length;if(o===0)return 0;t=e(t);for(var a=t!==t,f=t===null,c=On(t),d=t===i;u<o;){var _=Ye((u+o)/2),v=e(n[_]),x=v!==i,A=v===null,T=v===v,M=On(v);if(a)var P=r||T;else d?P=T&&(r||x):f?P=T&&x&&(r||!A):c?P=T&&x&&!A&&(r||!M):A||M?P=!1:P=r?v<=t:v<t;P?u=_+1:o=_}return hn(o,Vo)}function hs(n,t){for(var e=-1,r=n.length,u=0,o=[];++e<r;){var a=n[e],f=t?t(a):a;if(!e||!Qn(f,c)){var c=f;o[u++]=a===0?0:a}}return o}function gs(n){return typeof n=="number"?n:On(n)?Pe:+n}function Ln(n){if(typeof n=="string")return n;if(L(n))return Y(n,Ln)+"";if(On(n))return Hu?Hu.call(n):"";var t=n+"";return t=="0"&&1/n==-Tt?"-0":t}function yt(n,t,e){var r=-1,u=Ue,o=n.length,a=!0,f=[],c=f;if(e)a=!1,u=Kr;else if(o>=m){var d=t?null:fc(n);if(d)return Ne(d);a=!1,u=fe,c=new Lt}else c=t?[]:f;n:for(;++r<o;){var _=n[r],v=t?t(_):_;if(_=e||_!==0?_:0,a&&v===v){for(var x=c.length;x--;)if(c[x]===v)continue n;t&&c.push(v),f.push(_)}else u(c,v,e)||(c!==f&&c.push(v),f.push(_))}return f}function pi(n,t){return t=xt(t,n),n=qs(n,t),n==null||delete n[et(Gn(t))]}function ps(n,t,e,r){return me(n,t,e(Wt(n,t)),r)}function ir(n,t,e,r){for(var u=n.length,o=r?u:-1;(r?o--:++o<u)&&t(n[o],o,n););return e?Kn(n,r?0:o,r?o+1:u):Kn(n,r?o+1:0,r?u:o)}function ds(n,t){var e=n;return e instanceof N&&(e=e.value()),Gr(t,function(r,u){return u.func.apply(u.thisArg,_t([r],u.args))},e)}function di(n,t,e){var r=n.length;if(r<2)return r?yt(n[0]):[];for(var u=-1,o=h(r);++u<r;)for(var a=n[u],f=-1;++f<r;)f!=u&&(o[u]=_e(o[u]||a,n[f],t,e));return yt(cn(o,1),t,e)}function _s(n,t,e){for(var r=-1,u=n.length,o=t.length,a={};++r<u;){var f=r<o?t[r]:i;e(a,n[r],f)}return a}function _i(n){return j(n)?n:[]}function vi(n){return typeof n=="function"?n:bn}function xt(n,t){return L(n)?n:Ri(n,t)?[n]:Hs(G(n))}var jl=U;function St(n,t,e){var r=n.length;return e=e===i?r:e,!t&&e>=r?n:Kn(n,t,e)}var vs=$f||function(n){return ln.clearTimeout(n)};function ws(n,t){if(t)return n.slice();var e=n.length,r=Bu?Bu(e):new n.constructor(e);return n.copy(r),r}function wi(n){var t=new n.constructor(n.byteLength);return new ze(t).set(new ze(n)),t}function nc(n,t){var e=t?wi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}function tc(n){var t=new n.constructor(n.source,tu.exec(n));return t.lastIndex=n.lastIndex,t}function ec(n){return pe?k(pe.call(n)):{}}function ms(n,t){var e=t?wi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}function ys(n,t){if(n!==t){var e=n!==i,r=n===null,u=n===n,o=On(n),a=t!==i,f=t===null,c=t===t,d=On(t);if(!f&&!d&&!o&&n>t||o&&a&&c&&!f&&!d||r&&a&&c||!e&&c||!u)return 1;if(!r&&!o&&!d&&n<t||d&&e&&u&&!r&&!o||f&&e&&u||!a&&u||!c)return-1}return 0}function rc(n,t,e){for(var r=-1,u=n.criteria,o=t.criteria,a=u.length,f=e.length;++r<a;){var c=ys(u[r],o[r]);if(c){if(r>=f)return c;var d=e[r];return c*(d=="desc"?-1:1)}}return n.index-t.index}function xs(n,t,e,r){for(var u=-1,o=n.length,a=e.length,f=-1,c=t.length,d=an(o-a,0),_=h(c+d),v=!r;++f<c;)_[f]=t[f];for(;++u<a;)(v||u<o)&&(_[e[u]]=n[u]);for(;d--;)_[f++]=n[u++];return _}function Ss(n,t,e,r){for(var u=-1,o=n.length,a=-1,f=e.length,c=-1,d=t.length,_=an(o-f,0),v=h(_+d),x=!r;++u<_;)v[u]=n[u];for(var A=u;++c<d;)v[A+c]=t[c];for(;++a<f;)(x||u<o)&&(v[A+e[a]]=n[u++]);return v}function Sn(n,t){var e=-1,r=n.length;for(t||(t=h(r));++e<r;)t[e]=n[e];return t}function tt(n,t,e,r){var u=!e;e||(e={});for(var o=-1,a=t.length;++o<a;){var f=t[o],c=r?r(e[f],n[f],f,e,n):i;c===i&&(c=n[f]),u?st(e,f,c):de(e,f,c)}return e}function ic(n,t){return tt(n,bi(n),t)}function uc(n,t){return tt(n,Fs(n),t)}function ur(n,t){return function(e,r){var u=L(e)?lf:Tl,o=t?t():{};return u(e,n,b(r,2),o)}}function Zt(n){return U(function(t,e){var r=-1,u=e.length,o=u>1?e[u-1]:i,a=u>2?e[2]:i;for(o=n.length>3&&typeof o=="function"?(u--,o):i,a&&wn(e[0],e[1],a)&&(o=u<3?i:o,u=1),t=k(t);++r<u;){var f=e[r];f&&n(t,f,r,o)}return t})}function As(n,t){return function(e,r){if(e==null)return e;if(!An(e))return n(e,r);for(var u=e.length,o=t?u:-1,a=k(e);(t?o--:++o<u)&&r(a[o],o,a)!==!1;);return e}}function Cs(n){return function(t,e,r){for(var u=-1,o=k(t),a=r(t),f=a.length;f--;){var c=a[n?f:++u];if(e(o[c],c,o)===!1)break}return t}}function sc(n,t,e){var r=t&yn,u=ye(n);function o(){var a=this&&this!==ln&&this instanceof o?u:n;return a.apply(r?e:this,arguments)}return o}function bs(n){return function(t){t=G(t);var e=qt(t)?Yn(t):i,r=e?e[0]:t.charAt(0),u=e?St(e,1).join(""):t.slice(1);return r[n]()+u}}function Yt(n){return function(t){return Gr(Co(Ao(t).replace(Ya,"")),n,"")}}function ye(n){return function(){var t=arguments;switch(t.length){case 0:return new n;case 1:return new n(t[0]);case 2:return new n(t[0],t[1]);case 3:return new n(t[0],t[1],t[2]);case 4:return new n(t[0],t[1],t[2],t[3]);case 5:return new n(t[0],t[1],t[2],t[3],t[4]);case 6:return new n(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var e=Jt(n.prototype),r=n.apply(e,t);return X(r)?r:e}}function oc(n,t,e){var r=ye(n);function u(){for(var o=arguments.length,a=h(o),f=o,c=Xt(u);f--;)a[f]=arguments[f];var d=o<3&&a[0]!==c&&a[o-1]!==c?[]:vt(a,c);if(o-=d.length,o<e)return Is(n,t,sr,u.placeholder,i,a,d,i,i,e-o);var _=this&&this!==ln&&this instanceof u?r:n;return En(_,this,a)}return u}function Rs(n){return function(t,e,r){var u=k(t);if(!An(t)){var o=b(e,3);t=fn(t),e=function(f){return o(u[f],f,u)}}var a=n(t,e,r);return a>-1?u[o?t[a]:a]:i}}function Ts(n){return at(function(t){var e=t.length,r=e,u=$n.prototype.thru;for(n&&t.reverse();r--;){var o=t[r];if(typeof o!="function")throw new Bn(C);if(u&&!a&&lr(o)=="wrapper")var a=new $n([],!0)}for(r=a?r:e;++r<e;){o=t[r];var f=lr(o),c=f=="wrapper"?Ai(o):i;c&&Ti(c[0])&&c[1]==(F|Hn|kn|en)&&!c[4].length&&c[9]==1?a=a[lr(c[0])].apply(a,c[3]):a=o.length==1&&Ti(o)?a[f]():a.thru(o)}return function(){var d=arguments,_=d[0];if(a&&d.length==1&&L(_))return a.plant(_).value();for(var v=0,x=e?t[v].apply(this,d):_;++v<e;)x=t[v].call(this,x);return x}})}function sr(n,t,e,r,u,o,a,f,c,d){var _=t&F,v=t&yn,x=t&xn,A=t&(Hn|bt),T=t&H,M=x?i:ye(n);function P(){for(var D=arguments.length,B=h(D),Wn=D;Wn--;)B[Wn]=arguments[Wn];if(A)var mn=Xt(P),Mn=mf(B,mn);if(r&&(B=xs(B,r,u,A)),o&&(B=Ss(B,o,a,A)),D-=Mn,A&&D<d){var nn=vt(B,mn);return Is(n,t,sr,P.placeholder,e,B,nn,f,c,d-D)}var Vn=v?e:this,ht=x?Vn[n]:n;return D=B.length,f?B=Tc(B,f):T&&D>1&&B.reverse(),_&&c<D&&(B.length=c),this&&this!==ln&&this instanceof P&&(ht=M||ye(ht)),ht.apply(Vn,B)}return P}function Ps(n,t){return function(e,r){return Fl(e,n,t(r),{})}}function or(n,t){return function(e,r){var u;if(e===i&&r===i)return t;if(e!==i&&(u=e),r!==i){if(u===i)return r;typeof e=="string"||typeof r=="string"?(e=Ln(e),r=Ln(r)):(e=gs(e),r=gs(r)),u=n(e,r)}return u}}function mi(n){return at(function(t){return t=Y(t,In(b())),U(function(e){var r=this;return n(t,function(u){return En(u,r,e)})})})}function ar(n,t){t=t===i?" ":Ln(t);var e=t.length;if(e<2)return e?hi(t,n):t;var r=hi(t,Ze(n/Kt(t)));return qt(t)?St(Yn(r),0,n).join(""):r.slice(0,n)}function ac(n,t,e,r){var u=t&yn,o=ye(n);function a(){for(var f=-1,c=arguments.length,d=-1,_=r.length,v=h(_+c),x=this&&this!==ln&&this instanceof a?o:n;++d<_;)v[d]=r[d];for(;c--;)v[d++]=arguments[++f];return En(x,u?e:this,v)}return a}function Es(n){return function(t,e,r){return r&&typeof r!="number"&&wn(t,e,r)&&(e=r=i),t=ct(t),e===i?(e=t,t=0):e=ct(e),r=r===i?t<e?1:-1:ct(r),Jl(t,e,r,n)}}function fr(n){return function(t,e){return typeof t=="string"&&typeof e=="string"||(t=zn(t),e=zn(e)),n(t,e)}}function Is(n,t,e,r,u,o,a,f,c,d){var _=t&Hn,v=_?a:i,x=_?i:a,A=_?o:i,T=_?i:o;t|=_?kn:Rt,t&=~(_?Rt:kn),t&Te||(t&=-4);var M=[n,t,u,A,v,T,x,f,c,d],P=e.apply(i,M);return Ti(n)&&Ks(P,M),P.placeholder=r,Gs(P,n,t)}function yi(n){var t=on[n];return function(e,r){if(e=zn(e),r=r==null?0:hn(W(r),292),r&&Gu(e)){var u=(G(e)+"e").split("e"),o=t(u[0]+"e"+(+u[1]+r));return u=(G(o)+"e").split("e"),+(u[0]+"e"+(+u[1]-r))}return t(e)}}var fc=Ht&&1/Ne(new Ht([,-0]))[1]==Tt?function(n){return new Ht(n)}:Ki;function Ls(n){return function(t){var e=gn(t);return e==Jn?Xr(t):e==Zn?Rf(t):wf(t,n(t))}}function ot(n,t,e,r,u,o,a,f){var c=t&xn;if(!c&&typeof n!="function")throw new Bn(C);var d=r?r.length:0;if(d||(t&=-97,r=u=i),a=a===i?a:an(W(a),0),f=f===i?f:W(f),d-=u?u.length:0,t&Rt){var _=r,v=u;r=u=i}var x=c?i:Ai(n),A=[n,t,e,r,u,_,v,o,a,f];if(x&&Cc(A,x),n=A[0],t=A[1],e=A[2],r=A[3],u=A[4],f=A[9]=A[9]===i?c?0:n.length:an(A[9]-d,0),!f&&t&(Hn|bt)&&(t&=-25),!t||t==yn)var T=sc(n,t,e);else t==Hn||t==bt?T=oc(n,t,f):(t==kn||t==(yn|kn))&&!u.length?T=ac(n,t,e,r):T=sr.apply(i,A);var M=x?cs:Ks;return Gs(M(T,A),n,t)}function Os(n,t,e,r){return n===i||Qn(n,zt[e])&&!z.call(r,e)?t:n}function Ws(n,t,e,r,u,o){return X(n)&&X(t)&&(o.set(t,n),er(n,t,i,Ws,o),o.delete(t)),n}function lc(n){return Ae(n)?i:n}function Ms(n,t,e,r,u,o){var a=e&Pn,f=n.length,c=t.length;if(f!=c&&!(a&&c>f))return!1;var d=o.get(n),_=o.get(t);if(d&&_)return d==t&&_==n;var v=-1,x=!0,A=e&gt?new Lt:i;for(o.set(n,t),o.set(t,n);++v<f;){var T=n[v],M=t[v];if(r)var P=a?r(M,T,v,t,n,o):r(T,M,v,n,t,o);if(P!==i){if(P)continue;x=!1;break}if(A){if(!zr(t,function(D,B){if(!fe(A,B)&&(T===D||u(T,D,e,r,o)))return A.push(B)})){x=!1;break}}else if(!(T===M||u(T,M,e,r,o))){x=!1;break}}return o.delete(n),o.delete(t),x}function cc(n,t,e,r,u,o,a){switch(e){case Nt:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case ae:return!(n.byteLength!=t.byteLength||!o(new ze(n),new ze(t)));case ee:case re:case ie:return Qn(+n,+t);case Ie:return n.name==t.name&&n.message==t.message;case ue:case se:return n==t+"";case Jn:var f=Xr;case Zn:var c=r&Pn;if(f||(f=Ne),n.size!=t.size&&!c)return!1;var d=a.get(n);if(d)return d==t;r|=gt,a.set(n,t);var _=Ms(f(n),f(t),r,u,o,a);return a.delete(n),_;case Oe:if(pe)return pe.call(n)==pe.call(t)}return!1}function hc(n,t,e,r,u,o){var a=e&Pn,f=xi(n),c=f.length,d=xi(t),_=d.length;if(c!=_&&!a)return!1;for(var v=c;v--;){var x=f[v];if(!(a?x in t:z.call(t,x)))return!1}var A=o.get(n),T=o.get(t);if(A&&T)return A==t&&T==n;var M=!0;o.set(n,t),o.set(t,n);for(var P=a;++v<c;){x=f[v];var D=n[x],B=t[x];if(r)var Wn=a?r(B,D,x,t,n,o):r(D,B,x,n,t,o);if(!(Wn===i?D===B||u(D,B,e,r,o):Wn)){M=!1;break}P||(P=x=="constructor")}if(M&&!P){var mn=n.constructor,Mn=t.constructor;mn!=Mn&&"constructor"in n&&"constructor"in t&&!(typeof mn=="function"&&mn instanceof mn&&typeof Mn=="function"&&Mn instanceof Mn)&&(M=!1)}return o.delete(n),o.delete(t),M}function at(n){return Ei($s(n,i,Ys),n+"")}function xi(n){return ns(n,fn,bi)}function Si(n){return ns(n,Cn,Fs)}var Ai=Xe?function(n){return Xe.get(n)}:Ki;function lr(n){for(var t=n.name+"",e=kt[t],r=z.call(kt,t)?e.length:0;r--;){var u=e[r],o=u.func;if(o==null||o==n)return u.name}return t}function Xt(n){var t=z.call(s,"placeholder")?s:n;return t.placeholder}function b(){var n=s.iteratee||$i;return n=n===$i?rs:n,arguments.length?n(arguments[0],arguments[1]):n}function cr(n,t){var e=n.__data__;return yc(t)?e[typeof t=="string"?"string":"hash"]:e.map}function Ci(n){for(var t=fn(n),e=t.length;e--;){var r=t[e],u=n[r];t[e]=[r,u,Ns(u)]}return t}function Mt(n,t){var e=Af(n,t);return es(e)?e:i}function gc(n){var t=z.call(n,Et),e=n[Et];try{n[Et]=i;var r=!0}catch{}var u=Ke.call(n);return r&&(t?n[Et]=e:delete n[Et]),u}var bi=Vr?function(n){return n==null?[]:(n=k(n),dt(Vr(n),function(t){return qu.call(n,t)}))}:Gi,Fs=Vr?function(n){for(var t=[];n;)_t(t,bi(n)),n=He(n);return t}:Gi,gn=vn;(jr&&gn(new jr(new ArrayBuffer(1)))!=Nt||ce&&gn(new ce)!=Jn||ni&&gn(ni.resolve())!=Qi||Ht&&gn(new Ht)!=Zn||he&&gn(new he)!=oe)&&(gn=function(n){var t=vn(n),e=t==rt?n.constructor:i,r=e?Ft(e):"";if(r)switch(r){case Yf:return Nt;case Xf:return Jn;case Qf:return Qi;case Vf:return Zn;case jf:return oe}return t});function pc(n,t,e){for(var r=-1,u=e.length;++r<u;){var o=e[r],a=o.size;switch(o.type){case"drop":n+=a;break;case"dropRight":t-=a;break;case"take":t=hn(t,n+a);break;case"takeRight":n=an(n,t-a);break}}return{start:n,end:t}}function dc(n){var t=n.match(ya);return t?t[1].split(xa):[]}function Us(n,t,e){t=xt(t,n);for(var r=-1,u=t.length,o=!1;++r<u;){var a=et(t[r]);if(!(o=n!=null&&e(n,a)))break;n=n[a]}return o||++r!=u?o:(u=n==null?0:n.length,!!u&&wr(u)&&ft(a,u)&&(L(n)||Ut(n)))}function _c(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&z.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Ds(n){return typeof n.constructor=="function"&&!xe(n)?Jt(He(n)):{}}function vc(n,t,e){var r=n.constructor;switch(t){case ae:return wi(n);case ee:case re:return new r(+n);case Nt:return nc(n,e);case Cr:case br:case Rr:case Tr:case Pr:case Er:case Ir:case Lr:case Or:return ms(n,e);case Jn:return new r;case ie:case se:return new r(n);case ue:return tc(n);case Zn:return new r;case Oe:return ec(n)}}function wc(n,t){var e=t.length;if(!e)return n;var r=e-1;return t[r]=(e>1?"& ":"")+t[r],t=t.join(e>2?", ":" "),n.replace(ma,`{
9
+ /* [wrapped with `+t+`] */
10
+ `)}function mc(n){return L(n)||Ut(n)||!!(Ku&&n&&n[Ku])}function ft(n,t){var e=typeof n;return t=t??pt,!!t&&(e=="number"||e!="symbol"&&Ia.test(n))&&n>-1&&n%1==0&&n<t}function wn(n,t,e){if(!X(e))return!1;var r=typeof t;return(r=="number"?An(e)&&ft(t,e.length):r=="string"&&t in e)?Qn(e[t],n):!1}function Ri(n,t){if(L(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||On(n)?!0:da.test(n)||!pa.test(n)||t!=null&&n in k(t)}function yc(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}function Ti(n){var t=lr(n),e=s[t];if(typeof e!="function"||!(t in N.prototype))return!1;if(n===e)return!0;var r=Ai(e);return!!r&&n===r[0]}function xc(n){return!!Nu&&Nu in n}var Sc=$e?lt:zi;function xe(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||zt;return n===e}function Ns(n){return n===n&&!X(n)}function Bs(n,t){return function(e){return e==null?!1:e[n]===t&&(t!==i||n in k(e))}}function Ac(n){var t=_r(n,function(r){return e.size===rn&&e.clear(),r}),e=t.cache;return t}function Cc(n,t){var e=n[1],r=t[1],u=e|r,o=u<(yn|xn|F),a=r==F&&e==Hn||r==F&&e==en&&n[7].length<=t[8]||r==(F|en)&&t[7].length<=t[8]&&e==Hn;if(!(o||a))return n;r&yn&&(n[2]=t[2],u|=e&yn?0:Te);var f=t[3];if(f){var c=n[3];n[3]=c?xs(c,f,t[4]):f,n[4]=c?vt(n[3],Rn):t[4]}return f=t[5],f&&(c=n[5],n[5]=c?Ss(c,f,t[6]):f,n[6]=c?vt(n[5],Rn):t[6]),f=t[7],f&&(n[7]=f),r&F&&(n[8]=n[8]==null?t[8]:hn(n[8],t[8])),n[9]==null&&(n[9]=t[9]),n[0]=t[0],n[1]=u,n}function bc(n){var t=[];if(n!=null)for(var e in k(n))t.push(e);return t}function Rc(n){return Ke.call(n)}function $s(n,t,e){return t=an(t===i?n.length-1:t,0),function(){for(var r=arguments,u=-1,o=an(r.length-t,0),a=h(o);++u<o;)a[u]=r[t+u];u=-1;for(var f=h(t+1);++u<t;)f[u]=r[u];return f[t]=e(a),En(n,this,f)}}function qs(n,t){return t.length<2?n:Wt(n,Kn(t,0,-1))}function Tc(n,t){for(var e=n.length,r=hn(t.length,e),u=Sn(n);r--;){var o=t[r];n[r]=ft(o,e)?u[o]:i}return n}function Pi(n,t){if(!(t==="constructor"&&typeof n[t]=="function")&&t!="__proto__")return n[t]}var Ks=zs(cs),Se=Kf||function(n,t){return ln.setTimeout(n,t)},Ei=zs(Xl);function Gs(n,t,e){var r=t+"";return Ei(n,wc(r,Pc(dc(r),e)))}function zs(n){var t=0,e=0;return function(){var r=kf(),u=Q-(r-e);if(e=r,u>0){if(++t>=Un)return arguments[0]}else t=0;return n.apply(i,arguments)}}function hr(n,t){var e=-1,r=n.length,u=r-1;for(t=t===i?r:t;++e<t;){var o=ci(e,u),a=n[o];n[o]=n[e],n[e]=a}return n.length=t,n}var Hs=Ac(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(_a,function(e,r,u,o){t.push(u?o.replace(Ca,"$1"):r||e)}),t});function et(n){if(typeof n=="string"||On(n))return n;var t=n+"";return t=="0"&&1/n==-Tt?"-0":t}function Ft(n){if(n!=null){try{return qe.call(n)}catch{}try{return n+""}catch{}}return""}function Pc(n,t){return Nn(na,function(e){var r="_."+e[0];t&e[1]&&!Ue(n,r)&&n.push(r)}),n.sort()}function ks(n){if(n instanceof N)return n.clone();var t=new $n(n.__wrapped__,n.__chain__);return t.__actions__=Sn(n.__actions__),t.__index__=n.__index__,t.__values__=n.__values__,t}function Ec(n,t,e){(e?wn(n,t,e):t===i)?t=1:t=an(W(t),0);var r=n==null?0:n.length;if(!r||t<1)return[];for(var u=0,o=0,a=h(Ze(r/t));u<r;)a[o++]=Kn(n,u,u+=t);return a}function Ic(n){for(var t=-1,e=n==null?0:n.length,r=0,u=[];++t<e;){var o=n[t];o&&(u[r++]=o)}return u}function Lc(){var n=arguments.length;if(!n)return[];for(var t=h(n-1),e=arguments[0],r=n;r--;)t[r-1]=arguments[r];return _t(L(e)?Sn(e):[e],cn(t,1))}var Oc=U(function(n,t){return j(n)?_e(n,cn(t,1,j,!0)):[]}),Wc=U(function(n,t){var e=Gn(t);return j(e)&&(e=i),j(n)?_e(n,cn(t,1,j,!0),b(e,2)):[]}),Mc=U(function(n,t){var e=Gn(t);return j(e)&&(e=i),j(n)?_e(n,cn(t,1,j,!0),i,e):[]});function Fc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),Kn(n,t<0?0:t,r)):[]}function Uc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),t=r-t,Kn(n,0,t<0?0:t)):[]}function Dc(n,t){return n&&n.length?ir(n,b(t,3),!0,!0):[]}function Nc(n,t){return n&&n.length?ir(n,b(t,3),!0):[]}function Bc(n,t,e,r){var u=n==null?0:n.length;return u?(e&&typeof e!="number"&&wn(n,t,e)&&(e=0,r=u),Ll(n,t,e,r)):[]}function Js(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=e==null?0:W(e);return u<0&&(u=an(r+u,0)),De(n,b(t,3),u)}function Zs(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=r-1;return e!==i&&(u=W(e),u=e<0?an(r+u,0):hn(u,r-1)),De(n,b(t,3),u,!0)}function Ys(n){var t=n==null?0:n.length;return t?cn(n,1):[]}function $c(n){var t=n==null?0:n.length;return t?cn(n,Tt):[]}function qc(n,t){var e=n==null?0:n.length;return e?(t=t===i?1:W(t),cn(n,t)):[]}function Kc(n){for(var t=-1,e=n==null?0:n.length,r={};++t<e;){var u=n[t];r[u[0]]=u[1]}return r}function Xs(n){return n&&n.length?n[0]:i}function Gc(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=e==null?0:W(e);return u<0&&(u=an(r+u,0)),$t(n,t,u)}function zc(n){var t=n==null?0:n.length;return t?Kn(n,0,-1):[]}var Hc=U(function(n){var t=Y(n,_i);return t.length&&t[0]===n[0]?si(t):[]}),kc=U(function(n){var t=Gn(n),e=Y(n,_i);return t===Gn(e)?t=i:e.pop(),e.length&&e[0]===n[0]?si(e,b(t,2)):[]}),Jc=U(function(n){var t=Gn(n),e=Y(n,_i);return t=typeof t=="function"?t:i,t&&e.pop(),e.length&&e[0]===n[0]?si(e,i,t):[]});function Zc(n,t){return n==null?"":zf.call(n,t)}function Gn(n){var t=n==null?0:n.length;return t?n[t-1]:i}function Yc(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=r;return e!==i&&(u=W(e),u=u<0?an(r+u,0):hn(u,r-1)),t===t?Pf(n,t,u):De(n,Iu,u,!0)}function Xc(n,t){return n&&n.length?os(n,W(t)):i}var Qc=U(Qs);function Qs(n,t){return n&&n.length&&t&&t.length?li(n,t):n}function Vc(n,t,e){return n&&n.length&&t&&t.length?li(n,t,b(e,2)):n}function jc(n,t,e){return n&&n.length&&t&&t.length?li(n,t,i,e):n}var nh=at(function(n,t){var e=n==null?0:n.length,r=ei(n,t);return ls(n,Y(t,function(u){return ft(u,e)?+u:u}).sort(ys)),r});function th(n,t){var e=[];if(!(n&&n.length))return e;var r=-1,u=[],o=n.length;for(t=b(t,3);++r<o;){var a=n[r];t(a,r,n)&&(e.push(a),u.push(r))}return ls(n,u),e}function Ii(n){return n==null?n:Zf.call(n)}function eh(n,t,e){var r=n==null?0:n.length;return r?(e&&typeof e!="number"&&wn(n,t,e)?(t=0,e=r):(t=t==null?0:W(t),e=e===i?r:W(e)),Kn(n,t,e)):[]}function rh(n,t){return rr(n,t)}function ih(n,t,e){return gi(n,t,b(e,2))}function uh(n,t){var e=n==null?0:n.length;if(e){var r=rr(n,t);if(r<e&&Qn(n[r],t))return r}return-1}function sh(n,t){return rr(n,t,!0)}function oh(n,t,e){return gi(n,t,b(e,2),!0)}function ah(n,t){var e=n==null?0:n.length;if(e){var r=rr(n,t,!0)-1;if(Qn(n[r],t))return r}return-1}function fh(n){return n&&n.length?hs(n):[]}function lh(n,t){return n&&n.length?hs(n,b(t,2)):[]}function ch(n){var t=n==null?0:n.length;return t?Kn(n,1,t):[]}function hh(n,t,e){return n&&n.length?(t=e||t===i?1:W(t),Kn(n,0,t<0?0:t)):[]}function gh(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),t=r-t,Kn(n,t<0?0:t,r)):[]}function ph(n,t){return n&&n.length?ir(n,b(t,3),!1,!0):[]}function dh(n,t){return n&&n.length?ir(n,b(t,3)):[]}var _h=U(function(n){return yt(cn(n,1,j,!0))}),vh=U(function(n){var t=Gn(n);return j(t)&&(t=i),yt(cn(n,1,j,!0),b(t,2))}),wh=U(function(n){var t=Gn(n);return t=typeof t=="function"?t:i,yt(cn(n,1,j,!0),i,t)});function mh(n){return n&&n.length?yt(n):[]}function yh(n,t){return n&&n.length?yt(n,b(t,2)):[]}function xh(n,t){return t=typeof t=="function"?t:i,n&&n.length?yt(n,i,t):[]}function Li(n){if(!(n&&n.length))return[];var t=0;return n=dt(n,function(e){if(j(e))return t=an(e.length,t),!0}),Zr(t,function(e){return Y(n,Hr(e))})}function Vs(n,t){if(!(n&&n.length))return[];var e=Li(n);return t==null?e:Y(e,function(r){return En(t,i,r)})}var Sh=U(function(n,t){return j(n)?_e(n,t):[]}),Ah=U(function(n){return di(dt(n,j))}),Ch=U(function(n){var t=Gn(n);return j(t)&&(t=i),di(dt(n,j),b(t,2))}),bh=U(function(n){var t=Gn(n);return t=typeof t=="function"?t:i,di(dt(n,j),i,t)}),Rh=U(Li);function Th(n,t){return _s(n||[],t||[],de)}function Ph(n,t){return _s(n||[],t||[],me)}var Eh=U(function(n){var t=n.length,e=t>1?n[t-1]:i;return e=typeof e=="function"?(n.pop(),e):i,Vs(n,e)});function js(n){var t=s(n);return t.__chain__=!0,t}function Ih(n,t){return t(n),n}function gr(n,t){return t(n)}var Lh=at(function(n){var t=n.length,e=t?n[0]:0,r=this.__wrapped__,u=function(o){return ei(o,n)};return t>1||this.__actions__.length||!(r instanceof N)||!ft(e)?this.thru(u):(r=r.slice(e,+e+(t?1:0)),r.__actions__.push({func:gr,args:[u],thisArg:i}),new $n(r,this.__chain__).thru(function(o){return t&&!o.length&&o.push(i),o}))});function Oh(){return js(this)}function Wh(){return new $n(this.value(),this.__chain__)}function Mh(){this.__values__===i&&(this.__values__=go(this.value()));var n=this.__index__>=this.__values__.length,t=n?i:this.__values__[this.__index__++];return{done:n,value:t}}function Fh(){return this}function Uh(n){for(var t,e=this;e instanceof Ve;){var r=ks(e);r.__index__=0,r.__values__=i,t?u.__wrapped__=r:t=r;var u=r;e=e.__wrapped__}return u.__wrapped__=n,t}function Dh(){var n=this.__wrapped__;if(n instanceof N){var t=n;return this.__actions__.length&&(t=new N(this)),t=t.reverse(),t.__actions__.push({func:gr,args:[Ii],thisArg:i}),new $n(t,this.__chain__)}return this.thru(Ii)}function Nh(){return ds(this.__wrapped__,this.__actions__)}var Bh=ur(function(n,t,e){z.call(n,e)?++n[e]:st(n,e,1)});function $h(n,t,e){var r=L(n)?Pu:Il;return e&&wn(n,t,e)&&(t=i),r(n,b(t,3))}function qh(n,t){var e=L(n)?dt:Vu;return e(n,b(t,3))}var Kh=Rs(Js),Gh=Rs(Zs);function zh(n,t){return cn(pr(n,t),1)}function Hh(n,t){return cn(pr(n,t),Tt)}function kh(n,t,e){return e=e===i?1:W(e),cn(pr(n,t),e)}function no(n,t){var e=L(n)?Nn:mt;return e(n,b(t,3))}function to(n,t){var e=L(n)?cf:Qu;return e(n,b(t,3))}var Jh=ur(function(n,t,e){z.call(n,e)?n[e].push(t):st(n,e,[t])});function Zh(n,t,e,r){n=An(n)?n:Vt(n),e=e&&!r?W(e):0;var u=n.length;return e<0&&(e=an(u+e,0)),mr(n)?e<=u&&n.indexOf(t,e)>-1:!!u&&$t(n,t,e)>-1}var Yh=U(function(n,t,e){var r=-1,u=typeof t=="function",o=An(n)?h(n.length):[];return mt(n,function(a){o[++r]=u?En(t,a,e):ve(a,t,e)}),o}),Xh=ur(function(n,t,e){st(n,e,t)});function pr(n,t){var e=L(n)?Y:is;return e(n,b(t,3))}function Qh(n,t,e,r){return n==null?[]:(L(t)||(t=t==null?[]:[t]),e=r?i:e,L(e)||(e=e==null?[]:[e]),as(n,t,e))}var Vh=ur(function(n,t,e){n[e?0:1].push(t)},function(){return[[],[]]});function jh(n,t,e){var r=L(n)?Gr:Ou,u=arguments.length<3;return r(n,b(t,4),e,u,mt)}function ng(n,t,e){var r=L(n)?hf:Ou,u=arguments.length<3;return r(n,b(t,4),e,u,Qu)}function tg(n,t){var e=L(n)?dt:Vu;return e(n,vr(b(t,3)))}function eg(n){var t=L(n)?Ju:Zl;return t(n)}function rg(n,t,e){(e?wn(n,t,e):t===i)?t=1:t=W(t);var r=L(n)?bl:Yl;return r(n,t)}function ig(n){var t=L(n)?Rl:Ql;return t(n)}function ug(n){if(n==null)return 0;if(An(n))return mr(n)?Kt(n):n.length;var t=gn(n);return t==Jn||t==Zn?n.size:ai(n).length}function sg(n,t,e){var r=L(n)?zr:Vl;return e&&wn(n,t,e)&&(t=i),r(n,b(t,3))}var og=U(function(n,t){if(n==null)return[];var e=t.length;return e>1&&wn(n,t[0],t[1])?t=[]:e>2&&wn(t[0],t[1],t[2])&&(t=[t[0]]),as(n,cn(t,1),[])}),dr=qf||function(){return ln.Date.now()};function ag(n,t){if(typeof t!="function")throw new Bn(C);return n=W(n),function(){if(--n<1)return t.apply(this,arguments)}}function eo(n,t,e){return t=e?i:t,t=n&&t==null?n.length:t,ot(n,F,i,i,i,i,t)}function ro(n,t){var e;if(typeof t!="function")throw new Bn(C);return n=W(n),function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=i),e}}var Oi=U(function(n,t,e){var r=yn;if(e.length){var u=vt(e,Xt(Oi));r|=kn}return ot(n,r,t,e,u)}),io=U(function(n,t,e){var r=yn|xn;if(e.length){var u=vt(e,Xt(io));r|=kn}return ot(t,r,n,e,u)});function uo(n,t,e){t=e?i:t;var r=ot(n,Hn,i,i,i,i,i,t);return r.placeholder=uo.placeholder,r}function so(n,t,e){t=e?i:t;var r=ot(n,bt,i,i,i,i,i,t);return r.placeholder=so.placeholder,r}function oo(n,t,e){var r,u,o,a,f,c,d=0,_=!1,v=!1,x=!0;if(typeof n!="function")throw new Bn(C);t=zn(t)||0,X(e)&&(_=!!e.leading,v="maxWait"in e,o=v?an(zn(e.maxWait)||0,t):o,x="trailing"in e?!!e.trailing:x);function A(nn){var Vn=r,ht=u;return r=u=i,d=nn,a=n.apply(ht,Vn),a}function T(nn){return d=nn,f=Se(D,t),_?A(nn):a}function M(nn){var Vn=nn-c,ht=nn-d,To=t-Vn;return v?hn(To,o-ht):To}function P(nn){var Vn=nn-c,ht=nn-d;return c===i||Vn>=t||Vn<0||v&&ht>=o}function D(){var nn=dr();if(P(nn))return B(nn);f=Se(D,M(nn))}function B(nn){return f=i,x&&r?A(nn):(r=u=i,a)}function Wn(){f!==i&&vs(f),d=0,r=c=u=f=i}function mn(){return f===i?a:B(dr())}function Mn(){var nn=dr(),Vn=P(nn);if(r=arguments,u=this,c=nn,Vn){if(f===i)return T(c);if(v)return vs(f),f=Se(D,t),A(c)}return f===i&&(f=Se(D,t)),a}return Mn.cancel=Wn,Mn.flush=mn,Mn}var fg=U(function(n,t){return Xu(n,1,t)}),lg=U(function(n,t,e){return Xu(n,zn(t)||0,e)});function cg(n){return ot(n,H)}function _r(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new Bn(C);var e=function(){var r=arguments,u=t?t.apply(this,r):r[0],o=e.cache;if(o.has(u))return o.get(u);var a=n.apply(this,r);return e.cache=o.set(u,a)||o,a};return e.cache=new(_r.Cache||ut),e}_r.Cache=ut;function vr(n){if(typeof n!="function")throw new Bn(C);return function(){var t=arguments;switch(t.length){case 0:return!n.call(this);case 1:return!n.call(this,t[0]);case 2:return!n.call(this,t[0],t[1]);case 3:return!n.call(this,t[0],t[1],t[2])}return!n.apply(this,t)}}function hg(n){return ro(2,n)}var gg=jl(function(n,t){t=t.length==1&&L(t[0])?Y(t[0],In(b())):Y(cn(t,1),In(b()));var e=t.length;return U(function(r){for(var u=-1,o=hn(r.length,e);++u<o;)r[u]=t[u].call(this,r[u]);return En(n,this,r)})}),Wi=U(function(n,t){var e=vt(t,Xt(Wi));return ot(n,kn,i,t,e)}),ao=U(function(n,t){var e=vt(t,Xt(ao));return ot(n,Rt,i,t,e)}),pg=at(function(n,t){return ot(n,en,i,i,i,t)});function dg(n,t){if(typeof n!="function")throw new Bn(C);return t=t===i?t:W(t),U(n,t)}function _g(n,t){if(typeof n!="function")throw new Bn(C);return t=t==null?0:an(W(t),0),U(function(e){var r=e[t],u=St(e,0,t);return r&&_t(u,r),En(n,this,u)})}function vg(n,t,e){var r=!0,u=!0;if(typeof n!="function")throw new Bn(C);return X(e)&&(r="leading"in e?!!e.leading:r,u="trailing"in e?!!e.trailing:u),oo(n,t,{leading:r,maxWait:t,trailing:u})}function wg(n){return eo(n,1)}function mg(n,t){return Wi(vi(t),n)}function yg(){if(!arguments.length)return[];var n=arguments[0];return L(n)?n:[n]}function xg(n){return qn(n,dn)}function Sg(n,t){return t=typeof t=="function"?t:i,qn(n,dn,t)}function Ag(n){return qn(n,un|dn)}function Cg(n,t){return t=typeof t=="function"?t:i,qn(n,un|dn,t)}function bg(n,t){return t==null||Yu(n,t,fn(t))}function Qn(n,t){return n===t||n!==n&&t!==t}var Rg=fr(ui),Tg=fr(function(n,t){return n>=t}),Ut=ts(function(){return arguments}())?ts:function(n){return V(n)&&z.call(n,"callee")&&!qu.call(n,"callee")},L=h.isArray,Pg=Su?In(Su):Ul;function An(n){return n!=null&&wr(n.length)&&!lt(n)}function j(n){return V(n)&&An(n)}function Eg(n){return n===!0||n===!1||V(n)&&vn(n)==ee}var At=Gf||zi,Ig=Au?In(Au):Dl;function Lg(n){return V(n)&&n.nodeType===1&&!Ae(n)}function Og(n){if(n==null)return!0;if(An(n)&&(L(n)||typeof n=="string"||typeof n.splice=="function"||At(n)||Qt(n)||Ut(n)))return!n.length;var t=gn(n);if(t==Jn||t==Zn)return!n.size;if(xe(n))return!ai(n).length;for(var e in n)if(z.call(n,e))return!1;return!0}function Wg(n,t){return we(n,t)}function Mg(n,t,e){e=typeof e=="function"?e:i;var r=e?e(n,t):i;return r===i?we(n,t,i,e):!!r}function Mi(n){if(!V(n))return!1;var t=vn(n);return t==Ie||t==ea||typeof n.message=="string"&&typeof n.name=="string"&&!Ae(n)}function Fg(n){return typeof n=="number"&&Gu(n)}function lt(n){if(!X(n))return!1;var t=vn(n);return t==Le||t==Xi||t==ta||t==ia}function fo(n){return typeof n=="number"&&n==W(n)}function wr(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=pt}function X(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function V(n){return n!=null&&typeof n=="object"}var lo=Cu?In(Cu):Bl;function Ug(n,t){return n===t||oi(n,t,Ci(t))}function Dg(n,t,e){return e=typeof e=="function"?e:i,oi(n,t,Ci(t),e)}function Ng(n){return co(n)&&n!=+n}function Bg(n){if(Sc(n))throw new I(R);return es(n)}function $g(n){return n===null}function qg(n){return n==null}function co(n){return typeof n=="number"||V(n)&&vn(n)==ie}function Ae(n){if(!V(n)||vn(n)!=rt)return!1;var t=He(n);if(t===null)return!0;var e=z.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&qe.call(e)==Df}var Fi=bu?In(bu):$l;function Kg(n){return fo(n)&&n>=-pt&&n<=pt}var ho=Ru?In(Ru):ql;function mr(n){return typeof n=="string"||!L(n)&&V(n)&&vn(n)==se}function On(n){return typeof n=="symbol"||V(n)&&vn(n)==Oe}var Qt=Tu?In(Tu):Kl;function Gg(n){return n===i}function zg(n){return V(n)&&gn(n)==oe}function Hg(n){return V(n)&&vn(n)==sa}var kg=fr(fi),Jg=fr(function(n,t){return n<=t});function go(n){if(!n)return[];if(An(n))return mr(n)?Yn(n):Sn(n);if(le&&n[le])return bf(n[le]());var t=gn(n),e=t==Jn?Xr:t==Zn?Ne:Vt;return e(n)}function ct(n){if(!n)return n===0?n:0;if(n=zn(n),n===Tt||n===-Tt){var t=n<0?-1:1;return t*Qo}return n===n?n:0}function W(n){var t=ct(n),e=t%1;return t===t?e?t-e:t:0}function po(n){return n?Ot(W(n),0,jn):0}function zn(n){if(typeof n=="number")return n;if(On(n))return Pe;if(X(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=X(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=Wu(n);var e=Ta.test(n);return e||Ea.test(n)?af(n.slice(2),e?2:8):Ra.test(n)?Pe:+n}function _o(n){return tt(n,Cn(n))}function Zg(n){return n?Ot(W(n),-pt,pt):n===0?n:0}function G(n){return n==null?"":Ln(n)}var Yg=Zt(function(n,t){if(xe(t)||An(t)){tt(t,fn(t),n);return}for(var e in t)z.call(t,e)&&de(n,e,t[e])}),vo=Zt(function(n,t){tt(t,Cn(t),n)}),yr=Zt(function(n,t,e,r){tt(t,Cn(t),n,r)}),Xg=Zt(function(n,t,e,r){tt(t,fn(t),n,r)}),Qg=at(ei);function Vg(n,t){var e=Jt(n);return t==null?e:Zu(e,t)}var jg=U(function(n,t){n=k(n);var e=-1,r=t.length,u=r>2?t[2]:i;for(u&&wn(t[0],t[1],u)&&(r=1);++e<r;)for(var o=t[e],a=Cn(o),f=-1,c=a.length;++f<c;){var d=a[f],_=n[d];(_===i||Qn(_,zt[d])&&!z.call(n,d))&&(n[d]=o[d])}return n}),np=U(function(n){return n.push(i,Ws),En(wo,i,n)});function tp(n,t){return Eu(n,b(t,3),nt)}function ep(n,t){return Eu(n,b(t,3),ii)}function rp(n,t){return n==null?n:ri(n,b(t,3),Cn)}function ip(n,t){return n==null?n:ju(n,b(t,3),Cn)}function up(n,t){return n&&nt(n,b(t,3))}function sp(n,t){return n&&ii(n,b(t,3))}function op(n){return n==null?[]:tr(n,fn(n))}function ap(n){return n==null?[]:tr(n,Cn(n))}function Ui(n,t,e){var r=n==null?i:Wt(n,t);return r===i?e:r}function fp(n,t){return n!=null&&Us(n,t,Ol)}function Di(n,t){return n!=null&&Us(n,t,Wl)}var lp=Ps(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=Ke.call(t)),n[t]=e},Bi(bn)),cp=Ps(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=Ke.call(t)),z.call(n,t)?n[t].push(e):n[t]=[e]},b),hp=U(ve);function fn(n){return An(n)?ku(n):ai(n)}function Cn(n){return An(n)?ku(n,!0):Gl(n)}function gp(n,t){var e={};return t=b(t,3),nt(n,function(r,u,o){st(e,t(r,u,o),r)}),e}function pp(n,t){var e={};return t=b(t,3),nt(n,function(r,u,o){st(e,u,t(r,u,o))}),e}var dp=Zt(function(n,t,e){er(n,t,e)}),wo=Zt(function(n,t,e,r){er(n,t,e,r)}),_p=at(function(n,t){var e={};if(n==null)return e;var r=!1;t=Y(t,function(o){return o=xt(o,n),r||(r=o.length>1),o}),tt(n,Si(n),e),r&&(e=qn(e,un|Tn|dn,lc));for(var u=t.length;u--;)pi(e,t[u]);return e});function vp(n,t){return mo(n,vr(b(t)))}var wp=at(function(n,t){return n==null?{}:Hl(n,t)});function mo(n,t){if(n==null)return{};var e=Y(Si(n),function(r){return[r]});return t=b(t),fs(n,e,function(r,u){return t(r,u[0])})}function mp(n,t,e){t=xt(t,n);var r=-1,u=t.length;for(u||(u=1,n=i);++r<u;){var o=n==null?i:n[et(t[r])];o===i&&(r=u,o=e),n=lt(o)?o.call(n):o}return n}function yp(n,t,e){return n==null?n:me(n,t,e)}function xp(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:me(n,t,e,r)}var yo=Ls(fn),xo=Ls(Cn);function Sp(n,t,e){var r=L(n),u=r||At(n)||Qt(n);if(t=b(t,4),e==null){var o=n&&n.constructor;u?e=r?new o:[]:X(n)?e=lt(o)?Jt(He(n)):{}:e={}}return(u?Nn:nt)(n,function(a,f,c){return t(e,a,f,c)}),e}function Ap(n,t){return n==null?!0:pi(n,t)}function Cp(n,t,e){return n==null?n:ps(n,t,vi(e))}function bp(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:ps(n,t,vi(e),r)}function Vt(n){return n==null?[]:Yr(n,fn(n))}function Rp(n){return n==null?[]:Yr(n,Cn(n))}function Tp(n,t,e){return e===i&&(e=t,t=i),e!==i&&(e=zn(e),e=e===e?e:0),t!==i&&(t=zn(t),t=t===t?t:0),Ot(zn(n),t,e)}function Pp(n,t,e){return t=ct(t),e===i?(e=t,t=0):e=ct(e),n=zn(n),Ml(n,t,e)}function Ep(n,t,e){if(e&&typeof e!="boolean"&&wn(n,t,e)&&(t=e=i),e===i&&(typeof t=="boolean"?(e=t,t=i):typeof n=="boolean"&&(e=n,n=i)),n===i&&t===i?(n=0,t=1):(n=ct(n),t===i?(t=n,n=0):t=ct(t)),n>t){var r=n;n=t,t=r}if(e||n%1||t%1){var u=zu();return hn(n+u*(t-n+of("1e-"+((u+"").length-1))),t)}return ci(n,t)}var Ip=Yt(function(n,t,e){return t=t.toLowerCase(),n+(e?So(t):t)});function So(n){return Ni(G(n).toLowerCase())}function Ao(n){return n=G(n),n&&n.replace(La,yf).replace(Xa,"")}function Lp(n,t,e){n=G(n),t=Ln(t);var r=n.length;e=e===i?r:Ot(W(e),0,r);var u=e;return e-=t.length,e>=0&&n.slice(e,u)==t}function Op(n){return n=G(n),n&&ca.test(n)?n.replace(ji,xf):n}function Wp(n){return n=G(n),n&&va.test(n)?n.replace(Wr,"\\$&"):n}var Mp=Yt(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()}),Fp=Yt(function(n,t,e){return n+(e?" ":"")+t.toLowerCase()}),Up=bs("toLowerCase");function Dp(n,t,e){n=G(n),t=W(t);var r=t?Kt(n):0;if(!t||r>=t)return n;var u=(t-r)/2;return ar(Ye(u),e)+n+ar(Ze(u),e)}function Np(n,t,e){n=G(n),t=W(t);var r=t?Kt(n):0;return t&&r<t?n+ar(t-r,e):n}function Bp(n,t,e){n=G(n),t=W(t);var r=t?Kt(n):0;return t&&r<t?ar(t-r,e)+n:n}function $p(n,t,e){return e||t==null?t=0:t&&(t=+t),Jf(G(n).replace(Mr,""),t||0)}function qp(n,t,e){return(e?wn(n,t,e):t===i)?t=1:t=W(t),hi(G(n),t)}function Kp(){var n=arguments,t=G(n[0]);return n.length<3?t:t.replace(n[1],n[2])}var Gp=Yt(function(n,t,e){return n+(e?"_":"")+t.toLowerCase()});function zp(n,t,e){return e&&typeof e!="number"&&wn(n,t,e)&&(t=e=i),e=e===i?jn:e>>>0,e?(n=G(n),n&&(typeof t=="string"||t!=null&&!Fi(t))&&(t=Ln(t),!t&&qt(n))?St(Yn(n),0,e):n.split(t,e)):[]}var Hp=Yt(function(n,t,e){return n+(e?" ":"")+Ni(t)});function kp(n,t,e){return n=G(n),e=e==null?0:Ot(W(e),0,n.length),t=Ln(t),n.slice(e,e+t.length)==t}function Jp(n,t,e){var r=s.templateSettings;e&&wn(n,t,e)&&(t=i),n=G(n),t=yr({},t,r,Os);var u=yr({},t.imports,r.imports,Os),o=fn(u),a=Yr(u,o),f,c,d=0,_=t.interpolate||We,v="__p += '",x=Qr((t.escape||We).source+"|"+_.source+"|"+(_===nu?ba:We).source+"|"+(t.evaluate||We).source+"|$","g"),A="//# sourceURL="+(z.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++tf+"]")+`
11
+ `;n.replace(x,function(P,D,B,Wn,mn,Mn){return B||(B=Wn),v+=n.slice(d,Mn).replace(Oa,Sf),D&&(f=!0,v+=`' +
12
+ __e(`+D+`) +
13
+ '`),mn&&(c=!0,v+=`';
14
+ `+mn+`;
15
+ __p += '`),B&&(v+=`' +
16
+ ((__t = (`+B+`)) == null ? '' : __t) +
17
+ '`),d=Mn+P.length,P}),v+=`';
18
+ `;var T=z.call(t,"variable")&&t.variable;if(!T)v=`with (obj) {
19
+ `+v+`
32
20
  }
33
- `;else if(cf.test(D))throw new F(m);T=(b?T.replace(Gl,""):T).replace(Kl,"$1").replace(Yl,"$1;"),T="function("+(D||"obj")+`) {
34
- `+(D?"":`obj || (obj = {});
35
- `)+"var __t, __p = ''"+(g?", __e = _.escape":"")+(b?`, __j = Array.prototype.join;
21
+ `;else if(Aa.test(T))throw new I(O);v=(c?v.replace(oa,""):v).replace(aa,"$1").replace(fa,"$1;"),v="function("+(T||"obj")+`) {
22
+ `+(T?"":`obj || (obj = {});
23
+ `)+"var __t, __p = ''"+(f?", __e = _.escape":"")+(c?`, __j = Array.prototype.join;
36
24
  function print() { __p += __j.call(arguments, '') }
37
25
  `:`;
38
- `)+T+`return __p
39
- }`;var $=hc(function(){return V(l,L+"return "+T).apply(r,d)});if($.source=T,Ri($))throw $;return $}function Lm(t){return Z(t).toLowerCase()}function Bm(t){return Z(t).toUpperCase()}function km(t,e,s){if(t=Z(t),t&&(s||e===r))return va(t);if(!t||!(e=Bt(e)))return t;var o=ne(t),u=ne(e),l=wa(o,u),d=ya(o,u)+1;return Le(o,l,d).join("")}function Dm(t,e,s){if(t=Z(t),t&&(s||e===r))return t.slice(0,Ea(t)+1);if(!t||!(e=Bt(e)))return t;var o=ne(t),u=ya(o,ne(e))+1;return Le(o,0,u).join("")}function Nm(t,e,s){if(t=Z(t),t&&(s||e===r))return t.replace(Rs,"");if(!t||!(e=Bt(e)))return t;var o=ne(t),u=wa(o,ne(e));return Le(o,u).join("")}function Fm(t,e){var s=Ft,o=ft;if(st(e)){var u="separator"in e?e.separator:u;s="length"in e?W(e.length):s,o="omission"in e?Bt(e.omission):o}t=Z(t);var l=t.length;if(cn(t)){var d=ne(t);l=d.length}if(s>=l)return t;var g=s-hn(o);if(g<1)return o;var b=d?Le(d,0,g).join(""):t.slice(0,g);if(u===r)return b+o;if(d&&(g+=b.length-g),Mi(u)){if(t.slice(g).search(u)){var E,x=b;for(u.global||(u=Gs(u.source,Z($o.exec(u))+"g")),u.lastIndex=0;E=u.exec(x);)var T=E.index;b=b.slice(0,T===r?g:T)}}else if(t.indexOf(Bt(u),g)!=g){var M=b.lastIndexOf(u);M>-1&&(b=b.slice(0,M))}return b+o}function Um(t){return t=Z(t),t&&Vl.test(t)?t.replace(Fo,pd):t}var Wm=bn(function(t,e,s){return t+(s?" ":"")+e.toUpperCase()}),Li=lu("toUpperCase");function cc(t,e,s){return t=Z(t),e=s?r:e,e===r?cd(t)?bd(t):td(t):t.match(e)||[]}var hc=z(function(t,e){try{return Ot(t,r,e)}catch(s){return Ri(s)?s:new F(s)}}),$m=me(function(t,e){return $t(e,function(s){s=fe(s),_e(t,s,Ci(t[s],t))}),t});function qm(t){var e=t==null?0:t.length,s=k();return t=e?nt(t,function(o){if(typeof o[1]!="function")throw new qt(p);return[s(o[0]),o[1]]}):[],z(function(o){for(var u=-1;++u<e;){var l=t[u];if(Ot(l[0],this,o))return Ot(l[1],this,o)}})}function zm(t){return pp(Ht(t,C))}function Bi(t){return function(){return t}}function Hm(t,e){return t==null||t!==t?e:t}var Jm=du(),Gm=du(!0);function Mt(t){return t}function ki(t){return za(typeof t=="function"?t:Ht(t,C))}function Km(t){return Ja(Ht(t,C))}function Ym(t,e){return Ga(t,Ht(e,C))}var Vm=z(function(t,e){return function(s){return Hn(s,t,e)}}),Zm=z(function(t,e){return function(s){return Hn(t,s,e)}});function Di(t,e,s){var o=_t(e),u=kr(e,o);s==null&&!(st(e)&&(u.length||!o.length))&&(s=e,e=t,t=this,u=kr(e,_t(e)));var l=!(st(s)&&"chain"in s)||!!s.chain,d=we(t);return $t(u,function(g){var b=e[g];t[g]=b,d&&(t.prototype[g]=function(){var E=this.__chain__;if(l||E){var x=t(this.__wrapped__),T=x.__actions__=Ct(this.__actions__);return T.push({func:b,args:arguments,thisArg:t}),x.__chain__=E,x}return b.apply(t,Ce([this.value()],arguments))})}),t}function Xm(){return bt._===this&&(bt._=Ed),this}function Ni(){}function Qm(t){return t=W(t),z(function(e){return Ka(e,t)})}var jm=pi(nt),tv=pi(pa),ev=pi(Us);function lc(t){return yi(t)?Ws(fe(t)):Pp(t)}function nv(t){return function(e){return t==null?r:Ye(t,e)}}var rv=gu(),sv=gu(!0);function Fi(){return[]}function Ui(){return!1}function iv(){return{}}function ov(){return""}function av(){return!0}function uv(t,e){if(t=W(t),t<1||t>Te)return[];var s=ce,o=vt(t,ce);e=k(e),t-=ce;for(var u=zs(o,e);++s<t;)e(s);return u}function cv(t){return U(t)?nt(t,fe):kt(t)?[t]:Ct(Pu(Z(t)))}function hv(t){var e=++yd;return Z(t)+e}var lv=$r(function(t,e){return t+e},0),fv=gi("ceil"),dv=$r(function(t,e){return t/e},1),pv=gi("floor");function gv(t){return t&&t.length?Br(t,Mt,ti):r}function _v(t,e){return t&&t.length?Br(t,k(e,2),ti):r}function bv(t){return ba(t,Mt)}function mv(t,e){return ba(t,k(e,2))}function vv(t){return t&&t.length?Br(t,Mt,si):r}function wv(t,e){return t&&t.length?Br(t,k(e,2),si):r}var yv=$r(function(t,e){return t*e},1),Sv=gi("round"),Ev=$r(function(t,e){return t-e},0);function xv(t){return t&&t.length?qs(t,Mt):0}function Tv(t,e){return t&&t.length?qs(t,k(e,2)):0}return c.after=K_,c.ary=qu,c.assign=Bb,c.assignIn=nc,c.assignInWith=ts,c.assignWith=kb,c.at=Db,c.before=zu,c.bind=Ci,c.bindAll=$m,c.bindKey=Hu,c.castArray=ib,c.chain=Uu,c.chunk=pg,c.compact=gg,c.concat=_g,c.cond=qm,c.conforms=zm,c.constant=Bi,c.countBy=x_,c.create=Nb,c.curry=Ju,c.curryRight=Gu,c.debounce=Ku,c.defaults=Fb,c.defaultsDeep=Ub,c.defer=Y_,c.delay=V_,c.difference=bg,c.differenceBy=mg,c.differenceWith=vg,c.drop=wg,c.dropRight=yg,c.dropRightWhile=Sg,c.dropWhile=Eg,c.fill=xg,c.filter=A_,c.flatMap=R_,c.flatMapDeep=M_,c.flatMapDepth=P_,c.flatten=ku,c.flattenDeep=Tg,c.flattenDepth=Ag,c.flip=Z_,c.flow=Jm,c.flowRight=Gm,c.fromPairs=Cg,c.functions=Gb,c.functionsIn=Kb,c.groupBy=O_,c.initial=Rg,c.intersection=Mg,c.intersectionBy=Pg,c.intersectionWith=Og,c.invert=Vb,c.invertBy=Zb,c.invokeMap=B_,c.iteratee=ki,c.keyBy=k_,c.keys=_t,c.keysIn=Rt,c.map=Yr,c.mapKeys=Qb,c.mapValues=jb,c.matches=Km,c.matchesProperty=Ym,c.memoize=Zr,c.merge=tm,c.mergeWith=rc,c.method=Vm,c.methodOf=Zm,c.mixin=Di,c.negate=Xr,c.nthArg=Qm,c.omit=em,c.omitBy=nm,c.once=X_,c.orderBy=D_,c.over=jm,c.overArgs=Q_,c.overEvery=tv,c.overSome=ev,c.partial=Ii,c.partialRight=Yu,c.partition=N_,c.pick=rm,c.pickBy=sc,c.property=lc,c.propertyOf=nv,c.pull=Dg,c.pullAll=Nu,c.pullAllBy=Ng,c.pullAllWith=Fg,c.pullAt=Ug,c.range=rv,c.rangeRight=sv,c.rearg=j_,c.reject=W_,c.remove=Wg,c.rest=tb,c.reverse=Ti,c.sampleSize=q_,c.set=im,c.setWith=om,c.shuffle=z_,c.slice=$g,c.sortBy=G_,c.sortedUniq=Yg,c.sortedUniqBy=Vg,c.split=Rm,c.spread=eb,c.tail=Zg,c.take=Xg,c.takeRight=Qg,c.takeRightWhile=jg,c.takeWhile=t_,c.tap=g_,c.throttle=nb,c.thru=Kr,c.toArray=ju,c.toPairs=ic,c.toPairsIn=oc,c.toPath=cv,c.toPlainObject=ec,c.transform=am,c.unary=rb,c.union=e_,c.unionBy=n_,c.unionWith=r_,c.uniq=s_,c.uniqBy=i_,c.uniqWith=o_,c.unset=um,c.unzip=Ai,c.unzipWith=Fu,c.update=cm,c.updateWith=hm,c.values=wn,c.valuesIn=lm,c.without=a_,c.words=cc,c.wrap=sb,c.xor=u_,c.xorBy=c_,c.xorWith=h_,c.zip=l_,c.zipObject=f_,c.zipObjectDeep=d_,c.zipWith=p_,c.entries=ic,c.entriesIn=oc,c.extend=nc,c.extendWith=ts,Di(c,c),c.add=lv,c.attempt=hc,c.camelCase=gm,c.capitalize=ac,c.ceil=fv,c.clamp=fm,c.clone=ob,c.cloneDeep=ub,c.cloneDeepWith=cb,c.cloneWith=ab,c.conformsTo=hb,c.deburr=uc,c.defaultTo=Hm,c.divide=dv,c.endsWith=_m,c.eq=se,c.escape=bm,c.escapeRegExp=mm,c.every=T_,c.find=C_,c.findIndex=Lu,c.findKey=Wb,c.findLast=I_,c.findLastIndex=Bu,c.findLastKey=$b,c.floor=pv,c.forEach=Wu,c.forEachRight=$u,c.forIn=qb,c.forInRight=zb,c.forOwn=Hb,c.forOwnRight=Jb,c.get=Pi,c.gt=lb,c.gte=fb,c.has=Yb,c.hasIn=Oi,c.head=Du,c.identity=Mt,c.includes=L_,c.indexOf=Ig,c.inRange=dm,c.invoke=Xb,c.isArguments=Xe,c.isArray=U,c.isArrayBuffer=db,c.isArrayLike=It,c.isArrayLikeObject=at,c.isBoolean=pb,c.isBuffer=Be,c.isDate=gb,c.isElement=_b,c.isEmpty=bb,c.isEqual=mb,c.isEqualWith=vb,c.isError=Ri,c.isFinite=wb,c.isFunction=we,c.isInteger=Vu,c.isLength=Qr,c.isMap=Zu,c.isMatch=yb,c.isMatchWith=Sb,c.isNaN=Eb,c.isNative=xb,c.isNil=Ab,c.isNull=Tb,c.isNumber=Xu,c.isObject=st,c.isObjectLike=ot,c.isPlainObject=Zn,c.isRegExp=Mi,c.isSafeInteger=Cb,c.isSet=Qu,c.isString=jr,c.isSymbol=kt,c.isTypedArray=vn,c.isUndefined=Ib,c.isWeakMap=Rb,c.isWeakSet=Mb,c.join=Lg,c.kebabCase=vm,c.last=Gt,c.lastIndexOf=Bg,c.lowerCase=wm,c.lowerFirst=ym,c.lt=Pb,c.lte=Ob,c.max=gv,c.maxBy=_v,c.mean=bv,c.meanBy=mv,c.min=vv,c.minBy=wv,c.stubArray=Fi,c.stubFalse=Ui,c.stubObject=iv,c.stubString=ov,c.stubTrue=av,c.multiply=yv,c.nth=kg,c.noConflict=Xm,c.noop=Ni,c.now=Vr,c.pad=Sm,c.padEnd=Em,c.padStart=xm,c.parseInt=Tm,c.random=pm,c.reduce=F_,c.reduceRight=U_,c.repeat=Am,c.replace=Cm,c.result=sm,c.round=Sv,c.runInContext=_,c.sample=$_,c.size=H_,c.snakeCase=Im,c.some=J_,c.sortedIndex=qg,c.sortedIndexBy=zg,c.sortedIndexOf=Hg,c.sortedLastIndex=Jg,c.sortedLastIndexBy=Gg,c.sortedLastIndexOf=Kg,c.startCase=Mm,c.startsWith=Pm,c.subtract=Ev,c.sum=xv,c.sumBy=Tv,c.template=Om,c.times=uv,c.toFinite=ye,c.toInteger=W,c.toLength=tc,c.toLower=Lm,c.toNumber=Kt,c.toSafeInteger=Lb,c.toString=Z,c.toUpper=Bm,c.trim=km,c.trimEnd=Dm,c.trimStart=Nm,c.truncate=Fm,c.unescape=Um,c.uniqueId=hv,c.upperCase=Wm,c.upperFirst=Li,c.each=Wu,c.eachRight=$u,c.first=Du,Di(c,function(){var t={};return he(c,function(e,s){X.call(c.prototype,s)||(t[s]=e)}),t}(),{chain:!1}),c.VERSION=a,$t(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){c[t].placeholder=c}),$t(["drop","take"],function(t,e){J.prototype[t]=function(s){s=s===r?1:pt(W(s),0);var o=this.__filtered__&&!e?new J(this):this.clone();return o.__filtered__?o.__takeCount__=vt(s,o.__takeCount__):o.__views__.push({size:vt(s,ce),type:t+(o.__dir__<0?"Right":"")}),o},J.prototype[t+"Right"]=function(s){return this.reverse()[t](s).reverse()}}),$t(["filter","map","takeWhile"],function(t,e){var s=e+1,o=s==St||s==kl;J.prototype[t]=function(u){var l=this.clone();return l.__iteratees__.push({iteratee:k(u,3),type:s}),l.__filtered__=l.__filtered__||o,l}}),$t(["head","last"],function(t,e){var s="take"+(e?"Right":"");J.prototype[t]=function(){return this[s](1).value()[0]}}),$t(["initial","tail"],function(t,e){var s="drop"+(e?"":"Right");J.prototype[t]=function(){return this.__filtered__?new J(this):this[s](1)}}),J.prototype.compact=function(){return this.filter(Mt)},J.prototype.find=function(t){return this.filter(t).head()},J.prototype.findLast=function(t){return this.reverse().find(t)},J.prototype.invokeMap=z(function(t,e){return typeof t=="function"?new J(this):this.map(function(s){return Hn(s,t,e)})}),J.prototype.reject=function(t){return this.filter(Xr(k(t)))},J.prototype.slice=function(t,e){t=W(t);var s=this;return s.__filtered__&&(t>0||e<0)?new J(s):(t<0?s=s.takeRight(-t):t&&(s=s.drop(t)),e!==r&&(e=W(e),s=e<0?s.dropRight(-e):s.take(e-t)),s)},J.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},J.prototype.toArray=function(){return this.take(ce)},he(J.prototype,function(t,e){var s=/^(?:filter|find|map|reject)|While$/.test(e),o=/^(?:head|last)$/.test(e),u=c[o?"take"+(e=="last"?"Right":""):e],l=o||/^find/.test(e);u&&(c.prototype[e]=function(){var d=this.__wrapped__,g=o?[1]:arguments,b=d instanceof J,E=g[0],x=b||U(d),T=function(H){var G=u.apply(c,Ce([H],g));return o&&M?G[0]:G};x&&s&&typeof E=="function"&&E.length!=1&&(b=x=!1);var M=this.__chain__,L=!!this.__actions__.length,D=l&&!M,$=b&&!L;if(!l&&x){d=$?d:new J(this);var N=t.apply(d,g);return N.__actions__.push({func:Kr,args:[T],thisArg:r}),new zt(N,M)}return D&&$?t.apply(this,g):(N=this.thru(T),D?o?N.value()[0]:N.value():N)})}),$t(["pop","push","shift","sort","splice","unshift"],function(t){var e=vr[t],s=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",o=/^(?:pop|shift)$/.test(t);c.prototype[t]=function(){var u=arguments;if(o&&!this.__chain__){var l=this.value();return e.apply(U(l)?l:[],u)}return this[s](function(d){return e.apply(U(d)?d:[],u)})}}),he(J.prototype,function(t,e){var s=c[e];if(s){var o=s.name+"";X.call(pn,o)||(pn[o]=[]),pn[o].push({name:e,func:s})}}),pn[Wr(r,ct).name]=[{name:"wrapper",func:r}],J.prototype.clone=Ud,J.prototype.reverse=Wd,J.prototype.value=$d,c.prototype.at=__,c.prototype.chain=b_,c.prototype.commit=m_,c.prototype.next=v_,c.prototype.plant=y_,c.prototype.reverse=S_,c.prototype.toJSON=c.prototype.valueOf=c.prototype.value=E_,c.prototype.first=c.prototype.head,Nn&&(c.prototype[Nn]=w_),c},ln=md();ze?((ze.exports=ln)._=ln,ks._=ln):bt._=ln}).call(oe)}(ir,ir.exports);var bl=ir.exports;const ml=$i(bl);class vl{constructor(i){S(this,"config");this.config=i}async complete(i,r){var a;await this.persist(i,{...r,success:!0}),(a=this.config.logger)==null||a.debug("Transaction completed:",i)}async fail(i,r){var a;await this.persist(i,{...r,success:!1}),(a=this.config.logger)==null||a.debug("Transaction failed:",{...i,...r})}async persist(i,r){await fetch(`${this.config.apiUrl}/transactions/${i.id}`,{body:JSON.stringify(r),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class wl{constructor(i,r){S(this,"transaction");S(this,"manager");this.transaction=i,this.manager=r}getFunctionCall(){return this.transaction.functionCall}async invoke(i,r){var m;const a=this.transaction.functionCall;if(!a){await this.fail("No function call found");return}const h=a.name,f=a.args,p=i[h];if(!p){await this.fail(`Tool ${h} not found`);return}try{const w=ml.get(r,"schema.config.parameters.properties",{}),P=(w&&Object.keys(w).length>0?Object.keys(w):((m=p.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:m[1].split(",").map(A=>A.trim()).filter(Boolean))||[]).map(A=>f[A]),C=await p.apply(null,P);await this.complete(C)}catch(w){await this.fail(`Error executing tool ${h}: ${w}`)}}async complete(i){await this.manager.complete(this.transaction,{success:!0,output:i,error:null})}async fail(i){await this.manager.fail(this.transaction,{success:!1,output:null,error:i})}}class Oo extends Cn{constructor(r){super();S(this,"status");S(this,"autostart");S(this,"session");S(this,"config");S(this,"notify",!0);S(this,"_tools");S(this,"_toolSchema",{});if(this.config=r,this.status="disconnected",this.autostart=!0,Array.isArray(r.tools)){this._tools={};for(const a of r.tools)a.schema&&a.implementation&&(this._tools[a.schema.name]=a.implementation,this._toolSchema[a.schema.name]=a)}else this._tools=r.tools}getName(){return"transaction"}getPriority(){return 0}getToolInstance(r){return this._toolSchema[r]}async connect(r){return this.setStatus("connected"),r}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(r){this.session=r}async sendPacket(r){}onTransaction(r){const a=new vl(this.config),h=new wl(r,a);if(this.config.onTransaction)this.config.onTransaction(h);else{const f=r.functionCall?this.getToolInstance(r.functionCall.name):void 0;h.invoke(this._tools,f)}}getTools(){return this._tools}}const In=B.createContext(void 0);function yl(n){return new Promise((i,r)=>{const a=new FileReader;a.readAsDataURL(n),a.onload=()=>{const f=a.result.split(";base64,")[1];i(f)},a.onerror=h=>{r(h)}})}function Sl(n){const i={rest:r=>r.config.apiUrl,webrtc:r=>r.config.webrtcUrl.replace("/webrtc","").replace("ws://","http://").replace("wss://","https://"),websocket:r=>r.config.webSocketUrl.replace("/websocket","").replace("ws://","http://").replace("wss://","https://")};for(const r of n){const a=i[r.getName()];if(a)return a(r)}return null}function El({dev:n=!1,baseUrl:i,protocols:r,logger:a,children:h,session:f="new",transformMessages:p,...m}){const[w,I]=B.useState(!1),[P,C]=B.useState([]),[A,R]=B.useState(f),[K,At]=B.useState(new Map),gt=B.useRef(!1),ct=B.useMemo(()=>{if(Array.isArray(r))return r;if(typeof r=="object"&&r!==null){const q=n?"localhost:8000":i||"persona.applica.guru/api",ht=n?"http":"https",Q=n?"ws":"wss";let Ft=Object.keys(r).map(ft=>{switch(ft){case"rest":const Ut=r[ft];return Ut===!0?new _s({apiUrl:`${ht}://${q}`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof Ut=="object"&&Ut!==null?new _s(Ut):null;case"webrtc":const it=r[ft];return it===!0?new ms({webrtcUrl:`${Q}://${q}/webrtc`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof it=="object"&&it!==null?new ms(it):null;case"websocket":const St=r[ft];return St===!0?new bs({webSocketUrl:`${Q}://${q}/websocket`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof St=="object"&&St!==null?new bs(St):null;default:throw new Error(`Unknown protocol: ${ft}`)}}).filter(ft=>ft!==null);return m.tools&&Ft.push(new Oo({apiUrl:`${ht}://${q}`,apiKey:m.apiKey,agentId:m.agentId,tools:m.tools,logger:a})),Ft}throw new Error("Invalid protocols configuration")},[]);B.useEffect(()=>{gt.current||(gt.current=!0,a==null||a.debug("Initializing protocols: ",ct.map(q=>q.getName())),ct.forEach(q=>{q.setSession(A),q.clearListeners(),q.addStatusChangeListener(ht=>{a==null||a.debug(`${q.getName()} has notified new status: ${ht}`),K.set(q.getName(),ht),ht==="connected"&&(m.context&&q.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:m.context}}),m.tools&&Array.isArray(m.tools)&&q.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:m.tools.map(Q=>Q.schema)}}})),At(new Map(K))}),q.addPacketListener(ht=>{if(ht.type==="message"){const Q=ht.payload;(Q==null?void 0:Q.finishReason)==="stop"&&!(Q!=null&&Q.functionResponse)&&!(Q!=null&&Q.thought)&&I(!1),Q.thought&&(Q.type="reasoning"),C(Ft=>{const ft=Po([...Ft,{...Q,protocol:q.getName()}]);return p?p(ft):ft})}else if(ht.type==="reasoning"){const Ft={type:"reasoning",text:ht.payload.thought,role:"assistant",finishReason:"stop"};C(ft=>{const Ut=Po([...ft,{...Ft,protocol:q.getName()}]);return p?p(Ut):Ut})}else ht.type==="transaction"&&ct.filter(Q=>Q!==q).forEach(Q=>Q.onTransaction(ht.payload))}),q.autostart&&q.status==="disconnected"&&(a==null||a.debug(`Connecting to protocol: ${q.getName()}`),q.connect(A),I(!1))}))},[A,ct,a,K,p]);const ar=async q=>{var Ut;if(((Ut=q.content[0])==null?void 0:Ut.type)!=="text")throw new Error("Only text messages are supported");if(!ct.some(it=>it.getName()!=="transaction"&&it.status==="connected")){C(it=>{const St=[...it,{role:"assistant",type:"text",text:"No protocol is connected."}];return p?p(St):St});return}const Q=q.content[0].text;C(it=>{const St=[...it,{role:"user",type:"text",text:Q}];return p?p(St):St}),I(!0);const Ft=ct.sort((it,St)=>St.getPriority()-it.getPriority()).find(it=>it.status==="connected"),ft=[];if(q.attachments)for(const it of q.attachments)it.contentType.startsWith("image/")&&it.file&&ft.push({role:"user",image:{contentType:it.contentType,content:await yl(it.file)},text:"",type:"text"});q.content&&ft.push({role:"user",text:q.content[0].text,type:"text"}),a==null||a.debug("Sending message:",ft),await(Ft==null?void 0:Ft.sendPacket({type:"request",payload:ft}))},Qt=B.useCallback(()=>(I(!1),C([]),R("new"),Promise.resolve()),[]),We=B.useCallback(()=>Promise.resolve(),[]),jt=B.useCallback(()=>P,[P]),$e=ch({isRunning:w,messages:P,convertMessage:gl,onNew:ar,onCancel:Qt,onReload:We,adapters:{attachments:new Xc([new Vc])}});return Ee.jsx(In.Provider,{value:{protocols:ct,protocolsStatus:K,getMessages:jt},children:Ee.jsx(fl,{runtime:$e,children:h})})}function xl({children:n,...i}){return Ee.jsx(El,{...i,children:n})}function Tl(){const n=B.useContext(In);if(!n)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return n}function Lo(n){const i=B.useContext(In);if(!i)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const r=i.protocols.find(h=>h.getName()===n);if(!r)return null;const a=i.protocolsStatus.get(r.getName());return{...r,connect:r.connect.bind(r),disconnect:r.disconnect.bind(r),sendPacket:r.sendPacket.bind(r),setSession:r.setSession.bind(r),addStatusChangeListener:r.addStatusChangeListener.bind(r),addPacketListener:r.addPacketListener.bind(r),getName:r.getName.bind(r),getPriority:r.getPriority.bind(r),status:a||r.status}}function Al(){const n=B.useContext(In);if(!n)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return Sl(n.protocols)}function Cl(){return Lo("webrtc")}function Il(){const n=B.useContext(In);if(!n)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return n.getMessages()}class Rl{constructor(){S(this,"prefix","[Persona]")}log(i,...r){console.log(`${this.prefix} - ${i}`,...r)}info(i,...r){console.info(`${this.prefix} - ${i}`,...r)}warn(i,...r){console.warn(`${this.prefix} - ${i}`,...r)}error(i,...r){console.error(`${this.prefix} - ${i}`,...r)}debug(i,...r){console.debug(`${this.prefix} - ${i}`,...r)}}function Fe(n,i,r){return{type:n,description:i,...r}}function Bo(n){const i=Object.entries(n.parameters).filter(([r,a])=>a.required).map(([r])=>r);return{type:"local",name:n.name,description:n.description,config:{timeout:n.timeout||60,parameters:{type:"object",title:n.title||`${n.name} parameters`,required:i,properties:n.parameters},output:{type:"object",title:`${n.name} output`,properties:n.output}}}}function or(n){return{schema:Bo(n),implementation:n.implementation}}function ko(n,i,r,a,h,f){const p={name:n,description:i,title:f==null?void 0:f.title,timeout:f==null?void 0:f.timeout,parameters:a,output:h,implementation:r};return or(p)}const Ml=ko("sum","Sum two numbers",function(i,r){return{result:i+r}},{a:Fe("number","First number to sum",{required:!0}),b:Fe("number","Second number to sum",{required:!0})},{result:Fe("number","Sum of two numbers")}),Pl=or({name:"navigate_to",description:"Allow agent to redirect user to specific sub page like /foo or #/foo or anything like that",title:"Sum two numbers",timeout:60,parameters:{a:Fe("number","First number to sum"),b:Fe("number","Seconth number to sum")},output:{result:Fe("number","Sum of two numbers")},implementation:function(i,r){return{result:i+r}}});function Ol(n){const i=[],r={};return n.forEach(a=>{const{schema:h,implementation:f}=or(a);i.push(h),r[a.name]=f}),{schemas:i,implementations:r}}function Ll(n,i){const{required:r,properties:a}=i.config.parameters;for(const h of r)if(!(h in n))throw new Error(`Missing required parameter: ${h}`);for(const[h,f]of Object.entries(n)){const p=a[h];if(p){if(p.type==="number"&&typeof f!="number")throw new Error(`Parameter ${h} should be a number`);if(p.type==="string"&&typeof f!="string")throw new Error(`Parameter ${h} should be a string`);if(p.type==="boolean"&&typeof f!="boolean")throw new Error(`Parameter ${h} should be a boolean`)}}return!0}Y.PersonaConsoleLogger=Rl,Y.PersonaProtocolBase=Cn,Y.PersonaRESTProtocol=_s,Y.PersonaRuntimeProvider=xl,Y.PersonaTransactionProtocol=Oo,Y.PersonaWebRTCProtocol=ms,Y.PersonaWebSocketProtocol=bs,Y.createParameter=Fe,Y.createTool=or,Y.createToolFromFunction=ko,Y.createToolRegistry=Ol,Y.generateToolSchema=Bo,Y.navigateToToolExample=Pl,Y.sumTool=Ml,Y.usePersonaRuntime=Tl,Y.usePersonaRuntimeEndpoint=Al,Y.usePersonaRuntimeMessages=Il,Y.usePersonaRuntimeProtocol=Lo,Y.usePersonaRuntimeWebRTCProtocol=Cl,Y.validateToolParameters=Ll,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
26
+ `)+v+`return __p
27
+ }`;var M=bo(function(){return q(o,A+"return "+v).apply(i,a)});if(M.source=v,Mi(M))throw M;return M}function Zp(n){return G(n).toLowerCase()}function Yp(n){return G(n).toUpperCase()}function Xp(n,t,e){if(n=G(n),n&&(e||t===i))return Wu(n);if(!n||!(t=Ln(t)))return n;var r=Yn(n),u=Yn(t),o=Mu(r,u),a=Fu(r,u)+1;return St(r,o,a).join("")}function Qp(n,t,e){if(n=G(n),n&&(e||t===i))return n.slice(0,Du(n)+1);if(!n||!(t=Ln(t)))return n;var r=Yn(n),u=Fu(r,Yn(t))+1;return St(r,0,u).join("")}function Vp(n,t,e){if(n=G(n),n&&(e||t===i))return n.replace(Mr,"");if(!n||!(t=Ln(t)))return n;var r=Yn(n),u=Mu(r,Yn(t));return St(r,u).join("")}function jp(n,t){var e=Fn,r=sn;if(X(t)){var u="separator"in t?t.separator:u;e="length"in t?W(t.length):e,r="omission"in t?Ln(t.omission):r}n=G(n);var o=n.length;if(qt(n)){var a=Yn(n);o=a.length}if(e>=o)return n;var f=e-Kt(r);if(f<1)return r;var c=a?St(a,0,f).join(""):n.slice(0,f);if(u===i)return c+r;if(a&&(f+=c.length-f),Fi(u)){if(n.slice(f).search(u)){var d,_=c;for(u.global||(u=Qr(u.source,G(tu.exec(u))+"g")),u.lastIndex=0;d=u.exec(_);)var v=d.index;c=c.slice(0,v===i?f:v)}}else if(n.indexOf(Ln(u),f)!=f){var x=c.lastIndexOf(u);x>-1&&(c=c.slice(0,x))}return c+r}function nd(n){return n=G(n),n&&la.test(n)?n.replace(Vi,Ef):n}var td=Yt(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Ni=bs("toUpperCase");function Co(n,t,e){return n=G(n),t=e?i:t,t===i?Cf(n)?Of(n):df(n):n.match(t)||[]}var bo=U(function(n,t){try{return En(n,i,t)}catch(e){return Mi(e)?e:new I(e)}}),ed=at(function(n,t){return Nn(t,function(e){e=et(e),st(n,e,Oi(n[e],n))}),n});function rd(n){var t=n==null?0:n.length,e=b();return n=t?Y(n,function(r){if(typeof r[1]!="function")throw new Bn(C);return[e(r[0]),r[1]]}):[],U(function(r){for(var u=-1;++u<t;){var o=n[u];if(En(o[0],this,r))return En(o[1],this,r)}})}function id(n){return El(qn(n,un))}function Bi(n){return function(){return n}}function ud(n,t){return n==null||n!==n?t:n}var sd=Ts(),od=Ts(!0);function bn(n){return n}function $i(n){return rs(typeof n=="function"?n:qn(n,un))}function ad(n){return us(qn(n,un))}function fd(n,t){return ss(n,qn(t,un))}var ld=U(function(n,t){return function(e){return ve(e,n,t)}}),cd=U(function(n,t){return function(e){return ve(n,e,t)}});function qi(n,t,e){var r=fn(t),u=tr(t,r);e==null&&!(X(t)&&(u.length||!r.length))&&(e=t,t=n,n=this,u=tr(t,fn(t)));var o=!(X(e)&&"chain"in e)||!!e.chain,a=lt(n);return Nn(u,function(f){var c=t[f];n[f]=c,a&&(n.prototype[f]=function(){var d=this.__chain__;if(o||d){var _=n(this.__wrapped__),v=_.__actions__=Sn(this.__actions__);return v.push({func:c,args:arguments,thisArg:n}),_.__chain__=d,_}return c.apply(n,_t([this.value()],arguments))})}),n}function hd(){return ln._===this&&(ln._=Nf),this}function Ki(){}function gd(n){return n=W(n),U(function(t){return os(t,n)})}var pd=mi(Y),dd=mi(Pu),_d=mi(zr);function Ro(n){return Ri(n)?Hr(et(n)):kl(n)}function vd(n){return function(t){return n==null?i:Wt(n,t)}}var wd=Es(),md=Es(!0);function Gi(){return[]}function zi(){return!1}function yd(){return{}}function xd(){return""}function Sd(){return!0}function Ad(n,t){if(n=W(n),n<1||n>pt)return[];var e=jn,r=hn(n,jn);t=b(t),n-=jn;for(var u=Zr(r,t);++e<n;)t(e);return u}function Cd(n){return L(n)?Y(n,et):On(n)?[n]:Sn(Hs(G(n)))}function bd(n){var t=++Uf;return G(n)+t}var Rd=or(function(n,t){return n+t},0),Td=yi("ceil"),Pd=or(function(n,t){return n/t},1),Ed=yi("floor");function Id(n){return n&&n.length?nr(n,bn,ui):i}function Ld(n,t){return n&&n.length?nr(n,b(t,2),ui):i}function Od(n){return Lu(n,bn)}function Wd(n,t){return Lu(n,b(t,2))}function Md(n){return n&&n.length?nr(n,bn,fi):i}function Fd(n,t){return n&&n.length?nr(n,b(t,2),fi):i}var Ud=or(function(n,t){return n*t},1),Dd=yi("round"),Nd=or(function(n,t){return n-t},0);function Bd(n){return n&&n.length?Jr(n,bn):0}function $d(n,t){return n&&n.length?Jr(n,b(t,2)):0}return s.after=ag,s.ary=eo,s.assign=Yg,s.assignIn=vo,s.assignInWith=yr,s.assignWith=Xg,s.at=Qg,s.before=ro,s.bind=Oi,s.bindAll=ed,s.bindKey=io,s.castArray=yg,s.chain=js,s.chunk=Ec,s.compact=Ic,s.concat=Lc,s.cond=rd,s.conforms=id,s.constant=Bi,s.countBy=Bh,s.create=Vg,s.curry=uo,s.curryRight=so,s.debounce=oo,s.defaults=jg,s.defaultsDeep=np,s.defer=fg,s.delay=lg,s.difference=Oc,s.differenceBy=Wc,s.differenceWith=Mc,s.drop=Fc,s.dropRight=Uc,s.dropRightWhile=Dc,s.dropWhile=Nc,s.fill=Bc,s.filter=qh,s.flatMap=zh,s.flatMapDeep=Hh,s.flatMapDepth=kh,s.flatten=Ys,s.flattenDeep=$c,s.flattenDepth=qc,s.flip=cg,s.flow=sd,s.flowRight=od,s.fromPairs=Kc,s.functions=op,s.functionsIn=ap,s.groupBy=Jh,s.initial=zc,s.intersection=Hc,s.intersectionBy=kc,s.intersectionWith=Jc,s.invert=lp,s.invertBy=cp,s.invokeMap=Yh,s.iteratee=$i,s.keyBy=Xh,s.keys=fn,s.keysIn=Cn,s.map=pr,s.mapKeys=gp,s.mapValues=pp,s.matches=ad,s.matchesProperty=fd,s.memoize=_r,s.merge=dp,s.mergeWith=wo,s.method=ld,s.methodOf=cd,s.mixin=qi,s.negate=vr,s.nthArg=gd,s.omit=_p,s.omitBy=vp,s.once=hg,s.orderBy=Qh,s.over=pd,s.overArgs=gg,s.overEvery=dd,s.overSome=_d,s.partial=Wi,s.partialRight=ao,s.partition=Vh,s.pick=wp,s.pickBy=mo,s.property=Ro,s.propertyOf=vd,s.pull=Qc,s.pullAll=Qs,s.pullAllBy=Vc,s.pullAllWith=jc,s.pullAt=nh,s.range=wd,s.rangeRight=md,s.rearg=pg,s.reject=tg,s.remove=th,s.rest=dg,s.reverse=Ii,s.sampleSize=rg,s.set=yp,s.setWith=xp,s.shuffle=ig,s.slice=eh,s.sortBy=og,s.sortedUniq=fh,s.sortedUniqBy=lh,s.split=zp,s.spread=_g,s.tail=ch,s.take=hh,s.takeRight=gh,s.takeRightWhile=ph,s.takeWhile=dh,s.tap=Ih,s.throttle=vg,s.thru=gr,s.toArray=go,s.toPairs=yo,s.toPairsIn=xo,s.toPath=Cd,s.toPlainObject=_o,s.transform=Sp,s.unary=wg,s.union=_h,s.unionBy=vh,s.unionWith=wh,s.uniq=mh,s.uniqBy=yh,s.uniqWith=xh,s.unset=Ap,s.unzip=Li,s.unzipWith=Vs,s.update=Cp,s.updateWith=bp,s.values=Vt,s.valuesIn=Rp,s.without=Sh,s.words=Co,s.wrap=mg,s.xor=Ah,s.xorBy=Ch,s.xorWith=bh,s.zip=Rh,s.zipObject=Th,s.zipObjectDeep=Ph,s.zipWith=Eh,s.entries=yo,s.entriesIn=xo,s.extend=vo,s.extendWith=yr,qi(s,s),s.add=Rd,s.attempt=bo,s.camelCase=Ip,s.capitalize=So,s.ceil=Td,s.clamp=Tp,s.clone=xg,s.cloneDeep=Ag,s.cloneDeepWith=Cg,s.cloneWith=Sg,s.conformsTo=bg,s.deburr=Ao,s.defaultTo=ud,s.divide=Pd,s.endsWith=Lp,s.eq=Qn,s.escape=Op,s.escapeRegExp=Wp,s.every=$h,s.find=Kh,s.findIndex=Js,s.findKey=tp,s.findLast=Gh,s.findLastIndex=Zs,s.findLastKey=ep,s.floor=Ed,s.forEach=no,s.forEachRight=to,s.forIn=rp,s.forInRight=ip,s.forOwn=up,s.forOwnRight=sp,s.get=Ui,s.gt=Rg,s.gte=Tg,s.has=fp,s.hasIn=Di,s.head=Xs,s.identity=bn,s.includes=Zh,s.indexOf=Gc,s.inRange=Pp,s.invoke=hp,s.isArguments=Ut,s.isArray=L,s.isArrayBuffer=Pg,s.isArrayLike=An,s.isArrayLikeObject=j,s.isBoolean=Eg,s.isBuffer=At,s.isDate=Ig,s.isElement=Lg,s.isEmpty=Og,s.isEqual=Wg,s.isEqualWith=Mg,s.isError=Mi,s.isFinite=Fg,s.isFunction=lt,s.isInteger=fo,s.isLength=wr,s.isMap=lo,s.isMatch=Ug,s.isMatchWith=Dg,s.isNaN=Ng,s.isNative=Bg,s.isNil=qg,s.isNull=$g,s.isNumber=co,s.isObject=X,s.isObjectLike=V,s.isPlainObject=Ae,s.isRegExp=Fi,s.isSafeInteger=Kg,s.isSet=ho,s.isString=mr,s.isSymbol=On,s.isTypedArray=Qt,s.isUndefined=Gg,s.isWeakMap=zg,s.isWeakSet=Hg,s.join=Zc,s.kebabCase=Mp,s.last=Gn,s.lastIndexOf=Yc,s.lowerCase=Fp,s.lowerFirst=Up,s.lt=kg,s.lte=Jg,s.max=Id,s.maxBy=Ld,s.mean=Od,s.meanBy=Wd,s.min=Md,s.minBy=Fd,s.stubArray=Gi,s.stubFalse=zi,s.stubObject=yd,s.stubString=xd,s.stubTrue=Sd,s.multiply=Ud,s.nth=Xc,s.noConflict=hd,s.noop=Ki,s.now=dr,s.pad=Dp,s.padEnd=Np,s.padStart=Bp,s.parseInt=$p,s.random=Ep,s.reduce=jh,s.reduceRight=ng,s.repeat=qp,s.replace=Kp,s.result=mp,s.round=Dd,s.runInContext=l,s.sample=eg,s.size=ug,s.snakeCase=Gp,s.some=sg,s.sortedIndex=rh,s.sortedIndexBy=ih,s.sortedIndexOf=uh,s.sortedLastIndex=sh,s.sortedLastIndexBy=oh,s.sortedLastIndexOf=ah,s.startCase=Hp,s.startsWith=kp,s.subtract=Nd,s.sum=Bd,s.sumBy=$d,s.template=Jp,s.times=Ad,s.toFinite=ct,s.toInteger=W,s.toLength=po,s.toLower=Zp,s.toNumber=zn,s.toSafeInteger=Zg,s.toString=G,s.toUpper=Yp,s.trim=Xp,s.trimEnd=Qp,s.trimStart=Vp,s.truncate=jp,s.unescape=nd,s.uniqueId=bd,s.upperCase=td,s.upperFirst=Ni,s.each=no,s.eachRight=to,s.first=Xs,qi(s,function(){var n={};return nt(s,function(t,e){z.call(s.prototype,e)||(n[e]=t)}),n}(),{chain:!1}),s.VERSION=w,Nn(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){s[n].placeholder=s}),Nn(["drop","take"],function(n,t){N.prototype[n]=function(e){e=e===i?1:an(W(e),0);var r=this.__filtered__&&!t?new N(this):this.clone();return r.__filtered__?r.__takeCount__=hn(e,r.__takeCount__):r.__views__.push({size:hn(e,jn),type:n+(r.__dir__<0?"Right":"")}),r},N.prototype[n+"Right"]=function(e){return this.reverse()[n](e).reverse()}}),Nn(["filter","map","takeWhile"],function(n,t){var e=t+1,r=e==_n||e==Xo;N.prototype[n]=function(u){var o=this.clone();return o.__iteratees__.push({iteratee:b(u,3),type:e}),o.__filtered__=o.__filtered__||r,o}}),Nn(["head","last"],function(n,t){var e="take"+(t?"Right":"");N.prototype[n]=function(){return this[e](1).value()[0]}}),Nn(["initial","tail"],function(n,t){var e="drop"+(t?"":"Right");N.prototype[n]=function(){return this.__filtered__?new N(this):this[e](1)}}),N.prototype.compact=function(){return this.filter(bn)},N.prototype.find=function(n){return this.filter(n).head()},N.prototype.findLast=function(n){return this.reverse().find(n)},N.prototype.invokeMap=U(function(n,t){return typeof n=="function"?new N(this):this.map(function(e){return ve(e,n,t)})}),N.prototype.reject=function(n){return this.filter(vr(b(n)))},N.prototype.slice=function(n,t){n=W(n);var e=this;return e.__filtered__&&(n>0||t<0)?new N(e):(n<0?e=e.takeRight(-n):n&&(e=e.drop(n)),t!==i&&(t=W(t),e=t<0?e.dropRight(-t):e.take(t-n)),e)},N.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},N.prototype.toArray=function(){return this.take(jn)},nt(N.prototype,function(n,t){var e=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),u=s[r?"take"+(t=="last"?"Right":""):t],o=r||/^find/.test(t);u&&(s.prototype[t]=function(){var a=this.__wrapped__,f=r?[1]:arguments,c=a instanceof N,d=f[0],_=c||L(a),v=function(D){var B=u.apply(s,_t([D],f));return r&&x?B[0]:B};_&&e&&typeof d=="function"&&d.length!=1&&(c=_=!1);var x=this.__chain__,A=!!this.__actions__.length,T=o&&!x,M=c&&!A;if(!o&&_){a=M?a:new N(this);var P=n.apply(a,f);return P.__actions__.push({func:gr,args:[v],thisArg:i}),new $n(P,x)}return T&&M?n.apply(this,f):(P=this.thru(v),T?r?P.value()[0]:P.value():P)})}),Nn(["pop","push","shift","sort","splice","unshift"],function(n){var t=Be[n],e=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);s.prototype[n]=function(){var u=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(L(o)?o:[],u)}return this[e](function(a){return t.apply(L(a)?a:[],u)})}}),nt(N.prototype,function(n,t){var e=s[t];if(e){var r=e.name+"";z.call(kt,r)||(kt[r]=[]),kt[r].push({name:t,func:e})}}),kt[sr(i,xn).name]=[{name:"wrapper",func:i}],N.prototype.clone=nl,N.prototype.reverse=tl,N.prototype.value=el,s.prototype.at=Lh,s.prototype.chain=Oh,s.prototype.commit=Wh,s.prototype.next=Mh,s.prototype.plant=Uh,s.prototype.reverse=Dh,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=Nh,s.prototype.first=s.prototype.head,le&&(s.prototype[le]=Fh),s},Gt=Wf();Pt?((Pt.exports=Gt)._=Gt,$r._=Gt):ln._=Gt}).call(ne)}(be,be.exports);var Oo=be.exports;const Wo=Lo(Oo);class Mo{constructor(p){E(this,"config");this.config=p}async complete(p,i){var w;await this.persist(p,{...i,success:!0}),(w=this.config.logger)==null||w.debug("Transaction completed:",p)}async fail(p,i){var w;await this.persist(p,{...i,success:!1}),(w=this.config.logger)==null||w.debug("Transaction failed:",{...p,...i})}async persist(p,i){await fetch(`${this.config.apiUrl}/transactions/${p.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Fo{constructor(p,i){E(this,"transaction");E(this,"manager");this.transaction=p,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(p,i){var O;const w=this.transaction.functionCall;if(!w){await this.fail("No function call found");return}const m=w.name,R=w.args,C=p[m];if(!C){await this.fail(`Tool ${m} not found`);return}try{const K=Wo.get(i,"schema.config.parameters.properties",{}),Rn=(K&&Object.keys(K).length>0?Object.keys(K):((O=C.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:O[1].split(",").map(Tn=>Tn.trim()).filter(Boolean))||[]).map(Tn=>R[Tn]),un=await C.apply(null,Rn);await this.complete(un)}catch(K){await this.fail(`Error executing tool ${m}: ${K}`)}}async complete(p){await this.manager.complete(this.transaction,{success:!0,output:p,error:null})}async fail(p){await this.manager.fail(this.transaction,{success:!1,output:null,error:p})}}class ki extends jt{constructor(i){super();E(this,"status");E(this,"autostart");E(this,"session");E(this,"config");E(this,"notify",!0);E(this,"_tools");E(this,"_toolSchema",{});if(this.config=i,this.status="disconnected",this.autostart=!0,Array.isArray(i.tools)){this._tools={};for(const w of i.tools)w.schema&&w.implementation&&(this._tools[w.schema.name]=w.implementation,this._toolSchema[w.schema.name]=w)}else this._tools=i.tools}getName(){return"transaction"}getPriority(){return 0}getToolInstance(i){return this._toolSchema[i]}async connect(i){return this.setStatus("connected"),i}async disconnect(){this.setStatus("disconnected"),this.session=null}async syncSession(i){this.session=i}async sendPacket(i){}onTransaction(i){const w=new Mo(this.config),m=new Fo(i,w);if(this.config.onTransaction)this.config.onTransaction(m);else{const R=i.functionCall?this.getToolInstance(i.functionCall.name):void 0;m.invoke(this._tools,R)}}getTools(){return this._tools}}const te=tn.createContext(void 0);function Uo(y){return new Promise((p,i)=>{const w=new FileReader;w.readAsDataURL(y),w.onload=()=>{const R=w.result.split(";base64,")[1];p(R)},w.onerror=m=>{i(m)}})}function Do(y){const p={rest:i=>i.config.apiUrl,webrtc:i=>i.config.webrtcUrl.replace("/webrtc","").replace("ws://","http://").replace("wss://","https://"),websocket:i=>i.config.webSocketUrl.replace("/websocket","").replace("ws://","http://").replace("wss://","https://")};for(const i of y){const w=p[i.getName()];if(w)return w(i)}return null}function No({dev:y=!1,baseUrl:p,protocols:i,logger:w,children:m,session:R="new",transformMessages:C,...O}){const[K,rn]=tn.useState(!1),[Rn,un]=tn.useState([]),[Tn,dn]=tn.useState(R),[Pn,gt]=tn.useState(new Map),yn=tn.useRef(!1),xn=tn.useMemo(()=>{if(Array.isArray(i))return i;if(typeof i=="object"&&i!==null){const F=y?"localhost:8000":p||"persona.applica.guru/api",en=y?"http":"https",H=y?"ws":"wss";let Fn=Object.keys(i).map(sn=>{switch(sn){case"rest":const Un=i[sn];return Un===!0?new xr({apiUrl:`${en}://${F}`,apiKey:O.apiKey,agentId:O.agentId,logger:w}):typeof Un=="object"&&Un!==null?new xr(Un):null;case"webrtc":const Q=i[sn];return Q===!0?new Ar({webrtcUrl:`${H}://${F}/webrtc`,apiKey:O.apiKey,agentId:O.agentId,logger:w}):typeof Q=="object"&&Q!==null?new Ar(Q):null;case"websocket":const _n=i[sn];return _n===!0?new Sr({webSocketUrl:`${H}://${F}/websocket`,apiKey:O.apiKey,agentId:O.agentId,logger:w}):typeof _n=="object"&&_n!==null?new Sr(_n):null;default:throw new Error(`Unknown protocol: ${sn}`)}}).filter(sn=>sn!==null);return O.tools&&Fn.push(new ki({apiUrl:`${en}://${F}`,apiKey:O.apiKey,agentId:O.agentId,tools:O.tools,logger:w})),Fn}throw new Error("Invalid protocols configuration")},[]);tn.useEffect(()=>{yn.current||(yn.current=!0,w==null||w.debug("Initializing protocols: ",xn.map(F=>F.getName())),xn.forEach(F=>{F.setSession(Tn),F.clearListeners(),F.addStatusChangeListener(en=>{w==null||w.debug(`${F.getName()} has notified new status: ${en}`),Pn.set(F.getName(),en),en==="connected"&&(O.context&&F.sendPacket({type:"command",payload:{command:"set_initial_context",arguments:O.context}}),O.tools&&Array.isArray(O.tools)&&F.sendPacket({type:"command",payload:{command:"set_local_tools",arguments:{tools:O.tools.map(H=>H.schema)}}})),gt(new Map(Pn))}),F.addPacketListener(en=>{if(en.type==="message"){const H=en.payload;(H==null?void 0:H.finishReason)==="stop"&&!(H!=null&&H.functionResponse)&&!(H!=null&&H.thought)&&rn(!1),H.thought&&(H.type="reasoning"),un(Fn=>{const sn=Hi([...Fn,{...H,protocol:F.getName()}]);return C?C(sn):sn})}else if(en.type==="reasoning"){const Fn={type:"reasoning",text:en.payload.thought,role:"assistant",finishReason:"stop"};un(sn=>{const Un=Hi([...sn,{...Fn,protocol:F.getName()}]);return C?C(Un):Un})}else en.type==="transaction"&&xn.filter(H=>H!==F).forEach(H=>H.onTransaction(en.payload))}),F.autostart&&F.status==="disconnected"&&(w==null||w.debug(`Connecting to protocol: ${F.getName()}`),F.connect(Tn),rn(!1))}))},[Tn,xn,w,Pn,C]);const Te=async F=>{var Un;if(((Un=F.content[0])==null?void 0:Un.type)!=="text")throw new Error("Only text messages are supported");if(!xn.some(Q=>Q.getName()!=="transaction"&&Q.status==="connected")){un(Q=>{const _n=[...Q,{role:"assistant",type:"text",text:"No protocol is connected."}];return C?C(_n):_n});return}const H=F.content[0].text;un(Q=>{const _n=[...Q,{role:"user",type:"text",text:H}];return C?C(_n):_n}),rn(!0);const Fn=xn.sort((Q,_n)=>_n.getPriority()-Q.getPriority()).find(Q=>Q.status==="connected"),sn=[];if(F.attachments)for(const Q of F.attachments)Q.contentType.startsWith("image/")&&Q.file&&sn.push({role:"user",image:{contentType:Q.contentType,content:await Uo(Q.file)},text:"",type:"text"});F.content&&sn.push({role:"user",text:F.content[0].text,type:"text"}),w==null||w.debug("Sending message:",sn),await(Fn==null?void 0:Fn.sendPacket({type:"request",payload:sn}))},Hn=tn.useCallback(()=>(rn(!1),un([]),dn("new"),Promise.resolve()),[]),bt=tn.useCallback(()=>Promise.resolve(),[]),kn=tn.useCallback(()=>Rn,[Rn]),Rt=Ce.useExternalStoreRuntime({isRunning:K,messages:Rn,convertMessage:Eo,onNew:Te,onCancel:Hn,onReload:bt,adapters:{attachments:new Ce.CompositeAttachmentAdapter([new Ce.SimpleImageAttachmentAdapter])}});return pn.jsx(te.Provider,{value:{protocols:xn,protocolsStatus:Pn,getMessages:kn},children:pn.jsx(Ce.AssistantRuntimeProvider,{runtime:Rt,children:m})})}function Bo({children:y,...p}){return pn.jsx(No,{...p,children:y})}function $o(){const y=tn.useContext(te);if(!y)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return y}function Ji(y){const p=tn.useContext(te);if(!p)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=p.protocols.find(m=>m.getName()===y);if(!i)return null;const w=p.protocolsStatus.get(i.getName());return{...i,connect:i.connect.bind(i),disconnect:i.disconnect.bind(i),sendPacket:i.sendPacket.bind(i),setSession:i.setSession.bind(i),addStatusChangeListener:i.addStatusChangeListener.bind(i),addPacketListener:i.addPacketListener.bind(i),getName:i.getName.bind(i),getPriority:i.getPriority.bind(i),status:w||i.status}}function qo(){const y=tn.useContext(te);if(!y)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return Do(y.protocols)}function Ko(){return Ji("webrtc")}function Go(){const y=tn.useContext(te);if(!y)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return y.getMessages()}class zo{constructor(){E(this,"prefix","[Persona]")}log(p,...i){console.log(`${this.prefix} - ${p}`,...i)}info(p,...i){console.info(`${this.prefix} - ${p}`,...i)}warn(p,...i){console.warn(`${this.prefix} - ${p}`,...i)}error(p,...i){console.error(`${this.prefix} - ${p}`,...i)}debug(p,...i){console.debug(`${this.prefix} - ${p}`,...i)}}function Ct(y,p,i){return{type:y,description:p,...i}}function Zi(y){const p=Object.entries(y.parameters).filter(([i,w])=>w.required).map(([i])=>i);return{type:"local",name:y.name,description:y.description,config:{timeout:y.timeout||60,parameters:{type:"object",title:y.title||`${y.name} parameters`,required:p,properties:y.parameters},output:{type:"object",title:`${y.name} output`,properties:y.output}}}}function Re(y){return{schema:Zi(y),implementation:y.implementation}}function Yi(y,p,i,w,m,R){const C={name:y,description:p,title:R==null?void 0:R.title,timeout:R==null?void 0:R.timeout,parameters:w,output:m,implementation:i};return Re(C)}const Ho=Yi("sum","Sum two numbers",function(p,i){return{result:p+i}},{a:Ct("number","First number to sum",{required:!0}),b:Ct("number","Second number to sum",{required:!0})},{result:Ct("number","Sum of two numbers")}),ko=Re({name:"navigate_to",description:"Allow agent to redirect user to specific sub page like /foo or #/foo or anything like that",title:"Sum two numbers",timeout:60,parameters:{a:Ct("number","First number to sum"),b:Ct("number","Seconth number to sum")},output:{result:Ct("number","Sum of two numbers")},implementation:function(p,i){return{result:p+i}}});function Jo(y){const p=[],i={};return y.forEach(w=>{const{schema:m,implementation:R}=Re(w);p.push(m),i[w.name]=R}),{schemas:p,implementations:i}}function Zo(y,p){const{required:i,properties:w}=p.config.parameters;for(const m of i)if(!(m in y))throw new Error(`Missing required parameter: ${m}`);for(const[m,R]of Object.entries(y)){const C=w[m];if(C){if(C.type==="number"&&typeof R!="number")throw new Error(`Parameter ${m} should be a number`);if(C.type==="string"&&typeof R!="string")throw new Error(`Parameter ${m} should be a string`);if(C.type==="boolean"&&typeof R!="boolean")throw new Error(`Parameter ${m} should be a boolean`)}}return!0}$.PersonaConsoleLogger=zo,$.PersonaProtocolBase=jt,$.PersonaRESTProtocol=xr,$.PersonaRuntimeProvider=Bo,$.PersonaTransactionProtocol=ki,$.PersonaWebRTCProtocol=Ar,$.PersonaWebSocketProtocol=Sr,$.createParameter=Ct,$.createTool=Re,$.createToolFromFunction=Yi,$.createToolRegistry=Jo,$.generateToolSchema=Zi,$.navigateToToolExample=ko,$.sumTool=Ho,$.usePersonaRuntime=$o,$.usePersonaRuntimeEndpoint=qo,$.usePersonaRuntimeMessages=Go,$.usePersonaRuntimeProtocol=Ji,$.usePersonaRuntimeWebRTCProtocol=Ko,$.validateToolParameters=Zo,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});
40
28
  //# sourceMappingURL=bundle.umd.js.map