@applica-software-guru/persona-sdk 0.1.82 → 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.
- package/dist/bundle.cjs.js +18 -30
- package/dist/bundle.cjs.js.map +1 -1
- package/dist/bundle.es.js +3162 -7143
- package/dist/bundle.es.js.map +1 -1
- package/dist/bundle.iife.js +18 -30
- package/dist/bundle.iife.js.map +1 -1
- package/dist/bundle.umd.js +18 -30
- package/dist/bundle.umd.js.map +1 -1
- package/package.json +17 -12
- package/vite.config.ts +11 -1
package/dist/bundle.cjs.js
CHANGED
|
@@ -1,40 +1,28 @@
|
|
|
1
|
-
"use strict";var sb=Object.defineProperty;var ib=(n,i,r)=>i in n?sb(n,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[i]=r;var S=(n,i,r)=>ib(n,typeof i!="symbol"?i+"":i,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("react");var $n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Lu(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Bu={exports:{}},qn={};/**
|
|
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 mu;function ob(){if(mu)return qn;mu=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 qn.Fragment=i,qn.jsx=r,qn.jsxs=r,qn}Bu.exports=ob();var Pe=Bu.exports,ab=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},{}),ku=class{constructor(){S(this,"_providers",new Set);S(this,"_subscribers",new Set)}getModelContext(){return ab(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)}},ub=class{constructor(){S(this,"_contextProvider",new ku)}registerModelContextProvider(n){return this._contextProvider.registerModelContextProvider(n)}getModelContextProvider(){return this._contextProvider}},cb=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)}},hb=n=>n.status.type==="complete",Du=class extends cb{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=>hb(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)}}},lb=class extends Du{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()}};let fb=(n,i=21)=>(r=i)=>{let a="",h=r|0;for(;h--;)a+=n[Math.random()*n.length|0];return a};var Li=fb("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7),db="__optimistic__",pb=()=>`${db}${Li()}`,bn=Symbol("autoStatus"),gb=Object.freeze(Object.assign({type:"running"},{[bn]:!0})),_b=Object.freeze(Object.assign({type:"complete",reason:"unknown"},{[bn]:!0}));Object.freeze(Object.assign({type:"requires-action",reason:"tool-calls"},{[bn]:!0}));Object.freeze(Object.assign({type:"requires-action",reason:"interrupt"},{[bn]:!0}));var bb=n=>n[bn]===!0,Nu=(n,i,r,a,h)=>n&&h?Object.assign({type:"incomplete",reason:"error",error:h},{[bn]:!0}):n&&i?gb:_b,mn={exports:{}};const mb=typeof Buffer<"u",vu=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,wu=/"(?: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 Fu(n,i,r){r==null&&i!==null&&typeof i=="object"&&(r=i,i=void 0),mb&&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(vu.test(n)===!1&&wu.test(n)===!1)return a}else if(h!=="ignore"&&f==="ignore"){if(vu.test(n)===!1)return a}else if(wu.test(n)===!1)return a;return Uu(a,{protoAction:h,constructorAction:f,safe:r&&r.safe})}function Uu(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 Bi(n,i,r){const{stackTraceLimit:a}=Error;Error.stackTraceLimit=0;try{return Fu(n,i,r)}finally{Error.stackTraceLimit=a}}function vb(n,i){const{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return Fu(n,i,{safe:!0})}catch{return}finally{Error.stackTraceLimit=r}}mn.exports=Bi;mn.exports.default=Bi;mn.exports.parse=Bi;mn.exports.safeParse=vb;mn.exports.scan=Uu;var wb=mn.exports;const yu=Lu(wb);function yb(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 yi=Symbol("aui.parse-partial-json-object.meta"),Sb=n=>{if(n.length===0)return{[yi]:{state:"partial",partialPath:[]}};try{const i=yu.parse(n);if(typeof i!="object"||i===null)throw new Error("argsText is expected to be an object");return i[yi]={state:"complete",partialPath:[]},i}catch{try{const[i,r]=yb(n),a=yu.parse(i);if(typeof a!="object"||a===null)throw new Error("argsText is expected to be an object");return a[yi]={state:"partial",partialPath:r},a}catch{return}}},ki=(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:Tt,...pt}=A,ut={...pt,toolCallId:A.toolCallId??`tool-${Li()}`,...K!==void 0&&{parentId:K},...Tt!==void 0&&{messages:Tt}};return A.args?{...ut,args:A.args,argsText:A.argsText??JSON.stringify(A.args)}:{...ut,args:Sb(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}`)}}},Di={fromArray:n=>{const i=n.map(r=>ki(r,Li(),Nu(!1,!1,!1,!1,void 0)));return{messages:i.map((r,a)=>({parentId:a>0?i[a-1].id:null,message:r}))}}},Kr=n=>n.next?Kr(n.next):"current"in n?n:null,xb=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}},Wu=class{constructor(){S(this,"messages",new Map);S(this,"head",null);S(this,"root",{children:[],next:null});S(this,"_messages",new xb(()=>{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],(Kr(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=pb();while(this.messages.has(r));return this.addOrUpdateMessage(n,ki(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=Kr(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=Kr(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)}},Xr=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()}}},re=Symbol("skip-update"),Ni=class extends Xr{constructor(i){super();S(this,"_previousStateDirty",!0);S(this,"_previousState");S(this,"getState",()=>{if(!this.isConnected||this._previousStateDirty){const i=this.binding.getState();i!==re&&(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)}},Hr=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 Eb(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 ne=class extends Xr{constructor(i){super();S(this,"_previousState");S(this,"getState",()=>(this.isConnected||this._syncState(),this._previousState));this.binding=i;const r=i.getState();if(r===re)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===re||Eb(i,this._previousState)?!1:(this._previousState=i,!0)}_connect(){const i=()=>{this._syncState()&&this.notifySubscribers()};return this.binding.subscribe(i)}},_n=Symbol("innerMessage"),Tb=n=>n[_n],Jn=n=>n.content.filter(r=>r.type==="text").map(r=>r.text).join(`
|
|
12
|
-
|
|
13
|
-
`),$u=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)}},qu=class extends $u{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)}},Ab=class extends qu{get source(){return"thread-composer"}},Cb=class extends qu{get source(){return"edit-composer"}},Ib=class extends $u{get source(){return"message"}constructor(n){super(n)}remove(){throw new Error("Message attachments cannot be removed")}},zu=class extends Xr{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()}}},Hu=Object.freeze([]),Ju=Object.freeze({}),Rb=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)??Hu,text:(n==null?void 0:n.text)??"",role:(n==null?void 0:n.role)??"user",runConfig:(n==null?void 0:n.runConfig)??Ju,attachmentAccept:(n==null?void 0:n.attachmentAccept)??"",value:(n==null?void 0:n.text)??""}),Mb=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)??Hu,runConfig:(n==null?void 0:n.runConfig)??Ju,attachmentAccept:(n==null?void 0:n.attachmentAccept)??"",value:(n==null?void 0:n.text)??""}),Gu=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 zu({event:n,binding:this._core}),this._eventSubscriptionSubjects.set(n,r)),r.subscribe(i)}},Pb=class extends Gu{constructor(i){const r=new Ni({path:i.path,getState:()=>Rb(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 Ab(new ne({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"}:re},subscribe:r=>this._core.subscribe(r)}),this._core)}},Ob=class extends Gu{constructor(i,r){const a=new Ni({path:i.path,getState:()=>Mb(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 Cb(new ne({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"}:re},subscribe:r=>this._core.subscribe(r)}),this._core)}},Su=Symbol.for("aui.tool-response"),Lb=class Ci{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[Su](){return!0}static[Symbol.hasInstance](i){return typeof i=="object"&&i!==null&&Su in i}static toResponse(i){return i instanceof Ci?i:new Ci({result:i===void 0?"<no result>":i})}},xu=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=Lb.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)}},Yr=class extends Xr{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()}}},Jr=Object.freeze({type:"complete"}),Bb=(n,i,r)=>{if(n.role!=="assistant")return Jr;if(r.type==="tool-call")return r.result?Jr:n.status;const a=i===Math.max(0,n.content.length-1);return n.status.type==="requires-action"?Jr:a?n.status:Jr},Eu=(n,i)=>{const r=n.content[i];if(!r)return re;const a=Bb(n,i,r);return Object.freeze({...r,[_n]:r[_n],status:a})},kb=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 Ob(new Yr({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 Jn(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 xu(new ne({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${n}]`,messagePartSelector:{type:"index",index:n}},getState:()=>Eu(this.getState(),n),subscribe:i=>this._core.subscribe(i)}),this._core,this._threadBinding)}getMessagePartByToolCallId(n){return new xu(new ne({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?re:Eu(i,r)},subscribe:i=>this._core.subscribe(i)}),this._core,this._threadBinding)}getAttachmentByIndex(n){return new Ib(new ne({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"}:re},subscribe:i=>this._core.subscribe(i)}))}},Db=n=>({parentId:n.parentId??null,sourceId:n.sourceId??null,runConfig:n.runConfig??{},...n.stream?{stream:n.stream}:{}}),Nb=n=>({parentId:n.parentId??null,sourceId:n.sourceId??null,runConfig:n.runConfig??{}}),Fb=(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}},Ub=(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})},Wb=class{constructor(n,i){S(this,"_threadBinding");S(this,"composer");S(this,"_eventSubscriptionSubjects",new Map);const r=new ne({path:n.path,getState:()=>Ub(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 Pb(new Yr({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(Fb(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(Nb(i))}unstable_resumeRun(n){return this._threadBinding.getState().resumeRun(Db(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 kb(new ne({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 re;const w=this._threadBinding.getState().getBranches(r.id),I=r.metadata.submittedFeedback;return{...r,[_n]:r[_n],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 zu({event:n,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(n,r)),r.subscribe(i)}},$b=n=>({mainThreadId:n.mainThreadId,newThread:n.newThreadId,threads:n.threadIds,archivedThreads:n.archivedThreadIds,isLoading:n.isLoading,threadItems:n.threadData}),Gr=(n,i)=>{if(i===void 0)return re;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}:re},qb=class{constructor(n,i=Wb){S(this,"_getState");S(this,"_mainThreadListItemRuntime");S(this,"main");this._core=n,this._runtimeFactory=i;const r=new Ni({path:{},getState:()=>$b(n),subscribe:a=>n.subscribe(a)});this._getState=r.getState.bind(r),this._mainThreadListItemRuntime=new Hr(new ne({path:{ref:"threadItems[main]",threadSelector:{type:"main"}},getState:()=>Gr(this._core,this._core.mainThreadId),subscribe:a=>this._core.subscribe(a)}),this._core),this.main=new i(new Yr({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 Yr({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 Hr(new ne({path:{ref:`threadItems[${n}]`,threadSelector:{type:"index",index:n}},getState:()=>Gr(this._core,this._core.threadIds[n]),subscribe:i=>this._core.subscribe(i)}),this._core)}getArchivedItemByIndex(n){return new Hr(new ne({path:{ref:`archivedThreadItems[${n}]`,threadSelector:{type:"archiveIndex",index:n}},getState:()=>Gr(this._core,this._core.archivedThreadIds[n]),subscribe:i=>this._core.subscribe(i)}),this._core)}getItemById(n){return new Hr(new ne({path:{ref:`threadItems[threadId=${n}]`,threadSelector:{type:"threadId",threadId:n}},getState:()=>Gr(this._core,n),subscribe:i=>this._core.subscribe(i)}),this._core)}},zb=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 Hb(n.file)}]}}async remove(){}},Hb=n=>new Promise((i,r)=>{const a=new FileReader;a.onload=()=>i(a.result),a.onerror=h=>r(h),a.readAsDataURL(n)});function Si(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 Jb=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(Si(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(Si(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(Si({name:n.name,type:n.contentType},r.accept))return r.remove(n);throw new Error("No matching adapter found for attachment")}},Gb=U.createContext(null),Kb=()=>U.useContext(Gb),Je=Object.freeze([]),Ge="DEFAULT_THREAD_ID",Yb=Object.freeze([Ge]),Ku=Object.freeze({id:Ge,remoteId:void 0,externalId:void 0,status:"regular"}),Vb=Promise.resolve(),Tu=Object.freeze({[Ge]:Ku}),Zb=class{constructor(n={},i){S(this,"_mainThreadId",Ge);S(this,"_threads",Yb);S(this,"_archivedThreads",Je);S(this,"_threadData",Tu);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 Vb}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===Ge)return Ku}__internal_setAdapter(n,i=!1){var I,P,C,A;const r=this.adapter;this.adapter=n;const a=n.threadId??Ge,h=n.threads??Je,f=n.archivedThreads??Je,p=r.threadId??Ge,m=r.threads??Je,w=r.archivedThreads??Je;!i&&p===a&&m===h&&w===f||(this._threadData={...Tu,...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))??Je),w!==f&&(this._archivedThreads=((A=this.adapter.archivedThreads)==null?void 0:A.map(R=>R.id))??Je),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()}},Au=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})}},Xb=class extends Du{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=Jn(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){Jn(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()}},Qb=class{constructor(n){S(this,"_subscriptions",new Set);S(this,"_isInitialized",!1);S(this,"repository",new Wu);S(this,"composer",new lb(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 Xb(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(Jn(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(Di.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)}}},jb=Object.freeze([]),tm=(n,i)=>{var r;return n&&((r=i[i.length-1])==null?void 0:r.role)!=="assistant"},em=class extends Qb{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 Au);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(Tb).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??jb,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 Au;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,Tt=Nu(K,r,!1,!1,void 0);if(C&&(C.role!=="assistant"||!bb(C.status)||C.status===Tt))return C;const pt=i.convertMessage(A,R),ut=ki(pt,R.toString(),Tt);return ut[_n]=A,ut}):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),tm(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(Jn(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 Wu;r.import(Di.fromArray(i??[])),this.updateMessages(r.getMessages())}import(i){this._assistantOptimisticId=null,super.import(i),this._store.onImport&&this._store.onImport(this.repository.getMessages())}},Cu=n=>{var i;return((i=n.adapters)==null?void 0:i.threadList)??{}},nm=class extends ub{constructor(i){super();S(this,"threads");this.threads=new Zb(Cu(i),()=>new em(this._contextProvider,i))}setAdapter(i){this.threads.__internal_setAdapter(Cu(i)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(i)}},rm=n=>{const[i]=U.useState(()=>new nm(n));U.useEffect(()=>{i.setAdapter(n)});const{modelContext:r}=Kb()??{};return U.useEffect(()=>{if(r)return i.registerModelContextProvider(r)},[r,i]),U.useMemo(()=>new av(i),[i])};function sm(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 im(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 zn=null;function om(n,i){n.currentIndex=0;const r=zn;zn=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{zn=r}}function Fi(){if(!zn)throw new Error("No resource fiber available");return zn}function Yu(n,i){const r=n[Vu];if(!r)throw new Error("ResourceElement.type is not a valid Resource");return r(i)}var Vu=Symbol("fnSymbol");function Qr(n,i){return{resource:n,scheduleRerender:i,cells:[],currentIndex:0,renderContext:void 0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function pn(n){n.isMounted=!1,im(n)}function Gn(n,i){const r={commitTasks:[],props:i,state:void 0};return om(n,()=>{n.renderContext=r;try{r.state=Yu(n.resource,i)}finally{n.renderContext=void 0}}),r}function gn(n,i){n.isMounted=!0,n.isNeverMounted=!1,sm(i,n)}var am=globalThis.__ASSISTANT_UI_DISABLE_LAYOUT_EFFECT__===!0,Iu=am?U.useEffect:U.useLayoutEffect;function um(n){const[,i]=U.useState({}),r=U.useMemo(()=>Qr(n.type,()=>i({})),[n.type,i]),a=Gn(r,n.props);return Iu(()=>()=>pn(r),[]),Iu(()=>{gn(r,a)}),a.state}var Zu=n=>typeof n=="string"?{scope:n.split(".")[0],event:n}:{scope:n.scope,event:n.event},xi=(n,i,r)=>i===n,dn,Ei=()=>{if(dn)return dn;const n=()=>({apis:new Map,nextId:0,listeners:new Set});if(typeof window>"u")return dn=n(),dn;const i=window.__ASSISTANT_UI_DEVTOOLS_HOOK__;if(i)return dn=i,i;const r=n();return window.__ASSISTANT_UI_DEVTOOLS_HOOK__=r,dn=r,r},ee,cm=(ee=class{static register(i){var m,w;const r=Ei();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>ee.MAX_EVENT_LOGS_PER_API&&(P.logs=P.logs.slice(-200)),ee.notifyListeners(a))}),p=(w=i.subscribe)==null?void 0:w.call(i,()=>{ee.notifyListeners(a)});return r.apis.set(a,h),ee.notifyListeners(a),()=>{const I=Ei();I.apis.get(a)&&(f==null||f(),p==null||p(),I.apis.delete(a),ee.notifyListeners(a))}}static notifyListeners(i){Ei().listeners.forEach(a=>a(i))}},S(ee,"MAX_EVENT_LOGS_PER_API",200),ee);function dt(n){const i=(r,a)=>({type:i,props:r,...(a==null?void 0:a.key)!==void 0&&{key:a.key}});return i[Vu]=n,i}var hm=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 lm(n){const i=Fi(),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,hm(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 ce(n){const i=lm(n);return[i.value,i.set]}function fm(){const n=Fi(),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 Dt(n,i){const r=Fi(),a=fm();r.renderContext.commitTasks.push({effect:n,deps:i,cellIndex:a})}function Vr(n){const[i]=ce(()=>({current:n}));return i}var dm=(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=Vr();return r.current||(r.current={value:n(),deps:i}),dm(r.current.deps,i)||(r.current.value=n(),r.current.deps=i),r.current.value};function Ti(n,i){const[r,a]=ce({}),h=rt(()=>Qr(n.type,()=>a({})),[n.type]),f=i?rt(()=>n.props,i):n.props,p=rt(()=>Gn(h,f),[h,f,r]);return Dt(()=>()=>pn(h),[h]),Dt(()=>{gn(h,p)},[h,p]),p.state}function se(n){return Yu(n.type,n.props)}function pm(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]=ce({}),h=rt(()=>new Map(n.map(m=>[m.key,m])),[n]),[f]=ce(()=>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&&pn(C),C=Qr(I.type,()=>a({})),f.set(P,C));const A=Gn(C,I.props);m.set(P,A)}),f.forEach((I,P)=>{w.has(P)||(pn(I),f.delete(P))}),m},[h,r]);return Dt(()=>{p.forEach((m,w)=>{const I=f.get(w);I&&gn(I,m)})},[p,f]),Dt(()=>()=>{f.forEach(m=>{pn(m)}),f.clear()},[f]),rt(()=>n.map(m=>{var w;return(w=p.get(m.key))==null?void 0:w.state}),[n,p])}var Ii=[],Ri=!1;function gm(){Ri=!1;const n=Ii;Ii=[];for(const i of n)try{i()}catch(r){console.error("Error in scheduled task:",r)}}function _m(n){Ii.push(n),Ri||(Ri=!0,queueMicrotask(gm))}var Ke,bm=(Ke=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,_m(()=>{this._hasScheduledTask=!1,this.flushSync()}))}flushSync(){if(this._isFlushing)return;this._isFlushing=!0;let i=0;try{for(;this._isDirty;){if(i++,i>Ke.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(Ke,"MAX_FLUSH_DEPTH",50),Ke),mm=dt(({element:n,onUpdateInput:i,onFlushSync:r,onDispose:a})=>{const[h,f]=ce(n.props),p=se({type:n.type,props:h}),m=Vr(new Set).current,w=Vr(p);return Dt(()=>{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}),[])}),vm=(n,i=!1)=>{let r=!i;const a={element:n,onUpdateInput:()=>{r||(r=!0,gn(f,p))},onFlushSync:()=>{h.flushSync()},onDispose:()=>pn(f)},h=new bm(()=>{p=Gn(f,a),r&&gn(f,p)}),f=Qr(mm,()=>h.markDirty());let p=Gn(f,a);return r&&gn(f,p),p.state},Hn=Symbol("tap.Context"),Xu=n=>({[Hn]:n}),Qu=(n,i,r)=>{const a=n[Hn];n[Hn]=i;try{return r()}finally{n[Hn]=a}},ju=n=>n[Hn];const Ru=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},wm=n=>n?Ru(n):Ru,ym=n=>n;function Sm(n,i=ym){const r=U.useSyncExternalStore(n.subscribe,U.useCallback(()=>i(n.getState()),[n,i]),U.useCallback(()=>i(n.getInitialState()),[n,i]));return U.useDebugValue(r),r}const Mu=n=>{const i=wm(n),r=a=>Sm(i,a);return Object.assign(r,i),r},xm=n=>n?Mu(n):Mu;var Em=dt(n=>{const i=rt(()=>vm(n,!0),[n.type]);return Dt(()=>{i.updateInput(n.props)}),i}),Tm=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}},he=(n,i)=>{const r=Vr(n);Dt(()=>{r.current=n});const a=rt(()=>new Proxy({},new Tm(()=>r.current)),[]),h=i==null?void 0:i.key,f=n.getState();return rt(()=>({key:h,state:f,api:a}),[f,h])},tc=Xu(null),Am=(n,i)=>Qu(tc,n,i),ec=()=>{const n=ju(tc);if(!n)throw new Error("Model context is not available in this context");return n},Cm=dt(({toolkit:n})=>{const[i,r]=ce(()=>({tools:{}})),a=ec();Dt(()=>{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 he({getState:()=>i,setToolUI:h})}),Im=dt(()=>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})})}}},[])),nc=Xu(null),Rm=(n,i)=>Qu(nc,n,i),Ui=()=>{const n=ju(nc);if(!n)throw new Error("Events context is not available");return n},Mm=dt(()=>{const[n]=ce(()=>({})),i=new ku;return he({getState:()=>n,getModelContext:()=>i.getModelContext(),subscribe:r=>i.subscribe(r),register:r=>i.registerModelContextProvider(r)})}),Pm=dt(({threads:n,modelContext:i,tools:r})=>{const a=se(Im()),{threads:h,tools:f,modelContext:p}=Rm(a,()=>{const w=Ti(i??Mm(),[i]);return Am(w.api,()=>({modelContext:w,tools:Ti(r??Cm({}),[r]),threads:Ti(n,[n])}))}),m=rt(()=>({threads:h.state,tools:f.state,modelContext:p.state}),[h.state,f.state,p.state]);return he({getState:()=>m,threads:h.api,tools:f.api,modelContext:p.api,on:a.on})}),Om=n=>{const i=()=>n.getState().api.threads.item("main");return{threads:Et({source:"root",query:{},get:()=>n.getState().api.threads}),tools:Et({source:"root",query:{},get:()=>n.getState().api.tools}),modelContext:Et({source:"root",query:{},get:()=>n.getState().api.modelContext}),thread:Et({source:"threads",query:{type:"main"},get:()=>n.getState().api.threads.thread("main")}),threadListItem:Et({source:"threads",query:{type:"main"},get:()=>i()}),composer:Et({source:"thread",query:{},get:()=>n.getState().api.threads.thread("main").composer}),on(r,a){const{event:h,scope:f}=Zu(r);if(f==="*")return n.getState().api.on(h,a);if(xi("thread",f)||xi("thread-list-item",f)||xi("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}},Lm=n=>{const i=sc(),r=um(Em(Pm(n))),a=U.useMemo(()=>Om(r),[r]);return U.useMemo(()=>Fm(i,a),[i,a])},Et=n=>{const i=n.get;return i.source=n.source,i.query=n.query,i},Oe=()=>()=>{},rc=U.createContext({threads:Et({source:null,query:{},get:()=>{throw new Error("Threads is only available inside <AssistantProvider />")}}),tools:Et({source:null,query:{},get:()=>{throw new Error("Tools is only available inside <AssistantProvider />")}}),modelContext:Et({source:null,query:{},get:()=>{throw new Error("ModelContext is only available inside <AssistantProvider />")}}),threadListItem:Et({source:null,query:{},get:()=>{throw new Error("ThreadListItem is only available inside <AssistantProvider />")}}),thread:Et({source:null,query:{},get:()=>{throw new Error("Thread is only available inside <AssistantProvider />")}}),composer:Et({source:null,query:{},get:()=>{throw new Error("Composer is only available inside <AssistantProvider />")}}),message:Et({source:null,query:{},get:()=>{throw new Error("Message is only available inside <ThreadPrimitive.Messages />")}}),part:Et({source:null,query:{},get:()=>{throw new Error("Part is only available inside <MessagePrimitive.Parts />")}}),attachment:Et({source:null,query:{},get:()=>{throw new Error("Attachment is only available inside <MessagePrimitive.Attachments /> or <ComposerPrimitive.Attachments />")}}),subscribe:Oe,flushSync:Oe,on:n=>{const{scope:i}=Zu(n);throw new Error(`Event scope is not available in this component: ${i}`)}}),sc=()=>U.useContext(rc),Bm=n=>Lm(n);function km(n){return n?Bm(n):sc()}var Dm=(n,i)=>n===Oe?i:i===Oe?n:(...r)=>{n(...r),i(...r)},Nm=(n,i)=>n===Oe?i:i===Oe?n:(...r)=>{const a=n(...r),h=i(...r);return()=>{a(),h()}},Fm=(n,i)=>{const r=i.subscribe,a=i.flushSync;return{...n,...i,subscribe:Nm(n.subscribe,r??Oe),flushSync:Dm(n.flushSync,a??Oe)}},Um=({api:n,children:i,devToolsVisible:r=!0})=>(U.useEffect(()=>{if(!(!r||!n.subscribe))return cm.register(n)},[n,r]),Pe.jsx(rc.Provider,{value:n,children:i}));function Wm(n,i){function r(a){const h=U.useContext(n);if(!(a!=null&&a.optional)&&!h)throw new Error(`This component must be used within ${i}.`);return h}return r}function $m(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 ic=U.createContext(null),qm=Wm(ic,"ThreadPrimitive.Viewport"),{useThreadViewportStore:zm}=$m(qm,"useThreadViewport"),Ve=n=>{const[,i]=ce(n.getState);return Dt(()=>(i(n.getState()),n.subscribe(()=>{i(n.getState())})),[n]),n.getState()},Hm=dt(({runtime:n})=>{const i=Ve(n),r=Ui();return Dt(()=>{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]),he({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})}),Kn=n=>{const i=pm(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}}},oc=dt(({runtime:n})=>{const i=Ve(n);return he({getState:()=>i,remove:n.remove,__internal_getRuntime:()=>n},{key:i.id})}),Jm=dt(({runtime:n,index:i})=>{const r=rt(()=>n.getAttachmentByIndex(i),[n,i]);return se(oc({runtime:r}))}),ac=dt(({threadIdRef:n,messageIdRef:i,runtime:r})=>{const a=Ve(r),h=Ui();Dt(()=>{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=Kn(a.attachments.map((m,w)=>Jm({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 he({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})}),Gm=dt(({runtime:n})=>{const i=Ve(n);return he({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})}),Km=dt(({runtime:n,index:i})=>{const r=rt(()=>n.getAttachmentByIndex(i),[n,i]);return se(oc({runtime:r}))}),Ym=dt(({runtime:n,index:i})=>{const r=rt(()=>n.getMessagePartByIndex(i),[n,i]);return se(Gm({runtime:r}))}),Vm=dt(({runtime:n,threadIdRef:i})=>{var A;const r=Ve(n),[a,h]=ce(!1),[f,p]=ce(!1),m=rt(()=>({get current(){return n.getState().id}}),[n]),w=se(ac({runtime:n.composer,threadIdRef:i,messageIdRef:m})),I=Kn(r.content.map((R,K)=>Ym({runtime:n,index:K},{key:K}))),P=Kn(((A=r.attachments)==null?void 0:A.map((R,K)=>Km({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 he({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})}),Zm=dt(({runtime:n,id:i,threadIdRef:r})=>{const a=rt(()=>n.getMessageById(i),[n,i]);return se(Vm({runtime:a,threadIdRef:r}))}),Xm=dt(({runtime:n})=>{const i=Ve(n),r=Ui();Dt(()=>{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=se(ac({runtime:n.composer,threadIdRef:a})),f=Kn(i.messages.map(m=>Zm({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 he({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})}),Qm=dt(({runtime:n,id:i})=>{const r=rt(()=>n.getItemById(i),[n,i]);return se(Hm({runtime:r}))}),jm=dt(({runtime:n,__internal_assistantRuntime:i})=>{const r=Ve(n),a=se(Xm({runtime:n.main})),h=Kn(Object.keys(r.threadItems).map(p=>Qm({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 he({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})}),tv=dt(n=>{const i=ec();return Dt(()=>n.registerModelContextProvider(i),[n,i]),se(jm({runtime:n.threads,__internal_assistantRuntime:n}))}),Ai=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()}}}}},ev=(n={})=>{const i=new Set,r=Ai(p=>{f.setState({height:{...f.getState().height,viewport:p}})}),a=Ai(p=>{f.setState({height:{...f.getState().height,inset:p}})}),h=Ai(p=>{f.setState({height:{...f.getState().height,userMessage:p}})}),f=xm(()=>({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},Pu=n=>n,nv=n=>{const i=zm({optional:!0}),[r]=U.useState(()=>ev(n));return U.useEffect(()=>i==null?void 0:i.getState().onScrollToBottom(()=>{r.getState().scrollToBottom()}),[i,r]),U.useEffect(()=>{if(i)return r.subscribe(a=>{i.getState().isAtBottom!==a.isAtBottom&&Pu(i).setState({isAtBottom:a.isAtBottom})})},[r,i]),U.useEffect(()=>{const a={turnAnchor:n.turnAnchor??"bottom"};r.getState().turnAnchor!==a.turnAnchor&&Pu(r).setState(a)},[r,n.turnAnchor]),r},rv=({children:n,options:i={}})=>{const r=nv(i),[a]=U.useState(()=>({useThreadViewport:r}));return Pe.jsx(ic.Provider,{value:a,children:n})},sv=n=>{var i;return(i=n._core)==null?void 0:i.RenderComponent},iv=({children:n,runtime:i})=>{const r=km({threads:tv(i)}),a=sv(i);return Pe.jsxs(Um,{api:r,children:[a&&Pe.jsx(a,{}),Pe.jsx(rv,{children:n})]})},ov=U.memo(iv),av=class{constructor(n){S(this,"threads");S(this,"_thread");this._core=n,this.threads=new qb(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(Di.fromArray(n??[]))}};function uv(n){return n.filter(i=>i.finishReason==="stop"?i.text!==null&&i.text.trim()!=="":!0)}function Ou(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),uv(i)}function cv(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 Yn{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 Mi extends Yn{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(Tt=>({type:"message",payload:Tt})))}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 Pi extends Yn{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 hv{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 Oi extends Yn{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 hv(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 Zr={exports:{}};/**
|
|
1
|
+
"use strict";var md=Object.defineProperty;var yd=(m,g,i)=>g in m?md(m,g,{enumerable:!0,configurable:!0,writable:!0,value:i}):m[g]=i;var E=(m,g,i)=>yd(m,typeof g!="symbol"?g+"":g,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $i=require("react/jsx-runtime"),vn=require("react"),_r=require("@assistant-ui/react");function xd(m){return m.filter(g=>g.finishReason==="stop"?g.text!==null&&g.text.trim()!=="":!0)}function So(m){const g=[];let i=null;for(const y of m)if(y.type!=="transaction")if(y.file){i&&(g.push(i),i=null),g.push(y);continue}else y.functionCalls?(i&&g.push(i),g.push(y),i=null):y.functionResponse?g[g.length-1]={...g[g.length-1],functionResponse:y.functionResponse}:i&&y.type===i.type&&y.protocol===i.protocol&&i.role===y.role?(i.text+=y.text,i.file=i.file||y.file):(i&&g.push(i),i={...y,text:y.file?"":y.text,finishReason:y.file?void 0:y.finishReason});return i&&g.push(i),xd(g)}function Sd(m){var i;const g=m.file?[{type:"file",data:m.file.url,mimeType:m.file.contentType}]:[];return m.role==="function"?{id:m.id,role:"assistant",status:(m==null?void 0:m.functionResponse)===null?{type:"running"}:{type:"complete",reason:"stop"},content:((i=m.functionCalls)==null?void 0:i.map(w=>{var y;return{type:"tool-call",toolName:w.name,toolCallId:w.id,args:w.args,result:(y=m.functionResponse)==null?void 0:y.result}}))??[]}:{id:m.id,role:m.role,content:m.type==="reasoning"?[{type:"reasoning",text:m.text},...g]:[{type:"text",text:m.text},...g]}}class ye{constructor(){E(this,"statusChangeCallbacks",[]);E(this,"messageCallbacks",[])}addStatusChangeListener(g){this.statusChangeCallbacks.push(g)}addPacketListener(g){this.messageCallbacks.push(g)}async syncSession(g){this.session=g}async notifyPacket(g){this.messageCallbacks.forEach(i=>i(g))}async notifyPackets(g){g.forEach(i=>{this.messageCallbacks.forEach(w=>w(i))})}async setSession(g){this.session=g}async setStatus(g){const i=this.status!==g;this.status=g,i&&this.statusChangeCallbacks.forEach(w=>w(g))}clearListeners(){this.statusChangeCallbacks=[],this.messageCallbacks=[]}onTransaction(g){}}class qi extends ye{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 q,tn,An,en,bn;const{apiUrl:w,apiKey:y,agentId:R}=this.config,A=this.session??"new";if(i.type==="command"&&((q=i==null?void 0:i.payload)==null?void 0:q.command)=="set_initial_context"){this.context=(tn=i==null?void 0:i.payload)==null?void 0:tn.arguments;return}else if(i.type==="command"&&((An=i==null?void 0:i.payload)==null?void 0:An.command)=="set_local_tools"){const hn=(en=i==null?void 0:i.payload)==null?void 0:en.arguments.tools;(hn==null?void 0:hn.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 Rn=await(await fetch(`${w}/sessions/${A}/messages`,{body:JSON.stringify({agentId:R,userMessage:O,initialContext:this.context,tools:this.tools}),method:"POST",headers:{"Content-Type":"application/json","x-persona-apikey":y}})).json();this.notifyPackets(Rn.response.messages.map(ct=>({type:"message",payload:ct})))}catch(hn){this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"An error occurred while processing your request. Please try again later."}}),(bn=this.config.logger)==null||bn.error("Error sending packet:",hn)}}}class Ki extends ye{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 y=encodeURIComponent(this.config.apiKey),R=this.config.agentId,A=`${this.config.webSocketUrl}?sessionCode=${w}&agentId=${R}&apiKey=${y}`;return this.setStatus("connecting"),this.webSocket=new WebSocket(A),this.webSocket.addEventListener("open",()=>{this.setStatus("connected")}),this.webSocket.addEventListener("message",q=>{const tn=JSON.parse(q.data);this.notifyPacket(tn)}),this.webSocket.addEventListener("close",q=>{var tn;this.setStatus("disconnected"),this.webSocket=null,q.code!==1e3&&(this.notifyPacket({type:"message",payload:{role:"assistant",type:"text",text:"Oops! The connection to the server was lost. Please try again later."}}),(tn=this.config.logger)==null||tn.warn("WebSocket connection closed"))}),this.webSocket.addEventListener("error",()=>{var q;this.setStatus("disconnected"),this.webSocket=null,(q=this.config.logger)==null||q.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 Cd{constructor(g){E(this,"config");E(this,"pc",null);E(this,"ws",null);E(this,"localStream",null);E(this,"remoteStream",new MediaStream);E(this,"audioCtx",null);E(this,"localAnalyser",null);E(this,"remoteAnalyser",null);E(this,"analyzerFrame",null);E(this,"dataChannel",null);E(this,"isConnected",!1);E(this,"visualizerCallbacks",[]);E(this,"messageCallbacks",[]);E(this,"errorCallbacks",[]);E(this,"queuedMessages",[]);this.config=g}async connect(g){var w;if(this.isConnected)return;this.isConnected=!0;try{this.localStream=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(y){(w=this.config.logger)==null||w.error("Error accessing microphone:",y);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(y=>{this.pc.addTrack(y,this.localStream)}),this.pc.ontrack=y=>{y.streams[0].getTracks().forEach(A=>{this.remoteStream.addTrack(A)}),this.audioCtx||this._startAnalyzers();const R=new Audio;R.srcObject=this.remoteStream,R.play().catch(A=>{var O;(O=this.config.logger)==null||O.error("Error playing remote audio:",A)})},this.pc.onicecandidate=y=>{var R;y.candidate&&((R=this.ws)==null?void 0:R.readyState)===WebSocket.OPEN&&this.ws.send(JSON.stringify({type:"CANDIDATE",src:"client",payload:{candidate:y.candidate}}))},this.pc.ondatachannel=y=>{const R=y.channel;R.onmessage=A=>{this.messageCallbacks.forEach(O=>{O(A)})},R.onopen=()=>{var A;for(;this.queuedMessages.length>0;){const O=this.queuedMessages.shift();O&&(R.send(JSON.stringify(O)),(A=this.config.logger)==null||A.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,q;const y=await this.pc.createOffer();await this.pc.setLocalDescription(y);const R={apiKey:this.config.apiKey,agentId:this.config.agentId,sessionCode:g};(O=this.config.logger)==null||O.debug("Opening connection to WebRTC server: ",R);const A={type:"OFFER",src:((q=crypto.randomUUID)==null?void 0:q.call(crypto))||"client_"+Date.now(),payload:{sdp:{sdp:y.sdp,type:y.type},connectionId:(Date.now()%1e6).toString(),metadata:R}};this.ws.send(JSON.stringify(A))},this.ws.onmessage=async y=>{var A;const R=JSON.parse(y.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){(A=this.config.logger)==null||A.error("Error adding ICE candidate:",O)}},this.ws.onclose=y=>{y.code!==1e3&&this.errorCallbacks.forEach(R=>{R("Oops! The connection to the server was lost. Please try again later.")}),this._stopAnalyzers()}}async disconnect(){var g;this.isConnected&&(this.isConnected=!1,((g=this.ws)==null?void 0:g.readyState)===WebSocket.OPEN&&this.ws.close(),this.pc&&this.pc.close(),this.localStream&&this.localStream.getTracks().forEach(i=>i.stop()),this.remoteStream=new MediaStream,this.audioCtx&&(await this.audioCtx.close(),this.audioCtx=null),this._stopAnalyzers())}addVisualizerCallback(g){this.visualizerCallbacks.push(g)}addMessageCallback(g){this.messageCallbacks.push(g)}addErrorCallback(g){this.errorCallbacks.push(g)}createDataChannel(g="messages"){this.pc&&(this.dataChannel=this.pc.createDataChannel(g),this.dataChannel.onopen=()=>{var i,w;for((i=this.config.logger)==null||i.info("Data channel opened");this.queuedMessages.length>0;){const y=this.queuedMessages.shift();y&&(this.dataChannel.send(JSON.stringify(y)),(w=this.config.logger)==null||w.info("Sent queued message:",y))}},this.dataChannel.onmessage=i=>{this.messageCallbacks.forEach(w=>{w(i)})})}sendPacket(g){var i;if(!this.dataChannel||this.dataChannel.readyState!=="open"){this.queuedMessages.push(g);return}this.dataChannel.send(JSON.stringify(g)),(i=this.config.logger)==null||i.info("Sent message:",g)}_startAnalyzers(){if(!this.localStream||!this.remoteStream||this.visualizerCallbacks.length===0)return;this.audioCtx=new(window.AudioContext||window.webkitAudioContext);const g=this.audioCtx.createMediaStreamSource(this.localStream),i=this.audioCtx.createMediaStreamSource(this.remoteStream);this.localAnalyser=this.audioCtx.createAnalyser(),this.remoteAnalyser=this.audioCtx.createAnalyser(),this.localAnalyser.fftSize=256,this.remoteAnalyser.fftSize=256,g.connect(this.localAnalyser),i.connect(this.remoteAnalyser);const w=()=>{if(!this.localAnalyser||!this.remoteAnalyser||this.visualizerCallbacks.length===0)return;const y=new Uint8Array(this.localAnalyser.frequencyBinCount),R=new Uint8Array(this.remoteAnalyser.frequencyBinCount);this.localAnalyser.getByteFrequencyData(y),this.remoteAnalyser.getByteFrequencyData(R);const A=y.reduce((q,tn)=>q+tn,0)/y.length,O=R.reduce((q,tn)=>q+tn,0)/R.length;this.visualizerCallbacks.length>0&&this.visualizerCallbacks.forEach(q=>{q({localAmplitude:A,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 Gi extends ye{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 Cd(i),this.webRTCClient.addMessageCallback(w=>{const y=JSON.parse(w.data);this.notifyPacket(y)}),this.webRTCClient.addErrorCallback(w=>{var y;(y=this.config.logger)==null||y.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,y;if(this.status==="disconnected")return(i=this.config.logger)==null||i.warn("Already disconnected"),Promise.resolve();await this.webRTCClient.disconnect(),this.setStatus("disconnected"),(y=(w=this.config)==null?void 0:w.logger)==null||y.debug("Disconnected from WebRTC")}sendPacket(i){return this.status!=="connected"?Promise.reject(new Error("Not connected")):(this.webRTCClient.sendPacket(i),Promise.resolve())}}var me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ad(m){return m&&m.__esModule&&Object.prototype.hasOwnProperty.call(m,"default")?m.default:m}var vr={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
|
-
*/Zr.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,Tt=2,pt=1,ut=2,Zn=4,Kt=8,Le=16,Yt=32,Be=64,q=128,ct=256,X=512,Nt=30,ht="...",Ft=800,st=16,wt=1,fc=2,dc=3,ke=1/0,ye=9007199254740991,pc=17976931348623157e292,Xn=NaN,ie=4294967295,gc=ie-1,_c=ie>>>1,bc=[["ary",q],["bind",pt],["bindKey",ut],["curry",Kt],["curryRight",Le],["flip",X],["partial",Yt],["partialRight",Be],["rearg",ct]],Ze="[object Arguments]",Qn="[object Array]",mc="[object AsyncFunction]",vn="[object Boolean]",wn="[object Date]",vc="[object DOMException]",jn="[object Error]",tr="[object Function]",Wi="[object GeneratorFunction]",Vt="[object Map]",yn="[object Number]",wc="[object Null]",le="[object Object]",$i="[object Promise]",yc="[object Proxy]",Sn="[object RegExp]",Zt="[object Set]",xn="[object String]",er="[object Symbol]",Sc="[object Undefined]",En="[object WeakMap]",xc="[object WeakSet]",Tn="[object ArrayBuffer]",Xe="[object DataView]",ts="[object Float32Array]",es="[object Float64Array]",ns="[object Int8Array]",rs="[object Int16Array]",ss="[object Int32Array]",is="[object Uint8Array]",os="[object Uint8ClampedArray]",as="[object Uint16Array]",us="[object Uint32Array]",Ec=/\b__p \+= '';/g,Tc=/\b(__p \+=) '' \+/g,Ac=/(__e\(.*?\)|\b__t\)) \+\n'';/g,qi=/&(?:amp|lt|gt|quot|#39);/g,zi=/[&<>"']/g,Cc=RegExp(qi.source),Ic=RegExp(zi.source),Rc=/<%-([\s\S]+?)%>/g,Mc=/<%([\s\S]+?)%>/g,Hi=/<%=([\s\S]+?)%>/g,Pc=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Oc=/^\w*$/,Lc=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,cs=/[\\^$.*+?()[\]{}|]/g,Bc=RegExp(cs.source),hs=/^\s+/,kc=/\s/,Dc=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Nc=/\{\n\/\* \[wrapped with (.+)\] \*/,Fc=/,? & /,Uc=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Wc=/[()=,{}\[\]\/\s]/,$c=/\\(\\)?/g,qc=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Ji=/\w*$/,zc=/^[-+]0x[0-9a-f]+$/i,Hc=/^0b[01]+$/i,Jc=/^\[object .+?Constructor\]$/,Gc=/^0o[0-7]+$/i,Kc=/^(?:0|[1-9]\d*)$/,Yc=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,nr=/($^)/,Vc=/['\n\r\u2028\u2029\\]/g,rr="\\ud800-\\udfff",Zc="\\u0300-\\u036f",Xc="\\ufe20-\\ufe2f",Qc="\\u20d0-\\u20ff",Gi=Zc+Xc+Qc,Ki="\\u2700-\\u27bf",Yi="a-z\\xdf-\\xf6\\xf8-\\xff",jc="\\xac\\xb1\\xd7\\xf7",th="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",eh="\\u2000-\\u206f",nh=" \\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",Vi="A-Z\\xc0-\\xd6\\xd8-\\xde",Zi="\\ufe0e\\ufe0f",Xi=jc+th+eh+nh,ls="['’]",rh="["+rr+"]",Qi="["+Xi+"]",sr="["+Gi+"]",ji="\\d+",sh="["+Ki+"]",to="["+Yi+"]",eo="[^"+rr+Xi+ji+Ki+Yi+Vi+"]",fs="\\ud83c[\\udffb-\\udfff]",ih="(?:"+sr+"|"+fs+")",no="[^"+rr+"]",ds="(?:\\ud83c[\\udde6-\\uddff]){2}",ps="[\\ud800-\\udbff][\\udc00-\\udfff]",Qe="["+Vi+"]",ro="\\u200d",so="(?:"+to+"|"+eo+")",oh="(?:"+Qe+"|"+eo+")",io="(?:"+ls+"(?:d|ll|m|re|s|t|ve))?",oo="(?:"+ls+"(?:D|LL|M|RE|S|T|VE))?",ao=ih+"?",uo="["+Zi+"]?",ah="(?:"+ro+"(?:"+[no,ds,ps].join("|")+")"+uo+ao+")*",uh="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ch="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",co=uo+ao+ah,hh="(?:"+[sh,ds,ps].join("|")+")"+co,lh="(?:"+[no+sr+"?",sr,ds,ps,rh].join("|")+")",fh=RegExp(ls,"g"),dh=RegExp(sr,"g"),gs=RegExp(fs+"(?="+fs+")|"+lh+co,"g"),ph=RegExp([Qe+"?"+to+"+"+io+"(?="+[Qi,Qe,"$"].join("|")+")",oh+"+"+oo+"(?="+[Qi,Qe+so,"$"].join("|")+")",Qe+"?"+so+"+"+io,Qe+"+"+oo,ch,uh,ji,hh].join("|"),"g"),gh=RegExp("["+ro+rr+Gi+Zi+"]"),_h=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,bh=["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"],mh=-1,tt={};tt[ts]=tt[es]=tt[ns]=tt[rs]=tt[ss]=tt[is]=tt[os]=tt[as]=tt[us]=!0,tt[Ze]=tt[Qn]=tt[Tn]=tt[vn]=tt[Xe]=tt[wn]=tt[jn]=tt[tr]=tt[Vt]=tt[yn]=tt[le]=tt[Sn]=tt[Zt]=tt[xn]=tt[En]=!1;var j={};j[Ze]=j[Qn]=j[Tn]=j[Xe]=j[vn]=j[wn]=j[ts]=j[es]=j[ns]=j[rs]=j[ss]=j[Vt]=j[yn]=j[le]=j[Sn]=j[Zt]=j[xn]=j[er]=j[is]=j[os]=j[as]=j[us]=!0,j[jn]=j[tr]=j[En]=!1;var vh={À:"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"},wh={"&":"&","<":"<",">":">",'"':""","'":"'"},yh={"&":"&","<":"<",">":">",""":'"',"'":"'"},Sh={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},xh=parseFloat,Eh=parseInt,ho=typeof $n=="object"&&$n&&$n.Object===Object&&$n,Th=typeof self=="object"&&self&&self.Object===Object&&self,_t=ho||Th||Function("return this")(),_s=i&&!i.nodeType&&i,De=_s&&!0&&n&&!n.nodeType&&n,lo=De&&De.exports===_s,bs=lo&&ho.process,Ut=function(){try{var _=De&&De.require&&De.require("util").types;return _||bs&&bs.binding&&bs.binding("util")}catch{}}(),fo=Ut&&Ut.isArrayBuffer,po=Ut&&Ut.isDate,go=Ut&&Ut.isMap,_o=Ut&&Ut.isRegExp,bo=Ut&&Ut.isSet,mo=Ut&&Ut.isTypedArray;function Mt(_,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 Ah(_,y,v,O){for(var N=-1,Y=_==null?0:_.length;++N<Y;){var lt=_[N];y(O,lt,v(lt),_)}return O}function Wt(_,y){for(var v=-1,O=_==null?0:_.length;++v<O&&y(_[v],v,_)!==!1;);return _}function Ch(_,y){for(var v=_==null?0:_.length;v--&&y(_[v],v,_)!==!1;);return _}function vo(_,y){for(var v=-1,O=_==null?0:_.length;++v<O;)if(!y(_[v],v,_))return!1;return!0}function Se(_,y){for(var v=-1,O=_==null?0:_.length,N=0,Y=[];++v<O;){var lt=_[v];y(lt,v,_)&&(Y[N++]=lt)}return Y}function ir(_,y){var v=_==null?0:_.length;return!!v&&je(_,y,0)>-1}function ms(_,y,v){for(var O=-1,N=_==null?0:_.length;++O<N;)if(v(y,_[O]))return!0;return!1}function et(_,y){for(var v=-1,O=_==null?0:_.length,N=Array(O);++v<O;)N[v]=y(_[v],v,_);return N}function xe(_,y){for(var v=-1,O=y.length,N=_.length;++v<O;)_[N+v]=y[v];return _}function vs(_,y,v,O){var N=-1,Y=_==null?0:_.length;for(O&&Y&&(v=_[++N]);++N<Y;)v=y(v,_[N],N,_);return v}function Ih(_,y,v,O){var N=_==null?0:_.length;for(O&&N&&(v=_[--N]);N--;)v=y(v,_[N],N,_);return v}function ws(_,y){for(var v=-1,O=_==null?0:_.length;++v<O;)if(y(_[v],v,_))return!0;return!1}var Rh=ys("length");function Mh(_){return _.split("")}function Ph(_){return _.match(Uc)||[]}function wo(_,y,v){var O;return v(_,function(N,Y,lt){if(y(N,Y,lt))return O=Y,!1}),O}function or(_,y,v,O){for(var N=_.length,Y=v+(O?1:-1);O?Y--:++Y<N;)if(y(_[Y],Y,_))return Y;return-1}function je(_,y,v){return y===y?zh(_,y,v):or(_,yo,v)}function Oh(_,y,v,O){for(var N=v-1,Y=_.length;++N<Y;)if(O(_[N],y))return N;return-1}function yo(_){return _!==_}function So(_,y){var v=_==null?0:_.length;return v?xs(_,y)/v:Xn}function ys(_){return function(y){return y==null?r:y[_]}}function Ss(_){return function(y){return _==null?r:_[y]}}function xo(_,y,v,O,N){return N(_,function(Y,lt,Q){v=O?(O=!1,Y):y(v,Y,lt,Q)}),v}function Lh(_,y){var v=_.length;for(_.sort(y);v--;)_[v]=_[v].value;return _}function xs(_,y){for(var v,O=-1,N=_.length;++O<N;){var Y=y(_[O]);Y!==r&&(v=v===r?Y:v+Y)}return v}function Es(_,y){for(var v=-1,O=Array(_);++v<_;)O[v]=y(v);return O}function Bh(_,y){return et(y,function(v){return[v,_[v]]})}function Eo(_){return _&&_.slice(0,Io(_)+1).replace(hs,"")}function Pt(_){return function(y){return _(y)}}function Ts(_,y){return et(y,function(v){return _[v]})}function An(_,y){return _.has(y)}function To(_,y){for(var v=-1,O=_.length;++v<O&&je(y,_[v],0)>-1;);return v}function Ao(_,y){for(var v=_.length;v--&&je(y,_[v],0)>-1;);return v}function kh(_,y){for(var v=_.length,O=0;v--;)_[v]===y&&++O;return O}var Dh=Ss(vh),Nh=Ss(wh);function Fh(_){return"\\"+Sh[_]}function Uh(_,y){return _==null?r:_[y]}function tn(_){return gh.test(_)}function Wh(_){return _h.test(_)}function $h(_){for(var y,v=[];!(y=_.next()).done;)v.push(y.value);return v}function As(_){var y=-1,v=Array(_.size);return _.forEach(function(O,N){v[++y]=[N,O]}),v}function Co(_,y){return function(v){return _(y(v))}}function Ee(_,y){for(var v=-1,O=_.length,N=0,Y=[];++v<O;){var lt=_[v];(lt===y||lt===P)&&(_[v]=P,Y[N++]=v)}return Y}function ar(_){var y=-1,v=Array(_.size);return _.forEach(function(O){v[++y]=O}),v}function qh(_){var y=-1,v=Array(_.size);return _.forEach(function(O){v[++y]=[O,O]}),v}function zh(_,y,v){for(var O=v-1,N=_.length;++O<N;)if(_[O]===y)return O;return-1}function Hh(_,y,v){for(var O=v+1;O--;)if(_[O]===y)return O;return O}function en(_){return tn(_)?Gh(_):Rh(_)}function Xt(_){return tn(_)?Kh(_):Mh(_)}function Io(_){for(var y=_.length;y--&&kc.test(_.charAt(y)););return y}var Jh=Ss(yh);function Gh(_){for(var y=gs.lastIndex=0;gs.test(_);)++y;return y}function Kh(_){return _.match(gs)||[]}function Yh(_){return _.match(ph)||[]}var Vh=function _(y){y=y==null?_t:nn.defaults(_t.Object(),y,nn.pick(_t,bh));var v=y.Array,O=y.Date,N=y.Error,Y=y.Function,lt=y.Math,Q=y.Object,Cs=y.RegExp,Zh=y.String,$t=y.TypeError,ur=v.prototype,Xh=Y.prototype,rn=Q.prototype,cr=y["__core-js_shared__"],hr=Xh.toString,Z=rn.hasOwnProperty,Qh=0,Ro=function(){var t=/[^.]+$/.exec(cr&&cr.keys&&cr.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),lr=rn.toString,jh=hr.call(Q),tl=_t._,el=Cs("^"+hr.call(Z).replace(cs,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),fr=lo?y.Buffer:r,Te=y.Symbol,dr=y.Uint8Array,Mo=fr?fr.allocUnsafe:r,pr=Co(Q.getPrototypeOf,Q),Po=Q.create,Oo=rn.propertyIsEnumerable,gr=ur.splice,Lo=Te?Te.isConcatSpreadable:r,Cn=Te?Te.iterator:r,Ne=Te?Te.toStringTag:r,_r=function(){try{var t=qe(Q,"defineProperty");return t({},"",{}),t}catch{}}(),nl=y.clearTimeout!==_t.clearTimeout&&y.clearTimeout,rl=O&&O.now!==_t.Date.now&&O.now,sl=y.setTimeout!==_t.setTimeout&&y.setTimeout,br=lt.ceil,mr=lt.floor,Is=Q.getOwnPropertySymbols,il=fr?fr.isBuffer:r,Bo=y.isFinite,ol=ur.join,al=Co(Q.keys,Q),ft=lt.max,mt=lt.min,ul=O.now,cl=y.parseInt,ko=lt.random,hl=ur.reverse,Rs=qe(y,"DataView"),In=qe(y,"Map"),Ms=qe(y,"Promise"),sn=qe(y,"Set"),Rn=qe(y,"WeakMap"),Mn=qe(Q,"create"),vr=Rn&&new Rn,on={},ll=ze(Rs),fl=ze(In),dl=ze(Ms),pl=ze(sn),gl=ze(Rn),wr=Te?Te.prototype:r,Pn=wr?wr.valueOf:r,Do=wr?wr.toString:r;function c(t){if(it(t)&&!F(t)&&!(t instanceof J)){if(t instanceof qt)return t;if(Z.call(t,"__wrapped__"))return Na(t)}return new qt(t)}var an=function(){function t(){}return function(e){if(!nt(e))return{};if(Po)return Po(e);t.prototype=e;var s=new t;return t.prototype=r,s}}();function yr(){}function qt(t,e){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!e,this.__index__=0,this.__values__=r}c.templateSettings={escape:Rc,evaluate:Mc,interpolate:Hi,variable:"",imports:{_:c}},c.prototype=yr.prototype,c.prototype.constructor=c,qt.prototype=an(yr.prototype),qt.prototype.constructor=qt;function J(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ie,this.__views__=[]}function _l(){var t=new J(this.__wrapped__);return t.__actions__=At(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=At(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=At(this.__views__),t}function bl(){if(this.__filtered__){var t=new J(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function ml(){var t=this.__wrapped__.value(),e=this.__dir__,s=F(t),o=e<0,u=s?t.length:0,l=Pf(0,u,this.__views__),d=l.start,g=l.end,b=g-d,x=o?g:d-1,E=this.__iteratees__,T=E.length,M=0,L=mt(b,this.__takeCount__);if(!s||!o&&u==b&&L==b)return oa(t,this.__actions__);var k=[];t:for(;b--&&M<L;){x+=e;for(var $=-1,D=t[x];++$<T;){var H=E[$],G=H.iteratee,Bt=H.type,xt=G(D);if(Bt==fc)D=xt;else if(!xt){if(Bt==wt)continue t;break t}}k[M++]=D}return k}J.prototype=an(yr.prototype),J.prototype.constructor=J;function Fe(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 vl(){this.__data__=Mn?Mn(null):{},this.size=0}function wl(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}function yl(t){var e=this.__data__;if(Mn){var s=e[t];return s===w?r:s}return Z.call(e,t)?e[t]:r}function Sl(t){var e=this.__data__;return Mn?e[t]!==r:Z.call(e,t)}function xl(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=Mn&&e===r?w:e,this}Fe.prototype.clear=vl,Fe.prototype.delete=wl,Fe.prototype.get=yl,Fe.prototype.has=Sl,Fe.prototype.set=xl;function fe(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 El(){this.__data__=[],this.size=0}function Tl(t){var e=this.__data__,s=Sr(e,t);if(s<0)return!1;var o=e.length-1;return s==o?e.pop():gr.call(e,s,1),--this.size,!0}function Al(t){var e=this.__data__,s=Sr(e,t);return s<0?r:e[s][1]}function Cl(t){return Sr(this.__data__,t)>-1}function Il(t,e){var s=this.__data__,o=Sr(s,t);return o<0?(++this.size,s.push([t,e])):s[o][1]=e,this}fe.prototype.clear=El,fe.prototype.delete=Tl,fe.prototype.get=Al,fe.prototype.has=Cl,fe.prototype.set=Il;function de(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 Rl(){this.size=0,this.__data__={hash:new Fe,map:new(In||fe),string:new Fe}}function Ml(t){var e=Br(this,t).delete(t);return this.size-=e?1:0,e}function Pl(t){return Br(this,t).get(t)}function Ol(t){return Br(this,t).has(t)}function Ll(t,e){var s=Br(this,t),o=s.size;return s.set(t,e),this.size+=s.size==o?0:1,this}de.prototype.clear=Rl,de.prototype.delete=Ml,de.prototype.get=Pl,de.prototype.has=Ol,de.prototype.set=Ll;function Ue(t){var e=-1,s=t==null?0:t.length;for(this.__data__=new de;++e<s;)this.add(t[e])}function Bl(t){return this.__data__.set(t,w),this}function kl(t){return this.__data__.has(t)}Ue.prototype.add=Ue.prototype.push=Bl,Ue.prototype.has=kl;function Qt(t){var e=this.__data__=new fe(t);this.size=e.size}function Dl(){this.__data__=new fe,this.size=0}function Nl(t){var e=this.__data__,s=e.delete(t);return this.size=e.size,s}function Fl(t){return this.__data__.get(t)}function Ul(t){return this.__data__.has(t)}function Wl(t,e){var s=this.__data__;if(s instanceof fe){var o=s.__data__;if(!In||o.length<h-1)return o.push([t,e]),this.size=++s.size,this;s=this.__data__=new de(o)}return s.set(t,e),this.size=s.size,this}Qt.prototype.clear=Dl,Qt.prototype.delete=Nl,Qt.prototype.get=Fl,Qt.prototype.has=Ul,Qt.prototype.set=Wl;function No(t,e){var s=F(t),o=!s&&He(t),u=!s&&!o&&Me(t),l=!s&&!o&&!u&&ln(t),d=s||o||u||l,g=d?Es(t.length,Zh):[],b=g.length;for(var x in t)(e||Z.call(t,x))&&!(d&&(x=="length"||u&&(x=="offset"||x=="parent")||l&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||be(x,b)))&&g.push(x);return g}function Fo(t){var e=t.length;return e?t[$s(0,e-1)]:r}function $l(t,e){return kr(At(t),We(e,0,t.length))}function ql(t){return kr(At(t))}function Ps(t,e,s){(s!==r&&!jt(t[e],s)||s===r&&!(e in t))&&pe(t,e,s)}function On(t,e,s){var o=t[e];(!(Z.call(t,e)&&jt(o,s))||s===r&&!(e in t))&&pe(t,e,s)}function Sr(t,e){for(var s=t.length;s--;)if(jt(t[s][0],e))return s;return-1}function zl(t,e,s,o){return Ae(t,function(u,l,d){e(o,u,s(u),d)}),o}function Uo(t,e){return t&&ae(e,gt(e),t)}function Hl(t,e){return t&&ae(e,It(e),t)}function pe(t,e,s){e=="__proto__"&&_r?_r(t,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[e]=s}function Os(t,e){for(var s=-1,o=e.length,u=v(o),l=t==null;++s<o;)u[s]=l?r:fi(t,e[s]);return u}function We(t,e,s){return t===t&&(s!==r&&(t=t<=s?t:s),e!==r&&(t=t>=e?t:e)),t}function zt(t,e,s,o,u,l){var d,g=e&C,b=e&A,x=e&R;if(s&&(d=u?s(t,o,u,l):s(t)),d!==r)return d;if(!nt(t))return t;var E=F(t);if(E){if(d=Lf(t),!g)return At(t,d)}else{var T=vt(t),M=T==tr||T==Wi;if(Me(t))return ca(t,g);if(T==le||T==Ze||M&&!u){if(d=b||M?{}:Ia(t),!g)return b?Sf(t,Hl(d,t)):yf(t,Uo(d,t))}else{if(!j[T])return u?t:{};d=Bf(t,T,g)}}l||(l=new Qt);var L=l.get(t);if(L)return L;l.set(t,d),ru(t)?t.forEach(function(D){d.add(zt(D,e,s,D,t,l))}):eu(t)&&t.forEach(function(D,H){d.set(H,zt(D,e,s,H,t,l))});var k=x?b?Qs:Xs:b?It:gt,$=E?r:k(t);return Wt($||t,function(D,H){$&&(H=D,D=t[H]),On(d,H,zt(D,e,s,H,t,l))}),d}function Jl(t){var e=gt(t);return function(s){return Wo(s,t,e)}}function Wo(t,e,s){var o=s.length;if(t==null)return!o;for(t=Q(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 $o(t,e,s){if(typeof t!="function")throw new $t(p);return Un(function(){t.apply(r,s)},e)}function Ln(t,e,s,o){var u=-1,l=ir,d=!0,g=t.length,b=[],x=e.length;if(!g)return b;s&&(e=et(e,Pt(s))),o?(l=ms,d=!1):e.length>=h&&(l=An,d=!1,e=new Ue(e));t:for(;++u<g;){var E=t[u],T=s==null?E:s(E);if(E=o||E!==0?E:0,d&&T===T){for(var M=x;M--;)if(e[M]===T)continue t;b.push(E)}else l(e,T,o)||b.push(E)}return b}var Ae=pa(oe),qo=pa(Bs,!0);function Gl(t,e){var s=!0;return Ae(t,function(o,u,l){return s=!!e(o,u,l),s}),s}function xr(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&&!Lt(d):s(d,g)))var g=d,b=l}return b}function Kl(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:iu(o);s<o;)t[s++]=e;return t}function zo(t,e){var s=[];return Ae(t,function(o,u,l){e(o,u,l)&&s.push(o)}),s}function bt(t,e,s,o,u){var l=-1,d=t.length;for(s||(s=Df),u||(u=[]);++l<d;){var g=t[l];e>0&&s(g)?e>1?bt(g,e-1,s,o,u):xe(u,g):o||(u[u.length]=g)}return u}var Ls=ga(),Ho=ga(!0);function oe(t,e){return t&&Ls(t,e,gt)}function Bs(t,e){return t&&Ho(t,e,gt)}function Er(t,e){return Se(e,function(s){return me(t[s])})}function $e(t,e){e=Ie(e,t);for(var s=0,o=e.length;t!=null&&s<o;)t=t[ue(e[s++])];return s&&s==o?t:r}function Jo(t,e,s){var o=e(t);return F(t)?o:xe(o,s(t))}function yt(t){return t==null?t===r?Sc:wc:Ne&&Ne in Q(t)?Mf(t):zf(t)}function ks(t,e){return t>e}function Yl(t,e){return t!=null&&Z.call(t,e)}function Vl(t,e){return t!=null&&e in Q(t)}function Zl(t,e,s){return t>=mt(e,s)&&t<ft(e,s)}function Ds(t,e,s){for(var o=s?ms:ir,u=t[0].length,l=t.length,d=l,g=v(l),b=1/0,x=[];d--;){var E=t[d];d&&e&&(E=et(E,Pt(e))),b=mt(E.length,b),g[d]=!s&&(e||u>=120&&E.length>=120)?new Ue(d&&E):r}E=t[0];var T=-1,M=g[0];t:for(;++T<u&&x.length<b;){var L=E[T],k=e?e(L):L;if(L=s||L!==0?L:0,!(M?An(M,k):o(x,k,s))){for(d=l;--d;){var $=g[d];if(!($?An($,k):o(t[d],k,s)))continue t}M&&M.push(k),x.push(L)}}return x}function Xl(t,e,s,o){return oe(t,function(u,l,d){e(o,s(u),l,d)}),o}function Bn(t,e,s){e=Ie(e,t),t=Oa(t,e);var o=t==null?t:t[ue(Jt(e))];return o==null?r:Mt(o,t,s)}function Go(t){return it(t)&&yt(t)==Ze}function Ql(t){return it(t)&&yt(t)==Tn}function jl(t){return it(t)&&yt(t)==wn}function kn(t,e,s,o,u){return t===e?!0:t==null||e==null||!it(t)&&!it(e)?t!==t&&e!==e:tf(t,e,s,o,kn,u)}function tf(t,e,s,o,u,l){var d=F(t),g=F(e),b=d?Qn:vt(t),x=g?Qn:vt(e);b=b==Ze?le:b,x=x==Ze?le:x;var E=b==le,T=x==le,M=b==x;if(M&&Me(t)){if(!Me(e))return!1;d=!0,E=!1}if(M&&!E)return l||(l=new Qt),d||ln(t)?Ta(t,e,s,o,u,l):If(t,e,b,s,o,u,l);if(!(s&K)){var L=E&&Z.call(t,"__wrapped__"),k=T&&Z.call(e,"__wrapped__");if(L||k){var $=L?t.value():t,D=k?e.value():e;return l||(l=new Qt),u($,D,s,o,l)}}return M?(l||(l=new Qt),Rf(t,e,s,o,u,l)):!1}function ef(t){return it(t)&&vt(t)==Vt}function Ns(t,e,s,o){var u=s.length,l=u,d=!o;if(t==null)return!l;for(t=Q(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],x=t[b],E=g[1];if(d&&g[2]){if(x===r&&!(b in t))return!1}else{var T=new Qt;if(o)var M=o(x,E,b,t,e,T);if(!(M===r?kn(E,x,K|Tt,o,T):M))return!1}}return!0}function Ko(t){if(!nt(t)||Ff(t))return!1;var e=me(t)?el:Jc;return e.test(ze(t))}function nf(t){return it(t)&&yt(t)==Sn}function rf(t){return it(t)&&vt(t)==Zt}function sf(t){return it(t)&&$r(t.length)&&!!tt[yt(t)]}function Yo(t){return typeof t=="function"?t:t==null?Rt:typeof t=="object"?F(t)?Xo(t[0],t[1]):Zo(t):_u(t)}function Fs(t){if(!Fn(t))return al(t);var e=[];for(var s in Q(t))Z.call(t,s)&&s!="constructor"&&e.push(s);return e}function of(t){if(!nt(t))return qf(t);var e=Fn(t),s=[];for(var o in t)o=="constructor"&&(e||!Z.call(t,o))||s.push(o);return s}function Us(t,e){return t<e}function Vo(t,e){var s=-1,o=Ct(t)?v(t.length):[];return Ae(t,function(u,l,d){o[++s]=e(u,l,d)}),o}function Zo(t){var e=ti(t);return e.length==1&&e[0][2]?Ma(e[0][0],e[0][1]):function(s){return s===t||Ns(s,t,e)}}function Xo(t,e){return ni(t)&&Ra(e)?Ma(ue(t),e):function(s){var o=fi(s,t);return o===r&&o===e?di(s,t):kn(e,o,K|Tt)}}function Tr(t,e,s,o,u){t!==e&&Ls(e,function(l,d){if(u||(u=new Qt),nt(l))af(t,e,d,s,Tr,o,u);else{var g=o?o(si(t,d),l,d+"",t,e,u):r;g===r&&(g=l),Ps(t,d,g)}},It)}function af(t,e,s,o,u,l,d){var g=si(t,s),b=si(e,s),x=d.get(b);if(x){Ps(t,s,x);return}var E=l?l(g,b,s+"",t,e,d):r,T=E===r;if(T){var M=F(b),L=!M&&Me(b),k=!M&&!L&&ln(b);E=b,M||L||k?F(g)?E=g:ot(g)?E=At(g):L?(T=!1,E=ca(b,!0)):k?(T=!1,E=ha(b,!0)):E=[]:Wn(b)||He(b)?(E=g,He(g)?E=ou(g):(!nt(g)||me(g))&&(E=Ia(b))):T=!1}T&&(d.set(b,E),u(E,b,o,l,d),d.delete(b)),Ps(t,s,E)}function Qo(t,e){var s=t.length;if(s)return e+=e<0?s:0,be(e,s)?t[e]:r}function jo(t,e,s){e.length?e=et(e,function(l){return F(l)?function(d){return $e(d,l.length===1?l[0]:l)}:l}):e=[Rt];var o=-1;e=et(e,Pt(B()));var u=Vo(t,function(l,d,g){var b=et(e,function(x){return x(l)});return{criteria:b,index:++o,value:l}});return Lh(u,function(l,d){return wf(l,d,s)})}function uf(t,e){return ta(t,e,function(s,o){return di(t,o)})}function ta(t,e,s){for(var o=-1,u=e.length,l={};++o<u;){var d=e[o],g=$e(t,d);s(g,d)&&Dn(l,Ie(d,t),g)}return l}function cf(t){return function(e){return $e(e,t)}}function Ws(t,e,s,o){var u=o?Oh:je,l=-1,d=e.length,g=t;for(t===e&&(e=At(e)),s&&(g=et(t,Pt(s)));++l<d;)for(var b=0,x=e[l],E=s?s(x):x;(b=u(g,E,b,o))>-1;)g!==t&&gr.call(g,b,1),gr.call(t,b,1);return t}function ea(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;be(u)?gr.call(t,u,1):Hs(t,u)}}return t}function $s(t,e){return t+mr(ko()*(e-t+1))}function hf(t,e,s,o){for(var u=-1,l=ft(br((e-t)/(s||1)),0),d=v(l);l--;)d[o?l:++u]=t,t+=s;return d}function qs(t,e){var s="";if(!t||e<1||e>ye)return s;do e%2&&(s+=t),e=mr(e/2),e&&(t+=t);while(e);return s}function z(t,e){return ii(Pa(t,e,Rt),t+"")}function lf(t){return Fo(fn(t))}function ff(t,e){var s=fn(t);return kr(s,We(e,0,s.length))}function Dn(t,e,s,o){if(!nt(t))return t;e=Ie(e,t);for(var u=-1,l=e.length,d=l-1,g=t;g!=null&&++u<l;){var b=ue(e[u]),x=s;if(b==="__proto__"||b==="constructor"||b==="prototype")return t;if(u!=d){var E=g[b];x=o?o(E,b,g):r,x===r&&(x=nt(E)?E:be(e[u+1])?[]:{})}On(g,b,x),g=g[b]}return t}var na=vr?function(t,e){return vr.set(t,e),t}:Rt,df=_r?function(t,e){return _r(t,"toString",{configurable:!0,enumerable:!1,value:gi(e),writable:!0})}:Rt;function pf(t){return kr(fn(t))}function Ht(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 gf(t,e){var s;return Ae(t,function(o,u,l){return s=e(o,u,l),!s}),!!s}function Ar(t,e,s){var o=0,u=t==null?o:t.length;if(typeof e=="number"&&e===e&&u<=_c){for(;o<u;){var l=o+u>>>1,d=t[l];d!==null&&!Lt(d)&&(s?d<=e:d<e)?o=l+1:u=l}return u}return zs(t,e,Rt,s)}function zs(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=Lt(e),x=e===r;u<l;){var E=mr((u+l)/2),T=s(t[E]),M=T!==r,L=T===null,k=T===T,$=Lt(T);if(d)var D=o||k;else x?D=k&&(o||M):g?D=k&&M&&(o||!L):b?D=k&&M&&!L&&(o||!$):L||$?D=!1:D=o?T<=e:T<e;D?u=E+1:l=E}return mt(l,gc)}function ra(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||!jt(g,b)){var b=g;l[u++]=d===0?0:d}}return l}function sa(t){return typeof t=="number"?t:Lt(t)?Xn:+t}function Ot(t){if(typeof t=="string")return t;if(F(t))return et(t,Ot)+"";if(Lt(t))return Do?Do.call(t):"";var e=t+"";return e=="0"&&1/t==-ke?"-0":e}function Ce(t,e,s){var o=-1,u=ir,l=t.length,d=!0,g=[],b=g;if(s)d=!1,u=ms;else if(l>=h){var x=e?null:Af(t);if(x)return ar(x);d=!1,u=An,b=new Ue}else b=e?[]:g;t:for(;++o<l;){var E=t[o],T=e?e(E):E;if(E=s||E!==0?E:0,d&&T===T){for(var M=b.length;M--;)if(b[M]===T)continue t;e&&b.push(T),g.push(E)}else u(b,T,s)||(b!==g&&b.push(T),g.push(E))}return g}function Hs(t,e){return e=Ie(e,t),t=Oa(t,e),t==null||delete t[ue(Jt(e))]}function ia(t,e,s,o){return Dn(t,e,s($e(t,e)),o)}function Cr(t,e,s,o){for(var u=t.length,l=o?u:-1;(o?l--:++l<u)&&e(t[l],l,t););return s?Ht(t,o?0:l,o?l+1:u):Ht(t,o?l+1:0,o?u:l)}function oa(t,e){var s=t;return s instanceof J&&(s=s.value()),vs(e,function(o,u){return u.func.apply(u.thisArg,xe([o],u.args))},s)}function Js(t,e,s){var o=t.length;if(o<2)return o?Ce(t[0]):[];for(var u=-1,l=v(o);++u<o;)for(var d=t[u],g=-1;++g<o;)g!=u&&(l[u]=Ln(l[u]||d,t[g],e,s));return Ce(bt(l,1),e,s)}function aa(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 Gs(t){return ot(t)?t:[]}function Ks(t){return typeof t=="function"?t:Rt}function Ie(t,e){return F(t)?t:ni(t,e)?[t]:Da(V(t))}var _f=z;function Re(t,e,s){var o=t.length;return s=s===r?o:s,!e&&s>=o?t:Ht(t,e,s)}var ua=nl||function(t){return _t.clearTimeout(t)};function ca(t,e){if(e)return t.slice();var s=t.length,o=Mo?Mo(s):new t.constructor(s);return t.copy(o),o}function Ys(t){var e=new t.constructor(t.byteLength);return new dr(e).set(new dr(t)),e}function bf(t,e){var s=e?Ys(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}function mf(t){var e=new t.constructor(t.source,Ji.exec(t));return e.lastIndex=t.lastIndex,e}function vf(t){return Pn?Q(Pn.call(t)):{}}function ha(t,e){var s=e?Ys(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}function la(t,e){if(t!==e){var s=t!==r,o=t===null,u=t===t,l=Lt(t),d=e!==r,g=e===null,b=e===e,x=Lt(e);if(!g&&!x&&!l&&t>e||l&&d&&b&&!g&&!x||o&&d&&b||!s&&b||!u)return 1;if(!o&&!l&&!x&&t<e||x&&s&&u&&!o&&!l||g&&s&&u||!d&&u||!b)return-1}return 0}function wf(t,e,s){for(var o=-1,u=t.criteria,l=e.criteria,d=u.length,g=s.length;++o<d;){var b=la(u[o],l[o]);if(b){if(o>=g)return b;var x=s[o];return b*(x=="desc"?-1:1)}}return t.index-e.index}function fa(t,e,s,o){for(var u=-1,l=t.length,d=s.length,g=-1,b=e.length,x=ft(l-d,0),E=v(b+x),T=!o;++g<b;)E[g]=e[g];for(;++u<d;)(T||u<l)&&(E[s[u]]=t[u]);for(;x--;)E[g++]=t[u++];return E}function da(t,e,s,o){for(var u=-1,l=t.length,d=-1,g=s.length,b=-1,x=e.length,E=ft(l-g,0),T=v(E+x),M=!o;++u<E;)T[u]=t[u];for(var L=u;++b<x;)T[L+b]=e[b];for(;++d<g;)(M||u<l)&&(T[L+s[d]]=t[u++]);return T}function At(t,e){var s=-1,o=t.length;for(e||(e=v(o));++s<o;)e[s]=t[s];return e}function ae(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?pe(s,g,b):On(s,g,b)}return s}function yf(t,e){return ae(t,ei(t),e)}function Sf(t,e){return ae(t,Aa(t),e)}function Ir(t,e){return function(s,o){var u=F(s)?Ah:zl,l=e?e():{};return u(s,t,B(o,2),l)}}function un(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&&St(s[0],s[1],d)&&(l=u<3?r:l,u=1),e=Q(e);++o<u;){var g=s[o];g&&t(e,g,o,l)}return e})}function pa(t,e){return function(s,o){if(s==null)return s;if(!Ct(s))return t(s,o);for(var u=s.length,l=e?u:-1,d=Q(s);(e?l--:++l<u)&&o(d[l],l,d)!==!1;);return s}}function ga(t){return function(e,s,o){for(var u=-1,l=Q(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 xf(t,e,s){var o=e&pt,u=Nn(t);function l(){var d=this&&this!==_t&&this instanceof l?u:t;return d.apply(o?s:this,arguments)}return l}function _a(t){return function(e){e=V(e);var s=tn(e)?Xt(e):r,o=s?s[0]:e.charAt(0),u=s?Re(s,1).join(""):e.slice(1);return o[t]()+u}}function cn(t){return function(e){return vs(pu(du(e).replace(fh,"")),t,"")}}function Nn(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=an(t.prototype),o=t.apply(s,e);return nt(o)?o:s}}function Ef(t,e,s){var o=Nn(t);function u(){for(var l=arguments.length,d=v(l),g=l,b=hn(u);g--;)d[g]=arguments[g];var x=l<3&&d[0]!==b&&d[l-1]!==b?[]:Ee(d,b);if(l-=x.length,l<s)return ya(t,e,Rr,u.placeholder,r,d,x,r,r,s-l);var E=this&&this!==_t&&this instanceof u?o:t;return Mt(E,this,d)}return u}function ba(t){return function(e,s,o){var u=Q(e);if(!Ct(e)){var l=B(s,3);e=gt(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 ma(t){return _e(function(e){var s=e.length,o=s,u=qt.prototype.thru;for(t&&e.reverse();o--;){var l=e[o];if(typeof l!="function")throw new $t(p);if(u&&!d&&Lr(l)=="wrapper")var d=new qt([],!0)}for(o=d?o:s;++o<s;){l=e[o];var g=Lr(l),b=g=="wrapper"?js(l):r;b&&ri(b[0])&&b[1]==(q|Kt|Yt|ct)&&!b[4].length&&b[9]==1?d=d[Lr(b[0])].apply(d,b[3]):d=l.length==1&&ri(l)?d[g]():d.thru(l)}return function(){var x=arguments,E=x[0];if(d&&x.length==1&&F(E))return d.plant(E).value();for(var T=0,M=s?e[T].apply(this,x):E;++T<s;)M=e[T].call(this,M);return M}})}function Rr(t,e,s,o,u,l,d,g,b,x){var E=e&q,T=e&pt,M=e&ut,L=e&(Kt|Le),k=e&X,$=M?r:Nn(t);function D(){for(var H=arguments.length,G=v(H),Bt=H;Bt--;)G[Bt]=arguments[Bt];if(L)var xt=hn(D),kt=kh(G,xt);if(o&&(G=fa(G,o,u,L)),l&&(G=da(G,l,d,L)),H-=kt,L&&H<x){var at=Ee(G,xt);return ya(t,e,Rr,D.placeholder,s,G,at,g,b,x-H)}var te=T?s:this,we=M?te[t]:t;return H=G.length,g?G=Hf(G,g):k&&H>1&&G.reverse(),E&&b<H&&(G.length=b),this&&this!==_t&&this instanceof D&&(we=$||Nn(we)),we.apply(te,G)}return D}function va(t,e){return function(s,o){return Xl(s,t,e(o),{})}}function Mr(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=Ot(s),o=Ot(o)):(s=sa(s),o=sa(o)),u=t(s,o)}return u}}function Vs(t){return _e(function(e){return e=et(e,Pt(B())),z(function(s){var o=this;return t(e,function(u){return Mt(u,o,s)})})})}function Pr(t,e){e=e===r?" ":Ot(e);var s=e.length;if(s<2)return s?qs(e,t):e;var o=qs(e,br(t/en(e)));return tn(e)?Re(Xt(o),0,t).join(""):o.slice(0,t)}function Tf(t,e,s,o){var u=e&pt,l=Nn(t);function d(){for(var g=-1,b=arguments.length,x=-1,E=o.length,T=v(E+b),M=this&&this!==_t&&this instanceof d?l:t;++x<E;)T[x]=o[x];for(;b--;)T[x++]=arguments[++g];return Mt(M,u?s:this,T)}return d}function wa(t){return function(e,s,o){return o&&typeof o!="number"&&St(e,s,o)&&(s=o=r),e=ve(e),s===r?(s=e,e=0):s=ve(s),o=o===r?e<s?1:-1:ve(o),hf(e,s,o,t)}}function Or(t){return function(e,s){return typeof e=="string"&&typeof s=="string"||(e=Gt(e),s=Gt(s)),t(e,s)}}function ya(t,e,s,o,u,l,d,g,b,x){var E=e&Kt,T=E?d:r,M=E?r:d,L=E?l:r,k=E?r:l;e|=E?Yt:Be,e&=~(E?Be:Yt),e&Zn||(e&=-4);var $=[t,e,u,L,T,k,M,g,b,x],D=s.apply(r,$);return ri(t)&&La(D,$),D.placeholder=o,Ba(D,t,e)}function Zs(t){var e=lt[t];return function(s,o){if(s=Gt(s),o=o==null?0:mt(W(o),292),o&&Bo(s)){var u=(V(s)+"e").split("e"),l=e(u[0]+"e"+(+u[1]+o));return u=(V(l)+"e").split("e"),+(u[0]+"e"+(+u[1]-o))}return e(s)}}var Af=sn&&1/ar(new sn([,-0]))[1]==ke?function(t){return new sn(t)}:mi;function Sa(t){return function(e){var s=vt(e);return s==Vt?As(e):s==Zt?qh(e):Bh(e,t(e))}}function ge(t,e,s,o,u,l,d,g){var b=e&ut;if(!b&&typeof t!="function")throw new $t(p);var x=o?o.length:0;if(x||(e&=-97,o=u=r),d=d===r?d:ft(W(d),0),g=g===r?g:W(g),x-=u?u.length:0,e&Be){var E=o,T=u;o=u=r}var M=b?r:js(t),L=[t,e,s,o,u,E,T,l,d,g];if(M&&$f(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:ft(L[9]-x,0),!g&&e&(Kt|Le)&&(e&=-25),!e||e==pt)var k=xf(t,e,s);else e==Kt||e==Le?k=Ef(t,e,g):(e==Yt||e==(pt|Yt))&&!u.length?k=Tf(t,e,s,o):k=Rr.apply(r,L);var $=M?na:La;return Ba($(k,L),t,e)}function xa(t,e,s,o){return t===r||jt(t,rn[s])&&!Z.call(o,s)?e:t}function Ea(t,e,s,o,u,l){return nt(t)&&nt(e)&&(l.set(e,t),Tr(t,e,r,Ea,l),l.delete(e)),t}function Cf(t){return Wn(t)?r:t}function Ta(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 x=l.get(t),E=l.get(e);if(x&&E)return x==e&&E==t;var T=-1,M=!0,L=s&Tt?new Ue:r;for(l.set(t,e),l.set(e,t);++T<g;){var k=t[T],$=e[T];if(o)var D=d?o($,k,T,e,t,l):o(k,$,T,t,e,l);if(D!==r){if(D)continue;M=!1;break}if(L){if(!ws(e,function(H,G){if(!An(L,G)&&(k===H||u(k,H,s,o,l)))return L.push(G)})){M=!1;break}}else if(!(k===$||u(k,$,s,o,l))){M=!1;break}}return l.delete(t),l.delete(e),M}function If(t,e,s,o,u,l,d){switch(s){case Xe:if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case Tn:return!(t.byteLength!=e.byteLength||!l(new dr(t),new dr(e)));case vn:case wn:case yn:return jt(+t,+e);case jn:return t.name==e.name&&t.message==e.message;case Sn:case xn:return t==e+"";case Vt:var g=As;case Zt:var b=o&K;if(g||(g=ar),t.size!=e.size&&!b)return!1;var x=d.get(t);if(x)return x==e;o|=Tt,d.set(t,e);var E=Ta(g(t),g(e),o,u,l,d);return d.delete(t),E;case er:if(Pn)return Pn.call(t)==Pn.call(e)}return!1}function Rf(t,e,s,o,u,l){var d=s&K,g=Xs(t),b=g.length,x=Xs(e),E=x.length;if(b!=E&&!d)return!1;for(var T=b;T--;){var M=g[T];if(!(d?M in e:Z.call(e,M)))return!1}var L=l.get(t),k=l.get(e);if(L&&k)return L==e&&k==t;var $=!0;l.set(t,e),l.set(e,t);for(var D=d;++T<b;){M=g[T];var H=t[M],G=e[M];if(o)var Bt=d?o(G,H,M,e,t,l):o(H,G,M,t,e,l);if(!(Bt===r?H===G||u(H,G,s,o,l):Bt)){$=!1;break}D||(D=M=="constructor")}if($&&!D){var xt=t.constructor,kt=e.constructor;xt!=kt&&"constructor"in t&&"constructor"in e&&!(typeof xt=="function"&&xt instanceof xt&&typeof kt=="function"&&kt instanceof kt)&&($=!1)}return l.delete(t),l.delete(e),$}function _e(t){return ii(Pa(t,r,Wa),t+"")}function Xs(t){return Jo(t,gt,ei)}function Qs(t){return Jo(t,It,Aa)}var js=vr?function(t){return vr.get(t)}:mi;function Lr(t){for(var e=t.name+"",s=on[e],o=Z.call(on,e)?s.length:0;o--;){var u=s[o],l=u.func;if(l==null||l==t)return u.name}return e}function hn(t){var e=Z.call(c,"placeholder")?c:t;return e.placeholder}function B(){var t=c.iteratee||_i;return t=t===_i?Yo:t,arguments.length?t(arguments[0],arguments[1]):t}function Br(t,e){var s=t.__data__;return Nf(e)?s[typeof e=="string"?"string":"hash"]:s.map}function ti(t){for(var e=gt(t),s=e.length;s--;){var o=e[s],u=t[o];e[s]=[o,u,Ra(u)]}return e}function qe(t,e){var s=Uh(t,e);return Ko(s)?s:r}function Mf(t){var e=Z.call(t,Ne),s=t[Ne];try{t[Ne]=r;var o=!0}catch{}var u=lr.call(t);return o&&(e?t[Ne]=s:delete t[Ne]),u}var ei=Is?function(t){return t==null?[]:(t=Q(t),Se(Is(t),function(e){return Oo.call(t,e)}))}:vi,Aa=Is?function(t){for(var e=[];t;)xe(e,ei(t)),t=pr(t);return e}:vi,vt=yt;(Rs&&vt(new Rs(new ArrayBuffer(1)))!=Xe||In&&vt(new In)!=Vt||Ms&&vt(Ms.resolve())!=$i||sn&&vt(new sn)!=Zt||Rn&&vt(new Rn)!=En)&&(vt=function(t){var e=yt(t),s=e==le?t.constructor:r,o=s?ze(s):"";if(o)switch(o){case ll:return Xe;case fl:return Vt;case dl:return $i;case pl:return Zt;case gl:return En}return e});function Pf(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=mt(e,t+d);break;case"takeRight":t=ft(t,e-d);break}}return{start:t,end:e}}function Of(t){var e=t.match(Nc);return e?e[1].split(Fc):[]}function Ca(t,e,s){e=Ie(e,t);for(var o=-1,u=e.length,l=!1;++o<u;){var d=ue(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&&$r(u)&&be(d,u)&&(F(t)||He(t)))}function Lf(t){var e=t.length,s=new t.constructor(e);return e&&typeof t[0]=="string"&&Z.call(t,"index")&&(s.index=t.index,s.input=t.input),s}function Ia(t){return typeof t.constructor=="function"&&!Fn(t)?an(pr(t)):{}}function Bf(t,e,s){var o=t.constructor;switch(e){case Tn:return Ys(t);case vn:case wn:return new o(+t);case Xe:return bf(t,s);case ts:case es:case ns:case rs:case ss:case is:case os:case as:case us:return ha(t,s);case Vt:return new o;case yn:case xn:return new o(t);case Sn:return mf(t);case Zt:return new o;case er:return vf(t)}}function kf(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(Dc,`{
|
|
21
|
-
/* [wrapped with `+
|
|
22
|
-
`)}function Df(t){return F(t)||He(t)||!!(Lo&&t&&t[Lo])}function be(t,e){var s=typeof t;return e=e??ye,!!e&&(s=="number"||s!="symbol"&&Kc.test(t))&&t>-1&&t%1==0&&t<e}function St(t,e,s){if(!nt(s))return!1;var o=typeof e;return(o=="number"?Ct(s)&&be(e,s.length):o=="string"&&e in s)?jt(s[e],t):!1}function ni(t,e){if(F(t))return!1;var s=typeof t;return s=="number"||s=="symbol"||s=="boolean"||t==null||Lt(t)?!0:Oc.test(t)||!Pc.test(t)||e!=null&&t in Q(e)}function Nf(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function ri(t){var e=Lr(t),s=c[e];if(typeof s!="function"||!(e in J.prototype))return!1;if(t===s)return!0;var o=js(s);return!!o&&t===o[0]}function Ff(t){return!!Ro&&Ro in t}var Uf=cr?me:wi;function Fn(t){var e=t&&t.constructor,s=typeof e=="function"&&e.prototype||rn;return t===s}function Ra(t){return t===t&&!nt(t)}function Ma(t,e){return function(s){return s==null?!1:s[t]===e&&(e!==r||t in Q(s))}}function Wf(t){var e=Ur(t,function(o){return s.size===I&&s.clear(),o}),s=e.cache;return e}function $f(t,e){var s=t[1],o=e[1],u=s|o,l=u<(pt|ut|q),d=o==q&&s==Kt||o==q&&s==ct&&t[7].length<=e[8]||o==(q|ct)&&e[7].length<=e[8]&&s==Kt;if(!(l||d))return t;o&pt&&(t[2]=e[2],u|=s&pt?0:Zn);var g=e[3];if(g){var b=t[3];t[3]=b?fa(b,g,e[4]):g,t[4]=b?Ee(t[3],P):e[4]}return g=e[5],g&&(b=t[5],t[5]=b?da(b,g,e[6]):g,t[6]=b?Ee(t[5],P):e[6]),g=e[7],g&&(t[7]=g),o&q&&(t[8]=t[8]==null?e[8]:mt(t[8],e[8])),t[9]==null&&(t[9]=e[9]),t[0]=e[0],t[1]=u,t}function qf(t){var e=[];if(t!=null)for(var s in Q(t))e.push(s);return e}function zf(t){return lr.call(t)}function Pa(t,e,s){return e=ft(e===r?t.length-1:e,0),function(){for(var o=arguments,u=-1,l=ft(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),Mt(t,this,g)}}function Oa(t,e){return e.length<2?t:$e(t,Ht(e,0,-1))}function Hf(t,e){for(var s=t.length,o=mt(e.length,s),u=At(t);o--;){var l=e[o];t[o]=be(l,s)?u[l]:r}return t}function si(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var La=ka(na),Un=sl||function(t,e){return _t.setTimeout(t,e)},ii=ka(df);function Ba(t,e,s){var o=e+"";return ii(t,kf(o,Jf(Of(o),s)))}function ka(t){var e=0,s=0;return function(){var o=ul(),u=st-(o-s);if(s=o,u>0){if(++e>=Ft)return arguments[0]}else e=0;return t.apply(r,arguments)}}function kr(t,e){var s=-1,o=t.length,u=o-1;for(e=e===r?o:e;++s<e;){var l=$s(s,u),d=t[l];t[l]=t[s],t[s]=d}return t.length=e,t}var Da=Wf(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(Lc,function(s,o,u,l){e.push(u?l.replace($c,"$1"):o||s)}),e});function ue(t){if(typeof t=="string"||Lt(t))return t;var e=t+"";return e=="0"&&1/t==-ke?"-0":e}function ze(t){if(t!=null){try{return hr.call(t)}catch{}try{return t+""}catch{}}return""}function Jf(t,e){return Wt(bc,function(s){var o="_."+s[0];e&s[1]&&!ir(t,o)&&t.push(o)}),t.sort()}function Na(t){if(t instanceof J)return t.clone();var e=new qt(t.__wrapped__,t.__chain__);return e.__actions__=At(t.__actions__),e.__index__=t.__index__,e.__values__=t.__values__,e}function Gf(t,e,s){(s?St(t,e,s):e===r)?e=1:e=ft(W(e),0);var o=t==null?0:t.length;if(!o||e<1)return[];for(var u=0,l=0,d=v(br(o/e));u<o;)d[l++]=Ht(t,u,u+=e);return d}function Kf(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 Yf(){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 xe(F(s)?At(s):[s],bt(e,1))}var Vf=z(function(t,e){return ot(t)?Ln(t,bt(e,1,ot,!0)):[]}),Zf=z(function(t,e){var s=Jt(e);return ot(s)&&(s=r),ot(t)?Ln(t,bt(e,1,ot,!0),B(s,2)):[]}),Xf=z(function(t,e){var s=Jt(e);return ot(s)&&(s=r),ot(t)?Ln(t,bt(e,1,ot,!0),r,s):[]});function Qf(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),Ht(t,e<0?0:e,o)):[]}function jf(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),e=o-e,Ht(t,0,e<0?0:e)):[]}function td(t,e){return t&&t.length?Cr(t,B(e,3),!0,!0):[]}function ed(t,e){return t&&t.length?Cr(t,B(e,3),!0):[]}function nd(t,e,s,o){var u=t==null?0:t.length;return u?(s&&typeof s!="number"&&St(t,e,s)&&(s=0,o=u),Kl(t,e,s,o)):[]}function Fa(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=ft(o+u,0)),or(t,B(e,3),u)}function Ua(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?ft(o+u,0):mt(u,o-1)),or(t,B(e,3),u,!0)}function Wa(t){var e=t==null?0:t.length;return e?bt(t,1):[]}function rd(t){var e=t==null?0:t.length;return e?bt(t,ke):[]}function sd(t,e){var s=t==null?0:t.length;return s?(e=e===r?1:W(e),bt(t,e)):[]}function id(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 $a(t){return t&&t.length?t[0]:r}function od(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=ft(o+u,0)),je(t,e,u)}function ad(t){var e=t==null?0:t.length;return e?Ht(t,0,-1):[]}var ud=z(function(t){var e=et(t,Gs);return e.length&&e[0]===t[0]?Ds(e):[]}),cd=z(function(t){var e=Jt(t),s=et(t,Gs);return e===Jt(s)?e=r:s.pop(),s.length&&s[0]===t[0]?Ds(s,B(e,2)):[]}),hd=z(function(t){var e=Jt(t),s=et(t,Gs);return e=typeof e=="function"?e:r,e&&s.pop(),s.length&&s[0]===t[0]?Ds(s,r,e):[]});function ld(t,e){return t==null?"":ol.call(t,e)}function Jt(t){var e=t==null?0:t.length;return e?t[e-1]:r}function fd(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?ft(o+u,0):mt(u,o-1)),e===e?Hh(t,e,u):or(t,yo,u,!0)}function dd(t,e){return t&&t.length?Qo(t,W(e)):r}var pd=z(qa);function qa(t,e){return t&&t.length&&e&&e.length?Ws(t,e):t}function gd(t,e,s){return t&&t.length&&e&&e.length?Ws(t,e,B(s,2)):t}function _d(t,e,s){return t&&t.length&&e&&e.length?Ws(t,e,r,s):t}var bd=_e(function(t,e){var s=t==null?0:t.length,o=Os(t,e);return ea(t,et(e,function(u){return be(u,s)?+u:u}).sort(la)),o});function md(t,e){var s=[];if(!(t&&t.length))return s;var o=-1,u=[],l=t.length;for(e=B(e,3);++o<l;){var d=t[o];e(d,o,t)&&(s.push(d),u.push(o))}return ea(t,u),s}function oi(t){return t==null?t:hl.call(t)}function vd(t,e,s){var o=t==null?0:t.length;return o?(s&&typeof s!="number"&&St(t,e,s)?(e=0,s=o):(e=e==null?0:W(e),s=s===r?o:W(s)),Ht(t,e,s)):[]}function wd(t,e){return Ar(t,e)}function yd(t,e,s){return zs(t,e,B(s,2))}function Sd(t,e){var s=t==null?0:t.length;if(s){var o=Ar(t,e);if(o<s&&jt(t[o],e))return o}return-1}function xd(t,e){return Ar(t,e,!0)}function Ed(t,e,s){return zs(t,e,B(s,2),!0)}function Td(t,e){var s=t==null?0:t.length;if(s){var o=Ar(t,e,!0)-1;if(jt(t[o],e))return o}return-1}function Ad(t){return t&&t.length?ra(t):[]}function Cd(t,e){return t&&t.length?ra(t,B(e,2)):[]}function Id(t){var e=t==null?0:t.length;return e?Ht(t,1,e):[]}function Rd(t,e,s){return t&&t.length?(e=s||e===r?1:W(e),Ht(t,0,e<0?0:e)):[]}function Md(t,e,s){var o=t==null?0:t.length;return o?(e=s||e===r?1:W(e),e=o-e,Ht(t,e<0?0:e,o)):[]}function Pd(t,e){return t&&t.length?Cr(t,B(e,3),!1,!0):[]}function Od(t,e){return t&&t.length?Cr(t,B(e,3)):[]}var Ld=z(function(t){return Ce(bt(t,1,ot,!0))}),Bd=z(function(t){var e=Jt(t);return ot(e)&&(e=r),Ce(bt(t,1,ot,!0),B(e,2))}),kd=z(function(t){var e=Jt(t);return e=typeof e=="function"?e:r,Ce(bt(t,1,ot,!0),r,e)});function Dd(t){return t&&t.length?Ce(t):[]}function Nd(t,e){return t&&t.length?Ce(t,B(e,2)):[]}function Fd(t,e){return e=typeof e=="function"?e:r,t&&t.length?Ce(t,r,e):[]}function ai(t){if(!(t&&t.length))return[];var e=0;return t=Se(t,function(s){if(ot(s))return e=ft(s.length,e),!0}),Es(e,function(s){return et(t,ys(s))})}function za(t,e){if(!(t&&t.length))return[];var s=ai(t);return e==null?s:et(s,function(o){return Mt(e,r,o)})}var Ud=z(function(t,e){return ot(t)?Ln(t,e):[]}),Wd=z(function(t){return Js(Se(t,ot))}),$d=z(function(t){var e=Jt(t);return ot(e)&&(e=r),Js(Se(t,ot),B(e,2))}),qd=z(function(t){var e=Jt(t);return e=typeof e=="function"?e:r,Js(Se(t,ot),r,e)}),zd=z(ai);function Hd(t,e){return aa(t||[],e||[],On)}function Jd(t,e){return aa(t||[],e||[],Dn)}var Gd=z(function(t){var e=t.length,s=e>1?t[e-1]:r;return s=typeof s=="function"?(t.pop(),s):r,za(t,s)});function Ha(t){var e=c(t);return e.__chain__=!0,e}function Kd(t,e){return e(t),t}function Dr(t,e){return e(t)}var Yd=_e(function(t){var e=t.length,s=e?t[0]:0,o=this.__wrapped__,u=function(l){return Os(l,t)};return e>1||this.__actions__.length||!(o instanceof J)||!be(s)?this.thru(u):(o=o.slice(s,+s+(e?1:0)),o.__actions__.push({func:Dr,args:[u],thisArg:r}),new qt(o,this.__chain__).thru(function(l){return e&&!l.length&&l.push(r),l}))});function Vd(){return Ha(this)}function Zd(){return new qt(this.value(),this.__chain__)}function Xd(){this.__values__===r&&(this.__values__=su(this.value()));var t=this.__index__>=this.__values__.length,e=t?r:this.__values__[this.__index__++];return{done:t,value:e}}function Qd(){return this}function jd(t){for(var e,s=this;s instanceof yr;){var o=Na(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 tp(){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:Dr,args:[oi],thisArg:r}),new qt(e,this.__chain__)}return this.thru(oi)}function ep(){return oa(this.__wrapped__,this.__actions__)}var np=Ir(function(t,e,s){Z.call(t,s)?++t[s]:pe(t,s,1)});function rp(t,e,s){var o=F(t)?vo:Gl;return s&&St(t,e,s)&&(e=r),o(t,B(e,3))}function sp(t,e){var s=F(t)?Se:zo;return s(t,B(e,3))}var ip=ba(Fa),op=ba(Ua);function ap(t,e){return bt(Nr(t,e),1)}function up(t,e){return bt(Nr(t,e),ke)}function cp(t,e,s){return s=s===r?1:W(s),bt(Nr(t,e),s)}function Ja(t,e){var s=F(t)?Wt:Ae;return s(t,B(e,3))}function Ga(t,e){var s=F(t)?Ch:qo;return s(t,B(e,3))}var hp=Ir(function(t,e,s){Z.call(t,s)?t[s].push(e):pe(t,s,[e])});function lp(t,e,s,o){t=Ct(t)?t:fn(t),s=s&&!o?W(s):0;var u=t.length;return s<0&&(s=ft(u+s,0)),qr(t)?s<=u&&t.indexOf(e,s)>-1:!!u&&je(t,e,s)>-1}var fp=z(function(t,e,s){var o=-1,u=typeof e=="function",l=Ct(t)?v(t.length):[];return Ae(t,function(d){l[++o]=u?Mt(e,d,s):Bn(d,e,s)}),l}),dp=Ir(function(t,e,s){pe(t,s,e)});function Nr(t,e){var s=F(t)?et:Vo;return s(t,B(e,3))}function pp(t,e,s,o){return t==null?[]:(F(e)||(e=e==null?[]:[e]),s=o?r:s,F(s)||(s=s==null?[]:[s]),jo(t,e,s))}var gp=Ir(function(t,e,s){t[s?0:1].push(e)},function(){return[[],[]]});function _p(t,e,s){var o=F(t)?vs:xo,u=arguments.length<3;return o(t,B(e,4),s,u,Ae)}function bp(t,e,s){var o=F(t)?Ih:xo,u=arguments.length<3;return o(t,B(e,4),s,u,qo)}function mp(t,e){var s=F(t)?Se:zo;return s(t,Wr(B(e,3)))}function vp(t){var e=F(t)?Fo:lf;return e(t)}function wp(t,e,s){(s?St(t,e,s):e===r)?e=1:e=W(e);var o=F(t)?$l:ff;return o(t,e)}function yp(t){var e=F(t)?ql:pf;return e(t)}function Sp(t){if(t==null)return 0;if(Ct(t))return qr(t)?en(t):t.length;var e=vt(t);return e==Vt||e==Zt?t.size:Fs(t).length}function xp(t,e,s){var o=F(t)?ws:gf;return s&&St(t,e,s)&&(e=r),o(t,B(e,3))}var Ep=z(function(t,e){if(t==null)return[];var s=e.length;return s>1&&St(t,e[0],e[1])?e=[]:s>2&&St(e[0],e[1],e[2])&&(e=[e[0]]),jo(t,bt(e,1),[])}),Fr=rl||function(){return _t.Date.now()};function Tp(t,e){if(typeof e!="function")throw new $t(p);return t=W(t),function(){if(--t<1)return e.apply(this,arguments)}}function Ka(t,e,s){return e=s?r:e,e=t&&e==null?t.length:e,ge(t,q,r,r,r,r,e)}function Ya(t,e){var s;if(typeof e!="function")throw new $t(p);return t=W(t),function(){return--t>0&&(s=e.apply(this,arguments)),t<=1&&(e=r),s}}var ui=z(function(t,e,s){var o=pt;if(s.length){var u=Ee(s,hn(ui));o|=Yt}return ge(t,o,e,s,u)}),Va=z(function(t,e,s){var o=pt|ut;if(s.length){var u=Ee(s,hn(Va));o|=Yt}return ge(e,o,t,s,u)});function Za(t,e,s){e=s?r:e;var o=ge(t,Kt,r,r,r,r,r,e);return o.placeholder=Za.placeholder,o}function Xa(t,e,s){e=s?r:e;var o=ge(t,Le,r,r,r,r,r,e);return o.placeholder=Xa.placeholder,o}function Qa(t,e,s){var o,u,l,d,g,b,x=0,E=!1,T=!1,M=!0;if(typeof t!="function")throw new $t(p);e=Gt(e)||0,nt(s)&&(E=!!s.leading,T="maxWait"in s,l=T?ft(Gt(s.maxWait)||0,e):l,M="trailing"in s?!!s.trailing:M);function L(at){var te=o,we=u;return o=u=r,x=at,d=t.apply(we,te),d}function k(at){return x=at,g=Un(H,e),E?L(at):d}function $(at){var te=at-b,we=at-x,bu=e-te;return T?mt(bu,l-we):bu}function D(at){var te=at-b,we=at-x;return b===r||te>=e||te<0||T&&we>=l}function H(){var at=Fr();if(D(at))return G(at);g=Un(H,$(at))}function G(at){return g=r,M&&o?L(at):(o=u=r,d)}function Bt(){g!==r&&ua(g),x=0,o=b=u=g=r}function xt(){return g===r?d:G(Fr())}function kt(){var at=Fr(),te=D(at);if(o=arguments,u=this,b=at,te){if(g===r)return k(b);if(T)return ua(g),g=Un(H,e),L(b)}return g===r&&(g=Un(H,e)),d}return kt.cancel=Bt,kt.flush=xt,kt}var Ap=z(function(t,e){return $o(t,1,e)}),Cp=z(function(t,e,s){return $o(t,Gt(e)||0,s)});function Ip(t){return ge(t,X)}function Ur(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new $t(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(Ur.Cache||de),s}Ur.Cache=de;function Wr(t){if(typeof t!="function")throw new $t(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 Rp(t){return Ya(2,t)}var Mp=_f(function(t,e){e=e.length==1&&F(e[0])?et(e[0],Pt(B())):et(bt(e,1),Pt(B()));var s=e.length;return z(function(o){for(var u=-1,l=mt(o.length,s);++u<l;)o[u]=e[u].call(this,o[u]);return Mt(t,this,o)})}),ci=z(function(t,e){var s=Ee(e,hn(ci));return ge(t,Yt,r,e,s)}),ja=z(function(t,e){var s=Ee(e,hn(ja));return ge(t,Be,r,e,s)}),Pp=_e(function(t,e){return ge(t,ct,r,r,r,e)});function Op(t,e){if(typeof t!="function")throw new $t(p);return e=e===r?e:W(e),z(t,e)}function Lp(t,e){if(typeof t!="function")throw new $t(p);return e=e==null?0:ft(W(e),0),z(function(s){var o=s[e],u=Re(s,0,e);return o&&xe(u,o),Mt(t,this,u)})}function Bp(t,e,s){var o=!0,u=!0;if(typeof t!="function")throw new $t(p);return nt(s)&&(o="leading"in s?!!s.leading:o,u="trailing"in s?!!s.trailing:u),Qa(t,e,{leading:o,maxWait:e,trailing:u})}function kp(t){return Ka(t,1)}function Dp(t,e){return ci(Ks(e),t)}function Np(){if(!arguments.length)return[];var t=arguments[0];return F(t)?t:[t]}function Fp(t){return zt(t,R)}function Up(t,e){return e=typeof e=="function"?e:r,zt(t,R,e)}function Wp(t){return zt(t,C|R)}function $p(t,e){return e=typeof e=="function"?e:r,zt(t,C|R,e)}function qp(t,e){return e==null||Wo(t,e,gt(e))}function jt(t,e){return t===e||t!==t&&e!==e}var zp=Or(ks),Hp=Or(function(t,e){return t>=e}),He=Go(function(){return arguments}())?Go:function(t){return it(t)&&Z.call(t,"callee")&&!Oo.call(t,"callee")},F=v.isArray,Jp=fo?Pt(fo):Ql;function Ct(t){return t!=null&&$r(t.length)&&!me(t)}function ot(t){return it(t)&&Ct(t)}function Gp(t){return t===!0||t===!1||it(t)&&yt(t)==vn}var Me=il||wi,Kp=po?Pt(po):jl;function Yp(t){return it(t)&&t.nodeType===1&&!Wn(t)}function Vp(t){if(t==null)return!0;if(Ct(t)&&(F(t)||typeof t=="string"||typeof t.splice=="function"||Me(t)||ln(t)||He(t)))return!t.length;var e=vt(t);if(e==Vt||e==Zt)return!t.size;if(Fn(t))return!Fs(t).length;for(var s in t)if(Z.call(t,s))return!1;return!0}function Zp(t,e){return kn(t,e)}function Xp(t,e,s){s=typeof s=="function"?s:r;var o=s?s(t,e):r;return o===r?kn(t,e,r,s):!!o}function hi(t){if(!it(t))return!1;var e=yt(t);return e==jn||e==vc||typeof t.message=="string"&&typeof t.name=="string"&&!Wn(t)}function Qp(t){return typeof t=="number"&&Bo(t)}function me(t){if(!nt(t))return!1;var e=yt(t);return e==tr||e==Wi||e==mc||e==yc}function tu(t){return typeof t=="number"&&t==W(t)}function $r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=ye}function nt(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}function it(t){return t!=null&&typeof t=="object"}var eu=go?Pt(go):ef;function jp(t,e){return t===e||Ns(t,e,ti(e))}function tg(t,e,s){return s=typeof s=="function"?s:r,Ns(t,e,ti(e),s)}function eg(t){return nu(t)&&t!=+t}function ng(t){if(Uf(t))throw new N(f);return Ko(t)}function rg(t){return t===null}function sg(t){return t==null}function nu(t){return typeof t=="number"||it(t)&&yt(t)==yn}function Wn(t){if(!it(t)||yt(t)!=le)return!1;var e=pr(t);if(e===null)return!0;var s=Z.call(e,"constructor")&&e.constructor;return typeof s=="function"&&s instanceof s&&hr.call(s)==jh}var li=_o?Pt(_o):nf;function ig(t){return tu(t)&&t>=-ye&&t<=ye}var ru=bo?Pt(bo):rf;function qr(t){return typeof t=="string"||!F(t)&&it(t)&&yt(t)==xn}function Lt(t){return typeof t=="symbol"||it(t)&&yt(t)==er}var ln=mo?Pt(mo):sf;function og(t){return t===r}function ag(t){return it(t)&&vt(t)==En}function ug(t){return it(t)&&yt(t)==xc}var cg=Or(Us),hg=Or(function(t,e){return t<=e});function su(t){if(!t)return[];if(Ct(t))return qr(t)?Xt(t):At(t);if(Cn&&t[Cn])return $h(t[Cn]());var e=vt(t),s=e==Vt?As:e==Zt?ar:fn;return s(t)}function ve(t){if(!t)return t===0?t:0;if(t=Gt(t),t===ke||t===-ke){var e=t<0?-1:1;return e*pc}return t===t?t:0}function W(t){var e=ve(t),s=e%1;return e===e?s?e-s:e:0}function iu(t){return t?We(W(t),0,ie):0}function Gt(t){if(typeof t=="number")return t;if(Lt(t))return Xn;if(nt(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=nt(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=Eo(t);var s=Hc.test(t);return s||Gc.test(t)?Eh(t.slice(2),s?2:8):zc.test(t)?Xn:+t}function ou(t){return ae(t,It(t))}function lg(t){return t?We(W(t),-ye,ye):t===0?t:0}function V(t){return t==null?"":Ot(t)}var fg=un(function(t,e){if(Fn(e)||Ct(e)){ae(e,gt(e),t);return}for(var s in e)Z.call(e,s)&&On(t,s,e[s])}),au=un(function(t,e){ae(e,It(e),t)}),zr=un(function(t,e,s,o){ae(e,It(e),t,o)}),dg=un(function(t,e,s,o){ae(e,gt(e),t,o)}),pg=_e(Os);function gg(t,e){var s=an(t);return e==null?s:Uo(s,e)}var _g=z(function(t,e){t=Q(t);var s=-1,o=e.length,u=o>2?e[2]:r;for(u&&St(e[0],e[1],u)&&(o=1);++s<o;)for(var l=e[s],d=It(l),g=-1,b=d.length;++g<b;){var x=d[g],E=t[x];(E===r||jt(E,rn[x])&&!Z.call(t,x))&&(t[x]=l[x])}return t}),bg=z(function(t){return t.push(r,Ea),Mt(uu,r,t)});function mg(t,e){return wo(t,B(e,3),oe)}function vg(t,e){return wo(t,B(e,3),Bs)}function wg(t,e){return t==null?t:Ls(t,B(e,3),It)}function yg(t,e){return t==null?t:Ho(t,B(e,3),It)}function Sg(t,e){return t&&oe(t,B(e,3))}function xg(t,e){return t&&Bs(t,B(e,3))}function Eg(t){return t==null?[]:Er(t,gt(t))}function Tg(t){return t==null?[]:Er(t,It(t))}function fi(t,e,s){var o=t==null?r:$e(t,e);return o===r?s:o}function Ag(t,e){return t!=null&&Ca(t,e,Yl)}function di(t,e){return t!=null&&Ca(t,e,Vl)}var Cg=va(function(t,e,s){e!=null&&typeof e.toString!="function"&&(e=lr.call(e)),t[e]=s},gi(Rt)),Ig=va(function(t,e,s){e!=null&&typeof e.toString!="function"&&(e=lr.call(e)),Z.call(t,e)?t[e].push(s):t[e]=[s]},B),Rg=z(Bn);function gt(t){return Ct(t)?No(t):Fs(t)}function It(t){return Ct(t)?No(t,!0):of(t)}function Mg(t,e){var s={};return e=B(e,3),oe(t,function(o,u,l){pe(s,e(o,u,l),o)}),s}function Pg(t,e){var s={};return e=B(e,3),oe(t,function(o,u,l){pe(s,u,e(o,u,l))}),s}var Og=un(function(t,e,s){Tr(t,e,s)}),uu=un(function(t,e,s,o){Tr(t,e,s,o)}),Lg=_e(function(t,e){var s={};if(t==null)return s;var o=!1;e=et(e,function(l){return l=Ie(l,t),o||(o=l.length>1),l}),ae(t,Qs(t),s),o&&(s=zt(s,C|A|R,Cf));for(var u=e.length;u--;)Hs(s,e[u]);return s});function Bg(t,e){return cu(t,Wr(B(e)))}var kg=_e(function(t,e){return t==null?{}:uf(t,e)});function cu(t,e){if(t==null)return{};var s=et(Qs(t),function(o){return[o]});return e=B(e),ta(t,s,function(o,u){return e(o,u[0])})}function Dg(t,e,s){e=Ie(e,t);var o=-1,u=e.length;for(u||(u=1,t=r);++o<u;){var l=t==null?r:t[ue(e[o])];l===r&&(o=u,l=s),t=me(l)?l.call(t):l}return t}function Ng(t,e,s){return t==null?t:Dn(t,e,s)}function Fg(t,e,s,o){return o=typeof o=="function"?o:r,t==null?t:Dn(t,e,s,o)}var hu=Sa(gt),lu=Sa(It);function Ug(t,e,s){var o=F(t),u=o||Me(t)||ln(t);if(e=B(e,4),s==null){var l=t&&t.constructor;u?s=o?new l:[]:nt(t)?s=me(l)?an(pr(t)):{}:s={}}return(u?Wt:oe)(t,function(d,g,b){return e(s,d,g,b)}),s}function Wg(t,e){return t==null?!0:Hs(t,e)}function $g(t,e,s){return t==null?t:ia(t,e,Ks(s))}function qg(t,e,s,o){return o=typeof o=="function"?o:r,t==null?t:ia(t,e,Ks(s),o)}function fn(t){return t==null?[]:Ts(t,gt(t))}function zg(t){return t==null?[]:Ts(t,It(t))}function Hg(t,e,s){return s===r&&(s=e,e=r),s!==r&&(s=Gt(s),s=s===s?s:0),e!==r&&(e=Gt(e),e=e===e?e:0),We(Gt(t),e,s)}function Jg(t,e,s){return e=ve(e),s===r?(s=e,e=0):s=ve(s),t=Gt(t),Zl(t,e,s)}function Gg(t,e,s){if(s&&typeof s!="boolean"&&St(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=ve(t),e===r?(e=t,t=0):e=ve(e)),t>e){var o=t;t=e,e=o}if(s||t%1||e%1){var u=ko();return mt(t+u*(e-t+xh("1e-"+((u+"").length-1))),e)}return $s(t,e)}var Kg=cn(function(t,e,s){return e=e.toLowerCase(),t+(s?fu(e):e)});function fu(t){return pi(V(t).toLowerCase())}function du(t){return t=V(t),t&&t.replace(Yc,Dh).replace(dh,"")}function Yg(t,e,s){t=V(t),e=Ot(e);var o=t.length;s=s===r?o:We(W(s),0,o);var u=s;return s-=e.length,s>=0&&t.slice(s,u)==e}function Vg(t){return t=V(t),t&&Ic.test(t)?t.replace(zi,Nh):t}function Zg(t){return t=V(t),t&&Bc.test(t)?t.replace(cs,"\\$&"):t}var Xg=cn(function(t,e,s){return t+(s?"-":"")+e.toLowerCase()}),Qg=cn(function(t,e,s){return t+(s?" ":"")+e.toLowerCase()}),jg=_a("toLowerCase");function t_(t,e,s){t=V(t),e=W(e);var o=e?en(t):0;if(!e||o>=e)return t;var u=(e-o)/2;return Pr(mr(u),s)+t+Pr(br(u),s)}function e_(t,e,s){t=V(t),e=W(e);var o=e?en(t):0;return e&&o<e?t+Pr(e-o,s):t}function n_(t,e,s){t=V(t),e=W(e);var o=e?en(t):0;return e&&o<e?Pr(e-o,s)+t:t}function r_(t,e,s){return s||e==null?e=0:e&&(e=+e),cl(V(t).replace(hs,""),e||0)}function s_(t,e,s){return(s?St(t,e,s):e===r)?e=1:e=W(e),qs(V(t),e)}function i_(){var t=arguments,e=V(t[0]);return t.length<3?e:e.replace(t[1],t[2])}var o_=cn(function(t,e,s){return t+(s?"_":"")+e.toLowerCase()});function a_(t,e,s){return s&&typeof s!="number"&&St(t,e,s)&&(e=s=r),s=s===r?ie:s>>>0,s?(t=V(t),t&&(typeof e=="string"||e!=null&&!li(e))&&(e=Ot(e),!e&&tn(t))?Re(Xt(t),0,s):t.split(e,s)):[]}var u_=cn(function(t,e,s){return t+(s?" ":"")+pi(e)});function c_(t,e,s){return t=V(t),s=s==null?0:We(W(s),0,t.length),e=Ot(e),t.slice(s,s+e.length)==e}function h_(t,e,s){var o=c.templateSettings;s&&St(t,e,s)&&(e=r),t=V(t),e=zr({},e,o,xa);var u=zr({},e.imports,o.imports,xa),l=gt(u),d=Ts(u,l),g,b,x=0,E=e.interpolate||nr,T="__p += '",M=Cs((e.escape||nr).source+"|"+E.source+"|"+(E===Hi?qc:nr).source+"|"+(e.evaluate||nr).source+"|$","g"),L="//# sourceURL="+(Z.call(e,"sourceURL")?(e.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++mh+"]")+`
|
|
23
|
-
`;
|
|
24
|
-
__e(`+
|
|
25
|
-
'`),
|
|
26
|
-
`+
|
|
27
|
-
__p += '`),
|
|
28
|
-
((__t = (`+
|
|
29
|
-
'`),
|
|
30
|
-
`;var
|
|
31
|
-
`+
|
|
8
|
+
*/vr.exports;(function(m,g){(function(){var i,w="4.17.21",y=200,R="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",A="Expected a function",O="Invalid `variable` option passed into `_.template`",q="__lodash_hash_undefined__",tn=500,An="__lodash_placeholder__",en=1,bn=2,hn=4,Rn=1,ct=2,wn=1,mn=2,Se=4,Gn=8,St=16,zn=32,Ct=64,F=128,nn=256,z=512,Wn=30,rn="...",Mn=800,X=16,gn=1,Po=2,To=3,At=1/0,ht=9007199254740991,Eo=17976931348623157e292,Ce=NaN,Qn=4294967295,Io=Qn-1,Lo=Qn>>>1,Oo=[["ary",F],["bind",wn],["bindKey",mn],["curry",Gn],["curryRight",St],["flip",z],["partial",zn],["partialRight",Ct],["rearg",nn]],Ft="[object Arguments]",Ae="[object Array]",Wo="[object AsyncFunction]",Qt="[object Boolean]",Vt="[object Date]",Mo="[object DOMException]",be="[object Error]",Re="[object Function]",zi="[object GeneratorFunction]",Hn="[object Map]",jt="[object Number]",Fo="[object Null]",tt="[object Object]",Hi="[object Promise]",Uo="[object Proxy]",ne="[object RegExp]",kn="[object Set]",te="[object String]",Pe="[object Symbol]",Do="[object Undefined]",ee="[object WeakMap]",No="[object WeakSet]",re="[object ArrayBuffer]",Ut="[object DataView]",mr="[object Float32Array]",yr="[object Float64Array]",xr="[object Int8Array]",Sr="[object Int16Array]",Cr="[object Int32Array]",Ar="[object Uint8Array]",br="[object Uint8ClampedArray]",Rr="[object Uint16Array]",Pr="[object Uint32Array]",Bo=/\b__p \+= '';/g,$o=/\b(__p \+=) '' \+/g,qo=/(__e\(.*?\)|\b__t\)) \+\n'';/g,ki=/&(?:amp|lt|gt|quot|#39);/g,Ji=/[&<>"']/g,Ko=RegExp(ki.source),Go=RegExp(Ji.source),zo=/<%-([\s\S]+?)%>/g,Ho=/<%([\s\S]+?)%>/g,Zi=/<%=([\s\S]+?)%>/g,ko=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Jo=/^\w*$/,Zo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Tr=/[\\^$.*+?()[\]{}|]/g,Yo=RegExp(Tr.source),Er=/^\s+/,Xo=/\s/,Qo=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Vo=/\{\n\/\* \[wrapped with (.+)\] \*/,jo=/,? & /,na=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ta=/[()=,{}\[\]\/\s]/,ea=/\\(\\)?/g,ra=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Yi=/\w*$/,ia=/^[-+]0x[0-9a-f]+$/i,ua=/^0b[01]+$/i,sa=/^\[object .+?Constructor\]$/,oa=/^0o[0-7]+$/i,aa=/^(?:0|[1-9]\d*)$/,fa=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Te=/($^)/,la=/['\n\r\u2028\u2029\\]/g,Ee="\\ud800-\\udfff",ca="\\u0300-\\u036f",ha="\\ufe20-\\ufe2f",ga="\\u20d0-\\u20ff",Xi=ca+ha+ga,Qi="\\u2700-\\u27bf",Vi="a-z\\xdf-\\xf6\\xf8-\\xff",pa="\\xac\\xb1\\xd7\\xf7",da="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",_a="\\u2000-\\u206f",va=" \\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",ji="A-Z\\xc0-\\xd6\\xd8-\\xde",nu="\\ufe0e\\ufe0f",tu=pa+da+_a+va,Ir="['’]",wa="["+Ee+"]",eu="["+tu+"]",Ie="["+Xi+"]",ru="\\d+",ma="["+Qi+"]",iu="["+Vi+"]",uu="[^"+Ee+tu+ru+Qi+Vi+ji+"]",Lr="\\ud83c[\\udffb-\\udfff]",ya="(?:"+Ie+"|"+Lr+")",su="[^"+Ee+"]",Or="(?:\\ud83c[\\udde6-\\uddff]){2}",Wr="[\\ud800-\\udbff][\\udc00-\\udfff]",Dt="["+ji+"]",ou="\\u200d",au="(?:"+iu+"|"+uu+")",xa="(?:"+Dt+"|"+uu+")",fu="(?:"+Ir+"(?:d|ll|m|re|s|t|ve))?",lu="(?:"+Ir+"(?:D|LL|M|RE|S|T|VE))?",cu=ya+"?",hu="["+nu+"]?",Sa="(?:"+ou+"(?:"+[su,Or,Wr].join("|")+")"+hu+cu+")*",Ca="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",Aa="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",gu=hu+cu+Sa,ba="(?:"+[ma,Or,Wr].join("|")+")"+gu,Ra="(?:"+[su+Ie+"?",Ie,Or,Wr,wa].join("|")+")",Pa=RegExp(Ir,"g"),Ta=RegExp(Ie,"g"),Mr=RegExp(Lr+"(?="+Lr+")|"+Ra+gu,"g"),Ea=RegExp([Dt+"?"+iu+"+"+fu+"(?="+[eu,Dt,"$"].join("|")+")",xa+"+"+lu+"(?="+[eu,Dt+au,"$"].join("|")+")",Dt+"?"+au+"+"+fu,Dt+"+"+lu,Aa,Ca,ru,ba].join("|"),"g"),Ia=RegExp("["+ou+Ee+Xi+nu+"]"),La=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Oa=["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"],Wa=-1,J={};J[mr]=J[yr]=J[xr]=J[Sr]=J[Cr]=J[Ar]=J[br]=J[Rr]=J[Pr]=!0,J[Ft]=J[Ae]=J[re]=J[Qt]=J[Ut]=J[Vt]=J[be]=J[Re]=J[Hn]=J[jt]=J[tt]=J[ne]=J[kn]=J[te]=J[ee]=!1;var k={};k[Ft]=k[Ae]=k[re]=k[Ut]=k[Qt]=k[Vt]=k[mr]=k[yr]=k[xr]=k[Sr]=k[Cr]=k[Hn]=k[jt]=k[tt]=k[ne]=k[kn]=k[te]=k[Pe]=k[Ar]=k[br]=k[Rr]=k[Pr]=!0,k[be]=k[Re]=k[ee]=!1;var Ma={À:"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"},Fa={"&":"&","<":"<",">":">",'"':""","'":"'"},Ua={"&":"&","<":"<",">":">",""":'"',"'":"'"},Da={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Na=parseFloat,Ba=parseInt,pu=typeof me=="object"&&me&&me.Object===Object&&me,$a=typeof self=="object"&&self&&self.Object===Object&&self,an=pu||$a||Function("return this")(),Fr=g&&!g.nodeType&&g,bt=Fr&&!0&&m&&!m.nodeType&&m,du=bt&&bt.exports===Fr,Ur=du&&pu.process,Fn=function(){try{var l=bt&&bt.require&&bt.require("util").types;return l||Ur&&Ur.binding&&Ur.binding("util")}catch{}}(),_u=Fn&&Fn.isArrayBuffer,vu=Fn&&Fn.isDate,wu=Fn&&Fn.isMap,mu=Fn&&Fn.isRegExp,yu=Fn&&Fn.isSet,xu=Fn&&Fn.isTypedArray;function Pn(l,p,h){switch(h.length){case 0:return l.call(p);case 1:return l.call(p,h[0]);case 2:return l.call(p,h[0],h[1]);case 3:return l.call(p,h[0],h[1],h[2])}return l.apply(p,h)}function qa(l,p,h,S){for(var I=-1,$=l==null?0:l.length;++I<$;){var un=l[I];p(S,un,h(un),l)}return S}function Un(l,p){for(var h=-1,S=l==null?0:l.length;++h<S&&p(l[h],h,l)!==!1;);return l}function Ka(l,p){for(var h=l==null?0:l.length;h--&&p(l[h],h,l)!==!1;);return l}function Su(l,p){for(var h=-1,S=l==null?0:l.length;++h<S;)if(!p(l[h],h,l))return!1;return!0}function gt(l,p){for(var h=-1,S=l==null?0:l.length,I=0,$=[];++h<S;){var un=l[h];p(un,h,l)&&($[I++]=un)}return $}function Le(l,p){var h=l==null?0:l.length;return!!h&&Nt(l,p,0)>-1}function Dr(l,p,h){for(var S=-1,I=l==null?0:l.length;++S<I;)if(h(p,l[S]))return!0;return!1}function Z(l,p){for(var h=-1,S=l==null?0:l.length,I=Array(S);++h<S;)I[h]=p(l[h],h,l);return I}function pt(l,p){for(var h=-1,S=p.length,I=l.length;++h<S;)l[I+h]=p[h];return l}function Nr(l,p,h,S){var I=-1,$=l==null?0:l.length;for(S&&$&&(h=l[++I]);++I<$;)h=p(h,l[I],I,l);return h}function Ga(l,p,h,S){var I=l==null?0:l.length;for(S&&I&&(h=l[--I]);I--;)h=p(h,l[I],I,l);return h}function Br(l,p){for(var h=-1,S=l==null?0:l.length;++h<S;)if(p(l[h],h,l))return!0;return!1}var za=$r("length");function Ha(l){return l.split("")}function ka(l){return l.match(na)||[]}function Cu(l,p,h){var S;return h(l,function(I,$,un){if(p(I,$,un))return S=$,!1}),S}function Oe(l,p,h,S){for(var I=l.length,$=h+(S?1:-1);S?$--:++$<I;)if(p(l[$],$,l))return $;return-1}function Nt(l,p,h){return p===p?uf(l,p,h):Oe(l,Au,h)}function Ja(l,p,h,S){for(var I=h-1,$=l.length;++I<$;)if(S(l[I],p))return I;return-1}function Au(l){return l!==l}function bu(l,p){var h=l==null?0:l.length;return h?Kr(l,p)/h:Ce}function $r(l){return function(p){return p==null?i:p[l]}}function qr(l){return function(p){return l==null?i:l[p]}}function Ru(l,p,h,S,I){return I(l,function($,un,H){h=S?(S=!1,$):p(h,$,un,H)}),h}function Za(l,p){var h=l.length;for(l.sort(p);h--;)l[h]=l[h].value;return l}function Kr(l,p){for(var h,S=-1,I=l.length;++S<I;){var $=p(l[S]);$!==i&&(h=h===i?$:h+$)}return h}function Gr(l,p){for(var h=-1,S=Array(l);++h<l;)S[h]=p(h);return S}function Ya(l,p){return Z(p,function(h){return[h,l[h]]})}function Pu(l){return l&&l.slice(0,Lu(l)+1).replace(Er,"")}function Tn(l){return function(p){return l(p)}}function zr(l,p){return Z(p,function(h){return l[h]})}function ie(l,p){return l.has(p)}function Tu(l,p){for(var h=-1,S=l.length;++h<S&&Nt(p,l[h],0)>-1;);return h}function Eu(l,p){for(var h=l.length;h--&&Nt(p,l[h],0)>-1;);return h}function Xa(l,p){for(var h=l.length,S=0;h--;)l[h]===p&&++S;return S}var Qa=qr(Ma),Va=qr(Fa);function ja(l){return"\\"+Da[l]}function nf(l,p){return l==null?i:l[p]}function Bt(l){return Ia.test(l)}function tf(l){return La.test(l)}function ef(l){for(var p,h=[];!(p=l.next()).done;)h.push(p.value);return h}function Hr(l){var p=-1,h=Array(l.size);return l.forEach(function(S,I){h[++p]=[I,S]}),h}function Iu(l,p){return function(h){return l(p(h))}}function dt(l,p){for(var h=-1,S=l.length,I=0,$=[];++h<S;){var un=l[h];(un===p||un===An)&&(l[h]=An,$[I++]=h)}return $}function We(l){var p=-1,h=Array(l.size);return l.forEach(function(S){h[++p]=S}),h}function rf(l){var p=-1,h=Array(l.size);return l.forEach(function(S){h[++p]=[S,S]}),h}function uf(l,p,h){for(var S=h-1,I=l.length;++S<I;)if(l[S]===p)return S;return-1}function sf(l,p,h){for(var S=h+1;S--;)if(l[S]===p)return S;return S}function $t(l){return Bt(l)?af(l):za(l)}function Jn(l){return Bt(l)?ff(l):Ha(l)}function Lu(l){for(var p=l.length;p--&&Xo.test(l.charAt(p)););return p}var of=qr(Ua);function af(l){for(var p=Mr.lastIndex=0;Mr.test(l);)++p;return p}function ff(l){return l.match(Mr)||[]}function lf(l){return l.match(Ea)||[]}var cf=function l(p){p=p==null?an:qt.defaults(an.Object(),p,qt.pick(an,Oa));var h=p.Array,S=p.Date,I=p.Error,$=p.Function,un=p.Math,H=p.Object,kr=p.RegExp,hf=p.String,Dn=p.TypeError,Me=h.prototype,gf=$.prototype,Kt=H.prototype,Fe=p["__core-js_shared__"],Ue=gf.toString,G=Kt.hasOwnProperty,pf=0,Ou=function(){var n=/[^.]+$/.exec(Fe&&Fe.keys&&Fe.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),De=Kt.toString,df=Ue.call(H),_f=an._,vf=kr("^"+Ue.call(G).replace(Tr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ne=du?p.Buffer:i,_t=p.Symbol,Be=p.Uint8Array,Wu=Ne?Ne.allocUnsafe:i,$e=Iu(H.getPrototypeOf,H),Mu=H.create,Fu=Kt.propertyIsEnumerable,qe=Me.splice,Uu=_t?_t.isConcatSpreadable:i,ue=_t?_t.iterator:i,Rt=_t?_t.toStringTag:i,Ke=function(){try{var n=Lt(H,"defineProperty");return n({},"",{}),n}catch{}}(),wf=p.clearTimeout!==an.clearTimeout&&p.clearTimeout,mf=S&&S.now!==an.Date.now&&S.now,yf=p.setTimeout!==an.setTimeout&&p.setTimeout,Ge=un.ceil,ze=un.floor,Jr=H.getOwnPropertySymbols,xf=Ne?Ne.isBuffer:i,Du=p.isFinite,Sf=Me.join,Cf=Iu(H.keys,H),sn=un.max,ln=un.min,Af=S.now,bf=p.parseInt,Nu=un.random,Rf=Me.reverse,Zr=Lt(p,"DataView"),se=Lt(p,"Map"),Yr=Lt(p,"Promise"),Gt=Lt(p,"Set"),oe=Lt(p,"WeakMap"),ae=Lt(H,"create"),He=oe&&new oe,zt={},Pf=Ot(Zr),Tf=Ot(se),Ef=Ot(Yr),If=Ot(Gt),Lf=Ot(oe),ke=_t?_t.prototype:i,fe=ke?ke.valueOf:i,Bu=ke?ke.toString:i;function s(n){if(Q(n)&&!L(n)&&!(n instanceof N)){if(n instanceof Nn)return n;if(G.call(n,"__wrapped__"))return $s(n)}return new Nn(n)}var Ht=function(){function n(){}return function(t){if(!Y(t))return{};if(Mu)return Mu(t);n.prototype=t;var e=new n;return n.prototype=i,e}}();function Je(){}function Nn(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}s.templateSettings={escape:zo,evaluate:Ho,interpolate:Zi,variable:"",imports:{_:s}},s.prototype=Je.prototype,s.prototype.constructor=s,Nn.prototype=Ht(Je.prototype),Nn.prototype.constructor=Nn;function N(n){this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Qn,this.__views__=[]}function Of(){var n=new N(this.__wrapped__);return n.__actions__=yn(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=yn(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=yn(this.__views__),n}function Wf(){if(this.__filtered__){var n=new N(this);n.__dir__=-1,n.__filtered__=!0}else n=this.clone(),n.__dir__*=-1;return n}function Mf(){var n=this.__wrapped__.value(),t=this.__dir__,e=L(n),r=t<0,u=e?n.length:0,o=kl(0,u,this.__views__),a=o.start,f=o.end,c=f-a,d=r?f:a-1,_=this.__iteratees__,v=_.length,x=0,C=ln(c,this.__takeCount__);if(!e||!r&&u==c&&C==c)return fs(n,this.__actions__);var P=[];n:for(;c--&&x<C;){d+=t;for(var M=-1,T=n[d];++M<v;){var D=_[M],B=D.iteratee,Ln=D.type,_n=B(T);if(Ln==Po)T=_n;else if(!_n){if(Ln==gn)continue n;break n}}P[x++]=T}return P}N.prototype=Ht(Je.prototype),N.prototype.constructor=N;function Pt(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 Ff(){this.__data__=ae?ae(null):{},this.size=0}function Uf(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}function Df(n){var t=this.__data__;if(ae){var e=t[n];return e===q?i:e}return G.call(t,n)?t[n]:i}function Nf(n){var t=this.__data__;return ae?t[n]!==i:G.call(t,n)}function Bf(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=ae&&t===i?q:t,this}Pt.prototype.clear=Ff,Pt.prototype.delete=Uf,Pt.prototype.get=Df,Pt.prototype.has=Nf,Pt.prototype.set=Bf;function et(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}function $f(){this.__data__=[],this.size=0}function qf(n){var t=this.__data__,e=Ze(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():qe.call(t,e,1),--this.size,!0}function Kf(n){var t=this.__data__,e=Ze(t,n);return e<0?i:t[e][1]}function Gf(n){return Ze(this.__data__,n)>-1}function zf(n,t){var e=this.__data__,r=Ze(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}et.prototype.clear=$f,et.prototype.delete=qf,et.prototype.get=Kf,et.prototype.has=Gf,et.prototype.set=zf;function rt(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 Hf(){this.size=0,this.__data__={hash:new Pt,map:new(se||et),string:new Pt}}function kf(n){var t=sr(this,n).delete(n);return this.size-=t?1:0,t}function Jf(n){return sr(this,n).get(n)}function Zf(n){return sr(this,n).has(n)}function Yf(n,t){var e=sr(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}rt.prototype.clear=Hf,rt.prototype.delete=kf,rt.prototype.get=Jf,rt.prototype.has=Zf,rt.prototype.set=Yf;function Tt(n){var t=-1,e=n==null?0:n.length;for(this.__data__=new rt;++t<e;)this.add(n[t])}function Xf(n){return this.__data__.set(n,q),this}function Qf(n){return this.__data__.has(n)}Tt.prototype.add=Tt.prototype.push=Xf,Tt.prototype.has=Qf;function Zn(n){var t=this.__data__=new et(n);this.size=t.size}function Vf(){this.__data__=new et,this.size=0}function jf(n){var t=this.__data__,e=t.delete(n);return this.size=t.size,e}function nl(n){return this.__data__.get(n)}function tl(n){return this.__data__.has(n)}function el(n,t){var e=this.__data__;if(e instanceof et){var r=e.__data__;if(!se||r.length<y-1)return r.push([n,t]),this.size=++e.size,this;e=this.__data__=new rt(r)}return e.set(n,t),this.size=e.size,this}Zn.prototype.clear=Vf,Zn.prototype.delete=jf,Zn.prototype.get=nl,Zn.prototype.has=tl,Zn.prototype.set=el;function $u(n,t){var e=L(n),r=!e&&Wt(n),u=!e&&!r&&xt(n),o=!e&&!r&&!u&&Yt(n),a=e||r||u||o,f=a?Gr(n.length,hf):[],c=f.length;for(var d in n)(t||G.call(n,d))&&!(a&&(d=="length"||u&&(d=="offset"||d=="parent")||o&&(d=="buffer"||d=="byteLength"||d=="byteOffset")||ot(d,c)))&&f.push(d);return f}function qu(n){var t=n.length;return t?n[si(0,t-1)]:i}function rl(n,t){return or(yn(n),Et(t,0,n.length))}function il(n){return or(yn(n))}function Xr(n,t,e){(e!==i&&!Yn(n[t],e)||e===i&&!(t in n))&&it(n,t,e)}function le(n,t,e){var r=n[t];(!(G.call(n,t)&&Yn(r,e))||e===i&&!(t in n))&&it(n,t,e)}function Ze(n,t){for(var e=n.length;e--;)if(Yn(n[e][0],t))return e;return-1}function ul(n,t,e,r){return vt(n,function(u,o,a){t(r,u,e(u),a)}),r}function Ku(n,t){return n&&jn(t,on(t),n)}function sl(n,t){return n&&jn(t,Sn(t),n)}function it(n,t,e){t=="__proto__"&&Ke?Ke(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}function Qr(n,t){for(var e=-1,r=t.length,u=h(r),o=n==null;++e<r;)u[e]=o?i:Li(n,t[e]);return u}function Et(n,t,e){return n===n&&(e!==i&&(n=n<=e?n:e),t!==i&&(n=n>=t?n:t)),n}function Bn(n,t,e,r,u,o){var a,f=t&en,c=t&bn,d=t&hn;if(e&&(a=u?e(n,r,u,o):e(n)),a!==i)return a;if(!Y(n))return n;var _=L(n);if(_){if(a=Zl(n),!f)return yn(n,a)}else{var v=cn(n),x=v==Re||v==zi;if(xt(n))return hs(n,f);if(v==tt||v==Ft||x&&!u){if(a=c||x?{}:Ls(n),!f)return c?Dl(n,sl(a,n)):Ul(n,Ku(a,n))}else{if(!k[v])return u?n:{};a=Yl(n,v,f)}}o||(o=new Zn);var C=o.get(n);if(C)return C;o.set(n,a),so(n)?n.forEach(function(T){a.add(Bn(T,t,e,T,n,o))}):io(n)&&n.forEach(function(T,D){a.set(D,Bn(T,t,e,D,n,o))});var P=d?c?vi:_i:c?Sn:on,M=_?i:P(n);return Un(M||n,function(T,D){M&&(D=T,T=n[D]),le(a,D,Bn(T,t,e,D,n,o))}),a}function ol(n){var t=on(n);return function(e){return Gu(e,n,t)}}function Gu(n,t,e){var r=e.length;if(n==null)return!r;for(n=H(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 zu(n,t,e){if(typeof n!="function")throw new Dn(A);return ve(function(){n.apply(i,e)},t)}function ce(n,t,e,r){var u=-1,o=Le,a=!0,f=n.length,c=[],d=t.length;if(!f)return c;e&&(t=Z(t,Tn(e))),r?(o=Dr,a=!1):t.length>=y&&(o=ie,a=!1,t=new Tt(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 vt=vs(Vn),Hu=vs(jr,!0);function al(n,t){var e=!0;return vt(n,function(r,u,o){return e=!!t(r,u,o),e}),e}function Ye(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&&!In(a):e(a,f)))var f=a,c=o}return c}function fl(n,t,e,r){var u=n.length;for(e=W(e),e<0&&(e=-e>u?0:u+e),r=r===i||r>u?u:W(r),r<0&&(r+=u),r=e>r?0:ao(r);e<r;)n[e++]=t;return n}function ku(n,t){var e=[];return vt(n,function(r,u,o){t(r,u,o)&&e.push(r)}),e}function fn(n,t,e,r,u){var o=-1,a=n.length;for(e||(e=Ql),u||(u=[]);++o<a;){var f=n[o];t>0&&e(f)?t>1?fn(f,t-1,e,r,u):pt(u,f):r||(u[u.length]=f)}return u}var Vr=ws(),Ju=ws(!0);function Vn(n,t){return n&&Vr(n,t,on)}function jr(n,t){return n&&Ju(n,t,on)}function Xe(n,t){return gt(t,function(e){return at(n[e])})}function It(n,t){t=mt(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[nt(t[e++])];return e&&e==r?n:i}function Zu(n,t,e){var r=t(n);return L(n)?r:pt(r,e(n))}function pn(n){return n==null?n===i?Do:Fo:Rt&&Rt in H(n)?Hl(n):ic(n)}function ni(n,t){return n>t}function ll(n,t){return n!=null&&G.call(n,t)}function cl(n,t){return n!=null&&t in H(n)}function hl(n,t,e){return n>=ln(t,e)&&n<sn(t,e)}function ti(n,t,e){for(var r=e?Dr:Le,u=n[0].length,o=n.length,a=o,f=h(o),c=1/0,d=[];a--;){var _=n[a];a&&t&&(_=Z(_,Tn(t))),c=ln(_.length,c),f[a]=!e&&(t||u>=120&&_.length>=120)?new Tt(a&&_):i}_=n[0];var v=-1,x=f[0];n:for(;++v<u&&d.length<c;){var C=_[v],P=t?t(C):C;if(C=e||C!==0?C:0,!(x?ie(x,P):r(d,P,e))){for(a=o;--a;){var M=f[a];if(!(M?ie(M,P):r(n[a],P,e)))continue n}x&&x.push(P),d.push(C)}}return d}function gl(n,t,e,r){return Vn(n,function(u,o,a){t(r,e(u),o,a)}),r}function he(n,t,e){t=mt(t,n),n=Fs(n,t);var r=n==null?n:n[nt(qn(t))];return r==null?i:Pn(r,n,e)}function Yu(n){return Q(n)&&pn(n)==Ft}function pl(n){return Q(n)&&pn(n)==re}function dl(n){return Q(n)&&pn(n)==Vt}function ge(n,t,e,r,u){return n===t?!0:n==null||t==null||!Q(n)&&!Q(t)?n!==n&&t!==t:_l(n,t,e,r,ge,u)}function _l(n,t,e,r,u,o){var a=L(n),f=L(t),c=a?Ae:cn(n),d=f?Ae:cn(t);c=c==Ft?tt:c,d=d==Ft?tt:d;var _=c==tt,v=d==tt,x=c==d;if(x&&xt(n)){if(!xt(t))return!1;a=!0,_=!1}if(x&&!_)return o||(o=new Zn),a||Yt(n)?Ts(n,t,e,r,u,o):Gl(n,t,c,e,r,u,o);if(!(e&Rn)){var C=_&&G.call(n,"__wrapped__"),P=v&&G.call(t,"__wrapped__");if(C||P){var M=C?n.value():n,T=P?t.value():t;return o||(o=new Zn),u(M,T,e,r,o)}}return x?(o||(o=new Zn),zl(n,t,e,r,u,o)):!1}function vl(n){return Q(n)&&cn(n)==Hn}function ei(n,t,e,r){var u=e.length,o=u,a=!r;if(n==null)return!o;for(n=H(n);u--;){var f=e[u];if(a&&f[2]?f[1]!==n[f[0]]:!(f[0]in n))return!1}for(;++u<o;){f=e[u];var c=f[0],d=n[c],_=f[1];if(a&&f[2]){if(d===i&&!(c in n))return!1}else{var v=new Zn;if(r)var x=r(d,_,c,n,t,v);if(!(x===i?ge(_,d,Rn|ct,r,v):x))return!1}}return!0}function Xu(n){if(!Y(n)||jl(n))return!1;var t=at(n)?vf:sa;return t.test(Ot(n))}function wl(n){return Q(n)&&pn(n)==ne}function ml(n){return Q(n)&&cn(n)==kn}function yl(n){return Q(n)&&gr(n.length)&&!!J[pn(n)]}function Qu(n){return typeof n=="function"?n:n==null?Cn:typeof n=="object"?L(n)?ns(n[0],n[1]):ju(n):yo(n)}function ri(n){if(!_e(n))return Cf(n);var t=[];for(var e in H(n))G.call(n,e)&&e!="constructor"&&t.push(e);return t}function xl(n){if(!Y(n))return rc(n);var t=_e(n),e=[];for(var r in n)r=="constructor"&&(t||!G.call(n,r))||e.push(r);return e}function ii(n,t){return n<t}function Vu(n,t){var e=-1,r=xn(n)?h(n.length):[];return vt(n,function(u,o,a){r[++e]=t(u,o,a)}),r}function ju(n){var t=mi(n);return t.length==1&&t[0][2]?Ws(t[0][0],t[0][1]):function(e){return e===n||ei(e,n,t)}}function ns(n,t){return xi(n)&&Os(t)?Ws(nt(n),t):function(e){var r=Li(e,n);return r===i&&r===t?Oi(e,n):ge(t,r,Rn|ct)}}function Qe(n,t,e,r,u){n!==t&&Vr(t,function(o,a){if(u||(u=new Zn),Y(o))Sl(n,t,a,e,Qe,r,u);else{var f=r?r(Ci(n,a),o,a+"",n,t,u):i;f===i&&(f=o),Xr(n,a,f)}},Sn)}function Sl(n,t,e,r,u,o,a){var f=Ci(n,e),c=Ci(t,e),d=a.get(c);if(d){Xr(n,e,d);return}var _=o?o(f,c,e+"",n,t,a):i,v=_===i;if(v){var x=L(c),C=!x&&xt(c),P=!x&&!C&&Yt(c);_=c,x||C||P?L(f)?_=f:V(f)?_=yn(f):C?(v=!1,_=hs(c,!0)):P?(v=!1,_=gs(c,!0)):_=[]:we(c)||Wt(c)?(_=f,Wt(f)?_=fo(f):(!Y(f)||at(f))&&(_=Ls(c))):v=!1}v&&(a.set(c,_),u(_,c,r,o,a),a.delete(c)),Xr(n,e,_)}function ts(n,t){var e=n.length;if(e)return t+=t<0?e:0,ot(t,e)?n[t]:i}function es(n,t,e){t.length?t=Z(t,function(o){return L(o)?function(a){return It(a,o.length===1?o[0]:o)}:o}):t=[Cn];var r=-1;t=Z(t,Tn(b()));var u=Vu(n,function(o,a,f){var c=Z(t,function(d){return d(o)});return{criteria:c,index:++r,value:o}});return Za(u,function(o,a){return Fl(o,a,e)})}function Cl(n,t){return rs(n,t,function(e,r){return Oi(n,r)})}function rs(n,t,e){for(var r=-1,u=t.length,o={};++r<u;){var a=t[r],f=It(n,a);e(f,a)&&pe(o,mt(a,n),f)}return o}function Al(n){return function(t){return It(t,n)}}function ui(n,t,e,r){var u=r?Ja:Nt,o=-1,a=t.length,f=n;for(n===t&&(t=yn(t)),e&&(f=Z(n,Tn(e)));++o<a;)for(var c=0,d=t[o],_=e?e(d):d;(c=u(f,_,c,r))>-1;)f!==n&&qe.call(f,c,1),qe.call(n,c,1);return n}function is(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;ot(u)?qe.call(n,u,1):fi(n,u)}}return n}function si(n,t){return n+ze(Nu()*(t-n+1))}function bl(n,t,e,r){for(var u=-1,o=sn(Ge((t-n)/(e||1)),0),a=h(o);o--;)a[r?o:++u]=n,n+=e;return a}function oi(n,t){var e="";if(!n||t<1||t>ht)return e;do t%2&&(e+=n),t=ze(t/2),t&&(n+=n);while(t);return e}function U(n,t){return Ai(Ms(n,t,Cn),n+"")}function Rl(n){return qu(Xt(n))}function Pl(n,t){var e=Xt(n);return or(e,Et(t,0,e.length))}function pe(n,t,e,r){if(!Y(n))return n;t=mt(t,n);for(var u=-1,o=t.length,a=o-1,f=n;f!=null&&++u<o;){var c=nt(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=Y(_)?_:ot(t[u+1])?[]:{})}le(f,c,d),f=f[c]}return n}var us=He?function(n,t){return He.set(n,t),n}:Cn,Tl=Ke?function(n,t){return Ke(n,"toString",{configurable:!0,enumerable:!1,value:Mi(t),writable:!0})}:Cn;function El(n){return or(Xt(n))}function $n(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 Il(n,t){var e;return vt(n,function(r,u,o){return e=t(r,u,o),!e}),!!e}function Ve(n,t,e){var r=0,u=n==null?r:n.length;if(typeof t=="number"&&t===t&&u<=Lo){for(;r<u;){var o=r+u>>>1,a=n[o];a!==null&&!In(a)&&(e?a<=t:a<t)?r=o+1:u=o}return u}return ai(n,t,Cn,e)}function ai(n,t,e,r){var u=0,o=n==null?0:n.length;if(o===0)return 0;t=e(t);for(var a=t!==t,f=t===null,c=In(t),d=t===i;u<o;){var _=ze((u+o)/2),v=e(n[_]),x=v!==i,C=v===null,P=v===v,M=In(v);if(a)var T=r||P;else d?T=P&&(r||x):f?T=P&&x&&(r||!C):c?T=P&&x&&!C&&(r||!M):C||M?T=!1:T=r?v<=t:v<t;T?u=_+1:o=_}return ln(o,Io)}function ss(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||!Yn(f,c)){var c=f;o[u++]=a===0?0:a}}return o}function os(n){return typeof n=="number"?n:In(n)?Ce:+n}function En(n){if(typeof n=="string")return n;if(L(n))return Z(n,En)+"";if(In(n))return Bu?Bu.call(n):"";var t=n+"";return t=="0"&&1/n==-At?"-0":t}function wt(n,t,e){var r=-1,u=Le,o=n.length,a=!0,f=[],c=f;if(e)a=!1,u=Dr;else if(o>=y){var d=t?null:ql(n);if(d)return We(d);a=!1,u=ie,c=new Tt}else c=t?[]:f;n:for(;++r<o;){var _=n[r],v=t?t(_):_;if(_=e||_!==0?_:0,a&&v===v){for(var x=c.length;x--;)if(c[x]===v)continue n;t&&c.push(v),f.push(_)}else u(c,v,e)||(c!==f&&c.push(v),f.push(_))}return f}function fi(n,t){return t=mt(t,n),n=Fs(n,t),n==null||delete n[nt(qn(t))]}function as(n,t,e,r){return pe(n,t,e(It(n,t)),r)}function je(n,t,e,r){for(var u=n.length,o=r?u:-1;(r?o--:++o<u)&&t(n[o],o,n););return e?$n(n,r?0:o,r?o+1:u):$n(n,r?o+1:0,r?u:o)}function fs(n,t){var e=n;return e instanceof N&&(e=e.value()),Nr(t,function(r,u){return u.func.apply(u.thisArg,pt([r],u.args))},e)}function li(n,t,e){var r=n.length;if(r<2)return r?wt(n[0]):[];for(var u=-1,o=h(r);++u<r;)for(var a=n[u],f=-1;++f<r;)f!=u&&(o[u]=ce(o[u]||a,n[f],t,e));return wt(fn(o,1),t,e)}function ls(n,t,e){for(var r=-1,u=n.length,o=t.length,a={};++r<u;){var f=r<o?t[r]:i;e(a,n[r],f)}return a}function ci(n){return V(n)?n:[]}function hi(n){return typeof n=="function"?n:Cn}function mt(n,t){return L(n)?n:xi(n,t)?[n]:Bs(K(n))}var Ll=U;function yt(n,t,e){var r=n.length;return e=e===i?r:e,!t&&e>=r?n:$n(n,t,e)}var cs=wf||function(n){return an.clearTimeout(n)};function hs(n,t){if(t)return n.slice();var e=n.length,r=Wu?Wu(e):new n.constructor(e);return n.copy(r),r}function gi(n){var t=new n.constructor(n.byteLength);return new Be(t).set(new Be(n)),t}function Ol(n,t){var e=t?gi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}function Wl(n){var t=new n.constructor(n.source,Yi.exec(n));return t.lastIndex=n.lastIndex,t}function Ml(n){return fe?H(fe.call(n)):{}}function gs(n,t){var e=t?gi(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.length)}function ps(n,t){if(n!==t){var e=n!==i,r=n===null,u=n===n,o=In(n),a=t!==i,f=t===null,c=t===t,d=In(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 Fl(n,t,e){for(var r=-1,u=n.criteria,o=t.criteria,a=u.length,f=e.length;++r<a;){var c=ps(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 ds(n,t,e,r){for(var u=-1,o=n.length,a=e.length,f=-1,c=t.length,d=sn(o-a,0),_=h(c+d),v=!r;++f<c;)_[f]=t[f];for(;++u<a;)(v||u<o)&&(_[e[u]]=n[u]);for(;d--;)_[f++]=n[u++];return _}function _s(n,t,e,r){for(var u=-1,o=n.length,a=-1,f=e.length,c=-1,d=t.length,_=sn(o-f,0),v=h(_+d),x=!r;++u<_;)v[u]=n[u];for(var C=u;++c<d;)v[C+c]=t[c];for(;++a<f;)(x||u<o)&&(v[C+e[a]]=n[u++]);return v}function yn(n,t){var e=-1,r=n.length;for(t||(t=h(r));++e<r;)t[e]=n[e];return t}function jn(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?it(e,f,c):le(e,f,c)}return e}function Ul(n,t){return jn(n,yi(n),t)}function Dl(n,t){return jn(n,Es(n),t)}function nr(n,t){return function(e,r){var u=L(e)?qa:ul,o=t?t():{};return u(e,n,b(r,2),o)}}function kt(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&&dn(e[0],e[1],a)&&(o=u<3?i:o,u=1),t=H(t);++r<u;){var f=e[r];f&&n(t,f,r,o)}return t})}function vs(n,t){return function(e,r){if(e==null)return e;if(!xn(e))return n(e,r);for(var u=e.length,o=t?u:-1,a=H(e);(t?o--:++o<u)&&r(a[o],o,a)!==!1;);return e}}function ws(n){return function(t,e,r){for(var u=-1,o=H(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 Nl(n,t,e){var r=t&wn,u=de(n);function o(){var a=this&&this!==an&&this instanceof o?u:n;return a.apply(r?e:this,arguments)}return o}function ms(n){return function(t){t=K(t);var e=Bt(t)?Jn(t):i,r=e?e[0]:t.charAt(0),u=e?yt(e,1).join(""):t.slice(1);return r[n]()+u}}function Jt(n){return function(t){return Nr(wo(vo(t).replace(Pa,"")),n,"")}}function de(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=Ht(n.prototype),r=n.apply(e,t);return Y(r)?r:e}}function Bl(n,t,e){var r=de(n);function u(){for(var o=arguments.length,a=h(o),f=o,c=Zt(u);f--;)a[f]=arguments[f];var d=o<3&&a[0]!==c&&a[o-1]!==c?[]:dt(a,c);if(o-=d.length,o<e)return As(n,t,tr,u.placeholder,i,a,d,i,i,e-o);var _=this&&this!==an&&this instanceof u?r:n;return Pn(_,this,a)}return u}function ys(n){return function(t,e,r){var u=H(t);if(!xn(t)){var o=b(e,3);t=on(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 xs(n){return st(function(t){var e=t.length,r=e,u=Nn.prototype.thru;for(n&&t.reverse();r--;){var o=t[r];if(typeof o!="function")throw new Dn(A);if(u&&!a&&ur(o)=="wrapper")var a=new Nn([],!0)}for(r=a?r:e;++r<e;){o=t[r];var f=ur(o),c=f=="wrapper"?wi(o):i;c&&Si(c[0])&&c[1]==(F|Gn|zn|nn)&&!c[4].length&&c[9]==1?a=a[ur(c[0])].apply(a,c[3]):a=o.length==1&&Si(o)?a[f]():a.thru(o)}return function(){var d=arguments,_=d[0];if(a&&d.length==1&&L(_))return a.plant(_).value();for(var v=0,x=e?t[v].apply(this,d):_;++v<e;)x=t[v].call(this,x);return x}})}function tr(n,t,e,r,u,o,a,f,c,d){var _=t&F,v=t&wn,x=t&mn,C=t&(Gn|St),P=t&z,M=x?i:de(n);function T(){for(var D=arguments.length,B=h(D),Ln=D;Ln--;)B[Ln]=arguments[Ln];if(C)var _n=Zt(T),On=Xa(B,_n);if(r&&(B=ds(B,r,u,C)),o&&(B=_s(B,o,a,C)),D-=On,C&&D<d){var j=dt(B,_n);return As(n,t,tr,T.placeholder,e,B,j,f,c,d-D)}var Xn=v?e:this,lt=x?Xn[n]:n;return D=B.length,f?B=uc(B,f):P&&D>1&&B.reverse(),_&&c<D&&(B.length=c),this&&this!==an&&this instanceof T&&(lt=M||de(lt)),lt.apply(Xn,B)}return T}function Ss(n,t){return function(e,r){return gl(e,n,t(r),{})}}function er(n,t){return function(e,r){var u;if(e===i&&r===i)return t;if(e!==i&&(u=e),r!==i){if(u===i)return r;typeof e=="string"||typeof r=="string"?(e=En(e),r=En(r)):(e=os(e),r=os(r)),u=n(e,r)}return u}}function pi(n){return st(function(t){return t=Z(t,Tn(b())),U(function(e){var r=this;return n(t,function(u){return Pn(u,r,e)})})})}function rr(n,t){t=t===i?" ":En(t);var e=t.length;if(e<2)return e?oi(t,n):t;var r=oi(t,Ge(n/$t(t)));return Bt(t)?yt(Jn(r),0,n).join(""):r.slice(0,n)}function $l(n,t,e,r){var u=t&wn,o=de(n);function a(){for(var f=-1,c=arguments.length,d=-1,_=r.length,v=h(_+c),x=this&&this!==an&&this instanceof a?o:n;++d<_;)v[d]=r[d];for(;c--;)v[d++]=arguments[++f];return Pn(x,u?e:this,v)}return a}function Cs(n){return function(t,e,r){return r&&typeof r!="number"&&dn(t,e,r)&&(e=r=i),t=ft(t),e===i?(e=t,t=0):e=ft(e),r=r===i?t<e?1:-1:ft(r),bl(t,e,r,n)}}function ir(n){return function(t,e){return typeof t=="string"&&typeof e=="string"||(t=Kn(t),e=Kn(e)),n(t,e)}}function As(n,t,e,r,u,o,a,f,c,d){var _=t&Gn,v=_?a:i,x=_?i:a,C=_?o:i,P=_?i:o;t|=_?zn:Ct,t&=~(_?Ct:zn),t&Se||(t&=-4);var M=[n,t,u,C,v,P,x,f,c,d],T=e.apply(i,M);return Si(n)&&Us(T,M),T.placeholder=r,Ds(T,n,t)}function di(n){var t=un[n];return function(e,r){if(e=Kn(e),r=r==null?0:ln(W(r),292),r&&Du(e)){var u=(K(e)+"e").split("e"),o=t(u[0]+"e"+(+u[1]+r));return u=(K(o)+"e").split("e"),+(u[0]+"e"+(+u[1]-r))}return t(e)}}var ql=Gt&&1/We(new Gt([,-0]))[1]==At?function(n){return new Gt(n)}:Di;function bs(n){return function(t){var e=cn(t);return e==Hn?Hr(t):e==kn?rf(t):Ya(t,n(t))}}function ut(n,t,e,r,u,o,a,f){var c=t&mn;if(!c&&typeof n!="function")throw new Dn(A);var d=r?r.length:0;if(d||(t&=-97,r=u=i),a=a===i?a:sn(W(a),0),f=f===i?f:W(f),d-=u?u.length:0,t&Ct){var _=r,v=u;r=u=i}var x=c?i:wi(n),C=[n,t,e,r,u,_,v,o,a,f];if(x&&ec(C,x),n=C[0],t=C[1],e=C[2],r=C[3],u=C[4],f=C[9]=C[9]===i?c?0:n.length:sn(C[9]-d,0),!f&&t&(Gn|St)&&(t&=-25),!t||t==wn)var P=Nl(n,t,e);else t==Gn||t==St?P=Bl(n,t,f):(t==zn||t==(wn|zn))&&!u.length?P=$l(n,t,e,r):P=tr.apply(i,C);var M=x?us:Us;return Ds(M(P,C),n,t)}function Rs(n,t,e,r){return n===i||Yn(n,Kt[e])&&!G.call(r,e)?t:n}function Ps(n,t,e,r,u,o){return Y(n)&&Y(t)&&(o.set(t,n),Qe(n,t,i,Ps,o),o.delete(t)),n}function Kl(n){return we(n)?i:n}function Ts(n,t,e,r,u,o){var a=e&Rn,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,C=e&ct?new Tt:i;for(o.set(n,t),o.set(t,n);++v<f;){var P=n[v],M=t[v];if(r)var T=a?r(M,P,v,t,n,o):r(P,M,v,n,t,o);if(T!==i){if(T)continue;x=!1;break}if(C){if(!Br(t,function(D,B){if(!ie(C,B)&&(P===D||u(P,D,e,r,o)))return C.push(B)})){x=!1;break}}else if(!(P===M||u(P,M,e,r,o))){x=!1;break}}return o.delete(n),o.delete(t),x}function Gl(n,t,e,r,u,o,a){switch(e){case Ut:if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)return!1;n=n.buffer,t=t.buffer;case re:return!(n.byteLength!=t.byteLength||!o(new Be(n),new Be(t)));case Qt:case Vt:case jt:return Yn(+n,+t);case be:return n.name==t.name&&n.message==t.message;case ne:case te:return n==t+"";case Hn:var f=Hr;case kn:var c=r&Rn;if(f||(f=We),n.size!=t.size&&!c)return!1;var d=a.get(n);if(d)return d==t;r|=ct,a.set(n,t);var _=Ts(f(n),f(t),r,u,o,a);return a.delete(n),_;case Pe:if(fe)return fe.call(n)==fe.call(t)}return!1}function zl(n,t,e,r,u,o){var a=e&Rn,f=_i(n),c=f.length,d=_i(t),_=d.length;if(c!=_&&!a)return!1;for(var v=c;v--;){var x=f[v];if(!(a?x in t:G.call(t,x)))return!1}var C=o.get(n),P=o.get(t);if(C&&P)return C==t&&P==n;var M=!0;o.set(n,t),o.set(t,n);for(var T=a;++v<c;){x=f[v];var D=n[x],B=t[x];if(r)var Ln=a?r(B,D,x,t,n,o):r(D,B,x,n,t,o);if(!(Ln===i?D===B||u(D,B,e,r,o):Ln)){M=!1;break}T||(T=x=="constructor")}if(M&&!T){var _n=n.constructor,On=t.constructor;_n!=On&&"constructor"in n&&"constructor"in t&&!(typeof _n=="function"&&_n instanceof _n&&typeof On=="function"&&On instanceof On)&&(M=!1)}return o.delete(n),o.delete(t),M}function st(n){return Ai(Ms(n,i,Gs),n+"")}function _i(n){return Zu(n,on,yi)}function vi(n){return Zu(n,Sn,Es)}var wi=He?function(n){return He.get(n)}:Di;function ur(n){for(var t=n.name+"",e=zt[t],r=G.call(zt,t)?e.length:0;r--;){var u=e[r],o=u.func;if(o==null||o==n)return u.name}return t}function Zt(n){var t=G.call(s,"placeholder")?s:n;return t.placeholder}function b(){var n=s.iteratee||Fi;return n=n===Fi?Qu:n,arguments.length?n(arguments[0],arguments[1]):n}function sr(n,t){var e=n.__data__;return Vl(t)?e[typeof t=="string"?"string":"hash"]:e.map}function mi(n){for(var t=on(n),e=t.length;e--;){var r=t[e],u=n[r];t[e]=[r,u,Os(u)]}return t}function Lt(n,t){var e=nf(n,t);return Xu(e)?e:i}function Hl(n){var t=G.call(n,Rt),e=n[Rt];try{n[Rt]=i;var r=!0}catch{}var u=De.call(n);return r&&(t?n[Rt]=e:delete n[Rt]),u}var yi=Jr?function(n){return n==null?[]:(n=H(n),gt(Jr(n),function(t){return Fu.call(n,t)}))}:Ni,Es=Jr?function(n){for(var t=[];n;)pt(t,yi(n)),n=$e(n);return t}:Ni,cn=pn;(Zr&&cn(new Zr(new ArrayBuffer(1)))!=Ut||se&&cn(new se)!=Hn||Yr&&cn(Yr.resolve())!=Hi||Gt&&cn(new Gt)!=kn||oe&&cn(new oe)!=ee)&&(cn=function(n){var t=pn(n),e=t==tt?n.constructor:i,r=e?Ot(e):"";if(r)switch(r){case Pf:return Ut;case Tf:return Hn;case Ef:return Hi;case If:return kn;case Lf:return ee}return t});function kl(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=ln(t,n+a);break;case"takeRight":n=sn(n,t-a);break}}return{start:n,end:t}}function Jl(n){var t=n.match(Vo);return t?t[1].split(jo):[]}function Is(n,t,e){t=mt(t,n);for(var r=-1,u=t.length,o=!1;++r<u;){var a=nt(t[r]);if(!(o=n!=null&&e(n,a)))break;n=n[a]}return o||++r!=u?o:(u=n==null?0:n.length,!!u&&gr(u)&&ot(a,u)&&(L(n)||Wt(n)))}function Zl(n){var t=n.length,e=new n.constructor(t);return t&&typeof n[0]=="string"&&G.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Ls(n){return typeof n.constructor=="function"&&!_e(n)?Ht($e(n)):{}}function Yl(n,t,e){var r=n.constructor;switch(t){case re:return gi(n);case Qt:case Vt:return new r(+n);case Ut:return Ol(n,e);case mr:case yr:case xr:case Sr:case Cr:case Ar:case br:case Rr:case Pr:return gs(n,e);case Hn:return new r;case jt:case te:return new r(n);case ne:return Wl(n);case kn:return new r;case Pe:return Ml(n)}}function Xl(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(Qo,`{
|
|
9
|
+
/* [wrapped with `+t+`] */
|
|
10
|
+
`)}function Ql(n){return L(n)||Wt(n)||!!(Uu&&n&&n[Uu])}function ot(n,t){var e=typeof n;return t=t??ht,!!t&&(e=="number"||e!="symbol"&&aa.test(n))&&n>-1&&n%1==0&&n<t}function dn(n,t,e){if(!Y(e))return!1;var r=typeof t;return(r=="number"?xn(e)&&ot(t,e.length):r=="string"&&t in e)?Yn(e[t],n):!1}function xi(n,t){if(L(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||In(n)?!0:Jo.test(n)||!ko.test(n)||t!=null&&n in H(t)}function Vl(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}function Si(n){var t=ur(n),e=s[t];if(typeof e!="function"||!(t in N.prototype))return!1;if(n===e)return!0;var r=wi(e);return!!r&&n===r[0]}function jl(n){return!!Ou&&Ou in n}var nc=Fe?at:Bi;function _e(n){var t=n&&n.constructor,e=typeof t=="function"&&t.prototype||Kt;return n===e}function Os(n){return n===n&&!Y(n)}function Ws(n,t){return function(e){return e==null?!1:e[n]===t&&(t!==i||n in H(e))}}function tc(n){var t=cr(n,function(r){return e.size===tn&&e.clear(),r}),e=t.cache;return t}function ec(n,t){var e=n[1],r=t[1],u=e|r,o=u<(wn|mn|F),a=r==F&&e==Gn||r==F&&e==nn&&n[7].length<=t[8]||r==(F|nn)&&t[7].length<=t[8]&&e==Gn;if(!(o||a))return n;r&wn&&(n[2]=t[2],u|=e&wn?0:Se);var f=t[3];if(f){var c=n[3];n[3]=c?ds(c,f,t[4]):f,n[4]=c?dt(n[3],An):t[4]}return f=t[5],f&&(c=n[5],n[5]=c?_s(c,f,t[6]):f,n[6]=c?dt(n[5],An):t[6]),f=t[7],f&&(n[7]=f),r&F&&(n[8]=n[8]==null?t[8]:ln(n[8],t[8])),n[9]==null&&(n[9]=t[9]),n[0]=t[0],n[1]=u,n}function rc(n){var t=[];if(n!=null)for(var e in H(n))t.push(e);return t}function ic(n){return De.call(n)}function Ms(n,t,e){return t=sn(t===i?n.length-1:t,0),function(){for(var r=arguments,u=-1,o=sn(r.length-t,0),a=h(o);++u<o;)a[u]=r[t+u];u=-1;for(var f=h(t+1);++u<t;)f[u]=r[u];return f[t]=e(a),Pn(n,this,f)}}function Fs(n,t){return t.length<2?n:It(n,$n(t,0,-1))}function uc(n,t){for(var e=n.length,r=ln(t.length,e),u=yn(n);r--;){var o=t[r];n[r]=ot(o,e)?u[o]:i}return n}function Ci(n,t){if(!(t==="constructor"&&typeof n[t]=="function")&&t!="__proto__")return n[t]}var Us=Ns(us),ve=yf||function(n,t){return an.setTimeout(n,t)},Ai=Ns(Tl);function Ds(n,t,e){var r=t+"";return Ai(n,Xl(r,sc(Jl(r),e)))}function Ns(n){var t=0,e=0;return function(){var r=Af(),u=X-(r-e);if(e=r,u>0){if(++t>=Mn)return arguments[0]}else t=0;return n.apply(i,arguments)}}function or(n,t){var e=-1,r=n.length,u=r-1;for(t=t===i?r:t;++e<t;){var o=si(e,u),a=n[o];n[o]=n[e],n[e]=a}return n.length=t,n}var Bs=tc(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(Zo,function(e,r,u,o){t.push(u?o.replace(ea,"$1"):r||e)}),t});function nt(n){if(typeof n=="string"||In(n))return n;var t=n+"";return t=="0"&&1/n==-At?"-0":t}function Ot(n){if(n!=null){try{return Ue.call(n)}catch{}try{return n+""}catch{}}return""}function sc(n,t){return Un(Oo,function(e){var r="_."+e[0];t&e[1]&&!Le(n,r)&&n.push(r)}),n.sort()}function $s(n){if(n instanceof N)return n.clone();var t=new Nn(n.__wrapped__,n.__chain__);return t.__actions__=yn(n.__actions__),t.__index__=n.__index__,t.__values__=n.__values__,t}function oc(n,t,e){(e?dn(n,t,e):t===i)?t=1:t=sn(W(t),0);var r=n==null?0:n.length;if(!r||t<1)return[];for(var u=0,o=0,a=h(Ge(r/t));u<r;)a[o++]=$n(n,u,u+=t);return a}function ac(n){for(var t=-1,e=n==null?0:n.length,r=0,u=[];++t<e;){var o=n[t];o&&(u[r++]=o)}return u}function fc(){var n=arguments.length;if(!n)return[];for(var t=h(n-1),e=arguments[0],r=n;r--;)t[r-1]=arguments[r];return pt(L(e)?yn(e):[e],fn(t,1))}var lc=U(function(n,t){return V(n)?ce(n,fn(t,1,V,!0)):[]}),cc=U(function(n,t){var e=qn(t);return V(e)&&(e=i),V(n)?ce(n,fn(t,1,V,!0),b(e,2)):[]}),hc=U(function(n,t){var e=qn(t);return V(e)&&(e=i),V(n)?ce(n,fn(t,1,V,!0),i,e):[]});function gc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),$n(n,t<0?0:t,r)):[]}function pc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),t=r-t,$n(n,0,t<0?0:t)):[]}function dc(n,t){return n&&n.length?je(n,b(t,3),!0,!0):[]}function _c(n,t){return n&&n.length?je(n,b(t,3),!0):[]}function vc(n,t,e,r){var u=n==null?0:n.length;return u?(e&&typeof e!="number"&&dn(n,t,e)&&(e=0,r=u),fl(n,t,e,r)):[]}function qs(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=sn(r+u,0)),Oe(n,b(t,3),u)}function Ks(n,t,e){var r=n==null?0:n.length;if(!r)return-1;var u=r-1;return e!==i&&(u=W(e),u=e<0?sn(r+u,0):ln(u,r-1)),Oe(n,b(t,3),u,!0)}function Gs(n){var t=n==null?0:n.length;return t?fn(n,1):[]}function wc(n){var t=n==null?0:n.length;return t?fn(n,At):[]}function mc(n,t){var e=n==null?0:n.length;return e?(t=t===i?1:W(t),fn(n,t)):[]}function yc(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 zs(n){return n&&n.length?n[0]:i}function xc(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=sn(r+u,0)),Nt(n,t,u)}function Sc(n){var t=n==null?0:n.length;return t?$n(n,0,-1):[]}var Cc=U(function(n){var t=Z(n,ci);return t.length&&t[0]===n[0]?ti(t):[]}),Ac=U(function(n){var t=qn(n),e=Z(n,ci);return t===qn(e)?t=i:e.pop(),e.length&&e[0]===n[0]?ti(e,b(t,2)):[]}),bc=U(function(n){var t=qn(n),e=Z(n,ci);return t=typeof t=="function"?t:i,t&&e.pop(),e.length&&e[0]===n[0]?ti(e,i,t):[]});function Rc(n,t){return n==null?"":Sf.call(n,t)}function qn(n){var t=n==null?0:n.length;return t?n[t-1]:i}function Pc(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?sn(r+u,0):ln(u,r-1)),t===t?sf(n,t,u):Oe(n,Au,u,!0)}function Tc(n,t){return n&&n.length?ts(n,W(t)):i}var Ec=U(Hs);function Hs(n,t){return n&&n.length&&t&&t.length?ui(n,t):n}function Ic(n,t,e){return n&&n.length&&t&&t.length?ui(n,t,b(e,2)):n}function Lc(n,t,e){return n&&n.length&&t&&t.length?ui(n,t,i,e):n}var Oc=st(function(n,t){var e=n==null?0:n.length,r=Qr(n,t);return is(n,Z(t,function(u){return ot(u,e)?+u:u}).sort(ps)),r});function Wc(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 is(n,u),e}function bi(n){return n==null?n:Rf.call(n)}function Mc(n,t,e){var r=n==null?0:n.length;return r?(e&&typeof e!="number"&&dn(n,t,e)?(t=0,e=r):(t=t==null?0:W(t),e=e===i?r:W(e)),$n(n,t,e)):[]}function Fc(n,t){return Ve(n,t)}function Uc(n,t,e){return ai(n,t,b(e,2))}function Dc(n,t){var e=n==null?0:n.length;if(e){var r=Ve(n,t);if(r<e&&Yn(n[r],t))return r}return-1}function Nc(n,t){return Ve(n,t,!0)}function Bc(n,t,e){return ai(n,t,b(e,2),!0)}function $c(n,t){var e=n==null?0:n.length;if(e){var r=Ve(n,t,!0)-1;if(Yn(n[r],t))return r}return-1}function qc(n){return n&&n.length?ss(n):[]}function Kc(n,t){return n&&n.length?ss(n,b(t,2)):[]}function Gc(n){var t=n==null?0:n.length;return t?$n(n,1,t):[]}function zc(n,t,e){return n&&n.length?(t=e||t===i?1:W(t),$n(n,0,t<0?0:t)):[]}function Hc(n,t,e){var r=n==null?0:n.length;return r?(t=e||t===i?1:W(t),t=r-t,$n(n,t<0?0:t,r)):[]}function kc(n,t){return n&&n.length?je(n,b(t,3),!1,!0):[]}function Jc(n,t){return n&&n.length?je(n,b(t,3)):[]}var Zc=U(function(n){return wt(fn(n,1,V,!0))}),Yc=U(function(n){var t=qn(n);return V(t)&&(t=i),wt(fn(n,1,V,!0),b(t,2))}),Xc=U(function(n){var t=qn(n);return t=typeof t=="function"?t:i,wt(fn(n,1,V,!0),i,t)});function Qc(n){return n&&n.length?wt(n):[]}function Vc(n,t){return n&&n.length?wt(n,b(t,2)):[]}function jc(n,t){return t=typeof t=="function"?t:i,n&&n.length?wt(n,i,t):[]}function Ri(n){if(!(n&&n.length))return[];var t=0;return n=gt(n,function(e){if(V(e))return t=sn(e.length,t),!0}),Gr(t,function(e){return Z(n,$r(e))})}function ks(n,t){if(!(n&&n.length))return[];var e=Ri(n);return t==null?e:Z(e,function(r){return Pn(t,i,r)})}var nh=U(function(n,t){return V(n)?ce(n,t):[]}),th=U(function(n){return li(gt(n,V))}),eh=U(function(n){var t=qn(n);return V(t)&&(t=i),li(gt(n,V),b(t,2))}),rh=U(function(n){var t=qn(n);return t=typeof t=="function"?t:i,li(gt(n,V),i,t)}),ih=U(Ri);function uh(n,t){return ls(n||[],t||[],le)}function sh(n,t){return ls(n||[],t||[],pe)}var oh=U(function(n){var t=n.length,e=t>1?n[t-1]:i;return e=typeof e=="function"?(n.pop(),e):i,ks(n,e)});function Js(n){var t=s(n);return t.__chain__=!0,t}function ah(n,t){return t(n),n}function ar(n,t){return t(n)}var fh=st(function(n){var t=n.length,e=t?n[0]:0,r=this.__wrapped__,u=function(o){return Qr(o,n)};return t>1||this.__actions__.length||!(r instanceof N)||!ot(e)?this.thru(u):(r=r.slice(e,+e+(t?1:0)),r.__actions__.push({func:ar,args:[u],thisArg:i}),new Nn(r,this.__chain__).thru(function(o){return t&&!o.length&&o.push(i),o}))});function lh(){return Js(this)}function ch(){return new Nn(this.value(),this.__chain__)}function hh(){this.__values__===i&&(this.__values__=oo(this.value()));var n=this.__index__>=this.__values__.length,t=n?i:this.__values__[this.__index__++];return{done:n,value:t}}function gh(){return this}function ph(n){for(var t,e=this;e instanceof Je;){var r=$s(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:ar,args:[bi],thisArg:i}),new Nn(t,this.__chain__)}return this.thru(bi)}function _h(){return fs(this.__wrapped__,this.__actions__)}var vh=nr(function(n,t,e){G.call(n,e)?++n[e]:it(n,e,1)});function wh(n,t,e){var r=L(n)?Su:al;return e&&dn(n,t,e)&&(t=i),r(n,b(t,3))}function mh(n,t){var e=L(n)?gt:ku;return e(n,b(t,3))}var yh=ys(qs),xh=ys(Ks);function Sh(n,t){return fn(fr(n,t),1)}function Ch(n,t){return fn(fr(n,t),At)}function Ah(n,t,e){return e=e===i?1:W(e),fn(fr(n,t),e)}function Zs(n,t){var e=L(n)?Un:vt;return e(n,b(t,3))}function Ys(n,t){var e=L(n)?Ka:Hu;return e(n,b(t,3))}var bh=nr(function(n,t,e){G.call(n,e)?n[e].push(t):it(n,e,[t])});function Rh(n,t,e,r){n=xn(n)?n:Xt(n),e=e&&!r?W(e):0;var u=n.length;return e<0&&(e=sn(u+e,0)),pr(n)?e<=u&&n.indexOf(t,e)>-1:!!u&&Nt(n,t,e)>-1}var Ph=U(function(n,t,e){var r=-1,u=typeof t=="function",o=xn(n)?h(n.length):[];return vt(n,function(a){o[++r]=u?Pn(t,a,e):he(a,t,e)}),o}),Th=nr(function(n,t,e){it(n,e,t)});function fr(n,t){var e=L(n)?Z:Vu;return e(n,b(t,3))}function Eh(n,t,e,r){return n==null?[]:(L(t)||(t=t==null?[]:[t]),e=r?i:e,L(e)||(e=e==null?[]:[e]),es(n,t,e))}var Ih=nr(function(n,t,e){n[e?0:1].push(t)},function(){return[[],[]]});function Lh(n,t,e){var r=L(n)?Nr:Ru,u=arguments.length<3;return r(n,b(t,4),e,u,vt)}function Oh(n,t,e){var r=L(n)?Ga:Ru,u=arguments.length<3;return r(n,b(t,4),e,u,Hu)}function Wh(n,t){var e=L(n)?gt:ku;return e(n,hr(b(t,3)))}function Mh(n){var t=L(n)?qu:Rl;return t(n)}function Fh(n,t,e){(e?dn(n,t,e):t===i)?t=1:t=W(t);var r=L(n)?rl:Pl;return r(n,t)}function Uh(n){var t=L(n)?il:El;return t(n)}function Dh(n){if(n==null)return 0;if(xn(n))return pr(n)?$t(n):n.length;var t=cn(n);return t==Hn||t==kn?n.size:ri(n).length}function Nh(n,t,e){var r=L(n)?Br:Il;return e&&dn(n,t,e)&&(t=i),r(n,b(t,3))}var Bh=U(function(n,t){if(n==null)return[];var e=t.length;return e>1&&dn(n,t[0],t[1])?t=[]:e>2&&dn(t[0],t[1],t[2])&&(t=[t[0]]),es(n,fn(t,1),[])}),lr=mf||function(){return an.Date.now()};function $h(n,t){if(typeof t!="function")throw new Dn(A);return n=W(n),function(){if(--n<1)return t.apply(this,arguments)}}function Xs(n,t,e){return t=e?i:t,t=n&&t==null?n.length:t,ut(n,F,i,i,i,i,t)}function Qs(n,t){var e;if(typeof t!="function")throw new Dn(A);return n=W(n),function(){return--n>0&&(e=t.apply(this,arguments)),n<=1&&(t=i),e}}var Pi=U(function(n,t,e){var r=wn;if(e.length){var u=dt(e,Zt(Pi));r|=zn}return ut(n,r,t,e,u)}),Vs=U(function(n,t,e){var r=wn|mn;if(e.length){var u=dt(e,Zt(Vs));r|=zn}return ut(t,r,n,e,u)});function js(n,t,e){t=e?i:t;var r=ut(n,Gn,i,i,i,i,i,t);return r.placeholder=js.placeholder,r}function no(n,t,e){t=e?i:t;var r=ut(n,St,i,i,i,i,i,t);return r.placeholder=no.placeholder,r}function to(n,t,e){var r,u,o,a,f,c,d=0,_=!1,v=!1,x=!0;if(typeof n!="function")throw new Dn(A);t=Kn(t)||0,Y(e)&&(_=!!e.leading,v="maxWait"in e,o=v?sn(Kn(e.maxWait)||0,t):o,x="trailing"in e?!!e.trailing:x);function C(j){var Xn=r,lt=u;return r=u=i,d=j,a=n.apply(lt,Xn),a}function P(j){return d=j,f=ve(D,t),_?C(j):a}function M(j){var Xn=j-c,lt=j-d,xo=t-Xn;return v?ln(xo,o-lt):xo}function T(j){var Xn=j-c,lt=j-d;return c===i||Xn>=t||Xn<0||v&<>=o}function D(){var j=lr();if(T(j))return B(j);f=ve(D,M(j))}function B(j){return f=i,x&&r?C(j):(r=u=i,a)}function Ln(){f!==i&&cs(f),d=0,r=c=u=f=i}function _n(){return f===i?a:B(lr())}function On(){var j=lr(),Xn=T(j);if(r=arguments,u=this,c=j,Xn){if(f===i)return P(c);if(v)return cs(f),f=ve(D,t),C(c)}return f===i&&(f=ve(D,t)),a}return On.cancel=Ln,On.flush=_n,On}var qh=U(function(n,t){return zu(n,1,t)}),Kh=U(function(n,t,e){return zu(n,Kn(t)||0,e)});function Gh(n){return ut(n,z)}function cr(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new Dn(A);var e=function(){var r=arguments,u=t?t.apply(this,r):r[0],o=e.cache;if(o.has(u))return o.get(u);var a=n.apply(this,r);return e.cache=o.set(u,a)||o,a};return e.cache=new(cr.Cache||rt),e}cr.Cache=rt;function hr(n){if(typeof n!="function")throw new Dn(A);return function(){var t=arguments;switch(t.length){case 0:return!n.call(this);case 1:return!n.call(this,t[0]);case 2:return!n.call(this,t[0],t[1]);case 3:return!n.call(this,t[0],t[1],t[2])}return!n.apply(this,t)}}function zh(n){return Qs(2,n)}var Hh=Ll(function(n,t){t=t.length==1&&L(t[0])?Z(t[0],Tn(b())):Z(fn(t,1),Tn(b()));var e=t.length;return U(function(r){for(var u=-1,o=ln(r.length,e);++u<o;)r[u]=t[u].call(this,r[u]);return Pn(n,this,r)})}),Ti=U(function(n,t){var e=dt(t,Zt(Ti));return ut(n,zn,i,t,e)}),eo=U(function(n,t){var e=dt(t,Zt(eo));return ut(n,Ct,i,t,e)}),kh=st(function(n,t){return ut(n,nn,i,i,i,t)});function Jh(n,t){if(typeof n!="function")throw new Dn(A);return t=t===i?t:W(t),U(n,t)}function Zh(n,t){if(typeof n!="function")throw new Dn(A);return t=t==null?0:sn(W(t),0),U(function(e){var r=e[t],u=yt(e,0,t);return r&&pt(u,r),Pn(n,this,u)})}function Yh(n,t,e){var r=!0,u=!0;if(typeof n!="function")throw new Dn(A);return Y(e)&&(r="leading"in e?!!e.leading:r,u="trailing"in e?!!e.trailing:u),to(n,t,{leading:r,maxWait:t,trailing:u})}function Xh(n){return Xs(n,1)}function Qh(n,t){return Ti(hi(t),n)}function Vh(){if(!arguments.length)return[];var n=arguments[0];return L(n)?n:[n]}function jh(n){return Bn(n,hn)}function ng(n,t){return t=typeof t=="function"?t:i,Bn(n,hn,t)}function tg(n){return Bn(n,en|hn)}function eg(n,t){return t=typeof t=="function"?t:i,Bn(n,en|hn,t)}function rg(n,t){return t==null||Gu(n,t,on(t))}function Yn(n,t){return n===t||n!==n&&t!==t}var ig=ir(ni),ug=ir(function(n,t){return n>=t}),Wt=Yu(function(){return arguments}())?Yu:function(n){return Q(n)&&G.call(n,"callee")&&!Fu.call(n,"callee")},L=h.isArray,sg=_u?Tn(_u):pl;function xn(n){return n!=null&&gr(n.length)&&!at(n)}function V(n){return Q(n)&&xn(n)}function og(n){return n===!0||n===!1||Q(n)&&pn(n)==Qt}var xt=xf||Bi,ag=vu?Tn(vu):dl;function fg(n){return Q(n)&&n.nodeType===1&&!we(n)}function lg(n){if(n==null)return!0;if(xn(n)&&(L(n)||typeof n=="string"||typeof n.splice=="function"||xt(n)||Yt(n)||Wt(n)))return!n.length;var t=cn(n);if(t==Hn||t==kn)return!n.size;if(_e(n))return!ri(n).length;for(var e in n)if(G.call(n,e))return!1;return!0}function cg(n,t){return ge(n,t)}function hg(n,t,e){e=typeof e=="function"?e:i;var r=e?e(n,t):i;return r===i?ge(n,t,i,e):!!r}function Ei(n){if(!Q(n))return!1;var t=pn(n);return t==be||t==Mo||typeof n.message=="string"&&typeof n.name=="string"&&!we(n)}function gg(n){return typeof n=="number"&&Du(n)}function at(n){if(!Y(n))return!1;var t=pn(n);return t==Re||t==zi||t==Wo||t==Uo}function ro(n){return typeof n=="number"&&n==W(n)}function gr(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=ht}function Y(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function Q(n){return n!=null&&typeof n=="object"}var io=wu?Tn(wu):vl;function pg(n,t){return n===t||ei(n,t,mi(t))}function dg(n,t,e){return e=typeof e=="function"?e:i,ei(n,t,mi(t),e)}function _g(n){return uo(n)&&n!=+n}function vg(n){if(nc(n))throw new I(R);return Xu(n)}function wg(n){return n===null}function mg(n){return n==null}function uo(n){return typeof n=="number"||Q(n)&&pn(n)==jt}function we(n){if(!Q(n)||pn(n)!=tt)return!1;var t=$e(n);if(t===null)return!0;var e=G.call(t,"constructor")&&t.constructor;return typeof e=="function"&&e instanceof e&&Ue.call(e)==df}var Ii=mu?Tn(mu):wl;function yg(n){return ro(n)&&n>=-ht&&n<=ht}var so=yu?Tn(yu):ml;function pr(n){return typeof n=="string"||!L(n)&&Q(n)&&pn(n)==te}function In(n){return typeof n=="symbol"||Q(n)&&pn(n)==Pe}var Yt=xu?Tn(xu):yl;function xg(n){return n===i}function Sg(n){return Q(n)&&cn(n)==ee}function Cg(n){return Q(n)&&pn(n)==No}var Ag=ir(ii),bg=ir(function(n,t){return n<=t});function oo(n){if(!n)return[];if(xn(n))return pr(n)?Jn(n):yn(n);if(ue&&n[ue])return ef(n[ue]());var t=cn(n),e=t==Hn?Hr:t==kn?We:Xt;return e(n)}function ft(n){if(!n)return n===0?n:0;if(n=Kn(n),n===At||n===-At){var t=n<0?-1:1;return t*Eo}return n===n?n:0}function W(n){var t=ft(n),e=t%1;return t===t?e?t-e:t:0}function ao(n){return n?Et(W(n),0,Qn):0}function Kn(n){if(typeof n=="number")return n;if(In(n))return Ce;if(Y(n)){var t=typeof n.valueOf=="function"?n.valueOf():n;n=Y(t)?t+"":t}if(typeof n!="string")return n===0?n:+n;n=Pu(n);var e=ua.test(n);return e||oa.test(n)?Ba(n.slice(2),e?2:8):ia.test(n)?Ce:+n}function fo(n){return jn(n,Sn(n))}function Rg(n){return n?Et(W(n),-ht,ht):n===0?n:0}function K(n){return n==null?"":En(n)}var Pg=kt(function(n,t){if(_e(t)||xn(t)){jn(t,on(t),n);return}for(var e in t)G.call(t,e)&&le(n,e,t[e])}),lo=kt(function(n,t){jn(t,Sn(t),n)}),dr=kt(function(n,t,e,r){jn(t,Sn(t),n,r)}),Tg=kt(function(n,t,e,r){jn(t,on(t),n,r)}),Eg=st(Qr);function Ig(n,t){var e=Ht(n);return t==null?e:Ku(e,t)}var Lg=U(function(n,t){n=H(n);var e=-1,r=t.length,u=r>2?t[2]:i;for(u&&dn(t[0],t[1],u)&&(r=1);++e<r;)for(var o=t[e],a=Sn(o),f=-1,c=a.length;++f<c;){var d=a[f],_=n[d];(_===i||Yn(_,Kt[d])&&!G.call(n,d))&&(n[d]=o[d])}return n}),Og=U(function(n){return n.push(i,Ps),Pn(co,i,n)});function Wg(n,t){return Cu(n,b(t,3),Vn)}function Mg(n,t){return Cu(n,b(t,3),jr)}function Fg(n,t){return n==null?n:Vr(n,b(t,3),Sn)}function Ug(n,t){return n==null?n:Ju(n,b(t,3),Sn)}function Dg(n,t){return n&&Vn(n,b(t,3))}function Ng(n,t){return n&&jr(n,b(t,3))}function Bg(n){return n==null?[]:Xe(n,on(n))}function $g(n){return n==null?[]:Xe(n,Sn(n))}function Li(n,t,e){var r=n==null?i:It(n,t);return r===i?e:r}function qg(n,t){return n!=null&&Is(n,t,ll)}function Oi(n,t){return n!=null&&Is(n,t,cl)}var Kg=Ss(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=De.call(t)),n[t]=e},Mi(Cn)),Gg=Ss(function(n,t,e){t!=null&&typeof t.toString!="function"&&(t=De.call(t)),G.call(n,t)?n[t].push(e):n[t]=[e]},b),zg=U(he);function on(n){return xn(n)?$u(n):ri(n)}function Sn(n){return xn(n)?$u(n,!0):xl(n)}function Hg(n,t){var e={};return t=b(t,3),Vn(n,function(r,u,o){it(e,t(r,u,o),r)}),e}function kg(n,t){var e={};return t=b(t,3),Vn(n,function(r,u,o){it(e,u,t(r,u,o))}),e}var Jg=kt(function(n,t,e){Qe(n,t,e)}),co=kt(function(n,t,e,r){Qe(n,t,e,r)}),Zg=st(function(n,t){var e={};if(n==null)return e;var r=!1;t=Z(t,function(o){return o=mt(o,n),r||(r=o.length>1),o}),jn(n,vi(n),e),r&&(e=Bn(e,en|bn|hn,Kl));for(var u=t.length;u--;)fi(e,t[u]);return e});function Yg(n,t){return ho(n,hr(b(t)))}var Xg=st(function(n,t){return n==null?{}:Cl(n,t)});function ho(n,t){if(n==null)return{};var e=Z(vi(n),function(r){return[r]});return t=b(t),rs(n,e,function(r,u){return t(r,u[0])})}function Qg(n,t,e){t=mt(t,n);var r=-1,u=t.length;for(u||(u=1,n=i);++r<u;){var o=n==null?i:n[nt(t[r])];o===i&&(r=u,o=e),n=at(o)?o.call(n):o}return n}function Vg(n,t,e){return n==null?n:pe(n,t,e)}function jg(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:pe(n,t,e,r)}var go=bs(on),po=bs(Sn);function np(n,t,e){var r=L(n),u=r||xt(n)||Yt(n);if(t=b(t,4),e==null){var o=n&&n.constructor;u?e=r?new o:[]:Y(n)?e=at(o)?Ht($e(n)):{}:e={}}return(u?Un:Vn)(n,function(a,f,c){return t(e,a,f,c)}),e}function tp(n,t){return n==null?!0:fi(n,t)}function ep(n,t,e){return n==null?n:as(n,t,hi(e))}function rp(n,t,e,r){return r=typeof r=="function"?r:i,n==null?n:as(n,t,hi(e),r)}function Xt(n){return n==null?[]:zr(n,on(n))}function ip(n){return n==null?[]:zr(n,Sn(n))}function up(n,t,e){return e===i&&(e=t,t=i),e!==i&&(e=Kn(e),e=e===e?e:0),t!==i&&(t=Kn(t),t=t===t?t:0),Et(Kn(n),t,e)}function sp(n,t,e){return t=ft(t),e===i?(e=t,t=0):e=ft(e),n=Kn(n),hl(n,t,e)}function op(n,t,e){if(e&&typeof e!="boolean"&&dn(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=ft(n),t===i?(t=n,n=0):t=ft(t)),n>t){var r=n;n=t,t=r}if(e||n%1||t%1){var u=Nu();return ln(n+u*(t-n+Na("1e-"+((u+"").length-1))),t)}return si(n,t)}var ap=Jt(function(n,t,e){return t=t.toLowerCase(),n+(e?_o(t):t)});function _o(n){return Wi(K(n).toLowerCase())}function vo(n){return n=K(n),n&&n.replace(fa,Qa).replace(Ta,"")}function fp(n,t,e){n=K(n),t=En(t);var r=n.length;e=e===i?r:Et(W(e),0,r);var u=e;return e-=t.length,e>=0&&n.slice(e,u)==t}function lp(n){return n=K(n),n&&Go.test(n)?n.replace(Ji,Va):n}function cp(n){return n=K(n),n&&Yo.test(n)?n.replace(Tr,"\\$&"):n}var hp=Jt(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()}),gp=Jt(function(n,t,e){return n+(e?" ":"")+t.toLowerCase()}),pp=ms("toLowerCase");function dp(n,t,e){n=K(n),t=W(t);var r=t?$t(n):0;if(!t||r>=t)return n;var u=(t-r)/2;return rr(ze(u),e)+n+rr(Ge(u),e)}function _p(n,t,e){n=K(n),t=W(t);var r=t?$t(n):0;return t&&r<t?n+rr(t-r,e):n}function vp(n,t,e){n=K(n),t=W(t);var r=t?$t(n):0;return t&&r<t?rr(t-r,e)+n:n}function wp(n,t,e){return e||t==null?t=0:t&&(t=+t),bf(K(n).replace(Er,""),t||0)}function mp(n,t,e){return(e?dn(n,t,e):t===i)?t=1:t=W(t),oi(K(n),t)}function yp(){var n=arguments,t=K(n[0]);return n.length<3?t:t.replace(n[1],n[2])}var xp=Jt(function(n,t,e){return n+(e?"_":"")+t.toLowerCase()});function Sp(n,t,e){return e&&typeof e!="number"&&dn(n,t,e)&&(t=e=i),e=e===i?Qn:e>>>0,e?(n=K(n),n&&(typeof t=="string"||t!=null&&!Ii(t))&&(t=En(t),!t&&Bt(n))?yt(Jn(n),0,e):n.split(t,e)):[]}var Cp=Jt(function(n,t,e){return n+(e?" ":"")+Wi(t)});function Ap(n,t,e){return n=K(n),e=e==null?0:Et(W(e),0,n.length),t=En(t),n.slice(e,e+t.length)==t}function bp(n,t,e){var r=s.templateSettings;e&&dn(n,t,e)&&(t=i),n=K(n),t=dr({},t,r,Rs);var u=dr({},t.imports,r.imports,Rs),o=on(u),a=zr(u,o),f,c,d=0,_=t.interpolate||Te,v="__p += '",x=kr((t.escape||Te).source+"|"+_.source+"|"+(_===Zi?ra:Te).source+"|"+(t.evaluate||Te).source+"|$","g"),C="//# sourceURL="+(G.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Wa+"]")+`
|
|
11
|
+
`;n.replace(x,function(T,D,B,Ln,_n,On){return B||(B=Ln),v+=n.slice(d,On).replace(la,ja),D&&(f=!0,v+=`' +
|
|
12
|
+
__e(`+D+`) +
|
|
13
|
+
'`),_n&&(c=!0,v+=`';
|
|
14
|
+
`+_n+`;
|
|
15
|
+
__p += '`),B&&(v+=`' +
|
|
16
|
+
((__t = (`+B+`)) == null ? '' : __t) +
|
|
17
|
+
'`),d=On+T.length,T}),v+=`';
|
|
18
|
+
`;var P=G.call(t,"variable")&&t.variable;if(!P)v=`with (obj) {
|
|
19
|
+
`+v+`
|
|
32
20
|
}
|
|
33
|
-
`;else if(
|
|
34
|
-
`+(
|
|
35
|
-
`)+"var __t, __p = ''"+(
|
|
21
|
+
`;else if(ta.test(P))throw new I(O);v=(c?v.replace(Bo,""):v).replace($o,"$1").replace(qo,"$1;"),v="function("+(P||"obj")+`) {
|
|
22
|
+
`+(P?"":`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
|
-
`)+
|
|
39
|
-
}`;var $=gu(function(){return Y(l,L+"return "+T).apply(r,d)});if($.source=T,hi($))throw $;return $}function l_(t){return V(t).toLowerCase()}function f_(t){return V(t).toUpperCase()}function d_(t,e,s){if(t=V(t),t&&(s||e===r))return Eo(t);if(!t||!(e=Ot(e)))return t;var o=Xt(t),u=Xt(e),l=To(o,u),d=Ao(o,u)+1;return Re(o,l,d).join("")}function p_(t,e,s){if(t=V(t),t&&(s||e===r))return t.slice(0,Io(t)+1);if(!t||!(e=Ot(e)))return t;var o=Xt(t),u=Ao(o,Xt(e))+1;return Re(o,0,u).join("")}function g_(t,e,s){if(t=V(t),t&&(s||e===r))return t.replace(hs,"");if(!t||!(e=Ot(e)))return t;var o=Xt(t),u=To(o,Xt(e));return Re(o,u).join("")}function __(t,e){var s=Nt,o=ht;if(nt(e)){var u="separator"in e?e.separator:u;s="length"in e?W(e.length):s,o="omission"in e?Ot(e.omission):o}t=V(t);var l=t.length;if(tn(t)){var d=Xt(t);l=d.length}if(s>=l)return t;var g=s-en(o);if(g<1)return o;var b=d?Re(d,0,g).join(""):t.slice(0,g);if(u===r)return b+o;if(d&&(g+=b.length-g),li(u)){if(t.slice(g).search(u)){var x,E=b;for(u.global||(u=Cs(u.source,V(Ji.exec(u))+"g")),u.lastIndex=0;x=u.exec(E);)var T=x.index;b=b.slice(0,T===r?g:T)}}else if(t.indexOf(Ot(u),g)!=g){var M=b.lastIndexOf(u);M>-1&&(b=b.slice(0,M))}return b+o}function b_(t){return t=V(t),t&&Cc.test(t)?t.replace(qi,Jh):t}var m_=cn(function(t,e,s){return t+(s?" ":"")+e.toUpperCase()}),pi=_a("toUpperCase");function pu(t,e,s){return t=V(t),e=s?r:e,e===r?Wh(t)?Yh(t):Ph(t):t.match(e)||[]}var gu=z(function(t,e){try{return Mt(t,r,e)}catch(s){return hi(s)?s:new N(s)}}),v_=_e(function(t,e){return Wt(e,function(s){s=ue(s),pe(t,s,ui(t[s],t))}),t});function w_(t){var e=t==null?0:t.length,s=B();return t=e?et(t,function(o){if(typeof o[1]!="function")throw new $t(p);return[s(o[0]),o[1]]}):[],z(function(o){for(var u=-1;++u<e;){var l=t[u];if(Mt(l[0],this,o))return Mt(l[1],this,o)}})}function y_(t){return Jl(zt(t,C))}function gi(t){return function(){return t}}function S_(t,e){return t==null||t!==t?e:t}var x_=ma(),E_=ma(!0);function Rt(t){return t}function _i(t){return Yo(typeof t=="function"?t:zt(t,C))}function T_(t){return Zo(zt(t,C))}function A_(t,e){return Xo(t,zt(e,C))}var C_=z(function(t,e){return function(s){return Bn(s,t,e)}}),I_=z(function(t,e){return function(s){return Bn(t,s,e)}});function bi(t,e,s){var o=gt(e),u=Er(e,o);s==null&&!(nt(e)&&(u.length||!o.length))&&(s=e,e=t,t=this,u=Er(e,gt(e)));var l=!(nt(s)&&"chain"in s)||!!s.chain,d=me(t);return Wt(u,function(g){var b=e[g];t[g]=b,d&&(t.prototype[g]=function(){var x=this.__chain__;if(l||x){var E=t(this.__wrapped__),T=E.__actions__=At(this.__actions__);return T.push({func:b,args:arguments,thisArg:t}),E.__chain__=x,E}return b.apply(t,xe([this.value()],arguments))})}),t}function R_(){return _t._===this&&(_t._=tl),this}function mi(){}function M_(t){return t=W(t),z(function(e){return Qo(e,t)})}var P_=Vs(et),O_=Vs(vo),L_=Vs(ws);function _u(t){return ni(t)?ys(ue(t)):cf(t)}function B_(t){return function(e){return t==null?r:$e(t,e)}}var k_=wa(),D_=wa(!0);function vi(){return[]}function wi(){return!1}function N_(){return{}}function F_(){return""}function U_(){return!0}function W_(t,e){if(t=W(t),t<1||t>ye)return[];var s=ie,o=mt(t,ie);e=B(e),t-=ie;for(var u=Es(o,e);++s<t;)e(s);return u}function $_(t){return F(t)?et(t,ue):Lt(t)?[t]:At(Da(V(t)))}function q_(t){var e=++Qh;return V(t)+e}var z_=Mr(function(t,e){return t+e},0),H_=Zs("ceil"),J_=Mr(function(t,e){return t/e},1),G_=Zs("floor");function K_(t){return t&&t.length?xr(t,Rt,ks):r}function Y_(t,e){return t&&t.length?xr(t,B(e,2),ks):r}function V_(t){return So(t,Rt)}function Z_(t,e){return So(t,B(e,2))}function X_(t){return t&&t.length?xr(t,Rt,Us):r}function Q_(t,e){return t&&t.length?xr(t,B(e,2),Us):r}var j_=Mr(function(t,e){return t*e},1),tb=Zs("round"),eb=Mr(function(t,e){return t-e},0);function nb(t){return t&&t.length?xs(t,Rt):0}function rb(t,e){return t&&t.length?xs(t,B(e,2)):0}return c.after=Tp,c.ary=Ka,c.assign=fg,c.assignIn=au,c.assignInWith=zr,c.assignWith=dg,c.at=pg,c.before=Ya,c.bind=ui,c.bindAll=v_,c.bindKey=Va,c.castArray=Np,c.chain=Ha,c.chunk=Gf,c.compact=Kf,c.concat=Yf,c.cond=w_,c.conforms=y_,c.constant=gi,c.countBy=np,c.create=gg,c.curry=Za,c.curryRight=Xa,c.debounce=Qa,c.defaults=_g,c.defaultsDeep=bg,c.defer=Ap,c.delay=Cp,c.difference=Vf,c.differenceBy=Zf,c.differenceWith=Xf,c.drop=Qf,c.dropRight=jf,c.dropRightWhile=td,c.dropWhile=ed,c.fill=nd,c.filter=sp,c.flatMap=ap,c.flatMapDeep=up,c.flatMapDepth=cp,c.flatten=Wa,c.flattenDeep=rd,c.flattenDepth=sd,c.flip=Ip,c.flow=x_,c.flowRight=E_,c.fromPairs=id,c.functions=Eg,c.functionsIn=Tg,c.groupBy=hp,c.initial=ad,c.intersection=ud,c.intersectionBy=cd,c.intersectionWith=hd,c.invert=Cg,c.invertBy=Ig,c.invokeMap=fp,c.iteratee=_i,c.keyBy=dp,c.keys=gt,c.keysIn=It,c.map=Nr,c.mapKeys=Mg,c.mapValues=Pg,c.matches=T_,c.matchesProperty=A_,c.memoize=Ur,c.merge=Og,c.mergeWith=uu,c.method=C_,c.methodOf=I_,c.mixin=bi,c.negate=Wr,c.nthArg=M_,c.omit=Lg,c.omitBy=Bg,c.once=Rp,c.orderBy=pp,c.over=P_,c.overArgs=Mp,c.overEvery=O_,c.overSome=L_,c.partial=ci,c.partialRight=ja,c.partition=gp,c.pick=kg,c.pickBy=cu,c.property=_u,c.propertyOf=B_,c.pull=pd,c.pullAll=qa,c.pullAllBy=gd,c.pullAllWith=_d,c.pullAt=bd,c.range=k_,c.rangeRight=D_,c.rearg=Pp,c.reject=mp,c.remove=md,c.rest=Op,c.reverse=oi,c.sampleSize=wp,c.set=Ng,c.setWith=Fg,c.shuffle=yp,c.slice=vd,c.sortBy=Ep,c.sortedUniq=Ad,c.sortedUniqBy=Cd,c.split=a_,c.spread=Lp,c.tail=Id,c.take=Rd,c.takeRight=Md,c.takeRightWhile=Pd,c.takeWhile=Od,c.tap=Kd,c.throttle=Bp,c.thru=Dr,c.toArray=su,c.toPairs=hu,c.toPairsIn=lu,c.toPath=$_,c.toPlainObject=ou,c.transform=Ug,c.unary=kp,c.union=Ld,c.unionBy=Bd,c.unionWith=kd,c.uniq=Dd,c.uniqBy=Nd,c.uniqWith=Fd,c.unset=Wg,c.unzip=ai,c.unzipWith=za,c.update=$g,c.updateWith=qg,c.values=fn,c.valuesIn=zg,c.without=Ud,c.words=pu,c.wrap=Dp,c.xor=Wd,c.xorBy=$d,c.xorWith=qd,c.zip=zd,c.zipObject=Hd,c.zipObjectDeep=Jd,c.zipWith=Gd,c.entries=hu,c.entriesIn=lu,c.extend=au,c.extendWith=zr,bi(c,c),c.add=z_,c.attempt=gu,c.camelCase=Kg,c.capitalize=fu,c.ceil=H_,c.clamp=Hg,c.clone=Fp,c.cloneDeep=Wp,c.cloneDeepWith=$p,c.cloneWith=Up,c.conformsTo=qp,c.deburr=du,c.defaultTo=S_,c.divide=J_,c.endsWith=Yg,c.eq=jt,c.escape=Vg,c.escapeRegExp=Zg,c.every=rp,c.find=ip,c.findIndex=Fa,c.findKey=mg,c.findLast=op,c.findLastIndex=Ua,c.findLastKey=vg,c.floor=G_,c.forEach=Ja,c.forEachRight=Ga,c.forIn=wg,c.forInRight=yg,c.forOwn=Sg,c.forOwnRight=xg,c.get=fi,c.gt=zp,c.gte=Hp,c.has=Ag,c.hasIn=di,c.head=$a,c.identity=Rt,c.includes=lp,c.indexOf=od,c.inRange=Jg,c.invoke=Rg,c.isArguments=He,c.isArray=F,c.isArrayBuffer=Jp,c.isArrayLike=Ct,c.isArrayLikeObject=ot,c.isBoolean=Gp,c.isBuffer=Me,c.isDate=Kp,c.isElement=Yp,c.isEmpty=Vp,c.isEqual=Zp,c.isEqualWith=Xp,c.isError=hi,c.isFinite=Qp,c.isFunction=me,c.isInteger=tu,c.isLength=$r,c.isMap=eu,c.isMatch=jp,c.isMatchWith=tg,c.isNaN=eg,c.isNative=ng,c.isNil=sg,c.isNull=rg,c.isNumber=nu,c.isObject=nt,c.isObjectLike=it,c.isPlainObject=Wn,c.isRegExp=li,c.isSafeInteger=ig,c.isSet=ru,c.isString=qr,c.isSymbol=Lt,c.isTypedArray=ln,c.isUndefined=og,c.isWeakMap=ag,c.isWeakSet=ug,c.join=ld,c.kebabCase=Xg,c.last=Jt,c.lastIndexOf=fd,c.lowerCase=Qg,c.lowerFirst=jg,c.lt=cg,c.lte=hg,c.max=K_,c.maxBy=Y_,c.mean=V_,c.meanBy=Z_,c.min=X_,c.minBy=Q_,c.stubArray=vi,c.stubFalse=wi,c.stubObject=N_,c.stubString=F_,c.stubTrue=U_,c.multiply=j_,c.nth=dd,c.noConflict=R_,c.noop=mi,c.now=Fr,c.pad=t_,c.padEnd=e_,c.padStart=n_,c.parseInt=r_,c.random=Gg,c.reduce=_p,c.reduceRight=bp,c.repeat=s_,c.replace=i_,c.result=Dg,c.round=tb,c.runInContext=_,c.sample=vp,c.size=Sp,c.snakeCase=o_,c.some=xp,c.sortedIndex=wd,c.sortedIndexBy=yd,c.sortedIndexOf=Sd,c.sortedLastIndex=xd,c.sortedLastIndexBy=Ed,c.sortedLastIndexOf=Td,c.startCase=u_,c.startsWith=c_,c.subtract=eb,c.sum=nb,c.sumBy=rb,c.template=h_,c.times=W_,c.toFinite=ve,c.toInteger=W,c.toLength=iu,c.toLower=l_,c.toNumber=Gt,c.toSafeInteger=lg,c.toString=V,c.toUpper=f_,c.trim=d_,c.trimEnd=p_,c.trimStart=g_,c.truncate=__,c.unescape=b_,c.uniqueId=q_,c.upperCase=m_,c.upperFirst=pi,c.each=Ja,c.eachRight=Ga,c.first=$a,bi(c,function(){var t={};return oe(c,function(e,s){Z.call(c.prototype,s)||(t[s]=e)}),t}(),{chain:!1}),c.VERSION=a,Wt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){c[t].placeholder=c}),Wt(["drop","take"],function(t,e){J.prototype[t]=function(s){s=s===r?1:ft(W(s),0);var o=this.__filtered__&&!e?new J(this):this.clone();return o.__filtered__?o.__takeCount__=mt(s,o.__takeCount__):o.__views__.push({size:mt(s,ie),type:t+(o.__dir__<0?"Right":"")}),o},J.prototype[t+"Right"]=function(s){return this.reverse()[t](s).reverse()}}),Wt(["filter","map","takeWhile"],function(t,e){var s=e+1,o=s==wt||s==dc;J.prototype[t]=function(u){var l=this.clone();return l.__iteratees__.push({iteratee:B(u,3),type:s}),l.__filtered__=l.__filtered__||o,l}}),Wt(["head","last"],function(t,e){var s="take"+(e?"Right":"");J.prototype[t]=function(){return this[s](1).value()[0]}}),Wt(["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(Rt)},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 Bn(s,t,e)})}),J.prototype.reject=function(t){return this.filter(Wr(B(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(ie)},oe(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,x=g[0],E=b||F(d),T=function(H){var G=u.apply(c,xe([H],g));return o&&M?G[0]:G};E&&s&&typeof x=="function"&&x.length!=1&&(b=E=!1);var M=this.__chain__,L=!!this.__actions__.length,k=l&&!M,$=b&&!L;if(!l&&E){d=$?d:new J(this);var D=t.apply(d,g);return D.__actions__.push({func:Dr,args:[T],thisArg:r}),new qt(D,M)}return k&&$?t.apply(this,g):(D=this.thru(T),k?o?D.value()[0]:D.value():D)})}),Wt(["pop","push","shift","sort","splice","unshift"],function(t){var e=ur[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(F(l)?l:[],u)}return this[s](function(d){return e.apply(F(d)?d:[],u)})}}),oe(J.prototype,function(t,e){var s=c[e];if(s){var o=s.name+"";Z.call(on,o)||(on[o]=[]),on[o].push({name:e,func:s})}}),on[Rr(r,ut).name]=[{name:"wrapper",func:r}],J.prototype.clone=_l,J.prototype.reverse=bl,J.prototype.value=ml,c.prototype.at=Yd,c.prototype.chain=Vd,c.prototype.commit=Zd,c.prototype.next=Xd,c.prototype.plant=jd,c.prototype.reverse=tp,c.prototype.toJSON=c.prototype.valueOf=c.prototype.value=ep,c.prototype.first=c.prototype.head,Cn&&(c.prototype[Cn]=Qd),c},nn=Vh();De?((De.exports=nn)._=nn,_s._=nn):_t._=nn}).call($n)})(Zr,Zr.exports);var lv=Zr.exports;const fv=Lu(lv);class dv{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 pv{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=fv.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 uc extends Yn{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 dv(this.config),h=new pv(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 Vn=U.createContext(void 0);function gv(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 _v(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 bv({dev:n=!1,baseUrl:i,protocols:r,logger:a,children:h,session:f="new",transformMessages:p,...m}){const[w,I]=U.useState(!1),[P,C]=U.useState([]),[A,R]=U.useState(f),[K,Tt]=U.useState(new Map),pt=U.useRef(!1),ut=U.useMemo(()=>{if(Array.isArray(r))return r;if(typeof r=="object"&&r!==null){const q=n?"localhost:8000":i||"persona.applica.guru/api",ct=n?"http":"https",X=n?"ws":"wss";let Nt=Object.keys(r).map(ht=>{switch(ht){case"rest":const Ft=r[ht];return Ft===!0?new Mi({apiUrl:`${ct}://${q}`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof Ft=="object"&&Ft!==null?new Mi(Ft):null;case"webrtc":const st=r[ht];return st===!0?new Oi({webrtcUrl:`${X}://${q}/webrtc`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof st=="object"&&st!==null?new Oi(st):null;case"websocket":const wt=r[ht];return wt===!0?new Pi({webSocketUrl:`${X}://${q}/websocket`,apiKey:m.apiKey,agentId:m.agentId,logger:a}):typeof wt=="object"&&wt!==null?new Pi(wt):null;default:throw new Error(`Unknown protocol: ${ht}`)}}).filter(ht=>ht!==null);return m.tools&&Nt.push(new uc({apiUrl:`${ct}://${q}`,apiKey:m.apiKey,agentId:m.agentId,tools:m.tools,logger:a})),Nt}throw new Error("Invalid protocols configuration")},[]);U.useEffect(()=>{pt.current||(pt.current=!0,a==null||a.debug("Initializing protocols: ",ut.map(q=>q.getName())),ut.forEach(q=>{q.setSession(A),q.clearListeners(),q.addStatusChangeListener(ct=>{a==null||a.debug(`${q.getName()} has notified new status: ${ct}`),K.set(q.getName(),ct),ct==="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(X=>X.schema)}}})),Tt(new Map(K))}),q.addPacketListener(ct=>{if(ct.type==="message"){const X=ct.payload;(X==null?void 0:X.finishReason)==="stop"&&!(X!=null&&X.functionResponse)&&!(X!=null&&X.thought)&&I(!1),X.thought&&(X.type="reasoning"),C(Nt=>{const ht=Ou([...Nt,{...X,protocol:q.getName()}]);return p?p(ht):ht})}else if(ct.type==="reasoning"){const Nt={type:"reasoning",text:ct.payload.thought,role:"assistant",finishReason:"stop"};C(ht=>{const Ft=Ou([...ht,{...Nt,protocol:q.getName()}]);return p?p(Ft):Ft})}else ct.type==="transaction"&&ut.filter(X=>X!==q).forEach(X=>X.onTransaction(ct.payload))}),q.autostart&&q.status==="disconnected"&&(a==null||a.debug(`Connecting to protocol: ${q.getName()}`),q.connect(A),I(!1))}))},[A,ut,a,K,p]);const Zn=async q=>{var Ft;if(((Ft=q.content[0])==null?void 0:Ft.type)!=="text")throw new Error("Only text messages are supported");if(!ut.some(st=>st.getName()!=="transaction"&&st.status==="connected")){C(st=>{const wt=[...st,{role:"assistant",type:"text",text:"No protocol is connected."}];return p?p(wt):wt});return}const X=q.content[0].text;C(st=>{const wt=[...st,{role:"user",type:"text",text:X}];return p?p(wt):wt}),I(!0);const Nt=ut.sort((st,wt)=>wt.getPriority()-st.getPriority()).find(st=>st.status==="connected"),ht=[];if(q.attachments)for(const st of q.attachments)st.contentType.startsWith("image/")&&st.file&&ht.push({role:"user",image:{contentType:st.contentType,content:await gv(st.file)},text:"",type:"text"});q.content&&ht.push({role:"user",text:q.content[0].text,type:"text"}),a==null||a.debug("Sending message:",ht),await(Nt==null?void 0:Nt.sendPacket({type:"request",payload:ht}))},Kt=U.useCallback(()=>(I(!1),C([]),R("new"),Promise.resolve()),[]),Le=U.useCallback(()=>Promise.resolve(),[]),Yt=U.useCallback(()=>P,[P]),Be=rm({isRunning:w,messages:P,convertMessage:cv,onNew:Zn,onCancel:Kt,onReload:Le,adapters:{attachments:new Jb([new zb])}});return Pe.jsx(Vn.Provider,{value:{protocols:ut,protocolsStatus:K,getMessages:Yt},children:Pe.jsx(ov,{runtime:Be,children:h})})}function mv({children:n,...i}){return Pe.jsx(bv,{...i,children:n})}function vv(){const n=U.useContext(Vn);if(!n)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return n}function cc(n){const i=U.useContext(Vn);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 wv(){const n=U.useContext(Vn);if(!n)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return _v(n.protocols)}function yv(){return cc("webrtc")}function Sv(){const n=U.useContext(Vn);if(!n)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return n.getMessages()}class xv{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 Ye(n,i,r){return{type:n,description:i,...r}}function hc(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 jr(n){return{schema:hc(n),implementation:n.implementation}}function lc(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 jr(p)}const Ev=lc("sum","Sum two numbers",function(i,r){return{result:i+r}},{a:Ye("number","First number to sum",{required:!0}),b:Ye("number","Second number to sum",{required:!0})},{result:Ye("number","Sum of two numbers")}),Tv=jr({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:Ye("number","First number to sum"),b:Ye("number","Seconth number to sum")},output:{result:Ye("number","Sum of two numbers")},implementation:function(i,r){return{result:i+r}}});function Av(n){const i=[],r={};return n.forEach(a=>{const{schema:h,implementation:f}=jr(a);i.push(h),r[a.name]=f}),{schemas:i,implementations:r}}function Cv(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}exports.PersonaConsoleLogger=xv;exports.PersonaProtocolBase=Yn;exports.PersonaRESTProtocol=Mi;exports.PersonaRuntimeProvider=mv;exports.PersonaTransactionProtocol=uc;exports.PersonaWebRTCProtocol=Oi;exports.PersonaWebSocketProtocol=Pi;exports.createParameter=Ye;exports.createTool=jr;exports.createToolFromFunction=lc;exports.createToolRegistry=Av;exports.generateToolSchema=hc;exports.navigateToToolExample=Tv;exports.sumTool=Ev;exports.usePersonaRuntime=vv;exports.usePersonaRuntimeEndpoint=wv;exports.usePersonaRuntimeMessages=Sv;exports.usePersonaRuntimeProtocol=cc;exports.usePersonaRuntimeWebRTCProtocol=yv;exports.validateToolParameters=Cv;
|
|
26
|
+
`)+v+`return __p
|
|
27
|
+
}`;var M=mo(function(){return $(o,C+"return "+v).apply(i,a)});if(M.source=v,Ei(M))throw M;return M}function Rp(n){return K(n).toLowerCase()}function Pp(n){return K(n).toUpperCase()}function Tp(n,t,e){if(n=K(n),n&&(e||t===i))return Pu(n);if(!n||!(t=En(t)))return n;var r=Jn(n),u=Jn(t),o=Tu(r,u),a=Eu(r,u)+1;return yt(r,o,a).join("")}function Ep(n,t,e){if(n=K(n),n&&(e||t===i))return n.slice(0,Lu(n)+1);if(!n||!(t=En(t)))return n;var r=Jn(n),u=Eu(r,Jn(t))+1;return yt(r,0,u).join("")}function Ip(n,t,e){if(n=K(n),n&&(e||t===i))return n.replace(Er,"");if(!n||!(t=En(t)))return n;var r=Jn(n),u=Tu(r,Jn(t));return yt(r,u).join("")}function Lp(n,t){var e=Wn,r=rn;if(Y(t)){var u="separator"in t?t.separator:u;e="length"in t?W(t.length):e,r="omission"in t?En(t.omission):r}n=K(n);var o=n.length;if(Bt(n)){var a=Jn(n);o=a.length}if(e>=o)return n;var f=e-$t(r);if(f<1)return r;var c=a?yt(a,0,f).join(""):n.slice(0,f);if(u===i)return c+r;if(a&&(f+=c.length-f),Ii(u)){if(n.slice(f).search(u)){var d,_=c;for(u.global||(u=kr(u.source,K(Yi.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(En(u),f)!=f){var x=c.lastIndexOf(u);x>-1&&(c=c.slice(0,x))}return c+r}function Op(n){return n=K(n),n&&Ko.test(n)?n.replace(ki,of):n}var Wp=Jt(function(n,t,e){return n+(e?" ":"")+t.toUpperCase()}),Wi=ms("toUpperCase");function wo(n,t,e){return n=K(n),t=e?i:t,t===i?tf(n)?lf(n):ka(n):n.match(t)||[]}var mo=U(function(n,t){try{return Pn(n,i,t)}catch(e){return Ei(e)?e:new I(e)}}),Mp=st(function(n,t){return Un(t,function(e){e=nt(e),it(n,e,Pi(n[e],n))}),n});function Fp(n){var t=n==null?0:n.length,e=b();return n=t?Z(n,function(r){if(typeof r[1]!="function")throw new Dn(A);return[e(r[0]),r[1]]}):[],U(function(r){for(var u=-1;++u<t;){var o=n[u];if(Pn(o[0],this,r))return Pn(o[1],this,r)}})}function Up(n){return ol(Bn(n,en))}function Mi(n){return function(){return n}}function Dp(n,t){return n==null||n!==n?t:n}var Np=xs(),Bp=xs(!0);function Cn(n){return n}function Fi(n){return Qu(typeof n=="function"?n:Bn(n,en))}function $p(n){return ju(Bn(n,en))}function qp(n,t){return ns(n,Bn(t,en))}var Kp=U(function(n,t){return function(e){return he(e,n,t)}}),Gp=U(function(n,t){return function(e){return he(n,e,t)}});function Ui(n,t,e){var r=on(t),u=Xe(t,r);e==null&&!(Y(t)&&(u.length||!r.length))&&(e=t,t=n,n=this,u=Xe(t,on(t)));var o=!(Y(e)&&"chain"in e)||!!e.chain,a=at(n);return Un(u,function(f){var c=t[f];n[f]=c,a&&(n.prototype[f]=function(){var d=this.__chain__;if(o||d){var _=n(this.__wrapped__),v=_.__actions__=yn(this.__actions__);return v.push({func:c,args:arguments,thisArg:n}),_.__chain__=d,_}return c.apply(n,pt([this.value()],arguments))})}),n}function zp(){return an._===this&&(an._=_f),this}function Di(){}function Hp(n){return n=W(n),U(function(t){return ts(t,n)})}var kp=pi(Z),Jp=pi(Su),Zp=pi(Br);function yo(n){return xi(n)?$r(nt(n)):Al(n)}function Yp(n){return function(t){return n==null?i:It(n,t)}}var Xp=Cs(),Qp=Cs(!0);function Ni(){return[]}function Bi(){return!1}function Vp(){return{}}function jp(){return""}function nd(){return!0}function td(n,t){if(n=W(n),n<1||n>ht)return[];var e=Qn,r=ln(n,Qn);t=b(t),n-=Qn;for(var u=Gr(r,t);++e<n;)t(e);return u}function ed(n){return L(n)?Z(n,nt):In(n)?[n]:yn(Bs(K(n)))}function rd(n){var t=++pf;return K(n)+t}var id=er(function(n,t){return n+t},0),ud=di("ceil"),sd=er(function(n,t){return n/t},1),od=di("floor");function ad(n){return n&&n.length?Ye(n,Cn,ni):i}function fd(n,t){return n&&n.length?Ye(n,b(t,2),ni):i}function ld(n){return bu(n,Cn)}function cd(n,t){return bu(n,b(t,2))}function hd(n){return n&&n.length?Ye(n,Cn,ii):i}function gd(n,t){return n&&n.length?Ye(n,b(t,2),ii):i}var pd=er(function(n,t){return n*t},1),dd=di("round"),_d=er(function(n,t){return n-t},0);function vd(n){return n&&n.length?Kr(n,Cn):0}function wd(n,t){return n&&n.length?Kr(n,b(t,2)):0}return s.after=$h,s.ary=Xs,s.assign=Pg,s.assignIn=lo,s.assignInWith=dr,s.assignWith=Tg,s.at=Eg,s.before=Qs,s.bind=Pi,s.bindAll=Mp,s.bindKey=Vs,s.castArray=Vh,s.chain=Js,s.chunk=oc,s.compact=ac,s.concat=fc,s.cond=Fp,s.conforms=Up,s.constant=Mi,s.countBy=vh,s.create=Ig,s.curry=js,s.curryRight=no,s.debounce=to,s.defaults=Lg,s.defaultsDeep=Og,s.defer=qh,s.delay=Kh,s.difference=lc,s.differenceBy=cc,s.differenceWith=hc,s.drop=gc,s.dropRight=pc,s.dropRightWhile=dc,s.dropWhile=_c,s.fill=vc,s.filter=mh,s.flatMap=Sh,s.flatMapDeep=Ch,s.flatMapDepth=Ah,s.flatten=Gs,s.flattenDeep=wc,s.flattenDepth=mc,s.flip=Gh,s.flow=Np,s.flowRight=Bp,s.fromPairs=yc,s.functions=Bg,s.functionsIn=$g,s.groupBy=bh,s.initial=Sc,s.intersection=Cc,s.intersectionBy=Ac,s.intersectionWith=bc,s.invert=Kg,s.invertBy=Gg,s.invokeMap=Ph,s.iteratee=Fi,s.keyBy=Th,s.keys=on,s.keysIn=Sn,s.map=fr,s.mapKeys=Hg,s.mapValues=kg,s.matches=$p,s.matchesProperty=qp,s.memoize=cr,s.merge=Jg,s.mergeWith=co,s.method=Kp,s.methodOf=Gp,s.mixin=Ui,s.negate=hr,s.nthArg=Hp,s.omit=Zg,s.omitBy=Yg,s.once=zh,s.orderBy=Eh,s.over=kp,s.overArgs=Hh,s.overEvery=Jp,s.overSome=Zp,s.partial=Ti,s.partialRight=eo,s.partition=Ih,s.pick=Xg,s.pickBy=ho,s.property=yo,s.propertyOf=Yp,s.pull=Ec,s.pullAll=Hs,s.pullAllBy=Ic,s.pullAllWith=Lc,s.pullAt=Oc,s.range=Xp,s.rangeRight=Qp,s.rearg=kh,s.reject=Wh,s.remove=Wc,s.rest=Jh,s.reverse=bi,s.sampleSize=Fh,s.set=Vg,s.setWith=jg,s.shuffle=Uh,s.slice=Mc,s.sortBy=Bh,s.sortedUniq=qc,s.sortedUniqBy=Kc,s.split=Sp,s.spread=Zh,s.tail=Gc,s.take=zc,s.takeRight=Hc,s.takeRightWhile=kc,s.takeWhile=Jc,s.tap=ah,s.throttle=Yh,s.thru=ar,s.toArray=oo,s.toPairs=go,s.toPairsIn=po,s.toPath=ed,s.toPlainObject=fo,s.transform=np,s.unary=Xh,s.union=Zc,s.unionBy=Yc,s.unionWith=Xc,s.uniq=Qc,s.uniqBy=Vc,s.uniqWith=jc,s.unset=tp,s.unzip=Ri,s.unzipWith=ks,s.update=ep,s.updateWith=rp,s.values=Xt,s.valuesIn=ip,s.without=nh,s.words=wo,s.wrap=Qh,s.xor=th,s.xorBy=eh,s.xorWith=rh,s.zip=ih,s.zipObject=uh,s.zipObjectDeep=sh,s.zipWith=oh,s.entries=go,s.entriesIn=po,s.extend=lo,s.extendWith=dr,Ui(s,s),s.add=id,s.attempt=mo,s.camelCase=ap,s.capitalize=_o,s.ceil=ud,s.clamp=up,s.clone=jh,s.cloneDeep=tg,s.cloneDeepWith=eg,s.cloneWith=ng,s.conformsTo=rg,s.deburr=vo,s.defaultTo=Dp,s.divide=sd,s.endsWith=fp,s.eq=Yn,s.escape=lp,s.escapeRegExp=cp,s.every=wh,s.find=yh,s.findIndex=qs,s.findKey=Wg,s.findLast=xh,s.findLastIndex=Ks,s.findLastKey=Mg,s.floor=od,s.forEach=Zs,s.forEachRight=Ys,s.forIn=Fg,s.forInRight=Ug,s.forOwn=Dg,s.forOwnRight=Ng,s.get=Li,s.gt=ig,s.gte=ug,s.has=qg,s.hasIn=Oi,s.head=zs,s.identity=Cn,s.includes=Rh,s.indexOf=xc,s.inRange=sp,s.invoke=zg,s.isArguments=Wt,s.isArray=L,s.isArrayBuffer=sg,s.isArrayLike=xn,s.isArrayLikeObject=V,s.isBoolean=og,s.isBuffer=xt,s.isDate=ag,s.isElement=fg,s.isEmpty=lg,s.isEqual=cg,s.isEqualWith=hg,s.isError=Ei,s.isFinite=gg,s.isFunction=at,s.isInteger=ro,s.isLength=gr,s.isMap=io,s.isMatch=pg,s.isMatchWith=dg,s.isNaN=_g,s.isNative=vg,s.isNil=mg,s.isNull=wg,s.isNumber=uo,s.isObject=Y,s.isObjectLike=Q,s.isPlainObject=we,s.isRegExp=Ii,s.isSafeInteger=yg,s.isSet=so,s.isString=pr,s.isSymbol=In,s.isTypedArray=Yt,s.isUndefined=xg,s.isWeakMap=Sg,s.isWeakSet=Cg,s.join=Rc,s.kebabCase=hp,s.last=qn,s.lastIndexOf=Pc,s.lowerCase=gp,s.lowerFirst=pp,s.lt=Ag,s.lte=bg,s.max=ad,s.maxBy=fd,s.mean=ld,s.meanBy=cd,s.min=hd,s.minBy=gd,s.stubArray=Ni,s.stubFalse=Bi,s.stubObject=Vp,s.stubString=jp,s.stubTrue=nd,s.multiply=pd,s.nth=Tc,s.noConflict=zp,s.noop=Di,s.now=lr,s.pad=dp,s.padEnd=_p,s.padStart=vp,s.parseInt=wp,s.random=op,s.reduce=Lh,s.reduceRight=Oh,s.repeat=mp,s.replace=yp,s.result=Qg,s.round=dd,s.runInContext=l,s.sample=Mh,s.size=Dh,s.snakeCase=xp,s.some=Nh,s.sortedIndex=Fc,s.sortedIndexBy=Uc,s.sortedIndexOf=Dc,s.sortedLastIndex=Nc,s.sortedLastIndexBy=Bc,s.sortedLastIndexOf=$c,s.startCase=Cp,s.startsWith=Ap,s.subtract=_d,s.sum=vd,s.sumBy=wd,s.template=bp,s.times=td,s.toFinite=ft,s.toInteger=W,s.toLength=ao,s.toLower=Rp,s.toNumber=Kn,s.toSafeInteger=Rg,s.toString=K,s.toUpper=Pp,s.trim=Tp,s.trimEnd=Ep,s.trimStart=Ip,s.truncate=Lp,s.unescape=Op,s.uniqueId=rd,s.upperCase=Wp,s.upperFirst=Wi,s.each=Zs,s.eachRight=Ys,s.first=zs,Ui(s,function(){var n={};return Vn(s,function(t,e){G.call(s.prototype,e)||(n[e]=t)}),n}(),{chain:!1}),s.VERSION=w,Un(["bind","bindKey","curry","curryRight","partial","partialRight"],function(n){s[n].placeholder=s}),Un(["drop","take"],function(n,t){N.prototype[n]=function(e){e=e===i?1:sn(W(e),0);var r=this.__filtered__&&!t?new N(this):this.clone();return r.__filtered__?r.__takeCount__=ln(e,r.__takeCount__):r.__views__.push({size:ln(e,Qn),type:n+(r.__dir__<0?"Right":"")}),r},N.prototype[n+"Right"]=function(e){return this.reverse()[n](e).reverse()}}),Un(["filter","map","takeWhile"],function(n,t){var e=t+1,r=e==gn||e==To;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}}),Un(["head","last"],function(n,t){var e="take"+(t?"Right":"");N.prototype[n]=function(){return this[e](1).value()[0]}}),Un(["initial","tail"],function(n,t){var e="drop"+(t?"":"Right");N.prototype[n]=function(){return this.__filtered__?new N(this):this[e](1)}}),N.prototype.compact=function(){return this.filter(Cn)},N.prototype.find=function(n){return this.filter(n).head()},N.prototype.findLast=function(n){return this.reverse().find(n)},N.prototype.invokeMap=U(function(n,t){return typeof n=="function"?new N(this):this.map(function(e){return he(e,n,t)})}),N.prototype.reject=function(n){return this.filter(hr(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(Qn)},Vn(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,pt([D],f));return r&&x?B[0]:B};_&&e&&typeof d=="function"&&d.length!=1&&(c=_=!1);var x=this.__chain__,C=!!this.__actions__.length,P=o&&!x,M=c&&!C;if(!o&&_){a=M?a:new N(this);var T=n.apply(a,f);return T.__actions__.push({func:ar,args:[v],thisArg:i}),new Nn(T,x)}return P&&M?n.apply(this,f):(T=this.thru(v),P?r?T.value()[0]:T.value():T)})}),Un(["pop","push","shift","sort","splice","unshift"],function(n){var t=Me[n],e=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",r=/^(?:pop|shift)$/.test(n);s.prototype[n]=function(){var u=arguments;if(r&&!this.__chain__){var o=this.value();return t.apply(L(o)?o:[],u)}return this[e](function(a){return t.apply(L(a)?a:[],u)})}}),Vn(N.prototype,function(n,t){var e=s[t];if(e){var r=e.name+"";G.call(zt,r)||(zt[r]=[]),zt[r].push({name:t,func:e})}}),zt[tr(i,mn).name]=[{name:"wrapper",func:i}],N.prototype.clone=Of,N.prototype.reverse=Wf,N.prototype.value=Mf,s.prototype.at=fh,s.prototype.chain=lh,s.prototype.commit=ch,s.prototype.next=hh,s.prototype.plant=ph,s.prototype.reverse=dh,s.prototype.toJSON=s.prototype.valueOf=s.prototype.value=_h,s.prototype.first=s.prototype.head,ue&&(s.prototype[ue]=gh),s},qt=cf();bt?((bt.exports=qt)._=qt,Fr._=qt):an._=qt}).call(me)})(vr,vr.exports);var bd=vr.exports;const Rd=Ad(bd);class Pd{constructor(g){E(this,"config");this.config=g}async complete(g,i){var w;await this.persist(g,{...i,success:!0}),(w=this.config.logger)==null||w.debug("Transaction completed:",g)}async fail(g,i){var w;await this.persist(g,{...i,success:!1}),(w=this.config.logger)==null||w.debug("Transaction failed:",{...g,...i})}async persist(g,i){await fetch(`${this.config.apiUrl}/transactions/${g.id}`,{body:JSON.stringify(i),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","x-persona-apikey":this.config.apiKey}})}}class Td{constructor(g,i){E(this,"transaction");E(this,"manager");this.transaction=g,this.manager=i}getFunctionCall(){return this.transaction.functionCall}async invoke(g,i){var O;const w=this.transaction.functionCall;if(!w){await this.fail("No function call found");return}const y=w.name,R=w.args,A=g[y];if(!A){await this.fail(`Tool ${y} not found`);return}try{const q=Rd.get(i,"schema.config.parameters.properties",{}),An=(q&&Object.keys(q).length>0?Object.keys(q):((O=A.toString().replace(/\n/g," ").match(/^[^(]*\(([^)]*)\)/))==null?void 0:O[1].split(",").map(bn=>bn.trim()).filter(Boolean))||[]).map(bn=>R[bn]),en=await A.apply(null,An);await this.complete(en)}catch(q){await this.fail(`Error executing tool ${y}: ${q}`)}}async complete(g){await this.manager.complete(this.transaction,{success:!0,output:g,error:null})}async fail(g){await this.manager.fail(this.transaction,{success:!1,output:null,error:g})}}class Co extends ye{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 Pd(this.config),y=new Td(i,w);if(this.config.onTransaction)this.config.onTransaction(y);else{const R=i.functionCall?this.getToolInstance(i.functionCall.name):void 0;y.invoke(this._tools,R)}}getTools(){return this._tools}}const xe=vn.createContext(void 0);function Ed(m){return new Promise((g,i)=>{const w=new FileReader;w.readAsDataURL(m),w.onload=()=>{const R=w.result.split(";base64,")[1];g(R)},w.onerror=y=>{i(y)}})}function Id(m){const g={rest:i=>i.config.apiUrl,webrtc:i=>i.config.webrtcUrl.replace("/webrtc","").replace("ws://","http://").replace("wss://","https://"),websocket:i=>i.config.webSocketUrl.replace("/websocket","").replace("ws://","http://").replace("wss://","https://")};for(const i of m){const w=g[i.getName()];if(w)return w(i)}return null}function Ld({dev:m=!1,baseUrl:g,protocols:i,logger:w,children:y,session:R="new",transformMessages:A,...O}){const[q,tn]=vn.useState(!1),[An,en]=vn.useState([]),[bn,hn]=vn.useState(R),[Rn,ct]=vn.useState(new Map),wn=vn.useRef(!1),mn=vn.useMemo(()=>{if(Array.isArray(i))return i;if(typeof i=="object"&&i!==null){const F=m?"localhost:8000":g||"persona.applica.guru/api",nn=m?"http":"https",z=m?"ws":"wss";let Wn=Object.keys(i).map(rn=>{switch(rn){case"rest":const Mn=i[rn];return Mn===!0?new qi({apiUrl:`${nn}://${F}`,apiKey:O.apiKey,agentId:O.agentId,logger:w}):typeof Mn=="object"&&Mn!==null?new qi(Mn):null;case"webrtc":const X=i[rn];return X===!0?new Gi({webrtcUrl:`${z}://${F}/webrtc`,apiKey:O.apiKey,agentId:O.agentId,logger:w}):typeof X=="object"&&X!==null?new Gi(X):null;case"websocket":const gn=i[rn];return gn===!0?new Ki({webSocketUrl:`${z}://${F}/websocket`,apiKey:O.apiKey,agentId:O.agentId,logger:w}):typeof gn=="object"&&gn!==null?new Ki(gn):null;default:throw new Error(`Unknown protocol: ${rn}`)}}).filter(rn=>rn!==null);return O.tools&&Wn.push(new Co({apiUrl:`${nn}://${F}`,apiKey:O.apiKey,agentId:O.agentId,tools:O.tools,logger:w})),Wn}throw new Error("Invalid protocols configuration")},[]);vn.useEffect(()=>{wn.current||(wn.current=!0,w==null||w.debug("Initializing protocols: ",mn.map(F=>F.getName())),mn.forEach(F=>{F.setSession(bn),F.clearListeners(),F.addStatusChangeListener(nn=>{w==null||w.debug(`${F.getName()} has notified new status: ${nn}`),Rn.set(F.getName(),nn),nn==="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(z=>z.schema)}}})),ct(new Map(Rn))}),F.addPacketListener(nn=>{if(nn.type==="message"){const z=nn.payload;(z==null?void 0:z.finishReason)==="stop"&&!(z!=null&&z.functionResponse)&&!(z!=null&&z.thought)&&tn(!1),z.thought&&(z.type="reasoning"),en(Wn=>{const rn=So([...Wn,{...z,protocol:F.getName()}]);return A?A(rn):rn})}else if(nn.type==="reasoning"){const Wn={type:"reasoning",text:nn.payload.thought,role:"assistant",finishReason:"stop"};en(rn=>{const Mn=So([...rn,{...Wn,protocol:F.getName()}]);return A?A(Mn):Mn})}else nn.type==="transaction"&&mn.filter(z=>z!==F).forEach(z=>z.onTransaction(nn.payload))}),F.autostart&&F.status==="disconnected"&&(w==null||w.debug(`Connecting to protocol: ${F.getName()}`),F.connect(bn),tn(!1))}))},[bn,mn,w,Rn,A]);const Se=async F=>{var Mn;if(((Mn=F.content[0])==null?void 0:Mn.type)!=="text")throw new Error("Only text messages are supported");if(!mn.some(X=>X.getName()!=="transaction"&&X.status==="connected")){en(X=>{const gn=[...X,{role:"assistant",type:"text",text:"No protocol is connected."}];return A?A(gn):gn});return}const z=F.content[0].text;en(X=>{const gn=[...X,{role:"user",type:"text",text:z}];return A?A(gn):gn}),tn(!0);const Wn=mn.sort((X,gn)=>gn.getPriority()-X.getPriority()).find(X=>X.status==="connected"),rn=[];if(F.attachments)for(const X of F.attachments)X.contentType.startsWith("image/")&&X.file&&rn.push({role:"user",image:{contentType:X.contentType,content:await Ed(X.file)},text:"",type:"text"});F.content&&rn.push({role:"user",text:F.content[0].text,type:"text"}),w==null||w.debug("Sending message:",rn),await(Wn==null?void 0:Wn.sendPacket({type:"request",payload:rn}))},Gn=vn.useCallback(()=>(tn(!1),en([]),hn("new"),Promise.resolve()),[]),St=vn.useCallback(()=>Promise.resolve(),[]),zn=vn.useCallback(()=>An,[An]),Ct=_r.useExternalStoreRuntime({isRunning:q,messages:An,convertMessage:Sd,onNew:Se,onCancel:Gn,onReload:St,adapters:{attachments:new _r.CompositeAttachmentAdapter([new _r.SimpleImageAttachmentAdapter])}});return $i.jsx(xe.Provider,{value:{protocols:mn,protocolsStatus:Rn,getMessages:zn},children:$i.jsx(_r.AssistantRuntimeProvider,{runtime:Ct,children:y})})}function Od({children:m,...g}){return $i.jsx(Ld,{...g,children:m})}function Wd(){const m=vn.useContext(xe);if(!m)throw new Error("usePersonaRuntime must be used within a PersonaRuntimeProvider");return m}function Ao(m){const g=vn.useContext(xe);if(!g)throw new Error("usePersonaRuntimeProtocol must be used within a PersonaRuntimeProvider");const i=g.protocols.find(y=>y.getName()===m);if(!i)return null;const w=g.protocolsStatus.get(i.getName());return{...i,connect:i.connect.bind(i),disconnect:i.disconnect.bind(i),sendPacket:i.sendPacket.bind(i),setSession:i.setSession.bind(i),addStatusChangeListener:i.addStatusChangeListener.bind(i),addPacketListener:i.addPacketListener.bind(i),getName:i.getName.bind(i),getPriority:i.getPriority.bind(i),status:w||i.status}}function Md(){const m=vn.useContext(xe);if(!m)throw new Error("usePersonaRuntimeEndpoint must be used within a PersonaRuntimeProvider");return Id(m.protocols)}function Fd(){return Ao("webrtc")}function Ud(){const m=vn.useContext(xe);if(!m)throw new Error("usePersonaRuntimeMessages must be used within a PersonaRuntimeProvider");return m.getMessages()}class Dd{constructor(){E(this,"prefix","[Persona]")}log(g,...i){console.log(`${this.prefix} - ${g}`,...i)}info(g,...i){console.info(`${this.prefix} - ${g}`,...i)}warn(g,...i){console.warn(`${this.prefix} - ${g}`,...i)}error(g,...i){console.error(`${this.prefix} - ${g}`,...i)}debug(g,...i){console.debug(`${this.prefix} - ${g}`,...i)}}function Mt(m,g,i){return{type:m,description:g,...i}}function bo(m){const g=Object.entries(m.parameters).filter(([i,w])=>w.required).map(([i])=>i);return{type:"local",name:m.name,description:m.description,config:{timeout:m.timeout||60,parameters:{type:"object",title:m.title||`${m.name} parameters`,required:g,properties:m.parameters},output:{type:"object",title:`${m.name} output`,properties:m.output}}}}function wr(m){return{schema:bo(m),implementation:m.implementation}}function Ro(m,g,i,w,y,R){const A={name:m,description:g,title:R==null?void 0:R.title,timeout:R==null?void 0:R.timeout,parameters:w,output:y,implementation:i};return wr(A)}const Nd=Ro("sum","Sum two numbers",function(g,i){return{result:g+i}},{a:Mt("number","First number to sum",{required:!0}),b:Mt("number","Second number to sum",{required:!0})},{result:Mt("number","Sum of two numbers")}),Bd=wr({name:"navigate_to",description:"Allow agent to redirect user to specific sub page like /foo or #/foo or anything like that",title:"Sum two numbers",timeout:60,parameters:{a:Mt("number","First number to sum"),b:Mt("number","Seconth number to sum")},output:{result:Mt("number","Sum of two numbers")},implementation:function(g,i){return{result:g+i}}});function $d(m){const g=[],i={};return m.forEach(w=>{const{schema:y,implementation:R}=wr(w);g.push(y),i[w.name]=R}),{schemas:g,implementations:i}}function qd(m,g){const{required:i,properties:w}=g.config.parameters;for(const y of i)if(!(y in m))throw new Error(`Missing required parameter: ${y}`);for(const[y,R]of Object.entries(m)){const A=w[y];if(A){if(A.type==="number"&&typeof R!="number")throw new Error(`Parameter ${y} should be a number`);if(A.type==="string"&&typeof R!="string")throw new Error(`Parameter ${y} should be a string`);if(A.type==="boolean"&&typeof R!="boolean")throw new Error(`Parameter ${y} should be a boolean`)}}return!0}exports.PersonaConsoleLogger=Dd;exports.PersonaProtocolBase=ye;exports.PersonaRESTProtocol=qi;exports.PersonaRuntimeProvider=Od;exports.PersonaTransactionProtocol=Co;exports.PersonaWebRTCProtocol=Gi;exports.PersonaWebSocketProtocol=Ki;exports.createParameter=Mt;exports.createTool=wr;exports.createToolFromFunction=Ro;exports.createToolRegistry=$d;exports.generateToolSchema=bo;exports.navigateToToolExample=Bd;exports.sumTool=Nd;exports.usePersonaRuntime=Wd;exports.usePersonaRuntimeEndpoint=Md;exports.usePersonaRuntimeMessages=Ud;exports.usePersonaRuntimeProtocol=Ao;exports.usePersonaRuntimeWebRTCProtocol=Fd;exports.validateToolParameters=qd;
|
|
40
28
|
//# sourceMappingURL=bundle.cjs.js.map
|