@ottocode/web-ui 0.1.271 → 0.1.272

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.
@@ -6,7 +6,7 @@ import{R as Qt,o as at,p as De,m as We,k as m,j as o,_ as wC,u as xC,h as za,i a
6
6
  `);return i===-1?"":n.stack.slice(i+1)})();try{if(!s.stack)s.stack=r;else if(r){const i=r.indexOf(`
7
7
  `),a=i===-1?-1:r.indexOf(`
8
8
  `,i+1),g=a===-1?"":r.slice(a+1);String(s.stack).endsWith(g)||(s.stack+=`
9
- `+r)}}catch{}}throw s}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=xs(this.defaults,t);const{transitional:s,paramsSerializer:n,headers:r}=t;s!==void 0&&In.assertOptions(s,{silentJSONParsing:Eo.transitional(Eo.boolean),forcedJSONParsing:Eo.transitional(Eo.boolean),clarifyTimeoutError:Eo.transitional(Eo.boolean),legacyInterceptorReqResOrdering:Eo.transitional(Eo.boolean)},!1),n!=null&&(gA.isFunction(n)?t.paramsSerializer={serialize:n}:In.assertOptions(n,{encode:Eo.function,serialize:Eo.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),In.assertOptions(t,{baseUrl:Eo.spelling("baseURL"),withXsrfToken:Eo.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=r&&gA.merge(r.common,r[t.method]);r&&gA.forEach(["delete","get","head","post","put","patch","query","common"],h=>{delete r[h]}),t.headers=Ao.concat(i,r);const a=[];let g=!0;this.interceptors.request.forEach(function(f){if(typeof f.runWhen=="function"&&f.runWhen(t)===!1)return;g=g&&f.synchronous;const d=t.transitional||gg;d&&d.legacyInterceptorReqResOrdering?a.unshift(f.fulfilled,f.rejected):a.push(f.fulfilled,f.rejected)});const Q=[];this.interceptors.response.forEach(function(f){Q.push(f.fulfilled,f.rejected)});let B,u=0,E;if(!g){const h=[dl.bind(this),void 0];for(h.unshift(...a),h.push(...Q),E=h.length,B=Promise.resolve(t);u<E;)B=B.then(h[u++],h[u++]);return B}E=a.length;let c=t;for(;u<E;){const h=a[u++],f=a[u++];try{c=h(c)}catch(d){f.call(this,d);break}}try{B=dl.call(this,c)}catch(h){return Promise.reject(h)}for(u=0,E=Q.length;u<E;)B=B.then(Q[u++],Q[u++]);return B}getUri(e){e=xs(this.defaults,e);const t=JB(e.baseURL,e.url,e.allowAbsoluteUrls);return UB(t,e.params,e.paramsSerializer)}};gA.forEach(["delete","get","head","options"],function(e){fs.prototype[e]=function(t,s){return this.request(xs(s||{},{method:e,url:t,data:(s||{}).data}))}});gA.forEach(["post","put","patch","query"],function(e){function t(s){return function(r,i,a){return this.request(xs(a||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:r,data:i}))}}fs.prototype[e]=t(),e!=="query"&&(fs.prototype[e+"Form"]=t(!0))});let td=class qB{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const s=this;this.promise.then(n=>{if(!s._listeners)return;let r=s._listeners.length;for(;r-- >0;)s._listeners[r](n);s._listeners=null}),this.promise.then=n=>{let r;const i=new Promise(a=>{s.subscribe(a),r=a}).then(n);return i.cancel=function(){s.unsubscribe(r)},i},e(function(r,i,a){s.reason||(s.reason=new Lr(r,i,a),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=s=>{e.abort(s)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new qB(function(n){e=n}),cancel:e}}};function od(A){return function(t){return A.apply(null,t)}}function sd(A){return gA.isObject(A)&&A.isAxiosError===!0}const Ba={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ba).forEach(([A,e])=>{Ba[e]=A});function YB(A){const e=new fs(A),t=wB(fs.prototype.request,e);return gA.extend(t,fs.prototype,e,{allOwnKeys:!0}),gA.extend(t,e,null,{allOwnKeys:!0}),t.create=function(n){return YB(xs(A,n))},t}const ht=YB(Kr);ht.Axios=fs;ht.CanceledError=Lr;ht.CancelToken=td;ht.isCancel=KB;ht.VERSION=Qg;ht.toFormData=$n;ht.AxiosError=WA;ht.Cancel=ht.CanceledError;ht.all=function(e){return Promise.all(e)};ht.spread=od;ht.isAxiosError=sd;ht.mergeConfig=xs;ht.AxiosHeaders=Ao;ht.formToJSON=A=>RB(gA.isHTMLForm(A)?new FormData(A):A);ht.getAdapter=OB.getAdapter;ht.HttpStatusCode=Ba;ht.default=ht;const{Axios:dM,AxiosError:hM,CanceledError:pM,isCancel:fM,CancelToken:mM,VERSION:wM,all:xM,Cancel:DM,isAxiosError:yM,spread:NM,toFormData:kM,AxiosHeaders:MM,HttpStatusCode:bM,formToJSON:FM,getAdapter:vM,mergeConfig:GM,create:SM}=ht,rd=({onRequest:A,onSseError:e,onSseEvent:t,responseTransformer:s,responseValidator:n,sseDefaultRetryDelay:r,sseMaxRetryAttempts:i,sseMaxRetryDelay:a,sseSleepFn:g,url:Q,...B})=>{let u;const E=g??(f=>new Promise(d=>setTimeout(d,f)));return{stream:async function*(){let f=r??3e3,d=0;const D=B.signal??new AbortController().signal;for(;!D.aborted;){d++;const R=B.headers instanceof Headers?B.headers:new Headers(B.headers);u!==void 0&&R.set("Last-Event-ID",u);try{const M={redirect:"follow",...B,body:B.serializedBody,headers:R,signal:D};let q=new Request(Q,M);A&&(q=await A(Q,M));const T=await(B.fetch??globalThis.fetch)(q);if(!T.ok)throw new Error(`SSE failed: ${T.status} ${T.statusText}`);if(!T.body)throw new Error("No body in SSE response");const Z=T.body.pipeThrough(new TextDecoderStream).getReader();let X="";const U=()=>{try{Z.cancel()}catch{}};D.addEventListener("abort",U);try{for(;;){const{done:O,value:j}=await Z.read();if(O)break;X+=j;const Y=X.split(`
9
+ `+r)}}catch{}}throw s}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=xs(this.defaults,t);const{transitional:s,paramsSerializer:n,headers:r}=t;s!==void 0&&In.assertOptions(s,{silentJSONParsing:Eo.transitional(Eo.boolean),forcedJSONParsing:Eo.transitional(Eo.boolean),clarifyTimeoutError:Eo.transitional(Eo.boolean),legacyInterceptorReqResOrdering:Eo.transitional(Eo.boolean)},!1),n!=null&&(gA.isFunction(n)?t.paramsSerializer={serialize:n}:In.assertOptions(n,{encode:Eo.function,serialize:Eo.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),In.assertOptions(t,{baseUrl:Eo.spelling("baseURL"),withXsrfToken:Eo.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=r&&gA.merge(r.common,r[t.method]);r&&gA.forEach(["delete","get","head","post","put","patch","query","common"],h=>{delete r[h]}),t.headers=Ao.concat(i,r);const a=[];let g=!0;this.interceptors.request.forEach(function(f){if(typeof f.runWhen=="function"&&f.runWhen(t)===!1)return;g=g&&f.synchronous;const d=t.transitional||gg;d&&d.legacyInterceptorReqResOrdering?a.unshift(f.fulfilled,f.rejected):a.push(f.fulfilled,f.rejected)});const Q=[];this.interceptors.response.forEach(function(f){Q.push(f.fulfilled,f.rejected)});let B,u=0,E;if(!g){const h=[dl.bind(this),void 0];for(h.unshift(...a),h.push(...Q),E=h.length,B=Promise.resolve(t);u<E;)B=B.then(h[u++],h[u++]);return B}E=a.length;let c=t;for(;u<E;){const h=a[u++],f=a[u++];try{c=h(c)}catch(d){f.call(this,d);break}}try{B=dl.call(this,c)}catch(h){return Promise.reject(h)}for(u=0,E=Q.length;u<E;)B=B.then(Q[u++],Q[u++]);return B}getUri(e){e=xs(this.defaults,e);const t=JB(e.baseURL,e.url,e.allowAbsoluteUrls);return UB(t,e.params,e.paramsSerializer)}};gA.forEach(["delete","get","head","options"],function(e){fs.prototype[e]=function(t,s){return this.request(xs(s||{},{method:e,url:t,data:(s||{}).data}))}});gA.forEach(["post","put","patch","query"],function(e){function t(s){return function(r,i,a){return this.request(xs(a||{},{method:e,headers:s?{"Content-Type":"multipart/form-data"}:{},url:r,data:i}))}}fs.prototype[e]=t(),e!=="query"&&(fs.prototype[e+"Form"]=t(!0))});let td=class qB{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(r){t=r});const s=this;this.promise.then(n=>{if(!s._listeners)return;let r=s._listeners.length;for(;r-- >0;)s._listeners[r](n);s._listeners=null}),this.promise.then=n=>{let r;const i=new Promise(a=>{s.subscribe(a),r=a}).then(n);return i.cancel=function(){s.unsubscribe(r)},i},e(function(r,i,a){s.reason||(s.reason=new Lr(r,i,a),t(s.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=s=>{e.abort(s)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new qB(function(n){e=n}),cancel:e}}};function od(A){return function(t){return A.apply(null,t)}}function sd(A){return gA.isObject(A)&&A.isAxiosError===!0}const Ba={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ba).forEach(([A,e])=>{Ba[e]=A});function YB(A){const e=new fs(A),t=wB(fs.prototype.request,e);return gA.extend(t,fs.prototype,e,{allOwnKeys:!0}),gA.extend(t,e,null,{allOwnKeys:!0}),t.create=function(n){return YB(xs(A,n))},t}const ht=YB(Kr);ht.Axios=fs;ht.CanceledError=Lr;ht.CancelToken=td;ht.isCancel=KB;ht.VERSION=Qg;ht.toFormData=$n;ht.AxiosError=WA;ht.Cancel=ht.CanceledError;ht.all=function(e){return Promise.all(e)};ht.spread=od;ht.isAxiosError=sd;ht.mergeConfig=xs;ht.AxiosHeaders=Ao;ht.formToJSON=A=>RB(gA.isHTMLForm(A)?new FormData(A):A);ht.getAdapter=OB.getAdapter;ht.HttpStatusCode=Ba;ht.default=ht;const{Axios:IM,AxiosError:dM,CanceledError:hM,isCancel:pM,CancelToken:fM,VERSION:mM,all:wM,Cancel:xM,isAxiosError:DM,spread:yM,toFormData:NM,AxiosHeaders:kM,HttpStatusCode:MM,formToJSON:bM,getAdapter:FM,mergeConfig:vM,create:GM}=ht,rd=({onRequest:A,onSseError:e,onSseEvent:t,responseTransformer:s,responseValidator:n,sseDefaultRetryDelay:r,sseMaxRetryAttempts:i,sseMaxRetryDelay:a,sseSleepFn:g,url:Q,...B})=>{let u;const E=g??(f=>new Promise(d=>setTimeout(d,f)));return{stream:async function*(){let f=r??3e3,d=0;const D=B.signal??new AbortController().signal;for(;!D.aborted;){d++;const R=B.headers instanceof Headers?B.headers:new Headers(B.headers);u!==void 0&&R.set("Last-Event-ID",u);try{const M={redirect:"follow",...B,body:B.serializedBody,headers:R,signal:D};let q=new Request(Q,M);A&&(q=await A(Q,M));const T=await(B.fetch??globalThis.fetch)(q);if(!T.ok)throw new Error(`SSE failed: ${T.status} ${T.statusText}`);if(!T.body)throw new Error("No body in SSE response");const Z=T.body.pipeThrough(new TextDecoderStream).getReader();let X="";const U=()=>{try{Z.cancel()}catch{}};D.addEventListener("abort",U);try{for(;;){const{done:O,value:j}=await Z.read();if(O)break;X+=j;const Y=X.split(`
10
10
 
11
11
  `);X=Y.pop()??"";for(const x of Y){const l=x.split(`
12
12
  `),I=[];let y;for(const H of l)if(H.startsWith("data:"))I.push(H.replace(/^data:\s*/,""));else if(H.startsWith("event:"))y=H.replace(/^event:\s*/,"");else if(H.startsWith("id:"))u=H.replace(/^id:\s*/,"");else if(H.startsWith("retry:")){const v=Number.parseInt(H.replace(/^retry:\s*/,""),10);Number.isNaN(v)||(f=v)}let b,J=!1;if(I.length){const H=I.join(`
@@ -116,7 +116,7 @@ ${d.url}`).join(`
116
116
  `).map(t=>t.trim()).find(Boolean)||A.trim()}function vw(A){return A.replace(/^Reasoning:\s*/i,"").replace(/^[-*+]\s+/,"").replace(/\[(.*?)\]\((.*?)\)/g,"$1").replace(/[*_`#>~]+/g,"").replace(/\s+/g," ").trim()}function Mo(A,...e){for(const t of e){const s=A[t];if(typeof s=="string"&&s.trim())return s.trim()}}function Gw(A){return A.type==="reasoning"?!0:A.type!=="tool_call"&&A.type!=="tool_result"?!1:!!(A.toolName&&Lc.has(A.toolName))}function Sw(A){if(A.type==="reasoning"){const s=bw(A),n=vw(Fw(s));return{id:A.id,label:n?Bs(n):"Thinking through the approach",toolName:"reasoning",fullText:s||void 0,startedAt:A.startedAt,completedAt:A.completedAt}}if(!A.toolName||!Lc.has(A.toolName))return null;const e=kw(A),t=Mw(A);if(A.toolName==="read"){const s=Mo(t,"path")||Mo(e,"path");return{id:A.id,toolName:A.toolName,path:s,label:s?`Reading ${Bs(s)}`:"Reading file contents",startedAt:A.startedAt,completedAt:A.completedAt}}if(A.toolName==="ls"||A.toolName==="tree"){const s=Mo(e,"path")||Mo(t,"path");return{id:A.id,toolName:A.toolName,path:s,label:s?`Scanning ${Bs(s)}`:"Scanning the project",startedAt:A.startedAt,completedAt:A.completedAt}}if(A.toolName==="ripgrep"||A.toolName==="grep"||A.toolName==="glob"){const s=Mo(e,"query","pattern","filePattern")||Mo(t,"query","pattern");return{id:A.id,toolName:A.toolName,query:s,label:s?`Searching for ${Bs(s,42)}`:"Searching code",startedAt:A.startedAt,completedAt:A.completedAt}}if(A.toolName==="websearch"){const s=Mo(e,"query"),n=Mo(e,"url")||Mo(t,"url");return{id:A.id,toolName:A.toolName,query:s,url:n,label:s?`Researching ${Bs(s,42)}`:n?`Reviewing ${Bs(n,42)}`:"Researching references",startedAt:A.startedAt,completedAt:A.completedAt}}if(A.toolName==="skill"){const s=Mo(e,"name");return{id:A.id,toolName:A.toolName,label:s?`Loading skill ${Bs(s,36)}`:"Loading a skill",startedAt:A.startedAt,completedAt:A.completedAt}}return{id:A.id,toolName:A.toolName,label:"Reviewing prior context",startedAt:A.startedAt,completedAt:A.completedAt}}function Uw(A){const e=new Map;for(const s of A)s.type==="tool_result"&&s.toolCallId&&e.set(s.toolCallId,s);const t=[];for(const s of A){if(s.type==="tool_call"&&s.toolCallId&&e.has(s.toolCallId))continue;const n=Sw(s);n&&t.push(n)}return t}function Rw(A){const e=new Set;for(const t of A)t.path&&e.add(t.path);return e}function Kw(A){let e=null,t=null;for(const s of A){const n=s.startedAt??null,r=s.completedAt??s.startedAt??null;n!==null&&(e===null||n<e)&&(e=n),r!==null&&(t===null||r>t)&&(t=r)}return e!==null&&t!==null&&t>e?t-e:null}function Lw(A){const e=Math.round(A/1e3);if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return s>0?`${t}m ${s}s`:`${t}m`}function Jw(A){const e=Rw(A);let t=0,s=0,n=0,r=0,i=0;for(const c of A)switch(c.toolName){case"reasoning":r+=1;break;case"read":break;case"ls":case"tree":s+=1;break;case"ripgrep":case"grep":case"glob":t+=1;break;case"websearch":n+=1;break;case"skill":case"query_sessions":case"query_messages":case"search_history":case"get_session_context":case"get_parent_session":i+=1;break}const a=e.size>0||s>0,g=Kw(A),Q=g!==null?Lw(g):null,B=r>0&&e.size===0&&t===0&&s===0&&n===0&&i===0,u=B?Q?`Thought for ${Q}`:"Thought through the approach":n>0?a||t>0?"Researched and reviewed the project":"Researched references":i>0&&t>0?"Reviewed context and searched code":a&&t>0?"Reviewed files and searched code":s>0?"Explored project structure":e.size>0?"Reviewed project files":i>0?"Reviewed prior context":"Thought through the approach",E=[];return!B&&Q&&E.push(Q),e.size>0&&E.push(`${e.size} ${e.size===1?"file":"files"}`),t>0&&E.push(`${t} ${t===1?"search":"searches"}`),s>0&&e.size===0&&E.push(`${s} ${s===1?"scan":"scans"}`),n>0&&E.push(`${n} ${n===1?"web lookup":"web lookups"}`),i>0&&u!=="Reviewed prior context"&&E.push("prior context"),r>0&&!B&&E.push("reasoning"),E.length===0&&r===0&&E.push(`${A.length} ${A.length===1?"step":"steps"}`),{title:u,details:E}}const bo=320,Fo="cubic-bezier(0.25, 1, 0.5, 1)",Wl=140;function Tw({entries:A,titleOverride:e,showLine:t,collapsed:s,compact:n}){const r=kg(),i=!!(n||r),a=s&&A.length>0,[g,Q]=m.useState(a),[B,u]=m.useState(a),E=m.useRef(null),c=m.useRef(null),h=m.useRef(null),f=m.useRef(!1),d=m.useRef(A.length),[D,R]=m.useState(0),M=m.useMemo(()=>Jw(A),[A]),G=[e||M.title,...M.details].join(" · "),T=A.some(U=>U.toolName==="reasoning"),Z=A.length>0?A[A.length-1]:null;m.useEffect(()=>{if(!s&&!B){Q(!1);return}if(!B&&s&&u(!0),g||A.length===0)return;const U=window.setTimeout(()=>Q(!0),500);return()=>window.clearTimeout(U)},[s,g,B,A.length]),m.useLayoutEffect(()=>{if(g)return;const U=E.current;if(!U)return;const O=()=>{const Y=Math.min(U.scrollHeight,Wl);R(x=>x===Y?x:Y)};O();const j=new ResizeObserver(()=>O());return j.observe(U),()=>j.disconnect()},[g]),m.useEffect(()=>()=>{h.current!==null&&window.cancelAnimationFrame(h.current)},[]),m.useEffect(()=>{if(g||f.current)return;const U=c.current;if(!U)return;const O=E.current?.scrollHeight??0,j=O>D+1,Y=j?Math.max(0,O-D):0;if(h.current!==null&&(window.cancelAnimationFrame(h.current),h.current=null),!j){U.scrollTop=0;return}const x=U.scrollTop,l=Y-x;if(l<=1){U.scrollTop=Y;return}const I=performance.now(),y=Math.min(360,Math.max(180,l*.9)),b=J=>{const H=Math.min(1,(J-I)/y),v=1-(1-H)**3;if(U.scrollTop=x+l*v,H<1&&!f.current){h.current=window.requestAnimationFrame(b);return}h.current=null};h.current=window.requestAnimationFrame(b)},[A.length,Z?.fullText,g,D]),m.useEffect(()=>{d.current=A.length},[A.length]);const X=!g;return o.jsxs("div",{className:`flex ${i?"gap-1.5":"gap-3"} pb-2 relative max-w-full overflow-hidden`,children:[o.jsxs("div",{className:`flex-shrink-0 ${i?"w-4":"w-6"} flex items-start justify-center relative pt-0.5`,children:[o.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative bg-background",children:T?o.jsx(Pn,{className:"h-4 w-4 text-indigo-600 dark:text-indigo-300"}):o.jsx($o,{className:"h-4 w-4 text-amber-600 dark:text-amber-300"})}),t&&o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] bg-border z-0",style:{top:"1.25rem",bottom:"-0.5rem"}})]}),o.jsx("div",{className:"flex-1 min-w-0 pt-0.5",children:o.jsxs("div",{className:"relative rounded-lg overflow-hidden",style:{border:X?"1px solid hsl(var(--border) / 0.6)":"1px solid transparent",background:X?"hsl(var(--muted) / 0.2)":"transparent",padding:X?i?"6px 8px":"8px 12px":"0px 0px",transition:`border ${bo}ms ${Fo}, background ${bo}ms ${Fo}, padding ${bo}ms ${Fo}`},children:[o.jsxs("div",{style:{overflow:"hidden",opacity:X?1:0,maxHeight:X?`${Wl+28}px`:"0px",transition:`opacity ${bo}ms ${Fo}, max-height ${bo}ms ${Fo}`},children:[o.jsx("div",{className:"text-[12px] font-medium uppercase tracking-[0.18em] text-muted-foreground/70 mb-1",children:"Exploring"}),o.jsx("div",{ref:c,className:"overflow-y-auto",style:{height:`${D}px`,transition:`height ${bo}ms ${Fo}`,maskImage:"linear-gradient(to bottom, transparent 0px, black 20px)",WebkitMaskImage:"linear-gradient(to bottom, transparent 0px, black 20px)"},role:"log",onMouseEnter:()=>{f.current=!0},onMouseLeave:()=>{f.current=!1},children:o.jsx("div",{ref:E,className:"pt-2.5",children:A.map((U,O)=>{const j=O===A.length-1,Y=O>=d.current;return U.toolName==="reasoning"&&U.fullText&&U.fullText.trim()?o.jsx("div",{className:"px-1 py-0.5",style:{animation:Y?`ottoEntryIn ${bo}ms ${Fo} both`:void 0},children:o.jsx("p",{className:`text-[12px] leading-relaxed font-mono whitespace-pre-wrap ${j?"text-foreground/80":"text-muted-foreground/60"}`,children:U.fullText})},U.id):o.jsx("div",{className:`flex items-center px-1 ${i?"text-[13px] h-6":"text-[15px] h-7"} leading-5 ${j?"text-foreground":"text-muted-foreground/70"}`,style:{animation:Y?`ottoEntryIn ${bo}ms ${Fo} both`:void 0},children:o.jsx("span",{className:"block min-w-0 truncate",children:U.label})},U.id)})})})]}),o.jsx("div",{className:`flex items-center ${i?"text-[12px]":"text-xs"}`,style:{opacity:g?1:0,height:g?"20px":"0px",overflow:"hidden",transition:`opacity ${bo}ms ${Fo}, height ${bo}ms ${Fo}`},children:o.jsx("span",{className:"block min-w-0 truncate leading-none text-foreground",title:G,children:G})})]})}),o.jsx("style",{children:"@keyframes ottoEntryIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }"})]})}const jo=320,Oo="cubic-bezier(0.25, 1, 0.5, 1)",zl=140;function bg(A){if(A.contentJson&&typeof A.contentJson=="object")return A.contentJson;try{if(A.content){const e=JSON.parse(A.content);if(e&&typeof e=="object"&&!Array.isArray(e))return e}}catch{}return{}}function jw(A){const e=bg(A);return typeof e._streamedInput=="string"?e._streamedInput:""}function Ow(A){const e=bg(A);return typeof e._streamedOutput=="string"?e._streamedOutput:""}function qw(A){const t=bg(A)?.args;if(t&&typeof t=="object"&&!Array.isArray(t))return t}function Yw(A){return A.match(/^\*\*\*\s+(?:Update|Add|Delete|Replace in):\s+(.+)$/m)?.[1]?.trim()||null}const Hw={shell:{Icon:ao,color:"text-muted-foreground",label:"Running"},bash:{Icon:ao,color:"text-muted-foreground",label:"Running"},write:{Icon:So,color:"text-emerald-600 dark:text-emerald-300",label:"Writing"},apply_patch:{Icon:ia,color:"text-purple-600 dark:text-purple-300",label:"Patching"},edit:{Icon:So,color:"text-purple-600 dark:text-purple-300",label:"Editing"},multiedit:{Icon:So,color:"text-purple-600 dark:text-purple-300",label:"Editing"},copy_into:{Icon:So,color:"text-purple-600 dark:text-purple-300",label:"Copying"},terminal:{Icon:ao,color:"text-amber-600 dark:text-amber-300",label:"Terminal"}};function Jc(A){return A==="bash"?"shell":A}function qr(A){return Jc(A)==="shell"}function Pw(A,e){if(!e)return"";if(qr(A)){const t=String(e.cmd||"");return t.length>80?`${t.slice(0,77)}…`:t}if(A==="write"||A==="edit"||A==="multiedit")return String(e.path||"");if(A==="copy_into")return String(e.targetPath||"");if(A==="apply_patch"){const t=String(e.patch||"");return Yw(t)||""}return""}function Ww(A,e){if(qr(A)){const t=Wo(e,"cmd");if(t)return t.length>80?`${t.slice(0,77)}…`:t}if(A==="write")return Wo(e,"path")||Wo(e,"filePath");if(A==="edit"||A==="multiedit")return Wo(e,"path");if(A==="copy_into")return Wo(e,"targetPath");if(A==="apply_patch"){const t=e.match(/\*\*\*\s+(?:Update|Add|Delete|Replace in):\s+(.+?)(?:\\n|")/);return t?t[1].trim():""}return""}function zw(A){try{if(A.contentJson&&typeof A.contentJson=="object")return A.contentJson;if(typeof A.content=="string")return JSON.parse(A.content)}catch{}return{}}function Vw({part:A,showLine:e,compact:t}){const s=kg(),n=!!(t||s),r=m.useRef(null),i=m.useRef(null),a=m.useRef(null),g=m.useRef(!1),Q=m.useRef(0),[B,u]=m.useState(0),E=Jc(A.toolName||""),c=A.type==="tool_result",h=Hw[E]||{Icon:ao,color:"text-muted-foreground",label:E.replace(/_/g," ")},[f,d]=m.useState(()=>c),[D,R]=m.useState(()=>c),M=qw(A),q=jw(A),G=Ow(A),T=Pw(E,M)||Ww(E,q),Z=_w(E,q),X=qr(E)?G||Z||(M?Vl(E,M):""):M?Vl(E,M):Z,U=X.trim().length>0;m.useEffect(()=>{if(!c&&!D){d(!1);return}if(!D&&c&&R(!0),f||!c)return;const Y=window.setTimeout(()=>d(!0),500);return()=>window.clearTimeout(Y)},[c,f,D]),m.useLayoutEffect(()=>{if(!U){u(0);return}const Y=r.current;if(!Y||Y.textContent!==X)return;const x=Math.min(Y.scrollHeight,zl-12);u(l=>l===x?l:x)},[X,U]),m.useEffect(()=>()=>{a.current!==null&&window.cancelAnimationFrame(a.current)},[]),m.useEffect(()=>{const Y=i.current;if(!Y||g.current)return;const x=X.length,l=r.current?.scrollHeight??0,I=l>B+1,y=I?Math.max(0,l-B):0;if(a.current!==null&&(window.cancelAnimationFrame(a.current),a.current=null),!I){Y.scrollTop=0,Q.current=x;return}if(x<=Q.current){Y.scrollTop=y,Q.current=x;return}const b=Y.scrollTop,J=y-b;if(J<=1){Y.scrollTop=y,Q.current=x;return}const H=performance.now(),v=Math.min(360,Math.max(180,J*.9)),K=C=>{const p=Math.min(1,(C-H)/v),L=1-(1-p)**3;if(Y.scrollTop=b+J*L,p<1&&!g.current){a.current=window.requestAnimationFrame(K);return}a.current=null};a.current=window.requestAnimationFrame(K),Q.current=x},[X,B]);const O=!f,j=c?zw(A):null;return o.jsxs("div",{className:`flex ${n?"gap-1.5":"gap-3"} pb-2 relative max-w-full overflow-hidden`,children:[o.jsxs("div",{className:`flex-shrink-0 ${n?"w-4":"w-6"} flex items-start justify-center relative pt-0.5`,children:[o.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative bg-background",children:o.jsx(h.Icon,{className:`h-4 w-4 ${h.color}`})}),e&&o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 w-[2px] bg-border z-0",style:{top:"1.25rem",bottom:"-0.5rem"}})]}),o.jsx("div",{className:"flex-1 min-w-0 pt-0.5",children:o.jsxs("div",{className:"relative rounded-lg overflow-hidden",style:{border:O?"1px solid hsl(var(--border) / 0.6)":"1px solid transparent",background:O?"hsl(var(--muted) / 0.2)":"transparent",padding:O?n?"6px 8px":"8px 12px":"0px 0px",transition:`border ${jo}ms ${Oo}, background ${jo}ms ${Oo}, padding ${jo}ms ${Oo}`},children:[o.jsxs("div",{style:{overflow:"hidden",opacity:O?1:0,maxHeight:O?`${zl+28}px`:"0px",transition:`opacity ${jo}ms ${Oo}, max-height ${jo}ms ${Oo}`},children:[o.jsxs("div",{className:`flex items-center gap-2 ${n?"text-[13px]":"text-[14px]"} font-medium uppercase tracking-[0.18em] text-muted-foreground/70`,children:[o.jsx(Te,{className:"h-3 w-3 animate-spin flex-shrink-0"}),o.jsx("span",{className:"flex-shrink-0",children:h.label}),T&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/40 flex-shrink-0",children:"·"}),o.jsx("span",{className:"truncate text-foreground/60 lowercase tracking-normal font-normal font-mono",children:T})]}),!M&&!Z&&!G&&o.jsx("span",{className:"text-muted-foreground/50 animate-pulse lowercase tracking-normal font-normal",children:"generating…"})]}),o.jsx("div",{style:{overflow:"hidden",opacity:U?1:0,height:U?`${B+6}px`:"0px",transition:`opacity ${jo}ms ${Oo}, height ${jo}ms ${Oo}`},children:X&&o.jsx("div",{className:"pt-1.5",children:o.jsx("section",{ref:i,className:"overflow-y-auto","aria-label":`${h.label} content`,style:{height:`${B}px`,maskImage:"linear-gradient(to bottom, transparent 0px, black 20px)",WebkitMaskImage:"linear-gradient(to bottom, transparent 0px, black 20px)"},onMouseEnter:()=>{g.current=!0},onMouseLeave:()=>{g.current=!1},children:o.jsx("pre",{ref:r,className:"px-1 pt-2.5 pb-1 text-[12px] leading-relaxed text-foreground/60 font-mono whitespace-pre-wrap break-all",children:X})})})})]}),o.jsx("div",{className:"min-w-0 text-xs",style:{opacity:f?1:0,maxHeight:f?"1200px":"0px",overflow:"hidden",transition:`opacity ${jo}ms ${Oo}, max-height ${jo}ms ${Oo}`},children:j?o.jsx("div",{className:"min-w-0",children:o.jsx(Ma,{toolName:E,contentJson:j,toolDurationMs:A.toolDurationMs??void 0,debug:!1,compact:!1})}):o.jsx("div",{className:"flex min-w-0 items-center",children:o.jsx("span",{className:"block min-w-0 truncate leading-5 text-foreground",title:T||h.label,children:T?`${h.label} · ${T}`:h.label})})})]})})]})}function Vl(A,e){return qr(A)?String(e.cmd||""):A==="write"?String(e.content||""):A==="apply_patch"?String(e.patch||""):A==="edit"?String(e.oldString||""):""}function Wo(A,e){const s=new RegExp(`"${e}"\\s*:\\s*"`).exec(A);if(!s)return"";const n=s.index+s[0].length;let r="",i=n;for(;i<A.length;)if(A[i]==="\\"&&i+1<A.length){const a=A[i+1];a==="n"?r+=`
117
117
  `:a==="t"?r+=" ":a==='"'?r+='"':a==="\\"?r+="\\":r+=a,i+=2}else{if(A[i]==='"')break;r+=A[i],i+=1}return r}function _w(A,e){return e?qr(A)?Wo(e,"cmd"):A==="write"?Wo(e,"content"):A==="apply_patch"?Wo(e,"patch"):A==="edit"?Wo(e,"oldString"):"":""}function Zw(A){const e=De();return We({mutationFn:t=>{if(!A)throw new Error("No session ID");return fA.createBranch(A,t)},onSuccess:()=>{e.invalidateQueries({queryKey:lo}),A&&e.invalidateQueries({queryKey:["branches",A]})}})}function Tc(A){return at({queryKey:["parentSession",A],queryFn:()=>{if(!A)throw new Error("No session ID");return fA.getParentSession(A)},enabled:!!A})}function Xw({isOpen:A,onClose:e,sessionId:t,message:s,onBranchCreated:n}){const r=mg(t),i=Zw(t),[a,g]=m.useState(""),[Q,B]=m.useState(!0),u=m.useId(),E=m.useId(),c=s.parts?.find(d=>d.type==="text")?.content||"",h=(()=>{try{return JSON.parse(c)?.text?.slice(0,100)||""}catch{return c.slice(0,100)}})(),f=async d=>{d.preventDefault();try{const D=await i.mutateAsync({fromMessageId:s.id,title:a.trim()||void 0,provider:Q?r?.provider:void 0,model:Q?r?.model:void 0,agent:Q?r?.agent:void 0});e(),n&&D.session&&n(D.session.id)}catch(D){console.error("Failed to create branch:",D)}};return o.jsx(Lo,{isOpen:A,onClose:e,title:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Qo,{className:"h-5 w-5 text-primary"}),o.jsx("span",{children:"Branch Session"})]}),maxWidth:"md",children:o.jsxs("form",{onSubmit:f,className:"space-y-4",children:[o.jsxs("div",{className:"text-sm text-muted-foreground",children:[o.jsx("p",{children:"Creating branch from message:"}),o.jsxs("p",{className:"mt-1 p-2 bg-muted/50 rounded text-foreground italic truncate",children:['"',h,'..."']})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:u,className:"block text-sm font-medium text-foreground",children:"Branch Title (optional)"}),o.jsx("input",{id:u,type:"text",value:a,onChange:d=>g(d.target.value),placeholder:`Branch of ${r?.title||"Untitled"}`,className:"w-full px-3 py-2 bg-background border border-border rounded-md text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary/50"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{id:E,type:"checkbox",checked:Q,onChange:d=>B(d.target.checked),className:"h-4 w-4 rounded border-border text-primary focus:ring-primary/50"}),o.jsx("label",{htmlFor:E,className:"text-sm text-foreground",children:"Use same provider/model/agent as parent"})]}),r&&o.jsx("div",{className:"text-xs text-muted-foreground bg-muted/30 rounded p-2",children:o.jsxs("div",{className:"flex gap-4",children:[o.jsxs("span",{children:[o.jsx("strong",{children:"Provider:"})," ",r.provider]}),o.jsxs("span",{children:[o.jsx("strong",{children:"Model:"})," ",r.model]}),o.jsxs("span",{children:[o.jsx("strong",{children:"Agent:"})," ",r.agent]})]})}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o.jsx("button",{type:"button",onClick:e,className:"px-4 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors",children:"Cancel"}),o.jsx("button",{type:"submit",disabled:i.isPending,className:"px-4 py-2 text-sm bg-primary text-primary-foreground rounded-md hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:i.isPending?o.jsxs(o.Fragment,{children:[o.jsx(Te,{className:"h-4 w-4 animate-spin"}),"Creating..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Qo,{className:"h-4 w-4"}),"Create Branch"]})})]}),i.isError&&o.jsx("p",{className:"text-sm text-red-500",children:i.error?.message||"Failed to create branch"})]})})}const _l=["Generating...","Cooking up something...","Thinking...","Processing...","Working on it...","Crafting response...","Brewing magic...","Computing..."];function $w(A){const e=A.split("").reduce((t,s)=>t+s.charCodeAt(0),0);return _l[e%_l.length]}const jc=m.memo(function({sessionId:e,message:t,showHeader:s,hasNextAssistantMessage:n,onBranchCreated:r,compact:i,showBranchButton:a=!0,onNavigateToSession:g,onRetry:Q,onCompact:B}){const{isQueued:u}=hc(e,t.id),[E,c]=m.useState(!1),[h,f]=m.useState(!1),[d,D]=m.useState(!1),{pendingApprovals:R,removePendingApproval:M}=Jr(),q=m.useCallback(async C=>{if(e)try{await fA.approveToolCall(e,C,!0),M(C)}catch(p){console.error("Failed to approve tool call:",p)}},[e,M]),G=m.useCallback(async C=>{if(e)try{await fA.approveToolCall(e,C,!1),M(C)}catch(p){console.error("Failed to reject tool call:",p)}},[e,M]),T=m.useMemo(()=>R.filter(C=>C.messageId===t.id),[R,t.id]),Z=m.useCallback(async()=>{if(e)try{await Promise.all(T.map(C=>fA.approveToolCall(e,C.callId,!0)));for(const C of T)M(C.callId)}catch(C){console.error("Failed to approve all tool calls:",C)}},[e,T,M]),X=m.useMemo(()=>[...t.parts||[]].sort((p,L)=>{const S=(p.index??0)-(L.index??0);if(S!==0)return S;const $=(p.stepIndex??0)-(L.stepIndex??0);return $!==0?$:(p.startedAt??0)-(L.startedAt??0)}),[t.parts]),U=X.some(C=>C.toolName==="finish"),O=X.reduce((C,p,L)=>p.type==="tool_result"&&p.toolName==="progress_update"?L:C,-1),j=O>=0?X[O]:null,Y=new Set(X.filter(C=>C.ephemeral&&["shell","bash","edit","multiedit","write","copy_into","apply_patch","terminal"].includes(C.toolName||"")).map(C=>C.toolCallId).filter(C=>!!C)),x=m.useMemo(()=>{const C=[];let p=[],L=-1,S;const $=AA=>{if(p.length===0){AA&&(S=AA);return}const sA=Uw(p);if(sA.length>0)C.push({kind:"group",id:`compact-${p[0].id}`,entries:sA,titleOverride:S});else for(const[oA,bA]of p.entries())C.push({kind:"part",index:L+oA,part:bA});p=[],L=-1,S=AA};for(const[AA,sA]of X.entries()){if((sA.type==="tool_result"||sA.type==="tool_call")&&sA.toolName==="progress_update"){let bA;const GA=sA.contentJson&&typeof sA.contentJson=="object"?sA.contentJson:null;if(GA){const lA=GA.args??GA.result;if(lA&&typeof lA=="object"){const jA=lA.message;typeof jA=="string"&&jA.trim()&&(bA=jA.trim())}}bA&&$(bA);continue}if(i&&Gw(sA)){p.length===0&&(L=AA),p.push(sA);continue}$(),C.push({kind:"part",index:AA,part:sA})}return $(),C},[X,i]),l=x.length>0,I=X.findIndex(C=>!(C.type==="tool_result"&&C.toolName==="progress_update")),y=t.status==="pending"&&!U&&!!j,b=t.status==="pending"&&!U&&!j&&!u,J=C=>C?new Date(C).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",H=t.status==="complete",v=m.useCallback(()=>{const C=X.filter(p=>p.type==="text").map(p=>{try{return JSON.parse(p.content||"{}")?.text||""}catch{return p.content||""}}).join(`
118
118
  `);navigator.clipboard.writeText(C),D(!0),setTimeout(()=>D(!1),2e3)},[X]),K=m.useCallback(()=>{f(!0)},[]);return u?null:o.jsxs("div",{className:"relative group",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[s&&o.jsxs("div",{className:"pb-2 flex items-center justify-between",children:[o.jsxs("div",{className:"inline-flex items-center bg-violet-500/10 border border-violet-500/30 dark:bg-violet-500/5 dark:border-violet-500/20 rounded-full pr-3 md:pr-4 flex-shrink min-w-0",children:[o.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-violet-500/50 bg-violet-500/20 dark:bg-violet-500/10",children:o.jsx(Zt,{className:"h-3.5 w-3.5 text-violet-700 dark:text-violet-300"})}),o.jsxs("div",{className:"flex items-center gap-x-1.5 md:gap-x-2 text-xs md:text-sm text-muted-foreground pl-2 md:pl-3 min-w-0",children:[t.agent&&o.jsx("span",{className:"font-medium text-violet-700 dark:text-violet-300 whitespace-nowrap",title:t.agent,children:t.agent}),t.provider&&o.jsxs(o.Fragment,{children:[t.agent&&o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx(ro,{provider:t.provider,size:14,className:"opacity-70"})]}),t.model&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"hidden md:inline text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"hidden md:inline text-muted-foreground whitespace-nowrap",title:t.model,children:t.model})]}),t.createdAt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:J(t.createdAt)})]})]})]}),E&&H&&e&&a&&o.jsx("button",{type:"button",onClick:K,className:"ml-4 p-1.5 text-muted-foreground hover:text-primary transition-colors flex-shrink-0",title:"Branch from this message",children:o.jsx(Qo,{className:"h-4 w-4"})})]}),o.jsxs("div",{className:"relative ml-1",children:[x.map((C,p)=>{const L=p<x.length-1||n||y;if(C.kind==="group")return o.jsx(Tw,{entries:C.entries,titleOverride:C.titleOverride,showLine:L,collapsed:t.status!=="pending"||p<x.length-1,compact:i},C.id);const{part:S,index:$}=C,AA=$===X.length-1;if(S.ephemeral&&(S.type==="tool_call"||S.type==="tool_result")&&["shell","bash","edit","multiedit","write","copy_into","apply_patch","terminal"].includes(S.toolName||""))return o.jsx(Vw,{part:S,showLine:L,compact:i},S.id);const oA=S.type==="tool_call"&&S.toolCallId?R.find(jA=>jA.callId===S.toolCallId)??null:null;if(S.type==="tool_result"&&S.toolCallId&&Y.has(S.toolCallId))return null;const bA=S.type==="tool_result"&&S.toolName==="finish",GA=L&&!bA,lA=S.type==="tool_call"&&AA;return o.jsx(Pl,{part:S,showLine:GA,isFirstPart:$===I&&!s,isLastToolCall:lA,onNavigateToSession:g,compact:i,pendingApproval:oA,onApprove:q,onReject:G,sessionId:e,onRetry:Q,onCompact:B},S.id)}),T.length>1&&o.jsxs("div",{className:"flex items-center gap-3 py-2 px-3 my-2 bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg",children:[o.jsx($a,{className:"h-4 w-4 text-amber-600 dark:text-amber-400 flex-shrink-0"}),o.jsxs("span",{className:"text-sm text-amber-800 dark:text-amber-200 flex-1",children:[T.length," tools waiting for approval"]}),o.jsxs("button",{type:"button",onClick:Z,title:"Approve All (A)",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded bg-amber-600 text-white hover:bg-amber-700 transition-colors",children:[o.jsx(QB,{className:"w-3.5 h-3.5"}),"Approve All",o.jsx("kbd",{className:"ml-1 text-[10px] opacity-70",children:"A"})]})]}),y&&j&&o.jsx(Pl,{part:j,showLine:n,isFirstPart:!l&&!s,isLastProgressUpdate:!0,compact:i},j.id),b&&o.jsxs("div",{className:"flex gap-3 pb-2 relative",children:[o.jsx("div",{className:"flex-shrink-0 w-6 flex items-start justify-center relative pt-0.5",children:o.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full relative bg-card text-violet-700 dark:bg-background dark:text-violet-300",children:o.jsx(Zt,{className:"h-4 w-4"})})}),o.jsx("div",{className:"flex-1 pt-0.5",children:o.jsx("div",{className:"text-base text-foreground animate-pulse",children:$w(t.id)})})]})]}),H&&e&&o.jsx("div",{className:"grid ml-7 transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:E?"1fr":"0fr"},children:o.jsx("div",{className:"overflow-hidden",children:o.jsxs("div",{className:"flex gap-2 mt-2",children:[a&&o.jsxs("button",{type:"button",onClick:K,className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 rounded transition-colors",children:[o.jsx(Qo,{className:"h-3 w-3"}),"Branch"]}),o.jsx("button",{type:"button",onClick:v,className:"flex items-center gap-1.5 px-2 py-1 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 rounded transition-colors",children:d?o.jsxs(o.Fragment,{children:[o.jsx(zt,{className:"h-3 w-3 text-green-500"}),"Copied"]}):o.jsxs(o.Fragment,{children:[o.jsx(ws,{className:"h-3 w-3"}),"Copy"]})})]})})}),h&&e&&o.jsx(Xw,{isOpen:h,onClose:()=>f(!1),sessionId:e,message:t,onBranchCreated:r})]})},(A,e)=>{const t=A.message.parts||[],s=e.message.parts||[];if(t.length!==s.length)return!1;for(let n=0;n<t.length;n++){const r=t[n],i=s[n];if(r.id!==i.id||r.index!==i.index||r.stepIndex!==i.stepIndex||r.type!==i.type||r.content!==i.content||r.toolName!==i.toolName||r.toolCallId!==i.toolCallId||r.ephemeral!==i.ephemeral||r.completedAt!==i.completedAt||r.startedAt!==i.startedAt)return!1}return A.message.id===e.message.id&&A.message.status===e.message.status&&A.message.completedAt===e.message.completedAt&&A.showHeader===e.showHeader&&A.hasNextAssistantMessage===e.hasNextAssistantMessage&&A.isLastMessage===e.isLastMessage&&A.sessionId===e.sessionId&&A.compact===e.compact&&A.onNavigateToSession===e.onNavigateToSession}),Oc=m.memo(function({sessionId:e,message:t,nextAssistantMessageId:s}){const[n,r]=m.useState(null),i=t.parts||[],a=De(),{isQueued:g,position:Q}=hc(e,s??""),B=vn(j=>j.setPendingRestoreText),u=i.filter(j=>j.type==="text"),E=i.filter(j=>j.type==="image"),c=i.filter(j=>j.type==="file"),h=u[0];let f="";if(h){const j=h.contentJson||h.content;j&&typeof j=="object"&&"text"in j?f=String(j.text):typeof j=="string"?f=j:j&&(f=JSON.stringify(j,null,2))}const{researchContexts:d,cleanContent:D}=wm(f),R=[];for(const j of E)try{const Y=j.contentJson||JSON.parse(j.content||"{}");if(Y&&typeof Y=="object"&&"data"in Y){const x=Y,l=`data:${x.mediaType};base64,${x.data}`;R.push({id:j.id,src:l})}}catch{}const M=[];for(const j of c)try{const Y=j.contentJson||JSON.parse(j.content||"{}");if(Y&&typeof Y=="object"&&"type"in Y){const x=Y;if(x.type==="image"&&x.data){const l=`data:${x.mediaType};base64,${x.data}`;R.push({id:j.id,src:l})}else M.push({id:j.id,type:x.type,name:x.name})}}catch{}const q=j=>j?new Date(j).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",G=D.trim().length>0,T=R.length>0,Z=M.length>0,X=d.length>0;if(!G&&!T&&!Z&&!X||g)return null;const U=async()=>{if(!(!e||!s)){B(D);try{await fA.removeFromQueue(e,s),a.invalidateQueries({queryKey:["messages",e]})}catch(j){console.error("Failed to cancel queued message:",j)}}},O=async()=>{if(!(!e||!s))try{await fA.removeFromQueue(e,s),a.invalidateQueries({queryKey:["messages",e]})}catch(j){console.error("Failed to delete queued message:",j)}};return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative pb-8 pt-6",children:o.jsxs("div",{className:"flex flex-col items-end min-w-0 w-full",children:[o.jsxs("div",{className:"inline-flex items-center bg-emerald-500/10 border border-emerald-500/30 dark:bg-emerald-500/5 dark:border-emerald-500/20 rounded-full pl-3 md:pl-4 flex-shrink min-w-0 mb-2",children:[o.jsxs("div",{className:"flex items-center gap-x-1.5 md:gap-x-2 text-xs md:text-sm text-muted-foreground pr-2 md:pr-3 min-w-0",children:[o.jsx("span",{className:"font-medium text-emerald-700 dark:text-emerald-300 whitespace-nowrap",children:"You"}),t.createdAt&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsx("span",{className:"text-muted-foreground whitespace-nowrap",children:q(t.createdAt)})]}),g&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground/50",children:"·"}),o.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600 dark:text-amber-400 whitespace-nowrap",children:[o.jsx(Wn,{className:"h-3 w-3"}),"Queued",Q!==null&&Q>0?` #${Q+1}`:""]})]})]}),o.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-emerald-500/50 bg-emerald-500/20 dark:bg-emerald-500/10",children:o.jsx(_a,{className:"h-3.5 w-3.5 text-emerald-700 dark:text-emerald-300"})})]}),o.jsxs("div",{className:"flex flex-col items-end min-w-0 max-w-full md:max-w-2xl",children:[o.jsxs("div",{className:"inline-block max-w-full text-[16.5px] text-foreground leading-relaxed bg-card/80 border border-border rounded-xl px-4 py-3 [word-break:break-word] overflow-hidden",children:[T&&o.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:R.map(j=>o.jsx("button",{type:"button",onClick:()=>r(j.src),className:"w-16 h-16 rounded-lg overflow-hidden bg-muted hover:ring-2 hover:ring-primary/50 transition-all",children:o.jsx("img",{src:j.src,alt:"Attachment",className:"w-full h-full object-cover"})},j.id))}),Z&&o.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:M.map(j=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-muted/50 border border-border",children:[j.type==="pdf"?o.jsx(_o,{className:"w-4 h-4 text-red-500 flex-shrink-0"}):o.jsx(Uo,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}),o.jsx("span",{className:"text-xs truncate max-w-[150px]",children:j.name})]},j.id))}),X&&o.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:d.map(j=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-teal-500/10 border border-teal-500/30",children:[o.jsx(xr,{className:"w-4 h-4 text-teal-500 flex-shrink-0"}),o.jsx("span",{className:"text-xs text-teal-600 dark:text-teal-400",children:j.label})]},j.id))}),G&&o.jsx("div",{className:"prose prose-invert prose-sm [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_p]:text-[16.5px] [&_li]:text-[16.5px] [&_*]:[word-break:break-word] [&_*]:overflow-wrap-anywhere whitespace-pre-wrap",children:o.jsx(rg,{remarkPlugins:[ng],components:{a:({href:j,children:Y,...x})=>o.jsx("a",{href:j,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline decoration-primary/35 underline-offset-2 transition-colors hover:text-primary/90 hover:decoration-primary",onClick:l=>{window.self!==window.top&&j&&(l.preventDefault(),window.parent.postMessage({type:"otto-open-url",url:j},"*"))},...x,children:Y})},children:D.replace(/\n/g,`
119
- `)})})]}),g&&o.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[o.jsxs("button",{type:"button",onClick:U,className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground transition-colors",title:"Cancel and restore to input",children:[o.jsx(eg,{className:"h-3 w-3"}),"Cancel"]}),o.jsxs("button",{type:"button",onClick:O,className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md bg-destructive/10 hover:bg-destructive/20 text-destructive transition-colors",title:"Delete from queue",children:[o.jsx(Ar,{className:"h-3 w-3"}),"Delete"]})]})]})]})}),n&&o.jsxs("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",onClick:()=>r(null),onKeyDown:j=>j.key==="Escape"&&r(null),tabIndex:-1,children:[o.jsx("button",{type:"button",onClick:()=>r(null),className:"absolute top-4 right-4 p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors",children:o.jsx(et,{className:"w-6 h-6 text-white"})}),o.jsx("img",{src:n,alt:"Expanded attachment",className:"max-w-full max-h-full object-contain rounded-lg",onClick:j=>j.stopPropagation(),onKeyDown:j=>j.key==="Enter"&&j.stopPropagation()})]})]})},(A,e)=>{const t=A.message.parts?.[0],s=e.message.parts?.[0];return A.message.id===e.message.id&&t?.content===s?.content&&t?.contentJson===s?.contentJson&&A.message.createdAt===e.message.createdAt&&A.message.parts?.length===e.message.parts?.length&&A.sessionId===e.sessionId&&A.nextAssistantMessageId===e.nextAssistantMessageId}),Ax={openai:{id:"openai",models:[{id:"chatgpt-image-latest",ownedBy:"openai",label:"chatgpt-image-latest",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-12-16",lastUpdated:"2025-12-16",openWeights:!1,limit:{context:0,output:0}},{id:"gpt-3.5-turbo",ownedBy:"openai",label:"GPT-3.5-turbo",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2021-09-01",releaseDate:"2023-03-01",lastUpdated:"2023-11-06",openWeights:!1,cost:{input:.5,output:1.5,cacheRead:1.25},limit:{context:16385,output:4096}},{id:"gpt-4",ownedBy:"openai",label:"GPT-4",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-11",releaseDate:"2023-11-06",lastUpdated:"2024-04-09",openWeights:!1,cost:{input:30,output:60},limit:{context:8192,output:8192}},{id:"gpt-4-turbo",ownedBy:"openai",label:"GPT-4 Turbo",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-12",releaseDate:"2023-11-06",lastUpdated:"2024-04-09",openWeights:!1,cost:{input:10,output:30},limit:{context:128e3,output:4096}},{id:"gpt-4.1",ownedBy:"openai",label:"GPT-4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:1047576,output:32768}},{id:"gpt-4.1-mini",ownedBy:"openai",label:"GPT-4.1 mini",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.4,output:1.6,cacheRead:.1},limit:{context:1047576,output:32768}},{id:"gpt-4.1-nano",ownedBy:"openai",label:"GPT-4.1 nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.03},limit:{context:1047576,output:32768}},{id:"gpt-4o",ownedBy:"openai",label:"GPT-4o",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-05-13",lastUpdated:"2024-08-06",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-2024-05-13",ownedBy:"openai",label:"GPT-4o (2024-05-13)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-05-13",lastUpdated:"2024-05-13",openWeights:!1,cost:{input:5,output:15},limit:{context:128e3,output:4096}},{id:"gpt-4o-2024-08-06",ownedBy:"openai",label:"GPT-4o (2024-08-06)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-08-06",lastUpdated:"2024-08-06",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-2024-11-20",ownedBy:"openai",label:"GPT-4o (2024-11-20)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-11-20",lastUpdated:"2024-11-20",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-mini",ownedBy:"openai",label:"GPT-4o mini",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-07-18",lastUpdated:"2024-07-18",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.08},limit:{context:128e3,output:16384}},{id:"gpt-5",ownedBy:"openai",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5-chat-latest",ownedBy:"openai",label:"GPT-5 Chat (latest)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"gpt-5-codex",ownedBy:"openai",label:"GPT-5-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5-mini",ownedBy:"openai",label:"GPT-5 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3}},{id:"gpt-5-nano",ownedBy:"openai",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.05,output:.4,cacheRead:.005},limit:{context:4e5,output:128e3}},{id:"gpt-5-pro",ownedBy:"openai",label:"GPT-5 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-10-06",lastUpdated:"2025-10-06",openWeights:!1,cost:{input:15,output:120},limit:{context:4e5,output:272e3}},{id:"gpt-5.1",ownedBy:"openai",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.13},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-chat-latest",ownedBy:"openai",label:"GPT-5.1 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:128e3,output:16384}},{id:"gpt-5.1-codex",ownedBy:"openai",label:"GPT-5.1 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-max",ownedBy:"openai",label:"GPT-5.1 Codex Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-mini",ownedBy:"openai",label:"GPT-5.1 Codex mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3}},{id:"gpt-5.2",ownedBy:"openai",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"gpt-5.2-chat-latest",ownedBy:"openai",label:"GPT-5.2 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:16384}},{id:"gpt-5.2-codex",ownedBy:"openai",label:"GPT-5.2 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"gpt-5.2-pro",ownedBy:"openai",label:"GPT-5.2 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:21,output:168},limit:{context:4e5,output:128e3}},{id:"gpt-5.3-chat-latest",ownedBy:"openai",label:"GPT-5.3 Chat (latest)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-03-03",lastUpdated:"2026-03-03",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:16384}},{id:"gpt-5.3-codex",ownedBy:"openai",label:"GPT-5.3 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"gpt-5.3-codex-spark",ownedBy:"openai",label:"GPT-5.3 Codex Spark",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:32e3}},{id:"gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:2.5,output:15,cacheRead:.25},limit:{context:105e4,output:128e3}},{id:"gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.75,output:4.5,cacheRead:.075},limit:{context:4e5,output:128e3}},{id:"gpt-5.4-nano",ownedBy:"openai",label:"GPT-5.4 nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.2,output:1.25,cacheRead:.02},limit:{context:4e5,output:128e3}},{id:"gpt-5.4-pro",ownedBy:"openai",label:"GPT-5.4 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:30,output:180},limit:{context:105e4,output:128e3}},{id:"gpt-5.5",ownedBy:"openai",label:"GPT-5.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-23",lastUpdated:"2026-04-23",openWeights:!1,cost:{input:5,output:30,cacheRead:.5},limit:{context:105e4,output:128e3}},{id:"gpt-5.5-pro",ownedBy:"openai",label:"GPT-5.5 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-23",lastUpdated:"2026-04-23",openWeights:!1,cost:{input:30,output:180},limit:{context:105e4,output:128e3}},{id:"gpt-image-1",ownedBy:"openai",label:"gpt-image-1",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-04-24",lastUpdated:"2025-04-24",openWeights:!1,limit:{context:0,output:0}},{id:"gpt-image-1-mini",ownedBy:"openai",label:"gpt-image-1-mini",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-09-26",lastUpdated:"2025-09-26",openWeights:!1,limit:{context:0,output:0}},{id:"gpt-image-1.5",ownedBy:"openai",label:"gpt-image-1.5",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-11-25",lastUpdated:"2025-11-25",openWeights:!1,limit:{context:0,output:0}},{id:"o1",ownedBy:"openai",label:"o1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2023-09",releaseDate:"2024-12-05",lastUpdated:"2024-12-05",openWeights:!1,cost:{input:15,output:60,cacheRead:7.5},limit:{context:2e5,output:1e5}},{id:"o1-mini",ownedBy:"openai",label:"o1-mini",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2023-09",releaseDate:"2024-09-12",lastUpdated:"2024-09-12",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.55},limit:{context:128e3,output:65536}},{id:"o1-preview",ownedBy:"openai",label:"o1-preview",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-09",releaseDate:"2024-09-12",lastUpdated:"2024-09-12",openWeights:!1,cost:{input:15,output:60,cacheRead:7.5},limit:{context:128e3,output:32768}},{id:"o1-pro",ownedBy:"openai",label:"o1-pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2023-09",releaseDate:"2025-03-19",lastUpdated:"2025-03-19",openWeights:!1,cost:{input:150,output:600},limit:{context:2e5,output:1e5}},{id:"o3",ownedBy:"openai",label:"o3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:2e5,output:1e5}},{id:"o3-deep-research",ownedBy:"openai",label:"o3-deep-research",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2024-06-26",lastUpdated:"2024-06-26",openWeights:!1,cost:{input:10,output:40,cacheRead:2.5},limit:{context:2e5,output:1e5}},{id:"o3-mini",ownedBy:"openai",label:"o3-mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-05",releaseDate:"2024-12-20",lastUpdated:"2025-01-29",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.55},limit:{context:2e5,output:1e5}},{id:"o3-pro",ownedBy:"openai",label:"o3-pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-06-10",lastUpdated:"2025-06-10",openWeights:!1,cost:{input:20,output:80},limit:{context:2e5,output:1e5}},{id:"o4-mini",ownedBy:"openai",label:"o4-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.28},limit:{context:2e5,output:1e5}},{id:"o4-mini-deep-research",ownedBy:"openai",label:"o4-mini-deep-research",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2024-06-26",lastUpdated:"2024-06-26",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:2e5,output:1e5}},{id:"text-embedding-3-large",ownedBy:"openai",label:"text-embedding-3-large",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2024-01",releaseDate:"2024-01-25",lastUpdated:"2024-01-25",openWeights:!1,cost:{input:.13,output:0},limit:{context:8191,output:3072}},{id:"text-embedding-3-small",ownedBy:"openai",label:"text-embedding-3-small",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2024-01",releaseDate:"2024-01-25",lastUpdated:"2024-01-25",openWeights:!1,cost:{input:.02,output:0},limit:{context:8191,output:1536}},{id:"text-embedding-ada-002",ownedBy:"openai",label:"text-embedding-ada-002",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2022-12",releaseDate:"2022-12-15",lastUpdated:"2022-12-15",openWeights:!1,cost:{input:.1,output:0},limit:{context:8192,output:1536}}],label:"OpenAI",env:["OPENAI_API_KEY"],npm:"@ai-sdk/openai",doc:"https://platform.openai.com/docs/models"},anthropic:{id:"anthropic",models:[{id:"claude-3-5-haiku-20241022",ownedBy:"anthropic",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"claude-3-5-haiku-latest",ownedBy:"anthropic",label:"Claude Haiku 3.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"claude-3-5-sonnet-20240620",ownedBy:"anthropic",label:"Claude Sonnet 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04-30",releaseDate:"2024-06-20",lastUpdated:"2024-06-20",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:8192}},{id:"claude-3-5-sonnet-20241022",ownedBy:"anthropic",label:"Claude Sonnet 3.5 v2",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04-30",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:8192}},{id:"claude-3-7-sonnet-20250219",ownedBy:"anthropic",label:"Claude Sonnet 3.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-31",releaseDate:"2025-02-19",lastUpdated:"2025-02-19",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-3-haiku-20240307",ownedBy:"anthropic",label:"Claude Haiku 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-03-13",lastUpdated:"2024-03-13",openWeights:!1,cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},limit:{context:2e5,output:4096}},{id:"claude-3-opus-20240229",ownedBy:"anthropic",label:"Claude Opus 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-02-29",lastUpdated:"2024-02-29",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:4096}},{id:"claude-3-sonnet-20240229",ownedBy:"anthropic",label:"Claude Sonnet 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-03-04",lastUpdated:"2024-03-04",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:.3},limit:{context:2e5,output:4096}},{id:"claude-haiku-4-5",ownedBy:"anthropic",label:"Claude Haiku 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"claude-haiku-4-5-20251001",ownedBy:"anthropic",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"claude-opus-4-0",ownedBy:"anthropic",label:"Claude Opus 4 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-1",ownedBy:"anthropic",label:"Claude Opus 4.1 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-1-20250805",ownedBy:"anthropic",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-20250514",ownedBy:"anthropic",label:"Claude Opus 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-5",ownedBy:"anthropic",label:"Claude Opus 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3}},{id:"claude-opus-4-5-20251101",ownedBy:"anthropic",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-01",lastUpdated:"2025-11-01",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3}},{id:"claude-opus-4-6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-03-13",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"claude-opus-4-7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"claude-sonnet-4-0",ownedBy:"anthropic",label:"Claude Sonnet 4 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-20250514",ownedBy:"anthropic",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-5",ownedBy:"anthropic",label:"Claude Sonnet 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-5-20250929",ownedBy:"anthropic",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-03-13",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3}}],label:"Anthropic",env:["ANTHROPIC_API_KEY"],npm:"@ai-sdk/anthropic",doc:"https://docs.anthropic.com/en/docs/about-claude/models"},google:{id:"google",models:[{id:"gemini-1.5-flash",ownedBy:"google",label:"Gemini 1.5 Flash",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-05-14",lastUpdated:"2024-05-14",openWeights:!1,cost:{input:.075,output:.3,cacheRead:.01875},limit:{context:1e6,output:8192}},{id:"gemini-1.5-flash-8b",ownedBy:"google",label:"Gemini 1.5 Flash-8B",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-10-03",lastUpdated:"2024-10-03",openWeights:!1,cost:{input:.0375,output:.15,cacheRead:.01},limit:{context:1e6,output:8192}},{id:"gemini-1.5-pro",ownedBy:"google",label:"Gemini 1.5 Pro",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-02-15",lastUpdated:"2024-02-15",openWeights:!1,cost:{input:1.25,output:5,cacheRead:.3125},limit:{context:1e6,output:8192}},{id:"gemini-2.0-flash",ownedBy:"google",label:"Gemini 2.0 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:8192}},{id:"gemini-2.0-flash-lite",ownedBy:"google",label:"Gemini 2.0 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.075,output:.3},limit:{context:1048576,output:8192}},{id:"gemini-2.5-flash",ownedBy:"google",label:"Gemini 2.5 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.03},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-image",ownedBy:"google",label:"Gemini 2.5 Flash Image",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.3,output:30,cacheRead:.075},limit:{context:32768,output:32768}},{id:"gemini-2.5-flash-image-preview",ownedBy:"google",label:"Gemini 2.5 Flash Image (Preview)",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.3,output:30,cacheRead:.075},limit:{context:32768,output:32768}},{id:"gemini-2.5-flash-lite",ownedBy:"google",label:"Gemini 2.5 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-lite-preview-06-17",ownedBy:"google",label:"Gemini 2.5 Flash Lite Preview 06-17",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-lite-preview-09-2025",ownedBy:"google",label:"Gemini 2.5 Flash Lite Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-04-17",ownedBy:"google",label:"Gemini 2.5 Flash Preview 04-17",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-04-17",lastUpdated:"2025-04-17",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-05-20",ownedBy:"google",label:"Gemini 2.5 Flash Preview 05-20",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-09-2025",ownedBy:"google",label:"Gemini 2.5 Flash Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.075},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-tts",ownedBy:"google",label:"Gemini 2.5 Flash Preview TTS",modalities:{input:["text"],output:["audio"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-05-01",lastUpdated:"2025-05-01",openWeights:!1,cost:{input:.5,output:10},limit:{context:8e3,output:16e3}},{id:"gemini-2.5-pro",ownedBy:"google",label:"Gemini 2.5 Pro",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-05-06",ownedBy:"google",label:"Gemini 2.5 Pro Preview 05-06",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-06",lastUpdated:"2025-05-06",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-06-05",ownedBy:"google",label:"Gemini 2.5 Pro Preview 06-05",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-05",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-tts",ownedBy:"google",label:"Gemini 2.5 Pro Preview TTS",modalities:{input:["text"],output:["audio"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-05-01",lastUpdated:"2025-05-01",openWeights:!1,cost:{input:1,output:20},limit:{context:8e3,output:16e3}},{id:"gemini-3-flash-preview",ownedBy:"google",label:"Gemini 3 Flash Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536}},{id:"gemini-3-pro-preview",ownedBy:"google",label:"Gemini 3 Pro Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11-18",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1e6,output:64e3}},{id:"gemini-3.1-flash-image-preview",ownedBy:"google",label:"Gemini 3.1 Flash Image (Preview)",modalities:{input:["text","image","pdf"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-26",lastUpdated:"2026-02-26",openWeights:!1,cost:{input:.25,output:60},limit:{context:131072,output:32768}},{id:"gemini-3.1-flash-lite-preview",ownedBy:"google",label:"Gemini 3.1 Flash Lite Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-03-03",lastUpdated:"2026-03-03",openWeights:!1,cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:1},limit:{context:1048576,output:65536}},{id:"gemini-3.1-pro-preview",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536}},{id:"gemini-3.1-pro-preview-customtools",ownedBy:"google",label:"Gemini 3.1 Pro Preview Custom Tools",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536}},{id:"gemini-embedding-001",ownedBy:"google",label:"Gemini Embedding 001",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-05",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!1,cost:{input:.15,output:0},limit:{context:2048,output:3072}},{id:"gemini-flash-latest",ownedBy:"google",label:"Gemini Flash Latest",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.075},limit:{context:1048576,output:65536}},{id:"gemini-flash-lite-latest",ownedBy:"google",label:"Gemini Flash-Lite Latest",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-live-2.5-flash",ownedBy:"google",label:"Gemini Live 2.5 Flash",modalities:{input:["text","image","audio","video"],output:["text","audio"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-01",lastUpdated:"2025-09-01",openWeights:!1,cost:{input:.5,output:2},limit:{context:128e3,output:8e3}},{id:"gemini-live-2.5-flash-preview-native-audio",ownedBy:"google",label:"Gemini Live 2.5 Flash Preview Native Audio",modalities:{input:["text","audio","video"],output:["text","audio"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-09-18",openWeights:!1,cost:{input:.5,output:2},limit:{context:131072,output:65536}},{id:"gemma-3-12b-it",ownedBy:"google",label:"Gemma 3 12B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"gemma-3-27b-it",ownedBy:"google",label:"Gemma 3 27B",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-12",lastUpdated:"2025-03-12",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:8192}},{id:"gemma-3-4b-it",ownedBy:"google",label:"Gemma 3 4B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"gemma-3n-e2b-it",ownedBy:"google",label:"Gemma 3n 2B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:2e3}},{id:"gemma-3n-e4b-it",ownedBy:"google",label:"Gemma 3n 4B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:2e3}},{id:"gemma-4-26b-a4b-it",ownedBy:"google",label:"Gemma 4 26B",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,limit:{context:256e3,output:8192}},{id:"gemma-4-31b-it",ownedBy:"google",label:"Gemma 4 31B",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,limit:{context:256e3,output:8192}}],label:"Google",env:["GOOGLE_GENERATIVE_AI_API_KEY","GEMINI_API_KEY"],npm:"@ai-sdk/google",doc:"https://ai.google.dev/gemini-api/docs/pricing"},openrouter:{id:"openrouter",models:[{id:"anthropic/claude-3.5-haiku",ownedBy:"anthropic",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"anthropic/claude-3.7-sonnet",ownedBy:"anthropic",label:"Claude Sonnet 3.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-01",releaseDate:"2025-02-19",lastUpdated:"2025-02-19",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:128e3}},{id:"anthropic/claude-haiku-4.5",ownedBy:"anthropic",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"anthropic/claude-opus-4",ownedBy:"anthropic",label:"Claude Opus 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-opus-4.1",ownedBy:"anthropic",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-opus-4.5",ownedBy:"anthropic",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-30",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-opus-4.6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"anthropic/claude-opus-4.7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"anthropic/claude-sonnet-4",ownedBy:"anthropic",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"anthropic/claude-sonnet-4.5",ownedBy:"anthropic",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3}},{id:"anthropic/claude-sonnet-4.6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:128e3}},{id:"arcee-ai/trinity-large-preview:free",label:"Trinity Large Preview",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-28",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"arcee-ai/trinity-large-thinking",label:"Trinity Large Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-01",lastUpdated:"2026-04-03",openWeights:!0,cost:{input:.22,output:.85},limit:{context:262144,output:8e4}},{id:"black-forest-labs/flux.2-flex",label:"FLUX.2 Flex",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-11-25",lastUpdated:"2026-01-31",openWeights:!1,cost:{input:0,output:0},limit:{context:67344,output:67344}},{id:"black-forest-labs/flux.2-klein-4b",label:"FLUX.2 Klein 4B",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-14",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:40960,output:40960}},{id:"black-forest-labs/flux.2-max",label:"FLUX.2 Max",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-16",lastUpdated:"2026-01-31",openWeights:!1,cost:{input:0,output:0},limit:{context:46864,output:46864}},{id:"black-forest-labs/flux.2-pro",label:"FLUX.2 Pro",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-11-25",lastUpdated:"2026-01-31",openWeights:!1,cost:{input:0,output:0},limit:{context:46864,output:46864}},{id:"bytedance-seed/seedream-4.5",label:"Seedream 4.5",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-23",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:4096,output:4096}},{id:"cognitivecomputations/dolphin-mistral-24b-venice-edition:free",label:"Uncensored (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-07-09",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"deepseek/deepseek-chat-v3-0324",label:"DeepSeek V3 0324",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-24",lastUpdated:"2025-03-24",openWeights:!0,cost:{input:0,output:0},limit:{context:16384,output:8192}},{id:"deepseek/deepseek-chat-v3.1",label:"DeepSeek-V3.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-08-21",lastUpdated:"2025-08-21",openWeights:!0,cost:{input:.2,output:.8},limit:{context:163840,output:163840}},{id:"deepseek/deepseek-r1",label:"DeepSeek: R1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2025-01-20",lastUpdated:"2025-01-20",openWeights:!0,cost:{input:.7,output:2.5},limit:{context:64e3,output:16e3}},{id:"deepseek/deepseek-r1-distill-llama-70b",label:"DeepSeek R1 Distill Llama 70B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-01-23",lastUpdated:"2025-01-23",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"deepseek/deepseek-v3.1-terminus",label:"DeepSeek V3.1 Terminus",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-22",lastUpdated:"2025-09-22",openWeights:!0,cost:{input:.27,output:1},limit:{context:131072,output:65536}},{id:"deepseek/deepseek-v3.1-terminus:exacto",label:"DeepSeek V3.1 Terminus (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-22",lastUpdated:"2025-09-22",openWeights:!0,cost:{input:.27,output:1},limit:{context:131072,output:65536}},{id:"deepseek/deepseek-v3.2",label:"DeepSeek V3.2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2025-12-01",lastUpdated:"2025-12-01",openWeights:!0,cost:{input:.28,output:.4},limit:{context:163840,output:65536}},{id:"deepseek/deepseek-v3.2-speciale",label:"DeepSeek V3.2 Speciale",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2025-12-01",lastUpdated:"2025-12-01",openWeights:!0,cost:{input:.27,output:.41},limit:{context:163840,output:65536}},{id:"deepseek/deepseek-v4-flash",label:"DeepSeek V4 Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!0,cost:{input:.14,output:.28,cacheRead:.028},limit:{context:1048576,output:393216}},{id:"deepseek/deepseek-v4-pro",label:"DeepSeek V4 Pro",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!0,cost:{input:1.74,output:3.48,cacheRead:.145},limit:{context:1048576,output:393216}},{id:"google/gemini-2.0-flash-001",ownedBy:"google",label:"Gemini 2.0 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:8192}},{id:"google/gemini-2.5-flash",ownedBy:"google",label:"Gemini 2.5 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-07-17",lastUpdated:"2025-07-17",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-lite",ownedBy:"google",label:"Gemini 2.5 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-lite-preview-09-2025",ownedBy:"google",label:"Gemini 2.5 Flash Lite Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-preview-09-2025",ownedBy:"google",label:"Gemini 2.5 Flash Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.031},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro",ownedBy:"google",label:"Gemini 2.5 Pro",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro-preview-05-06",ownedBy:"google",label:"Gemini 2.5 Pro Preview 05-06",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-06",lastUpdated:"2025-05-06",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro-preview-06-05",ownedBy:"google",label:"Gemini 2.5 Pro Preview 06-05",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-05",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"google/gemini-3-flash-preview",ownedBy:"google",label:"Gemini 3 Flash Preview",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536}},{id:"google/gemini-3-pro-preview",ownedBy:"google",label:"Gemini 3 Pro Preview",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11",openWeights:!1,cost:{input:2,output:12},limit:{context:105e4,output:66e3}},{id:"google/gemini-3.1-flash-image-preview",ownedBy:"google",label:"Gemini 3.1 Flash Image Preview (Nano Banana 2)",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-26",lastUpdated:"2026-02-26",openWeights:!1,cost:{input:.5,output:3},limit:{context:65536,output:65536}},{id:"google/gemini-3.1-flash-lite-preview",ownedBy:"google",label:"Gemini 3.1 Flash Lite Preview",modalities:{input:["text","image","video","pdf","audio"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-03",lastUpdated:"2026-03-03",openWeights:!1,cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:.083},limit:{context:1048576,output:65536}},{id:"google/gemini-3.1-pro-preview",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12},limit:{context:1048576,output:65536}},{id:"google/gemini-3.1-pro-preview-customtools",ownedBy:"google",label:"Gemini 3.1 Pro Preview Custom Tools",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12},limit:{context:1048576,output:65536}},{id:"google/gemma-2-9b-it",ownedBy:"google",label:"Gemma 2 9B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-06",releaseDate:"2024-06-28",lastUpdated:"2024-06-28",openWeights:!0,cost:{input:.03,output:.09},limit:{context:8192,output:8192}},{id:"google/gemma-3-12b-it",ownedBy:"google",label:"Gemma 3 12B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:.03,output:.1},limit:{context:131072,output:131072}},{id:"google/gemma-3-12b-it:free",ownedBy:"google",label:"Gemma 3 12B (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"google/gemma-3-27b-it",ownedBy:"google",label:"Gemma 3 27B",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-12",lastUpdated:"2025-03-12",openWeights:!0,cost:{input:.04,output:.15},limit:{context:96e3,output:96e3}},{id:"google/gemma-3-27b-it:free",ownedBy:"google",label:"Gemma 3 27B (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-12",lastUpdated:"2025-03-12",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:8192}},{id:"google/gemma-3-4b-it",ownedBy:"google",label:"Gemma 3 4B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:.01703,output:.06815},limit:{context:96e3,output:96e3}},{id:"google/gemma-3-4b-it:free",ownedBy:"google",label:"Gemma 3 4B (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"google/gemma-3n-e2b-it:free",ownedBy:"google",label:"Gemma 3n 2B (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:2e3}},{id:"google/gemma-3n-e4b-it",ownedBy:"google",label:"Gemma 3n 4B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:.02,output:.04},limit:{context:32768,output:32768}},{id:"google/gemma-3n-e4b-it:free",ownedBy:"google",label:"Gemma 3n 4B (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:2e3}},{id:"google/gemma-4-26b-a4b-it",ownedBy:"google",label:"Gemma 4 26B A4B",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-03",lastUpdated:"2026-04-03",openWeights:!0,cost:{input:.13,output:.4},limit:{context:262144,output:262144}},{id:"google/gemma-4-26b-a4b-it:free",ownedBy:"google",label:"Gemma 4 26B A4B (free)",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-03",lastUpdated:"2026-04-03",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:32768}},{id:"google/gemma-4-31b-it",ownedBy:"google",label:"Gemma 4 31B",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,cost:{input:.14,output:.4},limit:{context:262144,output:262144}},{id:"google/gemma-4-31b-it:free",ownedBy:"google",label:"Gemma 4 31B (free)",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:32768}},{id:"inception/mercury-2",label:"Mercury 2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-04",lastUpdated:"2026-03-04",openWeights:!1,cost:{input:.25,output:.75,cacheRead:.025},limit:{context:128e3,output:5e4}},{id:"inception/mercury-edit-2",label:"Mercury Edit 2",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-30",lastUpdated:"2026-03-30",openWeights:!1,cost:{input:.25,output:.75,cacheRead:.025},limit:{context:128e3,output:8192}},{id:"liquid/lfm-2.5-1.2b-instruct:free",label:"LFM2.5-1.2B-Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-20",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:32768}},{id:"liquid/lfm-2.5-1.2b-thinking:free",label:"LFM2.5-1.2B-Thinking (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-20",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:32768}},{id:"meta-llama/llama-3.2-11b-vision-instruct",label:"Llama 3.2 11B Vision Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-12",releaseDate:"2024-09-25",lastUpdated:"2024-09-25",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:8192}},{id:"meta-llama/llama-3.2-3b-instruct:free",label:"Llama 3.2 3B Instruct (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-12",releaseDate:"2024-09-25",lastUpdated:"2024-09-25",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"meta-llama/llama-3.3-70b-instruct:free",label:"Llama 3.3 70B Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-12",releaseDate:"2024-12-06",lastUpdated:"2024-12-06",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"minimax/minimax-01",ownedBy:"minimax",label:"MiniMax-01",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2025-01-15",lastUpdated:"2025-01-15",openWeights:!0,cost:{input:.2,output:1.1},limit:{context:1e6,output:1e6}},{id:"minimax/minimax-m1",ownedBy:"minimax",label:"MiniMax M1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!0,cost:{input:.4,output:2.2},limit:{context:1e6,output:4e4}},{id:"minimax/minimax-m2",ownedBy:"minimax",label:"MiniMax M2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-10-23",lastUpdated:"2025-10-23",openWeights:!0,cost:{input:.28,output:1.15,cacheRead:.28,cacheWrite:1.15},limit:{context:196600,output:118e3}},{id:"minimax/minimax-m2.1",ownedBy:"minimax",label:"MiniMax M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:204800,output:131072}},{id:"minimax/minimax-m2.5",ownedBy:"minimax",label:"MiniMax M2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.03},limit:{context:204800,output:131072}},{id:"minimax/minimax-m2.5:free",ownedBy:"minimax",label:"MiniMax M2.5 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:0,output:0},limit:{context:204800,output:131072}},{id:"minimax/minimax-m2.7",ownedBy:"minimax",label:"MiniMax M2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}},{id:"mistralai/codestral-2508",label:"Codestral 2508",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-08-01",lastUpdated:"2025-08-01",openWeights:!0,cost:{input:.3,output:.9},limit:{context:256e3,output:256e3}},{id:"mistralai/devstral-2512",label:"Devstral 2 2512",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-12",releaseDate:"2025-09-12",lastUpdated:"2025-09-12",openWeights:!0,cost:{input:.15,output:.6},limit:{context:262144,output:262144}},{id:"mistralai/devstral-medium-2507",label:"Devstral Medium",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-07-10",lastUpdated:"2025-07-10",openWeights:!0,cost:{input:.4,output:2},limit:{context:131072,output:131072}},{id:"mistralai/devstral-small-2505",label:"Devstral Small",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-07",lastUpdated:"2025-05-07",openWeights:!0,cost:{input:.06,output:.12},limit:{context:128e3,output:128e3}},{id:"mistralai/devstral-small-2507",label:"Devstral Small 1.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-07-10",lastUpdated:"2025-07-10",openWeights:!0,cost:{input:.1,output:.3},limit:{context:131072,output:131072}},{id:"mistralai/mistral-medium-3",label:"Mistral Medium 3",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-07",lastUpdated:"2025-05-07",openWeights:!1,cost:{input:.4,output:2},limit:{context:131072,output:131072}},{id:"mistralai/mistral-medium-3.1",label:"Mistral Medium 3.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-05",releaseDate:"2025-08-12",lastUpdated:"2025-08-12",openWeights:!1,cost:{input:.4,output:2},limit:{context:262144,output:262144}},{id:"mistralai/mistral-small-2603",label:"Mistral Small 4",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!0,cost:{input:.15,output:.6},limit:{context:262144,output:262144}},{id:"mistralai/mistral-small-3.1-24b-instruct",label:"Mistral Small 3.1 24B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-17",lastUpdated:"2025-03-17",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:8192}},{id:"mistralai/mistral-small-3.2-24b-instruct",label:"Mistral Small 3.2 24B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-06-20",lastUpdated:"2025-06-20",openWeights:!0,cost:{input:0,output:0},limit:{context:96e3,output:8192}},{id:"moonshotai/kimi-k2",ownedBy:"moonshot",label:"Kimi K2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-07-11",lastUpdated:"2025-07-11",openWeights:!0,cost:{input:.55,output:2.2},limit:{context:131072,output:32768}},{id:"moonshotai/kimi-k2-0905",ownedBy:"moonshot",label:"Kimi K2 Instruct 0905",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5},limit:{context:262144,output:16384}},{id:"moonshotai/kimi-k2-0905:exacto",ownedBy:"moonshot",label:"Kimi K2 Instruct 0905 (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5},limit:{context:262144,output:16384}},{id:"moonshotai/kimi-k2-thinking",ownedBy:"moonshot",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144}},{id:"moonshotai/kimi-k2.5",ownedBy:"moonshot",label:"Kimi K2.5",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:.6,output:3,cacheRead:.1},limit:{context:262144,output:262144}},{id:"moonshotai/kimi-k2.6",ownedBy:"moonshot",label:"Kimi K2.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-20",lastUpdated:"2026-04-20",openWeights:!0,cost:{input:.95,output:4,cacheRead:.16},limit:{context:262144,output:262144}},{id:"nousresearch/hermes-3-llama-3.1-405b:free",label:"Hermes 3 405B Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-12",releaseDate:"2024-08-16",lastUpdated:"2024-08-16",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"nousresearch/hermes-4-405b",label:"Hermes 4 405B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-12",releaseDate:"2025-08-25",lastUpdated:"2025-08-25",openWeights:!0,cost:{input:1,output:3},limit:{context:131072,output:131072}},{id:"nousresearch/hermes-4-70b",label:"Hermes 4 70B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-12",releaseDate:"2025-08-25",lastUpdated:"2025-08-25",openWeights:!0,cost:{input:.13,output:.4},limit:{context:131072,output:131072}},{id:"nvidia/nemotron-3-nano-30b-a3b:free",label:"Nemotron 3 Nano 30B A3B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-11",releaseDate:"2025-12-14",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:256e3,output:256e3}},{id:"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free",label:"Nemotron 3 Nano Omni (free)",modalities:{input:["text","image","video","audio"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-28",lastUpdated:"2026-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:256e3,output:65536}},{id:"nvidia/nemotron-3-super-120b-a12b",label:"Nemotron 3 Super",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-04",releaseDate:"2026-03-11",lastUpdated:"2026-03-11",openWeights:!0,cost:{input:.1,output:.5},limit:{context:262144,output:262144}},{id:"nvidia/nemotron-3-super-120b-a12b:free",label:"Nemotron 3 Super (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-04",releaseDate:"2026-03-11",lastUpdated:"2026-03-11",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:262144}},{id:"nvidia/nemotron-nano-12b-v2-vl:free",label:"Nemotron Nano 12B 2 VL (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-11",releaseDate:"2025-10-28",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:128e3}},{id:"nvidia/nemotron-nano-9b-v2",label:"nvidia-nemotron-nano-9b-v2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-09",releaseDate:"2025-08-18",lastUpdated:"2025-08-18",openWeights:!0,cost:{input:.04,output:.16},limit:{context:131072,output:131072}},{id:"nvidia/nemotron-nano-9b-v2:free",label:"Nemotron Nano 9B V2 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-09",releaseDate:"2025-09-05",lastUpdated:"2025-08-18",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:128e3}},{id:"openai/gpt-4.1",ownedBy:"openai",label:"GPT-4.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:1047576,output:32768}},{id:"openai/gpt-4.1-mini",ownedBy:"openai",label:"GPT-4.1 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.4,output:1.6,cacheRead:.1},limit:{context:1047576,output:32768}},{id:"openai/gpt-4o-mini",ownedBy:"openai",label:"GPT-4o-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2024-07-18",lastUpdated:"2024-07-18",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.08},limit:{context:128e3,output:16384}},{id:"openai/gpt-5",ownedBy:"openai",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-chat",ownedBy:"openai",label:"GPT-5 Chat (latest)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-codex",ownedBy:"openai",label:"GPT-5 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-image",ownedBy:"openai",label:"GPT-5 Image",modalities:{input:["text","image","pdf"],output:["text","image"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-10-14",lastUpdated:"2025-10-14",openWeights:!1,cost:{input:5,output:10,cacheRead:1.25},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-mini",ownedBy:"openai",label:"GPT-5 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.25,output:2},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-nano",ownedBy:"openai",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.05,output:.4},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-pro",ownedBy:"openai",label:"GPT-5 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-10-06",lastUpdated:"2025-10-06",openWeights:!1,cost:{input:15,output:120},limit:{context:4e5,output:272e3}},{id:"openai/gpt-5.1",ownedBy:"openai",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-chat",ownedBy:"openai",label:"GPT-5.1 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:128e3,output:16384}},{id:"openai/gpt-5.1-codex",ownedBy:"openai",label:"GPT-5.1-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-codex-max",ownedBy:"openai",label:"GPT-5.1-Codex-Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.1,output:9,cacheRead:.11},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-codex-mini",ownedBy:"openai",label:"GPT-5.1-Codex-Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:1e5}},{id:"openai/gpt-5.2",ownedBy:"openai",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.2-chat",ownedBy:"openai",label:"GPT-5.2 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:16384}},{id:"openai/gpt-5.2-codex",ownedBy:"openai",label:"GPT-5.2-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-01-14",lastUpdated:"2026-01-14",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.2-pro",ownedBy:"openai",label:"GPT-5.2 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:21,output:168},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.3-codex",ownedBy:"openai",label:"GPT-5.3-Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-24",lastUpdated:"2026-02-24",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:2.5,output:15,cacheRead:.25},limit:{context:105e4,output:128e3}},{id:"openai/gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 Mini",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.75,output:4.5,cacheRead:.075},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.4-nano",ownedBy:"openai",label:"GPT-5.4 Nano",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.2,output:1.25,cacheRead:.02},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.4-pro",ownedBy:"openai",label:"GPT-5.4 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:30,output:180,cacheRead:30},limit:{context:105e4,output:128e3}},{id:"openai/gpt-5.5",ownedBy:"openai",label:"GPT-5.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-23",lastUpdated:"2026-04-23",openWeights:!1,cost:{input:5,output:30,cacheRead:.5},limit:{context:105e4,output:128e3}},{id:"openai/gpt-5.5-pro",ownedBy:"openai",label:"GPT-5.5 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-23",lastUpdated:"2026-04-23",openWeights:!1,cost:{input:30,output:180},limit:{context:105e4,output:128e3}},{id:"openai/gpt-oss-120b",ownedBy:"openai",label:"GPT OSS 120B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.072,output:.28},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-120b:exacto",ownedBy:"openai",label:"GPT OSS 120B (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.05,output:.24},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-120b:free",ownedBy:"openai",label:"gpt-oss-120b (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-20b",ownedBy:"openai",label:"GPT OSS 20B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.05,output:.2},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-20b:free",ownedBy:"openai",label:"gpt-oss-20b (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-safeguard-20b",ownedBy:"openai",label:"GPT OSS Safeguard 20B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-10-29",lastUpdated:"2025-10-29",openWeights:!1,cost:{input:.075,output:.3},limit:{context:131072,output:65536}},{id:"openai/o4-mini",ownedBy:"openai",label:"o4 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.28},limit:{context:2e5,output:1e5}},{id:"openrouter/elephant-alpha",label:"Elephant (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-13",lastUpdated:"2026-04-13",openWeights:!1,cost:{input:0,output:0},limit:{context:262144,output:32768}},{id:"openrouter/free",label:"Free Models Router",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-02-01",lastUpdated:"2026-02-01",openWeights:!1,cost:{input:0,output:0},limit:{context:2e5,output:8e3}},{id:"openrouter/owl-alpha",label:"Owl Alpha",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-28",lastUpdated:"2026-04-30",openWeights:!1,cost:{input:0,output:0},limit:{context:1048756,output:262144}},{id:"openrouter/pareto-code",label:"Pareto Code Router",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-21",lastUpdated:"2026-04-21",openWeights:!1,limit:{context:2e5,output:2e5}},{id:"poolside/laguna-m.1:free",label:"Laguna M.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-28",lastUpdated:"2026-04-28",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:8192}},{id:"poolside/laguna-xs.2:free",label:"Laguna XS.2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-28",lastUpdated:"2026-04-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:8192}},{id:"prime-intellect/intellect-3",ownedBy:"zai",label:"Intellect 3",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-01-15",lastUpdated:"2025-01-15",openWeights:!0,cost:{input:.2,output:1.1},limit:{context:131072,output:8192}},{id:"qwen/qwen-2.5-coder-32b-instruct",label:"Qwen2.5 Coder 32B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2024-11-11",lastUpdated:"2024-11-11",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"qwen/qwen-3.6-27b",label:"Qwen3.6 27B",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-04-22",lastUpdated:"2026-04-22",openWeights:!0,cost:{input:.195,output:1.56},limit:{context:262144,output:81920}},{id:"qwen/qwen2.5-vl-72b-instruct",label:"Qwen2.5 VL 72B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-02-01",lastUpdated:"2025-02-01",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"qwen/qwen3-235b-a22b-07-25",label:"Qwen3 235B A22B Instruct 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-07-21",openWeights:!0,cost:{input:.15,output:.85},limit:{context:262144,output:131072}},{id:"qwen/qwen3-235b-a22b-thinking-2507",label:"Qwen3 235B A22B Thinking 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-25",lastUpdated:"2025-07-25",openWeights:!0,cost:{input:.078,output:.312},limit:{context:262144,output:81920}},{id:"qwen/qwen3-30b-a3b-instruct-2507",label:"Qwen3 30B A3B Instruct 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-29",lastUpdated:"2025-07-29",openWeights:!0,cost:{input:.2,output:.8},limit:{context:262e3,output:262e3}},{id:"qwen/qwen3-30b-a3b-thinking-2507",label:"Qwen3 30B A3B Thinking 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-29",lastUpdated:"2025-07-29",openWeights:!0,cost:{input:.2,output:.8},limit:{context:262e3,output:262e3}},{id:"qwen/qwen3-coder",label:"Qwen3 Coder",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:262144,output:66536}},{id:"qwen/qwen3-coder-30b-a3b-instruct",label:"Qwen3 Coder 30B A3B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-31",lastUpdated:"2025-07-31",openWeights:!0,cost:{input:.07,output:.27},limit:{context:16e4,output:65536}},{id:"qwen/qwen3-coder-flash",label:"Qwen3 Coder Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!1,cost:{input:.3,output:1.5},limit:{context:128e3,output:66536}},{id:"qwen/qwen3-coder:exacto",label:"Qwen3 Coder (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.38,output:1.53},limit:{context:131072,output:32768}},{id:"qwen/qwen3-max",label:"Qwen3 Max",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!1,cost:{input:1.2,output:6},limit:{context:262144,output:32768}},{id:"qwen/qwen3-next-80b-a3b-instruct",label:"Qwen3 Next 80B A3B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-11",lastUpdated:"2025-09-11",openWeights:!0,cost:{input:.14,output:1.4},limit:{context:262144,output:262144}},{id:"qwen/qwen3-next-80b-a3b-thinking",label:"Qwen3 Next 80B A3B Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-11",lastUpdated:"2025-09-11",openWeights:!0,cost:{input:.14,output:1.4},limit:{context:262144,output:262144}},{id:"qwen/qwen3.5-397b-a17b",label:"Qwen3.5 397B A17B",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-16",lastUpdated:"2026-02-16",openWeights:!0,cost:{input:.6,output:3.6},limit:{context:262144,output:65536}},{id:"qwen/qwen3.5-flash-02-23",label:"Qwen: Qwen3.5-Flash",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-02-25",lastUpdated:"2026-02-25",openWeights:!1,cost:{input:.065,output:.26},limit:{context:1e6,output:65536}},{id:"qwen/qwen3.5-plus-02-15",label:"Qwen3.5 Plus 2026-02-15",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-16",lastUpdated:"2026-02-16",openWeights:!1,cost:{input:.4,output:2.4},limit:{context:1e6,output:65536}},{id:"qwen/qwen3.6-plus",label:"Qwen3.6 Plus",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!1,cost:{input:.325,output:1.95},limit:{context:1e6,output:65536}},{id:"sourceful/riverflow-v2-fast-preview",label:"Riverflow V2 Fast Preview",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-08",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"sourceful/riverflow-v2-max-preview",label:"Riverflow V2 Max Preview",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-08",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"sourceful/riverflow-v2-standard-preview",label:"Riverflow V2 Standard Preview",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-08",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"stepfun/step-3.5-flash",label:"Step 3.5 Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-01-29",lastUpdated:"2026-01-29",openWeights:!0,cost:{input:.1,output:.3,cacheRead:.02},limit:{context:256e3,output:256e3}},{id:"x-ai/grok-3",ownedBy:"xai",label:"Grok 3",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-beta",ownedBy:"xai",label:"Grok 3 Beta",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-mini",ownedBy:"xai",label:"Grok 3 Mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:.5},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-mini-beta",ownedBy:"xai",label:"Grok 3 Mini Beta",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:.5},limit:{context:131072,output:8192}},{id:"x-ai/grok-4",ownedBy:"xai",label:"Grok 4",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:256e3,output:64e3}},{id:"x-ai/grok-4-fast",ownedBy:"xai",label:"Grok 4 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-08-19",lastUpdated:"2025-08-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:.05},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-4.1-fast",ownedBy:"xai",label:"Grok 4.1 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-11-19",lastUpdated:"2025-11-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:.05},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-4.20-beta",ownedBy:"xai",label:"Grok 4.20 Beta",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-12",lastUpdated:"2026-03-12",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-4.20-multi-agent-beta",ownedBy:"xai",label:"Grok 4.20 Multi - Agent Beta",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-12",lastUpdated:"2026-03-12",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-4.3",ownedBy:"xai",label:"Grok 4.3",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-05-01",lastUpdated:"2026-05-01",openWeights:!1,cost:{input:1.25,output:2.5,cacheRead:.2},limit:{context:1e6,output:1e6}},{id:"x-ai/grok-code-fast-1",ownedBy:"xai",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-08",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.2,output:1.5,cacheRead:.02},limit:{context:256e3,output:1e4}},{id:"xiaomi/mimo-v2-flash",label:"Xiaomi: MiMo-V2-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-12-01",releaseDate:"2025-12-16",lastUpdated:"2026-02-04",openWeights:!0,cost:{input:.1,output:.3,cacheRead:.01},limit:{context:262144,output:65536}},{id:"xiaomi/mimo-v2-omni",label:"Xiaomi: MiMo-V2-Omni",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!1,cost:{input:.4,output:2,cacheRead:.08},limit:{context:262144,output:131072}},{id:"xiaomi/mimo-v2-pro",label:"Xiaomi: MiMo-V2-Pro",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!1,cost:{input:1,output:3,cacheRead:.2},limit:{context:1048576,output:131072}},{id:"xiaomi/mimo-v2.5",label:"Xiaomi: MiMo-V2.5",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-04-22",lastUpdated:"2026-04-22",openWeights:!0,cost:{input:.4,output:2,cacheRead:.08},limit:{context:1048576,output:131072}},{id:"xiaomi/mimo-v2.5-pro",label:"Xiaomi: MiMo-V2.5-Pro",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-04-22",lastUpdated:"2026-04-22",openWeights:!0,cost:{input:1,output:3,cacheRead:.2},limit:{context:1048576,output:131072}},{id:"z-ai/glm-4.5",ownedBy:"zai",label:"GLM 4.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.6,output:2.2},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5-air",ownedBy:"zai",label:"GLM 4.5 Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.2,output:1.1},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5-air:free",ownedBy:"zai",label:"GLM 4.5 Air (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5v",ownedBy:"zai",label:"GLM 4.5V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-08-11",lastUpdated:"2025-08-11",openWeights:!0,cost:{input:.6,output:1.8},limit:{context:64e3,output:16384}},{id:"z-ai/glm-4.6",ownedBy:"zai",label:"GLM 4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-09",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11},limit:{context:2e5,output:128e3}},{id:"z-ai/glm-4.6:exacto",ownedBy:"zai",label:"GLM 4.6 (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-09",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:1.9,cacheRead:.11},limit:{context:2e5,output:128e3}},{id:"z-ai/glm-4.7",ownedBy:"zai",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11},limit:{context:204800,output:131072}},{id:"z-ai/glm-4.7-flash",ownedBy:"zai",label:"GLM-4.7-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-01-19",lastUpdated:"2026-01-19",openWeights:!0,cost:{input:.07,output:.4},limit:{context:2e5,output:65535}},{id:"z-ai/glm-5",ownedBy:"zai",label:"GLM-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:1,output:3.2,cacheRead:.2},limit:{context:202752,output:131e3}},{id:"z-ai/glm-5-turbo",ownedBy:"zai",label:"GLM-5-Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!1,cost:{input:.96,output:3.2,cacheRead:.192,cacheWrite:0},limit:{context:202752,output:131072}},{id:"z-ai/glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-07",lastUpdated:"2026-04-07",openWeights:!0,cost:{input:1.4,output:4.4,cacheRead:.26},limit:{context:202752,output:131072}}],label:"OpenRouter",env:["OPENROUTER_API_KEY"],npm:"@openrouter/ai-sdk-provider",api:"https://openrouter.ai/api/v1",doc:"https://openrouter.ai/models"},opencode:{id:"opencode",models:[{id:"big-pickle",label:"Big Pickle",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-10-17",lastUpdated:"2025-10-17",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:128e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-3-5-haiku",ownedBy:"anthropic",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-haiku-4-5",ownedBy:"anthropic",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-1",ownedBy:"anthropic",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-5",ownedBy:"anthropic",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-03-13",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-sonnet-4",ownedBy:"anthropic",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-sonnet-4-5",ownedBy:"anthropic",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-sonnet-4-6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"gemini-3-flash",ownedBy:"google",label:"Gemini 3 Flash",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536},provider:{npm:"@ai-sdk/google"}},{id:"gemini-3-pro",ownedBy:"google",label:"Gemini 3 Pro",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11-18",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536},provider:{npm:"@ai-sdk/google"}},{id:"gemini-3.1-pro",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536},provider:{npm:"@ai-sdk/google"}},{id:"glm-4.6",ownedBy:"zai",label:"GLM-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"glm-4.7",ownedBy:"zai",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"glm-4.7-free",ownedBy:"zai",label:"GLM-4.7 Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072}},{id:"glm-5",ownedBy:"zai",label:"GLM-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,cost:{input:1,output:3.2,cacheRead:.2},limit:{context:204800,output:131072}},{id:"glm-5-free",ownedBy:"zai",label:"GLM-5 Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-04-07",lastUpdated:"2026-04-07",openWeights:!0,cost:{input:1.4,output:4.4,cacheRead:.26},limit:{context:204800,output:131072}},{id:"gpt-5",ownedBy:"openai",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5-codex",ownedBy:"openai",label:"GPT-5 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5-nano",ownedBy:"openai",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:0,output:0,cacheRead:0},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1",ownedBy:"openai",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex",ownedBy:"openai",label:"GPT-5.1 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex-max",ownedBy:"openai",label:"GPT-5.1 Codex Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex-mini",ownedBy:"openai",label:"GPT-5.1 Codex Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.2",ownedBy:"openai",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.2-codex",ownedBy:"openai",label:"GPT-5.2 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-01-14",lastUpdated:"2026-01-14",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.3-codex",ownedBy:"openai",label:"GPT-5.3 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-24",lastUpdated:"2026-02-24",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.3-codex-spark",ownedBy:"openai",label:"GPT-5.3 Codex Spark",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:2.5,output:15,cacheRead:.25},limit:{context:105e4,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 Mini",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.75,output:4.5,cacheRead:.075},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4-nano",ownedBy:"openai",label:"GPT-5.4 Nano",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.2,output:1.25,cacheRead:.02},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4-pro",ownedBy:"openai",label:"GPT-5.4 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:30,output:180,cacheRead:30},limit:{context:105e4,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.5",ownedBy:"openai",label:"GPT-5.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-23",lastUpdated:"2026-04-23",openWeights:!1,cost:{input:5,output:30,cacheRead:.5},limit:{context:105e4,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.5-pro",ownedBy:"openai",label:"GPT-5.5 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!1,cost:{input:30,output:180,cacheRead:30},limit:{context:105e4,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"grok-code",ownedBy:"xai",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2025-08-20",lastUpdated:"2025-08-20",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:256e3,output:256e3}},{id:"hy3-preview-free",label:"Hy3 preview Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-04-20",lastUpdated:"2026-04-20",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:256e3,output:64e3}},{id:"kimi-k2",ownedBy:"moonshot",label:"Kimi K2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.4,output:2.5,cacheRead:.4},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking",ownedBy:"moonshot",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.4,output:2.5,cacheRead:.4},limit:{context:262144,output:262144}},{id:"kimi-k2.5",ownedBy:"moonshot",label:"Kimi K2.5",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:.6,output:3,cacheRead:.08},limit:{context:262144,output:65536}},{id:"kimi-k2.5-free",ownedBy:"moonshot",label:"Kimi K2.5 Free",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:262144,output:262144}},{id:"kimi-k2.6",ownedBy:"moonshot",label:"Kimi K2.6",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2026-04-21",lastUpdated:"2026-04-21",openWeights:!0,cost:{input:.95,output:4,cacheRead:.16},limit:{context:262144,output:65536}},{id:"ling-2.6-flash-free",label:"Ling 2.6 Flash Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-04-21",lastUpdated:"2026-04-21",openWeights:!0,cost:{input:0,output:0},limit:{context:262100,output:32800}},{id:"mimo-v2-flash-free",label:"MiMo V2 Flash Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-12",releaseDate:"2025-12-16",lastUpdated:"2025-12-16",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:262144,output:65536}},{id:"mimo-v2-omni-free",label:"MiMo V2 Omni Free",modalities:{input:["text","image","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:262144,output:64e3}},{id:"mimo-v2-pro-free",label:"MiMo V2 Pro Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:1048576,output:64e3}},{id:"minimax-m2.1",ownedBy:"minimax",label:"MiniMax M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"minimax-m2.1-free",ownedBy:"minimax",label:"MiniMax M2.1 Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072},provider:{npm:"@ai-sdk/anthropic"}},{id:"minimax-m2.5",ownedBy:"minimax",label:"MiniMax M2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06},limit:{context:204800,output:131072}},{id:"minimax-m2.5-free",ownedBy:"minimax",label:"MiniMax M2.5 Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072},provider:{npm:"@ai-sdk/anthropic"}},{id:"minimax-m2.7",ownedBy:"minimax",label:"MiniMax M2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06},limit:{context:204800,output:131072}},{id:"nemotron-3-super-free",label:"Nemotron 3 Super Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2026-02",releaseDate:"2026-03-11",lastUpdated:"2026-03-11",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:128e3}},{id:"qwen3-coder",label:"Qwen3 Coder",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.45,output:1.8},limit:{context:262144,output:65536}},{id:"qwen3.5-plus",label:"Qwen3.5 Plus",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-16",lastUpdated:"2026-02-16",openWeights:!1,cost:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25},limit:{context:262144,output:65536},provider:{npm:"@ai-sdk/anthropic"}},{id:"qwen3.6-plus",label:"Qwen3.6 Plus",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05,cacheWrite:.625},limit:{context:262144,output:65536},provider:{npm:"@ai-sdk/anthropic"}},{id:"qwen3.6-plus-free",label:"Qwen3.6 Plus Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-30",lastUpdated:"2026-03-30",openWeights:!1,cost:{input:0,output:0,cacheRead:0},limit:{context:1048576,output:64e3}},{id:"trinity-large-preview-free",label:"Trinity Large Preview",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-28",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}}],label:"OpenCode Zen",env:["OPENCODE_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://opencode.ai/zen/v1",doc:"https://opencode.ai/docs/zen"},xai:{id:"xai",models:[{id:"grok-2",ownedBy:"xai",label:"Grok 2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2024-08-20",lastUpdated:"2024-08-20",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:131072,output:8192}},{id:"grok-2-1212",ownedBy:"xai",label:"Grok 2 (1212)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2024-12-12",lastUpdated:"2024-12-12",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:131072,output:8192}},{id:"grok-2-latest",ownedBy:"xai",label:"Grok 2 Latest",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2024-08-20",lastUpdated:"2024-12-12",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:131072,output:8192}},{id:"grok-2-vision",ownedBy:"xai",label:"Grok 2 Vision",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-08",releaseDate:"2024-08-20",lastUpdated:"2024-08-20",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:8192,output:4096}},{id:"grok-2-vision-1212",ownedBy:"xai",label:"Grok 2 Vision (1212)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-08",releaseDate:"2024-08-20",lastUpdated:"2024-12-12",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:8192,output:4096}},{id:"grok-2-vision-latest",ownedBy:"xai",label:"Grok 2 Vision Latest",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-08",releaseDate:"2024-08-20",lastUpdated:"2024-12-12",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:8192,output:4096}},{id:"grok-3",ownedBy:"xai",label:"Grok 3",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75},limit:{context:131072,output:8192}},{id:"grok-3-fast",ownedBy:"xai",label:"Grok 3 Fast",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:5,output:25,cacheRead:1.25},limit:{context:131072,output:8192}},{id:"grok-3-fast-latest",ownedBy:"xai",label:"Grok 3 Fast Latest",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:5,output:25,cacheRead:1.25},limit:{context:131072,output:8192}},{id:"grok-3-latest",ownedBy:"xai",label:"Grok 3 Latest",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75},limit:{context:131072,output:8192}},{id:"grok-3-mini",ownedBy:"xai",label:"Grok 3 Mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075},limit:{context:131072,output:8192}},{id:"grok-3-mini-fast",ownedBy:"xai",label:"Grok 3 Mini Fast",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.6,output:4,cacheRead:.15},limit:{context:131072,output:8192}},{id:"grok-3-mini-fast-latest",ownedBy:"xai",label:"Grok 3 Mini Fast Latest",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.6,output:4,cacheRead:.15},limit:{context:131072,output:8192}},{id:"grok-3-mini-latest",ownedBy:"xai",label:"Grok 3 Mini Latest",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075},limit:{context:131072,output:8192}},{id:"grok-4",ownedBy:"xai",label:"Grok 4",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!1,cost:{input:3,output:15,cacheRead:.75},limit:{context:256e3,output:64e3}},{id:"grok-4-1-fast",ownedBy:"xai",label:"Grok 4.1 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07",releaseDate:"2025-11-19",lastUpdated:"2025-11-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05},limit:{context:2e6,output:3e4}},{id:"grok-4-1-fast-non-reasoning",ownedBy:"xai",label:"Grok 4.1 Fast (Non-Reasoning)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-07",releaseDate:"2025-11-19",lastUpdated:"2025-11-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05},limit:{context:2e6,output:3e4}},{id:"grok-4-fast",ownedBy:"xai",label:"Grok 4 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-19",lastUpdated:"2025-09-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05},limit:{context:2e6,output:3e4}},{id:"grok-4-fast-non-reasoning",ownedBy:"xai",label:"Grok 4 Fast (Non-Reasoning)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-19",lastUpdated:"2025-09-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05},limit:{context:2e6,output:3e4}},{id:"grok-4.20-0309-non-reasoning",ownedBy:"xai",label:"Grok 4.20 (Non-Reasoning)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,releaseDate:"2026-03-09",lastUpdated:"2026-03-09",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"grok-4.20-0309-reasoning",ownedBy:"xai",label:"Grok 4.20 (Reasoning)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-09",lastUpdated:"2026-03-09",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"grok-4.20-multi-agent-0309",ownedBy:"xai",label:"Grok 4.20 Multi-Agent",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-09",lastUpdated:"2026-03-09",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"grok-4.3",ownedBy:"xai",label:"Grok 4.3",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-05-01",lastUpdated:"2026-05-01",openWeights:!1,cost:{input:1.25,output:2.5,cacheRead:.2},limit:{context:1e6,output:3e4}},{id:"grok-beta",ownedBy:"xai",label:"Grok Beta",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2024-11-01",lastUpdated:"2024-11-01",openWeights:!1,cost:{input:5,output:15,cacheRead:5},limit:{context:131072,output:4096}},{id:"grok-code-fast-1",ownedBy:"xai",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-10",releaseDate:"2025-08-28",lastUpdated:"2025-08-28",openWeights:!1,cost:{input:.2,output:1.5,cacheRead:.02},limit:{context:256e3,output:1e4}},{id:"grok-vision-beta",ownedBy:"xai",label:"Grok Vision Beta",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-08",releaseDate:"2024-11-01",lastUpdated:"2024-11-01",openWeights:!1,cost:{input:5,output:15,cacheRead:5},limit:{context:8192,output:4096}}],label:"xAI",env:["XAI_API_KEY"],npm:"@ai-sdk/xai",doc:"https://docs.x.ai/docs/models"},zai:{id:"zai",models:[{id:"glm-4.5",ownedBy:"zai",label:"GLM-4.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-air",ownedBy:"zai",label:"GLM-4.5-Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.2,output:1.1,cacheRead:.03,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-flash",ownedBy:"zai",label:"GLM-4.5-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5v",ownedBy:"zai",label:"GLM-4.5V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-08-11",lastUpdated:"2025-08-11",openWeights:!0,cost:{input:.6,output:1.8},limit:{context:64e3,output:16384}},{id:"glm-4.6",ownedBy:"zai",label:"GLM-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-4.6v",ownedBy:"zai",label:"GLM-4.6V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-08",lastUpdated:"2025-12-08",openWeights:!0,cost:{input:.3,output:.9},limit:{context:128e3,output:32768}},{id:"glm-4.7",ownedBy:"zai",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-4.7-flash",ownedBy:"zai",label:"GLM-4.7-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-01-19",lastUpdated:"2026-01-19",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-4.7-flashx",ownedBy:"zai",label:"GLM-4.7-FlashX",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-01-19",lastUpdated:"2026-01-19",openWeights:!0,cost:{input:.07,output:.4,cacheRead:.01,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5",ownedBy:"zai",label:"GLM-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-5-turbo",ownedBy:"zai",label:"GLM-5-Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!1,cost:{input:1.2,output:4,cacheRead:.24,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-27",lastUpdated:"2026-03-27",openWeights:!1,cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5v-turbo",ownedBy:"zai",label:"GLM-5V-Turbo",modalities:{input:["text","image","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-01",lastUpdated:"2026-04-01",openWeights:!1,cost:{input:1.2,output:4,cacheRead:.24,cacheWrite:0},limit:{context:2e5,output:131072}}],label:"Z.AI",env:["ZHIPU_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.z.ai/api/paas/v4",doc:"https://docs.z.ai/guides/overview/pricing"},"zai-coding":{id:"zai-coding",models:[{id:"glm-4.5-air",ownedBy:"zai",label:"GLM-4.5-Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.7",ownedBy:"zai",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-5-turbo",ownedBy:"zai",label:"GLM-5-Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-27",lastUpdated:"2026-03-27",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5v-turbo",ownedBy:"zai",label:"GLM-5V-Turbo",modalities:{input:["text","image","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-01",lastUpdated:"2026-04-01",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}}],label:"Z.AI Coding Plan",env:["ZHIPU_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.z.ai/api/coding/paas/v4",doc:"https://docs.z.ai/devpack/overview"},moonshot:{id:"moonshot",models:[{id:"kimi-k2-0711-preview",ownedBy:"moonshot",label:"Kimi K2 0711",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-07-14",lastUpdated:"2025-07-14",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:131072,output:16384}},{id:"kimi-k2-0905-preview",ownedBy:"moonshot",label:"Kimi K2 0905",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking",ownedBy:"moonshot",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking-turbo",ownedBy:"moonshot",label:"Kimi K2 Thinking Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:1.15,output:8,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-turbo-preview",ownedBy:"moonshot",label:"Kimi K2 Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:2.4,output:10,cacheRead:.6},limit:{context:262144,output:262144}},{id:"kimi-k2.5",ownedBy:"moonshot",label:"Kimi K2.5",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2026-01",lastUpdated:"2026-01",openWeights:!0,cost:{input:.6,output:3,cacheRead:.1},limit:{context:262144,output:262144}},{id:"kimi-k2.6",ownedBy:"moonshot",label:"Kimi K2.6",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-21",lastUpdated:"2026-04-21",openWeights:!0,cost:{input:.95,output:4,cacheRead:.16},limit:{context:262144,output:262144}}],label:"Moonshot AI",env:["MOONSHOT_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.moonshot.ai/v1",doc:"https://platform.moonshot.ai/docs/api/chat"},minimax:{id:"minimax",models:[{id:"MiniMax-M2",ownedBy:"minimax",label:"MiniMax-M2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-10-27",lastUpdated:"2025-10-27",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:196608,output:128e3}},{id:"MiniMax-M2.1",ownedBy:"minimax",label:"MiniMax-M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:204800,output:131072}},{id:"MiniMax-M2.5",ownedBy:"minimax",label:"MiniMax-M2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},limit:{context:204800,output:131072}},{id:"MiniMax-M2.5-highspeed",ownedBy:"minimax",label:"MiniMax-M2.5-highspeed",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-13",lastUpdated:"2026-02-13",openWeights:!0,cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}},{id:"MiniMax-M2.7",ownedBy:"minimax",label:"MiniMax-M2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}},{id:"MiniMax-M2.7-highspeed",ownedBy:"minimax",label:"MiniMax-M2.7-highspeed",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}}],label:"MiniMax (minimax.io)",env:["MINIMAX_API_KEY"],npm:"@ai-sdk/anthropic",api:"https://api.minimax.io/anthropic/v1",doc:"https://platform.minimax.io/docs/guides/quickstart"},copilot:{id:"copilot",models:[{id:"claude-haiku-4.5",ownedBy:"anthropic",label:"Claude Haiku 4.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:0,output:0},limit:{context:144e3,output:32e3}},{id:"claude-opus-4.5",ownedBy:"anthropic",label:"Claude Opus 4.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-24",lastUpdated:"2025-08-01",openWeights:!1,cost:{input:0,output:0},limit:{context:16e4,output:32e3}},{id:"claude-opus-4.6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:0,output:0},limit:{context:144e3,output:64e3}},{id:"claude-opus-4.7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:0,output:0},limit:{context:144e3,output:64e3}},{id:"claude-opus-41",ownedBy:"anthropic",label:"Claude Opus 4.1",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:0,output:0},limit:{context:8e4,output:16e3}},{id:"claude-sonnet-4",ownedBy:"anthropic",label:"Claude Sonnet 4",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:0,output:0},limit:{context:216e3,output:16e3}},{id:"claude-sonnet-4.5",ownedBy:"anthropic",label:"Claude Sonnet 4.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:0,output:0},limit:{context:144e3,output:32e3}},{id:"claude-sonnet-4.6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-02-17",openWeights:!1,cost:{input:0,output:0},limit:{context:2e5,output:32e3}},{id:"gemini-2.5-pro",ownedBy:"google",label:"Gemini 2.5 Pro",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}},{id:"gemini-3-flash-preview",ownedBy:"google",label:"Gemini 3 Flash",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}},{id:"gemini-3-pro-preview",ownedBy:"google",label:"Gemini 3 Pro Preview",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11-18",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}},{id:"gemini-3.1-pro-preview",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}},{id:"gpt-4.1",ownedBy:"openai",label:"GPT-4.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:16384}},{id:"gpt-4o",ownedBy:"openai",label:"GPT-4o",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-05-13",lastUpdated:"2024-05-13",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:4096}},{id:"gpt-5",ownedBy:"openai",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:128e3}},{id:"gpt-5-mini",ownedBy:"openai",label:"GPT-5-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-08-13",lastUpdated:"2025-08-13",openWeights:!1,cost:{input:0,output:0},limit:{context:264e3,output:64e3}},{id:"gpt-5.1",ownedBy:"openai",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:0,output:0},limit:{context:264e3,output:64e3}},{id:"gpt-5.1-codex",ownedBy:"openai",label:"GPT-5.1-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-max",ownedBy:"openai",label:"GPT-5.1-Codex-max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-12-04",lastUpdated:"2025-12-04",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-mini",ownedBy:"openai",label:"GPT-5.1-Codex-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.2",ownedBy:"openai",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:0,output:0},limit:{context:264e3,output:64e3}},{id:"gpt-5.2-codex",ownedBy:"openai",label:"GPT-5.2-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.3-codex",ownedBy:"openai",label:"GPT-5.3-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-24",lastUpdated:"2026-02-24",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.5",ownedBy:"openai",label:"GPT-5.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-04-22",lastUpdated:"2026-04-22",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"grok-code-fast-1",ownedBy:"xai",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-08",releaseDate:"2025-08-27",lastUpdated:"2025-08-27",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}}],label:"GitHub Copilot",env:["GITHUB_TOKEN"],npm:"@ai-sdk/openai-compatible",api:"https://api.githubcopilot.com",doc:"https://docs.github.com/en/copilot"},"ollama-cloud":{id:"ollama-cloud",models:[{id:"cogito-2.1:671b",label:"cogito-2.1:671b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-11-19",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:163840,output:32e3}},{id:"deepseek-v3.1:671b",label:"deepseek-v3.1:671b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-08-21",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:163840,output:163840}},{id:"deepseek-v3.2",label:"deepseek-v3.2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-06-15",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:163840,output:65536}},{id:"deepseek-v4-flash",label:"deepseek-v4-flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!0,limit:{context:1048576,output:1048576}},{id:"deepseek-v4-pro",label:"deepseek-v4-pro",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!0,limit:{context:1048576,output:1048576}},{id:"devstral-2:123b",label:"devstral-2:123b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-12-09",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"devstral-small-2:24b",label:"devstral-small-2:24b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2025-12-09",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"gemini-3-flash-preview",ownedBy:"google",label:"gemini-3-flash-preview",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2026-04-08",openWeights:!0,limit:{context:1048576,output:65536}},{id:"gemma3:12b",label:"gemma3:12b",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:131072}},{id:"gemma3:27b",label:"gemma3:27b",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,releaseDate:"2025-07-27",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:131072}},{id:"gemma3:4b",label:"gemma3:4b",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:131072}},{id:"gemma4:31b",label:"gemma4:31b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,knowledge:"2025-01",releaseDate:"2026-04-02",lastUpdated:"2026-04-08",openWeights:!0,limit:{context:262144,output:262144}},{id:"glm-4.6",ownedBy:"zai",label:"glm-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-09-29",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:202752,output:131072}},{id:"glm-4.7",ownedBy:"zai",label:"glm-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-12-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:202752,output:131072}},{id:"glm-5",ownedBy:"zai",label:"glm-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,limit:{context:202752,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"glm-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-03-27",lastUpdated:"2026-04-07",openWeights:!0,limit:{context:202752,output:131072}},{id:"gpt-oss:120b",ownedBy:"openai",label:"gpt-oss:120b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-08-05",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:32768}},{id:"gpt-oss:20b",ownedBy:"openai",label:"gpt-oss:20b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-08-05",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:32768}},{id:"kimi-k2-thinking",ownedBy:"moonshot",label:"kimi-k2-thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"kimi-k2:1t",ownedBy:"moonshot",label:"kimi-k2:1t",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,knowledge:"2024-10",releaseDate:"2025-07-11",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"kimi-k2.5",ownedBy:"moonshot",label:"kimi-k2.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,limit:{context:262144,output:262144}},{id:"kimi-k2.6:cloud",ownedBy:"moonshot",label:"kimi-k2.6:cloud",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2026-04-20",lastUpdated:"2026-04-20",openWeights:!0,limit:{context:262144,output:262144}},{id:"minimax-m2",ownedBy:"minimax",label:"minimax-m2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-10-23",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:204800,output:128e3}},{id:"minimax-m2.1",ownedBy:"minimax",label:"minimax-m2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-12-23",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:204800,output:131072}},{id:"minimax-m2.5",ownedBy:"minimax",label:"minimax-m2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,knowledge:"2025-01",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,limit:{context:204800,output:131072}},{id:"minimax-m2.7",ownedBy:"minimax",label:"minimax-m2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,limit:{context:196608,output:196608}},{id:"ministral-3:14b",label:"ministral-3:14b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:128e3}},{id:"ministral-3:3b",label:"ministral-3:3b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2024-10-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:128e3}},{id:"ministral-3:8b",label:"ministral-3:8b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:128e3}},{id:"mistral-large-3:675b",label:"mistral-large-3:675b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2025-12-02",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"nemotron-3-nano:30b",label:"nemotron-3-nano:30b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-12-15",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:1048576,output:131072}},{id:"nemotron-3-super",label:"nemotron-3-super",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-03-11",lastUpdated:"2026-03-12",openWeights:!0,limit:{context:262144,output:65536}},{id:"qwen3-coder-next",label:"qwen3-coder-next",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2026-02-02",lastUpdated:"2026-02-08",openWeights:!0,limit:{context:262144,output:65536}},{id:"qwen3-coder:480b",label:"qwen3-coder:480b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-07-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:65536}},{id:"qwen3-next:80b",label:"qwen3-next:80b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-09-15",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:32768}},{id:"qwen3-vl:235b",label:"qwen3-vl:235b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2025-09-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:32768}},{id:"qwen3-vl:235b-instruct",label:"qwen3-vl:235b-instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2025-09-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:131072}},{id:"qwen3.5:397b",label:"qwen3.5:397b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2026-02-15",lastUpdated:"2026-02-17",openWeights:!0,limit:{context:262144,output:65536}},{id:"rnj-1:8b",label:"rnj-1:8b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-12-06",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:32768,output:4096}}],label:"Ollama Cloud",env:["OLLAMA_API_KEY"],npm:"ai-sdk-ollama",api:"https://ollama.com",doc:"https://docs.ollama.com/cloud"}};var ki={},cr={},Zl;function ex(){if(Zl)return cr;Zl=1,cr.byteLength=a,cr.toByteArray=Q,cr.fromByteArray=E;for(var A=[],e=[],t=typeof Uint8Array<"u"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,r=s.length;n<r;++n)A[n]=s[n],e[s.charCodeAt(n)]=n;e[45]=62,e[95]=63;function i(c){var h=c.length;if(h%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=c.indexOf("=");f===-1&&(f=h);var d=f===h?0:4-f%4;return[f,d]}function a(c){var h=i(c),f=h[0],d=h[1];return(f+d)*3/4-d}function g(c,h,f){return(h+f)*3/4-f}function Q(c){var h,f=i(c),d=f[0],D=f[1],R=new t(g(c,d,D)),M=0,q=D>0?d-4:d,G;for(G=0;G<q;G+=4)h=e[c.charCodeAt(G)]<<18|e[c.charCodeAt(G+1)]<<12|e[c.charCodeAt(G+2)]<<6|e[c.charCodeAt(G+3)],R[M++]=h>>16&255,R[M++]=h>>8&255,R[M++]=h&255;return D===2&&(h=e[c.charCodeAt(G)]<<2|e[c.charCodeAt(G+1)]>>4,R[M++]=h&255),D===1&&(h=e[c.charCodeAt(G)]<<10|e[c.charCodeAt(G+1)]<<4|e[c.charCodeAt(G+2)]>>2,R[M++]=h>>8&255,R[M++]=h&255),R}function B(c){return A[c>>18&63]+A[c>>12&63]+A[c>>6&63]+A[c&63]}function u(c,h,f){for(var d,D=[],R=h;R<f;R+=3)d=(c[R]<<16&16711680)+(c[R+1]<<8&65280)+(c[R+2]&255),D.push(B(d));return D.join("")}function E(c){for(var h,f=c.length,d=f%3,D=[],R=16383,M=0,q=f-d;M<q;M+=R)D.push(u(c,M,M+R>q?q:M+R));return d===1?(h=c[f-1],D.push(A[h>>2]+A[h<<4&63]+"==")):d===2&&(h=(c[f-2]<<8)+c[f-1],D.push(A[h>>10]+A[h>>4&63]+A[h<<2&63]+"=")),D.join("")}return cr}var on={};var Xl;function tx(){return Xl||(Xl=1,on.read=function(A,e,t,s,n){var r,i,a=n*8-s-1,g=(1<<a)-1,Q=g>>1,B=-7,u=t?n-1:0,E=t?-1:1,c=A[e+u];for(u+=E,r=c&(1<<-B)-1,c>>=-B,B+=a;B>0;r=r*256+A[e+u],u+=E,B-=8);for(i=r&(1<<-B)-1,r>>=-B,B+=s;B>0;i=i*256+A[e+u],u+=E,B-=8);if(r===0)r=1-Q;else{if(r===g)return i?NaN:(c?-1:1)*(1/0);i=i+Math.pow(2,s),r=r-Q}return(c?-1:1)*i*Math.pow(2,r-s)},on.write=function(A,e,t,s,n,r){var i,a,g,Q=r*8-n-1,B=(1<<Q)-1,u=B>>1,E=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,c=s?0:r-1,h=s?1:-1,f=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,i=B):(i=Math.floor(Math.log(e)/Math.LN2),e*(g=Math.pow(2,-i))<1&&(i--,g*=2),i+u>=1?e+=E/g:e+=E*Math.pow(2,1-u),e*g>=2&&(i++,g/=2),i+u>=B?(a=0,i=B):i+u>=1?(a=(e*g-1)*Math.pow(2,n),i=i+u):(a=e*Math.pow(2,u-1)*Math.pow(2,n),i=0));n>=8;A[t+c]=a&255,c+=h,a/=256,n-=8);for(i=i<<n|a,Q+=n;Q>0;A[t+c]=i&255,c+=h,i/=256,Q-=8);A[t+c-h]|=f*128}),on}var $l;function Fg(){return $l||($l=1,(function(A){const e=ex(),t=tx(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;A.Buffer=a,A.SlowBuffer=R,A.INSPECT_MAX_BYTES=50;const n=2147483647;A.kMaxLength=n,a.TYPED_ARRAY_SUPPORT=r(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function r(){try{const P=new Uint8Array(1),N={foo:function(){return 42}};return Object.setPrototypeOf(N,Uint8Array.prototype),Object.setPrototypeOf(P,N),P.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function i(P){if(P>n)throw new RangeError('The value "'+P+'" is invalid for option "size"');const N=new Uint8Array(P);return Object.setPrototypeOf(N,a.prototype),N}function a(P,N,k){if(typeof P=="number"){if(typeof N=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return u(P)}return g(P,N,k)}a.poolSize=8192;function g(P,N,k){if(typeof P=="string")return E(P,N);if(ArrayBuffer.isView(P))return h(P);if(P==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P);if(nt(P,ArrayBuffer)||P&&nt(P.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(nt(P,SharedArrayBuffer)||P&&nt(P.buffer,SharedArrayBuffer)))return f(P,N,k);if(typeof P=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const _=P.valueOf&&P.valueOf();if(_!=null&&_!==P)return a.from(_,N,k);const tA=d(P);if(tA)return tA;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof P[Symbol.toPrimitive]=="function")return a.from(P[Symbol.toPrimitive]("string"),N,k);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P)}a.from=function(P,N,k){return g(P,N,k)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function Q(P){if(typeof P!="number")throw new TypeError('"size" argument must be of type number');if(P<0)throw new RangeError('The value "'+P+'" is invalid for option "size"')}function B(P,N,k){return Q(P),P<=0?i(P):N!==void 0?typeof k=="string"?i(P).fill(N,k):i(P).fill(N):i(P)}a.alloc=function(P,N,k){return B(P,N,k)};function u(P){return Q(P),i(P<0?0:D(P)|0)}a.allocUnsafe=function(P){return u(P)},a.allocUnsafeSlow=function(P){return u(P)};function E(P,N){if((typeof N!="string"||N==="")&&(N="utf8"),!a.isEncoding(N))throw new TypeError("Unknown encoding: "+N);const k=M(P,N)|0;let _=i(k);const tA=_.write(P,N);return tA!==k&&(_=_.slice(0,tA)),_}function c(P){const N=P.length<0?0:D(P.length)|0,k=i(N);for(let _=0;_<N;_+=1)k[_]=P[_]&255;return k}function h(P){if(nt(P,Uint8Array)){const N=new Uint8Array(P);return f(N.buffer,N.byteOffset,N.byteLength)}return c(P)}function f(P,N,k){if(N<0||P.byteLength<N)throw new RangeError('"offset" is outside of buffer bounds');if(P.byteLength<N+(k||0))throw new RangeError('"length" is outside of buffer bounds');let _;return N===void 0&&k===void 0?_=new Uint8Array(P):k===void 0?_=new Uint8Array(P,N):_=new Uint8Array(P,N,k),Object.setPrototypeOf(_,a.prototype),_}function d(P){if(a.isBuffer(P)){const N=D(P.length)|0,k=i(N);return k.length===0||P.copy(k,0,0,N),k}if(P.length!==void 0)return typeof P.length!="number"||Le(P.length)?i(0):c(P);if(P.type==="Buffer"&&Array.isArray(P.data))return c(P.data)}function D(P){if(P>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return P|0}function R(P){return+P!=P&&(P=0),a.alloc(+P)}a.isBuffer=function(N){return N!=null&&N._isBuffer===!0&&N!==a.prototype},a.compare=function(N,k){if(nt(N,Uint8Array)&&(N=a.from(N,N.offset,N.byteLength)),nt(k,Uint8Array)&&(k=a.from(k,k.offset,k.byteLength)),!a.isBuffer(N)||!a.isBuffer(k))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(N===k)return 0;let _=N.length,tA=k.length;for(let aA=0,EA=Math.min(_,tA);aA<EA;++aA)if(N[aA]!==k[aA]){_=N[aA],tA=k[aA];break}return _<tA?-1:tA<_?1:0},a.isEncoding=function(N){switch(String(N).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(N,k){if(!Array.isArray(N))throw new TypeError('"list" argument must be an Array of Buffers');if(N.length===0)return a.alloc(0);let _;if(k===void 0)for(k=0,_=0;_<N.length;++_)k+=N[_].length;const tA=a.allocUnsafe(k);let aA=0;for(_=0;_<N.length;++_){let EA=N[_];if(nt(EA,Uint8Array))aA+EA.length>tA.length?(a.isBuffer(EA)||(EA=a.from(EA)),EA.copy(tA,aA)):Uint8Array.prototype.set.call(tA,EA,aA);else if(a.isBuffer(EA))EA.copy(tA,aA);else throw new TypeError('"list" argument must be an Array of Buffers');aA+=EA.length}return tA};function M(P,N){if(a.isBuffer(P))return P.length;if(ArrayBuffer.isView(P)||nt(P,ArrayBuffer))return P.byteLength;if(typeof P!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof P);const k=P.length,_=arguments.length>2&&arguments[2]===!0;if(!_&&k===0)return 0;let tA=!1;for(;;)switch(N){case"ascii":case"latin1":case"binary":return k;case"utf8":case"utf-8":return _A(P).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k*2;case"hex":return k>>>1;case"base64":return de(P).length;default:if(tA)return _?-1:_A(P).length;N=(""+N).toLowerCase(),tA=!0}}a.byteLength=M;function q(P,N,k){let _=!1;if((N===void 0||N<0)&&(N=0),N>this.length||((k===void 0||k>this.length)&&(k=this.length),k<=0)||(k>>>=0,N>>>=0,k<=N))return"";for(P||(P="utf8");;)switch(P){case"hex":return H(this,N,k);case"utf8":case"utf-8":return l(this,N,k);case"ascii":return b(this,N,k);case"latin1":case"binary":return J(this,N,k);case"base64":return x(this,N,k);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,N,k);default:if(_)throw new TypeError("Unknown encoding: "+P);P=(P+"").toLowerCase(),_=!0}}a.prototype._isBuffer=!0;function G(P,N,k){const _=P[N];P[N]=P[k],P[k]=_}a.prototype.swap16=function(){const N=this.length;if(N%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let k=0;k<N;k+=2)G(this,k,k+1);return this},a.prototype.swap32=function(){const N=this.length;if(N%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let k=0;k<N;k+=4)G(this,k,k+3),G(this,k+1,k+2);return this},a.prototype.swap64=function(){const N=this.length;if(N%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let k=0;k<N;k+=8)G(this,k,k+7),G(this,k+1,k+6),G(this,k+2,k+5),G(this,k+3,k+4);return this},a.prototype.toString=function(){const N=this.length;return N===0?"":arguments.length===0?l(this,0,N):q.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(N){if(!a.isBuffer(N))throw new TypeError("Argument must be a Buffer");return this===N?!0:a.compare(this,N)===0},a.prototype.inspect=function(){let N="";const k=A.INSPECT_MAX_BYTES;return N=this.toString("hex",0,k).replace(/(.{2})/g,"$1 ").trim(),this.length>k&&(N+=" ... "),"<Buffer "+N+">"},s&&(a.prototype[s]=a.prototype.inspect),a.prototype.compare=function(N,k,_,tA,aA){if(nt(N,Uint8Array)&&(N=a.from(N,N.offset,N.byteLength)),!a.isBuffer(N))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof N);if(k===void 0&&(k=0),_===void 0&&(_=N?N.length:0),tA===void 0&&(tA=0),aA===void 0&&(aA=this.length),k<0||_>N.length||tA<0||aA>this.length)throw new RangeError("out of range index");if(tA>=aA&&k>=_)return 0;if(tA>=aA)return-1;if(k>=_)return 1;if(k>>>=0,_>>>=0,tA>>>=0,aA>>>=0,this===N)return 0;let EA=aA-tA,ZA=_-k;const VA=Math.min(EA,ZA),$A=this.slice(tA,aA),ke=N.slice(k,_);for(let XA=0;XA<VA;++XA)if($A[XA]!==ke[XA]){EA=$A[XA],ZA=ke[XA];break}return EA<ZA?-1:ZA<EA?1:0};function T(P,N,k,_,tA){if(P.length===0)return-1;if(typeof k=="string"?(_=k,k=0):k>2147483647?k=2147483647:k<-2147483648&&(k=-2147483648),k=+k,Le(k)&&(k=tA?0:P.length-1),k<0&&(k=P.length+k),k>=P.length){if(tA)return-1;k=P.length-1}else if(k<0)if(tA)k=0;else return-1;if(typeof N=="string"&&(N=a.from(N,_)),a.isBuffer(N))return N.length===0?-1:Z(P,N,k,_,tA);if(typeof N=="number")return N=N&255,typeof Uint8Array.prototype.indexOf=="function"?tA?Uint8Array.prototype.indexOf.call(P,N,k):Uint8Array.prototype.lastIndexOf.call(P,N,k):Z(P,[N],k,_,tA);throw new TypeError("val must be string, number or Buffer")}function Z(P,N,k,_,tA){let aA=1,EA=P.length,ZA=N.length;if(_!==void 0&&(_=String(_).toLowerCase(),_==="ucs2"||_==="ucs-2"||_==="utf16le"||_==="utf-16le")){if(P.length<2||N.length<2)return-1;aA=2,EA/=2,ZA/=2,k/=2}function VA(ke,XA){return aA===1?ke[XA]:ke.readUInt16BE(XA*aA)}let $A;if(tA){let ke=-1;for($A=k;$A<EA;$A++)if(VA(P,$A)===VA(N,ke===-1?0:$A-ke)){if(ke===-1&&(ke=$A),$A-ke+1===ZA)return ke*aA}else ke!==-1&&($A-=$A-ke),ke=-1}else for(k+ZA>EA&&(k=EA-ZA),$A=k;$A>=0;$A--){let ke=!0;for(let XA=0;XA<ZA;XA++)if(VA(P,$A+XA)!==VA(N,XA)){ke=!1;break}if(ke)return $A}return-1}a.prototype.includes=function(N,k,_){return this.indexOf(N,k,_)!==-1},a.prototype.indexOf=function(N,k,_){return T(this,N,k,_,!0)},a.prototype.lastIndexOf=function(N,k,_){return T(this,N,k,_,!1)};function X(P,N,k,_){k=Number(k)||0;const tA=P.length-k;_?(_=Number(_),_>tA&&(_=tA)):_=tA;const aA=N.length;_>aA/2&&(_=aA/2);let EA;for(EA=0;EA<_;++EA){const ZA=parseInt(N.substr(EA*2,2),16);if(Le(ZA))return EA;P[k+EA]=ZA}return EA}function U(P,N,k,_){return Ke(_A(N,P.length-k),P,k,_)}function O(P,N,k,_){return Ke(we(N),P,k,_)}function j(P,N,k,_){return Ke(de(N),P,k,_)}function Y(P,N,k,_){return Ke(He(N,P.length-k),P,k,_)}a.prototype.write=function(N,k,_,tA){if(k===void 0)tA="utf8",_=this.length,k=0;else if(_===void 0&&typeof k=="string")tA=k,_=this.length,k=0;else if(isFinite(k))k=k>>>0,isFinite(_)?(_=_>>>0,tA===void 0&&(tA="utf8")):(tA=_,_=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const aA=this.length-k;if((_===void 0||_>aA)&&(_=aA),N.length>0&&(_<0||k<0)||k>this.length)throw new RangeError("Attempt to write outside buffer bounds");tA||(tA="utf8");let EA=!1;for(;;)switch(tA){case"hex":return X(this,N,k,_);case"utf8":case"utf-8":return U(this,N,k,_);case"ascii":case"latin1":case"binary":return O(this,N,k,_);case"base64":return j(this,N,k,_);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,N,k,_);default:if(EA)throw new TypeError("Unknown encoding: "+tA);tA=(""+tA).toLowerCase(),EA=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(P,N,k){return N===0&&k===P.length?e.fromByteArray(P):e.fromByteArray(P.slice(N,k))}function l(P,N,k){k=Math.min(P.length,k);const _=[];let tA=N;for(;tA<k;){const aA=P[tA];let EA=null,ZA=aA>239?4:aA>223?3:aA>191?2:1;if(tA+ZA<=k){let VA,$A,ke,XA;switch(ZA){case 1:aA<128&&(EA=aA);break;case 2:VA=P[tA+1],(VA&192)===128&&(XA=(aA&31)<<6|VA&63,XA>127&&(EA=XA));break;case 3:VA=P[tA+1],$A=P[tA+2],(VA&192)===128&&($A&192)===128&&(XA=(aA&15)<<12|(VA&63)<<6|$A&63,XA>2047&&(XA<55296||XA>57343)&&(EA=XA));break;case 4:VA=P[tA+1],$A=P[tA+2],ke=P[tA+3],(VA&192)===128&&($A&192)===128&&(ke&192)===128&&(XA=(aA&15)<<18|(VA&63)<<12|($A&63)<<6|ke&63,XA>65535&&XA<1114112&&(EA=XA))}}EA===null?(EA=65533,ZA=1):EA>65535&&(EA-=65536,_.push(EA>>>10&1023|55296),EA=56320|EA&1023),_.push(EA),tA+=ZA}return y(_)}const I=4096;function y(P){const N=P.length;if(N<=I)return String.fromCharCode.apply(String,P);let k="",_=0;for(;_<N;)k+=String.fromCharCode.apply(String,P.slice(_,_+=I));return k}function b(P,N,k){let _="";k=Math.min(P.length,k);for(let tA=N;tA<k;++tA)_+=String.fromCharCode(P[tA]&127);return _}function J(P,N,k){let _="";k=Math.min(P.length,k);for(let tA=N;tA<k;++tA)_+=String.fromCharCode(P[tA]);return _}function H(P,N,k){const _=P.length;(!N||N<0)&&(N=0),(!k||k<0||k>_)&&(k=_);let tA="";for(let aA=N;aA<k;++aA)tA+=kA[P[aA]];return tA}function v(P,N,k){const _=P.slice(N,k);let tA="";for(let aA=0;aA<_.length-1;aA+=2)tA+=String.fromCharCode(_[aA]+_[aA+1]*256);return tA}a.prototype.slice=function(N,k){const _=this.length;N=~~N,k=k===void 0?_:~~k,N<0?(N+=_,N<0&&(N=0)):N>_&&(N=_),k<0?(k+=_,k<0&&(k=0)):k>_&&(k=_),k<N&&(k=N);const tA=this.subarray(N,k);return Object.setPrototypeOf(tA,a.prototype),tA};function K(P,N,k){if(P%1!==0||P<0)throw new RangeError("offset is not uint");if(P+N>k)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(N,k,_){N=N>>>0,k=k>>>0,_||K(N,k,this.length);let tA=this[N],aA=1,EA=0;for(;++EA<k&&(aA*=256);)tA+=this[N+EA]*aA;return tA},a.prototype.readUintBE=a.prototype.readUIntBE=function(N,k,_){N=N>>>0,k=k>>>0,_||K(N,k,this.length);let tA=this[N+--k],aA=1;for(;k>0&&(aA*=256);)tA+=this[N+--k]*aA;return tA},a.prototype.readUint8=a.prototype.readUInt8=function(N,k){return N=N>>>0,k||K(N,1,this.length),this[N]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(N,k){return N=N>>>0,k||K(N,2,this.length),this[N]|this[N+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(N,k){return N=N>>>0,k||K(N,2,this.length),this[N]<<8|this[N+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(N,k){return N=N>>>0,k||K(N,4,this.length),(this[N]|this[N+1]<<8|this[N+2]<<16)+this[N+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(N,k){return N=N>>>0,k||K(N,4,this.length),this[N]*16777216+(this[N+1]<<16|this[N+2]<<8|this[N+3])},a.prototype.readBigUInt64LE=he(function(N){N=N>>>0,jA(N,"offset");const k=this[N],_=this[N+7];(k===void 0||_===void 0)&&HA(N,this.length-8);const tA=k+this[++N]*2**8+this[++N]*2**16+this[++N]*2**24,aA=this[++N]+this[++N]*2**8+this[++N]*2**16+_*2**24;return BigInt(tA)+(BigInt(aA)<<BigInt(32))}),a.prototype.readBigUInt64BE=he(function(N){N=N>>>0,jA(N,"offset");const k=this[N],_=this[N+7];(k===void 0||_===void 0)&&HA(N,this.length-8);const tA=k*2**24+this[++N]*2**16+this[++N]*2**8+this[++N],aA=this[++N]*2**24+this[++N]*2**16+this[++N]*2**8+_;return(BigInt(tA)<<BigInt(32))+BigInt(aA)}),a.prototype.readIntLE=function(N,k,_){N=N>>>0,k=k>>>0,_||K(N,k,this.length);let tA=this[N],aA=1,EA=0;for(;++EA<k&&(aA*=256);)tA+=this[N+EA]*aA;return aA*=128,tA>=aA&&(tA-=Math.pow(2,8*k)),tA},a.prototype.readIntBE=function(N,k,_){N=N>>>0,k=k>>>0,_||K(N,k,this.length);let tA=k,aA=1,EA=this[N+--tA];for(;tA>0&&(aA*=256);)EA+=this[N+--tA]*aA;return aA*=128,EA>=aA&&(EA-=Math.pow(2,8*k)),EA},a.prototype.readInt8=function(N,k){return N=N>>>0,k||K(N,1,this.length),this[N]&128?(255-this[N]+1)*-1:this[N]},a.prototype.readInt16LE=function(N,k){N=N>>>0,k||K(N,2,this.length);const _=this[N]|this[N+1]<<8;return _&32768?_|4294901760:_},a.prototype.readInt16BE=function(N,k){N=N>>>0,k||K(N,2,this.length);const _=this[N+1]|this[N]<<8;return _&32768?_|4294901760:_},a.prototype.readInt32LE=function(N,k){return N=N>>>0,k||K(N,4,this.length),this[N]|this[N+1]<<8|this[N+2]<<16|this[N+3]<<24},a.prototype.readInt32BE=function(N,k){return N=N>>>0,k||K(N,4,this.length),this[N]<<24|this[N+1]<<16|this[N+2]<<8|this[N+3]},a.prototype.readBigInt64LE=he(function(N){N=N>>>0,jA(N,"offset");const k=this[N],_=this[N+7];(k===void 0||_===void 0)&&HA(N,this.length-8);const tA=this[N+4]+this[N+5]*2**8+this[N+6]*2**16+(_<<24);return(BigInt(tA)<<BigInt(32))+BigInt(k+this[++N]*2**8+this[++N]*2**16+this[++N]*2**24)}),a.prototype.readBigInt64BE=he(function(N){N=N>>>0,jA(N,"offset");const k=this[N],_=this[N+7];(k===void 0||_===void 0)&&HA(N,this.length-8);const tA=(k<<24)+this[++N]*2**16+this[++N]*2**8+this[++N];return(BigInt(tA)<<BigInt(32))+BigInt(this[++N]*2**24+this[++N]*2**16+this[++N]*2**8+_)}),a.prototype.readFloatLE=function(N,k){return N=N>>>0,k||K(N,4,this.length),t.read(this,N,!0,23,4)},a.prototype.readFloatBE=function(N,k){return N=N>>>0,k||K(N,4,this.length),t.read(this,N,!1,23,4)},a.prototype.readDoubleLE=function(N,k){return N=N>>>0,k||K(N,8,this.length),t.read(this,N,!0,52,8)},a.prototype.readDoubleBE=function(N,k){return N=N>>>0,k||K(N,8,this.length),t.read(this,N,!1,52,8)};function C(P,N,k,_,tA,aA){if(!a.isBuffer(P))throw new TypeError('"buffer" argument must be a Buffer instance');if(N>tA||N<aA)throw new RangeError('"value" argument is out of bounds');if(k+_>P.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(N,k,_,tA){if(N=+N,k=k>>>0,_=_>>>0,!tA){const ZA=Math.pow(2,8*_)-1;C(this,N,k,_,ZA,0)}let aA=1,EA=0;for(this[k]=N&255;++EA<_&&(aA*=256);)this[k+EA]=N/aA&255;return k+_},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(N,k,_,tA){if(N=+N,k=k>>>0,_=_>>>0,!tA){const ZA=Math.pow(2,8*_)-1;C(this,N,k,_,ZA,0)}let aA=_-1,EA=1;for(this[k+aA]=N&255;--aA>=0&&(EA*=256);)this[k+aA]=N/EA&255;return k+_},a.prototype.writeUint8=a.prototype.writeUInt8=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,1,255,0),this[k]=N&255,k+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,2,65535,0),this[k]=N&255,this[k+1]=N>>>8,k+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,2,65535,0),this[k]=N>>>8,this[k+1]=N&255,k+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,4,4294967295,0),this[k+3]=N>>>24,this[k+2]=N>>>16,this[k+1]=N>>>8,this[k]=N&255,k+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,4,4294967295,0),this[k]=N>>>24,this[k+1]=N>>>16,this[k+2]=N>>>8,this[k+3]=N&255,k+4};function p(P,N,k,_,tA){lA(N,_,tA,P,k,7);let aA=Number(N&BigInt(4294967295));P[k++]=aA,aA=aA>>8,P[k++]=aA,aA=aA>>8,P[k++]=aA,aA=aA>>8,P[k++]=aA;let EA=Number(N>>BigInt(32)&BigInt(4294967295));return P[k++]=EA,EA=EA>>8,P[k++]=EA,EA=EA>>8,P[k++]=EA,EA=EA>>8,P[k++]=EA,k}function L(P,N,k,_,tA){lA(N,_,tA,P,k,7);let aA=Number(N&BigInt(4294967295));P[k+7]=aA,aA=aA>>8,P[k+6]=aA,aA=aA>>8,P[k+5]=aA,aA=aA>>8,P[k+4]=aA;let EA=Number(N>>BigInt(32)&BigInt(4294967295));return P[k+3]=EA,EA=EA>>8,P[k+2]=EA,EA=EA>>8,P[k+1]=EA,EA=EA>>8,P[k]=EA,k+8}a.prototype.writeBigUInt64LE=he(function(N,k=0){return p(this,N,k,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=he(function(N,k=0){return L(this,N,k,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(N,k,_,tA){if(N=+N,k=k>>>0,!tA){const VA=Math.pow(2,8*_-1);C(this,N,k,_,VA-1,-VA)}let aA=0,EA=1,ZA=0;for(this[k]=N&255;++aA<_&&(EA*=256);)N<0&&ZA===0&&this[k+aA-1]!==0&&(ZA=1),this[k+aA]=(N/EA>>0)-ZA&255;return k+_},a.prototype.writeIntBE=function(N,k,_,tA){if(N=+N,k=k>>>0,!tA){const VA=Math.pow(2,8*_-1);C(this,N,k,_,VA-1,-VA)}let aA=_-1,EA=1,ZA=0;for(this[k+aA]=N&255;--aA>=0&&(EA*=256);)N<0&&ZA===0&&this[k+aA+1]!==0&&(ZA=1),this[k+aA]=(N/EA>>0)-ZA&255;return k+_},a.prototype.writeInt8=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,1,127,-128),N<0&&(N=255+N+1),this[k]=N&255,k+1},a.prototype.writeInt16LE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,2,32767,-32768),this[k]=N&255,this[k+1]=N>>>8,k+2},a.prototype.writeInt16BE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,2,32767,-32768),this[k]=N>>>8,this[k+1]=N&255,k+2},a.prototype.writeInt32LE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,4,2147483647,-2147483648),this[k]=N&255,this[k+1]=N>>>8,this[k+2]=N>>>16,this[k+3]=N>>>24,k+4},a.prototype.writeInt32BE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,4,2147483647,-2147483648),N<0&&(N=4294967295+N+1),this[k]=N>>>24,this[k+1]=N>>>16,this[k+2]=N>>>8,this[k+3]=N&255,k+4},a.prototype.writeBigInt64LE=he(function(N,k=0){return p(this,N,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=he(function(N,k=0){return L(this,N,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function S(P,N,k,_,tA,aA){if(k+_>P.length)throw new RangeError("Index out of range");if(k<0)throw new RangeError("Index out of range")}function $(P,N,k,_,tA){return N=+N,k=k>>>0,tA||S(P,N,k,4),t.write(P,N,k,_,23,4),k+4}a.prototype.writeFloatLE=function(N,k,_){return $(this,N,k,!0,_)},a.prototype.writeFloatBE=function(N,k,_){return $(this,N,k,!1,_)};function AA(P,N,k,_,tA){return N=+N,k=k>>>0,tA||S(P,N,k,8),t.write(P,N,k,_,52,8),k+8}a.prototype.writeDoubleLE=function(N,k,_){return AA(this,N,k,!0,_)},a.prototype.writeDoubleBE=function(N,k,_){return AA(this,N,k,!1,_)},a.prototype.copy=function(N,k,_,tA){if(!a.isBuffer(N))throw new TypeError("argument should be a Buffer");if(_||(_=0),!tA&&tA!==0&&(tA=this.length),k>=N.length&&(k=N.length),k||(k=0),tA>0&&tA<_&&(tA=_),tA===_||N.length===0||this.length===0)return 0;if(k<0)throw new RangeError("targetStart out of bounds");if(_<0||_>=this.length)throw new RangeError("Index out of range");if(tA<0)throw new RangeError("sourceEnd out of bounds");tA>this.length&&(tA=this.length),N.length-k<tA-_&&(tA=N.length-k+_);const aA=tA-_;return this===N&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(k,_,tA):Uint8Array.prototype.set.call(N,this.subarray(_,tA),k),aA},a.prototype.fill=function(N,k,_,tA){if(typeof N=="string"){if(typeof k=="string"?(tA=k,k=0,_=this.length):typeof _=="string"&&(tA=_,_=this.length),tA!==void 0&&typeof tA!="string")throw new TypeError("encoding must be a string");if(typeof tA=="string"&&!a.isEncoding(tA))throw new TypeError("Unknown encoding: "+tA);if(N.length===1){const EA=N.charCodeAt(0);(tA==="utf8"&&EA<128||tA==="latin1")&&(N=EA)}}else typeof N=="number"?N=N&255:typeof N=="boolean"&&(N=Number(N));if(k<0||this.length<k||this.length<_)throw new RangeError("Out of range index");if(_<=k)return this;k=k>>>0,_=_===void 0?this.length:_>>>0,N||(N=0);let aA;if(typeof N=="number")for(aA=k;aA<_;++aA)this[aA]=N;else{const EA=a.isBuffer(N)?N:a.from(N,tA),ZA=EA.length;if(ZA===0)throw new TypeError('The value "'+N+'" is invalid for argument "value"');for(aA=0;aA<_-k;++aA)this[aA+k]=EA[aA%ZA]}return this};const sA={};function oA(P,N,k){sA[P]=class extends k{constructor(){super(),Object.defineProperty(this,"message",{value:N.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${P}]`,this.stack,delete this.name}get code(){return P}set code(tA){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:tA,writable:!0})}toString(){return`${this.name} [${P}]: ${this.message}`}}}oA("ERR_BUFFER_OUT_OF_BOUNDS",function(P){return P?`${P} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),oA("ERR_INVALID_ARG_TYPE",function(P,N){return`The "${P}" argument must be of type number. Received type ${typeof N}`},TypeError),oA("ERR_OUT_OF_RANGE",function(P,N,k){let _=`The value of "${P}" is out of range.`,tA=k;return Number.isInteger(k)&&Math.abs(k)>2**32?tA=bA(String(k)):typeof k=="bigint"&&(tA=String(k),(k>BigInt(2)**BigInt(32)||k<-(BigInt(2)**BigInt(32)))&&(tA=bA(tA)),tA+="n"),_+=` It must be ${N}. Received ${tA}`,_},RangeError);function bA(P){let N="",k=P.length;const _=P[0]==="-"?1:0;for(;k>=_+4;k-=3)N=`_${P.slice(k-3,k)}${N}`;return`${P.slice(0,k)}${N}`}function GA(P,N,k){jA(N,"offset"),(P[N]===void 0||P[N+k]===void 0)&&HA(N,P.length-(k+1))}function lA(P,N,k,_,tA,aA){if(P>k||P<N){const EA=typeof N=="bigint"?"n":"";let ZA;throw N===0||N===BigInt(0)?ZA=`>= 0${EA} and < 2${EA} ** ${(aA+1)*8}${EA}`:ZA=`>= -(2${EA} ** ${(aA+1)*8-1}${EA}) and < 2 ** ${(aA+1)*8-1}${EA}`,new sA.ERR_OUT_OF_RANGE("value",ZA,P)}GA(_,tA,aA)}function jA(P,N){if(typeof P!="number")throw new sA.ERR_INVALID_ARG_TYPE(N,"number",P)}function HA(P,N,k){throw Math.floor(P)!==P?(jA(P,k),new sA.ERR_OUT_OF_RANGE("offset","an integer",P)):N<0?new sA.ERR_BUFFER_OUT_OF_BOUNDS:new sA.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${N}`,P)}const ce=/[^+/0-9A-Za-z-_]/g;function NA(P){if(P=P.split("=")[0],P=P.trim().replace(ce,""),P.length<2)return"";for(;P.length%4!==0;)P=P+"=";return P}function _A(P,N){N=N||1/0;let k;const _=P.length;let tA=null;const aA=[];for(let EA=0;EA<_;++EA){if(k=P.charCodeAt(EA),k>55295&&k<57344){if(!tA){if(k>56319){(N-=3)>-1&&aA.push(239,191,189);continue}else if(EA+1===_){(N-=3)>-1&&aA.push(239,191,189);continue}tA=k;continue}if(k<56320){(N-=3)>-1&&aA.push(239,191,189),tA=k;continue}k=(tA-55296<<10|k-56320)+65536}else tA&&(N-=3)>-1&&aA.push(239,191,189);if(tA=null,k<128){if((N-=1)<0)break;aA.push(k)}else if(k<2048){if((N-=2)<0)break;aA.push(k>>6|192,k&63|128)}else if(k<65536){if((N-=3)<0)break;aA.push(k>>12|224,k>>6&63|128,k&63|128)}else if(k<1114112){if((N-=4)<0)break;aA.push(k>>18|240,k>>12&63|128,k>>6&63|128,k&63|128)}else throw new Error("Invalid code point")}return aA}function we(P){const N=[];for(let k=0;k<P.length;++k)N.push(P.charCodeAt(k)&255);return N}function He(P,N){let k,_,tA;const aA=[];for(let EA=0;EA<P.length&&!((N-=2)<0);++EA)k=P.charCodeAt(EA),_=k>>8,tA=k%256,aA.push(tA),aA.push(_);return aA}function de(P){return e.toByteArray(NA(P))}function Ke(P,N,k,_){let tA;for(tA=0;tA<_&&!(tA+k>=N.length||tA>=P.length);++tA)N[tA+k]=P[tA];return tA}function nt(P,N){return P instanceof N||P!=null&&P.constructor!=null&&P.constructor.name!=null&&P.constructor.name===N.name}function Le(P){return P!==P}const kA=(function(){const P="0123456789abcdef",N=new Array(256);for(let k=0;k<16;++k){const _=k*16;for(let tA=0;tA<16;++tA)N[_+tA]=P[k]+P[tA]}return N})();function he(P){return typeof BigInt>"u"?zA:P}function zA(){throw new Error("BigInt not supported")}})(ki)),ki}var xt=Fg();const Ks=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Yr(A){return A instanceof Uint8Array||ArrayBuffer.isView(A)&&A.constructor.name==="Uint8Array"}function va(A){if(!Number.isSafeInteger(A)||A<0)throw new Error("positive integer expected, got "+A)}function ks(A,...e){if(!Yr(A))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(A.length))throw new Error("Uint8Array expected of length "+e+", got length="+A.length)}function qc(A){if(typeof A!="function"||typeof A.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");va(A.outputLen),va(A.blockLen)}function Gn(A,e=!0){if(A.destroyed)throw new Error("Hash instance has been destroyed");if(e&&A.finished)throw new Error("Hash#digest() has already been called")}function ox(A,e){ks(A);const t=e.outputLen;if(A.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function _s(...A){for(let e=0;e<A.length;e++)A[e].fill(0)}function Mi(A){return new DataView(A.buffer,A.byteOffset,A.byteLength)}function vo(A,e){return A<<32-e|A>>>e}const Yc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",sx=Array.from({length:256},(A,e)=>e.toString(16).padStart(2,"0"));function ms(A){if(ks(A),Yc)return A.toHex();let e="";for(let t=0;t<A.length;t++)e+=sx[A[t]];return e}const qo={_0:48,_9:57,A:65,F:70,a:97,f:102};function AQ(A){if(A>=qo._0&&A<=qo._9)return A-qo._0;if(A>=qo.A&&A<=qo.F)return A-(qo.A-10);if(A>=qo.a&&A<=qo.f)return A-(qo.a-10)}function Sn(A){if(typeof A!="string")throw new Error("hex string expected, got "+typeof A);if(Yc)return Uint8Array.fromHex(A);const e=A.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const s=new Uint8Array(t);for(let n=0,r=0;n<t;n++,r+=2){const i=AQ(A.charCodeAt(r)),a=AQ(A.charCodeAt(r+1));if(i===void 0||a===void 0){const g=A[r]+A[r+1];throw new Error('hex string expected, got non-hex character "'+g+'" at index '+r)}s[n]=i*16+a}return s}function rx(A){if(typeof A!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(A))}function vg(A){return typeof A=="string"&&(A=rx(A)),ks(A),A}function Go(...A){let e=0;for(let s=0;s<A.length;s++){const n=A[s];ks(n),e+=n.length}const t=new Uint8Array(e);for(let s=0,n=0;s<A.length;s++){const r=A[s];t.set(r,n),n+=r.length}return t}class Hc{}function Pc(A){const e=s=>A().update(vg(s)).digest(),t=A();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>A(),e}function Gg(A=32){if(Ks&&typeof Ks.getRandomValues=="function")return Ks.getRandomValues(new Uint8Array(A));if(Ks&&typeof Ks.randomBytes=="function")return Uint8Array.from(Ks.randomBytes(A));throw new Error("crypto.getRandomValues must be defined")}function nx(A,e,t,s){if(typeof A.setBigUint64=="function")return A.setBigUint64(e,t,s);const n=BigInt(32),r=BigInt(4294967295),i=Number(t>>n&r),a=Number(t&r),g=s?4:0,Q=s?0:4;A.setUint32(e+g,i,s),A.setUint32(e+Q,a,s)}function ix(A,e,t){return A&e^~A&t}function ax(A,e,t){return A&e^A&t^e&t}class Wc extends Hc{constructor(e,t,s,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Mi(this.buffer)}update(e){Gn(this),e=vg(e),ks(e);const{view:t,buffer:s,blockLen:n}=this,r=e.length;for(let i=0;i<r;){const a=Math.min(n-this.pos,r-i);if(a===n){const g=Mi(e);for(;n<=r-i;i+=n)this.process(g,i);continue}s.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Gn(this),ox(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:n,isLE:r}=this;let{pos:i}=this;t[i++]=128,_s(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(s,0),i=0);for(let u=i;u<n;u++)t[u]=0;nx(s,n-8,BigInt(this.length*8),r),this.process(s,0);const a=Mi(e),g=this.outputLen;if(g%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const Q=g/4,B=this.get();if(Q>B.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<Q;u++)a.setUint32(4*u,B[u],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,n%t&&e.buffer.set(s),e}clone(){return this._cloneInto()}}const es=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Tt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),sn=BigInt(2**32-1),eQ=BigInt(32);function gx(A,e=!1){return e?{h:Number(A&sn),l:Number(A>>eQ&sn)}:{h:Number(A>>eQ&sn)|0,l:Number(A&sn)|0}}function lx(A,e=!1){const t=A.length;let s=new Uint32Array(t),n=new Uint32Array(t);for(let r=0;r<t;r++){const{h:i,l:a}=gx(A[r],e);[s[r],n[r]]=[i,a]}return[s,n]}const tQ=(A,e,t)=>A>>>t,oQ=(A,e,t)=>A<<32-t|e>>>t,Ls=(A,e,t)=>A>>>t|e<<32-t,Js=(A,e,t)=>A<<32-t|e>>>t,rn=(A,e,t)=>A<<64-t|e>>>t-32,nn=(A,e,t)=>A>>>t-32|e<<64-t;function Yo(A,e,t,s){const n=(e>>>0)+(s>>>0);return{h:A+t+(n/2**32|0)|0,l:n|0}}const Qx=(A,e,t)=>(A>>>0)+(e>>>0)+(t>>>0),Bx=(A,e,t,s)=>e+t+s+(A/2**32|0)|0,cx=(A,e,t,s)=>(A>>>0)+(e>>>0)+(t>>>0)+(s>>>0),Ex=(A,e,t,s,n)=>e+t+s+n+(A/2**32|0)|0,Cx=(A,e,t,s,n)=>(A>>>0)+(e>>>0)+(t>>>0)+(s>>>0)+(n>>>0),ux=(A,e,t,s,n,r)=>e+t+s+n+r+(A/2**32|0)|0,Ix=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ts=new Uint32Array(64);class dx extends Wc{constructor(e=32){super(64,e,8,!1),this.A=es[0]|0,this.B=es[1]|0,this.C=es[2]|0,this.D=es[3]|0,this.E=es[4]|0,this.F=es[5]|0,this.G=es[6]|0,this.H=es[7]|0}get(){const{A:e,B:t,C:s,D:n,E:r,F:i,G:a,H:g}=this;return[e,t,s,n,r,i,a,g]}set(e,t,s,n,r,i,a,g){this.A=e|0,this.B=t|0,this.C=s|0,this.D=n|0,this.E=r|0,this.F=i|0,this.G=a|0,this.H=g|0}process(e,t){for(let u=0;u<16;u++,t+=4)ts[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const E=ts[u-15],c=ts[u-2],h=vo(E,7)^vo(E,18)^E>>>3,f=vo(c,17)^vo(c,19)^c>>>10;ts[u]=f+ts[u-7]+h+ts[u-16]|0}let{A:s,B:n,C:r,D:i,E:a,F:g,G:Q,H:B}=this;for(let u=0;u<64;u++){const E=vo(a,6)^vo(a,11)^vo(a,25),c=B+E+ix(a,g,Q)+Ix[u]+ts[u]|0,f=(vo(s,2)^vo(s,13)^vo(s,22))+ax(s,n,r)|0;B=Q,Q=g,g=a,a=i+c|0,i=r,r=n,n=s,s=c+f|0}s=s+this.A|0,n=n+this.B|0,r=r+this.C|0,i=i+this.D|0,a=a+this.E|0,g=g+this.F|0,Q=Q+this.G|0,B=B+this.H|0,this.set(s,n,r,i,a,g,Q,B)}roundClean(){_s(ts)}destroy(){this.set(0,0,0,0,0,0,0,0),_s(this.buffer)}}const zc=lx(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(A=>BigInt(A))),hx=zc[0],px=zc[1],os=new Uint32Array(80),ss=new Uint32Array(80);class fx extends Wc{constructor(e=64){super(128,e,16,!1),this.Ah=Tt[0]|0,this.Al=Tt[1]|0,this.Bh=Tt[2]|0,this.Bl=Tt[3]|0,this.Ch=Tt[4]|0,this.Cl=Tt[5]|0,this.Dh=Tt[6]|0,this.Dl=Tt[7]|0,this.Eh=Tt[8]|0,this.El=Tt[9]|0,this.Fh=Tt[10]|0,this.Fl=Tt[11]|0,this.Gh=Tt[12]|0,this.Gl=Tt[13]|0,this.Hh=Tt[14]|0,this.Hl=Tt[15]|0}get(){const{Ah:e,Al:t,Bh:s,Bl:n,Ch:r,Cl:i,Dh:a,Dl:g,Eh:Q,El:B,Fh:u,Fl:E,Gh:c,Gl:h,Hh:f,Hl:d}=this;return[e,t,s,n,r,i,a,g,Q,B,u,E,c,h,f,d]}set(e,t,s,n,r,i,a,g,Q,B,u,E,c,h,f,d){this.Ah=e|0,this.Al=t|0,this.Bh=s|0,this.Bl=n|0,this.Ch=r|0,this.Cl=i|0,this.Dh=a|0,this.Dl=g|0,this.Eh=Q|0,this.El=B|0,this.Fh=u|0,this.Fl=E|0,this.Gh=c|0,this.Gl=h|0,this.Hh=f|0,this.Hl=d|0}process(e,t){for(let M=0;M<16;M++,t+=4)os[M]=e.getUint32(t),ss[M]=e.getUint32(t+=4);for(let M=16;M<80;M++){const q=os[M-15]|0,G=ss[M-15]|0,T=Ls(q,G,1)^Ls(q,G,8)^tQ(q,G,7),Z=Js(q,G,1)^Js(q,G,8)^oQ(q,G,7),X=os[M-2]|0,U=ss[M-2]|0,O=Ls(X,U,19)^rn(X,U,61)^tQ(X,U,6),j=Js(X,U,19)^nn(X,U,61)^oQ(X,U,6),Y=cx(Z,j,ss[M-7],ss[M-16]),x=Ex(Y,T,O,os[M-7],os[M-16]);os[M]=x|0,ss[M]=Y|0}let{Ah:s,Al:n,Bh:r,Bl:i,Ch:a,Cl:g,Dh:Q,Dl:B,Eh:u,El:E,Fh:c,Fl:h,Gh:f,Gl:d,Hh:D,Hl:R}=this;for(let M=0;M<80;M++){const q=Ls(u,E,14)^Ls(u,E,18)^rn(u,E,41),G=Js(u,E,14)^Js(u,E,18)^nn(u,E,41),T=u&c^~u&f,Z=E&h^~E&d,X=Cx(R,G,Z,px[M],ss[M]),U=ux(X,D,q,T,hx[M],os[M]),O=X|0,j=Ls(s,n,28)^rn(s,n,34)^rn(s,n,39),Y=Js(s,n,28)^nn(s,n,34)^nn(s,n,39),x=s&r^s&a^r&a,l=n&i^n&g^i&g;D=f|0,R=d|0,f=c|0,d=h|0,c=u|0,h=E|0,{h:u,l:E}=Yo(Q|0,B|0,U|0,O|0),Q=a|0,B=g|0,a=r|0,g=i|0,r=s|0,i=n|0;const I=Qx(O,Y,l);s=Bx(I,U,j,x),n=I|0}({h:s,l:n}=Yo(this.Ah|0,this.Al|0,s|0,n|0)),{h:r,l:i}=Yo(this.Bh|0,this.Bl|0,r|0,i|0),{h:a,l:g}=Yo(this.Ch|0,this.Cl|0,a|0,g|0),{h:Q,l:B}=Yo(this.Dh|0,this.Dl|0,Q|0,B|0),{h:u,l:E}=Yo(this.Eh|0,this.El|0,u|0,E|0),{h:c,l:h}=Yo(this.Fh|0,this.Fl|0,c|0,h|0),{h:f,l:d}=Yo(this.Gh|0,this.Gl|0,f|0,d|0),{h:D,l:R}=Yo(this.Hh|0,this.Hl|0,D|0,R|0),this.set(s,n,r,i,a,g,Q,B,u,E,c,h,f,d,D,R)}roundClean(){_s(os,ss)}destroy(){_s(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Vc=Pc(()=>new dx),mx=Pc(()=>new fx);const Sg=BigInt(0),Ga=BigInt(1);function Ds(A,e=""){if(typeof A!="boolean"){const t=e&&`"${e}"`;throw new Error(t+"expected boolean, got type="+typeof A)}return A}function xo(A,e,t=""){const s=Yr(A),n=A?.length,r=e!==void 0;if(!s||r&&n!==e){const i=t&&`"${t}" `,a=r?` of length ${e}`:"",g=s?`length=${n}`:`type=${typeof A}`;throw new Error(i+"expected Uint8Array"+a+", got "+g)}return A}function an(A){const e=A.toString(16);return e.length&1?"0"+e:e}function _c(A){if(typeof A!="string")throw new Error("hex string expected, got "+typeof A);return A===""?Sg:BigInt("0x"+A)}function ai(A){return _c(ms(A))}function Mr(A){return ks(A),_c(ms(Uint8Array.from(A).reverse()))}function Ug(A,e){return Sn(A.toString(16).padStart(e*2,"0"))}function Zc(A,e){return Ug(A,e).reverse()}function ut(A,e,t){let s;if(typeof e=="string")try{s=Sn(e)}catch(r){throw new Error(A+" must be hex string or Uint8Array, cause: "+r)}else if(Yr(e))s=Uint8Array.from(e);else throw new Error(A+" must be hex string or Uint8Array");const n=s.length;if(typeof t=="number"&&n!==t)throw new Error(A+" of length "+t+" expected, got "+n);return s}function sQ(A){return Uint8Array.from(A)}const bi=A=>typeof A=="bigint"&&Sg<=A;function wx(A,e,t){return bi(A)&&bi(e)&&bi(t)&&e<=A&&A<t}function Sa(A,e,t,s){if(!wx(e,t,s))throw new Error("expected valid "+A+": "+t+" <= n < "+s+", got "+e)}function Xc(A){let e;for(e=0;A>Sg;A>>=Ga,e+=1);return e}const Hr=A=>(Ga<<BigInt(A))-Ga;function xx(A,e,t){if(typeof A!="number"||A<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");const s=c=>new Uint8Array(c),n=c=>Uint8Array.of(c);let r=s(A),i=s(A),a=0;const g=()=>{r.fill(1),i.fill(0),a=0},Q=(...c)=>t(i,r,...c),B=(c=s(0))=>{i=Q(n(0),c),r=Q(),c.length!==0&&(i=Q(n(1),c),r=Q())},u=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let c=0;const h=[];for(;c<e;){r=Q();const f=r.slice();h.push(f),c+=r.length}return Go(...h)};return(c,h)=>{g(),B(c);let f;for(;!(f=h(u()));)B();return g(),f}}function Pr(A,e,t={}){if(!A||typeof A!="object")throw new Error("expected valid options object");function s(n,r,i){const a=A[n];if(i&&a===void 0)return;const g=typeof a;if(g!==r||a===null)throw new Error(`param "${n}" is invalid: expected ${r}, got ${g}`)}Object.entries(e).forEach(([n,r])=>s(n,r,!1)),Object.entries(t).forEach(([n,r])=>s(n,r,!0))}function Un(A){const e=new WeakMap;return(t,...s)=>{const n=e.get(t);if(n!==void 0)return n;const r=A(t,...s);return e.set(t,r),r}}const io=BigInt(0),St=BigInt(1),ds=BigInt(2),$c=BigInt(3),AE=BigInt(4),eE=BigInt(5),Dx=BigInt(7),tE=BigInt(8),yx=BigInt(9),oE=BigInt(16);function pt(A,e){const t=A%e;return t>=io?t:e+t}function Ct(A,e,t){let s=A;for(;e-- >io;)s*=s,s%=t;return s}function rQ(A,e){if(A===io)throw new Error("invert: expected non-zero number");if(e<=io)throw new Error("invert: expected positive modulus, got "+e);let t=pt(A,e),s=e,n=io,r=St;for(;t!==io;){const a=s/t,g=s%t,Q=n-r*a;s=t,t=g,n=r,r=Q}if(s!==St)throw new Error("invert: does not exist");return pt(n,e)}function Rg(A,e,t){if(!A.eql(A.sqr(e),t))throw new Error("Cannot find square root")}function sE(A,e){const t=(A.ORDER+St)/AE,s=A.pow(e,t);return Rg(A,s,e),s}function Nx(A,e){const t=(A.ORDER-eE)/tE,s=A.mul(e,ds),n=A.pow(s,t),r=A.mul(e,n),i=A.mul(A.mul(r,ds),n),a=A.mul(r,A.sub(i,A.ONE));return Rg(A,a,e),a}function kx(A){const e=Ms(A),t=rE(A),s=t(e,e.neg(e.ONE)),n=t(e,s),r=t(e,e.neg(s)),i=(A+Dx)/oE;return(a,g)=>{let Q=a.pow(g,i),B=a.mul(Q,s);const u=a.mul(Q,n),E=a.mul(Q,r),c=a.eql(a.sqr(B),g),h=a.eql(a.sqr(u),g);Q=a.cmov(Q,B,c),B=a.cmov(E,u,h);const f=a.eql(a.sqr(B),g),d=a.cmov(Q,B,f);return Rg(a,d,g),d}}function rE(A){if(A<$c)throw new Error("sqrt is not defined for small field");let e=A-St,t=0;for(;e%ds===io;)e/=ds,t++;let s=ds;const n=Ms(A);for(;nQ(n,s)===1;)if(s++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return sE;let r=n.pow(s,e);const i=(e+St)/ds;return function(g,Q){if(g.is0(Q))return Q;if(nQ(g,Q)!==1)throw new Error("Cannot find square root");let B=t,u=g.mul(g.ONE,r),E=g.pow(Q,e),c=g.pow(Q,i);for(;!g.eql(E,g.ONE);){if(g.is0(E))return g.ZERO;let h=1,f=g.sqr(E);for(;!g.eql(f,g.ONE);)if(h++,f=g.sqr(f),h===B)throw new Error("Cannot find square root");const d=St<<BigInt(B-h-1),D=g.pow(u,d);B=h,u=g.sqr(D),E=g.mul(E,u),c=g.mul(c,D)}return c}}function Mx(A){return A%AE===$c?sE:A%tE===eE?Nx:A%oE===yx?kx(A):rE(A)}const bx=(A,e)=>(pt(A,e)&St)===St,Fx=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function vx(A){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},t=Fx.reduce((s,n)=>(s[n]="function",s),e);return Pr(A,t),A}function Gx(A,e,t){if(t<io)throw new Error("invalid exponent, negatives unsupported");if(t===io)return A.ONE;if(t===St)return e;let s=A.ONE,n=e;for(;t>io;)t&St&&(s=A.mul(s,n)),n=A.sqr(n),t>>=St;return s}function nE(A,e,t=!1){const s=new Array(e.length).fill(t?A.ZERO:void 0),n=e.reduce((i,a,g)=>A.is0(a)?i:(s[g]=i,A.mul(i,a)),A.ONE),r=A.inv(n);return e.reduceRight((i,a,g)=>A.is0(a)?i:(s[g]=A.mul(i,s[g]),A.mul(i,a)),r),s}function nQ(A,e){const t=(A.ORDER-St)/ds,s=A.pow(e,t),n=A.eql(s,A.ONE),r=A.eql(s,A.ZERO),i=A.eql(s,A.neg(A.ONE));if(!n&&!r&&!i)throw new Error("invalid Legendre symbol result");return n?1:r?0:-1}function iE(A,e){e!==void 0&&va(e);const t=e!==void 0?e:A.toString(2).length,s=Math.ceil(t/8);return{nBitLength:t,nByteLength:s}}function Ms(A,e,t=!1,s={}){if(A<=io)throw new Error("invalid field: expected ORDER > 0, got "+A);let n,r,i=!1,a;if(typeof e=="object"&&e!=null){if(s.sqrt||t)throw new Error("cannot specify opts in two arguments");const E=e;E.BITS&&(n=E.BITS),E.sqrt&&(r=E.sqrt),typeof E.isLE=="boolean"&&(t=E.isLE),typeof E.modFromBytes=="boolean"&&(i=E.modFromBytes),a=E.allowedLengths}else typeof e=="number"&&(n=e),s.sqrt&&(r=s.sqrt);const{nBitLength:g,nByteLength:Q}=iE(A,n);if(Q>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let B;const u=Object.freeze({ORDER:A,isLE:t,BITS:g,BYTES:Q,MASK:Hr(g),ZERO:io,ONE:St,allowedLengths:a,create:E=>pt(E,A),isValid:E=>{if(typeof E!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof E);return io<=E&&E<A},is0:E=>E===io,isValidNot0:E=>!u.is0(E)&&u.isValid(E),isOdd:E=>(E&St)===St,neg:E=>pt(-E,A),eql:(E,c)=>E===c,sqr:E=>pt(E*E,A),add:(E,c)=>pt(E+c,A),sub:(E,c)=>pt(E-c,A),mul:(E,c)=>pt(E*c,A),pow:(E,c)=>Gx(u,E,c),div:(E,c)=>pt(E*rQ(c,A),A),sqrN:E=>E*E,addN:(E,c)=>E+c,subN:(E,c)=>E-c,mulN:(E,c)=>E*c,inv:E=>rQ(E,A),sqrt:r||(E=>(B||(B=Mx(A)),B(u,E))),toBytes:E=>t?Zc(E,Q):Ug(E,Q),fromBytes:(E,c=!0)=>{if(a){if(!a.includes(E.length)||E.length>Q)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+E.length);const f=new Uint8Array(Q);f.set(E,t?0:f.length-E.length),E=f}if(E.length!==Q)throw new Error("Field.fromBytes: expected "+Q+" bytes, got "+E.length);let h=t?Mr(E):ai(E);if(i&&(h=pt(h,A)),!c&&!u.isValid(h))throw new Error("invalid field element: outside of range 0..ORDER");return h},invertBatch:E=>nE(u,E),cmov:(E,c,h)=>h?c:E});return Object.freeze(u)}function aE(A){if(typeof A!="bigint")throw new Error("field order must be bigint");const e=A.toString(2).length;return Math.ceil(e/8)}function gE(A){const e=aE(A);return e+Math.ceil(e/2)}function Sx(A,e,t=!1){const s=A.length,n=aE(e),r=gE(e);if(s<16||s<r||s>1024)throw new Error("expected "+r+"-1024 bytes of input, got "+s);const i=t?Mr(A):ai(A),a=pt(i,e-St)+St;return t?Zc(a,n):Ug(a,n)}const Zs=BigInt(0),hs=BigInt(1);function Rn(A,e){const t=e.negate();return A?t:e}function ps(A,e){const t=nE(A.Fp,e.map(s=>s.Z));return e.map((s,n)=>A.fromAffine(s.toAffine(t[n])))}function lE(A,e){if(!Number.isSafeInteger(A)||A<=0||A>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+A)}function Fi(A,e){lE(A,e);const t=Math.ceil(e/A)+1,s=2**(A-1),n=2**A,r=Hr(A),i=BigInt(A);return{windows:t,windowSize:s,mask:r,maxNumber:n,shiftBy:i}}function iQ(A,e,t){const{windowSize:s,mask:n,maxNumber:r,shiftBy:i}=t;let a=Number(A&n),g=A>>i;a>s&&(a-=r,g+=hs);const Q=e*s,B=Q+Math.abs(a)-1,u=a===0,E=a<0,c=e%2!==0;return{nextN:g,offset:B,isZero:u,isNeg:E,isNegF:c,offsetF:Q}}function Ux(A,e){if(!Array.isArray(A))throw new Error("array expected");A.forEach((t,s)=>{if(!(t instanceof e))throw new Error("invalid point at index "+s)})}function Rx(A,e){if(!Array.isArray(A))throw new Error("array of scalars expected");A.forEach((t,s)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+s)})}const vi=new WeakMap,QE=new WeakMap;function Gi(A){return QE.get(A)||1}function aQ(A){if(A!==Zs)throw new Error("invalid wNAF")}class BE{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,s=this.ZERO){let n=e;for(;t>Zs;)t&hs&&(s=s.add(n)),n=n.double(),t>>=hs;return s}precomputeWindow(e,t){const{windows:s,windowSize:n}=Fi(t,this.bits),r=[];let i=e,a=i;for(let g=0;g<s;g++){a=i,r.push(a);for(let Q=1;Q<n;Q++)a=a.add(i),r.push(a);i=a.double()}return r}wNAF(e,t,s){if(!this.Fn.isValid(s))throw new Error("invalid scalar");let n=this.ZERO,r=this.BASE;const i=Fi(e,this.bits);for(let a=0;a<i.windows;a++){const{nextN:g,offset:Q,isZero:B,isNeg:u,isNegF:E,offsetF:c}=iQ(s,a,i);s=g,B?r=r.add(Rn(E,t[c])):n=n.add(Rn(u,t[Q]))}return aQ(s),{p:n,f:r}}wNAFUnsafe(e,t,s,n=this.ZERO){const r=Fi(e,this.bits);for(let i=0;i<r.windows&&s!==Zs;i++){const{nextN:a,offset:g,isZero:Q,isNeg:B}=iQ(s,i,r);if(s=a,!Q){const u=t[g];n=n.add(B?u.negate():u)}}return aQ(s),n}getPrecomputes(e,t,s){let n=vi.get(t);return n||(n=this.precomputeWindow(t,e),e!==1&&(typeof s=="function"&&(n=s(n)),vi.set(t,n))),n}cached(e,t,s){const n=Gi(e);return this.wNAF(n,this.getPrecomputes(n,e,s),t)}unsafe(e,t,s,n){const r=Gi(e);return r===1?this._unsafeLadder(e,t,n):this.wNAFUnsafe(r,this.getPrecomputes(r,e,s),t,n)}createCache(e,t){lE(t,this.bits),QE.set(e,t),vi.delete(e)}hasCache(e){return Gi(e)!==1}}function Kx(A,e,t,s){let n=e,r=A.ZERO,i=A.ZERO;for(;t>Zs||s>Zs;)t&hs&&(r=r.add(n)),s&hs&&(i=i.add(n)),n=n.double(),t>>=hs,s>>=hs;return{p1:r,p2:i}}function cE(A,e,t,s){Ux(t,A),Rx(s,e);const n=t.length,r=s.length;if(n!==r)throw new Error("arrays of points and scalars must have equal length");const i=A.ZERO,a=Xc(BigInt(n));let g=1;a>12?g=a-3:a>4?g=a-2:a>0&&(g=2);const Q=Hr(g),B=new Array(Number(Q)+1).fill(i),u=Math.floor((e.BITS-1)/g)*g;let E=i;for(let c=u;c>=0;c-=g){B.fill(i);for(let f=0;f<r;f++){const d=s[f],D=Number(d>>BigInt(c)&Q);B[D]=B[D].add(t[f])}let h=i;for(let f=B.length-1,d=i;f>0;f--)d=d.add(B[f]),h=h.add(d);if(E=E.add(h),c!==0)for(let f=0;f<g;f++)E=E.double()}return E}function gQ(A,e,t){if(e){if(e.ORDER!==A)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return vx(e),e}else return Ms(A,{isLE:t})}function EE(A,e,t={},s){if(s===void 0&&(s=A==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${A} CURVE object`);for(const g of["p","n","h"]){const Q=e[g];if(!(typeof Q=="bigint"&&Q>Zs))throw new Error(`CURVE.${g} must be positive bigint`)}const n=gQ(e.p,t.Fp,s),r=gQ(e.n,t.Fn,s),a=["Gx","Gy","a",A==="weierstrass"?"b":"d"];for(const g of a)if(!n.isValid(e[g]))throw new Error(`CURVE.${g} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:n,Fn:r}}const rs=BigInt(0),Nt=BigInt(1),Si=BigInt(2),Lx=BigInt(8);function Jx(A,e,t,s){const n=A.sqr(t),r=A.sqr(s),i=A.add(A.mul(e.a,n),r),a=A.add(A.ONE,A.mul(e.d,A.mul(n,r)));return A.eql(i,a)}function Tx(A,e={}){const t=EE("edwards",A,e,e.FpFnLE),{Fp:s,Fn:n}=t;let r=t.CURVE;const{h:i}=r;Pr(e,{},{uvRatio:"function"});const a=Si<<BigInt(n.BYTES*8)-Nt,g=d=>s.create(d),Q=e.uvRatio||((d,D)=>{try{return{isValid:!0,value:s.sqrt(s.div(d,D))}}catch{return{isValid:!1,value:rs}}});if(!Jx(s,r,r.Gx,r.Gy))throw new Error("bad curve params: generator point");function B(d,D,R=!1){const M=R?Nt:rs;return Sa("coordinate "+d,D,M,a),D}function u(d){if(!(d instanceof h))throw new Error("ExtendedPoint expected")}const E=Un((d,D)=>{const{X:R,Y:M,Z:q}=d,G=d.is0();D==null&&(D=G?Lx:s.inv(q));const T=g(R*D),Z=g(M*D),X=s.mul(q,D);if(G)return{x:rs,y:Nt};if(X!==Nt)throw new Error("invZ was invalid");return{x:T,y:Z}}),c=Un(d=>{const{a:D,d:R}=r;if(d.is0())throw new Error("bad point: ZERO");const{X:M,Y:q,Z:G,T}=d,Z=g(M*M),X=g(q*q),U=g(G*G),O=g(U*U),j=g(Z*D),Y=g(U*g(j+X)),x=g(O+g(R*g(Z*X)));if(Y!==x)throw new Error("bad point: equation left != right (1)");const l=g(M*q),I=g(G*T);if(l!==I)throw new Error("bad point: equation left != right (2)");return!0});class h{constructor(D,R,M,q){this.X=B("x",D),this.Y=B("y",R),this.Z=B("z",M,!0),this.T=B("t",q),Object.freeze(this)}static CURVE(){return r}static fromAffine(D){if(D instanceof h)throw new Error("extended point not allowed");const{x:R,y:M}=D||{};return B("x",R),B("y",M),new h(R,M,Nt,g(R*M))}static fromBytes(D,R=!1){const M=s.BYTES,{a:q,d:G}=r;D=sQ(xo(D,M,"point")),Ds(R,"zip215");const T=sQ(D),Z=D[M-1];T[M-1]=Z&-129;const X=Mr(T),U=R?a:s.ORDER;Sa("point.y",X,rs,U);const O=g(X*X),j=g(O-Nt),Y=g(G*O-q);let{isValid:x,value:l}=Q(j,Y);if(!x)throw new Error("bad point: invalid y coordinate");const I=(l&Nt)===Nt,y=(Z&128)!==0;if(!R&&l===rs&&y)throw new Error("bad point: x=0 and x_0=1");return y!==I&&(l=g(-l)),h.fromAffine({x:l,y:X})}static fromHex(D,R=!1){return h.fromBytes(ut("point",D),R)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(D=8,R=!0){return f.createCache(this,D),R||this.multiply(Si),this}assertValidity(){c(this)}equals(D){u(D);const{X:R,Y:M,Z:q}=this,{X:G,Y:T,Z}=D,X=g(R*Z),U=g(G*q),O=g(M*Z),j=g(T*q);return X===U&&O===j}is0(){return this.equals(h.ZERO)}negate(){return new h(g(-this.X),this.Y,this.Z,g(-this.T))}double(){const{a:D}=r,{X:R,Y:M,Z:q}=this,G=g(R*R),T=g(M*M),Z=g(Si*g(q*q)),X=g(D*G),U=R+M,O=g(g(U*U)-G-T),j=X+T,Y=j-Z,x=X-T,l=g(O*Y),I=g(j*x),y=g(O*x),b=g(Y*j);return new h(l,I,b,y)}add(D){u(D);const{a:R,d:M}=r,{X:q,Y:G,Z:T,T:Z}=this,{X,Y:U,Z:O,T:j}=D,Y=g(q*X),x=g(G*U),l=g(Z*M*j),I=g(T*O),y=g((q+G)*(X+U)-Y-x),b=I-l,J=I+l,H=g(x-R*Y),v=g(y*b),K=g(J*H),C=g(y*H),p=g(b*J);return new h(v,K,p,C)}subtract(D){return this.add(D.negate())}multiply(D){if(!n.isValidNot0(D))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:R,f:M}=f.cached(this,D,q=>ps(h,q));return ps(h,[R,M])[0]}multiplyUnsafe(D,R=h.ZERO){if(!n.isValid(D))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return D===rs?h.ZERO:this.is0()||D===Nt?this:f.unsafe(this,D,M=>ps(h,M),R)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return f.unsafe(this,r.n).is0()}toAffine(D){return E(this,D)}clearCofactor(){return i===Nt?this:this.multiplyUnsafe(i)}toBytes(){const{x:D,y:R}=this.toAffine(),M=s.toBytes(R);return M[M.length-1]|=D&Nt?128:0,M}toHex(){return ms(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(D){return ps(h,D)}static msm(D,R){return cE(h,n,D,R)}_setWindowSize(D){this.precompute(D)}toRawBytes(){return this.toBytes()}}h.BASE=new h(r.Gx,r.Gy,Nt,g(r.Gx*r.Gy)),h.ZERO=new h(rs,Nt,Nt,rs),h.Fp=s,h.Fn=n;const f=new BE(h,n.BITS);return h.BASE.precompute(8),h}function jx(A,e,t={}){if(typeof e!="function")throw new Error('"hash" function param is required');Pr(t,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:s}=t,{BASE:n,Fp:r,Fn:i}=A,a=t.randomBytes||Gg,g=t.adjustScalarBytes||(U=>U),Q=t.domain||((U,O,j)=>{if(Ds(j,"phflag"),O.length||j)throw new Error("Contexts/pre-hash are not supported");return U});function B(U){return i.create(Mr(U))}function u(U){const O=M.secretKey;U=ut("private key",U,O);const j=ut("hashed private key",e(U),2*O),Y=g(j.slice(0,O)),x=j.slice(O,2*O),l=B(Y);return{head:Y,prefix:x,scalar:l}}function E(U){const{head:O,prefix:j,scalar:Y}=u(U),x=n.multiply(Y),l=x.toBytes();return{head:O,prefix:j,scalar:Y,point:x,pointBytes:l}}function c(U){return E(U).pointBytes}function h(U=Uint8Array.of(),...O){const j=Go(...O);return B(e(Q(j,ut("context",U),!!s)))}function f(U,O,j={}){U=ut("message",U),s&&(U=s(U));const{prefix:Y,scalar:x,pointBytes:l}=E(O),I=h(j.context,Y,U),y=n.multiply(I).toBytes(),b=h(j.context,y,l,U),J=i.create(I+b*x);if(!i.isValid(J))throw new Error("sign failed: invalid s");const H=Go(y,i.toBytes(J));return xo(H,M.signature,"result")}const d={zip215:!0};function D(U,O,j,Y=d){const{context:x,zip215:l}=Y,I=M.signature;U=ut("signature",U,I),O=ut("message",O),j=ut("publicKey",j,M.publicKey),l!==void 0&&Ds(l,"zip215"),s&&(O=s(O));const y=I/2,b=U.subarray(0,y),J=Mr(U.subarray(y,I));let H,v,K;try{H=A.fromBytes(j,l),v=A.fromBytes(b,l),K=n.multiplyUnsafe(J)}catch{return!1}if(!l&&H.isSmallOrder())return!1;const C=h(x,v.toBytes(),H.toBytes(),O);return v.add(H.multiplyUnsafe(C)).subtract(K).clearCofactor().is0()}const R=r.BYTES,M={secretKey:R,publicKey:R,signature:2*R,seed:R};function q(U=a(M.seed)){return xo(U,M.seed,"seed")}function G(U){const O=X.randomSecretKey(U);return{secretKey:O,publicKey:c(O)}}function T(U){return Yr(U)&&U.length===i.BYTES}function Z(U,O){try{return!!A.fromBytes(U,O)}catch{return!1}}const X={getExtendedPublicKey:E,randomSecretKey:q,isValidSecretKey:T,isValidPublicKey:Z,toMontgomery(U){const{y:O}=A.fromBytes(U),j=M.publicKey,Y=j===32;if(!Y&&j!==57)throw new Error("only defined for 25519 and 448");const x=Y?r.div(Nt+O,Nt-O):r.div(O-Nt,O+Nt);return r.toBytes(x)},toMontgomerySecret(U){const O=M.secretKey;xo(U,O);const j=e(U.subarray(0,O));return g(j).subarray(0,O)},randomPrivateKey:q,precompute(U=8,O=A.BASE){return O.precompute(U,!1)}};return Object.freeze({keygen:G,getPublicKey:c,sign:f,verify:D,utils:X,Point:A,lengths:M})}function Ox(A){const e={a:A.a,d:A.d,p:A.Fp.ORDER,n:A.n,h:A.h,Gx:A.Gx,Gy:A.Gy},t=A.Fp,s=Ms(e.n,A.nBitLength,!0),n={Fp:t,Fn:s,uvRatio:A.uvRatio},r={randomBytes:A.randomBytes,adjustScalarBytes:A.adjustScalarBytes,domain:A.domain,prehash:A.prehash,mapToCurve:A.mapToCurve};return{CURVE:e,curveOpts:n,hash:A.hash,eddsaOpts:r}}function qx(A,e){const t=e.Point;return Object.assign({},e,{ExtendedPoint:t,CURVE:A,nBitLength:t.Fn.BITS,nByteLength:t.Fn.BYTES})}function Yx(A){const{CURVE:e,curveOpts:t,hash:s,eddsaOpts:n}=Ox(A),r=Tx(e,t),i=jx(r,s,n);return qx(A,i)}const Hx=BigInt(1),lQ=BigInt(2);BigInt(3);const Px=BigInt(5),Wx=BigInt(8),Kg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),CE={p:Kg,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Wx,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function zx(A){const e=BigInt(10),t=BigInt(20),s=BigInt(40),n=BigInt(80),r=Kg,a=A*A%r*A%r,g=Ct(a,lQ,r)*a%r,Q=Ct(g,Hx,r)*A%r,B=Ct(Q,Px,r)*Q%r,u=Ct(B,e,r)*B%r,E=Ct(u,t,r)*u%r,c=Ct(E,s,r)*E%r,h=Ct(c,n,r)*c%r,f=Ct(h,n,r)*c%r,d=Ct(f,e,r)*B%r;return{pow_p_5_8:Ct(d,lQ,r)*A%r,b2:a}}function Vx(A){return A[0]&=248,A[31]&=127,A[31]|=64,A}const QQ=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function _x(A,e){const t=Kg,s=pt(e*e*e,t),n=pt(s*s*e,t),r=zx(A*n).pow_p_5_8;let i=pt(A*s*r,t);const a=pt(e*i*i,t),g=i,Q=pt(i*QQ,t),B=a===A,u=a===pt(-A,t),E=a===pt(-A*QQ,t);return B&&(i=g),(u||E)&&(i=Q),bx(i,t)&&(i=pt(-i,t)),{isValid:B||u,value:i}}const Zx=Ms(CE.p,{isLE:!0}),Xx={...CE,Fp:Zx,hash:mx,adjustScalarBytes:Vx,uvRatio:_x},gi=Yx(Xx);var wn={exports:{}};const $x={},AD=Object.freeze(Object.defineProperty({__proto__:null,default:$x},Symbol.toStringTag,{value:"Module"})),uE=za(AD);var eD=wn.exports,BQ;function IE(){return BQ||(BQ=1,(function(A){(function(e,t){function s(x,l){if(!x)throw new Error(l||"Assertion failed")}function n(x,l){x.super_=l;var I=function(){};I.prototype=l.prototype,x.prototype=new I,x.prototype.constructor=x}function r(x,l,I){if(r.isBN(x))return x;this.negative=0,this.words=null,this.length=0,this.red=null,x!==null&&((l==="le"||l==="be")&&(I=l,l=10),this._init(x||0,l||10,I||"be"))}typeof e=="object"?e.exports=r:t.BN=r,r.BN=r,r.wordSize=26;var i;try{typeof window<"u"&&typeof window.Buffer<"u"?i=window.Buffer:i=uE.Buffer}catch{}r.isBN=function(l){return l instanceof r?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===r.wordSize&&Array.isArray(l.words)},r.max=function(l,I){return l.cmp(I)>0?l:I},r.min=function(l,I){return l.cmp(I)<0?l:I},r.prototype._init=function(l,I,y){if(typeof l=="number")return this._initNumber(l,I,y);if(typeof l=="object")return this._initArray(l,I,y);I==="hex"&&(I=16),s(I===(I|0)&&I>=2&&I<=36),l=l.toString().replace(/\s+/g,"");var b=0;l[0]==="-"&&(b++,this.negative=1),b<l.length&&(I===16?this._parseHex(l,b,y):(this._parseBase(l,I,b),y==="le"&&this._initArray(this.toArray(),I,y)))},r.prototype._initNumber=function(l,I,y){l<0&&(this.negative=1,l=-l),l<67108864?(this.words=[l&67108863],this.length=1):l<4503599627370496?(this.words=[l&67108863,l/67108864&67108863],this.length=2):(s(l<9007199254740992),this.words=[l&67108863,l/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),I,y)},r.prototype._initArray=function(l,I,y){if(s(typeof l.length=="number"),l.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(l.length/3),this.words=new Array(this.length);for(var b=0;b<this.length;b++)this.words[b]=0;var J,H,v=0;if(y==="be")for(b=l.length-1,J=0;b>=0;b-=3)H=l[b]|l[b-1]<<8|l[b-2]<<16,this.words[J]|=H<<v&67108863,this.words[J+1]=H>>>26-v&67108863,v+=24,v>=26&&(v-=26,J++);else if(y==="le")for(b=0,J=0;b<l.length;b+=3)H=l[b]|l[b+1]<<8|l[b+2]<<16,this.words[J]|=H<<v&67108863,this.words[J+1]=H>>>26-v&67108863,v+=24,v>=26&&(v-=26,J++);return this._strip()};function a(x,l){var I=x.charCodeAt(l);if(I>=48&&I<=57)return I-48;if(I>=65&&I<=70)return I-55;if(I>=97&&I<=102)return I-87;s(!1,"Invalid character in "+x)}function g(x,l,I){var y=a(x,I);return I-1>=l&&(y|=a(x,I-1)<<4),y}r.prototype._parseHex=function(l,I,y){this.length=Math.ceil((l.length-I)/6),this.words=new Array(this.length);for(var b=0;b<this.length;b++)this.words[b]=0;var J=0,H=0,v;if(y==="be")for(b=l.length-1;b>=I;b-=2)v=g(l,I,b)<<J,this.words[H]|=v&67108863,J>=18?(J-=18,H+=1,this.words[H]|=v>>>26):J+=8;else{var K=l.length-I;for(b=K%2===0?I+1:I;b<l.length;b+=2)v=g(l,I,b)<<J,this.words[H]|=v&67108863,J>=18?(J-=18,H+=1,this.words[H]|=v>>>26):J+=8}this._strip()};function Q(x,l,I,y){for(var b=0,J=0,H=Math.min(x.length,I),v=l;v<H;v++){var K=x.charCodeAt(v)-48;b*=y,K>=49?J=K-49+10:K>=17?J=K-17+10:J=K,s(K>=0&&J<y,"Invalid character"),b+=J}return b}r.prototype._parseBase=function(l,I,y){this.words=[0],this.length=1;for(var b=0,J=1;J<=67108863;J*=I)b++;b--,J=J/I|0;for(var H=l.length-y,v=H%b,K=Math.min(H,H-v)+y,C=0,p=y;p<K;p+=b)C=Q(l,p,p+b,I),this.imuln(J),this.words[0]+C<67108864?this.words[0]+=C:this._iaddn(C);if(v!==0){var L=1;for(C=Q(l,p,l.length,I),p=0;p<v;p++)L*=I;this.imuln(L),this.words[0]+C<67108864?this.words[0]+=C:this._iaddn(C)}this._strip()},r.prototype.copy=function(l){l.words=new Array(this.length);for(var I=0;I<this.length;I++)l.words[I]=this.words[I];l.length=this.length,l.negative=this.negative,l.red=this.red};function B(x,l){x.words=l.words,x.length=l.length,x.negative=l.negative,x.red=l.red}if(r.prototype._move=function(l){B(l,this)},r.prototype.clone=function(){var l=new r(null);return this.copy(l),l},r.prototype._expand=function(l){for(;this.length<l;)this.words[this.length++]=0;return this},r.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},r.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{r.prototype[Symbol.for("nodejs.util.inspect.custom")]=u}catch{r.prototype.inspect=u}else r.prototype.inspect=u;function u(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var E=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];r.prototype.toString=function(l,I){l=l||10,I=I|0||1;var y;if(l===16||l==="hex"){y="";for(var b=0,J=0,H=0;H<this.length;H++){var v=this.words[H],K=((v<<b|J)&16777215).toString(16);J=v>>>24-b&16777215,b+=2,b>=26&&(b-=26,H--),J!==0||H!==this.length-1?y=E[6-K.length]+K+y:y=K+y}for(J!==0&&(y=J.toString(16)+y);y.length%I!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(l===(l|0)&&l>=2&&l<=36){var C=c[l],p=h[l];y="";var L=this.clone();for(L.negative=0;!L.isZero();){var S=L.modrn(p).toString(l);L=L.idivn(p),L.isZero()?y=S+y:y=E[C-S.length]+S+y}for(this.isZero()&&(y="0"+y);y.length%I!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}s(!1,"Base should be between 2 and 36")},r.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&s(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},r.prototype.toJSON=function(){return this.toString(16,2)},i&&(r.prototype.toBuffer=function(l,I){return this.toArrayLike(i,l,I)}),r.prototype.toArray=function(l,I){return this.toArrayLike(Array,l,I)};var f=function(l,I){return l.allocUnsafe?l.allocUnsafe(I):new l(I)};r.prototype.toArrayLike=function(l,I,y){this._strip();var b=this.byteLength(),J=y||Math.max(1,b);s(b<=J,"byte array longer than desired length"),s(J>0,"Requested array length <= 0");var H=f(l,J),v=I==="le"?"LE":"BE";return this["_toArrayLike"+v](H,b),H},r.prototype._toArrayLikeLE=function(l,I){for(var y=0,b=0,J=0,H=0;J<this.length;J++){var v=this.words[J]<<H|b;l[y++]=v&255,y<l.length&&(l[y++]=v>>8&255),y<l.length&&(l[y++]=v>>16&255),H===6?(y<l.length&&(l[y++]=v>>24&255),b=0,H=0):(b=v>>>24,H+=2)}if(y<l.length)for(l[y++]=b;y<l.length;)l[y++]=0},r.prototype._toArrayLikeBE=function(l,I){for(var y=l.length-1,b=0,J=0,H=0;J<this.length;J++){var v=this.words[J]<<H|b;l[y--]=v&255,y>=0&&(l[y--]=v>>8&255),y>=0&&(l[y--]=v>>16&255),H===6?(y>=0&&(l[y--]=v>>24&255),b=0,H=0):(b=v>>>24,H+=2)}if(y>=0)for(l[y--]=b;y>=0;)l[y--]=0},Math.clz32?r.prototype._countBits=function(l){return 32-Math.clz32(l)}:r.prototype._countBits=function(l){var I=l,y=0;return I>=4096&&(y+=13,I>>>=13),I>=64&&(y+=7,I>>>=7),I>=8&&(y+=4,I>>>=4),I>=2&&(y+=2,I>>>=2),y+I},r.prototype._zeroBits=function(l){if(l===0)return 26;var I=l,y=0;return(I&8191)===0&&(y+=13,I>>>=13),(I&127)===0&&(y+=7,I>>>=7),(I&15)===0&&(y+=4,I>>>=4),(I&3)===0&&(y+=2,I>>>=2),(I&1)===0&&y++,y},r.prototype.bitLength=function(){var l=this.words[this.length-1],I=this._countBits(l);return(this.length-1)*26+I};function d(x){for(var l=new Array(x.bitLength()),I=0;I<l.length;I++){var y=I/26|0,b=I%26;l[I]=x.words[y]>>>b&1}return l}r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,I=0;I<this.length;I++){var y=this._zeroBits(this.words[I]);if(l+=y,y!==26)break}return l},r.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},r.prototype.toTwos=function(l){return this.negative!==0?this.abs().inotn(l).iaddn(1):this.clone()},r.prototype.fromTwos=function(l){return this.testn(l-1)?this.notn(l).iaddn(1).ineg():this.clone()},r.prototype.isNeg=function(){return this.negative!==0},r.prototype.neg=function(){return this.clone().ineg()},r.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},r.prototype.iuor=function(l){for(;this.length<l.length;)this.words[this.length++]=0;for(var I=0;I<l.length;I++)this.words[I]=this.words[I]|l.words[I];return this._strip()},r.prototype.ior=function(l){return s((this.negative|l.negative)===0),this.iuor(l)},r.prototype.or=function(l){return this.length>l.length?this.clone().ior(l):l.clone().ior(this)},r.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},r.prototype.iuand=function(l){var I;this.length>l.length?I=l:I=this;for(var y=0;y<I.length;y++)this.words[y]=this.words[y]&l.words[y];return this.length=I.length,this._strip()},r.prototype.iand=function(l){return s((this.negative|l.negative)===0),this.iuand(l)},r.prototype.and=function(l){return this.length>l.length?this.clone().iand(l):l.clone().iand(this)},r.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},r.prototype.iuxor=function(l){var I,y;this.length>l.length?(I=this,y=l):(I=l,y=this);for(var b=0;b<y.length;b++)this.words[b]=I.words[b]^y.words[b];if(this!==I)for(;b<I.length;b++)this.words[b]=I.words[b];return this.length=I.length,this._strip()},r.prototype.ixor=function(l){return s((this.negative|l.negative)===0),this.iuxor(l)},r.prototype.xor=function(l){return this.length>l.length?this.clone().ixor(l):l.clone().ixor(this)},r.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},r.prototype.inotn=function(l){s(typeof l=="number"&&l>=0);var I=Math.ceil(l/26)|0,y=l%26;this._expand(I),y>0&&I--;for(var b=0;b<I;b++)this.words[b]=~this.words[b]&67108863;return y>0&&(this.words[b]=~this.words[b]&67108863>>26-y),this._strip()},r.prototype.notn=function(l){return this.clone().inotn(l)},r.prototype.setn=function(l,I){s(typeof l=="number"&&l>=0);var y=l/26|0,b=l%26;return this._expand(y+1),I?this.words[y]=this.words[y]|1<<b:this.words[y]=this.words[y]&~(1<<b),this._strip()},r.prototype.iadd=function(l){var I;if(this.negative!==0&&l.negative===0)return this.negative=0,I=this.isub(l),this.negative^=1,this._normSign();if(this.negative===0&&l.negative!==0)return l.negative=0,I=this.isub(l),l.negative=1,I._normSign();var y,b;this.length>l.length?(y=this,b=l):(y=l,b=this);for(var J=0,H=0;H<b.length;H++)I=(y.words[H]|0)+(b.words[H]|0)+J,this.words[H]=I&67108863,J=I>>>26;for(;J!==0&&H<y.length;H++)I=(y.words[H]|0)+J,this.words[H]=I&67108863,J=I>>>26;if(this.length=y.length,J!==0)this.words[this.length]=J,this.length++;else if(y!==this)for(;H<y.length;H++)this.words[H]=y.words[H];return this},r.prototype.add=function(l){var I;return l.negative!==0&&this.negative===0?(l.negative=0,I=this.sub(l),l.negative^=1,I):l.negative===0&&this.negative!==0?(this.negative=0,I=l.sub(this),this.negative=1,I):this.length>l.length?this.clone().iadd(l):l.clone().iadd(this)},r.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var I=this.iadd(l);return l.negative=1,I._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var y=this.cmp(l);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var b,J;y>0?(b=this,J=l):(b=l,J=this);for(var H=0,v=0;v<J.length;v++)I=(b.words[v]|0)-(J.words[v]|0)+H,H=I>>26,this.words[v]=I&67108863;for(;H!==0&&v<b.length;v++)I=(b.words[v]|0)+H,H=I>>26,this.words[v]=I&67108863;if(H===0&&v<b.length&&b!==this)for(;v<b.length;v++)this.words[v]=b.words[v];return this.length=Math.max(this.length,v),b!==this&&(this.negative=1),this._strip()},r.prototype.sub=function(l){return this.clone().isub(l)};function D(x,l,I){I.negative=l.negative^x.negative;var y=x.length+l.length|0;I.length=y,y=y-1|0;var b=x.words[0]|0,J=l.words[0]|0,H=b*J,v=H&67108863,K=H/67108864|0;I.words[0]=v;for(var C=1;C<y;C++){for(var p=K>>>26,L=K&67108863,S=Math.min(C,l.length-1),$=Math.max(0,C-x.length+1);$<=S;$++){var AA=C-$|0;b=x.words[AA]|0,J=l.words[$]|0,H=b*J+L,p+=H/67108864|0,L=H&67108863}I.words[C]=L|0,K=p|0}return K!==0?I.words[C]=K|0:I.length--,I._strip()}var R=function(l,I,y){var b=l.words,J=I.words,H=y.words,v=0,K,C,p,L=b[0]|0,S=L&8191,$=L>>>13,AA=b[1]|0,sA=AA&8191,oA=AA>>>13,bA=b[2]|0,GA=bA&8191,lA=bA>>>13,jA=b[3]|0,HA=jA&8191,ce=jA>>>13,NA=b[4]|0,_A=NA&8191,we=NA>>>13,He=b[5]|0,de=He&8191,Ke=He>>>13,nt=b[6]|0,Le=nt&8191,kA=nt>>>13,he=b[7]|0,zA=he&8191,P=he>>>13,N=b[8]|0,k=N&8191,_=N>>>13,tA=b[9]|0,aA=tA&8191,EA=tA>>>13,ZA=J[0]|0,VA=ZA&8191,$A=ZA>>>13,ke=J[1]|0,XA=ke&8191,ye=ke>>>13,Kt=J[2]|0,Je=Kt&8191,je=Kt>>>13,To=J[3]|0,Be=To&8191,ve=To>>>13,Lt=J[4]|0,Oe=Lt&8191,ze=Lt>>>13,co=J[5]|0,KA=co&8191,se=co>>>13,_t=J[6]|0,F=_t&8191,W=_t>>>13,z=J[7]|0,w=z&8191,V=z>>>13,nA=J[8]|0,rA=nA&8191,IA=nA>>>13,yA=J[9]|0,FA=yA&8191,xA=yA>>>13;y.negative=l.negative^I.negative,y.length=19,K=Math.imul(S,VA),C=Math.imul(S,$A),C=C+Math.imul($,VA)|0,p=Math.imul($,$A);var Ee=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,K=Math.imul(sA,VA),C=Math.imul(sA,$A),C=C+Math.imul(oA,VA)|0,p=Math.imul(oA,$A),K=K+Math.imul(S,XA)|0,C=C+Math.imul(S,ye)|0,C=C+Math.imul($,XA)|0,p=p+Math.imul($,ye)|0;var RA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(RA>>>26)|0,RA&=67108863,K=Math.imul(GA,VA),C=Math.imul(GA,$A),C=C+Math.imul(lA,VA)|0,p=Math.imul(lA,$A),K=K+Math.imul(sA,XA)|0,C=C+Math.imul(sA,ye)|0,C=C+Math.imul(oA,XA)|0,p=p+Math.imul(oA,ye)|0,K=K+Math.imul(S,Je)|0,C=C+Math.imul(S,je)|0,C=C+Math.imul($,Je)|0,p=p+Math.imul($,je)|0;var Ae=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,K=Math.imul(HA,VA),C=Math.imul(HA,$A),C=C+Math.imul(ce,VA)|0,p=Math.imul(ce,$A),K=K+Math.imul(GA,XA)|0,C=C+Math.imul(GA,ye)|0,C=C+Math.imul(lA,XA)|0,p=p+Math.imul(lA,ye)|0,K=K+Math.imul(sA,Je)|0,C=C+Math.imul(sA,je)|0,C=C+Math.imul(oA,Je)|0,p=p+Math.imul(oA,je)|0,K=K+Math.imul(S,Be)|0,C=C+Math.imul(S,ve)|0,C=C+Math.imul($,Be)|0,p=p+Math.imul($,ve)|0;var ie=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(ie>>>26)|0,ie&=67108863,K=Math.imul(_A,VA),C=Math.imul(_A,$A),C=C+Math.imul(we,VA)|0,p=Math.imul(we,$A),K=K+Math.imul(HA,XA)|0,C=C+Math.imul(HA,ye)|0,C=C+Math.imul(ce,XA)|0,p=p+Math.imul(ce,ye)|0,K=K+Math.imul(GA,Je)|0,C=C+Math.imul(GA,je)|0,C=C+Math.imul(lA,Je)|0,p=p+Math.imul(lA,je)|0,K=K+Math.imul(sA,Be)|0,C=C+Math.imul(sA,ve)|0,C=C+Math.imul(oA,Be)|0,p=p+Math.imul(oA,ve)|0,K=K+Math.imul(S,Oe)|0,C=C+Math.imul(S,ze)|0,C=C+Math.imul($,Oe)|0,p=p+Math.imul($,ze)|0;var le=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(le>>>26)|0,le&=67108863,K=Math.imul(de,VA),C=Math.imul(de,$A),C=C+Math.imul(Ke,VA)|0,p=Math.imul(Ke,$A),K=K+Math.imul(_A,XA)|0,C=C+Math.imul(_A,ye)|0,C=C+Math.imul(we,XA)|0,p=p+Math.imul(we,ye)|0,K=K+Math.imul(HA,Je)|0,C=C+Math.imul(HA,je)|0,C=C+Math.imul(ce,Je)|0,p=p+Math.imul(ce,je)|0,K=K+Math.imul(GA,Be)|0,C=C+Math.imul(GA,ve)|0,C=C+Math.imul(lA,Be)|0,p=p+Math.imul(lA,ve)|0,K=K+Math.imul(sA,Oe)|0,C=C+Math.imul(sA,ze)|0,C=C+Math.imul(oA,Oe)|0,p=p+Math.imul(oA,ze)|0,K=K+Math.imul(S,KA)|0,C=C+Math.imul(S,se)|0,C=C+Math.imul($,KA)|0,p=p+Math.imul($,se)|0;var ae=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(ae>>>26)|0,ae&=67108863,K=Math.imul(Le,VA),C=Math.imul(Le,$A),C=C+Math.imul(kA,VA)|0,p=Math.imul(kA,$A),K=K+Math.imul(de,XA)|0,C=C+Math.imul(de,ye)|0,C=C+Math.imul(Ke,XA)|0,p=p+Math.imul(Ke,ye)|0,K=K+Math.imul(_A,Je)|0,C=C+Math.imul(_A,je)|0,C=C+Math.imul(we,Je)|0,p=p+Math.imul(we,je)|0,K=K+Math.imul(HA,Be)|0,C=C+Math.imul(HA,ve)|0,C=C+Math.imul(ce,Be)|0,p=p+Math.imul(ce,ve)|0,K=K+Math.imul(GA,Oe)|0,C=C+Math.imul(GA,ze)|0,C=C+Math.imul(lA,Oe)|0,p=p+Math.imul(lA,ze)|0,K=K+Math.imul(sA,KA)|0,C=C+Math.imul(sA,se)|0,C=C+Math.imul(oA,KA)|0,p=p+Math.imul(oA,se)|0,K=K+Math.imul(S,F)|0,C=C+Math.imul(S,W)|0,C=C+Math.imul($,F)|0,p=p+Math.imul($,W)|0;var re=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(re>>>26)|0,re&=67108863,K=Math.imul(zA,VA),C=Math.imul(zA,$A),C=C+Math.imul(P,VA)|0,p=Math.imul(P,$A),K=K+Math.imul(Le,XA)|0,C=C+Math.imul(Le,ye)|0,C=C+Math.imul(kA,XA)|0,p=p+Math.imul(kA,ye)|0,K=K+Math.imul(de,Je)|0,C=C+Math.imul(de,je)|0,C=C+Math.imul(Ke,Je)|0,p=p+Math.imul(Ke,je)|0,K=K+Math.imul(_A,Be)|0,C=C+Math.imul(_A,ve)|0,C=C+Math.imul(we,Be)|0,p=p+Math.imul(we,ve)|0,K=K+Math.imul(HA,Oe)|0,C=C+Math.imul(HA,ze)|0,C=C+Math.imul(ce,Oe)|0,p=p+Math.imul(ce,ze)|0,K=K+Math.imul(GA,KA)|0,C=C+Math.imul(GA,se)|0,C=C+Math.imul(lA,KA)|0,p=p+Math.imul(lA,se)|0,K=K+Math.imul(sA,F)|0,C=C+Math.imul(sA,W)|0,C=C+Math.imul(oA,F)|0,p=p+Math.imul(oA,W)|0,K=K+Math.imul(S,w)|0,C=C+Math.imul(S,V)|0,C=C+Math.imul($,w)|0,p=p+Math.imul($,V)|0;var ne=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(ne>>>26)|0,ne&=67108863,K=Math.imul(k,VA),C=Math.imul(k,$A),C=C+Math.imul(_,VA)|0,p=Math.imul(_,$A),K=K+Math.imul(zA,XA)|0,C=C+Math.imul(zA,ye)|0,C=C+Math.imul(P,XA)|0,p=p+Math.imul(P,ye)|0,K=K+Math.imul(Le,Je)|0,C=C+Math.imul(Le,je)|0,C=C+Math.imul(kA,Je)|0,p=p+Math.imul(kA,je)|0,K=K+Math.imul(de,Be)|0,C=C+Math.imul(de,ve)|0,C=C+Math.imul(Ke,Be)|0,p=p+Math.imul(Ke,ve)|0,K=K+Math.imul(_A,Oe)|0,C=C+Math.imul(_A,ze)|0,C=C+Math.imul(we,Oe)|0,p=p+Math.imul(we,ze)|0,K=K+Math.imul(HA,KA)|0,C=C+Math.imul(HA,se)|0,C=C+Math.imul(ce,KA)|0,p=p+Math.imul(ce,se)|0,K=K+Math.imul(GA,F)|0,C=C+Math.imul(GA,W)|0,C=C+Math.imul(lA,F)|0,p=p+Math.imul(lA,W)|0,K=K+Math.imul(sA,w)|0,C=C+Math.imul(sA,V)|0,C=C+Math.imul(oA,w)|0,p=p+Math.imul(oA,V)|0,K=K+Math.imul(S,rA)|0,C=C+Math.imul(S,IA)|0,C=C+Math.imul($,rA)|0,p=p+Math.imul($,IA)|0;var ee=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(ee>>>26)|0,ee&=67108863,K=Math.imul(aA,VA),C=Math.imul(aA,$A),C=C+Math.imul(EA,VA)|0,p=Math.imul(EA,$A),K=K+Math.imul(k,XA)|0,C=C+Math.imul(k,ye)|0,C=C+Math.imul(_,XA)|0,p=p+Math.imul(_,ye)|0,K=K+Math.imul(zA,Je)|0,C=C+Math.imul(zA,je)|0,C=C+Math.imul(P,Je)|0,p=p+Math.imul(P,je)|0,K=K+Math.imul(Le,Be)|0,C=C+Math.imul(Le,ve)|0,C=C+Math.imul(kA,Be)|0,p=p+Math.imul(kA,ve)|0,K=K+Math.imul(de,Oe)|0,C=C+Math.imul(de,ze)|0,C=C+Math.imul(Ke,Oe)|0,p=p+Math.imul(Ke,ze)|0,K=K+Math.imul(_A,KA)|0,C=C+Math.imul(_A,se)|0,C=C+Math.imul(we,KA)|0,p=p+Math.imul(we,se)|0,K=K+Math.imul(HA,F)|0,C=C+Math.imul(HA,W)|0,C=C+Math.imul(ce,F)|0,p=p+Math.imul(ce,W)|0,K=K+Math.imul(GA,w)|0,C=C+Math.imul(GA,V)|0,C=C+Math.imul(lA,w)|0,p=p+Math.imul(lA,V)|0,K=K+Math.imul(sA,rA)|0,C=C+Math.imul(sA,IA)|0,C=C+Math.imul(oA,rA)|0,p=p+Math.imul(oA,IA)|0,K=K+Math.imul(S,FA)|0,C=C+Math.imul(S,xA)|0,C=C+Math.imul($,FA)|0,p=p+Math.imul($,xA)|0;var LA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(LA>>>26)|0,LA&=67108863,K=Math.imul(aA,XA),C=Math.imul(aA,ye),C=C+Math.imul(EA,XA)|0,p=Math.imul(EA,ye),K=K+Math.imul(k,Je)|0,C=C+Math.imul(k,je)|0,C=C+Math.imul(_,Je)|0,p=p+Math.imul(_,je)|0,K=K+Math.imul(zA,Be)|0,C=C+Math.imul(zA,ve)|0,C=C+Math.imul(P,Be)|0,p=p+Math.imul(P,ve)|0,K=K+Math.imul(Le,Oe)|0,C=C+Math.imul(Le,ze)|0,C=C+Math.imul(kA,Oe)|0,p=p+Math.imul(kA,ze)|0,K=K+Math.imul(de,KA)|0,C=C+Math.imul(de,se)|0,C=C+Math.imul(Ke,KA)|0,p=p+Math.imul(Ke,se)|0,K=K+Math.imul(_A,F)|0,C=C+Math.imul(_A,W)|0,C=C+Math.imul(we,F)|0,p=p+Math.imul(we,W)|0,K=K+Math.imul(HA,w)|0,C=C+Math.imul(HA,V)|0,C=C+Math.imul(ce,w)|0,p=p+Math.imul(ce,V)|0,K=K+Math.imul(GA,rA)|0,C=C+Math.imul(GA,IA)|0,C=C+Math.imul(lA,rA)|0,p=p+Math.imul(lA,IA)|0,K=K+Math.imul(sA,FA)|0,C=C+Math.imul(sA,xA)|0,C=C+Math.imul(oA,FA)|0,p=p+Math.imul(oA,xA)|0;var PA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(PA>>>26)|0,PA&=67108863,K=Math.imul(aA,Je),C=Math.imul(aA,je),C=C+Math.imul(EA,Je)|0,p=Math.imul(EA,je),K=K+Math.imul(k,Be)|0,C=C+Math.imul(k,ve)|0,C=C+Math.imul(_,Be)|0,p=p+Math.imul(_,ve)|0,K=K+Math.imul(zA,Oe)|0,C=C+Math.imul(zA,ze)|0,C=C+Math.imul(P,Oe)|0,p=p+Math.imul(P,ze)|0,K=K+Math.imul(Le,KA)|0,C=C+Math.imul(Le,se)|0,C=C+Math.imul(kA,KA)|0,p=p+Math.imul(kA,se)|0,K=K+Math.imul(de,F)|0,C=C+Math.imul(de,W)|0,C=C+Math.imul(Ke,F)|0,p=p+Math.imul(Ke,W)|0,K=K+Math.imul(_A,w)|0,C=C+Math.imul(_A,V)|0,C=C+Math.imul(we,w)|0,p=p+Math.imul(we,V)|0,K=K+Math.imul(HA,rA)|0,C=C+Math.imul(HA,IA)|0,C=C+Math.imul(ce,rA)|0,p=p+Math.imul(ce,IA)|0,K=K+Math.imul(GA,FA)|0,C=C+Math.imul(GA,xA)|0,C=C+Math.imul(lA,FA)|0,p=p+Math.imul(lA,xA)|0;var UA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(UA>>>26)|0,UA&=67108863,K=Math.imul(aA,Be),C=Math.imul(aA,ve),C=C+Math.imul(EA,Be)|0,p=Math.imul(EA,ve),K=K+Math.imul(k,Oe)|0,C=C+Math.imul(k,ze)|0,C=C+Math.imul(_,Oe)|0,p=p+Math.imul(_,ze)|0,K=K+Math.imul(zA,KA)|0,C=C+Math.imul(zA,se)|0,C=C+Math.imul(P,KA)|0,p=p+Math.imul(P,se)|0,K=K+Math.imul(Le,F)|0,C=C+Math.imul(Le,W)|0,C=C+Math.imul(kA,F)|0,p=p+Math.imul(kA,W)|0,K=K+Math.imul(de,w)|0,C=C+Math.imul(de,V)|0,C=C+Math.imul(Ke,w)|0,p=p+Math.imul(Ke,V)|0,K=K+Math.imul(_A,rA)|0,C=C+Math.imul(_A,IA)|0,C=C+Math.imul(we,rA)|0,p=p+Math.imul(we,IA)|0,K=K+Math.imul(HA,FA)|0,C=C+Math.imul(HA,xA)|0,C=C+Math.imul(ce,FA)|0,p=p+Math.imul(ce,xA)|0;var JA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(JA>>>26)|0,JA&=67108863,K=Math.imul(aA,Oe),C=Math.imul(aA,ze),C=C+Math.imul(EA,Oe)|0,p=Math.imul(EA,ze),K=K+Math.imul(k,KA)|0,C=C+Math.imul(k,se)|0,C=C+Math.imul(_,KA)|0,p=p+Math.imul(_,se)|0,K=K+Math.imul(zA,F)|0,C=C+Math.imul(zA,W)|0,C=C+Math.imul(P,F)|0,p=p+Math.imul(P,W)|0,K=K+Math.imul(Le,w)|0,C=C+Math.imul(Le,V)|0,C=C+Math.imul(kA,w)|0,p=p+Math.imul(kA,V)|0,K=K+Math.imul(de,rA)|0,C=C+Math.imul(de,IA)|0,C=C+Math.imul(Ke,rA)|0,p=p+Math.imul(Ke,IA)|0,K=K+Math.imul(_A,FA)|0,C=C+Math.imul(_A,xA)|0,C=C+Math.imul(we,FA)|0,p=p+Math.imul(we,xA)|0;var OA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(OA>>>26)|0,OA&=67108863,K=Math.imul(aA,KA),C=Math.imul(aA,se),C=C+Math.imul(EA,KA)|0,p=Math.imul(EA,se),K=K+Math.imul(k,F)|0,C=C+Math.imul(k,W)|0,C=C+Math.imul(_,F)|0,p=p+Math.imul(_,W)|0,K=K+Math.imul(zA,w)|0,C=C+Math.imul(zA,V)|0,C=C+Math.imul(P,w)|0,p=p+Math.imul(P,V)|0,K=K+Math.imul(Le,rA)|0,C=C+Math.imul(Le,IA)|0,C=C+Math.imul(kA,rA)|0,p=p+Math.imul(kA,IA)|0,K=K+Math.imul(de,FA)|0,C=C+Math.imul(de,xA)|0,C=C+Math.imul(Ke,FA)|0,p=p+Math.imul(Ke,xA)|0;var SA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(SA>>>26)|0,SA&=67108863,K=Math.imul(aA,F),C=Math.imul(aA,W),C=C+Math.imul(EA,F)|0,p=Math.imul(EA,W),K=K+Math.imul(k,w)|0,C=C+Math.imul(k,V)|0,C=C+Math.imul(_,w)|0,p=p+Math.imul(_,V)|0,K=K+Math.imul(zA,rA)|0,C=C+Math.imul(zA,IA)|0,C=C+Math.imul(P,rA)|0,p=p+Math.imul(P,IA)|0,K=K+Math.imul(Le,FA)|0,C=C+Math.imul(Le,xA)|0,C=C+Math.imul(kA,FA)|0,p=p+Math.imul(kA,xA)|0;var CA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(CA>>>26)|0,CA&=67108863,K=Math.imul(aA,w),C=Math.imul(aA,V),C=C+Math.imul(EA,w)|0,p=Math.imul(EA,V),K=K+Math.imul(k,rA)|0,C=C+Math.imul(k,IA)|0,C=C+Math.imul(_,rA)|0,p=p+Math.imul(_,IA)|0,K=K+Math.imul(zA,FA)|0,C=C+Math.imul(zA,xA)|0,C=C+Math.imul(P,FA)|0,p=p+Math.imul(P,xA)|0;var uA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(uA>>>26)|0,uA&=67108863,K=Math.imul(aA,rA),C=Math.imul(aA,IA),C=C+Math.imul(EA,rA)|0,p=Math.imul(EA,IA),K=K+Math.imul(k,FA)|0,C=C+Math.imul(k,xA)|0,C=C+Math.imul(_,FA)|0,p=p+Math.imul(_,xA)|0;var mA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(mA>>>26)|0,mA&=67108863,K=Math.imul(aA,FA),C=Math.imul(aA,xA),C=C+Math.imul(EA,FA)|0,p=Math.imul(EA,xA);var hA=(v+K|0)+((C&8191)<<13)|0;return v=(p+(C>>>13)|0)+(hA>>>26)|0,hA&=67108863,H[0]=Ee,H[1]=RA,H[2]=Ae,H[3]=ie,H[4]=le,H[5]=ae,H[6]=re,H[7]=ne,H[8]=ee,H[9]=LA,H[10]=PA,H[11]=UA,H[12]=JA,H[13]=OA,H[14]=SA,H[15]=CA,H[16]=uA,H[17]=mA,H[18]=hA,v!==0&&(H[19]=v,y.length++),y};Math.imul||(R=D);function M(x,l,I){I.negative=l.negative^x.negative,I.length=x.length+l.length;for(var y=0,b=0,J=0;J<I.length-1;J++){var H=b;b=0;for(var v=y&67108863,K=Math.min(J,l.length-1),C=Math.max(0,J-x.length+1);C<=K;C++){var p=J-C,L=x.words[p]|0,S=l.words[C]|0,$=L*S,AA=$&67108863;H=H+($/67108864|0)|0,AA=AA+v|0,v=AA&67108863,H=H+(AA>>>26)|0,b+=H>>>26,H&=67108863}I.words[J]=v,y=H,H=b}return y!==0?I.words[J]=y:I.length--,I._strip()}function q(x,l,I){return M(x,l,I)}r.prototype.mulTo=function(l,I){var y,b=this.length+l.length;return this.length===10&&l.length===10?y=R(this,l,I):b<63?y=D(this,l,I):b<1024?y=M(this,l,I):y=q(this,l,I),y},r.prototype.mul=function(l){var I=new r(null);return I.words=new Array(this.length+l.length),this.mulTo(l,I)},r.prototype.mulf=function(l){var I=new r(null);return I.words=new Array(this.length+l.length),q(this,l,I)},r.prototype.imul=function(l){return this.clone().mulTo(l,this)},r.prototype.imuln=function(l){var I=l<0;I&&(l=-l),s(typeof l=="number"),s(l<67108864);for(var y=0,b=0;b<this.length;b++){var J=(this.words[b]|0)*l,H=(J&67108863)+(y&67108863);y>>=26,y+=J/67108864|0,y+=H>>>26,this.words[b]=H&67108863}return y!==0&&(this.words[b]=y,this.length++),this.length=l===0?1:this.length,I?this.ineg():this},r.prototype.muln=function(l){return this.clone().imuln(l)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(l){var I=d(l);if(I.length===0)return new r(1);for(var y=this,b=0;b<I.length&&I[b]===0;b++,y=y.sqr());if(++b<I.length)for(var J=y.sqr();b<I.length;b++,J=J.sqr())I[b]!==0&&(y=y.mul(J));return y},r.prototype.iushln=function(l){s(typeof l=="number"&&l>=0);var I=l%26,y=(l-I)/26,b=67108863>>>26-I<<26-I,J;if(I!==0){var H=0;for(J=0;J<this.length;J++){var v=this.words[J]&b,K=(this.words[J]|0)-v<<I;this.words[J]=K|H,H=v>>>26-I}H&&(this.words[J]=H,this.length++)}if(y!==0){for(J=this.length-1;J>=0;J--)this.words[J+y]=this.words[J];for(J=0;J<y;J++)this.words[J]=0;this.length+=y}return this._strip()},r.prototype.ishln=function(l){return s(this.negative===0),this.iushln(l)},r.prototype.iushrn=function(l,I,y){s(typeof l=="number"&&l>=0);var b;I?b=(I-I%26)/26:b=0;var J=l%26,H=Math.min((l-J)/26,this.length),v=67108863^67108863>>>J<<J,K=y;if(b-=H,b=Math.max(0,b),K){for(var C=0;C<H;C++)K.words[C]=this.words[C];K.length=H}if(H!==0)if(this.length>H)for(this.length-=H,C=0;C<this.length;C++)this.words[C]=this.words[C+H];else this.words[0]=0,this.length=1;var p=0;for(C=this.length-1;C>=0&&(p!==0||C>=b);C--){var L=this.words[C]|0;this.words[C]=p<<26-J|L>>>J,p=L&v}return K&&p!==0&&(K.words[K.length++]=p),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.ishrn=function(l,I,y){return s(this.negative===0),this.iushrn(l,I,y)},r.prototype.shln=function(l){return this.clone().ishln(l)},r.prototype.ushln=function(l){return this.clone().iushln(l)},r.prototype.shrn=function(l){return this.clone().ishrn(l)},r.prototype.ushrn=function(l){return this.clone().iushrn(l)},r.prototype.testn=function(l){s(typeof l=="number"&&l>=0);var I=l%26,y=(l-I)/26,b=1<<I;if(this.length<=y)return!1;var J=this.words[y];return!!(J&b)},r.prototype.imaskn=function(l){s(typeof l=="number"&&l>=0);var I=l%26,y=(l-I)/26;if(s(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(I!==0&&y++,this.length=Math.min(y,this.length),I!==0){var b=67108863^67108863>>>I<<I;this.words[this.length-1]&=b}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.maskn=function(l){return this.clone().imaskn(l)},r.prototype.iaddn=function(l){return s(typeof l=="number"),s(l<67108864),l<0?this.isubn(-l):this.negative!==0?this.length===1&&(this.words[0]|0)<=l?(this.words[0]=l-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(l),this.negative=1,this):this._iaddn(l)},r.prototype._iaddn=function(l){this.words[0]+=l;for(var I=0;I<this.length&&this.words[I]>=67108864;I++)this.words[I]-=67108864,I===this.length-1?this.words[I+1]=1:this.words[I+1]++;return this.length=Math.max(this.length,I+1),this},r.prototype.isubn=function(l){if(s(typeof l=="number"),s(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var I=0;I<this.length&&this.words[I]<0;I++)this.words[I]+=67108864,this.words[I+1]-=1;return this._strip()},r.prototype.addn=function(l){return this.clone().iaddn(l)},r.prototype.subn=function(l){return this.clone().isubn(l)},r.prototype.iabs=function(){return this.negative=0,this},r.prototype.abs=function(){return this.clone().iabs()},r.prototype._ishlnsubmul=function(l,I,y){var b=l.length+y,J;this._expand(b);var H,v=0;for(J=0;J<l.length;J++){H=(this.words[J+y]|0)+v;var K=(l.words[J]|0)*I;H-=K&67108863,v=(H>>26)-(K/67108864|0),this.words[J+y]=H&67108863}for(;J<this.length-y;J++)H=(this.words[J+y]|0)+v,v=H>>26,this.words[J+y]=H&67108863;if(v===0)return this._strip();for(s(v===-1),v=0,J=0;J<this.length;J++)H=-(this.words[J]|0)+v,v=H>>26,this.words[J]=H&67108863;return this.negative=1,this._strip()},r.prototype._wordDiv=function(l,I){var y=this.length-l.length,b=this.clone(),J=l,H=J.words[J.length-1]|0,v=this._countBits(H);y=26-v,y!==0&&(J=J.ushln(y),b.iushln(y),H=J.words[J.length-1]|0);var K=b.length-J.length,C;if(I!=="mod"){C=new r(null),C.length=K+1,C.words=new Array(C.length);for(var p=0;p<C.length;p++)C.words[p]=0}var L=b.clone()._ishlnsubmul(J,1,K);L.negative===0&&(b=L,C&&(C.words[K]=1));for(var S=K-1;S>=0;S--){var $=(b.words[J.length+S]|0)*67108864+(b.words[J.length+S-1]|0);for($=Math.min($/H|0,67108863),b._ishlnsubmul(J,$,S);b.negative!==0;)$--,b.negative=0,b._ishlnsubmul(J,1,S),b.isZero()||(b.negative^=1);C&&(C.words[S]=$)}return C&&C._strip(),b._strip(),I!=="div"&&y!==0&&b.iushrn(y),{div:C||null,mod:b}},r.prototype.divmod=function(l,I,y){if(s(!l.isZero()),this.isZero())return{div:new r(0),mod:new r(0)};var b,J,H;return this.negative!==0&&l.negative===0?(H=this.neg().divmod(l,I),I!=="mod"&&(b=H.div.neg()),I!=="div"&&(J=H.mod.neg(),y&&J.negative!==0&&J.iadd(l)),{div:b,mod:J}):this.negative===0&&l.negative!==0?(H=this.divmod(l.neg(),I),I!=="mod"&&(b=H.div.neg()),{div:b,mod:H.mod}):(this.negative&l.negative)!==0?(H=this.neg().divmod(l.neg(),I),I!=="div"&&(J=H.mod.neg(),y&&J.negative!==0&&J.isub(l)),{div:H.div,mod:J}):l.length>this.length||this.cmp(l)<0?{div:new r(0),mod:this}:l.length===1?I==="div"?{div:this.divn(l.words[0]),mod:null}:I==="mod"?{div:null,mod:new r(this.modrn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new r(this.modrn(l.words[0]))}:this._wordDiv(l,I)},r.prototype.div=function(l){return this.divmod(l,"div",!1).div},r.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},r.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},r.prototype.divRound=function(l){var I=this.divmod(l);if(I.mod.isZero())return I.div;var y=I.div.negative!==0?I.mod.isub(l):I.mod,b=l.ushrn(1),J=l.andln(1),H=y.cmp(b);return H<0||J===1&&H===0?I.div:I.div.negative!==0?I.div.isubn(1):I.div.iaddn(1)},r.prototype.modrn=function(l){var I=l<0;I&&(l=-l),s(l<=67108863);for(var y=(1<<26)%l,b=0,J=this.length-1;J>=0;J--)b=(y*b+(this.words[J]|0))%l;return I?-b:b},r.prototype.modn=function(l){return this.modrn(l)},r.prototype.idivn=function(l){var I=l<0;I&&(l=-l),s(l<=67108863);for(var y=0,b=this.length-1;b>=0;b--){var J=(this.words[b]|0)+y*67108864;this.words[b]=J/l|0,y=J%l}return this._strip(),I?this.ineg():this},r.prototype.divn=function(l){return this.clone().idivn(l)},r.prototype.egcd=function(l){s(l.negative===0),s(!l.isZero());var I=this,y=l.clone();I.negative!==0?I=I.umod(l):I=I.clone();for(var b=new r(1),J=new r(0),H=new r(0),v=new r(1),K=0;I.isEven()&&y.isEven();)I.iushrn(1),y.iushrn(1),++K;for(var C=y.clone(),p=I.clone();!I.isZero();){for(var L=0,S=1;(I.words[0]&S)===0&&L<26;++L,S<<=1);if(L>0)for(I.iushrn(L);L-- >0;)(b.isOdd()||J.isOdd())&&(b.iadd(C),J.isub(p)),b.iushrn(1),J.iushrn(1);for(var $=0,AA=1;(y.words[0]&AA)===0&&$<26;++$,AA<<=1);if($>0)for(y.iushrn($);$-- >0;)(H.isOdd()||v.isOdd())&&(H.iadd(C),v.isub(p)),H.iushrn(1),v.iushrn(1);I.cmp(y)>=0?(I.isub(y),b.isub(H),J.isub(v)):(y.isub(I),H.isub(b),v.isub(J))}return{a:H,b:v,gcd:y.iushln(K)}},r.prototype._invmp=function(l){s(l.negative===0),s(!l.isZero());var I=this,y=l.clone();I.negative!==0?I=I.umod(l):I=I.clone();for(var b=new r(1),J=new r(0),H=y.clone();I.cmpn(1)>0&&y.cmpn(1)>0;){for(var v=0,K=1;(I.words[0]&K)===0&&v<26;++v,K<<=1);if(v>0)for(I.iushrn(v);v-- >0;)b.isOdd()&&b.iadd(H),b.iushrn(1);for(var C=0,p=1;(y.words[0]&p)===0&&C<26;++C,p<<=1);if(C>0)for(y.iushrn(C);C-- >0;)J.isOdd()&&J.iadd(H),J.iushrn(1);I.cmp(y)>=0?(I.isub(y),b.isub(J)):(y.isub(I),J.isub(b))}var L;return I.cmpn(1)===0?L=b:L=J,L.cmpn(0)<0&&L.iadd(l),L},r.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var I=this.clone(),y=l.clone();I.negative=0,y.negative=0;for(var b=0;I.isEven()&&y.isEven();b++)I.iushrn(1),y.iushrn(1);do{for(;I.isEven();)I.iushrn(1);for(;y.isEven();)y.iushrn(1);var J=I.cmp(y);if(J<0){var H=I;I=y,y=H}else if(J===0||y.cmpn(1)===0)break;I.isub(y)}while(!0);return y.iushln(b)},r.prototype.invm=function(l){return this.egcd(l).a.umod(l)},r.prototype.isEven=function(){return(this.words[0]&1)===0},r.prototype.isOdd=function(){return(this.words[0]&1)===1},r.prototype.andln=function(l){return this.words[0]&l},r.prototype.bincn=function(l){s(typeof l=="number");var I=l%26,y=(l-I)/26,b=1<<I;if(this.length<=y)return this._expand(y+1),this.words[y]|=b,this;for(var J=b,H=y;J!==0&&H<this.length;H++){var v=this.words[H]|0;v+=J,J=v>>>26,v&=67108863,this.words[H]=v}return J!==0&&(this.words[H]=J,this.length++),this},r.prototype.isZero=function(){return this.length===1&&this.words[0]===0},r.prototype.cmpn=function(l){var I=l<0;if(this.negative!==0&&!I)return-1;if(this.negative===0&&I)return 1;this._strip();var y;if(this.length>1)y=1;else{I&&(l=-l),s(l<=67108863,"Number is too big");var b=this.words[0]|0;y=b===l?0:b<l?-1:1}return this.negative!==0?-y|0:y},r.prototype.cmp=function(l){if(this.negative!==0&&l.negative===0)return-1;if(this.negative===0&&l.negative!==0)return 1;var I=this.ucmp(l);return this.negative!==0?-I|0:I},r.prototype.ucmp=function(l){if(this.length>l.length)return 1;if(this.length<l.length)return-1;for(var I=0,y=this.length-1;y>=0;y--){var b=this.words[y]|0,J=l.words[y]|0;if(b!==J){b<J?I=-1:b>J&&(I=1);break}}return I},r.prototype.gtn=function(l){return this.cmpn(l)===1},r.prototype.gt=function(l){return this.cmp(l)===1},r.prototype.gten=function(l){return this.cmpn(l)>=0},r.prototype.gte=function(l){return this.cmp(l)>=0},r.prototype.ltn=function(l){return this.cmpn(l)===-1},r.prototype.lt=function(l){return this.cmp(l)===-1},r.prototype.lten=function(l){return this.cmpn(l)<=0},r.prototype.lte=function(l){return this.cmp(l)<=0},r.prototype.eqn=function(l){return this.cmpn(l)===0},r.prototype.eq=function(l){return this.cmp(l)===0},r.red=function(l){return new j(l)},r.prototype.toRed=function(l){return s(!this.red,"Already a number in reduction context"),s(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},r.prototype.fromRed=function(){return s(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},r.prototype._forceRed=function(l){return this.red=l,this},r.prototype.forceRed=function(l){return s(!this.red,"Already a number in reduction context"),this._forceRed(l)},r.prototype.redAdd=function(l){return s(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},r.prototype.redIAdd=function(l){return s(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},r.prototype.redSub=function(l){return s(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},r.prototype.redISub=function(l){return s(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},r.prototype.redShl=function(l){return s(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},r.prototype.redMul=function(l){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},r.prototype.redIMul=function(l){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},r.prototype.redSqr=function(){return s(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return s(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return s(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return s(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return s(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(l){return s(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var G={k256:null,p224:null,p192:null,p25519:null};function T(x,l){this.name=x,this.p=new r(l,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}T.prototype._tmp=function(){var l=new r(null);return l.words=new Array(Math.ceil(this.n/13)),l},T.prototype.ireduce=function(l){var I=l,y;do this.split(I,this.tmp),I=this.imulK(I),I=I.iadd(this.tmp),y=I.bitLength();while(y>this.n);var b=y<this.n?-1:I.ucmp(this.p);return b===0?(I.words[0]=0,I.length=1):b>0?I.isub(this.p):I.strip!==void 0?I.strip():I._strip(),I},T.prototype.split=function(l,I){l.iushrn(this.n,0,I)},T.prototype.imulK=function(l){return l.imul(this.k)};function Z(){T.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(Z,T),Z.prototype.split=function(l,I){for(var y=4194303,b=Math.min(l.length,9),J=0;J<b;J++)I.words[J]=l.words[J];if(I.length=b,l.length<=9){l.words[0]=0,l.length=1;return}var H=l.words[9];for(I.words[I.length++]=H&y,J=10;J<l.length;J++){var v=l.words[J]|0;l.words[J-10]=(v&y)<<4|H>>>22,H=v}H>>>=22,l.words[J-10]=H,H===0&&l.length>10?l.length-=10:l.length-=9},Z.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var I=0,y=0;y<l.length;y++){var b=l.words[y]|0;I+=b*977,l.words[y]=I&67108863,I=b*64+(I/67108864|0)}return l.words[l.length-1]===0&&(l.length--,l.words[l.length-1]===0&&l.length--),l};function X(){T.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(X,T);function U(){T.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(U,T);function O(){T.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(O,T),O.prototype.imulK=function(l){for(var I=0,y=0;y<l.length;y++){var b=(l.words[y]|0)*19+I,J=b&67108863;b>>>=26,l.words[y]=J,I=b}return I!==0&&(l.words[l.length++]=I),l},r._prime=function(l){if(G[l])return G[l];var I;if(l==="k256")I=new Z;else if(l==="p224")I=new X;else if(l==="p192")I=new U;else if(l==="p25519")I=new O;else throw new Error("Unknown prime "+l);return G[l]=I,I};function j(x){if(typeof x=="string"){var l=r._prime(x);this.m=l.p,this.prime=l}else s(x.gtn(1),"modulus must be greater than 1"),this.m=x,this.prime=null}j.prototype._verify1=function(l){s(l.negative===0,"red works only with positives"),s(l.red,"red works only with red numbers")},j.prototype._verify2=function(l,I){s((l.negative|I.negative)===0,"red works only with positives"),s(l.red&&l.red===I.red,"red works only with red numbers")},j.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):(B(l,l.umod(this.m)._forceRed(this)),l)},j.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},j.prototype.add=function(l,I){this._verify2(l,I);var y=l.add(I);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},j.prototype.iadd=function(l,I){this._verify2(l,I);var y=l.iadd(I);return y.cmp(this.m)>=0&&y.isub(this.m),y},j.prototype.sub=function(l,I){this._verify2(l,I);var y=l.sub(I);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},j.prototype.isub=function(l,I){this._verify2(l,I);var y=l.isub(I);return y.cmpn(0)<0&&y.iadd(this.m),y},j.prototype.shl=function(l,I){return this._verify1(l),this.imod(l.ushln(I))},j.prototype.imul=function(l,I){return this._verify2(l,I),this.imod(l.imul(I))},j.prototype.mul=function(l,I){return this._verify2(l,I),this.imod(l.mul(I))},j.prototype.isqr=function(l){return this.imul(l,l.clone())},j.prototype.sqr=function(l){return this.mul(l,l)},j.prototype.sqrt=function(l){if(l.isZero())return l.clone();var I=this.m.andln(3);if(s(I%2===1),I===3){var y=this.m.add(new r(1)).iushrn(2);return this.pow(l,y)}for(var b=this.m.subn(1),J=0;!b.isZero()&&b.andln(1)===0;)J++,b.iushrn(1);s(!b.isZero());var H=new r(1).toRed(this),v=H.redNeg(),K=this.m.subn(1).iushrn(1),C=this.m.bitLength();for(C=new r(2*C*C).toRed(this);this.pow(C,K).cmp(v)!==0;)C.redIAdd(v);for(var p=this.pow(C,b),L=this.pow(l,b.addn(1).iushrn(1)),S=this.pow(l,b),$=J;S.cmp(H)!==0;){for(var AA=S,sA=0;AA.cmp(H)!==0;sA++)AA=AA.redSqr();s(sA<$);var oA=this.pow(p,new r(1).iushln($-sA-1));L=L.redMul(oA),p=oA.redSqr(),S=S.redMul(p),$=sA}return L},j.prototype.invm=function(l){var I=l._invmp(this.m);return I.negative!==0?(I.negative=0,this.imod(I).redNeg()):this.imod(I)},j.prototype.pow=function(l,I){if(I.isZero())return new r(1).toRed(this);if(I.cmpn(1)===0)return l.clone();var y=4,b=new Array(1<<y);b[0]=new r(1).toRed(this),b[1]=l;for(var J=2;J<b.length;J++)b[J]=this.mul(b[J-1],l);var H=b[0],v=0,K=0,C=I.bitLength()%26;for(C===0&&(C=26),J=I.length-1;J>=0;J--){for(var p=I.words[J],L=C-1;L>=0;L--){var S=p>>L&1;if(H!==b[0]&&(H=this.sqr(H)),S===0&&v===0){K=0;continue}v<<=1,v|=S,K++,!(K!==y&&(J!==0||L!==0))&&(H=this.mul(H,b[v]),K=0,v=0)}C=26}return H},j.prototype.convertTo=function(l){var I=l.umod(this.m);return I===l?I.clone():I},j.prototype.convertFrom=function(l){var I=l.clone();return I.red=null,I},r.mont=function(l){return new Y(l)};function Y(x){j.call(this,x),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(Y,j),Y.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},Y.prototype.convertFrom=function(l){var I=this.imod(l.mul(this.rinv));return I.red=null,I},Y.prototype.imul=function(l,I){if(l.isZero()||I.isZero())return l.words[0]=0,l.length=1,l;var y=l.imul(I),b=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),J=y.isub(b).iushrn(this.shift),H=J;return J.cmp(this.m)>=0?H=J.isub(this.m):J.cmpn(0)<0&&(H=J.iadd(this.m)),H._forceRed(this)},Y.prototype.mul=function(l,I){if(l.isZero()||I.isZero())return new r(0)._forceRed(this);var y=l.mul(I),b=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),J=y.isub(b).iushrn(this.shift),H=J;return J.cmp(this.m)>=0?H=J.isub(this.m):J.cmpn(0)<0&&(H=J.iadd(this.m)),H._forceRed(this)},Y.prototype.invm=function(l){var I=this.imod(l._invmp(this.m).mul(this.r2));return I._forceRed(this)}})(A,eD)})(wn)),wn.exports}var tD=IE();const cQ=sB(tD);var gn={exports:{}};var EQ;function dE(){return EQ||(EQ=1,(function(A,e){var t=Fg(),s=t.Buffer;function n(i,a){for(var g in i)a[g]=i[g]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?A.exports=t:(n(t,e),e.Buffer=r);function r(i,a,g){return s(i,a,g)}r.prototype=Object.create(s.prototype),n(s,r),r.from=function(i,a,g){if(typeof i=="number")throw new TypeError("Argument must not be a number");return s(i,a,g)},r.alloc=function(i,a,g){if(typeof i!="number")throw new TypeError("Argument must be a number");var Q=s(i);return a!==void 0?typeof g=="string"?Q.fill(a,g):Q.fill(a):Q.fill(0),Q},r.allocUnsafe=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return s(i)},r.allocUnsafeSlow=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(i)}})(gn,gn.exports)),gn.exports}var Ui,CQ;function oD(){if(CQ)return Ui;CQ=1;var A=dE().Buffer;function e(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),n=0;n<s.length;n++)s[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),a=i.charCodeAt(0);if(s[a]!==255)throw new TypeError(i+" is ambiguous");s[a]=r}var g=t.length,Q=t.charAt(0),B=Math.log(g)/Math.log(256),u=Math.log(256)/Math.log(g);function E(f){if((Array.isArray(f)||f instanceof Uint8Array)&&(f=A.from(f)),!A.isBuffer(f))throw new TypeError("Expected Buffer");if(f.length===0)return"";for(var d=0,D=0,R=0,M=f.length;R!==M&&f[R]===0;)R++,d++;for(var q=(M-R)*u+1>>>0,G=new Uint8Array(q);R!==M;){for(var T=f[R],Z=0,X=q-1;(T!==0||Z<D)&&X!==-1;X--,Z++)T+=256*G[X]>>>0,G[X]=T%g>>>0,T=T/g>>>0;if(T!==0)throw new Error("Non-zero carry");D=Z,R++}for(var U=q-D;U!==q&&G[U]===0;)U++;for(var O=Q.repeat(d);U<q;++U)O+=t.charAt(G[U]);return O}function c(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return A.alloc(0);for(var d=0,D=0,R=0;f[d]===Q;)D++,d++;for(var M=(f.length-d)*B+1>>>0,q=new Uint8Array(M);d<f.length;){var G=f.charCodeAt(d);if(G>255)return;var T=s[G];if(T===255)return;for(var Z=0,X=M-1;(T!==0||Z<R)&&X!==-1;X--,Z++)T+=g*q[X]>>>0,q[X]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");R=Z,d++}for(var U=M-R;U!==M&&q[U]===0;)U++;var O=A.allocUnsafe(D+(M-U));O.fill(0,0,D);for(var j=D;U!==M;)O[j++]=q[U++];return O}function h(f){var d=c(f);if(d)return d;throw new Error("Non-base"+g+" character")}return{encode:E,decodeUnsafe:c,decode:h}}return Ui=e,Ui}var Ri,uQ;function sD(){if(uQ)return Ri;uQ=1;var A=oD(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return Ri=A(e),Ri}var rD=sD();const IQ=sB(rD),dQ=Vc;var Xe={},Ki,hQ;function nD(){if(hQ)return Ki;hQ=1;var A=dE().Buffer;function e(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),n=0;n<s.length;n++)s[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),a=i.charCodeAt(0);if(s[a]!==255)throw new TypeError(i+" is ambiguous");s[a]=r}var g=t.length,Q=t.charAt(0),B=Math.log(g)/Math.log(256),u=Math.log(256)/Math.log(g);function E(f){if((Array.isArray(f)||f instanceof Uint8Array)&&(f=A.from(f)),!A.isBuffer(f))throw new TypeError("Expected Buffer");if(f.length===0)return"";for(var d=0,D=0,R=0,M=f.length;R!==M&&f[R]===0;)R++,d++;for(var q=(M-R)*u+1>>>0,G=new Uint8Array(q);R!==M;){for(var T=f[R],Z=0,X=q-1;(T!==0||Z<D)&&X!==-1;X--,Z++)T+=256*G[X]>>>0,G[X]=T%g>>>0,T=T/g>>>0;if(T!==0)throw new Error("Non-zero carry");D=Z,R++}for(var U=q-D;U!==q&&G[U]===0;)U++;for(var O=Q.repeat(d);U<q;++U)O+=t.charAt(G[U]);return O}function c(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return A.alloc(0);for(var d=0,D=0,R=0;f[d]===Q;)D++,d++;for(var M=(f.length-d)*B+1>>>0,q=new Uint8Array(M);d<f.length;){var G=f.charCodeAt(d);if(G>255)return;var T=s[G];if(T===255)return;for(var Z=0,X=M-1;(T!==0||Z<R)&&X!==-1;X--,Z++)T+=g*q[X]>>>0,q[X]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");R=Z,d++}for(var U=M-R;U!==M&&q[U]===0;)U++;var O=A.allocUnsafe(D+(M-U));O.fill(0,0,D);for(var j=D;U!==M;)O[j++]=q[U++];return O}function h(f){var d=c(f);if(d)return d;throw new Error("Non-base"+g+" character")}return{encode:E,decodeUnsafe:c,decode:h}}return Ki=e,Ki}var Li,pQ;function iD(){if(pQ)return Li;pQ=1;var A=nD(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return Li=A(e),Li}function zo(A,e,t){return e<=A&&A<=t}function li(A){if(A===void 0)return{};if(A===Object(A))return A;throw TypeError("Could not convert argument to dictionary")}function aD(A){for(var e=String(A),t=e.length,s=0,n=[];s<t;){var r=e.charCodeAt(s);if(r<55296||r>57343)n.push(r);else if(56320<=r&&r<=57343)n.push(65533);else if(55296<=r&&r<=56319)if(s===t-1)n.push(65533);else{var i=A.charCodeAt(s+1);if(56320<=i&&i<=57343){var a=r&1023,g=i&1023;n.push(65536+(a<<10)+g),s+=1}else n.push(65533)}s+=1}return n}function gD(A){for(var e="",t=0;t<A.length;++t){var s=A[t];s<=65535?e+=String.fromCharCode(s):(s-=65536,e+=String.fromCharCode((s>>10)+55296,(s&1023)+56320))}return e}var Kn=-1;function Lg(A){this.tokens=[].slice.call(A)}Lg.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Kn},prepend:function(A){if(Array.isArray(A))for(var e=A;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(A)},push:function(A){if(Array.isArray(A))for(var e=A;e.length;)this.tokens.push(e.shift());else this.tokens.push(A)}};var Xs=-1;function Ji(A,e){if(A)throw TypeError("Decoder error");return e||65533}var Ln="utf-8";function Jn(A,e){if(!(this instanceof Jn))return new Jn(A,e);if(A=A!==void 0?String(A).toLowerCase():Ln,A!==Ln)throw new Error("Encoding not supported. Only utf-8 is supported");e=li(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}Jn.prototype={decode:function(e,t){var s;typeof e=="object"&&e instanceof ArrayBuffer?s=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?s=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):s=new Uint8Array(0),t=li(t),this._streaming||(this._decoder=new lD({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var n=new Lg(s),r=[],i;!n.endOfStream()&&(i=this._decoder.handler(n,n.read()),i!==Xs);)i!==null&&(Array.isArray(i)?r.push.apply(r,i):r.push(i));if(!this._streaming){do{if(i=this._decoder.handler(n,n.read()),i===Xs)break;i!==null&&(Array.isArray(i)?r.push.apply(r,i):r.push(i))}while(!n.endOfStream());this._decoder=null}return r.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(r[0]===65279?(this._BOMseen=!0,r.shift()):this._BOMseen=!0),gD(r)}};function Tn(A,e){if(!(this instanceof Tn))return new Tn(A,e);if(A=A!==void 0?String(A).toLowerCase():Ln,A!==Ln)throw new Error("Encoding not supported. Only utf-8 is supported");e=li(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Tn.prototype={encode:function(e,t){e=e?String(e):"",t=li(t),this._streaming||(this._encoder=new QD(this._options)),this._streaming=!!t.stream;for(var s=[],n=new Lg(aD(e)),r;!n.endOfStream()&&(r=this._encoder.handler(n,n.read()),r!==Xs);)Array.isArray(r)?s.push.apply(s,r):s.push(r);if(!this._streaming){for(;r=this._encoder.handler(n,n.read()),r!==Xs;)Array.isArray(r)?s.push.apply(s,r):s.push(r);this._encoder=null}return new Uint8Array(s)}};function lD(A){var e=A.fatal,t=0,s=0,n=0,r=128,i=191;this.handler=function(a,g){if(g===Kn&&n!==0)return n=0,Ji(e);if(g===Kn)return Xs;if(n===0){if(zo(g,0,127))return g;if(zo(g,194,223))n=1,t=g-192;else if(zo(g,224,239))g===224&&(r=160),g===237&&(i=159),n=2,t=g-224;else if(zo(g,240,244))g===240&&(r=144),g===244&&(i=143),n=3,t=g-240;else return Ji(e);return t=t<<6*n,null}if(!zo(g,r,i))return t=n=s=0,r=128,i=191,a.prepend(g),Ji(e);if(r=128,i=191,s+=1,t+=g-128<<6*(n-s),s!==n)return null;var Q=t;return t=n=s=0,Q}}function QD(A){A.fatal,this.handler=function(e,t){if(t===Kn)return Xs;if(zo(t,0,127))return t;var s,n;zo(t,128,2047)?(s=1,n=192):zo(t,2048,65535)?(s=2,n=224):zo(t,65536,1114111)&&(s=3,n=240);for(var r=[(t>>6*s)+n];s>0;){var i=t>>6*(s-1);r.push(128|i&63),s-=1}return r}}const BD=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Jn,TextEncoder:Tn},Symbol.toStringTag,{value:"Module"})),cD=za(BD);var fQ;function ED(){if(fQ)return Xe;fQ=1;var A=Xe&&Xe.__createBinding||(Object.create?(function(U,O,j,Y){Y===void 0&&(Y=j),Object.defineProperty(U,Y,{enumerable:!0,get:function(){return O[j]}})}):(function(U,O,j,Y){Y===void 0&&(Y=j),U[Y]=O[j]})),e=Xe&&Xe.__setModuleDefault||(Object.create?(function(U,O){Object.defineProperty(U,"default",{enumerable:!0,value:O})}):function(U,O){U.default=O}),t=Xe&&Xe.__decorate||function(U,O,j,Y){var x=arguments.length,l=x<3?O:Y===null?Y=Object.getOwnPropertyDescriptor(O,j):Y,I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(U,O,j,Y);else for(var y=U.length-1;y>=0;y--)(I=U[y])&&(l=(x<3?I(l):x>3?I(O,j,l):I(O,j))||l);return x>3&&l&&Object.defineProperty(O,j,l),l},s=Xe&&Xe.__importStar||function(U){if(U&&U.__esModule)return U;var O={};if(U!=null)for(var j in U)j!=="default"&&Object.hasOwnProperty.call(U,j)&&A(O,U,j);return e(O,U),O},n=Xe&&Xe.__importDefault||function(U){return U&&U.__esModule?U:{default:U}};Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.deserializeUnchecked=Xe.deserialize=Xe.serialize=Xe.BinaryReader=Xe.BinaryWriter=Xe.BorshError=Xe.baseDecode=Xe.baseEncode=void 0;const r=n(IE()),i=n(iD()),a=s(cD),g=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,Q=new g("utf-8",{fatal:!0});function B(U){return typeof U=="string"&&(U=Buffer.from(U,"utf8")),i.default.encode(Buffer.from(U))}Xe.baseEncode=B;function u(U){return Buffer.from(i.default.decode(U))}Xe.baseDecode=u;const E=1024;class c extends Error{constructor(O){super(O),this.fieldPath=[],this.originalMessage=O}addToFieldPath(O){this.fieldPath.splice(0,0,O),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Xe.BorshError=c;class h{constructor(){this.buf=Buffer.alloc(E),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(E)]))}writeU8(O){this.maybeResize(),this.buf.writeUInt8(O,this.length),this.length+=1}writeU16(O){this.maybeResize(),this.buf.writeUInt16LE(O,this.length),this.length+=2}writeU32(O){this.maybeResize(),this.buf.writeUInt32LE(O,this.length),this.length+=4}writeU64(O){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(O).toArray("le",8)))}writeU128(O){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(O).toArray("le",16)))}writeU256(O){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(O).toArray("le",32)))}writeU512(O){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(O).toArray("le",64)))}writeBuffer(O){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),O,Buffer.alloc(E)]),this.length+=O.length}writeString(O){this.maybeResize();const j=Buffer.from(O,"utf8");this.writeU32(j.length),this.writeBuffer(j)}writeFixedArray(O){this.writeBuffer(Buffer.from(O))}writeArray(O,j){this.maybeResize(),this.writeU32(O.length);for(const Y of O)this.maybeResize(),j(Y)}toArray(){return this.buf.subarray(0,this.length)}}Xe.BinaryWriter=h;function f(U,O,j){const Y=j.value;j.value=function(...x){try{return Y.apply(this,x)}catch(l){if(l instanceof RangeError){const I=l.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(I)>=0)throw new c("Reached the end of buffer when deserializing")}throw l}}}class d{constructor(O){this.buf=O,this.offset=0}readU8(){const O=this.buf.readUInt8(this.offset);return this.offset+=1,O}readU16(){const O=this.buf.readUInt16LE(this.offset);return this.offset+=2,O}readU32(){const O=this.buf.readUInt32LE(this.offset);return this.offset+=4,O}readU64(){const O=this.readBuffer(8);return new r.default(O,"le")}readU128(){const O=this.readBuffer(16);return new r.default(O,"le")}readU256(){const O=this.readBuffer(32);return new r.default(O,"le")}readU512(){const O=this.readBuffer(64);return new r.default(O,"le")}readBuffer(O){if(this.offset+O>this.buf.length)throw new c(`Expected buffer length ${O} isn't within bounds`);const j=this.buf.slice(this.offset,this.offset+O);return this.offset+=O,j}readString(){const O=this.readU32(),j=this.readBuffer(O);try{return Q.decode(j)}catch(Y){throw new c(`Error decoding UTF-8 string: ${Y}`)}}readFixedArray(O){return new Uint8Array(this.readBuffer(O))}readArray(O){const j=this.readU32(),Y=Array();for(let x=0;x<j;++x)Y.push(O());return Y}}t([f],d.prototype,"readU8",null),t([f],d.prototype,"readU16",null),t([f],d.prototype,"readU32",null),t([f],d.prototype,"readU64",null),t([f],d.prototype,"readU128",null),t([f],d.prototype,"readU256",null),t([f],d.prototype,"readU512",null),t([f],d.prototype,"readString",null),t([f],d.prototype,"readFixedArray",null),t([f],d.prototype,"readArray",null),Xe.BinaryReader=d;function D(U){return U.charAt(0).toUpperCase()+U.slice(1)}function R(U,O,j,Y,x){try{if(typeof Y=="string")x[`write${D(Y)}`](j);else if(Y instanceof Array)if(typeof Y[0]=="number"){if(j.length!==Y[0])throw new c(`Expecting byte array of length ${Y[0]}, but got ${j.length} bytes`);x.writeFixedArray(j)}else if(Y.length===2&&typeof Y[1]=="number"){if(j.length!==Y[1])throw new c(`Expecting byte array of length ${Y[1]}, but got ${j.length} bytes`);for(let l=0;l<Y[1];l++)R(U,null,j[l],Y[0],x)}else x.writeArray(j,l=>{R(U,O,l,Y[0],x)});else if(Y.kind!==void 0)switch(Y.kind){case"option":{j==null?x.writeU8(0):(x.writeU8(1),R(U,O,j,Y.type,x));break}case"map":{x.writeU32(j.size),j.forEach((l,I)=>{R(U,O,I,Y.key,x),R(U,O,l,Y.value,x)});break}default:throw new c(`FieldType ${Y} unrecognized`)}else M(U,j,x)}catch(l){throw l instanceof c&&l.addToFieldPath(O),l}}function M(U,O,j){if(typeof O.borshSerialize=="function"){O.borshSerialize(j);return}const Y=U.get(O.constructor);if(!Y)throw new c(`Class ${O.constructor.name} is missing in schema`);if(Y.kind==="struct")Y.fields.map(([x,l])=>{R(U,x,O[x],l,j)});else if(Y.kind==="enum"){const x=O[Y.field];for(let l=0;l<Y.values.length;++l){const[I,y]=Y.values[l];if(I===x){j.writeU8(l),R(U,I,O[I],y,j);break}}}else throw new c(`Unexpected schema kind: ${Y.kind} for ${O.constructor.name}`)}function q(U,O,j=h){const Y=new j;return M(U,O,Y),Y.toArray()}Xe.serialize=q;function G(U,O,j,Y){try{if(typeof j=="string")return Y[`read${D(j)}`]();if(j instanceof Array){if(typeof j[0]=="number")return Y.readFixedArray(j[0]);if(typeof j[1]=="number"){const x=[];for(let l=0;l<j[1];l++)x.push(G(U,null,j[0],Y));return x}else return Y.readArray(()=>G(U,O,j[0],Y))}if(j.kind==="option")return Y.readU8()?G(U,O,j.type,Y):void 0;if(j.kind==="map"){let x=new Map;const l=Y.readU32();for(let I=0;I<l;I++){const y=G(U,O,j.key,Y),b=G(U,O,j.value,Y);x.set(y,b)}return x}return T(U,j,Y)}catch(x){throw x instanceof c&&x.addToFieldPath(O),x}}function T(U,O,j){if(typeof O.borshDeserialize=="function")return O.borshDeserialize(j);const Y=U.get(O);if(!Y)throw new c(`Class ${O.name} is missing in schema`);if(Y.kind==="struct"){const x={};for(const[l,I]of U.get(O).fields)x[l]=G(U,l,I,j);return new O(x)}if(Y.kind==="enum"){const x=j.readU8();if(x>=Y.values.length)throw new c(`Enum index: ${x} is out of range`);const[l,I]=Y.values[x],y=G(U,l,I,j);return new O({[l]:y})}throw new c(`Unexpected schema kind: ${Y.kind} for ${O.constructor.name}`)}function Z(U,O,j,Y=d){const x=new Y(j),l=T(U,O,x);if(x.offset<j.length)throw new c(`Unexpected ${j.length-x.offset} bytes after deserialized data`);return l}Xe.deserialize=Z;function X(U,O,j,Y=d){const x=new Y(j);return T(U,O,x)}return Xe.deserializeUnchecked=X,Xe}var Ti=ED(),cA={},mQ;function CD(){if(mQ)return cA;mQ=1,Object.defineProperty(cA,"__esModule",{value:!0}),cA.s16=cA.s8=cA.nu64be=cA.u48be=cA.u40be=cA.u32be=cA.u24be=cA.u16be=cA.nu64=cA.u48=cA.u40=cA.u32=cA.u24=cA.u16=cA.u8=cA.offset=cA.greedy=cA.Constant=cA.UTF8=cA.CString=cA.Blob=cA.Boolean=cA.BitField=cA.BitStructure=cA.VariantLayout=cA.Union=cA.UnionLayoutDiscriminator=cA.UnionDiscriminator=cA.Structure=cA.Sequence=cA.DoubleBE=cA.Double=cA.FloatBE=cA.Float=cA.NearInt64BE=cA.NearInt64=cA.NearUInt64BE=cA.NearUInt64=cA.IntBE=cA.Int=cA.UIntBE=cA.UInt=cA.OffsetLayout=cA.GreedyCount=cA.ExternalLayout=cA.bindConstructorLayout=cA.nameWithProperty=cA.Layout=cA.uint8ArrayToBuffer=cA.checkUint8Array=void 0,cA.constant=cA.utf8=cA.cstr=cA.blob=cA.unionLayoutDiscriminator=cA.union=cA.seq=cA.bits=cA.struct=cA.f64be=cA.f64=cA.f32be=cA.f32=cA.ns64be=cA.s48be=cA.s40be=cA.s32be=cA.s24be=cA.s16be=cA.ns64=cA.s48=cA.s40=cA.s32=cA.s24=void 0;const A=Fg();function e(C){if(!(C instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}cA.checkUint8Array=e;function t(C){return e(C),A.Buffer.from(C.buffer,C.byteOffset,C.length)}cA.uint8ArrayToBuffer=t;let s=class{constructor(p,L){if(!Number.isInteger(p))throw new TypeError("span must be an integer");this.span=p,this.property=L}makeDestinationObject(){return{}}getSpan(p,L){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(p){const L=Object.create(this.constructor.prototype);return Object.assign(L,this),L.property=p,L}fromArray(p){}};cA.Layout=s;function n(C,p){return p.property?C+"["+p.property+"]":C}cA.nameWithProperty=n;function r(C,p){if(typeof C!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(C,"layout_"))throw new Error("Class is already bound to a layout");if(!(p&&p instanceof s))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(p,"boundConstructor_"))throw new Error("layout is already bound to a constructor");C.layout_=p,p.boundConstructor_=C,p.makeDestinationObject=(()=>new C),Object.defineProperty(C.prototype,"encode",{value(L,S){return p.encode(this,L,S)},writable:!0}),Object.defineProperty(C,"decode",{value(L,S){return p.decode(L,S)},writable:!0})}cA.bindConstructorLayout=r;class i extends s{isCount(){throw new Error("ExternalLayout is abstract")}}cA.ExternalLayout=i;class a extends i{constructor(p=1,L){if(!Number.isInteger(p)||0>=p)throw new TypeError("elementSpan must be a (positive) integer");super(-1,L),this.elementSpan=p}isCount(){return!0}decode(p,L=0){e(p);const S=p.length-L;return Math.floor(S/this.elementSpan)}encode(p,L,S){return 0}}cA.GreedyCount=a;class g extends i{constructor(p,L=0,S){if(!(p instanceof s))throw new TypeError("layout must be a Layout");if(!Number.isInteger(L))throw new TypeError("offset must be integer or undefined");super(p.span,S||p.property),this.layout=p,this.offset=L}isCount(){return this.layout instanceof Q||this.layout instanceof B}decode(p,L=0){return this.layout.decode(p,L+this.offset)}encode(p,L,S=0){return this.layout.encode(p,L,S+this.offset)}}cA.OffsetLayout=g;class Q extends s{constructor(p,L){if(super(p,L),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,L=0){return t(p).readUIntLE(L,this.span)}encode(p,L,S=0){return t(L).writeUIntLE(p,S,this.span),this.span}}cA.UInt=Q;class B extends s{constructor(p,L){if(super(p,L),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,L=0){return t(p).readUIntBE(L,this.span)}encode(p,L,S=0){return t(L).writeUIntBE(p,S,this.span),this.span}}cA.UIntBE=B;class u extends s{constructor(p,L){if(super(p,L),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,L=0){return t(p).readIntLE(L,this.span)}encode(p,L,S=0){return t(L).writeIntLE(p,S,this.span),this.span}}cA.Int=u;class E extends s{constructor(p,L){if(super(p,L),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,L=0){return t(p).readIntBE(L,this.span)}encode(p,L,S=0){return t(L).writeIntBE(p,S,this.span),this.span}}cA.IntBE=E;const c=Math.pow(2,32);function h(C){const p=Math.floor(C/c),L=C-p*c;return{hi32:p,lo32:L}}function f(C,p){return C*c+p}class d extends s{constructor(p){super(8,p)}decode(p,L=0){const S=t(p),$=S.readUInt32LE(L),AA=S.readUInt32LE(L+4);return f(AA,$)}encode(p,L,S=0){const $=h(p),AA=t(L);return AA.writeUInt32LE($.lo32,S),AA.writeUInt32LE($.hi32,S+4),8}}cA.NearUInt64=d;class D extends s{constructor(p){super(8,p)}decode(p,L=0){const S=t(p),$=S.readUInt32BE(L),AA=S.readUInt32BE(L+4);return f($,AA)}encode(p,L,S=0){const $=h(p),AA=t(L);return AA.writeUInt32BE($.hi32,S),AA.writeUInt32BE($.lo32,S+4),8}}cA.NearUInt64BE=D;class R extends s{constructor(p){super(8,p)}decode(p,L=0){const S=t(p),$=S.readUInt32LE(L),AA=S.readInt32LE(L+4);return f(AA,$)}encode(p,L,S=0){const $=h(p),AA=t(L);return AA.writeUInt32LE($.lo32,S),AA.writeInt32LE($.hi32,S+4),8}}cA.NearInt64=R;class M extends s{constructor(p){super(8,p)}decode(p,L=0){const S=t(p),$=S.readInt32BE(L),AA=S.readUInt32BE(L+4);return f($,AA)}encode(p,L,S=0){const $=h(p),AA=t(L);return AA.writeInt32BE($.hi32,S),AA.writeUInt32BE($.lo32,S+4),8}}cA.NearInt64BE=M;class q extends s{constructor(p){super(4,p)}decode(p,L=0){return t(p).readFloatLE(L)}encode(p,L,S=0){return t(L).writeFloatLE(p,S),4}}cA.Float=q;class G extends s{constructor(p){super(4,p)}decode(p,L=0){return t(p).readFloatBE(L)}encode(p,L,S=0){return t(L).writeFloatBE(p,S),4}}cA.FloatBE=G;class T extends s{constructor(p){super(8,p)}decode(p,L=0){return t(p).readDoubleLE(L)}encode(p,L,S=0){return t(L).writeDoubleLE(p,S),8}}cA.Double=T;class Z extends s{constructor(p){super(8,p)}decode(p,L=0){return t(p).readDoubleBE(L)}encode(p,L,S=0){return t(L).writeDoubleBE(p,S),8}}cA.DoubleBE=Z;class X extends s{constructor(p,L,S){if(!(p instanceof s))throw new TypeError("elementLayout must be a Layout");if(!(L instanceof i&&L.isCount()||Number.isInteger(L)&&0<=L))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let $=-1;!(L instanceof i)&&0<p.span&&($=L*p.span),super($,S),this.elementLayout=p,this.count=L}getSpan(p,L=0){if(0<=this.span)return this.span;let S=0,$=this.count;if($ instanceof i&&($=$.decode(p,L)),0<this.elementLayout.span)S=$*this.elementLayout.span;else{let AA=0;for(;AA<$;)S+=this.elementLayout.getSpan(p,L+S),++AA}return S}decode(p,L=0){const S=[];let $=0,AA=this.count;for(AA instanceof i&&(AA=AA.decode(p,L));$<AA;)S.push(this.elementLayout.decode(p,L)),L+=this.elementLayout.getSpan(p,L),$+=1;return S}encode(p,L,S=0){const $=this.elementLayout,AA=p.reduce((sA,oA)=>sA+$.encode(oA,L,S+sA),0);return this.count instanceof i&&this.count.encode(p.length,L,S),AA}}cA.Sequence=X;class U extends s{constructor(p,L,S){if(!(Array.isArray(p)&&p.reduce((AA,sA)=>AA&&sA instanceof s,!0)))throw new TypeError("fields must be array of Layout instances");typeof L=="boolean"&&S===void 0&&(S=L,L=void 0);for(const AA of p)if(0>AA.span&&AA.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let $=-1;try{$=p.reduce((AA,sA)=>AA+sA.getSpan(),0)}catch{}super($,L),this.fields=p,this.decodePrefixes=!!S}getSpan(p,L=0){if(0<=this.span)return this.span;let S=0;try{S=this.fields.reduce(($,AA)=>{const sA=AA.getSpan(p,L);return L+=sA,$+sA},0)}catch{throw new RangeError("indeterminate span")}return S}decode(p,L=0){e(p);const S=this.makeDestinationObject();for(const $ of this.fields)if($.property!==void 0&&(S[$.property]=$.decode(p,L)),L+=$.getSpan(p,L),this.decodePrefixes&&p.length===L)break;return S}encode(p,L,S=0){const $=S;let AA=0,sA=0;for(const oA of this.fields){let bA=oA.span;if(sA=0<bA?bA:0,oA.property!==void 0){const GA=p[oA.property];GA!==void 0&&(sA=oA.encode(GA,L,S),0>bA&&(bA=oA.getSpan(L,S)))}AA=S,S+=bA}return AA+sA-$}fromArray(p){const L=this.makeDestinationObject();for(const S of this.fields)S.property!==void 0&&0<p.length&&(L[S.property]=p.shift());return L}layoutFor(p){if(typeof p!="string")throw new TypeError("property must be string");for(const L of this.fields)if(L.property===p)return L}offsetOf(p){if(typeof p!="string")throw new TypeError("property must be string");let L=0;for(const S of this.fields){if(S.property===p)return L;0>S.span?L=-1:0<=L&&(L+=S.span)}}}cA.Structure=U;class O{constructor(p){this.property=p}decode(p,L){throw new Error("UnionDiscriminator is abstract")}encode(p,L,S){throw new Error("UnionDiscriminator is abstract")}}cA.UnionDiscriminator=O;class j extends O{constructor(p,L){if(!(p instanceof i&&p.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(L||p.property||"variant"),this.layout=p}decode(p,L){return this.layout.decode(p,L)}encode(p,L,S){return this.layout.encode(p,L,S)}}cA.UnionLayoutDiscriminator=j;class Y extends s{constructor(p,L,S){let $;if(p instanceof Q||p instanceof B)$=new j(new g(p));else if(p instanceof i&&p.isCount())$=new j(p);else if(p instanceof O)$=p;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(L===void 0&&(L=null),!(L===null||L instanceof s))throw new TypeError("defaultLayout must be null or a Layout");if(L!==null){if(0>L.span)throw new Error("defaultLayout must have constant span");L.property===void 0&&(L=L.replicate("content"))}let AA=-1;L&&(AA=L.span,0<=AA&&(p instanceof Q||p instanceof B)&&(AA+=$.layout.span)),super(AA,S),this.discriminator=$,this.usesPrefixDiscriminator=p instanceof Q||p instanceof B,this.defaultLayout=L,this.registry={};let sA=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(oA){return sA(oA)},this.configGetSourceVariant=function(oA){sA=oA.bind(this)}}getSpan(p,L=0){if(0<=this.span)return this.span;const S=this.getVariant(p,L);if(!S)throw new Error("unable to determine span for unrecognized variant");return S.getSpan(p,L)}defaultGetSourceVariant(p){if(Object.prototype.hasOwnProperty.call(p,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(p,this.defaultLayout.property))return;const L=this.registry[p[this.discriminator.property]];if(L&&(!L.layout||L.property&&Object.prototype.hasOwnProperty.call(p,L.property)))return L}else for(const L in this.registry){const S=this.registry[L];if(S.property&&Object.prototype.hasOwnProperty.call(p,S.property))return S}throw new Error("unable to infer src variant")}decode(p,L=0){let S;const $=this.discriminator,AA=$.decode(p,L),sA=this.registry[AA];if(sA===void 0){const oA=this.defaultLayout;let bA=0;this.usesPrefixDiscriminator&&(bA=$.layout.span),S=this.makeDestinationObject(),S[$.property]=AA,S[oA.property]=oA.decode(p,L+bA)}else S=sA.decode(p,L);return S}encode(p,L,S=0){const $=this.getSourceVariant(p);if($===void 0){const AA=this.discriminator,sA=this.defaultLayout;let oA=0;return this.usesPrefixDiscriminator&&(oA=AA.layout.span),AA.encode(p[AA.property],L,S),oA+sA.encode(p[sA.property],L,S+oA)}return $.encode(p,L,S)}addVariant(p,L,S){const $=new x(this,p,L,S);return this.registry[p]=$,$}getVariant(p,L=0){let S;return p instanceof Uint8Array?S=this.discriminator.decode(p,L):S=p,this.registry[S]}}cA.Union=Y;class x extends s{constructor(p,L,S,$){if(!(p instanceof Y))throw new TypeError("union must be a Union");if(!Number.isInteger(L)||0>L)throw new TypeError("variant must be a (non-negative) integer");if(typeof S=="string"&&$===void 0&&($=S,S=null),S){if(!(S instanceof s))throw new TypeError("layout must be a Layout");if(p.defaultLayout!==null&&0<=S.span&&S.span>p.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof $!="string")throw new TypeError("variant must have a String property")}let AA=p.span;0>p.span&&(AA=S?S.span:0,0<=AA&&p.usesPrefixDiscriminator&&(AA+=p.discriminator.layout.span)),super(AA,$),this.union=p,this.variant=L,this.layout=S||null}getSpan(p,L=0){if(0<=this.span)return this.span;let S=0;this.union.usesPrefixDiscriminator&&(S=this.union.discriminator.layout.span);let $=0;return this.layout&&($=this.layout.getSpan(p,L+S)),S+$}decode(p,L=0){const S=this.makeDestinationObject();if(this!==this.union.getVariant(p,L))throw new Error("variant mismatch");let $=0;return this.union.usesPrefixDiscriminator&&($=this.union.discriminator.layout.span),this.layout?S[this.property]=this.layout.decode(p,L+$):this.property?S[this.property]=!0:this.union.usesPrefixDiscriminator&&(S[this.union.discriminator.property]=this.variant),S}encode(p,L,S=0){let $=0;if(this.union.usesPrefixDiscriminator&&($=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(p,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,L,S);let AA=$;if(this.layout&&(this.layout.encode(p[this.property],L,S+$),AA+=this.layout.getSpan(L,S+$),0<=this.union.span&&AA>this.union.span))throw new Error("encoded variant overruns containing union");return AA}fromArray(p){if(this.layout)return this.layout.fromArray(p)}}cA.VariantLayout=x;function l(C){return 0>C&&(C+=4294967296),C}class I extends s{constructor(p,L,S){if(!(p instanceof Q||p instanceof B))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof L=="string"&&S===void 0&&(S=L,L=!1),4<p.span)throw new RangeError("word cannot exceed 32 bits");super(p.span,S),this.word=p,this.msb=!!L,this.fields=[];let $=0;this._packedSetValue=function(AA){return $=l(AA),this},this._packedGetValue=function(){return $}}decode(p,L=0){const S=this.makeDestinationObject(),$=this.word.decode(p,L);this._packedSetValue($);for(const AA of this.fields)AA.property!==void 0&&(S[AA.property]=AA.decode(p));return S}encode(p,L,S=0){const $=this.word.decode(L,S);this._packedSetValue($);for(const AA of this.fields)if(AA.property!==void 0){const sA=p[AA.property];sA!==void 0&&AA.encode(sA)}return this.word.encode(this._packedGetValue(),L,S)}addField(p,L){const S=new y(this,p,L);return this.fields.push(S),S}addBoolean(p){const L=new b(this,p);return this.fields.push(L),L}fieldFor(p){if(typeof p!="string")throw new TypeError("property must be string");for(const L of this.fields)if(L.property===p)return L}}cA.BitStructure=I;class y{constructor(p,L,S){if(!(p instanceof I))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(L)||0>=L)throw new TypeError("bits must be positive integer");const $=8*p.span,AA=p.fields.reduce((sA,oA)=>sA+oA.bits,0);if(L+AA>$)throw new Error("bits too long for span remainder ("+($-AA)+" of "+$+" remain)");this.container=p,this.bits=L,this.valueMask=(1<<L)-1,L===32&&(this.valueMask=4294967295),this.start=AA,this.container.msb&&(this.start=$-AA-L),this.wordMask=l(this.valueMask<<this.start),this.property=S}decode(p,L){const S=this.container._packedGetValue();return l(S&this.wordMask)>>>this.start}encode(p){if(typeof p!="number"||!Number.isInteger(p)||p!==l(p&this.valueMask))throw new TypeError(n("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const L=this.container._packedGetValue(),S=l(p<<this.start);this.container._packedSetValue(l(L&~this.wordMask)|S)}}cA.BitField=y;class b extends y{constructor(p,L){super(p,1,L)}decode(p,L){return!!super.decode(p,L)}encode(p){typeof p=="boolean"&&(p=+p),super.encode(p)}}cA.Boolean=b;class J extends s{constructor(p,L){if(!(p instanceof i&&p.isCount()||Number.isInteger(p)&&0<=p))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let S=-1;p instanceof i||(S=p),super(S,L),this.length=p}getSpan(p,L){let S=this.span;return 0>S&&(S=this.length.decode(p,L)),S}decode(p,L=0){let S=this.span;return 0>S&&(S=this.length.decode(p,L)),t(p).slice(L,L+S)}encode(p,L,S){let $=this.length;if(this.length instanceof i&&($=p.length),!(p instanceof Uint8Array&&$===p.length))throw new TypeError(n("Blob.encode",this)+" requires (length "+$+") Uint8Array as src");if(S+$>L.length)throw new RangeError("encoding overruns Uint8Array");const AA=t(p);return t(L).write(AA.toString("hex"),S,$,"hex"),this.length instanceof i&&this.length.encode($,L,S),$}}cA.Blob=J;class H extends s{constructor(p){super(-1,p)}getSpan(p,L=0){e(p);let S=L;for(;S<p.length&&p[S]!==0;)S+=1;return 1+S-L}decode(p,L=0){const S=this.getSpan(p,L);return t(p).slice(L,L+S-1).toString("utf-8")}encode(p,L,S=0){typeof p!="string"&&(p=String(p));const $=A.Buffer.from(p,"utf8"),AA=$.length;if(S+AA>L.length)throw new RangeError("encoding overruns Buffer");const sA=t(L);return $.copy(sA,S),sA[S+AA]=0,AA+1}}cA.CString=H;class v extends s{constructor(p,L){if(typeof p=="string"&&L===void 0&&(L=p,p=void 0),p===void 0)p=-1;else if(!Number.isInteger(p))throw new TypeError("maxSpan must be an integer");super(-1,L),this.maxSpan=p}getSpan(p,L=0){return e(p),p.length-L}decode(p,L=0){const S=this.getSpan(p,L);if(0<=this.maxSpan&&this.maxSpan<S)throw new RangeError("text length exceeds maxSpan");return t(p).slice(L,L+S).toString("utf-8")}encode(p,L,S=0){typeof p!="string"&&(p=String(p));const $=A.Buffer.from(p,"utf8"),AA=$.length;if(0<=this.maxSpan&&this.maxSpan<AA)throw new RangeError("text length exceeds maxSpan");if(S+AA>L.length)throw new RangeError("encoding overruns Buffer");return $.copy(t(L),S),AA}}cA.UTF8=v;class K extends s{constructor(p,L){super(0,L),this.value=p}decode(p,L){return this.value}encode(p,L,S){return 0}}return cA.Constant=K,cA.greedy=((C,p)=>new a(C,p)),cA.offset=((C,p,L)=>new g(C,p,L)),cA.u8=(C=>new Q(1,C)),cA.u16=(C=>new Q(2,C)),cA.u24=(C=>new Q(3,C)),cA.u32=(C=>new Q(4,C)),cA.u40=(C=>new Q(5,C)),cA.u48=(C=>new Q(6,C)),cA.nu64=(C=>new d(C)),cA.u16be=(C=>new B(2,C)),cA.u24be=(C=>new B(3,C)),cA.u32be=(C=>new B(4,C)),cA.u40be=(C=>new B(5,C)),cA.u48be=(C=>new B(6,C)),cA.nu64be=(C=>new D(C)),cA.s8=(C=>new u(1,C)),cA.s16=(C=>new u(2,C)),cA.s24=(C=>new u(3,C)),cA.s32=(C=>new u(4,C)),cA.s40=(C=>new u(5,C)),cA.s48=(C=>new u(6,C)),cA.ns64=(C=>new R(C)),cA.s16be=(C=>new E(2,C)),cA.s24be=(C=>new E(3,C)),cA.s32be=(C=>new E(4,C)),cA.s40be=(C=>new E(5,C)),cA.s48be=(C=>new E(6,C)),cA.ns64be=(C=>new M(C)),cA.f32=(C=>new q(C)),cA.f32be=(C=>new G(C)),cA.f64=(C=>new T(C)),cA.f64be=(C=>new Z(C)),cA.struct=((C,p,L)=>new U(C,p,L)),cA.bits=((C,p,L)=>new I(C,p,L)),cA.seq=((C,p,L)=>new X(C,p,L)),cA.union=((C,p,L)=>new Y(C,p,L)),cA.unionLayoutDiscriminator=((C,p)=>new j(C,p)),cA.blob=((C,p)=>new J(C,p)),cA.cstr=(C=>new H(C)),cA.utf8=((C,p)=>new v(C,p)),cA.constant=((C,p)=>new K(C,p)),cA}var iA=CD(),uD=8078011;function hE(A){return Array.isArray(A)?"%5B"+A.map(hE).join("%2C%20")+"%5D":typeof A=="bigint"?`${A}n`:encodeURIComponent(String(A!=null&&Object.getPrototypeOf(A)===null?{...A}:A))}function ID([A,e]){return`${A}=${hE(e)}`}function dD(A){const e=Object.entries(A).map(ID).join("&");return btoa(e)}function hD(A,e={}){{let t=`Solana error #${A}; Decode this error by running \`npx @solana/errors decode -- ${A}`;return Object.keys(e).length&&(t+=` '${dD(e)}'`),`${t}\``}}var pD=class extends Error{cause=this.cause;context;constructor(...[e,t]){let s,n;if(t){const{cause:i,...a}=t;i&&(n={cause:i}),Object.keys(a).length>0&&(s=a)}const r=hD(e,s);super(r,n),this.context={__code:e,...s},this.name="SolanaError"}},fD=8078e3,mD=8078001,wD=8078004,xD=8078005,DD=8078006;function pE(A){return Array.isArray(A)?"%5B"+A.map(pE).join("%2C%20")+"%5D":typeof A=="bigint"?`${A}n`:encodeURIComponent(String(A!=null&&Object.getPrototypeOf(A)===null?{...A}:A))}function yD([A,e]){return`${A}=${pE(e)}`}function ND(A){const e=Object.entries(A).map(yD).join("&");return btoa(e)}function kD(A,e={}){{let t=`Solana error #${A}; Decode this error by running \`npx @solana/errors decode -- ${A}`;return Object.keys(e).length&&(t+=` '${ND(e)}'`),`${t}\``}}var mr=class extends Error{cause=this.cause;context;constructor(...[A,e]){let t,s;if(e){const{cause:r,...i}=e;r&&(s={cause:r}),Object.keys(i).length>0&&(t=i)}const n=kD(A,t);super(n,s),this.context={__code:A,...t},this.name="SolanaError"}};function MD(A,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(A)}function bD(A){return Object.freeze({...A,encode:e=>{const t=new Uint8Array(MD(e,A));return A.write(e,t,0),t}})}function FD(A){return Object.freeze({...A,decode:(e,t=0)=>A.read(e,t)[0]})}function Ts(A){return"fixedSize"in A&&typeof A.fixedSize=="number"}function vD(A,e){if(Ts(A)!==Ts(e))throw new mr(wD);if(Ts(A)&&Ts(e)&&A.fixedSize!==e.fixedSize)throw new mr(xD,{decoderFixedSize:e.fixedSize,encoderFixedSize:A.fixedSize});if(!Ts(A)&&!Ts(e)&&A.maxSize!==e.maxSize)throw new mr(DD,{decoderMaxSize:e.maxSize,encoderMaxSize:A.maxSize});return{...e,...A,decode:e.decode,encode:A.encode,read:e.read,write:A.write}}function GD(A,e,t=0){if(e.length-t<=0)throw new mr(fD,{codecDescription:A})}function SD(A,e,t,s=0){const n=t.length-s;if(n<e)throw new mr(mD,{bytesLength:n,codecDescription:A,expected:e})}function UD(A,e,t,s){if(s<e||s>t)throw new pD(uD,{codecDescription:A,max:t,min:e,value:s})}function fE(A){return A?.endian!==1}function RD(A){return bD({fixedSize:A.size,write(e,t,s){A.range&&UD(A.name,A.range[0],A.range[1],e);const n=new ArrayBuffer(A.size);return A.set(new DataView(n),e,fE(A.config)),t.set(new Uint8Array(n),s),s+A.size}})}function KD(A){return FD({fixedSize:A.size,read(e,t=0){GD(A.name,e,t),SD(A.name,A.size,e,t);const s=new DataView(LD(e,t,A.size));return[A.get(s,fE(A.config)),t+A.size]}})}function LD(A,e,t){const s=A.byteOffset+(e??0),n=t??A.byteLength;return A.buffer.slice(s,s+n)}var JD=(A={})=>RD({config:A,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,s)=>e.setBigUint64(0,BigInt(t),s),size:8}),TD=(A={})=>KD({config:A,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),jD=(A={})=>vD(JD(A),TD(A));class OD extends TypeError{constructor(e,t){let s;const{message:n,explanation:r,...i}=e,{path:a}=e,g=a.length===0?n:`At path: ${a.join(".")} -- ${n}`;super(r??g),r!=null&&(this.cause=g),Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>s??(s=[e,...t()])}}function qD(A){return Wr(A)&&typeof A[Symbol.iterator]=="function"}function Wr(A){return typeof A=="object"&&A!=null}function jn(A){return Wr(A)&&!Array.isArray(A)}function Do(A){return typeof A=="symbol"?A.toString():typeof A=="string"?JSON.stringify(A):`${A}`}function YD(A){const{done:e,value:t}=A.next();return e?void 0:t}function HD(A,e,t,s){if(A===!0)return;A===!1?A={}:typeof A=="string"&&(A={message:A});const{path:n,branch:r}=e,{type:i}=t,{refinement:a,message:g=`Expected a value of type \`${i}\`${a?` with refinement \`${a}\``:""}, but received: \`${Do(s)}\``}=A;return{value:s,type:i,refinement:a,key:n[n.length-1],path:n,branch:r,...A,message:g}}function*wQ(A,e,t,s){qD(A)||(A=[A]);for(const n of A){const r=HD(n,e,t,s);r&&(yield r)}}function*Jg(A,e,t={}){const{path:s=[],branch:n=[A],coerce:r=!1,mask:i=!1}=t,a={path:s,branch:n,mask:i};r&&(A=e.coercer(A,a));let g="valid";for(const Q of e.validator(A,a))Q.explanation=t.message,g="not_valid",yield[Q,void 0];for(let[Q,B,u]of e.entries(A,a)){const E=Jg(B,u,{path:Q===void 0?s:[...s,Q],branch:Q===void 0?n:[...n,B],coerce:r,mask:i,message:t.message});for(const c of E)c[0]?(g=c[0].refinement!=null?"not_refined":"not_valid",yield[c[0],void 0]):r&&(B=c[1],Q===void 0?A=B:A instanceof Map?A.set(Q,B):A instanceof Set?A.add(B):Wr(A)&&(B!==void 0||Q in A)&&(A[Q]=B))}if(g!=="not_valid")for(const Q of e.refiner(A,a))Q.explanation=t.message,g="not_refined",yield[Q,void 0];g==="valid"&&(yield[void 0,A])}let Jo=class{constructor(e){const{type:t,schema:s,validator:n,refiner:r,coercer:i=g=>g,entries:a=function*(){}}=e;this.type=t,this.schema=s,this.entries=a,this.coercer=i,n?this.validator=(g,Q)=>{const B=n(g,Q);return wQ(B,Q,this,g)}:this.validator=()=>[],r?this.refiner=(g,Q)=>{const B=r(g,Q);return wQ(B,Q,this,g)}:this.refiner=()=>[]}assert(e,t){return PD(e,this,t)}create(e,t){return br(e,this,t)}is(e){return mE(e,this)}mask(e,t){return WD(e,this,t)}validate(e,t={}){return zr(e,this,t)}};function PD(A,e,t){const s=zr(A,e,{message:t});if(s[0])throw s[0]}function br(A,e,t){const s=zr(A,e,{coerce:!0,message:t});if(s[0])throw s[0];return s[1]}function WD(A,e,t){const s=zr(A,e,{coerce:!0,mask:!0,message:t});if(s[0])throw s[0];return s[1]}function mE(A,e){return!zr(A,e)[0]}function zr(A,e,t={}){const s=Jg(A,e,t),n=YD(s);return n[0]?[new OD(n[0],function*(){for(const i of s)i[0]&&(yield i[0])}),void 0]:[void 0,n[1]]}function bs(A,e){return new Jo({type:A,schema:null,validator:e})}function zD(){return bs("any",()=>!0)}function qA(A){return new Jo({type:"array",schema:A,*entries(e){if(A&&Array.isArray(e))for(const[t,s]of e.entries())yield[t,s,A]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${Do(e)}`}})}function Ro(){return bs("boolean",A=>typeof A=="boolean")}function Tg(A){return bs("instance",e=>e instanceof A||`Expected a \`${A.name}\` instance, but received: ${Do(e)}`)}function Bt(A){const e=Do(A),t=typeof A;return new Jo({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?A:null,validator(s){return s===A||`Expected the literal \`${e}\`, but received: ${Do(s)}`}})}function VD(){return bs("never",()=>!1)}function YA(A){return new Jo({...A,validator:(e,t)=>e===null||A.validator(e,t),refiner:(e,t)=>e===null||A.refiner(e,t)})}function BA(){return bs("number",A=>typeof A=="number"&&!isNaN(A)||`Expected a number, but received: ${Do(A)}`)}function oe(A){return new Jo({...A,validator:(e,t)=>e===void 0||A.validator(e,t),refiner:(e,t)=>e===void 0||A.refiner(e,t)})}function wE(A,e){return new Jo({type:"record",schema:null,*entries(t){if(Wr(t))for(const s in t){const n=t[s];yield[s,s,A],yield[s,n,e]}},validator(t){return jn(t)||`Expected an object, but received: ${Do(t)}`},coercer(t){return jn(t)?{...t}:t}})}function vA(){return bs("string",A=>typeof A=="string"||`Expected a string, but received: ${Do(A)}`)}function jg(A){const e=VD();return new Jo({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const s=Math.max(A.length,t.length);for(let n=0;n<s;n++)yield[n,t[n],A[n]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${Do(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function DA(A){const e=Object.keys(A);return new Jo({type:"type",schema:A,*entries(t){if(Wr(t))for(const s of e)yield[s,t[s],A[s]]},validator(t){return jn(t)||`Expected an object, but received: ${Do(t)}`},coercer(t){return jn(t)?{...t}:t}})}function to(A){const e=A.map(t=>t.type).join(" | ");return new Jo({type:"union",schema:null,coercer(t,s){for(const n of A){const[r,i]=n.validate(t,{coerce:!0,mask:s.mask});if(!r)return i}return t},validator(t,s){const n=[];for(const r of A){const[...i]=Jg(t,r,s),[a]=i;if(a[0])for(const[g]of i)g&&n.push(g);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${Do(t)}`,...n]}})}function ar(){return bs("unknown",()=>!0)}function Vr(A,e,t){return new Jo({...A,coercer:(s,n)=>mE(s,e)?A.coercer(t(s,n),n):A.coercer(s,n)})}var ln,_D=new Uint8Array(16);function xE(){if(!ln&&(ln=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!ln))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ln(_D)}const ZD=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Qi(A){return typeof A=="string"&&ZD.test(A)}var vt=[];for(var ji=0;ji<256;++ji)vt.push((ji+256).toString(16).substr(1));function Bi(A){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(vt[A[e+0]]+vt[A[e+1]]+vt[A[e+2]]+vt[A[e+3]]+"-"+vt[A[e+4]]+vt[A[e+5]]+"-"+vt[A[e+6]]+vt[A[e+7]]+"-"+vt[A[e+8]]+vt[A[e+9]]+"-"+vt[A[e+10]]+vt[A[e+11]]+vt[A[e+12]]+vt[A[e+13]]+vt[A[e+14]]+vt[A[e+15]]).toLowerCase();if(!Qi(t))throw TypeError("Stringified UUID is invalid");return t}var xQ,Oi,qi=0,Yi=0;function XD(A,e,t){var s=e&&t||0,n=e||new Array(16);A=A||{};var r=A.node||xQ,i=A.clockseq!==void 0?A.clockseq:Oi;if(r==null||i==null){var a=A.random||(A.rng||xE)();r==null&&(r=xQ=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),i==null&&(i=Oi=(a[6]<<8|a[7])&16383)}var g=A.msecs!==void 0?A.msecs:Date.now(),Q=A.nsecs!==void 0?A.nsecs:Yi+1,B=g-qi+(Q-Yi)/1e4;if(B<0&&A.clockseq===void 0&&(i=i+1&16383),(B<0||g>qi)&&A.nsecs===void 0&&(Q=0),Q>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");qi=g,Yi=Q,Oi=i,g+=122192928e5;var u=((g&268435455)*1e4+Q)%4294967296;n[s++]=u>>>24&255,n[s++]=u>>>16&255,n[s++]=u>>>8&255,n[s++]=u&255;var E=g/4294967296*1e4&268435455;n[s++]=E>>>8&255,n[s++]=E&255,n[s++]=E>>>24&15|16,n[s++]=E>>>16&255,n[s++]=i>>>8|128,n[s++]=i&255;for(var c=0;c<6;++c)n[s+c]=r[c];return e||Bi(n)}function DE(A){if(!Qi(A))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(A.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(A.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(A.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(A.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(A.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function $D(A){A=unescape(encodeURIComponent(A));for(var e=[],t=0;t<A.length;++t)e.push(A.charCodeAt(t));return e}var A2="6ba7b810-9dad-11d1-80b4-00c04fd430c8",e2="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function yE(A,e,t){function s(n,r,i,a){if(typeof n=="string"&&(n=$D(n)),typeof r=="string"&&(r=DE(r)),r.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var g=new Uint8Array(16+n.length);if(g.set(r),g.set(n,r.length),g=t(g),g[6]=g[6]&15|e,g[8]=g[8]&63|128,i){a=a||0;for(var Q=0;Q<16;++Q)i[a+Q]=g[Q];return i}return Bi(g)}try{s.name=A}catch{}return s.DNS=A2,s.URL=e2,s}function t2(A){if(typeof A=="string"){var e=unescape(encodeURIComponent(A));A=new Uint8Array(e.length);for(var t=0;t<e.length;++t)A[t]=e.charCodeAt(t)}return o2(s2(r2(A),A.length*8))}function o2(A){for(var e=[],t=A.length*32,s="0123456789abcdef",n=0;n<t;n+=8){var r=A[n>>5]>>>n%32&255,i=parseInt(s.charAt(r>>>4&15)+s.charAt(r&15),16);e.push(i)}return e}function NE(A){return(A+64>>>9<<4)+14+1}function s2(A,e){A[e>>5]|=128<<e%32,A[NE(e)-1]=e;for(var t=1732584193,s=-271733879,n=-1732584194,r=271733878,i=0;i<A.length;i+=16){var a=t,g=s,Q=n,B=r;t=jt(t,s,n,r,A[i],7,-680876936),r=jt(r,t,s,n,A[i+1],12,-389564586),n=jt(n,r,t,s,A[i+2],17,606105819),s=jt(s,n,r,t,A[i+3],22,-1044525330),t=jt(t,s,n,r,A[i+4],7,-176418897),r=jt(r,t,s,n,A[i+5],12,1200080426),n=jt(n,r,t,s,A[i+6],17,-1473231341),s=jt(s,n,r,t,A[i+7],22,-45705983),t=jt(t,s,n,r,A[i+8],7,1770035416),r=jt(r,t,s,n,A[i+9],12,-1958414417),n=jt(n,r,t,s,A[i+10],17,-42063),s=jt(s,n,r,t,A[i+11],22,-1990404162),t=jt(t,s,n,r,A[i+12],7,1804603682),r=jt(r,t,s,n,A[i+13],12,-40341101),n=jt(n,r,t,s,A[i+14],17,-1502002290),s=jt(s,n,r,t,A[i+15],22,1236535329),t=Ot(t,s,n,r,A[i+1],5,-165796510),r=Ot(r,t,s,n,A[i+6],9,-1069501632),n=Ot(n,r,t,s,A[i+11],14,643717713),s=Ot(s,n,r,t,A[i],20,-373897302),t=Ot(t,s,n,r,A[i+5],5,-701558691),r=Ot(r,t,s,n,A[i+10],9,38016083),n=Ot(n,r,t,s,A[i+15],14,-660478335),s=Ot(s,n,r,t,A[i+4],20,-405537848),t=Ot(t,s,n,r,A[i+9],5,568446438),r=Ot(r,t,s,n,A[i+14],9,-1019803690),n=Ot(n,r,t,s,A[i+3],14,-187363961),s=Ot(s,n,r,t,A[i+8],20,1163531501),t=Ot(t,s,n,r,A[i+13],5,-1444681467),r=Ot(r,t,s,n,A[i+2],9,-51403784),n=Ot(n,r,t,s,A[i+7],14,1735328473),s=Ot(s,n,r,t,A[i+12],20,-1926607734),t=qt(t,s,n,r,A[i+5],4,-378558),r=qt(r,t,s,n,A[i+8],11,-2022574463),n=qt(n,r,t,s,A[i+11],16,1839030562),s=qt(s,n,r,t,A[i+14],23,-35309556),t=qt(t,s,n,r,A[i+1],4,-1530992060),r=qt(r,t,s,n,A[i+4],11,1272893353),n=qt(n,r,t,s,A[i+7],16,-155497632),s=qt(s,n,r,t,A[i+10],23,-1094730640),t=qt(t,s,n,r,A[i+13],4,681279174),r=qt(r,t,s,n,A[i],11,-358537222),n=qt(n,r,t,s,A[i+3],16,-722521979),s=qt(s,n,r,t,A[i+6],23,76029189),t=qt(t,s,n,r,A[i+9],4,-640364487),r=qt(r,t,s,n,A[i+12],11,-421815835),n=qt(n,r,t,s,A[i+15],16,530742520),s=qt(s,n,r,t,A[i+2],23,-995338651),t=Yt(t,s,n,r,A[i],6,-198630844),r=Yt(r,t,s,n,A[i+7],10,1126891415),n=Yt(n,r,t,s,A[i+14],15,-1416354905),s=Yt(s,n,r,t,A[i+5],21,-57434055),t=Yt(t,s,n,r,A[i+12],6,1700485571),r=Yt(r,t,s,n,A[i+3],10,-1894986606),n=Yt(n,r,t,s,A[i+10],15,-1051523),s=Yt(s,n,r,t,A[i+1],21,-2054922799),t=Yt(t,s,n,r,A[i+8],6,1873313359),r=Yt(r,t,s,n,A[i+15],10,-30611744),n=Yt(n,r,t,s,A[i+6],15,-1560198380),s=Yt(s,n,r,t,A[i+13],21,1309151649),t=Yt(t,s,n,r,A[i+4],6,-145523070),r=Yt(r,t,s,n,A[i+11],10,-1120210379),n=Yt(n,r,t,s,A[i+2],15,718787259),s=Yt(s,n,r,t,A[i+9],21,-343485551),t=is(t,a),s=is(s,g),n=is(n,Q),r=is(r,B)}return[t,s,n,r]}function r2(A){if(A.length===0)return[];for(var e=A.length*8,t=new Uint32Array(NE(e)),s=0;s<e;s+=8)t[s>>5]|=(A[s/8]&255)<<s%32;return t}function is(A,e){var t=(A&65535)+(e&65535),s=(A>>16)+(e>>16)+(t>>16);return s<<16|t&65535}function n2(A,e){return A<<e|A>>>32-e}function ci(A,e,t,s,n,r){return is(n2(is(is(e,A),is(s,r)),n),t)}function jt(A,e,t,s,n,r,i){return ci(e&t|~e&s,A,e,n,r,i)}function Ot(A,e,t,s,n,r,i){return ci(e&s|t&~s,A,e,n,r,i)}function qt(A,e,t,s,n,r,i){return ci(e^t^s,A,e,n,r,i)}function Yt(A,e,t,s,n,r,i){return ci(t^(e|~s),A,e,n,r,i)}var i2=yE("v3",48,t2);function a2(A,e,t){A=A||{};var s=A.random||(A.rng||xE)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){t=t||0;for(var n=0;n<16;++n)e[t+n]=s[n];return e}return Bi(s)}function g2(A,e,t,s){switch(A){case 0:return e&t^~e&s;case 1:return e^t^s;case 2:return e&t^e&s^t&s;case 3:return e^t^s}}function Hi(A,e){return A<<e|A>>>32-e}function l2(A){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof A=="string"){var s=unescape(encodeURIComponent(A));A=[];for(var n=0;n<s.length;++n)A.push(s.charCodeAt(n))}else Array.isArray(A)||(A=Array.prototype.slice.call(A));A.push(128);for(var r=A.length/4+2,i=Math.ceil(r/16),a=new Array(i),g=0;g<i;++g){for(var Q=new Uint32Array(16),B=0;B<16;++B)Q[B]=A[g*64+B*4]<<24|A[g*64+B*4+1]<<16|A[g*64+B*4+2]<<8|A[g*64+B*4+3];a[g]=Q}a[i-1][14]=(A.length-1)*8/Math.pow(2,32),a[i-1][14]=Math.floor(a[i-1][14]),a[i-1][15]=(A.length-1)*8&4294967295;for(var u=0;u<i;++u){for(var E=new Uint32Array(80),c=0;c<16;++c)E[c]=a[u][c];for(var h=16;h<80;++h)E[h]=Hi(E[h-3]^E[h-8]^E[h-14]^E[h-16],1);for(var f=t[0],d=t[1],D=t[2],R=t[3],M=t[4],q=0;q<80;++q){var G=Math.floor(q/20),T=Hi(f,5)+g2(G,d,D,R)+M+e[G]+E[q]>>>0;M=R,R=D,D=Hi(d,30)>>>0,d=f,f=T}t[0]=t[0]+f>>>0,t[1]=t[1]+d>>>0,t[2]=t[2]+D>>>0,t[3]=t[3]+R>>>0,t[4]=t[4]+M>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var Q2=yE("v5",80,l2);const B2="00000000-0000-0000-0000-000000000000";function c2(A){if(!Qi(A))throw TypeError("Invalid UUID");return parseInt(A.substr(14,1),16)}const E2=Object.freeze(Object.defineProperty({__proto__:null,NIL:B2,parse:DE,stringify:Bi,v1:XD,v3:i2,v4:a2,v5:Q2,validate:Qi,version:c2},Symbol.toStringTag,{value:"Module"})),kE=za(E2);var Pi,DQ;function C2(){if(DQ)return Pi;DQ=1;const A=kE.v4;return Pi=function(t,s,n,r){if(typeof t!="string")throw new TypeError(t+" must be a string");r=r||{};const i=typeof r.version=="number"?r.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const a={method:t};if(i===2&&(a.jsonrpc="2.0"),s){if(typeof s!="object"&&!Array.isArray(s))throw new TypeError(s+" must be an object, array or omitted");a.params=s}if(typeof n>"u"){const g=typeof r.generator=="function"?r.generator:function(){return A()};a.id=g(a,r)}else i===2&&n===null?r.notificationIdNull&&(a.id=null):a.id=n;return a},Pi}var Wi,yQ;function u2(){if(yQ)return Wi;yQ=1;const A=kE.v4,e=C2(),t=function(s,n){if(!(this instanceof t))return new t(s,n);n||(n={}),this.options={reviver:typeof n.reviver<"u"?n.reviver:null,replacer:typeof n.replacer<"u"?n.replacer:null,generator:typeof n.generator<"u"?n.generator:function(){return A()},version:typeof n.version<"u"?n.version:2,notificationIdNull:typeof n.notificationIdNull=="boolean"?n.notificationIdNull:!1},this.callServer=s};return Wi=t,t.prototype.request=function(s,n,r,i){const a=this;let g=null;const Q=Array.isArray(s)&&typeof n=="function";if(this.options.version===1&&Q)throw new TypeError("JSON-RPC 1.0 does not support batching");if(Q||!Q&&s&&typeof s=="object"&&typeof n=="function")i=n,g=s;else{typeof r=="function"&&(i=r,r=void 0);const E=typeof i=="function";try{g=e(s,n,r,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(c){if(E){i(c);return}throw c}if(!E)return g}let u;try{u=JSON.stringify(g,this.options.replacer)}catch(E){i(E);return}return this.callServer(u,function(E,c){a._parseResponse(E,c,i)}),g},t.prototype._parseResponse=function(s,n,r){if(s){r(s);return}if(!n){r();return}let i;try{i=JSON.parse(n,this.options.reviver)}catch(a){r(a);return}if(r.length===3)if(Array.isArray(i)){const a=function(Q){return typeof Q.error<"u"},g=function(Q){return!a(Q)};r(null,i.filter(a),i.filter(g));return}else{r(null,i.error,i.result);return}r(null,i)},Wi}u2();var zi={exports:{}},NQ;function I2(){return NQ||(NQ=1,(function(A){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function n(g,Q,B){this.fn=g,this.context=Q,this.once=B||!1}function r(g,Q,B,u,E){if(typeof B!="function")throw new TypeError("The listener must be a function");var c=new n(B,u||g,E),h=t?t+Q:Q;return g._events[h]?g._events[h].fn?g._events[h]=[g._events[h],c]:g._events[h].push(c):(g._events[h]=c,g._eventsCount++),g}function i(g,Q){--g._eventsCount===0?g._events=new s:delete g._events[Q]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var Q=[],B,u;if(this._eventsCount===0)return Q;for(u in B=this._events)e.call(B,u)&&Q.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?Q.concat(Object.getOwnPropertySymbols(B)):Q},a.prototype.listeners=function(Q){var B=t?t+Q:Q,u=this._events[B];if(!u)return[];if(u.fn)return[u.fn];for(var E=0,c=u.length,h=new Array(c);E<c;E++)h[E]=u[E].fn;return h},a.prototype.listenerCount=function(Q){var B=t?t+Q:Q,u=this._events[B];return u?u.fn?1:u.length:0},a.prototype.emit=function(Q,B,u,E,c,h){var f=t?t+Q:Q;if(!this._events[f])return!1;var d=this._events[f],D=arguments.length,R,M;if(d.fn){switch(d.once&&this.removeListener(Q,d.fn,void 0,!0),D){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,B),!0;case 3:return d.fn.call(d.context,B,u),!0;case 4:return d.fn.call(d.context,B,u,E),!0;case 5:return d.fn.call(d.context,B,u,E,c),!0;case 6:return d.fn.call(d.context,B,u,E,c,h),!0}for(M=1,R=new Array(D-1);M<D;M++)R[M-1]=arguments[M];d.fn.apply(d.context,R)}else{var q=d.length,G;for(M=0;M<q;M++)switch(d[M].once&&this.removeListener(Q,d[M].fn,void 0,!0),D){case 1:d[M].fn.call(d[M].context);break;case 2:d[M].fn.call(d[M].context,B);break;case 3:d[M].fn.call(d[M].context,B,u);break;case 4:d[M].fn.call(d[M].context,B,u,E);break;default:if(!R)for(G=1,R=new Array(D-1);G<D;G++)R[G-1]=arguments[G];d[M].fn.apply(d[M].context,R)}}return!0},a.prototype.on=function(Q,B,u){return r(this,Q,B,u,!1)},a.prototype.once=function(Q,B,u){return r(this,Q,B,u,!0)},a.prototype.removeListener=function(Q,B,u,E){var c=t?t+Q:Q;if(!this._events[c])return this;if(!B)return i(this,c),this;var h=this._events[c];if(h.fn)h.fn===B&&(!E||h.once)&&(!u||h.context===u)&&i(this,c);else{for(var f=0,d=[],D=h.length;f<D;f++)(h[f].fn!==B||E&&!h[f].once||u&&h[f].context!==u)&&d.push(h[f]);d.length?this._events[c]=d.length===1?d[0]:d:i(this,c)}return this},a.prototype.removeAllListeners=function(Q){var B;return Q?(B=t?t+Q:Q,this._events[B]&&i(this,B)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,A.exports=a})(zi)),zi.exports}I2();class ME extends Hc{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,qc(e);const s=vg(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,r=new Uint8Array(n);r.set(s.length>n?e.create().update(s).digest():s);for(let i=0;i<r.length;i++)r[i]^=54;this.iHash.update(r),this.oHash=e.create();for(let i=0;i<r.length;i++)r[i]^=106;this.oHash.update(r),_s(r)}update(e){return Gn(this),this.iHash.update(e),this}digestInto(e){Gn(this),ks(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:s,finished:n,destroyed:r,blockLen:i,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=r,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=s._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bE=(A,e,t)=>new ME(A,e).update(t).digest();bE.create=(A,e)=>new ME(A,e);const kQ=(A,e)=>(A+(A>=0?e:-e)/FE)/e;function d2(A,e,t){const[[s,n],[r,i]]=e,a=kQ(i*A,t),g=kQ(-n*A,t);let Q=A-a*s-g*r,B=-a*n-g*i;const u=Q<Vo,E=B<Vo;u&&(Q=-Q),E&&(B=-B);const c=Hr(Math.ceil(Xc(t)/2))+Ps;if(Q<Vo||Q>=c||B<Vo||B>=c)throw new Error("splitScalar (endomorphism): failed, k="+A);return{k1neg:u,k1:Q,k2neg:E,k2:B}}function Ua(A){if(!["compact","recovered","der"].includes(A))throw new Error('Signature format must be "compact", "recovered", or "der"');return A}function Vi(A,e){const t={};for(let s of Object.keys(e))t[s]=A[s]===void 0?e[s]:A[s];return Ds(t.lowS,"lowS"),Ds(t.prehash,"prehash"),t.format!==void 0&&Ua(t.format),t}class h2 extends Error{constructor(e=""){super(e)}}const Po={Err:h2,_tlv:{encode:(A,e)=>{const{Err:t}=Po;if(A<0||A>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const s=e.length/2,n=an(s);if(n.length/2&128)throw new t("tlv.encode: long form length too big");const r=s>127?an(n.length/2|128):"";return an(A)+r+n+e},decode(A,e){const{Err:t}=Po;let s=0;if(A<0||A>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[s++]!==A)throw new t("tlv.decode: wrong tlv");const n=e[s++],r=!!(n&128);let i=0;if(!r)i=n;else{const g=n&127;if(!g)throw new t("tlv.decode(long): indefinite length not supported");if(g>4)throw new t("tlv.decode(long): byte length is too big");const Q=e.subarray(s,s+g);if(Q.length!==g)throw new t("tlv.decode: length bytes not complete");if(Q[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const B of Q)i=i<<8|B;if(s+=g,i<128)throw new t("tlv.decode(long): not minimal encoding")}const a=e.subarray(s,s+i);if(a.length!==i)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(s+i)}}},_int:{encode(A){const{Err:e}=Po;if(A<Vo)throw new e("integer: negative integers are not allowed");let t=an(A);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(A){const{Err:e}=Po;if(A[0]&128)throw new e("invalid signature integer: negative");if(A[0]===0&&!(A[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return ai(A)}},toSig(A){const{Err:e,_int:t,_tlv:s}=Po,n=ut("signature",A),{v:r,l:i}=s.decode(48,n);if(i.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:g}=s.decode(2,r),{v:Q,l:B}=s.decode(2,g);if(B.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(Q)}},hexFromSig(A){const{_tlv:e,_int:t}=Po,s=e.encode(2,t.encode(A.r)),n=e.encode(2,t.encode(A.s)),r=s+n;return e.encode(48,r)}},Vo=BigInt(0),Ps=BigInt(1),FE=BigInt(2),Qn=BigInt(3),p2=BigInt(4);function qs(A,e){const{BYTES:t}=A;let s;if(typeof e=="bigint")s=e;else{let n=ut("private key",e);try{s=A.fromBytes(n)}catch{throw new Error(`invalid private key: expected ui8a of size ${t}, got ${typeof e}`)}}if(!A.isValidNot0(s))throw new Error("invalid private key: out of range [1..N-1]");return s}function f2(A,e={}){const t=EE("weierstrass",A,e),{Fp:s,Fn:n}=t;let r=t.CURVE;const{h:i,n:a}=r;Pr(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:g}=e;if(g&&(!s.is0(r.a)||typeof g.beta!="bigint"||!Array.isArray(g.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const Q=GE(s,n);function B(){if(!s.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function u(Y,x,l){const{x:I,y}=x.toAffine(),b=s.toBytes(I);if(Ds(l,"isCompressed"),l){B();const J=!s.isOdd(y);return Go(vE(J),b)}else return Go(Uint8Array.of(4),b,s.toBytes(y))}function E(Y){xo(Y,void 0,"Point");const{publicKey:x,publicKeyUncompressed:l}=Q,I=Y.length,y=Y[0],b=Y.subarray(1);if(I===x&&(y===2||y===3)){const J=s.fromBytes(b);if(!s.isValid(J))throw new Error("bad point: is not on curve, wrong x");const H=f(J);let v;try{v=s.sqrt(H)}catch(p){const L=p instanceof Error?": "+p.message:"";throw new Error("bad point: is not on curve, sqrt error"+L)}B();const K=s.isOdd(v);return(y&1)===1!==K&&(v=s.neg(v)),{x:J,y:v}}else if(I===l&&y===4){const J=s.BYTES,H=s.fromBytes(b.subarray(0,J)),v=s.fromBytes(b.subarray(J,J*2));if(!d(H,v))throw new Error("bad point: is not on curve");return{x:H,y:v}}else throw new Error(`bad point: got length ${I}, expected compressed=${x} or uncompressed=${l}`)}const c=e.toBytes||u,h=e.fromBytes||E;function f(Y){const x=s.sqr(Y),l=s.mul(x,Y);return s.add(s.add(l,s.mul(Y,r.a)),r.b)}function d(Y,x){const l=s.sqr(x),I=f(Y);return s.eql(l,I)}if(!d(r.Gx,r.Gy))throw new Error("bad curve params: generator point");const D=s.mul(s.pow(r.a,Qn),p2),R=s.mul(s.sqr(r.b),BigInt(27));if(s.is0(s.add(D,R)))throw new Error("bad curve params: a or b");function M(Y,x,l=!1){if(!s.isValid(x)||l&&s.is0(x))throw new Error(`bad point coordinate ${Y}`);return x}function q(Y){if(!(Y instanceof U))throw new Error("ProjectivePoint expected")}function G(Y){if(!g||!g.basises)throw new Error("no endo");return d2(Y,g.basises,n.ORDER)}const T=Un((Y,x)=>{const{X:l,Y:I,Z:y}=Y;if(s.eql(y,s.ONE))return{x:l,y:I};const b=Y.is0();x==null&&(x=b?s.ONE:s.inv(y));const J=s.mul(l,x),H=s.mul(I,x),v=s.mul(y,x);if(b)return{x:s.ZERO,y:s.ZERO};if(!s.eql(v,s.ONE))throw new Error("invZ was invalid");return{x:J,y:H}}),Z=Un(Y=>{if(Y.is0()){if(e.allowInfinityPoint&&!s.is0(Y.Y))return;throw new Error("bad point: ZERO")}const{x,y:l}=Y.toAffine();if(!s.isValid(x)||!s.isValid(l))throw new Error("bad point: x or y not field elements");if(!d(x,l))throw new Error("bad point: equation left != right");if(!Y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function X(Y,x,l,I,y){return l=new U(s.mul(l.X,Y),l.Y,l.Z),x=Rn(I,x),l=Rn(y,l),x.add(l)}class U{constructor(x,l,I){this.X=M("x",x),this.Y=M("y",l,!0),this.Z=M("z",I),Object.freeze(this)}static CURVE(){return r}static fromAffine(x){const{x:l,y:I}=x||{};if(!x||!s.isValid(l)||!s.isValid(I))throw new Error("invalid affine point");if(x instanceof U)throw new Error("projective point not allowed");return s.is0(l)&&s.is0(I)?U.ZERO:new U(l,I,s.ONE)}static fromBytes(x){const l=U.fromAffine(h(xo(x,void 0,"point")));return l.assertValidity(),l}static fromHex(x){return U.fromBytes(ut("pointHex",x))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,l=!0){return j.createCache(this,x),l||this.multiply(Qn),this}assertValidity(){Z(this)}hasEvenY(){const{y:x}=this.toAffine();if(!s.isOdd)throw new Error("Field doesn't support isOdd");return!s.isOdd(x)}equals(x){q(x);const{X:l,Y:I,Z:y}=this,{X:b,Y:J,Z:H}=x,v=s.eql(s.mul(l,H),s.mul(b,y)),K=s.eql(s.mul(I,H),s.mul(J,y));return v&&K}negate(){return new U(this.X,s.neg(this.Y),this.Z)}double(){const{a:x,b:l}=r,I=s.mul(l,Qn),{X:y,Y:b,Z:J}=this;let H=s.ZERO,v=s.ZERO,K=s.ZERO,C=s.mul(y,y),p=s.mul(b,b),L=s.mul(J,J),S=s.mul(y,b);return S=s.add(S,S),K=s.mul(y,J),K=s.add(K,K),H=s.mul(x,K),v=s.mul(I,L),v=s.add(H,v),H=s.sub(p,v),v=s.add(p,v),v=s.mul(H,v),H=s.mul(S,H),K=s.mul(I,K),L=s.mul(x,L),S=s.sub(C,L),S=s.mul(x,S),S=s.add(S,K),K=s.add(C,C),C=s.add(K,C),C=s.add(C,L),C=s.mul(C,S),v=s.add(v,C),L=s.mul(b,J),L=s.add(L,L),C=s.mul(L,S),H=s.sub(H,C),K=s.mul(L,p),K=s.add(K,K),K=s.add(K,K),new U(H,v,K)}add(x){q(x);const{X:l,Y:I,Z:y}=this,{X:b,Y:J,Z:H}=x;let v=s.ZERO,K=s.ZERO,C=s.ZERO;const p=r.a,L=s.mul(r.b,Qn);let S=s.mul(l,b),$=s.mul(I,J),AA=s.mul(y,H),sA=s.add(l,I),oA=s.add(b,J);sA=s.mul(sA,oA),oA=s.add(S,$),sA=s.sub(sA,oA),oA=s.add(l,y);let bA=s.add(b,H);return oA=s.mul(oA,bA),bA=s.add(S,AA),oA=s.sub(oA,bA),bA=s.add(I,y),v=s.add(J,H),bA=s.mul(bA,v),v=s.add($,AA),bA=s.sub(bA,v),C=s.mul(p,oA),v=s.mul(L,AA),C=s.add(v,C),v=s.sub($,C),C=s.add($,C),K=s.mul(v,C),$=s.add(S,S),$=s.add($,S),AA=s.mul(p,AA),oA=s.mul(L,oA),$=s.add($,AA),AA=s.sub(S,AA),AA=s.mul(p,AA),oA=s.add(oA,AA),S=s.mul($,oA),K=s.add(K,S),S=s.mul(bA,oA),v=s.mul(sA,v),v=s.sub(v,S),S=s.mul(sA,$),C=s.mul(bA,C),C=s.add(C,S),new U(v,K,C)}subtract(x){return this.add(x.negate())}is0(){return this.equals(U.ZERO)}multiply(x){const{endo:l}=e;if(!n.isValidNot0(x))throw new Error("invalid scalar: out of range");let I,y;const b=J=>j.cached(this,J,H=>ps(U,H));if(l){const{k1neg:J,k1:H,k2neg:v,k2:K}=G(x),{p:C,f:p}=b(H),{p:L,f:S}=b(K);y=p.add(S),I=X(l.beta,C,L,J,v)}else{const{p:J,f:H}=b(x);I=J,y=H}return ps(U,[I,y])[0]}multiplyUnsafe(x){const{endo:l}=e,I=this;if(!n.isValid(x))throw new Error("invalid scalar: out of range");if(x===Vo||I.is0())return U.ZERO;if(x===Ps)return I;if(j.hasCache(this))return this.multiply(x);if(l){const{k1neg:y,k1:b,k2neg:J,k2:H}=G(x),{p1:v,p2:K}=Kx(U,I,b,H);return X(l.beta,v,K,y,J)}else return j.unsafe(I,x)}multiplyAndAddUnsafe(x,l,I){const y=this.multiplyUnsafe(l).add(x.multiplyUnsafe(I));return y.is0()?void 0:y}toAffine(x){return T(this,x)}isTorsionFree(){const{isTorsionFree:x}=e;return i===Ps?!0:x?x(U,this):j.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:x}=e;return i===Ps?this:x?x(U,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(x=!0){return Ds(x,"isCompressed"),this.assertValidity(),c(U,this,x)}toHex(x=!0){return ms(this.toBytes(x))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(x=!0){return this.toBytes(x)}_setWindowSize(x){this.precompute(x)}static normalizeZ(x){return ps(U,x)}static msm(x,l){return cE(U,n,x,l)}static fromPrivateKey(x){return U.BASE.multiply(qs(n,x))}}U.BASE=new U(r.Gx,r.Gy,s.ONE),U.ZERO=new U(s.ZERO,s.ONE,s.ZERO),U.Fp=s,U.Fn=n;const O=n.BITS,j=new BE(U,e.endo?Math.ceil(O/2):O);return U.BASE.precompute(8),U}function vE(A){return Uint8Array.of(A?2:3)}function GE(A,e){return{secretKey:e.BYTES,publicKey:1+A.BYTES,publicKeyUncompressed:1+2*A.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function m2(A,e={}){const{Fn:t}=A,s=e.randomBytes||Gg,n=Object.assign(GE(A.Fp,t),{seed:gE(t.ORDER)});function r(c){try{return!!qs(t,c)}catch{return!1}}function i(c,h){const{publicKey:f,publicKeyUncompressed:d}=n;try{const D=c.length;return h===!0&&D!==f||h===!1&&D!==d?!1:!!A.fromBytes(c)}catch{return!1}}function a(c=s(n.seed)){return Sx(xo(c,n.seed,"seed"),t.ORDER)}function g(c,h=!0){return A.BASE.multiply(qs(t,c)).toBytes(h)}function Q(c){const h=a(c);return{secretKey:h,publicKey:g(h)}}function B(c){if(typeof c=="bigint")return!1;if(c instanceof A)return!0;const{secretKey:h,publicKey:f,publicKeyUncompressed:d}=n;if(t.allowedLengths||h===f)return;const D=ut("key",c).length;return D===f||D===d}function u(c,h,f=!0){if(B(c)===!0)throw new Error("first arg must be private key");if(B(h)===!1)throw new Error("second arg must be public key");const d=qs(t,c);return A.fromHex(h).multiply(d).toBytes(f)}return Object.freeze({getPublicKey:g,getSharedSecret:u,keygen:Q,Point:A,utils:{isValidSecretKey:r,isValidPublicKey:i,randomSecretKey:a,isValidPrivateKey:r,randomPrivateKey:a,normPrivateKeyToScalar:c=>qs(t,c),precompute(c=8,h=A.BASE){return h.precompute(c,!1)}},lengths:n})}function w2(A,e,t={}){qc(e),Pr(t,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const s=t.randomBytes||Gg,n=t.hmac||((l,...I)=>bE(e,l,Go(...I))),{Fp:r,Fn:i}=A,{ORDER:a,BITS:g}=i,{keygen:Q,getPublicKey:B,getSharedSecret:u,utils:E,lengths:c}=m2(A,t),h={prehash:!1,lowS:typeof t.lowS=="boolean"?t.lowS:!1,format:void 0,extraEntropy:!1},f="compact";function d(l){const I=a>>Ps;return l>I}function D(l,I){if(!i.isValidNot0(I))throw new Error(`invalid signature ${l}: out of range 1..Point.Fn.ORDER`);return I}function R(l,I){Ua(I);const y=c.signature,b=I==="compact"?y:I==="recovered"?y+1:void 0;return xo(l,b,`${I} signature`)}class M{constructor(I,y,b){this.r=D("r",I),this.s=D("s",y),b!=null&&(this.recovery=b),Object.freeze(this)}static fromBytes(I,y=f){R(I,y);let b;if(y==="der"){const{r:K,s:C}=Po.toSig(xo(I));return new M(K,C)}y==="recovered"&&(b=I[0],y="compact",I=I.subarray(1));const J=i.BYTES,H=I.subarray(0,J),v=I.subarray(J,J*2);return new M(i.fromBytes(H),i.fromBytes(v),b)}static fromHex(I,y){return this.fromBytes(Sn(I),y)}addRecoveryBit(I){return new M(this.r,this.s,I)}recoverPublicKey(I){const y=r.ORDER,{r:b,s:J,recovery:H}=this;if(H==null||![0,1,2,3].includes(H))throw new Error("recovery id invalid");if(a*FE<y&&H>1)throw new Error("recovery id is ambiguous for h>1 curve");const K=H===2||H===3?b+a:b;if(!r.isValid(K))throw new Error("recovery id 2 or 3 invalid");const C=r.toBytes(K),p=A.fromBytes(Go(vE((H&1)===0),C)),L=i.inv(K),S=G(ut("msgHash",I)),$=i.create(-S*L),AA=i.create(J*L),sA=A.BASE.multiplyUnsafe($).add(p.multiplyUnsafe(AA));if(sA.is0())throw new Error("point at infinify");return sA.assertValidity(),sA}hasHighS(){return d(this.s)}toBytes(I=f){if(Ua(I),I==="der")return Sn(Po.hexFromSig(this));const y=i.toBytes(this.r),b=i.toBytes(this.s);if(I==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Go(Uint8Array.of(this.recovery),y,b)}return Go(y,b)}toHex(I){return ms(this.toBytes(I))}assertValidity(){}static fromCompact(I){return M.fromBytes(ut("sig",I),"compact")}static fromDER(I){return M.fromBytes(ut("sig",I),"der")}normalizeS(){return this.hasHighS()?new M(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return ms(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return ms(this.toBytes("compact"))}}const q=t.bits2int||function(I){if(I.length>8192)throw new Error("input is too large");const y=ai(I),b=I.length*8-g;return b>0?y>>BigInt(b):y},G=t.bits2int_modN||function(I){return i.create(q(I))},T=Hr(g);function Z(l){return Sa("num < 2^"+g,l,Vo,T),i.toBytes(l)}function X(l,I){return xo(l,void 0,"message"),I?xo(e(l),void 0,"prehashed message"):l}function U(l,I,y){if(["recovered","canonical"].some($=>$ in y))throw new Error("sign() legacy options not supported");const{lowS:b,prehash:J,extraEntropy:H}=Vi(y,h);l=X(l,J);const v=G(l),K=qs(i,I),C=[Z(K),Z(v)];if(H!=null&&H!==!1){const $=H===!0?s(c.secretKey):H;C.push(ut("extraEntropy",$))}const p=Go(...C),L=v;function S($){const AA=q($);if(!i.isValidNot0(AA))return;const sA=i.inv(AA),oA=A.BASE.multiply(AA).toAffine(),bA=i.create(oA.x);if(bA===Vo)return;const GA=i.create(sA*i.create(L+bA*K));if(GA===Vo)return;let lA=(oA.x===bA?0:2)|Number(oA.y&Ps),jA=GA;return b&&d(GA)&&(jA=i.neg(GA),lA^=1),new M(bA,jA,lA)}return{seed:p,k2sig:S}}function O(l,I,y={}){l=ut("message",l);const{seed:b,k2sig:J}=U(l,I,y);return xx(e.outputLen,i.BYTES,n)(b,J)}function j(l){let I;const y=typeof l=="string"||Yr(l),b=!y&&l!==null&&typeof l=="object"&&typeof l.r=="bigint"&&typeof l.s=="bigint";if(!y&&!b)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(b)I=new M(l.r,l.s);else if(y){try{I=M.fromBytes(ut("sig",l),"der")}catch(J){if(!(J instanceof Po.Err))throw J}if(!I)try{I=M.fromBytes(ut("sig",l),"compact")}catch{return!1}}return I||!1}function Y(l,I,y,b={}){const{lowS:J,prehash:H,format:v}=Vi(b,h);if(y=ut("publicKey",y),I=X(ut("message",I),H),"strict"in b)throw new Error("options.strict was renamed to lowS");const K=v===void 0?j(l):M.fromBytes(ut("sig",l),v);if(K===!1)return!1;try{const C=A.fromBytes(y);if(J&&K.hasHighS())return!1;const{r:p,s:L}=K,S=G(I),$=i.inv(L),AA=i.create(S*$),sA=i.create(p*$),oA=A.BASE.multiplyUnsafe(AA).add(C.multiplyUnsafe(sA));return oA.is0()?!1:i.create(oA.x)===p}catch{return!1}}function x(l,I,y={}){const{prehash:b}=Vi(y,h);return I=X(I,b),M.fromBytes(l,"recovered").recoverPublicKey(I).toBytes()}return Object.freeze({keygen:Q,getPublicKey:B,getSharedSecret:u,utils:E,lengths:c,Point:A,sign:O,verify:Y,recoverPublicKey:x,Signature:M,hash:e})}function x2(A){const e={a:A.a,b:A.b,p:A.Fp.ORDER,n:A.n,h:A.h,Gx:A.Gx,Gy:A.Gy},t=A.Fp;let s=A.allowedPrivateKeyLengths?Array.from(new Set(A.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0;const n=Ms(e.n,{BITS:A.nBitLength,allowedLengths:s,modFromBytes:A.wrapPrivateKey}),r={Fp:t,Fn:n,allowInfinityPoint:A.allowInfinityPoint,endo:A.endo,isTorsionFree:A.isTorsionFree,clearCofactor:A.clearCofactor,fromBytes:A.fromBytes,toBytes:A.toBytes};return{CURVE:e,curveOpts:r}}function D2(A){const{CURVE:e,curveOpts:t}=x2(A),s={hmac:A.hmac,randomBytes:A.randomBytes,lowS:A.lowS,bits2int:A.bits2int,bits2int_modN:A.bits2int_modN};return{CURVE:e,curveOpts:t,hash:A.hash,ecdsaOpts:s}}function y2(A,e){const t=e.Point;return Object.assign({},e,{ProjectivePoint:t,CURVE:Object.assign({},A,iE(t.Fn.ORDER,t.Fn.BITS))})}function N2(A){const{CURVE:e,curveOpts:t,hash:s,ecdsaOpts:n}=D2(A),r=f2(e,t),i=w2(r,s,n);return y2(A,i)}function k2(A,e){const t=s=>N2({...A,hash:s});return{...t(e),create:t}}const Og={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},M2={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},MQ=BigInt(2);function b2(A){const e=Og.p,t=BigInt(3),s=BigInt(6),n=BigInt(11),r=BigInt(22),i=BigInt(23),a=BigInt(44),g=BigInt(88),Q=A*A*A%e,B=Q*Q*A%e,u=Ct(B,t,e)*B%e,E=Ct(u,t,e)*B%e,c=Ct(E,MQ,e)*Q%e,h=Ct(c,n,e)*c%e,f=Ct(h,r,e)*h%e,d=Ct(f,a,e)*f%e,D=Ct(d,g,e)*d%e,R=Ct(D,a,e)*f%e,M=Ct(R,t,e)*B%e,q=Ct(M,i,e)*h%e,G=Ct(q,s,e)*Q%e,T=Ct(G,MQ,e);if(!Ra.eql(Ra.sqr(T),A))throw new Error("Cannot find square root");return T}const Ra=Ms(Og.p,{sqrt:b2}),F2=k2({...Og,Fp:Ra,lowS:!0,endo:M2},Vc);gi.utils.randomPrivateKey;gi.getPublicKey;function bQ(A){try{return gi.ExtendedPoint.fromHex(A),!0}catch{return!1}}gi.verify;const v2=A=>xt.Buffer.isBuffer(A)?A:A instanceof Uint8Array?xt.Buffer.from(A.buffer,A.byteOffset,A.byteLength):xt.Buffer.from(A);class G2{constructor(e){Object.assign(this,e)}encode(){return xt.Buffer.from(Ti.serialize(xn,this))}static decode(e){return Ti.deserialize(xn,this,e)}static decodeUnchecked(e){return Ti.deserializeUnchecked(xn,this,e)}}const xn=new Map;var SE;const S2=32,_i=32;function U2(A){return A._bn!==void 0}let FQ=1;class qe extends G2{constructor(e){if(super({}),this._bn=void 0,U2(e))this._bn=e._bn;else{if(typeof e=="string"){const t=IQ.decode(e);if(t.length!=_i)throw new Error("Invalid public key input");this._bn=new cQ(t)}else this._bn=new cQ(e);if(this._bn.byteLength()>_i)throw new Error("Invalid public key input")}}static unique(){const e=new qe(FQ);return FQ+=1,new qe(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return IQ.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(xt.Buffer);if(e.length===_i)return e;const t=xt.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,s){const n=xt.Buffer.concat([e.toBuffer(),xt.Buffer.from(t),s.toBuffer()]),r=dQ(n);return new qe(r)}static createProgramAddressSync(e,t){let s=xt.Buffer.alloc(0);e.forEach(function(r){if(r.length>S2)throw new TypeError("Max seed length exceeded");s=xt.Buffer.concat([s,v2(r)])}),s=xt.Buffer.concat([s,t.toBuffer(),xt.Buffer.from("ProgramDerivedAddress")]);const n=dQ(s);if(bQ(n))throw new Error("Invalid seeds, address must fall off the curve");return new qe(n)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let s=255,n;for(;s!=0;){try{const r=e.concat(xt.Buffer.from([s]));n=this.createProgramAddressSync(r,t)}catch(r){if(r instanceof TypeError)throw r;s--;continue}return[n,s]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){const t=new qe(e);return bQ(t.toBytes())}}SE=qe;qe.default=new SE("11111111111111111111111111111111");xn.set(qe,{kind:"struct",fields:[["_bn","u256"]]});new qe("BPFLoader1111111111111111111111111111111111");const R2=64,_e=(A="publicKey")=>iA.blob(32,A),Ys=(A="string")=>{const e=iA.struct([iA.u32("length"),iA.u32("lengthPadding"),iA.blob(iA.offset(iA.u32(),-8),"chars")],A),t=e.decode.bind(e),s=e.encode.bind(e),n=e;return n.decode=(r,i)=>t(r,i).chars.toString(),n.encode=(r,i,a)=>{const g={chars:xt.Buffer.from(r,"utf8")};return s(g,i,a)},n.alloc=r=>iA.u32().span+iA.u32().span+xt.Buffer.from(r,"utf8").length,n},K2=(A="authorized")=>iA.struct([_e("staker"),_e("withdrawer")],A),L2=(A="lockup")=>iA.struct([iA.ns64("unixTimestamp"),iA.ns64("epoch"),_e("custodian")],A),J2=(A="voteInit")=>iA.struct([_e("nodePubkey"),_e("authorizedVoter"),_e("authorizedWithdrawer"),iA.u8("commission")],A),T2=(A="voteAuthorizeWithSeedArgs")=>iA.struct([iA.u32("voteAuthorizationType"),_e("currentAuthorityDerivedKeyOwnerPubkey"),Ys("currentAuthorityDerivedKeySeed"),_e("newAuthorized")],A);xt.Buffer.alloc(R2).fill(0);new qe("SysvarC1ock11111111111111111111111111111111");new qe("SysvarEpochSchedu1e111111111111111111111111");new qe("Sysvar1nstructions1111111111111111111111111");new qe("SysvarRecentB1ockHashes11111111111111111111");new qe("SysvarRent111111111111111111111111111111111");new qe("SysvarRewards111111111111111111111111111111");new qe("SysvarS1otHashes111111111111111111111111111");new qe("SysvarS1otHistory11111111111111111111111111");new qe("SysvarStakeHistory1111111111111111111111111");const j2=iA.nu64("lamportsPerSignature"),O2=iA.struct([iA.u32("version"),iA.u32("state"),_e("authorizedPubkey"),_e("nonce"),iA.struct([j2],"feeCalculator")]);O2.span;function $s(A){const e=iA.blob(8,A),t=e.decode.bind(e),s=e.encode.bind(e),n=e,r=jD();return n.decode=(i,a)=>{const g=t(i,a);return r.decode(g)},n.encode=(i,a,g)=>{const Q=r.encode(i);return s(Q,a,g)},n}Object.freeze({Create:{index:0,layout:iA.struct([iA.u32("instruction"),iA.ns64("lamports"),iA.ns64("space"),_e("programId")])},Assign:{index:1,layout:iA.struct([iA.u32("instruction"),_e("programId")])},Transfer:{index:2,layout:iA.struct([iA.u32("instruction"),$s("lamports")])},CreateWithSeed:{index:3,layout:iA.struct([iA.u32("instruction"),_e("base"),Ys("seed"),iA.ns64("lamports"),iA.ns64("space"),_e("programId")])},AdvanceNonceAccount:{index:4,layout:iA.struct([iA.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:iA.struct([iA.u32("instruction"),iA.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:iA.struct([iA.u32("instruction"),_e("authorized")])},AuthorizeNonceAccount:{index:7,layout:iA.struct([iA.u32("instruction"),_e("authorized")])},Allocate:{index:8,layout:iA.struct([iA.u32("instruction"),iA.ns64("space")])},AllocateWithSeed:{index:9,layout:iA.struct([iA.u32("instruction"),_e("base"),Ys("seed"),iA.ns64("space"),_e("programId")])},AssignWithSeed:{index:10,layout:iA.struct([iA.u32("instruction"),_e("base"),Ys("seed"),_e("programId")])},TransferWithSeed:{index:11,layout:iA.struct([iA.u32("instruction"),$s("lamports"),Ys("seed"),_e("programId")])},UpgradeNonceAccount:{index:12,layout:iA.struct([iA.u32("instruction")])}});new qe("11111111111111111111111111111111");new qe("BPFLoader2111111111111111111111111111111111");iA.struct([iA.u32("typeIndex"),$s("deactivationSlot"),iA.nu64("lastExtendedSlot"),iA.u8("lastExtendedStartIndex"),iA.u8(),iA.seq(_e(),iA.offset(iA.u8(),-1),"authority")]);const It=Vr(Tg(qe),vA(),A=>new qe(A)),UE=jg([vA(),Bt("base64")]),qg=Vr(Tg(xt.Buffer),UE,A=>xt.Buffer.from(A[0],"base64"));function RE(A){return to([DA({jsonrpc:Bt("2.0"),id:vA(),result:A}),DA({jsonrpc:Bt("2.0"),id:vA(),error:DA({code:ar(),message:vA(),data:oe(zD())})})])}const q2=RE(ar());function ot(A){return Vr(RE(A),q2,e=>"error"in e?e:{...e,result:br(e.result,A)})}function ko(A){return ot(DA({context:DA({slot:BA()}),value:A}))}function Ei(A){return DA({context:DA({slot:BA()}),value:A})}const Y2=DA({foundation:BA(),foundationTerm:BA(),initial:BA(),taper:BA(),terminal:BA()});ot(qA(YA(DA({epoch:BA(),effectiveSlot:BA(),amount:BA(),postBalance:BA(),commission:oe(YA(BA()))}))));const H2=qA(DA({slot:BA(),prioritizationFee:BA()})),P2=DA({total:BA(),validator:BA(),foundation:BA(),epoch:BA()}),W2=DA({epoch:BA(),slotIndex:BA(),slotsInEpoch:BA(),absoluteSlot:BA(),blockHeight:oe(BA()),transactionCount:oe(BA())}),z2=DA({slotsPerEpoch:BA(),leaderScheduleSlotOffset:BA(),warmup:Ro(),firstNormalEpoch:BA(),firstNormalSlot:BA()}),V2=wE(vA(),qA(BA())),Fs=YA(to([DA({}),vA()])),_2=DA({err:Fs}),Z2=Bt("receivedSignature");DA({"solana-core":vA(),"feature-set":oe(BA())});const X2=DA({program:vA(),programId:It,parsed:ar()}),$2=DA({programId:It,accounts:qA(It),data:vA()});ko(DA({err:YA(to([DA({}),vA()])),logs:YA(qA(vA())),accounts:oe(YA(qA(YA(DA({executable:Ro(),owner:vA(),lamports:BA(),data:qA(vA()),rentEpoch:oe(BA())}))))),unitsConsumed:oe(BA()),returnData:oe(YA(DA({programId:vA(),data:jg([vA(),Bt("base64")])}))),innerInstructions:oe(YA(qA(DA({index:BA(),instructions:qA(to([X2,$2]))}))))}));ko(DA({byIdentity:wE(vA(),qA(BA())),range:DA({firstSlot:BA(),lastSlot:BA()})}));ot(Y2);ot(P2);ot(H2);ot(W2);ot(z2);ot(V2);ot(BA());ko(DA({total:BA(),circulating:BA(),nonCirculating:BA(),nonCirculatingAccounts:qA(It)}));const A1=DA({amount:vA(),uiAmount:YA(BA()),decimals:BA(),uiAmountString:oe(vA())});ko(qA(DA({address:It,amount:vA(),uiAmount:YA(BA()),decimals:BA(),uiAmountString:oe(vA())})));ko(qA(DA({pubkey:It,account:DA({executable:Ro(),owner:It,lamports:BA(),data:qg,rentEpoch:BA()})})));const Ka=DA({program:vA(),parsed:ar(),space:BA()});ko(qA(DA({pubkey:It,account:DA({executable:Ro(),owner:It,lamports:BA(),data:Ka,rentEpoch:BA()})})));ko(qA(DA({lamports:BA(),address:It})));const Yg=DA({executable:Ro(),owner:It,lamports:BA(),data:qg,rentEpoch:BA()});DA({pubkey:It,account:Yg});const e1=Vr(to([Tg(xt.Buffer),Ka]),to([UE,Ka]),A=>Array.isArray(A)?br(A,qg):A),t1=DA({executable:Ro(),owner:It,lamports:BA(),data:e1,rentEpoch:BA()});DA({pubkey:It,account:t1});DA({state:to([Bt("active"),Bt("inactive"),Bt("activating"),Bt("deactivating")]),active:BA(),inactive:BA()});ot(qA(DA({signature:vA(),slot:BA(),err:Fs,memo:YA(vA()),blockTime:oe(YA(BA()))})));ot(qA(DA({signature:vA(),slot:BA(),err:Fs,memo:YA(vA()),blockTime:oe(YA(BA()))})));DA({subscription:BA(),result:Ei(Yg)});const o1=DA({pubkey:It,account:Yg});DA({subscription:BA(),result:Ei(o1)});const s1=DA({parent:BA(),slot:BA(),root:BA()});DA({subscription:BA(),result:s1});const r1=to([DA({type:to([Bt("firstShredReceived"),Bt("completed"),Bt("optimisticConfirmation"),Bt("root")]),slot:BA(),timestamp:BA()}),DA({type:Bt("createdBank"),parent:BA(),slot:BA(),timestamp:BA()}),DA({type:Bt("frozen"),slot:BA(),timestamp:BA(),stats:DA({numTransactionEntries:BA(),numSuccessfulTransactions:BA(),numFailedTransactions:BA(),maxTransactionsPerEntry:BA()})}),DA({type:Bt("dead"),slot:BA(),timestamp:BA(),err:vA()})]);DA({subscription:BA(),result:r1});DA({subscription:BA(),result:Ei(to([_2,Z2]))});DA({subscription:BA(),result:BA()});DA({pubkey:vA(),gossip:YA(vA()),tpu:YA(vA()),rpc:YA(vA()),version:YA(vA())});const vQ=DA({votePubkey:vA(),nodePubkey:vA(),activatedStake:BA(),epochVoteAccount:Ro(),epochCredits:qA(jg([BA(),BA(),BA()])),commission:BA(),lastVote:BA(),rootSlot:YA(BA())});ot(DA({current:qA(vQ),delinquent:qA(vQ)}));const n1=to([Bt("processed"),Bt("confirmed"),Bt("finalized")]),i1=DA({slot:BA(),confirmations:YA(BA()),err:Fs,confirmationStatus:oe(n1)});ko(qA(YA(i1)));ot(BA());const KE=DA({accountKey:It,writableIndexes:qA(BA()),readonlyIndexes:qA(BA())}),Hg=DA({signatures:qA(vA()),message:DA({accountKeys:qA(vA()),header:DA({numRequiredSignatures:BA(),numReadonlySignedAccounts:BA(),numReadonlyUnsignedAccounts:BA()}),instructions:qA(DA({accounts:qA(BA()),data:vA(),programIdIndex:BA()})),recentBlockhash:vA(),addressTableLookups:oe(qA(KE))})}),LE=DA({pubkey:It,signer:Ro(),writable:Ro(),source:oe(to([Bt("transaction"),Bt("lookupTable")]))}),JE=DA({accountKeys:qA(LE),signatures:qA(vA())}),TE=DA({parsed:ar(),program:vA(),programId:It}),jE=DA({accounts:qA(It),data:vA(),programId:It}),a1=to([jE,TE]),g1=to([DA({parsed:ar(),program:vA(),programId:vA()}),DA({accounts:qA(vA()),data:vA(),programId:vA()})]),OE=Vr(a1,g1,A=>"accounts"in A?br(A,jE):br(A,TE)),qE=DA({signatures:qA(vA()),message:DA({accountKeys:qA(LE),instructions:qA(OE),recentBlockhash:vA(),addressTableLookups:oe(YA(qA(KE)))})}),On=DA({accountIndex:BA(),mint:vA(),owner:oe(vA()),programId:oe(vA()),uiTokenAmount:A1}),YE=DA({writable:qA(It),readonly:qA(It)}),Ci=DA({err:Fs,fee:BA(),innerInstructions:oe(YA(qA(DA({index:BA(),instructions:qA(DA({accounts:qA(BA()),data:vA(),programIdIndex:BA()}))})))),preBalances:qA(BA()),postBalances:qA(BA()),logMessages:oe(YA(qA(vA()))),preTokenBalances:oe(YA(qA(On))),postTokenBalances:oe(YA(qA(On))),loadedAddresses:oe(YE),computeUnitsConsumed:oe(BA()),costUnits:oe(BA())}),Pg=DA({err:Fs,fee:BA(),innerInstructions:oe(YA(qA(DA({index:BA(),instructions:qA(OE)})))),preBalances:qA(BA()),postBalances:qA(BA()),logMessages:oe(YA(qA(vA()))),preTokenBalances:oe(YA(qA(On))),postTokenBalances:oe(YA(qA(On))),loadedAddresses:oe(YE),computeUnitsConsumed:oe(BA()),costUnits:oe(BA())}),gr=to([Bt(0),Bt("legacy")]),vs=DA({pubkey:vA(),lamports:BA(),postBalance:YA(BA()),rewardType:YA(vA()),commission:oe(YA(BA()))});ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),transactions:qA(DA({transaction:Hg,meta:YA(Ci),version:oe(gr)})),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),transactions:qA(DA({transaction:JE,meta:YA(Ci),version:oe(gr)})),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),transactions:qA(DA({transaction:qE,meta:YA(Pg),version:oe(gr)})),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),transactions:qA(DA({transaction:JE,meta:YA(Pg),version:oe(gr)})),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),transactions:qA(DA({transaction:Hg,meta:YA(Ci)})),rewards:oe(qA(vs)),blockTime:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),signatures:qA(vA()),blockTime:YA(BA())})));ot(YA(DA({slot:BA(),meta:YA(Ci),blockTime:oe(YA(BA())),transaction:Hg,version:oe(gr)})));ot(YA(DA({slot:BA(),transaction:qE,meta:YA(Pg),blockTime:oe(YA(BA())),version:oe(gr)})));ko(DA({blockhash:vA(),lastValidBlockHeight:BA()}));ko(Ro());const l1=DA({slot:BA(),numTransactions:BA(),numSlots:BA(),samplePeriodSecs:BA()});ot(qA(l1));ko(YA(DA({feeCalculator:DA({lamportsPerSignature:BA()})})));ot(vA());ot(vA());const Q1=DA({err:Fs,logs:qA(vA()),signature:vA()});DA({result:Ei(Q1),subscription:BA()});Object.freeze({CreateLookupTable:{index:0,layout:iA.struct([iA.u32("instruction"),$s("recentSlot"),iA.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:iA.struct([iA.u32("instruction")])},ExtendLookupTable:{index:2,layout:iA.struct([iA.u32("instruction"),$s(),iA.seq(_e(),iA.offset(iA.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:iA.struct([iA.u32("instruction")])},CloseLookupTable:{index:4,layout:iA.struct([iA.u32("instruction")])}});new qe("AddressLookupTab1e1111111111111111111111111");Object.freeze({RequestUnits:{index:0,layout:iA.struct([iA.u8("instruction"),iA.u32("units"),iA.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:iA.struct([iA.u8("instruction"),iA.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:iA.struct([iA.u8("instruction"),iA.u32("units")])},SetComputeUnitPrice:{index:3,layout:iA.struct([iA.u8("instruction"),$s("microLamports")])}});new qe("ComputeBudget111111111111111111111111111111");iA.struct([iA.u8("numSignatures"),iA.u8("padding"),iA.u16("signatureOffset"),iA.u16("signatureInstructionIndex"),iA.u16("publicKeyOffset"),iA.u16("publicKeyInstructionIndex"),iA.u16("messageDataOffset"),iA.u16("messageDataSize"),iA.u16("messageInstructionIndex")]);new qe("Ed25519SigVerify111111111111111111111111111");F2.utils.isValidPrivateKey;iA.struct([iA.u8("numSignatures"),iA.u16("signatureOffset"),iA.u8("signatureInstructionIndex"),iA.u16("ethAddressOffset"),iA.u8("ethAddressInstructionIndex"),iA.u16("messageDataOffset"),iA.u16("messageDataSize"),iA.u8("messageInstructionIndex"),iA.blob(20,"ethAddress"),iA.blob(64,"signature"),iA.u8("recoveryId")]);new qe("KeccakSecp256k11111111111111111111111111111");var HE;new qe("StakeConfig11111111111111111111111111111111");class PE{constructor(e,t,s){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=s}}HE=PE;PE.default=new HE(0,0,qe.default);Object.freeze({Initialize:{index:0,layout:iA.struct([iA.u32("instruction"),K2(),L2()])},Authorize:{index:1,layout:iA.struct([iA.u32("instruction"),_e("newAuthorized"),iA.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:iA.struct([iA.u32("instruction")])},Split:{index:3,layout:iA.struct([iA.u32("instruction"),iA.ns64("lamports")])},Withdraw:{index:4,layout:iA.struct([iA.u32("instruction"),iA.ns64("lamports")])},Deactivate:{index:5,layout:iA.struct([iA.u32("instruction")])},Merge:{index:7,layout:iA.struct([iA.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:iA.struct([iA.u32("instruction"),_e("newAuthorized"),iA.u32("stakeAuthorizationType"),Ys("authoritySeed"),_e("authorityOwner")])}});new qe("Stake11111111111111111111111111111111111111");Object.freeze({InitializeAccount:{index:0,layout:iA.struct([iA.u32("instruction"),J2()])},Authorize:{index:1,layout:iA.struct([iA.u32("instruction"),_e("newAuthorized"),iA.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:iA.struct([iA.u32("instruction"),iA.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:iA.struct([iA.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:iA.struct([iA.u32("instruction"),T2()])}});new qe("Vote111111111111111111111111111111111111111");new qe("Va1idator1nfo111111111111111111111111111111");DA({name:vA(),website:oe(vA()),details:oe(vA()),iconUrl:oe(vA()),keybaseUsername:oe(vA())});new qe("Vote111111111111111111111111111111111111111");iA.struct([_e("nodePubkey"),_e("authorizedWithdrawer"),iA.u8("commission"),iA.nu64(),iA.seq(iA.struct([iA.nu64("slot"),iA.u32("confirmationCount")]),iA.offset(iA.u32(),-8),"votes"),iA.u8("rootSlotValid"),iA.nu64("rootSlot"),iA.nu64(),iA.seq(iA.struct([iA.nu64("epoch"),_e("authorizedVoter")]),iA.offset(iA.u32(),-8),"authorizedVoters"),iA.struct([iA.seq(iA.struct([_e("authorizedPubkey"),iA.nu64("epochOfLastAuthorizedSwitch"),iA.nu64("targetEpoch")]),32,"buf"),iA.nu64("idx"),iA.u8("isEmpty")],"priorVoters"),iA.nu64(),iA.seq(iA.struct([iA.nu64("epoch"),iA.nu64("credits"),iA.nu64("prevCredits")]),iA.offset(iA.u32(),-8),"epochCredits"),iA.struct([iA.nu64("slot"),iA.nu64("timestamp")],"lastTimestamp")]);function B1(A){if(A.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let Q=0;Q<e.length;Q++)e[Q]=255;for(let Q=0;Q<A.length;Q++){const B=A.charAt(Q),u=B.charCodeAt(0);if(e[u]!==255)throw new TypeError(B+" is ambiguous");e[u]=Q}const t=A.length,s=A.charAt(0),n=Math.log(t)/Math.log(256),r=Math.log(256)/Math.log(t);function i(Q){if(Q instanceof Uint8Array||(ArrayBuffer.isView(Q)?Q=new Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength):Array.isArray(Q)&&(Q=Uint8Array.from(Q))),!(Q instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(Q.length===0)return"";let B=0,u=0,E=0;const c=Q.length;for(;E!==c&&Q[E]===0;)E++,B++;const h=(c-E)*r+1>>>0,f=new Uint8Array(h);for(;E!==c;){let R=Q[E],M=0;for(let q=h-1;(R!==0||M<u)&&q!==-1;q--,M++)R+=256*f[q]>>>0,f[q]=R%t>>>0,R=R/t>>>0;if(R!==0)throw new Error("Non-zero carry");u=M,E++}let d=h-u;for(;d!==h&&f[d]===0;)d++;let D=s.repeat(B);for(;d<h;++d)D+=A.charAt(f[d]);return D}function a(Q){if(typeof Q!="string")throw new TypeError("Expected String");if(Q.length===0)return new Uint8Array;let B=0,u=0,E=0;for(;Q[B]===s;)u++,B++;const c=(Q.length-B)*n+1>>>0,h=new Uint8Array(c);for(;B<Q.length;){const R=Q.charCodeAt(B);if(R>255)return;let M=e[R];if(M===255)return;let q=0;for(let G=c-1;(M!==0||q<E)&&G!==-1;G--,q++)M+=t*h[G]>>>0,h[G]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");E=q,B++}let f=c-E;for(;f!==c&&h[f]===0;)f++;const d=new Uint8Array(u+(c-f));let D=u;for(;f!==c;)d[D++]=h[f++];return d}function g(Q){const B=a(Q);if(B)return B;throw new Error("Non-base"+t+" character")}return{encode:i,decodeUnsafe:a,decode:g}}var c1="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";B1(c1);function E1(A){throw new Error('Could not dynamically require "'+A+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Zi={exports:{}},GQ;function C1(){return GQ||(GQ=1,(function(A){(function(e){var t=function(F){var W,z=new Float64Array(16);if(F)for(W=0;W<F.length;W++)z[W]=F[W];return z},s=function(){throw new Error("no PRNG")},n=new Uint8Array(16),r=new Uint8Array(32);r[0]=9;var i=t(),a=t([1]),g=t([56129,1]),Q=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),B=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),E=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),c=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function h(F,W,z,w){F[W]=z>>24&255,F[W+1]=z>>16&255,F[W+2]=z>>8&255,F[W+3]=z&255,F[W+4]=w>>24&255,F[W+5]=w>>16&255,F[W+6]=w>>8&255,F[W+7]=w&255}function f(F,W,z,w,V){var nA,rA=0;for(nA=0;nA<V;nA++)rA|=F[W+nA]^z[w+nA];return(1&rA-1>>>8)-1}function d(F,W,z,w){return f(F,W,z,w,16)}function D(F,W,z,w){return f(F,W,z,w,32)}function R(F,W,z,w){for(var V=w[0]&255|(w[1]&255)<<8|(w[2]&255)<<16|(w[3]&255)<<24,nA=z[0]&255|(z[1]&255)<<8|(z[2]&255)<<16|(z[3]&255)<<24,rA=z[4]&255|(z[5]&255)<<8|(z[6]&255)<<16|(z[7]&255)<<24,IA=z[8]&255|(z[9]&255)<<8|(z[10]&255)<<16|(z[11]&255)<<24,yA=z[12]&255|(z[13]&255)<<8|(z[14]&255)<<16|(z[15]&255)<<24,FA=w[4]&255|(w[5]&255)<<8|(w[6]&255)<<16|(w[7]&255)<<24,xA=W[0]&255|(W[1]&255)<<8|(W[2]&255)<<16|(W[3]&255)<<24,Ee=W[4]&255|(W[5]&255)<<8|(W[6]&255)<<16|(W[7]&255)<<24,RA=W[8]&255|(W[9]&255)<<8|(W[10]&255)<<16|(W[11]&255)<<24,Ae=W[12]&255|(W[13]&255)<<8|(W[14]&255)<<16|(W[15]&255)<<24,ie=w[8]&255|(w[9]&255)<<8|(w[10]&255)<<16|(w[11]&255)<<24,le=z[16]&255|(z[17]&255)<<8|(z[18]&255)<<16|(z[19]&255)<<24,ae=z[20]&255|(z[21]&255)<<8|(z[22]&255)<<16|(z[23]&255)<<24,re=z[24]&255|(z[25]&255)<<8|(z[26]&255)<<16|(z[27]&255)<<24,ne=z[28]&255|(z[29]&255)<<8|(z[30]&255)<<16|(z[31]&255)<<24,ee=w[12]&255|(w[13]&255)<<8|(w[14]&255)<<16|(w[15]&255)<<24,LA=V,PA=nA,UA=rA,JA=IA,OA=yA,SA=FA,CA=xA,uA=Ee,mA=RA,hA=Ae,pA=ie,MA=le,te=ae,Ce=re,Ie=ne,ue=ee,eA,xe=0;xe<20;xe+=2)eA=LA+te|0,OA^=eA<<7|eA>>>25,eA=OA+LA|0,mA^=eA<<9|eA>>>23,eA=mA+OA|0,te^=eA<<13|eA>>>19,eA=te+mA|0,LA^=eA<<18|eA>>>14,eA=SA+PA|0,hA^=eA<<7|eA>>>25,eA=hA+SA|0,Ce^=eA<<9|eA>>>23,eA=Ce+hA|0,PA^=eA<<13|eA>>>19,eA=PA+Ce|0,SA^=eA<<18|eA>>>14,eA=pA+CA|0,Ie^=eA<<7|eA>>>25,eA=Ie+pA|0,UA^=eA<<9|eA>>>23,eA=UA+Ie|0,CA^=eA<<13|eA>>>19,eA=CA+UA|0,pA^=eA<<18|eA>>>14,eA=ue+MA|0,JA^=eA<<7|eA>>>25,eA=JA+ue|0,uA^=eA<<9|eA>>>23,eA=uA+JA|0,MA^=eA<<13|eA>>>19,eA=MA+uA|0,ue^=eA<<18|eA>>>14,eA=LA+JA|0,PA^=eA<<7|eA>>>25,eA=PA+LA|0,UA^=eA<<9|eA>>>23,eA=UA+PA|0,JA^=eA<<13|eA>>>19,eA=JA+UA|0,LA^=eA<<18|eA>>>14,eA=SA+OA|0,CA^=eA<<7|eA>>>25,eA=CA+SA|0,uA^=eA<<9|eA>>>23,eA=uA+CA|0,OA^=eA<<13|eA>>>19,eA=OA+uA|0,SA^=eA<<18|eA>>>14,eA=pA+hA|0,MA^=eA<<7|eA>>>25,eA=MA+pA|0,mA^=eA<<9|eA>>>23,eA=mA+MA|0,hA^=eA<<13|eA>>>19,eA=hA+mA|0,pA^=eA<<18|eA>>>14,eA=ue+Ie|0,te^=eA<<7|eA>>>25,eA=te+ue|0,Ce^=eA<<9|eA>>>23,eA=Ce+te|0,Ie^=eA<<13|eA>>>19,eA=Ie+Ce|0,ue^=eA<<18|eA>>>14;LA=LA+V|0,PA=PA+nA|0,UA=UA+rA|0,JA=JA+IA|0,OA=OA+yA|0,SA=SA+FA|0,CA=CA+xA|0,uA=uA+Ee|0,mA=mA+RA|0,hA=hA+Ae|0,pA=pA+ie|0,MA=MA+le|0,te=te+ae|0,Ce=Ce+re|0,Ie=Ie+ne|0,ue=ue+ee|0,F[0]=LA>>>0&255,F[1]=LA>>>8&255,F[2]=LA>>>16&255,F[3]=LA>>>24&255,F[4]=PA>>>0&255,F[5]=PA>>>8&255,F[6]=PA>>>16&255,F[7]=PA>>>24&255,F[8]=UA>>>0&255,F[9]=UA>>>8&255,F[10]=UA>>>16&255,F[11]=UA>>>24&255,F[12]=JA>>>0&255,F[13]=JA>>>8&255,F[14]=JA>>>16&255,F[15]=JA>>>24&255,F[16]=OA>>>0&255,F[17]=OA>>>8&255,F[18]=OA>>>16&255,F[19]=OA>>>24&255,F[20]=SA>>>0&255,F[21]=SA>>>8&255,F[22]=SA>>>16&255,F[23]=SA>>>24&255,F[24]=CA>>>0&255,F[25]=CA>>>8&255,F[26]=CA>>>16&255,F[27]=CA>>>24&255,F[28]=uA>>>0&255,F[29]=uA>>>8&255,F[30]=uA>>>16&255,F[31]=uA>>>24&255,F[32]=mA>>>0&255,F[33]=mA>>>8&255,F[34]=mA>>>16&255,F[35]=mA>>>24&255,F[36]=hA>>>0&255,F[37]=hA>>>8&255,F[38]=hA>>>16&255,F[39]=hA>>>24&255,F[40]=pA>>>0&255,F[41]=pA>>>8&255,F[42]=pA>>>16&255,F[43]=pA>>>24&255,F[44]=MA>>>0&255,F[45]=MA>>>8&255,F[46]=MA>>>16&255,F[47]=MA>>>24&255,F[48]=te>>>0&255,F[49]=te>>>8&255,F[50]=te>>>16&255,F[51]=te>>>24&255,F[52]=Ce>>>0&255,F[53]=Ce>>>8&255,F[54]=Ce>>>16&255,F[55]=Ce>>>24&255,F[56]=Ie>>>0&255,F[57]=Ie>>>8&255,F[58]=Ie>>>16&255,F[59]=Ie>>>24&255,F[60]=ue>>>0&255,F[61]=ue>>>8&255,F[62]=ue>>>16&255,F[63]=ue>>>24&255}function M(F,W,z,w){for(var V=w[0]&255|(w[1]&255)<<8|(w[2]&255)<<16|(w[3]&255)<<24,nA=z[0]&255|(z[1]&255)<<8|(z[2]&255)<<16|(z[3]&255)<<24,rA=z[4]&255|(z[5]&255)<<8|(z[6]&255)<<16|(z[7]&255)<<24,IA=z[8]&255|(z[9]&255)<<8|(z[10]&255)<<16|(z[11]&255)<<24,yA=z[12]&255|(z[13]&255)<<8|(z[14]&255)<<16|(z[15]&255)<<24,FA=w[4]&255|(w[5]&255)<<8|(w[6]&255)<<16|(w[7]&255)<<24,xA=W[0]&255|(W[1]&255)<<8|(W[2]&255)<<16|(W[3]&255)<<24,Ee=W[4]&255|(W[5]&255)<<8|(W[6]&255)<<16|(W[7]&255)<<24,RA=W[8]&255|(W[9]&255)<<8|(W[10]&255)<<16|(W[11]&255)<<24,Ae=W[12]&255|(W[13]&255)<<8|(W[14]&255)<<16|(W[15]&255)<<24,ie=w[8]&255|(w[9]&255)<<8|(w[10]&255)<<16|(w[11]&255)<<24,le=z[16]&255|(z[17]&255)<<8|(z[18]&255)<<16|(z[19]&255)<<24,ae=z[20]&255|(z[21]&255)<<8|(z[22]&255)<<16|(z[23]&255)<<24,re=z[24]&255|(z[25]&255)<<8|(z[26]&255)<<16|(z[27]&255)<<24,ne=z[28]&255|(z[29]&255)<<8|(z[30]&255)<<16|(z[31]&255)<<24,ee=w[12]&255|(w[13]&255)<<8|(w[14]&255)<<16|(w[15]&255)<<24,LA=V,PA=nA,UA=rA,JA=IA,OA=yA,SA=FA,CA=xA,uA=Ee,mA=RA,hA=Ae,pA=ie,MA=le,te=ae,Ce=re,Ie=ne,ue=ee,eA,xe=0;xe<20;xe+=2)eA=LA+te|0,OA^=eA<<7|eA>>>25,eA=OA+LA|0,mA^=eA<<9|eA>>>23,eA=mA+OA|0,te^=eA<<13|eA>>>19,eA=te+mA|0,LA^=eA<<18|eA>>>14,eA=SA+PA|0,hA^=eA<<7|eA>>>25,eA=hA+SA|0,Ce^=eA<<9|eA>>>23,eA=Ce+hA|0,PA^=eA<<13|eA>>>19,eA=PA+Ce|0,SA^=eA<<18|eA>>>14,eA=pA+CA|0,Ie^=eA<<7|eA>>>25,eA=Ie+pA|0,UA^=eA<<9|eA>>>23,eA=UA+Ie|0,CA^=eA<<13|eA>>>19,eA=CA+UA|0,pA^=eA<<18|eA>>>14,eA=ue+MA|0,JA^=eA<<7|eA>>>25,eA=JA+ue|0,uA^=eA<<9|eA>>>23,eA=uA+JA|0,MA^=eA<<13|eA>>>19,eA=MA+uA|0,ue^=eA<<18|eA>>>14,eA=LA+JA|0,PA^=eA<<7|eA>>>25,eA=PA+LA|0,UA^=eA<<9|eA>>>23,eA=UA+PA|0,JA^=eA<<13|eA>>>19,eA=JA+UA|0,LA^=eA<<18|eA>>>14,eA=SA+OA|0,CA^=eA<<7|eA>>>25,eA=CA+SA|0,uA^=eA<<9|eA>>>23,eA=uA+CA|0,OA^=eA<<13|eA>>>19,eA=OA+uA|0,SA^=eA<<18|eA>>>14,eA=pA+hA|0,MA^=eA<<7|eA>>>25,eA=MA+pA|0,mA^=eA<<9|eA>>>23,eA=mA+MA|0,hA^=eA<<13|eA>>>19,eA=hA+mA|0,pA^=eA<<18|eA>>>14,eA=ue+Ie|0,te^=eA<<7|eA>>>25,eA=te+ue|0,Ce^=eA<<9|eA>>>23,eA=Ce+te|0,Ie^=eA<<13|eA>>>19,eA=Ie+Ce|0,ue^=eA<<18|eA>>>14;F[0]=LA>>>0&255,F[1]=LA>>>8&255,F[2]=LA>>>16&255,F[3]=LA>>>24&255,F[4]=SA>>>0&255,F[5]=SA>>>8&255,F[6]=SA>>>16&255,F[7]=SA>>>24&255,F[8]=pA>>>0&255,F[9]=pA>>>8&255,F[10]=pA>>>16&255,F[11]=pA>>>24&255,F[12]=ue>>>0&255,F[13]=ue>>>8&255,F[14]=ue>>>16&255,F[15]=ue>>>24&255,F[16]=CA>>>0&255,F[17]=CA>>>8&255,F[18]=CA>>>16&255,F[19]=CA>>>24&255,F[20]=uA>>>0&255,F[21]=uA>>>8&255,F[22]=uA>>>16&255,F[23]=uA>>>24&255,F[24]=mA>>>0&255,F[25]=mA>>>8&255,F[26]=mA>>>16&255,F[27]=mA>>>24&255,F[28]=hA>>>0&255,F[29]=hA>>>8&255,F[30]=hA>>>16&255,F[31]=hA>>>24&255}function q(F,W,z,w){R(F,W,z,w)}function G(F,W,z,w){M(F,W,z,w)}var T=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Z(F,W,z,w,V,nA,rA){var IA=new Uint8Array(16),yA=new Uint8Array(64),FA,xA;for(xA=0;xA<16;xA++)IA[xA]=0;for(xA=0;xA<8;xA++)IA[xA]=nA[xA];for(;V>=64;){for(q(yA,IA,rA,T),xA=0;xA<64;xA++)F[W+xA]=z[w+xA]^yA[xA];for(FA=1,xA=8;xA<16;xA++)FA=FA+(IA[xA]&255)|0,IA[xA]=FA&255,FA>>>=8;V-=64,W+=64,w+=64}if(V>0)for(q(yA,IA,rA,T),xA=0;xA<V;xA++)F[W+xA]=z[w+xA]^yA[xA];return 0}function X(F,W,z,w,V){var nA=new Uint8Array(16),rA=new Uint8Array(64),IA,yA;for(yA=0;yA<16;yA++)nA[yA]=0;for(yA=0;yA<8;yA++)nA[yA]=w[yA];for(;z>=64;){for(q(rA,nA,V,T),yA=0;yA<64;yA++)F[W+yA]=rA[yA];for(IA=1,yA=8;yA<16;yA++)IA=IA+(nA[yA]&255)|0,nA[yA]=IA&255,IA>>>=8;z-=64,W+=64}if(z>0)for(q(rA,nA,V,T),yA=0;yA<z;yA++)F[W+yA]=rA[yA];return 0}function U(F,W,z,w,V){var nA=new Uint8Array(32);G(nA,w,V,T);for(var rA=new Uint8Array(8),IA=0;IA<8;IA++)rA[IA]=w[IA+16];return X(F,W,z,rA,nA)}function O(F,W,z,w,V,nA,rA){var IA=new Uint8Array(32);G(IA,nA,rA,T);for(var yA=new Uint8Array(8),FA=0;FA<8;FA++)yA[FA]=nA[FA+16];return Z(F,W,z,w,V,yA,IA)}var j=function(F){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var W,z,w,V,nA,rA,IA,yA;W=F[0]&255|(F[1]&255)<<8,this.r[0]=W&8191,z=F[2]&255|(F[3]&255)<<8,this.r[1]=(W>>>13|z<<3)&8191,w=F[4]&255|(F[5]&255)<<8,this.r[2]=(z>>>10|w<<6)&7939,V=F[6]&255|(F[7]&255)<<8,this.r[3]=(w>>>7|V<<9)&8191,nA=F[8]&255|(F[9]&255)<<8,this.r[4]=(V>>>4|nA<<12)&255,this.r[5]=nA>>>1&8190,rA=F[10]&255|(F[11]&255)<<8,this.r[6]=(nA>>>14|rA<<2)&8191,IA=F[12]&255|(F[13]&255)<<8,this.r[7]=(rA>>>11|IA<<5)&8065,yA=F[14]&255|(F[15]&255)<<8,this.r[8]=(IA>>>8|yA<<8)&8191,this.r[9]=yA>>>5&127,this.pad[0]=F[16]&255|(F[17]&255)<<8,this.pad[1]=F[18]&255|(F[19]&255)<<8,this.pad[2]=F[20]&255|(F[21]&255)<<8,this.pad[3]=F[22]&255|(F[23]&255)<<8,this.pad[4]=F[24]&255|(F[25]&255)<<8,this.pad[5]=F[26]&255|(F[27]&255)<<8,this.pad[6]=F[28]&255|(F[29]&255)<<8,this.pad[7]=F[30]&255|(F[31]&255)<<8};j.prototype.blocks=function(F,W,z){for(var w=this.fin?0:2048,V,nA,rA,IA,yA,FA,xA,Ee,RA,Ae,ie,le,ae,re,ne,ee,LA,PA,UA,JA=this.h[0],OA=this.h[1],SA=this.h[2],CA=this.h[3],uA=this.h[4],mA=this.h[5],hA=this.h[6],pA=this.h[7],MA=this.h[8],te=this.h[9],Ce=this.r[0],Ie=this.r[1],ue=this.r[2],eA=this.r[3],xe=this.r[4],Ge=this.r[5],Me=this.r[6],pe=this.r[7],be=this.r[8],Se=this.r[9];z>=16;)V=F[W+0]&255|(F[W+1]&255)<<8,JA+=V&8191,nA=F[W+2]&255|(F[W+3]&255)<<8,OA+=(V>>>13|nA<<3)&8191,rA=F[W+4]&255|(F[W+5]&255)<<8,SA+=(nA>>>10|rA<<6)&8191,IA=F[W+6]&255|(F[W+7]&255)<<8,CA+=(rA>>>7|IA<<9)&8191,yA=F[W+8]&255|(F[W+9]&255)<<8,uA+=(IA>>>4|yA<<12)&8191,mA+=yA>>>1&8191,FA=F[W+10]&255|(F[W+11]&255)<<8,hA+=(yA>>>14|FA<<2)&8191,xA=F[W+12]&255|(F[W+13]&255)<<8,pA+=(FA>>>11|xA<<5)&8191,Ee=F[W+14]&255|(F[W+15]&255)<<8,MA+=(xA>>>8|Ee<<8)&8191,te+=Ee>>>5|w,RA=0,Ae=RA,Ae+=JA*Ce,Ae+=OA*(5*Se),Ae+=SA*(5*be),Ae+=CA*(5*pe),Ae+=uA*(5*Me),RA=Ae>>>13,Ae&=8191,Ae+=mA*(5*Ge),Ae+=hA*(5*xe),Ae+=pA*(5*eA),Ae+=MA*(5*ue),Ae+=te*(5*Ie),RA+=Ae>>>13,Ae&=8191,ie=RA,ie+=JA*Ie,ie+=OA*Ce,ie+=SA*(5*Se),ie+=CA*(5*be),ie+=uA*(5*pe),RA=ie>>>13,ie&=8191,ie+=mA*(5*Me),ie+=hA*(5*Ge),ie+=pA*(5*xe),ie+=MA*(5*eA),ie+=te*(5*ue),RA+=ie>>>13,ie&=8191,le=RA,le+=JA*ue,le+=OA*Ie,le+=SA*Ce,le+=CA*(5*Se),le+=uA*(5*be),RA=le>>>13,le&=8191,le+=mA*(5*pe),le+=hA*(5*Me),le+=pA*(5*Ge),le+=MA*(5*xe),le+=te*(5*eA),RA+=le>>>13,le&=8191,ae=RA,ae+=JA*eA,ae+=OA*ue,ae+=SA*Ie,ae+=CA*Ce,ae+=uA*(5*Se),RA=ae>>>13,ae&=8191,ae+=mA*(5*be),ae+=hA*(5*pe),ae+=pA*(5*Me),ae+=MA*(5*Ge),ae+=te*(5*xe),RA+=ae>>>13,ae&=8191,re=RA,re+=JA*xe,re+=OA*eA,re+=SA*ue,re+=CA*Ie,re+=uA*Ce,RA=re>>>13,re&=8191,re+=mA*(5*Se),re+=hA*(5*be),re+=pA*(5*pe),re+=MA*(5*Me),re+=te*(5*Ge),RA+=re>>>13,re&=8191,ne=RA,ne+=JA*Ge,ne+=OA*xe,ne+=SA*eA,ne+=CA*ue,ne+=uA*Ie,RA=ne>>>13,ne&=8191,ne+=mA*Ce,ne+=hA*(5*Se),ne+=pA*(5*be),ne+=MA*(5*pe),ne+=te*(5*Me),RA+=ne>>>13,ne&=8191,ee=RA,ee+=JA*Me,ee+=OA*Ge,ee+=SA*xe,ee+=CA*eA,ee+=uA*ue,RA=ee>>>13,ee&=8191,ee+=mA*Ie,ee+=hA*Ce,ee+=pA*(5*Se),ee+=MA*(5*be),ee+=te*(5*pe),RA+=ee>>>13,ee&=8191,LA=RA,LA+=JA*pe,LA+=OA*Me,LA+=SA*Ge,LA+=CA*xe,LA+=uA*eA,RA=LA>>>13,LA&=8191,LA+=mA*ue,LA+=hA*Ie,LA+=pA*Ce,LA+=MA*(5*Se),LA+=te*(5*be),RA+=LA>>>13,LA&=8191,PA=RA,PA+=JA*be,PA+=OA*pe,PA+=SA*Me,PA+=CA*Ge,PA+=uA*xe,RA=PA>>>13,PA&=8191,PA+=mA*eA,PA+=hA*ue,PA+=pA*Ie,PA+=MA*Ce,PA+=te*(5*Se),RA+=PA>>>13,PA&=8191,UA=RA,UA+=JA*Se,UA+=OA*be,UA+=SA*pe,UA+=CA*Me,UA+=uA*Ge,RA=UA>>>13,UA&=8191,UA+=mA*xe,UA+=hA*eA,UA+=pA*ue,UA+=MA*Ie,UA+=te*Ce,RA+=UA>>>13,UA&=8191,RA=(RA<<2)+RA|0,RA=RA+Ae|0,Ae=RA&8191,RA=RA>>>13,ie+=RA,JA=Ae,OA=ie,SA=le,CA=ae,uA=re,mA=ne,hA=ee,pA=LA,MA=PA,te=UA,W+=16,z-=16;this.h[0]=JA,this.h[1]=OA,this.h[2]=SA,this.h[3]=CA,this.h[4]=uA,this.h[5]=mA,this.h[6]=hA,this.h[7]=pA,this.h[8]=MA,this.h[9]=te},j.prototype.finish=function(F,W){var z=new Uint16Array(10),w,V,nA,rA;if(this.leftover){for(rA=this.leftover,this.buffer[rA++]=1;rA<16;rA++)this.buffer[rA]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(w=this.h[1]>>>13,this.h[1]&=8191,rA=2;rA<10;rA++)this.h[rA]+=w,w=this.h[rA]>>>13,this.h[rA]&=8191;for(this.h[0]+=w*5,w=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=w,w=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=w,z[0]=this.h[0]+5,w=z[0]>>>13,z[0]&=8191,rA=1;rA<10;rA++)z[rA]=this.h[rA]+w,w=z[rA]>>>13,z[rA]&=8191;for(z[9]-=8192,V=(w^1)-1,rA=0;rA<10;rA++)z[rA]&=V;for(V=~V,rA=0;rA<10;rA++)this.h[rA]=this.h[rA]&V|z[rA];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,nA=this.h[0]+this.pad[0],this.h[0]=nA&65535,rA=1;rA<8;rA++)nA=(this.h[rA]+this.pad[rA]|0)+(nA>>>16)|0,this.h[rA]=nA&65535;F[W+0]=this.h[0]>>>0&255,F[W+1]=this.h[0]>>>8&255,F[W+2]=this.h[1]>>>0&255,F[W+3]=this.h[1]>>>8&255,F[W+4]=this.h[2]>>>0&255,F[W+5]=this.h[2]>>>8&255,F[W+6]=this.h[3]>>>0&255,F[W+7]=this.h[3]>>>8&255,F[W+8]=this.h[4]>>>0&255,F[W+9]=this.h[4]>>>8&255,F[W+10]=this.h[5]>>>0&255,F[W+11]=this.h[5]>>>8&255,F[W+12]=this.h[6]>>>0&255,F[W+13]=this.h[6]>>>8&255,F[W+14]=this.h[7]>>>0&255,F[W+15]=this.h[7]>>>8&255},j.prototype.update=function(F,W,z){var w,V;if(this.leftover){for(V=16-this.leftover,V>z&&(V=z),w=0;w<V;w++)this.buffer[this.leftover+w]=F[W+w];if(z-=V,W+=V,this.leftover+=V,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(z>=16&&(V=z-z%16,this.blocks(F,W,V),W+=V,z-=V),z){for(w=0;w<z;w++)this.buffer[this.leftover+w]=F[W+w];this.leftover+=z}};function Y(F,W,z,w,V,nA){var rA=new j(nA);return rA.update(z,w,V),rA.finish(F,W),0}function x(F,W,z,w,V,nA){var rA=new Uint8Array(16);return Y(rA,0,z,w,V,nA),d(F,W,rA,0)}function l(F,W,z,w,V){var nA;if(z<32)return-1;for(O(F,0,W,0,z,w,V),Y(F,16,F,32,z-32,F),nA=0;nA<16;nA++)F[nA]=0;return 0}function I(F,W,z,w,V){var nA,rA=new Uint8Array(32);if(z<32||(U(rA,0,32,w,V),x(W,16,W,32,z-32,rA)!==0))return-1;for(O(F,0,W,0,z,w,V),nA=0;nA<32;nA++)F[nA]=0;return 0}function y(F,W){var z;for(z=0;z<16;z++)F[z]=W[z]|0}function b(F){var W,z,w=1;for(W=0;W<16;W++)z=F[W]+w+65535,w=Math.floor(z/65536),F[W]=z-w*65536;F[0]+=w-1+37*(w-1)}function J(F,W,z){for(var w,V=~(z-1),nA=0;nA<16;nA++)w=V&(F[nA]^W[nA]),F[nA]^=w,W[nA]^=w}function H(F,W){var z,w,V,nA=t(),rA=t();for(z=0;z<16;z++)rA[z]=W[z];for(b(rA),b(rA),b(rA),w=0;w<2;w++){for(nA[0]=rA[0]-65517,z=1;z<15;z++)nA[z]=rA[z]-65535-(nA[z-1]>>16&1),nA[z-1]&=65535;nA[15]=rA[15]-32767-(nA[14]>>16&1),V=nA[15]>>16&1,nA[14]&=65535,J(rA,nA,1-V)}for(z=0;z<16;z++)F[2*z]=rA[z]&255,F[2*z+1]=rA[z]>>8}function v(F,W){var z=new Uint8Array(32),w=new Uint8Array(32);return H(z,F),H(w,W),D(z,0,w,0)}function K(F){var W=new Uint8Array(32);return H(W,F),W[0]&1}function C(F,W){var z;for(z=0;z<16;z++)F[z]=W[2*z]+(W[2*z+1]<<8);F[15]&=32767}function p(F,W,z){for(var w=0;w<16;w++)F[w]=W[w]+z[w]}function L(F,W,z){for(var w=0;w<16;w++)F[w]=W[w]-z[w]}function S(F,W,z){var w,V,nA=0,rA=0,IA=0,yA=0,FA=0,xA=0,Ee=0,RA=0,Ae=0,ie=0,le=0,ae=0,re=0,ne=0,ee=0,LA=0,PA=0,UA=0,JA=0,OA=0,SA=0,CA=0,uA=0,mA=0,hA=0,pA=0,MA=0,te=0,Ce=0,Ie=0,ue=0,eA=z[0],xe=z[1],Ge=z[2],Me=z[3],pe=z[4],be=z[5],Se=z[6],lt=z[7],Ve=z[8],tt=z[9],it=z[10],st=z[11],ct=z[12],dt=z[13],yt=z[14],QA=z[15];w=W[0],nA+=w*eA,rA+=w*xe,IA+=w*Ge,yA+=w*Me,FA+=w*pe,xA+=w*be,Ee+=w*Se,RA+=w*lt,Ae+=w*Ve,ie+=w*tt,le+=w*it,ae+=w*st,re+=w*ct,ne+=w*dt,ee+=w*yt,LA+=w*QA,w=W[1],rA+=w*eA,IA+=w*xe,yA+=w*Ge,FA+=w*Me,xA+=w*pe,Ee+=w*be,RA+=w*Se,Ae+=w*lt,ie+=w*Ve,le+=w*tt,ae+=w*it,re+=w*st,ne+=w*ct,ee+=w*dt,LA+=w*yt,PA+=w*QA,w=W[2],IA+=w*eA,yA+=w*xe,FA+=w*Ge,xA+=w*Me,Ee+=w*pe,RA+=w*be,Ae+=w*Se,ie+=w*lt,le+=w*Ve,ae+=w*tt,re+=w*it,ne+=w*st,ee+=w*ct,LA+=w*dt,PA+=w*yt,UA+=w*QA,w=W[3],yA+=w*eA,FA+=w*xe,xA+=w*Ge,Ee+=w*Me,RA+=w*pe,Ae+=w*be,ie+=w*Se,le+=w*lt,ae+=w*Ve,re+=w*tt,ne+=w*it,ee+=w*st,LA+=w*ct,PA+=w*dt,UA+=w*yt,JA+=w*QA,w=W[4],FA+=w*eA,xA+=w*xe,Ee+=w*Ge,RA+=w*Me,Ae+=w*pe,ie+=w*be,le+=w*Se,ae+=w*lt,re+=w*Ve,ne+=w*tt,ee+=w*it,LA+=w*st,PA+=w*ct,UA+=w*dt,JA+=w*yt,OA+=w*QA,w=W[5],xA+=w*eA,Ee+=w*xe,RA+=w*Ge,Ae+=w*Me,ie+=w*pe,le+=w*be,ae+=w*Se,re+=w*lt,ne+=w*Ve,ee+=w*tt,LA+=w*it,PA+=w*st,UA+=w*ct,JA+=w*dt,OA+=w*yt,SA+=w*QA,w=W[6],Ee+=w*eA,RA+=w*xe,Ae+=w*Ge,ie+=w*Me,le+=w*pe,ae+=w*be,re+=w*Se,ne+=w*lt,ee+=w*Ve,LA+=w*tt,PA+=w*it,UA+=w*st,JA+=w*ct,OA+=w*dt,SA+=w*yt,CA+=w*QA,w=W[7],RA+=w*eA,Ae+=w*xe,ie+=w*Ge,le+=w*Me,ae+=w*pe,re+=w*be,ne+=w*Se,ee+=w*lt,LA+=w*Ve,PA+=w*tt,UA+=w*it,JA+=w*st,OA+=w*ct,SA+=w*dt,CA+=w*yt,uA+=w*QA,w=W[8],Ae+=w*eA,ie+=w*xe,le+=w*Ge,ae+=w*Me,re+=w*pe,ne+=w*be,ee+=w*Se,LA+=w*lt,PA+=w*Ve,UA+=w*tt,JA+=w*it,OA+=w*st,SA+=w*ct,CA+=w*dt,uA+=w*yt,mA+=w*QA,w=W[9],ie+=w*eA,le+=w*xe,ae+=w*Ge,re+=w*Me,ne+=w*pe,ee+=w*be,LA+=w*Se,PA+=w*lt,UA+=w*Ve,JA+=w*tt,OA+=w*it,SA+=w*st,CA+=w*ct,uA+=w*dt,mA+=w*yt,hA+=w*QA,w=W[10],le+=w*eA,ae+=w*xe,re+=w*Ge,ne+=w*Me,ee+=w*pe,LA+=w*be,PA+=w*Se,UA+=w*lt,JA+=w*Ve,OA+=w*tt,SA+=w*it,CA+=w*st,uA+=w*ct,mA+=w*dt,hA+=w*yt,pA+=w*QA,w=W[11],ae+=w*eA,re+=w*xe,ne+=w*Ge,ee+=w*Me,LA+=w*pe,PA+=w*be,UA+=w*Se,JA+=w*lt,OA+=w*Ve,SA+=w*tt,CA+=w*it,uA+=w*st,mA+=w*ct,hA+=w*dt,pA+=w*yt,MA+=w*QA,w=W[12],re+=w*eA,ne+=w*xe,ee+=w*Ge,LA+=w*Me,PA+=w*pe,UA+=w*be,JA+=w*Se,OA+=w*lt,SA+=w*Ve,CA+=w*tt,uA+=w*it,mA+=w*st,hA+=w*ct,pA+=w*dt,MA+=w*yt,te+=w*QA,w=W[13],ne+=w*eA,ee+=w*xe,LA+=w*Ge,PA+=w*Me,UA+=w*pe,JA+=w*be,OA+=w*Se,SA+=w*lt,CA+=w*Ve,uA+=w*tt,mA+=w*it,hA+=w*st,pA+=w*ct,MA+=w*dt,te+=w*yt,Ce+=w*QA,w=W[14],ee+=w*eA,LA+=w*xe,PA+=w*Ge,UA+=w*Me,JA+=w*pe,OA+=w*be,SA+=w*Se,CA+=w*lt,uA+=w*Ve,mA+=w*tt,hA+=w*it,pA+=w*st,MA+=w*ct,te+=w*dt,Ce+=w*yt,Ie+=w*QA,w=W[15],LA+=w*eA,PA+=w*xe,UA+=w*Ge,JA+=w*Me,OA+=w*pe,SA+=w*be,CA+=w*Se,uA+=w*lt,mA+=w*Ve,hA+=w*tt,pA+=w*it,MA+=w*st,te+=w*ct,Ce+=w*dt,Ie+=w*yt,ue+=w*QA,nA+=38*PA,rA+=38*UA,IA+=38*JA,yA+=38*OA,FA+=38*SA,xA+=38*CA,Ee+=38*uA,RA+=38*mA,Ae+=38*hA,ie+=38*pA,le+=38*MA,ae+=38*te,re+=38*Ce,ne+=38*Ie,ee+=38*ue,V=1,w=nA+V+65535,V=Math.floor(w/65536),nA=w-V*65536,w=rA+V+65535,V=Math.floor(w/65536),rA=w-V*65536,w=IA+V+65535,V=Math.floor(w/65536),IA=w-V*65536,w=yA+V+65535,V=Math.floor(w/65536),yA=w-V*65536,w=FA+V+65535,V=Math.floor(w/65536),FA=w-V*65536,w=xA+V+65535,V=Math.floor(w/65536),xA=w-V*65536,w=Ee+V+65535,V=Math.floor(w/65536),Ee=w-V*65536,w=RA+V+65535,V=Math.floor(w/65536),RA=w-V*65536,w=Ae+V+65535,V=Math.floor(w/65536),Ae=w-V*65536,w=ie+V+65535,V=Math.floor(w/65536),ie=w-V*65536,w=le+V+65535,V=Math.floor(w/65536),le=w-V*65536,w=ae+V+65535,V=Math.floor(w/65536),ae=w-V*65536,w=re+V+65535,V=Math.floor(w/65536),re=w-V*65536,w=ne+V+65535,V=Math.floor(w/65536),ne=w-V*65536,w=ee+V+65535,V=Math.floor(w/65536),ee=w-V*65536,w=LA+V+65535,V=Math.floor(w/65536),LA=w-V*65536,nA+=V-1+37*(V-1),V=1,w=nA+V+65535,V=Math.floor(w/65536),nA=w-V*65536,w=rA+V+65535,V=Math.floor(w/65536),rA=w-V*65536,w=IA+V+65535,V=Math.floor(w/65536),IA=w-V*65536,w=yA+V+65535,V=Math.floor(w/65536),yA=w-V*65536,w=FA+V+65535,V=Math.floor(w/65536),FA=w-V*65536,w=xA+V+65535,V=Math.floor(w/65536),xA=w-V*65536,w=Ee+V+65535,V=Math.floor(w/65536),Ee=w-V*65536,w=RA+V+65535,V=Math.floor(w/65536),RA=w-V*65536,w=Ae+V+65535,V=Math.floor(w/65536),Ae=w-V*65536,w=ie+V+65535,V=Math.floor(w/65536),ie=w-V*65536,w=le+V+65535,V=Math.floor(w/65536),le=w-V*65536,w=ae+V+65535,V=Math.floor(w/65536),ae=w-V*65536,w=re+V+65535,V=Math.floor(w/65536),re=w-V*65536,w=ne+V+65535,V=Math.floor(w/65536),ne=w-V*65536,w=ee+V+65535,V=Math.floor(w/65536),ee=w-V*65536,w=LA+V+65535,V=Math.floor(w/65536),LA=w-V*65536,nA+=V-1+37*(V-1),F[0]=nA,F[1]=rA,F[2]=IA,F[3]=yA,F[4]=FA,F[5]=xA,F[6]=Ee,F[7]=RA,F[8]=Ae,F[9]=ie,F[10]=le,F[11]=ae,F[12]=re,F[13]=ne,F[14]=ee,F[15]=LA}function $(F,W){S(F,W,W)}function AA(F,W){var z=t(),w;for(w=0;w<16;w++)z[w]=W[w];for(w=253;w>=0;w--)$(z,z),w!==2&&w!==4&&S(z,z,W);for(w=0;w<16;w++)F[w]=z[w]}function sA(F,W){var z=t(),w;for(w=0;w<16;w++)z[w]=W[w];for(w=250;w>=0;w--)$(z,z),w!==1&&S(z,z,W);for(w=0;w<16;w++)F[w]=z[w]}function oA(F,W,z){var w=new Uint8Array(32),V=new Float64Array(80),nA,rA,IA=t(),yA=t(),FA=t(),xA=t(),Ee=t(),RA=t();for(rA=0;rA<31;rA++)w[rA]=W[rA];for(w[31]=W[31]&127|64,w[0]&=248,C(V,z),rA=0;rA<16;rA++)yA[rA]=V[rA],xA[rA]=IA[rA]=FA[rA]=0;for(IA[0]=xA[0]=1,rA=254;rA>=0;--rA)nA=w[rA>>>3]>>>(rA&7)&1,J(IA,yA,nA),J(FA,xA,nA),p(Ee,IA,FA),L(IA,IA,FA),p(FA,yA,xA),L(yA,yA,xA),$(xA,Ee),$(RA,IA),S(IA,FA,IA),S(FA,yA,Ee),p(Ee,IA,FA),L(IA,IA,FA),$(yA,IA),L(FA,xA,RA),S(IA,FA,g),p(IA,IA,xA),S(FA,FA,IA),S(IA,xA,RA),S(xA,yA,V),$(yA,Ee),J(IA,yA,nA),J(FA,xA,nA);for(rA=0;rA<16;rA++)V[rA+16]=IA[rA],V[rA+32]=FA[rA],V[rA+48]=yA[rA],V[rA+64]=xA[rA];var Ae=V.subarray(32),ie=V.subarray(16);return AA(Ae,Ae),S(ie,ie,Ae),H(F,ie),0}function bA(F,W){return oA(F,W,r)}function GA(F,W){return s(W,32),bA(F,W)}function lA(F,W,z){var w=new Uint8Array(32);return oA(w,z,W),G(F,n,w,T)}var jA=l,HA=I;function ce(F,W,z,w,V,nA){var rA=new Uint8Array(32);return lA(rA,V,nA),jA(F,W,z,w,rA)}function NA(F,W,z,w,V,nA){var rA=new Uint8Array(32);return lA(rA,V,nA),HA(F,W,z,w,rA)}var _A=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function we(F,W,z,w){for(var V=new Int32Array(16),nA=new Int32Array(16),rA,IA,yA,FA,xA,Ee,RA,Ae,ie,le,ae,re,ne,ee,LA,PA,UA,JA,OA,SA,CA,uA,mA,hA,pA,MA,te=F[0],Ce=F[1],Ie=F[2],ue=F[3],eA=F[4],xe=F[5],Ge=F[6],Me=F[7],pe=W[0],be=W[1],Se=W[2],lt=W[3],Ve=W[4],tt=W[5],it=W[6],st=W[7],ct=0;w>=128;){for(OA=0;OA<16;OA++)SA=8*OA+ct,V[OA]=z[SA+0]<<24|z[SA+1]<<16|z[SA+2]<<8|z[SA+3],nA[OA]=z[SA+4]<<24|z[SA+5]<<16|z[SA+6]<<8|z[SA+7];for(OA=0;OA<80;OA++)if(rA=te,IA=Ce,yA=Ie,FA=ue,xA=eA,Ee=xe,RA=Ge,Ae=Me,ie=pe,le=be,ae=Se,re=lt,ne=Ve,ee=tt,LA=it,PA=st,CA=Me,uA=st,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=(eA>>>14|Ve<<18)^(eA>>>18|Ve<<14)^(Ve>>>9|eA<<23),uA=(Ve>>>14|eA<<18)^(Ve>>>18|eA<<14)^(eA>>>9|Ve<<23),mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,CA=eA&xe^~eA&Ge,uA=Ve&tt^~Ve&it,mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,CA=_A[OA*2],uA=_A[OA*2+1],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,CA=V[OA%16],uA=nA[OA%16],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,UA=pA&65535|MA<<16,JA=mA&65535|hA<<16,CA=UA,uA=JA,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=(te>>>28|pe<<4)^(pe>>>2|te<<30)^(pe>>>7|te<<25),uA=(pe>>>28|te<<4)^(te>>>2|pe<<30)^(te>>>7|pe<<25),mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,CA=te&Ce^te&Ie^Ce&Ie,uA=pe&be^pe&Se^be&Se,mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,Ae=pA&65535|MA<<16,PA=mA&65535|hA<<16,CA=FA,uA=re,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=UA,uA=JA,mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,FA=pA&65535|MA<<16,re=mA&65535|hA<<16,Ce=rA,Ie=IA,ue=yA,eA=FA,xe=xA,Ge=Ee,Me=RA,te=Ae,be=ie,Se=le,lt=ae,Ve=re,tt=ne,it=ee,st=LA,pe=PA,OA%16===15)for(SA=0;SA<16;SA++)CA=V[SA],uA=nA[SA],mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=V[(SA+9)%16],uA=nA[(SA+9)%16],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,UA=V[(SA+1)%16],JA=nA[(SA+1)%16],CA=(UA>>>1|JA<<31)^(UA>>>8|JA<<24)^UA>>>7,uA=(JA>>>1|UA<<31)^(JA>>>8|UA<<24)^(JA>>>7|UA<<25),mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,UA=V[(SA+14)%16],JA=nA[(SA+14)%16],CA=(UA>>>19|JA<<13)^(JA>>>29|UA<<3)^UA>>>6,uA=(JA>>>19|UA<<13)^(UA>>>29|JA<<3)^(JA>>>6|UA<<26),mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,V[SA]=pA&65535|MA<<16,nA[SA]=mA&65535|hA<<16;CA=te,uA=pe,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[0],uA=W[0],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[0]=te=pA&65535|MA<<16,W[0]=pe=mA&65535|hA<<16,CA=Ce,uA=be,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[1],uA=W[1],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[1]=Ce=pA&65535|MA<<16,W[1]=be=mA&65535|hA<<16,CA=Ie,uA=Se,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[2],uA=W[2],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[2]=Ie=pA&65535|MA<<16,W[2]=Se=mA&65535|hA<<16,CA=ue,uA=lt,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[3],uA=W[3],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[3]=ue=pA&65535|MA<<16,W[3]=lt=mA&65535|hA<<16,CA=eA,uA=Ve,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[4],uA=W[4],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[4]=eA=pA&65535|MA<<16,W[4]=Ve=mA&65535|hA<<16,CA=xe,uA=tt,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[5],uA=W[5],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[5]=xe=pA&65535|MA<<16,W[5]=tt=mA&65535|hA<<16,CA=Ge,uA=it,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[6],uA=W[6],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[6]=Ge=pA&65535|MA<<16,W[6]=it=mA&65535|hA<<16,CA=Me,uA=st,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[7],uA=W[7],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[7]=Me=pA&65535|MA<<16,W[7]=st=mA&65535|hA<<16,ct+=128,w-=128}return w}function He(F,W,z){var w=new Int32Array(8),V=new Int32Array(8),nA=new Uint8Array(256),rA,IA=z;for(w[0]=1779033703,w[1]=3144134277,w[2]=1013904242,w[3]=2773480762,w[4]=1359893119,w[5]=2600822924,w[6]=528734635,w[7]=1541459225,V[0]=4089235720,V[1]=2227873595,V[2]=4271175723,V[3]=1595750129,V[4]=2917565137,V[5]=725511199,V[6]=4215389547,V[7]=327033209,we(w,V,W,z),z%=128,rA=0;rA<z;rA++)nA[rA]=W[IA-z+rA];for(nA[z]=128,z=256-128*(z<112?1:0),nA[z-9]=0,h(nA,z-8,IA/536870912|0,IA<<3),we(w,V,nA,z),rA=0;rA<8;rA++)h(F,8*rA,w[rA],V[rA]);return 0}function de(F,W){var z=t(),w=t(),V=t(),nA=t(),rA=t(),IA=t(),yA=t(),FA=t(),xA=t();L(z,F[1],F[0]),L(xA,W[1],W[0]),S(z,z,xA),p(w,F[0],F[1]),p(xA,W[0],W[1]),S(w,w,xA),S(V,F[3],W[3]),S(V,V,B),S(nA,F[2],W[2]),p(nA,nA,nA),L(rA,w,z),L(IA,nA,V),p(yA,nA,V),p(FA,w,z),S(F[0],rA,IA),S(F[1],FA,yA),S(F[2],yA,IA),S(F[3],rA,FA)}function Ke(F,W,z){var w;for(w=0;w<4;w++)J(F[w],W[w],z)}function nt(F,W){var z=t(),w=t(),V=t();AA(V,W[2]),S(z,W[0],V),S(w,W[1],V),H(F,w),F[31]^=K(z)<<7}function Le(F,W,z){var w,V;for(y(F[0],i),y(F[1],a),y(F[2],a),y(F[3],i),V=255;V>=0;--V)w=z[V/8|0]>>(V&7)&1,Ke(F,W,w),de(W,F),de(F,F),Ke(F,W,w)}function kA(F,W){var z=[t(),t(),t(),t()];y(z[0],u),y(z[1],E),y(z[2],a),S(z[3],u,E),Le(F,z,W)}function he(F,W,z){var w=new Uint8Array(64),V=[t(),t(),t(),t()],nA;for(z||s(W,32),He(w,W,32),w[0]&=248,w[31]&=127,w[31]|=64,kA(V,w),nt(F,V),nA=0;nA<32;nA++)W[nA+32]=F[nA];return 0}var zA=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function P(F,W){var z,w,V,nA;for(w=63;w>=32;--w){for(z=0,V=w-32,nA=w-12;V<nA;++V)W[V]+=z-16*W[w]*zA[V-(w-32)],z=Math.floor((W[V]+128)/256),W[V]-=z*256;W[V]+=z,W[w]=0}for(z=0,V=0;V<32;V++)W[V]+=z-(W[31]>>4)*zA[V],z=W[V]>>8,W[V]&=255;for(V=0;V<32;V++)W[V]-=z*zA[V];for(w=0;w<32;w++)W[w+1]+=W[w]>>8,F[w]=W[w]&255}function N(F){var W=new Float64Array(64),z;for(z=0;z<64;z++)W[z]=F[z];for(z=0;z<64;z++)F[z]=0;P(F,W)}function k(F,W,z,w){var V=new Uint8Array(64),nA=new Uint8Array(64),rA=new Uint8Array(64),IA,yA,FA=new Float64Array(64),xA=[t(),t(),t(),t()];He(V,w,32),V[0]&=248,V[31]&=127,V[31]|=64;var Ee=z+64;for(IA=0;IA<z;IA++)F[64+IA]=W[IA];for(IA=0;IA<32;IA++)F[32+IA]=V[32+IA];for(He(rA,F.subarray(32),z+32),N(rA),kA(xA,rA),nt(F,xA),IA=32;IA<64;IA++)F[IA]=w[IA];for(He(nA,F,z+64),N(nA),IA=0;IA<64;IA++)FA[IA]=0;for(IA=0;IA<32;IA++)FA[IA]=rA[IA];for(IA=0;IA<32;IA++)for(yA=0;yA<32;yA++)FA[IA+yA]+=nA[IA]*V[yA];return P(F.subarray(32),FA),Ee}function _(F,W){var z=t(),w=t(),V=t(),nA=t(),rA=t(),IA=t(),yA=t();return y(F[2],a),C(F[1],W),$(V,F[1]),S(nA,V,Q),L(V,V,F[2]),p(nA,F[2],nA),$(rA,nA),$(IA,rA),S(yA,IA,rA),S(z,yA,V),S(z,z,nA),sA(z,z),S(z,z,V),S(z,z,nA),S(z,z,nA),S(F[0],z,nA),$(w,F[0]),S(w,w,nA),v(w,V)&&S(F[0],F[0],c),$(w,F[0]),S(w,w,nA),v(w,V)?-1:(K(F[0])===W[31]>>7&&L(F[0],i,F[0]),S(F[3],F[0],F[1]),0)}function tA(F,W,z,w){var V,nA=new Uint8Array(32),rA=new Uint8Array(64),IA=[t(),t(),t(),t()],yA=[t(),t(),t(),t()];if(z<64||_(yA,w))return-1;for(V=0;V<z;V++)F[V]=W[V];for(V=0;V<32;V++)F[V+32]=w[V];if(He(rA,F,z),N(rA),Le(IA,yA,rA),kA(yA,W.subarray(32)),de(IA,yA),nt(nA,IA),z-=64,D(W,0,nA,0)){for(V=0;V<z;V++)F[V]=0;return-1}for(V=0;V<z;V++)F[V]=W[V+64];return z}var aA=32,EA=24,ZA=32,VA=16,$A=32,ke=32,XA=32,ye=32,Kt=32,Je=EA,je=ZA,To=VA,Be=64,ve=32,Lt=64,Oe=32,ze=64;e.lowlevel={crypto_core_hsalsa20:G,crypto_stream_xor:O,crypto_stream:U,crypto_stream_salsa20_xor:Z,crypto_stream_salsa20:X,crypto_onetimeauth:Y,crypto_onetimeauth_verify:x,crypto_verify_16:d,crypto_verify_32:D,crypto_secretbox:l,crypto_secretbox_open:I,crypto_scalarmult:oA,crypto_scalarmult_base:bA,crypto_box_beforenm:lA,crypto_box_afternm:jA,crypto_box:ce,crypto_box_open:NA,crypto_box_keypair:GA,crypto_hash:He,crypto_sign:k,crypto_sign_keypair:he,crypto_sign_open:tA,crypto_secretbox_KEYBYTES:aA,crypto_secretbox_NONCEBYTES:EA,crypto_secretbox_ZEROBYTES:ZA,crypto_secretbox_BOXZEROBYTES:VA,crypto_scalarmult_BYTES:$A,crypto_scalarmult_SCALARBYTES:ke,crypto_box_PUBLICKEYBYTES:XA,crypto_box_SECRETKEYBYTES:ye,crypto_box_BEFORENMBYTES:Kt,crypto_box_NONCEBYTES:Je,crypto_box_ZEROBYTES:je,crypto_box_BOXZEROBYTES:To,crypto_sign_BYTES:Be,crypto_sign_PUBLICKEYBYTES:ve,crypto_sign_SECRETKEYBYTES:Lt,crypto_sign_SEEDBYTES:Oe,crypto_hash_BYTES:ze,gf:t,D:Q,L:zA,pack25519:H,unpack25519:C,M:S,A:p,S:$,Z:L,pow2523:sA,add:de,set25519:y,modL:P,scalarmult:Le,scalarbase:kA};function co(F,W){if(F.length!==aA)throw new Error("bad key size");if(W.length!==EA)throw new Error("bad nonce size")}function KA(F,W){if(F.length!==XA)throw new Error("bad public key size");if(W.length!==ye)throw new Error("bad secret key size")}function se(){for(var F=0;F<arguments.length;F++)if(!(arguments[F]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function _t(F){for(var W=0;W<F.length;W++)F[W]=0}e.randomBytes=function(F){var W=new Uint8Array(F);return s(W,F),W},e.secretbox=function(F,W,z){se(F,W,z),co(z,W);for(var w=new Uint8Array(ZA+F.length),V=new Uint8Array(w.length),nA=0;nA<F.length;nA++)w[nA+ZA]=F[nA];return l(V,w,w.length,W,z),V.subarray(VA)},e.secretbox.open=function(F,W,z){se(F,W,z),co(z,W);for(var w=new Uint8Array(VA+F.length),V=new Uint8Array(w.length),nA=0;nA<F.length;nA++)w[nA+VA]=F[nA];return w.length<32||I(V,w,w.length,W,z)!==0?null:V.subarray(ZA)},e.secretbox.keyLength=aA,e.secretbox.nonceLength=EA,e.secretbox.overheadLength=VA,e.scalarMult=function(F,W){if(se(F,W),F.length!==ke)throw new Error("bad n size");if(W.length!==$A)throw new Error("bad p size");var z=new Uint8Array($A);return oA(z,F,W),z},e.scalarMult.base=function(F){if(se(F),F.length!==ke)throw new Error("bad n size");var W=new Uint8Array($A);return bA(W,F),W},e.scalarMult.scalarLength=ke,e.scalarMult.groupElementLength=$A,e.box=function(F,W,z,w){var V=e.box.before(z,w);return e.secretbox(F,W,V)},e.box.before=function(F,W){se(F,W),KA(F,W);var z=new Uint8Array(Kt);return lA(z,F,W),z},e.box.after=e.secretbox,e.box.open=function(F,W,z,w){var V=e.box.before(z,w);return e.secretbox.open(F,W,V)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var F=new Uint8Array(XA),W=new Uint8Array(ye);return GA(F,W),{publicKey:F,secretKey:W}},e.box.keyPair.fromSecretKey=function(F){if(se(F),F.length!==ye)throw new Error("bad secret key size");var W=new Uint8Array(XA);return bA(W,F),{publicKey:W,secretKey:new Uint8Array(F)}},e.box.publicKeyLength=XA,e.box.secretKeyLength=ye,e.box.sharedKeyLength=Kt,e.box.nonceLength=Je,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(F,W){if(se(F,W),W.length!==Lt)throw new Error("bad secret key size");var z=new Uint8Array(Be+F.length);return k(z,F,F.length,W),z},e.sign.open=function(F,W){if(se(F,W),W.length!==ve)throw new Error("bad public key size");var z=new Uint8Array(F.length),w=tA(z,F,F.length,W);if(w<0)return null;for(var V=new Uint8Array(w),nA=0;nA<V.length;nA++)V[nA]=z[nA];return V},e.sign.detached=function(F,W){for(var z=e.sign(F,W),w=new Uint8Array(Be),V=0;V<w.length;V++)w[V]=z[V];return w},e.sign.detached.verify=function(F,W,z){if(se(F,W,z),W.length!==Be)throw new Error("bad signature size");if(z.length!==ve)throw new Error("bad public key size");var w=new Uint8Array(Be+F.length),V=new Uint8Array(Be+F.length),nA;for(nA=0;nA<Be;nA++)w[nA]=W[nA];for(nA=0;nA<F.length;nA++)w[nA+Be]=F[nA];return tA(V,w,w.length,z)>=0},e.sign.keyPair=function(){var F=new Uint8Array(ve),W=new Uint8Array(Lt);return he(F,W),{publicKey:F,secretKey:W}},e.sign.keyPair.fromSecretKey=function(F){if(se(F),F.length!==Lt)throw new Error("bad secret key size");for(var W=new Uint8Array(ve),z=0;z<W.length;z++)W[z]=F[32+z];return{publicKey:W,secretKey:new Uint8Array(F)}},e.sign.keyPair.fromSeed=function(F){if(se(F),F.length!==Oe)throw new Error("bad seed size");for(var W=new Uint8Array(ve),z=new Uint8Array(Lt),w=0;w<32;w++)z[w]=F[w];return he(W,z,!0),{publicKey:W,secretKey:z}},e.sign.publicKeyLength=ve,e.sign.secretKeyLength=Lt,e.sign.seedLength=Oe,e.sign.signatureLength=Be,e.hash=function(F){se(F);var W=new Uint8Array(ze);return He(W,F,F.length),W},e.hash.hashLength=ze,e.verify=function(F,W){return se(F,W),F.length===0||W.length===0||F.length!==W.length?!1:f(F,0,W,0,F.length)===0},e.setPRNG=function(F){s=F},(function(){var F=typeof self<"u"?self.crypto||self.msCrypto:null;if(F&&F.getRandomValues){var W=65536;e.setPRNG(function(z,w){var V,nA=new Uint8Array(w);for(V=0;V<w;V+=W)F.getRandomValues(nA.subarray(V,V+Math.min(w-V,W)));for(V=0;V<w;V++)z[V]=nA[V];_t(nA)})}else typeof E1<"u"&&(F=uE,F&&F.randomBytes&&e.setPRNG(function(z,w){var V,nA=F.randomBytes(w);for(V=0;V<w;V++)z[V]=nA[V];_t(nA)}))})()})(A.exports?A.exports:self.nacl=self.nacl||{})})(Zi)),Zi.exports}C1();const u1={models:[{id:"claude-3-5-haiku-20241022",name:"Claude Haiku 3.5",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-07-31",release_date:"2024-10-22",last_updated:"2024-10-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:.8039999999999999,output:4.02,cache_read:.0804,cache_write:1.005}},{id:"claude-3-5-haiku-latest",name:"Claude Haiku 3.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-07-31",release_date:"2024-10-22",last_updated:"2024-10-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:.8039999999999999,output:4.02,cache_read:.0804,cache_write:1.005}},{id:"claude-3-5-sonnet-20240620",name:"Claude Sonnet 3.5",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-04-30",release_date:"2024-06-20",last_updated:"2024-06-20",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-3-5-sonnet-20241022",name:"Claude Sonnet 3.5 v2",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-04-30",release_date:"2024-10-22",last_updated:"2024-10-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-haiku-4-5",name:"Claude Haiku 4.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",release_date:"2025-10-15",last_updated:"2025-10-15",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.005,output:5.0249999999999995,cache_read:.10049999999999999,cache_write:1.2562499999999999}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",release_date:"2025-10-15",last_updated:"2025-10-15",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.005,output:5.0249999999999995,cache_read:.10049999999999999,cache_write:1.2562499999999999}},{id:"claude-opus-4-0",name:"Claude Opus 4 (latest)",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-1",name:"Claude Opus 4.1 (latest)",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-08-05",last_updated:"2025-08-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-1-20250805",name:"Claude Opus 4.1",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-08-05",last_updated:"2025-08-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-20250514",name:"Claude Opus 4",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-5",name:"Claude Opus 4.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-11-24",last_updated:"2025-11-24",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-11-01",last_updated:"2025-11-01",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-opus-4-6",name:"Claude Opus 4.6",owned_by:"anthropic",context_length:1e6,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",release_date:"2026-02-05",last_updated:"2026-03-13",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-opus-4-7",name:"Claude Opus 4.7",owned_by:"anthropic",context_length:1e6,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",release_date:"2026-04-16",last_updated:"2026-04-16",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-sonnet-4-0",name:"Claude Sonnet 4 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",release_date:"2025-09-29",last_updated:"2025-09-29",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",release_date:"2025-09-29",last_updated:"2025-09-29",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",owned_by:"anthropic",context_length:1e6,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",release_date:"2026-02-17",last_updated:"2026-03-13",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"deepseek-chat",name:"DeepSeek Chat",owned_by:"deepseek",context_length:1e6,max_output:384e3,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-09",release_date:"2025-12-01",last_updated:"2026-02-28",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.1407,output:.2814,cache_read:.02814}},{id:"deepseek-reasoner",name:"DeepSeek Reasoner",owned_by:"deepseek",context_length:1e6,max_output:384e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-09",release_date:"2025-12-01",last_updated:"2026-02-28",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.1407,output:.2814,cache_read:.02814}},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",owned_by:"deepseek",context_length:1e6,max_output:384e3,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-05",release_date:"2026-04-24",last_updated:"2026-04-24",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.1407,output:.2814,cache_read:.02814}},{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",owned_by:"deepseek",context_length:1e6,max_output:384e3,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-05",release_date:"2026-04-24",last_updated:"2026-04-24",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:1.7486999999999997,output:3.4973999999999994,cache_read:.14572499999999997}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2025-12-17",last_updated:"2025-12-17",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:.5025,output:3.0149999999999997,cache_read:.050249999999999996}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview",owned_by:"google",context_length:1e6,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2025-11-18",last_updated:"2025-11-18",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:2.01,output:12.059999999999999,cache_read:.20099999999999998}},{id:"gemini-3.1-flash-image-preview",name:"Gemini 3.1 Flash Image (Preview)",owned_by:"google",context_length:131072,max_output:32768,reasoning:!0,tool_call:!1,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-02-26",last_updated:"2026-02-26",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text","image"]},pricing:{input:.25125,output:60.3}},{id:"gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-03-03",last_updated:"2026-03-03",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:.25125,output:1.5074999999999998,cache_read:.025124999999999998,cache_write:1.005}},{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-02-19",last_updated:"2026-02-19",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:2.01,output:12.059999999999999,cache_read:.20099999999999998}},{id:"gemini-3.1-pro-preview-customtools",name:"Gemini 3.1 Pro Preview Custom Tools",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-02-19",last_updated:"2026-02-19",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:2.01,output:12.059999999999999,cache_read:.20099999999999998}},{id:"MiniMax-M2.1",name:"MiniMax-M2.1",owned_by:"minimax",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2025-12-23",last_updated:"2025-12-23",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.30149999999999993,output:1.2059999999999997}},{id:"MiniMax-M2.5",name:"MiniMax-M2.5",owned_by:"minimax",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-02-12",last_updated:"2026-02-12",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.30149999999999993,output:1.2059999999999997,cache_read:.030149999999999996,cache_write:.37687499999999996}},{id:"MiniMax-M2.7",name:"MiniMax-M2.7",owned_by:"minimax",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-03-18",last_updated:"2026-03-18",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.30149999999999993,output:1.2059999999999997,cache_read:.06029999999999999,cache_write:.37687499999999996}},{id:"kimi-k2-0711-preview",name:"Kimi K2 0711",owned_by:"moonshot",context_length:131072,max_output:16384,reasoning:!1,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-10",release_date:"2025-07-14",last_updated:"2025-07-14",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.5124999999999997,cache_read:.15074999999999997}},{id:"kimi-k2-0905-preview",name:"Kimi K2 0905",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!1,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-10",release_date:"2025-09-05",last_updated:"2025-09-05",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.5124999999999997,cache_read:.15074999999999997}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-08",release_date:"2025-11-06",last_updated:"2025-11-06",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.5124999999999997,cache_read:.15074999999999997}},{id:"kimi-k2-thinking-turbo",name:"Kimi K2 Thinking Turbo",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-08",release_date:"2025-11-06",last_updated:"2025-11-06",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:1.1557499999999998,output:8.04,cache_read:.15074999999999997}},{id:"kimi-k2-turbo-preview",name:"Kimi K2 Turbo",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!1,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-10",release_date:"2025-09-05",last_updated:"2025-09-05",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:2.4119999999999995,output:10.049999999999999,cache_read:.6029999999999999}},{id:"kimi-k2.5",name:"Kimi K2.5",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!1,temperature:!1,knowledge:"2025-01",release_date:"2026-01",last_updated:"2026-01",open_weights:!0,modalities:{input:["text","image","video"],output:["text"]},pricing:{input:.6029999999999999,output:3.0149999999999997,cache_read:.10049999999999999,cache_write:.6029999999999999}},{id:"kimi-k2.6",name:"Kimi K2.6",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-04-21",last_updated:"2026-04-21",open_weights:!0,modalities:{input:["text","image","video"],output:["text"]},pricing:{input:.9547499999999999,output:4.02,cache_read:.1608}},{id:"gpt-5",name:"GPT-5",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5-chat-latest",name:"GPT-5 Chat (latest)",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!1,attachment:!0,temperature:!0,knowledge:"2024-09-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999}},{id:"gpt-5-codex",name:"GPT-5-Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",release_date:"2025-09-15",last_updated:"2025-09-15",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5-mini",name:"GPT-5 Mini",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.25125,output:2.01,cache_read:.025124999999999998}},{id:"gpt-5-nano",name:"GPT-5 Nano",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.050249999999999996,output:.40199999999999997,cache_read:.005025}},{id:"gpt-5-pro",name:"GPT-5 Pro",owned_by:"openai",context_length:4e5,max_output:272e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-10-06",last_updated:"2025-10-06",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:15.075,output:120.6}},{id:"gpt-5.1",name:"GPT-5.1",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.13065}},{id:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",owned_by:"openai",context_length:128e3,max_output:16384,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.25125,output:2.01,cache_read:.025124999999999998}},{id:"gpt-5.2",name:"GPT-5.2",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",owned_by:"openai",context_length:128e3,max_output:16384,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.2-pro",name:"GPT-5.2 Pro",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:21.104999999999997,output:168.83999999999997}},{id:"gpt-5.3-chat-latest",name:"GPT-5.3 Chat (latest)",owned_by:"openai",context_length:128e3,max_output:16384,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",release_date:"2026-03-03",last_updated:"2026-03-03",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-02-05",last_updated:"2026-02-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",owned_by:"openai",context_length:128e3,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-02-05",last_updated:"2026-02-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.4",name:"GPT-5.4",owned_by:"openai",context_length:105e4,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-05",last_updated:"2026-03-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:2.5124999999999997,output:15.075,cache_read:.25125}},{id:"gpt-5.4-mini",name:"GPT-5.4 mini",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-17",last_updated:"2026-03-17",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.7537499999999999,output:4.522499999999999,cache_read:.07537499999999998}},{id:"gpt-5.4-nano",name:"GPT-5.4 nano",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-17",last_updated:"2026-03-17",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.20099999999999998,output:1.2562499999999999,cache_read:.0201}},{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",owned_by:"openai",context_length:105e4,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-05",last_updated:"2026-03-05",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:30.15,output:180.89999999999998}},{id:"gpt-5.5",name:"GPT-5.5",owned_by:"openai",context_length:105e4,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",release_date:"2026-04-23",last_updated:"2026-04-23",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:30.15,cache_read:.5025}},{id:"gpt-5.5-pro",name:"GPT-5.5 Pro",owned_by:"openai",context_length:105e4,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",release_date:"2026-04-23",last_updated:"2026-04-23",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:30.15,output:180.89999999999998}},{id:"grok-4.20-0309-non-reasoning",name:"Grok 4.20 (Non-Reasoning)",owned_by:"xai",context_length:2e6,max_output:3e4,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,release_date:"2026-03-09",last_updated:"2026-03-09",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:2.01,output:6.029999999999999,cache_read:.20099999999999998}},{id:"grok-4.20-0309-reasoning",name:"Grok 4.20 (Reasoning)",owned_by:"xai",context_length:2e6,max_output:3e4,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,release_date:"2026-03-09",last_updated:"2026-03-09",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:2.01,output:6.029999999999999,cache_read:.20099999999999998}},{id:"grok-4.20-multi-agent-0309",name:"Grok 4.20 Multi-Agent",owned_by:"xai",context_length:2e6,max_output:3e4,reasoning:!0,tool_call:!1,attachment:!0,temperature:!0,release_date:"2026-03-09",last_updated:"2026-03-09",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:2.01,output:6.029999999999999,cache_read:.20099999999999998}},{id:"grok-4.3",name:"Grok 4.3",owned_by:"xai",context_length:1e6,max_output:3e4,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,release_date:"2026-05-01",last_updated:"2026-05-01",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:2.5124999999999997,cache_read:.20099999999999998}},{id:"glm-4.7",name:"GLM-4.7",owned_by:"zai",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-04",release_date:"2025-12-22",last_updated:"2025-12-22",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.211,cache_read:.11055}},{id:"glm-4.7-flash",name:"GLM-4.7-Flash",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-04",release_date:"2026-01-19",last_updated:"2026-01-19",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:0,output:0}},{id:"glm-4.7-flashx",name:"GLM-4.7-FlashX",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-04",release_date:"2026-01-19",last_updated:"2026-01-19",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.07035,output:.40199999999999997,cache_read:.01005}},{id:"glm-5",name:"GLM-5",owned_by:"zai",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-02-11",last_updated:"2026-02-11",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:1.005,output:3.2159999999999997,cache_read:.20099999999999998}},{id:"glm-5-turbo",name:"GLM-5-Turbo",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-03-16",last_updated:"2026-03-16",open_weights:!1,modalities:{input:["text"],output:["text"]},pricing:{input:1.2059999999999997,output:4.02,cache_read:.24119999999999997}},{id:"glm-5.1",name:"GLM-5.1",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-03-27",last_updated:"2026-03-27",open_weights:!1,modalities:{input:["text"],output:["text"]},pricing:{input:1.4069999999999998,output:4.422,cache_read:.2613}},{id:"glm-5v-turbo",name:"GLM-5V-Turbo",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,release_date:"2026-04-01",last_updated:"2026-04-01",open_weights:!1,modalities:{input:["text","image","video","pdf"],output:["text"]},pricing:{input:1.2059999999999997,output:4.02,cache_read:.24119999999999997}}]},La="ollama-cloud",WE="ottorouter",I1={openai:"@ai-sdk/openai",anthropic:"@ai-sdk/anthropic",google:"@ai-sdk/google",openrouter:"@openrouter/ai-sdk-provider",xai:"@ai-sdk/xai",moonshot:"@ai-sdk/openai-compatible",zai:"@ai-sdk/openai-compatible",minimax:"@ai-sdk/anthropic"};function d1(A){const e=A.owned_by;return{id:A.id,ownedBy:e,label:A.name,modalities:A.modalities,toolCall:A.tool_call,reasoningText:A.reasoning,attachment:A.attachment,temperature:A.temperature,knowledge:A.knowledge,releaseDate:A.release_date,lastUpdated:A.last_updated,openWeights:A.open_weights,cost:{input:A.pricing.input,output:A.pricing.output,cacheRead:A.pricing.cache_read,cacheWrite:A.pricing.cache_write},limit:{context:A.context_length,output:A.max_output},provider:{npm:I1[e]}}}function h1(){const A=u1.models.map(d1);if(!A.length)return null;A.sort((s,n)=>{const r=s.ownedBy??"",i=n.ownedBy??"";return r===i?s.id.localeCompare(n.id):r==="openai"?-1:i==="openai"?1:r.localeCompare(i)});const e="gpt-5-codex",t=A.findIndex(s=>s.id===e);if(t>0){const[s]=A.splice(t,1);A.unshift(s)}return{id:WE,label:"OttoRouter",env:["OTTOROUTER_PRIVATE_KEY"],api:"https://api.ottorouter.org/v1",doc:"https://ottorouter.org/docs",models:A}}function p1(){return{id:La,label:"Ollama Cloud",env:["OLLAMA_API_KEY"],npm:"ai-sdk-ollama",api:"https://ollama.com",doc:"https://docs.ollama.com/cloud",models:[]}}function f1(A){const e=A[La]??p1(),t=h1(),s={...A};return s[La]=e,t&&(s[WE]=t),s}const ui=f1(Ax),m1={openai:[{match:A=>A.includes("gpt-4o-mini"),inputPerMillion:.15,outputPerMillion:.6},{match:A=>A.includes("gpt-4o"),inputPerMillion:5,outputPerMillion:15},{match:A=>A.includes("gpt-4.1-mini"),inputPerMillion:1,outputPerMillion:4},{match:A=>A.includes("gpt-4.1"),inputPerMillion:5,outputPerMillion:15}],anthropic:[{match:A=>A.includes("claude-3-haiku"),inputPerMillion:.25,outputPerMillion:1.25},{match:A=>A.includes("claude-3-sonnet"),inputPerMillion:3,outputPerMillion:15},{match:A=>A.includes("claude-3-opus"),inputPerMillion:15,outputPerMillion:75}],google:[{match:A=>A.includes("gemini-1.5-flash"),inputPerMillion:.35,outputPerMillion:1.05},{match:A=>A.includes("gemini-1.5-pro"),inputPerMillion:3.5,outputPerMillion:10.5}],"ollama-cloud":[],openrouter:[],opencode:[],ottorouter:[],xai:[],zai:[],"zai-coding":[],moonshot:[],minimax:[],copilot:[]};function w1(A,e){const t=m1[A];if(t)return t.find(s=>{try{return s.match(e)}catch{return!1}})}function x1(A,e){const t=ui[A];if(!t)return;const s=e.toLowerCase();return t.models.find(n=>n.id?.toLowerCase()===s)}function zE(A,e,t){const s=typeof t.inputTokens=="number"?t.inputTokens:0,n=typeof t.outputTokens=="number"?t.outputTokens:0,r=typeof t.cachedInputTokens=="number"?t.cachedInputTokens:0,i=typeof t.cacheCreationInputTokens=="number"?t.cacheCreationInputTokens:0;if(!s&&!n&&!r&&!i)return;const a=x1(A,e);if(a?.cost?.input!=null||a?.cost?.output!=null){const c=typeof a.cost?.input=="number"?a.cost.input:0,h=typeof a.cost?.output=="number"?a.cost.output:0,f=typeof a.cost?.cacheRead=="number"?a.cost.cacheRead:0,d=typeof a.cost?.cacheWrite=="number"?a.cost.cacheWrite:0,R=Math.max(0,s-r-i)*c/1e6,M=n*h/1e6,q=r*f/1e6,G=i*d/1e6,T=R+M+q+G;return Number.isFinite(T)?Number(T.toFixed(6)):void 0}const g=w1(A,e.toLowerCase());if(!g)return;const B=Math.max(0,s-r-i)*g.inputPerMillion/1e6,u=n*g.outputPerMillion/1e6,E=B+u;return Number.isFinite(E)?Number(E.toFixed(6)):void 0}var Ja={};function Wg(...A){return A.filter(Boolean).map(e=>e.replace(/\\/g,"/")).join("/").replace(/\/+\/+/g,"/")}function D1(){return(Ja.HOME||Ja.USERPROFILE||"").replace(/\\/g,"/")}function y1(){const A=Ja.XDG_CONFIG_HOME;return A?.trim()?A.replace(/\\/g,"/"):Wg(D1(),".config")}function N1(){return Wg(y1(),"otto")}const k1="catalog-models.json";function M1(){return Wg(N1(),k1)}function Fr(A){return typeof A=="object"&&A!==null&&!Array.isArray(A)}function b1(A){try{return globalThis.process?.getBuiltinModule?.("node:fs")?.readFileSync(A,"utf8")??null}catch{return null}}function F1(A,e){if(!Fr(e))return null;const t=Array.isArray(e.models)?e.models.filter(s=>Fr(s)&&typeof s.id=="string"):[];return{id:typeof e.id=="string"?e.id:A,label:typeof e.label=="string"?e.label:void 0,models:t}}function v1(A){if(!Fr(A))return{};const e=Fr(A.providers)?A.providers:A,t={};for(const[s,n]of Object.entries(e)){const r=F1(s,n);r&&(t[s]=r)}return t}function G1(A){return{version:1,updatedAt:Fr(A)&&typeof A.updatedAt=="string"?A.updatedAt:new Date(0).toISOString(),providers:v1(A)}}function S1(){try{const A=b1(M1());if(!A)return null;const e=JSON.parse(A);return G1(e)}catch{return null}}function U1(A){return S1()?.providers[A]}function VE(A){return typeof A=="string"&&R1.includes(A)}const R1=Object.keys(ui);function _E(A,e){if(VE(A)&&ui[A])return K1(A).find(s=>s.id===e)}function K1(A){return U1(A)?.models??(VE(A)?ui[A]?.models:void 0)??[]}function zg(A){const[e,t]=m.useState(0);return m.useEffect(()=>{const s=A.current;if(!s)return;const n=()=>t(s.clientWidth);n();const r=new ResizeObserver(()=>n());return r.observe(s),()=>r.disconnect()},[A]),e}function ZE({sessionId:A,title:e,className:t=""}){const[s,n]=m.useState(!1),[r,i]=m.useState(e||""),a=m.useRef(null),{mutate:g}=wg(A);m.useEffect(()=>{s&&a.current&&(a.current.focus(),a.current.select())},[s]),m.useEffect(()=>{i(e||"")},[e]);const Q=m.useCallback(()=>{const u=r.trim();u&&u!==(e||"")&&g({title:u}),n(!1)},[r,e,g]),B=m.useCallback(()=>{i(e||""),n(!1)},[e]);return s?o.jsx("input",{ref:a,type:"text",value:r,onChange:u=>i(u.target.value),onBlur:Q,onKeyDown:u=>{u.key==="Enter"&&Q(),u.key==="Escape"&&B()},className:`w-full bg-muted/30 text-foreground rounded px-2 py-1 outline-none ring-1 ring-primary/50 focus:ring-primary ${t}`}):o.jsxs("button",{type:"button",onClick:()=>n(!0),className:`group flex items-center gap-2 hover:opacity-80 transition-opacity truncate text-left ${t}`,title:"Click to edit title",children:[o.jsx("span",{className:"truncate",children:e||"Untitled Session"}),o.jsx(yn,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-50 flex-shrink-0 transition-opacity"})]})}function L1({session:A,onNavigateToSession:e}){const{data:t}=Tc(A.sessionType==="branch"?A.id:void 0),{preferences:s}=sr(),{data:n}=fg(A.id),r=m.useRef(null),i=zg(r),a=i>0&&i<640,g=m.useMemo(()=>{const q=A.totalInputTokens||0,G=A.totalOutputTokens||0,T=A.totalCachedTokens||0,Z=A.totalCacheCreationTokens||0;return zE(A.provider,A.model,{inputTokens:q,outputTokens:G,cachedInputTokens:T,cacheCreationInputTokens:Z})??0},[A.provider,A.model,A.totalInputTokens,A.totalOutputTokens,A.totalCachedTokens,A.totalCacheCreationTokens]),Q=q=>{if(!q)return"0s";const G=Math.floor(q/1e3),T=Math.floor(G/60),Z=Math.floor(T/60);return Z>0?`${Z}h ${T%60}m`:T>0?`${T}m ${G%60}s`:`${G}s`},B=q=>q.toLocaleString("en-US"),u=q=>q>=1e6?`${(q/1e6).toFixed(1)}M`:q>=1e3?`${(q/1e3).toFixed(1)}K`:q.toString(),E=A.currentContextTokens||0,c=A.totalOutputTokens||0,h=A.sessionType==="branch",f=t?.parent,d=m.useMemo(()=>_E(A.provider,A.model)?.limit?.context,[A.provider,A.model]),D=d?E/d*100:0,R=()=>D>=90?"text-red-600 dark:text-red-400":D>=70?"text-amber-600 dark:text-amber-400":"text-foreground",M=s.fullWidthContent?"w-full px-6 py-6":"max-w-3xl mx-auto px-6 py-6";return o.jsx("div",{ref:r,className:"border-b border-border bg-background/95 backdrop-blur-sm",children:o.jsxs("div",{className:M,children:[h&&o.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm",children:[o.jsx(Qo,{className:"h-4 w-4 text-violet-500"}),o.jsx("span",{className:"text-violet-600 dark:text-violet-400 font-medium",children:"Branch"}),f&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground",children:"from"}),o.jsxs("button",{type:"button",onClick:()=>e?.(f.id),className:"text-primary hover:underline flex items-center gap-1",children:[f.title||`Session ${f.id.slice(0,8)}`,o.jsx(dB,{className:"h-3 w-3"})]})]}),!f&&A.parentSessionId&&o.jsx("span",{className:"text-muted-foreground italic text-xs",children:"(parent deleted)"})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(ZE,{sessionId:A.id,title:A.title,className:"text-2xl font-semibold text-foreground leading-tight"}),n?.shared&&o.jsxs("button",{type:"button",onClick:()=>Io(n.url),className:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20 transition-colors text-xs font-medium flex-shrink-0",children:[o.jsx(Xa,{className:"h-3 w-3"}),o.jsx("span",{children:"Shared"}),n.pendingMessages&&n.pendingMessages>0?o.jsxs("span",{className:"flex items-center gap-0.5 text-amber-600 dark:text-amber-400",children:[o.jsx(Xt,{className:"h-2.5 w-2.5"}),n.pendingMessages]}):o.jsx(Gt,{className:"h-2.5 w-2.5 opacity-60"})]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-2 mt-4 text-sm text-muted-foreground",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"flex items-center gap-1.5",title:`Current context window: ${B(E)} tokens`,children:[o.jsx("span",{className:"text-xs opacity-70",children:"ctx"}),o.jsx("span",{className:`font-medium ${R()}`,children:u(E)})]}),!a&&o.jsxs("div",{className:"flex items-center gap-1.5",title:`Total output: ${B(c)} tokens`,children:[o.jsx("span",{className:"text-xs opacity-70",children:"out"}),o.jsx("span",{className:"font-medium text-foreground",children:u(c)})]})]}),!a&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Wn,{className:"w-4 h-4"}),o.jsx("span",{className:"font-medium text-foreground",children:Q(A.totalToolTimeMs)})]}),g>0&&!a&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(hB,{className:"w-4 h-4"}),o.jsx("span",{className:"font-medium text-foreground",children:g.toFixed(4)})]}),o.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[o.jsx(ro,{provider:A.provider,size:18}),!a&&o.jsx("span",{className:"font-medium text-foreground",children:A.model})]})]})]})})}const uo=gt(A=>({usage:{},isLoading:{},lastFetched:{},isModalOpen:!1,modalProvider:null,setUsage:(e,t)=>A(s=>({usage:{...s.usage,[e]:t}})),setLoading:(e,t)=>A(s=>({isLoading:{...s.isLoading,[e]:t}})),setLastFetched:(e,t)=>A(s=>({lastFetched:{...s.lastFetched,[e]:t}})),openModal:e=>A({isModalOpen:!0,modalProvider:e}),closeModal:()=>A({isModalOpen:!1,modalProvider:null})})),Es=22,Ta=2.5,ja=(Es-Ta)/2,Xi=2*Math.PI*ja;function J1(A){return A>=90?"#ef4444":A>=70?"#f59e0b":"#3b82f6"}const SQ=m.memo(function({usage:e,provider:t}){const s=uo(a=>a.openModal),n=e.primaryWindow?.usedPercent??0,r=Xi-n/100*Xi,i=J1(n);return o.jsxs("button",{type:"button",onClick:()=>s(t),className:"relative flex items-center hover:opacity-80 transition-opacity cursor-pointer",title:`Usage: ${Math.round(n)}% (5h window) — Click for details`,children:[o.jsxs("svg",{width:Es,height:Es,className:"-rotate-90",role:"img","aria-label":"Usage ring",children:[o.jsx("circle",{cx:Es/2,cy:Es/2,r:ja,fill:"none",stroke:"hsl(var(--muted))",strokeWidth:Ta}),o.jsx("circle",{cx:Es/2,cy:Es/2,r:ja,fill:"none",stroke:i,strokeWidth:Ta,strokeDasharray:Xi,strokeDashoffset:r,strokeLinecap:"round",className:"transition-all duration-500"})]}),o.jsx("span",{className:"absolute inset-0 flex items-center justify-center rotate-0 font-medium text-muted-foreground",style:{fontSize:7},children:"5h"})]})});function T1(A){if(!A)return"Unknown";const e=Date.now(),s=new Date(A).getTime()-e;if(s<=0)return"Now";const n=Math.floor(s/864e5),r=Math.floor(s%864e5/36e5),i=Math.floor(s%36e5/6e4);return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:`${i}m`}function UQ(A){return A<=18e3?"5 Hour":A<=86400?"24 Hour":"7 Day"}function $i({label:A,window:e}){const t=Math.min(e.usedPercent,100),s=t>=90?"bg-red-500":t>=70?"bg-amber-500":"bg-blue-500";return o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:A}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:"font-medium text-foreground",children:[Math.round(t),"%"]}),e.resetsAt&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["resets in ",T1(e.resetsAt)]})]})]}),o.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${s}`,style:{width:`${t}%`}})})]})}const j1=m.memo(function(){const e=uo(i=>i.isModalOpen),t=uo(i=>i.modalProvider),s=uo(i=>i.closeModal),n=uo(i=>t?i.usage[t]:void 0),r=m.useMemo(()=>o.jsxs("div",{className:"flex items-center gap-2",children:[t&&o.jsx(ro,{provider:t,size:20}),o.jsx("span",{children:"Usage & Limits"})]}),[t]);return n?o.jsx(Lo,{isOpen:e,onClose:s,title:r,maxWidth:"sm",children:o.jsxs("div",{className:"space-y-5",children:[n.limitReached&&o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md bg-red-500/10 border border-red-500/20",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 flex-shrink-0"}),o.jsx("span",{className:"text-sm text-red-600 dark:text-red-400 font-medium",children:"Rate limit reached"})]}),n.primaryWindow&&o.jsx($i,{label:`${UQ(n.primaryWindow.windowSeconds)} Window`,window:n.primaryWindow}),n.secondaryWindow&&o.jsx($i,{label:`${UQ(n.secondaryWindow.windowSeconds)} Window`,window:n.secondaryWindow}),n.sonnetWindow&&n.sonnetWindow.usedPercent>0&&o.jsx($i,{label:"Sonnet (7 Day)",window:{usedPercent:n.sonnetWindow.usedPercent,windowSeconds:604800,resetsAt:n.sonnetWindow.resetsAt}}),n.extraUsage?.is_enabled&&o.jsx("div",{className:"pt-2 border-t border-border space-y-1",children:o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Extra Credits"}),o.jsxs("span",{className:"font-medium text-foreground",children:["$",n.extraUsage.used_credits.toFixed(2)," / $",n.extraUsage.monthly_limit]})]})}),n.credits?.has_credits&&o.jsx("div",{className:"pt-2 border-t border-border space-y-1",children:o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Credits"}),o.jsx("span",{className:"font-medium text-foreground",children:n.credits.balance!==null?`$${n.credits.balance.toFixed(2)}`:"Available"})]})}),n.planType&&o.jsx("div",{className:"pt-2 border-t border-border",children:o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Plan"}),o.jsx("span",{className:"font-medium text-foreground capitalize",children:n.planType})]})})]})}):null}),O1=6e4,q1=3e4,Aa=new Set;function Y1(A,e){const t=uo(Q=>Q.setUsage),s=uo(Q=>Q.setLoading),n=uo(Q=>Q.setLastFetched),r=uo(Q=>A?Q.usage[A]:void 0),i=e==="oauth"&&(A==="anthropic"||A==="openai"),a=m.useCallback(async()=>{if(!A||!i||Aa.has(A))return;const Q=uo.getState().lastFetched[A]??0;if(!(Q&&Date.now()-Q<q1)){Aa.add(A),s(A,!0);try{const B=await fA.getProviderUsage(A);t(A,B),n(A,Date.now())}catch{}finally{s(A,!1),Aa.delete(A)}}},[A,i,t,s,n]),g=m.useRef(a);return g.current=a,m.useEffect(()=>{if(!A||!i)return;g.current();const Q=setInterval(()=>g.current(),O1);return()=>clearInterval(Q)},[i,A]),{usage:r,fetchUsage:a,isOAuthProvider:i}}function Ii(A){const e=Ne(d=>d.setBalance),t=Ne(d=>d.setUsdcBalance),s=Ne(d=>d.setWalletAddress),n=Ne(d=>d.setLoading),r=Ne(d=>d.setScope),i=Ne(d=>d.setPayg),a=Ne(d=>d.setSubscription),g=Ne(d=>d.setLimits),Q=uo(d=>d.setUsage),B=Ne(d=>d.balance),u=Ne(d=>d.usdcBalance),E=Ne(d=>d.subscription),c=Ne(d=>d.network),h=m.useCallback(async()=>{if(A==="ottorouter"){n(!0);try{const[d,D,R]=await Promise.all([fA.getOttoRouterBalance(),fA.getOttoRouterUsdcBalance(c),fA.getOttoRouterWallet()]);if(d){e(d.balance),s(d.walletAddress),r(d.scope??null),i(d.payg??null),a(d.subscription??null),g(d.limits??null);const M=d.subscription;M?.active&&M.usageWindows&&Q("ottorouter",{provider:"ottorouter",primaryWindow:{usedPercent:M.usageWindows.fiveHour.percentUsed,windowSeconds:18e3,resetsAt:null},secondaryWindow:{usedPercent:M.usageWindows.weekly.percentUsed,windowSeconds:604800,resetsAt:null},limitReached:!1,planType:M.tierName??"GO"})}else R?.configured&&R.publicKey&&s(R.publicKey);D&&(t(D.usdcBalance),!d&&D.walletAddress&&s(D.walletAddress))}catch{}finally{n(!1)}}},[A,c,e,t,s,n,r,i,a,g,Q]),f=E?.active&&!E.usageWindows;return m.useEffect(()=>{A==="ottorouter"&&(B===null||u===null||f)&&h()},[A,B,u,f,h]),{fetchBalance:h}}function H1({session:A,isVisible:e,isGenerating:t,onNavigateToSession:s}){const{data:n}=Tc(A.sessionType==="branch"?A.id:void 0),{data:r}=fg(A.id),i=m.useMemo(()=>{const Z=A.totalInputTokens||0,X=A.totalOutputTokens||0,U=A.totalCachedTokens||0,O=A.totalCacheCreationTokens||0;return zE(A.provider,A.model,{inputTokens:Z,outputTokens:X,cachedInputTokens:U,cacheCreationInputTokens:O})??0},[A.provider,A.model,A.totalInputTokens,A.totalOutputTokens,A.totalCachedTokens,A.totalCacheCreationTokens]),a=Z=>Z>=1e6?`${(Z/1e6).toFixed(1)}M`:Z>=1e3?`${(Z/1e3).toFixed(1)}K`:Z.toString(),g=A.currentContextTokens||0,Q=A.sessionType==="branch",B=n?.parent,u=m.useMemo(()=>_E(A.provider,A.model)?.limit?.context,[A.provider,A.model]),E=u?g/u*100:0,c=()=>E>=90?"text-red-600 dark:text-red-400":E>=70?"text-amber-600 dark:text-amber-400":"text-foreground",{data:h}=or(),f=h?.[A.provider]?.authType,{usage:d,isOAuthProvider:D}=Y1(A.provider,f),R=A.provider==="ottorouter";Ii(R?"ottorouter":void 0);const M=uo(Z=>Z.usage.ottorouter),q=m.useRef(null),G=zg(q),T=G>0&&G<640;return o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:q,className:`absolute top-0 left-0 right-0 h-12 border-b border-border bg-background/40 backdrop-blur-xl supports-[backdrop-filter]:bg-background/20 z-10 transition-transform duration-200 ${e?"translate-y-0":"-translate-y-full"}`,children:o.jsxs("div",{className:"h-full px-2.5 flex items-center justify-between gap-3 text-sm",children:[o.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 text-muted-foreground",children:[Q&&o.jsx(Qo,{className:"size-4 flex-shrink-0 text-violet-500"}),o.jsx(ZE,{sessionId:A.id,title:A.title,className:"text-foreground font-medium text-sm"}),r?.shared&&o.jsxs("button",{type:"button",onClick:()=>Io(r.url),className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20 transition-colors text-xs font-medium flex-shrink-0",children:[o.jsx(Xa,{className:"h-3 w-3"}),r.pendingMessages&&r.pendingMessages>0?o.jsxs("span",{className:"flex items-center gap-0.5 text-amber-600 dark:text-amber-400",children:[o.jsx(Xt,{className:"h-2.5 w-2.5"}),r.pendingMessages]}):o.jsx(Gt,{className:"h-2.5 w-2.5 opacity-60"})]}),Q&&B&&o.jsxs(o.Fragment,{children:[!T&&o.jsx("span",{className:"text-muted-foreground",children:"from"}),o.jsxs("button",{type:"button",onClick:()=>s?.(B.id),className:"text-primary hover:underline flex items-center gap-0.5 truncate max-w-32",title:B.title||`Session ${B.id.slice(0,8)}`,children:[o.jsx("span",{className:"truncate",children:B.title||`Session ${B.id.slice(0,8)}`}),o.jsx(dB,{className:"h-3 w-3 flex-shrink-0"})]})]})]}),o.jsxs("div",{className:"flex-shrink-0 flex items-center gap-3 text-muted-foreground",children:[t&&o.jsx(km,{sessionId:A.id}),D&&d&&o.jsx(SQ,{usage:d,provider:A.provider}),R&&M&&o.jsx(SQ,{usage:M,provider:"ottorouter"}),o.jsx("div",{className:"flex items-center gap-2",children:o.jsxs("div",{className:"flex items-center gap-1",title:`Current context window: ${g.toLocaleString()} tokens`,children:[o.jsx("span",{className:"text-xs opacity-70",children:"ctx"}),o.jsx("span",{className:`font-medium ${c()}`,children:a(g)})]})}),i>0&&!T&&o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(hB,{className:"size-3.5"}),o.jsx("span",{className:"text-foreground font-medium",children:i.toFixed(4)})]}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(ro,{provider:A.provider,size:14}),!T&&o.jsx("span",{className:"font-medium text-foreground",children:A.model})]})]})]})}),o.jsx(j1,{})]})}const P1=m.memo(function({pendingTopup:e,onMethodSelected:t,onCancel:s}){const[n,r]=m.useState(!1),[i,a]=m.useState(null),g=Ne(c=>c.openTopupModal),Q=Ne(c=>!!c.subscription?.active),B=async()=>{a("crypto"),r(!0);try{await fA.selectTopupMethod(e.sessionId,"crypto"),t("crypto")}catch(c){ge.error(c instanceof Error?c.message:"Failed to process payment"),r(!1),a(null)}},u=async()=>{a("fiat"),g(),fA.selectTopupMethod(e.sessionId,"fiat").catch(()=>{}),t("fiat")},E=async()=>{r(!0);try{await fA.cancelTopup(e.sessionId),s()}catch(c){ge.error(c instanceof Error?c.message:"Failed to cancel"),r(!1)}};return o.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(yo,{className:"h-4 w-4 text-amber-500 flex-shrink-0"}),o.jsx("span",{className:"font-medium text-foreground text-sm",children:"Insufficient Balance"}),o.jsx("span",{className:"text-amber-600 dark:text-amber-400 font-medium text-sm",children:"payment required"})]}),Q&&o.jsx("p",{className:"ml-6 text-xs text-muted-foreground",children:"GO credits may not apply to this request. Add balance to continue."}),o.jsxs("div",{className:"ml-6 bg-muted/30 rounded-lg p-3 space-y-2 text-sm",children:[o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-muted-foreground",children:"Request cost"}),o.jsxs("span",{className:"font-mono",children:["~$",e.amountUsd.toFixed(4)]})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-muted-foreground",children:"Current balance"}),o.jsxs("span",{className:"font-mono",children:["$",e.currentBalance.toFixed(4)]})]})]}),o.jsxs("div",{className:"ml-6 flex flex-wrap items-center gap-2",children:[o.jsxs("button",{type:"button",onClick:E,disabled:n,title:"Cancel request",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded border border-border bg-background hover:bg-muted transition-colors disabled:opacity-50",children:[o.jsx(et,{className:"w-3 h-3"}),"Cancel"]}),o.jsxs("button",{type:"button",onClick:B,disabled:n,title:"Pay with USDC from your wallet",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded bg-violet-600 text-white hover:bg-violet-700 transition-colors disabled:opacity-50",children:[i==="crypto"&&n?o.jsx(Te,{className:"w-3 h-3 animate-spin"}):o.jsx(tg,{className:"w-3 h-3"}),"Pay with USDC"]}),o.jsxs("button",{type:"button",onClick:u,disabled:n,title:"Top up with card (min $5)",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded border border-violet-500 text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 transition-colors disabled:opacity-50",children:[i==="fiat"&&n?o.jsx(Te,{className:"w-3 h-3 animate-spin"}):o.jsx(zn,{className:"w-3 h-3"}),"Top up with Card",o.jsx("span",{className:"text-[10px] opacity-70",children:"(min $5)"})]})]}),o.jsx("p",{className:"ml-6 text-xs text-muted-foreground",children:i==="crypto"?"Processing USDC payment from your wallet...":i==="fiat"?"Opening checkout...":"Select a payment method to continue your request."})]})}),qn=gt(A=>({pendingTopup:null,isProcessing:!1,selectedMethod:null,setPendingTopup:e=>A({pendingTopup:e,isProcessing:!1,selectedMethod:null}),setProcessing:e=>A({isProcessing:e}),setSelectedMethod:e=>A({selectedMethod:e}),clearPendingTopup:()=>A({pendingTopup:null,isProcessing:!1,selectedMethod:null})})),W1=new Set(["update_todos","update_plan","UpdateTodos","UpdatePlan"]);function z1(A){if(A.contentJson&&typeof A.contentJson=="object")return A.contentJson;try{const e=JSON.parse(A.content);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return null}function V1(A){return A==="pending"||A==="in_progress"||A==="completed"||A==="cancelled"}function _1(A,e){const t=A.toolName??e?.name;return typeof t=="string"?t:null}function Z1(A){const e=A.result,t=e&&typeof e=="object"&&!Array.isArray(e)?e:A,s=t.items;if(!Array.isArray(s))return null;const n=s.flatMap(i=>{if(!i||typeof i!="object"||Array.isArray(i))return[];const a=i;return typeof a.step!="string"||!V1(a.status)?[]:[{step:a.step,status:a.status}]}),r=typeof t.note=="string"?t.note:void 0;return{items:n,note:r}}function X1(A){return A.items.length>0&&A.items.every(e=>e.status==="completed"||e.status==="cancelled")}function $1(A,e,t){const s=A.slice(e+1).find(n=>n.role==="assistant");return!!(s&&t.has(s.id))}function Ay(A,e){let t=!1;for(let s=A.length-1;s>=0;s--){const n=A[s];n?.role==="user"&&!$1(A,s,e)&&(t=!0);const r=n?.parts??[];for(let i=r.length-1;i>=0;i--){const a=r[i];if(a.type!=="tool_result")continue;const g=z1(a),Q=_1(a,g);if(!Q||!W1.has(Q))continue;if(!g)return null;const B=Z1(g);return!B||t&&X1(B)?null:B}}return null}const ey=m.memo(function({messages:e,session:t,sessionId:s,isGenerating:n,compact:r=!1,disableAutoScroll:i=!1,onSelectSession:a}){const g=De(),{preferences:Q}=sr(),B=m.useRef(null),u=m.useRef(null),E=m.useRef(null),c=m.useRef(null),h=zg(c),f=h>0&&h<640?"compact":"normal",[d,D]=m.useState(!0),R=m.useRef(!0),[M,q]=m.useState(!1),G=m.useRef(!1),T=m.useRef(void 0),Z=m.useRef(0),X=m.useRef(void 0),U=m.useRef(!1),O=m.useRef(t?.id),j=m.useRef(e.length),Y=m.useRef(n),x=m.useRef(0),l=m.useRef(0),I=qn(AA=>AA.pendingTopup),y=qn(AA=>AA.clearPendingTopup),b=pc(AA=>AA.setSessionTodos),J=xg(s),H=m.useMemo(()=>new Set(J.queuedMessages.map(AA=>AA.messageId)),[J.queuedMessages]),v=I&&I.sessionId===s;m.useEffect(()=>{s&&b(s,Ay(e,H))},[e,H,s,b]);const K=m.useCallback(()=>{const AA=u.current;if(!AA)return;const{scrollTop:sA,scrollHeight:oA,clientHeight:bA}=AA,GA=oA-sA-bA,lA=oA>x.current,jA=sA<l.current-5;x.current=oA,l.current=sA,GA<100?(R.current=!0,D(!0)):jA?(R.current=!1,D(!1),G.current=!0):!lA&&R.current&&(R.current=!1,D(!1)),(jA||!R.current&&GA>=100)&&(T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{G.current=!1},150));const HA=E.current;if(HA){const ce=HA.getBoundingClientRect(),NA=AA.getBoundingClientRect();q(ce.bottom<NA.top)}},[]);m.useEffect(()=>{if(i)return;const AA=t?.id!==O.current;if(O.current=t?.id,AA&&(U.current=!1),!U.current&&e.length>0){U.current=!0;const sA=u.current;sA&&(sA.scrollTop=sA.scrollHeight)}},[e.length,t?.id,i]),m.useEffect(()=>{if(i)return;const AA=n&&!Y.current,sA=e.length>j.current;Y.current=n,j.current=e.length,AA?(G.current=!1,R.current=!0,D(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const oA=u.current;oA&&(oA.scrollTop=oA.scrollHeight)})})):sA&&!G.current&&!n&&(R.current=!0,D(!0))},[e.length,n,i]),m.useEffect(()=>{if(i)return;const AA=u.current;if(!AA||!d||G.current)return;Z.current=AA.scrollHeight-AA.clientHeight;const sA=()=>{const oA=u.current;if(!oA||G.current)return;const bA=oA.scrollTop,lA=oA.scrollHeight-oA.clientHeight-bA;if(Math.abs(lA)<1){oA.scrollTop=oA.scrollHeight-oA.clientHeight;return}if(Math.abs(lA)<10){oA.scrollTop=oA.scrollHeight-oA.clientHeight;return}oA.scrollTop=bA+lA*.15,X.current=requestAnimationFrame(sA)};X.current&&cancelAnimationFrame(X.current),X.current=requestAnimationFrame(sA)},[e,d]),m.useEffect(()=>()=>{T.current&&clearTimeout(T.current),X.current&&cancelAnimationFrame(X.current)},[]);const C=()=>{G.current=!1,R.current=!0,D(!0);const AA=u.current;AA&&(AA.scrollTop=AA.scrollHeight)},p=m.useMemo(()=>e.filter(AA=>AA.role!=="system"),[e]),L=Q.fullWidthContent?r?"w-full space-y-4":"w-full space-y-6":r?"max-w-3xl mx-auto space-y-4":"max-w-3xl mx-auto space-y-6",S=m.useCallback(AA=>async()=>{if(s&&AA){g.setQueryData(["messages",s],sA=>sA&&sA.map(oA=>{if(oA.id!==AA)return oA;const bA=oA.parts?.filter(GA=>!(GA.type==="error"||GA.type==="tool_call"&&GA.toolName==="finish"))??[];return{...oA,status:"pending",parts:bA,error:null}}));try{await fA.retryMessage(s,AA)}catch(sA){ge.error(sA instanceof Error?sA.message:"Failed to retry")}}},[s,g]),$=m.useCallback(async()=>{if(s)try{await fA.sendMessage(s,{content:"/compact"})}catch(AA){ge.error(AA instanceof Error?AA.message:"Failed to compact")}},[s]);return e.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"No messages yet. Start a conversation below."}):o.jsx("div",{ref:c,className:"absolute inset-0 flex flex-col",children:o.jsxs(pw,{density:f,children:[t&&o.jsx(H1,{session:t,isVisible:M,isGenerating:n,onNavigateToSession:a}),o.jsxs("div",{ref:u,className:"flex-1 overflow-y-auto scrollbar-hide",onScroll:K,children:[o.jsx("div",{ref:E,children:t&&o.jsx(L1,{session:t,onNavigateToSession:a})}),o.jsx("div",{className:f==="compact"?"px-2 pt-3 pb-56":r?"p-4 pb-56":"p-6 pb-64",children:o.jsxs("div",{className:L,children:[p.map((AA,sA)=>{const oA=p[sA-1],bA=p[sA+1],GA=sA===p.length-1;if(AA.role==="user"){const lA=bA&&bA.role==="assistant"?bA:void 0;return o.jsx(Oc,{sessionId:s,message:AA,isFirst:sA===0,nextAssistantMessageId:lA?.id},AA.id)}if(AA.role==="assistant"){const lA=!oA||oA.role!=="assistant",jA=bA&&bA.role==="assistant";return o.jsx(jc,{sessionId:s,message:AA,showHeader:lA,hasNextAssistantMessage:jA,isLastMessage:GA,onBranchCreated:a,onRetry:GA?S(AA.id):void 0,compact:r,onCompact:GA?$:void 0},AA.id)}return null}),v&&I&&o.jsx("div",{className:"py-4",children:o.jsx(P1,{pendingTopup:I,onMethodSelected:()=>y(),onCancel:()=>y()})}),o.jsx("div",{ref:B})]})})]}),!d&&o.jsxs("button",{type:"button",onClick:C,className:"absolute bottom-36 left-1/2 -translate-x-1/2 flex items-center gap-2 px-4 py-2 bg-background border border-border rounded-full shadow-lg hover:bg-muted/50 transition-all text-sm text-foreground z-10",children:[o.jsx(zC,{className:"w-4 h-4"}),o.jsx("span",{children:"Scroll to bottom"})]})]})})});class XE{abortController=null;handlers=new Map;running=!1;async connect(e){this.abortController&&this.abortController.abort(),this.abortController=new AbortController,this.running=!0;const t=!e.includes("localhost")&&!e.includes("127.0.0.1");try{const s=await fetch(e,{method:t?"POST":"GET",headers:{Accept:"text/event-stream"},signal:this.abortController.signal});if(!s.ok){console.error("[SSE] Connection failed:",s.status);return}const n=s.body?.getReader();if(!n){console.error("[SSE] No response body");return}const r=new TextDecoder;let i="";for(;this.running;){const{done:a,value:g}=await n.read();if(a)break;i+=r.decode(g,{stream:!0});let Q=i.indexOf(`
119
+ `)})})]}),g&&o.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[o.jsxs("button",{type:"button",onClick:U,className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md bg-muted hover:bg-muted/80 text-muted-foreground hover:text-foreground transition-colors",title:"Cancel and restore to input",children:[o.jsx(eg,{className:"h-3 w-3"}),"Cancel"]}),o.jsxs("button",{type:"button",onClick:O,className:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-md bg-destructive/10 hover:bg-destructive/20 text-destructive transition-colors",title:"Delete from queue",children:[o.jsx(Ar,{className:"h-3 w-3"}),"Delete"]})]})]})]})}),n&&o.jsxs("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",onClick:()=>r(null),onKeyDown:j=>j.key==="Escape"&&r(null),tabIndex:-1,children:[o.jsx("button",{type:"button",onClick:()=>r(null),className:"absolute top-4 right-4 p-2 rounded-full bg-white/10 hover:bg-white/20 transition-colors",children:o.jsx(et,{className:"w-6 h-6 text-white"})}),o.jsx("img",{src:n,alt:"Expanded attachment",className:"max-w-full max-h-full object-contain rounded-lg",onClick:j=>j.stopPropagation(),onKeyDown:j=>j.key==="Enter"&&j.stopPropagation()})]})]})},(A,e)=>{const t=A.message.parts?.[0],s=e.message.parts?.[0];return A.message.id===e.message.id&&t?.content===s?.content&&t?.contentJson===s?.contentJson&&A.message.createdAt===e.message.createdAt&&A.message.parts?.length===e.message.parts?.length&&A.sessionId===e.sessionId&&A.nextAssistantMessageId===e.nextAssistantMessageId}),Ax={openai:{id:"openai",models:[{id:"chatgpt-image-latest",ownedBy:"openai",label:"chatgpt-image-latest",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-12-16",lastUpdated:"2025-12-16",openWeights:!1,limit:{context:0,output:0}},{id:"gpt-3.5-turbo",ownedBy:"openai",label:"GPT-3.5-turbo",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2021-09-01",releaseDate:"2023-03-01",lastUpdated:"2023-11-06",openWeights:!1,cost:{input:.5,output:1.5,cacheRead:1.25},limit:{context:16385,output:4096}},{id:"gpt-4",ownedBy:"openai",label:"GPT-4",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-11",releaseDate:"2023-11-06",lastUpdated:"2024-04-09",openWeights:!1,cost:{input:30,output:60},limit:{context:8192,output:8192}},{id:"gpt-4-turbo",ownedBy:"openai",label:"GPT-4 Turbo",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-12",releaseDate:"2023-11-06",lastUpdated:"2024-04-09",openWeights:!1,cost:{input:10,output:30},limit:{context:128e3,output:4096}},{id:"gpt-4.1",ownedBy:"openai",label:"GPT-4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:1047576,output:32768}},{id:"gpt-4.1-mini",ownedBy:"openai",label:"GPT-4.1 mini",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.4,output:1.6,cacheRead:.1},limit:{context:1047576,output:32768}},{id:"gpt-4.1-nano",ownedBy:"openai",label:"GPT-4.1 nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.03},limit:{context:1047576,output:32768}},{id:"gpt-4o",ownedBy:"openai",label:"GPT-4o",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-05-13",lastUpdated:"2024-08-06",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-2024-05-13",ownedBy:"openai",label:"GPT-4o (2024-05-13)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-05-13",lastUpdated:"2024-05-13",openWeights:!1,cost:{input:5,output:15},limit:{context:128e3,output:4096}},{id:"gpt-4o-2024-08-06",ownedBy:"openai",label:"GPT-4o (2024-08-06)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-08-06",lastUpdated:"2024-08-06",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-2024-11-20",ownedBy:"openai",label:"GPT-4o (2024-11-20)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-11-20",lastUpdated:"2024-11-20",openWeights:!1,cost:{input:2.5,output:10,cacheRead:1.25},limit:{context:128e3,output:16384}},{id:"gpt-4o-mini",ownedBy:"openai",label:"GPT-4o mini",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-07-18",lastUpdated:"2024-07-18",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.08},limit:{context:128e3,output:16384}},{id:"gpt-5",ownedBy:"openai",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5-chat-latest",ownedBy:"openai",label:"GPT-5 Chat (latest)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"gpt-5-codex",ownedBy:"openai",label:"GPT-5-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5-mini",ownedBy:"openai",label:"GPT-5 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3}},{id:"gpt-5-nano",ownedBy:"openai",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.05,output:.4,cacheRead:.005},limit:{context:4e5,output:128e3}},{id:"gpt-5-pro",ownedBy:"openai",label:"GPT-5 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-10-06",lastUpdated:"2025-10-06",openWeights:!1,cost:{input:15,output:120},limit:{context:4e5,output:272e3}},{id:"gpt-5.1",ownedBy:"openai",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.13},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-chat-latest",ownedBy:"openai",label:"GPT-5.1 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:128e3,output:16384}},{id:"gpt-5.1-codex",ownedBy:"openai",label:"GPT-5.1 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-max",ownedBy:"openai",label:"GPT-5.1 Codex Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-mini",ownedBy:"openai",label:"GPT-5.1 Codex mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3}},{id:"gpt-5.2",ownedBy:"openai",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"gpt-5.2-chat-latest",ownedBy:"openai",label:"GPT-5.2 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:16384}},{id:"gpt-5.2-codex",ownedBy:"openai",label:"GPT-5.2 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"gpt-5.2-pro",ownedBy:"openai",label:"GPT-5.2 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:21,output:168},limit:{context:4e5,output:128e3}},{id:"gpt-5.3-chat-latest",ownedBy:"openai",label:"GPT-5.3 Chat (latest)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-03-03",lastUpdated:"2026-03-03",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:16384}},{id:"gpt-5.3-codex",ownedBy:"openai",label:"GPT-5.3 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"gpt-5.3-codex-spark",ownedBy:"openai",label:"GPT-5.3 Codex Spark",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:32e3}},{id:"gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:2.5,output:15,cacheRead:.25},limit:{context:105e4,output:128e3}},{id:"gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.75,output:4.5,cacheRead:.075},limit:{context:4e5,output:128e3}},{id:"gpt-5.4-nano",ownedBy:"openai",label:"GPT-5.4 nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.2,output:1.25,cacheRead:.02},limit:{context:4e5,output:128e3}},{id:"gpt-5.4-pro",ownedBy:"openai",label:"GPT-5.4 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:30,output:180},limit:{context:105e4,output:128e3}},{id:"gpt-5.5",ownedBy:"openai",label:"GPT-5.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-23",lastUpdated:"2026-04-23",openWeights:!1,cost:{input:5,output:30,cacheRead:.5},limit:{context:105e4,output:128e3}},{id:"gpt-5.5-pro",ownedBy:"openai",label:"GPT-5.5 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-23",lastUpdated:"2026-04-23",openWeights:!1,cost:{input:30,output:180},limit:{context:105e4,output:128e3}},{id:"gpt-image-1",ownedBy:"openai",label:"gpt-image-1",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-04-24",lastUpdated:"2025-04-24",openWeights:!1,limit:{context:0,output:0}},{id:"gpt-image-1-mini",ownedBy:"openai",label:"gpt-image-1-mini",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-09-26",lastUpdated:"2025-09-26",openWeights:!1,limit:{context:0,output:0}},{id:"gpt-image-1.5",ownedBy:"openai",label:"gpt-image-1.5",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!1,releaseDate:"2025-11-25",lastUpdated:"2025-11-25",openWeights:!1,limit:{context:0,output:0}},{id:"o1",ownedBy:"openai",label:"o1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2023-09",releaseDate:"2024-12-05",lastUpdated:"2024-12-05",openWeights:!1,cost:{input:15,output:60,cacheRead:7.5},limit:{context:2e5,output:1e5}},{id:"o1-mini",ownedBy:"openai",label:"o1-mini",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2023-09",releaseDate:"2024-09-12",lastUpdated:"2024-09-12",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.55},limit:{context:128e3,output:65536}},{id:"o1-preview",ownedBy:"openai",label:"o1-preview",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-09",releaseDate:"2024-09-12",lastUpdated:"2024-09-12",openWeights:!1,cost:{input:15,output:60,cacheRead:7.5},limit:{context:128e3,output:32768}},{id:"o1-pro",ownedBy:"openai",label:"o1-pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2023-09",releaseDate:"2025-03-19",lastUpdated:"2025-03-19",openWeights:!1,cost:{input:150,output:600},limit:{context:2e5,output:1e5}},{id:"o3",ownedBy:"openai",label:"o3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:2e5,output:1e5}},{id:"o3-deep-research",ownedBy:"openai",label:"o3-deep-research",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2024-06-26",lastUpdated:"2024-06-26",openWeights:!1,cost:{input:10,output:40,cacheRead:2.5},limit:{context:2e5,output:1e5}},{id:"o3-mini",ownedBy:"openai",label:"o3-mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-05",releaseDate:"2024-12-20",lastUpdated:"2025-01-29",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.55},limit:{context:2e5,output:1e5}},{id:"o3-pro",ownedBy:"openai",label:"o3-pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-06-10",lastUpdated:"2025-06-10",openWeights:!1,cost:{input:20,output:80},limit:{context:2e5,output:1e5}},{id:"o4-mini",ownedBy:"openai",label:"o4-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.28},limit:{context:2e5,output:1e5}},{id:"o4-mini-deep-research",ownedBy:"openai",label:"o4-mini-deep-research",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05",releaseDate:"2024-06-26",lastUpdated:"2024-06-26",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:2e5,output:1e5}},{id:"text-embedding-3-large",ownedBy:"openai",label:"text-embedding-3-large",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2024-01",releaseDate:"2024-01-25",lastUpdated:"2024-01-25",openWeights:!1,cost:{input:.13,output:0},limit:{context:8191,output:3072}},{id:"text-embedding-3-small",ownedBy:"openai",label:"text-embedding-3-small",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2024-01",releaseDate:"2024-01-25",lastUpdated:"2024-01-25",openWeights:!1,cost:{input:.02,output:0},limit:{context:8191,output:1536}},{id:"text-embedding-ada-002",ownedBy:"openai",label:"text-embedding-ada-002",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2022-12",releaseDate:"2022-12-15",lastUpdated:"2022-12-15",openWeights:!1,cost:{input:.1,output:0},limit:{context:8192,output:1536}}],label:"OpenAI",env:["OPENAI_API_KEY"],npm:"@ai-sdk/openai",doc:"https://platform.openai.com/docs/models"},anthropic:{id:"anthropic",models:[{id:"claude-3-5-haiku-20241022",ownedBy:"anthropic",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"claude-3-5-haiku-latest",ownedBy:"anthropic",label:"Claude Haiku 3.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"claude-3-5-sonnet-20240620",ownedBy:"anthropic",label:"Claude Sonnet 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04-30",releaseDate:"2024-06-20",lastUpdated:"2024-06-20",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:8192}},{id:"claude-3-5-sonnet-20241022",ownedBy:"anthropic",label:"Claude Sonnet 3.5 v2",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04-30",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:8192}},{id:"claude-3-7-sonnet-20250219",ownedBy:"anthropic",label:"Claude Sonnet 3.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-31",releaseDate:"2025-02-19",lastUpdated:"2025-02-19",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-3-haiku-20240307",ownedBy:"anthropic",label:"Claude Haiku 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-03-13",lastUpdated:"2024-03-13",openWeights:!1,cost:{input:.25,output:1.25,cacheRead:.03,cacheWrite:.3},limit:{context:2e5,output:4096}},{id:"claude-3-opus-20240229",ownedBy:"anthropic",label:"Claude Opus 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-02-29",lastUpdated:"2024-02-29",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:4096}},{id:"claude-3-sonnet-20240229",ownedBy:"anthropic",label:"Claude Sonnet 3",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-08-31",releaseDate:"2024-03-04",lastUpdated:"2024-03-04",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:.3},limit:{context:2e5,output:4096}},{id:"claude-haiku-4-5",ownedBy:"anthropic",label:"Claude Haiku 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"claude-haiku-4-5-20251001",ownedBy:"anthropic",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"claude-opus-4-0",ownedBy:"anthropic",label:"Claude Opus 4 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-1",ownedBy:"anthropic",label:"Claude Opus 4.1 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-1-20250805",ownedBy:"anthropic",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-20250514",ownedBy:"anthropic",label:"Claude Opus 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"claude-opus-4-5",ownedBy:"anthropic",label:"Claude Opus 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3}},{id:"claude-opus-4-5-20251101",ownedBy:"anthropic",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-01",lastUpdated:"2025-11-01",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3}},{id:"claude-opus-4-6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-03-13",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"claude-opus-4-7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"claude-sonnet-4-0",ownedBy:"anthropic",label:"Claude Sonnet 4 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-20250514",ownedBy:"anthropic",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-5",ownedBy:"anthropic",label:"Claude Sonnet 4.5 (latest)",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-5-20250929",ownedBy:"anthropic",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"claude-sonnet-4-6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-03-13",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3}}],label:"Anthropic",env:["ANTHROPIC_API_KEY"],npm:"@ai-sdk/anthropic",doc:"https://docs.anthropic.com/en/docs/about-claude/models"},google:{id:"google",models:[{id:"gemini-1.5-flash",ownedBy:"google",label:"Gemini 1.5 Flash",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-05-14",lastUpdated:"2024-05-14",openWeights:!1,cost:{input:.075,output:.3,cacheRead:.01875},limit:{context:1e6,output:8192}},{id:"gemini-1.5-flash-8b",ownedBy:"google",label:"Gemini 1.5 Flash-8B",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-10-03",lastUpdated:"2024-10-03",openWeights:!1,cost:{input:.0375,output:.15,cacheRead:.01},limit:{context:1e6,output:8192}},{id:"gemini-1.5-pro",ownedBy:"google",label:"Gemini 1.5 Pro",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2024-02-15",lastUpdated:"2024-02-15",openWeights:!1,cost:{input:1.25,output:5,cacheRead:.3125},limit:{context:1e6,output:8192}},{id:"gemini-2.0-flash",ownedBy:"google",label:"Gemini 2.0 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:8192}},{id:"gemini-2.0-flash-lite",ownedBy:"google",label:"Gemini 2.0 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.075,output:.3},limit:{context:1048576,output:8192}},{id:"gemini-2.5-flash",ownedBy:"google",label:"Gemini 2.5 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.03},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-image",ownedBy:"google",label:"Gemini 2.5 Flash Image",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.3,output:30,cacheRead:.075},limit:{context:32768,output:32768}},{id:"gemini-2.5-flash-image-preview",ownedBy:"google",label:"Gemini 2.5 Flash Image (Preview)",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.3,output:30,cacheRead:.075},limit:{context:32768,output:32768}},{id:"gemini-2.5-flash-lite",ownedBy:"google",label:"Gemini 2.5 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-lite-preview-06-17",ownedBy:"google",label:"Gemini 2.5 Flash Lite Preview 06-17",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-lite-preview-09-2025",ownedBy:"google",label:"Gemini 2.5 Flash Lite Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-04-17",ownedBy:"google",label:"Gemini 2.5 Flash Preview 04-17",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-04-17",lastUpdated:"2025-04-17",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-05-20",ownedBy:"google",label:"Gemini 2.5 Flash Preview 05-20",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-09-2025",ownedBy:"google",label:"Gemini 2.5 Flash Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.075},limit:{context:1048576,output:65536}},{id:"gemini-2.5-flash-preview-tts",ownedBy:"google",label:"Gemini 2.5 Flash Preview TTS",modalities:{input:["text"],output:["audio"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-05-01",lastUpdated:"2025-05-01",openWeights:!1,cost:{input:.5,output:10},limit:{context:8e3,output:16e3}},{id:"gemini-2.5-pro",ownedBy:"google",label:"Gemini 2.5 Pro",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-05-06",ownedBy:"google",label:"Gemini 2.5 Pro Preview 05-06",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-06",lastUpdated:"2025-05-06",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-06-05",ownedBy:"google",label:"Gemini 2.5 Pro Preview 06-05",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-05",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"gemini-2.5-pro-preview-tts",ownedBy:"google",label:"Gemini 2.5 Pro Preview TTS",modalities:{input:["text"],output:["audio"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-05-01",lastUpdated:"2025-05-01",openWeights:!1,cost:{input:1,output:20},limit:{context:8e3,output:16e3}},{id:"gemini-3-flash-preview",ownedBy:"google",label:"Gemini 3 Flash Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536}},{id:"gemini-3-pro-preview",ownedBy:"google",label:"Gemini 3 Pro Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11-18",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1e6,output:64e3}},{id:"gemini-3.1-flash-image-preview",ownedBy:"google",label:"Gemini 3.1 Flash Image (Preview)",modalities:{input:["text","image","pdf"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-26",lastUpdated:"2026-02-26",openWeights:!1,cost:{input:.25,output:60},limit:{context:131072,output:32768}},{id:"gemini-3.1-flash-lite-preview",ownedBy:"google",label:"Gemini 3.1 Flash Lite Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-03-03",lastUpdated:"2026-03-03",openWeights:!1,cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:1},limit:{context:1048576,output:65536}},{id:"gemini-3.1-pro-preview",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536}},{id:"gemini-3.1-pro-preview-customtools",ownedBy:"google",label:"Gemini 3.1 Pro Preview Custom Tools",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536}},{id:"gemini-embedding-001",ownedBy:"google",label:"Gemini Embedding 001",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!1,knowledge:"2025-05",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!1,cost:{input:.15,output:0},limit:{context:2048,output:3072}},{id:"gemini-flash-latest",ownedBy:"google",label:"Gemini Flash Latest",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.075},limit:{context:1048576,output:65536}},{id:"gemini-flash-lite-latest",ownedBy:"google",label:"Gemini Flash-Lite Latest",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"gemini-live-2.5-flash",ownedBy:"google",label:"Gemini Live 2.5 Flash",modalities:{input:["text","image","audio","video"],output:["text","audio"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-01",lastUpdated:"2025-09-01",openWeights:!1,cost:{input:.5,output:2},limit:{context:128e3,output:8e3}},{id:"gemini-live-2.5-flash-preview-native-audio",ownedBy:"google",label:"Gemini Live 2.5 Flash Preview Native Audio",modalities:{input:["text","audio","video"],output:["text","audio"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-09-18",openWeights:!1,cost:{input:.5,output:2},limit:{context:131072,output:65536}},{id:"gemma-3-12b-it",ownedBy:"google",label:"Gemma 3 12B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"gemma-3-27b-it",ownedBy:"google",label:"Gemma 3 27B",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-12",lastUpdated:"2025-03-12",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:8192}},{id:"gemma-3-4b-it",ownedBy:"google",label:"Gemma 3 4B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"gemma-3n-e2b-it",ownedBy:"google",label:"Gemma 3n 2B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:2e3}},{id:"gemma-3n-e4b-it",ownedBy:"google",label:"Gemma 3n 4B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:2e3}},{id:"gemma-4-26b-a4b-it",ownedBy:"google",label:"Gemma 4 26B",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,limit:{context:256e3,output:8192}},{id:"gemma-4-31b-it",ownedBy:"google",label:"Gemma 4 31B",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,limit:{context:256e3,output:8192}}],label:"Google",env:["GOOGLE_GENERATIVE_AI_API_KEY","GEMINI_API_KEY"],npm:"@ai-sdk/google",doc:"https://ai.google.dev/gemini-api/docs/pricing"},openrouter:{id:"openrouter",models:[{id:"anthropic/claude-3.5-haiku",ownedBy:"anthropic",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192}},{id:"anthropic/claude-3.7-sonnet",ownedBy:"anthropic",label:"Claude Sonnet 3.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-01",releaseDate:"2025-02-19",lastUpdated:"2025-02-19",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:128e3}},{id:"anthropic/claude-haiku-4.5",ownedBy:"anthropic",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3}},{id:"anthropic/claude-opus-4",ownedBy:"anthropic",label:"Claude Opus 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-opus-4.1",ownedBy:"anthropic",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-opus-4.5",ownedBy:"anthropic",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-30",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:32e3}},{id:"anthropic/claude-opus-4.6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"anthropic/claude-opus-4.7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3}},{id:"anthropic/claude-sonnet-4",ownedBy:"anthropic",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:2e5,output:64e3}},{id:"anthropic/claude-sonnet-4.5",ownedBy:"anthropic",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3}},{id:"anthropic/claude-sonnet-4.6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:128e3}},{id:"arcee-ai/trinity-large-preview:free",label:"Trinity Large Preview",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-28",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"arcee-ai/trinity-large-thinking",label:"Trinity Large Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-01",lastUpdated:"2026-04-03",openWeights:!0,cost:{input:.22,output:.85},limit:{context:262144,output:8e4}},{id:"black-forest-labs/flux.2-flex",label:"FLUX.2 Flex",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-11-25",lastUpdated:"2026-01-31",openWeights:!1,cost:{input:0,output:0},limit:{context:67344,output:67344}},{id:"black-forest-labs/flux.2-klein-4b",label:"FLUX.2 Klein 4B",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-14",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:40960,output:40960}},{id:"black-forest-labs/flux.2-max",label:"FLUX.2 Max",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-16",lastUpdated:"2026-01-31",openWeights:!1,cost:{input:0,output:0},limit:{context:46864,output:46864}},{id:"black-forest-labs/flux.2-pro",label:"FLUX.2 Pro",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-11-25",lastUpdated:"2026-01-31",openWeights:!1,cost:{input:0,output:0},limit:{context:46864,output:46864}},{id:"bytedance-seed/seedream-4.5",label:"Seedream 4.5",modalities:{input:["image","text"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-23",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:4096,output:4096}},{id:"cognitivecomputations/dolphin-mistral-24b-venice-edition:free",label:"Uncensored (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-07-09",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:32768}},{id:"deepseek/deepseek-chat-v3-0324",label:"DeepSeek V3 0324",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-24",lastUpdated:"2025-03-24",openWeights:!0,cost:{input:0,output:0},limit:{context:16384,output:8192}},{id:"deepseek/deepseek-chat-v3.1",label:"DeepSeek-V3.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-08-21",lastUpdated:"2025-08-21",openWeights:!0,cost:{input:.2,output:.8},limit:{context:163840,output:163840}},{id:"deepseek/deepseek-r1",label:"DeepSeek: R1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2025-01-20",lastUpdated:"2025-01-20",openWeights:!0,cost:{input:.7,output:2.5},limit:{context:64e3,output:16e3}},{id:"deepseek/deepseek-r1-distill-llama-70b",label:"DeepSeek R1 Distill Llama 70B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-01-23",lastUpdated:"2025-01-23",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"deepseek/deepseek-v3.1-terminus",label:"DeepSeek V3.1 Terminus",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-22",lastUpdated:"2025-09-22",openWeights:!0,cost:{input:.27,output:1},limit:{context:131072,output:65536}},{id:"deepseek/deepseek-v3.1-terminus:exacto",label:"DeepSeek V3.1 Terminus (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-22",lastUpdated:"2025-09-22",openWeights:!0,cost:{input:.27,output:1},limit:{context:131072,output:65536}},{id:"deepseek/deepseek-v3.2",label:"DeepSeek V3.2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2025-12-01",lastUpdated:"2025-12-01",openWeights:!0,cost:{input:.28,output:.4},limit:{context:163840,output:65536}},{id:"deepseek/deepseek-v3.2-speciale",label:"DeepSeek V3.2 Speciale",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-07",releaseDate:"2025-12-01",lastUpdated:"2025-12-01",openWeights:!0,cost:{input:.27,output:.41},limit:{context:163840,output:65536}},{id:"deepseek/deepseek-v4-flash",label:"DeepSeek V4 Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!0,cost:{input:.14,output:.28,cacheRead:.028},limit:{context:1048576,output:393216}},{id:"deepseek/deepseek-v4-pro",label:"DeepSeek V4 Pro",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!0,cost:{input:1.74,output:3.48,cacheRead:.145},limit:{context:1048576,output:393216}},{id:"google/gemini-2.0-flash-001",ownedBy:"google",label:"Gemini 2.0 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2024-12-11",lastUpdated:"2024-12-11",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:8192}},{id:"google/gemini-2.5-flash",ownedBy:"google",label:"Gemini 2.5 Flash",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-07-17",lastUpdated:"2025-07-17",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.0375},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-lite",ownedBy:"google",label:"Gemini 2.5 Flash Lite",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-lite-preview-09-2025",ownedBy:"google",label:"Gemini 2.5 Flash Lite Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.1,output:.4,cacheRead:.025},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-flash-preview-09-2025",ownedBy:"google",label:"Gemini 2.5 Flash Preview 09-25",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-09-25",lastUpdated:"2025-09-25",openWeights:!1,cost:{input:.3,output:2.5,cacheRead:.031},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro",ownedBy:"google",label:"Gemini 2.5 Pro",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro-preview-05-06",ownedBy:"google",label:"Gemini 2.5 Pro Preview 05-06",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-05-06",lastUpdated:"2025-05-06",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"google/gemini-2.5-pro-preview-06-05",ownedBy:"google",label:"Gemini 2.5 Pro Preview 06-05",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-06-05",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.31},limit:{context:1048576,output:65536}},{id:"google/gemini-3-flash-preview",ownedBy:"google",label:"Gemini 3 Flash Preview",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536}},{id:"google/gemini-3-pro-preview",ownedBy:"google",label:"Gemini 3 Pro Preview",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11",openWeights:!1,cost:{input:2,output:12},limit:{context:105e4,output:66e3}},{id:"google/gemini-3.1-flash-image-preview",ownedBy:"google",label:"Gemini 3.1 Flash Image Preview (Nano Banana 2)",modalities:{input:["text","image"],output:["text","image"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-26",lastUpdated:"2026-02-26",openWeights:!1,cost:{input:.5,output:3},limit:{context:65536,output:65536}},{id:"google/gemini-3.1-flash-lite-preview",ownedBy:"google",label:"Gemini 3.1 Flash Lite Preview",modalities:{input:["text","image","video","pdf","audio"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-03",lastUpdated:"2026-03-03",openWeights:!1,cost:{input:.25,output:1.5,cacheRead:.025,cacheWrite:.083},limit:{context:1048576,output:65536}},{id:"google/gemini-3.1-pro-preview",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12},limit:{context:1048576,output:65536}},{id:"google/gemini-3.1-pro-preview-customtools",ownedBy:"google",label:"Gemini 3.1 Pro Preview Custom Tools",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12},limit:{context:1048576,output:65536}},{id:"google/gemma-2-9b-it",ownedBy:"google",label:"Gemma 2 9B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-06",releaseDate:"2024-06-28",lastUpdated:"2024-06-28",openWeights:!0,cost:{input:.03,output:.09},limit:{context:8192,output:8192}},{id:"google/gemma-3-12b-it",ownedBy:"google",label:"Gemma 3 12B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:.03,output:.1},limit:{context:131072,output:131072}},{id:"google/gemma-3-12b-it:free",ownedBy:"google",label:"Gemma 3 12B (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"google/gemma-3-27b-it",ownedBy:"google",label:"Gemma 3 27B",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-12",lastUpdated:"2025-03-12",openWeights:!0,cost:{input:.04,output:.15},limit:{context:96e3,output:96e3}},{id:"google/gemma-3-27b-it:free",ownedBy:"google",label:"Gemma 3 27B (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-12",lastUpdated:"2025-03-12",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:8192}},{id:"google/gemma-3-4b-it",ownedBy:"google",label:"Gemma 3 4B",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:.01703,output:.06815},limit:{context:96e3,output:96e3}},{id:"google/gemma-3-4b-it:free",ownedBy:"google",label:"Gemma 3 4B (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-13",lastUpdated:"2025-03-13",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"google/gemma-3n-e2b-it:free",ownedBy:"google",label:"Gemma 3n 2B (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:2e3}},{id:"google/gemma-3n-e4b-it",ownedBy:"google",label:"Gemma 3n 4B",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:.02,output:.04},limit:{context:32768,output:32768}},{id:"google/gemma-3n-e4b-it:free",ownedBy:"google",label:"Gemma 3n 4B (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-05-20",lastUpdated:"2025-05-20",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:2e3}},{id:"google/gemma-4-26b-a4b-it",ownedBy:"google",label:"Gemma 4 26B A4B",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-03",lastUpdated:"2026-04-03",openWeights:!0,cost:{input:.13,output:.4},limit:{context:262144,output:262144}},{id:"google/gemma-4-26b-a4b-it:free",ownedBy:"google",label:"Gemma 4 26B A4B (free)",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-03",lastUpdated:"2026-04-03",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:32768}},{id:"google/gemma-4-31b-it",ownedBy:"google",label:"Gemma 4 31B",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,cost:{input:.14,output:.4},limit:{context:262144,output:262144}},{id:"google/gemma-4-31b-it:free",ownedBy:"google",label:"Gemma 4 31B (free)",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:32768}},{id:"inception/mercury-2",label:"Mercury 2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-04",lastUpdated:"2026-03-04",openWeights:!1,cost:{input:.25,output:.75,cacheRead:.025},limit:{context:128e3,output:5e4}},{id:"inception/mercury-edit-2",label:"Mercury Edit 2",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-30",lastUpdated:"2026-03-30",openWeights:!1,cost:{input:.25,output:.75,cacheRead:.025},limit:{context:128e3,output:8192}},{id:"liquid/lfm-2.5-1.2b-instruct:free",label:"LFM2.5-1.2B-Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-20",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:32768}},{id:"liquid/lfm-2.5-1.2b-thinking:free",label:"LFM2.5-1.2B-Thinking (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-20",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:32768}},{id:"meta-llama/llama-3.2-11b-vision-instruct",label:"Llama 3.2 11B Vision Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-12",releaseDate:"2024-09-25",lastUpdated:"2024-09-25",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:8192}},{id:"meta-llama/llama-3.2-3b-instruct:free",label:"Llama 3.2 3B Instruct (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-12",releaseDate:"2024-09-25",lastUpdated:"2024-09-25",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"meta-llama/llama-3.3-70b-instruct:free",label:"Llama 3.3 70B Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-12",releaseDate:"2024-12-06",lastUpdated:"2024-12-06",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"minimax/minimax-01",ownedBy:"minimax",label:"MiniMax-01",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2025-01-15",lastUpdated:"2025-01-15",openWeights:!0,cost:{input:.2,output:1.1},limit:{context:1e6,output:1e6}},{id:"minimax/minimax-m1",ownedBy:"minimax",label:"MiniMax M1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-06-17",lastUpdated:"2025-06-17",openWeights:!0,cost:{input:.4,output:2.2},limit:{context:1e6,output:4e4}},{id:"minimax/minimax-m2",ownedBy:"minimax",label:"MiniMax M2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-10-23",lastUpdated:"2025-10-23",openWeights:!0,cost:{input:.28,output:1.15,cacheRead:.28,cacheWrite:1.15},limit:{context:196600,output:118e3}},{id:"minimax/minimax-m2.1",ownedBy:"minimax",label:"MiniMax M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:204800,output:131072}},{id:"minimax/minimax-m2.5",ownedBy:"minimax",label:"MiniMax M2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.03},limit:{context:204800,output:131072}},{id:"minimax/minimax-m2.5:free",ownedBy:"minimax",label:"MiniMax M2.5 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:0,output:0},limit:{context:204800,output:131072}},{id:"minimax/minimax-m2.7",ownedBy:"minimax",label:"MiniMax M2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}},{id:"mistralai/codestral-2508",label:"Codestral 2508",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-08-01",lastUpdated:"2025-08-01",openWeights:!0,cost:{input:.3,output:.9},limit:{context:256e3,output:256e3}},{id:"mistralai/devstral-2512",label:"Devstral 2 2512",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-12",releaseDate:"2025-09-12",lastUpdated:"2025-09-12",openWeights:!0,cost:{input:.15,output:.6},limit:{context:262144,output:262144}},{id:"mistralai/devstral-medium-2507",label:"Devstral Medium",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-07-10",lastUpdated:"2025-07-10",openWeights:!0,cost:{input:.4,output:2},limit:{context:131072,output:131072}},{id:"mistralai/devstral-small-2505",label:"Devstral Small",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-07",lastUpdated:"2025-05-07",openWeights:!0,cost:{input:.06,output:.12},limit:{context:128e3,output:128e3}},{id:"mistralai/devstral-small-2507",label:"Devstral Small 1.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-05",releaseDate:"2025-07-10",lastUpdated:"2025-07-10",openWeights:!0,cost:{input:.1,output:.3},limit:{context:131072,output:131072}},{id:"mistralai/mistral-medium-3",label:"Mistral Medium 3",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-05",releaseDate:"2025-05-07",lastUpdated:"2025-05-07",openWeights:!1,cost:{input:.4,output:2},limit:{context:131072,output:131072}},{id:"mistralai/mistral-medium-3.1",label:"Mistral Medium 3.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-05",releaseDate:"2025-08-12",lastUpdated:"2025-08-12",openWeights:!1,cost:{input:.4,output:2},limit:{context:262144,output:262144}},{id:"mistralai/mistral-small-2603",label:"Mistral Small 4",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-06",releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!0,cost:{input:.15,output:.6},limit:{context:262144,output:262144}},{id:"mistralai/mistral-small-3.1-24b-instruct",label:"Mistral Small 3.1 24B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-03-17",lastUpdated:"2025-03-17",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:8192}},{id:"mistralai/mistral-small-3.2-24b-instruct",label:"Mistral Small 3.2 24B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-06-20",lastUpdated:"2025-06-20",openWeights:!0,cost:{input:0,output:0},limit:{context:96e3,output:8192}},{id:"moonshotai/kimi-k2",ownedBy:"moonshot",label:"Kimi K2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-07-11",lastUpdated:"2025-07-11",openWeights:!0,cost:{input:.55,output:2.2},limit:{context:131072,output:32768}},{id:"moonshotai/kimi-k2-0905",ownedBy:"moonshot",label:"Kimi K2 Instruct 0905",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5},limit:{context:262144,output:16384}},{id:"moonshotai/kimi-k2-0905:exacto",ownedBy:"moonshot",label:"Kimi K2 Instruct 0905 (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5},limit:{context:262144,output:16384}},{id:"moonshotai/kimi-k2-thinking",ownedBy:"moonshot",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144}},{id:"moonshotai/kimi-k2.5",ownedBy:"moonshot",label:"Kimi K2.5",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:.6,output:3,cacheRead:.1},limit:{context:262144,output:262144}},{id:"moonshotai/kimi-k2.6",ownedBy:"moonshot",label:"Kimi K2.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-20",lastUpdated:"2026-04-20",openWeights:!0,cost:{input:.95,output:4,cacheRead:.16},limit:{context:262144,output:262144}},{id:"nousresearch/hermes-3-llama-3.1-405b:free",label:"Hermes 3 405B Instruct (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-12",releaseDate:"2024-08-16",lastUpdated:"2024-08-16",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}},{id:"nousresearch/hermes-4-405b",label:"Hermes 4 405B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-12",releaseDate:"2025-08-25",lastUpdated:"2025-08-25",openWeights:!0,cost:{input:1,output:3},limit:{context:131072,output:131072}},{id:"nousresearch/hermes-4-70b",label:"Hermes 4 70B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-12",releaseDate:"2025-08-25",lastUpdated:"2025-08-25",openWeights:!0,cost:{input:.13,output:.4},limit:{context:131072,output:131072}},{id:"nvidia/nemotron-3-nano-30b-a3b:free",label:"Nemotron 3 Nano 30B A3B (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-11",releaseDate:"2025-12-14",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:256e3,output:256e3}},{id:"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free",label:"Nemotron 3 Nano Omni (free)",modalities:{input:["text","image","video","audio"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-28",lastUpdated:"2026-04-28",openWeights:!0,cost:{input:0,output:0},limit:{context:256e3,output:65536}},{id:"nvidia/nemotron-3-super-120b-a12b",label:"Nemotron 3 Super",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-04",releaseDate:"2026-03-11",lastUpdated:"2026-03-11",openWeights:!0,cost:{input:.1,output:.5},limit:{context:262144,output:262144}},{id:"nvidia/nemotron-3-super-120b-a12b:free",label:"Nemotron 3 Super (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-04",releaseDate:"2026-03-11",lastUpdated:"2026-03-11",openWeights:!0,cost:{input:0,output:0},limit:{context:262144,output:262144}},{id:"nvidia/nemotron-nano-12b-v2-vl:free",label:"Nemotron Nano 12B 2 VL (free)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-11",releaseDate:"2025-10-28",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:128e3}},{id:"nvidia/nemotron-nano-9b-v2",label:"nvidia-nemotron-nano-9b-v2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-09",releaseDate:"2025-08-18",lastUpdated:"2025-08-18",openWeights:!0,cost:{input:.04,output:.16},limit:{context:131072,output:131072}},{id:"nvidia/nemotron-nano-9b-v2:free",label:"Nemotron Nano 9B V2 (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-09",releaseDate:"2025-09-05",lastUpdated:"2025-08-18",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:128e3}},{id:"openai/gpt-4.1",ownedBy:"openai",label:"GPT-4.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:2,output:8,cacheRead:.5},limit:{context:1047576,output:32768}},{id:"openai/gpt-4.1-mini",ownedBy:"openai",label:"GPT-4.1 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:.4,output:1.6,cacheRead:.1},limit:{context:1047576,output:32768}},{id:"openai/gpt-4o-mini",ownedBy:"openai",label:"GPT-4o-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2024-07-18",lastUpdated:"2024-07-18",openWeights:!1,cost:{input:.15,output:.6,cacheRead:.08},limit:{context:128e3,output:16384}},{id:"openai/gpt-5",ownedBy:"openai",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-chat",ownedBy:"openai",label:"GPT-5 Chat (latest)",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.25,output:10},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-codex",ownedBy:"openai",label:"GPT-5 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-image",ownedBy:"openai",label:"GPT-5 Image",modalities:{input:["text","image","pdf"],output:["text","image"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-10-14",lastUpdated:"2025-10-14",openWeights:!1,cost:{input:5,output:10,cacheRead:1.25},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-mini",ownedBy:"openai",label:"GPT-5 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.25,output:2},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-nano",ownedBy:"openai",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10-01",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:.05,output:.4},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5-pro",ownedBy:"openai",label:"GPT-5 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-10-06",lastUpdated:"2025-10-06",openWeights:!1,cost:{input:15,output:120},limit:{context:4e5,output:272e3}},{id:"openai/gpt-5.1",ownedBy:"openai",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-chat",ownedBy:"openai",label:"GPT-5.1 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:128e3,output:16384}},{id:"openai/gpt-5.1-codex",ownedBy:"openai",label:"GPT-5.1-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-codex-max",ownedBy:"openai",label:"GPT-5.1-Codex-Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.1,output:9,cacheRead:.11},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.1-codex-mini",ownedBy:"openai",label:"GPT-5.1-Codex-Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:1e5}},{id:"openai/gpt-5.2",ownedBy:"openai",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.2-chat",ownedBy:"openai",label:"GPT-5.2 Chat",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:16384}},{id:"openai/gpt-5.2-codex",ownedBy:"openai",label:"GPT-5.2-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-01-14",lastUpdated:"2026-01-14",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.2-pro",ownedBy:"openai",label:"GPT-5.2 Pro",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:21,output:168},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.3-codex",ownedBy:"openai",label:"GPT-5.3-Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-24",lastUpdated:"2026-02-24",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:2.5,output:15,cacheRead:.25},limit:{context:105e4,output:128e3}},{id:"openai/gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 Mini",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.75,output:4.5,cacheRead:.075},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.4-nano",ownedBy:"openai",label:"GPT-5.4 Nano",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.2,output:1.25,cacheRead:.02},limit:{context:4e5,output:128e3}},{id:"openai/gpt-5.4-pro",ownedBy:"openai",label:"GPT-5.4 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:30,output:180,cacheRead:30},limit:{context:105e4,output:128e3}},{id:"openai/gpt-5.5",ownedBy:"openai",label:"GPT-5.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-23",lastUpdated:"2026-04-23",openWeights:!1,cost:{input:5,output:30,cacheRead:.5},limit:{context:105e4,output:128e3}},{id:"openai/gpt-5.5-pro",ownedBy:"openai",label:"GPT-5.5 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-23",lastUpdated:"2026-04-23",openWeights:!1,cost:{input:30,output:180},limit:{context:105e4,output:128e3}},{id:"openai/gpt-oss-120b",ownedBy:"openai",label:"GPT OSS 120B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.072,output:.28},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-120b:exacto",ownedBy:"openai",label:"GPT OSS 120B (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.05,output:.24},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-120b:free",ownedBy:"openai",label:"gpt-oss-120b (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-20b",ownedBy:"openai",label:"GPT OSS 20B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!0,cost:{input:.05,output:.2},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-20b:free",ownedBy:"openai",label:"gpt-oss-20b (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-08-05",lastUpdated:"2026-01-31",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:32768}},{id:"openai/gpt-oss-safeguard-20b",ownedBy:"openai",label:"GPT OSS Safeguard 20B",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-10-29",lastUpdated:"2025-10-29",openWeights:!1,cost:{input:.075,output:.3},limit:{context:131072,output:65536}},{id:"openai/o4-mini",ownedBy:"openai",label:"o4 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-04-16",lastUpdated:"2025-04-16",openWeights:!1,cost:{input:1.1,output:4.4,cacheRead:.28},limit:{context:2e5,output:1e5}},{id:"openrouter/elephant-alpha",label:"Elephant (free)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-13",lastUpdated:"2026-04-13",openWeights:!1,cost:{input:0,output:0},limit:{context:262144,output:32768}},{id:"openrouter/free",label:"Free Models Router",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-02-01",lastUpdated:"2026-02-01",openWeights:!1,cost:{input:0,output:0},limit:{context:2e5,output:8e3}},{id:"openrouter/owl-alpha",label:"Owl Alpha",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-28",lastUpdated:"2026-04-30",openWeights:!1,cost:{input:0,output:0},limit:{context:1048756,output:262144}},{id:"openrouter/pareto-code",label:"Pareto Code Router",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-21",lastUpdated:"2026-04-21",openWeights:!1,limit:{context:2e5,output:2e5}},{id:"poolside/laguna-m.1:free",label:"Laguna M.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-28",lastUpdated:"2026-04-28",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:8192}},{id:"poolside/laguna-xs.2:free",label:"Laguna XS.2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-28",lastUpdated:"2026-04-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:8192}},{id:"prime-intellect/intellect-3",ownedBy:"zai",label:"Intellect 3",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-01-15",lastUpdated:"2025-01-15",openWeights:!0,cost:{input:.2,output:1.1},limit:{context:131072,output:8192}},{id:"qwen/qwen-2.5-coder-32b-instruct",label:"Qwen2.5 Coder 32B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2024-11-11",lastUpdated:"2024-11-11",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"qwen/qwen-3.6-27b",label:"Qwen3.6 27B",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-04-22",lastUpdated:"2026-04-22",openWeights:!0,cost:{input:.195,output:1.56},limit:{context:262144,output:81920}},{id:"qwen/qwen2.5-vl-72b-instruct",label:"Qwen2.5 VL 72B Instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-02-01",lastUpdated:"2025-02-01",openWeights:!0,cost:{input:0,output:0},limit:{context:32768,output:8192}},{id:"qwen/qwen3-235b-a22b-07-25",label:"Qwen3 235B A22B Instruct 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-04-28",lastUpdated:"2025-07-21",openWeights:!0,cost:{input:.15,output:.85},limit:{context:262144,output:131072}},{id:"qwen/qwen3-235b-a22b-thinking-2507",label:"Qwen3 235B A22B Thinking 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-25",lastUpdated:"2025-07-25",openWeights:!0,cost:{input:.078,output:.312},limit:{context:262144,output:81920}},{id:"qwen/qwen3-30b-a3b-instruct-2507",label:"Qwen3 30B A3B Instruct 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-29",lastUpdated:"2025-07-29",openWeights:!0,cost:{input:.2,output:.8},limit:{context:262e3,output:262e3}},{id:"qwen/qwen3-30b-a3b-thinking-2507",label:"Qwen3 30B A3B Thinking 2507",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-29",lastUpdated:"2025-07-29",openWeights:!0,cost:{input:.2,output:.8},limit:{context:262e3,output:262e3}},{id:"qwen/qwen3-coder",label:"Qwen3 Coder",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:262144,output:66536}},{id:"qwen/qwen3-coder-30b-a3b-instruct",label:"Qwen3 Coder 30B A3B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-31",lastUpdated:"2025-07-31",openWeights:!0,cost:{input:.07,output:.27},limit:{context:16e4,output:65536}},{id:"qwen/qwen3-coder-flash",label:"Qwen3 Coder Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!1,cost:{input:.3,output:1.5},limit:{context:128e3,output:66536}},{id:"qwen/qwen3-coder:exacto",label:"Qwen3 Coder (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.38,output:1.53},limit:{context:131072,output:32768}},{id:"qwen/qwen3-max",label:"Qwen3 Max",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!1,cost:{input:1.2,output:6},limit:{context:262144,output:32768}},{id:"qwen/qwen3-next-80b-a3b-instruct",label:"Qwen3 Next 80B A3B Instruct",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-11",lastUpdated:"2025-09-11",openWeights:!0,cost:{input:.14,output:1.4},limit:{context:262144,output:262144}},{id:"qwen/qwen3-next-80b-a3b-thinking",label:"Qwen3 Next 80B A3B Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-11",lastUpdated:"2025-09-11",openWeights:!0,cost:{input:.14,output:1.4},limit:{context:262144,output:262144}},{id:"qwen/qwen3.5-397b-a17b",label:"Qwen3.5 397B A17B",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-16",lastUpdated:"2026-02-16",openWeights:!0,cost:{input:.6,output:3.6},limit:{context:262144,output:65536}},{id:"qwen/qwen3.5-flash-02-23",label:"Qwen: Qwen3.5-Flash",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-02-25",lastUpdated:"2026-02-25",openWeights:!1,cost:{input:.065,output:.26},limit:{context:1e6,output:65536}},{id:"qwen/qwen3.5-plus-02-15",label:"Qwen3.5 Plus 2026-02-15",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-16",lastUpdated:"2026-02-16",openWeights:!1,cost:{input:.4,output:2.4},limit:{context:1e6,output:65536}},{id:"qwen/qwen3.6-plus",label:"Qwen3.6 Plus",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!1,cost:{input:.325,output:1.95},limit:{context:1e6,output:65536}},{id:"sourceful/riverflow-v2-fast-preview",label:"Riverflow V2 Fast Preview",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-08",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"sourceful/riverflow-v2-max-preview",label:"Riverflow V2 Max Preview",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-08",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"sourceful/riverflow-v2-standard-preview",label:"Riverflow V2 Standard Preview",modalities:{input:["text","image"],output:["image"]},toolCall:!1,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2025-12-08",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:8192,output:8192}},{id:"stepfun/step-3.5-flash",label:"Step 3.5 Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-01-29",lastUpdated:"2026-01-29",openWeights:!0,cost:{input:.1,output:.3,cacheRead:.02},limit:{context:256e3,output:256e3}},{id:"x-ai/grok-3",ownedBy:"xai",label:"Grok 3",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-beta",ownedBy:"xai",label:"Grok 3 Beta",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-mini",ownedBy:"xai",label:"Grok 3 Mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:.5},limit:{context:131072,output:8192}},{id:"x-ai/grok-3-mini-beta",ownedBy:"xai",label:"Grok 3 Mini Beta",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075,cacheWrite:.5},limit:{context:131072,output:8192}},{id:"x-ai/grok-4",ownedBy:"xai",label:"Grok 4",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!1,cost:{input:3,output:15,cacheRead:.75,cacheWrite:15},limit:{context:256e3,output:64e3}},{id:"x-ai/grok-4-fast",ownedBy:"xai",label:"Grok 4 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-08-19",lastUpdated:"2025-08-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:.05},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-4.1-fast",ownedBy:"xai",label:"Grok 4.1 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-11-19",lastUpdated:"2025-11-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05,cacheWrite:.05},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-4.20-beta",ownedBy:"xai",label:"Grok 4.20 Beta",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-12",lastUpdated:"2026-03-12",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-4.20-multi-agent-beta",ownedBy:"xai",label:"Grok 4.20 Multi - Agent Beta",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-12",lastUpdated:"2026-03-12",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"x-ai/grok-4.3",ownedBy:"xai",label:"Grok 4.3",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-05-01",lastUpdated:"2026-05-01",openWeights:!1,cost:{input:1.25,output:2.5,cacheRead:.2},limit:{context:1e6,output:1e6}},{id:"x-ai/grok-code-fast-1",ownedBy:"xai",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-08",releaseDate:"2025-08-26",lastUpdated:"2025-08-26",openWeights:!1,cost:{input:.2,output:1.5,cacheRead:.02},limit:{context:256e3,output:1e4}},{id:"xiaomi/mimo-v2-flash",label:"Xiaomi: MiMo-V2-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-12-01",releaseDate:"2025-12-16",lastUpdated:"2026-02-04",openWeights:!0,cost:{input:.1,output:.3,cacheRead:.01},limit:{context:262144,output:65536}},{id:"xiaomi/mimo-v2-omni",label:"Xiaomi: MiMo-V2-Omni",modalities:{input:["text","image","audio","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!1,cost:{input:.4,output:2,cacheRead:.08},limit:{context:262144,output:131072}},{id:"xiaomi/mimo-v2-pro",label:"Xiaomi: MiMo-V2-Pro",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!1,cost:{input:1,output:3,cacheRead:.2},limit:{context:1048576,output:131072}},{id:"xiaomi/mimo-v2.5",label:"Xiaomi: MiMo-V2.5",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-04-22",lastUpdated:"2026-04-22",openWeights:!0,cost:{input:.4,output:2,cacheRead:.08},limit:{context:1048576,output:131072}},{id:"xiaomi/mimo-v2.5-pro",label:"Xiaomi: MiMo-V2.5-Pro",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-04-22",lastUpdated:"2026-04-22",openWeights:!0,cost:{input:1,output:3,cacheRead:.2},limit:{context:1048576,output:131072}},{id:"z-ai/glm-4.5",ownedBy:"zai",label:"GLM 4.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.6,output:2.2},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5-air",ownedBy:"zai",label:"GLM 4.5 Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.2,output:1.1},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5-air:free",ownedBy:"zai",label:"GLM 4.5 Air (free)",modalities:{input:["text"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0},limit:{context:128e3,output:96e3}},{id:"z-ai/glm-4.5v",ownedBy:"zai",label:"GLM 4.5V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-08-11",lastUpdated:"2025-08-11",openWeights:!0,cost:{input:.6,output:1.8},limit:{context:64e3,output:16384}},{id:"z-ai/glm-4.6",ownedBy:"zai",label:"GLM 4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-09",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11},limit:{context:2e5,output:128e3}},{id:"z-ai/glm-4.6:exacto",ownedBy:"zai",label:"GLM 4.6 (exacto)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-09",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:1.9,cacheRead:.11},limit:{context:2e5,output:128e3}},{id:"z-ai/glm-4.7",ownedBy:"zai",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11},limit:{context:204800,output:131072}},{id:"z-ai/glm-4.7-flash",ownedBy:"zai",label:"GLM-4.7-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-01-19",lastUpdated:"2026-01-19",openWeights:!0,cost:{input:.07,output:.4},limit:{context:2e5,output:65535}},{id:"z-ai/glm-5",ownedBy:"zai",label:"GLM-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:1,output:3.2,cacheRead:.2},limit:{context:202752,output:131e3}},{id:"z-ai/glm-5-turbo",ownedBy:"zai",label:"GLM-5-Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!1,cost:{input:.96,output:3.2,cacheRead:.192,cacheWrite:0},limit:{context:202752,output:131072}},{id:"z-ai/glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-04-07",lastUpdated:"2026-04-07",openWeights:!0,cost:{input:1.4,output:4.4,cacheRead:.26},limit:{context:202752,output:131072}}],label:"OpenRouter",env:["OPENROUTER_API_KEY"],npm:"@openrouter/ai-sdk-provider",api:"https://openrouter.ai/api/v1",doc:"https://openrouter.ai/models"},opencode:{id:"opencode",models:[{id:"big-pickle",label:"Big Pickle",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-10-17",lastUpdated:"2025-10-17",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:128e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-3-5-haiku",ownedBy:"anthropic",label:"Claude Haiku 3.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-07-31",releaseDate:"2024-10-22",lastUpdated:"2024-10-22",openWeights:!1,cost:{input:.8,output:4,cacheRead:.08,cacheWrite:1},limit:{context:2e5,output:8192},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-haiku-4-5",ownedBy:"anthropic",label:"Claude Haiku 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:1,output:5,cacheRead:.1,cacheWrite:1.25},limit:{context:2e5,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-1",ownedBy:"anthropic",label:"Claude Opus 4.1",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75},limit:{context:2e5,output:32e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-5",ownedBy:"anthropic",label:"Claude Opus 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-24",lastUpdated:"2025-11-24",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:2e5,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-03-13",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-opus-4-7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:5,output:25,cacheRead:.5,cacheWrite:6.25},limit:{context:1e6,output:128e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-sonnet-4",ownedBy:"anthropic",label:"Claude Sonnet 4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-sonnet-4-5",ownedBy:"anthropic",label:"Claude Sonnet 4.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"claude-sonnet-4-6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.3,cacheWrite:3.75},limit:{context:1e6,output:64e3},provider:{npm:"@ai-sdk/anthropic"}},{id:"gemini-3-flash",ownedBy:"google",label:"Gemini 3 Flash",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05},limit:{context:1048576,output:65536},provider:{npm:"@ai-sdk/google"}},{id:"gemini-3-pro",ownedBy:"google",label:"Gemini 3 Pro",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11-18",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536},provider:{npm:"@ai-sdk/google"}},{id:"gemini-3.1-pro",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image","video","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:2,output:12,cacheRead:.2},limit:{context:1048576,output:65536},provider:{npm:"@ai-sdk/google"}},{id:"glm-4.6",ownedBy:"zai",label:"GLM-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"glm-4.7",ownedBy:"zai",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"glm-4.7-free",ownedBy:"zai",label:"GLM-4.7 Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072}},{id:"glm-5",ownedBy:"zai",label:"GLM-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,cost:{input:1,output:3.2,cacheRead:.2},limit:{context:204800,output:131072}},{id:"glm-5-free",ownedBy:"zai",label:"GLM-5 Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-04-07",lastUpdated:"2026-04-07",openWeights:!0,cost:{input:1.4,output:4.4,cacheRead:.26},limit:{context:204800,output:131072}},{id:"gpt-5",ownedBy:"openai",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5-codex",ownedBy:"openai",label:"GPT-5 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-09-15",lastUpdated:"2025-09-15",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5-nano",ownedBy:"openai",label:"GPT-5 Nano",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:0,output:0,cacheRead:0},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1",ownedBy:"openai",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex",ownedBy:"openai",label:"GPT-5.1 Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.07,output:8.5,cacheRead:.107},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex-max",ownedBy:"openai",label:"GPT-5.1 Codex Max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:1.25,output:10,cacheRead:.125},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.1-codex-mini",ownedBy:"openai",label:"GPT-5.1 Codex Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:.25,output:2,cacheRead:.025},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.2",ownedBy:"openai",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.2-codex",ownedBy:"openai",label:"GPT-5.2 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-01-14",lastUpdated:"2026-01-14",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.3-codex",ownedBy:"openai",label:"GPT-5.3 Codex",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-24",lastUpdated:"2026-02-24",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.3-codex-spark",ownedBy:"openai",label:"GPT-5.3 Codex Spark",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!1,cost:{input:1.75,output:14,cacheRead:.175},limit:{context:128e3,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:2.5,output:15,cacheRead:.25},limit:{context:105e4,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 Mini",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.75,output:4.5,cacheRead:.075},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4-nano",ownedBy:"openai",label:"GPT-5.4 Nano",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:.2,output:1.25,cacheRead:.02},limit:{context:4e5,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.4-pro",ownedBy:"openai",label:"GPT-5.4 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:30,output:180,cacheRead:30},limit:{context:105e4,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.5",ownedBy:"openai",label:"GPT-5.5",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-23",lastUpdated:"2026-04-23",openWeights:!1,cost:{input:5,output:30,cacheRead:.5},limit:{context:105e4,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"gpt-5.5-pro",ownedBy:"openai",label:"GPT-5.5 Pro",modalities:{input:["text","image","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!1,cost:{input:30,output:180,cacheRead:30},limit:{context:105e4,output:128e3},provider:{npm:"@ai-sdk/openai"}},{id:"grok-code",ownedBy:"xai",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2025-08-20",lastUpdated:"2025-08-20",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:256e3,output:256e3}},{id:"hy3-preview-free",label:"Hy3 preview Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-04-20",lastUpdated:"2026-04-20",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:256e3,output:64e3}},{id:"kimi-k2",ownedBy:"moonshot",label:"Kimi K2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.4,output:2.5,cacheRead:.4},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking",ownedBy:"moonshot",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.4,output:2.5,cacheRead:.4},limit:{context:262144,output:262144}},{id:"kimi-k2.5",ownedBy:"moonshot",label:"Kimi K2.5",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:.6,output:3,cacheRead:.08},limit:{context:262144,output:65536}},{id:"kimi-k2.5-free",ownedBy:"moonshot",label:"Kimi K2.5 Free",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:262144,output:262144}},{id:"kimi-k2.6",ownedBy:"moonshot",label:"Kimi K2.6",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2026-04-21",lastUpdated:"2026-04-21",openWeights:!0,cost:{input:.95,output:4,cacheRead:.16},limit:{context:262144,output:65536}},{id:"ling-2.6-flash-free",label:"Ling 2.6 Flash Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-04-21",lastUpdated:"2026-04-21",openWeights:!0,cost:{input:0,output:0},limit:{context:262100,output:32800}},{id:"mimo-v2-flash-free",label:"MiMo V2 Flash Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-12",releaseDate:"2025-12-16",lastUpdated:"2025-12-16",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:262144,output:65536}},{id:"mimo-v2-omni-free",label:"MiMo V2 Omni Free",modalities:{input:["text","image","audio","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:262144,output:64e3}},{id:"mimo-v2-pro-free",label:"MiMo V2 Pro Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:1048576,output:64e3}},{id:"minimax-m2.1",ownedBy:"minimax",label:"MiniMax M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.1},limit:{context:204800,output:131072}},{id:"minimax-m2.1-free",ownedBy:"minimax",label:"MiniMax M2.1 Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072},provider:{npm:"@ai-sdk/anthropic"}},{id:"minimax-m2.5",ownedBy:"minimax",label:"MiniMax M2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06},limit:{context:204800,output:131072}},{id:"minimax-m2.5-free",ownedBy:"minimax",label:"MiniMax M2.5 Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:131072},provider:{npm:"@ai-sdk/anthropic"}},{id:"minimax-m2.7",ownedBy:"minimax",label:"MiniMax M2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-01",releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06},limit:{context:204800,output:131072}},{id:"nemotron-3-super-free",label:"Nemotron 3 Super Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2026-02",releaseDate:"2026-03-11",lastUpdated:"2026-03-11",openWeights:!0,cost:{input:0,output:0,cacheRead:0},limit:{context:204800,output:128e3}},{id:"qwen3-coder",label:"Qwen3 Coder",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-23",lastUpdated:"2025-07-23",openWeights:!0,cost:{input:.45,output:1.8},limit:{context:262144,output:65536}},{id:"qwen3.5-plus",label:"Qwen3.5 Plus",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-02-16",lastUpdated:"2026-02-16",openWeights:!1,cost:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25},limit:{context:262144,output:65536},provider:{npm:"@ai-sdk/anthropic"}},{id:"qwen3.6-plus",label:"Qwen3.6 Plus",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2026-04-02",lastUpdated:"2026-04-02",openWeights:!1,cost:{input:.5,output:3,cacheRead:.05,cacheWrite:.625},limit:{context:262144,output:65536},provider:{npm:"@ai-sdk/anthropic"}},{id:"qwen3.6-plus-free",label:"Qwen3.6 Plus Free",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-12",releaseDate:"2026-03-30",lastUpdated:"2026-03-30",openWeights:!1,cost:{input:0,output:0,cacheRead:0},limit:{context:1048576,output:64e3}},{id:"trinity-large-preview-free",label:"Trinity Large Preview",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2025-06",releaseDate:"2026-01-28",lastUpdated:"2026-01-28",openWeights:!0,cost:{input:0,output:0},limit:{context:131072,output:131072}}],label:"OpenCode Zen",env:["OPENCODE_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://opencode.ai/zen/v1",doc:"https://opencode.ai/docs/zen"},xai:{id:"xai",models:[{id:"grok-2",ownedBy:"xai",label:"Grok 2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2024-08-20",lastUpdated:"2024-08-20",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:131072,output:8192}},{id:"grok-2-1212",ownedBy:"xai",label:"Grok 2 (1212)",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2024-12-12",lastUpdated:"2024-12-12",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:131072,output:8192}},{id:"grok-2-latest",ownedBy:"xai",label:"Grok 2 Latest",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2024-08-20",lastUpdated:"2024-12-12",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:131072,output:8192}},{id:"grok-2-vision",ownedBy:"xai",label:"Grok 2 Vision",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-08",releaseDate:"2024-08-20",lastUpdated:"2024-08-20",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:8192,output:4096}},{id:"grok-2-vision-1212",ownedBy:"xai",label:"Grok 2 Vision (1212)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-08",releaseDate:"2024-08-20",lastUpdated:"2024-12-12",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:8192,output:4096}},{id:"grok-2-vision-latest",ownedBy:"xai",label:"Grok 2 Vision Latest",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-08",releaseDate:"2024-08-20",lastUpdated:"2024-12-12",openWeights:!1,cost:{input:2,output:10,cacheRead:2},limit:{context:8192,output:4096}},{id:"grok-3",ownedBy:"xai",label:"Grok 3",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75},limit:{context:131072,output:8192}},{id:"grok-3-fast",ownedBy:"xai",label:"Grok 3 Fast",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:5,output:25,cacheRead:1.25},limit:{context:131072,output:8192}},{id:"grok-3-fast-latest",ownedBy:"xai",label:"Grok 3 Fast Latest",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:5,output:25,cacheRead:1.25},limit:{context:131072,output:8192}},{id:"grok-3-latest",ownedBy:"xai",label:"Grok 3 Latest",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:3,output:15,cacheRead:.75},limit:{context:131072,output:8192}},{id:"grok-3-mini",ownedBy:"xai",label:"Grok 3 Mini",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075},limit:{context:131072,output:8192}},{id:"grok-3-mini-fast",ownedBy:"xai",label:"Grok 3 Mini Fast",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.6,output:4,cacheRead:.15},limit:{context:131072,output:8192}},{id:"grok-3-mini-fast-latest",ownedBy:"xai",label:"Grok 3 Mini Fast Latest",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.6,output:4,cacheRead:.15},limit:{context:131072,output:8192}},{id:"grok-3-mini-latest",ownedBy:"xai",label:"Grok 3 Mini Latest",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-11",releaseDate:"2025-02-17",lastUpdated:"2025-02-17",openWeights:!1,cost:{input:.3,output:.5,cacheRead:.075},limit:{context:131072,output:8192}},{id:"grok-4",ownedBy:"xai",label:"Grok 4",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-07",releaseDate:"2025-07-09",lastUpdated:"2025-07-09",openWeights:!1,cost:{input:3,output:15,cacheRead:.75},limit:{context:256e3,output:64e3}},{id:"grok-4-1-fast",ownedBy:"xai",label:"Grok 4.1 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07",releaseDate:"2025-11-19",lastUpdated:"2025-11-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05},limit:{context:2e6,output:3e4}},{id:"grok-4-1-fast-non-reasoning",ownedBy:"xai",label:"Grok 4.1 Fast (Non-Reasoning)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-07",releaseDate:"2025-11-19",lastUpdated:"2025-11-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05},limit:{context:2e6,output:3e4}},{id:"grok-4-fast",ownedBy:"xai",label:"Grok 4 Fast",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-19",lastUpdated:"2025-09-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05},limit:{context:2e6,output:3e4}},{id:"grok-4-fast-non-reasoning",ownedBy:"xai",label:"Grok 4 Fast (Non-Reasoning)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-07",releaseDate:"2025-09-19",lastUpdated:"2025-09-19",openWeights:!1,cost:{input:.2,output:.5,cacheRead:.05},limit:{context:2e6,output:3e4}},{id:"grok-4.20-0309-non-reasoning",ownedBy:"xai",label:"Grok 4.20 (Non-Reasoning)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,releaseDate:"2026-03-09",lastUpdated:"2026-03-09",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"grok-4.20-0309-reasoning",ownedBy:"xai",label:"Grok 4.20 (Reasoning)",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-09",lastUpdated:"2026-03-09",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"grok-4.20-multi-agent-0309",ownedBy:"xai",label:"Grok 4.20 Multi-Agent",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-03-09",lastUpdated:"2026-03-09",openWeights:!1,cost:{input:2,output:6,cacheRead:.2},limit:{context:2e6,output:3e4}},{id:"grok-4.3",ownedBy:"xai",label:"Grok 4.3",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-05-01",lastUpdated:"2026-05-01",openWeights:!1,cost:{input:1.25,output:2.5,cacheRead:.2},limit:{context:1e6,output:3e4}},{id:"grok-beta",ownedBy:"xai",label:"Grok Beta",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2024-11-01",lastUpdated:"2024-11-01",openWeights:!1,cost:{input:5,output:15,cacheRead:5},limit:{context:131072,output:4096}},{id:"grok-code-fast-1",ownedBy:"xai",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2023-10",releaseDate:"2025-08-28",lastUpdated:"2025-08-28",openWeights:!1,cost:{input:.2,output:1.5,cacheRead:.02},limit:{context:256e3,output:1e4}},{id:"grok-vision-beta",ownedBy:"xai",label:"Grok Vision Beta",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-08",releaseDate:"2024-11-01",lastUpdated:"2024-11-01",openWeights:!1,cost:{input:5,output:15,cacheRead:5},limit:{context:8192,output:4096}}],label:"xAI",env:["XAI_API_KEY"],npm:"@ai-sdk/xai",doc:"https://docs.x.ai/docs/models"},zai:{id:"zai",models:[{id:"glm-4.5",ownedBy:"zai",label:"GLM-4.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-air",ownedBy:"zai",label:"GLM-4.5-Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:.2,output:1.1,cacheRead:.03,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5-flash",ownedBy:"zai",label:"GLM-4.5-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.5v",ownedBy:"zai",label:"GLM-4.5V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-08-11",lastUpdated:"2025-08-11",openWeights:!0,cost:{input:.6,output:1.8},limit:{context:64e3,output:16384}},{id:"glm-4.6",ownedBy:"zai",label:"GLM-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-09-30",lastUpdated:"2025-09-30",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-4.6v",ownedBy:"zai",label:"GLM-4.6V",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-08",lastUpdated:"2025-12-08",openWeights:!0,cost:{input:.3,output:.9},limit:{context:128e3,output:32768}},{id:"glm-4.7",ownedBy:"zai",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:.6,output:2.2,cacheRead:.11,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-4.7-flash",ownedBy:"zai",label:"GLM-4.7-Flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-01-19",lastUpdated:"2026-01-19",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-4.7-flashx",ownedBy:"zai",label:"GLM-4.7-FlashX",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2026-01-19",lastUpdated:"2026-01-19",openWeights:!0,cost:{input:.07,output:.4,cacheRead:.01,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5",ownedBy:"zai",label:"GLM-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,cost:{input:1,output:3.2,cacheRead:.2,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-5-turbo",ownedBy:"zai",label:"GLM-5-Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!1,cost:{input:1.2,output:4,cacheRead:.24,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-27",lastUpdated:"2026-03-27",openWeights:!1,cost:{input:1.4,output:4.4,cacheRead:.26,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5v-turbo",ownedBy:"zai",label:"GLM-5V-Turbo",modalities:{input:["text","image","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-01",lastUpdated:"2026-04-01",openWeights:!1,cost:{input:1.2,output:4,cacheRead:.24,cacheWrite:0},limit:{context:2e5,output:131072}}],label:"Z.AI",env:["ZHIPU_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.z.ai/api/paas/v4",doc:"https://docs.z.ai/guides/overview/pricing"},"zai-coding":{id:"zai-coding",models:[{id:"glm-4.5-air",ownedBy:"zai",label:"GLM-4.5-Air",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-07-28",lastUpdated:"2025-07-28",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:131072,output:98304}},{id:"glm-4.7",ownedBy:"zai",label:"GLM-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-04",releaseDate:"2025-12-22",lastUpdated:"2025-12-22",openWeights:!0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:204800,output:131072}},{id:"glm-5-turbo",ownedBy:"zai",label:"GLM-5-Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-16",lastUpdated:"2026-03-16",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"GLM-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-27",lastUpdated:"2026-03-27",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}},{id:"glm-5v-turbo",ownedBy:"zai",label:"GLM-5V-Turbo",modalities:{input:["text","image","video","pdf"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,releaseDate:"2026-04-01",lastUpdated:"2026-04-01",openWeights:!1,cost:{input:0,output:0,cacheRead:0,cacheWrite:0},limit:{context:2e5,output:131072}}],label:"Z.AI Coding Plan",env:["ZHIPU_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.z.ai/api/coding/paas/v4",doc:"https://docs.z.ai/devpack/overview"},moonshot:{id:"moonshot",models:[{id:"kimi-k2-0711-preview",ownedBy:"moonshot",label:"Kimi K2 0711",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-07-14",lastUpdated:"2025-07-14",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:131072,output:16384}},{id:"kimi-k2-0905-preview",ownedBy:"moonshot",label:"Kimi K2 0905",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking",ownedBy:"moonshot",label:"Kimi K2 Thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:.6,output:2.5,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-thinking-turbo",ownedBy:"moonshot",label:"Kimi K2 Thinking Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2025-11-06",openWeights:!0,cost:{input:1.15,output:8,cacheRead:.15},limit:{context:262144,output:262144}},{id:"kimi-k2-turbo-preview",ownedBy:"moonshot",label:"Kimi K2 Turbo",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,temperature:!0,knowledge:"2024-10",releaseDate:"2025-09-05",lastUpdated:"2025-09-05",openWeights:!0,cost:{input:2.4,output:10,cacheRead:.6},limit:{context:262144,output:262144}},{id:"kimi-k2.5",ownedBy:"moonshot",label:"Kimi K2.5",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-01",releaseDate:"2026-01",lastUpdated:"2026-01",openWeights:!0,cost:{input:.6,output:3,cacheRead:.1},limit:{context:262144,output:262144}},{id:"kimi-k2.6",ownedBy:"moonshot",label:"Kimi K2.6",modalities:{input:["text","image","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-04-21",lastUpdated:"2026-04-21",openWeights:!0,cost:{input:.95,output:4,cacheRead:.16},limit:{context:262144,output:262144}}],label:"Moonshot AI",env:["MOONSHOT_API_KEY"],npm:"@ai-sdk/openai-compatible",api:"https://api.moonshot.ai/v1",doc:"https://platform.moonshot.ai/docs/api/chat"},minimax:{id:"minimax",models:[{id:"MiniMax-M2",ownedBy:"minimax",label:"MiniMax-M2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-10-27",lastUpdated:"2025-10-27",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:196608,output:128e3}},{id:"MiniMax-M2.1",ownedBy:"minimax",label:"MiniMax-M2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2025-12-23",lastUpdated:"2025-12-23",openWeights:!0,cost:{input:.3,output:1.2},limit:{context:204800,output:131072}},{id:"MiniMax-M2.5",ownedBy:"minimax",label:"MiniMax-M2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.03,cacheWrite:.375},limit:{context:204800,output:131072}},{id:"MiniMax-M2.5-highspeed",ownedBy:"minimax",label:"MiniMax-M2.5-highspeed",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-02-13",lastUpdated:"2026-02-13",openWeights:!0,cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}},{id:"MiniMax-M2.7",ownedBy:"minimax",label:"MiniMax-M2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.3,output:1.2,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}},{id:"MiniMax-M2.7-highspeed",ownedBy:"minimax",label:"MiniMax-M2.7-highspeed",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,cost:{input:.6,output:2.4,cacheRead:.06,cacheWrite:.375},limit:{context:204800,output:131072}}],label:"MiniMax (minimax.io)",env:["MINIMAX_API_KEY"],npm:"@ai-sdk/anthropic",api:"https://api.minimax.io/anthropic/v1",doc:"https://platform.minimax.io/docs/guides/quickstart"},copilot:{id:"copilot",models:[{id:"claude-haiku-4.5",ownedBy:"anthropic",label:"Claude Haiku 4.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",releaseDate:"2025-10-15",lastUpdated:"2025-10-15",openWeights:!1,cost:{input:0,output:0},limit:{context:144e3,output:32e3}},{id:"claude-opus-4.5",ownedBy:"anthropic",label:"Claude Opus 4.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-11-24",lastUpdated:"2025-08-01",openWeights:!1,cost:{input:0,output:0},limit:{context:16e4,output:32e3}},{id:"claude-opus-4.6",ownedBy:"anthropic",label:"Claude Opus 4.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",releaseDate:"2026-02-05",lastUpdated:"2026-02-05",openWeights:!1,cost:{input:0,output:0},limit:{context:144e3,output:64e3}},{id:"claude-opus-4.7",ownedBy:"anthropic",label:"Claude Opus 4.7",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",releaseDate:"2026-04-16",lastUpdated:"2026-04-16",openWeights:!1,cost:{input:0,output:0},limit:{context:144e3,output:64e3}},{id:"claude-opus-41",ownedBy:"anthropic",label:"Claude Opus 4.1",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-08-05",lastUpdated:"2025-08-05",openWeights:!1,cost:{input:0,output:0},limit:{context:8e4,output:16e3}},{id:"claude-sonnet-4",ownedBy:"anthropic",label:"Claude Sonnet 4",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-05-22",lastUpdated:"2025-05-22",openWeights:!1,cost:{input:0,output:0},limit:{context:216e3,output:16e3}},{id:"claude-sonnet-4.5",ownedBy:"anthropic",label:"Claude Sonnet 4.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",releaseDate:"2025-09-29",lastUpdated:"2025-09-29",openWeights:!1,cost:{input:0,output:0},limit:{context:144e3,output:32e3}},{id:"claude-sonnet-4.6",ownedBy:"anthropic",label:"Claude Sonnet 4.6",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",releaseDate:"2026-02-17",lastUpdated:"2026-02-17",openWeights:!1,cost:{input:0,output:0},limit:{context:2e5,output:32e3}},{id:"gemini-2.5-pro",ownedBy:"google",label:"Gemini 2.5 Pro",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-03-20",lastUpdated:"2025-06-05",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}},{id:"gemini-3-flash-preview",ownedBy:"google",label:"Gemini 3 Flash",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2025-12-17",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}},{id:"gemini-3-pro-preview",ownedBy:"google",label:"Gemini 3 Pro Preview",modalities:{input:["text","image","audio","video"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2025-11-18",lastUpdated:"2025-11-18",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}},{id:"gemini-3.1-pro-preview",ownedBy:"google",label:"Gemini 3.1 Pro Preview",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2025-01",releaseDate:"2026-02-19",lastUpdated:"2026-02-19",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}},{id:"gpt-4.1",ownedBy:"openai",label:"GPT-4.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2024-04",releaseDate:"2025-04-14",lastUpdated:"2025-04-14",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:16384}},{id:"gpt-4o",ownedBy:"openai",label:"GPT-4o",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,temperature:!0,knowledge:"2023-09",releaseDate:"2024-05-13",lastUpdated:"2024-05-13",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:4096}},{id:"gpt-5",ownedBy:"openai",label:"GPT-5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-10",releaseDate:"2025-08-07",lastUpdated:"2025-08-07",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:128e3}},{id:"gpt-5-mini",ownedBy:"openai",label:"GPT-5-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!0,knowledge:"2024-06",releaseDate:"2025-08-13",lastUpdated:"2025-08-13",openWeights:!1,cost:{input:0,output:0},limit:{context:264e3,output:64e3}},{id:"gpt-5.1",ownedBy:"openai",label:"GPT-5.1",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:0,output:0},limit:{context:264e3,output:64e3}},{id:"gpt-5.1-codex",ownedBy:"openai",label:"GPT-5.1-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-max",ownedBy:"openai",label:"GPT-5.1-Codex-max",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-12-04",lastUpdated:"2025-12-04",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.1-codex-mini",ownedBy:"openai",label:"GPT-5.1-Codex-mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",releaseDate:"2025-11-13",lastUpdated:"2025-11-13",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.2",ownedBy:"openai",label:"GPT-5.2",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:0,output:0},limit:{context:264e3,output:64e3}},{id:"gpt-5.2-codex",ownedBy:"openai",label:"GPT-5.2-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2025-12-11",lastUpdated:"2025-12-11",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.3-codex",ownedBy:"openai",label:"GPT-5.3-Codex",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-02-24",lastUpdated:"2026-02-24",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.4",ownedBy:"openai",label:"GPT-5.4",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-05",lastUpdated:"2026-03-05",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.4-mini",ownedBy:"openai",label:"GPT-5.4 Mini",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-03-17",lastUpdated:"2026-03-17",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"gpt-5.5",ownedBy:"openai",label:"GPT-5.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!1,knowledge:"2025-08-31",releaseDate:"2026-04-22",lastUpdated:"2026-04-22",openWeights:!1,cost:{input:0,output:0},limit:{context:4e5,output:128e3}},{id:"grok-code-fast-1",ownedBy:"xai",label:"Grok Code Fast 1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,temperature:!0,knowledge:"2025-08",releaseDate:"2025-08-27",lastUpdated:"2025-08-27",openWeights:!1,cost:{input:0,output:0},limit:{context:128e3,output:64e3}}],label:"GitHub Copilot",env:["GITHUB_TOKEN"],npm:"@ai-sdk/openai-compatible",api:"https://api.githubcopilot.com",doc:"https://docs.github.com/en/copilot"},"ollama-cloud":{id:"ollama-cloud",models:[{id:"cogito-2.1:671b",label:"cogito-2.1:671b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-11-19",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:163840,output:32e3}},{id:"deepseek-v3.1:671b",label:"deepseek-v3.1:671b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-08-21",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:163840,output:163840}},{id:"deepseek-v3.2",label:"deepseek-v3.2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-06-15",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:163840,output:65536}},{id:"deepseek-v4-flash",label:"deepseek-v4-flash",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!0,limit:{context:1048576,output:1048576}},{id:"deepseek-v4-pro",label:"deepseek-v4-pro",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-04-24",lastUpdated:"2026-04-24",openWeights:!0,limit:{context:1048576,output:1048576}},{id:"devstral-2:123b",label:"devstral-2:123b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-12-09",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"devstral-small-2:24b",label:"devstral-small-2:24b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2025-12-09",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"gemini-3-flash-preview",ownedBy:"google",label:"gemini-3-flash-preview",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,knowledge:"2025-01",releaseDate:"2025-12-17",lastUpdated:"2026-04-08",openWeights:!0,limit:{context:1048576,output:65536}},{id:"gemma3:12b",label:"gemma3:12b",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:131072}},{id:"gemma3:27b",label:"gemma3:27b",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,releaseDate:"2025-07-27",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:131072}},{id:"gemma3:4b",label:"gemma3:4b",modalities:{input:["text","image"],output:["text"]},toolCall:!1,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:131072}},{id:"gemma4:31b",label:"gemma4:31b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,knowledge:"2025-01",releaseDate:"2026-04-02",lastUpdated:"2026-04-08",openWeights:!0,limit:{context:262144,output:262144}},{id:"glm-4.6",ownedBy:"zai",label:"glm-4.6",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-09-29",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:202752,output:131072}},{id:"glm-4.7",ownedBy:"zai",label:"glm-4.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-12-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:202752,output:131072}},{id:"glm-5",ownedBy:"zai",label:"glm-5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-02-11",lastUpdated:"2026-02-11",openWeights:!0,limit:{context:202752,output:131072}},{id:"glm-5.1",ownedBy:"zai",label:"glm-5.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-03-27",lastUpdated:"2026-04-07",openWeights:!0,limit:{context:202752,output:131072}},{id:"gpt-oss:120b",ownedBy:"openai",label:"gpt-oss:120b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-08-05",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:32768}},{id:"gpt-oss:20b",ownedBy:"openai",label:"gpt-oss:20b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-08-05",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:131072,output:32768}},{id:"kimi-k2-thinking",ownedBy:"moonshot",label:"kimi-k2-thinking",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,knowledge:"2024-08",releaseDate:"2025-11-06",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"kimi-k2:1t",ownedBy:"moonshot",label:"kimi-k2:1t",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,knowledge:"2024-10",releaseDate:"2025-07-11",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"kimi-k2.5",ownedBy:"moonshot",label:"kimi-k2.5",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2026-01-27",lastUpdated:"2026-01-27",openWeights:!0,limit:{context:262144,output:262144}},{id:"kimi-k2.6:cloud",ownedBy:"moonshot",label:"kimi-k2.6:cloud",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2026-04-20",lastUpdated:"2026-04-20",openWeights:!0,limit:{context:262144,output:262144}},{id:"minimax-m2",ownedBy:"minimax",label:"minimax-m2",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-10-23",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:204800,output:128e3}},{id:"minimax-m2.1",ownedBy:"minimax",label:"minimax-m2.1",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-12-23",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:204800,output:131072}},{id:"minimax-m2.5",ownedBy:"minimax",label:"minimax-m2.5",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,knowledge:"2025-01",releaseDate:"2026-02-12",lastUpdated:"2026-02-12",openWeights:!0,limit:{context:204800,output:131072}},{id:"minimax-m2.7",ownedBy:"minimax",label:"minimax-m2.7",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-03-18",lastUpdated:"2026-03-18",openWeights:!0,limit:{context:196608,output:196608}},{id:"ministral-3:14b",label:"ministral-3:14b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:128e3}},{id:"ministral-3:3b",label:"ministral-3:3b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2024-10-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:128e3}},{id:"ministral-3:8b",label:"ministral-3:8b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2024-12-01",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:128e3}},{id:"mistral-large-3:675b",label:"mistral-large-3:675b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2025-12-02",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:262144}},{id:"nemotron-3-nano:30b",label:"nemotron-3-nano:30b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-12-15",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:1048576,output:131072}},{id:"nemotron-3-super",label:"nemotron-3-super",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2026-03-11",lastUpdated:"2026-03-12",openWeights:!0,limit:{context:262144,output:65536}},{id:"qwen3-coder-next",label:"qwen3-coder-next",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2026-02-02",lastUpdated:"2026-02-08",openWeights:!0,limit:{context:262144,output:65536}},{id:"qwen3-coder:480b",label:"qwen3-coder:480b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-07-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:65536}},{id:"qwen3-next:80b",label:"qwen3-next:80b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!1,releaseDate:"2025-09-15",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:32768}},{id:"qwen3-vl:235b",label:"qwen3-vl:235b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2025-09-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:32768}},{id:"qwen3-vl:235b-instruct",label:"qwen3-vl:235b-instruct",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!0,releaseDate:"2025-09-22",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:262144,output:131072}},{id:"qwen3.5:397b",label:"qwen3.5:397b",modalities:{input:["text","image"],output:["text"]},toolCall:!0,reasoningText:!0,attachment:!0,releaseDate:"2026-02-15",lastUpdated:"2026-02-17",openWeights:!0,limit:{context:262144,output:65536}},{id:"rnj-1:8b",label:"rnj-1:8b",modalities:{input:["text"],output:["text"]},toolCall:!0,reasoningText:!1,attachment:!1,releaseDate:"2025-12-06",lastUpdated:"2026-01-19",openWeights:!0,limit:{context:32768,output:4096}}],label:"Ollama Cloud",env:["OLLAMA_API_KEY"],npm:"ai-sdk-ollama",api:"https://ollama.com",doc:"https://docs.ollama.com/cloud"}};var ki={},cr={},Zl;function ex(){if(Zl)return cr;Zl=1,cr.byteLength=a,cr.toByteArray=Q,cr.fromByteArray=E;for(var A=[],e=[],t=typeof Uint8Array<"u"?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,r=s.length;n<r;++n)A[n]=s[n],e[s.charCodeAt(n)]=n;e[45]=62,e[95]=63;function i(c){var h=c.length;if(h%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var f=c.indexOf("=");f===-1&&(f=h);var d=f===h?0:4-f%4;return[f,d]}function a(c){var h=i(c),f=h[0],d=h[1];return(f+d)*3/4-d}function g(c,h,f){return(h+f)*3/4-f}function Q(c){var h,f=i(c),d=f[0],D=f[1],R=new t(g(c,d,D)),M=0,q=D>0?d-4:d,G;for(G=0;G<q;G+=4)h=e[c.charCodeAt(G)]<<18|e[c.charCodeAt(G+1)]<<12|e[c.charCodeAt(G+2)]<<6|e[c.charCodeAt(G+3)],R[M++]=h>>16&255,R[M++]=h>>8&255,R[M++]=h&255;return D===2&&(h=e[c.charCodeAt(G)]<<2|e[c.charCodeAt(G+1)]>>4,R[M++]=h&255),D===1&&(h=e[c.charCodeAt(G)]<<10|e[c.charCodeAt(G+1)]<<4|e[c.charCodeAt(G+2)]>>2,R[M++]=h>>8&255,R[M++]=h&255),R}function B(c){return A[c>>18&63]+A[c>>12&63]+A[c>>6&63]+A[c&63]}function u(c,h,f){for(var d,D=[],R=h;R<f;R+=3)d=(c[R]<<16&16711680)+(c[R+1]<<8&65280)+(c[R+2]&255),D.push(B(d));return D.join("")}function E(c){for(var h,f=c.length,d=f%3,D=[],R=16383,M=0,q=f-d;M<q;M+=R)D.push(u(c,M,M+R>q?q:M+R));return d===1?(h=c[f-1],D.push(A[h>>2]+A[h<<4&63]+"==")):d===2&&(h=(c[f-2]<<8)+c[f-1],D.push(A[h>>10]+A[h>>4&63]+A[h<<2&63]+"=")),D.join("")}return cr}var on={};var Xl;function tx(){return Xl||(Xl=1,on.read=function(A,e,t,s,n){var r,i,a=n*8-s-1,g=(1<<a)-1,Q=g>>1,B=-7,u=t?n-1:0,E=t?-1:1,c=A[e+u];for(u+=E,r=c&(1<<-B)-1,c>>=-B,B+=a;B>0;r=r*256+A[e+u],u+=E,B-=8);for(i=r&(1<<-B)-1,r>>=-B,B+=s;B>0;i=i*256+A[e+u],u+=E,B-=8);if(r===0)r=1-Q;else{if(r===g)return i?NaN:(c?-1:1)*(1/0);i=i+Math.pow(2,s),r=r-Q}return(c?-1:1)*i*Math.pow(2,r-s)},on.write=function(A,e,t,s,n,r){var i,a,g,Q=r*8-n-1,B=(1<<Q)-1,u=B>>1,E=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,c=s?0:r-1,h=s?1:-1,f=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,i=B):(i=Math.floor(Math.log(e)/Math.LN2),e*(g=Math.pow(2,-i))<1&&(i--,g*=2),i+u>=1?e+=E/g:e+=E*Math.pow(2,1-u),e*g>=2&&(i++,g/=2),i+u>=B?(a=0,i=B):i+u>=1?(a=(e*g-1)*Math.pow(2,n),i=i+u):(a=e*Math.pow(2,u-1)*Math.pow(2,n),i=0));n>=8;A[t+c]=a&255,c+=h,a/=256,n-=8);for(i=i<<n|a,Q+=n;Q>0;A[t+c]=i&255,c+=h,i/=256,Q-=8);A[t+c-h]|=f*128}),on}var $l;function Fg(){return $l||($l=1,(function(A){const e=ex(),t=tx(),s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;A.Buffer=a,A.SlowBuffer=R,A.INSPECT_MAX_BYTES=50;const n=2147483647;A.kMaxLength=n,a.TYPED_ARRAY_SUPPORT=r(),!a.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function r(){try{const P=new Uint8Array(1),N={foo:function(){return 42}};return Object.setPrototypeOf(N,Uint8Array.prototype),Object.setPrototypeOf(P,N),P.foo()===42}catch{return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function i(P){if(P>n)throw new RangeError('The value "'+P+'" is invalid for option "size"');const N=new Uint8Array(P);return Object.setPrototypeOf(N,a.prototype),N}function a(P,N,k){if(typeof P=="number"){if(typeof N=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return u(P)}return g(P,N,k)}a.poolSize=8192;function g(P,N,k){if(typeof P=="string")return E(P,N);if(ArrayBuffer.isView(P))return h(P);if(P==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P);if(nt(P,ArrayBuffer)||P&&nt(P.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(nt(P,SharedArrayBuffer)||P&&nt(P.buffer,SharedArrayBuffer)))return f(P,N,k);if(typeof P=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const _=P.valueOf&&P.valueOf();if(_!=null&&_!==P)return a.from(_,N,k);const tA=d(P);if(tA)return tA;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof P[Symbol.toPrimitive]=="function")return a.from(P[Symbol.toPrimitive]("string"),N,k);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P)}a.from=function(P,N,k){return g(P,N,k)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function Q(P){if(typeof P!="number")throw new TypeError('"size" argument must be of type number');if(P<0)throw new RangeError('The value "'+P+'" is invalid for option "size"')}function B(P,N,k){return Q(P),P<=0?i(P):N!==void 0?typeof k=="string"?i(P).fill(N,k):i(P).fill(N):i(P)}a.alloc=function(P,N,k){return B(P,N,k)};function u(P){return Q(P),i(P<0?0:D(P)|0)}a.allocUnsafe=function(P){return u(P)},a.allocUnsafeSlow=function(P){return u(P)};function E(P,N){if((typeof N!="string"||N==="")&&(N="utf8"),!a.isEncoding(N))throw new TypeError("Unknown encoding: "+N);const k=M(P,N)|0;let _=i(k);const tA=_.write(P,N);return tA!==k&&(_=_.slice(0,tA)),_}function c(P){const N=P.length<0?0:D(P.length)|0,k=i(N);for(let _=0;_<N;_+=1)k[_]=P[_]&255;return k}function h(P){if(nt(P,Uint8Array)){const N=new Uint8Array(P);return f(N.buffer,N.byteOffset,N.byteLength)}return c(P)}function f(P,N,k){if(N<0||P.byteLength<N)throw new RangeError('"offset" is outside of buffer bounds');if(P.byteLength<N+(k||0))throw new RangeError('"length" is outside of buffer bounds');let _;return N===void 0&&k===void 0?_=new Uint8Array(P):k===void 0?_=new Uint8Array(P,N):_=new Uint8Array(P,N,k),Object.setPrototypeOf(_,a.prototype),_}function d(P){if(a.isBuffer(P)){const N=D(P.length)|0,k=i(N);return k.length===0||P.copy(k,0,0,N),k}if(P.length!==void 0)return typeof P.length!="number"||Le(P.length)?i(0):c(P);if(P.type==="Buffer"&&Array.isArray(P.data))return c(P.data)}function D(P){if(P>=n)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n.toString(16)+" bytes");return P|0}function R(P){return+P!=P&&(P=0),a.alloc(+P)}a.isBuffer=function(N){return N!=null&&N._isBuffer===!0&&N!==a.prototype},a.compare=function(N,k){if(nt(N,Uint8Array)&&(N=a.from(N,N.offset,N.byteLength)),nt(k,Uint8Array)&&(k=a.from(k,k.offset,k.byteLength)),!a.isBuffer(N)||!a.isBuffer(k))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(N===k)return 0;let _=N.length,tA=k.length;for(let aA=0,EA=Math.min(_,tA);aA<EA;++aA)if(N[aA]!==k[aA]){_=N[aA],tA=k[aA];break}return _<tA?-1:tA<_?1:0},a.isEncoding=function(N){switch(String(N).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(N,k){if(!Array.isArray(N))throw new TypeError('"list" argument must be an Array of Buffers');if(N.length===0)return a.alloc(0);let _;if(k===void 0)for(k=0,_=0;_<N.length;++_)k+=N[_].length;const tA=a.allocUnsafe(k);let aA=0;for(_=0;_<N.length;++_){let EA=N[_];if(nt(EA,Uint8Array))aA+EA.length>tA.length?(a.isBuffer(EA)||(EA=a.from(EA)),EA.copy(tA,aA)):Uint8Array.prototype.set.call(tA,EA,aA);else if(a.isBuffer(EA))EA.copy(tA,aA);else throw new TypeError('"list" argument must be an Array of Buffers');aA+=EA.length}return tA};function M(P,N){if(a.isBuffer(P))return P.length;if(ArrayBuffer.isView(P)||nt(P,ArrayBuffer))return P.byteLength;if(typeof P!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof P);const k=P.length,_=arguments.length>2&&arguments[2]===!0;if(!_&&k===0)return 0;let tA=!1;for(;;)switch(N){case"ascii":case"latin1":case"binary":return k;case"utf8":case"utf-8":return _A(P).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k*2;case"hex":return k>>>1;case"base64":return de(P).length;default:if(tA)return _?-1:_A(P).length;N=(""+N).toLowerCase(),tA=!0}}a.byteLength=M;function q(P,N,k){let _=!1;if((N===void 0||N<0)&&(N=0),N>this.length||((k===void 0||k>this.length)&&(k=this.length),k<=0)||(k>>>=0,N>>>=0,k<=N))return"";for(P||(P="utf8");;)switch(P){case"hex":return H(this,N,k);case"utf8":case"utf-8":return l(this,N,k);case"ascii":return b(this,N,k);case"latin1":case"binary":return J(this,N,k);case"base64":return x(this,N,k);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,N,k);default:if(_)throw new TypeError("Unknown encoding: "+P);P=(P+"").toLowerCase(),_=!0}}a.prototype._isBuffer=!0;function G(P,N,k){const _=P[N];P[N]=P[k],P[k]=_}a.prototype.swap16=function(){const N=this.length;if(N%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let k=0;k<N;k+=2)G(this,k,k+1);return this},a.prototype.swap32=function(){const N=this.length;if(N%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let k=0;k<N;k+=4)G(this,k,k+3),G(this,k+1,k+2);return this},a.prototype.swap64=function(){const N=this.length;if(N%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let k=0;k<N;k+=8)G(this,k,k+7),G(this,k+1,k+6),G(this,k+2,k+5),G(this,k+3,k+4);return this},a.prototype.toString=function(){const N=this.length;return N===0?"":arguments.length===0?l(this,0,N):q.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(N){if(!a.isBuffer(N))throw new TypeError("Argument must be a Buffer");return this===N?!0:a.compare(this,N)===0},a.prototype.inspect=function(){let N="";const k=A.INSPECT_MAX_BYTES;return N=this.toString("hex",0,k).replace(/(.{2})/g,"$1 ").trim(),this.length>k&&(N+=" ... "),"<Buffer "+N+">"},s&&(a.prototype[s]=a.prototype.inspect),a.prototype.compare=function(N,k,_,tA,aA){if(nt(N,Uint8Array)&&(N=a.from(N,N.offset,N.byteLength)),!a.isBuffer(N))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof N);if(k===void 0&&(k=0),_===void 0&&(_=N?N.length:0),tA===void 0&&(tA=0),aA===void 0&&(aA=this.length),k<0||_>N.length||tA<0||aA>this.length)throw new RangeError("out of range index");if(tA>=aA&&k>=_)return 0;if(tA>=aA)return-1;if(k>=_)return 1;if(k>>>=0,_>>>=0,tA>>>=0,aA>>>=0,this===N)return 0;let EA=aA-tA,ZA=_-k;const VA=Math.min(EA,ZA),$A=this.slice(tA,aA),ke=N.slice(k,_);for(let XA=0;XA<VA;++XA)if($A[XA]!==ke[XA]){EA=$A[XA],ZA=ke[XA];break}return EA<ZA?-1:ZA<EA?1:0};function T(P,N,k,_,tA){if(P.length===0)return-1;if(typeof k=="string"?(_=k,k=0):k>2147483647?k=2147483647:k<-2147483648&&(k=-2147483648),k=+k,Le(k)&&(k=tA?0:P.length-1),k<0&&(k=P.length+k),k>=P.length){if(tA)return-1;k=P.length-1}else if(k<0)if(tA)k=0;else return-1;if(typeof N=="string"&&(N=a.from(N,_)),a.isBuffer(N))return N.length===0?-1:Z(P,N,k,_,tA);if(typeof N=="number")return N=N&255,typeof Uint8Array.prototype.indexOf=="function"?tA?Uint8Array.prototype.indexOf.call(P,N,k):Uint8Array.prototype.lastIndexOf.call(P,N,k):Z(P,[N],k,_,tA);throw new TypeError("val must be string, number or Buffer")}function Z(P,N,k,_,tA){let aA=1,EA=P.length,ZA=N.length;if(_!==void 0&&(_=String(_).toLowerCase(),_==="ucs2"||_==="ucs-2"||_==="utf16le"||_==="utf-16le")){if(P.length<2||N.length<2)return-1;aA=2,EA/=2,ZA/=2,k/=2}function VA(ke,XA){return aA===1?ke[XA]:ke.readUInt16BE(XA*aA)}let $A;if(tA){let ke=-1;for($A=k;$A<EA;$A++)if(VA(P,$A)===VA(N,ke===-1?0:$A-ke)){if(ke===-1&&(ke=$A),$A-ke+1===ZA)return ke*aA}else ke!==-1&&($A-=$A-ke),ke=-1}else for(k+ZA>EA&&(k=EA-ZA),$A=k;$A>=0;$A--){let ke=!0;for(let XA=0;XA<ZA;XA++)if(VA(P,$A+XA)!==VA(N,XA)){ke=!1;break}if(ke)return $A}return-1}a.prototype.includes=function(N,k,_){return this.indexOf(N,k,_)!==-1},a.prototype.indexOf=function(N,k,_){return T(this,N,k,_,!0)},a.prototype.lastIndexOf=function(N,k,_){return T(this,N,k,_,!1)};function X(P,N,k,_){k=Number(k)||0;const tA=P.length-k;_?(_=Number(_),_>tA&&(_=tA)):_=tA;const aA=N.length;_>aA/2&&(_=aA/2);let EA;for(EA=0;EA<_;++EA){const ZA=parseInt(N.substr(EA*2,2),16);if(Le(ZA))return EA;P[k+EA]=ZA}return EA}function U(P,N,k,_){return Ke(_A(N,P.length-k),P,k,_)}function O(P,N,k,_){return Ke(we(N),P,k,_)}function j(P,N,k,_){return Ke(de(N),P,k,_)}function Y(P,N,k,_){return Ke(He(N,P.length-k),P,k,_)}a.prototype.write=function(N,k,_,tA){if(k===void 0)tA="utf8",_=this.length,k=0;else if(_===void 0&&typeof k=="string")tA=k,_=this.length,k=0;else if(isFinite(k))k=k>>>0,isFinite(_)?(_=_>>>0,tA===void 0&&(tA="utf8")):(tA=_,_=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const aA=this.length-k;if((_===void 0||_>aA)&&(_=aA),N.length>0&&(_<0||k<0)||k>this.length)throw new RangeError("Attempt to write outside buffer bounds");tA||(tA="utf8");let EA=!1;for(;;)switch(tA){case"hex":return X(this,N,k,_);case"utf8":case"utf-8":return U(this,N,k,_);case"ascii":case"latin1":case"binary":return O(this,N,k,_);case"base64":return j(this,N,k,_);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Y(this,N,k,_);default:if(EA)throw new TypeError("Unknown encoding: "+tA);tA=(""+tA).toLowerCase(),EA=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(P,N,k){return N===0&&k===P.length?e.fromByteArray(P):e.fromByteArray(P.slice(N,k))}function l(P,N,k){k=Math.min(P.length,k);const _=[];let tA=N;for(;tA<k;){const aA=P[tA];let EA=null,ZA=aA>239?4:aA>223?3:aA>191?2:1;if(tA+ZA<=k){let VA,$A,ke,XA;switch(ZA){case 1:aA<128&&(EA=aA);break;case 2:VA=P[tA+1],(VA&192)===128&&(XA=(aA&31)<<6|VA&63,XA>127&&(EA=XA));break;case 3:VA=P[tA+1],$A=P[tA+2],(VA&192)===128&&($A&192)===128&&(XA=(aA&15)<<12|(VA&63)<<6|$A&63,XA>2047&&(XA<55296||XA>57343)&&(EA=XA));break;case 4:VA=P[tA+1],$A=P[tA+2],ke=P[tA+3],(VA&192)===128&&($A&192)===128&&(ke&192)===128&&(XA=(aA&15)<<18|(VA&63)<<12|($A&63)<<6|ke&63,XA>65535&&XA<1114112&&(EA=XA))}}EA===null?(EA=65533,ZA=1):EA>65535&&(EA-=65536,_.push(EA>>>10&1023|55296),EA=56320|EA&1023),_.push(EA),tA+=ZA}return y(_)}const I=4096;function y(P){const N=P.length;if(N<=I)return String.fromCharCode.apply(String,P);let k="",_=0;for(;_<N;)k+=String.fromCharCode.apply(String,P.slice(_,_+=I));return k}function b(P,N,k){let _="";k=Math.min(P.length,k);for(let tA=N;tA<k;++tA)_+=String.fromCharCode(P[tA]&127);return _}function J(P,N,k){let _="";k=Math.min(P.length,k);for(let tA=N;tA<k;++tA)_+=String.fromCharCode(P[tA]);return _}function H(P,N,k){const _=P.length;(!N||N<0)&&(N=0),(!k||k<0||k>_)&&(k=_);let tA="";for(let aA=N;aA<k;++aA)tA+=kA[P[aA]];return tA}function v(P,N,k){const _=P.slice(N,k);let tA="";for(let aA=0;aA<_.length-1;aA+=2)tA+=String.fromCharCode(_[aA]+_[aA+1]*256);return tA}a.prototype.slice=function(N,k){const _=this.length;N=~~N,k=k===void 0?_:~~k,N<0?(N+=_,N<0&&(N=0)):N>_&&(N=_),k<0?(k+=_,k<0&&(k=0)):k>_&&(k=_),k<N&&(k=N);const tA=this.subarray(N,k);return Object.setPrototypeOf(tA,a.prototype),tA};function K(P,N,k){if(P%1!==0||P<0)throw new RangeError("offset is not uint");if(P+N>k)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(N,k,_){N=N>>>0,k=k>>>0,_||K(N,k,this.length);let tA=this[N],aA=1,EA=0;for(;++EA<k&&(aA*=256);)tA+=this[N+EA]*aA;return tA},a.prototype.readUintBE=a.prototype.readUIntBE=function(N,k,_){N=N>>>0,k=k>>>0,_||K(N,k,this.length);let tA=this[N+--k],aA=1;for(;k>0&&(aA*=256);)tA+=this[N+--k]*aA;return tA},a.prototype.readUint8=a.prototype.readUInt8=function(N,k){return N=N>>>0,k||K(N,1,this.length),this[N]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(N,k){return N=N>>>0,k||K(N,2,this.length),this[N]|this[N+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(N,k){return N=N>>>0,k||K(N,2,this.length),this[N]<<8|this[N+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(N,k){return N=N>>>0,k||K(N,4,this.length),(this[N]|this[N+1]<<8|this[N+2]<<16)+this[N+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(N,k){return N=N>>>0,k||K(N,4,this.length),this[N]*16777216+(this[N+1]<<16|this[N+2]<<8|this[N+3])},a.prototype.readBigUInt64LE=he(function(N){N=N>>>0,jA(N,"offset");const k=this[N],_=this[N+7];(k===void 0||_===void 0)&&HA(N,this.length-8);const tA=k+this[++N]*2**8+this[++N]*2**16+this[++N]*2**24,aA=this[++N]+this[++N]*2**8+this[++N]*2**16+_*2**24;return BigInt(tA)+(BigInt(aA)<<BigInt(32))}),a.prototype.readBigUInt64BE=he(function(N){N=N>>>0,jA(N,"offset");const k=this[N],_=this[N+7];(k===void 0||_===void 0)&&HA(N,this.length-8);const tA=k*2**24+this[++N]*2**16+this[++N]*2**8+this[++N],aA=this[++N]*2**24+this[++N]*2**16+this[++N]*2**8+_;return(BigInt(tA)<<BigInt(32))+BigInt(aA)}),a.prototype.readIntLE=function(N,k,_){N=N>>>0,k=k>>>0,_||K(N,k,this.length);let tA=this[N],aA=1,EA=0;for(;++EA<k&&(aA*=256);)tA+=this[N+EA]*aA;return aA*=128,tA>=aA&&(tA-=Math.pow(2,8*k)),tA},a.prototype.readIntBE=function(N,k,_){N=N>>>0,k=k>>>0,_||K(N,k,this.length);let tA=k,aA=1,EA=this[N+--tA];for(;tA>0&&(aA*=256);)EA+=this[N+--tA]*aA;return aA*=128,EA>=aA&&(EA-=Math.pow(2,8*k)),EA},a.prototype.readInt8=function(N,k){return N=N>>>0,k||K(N,1,this.length),this[N]&128?(255-this[N]+1)*-1:this[N]},a.prototype.readInt16LE=function(N,k){N=N>>>0,k||K(N,2,this.length);const _=this[N]|this[N+1]<<8;return _&32768?_|4294901760:_},a.prototype.readInt16BE=function(N,k){N=N>>>0,k||K(N,2,this.length);const _=this[N+1]|this[N]<<8;return _&32768?_|4294901760:_},a.prototype.readInt32LE=function(N,k){return N=N>>>0,k||K(N,4,this.length),this[N]|this[N+1]<<8|this[N+2]<<16|this[N+3]<<24},a.prototype.readInt32BE=function(N,k){return N=N>>>0,k||K(N,4,this.length),this[N]<<24|this[N+1]<<16|this[N+2]<<8|this[N+3]},a.prototype.readBigInt64LE=he(function(N){N=N>>>0,jA(N,"offset");const k=this[N],_=this[N+7];(k===void 0||_===void 0)&&HA(N,this.length-8);const tA=this[N+4]+this[N+5]*2**8+this[N+6]*2**16+(_<<24);return(BigInt(tA)<<BigInt(32))+BigInt(k+this[++N]*2**8+this[++N]*2**16+this[++N]*2**24)}),a.prototype.readBigInt64BE=he(function(N){N=N>>>0,jA(N,"offset");const k=this[N],_=this[N+7];(k===void 0||_===void 0)&&HA(N,this.length-8);const tA=(k<<24)+this[++N]*2**16+this[++N]*2**8+this[++N];return(BigInt(tA)<<BigInt(32))+BigInt(this[++N]*2**24+this[++N]*2**16+this[++N]*2**8+_)}),a.prototype.readFloatLE=function(N,k){return N=N>>>0,k||K(N,4,this.length),t.read(this,N,!0,23,4)},a.prototype.readFloatBE=function(N,k){return N=N>>>0,k||K(N,4,this.length),t.read(this,N,!1,23,4)},a.prototype.readDoubleLE=function(N,k){return N=N>>>0,k||K(N,8,this.length),t.read(this,N,!0,52,8)},a.prototype.readDoubleBE=function(N,k){return N=N>>>0,k||K(N,8,this.length),t.read(this,N,!1,52,8)};function C(P,N,k,_,tA,aA){if(!a.isBuffer(P))throw new TypeError('"buffer" argument must be a Buffer instance');if(N>tA||N<aA)throw new RangeError('"value" argument is out of bounds');if(k+_>P.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(N,k,_,tA){if(N=+N,k=k>>>0,_=_>>>0,!tA){const ZA=Math.pow(2,8*_)-1;C(this,N,k,_,ZA,0)}let aA=1,EA=0;for(this[k]=N&255;++EA<_&&(aA*=256);)this[k+EA]=N/aA&255;return k+_},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(N,k,_,tA){if(N=+N,k=k>>>0,_=_>>>0,!tA){const ZA=Math.pow(2,8*_)-1;C(this,N,k,_,ZA,0)}let aA=_-1,EA=1;for(this[k+aA]=N&255;--aA>=0&&(EA*=256);)this[k+aA]=N/EA&255;return k+_},a.prototype.writeUint8=a.prototype.writeUInt8=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,1,255,0),this[k]=N&255,k+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,2,65535,0),this[k]=N&255,this[k+1]=N>>>8,k+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,2,65535,0),this[k]=N>>>8,this[k+1]=N&255,k+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,4,4294967295,0),this[k+3]=N>>>24,this[k+2]=N>>>16,this[k+1]=N>>>8,this[k]=N&255,k+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,4,4294967295,0),this[k]=N>>>24,this[k+1]=N>>>16,this[k+2]=N>>>8,this[k+3]=N&255,k+4};function p(P,N,k,_,tA){lA(N,_,tA,P,k,7);let aA=Number(N&BigInt(4294967295));P[k++]=aA,aA=aA>>8,P[k++]=aA,aA=aA>>8,P[k++]=aA,aA=aA>>8,P[k++]=aA;let EA=Number(N>>BigInt(32)&BigInt(4294967295));return P[k++]=EA,EA=EA>>8,P[k++]=EA,EA=EA>>8,P[k++]=EA,EA=EA>>8,P[k++]=EA,k}function L(P,N,k,_,tA){lA(N,_,tA,P,k,7);let aA=Number(N&BigInt(4294967295));P[k+7]=aA,aA=aA>>8,P[k+6]=aA,aA=aA>>8,P[k+5]=aA,aA=aA>>8,P[k+4]=aA;let EA=Number(N>>BigInt(32)&BigInt(4294967295));return P[k+3]=EA,EA=EA>>8,P[k+2]=EA,EA=EA>>8,P[k+1]=EA,EA=EA>>8,P[k]=EA,k+8}a.prototype.writeBigUInt64LE=he(function(N,k=0){return p(this,N,k,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=he(function(N,k=0){return L(this,N,k,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(N,k,_,tA){if(N=+N,k=k>>>0,!tA){const VA=Math.pow(2,8*_-1);C(this,N,k,_,VA-1,-VA)}let aA=0,EA=1,ZA=0;for(this[k]=N&255;++aA<_&&(EA*=256);)N<0&&ZA===0&&this[k+aA-1]!==0&&(ZA=1),this[k+aA]=(N/EA>>0)-ZA&255;return k+_},a.prototype.writeIntBE=function(N,k,_,tA){if(N=+N,k=k>>>0,!tA){const VA=Math.pow(2,8*_-1);C(this,N,k,_,VA-1,-VA)}let aA=_-1,EA=1,ZA=0;for(this[k+aA]=N&255;--aA>=0&&(EA*=256);)N<0&&ZA===0&&this[k+aA+1]!==0&&(ZA=1),this[k+aA]=(N/EA>>0)-ZA&255;return k+_},a.prototype.writeInt8=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,1,127,-128),N<0&&(N=255+N+1),this[k]=N&255,k+1},a.prototype.writeInt16LE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,2,32767,-32768),this[k]=N&255,this[k+1]=N>>>8,k+2},a.prototype.writeInt16BE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,2,32767,-32768),this[k]=N>>>8,this[k+1]=N&255,k+2},a.prototype.writeInt32LE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,4,2147483647,-2147483648),this[k]=N&255,this[k+1]=N>>>8,this[k+2]=N>>>16,this[k+3]=N>>>24,k+4},a.prototype.writeInt32BE=function(N,k,_){return N=+N,k=k>>>0,_||C(this,N,k,4,2147483647,-2147483648),N<0&&(N=4294967295+N+1),this[k]=N>>>24,this[k+1]=N>>>16,this[k+2]=N>>>8,this[k+3]=N&255,k+4},a.prototype.writeBigInt64LE=he(function(N,k=0){return p(this,N,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=he(function(N,k=0){return L(this,N,k,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function S(P,N,k,_,tA,aA){if(k+_>P.length)throw new RangeError("Index out of range");if(k<0)throw new RangeError("Index out of range")}function $(P,N,k,_,tA){return N=+N,k=k>>>0,tA||S(P,N,k,4),t.write(P,N,k,_,23,4),k+4}a.prototype.writeFloatLE=function(N,k,_){return $(this,N,k,!0,_)},a.prototype.writeFloatBE=function(N,k,_){return $(this,N,k,!1,_)};function AA(P,N,k,_,tA){return N=+N,k=k>>>0,tA||S(P,N,k,8),t.write(P,N,k,_,52,8),k+8}a.prototype.writeDoubleLE=function(N,k,_){return AA(this,N,k,!0,_)},a.prototype.writeDoubleBE=function(N,k,_){return AA(this,N,k,!1,_)},a.prototype.copy=function(N,k,_,tA){if(!a.isBuffer(N))throw new TypeError("argument should be a Buffer");if(_||(_=0),!tA&&tA!==0&&(tA=this.length),k>=N.length&&(k=N.length),k||(k=0),tA>0&&tA<_&&(tA=_),tA===_||N.length===0||this.length===0)return 0;if(k<0)throw new RangeError("targetStart out of bounds");if(_<0||_>=this.length)throw new RangeError("Index out of range");if(tA<0)throw new RangeError("sourceEnd out of bounds");tA>this.length&&(tA=this.length),N.length-k<tA-_&&(tA=N.length-k+_);const aA=tA-_;return this===N&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(k,_,tA):Uint8Array.prototype.set.call(N,this.subarray(_,tA),k),aA},a.prototype.fill=function(N,k,_,tA){if(typeof N=="string"){if(typeof k=="string"?(tA=k,k=0,_=this.length):typeof _=="string"&&(tA=_,_=this.length),tA!==void 0&&typeof tA!="string")throw new TypeError("encoding must be a string");if(typeof tA=="string"&&!a.isEncoding(tA))throw new TypeError("Unknown encoding: "+tA);if(N.length===1){const EA=N.charCodeAt(0);(tA==="utf8"&&EA<128||tA==="latin1")&&(N=EA)}}else typeof N=="number"?N=N&255:typeof N=="boolean"&&(N=Number(N));if(k<0||this.length<k||this.length<_)throw new RangeError("Out of range index");if(_<=k)return this;k=k>>>0,_=_===void 0?this.length:_>>>0,N||(N=0);let aA;if(typeof N=="number")for(aA=k;aA<_;++aA)this[aA]=N;else{const EA=a.isBuffer(N)?N:a.from(N,tA),ZA=EA.length;if(ZA===0)throw new TypeError('The value "'+N+'" is invalid for argument "value"');for(aA=0;aA<_-k;++aA)this[aA+k]=EA[aA%ZA]}return this};const sA={};function oA(P,N,k){sA[P]=class extends k{constructor(){super(),Object.defineProperty(this,"message",{value:N.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${P}]`,this.stack,delete this.name}get code(){return P}set code(tA){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:tA,writable:!0})}toString(){return`${this.name} [${P}]: ${this.message}`}}}oA("ERR_BUFFER_OUT_OF_BOUNDS",function(P){return P?`${P} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),oA("ERR_INVALID_ARG_TYPE",function(P,N){return`The "${P}" argument must be of type number. Received type ${typeof N}`},TypeError),oA("ERR_OUT_OF_RANGE",function(P,N,k){let _=`The value of "${P}" is out of range.`,tA=k;return Number.isInteger(k)&&Math.abs(k)>2**32?tA=bA(String(k)):typeof k=="bigint"&&(tA=String(k),(k>BigInt(2)**BigInt(32)||k<-(BigInt(2)**BigInt(32)))&&(tA=bA(tA)),tA+="n"),_+=` It must be ${N}. Received ${tA}`,_},RangeError);function bA(P){let N="",k=P.length;const _=P[0]==="-"?1:0;for(;k>=_+4;k-=3)N=`_${P.slice(k-3,k)}${N}`;return`${P.slice(0,k)}${N}`}function GA(P,N,k){jA(N,"offset"),(P[N]===void 0||P[N+k]===void 0)&&HA(N,P.length-(k+1))}function lA(P,N,k,_,tA,aA){if(P>k||P<N){const EA=typeof N=="bigint"?"n":"";let ZA;throw N===0||N===BigInt(0)?ZA=`>= 0${EA} and < 2${EA} ** ${(aA+1)*8}${EA}`:ZA=`>= -(2${EA} ** ${(aA+1)*8-1}${EA}) and < 2 ** ${(aA+1)*8-1}${EA}`,new sA.ERR_OUT_OF_RANGE("value",ZA,P)}GA(_,tA,aA)}function jA(P,N){if(typeof P!="number")throw new sA.ERR_INVALID_ARG_TYPE(N,"number",P)}function HA(P,N,k){throw Math.floor(P)!==P?(jA(P,k),new sA.ERR_OUT_OF_RANGE("offset","an integer",P)):N<0?new sA.ERR_BUFFER_OUT_OF_BOUNDS:new sA.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${N}`,P)}const ce=/[^+/0-9A-Za-z-_]/g;function NA(P){if(P=P.split("=")[0],P=P.trim().replace(ce,""),P.length<2)return"";for(;P.length%4!==0;)P=P+"=";return P}function _A(P,N){N=N||1/0;let k;const _=P.length;let tA=null;const aA=[];for(let EA=0;EA<_;++EA){if(k=P.charCodeAt(EA),k>55295&&k<57344){if(!tA){if(k>56319){(N-=3)>-1&&aA.push(239,191,189);continue}else if(EA+1===_){(N-=3)>-1&&aA.push(239,191,189);continue}tA=k;continue}if(k<56320){(N-=3)>-1&&aA.push(239,191,189),tA=k;continue}k=(tA-55296<<10|k-56320)+65536}else tA&&(N-=3)>-1&&aA.push(239,191,189);if(tA=null,k<128){if((N-=1)<0)break;aA.push(k)}else if(k<2048){if((N-=2)<0)break;aA.push(k>>6|192,k&63|128)}else if(k<65536){if((N-=3)<0)break;aA.push(k>>12|224,k>>6&63|128,k&63|128)}else if(k<1114112){if((N-=4)<0)break;aA.push(k>>18|240,k>>12&63|128,k>>6&63|128,k&63|128)}else throw new Error("Invalid code point")}return aA}function we(P){const N=[];for(let k=0;k<P.length;++k)N.push(P.charCodeAt(k)&255);return N}function He(P,N){let k,_,tA;const aA=[];for(let EA=0;EA<P.length&&!((N-=2)<0);++EA)k=P.charCodeAt(EA),_=k>>8,tA=k%256,aA.push(tA),aA.push(_);return aA}function de(P){return e.toByteArray(NA(P))}function Ke(P,N,k,_){let tA;for(tA=0;tA<_&&!(tA+k>=N.length||tA>=P.length);++tA)N[tA+k]=P[tA];return tA}function nt(P,N){return P instanceof N||P!=null&&P.constructor!=null&&P.constructor.name!=null&&P.constructor.name===N.name}function Le(P){return P!==P}const kA=(function(){const P="0123456789abcdef",N=new Array(256);for(let k=0;k<16;++k){const _=k*16;for(let tA=0;tA<16;++tA)N[_+tA]=P[k]+P[tA]}return N})();function he(P){return typeof BigInt>"u"?zA:P}function zA(){throw new Error("BigInt not supported")}})(ki)),ki}var xt=Fg();const Ks=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Yr(A){return A instanceof Uint8Array||ArrayBuffer.isView(A)&&A.constructor.name==="Uint8Array"}function va(A){if(!Number.isSafeInteger(A)||A<0)throw new Error("positive integer expected, got "+A)}function ks(A,...e){if(!Yr(A))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(A.length))throw new Error("Uint8Array expected of length "+e+", got length="+A.length)}function qc(A){if(typeof A!="function"||typeof A.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");va(A.outputLen),va(A.blockLen)}function Gn(A,e=!0){if(A.destroyed)throw new Error("Hash instance has been destroyed");if(e&&A.finished)throw new Error("Hash#digest() has already been called")}function ox(A,e){ks(A);const t=e.outputLen;if(A.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function _s(...A){for(let e=0;e<A.length;e++)A[e].fill(0)}function Mi(A){return new DataView(A.buffer,A.byteOffset,A.byteLength)}function vo(A,e){return A<<32-e|A>>>e}const Yc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",sx=Array.from({length:256},(A,e)=>e.toString(16).padStart(2,"0"));function ms(A){if(ks(A),Yc)return A.toHex();let e="";for(let t=0;t<A.length;t++)e+=sx[A[t]];return e}const qo={_0:48,_9:57,A:65,F:70,a:97,f:102};function AQ(A){if(A>=qo._0&&A<=qo._9)return A-qo._0;if(A>=qo.A&&A<=qo.F)return A-(qo.A-10);if(A>=qo.a&&A<=qo.f)return A-(qo.a-10)}function Sn(A){if(typeof A!="string")throw new Error("hex string expected, got "+typeof A);if(Yc)return Uint8Array.fromHex(A);const e=A.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const s=new Uint8Array(t);for(let n=0,r=0;n<t;n++,r+=2){const i=AQ(A.charCodeAt(r)),a=AQ(A.charCodeAt(r+1));if(i===void 0||a===void 0){const g=A[r]+A[r+1];throw new Error('hex string expected, got non-hex character "'+g+'" at index '+r)}s[n]=i*16+a}return s}function rx(A){if(typeof A!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(A))}function vg(A){return typeof A=="string"&&(A=rx(A)),ks(A),A}function Go(...A){let e=0;for(let s=0;s<A.length;s++){const n=A[s];ks(n),e+=n.length}const t=new Uint8Array(e);for(let s=0,n=0;s<A.length;s++){const r=A[s];t.set(r,n),n+=r.length}return t}class Hc{}function Pc(A){const e=s=>A().update(vg(s)).digest(),t=A();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>A(),e}function Gg(A=32){if(Ks&&typeof Ks.getRandomValues=="function")return Ks.getRandomValues(new Uint8Array(A));if(Ks&&typeof Ks.randomBytes=="function")return Uint8Array.from(Ks.randomBytes(A));throw new Error("crypto.getRandomValues must be defined")}function nx(A,e,t,s){if(typeof A.setBigUint64=="function")return A.setBigUint64(e,t,s);const n=BigInt(32),r=BigInt(4294967295),i=Number(t>>n&r),a=Number(t&r),g=s?4:0,Q=s?0:4;A.setUint32(e+g,i,s),A.setUint32(e+Q,a,s)}function ix(A,e,t){return A&e^~A&t}function ax(A,e,t){return A&e^A&t^e&t}class Wc extends Hc{constructor(e,t,s,n){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=n,this.buffer=new Uint8Array(e),this.view=Mi(this.buffer)}update(e){Gn(this),e=vg(e),ks(e);const{view:t,buffer:s,blockLen:n}=this,r=e.length;for(let i=0;i<r;){const a=Math.min(n-this.pos,r-i);if(a===n){const g=Mi(e);for(;n<=r-i;i+=n)this.process(g,i);continue}s.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===n&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Gn(this),ox(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:n,isLE:r}=this;let{pos:i}=this;t[i++]=128,_s(this.buffer.subarray(i)),this.padOffset>n-i&&(this.process(s,0),i=0);for(let u=i;u<n;u++)t[u]=0;nx(s,n-8,BigInt(this.length*8),r),this.process(s,0);const a=Mi(e),g=this.outputLen;if(g%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const Q=g/4,B=this.get();if(Q>B.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<Q;u++)a.setUint32(4*u,B[u],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,n%t&&e.buffer.set(s),e}clone(){return this._cloneInto()}}const es=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Tt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),sn=BigInt(2**32-1),eQ=BigInt(32);function gx(A,e=!1){return e?{h:Number(A&sn),l:Number(A>>eQ&sn)}:{h:Number(A>>eQ&sn)|0,l:Number(A&sn)|0}}function lx(A,e=!1){const t=A.length;let s=new Uint32Array(t),n=new Uint32Array(t);for(let r=0;r<t;r++){const{h:i,l:a}=gx(A[r],e);[s[r],n[r]]=[i,a]}return[s,n]}const tQ=(A,e,t)=>A>>>t,oQ=(A,e,t)=>A<<32-t|e>>>t,Ls=(A,e,t)=>A>>>t|e<<32-t,Js=(A,e,t)=>A<<32-t|e>>>t,rn=(A,e,t)=>A<<64-t|e>>>t-32,nn=(A,e,t)=>A>>>t-32|e<<64-t;function Yo(A,e,t,s){const n=(e>>>0)+(s>>>0);return{h:A+t+(n/2**32|0)|0,l:n|0}}const Qx=(A,e,t)=>(A>>>0)+(e>>>0)+(t>>>0),Bx=(A,e,t,s)=>e+t+s+(A/2**32|0)|0,cx=(A,e,t,s)=>(A>>>0)+(e>>>0)+(t>>>0)+(s>>>0),Ex=(A,e,t,s,n)=>e+t+s+n+(A/2**32|0)|0,Cx=(A,e,t,s,n)=>(A>>>0)+(e>>>0)+(t>>>0)+(s>>>0)+(n>>>0),ux=(A,e,t,s,n,r)=>e+t+s+n+r+(A/2**32|0)|0,Ix=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ts=new Uint32Array(64);class dx extends Wc{constructor(e=32){super(64,e,8,!1),this.A=es[0]|0,this.B=es[1]|0,this.C=es[2]|0,this.D=es[3]|0,this.E=es[4]|0,this.F=es[5]|0,this.G=es[6]|0,this.H=es[7]|0}get(){const{A:e,B:t,C:s,D:n,E:r,F:i,G:a,H:g}=this;return[e,t,s,n,r,i,a,g]}set(e,t,s,n,r,i,a,g){this.A=e|0,this.B=t|0,this.C=s|0,this.D=n|0,this.E=r|0,this.F=i|0,this.G=a|0,this.H=g|0}process(e,t){for(let u=0;u<16;u++,t+=4)ts[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const E=ts[u-15],c=ts[u-2],h=vo(E,7)^vo(E,18)^E>>>3,f=vo(c,17)^vo(c,19)^c>>>10;ts[u]=f+ts[u-7]+h+ts[u-16]|0}let{A:s,B:n,C:r,D:i,E:a,F:g,G:Q,H:B}=this;for(let u=0;u<64;u++){const E=vo(a,6)^vo(a,11)^vo(a,25),c=B+E+ix(a,g,Q)+Ix[u]+ts[u]|0,f=(vo(s,2)^vo(s,13)^vo(s,22))+ax(s,n,r)|0;B=Q,Q=g,g=a,a=i+c|0,i=r,r=n,n=s,s=c+f|0}s=s+this.A|0,n=n+this.B|0,r=r+this.C|0,i=i+this.D|0,a=a+this.E|0,g=g+this.F|0,Q=Q+this.G|0,B=B+this.H|0,this.set(s,n,r,i,a,g,Q,B)}roundClean(){_s(ts)}destroy(){this.set(0,0,0,0,0,0,0,0),_s(this.buffer)}}const zc=lx(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(A=>BigInt(A))),hx=zc[0],px=zc[1],os=new Uint32Array(80),ss=new Uint32Array(80);class fx extends Wc{constructor(e=64){super(128,e,16,!1),this.Ah=Tt[0]|0,this.Al=Tt[1]|0,this.Bh=Tt[2]|0,this.Bl=Tt[3]|0,this.Ch=Tt[4]|0,this.Cl=Tt[5]|0,this.Dh=Tt[6]|0,this.Dl=Tt[7]|0,this.Eh=Tt[8]|0,this.El=Tt[9]|0,this.Fh=Tt[10]|0,this.Fl=Tt[11]|0,this.Gh=Tt[12]|0,this.Gl=Tt[13]|0,this.Hh=Tt[14]|0,this.Hl=Tt[15]|0}get(){const{Ah:e,Al:t,Bh:s,Bl:n,Ch:r,Cl:i,Dh:a,Dl:g,Eh:Q,El:B,Fh:u,Fl:E,Gh:c,Gl:h,Hh:f,Hl:d}=this;return[e,t,s,n,r,i,a,g,Q,B,u,E,c,h,f,d]}set(e,t,s,n,r,i,a,g,Q,B,u,E,c,h,f,d){this.Ah=e|0,this.Al=t|0,this.Bh=s|0,this.Bl=n|0,this.Ch=r|0,this.Cl=i|0,this.Dh=a|0,this.Dl=g|0,this.Eh=Q|0,this.El=B|0,this.Fh=u|0,this.Fl=E|0,this.Gh=c|0,this.Gl=h|0,this.Hh=f|0,this.Hl=d|0}process(e,t){for(let M=0;M<16;M++,t+=4)os[M]=e.getUint32(t),ss[M]=e.getUint32(t+=4);for(let M=16;M<80;M++){const q=os[M-15]|0,G=ss[M-15]|0,T=Ls(q,G,1)^Ls(q,G,8)^tQ(q,G,7),Z=Js(q,G,1)^Js(q,G,8)^oQ(q,G,7),X=os[M-2]|0,U=ss[M-2]|0,O=Ls(X,U,19)^rn(X,U,61)^tQ(X,U,6),j=Js(X,U,19)^nn(X,U,61)^oQ(X,U,6),Y=cx(Z,j,ss[M-7],ss[M-16]),x=Ex(Y,T,O,os[M-7],os[M-16]);os[M]=x|0,ss[M]=Y|0}let{Ah:s,Al:n,Bh:r,Bl:i,Ch:a,Cl:g,Dh:Q,Dl:B,Eh:u,El:E,Fh:c,Fl:h,Gh:f,Gl:d,Hh:D,Hl:R}=this;for(let M=0;M<80;M++){const q=Ls(u,E,14)^Ls(u,E,18)^rn(u,E,41),G=Js(u,E,14)^Js(u,E,18)^nn(u,E,41),T=u&c^~u&f,Z=E&h^~E&d,X=Cx(R,G,Z,px[M],ss[M]),U=ux(X,D,q,T,hx[M],os[M]),O=X|0,j=Ls(s,n,28)^rn(s,n,34)^rn(s,n,39),Y=Js(s,n,28)^nn(s,n,34)^nn(s,n,39),x=s&r^s&a^r&a,l=n&i^n&g^i&g;D=f|0,R=d|0,f=c|0,d=h|0,c=u|0,h=E|0,{h:u,l:E}=Yo(Q|0,B|0,U|0,O|0),Q=a|0,B=g|0,a=r|0,g=i|0,r=s|0,i=n|0;const I=Qx(O,Y,l);s=Bx(I,U,j,x),n=I|0}({h:s,l:n}=Yo(this.Ah|0,this.Al|0,s|0,n|0)),{h:r,l:i}=Yo(this.Bh|0,this.Bl|0,r|0,i|0),{h:a,l:g}=Yo(this.Ch|0,this.Cl|0,a|0,g|0),{h:Q,l:B}=Yo(this.Dh|0,this.Dl|0,Q|0,B|0),{h:u,l:E}=Yo(this.Eh|0,this.El|0,u|0,E|0),{h:c,l:h}=Yo(this.Fh|0,this.Fl|0,c|0,h|0),{h:f,l:d}=Yo(this.Gh|0,this.Gl|0,f|0,d|0),{h:D,l:R}=Yo(this.Hh|0,this.Hl|0,D|0,R|0),this.set(s,n,r,i,a,g,Q,B,u,E,c,h,f,d,D,R)}roundClean(){_s(os,ss)}destroy(){_s(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Vc=Pc(()=>new dx),mx=Pc(()=>new fx);const Sg=BigInt(0),Ga=BigInt(1);function Ds(A,e=""){if(typeof A!="boolean"){const t=e&&`"${e}"`;throw new Error(t+"expected boolean, got type="+typeof A)}return A}function xo(A,e,t=""){const s=Yr(A),n=A?.length,r=e!==void 0;if(!s||r&&n!==e){const i=t&&`"${t}" `,a=r?` of length ${e}`:"",g=s?`length=${n}`:`type=${typeof A}`;throw new Error(i+"expected Uint8Array"+a+", got "+g)}return A}function an(A){const e=A.toString(16);return e.length&1?"0"+e:e}function _c(A){if(typeof A!="string")throw new Error("hex string expected, got "+typeof A);return A===""?Sg:BigInt("0x"+A)}function ai(A){return _c(ms(A))}function Mr(A){return ks(A),_c(ms(Uint8Array.from(A).reverse()))}function Ug(A,e){return Sn(A.toString(16).padStart(e*2,"0"))}function Zc(A,e){return Ug(A,e).reverse()}function ut(A,e,t){let s;if(typeof e=="string")try{s=Sn(e)}catch(r){throw new Error(A+" must be hex string or Uint8Array, cause: "+r)}else if(Yr(e))s=Uint8Array.from(e);else throw new Error(A+" must be hex string or Uint8Array");const n=s.length;if(typeof t=="number"&&n!==t)throw new Error(A+" of length "+t+" expected, got "+n);return s}function sQ(A){return Uint8Array.from(A)}const bi=A=>typeof A=="bigint"&&Sg<=A;function wx(A,e,t){return bi(A)&&bi(e)&&bi(t)&&e<=A&&A<t}function Sa(A,e,t,s){if(!wx(e,t,s))throw new Error("expected valid "+A+": "+t+" <= n < "+s+", got "+e)}function Xc(A){let e;for(e=0;A>Sg;A>>=Ga,e+=1);return e}const Hr=A=>(Ga<<BigInt(A))-Ga;function xx(A,e,t){if(typeof A!="number"||A<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");const s=c=>new Uint8Array(c),n=c=>Uint8Array.of(c);let r=s(A),i=s(A),a=0;const g=()=>{r.fill(1),i.fill(0),a=0},Q=(...c)=>t(i,r,...c),B=(c=s(0))=>{i=Q(n(0),c),r=Q(),c.length!==0&&(i=Q(n(1),c),r=Q())},u=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let c=0;const h=[];for(;c<e;){r=Q();const f=r.slice();h.push(f),c+=r.length}return Go(...h)};return(c,h)=>{g(),B(c);let f;for(;!(f=h(u()));)B();return g(),f}}function Pr(A,e,t={}){if(!A||typeof A!="object")throw new Error("expected valid options object");function s(n,r,i){const a=A[n];if(i&&a===void 0)return;const g=typeof a;if(g!==r||a===null)throw new Error(`param "${n}" is invalid: expected ${r}, got ${g}`)}Object.entries(e).forEach(([n,r])=>s(n,r,!1)),Object.entries(t).forEach(([n,r])=>s(n,r,!0))}function Un(A){const e=new WeakMap;return(t,...s)=>{const n=e.get(t);if(n!==void 0)return n;const r=A(t,...s);return e.set(t,r),r}}const io=BigInt(0),St=BigInt(1),ds=BigInt(2),$c=BigInt(3),AE=BigInt(4),eE=BigInt(5),Dx=BigInt(7),tE=BigInt(8),yx=BigInt(9),oE=BigInt(16);function pt(A,e){const t=A%e;return t>=io?t:e+t}function Ct(A,e,t){let s=A;for(;e-- >io;)s*=s,s%=t;return s}function rQ(A,e){if(A===io)throw new Error("invert: expected non-zero number");if(e<=io)throw new Error("invert: expected positive modulus, got "+e);let t=pt(A,e),s=e,n=io,r=St;for(;t!==io;){const a=s/t,g=s%t,Q=n-r*a;s=t,t=g,n=r,r=Q}if(s!==St)throw new Error("invert: does not exist");return pt(n,e)}function Rg(A,e,t){if(!A.eql(A.sqr(e),t))throw new Error("Cannot find square root")}function sE(A,e){const t=(A.ORDER+St)/AE,s=A.pow(e,t);return Rg(A,s,e),s}function Nx(A,e){const t=(A.ORDER-eE)/tE,s=A.mul(e,ds),n=A.pow(s,t),r=A.mul(e,n),i=A.mul(A.mul(r,ds),n),a=A.mul(r,A.sub(i,A.ONE));return Rg(A,a,e),a}function kx(A){const e=Ms(A),t=rE(A),s=t(e,e.neg(e.ONE)),n=t(e,s),r=t(e,e.neg(s)),i=(A+Dx)/oE;return(a,g)=>{let Q=a.pow(g,i),B=a.mul(Q,s);const u=a.mul(Q,n),E=a.mul(Q,r),c=a.eql(a.sqr(B),g),h=a.eql(a.sqr(u),g);Q=a.cmov(Q,B,c),B=a.cmov(E,u,h);const f=a.eql(a.sqr(B),g),d=a.cmov(Q,B,f);return Rg(a,d,g),d}}function rE(A){if(A<$c)throw new Error("sqrt is not defined for small field");let e=A-St,t=0;for(;e%ds===io;)e/=ds,t++;let s=ds;const n=Ms(A);for(;nQ(n,s)===1;)if(s++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(t===1)return sE;let r=n.pow(s,e);const i=(e+St)/ds;return function(g,Q){if(g.is0(Q))return Q;if(nQ(g,Q)!==1)throw new Error("Cannot find square root");let B=t,u=g.mul(g.ONE,r),E=g.pow(Q,e),c=g.pow(Q,i);for(;!g.eql(E,g.ONE);){if(g.is0(E))return g.ZERO;let h=1,f=g.sqr(E);for(;!g.eql(f,g.ONE);)if(h++,f=g.sqr(f),h===B)throw new Error("Cannot find square root");const d=St<<BigInt(B-h-1),D=g.pow(u,d);B=h,u=g.sqr(D),E=g.mul(E,u),c=g.mul(c,D)}return c}}function Mx(A){return A%AE===$c?sE:A%tE===eE?Nx:A%oE===yx?kx(A):rE(A)}const bx=(A,e)=>(pt(A,e)&St)===St,Fx=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function vx(A){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},t=Fx.reduce((s,n)=>(s[n]="function",s),e);return Pr(A,t),A}function Gx(A,e,t){if(t<io)throw new Error("invalid exponent, negatives unsupported");if(t===io)return A.ONE;if(t===St)return e;let s=A.ONE,n=e;for(;t>io;)t&St&&(s=A.mul(s,n)),n=A.sqr(n),t>>=St;return s}function nE(A,e,t=!1){const s=new Array(e.length).fill(t?A.ZERO:void 0),n=e.reduce((i,a,g)=>A.is0(a)?i:(s[g]=i,A.mul(i,a)),A.ONE),r=A.inv(n);return e.reduceRight((i,a,g)=>A.is0(a)?i:(s[g]=A.mul(i,s[g]),A.mul(i,a)),r),s}function nQ(A,e){const t=(A.ORDER-St)/ds,s=A.pow(e,t),n=A.eql(s,A.ONE),r=A.eql(s,A.ZERO),i=A.eql(s,A.neg(A.ONE));if(!n&&!r&&!i)throw new Error("invalid Legendre symbol result");return n?1:r?0:-1}function iE(A,e){e!==void 0&&va(e);const t=e!==void 0?e:A.toString(2).length,s=Math.ceil(t/8);return{nBitLength:t,nByteLength:s}}function Ms(A,e,t=!1,s={}){if(A<=io)throw new Error("invalid field: expected ORDER > 0, got "+A);let n,r,i=!1,a;if(typeof e=="object"&&e!=null){if(s.sqrt||t)throw new Error("cannot specify opts in two arguments");const E=e;E.BITS&&(n=E.BITS),E.sqrt&&(r=E.sqrt),typeof E.isLE=="boolean"&&(t=E.isLE),typeof E.modFromBytes=="boolean"&&(i=E.modFromBytes),a=E.allowedLengths}else typeof e=="number"&&(n=e),s.sqrt&&(r=s.sqrt);const{nBitLength:g,nByteLength:Q}=iE(A,n);if(Q>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let B;const u=Object.freeze({ORDER:A,isLE:t,BITS:g,BYTES:Q,MASK:Hr(g),ZERO:io,ONE:St,allowedLengths:a,create:E=>pt(E,A),isValid:E=>{if(typeof E!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof E);return io<=E&&E<A},is0:E=>E===io,isValidNot0:E=>!u.is0(E)&&u.isValid(E),isOdd:E=>(E&St)===St,neg:E=>pt(-E,A),eql:(E,c)=>E===c,sqr:E=>pt(E*E,A),add:(E,c)=>pt(E+c,A),sub:(E,c)=>pt(E-c,A),mul:(E,c)=>pt(E*c,A),pow:(E,c)=>Gx(u,E,c),div:(E,c)=>pt(E*rQ(c,A),A),sqrN:E=>E*E,addN:(E,c)=>E+c,subN:(E,c)=>E-c,mulN:(E,c)=>E*c,inv:E=>rQ(E,A),sqrt:r||(E=>(B||(B=Mx(A)),B(u,E))),toBytes:E=>t?Zc(E,Q):Ug(E,Q),fromBytes:(E,c=!0)=>{if(a){if(!a.includes(E.length)||E.length>Q)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+E.length);const f=new Uint8Array(Q);f.set(E,t?0:f.length-E.length),E=f}if(E.length!==Q)throw new Error("Field.fromBytes: expected "+Q+" bytes, got "+E.length);let h=t?Mr(E):ai(E);if(i&&(h=pt(h,A)),!c&&!u.isValid(h))throw new Error("invalid field element: outside of range 0..ORDER");return h},invertBatch:E=>nE(u,E),cmov:(E,c,h)=>h?c:E});return Object.freeze(u)}function aE(A){if(typeof A!="bigint")throw new Error("field order must be bigint");const e=A.toString(2).length;return Math.ceil(e/8)}function gE(A){const e=aE(A);return e+Math.ceil(e/2)}function Sx(A,e,t=!1){const s=A.length,n=aE(e),r=gE(e);if(s<16||s<r||s>1024)throw new Error("expected "+r+"-1024 bytes of input, got "+s);const i=t?Mr(A):ai(A),a=pt(i,e-St)+St;return t?Zc(a,n):Ug(a,n)}const Zs=BigInt(0),hs=BigInt(1);function Rn(A,e){const t=e.negate();return A?t:e}function ps(A,e){const t=nE(A.Fp,e.map(s=>s.Z));return e.map((s,n)=>A.fromAffine(s.toAffine(t[n])))}function lE(A,e){if(!Number.isSafeInteger(A)||A<=0||A>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+A)}function Fi(A,e){lE(A,e);const t=Math.ceil(e/A)+1,s=2**(A-1),n=2**A,r=Hr(A),i=BigInt(A);return{windows:t,windowSize:s,mask:r,maxNumber:n,shiftBy:i}}function iQ(A,e,t){const{windowSize:s,mask:n,maxNumber:r,shiftBy:i}=t;let a=Number(A&n),g=A>>i;a>s&&(a-=r,g+=hs);const Q=e*s,B=Q+Math.abs(a)-1,u=a===0,E=a<0,c=e%2!==0;return{nextN:g,offset:B,isZero:u,isNeg:E,isNegF:c,offsetF:Q}}function Ux(A,e){if(!Array.isArray(A))throw new Error("array expected");A.forEach((t,s)=>{if(!(t instanceof e))throw new Error("invalid point at index "+s)})}function Rx(A,e){if(!Array.isArray(A))throw new Error("array of scalars expected");A.forEach((t,s)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+s)})}const vi=new WeakMap,QE=new WeakMap;function Gi(A){return QE.get(A)||1}function aQ(A){if(A!==Zs)throw new Error("invalid wNAF")}class BE{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t,s=this.ZERO){let n=e;for(;t>Zs;)t&hs&&(s=s.add(n)),n=n.double(),t>>=hs;return s}precomputeWindow(e,t){const{windows:s,windowSize:n}=Fi(t,this.bits),r=[];let i=e,a=i;for(let g=0;g<s;g++){a=i,r.push(a);for(let Q=1;Q<n;Q++)a=a.add(i),r.push(a);i=a.double()}return r}wNAF(e,t,s){if(!this.Fn.isValid(s))throw new Error("invalid scalar");let n=this.ZERO,r=this.BASE;const i=Fi(e,this.bits);for(let a=0;a<i.windows;a++){const{nextN:g,offset:Q,isZero:B,isNeg:u,isNegF:E,offsetF:c}=iQ(s,a,i);s=g,B?r=r.add(Rn(E,t[c])):n=n.add(Rn(u,t[Q]))}return aQ(s),{p:n,f:r}}wNAFUnsafe(e,t,s,n=this.ZERO){const r=Fi(e,this.bits);for(let i=0;i<r.windows&&s!==Zs;i++){const{nextN:a,offset:g,isZero:Q,isNeg:B}=iQ(s,i,r);if(s=a,!Q){const u=t[g];n=n.add(B?u.negate():u)}}return aQ(s),n}getPrecomputes(e,t,s){let n=vi.get(t);return n||(n=this.precomputeWindow(t,e),e!==1&&(typeof s=="function"&&(n=s(n)),vi.set(t,n))),n}cached(e,t,s){const n=Gi(e);return this.wNAF(n,this.getPrecomputes(n,e,s),t)}unsafe(e,t,s,n){const r=Gi(e);return r===1?this._unsafeLadder(e,t,n):this.wNAFUnsafe(r,this.getPrecomputes(r,e,s),t,n)}createCache(e,t){lE(t,this.bits),QE.set(e,t),vi.delete(e)}hasCache(e){return Gi(e)!==1}}function Kx(A,e,t,s){let n=e,r=A.ZERO,i=A.ZERO;for(;t>Zs||s>Zs;)t&hs&&(r=r.add(n)),s&hs&&(i=i.add(n)),n=n.double(),t>>=hs,s>>=hs;return{p1:r,p2:i}}function cE(A,e,t,s){Ux(t,A),Rx(s,e);const n=t.length,r=s.length;if(n!==r)throw new Error("arrays of points and scalars must have equal length");const i=A.ZERO,a=Xc(BigInt(n));let g=1;a>12?g=a-3:a>4?g=a-2:a>0&&(g=2);const Q=Hr(g),B=new Array(Number(Q)+1).fill(i),u=Math.floor((e.BITS-1)/g)*g;let E=i;for(let c=u;c>=0;c-=g){B.fill(i);for(let f=0;f<r;f++){const d=s[f],D=Number(d>>BigInt(c)&Q);B[D]=B[D].add(t[f])}let h=i;for(let f=B.length-1,d=i;f>0;f--)d=d.add(B[f]),h=h.add(d);if(E=E.add(h),c!==0)for(let f=0;f<g;f++)E=E.double()}return E}function gQ(A,e,t){if(e){if(e.ORDER!==A)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return vx(e),e}else return Ms(A,{isLE:t})}function EE(A,e,t={},s){if(s===void 0&&(s=A==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${A} CURVE object`);for(const g of["p","n","h"]){const Q=e[g];if(!(typeof Q=="bigint"&&Q>Zs))throw new Error(`CURVE.${g} must be positive bigint`)}const n=gQ(e.p,t.Fp,s),r=gQ(e.n,t.Fn,s),a=["Gx","Gy","a",A==="weierstrass"?"b":"d"];for(const g of a)if(!n.isValid(e[g]))throw new Error(`CURVE.${g} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:n,Fn:r}}const rs=BigInt(0),Nt=BigInt(1),Si=BigInt(2),Lx=BigInt(8);function Jx(A,e,t,s){const n=A.sqr(t),r=A.sqr(s),i=A.add(A.mul(e.a,n),r),a=A.add(A.ONE,A.mul(e.d,A.mul(n,r)));return A.eql(i,a)}function Tx(A,e={}){const t=EE("edwards",A,e,e.FpFnLE),{Fp:s,Fn:n}=t;let r=t.CURVE;const{h:i}=r;Pr(e,{},{uvRatio:"function"});const a=Si<<BigInt(n.BYTES*8)-Nt,g=d=>s.create(d),Q=e.uvRatio||((d,D)=>{try{return{isValid:!0,value:s.sqrt(s.div(d,D))}}catch{return{isValid:!1,value:rs}}});if(!Jx(s,r,r.Gx,r.Gy))throw new Error("bad curve params: generator point");function B(d,D,R=!1){const M=R?Nt:rs;return Sa("coordinate "+d,D,M,a),D}function u(d){if(!(d instanceof h))throw new Error("ExtendedPoint expected")}const E=Un((d,D)=>{const{X:R,Y:M,Z:q}=d,G=d.is0();D==null&&(D=G?Lx:s.inv(q));const T=g(R*D),Z=g(M*D),X=s.mul(q,D);if(G)return{x:rs,y:Nt};if(X!==Nt)throw new Error("invZ was invalid");return{x:T,y:Z}}),c=Un(d=>{const{a:D,d:R}=r;if(d.is0())throw new Error("bad point: ZERO");const{X:M,Y:q,Z:G,T}=d,Z=g(M*M),X=g(q*q),U=g(G*G),O=g(U*U),j=g(Z*D),Y=g(U*g(j+X)),x=g(O+g(R*g(Z*X)));if(Y!==x)throw new Error("bad point: equation left != right (1)");const l=g(M*q),I=g(G*T);if(l!==I)throw new Error("bad point: equation left != right (2)");return!0});class h{constructor(D,R,M,q){this.X=B("x",D),this.Y=B("y",R),this.Z=B("z",M,!0),this.T=B("t",q),Object.freeze(this)}static CURVE(){return r}static fromAffine(D){if(D instanceof h)throw new Error("extended point not allowed");const{x:R,y:M}=D||{};return B("x",R),B("y",M),new h(R,M,Nt,g(R*M))}static fromBytes(D,R=!1){const M=s.BYTES,{a:q,d:G}=r;D=sQ(xo(D,M,"point")),Ds(R,"zip215");const T=sQ(D),Z=D[M-1];T[M-1]=Z&-129;const X=Mr(T),U=R?a:s.ORDER;Sa("point.y",X,rs,U);const O=g(X*X),j=g(O-Nt),Y=g(G*O-q);let{isValid:x,value:l}=Q(j,Y);if(!x)throw new Error("bad point: invalid y coordinate");const I=(l&Nt)===Nt,y=(Z&128)!==0;if(!R&&l===rs&&y)throw new Error("bad point: x=0 and x_0=1");return y!==I&&(l=g(-l)),h.fromAffine({x:l,y:X})}static fromHex(D,R=!1){return h.fromBytes(ut("point",D),R)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(D=8,R=!0){return f.createCache(this,D),R||this.multiply(Si),this}assertValidity(){c(this)}equals(D){u(D);const{X:R,Y:M,Z:q}=this,{X:G,Y:T,Z}=D,X=g(R*Z),U=g(G*q),O=g(M*Z),j=g(T*q);return X===U&&O===j}is0(){return this.equals(h.ZERO)}negate(){return new h(g(-this.X),this.Y,this.Z,g(-this.T))}double(){const{a:D}=r,{X:R,Y:M,Z:q}=this,G=g(R*R),T=g(M*M),Z=g(Si*g(q*q)),X=g(D*G),U=R+M,O=g(g(U*U)-G-T),j=X+T,Y=j-Z,x=X-T,l=g(O*Y),I=g(j*x),y=g(O*x),b=g(Y*j);return new h(l,I,b,y)}add(D){u(D);const{a:R,d:M}=r,{X:q,Y:G,Z:T,T:Z}=this,{X,Y:U,Z:O,T:j}=D,Y=g(q*X),x=g(G*U),l=g(Z*M*j),I=g(T*O),y=g((q+G)*(X+U)-Y-x),b=I-l,J=I+l,H=g(x-R*Y),v=g(y*b),K=g(J*H),C=g(y*H),p=g(b*J);return new h(v,K,p,C)}subtract(D){return this.add(D.negate())}multiply(D){if(!n.isValidNot0(D))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:R,f:M}=f.cached(this,D,q=>ps(h,q));return ps(h,[R,M])[0]}multiplyUnsafe(D,R=h.ZERO){if(!n.isValid(D))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return D===rs?h.ZERO:this.is0()||D===Nt?this:f.unsafe(this,D,M=>ps(h,M),R)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return f.unsafe(this,r.n).is0()}toAffine(D){return E(this,D)}clearCofactor(){return i===Nt?this:this.multiplyUnsafe(i)}toBytes(){const{x:D,y:R}=this.toAffine(),M=s.toBytes(R);return M[M.length-1]|=D&Nt?128:0,M}toHex(){return ms(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(D){return ps(h,D)}static msm(D,R){return cE(h,n,D,R)}_setWindowSize(D){this.precompute(D)}toRawBytes(){return this.toBytes()}}h.BASE=new h(r.Gx,r.Gy,Nt,g(r.Gx*r.Gy)),h.ZERO=new h(rs,Nt,Nt,rs),h.Fp=s,h.Fn=n;const f=new BE(h,n.BITS);return h.BASE.precompute(8),h}function jx(A,e,t={}){if(typeof e!="function")throw new Error('"hash" function param is required');Pr(t,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:s}=t,{BASE:n,Fp:r,Fn:i}=A,a=t.randomBytes||Gg,g=t.adjustScalarBytes||(U=>U),Q=t.domain||((U,O,j)=>{if(Ds(j,"phflag"),O.length||j)throw new Error("Contexts/pre-hash are not supported");return U});function B(U){return i.create(Mr(U))}function u(U){const O=M.secretKey;U=ut("private key",U,O);const j=ut("hashed private key",e(U),2*O),Y=g(j.slice(0,O)),x=j.slice(O,2*O),l=B(Y);return{head:Y,prefix:x,scalar:l}}function E(U){const{head:O,prefix:j,scalar:Y}=u(U),x=n.multiply(Y),l=x.toBytes();return{head:O,prefix:j,scalar:Y,point:x,pointBytes:l}}function c(U){return E(U).pointBytes}function h(U=Uint8Array.of(),...O){const j=Go(...O);return B(e(Q(j,ut("context",U),!!s)))}function f(U,O,j={}){U=ut("message",U),s&&(U=s(U));const{prefix:Y,scalar:x,pointBytes:l}=E(O),I=h(j.context,Y,U),y=n.multiply(I).toBytes(),b=h(j.context,y,l,U),J=i.create(I+b*x);if(!i.isValid(J))throw new Error("sign failed: invalid s");const H=Go(y,i.toBytes(J));return xo(H,M.signature,"result")}const d={zip215:!0};function D(U,O,j,Y=d){const{context:x,zip215:l}=Y,I=M.signature;U=ut("signature",U,I),O=ut("message",O),j=ut("publicKey",j,M.publicKey),l!==void 0&&Ds(l,"zip215"),s&&(O=s(O));const y=I/2,b=U.subarray(0,y),J=Mr(U.subarray(y,I));let H,v,K;try{H=A.fromBytes(j,l),v=A.fromBytes(b,l),K=n.multiplyUnsafe(J)}catch{return!1}if(!l&&H.isSmallOrder())return!1;const C=h(x,v.toBytes(),H.toBytes(),O);return v.add(H.multiplyUnsafe(C)).subtract(K).clearCofactor().is0()}const R=r.BYTES,M={secretKey:R,publicKey:R,signature:2*R,seed:R};function q(U=a(M.seed)){return xo(U,M.seed,"seed")}function G(U){const O=X.randomSecretKey(U);return{secretKey:O,publicKey:c(O)}}function T(U){return Yr(U)&&U.length===i.BYTES}function Z(U,O){try{return!!A.fromBytes(U,O)}catch{return!1}}const X={getExtendedPublicKey:E,randomSecretKey:q,isValidSecretKey:T,isValidPublicKey:Z,toMontgomery(U){const{y:O}=A.fromBytes(U),j=M.publicKey,Y=j===32;if(!Y&&j!==57)throw new Error("only defined for 25519 and 448");const x=Y?r.div(Nt+O,Nt-O):r.div(O-Nt,O+Nt);return r.toBytes(x)},toMontgomerySecret(U){const O=M.secretKey;xo(U,O);const j=e(U.subarray(0,O));return g(j).subarray(0,O)},randomPrivateKey:q,precompute(U=8,O=A.BASE){return O.precompute(U,!1)}};return Object.freeze({keygen:G,getPublicKey:c,sign:f,verify:D,utils:X,Point:A,lengths:M})}function Ox(A){const e={a:A.a,d:A.d,p:A.Fp.ORDER,n:A.n,h:A.h,Gx:A.Gx,Gy:A.Gy},t=A.Fp,s=Ms(e.n,A.nBitLength,!0),n={Fp:t,Fn:s,uvRatio:A.uvRatio},r={randomBytes:A.randomBytes,adjustScalarBytes:A.adjustScalarBytes,domain:A.domain,prehash:A.prehash,mapToCurve:A.mapToCurve};return{CURVE:e,curveOpts:n,hash:A.hash,eddsaOpts:r}}function qx(A,e){const t=e.Point;return Object.assign({},e,{ExtendedPoint:t,CURVE:A,nBitLength:t.Fn.BITS,nByteLength:t.Fn.BYTES})}function Yx(A){const{CURVE:e,curveOpts:t,hash:s,eddsaOpts:n}=Ox(A),r=Tx(e,t),i=jx(r,s,n);return qx(A,i)}const Hx=BigInt(1),lQ=BigInt(2);BigInt(3);const Px=BigInt(5),Wx=BigInt(8),Kg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),CE={p:Kg,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Wx,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function zx(A){const e=BigInt(10),t=BigInt(20),s=BigInt(40),n=BigInt(80),r=Kg,a=A*A%r*A%r,g=Ct(a,lQ,r)*a%r,Q=Ct(g,Hx,r)*A%r,B=Ct(Q,Px,r)*Q%r,u=Ct(B,e,r)*B%r,E=Ct(u,t,r)*u%r,c=Ct(E,s,r)*E%r,h=Ct(c,n,r)*c%r,f=Ct(h,n,r)*c%r,d=Ct(f,e,r)*B%r;return{pow_p_5_8:Ct(d,lQ,r)*A%r,b2:a}}function Vx(A){return A[0]&=248,A[31]&=127,A[31]|=64,A}const QQ=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function _x(A,e){const t=Kg,s=pt(e*e*e,t),n=pt(s*s*e,t),r=zx(A*n).pow_p_5_8;let i=pt(A*s*r,t);const a=pt(e*i*i,t),g=i,Q=pt(i*QQ,t),B=a===A,u=a===pt(-A,t),E=a===pt(-A*QQ,t);return B&&(i=g),(u||E)&&(i=Q),bx(i,t)&&(i=pt(-i,t)),{isValid:B||u,value:i}}const Zx=Ms(CE.p,{isLE:!0}),Xx={...CE,Fp:Zx,hash:mx,adjustScalarBytes:Vx,uvRatio:_x},gi=Yx(Xx);var wn={exports:{}};const $x={},AD=Object.freeze(Object.defineProperty({__proto__:null,default:$x},Symbol.toStringTag,{value:"Module"})),uE=za(AD);var eD=wn.exports,BQ;function IE(){return BQ||(BQ=1,(function(A){(function(e,t){function s(x,l){if(!x)throw new Error(l||"Assertion failed")}function n(x,l){x.super_=l;var I=function(){};I.prototype=l.prototype,x.prototype=new I,x.prototype.constructor=x}function r(x,l,I){if(r.isBN(x))return x;this.negative=0,this.words=null,this.length=0,this.red=null,x!==null&&((l==="le"||l==="be")&&(I=l,l=10),this._init(x||0,l||10,I||"be"))}typeof e=="object"?e.exports=r:t.BN=r,r.BN=r,r.wordSize=26;var i;try{typeof window<"u"&&typeof window.Buffer<"u"?i=window.Buffer:i=uE.Buffer}catch{}r.isBN=function(l){return l instanceof r?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===r.wordSize&&Array.isArray(l.words)},r.max=function(l,I){return l.cmp(I)>0?l:I},r.min=function(l,I){return l.cmp(I)<0?l:I},r.prototype._init=function(l,I,y){if(typeof l=="number")return this._initNumber(l,I,y);if(typeof l=="object")return this._initArray(l,I,y);I==="hex"&&(I=16),s(I===(I|0)&&I>=2&&I<=36),l=l.toString().replace(/\s+/g,"");var b=0;l[0]==="-"&&(b++,this.negative=1),b<l.length&&(I===16?this._parseHex(l,b,y):(this._parseBase(l,I,b),y==="le"&&this._initArray(this.toArray(),I,y)))},r.prototype._initNumber=function(l,I,y){l<0&&(this.negative=1,l=-l),l<67108864?(this.words=[l&67108863],this.length=1):l<4503599627370496?(this.words=[l&67108863,l/67108864&67108863],this.length=2):(s(l<9007199254740992),this.words=[l&67108863,l/67108864&67108863,1],this.length=3),y==="le"&&this._initArray(this.toArray(),I,y)},r.prototype._initArray=function(l,I,y){if(s(typeof l.length=="number"),l.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(l.length/3),this.words=new Array(this.length);for(var b=0;b<this.length;b++)this.words[b]=0;var J,H,v=0;if(y==="be")for(b=l.length-1,J=0;b>=0;b-=3)H=l[b]|l[b-1]<<8|l[b-2]<<16,this.words[J]|=H<<v&67108863,this.words[J+1]=H>>>26-v&67108863,v+=24,v>=26&&(v-=26,J++);else if(y==="le")for(b=0,J=0;b<l.length;b+=3)H=l[b]|l[b+1]<<8|l[b+2]<<16,this.words[J]|=H<<v&67108863,this.words[J+1]=H>>>26-v&67108863,v+=24,v>=26&&(v-=26,J++);return this._strip()};function a(x,l){var I=x.charCodeAt(l);if(I>=48&&I<=57)return I-48;if(I>=65&&I<=70)return I-55;if(I>=97&&I<=102)return I-87;s(!1,"Invalid character in "+x)}function g(x,l,I){var y=a(x,I);return I-1>=l&&(y|=a(x,I-1)<<4),y}r.prototype._parseHex=function(l,I,y){this.length=Math.ceil((l.length-I)/6),this.words=new Array(this.length);for(var b=0;b<this.length;b++)this.words[b]=0;var J=0,H=0,v;if(y==="be")for(b=l.length-1;b>=I;b-=2)v=g(l,I,b)<<J,this.words[H]|=v&67108863,J>=18?(J-=18,H+=1,this.words[H]|=v>>>26):J+=8;else{var K=l.length-I;for(b=K%2===0?I+1:I;b<l.length;b+=2)v=g(l,I,b)<<J,this.words[H]|=v&67108863,J>=18?(J-=18,H+=1,this.words[H]|=v>>>26):J+=8}this._strip()};function Q(x,l,I,y){for(var b=0,J=0,H=Math.min(x.length,I),v=l;v<H;v++){var K=x.charCodeAt(v)-48;b*=y,K>=49?J=K-49+10:K>=17?J=K-17+10:J=K,s(K>=0&&J<y,"Invalid character"),b+=J}return b}r.prototype._parseBase=function(l,I,y){this.words=[0],this.length=1;for(var b=0,J=1;J<=67108863;J*=I)b++;b--,J=J/I|0;for(var H=l.length-y,v=H%b,K=Math.min(H,H-v)+y,C=0,p=y;p<K;p+=b)C=Q(l,p,p+b,I),this.imuln(J),this.words[0]+C<67108864?this.words[0]+=C:this._iaddn(C);if(v!==0){var L=1;for(C=Q(l,p,l.length,I),p=0;p<v;p++)L*=I;this.imuln(L),this.words[0]+C<67108864?this.words[0]+=C:this._iaddn(C)}this._strip()},r.prototype.copy=function(l){l.words=new Array(this.length);for(var I=0;I<this.length;I++)l.words[I]=this.words[I];l.length=this.length,l.negative=this.negative,l.red=this.red};function B(x,l){x.words=l.words,x.length=l.length,x.negative=l.negative,x.red=l.red}if(r.prototype._move=function(l){B(l,this)},r.prototype.clone=function(){var l=new r(null);return this.copy(l),l},r.prototype._expand=function(l){for(;this.length<l;)this.words[this.length++]=0;return this},r.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},r.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{r.prototype[Symbol.for("nodejs.util.inspect.custom")]=u}catch{r.prototype.inspect=u}else r.prototype.inspect=u;function u(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var E=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],h=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];r.prototype.toString=function(l,I){l=l||10,I=I|0||1;var y;if(l===16||l==="hex"){y="";for(var b=0,J=0,H=0;H<this.length;H++){var v=this.words[H],K=((v<<b|J)&16777215).toString(16);J=v>>>24-b&16777215,b+=2,b>=26&&(b-=26,H--),J!==0||H!==this.length-1?y=E[6-K.length]+K+y:y=K+y}for(J!==0&&(y=J.toString(16)+y);y.length%I!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}if(l===(l|0)&&l>=2&&l<=36){var C=c[l],p=h[l];y="";var L=this.clone();for(L.negative=0;!L.isZero();){var S=L.modrn(p).toString(l);L=L.idivn(p),L.isZero()?y=S+y:y=E[C-S.length]+S+y}for(this.isZero()&&(y="0"+y);y.length%I!==0;)y="0"+y;return this.negative!==0&&(y="-"+y),y}s(!1,"Base should be between 2 and 36")},r.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&s(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},r.prototype.toJSON=function(){return this.toString(16,2)},i&&(r.prototype.toBuffer=function(l,I){return this.toArrayLike(i,l,I)}),r.prototype.toArray=function(l,I){return this.toArrayLike(Array,l,I)};var f=function(l,I){return l.allocUnsafe?l.allocUnsafe(I):new l(I)};r.prototype.toArrayLike=function(l,I,y){this._strip();var b=this.byteLength(),J=y||Math.max(1,b);s(b<=J,"byte array longer than desired length"),s(J>0,"Requested array length <= 0");var H=f(l,J),v=I==="le"?"LE":"BE";return this["_toArrayLike"+v](H,b),H},r.prototype._toArrayLikeLE=function(l,I){for(var y=0,b=0,J=0,H=0;J<this.length;J++){var v=this.words[J]<<H|b;l[y++]=v&255,y<l.length&&(l[y++]=v>>8&255),y<l.length&&(l[y++]=v>>16&255),H===6?(y<l.length&&(l[y++]=v>>24&255),b=0,H=0):(b=v>>>24,H+=2)}if(y<l.length)for(l[y++]=b;y<l.length;)l[y++]=0},r.prototype._toArrayLikeBE=function(l,I){for(var y=l.length-1,b=0,J=0,H=0;J<this.length;J++){var v=this.words[J]<<H|b;l[y--]=v&255,y>=0&&(l[y--]=v>>8&255),y>=0&&(l[y--]=v>>16&255),H===6?(y>=0&&(l[y--]=v>>24&255),b=0,H=0):(b=v>>>24,H+=2)}if(y>=0)for(l[y--]=b;y>=0;)l[y--]=0},Math.clz32?r.prototype._countBits=function(l){return 32-Math.clz32(l)}:r.prototype._countBits=function(l){var I=l,y=0;return I>=4096&&(y+=13,I>>>=13),I>=64&&(y+=7,I>>>=7),I>=8&&(y+=4,I>>>=4),I>=2&&(y+=2,I>>>=2),y+I},r.prototype._zeroBits=function(l){if(l===0)return 26;var I=l,y=0;return(I&8191)===0&&(y+=13,I>>>=13),(I&127)===0&&(y+=7,I>>>=7),(I&15)===0&&(y+=4,I>>>=4),(I&3)===0&&(y+=2,I>>>=2),(I&1)===0&&y++,y},r.prototype.bitLength=function(){var l=this.words[this.length-1],I=this._countBits(l);return(this.length-1)*26+I};function d(x){for(var l=new Array(x.bitLength()),I=0;I<l.length;I++){var y=I/26|0,b=I%26;l[I]=x.words[y]>>>b&1}return l}r.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,I=0;I<this.length;I++){var y=this._zeroBits(this.words[I]);if(l+=y,y!==26)break}return l},r.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},r.prototype.toTwos=function(l){return this.negative!==0?this.abs().inotn(l).iaddn(1):this.clone()},r.prototype.fromTwos=function(l){return this.testn(l-1)?this.notn(l).iaddn(1).ineg():this.clone()},r.prototype.isNeg=function(){return this.negative!==0},r.prototype.neg=function(){return this.clone().ineg()},r.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},r.prototype.iuor=function(l){for(;this.length<l.length;)this.words[this.length++]=0;for(var I=0;I<l.length;I++)this.words[I]=this.words[I]|l.words[I];return this._strip()},r.prototype.ior=function(l){return s((this.negative|l.negative)===0),this.iuor(l)},r.prototype.or=function(l){return this.length>l.length?this.clone().ior(l):l.clone().ior(this)},r.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},r.prototype.iuand=function(l){var I;this.length>l.length?I=l:I=this;for(var y=0;y<I.length;y++)this.words[y]=this.words[y]&l.words[y];return this.length=I.length,this._strip()},r.prototype.iand=function(l){return s((this.negative|l.negative)===0),this.iuand(l)},r.prototype.and=function(l){return this.length>l.length?this.clone().iand(l):l.clone().iand(this)},r.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},r.prototype.iuxor=function(l){var I,y;this.length>l.length?(I=this,y=l):(I=l,y=this);for(var b=0;b<y.length;b++)this.words[b]=I.words[b]^y.words[b];if(this!==I)for(;b<I.length;b++)this.words[b]=I.words[b];return this.length=I.length,this._strip()},r.prototype.ixor=function(l){return s((this.negative|l.negative)===0),this.iuxor(l)},r.prototype.xor=function(l){return this.length>l.length?this.clone().ixor(l):l.clone().ixor(this)},r.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},r.prototype.inotn=function(l){s(typeof l=="number"&&l>=0);var I=Math.ceil(l/26)|0,y=l%26;this._expand(I),y>0&&I--;for(var b=0;b<I;b++)this.words[b]=~this.words[b]&67108863;return y>0&&(this.words[b]=~this.words[b]&67108863>>26-y),this._strip()},r.prototype.notn=function(l){return this.clone().inotn(l)},r.prototype.setn=function(l,I){s(typeof l=="number"&&l>=0);var y=l/26|0,b=l%26;return this._expand(y+1),I?this.words[y]=this.words[y]|1<<b:this.words[y]=this.words[y]&~(1<<b),this._strip()},r.prototype.iadd=function(l){var I;if(this.negative!==0&&l.negative===0)return this.negative=0,I=this.isub(l),this.negative^=1,this._normSign();if(this.negative===0&&l.negative!==0)return l.negative=0,I=this.isub(l),l.negative=1,I._normSign();var y,b;this.length>l.length?(y=this,b=l):(y=l,b=this);for(var J=0,H=0;H<b.length;H++)I=(y.words[H]|0)+(b.words[H]|0)+J,this.words[H]=I&67108863,J=I>>>26;for(;J!==0&&H<y.length;H++)I=(y.words[H]|0)+J,this.words[H]=I&67108863,J=I>>>26;if(this.length=y.length,J!==0)this.words[this.length]=J,this.length++;else if(y!==this)for(;H<y.length;H++)this.words[H]=y.words[H];return this},r.prototype.add=function(l){var I;return l.negative!==0&&this.negative===0?(l.negative=0,I=this.sub(l),l.negative^=1,I):l.negative===0&&this.negative!==0?(this.negative=0,I=l.sub(this),this.negative=1,I):this.length>l.length?this.clone().iadd(l):l.clone().iadd(this)},r.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var I=this.iadd(l);return l.negative=1,I._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var y=this.cmp(l);if(y===0)return this.negative=0,this.length=1,this.words[0]=0,this;var b,J;y>0?(b=this,J=l):(b=l,J=this);for(var H=0,v=0;v<J.length;v++)I=(b.words[v]|0)-(J.words[v]|0)+H,H=I>>26,this.words[v]=I&67108863;for(;H!==0&&v<b.length;v++)I=(b.words[v]|0)+H,H=I>>26,this.words[v]=I&67108863;if(H===0&&v<b.length&&b!==this)for(;v<b.length;v++)this.words[v]=b.words[v];return this.length=Math.max(this.length,v),b!==this&&(this.negative=1),this._strip()},r.prototype.sub=function(l){return this.clone().isub(l)};function D(x,l,I){I.negative=l.negative^x.negative;var y=x.length+l.length|0;I.length=y,y=y-1|0;var b=x.words[0]|0,J=l.words[0]|0,H=b*J,v=H&67108863,K=H/67108864|0;I.words[0]=v;for(var C=1;C<y;C++){for(var p=K>>>26,L=K&67108863,S=Math.min(C,l.length-1),$=Math.max(0,C-x.length+1);$<=S;$++){var AA=C-$|0;b=x.words[AA]|0,J=l.words[$]|0,H=b*J+L,p+=H/67108864|0,L=H&67108863}I.words[C]=L|0,K=p|0}return K!==0?I.words[C]=K|0:I.length--,I._strip()}var R=function(l,I,y){var b=l.words,J=I.words,H=y.words,v=0,K,C,p,L=b[0]|0,S=L&8191,$=L>>>13,AA=b[1]|0,sA=AA&8191,oA=AA>>>13,bA=b[2]|0,GA=bA&8191,lA=bA>>>13,jA=b[3]|0,HA=jA&8191,ce=jA>>>13,NA=b[4]|0,_A=NA&8191,we=NA>>>13,He=b[5]|0,de=He&8191,Ke=He>>>13,nt=b[6]|0,Le=nt&8191,kA=nt>>>13,he=b[7]|0,zA=he&8191,P=he>>>13,N=b[8]|0,k=N&8191,_=N>>>13,tA=b[9]|0,aA=tA&8191,EA=tA>>>13,ZA=J[0]|0,VA=ZA&8191,$A=ZA>>>13,ke=J[1]|0,XA=ke&8191,ye=ke>>>13,Kt=J[2]|0,Je=Kt&8191,je=Kt>>>13,To=J[3]|0,Be=To&8191,ve=To>>>13,Lt=J[4]|0,Oe=Lt&8191,ze=Lt>>>13,co=J[5]|0,KA=co&8191,se=co>>>13,_t=J[6]|0,F=_t&8191,W=_t>>>13,z=J[7]|0,w=z&8191,V=z>>>13,nA=J[8]|0,rA=nA&8191,IA=nA>>>13,yA=J[9]|0,FA=yA&8191,xA=yA>>>13;y.negative=l.negative^I.negative,y.length=19,K=Math.imul(S,VA),C=Math.imul(S,$A),C=C+Math.imul($,VA)|0,p=Math.imul($,$A);var Ee=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,K=Math.imul(sA,VA),C=Math.imul(sA,$A),C=C+Math.imul(oA,VA)|0,p=Math.imul(oA,$A),K=K+Math.imul(S,XA)|0,C=C+Math.imul(S,ye)|0,C=C+Math.imul($,XA)|0,p=p+Math.imul($,ye)|0;var RA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(RA>>>26)|0,RA&=67108863,K=Math.imul(GA,VA),C=Math.imul(GA,$A),C=C+Math.imul(lA,VA)|0,p=Math.imul(lA,$A),K=K+Math.imul(sA,XA)|0,C=C+Math.imul(sA,ye)|0,C=C+Math.imul(oA,XA)|0,p=p+Math.imul(oA,ye)|0,K=K+Math.imul(S,Je)|0,C=C+Math.imul(S,je)|0,C=C+Math.imul($,Je)|0,p=p+Math.imul($,je)|0;var Ae=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,K=Math.imul(HA,VA),C=Math.imul(HA,$A),C=C+Math.imul(ce,VA)|0,p=Math.imul(ce,$A),K=K+Math.imul(GA,XA)|0,C=C+Math.imul(GA,ye)|0,C=C+Math.imul(lA,XA)|0,p=p+Math.imul(lA,ye)|0,K=K+Math.imul(sA,Je)|0,C=C+Math.imul(sA,je)|0,C=C+Math.imul(oA,Je)|0,p=p+Math.imul(oA,je)|0,K=K+Math.imul(S,Be)|0,C=C+Math.imul(S,ve)|0,C=C+Math.imul($,Be)|0,p=p+Math.imul($,ve)|0;var ie=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(ie>>>26)|0,ie&=67108863,K=Math.imul(_A,VA),C=Math.imul(_A,$A),C=C+Math.imul(we,VA)|0,p=Math.imul(we,$A),K=K+Math.imul(HA,XA)|0,C=C+Math.imul(HA,ye)|0,C=C+Math.imul(ce,XA)|0,p=p+Math.imul(ce,ye)|0,K=K+Math.imul(GA,Je)|0,C=C+Math.imul(GA,je)|0,C=C+Math.imul(lA,Je)|0,p=p+Math.imul(lA,je)|0,K=K+Math.imul(sA,Be)|0,C=C+Math.imul(sA,ve)|0,C=C+Math.imul(oA,Be)|0,p=p+Math.imul(oA,ve)|0,K=K+Math.imul(S,Oe)|0,C=C+Math.imul(S,ze)|0,C=C+Math.imul($,Oe)|0,p=p+Math.imul($,ze)|0;var le=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(le>>>26)|0,le&=67108863,K=Math.imul(de,VA),C=Math.imul(de,$A),C=C+Math.imul(Ke,VA)|0,p=Math.imul(Ke,$A),K=K+Math.imul(_A,XA)|0,C=C+Math.imul(_A,ye)|0,C=C+Math.imul(we,XA)|0,p=p+Math.imul(we,ye)|0,K=K+Math.imul(HA,Je)|0,C=C+Math.imul(HA,je)|0,C=C+Math.imul(ce,Je)|0,p=p+Math.imul(ce,je)|0,K=K+Math.imul(GA,Be)|0,C=C+Math.imul(GA,ve)|0,C=C+Math.imul(lA,Be)|0,p=p+Math.imul(lA,ve)|0,K=K+Math.imul(sA,Oe)|0,C=C+Math.imul(sA,ze)|0,C=C+Math.imul(oA,Oe)|0,p=p+Math.imul(oA,ze)|0,K=K+Math.imul(S,KA)|0,C=C+Math.imul(S,se)|0,C=C+Math.imul($,KA)|0,p=p+Math.imul($,se)|0;var ae=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(ae>>>26)|0,ae&=67108863,K=Math.imul(Le,VA),C=Math.imul(Le,$A),C=C+Math.imul(kA,VA)|0,p=Math.imul(kA,$A),K=K+Math.imul(de,XA)|0,C=C+Math.imul(de,ye)|0,C=C+Math.imul(Ke,XA)|0,p=p+Math.imul(Ke,ye)|0,K=K+Math.imul(_A,Je)|0,C=C+Math.imul(_A,je)|0,C=C+Math.imul(we,Je)|0,p=p+Math.imul(we,je)|0,K=K+Math.imul(HA,Be)|0,C=C+Math.imul(HA,ve)|0,C=C+Math.imul(ce,Be)|0,p=p+Math.imul(ce,ve)|0,K=K+Math.imul(GA,Oe)|0,C=C+Math.imul(GA,ze)|0,C=C+Math.imul(lA,Oe)|0,p=p+Math.imul(lA,ze)|0,K=K+Math.imul(sA,KA)|0,C=C+Math.imul(sA,se)|0,C=C+Math.imul(oA,KA)|0,p=p+Math.imul(oA,se)|0,K=K+Math.imul(S,F)|0,C=C+Math.imul(S,W)|0,C=C+Math.imul($,F)|0,p=p+Math.imul($,W)|0;var re=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(re>>>26)|0,re&=67108863,K=Math.imul(zA,VA),C=Math.imul(zA,$A),C=C+Math.imul(P,VA)|0,p=Math.imul(P,$A),K=K+Math.imul(Le,XA)|0,C=C+Math.imul(Le,ye)|0,C=C+Math.imul(kA,XA)|0,p=p+Math.imul(kA,ye)|0,K=K+Math.imul(de,Je)|0,C=C+Math.imul(de,je)|0,C=C+Math.imul(Ke,Je)|0,p=p+Math.imul(Ke,je)|0,K=K+Math.imul(_A,Be)|0,C=C+Math.imul(_A,ve)|0,C=C+Math.imul(we,Be)|0,p=p+Math.imul(we,ve)|0,K=K+Math.imul(HA,Oe)|0,C=C+Math.imul(HA,ze)|0,C=C+Math.imul(ce,Oe)|0,p=p+Math.imul(ce,ze)|0,K=K+Math.imul(GA,KA)|0,C=C+Math.imul(GA,se)|0,C=C+Math.imul(lA,KA)|0,p=p+Math.imul(lA,se)|0,K=K+Math.imul(sA,F)|0,C=C+Math.imul(sA,W)|0,C=C+Math.imul(oA,F)|0,p=p+Math.imul(oA,W)|0,K=K+Math.imul(S,w)|0,C=C+Math.imul(S,V)|0,C=C+Math.imul($,w)|0,p=p+Math.imul($,V)|0;var ne=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(ne>>>26)|0,ne&=67108863,K=Math.imul(k,VA),C=Math.imul(k,$A),C=C+Math.imul(_,VA)|0,p=Math.imul(_,$A),K=K+Math.imul(zA,XA)|0,C=C+Math.imul(zA,ye)|0,C=C+Math.imul(P,XA)|0,p=p+Math.imul(P,ye)|0,K=K+Math.imul(Le,Je)|0,C=C+Math.imul(Le,je)|0,C=C+Math.imul(kA,Je)|0,p=p+Math.imul(kA,je)|0,K=K+Math.imul(de,Be)|0,C=C+Math.imul(de,ve)|0,C=C+Math.imul(Ke,Be)|0,p=p+Math.imul(Ke,ve)|0,K=K+Math.imul(_A,Oe)|0,C=C+Math.imul(_A,ze)|0,C=C+Math.imul(we,Oe)|0,p=p+Math.imul(we,ze)|0,K=K+Math.imul(HA,KA)|0,C=C+Math.imul(HA,se)|0,C=C+Math.imul(ce,KA)|0,p=p+Math.imul(ce,se)|0,K=K+Math.imul(GA,F)|0,C=C+Math.imul(GA,W)|0,C=C+Math.imul(lA,F)|0,p=p+Math.imul(lA,W)|0,K=K+Math.imul(sA,w)|0,C=C+Math.imul(sA,V)|0,C=C+Math.imul(oA,w)|0,p=p+Math.imul(oA,V)|0,K=K+Math.imul(S,rA)|0,C=C+Math.imul(S,IA)|0,C=C+Math.imul($,rA)|0,p=p+Math.imul($,IA)|0;var ee=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(ee>>>26)|0,ee&=67108863,K=Math.imul(aA,VA),C=Math.imul(aA,$A),C=C+Math.imul(EA,VA)|0,p=Math.imul(EA,$A),K=K+Math.imul(k,XA)|0,C=C+Math.imul(k,ye)|0,C=C+Math.imul(_,XA)|0,p=p+Math.imul(_,ye)|0,K=K+Math.imul(zA,Je)|0,C=C+Math.imul(zA,je)|0,C=C+Math.imul(P,Je)|0,p=p+Math.imul(P,je)|0,K=K+Math.imul(Le,Be)|0,C=C+Math.imul(Le,ve)|0,C=C+Math.imul(kA,Be)|0,p=p+Math.imul(kA,ve)|0,K=K+Math.imul(de,Oe)|0,C=C+Math.imul(de,ze)|0,C=C+Math.imul(Ke,Oe)|0,p=p+Math.imul(Ke,ze)|0,K=K+Math.imul(_A,KA)|0,C=C+Math.imul(_A,se)|0,C=C+Math.imul(we,KA)|0,p=p+Math.imul(we,se)|0,K=K+Math.imul(HA,F)|0,C=C+Math.imul(HA,W)|0,C=C+Math.imul(ce,F)|0,p=p+Math.imul(ce,W)|0,K=K+Math.imul(GA,w)|0,C=C+Math.imul(GA,V)|0,C=C+Math.imul(lA,w)|0,p=p+Math.imul(lA,V)|0,K=K+Math.imul(sA,rA)|0,C=C+Math.imul(sA,IA)|0,C=C+Math.imul(oA,rA)|0,p=p+Math.imul(oA,IA)|0,K=K+Math.imul(S,FA)|0,C=C+Math.imul(S,xA)|0,C=C+Math.imul($,FA)|0,p=p+Math.imul($,xA)|0;var LA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(LA>>>26)|0,LA&=67108863,K=Math.imul(aA,XA),C=Math.imul(aA,ye),C=C+Math.imul(EA,XA)|0,p=Math.imul(EA,ye),K=K+Math.imul(k,Je)|0,C=C+Math.imul(k,je)|0,C=C+Math.imul(_,Je)|0,p=p+Math.imul(_,je)|0,K=K+Math.imul(zA,Be)|0,C=C+Math.imul(zA,ve)|0,C=C+Math.imul(P,Be)|0,p=p+Math.imul(P,ve)|0,K=K+Math.imul(Le,Oe)|0,C=C+Math.imul(Le,ze)|0,C=C+Math.imul(kA,Oe)|0,p=p+Math.imul(kA,ze)|0,K=K+Math.imul(de,KA)|0,C=C+Math.imul(de,se)|0,C=C+Math.imul(Ke,KA)|0,p=p+Math.imul(Ke,se)|0,K=K+Math.imul(_A,F)|0,C=C+Math.imul(_A,W)|0,C=C+Math.imul(we,F)|0,p=p+Math.imul(we,W)|0,K=K+Math.imul(HA,w)|0,C=C+Math.imul(HA,V)|0,C=C+Math.imul(ce,w)|0,p=p+Math.imul(ce,V)|0,K=K+Math.imul(GA,rA)|0,C=C+Math.imul(GA,IA)|0,C=C+Math.imul(lA,rA)|0,p=p+Math.imul(lA,IA)|0,K=K+Math.imul(sA,FA)|0,C=C+Math.imul(sA,xA)|0,C=C+Math.imul(oA,FA)|0,p=p+Math.imul(oA,xA)|0;var PA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(PA>>>26)|0,PA&=67108863,K=Math.imul(aA,Je),C=Math.imul(aA,je),C=C+Math.imul(EA,Je)|0,p=Math.imul(EA,je),K=K+Math.imul(k,Be)|0,C=C+Math.imul(k,ve)|0,C=C+Math.imul(_,Be)|0,p=p+Math.imul(_,ve)|0,K=K+Math.imul(zA,Oe)|0,C=C+Math.imul(zA,ze)|0,C=C+Math.imul(P,Oe)|0,p=p+Math.imul(P,ze)|0,K=K+Math.imul(Le,KA)|0,C=C+Math.imul(Le,se)|0,C=C+Math.imul(kA,KA)|0,p=p+Math.imul(kA,se)|0,K=K+Math.imul(de,F)|0,C=C+Math.imul(de,W)|0,C=C+Math.imul(Ke,F)|0,p=p+Math.imul(Ke,W)|0,K=K+Math.imul(_A,w)|0,C=C+Math.imul(_A,V)|0,C=C+Math.imul(we,w)|0,p=p+Math.imul(we,V)|0,K=K+Math.imul(HA,rA)|0,C=C+Math.imul(HA,IA)|0,C=C+Math.imul(ce,rA)|0,p=p+Math.imul(ce,IA)|0,K=K+Math.imul(GA,FA)|0,C=C+Math.imul(GA,xA)|0,C=C+Math.imul(lA,FA)|0,p=p+Math.imul(lA,xA)|0;var UA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(UA>>>26)|0,UA&=67108863,K=Math.imul(aA,Be),C=Math.imul(aA,ve),C=C+Math.imul(EA,Be)|0,p=Math.imul(EA,ve),K=K+Math.imul(k,Oe)|0,C=C+Math.imul(k,ze)|0,C=C+Math.imul(_,Oe)|0,p=p+Math.imul(_,ze)|0,K=K+Math.imul(zA,KA)|0,C=C+Math.imul(zA,se)|0,C=C+Math.imul(P,KA)|0,p=p+Math.imul(P,se)|0,K=K+Math.imul(Le,F)|0,C=C+Math.imul(Le,W)|0,C=C+Math.imul(kA,F)|0,p=p+Math.imul(kA,W)|0,K=K+Math.imul(de,w)|0,C=C+Math.imul(de,V)|0,C=C+Math.imul(Ke,w)|0,p=p+Math.imul(Ke,V)|0,K=K+Math.imul(_A,rA)|0,C=C+Math.imul(_A,IA)|0,C=C+Math.imul(we,rA)|0,p=p+Math.imul(we,IA)|0,K=K+Math.imul(HA,FA)|0,C=C+Math.imul(HA,xA)|0,C=C+Math.imul(ce,FA)|0,p=p+Math.imul(ce,xA)|0;var JA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(JA>>>26)|0,JA&=67108863,K=Math.imul(aA,Oe),C=Math.imul(aA,ze),C=C+Math.imul(EA,Oe)|0,p=Math.imul(EA,ze),K=K+Math.imul(k,KA)|0,C=C+Math.imul(k,se)|0,C=C+Math.imul(_,KA)|0,p=p+Math.imul(_,se)|0,K=K+Math.imul(zA,F)|0,C=C+Math.imul(zA,W)|0,C=C+Math.imul(P,F)|0,p=p+Math.imul(P,W)|0,K=K+Math.imul(Le,w)|0,C=C+Math.imul(Le,V)|0,C=C+Math.imul(kA,w)|0,p=p+Math.imul(kA,V)|0,K=K+Math.imul(de,rA)|0,C=C+Math.imul(de,IA)|0,C=C+Math.imul(Ke,rA)|0,p=p+Math.imul(Ke,IA)|0,K=K+Math.imul(_A,FA)|0,C=C+Math.imul(_A,xA)|0,C=C+Math.imul(we,FA)|0,p=p+Math.imul(we,xA)|0;var OA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(OA>>>26)|0,OA&=67108863,K=Math.imul(aA,KA),C=Math.imul(aA,se),C=C+Math.imul(EA,KA)|0,p=Math.imul(EA,se),K=K+Math.imul(k,F)|0,C=C+Math.imul(k,W)|0,C=C+Math.imul(_,F)|0,p=p+Math.imul(_,W)|0,K=K+Math.imul(zA,w)|0,C=C+Math.imul(zA,V)|0,C=C+Math.imul(P,w)|0,p=p+Math.imul(P,V)|0,K=K+Math.imul(Le,rA)|0,C=C+Math.imul(Le,IA)|0,C=C+Math.imul(kA,rA)|0,p=p+Math.imul(kA,IA)|0,K=K+Math.imul(de,FA)|0,C=C+Math.imul(de,xA)|0,C=C+Math.imul(Ke,FA)|0,p=p+Math.imul(Ke,xA)|0;var SA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(SA>>>26)|0,SA&=67108863,K=Math.imul(aA,F),C=Math.imul(aA,W),C=C+Math.imul(EA,F)|0,p=Math.imul(EA,W),K=K+Math.imul(k,w)|0,C=C+Math.imul(k,V)|0,C=C+Math.imul(_,w)|0,p=p+Math.imul(_,V)|0,K=K+Math.imul(zA,rA)|0,C=C+Math.imul(zA,IA)|0,C=C+Math.imul(P,rA)|0,p=p+Math.imul(P,IA)|0,K=K+Math.imul(Le,FA)|0,C=C+Math.imul(Le,xA)|0,C=C+Math.imul(kA,FA)|0,p=p+Math.imul(kA,xA)|0;var CA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(CA>>>26)|0,CA&=67108863,K=Math.imul(aA,w),C=Math.imul(aA,V),C=C+Math.imul(EA,w)|0,p=Math.imul(EA,V),K=K+Math.imul(k,rA)|0,C=C+Math.imul(k,IA)|0,C=C+Math.imul(_,rA)|0,p=p+Math.imul(_,IA)|0,K=K+Math.imul(zA,FA)|0,C=C+Math.imul(zA,xA)|0,C=C+Math.imul(P,FA)|0,p=p+Math.imul(P,xA)|0;var uA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(uA>>>26)|0,uA&=67108863,K=Math.imul(aA,rA),C=Math.imul(aA,IA),C=C+Math.imul(EA,rA)|0,p=Math.imul(EA,IA),K=K+Math.imul(k,FA)|0,C=C+Math.imul(k,xA)|0,C=C+Math.imul(_,FA)|0,p=p+Math.imul(_,xA)|0;var mA=(v+K|0)+((C&8191)<<13)|0;v=(p+(C>>>13)|0)+(mA>>>26)|0,mA&=67108863,K=Math.imul(aA,FA),C=Math.imul(aA,xA),C=C+Math.imul(EA,FA)|0,p=Math.imul(EA,xA);var hA=(v+K|0)+((C&8191)<<13)|0;return v=(p+(C>>>13)|0)+(hA>>>26)|0,hA&=67108863,H[0]=Ee,H[1]=RA,H[2]=Ae,H[3]=ie,H[4]=le,H[5]=ae,H[6]=re,H[7]=ne,H[8]=ee,H[9]=LA,H[10]=PA,H[11]=UA,H[12]=JA,H[13]=OA,H[14]=SA,H[15]=CA,H[16]=uA,H[17]=mA,H[18]=hA,v!==0&&(H[19]=v,y.length++),y};Math.imul||(R=D);function M(x,l,I){I.negative=l.negative^x.negative,I.length=x.length+l.length;for(var y=0,b=0,J=0;J<I.length-1;J++){var H=b;b=0;for(var v=y&67108863,K=Math.min(J,l.length-1),C=Math.max(0,J-x.length+1);C<=K;C++){var p=J-C,L=x.words[p]|0,S=l.words[C]|0,$=L*S,AA=$&67108863;H=H+($/67108864|0)|0,AA=AA+v|0,v=AA&67108863,H=H+(AA>>>26)|0,b+=H>>>26,H&=67108863}I.words[J]=v,y=H,H=b}return y!==0?I.words[J]=y:I.length--,I._strip()}function q(x,l,I){return M(x,l,I)}r.prototype.mulTo=function(l,I){var y,b=this.length+l.length;return this.length===10&&l.length===10?y=R(this,l,I):b<63?y=D(this,l,I):b<1024?y=M(this,l,I):y=q(this,l,I),y},r.prototype.mul=function(l){var I=new r(null);return I.words=new Array(this.length+l.length),this.mulTo(l,I)},r.prototype.mulf=function(l){var I=new r(null);return I.words=new Array(this.length+l.length),q(this,l,I)},r.prototype.imul=function(l){return this.clone().mulTo(l,this)},r.prototype.imuln=function(l){var I=l<0;I&&(l=-l),s(typeof l=="number"),s(l<67108864);for(var y=0,b=0;b<this.length;b++){var J=(this.words[b]|0)*l,H=(J&67108863)+(y&67108863);y>>=26,y+=J/67108864|0,y+=H>>>26,this.words[b]=H&67108863}return y!==0&&(this.words[b]=y,this.length++),this.length=l===0?1:this.length,I?this.ineg():this},r.prototype.muln=function(l){return this.clone().imuln(l)},r.prototype.sqr=function(){return this.mul(this)},r.prototype.isqr=function(){return this.imul(this.clone())},r.prototype.pow=function(l){var I=d(l);if(I.length===0)return new r(1);for(var y=this,b=0;b<I.length&&I[b]===0;b++,y=y.sqr());if(++b<I.length)for(var J=y.sqr();b<I.length;b++,J=J.sqr())I[b]!==0&&(y=y.mul(J));return y},r.prototype.iushln=function(l){s(typeof l=="number"&&l>=0);var I=l%26,y=(l-I)/26,b=67108863>>>26-I<<26-I,J;if(I!==0){var H=0;for(J=0;J<this.length;J++){var v=this.words[J]&b,K=(this.words[J]|0)-v<<I;this.words[J]=K|H,H=v>>>26-I}H&&(this.words[J]=H,this.length++)}if(y!==0){for(J=this.length-1;J>=0;J--)this.words[J+y]=this.words[J];for(J=0;J<y;J++)this.words[J]=0;this.length+=y}return this._strip()},r.prototype.ishln=function(l){return s(this.negative===0),this.iushln(l)},r.prototype.iushrn=function(l,I,y){s(typeof l=="number"&&l>=0);var b;I?b=(I-I%26)/26:b=0;var J=l%26,H=Math.min((l-J)/26,this.length),v=67108863^67108863>>>J<<J,K=y;if(b-=H,b=Math.max(0,b),K){for(var C=0;C<H;C++)K.words[C]=this.words[C];K.length=H}if(H!==0)if(this.length>H)for(this.length-=H,C=0;C<this.length;C++)this.words[C]=this.words[C+H];else this.words[0]=0,this.length=1;var p=0;for(C=this.length-1;C>=0&&(p!==0||C>=b);C--){var L=this.words[C]|0;this.words[C]=p<<26-J|L>>>J,p=L&v}return K&&p!==0&&(K.words[K.length++]=p),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.ishrn=function(l,I,y){return s(this.negative===0),this.iushrn(l,I,y)},r.prototype.shln=function(l){return this.clone().ishln(l)},r.prototype.ushln=function(l){return this.clone().iushln(l)},r.prototype.shrn=function(l){return this.clone().ishrn(l)},r.prototype.ushrn=function(l){return this.clone().iushrn(l)},r.prototype.testn=function(l){s(typeof l=="number"&&l>=0);var I=l%26,y=(l-I)/26,b=1<<I;if(this.length<=y)return!1;var J=this.words[y];return!!(J&b)},r.prototype.imaskn=function(l){s(typeof l=="number"&&l>=0);var I=l%26,y=(l-I)/26;if(s(this.negative===0,"imaskn works only with positive numbers"),this.length<=y)return this;if(I!==0&&y++,this.length=Math.min(y,this.length),I!==0){var b=67108863^67108863>>>I<<I;this.words[this.length-1]&=b}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},r.prototype.maskn=function(l){return this.clone().imaskn(l)},r.prototype.iaddn=function(l){return s(typeof l=="number"),s(l<67108864),l<0?this.isubn(-l):this.negative!==0?this.length===1&&(this.words[0]|0)<=l?(this.words[0]=l-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(l),this.negative=1,this):this._iaddn(l)},r.prototype._iaddn=function(l){this.words[0]+=l;for(var I=0;I<this.length&&this.words[I]>=67108864;I++)this.words[I]-=67108864,I===this.length-1?this.words[I+1]=1:this.words[I+1]++;return this.length=Math.max(this.length,I+1),this},r.prototype.isubn=function(l){if(s(typeof l=="number"),s(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var I=0;I<this.length&&this.words[I]<0;I++)this.words[I]+=67108864,this.words[I+1]-=1;return this._strip()},r.prototype.addn=function(l){return this.clone().iaddn(l)},r.prototype.subn=function(l){return this.clone().isubn(l)},r.prototype.iabs=function(){return this.negative=0,this},r.prototype.abs=function(){return this.clone().iabs()},r.prototype._ishlnsubmul=function(l,I,y){var b=l.length+y,J;this._expand(b);var H,v=0;for(J=0;J<l.length;J++){H=(this.words[J+y]|0)+v;var K=(l.words[J]|0)*I;H-=K&67108863,v=(H>>26)-(K/67108864|0),this.words[J+y]=H&67108863}for(;J<this.length-y;J++)H=(this.words[J+y]|0)+v,v=H>>26,this.words[J+y]=H&67108863;if(v===0)return this._strip();for(s(v===-1),v=0,J=0;J<this.length;J++)H=-(this.words[J]|0)+v,v=H>>26,this.words[J]=H&67108863;return this.negative=1,this._strip()},r.prototype._wordDiv=function(l,I){var y=this.length-l.length,b=this.clone(),J=l,H=J.words[J.length-1]|0,v=this._countBits(H);y=26-v,y!==0&&(J=J.ushln(y),b.iushln(y),H=J.words[J.length-1]|0);var K=b.length-J.length,C;if(I!=="mod"){C=new r(null),C.length=K+1,C.words=new Array(C.length);for(var p=0;p<C.length;p++)C.words[p]=0}var L=b.clone()._ishlnsubmul(J,1,K);L.negative===0&&(b=L,C&&(C.words[K]=1));for(var S=K-1;S>=0;S--){var $=(b.words[J.length+S]|0)*67108864+(b.words[J.length+S-1]|0);for($=Math.min($/H|0,67108863),b._ishlnsubmul(J,$,S);b.negative!==0;)$--,b.negative=0,b._ishlnsubmul(J,1,S),b.isZero()||(b.negative^=1);C&&(C.words[S]=$)}return C&&C._strip(),b._strip(),I!=="div"&&y!==0&&b.iushrn(y),{div:C||null,mod:b}},r.prototype.divmod=function(l,I,y){if(s(!l.isZero()),this.isZero())return{div:new r(0),mod:new r(0)};var b,J,H;return this.negative!==0&&l.negative===0?(H=this.neg().divmod(l,I),I!=="mod"&&(b=H.div.neg()),I!=="div"&&(J=H.mod.neg(),y&&J.negative!==0&&J.iadd(l)),{div:b,mod:J}):this.negative===0&&l.negative!==0?(H=this.divmod(l.neg(),I),I!=="mod"&&(b=H.div.neg()),{div:b,mod:H.mod}):(this.negative&l.negative)!==0?(H=this.neg().divmod(l.neg(),I),I!=="div"&&(J=H.mod.neg(),y&&J.negative!==0&&J.isub(l)),{div:H.div,mod:J}):l.length>this.length||this.cmp(l)<0?{div:new r(0),mod:this}:l.length===1?I==="div"?{div:this.divn(l.words[0]),mod:null}:I==="mod"?{div:null,mod:new r(this.modrn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new r(this.modrn(l.words[0]))}:this._wordDiv(l,I)},r.prototype.div=function(l){return this.divmod(l,"div",!1).div},r.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},r.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},r.prototype.divRound=function(l){var I=this.divmod(l);if(I.mod.isZero())return I.div;var y=I.div.negative!==0?I.mod.isub(l):I.mod,b=l.ushrn(1),J=l.andln(1),H=y.cmp(b);return H<0||J===1&&H===0?I.div:I.div.negative!==0?I.div.isubn(1):I.div.iaddn(1)},r.prototype.modrn=function(l){var I=l<0;I&&(l=-l),s(l<=67108863);for(var y=(1<<26)%l,b=0,J=this.length-1;J>=0;J--)b=(y*b+(this.words[J]|0))%l;return I?-b:b},r.prototype.modn=function(l){return this.modrn(l)},r.prototype.idivn=function(l){var I=l<0;I&&(l=-l),s(l<=67108863);for(var y=0,b=this.length-1;b>=0;b--){var J=(this.words[b]|0)+y*67108864;this.words[b]=J/l|0,y=J%l}return this._strip(),I?this.ineg():this},r.prototype.divn=function(l){return this.clone().idivn(l)},r.prototype.egcd=function(l){s(l.negative===0),s(!l.isZero());var I=this,y=l.clone();I.negative!==0?I=I.umod(l):I=I.clone();for(var b=new r(1),J=new r(0),H=new r(0),v=new r(1),K=0;I.isEven()&&y.isEven();)I.iushrn(1),y.iushrn(1),++K;for(var C=y.clone(),p=I.clone();!I.isZero();){for(var L=0,S=1;(I.words[0]&S)===0&&L<26;++L,S<<=1);if(L>0)for(I.iushrn(L);L-- >0;)(b.isOdd()||J.isOdd())&&(b.iadd(C),J.isub(p)),b.iushrn(1),J.iushrn(1);for(var $=0,AA=1;(y.words[0]&AA)===0&&$<26;++$,AA<<=1);if($>0)for(y.iushrn($);$-- >0;)(H.isOdd()||v.isOdd())&&(H.iadd(C),v.isub(p)),H.iushrn(1),v.iushrn(1);I.cmp(y)>=0?(I.isub(y),b.isub(H),J.isub(v)):(y.isub(I),H.isub(b),v.isub(J))}return{a:H,b:v,gcd:y.iushln(K)}},r.prototype._invmp=function(l){s(l.negative===0),s(!l.isZero());var I=this,y=l.clone();I.negative!==0?I=I.umod(l):I=I.clone();for(var b=new r(1),J=new r(0),H=y.clone();I.cmpn(1)>0&&y.cmpn(1)>0;){for(var v=0,K=1;(I.words[0]&K)===0&&v<26;++v,K<<=1);if(v>0)for(I.iushrn(v);v-- >0;)b.isOdd()&&b.iadd(H),b.iushrn(1);for(var C=0,p=1;(y.words[0]&p)===0&&C<26;++C,p<<=1);if(C>0)for(y.iushrn(C);C-- >0;)J.isOdd()&&J.iadd(H),J.iushrn(1);I.cmp(y)>=0?(I.isub(y),b.isub(J)):(y.isub(I),J.isub(b))}var L;return I.cmpn(1)===0?L=b:L=J,L.cmpn(0)<0&&L.iadd(l),L},r.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var I=this.clone(),y=l.clone();I.negative=0,y.negative=0;for(var b=0;I.isEven()&&y.isEven();b++)I.iushrn(1),y.iushrn(1);do{for(;I.isEven();)I.iushrn(1);for(;y.isEven();)y.iushrn(1);var J=I.cmp(y);if(J<0){var H=I;I=y,y=H}else if(J===0||y.cmpn(1)===0)break;I.isub(y)}while(!0);return y.iushln(b)},r.prototype.invm=function(l){return this.egcd(l).a.umod(l)},r.prototype.isEven=function(){return(this.words[0]&1)===0},r.prototype.isOdd=function(){return(this.words[0]&1)===1},r.prototype.andln=function(l){return this.words[0]&l},r.prototype.bincn=function(l){s(typeof l=="number");var I=l%26,y=(l-I)/26,b=1<<I;if(this.length<=y)return this._expand(y+1),this.words[y]|=b,this;for(var J=b,H=y;J!==0&&H<this.length;H++){var v=this.words[H]|0;v+=J,J=v>>>26,v&=67108863,this.words[H]=v}return J!==0&&(this.words[H]=J,this.length++),this},r.prototype.isZero=function(){return this.length===1&&this.words[0]===0},r.prototype.cmpn=function(l){var I=l<0;if(this.negative!==0&&!I)return-1;if(this.negative===0&&I)return 1;this._strip();var y;if(this.length>1)y=1;else{I&&(l=-l),s(l<=67108863,"Number is too big");var b=this.words[0]|0;y=b===l?0:b<l?-1:1}return this.negative!==0?-y|0:y},r.prototype.cmp=function(l){if(this.negative!==0&&l.negative===0)return-1;if(this.negative===0&&l.negative!==0)return 1;var I=this.ucmp(l);return this.negative!==0?-I|0:I},r.prototype.ucmp=function(l){if(this.length>l.length)return 1;if(this.length<l.length)return-1;for(var I=0,y=this.length-1;y>=0;y--){var b=this.words[y]|0,J=l.words[y]|0;if(b!==J){b<J?I=-1:b>J&&(I=1);break}}return I},r.prototype.gtn=function(l){return this.cmpn(l)===1},r.prototype.gt=function(l){return this.cmp(l)===1},r.prototype.gten=function(l){return this.cmpn(l)>=0},r.prototype.gte=function(l){return this.cmp(l)>=0},r.prototype.ltn=function(l){return this.cmpn(l)===-1},r.prototype.lt=function(l){return this.cmp(l)===-1},r.prototype.lten=function(l){return this.cmpn(l)<=0},r.prototype.lte=function(l){return this.cmp(l)<=0},r.prototype.eqn=function(l){return this.cmpn(l)===0},r.prototype.eq=function(l){return this.cmp(l)===0},r.red=function(l){return new j(l)},r.prototype.toRed=function(l){return s(!this.red,"Already a number in reduction context"),s(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},r.prototype.fromRed=function(){return s(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},r.prototype._forceRed=function(l){return this.red=l,this},r.prototype.forceRed=function(l){return s(!this.red,"Already a number in reduction context"),this._forceRed(l)},r.prototype.redAdd=function(l){return s(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},r.prototype.redIAdd=function(l){return s(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},r.prototype.redSub=function(l){return s(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},r.prototype.redISub=function(l){return s(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},r.prototype.redShl=function(l){return s(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},r.prototype.redMul=function(l){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},r.prototype.redIMul=function(l){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},r.prototype.redSqr=function(){return s(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},r.prototype.redISqr=function(){return s(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},r.prototype.redSqrt=function(){return s(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},r.prototype.redInvm=function(){return s(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},r.prototype.redNeg=function(){return s(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},r.prototype.redPow=function(l){return s(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var G={k256:null,p224:null,p192:null,p25519:null};function T(x,l){this.name=x,this.p=new r(l,16),this.n=this.p.bitLength(),this.k=new r(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}T.prototype._tmp=function(){var l=new r(null);return l.words=new Array(Math.ceil(this.n/13)),l},T.prototype.ireduce=function(l){var I=l,y;do this.split(I,this.tmp),I=this.imulK(I),I=I.iadd(this.tmp),y=I.bitLength();while(y>this.n);var b=y<this.n?-1:I.ucmp(this.p);return b===0?(I.words[0]=0,I.length=1):b>0?I.isub(this.p):I.strip!==void 0?I.strip():I._strip(),I},T.prototype.split=function(l,I){l.iushrn(this.n,0,I)},T.prototype.imulK=function(l){return l.imul(this.k)};function Z(){T.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}n(Z,T),Z.prototype.split=function(l,I){for(var y=4194303,b=Math.min(l.length,9),J=0;J<b;J++)I.words[J]=l.words[J];if(I.length=b,l.length<=9){l.words[0]=0,l.length=1;return}var H=l.words[9];for(I.words[I.length++]=H&y,J=10;J<l.length;J++){var v=l.words[J]|0;l.words[J-10]=(v&y)<<4|H>>>22,H=v}H>>>=22,l.words[J-10]=H,H===0&&l.length>10?l.length-=10:l.length-=9},Z.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var I=0,y=0;y<l.length;y++){var b=l.words[y]|0;I+=b*977,l.words[y]=I&67108863,I=b*64+(I/67108864|0)}return l.words[l.length-1]===0&&(l.length--,l.words[l.length-1]===0&&l.length--),l};function X(){T.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}n(X,T);function U(){T.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}n(U,T);function O(){T.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}n(O,T),O.prototype.imulK=function(l){for(var I=0,y=0;y<l.length;y++){var b=(l.words[y]|0)*19+I,J=b&67108863;b>>>=26,l.words[y]=J,I=b}return I!==0&&(l.words[l.length++]=I),l},r._prime=function(l){if(G[l])return G[l];var I;if(l==="k256")I=new Z;else if(l==="p224")I=new X;else if(l==="p192")I=new U;else if(l==="p25519")I=new O;else throw new Error("Unknown prime "+l);return G[l]=I,I};function j(x){if(typeof x=="string"){var l=r._prime(x);this.m=l.p,this.prime=l}else s(x.gtn(1),"modulus must be greater than 1"),this.m=x,this.prime=null}j.prototype._verify1=function(l){s(l.negative===0,"red works only with positives"),s(l.red,"red works only with red numbers")},j.prototype._verify2=function(l,I){s((l.negative|I.negative)===0,"red works only with positives"),s(l.red&&l.red===I.red,"red works only with red numbers")},j.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):(B(l,l.umod(this.m)._forceRed(this)),l)},j.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},j.prototype.add=function(l,I){this._verify2(l,I);var y=l.add(I);return y.cmp(this.m)>=0&&y.isub(this.m),y._forceRed(this)},j.prototype.iadd=function(l,I){this._verify2(l,I);var y=l.iadd(I);return y.cmp(this.m)>=0&&y.isub(this.m),y},j.prototype.sub=function(l,I){this._verify2(l,I);var y=l.sub(I);return y.cmpn(0)<0&&y.iadd(this.m),y._forceRed(this)},j.prototype.isub=function(l,I){this._verify2(l,I);var y=l.isub(I);return y.cmpn(0)<0&&y.iadd(this.m),y},j.prototype.shl=function(l,I){return this._verify1(l),this.imod(l.ushln(I))},j.prototype.imul=function(l,I){return this._verify2(l,I),this.imod(l.imul(I))},j.prototype.mul=function(l,I){return this._verify2(l,I),this.imod(l.mul(I))},j.prototype.isqr=function(l){return this.imul(l,l.clone())},j.prototype.sqr=function(l){return this.mul(l,l)},j.prototype.sqrt=function(l){if(l.isZero())return l.clone();var I=this.m.andln(3);if(s(I%2===1),I===3){var y=this.m.add(new r(1)).iushrn(2);return this.pow(l,y)}for(var b=this.m.subn(1),J=0;!b.isZero()&&b.andln(1)===0;)J++,b.iushrn(1);s(!b.isZero());var H=new r(1).toRed(this),v=H.redNeg(),K=this.m.subn(1).iushrn(1),C=this.m.bitLength();for(C=new r(2*C*C).toRed(this);this.pow(C,K).cmp(v)!==0;)C.redIAdd(v);for(var p=this.pow(C,b),L=this.pow(l,b.addn(1).iushrn(1)),S=this.pow(l,b),$=J;S.cmp(H)!==0;){for(var AA=S,sA=0;AA.cmp(H)!==0;sA++)AA=AA.redSqr();s(sA<$);var oA=this.pow(p,new r(1).iushln($-sA-1));L=L.redMul(oA),p=oA.redSqr(),S=S.redMul(p),$=sA}return L},j.prototype.invm=function(l){var I=l._invmp(this.m);return I.negative!==0?(I.negative=0,this.imod(I).redNeg()):this.imod(I)},j.prototype.pow=function(l,I){if(I.isZero())return new r(1).toRed(this);if(I.cmpn(1)===0)return l.clone();var y=4,b=new Array(1<<y);b[0]=new r(1).toRed(this),b[1]=l;for(var J=2;J<b.length;J++)b[J]=this.mul(b[J-1],l);var H=b[0],v=0,K=0,C=I.bitLength()%26;for(C===0&&(C=26),J=I.length-1;J>=0;J--){for(var p=I.words[J],L=C-1;L>=0;L--){var S=p>>L&1;if(H!==b[0]&&(H=this.sqr(H)),S===0&&v===0){K=0;continue}v<<=1,v|=S,K++,!(K!==y&&(J!==0||L!==0))&&(H=this.mul(H,b[v]),K=0,v=0)}C=26}return H},j.prototype.convertTo=function(l){var I=l.umod(this.m);return I===l?I.clone():I},j.prototype.convertFrom=function(l){var I=l.clone();return I.red=null,I},r.mont=function(l){return new Y(l)};function Y(x){j.call(this,x),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new r(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}n(Y,j),Y.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},Y.prototype.convertFrom=function(l){var I=this.imod(l.mul(this.rinv));return I.red=null,I},Y.prototype.imul=function(l,I){if(l.isZero()||I.isZero())return l.words[0]=0,l.length=1,l;var y=l.imul(I),b=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),J=y.isub(b).iushrn(this.shift),H=J;return J.cmp(this.m)>=0?H=J.isub(this.m):J.cmpn(0)<0&&(H=J.iadd(this.m)),H._forceRed(this)},Y.prototype.mul=function(l,I){if(l.isZero()||I.isZero())return new r(0)._forceRed(this);var y=l.mul(I),b=y.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),J=y.isub(b).iushrn(this.shift),H=J;return J.cmp(this.m)>=0?H=J.isub(this.m):J.cmpn(0)<0&&(H=J.iadd(this.m)),H._forceRed(this)},Y.prototype.invm=function(l){var I=this.imod(l._invmp(this.m).mul(this.r2));return I._forceRed(this)}})(A,eD)})(wn)),wn.exports}var tD=IE();const cQ=sB(tD);var gn={exports:{}};var EQ;function dE(){return EQ||(EQ=1,(function(A,e){var t=Fg(),s=t.Buffer;function n(i,a){for(var g in i)a[g]=i[g]}s.from&&s.alloc&&s.allocUnsafe&&s.allocUnsafeSlow?A.exports=t:(n(t,e),e.Buffer=r);function r(i,a,g){return s(i,a,g)}r.prototype=Object.create(s.prototype),n(s,r),r.from=function(i,a,g){if(typeof i=="number")throw new TypeError("Argument must not be a number");return s(i,a,g)},r.alloc=function(i,a,g){if(typeof i!="number")throw new TypeError("Argument must be a number");var Q=s(i);return a!==void 0?typeof g=="string"?Q.fill(a,g):Q.fill(a):Q.fill(0),Q},r.allocUnsafe=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return s(i)},r.allocUnsafeSlow=function(i){if(typeof i!="number")throw new TypeError("Argument must be a number");return t.SlowBuffer(i)}})(gn,gn.exports)),gn.exports}var Ui,CQ;function oD(){if(CQ)return Ui;CQ=1;var A=dE().Buffer;function e(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),n=0;n<s.length;n++)s[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),a=i.charCodeAt(0);if(s[a]!==255)throw new TypeError(i+" is ambiguous");s[a]=r}var g=t.length,Q=t.charAt(0),B=Math.log(g)/Math.log(256),u=Math.log(256)/Math.log(g);function E(f){if((Array.isArray(f)||f instanceof Uint8Array)&&(f=A.from(f)),!A.isBuffer(f))throw new TypeError("Expected Buffer");if(f.length===0)return"";for(var d=0,D=0,R=0,M=f.length;R!==M&&f[R]===0;)R++,d++;for(var q=(M-R)*u+1>>>0,G=new Uint8Array(q);R!==M;){for(var T=f[R],Z=0,X=q-1;(T!==0||Z<D)&&X!==-1;X--,Z++)T+=256*G[X]>>>0,G[X]=T%g>>>0,T=T/g>>>0;if(T!==0)throw new Error("Non-zero carry");D=Z,R++}for(var U=q-D;U!==q&&G[U]===0;)U++;for(var O=Q.repeat(d);U<q;++U)O+=t.charAt(G[U]);return O}function c(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return A.alloc(0);for(var d=0,D=0,R=0;f[d]===Q;)D++,d++;for(var M=(f.length-d)*B+1>>>0,q=new Uint8Array(M);d<f.length;){var G=f.charCodeAt(d);if(G>255)return;var T=s[G];if(T===255)return;for(var Z=0,X=M-1;(T!==0||Z<R)&&X!==-1;X--,Z++)T+=g*q[X]>>>0,q[X]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");R=Z,d++}for(var U=M-R;U!==M&&q[U]===0;)U++;var O=A.allocUnsafe(D+(M-U));O.fill(0,0,D);for(var j=D;U!==M;)O[j++]=q[U++];return O}function h(f){var d=c(f);if(d)return d;throw new Error("Non-base"+g+" character")}return{encode:E,decodeUnsafe:c,decode:h}}return Ui=e,Ui}var Ri,uQ;function sD(){if(uQ)return Ri;uQ=1;var A=oD(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return Ri=A(e),Ri}var rD=sD();const IQ=sB(rD),dQ=Vc;var Xe={},Ki,hQ;function nD(){if(hQ)return Ki;hQ=1;var A=dE().Buffer;function e(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),n=0;n<s.length;n++)s[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),a=i.charCodeAt(0);if(s[a]!==255)throw new TypeError(i+" is ambiguous");s[a]=r}var g=t.length,Q=t.charAt(0),B=Math.log(g)/Math.log(256),u=Math.log(256)/Math.log(g);function E(f){if((Array.isArray(f)||f instanceof Uint8Array)&&(f=A.from(f)),!A.isBuffer(f))throw new TypeError("Expected Buffer");if(f.length===0)return"";for(var d=0,D=0,R=0,M=f.length;R!==M&&f[R]===0;)R++,d++;for(var q=(M-R)*u+1>>>0,G=new Uint8Array(q);R!==M;){for(var T=f[R],Z=0,X=q-1;(T!==0||Z<D)&&X!==-1;X--,Z++)T+=256*G[X]>>>0,G[X]=T%g>>>0,T=T/g>>>0;if(T!==0)throw new Error("Non-zero carry");D=Z,R++}for(var U=q-D;U!==q&&G[U]===0;)U++;for(var O=Q.repeat(d);U<q;++U)O+=t.charAt(G[U]);return O}function c(f){if(typeof f!="string")throw new TypeError("Expected String");if(f.length===0)return A.alloc(0);for(var d=0,D=0,R=0;f[d]===Q;)D++,d++;for(var M=(f.length-d)*B+1>>>0,q=new Uint8Array(M);d<f.length;){var G=f.charCodeAt(d);if(G>255)return;var T=s[G];if(T===255)return;for(var Z=0,X=M-1;(T!==0||Z<R)&&X!==-1;X--,Z++)T+=g*q[X]>>>0,q[X]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");R=Z,d++}for(var U=M-R;U!==M&&q[U]===0;)U++;var O=A.allocUnsafe(D+(M-U));O.fill(0,0,D);for(var j=D;U!==M;)O[j++]=q[U++];return O}function h(f){var d=c(f);if(d)return d;throw new Error("Non-base"+g+" character")}return{encode:E,decodeUnsafe:c,decode:h}}return Ki=e,Ki}var Li,pQ;function iD(){if(pQ)return Li;pQ=1;var A=nD(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return Li=A(e),Li}function zo(A,e,t){return e<=A&&A<=t}function li(A){if(A===void 0)return{};if(A===Object(A))return A;throw TypeError("Could not convert argument to dictionary")}function aD(A){for(var e=String(A),t=e.length,s=0,n=[];s<t;){var r=e.charCodeAt(s);if(r<55296||r>57343)n.push(r);else if(56320<=r&&r<=57343)n.push(65533);else if(55296<=r&&r<=56319)if(s===t-1)n.push(65533);else{var i=A.charCodeAt(s+1);if(56320<=i&&i<=57343){var a=r&1023,g=i&1023;n.push(65536+(a<<10)+g),s+=1}else n.push(65533)}s+=1}return n}function gD(A){for(var e="",t=0;t<A.length;++t){var s=A[t];s<=65535?e+=String.fromCharCode(s):(s-=65536,e+=String.fromCharCode((s>>10)+55296,(s&1023)+56320))}return e}var Kn=-1;function Lg(A){this.tokens=[].slice.call(A)}Lg.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Kn},prepend:function(A){if(Array.isArray(A))for(var e=A;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(A)},push:function(A){if(Array.isArray(A))for(var e=A;e.length;)this.tokens.push(e.shift());else this.tokens.push(A)}};var Xs=-1;function Ji(A,e){if(A)throw TypeError("Decoder error");return e||65533}var Ln="utf-8";function Jn(A,e){if(!(this instanceof Jn))return new Jn(A,e);if(A=A!==void 0?String(A).toLowerCase():Ln,A!==Ln)throw new Error("Encoding not supported. Only utf-8 is supported");e=li(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}Jn.prototype={decode:function(e,t){var s;typeof e=="object"&&e instanceof ArrayBuffer?s=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?s=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):s=new Uint8Array(0),t=li(t),this._streaming||(this._decoder=new lD({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!t.stream;for(var n=new Lg(s),r=[],i;!n.endOfStream()&&(i=this._decoder.handler(n,n.read()),i!==Xs);)i!==null&&(Array.isArray(i)?r.push.apply(r,i):r.push(i));if(!this._streaming){do{if(i=this._decoder.handler(n,n.read()),i===Xs)break;i!==null&&(Array.isArray(i)?r.push.apply(r,i):r.push(i))}while(!n.endOfStream());this._decoder=null}return r.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(r[0]===65279?(this._BOMseen=!0,r.shift()):this._BOMseen=!0),gD(r)}};function Tn(A,e){if(!(this instanceof Tn))return new Tn(A,e);if(A=A!==void 0?String(A).toLowerCase():Ln,A!==Ln)throw new Error("Encoding not supported. Only utf-8 is supported");e=li(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}Tn.prototype={encode:function(e,t){e=e?String(e):"",t=li(t),this._streaming||(this._encoder=new QD(this._options)),this._streaming=!!t.stream;for(var s=[],n=new Lg(aD(e)),r;!n.endOfStream()&&(r=this._encoder.handler(n,n.read()),r!==Xs);)Array.isArray(r)?s.push.apply(s,r):s.push(r);if(!this._streaming){for(;r=this._encoder.handler(n,n.read()),r!==Xs;)Array.isArray(r)?s.push.apply(s,r):s.push(r);this._encoder=null}return new Uint8Array(s)}};function lD(A){var e=A.fatal,t=0,s=0,n=0,r=128,i=191;this.handler=function(a,g){if(g===Kn&&n!==0)return n=0,Ji(e);if(g===Kn)return Xs;if(n===0){if(zo(g,0,127))return g;if(zo(g,194,223))n=1,t=g-192;else if(zo(g,224,239))g===224&&(r=160),g===237&&(i=159),n=2,t=g-224;else if(zo(g,240,244))g===240&&(r=144),g===244&&(i=143),n=3,t=g-240;else return Ji(e);return t=t<<6*n,null}if(!zo(g,r,i))return t=n=s=0,r=128,i=191,a.prepend(g),Ji(e);if(r=128,i=191,s+=1,t+=g-128<<6*(n-s),s!==n)return null;var Q=t;return t=n=s=0,Q}}function QD(A){A.fatal,this.handler=function(e,t){if(t===Kn)return Xs;if(zo(t,0,127))return t;var s,n;zo(t,128,2047)?(s=1,n=192):zo(t,2048,65535)?(s=2,n=224):zo(t,65536,1114111)&&(s=3,n=240);for(var r=[(t>>6*s)+n];s>0;){var i=t>>6*(s-1);r.push(128|i&63),s-=1}return r}}const BD=Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Jn,TextEncoder:Tn},Symbol.toStringTag,{value:"Module"})),cD=za(BD);var fQ;function ED(){if(fQ)return Xe;fQ=1;var A=Xe&&Xe.__createBinding||(Object.create?(function(U,O,j,Y){Y===void 0&&(Y=j),Object.defineProperty(U,Y,{enumerable:!0,get:function(){return O[j]}})}):(function(U,O,j,Y){Y===void 0&&(Y=j),U[Y]=O[j]})),e=Xe&&Xe.__setModuleDefault||(Object.create?(function(U,O){Object.defineProperty(U,"default",{enumerable:!0,value:O})}):function(U,O){U.default=O}),t=Xe&&Xe.__decorate||function(U,O,j,Y){var x=arguments.length,l=x<3?O:Y===null?Y=Object.getOwnPropertyDescriptor(O,j):Y,I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(U,O,j,Y);else for(var y=U.length-1;y>=0;y--)(I=U[y])&&(l=(x<3?I(l):x>3?I(O,j,l):I(O,j))||l);return x>3&&l&&Object.defineProperty(O,j,l),l},s=Xe&&Xe.__importStar||function(U){if(U&&U.__esModule)return U;var O={};if(U!=null)for(var j in U)j!=="default"&&Object.hasOwnProperty.call(U,j)&&A(O,U,j);return e(O,U),O},n=Xe&&Xe.__importDefault||function(U){return U&&U.__esModule?U:{default:U}};Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.deserializeUnchecked=Xe.deserialize=Xe.serialize=Xe.BinaryReader=Xe.BinaryWriter=Xe.BorshError=Xe.baseDecode=Xe.baseEncode=void 0;const r=n(IE()),i=n(iD()),a=s(cD),g=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,Q=new g("utf-8",{fatal:!0});function B(U){return typeof U=="string"&&(U=Buffer.from(U,"utf8")),i.default.encode(Buffer.from(U))}Xe.baseEncode=B;function u(U){return Buffer.from(i.default.decode(U))}Xe.baseDecode=u;const E=1024;class c extends Error{constructor(O){super(O),this.fieldPath=[],this.originalMessage=O}addToFieldPath(O){this.fieldPath.splice(0,0,O),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}Xe.BorshError=c;class h{constructor(){this.buf=Buffer.alloc(E),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(E)]))}writeU8(O){this.maybeResize(),this.buf.writeUInt8(O,this.length),this.length+=1}writeU16(O){this.maybeResize(),this.buf.writeUInt16LE(O,this.length),this.length+=2}writeU32(O){this.maybeResize(),this.buf.writeUInt32LE(O,this.length),this.length+=4}writeU64(O){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(O).toArray("le",8)))}writeU128(O){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(O).toArray("le",16)))}writeU256(O){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(O).toArray("le",32)))}writeU512(O){this.maybeResize(),this.writeBuffer(Buffer.from(new r.default(O).toArray("le",64)))}writeBuffer(O){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),O,Buffer.alloc(E)]),this.length+=O.length}writeString(O){this.maybeResize();const j=Buffer.from(O,"utf8");this.writeU32(j.length),this.writeBuffer(j)}writeFixedArray(O){this.writeBuffer(Buffer.from(O))}writeArray(O,j){this.maybeResize(),this.writeU32(O.length);for(const Y of O)this.maybeResize(),j(Y)}toArray(){return this.buf.subarray(0,this.length)}}Xe.BinaryWriter=h;function f(U,O,j){const Y=j.value;j.value=function(...x){try{return Y.apply(this,x)}catch(l){if(l instanceof RangeError){const I=l.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(I)>=0)throw new c("Reached the end of buffer when deserializing")}throw l}}}class d{constructor(O){this.buf=O,this.offset=0}readU8(){const O=this.buf.readUInt8(this.offset);return this.offset+=1,O}readU16(){const O=this.buf.readUInt16LE(this.offset);return this.offset+=2,O}readU32(){const O=this.buf.readUInt32LE(this.offset);return this.offset+=4,O}readU64(){const O=this.readBuffer(8);return new r.default(O,"le")}readU128(){const O=this.readBuffer(16);return new r.default(O,"le")}readU256(){const O=this.readBuffer(32);return new r.default(O,"le")}readU512(){const O=this.readBuffer(64);return new r.default(O,"le")}readBuffer(O){if(this.offset+O>this.buf.length)throw new c(`Expected buffer length ${O} isn't within bounds`);const j=this.buf.slice(this.offset,this.offset+O);return this.offset+=O,j}readString(){const O=this.readU32(),j=this.readBuffer(O);try{return Q.decode(j)}catch(Y){throw new c(`Error decoding UTF-8 string: ${Y}`)}}readFixedArray(O){return new Uint8Array(this.readBuffer(O))}readArray(O){const j=this.readU32(),Y=Array();for(let x=0;x<j;++x)Y.push(O());return Y}}t([f],d.prototype,"readU8",null),t([f],d.prototype,"readU16",null),t([f],d.prototype,"readU32",null),t([f],d.prototype,"readU64",null),t([f],d.prototype,"readU128",null),t([f],d.prototype,"readU256",null),t([f],d.prototype,"readU512",null),t([f],d.prototype,"readString",null),t([f],d.prototype,"readFixedArray",null),t([f],d.prototype,"readArray",null),Xe.BinaryReader=d;function D(U){return U.charAt(0).toUpperCase()+U.slice(1)}function R(U,O,j,Y,x){try{if(typeof Y=="string")x[`write${D(Y)}`](j);else if(Y instanceof Array)if(typeof Y[0]=="number"){if(j.length!==Y[0])throw new c(`Expecting byte array of length ${Y[0]}, but got ${j.length} bytes`);x.writeFixedArray(j)}else if(Y.length===2&&typeof Y[1]=="number"){if(j.length!==Y[1])throw new c(`Expecting byte array of length ${Y[1]}, but got ${j.length} bytes`);for(let l=0;l<Y[1];l++)R(U,null,j[l],Y[0],x)}else x.writeArray(j,l=>{R(U,O,l,Y[0],x)});else if(Y.kind!==void 0)switch(Y.kind){case"option":{j==null?x.writeU8(0):(x.writeU8(1),R(U,O,j,Y.type,x));break}case"map":{x.writeU32(j.size),j.forEach((l,I)=>{R(U,O,I,Y.key,x),R(U,O,l,Y.value,x)});break}default:throw new c(`FieldType ${Y} unrecognized`)}else M(U,j,x)}catch(l){throw l instanceof c&&l.addToFieldPath(O),l}}function M(U,O,j){if(typeof O.borshSerialize=="function"){O.borshSerialize(j);return}const Y=U.get(O.constructor);if(!Y)throw new c(`Class ${O.constructor.name} is missing in schema`);if(Y.kind==="struct")Y.fields.map(([x,l])=>{R(U,x,O[x],l,j)});else if(Y.kind==="enum"){const x=O[Y.field];for(let l=0;l<Y.values.length;++l){const[I,y]=Y.values[l];if(I===x){j.writeU8(l),R(U,I,O[I],y,j);break}}}else throw new c(`Unexpected schema kind: ${Y.kind} for ${O.constructor.name}`)}function q(U,O,j=h){const Y=new j;return M(U,O,Y),Y.toArray()}Xe.serialize=q;function G(U,O,j,Y){try{if(typeof j=="string")return Y[`read${D(j)}`]();if(j instanceof Array){if(typeof j[0]=="number")return Y.readFixedArray(j[0]);if(typeof j[1]=="number"){const x=[];for(let l=0;l<j[1];l++)x.push(G(U,null,j[0],Y));return x}else return Y.readArray(()=>G(U,O,j[0],Y))}if(j.kind==="option")return Y.readU8()?G(U,O,j.type,Y):void 0;if(j.kind==="map"){let x=new Map;const l=Y.readU32();for(let I=0;I<l;I++){const y=G(U,O,j.key,Y),b=G(U,O,j.value,Y);x.set(y,b)}return x}return T(U,j,Y)}catch(x){throw x instanceof c&&x.addToFieldPath(O),x}}function T(U,O,j){if(typeof O.borshDeserialize=="function")return O.borshDeserialize(j);const Y=U.get(O);if(!Y)throw new c(`Class ${O.name} is missing in schema`);if(Y.kind==="struct"){const x={};for(const[l,I]of U.get(O).fields)x[l]=G(U,l,I,j);return new O(x)}if(Y.kind==="enum"){const x=j.readU8();if(x>=Y.values.length)throw new c(`Enum index: ${x} is out of range`);const[l,I]=Y.values[x],y=G(U,l,I,j);return new O({[l]:y})}throw new c(`Unexpected schema kind: ${Y.kind} for ${O.constructor.name}`)}function Z(U,O,j,Y=d){const x=new Y(j),l=T(U,O,x);if(x.offset<j.length)throw new c(`Unexpected ${j.length-x.offset} bytes after deserialized data`);return l}Xe.deserialize=Z;function X(U,O,j,Y=d){const x=new Y(j);return T(U,O,x)}return Xe.deserializeUnchecked=X,Xe}var Ti=ED(),cA={},mQ;function CD(){if(mQ)return cA;mQ=1,Object.defineProperty(cA,"__esModule",{value:!0}),cA.s16=cA.s8=cA.nu64be=cA.u48be=cA.u40be=cA.u32be=cA.u24be=cA.u16be=cA.nu64=cA.u48=cA.u40=cA.u32=cA.u24=cA.u16=cA.u8=cA.offset=cA.greedy=cA.Constant=cA.UTF8=cA.CString=cA.Blob=cA.Boolean=cA.BitField=cA.BitStructure=cA.VariantLayout=cA.Union=cA.UnionLayoutDiscriminator=cA.UnionDiscriminator=cA.Structure=cA.Sequence=cA.DoubleBE=cA.Double=cA.FloatBE=cA.Float=cA.NearInt64BE=cA.NearInt64=cA.NearUInt64BE=cA.NearUInt64=cA.IntBE=cA.Int=cA.UIntBE=cA.UInt=cA.OffsetLayout=cA.GreedyCount=cA.ExternalLayout=cA.bindConstructorLayout=cA.nameWithProperty=cA.Layout=cA.uint8ArrayToBuffer=cA.checkUint8Array=void 0,cA.constant=cA.utf8=cA.cstr=cA.blob=cA.unionLayoutDiscriminator=cA.union=cA.seq=cA.bits=cA.struct=cA.f64be=cA.f64=cA.f32be=cA.f32=cA.ns64be=cA.s48be=cA.s40be=cA.s32be=cA.s24be=cA.s16be=cA.ns64=cA.s48=cA.s40=cA.s32=cA.s24=void 0;const A=Fg();function e(C){if(!(C instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}cA.checkUint8Array=e;function t(C){return e(C),A.Buffer.from(C.buffer,C.byteOffset,C.length)}cA.uint8ArrayToBuffer=t;let s=class{constructor(p,L){if(!Number.isInteger(p))throw new TypeError("span must be an integer");this.span=p,this.property=L}makeDestinationObject(){return{}}getSpan(p,L){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(p){const L=Object.create(this.constructor.prototype);return Object.assign(L,this),L.property=p,L}fromArray(p){}};cA.Layout=s;function n(C,p){return p.property?C+"["+p.property+"]":C}cA.nameWithProperty=n;function r(C,p){if(typeof C!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(C,"layout_"))throw new Error("Class is already bound to a layout");if(!(p&&p instanceof s))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(p,"boundConstructor_"))throw new Error("layout is already bound to a constructor");C.layout_=p,p.boundConstructor_=C,p.makeDestinationObject=(()=>new C),Object.defineProperty(C.prototype,"encode",{value(L,S){return p.encode(this,L,S)},writable:!0}),Object.defineProperty(C,"decode",{value(L,S){return p.decode(L,S)},writable:!0})}cA.bindConstructorLayout=r;class i extends s{isCount(){throw new Error("ExternalLayout is abstract")}}cA.ExternalLayout=i;class a extends i{constructor(p=1,L){if(!Number.isInteger(p)||0>=p)throw new TypeError("elementSpan must be a (positive) integer");super(-1,L),this.elementSpan=p}isCount(){return!0}decode(p,L=0){e(p);const S=p.length-L;return Math.floor(S/this.elementSpan)}encode(p,L,S){return 0}}cA.GreedyCount=a;class g extends i{constructor(p,L=0,S){if(!(p instanceof s))throw new TypeError("layout must be a Layout");if(!Number.isInteger(L))throw new TypeError("offset must be integer or undefined");super(p.span,S||p.property),this.layout=p,this.offset=L}isCount(){return this.layout instanceof Q||this.layout instanceof B}decode(p,L=0){return this.layout.decode(p,L+this.offset)}encode(p,L,S=0){return this.layout.encode(p,L,S+this.offset)}}cA.OffsetLayout=g;class Q extends s{constructor(p,L){if(super(p,L),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,L=0){return t(p).readUIntLE(L,this.span)}encode(p,L,S=0){return t(L).writeUIntLE(p,S,this.span),this.span}}cA.UInt=Q;class B extends s{constructor(p,L){if(super(p,L),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,L=0){return t(p).readUIntBE(L,this.span)}encode(p,L,S=0){return t(L).writeUIntBE(p,S,this.span),this.span}}cA.UIntBE=B;class u extends s{constructor(p,L){if(super(p,L),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,L=0){return t(p).readIntLE(L,this.span)}encode(p,L,S=0){return t(L).writeIntLE(p,S,this.span),this.span}}cA.Int=u;class E extends s{constructor(p,L){if(super(p,L),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(p,L=0){return t(p).readIntBE(L,this.span)}encode(p,L,S=0){return t(L).writeIntBE(p,S,this.span),this.span}}cA.IntBE=E;const c=Math.pow(2,32);function h(C){const p=Math.floor(C/c),L=C-p*c;return{hi32:p,lo32:L}}function f(C,p){return C*c+p}class d extends s{constructor(p){super(8,p)}decode(p,L=0){const S=t(p),$=S.readUInt32LE(L),AA=S.readUInt32LE(L+4);return f(AA,$)}encode(p,L,S=0){const $=h(p),AA=t(L);return AA.writeUInt32LE($.lo32,S),AA.writeUInt32LE($.hi32,S+4),8}}cA.NearUInt64=d;class D extends s{constructor(p){super(8,p)}decode(p,L=0){const S=t(p),$=S.readUInt32BE(L),AA=S.readUInt32BE(L+4);return f($,AA)}encode(p,L,S=0){const $=h(p),AA=t(L);return AA.writeUInt32BE($.hi32,S),AA.writeUInt32BE($.lo32,S+4),8}}cA.NearUInt64BE=D;class R extends s{constructor(p){super(8,p)}decode(p,L=0){const S=t(p),$=S.readUInt32LE(L),AA=S.readInt32LE(L+4);return f(AA,$)}encode(p,L,S=0){const $=h(p),AA=t(L);return AA.writeUInt32LE($.lo32,S),AA.writeInt32LE($.hi32,S+4),8}}cA.NearInt64=R;class M extends s{constructor(p){super(8,p)}decode(p,L=0){const S=t(p),$=S.readInt32BE(L),AA=S.readUInt32BE(L+4);return f($,AA)}encode(p,L,S=0){const $=h(p),AA=t(L);return AA.writeInt32BE($.hi32,S),AA.writeUInt32BE($.lo32,S+4),8}}cA.NearInt64BE=M;class q extends s{constructor(p){super(4,p)}decode(p,L=0){return t(p).readFloatLE(L)}encode(p,L,S=0){return t(L).writeFloatLE(p,S),4}}cA.Float=q;class G extends s{constructor(p){super(4,p)}decode(p,L=0){return t(p).readFloatBE(L)}encode(p,L,S=0){return t(L).writeFloatBE(p,S),4}}cA.FloatBE=G;class T extends s{constructor(p){super(8,p)}decode(p,L=0){return t(p).readDoubleLE(L)}encode(p,L,S=0){return t(L).writeDoubleLE(p,S),8}}cA.Double=T;class Z extends s{constructor(p){super(8,p)}decode(p,L=0){return t(p).readDoubleBE(L)}encode(p,L,S=0){return t(L).writeDoubleBE(p,S),8}}cA.DoubleBE=Z;class X extends s{constructor(p,L,S){if(!(p instanceof s))throw new TypeError("elementLayout must be a Layout");if(!(L instanceof i&&L.isCount()||Number.isInteger(L)&&0<=L))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let $=-1;!(L instanceof i)&&0<p.span&&($=L*p.span),super($,S),this.elementLayout=p,this.count=L}getSpan(p,L=0){if(0<=this.span)return this.span;let S=0,$=this.count;if($ instanceof i&&($=$.decode(p,L)),0<this.elementLayout.span)S=$*this.elementLayout.span;else{let AA=0;for(;AA<$;)S+=this.elementLayout.getSpan(p,L+S),++AA}return S}decode(p,L=0){const S=[];let $=0,AA=this.count;for(AA instanceof i&&(AA=AA.decode(p,L));$<AA;)S.push(this.elementLayout.decode(p,L)),L+=this.elementLayout.getSpan(p,L),$+=1;return S}encode(p,L,S=0){const $=this.elementLayout,AA=p.reduce((sA,oA)=>sA+$.encode(oA,L,S+sA),0);return this.count instanceof i&&this.count.encode(p.length,L,S),AA}}cA.Sequence=X;class U extends s{constructor(p,L,S){if(!(Array.isArray(p)&&p.reduce((AA,sA)=>AA&&sA instanceof s,!0)))throw new TypeError("fields must be array of Layout instances");typeof L=="boolean"&&S===void 0&&(S=L,L=void 0);for(const AA of p)if(0>AA.span&&AA.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let $=-1;try{$=p.reduce((AA,sA)=>AA+sA.getSpan(),0)}catch{}super($,L),this.fields=p,this.decodePrefixes=!!S}getSpan(p,L=0){if(0<=this.span)return this.span;let S=0;try{S=this.fields.reduce(($,AA)=>{const sA=AA.getSpan(p,L);return L+=sA,$+sA},0)}catch{throw new RangeError("indeterminate span")}return S}decode(p,L=0){e(p);const S=this.makeDestinationObject();for(const $ of this.fields)if($.property!==void 0&&(S[$.property]=$.decode(p,L)),L+=$.getSpan(p,L),this.decodePrefixes&&p.length===L)break;return S}encode(p,L,S=0){const $=S;let AA=0,sA=0;for(const oA of this.fields){let bA=oA.span;if(sA=0<bA?bA:0,oA.property!==void 0){const GA=p[oA.property];GA!==void 0&&(sA=oA.encode(GA,L,S),0>bA&&(bA=oA.getSpan(L,S)))}AA=S,S+=bA}return AA+sA-$}fromArray(p){const L=this.makeDestinationObject();for(const S of this.fields)S.property!==void 0&&0<p.length&&(L[S.property]=p.shift());return L}layoutFor(p){if(typeof p!="string")throw new TypeError("property must be string");for(const L of this.fields)if(L.property===p)return L}offsetOf(p){if(typeof p!="string")throw new TypeError("property must be string");let L=0;for(const S of this.fields){if(S.property===p)return L;0>S.span?L=-1:0<=L&&(L+=S.span)}}}cA.Structure=U;class O{constructor(p){this.property=p}decode(p,L){throw new Error("UnionDiscriminator is abstract")}encode(p,L,S){throw new Error("UnionDiscriminator is abstract")}}cA.UnionDiscriminator=O;class j extends O{constructor(p,L){if(!(p instanceof i&&p.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(L||p.property||"variant"),this.layout=p}decode(p,L){return this.layout.decode(p,L)}encode(p,L,S){return this.layout.encode(p,L,S)}}cA.UnionLayoutDiscriminator=j;class Y extends s{constructor(p,L,S){let $;if(p instanceof Q||p instanceof B)$=new j(new g(p));else if(p instanceof i&&p.isCount())$=new j(p);else if(p instanceof O)$=p;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(L===void 0&&(L=null),!(L===null||L instanceof s))throw new TypeError("defaultLayout must be null or a Layout");if(L!==null){if(0>L.span)throw new Error("defaultLayout must have constant span");L.property===void 0&&(L=L.replicate("content"))}let AA=-1;L&&(AA=L.span,0<=AA&&(p instanceof Q||p instanceof B)&&(AA+=$.layout.span)),super(AA,S),this.discriminator=$,this.usesPrefixDiscriminator=p instanceof Q||p instanceof B,this.defaultLayout=L,this.registry={};let sA=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(oA){return sA(oA)},this.configGetSourceVariant=function(oA){sA=oA.bind(this)}}getSpan(p,L=0){if(0<=this.span)return this.span;const S=this.getVariant(p,L);if(!S)throw new Error("unable to determine span for unrecognized variant");return S.getSpan(p,L)}defaultGetSourceVariant(p){if(Object.prototype.hasOwnProperty.call(p,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(p,this.defaultLayout.property))return;const L=this.registry[p[this.discriminator.property]];if(L&&(!L.layout||L.property&&Object.prototype.hasOwnProperty.call(p,L.property)))return L}else for(const L in this.registry){const S=this.registry[L];if(S.property&&Object.prototype.hasOwnProperty.call(p,S.property))return S}throw new Error("unable to infer src variant")}decode(p,L=0){let S;const $=this.discriminator,AA=$.decode(p,L),sA=this.registry[AA];if(sA===void 0){const oA=this.defaultLayout;let bA=0;this.usesPrefixDiscriminator&&(bA=$.layout.span),S=this.makeDestinationObject(),S[$.property]=AA,S[oA.property]=oA.decode(p,L+bA)}else S=sA.decode(p,L);return S}encode(p,L,S=0){const $=this.getSourceVariant(p);if($===void 0){const AA=this.discriminator,sA=this.defaultLayout;let oA=0;return this.usesPrefixDiscriminator&&(oA=AA.layout.span),AA.encode(p[AA.property],L,S),oA+sA.encode(p[sA.property],L,S+oA)}return $.encode(p,L,S)}addVariant(p,L,S){const $=new x(this,p,L,S);return this.registry[p]=$,$}getVariant(p,L=0){let S;return p instanceof Uint8Array?S=this.discriminator.decode(p,L):S=p,this.registry[S]}}cA.Union=Y;class x extends s{constructor(p,L,S,$){if(!(p instanceof Y))throw new TypeError("union must be a Union");if(!Number.isInteger(L)||0>L)throw new TypeError("variant must be a (non-negative) integer");if(typeof S=="string"&&$===void 0&&($=S,S=null),S){if(!(S instanceof s))throw new TypeError("layout must be a Layout");if(p.defaultLayout!==null&&0<=S.span&&S.span>p.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof $!="string")throw new TypeError("variant must have a String property")}let AA=p.span;0>p.span&&(AA=S?S.span:0,0<=AA&&p.usesPrefixDiscriminator&&(AA+=p.discriminator.layout.span)),super(AA,$),this.union=p,this.variant=L,this.layout=S||null}getSpan(p,L=0){if(0<=this.span)return this.span;let S=0;this.union.usesPrefixDiscriminator&&(S=this.union.discriminator.layout.span);let $=0;return this.layout&&($=this.layout.getSpan(p,L+S)),S+$}decode(p,L=0){const S=this.makeDestinationObject();if(this!==this.union.getVariant(p,L))throw new Error("variant mismatch");let $=0;return this.union.usesPrefixDiscriminator&&($=this.union.discriminator.layout.span),this.layout?S[this.property]=this.layout.decode(p,L+$):this.property?S[this.property]=!0:this.union.usesPrefixDiscriminator&&(S[this.union.discriminator.property]=this.variant),S}encode(p,L,S=0){let $=0;if(this.union.usesPrefixDiscriminator&&($=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(p,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,L,S);let AA=$;if(this.layout&&(this.layout.encode(p[this.property],L,S+$),AA+=this.layout.getSpan(L,S+$),0<=this.union.span&&AA>this.union.span))throw new Error("encoded variant overruns containing union");return AA}fromArray(p){if(this.layout)return this.layout.fromArray(p)}}cA.VariantLayout=x;function l(C){return 0>C&&(C+=4294967296),C}class I extends s{constructor(p,L,S){if(!(p instanceof Q||p instanceof B))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof L=="string"&&S===void 0&&(S=L,L=!1),4<p.span)throw new RangeError("word cannot exceed 32 bits");super(p.span,S),this.word=p,this.msb=!!L,this.fields=[];let $=0;this._packedSetValue=function(AA){return $=l(AA),this},this._packedGetValue=function(){return $}}decode(p,L=0){const S=this.makeDestinationObject(),$=this.word.decode(p,L);this._packedSetValue($);for(const AA of this.fields)AA.property!==void 0&&(S[AA.property]=AA.decode(p));return S}encode(p,L,S=0){const $=this.word.decode(L,S);this._packedSetValue($);for(const AA of this.fields)if(AA.property!==void 0){const sA=p[AA.property];sA!==void 0&&AA.encode(sA)}return this.word.encode(this._packedGetValue(),L,S)}addField(p,L){const S=new y(this,p,L);return this.fields.push(S),S}addBoolean(p){const L=new b(this,p);return this.fields.push(L),L}fieldFor(p){if(typeof p!="string")throw new TypeError("property must be string");for(const L of this.fields)if(L.property===p)return L}}cA.BitStructure=I;class y{constructor(p,L,S){if(!(p instanceof I))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(L)||0>=L)throw new TypeError("bits must be positive integer");const $=8*p.span,AA=p.fields.reduce((sA,oA)=>sA+oA.bits,0);if(L+AA>$)throw new Error("bits too long for span remainder ("+($-AA)+" of "+$+" remain)");this.container=p,this.bits=L,this.valueMask=(1<<L)-1,L===32&&(this.valueMask=4294967295),this.start=AA,this.container.msb&&(this.start=$-AA-L),this.wordMask=l(this.valueMask<<this.start),this.property=S}decode(p,L){const S=this.container._packedGetValue();return l(S&this.wordMask)>>>this.start}encode(p){if(typeof p!="number"||!Number.isInteger(p)||p!==l(p&this.valueMask))throw new TypeError(n("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const L=this.container._packedGetValue(),S=l(p<<this.start);this.container._packedSetValue(l(L&~this.wordMask)|S)}}cA.BitField=y;class b extends y{constructor(p,L){super(p,1,L)}decode(p,L){return!!super.decode(p,L)}encode(p){typeof p=="boolean"&&(p=+p),super.encode(p)}}cA.Boolean=b;class J extends s{constructor(p,L){if(!(p instanceof i&&p.isCount()||Number.isInteger(p)&&0<=p))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let S=-1;p instanceof i||(S=p),super(S,L),this.length=p}getSpan(p,L){let S=this.span;return 0>S&&(S=this.length.decode(p,L)),S}decode(p,L=0){let S=this.span;return 0>S&&(S=this.length.decode(p,L)),t(p).slice(L,L+S)}encode(p,L,S){let $=this.length;if(this.length instanceof i&&($=p.length),!(p instanceof Uint8Array&&$===p.length))throw new TypeError(n("Blob.encode",this)+" requires (length "+$+") Uint8Array as src");if(S+$>L.length)throw new RangeError("encoding overruns Uint8Array");const AA=t(p);return t(L).write(AA.toString("hex"),S,$,"hex"),this.length instanceof i&&this.length.encode($,L,S),$}}cA.Blob=J;class H extends s{constructor(p){super(-1,p)}getSpan(p,L=0){e(p);let S=L;for(;S<p.length&&p[S]!==0;)S+=1;return 1+S-L}decode(p,L=0){const S=this.getSpan(p,L);return t(p).slice(L,L+S-1).toString("utf-8")}encode(p,L,S=0){typeof p!="string"&&(p=String(p));const $=A.Buffer.from(p,"utf8"),AA=$.length;if(S+AA>L.length)throw new RangeError("encoding overruns Buffer");const sA=t(L);return $.copy(sA,S),sA[S+AA]=0,AA+1}}cA.CString=H;class v extends s{constructor(p,L){if(typeof p=="string"&&L===void 0&&(L=p,p=void 0),p===void 0)p=-1;else if(!Number.isInteger(p))throw new TypeError("maxSpan must be an integer");super(-1,L),this.maxSpan=p}getSpan(p,L=0){return e(p),p.length-L}decode(p,L=0){const S=this.getSpan(p,L);if(0<=this.maxSpan&&this.maxSpan<S)throw new RangeError("text length exceeds maxSpan");return t(p).slice(L,L+S).toString("utf-8")}encode(p,L,S=0){typeof p!="string"&&(p=String(p));const $=A.Buffer.from(p,"utf8"),AA=$.length;if(0<=this.maxSpan&&this.maxSpan<AA)throw new RangeError("text length exceeds maxSpan");if(S+AA>L.length)throw new RangeError("encoding overruns Buffer");return $.copy(t(L),S),AA}}cA.UTF8=v;class K extends s{constructor(p,L){super(0,L),this.value=p}decode(p,L){return this.value}encode(p,L,S){return 0}}return cA.Constant=K,cA.greedy=((C,p)=>new a(C,p)),cA.offset=((C,p,L)=>new g(C,p,L)),cA.u8=(C=>new Q(1,C)),cA.u16=(C=>new Q(2,C)),cA.u24=(C=>new Q(3,C)),cA.u32=(C=>new Q(4,C)),cA.u40=(C=>new Q(5,C)),cA.u48=(C=>new Q(6,C)),cA.nu64=(C=>new d(C)),cA.u16be=(C=>new B(2,C)),cA.u24be=(C=>new B(3,C)),cA.u32be=(C=>new B(4,C)),cA.u40be=(C=>new B(5,C)),cA.u48be=(C=>new B(6,C)),cA.nu64be=(C=>new D(C)),cA.s8=(C=>new u(1,C)),cA.s16=(C=>new u(2,C)),cA.s24=(C=>new u(3,C)),cA.s32=(C=>new u(4,C)),cA.s40=(C=>new u(5,C)),cA.s48=(C=>new u(6,C)),cA.ns64=(C=>new R(C)),cA.s16be=(C=>new E(2,C)),cA.s24be=(C=>new E(3,C)),cA.s32be=(C=>new E(4,C)),cA.s40be=(C=>new E(5,C)),cA.s48be=(C=>new E(6,C)),cA.ns64be=(C=>new M(C)),cA.f32=(C=>new q(C)),cA.f32be=(C=>new G(C)),cA.f64=(C=>new T(C)),cA.f64be=(C=>new Z(C)),cA.struct=((C,p,L)=>new U(C,p,L)),cA.bits=((C,p,L)=>new I(C,p,L)),cA.seq=((C,p,L)=>new X(C,p,L)),cA.union=((C,p,L)=>new Y(C,p,L)),cA.unionLayoutDiscriminator=((C,p)=>new j(C,p)),cA.blob=((C,p)=>new J(C,p)),cA.cstr=(C=>new H(C)),cA.utf8=((C,p)=>new v(C,p)),cA.constant=((C,p)=>new K(C,p)),cA}var iA=CD(),uD=8078011;function hE(A){return Array.isArray(A)?"%5B"+A.map(hE).join("%2C%20")+"%5D":typeof A=="bigint"?`${A}n`:encodeURIComponent(String(A!=null&&Object.getPrototypeOf(A)===null?{...A}:A))}function ID([A,e]){return`${A}=${hE(e)}`}function dD(A){const e=Object.entries(A).map(ID).join("&");return btoa(e)}function hD(A,e={}){{let t=`Solana error #${A}; Decode this error by running \`npx @solana/errors decode -- ${A}`;return Object.keys(e).length&&(t+=` '${dD(e)}'`),`${t}\``}}var pD=class extends Error{cause=this.cause;context;constructor(...[e,t]){let s,n;if(t){const{cause:i,...a}=t;i&&(n={cause:i}),Object.keys(a).length>0&&(s=a)}const r=hD(e,s);super(r,n),this.context={__code:e,...s},this.name="SolanaError"}},fD=8078e3,mD=8078001,wD=8078004,xD=8078005,DD=8078006;function pE(A){return Array.isArray(A)?"%5B"+A.map(pE).join("%2C%20")+"%5D":typeof A=="bigint"?`${A}n`:encodeURIComponent(String(A!=null&&Object.getPrototypeOf(A)===null?{...A}:A))}function yD([A,e]){return`${A}=${pE(e)}`}function ND(A){const e=Object.entries(A).map(yD).join("&");return btoa(e)}function kD(A,e={}){{let t=`Solana error #${A}; Decode this error by running \`npx @solana/errors decode -- ${A}`;return Object.keys(e).length&&(t+=` '${ND(e)}'`),`${t}\``}}var mr=class extends Error{cause=this.cause;context;constructor(...[A,e]){let t,s;if(e){const{cause:r,...i}=e;r&&(s={cause:r}),Object.keys(i).length>0&&(t=i)}const n=kD(A,t);super(n,s),this.context={__code:A,...t},this.name="SolanaError"}};function MD(A,e){return"fixedSize"in e?e.fixedSize:e.getSizeFromValue(A)}function bD(A){return Object.freeze({...A,encode:e=>{const t=new Uint8Array(MD(e,A));return A.write(e,t,0),t}})}function FD(A){return Object.freeze({...A,decode:(e,t=0)=>A.read(e,t)[0]})}function Ts(A){return"fixedSize"in A&&typeof A.fixedSize=="number"}function vD(A,e){if(Ts(A)!==Ts(e))throw new mr(wD);if(Ts(A)&&Ts(e)&&A.fixedSize!==e.fixedSize)throw new mr(xD,{decoderFixedSize:e.fixedSize,encoderFixedSize:A.fixedSize});if(!Ts(A)&&!Ts(e)&&A.maxSize!==e.maxSize)throw new mr(DD,{decoderMaxSize:e.maxSize,encoderMaxSize:A.maxSize});return{...e,...A,decode:e.decode,encode:A.encode,read:e.read,write:A.write}}function GD(A,e,t=0){if(e.length-t<=0)throw new mr(fD,{codecDescription:A})}function SD(A,e,t,s=0){const n=t.length-s;if(n<e)throw new mr(mD,{bytesLength:n,codecDescription:A,expected:e})}function UD(A,e,t,s){if(s<e||s>t)throw new pD(uD,{codecDescription:A,max:t,min:e,value:s})}function fE(A){return A?.endian!==1}function RD(A){return bD({fixedSize:A.size,write(e,t,s){A.range&&UD(A.name,A.range[0],A.range[1],e);const n=new ArrayBuffer(A.size);return A.set(new DataView(n),e,fE(A.config)),t.set(new Uint8Array(n),s),s+A.size}})}function KD(A){return FD({fixedSize:A.size,read(e,t=0){GD(A.name,e,t),SD(A.name,A.size,e,t);const s=new DataView(LD(e,t,A.size));return[A.get(s,fE(A.config)),t+A.size]}})}function LD(A,e,t){const s=A.byteOffset+(e??0),n=t??A.byteLength;return A.buffer.slice(s,s+n)}var JD=(A={})=>RD({config:A,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,s)=>e.setBigUint64(0,BigInt(t),s),size:8}),TD=(A={})=>KD({config:A,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),jD=(A={})=>vD(JD(A),TD(A));class OD extends TypeError{constructor(e,t){let s;const{message:n,explanation:r,...i}=e,{path:a}=e,g=a.length===0?n:`At path: ${a.join(".")} -- ${n}`;super(r??g),r!=null&&(this.cause=g),Object.assign(this,i),this.name=this.constructor.name,this.failures=()=>s??(s=[e,...t()])}}function qD(A){return Wr(A)&&typeof A[Symbol.iterator]=="function"}function Wr(A){return typeof A=="object"&&A!=null}function jn(A){return Wr(A)&&!Array.isArray(A)}function Do(A){return typeof A=="symbol"?A.toString():typeof A=="string"?JSON.stringify(A):`${A}`}function YD(A){const{done:e,value:t}=A.next();return e?void 0:t}function HD(A,e,t,s){if(A===!0)return;A===!1?A={}:typeof A=="string"&&(A={message:A});const{path:n,branch:r}=e,{type:i}=t,{refinement:a,message:g=`Expected a value of type \`${i}\`${a?` with refinement \`${a}\``:""}, but received: \`${Do(s)}\``}=A;return{value:s,type:i,refinement:a,key:n[n.length-1],path:n,branch:r,...A,message:g}}function*wQ(A,e,t,s){qD(A)||(A=[A]);for(const n of A){const r=HD(n,e,t,s);r&&(yield r)}}function*Jg(A,e,t={}){const{path:s=[],branch:n=[A],coerce:r=!1,mask:i=!1}=t,a={path:s,branch:n,mask:i};r&&(A=e.coercer(A,a));let g="valid";for(const Q of e.validator(A,a))Q.explanation=t.message,g="not_valid",yield[Q,void 0];for(let[Q,B,u]of e.entries(A,a)){const E=Jg(B,u,{path:Q===void 0?s:[...s,Q],branch:Q===void 0?n:[...n,B],coerce:r,mask:i,message:t.message});for(const c of E)c[0]?(g=c[0].refinement!=null?"not_refined":"not_valid",yield[c[0],void 0]):r&&(B=c[1],Q===void 0?A=B:A instanceof Map?A.set(Q,B):A instanceof Set?A.add(B):Wr(A)&&(B!==void 0||Q in A)&&(A[Q]=B))}if(g!=="not_valid")for(const Q of e.refiner(A,a))Q.explanation=t.message,g="not_refined",yield[Q,void 0];g==="valid"&&(yield[void 0,A])}let Jo=class{constructor(e){const{type:t,schema:s,validator:n,refiner:r,coercer:i=g=>g,entries:a=function*(){}}=e;this.type=t,this.schema=s,this.entries=a,this.coercer=i,n?this.validator=(g,Q)=>{const B=n(g,Q);return wQ(B,Q,this,g)}:this.validator=()=>[],r?this.refiner=(g,Q)=>{const B=r(g,Q);return wQ(B,Q,this,g)}:this.refiner=()=>[]}assert(e,t){return PD(e,this,t)}create(e,t){return br(e,this,t)}is(e){return mE(e,this)}mask(e,t){return WD(e,this,t)}validate(e,t={}){return zr(e,this,t)}};function PD(A,e,t){const s=zr(A,e,{message:t});if(s[0])throw s[0]}function br(A,e,t){const s=zr(A,e,{coerce:!0,message:t});if(s[0])throw s[0];return s[1]}function WD(A,e,t){const s=zr(A,e,{coerce:!0,mask:!0,message:t});if(s[0])throw s[0];return s[1]}function mE(A,e){return!zr(A,e)[0]}function zr(A,e,t={}){const s=Jg(A,e,t),n=YD(s);return n[0]?[new OD(n[0],function*(){for(const i of s)i[0]&&(yield i[0])}),void 0]:[void 0,n[1]]}function bs(A,e){return new Jo({type:A,schema:null,validator:e})}function zD(){return bs("any",()=>!0)}function qA(A){return new Jo({type:"array",schema:A,*entries(e){if(A&&Array.isArray(e))for(const[t,s]of e.entries())yield[t,s,A]},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${Do(e)}`}})}function Ro(){return bs("boolean",A=>typeof A=="boolean")}function Tg(A){return bs("instance",e=>e instanceof A||`Expected a \`${A.name}\` instance, but received: ${Do(e)}`)}function Bt(A){const e=Do(A),t=typeof A;return new Jo({type:"literal",schema:t==="string"||t==="number"||t==="boolean"?A:null,validator(s){return s===A||`Expected the literal \`${e}\`, but received: ${Do(s)}`}})}function VD(){return bs("never",()=>!1)}function YA(A){return new Jo({...A,validator:(e,t)=>e===null||A.validator(e,t),refiner:(e,t)=>e===null||A.refiner(e,t)})}function BA(){return bs("number",A=>typeof A=="number"&&!isNaN(A)||`Expected a number, but received: ${Do(A)}`)}function oe(A){return new Jo({...A,validator:(e,t)=>e===void 0||A.validator(e,t),refiner:(e,t)=>e===void 0||A.refiner(e,t)})}function wE(A,e){return new Jo({type:"record",schema:null,*entries(t){if(Wr(t))for(const s in t){const n=t[s];yield[s,s,A],yield[s,n,e]}},validator(t){return jn(t)||`Expected an object, but received: ${Do(t)}`},coercer(t){return jn(t)?{...t}:t}})}function vA(){return bs("string",A=>typeof A=="string"||`Expected a string, but received: ${Do(A)}`)}function jg(A){const e=VD();return new Jo({type:"tuple",schema:null,*entries(t){if(Array.isArray(t)){const s=Math.max(A.length,t.length);for(let n=0;n<s;n++)yield[n,t[n],A[n]||e]}},validator(t){return Array.isArray(t)||`Expected an array, but received: ${Do(t)}`},coercer(t){return Array.isArray(t)?t.slice():t}})}function DA(A){const e=Object.keys(A);return new Jo({type:"type",schema:A,*entries(t){if(Wr(t))for(const s of e)yield[s,t[s],A[s]]},validator(t){return jn(t)||`Expected an object, but received: ${Do(t)}`},coercer(t){return jn(t)?{...t}:t}})}function to(A){const e=A.map(t=>t.type).join(" | ");return new Jo({type:"union",schema:null,coercer(t,s){for(const n of A){const[r,i]=n.validate(t,{coerce:!0,mask:s.mask});if(!r)return i}return t},validator(t,s){const n=[];for(const r of A){const[...i]=Jg(t,r,s),[a]=i;if(a[0])for(const[g]of i)g&&n.push(g);else return[]}return[`Expected the value to satisfy a union of \`${e}\`, but received: ${Do(t)}`,...n]}})}function ar(){return bs("unknown",()=>!0)}function Vr(A,e,t){return new Jo({...A,coercer:(s,n)=>mE(s,e)?A.coercer(t(s,n),n):A.coercer(s,n)})}var ln,_D=new Uint8Array(16);function xE(){if(!ln&&(ln=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto),!ln))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ln(_D)}const ZD=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function Qi(A){return typeof A=="string"&&ZD.test(A)}var vt=[];for(var ji=0;ji<256;++ji)vt.push((ji+256).toString(16).substr(1));function Bi(A){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,t=(vt[A[e+0]]+vt[A[e+1]]+vt[A[e+2]]+vt[A[e+3]]+"-"+vt[A[e+4]]+vt[A[e+5]]+"-"+vt[A[e+6]]+vt[A[e+7]]+"-"+vt[A[e+8]]+vt[A[e+9]]+"-"+vt[A[e+10]]+vt[A[e+11]]+vt[A[e+12]]+vt[A[e+13]]+vt[A[e+14]]+vt[A[e+15]]).toLowerCase();if(!Qi(t))throw TypeError("Stringified UUID is invalid");return t}var xQ,Oi,qi=0,Yi=0;function XD(A,e,t){var s=e&&t||0,n=e||new Array(16);A=A||{};var r=A.node||xQ,i=A.clockseq!==void 0?A.clockseq:Oi;if(r==null||i==null){var a=A.random||(A.rng||xE)();r==null&&(r=xQ=[a[0]|1,a[1],a[2],a[3],a[4],a[5]]),i==null&&(i=Oi=(a[6]<<8|a[7])&16383)}var g=A.msecs!==void 0?A.msecs:Date.now(),Q=A.nsecs!==void 0?A.nsecs:Yi+1,B=g-qi+(Q-Yi)/1e4;if(B<0&&A.clockseq===void 0&&(i=i+1&16383),(B<0||g>qi)&&A.nsecs===void 0&&(Q=0),Q>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");qi=g,Yi=Q,Oi=i,g+=122192928e5;var u=((g&268435455)*1e4+Q)%4294967296;n[s++]=u>>>24&255,n[s++]=u>>>16&255,n[s++]=u>>>8&255,n[s++]=u&255;var E=g/4294967296*1e4&268435455;n[s++]=E>>>8&255,n[s++]=E&255,n[s++]=E>>>24&15|16,n[s++]=E>>>16&255,n[s++]=i>>>8|128,n[s++]=i&255;for(var c=0;c<6;++c)n[s+c]=r[c];return e||Bi(n)}function DE(A){if(!Qi(A))throw TypeError("Invalid UUID");var e,t=new Uint8Array(16);return t[0]=(e=parseInt(A.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(A.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(A.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(A.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(A.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}function $D(A){A=unescape(encodeURIComponent(A));for(var e=[],t=0;t<A.length;++t)e.push(A.charCodeAt(t));return e}var A2="6ba7b810-9dad-11d1-80b4-00c04fd430c8",e2="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function yE(A,e,t){function s(n,r,i,a){if(typeof n=="string"&&(n=$D(n)),typeof r=="string"&&(r=DE(r)),r.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var g=new Uint8Array(16+n.length);if(g.set(r),g.set(n,r.length),g=t(g),g[6]=g[6]&15|e,g[8]=g[8]&63|128,i){a=a||0;for(var Q=0;Q<16;++Q)i[a+Q]=g[Q];return i}return Bi(g)}try{s.name=A}catch{}return s.DNS=A2,s.URL=e2,s}function t2(A){if(typeof A=="string"){var e=unescape(encodeURIComponent(A));A=new Uint8Array(e.length);for(var t=0;t<e.length;++t)A[t]=e.charCodeAt(t)}return o2(s2(r2(A),A.length*8))}function o2(A){for(var e=[],t=A.length*32,s="0123456789abcdef",n=0;n<t;n+=8){var r=A[n>>5]>>>n%32&255,i=parseInt(s.charAt(r>>>4&15)+s.charAt(r&15),16);e.push(i)}return e}function NE(A){return(A+64>>>9<<4)+14+1}function s2(A,e){A[e>>5]|=128<<e%32,A[NE(e)-1]=e;for(var t=1732584193,s=-271733879,n=-1732584194,r=271733878,i=0;i<A.length;i+=16){var a=t,g=s,Q=n,B=r;t=jt(t,s,n,r,A[i],7,-680876936),r=jt(r,t,s,n,A[i+1],12,-389564586),n=jt(n,r,t,s,A[i+2],17,606105819),s=jt(s,n,r,t,A[i+3],22,-1044525330),t=jt(t,s,n,r,A[i+4],7,-176418897),r=jt(r,t,s,n,A[i+5],12,1200080426),n=jt(n,r,t,s,A[i+6],17,-1473231341),s=jt(s,n,r,t,A[i+7],22,-45705983),t=jt(t,s,n,r,A[i+8],7,1770035416),r=jt(r,t,s,n,A[i+9],12,-1958414417),n=jt(n,r,t,s,A[i+10],17,-42063),s=jt(s,n,r,t,A[i+11],22,-1990404162),t=jt(t,s,n,r,A[i+12],7,1804603682),r=jt(r,t,s,n,A[i+13],12,-40341101),n=jt(n,r,t,s,A[i+14],17,-1502002290),s=jt(s,n,r,t,A[i+15],22,1236535329),t=Ot(t,s,n,r,A[i+1],5,-165796510),r=Ot(r,t,s,n,A[i+6],9,-1069501632),n=Ot(n,r,t,s,A[i+11],14,643717713),s=Ot(s,n,r,t,A[i],20,-373897302),t=Ot(t,s,n,r,A[i+5],5,-701558691),r=Ot(r,t,s,n,A[i+10],9,38016083),n=Ot(n,r,t,s,A[i+15],14,-660478335),s=Ot(s,n,r,t,A[i+4],20,-405537848),t=Ot(t,s,n,r,A[i+9],5,568446438),r=Ot(r,t,s,n,A[i+14],9,-1019803690),n=Ot(n,r,t,s,A[i+3],14,-187363961),s=Ot(s,n,r,t,A[i+8],20,1163531501),t=Ot(t,s,n,r,A[i+13],5,-1444681467),r=Ot(r,t,s,n,A[i+2],9,-51403784),n=Ot(n,r,t,s,A[i+7],14,1735328473),s=Ot(s,n,r,t,A[i+12],20,-1926607734),t=qt(t,s,n,r,A[i+5],4,-378558),r=qt(r,t,s,n,A[i+8],11,-2022574463),n=qt(n,r,t,s,A[i+11],16,1839030562),s=qt(s,n,r,t,A[i+14],23,-35309556),t=qt(t,s,n,r,A[i+1],4,-1530992060),r=qt(r,t,s,n,A[i+4],11,1272893353),n=qt(n,r,t,s,A[i+7],16,-155497632),s=qt(s,n,r,t,A[i+10],23,-1094730640),t=qt(t,s,n,r,A[i+13],4,681279174),r=qt(r,t,s,n,A[i],11,-358537222),n=qt(n,r,t,s,A[i+3],16,-722521979),s=qt(s,n,r,t,A[i+6],23,76029189),t=qt(t,s,n,r,A[i+9],4,-640364487),r=qt(r,t,s,n,A[i+12],11,-421815835),n=qt(n,r,t,s,A[i+15],16,530742520),s=qt(s,n,r,t,A[i+2],23,-995338651),t=Yt(t,s,n,r,A[i],6,-198630844),r=Yt(r,t,s,n,A[i+7],10,1126891415),n=Yt(n,r,t,s,A[i+14],15,-1416354905),s=Yt(s,n,r,t,A[i+5],21,-57434055),t=Yt(t,s,n,r,A[i+12],6,1700485571),r=Yt(r,t,s,n,A[i+3],10,-1894986606),n=Yt(n,r,t,s,A[i+10],15,-1051523),s=Yt(s,n,r,t,A[i+1],21,-2054922799),t=Yt(t,s,n,r,A[i+8],6,1873313359),r=Yt(r,t,s,n,A[i+15],10,-30611744),n=Yt(n,r,t,s,A[i+6],15,-1560198380),s=Yt(s,n,r,t,A[i+13],21,1309151649),t=Yt(t,s,n,r,A[i+4],6,-145523070),r=Yt(r,t,s,n,A[i+11],10,-1120210379),n=Yt(n,r,t,s,A[i+2],15,718787259),s=Yt(s,n,r,t,A[i+9],21,-343485551),t=is(t,a),s=is(s,g),n=is(n,Q),r=is(r,B)}return[t,s,n,r]}function r2(A){if(A.length===0)return[];for(var e=A.length*8,t=new Uint32Array(NE(e)),s=0;s<e;s+=8)t[s>>5]|=(A[s/8]&255)<<s%32;return t}function is(A,e){var t=(A&65535)+(e&65535),s=(A>>16)+(e>>16)+(t>>16);return s<<16|t&65535}function n2(A,e){return A<<e|A>>>32-e}function ci(A,e,t,s,n,r){return is(n2(is(is(e,A),is(s,r)),n),t)}function jt(A,e,t,s,n,r,i){return ci(e&t|~e&s,A,e,n,r,i)}function Ot(A,e,t,s,n,r,i){return ci(e&s|t&~s,A,e,n,r,i)}function qt(A,e,t,s,n,r,i){return ci(e^t^s,A,e,n,r,i)}function Yt(A,e,t,s,n,r,i){return ci(t^(e|~s),A,e,n,r,i)}var i2=yE("v3",48,t2);function a2(A,e,t){A=A||{};var s=A.random||(A.rng||xE)();if(s[6]=s[6]&15|64,s[8]=s[8]&63|128,e){t=t||0;for(var n=0;n<16;++n)e[t+n]=s[n];return e}return Bi(s)}function g2(A,e,t,s){switch(A){case 0:return e&t^~e&s;case 1:return e^t^s;case 2:return e&t^e&s^t&s;case 3:return e^t^s}}function Hi(A,e){return A<<e|A>>>32-e}function l2(A){var e=[1518500249,1859775393,2400959708,3395469782],t=[1732584193,4023233417,2562383102,271733878,3285377520];if(typeof A=="string"){var s=unescape(encodeURIComponent(A));A=[];for(var n=0;n<s.length;++n)A.push(s.charCodeAt(n))}else Array.isArray(A)||(A=Array.prototype.slice.call(A));A.push(128);for(var r=A.length/4+2,i=Math.ceil(r/16),a=new Array(i),g=0;g<i;++g){for(var Q=new Uint32Array(16),B=0;B<16;++B)Q[B]=A[g*64+B*4]<<24|A[g*64+B*4+1]<<16|A[g*64+B*4+2]<<8|A[g*64+B*4+3];a[g]=Q}a[i-1][14]=(A.length-1)*8/Math.pow(2,32),a[i-1][14]=Math.floor(a[i-1][14]),a[i-1][15]=(A.length-1)*8&4294967295;for(var u=0;u<i;++u){for(var E=new Uint32Array(80),c=0;c<16;++c)E[c]=a[u][c];for(var h=16;h<80;++h)E[h]=Hi(E[h-3]^E[h-8]^E[h-14]^E[h-16],1);for(var f=t[0],d=t[1],D=t[2],R=t[3],M=t[4],q=0;q<80;++q){var G=Math.floor(q/20),T=Hi(f,5)+g2(G,d,D,R)+M+e[G]+E[q]>>>0;M=R,R=D,D=Hi(d,30)>>>0,d=f,f=T}t[0]=t[0]+f>>>0,t[1]=t[1]+d>>>0,t[2]=t[2]+D>>>0,t[3]=t[3]+R>>>0,t[4]=t[4]+M>>>0}return[t[0]>>24&255,t[0]>>16&255,t[0]>>8&255,t[0]&255,t[1]>>24&255,t[1]>>16&255,t[1]>>8&255,t[1]&255,t[2]>>24&255,t[2]>>16&255,t[2]>>8&255,t[2]&255,t[3]>>24&255,t[3]>>16&255,t[3]>>8&255,t[3]&255,t[4]>>24&255,t[4]>>16&255,t[4]>>8&255,t[4]&255]}var Q2=yE("v5",80,l2);const B2="00000000-0000-0000-0000-000000000000";function c2(A){if(!Qi(A))throw TypeError("Invalid UUID");return parseInt(A.substr(14,1),16)}const E2=Object.freeze(Object.defineProperty({__proto__:null,NIL:B2,parse:DE,stringify:Bi,v1:XD,v3:i2,v4:a2,v5:Q2,validate:Qi,version:c2},Symbol.toStringTag,{value:"Module"})),kE=za(E2);var Pi,DQ;function C2(){if(DQ)return Pi;DQ=1;const A=kE.v4;return Pi=function(t,s,n,r){if(typeof t!="string")throw new TypeError(t+" must be a string");r=r||{};const i=typeof r.version=="number"?r.version:2;if(i!==1&&i!==2)throw new TypeError(i+" must be 1 or 2");const a={method:t};if(i===2&&(a.jsonrpc="2.0"),s){if(typeof s!="object"&&!Array.isArray(s))throw new TypeError(s+" must be an object, array or omitted");a.params=s}if(typeof n>"u"){const g=typeof r.generator=="function"?r.generator:function(){return A()};a.id=g(a,r)}else i===2&&n===null?r.notificationIdNull&&(a.id=null):a.id=n;return a},Pi}var Wi,yQ;function u2(){if(yQ)return Wi;yQ=1;const A=kE.v4,e=C2(),t=function(s,n){if(!(this instanceof t))return new t(s,n);n||(n={}),this.options={reviver:typeof n.reviver<"u"?n.reviver:null,replacer:typeof n.replacer<"u"?n.replacer:null,generator:typeof n.generator<"u"?n.generator:function(){return A()},version:typeof n.version<"u"?n.version:2,notificationIdNull:typeof n.notificationIdNull=="boolean"?n.notificationIdNull:!1},this.callServer=s};return Wi=t,t.prototype.request=function(s,n,r,i){const a=this;let g=null;const Q=Array.isArray(s)&&typeof n=="function";if(this.options.version===1&&Q)throw new TypeError("JSON-RPC 1.0 does not support batching");if(Q||!Q&&s&&typeof s=="object"&&typeof n=="function")i=n,g=s;else{typeof r=="function"&&(i=r,r=void 0);const E=typeof i=="function";try{g=e(s,n,r,{generator:this.options.generator,version:this.options.version,notificationIdNull:this.options.notificationIdNull})}catch(c){if(E){i(c);return}throw c}if(!E)return g}let u;try{u=JSON.stringify(g,this.options.replacer)}catch(E){i(E);return}return this.callServer(u,function(E,c){a._parseResponse(E,c,i)}),g},t.prototype._parseResponse=function(s,n,r){if(s){r(s);return}if(!n){r();return}let i;try{i=JSON.parse(n,this.options.reviver)}catch(a){r(a);return}if(r.length===3)if(Array.isArray(i)){const a=function(Q){return typeof Q.error<"u"},g=function(Q){return!a(Q)};r(null,i.filter(a),i.filter(g));return}else{r(null,i.error,i.result);return}r(null,i)},Wi}u2();var zi={exports:{}},NQ;function I2(){return NQ||(NQ=1,(function(A){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function n(g,Q,B){this.fn=g,this.context=Q,this.once=B||!1}function r(g,Q,B,u,E){if(typeof B!="function")throw new TypeError("The listener must be a function");var c=new n(B,u||g,E),h=t?t+Q:Q;return g._events[h]?g._events[h].fn?g._events[h]=[g._events[h],c]:g._events[h].push(c):(g._events[h]=c,g._eventsCount++),g}function i(g,Q){--g._eventsCount===0?g._events=new s:delete g._events[Q]}function a(){this._events=new s,this._eventsCount=0}a.prototype.eventNames=function(){var Q=[],B,u;if(this._eventsCount===0)return Q;for(u in B=this._events)e.call(B,u)&&Q.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?Q.concat(Object.getOwnPropertySymbols(B)):Q},a.prototype.listeners=function(Q){var B=t?t+Q:Q,u=this._events[B];if(!u)return[];if(u.fn)return[u.fn];for(var E=0,c=u.length,h=new Array(c);E<c;E++)h[E]=u[E].fn;return h},a.prototype.listenerCount=function(Q){var B=t?t+Q:Q,u=this._events[B];return u?u.fn?1:u.length:0},a.prototype.emit=function(Q,B,u,E,c,h){var f=t?t+Q:Q;if(!this._events[f])return!1;var d=this._events[f],D=arguments.length,R,M;if(d.fn){switch(d.once&&this.removeListener(Q,d.fn,void 0,!0),D){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,B),!0;case 3:return d.fn.call(d.context,B,u),!0;case 4:return d.fn.call(d.context,B,u,E),!0;case 5:return d.fn.call(d.context,B,u,E,c),!0;case 6:return d.fn.call(d.context,B,u,E,c,h),!0}for(M=1,R=new Array(D-1);M<D;M++)R[M-1]=arguments[M];d.fn.apply(d.context,R)}else{var q=d.length,G;for(M=0;M<q;M++)switch(d[M].once&&this.removeListener(Q,d[M].fn,void 0,!0),D){case 1:d[M].fn.call(d[M].context);break;case 2:d[M].fn.call(d[M].context,B);break;case 3:d[M].fn.call(d[M].context,B,u);break;case 4:d[M].fn.call(d[M].context,B,u,E);break;default:if(!R)for(G=1,R=new Array(D-1);G<D;G++)R[G-1]=arguments[G];d[M].fn.apply(d[M].context,R)}}return!0},a.prototype.on=function(Q,B,u){return r(this,Q,B,u,!1)},a.prototype.once=function(Q,B,u){return r(this,Q,B,u,!0)},a.prototype.removeListener=function(Q,B,u,E){var c=t?t+Q:Q;if(!this._events[c])return this;if(!B)return i(this,c),this;var h=this._events[c];if(h.fn)h.fn===B&&(!E||h.once)&&(!u||h.context===u)&&i(this,c);else{for(var f=0,d=[],D=h.length;f<D;f++)(h[f].fn!==B||E&&!h[f].once||u&&h[f].context!==u)&&d.push(h[f]);d.length?this._events[c]=d.length===1?d[0]:d:i(this,c)}return this},a.prototype.removeAllListeners=function(Q){var B;return Q?(B=t?t+Q:Q,this._events[B]&&i(this,B)):(this._events=new s,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=t,a.EventEmitter=a,A.exports=a})(zi)),zi.exports}I2();class ME extends Hc{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,qc(e);const s=vg(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,r=new Uint8Array(n);r.set(s.length>n?e.create().update(s).digest():s);for(let i=0;i<r.length;i++)r[i]^=54;this.iHash.update(r),this.oHash=e.create();for(let i=0;i<r.length;i++)r[i]^=106;this.oHash.update(r),_s(r)}update(e){return Gn(this),this.iHash.update(e),this}digestInto(e){Gn(this),ks(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:s,finished:n,destroyed:r,blockLen:i,outputLen:a}=this;return e=e,e.finished=n,e.destroyed=r,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=s._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const bE=(A,e,t)=>new ME(A,e).update(t).digest();bE.create=(A,e)=>new ME(A,e);const kQ=(A,e)=>(A+(A>=0?e:-e)/FE)/e;function d2(A,e,t){const[[s,n],[r,i]]=e,a=kQ(i*A,t),g=kQ(-n*A,t);let Q=A-a*s-g*r,B=-a*n-g*i;const u=Q<Vo,E=B<Vo;u&&(Q=-Q),E&&(B=-B);const c=Hr(Math.ceil(Xc(t)/2))+Ps;if(Q<Vo||Q>=c||B<Vo||B>=c)throw new Error("splitScalar (endomorphism): failed, k="+A);return{k1neg:u,k1:Q,k2neg:E,k2:B}}function Ua(A){if(!["compact","recovered","der"].includes(A))throw new Error('Signature format must be "compact", "recovered", or "der"');return A}function Vi(A,e){const t={};for(let s of Object.keys(e))t[s]=A[s]===void 0?e[s]:A[s];return Ds(t.lowS,"lowS"),Ds(t.prehash,"prehash"),t.format!==void 0&&Ua(t.format),t}class h2 extends Error{constructor(e=""){super(e)}}const Po={Err:h2,_tlv:{encode:(A,e)=>{const{Err:t}=Po;if(A<0||A>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");const s=e.length/2,n=an(s);if(n.length/2&128)throw new t("tlv.encode: long form length too big");const r=s>127?an(n.length/2|128):"";return an(A)+r+n+e},decode(A,e){const{Err:t}=Po;let s=0;if(A<0||A>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[s++]!==A)throw new t("tlv.decode: wrong tlv");const n=e[s++],r=!!(n&128);let i=0;if(!r)i=n;else{const g=n&127;if(!g)throw new t("tlv.decode(long): indefinite length not supported");if(g>4)throw new t("tlv.decode(long): byte length is too big");const Q=e.subarray(s,s+g);if(Q.length!==g)throw new t("tlv.decode: length bytes not complete");if(Q[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(const B of Q)i=i<<8|B;if(s+=g,i<128)throw new t("tlv.decode(long): not minimal encoding")}const a=e.subarray(s,s+i);if(a.length!==i)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(s+i)}}},_int:{encode(A){const{Err:e}=Po;if(A<Vo)throw new e("integer: negative integers are not allowed");let t=an(A);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(A){const{Err:e}=Po;if(A[0]&128)throw new e("invalid signature integer: negative");if(A[0]===0&&!(A[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return ai(A)}},toSig(A){const{Err:e,_int:t,_tlv:s}=Po,n=ut("signature",A),{v:r,l:i}=s.decode(48,n);if(i.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:g}=s.decode(2,r),{v:Q,l:B}=s.decode(2,g);if(B.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(Q)}},hexFromSig(A){const{_tlv:e,_int:t}=Po,s=e.encode(2,t.encode(A.r)),n=e.encode(2,t.encode(A.s)),r=s+n;return e.encode(48,r)}},Vo=BigInt(0),Ps=BigInt(1),FE=BigInt(2),Qn=BigInt(3),p2=BigInt(4);function qs(A,e){const{BYTES:t}=A;let s;if(typeof e=="bigint")s=e;else{let n=ut("private key",e);try{s=A.fromBytes(n)}catch{throw new Error(`invalid private key: expected ui8a of size ${t}, got ${typeof e}`)}}if(!A.isValidNot0(s))throw new Error("invalid private key: out of range [1..N-1]");return s}function f2(A,e={}){const t=EE("weierstrass",A,e),{Fp:s,Fn:n}=t;let r=t.CURVE;const{h:i,n:a}=r;Pr(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:g}=e;if(g&&(!s.is0(r.a)||typeof g.beta!="bigint"||!Array.isArray(g.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const Q=GE(s,n);function B(){if(!s.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function u(Y,x,l){const{x:I,y}=x.toAffine(),b=s.toBytes(I);if(Ds(l,"isCompressed"),l){B();const J=!s.isOdd(y);return Go(vE(J),b)}else return Go(Uint8Array.of(4),b,s.toBytes(y))}function E(Y){xo(Y,void 0,"Point");const{publicKey:x,publicKeyUncompressed:l}=Q,I=Y.length,y=Y[0],b=Y.subarray(1);if(I===x&&(y===2||y===3)){const J=s.fromBytes(b);if(!s.isValid(J))throw new Error("bad point: is not on curve, wrong x");const H=f(J);let v;try{v=s.sqrt(H)}catch(p){const L=p instanceof Error?": "+p.message:"";throw new Error("bad point: is not on curve, sqrt error"+L)}B();const K=s.isOdd(v);return(y&1)===1!==K&&(v=s.neg(v)),{x:J,y:v}}else if(I===l&&y===4){const J=s.BYTES,H=s.fromBytes(b.subarray(0,J)),v=s.fromBytes(b.subarray(J,J*2));if(!d(H,v))throw new Error("bad point: is not on curve");return{x:H,y:v}}else throw new Error(`bad point: got length ${I}, expected compressed=${x} or uncompressed=${l}`)}const c=e.toBytes||u,h=e.fromBytes||E;function f(Y){const x=s.sqr(Y),l=s.mul(x,Y);return s.add(s.add(l,s.mul(Y,r.a)),r.b)}function d(Y,x){const l=s.sqr(x),I=f(Y);return s.eql(l,I)}if(!d(r.Gx,r.Gy))throw new Error("bad curve params: generator point");const D=s.mul(s.pow(r.a,Qn),p2),R=s.mul(s.sqr(r.b),BigInt(27));if(s.is0(s.add(D,R)))throw new Error("bad curve params: a or b");function M(Y,x,l=!1){if(!s.isValid(x)||l&&s.is0(x))throw new Error(`bad point coordinate ${Y}`);return x}function q(Y){if(!(Y instanceof U))throw new Error("ProjectivePoint expected")}function G(Y){if(!g||!g.basises)throw new Error("no endo");return d2(Y,g.basises,n.ORDER)}const T=Un((Y,x)=>{const{X:l,Y:I,Z:y}=Y;if(s.eql(y,s.ONE))return{x:l,y:I};const b=Y.is0();x==null&&(x=b?s.ONE:s.inv(y));const J=s.mul(l,x),H=s.mul(I,x),v=s.mul(y,x);if(b)return{x:s.ZERO,y:s.ZERO};if(!s.eql(v,s.ONE))throw new Error("invZ was invalid");return{x:J,y:H}}),Z=Un(Y=>{if(Y.is0()){if(e.allowInfinityPoint&&!s.is0(Y.Y))return;throw new Error("bad point: ZERO")}const{x,y:l}=Y.toAffine();if(!s.isValid(x)||!s.isValid(l))throw new Error("bad point: x or y not field elements");if(!d(x,l))throw new Error("bad point: equation left != right");if(!Y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function X(Y,x,l,I,y){return l=new U(s.mul(l.X,Y),l.Y,l.Z),x=Rn(I,x),l=Rn(y,l),x.add(l)}class U{constructor(x,l,I){this.X=M("x",x),this.Y=M("y",l,!0),this.Z=M("z",I),Object.freeze(this)}static CURVE(){return r}static fromAffine(x){const{x:l,y:I}=x||{};if(!x||!s.isValid(l)||!s.isValid(I))throw new Error("invalid affine point");if(x instanceof U)throw new Error("projective point not allowed");return s.is0(l)&&s.is0(I)?U.ZERO:new U(l,I,s.ONE)}static fromBytes(x){const l=U.fromAffine(h(xo(x,void 0,"point")));return l.assertValidity(),l}static fromHex(x){return U.fromBytes(ut("pointHex",x))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,l=!0){return j.createCache(this,x),l||this.multiply(Qn),this}assertValidity(){Z(this)}hasEvenY(){const{y:x}=this.toAffine();if(!s.isOdd)throw new Error("Field doesn't support isOdd");return!s.isOdd(x)}equals(x){q(x);const{X:l,Y:I,Z:y}=this,{X:b,Y:J,Z:H}=x,v=s.eql(s.mul(l,H),s.mul(b,y)),K=s.eql(s.mul(I,H),s.mul(J,y));return v&&K}negate(){return new U(this.X,s.neg(this.Y),this.Z)}double(){const{a:x,b:l}=r,I=s.mul(l,Qn),{X:y,Y:b,Z:J}=this;let H=s.ZERO,v=s.ZERO,K=s.ZERO,C=s.mul(y,y),p=s.mul(b,b),L=s.mul(J,J),S=s.mul(y,b);return S=s.add(S,S),K=s.mul(y,J),K=s.add(K,K),H=s.mul(x,K),v=s.mul(I,L),v=s.add(H,v),H=s.sub(p,v),v=s.add(p,v),v=s.mul(H,v),H=s.mul(S,H),K=s.mul(I,K),L=s.mul(x,L),S=s.sub(C,L),S=s.mul(x,S),S=s.add(S,K),K=s.add(C,C),C=s.add(K,C),C=s.add(C,L),C=s.mul(C,S),v=s.add(v,C),L=s.mul(b,J),L=s.add(L,L),C=s.mul(L,S),H=s.sub(H,C),K=s.mul(L,p),K=s.add(K,K),K=s.add(K,K),new U(H,v,K)}add(x){q(x);const{X:l,Y:I,Z:y}=this,{X:b,Y:J,Z:H}=x;let v=s.ZERO,K=s.ZERO,C=s.ZERO;const p=r.a,L=s.mul(r.b,Qn);let S=s.mul(l,b),$=s.mul(I,J),AA=s.mul(y,H),sA=s.add(l,I),oA=s.add(b,J);sA=s.mul(sA,oA),oA=s.add(S,$),sA=s.sub(sA,oA),oA=s.add(l,y);let bA=s.add(b,H);return oA=s.mul(oA,bA),bA=s.add(S,AA),oA=s.sub(oA,bA),bA=s.add(I,y),v=s.add(J,H),bA=s.mul(bA,v),v=s.add($,AA),bA=s.sub(bA,v),C=s.mul(p,oA),v=s.mul(L,AA),C=s.add(v,C),v=s.sub($,C),C=s.add($,C),K=s.mul(v,C),$=s.add(S,S),$=s.add($,S),AA=s.mul(p,AA),oA=s.mul(L,oA),$=s.add($,AA),AA=s.sub(S,AA),AA=s.mul(p,AA),oA=s.add(oA,AA),S=s.mul($,oA),K=s.add(K,S),S=s.mul(bA,oA),v=s.mul(sA,v),v=s.sub(v,S),S=s.mul(sA,$),C=s.mul(bA,C),C=s.add(C,S),new U(v,K,C)}subtract(x){return this.add(x.negate())}is0(){return this.equals(U.ZERO)}multiply(x){const{endo:l}=e;if(!n.isValidNot0(x))throw new Error("invalid scalar: out of range");let I,y;const b=J=>j.cached(this,J,H=>ps(U,H));if(l){const{k1neg:J,k1:H,k2neg:v,k2:K}=G(x),{p:C,f:p}=b(H),{p:L,f:S}=b(K);y=p.add(S),I=X(l.beta,C,L,J,v)}else{const{p:J,f:H}=b(x);I=J,y=H}return ps(U,[I,y])[0]}multiplyUnsafe(x){const{endo:l}=e,I=this;if(!n.isValid(x))throw new Error("invalid scalar: out of range");if(x===Vo||I.is0())return U.ZERO;if(x===Ps)return I;if(j.hasCache(this))return this.multiply(x);if(l){const{k1neg:y,k1:b,k2neg:J,k2:H}=G(x),{p1:v,p2:K}=Kx(U,I,b,H);return X(l.beta,v,K,y,J)}else return j.unsafe(I,x)}multiplyAndAddUnsafe(x,l,I){const y=this.multiplyUnsafe(l).add(x.multiplyUnsafe(I));return y.is0()?void 0:y}toAffine(x){return T(this,x)}isTorsionFree(){const{isTorsionFree:x}=e;return i===Ps?!0:x?x(U,this):j.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:x}=e;return i===Ps?this:x?x(U,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(x=!0){return Ds(x,"isCompressed"),this.assertValidity(),c(U,this,x)}toHex(x=!0){return ms(this.toBytes(x))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(x=!0){return this.toBytes(x)}_setWindowSize(x){this.precompute(x)}static normalizeZ(x){return ps(U,x)}static msm(x,l){return cE(U,n,x,l)}static fromPrivateKey(x){return U.BASE.multiply(qs(n,x))}}U.BASE=new U(r.Gx,r.Gy,s.ONE),U.ZERO=new U(s.ZERO,s.ONE,s.ZERO),U.Fp=s,U.Fn=n;const O=n.BITS,j=new BE(U,e.endo?Math.ceil(O/2):O);return U.BASE.precompute(8),U}function vE(A){return Uint8Array.of(A?2:3)}function GE(A,e){return{secretKey:e.BYTES,publicKey:1+A.BYTES,publicKeyUncompressed:1+2*A.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function m2(A,e={}){const{Fn:t}=A,s=e.randomBytes||Gg,n=Object.assign(GE(A.Fp,t),{seed:gE(t.ORDER)});function r(c){try{return!!qs(t,c)}catch{return!1}}function i(c,h){const{publicKey:f,publicKeyUncompressed:d}=n;try{const D=c.length;return h===!0&&D!==f||h===!1&&D!==d?!1:!!A.fromBytes(c)}catch{return!1}}function a(c=s(n.seed)){return Sx(xo(c,n.seed,"seed"),t.ORDER)}function g(c,h=!0){return A.BASE.multiply(qs(t,c)).toBytes(h)}function Q(c){const h=a(c);return{secretKey:h,publicKey:g(h)}}function B(c){if(typeof c=="bigint")return!1;if(c instanceof A)return!0;const{secretKey:h,publicKey:f,publicKeyUncompressed:d}=n;if(t.allowedLengths||h===f)return;const D=ut("key",c).length;return D===f||D===d}function u(c,h,f=!0){if(B(c)===!0)throw new Error("first arg must be private key");if(B(h)===!1)throw new Error("second arg must be public key");const d=qs(t,c);return A.fromHex(h).multiply(d).toBytes(f)}return Object.freeze({getPublicKey:g,getSharedSecret:u,keygen:Q,Point:A,utils:{isValidSecretKey:r,isValidPublicKey:i,randomSecretKey:a,isValidPrivateKey:r,randomPrivateKey:a,normPrivateKeyToScalar:c=>qs(t,c),precompute(c=8,h=A.BASE){return h.precompute(c,!1)}},lengths:n})}function w2(A,e,t={}){qc(e),Pr(t,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const s=t.randomBytes||Gg,n=t.hmac||((l,...I)=>bE(e,l,Go(...I))),{Fp:r,Fn:i}=A,{ORDER:a,BITS:g}=i,{keygen:Q,getPublicKey:B,getSharedSecret:u,utils:E,lengths:c}=m2(A,t),h={prehash:!1,lowS:typeof t.lowS=="boolean"?t.lowS:!1,format:void 0,extraEntropy:!1},f="compact";function d(l){const I=a>>Ps;return l>I}function D(l,I){if(!i.isValidNot0(I))throw new Error(`invalid signature ${l}: out of range 1..Point.Fn.ORDER`);return I}function R(l,I){Ua(I);const y=c.signature,b=I==="compact"?y:I==="recovered"?y+1:void 0;return xo(l,b,`${I} signature`)}class M{constructor(I,y,b){this.r=D("r",I),this.s=D("s",y),b!=null&&(this.recovery=b),Object.freeze(this)}static fromBytes(I,y=f){R(I,y);let b;if(y==="der"){const{r:K,s:C}=Po.toSig(xo(I));return new M(K,C)}y==="recovered"&&(b=I[0],y="compact",I=I.subarray(1));const J=i.BYTES,H=I.subarray(0,J),v=I.subarray(J,J*2);return new M(i.fromBytes(H),i.fromBytes(v),b)}static fromHex(I,y){return this.fromBytes(Sn(I),y)}addRecoveryBit(I){return new M(this.r,this.s,I)}recoverPublicKey(I){const y=r.ORDER,{r:b,s:J,recovery:H}=this;if(H==null||![0,1,2,3].includes(H))throw new Error("recovery id invalid");if(a*FE<y&&H>1)throw new Error("recovery id is ambiguous for h>1 curve");const K=H===2||H===3?b+a:b;if(!r.isValid(K))throw new Error("recovery id 2 or 3 invalid");const C=r.toBytes(K),p=A.fromBytes(Go(vE((H&1)===0),C)),L=i.inv(K),S=G(ut("msgHash",I)),$=i.create(-S*L),AA=i.create(J*L),sA=A.BASE.multiplyUnsafe($).add(p.multiplyUnsafe(AA));if(sA.is0())throw new Error("point at infinify");return sA.assertValidity(),sA}hasHighS(){return d(this.s)}toBytes(I=f){if(Ua(I),I==="der")return Sn(Po.hexFromSig(this));const y=i.toBytes(this.r),b=i.toBytes(this.s);if(I==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Go(Uint8Array.of(this.recovery),y,b)}return Go(y,b)}toHex(I){return ms(this.toBytes(I))}assertValidity(){}static fromCompact(I){return M.fromBytes(ut("sig",I),"compact")}static fromDER(I){return M.fromBytes(ut("sig",I),"der")}normalizeS(){return this.hasHighS()?new M(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return ms(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return ms(this.toBytes("compact"))}}const q=t.bits2int||function(I){if(I.length>8192)throw new Error("input is too large");const y=ai(I),b=I.length*8-g;return b>0?y>>BigInt(b):y},G=t.bits2int_modN||function(I){return i.create(q(I))},T=Hr(g);function Z(l){return Sa("num < 2^"+g,l,Vo,T),i.toBytes(l)}function X(l,I){return xo(l,void 0,"message"),I?xo(e(l),void 0,"prehashed message"):l}function U(l,I,y){if(["recovered","canonical"].some($=>$ in y))throw new Error("sign() legacy options not supported");const{lowS:b,prehash:J,extraEntropy:H}=Vi(y,h);l=X(l,J);const v=G(l),K=qs(i,I),C=[Z(K),Z(v)];if(H!=null&&H!==!1){const $=H===!0?s(c.secretKey):H;C.push(ut("extraEntropy",$))}const p=Go(...C),L=v;function S($){const AA=q($);if(!i.isValidNot0(AA))return;const sA=i.inv(AA),oA=A.BASE.multiply(AA).toAffine(),bA=i.create(oA.x);if(bA===Vo)return;const GA=i.create(sA*i.create(L+bA*K));if(GA===Vo)return;let lA=(oA.x===bA?0:2)|Number(oA.y&Ps),jA=GA;return b&&d(GA)&&(jA=i.neg(GA),lA^=1),new M(bA,jA,lA)}return{seed:p,k2sig:S}}function O(l,I,y={}){l=ut("message",l);const{seed:b,k2sig:J}=U(l,I,y);return xx(e.outputLen,i.BYTES,n)(b,J)}function j(l){let I;const y=typeof l=="string"||Yr(l),b=!y&&l!==null&&typeof l=="object"&&typeof l.r=="bigint"&&typeof l.s=="bigint";if(!y&&!b)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(b)I=new M(l.r,l.s);else if(y){try{I=M.fromBytes(ut("sig",l),"der")}catch(J){if(!(J instanceof Po.Err))throw J}if(!I)try{I=M.fromBytes(ut("sig",l),"compact")}catch{return!1}}return I||!1}function Y(l,I,y,b={}){const{lowS:J,prehash:H,format:v}=Vi(b,h);if(y=ut("publicKey",y),I=X(ut("message",I),H),"strict"in b)throw new Error("options.strict was renamed to lowS");const K=v===void 0?j(l):M.fromBytes(ut("sig",l),v);if(K===!1)return!1;try{const C=A.fromBytes(y);if(J&&K.hasHighS())return!1;const{r:p,s:L}=K,S=G(I),$=i.inv(L),AA=i.create(S*$),sA=i.create(p*$),oA=A.BASE.multiplyUnsafe(AA).add(C.multiplyUnsafe(sA));return oA.is0()?!1:i.create(oA.x)===p}catch{return!1}}function x(l,I,y={}){const{prehash:b}=Vi(y,h);return I=X(I,b),M.fromBytes(l,"recovered").recoverPublicKey(I).toBytes()}return Object.freeze({keygen:Q,getPublicKey:B,getSharedSecret:u,utils:E,lengths:c,Point:A,sign:O,verify:Y,recoverPublicKey:x,Signature:M,hash:e})}function x2(A){const e={a:A.a,b:A.b,p:A.Fp.ORDER,n:A.n,h:A.h,Gx:A.Gx,Gy:A.Gy},t=A.Fp;let s=A.allowedPrivateKeyLengths?Array.from(new Set(A.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0;const n=Ms(e.n,{BITS:A.nBitLength,allowedLengths:s,modFromBytes:A.wrapPrivateKey}),r={Fp:t,Fn:n,allowInfinityPoint:A.allowInfinityPoint,endo:A.endo,isTorsionFree:A.isTorsionFree,clearCofactor:A.clearCofactor,fromBytes:A.fromBytes,toBytes:A.toBytes};return{CURVE:e,curveOpts:r}}function D2(A){const{CURVE:e,curveOpts:t}=x2(A),s={hmac:A.hmac,randomBytes:A.randomBytes,lowS:A.lowS,bits2int:A.bits2int,bits2int_modN:A.bits2int_modN};return{CURVE:e,curveOpts:t,hash:A.hash,ecdsaOpts:s}}function y2(A,e){const t=e.Point;return Object.assign({},e,{ProjectivePoint:t,CURVE:Object.assign({},A,iE(t.Fn.ORDER,t.Fn.BITS))})}function N2(A){const{CURVE:e,curveOpts:t,hash:s,ecdsaOpts:n}=D2(A),r=f2(e,t),i=w2(r,s,n);return y2(A,i)}function k2(A,e){const t=s=>N2({...A,hash:s});return{...t(e),create:t}}const Og={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},M2={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},MQ=BigInt(2);function b2(A){const e=Og.p,t=BigInt(3),s=BigInt(6),n=BigInt(11),r=BigInt(22),i=BigInt(23),a=BigInt(44),g=BigInt(88),Q=A*A*A%e,B=Q*Q*A%e,u=Ct(B,t,e)*B%e,E=Ct(u,t,e)*B%e,c=Ct(E,MQ,e)*Q%e,h=Ct(c,n,e)*c%e,f=Ct(h,r,e)*h%e,d=Ct(f,a,e)*f%e,D=Ct(d,g,e)*d%e,R=Ct(D,a,e)*f%e,M=Ct(R,t,e)*B%e,q=Ct(M,i,e)*h%e,G=Ct(q,s,e)*Q%e,T=Ct(G,MQ,e);if(!Ra.eql(Ra.sqr(T),A))throw new Error("Cannot find square root");return T}const Ra=Ms(Og.p,{sqrt:b2}),F2=k2({...Og,Fp:Ra,lowS:!0,endo:M2},Vc);gi.utils.randomPrivateKey;gi.getPublicKey;function bQ(A){try{return gi.ExtendedPoint.fromHex(A),!0}catch{return!1}}gi.verify;const v2=A=>xt.Buffer.isBuffer(A)?A:A instanceof Uint8Array?xt.Buffer.from(A.buffer,A.byteOffset,A.byteLength):xt.Buffer.from(A);class G2{constructor(e){Object.assign(this,e)}encode(){return xt.Buffer.from(Ti.serialize(xn,this))}static decode(e){return Ti.deserialize(xn,this,e)}static decodeUnchecked(e){return Ti.deserializeUnchecked(xn,this,e)}}const xn=new Map;var SE;const S2=32,_i=32;function U2(A){return A._bn!==void 0}let FQ=1;class qe extends G2{constructor(e){if(super({}),this._bn=void 0,U2(e))this._bn=e._bn;else{if(typeof e=="string"){const t=IQ.decode(e);if(t.length!=_i)throw new Error("Invalid public key input");this._bn=new cQ(t)}else this._bn=new cQ(e);if(this._bn.byteLength()>_i)throw new Error("Invalid public key input")}}static unique(){const e=new qe(FQ);return FQ+=1,new qe(e.toBuffer())}equals(e){return this._bn.eq(e._bn)}toBase58(){return IQ.encode(this.toBytes())}toJSON(){return this.toBase58()}toBytes(){const e=this.toBuffer();return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}toBuffer(){const e=this._bn.toArrayLike(xt.Buffer);if(e.length===_i)return e;const t=xt.Buffer.alloc(32);return e.copy(t,32-e.length),t}get[Symbol.toStringTag](){return`PublicKey(${this.toString()})`}toString(){return this.toBase58()}static async createWithSeed(e,t,s){const n=xt.Buffer.concat([e.toBuffer(),xt.Buffer.from(t),s.toBuffer()]),r=dQ(n);return new qe(r)}static createProgramAddressSync(e,t){let s=xt.Buffer.alloc(0);e.forEach(function(r){if(r.length>S2)throw new TypeError("Max seed length exceeded");s=xt.Buffer.concat([s,v2(r)])}),s=xt.Buffer.concat([s,t.toBuffer(),xt.Buffer.from("ProgramDerivedAddress")]);const n=dQ(s);if(bQ(n))throw new Error("Invalid seeds, address must fall off the curve");return new qe(n)}static async createProgramAddress(e,t){return this.createProgramAddressSync(e,t)}static findProgramAddressSync(e,t){let s=255,n;for(;s!=0;){try{const r=e.concat(xt.Buffer.from([s]));n=this.createProgramAddressSync(r,t)}catch(r){if(r instanceof TypeError)throw r;s--;continue}return[n,s]}throw new Error("Unable to find a viable program address nonce")}static async findProgramAddress(e,t){return this.findProgramAddressSync(e,t)}static isOnCurve(e){const t=new qe(e);return bQ(t.toBytes())}}SE=qe;qe.default=new SE("11111111111111111111111111111111");xn.set(qe,{kind:"struct",fields:[["_bn","u256"]]});new qe("BPFLoader1111111111111111111111111111111111");const R2=64,_e=(A="publicKey")=>iA.blob(32,A),Ys=(A="string")=>{const e=iA.struct([iA.u32("length"),iA.u32("lengthPadding"),iA.blob(iA.offset(iA.u32(),-8),"chars")],A),t=e.decode.bind(e),s=e.encode.bind(e),n=e;return n.decode=(r,i)=>t(r,i).chars.toString(),n.encode=(r,i,a)=>{const g={chars:xt.Buffer.from(r,"utf8")};return s(g,i,a)},n.alloc=r=>iA.u32().span+iA.u32().span+xt.Buffer.from(r,"utf8").length,n},K2=(A="authorized")=>iA.struct([_e("staker"),_e("withdrawer")],A),L2=(A="lockup")=>iA.struct([iA.ns64("unixTimestamp"),iA.ns64("epoch"),_e("custodian")],A),J2=(A="voteInit")=>iA.struct([_e("nodePubkey"),_e("authorizedVoter"),_e("authorizedWithdrawer"),iA.u8("commission")],A),T2=(A="voteAuthorizeWithSeedArgs")=>iA.struct([iA.u32("voteAuthorizationType"),_e("currentAuthorityDerivedKeyOwnerPubkey"),Ys("currentAuthorityDerivedKeySeed"),_e("newAuthorized")],A);xt.Buffer.alloc(R2).fill(0);new qe("SysvarC1ock11111111111111111111111111111111");new qe("SysvarEpochSchedu1e111111111111111111111111");new qe("Sysvar1nstructions1111111111111111111111111");new qe("SysvarRecentB1ockHashes11111111111111111111");new qe("SysvarRent111111111111111111111111111111111");new qe("SysvarRewards111111111111111111111111111111");new qe("SysvarS1otHashes111111111111111111111111111");new qe("SysvarS1otHistory11111111111111111111111111");new qe("SysvarStakeHistory1111111111111111111111111");const j2=iA.nu64("lamportsPerSignature"),O2=iA.struct([iA.u32("version"),iA.u32("state"),_e("authorizedPubkey"),_e("nonce"),iA.struct([j2],"feeCalculator")]);O2.span;function $s(A){const e=iA.blob(8,A),t=e.decode.bind(e),s=e.encode.bind(e),n=e,r=jD();return n.decode=(i,a)=>{const g=t(i,a);return r.decode(g)},n.encode=(i,a,g)=>{const Q=r.encode(i);return s(Q,a,g)},n}Object.freeze({Create:{index:0,layout:iA.struct([iA.u32("instruction"),iA.ns64("lamports"),iA.ns64("space"),_e("programId")])},Assign:{index:1,layout:iA.struct([iA.u32("instruction"),_e("programId")])},Transfer:{index:2,layout:iA.struct([iA.u32("instruction"),$s("lamports")])},CreateWithSeed:{index:3,layout:iA.struct([iA.u32("instruction"),_e("base"),Ys("seed"),iA.ns64("lamports"),iA.ns64("space"),_e("programId")])},AdvanceNonceAccount:{index:4,layout:iA.struct([iA.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:iA.struct([iA.u32("instruction"),iA.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:iA.struct([iA.u32("instruction"),_e("authorized")])},AuthorizeNonceAccount:{index:7,layout:iA.struct([iA.u32("instruction"),_e("authorized")])},Allocate:{index:8,layout:iA.struct([iA.u32("instruction"),iA.ns64("space")])},AllocateWithSeed:{index:9,layout:iA.struct([iA.u32("instruction"),_e("base"),Ys("seed"),iA.ns64("space"),_e("programId")])},AssignWithSeed:{index:10,layout:iA.struct([iA.u32("instruction"),_e("base"),Ys("seed"),_e("programId")])},TransferWithSeed:{index:11,layout:iA.struct([iA.u32("instruction"),$s("lamports"),Ys("seed"),_e("programId")])},UpgradeNonceAccount:{index:12,layout:iA.struct([iA.u32("instruction")])}});new qe("11111111111111111111111111111111");new qe("BPFLoader2111111111111111111111111111111111");iA.struct([iA.u32("typeIndex"),$s("deactivationSlot"),iA.nu64("lastExtendedSlot"),iA.u8("lastExtendedStartIndex"),iA.u8(),iA.seq(_e(),iA.offset(iA.u8(),-1),"authority")]);const It=Vr(Tg(qe),vA(),A=>new qe(A)),UE=jg([vA(),Bt("base64")]),qg=Vr(Tg(xt.Buffer),UE,A=>xt.Buffer.from(A[0],"base64"));function RE(A){return to([DA({jsonrpc:Bt("2.0"),id:vA(),result:A}),DA({jsonrpc:Bt("2.0"),id:vA(),error:DA({code:ar(),message:vA(),data:oe(zD())})})])}const q2=RE(ar());function ot(A){return Vr(RE(A),q2,e=>"error"in e?e:{...e,result:br(e.result,A)})}function ko(A){return ot(DA({context:DA({slot:BA()}),value:A}))}function Ei(A){return DA({context:DA({slot:BA()}),value:A})}const Y2=DA({foundation:BA(),foundationTerm:BA(),initial:BA(),taper:BA(),terminal:BA()});ot(qA(YA(DA({epoch:BA(),effectiveSlot:BA(),amount:BA(),postBalance:BA(),commission:oe(YA(BA()))}))));const H2=qA(DA({slot:BA(),prioritizationFee:BA()})),P2=DA({total:BA(),validator:BA(),foundation:BA(),epoch:BA()}),W2=DA({epoch:BA(),slotIndex:BA(),slotsInEpoch:BA(),absoluteSlot:BA(),blockHeight:oe(BA()),transactionCount:oe(BA())}),z2=DA({slotsPerEpoch:BA(),leaderScheduleSlotOffset:BA(),warmup:Ro(),firstNormalEpoch:BA(),firstNormalSlot:BA()}),V2=wE(vA(),qA(BA())),Fs=YA(to([DA({}),vA()])),_2=DA({err:Fs}),Z2=Bt("receivedSignature");DA({"solana-core":vA(),"feature-set":oe(BA())});const X2=DA({program:vA(),programId:It,parsed:ar()}),$2=DA({programId:It,accounts:qA(It),data:vA()});ko(DA({err:YA(to([DA({}),vA()])),logs:YA(qA(vA())),accounts:oe(YA(qA(YA(DA({executable:Ro(),owner:vA(),lamports:BA(),data:qA(vA()),rentEpoch:oe(BA())}))))),unitsConsumed:oe(BA()),returnData:oe(YA(DA({programId:vA(),data:jg([vA(),Bt("base64")])}))),innerInstructions:oe(YA(qA(DA({index:BA(),instructions:qA(to([X2,$2]))}))))}));ko(DA({byIdentity:wE(vA(),qA(BA())),range:DA({firstSlot:BA(),lastSlot:BA()})}));ot(Y2);ot(P2);ot(H2);ot(W2);ot(z2);ot(V2);ot(BA());ko(DA({total:BA(),circulating:BA(),nonCirculating:BA(),nonCirculatingAccounts:qA(It)}));const A1=DA({amount:vA(),uiAmount:YA(BA()),decimals:BA(),uiAmountString:oe(vA())});ko(qA(DA({address:It,amount:vA(),uiAmount:YA(BA()),decimals:BA(),uiAmountString:oe(vA())})));ko(qA(DA({pubkey:It,account:DA({executable:Ro(),owner:It,lamports:BA(),data:qg,rentEpoch:BA()})})));const Ka=DA({program:vA(),parsed:ar(),space:BA()});ko(qA(DA({pubkey:It,account:DA({executable:Ro(),owner:It,lamports:BA(),data:Ka,rentEpoch:BA()})})));ko(qA(DA({lamports:BA(),address:It})));const Yg=DA({executable:Ro(),owner:It,lamports:BA(),data:qg,rentEpoch:BA()});DA({pubkey:It,account:Yg});const e1=Vr(to([Tg(xt.Buffer),Ka]),to([UE,Ka]),A=>Array.isArray(A)?br(A,qg):A),t1=DA({executable:Ro(),owner:It,lamports:BA(),data:e1,rentEpoch:BA()});DA({pubkey:It,account:t1});DA({state:to([Bt("active"),Bt("inactive"),Bt("activating"),Bt("deactivating")]),active:BA(),inactive:BA()});ot(qA(DA({signature:vA(),slot:BA(),err:Fs,memo:YA(vA()),blockTime:oe(YA(BA()))})));ot(qA(DA({signature:vA(),slot:BA(),err:Fs,memo:YA(vA()),blockTime:oe(YA(BA()))})));DA({subscription:BA(),result:Ei(Yg)});const o1=DA({pubkey:It,account:Yg});DA({subscription:BA(),result:Ei(o1)});const s1=DA({parent:BA(),slot:BA(),root:BA()});DA({subscription:BA(),result:s1});const r1=to([DA({type:to([Bt("firstShredReceived"),Bt("completed"),Bt("optimisticConfirmation"),Bt("root")]),slot:BA(),timestamp:BA()}),DA({type:Bt("createdBank"),parent:BA(),slot:BA(),timestamp:BA()}),DA({type:Bt("frozen"),slot:BA(),timestamp:BA(),stats:DA({numTransactionEntries:BA(),numSuccessfulTransactions:BA(),numFailedTransactions:BA(),maxTransactionsPerEntry:BA()})}),DA({type:Bt("dead"),slot:BA(),timestamp:BA(),err:vA()})]);DA({subscription:BA(),result:r1});DA({subscription:BA(),result:Ei(to([_2,Z2]))});DA({subscription:BA(),result:BA()});DA({pubkey:vA(),gossip:YA(vA()),tpu:YA(vA()),rpc:YA(vA()),version:YA(vA())});const vQ=DA({votePubkey:vA(),nodePubkey:vA(),activatedStake:BA(),epochVoteAccount:Ro(),epochCredits:qA(jg([BA(),BA(),BA()])),commission:BA(),lastVote:BA(),rootSlot:YA(BA())});ot(DA({current:qA(vQ),delinquent:qA(vQ)}));const n1=to([Bt("processed"),Bt("confirmed"),Bt("finalized")]),i1=DA({slot:BA(),confirmations:YA(BA()),err:Fs,confirmationStatus:oe(n1)});ko(qA(YA(i1)));ot(BA());const KE=DA({accountKey:It,writableIndexes:qA(BA()),readonlyIndexes:qA(BA())}),Hg=DA({signatures:qA(vA()),message:DA({accountKeys:qA(vA()),header:DA({numRequiredSignatures:BA(),numReadonlySignedAccounts:BA(),numReadonlyUnsignedAccounts:BA()}),instructions:qA(DA({accounts:qA(BA()),data:vA(),programIdIndex:BA()})),recentBlockhash:vA(),addressTableLookups:oe(qA(KE))})}),LE=DA({pubkey:It,signer:Ro(),writable:Ro(),source:oe(to([Bt("transaction"),Bt("lookupTable")]))}),JE=DA({accountKeys:qA(LE),signatures:qA(vA())}),TE=DA({parsed:ar(),program:vA(),programId:It}),jE=DA({accounts:qA(It),data:vA(),programId:It}),a1=to([jE,TE]),g1=to([DA({parsed:ar(),program:vA(),programId:vA()}),DA({accounts:qA(vA()),data:vA(),programId:vA()})]),OE=Vr(a1,g1,A=>"accounts"in A?br(A,jE):br(A,TE)),qE=DA({signatures:qA(vA()),message:DA({accountKeys:qA(LE),instructions:qA(OE),recentBlockhash:vA(),addressTableLookups:oe(YA(qA(KE)))})}),On=DA({accountIndex:BA(),mint:vA(),owner:oe(vA()),programId:oe(vA()),uiTokenAmount:A1}),YE=DA({writable:qA(It),readonly:qA(It)}),Ci=DA({err:Fs,fee:BA(),innerInstructions:oe(YA(qA(DA({index:BA(),instructions:qA(DA({accounts:qA(BA()),data:vA(),programIdIndex:BA()}))})))),preBalances:qA(BA()),postBalances:qA(BA()),logMessages:oe(YA(qA(vA()))),preTokenBalances:oe(YA(qA(On))),postTokenBalances:oe(YA(qA(On))),loadedAddresses:oe(YE),computeUnitsConsumed:oe(BA()),costUnits:oe(BA())}),Pg=DA({err:Fs,fee:BA(),innerInstructions:oe(YA(qA(DA({index:BA(),instructions:qA(OE)})))),preBalances:qA(BA()),postBalances:qA(BA()),logMessages:oe(YA(qA(vA()))),preTokenBalances:oe(YA(qA(On))),postTokenBalances:oe(YA(qA(On))),loadedAddresses:oe(YE),computeUnitsConsumed:oe(BA()),costUnits:oe(BA())}),gr=to([Bt(0),Bt("legacy")]),vs=DA({pubkey:vA(),lamports:BA(),postBalance:YA(BA()),rewardType:YA(vA()),commission:oe(YA(BA()))});ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),transactions:qA(DA({transaction:Hg,meta:YA(Ci),version:oe(gr)})),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),transactions:qA(DA({transaction:JE,meta:YA(Ci),version:oe(gr)})),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),transactions:qA(DA({transaction:qE,meta:YA(Pg),version:oe(gr)})),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),transactions:qA(DA({transaction:JE,meta:YA(Pg),version:oe(gr)})),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),rewards:oe(qA(vs)),blockTime:YA(BA()),blockHeight:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),transactions:qA(DA({transaction:Hg,meta:YA(Ci)})),rewards:oe(qA(vs)),blockTime:YA(BA())})));ot(YA(DA({blockhash:vA(),previousBlockhash:vA(),parentSlot:BA(),signatures:qA(vA()),blockTime:YA(BA())})));ot(YA(DA({slot:BA(),meta:YA(Ci),blockTime:oe(YA(BA())),transaction:Hg,version:oe(gr)})));ot(YA(DA({slot:BA(),transaction:qE,meta:YA(Pg),blockTime:oe(YA(BA())),version:oe(gr)})));ko(DA({blockhash:vA(),lastValidBlockHeight:BA()}));ko(Ro());const l1=DA({slot:BA(),numTransactions:BA(),numSlots:BA(),samplePeriodSecs:BA()});ot(qA(l1));ko(YA(DA({feeCalculator:DA({lamportsPerSignature:BA()})})));ot(vA());ot(vA());const Q1=DA({err:Fs,logs:qA(vA()),signature:vA()});DA({result:Ei(Q1),subscription:BA()});Object.freeze({CreateLookupTable:{index:0,layout:iA.struct([iA.u32("instruction"),$s("recentSlot"),iA.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:iA.struct([iA.u32("instruction")])},ExtendLookupTable:{index:2,layout:iA.struct([iA.u32("instruction"),$s(),iA.seq(_e(),iA.offset(iA.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:iA.struct([iA.u32("instruction")])},CloseLookupTable:{index:4,layout:iA.struct([iA.u32("instruction")])}});new qe("AddressLookupTab1e1111111111111111111111111");Object.freeze({RequestUnits:{index:0,layout:iA.struct([iA.u8("instruction"),iA.u32("units"),iA.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:iA.struct([iA.u8("instruction"),iA.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:iA.struct([iA.u8("instruction"),iA.u32("units")])},SetComputeUnitPrice:{index:3,layout:iA.struct([iA.u8("instruction"),$s("microLamports")])}});new qe("ComputeBudget111111111111111111111111111111");iA.struct([iA.u8("numSignatures"),iA.u8("padding"),iA.u16("signatureOffset"),iA.u16("signatureInstructionIndex"),iA.u16("publicKeyOffset"),iA.u16("publicKeyInstructionIndex"),iA.u16("messageDataOffset"),iA.u16("messageDataSize"),iA.u16("messageInstructionIndex")]);new qe("Ed25519SigVerify111111111111111111111111111");F2.utils.isValidPrivateKey;iA.struct([iA.u8("numSignatures"),iA.u16("signatureOffset"),iA.u8("signatureInstructionIndex"),iA.u16("ethAddressOffset"),iA.u8("ethAddressInstructionIndex"),iA.u16("messageDataOffset"),iA.u16("messageDataSize"),iA.u8("messageInstructionIndex"),iA.blob(20,"ethAddress"),iA.blob(64,"signature"),iA.u8("recoveryId")]);new qe("KeccakSecp256k11111111111111111111111111111");var HE;new qe("StakeConfig11111111111111111111111111111111");class PE{constructor(e,t,s){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=t,this.custodian=s}}HE=PE;PE.default=new HE(0,0,qe.default);Object.freeze({Initialize:{index:0,layout:iA.struct([iA.u32("instruction"),K2(),L2()])},Authorize:{index:1,layout:iA.struct([iA.u32("instruction"),_e("newAuthorized"),iA.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:iA.struct([iA.u32("instruction")])},Split:{index:3,layout:iA.struct([iA.u32("instruction"),iA.ns64("lamports")])},Withdraw:{index:4,layout:iA.struct([iA.u32("instruction"),iA.ns64("lamports")])},Deactivate:{index:5,layout:iA.struct([iA.u32("instruction")])},Merge:{index:7,layout:iA.struct([iA.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:iA.struct([iA.u32("instruction"),_e("newAuthorized"),iA.u32("stakeAuthorizationType"),Ys("authoritySeed"),_e("authorityOwner")])}});new qe("Stake11111111111111111111111111111111111111");Object.freeze({InitializeAccount:{index:0,layout:iA.struct([iA.u32("instruction"),J2()])},Authorize:{index:1,layout:iA.struct([iA.u32("instruction"),_e("newAuthorized"),iA.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:iA.struct([iA.u32("instruction"),iA.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:iA.struct([iA.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:iA.struct([iA.u32("instruction"),T2()])}});new qe("Vote111111111111111111111111111111111111111");new qe("Va1idator1nfo111111111111111111111111111111");DA({name:vA(),website:oe(vA()),details:oe(vA()),iconUrl:oe(vA()),keybaseUsername:oe(vA())});new qe("Vote111111111111111111111111111111111111111");iA.struct([_e("nodePubkey"),_e("authorizedWithdrawer"),iA.u8("commission"),iA.nu64(),iA.seq(iA.struct([iA.nu64("slot"),iA.u32("confirmationCount")]),iA.offset(iA.u32(),-8),"votes"),iA.u8("rootSlotValid"),iA.nu64("rootSlot"),iA.nu64(),iA.seq(iA.struct([iA.nu64("epoch"),_e("authorizedVoter")]),iA.offset(iA.u32(),-8),"authorizedVoters"),iA.struct([iA.seq(iA.struct([_e("authorizedPubkey"),iA.nu64("epochOfLastAuthorizedSwitch"),iA.nu64("targetEpoch")]),32,"buf"),iA.nu64("idx"),iA.u8("isEmpty")],"priorVoters"),iA.nu64(),iA.seq(iA.struct([iA.nu64("epoch"),iA.nu64("credits"),iA.nu64("prevCredits")]),iA.offset(iA.u32(),-8),"epochCredits"),iA.struct([iA.nu64("slot"),iA.nu64("timestamp")],"lastTimestamp")]);function B1(A){if(A.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let Q=0;Q<e.length;Q++)e[Q]=255;for(let Q=0;Q<A.length;Q++){const B=A.charAt(Q),u=B.charCodeAt(0);if(e[u]!==255)throw new TypeError(B+" is ambiguous");e[u]=Q}const t=A.length,s=A.charAt(0),n=Math.log(t)/Math.log(256),r=Math.log(256)/Math.log(t);function i(Q){if(Q instanceof Uint8Array||(ArrayBuffer.isView(Q)?Q=new Uint8Array(Q.buffer,Q.byteOffset,Q.byteLength):Array.isArray(Q)&&(Q=Uint8Array.from(Q))),!(Q instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(Q.length===0)return"";let B=0,u=0,E=0;const c=Q.length;for(;E!==c&&Q[E]===0;)E++,B++;const h=(c-E)*r+1>>>0,f=new Uint8Array(h);for(;E!==c;){let R=Q[E],M=0;for(let q=h-1;(R!==0||M<u)&&q!==-1;q--,M++)R+=256*f[q]>>>0,f[q]=R%t>>>0,R=R/t>>>0;if(R!==0)throw new Error("Non-zero carry");u=M,E++}let d=h-u;for(;d!==h&&f[d]===0;)d++;let D=s.repeat(B);for(;d<h;++d)D+=A.charAt(f[d]);return D}function a(Q){if(typeof Q!="string")throw new TypeError("Expected String");if(Q.length===0)return new Uint8Array;let B=0,u=0,E=0;for(;Q[B]===s;)u++,B++;const c=(Q.length-B)*n+1>>>0,h=new Uint8Array(c);for(;B<Q.length;){const R=Q.charCodeAt(B);if(R>255)return;let M=e[R];if(M===255)return;let q=0;for(let G=c-1;(M!==0||q<E)&&G!==-1;G--,q++)M+=t*h[G]>>>0,h[G]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");E=q,B++}let f=c-E;for(;f!==c&&h[f]===0;)f++;const d=new Uint8Array(u+(c-f));let D=u;for(;f!==c;)d[D++]=h[f++];return d}function g(Q){const B=a(Q);if(B)return B;throw new Error("Non-base"+t+" character")}return{encode:i,decodeUnsafe:a,decode:g}}var c1="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";B1(c1);function E1(A){throw new Error('Could not dynamically require "'+A+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Zi={exports:{}},GQ;function C1(){return GQ||(GQ=1,(function(A){(function(e){var t=function(F){var W,z=new Float64Array(16);if(F)for(W=0;W<F.length;W++)z[W]=F[W];return z},s=function(){throw new Error("no PRNG")},n=new Uint8Array(16),r=new Uint8Array(32);r[0]=9;var i=t(),a=t([1]),g=t([56129,1]),Q=t([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),B=t([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),u=t([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),E=t([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),c=t([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function h(F,W,z,w){F[W]=z>>24&255,F[W+1]=z>>16&255,F[W+2]=z>>8&255,F[W+3]=z&255,F[W+4]=w>>24&255,F[W+5]=w>>16&255,F[W+6]=w>>8&255,F[W+7]=w&255}function f(F,W,z,w,V){var nA,rA=0;for(nA=0;nA<V;nA++)rA|=F[W+nA]^z[w+nA];return(1&rA-1>>>8)-1}function d(F,W,z,w){return f(F,W,z,w,16)}function D(F,W,z,w){return f(F,W,z,w,32)}function R(F,W,z,w){for(var V=w[0]&255|(w[1]&255)<<8|(w[2]&255)<<16|(w[3]&255)<<24,nA=z[0]&255|(z[1]&255)<<8|(z[2]&255)<<16|(z[3]&255)<<24,rA=z[4]&255|(z[5]&255)<<8|(z[6]&255)<<16|(z[7]&255)<<24,IA=z[8]&255|(z[9]&255)<<8|(z[10]&255)<<16|(z[11]&255)<<24,yA=z[12]&255|(z[13]&255)<<8|(z[14]&255)<<16|(z[15]&255)<<24,FA=w[4]&255|(w[5]&255)<<8|(w[6]&255)<<16|(w[7]&255)<<24,xA=W[0]&255|(W[1]&255)<<8|(W[2]&255)<<16|(W[3]&255)<<24,Ee=W[4]&255|(W[5]&255)<<8|(W[6]&255)<<16|(W[7]&255)<<24,RA=W[8]&255|(W[9]&255)<<8|(W[10]&255)<<16|(W[11]&255)<<24,Ae=W[12]&255|(W[13]&255)<<8|(W[14]&255)<<16|(W[15]&255)<<24,ie=w[8]&255|(w[9]&255)<<8|(w[10]&255)<<16|(w[11]&255)<<24,le=z[16]&255|(z[17]&255)<<8|(z[18]&255)<<16|(z[19]&255)<<24,ae=z[20]&255|(z[21]&255)<<8|(z[22]&255)<<16|(z[23]&255)<<24,re=z[24]&255|(z[25]&255)<<8|(z[26]&255)<<16|(z[27]&255)<<24,ne=z[28]&255|(z[29]&255)<<8|(z[30]&255)<<16|(z[31]&255)<<24,ee=w[12]&255|(w[13]&255)<<8|(w[14]&255)<<16|(w[15]&255)<<24,LA=V,PA=nA,UA=rA,JA=IA,OA=yA,SA=FA,CA=xA,uA=Ee,mA=RA,hA=Ae,pA=ie,MA=le,te=ae,Ce=re,Ie=ne,ue=ee,eA,xe=0;xe<20;xe+=2)eA=LA+te|0,OA^=eA<<7|eA>>>25,eA=OA+LA|0,mA^=eA<<9|eA>>>23,eA=mA+OA|0,te^=eA<<13|eA>>>19,eA=te+mA|0,LA^=eA<<18|eA>>>14,eA=SA+PA|0,hA^=eA<<7|eA>>>25,eA=hA+SA|0,Ce^=eA<<9|eA>>>23,eA=Ce+hA|0,PA^=eA<<13|eA>>>19,eA=PA+Ce|0,SA^=eA<<18|eA>>>14,eA=pA+CA|0,Ie^=eA<<7|eA>>>25,eA=Ie+pA|0,UA^=eA<<9|eA>>>23,eA=UA+Ie|0,CA^=eA<<13|eA>>>19,eA=CA+UA|0,pA^=eA<<18|eA>>>14,eA=ue+MA|0,JA^=eA<<7|eA>>>25,eA=JA+ue|0,uA^=eA<<9|eA>>>23,eA=uA+JA|0,MA^=eA<<13|eA>>>19,eA=MA+uA|0,ue^=eA<<18|eA>>>14,eA=LA+JA|0,PA^=eA<<7|eA>>>25,eA=PA+LA|0,UA^=eA<<9|eA>>>23,eA=UA+PA|0,JA^=eA<<13|eA>>>19,eA=JA+UA|0,LA^=eA<<18|eA>>>14,eA=SA+OA|0,CA^=eA<<7|eA>>>25,eA=CA+SA|0,uA^=eA<<9|eA>>>23,eA=uA+CA|0,OA^=eA<<13|eA>>>19,eA=OA+uA|0,SA^=eA<<18|eA>>>14,eA=pA+hA|0,MA^=eA<<7|eA>>>25,eA=MA+pA|0,mA^=eA<<9|eA>>>23,eA=mA+MA|0,hA^=eA<<13|eA>>>19,eA=hA+mA|0,pA^=eA<<18|eA>>>14,eA=ue+Ie|0,te^=eA<<7|eA>>>25,eA=te+ue|0,Ce^=eA<<9|eA>>>23,eA=Ce+te|0,Ie^=eA<<13|eA>>>19,eA=Ie+Ce|0,ue^=eA<<18|eA>>>14;LA=LA+V|0,PA=PA+nA|0,UA=UA+rA|0,JA=JA+IA|0,OA=OA+yA|0,SA=SA+FA|0,CA=CA+xA|0,uA=uA+Ee|0,mA=mA+RA|0,hA=hA+Ae|0,pA=pA+ie|0,MA=MA+le|0,te=te+ae|0,Ce=Ce+re|0,Ie=Ie+ne|0,ue=ue+ee|0,F[0]=LA>>>0&255,F[1]=LA>>>8&255,F[2]=LA>>>16&255,F[3]=LA>>>24&255,F[4]=PA>>>0&255,F[5]=PA>>>8&255,F[6]=PA>>>16&255,F[7]=PA>>>24&255,F[8]=UA>>>0&255,F[9]=UA>>>8&255,F[10]=UA>>>16&255,F[11]=UA>>>24&255,F[12]=JA>>>0&255,F[13]=JA>>>8&255,F[14]=JA>>>16&255,F[15]=JA>>>24&255,F[16]=OA>>>0&255,F[17]=OA>>>8&255,F[18]=OA>>>16&255,F[19]=OA>>>24&255,F[20]=SA>>>0&255,F[21]=SA>>>8&255,F[22]=SA>>>16&255,F[23]=SA>>>24&255,F[24]=CA>>>0&255,F[25]=CA>>>8&255,F[26]=CA>>>16&255,F[27]=CA>>>24&255,F[28]=uA>>>0&255,F[29]=uA>>>8&255,F[30]=uA>>>16&255,F[31]=uA>>>24&255,F[32]=mA>>>0&255,F[33]=mA>>>8&255,F[34]=mA>>>16&255,F[35]=mA>>>24&255,F[36]=hA>>>0&255,F[37]=hA>>>8&255,F[38]=hA>>>16&255,F[39]=hA>>>24&255,F[40]=pA>>>0&255,F[41]=pA>>>8&255,F[42]=pA>>>16&255,F[43]=pA>>>24&255,F[44]=MA>>>0&255,F[45]=MA>>>8&255,F[46]=MA>>>16&255,F[47]=MA>>>24&255,F[48]=te>>>0&255,F[49]=te>>>8&255,F[50]=te>>>16&255,F[51]=te>>>24&255,F[52]=Ce>>>0&255,F[53]=Ce>>>8&255,F[54]=Ce>>>16&255,F[55]=Ce>>>24&255,F[56]=Ie>>>0&255,F[57]=Ie>>>8&255,F[58]=Ie>>>16&255,F[59]=Ie>>>24&255,F[60]=ue>>>0&255,F[61]=ue>>>8&255,F[62]=ue>>>16&255,F[63]=ue>>>24&255}function M(F,W,z,w){for(var V=w[0]&255|(w[1]&255)<<8|(w[2]&255)<<16|(w[3]&255)<<24,nA=z[0]&255|(z[1]&255)<<8|(z[2]&255)<<16|(z[3]&255)<<24,rA=z[4]&255|(z[5]&255)<<8|(z[6]&255)<<16|(z[7]&255)<<24,IA=z[8]&255|(z[9]&255)<<8|(z[10]&255)<<16|(z[11]&255)<<24,yA=z[12]&255|(z[13]&255)<<8|(z[14]&255)<<16|(z[15]&255)<<24,FA=w[4]&255|(w[5]&255)<<8|(w[6]&255)<<16|(w[7]&255)<<24,xA=W[0]&255|(W[1]&255)<<8|(W[2]&255)<<16|(W[3]&255)<<24,Ee=W[4]&255|(W[5]&255)<<8|(W[6]&255)<<16|(W[7]&255)<<24,RA=W[8]&255|(W[9]&255)<<8|(W[10]&255)<<16|(W[11]&255)<<24,Ae=W[12]&255|(W[13]&255)<<8|(W[14]&255)<<16|(W[15]&255)<<24,ie=w[8]&255|(w[9]&255)<<8|(w[10]&255)<<16|(w[11]&255)<<24,le=z[16]&255|(z[17]&255)<<8|(z[18]&255)<<16|(z[19]&255)<<24,ae=z[20]&255|(z[21]&255)<<8|(z[22]&255)<<16|(z[23]&255)<<24,re=z[24]&255|(z[25]&255)<<8|(z[26]&255)<<16|(z[27]&255)<<24,ne=z[28]&255|(z[29]&255)<<8|(z[30]&255)<<16|(z[31]&255)<<24,ee=w[12]&255|(w[13]&255)<<8|(w[14]&255)<<16|(w[15]&255)<<24,LA=V,PA=nA,UA=rA,JA=IA,OA=yA,SA=FA,CA=xA,uA=Ee,mA=RA,hA=Ae,pA=ie,MA=le,te=ae,Ce=re,Ie=ne,ue=ee,eA,xe=0;xe<20;xe+=2)eA=LA+te|0,OA^=eA<<7|eA>>>25,eA=OA+LA|0,mA^=eA<<9|eA>>>23,eA=mA+OA|0,te^=eA<<13|eA>>>19,eA=te+mA|0,LA^=eA<<18|eA>>>14,eA=SA+PA|0,hA^=eA<<7|eA>>>25,eA=hA+SA|0,Ce^=eA<<9|eA>>>23,eA=Ce+hA|0,PA^=eA<<13|eA>>>19,eA=PA+Ce|0,SA^=eA<<18|eA>>>14,eA=pA+CA|0,Ie^=eA<<7|eA>>>25,eA=Ie+pA|0,UA^=eA<<9|eA>>>23,eA=UA+Ie|0,CA^=eA<<13|eA>>>19,eA=CA+UA|0,pA^=eA<<18|eA>>>14,eA=ue+MA|0,JA^=eA<<7|eA>>>25,eA=JA+ue|0,uA^=eA<<9|eA>>>23,eA=uA+JA|0,MA^=eA<<13|eA>>>19,eA=MA+uA|0,ue^=eA<<18|eA>>>14,eA=LA+JA|0,PA^=eA<<7|eA>>>25,eA=PA+LA|0,UA^=eA<<9|eA>>>23,eA=UA+PA|0,JA^=eA<<13|eA>>>19,eA=JA+UA|0,LA^=eA<<18|eA>>>14,eA=SA+OA|0,CA^=eA<<7|eA>>>25,eA=CA+SA|0,uA^=eA<<9|eA>>>23,eA=uA+CA|0,OA^=eA<<13|eA>>>19,eA=OA+uA|0,SA^=eA<<18|eA>>>14,eA=pA+hA|0,MA^=eA<<7|eA>>>25,eA=MA+pA|0,mA^=eA<<9|eA>>>23,eA=mA+MA|0,hA^=eA<<13|eA>>>19,eA=hA+mA|0,pA^=eA<<18|eA>>>14,eA=ue+Ie|0,te^=eA<<7|eA>>>25,eA=te+ue|0,Ce^=eA<<9|eA>>>23,eA=Ce+te|0,Ie^=eA<<13|eA>>>19,eA=Ie+Ce|0,ue^=eA<<18|eA>>>14;F[0]=LA>>>0&255,F[1]=LA>>>8&255,F[2]=LA>>>16&255,F[3]=LA>>>24&255,F[4]=SA>>>0&255,F[5]=SA>>>8&255,F[6]=SA>>>16&255,F[7]=SA>>>24&255,F[8]=pA>>>0&255,F[9]=pA>>>8&255,F[10]=pA>>>16&255,F[11]=pA>>>24&255,F[12]=ue>>>0&255,F[13]=ue>>>8&255,F[14]=ue>>>16&255,F[15]=ue>>>24&255,F[16]=CA>>>0&255,F[17]=CA>>>8&255,F[18]=CA>>>16&255,F[19]=CA>>>24&255,F[20]=uA>>>0&255,F[21]=uA>>>8&255,F[22]=uA>>>16&255,F[23]=uA>>>24&255,F[24]=mA>>>0&255,F[25]=mA>>>8&255,F[26]=mA>>>16&255,F[27]=mA>>>24&255,F[28]=hA>>>0&255,F[29]=hA>>>8&255,F[30]=hA>>>16&255,F[31]=hA>>>24&255}function q(F,W,z,w){R(F,W,z,w)}function G(F,W,z,w){M(F,W,z,w)}var T=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function Z(F,W,z,w,V,nA,rA){var IA=new Uint8Array(16),yA=new Uint8Array(64),FA,xA;for(xA=0;xA<16;xA++)IA[xA]=0;for(xA=0;xA<8;xA++)IA[xA]=nA[xA];for(;V>=64;){for(q(yA,IA,rA,T),xA=0;xA<64;xA++)F[W+xA]=z[w+xA]^yA[xA];for(FA=1,xA=8;xA<16;xA++)FA=FA+(IA[xA]&255)|0,IA[xA]=FA&255,FA>>>=8;V-=64,W+=64,w+=64}if(V>0)for(q(yA,IA,rA,T),xA=0;xA<V;xA++)F[W+xA]=z[w+xA]^yA[xA];return 0}function X(F,W,z,w,V){var nA=new Uint8Array(16),rA=new Uint8Array(64),IA,yA;for(yA=0;yA<16;yA++)nA[yA]=0;for(yA=0;yA<8;yA++)nA[yA]=w[yA];for(;z>=64;){for(q(rA,nA,V,T),yA=0;yA<64;yA++)F[W+yA]=rA[yA];for(IA=1,yA=8;yA<16;yA++)IA=IA+(nA[yA]&255)|0,nA[yA]=IA&255,IA>>>=8;z-=64,W+=64}if(z>0)for(q(rA,nA,V,T),yA=0;yA<z;yA++)F[W+yA]=rA[yA];return 0}function U(F,W,z,w,V){var nA=new Uint8Array(32);G(nA,w,V,T);for(var rA=new Uint8Array(8),IA=0;IA<8;IA++)rA[IA]=w[IA+16];return X(F,W,z,rA,nA)}function O(F,W,z,w,V,nA,rA){var IA=new Uint8Array(32);G(IA,nA,rA,T);for(var yA=new Uint8Array(8),FA=0;FA<8;FA++)yA[FA]=nA[FA+16];return Z(F,W,z,w,V,yA,IA)}var j=function(F){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var W,z,w,V,nA,rA,IA,yA;W=F[0]&255|(F[1]&255)<<8,this.r[0]=W&8191,z=F[2]&255|(F[3]&255)<<8,this.r[1]=(W>>>13|z<<3)&8191,w=F[4]&255|(F[5]&255)<<8,this.r[2]=(z>>>10|w<<6)&7939,V=F[6]&255|(F[7]&255)<<8,this.r[3]=(w>>>7|V<<9)&8191,nA=F[8]&255|(F[9]&255)<<8,this.r[4]=(V>>>4|nA<<12)&255,this.r[5]=nA>>>1&8190,rA=F[10]&255|(F[11]&255)<<8,this.r[6]=(nA>>>14|rA<<2)&8191,IA=F[12]&255|(F[13]&255)<<8,this.r[7]=(rA>>>11|IA<<5)&8065,yA=F[14]&255|(F[15]&255)<<8,this.r[8]=(IA>>>8|yA<<8)&8191,this.r[9]=yA>>>5&127,this.pad[0]=F[16]&255|(F[17]&255)<<8,this.pad[1]=F[18]&255|(F[19]&255)<<8,this.pad[2]=F[20]&255|(F[21]&255)<<8,this.pad[3]=F[22]&255|(F[23]&255)<<8,this.pad[4]=F[24]&255|(F[25]&255)<<8,this.pad[5]=F[26]&255|(F[27]&255)<<8,this.pad[6]=F[28]&255|(F[29]&255)<<8,this.pad[7]=F[30]&255|(F[31]&255)<<8};j.prototype.blocks=function(F,W,z){for(var w=this.fin?0:2048,V,nA,rA,IA,yA,FA,xA,Ee,RA,Ae,ie,le,ae,re,ne,ee,LA,PA,UA,JA=this.h[0],OA=this.h[1],SA=this.h[2],CA=this.h[3],uA=this.h[4],mA=this.h[5],hA=this.h[6],pA=this.h[7],MA=this.h[8],te=this.h[9],Ce=this.r[0],Ie=this.r[1],ue=this.r[2],eA=this.r[3],xe=this.r[4],Ge=this.r[5],Me=this.r[6],pe=this.r[7],be=this.r[8],Se=this.r[9];z>=16;)V=F[W+0]&255|(F[W+1]&255)<<8,JA+=V&8191,nA=F[W+2]&255|(F[W+3]&255)<<8,OA+=(V>>>13|nA<<3)&8191,rA=F[W+4]&255|(F[W+5]&255)<<8,SA+=(nA>>>10|rA<<6)&8191,IA=F[W+6]&255|(F[W+7]&255)<<8,CA+=(rA>>>7|IA<<9)&8191,yA=F[W+8]&255|(F[W+9]&255)<<8,uA+=(IA>>>4|yA<<12)&8191,mA+=yA>>>1&8191,FA=F[W+10]&255|(F[W+11]&255)<<8,hA+=(yA>>>14|FA<<2)&8191,xA=F[W+12]&255|(F[W+13]&255)<<8,pA+=(FA>>>11|xA<<5)&8191,Ee=F[W+14]&255|(F[W+15]&255)<<8,MA+=(xA>>>8|Ee<<8)&8191,te+=Ee>>>5|w,RA=0,Ae=RA,Ae+=JA*Ce,Ae+=OA*(5*Se),Ae+=SA*(5*be),Ae+=CA*(5*pe),Ae+=uA*(5*Me),RA=Ae>>>13,Ae&=8191,Ae+=mA*(5*Ge),Ae+=hA*(5*xe),Ae+=pA*(5*eA),Ae+=MA*(5*ue),Ae+=te*(5*Ie),RA+=Ae>>>13,Ae&=8191,ie=RA,ie+=JA*Ie,ie+=OA*Ce,ie+=SA*(5*Se),ie+=CA*(5*be),ie+=uA*(5*pe),RA=ie>>>13,ie&=8191,ie+=mA*(5*Me),ie+=hA*(5*Ge),ie+=pA*(5*xe),ie+=MA*(5*eA),ie+=te*(5*ue),RA+=ie>>>13,ie&=8191,le=RA,le+=JA*ue,le+=OA*Ie,le+=SA*Ce,le+=CA*(5*Se),le+=uA*(5*be),RA=le>>>13,le&=8191,le+=mA*(5*pe),le+=hA*(5*Me),le+=pA*(5*Ge),le+=MA*(5*xe),le+=te*(5*eA),RA+=le>>>13,le&=8191,ae=RA,ae+=JA*eA,ae+=OA*ue,ae+=SA*Ie,ae+=CA*Ce,ae+=uA*(5*Se),RA=ae>>>13,ae&=8191,ae+=mA*(5*be),ae+=hA*(5*pe),ae+=pA*(5*Me),ae+=MA*(5*Ge),ae+=te*(5*xe),RA+=ae>>>13,ae&=8191,re=RA,re+=JA*xe,re+=OA*eA,re+=SA*ue,re+=CA*Ie,re+=uA*Ce,RA=re>>>13,re&=8191,re+=mA*(5*Se),re+=hA*(5*be),re+=pA*(5*pe),re+=MA*(5*Me),re+=te*(5*Ge),RA+=re>>>13,re&=8191,ne=RA,ne+=JA*Ge,ne+=OA*xe,ne+=SA*eA,ne+=CA*ue,ne+=uA*Ie,RA=ne>>>13,ne&=8191,ne+=mA*Ce,ne+=hA*(5*Se),ne+=pA*(5*be),ne+=MA*(5*pe),ne+=te*(5*Me),RA+=ne>>>13,ne&=8191,ee=RA,ee+=JA*Me,ee+=OA*Ge,ee+=SA*xe,ee+=CA*eA,ee+=uA*ue,RA=ee>>>13,ee&=8191,ee+=mA*Ie,ee+=hA*Ce,ee+=pA*(5*Se),ee+=MA*(5*be),ee+=te*(5*pe),RA+=ee>>>13,ee&=8191,LA=RA,LA+=JA*pe,LA+=OA*Me,LA+=SA*Ge,LA+=CA*xe,LA+=uA*eA,RA=LA>>>13,LA&=8191,LA+=mA*ue,LA+=hA*Ie,LA+=pA*Ce,LA+=MA*(5*Se),LA+=te*(5*be),RA+=LA>>>13,LA&=8191,PA=RA,PA+=JA*be,PA+=OA*pe,PA+=SA*Me,PA+=CA*Ge,PA+=uA*xe,RA=PA>>>13,PA&=8191,PA+=mA*eA,PA+=hA*ue,PA+=pA*Ie,PA+=MA*Ce,PA+=te*(5*Se),RA+=PA>>>13,PA&=8191,UA=RA,UA+=JA*Se,UA+=OA*be,UA+=SA*pe,UA+=CA*Me,UA+=uA*Ge,RA=UA>>>13,UA&=8191,UA+=mA*xe,UA+=hA*eA,UA+=pA*ue,UA+=MA*Ie,UA+=te*Ce,RA+=UA>>>13,UA&=8191,RA=(RA<<2)+RA|0,RA=RA+Ae|0,Ae=RA&8191,RA=RA>>>13,ie+=RA,JA=Ae,OA=ie,SA=le,CA=ae,uA=re,mA=ne,hA=ee,pA=LA,MA=PA,te=UA,W+=16,z-=16;this.h[0]=JA,this.h[1]=OA,this.h[2]=SA,this.h[3]=CA,this.h[4]=uA,this.h[5]=mA,this.h[6]=hA,this.h[7]=pA,this.h[8]=MA,this.h[9]=te},j.prototype.finish=function(F,W){var z=new Uint16Array(10),w,V,nA,rA;if(this.leftover){for(rA=this.leftover,this.buffer[rA++]=1;rA<16;rA++)this.buffer[rA]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(w=this.h[1]>>>13,this.h[1]&=8191,rA=2;rA<10;rA++)this.h[rA]+=w,w=this.h[rA]>>>13,this.h[rA]&=8191;for(this.h[0]+=w*5,w=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=w,w=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=w,z[0]=this.h[0]+5,w=z[0]>>>13,z[0]&=8191,rA=1;rA<10;rA++)z[rA]=this.h[rA]+w,w=z[rA]>>>13,z[rA]&=8191;for(z[9]-=8192,V=(w^1)-1,rA=0;rA<10;rA++)z[rA]&=V;for(V=~V,rA=0;rA<10;rA++)this.h[rA]=this.h[rA]&V|z[rA];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,nA=this.h[0]+this.pad[0],this.h[0]=nA&65535,rA=1;rA<8;rA++)nA=(this.h[rA]+this.pad[rA]|0)+(nA>>>16)|0,this.h[rA]=nA&65535;F[W+0]=this.h[0]>>>0&255,F[W+1]=this.h[0]>>>8&255,F[W+2]=this.h[1]>>>0&255,F[W+3]=this.h[1]>>>8&255,F[W+4]=this.h[2]>>>0&255,F[W+5]=this.h[2]>>>8&255,F[W+6]=this.h[3]>>>0&255,F[W+7]=this.h[3]>>>8&255,F[W+8]=this.h[4]>>>0&255,F[W+9]=this.h[4]>>>8&255,F[W+10]=this.h[5]>>>0&255,F[W+11]=this.h[5]>>>8&255,F[W+12]=this.h[6]>>>0&255,F[W+13]=this.h[6]>>>8&255,F[W+14]=this.h[7]>>>0&255,F[W+15]=this.h[7]>>>8&255},j.prototype.update=function(F,W,z){var w,V;if(this.leftover){for(V=16-this.leftover,V>z&&(V=z),w=0;w<V;w++)this.buffer[this.leftover+w]=F[W+w];if(z-=V,W+=V,this.leftover+=V,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(z>=16&&(V=z-z%16,this.blocks(F,W,V),W+=V,z-=V),z){for(w=0;w<z;w++)this.buffer[this.leftover+w]=F[W+w];this.leftover+=z}};function Y(F,W,z,w,V,nA){var rA=new j(nA);return rA.update(z,w,V),rA.finish(F,W),0}function x(F,W,z,w,V,nA){var rA=new Uint8Array(16);return Y(rA,0,z,w,V,nA),d(F,W,rA,0)}function l(F,W,z,w,V){var nA;if(z<32)return-1;for(O(F,0,W,0,z,w,V),Y(F,16,F,32,z-32,F),nA=0;nA<16;nA++)F[nA]=0;return 0}function I(F,W,z,w,V){var nA,rA=new Uint8Array(32);if(z<32||(U(rA,0,32,w,V),x(W,16,W,32,z-32,rA)!==0))return-1;for(O(F,0,W,0,z,w,V),nA=0;nA<32;nA++)F[nA]=0;return 0}function y(F,W){var z;for(z=0;z<16;z++)F[z]=W[z]|0}function b(F){var W,z,w=1;for(W=0;W<16;W++)z=F[W]+w+65535,w=Math.floor(z/65536),F[W]=z-w*65536;F[0]+=w-1+37*(w-1)}function J(F,W,z){for(var w,V=~(z-1),nA=0;nA<16;nA++)w=V&(F[nA]^W[nA]),F[nA]^=w,W[nA]^=w}function H(F,W){var z,w,V,nA=t(),rA=t();for(z=0;z<16;z++)rA[z]=W[z];for(b(rA),b(rA),b(rA),w=0;w<2;w++){for(nA[0]=rA[0]-65517,z=1;z<15;z++)nA[z]=rA[z]-65535-(nA[z-1]>>16&1),nA[z-1]&=65535;nA[15]=rA[15]-32767-(nA[14]>>16&1),V=nA[15]>>16&1,nA[14]&=65535,J(rA,nA,1-V)}for(z=0;z<16;z++)F[2*z]=rA[z]&255,F[2*z+1]=rA[z]>>8}function v(F,W){var z=new Uint8Array(32),w=new Uint8Array(32);return H(z,F),H(w,W),D(z,0,w,0)}function K(F){var W=new Uint8Array(32);return H(W,F),W[0]&1}function C(F,W){var z;for(z=0;z<16;z++)F[z]=W[2*z]+(W[2*z+1]<<8);F[15]&=32767}function p(F,W,z){for(var w=0;w<16;w++)F[w]=W[w]+z[w]}function L(F,W,z){for(var w=0;w<16;w++)F[w]=W[w]-z[w]}function S(F,W,z){var w,V,nA=0,rA=0,IA=0,yA=0,FA=0,xA=0,Ee=0,RA=0,Ae=0,ie=0,le=0,ae=0,re=0,ne=0,ee=0,LA=0,PA=0,UA=0,JA=0,OA=0,SA=0,CA=0,uA=0,mA=0,hA=0,pA=0,MA=0,te=0,Ce=0,Ie=0,ue=0,eA=z[0],xe=z[1],Ge=z[2],Me=z[3],pe=z[4],be=z[5],Se=z[6],lt=z[7],Ve=z[8],tt=z[9],it=z[10],st=z[11],ct=z[12],dt=z[13],yt=z[14],QA=z[15];w=W[0],nA+=w*eA,rA+=w*xe,IA+=w*Ge,yA+=w*Me,FA+=w*pe,xA+=w*be,Ee+=w*Se,RA+=w*lt,Ae+=w*Ve,ie+=w*tt,le+=w*it,ae+=w*st,re+=w*ct,ne+=w*dt,ee+=w*yt,LA+=w*QA,w=W[1],rA+=w*eA,IA+=w*xe,yA+=w*Ge,FA+=w*Me,xA+=w*pe,Ee+=w*be,RA+=w*Se,Ae+=w*lt,ie+=w*Ve,le+=w*tt,ae+=w*it,re+=w*st,ne+=w*ct,ee+=w*dt,LA+=w*yt,PA+=w*QA,w=W[2],IA+=w*eA,yA+=w*xe,FA+=w*Ge,xA+=w*Me,Ee+=w*pe,RA+=w*be,Ae+=w*Se,ie+=w*lt,le+=w*Ve,ae+=w*tt,re+=w*it,ne+=w*st,ee+=w*ct,LA+=w*dt,PA+=w*yt,UA+=w*QA,w=W[3],yA+=w*eA,FA+=w*xe,xA+=w*Ge,Ee+=w*Me,RA+=w*pe,Ae+=w*be,ie+=w*Se,le+=w*lt,ae+=w*Ve,re+=w*tt,ne+=w*it,ee+=w*st,LA+=w*ct,PA+=w*dt,UA+=w*yt,JA+=w*QA,w=W[4],FA+=w*eA,xA+=w*xe,Ee+=w*Ge,RA+=w*Me,Ae+=w*pe,ie+=w*be,le+=w*Se,ae+=w*lt,re+=w*Ve,ne+=w*tt,ee+=w*it,LA+=w*st,PA+=w*ct,UA+=w*dt,JA+=w*yt,OA+=w*QA,w=W[5],xA+=w*eA,Ee+=w*xe,RA+=w*Ge,Ae+=w*Me,ie+=w*pe,le+=w*be,ae+=w*Se,re+=w*lt,ne+=w*Ve,ee+=w*tt,LA+=w*it,PA+=w*st,UA+=w*ct,JA+=w*dt,OA+=w*yt,SA+=w*QA,w=W[6],Ee+=w*eA,RA+=w*xe,Ae+=w*Ge,ie+=w*Me,le+=w*pe,ae+=w*be,re+=w*Se,ne+=w*lt,ee+=w*Ve,LA+=w*tt,PA+=w*it,UA+=w*st,JA+=w*ct,OA+=w*dt,SA+=w*yt,CA+=w*QA,w=W[7],RA+=w*eA,Ae+=w*xe,ie+=w*Ge,le+=w*Me,ae+=w*pe,re+=w*be,ne+=w*Se,ee+=w*lt,LA+=w*Ve,PA+=w*tt,UA+=w*it,JA+=w*st,OA+=w*ct,SA+=w*dt,CA+=w*yt,uA+=w*QA,w=W[8],Ae+=w*eA,ie+=w*xe,le+=w*Ge,ae+=w*Me,re+=w*pe,ne+=w*be,ee+=w*Se,LA+=w*lt,PA+=w*Ve,UA+=w*tt,JA+=w*it,OA+=w*st,SA+=w*ct,CA+=w*dt,uA+=w*yt,mA+=w*QA,w=W[9],ie+=w*eA,le+=w*xe,ae+=w*Ge,re+=w*Me,ne+=w*pe,ee+=w*be,LA+=w*Se,PA+=w*lt,UA+=w*Ve,JA+=w*tt,OA+=w*it,SA+=w*st,CA+=w*ct,uA+=w*dt,mA+=w*yt,hA+=w*QA,w=W[10],le+=w*eA,ae+=w*xe,re+=w*Ge,ne+=w*Me,ee+=w*pe,LA+=w*be,PA+=w*Se,UA+=w*lt,JA+=w*Ve,OA+=w*tt,SA+=w*it,CA+=w*st,uA+=w*ct,mA+=w*dt,hA+=w*yt,pA+=w*QA,w=W[11],ae+=w*eA,re+=w*xe,ne+=w*Ge,ee+=w*Me,LA+=w*pe,PA+=w*be,UA+=w*Se,JA+=w*lt,OA+=w*Ve,SA+=w*tt,CA+=w*it,uA+=w*st,mA+=w*ct,hA+=w*dt,pA+=w*yt,MA+=w*QA,w=W[12],re+=w*eA,ne+=w*xe,ee+=w*Ge,LA+=w*Me,PA+=w*pe,UA+=w*be,JA+=w*Se,OA+=w*lt,SA+=w*Ve,CA+=w*tt,uA+=w*it,mA+=w*st,hA+=w*ct,pA+=w*dt,MA+=w*yt,te+=w*QA,w=W[13],ne+=w*eA,ee+=w*xe,LA+=w*Ge,PA+=w*Me,UA+=w*pe,JA+=w*be,OA+=w*Se,SA+=w*lt,CA+=w*Ve,uA+=w*tt,mA+=w*it,hA+=w*st,pA+=w*ct,MA+=w*dt,te+=w*yt,Ce+=w*QA,w=W[14],ee+=w*eA,LA+=w*xe,PA+=w*Ge,UA+=w*Me,JA+=w*pe,OA+=w*be,SA+=w*Se,CA+=w*lt,uA+=w*Ve,mA+=w*tt,hA+=w*it,pA+=w*st,MA+=w*ct,te+=w*dt,Ce+=w*yt,Ie+=w*QA,w=W[15],LA+=w*eA,PA+=w*xe,UA+=w*Ge,JA+=w*Me,OA+=w*pe,SA+=w*be,CA+=w*Se,uA+=w*lt,mA+=w*Ve,hA+=w*tt,pA+=w*it,MA+=w*st,te+=w*ct,Ce+=w*dt,Ie+=w*yt,ue+=w*QA,nA+=38*PA,rA+=38*UA,IA+=38*JA,yA+=38*OA,FA+=38*SA,xA+=38*CA,Ee+=38*uA,RA+=38*mA,Ae+=38*hA,ie+=38*pA,le+=38*MA,ae+=38*te,re+=38*Ce,ne+=38*Ie,ee+=38*ue,V=1,w=nA+V+65535,V=Math.floor(w/65536),nA=w-V*65536,w=rA+V+65535,V=Math.floor(w/65536),rA=w-V*65536,w=IA+V+65535,V=Math.floor(w/65536),IA=w-V*65536,w=yA+V+65535,V=Math.floor(w/65536),yA=w-V*65536,w=FA+V+65535,V=Math.floor(w/65536),FA=w-V*65536,w=xA+V+65535,V=Math.floor(w/65536),xA=w-V*65536,w=Ee+V+65535,V=Math.floor(w/65536),Ee=w-V*65536,w=RA+V+65535,V=Math.floor(w/65536),RA=w-V*65536,w=Ae+V+65535,V=Math.floor(w/65536),Ae=w-V*65536,w=ie+V+65535,V=Math.floor(w/65536),ie=w-V*65536,w=le+V+65535,V=Math.floor(w/65536),le=w-V*65536,w=ae+V+65535,V=Math.floor(w/65536),ae=w-V*65536,w=re+V+65535,V=Math.floor(w/65536),re=w-V*65536,w=ne+V+65535,V=Math.floor(w/65536),ne=w-V*65536,w=ee+V+65535,V=Math.floor(w/65536),ee=w-V*65536,w=LA+V+65535,V=Math.floor(w/65536),LA=w-V*65536,nA+=V-1+37*(V-1),V=1,w=nA+V+65535,V=Math.floor(w/65536),nA=w-V*65536,w=rA+V+65535,V=Math.floor(w/65536),rA=w-V*65536,w=IA+V+65535,V=Math.floor(w/65536),IA=w-V*65536,w=yA+V+65535,V=Math.floor(w/65536),yA=w-V*65536,w=FA+V+65535,V=Math.floor(w/65536),FA=w-V*65536,w=xA+V+65535,V=Math.floor(w/65536),xA=w-V*65536,w=Ee+V+65535,V=Math.floor(w/65536),Ee=w-V*65536,w=RA+V+65535,V=Math.floor(w/65536),RA=w-V*65536,w=Ae+V+65535,V=Math.floor(w/65536),Ae=w-V*65536,w=ie+V+65535,V=Math.floor(w/65536),ie=w-V*65536,w=le+V+65535,V=Math.floor(w/65536),le=w-V*65536,w=ae+V+65535,V=Math.floor(w/65536),ae=w-V*65536,w=re+V+65535,V=Math.floor(w/65536),re=w-V*65536,w=ne+V+65535,V=Math.floor(w/65536),ne=w-V*65536,w=ee+V+65535,V=Math.floor(w/65536),ee=w-V*65536,w=LA+V+65535,V=Math.floor(w/65536),LA=w-V*65536,nA+=V-1+37*(V-1),F[0]=nA,F[1]=rA,F[2]=IA,F[3]=yA,F[4]=FA,F[5]=xA,F[6]=Ee,F[7]=RA,F[8]=Ae,F[9]=ie,F[10]=le,F[11]=ae,F[12]=re,F[13]=ne,F[14]=ee,F[15]=LA}function $(F,W){S(F,W,W)}function AA(F,W){var z=t(),w;for(w=0;w<16;w++)z[w]=W[w];for(w=253;w>=0;w--)$(z,z),w!==2&&w!==4&&S(z,z,W);for(w=0;w<16;w++)F[w]=z[w]}function sA(F,W){var z=t(),w;for(w=0;w<16;w++)z[w]=W[w];for(w=250;w>=0;w--)$(z,z),w!==1&&S(z,z,W);for(w=0;w<16;w++)F[w]=z[w]}function oA(F,W,z){var w=new Uint8Array(32),V=new Float64Array(80),nA,rA,IA=t(),yA=t(),FA=t(),xA=t(),Ee=t(),RA=t();for(rA=0;rA<31;rA++)w[rA]=W[rA];for(w[31]=W[31]&127|64,w[0]&=248,C(V,z),rA=0;rA<16;rA++)yA[rA]=V[rA],xA[rA]=IA[rA]=FA[rA]=0;for(IA[0]=xA[0]=1,rA=254;rA>=0;--rA)nA=w[rA>>>3]>>>(rA&7)&1,J(IA,yA,nA),J(FA,xA,nA),p(Ee,IA,FA),L(IA,IA,FA),p(FA,yA,xA),L(yA,yA,xA),$(xA,Ee),$(RA,IA),S(IA,FA,IA),S(FA,yA,Ee),p(Ee,IA,FA),L(IA,IA,FA),$(yA,IA),L(FA,xA,RA),S(IA,FA,g),p(IA,IA,xA),S(FA,FA,IA),S(IA,xA,RA),S(xA,yA,V),$(yA,Ee),J(IA,yA,nA),J(FA,xA,nA);for(rA=0;rA<16;rA++)V[rA+16]=IA[rA],V[rA+32]=FA[rA],V[rA+48]=yA[rA],V[rA+64]=xA[rA];var Ae=V.subarray(32),ie=V.subarray(16);return AA(Ae,Ae),S(ie,ie,Ae),H(F,ie),0}function bA(F,W){return oA(F,W,r)}function GA(F,W){return s(W,32),bA(F,W)}function lA(F,W,z){var w=new Uint8Array(32);return oA(w,z,W),G(F,n,w,T)}var jA=l,HA=I;function ce(F,W,z,w,V,nA){var rA=new Uint8Array(32);return lA(rA,V,nA),jA(F,W,z,w,rA)}function NA(F,W,z,w,V,nA){var rA=new Uint8Array(32);return lA(rA,V,nA),HA(F,W,z,w,rA)}var _A=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function we(F,W,z,w){for(var V=new Int32Array(16),nA=new Int32Array(16),rA,IA,yA,FA,xA,Ee,RA,Ae,ie,le,ae,re,ne,ee,LA,PA,UA,JA,OA,SA,CA,uA,mA,hA,pA,MA,te=F[0],Ce=F[1],Ie=F[2],ue=F[3],eA=F[4],xe=F[5],Ge=F[6],Me=F[7],pe=W[0],be=W[1],Se=W[2],lt=W[3],Ve=W[4],tt=W[5],it=W[6],st=W[7],ct=0;w>=128;){for(OA=0;OA<16;OA++)SA=8*OA+ct,V[OA]=z[SA+0]<<24|z[SA+1]<<16|z[SA+2]<<8|z[SA+3],nA[OA]=z[SA+4]<<24|z[SA+5]<<16|z[SA+6]<<8|z[SA+7];for(OA=0;OA<80;OA++)if(rA=te,IA=Ce,yA=Ie,FA=ue,xA=eA,Ee=xe,RA=Ge,Ae=Me,ie=pe,le=be,ae=Se,re=lt,ne=Ve,ee=tt,LA=it,PA=st,CA=Me,uA=st,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=(eA>>>14|Ve<<18)^(eA>>>18|Ve<<14)^(Ve>>>9|eA<<23),uA=(Ve>>>14|eA<<18)^(Ve>>>18|eA<<14)^(eA>>>9|Ve<<23),mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,CA=eA&xe^~eA&Ge,uA=Ve&tt^~Ve&it,mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,CA=_A[OA*2],uA=_A[OA*2+1],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,CA=V[OA%16],uA=nA[OA%16],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,UA=pA&65535|MA<<16,JA=mA&65535|hA<<16,CA=UA,uA=JA,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=(te>>>28|pe<<4)^(pe>>>2|te<<30)^(pe>>>7|te<<25),uA=(pe>>>28|te<<4)^(te>>>2|pe<<30)^(te>>>7|pe<<25),mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,CA=te&Ce^te&Ie^Ce&Ie,uA=pe&be^pe&Se^be&Se,mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,Ae=pA&65535|MA<<16,PA=mA&65535|hA<<16,CA=FA,uA=re,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=UA,uA=JA,mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,FA=pA&65535|MA<<16,re=mA&65535|hA<<16,Ce=rA,Ie=IA,ue=yA,eA=FA,xe=xA,Ge=Ee,Me=RA,te=Ae,be=ie,Se=le,lt=ae,Ve=re,tt=ne,it=ee,st=LA,pe=PA,OA%16===15)for(SA=0;SA<16;SA++)CA=V[SA],uA=nA[SA],mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=V[(SA+9)%16],uA=nA[(SA+9)%16],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,UA=V[(SA+1)%16],JA=nA[(SA+1)%16],CA=(UA>>>1|JA<<31)^(UA>>>8|JA<<24)^UA>>>7,uA=(JA>>>1|UA<<31)^(JA>>>8|UA<<24)^(JA>>>7|UA<<25),mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,UA=V[(SA+14)%16],JA=nA[(SA+14)%16],CA=(UA>>>19|JA<<13)^(JA>>>29|UA<<3)^UA>>>6,uA=(JA>>>19|UA<<13)^(UA>>>29|JA<<3)^(JA>>>6|UA<<26),mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,V[SA]=pA&65535|MA<<16,nA[SA]=mA&65535|hA<<16;CA=te,uA=pe,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[0],uA=W[0],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[0]=te=pA&65535|MA<<16,W[0]=pe=mA&65535|hA<<16,CA=Ce,uA=be,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[1],uA=W[1],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[1]=Ce=pA&65535|MA<<16,W[1]=be=mA&65535|hA<<16,CA=Ie,uA=Se,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[2],uA=W[2],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[2]=Ie=pA&65535|MA<<16,W[2]=Se=mA&65535|hA<<16,CA=ue,uA=lt,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[3],uA=W[3],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[3]=ue=pA&65535|MA<<16,W[3]=lt=mA&65535|hA<<16,CA=eA,uA=Ve,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[4],uA=W[4],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[4]=eA=pA&65535|MA<<16,W[4]=Ve=mA&65535|hA<<16,CA=xe,uA=tt,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[5],uA=W[5],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[5]=xe=pA&65535|MA<<16,W[5]=tt=mA&65535|hA<<16,CA=Ge,uA=it,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[6],uA=W[6],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[6]=Ge=pA&65535|MA<<16,W[6]=it=mA&65535|hA<<16,CA=Me,uA=st,mA=uA&65535,hA=uA>>>16,pA=CA&65535,MA=CA>>>16,CA=F[7],uA=W[7],mA+=uA&65535,hA+=uA>>>16,pA+=CA&65535,MA+=CA>>>16,hA+=mA>>>16,pA+=hA>>>16,MA+=pA>>>16,F[7]=Me=pA&65535|MA<<16,W[7]=st=mA&65535|hA<<16,ct+=128,w-=128}return w}function He(F,W,z){var w=new Int32Array(8),V=new Int32Array(8),nA=new Uint8Array(256),rA,IA=z;for(w[0]=1779033703,w[1]=3144134277,w[2]=1013904242,w[3]=2773480762,w[4]=1359893119,w[5]=2600822924,w[6]=528734635,w[7]=1541459225,V[0]=4089235720,V[1]=2227873595,V[2]=4271175723,V[3]=1595750129,V[4]=2917565137,V[5]=725511199,V[6]=4215389547,V[7]=327033209,we(w,V,W,z),z%=128,rA=0;rA<z;rA++)nA[rA]=W[IA-z+rA];for(nA[z]=128,z=256-128*(z<112?1:0),nA[z-9]=0,h(nA,z-8,IA/536870912|0,IA<<3),we(w,V,nA,z),rA=0;rA<8;rA++)h(F,8*rA,w[rA],V[rA]);return 0}function de(F,W){var z=t(),w=t(),V=t(),nA=t(),rA=t(),IA=t(),yA=t(),FA=t(),xA=t();L(z,F[1],F[0]),L(xA,W[1],W[0]),S(z,z,xA),p(w,F[0],F[1]),p(xA,W[0],W[1]),S(w,w,xA),S(V,F[3],W[3]),S(V,V,B),S(nA,F[2],W[2]),p(nA,nA,nA),L(rA,w,z),L(IA,nA,V),p(yA,nA,V),p(FA,w,z),S(F[0],rA,IA),S(F[1],FA,yA),S(F[2],yA,IA),S(F[3],rA,FA)}function Ke(F,W,z){var w;for(w=0;w<4;w++)J(F[w],W[w],z)}function nt(F,W){var z=t(),w=t(),V=t();AA(V,W[2]),S(z,W[0],V),S(w,W[1],V),H(F,w),F[31]^=K(z)<<7}function Le(F,W,z){var w,V;for(y(F[0],i),y(F[1],a),y(F[2],a),y(F[3],i),V=255;V>=0;--V)w=z[V/8|0]>>(V&7)&1,Ke(F,W,w),de(W,F),de(F,F),Ke(F,W,w)}function kA(F,W){var z=[t(),t(),t(),t()];y(z[0],u),y(z[1],E),y(z[2],a),S(z[3],u,E),Le(F,z,W)}function he(F,W,z){var w=new Uint8Array(64),V=[t(),t(),t(),t()],nA;for(z||s(W,32),He(w,W,32),w[0]&=248,w[31]&=127,w[31]|=64,kA(V,w),nt(F,V),nA=0;nA<32;nA++)W[nA+32]=F[nA];return 0}var zA=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function P(F,W){var z,w,V,nA;for(w=63;w>=32;--w){for(z=0,V=w-32,nA=w-12;V<nA;++V)W[V]+=z-16*W[w]*zA[V-(w-32)],z=Math.floor((W[V]+128)/256),W[V]-=z*256;W[V]+=z,W[w]=0}for(z=0,V=0;V<32;V++)W[V]+=z-(W[31]>>4)*zA[V],z=W[V]>>8,W[V]&=255;for(V=0;V<32;V++)W[V]-=z*zA[V];for(w=0;w<32;w++)W[w+1]+=W[w]>>8,F[w]=W[w]&255}function N(F){var W=new Float64Array(64),z;for(z=0;z<64;z++)W[z]=F[z];for(z=0;z<64;z++)F[z]=0;P(F,W)}function k(F,W,z,w){var V=new Uint8Array(64),nA=new Uint8Array(64),rA=new Uint8Array(64),IA,yA,FA=new Float64Array(64),xA=[t(),t(),t(),t()];He(V,w,32),V[0]&=248,V[31]&=127,V[31]|=64;var Ee=z+64;for(IA=0;IA<z;IA++)F[64+IA]=W[IA];for(IA=0;IA<32;IA++)F[32+IA]=V[32+IA];for(He(rA,F.subarray(32),z+32),N(rA),kA(xA,rA),nt(F,xA),IA=32;IA<64;IA++)F[IA]=w[IA];for(He(nA,F,z+64),N(nA),IA=0;IA<64;IA++)FA[IA]=0;for(IA=0;IA<32;IA++)FA[IA]=rA[IA];for(IA=0;IA<32;IA++)for(yA=0;yA<32;yA++)FA[IA+yA]+=nA[IA]*V[yA];return P(F.subarray(32),FA),Ee}function _(F,W){var z=t(),w=t(),V=t(),nA=t(),rA=t(),IA=t(),yA=t();return y(F[2],a),C(F[1],W),$(V,F[1]),S(nA,V,Q),L(V,V,F[2]),p(nA,F[2],nA),$(rA,nA),$(IA,rA),S(yA,IA,rA),S(z,yA,V),S(z,z,nA),sA(z,z),S(z,z,V),S(z,z,nA),S(z,z,nA),S(F[0],z,nA),$(w,F[0]),S(w,w,nA),v(w,V)&&S(F[0],F[0],c),$(w,F[0]),S(w,w,nA),v(w,V)?-1:(K(F[0])===W[31]>>7&&L(F[0],i,F[0]),S(F[3],F[0],F[1]),0)}function tA(F,W,z,w){var V,nA=new Uint8Array(32),rA=new Uint8Array(64),IA=[t(),t(),t(),t()],yA=[t(),t(),t(),t()];if(z<64||_(yA,w))return-1;for(V=0;V<z;V++)F[V]=W[V];for(V=0;V<32;V++)F[V+32]=w[V];if(He(rA,F,z),N(rA),Le(IA,yA,rA),kA(yA,W.subarray(32)),de(IA,yA),nt(nA,IA),z-=64,D(W,0,nA,0)){for(V=0;V<z;V++)F[V]=0;return-1}for(V=0;V<z;V++)F[V]=W[V+64];return z}var aA=32,EA=24,ZA=32,VA=16,$A=32,ke=32,XA=32,ye=32,Kt=32,Je=EA,je=ZA,To=VA,Be=64,ve=32,Lt=64,Oe=32,ze=64;e.lowlevel={crypto_core_hsalsa20:G,crypto_stream_xor:O,crypto_stream:U,crypto_stream_salsa20_xor:Z,crypto_stream_salsa20:X,crypto_onetimeauth:Y,crypto_onetimeauth_verify:x,crypto_verify_16:d,crypto_verify_32:D,crypto_secretbox:l,crypto_secretbox_open:I,crypto_scalarmult:oA,crypto_scalarmult_base:bA,crypto_box_beforenm:lA,crypto_box_afternm:jA,crypto_box:ce,crypto_box_open:NA,crypto_box_keypair:GA,crypto_hash:He,crypto_sign:k,crypto_sign_keypair:he,crypto_sign_open:tA,crypto_secretbox_KEYBYTES:aA,crypto_secretbox_NONCEBYTES:EA,crypto_secretbox_ZEROBYTES:ZA,crypto_secretbox_BOXZEROBYTES:VA,crypto_scalarmult_BYTES:$A,crypto_scalarmult_SCALARBYTES:ke,crypto_box_PUBLICKEYBYTES:XA,crypto_box_SECRETKEYBYTES:ye,crypto_box_BEFORENMBYTES:Kt,crypto_box_NONCEBYTES:Je,crypto_box_ZEROBYTES:je,crypto_box_BOXZEROBYTES:To,crypto_sign_BYTES:Be,crypto_sign_PUBLICKEYBYTES:ve,crypto_sign_SECRETKEYBYTES:Lt,crypto_sign_SEEDBYTES:Oe,crypto_hash_BYTES:ze,gf:t,D:Q,L:zA,pack25519:H,unpack25519:C,M:S,A:p,S:$,Z:L,pow2523:sA,add:de,set25519:y,modL:P,scalarmult:Le,scalarbase:kA};function co(F,W){if(F.length!==aA)throw new Error("bad key size");if(W.length!==EA)throw new Error("bad nonce size")}function KA(F,W){if(F.length!==XA)throw new Error("bad public key size");if(W.length!==ye)throw new Error("bad secret key size")}function se(){for(var F=0;F<arguments.length;F++)if(!(arguments[F]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function _t(F){for(var W=0;W<F.length;W++)F[W]=0}e.randomBytes=function(F){var W=new Uint8Array(F);return s(W,F),W},e.secretbox=function(F,W,z){se(F,W,z),co(z,W);for(var w=new Uint8Array(ZA+F.length),V=new Uint8Array(w.length),nA=0;nA<F.length;nA++)w[nA+ZA]=F[nA];return l(V,w,w.length,W,z),V.subarray(VA)},e.secretbox.open=function(F,W,z){se(F,W,z),co(z,W);for(var w=new Uint8Array(VA+F.length),V=new Uint8Array(w.length),nA=0;nA<F.length;nA++)w[nA+VA]=F[nA];return w.length<32||I(V,w,w.length,W,z)!==0?null:V.subarray(ZA)},e.secretbox.keyLength=aA,e.secretbox.nonceLength=EA,e.secretbox.overheadLength=VA,e.scalarMult=function(F,W){if(se(F,W),F.length!==ke)throw new Error("bad n size");if(W.length!==$A)throw new Error("bad p size");var z=new Uint8Array($A);return oA(z,F,W),z},e.scalarMult.base=function(F){if(se(F),F.length!==ke)throw new Error("bad n size");var W=new Uint8Array($A);return bA(W,F),W},e.scalarMult.scalarLength=ke,e.scalarMult.groupElementLength=$A,e.box=function(F,W,z,w){var V=e.box.before(z,w);return e.secretbox(F,W,V)},e.box.before=function(F,W){se(F,W),KA(F,W);var z=new Uint8Array(Kt);return lA(z,F,W),z},e.box.after=e.secretbox,e.box.open=function(F,W,z,w){var V=e.box.before(z,w);return e.secretbox.open(F,W,V)},e.box.open.after=e.secretbox.open,e.box.keyPair=function(){var F=new Uint8Array(XA),W=new Uint8Array(ye);return GA(F,W),{publicKey:F,secretKey:W}},e.box.keyPair.fromSecretKey=function(F){if(se(F),F.length!==ye)throw new Error("bad secret key size");var W=new Uint8Array(XA);return bA(W,F),{publicKey:W,secretKey:new Uint8Array(F)}},e.box.publicKeyLength=XA,e.box.secretKeyLength=ye,e.box.sharedKeyLength=Kt,e.box.nonceLength=Je,e.box.overheadLength=e.secretbox.overheadLength,e.sign=function(F,W){if(se(F,W),W.length!==Lt)throw new Error("bad secret key size");var z=new Uint8Array(Be+F.length);return k(z,F,F.length,W),z},e.sign.open=function(F,W){if(se(F,W),W.length!==ve)throw new Error("bad public key size");var z=new Uint8Array(F.length),w=tA(z,F,F.length,W);if(w<0)return null;for(var V=new Uint8Array(w),nA=0;nA<V.length;nA++)V[nA]=z[nA];return V},e.sign.detached=function(F,W){for(var z=e.sign(F,W),w=new Uint8Array(Be),V=0;V<w.length;V++)w[V]=z[V];return w},e.sign.detached.verify=function(F,W,z){if(se(F,W,z),W.length!==Be)throw new Error("bad signature size");if(z.length!==ve)throw new Error("bad public key size");var w=new Uint8Array(Be+F.length),V=new Uint8Array(Be+F.length),nA;for(nA=0;nA<Be;nA++)w[nA]=W[nA];for(nA=0;nA<F.length;nA++)w[nA+Be]=F[nA];return tA(V,w,w.length,z)>=0},e.sign.keyPair=function(){var F=new Uint8Array(ve),W=new Uint8Array(Lt);return he(F,W),{publicKey:F,secretKey:W}},e.sign.keyPair.fromSecretKey=function(F){if(se(F),F.length!==Lt)throw new Error("bad secret key size");for(var W=new Uint8Array(ve),z=0;z<W.length;z++)W[z]=F[32+z];return{publicKey:W,secretKey:new Uint8Array(F)}},e.sign.keyPair.fromSeed=function(F){if(se(F),F.length!==Oe)throw new Error("bad seed size");for(var W=new Uint8Array(ve),z=new Uint8Array(Lt),w=0;w<32;w++)z[w]=F[w];return he(W,z,!0),{publicKey:W,secretKey:z}},e.sign.publicKeyLength=ve,e.sign.secretKeyLength=Lt,e.sign.seedLength=Oe,e.sign.signatureLength=Be,e.hash=function(F){se(F);var W=new Uint8Array(ze);return He(W,F,F.length),W},e.hash.hashLength=ze,e.verify=function(F,W){return se(F,W),F.length===0||W.length===0||F.length!==W.length?!1:f(F,0,W,0,F.length)===0},e.setPRNG=function(F){s=F},(function(){var F=typeof self<"u"?self.crypto||self.msCrypto:null;if(F&&F.getRandomValues){var W=65536;e.setPRNG(function(z,w){var V,nA=new Uint8Array(w);for(V=0;V<w;V+=W)F.getRandomValues(nA.subarray(V,V+Math.min(w-V,W)));for(V=0;V<w;V++)z[V]=nA[V];_t(nA)})}else typeof E1<"u"&&(F=uE,F&&F.randomBytes&&e.setPRNG(function(z,w){var V,nA=F.randomBytes(w);for(V=0;V<w;V++)z[V]=nA[V];_t(nA)}))})()})(A.exports?A.exports:self.nacl=self.nacl||{})})(Zi)),Zi.exports}C1();const u1={models:[{id:"claude-3-5-haiku-20241022",name:"Claude Haiku 3.5",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-07-31",release_date:"2024-10-22",last_updated:"2024-10-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:.8039999999999999,output:4.02,cache_read:.0804,cache_write:1.005}},{id:"claude-3-5-haiku-latest",name:"Claude Haiku 3.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-07-31",release_date:"2024-10-22",last_updated:"2024-10-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:.8039999999999999,output:4.02,cache_read:.0804,cache_write:1.005}},{id:"claude-3-5-sonnet-20240620",name:"Claude Sonnet 3.5",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-04-30",release_date:"2024-06-20",last_updated:"2024-06-20",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-3-5-sonnet-20241022",name:"Claude Sonnet 3.5 v2",owned_by:"anthropic",context_length:2e5,max_output:8192,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2024-04-30",release_date:"2024-10-22",last_updated:"2024-10-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-haiku-4-5",name:"Claude Haiku 4.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",release_date:"2025-10-15",last_updated:"2025-10-15",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.005,output:5.0249999999999995,cache_read:.10049999999999999,cache_write:1.2562499999999999}},{id:"claude-haiku-4-5-20251001",name:"Claude Haiku 4.5",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-02-28",release_date:"2025-10-15",last_updated:"2025-10-15",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.005,output:5.0249999999999995,cache_read:.10049999999999999,cache_write:1.2562499999999999}},{id:"claude-opus-4-0",name:"Claude Opus 4 (latest)",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-1",name:"Claude Opus 4.1 (latest)",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-08-05",last_updated:"2025-08-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-1-20250805",name:"Claude Opus 4.1",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-08-05",last_updated:"2025-08-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-20250514",name:"Claude Opus 4",owned_by:"anthropic",context_length:2e5,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:15.075,output:75.37499999999999,cache_read:1.5074999999999998,cache_write:18.843749999999996}},{id:"claude-opus-4-5",name:"Claude Opus 4.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-11-24",last_updated:"2025-11-24",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-opus-4-5-20251101",name:"Claude Opus 4.5",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-11-01",last_updated:"2025-11-01",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-opus-4-6",name:"Claude Opus 4.6",owned_by:"anthropic",context_length:1e6,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-05-31",release_date:"2026-02-05",last_updated:"2026-03-13",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-opus-4-7",name:"Claude Opus 4.7",owned_by:"anthropic",context_length:1e6,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2026-01-31",release_date:"2026-04-16",last_updated:"2026-04-16",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:25.124999999999996,cache_read:.5025,cache_write:6.281249999999999}},{id:"claude-sonnet-4-0",name:"Claude Sonnet 4 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-20250514",name:"Claude Sonnet 4",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-03-31",release_date:"2025-05-22",last_updated:"2025-05-22",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-5",name:"Claude Sonnet 4.5 (latest)",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",release_date:"2025-09-29",last_updated:"2025-09-29",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-5-20250929",name:"Claude Sonnet 4.5",owned_by:"anthropic",context_length:2e5,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-07-31",release_date:"2025-09-29",last_updated:"2025-09-29",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"claude-sonnet-4-6",name:"Claude Sonnet 4.6",owned_by:"anthropic",context_length:1e6,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",release_date:"2026-02-17",last_updated:"2026-03-13",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:3.0149999999999997,output:15.075,cache_read:.30149999999999993,cache_write:3.76875}},{id:"deepseek-chat",name:"DeepSeek Chat",owned_by:"deepseek",context_length:1e6,max_output:384e3,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-09",release_date:"2025-12-01",last_updated:"2026-02-28",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.1407,output:.2814,cache_read:.02814}},{id:"deepseek-reasoner",name:"DeepSeek Reasoner",owned_by:"deepseek",context_length:1e6,max_output:384e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-09",release_date:"2025-12-01",last_updated:"2026-02-28",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.1407,output:.2814,cache_read:.02814}},{id:"deepseek-v4-flash",name:"DeepSeek V4 Flash",owned_by:"deepseek",context_length:1e6,max_output:384e3,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-05",release_date:"2026-04-24",last_updated:"2026-04-24",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.1407,output:.2814,cache_read:.02814}},{id:"deepseek-v4-pro",name:"DeepSeek V4 Pro",owned_by:"deepseek",context_length:1e6,max_output:384e3,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-05",release_date:"2026-04-24",last_updated:"2026-04-24",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:1.7486999999999997,output:3.4973999999999994,cache_read:.14572499999999997}},{id:"gemini-3-flash-preview",name:"Gemini 3 Flash Preview",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2025-12-17",last_updated:"2025-12-17",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:.5025,output:3.0149999999999997,cache_read:.050249999999999996}},{id:"gemini-3-pro-preview",name:"Gemini 3 Pro Preview",owned_by:"google",context_length:1e6,max_output:64e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2025-11-18",last_updated:"2025-11-18",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:2.01,output:12.059999999999999,cache_read:.20099999999999998}},{id:"gemini-3.1-flash-image-preview",name:"Gemini 3.1 Flash Image (Preview)",owned_by:"google",context_length:131072,max_output:32768,reasoning:!0,tool_call:!1,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-02-26",last_updated:"2026-02-26",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text","image"]},pricing:{input:.25125,output:60.3}},{id:"gemini-3.1-flash-lite-preview",name:"Gemini 3.1 Flash Lite Preview",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-03-03",last_updated:"2026-03-03",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:.25125,output:1.5074999999999998,cache_read:.025124999999999998,cache_write:1.005}},{id:"gemini-3.1-pro-preview",name:"Gemini 3.1 Pro Preview",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-02-19",last_updated:"2026-02-19",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:2.01,output:12.059999999999999,cache_read:.20099999999999998}},{id:"gemini-3.1-pro-preview-customtools",name:"Gemini 3.1 Pro Preview Custom Tools",owned_by:"google",context_length:1048576,max_output:65536,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-02-19",last_updated:"2026-02-19",open_weights:!1,modalities:{input:["text","image","video","audio","pdf"],output:["text"]},pricing:{input:2.01,output:12.059999999999999,cache_read:.20099999999999998}},{id:"MiniMax-M2.1",name:"MiniMax-M2.1",owned_by:"minimax",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2025-12-23",last_updated:"2025-12-23",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.30149999999999993,output:1.2059999999999997}},{id:"MiniMax-M2.5",name:"MiniMax-M2.5",owned_by:"minimax",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-02-12",last_updated:"2026-02-12",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.30149999999999993,output:1.2059999999999997,cache_read:.030149999999999996,cache_write:.37687499999999996}},{id:"MiniMax-M2.7",name:"MiniMax-M2.7",owned_by:"minimax",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-03-18",last_updated:"2026-03-18",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.30149999999999993,output:1.2059999999999997,cache_read:.06029999999999999,cache_write:.37687499999999996}},{id:"kimi-k2-0711-preview",name:"Kimi K2 0711",owned_by:"moonshot",context_length:131072,max_output:16384,reasoning:!1,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-10",release_date:"2025-07-14",last_updated:"2025-07-14",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.5124999999999997,cache_read:.15074999999999997}},{id:"kimi-k2-0905-preview",name:"Kimi K2 0905",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!1,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-10",release_date:"2025-09-05",last_updated:"2025-09-05",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.5124999999999997,cache_read:.15074999999999997}},{id:"kimi-k2-thinking",name:"Kimi K2 Thinking",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-08",release_date:"2025-11-06",last_updated:"2025-11-06",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.5124999999999997,cache_read:.15074999999999997}},{id:"kimi-k2-thinking-turbo",name:"Kimi K2 Thinking Turbo",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-08",release_date:"2025-11-06",last_updated:"2025-11-06",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:1.1557499999999998,output:8.04,cache_read:.15074999999999997}},{id:"kimi-k2-turbo-preview",name:"Kimi K2 Turbo",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!1,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2024-10",release_date:"2025-09-05",last_updated:"2025-09-05",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:2.4119999999999995,output:10.049999999999999,cache_read:.6029999999999999}},{id:"kimi-k2.5",name:"Kimi K2.5",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!1,temperature:!1,knowledge:"2025-01",release_date:"2026-01",last_updated:"2026-01",open_weights:!0,modalities:{input:["text","image","video"],output:["text"]},pricing:{input:.6029999999999999,output:3.0149999999999997,cache_read:.10049999999999999,cache_write:.6029999999999999}},{id:"kimi-k2.6",name:"Kimi K2.6",owned_by:"moonshot",context_length:262144,max_output:262144,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-01",release_date:"2026-04-21",last_updated:"2026-04-21",open_weights:!0,modalities:{input:["text","image","video"],output:["text"]},pricing:{input:.9547499999999999,output:4.02,cache_read:.1608}},{id:"gpt-5",name:"GPT-5",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5-chat-latest",name:"GPT-5 Chat (latest)",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!1,attachment:!0,temperature:!0,knowledge:"2024-09-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999}},{id:"gpt-5-codex",name:"GPT-5-Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!1,temperature:!1,knowledge:"2024-09-30",release_date:"2025-09-15",last_updated:"2025-09-15",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5-mini",name:"GPT-5 Mini",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.25125,output:2.01,cache_read:.025124999999999998}},{id:"gpt-5-nano",name:"GPT-5 Nano",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-05-30",release_date:"2025-08-07",last_updated:"2025-08-07",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.050249999999999996,output:.40199999999999997,cache_read:.005025}},{id:"gpt-5-pro",name:"GPT-5 Pro",owned_by:"openai",context_length:4e5,max_output:272e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-10-06",last_updated:"2025-10-06",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:15.075,output:120.6}},{id:"gpt-5.1",name:"GPT-5.1",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.13065}},{id:"gpt-5.1-chat-latest",name:"GPT-5.1 Chat",owned_by:"openai",context_length:128e3,max_output:16384,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5.1-codex",name:"GPT-5.1 Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5.1-codex-max",name:"GPT-5.1 Codex Max",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:10.049999999999999,cache_read:.125625}},{id:"gpt-5.1-codex-mini",name:"GPT-5.1 Codex mini",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2024-09-30",release_date:"2025-11-13",last_updated:"2025-11-13",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.25125,output:2.01,cache_read:.025124999999999998}},{id:"gpt-5.2",name:"GPT-5.2",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.2-chat-latest",name:"GPT-5.2 Chat",owned_by:"openai",context_length:128e3,max_output:16384,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.2-pro",name:"GPT-5.2 Pro",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2025-12-11",last_updated:"2025-12-11",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:21.104999999999997,output:168.83999999999997}},{id:"gpt-5.3-chat-latest",name:"GPT-5.3 Chat (latest)",owned_by:"openai",context_length:128e3,max_output:16384,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,knowledge:"2025-08-31",release_date:"2026-03-03",last_updated:"2026-03-03",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.3-codex",name:"GPT-5.3 Codex",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-02-05",last_updated:"2026-02-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.3-codex-spark",name:"GPT-5.3 Codex Spark",owned_by:"openai",context_length:128e3,max_output:32e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-02-05",last_updated:"2026-02-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:1.7587499999999998,output:14.069999999999999,cache_read:.17587499999999998}},{id:"gpt-5.4",name:"GPT-5.4",owned_by:"openai",context_length:105e4,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-05",last_updated:"2026-03-05",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:2.5124999999999997,output:15.075,cache_read:.25125}},{id:"gpt-5.4-mini",name:"GPT-5.4 mini",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-17",last_updated:"2026-03-17",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.7537499999999999,output:4.522499999999999,cache_read:.07537499999999998}},{id:"gpt-5.4-nano",name:"GPT-5.4 nano",owned_by:"openai",context_length:4e5,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-17",last_updated:"2026-03-17",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:.20099999999999998,output:1.2562499999999999,cache_read:.0201}},{id:"gpt-5.4-pro",name:"GPT-5.4 Pro",owned_by:"openai",context_length:105e4,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-08-31",release_date:"2026-03-05",last_updated:"2026-03-05",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:30.15,output:180.89999999999998}},{id:"gpt-5.5",name:"GPT-5.5",owned_by:"openai",context_length:105e4,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",release_date:"2026-04-23",last_updated:"2026-04-23",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:5.0249999999999995,output:30.15,cache_read:.5025}},{id:"gpt-5.5-pro",name:"GPT-5.5 Pro",owned_by:"openai",context_length:105e4,max_output:128e3,reasoning:!0,tool_call:!0,attachment:!0,temperature:!1,knowledge:"2025-12-01",release_date:"2026-04-23",last_updated:"2026-04-23",open_weights:!1,modalities:{input:["text","image","pdf"],output:["text"]},pricing:{input:30.15,output:180.89999999999998}},{id:"grok-4.20-0309-non-reasoning",name:"Grok 4.20 (Non-Reasoning)",owned_by:"xai",context_length:2e6,max_output:3e4,reasoning:!1,tool_call:!0,attachment:!0,temperature:!0,release_date:"2026-03-09",last_updated:"2026-03-09",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:2.01,output:6.029999999999999,cache_read:.20099999999999998}},{id:"grok-4.20-0309-reasoning",name:"Grok 4.20 (Reasoning)",owned_by:"xai",context_length:2e6,max_output:3e4,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,release_date:"2026-03-09",last_updated:"2026-03-09",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:2.01,output:6.029999999999999,cache_read:.20099999999999998}},{id:"grok-4.20-multi-agent-0309",name:"Grok 4.20 Multi-Agent",owned_by:"xai",context_length:2e6,max_output:3e4,reasoning:!0,tool_call:!1,attachment:!0,temperature:!0,release_date:"2026-03-09",last_updated:"2026-03-09",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:2.01,output:6.029999999999999,cache_read:.20099999999999998}},{id:"grok-4.3",name:"Grok 4.3",owned_by:"xai",context_length:1e6,max_output:3e4,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,release_date:"2026-05-01",last_updated:"2026-05-01",open_weights:!1,modalities:{input:["text","image"],output:["text"]},pricing:{input:1.2562499999999999,output:2.5124999999999997,cache_read:.20099999999999998}},{id:"glm-4.7",name:"GLM-4.7",owned_by:"zai",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-04",release_date:"2025-12-22",last_updated:"2025-12-22",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.6029999999999999,output:2.211,cache_read:.11055}},{id:"glm-4.7-flash",name:"GLM-4.7-Flash",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-04",release_date:"2026-01-19",last_updated:"2026-01-19",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:0,output:0}},{id:"glm-4.7-flashx",name:"GLM-4.7-FlashX",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,knowledge:"2025-04",release_date:"2026-01-19",last_updated:"2026-01-19",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:.07035,output:.40199999999999997,cache_read:.01005}},{id:"glm-5",name:"GLM-5",owned_by:"zai",context_length:204800,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-02-11",last_updated:"2026-02-11",open_weights:!0,modalities:{input:["text"],output:["text"]},pricing:{input:1.005,output:3.2159999999999997,cache_read:.20099999999999998}},{id:"glm-5-turbo",name:"GLM-5-Turbo",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-03-16",last_updated:"2026-03-16",open_weights:!1,modalities:{input:["text"],output:["text"]},pricing:{input:1.2059999999999997,output:4.02,cache_read:.24119999999999997}},{id:"glm-5.1",name:"GLM-5.1",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!1,temperature:!0,release_date:"2026-03-27",last_updated:"2026-03-27",open_weights:!1,modalities:{input:["text"],output:["text"]},pricing:{input:1.4069999999999998,output:4.422,cache_read:.2613}},{id:"glm-5v-turbo",name:"GLM-5V-Turbo",owned_by:"zai",context_length:2e5,max_output:131072,reasoning:!0,tool_call:!0,attachment:!0,temperature:!0,release_date:"2026-04-01",last_updated:"2026-04-01",open_weights:!1,modalities:{input:["text","image","video","pdf"],output:["text"]},pricing:{input:1.2059999999999997,output:4.02,cache_read:.24119999999999997}}]},La="ollama-cloud",WE="ottorouter",I1={openai:"@ai-sdk/openai",anthropic:"@ai-sdk/anthropic",google:"@ai-sdk/google",openrouter:"@openrouter/ai-sdk-provider",xai:"@ai-sdk/xai",moonshot:"@ai-sdk/openai-compatible",zai:"@ai-sdk/openai-compatible",minimax:"@ai-sdk/anthropic"};function d1(A){const e=A.owned_by;return{id:A.id,ownedBy:e,label:A.name,modalities:A.modalities,toolCall:A.tool_call,reasoningText:A.reasoning,attachment:A.attachment,temperature:A.temperature,knowledge:A.knowledge,releaseDate:A.release_date,lastUpdated:A.last_updated,openWeights:A.open_weights,cost:{input:A.pricing.input,output:A.pricing.output,cacheRead:A.pricing.cache_read,cacheWrite:A.pricing.cache_write},limit:{context:A.context_length,output:A.max_output},provider:{npm:I1[e]}}}function h1(){const A=u1.models.map(d1);if(!A.length)return null;A.sort((s,n)=>{const r=s.ownedBy??"",i=n.ownedBy??"";return r===i?s.id.localeCompare(n.id):r==="openai"?-1:i==="openai"?1:r.localeCompare(i)});const e="gpt-5-codex",t=A.findIndex(s=>s.id===e);if(t>0){const[s]=A.splice(t,1);A.unshift(s)}return{id:WE,label:"OttoRouter",env:["OTTOROUTER_PRIVATE_KEY"],api:"https://api.ottorouter.org/v1",doc:"https://ottorouter.org/docs",models:A}}function p1(){return{id:La,label:"Ollama Cloud",env:["OLLAMA_API_KEY"],npm:"ai-sdk-ollama",api:"https://ollama.com",doc:"https://docs.ollama.com/cloud",models:[]}}function f1(A){const e=A[La]??p1(),t=h1(),s={...A};return s[La]=e,t&&(s[WE]=t),s}const ui=f1(Ax),m1={openai:[{match:A=>A.includes("gpt-4o-mini"),inputPerMillion:.15,outputPerMillion:.6},{match:A=>A.includes("gpt-4o"),inputPerMillion:5,outputPerMillion:15},{match:A=>A.includes("gpt-4.1-mini"),inputPerMillion:1,outputPerMillion:4},{match:A=>A.includes("gpt-4.1"),inputPerMillion:5,outputPerMillion:15}],anthropic:[{match:A=>A.includes("claude-3-haiku"),inputPerMillion:.25,outputPerMillion:1.25},{match:A=>A.includes("claude-3-sonnet"),inputPerMillion:3,outputPerMillion:15},{match:A=>A.includes("claude-3-opus"),inputPerMillion:15,outputPerMillion:75}],google:[{match:A=>A.includes("gemini-1.5-flash"),inputPerMillion:.35,outputPerMillion:1.05},{match:A=>A.includes("gemini-1.5-pro"),inputPerMillion:3.5,outputPerMillion:10.5}],"ollama-cloud":[],openrouter:[],opencode:[],ottorouter:[],xai:[],zai:[],"zai-coding":[],moonshot:[],minimax:[],copilot:[]};function w1(A,e){const t=m1[A];if(t)return t.find(s=>{try{return s.match(e)}catch{return!1}})}function x1(A,e){const t=ui[A];if(!t)return;const s=e.toLowerCase();return t.models.find(n=>n.id?.toLowerCase()===s)}function zE(A,e,t){const s=typeof t.inputTokens=="number"?t.inputTokens:0,n=typeof t.outputTokens=="number"?t.outputTokens:0,r=typeof t.cachedInputTokens=="number"?t.cachedInputTokens:0,i=typeof t.cacheCreationInputTokens=="number"?t.cacheCreationInputTokens:0;if(!s&&!n&&!r&&!i)return;const a=x1(A,e);if(a?.cost?.input!=null||a?.cost?.output!=null){const c=typeof a.cost?.input=="number"?a.cost.input:0,h=typeof a.cost?.output=="number"?a.cost.output:0,f=typeof a.cost?.cacheRead=="number"?a.cost.cacheRead:0,d=typeof a.cost?.cacheWrite=="number"?a.cost.cacheWrite:0,R=Math.max(0,s-r-i)*c/1e6,M=n*h/1e6,q=r*f/1e6,G=i*d/1e6,T=R+M+q+G;return Number.isFinite(T)?Number(T.toFixed(6)):void 0}const g=w1(A,e.toLowerCase());if(!g)return;const B=Math.max(0,s-r-i)*g.inputPerMillion/1e6,u=n*g.outputPerMillion/1e6,E=B+u;return Number.isFinite(E)?Number(E.toFixed(6)):void 0}var Ja={};function Wg(...A){return A.filter(Boolean).map(e=>e.replace(/\\/g,"/")).join("/").replace(/\/+\/+/g,"/")}function D1(){return(Ja.HOME||Ja.USERPROFILE||"").replace(/\\/g,"/")}function y1(){const A=Ja.XDG_CONFIG_HOME;return A?.trim()?A.replace(/\\/g,"/"):Wg(D1(),".config")}function N1(){return Wg(y1(),"otto")}const k1="catalog-models.json";function M1(){return Wg(N1(),k1)}function Fr(A){return typeof A=="object"&&A!==null&&!Array.isArray(A)}function b1(A){try{return globalThis.process?.getBuiltinModule?.("node:fs")?.readFileSync(A,"utf8")??null}catch{return null}}function F1(A,e){if(!Fr(e))return null;const t=Array.isArray(e.models)?e.models.filter(s=>Fr(s)&&typeof s.id=="string"):[];return{id:typeof e.id=="string"?e.id:A,label:typeof e.label=="string"?e.label:void 0,models:t}}function v1(A){if(!Fr(A))return{};const e=Fr(A.providers)?A.providers:A,t={};for(const[s,n]of Object.entries(e)){const r=F1(s,n);r&&(t[s]=r)}return t}function G1(A){return{version:1,updatedAt:Fr(A)&&typeof A.updatedAt=="string"?A.updatedAt:new Date(0).toISOString(),providers:v1(A)}}function S1(){try{const A=b1(M1());if(!A)return null;const e=JSON.parse(A);return G1(e)}catch{return null}}function U1(A){return S1()?.providers[A]}function VE(A){return typeof A=="string"&&R1.includes(A)}const R1=Object.keys(ui);function _E(A,e){if(VE(A)&&ui[A])return K1(A).find(s=>s.id===e)}function K1(A){return U1(A)?.models??(VE(A)?ui[A]?.models:void 0)??[]}function zg(A){const[e,t]=m.useState(0);return m.useEffect(()=>{const s=A.current;if(!s)return;const n=()=>t(s.clientWidth);n();const r=new ResizeObserver(()=>n());return r.observe(s),()=>r.disconnect()},[A]),e}function ZE({sessionId:A,title:e,className:t=""}){const[s,n]=m.useState(!1),[r,i]=m.useState(e||""),a=m.useRef(null),{mutate:g}=wg(A);m.useEffect(()=>{s&&a.current&&(a.current.focus(),a.current.select())},[s]),m.useEffect(()=>{i(e||"")},[e]);const Q=m.useCallback(()=>{const u=r.trim();u&&u!==(e||"")&&g({title:u}),n(!1)},[r,e,g]),B=m.useCallback(()=>{i(e||""),n(!1)},[e]);return s?o.jsx("input",{ref:a,type:"text",value:r,onChange:u=>i(u.target.value),onBlur:Q,onKeyDown:u=>{u.key==="Enter"&&Q(),u.key==="Escape"&&B()},className:`w-full bg-muted/30 text-foreground rounded px-2 py-1 outline-none ring-1 ring-primary/50 focus:ring-primary ${t}`}):o.jsxs("button",{type:"button",onClick:()=>n(!0),className:`group flex items-center gap-2 hover:opacity-80 transition-opacity truncate text-left ${t}`,title:"Click to edit title",children:[o.jsx("span",{className:"truncate",children:e||"Untitled Session"}),o.jsx(yn,{className:"h-3.5 w-3.5 opacity-0 group-hover:opacity-50 flex-shrink-0 transition-opacity"})]})}function L1({session:A,onNavigateToSession:e}){const{data:t}=Tc(A.sessionType==="branch"?A.id:void 0),{preferences:s}=sr(),{data:n}=fg(A.id),r=m.useRef(null),i=zg(r),a=i>0&&i<640,g=m.useMemo(()=>{const q=A.totalInputTokens||0,G=A.totalOutputTokens||0,T=A.totalCachedTokens||0,Z=A.totalCacheCreationTokens||0;return zE(A.provider,A.model,{inputTokens:q,outputTokens:G,cachedInputTokens:T,cacheCreationInputTokens:Z})??0},[A.provider,A.model,A.totalInputTokens,A.totalOutputTokens,A.totalCachedTokens,A.totalCacheCreationTokens]),Q=q=>{if(!q)return"0s";const G=Math.floor(q/1e3),T=Math.floor(G/60),Z=Math.floor(T/60);return Z>0?`${Z}h ${T%60}m`:T>0?`${T}m ${G%60}s`:`${G}s`},B=q=>q.toLocaleString("en-US"),u=q=>q>=1e6?`${(q/1e6).toFixed(1)}M`:q>=1e3?`${(q/1e3).toFixed(1)}K`:q.toString(),E=A.currentContextTokens||0,c=A.totalOutputTokens||0,h=A.sessionType==="branch",f=t?.parent,d=m.useMemo(()=>_E(A.provider,A.model)?.limit?.context,[A.provider,A.model]),D=d?E/d*100:0,R=()=>D>=90?"text-red-600 dark:text-red-400":D>=70?"text-amber-600 dark:text-amber-400":"text-foreground",M=s.fullWidthContent?"w-full px-6 py-6":"max-w-3xl mx-auto px-6 py-6";return o.jsx("div",{ref:r,className:"border-b border-border bg-background/95 backdrop-blur-sm",children:o.jsxs("div",{className:M,children:[h&&o.jsxs("div",{className:"flex items-center gap-2 mb-3 text-sm",children:[o.jsx(Qo,{className:"h-4 w-4 text-violet-500"}),o.jsx("span",{className:"text-violet-600 dark:text-violet-400 font-medium",children:"Branch"}),f&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-muted-foreground",children:"from"}),o.jsxs("button",{type:"button",onClick:()=>e?.(f.id),className:"text-primary hover:underline flex items-center gap-1",children:[f.title||`Session ${f.id.slice(0,8)}`,o.jsx(dB,{className:"h-3 w-3"})]})]}),!f&&A.parentSessionId&&o.jsx("span",{className:"text-muted-foreground italic text-xs",children:"(parent deleted)"})]}),o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(ZE,{sessionId:A.id,title:A.title,className:"text-2xl font-semibold text-foreground leading-tight"}),n?.shared&&o.jsxs("button",{type:"button",onClick:()=>Io(n.url),className:"flex items-center gap-1.5 px-2 py-1 rounded-md bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20 transition-colors text-xs font-medium flex-shrink-0",children:[o.jsx(Xa,{className:"h-3 w-3"}),o.jsx("span",{children:"Shared"}),n.pendingMessages&&n.pendingMessages>0?o.jsxs("span",{className:"flex items-center gap-0.5 text-amber-600 dark:text-amber-400",children:[o.jsx(Xt,{className:"h-2.5 w-2.5"}),n.pendingMessages]}):o.jsx(Gt,{className:"h-2.5 w-2.5 opacity-60"})]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-x-5 gap-y-2 mt-4 text-sm text-muted-foreground",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs("div",{className:"flex items-center gap-1.5",title:`Current context window: ${B(E)} tokens`,children:[o.jsx("span",{className:"text-xs opacity-70",children:"ctx"}),o.jsx("span",{className:`font-medium ${R()}`,children:u(E)})]}),!a&&o.jsxs("div",{className:"flex items-center gap-1.5",title:`Total output: ${B(c)} tokens`,children:[o.jsx("span",{className:"text-xs opacity-70",children:"out"}),o.jsx("span",{className:"font-medium text-foreground",children:u(c)})]})]}),!a&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Wn,{className:"w-4 h-4"}),o.jsx("span",{className:"font-medium text-foreground",children:Q(A.totalToolTimeMs)})]}),g>0&&!a&&o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(hB,{className:"w-4 h-4"}),o.jsx("span",{className:"font-medium text-foreground",children:g.toFixed(4)})]}),o.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[o.jsx(ro,{provider:A.provider,size:18}),!a&&o.jsx("span",{className:"font-medium text-foreground",children:A.model})]})]})]})})}const uo=gt(A=>({usage:{},isLoading:{},lastFetched:{},isModalOpen:!1,modalProvider:null,setUsage:(e,t)=>A(s=>({usage:{...s.usage,[e]:t}})),setLoading:(e,t)=>A(s=>({isLoading:{...s.isLoading,[e]:t}})),setLastFetched:(e,t)=>A(s=>({lastFetched:{...s.lastFetched,[e]:t}})),openModal:e=>A({isModalOpen:!0,modalProvider:e}),closeModal:()=>A({isModalOpen:!1,modalProvider:null})})),Es=22,Ta=2.5,ja=(Es-Ta)/2,Xi=2*Math.PI*ja;function J1(A){return A>=90?"#ef4444":A>=70?"#f59e0b":"#3b82f6"}const SQ=m.memo(function({usage:e,provider:t}){const s=uo(a=>a.openModal),n=e.primaryWindow?.usedPercent??0,r=Xi-n/100*Xi,i=J1(n);return o.jsxs("button",{type:"button",onClick:()=>s(t),className:"relative flex items-center hover:opacity-80 transition-opacity cursor-pointer",title:`Usage: ${Math.round(n)}% (5h window) — Click for details`,children:[o.jsxs("svg",{width:Es,height:Es,className:"-rotate-90",role:"img","aria-label":"Usage ring",children:[o.jsx("circle",{cx:Es/2,cy:Es/2,r:ja,fill:"none",stroke:"hsl(var(--muted))",strokeWidth:Ta}),o.jsx("circle",{cx:Es/2,cy:Es/2,r:ja,fill:"none",stroke:i,strokeWidth:Ta,strokeDasharray:Xi,strokeDashoffset:r,strokeLinecap:"round",className:"transition-all duration-500"})]}),o.jsx("span",{className:"absolute inset-0 flex items-center justify-center rotate-0 font-medium text-muted-foreground",style:{fontSize:7},children:"5h"})]})});function T1(A){if(!A)return"Unknown";const e=Date.now(),s=new Date(A).getTime()-e;if(s<=0)return"Now";const n=Math.floor(s/864e5),r=Math.floor(s%864e5/36e5),i=Math.floor(s%36e5/6e4);return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:`${i}m`}function UQ(A){return A<=18e3?"5 Hour":A<=86400?"24 Hour":"7 Day"}function $i({label:A,window:e}){const t=Math.min(e.usedPercent,100),s=t>=90?"bg-red-500":t>=70?"bg-amber-500":"bg-blue-500";return o.jsxs("div",{className:"space-y-1.5",children:[o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:A}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsxs("span",{className:"font-medium text-foreground",children:[Math.round(t),"%"]}),e.resetsAt&&o.jsxs("span",{className:"text-xs text-muted-foreground",children:["resets in ",T1(e.resetsAt)]})]})]}),o.jsx("div",{className:"h-2 rounded-full bg-muted overflow-hidden",children:o.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${s}`,style:{width:`${t}%`}})})]})}const j1=m.memo(function(){const e=uo(i=>i.isModalOpen),t=uo(i=>i.modalProvider),s=uo(i=>i.closeModal),n=uo(i=>t?i.usage[t]:void 0),r=m.useMemo(()=>o.jsxs("div",{className:"flex items-center gap-2",children:[t&&o.jsx(ro,{provider:t,size:20}),o.jsx("span",{children:"Usage & Limits"})]}),[t]);return n?o.jsx(Lo,{isOpen:e,onClose:s,title:r,maxWidth:"sm",children:o.jsxs("div",{className:"space-y-5",children:[n.limitReached&&o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-md bg-red-500/10 border border-red-500/20",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-red-500 flex-shrink-0"}),o.jsx("span",{className:"text-sm text-red-600 dark:text-red-400 font-medium",children:"Rate limit reached"})]}),n.primaryWindow&&o.jsx($i,{label:`${UQ(n.primaryWindow.windowSeconds)} Window`,window:n.primaryWindow}),n.secondaryWindow&&o.jsx($i,{label:`${UQ(n.secondaryWindow.windowSeconds)} Window`,window:n.secondaryWindow}),n.sonnetWindow&&n.sonnetWindow.usedPercent>0&&o.jsx($i,{label:"Sonnet (7 Day)",window:{usedPercent:n.sonnetWindow.usedPercent,windowSeconds:604800,resetsAt:n.sonnetWindow.resetsAt}}),n.extraUsage?.is_enabled&&o.jsx("div",{className:"pt-2 border-t border-border space-y-1",children:o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Extra Credits"}),o.jsxs("span",{className:"font-medium text-foreground",children:["$",n.extraUsage.used_credits.toFixed(2)," / $",n.extraUsage.monthly_limit]})]})}),n.credits?.has_credits&&o.jsx("div",{className:"pt-2 border-t border-border space-y-1",children:o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Credits"}),o.jsx("span",{className:"font-medium text-foreground",children:n.credits.balance!==null?`$${n.credits.balance.toFixed(2)}`:"Available"})]})}),n.planType&&o.jsx("div",{className:"pt-2 border-t border-border",children:o.jsxs("div",{className:"flex items-center justify-between text-sm",children:[o.jsx("span",{className:"text-muted-foreground",children:"Plan"}),o.jsx("span",{className:"font-medium text-foreground capitalize",children:n.planType})]})})]})}):null}),O1=6e4,q1=3e4,Aa=new Set;function Y1(A,e){const t=uo(Q=>Q.setUsage),s=uo(Q=>Q.setLoading),n=uo(Q=>Q.setLastFetched),r=uo(Q=>A?Q.usage[A]:void 0),i=e==="oauth"&&(A==="anthropic"||A==="openai"),a=m.useCallback(async()=>{if(!A||!i||Aa.has(A))return;const Q=uo.getState().lastFetched[A]??0;if(!(Q&&Date.now()-Q<q1)){Aa.add(A),s(A,!0);try{const B=await fA.getProviderUsage(A);t(A,B),n(A,Date.now())}catch{}finally{s(A,!1),Aa.delete(A)}}},[A,i,t,s,n]),g=m.useRef(a);return g.current=a,m.useEffect(()=>{if(!A||!i)return;g.current();const Q=setInterval(()=>g.current(),O1);return()=>clearInterval(Q)},[i,A]),{usage:r,fetchUsage:a,isOAuthProvider:i}}function Ii(A){const e=Ne(d=>d.setBalance),t=Ne(d=>d.setUsdcBalance),s=Ne(d=>d.setWalletAddress),n=Ne(d=>d.setLoading),r=Ne(d=>d.setScope),i=Ne(d=>d.setPayg),a=Ne(d=>d.setSubscription),g=Ne(d=>d.setLimits),Q=uo(d=>d.setUsage),B=Ne(d=>d.balance),u=Ne(d=>d.usdcBalance),E=Ne(d=>d.subscription),c=Ne(d=>d.network),h=m.useCallback(async()=>{if(A==="ottorouter"){n(!0);try{const[d,D,R]=await Promise.all([fA.getOttoRouterBalance(),fA.getOttoRouterUsdcBalance(c),fA.getOttoRouterWallet()]);if(d){e(d.balance),s(d.walletAddress),r(d.scope??null),i(d.payg??null),a(d.subscription??null),g(d.limits??null);const M=d.subscription;M?.active&&M.usageWindows&&Q("ottorouter",{provider:"ottorouter",primaryWindow:{usedPercent:M.usageWindows.fiveHour.percentUsed,windowSeconds:18e3,resetsAt:null},secondaryWindow:{usedPercent:M.usageWindows.weekly.percentUsed,windowSeconds:604800,resetsAt:null},limitReached:!1,planType:M.tierName??"GO"})}else R?.configured&&R.publicKey&&s(R.publicKey);D&&(t(D.usdcBalance),!d&&D.walletAddress&&s(D.walletAddress))}catch{}finally{n(!1)}}},[A,c,e,t,s,n,r,i,a,g,Q]),f=E?.active&&!E.usageWindows;return m.useEffect(()=>{A==="ottorouter"&&(B===null||u===null||f)&&h()},[A,B,u,f,h]),{fetchBalance:h}}function H1({session:A,isVisible:e,isGenerating:t,onNavigateToSession:s}){const{data:n}=Tc(A.sessionType==="branch"?A.id:void 0),{data:r}=fg(A.id),i=m.useMemo(()=>{const Z=A.totalInputTokens||0,X=A.totalOutputTokens||0,U=A.totalCachedTokens||0,O=A.totalCacheCreationTokens||0;return zE(A.provider,A.model,{inputTokens:Z,outputTokens:X,cachedInputTokens:U,cacheCreationInputTokens:O})??0},[A.provider,A.model,A.totalInputTokens,A.totalOutputTokens,A.totalCachedTokens,A.totalCacheCreationTokens]),a=Z=>Z>=1e6?`${(Z/1e6).toFixed(1)}M`:Z>=1e3?`${(Z/1e3).toFixed(1)}K`:Z.toString(),g=A.currentContextTokens||0,Q=A.sessionType==="branch",B=n?.parent,u=m.useMemo(()=>_E(A.provider,A.model)?.limit?.context,[A.provider,A.model]),E=u?g/u*100:0,c=()=>E>=90?"text-red-600 dark:text-red-400":E>=70?"text-amber-600 dark:text-amber-400":"text-foreground",{data:h}=or(),f=h?.[A.provider]?.authType,{usage:d,isOAuthProvider:D}=Y1(A.provider,f),R=A.provider==="ottorouter";Ii(R?"ottorouter":void 0);const M=uo(Z=>Z.usage.ottorouter),q=m.useRef(null),G=zg(q),T=G>0&&G<640;return o.jsxs(o.Fragment,{children:[o.jsx("div",{ref:q,className:`absolute top-0 left-0 right-0 h-12 border-b border-border bg-background/40 backdrop-blur-xl supports-[backdrop-filter]:bg-background/20 z-10 transition-transform duration-200 ${e?"translate-y-0":"-translate-y-full"}`,children:o.jsxs("div",{className:"h-full px-2.5 flex items-center justify-between gap-3 text-sm",children:[o.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 text-muted-foreground",children:[Q&&o.jsx(Qo,{className:"size-4 flex-shrink-0 text-violet-500"}),o.jsx(ZE,{sessionId:A.id,title:A.title,className:"text-foreground font-medium text-sm"}),r?.shared&&o.jsxs("button",{type:"button",onClick:()=>Io(r.url),className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 hover:bg-emerald-500/20 transition-colors text-xs font-medium flex-shrink-0",children:[o.jsx(Xa,{className:"h-3 w-3"}),r.pendingMessages&&r.pendingMessages>0?o.jsxs("span",{className:"flex items-center gap-0.5 text-amber-600 dark:text-amber-400",children:[o.jsx(Xt,{className:"h-2.5 w-2.5"}),r.pendingMessages]}):o.jsx(Gt,{className:"h-2.5 w-2.5 opacity-60"})]}),Q&&B&&o.jsxs(o.Fragment,{children:[!T&&o.jsx("span",{className:"text-muted-foreground",children:"from"}),o.jsxs("button",{type:"button",onClick:()=>s?.(B.id),className:"text-primary hover:underline flex items-center gap-0.5 truncate max-w-32",title:B.title||`Session ${B.id.slice(0,8)}`,children:[o.jsx("span",{className:"truncate",children:B.title||`Session ${B.id.slice(0,8)}`}),o.jsx(dB,{className:"h-3 w-3 flex-shrink-0"})]})]})]}),o.jsxs("div",{className:"flex-shrink-0 flex items-center gap-3 text-muted-foreground",children:[t&&o.jsx(km,{sessionId:A.id}),D&&d&&o.jsx(SQ,{usage:d,provider:A.provider}),R&&M&&o.jsx(SQ,{usage:M,provider:"ottorouter"}),o.jsx("div",{className:"flex items-center gap-2",children:o.jsxs("div",{className:"flex items-center gap-1",title:`Current context window: ${g.toLocaleString()} tokens`,children:[o.jsx("span",{className:"text-xs opacity-70",children:"ctx"}),o.jsx("span",{className:`font-medium ${c()}`,children:a(g)})]})}),i>0&&!T&&o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(hB,{className:"size-3.5"}),o.jsx("span",{className:"text-foreground font-medium",children:i.toFixed(4)})]}),o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx(ro,{provider:A.provider,size:14}),!T&&o.jsx("span",{className:"font-medium text-foreground",children:A.model})]})]})]})}),o.jsx(j1,{})]})}const P1=m.memo(function({pendingTopup:e,onMethodSelected:t,onCancel:s}){const[n,r]=m.useState(!1),[i,a]=m.useState(null),g=Ne(c=>c.openTopupModal),Q=Ne(c=>!!c.subscription?.active),B=async()=>{a("crypto"),r(!0);try{await fA.selectTopupMethod(e.sessionId,"crypto"),t("crypto")}catch(c){ge.error(c instanceof Error?c.message:"Failed to process payment"),r(!1),a(null)}},u=async()=>{a("fiat"),g(),fA.selectTopupMethod(e.sessionId,"fiat").catch(()=>{}),t("fiat")},E=async()=>{r(!0);try{await fA.cancelTopup(e.sessionId),s()}catch(c){ge.error(c instanceof Error?c.message:"Failed to cancel"),r(!1)}};return o.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(yo,{className:"h-4 w-4 text-amber-500 flex-shrink-0"}),o.jsx("span",{className:"font-medium text-foreground text-sm",children:"Insufficient Balance"}),o.jsx("span",{className:"text-amber-600 dark:text-amber-400 font-medium text-sm",children:"payment required"})]}),Q&&o.jsx("p",{className:"ml-6 text-xs text-muted-foreground",children:"GO credits may not apply to this request. Add balance to continue."}),o.jsxs("div",{className:"ml-6 bg-muted/30 rounded-lg p-3 space-y-2 text-sm",children:[o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-muted-foreground",children:"Request cost"}),o.jsxs("span",{className:"font-mono",children:["~$",e.amountUsd.toFixed(4)]})]}),o.jsxs("div",{className:"flex justify-between",children:[o.jsx("span",{className:"text-muted-foreground",children:"Current balance"}),o.jsxs("span",{className:"font-mono",children:["$",e.currentBalance.toFixed(4)]})]})]}),o.jsxs("div",{className:"ml-6 flex flex-wrap items-center gap-2",children:[o.jsxs("button",{type:"button",onClick:E,disabled:n,title:"Cancel request",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded border border-border bg-background hover:bg-muted transition-colors disabled:opacity-50",children:[o.jsx(et,{className:"w-3 h-3"}),"Cancel"]}),o.jsxs("button",{type:"button",onClick:B,disabled:n,title:"Pay with USDC from your wallet",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded bg-violet-600 text-white hover:bg-violet-700 transition-colors disabled:opacity-50",children:[i==="crypto"&&n?o.jsx(Te,{className:"w-3 h-3 animate-spin"}):o.jsx(tg,{className:"w-3 h-3"}),"Pay with USDC"]}),o.jsxs("button",{type:"button",onClick:u,disabled:n,title:"Top up with card (min $5)",className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded border border-violet-500 text-violet-600 dark:text-violet-400 hover:bg-violet-500/10 transition-colors disabled:opacity-50",children:[i==="fiat"&&n?o.jsx(Te,{className:"w-3 h-3 animate-spin"}):o.jsx(zn,{className:"w-3 h-3"}),"Top up with Card",o.jsx("span",{className:"text-[10px] opacity-70",children:"(min $5)"})]})]}),o.jsx("p",{className:"ml-6 text-xs text-muted-foreground",children:i==="crypto"?"Processing USDC payment from your wallet...":i==="fiat"?"Opening checkout...":"Select a payment method to continue your request."})]})}),qn=gt(A=>({pendingTopup:null,isProcessing:!1,selectedMethod:null,setPendingTopup:e=>A({pendingTopup:e,isProcessing:!1,selectedMethod:null}),setProcessing:e=>A({isProcessing:e}),setSelectedMethod:e=>A({selectedMethod:e}),clearPendingTopup:()=>A({pendingTopup:null,isProcessing:!1,selectedMethod:null})})),W1=new Set(["update_todos","update_plan","UpdateTodos","UpdatePlan"]);function z1(A){if(A.contentJson&&typeof A.contentJson=="object")return A.contentJson;try{const e=JSON.parse(A.content);if(e&&typeof e=="object"&&!Array.isArray(e))return e}catch{}return null}function V1(A){return A==="pending"||A==="in_progress"||A==="completed"||A==="cancelled"}function _1(A,e){const t=A.toolName??e?.name;return typeof t=="string"?t:null}function Z1(A){const e=A.result,t=e&&typeof e=="object"&&!Array.isArray(e)?e:A,s=t.items;if(!Array.isArray(s))return null;const n=s.flatMap(i=>{if(!i||typeof i!="object"||Array.isArray(i))return[];const a=i;return typeof a.step!="string"||!V1(a.status)?[]:[{step:a.step,status:a.status}]}),r=typeof t.note=="string"?t.note:void 0;return{items:n,note:r}}function X1(A){return A.items.length>0&&A.items.every(e=>e.status==="completed"||e.status==="cancelled")}function $1(A,e,t){const s=A.slice(e+1).find(n=>n.role==="assistant");return!!(s&&t.has(s.id))}function Ay(A,e){let t=!1;for(let s=A.length-1;s>=0;s--){const n=A[s];n?.role==="user"&&!$1(A,s,e)&&(t=!0);const r=n?.parts??[];for(let i=r.length-1;i>=0;i--){const a=r[i];if(a.type!=="tool_result")continue;const g=z1(a),Q=_1(a,g);if(!Q||!W1.has(Q))continue;if(!g)return null;const B=Z1(g);return!B||t&&X1(B)?null:B}}return null}const ey=m.memo(function({messages:e,session:t,sessionId:s,isGenerating:n,compact:r=!1,disableAutoScroll:i=!1,onSelectSession:a}){const g=De(),{preferences:Q}=sr(),B=m.useRef(null),u=m.useRef(null),E=m.useRef(null),c=m.useRef(null),h=zg(c),f=h>0&&h<640?"compact":"normal",[d,D]=m.useState(!0),R=m.useRef(!0),[M,q]=m.useState(!1),G=m.useRef(!1),T=m.useRef(void 0),Z=m.useRef(0),X=m.useRef(void 0),U=m.useRef(!1),O=m.useRef(t?.id),j=m.useRef(e.length),Y=m.useRef(n),x=m.useRef(0),l=m.useRef(0),I=qn(AA=>AA.pendingTopup),y=qn(AA=>AA.clearPendingTopup),b=pc(AA=>AA.setSessionTodos),J=xg(s),H=m.useMemo(()=>new Set(J.queuedMessages.map(AA=>AA.messageId)),[J.queuedMessages]),v=I&&I.sessionId===s;m.useEffect(()=>{s&&b(s,Ay(e,H))},[e,H,s,b]);const K=m.useCallback(()=>{const AA=u.current;if(!AA)return;const{scrollTop:sA,scrollHeight:oA,clientHeight:bA}=AA,GA=oA-sA-bA,lA=oA>x.current,jA=sA<l.current-5;x.current=oA,l.current=sA,GA<100?(R.current=!0,D(!0)):jA?(R.current=!1,D(!1),G.current=!0):!lA&&R.current&&(R.current=!1,D(!1)),(jA||!R.current&&GA>=100)&&(T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{G.current=!1},150));const HA=E.current;if(HA){const ce=HA.getBoundingClientRect(),NA=AA.getBoundingClientRect();q(ce.bottom<NA.top)}},[]);m.useEffect(()=>{if(i)return;const AA=t?.id!==O.current;if(O.current=t?.id,AA&&(U.current=!1),!U.current&&e.length>0){U.current=!0;const sA=u.current;sA&&(sA.scrollTop=sA.scrollHeight)}},[e.length,t?.id,i]),m.useEffect(()=>{if(i)return;const AA=n&&!Y.current,sA=e.length>j.current;Y.current=n,j.current=e.length,AA?(G.current=!1,R.current=!0,D(!0),requestAnimationFrame(()=>{requestAnimationFrame(()=>{const oA=u.current;oA&&(oA.scrollTop=oA.scrollHeight)})})):sA&&!G.current&&!n&&(R.current=!0,D(!0))},[e.length,n,i]),m.useEffect(()=>{if(i)return;const AA=u.current;if(!AA||!d||G.current)return;Z.current=AA.scrollHeight-AA.clientHeight;const sA=()=>{const oA=u.current;if(!oA||G.current)return;const bA=oA.scrollTop,lA=oA.scrollHeight-oA.clientHeight-bA;if(Math.abs(lA)<1){oA.scrollTop=oA.scrollHeight-oA.clientHeight;return}if(Math.abs(lA)<10){oA.scrollTop=oA.scrollHeight-oA.clientHeight;return}oA.scrollTop=bA+lA*.15,X.current=requestAnimationFrame(sA)};X.current&&cancelAnimationFrame(X.current),X.current=requestAnimationFrame(sA)},[e,d]),m.useEffect(()=>()=>{T.current&&clearTimeout(T.current),X.current&&cancelAnimationFrame(X.current)},[]);const C=()=>{G.current=!1,R.current=!0,D(!0);const AA=u.current;AA&&(AA.scrollTop=AA.scrollHeight)},p=m.useMemo(()=>e.filter(AA=>AA.role!=="system"),[e]),L=Q.fullWidthContent?r?"w-full space-y-4":"w-full space-y-6":r?"max-w-3xl mx-auto space-y-4":"max-w-3xl mx-auto space-y-6",S=m.useCallback(AA=>async()=>{if(s&&AA){g.setQueryData(["messages",s],sA=>sA&&sA.map(oA=>{if(oA.id!==AA)return oA;const bA=oA.parts?.filter(GA=>!(GA.type==="error"||GA.type==="tool_call"&&GA.toolName==="finish"))??[];return{...oA,status:"pending",parts:bA,error:null}}));try{await fA.retryMessage(s,AA)}catch(sA){ge.error(sA instanceof Error?sA.message:"Failed to retry")}}},[s,g]),$=m.useCallback(async()=>{if(s)try{await fA.sendMessage(s,{content:"/compact"})}catch(AA){ge.error(AA instanceof Error?AA.message:"Failed to compact")}},[s]);return e.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"No messages yet. Start a conversation below."}):o.jsx("div",{ref:c,className:"absolute inset-0 flex flex-col",children:o.jsxs(pw,{density:f,children:[t&&o.jsx(H1,{session:t,isVisible:M,isGenerating:n,onNavigateToSession:a}),o.jsxs("div",{ref:u,className:"flex-1 overflow-y-auto scrollbar-hide",onScroll:K,children:[o.jsx("div",{ref:E,children:t&&o.jsx(L1,{session:t,onNavigateToSession:a})}),o.jsx("div",{className:f==="compact"?"px-2 pt-3 pb-80":r?"p-4 pb-80":"p-6 pb-96",children:o.jsxs("div",{className:L,children:[p.map((AA,sA)=>{const oA=p[sA-1],bA=p[sA+1],GA=sA===p.length-1;if(AA.role==="user"){const lA=bA&&bA.role==="assistant"?bA:void 0;return o.jsx(Oc,{sessionId:s,message:AA,isFirst:sA===0,nextAssistantMessageId:lA?.id},AA.id)}if(AA.role==="assistant"){const lA=!oA||oA.role!=="assistant",jA=bA&&bA.role==="assistant";return o.jsx(jc,{sessionId:s,message:AA,showHeader:lA,hasNextAssistantMessage:jA,isLastMessage:GA,onBranchCreated:a,onRetry:GA?S(AA.id):void 0,compact:r,onCompact:GA?$:void 0},AA.id)}return null}),v&&I&&o.jsx("div",{className:"py-4",children:o.jsx(P1,{pendingTopup:I,onMethodSelected:()=>y(),onCancel:()=>y()})}),o.jsx("div",{ref:B})]})})]}),!d&&o.jsxs("button",{type:"button",onClick:C,className:"absolute bottom-36 left-1/2 -translate-x-1/2 flex items-center gap-2 px-4 py-2 bg-background border border-border rounded-full shadow-lg hover:bg-muted/50 transition-all text-sm text-foreground z-10",children:[o.jsx(zC,{className:"w-4 h-4"}),o.jsx("span",{children:"Scroll to bottom"})]})]})})});class XE{abortController=null;handlers=new Map;running=!1;async connect(e){this.abortController&&this.abortController.abort(),this.abortController=new AbortController,this.running=!0;const t=!e.includes("localhost")&&!e.includes("127.0.0.1");try{const s=await fetch(e,{method:t?"POST":"GET",headers:{Accept:"text/event-stream"},signal:this.abortController.signal});if(!s.ok){console.error("[SSE] Connection failed:",s.status);return}const n=s.body?.getReader();if(!n){console.error("[SSE] No response body");return}const r=new TextDecoder;let i="";for(;this.running;){const{done:a,value:g}=await n.read();if(a)break;i+=r.decode(g,{stream:!0});let Q=i.indexOf(`
120
120
 
121
121
  `);for(;Q!==-1;){const B=i.slice(0,Q);i=i.slice(Q+2);const u=B.split(`
122
122
  `);let E="message",c="";for(const h of u)h.startsWith("event: ")?E=h.slice(7).trim():h.startsWith("data: ")?c+=(c?`
@@ -146,4 +146,4 @@ ${U.map(O=>`+${O}`).join(`
146
146
  `)){const n=s.indexOf(":");n>0&&(t[s.slice(0,n).trim()]=s.slice(n+1).trim())}return Object.keys(t).length>0?t:void 0}const PN=m.memo(function({isOpen:e,onClose:t}){const[s,n]=m.useState("local"),[r,i]=m.useState(""),[a,g]=m.useState(""),[Q,B]=m.useState(""),[u,E]=m.useState("http"),[c,h]=m.useState(""),[f,d]=m.useState(""),[D,R]=m.useState("global"),[M,q]=m.useState(null),G=LN(),T=m.useCallback(()=>{i(""),g(""),B(""),E("http"),h(""),d(""),R("global"),q(null),n("local")},[]),Z=m.useCallback(()=>{T(),t()},[T,t]),X=m.useCallback(async()=>{q(null);const Y=r.trim();if(!Y){q("Server name is required");return}try{if(s==="local"){const x=a.trim();if(!x){q("Command is required");return}if(/^https?:\/\//i.test(x)){q("Local commands cannot be URLs. Switch to Remote (HTTP) for remote servers.");return}const{command:l,args:I}=qN(x);await G.mutateAsync({name:Y,transport:"stdio",command:l,args:I,env:YN(f),scope:D})}else{const x=Q.trim();if(!x){q("URL is required");return}await G.mutateAsync({name:Y,transport:u,url:x,headers:HN(c),scope:D})}Z()}catch(x){q(x instanceof Error?x.message:"Failed to add server")}},[r,s,a,f,Q,u,c,D,G,Z]),U=m.useRef(null),[O,j]=m.useState(void 0);return m.useEffect(()=>{const Y=U.current;if(!Y)return;const x=new ResizeObserver(()=>{j(Y.scrollHeight)});return x.observe(Y),()=>x.disconnect()},[]),o.jsx(Lo,{isOpen:e,onClose:Z,title:"Add MCP Server",children:o.jsx("div",{className:"overflow-hidden transition-[height] duration-200 ease-in-out",style:{height:O!==void 0?O:"auto"},children:o.jsxs("div",{ref:U,className:"space-y-4",children:[o.jsxs("div",{className:"relative flex w-full rounded-lg bg-muted p-1",children:[o.jsx("div",{className:"absolute top-1 bottom-1 rounded-md bg-background shadow-md border border-border transition-all duration-200 ease-in-out",style:{left:s==="local"?"4px":"50%",right:s==="remote"?"4px":"50%"}}),o.jsxs("button",{type:"button",onClick:()=>n("local"),className:`relative z-10 flex items-center justify-center gap-2 flex-1 text-sm font-medium py-2 rounded-md transition-colors duration-200 ${s==="local"?"text-foreground":"text-muted-foreground/50"}`,children:[o.jsx(ao,{className:"w-4 h-4"}),"Local (stdio)"]}),o.jsxs("button",{type:"button",onClick:()=>n("remote"),className:`relative z-10 flex items-center justify-center gap-2 flex-1 text-sm font-medium py-2 rounded-md transition-colors duration-200 ${s==="remote"?"text-foreground":"text-muted-foreground/50"}`,children:[o.jsx(Zo,{className:"w-4 h-4"}),"Remote (HTTP)"]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium mb-1",children:"Name"}),o.jsx(hn,{value:r,onChange:Y=>i(Y.target.value),placeholder:"e.g. github, linear, helius",autoFocus:!0})]}),s==="local"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium mb-1",children:"Command"}),o.jsx(hn,{value:a,onChange:Y=>g(Y.target.value),placeholder:"e.g. npx -y @modelcontextprotocol/server-github",onKeyDown:Y=>{Y.key==="Enter"&&X()}}),o.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Like"," ",o.jsx("code",{className:"bg-muted px-1 rounded",children:"npx -y helius-mcp@latest"})]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium mb-1",children:"Environment Variables"}),o.jsx("textarea",{value:f,onChange:Y=>d(Y.target.value),placeholder:`GITHUB_TOKEN=ghp_xxx
147
147
  API_KEY=sk-xxx`,rows:2,className:"w-full bg-muted border border-border rounded-md px-3 py-2 text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-primary"}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"One per line: KEY=VALUE"})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium mb-1",children:"URL"}),o.jsx(hn,{value:Q,onChange:Y=>B(Y.target.value),placeholder:"e.g. https://mcp.linear.app/mcp",onKeyDown:Y=>{Y.key==="Enter"&&X()}})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium mb-1",children:"Transport"}),o.jsxs("div",{className:"relative flex w-full rounded-lg border border-border bg-muted/50 p-0.5",children:[o.jsx("div",{className:"absolute top-0.5 bottom-0.5 rounded-md bg-background shadow-md border border-border transition-all duration-200 ease-in-out",style:{left:u==="http"?"2px":"50%",right:u==="sse"?"2px":"50%"}}),o.jsx("button",{type:"button",onClick:()=>E("http"),className:`relative z-10 flex items-center justify-center gap-1.5 text-xs font-medium py-1.5 rounded-md flex-1 transition-colors duration-200 ${u==="http"?"text-foreground":"text-muted-foreground/50"}`,children:"HTTP (recommended)"}),o.jsx("button",{type:"button",onClick:()=>E("sse"),className:`relative z-10 flex items-center justify-center gap-1.5 text-xs font-medium py-1.5 rounded-md flex-1 transition-colors duration-200 ${u==="sse"?"text-foreground":"text-muted-foreground/50"}`,children:"SSE (legacy)"})]})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium mb-1",children:"Headers"}),o.jsx("textarea",{value:c,onChange:Y=>h(Y.target.value),placeholder:"Authorization: Bearer xxx",rows:2,className:"w-full bg-muted border border-border rounded-md px-3 py-2 text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-primary"}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"One per line: Header-Name: value"})]}),o.jsx("p",{className:"text-xs text-muted-foreground",children:"For OAuth servers (Linear, Notion, etc.), leave headers empty and authenticate after adding."})]}),o.jsxs("div",{children:[o.jsx("div",{className:"text-sm font-medium mb-1",children:"Scope"}),o.jsxs("div",{className:"relative flex w-full rounded-lg border border-border bg-muted/50 p-0.5",children:[o.jsx("div",{className:"absolute top-0.5 bottom-0.5 rounded-md bg-background shadow-md border border-border transition-all duration-200 ease-in-out",style:{left:D==="global"?"2px":"50%",right:D==="project"?"2px":"50%"}}),o.jsxs("button",{type:"button",onClick:()=>R("global"),className:`relative z-10 flex items-center justify-center gap-1.5 text-xs font-medium py-1.5 rounded-md flex-1 transition-colors duration-200 ${D==="global"?"text-foreground":"text-muted-foreground/50"}`,children:[o.jsx(sg,{className:"w-3 h-3"}),"All projects"]}),o.jsxs("button",{type:"button",onClick:()=>R("project"),className:`relative z-10 flex items-center justify-center gap-1.5 text-xs font-medium py-1.5 rounded-md flex-1 transition-colors duration-200 ${D==="project"?"text-foreground":"text-muted-foreground/50"}`,children:[o.jsx(hr,{className:"w-3 h-3"}),"This project only"]})]}),o.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:D==="global"?"Saved to ~/.config/otto/config.json":"Saved to .otto/config.json (project-local)"})]}),M&&o.jsx("div",{className:"text-sm text-red-400 bg-red-500/10 px-3 py-2 rounded",children:M}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[o.jsx(fe,{variant:"ghost",onClick:Z,children:"Cancel"}),o.jsx(fe,{variant:"primary",onClick:X,disabled:G.isPending,children:G.isPending?o.jsxs(o.Fragment,{children:[o.jsx(Te,{className:"w-3 h-3 animate-spin mr-1"}),"Adding..."]}):"Add Server"})]})]})})})}),Ya=m.memo(function({checked:e,loading:t,onChange:s,disabled:n}){return o.jsx("button",{type:"button",role:"switch","aria-checked":e,disabled:n||t,onClick:r=>{r.stopPropagation(),s()},className:`relative inline-flex h-5 w-9 flex-shrink-0 items-center rounded-full transition-colors duration-200 focus-visible:outline-none disabled:opacity-50 disabled:cursor-not-allowed ${e?"bg-green-500":"bg-muted-foreground/30"}`,children:o.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full transition-transform duration-200 ${e?"translate-x-[18px]":"translate-x-[3px]"} ${t?"bg-transparent":"bg-white"}`,children:t?o.jsx(Te,{className:"w-3.5 h-3.5 animate-spin text-white"}):null})})}),WN=m.memo(function({userCode:e,verificationUri:t}){const[s,n]=m.useState(!1),r=m.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)})},[e]);return o.jsx("div",{className:"px-3 pb-2.5 pt-0",children:o.jsxs("div",{className:"rounded-md bg-yellow-500/10 border border-yellow-500/20 p-2 space-y-1.5",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[o.jsx(Te,{className:"w-3 h-3 animate-spin text-yellow-500 flex-shrink-0"}),o.jsx("span",{className:"text-yellow-500/80",children:"Enter code at GitHub:"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("code",{className:"text-sm font-mono font-bold text-yellow-400 tracking-wider",children:e}),o.jsx("button",{type:"button",onClick:r,className:"text-yellow-500/60 hover:text-yellow-400 transition-colors",title:"Copy code",children:o.jsx(ru,{className:"w-3.5 h-3.5"})}),s&&o.jsx("span",{className:"text-xs text-green-400",children:"Copied!"})]}),o.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer",onClick:i=>{i.preventDefault(),Io(t)},className:"inline-flex items-center gap-1 text-xs text-yellow-400 hover:text-yellow-300 underline underline-offset-2",children:["Open GitHub login",o.jsx(Gt,{className:"w-3 h-3"})]})]})})}),zN=m.memo(function({server:e,isLoading:t,authUrl:s,copilotDevice:n,onStart:r,onStop:i,onRemove:a,onAuth:g}){const[Q,B]=m.useState(!1),u=e.connected&&e.tools.length>0,E=e.transport==="http"||e.transport==="sse",c=(!!s||!!n)&&!e.connected,h=m.useCallback(()=>{e.authRequired&&!e.connected?g():e.connected?i():r()},[e.connected,e.authRequired,g,i,r]),f=m.useCallback(()=>{u&&B(d=>!d)},[u]);return o.jsxs("div",{className:`group transition-colors duration-200 ${e.connected?"bg-green-500/5 hover:bg-green-500/10":c?"bg-yellow-500/5 hover:bg-yellow-500/10":"hover:bg-accent"}`,children:[o.jsxs("div",{className:"flex items-center gap-3 px-3 py-2",children:[o.jsx(Ya,{checked:e.connected,loading:t||c,onChange:h}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsx("span",{className:"text-sm font-medium truncate",children:e.name}),E&&o.jsx(Zo,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),e.authRequired&&!e.connected&&o.jsx(nu,{className:"w-3 h-3 text-yellow-500 flex-shrink-0"})]}),o.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[o.jsx("span",{className:"text-xs text-muted-foreground truncate",children:E?e.url:`${e.command??""} ${e.args.join(" ")}`}),o.jsx("span",{className:"flex items-center flex-shrink-0 opacity-50",title:e.scope==="project"?"Project-local":"Global",children:e.scope==="project"?o.jsx(hr,{className:"w-3 h-3"}):o.jsx(sg,{className:"w-3 h-3"})})]})]}),o.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[u&&o.jsxs("button",{type:"button",onClick:f,className:"flex items-center gap-0.5 text-xs text-muted-foreground hover:text-foreground px-1.5 py-1 rounded transition-colors",children:[o.jsx(iu,{className:"w-3 h-3"}),e.tools.length,Q?o.jsx(Mt,{className:"w-3 h-3"}):o.jsx(Ut,{className:"w-3 h-3"})]}),o.jsx(fe,{variant:"ghost",size:"icon",onClick:a,title:"Remove server",className:"h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(Ar,{className:"w-3 h-3 text-muted-foreground hover:text-red-400"})})]})]}),n&&!e.connected&&o.jsx(WN,{userCode:n.userCode,verificationUri:n.verificationUri}),!n&&c&&s&&o.jsx("div",{className:"px-3 pb-2.5 pt-0",children:o.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[o.jsx(Te,{className:"w-3 h-3 animate-spin text-yellow-500 flex-shrink-0"}),o.jsx("span",{className:"text-yellow-500/80",children:"Waiting for auth..."}),o.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",onClick:d=>{d.preventDefault(),Io(s)},className:"inline-flex items-center gap-0.5 text-yellow-400 hover:text-yellow-300 underline underline-offset-2",children:["Open login",o.jsx(Gt,{className:"w-3 h-3"})]})]})}),u&&Q&&o.jsx("div",{className:"px-3 pb-2.5 pt-0",children:o.jsx("div",{className:"flex flex-wrap gap-1",children:e.tools.map(d=>o.jsx("span",{className:"text-xs bg-muted px-1.5 py-0.5 rounded",title:d,children:d.split("__").pop()},d))})})]})});function VN(A,e){const{data:t}=jN(A),s=m.useRef(!1);m.useEffect(()=>{t?.authenticated&&!s.current&&e(),s.current=t?.authenticated??!1},[t?.authenticated,e])}const _N=m.memo(function(){const e=Ze(l=>l.isExpanded),t=Ze(l=>l.collapseSidebar),s=Ze(l=>l.servers),n=Ze(l=>l.loading),r=Ze(l=>l.authUrls),i=Ze(l=>l.setAuthUrl),a=Ze(l=>l.setLoading),g=Ze(l=>l.setCopilotDevice),{isLoading:Q}=UN(),B=RN(),u=KN(),E=JN(),c=TN(),h=ON(),[f,d]=m.useState(!1),[D,R]=m.useState(null),[M,q]=m.useState(null),[G,T]=m.useState(""),Z=De(),X=m.useCallback(()=>{D&&(i(D,null),R(null),Z.invalidateQueries({queryKey:["mcp","servers"]}))},[D,i,Z]);VN(D,X),m.useEffect(()=>{for(const l of n)s.find(y=>y.name===l)?.connected&&a(l,!1)},[s,n,a]);const U=m.useCallback((l,I)=>{I.sessionId&&I.userCode&&I.verificationUri&&(g({sessionId:I.sessionId,userCode:I.userCode,verificationUri:I.verificationUri,interval:I.interval??5,serverName:l}),Io(I.verificationUri))},[g]),O=m.useCallback(async l=>{try{a(l,!0);const I=await c.mutateAsync(l);if(I.authType==="copilot-device"){if(I.authenticated){a(l,!1),Z.invalidateQueries({queryKey:["mcp","servers"]});return}U(l,I)}else I.authUrl?(i(l,I.authUrl),R(l),Io(I.authUrl)):a(l,!1)}catch{a(l,!1),i(l,null)}},[c,i,a,U,Z]),j=m.useCallback(async l=>{try{a(l,!0);const I=await B.mutateAsync(l);I.authType==="copilot-device"&&!I.connected?U(l,I):I.authRequired&&I.authUrl?(i(l,I.authUrl),R(l),Io(I.authUrl)):a(l,!1)}catch{a(l,!1),i(l,null)}},[B,i,a,U]),Y=m.useMemo(()=>{const l=G.trim().toLowerCase();return[...l?s.filter(y=>{const b=y.command?`${y.command} ${y.args.join(" ")}`:"";return y.name.toLowerCase().includes(l)||(y.url??"").toLowerCase().includes(l)||b.toLowerCase().includes(l)}):s].sort((y,b)=>y.connected&&!b.connected?-1:!y.connected&&b.connected?1:y.name.localeCompare(b.name))},[s,G]);if(!e)return null;const x=s.filter(l=>l.connected).length;return o.jsxs("div",{className:"w-full min-w-80 border-l border-sidebar-border sidebar-fade-in flex flex-col h-full",children:[o.jsx(as,{icon:o.jsx(Gr,{className:"size-[15px]"}),title:o.jsxs(o.Fragment,{children:["MCP Servers",x>0&&o.jsxs("span",{className:"ml-2 text-xs bg-green-500/20 text-green-400 px-1.5 py-0.5 rounded-full",children:[x," active"]})]}),onClose:t,children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:()=>d(!0),title:"Add MCP server",className:"h-7 w-7",children:o.jsx(Bo,{className:"w-4 h-4"})})}),s.length>0&&o.jsx("div",{className:"px-2 py-2 border-b border-sidebar-border/60",children:o.jsxs("div",{className:"relative",children:[o.jsx($o,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none"}),o.jsx("input",{type:"text",value:G,onChange:l=>T(l.target.value),placeholder:"Search servers...",className:"w-full h-8 pl-7 pr-7 text-[12px] bg-muted/40 border border-sidebar-border/60 rounded-md outline-none focus:border-foreground/20 placeholder:text-muted-foreground"}),G&&o.jsx("button",{type:"button",onClick:()=>T(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 h-5 w-5 rounded text-muted-foreground hover:text-foreground hover:bg-muted flex items-center justify-center",title:"Clear search",children:o.jsx(et,{className:"w-3 h-3"})})]})}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:Q&&s.length===0?o.jsxs("div",{className:"flex items-center justify-center h-32 text-muted-foreground",children:[o.jsx(Te,{className:"w-4 h-4 animate-spin mr-2"}),"Loading..."]}):s.length===0?o.jsxs("div",{className:"p-4 text-sm text-muted-foreground space-y-3",children:[o.jsx("p",{children:"No MCP servers configured."}),o.jsxs(fe,{variant:"primary",size:"sm",onClick:()=>d(!0),className:"w-full",children:[o.jsx(Bo,{className:"w-3 h-3 mr-1"}),"Add MCP Server"]}),o.jsxs("p",{className:"text-xs",children:["Or add servers to"," ",o.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs",children:".otto/config.json"})]})]}):Y.length===0?o.jsxs("div",{className:"p-4 text-sm text-muted-foreground text-center",children:['No servers match "',G,'".']}):o.jsx("div",{className:"py-1",children:Y.map(l=>o.jsx(zN,{server:l,isLoading:n.has(l.name),authUrl:r.get(l.name),copilotDevice:h?.serverName===l.name?h:null,onStart:()=>j(l.name),onStop:()=>u.mutate(l.name),onRemove:()=>q(l.name),onAuth:()=>O(l.name)},l.name))})}),o.jsx(PN,{isOpen:f,onClose:()=>d(!1)}),o.jsxs(Lo,{isOpen:!!M,onClose:()=>q(null),title:"Remove MCP Server",maxWidth:"sm",showCloseButton:!1,children:[o.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["Are you sure you want to remove"," ",o.jsx("span",{className:"font-medium text-foreground",children:M}),"? This will stop the server and remove its configuration."]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(fe,{variant:"secondary",size:"sm",onClick:()=>q(null),children:"Cancel"}),o.jsx(fe,{variant:"primary",size:"sm",className:"bg-red-500 hover:bg-red-600 text-white",onClick:()=>{M&&E.mutate(M),q(null)},children:"Remove"})]})]})]})}),ZN=m.memo(function(){const e=Ze(r=>r.isExpanded),t=Ze(r=>r.toggleSidebar),n=Ze(r=>r.servers).filter(r=>r.connected).length;return o.jsxs("button",{type:"button",onClick:t,className:`relative h-12 w-full transition-colors touch-manipulation flex items-center justify-center border-r-2 ${e?"bg-muted border-primary":"border-transparent hover:bg-muted/50"}`,title:"MCP Servers",children:[o.jsx(Gr,{className:"size-[18px] text-muted-foreground mx-auto"}),n>0&&o.jsx("span",{className:"absolute top-1.5 right-1.5 w-2 h-2 bg-green-500 rounded-full"}),o.jsx(Gs,{shortcut:"5"})]})});function XN(){const A=Pe(t=>t.setSkillsConfig),e=at({queryKey:["skills"],queryFn:async()=>fA.getSkillsConfig(),refetchInterval:3e4});return m.useEffect(()=>{e.data?.items&&A({skills:e.data.items,globalEnabled:e.data.enabled,totalCount:e.data.totalCount,enabledCount:e.data.enabledCount})},[e.data,A]),e}function $N(){const A=De(),e=Pe(t=>t.setSkillsConfig);return We({mutationFn:t=>fA.updateSkillsConfig(t),onSuccess:t=>{e({skills:t.items,globalEnabled:t.enabled,totalCount:t.totalCount,enabledCount:t.enabledCount}),A.setQueryData(["skills"],t)}})}function CC(A){return at({queryKey:["skills",A],queryFn:async()=>A?fA.getSkill(A):null,enabled:!!A})}function Ak(A){return at({queryKey:["skills",A,"files"],queryFn:async()=>A?fA.getSkillFiles(A):null,enabled:!!A})}function ek(A,e){return at({queryKey:["skills",A,"files",e],queryFn:async()=>!A||!e?null:fA.getSkillFileContent(A,e),enabled:!!A&&!!e})}const tk={cwd:hr,parent:hr,repo:hr,user:sg,system:Zo},WQ={cwd:"Project",parent:"Parent",repo:"Repository",user:"User",system:"System"};function ok(A){return A<1024?`${A} B`:A<1024*1024?`${(A/1024).toFixed(1)} KB`:`${(A/(1024*1024)).toFixed(1)} MB`}const sk=m.memo(function(){const e=Pe(T=>T.isExpanded),t=Pe(T=>T.collapseSidebar),s=Pe(T=>T.skills),n=Pe(T=>T.globalEnabled),r=Pe(T=>T.totalCount),i=Pe(T=>T.enabledCount),a=Pe(T=>T.selectedSkill),g=Pe(T=>T.selectSkill),Q=Pe(T=>T.openViewer),B=Pe(T=>T.viewingFile),[u,E]=m.useState(""),{isLoading:c,isFetching:h,refetch:f}=XN(),d=$N(),{data:D}=CC(a),{data:R}=Ak(a),M=R?.files??[],q=m.useMemo(()=>{const T=u.trim().toLowerCase();return T?s.filter(Z=>Z.name.toLowerCase().includes(T)||(Z.description??"").toLowerCase().includes(T)):s},[s,u]),G=m.useMemo(()=>{const T=new Map;for(const Z of q){const X=T.get(Z.scope)??[];X.push(Z),T.set(Z.scope,X)}return T},[q]);return e?o.jsxs("div",{className:"w-full min-w-80 border-l border-sidebar-border sidebar-fade-in flex flex-col h-full",children:[o.jsx(as,{icon:o.jsx(Zt,{className:"size-[15px]"}),title:"Skills",onClose:t,children:o.jsx(Ya,{checked:n,loading:d.isPending,onChange:()=>d.mutate({enabled:!n})})}),!a&&r>0&&o.jsx("div",{className:"px-2 py-2 border-b border-sidebar-border/60",children:o.jsxs("div",{className:"relative",children:[o.jsx($o,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none"}),o.jsx("input",{type:"text",value:u,onChange:T=>E(T.target.value),placeholder:"Search skills...",className:"w-full h-8 pl-7 pr-7 text-[12px] bg-muted/40 border border-sidebar-border/60 rounded-md outline-none focus:border-foreground/20 placeholder:text-muted-foreground"}),u&&o.jsx("button",{type:"button",onClick:()=>E(""),className:"absolute right-1.5 top-1/2 -translate-y-1/2 h-5 w-5 rounded text-muted-foreground hover:text-foreground hover:bg-muted flex items-center justify-center",title:"Clear search",children:o.jsx(et,{className:"w-3 h-3"})})]})}),a&&D?o.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o.jsx("div",{className:"p-3 border-b border-border",children:o.jsx("button",{type:"button",onClick:()=>g(null),className:"text-xs text-muted-foreground hover:text-foreground transition-colors",children:"← Back to list"})}),o.jsxs("div",{className:"px-3 py-3 border-b border-border",children:[o.jsx("h3",{className:"font-medium text-sm mb-1",children:D.name}),o.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:D.description}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:WQ[D.scope]??D.scope}),D.license&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:D.license})]})]}),o.jsxs("div",{className:"py-1",children:[o.jsx("div",{className:"flex items-center gap-1.5 px-3 py-2 text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:"Files"}),o.jsx("button",{type:"button",onClick:()=>Q(null),className:`w-full text-left px-3 py-2 hover:bg-accent transition-colors ${B===null?"bg-accent":""}`,children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Uo,{className:"w-3.5 h-3.5 flex-shrink-0 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-mono truncate flex-1",children:"SKILL.md"})]})}),M.map(T=>o.jsx("button",{type:"button",onClick:()=>Q(T.relativePath),className:`w-full text-left px-3 py-2 hover:bg-accent transition-colors ${B===T.relativePath?"bg-accent":""}`,children:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(vr,{className:"w-3.5 h-3.5 flex-shrink-0 text-muted-foreground"}),o.jsx("span",{className:"text-sm font-mono truncate flex-1",children:T.relativePath}),o.jsx("span",{className:"text-[10px] text-muted-foreground flex-shrink-0",children:ok(T.size)})]})},T.relativePath))]})]}):o.jsx("div",{className:"flex-1 overflow-y-auto",children:c?o.jsx("div",{className:"flex items-center justify-center py-8",children:o.jsx(Te,{className:"w-4 h-4 animate-spin text-muted-foreground"})}):r===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-4",children:[o.jsx(Zt,{className:"w-12 h-12 text-muted-foreground/30 mb-4"}),o.jsx("h3",{className:"text-sm font-medium mb-2",children:"No skills found"}),o.jsxs("p",{className:"text-xs text-muted-foreground max-w-[220px]",children:["Create skills in"," ",o.jsx("code",{className:"text-[10px] bg-muted px-1 rounded",children:".otto/skills/ or .agents/skills/"})," ","or"," ",o.jsx("code",{className:"text-[10px] bg-muted px-1 rounded",children:"~/.config/otto/skills/ or ~/.agents/skills/"})]})]}):n?s.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-4",children:[o.jsx(Zt,{className:"w-12 h-12 text-muted-foreground/30 mb-4"}),o.jsx("h3",{className:"text-sm font-medium mb-2",children:"All skills are disabled"}),o.jsx("p",{className:"text-xs text-muted-foreground max-w-[220px]",children:"Enable individual skills or turn all skills back on."})]}):q.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-4",children:[o.jsx(Zt,{className:"w-12 h-12 text-muted-foreground/30 mb-4"}),o.jsx("h3",{className:"text-sm font-medium mb-2",children:"No matches"}),o.jsxs("p",{className:"text-xs text-muted-foreground max-w-[220px]",children:['No skills match "',u,'".']})]}):o.jsx("div",{className:"py-1",children:["cwd","parent","repo","user","system"].map(T=>{const Z=G.get(T);if(!Z?.length)return null;const X=tk[T]??Zo;return o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-[10px] uppercase tracking-wider text-muted-foreground font-medium",children:[o.jsx(X,{className:"w-3 h-3"}),WQ[T]??T]}),Z.map(U=>o.jsx("button",{type:"button",onClick:()=>g(U.name),className:`w-full text-left px-3 py-2 hover:bg-accent transition-colors ${a===U.name?"bg-accent":""}`,children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Uo,{className:"w-3.5 h-3.5 flex-shrink-0 text-muted-foreground"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("div",{className:"text-sm font-medium truncate",children:U.name}),o.jsx("div",{className:"text-xs text-muted-foreground truncate",children:U.description})]}),o.jsx(Ya,{checked:U.enabled!==!1,loading:d.isPending,onChange:()=>d.mutate({items:{[U.name]:{enabled:U.enabled===!1}}})})]})},`${U.scope}-${U.name}`))]},T)})}):o.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center p-4",children:[o.jsx(Zt,{className:"w-12 h-12 text-muted-foreground/30 mb-4"}),o.jsx("h3",{className:"text-sm font-medium mb-2",children:"Skills are disabled"}),o.jsx("p",{className:"text-xs text-muted-foreground max-w-[220px]",children:"Turn the skills toggle on to make discovered skills available."})]})}),o.jsxs("div",{className:"h-12 px-3 border-t border-border text-xs text-muted-foreground flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o.jsx(Zt,{className:"w-3 h-3 flex-shrink-0"}),o.jsxs("span",{className:"truncate",children:[i,"/",r," ",r===1?"skill":"skills"]})]}),o.jsx(fe,{variant:"ghost",size:"icon",onClick:()=>f(),title:"Refresh skills",className:"h-6 w-6 flex-shrink-0",disabled:h,children:o.jsx(Xt,{className:`w-3 h-3 ${h?"animate-spin":""}`})})]})]}):null}),rk=m.memo(function(){const e=Pe(s=>s.isExpanded),t=Pe(s=>s.toggleSidebar);return o.jsxs("button",{type:"button",onClick:t,className:`relative h-12 w-full transition-colors touch-manipulation flex items-center justify-center border-r-2 ${e?"bg-muted border-primary":"border-transparent hover:bg-muted/50"}`,title:"Skills",children:[o.jsx(Zt,{className:"size-[18px] text-muted-foreground mx-auto"}),o.jsx(Gs,{shortcut:"6"})]})}),nk={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",sql:"sql",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",html:"html",css:"css",scss:"scss",md:"markdown",txt:"plaintext",toml:"toml"};function ik(A){const e=A.split(".").pop()?.toLowerCase()??"";return nk[e]??"plaintext"}const ak=m.memo(function({mode:e="overlay",open:t,skillName:s,file:n,onClose:r}={}){const i=Pe(Z=>Z.isViewerOpen),a=Pe(Z=>Z.viewingFile),g=Pe(Z=>Z.selectedSkill),Q=Pe(Z=>Z.closeViewer),B=t??i,u=n!==void 0?n:a,E=s??g,c=r??Q,{data:h}=CC(E),{data:f,isLoading:d}=ek(E,u),D=u===null,R=D?h?.content:f?.content,M=D?!h:d,q=D?"SKILL.md":u??"",G=ik(q);if(m.useEffect(()=>{const Z=X=>{const U=X.target,O=U.tagName==="INPUT"||U.tagName==="TEXTAREA"||U.isContentEditable;(X.key==="Escape"||X.key==="q"&&!O)&&B&&c()};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[B,c]),!B||!E)return null;const T=document?.documentElement.classList.contains("dark")?po:fo;return o.jsxs("div",{className:e==="pane"?"h-full w-full bg-transparent flex flex-col":"absolute inset-0 bg-background z-50 flex flex-col animate-in slide-in-from-left duration-300",children:[e!=="pane"&&o.jsxs("div",{className:"h-12 border-b border-sidebar-border px-2.5 flex items-center gap-2 shrink-0 bg-sidebar-accent/40",children:[o.jsx(fe,{variant:"ghost",size:"icon",onClick:c,title:"Close viewer (ESC)",className:"h-8 w-8",children:o.jsx(et,{className:"size-[17px]"})}),o.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"text-[13px] text-muted-foreground flex-shrink-0",children:E}),o.jsx("span",{className:"text-[13px] text-muted-foreground",children:"/"}),o.jsx("span",{className:"text-[13px] font-medium text-foreground font-mono truncate",title:q,children:q})]}),o.jsx("span",{className:"text-[12px] text-muted-foreground pr-1",children:G})]}),o.jsx("div",{className:"flex-1 overflow-auto",children:M?o.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Loading..."}):R?o.jsx("div",{className:"code-with-line-numbers",children:o.jsx(Wt,{language:G,style:T,wrapLines:!0,wrapLongLines:!0,lineProps:()=>({className:"code-line"}),customStyle:{margin:0,padding:"1rem",background:"transparent",fontSize:"0.8125rem",lineHeight:"1.3125rem"},codeTagProps:{style:{flex:1}},children:R})}):o.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Unable to load file"})})]})}),zQ="file-browser",VQ=320,gk=280,lk=600;function Qk(A){if(!A)return null;switch(A.type){case"git-diff":case"session-file-diff":case"file":return A.path;case"skill-file":return A.file}}function Bk(A){return A?.type==="file"?A.path:null}function ck({dirPath:A}){const t=$e(r=>r.expandedDirs).has(A),{data:s,isLoading:n}=AC(A,t);return t?n?o.jsx("div",{className:"pl-4 py-1 text-xs text-muted-foreground",children:"Loading..."}):o.jsx("div",{className:"pl-3",children:s?.items.map(r=>o.jsx(uC,{name:r.name,path:r.path,type:r.type,gitignored:r.gitignored,vendor:r.vendor},r.path))}):null}function uC({name:A,path:e,type:t,gitignored:s,vendor:n}){const r=$e(f=>f.expandedDirs),i=$e(f=>f.toggleDir),a=$e(f=>f.openFile),g=$e(f=>f.selectedFile),Q=Ht(f=>f.tabs.find(d=>d.id===f.activeTabId)),B=r.has(e),u=Qk(Q),E=g===e||u===e,c=m.useRef(null);m.useEffect(()=>{E&&c.current?.scrollIntoView({block:"nearest"})},[E]);const h=m.useCallback(()=>{t==="directory"?i(e):a(e)},[t,e,i,a]);return o.jsxs("div",{children:[o.jsxs("button",{ref:c,type:"button",onClick:h,className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-sm hover:bg-muted/50 rounded transition-colors ${E?"bg-muted text-foreground":"text-foreground/80"} ${s||n?"opacity-40":""}`,children:[t==="directory"?o.jsxs(o.Fragment,{children:[B?o.jsx(Mt,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}):o.jsx(Ut,{className:"w-3 h-3 text-muted-foreground flex-shrink-0"}),B?o.jsx(CB,{className:"w-3.5 h-3.5 text-blue-500 flex-shrink-0"}):o.jsx(uB,{className:"w-3.5 h-3.5 text-blue-500 flex-shrink-0"})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"w-3 flex-shrink-0"}),o.jsx(vr,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"})]}),o.jsx("span",{className:"truncate",children:A})]}),t==="directory"&&o.jsx(ck,{dirPath:e})]})}const Ek=m.memo(function(){const e=$e(Q=>Q.isExpanded),t=$e(Q=>Q.collapseSidebar),s=$e(Q=>Q.revealFile),n=Ht(Q=>{const B=Q.tabs.find(u=>u.id===Q.activeTabId);return Bk(B)}),r=Xo(Q=>Q.widths[zQ]??VQ),{data:i,isLoading:a,refetch:g}=AC(".");return m.useEffect(()=>{e&&n&&s(n)},[e,n,s]),e?o.jsxs("div",{className:"border-l border-sidebar-border sidebar-fade-in flex h-full relative",style:{width:r},children:[o.jsx(tr,{panelKey:zQ,side:"right",minWidth:gk,maxWidth:lk,defaultWidth:VQ}),o.jsxs("div",{className:"flex-1 flex flex-col h-full min-w-0",children:[o.jsx(as,{icon:o.jsx(Dr,{className:"size-[15px]"}),title:"Files",onClose:t}),o.jsx("div",{className:"flex-1 overflow-y-auto p-1",children:a?o.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading file tree..."}):!i||i.items.length===0?o.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"No files found"}):i.items.map(Q=>o.jsx(uC,{name:Q.name,path:Q.path,type:Q.type,gitignored:Q.gitignored,vendor:Q.vendor},Q.path))}),o.jsxs("div",{className:"h-12 px-3 border-t border-border text-xs text-muted-foreground flex items-center justify-between gap-2",children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[o.jsx(Dr,{className:"w-3 h-3 flex-shrink-0"}),o.jsx("span",{className:"truncate",children:"Project Files"})]}),o.jsx(fe,{variant:"ghost",size:"icon",onClick:()=>g(),title:"Refresh file tree",className:"h-6 w-6 flex-shrink-0",disabled:a,children:o.jsx(Xt,{className:`w-3 h-3 ${a?"animate-spin":""}`})})]})]})]}):null}),Ck=m.memo(function(){const e=$e(s=>s.isExpanded),t=$e(s=>s.toggleSidebar);return o.jsxs("button",{type:"button",onClick:t,className:`relative h-12 w-full transition-colors touch-manipulation flex items-center justify-center border-r-2 ${e?"bg-muted border-primary":"border-transparent hover:bg-muted/50"}`,title:"Files",children:[o.jsx(Dr,{className:"size-[18px] text-muted-foreground mx-auto"}),o.jsx(Gs,{shortcut:"3"})]})}),uk={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",sql:"sql",json:"json",yaml:"yaml",yml:"yaml",xml:"xml",html:"html",css:"css",scss:"scss",md:"markdown",markdown:"markdown",mdx:"markdown",txt:"plaintext",svelte:"svelte",toml:"toml",lock:"plaintext"};function IC(A){return A.split(".").pop()?.toLowerCase()??""}function Ik(A){const e=IC(A);return uk[e]??"plaintext"}function dk(A){const e=IC(A);return e==="md"||e==="markdown"||e==="mdx"}const hk=m.memo(function({mode:e="overlay",open:t,file:s,onClose:n}={}){const r=$e(d=>d.isViewerOpen),i=$e(d=>d.selectedFile),a=$e(d=>d.closeViewer),g=t??r,Q=s??i,B=n??a,{data:u,isLoading:E}=vy(Q);if(m.useEffect(()=>{const d=D=>{const R=D.target,M=R.tagName==="INPUT"||R.tagName==="TEXTAREA"||R.isContentEditable;(D.key==="Escape"||D.key==="q"&&!M)&&g&&B()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[g,B]),!g||!Q)return null;const c=document?.documentElement.classList.contains("dark")?po:fo,h=Ik(Q),f=dk(Q);return o.jsxs("div",{className:e==="pane"?"h-full w-full bg-transparent flex flex-col":"absolute inset-0 bg-background z-50 flex flex-col animate-in slide-in-from-left duration-300",children:[e!=="pane"&&o.jsxs("div",{className:"h-12 border-b border-sidebar-border px-2.5 flex items-center gap-2 shrink-0 bg-sidebar-accent/40",children:[o.jsx(fe,{variant:"ghost",size:"icon",onClick:B,title:"Close file viewer (ESC)",className:"h-8 w-8",children:o.jsx(et,{className:"size-[17px]"})}),o.jsxs("div",{className:"flex-1 flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"text-[13px] font-medium text-foreground font-mono truncate",title:Q,children:Q}),u&&o.jsxs("span",{className:"text-[12px] text-muted-foreground flex-shrink-0",children:[u.lineCount," lines"]})]}),o.jsx("span",{className:"text-[12px] text-muted-foreground pr-1",children:h})]}),o.jsx("div",{className:"flex-1 overflow-auto",children:E?o.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Loading file..."}):u?f?o.jsx("div",{className:"p-4 text-[14px] text-foreground leading-6 markdown-content max-w-full overflow-x-auto",children:o.jsx(rg,{remarkPlugins:[ng],components:{a:({href:d,children:D,...R})=>o.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",onClick:M=>{window.self!==window.top&&d&&(M.preventDefault(),window.parent.postMessage({type:"otto-open-url",url:d},"*"))},...R,children:D}),table:({children:d,...D})=>o.jsx("div",{className:"overflow-x-auto max-w-full min-w-0 my-3",children:o.jsx("table",{...D,children:d})})},children:u.content})}):o.jsx("div",{className:"code-with-line-numbers",children:o.jsx(Wt,{language:h,style:c,wrapLines:!0,wrapLongLines:!0,lineProps:()=>({className:"code-line"}),customStyle:{margin:0,padding:"1rem",background:"transparent",fontSize:"0.8125rem",lineHeight:"1.3125rem"},codeTagProps:{style:{flex:1}},children:u.content})}):o.jsx("div",{className:"h-full flex items-center justify-center text-muted-foreground",children:"Unable to load file"})})]})}),Ha=gt(A=>({isOpen:!1,open:()=>A({isOpen:!0}),close:()=>A({isOpen:!1}),toggle:()=>A(e=>({isOpen:!e.isOpen}))}));function pk(A,e){const t=A.toLowerCase(),s=e.toLowerCase();if(t.length===0)return{match:!0,score:0};if(s.includes(t))return{match:!0,score:100-s.indexOf(t)};let n=0,r=0,i=-1;for(let a=0;a<s.length&&n<t.length;a++)s[a]===t[n]&&(r+=10,i===a-1&&(r+=5),(a===0||s[a-1]==="/"||s[a-1]===".")&&(r+=8),i=a,n++);return{match:n===t.length,score:r}}const fk=m.memo(function(){const e=Ha(d=>d.isOpen),t=Ha(d=>d.close),s=$e(d=>d.openFile),[n,r]=m.useState(""),[i,a]=m.useState(0),g=m.useRef(null),Q=m.useRef(null),{data:B}=dc({enabled:e,query:n}),u=m.useMemo(()=>new Set(B?.ignoredFiles??[]),[B?.ignoredFiles]),E=m.useMemo(()=>B?.files?n?B.files.map(D=>({file:D,...pk(n,D)})).filter(D=>D.match).sort((D,R)=>R.score-D.score).slice(0,50).map(D=>D.file):B.files.slice(0,50):[],[B?.files,n]);m.useEffect(()=>{e&&(r(""),a(0),setTimeout(()=>g.current?.focus(),0))},[e]),m.useEffect(()=>{Q.current?.children[i]?.scrollIntoView({block:"nearest"})},[i]);const c=m.useCallback(d=>{s(d),t()},[s,t]),h=m.useCallback(d=>{d.key==="ArrowDown"||d.ctrlKey&&d.key==="j"?(d.preventDefault(),a(D=>Math.min(D+1,E.length-1))):d.key==="ArrowUp"||d.ctrlKey&&d.key==="k"?(d.preventDefault(),a(D=>Math.max(D-1,0))):d.key==="Enter"&&E[i]?(d.preventDefault(),c(E[i])):d.key==="Escape"&&(d.preventDefault(),t())},[E,i,c,t]),f=m.useCallback(d=>{d.target===d.currentTarget&&t()},[t]);return e?o.jsx("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 bg-black/50 flex items-start justify-center z-[60] pt-[15vh]",onClick:f,onKeyDown:d=>{d.key==="Escape"&&t()},children:o.jsxs("div",{className:"bg-background border border-border rounded-lg shadow-2xl w-full max-w-lg overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 border-b border-border",children:[o.jsx($o,{className:"w-4 h-4 text-muted-foreground flex-shrink-0"}),o.jsx("input",{ref:g,type:"text",value:n,onChange:d=>{r(d.target.value),a(0)},onKeyDown:h,placeholder:"Search files by name...",className:"flex-1 bg-transparent py-3 text-sm text-foreground placeholder-muted-foreground outline-none"}),o.jsx("kbd",{className:"text-[10px] text-muted-foreground bg-muted px-1.5 py-0.5 rounded border border-border font-mono",children:"ESC"})]}),o.jsx("div",{ref:Q,className:"max-h-[40vh] overflow-y-auto",children:E.length===0?o.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground",children:n?"No matching files":"No files found"}):E.map((d,D)=>{const R=u.has(d);return o.jsxs("button",{type:"button",onClick:()=>c(d),className:`w-full text-left flex items-center gap-2 px-3 py-2 text-sm transition-colors ${D===i?"bg-accent text-accent-foreground":"text-foreground/80 hover:bg-muted/50"} ${R?"opacity-40":""}`,children:[o.jsx(vr,{className:"w-3.5 h-3.5 text-muted-foreground flex-shrink-0"}),o.jsx(mk,{path:d,query:n}),R&&o.jsx("span",{className:"ml-auto text-[10px] text-muted-foreground italic",children:"ignored"})]},d)})}),E.length>0&&o.jsxs("div",{className:"px-3 py-2 border-t border-border text-xs text-muted-foreground flex items-center gap-3",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"bg-muted px-1 py-0.5 rounded border border-border font-mono",children:"↑↓"})," ","navigate"]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"bg-muted px-1 py-0.5 rounded border border-border font-mono",children:"↵"})," ","open"]}),o.jsxs("span",{className:"ml-auto",children:[E.length," files"]})]})]})}):null});function mk({path:A,query:e}){if(!e)return o.jsx("span",{className:"truncate font-mono text-xs",children:A});const t=A.toLowerCase(),s=e.toLowerCase(),n=t.indexOf(s);return n>=0?o.jsxs("span",{className:"truncate font-mono text-xs",children:[A.slice(0,n),o.jsx("span",{className:"text-primary font-semibold",children:A.slice(n,n+e.length)}),A.slice(n+e.length)]}):o.jsx("span",{className:"truncate font-mono text-xs",children:A})}function wk(A){switch(A.type){case"git-diff":return A.staged?"staged diff":"diff";case"session-file-diff":return"session diff";case"file":return"file";case"skill-file":return A.skill}}function xk(A){switch(A.type){case"git-diff":case"session-file-diff":case"file":return A.path;case"skill-file":return A.file??"SKILL.md"}}function Dk(A){const e=A.split(".").pop()?.toLowerCase()??"";return e&&e!==A.toLowerCase()?e:""}function yk(A){switch(A){case"ts":case"tsx":return o.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center bg-[#3178c6] text-[7px] font-bold leading-none text-white",children:"TS"});case"js":case"jsx":case"mjs":case"cjs":return o.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center bg-[#f7df1e] text-[7px] font-bold leading-none text-black",children:"JS"});case"py":return o.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-[3px] bg-gradient-to-br from-[#3776ab] to-[#ffd43b] text-[7px] font-bold leading-none text-white",children:"Py"});case"go":return o.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full bg-[#00add8] text-[7px] font-bold leading-none text-white",children:"Go"});case"rs":return o.jsx("span",{className:"inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full bg-[#ce422b] text-[8px] font-bold leading-none text-white",children:"R"});case"json":return o.jsx(aB,{className:"h-3.5 w-3.5 shrink-0 text-yellow-500"});case"md":case"mdx":return o.jsx(Uo,{className:"h-3.5 w-3.5 shrink-0 text-sky-500"});case"env":case"toml":case"yaml":case"yml":return o.jsx(og,{className:"h-3.5 w-3.5 shrink-0 text-violet-500"});case"css":case"scss":case"sass":case"less":return o.jsx(iB,{className:"h-3.5 w-3.5 shrink-0 text-blue-500"});case"html":case"xml":return o.jsx(nB,{className:"h-3.5 w-3.5 shrink-0 text-orange-500"});case"png":case"jpg":case"jpeg":case"gif":case"svg":case"webp":return o.jsx(Hn,{className:"h-3.5 w-3.5 shrink-0 text-pink-500"});case"txt":case"log":return o.jsx(Uo,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"});default:return A?o.jsx(vr,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80"}):o.jsx(_o,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/80"})}}function Nk(A){if(A.type==="git-diff")return o.jsx(zs,{className:`h-3.5 w-3.5 shrink-0 ${A.staged?"text-emerald-500":"text-amber-500"}`});if(A.type==="session-file-diff")return o.jsx(zs,{className:"h-3.5 w-3.5 shrink-0 text-sky-500"});const e=Dk(xk(A));return o.jsx("span",{className:"shrink-0 inline-flex items-center text-muted-foreground/80",children:yk(e)})}function kk(A,e,t){switch(A.type){case"git-diff":return o.jsx(Sy,{mode:"pane",open:!0,file:A.path,staged:A.staged,onClose:()=>e(A.id)});case"session-file-diff":return o.jsx(_y,{mode:"pane",open:!0,file:A.path,operations:A.operations,operationIndex:A.selectedOperationIndex,onOperationIndexChange:s=>t(A.id,s),onClose:()=>e(A.id)});case"file":return o.jsx(hk,{mode:"pane",open:!0,file:A.path,onClose:()=>e(A.id)});case"skill-file":return o.jsx(ak,{mode:"pane",open:!0,skillName:A.skill,file:A.file,onClose:()=>e(A.id)})}}const Mk=m.memo(function(){const e=Ht(a=>a.tabs),t=Ht(a=>a.activeTabId),s=Ht(a=>a.setActiveTab),n=Ht(a=>a.closeTab),r=Ht(a=>a.updateSessionFileOperationIndex);if(m.useEffect(()=>{const a=g=>{const Q=g.target;if(Q?.tagName==="INPUT"||Q?.tagName==="TEXTAREA"||Q?.isContentEditable||g.key.toLowerCase()!=="w"||!g.metaKey&&!g.ctrlKey)return;const u=Ht.getState().activeTabId;u&&(g.preventDefault(),Ht.getState().closeTab(u))};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[]),e.length===0)return null;const i=e.find(a=>a.id===t)??e[0];return o.jsxs("section",{className:"h-full w-full min-w-0 bg-sidebar flex flex-col",children:[o.jsxs("div",{className:"h-12 shrink-0 bg-background flex overflow-x-auto overflow-y-hidden",children:[e.map(a=>{const g=a.id===i.id;return o.jsxs("div",{className:`group h-12 max-w-56 min-w-0 px-3 border-r border-sidebar-border flex items-center gap-2 text-left transition-colors ${g?"bg-sidebar text-sidebar-foreground":"border-b bg-background text-muted-foreground/70 hover:text-foreground hover:bg-sidebar-accent/40"}`,title:`${a.title}
148
148
  ${wk(a)}`,children:[o.jsxs("button",{type:"button",onClick:()=>s(a.id),className:"min-w-0 flex-1 h-full flex items-center gap-2 text-left",children:[Nk(a),o.jsx("span",{className:"min-w-0 flex-1 truncate text-[12px] font-mono",children:a.title})]}),o.jsx(fe,{variant:"ghost",size:"icon",onClick:()=>{n(a.id)},title:"Close tab",className:"h-6 w-6 opacity-60 group-hover:opacity-100 shrink-0",children:o.jsx(et,{className:"h-3.5 w-3.5"})})]},a.id)}),o.jsx("div",{className:"min-w-8 flex-1 border-b border-sidebar-border bg-background"})]}),o.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:kk(i,n,r)})]})}),bk=[{value:"openai-compatible",label:"OpenAI-compatible"},{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"google",label:"Google"},{value:"openrouter",label:"OpenRouter"},{value:"ollama",label:"Ollama"}];function _Q(A){return A>=1e6?`${(A/1e6).toFixed(1)}M`:A>=1e3?`${Math.round(A/1e3)}K`:String(A)}const Fk=m.memo(function({authStatus:e,onSetupWallet:t,onImportWallet:s,onAddProvider:n,onAddCustomProvider:r,onRemoveProvider:i,onStartOAuth:a,onStartOAuthManual:g,onExchangeOAuthCode:Q,onOpenTopup:B,onNext:u,manageMode:E=!1,onClose:c,hideHeader:h=!1,onStartCopilotDeviceFlow:f,onPollCopilotDeviceFlow:d,onGetCopilotAuthMethods:D,onSaveCopilotToken:R,onImportCopilotTokenFromGh:M,onGetCopilotDiagnostics:q}){const[G,T]=m.useState(!1),[Z,X]=m.useState(!1),[U,O]=m.useState(!1),[j,Y]=m.useState(""),[x,l]=m.useState(!1),[I,y]=m.useState(null),[b,J]=m.useState(null),[H,v]=m.useState(""),[K,C]=m.useState(!1),[p,L]=m.useState(""),[S,$]=m.useState(""),[AA,sA]=m.useState(""),[oA,bA]=m.useState(""),[GA,lA]=m.useState(""),[jA,HA]=m.useState("openai-compatible"),[ce,NA]=m.useState(!0),[_A,we]=m.useState(!1),[He,de]=m.useState(null),[Ke,nt]=m.useState(!1),[Le,kA]=m.useState([]),[he,zA]=m.useState(null),[P,N]=m.useState(null),[k,_]=m.useState(null),[tA,aA]=m.useState(null),[EA,ZA]=m.useState(""),[VA,$A]=m.useState(!1),[ke,XA]=m.useState(!1),[ye,Kt]=m.useState(null),[Je,je]=m.useState(!1),[To,Be]=m.useState(null),[ve,Lt]=m.useState("oauth"),[Oe,ze]=m.useState(""),[co,KA]=m.useState(!1),[se,_t]=m.useState(!1),[F,W]=m.useState(null),[z,w]=m.useState(null),[V,nA]=m.useState(!1),[rA,IA]=m.useState(!1),[yA,FA]=m.useState(!1),xA=m.useRef(void 0),Ee=m.useRef(!1),RA=m.useRef(d);RA.current=d;const Ae=Ne(QA=>QA.balance),ie=Ne(QA=>QA.usdcBalance),le=Ne(QA=>QA.payg),ae=Ne(QA=>QA.subscription),re=Ne(QA=>QA.isLoading),ne=m.useRef(null),ee=m.useRef(null),LA=m.useRef(null),PA=Ne(QA=>QA.isTopupModalOpen),UA=m.useRef(!1),{fetchBalance:JA}=Ii("ottorouter"),OA=le?.effectiveSpendableUsd??Ae??0,SA=ae?.active?`GO ${(ae.creditsRemaining??0).toFixed(1)} credits`:`$${OA.toFixed(2)}`;m.useEffect(()=>{UA.current&&!PA&&JA(),UA.current=PA},[PA,JA]),m.useEffect(()=>{!e.ottorouter.configured&&!Z&&(X(!0),t().finally(()=>X(!1)))},[e.ottorouter.configured,t,Z]),m.useEffect(()=>{b&&ne.current&&ne.current.focus()},[b]),m.useEffect(()=>{tA&&ee.current&&ee.current.focus()},[tA]),m.useEffect(()=>{U&&LA.current&&LA.current.focus()},[U]),m.useEffect(()=>{if(!Je||!ye||!RA.current)return;Ee.current=!1;const QA=Math.max((ye.interval||5)*1e3+2e3,7e3),Ue=()=>{xA.current=setTimeout(async()=>{if(!Ee.current)try{const mo=RA.current;if(!mo)return;const lr=await mo(ye.sessionId);if(Ee.current)return;lr.status==="complete"?(Kt(null),je(!1),Be(null),IA(!1)):lr.status==="error"?(Be(lr.error||"Authorization failed"),je(!1)):Ue()}catch{Ee.current||Ue()}},QA)};Ue();const mt=setTimeout(()=>{je(!1),Be("Authorization timed out. Please try again.")},3e5);return()=>{Ee.current=!0,xA.current&&clearTimeout(xA.current),clearTimeout(mt)}},[Je,ye]);const CA=async()=>{e.ottorouter.publicKey&&(await navigator.clipboard.writeText(e.ottorouter.publicKey),T(!0),setTimeout(()=>T(!1),2e3))},uA=QA=>`${QA.slice(0,8)}...${QA.slice(-6)}`,mA=async QA=>{if(H.trim())try{await n(QA,H.trim()),J(null),v("")}catch{}},hA=()=>{L(""),$(""),sA(""),bA(""),lA(""),HA("openai-compatible"),NA(!0),de(null),kA([]),zA(null)},pA=()=>{_A||(C(!1),hA())},MA=async()=>{const QA=AA.trim();if(!QA){zA("Enter a base URL first.");return}nt(!0),zA(null);try{const Ue=await fA.discoverProviderModels({compatibility:jA,baseURL:QA,apiKey:oA.trim()||void 0});Ue.baseURL&&sA(Ue.baseURL),kA(Ue.models),Ue.models.length>0&&lA(Ue.models.map(mt=>mt.id).join(`
149
- `)),zA(Ue.message||(Ue.models.length>0?`Fetched ${Ue.models.length} model${Ue.models.length===1?"":"s"}.`:"No models found."))}catch(Ue){kA([]),zA(Ue instanceof Error?Ue.message:"Failed to fetch models")}finally{nt(!1)}},te=async()=>{const QA=p.trim(),Ue=S.trim()||QA,mt=AA.trim(),mo=oA.trim(),lr=GA.split(/[\n,]/).map(_r=>_r.trim()).filter(Boolean);if(!QA||!mt){de("Provider ID and base URL are required.");return}we(!0),de(null);try{await r({id:QA,label:Ue,baseURL:mt,apiKey:mo||void 0,compatibility:jA,models:lr,allowAnyModel:ce}),C(!1),hA()}catch(_r){de(_r instanceof Error?_r.message:"Failed to add custom provider")}finally{we(!1)}},Ce=async QA=>{if(k===QA){N(QA);try{await i(QA)}finally{N(null),_(null)}}else _(QA)},Ie=()=>{_(null)},ue=()=>{f&&(FA(!0),Be(null),f().then(QA=>{Kt(QA),FA(!1)}).catch(QA=>{Be(QA instanceof Error?QA.message:"Failed to start device flow"),FA(!1)}))},eA=async(QA,Ue)=>{QA==="anthropic"?aA({provider:QA,sessionId:null,mode:Ue}):QA==="copilot"?(Lt("oauth"),ze(""),w(null),W(null),je(!1),Kt(null),Be(null),IA(!0),D&&D().then(mt=>W(mt)).catch(()=>{}),q&&q().then(mt=>w(mt)).catch(()=>{}),ue()):a(QA,Ue)},xe=async()=>{if(tA){XA(!0);try{const{sessionId:QA}=await g(tA.provider,tA.mode);aA({...tA,sessionId:QA})}catch(QA){console.error("Failed to start OAuth:",QA)}XA(!1)}},Ge=async()=>{if(!(!tA||!tA.sessionId||!EA.trim())){$A(!0);try{await Q(tA.provider,EA.trim(),tA.sessionId),aA(null),ZA("")}catch{}$A(!1)}},Me=()=>{aA(null),ZA("")},pe=()=>{ye&&(Io(ye.verificationUri),je(!0))},be=QA=>{Lt(QA),Be(null),QA==="token"&&je(!1),QA==="oauth"&&!ye&&!yA&&ue()},Se=async()=>{if(!(!Oe.trim()||!R)){KA(!0),Be(null);try{await R(Oe.trim()),tt()}catch(QA){Be(QA instanceof Error?QA.message:"Failed to save Copilot token")}finally{KA(!1)}}},lt=async()=>{if(M){_t(!0),Be(null);try{await M(),tt()}catch(QA){Be(QA instanceof Error?QA.message:"Failed to import token from GitHub CLI")}finally{_t(!1)}}},Ve=async()=>{ye&&(await navigator.clipboard.writeText(ye.userCode),nA(!0),setTimeout(()=>nA(!1),2e3))},tt=()=>{Kt(null),je(!1),Be(null),ze(""),KA(!1),_t(!1),Lt("oauth"),nA(!1),IA(!1),FA(!1),Ee.current=!0,xA.current&&(clearTimeout(xA.current),xA.current=void 0)},it=()=>{y(null),Y(""),O(!0)},st=()=>{x||(O(!1),y(null),Y(""))};m.useEffect(()=>{const QA=Ue=>{const mt=Ue;if(!mt.detail||mt.detail.handled)return;const mo=()=>{mt.detail.handled=!0,Ue.preventDefault()};if(K){mo(),_A||(C(!1),L(""),$(""),sA(""),bA(""),lA(""),HA("openai-compatible"),NA(!0),de(null),kA([]),zA(null));return}if(U){mo(),x||(O(!1),y(null),Y(""));return}if(tA){mo(),!VA&&!ke&&(aA(null),ZA(""));return}if(rA){mo(),!co&&!se&&!yA&&(Kt(null),je(!1),Be(null),ze(""),KA(!1),_t(!1),Lt("oauth"),nA(!1),IA(!1),FA(!1),Ee.current=!0,xA.current&&(clearTimeout(xA.current),xA.current=void 0));return}if(b){mo(),J(null),v("");return}k&&(mo(),_(null))};return window.addEventListener("otto:native-back",QA),()=>window.removeEventListener("otto:native-back",QA)},[b,k,se,yA,rA,co,_A,K,VA,x,U,ke,tA]);const ct=async()=>{if(!(!j.trim()||x)){l(!0),y(null);try{await s(j.trim()),O(!1),Y(""),JA()}catch(QA){y(QA instanceof Error?QA.message:"Failed to import wallet")}finally{l(!1)}}},dt=Object.entries(e.providers).filter(([QA,Ue])=>Ue.configured&&QA!=="ottorouter"),yt=Object.entries(e.providers).filter(([QA,Ue])=>!Ue.configured&&QA!=="ottorouter");return o.jsxs("div",{className:"min-h-screen flex flex-col",children:[!h&&o.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-6 py-4 border-b border-border",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(ro,{provider:"ottorouter",size:24}),o.jsx("span",{className:"font-semibold text-foreground",children:"otto"})]}),!E&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500"}),"Step 1 of 2"]})]}),o.jsx("div",{className:`flex-1 px-4 sm:px-6 lg:px-12 pb-32 ${h?"pt-8 sm:pt-10 lg:pt-14":"pt-6 sm:pt-8 lg:pt-12"}`,children:o.jsxs("div",{className:"max-w-7xl mx-auto",children:[o.jsxs("div",{className:"mb-10",children:[o.jsx("h1",{className:"text-2xl sm:text-3xl lg:text-4xl font-semibold text-foreground mb-3",children:E?"Manage Providers":"Welcome to otto"}),o.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl",children:E?"Add or remove AI providers. Your changes are saved automatically.":"Setu is your default AI provider. GO plan credits are applied automatically."})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-6 sm:gap-8",children:[o.jsx("div",{children:o.jsx("div",{className:"bg-card rounded-2xl border border-border p-5",children:e.ottorouter.configured&&e.ottorouter.publicKey?o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-500/10 border border-green-500/20 rounded-lg",children:[o.jsx(ro,{provider:"ottorouter",size:16}),o.jsx("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:"Setu"}),o.jsx("span",{className:"text-xs text-green-600/60 dark:text-green-500/60 ml-auto",children:"Default Provider"})]}),o.jsx("div",{className:"flex justify-center py-4 mt-4",children:o.jsx("div",{className:"bg-white p-2 rounded-lg",children:o.jsx(hi,{value:e.ottorouter.publicKey,size:140,level:"M"})})}),o.jsxs("div",{className:"space-y-2 mt-4",children:[o.jsxs("button",{type:"button",onClick:CA,className:"w-full flex items-center justify-center gap-2 px-3 py-2 bg-muted hover:bg-muted/80 rounded-lg text-xs font-mono text-muted-foreground transition-colors",children:[uA(e.ottorouter.publicKey),G?o.jsx(zt,{className:"w-3.5 h-3.5 text-green-500"}):o.jsx(ws,{className:"w-3.5 h-3.5 text-muted-foreground"})]}),o.jsxs("div",{className:"space-y-1.5 px-3 py-2 bg-muted/50 rounded-lg",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("div",{className:"flex items-center gap-1.5 min-w-0",children:o.jsx("span",{className:"font-mono text-xs sm:text-sm text-foreground truncate",children:SA})}),o.jsx("button",{type:"button",onClick:JA,disabled:re,className:"p-0.5 text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:o.jsx(Xt,{className:`w-3 h-3 ${re?"animate-spin":""}`})})]}),o.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:["Balance $",(Ae??0).toFixed(2)," • On-chain"," ",(ie??0).toFixed(2)," USDC"]})]})]}),o.jsxs("div",{className:"flex items-center gap-4 py-4",children:[o.jsx("div",{className:"flex-1 h-px bg-border"}),o.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"OR"}),o.jsx("div",{className:"flex-1 h-px bg-border"})]}),o.jsxs("button",{type:"button",onClick:B,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:bg-primary/90 transition-colors",children:[o.jsx(zn,{className:"w-4 h-4"}),"Top Up with Card"]}),o.jsxs("button",{type:"button",onClick:it,className:"w-full mt-2 flex items-center justify-center gap-2 px-4 py-2.5 border border-border text-foreground rounded-lg text-sm font-medium hover:bg-muted/50 transition-colors",children:[o.jsx(dr,{className:"w-4 h-4"}),"Import Wallet"]})]}):o.jsx("div",{className:"flex items-center justify-center py-16",children:o.jsx(Te,{className:"w-8 h-8 animate-spin text-muted-foreground"})})})}),o.jsxs("div",{className:"sm:col-span-2 space-y-6",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h2",{className:"font-semibold text-foreground",children:"Connected Providers"}),dt.length>0&&o.jsxs("span",{className:"text-sm text-muted-foreground",children:[dt.length," active"]})]}),dt.length===0?o.jsx("div",{className:"text-sm text-muted-foreground py-4",children:"No providers connected yet. Add one below."}):o.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(([QA,Ue])=>o.jsxs("div",{className:`flex items-center gap-2 pl-3 pr-2 py-2 rounded-full transition-all duration-200 ${k===QA?"bg-destructive/10 border border-destructive/30":"group bg-green-500/10 border border-green-500/20"}`,children:[o.jsx(ro,{provider:QA,size:16}),o.jsx("span",{className:`text-sm font-medium transition-colors ${k===QA?"text-destructive":"text-green-600 dark:text-green-400"}`,children:Ue.label}),k!==QA&&o.jsx("span",{className:"text-xs text-green-600/60 dark:text-green-500/60",children:Ue.type==="oauth"?"OAuth":"API"}),k===QA?o.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[o.jsx("span",{className:"text-xs text-destructive/80 mr-1",children:"Remove?"}),o.jsx("button",{type:"button",onClick:()=>Ce(QA),disabled:P===QA,className:"px-2 py-0.5 text-xs bg-destructive text-destructive-foreground rounded hover:bg-destructive/90 transition-colors disabled:opacity-50",children:P===QA?o.jsx(Te,{className:"w-3 h-3 animate-spin"}):"Yes"}),o.jsx("button",{type:"button",onClick:Ie,className:"px-2 py-0.5 text-xs bg-muted text-muted-foreground rounded hover:bg-muted/80 transition-colors",children:"No"})]}):QA!=="ottorouter"&&o.jsx("button",{type:"button",onClick:()=>Ce(QA),className:"ml-1 p-1 text-green-600/40 dark:text-green-500/40 hover:text-green-600/80 dark:hover:text-green-500/80 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(et,{className:"w-3 h-3"})})]},QA))})]}),o.jsxs("div",{children:[o.jsx("h2",{className:"font-semibold text-foreground mb-4",children:"Add Providers"}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 items-start",children:[yt.map(([QA,Ue])=>o.jsx("div",{children:b===QA?o.jsxs("div",{className:"flex items-center gap-2 p-3 bg-card border border-ring rounded-xl overflow-hidden",children:[o.jsx("div",{className:"shrink-0",children:o.jsx(ro,{provider:QA,size:18})}),o.jsx("input",{ref:ne,type:"password",value:H,onChange:mt=>v(mt.target.value),placeholder:`${Ue.label} API key...`,className:"flex-1 min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground text-foreground",onKeyDown:mt=>{mt.key==="Enter"&&mA(QA),mt.key==="Escape"&&(J(null),v(""))}}),o.jsx("button",{type:"button",onClick:()=>mA(QA),disabled:!H.trim(),className:"shrink-0 px-3 py-1.5 bg-primary text-primary-foreground text-sm font-medium rounded-lg disabled:opacity-50",children:"Add"}),o.jsx("button",{type:"button",onClick:()=>{J(null),v("")},className:"shrink-0 p-1.5 text-muted-foreground hover:text-foreground",children:o.jsx(et,{className:"w-4 h-4"})})]}):o.jsxs("div",{className:"flex items-center justify-between p-3 bg-card border border-border hover:border-border/80 rounded-xl transition-colors gap-2",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx(ro,{provider:QA,size:20}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"font-medium text-foreground truncate",children:Ue.label}),o.jsxs("div",{className:"text-xs text-muted-foreground",children:[Ue.modelCount," models"]})]})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[QA!=="copilot"&&o.jsxs("button",{type:"button",onClick:()=>J(QA),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors",children:[o.jsx(dr,{className:"w-3.5 h-3.5"}),"API"]}),Ue.supportsOAuth&&o.jsxs("button",{type:"button",onClick:()=>eA(QA,QA==="anthropic"?"max":void 0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors",children:[o.jsx(Gt,{className:"w-3.5 h-3.5"}),QA==="anthropic"?"Pro":QA==="copilot"?"Login":"OAuth"]})]})]})},QA)),o.jsxs("button",{type:"button",onClick:()=>C(!0),className:"group flex items-center justify-between p-3 bg-card border border-dashed border-border hover:border-primary/60 hover:bg-primary/5 hover:shadow-sm rounded-xl transition-all gap-2 text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full bg-muted text-muted-foreground group-hover:bg-primary/10 group-hover:text-primary transition-colors",children:o.jsx(Bo,{className:"w-3.5 h-3.5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"font-medium text-foreground truncate",children:"Custom Provider"}),o.jsx("div",{className:"text-xs text-muted-foreground group-hover:text-foreground/70 transition-colors",children:"OpenAI-compatible or Ollama endpoint"})]})]}),o.jsxs("span",{className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground group-hover:text-primary group-hover:bg-primary/10 rounded-lg transition-colors",children:[o.jsx(dr,{className:"w-3.5 h-3.5"}),"Add"]})]})]})]})]})]})]})}),o.jsx("div",{className:"fixed bottom-0 left-0 right-0 px-4 sm:px-6 py-4 border-t border-border bg-background",children:o.jsxs("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:[!E&&o.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground hidden sm:block",children:"You can add more providers later in settings"}),E?o.jsx("button",{type:"button",onClick:c,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors ml-auto",children:"Done"}):o.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors",children:["Continue",o.jsx(cB,{className:"w-4 h-4"})]})]})}),K&&o.jsx("div",{"data-otto-nested-modal":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm",children:o.jsxs("div",{className:"bg-background border border-border rounded-xl w-full max-w-2xl mx-6 shadow-2xl max-h-[90vh] overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center gap-3 p-6 border-b border-border",children:[o.jsx("span",{className:"inline-flex items-center justify-center w-6 h-6 rounded-full bg-muted text-muted-foreground",children:o.jsx(Bo,{className:"w-4 h-4"})}),o.jsx("h3",{className:"text-lg font-semibold",children:"Add Custom Provider"})]}),o.jsxs("div",{className:"p-6 space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("label",{className:"space-y-2",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Provider ID"}),o.jsx("input",{type:"text",value:p,onChange:QA=>L(QA.target.value),placeholder:"my-provider",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors font-mono text-sm"})]}),o.jsxs("label",{className:"space-y-2",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Display Name"}),o.jsx("input",{type:"text",value:S,onChange:QA=>$(QA.target.value),placeholder:"My Provider",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors text-sm"})]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-3 p-3 bg-muted/30 border border-border rounded-lg",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-foreground",children:"Fetch models from provider"}),o.jsx("div",{className:"text-xs text-muted-foreground",children:"For Ollama, this reads /api/tags and /api/show to include context windows."})]}),o.jsxs("button",{type:"button",onClick:MA,disabled:!AA.trim()||Ke,className:"shrink-0 px-3 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 flex items-center gap-2",children:[Ke&&o.jsx(Te,{className:"w-3.5 h-3.5 animate-spin"}),"Fetch Models"]})]}),he&&o.jsx("p",{className:"text-xs text-muted-foreground",children:he}),Le.length>0&&o.jsx("div",{className:"space-y-2 max-h-44 overflow-y-auto border border-border rounded-lg p-2",children:Le.map(QA=>o.jsxs("div",{className:"flex items-center justify-between gap-3 p-2 bg-card rounded-md",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:QA.label}),o.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate",children:QA.id})]}),o.jsxs("div",{className:"flex flex-wrap justify-end gap-1 shrink-0",children:[QA.contextWindow&&o.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-blue-600/20 text-blue-400 rounded",children:[_Q(QA.contextWindow)," ctx"]}),QA.maxOutputTokens&&o.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-cyan-600/20 text-cyan-400 rounded",children:[_Q(QA.maxOutputTokens)," out"]}),QA.toolCall&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-600/20 text-green-400 rounded",children:"Tools"}),QA.reasoningText&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-purple-600/20 text-purple-400 rounded",children:"Reasoning"}),QA.vision&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-orange-600/20 text-orange-400 rounded",children:"Vision"})]})]},QA.id))}),o.jsxs("label",{className:"space-y-2 block",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Base URL"}),o.jsx("input",{type:"url",value:AA,onChange:QA=>sA(QA.target.value),placeholder:"https://api.example.com/v1",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors font-mono text-sm"})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("label",{className:"space-y-2",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"API Key"}),o.jsx("input",{type:"password",value:oA,onChange:QA=>bA(QA.target.value),placeholder:"Optional",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors font-mono text-sm"})]}),o.jsxs("label",{className:"space-y-2",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Compatibility"}),o.jsx("select",{value:jA,onChange:QA=>HA(QA.target.value),className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground outline-none focus:border-foreground/30 transition-colors text-sm",children:bk.map(QA=>o.jsx("option",{value:QA.value,children:QA.label},QA.value))})]})]}),o.jsxs("label",{className:"space-y-2 block",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Models"}),o.jsx("textarea",{value:GA,onChange:QA=>lA(QA.target.value),placeholder:"gpt-4o, claude-sonnet-4-5, llama3.3",className:"w-full min-h-[90px] px-4 py-3 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors font-mono text-sm resize-y"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:"Comma or newline separated. Leave blank to allow any model."})]}),o.jsxs("label",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[o.jsx("input",{type:"checkbox",checked:ce,onChange:QA=>NA(QA.target.checked),className:"h-4 w-4 accent-primary"}),"Allow entering model IDs not listed above"]}),He&&o.jsx("p",{className:"text-sm text-red-500",children:He}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx("button",{type:"button",onClick:pA,disabled:_A,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors disabled:opacity-50",children:"Cancel"}),o.jsx("button",{type:"button",onClick:te,disabled:!p.trim()||!AA.trim()||_A,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:_A?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):"Add Provider"})]})]})]})}),U&&o.jsx("div",{"data-otto-nested-modal":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm",children:o.jsxs("div",{className:"bg-background border border-border rounded-xl w-full max-w-lg mx-6 shadow-2xl",children:[o.jsxs("div",{className:"flex items-center gap-3 p-6 border-b border-border",children:[o.jsx(ro,{provider:"ottorouter",size:24}),o.jsx("h3",{className:"text-lg font-semibold",children:"Import Setu Wallet"})]}),o.jsxs("div",{className:"p-6",children:[o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Paste your base58 private key to replace the current wallet used for Setu."}),o.jsx("textarea",{ref:LA,value:j,onChange:QA=>Y(QA.target.value),placeholder:"Enter private key",className:"w-full min-h-[110px] px-4 py-3 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors font-mono text-xs resize-y",onKeyDown:QA=>{(QA.metaKey||QA.ctrlKey)&&QA.key==="Enter"&&(QA.preventDefault(),ct()),QA.key==="Escape"&&st()}}),I&&o.jsx("p",{className:"text-sm text-red-500 mt-3",children:I}),o.jsxs("div",{className:"flex gap-3 mt-5",children:[o.jsx("button",{type:"button",onClick:st,disabled:x,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors disabled:opacity-50",children:"Cancel"}),o.jsx("button",{type:"button",onClick:ct,disabled:!j.trim()||x,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:x?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):"Import Wallet"})]})]})]})}),tA&&o.jsx("div",{"data-otto-nested-modal":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm",children:o.jsxs("div",{className:"bg-background border border-border rounded-xl w-full max-w-lg mx-6 shadow-2xl",children:[o.jsxs("div",{className:"flex items-center gap-3 p-6 border-b border-border",children:[o.jsx(ro,{provider:tA.provider,size:24}),o.jsxs("h3",{className:"text-lg font-semibold",children:["Connect"," ",e.providers[tA.provider]?.label||tA.provider]})]}),tA.sessionId?o.jsxs("div",{className:"p-6",children:[o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Paste the authorization code:"}),o.jsx("input",{type:"text",ref:ee,value:EA,onChange:QA=>ZA(QA.target.value),placeholder:"Paste code here...",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors mb-4 font-mono text-sm",onKeyDown:QA=>{QA.key==="Enter"&&Ge(),QA.key==="Escape"&&Me()}}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{type:"button",onClick:Me,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors",children:"Cancel"}),o.jsx("button",{type:"button",onClick:Ge,disabled:!EA.trim()||VA,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:VA?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):"Connect"})]})]}):o.jsxs("div",{className:"p-6",children:[o.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["You'll be redirected to"," ",e.providers[tA.provider]?.label||tA.provider," ","to authorize access. After authorizing, copy the code and return here."]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{type:"button",onClick:Me,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors",children:"Cancel"}),o.jsx("button",{type:"button",onClick:xe,disabled:ke,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:ke?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:["Continue",o.jsx(Gt,{className:"w-4 h-4"})]})})]})]})]})}),rA&&o.jsx("div",{"data-otto-nested-modal":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm",children:o.jsxs("div",{className:"bg-background border border-border rounded-xl w-full max-w-lg mx-6 shadow-2xl",children:[o.jsxs("div",{className:"flex items-center gap-3 p-6 border-b border-border",children:[o.jsx(ro,{provider:"copilot",size:24}),o.jsx("h3",{className:"text-lg font-semibold",children:"Connect GitHub Copilot"})]}),o.jsxs("div",{className:"p-6 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>be("oauth"),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${ve==="oauth"?"bg-foreground text-background":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"OAuth"}),o.jsx("button",{type:"button",onClick:()=>be("token"),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${ve==="token"?"bg-foreground text-background":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"Token"})]}),ve==="oauth"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter this code on GitHub to authorize:"}),o.jsx("div",{className:"flex items-center justify-center gap-3",children:yA?o.jsx("div",{className:"bg-muted px-6 py-3 rounded-lg animate-pulse",children:o.jsx("div",{className:"h-9 w-48 bg-muted-foreground/20 rounded"})}):ye?o.jsxs(o.Fragment,{children:[o.jsx("code",{className:"text-3xl font-mono font-bold tracking-widest text-foreground bg-muted px-6 py-3 rounded-lg select-all",children:ye.userCode}),o.jsx("button",{type:"button",onClick:Ve,className:"p-2 text-muted-foreground hover:text-foreground transition-colors",children:V?o.jsx(zt,{className:"w-5 h-5 text-green-500"}):o.jsx(ws,{className:"w-5 h-5"})})]}):null})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"Paste a GitHub token with Copilot model access."}),o.jsx("input",{type:"password",value:Oe,onChange:QA=>ze(QA.target.value),placeholder:"gho_...",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors"}),F?.ghImport.available&&o.jsx("button",{type:"button",onClick:lt,disabled:se,className:"w-full h-10 px-4 bg-muted text-foreground rounded-lg font-medium hover:bg-muted/80 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:se?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):"Import from GH CLI"}),F?.ghImport.available&&!F.ghImport.authenticated&&o.jsx("p",{className:"text-xs text-muted-foreground",children:F.ghImport.reason||"GitHub CLI is not authenticated"}),F&&!F.ghImport.available&&F.ghImport.reason&&o.jsx("p",{className:"text-xs text-muted-foreground",children:F.ghImport.reason})]}),z&&z.tokenSources.length>0&&o.jsx("div",{className:"text-xs text-muted-foreground space-y-1",children:z.tokenSources.map(QA=>o.jsxs("div",{children:[QA.source,":"," ",QA.configured?QA.error?QA.error:`${QA.modelCount??0} models visible`:"not configured",QA.restrictedByOrgPolicy&&QA.restrictedOrg?` (org restriction: ${QA.restrictedOrg})`:""]},QA.source))}),To&&o.jsx("p",{className:"text-sm text-red-500 text-center",children:To}),Je&&ve==="oauth"&&o.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[o.jsx(Te,{className:"w-4 h-4 animate-spin"}),"Waiting for authorization..."]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{type:"button",onClick:tt,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors",children:"Cancel"}),ve==="oauth"?o.jsx("button",{type:"button",onClick:pe,disabled:Je||yA,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:Je||yA?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:["Open GitHub",o.jsx(Gt,{className:"w-4 h-4"})]})}):o.jsx("button",{type:"button",onClick:Se,disabled:!Oe.trim()||co,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:co?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):"Save token"})]})]})]})})]})}),vk=m.memo(function({authStatus:e,onComplete:t,onBack:s,hideHeader:n=!1}){const[r,i]=m.useState(null),[a,g]=m.useState(null),[Q,B]=m.useState(!0),[u,E]=m.useState(!1),[c,h]=m.useState("ottorouter"),[f,d]=m.useState("kimi-k2.5"),[D,R]=m.useState(e.defaults.agent||"build"),[M,q]=m.useState(e.defaults.toolApproval||"dangerous"),[G,T]=m.useState(!1),Z=m.useRef(!1),X=m.useId(),U=m.useId(),O=m.useId(),j=m.useId();m.useEffect(()=>{(async()=>{try{const[y,b]=await Promise.all([fA.getConfig(),fA.getAllModels()]);i(y),g(b);const J=y?.defaults?.provider||"ottorouter",H=y?.defaults?.model||"kimi-k2.5",v=b?.[J]?.models?.length>0,K=v?J:"ottorouter",C=v&&b[J].models.some(p=>p.id===H)?H:b?.[K]?.models?.[0]?.id||"kimi-k2.5";h(K),d(C),y?.defaults?.agent&&R(y.defaults.agent),y?.defaults?.toolApproval&&q(y.defaults.toolApproval),y?.defaults?.guidedMode&&T(y.defaults.guidedMode)}catch{}finally{B(!1)}})()},[]),m.useEffect(()=>{if(r?.agents?.length){const I=r.agents;(!D||!I.includes(D))&&R(I.includes("build")?"build":I[0])}},[r,D]),m.useEffect(()=>{if(a?.[c]&&Z.current){const I=a[c];I.models.some(y=>y.id===f)||d(I.models[0]?.id||"")}},[c,a,f]);const Y=async()=>{E(!0);try{await fA.updateDefaults({provider:c,model:f,agent:D,toolApproval:M,guidedMode:G,fullWidthContent:r?.defaults?.fullWidthContent??!0,scope:"global"}),await t()}catch{}finally{E(!1)}};if(Q)return o.jsx("div",{className:"min-h-screen flex items-center justify-center",children:o.jsx(Te,{className:"w-8 h-8 animate-spin text-muted-foreground"})});const x=r?.providers.filter(I=>(e.providers[I]?.configured||I==="ottorouter")&&a?.[I]?.models?.length>0)||["ottorouter"],l=a?.[c]?.models||[];return o.jsxs("div",{className:"min-h-screen flex flex-col",children:[!n&&o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(ro,{provider:"ottorouter",size:24}),o.jsx("span",{className:"font-semibold text-foreground",children:"otto"})]}),o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500"}),"Step 2 of 2"]})]}),o.jsx("div",{className:`flex-1 px-4 sm:px-6 lg:px-12 pb-32 ${n?"pt-8 sm:pt-10 lg:pt-14":"pt-6 sm:pt-8 lg:pt-12"}`,children:o.jsxs("div",{className:"max-w-7xl mx-auto",children:[o.jsxs("div",{className:"mb-10",children:[o.jsx("h1",{className:"text-3xl lg:text-4xl font-semibold text-foreground mb-3",children:"Configure Defaults"}),o.jsx("p",{className:"text-lg text-muted-foreground",children:"Set your preferences. You can change these anytime in settings."})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"md:col-span-2",children:[o.jsx("label",{htmlFor:X,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Provider"}),o.jsxs("div",{className:"relative",children:[o.jsx("select",{id:X,value:c,onChange:I=>{Z.current=!0,h(I.target.value)},className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:x.map(I=>o.jsx("option",{value:I,children:e.providers[I]?.label||I},I))}),o.jsx(Mt,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),o.jsxs("div",{className:"md:col-span-2",children:[o.jsx("label",{htmlFor:U,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Model"}),o.jsxs("div",{className:"relative",children:[o.jsx("select",{id:U,value:f,onChange:I=>d(I.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:l.map(I=>o.jsx("option",{value:I.id,children:I.label||I.id},I.id))}),o.jsx(Mt,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:O,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Agent"}),o.jsxs("div",{className:"relative",children:[o.jsx("select",{id:O,value:D,onChange:I=>R(I.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:(r?.agents||["build"]).map(I=>o.jsx("option",{value:I,children:I},I))}),o.jsx(Mt,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:j,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Tool Approval"}),o.jsxs("div",{className:"relative",children:[o.jsxs("select",{id:j,value:M,onChange:I=>q(I.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:[o.jsx("option",{value:"auto",children:"Auto - run without asking"}),o.jsx("option",{value:"dangerous",children:"Dangerous - approve writes only"}),o.jsx("option",{value:"yolo",children:"YOLO - skip approvals except hard safety blocks"}),o.jsx("option",{value:"all",children:"All - approve every tool"})]}),o.jsx(Mt,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]}),o.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Controls when tool executions need approval. YOLO still blocks extreme destructive commands."})]}),o.jsx("div",{className:"md:col-span-2",children:o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-card border border-border rounded-xl",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Guided Mode"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"AI will run commands and manage services for you instead of giving instructions"})]}),o.jsx("button",{type:"button",role:"switch","aria-checked":G,onClick:()=>T(!G),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 ${G?"bg-primary":"bg-muted"}`,children:o.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${G?"translate-x-6":"translate-x-1"} ${G?"bg-primary-foreground":"bg-foreground"}`})})]})})]})]})}),o.jsx("div",{className:"fixed bottom-0 left-0 right-0 px-4 sm:px-6 py-4 border-t border-border bg-background",children:o.jsxs("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:[o.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-2 px-4 py-3 text-muted-foreground hover:text-foreground transition-colors",children:[o.jsx(au,{className:"w-4 h-4"}),"Back"]}),o.jsx("button",{type:"button",onClick:Y,disabled:u,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors disabled:opacity-50",children:u?o.jsxs(o.Fragment,{children:[o.jsx(Te,{className:"w-4 h-4 animate-spin"}),"Setting up..."]}):o.jsxs(o.Fragment,{children:["Start Using otto",o.jsx(Zt,{className:"w-4 h-4"})]})})]})})]})}),Gk=m.memo(function({hideHeader:e=!1,style:t}){const s=kt(O=>O.isOpen),n=kt(O=>O.currentStep),r=kt(O=>O.manageMode),i=kt(O=>O.authStatus),a=kt(O=>O.nextStep),g=kt(O=>O.prevStep),Q=kt(O=>O.reset),B=Ne(O=>O.openTopupModal),{setupWallet:u,importWallet:E,addProvider:c,addCustomProvider:h,removeProvider:f,completeOnboarding:d,startOAuth:D,startOAuthManual:R,exchangeOAuthCode:M,startCopilotDeviceFlow:q,pollCopilotDeviceFlow:G,getCopilotAuthMethods:T,saveCopilotToken:Z,importCopilotTokenFromGh:X,getCopilotDiagnostics:U}=Zg();return m.useEffect(()=>{if(!s)return;const O=j=>{const Y=j;!Y.detail||Y.detail.handled||document.querySelector('[data-otto-nested-modal="true"]')||(Y.detail.handled=!0,j.preventDefault(),Q())};return window.addEventListener("otto:native-back",O),()=>window.removeEventListener("otto:native-back",O)},[s,Q]),!s||!i?null:o.jsxs("div",{className:"fixed inset-0 z-[9999] bg-background text-foreground overflow-y-auto",style:t,children:[n==="wallet"&&o.jsx(Fk,{authStatus:i,onSetupWallet:u,onImportWallet:E,onAddProvider:c,onAddCustomProvider:h,onRemoveProvider:f,onStartOAuth:D,onStartOAuthManual:R,onExchangeOAuthCode:M,onOpenTopup:B,onNext:a,manageMode:r,onClose:Q,hideHeader:e,onStartCopilotDeviceFlow:q,onPollCopilotDeviceFlow:G,onGetCopilotAuthMethods:T,onSaveCopilotToken:Z,onImportCopilotTokenFromGh:X,onGetCopilotDiagnostics:U}),n==="defaults"&&o.jsx(vk,{authStatus:i,onComplete:d,onBack:g,hideHeader:e})]})});function ZQ(A){return A==="success"?"success":A==="error"?"error":"default"}function Xg(A){return A.action?.href??(A.sessionId?`/sessions/${encodeURIComponent(A.sessionId)}`:void 0)}function Pa(A){const e=Xg(A);if(!(!e||typeof window>"u")&&!(A.sessionId&&tp(A.sessionId))){if(e.startsWith("/")){window.location.href=e;return}Io(e)}}function Sk(){return new Promise(A=>{let e=!1;const t=s=>{e||(e=!0,setTimeout(()=>A(s??Notification.permission),100))};try{const s=Notification.requestPermission(t);s&&typeof s.then=="function"&&s.then(t).catch(()=>t())}catch{t()}setTimeout(()=>t(),1500)})}function Uk(A){const e=A.body?`${A.title}: ${A.body}`:A.title;if(Xg(A)){const s=ge(e,ZQ(A.level),6e3);eo.getState().updateToast(s,{activateActionOnClick:!0,action:A.action?{...A.action,onClick:()=>Pa(A)}:{label:"Open session",onClick:()=>Pa(A)}});return}ge(e,ZQ(A.level),5e3)}function Rk(A){if(typeof window>"u")return!1;if($0(A))return!0;if(window.parent&&window.parent!==window){const t={type:"otto-notification",notification:A};return window.parent.postMessage(t,"*"),!0}if(!("Notification"in window)||Notification.permission!=="granted")return!1;const e=new Notification(A.title,{body:A.body,tag:A.id,data:{href:Xg(A)}});return e.onclick=()=>{window.focus(),Pa(A),e.close()},!0}function Kk(A,e){A.setQueryData(lo,t=>t&&{...t,pages:t.pages.map(s=>({...s,items:s.items.map(n=>n.id===e.sessionId?{...n,isRunning:e.status==="running"}:n)}))})}function Lk(A){try{const{hostname:e}=new URL(A);return e==="localhost"||e==="127.0.0.1"||e.startsWith("192.168.")||e.startsWith("10.")||/^172\.(1[6-9]|2\d|3[01])\./.test(e)}catch{return!1}}async function XQ(A){const e=await fetch(new URL("/openapi.json",A),{cache:"no-store",credentials:"include"});if(!e.ok)throw new Error(`Local API returned ${e.status}`)}const En=new Map,ra=new Set;function dC(A){return`otto-local-access-confirmed:${A}`}function Jk(A){try{return window.localStorage.getItem(dC(A))==="1"}catch{return!1}}function $Q(A){try{window.localStorage.setItem(dC(A),"1")}catch{}}async function Tk(A){if(op()||!Lk(A)||Jk(A)||En.has(A)||ra.has(A))return;ra.add(A);try{await XQ(A),$Q(A);return}catch{}finally{ra.delete(A)}if(En.has(A))return;const e=ge("Safari may need permission to access the local otto server.","default",0);En.set(A,e),eo.getState().updateToast(e,{action:{label:"Allow access",onClick:async()=>{await XQ(A),$Q(A),eo.getState().removeToast(e),En.delete(A),ge.success("Local otto server access confirmed.")}}})}function jk(A){const e=De(),t=m.useRef(A);return m.useEffect(()=>{t.current=A},[A]),m.useEffect(()=>{if(typeof window>"u"||window.parent!==window||!("Notification"in window)||Notification.permission!=="default"||window.localStorage.getItem("otto-notification-permission-prompted"))return;window.localStorage.setItem("otto-notification-permission-prompted","1");const s=ge("Enable browser notifications for background session updates.","default",0);eo.getState().updateToast(s,{action:{label:"Enable",onClick:async()=>{const n=await Sk(),r=Notification.permission;n==="granted"||r==="granted"?ge.success("Browser notifications enabled."):ge.info("Browser notifications were not enabled.")}}})},[]),m.useEffect(()=>{const s=new AbortController,n=Nr();return E0({baseUrl:n,onEvent:r=>{if(r.event==="heartbeat")return;let i;try{i=JSON.parse(r.data)}catch(a){console.error("[client-events] Failed to parse event:",a);return}if(r.event==="session.status"){const a=i;Kk(e,a),a.status!=="running"&&e.invalidateQueries({queryKey:lo});return}if(r.event==="notification"){const a=i,g=a.sessionId===t.current&&document.visibilityState==="visible",Q=a.source==="session"||!!a.sessionId;let B=!1;g||(B=Rk(a)),(!Q||!B&&!g)&&Uk(a)}},onError:r=>{s.signal.aborted||(console.error("[client-events] Stream error:",r),Tk(n))}},s.signal),()=>s.abort()},[e]),VB({baseUrl:Nr()})}const hC="otto-theme";function Ok(){if(typeof window>"u")return"dark";const A=window.localStorage.getItem(hC);return A==="light"||A==="dark"?A:window.matchMedia?.("(prefers-color-scheme: light)").matches?"light":"dark"}function qk(){const[A,e]=m.useState(()=>Ok());m.useEffect(()=>{if(typeof document>"u")return;const s=document.documentElement;A==="dark"?s.classList.add("dark"):s.classList.remove("dark");try{window.localStorage.setItem(hC,A)}catch(n){console.warn("Failed to persist theme preference",n)}window.parent&&window.parent!==window&&window.parent.postMessage({type:"otto-set-theme",theme:A},"*")},[A]),m.useEffect(()=>{if(typeof window>"u")return;const s=n=>{n.data?.type==="otto-set-theme"&&(n.data.theme==="light"||n.data.theme==="dark")&&e(n.data.theme)};return window.addEventListener("message",s),()=>window.removeEventListener("message",s)},[]);const t=m.useCallback(()=>{e(s=>s==="dark"?"light":"dark")},[]);return m.useMemo(()=>({theme:A,setTheme:e,toggleTheme:t}),[A,t])}function Yk(){const[A,e]=m.useState(null);return m.useEffect(()=>{(async()=>{try{const s=await Ud({baseURL:Nr()});if(s.error)throw new Error(JSON.stringify(s.error));const n=s.data;console.log("[useWorkingDirectory] Success:",n),n.dirName&&(console.log("[useWorkingDirectory] Setting title to:",n.dirName),e(n.dirName),document.title=n.dirName)}catch(s){console.error("[useWorkingDirectory] Error:",s),document.title="otto"}})()},[]),A}const Wa=gt()(rc(A=>({isCollapsed:!1,toggleCollapse:()=>A(e=>({isCollapsed:!e.isCollapsed})),setCollapsed:e=>A({isCollapsed:e})}),{name:"sidebar-storage"}));function Hk({sessionIds:A,activeSessionId:e,gitFiles:t,onSelectSession:s,onNewSession:n,onStageFile:r,onUnstageFile:i,onRestoreFile:a,onDeleteFile:g,onStageAll:Q,onUnstageAll:B,onOpenCommitModal:u,onViewDiff:E,onReturnToInput:c}){const{currentFocus:h,sessionIndex:f,gitFileIndex:d,setFocus:D,setSessionIndex:R,setGitFileIndex:M,resetGitFileIndex:q}=_g(),{setCollapsed:G,toggleCollapse:T}=Wa(),{isExpanded:Z,toggleSidebar:X}=Ye(),U=Ye(v=>v.closeDiff),O=At(v=>v.toggleSidebar),j=$e(v=>v.toggleSidebar),Y=Re(v=>v.toggleSidebar),x=Ze(v=>v.toggleSidebar),l=Pe(v=>v.toggleSidebar),I=Dt(v=>v.toggleSidebar),y=ft(v=>v.toggleSidebar),b=so(v=>v.togglePanel),J=A.indexOf(e||""),H=m.useCallback(v=>{const K=v.target,C=K.tagName==="INPUT"||K.tagName==="TEXTAREA"||K.isContentEditable,p=!!K.closest("[data-terminal-viewer]");if((v.ctrlKey||v.metaKey)&&!v.shiftKey&&!v.altKey&&v.key>="1"&&v.key<="7"){switch(v.preventDefault(),v.key){case"1":X(),Z&&h==="git"?D("input"):(D("git"),q());break;case"2":O(),D("input");break;case"3":j(),D("input");break;case"4":Y(),D("input");break;case"5":x(),D("input");break;case"6":l(),D("input");break;case"7":I(),D("input");break}return}if((v.ctrlKey||v.metaKey)&&v.key==="h"){v.preventDefault(),h==="sessions"?(document.activeElement?.blur(),D("input"),G(!0),setTimeout(()=>c?.(),50)):h==="git"?(document.activeElement?.blur(),D("input"),X(),U(),setTimeout(()=>c?.(),50)):(document.activeElement?.blur(),D("sessions"),G(!1),J>=0&&R(J));return}if((v.ctrlKey||v.metaKey)&&v.key==="l"){v.preventDefault(),h==="git"?(document.activeElement?.blur(),D("input"),X(),U(),setTimeout(()=>c?.(),50)):h==="sessions"?(document.activeElement?.blur(),D("input"),G(!0),setTimeout(()=>c?.(),50)):(document.activeElement?.blur(),Z||X(),D("git"),q());return}if((v.ctrlKey||v.metaKey)&&v.key==="/"){v.preventDefault(),T();return}if((v.ctrlKey||v.metaKey)&&v.key==="\\"){v.preventDefault(),X();return}if((v.ctrlKey||v.metaKey)&&v.key==="j"){v.preventDefault(),b();return}if((v.ctrlKey||v.metaKey)&&v.shiftKey&&v.key==="r"){v.preventDefault(),y();return}if((v.ctrlKey||v.metaKey)&&v.key==="n"){v.preventDefault(),n();return}if((v.ctrlKey||v.metaKey)&&v.key==="p"){v.preventDefault(),Ha.getState().toggle();return}if(v.key==="Escape"&&!p||v.key==="q"&&!C&&(h==="sessions"||h==="git")){v.preventDefault(),h==="sessions"?G(!0):h==="git"&&(X(),U()),D("input"),c?.();return}if(h==="sessions"&&!C){if(v.key==="j"&&A.length>0){v.preventDefault();const S=Math.min(f+1,A.length-1);R(S);return}if(v.key==="k"&&A.length>0){v.preventDefault();const S=Math.max(f-1,0);R(S);return}if(v.key==="Enter"&&A[f]){v.preventDefault(),s(A[f]),D("input");return}}if(h==="git"&&!C){if(v.key==="j"&&t.length>0){v.preventDefault();const S=Math.min(d+1,t.length-1);M(S);return}if(v.key==="k"&&t.length>0){v.preventDefault();const S=Math.max(d-1,0);M(S);return}if(v.key===" "&&t[d]){v.preventDefault();const S=t[d];S.staged?i?.(S.path):r?.(S.path);return}if(v.key==="a"){v.preventDefault(),Q?.();return}if(v.key==="u"){v.preventDefault(),B?.();return}if(v.key==="R"&&t[d]){v.preventDefault();const S=t[d];!S.staged&&S.status!=="untracked"&&S.status!=="added"&&a?.(S.path);return}if(v.shiftKey&&v.key==="D"||v.key==="Backspace"){v.preventDefault();const S=t[d];S&&!S.staged&&S.status==="untracked"&&g?.(S.path);return}if(v.key==="c"){v.preventDefault(),u?.();return}if(v.key==="Enter"&&t[d]){v.preventDefault();const S=t[d];E?.(S.path,S.staged);return}}},[h,f,d,A,t,J,Z,D,R,M,q,G,X,O,j,Y,x,l,I,b,y,T,s,n,r,i,a,g,Q,B,u,E,c,U]);return m.useEffect(()=>(window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)),[H]),{currentFocus:h,sessionIndex:f,gitFileIndex:d}}function Pk(A){const e=m.useRef(null),t=m.useRef(null),s=Ne(Q=>Q.setBalance),n=Ne(Q=>Q.setPaymentPending),r=eo(Q=>Q.removeToast),i=eo(Q=>Q.updateToast),a=qn(Q=>Q.setPendingTopup),g=qn(Q=>Q.clearPendingTopup);m.useEffect(()=>{if(!A)return;const Q=new XE;e.current=Q;const B=fA.getStreamUrl(A);Q.connect(B);const u=Q.on("*",E=>{const c=E.payload;switch(E.type){case"ottorouter.topup.required":{const h=typeof c?.amountUsd=="number"?c.amountUsd:0,f=typeof c?.currentBalance=="number"?c.currentBalance:0,d=typeof c?.minTopupUsd=="number"?c.minTopupUsd:5,D=typeof c?.suggestedTopupUsd=="number"?c.suggestedTopupUsd:10,R=typeof c?.messageId=="string"?c.messageId:"";a({sessionId:A,messageId:R,amountUsd:h,currentBalance:f,minTopupUsd:d,suggestedTopupUsd:D});break}case"ottorouter.topup.method_selected":{c?.method==="crypto"&&(n(!0),t.current=ge.loading("💳 Processing crypto payment..."));break}case"ottorouter.topup.cancelled":{g();const h=typeof c?.reason=="string"?c.reason:"Request cancelled";ge(`⚠️ ${h}`);break}case"ottorouter.payment.required":{const h=typeof c?.amountUsd=="number"?c.amountUsd:0;n(!0),t.current||(t.current=ge.loading(`💳 Payment required: $${h.toFixed(2)}`));break}case"ottorouter.payment.signing":{t.current?i(t.current,{message:"✍️ Signing transaction..."}):t.current=ge.loading("✍️ Signing transaction...");break}case"ottorouter.payment.complete":{g();const h=c?.amountUsd,f=c?.newBalance,d=typeof c?.transactionId=="string"?c.transactionId:void 0,D=typeof h=="number"?h:typeof h=="string"?parseFloat(h):0,R=typeof f=="number"?f:typeof f=="string"?parseFloat(f):0;s(R),n(!1),t.current&&(r(t.current),t.current=null);const M=`✅ Paid $${D.toFixed(2)}`;d?ge.successWithAction(M,{label:"View Tx",href:`https://orbmarkets.io/tx/${d}`}):ge.success(M);break}case"ottorouter.fiat.checkout_created":{g(),n(!1),t.current&&(r(t.current),t.current=null),ge.success("💳 Complete payment, then retry your message");break}case"ottorouter.balance.updated":{const h=c?.balanceRemaining,f=typeof h=="number"?h:typeof h=="string"?parseFloat(h):null;f!==null&&!Number.isNaN(f)&&s(f);break}case"ottorouter.payment.error":{g();const h=typeof c?.error=="string"?c.error:"Payment failed";n(!1),t.current&&(r(t.current),t.current=null),ge.error(`❌ ${h}`);break}}});return()=>{u(),Q.disconnect()}},[A,s,n,r,i,a,g])}const pi=yC({component:Wk});function Wk(){const{checkOnboarding:A}=Zg();return m.useEffect(()=>{A()},[A]),o.jsxs(o.Fragment,{children:[o.jsx(NC,{}),o.jsx(Gk,{}),o.jsx(Vg,{}),null]})}const zk=Va("/")({beforeLoad:()=>{throw kC({to:"/sessions"})},component:()=>null});function AB({height:A=16,className:e=""}){const t=Math.round(A*2.4686468646864688);return o.jsx("svg",{width:t,height:A,viewBox:"0 0 748 303",fill:"currentColor",className:e,"aria-label":"otto",role:"img",children:o.jsx("path",{d:"M192.877 257.682C192.877 263.287 191.783 268.551 189.596 273.473C187.545 278.395 184.674 282.701 180.982 286.393C177.428 289.947 173.189 292.818 168.268 295.006C163.482 297.057 158.287 298.082 152.682 298.082H44.1953C38.7266 298.082 33.5312 297.057 28.6094 295.006C23.6875 292.818 19.3809 289.947 15.6895 286.393C12.1348 282.701 9.26367 278.395 7.07617 273.473C5.02539 268.551 4 263.287 4 257.682V120.074C4 114.469 5.02539 109.205 7.07617 104.283C9.26367 99.3613 12.1348 95.123 15.6895 91.5684C19.3809 87.877 23.6875 85.0059 28.6094 82.9551C33.5312 80.7676 38.7266 79.6738 44.1953 79.6738H152.682C158.287 79.6738 163.482 80.7676 168.268 82.9551C173.189 85.0059 177.428 87.877 180.982 91.5684C184.674 95.123 187.545 99.3613 189.596 104.283C191.783 109.205 192.877 114.469 192.877 120.074V257.682ZM44.1953 120.074V257.682H152.682V120.074H44.1953ZM331.715 4V298.082H289.674V46.041H239.225V4H331.715ZM478.961 4V298.082H436.92V46.041H386.471V4H478.961ZM743.717 257.682C743.717 263.287 742.623 268.551 740.436 273.473C738.385 278.395 735.514 282.701 731.822 286.393C728.268 289.947 724.029 292.818 719.107 295.006C714.322 297.057 709.127 298.082 703.521 298.082H595.035C589.566 298.082 584.371 297.057 579.449 295.006C574.527 292.818 570.221 289.947 566.529 286.393C562.975 282.701 560.104 278.395 557.916 273.473C555.865 268.551 554.84 263.287 554.84 257.682V120.074C554.84 114.469 555.865 109.205 557.916 104.283C560.104 99.3613 562.975 95.123 566.529 91.5684C570.221 87.877 574.527 85.0059 579.449 82.9551C584.371 80.7676 589.566 79.6738 595.035 79.6738H703.521C709.127 79.6738 714.322 80.7676 719.107 82.9551C724.029 85.0059 728.268 87.877 731.822 91.5684C735.514 95.123 738.385 99.3613 740.436 104.283C742.623 109.205 743.717 114.469 743.717 120.074V257.682ZM595.035 120.074V257.682H703.521V120.074H595.035Z"})})}const eB="left-sidebar",tB=272,Vk=256,_k=480,Zk=48,Xk=m.memo(function({children:e,onNewSession:t}){const s=Wa(a=>a.isCollapsed),n=Wa(a=>a.toggleCollapse),r=Xo(a=>a.widths[eB]??tB),i={"--sidebar-width":`${s?Zk:r}px`,"--expanded-sidebar-width":`${r}px`,maxWidth:"100%"};return m.useEffect(()=>(s?document.body.style.overflow="":document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[s]),o.jsxs(o.Fragment,{children:[o.jsx("aside",{className:`relative z-50 shrink-0 overflow-hidden border-r transition-[width,background-color,border-color] duration-300 ease-out fixed md:relative top-0 left-0 h-screen md:h-auto w-full md:w-[var(--sidebar-width)] ${s?"hidden md:flex border-border bg-background":"flex border-sidebar-border sidebar-fade-in"}`,style:i,children:s?o.jsxs("div",{className:"flex h-full w-12 flex-col",children:[o.jsx("div",{className:"h-12 border-b border-border flex items-center justify-center",children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:t,title:"New session",className:"h-8 w-8 rounded-md touch-manipulation text-muted-foreground hover:bg-muted/50",children:o.jsx(Bo,{className:"size-[18px]"})})}),o.jsx("button",{type:"button",className:"flex-1 cursor-pointer hover:bg-muted/50 transition-colors touch-manipulation",onClick:n,title:"Expand sidebar","aria-label":"Expand sidebar"}),o.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:n,title:"Expand sidebar",className:"h-8 w-8 transition-transform duration-200 hover:scale-110 touch-manipulation text-muted-foreground hover:bg-muted/50",children:o.jsx(Ut,{className:"size-[18px]"})})})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex h-full w-full md:w-[var(--expanded-sidebar-width)] flex-col min-w-0 relative",children:[o.jsxs("div",{className:"h-14 border-b border-sidebar-border px-4 flex items-center gap-2 md:hidden bg-sidebar",children:[o.jsx(fe,{variant:"ghost",size:"icon",onClick:n,title:"Close menu",className:"touch-manipulation flex-shrink-0 text-sidebar-foreground hover:bg-sidebar-accent","aria-label":"Close menu",children:o.jsx(et,{className:"w-5 h-5"})}),o.jsx("div",{className:"flex-1 flex items-center",children:o.jsx(AB,{height:14,className:"text-sidebar-foreground"})})]}),o.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[o.jsx("div",{className:"absolute top-0 left-0 right-0 z-10 pointer-events-none",children:o.jsxs("div",{className:"h-12 px-3 flex items-center justify-between border-b border-sidebar-border/40 bg-sidebar/40 backdrop-blur-xl supports-[backdrop-filter]:bg-sidebar/20",children:[o.jsx("div",{className:"flex items-center text-sidebar-foreground/90",children:o.jsx(AB,{height:14,className:"select-none"})}),o.jsx("button",{type:"button",onClick:t,className:"w-8 h-8 rounded-full bg-sidebar-primary flex items-center justify-center hover:opacity-90 transition-opacity touch-manipulation pointer-events-auto",title:"New session",children:o.jsx(Bo,{className:"w-4 h-4 text-sidebar-primary-foreground"})})]})}),o.jsx("div",{className:"absolute inset-0 overflow-hidden",children:e})]}),o.jsx("div",{className:"h-12 border-t border-sidebar-border px-2 flex items-center justify-end",children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:n,title:"Collapse sidebar",className:"transition-transform duration-200 hover:scale-110 touch-manipulation text-sidebar-muted-foreground hover:bg-sidebar-accent w-8 h-8",children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"transition-transform duration-300",role:"img","aria-label":"Collapse sidebar",children:[o.jsx("title",{children:"Collapse sidebar"}),o.jsx("path",{d:"M15 18l-6-6 6-6"})]})})})]}),o.jsx("div",{className:"hidden md:block",children:o.jsx(tr,{panelKey:eB,side:"left",minWidth:Vk,maxWidth:_k,defaultWidth:tB})})]})}),!s&&o.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 md:hidden",onClick:n,"aria-hidden":"true"})]})}),oB="clamp(360px, 28vw, 520px)",ur=320,$k=m.memo(function({sidebar:e,children:t,onNewSession:s,theme:n,onToggleTheme:r,sessionId:i,onFixWithAI:a}){const g=Ye(b=>b.isExpanded),Q=At(b=>b.isExpanded),B=Dt(b=>b.isExpanded),u=Re(b=>b.isExpanded),E=$e(b=>b.isExpanded),c=Ze(b=>b.isExpanded),h=Pe(b=>b.isExpanded),f=Ht(b=>b.tabs.length),d=Xo(b=>b.widths),D=g||Q||B||u||E||c||h,R=f>0,M=g?d.git??ur:Q?d["session-files"]??ur:B?d.settings??ur:E?d["file-browser"]??ur:ur,q=m.useRef(R),G=m.useRef(D),[T,Z]=m.useState(D),[X,U]=m.useState(D?M:0),[O,j]=m.useState(!1),Y=q.current!==R,x={width:R?oB:"100%"},l={width:R?`calc(100% - ${oB})`:"0px"},I={width:`${X}px`},y=D||T;return m.useEffect(()=>{const b=G.current;if(D){b||(j(!0),U(0)),Z(!0);const H=requestAnimationFrame(()=>{U(M)}),v=window.setTimeout(()=>{j(!1)},300);return G.current=!0,()=>{cancelAnimationFrame(H),window.clearTimeout(v)}}if(!b){U(0);return}j(!0),U(0);const J=window.setTimeout(()=>{Z(!1),j(!1)},300);return G.current=!1,()=>window.clearTimeout(J)},[D,M]),m.useEffect(()=>{q.current=R},[R]),o.jsxs("div",{className:"h-screen flex bg-background touch-manipulation border-t border-border/50",children:[o.jsx(Xk,{onNewSession:s,children:e}),o.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden w-full md:w-auto",children:[o.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 overflow-hidden",children:[o.jsx("main",{className:`relative shrink-0 flex-col overflow-hidden min-w-0 ${Y?"transition-[width] duration-300 ease-out":"transition-none"} ${R?"hidden md:flex md:min-w-[320px]":"flex"}`,style:x,children:t}),o.jsx("section",{className:`hidden md:flex shrink-0 min-w-0 overflow-hidden border-l bg-sidebar ${R?"border-sidebar-border opacity-100":"border-transparent opacity-0"} ${Y?"transition-[width,opacity,border-color] duration-300 ease-out":"transition-none"}`,style:l,"aria-hidden":!R,children:R&&o.jsx(Mk,{})})]}),o.jsxs("div",{className:"hidden md:flex",children:[o.jsx("div",{className:`h-full shrink-0 overflow-hidden bg-sidebar ${O?"transition-[width] duration-300 ease-out":"transition-none"}`,style:I,"aria-hidden":!y,children:o.jsxs("div",{className:"h-full w-full",children:[o.jsx(My,{onFixWithAI:a}),o.jsx(qy,{sessionId:i}),o.jsx(fN,{}),o.jsx(GN,{}),o.jsx(Ek,{}),o.jsx(_N,{}),o.jsx(sk,{})]})}),o.jsxs("div",{className:`flex flex-col w-12 border-l ${D?"sidebar-fade-in border-sidebar-border":"bg-background border-border"}`,children:[o.jsx(Fy,{}),o.jsx(Yy,{sessionId:i}),o.jsx(Ck,{}),o.jsx(SN,{}),o.jsx(ZN,{}),o.jsx(rk,{}),o.jsx(xN,{}),o.jsx("div",{className:"flex-1"}),o.jsx(V0,{}),o.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:r,title:`Switch to ${n==="dark"?"light":"dark"} mode`,"aria-label":`Switch to ${n==="dark"?"light":"dark"} mode`,className:"touch-manipulation",children:n==="dark"?o.jsx(gu,{className:"w-4 h-4"}):o.jsx(lu,{className:"w-4 h-4"})})})]})]})]}),o.jsx(z0,{})]}),o.jsx(Uy,{}),o.jsx(Z0,{}),o.jsx(fk,{})]})});function pC({sessionId:A}){const e=m.useRef(null),t=Wf(),{data:s}=As(),{theme:n,toggleTheme:r}=qk(),{openCommitModal:i,openDiff:a}=Ye(),g=MC(),{data:Q=[]}=ri(),{data:B}=ni(),u=ii(),E=Dg(),c=Dc(),h=yc(),f=ug(U=>U.openConfirmation);Yk(),jk(A),Pk(A),Ii(s?.defaults?.provider);const d=m.useCallback(()=>{setTimeout(()=>{e.current?.focus()},100)},[]),D=m.useCallback(()=>{g({to:"/sessions"})},[g]),R=m.useCallback(U=>{g({to:"/sessions/$sessionId",params:{sessionId:U},replace:!1}),d()},[g,d]),M=m.useCallback(()=>{g({to:"/sessions"})},[g]),q=m.useCallback(U=>{g({to:"/sessions/$sessionId",params:{sessionId:U}}),d()},[g,d]),G=m.useCallback(async U=>{try{const O=await t.mutateAsync({agent:s?.defaults.agent||"general",provider:s?.defaults.provider,model:s?.defaults.model,title:"Fix Git Error"});g({to:"/sessions/$sessionId",params:{sessionId:O.id},replace:!1}),await fA.sendMessage(O.id,{content:U})}catch(O){console.error("Failed to create fix session:",O)}},[t,s,g]),T=m.useMemo(()=>B?[...(B.conflicted??[]).map(U=>({path:U.path,staged:!1,status:U.status})),...B.staged.map(U=>({path:U.path,staged:!0,status:U.status})),...B.unstaged.map(U=>({path:U.path,staged:!1,status:U.status})),...B.untracked.map(U=>({path:U.path,staged:!1,status:U.status}))]:[],[B]),Z=m.useMemo(()=>Q.map(U=>U.id),[Q]);Hk({sessionIds:Z,activeSessionId:A,gitFiles:T,onSelectSession:q,onNewSession:D,onStageFile:U=>u.mutate([U]),onUnstageFile:U=>E.mutate([U]),onRestoreFile:U=>c.mutate([U]),onDeleteFile:U=>{f({title:"Delete File",message:`Delete ${U}? This will permanently remove the untracked file.`,confirmLabel:"Delete",variant:"destructive",onConfirm:async()=>{await h.mutateAsync([U])}})},onStageAll:()=>{const U=T.filter(O=>!O.staged).map(O=>O.path);U.length>0&&u.mutate(U)},onUnstageAll:()=>{const U=T.filter(O=>O.staged).map(O=>O.path);U.length>0&&E.mutate(U)},onOpenCommitModal:i,onViewDiff:a,onReturnToInput:d}),m.useEffect(()=>{A&&d()},[A,d]),m.useEffect(()=>{const U=window,O=j=>{q(j)};return U.OTTO_OPEN_SESSION=O,()=>{U.OTTO_OPEN_SESSION===O&&delete U.OTTO_OPEN_SESSION}},[q]),m.useEffect(()=>{const U=O=>{O.data?.type==="otto-navigate-session"&&typeof O.data.sessionId=="string"&&(window.parent?.postMessage({type:"otto-navigate-session-ack",sessionId:O.data.sessionId},"*"),g({to:"/sessions/$sessionId",params:{sessionId:O.data.sessionId}}),d())};return window.addEventListener("message",U),()=>window.removeEventListener("message",U)},[g,d]);const X=m.useMemo(()=>A?o.jsxs(o.Fragment,{children:[o.jsx(Qy,{sessionId:A,onSelectSession:q}),o.jsx(Nm,{ref:e,sessionId:A,onNewSession:D,onDeleteSession:M})]}):o.jsx(Mm,{onSessionCreated:R}),[A,D,q,M,R]);return o.jsxs(o.Fragment,{children:[o.jsx($k,{onNewSession:D,theme:n,onToggleTheme:r,sessionId:A,onNavigateToSession:q,onFixWithAI:G,sidebar:o.jsx(Iy,{activeSessionId:A,onSelectSession:q}),children:X}),o.jsx(ip,{})]})}const AM=Va("/sessions/")({component:eM});function eM(){return o.jsx(pC,{})}const fC=Va("/sessions/$sessionId")({component:tM});function tM(){const{sessionId:A}=fC.useParams();return o.jsx(pC,{sessionId:A})}const oM=zk.update({id:"/",path:"/",getParentRoute:()=>pi}),sM=AM.update({id:"/sessions/",path:"/sessions/",getParentRoute:()=>pi}),rM=fC.update({id:"/sessions/$sessionId",path:"/sessions/$sessionId",getParentRoute:()=>pi}),nM={IndexRoute:oM,SessionsSessionIdRoute:rM,SessionsIndexRoute:sM},iM=pi._addFileChildren(nM)._addFileTypes(),aM=()=>{const t=(typeof globalThis<"u"?globalThis.OTTO_ROUTER_BASEPATH:void 0)??"/"??"/";if(!t||t==="/")return"/";const s=t.replace(/\/+$/,"")||"/";return s.startsWith("/")?s:`/${s}`},gM=bC({routeTree:iM,basepath:aM()}),$g=new FC({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1,structuralSharing:!0}}});$g.prefetchQuery({queryKey:["sessions"],queryFn:()=>fA.getSessions()});$g.prefetchQuery({queryKey:["config"],queryFn:()=>fA.getConfig()});function lM(){return o.jsx(vC,{client:$g,children:o.jsx(GC,{router:gM})})}const mC=document.getElementById("root");if(!mC)throw new Error("Root element not found");SC.createRoot(mC).render(o.jsx(m.StrictMode,{children:o.jsx(lM,{})}));
149
+ `)),zA(Ue.message||(Ue.models.length>0?`Fetched ${Ue.models.length} model${Ue.models.length===1?"":"s"}.`:"No models found."))}catch(Ue){kA([]),zA(Ue instanceof Error?Ue.message:"Failed to fetch models")}finally{nt(!1)}},te=async()=>{const QA=p.trim(),Ue=S.trim()||QA,mt=AA.trim(),mo=oA.trim(),lr=GA.split(/[\n,]/).map(_r=>_r.trim()).filter(Boolean);if(!QA||!mt){de("Provider ID and base URL are required.");return}we(!0),de(null);try{await r({id:QA,label:Ue,baseURL:mt,apiKey:mo||void 0,compatibility:jA,models:lr,allowAnyModel:ce}),C(!1),hA()}catch(_r){de(_r instanceof Error?_r.message:"Failed to add custom provider")}finally{we(!1)}},Ce=async QA=>{if(k===QA){N(QA);try{await i(QA)}finally{N(null),_(null)}}else _(QA)},Ie=()=>{_(null)},ue=()=>{f&&(FA(!0),Be(null),f().then(QA=>{Kt(QA),FA(!1)}).catch(QA=>{Be(QA instanceof Error?QA.message:"Failed to start device flow"),FA(!1)}))},eA=async(QA,Ue)=>{QA==="anthropic"?aA({provider:QA,sessionId:null,mode:Ue}):QA==="copilot"?(Lt("oauth"),ze(""),w(null),W(null),je(!1),Kt(null),Be(null),IA(!0),D&&D().then(mt=>W(mt)).catch(()=>{}),q&&q().then(mt=>w(mt)).catch(()=>{}),ue()):a(QA,Ue)},xe=async()=>{if(tA){XA(!0);try{const{sessionId:QA}=await g(tA.provider,tA.mode);aA({...tA,sessionId:QA})}catch(QA){console.error("Failed to start OAuth:",QA)}XA(!1)}},Ge=async()=>{if(!(!tA||!tA.sessionId||!EA.trim())){$A(!0);try{await Q(tA.provider,EA.trim(),tA.sessionId),aA(null),ZA("")}catch{}$A(!1)}},Me=()=>{aA(null),ZA("")},pe=()=>{ye&&(Io(ye.verificationUri),je(!0))},be=QA=>{Lt(QA),Be(null),QA==="token"&&je(!1),QA==="oauth"&&!ye&&!yA&&ue()},Se=async()=>{if(!(!Oe.trim()||!R)){KA(!0),Be(null);try{await R(Oe.trim()),tt()}catch(QA){Be(QA instanceof Error?QA.message:"Failed to save Copilot token")}finally{KA(!1)}}},lt=async()=>{if(M){_t(!0),Be(null);try{await M(),tt()}catch(QA){Be(QA instanceof Error?QA.message:"Failed to import token from GitHub CLI")}finally{_t(!1)}}},Ve=async()=>{ye&&(await navigator.clipboard.writeText(ye.userCode),nA(!0),setTimeout(()=>nA(!1),2e3))},tt=()=>{Kt(null),je(!1),Be(null),ze(""),KA(!1),_t(!1),Lt("oauth"),nA(!1),IA(!1),FA(!1),Ee.current=!0,xA.current&&(clearTimeout(xA.current),xA.current=void 0)},it=()=>{y(null),Y(""),O(!0)},st=()=>{x||(O(!1),y(null),Y(""))};m.useEffect(()=>{const QA=Ue=>{const mt=Ue;if(!mt.detail||mt.detail.handled)return;const mo=()=>{mt.detail.handled=!0,Ue.preventDefault()};if(K){mo(),_A||(C(!1),L(""),$(""),sA(""),bA(""),lA(""),HA("openai-compatible"),NA(!0),de(null),kA([]),zA(null));return}if(U){mo(),x||(O(!1),y(null),Y(""));return}if(tA){mo(),!VA&&!ke&&(aA(null),ZA(""));return}if(rA){mo(),!co&&!se&&!yA&&(Kt(null),je(!1),Be(null),ze(""),KA(!1),_t(!1),Lt("oauth"),nA(!1),IA(!1),FA(!1),Ee.current=!0,xA.current&&(clearTimeout(xA.current),xA.current=void 0));return}if(b){mo(),J(null),v("");return}k&&(mo(),_(null))};return window.addEventListener("otto:native-back",QA),()=>window.removeEventListener("otto:native-back",QA)},[b,k,se,yA,rA,co,_A,K,VA,x,U,ke,tA]);const ct=async()=>{if(!(!j.trim()||x)){l(!0),y(null);try{await s(j.trim()),O(!1),Y(""),JA()}catch(QA){y(QA instanceof Error?QA.message:"Failed to import wallet")}finally{l(!1)}}},dt=Object.entries(e.providers).filter(([QA,Ue])=>Ue.configured&&QA!=="ottorouter"),yt=Object.entries(e.providers).filter(([QA,Ue])=>!Ue.configured&&QA!=="ottorouter");return o.jsxs("div",{className:"min-h-screen flex flex-col",children:[!h&&o.jsxs("div",{className:"flex items-center justify-between px-4 sm:px-6 py-4 border-b border-border",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(ro,{provider:"ottorouter",size:24}),o.jsx("span",{className:"font-semibold text-foreground",children:"otto"})]}),!E&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500"}),"Step 1 of 2"]})]}),o.jsx("div",{className:`flex-1 px-4 sm:px-6 lg:px-12 pb-32 ${h?"pt-8 sm:pt-10 lg:pt-14":"pt-6 sm:pt-8 lg:pt-12"}`,children:o.jsxs("div",{className:"max-w-7xl mx-auto",children:[o.jsxs("div",{className:"mb-10",children:[o.jsx("h1",{className:"text-2xl sm:text-3xl lg:text-4xl font-semibold text-foreground mb-3",children:E?"Manage Providers":"Welcome to otto"}),o.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl",children:E?"Add or remove AI providers. Your changes are saved automatically.":"Setu is your default AI provider. GO plan credits are applied automatically."})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-6 sm:gap-8",children:[o.jsx("div",{children:o.jsx("div",{className:"bg-card rounded-2xl border border-border p-5",children:e.ottorouter.configured&&e.ottorouter.publicKey?o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-green-500/10 border border-green-500/20 rounded-lg",children:[o.jsx(ro,{provider:"ottorouter",size:16}),o.jsx("span",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:"Setu"}),o.jsx("span",{className:"text-xs text-green-600/60 dark:text-green-500/60 ml-auto",children:"Default Provider"})]}),o.jsx("div",{className:"flex justify-center py-4 mt-4",children:o.jsx("div",{className:"bg-white p-2 rounded-lg",children:o.jsx(hi,{value:e.ottorouter.publicKey,size:140,level:"M"})})}),o.jsxs("div",{className:"space-y-2 mt-4",children:[o.jsxs("button",{type:"button",onClick:CA,className:"w-full flex items-center justify-center gap-2 px-3 py-2 bg-muted hover:bg-muted/80 rounded-lg text-xs font-mono text-muted-foreground transition-colors",children:[uA(e.ottorouter.publicKey),G?o.jsx(zt,{className:"w-3.5 h-3.5 text-green-500"}):o.jsx(ws,{className:"w-3.5 h-3.5 text-muted-foreground"})]}),o.jsxs("div",{className:"space-y-1.5 px-3 py-2 bg-muted/50 rounded-lg",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("div",{className:"flex items-center gap-1.5 min-w-0",children:o.jsx("span",{className:"font-mono text-xs sm:text-sm text-foreground truncate",children:SA})}),o.jsx("button",{type:"button",onClick:JA,disabled:re,className:"p-0.5 text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:o.jsx(Xt,{className:`w-3 h-3 ${re?"animate-spin":""}`})})]}),o.jsxs("span",{className:"text-[10px] text-muted-foreground font-mono",children:["Balance $",(Ae??0).toFixed(2)," • On-chain"," ",(ie??0).toFixed(2)," USDC"]})]})]}),o.jsxs("div",{className:"flex items-center gap-4 py-4",children:[o.jsx("div",{className:"flex-1 h-px bg-border"}),o.jsx("span",{className:"text-xs text-muted-foreground font-medium",children:"OR"}),o.jsx("div",{className:"flex-1 h-px bg-border"})]}),o.jsxs("button",{type:"button",onClick:B,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:bg-primary/90 transition-colors",children:[o.jsx(zn,{className:"w-4 h-4"}),"Top Up with Card"]}),o.jsxs("button",{type:"button",onClick:it,className:"w-full mt-2 flex items-center justify-center gap-2 px-4 py-2.5 border border-border text-foreground rounded-lg text-sm font-medium hover:bg-muted/50 transition-colors",children:[o.jsx(dr,{className:"w-4 h-4"}),"Import Wallet"]})]}):o.jsx("div",{className:"flex items-center justify-center py-16",children:o.jsx(Te,{className:"w-8 h-8 animate-spin text-muted-foreground"})})})}),o.jsxs("div",{className:"sm:col-span-2 space-y-6",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsx("h2",{className:"font-semibold text-foreground",children:"Connected Providers"}),dt.length>0&&o.jsxs("span",{className:"text-sm text-muted-foreground",children:[dt.length," active"]})]}),dt.length===0?o.jsx("div",{className:"text-sm text-muted-foreground py-4",children:"No providers connected yet. Add one below."}):o.jsx("div",{className:"flex flex-wrap gap-2",children:dt.map(([QA,Ue])=>o.jsxs("div",{className:`flex items-center gap-2 pl-3 pr-2 py-2 rounded-full transition-all duration-200 ${k===QA?"bg-destructive/10 border border-destructive/30":"group bg-green-500/10 border border-green-500/20"}`,children:[o.jsx(ro,{provider:QA,size:16}),o.jsx("span",{className:`text-sm font-medium transition-colors ${k===QA?"text-destructive":"text-green-600 dark:text-green-400"}`,children:Ue.label}),k!==QA&&o.jsx("span",{className:"text-xs text-green-600/60 dark:text-green-500/60",children:Ue.type==="oauth"?"OAuth":"API"}),k===QA?o.jsxs("div",{className:"flex items-center gap-1 ml-1",children:[o.jsx("span",{className:"text-xs text-destructive/80 mr-1",children:"Remove?"}),o.jsx("button",{type:"button",onClick:()=>Ce(QA),disabled:P===QA,className:"px-2 py-0.5 text-xs bg-destructive text-destructive-foreground rounded hover:bg-destructive/90 transition-colors disabled:opacity-50",children:P===QA?o.jsx(Te,{className:"w-3 h-3 animate-spin"}):"Yes"}),o.jsx("button",{type:"button",onClick:Ie,className:"px-2 py-0.5 text-xs bg-muted text-muted-foreground rounded hover:bg-muted/80 transition-colors",children:"No"})]}):QA!=="ottorouter"&&o.jsx("button",{type:"button",onClick:()=>Ce(QA),className:"ml-1 p-1 text-green-600/40 dark:text-green-500/40 hover:text-green-600/80 dark:hover:text-green-500/80 opacity-0 group-hover:opacity-100 transition-opacity",children:o.jsx(et,{className:"w-3 h-3"})})]},QA))})]}),o.jsxs("div",{children:[o.jsx("h2",{className:"font-semibold text-foreground mb-4",children:"Add Providers"}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 items-start",children:[yt.map(([QA,Ue])=>o.jsx("div",{children:b===QA?o.jsxs("div",{className:"flex items-center gap-2 p-3 bg-card border border-ring rounded-xl overflow-hidden",children:[o.jsx("div",{className:"shrink-0",children:o.jsx(ro,{provider:QA,size:18})}),o.jsx("input",{ref:ne,type:"password",value:H,onChange:mt=>v(mt.target.value),placeholder:`${Ue.label} API key...`,className:"flex-1 min-w-0 bg-transparent text-sm outline-none placeholder:text-muted-foreground text-foreground",onKeyDown:mt=>{mt.key==="Enter"&&mA(QA),mt.key==="Escape"&&(J(null),v(""))}}),o.jsx("button",{type:"button",onClick:()=>mA(QA),disabled:!H.trim(),className:"shrink-0 px-3 py-1.5 bg-primary text-primary-foreground text-sm font-medium rounded-lg disabled:opacity-50",children:"Add"}),o.jsx("button",{type:"button",onClick:()=>{J(null),v("")},className:"shrink-0 p-1.5 text-muted-foreground hover:text-foreground",children:o.jsx(et,{className:"w-4 h-4"})})]}):o.jsxs("div",{className:"flex items-center justify-between p-3 bg-card border border-border hover:border-border/80 rounded-xl transition-colors gap-2",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx(ro,{provider:QA,size:20}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"font-medium text-foreground truncate",children:Ue.label}),o.jsxs("div",{className:"text-xs text-muted-foreground",children:[Ue.modelCount," models"]})]})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[QA!=="copilot"&&o.jsxs("button",{type:"button",onClick:()=>J(QA),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors",children:[o.jsx(dr,{className:"w-3.5 h-3.5"}),"API"]}),Ue.supportsOAuth&&o.jsxs("button",{type:"button",onClick:()=>eA(QA,QA==="anthropic"?"max":void 0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground hover:text-foreground hover:bg-muted rounded-lg transition-colors",children:[o.jsx(Gt,{className:"w-3.5 h-3.5"}),QA==="anthropic"?"Pro":QA==="copilot"?"Login":"OAuth"]})]})]})},QA)),o.jsxs("button",{type:"button",onClick:()=>C(!0),className:"group flex items-center justify-between p-3 bg-card border border-dashed border-border hover:border-primary/60 hover:bg-primary/5 hover:shadow-sm rounded-xl transition-all gap-2 text-left cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsx("span",{className:"inline-flex items-center justify-center w-5 h-5 rounded-full bg-muted text-muted-foreground group-hover:bg-primary/10 group-hover:text-primary transition-colors",children:o.jsx(Bo,{className:"w-3.5 h-3.5"})}),o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"font-medium text-foreground truncate",children:"Custom Provider"}),o.jsx("div",{className:"text-xs text-muted-foreground group-hover:text-foreground/70 transition-colors",children:"OpenAI-compatible or Ollama endpoint"})]})]}),o.jsxs("span",{className:"flex items-center gap-1.5 px-3 py-1.5 text-sm text-muted-foreground group-hover:text-primary group-hover:bg-primary/10 rounded-lg transition-colors",children:[o.jsx(dr,{className:"w-3.5 h-3.5"}),"Add"]})]})]})]})]})]})]})}),o.jsx("div",{className:"fixed bottom-0 left-0 right-0 px-4 sm:px-6 py-4 border-t border-border bg-background",children:o.jsxs("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:[!E&&o.jsx("div",{className:"text-xs sm:text-sm text-muted-foreground hidden sm:block",children:"You can add more providers later in settings"}),E?o.jsx("button",{type:"button",onClick:c,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors ml-auto",children:"Done"}):o.jsxs("button",{type:"button",onClick:u,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors",children:["Continue",o.jsx(cB,{className:"w-4 h-4"})]})]})}),K&&o.jsx("div",{"data-otto-nested-modal":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm",children:o.jsxs("div",{className:"bg-background border border-border rounded-xl w-full max-w-2xl mx-6 shadow-2xl max-h-[90vh] overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center gap-3 p-6 border-b border-border",children:[o.jsx("span",{className:"inline-flex items-center justify-center w-6 h-6 rounded-full bg-muted text-muted-foreground",children:o.jsx(Bo,{className:"w-4 h-4"})}),o.jsx("h3",{className:"text-lg font-semibold",children:"Add Custom Provider"})]}),o.jsxs("div",{className:"p-6 space-y-4",children:[o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("label",{className:"space-y-2",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Provider ID"}),o.jsx("input",{type:"text",value:p,onChange:QA=>L(QA.target.value),placeholder:"my-provider",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors font-mono text-sm"})]}),o.jsxs("label",{className:"space-y-2",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Display Name"}),o.jsx("input",{type:"text",value:S,onChange:QA=>$(QA.target.value),placeholder:"My Provider",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors text-sm"})]})]}),o.jsxs("div",{className:"flex items-center justify-between gap-3 p-3 bg-muted/30 border border-border rounded-lg",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-foreground",children:"Fetch models from provider"}),o.jsx("div",{className:"text-xs text-muted-foreground",children:"For Ollama, this reads /api/tags and /api/show to include context windows."})]}),o.jsxs("button",{type:"button",onClick:MA,disabled:!AA.trim()||Ke,className:"shrink-0 px-3 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 flex items-center gap-2",children:[Ke&&o.jsx(Te,{className:"w-3.5 h-3.5 animate-spin"}),"Fetch Models"]})]}),he&&o.jsx("p",{className:"text-xs text-muted-foreground",children:he}),Le.length>0&&o.jsx("div",{className:"space-y-2 max-h-44 overflow-y-auto border border-border rounded-lg p-2",children:Le.map(QA=>o.jsxs("div",{className:"flex items-center justify-between gap-3 p-2 bg-card rounded-md",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:QA.label}),o.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate",children:QA.id})]}),o.jsxs("div",{className:"flex flex-wrap justify-end gap-1 shrink-0",children:[QA.contextWindow&&o.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-blue-600/20 text-blue-400 rounded",children:[_Q(QA.contextWindow)," ctx"]}),QA.maxOutputTokens&&o.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 bg-cyan-600/20 text-cyan-400 rounded",children:[_Q(QA.maxOutputTokens)," out"]}),QA.toolCall&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-green-600/20 text-green-400 rounded",children:"Tools"}),QA.reasoningText&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-purple-600/20 text-purple-400 rounded",children:"Reasoning"}),QA.vision&&o.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-orange-600/20 text-orange-400 rounded",children:"Vision"})]})]},QA.id))}),o.jsxs("label",{className:"space-y-2 block",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Base URL"}),o.jsx("input",{type:"url",value:AA,onChange:QA=>sA(QA.target.value),placeholder:"https://api.example.com/v1",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors font-mono text-sm"})]}),o.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[o.jsxs("label",{className:"space-y-2",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"API Key"}),o.jsx("input",{type:"password",value:oA,onChange:QA=>bA(QA.target.value),placeholder:"Optional",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors font-mono text-sm"})]}),o.jsxs("label",{className:"space-y-2",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Compatibility"}),o.jsx("select",{value:jA,onChange:QA=>HA(QA.target.value),className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground outline-none focus:border-foreground/30 transition-colors text-sm",children:bk.map(QA=>o.jsx("option",{value:QA.value,children:QA.label},QA.value))})]})]}),o.jsxs("label",{className:"space-y-2 block",children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Models"}),o.jsx("textarea",{value:GA,onChange:QA=>lA(QA.target.value),placeholder:"gpt-4o, claude-sonnet-4-5, llama3.3",className:"w-full min-h-[90px] px-4 py-3 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors font-mono text-sm resize-y"}),o.jsx("span",{className:"text-xs text-muted-foreground",children:"Comma or newline separated. Leave blank to allow any model."})]}),o.jsxs("label",{className:"flex items-center gap-3 text-sm text-muted-foreground",children:[o.jsx("input",{type:"checkbox",checked:ce,onChange:QA=>NA(QA.target.checked),className:"h-4 w-4 accent-primary"}),"Allow entering model IDs not listed above"]}),He&&o.jsx("p",{className:"text-sm text-red-500",children:He}),o.jsxs("div",{className:"flex gap-3 pt-2",children:[o.jsx("button",{type:"button",onClick:pA,disabled:_A,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors disabled:opacity-50",children:"Cancel"}),o.jsx("button",{type:"button",onClick:te,disabled:!p.trim()||!AA.trim()||_A,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:_A?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):"Add Provider"})]})]})]})}),U&&o.jsx("div",{"data-otto-nested-modal":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm",children:o.jsxs("div",{className:"bg-background border border-border rounded-xl w-full max-w-lg mx-6 shadow-2xl",children:[o.jsxs("div",{className:"flex items-center gap-3 p-6 border-b border-border",children:[o.jsx(ro,{provider:"ottorouter",size:24}),o.jsx("h3",{className:"text-lg font-semibold",children:"Import Setu Wallet"})]}),o.jsxs("div",{className:"p-6",children:[o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Paste your base58 private key to replace the current wallet used for Setu."}),o.jsx("textarea",{ref:LA,value:j,onChange:QA=>Y(QA.target.value),placeholder:"Enter private key",className:"w-full min-h-[110px] px-4 py-3 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors font-mono text-xs resize-y",onKeyDown:QA=>{(QA.metaKey||QA.ctrlKey)&&QA.key==="Enter"&&(QA.preventDefault(),ct()),QA.key==="Escape"&&st()}}),I&&o.jsx("p",{className:"text-sm text-red-500 mt-3",children:I}),o.jsxs("div",{className:"flex gap-3 mt-5",children:[o.jsx("button",{type:"button",onClick:st,disabled:x,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors disabled:opacity-50",children:"Cancel"}),o.jsx("button",{type:"button",onClick:ct,disabled:!j.trim()||x,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:x?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):"Import Wallet"})]})]})]})}),tA&&o.jsx("div",{"data-otto-nested-modal":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm",children:o.jsxs("div",{className:"bg-background border border-border rounded-xl w-full max-w-lg mx-6 shadow-2xl",children:[o.jsxs("div",{className:"flex items-center gap-3 p-6 border-b border-border",children:[o.jsx(ro,{provider:tA.provider,size:24}),o.jsxs("h3",{className:"text-lg font-semibold",children:["Connect"," ",e.providers[tA.provider]?.label||tA.provider]})]}),tA.sessionId?o.jsxs("div",{className:"p-6",children:[o.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Paste the authorization code:"}),o.jsx("input",{type:"text",ref:ee,value:EA,onChange:QA=>ZA(QA.target.value),placeholder:"Paste code here...",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors mb-4 font-mono text-sm",onKeyDown:QA=>{QA.key==="Enter"&&Ge(),QA.key==="Escape"&&Me()}}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{type:"button",onClick:Me,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors",children:"Cancel"}),o.jsx("button",{type:"button",onClick:Ge,disabled:!EA.trim()||VA,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:VA?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):"Connect"})]})]}):o.jsxs("div",{className:"p-6",children:[o.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["You'll be redirected to"," ",e.providers[tA.provider]?.label||tA.provider," ","to authorize access. After authorizing, copy the code and return here."]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{type:"button",onClick:Me,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors",children:"Cancel"}),o.jsx("button",{type:"button",onClick:xe,disabled:ke,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:ke?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:["Continue",o.jsx(Gt,{className:"w-4 h-4"})]})})]})]})]})}),rA&&o.jsx("div",{"data-otto-nested-modal":"true",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60 backdrop-blur-sm",children:o.jsxs("div",{className:"bg-background border border-border rounded-xl w-full max-w-lg mx-6 shadow-2xl",children:[o.jsxs("div",{className:"flex items-center gap-3 p-6 border-b border-border",children:[o.jsx(ro,{provider:"copilot",size:24}),o.jsx("h3",{className:"text-lg font-semibold",children:"Connect GitHub Copilot"})]}),o.jsxs("div",{className:"p-6 space-y-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{type:"button",onClick:()=>be("oauth"),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${ve==="oauth"?"bg-foreground text-background":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"OAuth"}),o.jsx("button",{type:"button",onClick:()=>be("token"),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${ve==="token"?"bg-foreground text-background":"bg-muted text-muted-foreground hover:text-foreground"}`,children:"Token"})]}),ve==="oauth"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter this code on GitHub to authorize:"}),o.jsx("div",{className:"flex items-center justify-center gap-3",children:yA?o.jsx("div",{className:"bg-muted px-6 py-3 rounded-lg animate-pulse",children:o.jsx("div",{className:"h-9 w-48 bg-muted-foreground/20 rounded"})}):ye?o.jsxs(o.Fragment,{children:[o.jsx("code",{className:"text-3xl font-mono font-bold tracking-widest text-foreground bg-muted px-6 py-3 rounded-lg select-all",children:ye.userCode}),o.jsx("button",{type:"button",onClick:Ve,className:"p-2 text-muted-foreground hover:text-foreground transition-colors",children:V?o.jsx(zt,{className:"w-5 h-5 text-green-500"}):o.jsx(ws,{className:"w-5 h-5"})})]}):null})]}):o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-sm text-muted-foreground",children:"Paste a GitHub token with Copilot model access."}),o.jsx("input",{type:"password",value:Oe,onChange:QA=>ze(QA.target.value),placeholder:"gho_...",className:"w-full h-11 px-4 bg-muted/50 border border-border rounded-lg text-foreground placeholder:text-muted-foreground outline-none focus:border-foreground/30 transition-colors"}),F?.ghImport.available&&o.jsx("button",{type:"button",onClick:lt,disabled:se,className:"w-full h-10 px-4 bg-muted text-foreground rounded-lg font-medium hover:bg-muted/80 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:se?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):"Import from GH CLI"}),F?.ghImport.available&&!F.ghImport.authenticated&&o.jsx("p",{className:"text-xs text-muted-foreground",children:F.ghImport.reason||"GitHub CLI is not authenticated"}),F&&!F.ghImport.available&&F.ghImport.reason&&o.jsx("p",{className:"text-xs text-muted-foreground",children:F.ghImport.reason})]}),z&&z.tokenSources.length>0&&o.jsx("div",{className:"text-xs text-muted-foreground space-y-1",children:z.tokenSources.map(QA=>o.jsxs("div",{children:[QA.source,":"," ",QA.configured?QA.error?QA.error:`${QA.modelCount??0} models visible`:"not configured",QA.restrictedByOrgPolicy&&QA.restrictedOrg?` (org restriction: ${QA.restrictedOrg})`:""]},QA.source))}),To&&o.jsx("p",{className:"text-sm text-red-500 text-center",children:To}),Je&&ve==="oauth"&&o.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-muted-foreground",children:[o.jsx(Te,{className:"w-4 h-4 animate-spin"}),"Waiting for authorization..."]}),o.jsxs("div",{className:"flex gap-3",children:[o.jsx("button",{type:"button",onClick:tt,className:"flex-1 h-11 px-4 bg-transparent border border-border text-foreground rounded-lg font-medium hover:bg-muted/50 transition-colors",children:"Cancel"}),ve==="oauth"?o.jsx("button",{type:"button",onClick:pe,disabled:Je||yA,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:Je||yA?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):o.jsxs(o.Fragment,{children:["Open GitHub",o.jsx(Gt,{className:"w-4 h-4"})]})}):o.jsx("button",{type:"button",onClick:Se,disabled:!Oe.trim()||co,className:"flex-1 h-11 px-4 bg-foreground text-background rounded-lg font-medium hover:bg-foreground/90 transition-colors disabled:opacity-50 flex items-center justify-center gap-2",children:co?o.jsx(Te,{className:"w-4 h-4 animate-spin"}):"Save token"})]})]})]})})]})}),vk=m.memo(function({authStatus:e,onComplete:t,onBack:s,hideHeader:n=!1}){const[r,i]=m.useState(null),[a,g]=m.useState(null),[Q,B]=m.useState(!0),[u,E]=m.useState(!1),[c,h]=m.useState("ottorouter"),[f,d]=m.useState("kimi-k2.5"),[D,R]=m.useState(e.defaults.agent||"build"),[M,q]=m.useState(e.defaults.toolApproval||"dangerous"),[G,T]=m.useState(!1),Z=m.useRef(!1),X=m.useId(),U=m.useId(),O=m.useId(),j=m.useId();m.useEffect(()=>{(async()=>{try{const[y,b]=await Promise.all([fA.getConfig(),fA.getAllModels()]);i(y),g(b);const J=y?.defaults?.provider||"ottorouter",H=y?.defaults?.model||"kimi-k2.5",v=b?.[J]?.models?.length>0,K=v?J:"ottorouter",C=v&&b[J].models.some(p=>p.id===H)?H:b?.[K]?.models?.[0]?.id||"kimi-k2.5";h(K),d(C),y?.defaults?.agent&&R(y.defaults.agent),y?.defaults?.toolApproval&&q(y.defaults.toolApproval),y?.defaults?.guidedMode&&T(y.defaults.guidedMode)}catch{}finally{B(!1)}})()},[]),m.useEffect(()=>{if(r?.agents?.length){const I=r.agents;(!D||!I.includes(D))&&R(I.includes("build")?"build":I[0])}},[r,D]),m.useEffect(()=>{if(a?.[c]&&Z.current){const I=a[c];I.models.some(y=>y.id===f)||d(I.models[0]?.id||"")}},[c,a,f]);const Y=async()=>{E(!0);try{await fA.updateDefaults({provider:c,model:f,agent:D,toolApproval:M,guidedMode:G,fullWidthContent:r?.defaults?.fullWidthContent??!0,scope:"global"}),await t()}catch{}finally{E(!1)}};if(Q)return o.jsx("div",{className:"min-h-screen flex items-center justify-center",children:o.jsx(Te,{className:"w-8 h-8 animate-spin text-muted-foreground"})});const x=r?.providers.filter(I=>(e.providers[I]?.configured||I==="ottorouter")&&a?.[I]?.models?.length>0)||["ottorouter"],l=a?.[c]?.models||[];return o.jsxs("div",{className:"min-h-screen flex flex-col",children:[!n&&o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx(ro,{provider:"ottorouter",size:24}),o.jsx("span",{className:"font-semibold text-foreground",children:"otto"})]}),o.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[o.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500"}),"Step 2 of 2"]})]}),o.jsx("div",{className:`flex-1 px-4 sm:px-6 lg:px-12 pb-32 ${n?"pt-8 sm:pt-10 lg:pt-14":"pt-6 sm:pt-8 lg:pt-12"}`,children:o.jsxs("div",{className:"max-w-7xl mx-auto",children:[o.jsxs("div",{className:"mb-10",children:[o.jsx("h1",{className:"text-3xl lg:text-4xl font-semibold text-foreground mb-3",children:"Configure Defaults"}),o.jsx("p",{className:"text-lg text-muted-foreground",children:"Set your preferences. You can change these anytime in settings."})]}),o.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[o.jsxs("div",{className:"md:col-span-2",children:[o.jsx("label",{htmlFor:X,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Provider"}),o.jsxs("div",{className:"relative",children:[o.jsx("select",{id:X,value:c,onChange:I=>{Z.current=!0,h(I.target.value)},className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:x.map(I=>o.jsx("option",{value:I,children:e.providers[I]?.label||I},I))}),o.jsx(Mt,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),o.jsxs("div",{className:"md:col-span-2",children:[o.jsx("label",{htmlFor:U,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Model"}),o.jsxs("div",{className:"relative",children:[o.jsx("select",{id:U,value:f,onChange:I=>d(I.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:l.map(I=>o.jsx("option",{value:I.id,children:I.label||I.id},I.id))}),o.jsx(Mt,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:O,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Default Agent"}),o.jsxs("div",{className:"relative",children:[o.jsx("select",{id:O,value:D,onChange:I=>R(I.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:(r?.agents||["build"]).map(I=>o.jsx("option",{value:I,children:I},I))}),o.jsx(Mt,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:j,className:"block text-sm font-medium text-muted-foreground mb-2",children:"Tool Approval"}),o.jsxs("div",{className:"relative",children:[o.jsxs("select",{id:j,value:M,onChange:I=>q(I.target.value),className:"w-full px-4 py-3 bg-card border border-border rounded-xl text-foreground appearance-none cursor-pointer focus:outline-none focus:border-ring transition-colors",children:[o.jsx("option",{value:"auto",children:"Auto - run without asking"}),o.jsx("option",{value:"dangerous",children:"Dangerous - approve writes only"}),o.jsx("option",{value:"yolo",children:"YOLO - skip approvals except hard safety blocks"}),o.jsx("option",{value:"all",children:"All - approve every tool"})]}),o.jsx(Mt,{className:"absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-muted-foreground pointer-events-none"})]}),o.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Controls when tool executions need approval. YOLO still blocks extreme destructive commands."})]}),o.jsx("div",{className:"md:col-span-2",children:o.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-card border border-border rounded-xl",children:[o.jsxs("div",{children:[o.jsx("span",{className:"text-sm font-medium text-foreground",children:"Guided Mode"}),o.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:"AI will run commands and manage services for you instead of giving instructions"})]}),o.jsx("button",{type:"button",role:"switch","aria-checked":G,onClick:()=>T(!G),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2 ${G?"bg-primary":"bg-muted"}`,children:o.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full transition-transform ${G?"translate-x-6":"translate-x-1"} ${G?"bg-primary-foreground":"bg-foreground"}`})})]})})]})]})}),o.jsx("div",{className:"fixed bottom-0 left-0 right-0 px-4 sm:px-6 py-4 border-t border-border bg-background",children:o.jsxs("div",{className:"max-w-7xl mx-auto flex items-center justify-between",children:[o.jsxs("button",{type:"button",onClick:s,className:"flex items-center gap-2 px-4 py-3 text-muted-foreground hover:text-foreground transition-colors",children:[o.jsx(au,{className:"w-4 h-4"}),"Back"]}),o.jsx("button",{type:"button",onClick:Y,disabled:u,className:"flex items-center gap-2 px-6 py-3 bg-primary text-primary-foreground rounded-lg font-medium hover:bg-primary/90 transition-colors disabled:opacity-50",children:u?o.jsxs(o.Fragment,{children:[o.jsx(Te,{className:"w-4 h-4 animate-spin"}),"Setting up..."]}):o.jsxs(o.Fragment,{children:["Start Using otto",o.jsx(Zt,{className:"w-4 h-4"})]})})]})})]})}),Gk=m.memo(function({hideHeader:e=!1,style:t}){const s=kt(O=>O.isOpen),n=kt(O=>O.currentStep),r=kt(O=>O.manageMode),i=kt(O=>O.authStatus),a=kt(O=>O.nextStep),g=kt(O=>O.prevStep),Q=kt(O=>O.reset),B=Ne(O=>O.openTopupModal),{setupWallet:u,importWallet:E,addProvider:c,addCustomProvider:h,removeProvider:f,completeOnboarding:d,startOAuth:D,startOAuthManual:R,exchangeOAuthCode:M,startCopilotDeviceFlow:q,pollCopilotDeviceFlow:G,getCopilotAuthMethods:T,saveCopilotToken:Z,importCopilotTokenFromGh:X,getCopilotDiagnostics:U}=Zg();return m.useEffect(()=>{if(!s)return;const O=j=>{const Y=j;!Y.detail||Y.detail.handled||document.querySelector('[data-otto-nested-modal="true"]')||(Y.detail.handled=!0,j.preventDefault(),Q())};return window.addEventListener("otto:native-back",O),()=>window.removeEventListener("otto:native-back",O)},[s,Q]),!s||!i?null:o.jsxs("div",{className:"fixed inset-0 z-[9999] bg-background text-foreground overflow-y-auto",style:t,children:[n==="wallet"&&o.jsx(Fk,{authStatus:i,onSetupWallet:u,onImportWallet:E,onAddProvider:c,onAddCustomProvider:h,onRemoveProvider:f,onStartOAuth:D,onStartOAuthManual:R,onExchangeOAuthCode:M,onOpenTopup:B,onNext:a,manageMode:r,onClose:Q,hideHeader:e,onStartCopilotDeviceFlow:q,onPollCopilotDeviceFlow:G,onGetCopilotAuthMethods:T,onSaveCopilotToken:Z,onImportCopilotTokenFromGh:X,onGetCopilotDiagnostics:U}),n==="defaults"&&o.jsx(vk,{authStatus:i,onComplete:d,onBack:g,hideHeader:e})]})});function ZQ(A){return A==="success"?"success":A==="error"?"error":"default"}function Xg(A){return A.action?.href??(A.sessionId?`/sessions/${encodeURIComponent(A.sessionId)}`:void 0)}function Pa(A){const e=Xg(A);if(!(!e||typeof window>"u")&&!(A.sessionId&&tp(A.sessionId))){if(e.startsWith("/")){window.location.href=e;return}Io(e)}}function Sk(){return new Promise(A=>{let e=!1,t=!1;const s=n=>{e||(e=!0,setTimeout(()=>A(n??Notification.permission),100))};try{const n=Notification.requestPermission(s);n&&typeof n.then=="function"&&(t=!0,n.then(s).catch(()=>s()))}catch{s()}t||setTimeout(()=>s(),6e4)})}function Uk(A){const e=A.body?`${A.title}: ${A.body}`:A.title;if(Xg(A)){const s=ge(e,ZQ(A.level),6e3);eo.getState().updateToast(s,{activateActionOnClick:!0,action:A.action?{...A.action,onClick:()=>Pa(A)}:{label:"Open session",onClick:()=>Pa(A)}});return}ge(e,ZQ(A.level),5e3)}function Rk(A){if(typeof window>"u")return!1;if($0(A))return!0;if(window.parent&&window.parent!==window){const t={type:"otto-notification",notification:A};return window.parent.postMessage(t,"*"),!0}if(!("Notification"in window)||Notification.permission!=="granted")return!1;const e=new Notification(A.title,{body:A.body,tag:A.id,data:{href:Xg(A)}});return e.onclick=()=>{window.focus(),Pa(A),e.close()},!0}function Kk(A,e){A.setQueryData(lo,t=>t&&{...t,pages:t.pages.map(s=>({...s,items:s.items.map(n=>n.id===e.sessionId?{...n,isRunning:e.status==="running"}:n)}))})}function Lk(A){try{const{hostname:e}=new URL(A);return e==="localhost"||e==="127.0.0.1"||e.startsWith("192.168.")||e.startsWith("10.")||/^172\.(1[6-9]|2\d|3[01])\./.test(e)}catch{return!1}}async function XQ(A){const e=await fetch(new URL("/openapi.json",A),{cache:"no-store",credentials:"include"});if(!e.ok)throw new Error(`Local API returned ${e.status}`)}const En=new Map,ra=new Set;function dC(A){return`otto-local-access-confirmed:${A}`}function Jk(A){try{return window.localStorage.getItem(dC(A))==="1"}catch{return!1}}function $Q(A){try{window.localStorage.setItem(dC(A),"1")}catch{}}async function Tk(A){if(op()||!Lk(A)||Jk(A)||En.has(A)||ra.has(A))return;ra.add(A);try{await XQ(A),$Q(A);return}catch{}finally{ra.delete(A)}if(En.has(A))return;const e=ge("Safari may need permission to access the local otto server.","default",0);En.set(A,e),eo.getState().updateToast(e,{action:{label:"Allow access",onClick:async()=>{await XQ(A),$Q(A),eo.getState().removeToast(e),En.delete(A),ge.success("Local otto server access confirmed.")}}})}function jk(A){const e=De(),t=m.useRef(A);return m.useEffect(()=>{t.current=A},[A]),m.useEffect(()=>{if(typeof window>"u"||window.parent!==window||!("Notification"in window)||Notification.permission!=="default"||window.localStorage.getItem("otto-notification-permission-prompted"))return;window.localStorage.setItem("otto-notification-permission-prompted","1");const s=ge("Enable browser notifications for background session updates.","default",0);eo.getState().updateToast(s,{action:{label:"Enable",onClick:async()=>{const n=await Sk(),r=Notification.permission;if(n==="granted"||r==="granted")ge.success("Browser notifications enabled.");else{if(n==="default"&&r==="default")return;ge.info("Browser notifications were not enabled.")}}}})},[]),m.useEffect(()=>{const s=new AbortController,n=Nr();return E0({baseUrl:n,onEvent:r=>{if(r.event==="heartbeat")return;let i;try{i=JSON.parse(r.data)}catch(a){console.error("[client-events] Failed to parse event:",a);return}if(r.event==="session.status"){const a=i;Kk(e,a),a.status!=="running"&&e.invalidateQueries({queryKey:lo});return}if(r.event==="notification"){const a=i,g=a.sessionId===t.current&&document.visibilityState==="visible",Q=a.source==="session"||!!a.sessionId;let B=!1;g||(B=Rk(a)),(!Q||!B&&!g)&&Uk(a)}},onError:r=>{s.signal.aborted||(console.error("[client-events] Stream error:",r),Tk(n))}},s.signal),()=>s.abort()},[e]),VB({baseUrl:Nr()})}const hC="otto-theme";function Ok(){if(typeof window>"u")return"dark";const A=window.localStorage.getItem(hC);return A==="light"||A==="dark"?A:window.matchMedia?.("(prefers-color-scheme: light)").matches?"light":"dark"}function qk(){const[A,e]=m.useState(()=>Ok());m.useEffect(()=>{if(typeof document>"u")return;const s=document.documentElement;A==="dark"?s.classList.add("dark"):s.classList.remove("dark");try{window.localStorage.setItem(hC,A)}catch(n){console.warn("Failed to persist theme preference",n)}window.parent&&window.parent!==window&&window.parent.postMessage({type:"otto-set-theme",theme:A},"*")},[A]),m.useEffect(()=>{if(typeof window>"u")return;const s=n=>{n.data?.type==="otto-set-theme"&&(n.data.theme==="light"||n.data.theme==="dark")&&e(n.data.theme)};return window.addEventListener("message",s),()=>window.removeEventListener("message",s)},[]);const t=m.useCallback(()=>{e(s=>s==="dark"?"light":"dark")},[]);return m.useMemo(()=>({theme:A,setTheme:e,toggleTheme:t}),[A,t])}function Yk(){const[A,e]=m.useState(null);return m.useEffect(()=>{(async()=>{try{const s=await Ud({baseURL:Nr()});if(s.error)throw new Error(JSON.stringify(s.error));const n=s.data;console.log("[useWorkingDirectory] Success:",n),n.dirName&&(console.log("[useWorkingDirectory] Setting title to:",n.dirName),e(n.dirName),document.title=n.dirName)}catch(s){console.error("[useWorkingDirectory] Error:",s),document.title="otto"}})()},[]),A}const Wa=gt()(rc(A=>({isCollapsed:!1,toggleCollapse:()=>A(e=>({isCollapsed:!e.isCollapsed})),setCollapsed:e=>A({isCollapsed:e})}),{name:"sidebar-storage"}));function Hk({sessionIds:A,activeSessionId:e,gitFiles:t,onSelectSession:s,onNewSession:n,onStageFile:r,onUnstageFile:i,onRestoreFile:a,onDeleteFile:g,onStageAll:Q,onUnstageAll:B,onOpenCommitModal:u,onViewDiff:E,onReturnToInput:c}){const{currentFocus:h,sessionIndex:f,gitFileIndex:d,setFocus:D,setSessionIndex:R,setGitFileIndex:M,resetGitFileIndex:q}=_g(),{setCollapsed:G,toggleCollapse:T}=Wa(),{isExpanded:Z,toggleSidebar:X}=Ye(),U=Ye(v=>v.closeDiff),O=At(v=>v.toggleSidebar),j=$e(v=>v.toggleSidebar),Y=Re(v=>v.toggleSidebar),x=Ze(v=>v.toggleSidebar),l=Pe(v=>v.toggleSidebar),I=Dt(v=>v.toggleSidebar),y=ft(v=>v.toggleSidebar),b=so(v=>v.togglePanel),J=A.indexOf(e||""),H=m.useCallback(v=>{const K=v.target,C=K.tagName==="INPUT"||K.tagName==="TEXTAREA"||K.isContentEditable,p=!!K.closest("[data-terminal-viewer]");if((v.ctrlKey||v.metaKey)&&!v.shiftKey&&!v.altKey&&v.key>="1"&&v.key<="7"){switch(v.preventDefault(),v.key){case"1":X(),Z&&h==="git"?D("input"):(D("git"),q());break;case"2":O(),D("input");break;case"3":j(),D("input");break;case"4":Y(),D("input");break;case"5":x(),D("input");break;case"6":l(),D("input");break;case"7":I(),D("input");break}return}if((v.ctrlKey||v.metaKey)&&v.key==="h"){v.preventDefault(),h==="sessions"?(document.activeElement?.blur(),D("input"),G(!0),setTimeout(()=>c?.(),50)):h==="git"?(document.activeElement?.blur(),D("input"),X(),U(),setTimeout(()=>c?.(),50)):(document.activeElement?.blur(),D("sessions"),G(!1),J>=0&&R(J));return}if((v.ctrlKey||v.metaKey)&&v.key==="l"){v.preventDefault(),h==="git"?(document.activeElement?.blur(),D("input"),X(),U(),setTimeout(()=>c?.(),50)):h==="sessions"?(document.activeElement?.blur(),D("input"),G(!0),setTimeout(()=>c?.(),50)):(document.activeElement?.blur(),Z||X(),D("git"),q());return}if((v.ctrlKey||v.metaKey)&&v.key==="/"){v.preventDefault(),T();return}if((v.ctrlKey||v.metaKey)&&v.key==="\\"){v.preventDefault(),X();return}if((v.ctrlKey||v.metaKey)&&v.key==="j"){v.preventDefault(),b();return}if((v.ctrlKey||v.metaKey)&&v.shiftKey&&v.key==="r"){v.preventDefault(),y();return}if((v.ctrlKey||v.metaKey)&&v.key==="n"){v.preventDefault(),n();return}if((v.ctrlKey||v.metaKey)&&v.key==="p"){v.preventDefault(),Ha.getState().toggle();return}if(v.key==="Escape"&&!p||v.key==="q"&&!C&&(h==="sessions"||h==="git")){v.preventDefault(),h==="sessions"?G(!0):h==="git"&&(X(),U()),D("input"),c?.();return}if(h==="sessions"&&!C){if(v.key==="j"&&A.length>0){v.preventDefault();const S=Math.min(f+1,A.length-1);R(S);return}if(v.key==="k"&&A.length>0){v.preventDefault();const S=Math.max(f-1,0);R(S);return}if(v.key==="Enter"&&A[f]){v.preventDefault(),s(A[f]),D("input");return}}if(h==="git"&&!C){if(v.key==="j"&&t.length>0){v.preventDefault();const S=Math.min(d+1,t.length-1);M(S);return}if(v.key==="k"&&t.length>0){v.preventDefault();const S=Math.max(d-1,0);M(S);return}if(v.key===" "&&t[d]){v.preventDefault();const S=t[d];S.staged?i?.(S.path):r?.(S.path);return}if(v.key==="a"){v.preventDefault(),Q?.();return}if(v.key==="u"){v.preventDefault(),B?.();return}if(v.key==="R"&&t[d]){v.preventDefault();const S=t[d];!S.staged&&S.status!=="untracked"&&S.status!=="added"&&a?.(S.path);return}if(v.shiftKey&&v.key==="D"||v.key==="Backspace"){v.preventDefault();const S=t[d];S&&!S.staged&&S.status==="untracked"&&g?.(S.path);return}if(v.key==="c"){v.preventDefault(),u?.();return}if(v.key==="Enter"&&t[d]){v.preventDefault();const S=t[d];E?.(S.path,S.staged);return}}},[h,f,d,A,t,J,Z,D,R,M,q,G,X,O,j,Y,x,l,I,b,y,T,s,n,r,i,a,g,Q,B,u,E,c,U]);return m.useEffect(()=>(window.addEventListener("keydown",H,!0),()=>window.removeEventListener("keydown",H,!0)),[H]),{currentFocus:h,sessionIndex:f,gitFileIndex:d}}function Pk(A){const e=m.useRef(null),t=m.useRef(null),s=Ne(Q=>Q.setBalance),n=Ne(Q=>Q.setPaymentPending),r=eo(Q=>Q.removeToast),i=eo(Q=>Q.updateToast),a=qn(Q=>Q.setPendingTopup),g=qn(Q=>Q.clearPendingTopup);m.useEffect(()=>{if(!A)return;const Q=new XE;e.current=Q;const B=fA.getStreamUrl(A);Q.connect(B);const u=Q.on("*",E=>{const c=E.payload;switch(E.type){case"ottorouter.topup.required":{const h=typeof c?.amountUsd=="number"?c.amountUsd:0,f=typeof c?.currentBalance=="number"?c.currentBalance:0,d=typeof c?.minTopupUsd=="number"?c.minTopupUsd:5,D=typeof c?.suggestedTopupUsd=="number"?c.suggestedTopupUsd:10,R=typeof c?.messageId=="string"?c.messageId:"";a({sessionId:A,messageId:R,amountUsd:h,currentBalance:f,minTopupUsd:d,suggestedTopupUsd:D});break}case"ottorouter.topup.method_selected":{c?.method==="crypto"&&(n(!0),t.current=ge.loading("💳 Processing crypto payment..."));break}case"ottorouter.topup.cancelled":{g();const h=typeof c?.reason=="string"?c.reason:"Request cancelled";ge(`⚠️ ${h}`);break}case"ottorouter.payment.required":{const h=typeof c?.amountUsd=="number"?c.amountUsd:0;n(!0),t.current||(t.current=ge.loading(`💳 Payment required: $${h.toFixed(2)}`));break}case"ottorouter.payment.signing":{t.current?i(t.current,{message:"✍️ Signing transaction..."}):t.current=ge.loading("✍️ Signing transaction...");break}case"ottorouter.payment.complete":{g();const h=c?.amountUsd,f=c?.newBalance,d=typeof c?.transactionId=="string"?c.transactionId:void 0,D=typeof h=="number"?h:typeof h=="string"?parseFloat(h):0,R=typeof f=="number"?f:typeof f=="string"?parseFloat(f):0;s(R),n(!1),t.current&&(r(t.current),t.current=null);const M=`✅ Paid $${D.toFixed(2)}`;d?ge.successWithAction(M,{label:"View Tx",href:`https://orbmarkets.io/tx/${d}`}):ge.success(M);break}case"ottorouter.fiat.checkout_created":{g(),n(!1),t.current&&(r(t.current),t.current=null),ge.success("💳 Complete payment, then retry your message");break}case"ottorouter.balance.updated":{const h=c?.balanceRemaining,f=typeof h=="number"?h:typeof h=="string"?parseFloat(h):null;f!==null&&!Number.isNaN(f)&&s(f);break}case"ottorouter.payment.error":{g();const h=typeof c?.error=="string"?c.error:"Payment failed";n(!1),t.current&&(r(t.current),t.current=null),ge.error(`❌ ${h}`);break}}});return()=>{u(),Q.disconnect()}},[A,s,n,r,i,a,g])}const pi=yC({component:Wk});function Wk(){const{checkOnboarding:A}=Zg();return m.useEffect(()=>{A()},[A]),o.jsxs(o.Fragment,{children:[o.jsx(NC,{}),o.jsx(Gk,{}),o.jsx(Vg,{}),null]})}const zk=Va("/")({beforeLoad:()=>{throw kC({to:"/sessions"})},component:()=>null});function AB({height:A=16,className:e=""}){const t=Math.round(A*2.4686468646864688);return o.jsx("svg",{width:t,height:A,viewBox:"0 0 748 303",fill:"currentColor",className:e,"aria-label":"otto",role:"img",children:o.jsx("path",{d:"M192.877 257.682C192.877 263.287 191.783 268.551 189.596 273.473C187.545 278.395 184.674 282.701 180.982 286.393C177.428 289.947 173.189 292.818 168.268 295.006C163.482 297.057 158.287 298.082 152.682 298.082H44.1953C38.7266 298.082 33.5312 297.057 28.6094 295.006C23.6875 292.818 19.3809 289.947 15.6895 286.393C12.1348 282.701 9.26367 278.395 7.07617 273.473C5.02539 268.551 4 263.287 4 257.682V120.074C4 114.469 5.02539 109.205 7.07617 104.283C9.26367 99.3613 12.1348 95.123 15.6895 91.5684C19.3809 87.877 23.6875 85.0059 28.6094 82.9551C33.5312 80.7676 38.7266 79.6738 44.1953 79.6738H152.682C158.287 79.6738 163.482 80.7676 168.268 82.9551C173.189 85.0059 177.428 87.877 180.982 91.5684C184.674 95.123 187.545 99.3613 189.596 104.283C191.783 109.205 192.877 114.469 192.877 120.074V257.682ZM44.1953 120.074V257.682H152.682V120.074H44.1953ZM331.715 4V298.082H289.674V46.041H239.225V4H331.715ZM478.961 4V298.082H436.92V46.041H386.471V4H478.961ZM743.717 257.682C743.717 263.287 742.623 268.551 740.436 273.473C738.385 278.395 735.514 282.701 731.822 286.393C728.268 289.947 724.029 292.818 719.107 295.006C714.322 297.057 709.127 298.082 703.521 298.082H595.035C589.566 298.082 584.371 297.057 579.449 295.006C574.527 292.818 570.221 289.947 566.529 286.393C562.975 282.701 560.104 278.395 557.916 273.473C555.865 268.551 554.84 263.287 554.84 257.682V120.074C554.84 114.469 555.865 109.205 557.916 104.283C560.104 99.3613 562.975 95.123 566.529 91.5684C570.221 87.877 574.527 85.0059 579.449 82.9551C584.371 80.7676 589.566 79.6738 595.035 79.6738H703.521C709.127 79.6738 714.322 80.7676 719.107 82.9551C724.029 85.0059 728.268 87.877 731.822 91.5684C735.514 95.123 738.385 99.3613 740.436 104.283C742.623 109.205 743.717 114.469 743.717 120.074V257.682ZM595.035 120.074V257.682H703.521V120.074H595.035Z"})})}const eB="left-sidebar",tB=272,Vk=256,_k=480,Zk=m.memo(function({children:e,onNewSession:t}){const s=Wa(a=>a.isCollapsed),n=Wa(a=>a.toggleCollapse),i={"--expanded-sidebar-width":`${Xo(a=>a.widths[eB]??tB)}px`,maxWidth:"100%"};return m.useEffect(()=>(s?document.body.style.overflow="":document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[s]),o.jsxs(o.Fragment,{children:[o.jsx("aside",{className:`relative z-50 shrink-0 overflow-hidden border-r transition-[width,background-color,border-color] duration-300 ease-out fixed md:relative top-0 left-0 h-screen md:h-auto w-full ${s?"hidden md:flex md:w-12 border-border bg-background":"flex md:w-[var(--expanded-sidebar-width)] border-sidebar-border sidebar-fade-in"}`,style:i,children:s?o.jsxs("div",{className:"flex h-full w-full flex-col",children:[o.jsx("div",{className:"h-12 border-b border-border flex items-center justify-center",children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:t,title:"New session",className:"h-8 w-8 rounded-md touch-manipulation text-muted-foreground hover:bg-muted/50",children:o.jsx(Bo,{className:"size-[18px]"})})}),o.jsx("button",{type:"button",className:"flex-1 cursor-pointer hover:bg-muted/50 transition-colors touch-manipulation",onClick:n,title:"Expand sidebar","aria-label":"Expand sidebar"}),o.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:n,title:"Expand sidebar",className:"h-8 w-8 transition-transform duration-200 hover:scale-110 touch-manipulation text-muted-foreground hover:bg-muted/50",children:o.jsx(Ut,{className:"size-[18px]"})})})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"flex h-full w-full md:w-[var(--expanded-sidebar-width)] flex-col min-w-0 relative",children:[o.jsxs("div",{className:"h-14 border-b border-sidebar-border px-4 flex items-center gap-2 md:hidden bg-sidebar",children:[o.jsx(fe,{variant:"ghost",size:"icon",onClick:n,title:"Close menu",className:"touch-manipulation flex-shrink-0 text-sidebar-foreground hover:bg-sidebar-accent","aria-label":"Close menu",children:o.jsx(et,{className:"w-5 h-5"})}),o.jsx("div",{className:"flex-1 flex items-center",children:o.jsx(AB,{height:14,className:"text-sidebar-foreground"})})]}),o.jsxs("div",{className:"flex-1 relative overflow-hidden",children:[o.jsx("div",{className:"absolute top-0 left-0 right-0 z-10 pointer-events-none",children:o.jsxs("div",{className:"h-12 px-3 flex items-center justify-between border-b border-sidebar-border/40 bg-sidebar/40 backdrop-blur-xl supports-[backdrop-filter]:bg-sidebar/20",children:[o.jsx("div",{className:"flex items-center text-sidebar-foreground/90",children:o.jsx(AB,{height:14,className:"select-none"})}),o.jsx("button",{type:"button",onClick:t,className:"w-8 h-8 rounded-full bg-sidebar-primary flex items-center justify-center hover:opacity-90 transition-opacity touch-manipulation pointer-events-auto",title:"New session",children:o.jsx(Bo,{className:"w-4 h-4 text-sidebar-primary-foreground"})})]})}),o.jsx("div",{className:"absolute inset-0 overflow-hidden",children:e})]}),o.jsx("div",{className:"h-12 border-t border-sidebar-border px-2 flex items-center justify-end",children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:n,title:"Collapse sidebar",className:"transition-transform duration-200 hover:scale-110 touch-manipulation text-sidebar-muted-foreground hover:bg-sidebar-accent w-8 h-8",children:o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"transition-transform duration-300",role:"img","aria-label":"Collapse sidebar",children:[o.jsx("title",{children:"Collapse sidebar"}),o.jsx("path",{d:"M15 18l-6-6 6-6"})]})})})]}),o.jsx("div",{className:"hidden md:block",children:o.jsx(tr,{panelKey:eB,side:"left",minWidth:Vk,maxWidth:_k,defaultWidth:tB})})]})}),!s&&o.jsx("div",{className:"fixed inset-0 bg-black/50 z-40 md:hidden",onClick:n,"aria-hidden":"true"})]})}),oB="clamp(360px, 28vw, 520px)",ur=320,Xk=m.memo(function({sidebar:e,children:t,onNewSession:s,theme:n,onToggleTheme:r,sessionId:i,onFixWithAI:a}){const g=Ye(b=>b.isExpanded),Q=At(b=>b.isExpanded),B=Dt(b=>b.isExpanded),u=Re(b=>b.isExpanded),E=$e(b=>b.isExpanded),c=Ze(b=>b.isExpanded),h=Pe(b=>b.isExpanded),f=Ht(b=>b.tabs.length),d=Xo(b=>b.widths),D=g||Q||B||u||E||c||h,R=f>0,M=g?d.git??ur:Q?d["session-files"]??ur:B?d.settings??ur:E?d["file-browser"]??ur:ur,q=m.useRef(R),G=m.useRef(D),[T,Z]=m.useState(D),[X,U]=m.useState(D?M:0),[O,j]=m.useState(!1),Y=q.current!==R,x={width:R?oB:"100%"},l={width:R?`calc(100% - ${oB})`:"0px"},I={width:`${X}px`},y=D||T;return m.useEffect(()=>{const b=G.current;if(D){b||(j(!0),U(0)),Z(!0);const H=requestAnimationFrame(()=>{U(M)}),v=window.setTimeout(()=>{j(!1)},300);return G.current=!0,()=>{cancelAnimationFrame(H),window.clearTimeout(v)}}if(!b){U(0);return}j(!0),U(0);const J=window.setTimeout(()=>{Z(!1),j(!1)},300);return G.current=!1,()=>window.clearTimeout(J)},[D,M]),m.useEffect(()=>{q.current=R},[R]),o.jsxs("div",{className:"h-screen flex bg-background touch-manipulation border-t border-border/50",children:[o.jsx(Zk,{onNewSession:s,children:e}),o.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden w-full md:w-auto",children:[o.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[o.jsxs("div",{className:"flex min-w-0 flex-1 overflow-hidden",children:[o.jsx("main",{className:`relative shrink-0 flex-col overflow-hidden min-w-0 ${Y?"transition-[width] duration-300 ease-out":"transition-none"} ${R?"hidden md:flex md:min-w-[320px]":"flex"}`,style:x,children:t}),o.jsx("section",{className:`hidden md:flex shrink-0 min-w-0 overflow-hidden border-l bg-sidebar ${R?"border-sidebar-border opacity-100":"border-transparent opacity-0"} ${Y?"transition-[width,opacity,border-color] duration-300 ease-out":"transition-none"}`,style:l,"aria-hidden":!R,children:R&&o.jsx(Mk,{})})]}),o.jsxs("div",{className:"hidden md:flex",children:[o.jsx("div",{className:`h-full shrink-0 overflow-hidden bg-sidebar ${O?"transition-[width] duration-300 ease-out":"transition-none"}`,style:I,"aria-hidden":!y,children:o.jsxs("div",{className:"h-full w-full",children:[o.jsx(My,{onFixWithAI:a}),o.jsx(qy,{sessionId:i}),o.jsx(fN,{}),o.jsx(GN,{}),o.jsx(Ek,{}),o.jsx(_N,{}),o.jsx(sk,{})]})}),o.jsxs("div",{className:`flex flex-col w-12 border-l ${D?"sidebar-fade-in border-sidebar-border":"bg-background border-border"}`,children:[o.jsx(Fy,{}),o.jsx(Yy,{sessionId:i}),o.jsx(Ck,{}),o.jsx(SN,{}),o.jsx(ZN,{}),o.jsx(rk,{}),o.jsx(xN,{}),o.jsx("div",{className:"flex-1"}),o.jsx(V0,{}),o.jsx("div",{className:"h-12 border-t border-border flex items-center justify-center",children:o.jsx(fe,{variant:"ghost",size:"icon",onClick:r,title:`Switch to ${n==="dark"?"light":"dark"} mode`,"aria-label":`Switch to ${n==="dark"?"light":"dark"} mode`,className:"touch-manipulation",children:n==="dark"?o.jsx(gu,{className:"w-4 h-4"}):o.jsx(lu,{className:"w-4 h-4"})})})]})]})]}),o.jsx(z0,{})]}),o.jsx(Uy,{}),o.jsx(Z0,{}),o.jsx(fk,{})]})});function pC({sessionId:A}){const e=m.useRef(null),t=Wf(),{data:s}=As(),{theme:n,toggleTheme:r}=qk(),{openCommitModal:i,openDiff:a}=Ye(),g=MC(),{data:Q=[]}=ri(),{data:B}=ni(),u=ii(),E=Dg(),c=Dc(),h=yc(),f=ug(U=>U.openConfirmation);Yk(),jk(A),Pk(A),Ii(s?.defaults?.provider);const d=m.useCallback(()=>{setTimeout(()=>{e.current?.focus()},100)},[]),D=m.useCallback(()=>{g({to:"/sessions"})},[g]),R=m.useCallback(U=>{g({to:"/sessions/$sessionId",params:{sessionId:U},replace:!1}),d()},[g,d]),M=m.useCallback(()=>{g({to:"/sessions"})},[g]),q=m.useCallback(U=>{g({to:"/sessions/$sessionId",params:{sessionId:U}}),d()},[g,d]),G=m.useCallback(async U=>{try{const O=await t.mutateAsync({agent:s?.defaults.agent||"general",provider:s?.defaults.provider,model:s?.defaults.model,title:"Fix Git Error"});g({to:"/sessions/$sessionId",params:{sessionId:O.id},replace:!1}),await fA.sendMessage(O.id,{content:U})}catch(O){console.error("Failed to create fix session:",O)}},[t,s,g]),T=m.useMemo(()=>B?[...(B.conflicted??[]).map(U=>({path:U.path,staged:!1,status:U.status})),...B.staged.map(U=>({path:U.path,staged:!0,status:U.status})),...B.unstaged.map(U=>({path:U.path,staged:!1,status:U.status})),...B.untracked.map(U=>({path:U.path,staged:!1,status:U.status}))]:[],[B]),Z=m.useMemo(()=>Q.map(U=>U.id),[Q]);Hk({sessionIds:Z,activeSessionId:A,gitFiles:T,onSelectSession:q,onNewSession:D,onStageFile:U=>u.mutate([U]),onUnstageFile:U=>E.mutate([U]),onRestoreFile:U=>c.mutate([U]),onDeleteFile:U=>{f({title:"Delete File",message:`Delete ${U}? This will permanently remove the untracked file.`,confirmLabel:"Delete",variant:"destructive",onConfirm:async()=>{await h.mutateAsync([U])}})},onStageAll:()=>{const U=T.filter(O=>!O.staged).map(O=>O.path);U.length>0&&u.mutate(U)},onUnstageAll:()=>{const U=T.filter(O=>O.staged).map(O=>O.path);U.length>0&&E.mutate(U)},onOpenCommitModal:i,onViewDiff:a,onReturnToInput:d}),m.useEffect(()=>{A&&d()},[A,d]),m.useEffect(()=>{const U=window,O=j=>{q(j)};return U.OTTO_OPEN_SESSION=O,()=>{U.OTTO_OPEN_SESSION===O&&delete U.OTTO_OPEN_SESSION}},[q]),m.useEffect(()=>{const U=O=>{O.data?.type==="otto-navigate-session"&&typeof O.data.sessionId=="string"&&(window.parent?.postMessage({type:"otto-navigate-session-ack",sessionId:O.data.sessionId},"*"),g({to:"/sessions/$sessionId",params:{sessionId:O.data.sessionId}}),d())};return window.addEventListener("message",U),()=>window.removeEventListener("message",U)},[g,d]);const X=m.useMemo(()=>A?o.jsxs(o.Fragment,{children:[o.jsx(Qy,{sessionId:A,onSelectSession:q}),o.jsx(Nm,{ref:e,sessionId:A,onNewSession:D,onDeleteSession:M})]}):o.jsx(Mm,{onSessionCreated:R}),[A,D,q,M,R]);return o.jsxs(o.Fragment,{children:[o.jsx(Xk,{onNewSession:D,theme:n,onToggleTheme:r,sessionId:A,onNavigateToSession:q,onFixWithAI:G,sidebar:o.jsx(Iy,{activeSessionId:A,onSelectSession:q}),children:X}),o.jsx(ip,{})]})}const $k=Va("/sessions/")({component:AM});function AM(){return o.jsx(pC,{})}const fC=Va("/sessions/$sessionId")({component:eM});function eM(){const{sessionId:A}=fC.useParams();return o.jsx(pC,{sessionId:A})}const tM=zk.update({id:"/",path:"/",getParentRoute:()=>pi}),oM=$k.update({id:"/sessions/",path:"/sessions/",getParentRoute:()=>pi}),sM=fC.update({id:"/sessions/$sessionId",path:"/sessions/$sessionId",getParentRoute:()=>pi}),rM={IndexRoute:tM,SessionsSessionIdRoute:sM,SessionsIndexRoute:oM},nM=pi._addFileChildren(rM)._addFileTypes(),iM=()=>{const t=(typeof globalThis<"u"?globalThis.OTTO_ROUTER_BASEPATH:void 0)??"/"??"/";if(!t||t==="/")return"/";const s=t.replace(/\/+$/,"")||"/";return s.startsWith("/")?s:`/${s}`},aM=bC({routeTree:nM,basepath:iM()}),$g=new FC({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1,structuralSharing:!0}}});$g.prefetchQuery({queryKey:["sessions"],queryFn:()=>fA.getSessions()});$g.prefetchQuery({queryKey:["config"],queryFn:()=>fA.getConfig()});function gM(){return o.jsx(vC,{client:$g,children:o.jsx(GC,{router:aM})})}const mC=document.getElementById("root");if(!mC)throw new Error("Root element not found");SC.createRoot(mC).render(o.jsx(m.StrictMode,{children:o.jsx(gM,{})}));