@iflow-ai/iflow-cli 0.2.13 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bundle/iflow.js
CHANGED
|
@@ -471,7 +471,7 @@ ${e.format(r)}`.trim())}};okt.exports=BUe});var MUe=B((sNo,lkt)=>{"use strict";v
|
|
|
471
471
|
LIMIT ?
|
|
472
472
|
)
|
|
473
473
|
`)}close(){this.#r.close()}get(e){tQe(e);let r=this.#g(e);return r?{body:r.body?Buffer.from(r.body.buffer,r.body.byteOffset,r.body.byteLength):void 0,statusCode:r.statusCode,statusMessage:r.statusMessage,headers:r.headers?JSON.parse(r.headers):void 0,etag:r.etag?r.etag:void 0,vary:r.vary?JSON.parse(r.vary):void 0,cacheControlDirectives:r.cacheControlDirectives?JSON.parse(r.cacheControlDirectives):void 0,cachedAt:r.cachedAt,staleAt:r.staleAt,deleteAt:r.deleteAt}:void 0}set(e,r){tQe(e);let n=this.#p(e),i=Array.isArray(r.body)?Buffer.concat(r.body):r.body,o=i?.byteLength;if(o&&o>this.#e)return;let s=this.#g(e,!0);s?this.#o.run(i,r.deleteAt,r.statusCode,r.statusMessage,r.headers?JSON.stringify(r.headers):null,r.etag?r.etag:null,r.cacheControlDirectives?JSON.stringify(r.cacheControlDirectives):null,r.cachedAt,r.staleAt,s.id):(this.#l(),this.#i.run(n,e.method,i,r.deleteAt,r.statusCode,r.statusMessage,r.headers?JSON.stringify(r.headers):null,r.etag?r.etag:null,r.cacheControlDirectives?JSON.stringify(r.cacheControlDirectives):null,r.vary?JSON.stringify(r.vary):null,r.cachedAt,r.staleAt))}createWriteStream(e,r){tQe(e),wOn(r);let n=0,i=[],o=this;return new SOn({decodeStrings:!0,write(s,a,c){n+=s.byteLength,n<o.#e?i.push(s):this.destroy(),c()},final(s){o.set(e,{...r,body:i}),s()}})}delete(e){if(typeof e!="object")throw new TypeError(`expected key to be object, got ${typeof e}`);this.#s.run(this.#p(e))}#l(){if(Number.isFinite(this.#t)&&this.size<=this.#t)return 0;{let e=this.#c.run(Date.now()).changes;if(e)return e}{let e=this.#u?.run(Math.max(Math.floor(this.#t*.1),1)).changes;if(e)return e}return 0}get size(){let{total:e}=this.#a.get();return e}#p(e){return`${e.origin}/${e.path}`}#g(e,r=!1){let n=this.#p(e),{headers:i,method:o}=e,s=this.#n.all(n,o);if(s.length===0)return;let a=Date.now();for(let c of s){if(a>=c.deleteAt&&!r)return;let u=!0;if(c.vary){let f=JSON.parse(c.vary);for(let d in f)if(!xOn(i[d],f[d])){u=!1;break}}if(u)return c}}};function xOn(t,e){return t==null&&e==null?!0:t==null&&e!=null||t!=null&&e==null?!1:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,n)=>r===e[n]):t===e}});var NN=B((TNo,vLt)=>{"use strict";var{kConstruct:TOn}=Fc(),{kEnumerableProperty:lH}=jo(),{iteratorMixin:DOn,isValidHeaderName:XZ,isValidHeaderValue:mLt}=Pg(),{webidl:ya}=u2(),nQe=we("node:assert"),d2e=we("node:util");function hLt(t){return t===10||t===13||t===9||t===32}function gLt(t){let e=0,r=t.length;for(;r>e&&hLt(t.charCodeAt(r-1));)--r;for(;r>e&&hLt(t.charCodeAt(e));)++e;return e===0&&r===t.length?t:t.substring(e,r)}function ALt(t,e){if(Array.isArray(e))for(let r=0;r<e.length;++r){let n=e[r];if(n.length!==2)throw ya.errors.exception({header:"Headers constructor",message:`expected name/value pair to be length 2, found ${n.length}.`});iQe(t,n[0],n[1])}else if(typeof e=="object"&&e!==null){let r=Object.keys(e);for(let n=0;n<r.length;++n)iQe(t,r[n],e[r[n]])}else throw ya.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]})}function iQe(t,e,r){if(r=gLt(r),XZ(e)){if(!mLt(r))throw ya.errors.invalidArgument({prefix:"Headers.append",value:r,type:"header value"})}else throw ya.errors.invalidArgument({prefix:"Headers.append",value:e,type:"header name"});if(ELt(t)==="immutable")throw new TypeError("immutable");return h2e(t).append(e,r,!1)}function IOn(t){let e=h2e(t);if(!e)return[];if(e.sortedMap)return e.sortedMap;let r=[],n=e.toSortedArray(),i=e.cookies;if(i===null||i.length===1)return e.sortedMap=n;for(let o=0;o<n.length;++o){let{0:s,1:a}=n[o];if(s==="set-cookie")for(let c=0;c<i.length;++c)r.push([s,i[c]]);else r.push([s,a])}return e.sortedMap=r}function yLt(t,e){return t[0]<e[0]?-1:1}var p2e=class t{cookies=null;sortedMap;headersMap;constructor(e){e instanceof t?(this.headersMap=new Map(e.headersMap),this.sortedMap=e.sortedMap,this.cookies=e.cookies===null?null:[...e.cookies]):(this.headersMap=new Map(e),this.sortedMap=null)}contains(e,r){return this.headersMap.has(r?e:e.toLowerCase())}clear(){this.headersMap.clear(),this.sortedMap=null,this.cookies=null}append(e,r,n){this.sortedMap=null;let i=n?e:e.toLowerCase(),o=this.headersMap.get(i);if(o){let s=i==="cookie"?"; ":", ";this.headersMap.set(i,{name:o.name,value:`${o.value}${s}${r}`})}else this.headersMap.set(i,{name:e,value:r});i==="set-cookie"&&(this.cookies??=[]).push(r)}set(e,r,n){this.sortedMap=null;let i=n?e:e.toLowerCase();i==="set-cookie"&&(this.cookies=[r]),this.headersMap.set(i,{name:e,value:r})}delete(e,r){this.sortedMap=null,r||(e=e.toLowerCase()),e==="set-cookie"&&(this.cookies=null),this.headersMap.delete(e)}get(e,r){return this.headersMap.get(r?e:e.toLowerCase())?.value??null}*[Symbol.iterator](){for(let{0:e,1:{value:r}}of this.headersMap)yield[e,r]}get entries(){let e={};if(this.headersMap.size!==0)for(let{name:r,value:n}of this.headersMap.values())e[r]=n;return e}rawValues(){return this.headersMap.values()}get entriesList(){let e=[];if(this.headersMap.size!==0)for(let{0:r,1:{name:n,value:i}}of this.headersMap)if(r==="set-cookie")for(let o of this.cookies)e.push([n,o]);else e.push([n,i]);return e}toSortedArray(){let e=this.headersMap.size,r=new Array(e);if(e<=32){if(e===0)return r;let n=this.headersMap[Symbol.iterator](),i=n.next().value;r[0]=[i[0],i[1].value],nQe(i[1].value!==null);for(let o=1,s=0,a=0,c=0,u=0,f,d;o<e;++o){for(d=n.next().value,f=r[o]=[d[0],d[1].value],nQe(f[1]!==null),c=0,a=o;c<a;)u=c+(a-c>>1),r[u][0]<=f[0]?c=u+1:a=u;if(o!==u){for(s=o;s>c;)r[s]=r[--s];r[c]=f}}if(!n.next().done)throw new TypeError("Unreachable");return r}else{let n=0;for(let{0:i,1:{value:o}}of this.headersMap)r[n++]=[i,o],nQe(o!==null);return r.sort(yLt)}}},w5=class t{#e;#t;constructor(e=void 0){ya.util.markAsUncloneable(this),e!==TOn&&(this.#t=new p2e,this.#e="none",e!==void 0&&(e=ya.converters.HeadersInit(e,"Headers constructor","init"),ALt(this,e)))}append(e,r){ya.brandCheck(this,t),ya.argumentLengthCheck(arguments,2,"Headers.append");let n="Headers.append";return e=ya.converters.ByteString(e,n,"name"),r=ya.converters.ByteString(r,n,"value"),iQe(this,e,r)}delete(e){if(ya.brandCheck(this,t),ya.argumentLengthCheck(arguments,1,"Headers.delete"),e=ya.converters.ByteString(e,"Headers.delete","name"),!XZ(e))throw ya.errors.invalidArgument({prefix:"Headers.delete",value:e,type:"header name"});if(this.#e==="immutable")throw new TypeError("immutable");this.#t.contains(e,!1)&&this.#t.delete(e,!1)}get(e){ya.brandCheck(this,t),ya.argumentLengthCheck(arguments,1,"Headers.get");let r="Headers.get";if(e=ya.converters.ByteString(e,r,"name"),!XZ(e))throw ya.errors.invalidArgument({prefix:r,value:e,type:"header name"});return this.#t.get(e,!1)}has(e){ya.brandCheck(this,t),ya.argumentLengthCheck(arguments,1,"Headers.has");let r="Headers.has";if(e=ya.converters.ByteString(e,r,"name"),!XZ(e))throw ya.errors.invalidArgument({prefix:r,value:e,type:"header name"});return this.#t.contains(e,!1)}set(e,r){ya.brandCheck(this,t),ya.argumentLengthCheck(arguments,2,"Headers.set");let n="Headers.set";if(e=ya.converters.ByteString(e,n,"name"),r=ya.converters.ByteString(r,n,"value"),r=gLt(r),XZ(e)){if(!mLt(r))throw ya.errors.invalidArgument({prefix:n,value:r,type:"header value"})}else throw ya.errors.invalidArgument({prefix:n,value:e,type:"header name"});if(this.#e==="immutable")throw new TypeError("immutable");this.#t.set(e,r,!1)}getSetCookie(){ya.brandCheck(this,t);let e=this.#t.cookies;return e?[...e]:[]}[d2e.inspect.custom](e,r){return r.depth??=e,`Headers ${d2e.formatWithOptions(r,this.#t.entries)}`}static getHeadersGuard(e){return e.#e}static setHeadersGuard(e,r){e.#e=r}static getHeadersList(e){return e.#t}static setHeadersList(e,r){e.#t=r}},{getHeadersGuard:ELt,setHeadersGuard:ROn,getHeadersList:h2e,setHeadersList:BOn}=w5;Reflect.deleteProperty(w5,"getHeadersGuard");Reflect.deleteProperty(w5,"setHeadersGuard");Reflect.deleteProperty(w5,"getHeadersList");Reflect.deleteProperty(w5,"setHeadersList");DOn("Headers",w5,IOn,0,1);Object.defineProperties(w5.prototype,{append:lH,delete:lH,get:lH,has:lH,set:lH,getSetCookie:lH,[Symbol.toStringTag]:{value:"Headers",configurable:!0},[d2e.inspect.custom]:{enumerable:!1}});ya.converters.HeadersInit=function(t,e,r){if(ya.util.Type(t)===ya.util.Types.OBJECT){let n=Reflect.get(t,Symbol.iterator);if(!d2e.types.isProxy(t)&&n===w5.prototype.entries)try{return h2e(t).entriesList}catch{}return typeof n=="function"?ya.converters["sequence<sequence<ByteString>>"](t,e,r,n.bind(t)):ya.converters["record<ByteString, ByteString>"](t,e,r)}throw ya.errors.conversionFailed({prefix:"Headers constructor",argument:"Argument 1",types:["sequence<sequence<ByteString>>","record<ByteString, ByteString>"]})};vLt.exports={fill:ALt,compareHeaderName:yLt,Headers:w5,HeadersList:p2e,getHeadersGuard:ELt,setHeadersGuard:ROn,setHeadersList:BOn,getHeadersList:h2e}});var eee=B((DNo,BLt)=>{"use strict";var{Headers:wLt,HeadersList:bLt,fill:NOn,getHeadersGuard:OOn,setHeadersGuard:xLt,setHeadersList:TLt}=NN(),{extractBody:CLt,cloneBody:MOn,mixinBody:kOn,streamRegistry:DLt,bodyUnusable:LOn}=Gq(),ILt=jo(),oQe=we("node:util"),{kEnumerableProperty:O3}=ILt,{isValidReasonPhrase:POn,isCancelled:FOn,isAborted:UOn,serializeJavascriptValueToJSONString:QOn,isErrorLike:qOn,isomorphicEncode:HOn,environmentSettingsObject:GOn}=Pg(),{redirectStatusSet:jOn,nullBodyStatus:VOn}=vZ(),{webidl:fa}=u2(),{URLSerializer:_Lt}=D3(),{kConstruct:g2e}=Fc(),sQe=we("node:assert"),{isArrayBuffer:$On}=oQe.types,WOn=new TextEncoder("utf-8"),M3=class t{#e;#t;static error(){return ZZ(A2e(),"immutable")}static json(e,r=void 0){fa.argumentLengthCheck(arguments,1,"Response.json"),r!==null&&(r=fa.converters.ResponseInit(r));let n=WOn.encode(QOn(e)),i=CLt(n),o=ZZ(cH({}),"response");return SLt(o,r,{body:i[0],type:"application/json"}),o}static redirect(e,r=302){fa.argumentLengthCheck(arguments,1,"Response.redirect"),e=fa.converters.USVString(e),r=fa.converters["unsigned short"](r);let n;try{n=new URL(e,GOn.settingsObject.baseUrl)}catch(s){throw new TypeError(`Failed to parse URL from ${e}`,{cause:s})}if(!jOn.has(r))throw new RangeError(`Invalid status code ${r}`);let i=ZZ(cH({}),"immutable");i.#t.status=r;let o=HOn(_Lt(n));return i.#t.headersList.append("location",o,!0),i}constructor(e=null,r=void 0){if(fa.util.markAsUncloneable(this),e===g2e)return;e!==null&&(e=fa.converters.BodyInit(e)),r=fa.converters.ResponseInit(r),this.#t=cH({}),this.#e=new wLt(g2e),xLt(this.#e,"response"),TLt(this.#e,this.#t.headersList);let n=null;if(e!=null){let[i,o]=CLt(e);n={body:i,type:o}}SLt(this,r,n)}get type(){return fa.brandCheck(this,t),this.#t.type}get url(){fa.brandCheck(this,t);let e=this.#t.urlList,r=e[e.length-1]??null;return r===null?"":_Lt(r,!0)}get redirected(){return fa.brandCheck(this,t),this.#t.urlList.length>1}get status(){return fa.brandCheck(this,t),this.#t.status}get ok(){return fa.brandCheck(this,t),this.#t.status>=200&&this.#t.status<=299}get statusText(){return fa.brandCheck(this,t),this.#t.statusText}get headers(){return fa.brandCheck(this,t),this.#e}get body(){return fa.brandCheck(this,t),this.#t.body?this.#t.body.stream:null}get bodyUsed(){return fa.brandCheck(this,t),!!this.#t.body&&ILt.isDisturbed(this.#t.body.stream)}clone(){if(fa.brandCheck(this,t),LOn(this.#t))throw fa.errors.exception({header:"Response.clone",message:"Body has already been consumed."});let e=aQe(this.#t);return this.#t.body?.stream&&DLt.register(this,new WeakRef(this.#t.body.stream)),ZZ(e,OOn(this.#e))}[oQe.inspect.custom](e,r){r.depth===null&&(r.depth=2),r.colors??=!0;let n={status:this.status,statusText:this.statusText,headers:this.headers,body:this.body,bodyUsed:this.bodyUsed,ok:this.ok,redirected:this.redirected,type:this.type,url:this.url};return`Response ${oQe.formatWithOptions(r,n)}`}static getResponseHeaders(e){return e.#e}static setResponseHeaders(e,r){e.#e=r}static getResponseState(e){return e.#t}static setResponseState(e,r){e.#t=r}},{getResponseHeaders:YOn,setResponseHeaders:zOn,getResponseState:ON,setResponseState:JOn}=M3;Reflect.deleteProperty(M3,"getResponseHeaders");Reflect.deleteProperty(M3,"setResponseHeaders");Reflect.deleteProperty(M3,"getResponseState");Reflect.deleteProperty(M3,"setResponseState");kOn(M3,ON);Object.defineProperties(M3.prototype,{type:O3,url:O3,status:O3,ok:O3,redirected:O3,statusText:O3,headers:O3,clone:O3,body:O3,bodyUsed:O3,[Symbol.toStringTag]:{value:"Response",configurable:!0}});Object.defineProperties(M3,{json:O3,redirect:O3,error:O3});function aQe(t){if(t.internalResponse)return RLt(aQe(t.internalResponse),t.type);let e=cH({...t,body:null});return t.body!=null&&(e.body=MOn(t.body)),e}function cH(t){return{aborted:!1,rangeRequested:!1,timingAllowPassed:!1,requestIncludesCredentials:!1,type:"default",status:200,timingInfo:null,cacheState:"",statusText:"",...t,headersList:t?.headersList?new bLt(t?.headersList):new bLt,urlList:t?.urlList?[...t.urlList]:[]}}function A2e(t){let e=qOn(t);return cH({type:"error",status:0,error:e?t:new Error(t&&String(t)),aborted:t&&t.name==="AbortError"})}function KOn(t){return t.type==="error"&&t.status===0}function m2e(t,e){return e={internalResponse:t,...e},new Proxy(t,{get(r,n){return n in e?e[n]:r[n]},set(r,n,i){return sQe(!(n in e)),r[n]=i,!0}})}function RLt(t,e){if(e==="basic")return m2e(t,{type:"basic",headersList:t.headersList});if(e==="cors")return m2e(t,{type:"cors",headersList:t.headersList});if(e==="opaque")return m2e(t,{type:"opaque",urlList:Object.freeze([]),status:0,statusText:"",body:null});if(e==="opaqueredirect")return m2e(t,{type:"opaqueredirect",status:0,statusText:"",headersList:[],body:null});sQe(!1)}function XOn(t,e=null){return sQe(FOn(t)),UOn(t)?A2e(Object.assign(new DOMException("The operation was aborted.","AbortError"),{cause:e})):A2e(Object.assign(new DOMException("Request was cancelled."),{cause:e}))}function SLt(t,e,r){if(e.status!==null&&(e.status<200||e.status>599))throw new RangeError('init["status"] must be in the range of 200 to 599, inclusive.');if("statusText"in e&&e.statusText!=null&&!POn(String(e.statusText)))throw new TypeError("Invalid statusText");if("status"in e&&e.status!=null&&(ON(t).status=e.status),"statusText"in e&&e.statusText!=null&&(ON(t).statusText=e.statusText),"headers"in e&&e.headers!=null&&NOn(YOn(t),e.headers),r){if(VOn.includes(t.status))throw fa.errors.exception({header:"Response constructor",message:`Invalid response status code ${t.status}`});ON(t).body=r.body,r.type!=null&&!ON(t).headersList.contains("content-type",!0)&&ON(t).headersList.append("content-type",r.type,!0)}}function ZZ(t,e){let r=new M3(g2e);JOn(r,t);let n=new wLt(g2e);return zOn(r,n),TLt(n,t.headersList),xLt(n,e),t.body?.stream&&DLt.register(r,new WeakRef(t.body.stream)),r}fa.converters.XMLHttpRequestBodyInit=function(t,e,r){return typeof t=="string"?fa.converters.USVString(t,e,r):fa.is.Blob(t)||ArrayBuffer.isView(t)||$On(t)||fa.is.FormData(t)||fa.is.URLSearchParams(t)?t:fa.converters.DOMString(t,e,r)};fa.converters.BodyInit=function(t,e,r){return fa.is.ReadableStream(t)||t?.[Symbol.asyncIterator]?t:fa.converters.XMLHttpRequestBodyInit(t,e,r)};fa.converters.ResponseInit=fa.dictionaryConverter([{key:"status",converter:fa.converters["unsigned short"],defaultValue:()=>200},{key:"statusText",converter:fa.converters.ByteString,defaultValue:()=>""},{key:"headers",converter:fa.converters.HeadersInit}]);fa.is.Response=fa.util.MakeTypeAssertion(M3);BLt.exports={isNetworkError:KOn,makeNetworkError:A2e,makeResponse:cH,makeAppropriateNetworkError:XOn,filterResponse:RLt,Response:M3,cloneResponse:aQe,fromInnerResponse:ZZ,getResponseState:ON}});var uH=B((INo,VLt)=>{"use strict";var{extractBody:ZOn,mixinBody:eMn,cloneBody:tMn,bodyUnusable:NLt}=Gq(),{Headers:FLt,fill:rMn,HeadersList:v2e,setHeadersGuard:lQe,getHeadersGuard:nMn,setHeadersList:ULt,getHeadersList:OLt}=NN(),E2e=jo(),MLt=we("node:util"),{isValidHTTPToken:iMn,sameOrigin:kLt,environmentSettingsObject:y2e}=Pg(),{forbiddenMethodsSet:oMn,corsSafeListedMethodsSet:sMn,referrerPolicy:aMn,requestRedirect:lMn,requestMode:cMn,requestCredentials:uMn,requestCache:fMn,requestDuplex:dMn}=vZ(),{kEnumerableProperty:_p,normalizedMethodRecordsBase:pMn,normalizedMethodRecords:hMn}=E2e,{webidl:qi}=u2(),{URLSerializer:mMn}=D3(),{kConstruct:b2e}=Fc(),gMn=we("node:assert"),{getMaxListeners:QLt,setMaxListeners:AMn,defaultMaxListeners:yMn}=we("node:events"),EMn=Symbol("abortController"),qLt=new FinalizationRegistry(({signal:t,abort:e})=>{t.removeEventListener("abort",e)}),C2e=new WeakMap,cQe;try{cQe=QLt(new AbortController().signal)>0}catch{cQe=!1}function LLt(t){return e;function e(){let r=t.deref();if(r!==void 0){qLt.unregister(e),this.removeEventListener("abort",e),r.abort(this.reason);let n=C2e.get(r.signal);if(n!==void 0){if(n.size!==0){for(let i of n){let o=i.deref();o!==void 0&&o.abort(this.reason)}n.clear()}C2e.delete(r.signal)}}}}var PLt=!1,K1=class t{#e;#t;#r;#n;constructor(e,r=void 0){if(qi.util.markAsUncloneable(this),e===b2e)return;qi.argumentLengthCheck(arguments,1,"Request constructor"),e=qi.converters.RequestInfo(e),r=qi.converters.RequestInit(r);let i=null,o=null,s=y2e.settingsObject.baseUrl,a=null;if(typeof e=="string"){this.#t=r.dispatcher;let v;try{v=new URL(e,s)}catch(S){throw new TypeError("Failed to parse URL from "+e,{cause:S})}if(v.username||v.password)throw new TypeError("Request cannot be constructed from a URL that includes credentials: "+e);i=_2e({urlList:[v]}),o="cors"}else gMn(qi.is.Request(e)),i=e.#n,a=e.#e,this.#t=r.dispatcher||e.#t;let c=y2e.settingsObject.origin,u="client";if(i.window?.constructor?.name==="EnvironmentSettingsObject"&&kLt(i.window,c)&&(u=i.window),r.window!=null)throw new TypeError(`'window' option '${u}' must be null`);"window"in r&&(u="no-window"),i=_2e({method:i.method,headersList:i.headersList,unsafeRequest:i.unsafeRequest,client:y2e.settingsObject,window:u,priority:i.priority,origin:i.origin,referrer:i.referrer,referrerPolicy:i.referrerPolicy,mode:i.mode,credentials:i.credentials,cache:i.cache,redirect:i.redirect,integrity:i.integrity,keepalive:i.keepalive,reloadNavigation:i.reloadNavigation,historyNavigation:i.historyNavigation,urlList:[...i.urlList]});let f=Object.keys(r).length!==0;if(f&&(i.mode==="navigate"&&(i.mode="same-origin"),i.reloadNavigation=!1,i.historyNavigation=!1,i.origin="client",i.referrer="client",i.referrerPolicy="",i.url=i.urlList[i.urlList.length-1],i.urlList=[i.url]),r.referrer!==void 0){let v=r.referrer;if(v==="")i.referrer="no-referrer";else{let S;try{S=new URL(v,s)}catch(w){throw new TypeError(`Referrer "${v}" is not a valid URL.`,{cause:w})}S.protocol==="about:"&&S.hostname==="client"||c&&!kLt(S,y2e.settingsObject.baseUrl)?i.referrer="client":i.referrer=S}}r.referrerPolicy!==void 0&&(i.referrerPolicy=r.referrerPolicy);let d;if(r.mode!==void 0?d=r.mode:d=o,d==="navigate")throw qi.errors.exception({header:"Request constructor",message:"invalid request mode navigate."});if(d!=null&&(i.mode=d),r.credentials!==void 0&&(i.credentials=r.credentials),r.cache!==void 0&&(i.cache=r.cache),i.cache==="only-if-cached"&&i.mode!=="same-origin")throw new TypeError("'only-if-cached' can be set only with 'same-origin' mode");if(r.redirect!==void 0&&(i.redirect=r.redirect),r.integrity!=null&&(i.integrity=String(r.integrity)),r.keepalive!==void 0&&(i.keepalive=!!r.keepalive),r.method!==void 0){let v=r.method,S=hMn[v];if(S!==void 0)i.method=S;else{if(!iMn(v))throw new TypeError(`'${v}' is not a valid HTTP method.`);let w=v.toUpperCase();if(oMn.has(w))throw new TypeError(`'${v}' HTTP method is unsupported.`);v=pMn[w]??v,i.method=v}!PLt&&i.method==="patch"&&(process.emitWarning("Using `patch` is highly likely to result in a `405 Method Not Allowed`. `PATCH` is much more likely to succeed.",{code:"UNDICI-FETCH-patch"}),PLt=!0)}r.signal!==void 0&&(a=r.signal),this.#n=i;let p=new AbortController;if(this.#e=p.signal,a!=null)if(a.aborted)p.abort(a.reason);else{this[EMn]=p;let v=new WeakRef(p),S=LLt(v);cQe&&QLt(a)===yMn&&AMn(1500,a),E2e.addAbortListener(a,S),qLt.register(p,{signal:a,abort:S},S)}if(this.#r=new FLt(b2e),ULt(this.#r,i.headersList),lQe(this.#r,"request"),d==="no-cors"){if(!sMn.has(i.method))throw new TypeError(`'${i.method} is unsupported in no-cors mode.`);lQe(this.#r,"request-no-cors")}if(f){let v=OLt(this.#r),S=r.headers!==void 0?r.headers:new v2e(v);if(v.clear(),S instanceof v2e){for(let{name:w,value:T}of S.rawValues())v.append(w,T,!1);v.cookies=S.cookies}else rMn(this.#r,S)}let h=qi.is.Request(e)?e.#n.body:null;if((r.body!=null||h!=null)&&(i.method==="GET"||i.method==="HEAD"))throw new TypeError("Request with GET/HEAD method cannot have body.");let g=null;if(r.body!=null){let[v,S]=ZOn(r.body,i.keepalive);g=v,S&&!OLt(this.#r).contains("content-type",!0)&&this.#r.append("content-type",S,!0)}let A=g??h;if(A!=null&&A.source==null){if(g!=null&&r.duplex==null)throw new TypeError("RequestInit: duplex option is required when sending a body.");if(i.mode!=="same-origin"&&i.mode!=="cors")throw new TypeError('If request is made from ReadableStream, mode should be "same-origin" or "cors"');i.useCORSPreflightFlag=!0}let y=A;if(g==null&&h!=null){if(NLt(e.#n))throw new TypeError("Cannot construct a Request with a Request object that has already been used.");let v=new TransformStream;h.stream.pipeThrough(v),y={source:h.source,length:h.length,stream:v.readable}}this.#n.body=y}get method(){return qi.brandCheck(this,t),this.#n.method}get url(){return qi.brandCheck(this,t),mMn(this.#n.url)}get headers(){return qi.brandCheck(this,t),this.#r}get destination(){return qi.brandCheck(this,t),this.#n.destination}get referrer(){return qi.brandCheck(this,t),this.#n.referrer==="no-referrer"?"":this.#n.referrer==="client"?"about:client":this.#n.referrer.toString()}get referrerPolicy(){return qi.brandCheck(this,t),this.#n.referrerPolicy}get mode(){return qi.brandCheck(this,t),this.#n.mode}get credentials(){return qi.brandCheck(this,t),this.#n.credentials}get cache(){return qi.brandCheck(this,t),this.#n.cache}get redirect(){return qi.brandCheck(this,t),this.#n.redirect}get integrity(){return qi.brandCheck(this,t),this.#n.integrity}get keepalive(){return qi.brandCheck(this,t),this.#n.keepalive}get isReloadNavigation(){return qi.brandCheck(this,t),this.#n.reloadNavigation}get isHistoryNavigation(){return qi.brandCheck(this,t),this.#n.historyNavigation}get signal(){return qi.brandCheck(this,t),this.#e}get body(){return qi.brandCheck(this,t),this.#n.body?this.#n.body.stream:null}get bodyUsed(){return qi.brandCheck(this,t),!!this.#n.body&&E2e.isDisturbed(this.#n.body.stream)}get duplex(){return qi.brandCheck(this,t),"half"}clone(){if(qi.brandCheck(this,t),NLt(this.#n))throw new TypeError("unusable");let e=GLt(this.#n),r=new AbortController;if(this.signal.aborted)r.abort(this.signal.reason);else{let n=C2e.get(this.signal);n===void 0&&(n=new Set,C2e.set(this.signal,n));let i=new WeakRef(r);n.add(i),E2e.addAbortListener(r.signal,LLt(i))}return jLt(e,this.#t,r.signal,nMn(this.#r))}[MLt.inspect.custom](e,r){r.depth===null&&(r.depth=2),r.colors??=!0;let n={method:this.method,url:this.url,headers:this.headers,destination:this.destination,referrer:this.referrer,referrerPolicy:this.referrerPolicy,mode:this.mode,credentials:this.credentials,cache:this.cache,redirect:this.redirect,integrity:this.integrity,keepalive:this.keepalive,isReloadNavigation:this.isReloadNavigation,isHistoryNavigation:this.isHistoryNavigation,signal:this.signal};return`Request ${MLt.formatWithOptions(r,n)}`}static setRequestSignal(e,r){return e.#e=r,e}static getRequestDispatcher(e){return e.#t}static setRequestDispatcher(e,r){e.#t=r}static setRequestHeaders(e,r){e.#r=r}static getRequestState(e){return e.#n}static setRequestState(e,r){e.#n=r}},{setRequestSignal:vMn,getRequestDispatcher:bMn,setRequestDispatcher:CMn,setRequestHeaders:_Mn,getRequestState:HLt,setRequestState:SMn}=K1;Reflect.deleteProperty(K1,"setRequestSignal");Reflect.deleteProperty(K1,"getRequestDispatcher");Reflect.deleteProperty(K1,"setRequestDispatcher");Reflect.deleteProperty(K1,"setRequestHeaders");Reflect.deleteProperty(K1,"getRequestState");Reflect.deleteProperty(K1,"setRequestState");eMn(K1,HLt);function _2e(t){return{method:t.method??"GET",localURLsOnly:t.localURLsOnly??!1,unsafeRequest:t.unsafeRequest??!1,body:t.body??null,client:t.client??null,reservedClient:t.reservedClient??null,replacesClientId:t.replacesClientId??"",window:t.window??"client",keepalive:t.keepalive??!1,serviceWorkers:t.serviceWorkers??"all",initiator:t.initiator??"",destination:t.destination??"",priority:t.priority??null,origin:t.origin??"client",policyContainer:t.policyContainer??"client",referrer:t.referrer??"client",referrerPolicy:t.referrerPolicy??"",mode:t.mode??"no-cors",useCORSPreflightFlag:t.useCORSPreflightFlag??!1,credentials:t.credentials??"same-origin",useCredentials:t.useCredentials??!1,cache:t.cache??"default",redirect:t.redirect??"follow",integrity:t.integrity??"",cryptoGraphicsNonceMetadata:t.cryptoGraphicsNonceMetadata??"",parserMetadata:t.parserMetadata??"",reloadNavigation:t.reloadNavigation??!1,historyNavigation:t.historyNavigation??!1,userActivation:t.userActivation??!1,taintedOrigin:t.taintedOrigin??!1,redirectCount:t.redirectCount??0,responseTainting:t.responseTainting??"basic",preventNoCacheCacheControlHeaderModification:t.preventNoCacheCacheControlHeaderModification??!1,done:t.done??!1,timingAllowFailed:t.timingAllowFailed??!1,urlList:t.urlList,url:t.urlList[0],headersList:t.headersList?new v2e(t.headersList):new v2e}}function GLt(t){let e=_2e({...t,body:null});return t.body!=null&&(e.body=tMn(t.body)),e}function jLt(t,e,r,n){let i=new K1(b2e);SMn(i,t),CMn(i,e),vMn(i,r);let o=new FLt(b2e);return _Mn(i,o),ULt(o,t.headersList),lQe(o,n),i}Object.defineProperties(K1.prototype,{method:_p,url:_p,headers:_p,redirect:_p,clone:_p,signal:_p,duplex:_p,destination:_p,body:_p,bodyUsed:_p,isHistoryNavigation:_p,isReloadNavigation:_p,keepalive:_p,integrity:_p,cache:_p,credentials:_p,attribute:_p,referrerPolicy:_p,referrer:_p,mode:_p,[Symbol.toStringTag]:{value:"Request",configurable:!0}});qi.is.Request=qi.util.MakeTypeAssertion(K1);qi.converters.RequestInfo=function(t){return typeof t=="string"?qi.converters.USVString(t):qi.is.Request(t)?t:qi.converters.USVString(t)};qi.converters.RequestInit=qi.dictionaryConverter([{key:"method",converter:qi.converters.ByteString},{key:"headers",converter:qi.converters.HeadersInit},{key:"body",converter:qi.nullableConverter(qi.converters.BodyInit)},{key:"referrer",converter:qi.converters.USVString},{key:"referrerPolicy",converter:qi.converters.DOMString,allowedValues:aMn},{key:"mode",converter:qi.converters.DOMString,allowedValues:cMn},{key:"credentials",converter:qi.converters.DOMString,allowedValues:uMn},{key:"cache",converter:qi.converters.DOMString,allowedValues:fMn},{key:"redirect",converter:qi.converters.DOMString,allowedValues:lMn},{key:"integrity",converter:qi.converters.DOMString},{key:"keepalive",converter:qi.converters.boolean},{key:"signal",converter:qi.nullableConverter(t=>qi.converters.AbortSignal(t,"RequestInit","signal"))},{key:"window",converter:qi.converters.any},{key:"duplex",converter:qi.converters.DOMString,allowedValues:dMn},{key:"dispatcher",converter:qi.converters.any}]);VLt.exports={Request:K1,makeRequest:_2e,fromInnerRequest:jLt,cloneRequest:GLt,getRequestDispatcher:bMn,getRequestState:HLt}});var XLt=B((RNo,KLt)=>{"use strict";var wMn=we("node:assert"),MN=new Map([["sha256",0],["sha384",1],["sha512",2]]),S2e;try{S2e=we("node:crypto");let t=S2e.getHashes();t.length===0&&MN.clear();for(let e of MN.keys())t.includes(e)===!1&&MN.delete(e)}catch{MN.clear()}var $Lt=Map.prototype.get.bind(MN),uQe=Map.prototype.has.bind(MN),xMn=S2e===void 0||MN.size===0?()=>!0:(t,e)=>{let r=YLt(e);if(r.length===0)return!0;let n=WLt(r);for(let i of n){let o=i.alg,s=i.val,a=zLt(o,t);if(JLt(a,s))return!0}return!1};function WLt(t){let e=[],r=null;for(let n of t){if(wMn(uQe(n.alg),"Invalid SRI hash algorithm token"),e.length===0){e.push(n),r=n;continue}let i=r.alg,o=$Lt(i),s=n.alg,a=$Lt(s);a<o||(a>o?(r=n,e[0]=n,e.length=1):e.push(n))}return e}function YLt(t){let e=[];for(let r of t.split(" ")){let i=r.split("?",1)[0],o="",s=[i.slice(0,6),i.slice(7)],a=s[0];if(!uQe(a))continue;s[1]&&(o=s[1]);let c={alg:a,val:o};e.push(c)}return e}var zLt=(t,e)=>S2e.hash(t,e,"base64");function JLt(t,e){let r=t.length;r!==0&&t[r-1]==="="&&(r-=1),r!==0&&t[r-1]==="="&&(r-=1);let n=e.length;if(n!==0&&e[n-1]==="="&&(n-=1),n!==0&&e[n-1]==="="&&(n-=1),r!==n)return!1;for(let i=0;i<r;++i)if(!(t[i]===e[i]||t[i]==="+"&&e[i]==="-"||t[i]==="/"&&e[i]==="_"))return!1;return!0}KLt.exports={applyAlgorithmToBytes:zLt,bytesMatch:xMn,caseSensitiveMatch:JLt,isValidSRIHashAlgorithm:uQe,getStrongestMetadata:WLt,parseMetadata:YLt}});var ree=B((BNo,dPt)=>{"use strict";var{makeNetworkError:oc,makeAppropriateNetworkError:w2e,filterResponse:fQe,makeResponse:x2e,fromInnerResponse:TMn,getResponseState:DMn}=eee(),{HeadersList:ZLt}=NN(),{Request:IMn,cloneRequest:RMn,getRequestDispatcher:BMn,getRequestState:NMn}=uH(),$6=we("node:zlib"),{makePolicyContainer:OMn,clonePolicyContainer:MMn,requestBadPort:kMn,TAOCheck:LMn,appendRequestOriginHeader:PMn,responseLocationURL:FMn,requestCurrentURL:l8,setRequestReferrerPolicyOnRedirect:UMn,tryUpgradeRequestToAPotentiallyTrustworthyURL:QMn,createOpaqueTimingInfo:gQe,appendFetchMetadata:qMn,corsCheck:HMn,crossOriginResourcePolicyCheck:GMn,determineRequestsReferrer:jMn,coarsenedSharedCurrentTime:tee,sameOrigin:mQe,isCancelled:kN,isAborted:ePt,isErrorLike:VMn,fullyReadBody:$Mn,readableStreamClose:WMn,isomorphicEncode:T2e,urlIsLocal:YMn,urlIsHttpHttpsScheme:R2e,urlHasHttpsScheme:zMn,clampAndCoarsenConnectionTimingInfo:JMn,simpleRangeHeaderValue:KMn,buildContentRange:XMn,createInflate:ZMn,extractMimeType:ekn}=Pg(),LN=we("node:assert"),{safelyExtractBody:AQe,extractBody:tPt}=Gq(),{redirectStatusSet:iPt,nullBodyStatus:oPt,safeMethodsSet:tkn,requestBodyHeader:rkn,subresourceSet:nkn}=vZ(),ikn=we("node:events"),{Readable:okn,pipeline:skn,finished:akn,isErrored:lkn,isReadable:D2e}=we("node:stream"),{addAbortListener:ckn,bufferToLowerCasedHeaderName:rPt}=jo(),{dataURLProcessor:ukn,serializeAMimeType:fkn,minimizeSupportedMimeType:dkn}=D3(),{getGlobalDispatcher:pkn}=c2e(),{webidl:yQe}=u2(),{STATUS_CODES:hkn}=we("node:http"),{bytesMatch:mkn}=XLt(),{createDeferredPromise:gkn}=_Z(),Akn=["GET","HEAD"],ykn=typeof __UNDICI_IS_NODE__<"u"||typeof esbuildDetection<"u"?"node":"undici",dQe,I2e=class extends ikn{constructor(e){super(),this.dispatcher=e,this.connection=null,this.dump=!1,this.state="ongoing"}terminate(e){this.state==="ongoing"&&(this.state="terminated",this.connection?.destroy(e),this.emit("terminated",e))}abort(e){this.state==="ongoing"&&(this.state="aborted",e||(e=new DOMException("The operation was aborted.","AbortError")),this.serializedAbortReason=e,this.connection?.destroy(e),this.emit("terminated",e))}};function Ekn(t){sPt(t,"fetch")}function vkn(t,e=void 0){yQe.argumentLengthCheck(arguments,1,"globalThis.fetch");let r=gkn(),n;try{n=new IMn(t,e)}catch(f){return r.reject(f),r.promise}let i=NMn(n);if(n.signal.aborted)return pQe(r,i,null,n.signal.reason),r.promise;i.client.globalObject?.constructor?.name==="ServiceWorkerGlobalScope"&&(i.serviceWorkers="none");let s=null,a=!1,c=null;return ckn(n.signal,()=>{a=!0,LN(c!=null),c.abort(n.signal.reason);let f=s?.deref();pQe(r,i,f,n.signal.reason)}),c=lPt({request:i,processResponseEndOfBody:Ekn,processResponse:f=>{if(!a){if(f.aborted){pQe(r,i,s,c.serializedAbortReason);return}if(f.type==="error"){r.reject(new TypeError("fetch failed",{cause:f.error}));return}s=new WeakRef(TMn(f,"immutable")),r.resolve(s.deref()),r=null}},dispatcher:BMn(n)}),r.promise}function sPt(t,e="other"){if(t.type==="error"&&t.aborted||!t.urlList?.length)return;let r=t.urlList[0],n=t.timingInfo,i=t.cacheState;R2e(r)&&n!==null&&(t.timingAllowPassed||(n=gQe({startTime:n.startTime}),i=""),n.endTime=tee(),t.timingInfo=n,aPt(n,r.href,e,globalThis,i,"",t.status))}var aPt=performance.markResourceTiming;function pQe(t,e,r,n){if(t&&t.reject(n),e.body?.stream!=null&&D2e(e.body.stream)&&e.body.stream.cancel(n).catch(o=>{if(o.code!=="ERR_INVALID_STATE")throw o}),r==null)return;let i=DMn(r);i.body?.stream!=null&&D2e(i.body.stream)&&i.body.stream.cancel(n).catch(o=>{if(o.code!=="ERR_INVALID_STATE")throw o})}function lPt({request:t,processRequestBodyChunkLength:e,processRequestEndOfBody:r,processResponse:n,processResponseEndOfBody:i,processResponseConsumeBody:o,useParallelQueue:s=!1,dispatcher:a=pkn()}){LN(a);let c=null,u=!1;t.client!=null&&(c=t.client.globalObject,u=t.client.crossOriginIsolatedCapability);let f=tee(u),d=gQe({startTime:f}),p={controller:new I2e(a),request:t,timingInfo:d,processRequestBodyChunkLength:e,processRequestEndOfBody:r,processResponse:n,processResponseConsumeBody:o,processResponseEndOfBody:i,taskDestination:c,crossOriginIsolatedCapability:u};return LN(!t.body||t.body.stream),t.window==="client"&&(t.window=t.client?.globalObject?.constructor?.name==="Window"?t.client:"no-window"),t.origin==="client"&&(t.origin=t.client.origin),t.policyContainer==="client"&&(t.client!=null?t.policyContainer=MMn(t.client.policyContainer):t.policyContainer=OMn()),t.headersList.contains("accept",!0)||t.headersList.append("accept","*/*",!0),t.headersList.contains("accept-language",!0)||t.headersList.append("accept-language","*",!0),t.priority,nkn.has(t.destination),cPt(p,!1),p.controller}async function cPt(t,e){try{let r=t.request,n=null;if(r.localURLsOnly&&!YMn(l8(r))&&(n=oc("local URLs only")),QMn(r),kMn(r)==="blocked"&&(n=oc("bad port")),r.referrerPolicy===""&&(r.referrerPolicy=r.policyContainer.referrerPolicy),r.referrer!=="no-referrer"&&(r.referrer=jMn(r)),n===null){let o=l8(r);mQe(o,r.url)&&r.responseTainting==="basic"||o.protocol==="data:"||r.mode==="navigate"||r.mode==="websocket"?(r.responseTainting="basic",n=await nPt(t)):r.mode==="same-origin"?n=oc('request mode cannot be "same-origin"'):r.mode==="no-cors"?r.redirect!=="follow"?n=oc('redirect mode cannot be "follow" for "no-cors" request'):(r.responseTainting="opaque",n=await nPt(t)):R2e(l8(r))?(r.responseTainting="cors",n=await uPt(t)):n=oc("URL scheme must be a HTTP(S) scheme")}if(e)return n;n.status!==0&&!n.internalResponse&&(r.responseTainting,r.responseTainting==="basic"?n=fQe(n,"basic"):r.responseTainting==="cors"?n=fQe(n,"cors"):r.responseTainting==="opaque"?n=fQe(n,"opaque"):LN(!1));let i=n.status===0?n:n.internalResponse;if(i.urlList.length===0&&i.urlList.push(...r.urlList),r.timingAllowFailed||(n.timingAllowPassed=!0),n.type==="opaque"&&i.status===206&&i.rangeRequested&&!r.headers.contains("range",!0)&&(n=i=oc()),n.status!==0&&(r.method==="HEAD"||r.method==="CONNECT"||oPt.includes(i.status))&&(i.body=null,t.controller.dump=!0),r.integrity){let o=a=>hQe(t,oc(a));if(r.responseTainting==="opaque"||n.body==null){o(n.error);return}let s=a=>{if(!mkn(a,r.integrity)){o("integrity mismatch");return}n.body=AQe(a)[0],hQe(t,n)};$Mn(n.body,s,o)}else hQe(t,n)}catch(r){t.controller.terminate(r)}}function nPt(t){if(kN(t)&&t.request.redirectCount===0)return Promise.resolve(w2e(t));let{request:e}=t,{protocol:r}=l8(e);switch(r){case"about:":return Promise.resolve(oc("about scheme is not supported"));case"blob:":{dQe||(dQe=we("node:buffer").resolveObjectURL);let n=l8(e);if(n.search.length!==0)return Promise.resolve(oc("NetworkError when attempting to fetch resource."));let i=dQe(n.toString());if(e.method!=="GET"||!yQe.is.Blob(i))return Promise.resolve(oc("invalid method"));let o=x2e(),s=i.size,a=T2e(`${s}`),c=i.type;if(e.headersList.contains("range",!0)){o.rangeRequested=!0;let u=e.headersList.get("range",!0),f=KMn(u,!0);if(f==="failure")return Promise.resolve(oc("failed to fetch the data URL"));let{rangeStartValue:d,rangeEndValue:p}=f;if(d===null)d=s-p,p=d+p-1;else{if(d>=s)return Promise.resolve(oc("Range start is greater than the blob's size."));(p===null||p>=s)&&(p=s-1)}let h=i.slice(d,p,c),g=tPt(h);o.body=g[0];let A=T2e(`${h.size}`),y=XMn(d,p,s);o.status=206,o.statusText="Partial Content",o.headersList.set("content-length",A,!0),o.headersList.set("content-type",c,!0),o.headersList.set("content-range",y,!0)}else{let u=tPt(i);o.statusText="OK",o.body=u[0],o.headersList.set("content-length",a,!0),o.headersList.set("content-type",c,!0)}return Promise.resolve(o)}case"data:":{let n=l8(e),i=ukn(n);if(i==="failure")return Promise.resolve(oc("failed to fetch the data URL"));let o=fkn(i.mimeType);return Promise.resolve(x2e({statusText:"OK",headersList:[["content-type",{name:"Content-Type",value:o}]],body:AQe(i.body)[0]}))}case"file:":return Promise.resolve(oc("not implemented... yet..."));case"http:":case"https:":return uPt(t).catch(n=>oc(n));default:return Promise.resolve(oc("unknown scheme"))}}function bkn(t,e){t.request.done=!0,t.processResponseDone!=null&&queueMicrotask(()=>t.processResponseDone(e))}function hQe(t,e){let r=t.timingInfo,n=()=>{let o=Date.now();t.request.destination==="document"&&(t.controller.fullTimingInfo=r),t.controller.reportTimingSteps=()=>{if(!R2e(t.request.url))return;r.endTime=o;let a=e.cacheState,c=e.bodyInfo;e.timingAllowPassed||(r=gQe(r),a="");let u=0;if(t.request.mode!=="navigator"||!e.hasCrossOriginRedirects){u=e.status;let f=ekn(e.headersList);f!=="failure"&&(c.contentType=dkn(f))}t.request.initiatorType!=null&&aPt(r,t.request.url.href,t.request.initiatorType,globalThis,a,c,u)};let s=()=>{t.request.done=!0,t.processResponseEndOfBody!=null&&queueMicrotask(()=>t.processResponseEndOfBody(e)),t.request.initiatorType!=null&&t.controller.reportTimingSteps()};queueMicrotask(()=>s())};t.processResponse!=null&&queueMicrotask(()=>{t.processResponse(e),t.processResponse=null});let i=e.type==="error"?e:e.internalResponse??e;i.body==null?n():akn(i.body.stream,()=>{n()})}async function uPt(t){let e=t.request,r=null,n=null,i=t.timingInfo;if(e.serviceWorkers,r===null){if(e.redirect==="follow"&&(e.serviceWorkers="none"),n=r=await fPt(t),e.responseTainting==="cors"&&HMn(e,r)==="failure")return oc("cors failure");LMn(e,r)==="failure"&&(e.timingAllowFailed=!0)}return(e.responseTainting==="opaque"||r.type==="opaque")&&GMn(e.origin,e.client,e.destination,n)==="blocked"?oc("blocked"):(iPt.has(n.status)&&(e.redirect!=="manual"&&t.controller.connection.destroy(void 0,!1),e.redirect==="error"?r=oc("unexpected redirect"):e.redirect==="manual"?r=n:e.redirect==="follow"?r=await Ckn(t,r):LN(!1)),r.timingInfo=i,r)}function Ckn(t,e){let r=t.request,n=e.internalResponse?e.internalResponse:e,i;try{if(i=FMn(n,l8(r).hash),i==null)return e}catch(s){return Promise.resolve(oc(s))}if(!R2e(i))return Promise.resolve(oc("URL scheme must be a HTTP(S) scheme"));if(r.redirectCount===20)return Promise.resolve(oc("redirect count exceeded"));if(r.redirectCount+=1,r.mode==="cors"&&(i.username||i.password)&&!mQe(r,i))return Promise.resolve(oc('cross origin not allowed for request mode "cors"'));if(r.responseTainting==="cors"&&(i.username||i.password))return Promise.resolve(oc('URL cannot contain credentials for request mode "cors"'));if(n.status!==303&&r.body!=null&&r.body.source==null)return Promise.resolve(oc());if([301,302].includes(n.status)&&r.method==="POST"||n.status===303&&!Akn.includes(r.method)){r.method="GET",r.body=null;for(let s of rkn)r.headersList.delete(s)}mQe(l8(r),i)||(r.headersList.delete("authorization",!0),r.headersList.delete("proxy-authorization",!0),r.headersList.delete("cookie",!0),r.headersList.delete("host",!0)),r.body!=null&&(LN(r.body.source!=null),r.body=AQe(r.body.source)[0]);let o=t.timingInfo;return o.redirectEndTime=o.postRedirectStartTime=tee(t.crossOriginIsolatedCapability),o.redirectStartTime===0&&(o.redirectStartTime=o.startTime),r.urlList.push(i),UMn(r,n),cPt(t,!0)}async function fPt(t,e=!1,r=!1){let n=t.request,i=null,o=null,s=null,a=null,c=!1;n.window==="no-window"&&n.redirect==="error"?(i=t,o=n):(o=RMn(n),i={...t},i.request=o);let u=n.credentials==="include"||n.credentials==="same-origin"&&n.responseTainting==="basic",f=o.body?o.body.length:null,d=null;if(o.body==null&&["POST","PUT"].includes(o.method)&&(d="0"),f!=null&&(d=T2e(`${f}`)),d!=null&&o.headersList.append("content-length",d,!0),f!=null&&o.keepalive,yQe.is.URL(o.referrer)&&o.headersList.append("referer",T2e(o.referrer.href),!0),PMn(o),qMn(o),o.headersList.contains("user-agent",!0)||o.headersList.append("user-agent",ykn,!0),o.cache==="default"&&(o.headersList.contains("if-modified-since",!0)||o.headersList.contains("if-none-match",!0)||o.headersList.contains("if-unmodified-since",!0)||o.headersList.contains("if-match",!0)||o.headersList.contains("if-range",!0))&&(o.cache="no-store"),o.cache==="no-cache"&&!o.preventNoCacheCacheControlHeaderModification&&!o.headersList.contains("cache-control",!0)&&o.headersList.append("cache-control","max-age=0",!0),(o.cache==="no-store"||o.cache==="reload")&&(o.headersList.contains("pragma",!0)||o.headersList.append("pragma","no-cache",!0),o.headersList.contains("cache-control",!0)||o.headersList.append("cache-control","no-cache",!0)),o.headersList.contains("range",!0)&&o.headersList.append("accept-encoding","identity",!0),o.headersList.contains("accept-encoding",!0)||(zMn(l8(o))?o.headersList.append("accept-encoding","br, gzip, deflate",!0):o.headersList.append("accept-encoding","gzip, deflate",!0)),o.headersList.delete("host",!0),a==null&&(o.cache="no-store"),o.cache!=="no-store"&&o.cache,s==null){if(o.cache==="only-if-cached")return oc("only if cached");let p=await _kn(i,u,r);!tkn.has(o.method)&&p.status>=200&&p.status<=399,c&&p.status,s==null&&(s=p)}if(s.urlList=[...o.urlList],o.headersList.contains("range",!0)&&(s.rangeRequested=!0),s.requestIncludesCredentials=u,s.status===407)return n.window==="no-window"?oc():kN(t)?w2e(t):oc("proxy authentication required");if(s.status===421&&!r&&(n.body==null||n.body.source!=null)){if(kN(t))return w2e(t);t.controller.connection.destroy(),s=await fPt(t,e,!0)}return s}async function _kn(t,e=!1,r=!1){LN(!t.controller.connection||t.controller.connection.destroyed),t.controller.connection={abort:null,destroyed:!1,destroy(g,A=!0){this.destroyed||(this.destroyed=!0,A&&this.abort?.(g??new DOMException("The operation was aborted.","AbortError")))}};let n=t.request,i=null,o=t.timingInfo;null==null&&(n.cache="no-store");let a=r?"yes":"no";n.mode;let c=null;if(n.body==null&&t.processRequestEndOfBody)queueMicrotask(()=>t.processRequestEndOfBody());else if(n.body!=null){let g=async function*(v){kN(t)||(yield v,t.processRequestBodyChunkLength?.(v.byteLength))},A=()=>{kN(t)||t.processRequestEndOfBody&&t.processRequestEndOfBody()},y=v=>{kN(t)||(v.name==="AbortError"?t.controller.abort():t.controller.terminate(v))};c=(async function*(){try{for await(let v of n.body.stream)yield*g(v);A()}catch(v){y(v)}})()}try{let{body:g,status:A,statusText:y,headersList:v,socket:S}=await h({body:c});if(S)i=x2e({status:A,statusText:y,headersList:v,socket:S});else{let w=g[Symbol.asyncIterator]();t.controller.next=()=>w.next(),i=x2e({status:A,statusText:y,headersList:v})}}catch(g){return g.name==="AbortError"?(t.controller.connection.destroy(),w2e(t,g)):oc(g)}let u=()=>t.controller.resume(),f=g=>{kN(t)||t.controller.abort(g)},d=new ReadableStream({start(g){t.controller.controller=g},pull:u,cancel:f,type:"bytes"});i.body={stream:d,source:null,length:null},t.controller.resume||t.controller.on("terminated",p),t.controller.resume=async()=>{for(;;){let g,A;try{let{done:v,value:S}=await t.controller.next();if(ePt(t))break;g=v?void 0:S}catch(v){t.controller.ended&&!o.encodedBodySize?g=void 0:(g=v,A=!0)}if(g===void 0){WMn(t.controller.controller),bkn(t,i);return}if(o.decodedBodySize+=g?.byteLength??0,A){t.controller.terminate(g);return}let y=new Uint8Array(g);if(y.byteLength&&t.controller.controller.enqueue(y),lkn(d)){t.controller.terminate();return}if(t.controller.controller.desiredSize<=0)return}};function p(g){ePt(t)?(i.aborted=!0,D2e(d)&&t.controller.controller.error(t.controller.serializedAbortReason)):D2e(d)&&t.controller.controller.error(new TypeError("terminated",{cause:VMn(g)?g:void 0})),t.controller.connection.destroy()}return i;function h({body:g}){let A=l8(n),y=t.controller.dispatcher;return new Promise((v,S)=>y.dispatch({path:A.pathname+A.search,origin:A.origin,method:n.method,body:y.isMockActive?n.body&&(n.body.source||n.body.stream):g,headers:n.headersList.entries,maxRedirections:0,upgrade:n.mode==="websocket"?"websocket":void 0},{body:null,abort:null,onConnect(w){let{connection:T}=t.controller;o.finalConnectionTimingInfo=JMn(void 0,o.postRedirectStartTime,t.crossOriginIsolatedCapability),T.destroyed?w(new DOMException("The operation was aborted.","AbortError")):(t.controller.on("terminated",w),this.abort=T.abort=w),o.finalNetworkRequestStartTime=tee(t.crossOriginIsolatedCapability)},onResponseStarted(){o.finalNetworkResponseStartTime=tee(t.crossOriginIsolatedCapability)},onHeaders(w,T,N,P){if(w<200)return!1;let U=[],Q=new ZLt;for(let M=0;M<T.length;M+=2)Q.append(rPt(T[M]),T[M+1].toString("latin1"),!0);let D=Q.get("content-encoding",!0);D&&(U=D.toLowerCase().split(",").map(M=>M.trim()));let F=Q.get("location",!0);this.body=new okn({read:N});let O=[],q=F&&n.redirect==="follow"&&iPt.has(w);if(U.length!==0&&n.method!=="HEAD"&&n.method!=="CONNECT"&&!oPt.includes(w)&&!q)for(let M=U.length-1;M>=0;--M){let j=U[M];if(j==="x-gzip"||j==="gzip")O.push($6.createGunzip({flush:$6.constants.Z_SYNC_FLUSH,finishFlush:$6.constants.Z_SYNC_FLUSH}));else if(j==="deflate")O.push(ZMn({flush:$6.constants.Z_SYNC_FLUSH,finishFlush:$6.constants.Z_SYNC_FLUSH}));else if(j==="br")O.push($6.createBrotliDecompress({flush:$6.constants.BROTLI_OPERATION_FLUSH,finishFlush:$6.constants.BROTLI_OPERATION_FLUSH}));else if(j==="zstd"&&typeof $6.createZstdDecompress=="function")O.push($6.createZstdDecompress({flush:$6.constants.ZSTD_e_continue,finishFlush:$6.constants.ZSTD_e_end}));else{O.length=0;break}}let L=this.onError.bind(this);return v({status:w,statusText:P,headersList:Q,body:O.length?skn(this.body,...O,M=>{M&&this.onError(M)}).on("error",L):this.body.on("error",L)}),!0},onData(w){if(t.controller.dump)return;let T=w;return o.encodedBodySize+=T.byteLength,this.body.push(T)},onComplete(){this.abort&&t.controller.off("terminated",this.abort),t.controller.ended=!0,this.body.push(null)},onError(w){this.abort&&t.controller.off("terminated",this.abort),this.body?.destroy(w),t.controller.terminate(w),S(w)},onUpgrade(w,T,N){if(w!==101)return;let P=new ZLt;for(let U=0;U<T.length;U+=2)P.append(rPt(T[U]),T[U+1].toString("latin1"),!0);return v({status:w,statusText:hkn[w],headersList:P,socket:N}),!0}}))}}dPt.exports={fetch:vkn,Fetch:I2e,fetching:lPt,finalizeAndReportTiming:sPt}});var mPt=B((NNo,hPt)=>{"use strict";var Skn=we("node:assert"),{URLSerializer:pPt}=D3(),{isValidHeaderName:wkn}=Pg();function xkn(t,e,r=!1){let n=pPt(t,r),i=pPt(e,r);return n===i}function Tkn(t){Skn(t!==null);let e=[];for(let r of t.split(","))r=r.trim(),wkn(r)&&e.push(r);return e}hPt.exports={urlEquals:xkn,getFieldValues:Tkn}});var yPt=B((ONo,APt)=>{"use strict";var EQe=we("node:assert"),{kConstruct:Dkn}=Fc(),{urlEquals:Ikn,getFieldValues:vQe}=mPt(),{kEnumerableProperty:PN,isDisturbed:Rkn}=jo(),{webidl:ri}=u2(),{cloneResponse:Bkn,fromInnerResponse:Nkn,getResponseState:Okn}=eee(),{Request:nee,fromInnerRequest:Mkn,getRequestState:c8}=uH(),{fetching:kkn}=ree(),{urlIsHttpHttpsScheme:B2e,readAllBytes:Lkn}=Pg(),{createDeferredPromise:fH}=_Z(),N2e=class t{#e;constructor(){arguments[0]!==Dkn&&ri.illegalConstructor(),ri.util.markAsUncloneable(this),this.#e=arguments[1]}async match(e,r={}){ri.brandCheck(this,t);let n="Cache.match";ri.argumentLengthCheck(arguments,1,n),e=ri.converters.RequestInfo(e),r=ri.converters.CacheQueryOptions(r,n,"options");let i=this.#o(e,r,1);if(i.length!==0)return i[0]}async matchAll(e=void 0,r={}){ri.brandCheck(this,t);let n="Cache.matchAll";return e!==void 0&&(e=ri.converters.RequestInfo(e)),r=ri.converters.CacheQueryOptions(r,n,"options"),this.#o(e,r)}async add(e){ri.brandCheck(this,t),ri.argumentLengthCheck(arguments,1,"Cache.add"),e=ri.converters.RequestInfo(e);let n=[e];return await this.addAll(n)}async addAll(e){ri.brandCheck(this,t);let r="Cache.addAll";ri.argumentLengthCheck(arguments,1,r);let n=[],i=[];for(let p of e){if(p===void 0)throw ri.errors.conversionFailed({prefix:r,argument:"Argument 1",types:["undefined is not allowed"]});if(p=ri.converters.RequestInfo(p),typeof p=="string")continue;let h=c8(p);if(!B2e(h.url)||h.method!=="GET")throw ri.errors.exception({header:r,message:"Expected http/s scheme when method is not GET."})}let o=[];for(let p of e){let h=c8(new nee(p));if(!B2e(h.url))throw ri.errors.exception({header:r,message:"Expected http/s scheme."});h.initiator="fetch",h.destination="subresource",i.push(h);let g=fH();o.push(kkn({request:h,processResponse(A){if(A.type==="error"||A.status===206||A.status<200||A.status>299)g.reject(ri.errors.exception({header:"Cache.addAll",message:"Received an invalid status code or the request failed."}));else if(A.headersList.contains("vary")){let y=vQe(A.headersList.get("vary"));for(let v of y)if(v==="*"){g.reject(ri.errors.exception({header:"Cache.addAll",message:"invalid vary field value"}));for(let S of o)S.abort();return}}},processResponseEndOfBody(A){if(A.aborted){g.reject(new DOMException("aborted","AbortError"));return}g.resolve(A)}})),n.push(g.promise)}let a=await Promise.all(n),c=[],u=0;for(let p of a){let h={type:"put",request:i[u],response:p};c.push(h),u++}let f=fH(),d=null;try{this.#t(c)}catch(p){d=p}return queueMicrotask(()=>{d===null?f.resolve(void 0):f.reject(d)}),f.promise}async put(e,r){ri.brandCheck(this,t);let n="Cache.put";ri.argumentLengthCheck(arguments,2,n),e=ri.converters.RequestInfo(e),r=ri.converters.Response(r,n,"response");let i=null;if(ri.is.Request(e)?i=c8(e):i=c8(new nee(e)),!B2e(i.url)||i.method!=="GET")throw ri.errors.exception({header:n,message:"Expected an http/s scheme when method is not GET"});let o=Okn(r);if(o.status===206)throw ri.errors.exception({header:n,message:"Got 206 status"});if(o.headersList.contains("vary")){let h=vQe(o.headersList.get("vary"));for(let g of h)if(g==="*")throw ri.errors.exception({header:n,message:"Got * vary field value"})}if(o.body&&(Rkn(o.body.stream)||o.body.stream.locked))throw ri.errors.exception({header:n,message:"Response body is locked or disturbed"});let s=Bkn(o),a=fH();if(o.body!=null){let g=o.body.stream.getReader();Lkn(g,a.resolve,a.reject)}else a.resolve(void 0);let c=[],u={type:"put",request:i,response:s};c.push(u);let f=await a.promise;s.body!=null&&(s.body.source=f);let d=fH(),p=null;try{this.#t(c)}catch(h){p=h}return queueMicrotask(()=>{p===null?d.resolve():d.reject(p)}),d.promise}async delete(e,r={}){ri.brandCheck(this,t);let n="Cache.delete";ri.argumentLengthCheck(arguments,1,n),e=ri.converters.RequestInfo(e),r=ri.converters.CacheQueryOptions(r,n,"options");let i=null;if(ri.is.Request(e)){if(i=c8(e),i.method!=="GET"&&!r.ignoreMethod)return!1}else EQe(typeof e=="string"),i=c8(new nee(e));let o=[],s={type:"delete",request:i,options:r};o.push(s);let a=fH(),c=null,u;try{u=this.#t(o)}catch(f){c=f}return queueMicrotask(()=>{c===null?a.resolve(!!u?.length):a.reject(c)}),a.promise}async keys(e=void 0,r={}){ri.brandCheck(this,t);let n="Cache.keys";e!==void 0&&(e=ri.converters.RequestInfo(e)),r=ri.converters.CacheQueryOptions(r,n,"options");let i=null;if(e!==void 0)if(ri.is.Request(e)){if(i=c8(e),i.method!=="GET"&&!r.ignoreMethod)return[]}else typeof e=="string"&&(i=c8(new nee(e)));let o=fH(),s=[];if(e===void 0)for(let a of this.#e)s.push(a[0]);else{let a=this.#r(i,r);for(let c of a)s.push(c[0])}return queueMicrotask(()=>{let a=[];for(let c of s){let u=Mkn(c,void 0,new AbortController().signal,"immutable");a.push(u)}o.resolve(Object.freeze(a))}),o.promise}#t(e){let r=this.#e,n=[...r],i=[],o=[];try{for(let s of e){if(s.type!=="delete"&&s.type!=="put")throw ri.errors.exception({header:"Cache.#batchCacheOperations",message:'operation type does not match "delete" or "put"'});if(s.type==="delete"&&s.response!=null)throw ri.errors.exception({header:"Cache.#batchCacheOperations",message:"delete operation should not have an associated response"});if(this.#r(s.request,s.options,i).length)throw new DOMException("???","InvalidStateError");let a;if(s.type==="delete"){if(a=this.#r(s.request,s.options),a.length===0)return[];for(let c of a){let u=r.indexOf(c);EQe(u!==-1),r.splice(u,1)}}else if(s.type==="put"){if(s.response==null)throw ri.errors.exception({header:"Cache.#batchCacheOperations",message:"put operation should have an associated response"});let c=s.request;if(!B2e(c.url))throw ri.errors.exception({header:"Cache.#batchCacheOperations",message:"expected http or https scheme"});if(c.method!=="GET")throw ri.errors.exception({header:"Cache.#batchCacheOperations",message:"not get method"});if(s.options!=null)throw ri.errors.exception({header:"Cache.#batchCacheOperations",message:"options must not be defined"});a=this.#r(s.request);for(let u of a){let f=r.indexOf(u);EQe(f!==-1),r.splice(f,1)}r.push([s.request,s.response]),i.push([s.request,s.response])}o.push([s.request,s.response])}return o}catch(s){throw this.#e.length=0,this.#e=n,s}}#r(e,r,n){let i=[],o=n??this.#e;for(let s of o){let[a,c]=s;this.#n(e,a,c,r)&&i.push(s)}return i}#n(e,r,n=null,i){let o=new URL(e.url),s=new URL(r.url);if(i?.ignoreSearch&&(s.search="",o.search=""),!Ikn(o,s,!0))return!1;if(n==null||i?.ignoreVary||!n.headersList.contains("vary"))return!0;let a=vQe(n.headersList.get("vary"));for(let c of a){if(c==="*")return!1;let u=r.headersList.get(c),f=e.headersList.get(c);if(u!==f)return!1}return!0}#o(e,r,n=1/0){let i=null;if(e!==void 0)if(ri.is.Request(e)){if(i=c8(e),i.method!=="GET"&&!r.ignoreMethod)return[]}else typeof e=="string"&&(i=c8(new nee(e)));let o=[];if(e===void 0)for(let a of this.#e)o.push(a[1]);else{let a=this.#r(i,r);for(let c of a)o.push(c[1])}let s=[];for(let a of o){let c=Nkn(a,"immutable");if(s.push(c.clone()),s.length>=n)break}return Object.freeze(s)}};Object.defineProperties(N2e.prototype,{[Symbol.toStringTag]:{value:"Cache",configurable:!0},match:PN,matchAll:PN,add:PN,addAll:PN,put:PN,delete:PN,keys:PN});var gPt=[{key:"ignoreSearch",converter:ri.converters.boolean,defaultValue:()=>!1},{key:"ignoreMethod",converter:ri.converters.boolean,defaultValue:()=>!1},{key:"ignoreVary",converter:ri.converters.boolean,defaultValue:()=>!1}];ri.converters.CacheQueryOptions=ri.dictionaryConverter(gPt);ri.converters.MultiCacheQueryOptions=ri.dictionaryConverter([...gPt,{key:"cacheName",converter:ri.converters.DOMString}]);ri.converters.Response=ri.interfaceConverter(ri.is.Response,"Response");ri.converters["sequence<RequestInfo>"]=ri.sequenceConverter(ri.converters.RequestInfo);APt.exports={Cache:N2e}});var vPt=B((MNo,EPt)=>{"use strict";var{Cache:O2e}=yPt(),{webidl:pm}=u2(),{kEnumerableProperty:iee}=jo(),{kConstruct:oee}=Fc(),M2e=class t{#e=new Map;constructor(){arguments[0]!==oee&&pm.illegalConstructor(),pm.util.markAsUncloneable(this)}async match(e,r={}){if(pm.brandCheck(this,t),pm.argumentLengthCheck(arguments,1,"CacheStorage.match"),e=pm.converters.RequestInfo(e),r=pm.converters.MultiCacheQueryOptions(r),r.cacheName!=null){if(this.#e.has(r.cacheName)){let n=this.#e.get(r.cacheName);return await new O2e(oee,n).match(e,r)}}else for(let n of this.#e.values()){let o=await new O2e(oee,n).match(e,r);if(o!==void 0)return o}}async has(e){pm.brandCheck(this,t);let r="CacheStorage.has";return pm.argumentLengthCheck(arguments,1,r),e=pm.converters.DOMString(e,r,"cacheName"),this.#e.has(e)}async open(e){pm.brandCheck(this,t);let r="CacheStorage.open";if(pm.argumentLengthCheck(arguments,1,r),e=pm.converters.DOMString(e,r,"cacheName"),this.#e.has(e)){let i=this.#e.get(e);return new O2e(oee,i)}let n=[];return this.#e.set(e,n),new O2e(oee,n)}async delete(e){pm.brandCheck(this,t);let r="CacheStorage.delete";return pm.argumentLengthCheck(arguments,1,r),e=pm.converters.DOMString(e,r,"cacheName"),this.#e.delete(e)}async keys(){return pm.brandCheck(this,t),[...this.#e.keys()]}};Object.defineProperties(M2e.prototype,{[Symbol.toStringTag]:{value:"CacheStorage",configurable:!0},match:iee,has:iee,open:iee,delete:iee,keys:iee});EPt.exports={CacheStorage:M2e}});var CPt=B((kNo,bPt)=>{"use strict";bPt.exports={maxAttributeValueSize:1024,maxNameValuePairSize:4096}});var bQe=B((LNo,TPt)=>{"use strict";function Pkn(t){for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(r>=0&&r<=8||r>=10&&r<=31||r===127)return!0}return!1}function _Pt(t){for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(r<33||r>126||r===34||r===40||r===41||r===60||r===62||r===64||r===44||r===59||r===58||r===92||r===47||r===91||r===93||r===63||r===61||r===123||r===125)throw new Error("Invalid cookie name")}}function SPt(t){let e=t.length,r=0;if(t[0]==='"'){if(e===1||t[e-1]!=='"')throw new Error("Invalid cookie value");--e,++r}for(;r<e;){let n=t.charCodeAt(r++);if(n<33||n>126||n===34||n===44||n===59||n===92)throw new Error("Invalid cookie value")}}function wPt(t){for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(r<32||r===127||r===59)throw new Error("Invalid cookie path")}}function Fkn(t){if(t.startsWith("-")||t.endsWith(".")||t.endsWith("-"))throw new Error("Invalid cookie domain")}var Ukn=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Qkn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],k2e=Array(61).fill(0).map((t,e)=>e.toString().padStart(2,"0"));function xPt(t){return typeof t=="number"&&(t=new Date(t)),`${Ukn[t.getUTCDay()]}, ${k2e[t.getUTCDate()]} ${Qkn[t.getUTCMonth()]} ${t.getUTCFullYear()} ${k2e[t.getUTCHours()]}:${k2e[t.getUTCMinutes()]}:${k2e[t.getUTCSeconds()]} GMT`}function qkn(t){if(t<0)throw new Error("Invalid cookie max-age")}function Hkn(t){if(t.name.length===0)return null;_Pt(t.name),SPt(t.value);let e=[`${t.name}=${t.value}`];t.name.startsWith("__Secure-")&&(t.secure=!0),t.name.startsWith("__Host-")&&(t.secure=!0,t.domain=null,t.path="/"),t.secure&&e.push("Secure"),t.httpOnly&&e.push("HttpOnly"),typeof t.maxAge=="number"&&(qkn(t.maxAge),e.push(`Max-Age=${t.maxAge}`)),t.domain&&(Fkn(t.domain),e.push(`Domain=${t.domain}`)),t.path&&(wPt(t.path),e.push(`Path=${t.path}`)),t.expires&&t.expires.toString()!=="Invalid Date"&&e.push(`Expires=${xPt(t.expires)}`),t.sameSite&&e.push(`SameSite=${t.sameSite}`);for(let r of t.unparsed){if(!r.includes("="))throw new Error("Invalid unparsed");let[n,...i]=r.split("=");e.push(`${n.trim()}=${i.join("=")}`)}return e.join("; ")}TPt.exports={isCTLExcludingHtab:Pkn,validateCookieName:_Pt,validateCookiePath:wPt,validateCookieValue:SPt,toIMFDate:xPt,stringify:Hkn}});var IPt=B((PNo,DPt)=>{"use strict";var{maxNameValuePairSize:Gkn,maxAttributeValueSize:jkn}=CPt(),{isCTLExcludingHtab:Vkn}=bQe(),{collectASequenceOfCodePointsFast:L2e}=D3(),$kn=we("node:assert"),{unescape:Wkn}=we("node:querystring");function Ykn(t){if(Vkn(t))return null;let e="",r="",n="",i="";if(t.includes(";")){let o={position:0};e=L2e(";",t,o),r=t.slice(o.position)}else e=t;if(!e.includes("="))i=e;else{let o={position:0};n=L2e("=",e,o),i=e.slice(o.position+1)}return n=n.trim(),i=i.trim(),n.length+i.length>Gkn?null:{name:n,value:Wkn(i),...dH(r)}}function dH(t,e={}){if(t.length===0)return e;$kn(t[0]===";"),t=t.slice(1);let r="";t.includes(";")?(r=L2e(";",t,{position:0}),t=t.slice(r.length)):(r=t,t="");let n="",i="";if(r.includes("=")){let s={position:0};n=L2e("=",r,s),i=r.slice(s.position+1)}else n=r;if(n=n.trim(),i=i.trim(),i.length>jkn)return dH(t,e);let o=n.toLowerCase();if(o==="expires"){let s=new Date(i);e.expires=s}else if(o==="max-age"){let s=i.charCodeAt(0);if((s<48||s>57)&&i[0]!=="-"||!/^\d+$/.test(i))return dH(t,e);let a=Number(i);e.maxAge=a}else if(o==="domain"){let s=i;s[0]==="."&&(s=s.slice(1)),s=s.toLowerCase(),e.domain=s}else if(o==="path"){let s="";i.length===0||i[0]!=="/"?s="/":s=i,e.path=s}else if(o==="secure")e.secure=!0;else if(o==="httponly")e.httpOnly=!0;else if(o==="samesite"){let s="Default",a=i.toLowerCase();a.includes("none")&&(s="None"),a.includes("strict")&&(s="Strict"),a.includes("lax")&&(s="Lax"),e.sameSite=s}else e.unparsed??=[],e.unparsed.push(`${n}=${i}`);return dH(t,e)}DPt.exports={parseSetCookie:Ykn,parseUnparsedAttributes:dH}});var OPt=B((FNo,NPt)=>{"use strict";var{parseSetCookie:RPt}=IPt(),{stringify:zkn}=bQe(),{webidl:Ta}=u2(),{Headers:Jkn}=NN(),P2e=Ta.brandCheckMultiple([Jkn,globalThis.Headers].filter(Boolean));function Kkn(t){Ta.argumentLengthCheck(arguments,1,"getCookies"),P2e(t);let e=t.get("cookie"),r={};if(!e)return r;for(let n of e.split(";")){let[i,...o]=n.split("=");r[i.trim()]=o.join("=")}return r}function Xkn(t,e,r){P2e(t);let n="deleteCookie";Ta.argumentLengthCheck(arguments,2,n),e=Ta.converters.DOMString(e,n,"name"),r=Ta.converters.DeleteCookieAttributes(r),BPt(t,{name:e,value:"",expires:new Date(0),...r})}function Zkn(t){Ta.argumentLengthCheck(arguments,1,"getSetCookies"),P2e(t);let e=t.getSetCookie();return e?e.map(r=>RPt(r)):[]}function eLn(t){return t=Ta.converters.DOMString(t),RPt(t)}function BPt(t,e){Ta.argumentLengthCheck(arguments,2,"setCookie"),P2e(t),e=Ta.converters.Cookie(e);let r=zkn(e);r&&t.append("set-cookie",r,!0)}Ta.converters.DeleteCookieAttributes=Ta.dictionaryConverter([{converter:Ta.nullableConverter(Ta.converters.DOMString),key:"path",defaultValue:()=>null},{converter:Ta.nullableConverter(Ta.converters.DOMString),key:"domain",defaultValue:()=>null}]);Ta.converters.Cookie=Ta.dictionaryConverter([{converter:Ta.converters.DOMString,key:"name"},{converter:Ta.converters.DOMString,key:"value"},{converter:Ta.nullableConverter(t=>typeof t=="number"?Ta.converters["unsigned long long"](t):new Date(t)),key:"expires",defaultValue:()=>null},{converter:Ta.nullableConverter(Ta.converters["long long"]),key:"maxAge",defaultValue:()=>null},{converter:Ta.nullableConverter(Ta.converters.DOMString),key:"domain",defaultValue:()=>null},{converter:Ta.nullableConverter(Ta.converters.DOMString),key:"path",defaultValue:()=>null},{converter:Ta.nullableConverter(Ta.converters.boolean),key:"secure",defaultValue:()=>null},{converter:Ta.nullableConverter(Ta.converters.boolean),key:"httpOnly",defaultValue:()=>null},{converter:Ta.converters.USVString,key:"sameSite",allowedValues:["Strict","Lax","None"]},{converter:Ta.sequenceConverter(Ta.converters.DOMString),key:"unparsed",defaultValue:()=>new Array(0)}]);NPt.exports={getCookies:Kkn,deleteCookie:Xkn,getSetCookies:Zkn,setCookie:BPt,parseCookie:eLn}});var Q2e=B((UNo,kPt)=>{"use strict";var{webidl:Ai}=u2(),{kEnumerableProperty:X1}=jo(),{kConstruct:MPt}=Fc(),pH=class t extends Event{#e;constructor(e,r={}){if(e===MPt){super(arguments[1],arguments[2]),Ai.util.markAsUncloneable(this);return}let n="MessageEvent constructor";Ai.argumentLengthCheck(arguments,1,n),e=Ai.converters.DOMString(e,n,"type"),r=Ai.converters.MessageEventInit(r,n,"eventInitDict"),super(e,r),this.#e=r,Ai.util.markAsUncloneable(this)}get data(){return Ai.brandCheck(this,t),this.#e.data}get origin(){return Ai.brandCheck(this,t),this.#e.origin}get lastEventId(){return Ai.brandCheck(this,t),this.#e.lastEventId}get source(){return Ai.brandCheck(this,t),this.#e.source}get ports(){return Ai.brandCheck(this,t),Object.isFrozen(this.#e.ports)||Object.freeze(this.#e.ports),this.#e.ports}initMessageEvent(e,r=!1,n=!1,i=null,o="",s="",a=null,c=[]){return Ai.brandCheck(this,t),Ai.argumentLengthCheck(arguments,1,"MessageEvent.initMessageEvent"),new t(e,{bubbles:r,cancelable:n,data:i,origin:o,lastEventId:s,source:a,ports:c})}static createFastMessageEvent(e,r){let n=new t(MPt,e,r);return n.#e=r,n.#e.data??=null,n.#e.origin??="",n.#e.lastEventId??="",n.#e.source??=null,n.#e.ports??=[],n}},{createFastMessageEvent:tLn}=pH;delete pH.createFastMessageEvent;var F2e=class t extends Event{#e;constructor(e,r={}){let n="CloseEvent constructor";Ai.argumentLengthCheck(arguments,1,n),e=Ai.converters.DOMString(e,n,"type"),r=Ai.converters.CloseEventInit(r),super(e,r),this.#e=r,Ai.util.markAsUncloneable(this)}get wasClean(){return Ai.brandCheck(this,t),this.#e.wasClean}get code(){return Ai.brandCheck(this,t),this.#e.code}get reason(){return Ai.brandCheck(this,t),this.#e.reason}},U2e=class t extends Event{#e;constructor(e,r){let n="ErrorEvent constructor";Ai.argumentLengthCheck(arguments,1,n),super(e,r),Ai.util.markAsUncloneable(this),e=Ai.converters.DOMString(e,n,"type"),r=Ai.converters.ErrorEventInit(r??{}),this.#e=r}get message(){return Ai.brandCheck(this,t),this.#e.message}get filename(){return Ai.brandCheck(this,t),this.#e.filename}get lineno(){return Ai.brandCheck(this,t),this.#e.lineno}get colno(){return Ai.brandCheck(this,t),this.#e.colno}get error(){return Ai.brandCheck(this,t),this.#e.error}};Object.defineProperties(pH.prototype,{[Symbol.toStringTag]:{value:"MessageEvent",configurable:!0},data:X1,origin:X1,lastEventId:X1,source:X1,ports:X1,initMessageEvent:X1});Object.defineProperties(F2e.prototype,{[Symbol.toStringTag]:{value:"CloseEvent",configurable:!0},reason:X1,code:X1,wasClean:X1});Object.defineProperties(U2e.prototype,{[Symbol.toStringTag]:{value:"ErrorEvent",configurable:!0},message:X1,filename:X1,lineno:X1,colno:X1,error:X1});Ai.converters.MessagePort=Ai.interfaceConverter(Ai.is.MessagePort,"MessagePort");Ai.converters["sequence<MessagePort>"]=Ai.sequenceConverter(Ai.converters.MessagePort);var CQe=[{key:"bubbles",converter:Ai.converters.boolean,defaultValue:()=>!1},{key:"cancelable",converter:Ai.converters.boolean,defaultValue:()=>!1},{key:"composed",converter:Ai.converters.boolean,defaultValue:()=>!1}];Ai.converters.MessageEventInit=Ai.dictionaryConverter([...CQe,{key:"data",converter:Ai.converters.any,defaultValue:()=>null},{key:"origin",converter:Ai.converters.USVString,defaultValue:()=>""},{key:"lastEventId",converter:Ai.converters.DOMString,defaultValue:()=>""},{key:"source",converter:Ai.nullableConverter(Ai.converters.MessagePort),defaultValue:()=>null},{key:"ports",converter:Ai.converters["sequence<MessagePort>"],defaultValue:()=>new Array(0)}]);Ai.converters.CloseEventInit=Ai.dictionaryConverter([...CQe,{key:"wasClean",converter:Ai.converters.boolean,defaultValue:()=>!1},{key:"code",converter:Ai.converters["unsigned short"],defaultValue:()=>0},{key:"reason",converter:Ai.converters.USVString,defaultValue:()=>""}]);Ai.converters.ErrorEventInit=Ai.dictionaryConverter([...CQe,{key:"message",converter:Ai.converters.DOMString,defaultValue:()=>""},{key:"filename",converter:Ai.converters.USVString,defaultValue:()=>""},{key:"lineno",converter:Ai.converters["unsigned long"],defaultValue:()=>0},{key:"colno",converter:Ai.converters["unsigned long"],defaultValue:()=>0},{key:"error",converter:Ai.converters.any}]);kPt.exports={MessageEvent:pH,CloseEvent:F2e,ErrorEvent:U2e,createFastMessageEvent:tLn}});var Ox=B((QNo,LPt)=>{"use strict";var rLn="258EAFA5-E914-47DA-95CA-C5AB0DC85B11",nLn={enumerable:!0,writable:!1,configurable:!1},iLn={CONNECTING:0,OPEN:1,CLOSING:2,CLOSED:3},oLn={SENT:1,RECEIVED:2},sLn={CONTINUATION:0,TEXT:1,BINARY:2,CLOSE:8,PING:9,PONG:10},aLn=65535,lLn={INFO:0,PAYLOADLENGTH_16:2,PAYLOADLENGTH_64:3,READ_DATA:4},cLn=Buffer.allocUnsafe(0),uLn={text:1,typedArray:2,arrayBuffer:3,blob:4};LPt.exports={uid:rLn,sentCloseFrameState:oLn,staticPropertyDescriptors:nLn,states:iLn,opcodes:sLn,maxUnsigned16Bit:aLn,parserStates:lLn,emptyBuffer:cLn,sendHints:uLn}});var FN=B((qNo,qPt)=>{"use strict";var{states:q2e,opcodes:hH}=Ox(),{isUtf8:fLn}=we("node:buffer"),{collectASequenceOfCodePointsFast:dLn,removeHTTPWhitespace:PPt}=D3();function pLn(t){return t===q2e.CONNECTING}function hLn(t){return t===q2e.OPEN}function mLn(t){return t===q2e.CLOSING}function gLn(t){return t===q2e.CLOSED}function ALn(t,e,r=(i,o)=>new Event(i,o),n={}){let i=r(t,n);e.dispatchEvent(i)}function yLn(t,e,r){t.onMessage(e,r)}function ELn(t){return t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer}function vLn(t){if(t.length===0)return!1;for(let e=0;e<t.length;++e){let r=t.charCodeAt(e);if(r<33||r>126||r===34||r===40||r===41||r===44||r===47||r===58||r===59||r===60||r===61||r===62||r===63||r===64||r===91||r===92||r===93||r===123||r===125)return!1}return!0}function bLn(t){return t>=1e3&&t<1015?t!==1004&&t!==1005&&t!==1006:t>=3e3&&t<=4999}function FPt(t){return t===hH.CLOSE||t===hH.PING||t===hH.PONG}function UPt(t){return t===hH.CONTINUATION}function QPt(t){return t===hH.TEXT||t===hH.BINARY}function CLn(t){return QPt(t)||UPt(t)||FPt(t)}function _Ln(t){let e={position:0},r=new Map;for(;e.position<t.length;){let n=dLn(";",t,e),[i,o=""]=n.split("=",2);r.set(PPt(i,!0,!1),PPt(o,!1,!0)),e.position++}return r}function SLn(t){for(let e=0;e<t.length;e++){let r=t.charCodeAt(e);if(r<48||r>57)return!1}return!0}function wLn(t,e){let r;try{r=new URL(t,e)}catch(n){throw new DOMException(n,"SyntaxError")}if(r.protocol==="http:"?r.protocol="ws:":r.protocol==="https:"&&(r.protocol="wss:"),r.protocol!=="ws:"&&r.protocol!=="wss:")throw new DOMException("expected a ws: or wss: url","SyntaxError");if(r.hash.length||r.href.endsWith("#"))throw new DOMException("hash","SyntaxError");return r}function xLn(t,e){if(t!==null&&t!==1e3&&(t<3e3||t>4999))throw new DOMException("invalid code","InvalidAccessError");if(e!==null){let r=Buffer.byteLength(e);if(r>123)throw new DOMException(`Reason must be less than 123 bytes; received ${r}`,"SyntaxError")}}var TLn=(()=>{if(typeof process.versions.icu=="string"){let t=new TextDecoder("utf-8",{fatal:!0});return t.decode.bind(t)}return function(t){if(fLn(t))return t.toString("utf-8");throw new TypeError("Invalid utf-8 received.")}})();qPt.exports={isConnecting:pLn,isEstablished:hLn,isClosing:mLn,isClosed:gLn,fireEvent:ALn,isValidSubprotocol:vLn,isValidStatusCode:bLn,websocketMessageReceived:yLn,utf8Decode:TLn,isControlFrame:FPt,isContinuationFrame:UPt,isTextBinaryFrame:QPt,isValidOpcode:CLn,parseExtensions:_Ln,isValidClientWindowBits:SLn,toArrayBuffer:ELn,getURLRecord:wLn,validateCloseCodeAndReason:xLn}});var gH=B((HNo,GPt)=>{"use strict";var{maxUnsigned16Bit:HPt,opcodes:DLn}=Ox(),H2e=8*1024,_Qe,see=null,mH=H2e;try{_Qe=we("node:crypto")}catch{_Qe={randomFillSync:function(e,r,n){for(let i=0;i<e.length;++i)e[i]=Math.random()*255|0;return e}}}function SQe(){return mH===H2e&&(mH=0,_Qe.randomFillSync(see??=Buffer.allocUnsafeSlow(H2e),0,H2e)),[see[mH++],see[mH++],see[mH++],see[mH++]]}var wQe=class{constructor(e){this.frameData=e}createFrame(e){let r=this.frameData,n=SQe(),i=r?.byteLength??0,o=i,s=6;i>HPt?(s+=8,o=127):i>125&&(s+=2,o=126);let a=Buffer.allocUnsafe(i+s);a[0]=a[1]=0,a[0]|=128,a[0]=(a[0]&240)+e;a[s-4]=n[0],a[s-3]=n[1],a[s-2]=n[2],a[s-1]=n[3],a[1]=o,o===126?a.writeUInt16BE(i,2):o===127&&(a[2]=a[3]=0,a.writeUIntBE(i,4,6)),a[1]|=128;for(let c=0;c<i;++c)a[s+c]=r[c]^n[c&3];return a}static createFastTextFrame(e){let r=SQe(),n=e.length;for(let a=0;a<n;++a)e[a]^=r[a&3];let i=n,o=6;n>HPt?(o+=8,i=127):n>125&&(o+=2,i=126);let s=Buffer.allocUnsafeSlow(o);return s[0]=128|DLn.TEXT,s[1]=i|128,s[o-4]=r[0],s[o-3]=r[1],s[o-2]=r[2],s[o-1]=r[3],i===126?s.writeUInt16BE(n,2):i===127&&(s[2]=s[3]=0,s.writeUIntBE(n,4,6)),[s,e]}};GPt.exports={WebsocketFrameSend:wQe,generateMask:SQe}});var j2e=B((GNo,WPt)=>{"use strict";var{uid:ILn,states:G2e,sentCloseFrameState:xQe,emptyBuffer:jPt,opcodes:RLn}=Ox(),{parseExtensions:BLn,isClosed:NLn,isClosing:OLn,isEstablished:VPt,validateCloseCodeAndReason:MLn}=FN(),{makeRequest:kLn}=uH(),{fetching:LLn}=ree(),{Headers:PLn,getHeadersList:FLn}=NN(),{getDecodeSplit:ULn}=Pg(),{WebsocketFrameSend:QLn}=gH(),qLn=we("node:assert"),TQe;try{TQe=we("node:crypto")}catch{}function HLn(t,e,r,n,i){let o=t;o.protocol=t.protocol==="ws:"?"http:":"https:";let s=kLn({urlList:[o],client:r,serviceWorkers:"none",referrer:"no-referrer",mode:"websocket",credentials:"include",cache:"no-store",redirect:"error"});if(i.headers){let f=FLn(new PLn(i.headers));s.headersList=f}let a=TQe.randomBytes(16).toString("base64");s.headersList.append("sec-websocket-key",a,!0),s.headersList.append("sec-websocket-version","13",!0);for(let f of e)s.headersList.append("sec-websocket-protocol",f,!0);return s.headersList.append("sec-websocket-extensions","permessage-deflate; client_max_window_bits",!0),LLn({request:s,useParallelQueue:!0,dispatcher:i.dispatcher,processResponse(f){if(f.type==="error"&&(n.readyState=G2e.CLOSED),f.type==="error"||f.status!==101){k7(n,1002,"Received network error or non-101 status code.",f.error);return}if(e.length!==0&&!f.headersList.get("Sec-WebSocket-Protocol")){k7(n,1002,"Server did not respond with sent protocols.");return}if(f.headersList.get("Upgrade")?.toLowerCase()!=="websocket"){k7(n,1002,'Server did not set Upgrade header to "websocket".');return}if(f.headersList.get("Connection")?.toLowerCase()!=="upgrade"){k7(n,1002,'Server did not set Connection header to "upgrade".');return}let d=f.headersList.get("Sec-WebSocket-Accept"),p=TQe.createHash("sha1").update(a+ILn).digest("base64");if(d!==p){k7(n,1002,"Incorrect hash received in Sec-WebSocket-Accept header.");return}let h=f.headersList.get("Sec-WebSocket-Extensions"),g;if(h!==null&&(g=BLn(h),!g.has("permessage-deflate"))){k7(n,1002,"Sec-WebSocket-Extensions header does not match.");return}let A=f.headersList.get("Sec-WebSocket-Protocol");if(A!==null&&!ULn("sec-websocket-protocol",s.headersList).includes(A)){k7(n,1002,"Protocol was not set in the opening handshake.");return}f.socket.on("data",n.onSocketData),f.socket.on("close",n.onSocketClose),f.socket.on("error",n.onSocketError),n.wasEverConnected=!0,n.onConnectionEstablished(f,g)}})}function $Pt(t,e,r,n=!1){if(e??=null,r??="",n&&MLn(e,r),!(NLn(t.readyState)||OLn(t.readyState)))if(!VPt(t.readyState))k7(t),t.readyState=G2e.CLOSING;else if(!t.closeState.has(xQe.SENT)&&!t.closeState.has(xQe.RECEIVED)){let i=new QLn;r.length!==0&&e===null&&(e=1e3),qLn(e===null||Number.isInteger(e)),e===null&&r.length===0?i.frameData=jPt:e!==null&&r===null?(i.frameData=Buffer.allocUnsafe(2),i.frameData.writeUInt16BE(e,0)):e!==null&&r!==null?(i.frameData=Buffer.allocUnsafe(2+Buffer.byteLength(r)),i.frameData.writeUInt16BE(e,0),i.frameData.write(r,2,"utf-8")):i.frameData=jPt,t.socket.write(i.createFrame(RLn.CLOSE)),t.closeState.add(xQe.SENT),t.readyState=G2e.CLOSING}else t.readyState=G2e.CLOSING}function k7(t,e,r,n){VPt(t.readyState)&&$Pt(t,e,r,!1),t.controller.abort(),t.socket?.destroyed===!1&&t.socket.destroy(),t.onFail(e,r,n)}WPt.exports={establishWebSocketConnection:HLn,failWebsocketConnection:k7,closeWebSocketConnection:$Pt}});var zPt=B((jNo,YPt)=>{"use strict";var{createInflateRaw:GLn,Z_DEFAULT_WINDOWBITS:jLn}=we("node:zlib"),{isValidClientWindowBits:VLn}=FN(),$Ln=Buffer.from([0,0,255,255]),V2e=Symbol("kBuffer"),$2e=Symbol("kLength"),DQe=class{#e;#t={};constructor(e){this.#t.serverNoContextTakeover=e.has("server_no_context_takeover"),this.#t.serverMaxWindowBits=e.get("server_max_window_bits")}decompress(e,r,n){if(!this.#e){let i=jLn;if(this.#t.serverMaxWindowBits){if(!VLn(this.#t.serverMaxWindowBits)){n(new Error("Invalid server_max_window_bits"));return}i=Number.parseInt(this.#t.serverMaxWindowBits)}this.#e=GLn({windowBits:i}),this.#e[V2e]=[],this.#e[$2e]=0,this.#e.on("data",o=>{this.#e[V2e].push(o),this.#e[$2e]+=o.length}),this.#e.on("error",o=>{this.#e=null,n(o)})}this.#e.write(e),r&&this.#e.write($Ln),this.#e.flush(()=>{let i=Buffer.concat(this.#e[V2e],this.#e[$2e]);this.#e[V2e].length=0,this.#e[$2e]=0,n(null,i)})}};YPt.exports={PerMessageDeflate:DQe}});var BQe=B((VNo,eFt)=>{"use strict";var{Writable:WLn}=we("node:stream"),YLn=we("node:assert"),{parserStates:Z1,opcodes:AH,states:zLn,emptyBuffer:JPt,sentCloseFrameState:aee}=Ox(),{isValidStatusCode:JLn,isValidOpcode:KLn,websocketMessageReceived:KPt,utf8Decode:XLn,isControlFrame:XPt,isTextBinaryFrame:IQe,isContinuationFrame:ZLn}=FN(),{failWebsocketConnection:k3}=j2e(),{WebsocketFrameSend:ZPt}=gH(),{PerMessageDeflate:ePn}=zPt(),RQe=class extends WLn{#e=[];#t=0;#r=0;#n=!1;#o=Z1.INFO;#i={};#c=[];#s;#a;constructor(e,r){super(),this.#a=e,this.#s=r??new Map,this.#s.has("permessage-deflate")&&this.#s.set("permessage-deflate",new ePn(r))}_write(e,r,n){this.#e.push(e),this.#r+=e.length,this.#n=!0,this.run(n)}run(e){for(;this.#n;)if(this.#o===Z1.INFO){if(this.#r<2)return e();let r=this.consume(2),n=(r[0]&128)!==0,i=r[0]&15,o=(r[1]&128)===128,s=!n&&i!==AH.CONTINUATION,a=r[1]&127,c=r[0]&64,u=r[0]&32,f=r[0]&16;if(!KLn(i))return k3(this.#a,1002,"Invalid opcode received"),e();if(o)return k3(this.#a,1002,"Frame cannot be masked"),e();if(c!==0&&!this.#s.has("permessage-deflate")){k3(this.#a,1002,"Expected RSV1 to be clear.");return}if(u!==0||f!==0){k3(this.#a,1002,"RSV1, RSV2, RSV3 must be clear");return}if(s&&!IQe(i)){k3(this.#a,1002,"Invalid frame type was fragmented.");return}if(IQe(i)&&this.#c.length>0){k3(this.#a,1002,"Expected continuation frame");return}if(this.#i.fragmented&&s){k3(this.#a,1002,"Fragmented frame exceeded 125 bytes.");return}if((a>125||s)&&XPt(i)){k3(this.#a,1002,"Control frame either too large or fragmented");return}if(ZLn(i)&&this.#c.length===0&&!this.#i.compressed){k3(this.#a,1002,"Unexpected continuation frame");return}a<=125?(this.#i.payloadLength=a,this.#o=Z1.READ_DATA):a===126?this.#o=Z1.PAYLOADLENGTH_16:a===127&&(this.#o=Z1.PAYLOADLENGTH_64),IQe(i)&&(this.#i.binaryType=i,this.#i.compressed=c!==0),this.#i.opcode=i,this.#i.masked=o,this.#i.fin=n,this.#i.fragmented=s}else if(this.#o===Z1.PAYLOADLENGTH_16){if(this.#r<2)return e();let r=this.consume(2);this.#i.payloadLength=r.readUInt16BE(0),this.#o=Z1.READ_DATA}else if(this.#o===Z1.PAYLOADLENGTH_64){if(this.#r<8)return e();let r=this.consume(8),n=r.readUInt32BE(0);if(n>2**31-1){k3(this.#a,1009,"Received payload length > 2^31 bytes.");return}let i=r.readUInt32BE(4);this.#i.payloadLength=(n<<8)+i,this.#o=Z1.READ_DATA}else if(this.#o===Z1.READ_DATA){if(this.#r<this.#i.payloadLength)return e();let r=this.consume(this.#i.payloadLength);if(XPt(this.#i.opcode))this.#n=this.parseControlFrame(r),this.#o=Z1.INFO;else if(!this.#i.compressed)this.writeFragments(r),!this.#i.fragmented&&this.#i.fin&&KPt(this.#a,this.#i.binaryType,this.consumeFragments()),this.#o=Z1.INFO;else{this.#s.get("permessage-deflate").decompress(r,this.#i.fin,(n,i)=>{if(n){k3(this.#a,1007,n.message);return}if(this.writeFragments(i),!this.#i.fin){this.#o=Z1.INFO,this.#n=!0,this.run(e);return}KPt(this.#a,this.#i.binaryType,this.consumeFragments()),this.#n=!0,this.#o=Z1.INFO,this.run(e)}),this.#n=!1;break}}}consume(e){if(e>this.#r)throw new Error("Called consume() before buffers satiated.");if(e===0)return JPt;this.#r-=e;let r=this.#e[0];if(r.length>e)return this.#e[0]=r.subarray(e,r.length),r.subarray(0,e);if(r.length===e)return this.#e.shift();{let n=0,i=Buffer.allocUnsafeSlow(e);for(;n!==e;){let o=this.#e[0],s=o.length;if(s+n===e){i.set(this.#e.shift(),n);break}else if(s+n>e){i.set(o.subarray(0,e-n),n),this.#e[0]=o.subarray(e-n);break}else i.set(this.#e.shift(),n),n+=s}return i}}writeFragments(e){this.#t+=e.length,this.#c.push(e)}consumeFragments(){let e=this.#c;if(e.length===1)return this.#t=0,e.shift();let r=0,n=Buffer.allocUnsafeSlow(this.#t);for(let i=0;i<e.length;++i){let o=e[i];n.set(o,r),r+=o.length}return this.#c=[],this.#t=0,n}parseCloseBody(e){YLn(e.length!==1);let r;if(e.length>=2&&(r=e.readUInt16BE(0)),r!==void 0&&!JLn(r))return{code:1002,reason:"Invalid status code",error:!0};let n=e.subarray(2);n[0]===239&&n[1]===187&&n[2]===191&&(n=n.subarray(3));try{n=XLn(n)}catch{return{code:1007,reason:"Invalid UTF-8",error:!0}}return{code:r,reason:n,error:!1}}parseControlFrame(e){let{opcode:r,payloadLength:n}=this.#i;if(r===AH.CLOSE){if(n===1)return k3(this.#a,1002,"Received close frame with a 1-byte body."),!1;if(this.#i.closeInfo=this.parseCloseBody(e),this.#i.closeInfo.error){let{code:i,reason:o}=this.#i.closeInfo;return k3(this.#a,i,o),!1}if(!this.#a.closeState.has(aee.SENT)&&!this.#a.closeState.has(aee.RECEIVED)){let i=JPt;this.#i.closeInfo.code&&(i=Buffer.allocUnsafe(2),i.writeUInt16BE(this.#i.closeInfo.code,0));let o=new ZPt(i);this.#a.socket.write(o.createFrame(AH.CLOSE)),this.#a.closeState.add(aee.SENT)}return this.#a.readyState=zLn.CLOSING,this.#a.closeState.add(aee.RECEIVED),!1}else if(r===AH.PING){if(!this.#a.closeState.has(aee.RECEIVED)){let i=new ZPt(e);this.#a.socket.write(i.createFrame(AH.PONG)),this.#a.onPing(e)}}else r===AH.PONG&&this.#a.onPong(e);return!0}get closingInfo(){return this.#i.closeInfo}};eFt.exports={ByteParser:RQe}});var iFt=B(($No,nFt)=>{"use strict";var{WebsocketFrameSend:rFt}=gH(),{opcodes:tFt,sendHints:UN}=Ox(),tPn=yFe(),OQe=class{#e=new tPn;#t=!1;#r;constructor(e){this.#r=e}add(e,r,n){if(n!==UN.blob){if(this.#t){let o={promise:null,callback:r,frame:NQe(e,n)};this.#e.push(o)}else if(n===UN.text){let{0:o,1:s}=rFt.createFastTextFrame(e);this.#r.cork(),this.#r.write(o),this.#r.write(s,r),this.#r.uncork()}else this.#r.write(NQe(e,n),r);return}let i={promise:e.arrayBuffer().then(o=>{i.promise=null,i.frame=NQe(o,n)}),callback:r,frame:null};this.#e.push(i),this.#t||this.#n()}async#n(){this.#t=!0;let e=this.#e;for(;!e.isEmpty();){let r=e.shift();r.promise!==null&&await r.promise,this.#r.write(r.frame,r.callback),r.callback=r.frame=null}this.#t=!1}};function NQe(t,e){return new rFt(rPn(t,e)).createFrame(e===UN.text?tFt.TEXT:tFt.BINARY)}function rPn(t,e){switch(e){case UN.text:case UN.typedArray:return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);case UN.arrayBuffer:case UN.blob:return new Uint8Array(t)}}nFt.exports={SendQueue:OQe}});var dFt=B((WNo,fFt)=>{"use strict";var{isArrayBuffer:uFt}=we("node:util/types"),{webidl:$i}=u2(),{URLSerializer:nPn}=D3(),{environmentSettingsObject:oFt}=Pg(),{staticPropertyDescriptors:Mx,states:f8,sentCloseFrameState:MQe,sendHints:W2e,opcodes:kQe}=Ox(),{isConnecting:iPn,isEstablished:sFt,isClosing:aFt,isClosed:oPn,isValidSubprotocol:sPn,fireEvent:lee,utf8Decode:aPn,toArrayBuffer:lPn,getURLRecord:cPn}=FN(),{establishWebSocketConnection:uPn,closeWebSocketConnection:fPn,failWebsocketConnection:lFt}=j2e(),{ByteParser:dPn}=BQe(),{kEnumerableProperty:W6}=jo(),{getGlobalDispatcher:pPn}=c2e(),{ErrorEvent:hPn,CloseEvent:cFt,createFastMessageEvent:mPn}=Q2e(),{SendQueue:gPn}=iFt(),{WebsocketFrameSend:APn}=gH(),{channels:u8}=fN(),Ug=class t extends EventTarget{#e={open:null,error:null,close:null,message:null};#t=0;#r="";#n="";#o;#i={onConnectionEstablished:(e,r)=>this.#u(e,r),onFail:(e,r,n)=>this.#l(e,r,n),onMessage:(e,r)=>this.#p(e,r),onParserError:e=>lFt(this.#i,null,e.message),onParserDrain:()=>this.#g(),onSocketData:e=>{this.#a.write(e)||this.#i.socket.pause()},onSocketError:e=>{this.#i.readyState=f8.CLOSING,u8.socketError.hasSubscribers&&u8.socketError.publish(e),this.#i.socket.destroy()},onSocketClose:()=>this.#h(),onPing:e=>{u8.ping.hasSubscribers&&u8.ping.publish({payload:e,websocket:this})},onPong:e=>{u8.pong.hasSubscribers&&u8.pong.publish({payload:e,websocket:this})},readyState:f8.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1};#c;#s;#a;constructor(e,r=[]){super(),$i.util.markAsUncloneable(this);let n="WebSocket constructor";$i.argumentLengthCheck(arguments,1,n);let i=$i.converters["DOMString or sequence<DOMString> or WebSocketInit"](r,n,"options");e=$i.converters.USVString(e),r=i.protocols;let o=oFt.settingsObject.baseUrl,s=cPn(e,o);if(typeof r=="string"&&(r=[r]),r.length!==new Set(r.map(c=>c.toLowerCase())).size)throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(r.length>0&&!r.every(c=>sPn(c)))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");this.#c=new URL(s.href);let a=oFt.settingsObject;this.#i.controller=uPn(s,r,a,this.#i,i),this.#i.readyState=t.CONNECTING,this.#s="blob"}close(e=void 0,r=void 0){$i.brandCheck(this,t),e!==void 0&&(e=$i.converters["unsigned short"](e,"WebSocket.close","code",{clamp:!0})),r!==void 0&&(r=$i.converters.USVString(r)),e??=null,r??="",fPn(this.#i,e,r,!0)}send(e){$i.brandCheck(this,t);let r="WebSocket.send";if($i.argumentLengthCheck(arguments,1,r),e=$i.converters.WebSocketSendData(e,r,"data"),iPn(this.#i.readyState))throw new DOMException("Sent before connected.","InvalidStateError");if(!(!sFt(this.#i.readyState)||aFt(this.#i.readyState)))if(typeof e=="string"){let n=Buffer.from(e);this.#t+=n.byteLength,this.#o.add(n,()=>{this.#t-=n.byteLength},W2e.text)}else uFt(e)?(this.#t+=e.byteLength,this.#o.add(e,()=>{this.#t-=e.byteLength},W2e.arrayBuffer)):ArrayBuffer.isView(e)?(this.#t+=e.byteLength,this.#o.add(e,()=>{this.#t-=e.byteLength},W2e.typedArray)):$i.is.Blob(e)&&(this.#t+=e.size,this.#o.add(e,()=>{this.#t-=e.size},W2e.blob))}get readyState(){return $i.brandCheck(this,t),this.#i.readyState}get bufferedAmount(){return $i.brandCheck(this,t),this.#t}get url(){return $i.brandCheck(this,t),nPn(this.#c)}get extensions(){return $i.brandCheck(this,t),this.#n}get protocol(){return $i.brandCheck(this,t),this.#r}get onopen(){return $i.brandCheck(this,t),this.#e.open}set onopen(e){$i.brandCheck(this,t),this.#e.open&&this.removeEventListener("open",this.#e.open),typeof e=="function"?(this.#e.open=e,this.addEventListener("open",e)):this.#e.open=null}get onerror(){return $i.brandCheck(this,t),this.#e.error}set onerror(e){$i.brandCheck(this,t),this.#e.error&&this.removeEventListener("error",this.#e.error),typeof e=="function"?(this.#e.error=e,this.addEventListener("error",e)):this.#e.error=null}get onclose(){return $i.brandCheck(this,t),this.#e.close}set onclose(e){$i.brandCheck(this,t),this.#e.close&&this.removeEventListener("close",this.#e.close),typeof e=="function"?(this.#e.close=e,this.addEventListener("close",e)):this.#e.close=null}get onmessage(){return $i.brandCheck(this,t),this.#e.message}set onmessage(e){$i.brandCheck(this,t),this.#e.message&&this.removeEventListener("message",this.#e.message),typeof e=="function"?(this.#e.message=e,this.addEventListener("message",e)):this.#e.message=null}get binaryType(){return $i.brandCheck(this,t),this.#s}set binaryType(e){$i.brandCheck(this,t),e!=="blob"&&e!=="arraybuffer"?this.#s="blob":this.#s=e}#u(e,r){this.#i.socket=e.socket;let n=new dPn(this.#i,r);n.on("drain",()=>this.#i.onParserDrain()),n.on("error",s=>this.#i.onParserError(s)),this.#a=n,this.#o=new gPn(e.socket),this.#i.readyState=f8.OPEN;let i=e.headersList.get("sec-websocket-extensions");i!==null&&(this.#n=i);let o=e.headersList.get("sec-websocket-protocol");if(o!==null&&(this.#r=o),lee("open",this),u8.open.hasSubscribers){let s=e.headersList.entries;u8.open.publish({address:e.socket.address(),protocol:this.#r,extensions:this.#n,websocket:this,handshakeResponse:{status:e.status,statusText:e.statusText,headers:s}})}}#l(e,r,n){r&&lee("error",this,(i,o)=>new hPn(i,o),{error:new Error(r,n?{cause:n}:void 0),message:r}),this.#i.wasEverConnected||(this.#i.readyState=f8.CLOSED,lee("close",this,(i,o)=>new cFt(i,o),{wasClean:!1,code:e,reason:r}))}#p(e,r){if(this.#i.readyState!==f8.OPEN)return;let n;if(e===kQe.TEXT)try{n=aPn(r)}catch{lFt(this.#i,1007,"Received invalid UTF-8 in text frame.");return}else e===kQe.BINARY&&(this.#s==="blob"?n=new Blob([r]):n=lPn(r));lee("message",this,mPn,{origin:this.#c.origin,data:n})}#g(){this.#i.socket.resume()}#h(){let e=this.#i.closeState.has(MQe.SENT)&&this.#i.closeState.has(MQe.RECEIVED),r=1005,n="",i=this.#a.closingInfo;i&&!i.error?(r=i.code??1005,n=i.reason):this.#i.closeState.has(MQe.RECEIVED)||(r=1006),this.#i.readyState=f8.CLOSED,lee("close",this,(o,s)=>new cFt(o,s),{wasClean:e,code:r,reason:n}),u8.close.hasSubscribers&&u8.close.publish({websocket:this,code:r,reason:n})}static ping(e,r){if(Buffer.isBuffer(r)){if(r.length>125)throw new TypeError("A PING frame cannot have a body larger than 125 bytes.")}else if(r!==void 0)throw new TypeError("Expected buffer payload");let n=e.#i.readyState;if(sFt(n)&&!aFt(n)&&!oPn(n)){let i=new APn(r);e.#i.socket.write(i.createFrame(kQe.PING))}}},{ping:yPn}=Ug;Reflect.deleteProperty(Ug,"ping");Ug.CONNECTING=Ug.prototype.CONNECTING=f8.CONNECTING;Ug.OPEN=Ug.prototype.OPEN=f8.OPEN;Ug.CLOSING=Ug.prototype.CLOSING=f8.CLOSING;Ug.CLOSED=Ug.prototype.CLOSED=f8.CLOSED;Object.defineProperties(Ug.prototype,{CONNECTING:Mx,OPEN:Mx,CLOSING:Mx,CLOSED:Mx,url:W6,readyState:W6,bufferedAmount:W6,onopen:W6,onerror:W6,onclose:W6,close:W6,onmessage:W6,binaryType:W6,send:W6,extensions:W6,protocol:W6,[Symbol.toStringTag]:{value:"WebSocket",writable:!1,enumerable:!1,configurable:!0}});Object.defineProperties(Ug,{CONNECTING:Mx,OPEN:Mx,CLOSING:Mx,CLOSED:Mx});$i.converters["sequence<DOMString>"]=$i.sequenceConverter($i.converters.DOMString);$i.converters["DOMString or sequence<DOMString>"]=function(t,e,r){return $i.util.Type(t)===$i.util.Types.OBJECT&&Symbol.iterator in t?$i.converters["sequence<DOMString>"](t):$i.converters.DOMString(t,e,r)};$i.converters.WebSocketInit=$i.dictionaryConverter([{key:"protocols",converter:$i.converters["DOMString or sequence<DOMString>"],defaultValue:()=>new Array(0)},{key:"dispatcher",converter:$i.converters.any,defaultValue:()=>pPn()},{key:"headers",converter:$i.nullableConverter($i.converters.HeadersInit)}]);$i.converters["DOMString or sequence<DOMString> or WebSocketInit"]=function(t){return $i.util.Type(t)===$i.util.Types.OBJECT&&!(Symbol.iterator in t)?$i.converters.WebSocketInit(t):{protocols:$i.converters["DOMString or sequence<DOMString>"](t)}};$i.converters.WebSocketSendData=function(t){return $i.util.Type(t)===$i.util.Types.OBJECT&&($i.is.Blob(t)||ArrayBuffer.isView(t)||uFt(t))?t:$i.converters.USVString(t)};fFt.exports={WebSocket:Ug,ping:yPn}});var LQe=B((YNo,mFt)=>{"use strict";var{webidl:Y2e}=u2(),{validateCloseCodeAndReason:EPn}=FN(),{kConstruct:pFt}=Fc(),{kEnumerableProperty:hFt}=jo(),QN=class t extends DOMException{#e;#t;constructor(e="",r=void 0){if(e=Y2e.converters.DOMString(e,"WebSocketError","message"),super(e,"WebSocketError"),r===pFt)return;r!==null&&(r=Y2e.converters.WebSocketCloseInfo(r));let n=r.closeCode??null,i=r.reason??"";EPn(n,i),i.length!==0&&n===null&&(n=1e3),this.#e=n,this.#t=i}get closeCode(){return this.#e}get reason(){return this.#t}static createUnvalidatedWebSocketError(e,r,n){let i=new t(e,pFt);return i.#e=r,i.#t=n,i}},{createUnvalidatedWebSocketError:vPn}=QN;delete QN.createUnvalidatedWebSocketError;Object.defineProperties(QN.prototype,{closeCode:hFt,reason:hFt,[Symbol.toStringTag]:{value:"WebSocketError",writable:!1,enumerable:!1,configurable:!0}});Y2e.is.WebSocketError=Y2e.util.MakeTypeAssertion(QN);mFt.exports={WebSocketError:QN,createUnvalidatedWebSocketError:vPn}});var vFt=B((zNo,EFt)=>{"use strict";var{createDeferredPromise:PQe}=_Z(),{environmentSettingsObject:gFt}=Pg(),{states:yH,opcodes:z2e,sentCloseFrameState:EH}=Ox(),{webidl:hm}=u2(),{getURLRecord:bPn,isValidSubprotocol:CPn,isEstablished:_Pn,utf8Decode:SPn}=FN(),{establishWebSocketConnection:wPn,failWebsocketConnection:FQe,closeWebSocketConnection:UQe}=j2e(),{isArrayBuffer:xPn}=we("node:util/types"),{channels:AFt}=fN(),{WebsocketFrameSend:TPn}=gH(),{ByteParser:DPn}=BQe(),{WebSocketError:IPn,createUnvalidatedWebSocketError:RPn}=LQe(),{utf8DecodeBytes:BPn}=Pg(),{kEnumerableProperty:J2e}=jo(),yFt=!1,K2e=class{#e;#t;#r;#n;#o;#i;#c=!1;#s={onConnectionEstablished:(e,r)=>this.#l(e,r),onFail:(e,r)=>{},onMessage:(e,r)=>this.#p(e,r),onParserError:e=>FQe(this.#s,null,e.message),onParserDrain:()=>this.#s.socket.resume(),onSocketData:e=>{this.#a.write(e)||this.#s.socket.pause()},onSocketError:e=>{this.#s.readyState=yH.CLOSING,AFt.socketError.hasSubscribers&&AFt.socketError.publish(e),this.#s.socket.destroy()},onSocketClose:()=>this.#g(),onPing:()=>{},onPong:()=>{},readyState:yH.CONNECTING,socket:null,closeState:new Set,controller:null,wasEverConnected:!1};#a;constructor(e,r=void 0){yFt||(process.emitWarning("WebSocketStream is experimental! Expect it to change at any time.",{code:"UNDICI-WSS"}),yFt=!0),hm.argumentLengthCheck(arguments,1,"WebSocket"),e=hm.converters.USVString(e),r!==null&&(r=hm.converters.WebSocketStreamOptions(r));let n=gFt.settingsObject.baseUrl,i=bPn(e,n),o=r.protocols;if(o.length!==new Set(o.map(a=>a.toLowerCase())).size)throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(o.length>0&&!o.every(a=>CPn(a)))throw new DOMException("Invalid Sec-WebSocket-Protocol value","SyntaxError");if(this.#e=i.toString(),this.#t=PQe(),this.#r=PQe(),r.signal!=null){let a=r.signal;if(a.aborted){this.#t.reject(a.reason),this.#r.reject(a.reason);return}a.addEventListener("abort",()=>{_Pn(this.#s.readyState)||(FQe(this.#s),this.#s.readyState=yH.CLOSING,this.#t.reject(a.reason),this.#r.reject(a.reason),this.#c=!0)},{once:!0})}let s=gFt.settingsObject;this.#s.controller=wPn(i,o,s,this.#s,r)}get url(){return this.#e.toString()}get opened(){return this.#t.promise}get closed(){return this.#r.promise}close(e=void 0){e!==null&&(e=hm.converters.WebSocketCloseInfo(e));let r=e.closeCode??null,n=e.reason;UQe(this.#s,r,n,!0)}#u(e){let r=PQe(),n=null,i=null;if(ArrayBuffer.isView(e)||xPn(e))n=new Uint8Array(ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e),i=z2e.BINARY;else{let o;try{o=hm.converters.DOMString(e)}catch(s){r.reject(s);return}n=new TextEncoder().encode(o),i=z2e.TEXT}if(!this.#s.closeState.has(EH.SENT)&&!this.#s.closeState.has(EH.RECEIVED)){let o=new TPn(n);this.#s.socket.write(o.createFrame(i),()=>{r.resolve(void 0)})}return r}#l(e,r){this.#s.socket=e.socket;let n=new DPn(this.#s,r);n.on("drain",()=>this.#s.onParserDrain()),n.on("error",c=>this.#s.onParserError(c)),this.#a=n,this.#s.readyState=yH.OPEN;let i=r??"",o=e.headersList.get("sec-websocket-protocol")??"",s=new ReadableStream({start:c=>{this.#o=c},pull(c){let u;for(;c.desiredSize>0&&(u=e.socket.read())!==null;)c.enqueue(u)},cancel:c=>this.#m(c)}),a=new WritableStream({write:c=>this.#u(c),close:()=>UQe(this.#s,null,null),abort:c=>this.#h(c)});this.#n=s,this.#i=a,this.#t.resolve({extensions:i,protocol:o,readable:s,writable:a})}#p(e,r){if(this.#s.readyState!==yH.OPEN)return;let n;if(e===z2e.TEXT)try{n=SPn(r)}catch{FQe(this.#s,"Received invalid UTF-8 in text frame.");return}else e===z2e.BINARY&&(n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength));this.#o.enqueue(n)}#g(){let e=this.#s.closeState.has(EH.SENT)&&this.#s.closeState.has(EH.RECEIVED);if(this.#s.readyState=yH.CLOSED,this.#c)return;this.#s.wasEverConnected||this.#t.reject(new IPn("Socket never opened"));let r=this.#a.closingInfo,n=r?.code??1005;!this.#s.closeState.has(EH.SENT)&&!this.#s.closeState.has(EH.RECEIVED)&&(n=1006);let i=r?.reason==null?"":BPn(Buffer.from(r.reason));if(e)this.#o.close(),this.#i.locked||this.#i.abort(new DOMException("A closed WebSocketStream cannot be written to","InvalidStateError")),this.#r.resolve({closeCode:n,reason:i});else{let o=RPn("unclean close",n,i);this.#o.error(o),this.#i.abort(o),this.#r.reject(o)}}#h(e){let r=null,n="";hm.is.WebSocketError(e)&&(r=e.closeCode,n=e.reason),UQe(this.#s,r,n)}#m(e){this.#h(e)}};Object.defineProperties(K2e.prototype,{url:J2e,opened:J2e,closed:J2e,close:J2e,[Symbol.toStringTag]:{value:"WebSocketStream",writable:!1,enumerable:!1,configurable:!0}});hm.converters.WebSocketStreamOptions=hm.dictionaryConverter([{key:"protocols",converter:hm.sequenceConverter(hm.converters.USVString),defaultValue:()=>[]},{key:"signal",converter:hm.nullableConverter(hm.converters.AbortSignal),defaultValue:()=>null}]);hm.converters.WebSocketCloseInfo=hm.dictionaryConverter([{key:"closeCode",converter:t=>hm.converters["unsigned short"](t,{enforceRange:!0})},{key:"reason",converter:hm.converters.USVString,defaultValue:()=>""}]);EFt.exports={WebSocketStream:K2e}});var QQe=B((JNo,bFt)=>{"use strict";function NPn(t){return t.indexOf("\0")===-1}function OPn(t){if(t.length===0)return!1;for(let e=0;e<t.length;e++)if(t.charCodeAt(e)<48||t.charCodeAt(e)>57)return!1;return!0}function MPn(t){return new Promise(e=>{setTimeout(e,t)})}bFt.exports={isValidLastEventId:NPn,isASCIINumber:OPn,delay:MPn}});var wFt=B((KNo,SFt)=>{"use strict";var{Transform:kPn}=we("node:stream"),{isASCIINumber:CFt,isValidLastEventId:_Ft}=QQe(),L7=[239,187,191],qQe=10,X2e=13,LPn=58,PPn=32,HQe=class extends kPn{state;checkBOM=!0;crlfCheck=!1;eventEndCheck=!1;buffer=null;pos=0;event={data:void 0,event:void 0,id:void 0,retry:void 0};constructor(e={}){e.readableObjectMode=!0,super(e),this.state=e.eventSourceSettings||{},e.push&&(this.push=e.push)}_transform(e,r,n){if(e.length===0){n();return}if(this.buffer?this.buffer=Buffer.concat([this.buffer,e]):this.buffer=e,this.checkBOM)switch(this.buffer.length){case 1:if(this.buffer[0]===L7[0]){n();return}this.checkBOM=!1,n();return;case 2:if(this.buffer[0]===L7[0]&&this.buffer[1]===L7[1]){n();return}this.checkBOM=!1;break;case 3:if(this.buffer[0]===L7[0]&&this.buffer[1]===L7[1]&&this.buffer[2]===L7[2]){this.buffer=Buffer.alloc(0),this.checkBOM=!1,n();return}this.checkBOM=!1;break;default:this.buffer[0]===L7[0]&&this.buffer[1]===L7[1]&&this.buffer[2]===L7[2]&&(this.buffer=this.buffer.subarray(3)),this.checkBOM=!1;break}for(;this.pos<this.buffer.length;){if(this.eventEndCheck){if(this.crlfCheck){if(this.buffer[this.pos]===qQe){this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.crlfCheck=!1;continue}this.crlfCheck=!1}if(this.buffer[this.pos]===qQe||this.buffer[this.pos]===X2e){this.buffer[this.pos]===X2e&&(this.crlfCheck=!0),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,(this.event.data!==void 0||this.event.event||this.event.id||this.event.retry)&&this.processEvent(this.event),this.clearEvent();continue}this.eventEndCheck=!1;continue}if(this.buffer[this.pos]===qQe||this.buffer[this.pos]===X2e){this.buffer[this.pos]===X2e&&(this.crlfCheck=!0),this.parseLine(this.buffer.subarray(0,this.pos),this.event),this.buffer=this.buffer.subarray(this.pos+1),this.pos=0,this.eventEndCheck=!0;continue}this.pos++}n()}parseLine(e,r){if(e.length===0)return;let n=e.indexOf(LPn);if(n===0)return;let i="",o="";if(n!==-1){i=e.subarray(0,n).toString("utf8");let s=n+1;e[s]===PPn&&++s,o=e.subarray(s).toString("utf8")}else i=e.toString("utf8"),o="";switch(i){case"data":r[i]===void 0?r[i]=o:r[i]+=`
|
|
474
|
-
${o}`;break;case"retry":CFt(o)&&(r[i]=o);break;case"id":_Ft(o)&&(r[i]=o);break;case"event":o.length>0&&(r[i]=o);break}}processEvent(e){e.retry&&CFt(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),e.id&&_Ft(e.id)&&(this.state.lastEventId=e.id),e.data!==void 0&&this.push({type:e.event||"message",options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}};SFt.exports={EventSourceStream:HQe}});var OFt=B((XNo,NFt)=>{"use strict";var{pipeline:FPn}=we("node:stream"),{fetching:UPn}=ree(),{makeRequest:QPn}=uH(),{webidl:Y6}=u2(),{EventSourceStream:qPn}=wFt(),{parseMIMEType:HPn}=D3(),{createFastMessageEvent:GPn}=Q2e(),{isNetworkError:xFt}=eee(),{delay:jPn}=QQe(),{kEnumerableProperty:qN}=jo(),{environmentSettingsObject:TFt}=Pg(),DFt=!1,IFt=3e3,cee=0,RFt=1,uee=2,VPn="anonymous",$Pn="use-credentials",vH=class t extends EventTarget{#e={open:null,error:null,message:null};#t;#r=!1;#n=cee;#o=null;#i=null;#c;#s;constructor(e,r={}){super(),Y6.util.markAsUncloneable(this);let n="EventSource constructor";Y6.argumentLengthCheck(arguments,1,n),DFt||(DFt=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"})),e=Y6.converters.USVString(e),r=Y6.converters.EventSourceInitDict(r,n,"eventSourceInitDict"),this.#c=r.node.dispatcher||r.dispatcher,this.#s={lastEventId:"",reconnectionTime:r.node.reconnectionTime};let i=TFt,o;try{o=new URL(e,i.settingsObject.baseUrl),this.#s.origin=o.origin}catch(c){throw new DOMException(c,"SyntaxError")}this.#t=o.href;let s=VPn;r.withCredentials===!0&&(s=$Pn,this.#r=!0);let a={redirect:"follow",keepalive:!0,mode:"cors",credentials:s==="anonymous"?"same-origin":"omit",referrer:"no-referrer"};a.client=TFt.settingsObject,a.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],a.cache="no-store",a.initiator="other",a.urlList=[new URL(this.#t)],this.#o=QPn(a),this.#a()}get readyState(){return this.#n}get url(){return this.#t}get withCredentials(){return this.#r}#a(){if(this.#n===uee)return;this.#n=cee;let e={request:this.#o,dispatcher:this.#c},r=n=>{if(!xFt(n))return this.#u()};e.processResponseEndOfBody=r,e.processResponse=n=>{if(xFt(n))if(n.aborted){this.close(),this.dispatchEvent(new Event("error"));return}else{this.#u();return}let i=n.headersList.get("content-type",!0),o=i!==null?HPn(i):"failure",s=o!=="failure"&&o.essence==="text/event-stream";if(n.status!==200||s===!1){this.close(),this.dispatchEvent(new Event("error"));return}this.#n=RFt,this.dispatchEvent(new Event("open")),this.#s.origin=n.urlList[n.urlList.length-1].origin;let a=new qPn({eventSourceSettings:this.#s,push:c=>{this.dispatchEvent(GPn(c.type,c.options))}});FPn(n.body.stream,a,c=>{c?.aborted===!1&&(this.close(),this.dispatchEvent(new Event("error")))})},this.#i=UPn(e)}async#u(){this.#n!==uee&&(this.#n=cee,this.dispatchEvent(new Event("error")),await jPn(this.#s.reconnectionTime),this.#n===cee&&(this.#s.lastEventId.length&&this.#o.headersList.set("last-event-id",this.#s.lastEventId,!0),this.#a()))}close(){Y6.brandCheck(this,t),this.#n!==uee&&(this.#n=uee,this.#i.abort(),this.#o=null)}get onopen(){return this.#e.open}set onopen(e){this.#e.open&&this.removeEventListener("open",this.#e.open),typeof e=="function"?(this.#e.open=e,this.addEventListener("open",e)):this.#e.open=null}get onmessage(){return this.#e.message}set onmessage(e){this.#e.message&&this.removeEventListener("message",this.#e.message),typeof e=="function"?(this.#e.message=e,this.addEventListener("message",e)):this.#e.message=null}get onerror(){return this.#e.error}set onerror(e){this.#e.error&&this.removeEventListener("error",this.#e.error),typeof e=="function"?(this.#e.error=e,this.addEventListener("error",e)):this.#e.error=null}},BFt={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:cee,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:RFt,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:uee,writable:!1}};Object.defineProperties(vH,BFt);Object.defineProperties(vH.prototype,BFt);Object.defineProperties(vH.prototype,{close:qN,onerror:qN,onmessage:qN,onopen:qN,readyState:qN,url:qN,withCredentials:qN});Y6.converters.EventSourceInitDict=Y6.dictionaryConverter([{key:"withCredentials",converter:Y6.converters.boolean,defaultValue:()=>!1},{key:"dispatcher",converter:Y6.converters.any},{key:"node",converter:Y6.dictionaryConverter([{key:"reconnectionTime",converter:Y6.converters["unsigned long"],defaultValue:()=>IFt},{key:"dispatcher",converter:Y6.converters.any}]),defaultValue:()=>({})}]);NFt.exports={EventSource:vH,defaultReconnectionTime:IFt}});var tme=B((ZNo,Dn)=>{"use strict";var WPn=CN(),MFt=AZ(),YPn=zq(),zPn=cOt(),JPn=wN(),KPn=LFe(),XPn=OOt(),ZPn=UOt(),eFn=HOt(),kFt=ms(),eme=jo(),{InvalidArgumentError:Z2e}=kFt,bH=_Mt(),tFn=EZ(),rFn=vUe(),{MockCallHistory:nFn,MockCallHistoryLog:iFn}=_Ue(),oFn=NUe(),sFn=TUe(),aFn=vkt(),lFn=oUe(),cFn=Y0e(),{getGlobalDispatcher:LFt,setGlobalDispatcher:uFn}=c2e(),fFn=oH(),dFn=HUe();Object.assign(MFt.prototype,bH);Dn.exports.Dispatcher=MFt;Dn.exports.Client=WPn;Dn.exports.Pool=YPn;Dn.exports.BalancedPool=zPn;Dn.exports.Agent=JPn;Dn.exports.ProxyAgent=KPn;Dn.exports.EnvHttpProxyAgent=XPn;Dn.exports.RetryAgent=ZPn;Dn.exports.H2CClient=eFn;Dn.exports.RetryHandler=cFn;Dn.exports.DecoratorHandler=fFn;Dn.exports.RedirectHandler=dFn;Dn.exports.interceptors={redirect:Bkt(),responseError:Okt(),retry:kkt(),dump:Pkt(),dns:Ukt(),cache:iLt(),decompress:uLt()};Dn.exports.cacheStores={MemoryCacheStore:KUe()};var pFn=pLt();Dn.exports.cacheStores.SqliteCacheStore=pFn;Dn.exports.buildConnector=tFn;Dn.exports.errors=kFt;Dn.exports.util={parseHeaders:eme.parseHeaders,headerNameToString:eme.headerNameToString};function fee(t){return(e,r,n)=>{if(typeof r=="function"&&(n=r,r=null),!e||typeof e!="string"&&typeof e!="object"&&!(e instanceof URL))throw new Z2e("invalid url");if(r!=null&&typeof r!="object")throw new Z2e("invalid opts");if(r&&r.path!=null){if(typeof r.path!="string")throw new Z2e("invalid opts.path");let s=r.path;r.path.startsWith("/")||(s=`/${s}`),e=new URL(eme.parseOrigin(e).origin+s)}else r||(r=typeof e=="object"?e:{}),e=eme.parseURL(e);let{agent:i,dispatcher:o=LFt()}=r;if(i)throw new Z2e("unsupported opts.agent. Did you mean opts.client?");return t.call(o,{...r,origin:e.origin,path:e.search?`${e.pathname}${e.search}`:e.pathname,method:r.method||(r.body?"PUT":"GET")},n)}}Dn.exports.setGlobalDispatcher=uFn;Dn.exports.getGlobalDispatcher=LFt;var hFn=ree().fetch;Dn.exports.fetch=async function(e,r=void 0){try{return await hFn(e,r)}catch(n){throw n&&typeof n=="object"&&Error.captureStackTrace(n),n}};Dn.exports.Headers=NN().Headers;Dn.exports.Response=eee().Response;Dn.exports.Request=uH().Request;Dn.exports.FormData=_0e().FormData;var{setGlobalOrigin:mFn,getGlobalOrigin:gFn}=UPe();Dn.exports.setGlobalOrigin=mFn;Dn.exports.getGlobalOrigin=gFn;var{CacheStorage:AFn}=vPt(),{kConstruct:yFn}=Fc();Dn.exports.caches=new AFn(yFn);var{deleteCookie:EFn,getCookies:vFn,getSetCookies:bFn,setCookie:CFn,parseCookie:_Fn}=OPt();Dn.exports.deleteCookie=EFn;Dn.exports.getCookies=vFn;Dn.exports.getSetCookies=bFn;Dn.exports.setCookie=CFn;Dn.exports.parseCookie=_Fn;var{parseMIMEType:SFn,serializeAMimeType:wFn}=D3();Dn.exports.parseMIMEType=SFn;Dn.exports.serializeAMimeType=wFn;var{CloseEvent:xFn,ErrorEvent:TFn,MessageEvent:DFn}=Q2e(),{WebSocket:IFn,ping:RFn}=dFt();Dn.exports.WebSocket=IFn;Dn.exports.CloseEvent=xFn;Dn.exports.ErrorEvent=TFn;Dn.exports.MessageEvent=DFn;Dn.exports.ping=RFn;Dn.exports.WebSocketStream=vFt().WebSocketStream;Dn.exports.WebSocketError=LQe().WebSocketError;Dn.exports.request=fee(bH.request);Dn.exports.stream=fee(bH.stream);Dn.exports.pipeline=fee(bH.pipeline);Dn.exports.connect=fee(bH.connect);Dn.exports.upgrade=fee(bH.upgrade);Dn.exports.MockClient=rFn;Dn.exports.MockCallHistory=nFn;Dn.exports.MockCallHistoryLog=iFn;Dn.exports.MockPool=sFn;Dn.exports.MockAgent=oFn;Dn.exports.SnapshotAgent=aFn;Dn.exports.mockErrors=lFn;var{EventSource:BFn}=OFt();Dn.exports.EventSource=BFn;function NFn(){globalThis.fetch=Dn.exports.fetch,globalThis.Headers=Dn.exports.Headers,globalThis.Response=Dn.exports.Response,globalThis.Request=Dn.exports.Request,globalThis.FormData=Dn.exports.FormData,globalThis.WebSocket=Dn.exports.WebSocket,globalThis.CloseEvent=Dn.exports.CloseEvent,globalThis.ErrorEvent=Dn.exports.ErrorEvent,globalThis.MessageEvent=Dn.exports.MessageEvent,globalThis.EventSource=Dn.exports.EventSource}Dn.exports.install=NFn});async function PFt(t,e,r){if(e!==um)return e;let n=um,i=tf,o=`https://generativelanguage.googleapis.com/v1beta/models/${n}:generateContent`,s=JSON.stringify({contents:[{parts:[{text:"test"}]}],generationConfig:{maxOutputTokens:1,temperature:0,topK:1,thinkingConfig:{thinkingBudget:128,includeThoughts:!1}}}),a=new AbortController,c=setTimeout(()=>a.abort(),2e3);try{r&&(0,rme.setGlobalDispatcher)(new rme.ProxyAgent(r));let u=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":t},body:s,signal:a.signal});return clearTimeout(c),u.status===429?(console.log(`[INFO] Your configured model (${n}) was temporarily unavailable. Switched to ${i} for this session.`),i):e}catch{return clearTimeout(c),e}}var rme,FFt=Re(()=>{"use strict";rme=ze(tme(),1);y5();});function CH(t,e){if(e&&e>0)return e;if(!t||typeof t!="string")return 128e3;let r=t.toLowerCase();if(UFt[t])return UFt[t];for(let n of MFn)if(n.pattern.test(r)){for(let[i,o]of Object.entries(n.limits))if(i!=="default"&&r.includes(i))return o;return n.limits.default??n.defaultLimit??128e3}return 128e3}function GQe(t,e=0,r){if(!t||typeof t!="string")return 8e3;let n=t.toLowerCase(),i=8e3;if(QFt[t])i=QFt[t];else for(let a of kFn)if(a.pattern.test(n)){for(let[c,u]of Object.entries(a.limits))if(c!=="default"&&n.includes(c)){i=u;break}i===8e3&&(i=a.limits.default??a.defaultLimit??8e3);break}let s=CH(t,r)-e;return Math.min(i,s)}var OFn,MFn,UFt,kFn,QFt,nme=Re(()=>{"use strict";OFn=128e3,MFn=[{pattern:/kimi/i,limits:{"k2-0905":256e3,k2:128e3}},{pattern:/glm/i,limits:{},defaultLimit:128e3},{pattern:/claude/i,limits:{},defaultLimit:2e5},{pattern:/deepseek/i,limits:{v3:128e3,default:65e3}},{pattern:/qwen3/i,limits:{coder:2e5,thinking:2e5,instruct:2e5,"max-preview":256e3,default:128e3}},{pattern:/qwen/i,limits:{max:1228e3,plus:1228e3}},{pattern:/gpt/i,limits:{"32k":32e3,default:128e3}}],UFt={"gemini-1.5-pro":2097152,"gemini-1.5-flash":1048576,"gemini-2.5-pro-preview-05-06":1048576,"gemini-2.5-pro-preview-06-05":1048576,"gemini-2.5-pro":1048576,"gemini-2.5-flash-preview-05-20":1048576,"gemini-2.5-flash":1048576,"gemini-2.0-flash":1048576,"gemini-2.0-flash-preview-image-generation":32e3},kFn=[{pattern:/kimi/i,limits:{k2:16384,"k2-0905":16384,default:8e3}},{pattern:/glm/i,limits:{},defaultLimit:64e3},{pattern:/claude/i,limits:{},defaultLimit:64e3},{pattern:/deepseek|seek/i,limits:{v3:8192,r1:32e3,default:8e3}},{pattern:/qwen3/i,limits:{coder:32e3,"max-preview":32e3,default:8192}},{pattern:/qwen/i,limits:{max:8192,plus:8192,default:8e3}},{pattern:/gpt/i,limits:{"32k":4096,default:16384}}],QFt={"gemini-1.5-pro":8192,"gemini-1.5-flash":65536,"gemini-2.5-pro-preview-05-06":65536,"gemini-2.5-pro-preview-06-05":65536,"gemini-2.5-pro":65536,"gemini-2.5-flash-preview-05-20":65536,"gemini-2.5-flash":65536,"gemini-2.0-flash":65536,"gemini-2.0-flash-preview-image-generation":8192}});var z6,jQe=Re(()=>{"use strict";z6=class{apiKey;baseUrl;modelName;constructor(e,r,n){this.apiKey=e,this.baseUrl=r,this.modelName=n||""}async generateImageDescription(e,r){if(!this.modelName)throw new Error("No multimodal model specified for image description");let n=this.createImageAnalysisPrompt();try{let o={model:this.baseUrl==="https://apis.iflow.cn/v1"?"qwen-vl-max":this.modelName,messages:[{role:"user",content:[{type:"text",text:n},{type:"image_url",image_url:{url:`data:${r};base64,${e}`}}]}],temperature:.1,max_tokens:2e3},s=await fetch(`${this.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,"user-agent":"iFlow-Cli-MultimodalHelper"},body:JSON.stringify(o)});if(!s.ok){let u=await s.text();throw new Error(`API error! status: ${s.status}, body: ${u} TraceID: ${s.headers.get("eagleeye-traceid")}`)}let a;try{a=await s.json()}catch{throw new Error(`Response format error. TraceID: ${s.headers.get("eagleeye-traceid")}`)}if(a.msg&&a.msg.includes("invalid apiKey"))throw new Error("Invalid API key provided for model");let c=a.choices?.[0]?.message?.content;if(!c)throw new Error("No description generated by model");return c.trim()}catch(i){throw new Error(`Image description error: ${i instanceof Error?i.message:String(i)}`)}}createImageAnalysisPrompt(){return`\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u591A\u6A21\u6001AI\u5206\u6790\u4E13\u5BB6\uFF0C\u80FD\u591F\u6DF1\u5EA6\u7406\u89E3\u56FE\u7247\u5185\u5BB9\u5E76\u63D0\u4F9B\u53EF\u7528\u4E8E\u56DE\u7B54\u95EE\u9898\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002\u8BF7\u6309\u4EE5\u4E0B\u7B56\u7565\u5206\u6790\u56FE\u7247\uFF1A
|
|
474
|
+
${o}`;break;case"retry":CFt(o)&&(r[i]=o);break;case"id":_Ft(o)&&(r[i]=o);break;case"event":o.length>0&&(r[i]=o);break}}processEvent(e){e.retry&&CFt(e.retry)&&(this.state.reconnectionTime=parseInt(e.retry,10)),e.id&&_Ft(e.id)&&(this.state.lastEventId=e.id),e.data!==void 0&&this.push({type:e.event||"message",options:{data:e.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}};SFt.exports={EventSourceStream:HQe}});var OFt=B((XNo,NFt)=>{"use strict";var{pipeline:FPn}=we("node:stream"),{fetching:UPn}=ree(),{makeRequest:QPn}=uH(),{webidl:Y6}=u2(),{EventSourceStream:qPn}=wFt(),{parseMIMEType:HPn}=D3(),{createFastMessageEvent:GPn}=Q2e(),{isNetworkError:xFt}=eee(),{delay:jPn}=QQe(),{kEnumerableProperty:qN}=jo(),{environmentSettingsObject:TFt}=Pg(),DFt=!1,IFt=3e3,cee=0,RFt=1,uee=2,VPn="anonymous",$Pn="use-credentials",vH=class t extends EventTarget{#e={open:null,error:null,message:null};#t;#r=!1;#n=cee;#o=null;#i=null;#c;#s;constructor(e,r={}){super(),Y6.util.markAsUncloneable(this);let n="EventSource constructor";Y6.argumentLengthCheck(arguments,1,n),DFt||(DFt=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"})),e=Y6.converters.USVString(e),r=Y6.converters.EventSourceInitDict(r,n,"eventSourceInitDict"),this.#c=r.node.dispatcher||r.dispatcher,this.#s={lastEventId:"",reconnectionTime:r.node.reconnectionTime};let i=TFt,o;try{o=new URL(e,i.settingsObject.baseUrl),this.#s.origin=o.origin}catch(c){throw new DOMException(c,"SyntaxError")}this.#t=o.href;let s=VPn;r.withCredentials===!0&&(s=$Pn,this.#r=!0);let a={redirect:"follow",keepalive:!0,mode:"cors",credentials:s==="anonymous"?"same-origin":"omit",referrer:"no-referrer"};a.client=TFt.settingsObject,a.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],a.cache="no-store",a.initiator="other",a.urlList=[new URL(this.#t)],this.#o=QPn(a),this.#a()}get readyState(){return this.#n}get url(){return this.#t}get withCredentials(){return this.#r}#a(){if(this.#n===uee)return;this.#n=cee;let e={request:this.#o,dispatcher:this.#c},r=n=>{if(!xFt(n))return this.#u()};e.processResponseEndOfBody=r,e.processResponse=n=>{if(xFt(n))if(n.aborted){this.close(),this.dispatchEvent(new Event("error"));return}else{this.#u();return}let i=n.headersList.get("content-type",!0),o=i!==null?HPn(i):"failure",s=o!=="failure"&&o.essence==="text/event-stream";if(n.status!==200||s===!1){this.close(),this.dispatchEvent(new Event("error"));return}this.#n=RFt,this.dispatchEvent(new Event("open")),this.#s.origin=n.urlList[n.urlList.length-1].origin;let a=new qPn({eventSourceSettings:this.#s,push:c=>{this.dispatchEvent(GPn(c.type,c.options))}});FPn(n.body.stream,a,c=>{c?.aborted===!1&&(this.close(),this.dispatchEvent(new Event("error")))})},this.#i=UPn(e)}async#u(){this.#n!==uee&&(this.#n=cee,this.dispatchEvent(new Event("error")),await jPn(this.#s.reconnectionTime),this.#n===cee&&(this.#s.lastEventId.length&&this.#o.headersList.set("last-event-id",this.#s.lastEventId,!0),this.#a()))}close(){Y6.brandCheck(this,t),this.#n!==uee&&(this.#n=uee,this.#i.abort(),this.#o=null)}get onopen(){return this.#e.open}set onopen(e){this.#e.open&&this.removeEventListener("open",this.#e.open),typeof e=="function"?(this.#e.open=e,this.addEventListener("open",e)):this.#e.open=null}get onmessage(){return this.#e.message}set onmessage(e){this.#e.message&&this.removeEventListener("message",this.#e.message),typeof e=="function"?(this.#e.message=e,this.addEventListener("message",e)):this.#e.message=null}get onerror(){return this.#e.error}set onerror(e){this.#e.error&&this.removeEventListener("error",this.#e.error),typeof e=="function"?(this.#e.error=e,this.addEventListener("error",e)):this.#e.error=null}},BFt={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:cee,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:RFt,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:uee,writable:!1}};Object.defineProperties(vH,BFt);Object.defineProperties(vH.prototype,BFt);Object.defineProperties(vH.prototype,{close:qN,onerror:qN,onmessage:qN,onopen:qN,readyState:qN,url:qN,withCredentials:qN});Y6.converters.EventSourceInitDict=Y6.dictionaryConverter([{key:"withCredentials",converter:Y6.converters.boolean,defaultValue:()=>!1},{key:"dispatcher",converter:Y6.converters.any},{key:"node",converter:Y6.dictionaryConverter([{key:"reconnectionTime",converter:Y6.converters["unsigned long"],defaultValue:()=>IFt},{key:"dispatcher",converter:Y6.converters.any}]),defaultValue:()=>({})}]);NFt.exports={EventSource:vH,defaultReconnectionTime:IFt}});var tme=B((ZNo,Dn)=>{"use strict";var WPn=CN(),MFt=AZ(),YPn=zq(),zPn=cOt(),JPn=wN(),KPn=LFe(),XPn=OOt(),ZPn=UOt(),eFn=HOt(),kFt=ms(),eme=jo(),{InvalidArgumentError:Z2e}=kFt,bH=_Mt(),tFn=EZ(),rFn=vUe(),{MockCallHistory:nFn,MockCallHistoryLog:iFn}=_Ue(),oFn=NUe(),sFn=TUe(),aFn=vkt(),lFn=oUe(),cFn=Y0e(),{getGlobalDispatcher:LFt,setGlobalDispatcher:uFn}=c2e(),fFn=oH(),dFn=HUe();Object.assign(MFt.prototype,bH);Dn.exports.Dispatcher=MFt;Dn.exports.Client=WPn;Dn.exports.Pool=YPn;Dn.exports.BalancedPool=zPn;Dn.exports.Agent=JPn;Dn.exports.ProxyAgent=KPn;Dn.exports.EnvHttpProxyAgent=XPn;Dn.exports.RetryAgent=ZPn;Dn.exports.H2CClient=eFn;Dn.exports.RetryHandler=cFn;Dn.exports.DecoratorHandler=fFn;Dn.exports.RedirectHandler=dFn;Dn.exports.interceptors={redirect:Bkt(),responseError:Okt(),retry:kkt(),dump:Pkt(),dns:Ukt(),cache:iLt(),decompress:uLt()};Dn.exports.cacheStores={MemoryCacheStore:KUe()};var pFn=pLt();Dn.exports.cacheStores.SqliteCacheStore=pFn;Dn.exports.buildConnector=tFn;Dn.exports.errors=kFt;Dn.exports.util={parseHeaders:eme.parseHeaders,headerNameToString:eme.headerNameToString};function fee(t){return(e,r,n)=>{if(typeof r=="function"&&(n=r,r=null),!e||typeof e!="string"&&typeof e!="object"&&!(e instanceof URL))throw new Z2e("invalid url");if(r!=null&&typeof r!="object")throw new Z2e("invalid opts");if(r&&r.path!=null){if(typeof r.path!="string")throw new Z2e("invalid opts.path");let s=r.path;r.path.startsWith("/")||(s=`/${s}`),e=new URL(eme.parseOrigin(e).origin+s)}else r||(r=typeof e=="object"?e:{}),e=eme.parseURL(e);let{agent:i,dispatcher:o=LFt()}=r;if(i)throw new Z2e("unsupported opts.agent. Did you mean opts.client?");return t.call(o,{...r,origin:e.origin,path:e.search?`${e.pathname}${e.search}`:e.pathname,method:r.method||(r.body?"PUT":"GET")},n)}}Dn.exports.setGlobalDispatcher=uFn;Dn.exports.getGlobalDispatcher=LFt;var hFn=ree().fetch;Dn.exports.fetch=async function(e,r=void 0){try{return await hFn(e,r)}catch(n){throw n&&typeof n=="object"&&Error.captureStackTrace(n),n}};Dn.exports.Headers=NN().Headers;Dn.exports.Response=eee().Response;Dn.exports.Request=uH().Request;Dn.exports.FormData=_0e().FormData;var{setGlobalOrigin:mFn,getGlobalOrigin:gFn}=UPe();Dn.exports.setGlobalOrigin=mFn;Dn.exports.getGlobalOrigin=gFn;var{CacheStorage:AFn}=vPt(),{kConstruct:yFn}=Fc();Dn.exports.caches=new AFn(yFn);var{deleteCookie:EFn,getCookies:vFn,getSetCookies:bFn,setCookie:CFn,parseCookie:_Fn}=OPt();Dn.exports.deleteCookie=EFn;Dn.exports.getCookies=vFn;Dn.exports.getSetCookies=bFn;Dn.exports.setCookie=CFn;Dn.exports.parseCookie=_Fn;var{parseMIMEType:SFn,serializeAMimeType:wFn}=D3();Dn.exports.parseMIMEType=SFn;Dn.exports.serializeAMimeType=wFn;var{CloseEvent:xFn,ErrorEvent:TFn,MessageEvent:DFn}=Q2e(),{WebSocket:IFn,ping:RFn}=dFt();Dn.exports.WebSocket=IFn;Dn.exports.CloseEvent=xFn;Dn.exports.ErrorEvent=TFn;Dn.exports.MessageEvent=DFn;Dn.exports.ping=RFn;Dn.exports.WebSocketStream=vFt().WebSocketStream;Dn.exports.WebSocketError=LQe().WebSocketError;Dn.exports.request=fee(bH.request);Dn.exports.stream=fee(bH.stream);Dn.exports.pipeline=fee(bH.pipeline);Dn.exports.connect=fee(bH.connect);Dn.exports.upgrade=fee(bH.upgrade);Dn.exports.MockClient=rFn;Dn.exports.MockCallHistory=nFn;Dn.exports.MockCallHistoryLog=iFn;Dn.exports.MockPool=sFn;Dn.exports.MockAgent=oFn;Dn.exports.SnapshotAgent=aFn;Dn.exports.mockErrors=lFn;var{EventSource:BFn}=OFt();Dn.exports.EventSource=BFn;function NFn(){globalThis.fetch=Dn.exports.fetch,globalThis.Headers=Dn.exports.Headers,globalThis.Response=Dn.exports.Response,globalThis.Request=Dn.exports.Request,globalThis.FormData=Dn.exports.FormData,globalThis.WebSocket=Dn.exports.WebSocket,globalThis.CloseEvent=Dn.exports.CloseEvent,globalThis.ErrorEvent=Dn.exports.ErrorEvent,globalThis.MessageEvent=Dn.exports.MessageEvent,globalThis.EventSource=Dn.exports.EventSource}Dn.exports.install=NFn});async function PFt(t,e,r){if(e!==um)return e;let n=um,i=tf,o=`https://generativelanguage.googleapis.com/v1beta/models/${n}:generateContent`,s=JSON.stringify({contents:[{parts:[{text:"test"}]}],generationConfig:{maxOutputTokens:1,temperature:0,topK:1,thinkingConfig:{thinkingBudget:128,includeThoughts:!1}}}),a=new AbortController,c=setTimeout(()=>a.abort(),2e3);try{r&&(0,rme.setGlobalDispatcher)(new rme.ProxyAgent(r));let u=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":t},body:s,signal:a.signal});return clearTimeout(c),u.status===429?(console.log(`[INFO] Your configured model (${n}) was temporarily unavailable. Switched to ${i} for this session.`),i):e}catch{return clearTimeout(c),e}}var rme,FFt=Re(()=>{"use strict";rme=ze(tme(),1);y5();});function CH(t,e){if(e&&e>0)return e;if(!t||typeof t!="string")return 128e3;let r=t.toLowerCase();if(UFt[t])return UFt[t];for(let n of MFn)if(n.pattern.test(r)){for(let[i,o]of Object.entries(n.limits))if(i!=="default"&&r.includes(i))return o;return n.limits.default??n.defaultLimit??128e3}return 128e3}function GQe(t,e=0,r){if(!t||typeof t!="string")return 8e3;let n=t.toLowerCase(),i=8e3;if(QFt[t])i=QFt[t];else for(let a of kFn)if(a.pattern.test(n)){for(let[c,u]of Object.entries(a.limits))if(c!=="default"&&n.includes(c)){i=u;break}i===8e3&&(i=a.limits.default??a.defaultLimit??8e3);break}let s=CH(t,r)-e;return Math.min(i,s)}var OFn,MFn,UFt,kFn,QFt,nme=Re(()=>{"use strict";OFn=128e3,MFn=[{pattern:/kimi/i,limits:{k2:128e3}},{pattern:/glm/i,limits:{},defaultLimit:128e3},{pattern:/claude/i,limits:{},defaultLimit:2e5},{pattern:/deepseek/i,limits:{v3:128e3,default:65e3}},{pattern:/qwen3/i,limits:{coder:2e5,thinking:2e5,instruct:2e5,default:128e3}},{pattern:/qwen/i,limits:{max:1228e3,plus:1228e3}},{pattern:/gpt/i,limits:{"32k":32e3,default:128e3}}],UFt={"gemini-1.5-pro":2097152,"gemini-1.5-flash":1048576,"gemini-2.5-pro-preview-05-06":1048576,"gemini-2.5-pro-preview-06-05":1048576,"gemini-2.5-pro":1048576,"gemini-2.5-flash-preview-05-20":1048576,"gemini-2.5-flash":1048576,"gemini-2.0-flash":1048576,"gemini-2.0-flash-preview-image-generation":32e3},kFn=[{pattern:/kimi/i,limits:{k2:16384,default:8e3}},{pattern:/glm/i,limits:{},defaultLimit:64e3},{pattern:/claude/i,limits:{},defaultLimit:64e3},{pattern:/deepseek|seek/i,limits:{v3:8192,r1:32e3,default:8e3}},{pattern:/qwen3/i,limits:{coder:32e3,default:8192}},{pattern:/qwen/i,limits:{max:8192,plus:8192,default:8e3}},{pattern:/gpt/i,limits:{"32k":4096,default:16384}}],QFt={"gemini-1.5-pro":8192,"gemini-1.5-flash":65536,"gemini-2.5-pro-preview-05-06":65536,"gemini-2.5-pro-preview-06-05":65536,"gemini-2.5-pro":65536,"gemini-2.5-flash-preview-05-20":65536,"gemini-2.5-flash":65536,"gemini-2.0-flash":65536,"gemini-2.0-flash-preview-image-generation":8192}});var z6,jQe=Re(()=>{"use strict";z6=class{apiKey;baseUrl;modelName;constructor(e,r,n){this.apiKey=e,this.baseUrl=r,this.modelName=n||""}async generateImageDescription(e,r){if(!this.modelName)throw new Error("No multimodal model specified for image description");let n=this.createImageAnalysisPrompt();try{let o={model:this.baseUrl==="https://apis.iflow.cn/v1"?"qwen-vl-max":this.modelName,messages:[{role:"user",content:[{type:"text",text:n},{type:"image_url",image_url:{url:`data:${r};base64,${e}`}}]}],temperature:.1,max_tokens:2e3},s=await fetch(`${this.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`,"user-agent":"iFlow-Cli-MultimodalHelper"},body:JSON.stringify(o)});if(!s.ok){let u=await s.text();throw new Error(`API error! status: ${s.status}, body: ${u} TraceID: ${s.headers.get("eagleeye-traceid")}`)}let a;try{a=await s.json()}catch{throw new Error(`Response format error. TraceID: ${s.headers.get("eagleeye-traceid")}`)}if(a.msg&&a.msg.includes("invalid apiKey"))throw new Error("Invalid API key provided for model");let c=a.choices?.[0]?.message?.content;if(!c)throw new Error("No description generated by model");return c.trim()}catch(i){throw new Error(`Image description error: ${i instanceof Error?i.message:String(i)}`)}}createImageAnalysisPrompt(){return`\u4F60\u662F\u4E00\u4E2A\u4E13\u4E1A\u7684\u591A\u6A21\u6001AI\u5206\u6790\u4E13\u5BB6\uFF0C\u80FD\u591F\u6DF1\u5EA6\u7406\u89E3\u56FE\u7247\u5185\u5BB9\u5E76\u63D0\u4F9B\u53EF\u7528\u4E8E\u56DE\u7B54\u95EE\u9898\u7684\u8BE6\u7EC6\u4FE1\u606F\u3002\u8BF7\u6309\u4EE5\u4E0B\u7B56\u7565\u5206\u6790\u56FE\u7247\uFF1A
|
|
475
475
|
|
|
476
476
|
**\u6838\u5FC3\u5206\u6790\u539F\u5219\uFF1A**
|
|
477
477
|
1. **\u4FE1\u606F\u63D0\u53D6\u4F18\u5148**\uFF1A\u91CD\u70B9\u63D0\u53D6\u56FE\u50CF\u4E2D\u7684\u5173\u952E\u4FE1\u606F\uFF0C\u5BF9\u6570\u5B66\u3001\u903B\u8F91\u95EE\u9898\u8FDB\u884C\u5B8C\u6574\u8F6C\u5F55
|
|
@@ -541,7 +541,7 @@ ${JSON.stringify(c,null,2)}`),c.usage&&(this.lastUsageMetadata={total_tokens:c.u
|
|
|
541
541
|
\u8FD9\u4E2A\u662F\u9519\u8BEF\u7684json\u683C\u5F0F\uFF1A
|
|
542
542
|
${e}
|
|
543
543
|
|
|
544
|
-
\u8BF7\u76F4\u63A5\u8F93\u51FA\u4E00\u4E2A\u6B63\u786E\u7684json\u683C\u5F0F\uFF1A`;try{let n=await fetch("https://apis.iflow.cn/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({model:"QWen3-4B",messages:[{role:"user",content:r}],temperature:.1,max_tokens:1e3})});if(!n.ok)throw new Error(`QWen API error: ${n.status}`);let i=await n.json();if(!i||!i.choices||!Array.isArray(i.choices)||i.choices.length===0)throw new Error("Invalid QWen response format - missing or empty choices array");let o=i.choices[0]?.message?.content;if(!o||typeof o!="string")throw new Error("Invalid QWen response - missing or invalid message content");let s=o.trim();if(s.startsWith("```json")?s=s.replace(/^```json\s*/,"").replace(/\s*```$/,""):s.startsWith("```")&&(s=s.replace(/^```\s*/,"").replace(/\s*```$/,"")),!s)throw new Error("Fixed JSON is empty after processing");return JSON.parse(s)}catch(n){throw x5(n),console.error("QWen JSON fix failed:",n),n}}extractTextFromRequest(e){let r="";if(e.contents){let n=Array.isArray(e.contents)?e.contents:[e.contents];for(let i of n)if(i&&typeof i=="object"&&"parts"in i&&i.parts){let o=Array.isArray(i.parts)?i.parts:[i.parts];for(let s of o)if(s&&typeof s=="object"&&"text"in s&&s.text)r+=s.text+" ";else if(s.functionResponse&&s.functionResponse.response)for(let[a,c]of Object.entries(s.functionResponse.response))c!=null&&(r+=String(c)+" ")}}return r+=e.config?.systemInstruction,r.trim()}extractTextFromEmbedRequest(e){if(e.contents){let r=Array.isArray(e.contents)?e.contents:[e.contents];for(let n of r)if(typeof n=="object"&&n!==null&&"parts"in n&&n.parts){let i=Array.isArray(n.parts)?n.parts:[n.parts];for(let o of i)if(typeof o=="object"&&o!==null&&"text"in o&&o.text)return o.text}else{if(typeof n=="string")return n;if(typeof n=="object"&&n!==null&&"text"in n&&n.text)return n.text}}return""}extractSystemInstruction(e){let r="";if(typeof e=="string")r=e;else if(Array.isArray(e)){for(let n of e)typeof n=="object"&&n!==null&&"text"in n&&n.text&&(r+=n.text+" ");r=r.trim()}else if(typeof e=="object"&&e!==null)if("parts"in e&&e.parts){let n=Array.isArray(e.parts)?e.parts:[e.parts];for(let i of n)typeof i=="object"&&i!==null&&"text"in i&&i.text&&(r+=i.text+" ");r=r.trim()}else"text"in e&&e.text&&(r=e.text);return r}convertToOpenAITools(e){if(!e||e.length===0)return[];let r=[];for(let n of e)if(n.functionDeclarations&&Array.isArray(n.functionDeclarations))for(let i of n.functionDeclarations)r.push({type:"function",function:{name:i.name||"",description:i.description,parameters:this.convertParameters(i.parameters||i.parametersJsonSchema)}});return r}convertParameters(e){if(!e)return;let r={STRING:"string",INTEGER:"integer",NUMBER:"number",BOOLEAN:"boolean",OBJECT:"object",ARRAY:"array"};if(typeof e=="object"&&e.type){if(typeof e.type=="string"&&(r[e.type]?e.type=r[e.type]:e.type=e.type.toLowerCase()),e.properties)for(let i in e.properties){let o=e.properties[i],s={};o.type&&(s.type=r[o.type]),o.description&&(s.description=o.description),e.properties[i]=s}return e.items&&(e.items=this.convertParameters(e.items)),e}let n=i=>{if(!i)return;let o={};if(i.type)switch(i.type){case"STRING":o.type="string";break;case"INTEGER":o.type="integer";break;case"NUMBER":o.type="number";break;case"BOOLEAN":o.type="boolean";break;case"OBJECT":o.type="object";break;case"ARRAY":o.type="array";break;default:o.type=i.type.toLowerCase()}if(o.type="object",i.description&&(o.description=i.description),i.enum&&(o.enum=i.enum),i.properties){o.properties={};for(let[s,a]of Object.entries(i.properties))o.properties[s]=n(a)}return i.items&&(o.items=n(i.items)),i.required&&(o.required=i.required),o};return n(e)}mapFinishReason(e){switch(e){case"stop":return Wf.STOP;case"length":return Wf.MAX_TOKENS;case"content_filter":return Wf.SAFETY;case"tool_calls":return Wf.MALFORMED_FUNCTION_CALL;default:return Wf.OTHER}}convertResponseSchema(e){if(e)return e.type==="object"||e.type==="OBJECT"?{type:"json_schema",json_schema:{name:e.name||"",description:e.description||"",schema:this.convertSchemaToJsonSchema(e),strict:!0}}:{type:"json_schema",json_schema:{name:"response_schema",description:"Generated response schema",schema:this.convertSchemaToJsonSchema(e),strict:!0}}}convertSchemaToJsonSchema(e){if(!e)return{};let r={};if(e.type)switch(e.type){case"STRING":r.type="string";break;case"INTEGER":r.type="integer";break;case"NUMBER":r.type="number";break;case"BOOLEAN":r.type="boolean";break;case"OBJECT":r.type="object";break;case"ARRAY":r.type="array";break;default:r.type=typeof e.type=="string"?e.type.toLowerCase():e.type}if(e.description&&(r.description=e.description),e.enum&&(r.enum=e.enum),e.properties){r.properties={};for(let[n,i]of Object.entries(e.properties))r.properties[n]=this.convertSchemaToJsonSchema(i)}return e.items&&(r.items=this.convertSchemaToJsonSchema(e.items)),e.required&&(r.required=e.required),r.type==="object"&&!("additionalProperties"in r)&&(r.additionalProperties=!1),r}}});function $Fn(t){return t.replace(/([a-z])([A-Z])/g,"$1_$2").toUpperCase()}function d8(t){let e=$Fn(t),r=`IFLOW_${t}`;if(process.env[r])return process.env[r];let n=`IFLOW_${e}`;if(process.env[n])return process.env[n];let i=`iflow_${t}`;if(process.env[i])return process.env[i];let o=`iflow_${e}`;if(process.env[o])return process.env[o]}function pee(){return d8("apiKey")}function hee(){return d8("baseUrl")||d8("url")}function mee(){return d8("modelName")||d8("model")}function WFt(t){let e=d8(t);if(e===void 0)return;let r=e.toLowerCase();if(r==="true"||r==="1"||r==="yes")return!0;if(r==="false"||r==="0"||r==="no")return!1}function YFt(t){let e=d8(t);if(e===void 0)return;let r=Number(e);return isNaN(r)?void 0:r}function zFt(t){let e=d8(t);if(e!==void 0)return e.split(",").map(r=>r.trim()).filter(r=>r.length>0)}function sme(){return!!(pee()||hee()||mee())}function zQe(){let t={},e=["theme","selectedAuthType","sandbox","toolDiscoveryCommand","toolCallCommand","mcpServerCommand","contextFileName","preferredEditor","apiKey","baseUrl","modelName","searchApiKey","multimodalModelName","memoryImportFormat"],r=["useExternalAuth","showMemoryUsage","usageStatisticsEnabled","autoConfigureMaxOldSpaceSize","hideWindowTitle","hideTips","hideBanner","vimMode","ideModeFeature","ideMode","disableAutoUpdate"],n=["maxSessionTurns","memoryDiscoveryMaxDirs"],i=["coreTools","excludeTools","allowMCPServers","excludeMCPServers"];return e.forEach(o=>{let s=d8(o);s!==void 0&&(t[o]=s)}),r.forEach(o=>{let s=WFt(o);s!==void 0&&(t[o]=s)}),n.forEach(o=>{let s=YFt(o);s!==void 0&&(t[o]=s)}),i.forEach(o=>{let s=zFt(o);s!==void 0&&(t[o]=s)}),t}function WFn(){return{apiKey:pee(),baseUrl:hee(),model:mee()}}var JQe=Re(()=>{"use strict";});function KQe(t,e,r){let n=process.env.GEMINI_API_KEY,i=process.env.GOOGLE_API_KEY,o=process.env.GOOGLE_CLOUD_PROJECT,s=process.env.GOOGLE_CLOUD_LOCATION,a=pee(),c=hee(),u=mee(),f=r?.apiKey||a,d=r?.baseUrl||c||YFn[e],p=t.getModel()||u||um,h={model:p,authType:e,proxy:t?.getProxy(),multimodalModelName:r?.multimodalModelName,debugMode:t?.getDebugMode()};return e===Jr.LOGIN_WITH_GOOGLE||e===Jr.CLOUD_SHELL?h:e===Jr.USE_GEMINI&&n?(h.apiKey=n,h.vertexai=!1,PFt(h.apiKey,h.model,h.proxy),h):e===Jr.USE_VERTEX_AI&&(i||o&&s)?(h.apiKey=i,h.vertexai=!0,h):([...Kh,Jr.OPENAI_COMPATIBLE].includes(e)&&f&&(h.apiKey=f,h.baseUrl=d,h.model=p),h)}async function XQe(t,e,r){let i={headers:{"User-Agent":`iFlowCLI/0.2.13 (${process.platform}; ${process.arch})`}};if(t.authType&&[...Kh,Jr.IDEA_LAB].includes(t.authType)||t.authType===Jr.OPENAI_COMPATIBLE)return new ome(t);if(t.authType===Jr.LOGIN_WITH_GOOGLE||t.authType===Jr.CLOUD_SHELL)return GLe(i,t.authType,e,r);if([...Kh,Jr.OPENAI_COMPATIBLE].includes(t.authType)||t.authType===Jr.USE_GEMINI||t.authType===Jr.USE_VERTEX_AI)return new Qhe({apiKey:t.apiKey===""?void 0:t.apiKey,vertexai:t.vertexai,httpOptions:i}).models;throw new Error(`Error creating contentGenerator: Unsupported authType: ${t.authType}`)}var Jr,Kh,YFn,C7=Re(()=>{"use strict";ic();jLe();y5();FFt();$Ft();JQe();(function(t){t.LOGIN_WITH_GOOGLE="oauth-personal",t.USE_GEMINI="gemini-api-key",t.USE_VERTEX_AI="vertex-ai",t.CLOUD_SHELL="cloud-shell",t.IFLOW="iflow",t.IDEA_LAB="idealab",t.OPENAI_COMPATIBLE="openai-compatible"})(Jr||(Jr={}));Kh=[Jr.IFLOW,Jr.IDEA_LAB],YFn={[Jr.IDEA_LAB]:"https://idealab.alibaba-inc.com/api/openai/v1",[Jr.IFLOW]:yRt}});var ame,JFt=Re(()=>{"use strict";ame=class{prompts=new Map;registerPrompt(e){if(this.prompts.has(e.name)){let r=`${e.serverName}_${e.name}`;console.warn(`Prompt with name "${e.name}" is already registered. Renaming to "${r}".`),this.prompts.set(r,{...e,name:r})}else this.prompts.set(e.name,e)}getAllPrompts(){return Array.from(this.prompts.values()).sort((e,r)=>e.name.localeCompare(r.name))}getPrompt(e){return this.prompts.get(e)}getPromptsByServer(e){let r=[];for(let n of this.prompts.values())n.serverName===e&&r.push(n);return r.sort((n,i)=>n.name.localeCompare(i.name))}clear(){this.prompts.clear()}removePromptsByServer(e){for(let[r,n]of this.prompts.entries())n.serverName===e&&this.prompts.delete(r)}}});var ss,ni,as,zf=Re(()=>{"use strict";ss=class{name;displayName;description;icon;parameterSchema;isOutputMarkdown;canUpdateOutput;aliases;constructor(e,r,n,i,o,s=!0,a=!1,c=[]){this.name=e,this.displayName=r,this.description=n,this.icon=i,this.parameterSchema=o,this.isOutputMarkdown=s,this.canUpdateOutput=a,this.aliases=c}get schema(){return{name:this.name,description:this.description,parameters:this.parameterSchema}}validateToolParams(e){return null}getDescription(e){return JSON.stringify(e)}shouldConfirmExecute(e,r){return Promise.resolve(!1)}toolLocations(e){return[]}};(function(t){t.ProceedOnce="proceed_once",t.ProceedAlways="proceed_always",t.ProceedAlwaysServer="proceed_always_server",t.ProceedAlwaysTool="proceed_always_tool",t.ModifyWithEditor="modify_with_editor",t.Cancel="cancel"})(ni||(ni={}));(function(t){t.FileSearch="fileSearch",t.Folder="folder",t.Globe="globe",t.Hammer="hammer",t.LightBulb="lightBulb",t.Pencil="pencil",t.Regex="regex",t.Terminal="terminal"})(as||(as={}))});function GN(t,e){let r=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof i=="object"&&i!==null){if(r.has(i))return"[Circular]";r.add(i)}return i},e)}var lme=Re(()=>{"use strict";});var Uc,cme=Re(()=>{"use strict";(function(t){t.INVALID_TOOL_PARAMS="invalid_tool_params",t.UNKNOWN="unknown",t.UNHANDLED_EXCEPTION="unhandled_exception",t.TOOL_NOT_REGISTERED="tool_not_registered",t.EXECUTION_FAILED="execution_failed",t.FILE_NOT_FOUND="file_not_found",t.FILE_WRITE_FAILURE="file_write_failure",t.READ_CONTENT_FAILURE="read_content_failure",t.ATTEMPT_TO_CREATE_EXISTING_FILE="attempt_to_create_existing_file",t.FILE_TOO_LARGE="file_too_large",t.PERMISSION_DENIED="permission_denied",t.NO_SPACE_LEFT="no_space_left",t.TARGET_IS_DIRECTORY="target_is_directory",t.PATH_NOT_IN_WORKSPACE="path_not_in_workspace",t.SEARCH_PATH_NOT_FOUND="search_path_not_found",t.SEARCH_PATH_NOT_A_DIRECTORY="search_path_not_a_directory",t.EDIT_PREPARATION_FAILURE="edit_preparation_failure",t.EDIT_NO_OCCURRENCE_FOUND="edit_no_occurrence_found",t.EDIT_EXPECTED_OCCURRENCE_MISMATCH="edit_expected_occurrence_mismatch",t.EDIT_NO_CHANGE="edit_no_change",t.GLOB_EXECUTION_ERROR="glob_execution_error",t.GREP_EXECUTION_ERROR="grep_execution_error",t.LS_EXECUTION_ERROR="ls_execution_error",t.PATH_IS_NOT_A_DIRECTORY="path_is_not_a_directory",t.MCP_TOOL_ERROR="mcp_tool_error",t.MEMORY_TOOL_EXECUTION_ERROR="memory_tool_execution_error",t.READ_MANY_FILES_SEARCH_ERROR="read_many_files_search_error",t.DISCOVERED_TOOL_EXECUTION_ERROR="discovered_tool_execution_error",t.WEB_FETCH_NO_URL_IN_PROMPT="web_fetch_no_url_in_prompt",t.WEB_FETCH_FALLBACK_FAILED="web_fetch_fallback_failed",t.WEB_FETCH_PROCESSING_ERROR="web_fetch_processing_error",t.WEB_SEARCH_FAILED="web_search_failed"})(Uc||(Uc={}))});function zFn(t){return{text:t.text}}function JFn(t,e){return[{text:`[Tool '${e}' provided the following ${t.type} data with mime-type: ${t.mimeType}]`},{inlineData:{mimeType:t.mimeType,data:t.data}}]}function KFn(t,e){let r=t.resource;if(r?.text)return{text:r.text};if(r?.blob){let n=r.mimeType||"application/octet-stream";return[{text:`[Tool '${e}' provided the following embedded resource with mime-type: ${n}]`},{inlineData:{mimeType:n,data:r.blob}}]}return null}function XFn(t){return{text:`Resource Link: ${t.title||t.name} at ${t.uri}`}}function ZFn(t){let e=t?.[0]?.functionResponse,r=e?.response?.content,n=e?.name||"unknown tool";return Array.isArray(r)?r.flatMap(o=>{switch(o.type){case"text":return zFn(o);case"image":case"audio":return JFn(o,n);case"resource":return KFn(o,n);case"resource_link":return XFn(o);default:return null}}).filter(o=>o!==null):[{text:"[Error: Could not parse tool response]"}]}function eUn(t){let e=t?.[0]?.functionResponse?.response?.content;return Array.isArray(e)?e.map(n=>{switch(n.type){case"text":return n.text;case"image":return`[Image: ${n.mimeType}]`;case"audio":return`[Audio: ${n.mimeType}]`;case"resource_link":return`[Link to ${n.title||n.name}: ${n.uri}]`;case"resource":return n.resource?.text?n.resource.text:`[Embedded Resource: ${n.resource?.mimeType||"unknown type"}]`;default:return`[Unknown content type: ${n.type}]`}}).join(`
|
|
544
|
+
\u8BF7\u76F4\u63A5\u8F93\u51FA\u4E00\u4E2A\u6B63\u786E\u7684json\u683C\u5F0F\uFF1A`;try{let n=await fetch("https://apis.iflow.cn/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({model:"QWen3-4B",messages:[{role:"user",content:r}],temperature:.1,max_tokens:1e3})});if(!n.ok)throw new Error(`QWen API error: ${n.status}`);let o=(await n.json()).choices[0].message.content.trim();return o.startsWith("```json")?o=o.replace(/^```json\s*/,"").replace(/\s*```$/,""):o.startsWith("```")&&(o=o.replace(/^```\s*/,"").replace(/\s*```$/,"")),JSON.parse(o)}catch(n){throw x5(n),console.error("QWen JSON fix failed:",n),n}}extractTextFromRequest(e){let r="";if(e.contents){let n=Array.isArray(e.contents)?e.contents:[e.contents];for(let i of n)if(i&&typeof i=="object"&&"parts"in i&&i.parts){let o=Array.isArray(i.parts)?i.parts:[i.parts];for(let s of o)if(s&&typeof s=="object"&&"text"in s&&s.text)r+=s.text+" ";else if(s.functionResponse&&s.functionResponse.response)for(let[a,c]of Object.entries(s.functionResponse.response))c!=null&&(r+=String(c)+" ")}}return r+=e.config?.systemInstruction,r.trim()}extractTextFromEmbedRequest(e){if(e.contents){let r=Array.isArray(e.contents)?e.contents:[e.contents];for(let n of r)if(typeof n=="object"&&n!==null&&"parts"in n&&n.parts){let i=Array.isArray(n.parts)?n.parts:[n.parts];for(let o of i)if(typeof o=="object"&&o!==null&&"text"in o&&o.text)return o.text}else{if(typeof n=="string")return n;if(typeof n=="object"&&n!==null&&"text"in n&&n.text)return n.text}}return""}extractSystemInstruction(e){let r="";if(typeof e=="string")r=e;else if(Array.isArray(e)){for(let n of e)typeof n=="object"&&n!==null&&"text"in n&&n.text&&(r+=n.text+" ");r=r.trim()}else if(typeof e=="object"&&e!==null)if("parts"in e&&e.parts){let n=Array.isArray(e.parts)?e.parts:[e.parts];for(let i of n)typeof i=="object"&&i!==null&&"text"in i&&i.text&&(r+=i.text+" ");r=r.trim()}else"text"in e&&e.text&&(r=e.text);return r}convertToOpenAITools(e){if(!e||e.length===0)return[];let r=[];for(let n of e)if(n.functionDeclarations&&Array.isArray(n.functionDeclarations))for(let i of n.functionDeclarations)r.push({type:"function",function:{name:i.name||"",description:i.description,parameters:this.convertParameters(i.parameters||i.parametersJsonSchema)}});return r}convertParameters(e){if(!e)return;let r={STRING:"string",INTEGER:"integer",NUMBER:"number",BOOLEAN:"boolean",OBJECT:"object",ARRAY:"array"};if(typeof e=="object"&&e.type){if(typeof e.type=="string"&&(r[e.type]?e.type=r[e.type]:e.type=e.type.toLowerCase()),e.properties)for(let i in e.properties){let o=e.properties[i],s={};o.type&&(s.type=r[o.type]),o.description&&(s.description=o.description),e.properties[i]=s}return e.items&&(e.items=this.convertParameters(e.items)),e}let n=i=>{if(!i)return;let o={};if(i.type)switch(i.type){case"STRING":o.type="string";break;case"INTEGER":o.type="integer";break;case"NUMBER":o.type="number";break;case"BOOLEAN":o.type="boolean";break;case"OBJECT":o.type="object";break;case"ARRAY":o.type="array";break;default:o.type=i.type.toLowerCase()}if(o.type="object",i.description&&(o.description=i.description),i.enum&&(o.enum=i.enum),i.properties){o.properties={};for(let[s,a]of Object.entries(i.properties))o.properties[s]=n(a)}return i.items&&(o.items=n(i.items)),i.required&&(o.required=i.required),o};return n(e)}mapFinishReason(e){switch(e){case"stop":return Wf.STOP;case"length":return Wf.MAX_TOKENS;case"content_filter":return Wf.SAFETY;case"tool_calls":return Wf.MALFORMED_FUNCTION_CALL;default:return Wf.OTHER}}convertResponseSchema(e){if(e)return e.type==="object"||e.type==="OBJECT"?{type:"json_schema",json_schema:{name:e.name||"",description:e.description||"",schema:this.convertSchemaToJsonSchema(e),strict:!0}}:{type:"json_schema",json_schema:{name:"response_schema",description:"Generated response schema",schema:this.convertSchemaToJsonSchema(e),strict:!0}}}convertSchemaToJsonSchema(e){if(!e)return{};let r={};if(e.type)switch(e.type){case"STRING":r.type="string";break;case"INTEGER":r.type="integer";break;case"NUMBER":r.type="number";break;case"BOOLEAN":r.type="boolean";break;case"OBJECT":r.type="object";break;case"ARRAY":r.type="array";break;default:r.type=typeof e.type=="string"?e.type.toLowerCase():e.type}if(e.description&&(r.description=e.description),e.enum&&(r.enum=e.enum),e.properties){r.properties={};for(let[n,i]of Object.entries(e.properties))r.properties[n]=this.convertSchemaToJsonSchema(i)}return e.items&&(r.items=this.convertSchemaToJsonSchema(e.items)),e.required&&(r.required=e.required),r.type==="object"&&!("additionalProperties"in r)&&(r.additionalProperties=!1),r}}});function $Fn(t){return t.replace(/([a-z])([A-Z])/g,"$1_$2").toUpperCase()}function d8(t){let e=$Fn(t),r=`IFLOW_${t}`;if(process.env[r])return process.env[r];let n=`IFLOW_${e}`;if(process.env[n])return process.env[n];let i=`iflow_${t}`;if(process.env[i])return process.env[i];let o=`iflow_${e}`;if(process.env[o])return process.env[o]}function pee(){return d8("apiKey")}function hee(){return d8("baseUrl")||d8("url")}function mee(){return d8("modelName")||d8("model")}function WFt(t){let e=d8(t);if(e===void 0)return;let r=e.toLowerCase();if(r==="true"||r==="1"||r==="yes")return!0;if(r==="false"||r==="0"||r==="no")return!1}function YFt(t){let e=d8(t);if(e===void 0)return;let r=Number(e);return isNaN(r)?void 0:r}function zFt(t){let e=d8(t);if(e!==void 0)return e.split(",").map(r=>r.trim()).filter(r=>r.length>0)}function sme(){return!!(pee()||hee()||mee())}function zQe(){let t={},e=["theme","selectedAuthType","sandbox","toolDiscoveryCommand","toolCallCommand","mcpServerCommand","contextFileName","preferredEditor","apiKey","baseUrl","modelName","searchApiKey","multimodalModelName","memoryImportFormat"],r=["useExternalAuth","showMemoryUsage","usageStatisticsEnabled","autoConfigureMaxOldSpaceSize","hideWindowTitle","hideTips","hideBanner","vimMode","ideModeFeature","ideMode","disableAutoUpdate"],n=["maxSessionTurns","memoryDiscoveryMaxDirs"],i=["coreTools","excludeTools","allowMCPServers","excludeMCPServers"];return e.forEach(o=>{let s=d8(o);s!==void 0&&(t[o]=s)}),r.forEach(o=>{let s=WFt(o);s!==void 0&&(t[o]=s)}),n.forEach(o=>{let s=YFt(o);s!==void 0&&(t[o]=s)}),i.forEach(o=>{let s=zFt(o);s!==void 0&&(t[o]=s)}),t}function WFn(){return{apiKey:pee(),baseUrl:hee(),model:mee()}}var JQe=Re(()=>{"use strict";});function KQe(t,e,r){let n=process.env.GEMINI_API_KEY,i=process.env.GOOGLE_API_KEY,o=process.env.GOOGLE_CLOUD_PROJECT,s=process.env.GOOGLE_CLOUD_LOCATION,a=pee(),c=hee(),u=mee(),f=r?.apiKey||a,d=r?.baseUrl||c||YFn[e],p=t.getModel()||u||um,h={model:p,authType:e,proxy:t?.getProxy(),multimodalModelName:r?.multimodalModelName,debugMode:t?.getDebugMode()};return e===Jr.LOGIN_WITH_GOOGLE||e===Jr.CLOUD_SHELL?h:e===Jr.USE_GEMINI&&n?(h.apiKey=n,h.vertexai=!1,PFt(h.apiKey,h.model,h.proxy),h):e===Jr.USE_VERTEX_AI&&(i||o&&s)?(h.apiKey=i,h.vertexai=!0,h):([...Kh,Jr.OPENAI_COMPATIBLE].includes(e)&&f&&(h.apiKey=f,h.baseUrl=d,h.model=p),h)}async function XQe(t,e,r){let i={headers:{"User-Agent":`iFlowCLI/0.2.14 (${process.platform}; ${process.arch})`}};if(t.authType&&[...Kh,Jr.IDEA_LAB].includes(t.authType)||t.authType===Jr.OPENAI_COMPATIBLE)return new ome(t);if(t.authType===Jr.LOGIN_WITH_GOOGLE||t.authType===Jr.CLOUD_SHELL)return GLe(i,t.authType,e,r);if([...Kh,Jr.OPENAI_COMPATIBLE].includes(t.authType)||t.authType===Jr.USE_GEMINI||t.authType===Jr.USE_VERTEX_AI)return new Qhe({apiKey:t.apiKey===""?void 0:t.apiKey,vertexai:t.vertexai,httpOptions:i}).models;throw new Error(`Error creating contentGenerator: Unsupported authType: ${t.authType}`)}var Jr,Kh,YFn,C7=Re(()=>{"use strict";ic();jLe();y5();FFt();$Ft();JQe();(function(t){t.LOGIN_WITH_GOOGLE="oauth-personal",t.USE_GEMINI="gemini-api-key",t.USE_VERTEX_AI="vertex-ai",t.CLOUD_SHELL="cloud-shell",t.IFLOW="iflow",t.IDEA_LAB="idealab",t.OPENAI_COMPATIBLE="openai-compatible"})(Jr||(Jr={}));Kh=[Jr.IFLOW,Jr.IDEA_LAB],YFn={[Jr.IDEA_LAB]:"https://idealab.alibaba-inc.com/api/openai/v1",[Jr.IFLOW]:yRt}});var ame,JFt=Re(()=>{"use strict";ame=class{prompts=new Map;registerPrompt(e){if(this.prompts.has(e.name)){let r=`${e.serverName}_${e.name}`;console.warn(`Prompt with name "${e.name}" is already registered. Renaming to "${r}".`),this.prompts.set(r,{...e,name:r})}else this.prompts.set(e.name,e)}getAllPrompts(){return Array.from(this.prompts.values()).sort((e,r)=>e.name.localeCompare(r.name))}getPrompt(e){return this.prompts.get(e)}getPromptsByServer(e){let r=[];for(let n of this.prompts.values())n.serverName===e&&r.push(n);return r.sort((n,i)=>n.name.localeCompare(i.name))}clear(){this.prompts.clear()}removePromptsByServer(e){for(let[r,n]of this.prompts.entries())n.serverName===e&&this.prompts.delete(r)}}});var ss,ni,as,zf=Re(()=>{"use strict";ss=class{name;displayName;description;icon;parameterSchema;isOutputMarkdown;canUpdateOutput;aliases;constructor(e,r,n,i,o,s=!0,a=!1,c=[]){this.name=e,this.displayName=r,this.description=n,this.icon=i,this.parameterSchema=o,this.isOutputMarkdown=s,this.canUpdateOutput=a,this.aliases=c}get schema(){return{name:this.name,description:this.description,parameters:this.parameterSchema}}validateToolParams(e){return null}getDescription(e){return JSON.stringify(e)}shouldConfirmExecute(e,r){return Promise.resolve(!1)}toolLocations(e){return[]}};(function(t){t.ProceedOnce="proceed_once",t.ProceedAlways="proceed_always",t.ProceedAlwaysServer="proceed_always_server",t.ProceedAlwaysTool="proceed_always_tool",t.ModifyWithEditor="modify_with_editor",t.Cancel="cancel"})(ni||(ni={}));(function(t){t.FileSearch="fileSearch",t.Folder="folder",t.Globe="globe",t.Hammer="hammer",t.LightBulb="lightBulb",t.Pencil="pencil",t.Regex="regex",t.Terminal="terminal"})(as||(as={}))});function GN(t,e){let r=new WeakSet;return JSON.stringify(t,(n,i)=>{if(typeof i=="object"&&i!==null){if(r.has(i))return"[Circular]";r.add(i)}return i},e)}var lme=Re(()=>{"use strict";});var Uc,cme=Re(()=>{"use strict";(function(t){t.INVALID_TOOL_PARAMS="invalid_tool_params",t.UNKNOWN="unknown",t.UNHANDLED_EXCEPTION="unhandled_exception",t.TOOL_NOT_REGISTERED="tool_not_registered",t.EXECUTION_FAILED="execution_failed",t.FILE_NOT_FOUND="file_not_found",t.FILE_WRITE_FAILURE="file_write_failure",t.READ_CONTENT_FAILURE="read_content_failure",t.ATTEMPT_TO_CREATE_EXISTING_FILE="attempt_to_create_existing_file",t.FILE_TOO_LARGE="file_too_large",t.PERMISSION_DENIED="permission_denied",t.NO_SPACE_LEFT="no_space_left",t.TARGET_IS_DIRECTORY="target_is_directory",t.PATH_NOT_IN_WORKSPACE="path_not_in_workspace",t.SEARCH_PATH_NOT_FOUND="search_path_not_found",t.SEARCH_PATH_NOT_A_DIRECTORY="search_path_not_a_directory",t.EDIT_PREPARATION_FAILURE="edit_preparation_failure",t.EDIT_NO_OCCURRENCE_FOUND="edit_no_occurrence_found",t.EDIT_EXPECTED_OCCURRENCE_MISMATCH="edit_expected_occurrence_mismatch",t.EDIT_NO_CHANGE="edit_no_change",t.GLOB_EXECUTION_ERROR="glob_execution_error",t.GREP_EXECUTION_ERROR="grep_execution_error",t.LS_EXECUTION_ERROR="ls_execution_error",t.PATH_IS_NOT_A_DIRECTORY="path_is_not_a_directory",t.MCP_TOOL_ERROR="mcp_tool_error",t.MEMORY_TOOL_EXECUTION_ERROR="memory_tool_execution_error",t.READ_MANY_FILES_SEARCH_ERROR="read_many_files_search_error",t.DISCOVERED_TOOL_EXECUTION_ERROR="discovered_tool_execution_error",t.WEB_FETCH_NO_URL_IN_PROMPT="web_fetch_no_url_in_prompt",t.WEB_FETCH_FALLBACK_FAILED="web_fetch_fallback_failed",t.WEB_FETCH_PROCESSING_ERROR="web_fetch_processing_error",t.WEB_SEARCH_FAILED="web_search_failed"})(Uc||(Uc={}))});function zFn(t){return{text:t.text}}function JFn(t,e){return[{text:`[Tool '${e}' provided the following ${t.type} data with mime-type: ${t.mimeType}]`},{inlineData:{mimeType:t.mimeType,data:t.data}}]}function KFn(t,e){let r=t.resource;if(r?.text)return{text:r.text};if(r?.blob){let n=r.mimeType||"application/octet-stream";return[{text:`[Tool '${e}' provided the following embedded resource with mime-type: ${n}]`},{inlineData:{mimeType:n,data:r.blob}}]}return null}function XFn(t){return{text:`Resource Link: ${t.title||t.name} at ${t.uri}`}}function ZFn(t){let e=t?.[0]?.functionResponse,r=e?.response?.content,n=e?.name||"unknown tool";return Array.isArray(r)?r.flatMap(o=>{switch(o.type){case"text":return zFn(o);case"image":case"audio":return JFn(o,n);case"resource":return KFn(o,n);case"resource_link":return XFn(o);default:return null}}).filter(o=>o!==null):[{text:"[Error: Could not parse tool response]"}]}function eUn(t){let e=t?.[0]?.functionResponse?.response?.content;return Array.isArray(e)?e.map(n=>{switch(n.type){case"text":return n.text;case"image":return`[Image: ${n.mimeType}]`;case"audio":return`[Audio: ${n.mimeType}]`;case"resource_link":return`[Link to ${n.title||n.name}: ${n.uri}]`;case"resource":return n.resource?.text?n.resource.text:`[Embedded Resource: ${n.resource?.mimeType||"unknown type"}]`;default:return`[Unknown content type: ${n.type}]`}}).join(`
|
|
545
545
|
`):"```json\n"+JSON.stringify(t,null,2)+"\n```"}function KFt(t){let e=t.replace(/[^a-zA-Z0-9_.-]/g,"_");return e.length>63&&(e=e.slice(0,28)+"___"+e.slice(-32)),e}var f2,gee=Re(()=>{"use strict";lme();cme();zf();ic();f2=class t extends ss{mcpTool;serverName;serverToolName;parameterSchemaJson;timeout;trust;static allowlist=new Set;constructor(e,r,n,i,o,s,a,c){super(c??KFt(n),`${n} (${r} MCP Server)`,i,as.Hammer,{type:ar.OBJECT},!0,!1),this.mcpTool=e,this.serverName=r,this.serverToolName=n,this.parameterSchemaJson=o,this.timeout=s,this.trust=a}asFullyQualifiedTool(){return new t(this.mcpTool,this.serverName,this.serverToolName,this.description,this.parameterSchemaJson,this.timeout,this.trust,`${this.serverName}__${this.serverToolName}`)}get schema(){return{name:this.name,description:this.description,parametersJsonSchema:this.parameterSchemaJson}}async shouldConfirmExecute(e,r){let n=this.serverName,i=`${this.serverName}.${this.serverToolName}`;return this.trust||t.allowlist.has(n)||t.allowlist.has(i)?!1:{type:"mcp",title:"Confirm MCP Tool Execution",serverName:this.serverName,toolName:this.serverToolName,toolDisplayName:this.name,onConfirm:async s=>{s===ni.ProceedAlwaysServer?t.allowlist.add(n):s===ni.ProceedAlwaysTool&&t.allowlist.add(i)}}}isMCPToolError(e){let n=e?.[0]?.functionResponse?.response;if(n){let i=n?.error,o=i?.isError;if(i&&(o===!0||o==="true"))return!0}return!1}async execute(e){let{callId:r,...n}=e,i=[{name:this.serverToolName,args:n}],o=await this.mcpTool.callTool(i);if(this.isMCPToolError(o)){let a=`MCP tool '${this.serverToolName}' reported tool error for function call: ${GN(i[0])} with response: ${GN(o)}`;return{llmContent:a,returnDisplay:`Error: MCP tool '${this.serverToolName}' reported an error.`,error:{message:a,type:Uc.MCP_TOOL_ERROR}}}return{llmContent:ZFn(o),returnDisplay:eUn(o)}}}});var ZFt=B((LOo,XFt)=>{"use strict";XFt.exports=function(e){return e.map(function(r){return r===""?"''":r&&typeof r=="object"?r.op.replace(/(.)/g,"\\$1"):/["\s\\]/.test(r)&&!/'/.test(r)?"'"+r.replace(/(['])/g,"\\$1")+"'":/["'\s]/.test(r)?'"'+r.replace(/(["\\$`!])/g,"\\$1")+'"':String(r).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}])/g,"$1\\$2")}).join(" ")}});var sUt=B((POo,oUt)=>{"use strict";var iUt="(?:"+["\\|\\|","\\&\\&",";;","\\|\\&","\\<\\(","\\<\\<\\<",">>",">\\&","<\\&","[&;()|<>]"].join("|")+")",eUt=new RegExp("^"+iUt+"$"),tUt="|&;()<> \\t",tUn='"((\\\\"|[^"])*?)"',rUn="'((\\\\'|[^'])*?)'",nUn=/^#$/,rUt="'",nUt='"',ZQe="$",jN="",iUn=4294967296;for(eqe=0;eqe<4;eqe++)jN+=(iUn*Math.random()).toString(16);var eqe,oUn=new RegExp("^"+jN);function sUn(t,e){for(var r=e.lastIndex,n=[],i;i=e.exec(t);)n.push(i),e.lastIndex===i.index&&(e.lastIndex+=1);return e.lastIndex=r,n}function aUn(t,e,r){var n=typeof t=="function"?t(r):t[r];return typeof n>"u"&&r!=""?n="":typeof n>"u"&&(n="$"),typeof n=="object"?e+jN+JSON.stringify(n)+jN:e+n}function lUn(t,e,r){r||(r={});var n=r.escape||"\\",i="(\\"+n+`['"`+tUt+`]|[^\\s'"`+tUt+"])+",o=new RegExp(["("+iUt+")","("+i+"|"+tUn+"|"+rUn+")+"].join("|"),"g"),s=sUn(t,o);if(s.length===0)return[];e||(e={});var a=!1;return s.map(function(c){var u=c[0];if(!u||a)return;if(eUt.test(u))return{op:u};var f=!1,d=!1,p="",h=!1,g;function A(){g+=1;var S,w,T=u.charAt(g);if(T==="{"){if(g+=1,u.charAt(g)==="}")throw new Error("Bad substitution: "+u.slice(g-2,g+1));if(S=u.indexOf("}",g),S<0)throw new Error("Bad substitution: "+u.slice(g));w=u.slice(g,S),g=S}else if(/[*@#?$!_-]/.test(T))w=T,g+=1;else{var N=u.slice(g);S=N.match(/[^\w\d_]/),S?(w=N.slice(0,S.index),g+=S.index-1):(w=N,g=u.length)}return aUn(e,"",w)}for(g=0;g<u.length;g++){var y=u.charAt(g);if(h=h||!f&&(y==="*"||y==="?"),d)p+=y,d=!1;else if(f)y===f?f=!1:f==rUt?p+=y:y===n?(g+=1,y=u.charAt(g),y===nUt||y===n||y===ZQe?p+=y:p+=n+y):y===ZQe?p+=A():p+=y;else if(y===nUt||y===rUt)f=y;else{if(eUt.test(y))return{op:u};if(nUn.test(y)){a=!0;var v={comment:t.slice(c.index+g+1)};return p.length?[p,v]:[v]}else y===n?d=!0:y===ZQe?p+=A():p+=y}}return h?{op:"glob",pattern:p}:p}).reduce(function(c,u){return typeof u>"u"?c:c.concat(u)},[])}oUt.exports=function(e,r,n){var i=lUn(e,r,n);return typeof r!="function"?i:i.reduce(function(o,s){if(typeof s=="object")return o.concat(s);var a=s.split(RegExp("("+jN+".*?"+jN+")","g"));return a.length===1?o.concat(a[0]):o.concat(a.filter(Boolean).map(function(c){return oUn.test(c)?JSON.parse(c.split(jN)[1]):c}))},[])}});var ume=B(tqe=>{"use strict";tqe.quote=ZFt();tqe.parse=sUt()});var Ys,rqe,An,p8,Aee=Re(()=>{(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{let o={};for(let s of i)o[s]=s;return o},t.getValidEnumValues=i=>{let o=t.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),s={};for(let a of o)s[a]=i[a];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(o){return i[o]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let o=[];for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&o.push(s);return o},t.find=(i,o)=>{for(let s of i)if(o(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,o=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(o)}t.joinValues=n,t.jsonStringifyReplacer=(i,o)=>typeof o=="bigint"?o.toString():o})(Ys||(Ys={}));(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(rqe||(rqe={}));An=Ys.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),p8=t=>{switch(typeof t){case"undefined":return An.undefined;case"string":return An.string;case"number":return Number.isNaN(t)?An.nan:An.number;case"boolean":return An.boolean;case"function":return An.function;case"bigint":return An.bigint;case"symbol":return An.symbol;case"object":return Array.isArray(t)?An.array:t===null?An.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?An.promise:typeof Map<"u"&&t instanceof Map?An.map:typeof Set<"u"&&t instanceof Set?An.set:typeof Date<"u"&&t instanceof Date?An.date:An.object;default:return An.unknown}}});var kr,cUn,eA,fme=Re(()=>{Aee();kr=Ys.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),cUn=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),eA=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(o){return o.message},n={_errors:[]},i=o=>{for(let s of o.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let a=n,c=0;for(;c<s.path.length;){let u=s.path[c];c===s.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(s))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return i(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ys.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let i of this.issues)if(i.path.length>0){let o=i.path[0];r[o]=r[o]||[],r[o].push(e(i))}else n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};eA.create=t=>new eA(t)});var uUn,P7,nqe=Re(()=>{fme();Aee();uUn=(t,e)=>{let r;switch(t.code){case kr.invalid_type:t.received===An.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case kr.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,Ys.jsonStringifyReplacer)}`;break;case kr.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ys.joinValues(t.keys,", ")}`;break;case kr.invalid_union:r="Invalid input";break;case kr.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ys.joinValues(t.options)}`;break;case kr.invalid_enum_value:r=`Invalid enum value. Expected ${Ys.joinValues(t.options)}, received '${t.received}'`;break;case kr.invalid_arguments:r="Invalid function arguments";break;case kr.invalid_return_type:r="Invalid function return type";break;case kr.invalid_date:r="Invalid date";break;case kr.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:Ys.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case kr.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case kr.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case kr.custom:r="Invalid input";break;case kr.invalid_intersection_types:r="Intersection results could not be merged";break;case kr.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case kr.not_finite:r="Number must be finite";break;default:r=e.defaultError,Ys.assertNever(t)}return{message:r}},P7=uUn});function fUn(t){aUt=t}function wH(){return aUt}var aUt,dme=Re(()=>{nqe();aUt=P7});function ln(t,e){let r=wH(),n=yee({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===P7?void 0:P7].filter(i=>!!i)});t.common.issues.push(n)}var yee,dUn,d2,Hi,VN,mm,pme,hme,kx,xH,iqe=Re(()=>{dme();nqe();yee=t=>{let{data:e,path:r,errorMaps:n,issueData:i}=t,o=[...r,...i.path||[]],s={...i,path:o};if(i.message!==void 0)return{...i,path:o,message:i.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(s,{data:e,defaultError:a}).message;return{...i,path:o,message:a}},dUn=[];d2=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let i of r){if(i.status==="aborted")return Hi;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let i of r){let o=await i.key,s=await i.value;n.push({key:o,value:s})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let i of r){let{key:o,value:s}=i;if(o.status==="aborted"||s.status==="aborted")return Hi;o.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),o.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[o.value]=s.value)}return{status:e.value,value:n}}},Hi=Object.freeze({status:"aborted"}),VN=t=>({status:"dirty",value:t}),mm=t=>({status:"valid",value:t}),pme=t=>t.status==="aborted",hme=t=>t.status==="dirty",kx=t=>t.status==="valid",xH=t=>typeof Promise<"u"&&t instanceof Promise});var lUt=Re(()=>{});var zn,cUt=Re(()=>{(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(zn||(zn={}))});function Zo(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,a)=>{let{message:c}=t;return s.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:s.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:i}}function pUt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function IUn(t){return new RegExp(`^${pUt(t)}$`)}function hUt(t){let e=`${dUt}T${pUt(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function RUn(t,e){return!!((e==="v4"||!e)&&CUn.test(t)||(e==="v6"||!e)&&SUn.test(t))}function BUn(t,e){if(!yUn.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function NUn(t,e){return!!((e==="v4"||!e)&&_Un.test(t)||(e==="v6"||!e)&&wUn.test(t))}function OUn(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,o=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return o%s/10**i}function TH(t){if(t instanceof tA){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=J6.create(TH(n))}return new tA({...t._def,shape:()=>e})}else return t instanceof Q7?new Q7({...t._def,type:TH(t.element)}):t instanceof J6?J6.create(TH(t.unwrap())):t instanceof m8?m8.create(TH(t.unwrap())):t instanceof h8?h8.create(t.items.map(e=>TH(e))):t}function sqe(t,e){let r=p8(t),n=p8(e);if(t===e)return{valid:!0,data:t};if(r===An.object&&n===An.object){let i=Ys.objectKeys(e),o=Ys.objectKeys(t).filter(a=>i.indexOf(a)!==-1),s={...t,...e};for(let a of o){let c=sqe(t[a],e[a]);if(!c.valid)return{valid:!1};s[a]=c.data}return{valid:!0,data:s}}else if(r===An.array&&n===An.array){if(t.length!==e.length)return{valid:!1};let i=[];for(let o=0;o<t.length;o++){let s=t[o],a=e[o],c=sqe(s,a);if(!c.valid)return{valid:!1};i.push(c.data)}return{valid:!0,data:i}}else return r===An.date&&n===An.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}function mUt(t,e){return new rO({values:t,typeName:eo.ZodEnum,...Zo(e)})}function fUt(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function gUt(t,e={},r){return t?Px.create().superRefine((n,i)=>{let o=t(n);if(o instanceof Promise)return o.then(s=>{if(!s){let a=fUt(e,n),c=a.fatal??r??!0;i.addIssue({code:"custom",...a,fatal:c})}});if(!o){let s=fUt(e,n),a=s.fatal??r??!0;i.addIssue({code:"custom",...s,fatal:a})}}):Px.create()}var K6,uUt,gs,pUn,hUn,mUn,gUn,AUn,yUn,EUn,vUn,bUn,oqe,CUn,_Un,SUn,wUn,xUn,TUn,dUt,DUn,Lx,$N,WN,YN,zN,DH,JN,KN,Px,U7,T5,IH,Q7,tA,XN,F7,mme,ZN,h8,gme,RH,BH,Ame,eO,tO,rO,nO,Fx,X6,J6,m8,iO,oO,NH,MUn,Eee,vee,sO,kUn,eo,LUn,AUt,yUt,PUn,FUn,EUt,UUn,QUn,qUn,HUn,GUn,jUn,VUn,$Un,WUn,YUn,zUn,JUn,KUn,XUn,ZUn,eQn,tQn,rQn,nQn,iQn,oQn,sQn,aQn,lQn,cQn,uQn,fQn,dQn,pQn,hQn,mQn,gQn,AQn,yQn,vUt=Re(()=>{fme();dme();cUt();iqe();Aee();K6=class{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},uUt=(t,e)=>{if(kx(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new eA(t.common.issues);return this._error=r,this._error}}};gs=class{get description(){return this._def.description}_getType(e){return p8(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:p8(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new d2,ctx:{common:e.parent.common,data:e.data,parsedType:p8(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(xH(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p8(e)},i=this._parseSync({data:e,path:n.path,parent:n});return uUt(n,i)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p8(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return kx(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(n=>kx(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p8(e)},i=this._parse({data:e,path:n.path,parent:n}),o=await(xH(i)?i:Promise.resolve(i));return uUt(n,o)}refine(e,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,o)=>{let s=e(i),a=()=>o.addIssue({code:kr.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(c=>c?!0:(a(),!1)):s?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new X6({schema:this,typeName:eo.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return J6.create(this,this._def)}nullable(){return m8.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Q7.create(this)}promise(){return Fx.create(this,this._def)}or(e){return XN.create([this,e],this._def)}and(e){return ZN.create(this,e,this._def)}transform(e){return new X6({...Zo(this._def),schema:this,typeName:eo.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new iO({...Zo(this._def),innerType:this,defaultValue:r,typeName:eo.ZodDefault})}brand(){return new Eee({typeName:eo.ZodBranded,type:this,...Zo(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new oO({...Zo(this._def),innerType:this,catchValue:r,typeName:eo.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return vee.create(this,e)}readonly(){return sO.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},pUn=/^c[^\s-]{8,}$/i,hUn=/^[0-9a-z]+$/,mUn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,gUn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,AUn=/^[a-z0-9_-]{21}$/i,yUn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,EUn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,vUn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bUn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",CUn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,_Un=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,SUn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,wUn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,xUn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,TUn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dUt="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",DUn=new RegExp(`^${dUt}$`);Lx=class t extends gs{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==An.string){let o=this._getOrReturnCtx(e);return ln(o,{code:kr.invalid_type,expected:An.string,received:o.parsedType}),Hi}let n=new d2,i;for(let o of this._def.checks)if(o.kind==="min")e.data.length<o.value&&(i=this._getOrReturnCtx(e,i),ln(i,{code:kr.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="max")e.data.length>o.value&&(i=this._getOrReturnCtx(e,i),ln(i,{code:kr.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),n.dirty());else if(o.kind==="length"){let s=e.data.length>o.value,a=e.data.length<o.value;(s||a)&&(i=this._getOrReturnCtx(e,i),s?ln(i,{code:kr.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):a&&ln(i,{code:kr.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),n.dirty())}else if(o.kind==="email")vUn.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"email",code:kr.invalid_string,message:o.message}),n.dirty());else if(o.kind==="emoji")oqe||(oqe=new RegExp(bUn,"u")),oqe.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"emoji",code:kr.invalid_string,message:o.message}),n.dirty());else if(o.kind==="uuid")gUn.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"uuid",code:kr.invalid_string,message:o.message}),n.dirty());else if(o.kind==="nanoid")AUn.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"nanoid",code:kr.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid")pUn.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"cuid",code:kr.invalid_string,message:o.message}),n.dirty());else if(o.kind==="cuid2")hUn.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"cuid2",code:kr.invalid_string,message:o.message}),n.dirty());else if(o.kind==="ulid")mUn.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"ulid",code:kr.invalid_string,message:o.message}),n.dirty());else if(o.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),ln(i,{validation:"url",code:kr.invalid_string,message:o.message}),n.dirty()}else o.kind==="regex"?(o.regex.lastIndex=0,o.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"regex",code:kr.invalid_string,message:o.message}),n.dirty())):o.kind==="trim"?e.data=e.data.trim():o.kind==="includes"?e.data.includes(o.value,o.position)||(i=this._getOrReturnCtx(e,i),ln(i,{code:kr.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),n.dirty()):o.kind==="toLowerCase"?e.data=e.data.toLowerCase():o.kind==="toUpperCase"?e.data=e.data.toUpperCase():o.kind==="startsWith"?e.data.startsWith(o.value)||(i=this._getOrReturnCtx(e,i),ln(i,{code:kr.invalid_string,validation:{startsWith:o.value},message:o.message}),n.dirty()):o.kind==="endsWith"?e.data.endsWith(o.value)||(i=this._getOrReturnCtx(e,i),ln(i,{code:kr.invalid_string,validation:{endsWith:o.value},message:o.message}),n.dirty()):o.kind==="datetime"?hUt(o).test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{code:kr.invalid_string,validation:"datetime",message:o.message}),n.dirty()):o.kind==="date"?DUn.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{code:kr.invalid_string,validation:"date",message:o.message}),n.dirty()):o.kind==="time"?IUn(o).test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{code:kr.invalid_string,validation:"time",message:o.message}),n.dirty()):o.kind==="duration"?EUn.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"duration",code:kr.invalid_string,message:o.message}),n.dirty()):o.kind==="ip"?RUn(e.data,o.version)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"ip",code:kr.invalid_string,message:o.message}),n.dirty()):o.kind==="jwt"?BUn(e.data,o.alg)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"jwt",code:kr.invalid_string,message:o.message}),n.dirty()):o.kind==="cidr"?NUn(e.data,o.version)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"cidr",code:kr.invalid_string,message:o.message}),n.dirty()):o.kind==="base64"?xUn.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"base64",code:kr.invalid_string,message:o.message}),n.dirty()):o.kind==="base64url"?TUn.test(e.data)||(i=this._getOrReturnCtx(e,i),ln(i,{validation:"base64url",code:kr.invalid_string,message:o.message}),n.dirty()):Ys.assertNever(o);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:kr.invalid_string,...zn.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...zn.errToObj(e)})}url(e){return this._addCheck({kind:"url",...zn.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...zn.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...zn.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...zn.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...zn.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...zn.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...zn.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...zn.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...zn.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...zn.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...zn.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...zn.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...zn.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...zn.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...zn.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...zn.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...zn.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...zn.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...zn.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...zn.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...zn.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...zn.errToObj(r)})}nonempty(e){return this.min(1,zn.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};Lx.create=t=>new Lx({checks:[],typeName:eo.ZodString,coerce:t?.coerce??!1,...Zo(t)});$N=class t extends gs{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==An.number){let o=this._getOrReturnCtx(e);return ln(o,{code:kr.invalid_type,expected:An.number,received:o.parsedType}),Hi}let n,i=new d2;for(let o of this._def.checks)o.kind==="int"?Ys.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),ln(n,{code:kr.invalid_type,expected:"integer",received:"float",message:o.message}),i.dirty()):o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),ln(n,{code:kr.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),ln(n,{code:kr.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),i.dirty()):o.kind==="multipleOf"?OUn(e.data,o.value)!==0&&(n=this._getOrReturnCtx(e,n),ln(n,{code:kr.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):o.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),ln(n,{code:kr.not_finite,message:o.message}),i.dirty()):Ys.assertNever(o);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,zn.toString(r))}gt(e,r){return this.setLimit("min",e,!1,zn.toString(r))}lte(e,r){return this.setLimit("max",e,!0,zn.toString(r))}lt(e,r){return this.setLimit("max",e,!1,zn.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:zn.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:zn.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:zn.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:zn.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:zn.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:zn.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:zn.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:zn.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:zn.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:zn.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Ys.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}};$N.create=t=>new $N({checks:[],typeName:eo.ZodNumber,coerce:t?.coerce||!1,...Zo(t)});WN=class t extends gs{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==An.bigint)return this._getInvalidInput(e);let n,i=new d2;for(let o of this._def.checks)o.kind==="min"?(o.inclusive?e.data<o.value:e.data<=o.value)&&(n=this._getOrReturnCtx(e,n),ln(n,{code:kr.too_small,type:"bigint",minimum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="max"?(o.inclusive?e.data>o.value:e.data>=o.value)&&(n=this._getOrReturnCtx(e,n),ln(n,{code:kr.too_big,type:"bigint",maximum:o.value,inclusive:o.inclusive,message:o.message}),i.dirty()):o.kind==="multipleOf"?e.data%o.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),ln(n,{code:kr.not_multiple_of,multipleOf:o.value,message:o.message}),i.dirty()):Ys.assertNever(o);return{status:i.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return ln(r,{code:kr.invalid_type,expected:An.bigint,received:r.parsedType}),Hi}gte(e,r){return this.setLimit("min",e,!0,zn.toString(r))}gt(e,r){return this.setLimit("min",e,!1,zn.toString(r))}lte(e,r){return this.setLimit("max",e,!0,zn.toString(r))}lt(e,r){return this.setLimit("max",e,!1,zn.toString(r))}setLimit(e,r,n,i){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:zn.toString(i)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:zn.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:zn.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:zn.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:zn.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:zn.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};WN.create=t=>new WN({checks:[],typeName:eo.ZodBigInt,coerce:t?.coerce??!1,...Zo(t)});YN=class extends gs{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==An.boolean){let n=this._getOrReturnCtx(e);return ln(n,{code:kr.invalid_type,expected:An.boolean,received:n.parsedType}),Hi}return mm(e.data)}};YN.create=t=>new YN({typeName:eo.ZodBoolean,coerce:t?.coerce||!1,...Zo(t)});zN=class t extends gs{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==An.date){let o=this._getOrReturnCtx(e);return ln(o,{code:kr.invalid_type,expected:An.date,received:o.parsedType}),Hi}if(Number.isNaN(e.data.getTime())){let o=this._getOrReturnCtx(e);return ln(o,{code:kr.invalid_date}),Hi}let n=new d2,i;for(let o of this._def.checks)o.kind==="min"?e.data.getTime()<o.value&&(i=this._getOrReturnCtx(e,i),ln(i,{code:kr.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):o.kind==="max"?e.data.getTime()>o.value&&(i=this._getOrReturnCtx(e,i),ln(i,{code:kr.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):Ys.assertNever(o);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:zn.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:zn.toString(r)})}get minDate(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};zN.create=t=>new zN({checks:[],coerce:t?.coerce||!1,typeName:eo.ZodDate,...Zo(t)});DH=class extends gs{_parse(e){if(this._getType(e)!==An.symbol){let n=this._getOrReturnCtx(e);return ln(n,{code:kr.invalid_type,expected:An.symbol,received:n.parsedType}),Hi}return mm(e.data)}};DH.create=t=>new DH({typeName:eo.ZodSymbol,...Zo(t)});JN=class extends gs{_parse(e){if(this._getType(e)!==An.undefined){let n=this._getOrReturnCtx(e);return ln(n,{code:kr.invalid_type,expected:An.undefined,received:n.parsedType}),Hi}return mm(e.data)}};JN.create=t=>new JN({typeName:eo.ZodUndefined,...Zo(t)});KN=class extends gs{_parse(e){if(this._getType(e)!==An.null){let n=this._getOrReturnCtx(e);return ln(n,{code:kr.invalid_type,expected:An.null,received:n.parsedType}),Hi}return mm(e.data)}};KN.create=t=>new KN({typeName:eo.ZodNull,...Zo(t)});Px=class extends gs{constructor(){super(...arguments),this._any=!0}_parse(e){return mm(e.data)}};Px.create=t=>new Px({typeName:eo.ZodAny,...Zo(t)});U7=class extends gs{constructor(){super(...arguments),this._unknown=!0}_parse(e){return mm(e.data)}};U7.create=t=>new U7({typeName:eo.ZodUnknown,...Zo(t)});T5=class extends gs{_parse(e){let r=this._getOrReturnCtx(e);return ln(r,{code:kr.invalid_type,expected:An.never,received:r.parsedType}),Hi}};T5.create=t=>new T5({typeName:eo.ZodNever,...Zo(t)});IH=class extends gs{_parse(e){if(this._getType(e)!==An.undefined){let n=this._getOrReturnCtx(e);return ln(n,{code:kr.invalid_type,expected:An.void,received:n.parsedType}),Hi}return mm(e.data)}};IH.create=t=>new IH({typeName:eo.ZodVoid,...Zo(t)});Q7=class t extends gs{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==An.array)return ln(r,{code:kr.invalid_type,expected:An.array,received:r.parsedType}),Hi;if(i.exactLength!==null){let s=r.data.length>i.exactLength.value,a=r.data.length<i.exactLength.value;(s||a)&&(ln(r,{code:s?kr.too_big:kr.too_small,minimum:a?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(ln(r,{code:kr.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(ln(r,{code:kr.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,a)=>i.type._parseAsync(new K6(r,s,r.path,a)))).then(s=>d2.mergeArray(n,s));let o=[...r.data].map((s,a)=>i.type._parseSync(new K6(r,s,r.path,a)));return d2.mergeArray(n,o)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:zn.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:zn.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:zn.toString(r)}})}nonempty(e){return this.min(1,e)}};Q7.create=(t,e)=>new Q7({type:t,minLength:null,maxLength:null,exactLength:null,typeName:eo.ZodArray,...Zo(e)});tA=class t extends gs{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=Ys.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==An.object){let u=this._getOrReturnCtx(e);return ln(u,{code:kr.invalid_type,expected:An.object,received:u.parsedType}),Hi}let{status:n,ctx:i}=this._processInputParams(e),{shape:o,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof T5&&this._def.unknownKeys==="strip"))for(let u in i.data)s.includes(u)||a.push(u);let c=[];for(let u of s){let f=o[u],d=i.data[u];c.push({key:{status:"valid",value:u},value:f._parse(new K6(i,d,i.path,u)),alwaysSet:u in i.data})}if(this._def.catchall instanceof T5){let u=this._def.unknownKeys;if(u==="passthrough")for(let f of a)c.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(u==="strict")a.length>0&&(ln(i,{code:kr.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let f of a){let d=i.data[f];c.push({key:{status:"valid",value:f},value:u._parse(new K6(i,d,i.path,f)),alwaysSet:f in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let u=[];for(let f of c){let d=await f.key,p=await f.value;u.push({key:d,value:p,alwaysSet:f.alwaysSet})}return u}).then(u=>d2.mergeObjectSync(n,u)):d2.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return zn.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:zn.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:eo.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of Ys.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of Ys.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return TH(this)}partial(e){let r={};for(let n of Ys.objectKeys(this.shape)){let i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of Ys.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let o=this.shape[n];for(;o instanceof J6;)o=o._def.innerType;r[n]=o}return new t({...this._def,shape:()=>r})}keyof(){return mUt(Ys.objectKeys(this.shape))}};tA.create=(t,e)=>new tA({shape:()=>t,unknownKeys:"strip",catchall:T5.create(),typeName:eo.ZodObject,...Zo(e)});tA.strictCreate=(t,e)=>new tA({shape:()=>t,unknownKeys:"strict",catchall:T5.create(),typeName:eo.ZodObject,...Zo(e)});tA.lazycreate=(t,e)=>new tA({shape:t,unknownKeys:"strip",catchall:T5.create(),typeName:eo.ZodObject,...Zo(e)});XN=class extends gs{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function i(o){for(let a of o)if(a.result.status==="valid")return a.result;for(let a of o)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(a=>new eA(a.ctx.common.issues));return ln(r,{code:kr.invalid_union,unionErrors:s}),Hi}if(r.common.async)return Promise.all(n.map(async o=>{let s={...r,common:{...r.common,issues:[]},parent:null};return{result:await o._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let o,s=[];for(let c of n){let u={...r,common:{...r.common,issues:[]},parent:null},f=c._parseSync({data:r.data,path:r.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!o&&(o={result:f,ctx:u}),u.common.issues.length&&s.push(u.common.issues)}if(o)return r.common.issues.push(...o.ctx.common.issues),o.result;let a=s.map(c=>new eA(c));return ln(r,{code:kr.invalid_union,unionErrors:a}),Hi}}get options(){return this._def.options}};XN.create=(t,e)=>new XN({options:t,typeName:eo.ZodUnion,...Zo(e)});F7=t=>t instanceof eO?F7(t.schema):t instanceof X6?F7(t.innerType()):t instanceof tO?[t.value]:t instanceof rO?t.options:t instanceof nO?Ys.objectValues(t.enum):t instanceof iO?F7(t._def.innerType):t instanceof JN?[void 0]:t instanceof KN?[null]:t instanceof J6?[void 0,...F7(t.unwrap())]:t instanceof m8?[null,...F7(t.unwrap())]:t instanceof Eee||t instanceof sO?F7(t.unwrap()):t instanceof oO?F7(t._def.innerType):[],mme=class t extends gs{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==An.object)return ln(r,{code:kr.invalid_type,expected:An.object,received:r.parsedType}),Hi;let n=this.discriminator,i=r.data[n],o=this.optionsMap.get(i);return o?r.common.async?o._parseAsync({data:r.data,path:r.path,parent:r}):o._parseSync({data:r.data,path:r.path,parent:r}):(ln(r,{code:kr.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Hi)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let i=new Map;for(let o of r){let s=F7(o.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of s){if(i.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);i.set(a,o)}}return new t({typeName:eo.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...Zo(n)})}};ZN=class extends gs{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=(o,s)=>{if(pme(o)||pme(s))return Hi;let a=sqe(o.value,s.value);return a.valid?((hme(o)||hme(s))&&r.dirty(),{status:r.value,value:a.data}):(ln(n,{code:kr.invalid_intersection_types}),Hi)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([o,s])=>i(o,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ZN.create=(t,e,r)=>new ZN({left:t,right:e,typeName:eo.ZodIntersection,...Zo(r)});h8=class t extends gs{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==An.array)return ln(n,{code:kr.invalid_type,expected:An.array,received:n.parsedType}),Hi;if(n.data.length<this._def.items.length)return ln(n,{code:kr.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Hi;!this._def.rest&&n.data.length>this._def.items.length&&(ln(n,{code:kr.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let o=[...n.data].map((s,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new K6(n,s,n.path,a)):null}).filter(s=>!!s);return n.common.async?Promise.all(o).then(s=>d2.mergeArray(r,s)):d2.mergeArray(r,o)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};h8.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new h8({items:t,typeName:eo.ZodTuple,rest:null,...Zo(e)})};gme=class t extends gs{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==An.object)return ln(n,{code:kr.invalid_type,expected:An.object,received:n.parsedType}),Hi;let i=[],o=this._def.keyType,s=this._def.valueType;for(let a in n.data)i.push({key:o._parse(new K6(n,a,n.path,a)),value:s._parse(new K6(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?d2.mergeObjectAsync(r,i):d2.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof gs?new t({keyType:e,valueType:r,typeName:eo.ZodRecord,...Zo(n)}):new t({keyType:Lx.create(),valueType:e,typeName:eo.ZodRecord,...Zo(r)})}},RH=class extends gs{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==An.map)return ln(n,{code:kr.invalid_type,expected:An.map,received:n.parsedType}),Hi;let i=this._def.keyType,o=this._def.valueType,s=[...n.data.entries()].map(([a,c],u)=>({key:i._parse(new K6(n,a,n.path,[u,"key"])),value:o._parse(new K6(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of s){let u=await c.key,f=await c.value;if(u.status==="aborted"||f.status==="aborted")return Hi;(u.status==="dirty"||f.status==="dirty")&&r.dirty(),a.set(u.value,f.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of s){let u=c.key,f=c.value;if(u.status==="aborted"||f.status==="aborted")return Hi;(u.status==="dirty"||f.status==="dirty")&&r.dirty(),a.set(u.value,f.value)}return{status:r.value,value:a}}}};RH.create=(t,e,r)=>new RH({valueType:e,keyType:t,typeName:eo.ZodMap,...Zo(r)});BH=class t extends gs{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==An.set)return ln(n,{code:kr.invalid_type,expected:An.set,received:n.parsedType}),Hi;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(ln(n,{code:kr.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(ln(n,{code:kr.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let o=this._def.valueType;function s(c){let u=new Set;for(let f of c){if(f.status==="aborted")return Hi;f.status==="dirty"&&r.dirty(),u.add(f.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>o._parse(new K6(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>s(c)):s(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:zn.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:zn.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};BH.create=(t,e)=>new BH({valueType:t,minSize:null,maxSize:null,typeName:eo.ZodSet,...Zo(e)});Ame=class t extends gs{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==An.function)return ln(r,{code:kr.invalid_type,expected:An.function,received:r.parsedType}),Hi;function n(a,c){return yee({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,wH(),P7].filter(u=>!!u),issueData:{code:kr.invalid_arguments,argumentsError:c}})}function i(a,c){return yee({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,wH(),P7].filter(u=>!!u),issueData:{code:kr.invalid_return_type,returnTypeError:c}})}let o={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Fx){let a=this;return mm(async function(...c){let u=new eA([]),f=await a._def.args.parseAsync(c,o).catch(h=>{throw u.addIssue(n(c,h)),u}),d=await Reflect.apply(s,this,f);return await a._def.returns._def.type.parseAsync(d,o).catch(h=>{throw u.addIssue(i(d,h)),u})})}else{let a=this;return mm(function(...c){let u=a._def.args.safeParse(c,o);if(!u.success)throw new eA([n(c,u.error)]);let f=Reflect.apply(s,this,u.data),d=a._def.returns.safeParse(f,o);if(!d.success)throw new eA([i(f,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:h8.create(e).rest(U7.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||h8.create([]).rest(U7.create()),returns:r||U7.create(),typeName:eo.ZodFunction,...Zo(n)})}},eO=class extends gs{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};eO.create=(t,e)=>new eO({getter:t,typeName:eo.ZodLazy,...Zo(e)});tO=class extends gs{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return ln(r,{received:r.data,code:kr.invalid_literal,expected:this._def.value}),Hi}return{status:"valid",value:e.data}}get value(){return this._def.value}};tO.create=(t,e)=>new tO({value:t,typeName:eo.ZodLiteral,...Zo(e)});rO=class t extends gs{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return ln(r,{expected:Ys.joinValues(n),received:r.parsedType,code:kr.invalid_type}),Hi}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return ln(r,{received:r.data,code:kr.invalid_enum_value,options:n}),Hi}return mm(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};rO.create=mUt;nO=class extends gs{_parse(e){let r=Ys.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==An.string&&n.parsedType!==An.number){let i=Ys.objectValues(r);return ln(n,{expected:Ys.joinValues(i),received:n.parsedType,code:kr.invalid_type}),Hi}if(this._cache||(this._cache=new Set(Ys.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let i=Ys.objectValues(r);return ln(n,{received:n.data,code:kr.invalid_enum_value,options:i}),Hi}return mm(e.data)}get enum(){return this._def.values}};nO.create=(t,e)=>new nO({values:t,typeName:eo.ZodNativeEnum,...Zo(e)});Fx=class extends gs{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==An.promise&&r.common.async===!1)return ln(r,{code:kr.invalid_type,expected:An.promise,received:r.parsedType}),Hi;let n=r.parsedType===An.promise?r.data:Promise.resolve(r.data);return mm(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Fx.create=(t,e)=>new Fx({type:t,typeName:eo.ZodPromise,...Zo(e)});X6=class extends gs{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===eo.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,o={addIssue:s=>{ln(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(o.addIssue=o.addIssue.bind(o),i.type==="preprocess"){let s=i.transform(n.data,o);if(n.common.async)return Promise.resolve(s).then(async a=>{if(r.value==="aborted")return Hi;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?Hi:c.status==="dirty"?VN(c.value):r.value==="dirty"?VN(c.value):c});{if(r.value==="aborted")return Hi;let a=this._def.schema._parseSync({data:s,path:n.path,parent:n});return a.status==="aborted"?Hi:a.status==="dirty"?VN(a.value):r.value==="dirty"?VN(a.value):a}}if(i.type==="refinement"){let s=a=>{let c=i.refinement(a,o);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Hi:(a.status==="dirty"&&r.dirty(),s(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?Hi:(a.status==="dirty"&&r.dirty(),s(a.value).then(()=>({status:r.value,value:a.value}))))}if(i.type==="transform")if(n.common.async===!1){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!kx(s))return Hi;let a=i.transform(s.value,o);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>kx(s)?Promise.resolve(i.transform(s.value,o)).then(a=>({status:r.value,value:a})):Hi);Ys.assertNever(i)}};X6.create=(t,e,r)=>new X6({schema:t,typeName:eo.ZodEffects,effect:e,...Zo(r)});X6.createWithPreprocess=(t,e,r)=>new X6({schema:e,effect:{type:"preprocess",transform:t},typeName:eo.ZodEffects,...Zo(r)});J6=class extends gs{_parse(e){return this._getType(e)===An.undefined?mm(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};J6.create=(t,e)=>new J6({innerType:t,typeName:eo.ZodOptional,...Zo(e)});m8=class extends gs{_parse(e){return this._getType(e)===An.null?mm(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};m8.create=(t,e)=>new m8({innerType:t,typeName:eo.ZodNullable,...Zo(e)});iO=class extends gs{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===An.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};iO.create=(t,e)=>new iO({innerType:t,typeName:eo.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...Zo(e)});oO=class extends gs{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return xH(i)?i.then(o=>({status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new eA(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new eA(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};oO.create=(t,e)=>new oO({innerType:t,typeName:eo.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...Zo(e)});NH=class extends gs{_parse(e){if(this._getType(e)!==An.nan){let n=this._getOrReturnCtx(e);return ln(n,{code:kr.invalid_type,expected:An.nan,received:n.parsedType}),Hi}return{status:"valid",value:e.data}}};NH.create=t=>new NH({typeName:eo.ZodNaN,...Zo(t)});MUn=Symbol("zod_brand"),Eee=class extends gs{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},vee=class t extends gs{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let o=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Hi:o.status==="dirty"?(r.dirty(),VN(o.value)):this._def.out._parseAsync({data:o.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Hi:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:eo.ZodPipeline})}},sO=class extends gs{_parse(e){let r=this._def.innerType._parse(e),n=i=>(kx(i)&&(i.value=Object.freeze(i.value)),i);return xH(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};sO.create=(t,e)=>new sO({innerType:t,typeName:eo.ZodReadonly,...Zo(e)});kUn={object:tA.lazycreate};(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(eo||(eo={}));LUn=(t,e={message:`Input not instance of ${t.name}`})=>gUt(r=>r instanceof t,e),AUt=Lx.create,yUt=$N.create,PUn=NH.create,FUn=WN.create,EUt=YN.create,UUn=zN.create,QUn=DH.create,qUn=JN.create,HUn=KN.create,GUn=Px.create,jUn=U7.create,VUn=T5.create,$Un=IH.create,WUn=Q7.create,YUn=tA.create,zUn=tA.strictCreate,JUn=XN.create,KUn=mme.create,XUn=ZN.create,ZUn=h8.create,eQn=gme.create,tQn=RH.create,rQn=BH.create,nQn=Ame.create,iQn=eO.create,oQn=tO.create,sQn=rO.create,aQn=nO.create,lQn=Fx.create,cQn=X6.create,uQn=J6.create,fQn=m8.create,dQn=X6.createWithPreprocess,pQn=vee.create,hQn=()=>AUt().optional(),mQn=()=>yUt().optional(),gQn=()=>EUt().optional(),AQn={string:(t=>Lx.create({...t,coerce:!0})),number:(t=>$N.create({...t,coerce:!0})),boolean:(t=>YN.create({...t,coerce:!0})),bigint:(t=>WN.create({...t,coerce:!0})),date:(t=>zN.create({...t,coerce:!0}))},yQn=Hi});var Me={};o2(Me,{BRAND:()=>MUn,DIRTY:()=>VN,EMPTY_PATH:()=>dUn,INVALID:()=>Hi,NEVER:()=>yQn,OK:()=>mm,ParseStatus:()=>d2,Schema:()=>gs,ZodAny:()=>Px,ZodArray:()=>Q7,ZodBigInt:()=>WN,ZodBoolean:()=>YN,ZodBranded:()=>Eee,ZodCatch:()=>oO,ZodDate:()=>zN,ZodDefault:()=>iO,ZodDiscriminatedUnion:()=>mme,ZodEffects:()=>X6,ZodEnum:()=>rO,ZodError:()=>eA,ZodFirstPartyTypeKind:()=>eo,ZodFunction:()=>Ame,ZodIntersection:()=>ZN,ZodIssueCode:()=>kr,ZodLazy:()=>eO,ZodLiteral:()=>tO,ZodMap:()=>RH,ZodNaN:()=>NH,ZodNativeEnum:()=>nO,ZodNever:()=>T5,ZodNull:()=>KN,ZodNullable:()=>m8,ZodNumber:()=>$N,ZodObject:()=>tA,ZodOptional:()=>J6,ZodParsedType:()=>An,ZodPipeline:()=>vee,ZodPromise:()=>Fx,ZodReadonly:()=>sO,ZodRecord:()=>gme,ZodSchema:()=>gs,ZodSet:()=>BH,ZodString:()=>Lx,ZodSymbol:()=>DH,ZodTransformer:()=>X6,ZodTuple:()=>h8,ZodType:()=>gs,ZodUndefined:()=>JN,ZodUnion:()=>XN,ZodUnknown:()=>U7,ZodVoid:()=>IH,addIssueToContext:()=>ln,any:()=>GUn,array:()=>WUn,bigint:()=>FUn,boolean:()=>EUt,coerce:()=>AQn,custom:()=>gUt,date:()=>UUn,datetimeRegex:()=>hUt,defaultErrorMap:()=>P7,discriminatedUnion:()=>KUn,effect:()=>cQn,enum:()=>sQn,function:()=>nQn,getErrorMap:()=>wH,getParsedType:()=>p8,instanceof:()=>LUn,intersection:()=>XUn,isAborted:()=>pme,isAsync:()=>xH,isDirty:()=>hme,isValid:()=>kx,late:()=>kUn,lazy:()=>iQn,literal:()=>oQn,makeIssue:()=>yee,map:()=>tQn,nan:()=>PUn,nativeEnum:()=>aQn,never:()=>VUn,null:()=>HUn,nullable:()=>fQn,number:()=>yUt,object:()=>YUn,objectUtil:()=>rqe,oboolean:()=>gQn,onumber:()=>mQn,optional:()=>uQn,ostring:()=>hQn,pipeline:()=>pQn,preprocess:()=>dQn,promise:()=>lQn,quotelessJson:()=>cUn,record:()=>eQn,set:()=>rQn,setErrorMap:()=>fUn,strictObject:()=>zUn,string:()=>AUt,symbol:()=>QUn,transformer:()=>cQn,tuple:()=>ZUn,undefined:()=>qUn,union:()=>JUn,unknown:()=>jUn,util:()=>Ys,void:()=>$Un});var aqe=Re(()=>{dme();iqe();lUt();Aee();vUt();fme()});var bee=Re(()=>{aqe();aqe()});var OH,bUt,yme,CUt,_Ut,EQn,t4,rA,Cee,g8,r4,Eme,SUt,vme,wUt,xUt,TUt,_ee,Z6,DUt,IUt,Ux,aO,bme,See,RUt,vQn,bQn,CQn,lqe,BUt,NUt,Cme,_Qn,_me,Sme,wme,OUt,MUt,cqe,kUt,LUt,SQn,wQn,uqe,xQn,fqe,TQn,dqe,DQn,IQn,RQn,BQn,NQn,OQn,MQn,wee,kQn,pqe,hqe,mqe,LQn,PQn,PUt,FQn,xee,UQn,QQn,qQn,HQn,gqe,xme,dMo,GQn,jQn,FUt,VQn,$Qn,WQn,YQn,zQn,JQn,KQn,XQn,ZQn,eqn,tqn,rqn,nqn,iqn,oqn,sqn,aqn,Aqe,lqn,Tme,cqn,uqn,pMo,hMo,mMo,gMo,AMo,yMo,e4,Qx=Re(()=>{bee();OH="2025-06-18",bUt=[OH,"2025-03-26","2024-11-05","2024-10-07"],yme="2.0",CUt=Me.union([Me.string(),Me.number().int()]),_Ut=Me.string(),EQn=Me.object({progressToken:Me.optional(CUt)}).passthrough(),t4=Me.object({_meta:Me.optional(EQn)}).passthrough(),rA=Me.object({method:Me.string(),params:Me.optional(t4)}),Cee=Me.object({_meta:Me.optional(Me.object({}).passthrough())}).passthrough(),g8=Me.object({method:Me.string(),params:Me.optional(Cee)}),r4=Me.object({_meta:Me.optional(Me.object({}).passthrough())}).passthrough(),Eme=Me.union([Me.string(),Me.number().int()]),SUt=Me.object({jsonrpc:Me.literal(yme),id:Eme}).merge(rA).strict(),vme=t=>SUt.safeParse(t).success,wUt=Me.object({jsonrpc:Me.literal(yme)}).merge(g8).strict(),xUt=t=>wUt.safeParse(t).success,TUt=Me.object({jsonrpc:Me.literal(yme),id:Eme,result:r4}).strict(),_ee=t=>TUt.safeParse(t).success;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError"})(Z6||(Z6={}));DUt=Me.object({jsonrpc:Me.literal(yme),id:Eme,error:Me.object({code:Me.number().int(),message:Me.string(),data:Me.optional(Me.unknown())})}).strict(),IUt=t=>DUt.safeParse(t).success,Ux=Me.union([SUt,wUt,TUt,DUt]),aO=r4.strict(),bme=g8.extend({method:Me.literal("notifications/cancelled"),params:Cee.extend({requestId:Eme,reason:Me.string().optional()})}),See=Me.object({name:Me.string(),title:Me.optional(Me.string())}).passthrough(),RUt=See.extend({version:Me.string()}),vQn=Me.object({experimental:Me.optional(Me.object({}).passthrough()),sampling:Me.optional(Me.object({}).passthrough()),elicitation:Me.optional(Me.object({}).passthrough()),roots:Me.optional(Me.object({listChanged:Me.optional(Me.boolean())}).passthrough())}).passthrough(),bQn=rA.extend({method:Me.literal("initialize"),params:t4.extend({protocolVersion:Me.string(),capabilities:vQn,clientInfo:RUt})}),CQn=Me.object({experimental:Me.optional(Me.object({}).passthrough()),logging:Me.optional(Me.object({}).passthrough()),completions:Me.optional(Me.object({}).passthrough()),prompts:Me.optional(Me.object({listChanged:Me.optional(Me.boolean())}).passthrough()),resources:Me.optional(Me.object({subscribe:Me.optional(Me.boolean()),listChanged:Me.optional(Me.boolean())}).passthrough()),tools:Me.optional(Me.object({listChanged:Me.optional(Me.boolean())}).passthrough())}).passthrough(),lqe=r4.extend({protocolVersion:Me.string(),capabilities:CQn,serverInfo:RUt,instructions:Me.optional(Me.string())}),BUt=g8.extend({method:Me.literal("notifications/initialized")}),NUt=t=>BUt.safeParse(t).success,Cme=rA.extend({method:Me.literal("ping")}),_Qn=Me.object({progress:Me.number(),total:Me.optional(Me.number()),message:Me.optional(Me.string())}).passthrough(),_me=g8.extend({method:Me.literal("notifications/progress"),params:Cee.merge(_Qn).extend({progressToken:CUt})}),Sme=rA.extend({params:t4.extend({cursor:Me.optional(_Ut)}).optional()}),wme=r4.extend({nextCursor:Me.optional(_Ut)}),OUt=Me.object({uri:Me.string(),mimeType:Me.optional(Me.string()),_meta:Me.optional(Me.object({}).passthrough())}).passthrough(),MUt=OUt.extend({text:Me.string()}),cqe=Me.string().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),kUt=OUt.extend({blob:cqe}),LUt=See.extend({uri:Me.string(),description:Me.optional(Me.string()),mimeType:Me.optional(Me.string()),_meta:Me.optional(Me.object({}).passthrough())}),SQn=See.extend({uriTemplate:Me.string(),description:Me.optional(Me.string()),mimeType:Me.optional(Me.string()),_meta:Me.optional(Me.object({}).passthrough())}),wQn=Sme.extend({method:Me.literal("resources/list")}),uqe=wme.extend({resources:Me.array(LUt)}),xQn=Sme.extend({method:Me.literal("resources/templates/list")}),fqe=wme.extend({resourceTemplates:Me.array(SQn)}),TQn=rA.extend({method:Me.literal("resources/read"),params:t4.extend({uri:Me.string()})}),dqe=r4.extend({contents:Me.array(Me.union([MUt,kUt]))}),DQn=g8.extend({method:Me.literal("notifications/resources/list_changed")}),IQn=rA.extend({method:Me.literal("resources/subscribe"),params:t4.extend({uri:Me.string()})}),RQn=rA.extend({method:Me.literal("resources/unsubscribe"),params:t4.extend({uri:Me.string()})}),BQn=g8.extend({method:Me.literal("notifications/resources/updated"),params:Cee.extend({uri:Me.string()})}),NQn=Me.object({name:Me.string(),description:Me.optional(Me.string()),required:Me.optional(Me.boolean())}).passthrough(),OQn=See.extend({description:Me.optional(Me.string()),arguments:Me.optional(Me.array(NQn)),_meta:Me.optional(Me.object({}).passthrough())}),MQn=Sme.extend({method:Me.literal("prompts/list")}),wee=wme.extend({prompts:Me.array(OQn)}),kQn=rA.extend({method:Me.literal("prompts/get"),params:t4.extend({name:Me.string(),arguments:Me.optional(Me.record(Me.string()))})}),pqe=Me.object({type:Me.literal("text"),text:Me.string(),_meta:Me.optional(Me.object({}).passthrough())}).passthrough(),hqe=Me.object({type:Me.literal("image"),data:cqe,mimeType:Me.string(),_meta:Me.optional(Me.object({}).passthrough())}).passthrough(),mqe=Me.object({type:Me.literal("audio"),data:cqe,mimeType:Me.string(),_meta:Me.optional(Me.object({}).passthrough())}).passthrough(),LQn=Me.object({type:Me.literal("resource"),resource:Me.union([MUt,kUt]),_meta:Me.optional(Me.object({}).passthrough())}).passthrough(),PQn=LUt.extend({type:Me.literal("resource_link")}),PUt=Me.union([pqe,hqe,mqe,PQn,LQn]),FQn=Me.object({role:Me.enum(["user","assistant"]),content:PUt}).passthrough(),xee=r4.extend({description:Me.optional(Me.string()),messages:Me.array(FQn)}),UQn=g8.extend({method:Me.literal("notifications/prompts/list_changed")}),QQn=Me.object({title:Me.optional(Me.string()),readOnlyHint:Me.optional(Me.boolean()),destructiveHint:Me.optional(Me.boolean()),idempotentHint:Me.optional(Me.boolean()),openWorldHint:Me.optional(Me.boolean())}).passthrough(),qQn=See.extend({description:Me.optional(Me.string()),inputSchema:Me.object({type:Me.literal("object"),properties:Me.optional(Me.object({}).passthrough()),required:Me.optional(Me.array(Me.string()))}).passthrough(),outputSchema:Me.optional(Me.object({type:Me.literal("object"),properties:Me.optional(Me.object({}).passthrough()),required:Me.optional(Me.array(Me.string()))}).passthrough()),annotations:Me.optional(QQn),_meta:Me.optional(Me.object({}).passthrough())}),HQn=Sme.extend({method:Me.literal("tools/list")}),gqe=wme.extend({tools:Me.array(qQn)}),xme=r4.extend({content:Me.array(PUt).default([]),structuredContent:Me.object({}).passthrough().optional(),isError:Me.optional(Me.boolean())}),dMo=xme.or(r4.extend({toolResult:Me.unknown()})),GQn=rA.extend({method:Me.literal("tools/call"),params:t4.extend({name:Me.string(),arguments:Me.optional(Me.record(Me.unknown()))})}),jQn=g8.extend({method:Me.literal("notifications/tools/list_changed")}),FUt=Me.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),VQn=rA.extend({method:Me.literal("logging/setLevel"),params:t4.extend({level:FUt})}),$Qn=g8.extend({method:Me.literal("notifications/message"),params:Cee.extend({level:FUt,logger:Me.optional(Me.string()),data:Me.unknown()})}),WQn=Me.object({name:Me.string().optional()}).passthrough(),YQn=Me.object({hints:Me.optional(Me.array(WQn)),costPriority:Me.optional(Me.number().min(0).max(1)),speedPriority:Me.optional(Me.number().min(0).max(1)),intelligencePriority:Me.optional(Me.number().min(0).max(1))}).passthrough(),zQn=Me.object({role:Me.enum(["user","assistant"]),content:Me.union([pqe,hqe,mqe])}).passthrough(),JQn=rA.extend({method:Me.literal("sampling/createMessage"),params:t4.extend({messages:Me.array(zQn),systemPrompt:Me.optional(Me.string()),includeContext:Me.optional(Me.enum(["none","thisServer","allServers"])),temperature:Me.optional(Me.number()),maxTokens:Me.number().int(),stopSequences:Me.optional(Me.array(Me.string())),metadata:Me.optional(Me.object({}).passthrough()),modelPreferences:Me.optional(YQn)})}),KQn=r4.extend({model:Me.string(),stopReason:Me.optional(Me.enum(["endTurn","stopSequence","maxTokens"]).or(Me.string())),role:Me.enum(["user","assistant"]),content:Me.discriminatedUnion("type",[pqe,hqe,mqe])}),XQn=Me.object({type:Me.literal("boolean"),title:Me.optional(Me.string()),description:Me.optional(Me.string()),default:Me.optional(Me.boolean())}).passthrough(),ZQn=Me.object({type:Me.literal("string"),title:Me.optional(Me.string()),description:Me.optional(Me.string()),minLength:Me.optional(Me.number()),maxLength:Me.optional(Me.number()),format:Me.optional(Me.enum(["email","uri","date","date-time"]))}).passthrough(),eqn=Me.object({type:Me.enum(["number","integer"]),title:Me.optional(Me.string()),description:Me.optional(Me.string()),minimum:Me.optional(Me.number()),maximum:Me.optional(Me.number())}).passthrough(),tqn=Me.object({type:Me.literal("string"),title:Me.optional(Me.string()),description:Me.optional(Me.string()),enum:Me.array(Me.string()),enumNames:Me.optional(Me.array(Me.string()))}).passthrough(),rqn=Me.union([XQn,ZQn,eqn,tqn]),nqn=rA.extend({method:Me.literal("elicitation/create"),params:t4.extend({message:Me.string(),requestedSchema:Me.object({type:Me.literal("object"),properties:Me.record(Me.string(),rqn),required:Me.optional(Me.array(Me.string()))}).passthrough()})}),iqn=r4.extend({action:Me.enum(["accept","decline","cancel"]),content:Me.optional(Me.record(Me.string(),Me.unknown()))}),oqn=Me.object({type:Me.literal("ref/resource"),uri:Me.string()}).passthrough(),sqn=Me.object({type:Me.literal("ref/prompt"),name:Me.string()}).passthrough(),aqn=rA.extend({method:Me.literal("completion/complete"),params:t4.extend({ref:Me.union([sqn,oqn]),argument:Me.object({name:Me.string(),value:Me.string()}).passthrough(),context:Me.optional(Me.object({arguments:Me.optional(Me.record(Me.string(),Me.string()))}))})}),Aqe=r4.extend({completion:Me.object({values:Me.array(Me.string()).max(100),total:Me.optional(Me.number().int()),hasMore:Me.optional(Me.boolean())}).passthrough()}),lqn=Me.object({uri:Me.string().startsWith("file://"),name:Me.optional(Me.string()),_meta:Me.optional(Me.object({}).passthrough())}).passthrough(),Tme=rA.extend({method:Me.literal("roots/list")}),cqn=r4.extend({roots:Me.array(lqn)}),uqn=g8.extend({method:Me.literal("notifications/roots/list_changed")}),pMo=Me.union([Cme,bQn,aqn,VQn,kQn,MQn,wQn,xQn,TQn,IQn,RQn,GQn,HQn]),hMo=Me.union([bme,_me,BUt,uqn]),mMo=Me.union([aO,KQn,iqn,cqn]),gMo=Me.union([Cme,JQn,nqn,Tme]),AMo=Me.union([bme,_me,$Qn,BQn,DQn,jQn,UQn]),yMo=Me.union([aO,lqe,Aqe,xee,wee,uqe,fqe,dqe,xme,gqe]),e4=class extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}}});function UUt(t,e){return Object.entries(e).reduce((r,[n,i])=>(i&&typeof i=="object"?r[n]=r[n]?{...r[n],...i}:i:r[n]=i,r),{...t})}var fqn,Dme,QUt=Re(()=>{Qx();fqn=6e4,Dme=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this.setNotificationHandler(bme,r=>{let n=this._requestHandlerAbortControllers.get(r.params.requestId);n?.abort(r.params.reason)}),this.setNotificationHandler(_me,r=>{this._onprogress(r)}),this.setRequestHandler(Cme,r=>({}))}_setupTimeout(e,r,n,i,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(i,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:o,onTimeout:i})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),new e4(Z6.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){var r,n,i;this._transport=e;let o=(r=this.transport)===null||r===void 0?void 0:r.onclose;this._transport.onclose=()=>{o?.(),this._onclose()};let s=(n=this.transport)===null||n===void 0?void 0:n.onerror;this._transport.onerror=c=>{s?.(c),this._onerror(c)};let a=(i=this._transport)===null||i===void 0?void 0:i.onmessage;this._transport.onmessage=(c,u)=>{a?.(c,u),_ee(c)||IUt(c)?this._onresponse(c):vme(c)?this._onrequest(c,u):xUt(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var e;let r=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._pendingDebouncedNotifications.clear(),this._transport=void 0,(e=this.onclose)===null||e===void 0||e.call(this);let n=new e4(Z6.ConnectionClosed,"Connection closed");for(let i of r.values())i(n)}_onerror(e){var r;(r=this.onerror)===null||r===void 0||r.call(this,e)}_onnotification(e){var r;let n=(r=this._notificationHandlers.get(e.method))!==null&&r!==void 0?r:this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(i=>this._onerror(new Error(`Uncaught error in notification handler: ${i}`)))}_onrequest(e,r){var n,i;let o=(n=this._requestHandlers.get(e.method))!==null&&n!==void 0?n:this.fallbackRequestHandler,s=this._transport;if(o===void 0){s?.send({jsonrpc:"2.0",id:e.id,error:{code:Z6.MethodNotFound,message:"Method not found"}}).catch(u=>this._onerror(new Error(`Failed to send an error response: ${u}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let c={signal:a.signal,sessionId:s?.sessionId,_meta:(i=e.params)===null||i===void 0?void 0:i._meta,sendNotification:u=>this.notification(u,{relatedRequestId:e.id}),sendRequest:(u,f,d)=>this.request(u,f,{...d,relatedRequestId:e.id}),authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo};Promise.resolve().then(()=>o(e,c)).then(u=>{if(!a.signal.aborted)return s?.send({result:u,jsonrpc:"2.0",id:e.id})},u=>{var f;if(!a.signal.aborted)return s?.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(u.code)?u.code:Z6.InternalError,message:(f=u.message)!==null&&f!==void 0?f:"Internal error"}})}).catch(u=>this._onerror(new Error(`Failed to send response: ${u}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,i=Number(r),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let s=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(c){s(c);return}o(n)}_onresponse(e){let r=Number(e.id),n=this._responseHandlers.get(r);if(n===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}if(this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),_ee(e))n(e);else{let i=new e4(e.error.code,e.error.message,e.error.data);n(i)}}get transport(){return this._transport}async close(){var e;await((e=this._transport)===null||e===void 0?void 0:e.close())}request(e,r,n){let{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}=n??{};return new Promise((a,c)=>{var u,f,d,p,h,g;if(!this._transport){c(new Error("Not connected"));return}((u=this._options)===null||u===void 0?void 0:u.enforceStrictCapabilities)===!0&&this.assertCapabilityForMethod(e.method),(f=n?.signal)===null||f===void 0||f.throwIfAborted();let A=this._requestMessageId++,y={...e,jsonrpc:"2.0",id:A};n?.onprogress&&(this._progressHandlers.set(A,n.onprogress),y.params={...e.params,_meta:{...((d=e.params)===null||d===void 0?void 0:d._meta)||{},progressToken:A}});let v=T=>{var N;this._responseHandlers.delete(A),this._progressHandlers.delete(A),this._cleanupTimeout(A),(N=this._transport)===null||N===void 0||N.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:A,reason:String(T)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(P=>this._onerror(new Error(`Failed to send cancellation: ${P}`))),c(T)};this._responseHandlers.set(A,T=>{var N;if(!(!((N=n?.signal)===null||N===void 0)&&N.aborted)){if(T instanceof Error)return c(T);try{let P=r.parse(T.result);a(P)}catch(P){c(P)}}}),(p=n?.signal)===null||p===void 0||p.addEventListener("abort",()=>{var T;v((T=n?.signal)===null||T===void 0?void 0:T.reason)});let S=(h=n?.timeout)!==null&&h!==void 0?h:fqn,w=()=>v(new e4(Z6.RequestTimeout,"Request timed out",{timeout:S}));this._setupTimeout(A,S,n?.maxTotalTimeout,w,(g=n?.resetTimeoutOnProgress)!==null&&g!==void 0?g:!1),this._transport.send(y,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(T=>{this._cleanupTimeout(A),c(T)})})}async notification(e,r){var n,i;if(!this._transport)throw new Error("Not connected");if(this.assertNotificationCapability(e.method),((i=(n=this._options)===null||n===void 0?void 0:n.debouncedNotificationMethods)!==null&&i!==void 0?i:[]).includes(e.method)&&!e.params&&!r?.relatedRequestId){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{var c;if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let u={...e,jsonrpc:"2.0"};(c=this._transport)===null||c===void 0||c.send(u,r).catch(f=>this._onerror(f))});return}let a={...e,jsonrpc:"2.0"};await this._transport.send(a,r)}setRequestHandler(e,r){let n=e.shape.method.value;this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(i,o)=>Promise.resolve(r(e.parse(i),o)))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){this._notificationHandlers.set(e.shape.method.value,n=>Promise.resolve(r(e.parse(n))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}}});var HUt=B((Ime,qUt)=>{(function(t,e){typeof Ime=="object"&&typeof qUt<"u"?e(Ime):typeof define=="function"&&define.amd?define(["exports"],e):e(t.URI=t.URI||{})})(Ime,(function(t){"use strict";function e(){for(var lt=arguments.length,Je=Array(lt),dt=0;dt<lt;dt++)Je[dt]=arguments[dt];if(Je.length>1){Je[0]=Je[0].slice(0,-1);for(var xt=Je.length-1,mt=1;mt<xt;++mt)Je[mt]=Je[mt].slice(1,-1);return Je[xt]=Je[xt].slice(1),Je.join("")}else return Je[0]}function r(lt){return"(?:"+lt+")"}function n(lt){return lt===void 0?"undefined":lt===null?"null":Object.prototype.toString.call(lt).split(" ").pop().split("]").shift().toLowerCase()}function i(lt){return lt.toUpperCase()}function o(lt){return lt!=null?lt instanceof Array?lt:typeof lt.length!="number"||lt.split||lt.setInterval||lt.call?[lt]:Array.prototype.slice.call(lt):[]}function s(lt,Je){var dt=lt;if(Je)for(var xt in Je)dt[xt]=Je[xt];return dt}function a(lt){var Je="[A-Za-z]",dt="[\\x0D]",xt="[0-9]",mt="[\\x22]",mr=e(xt,"[A-Fa-f]"),Rr="[\\x0A]",Yr="[\\x20]",un=r(r("%[EFef]"+mr+"%"+mr+mr+"%"+mr+mr)+"|"+r("%[89A-Fa-f]"+mr+"%"+mr+mr)+"|"+r("%"+mr+mr)),fi="[\\:\\/\\?\\#\\[\\]\\@]",dn="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",_i=e(fi,dn),Pi=lt?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]",vn=lt?"[\\uE000-\\uF8FF]":"[]",Ii=e(Je,xt,"[\\-\\.\\_\\~]",Pi),fo=r(Je+e(Je,xt,"[\\+\\-\\.]")+"*"),zi=r(r(un+"|"+e(Ii,dn,"[\\:]"))+"*"),Zl=r(r("25[0-5]")+"|"+r("2[0-4]"+xt)+"|"+r("1"+xt+xt)+"|"+r("[1-9]"+xt)+"|"+xt),Zs=r(r("25[0-5]")+"|"+r("2[0-4]"+xt)+"|"+r("1"+xt+xt)+"|"+r("0?[1-9]"+xt)+"|0?0?"+xt),ea=r(Zs+"\\."+Zs+"\\."+Zs+"\\."+Zs),vi=r(mr+"{1,4}"),ns=r(r(vi+"\\:"+vi)+"|"+ea),yo=r(r(vi+"\\:")+"{6}"+ns),Bi=r("\\:\\:"+r(vi+"\\:")+"{5}"+ns),Oc=r(r(vi)+"?\\:\\:"+r(vi+"\\:")+"{4}"+ns),Ua=r(r(r(vi+"\\:")+"{0,1}"+vi)+"?\\:\\:"+r(vi+"\\:")+"{3}"+ns),Io=r(r(r(vi+"\\:")+"{0,2}"+vi)+"?\\:\\:"+r(vi+"\\:")+"{2}"+ns),pa=r(r(r(vi+"\\:")+"{0,3}"+vi)+"?\\:\\:"+vi+"\\:"+ns),ta=r(r(r(vi+"\\:")+"{0,4}"+vi)+"?\\:\\:"+ns),Ss=r(r(r(vi+"\\:")+"{0,5}"+vi)+"?\\:\\:"+vi),ol=r(r(r(vi+"\\:")+"{0,6}"+vi)+"?\\:\\:"),je=r([yo,Bi,Oc,Ua,Io,pa,ta,Ss,ol].join("|")),$e=r(r(Ii+"|"+un)+"+"),At=r(je+"\\%25"+$e),wt=r(je+r("\\%25|\\%(?!"+mr+"{2})")+$e),Rt=r("[vV]"+mr+"+\\."+e(Ii,dn,"[\\:]")+"+"),rr=r("\\["+r(wt+"|"+je+"|"+Rt)+"\\]"),yr=r(r(un+"|"+e(Ii,dn))+"*"),fr=r(rr+"|"+ea+"(?!"+yr+")|"+yr),Sr=r(xt+"*"),xr=r(r(zi+"@")+"?"+fr+r("\\:"+Sr)+"?"),Pr=r(un+"|"+e(Ii,dn,"[\\:\\@]")),Sn=r(Pr+"*"),po=r(Pr+"+"),ws=r(r(un+"|"+e(Ii,dn,"[\\@]"))+"+"),Ni=r(r("\\/"+Sn)+"*"),sl=r("\\/"+r(po+Ni)+"?"),ec=r(ws+Ni),Lf=r(po+Ni),vl="(?!"+Pr+")",_1=r(Ni+"|"+sl+"|"+ec+"|"+Lf+"|"+vl),ip=r(r(Pr+"|"+e("[\\/\\?]",vn))+"*"),op=r(r(Pr+"|[\\/\\?]")+"*"),Qp=r(r("\\/\\/"+xr+Ni)+"|"+sl+"|"+Lf+"|"+vl),ag=r(fo+"\\:"+Qp+r("\\?"+ip)+"?"+r("\\#"+op)+"?"),mf=r(r("\\/\\/"+xr+Ni)+"|"+sl+"|"+ec+"|"+vl),$c=r(mf+r("\\?"+ip)+"?"+r("\\#"+op)+"?"),qp=r(ag+"|"+$c),Fu=r(fo+"\\:"+Qp+r("\\?"+ip)+"?"),xh="^("+fo+")\\:"+r(r("\\/\\/("+r("("+zi+")@")+"?("+fr+")"+r("\\:("+Sr+")")+"?)")+"?("+Ni+"|"+sl+"|"+Lf+"|"+vl+")")+r("\\?("+ip+")")+"?"+r("\\#("+op+")")+"?$",yd="^(){0}"+r(r("\\/\\/("+r("("+zi+")@")+"?("+fr+")"+r("\\:("+Sr+")")+"?)")+"?("+Ni+"|"+sl+"|"+ec+"|"+vl+")")+r("\\?("+ip+")")+"?"+r("\\#("+op+")")+"?$",Q0="^("+fo+")\\:"+r(r("\\/\\/("+r("("+zi+")@")+"?("+fr+")"+r("\\:("+Sr+")")+"?)")+"?("+Ni+"|"+sl+"|"+Lf+"|"+vl+")")+r("\\?("+ip+")")+"?$",cu="^"+r("\\#("+op+")")+"?$",e3="^"+r("("+zi+")@")+"?("+fr+")"+r("\\:("+Sr+")")+"?$";return{NOT_SCHEME:new RegExp(e("[^]",Je,xt,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(e("[^\\%\\:]",Ii,dn),"g"),NOT_HOST:new RegExp(e("[^\\%\\[\\]\\:]",Ii,dn),"g"),NOT_PATH:new RegExp(e("[^\\%\\/\\:\\@]",Ii,dn),"g"),NOT_PATH_NOSCHEME:new RegExp(e("[^\\%\\/\\@]",Ii,dn),"g"),NOT_QUERY:new RegExp(e("[^\\%]",Ii,dn,"[\\:\\@\\/\\?]",vn),"g"),NOT_FRAGMENT:new RegExp(e("[^\\%]",Ii,dn,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(e("[^]",Ii,dn),"g"),UNRESERVED:new RegExp(Ii,"g"),OTHER_CHARS:new RegExp(e("[^\\%]",Ii,_i),"g"),PCT_ENCODED:new RegExp(un,"g"),IPV4ADDRESS:new RegExp("^("+ea+")$"),IPV6ADDRESS:new RegExp("^\\[?("+je+")"+r(r("\\%25|\\%(?!"+mr+"{2})")+"("+$e+")")+"?\\]?$")}}var c=a(!1),u=a(!0),f=(function(){function lt(Je,dt){var xt=[],mt=!0,mr=!1,Rr=void 0;try{for(var Yr=Je[Symbol.iterator](),un;!(mt=(un=Yr.next()).done)&&(xt.push(un.value),!(dt&&xt.length===dt));mt=!0);}catch(fi){mr=!0,Rr=fi}finally{try{!mt&&Yr.return&&Yr.return()}finally{if(mr)throw Rr}}return xt}return function(Je,dt){if(Array.isArray(Je))return Je;if(Symbol.iterator in Object(Je))return lt(Je,dt);throw new TypeError("Invalid attempt to destructure non-iterable instance")}})(),d=function(lt){if(Array.isArray(lt)){for(var Je=0,dt=Array(lt.length);Je<lt.length;Je++)dt[Je]=lt[Je];return dt}else return Array.from(lt)},p=2147483647,h=36,g=1,A=26,y=38,v=700,S=72,w=128,T="-",N=/^xn--/,P=/[^\0-\x7E]/,U=/[\x2E\u3002\uFF0E\uFF61]/g,Q={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},D=h-g,F=Math.floor,O=String.fromCharCode;function q(lt){throw new RangeError(Q[lt])}function L(lt,Je){for(var dt=[],xt=lt.length;xt--;)dt[xt]=Je(lt[xt]);return dt}function M(lt,Je){var dt=lt.split("@"),xt="";dt.length>1&&(xt=dt[0]+"@",lt=dt[1]),lt=lt.replace(U,".");var mt=lt.split("."),mr=L(mt,Je).join(".");return xt+mr}function j(lt){for(var Je=[],dt=0,xt=lt.length;dt<xt;){var mt=lt.charCodeAt(dt++);if(mt>=55296&&mt<=56319&&dt<xt){var mr=lt.charCodeAt(dt++);(mr&64512)==56320?Je.push(((mt&1023)<<10)+(mr&1023)+65536):(Je.push(mt),dt--)}else Je.push(mt)}return Je}var G=function(Je){return String.fromCodePoint.apply(String,d(Je))},W=function(Je){return Je-48<10?Je-22:Je-65<26?Je-65:Je-97<26?Je-97:h},V=function(Je,dt){return Je+22+75*(Je<26)-((dt!=0)<<5)},X=function(Je,dt,xt){var mt=0;for(Je=xt?F(Je/v):Je>>1,Je+=F(Je/dt);Je>D*A>>1;mt+=h)Je=F(Je/D);return F(mt+(D+1)*Je/(Je+y))},J=function(Je){var dt=[],xt=Je.length,mt=0,mr=w,Rr=S,Yr=Je.lastIndexOf(T);Yr<0&&(Yr=0);for(var un=0;un<Yr;++un)Je.charCodeAt(un)>=128&&q("not-basic"),dt.push(Je.charCodeAt(un));for(var fi=Yr>0?Yr+1:0;fi<xt;){for(var dn=mt,_i=1,Pi=h;;Pi+=h){fi>=xt&&q("invalid-input");var vn=W(Je.charCodeAt(fi++));(vn>=h||vn>F((p-mt)/_i))&&q("overflow"),mt+=vn*_i;var Ii=Pi<=Rr?g:Pi>=Rr+A?A:Pi-Rr;if(vn<Ii)break;var fo=h-Ii;_i>F(p/fo)&&q("overflow"),_i*=fo}var zi=dt.length+1;Rr=X(mt-dn,zi,dn==0),F(mt/zi)>p-mr&&q("overflow"),mr+=F(mt/zi),mt%=zi,dt.splice(mt++,0,mr)}return String.fromCodePoint.apply(String,dt)},he=function(Je){var dt=[];Je=j(Je);var xt=Je.length,mt=w,mr=0,Rr=S,Yr=!0,un=!1,fi=void 0;try{for(var dn=Je[Symbol.iterator](),_i;!(Yr=(_i=dn.next()).done);Yr=!0){var Pi=_i.value;Pi<128&&dt.push(O(Pi))}}catch(wt){un=!0,fi=wt}finally{try{!Yr&&dn.return&&dn.return()}finally{if(un)throw fi}}var vn=dt.length,Ii=vn;for(vn&&dt.push(T);Ii<xt;){var fo=p,zi=!0,Zl=!1,Zs=void 0;try{for(var ea=Je[Symbol.iterator](),vi;!(zi=(vi=ea.next()).done);zi=!0){var ns=vi.value;ns>=mt&&ns<fo&&(fo=ns)}}catch(wt){Zl=!0,Zs=wt}finally{try{!zi&&ea.return&&ea.return()}finally{if(Zl)throw Zs}}var yo=Ii+1;fo-mt>F((p-mr)/yo)&&q("overflow"),mr+=(fo-mt)*yo,mt=fo;var Bi=!0,Oc=!1,Ua=void 0;try{for(var Io=Je[Symbol.iterator](),pa;!(Bi=(pa=Io.next()).done);Bi=!0){var ta=pa.value;if(ta<mt&&++mr>p&&q("overflow"),ta==mt){for(var Ss=mr,ol=h;;ol+=h){var je=ol<=Rr?g:ol>=Rr+A?A:ol-Rr;if(Ss<je)break;var $e=Ss-je,At=h-je;dt.push(O(V(je+$e%At,0))),Ss=F($e/At)}dt.push(O(V(Ss,0))),Rr=X(mr,yo,Ii==vn),mr=0,++Ii}}}catch(wt){Oc=!0,Ua=wt}finally{try{!Bi&&Io.return&&Io.return()}finally{if(Oc)throw Ua}}++mr,++mt}return dt.join("")},be=function(Je){return M(Je,function(dt){return N.test(dt)?J(dt.slice(4).toLowerCase()):dt})},ge=function(Je){return M(Je,function(dt){return P.test(dt)?"xn--"+he(dt):dt})},_e={version:"2.1.0",ucs2:{decode:j,encode:G},decode:J,encode:he,toASCII:ge,toUnicode:be},Se={};function pe(lt){var Je=lt.charCodeAt(0),dt=void 0;return Je<16?dt="%0"+Je.toString(16).toUpperCase():Je<128?dt="%"+Je.toString(16).toUpperCase():Je<2048?dt="%"+(Je>>6|192).toString(16).toUpperCase()+"%"+(Je&63|128).toString(16).toUpperCase():dt="%"+(Je>>12|224).toString(16).toUpperCase()+"%"+(Je>>6&63|128).toString(16).toUpperCase()+"%"+(Je&63|128).toString(16).toUpperCase(),dt}function Ae(lt){for(var Je="",dt=0,xt=lt.length;dt<xt;){var mt=parseInt(lt.substr(dt+1,2),16);if(mt<128)Je+=String.fromCharCode(mt),dt+=3;else if(mt>=194&&mt<224){if(xt-dt>=6){var mr=parseInt(lt.substr(dt+4,2),16);Je+=String.fromCharCode((mt&31)<<6|mr&63)}else Je+=lt.substr(dt,6);dt+=6}else if(mt>=224){if(xt-dt>=9){var Rr=parseInt(lt.substr(dt+4,2),16),Yr=parseInt(lt.substr(dt+7,2),16);Je+=String.fromCharCode((mt&15)<<12|(Rr&63)<<6|Yr&63)}else Je+=lt.substr(dt,9);dt+=9}else Je+=lt.substr(dt,3),dt+=3}return Je}function ae(lt,Je){function dt(xt){var mt=Ae(xt);return mt.match(Je.UNRESERVED)?mt:xt}return lt.scheme&&(lt.scheme=String(lt.scheme).replace(Je.PCT_ENCODED,dt).toLowerCase().replace(Je.NOT_SCHEME,"")),lt.userinfo!==void 0&&(lt.userinfo=String(lt.userinfo).replace(Je.PCT_ENCODED,dt).replace(Je.NOT_USERINFO,pe).replace(Je.PCT_ENCODED,i)),lt.host!==void 0&&(lt.host=String(lt.host).replace(Je.PCT_ENCODED,dt).toLowerCase().replace(Je.NOT_HOST,pe).replace(Je.PCT_ENCODED,i)),lt.path!==void 0&&(lt.path=String(lt.path).replace(Je.PCT_ENCODED,dt).replace(lt.scheme?Je.NOT_PATH:Je.NOT_PATH_NOSCHEME,pe).replace(Je.PCT_ENCODED,i)),lt.query!==void 0&&(lt.query=String(lt.query).replace(Je.PCT_ENCODED,dt).replace(Je.NOT_QUERY,pe).replace(Je.PCT_ENCODED,i)),lt.fragment!==void 0&&(lt.fragment=String(lt.fragment).replace(Je.PCT_ENCODED,dt).replace(Je.NOT_FRAGMENT,pe).replace(Je.PCT_ENCODED,i)),lt}function ie(lt){return lt.replace(/^0*(.*)/,"$1")||"0"}function de(lt,Je){var dt=lt.match(Je.IPV4ADDRESS)||[],xt=f(dt,2),mt=xt[1];return mt?mt.split(".").map(ie).join("."):lt}function te(lt,Je){var dt=lt.match(Je.IPV6ADDRESS)||[],xt=f(dt,3),mt=xt[1],mr=xt[2];if(mt){for(var Rr=mt.toLowerCase().split("::").reverse(),Yr=f(Rr,2),un=Yr[0],fi=Yr[1],dn=fi?fi.split(":").map(ie):[],_i=un.split(":").map(ie),Pi=Je.IPV4ADDRESS.test(_i[_i.length-1]),vn=Pi?7:8,Ii=_i.length-vn,fo=Array(vn),zi=0;zi<vn;++zi)fo[zi]=dn[zi]||_i[Ii+zi]||"";Pi&&(fo[vn-1]=de(fo[vn-1],Je));var Zl=fo.reduce(function(yo,Bi,Oc){if(!Bi||Bi==="0"){var Ua=yo[yo.length-1];Ua&&Ua.index+Ua.length===Oc?Ua.length++:yo.push({index:Oc,length:1})}return yo},[]),Zs=Zl.sort(function(yo,Bi){return Bi.length-yo.length})[0],ea=void 0;if(Zs&&Zs.length>1){var vi=fo.slice(0,Zs.index),ns=fo.slice(Zs.index+Zs.length);ea=vi.join(":")+"::"+ns.join(":")}else ea=fo.join(":");return mr&&(ea+="%"+mr),ea}else return lt}var oe=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,me="".match(/(){0}/)[1]===void 0;function ue(lt){var Je=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},dt={},xt=Je.iri!==!1?u:c;Je.reference==="suffix"&&(lt=(Je.scheme?Je.scheme+":":"")+"//"+lt);var mt=lt.match(oe);if(mt){me?(dt.scheme=mt[1],dt.userinfo=mt[3],dt.host=mt[4],dt.port=parseInt(mt[5],10),dt.path=mt[6]||"",dt.query=mt[7],dt.fragment=mt[8],isNaN(dt.port)&&(dt.port=mt[5])):(dt.scheme=mt[1]||void 0,dt.userinfo=lt.indexOf("@")!==-1?mt[3]:void 0,dt.host=lt.indexOf("//")!==-1?mt[4]:void 0,dt.port=parseInt(mt[5],10),dt.path=mt[6]||"",dt.query=lt.indexOf("?")!==-1?mt[7]:void 0,dt.fragment=lt.indexOf("#")!==-1?mt[8]:void 0,isNaN(dt.port)&&(dt.port=lt.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?mt[4]:void 0)),dt.host&&(dt.host=te(de(dt.host,xt),xt)),dt.scheme===void 0&&dt.userinfo===void 0&&dt.host===void 0&&dt.port===void 0&&!dt.path&&dt.query===void 0?dt.reference="same-document":dt.scheme===void 0?dt.reference="relative":dt.fragment===void 0?dt.reference="absolute":dt.reference="uri",Je.reference&&Je.reference!=="suffix"&&Je.reference!==dt.reference&&(dt.error=dt.error||"URI is not a "+Je.reference+" reference.");var mr=Se[(Je.scheme||dt.scheme||"").toLowerCase()];if(!Je.unicodeSupport&&(!mr||!mr.unicodeSupport)){if(dt.host&&(Je.domainHost||mr&&mr.domainHost))try{dt.host=_e.toASCII(dt.host.replace(xt.PCT_ENCODED,Ae).toLowerCase())}catch(Rr){dt.error=dt.error||"Host's domain name can not be converted to ASCII via punycode: "+Rr}ae(dt,c)}else ae(dt,xt);mr&&mr.parse&&mr.parse(dt,Je)}else dt.error=dt.error||"URI can not be parsed.";return dt}function K(lt,Je){var dt=Je.iri!==!1?u:c,xt=[];return lt.userinfo!==void 0&&(xt.push(lt.userinfo),xt.push("@")),lt.host!==void 0&&xt.push(te(de(String(lt.host),dt),dt).replace(dt.IPV6ADDRESS,function(mt,mr,Rr){return"["+mr+(Rr?"%25"+Rr:"")+"]"})),(typeof lt.port=="number"||typeof lt.port=="string")&&(xt.push(":"),xt.push(String(lt.port))),xt.length?xt.join(""):void 0}var re=/^\.\.?\//,xe=/^\/\.(\/|$)/,ye=/^\/\.\.(\/|$)/,Z=/^\/?(?:.|\n)*?(?=\/|$)/;function Ne(lt){for(var Je=[];lt.length;)if(lt.match(re))lt=lt.replace(re,"");else if(lt.match(xe))lt=lt.replace(xe,"/");else if(lt.match(ye))lt=lt.replace(ye,"/"),Je.pop();else if(lt==="."||lt==="..")lt="";else{var dt=lt.match(Z);if(dt){var xt=dt[0];lt=lt.slice(xt.length),Je.push(xt)}else throw new Error("Unexpected dot segment condition")}return Je.join("")}function Qe(lt){var Je=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},dt=Je.iri?u:c,xt=[],mt=Se[(Je.scheme||lt.scheme||"").toLowerCase()];if(mt&&mt.serialize&&mt.serialize(lt,Je),lt.host&&!dt.IPV6ADDRESS.test(lt.host)){if(Je.domainHost||mt&&mt.domainHost)try{lt.host=Je.iri?_e.toUnicode(lt.host):_e.toASCII(lt.host.replace(dt.PCT_ENCODED,Ae).toLowerCase())}catch(Yr){lt.error=lt.error||"Host's domain name can not be converted to "+(Je.iri?"Unicode":"ASCII")+" via punycode: "+Yr}}ae(lt,dt),Je.reference!=="suffix"&<.scheme&&(xt.push(lt.scheme),xt.push(":"));var mr=K(lt,Je);if(mr!==void 0&&(Je.reference!=="suffix"&&xt.push("//"),xt.push(mr),lt.path&<.path.charAt(0)!=="/"&&xt.push("/")),lt.path!==void 0){var Rr=lt.path;!Je.absolutePath&&(!mt||!mt.absolutePath)&&(Rr=Ne(Rr)),mr===void 0&&(Rr=Rr.replace(/^\/\//,"/%2F")),xt.push(Rr)}return lt.query!==void 0&&(xt.push("?"),xt.push(lt.query)),lt.fragment!==void 0&&(xt.push("#"),xt.push(lt.fragment)),xt.join("")}function qe(lt,Je){var dt=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},xt=arguments[3],mt={};return xt||(lt=ue(Qe(lt,dt),dt),Je=ue(Qe(Je,dt),dt)),dt=dt||{},!dt.tolerant&&Je.scheme?(mt.scheme=Je.scheme,mt.userinfo=Je.userinfo,mt.host=Je.host,mt.port=Je.port,mt.path=Ne(Je.path||""),mt.query=Je.query):(Je.userinfo!==void 0||Je.host!==void 0||Je.port!==void 0?(mt.userinfo=Je.userinfo,mt.host=Je.host,mt.port=Je.port,mt.path=Ne(Je.path||""),mt.query=Je.query):(Je.path?(Je.path.charAt(0)==="/"?mt.path=Ne(Je.path):((lt.userinfo!==void 0||lt.host!==void 0||lt.port!==void 0)&&!lt.path?mt.path="/"+Je.path:lt.path?mt.path=lt.path.slice(0,lt.path.lastIndexOf("/")+1)+Je.path:mt.path=Je.path,mt.path=Ne(mt.path)),mt.query=Je.query):(mt.path=lt.path,Je.query!==void 0?mt.query=Je.query:mt.query=lt.query),mt.userinfo=lt.userinfo,mt.host=lt.host,mt.port=lt.port),mt.scheme=lt.scheme),mt.fragment=Je.fragment,mt}function He(lt,Je,dt){var xt=s({scheme:"null"},dt);return Qe(qe(ue(lt,xt),ue(Je,xt),xt,!0),xt)}function le(lt,Je){return typeof lt=="string"?lt=Qe(ue(lt,Je),Je):n(lt)==="object"&&(lt=ue(Qe(lt,Je),Je)),lt}function Ie(lt,Je,dt){return typeof lt=="string"?lt=Qe(ue(lt,dt),dt):n(lt)==="object"&&(lt=Qe(lt,dt)),typeof Je=="string"?Je=Qe(ue(Je,dt),dt):n(Je)==="object"&&(Je=Qe(Je,dt)),lt===Je}function Oe(lt,Je){return lt&<.toString().replace(!Je||!Je.iri?c.ESCAPE:u.ESCAPE,pe)}function Le(lt,Je){return lt&<.toString().replace(!Je||!Je.iri?c.PCT_ENCODED:u.PCT_ENCODED,Ae)}var Ke={scheme:"http",domainHost:!0,parse:function(Je,dt){return Je.host||(Je.error=Je.error||"HTTP URIs must have a host."),Je},serialize:function(Je,dt){var xt=String(Je.scheme).toLowerCase()==="https";return(Je.port===(xt?443:80)||Je.port==="")&&(Je.port=void 0),Je.path||(Je.path="/"),Je}},nt={scheme:"https",domainHost:Ke.domainHost,parse:Ke.parse,serialize:Ke.serialize};function pt(lt){return typeof lt.secure=="boolean"?lt.secure:String(lt.scheme).toLowerCase()==="wss"}var vt={scheme:"ws",domainHost:!0,parse:function(Je,dt){var xt=Je;return xt.secure=pt(xt),xt.resourceName=(xt.path||"/")+(xt.query?"?"+xt.query:""),xt.path=void 0,xt.query=void 0,xt},serialize:function(Je,dt){if((Je.port===(pt(Je)?443:80)||Je.port==="")&&(Je.port=void 0),typeof Je.secure=="boolean"&&(Je.scheme=Je.secure?"wss":"ws",Je.secure=void 0),Je.resourceName){var xt=Je.resourceName.split("?"),mt=f(xt,2),mr=mt[0],Rr=mt[1];Je.path=mr&&mr!=="/"?mr:void 0,Je.query=Rr,Je.resourceName=void 0}return Je.fragment=void 0,Je}},It={scheme:"wss",domainHost:vt.domainHost,parse:vt.parse,serialize:vt.serialize},Ar={},Mr=!0,Fe="[A-Za-z0-9\\-\\.\\_\\~"+(Mr?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",ct="[0-9A-Fa-f]",ut=r(r("%[EFef]"+ct+"%"+ct+ct+"%"+ct+ct)+"|"+r("%[89A-Fa-f]"+ct+"%"+ct+ct)+"|"+r("%"+ct+ct)),Ht="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Lt="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",Pt=e(Lt,'[\\"\\\\]'),Ft="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",Zt=new RegExp(Fe,"g"),Jt=new RegExp(ut,"g"),an=new RegExp(e("[^]",Ht,"[\\.]",'[\\"]',Pt),"g"),Fr=new RegExp(e("[^]",Fe,Ft),"g"),en=Fr;function Zr(lt){var Je=Ae(lt);return Je.match(Zt)?Je:lt}var Xn={scheme:"mailto",parse:function(Je,dt){var xt=Je,mt=xt.to=xt.path?xt.path.split(","):[];if(xt.path=void 0,xt.query){for(var mr=!1,Rr={},Yr=xt.query.split("&"),un=0,fi=Yr.length;un<fi;++un){var dn=Yr[un].split("=");switch(dn[0]){case"to":for(var _i=dn[1].split(","),Pi=0,vn=_i.length;Pi<vn;++Pi)mt.push(_i[Pi]);break;case"subject":xt.subject=Le(dn[1],dt);break;case"body":xt.body=Le(dn[1],dt);break;default:mr=!0,Rr[Le(dn[0],dt)]=Le(dn[1],dt);break}}mr&&(xt.headers=Rr)}xt.query=void 0;for(var Ii=0,fo=mt.length;Ii<fo;++Ii){var zi=mt[Ii].split("@");if(zi[0]=Le(zi[0]),dt.unicodeSupport)zi[1]=Le(zi[1],dt).toLowerCase();else try{zi[1]=_e.toASCII(Le(zi[1],dt).toLowerCase())}catch(Zl){xt.error=xt.error||"Email address's domain name can not be converted to ASCII via punycode: "+Zl}mt[Ii]=zi.join("@")}return xt},serialize:function(Je,dt){var xt=Je,mt=o(Je.to);if(mt){for(var mr=0,Rr=mt.length;mr<Rr;++mr){var Yr=String(mt[mr]),un=Yr.lastIndexOf("@"),fi=Yr.slice(0,un).replace(Jt,Zr).replace(Jt,i).replace(an,pe),dn=Yr.slice(un+1);try{dn=dt.iri?_e.toUnicode(dn):_e.toASCII(Le(dn,dt).toLowerCase())}catch(Ii){xt.error=xt.error||"Email address's domain name can not be converted to "+(dt.iri?"Unicode":"ASCII")+" via punycode: "+Ii}mt[mr]=fi+"@"+dn}xt.path=mt.join(",")}var _i=Je.headers=Je.headers||{};Je.subject&&(_i.subject=Je.subject),Je.body&&(_i.body=Je.body);var Pi=[];for(var vn in _i)_i[vn]!==Ar[vn]&&Pi.push(vn.replace(Jt,Zr).replace(Jt,i).replace(Fr,pe)+"="+_i[vn].replace(Jt,Zr).replace(Jt,i).replace(en,pe));return Pi.length&&(xt.query=Pi.join("&")),xt}},Zn=/^([^\:]+)\:(.*)/,In={scheme:"urn",parse:function(Je,dt){var xt=Je.path&&Je.path.match(Zn),mt=Je;if(xt){var mr=dt.scheme||mt.scheme||"urn",Rr=xt[1].toLowerCase(),Yr=xt[2],un=mr+":"+(dt.nid||Rr),fi=Se[un];mt.nid=Rr,mt.nss=Yr,mt.path=void 0,fi&&(mt=fi.parse(mt,dt))}else mt.error=mt.error||"URN can not be parsed.";return mt},serialize:function(Je,dt){var xt=dt.scheme||Je.scheme||"urn",mt=Je.nid,mr=xt+":"+(dt.nid||mt),Rr=Se[mr];Rr&&(Je=Rr.serialize(Je,dt));var Yr=Je,un=Je.nss;return Yr.path=(mt||dt.nid)+":"+un,Yr}},uo=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,Yi={scheme:"urn:uuid",parse:function(Je,dt){var xt=Je;return xt.uuid=xt.nss,xt.nss=void 0,!dt.tolerant&&(!xt.uuid||!xt.uuid.match(uo))&&(xt.error=xt.error||"UUID is not valid."),xt},serialize:function(Je,dt){var xt=Je;return xt.nss=(Je.uuid||"").toLowerCase(),xt}};Se[Ke.scheme]=Ke,Se[nt.scheme]=nt,Se[vt.scheme]=vt,Se[It.scheme]=It,Se[Xn.scheme]=Xn,Se[In.scheme]=In,Se[Yi.scheme]=Yi,t.SCHEMES=Se,t.pctEncChar=pe,t.pctDecChars=Ae,t.parse=ue,t.removeDotSegments=Ne,t.serialize=Qe,t.resolveComponents=qe,t.resolve=He,t.normalize=le,t.equal=Ie,t.escapeComponent=Oe,t.unescapeComponent=Le,Object.defineProperty(t,"__esModule",{value:!0})}))});var MH=B((CMo,GUt)=>{"use strict";GUt.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,i,o;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!t(e[i],r[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[i]))return!1;for(i=n;i--!==0;){var s=o[i];if(!t(e[s],r[s]))return!1}return!0}return e!==e&&r!==r}});var VUt=B((_Mo,jUt)=>{"use strict";jUt.exports=function(e){for(var r=0,n=e.length,i=0,o;i<n;)r++,o=e.charCodeAt(i++),o>=55296&&o<=56319&&i<n&&(o=e.charCodeAt(i),(o&64512)==56320&&i++);return r}});var lO=B((SMo,YUt)=>{"use strict";YUt.exports={copy:dqn,checkDataType:yqe,checkDataTypes:pqn,coerceToTypes:hqn,toHash:vqe,getProperty:bqe,escapeQuotes:Cqe,equal:MH(),ucs2length:VUt(),varOccurences:Aqn,varReplace:yqn,schemaHasRules:Eqn,schemaHasRulesExcept:vqn,schemaUnknownRules:bqn,toQuotedString:Eqe,getPathExpr:Cqn,getPath:_qn,getData:xqn,unescapeFragment:Tqn,unescapeJsonPointer:Sqe,escapeFragment:Dqn,escapeJsonPointer:_qe};function dqn(t,e){e=e||{};for(var r in t)e[r]=t[r];return e}function yqe(t,e,r,n){var i=n?" !== ":" === ",o=n?" || ":" && ",s=n?"!":"",a=n?"":"!";switch(t){case"null":return e+i+"null";case"array":return s+"Array.isArray("+e+")";case"object":return"("+s+e+o+"typeof "+e+i+'"object"'+o+a+"Array.isArray("+e+"))";case"integer":return"(typeof "+e+i+'"number"'+o+a+"("+e+" % 1)"+o+e+i+e+(r?o+s+"isFinite("+e+")":"")+")";case"number":return"(typeof "+e+i+'"'+t+'"'+(r?o+s+"isFinite("+e+")":"")+")";default:return"typeof "+e+i+'"'+t+'"'}}function pqn(t,e,r){switch(t.length){case 1:return yqe(t[0],e,r,!0);default:var n="",i=vqe(t);i.array&&i.object&&(n=i.null?"(":"(!"+e+" || ",n+="typeof "+e+' !== "object")',delete i.null,delete i.array,delete i.object),i.number&&delete i.integer;for(var o in i)n+=(n?" && ":"")+yqe(o,e,r,!0);return n}}var $Ut=vqe(["string","number","integer","boolean","null"]);function hqn(t,e){if(Array.isArray(e)){for(var r=[],n=0;n<e.length;n++){var i=e[n];($Ut[i]||t==="array"&&i==="array")&&(r[r.length]=i)}if(r.length)return r}else{if($Ut[e])return[e];if(t==="array"&&e==="array")return["array"]}}function vqe(t){for(var e={},r=0;r<t.length;r++)e[t[r]]=!0;return e}var mqn=/^[a-z$_][a-z$_0-9]*$/i,gqn=/'|\\/g;function bqe(t){return typeof t=="number"?"["+t+"]":mqn.test(t)?"."+t:"['"+Cqe(t)+"']"}function Cqe(t){return t.replace(gqn,"\\$&").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\f/g,"\\f").replace(/\t/g,"\\t")}function Aqn(t,e){e+="[^0-9]";var r=t.match(new RegExp(e,"g"));return r?r.length:0}function yqn(t,e,r){return e+="([^0-9])",r=r.replace(/\$/g,"$$$$"),t.replace(new RegExp(e,"g"),r+"$1")}function Eqn(t,e){if(typeof t=="boolean")return!t;for(var r in t)if(e[r])return!0}function vqn(t,e,r){if(typeof t=="boolean")return!t&&r!="not";for(var n in t)if(n!=r&&e[n])return!0}function bqn(t,e){if(typeof t!="boolean"){for(var r in t)if(!e[r])return r}}function Eqe(t){return"'"+Cqe(t)+"'"}function Cqn(t,e,r,n){var i=r?"'/' + "+e+(n?"":".replace(/~/g, '~0').replace(/\\//g, '~1')"):n?"'[' + "+e+" + ']'":"'[\\'' + "+e+" + '\\']'";return WUt(t,i)}function _qn(t,e,r){var n=Eqe(r?"/"+_qe(e):bqe(e));return WUt(t,n)}var Sqn=/^\/(?:[^~]|~0|~1)*$/,wqn=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function xqn(t,e,r){var n,i,o,s;if(t==="")return"rootData";if(t[0]=="/"){if(!Sqn.test(t))throw new Error("Invalid JSON-pointer: "+t);i=t,o="rootData"}else{if(s=t.match(wqn),!s)throw new Error("Invalid JSON-pointer: "+t);if(n=+s[1],i=s[2],i=="#"){if(n>=e)throw new Error("Cannot access property/index "+n+" levels up, current level is "+e);return r[e-n]}if(n>e)throw new Error("Cannot access data "+n+" levels up, current level is "+e);if(o="data"+(e-n||""),!i)return o}for(var a=o,c=i.split("/"),u=0;u<c.length;u++){var f=c[u];f&&(o+=bqe(Sqe(f)),a+=" && "+o)}return a}function WUt(t,e){return t=='""'?e:(t+" + "+e).replace(/([^\\])' \+ '/g,"$1")}function Tqn(t){return Sqe(decodeURIComponent(t))}function Dqn(t){return encodeURIComponent(_qe(t))}function _qe(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}function Sqe(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}});var wqe=B((wMo,zUt)=>{"use strict";var Iqn=lO();zUt.exports=Rqn;function Rqn(t){Iqn.copy(t,this)}});var KUt=B((xMo,JUt)=>{"use strict";var qx=JUt.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},i=r.post||function(){};Rme(e,n,i,t,"",t)};qx.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0};qx.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};qx.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};qx.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Rme(t,e,r,n,i,o,s,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,i,o,s,a,c,u);for(var f in n){var d=n[f];if(Array.isArray(d)){if(f in qx.arrayKeywords)for(var p=0;p<d.length;p++)Rme(t,e,r,d[p],i+"/"+f+"/"+p,o,i,f,n,p)}else if(f in qx.propsKeywords){if(d&&typeof d=="object")for(var h in d)Rme(t,e,r,d[h],i+"/"+f+"/"+Bqn(h),o,i,f,n,h)}else(f in qx.keywords||t.allKeys&&!(f in qx.skipKeywords))&&Rme(t,e,r,d,i+"/"+f,o,i,f,n)}r(n,i,o,s,a,c,u)}}function Bqn(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var Lme=B((TMo,tQt)=>{"use strict";var Tee=HUt(),XUt=MH(),Mme=lO(),Bme=wqe(),Nqn=KUt();tQt.exports=Gx;Gx.normalizeId=Hx;Gx.fullPath=Nme;Gx.url=Ome;Gx.ids=Pqn;Gx.inlineRef=xqe;Gx.schema=kme;function Gx(t,e,r){var n=this._refs[r];if(typeof n=="string")if(this._refs[n])n=this._refs[n];else return Gx.call(this,t,e,n);if(n=n||this._schemas[r],n instanceof Bme)return xqe(n.schema,this._opts.inlineRefs)?n.schema:n.validate||this._compile(n);var i=kme.call(this,e,r),o,s,a;return i&&(o=i.schema,e=i.root,a=i.baseId),o instanceof Bme?s=o.validate||t.call(this,o.schema,e,void 0,a):o!==void 0&&(s=xqe(o,this._opts.inlineRefs)?o:t.call(this,o,e,void 0,a)),s}function kme(t,e){var r=Tee.parse(e),n=eQt(r),i=Nme(this._getId(t.schema));if(Object.keys(t.schema).length===0||n!==i){var o=Hx(n),s=this._refs[o];if(typeof s=="string")return Oqn.call(this,t,s,r);if(s instanceof Bme)s.validate||this._compile(s),t=s;else if(s=this._schemas[o],s instanceof Bme){if(s.validate||this._compile(s),o==Hx(e))return{schema:s,root:t,baseId:i};t=s}else return;if(!t.schema)return;i=Nme(this._getId(t.schema))}return ZUt.call(this,r,i,t.schema,t)}function Oqn(t,e,r){var n=kme.call(this,t,e);if(n){var i=n.schema,o=n.baseId;t=n.root;var s=this._getId(i);return s&&(o=Ome(o,s)),ZUt.call(this,r,o,i,t)}}var Mqn=Mme.toHash(["properties","patternProperties","enum","dependencies","definitions"]);function ZUt(t,e,r,n){if(t.fragment=t.fragment||"",t.fragment.slice(0,1)=="/"){for(var i=t.fragment.split("/"),o=1;o<i.length;o++){var s=i[o];if(s){if(s=Mme.unescapeFragment(s),r=r[s],r===void 0)break;var a;if(!Mqn[s]&&(a=this._getId(r),a&&(e=Ome(e,a)),r.$ref)){var c=Ome(e,r.$ref),u=kme.call(this,n,c);u&&(r=u.schema,n=u.root,e=u.baseId)}}}if(r!==void 0&&r!==n.schema)return{schema:r,root:n,baseId:e}}}var kqn=Mme.toHash(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum"]);function xqe(t,e){if(e===!1)return!1;if(e===void 0||e===!0)return Tqe(t);if(e)return Dqe(t)<=e}function Tqe(t){var e;if(Array.isArray(t)){for(var r=0;r<t.length;r++)if(e=t[r],typeof e=="object"&&!Tqe(e))return!1}else for(var n in t)if(n=="$ref"||(e=t[n],typeof e=="object"&&!Tqe(e)))return!1;return!0}function Dqe(t){var e=0,r;if(Array.isArray(t)){for(var n=0;n<t.length;n++)if(r=t[n],typeof r=="object"&&(e+=Dqe(r)),e==1/0)return 1/0}else for(var i in t){if(i=="$ref")return 1/0;if(kqn[i])e++;else if(r=t[i],typeof r=="object"&&(e+=Dqe(r)+1),e==1/0)return 1/0}return e}function Nme(t,e){e!==!1&&(t=Hx(t));var r=Tee.parse(t);return eQt(r)}function eQt(t){return Tee.serialize(t).split("#")[0]+"#"}var Lqn=/#\/?$/;function Hx(t){return t?t.replace(Lqn,""):""}function Ome(t,e){return e=Hx(e),Tee.resolve(t,e)}function Pqn(t){var e=Hx(this._getId(t)),r={"":e},n={"":Nme(e,!1)},i={},o=this;return Nqn(t,{allKeys:!0},function(s,a,c,u,f,d,p){if(a!==""){var h=o._getId(s),g=r[u],A=n[u]+"/"+f;if(p!==void 0&&(A+="/"+(typeof p=="number"?p:Mme.escapeFragment(p))),typeof h=="string"){h=g=Hx(g?Tee.resolve(g,h):h);var y=o._refs[h];if(typeof y=="string"&&(y=o._refs[y]),y&&y.schema){if(!XUt(s,y.schema))throw new Error('id "'+h+'" resolves to more than one schema')}else if(h!=Hx(A))if(h[0]=="#"){if(i[h]&&!XUt(s,i[h]))throw new Error('id "'+h+'" resolves to more than one schema');i[h]=s}else o._refs[h]=A}r[a]=g,n[a]=A}}),i}});var Pme=B((DMo,nQt)=>{"use strict";var Iqe=Lme();nQt.exports={Validation:rQt(Fqn),MissingRef:rQt(Rqe)};function Fqn(t){this.message="validation failed",this.errors=t,this.ajv=this.validation=!0}Rqe.message=function(t,e){return"can't resolve reference "+e+" from id "+t};function Rqe(t,e,r){this.message=r||Rqe.message(t,e),this.missingRef=Iqe.url(t,e),this.missingSchema=Iqe.normalizeId(Iqe.fullPath(this.missingRef))}function rQt(t){return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}});var Bqe=B((IMo,iQt)=>{"use strict";iQt.exports=function(t,e){e||(e={}),typeof e=="function"&&(e={cmp:e});var r=typeof e.cycles=="boolean"?e.cycles:!1,n=e.cmp&&(function(o){return function(s){return function(a,c){var u={key:a,value:s[a]},f={key:c,value:s[c]};return o(u,f)}}})(e.cmp),i=[];return(function o(s){if(s&&s.toJSON&&typeof s.toJSON=="function"&&(s=s.toJSON()),s!==void 0){if(typeof s=="number")return isFinite(s)?""+s:"null";if(typeof s!="object")return JSON.stringify(s);var a,c;if(Array.isArray(s)){for(c="[",a=0;a<s.length;a++)a&&(c+=","),c+=o(s[a])||"null";return c+"]"}if(s===null)return"null";if(i.indexOf(s)!==-1){if(r)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var u=i.push(s)-1,f=Object.keys(s).sort(n&&n(s));for(c="",a=0;a<f.length;a++){var d=f[a],p=o(s[d]);p&&(c&&(c+=","),c+=JSON.stringify(d)+":"+p)}return i.splice(u,1),"{"+c+"}"}})(t)}});var Nqe=B((RMo,oQt)=>{"use strict";oQt.exports=function(e,r,n){var i="",o=e.schema.$async===!0,s=e.util.schemaHasRulesExcept(e.schema,e.RULES.all,"$ref"),a=e.self._getId(e.schema);if(e.opts.strictKeywords){var c=e.util.schemaUnknownRules(e.schema,e.RULES.keywords);if(c){var u="unknown keyword: "+c;if(e.opts.strictKeywords==="log")e.logger.warn(u);else throw new Error(u)}}if(e.isTop&&(i+=" var validate = ",o&&(e.async=!0,i+="async "),i+="function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; ",a&&(e.opts.sourceCode||e.opts.processCode)&&(i+=" "+("/*# sourceURL="+a+" */")+" ")),typeof e.schema=="boolean"||!(s||e.schema.$ref)){var r="false schema",f=e.level,d=e.dataLevel,p=e.schema[r],h=e.schemaPath+e.util.getProperty(r),g=e.errSchemaPath+"/"+r,N=!e.opts.allErrors,Q,A="data"+(d||""),T="valid"+f;if(e.schema===!1){e.isTop?N=!0:i+=" var "+T+" = false; ";var y=y||[];y.push(i),i="",e.createErrors!==!1?(i+=" { keyword: '"+(Q||"false schema")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(g)+" , params: {} ",e.opts.messages!==!1&&(i+=" , message: 'boolean schema is false' "),e.opts.verbose&&(i+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+A+" "),i+=" } "):i+=" {} ";var v=i;i=y.pop(),!e.compositeRule&&N?e.async?i+=" throw new ValidationError(["+v+"]); ":i+=" validate.errors = ["+v+"]; return false; ":i+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else e.isTop?o?i+=" return data; ":i+=" validate.errors = null; return true; ":i+=" var "+T+" = true; ";return e.isTop&&(i+=" }; return validate; "),i}if(e.isTop){var S=e.isTop,f=e.level=0,d=e.dataLevel=0,A="data";if(e.rootId=e.resolve.fullPath(e.self._getId(e.root.schema)),e.baseId=e.baseId||e.rootId,delete e.isTop,e.dataPathArr=[""],e.schema.default!==void 0&&e.opts.useDefaults&&e.opts.strictDefaults){var w="default is ignored in the schema root";if(e.opts.strictDefaults==="log")e.logger.warn(w);else throw new Error(w)}i+=" var vErrors = null; ",i+=" var errors = 0; ",i+=" if (rootData === undefined) rootData = data; "}else{var f=e.level,d=e.dataLevel,A="data"+(d||"");if(a&&(e.baseId=e.resolve.url(e.baseId,a)),o&&!e.async)throw new Error("async schema in sync schema");i+=" var errs_"+f+" = errors;"}var T="valid"+f,N=!e.opts.allErrors,P="",U="",Q,D=e.schema.type,F=Array.isArray(D);if(D&&e.opts.nullable&&e.schema.nullable===!0&&(F?D.indexOf("null")==-1&&(D=D.concat("null")):D!="null"&&(D=[D,"null"],F=!0)),F&&D.length==1&&(D=D[0],F=!1),e.schema.$ref&&s){if(e.opts.extendRefs=="fail")throw new Error('$ref: validation keywords used in schema at path "'+e.errSchemaPath+'" (see option extendRefs)');e.opts.extendRefs!==!0&&(s=!1,e.logger.warn('$ref: keywords ignored in schema at path "'+e.errSchemaPath+'"'))}if(e.schema.$comment&&e.opts.$comment&&(i+=" "+e.RULES.all.$comment.code(e,"$comment")),D){if(e.opts.coerceTypes)var O=e.util.coerceToTypes(e.opts.coerceTypes,D);var q=e.RULES.types[D];if(O||F||q===!0||q&&!Z(q)){var h=e.schemaPath+".type",g=e.errSchemaPath+"/type",h=e.schemaPath+".type",g=e.errSchemaPath+"/type",L=F?"checkDataTypes":"checkDataType";if(i+=" if ("+e.util[L](D,A,e.opts.strictNumbers,!0)+") { ",O){var M="dataType"+f,j="coerced"+f;i+=" var "+M+" = typeof "+A+"; var "+j+" = undefined; ",e.opts.coerceTypes=="array"&&(i+=" if ("+M+" == 'object' && Array.isArray("+A+") && "+A+".length == 1) { "+A+" = "+A+"[0]; "+M+" = typeof "+A+"; if ("+e.util.checkDataType(e.schema.type,A,e.opts.strictNumbers)+") "+j+" = "+A+"; } "),i+=" if ("+j+" !== undefined) ; ";var G=O;if(G)for(var W,V=-1,X=G.length-1;V<X;)W=G[V+=1],W=="string"?i+=" else if ("+M+" == 'number' || "+M+" == 'boolean') "+j+" = '' + "+A+"; else if ("+A+" === null) "+j+" = ''; ":W=="number"||W=="integer"?(i+=" else if ("+M+" == 'boolean' || "+A+" === null || ("+M+" == 'string' && "+A+" && "+A+" == +"+A+" ",W=="integer"&&(i+=" && !("+A+" % 1)"),i+=")) "+j+" = +"+A+"; "):W=="boolean"?i+=" else if ("+A+" === 'false' || "+A+" === 0 || "+A+" === null) "+j+" = false; else if ("+A+" === 'true' || "+A+" === 1) "+j+" = true; ":W=="null"?i+=" else if ("+A+" === '' || "+A+" === 0 || "+A+" === false) "+j+" = null; ":e.opts.coerceTypes=="array"&&W=="array"&&(i+=" else if ("+M+" == 'string' || "+M+" == 'number' || "+M+" == 'boolean' || "+A+" == null) "+j+" = ["+A+"]; ");i+=" else { ";var y=y||[];y.push(i),i="",e.createErrors!==!1?(i+=" { keyword: '"+(Q||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(g)+" , params: { type: '",F?i+=""+D.join(","):i+=""+D,i+="' } ",e.opts.messages!==!1&&(i+=" , message: 'should be ",F?i+=""+D.join(","):i+=""+D,i+="' "),e.opts.verbose&&(i+=" , schema: validate.schema"+h+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+A+" "),i+=" } "):i+=" {} ";var v=i;i=y.pop(),!e.compositeRule&&N?e.async?i+=" throw new ValidationError(["+v+"]); ":i+=" validate.errors = ["+v+"]; return false; ":i+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } if ("+j+" !== undefined) { ";var J=d?"data"+(d-1||""):"parentData",he=d?e.dataPathArr[d]:"parentDataProperty";i+=" "+A+" = "+j+"; ",d||(i+="if ("+J+" !== undefined)"),i+=" "+J+"["+he+"] = "+j+"; } "}else{var y=y||[];y.push(i),i="",e.createErrors!==!1?(i+=" { keyword: '"+(Q||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(g)+" , params: { type: '",F?i+=""+D.join(","):i+=""+D,i+="' } ",e.opts.messages!==!1&&(i+=" , message: 'should be ",F?i+=""+D.join(","):i+=""+D,i+="' "),e.opts.verbose&&(i+=" , schema: validate.schema"+h+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+A+" "),i+=" } "):i+=" {} ";var v=i;i=y.pop(),!e.compositeRule&&N?e.async?i+=" throw new ValidationError(["+v+"]); ":i+=" validate.errors = ["+v+"]; return false; ":i+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}i+=" } "}}if(e.schema.$ref&&!s)i+=" "+e.RULES.all.$ref.code(e,"$ref")+" ",N&&(i+=" } if (errors === ",S?i+="0":i+="errs_"+f,i+=") { ",U+="}");else{var be=e.RULES;if(be){for(var q,ge=-1,_e=be.length-1;ge<_e;)if(q=be[ge+=1],Z(q)){if(q.type&&(i+=" if ("+e.util.checkDataType(q.type,A,e.opts.strictNumbers)+") { "),e.opts.useDefaults){if(q.type=="object"&&e.schema.properties){var p=e.schema.properties,Se=Object.keys(p),pe=Se;if(pe)for(var Ae,ae=-1,ie=pe.length-1;ae<ie;){Ae=pe[ae+=1];var de=p[Ae];if(de.default!==void 0){var te=A+e.util.getProperty(Ae);if(e.compositeRule){if(e.opts.strictDefaults){var w="default is ignored for: "+te;if(e.opts.strictDefaults==="log")e.logger.warn(w);else throw new Error(w)}}else i+=" if ("+te+" === undefined ",e.opts.useDefaults=="empty"&&(i+=" || "+te+" === null || "+te+" === '' "),i+=" ) "+te+" = ",e.opts.useDefaults=="shared"?i+=" "+e.useDefault(de.default)+" ":i+=" "+JSON.stringify(de.default)+" ",i+="; "}}}else if(q.type=="array"&&Array.isArray(e.schema.items)){var oe=e.schema.items;if(oe){for(var de,V=-1,me=oe.length-1;V<me;)if(de=oe[V+=1],de.default!==void 0){var te=A+"["+V+"]";if(e.compositeRule){if(e.opts.strictDefaults){var w="default is ignored for: "+te;if(e.opts.strictDefaults==="log")e.logger.warn(w);else throw new Error(w)}}else i+=" if ("+te+" === undefined ",e.opts.useDefaults=="empty"&&(i+=" || "+te+" === null || "+te+" === '' "),i+=" ) "+te+" = ",e.opts.useDefaults=="shared"?i+=" "+e.useDefault(de.default)+" ":i+=" "+JSON.stringify(de.default)+" ",i+="; "}}}}var ue=q.rules;if(ue){for(var K,re=-1,xe=ue.length-1;re<xe;)if(K=ue[re+=1],Ne(K)){var ye=K.code(e,K.keyword,q.type);ye&&(i+=" "+ye+" ",N&&(P+="}"))}}if(N&&(i+=" "+P+" ",P=""),q.type&&(i+=" } ",D&&D===q.type&&!O)){i+=" else { ";var h=e.schemaPath+".type",g=e.errSchemaPath+"/type",y=y||[];y.push(i),i="",e.createErrors!==!1?(i+=" { keyword: '"+(Q||"type")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(g)+" , params: { type: '",F?i+=""+D.join(","):i+=""+D,i+="' } ",e.opts.messages!==!1&&(i+=" , message: 'should be ",F?i+=""+D.join(","):i+=""+D,i+="' "),e.opts.verbose&&(i+=" , schema: validate.schema"+h+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+A+" "),i+=" } "):i+=" {} ";var v=i;i=y.pop(),!e.compositeRule&&N?e.async?i+=" throw new ValidationError(["+v+"]); ":i+=" validate.errors = ["+v+"]; return false; ":i+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } "}N&&(i+=" if (errors === ",S?i+="0":i+="errs_"+f,i+=") { ",U+="}")}}}N&&(i+=" "+U+" "),S?(o?(i+=" if (errors === 0) return data; ",i+=" else throw new ValidationError(vErrors); "):(i+=" validate.errors = vErrors; ",i+=" return errors === 0; "),i+=" }; return validate;"):i+=" var "+T+" = errors === errs_"+f+";";function Z(qe){for(var He=qe.rules,le=0;le<He.length;le++)if(Ne(He[le]))return!0}function Ne(qe){return e.schema[qe.keyword]!==void 0||qe.implements&&Qe(qe)}function Qe(qe){for(var He=qe.implements,le=0;le<He.length;le++)if(e.schema[He[le]]!==void 0)return!0}return i}});var uQt=B((BMo,cQt)=>{"use strict";var Fme=Lme(),Qme=lO(),aQt=Pme(),Uqn=Bqe(),sQt=Nqe(),Qqn=Qme.ucs2length,qqn=MH(),Hqn=aQt.Validation;cQt.exports=Oqe;function Oqe(t,e,r,n){var i=this,o=this._opts,s=[void 0],a={},c=[],u={},f=[],d={},p=[];e=e||{schema:t,refVal:s,refs:a};var h=Gqn.call(this,t,e,n),g=this._compilations[h.index];if(h.compiling)return g.callValidate=w;var A=this._formats,y=this.RULES;try{var v=T(t,e,r,n);g.validate=v;var S=g.callValidate;return S&&(S.schema=v.schema,S.errors=null,S.refs=v.refs,S.refVal=v.refVal,S.root=v.root,S.$async=v.$async,o.sourceCode&&(S.source=v.source)),v}finally{jqn.call(this,t,e,n)}function w(){var L=g.validate,M=L.apply(this,arguments);return w.errors=L.errors,M}function T(L,M,j,G){var W=!M||M&&M.schema==L;if(M.schema!=e.schema)return Oqe.call(i,L,M,j,G);var V=L.$async===!0,X=sQt({isTop:!0,schema:L,isRoot:W,baseId:G,root:M,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:aQt.MissingRef,RULES:y,validate:sQt,util:Qme,resolve:Fme,resolveRef:N,usePattern:F,useDefault:O,useCustomRule:q,opts:o,formats:A,logger:i.logger,self:i});X=Ume(s,Wqn)+Ume(c,Vqn)+Ume(f,$qn)+Ume(p,Yqn)+X,o.processCode&&(X=o.processCode(X,L));var J;try{var he=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",X);J=he(i,y,A,e,s,f,p,qqn,Qqn,Hqn),s[0]=J}catch(be){throw i.logger.error("Error compiling schema, function code:",X),be}return J.schema=L,J.errors=null,J.refs=a,J.refVal=s,J.root=W?J:M,V&&(J.$async=!0),o.sourceCode===!0&&(J.source={code:X,patterns:c,defaults:f}),J}function N(L,M,j){M=Fme.url(L,M);var G=a[M],W,V;if(G!==void 0)return W=s[G],V="refVal["+G+"]",D(W,V);if(!j&&e.refs){var X=e.refs[M];if(X!==void 0)return W=e.refVal[X],V=P(M,W),D(W,V)}V=P(M);var J=Fme.call(i,T,e,M);if(J===void 0){var he=r&&r[M];he&&(J=Fme.inlineRef(he,o.inlineRefs)?he:Oqe.call(i,he,e,r,L))}if(J===void 0)U(M);else return Q(M,J),D(J,V)}function P(L,M){var j=s.length;return s[j]=M,a[L]=j,"refVal"+j}function U(L){delete a[L]}function Q(L,M){var j=a[L];s[j]=M}function D(L,M){return typeof L=="object"||typeof L=="boolean"?{code:M,schema:L,inline:!0}:{code:M,$async:L&&!!L.$async}}function F(L){var M=u[L];return M===void 0&&(M=u[L]=c.length,c[M]=L),"pattern"+M}function O(L){switch(typeof L){case"boolean":case"number":return""+L;case"string":return Qme.toQuotedString(L);case"object":if(L===null)return"null";var M=Uqn(L),j=d[M];return j===void 0&&(j=d[M]=f.length,f[j]=L),"default"+j}}function q(L,M,j,G){if(i._opts.validateSchema!==!1){var W=L.definition.dependencies;if(W&&!W.every(function(pe){return Object.prototype.hasOwnProperty.call(j,pe)}))throw new Error("parent schema must have all required keywords: "+W.join(","));var V=L.definition.validateSchema;if(V){var X=V(M);if(!X){var J="keyword schema is invalid: "+i.errorsText(V.errors);if(i._opts.validateSchema=="log")i.logger.error(J);else throw new Error(J)}}}var he=L.definition.compile,be=L.definition.inline,ge=L.definition.macro,_e;if(he)_e=he.call(i,M,j,G);else if(ge)_e=ge.call(i,M,j,G),o.validateSchema!==!1&&i.validateSchema(_e,!0);else if(be)_e=be.call(i,G,L.keyword,M,j);else if(_e=L.definition.validate,!_e)return;if(_e===void 0)throw new Error('custom keyword "'+L.keyword+'"failed to compile');var Se=p.length;return p[Se]=_e,{code:"customRule"+Se,validate:_e}}}function Gqn(t,e,r){var n=lQt.call(this,t,e,r);return n>=0?{index:n,compiling:!0}:(n=this._compilations.length,this._compilations[n]={schema:t,root:e,baseId:r},{index:n,compiling:!1})}function jqn(t,e,r){var n=lQt.call(this,t,e,r);n>=0&&this._compilations.splice(n,1)}function lQt(t,e,r){for(var n=0;n<this._compilations.length;n++){var i=this._compilations[n];if(i.schema==t&&i.root==e&&i.baseId==r)return n}return-1}function Vqn(t,e){return"var pattern"+t+" = new RegExp("+Qme.toQuotedString(e[t])+");"}function $qn(t){return"var default"+t+" = defaults["+t+"];"}function Wqn(t,e){return e[t]===void 0?"":"var refVal"+t+" = refVal["+t+"];"}function Yqn(t){return"var customRule"+t+" = customRules["+t+"];"}function Ume(t,e){if(!t.length)return"";for(var r="",n=0;n<t.length;n++)r+=e(n,t);return r}});var dQt=B((NMo,fQt)=>{"use strict";var qme=fQt.exports=function(){this._cache={}};qme.prototype.put=function(e,r){this._cache[e]=r};qme.prototype.get=function(e){return this._cache[e]};qme.prototype.del=function(e){delete this._cache[e]};qme.prototype.clear=function(){this._cache={}}});var SQt=B((OMo,_Qt)=>{"use strict";var zqn=lO(),Jqn=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Kqn=[0,31,28,31,30,31,30,31,31,30,31,30,31],Xqn=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,pQt=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,Zqn=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,eHn=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,hQt=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,mQt=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,gQt=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,AQt=/^(?:\/(?:[^~/]|~0|~1)*)*$/,yQt=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,EQt=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;_Qt.exports=Hme;function Hme(t){return t=t=="full"?"full":"fast",zqn.copy(Hme[t])}Hme.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":hQt,url:mQt,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,hostname:pQt,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:CQt,uuid:gQt,"json-pointer":AQt,"json-pointer-uri-fragment":yQt,"relative-json-pointer":EQt};Hme.full={date:vQt,time:bQt,"date-time":nHn,uri:oHn,"uri-reference":eHn,"uri-template":hQt,url:mQt,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:pQt,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:CQt,uuid:gQt,"json-pointer":AQt,"json-pointer-uri-fragment":yQt,"relative-json-pointer":EQt};function tHn(t){return t%4===0&&(t%100!==0||t%400===0)}function vQt(t){var e=t.match(Jqn);if(!e)return!1;var r=+e[1],n=+e[2],i=+e[3];return n>=1&&n<=12&&i>=1&&i<=(n==2&&tHn(r)?29:Kqn[n])}function bQt(t,e){var r=t.match(Xqn);if(!r)return!1;var n=r[1],i=r[2],o=r[3],s=r[5];return(n<=23&&i<=59&&o<=59||n==23&&i==59&&o==60)&&(!e||s)}var rHn=/t|\s/i;function nHn(t){var e=t.split(rHn);return e.length==2&&vQt(e[0])&&bQt(e[1],!0)}var iHn=/\/|:/;function oHn(t){return iHn.test(t)&&Zqn.test(t)}var sHn=/[^\\]\\Z/;function CQt(t){if(sHn.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var xQt=B((MMo,wQt)=>{"use strict";wQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.errSchemaPath+"/"+r,u=!e.opts.allErrors,f="data"+(s||""),d="valid"+o,p,h;if(a=="#"||a=="#/")e.isRoot?(p=e.async,h="validate"):(p=e.root.schema.$async===!0,h="root.refVal[0]");else{var g=e.resolveRef(e.baseId,a,e.isRoot);if(g===void 0){var A=e.MissingRefError.message(e.baseId,a);if(e.opts.missingRefs=="fail"){e.logger.error(A);var y=y||[];y.push(i),i="",e.createErrors!==!1?(i+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { ref: '"+e.util.escapeQuotes(a)+"' } ",e.opts.messages!==!1&&(i+=" , message: 'can\\'t resolve reference "+e.util.escapeQuotes(a)+"' "),e.opts.verbose&&(i+=" , schema: "+e.util.toQuotedString(a)+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+f+" "),i+=" } "):i+=" {} ";var v=i;i=y.pop(),!e.compositeRule&&u?e.async?i+=" throw new ValidationError(["+v+"]); ":i+=" validate.errors = ["+v+"]; return false; ":i+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",u&&(i+=" if (false) { ")}else if(e.opts.missingRefs=="ignore")e.logger.warn(A),u&&(i+=" if (true) { ");else throw new e.MissingRefError(e.baseId,a,A)}else if(g.inline){var S=e.util.copy(e);S.level++;var w="valid"+S.level;S.schema=g.schema,S.schemaPath="",S.errSchemaPath=a;var T=e.validate(S).replace(/validate\.schema/g,g.code);i+=" "+T+" ",u&&(i+=" if ("+w+") { ")}else p=g.$async===!0||e.async&&g.$async!==!1,h=g.code}if(h){var y=y||[];y.push(i),i="",e.opts.passContext?i+=" "+h+".call(this, ":i+=" "+h+"( ",i+=" "+f+", (dataPath || '')",e.errorPath!='""'&&(i+=" + "+e.errorPath);var N=s?"data"+(s-1||""):"parentData",P=s?e.dataPathArr[s]:"parentDataProperty";i+=" , "+N+" , "+P+", rootData) ";var U=i;if(i=y.pop(),p){if(!e.async)throw new Error("async schema referenced by sync schema");u&&(i+=" var "+d+"; "),i+=" try { await "+U+"; ",u&&(i+=" "+d+" = true; "),i+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",u&&(i+=" "+d+" = false; "),i+=" } ",u&&(i+=" if ("+d+") { ")}else i+=" if (!"+U+") { if (vErrors === null) vErrors = "+h+".errors; else vErrors = vErrors.concat("+h+".errors); errors = vErrors.length; } ",u&&(i+=" else { ")}return i}});var DQt=B((kMo,TQt)=>{"use strict";TQt.exports=function(e,r,n){var i=" ",o=e.schema[r],s=e.schemaPath+e.util.getProperty(r),a=e.errSchemaPath+"/"+r,c=!e.opts.allErrors,u=e.util.copy(e),f="";u.level++;var d="valid"+u.level,p=u.baseId,h=!0,g=o;if(g)for(var A,y=-1,v=g.length-1;y<v;)A=g[y+=1],(e.opts.strictKeywords?typeof A=="object"&&Object.keys(A).length>0||A===!1:e.util.schemaHasRules(A,e.RULES.all))&&(h=!1,u.schema=A,u.schemaPath=s+"["+y+"]",u.errSchemaPath=a+"/"+y,i+=" "+e.validate(u)+" ",u.baseId=p,c&&(i+=" if ("+d+") { ",f+="}"));return c&&(h?i+=" if (true) { ":i+=" "+f.slice(0,-1)+" "),i}});var RQt=B((LMo,IQt)=>{"use strict";IQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="valid"+o,h="errs__"+o,g=e.util.copy(e),A="";g.level++;var y="valid"+g.level,v=a.every(function(Q){return e.opts.strictKeywords?typeof Q=="object"&&Object.keys(Q).length>0||Q===!1:e.util.schemaHasRules(Q,e.RULES.all)});if(v){var S=g.baseId;i+=" var "+h+" = errors; var "+p+" = false; ";var w=e.compositeRule;e.compositeRule=g.compositeRule=!0;var T=a;if(T)for(var N,P=-1,U=T.length-1;P<U;)N=T[P+=1],g.schema=N,g.schemaPath=c+"["+P+"]",g.errSchemaPath=u+"/"+P,i+=" "+e.validate(g)+" ",g.baseId=S,i+=" "+p+" = "+p+" || "+y+"; if (!"+p+") { ",A+="}";e.compositeRule=g.compositeRule=w,i+=" "+A+" if (!"+p+") { var err = ",e.createErrors!==!1?(i+=" { keyword: 'anyOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: {} ",e.opts.messages!==!1&&(i+=" , message: 'should match some schema in anyOf' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&f&&(e.async?i+=" throw new ValidationError(vErrors); ":i+=" validate.errors = vErrors; return false; "),i+=" } else { errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } ",e.opts.allErrors&&(i+=" } ")}else f&&(i+=" if (true) { ");return i}});var NQt=B((PMo,BQt)=>{"use strict";BQt.exports=function(e,r,n){var i=" ",o=e.schema[r],s=e.errSchemaPath+"/"+r,a=!e.opts.allErrors,c=e.util.toQuotedString(o);return e.opts.$comment===!0?i+=" console.log("+c+");":typeof e.opts.$comment=="function"&&(i+=" self._opts.$comment("+c+", "+e.util.toQuotedString(s)+", validate.root.schema);"),i}});var MQt=B((FMo,OQt)=>{"use strict";OQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="valid"+o,h=e.opts.$data&&a&&a.$data,g;h?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",g="schema"+o):g=a,h||(i+=" var schema"+o+" = validate.schema"+c+";"),i+="var "+p+" = equal("+d+", schema"+o+"); if (!"+p+") { ";var A=A||[];A.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'const' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { allowedValue: schema"+o+" } ",e.opts.messages!==!1&&(i+=" , message: 'should be equal to constant' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var y=i;return i=A.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+y+"]); ":i+=" validate.errors = ["+y+"]; return false; ":i+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" }",f&&(i+=" else { "),i}});var LQt=B((UMo,kQt)=>{"use strict";kQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="valid"+o,h="errs__"+o,g=e.util.copy(e),A="";g.level++;var y="valid"+g.level,v="i"+o,S=g.dataLevel=e.dataLevel+1,w="data"+S,T=e.baseId,N=e.opts.strictKeywords?typeof a=="object"&&Object.keys(a).length>0||a===!1:e.util.schemaHasRules(a,e.RULES.all);if(i+="var "+h+" = errors;var "+p+";",N){var P=e.compositeRule;e.compositeRule=g.compositeRule=!0,g.schema=a,g.schemaPath=c,g.errSchemaPath=u,i+=" var "+y+" = false; for (var "+v+" = 0; "+v+" < "+d+".length; "+v+"++) { ",g.errorPath=e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers,!0);var U=d+"["+v+"]";g.dataPathArr[S]=v;var Q=e.validate(g);g.baseId=T,e.util.varOccurences(Q,w)<2?i+=" "+e.util.varReplace(Q,w,U)+" ":i+=" var "+w+" = "+U+"; "+Q+" ",i+=" if ("+y+") break; } ",e.compositeRule=g.compositeRule=P,i+=" "+A+" if (!"+y+") {"}else i+=" if ("+d+".length == 0) {";var D=D||[];D.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: {} ",e.opts.messages!==!1&&(i+=" , message: 'should contain a valid item' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var F=i;return i=D.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+F+"]); ":i+=" validate.errors = ["+F+"]; return false; ":i+=" var err = "+F+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } else { ",N&&(i+=" errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } "),e.opts.allErrors&&(i+=" } "),i}});var FQt=B((QMo,PQt)=>{"use strict";PQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="errs__"+o,h=e.util.copy(e),g="";h.level++;var A="valid"+h.level,y={},v={},S=e.opts.ownProperties;for(P in a)if(P!="__proto__"){var w=a[P],T=Array.isArray(w)?v:y;T[P]=w}i+="var "+p+" = errors;";var N=e.errorPath;i+="var missing"+o+";";for(var P in v)if(T=v[P],T.length){if(i+=" if ( "+d+e.util.getProperty(P)+" !== undefined ",S&&(i+=" && Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(P)+"') "),f){i+=" && ( ";var U=T;if(U)for(var Q,D=-1,F=U.length-1;D<F;){Q=U[D+=1],D&&(i+=" || ");var O=e.util.getProperty(Q),q=d+O;i+=" ( ( "+q+" === undefined ",S&&(i+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(Q)+"') "),i+=") && (missing"+o+" = "+e.util.toQuotedString(e.opts.jsonPointers?Q:O)+") ) "}i+=")) { ";var L="missing"+o,M="' + "+L+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(N,L,!0):N+" + "+L);var j=j||[];j.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { property: '"+e.util.escapeQuotes(P)+"', missingProperty: '"+M+"', depsCount: "+T.length+", deps: '"+e.util.escapeQuotes(T.length==1?T[0]:T.join(", "))+"' } ",e.opts.messages!==!1&&(i+=" , message: 'should have ",T.length==1?i+="property "+e.util.escapeQuotes(T[0]):i+="properties "+e.util.escapeQuotes(T.join(", ")),i+=" when property "+e.util.escapeQuotes(P)+" is present' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var G=i;i=j.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+G+"]); ":i+=" validate.errors = ["+G+"]; return false; ":i+=" var err = "+G+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else{i+=" ) { ";var W=T;if(W)for(var Q,V=-1,X=W.length-1;V<X;){Q=W[V+=1];var O=e.util.getProperty(Q),M=e.util.escapeQuotes(Q),q=d+O;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(N,Q,e.opts.jsonPointers)),i+=" if ( "+q+" === undefined ",S&&(i+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(Q)+"') "),i+=") { var err = ",e.createErrors!==!1?(i+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { property: '"+e.util.escapeQuotes(P)+"', missingProperty: '"+M+"', depsCount: "+T.length+", deps: '"+e.util.escapeQuotes(T.length==1?T[0]:T.join(", "))+"' } ",e.opts.messages!==!1&&(i+=" , message: 'should have ",T.length==1?i+="property "+e.util.escapeQuotes(T[0]):i+="properties "+e.util.escapeQuotes(T.join(", ")),i+=" when property "+e.util.escapeQuotes(P)+" is present' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}i+=" } ",f&&(g+="}",i+=" else { ")}e.errorPath=N;var J=h.baseId;for(var P in y){var w=y[P];(e.opts.strictKeywords?typeof w=="object"&&Object.keys(w).length>0||w===!1:e.util.schemaHasRules(w,e.RULES.all))&&(i+=" "+A+" = true; if ( "+d+e.util.getProperty(P)+" !== undefined ",S&&(i+=" && Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(P)+"') "),i+=") { ",h.schema=w,h.schemaPath=c+e.util.getProperty(P),h.errSchemaPath=u+"/"+e.util.escapeFragment(P),i+=" "+e.validate(h)+" ",h.baseId=J,i+=" } ",f&&(i+=" if ("+A+") { ",g+="}"))}return f&&(i+=" "+g+" if ("+p+" == errors) {"),i}});var QQt=B((qMo,UQt)=>{"use strict";UQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="valid"+o,h=e.opts.$data&&a&&a.$data,g;h?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",g="schema"+o):g=a;var A="i"+o,y="schema"+o;h||(i+=" var "+y+" = validate.schema"+c+";"),i+="var "+p+";",h&&(i+=" if (schema"+o+" === undefined) "+p+" = true; else if (!Array.isArray(schema"+o+")) "+p+" = false; else {"),i+=""+p+" = false;for (var "+A+"=0; "+A+"<"+y+".length; "+A+"++) if (equal("+d+", "+y+"["+A+"])) { "+p+" = true; break; }",h&&(i+=" } "),i+=" if (!"+p+") { ";var v=v||[];v.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { allowedValues: schema"+o+" } ",e.opts.messages!==!1&&(i+=" , message: 'should be equal to one of the allowed values' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var S=i;return i=v.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+S+"]); ":i+=" validate.errors = ["+S+"]; return false; ":i+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" }",f&&(i+=" else { "),i}});var HQt=B((HMo,qQt)=>{"use strict";qQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||"");if(e.opts.format===!1)return f&&(i+=" if (true) { "),i;var p=e.opts.$data&&a&&a.$data,h;p?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",h="schema"+o):h=a;var g=e.opts.unknownFormats,A=Array.isArray(g);if(p){var y="format"+o,v="isObject"+o,S="formatType"+o;i+=" var "+y+" = formats["+h+"]; var "+v+" = typeof "+y+" == 'object' && !("+y+" instanceof RegExp) && "+y+".validate; var "+S+" = "+v+" && "+y+".type || 'string'; if ("+v+") { ",e.async&&(i+=" var async"+o+" = "+y+".async; "),i+=" "+y+" = "+y+".validate; } if ( ",p&&(i+=" ("+h+" !== undefined && typeof "+h+" != 'string') || "),i+=" (",g!="ignore"&&(i+=" ("+h+" && !"+y+" ",A&&(i+=" && self._opts.unknownFormats.indexOf("+h+") == -1 "),i+=") || "),i+=" ("+y+" && "+S+" == '"+n+"' && !(typeof "+y+" == 'function' ? ",e.async?i+=" (async"+o+" ? await "+y+"("+d+") : "+y+"("+d+")) ":i+=" "+y+"("+d+") ",i+=" : "+y+".test("+d+"))))) {"}else{var y=e.formats[a];if(!y){if(g=="ignore")return e.logger.warn('unknown format "'+a+'" ignored in schema at path "'+e.errSchemaPath+'"'),f&&(i+=" if (true) { "),i;if(A&&g.indexOf(a)>=0)return f&&(i+=" if (true) { "),i;throw new Error('unknown format "'+a+'" is used in schema at path "'+e.errSchemaPath+'"')}var v=typeof y=="object"&&!(y instanceof RegExp)&&y.validate,S=v&&y.type||"string";if(v){var w=y.async===!0;y=y.validate}if(S!=n)return f&&(i+=" if (true) { "),i;if(w){if(!e.async)throw new Error("async format in sync schema");var T="formats"+e.util.getProperty(a)+".validate";i+=" if (!(await "+T+"("+d+"))) { "}else{i+=" if (! ";var T="formats"+e.util.getProperty(a);v&&(T+=".validate"),typeof y=="function"?i+=" "+T+"("+d+") ":i+=" "+T+".test("+d+") ",i+=") { "}}var N=N||[];N.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'format' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { format: ",p?i+=""+h:i+=""+e.util.toQuotedString(a),i+=" } ",e.opts.messages!==!1&&(i+=` , message: 'should match format "`,p?i+="' + "+h+" + '":i+=""+e.util.escapeQuotes(a),i+=`"' `),e.opts.verbose&&(i+=" , schema: ",p?i+="validate.schema"+c:i+=""+e.util.toQuotedString(a),i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var P=i;return i=N.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+P+"]); ":i+=" validate.errors = ["+P+"]; return false; ":i+=" var err = "+P+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } ",f&&(i+=" else { "),i}});var jQt=B((GMo,GQt)=>{"use strict";GQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="valid"+o,h="errs__"+o,g=e.util.copy(e);g.level++;var A="valid"+g.level,y=e.schema.then,v=e.schema.else,S=y!==void 0&&(e.opts.strictKeywords?typeof y=="object"&&Object.keys(y).length>0||y===!1:e.util.schemaHasRules(y,e.RULES.all)),w=v!==void 0&&(e.opts.strictKeywords?typeof v=="object"&&Object.keys(v).length>0||v===!1:e.util.schemaHasRules(v,e.RULES.all)),T=g.baseId;if(S||w){var N;g.createErrors=!1,g.schema=a,g.schemaPath=c,g.errSchemaPath=u,i+=" var "+h+" = errors; var "+p+" = true; ";var P=e.compositeRule;e.compositeRule=g.compositeRule=!0,i+=" "+e.validate(g)+" ",g.baseId=T,g.createErrors=!0,i+=" errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } ",e.compositeRule=g.compositeRule=P,S?(i+=" if ("+A+") { ",g.schema=e.schema.then,g.schemaPath=e.schemaPath+".then",g.errSchemaPath=e.errSchemaPath+"/then",i+=" "+e.validate(g)+" ",g.baseId=T,i+=" "+p+" = "+A+"; ",S&&w?(N="ifClause"+o,i+=" var "+N+" = 'then'; "):N="'then'",i+=" } ",w&&(i+=" else { ")):i+=" if (!"+A+") { ",w&&(g.schema=e.schema.else,g.schemaPath=e.schemaPath+".else",g.errSchemaPath=e.errSchemaPath+"/else",i+=" "+e.validate(g)+" ",g.baseId=T,i+=" "+p+" = "+A+"; ",S&&w?(N="ifClause"+o,i+=" var "+N+" = 'else'; "):N="'else'",i+=" } "),i+=" if (!"+p+") { var err = ",e.createErrors!==!1?(i+=" { keyword: 'if' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { failingKeyword: "+N+" } ",e.opts.messages!==!1&&(i+=` , message: 'should match "' + `+N+` + '" schema' `),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&f&&(e.async?i+=" throw new ValidationError(vErrors); ":i+=" validate.errors = vErrors; return false; "),i+=" } ",f&&(i+=" else { ")}else f&&(i+=" if (true) { ");return i}});var $Qt=B((jMo,VQt)=>{"use strict";VQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="valid"+o,h="errs__"+o,g=e.util.copy(e),A="";g.level++;var y="valid"+g.level,v="i"+o,S=g.dataLevel=e.dataLevel+1,w="data"+S,T=e.baseId;if(i+="var "+h+" = errors;var "+p+";",Array.isArray(a)){var N=e.schema.additionalItems;if(N===!1){i+=" "+p+" = "+d+".length <= "+a.length+"; ";var P=u;u=e.errSchemaPath+"/additionalItems",i+=" if (!"+p+") { ";var U=U||[];U.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { limit: "+a.length+" } ",e.opts.messages!==!1&&(i+=" , message: 'should NOT have more than "+a.length+" items' "),e.opts.verbose&&(i+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var Q=i;i=U.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+Q+"]); ":i+=" validate.errors = ["+Q+"]; return false; ":i+=" var err = "+Q+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } ",u=P,f&&(A+="}",i+=" else { ")}var D=a;if(D){for(var F,O=-1,q=D.length-1;O<q;)if(F=D[O+=1],e.opts.strictKeywords?typeof F=="object"&&Object.keys(F).length>0||F===!1:e.util.schemaHasRules(F,e.RULES.all)){i+=" "+y+" = true; if ("+d+".length > "+O+") { ";var L=d+"["+O+"]";g.schema=F,g.schemaPath=c+"["+O+"]",g.errSchemaPath=u+"/"+O,g.errorPath=e.util.getPathExpr(e.errorPath,O,e.opts.jsonPointers,!0),g.dataPathArr[S]=O;var M=e.validate(g);g.baseId=T,e.util.varOccurences(M,w)<2?i+=" "+e.util.varReplace(M,w,L)+" ":i+=" var "+w+" = "+L+"; "+M+" ",i+=" } ",f&&(i+=" if ("+y+") { ",A+="}")}}if(typeof N=="object"&&(e.opts.strictKeywords?typeof N=="object"&&Object.keys(N).length>0||N===!1:e.util.schemaHasRules(N,e.RULES.all))){g.schema=N,g.schemaPath=e.schemaPath+".additionalItems",g.errSchemaPath=e.errSchemaPath+"/additionalItems",i+=" "+y+" = true; if ("+d+".length > "+a.length+") { for (var "+v+" = "+a.length+"; "+v+" < "+d+".length; "+v+"++) { ",g.errorPath=e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers,!0);var L=d+"["+v+"]";g.dataPathArr[S]=v;var M=e.validate(g);g.baseId=T,e.util.varOccurences(M,w)<2?i+=" "+e.util.varReplace(M,w,L)+" ":i+=" var "+w+" = "+L+"; "+M+" ",f&&(i+=" if (!"+y+") break; "),i+=" } } ",f&&(i+=" if ("+y+") { ",A+="}")}}else if(e.opts.strictKeywords?typeof a=="object"&&Object.keys(a).length>0||a===!1:e.util.schemaHasRules(a,e.RULES.all)){g.schema=a,g.schemaPath=c,g.errSchemaPath=u,i+=" for (var "+v+" = 0; "+v+" < "+d+".length; "+v+"++) { ",g.errorPath=e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers,!0);var L=d+"["+v+"]";g.dataPathArr[S]=v;var M=e.validate(g);g.baseId=T,e.util.varOccurences(M,w)<2?i+=" "+e.util.varReplace(M,w,L)+" ":i+=" var "+w+" = "+L+"; "+M+" ",f&&(i+=" if (!"+y+") break; "),i+=" }"}return f&&(i+=" "+A+" if ("+h+" == errors) {"),i}});var Mqe=B((VMo,WQt)=>{"use strict";WQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,T,d="data"+(s||""),p=e.opts.$data&&a&&a.$data,h;p?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",h="schema"+o):h=a;var g=r=="maximum",A=g?"exclusiveMaximum":"exclusiveMinimum",y=e.schema[A],v=e.opts.$data&&y&&y.$data,S=g?"<":">",w=g?">":"<",T=void 0;if(!(p||typeof a=="number"||a===void 0))throw new Error(r+" must be number");if(!(v||y===void 0||typeof y=="number"||typeof y=="boolean"))throw new Error(A+" must be number or boolean");if(v){var N=e.util.getData(y.$data,s,e.dataPathArr),P="exclusive"+o,U="exclType"+o,Q="exclIsNumber"+o,D="op"+o,F="' + "+D+" + '";i+=" var schemaExcl"+o+" = "+N+"; ",N="schemaExcl"+o,i+=" var "+P+"; var "+U+" = typeof "+N+"; if ("+U+" != 'boolean' && "+U+" != 'undefined' && "+U+" != 'number') { ";var T=A,O=O||[];O.push(i),i="",e.createErrors!==!1?(i+=" { keyword: '"+(T||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: {} ",e.opts.messages!==!1&&(i+=" , message: '"+A+" should be boolean' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var q=i;i=O.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+q+"]); ":i+=" validate.errors = ["+q+"]; return false; ":i+=" var err = "+q+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } else if ( ",p&&(i+=" ("+h+" !== undefined && typeof "+h+" != 'number') || "),i+=" "+U+" == 'number' ? ( ("+P+" = "+h+" === undefined || "+N+" "+S+"= "+h+") ? "+d+" "+w+"= "+N+" : "+d+" "+w+" "+h+" ) : ( ("+P+" = "+N+" === true) ? "+d+" "+w+"= "+h+" : "+d+" "+w+" "+h+" ) || "+d+" !== "+d+") { var op"+o+" = "+P+" ? '"+S+"' : '"+S+"='; ",a===void 0&&(T=A,u=e.errSchemaPath+"/"+A,h=N,p=v)}else{var Q=typeof y=="number",F=S;if(Q&&p){var D="'"+F+"'";i+=" if ( ",p&&(i+=" ("+h+" !== undefined && typeof "+h+" != 'number') || "),i+=" ( "+h+" === undefined || "+y+" "+S+"= "+h+" ? "+d+" "+w+"= "+y+" : "+d+" "+w+" "+h+" ) || "+d+" !== "+d+") { "}else{Q&&a===void 0?(P=!0,T=A,u=e.errSchemaPath+"/"+A,h=y,w+="="):(Q&&(h=Math[g?"min":"max"](y,a)),y===(Q?h:!0)?(P=!0,T=A,u=e.errSchemaPath+"/"+A,w+="="):(P=!1,F+="="));var D="'"+F+"'";i+=" if ( ",p&&(i+=" ("+h+" !== undefined && typeof "+h+" != 'number') || "),i+=" "+d+" "+w+" "+h+" || "+d+" !== "+d+") { "}}T=T||r;var O=O||[];O.push(i),i="",e.createErrors!==!1?(i+=" { keyword: '"+(T||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { comparison: "+D+", limit: "+h+", exclusive: "+P+" } ",e.opts.messages!==!1&&(i+=" , message: 'should be "+F+" ",p?i+="' + "+h:i+=""+h+"'"),e.opts.verbose&&(i+=" , schema: ",p?i+="validate.schema"+c:i+=""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var q=i;return i=O.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+q+"]); ":i+=" validate.errors = ["+q+"]; return false; ":i+=" var err = "+q+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } ",f&&(i+=" else { "),i}});var kqe=B(($Mo,YQt)=>{"use strict";YQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,A,d="data"+(s||""),p=e.opts.$data&&a&&a.$data,h;if(p?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",h="schema"+o):h=a,!(p||typeof a=="number"))throw new Error(r+" must be number");var g=r=="maxItems"?">":"<";i+="if ( ",p&&(i+=" ("+h+" !== undefined && typeof "+h+" != 'number') || "),i+=" "+d+".length "+g+" "+h+") { ";var A=r,y=y||[];y.push(i),i="",e.createErrors!==!1?(i+=" { keyword: '"+(A||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { limit: "+h+" } ",e.opts.messages!==!1&&(i+=" , message: 'should NOT have ",r=="maxItems"?i+="more":i+="fewer",i+=" than ",p?i+="' + "+h+" + '":i+=""+a,i+=" items' "),e.opts.verbose&&(i+=" , schema: ",p?i+="validate.schema"+c:i+=""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var v=i;return i=y.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+v+"]); ":i+=" validate.errors = ["+v+"]; return false; ":i+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+="} ",f&&(i+=" else { "),i}});var Lqe=B((WMo,zQt)=>{"use strict";zQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,A,d="data"+(s||""),p=e.opts.$data&&a&&a.$data,h;if(p?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",h="schema"+o):h=a,!(p||typeof a=="number"))throw new Error(r+" must be number");var g=r=="maxLength"?">":"<";i+="if ( ",p&&(i+=" ("+h+" !== undefined && typeof "+h+" != 'number') || "),e.opts.unicode===!1?i+=" "+d+".length ":i+=" ucs2length("+d+") ",i+=" "+g+" "+h+") { ";var A=r,y=y||[];y.push(i),i="",e.createErrors!==!1?(i+=" { keyword: '"+(A||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { limit: "+h+" } ",e.opts.messages!==!1&&(i+=" , message: 'should NOT be ",r=="maxLength"?i+="longer":i+="shorter",i+=" than ",p?i+="' + "+h+" + '":i+=""+a,i+=" characters' "),e.opts.verbose&&(i+=" , schema: ",p?i+="validate.schema"+c:i+=""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var v=i;return i=y.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+v+"]); ":i+=" validate.errors = ["+v+"]; return false; ":i+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+="} ",f&&(i+=" else { "),i}});var Pqe=B((YMo,JQt)=>{"use strict";JQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,A,d="data"+(s||""),p=e.opts.$data&&a&&a.$data,h;if(p?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",h="schema"+o):h=a,!(p||typeof a=="number"))throw new Error(r+" must be number");var g=r=="maxProperties"?">":"<";i+="if ( ",p&&(i+=" ("+h+" !== undefined && typeof "+h+" != 'number') || "),i+=" Object.keys("+d+").length "+g+" "+h+") { ";var A=r,y=y||[];y.push(i),i="",e.createErrors!==!1?(i+=" { keyword: '"+(A||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { limit: "+h+" } ",e.opts.messages!==!1&&(i+=" , message: 'should NOT have ",r=="maxProperties"?i+="more":i+="fewer",i+=" than ",p?i+="' + "+h+" + '":i+=""+a,i+=" properties' "),e.opts.verbose&&(i+=" , schema: ",p?i+="validate.schema"+c:i+=""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var v=i;return i=y.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+v+"]); ":i+=" validate.errors = ["+v+"]; return false; ":i+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+="} ",f&&(i+=" else { "),i}});var XQt=B((zMo,KQt)=>{"use strict";KQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p=e.opts.$data&&a&&a.$data,h;if(p?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",h="schema"+o):h=a,!(p||typeof a=="number"))throw new Error(r+" must be number");i+="var division"+o+";if (",p&&(i+=" "+h+" !== undefined && ( typeof "+h+" != 'number' || "),i+=" (division"+o+" = "+d+" / "+h+", ",e.opts.multipleOfPrecision?i+=" Math.abs(Math.round(division"+o+") - division"+o+") > 1e-"+e.opts.multipleOfPrecision+" ":i+=" division"+o+" !== parseInt(division"+o+") ",i+=" ) ",p&&(i+=" ) "),i+=" ) { ";var g=g||[];g.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { multipleOf: "+h+" } ",e.opts.messages!==!1&&(i+=" , message: 'should be multiple of ",p?i+="' + "+h:i+=""+h+"'"),e.opts.verbose&&(i+=" , schema: ",p?i+="validate.schema"+c:i+=""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var A=i;return i=g.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+A+"]); ":i+=" validate.errors = ["+A+"]; return false; ":i+=" var err = "+A+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+="} ",f&&(i+=" else { "),i}});var eqt=B((JMo,ZQt)=>{"use strict";ZQt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="errs__"+o,h=e.util.copy(e);h.level++;var g="valid"+h.level;if(e.opts.strictKeywords?typeof a=="object"&&Object.keys(a).length>0||a===!1:e.util.schemaHasRules(a,e.RULES.all)){h.schema=a,h.schemaPath=c,h.errSchemaPath=u,i+=" var "+p+" = errors; ";var A=e.compositeRule;e.compositeRule=h.compositeRule=!0,h.createErrors=!1;var y;h.opts.allErrors&&(y=h.opts.allErrors,h.opts.allErrors=!1),i+=" "+e.validate(h)+" ",h.createErrors=!0,y&&(h.opts.allErrors=y),e.compositeRule=h.compositeRule=A,i+=" if ("+g+") { ";var v=v||[];v.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: {} ",e.opts.messages!==!1&&(i+=" , message: 'should NOT be valid' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var S=i;i=v.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+S+"]); ":i+=" validate.errors = ["+S+"]; return false; ":i+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } else { errors = "+p+"; if (vErrors !== null) { if ("+p+") vErrors.length = "+p+"; else vErrors = null; } ",e.opts.allErrors&&(i+=" } ")}else i+=" var err = ",e.createErrors!==!1?(i+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: {} ",e.opts.messages!==!1&&(i+=" , message: 'should NOT be valid' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",f&&(i+=" if (false) { ");return i}});var rqt=B((KMo,tqt)=>{"use strict";tqt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="valid"+o,h="errs__"+o,g=e.util.copy(e),A="";g.level++;var y="valid"+g.level,v=g.baseId,S="prevValid"+o,w="passingSchemas"+o;i+="var "+h+" = errors , "+S+" = false , "+p+" = false , "+w+" = null; ";var T=e.compositeRule;e.compositeRule=g.compositeRule=!0;var N=a;if(N)for(var P,U=-1,Q=N.length-1;U<Q;)P=N[U+=1],(e.opts.strictKeywords?typeof P=="object"&&Object.keys(P).length>0||P===!1:e.util.schemaHasRules(P,e.RULES.all))?(g.schema=P,g.schemaPath=c+"["+U+"]",g.errSchemaPath=u+"/"+U,i+=" "+e.validate(g)+" ",g.baseId=v):i+=" var "+y+" = true; ",U&&(i+=" if ("+y+" && "+S+") { "+p+" = false; "+w+" = ["+w+", "+U+"]; } else { ",A+="}"),i+=" if ("+y+") { "+p+" = "+S+" = true; "+w+" = "+U+"; }";return e.compositeRule=g.compositeRule=T,i+=""+A+"if (!"+p+") { var err = ",e.createErrors!==!1?(i+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { passingSchemas: "+w+" } ",e.opts.messages!==!1&&(i+=" , message: 'should match exactly one schema in oneOf' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&f&&(e.async?i+=" throw new ValidationError(vErrors); ":i+=" validate.errors = vErrors; return false; "),i+="} else { errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; }",e.opts.allErrors&&(i+=" } "),i}});var iqt=B((XMo,nqt)=>{"use strict";nqt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p=e.opts.$data&&a&&a.$data,h;p?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",h="schema"+o):h=a;var g=p?"(new RegExp("+h+"))":e.usePattern(a);i+="if ( ",p&&(i+=" ("+h+" !== undefined && typeof "+h+" != 'string') || "),i+=" !"+g+".test("+d+") ) { ";var A=A||[];A.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { pattern: ",p?i+=""+h:i+=""+e.util.toQuotedString(a),i+=" } ",e.opts.messages!==!1&&(i+=` , message: 'should match pattern "`,p?i+="' + "+h+" + '":i+=""+e.util.escapeQuotes(a),i+=`"' `),e.opts.verbose&&(i+=" , schema: ",p?i+="validate.schema"+c:i+=""+e.util.toQuotedString(a),i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var y=i;return i=A.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+y+"]); ":i+=" validate.errors = ["+y+"]; return false; ":i+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+="} ",f&&(i+=" else { "),i}});var sqt=B((ZMo,oqt)=>{"use strict";oqt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="errs__"+o,h=e.util.copy(e),g="";h.level++;var A="valid"+h.level,y="key"+o,v="idx"+o,S=h.dataLevel=e.dataLevel+1,w="data"+S,T="dataProperties"+o,N=Object.keys(a||{}).filter(V),P=e.schema.patternProperties||{},U=Object.keys(P).filter(V),Q=e.schema.additionalProperties,D=N.length||U.length,F=Q===!1,O=typeof Q=="object"&&Object.keys(Q).length,q=e.opts.removeAdditional,L=F||O||q,M=e.opts.ownProperties,j=e.baseId,G=e.schema.required;if(G&&!(e.opts.$data&&G.$data)&&G.length<e.opts.loopRequired)var W=e.util.toHash(G);function V(Le){return Le!=="__proto__"}if(i+="var "+p+" = errors;var "+A+" = true;",M&&(i+=" var "+T+" = undefined;"),L){if(M?i+=" "+T+" = "+T+" || Object.keys("+d+"); for (var "+v+"=0; "+v+"<"+T+".length; "+v+"++) { var "+y+" = "+T+"["+v+"]; ":i+=" for (var "+y+" in "+d+") { ",D){if(i+=" var isAdditional"+o+" = !(false ",N.length)if(N.length>8)i+=" || validate.schema"+c+".hasOwnProperty("+y+") ";else{var X=N;if(X)for(var J,he=-1,be=X.length-1;he<be;)J=X[he+=1],i+=" || "+y+" == "+e.util.toQuotedString(J)+" "}if(U.length){var ge=U;if(ge)for(var _e,Se=-1,pe=ge.length-1;Se<pe;)_e=ge[Se+=1],i+=" || "+e.usePattern(_e)+".test("+y+") "}i+=" ); if (isAdditional"+o+") { "}if(q=="all")i+=" delete "+d+"["+y+"]; ";else{var Ae=e.errorPath,ae="' + "+y+" + '";if(e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(e.errorPath,y,e.opts.jsonPointers)),F)if(q)i+=" delete "+d+"["+y+"]; ";else{i+=" "+A+" = false; ";var ie=u;u=e.errSchemaPath+"/additionalProperties";var de=de||[];de.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'additionalProperties' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { additionalProperty: '"+ae+"' } ",e.opts.messages!==!1&&(i+=" , message: '",e.opts._errorDataPathProperty?i+="is an invalid additional property":i+="should NOT have additional properties",i+="' "),e.opts.verbose&&(i+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var te=i;i=de.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+te+"]); ":i+=" validate.errors = ["+te+"]; return false; ":i+=" var err = "+te+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",u=ie,f&&(i+=" break; ")}else if(O)if(q=="failing"){i+=" var "+p+" = errors; ";var oe=e.compositeRule;e.compositeRule=h.compositeRule=!0,h.schema=Q,h.schemaPath=e.schemaPath+".additionalProperties",h.errSchemaPath=e.errSchemaPath+"/additionalProperties",h.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,y,e.opts.jsonPointers);var me=d+"["+y+"]";h.dataPathArr[S]=y;var ue=e.validate(h);h.baseId=j,e.util.varOccurences(ue,w)<2?i+=" "+e.util.varReplace(ue,w,me)+" ":i+=" var "+w+" = "+me+"; "+ue+" ",i+=" if (!"+A+") { errors = "+p+"; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete "+d+"["+y+"]; } ",e.compositeRule=h.compositeRule=oe}else{h.schema=Q,h.schemaPath=e.schemaPath+".additionalProperties",h.errSchemaPath=e.errSchemaPath+"/additionalProperties",h.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,y,e.opts.jsonPointers);var me=d+"["+y+"]";h.dataPathArr[S]=y;var ue=e.validate(h);h.baseId=j,e.util.varOccurences(ue,w)<2?i+=" "+e.util.varReplace(ue,w,me)+" ":i+=" var "+w+" = "+me+"; "+ue+" ",f&&(i+=" if (!"+A+") break; ")}e.errorPath=Ae}D&&(i+=" } "),i+=" } ",f&&(i+=" if ("+A+") { ",g+="}")}var K=e.opts.useDefaults&&!e.compositeRule;if(N.length){var re=N;if(re)for(var J,xe=-1,ye=re.length-1;xe<ye;){J=re[xe+=1];var Z=a[J];if(e.opts.strictKeywords?typeof Z=="object"&&Object.keys(Z).length>0||Z===!1:e.util.schemaHasRules(Z,e.RULES.all)){var Ne=e.util.getProperty(J),me=d+Ne,Qe=K&&Z.default!==void 0;h.schema=Z,h.schemaPath=c+Ne,h.errSchemaPath=u+"/"+e.util.escapeFragment(J),h.errorPath=e.util.getPath(e.errorPath,J,e.opts.jsonPointers),h.dataPathArr[S]=e.util.toQuotedString(J);var ue=e.validate(h);if(h.baseId=j,e.util.varOccurences(ue,w)<2){ue=e.util.varReplace(ue,w,me);var qe=me}else{var qe=w;i+=" var "+w+" = "+me+"; "}if(Qe)i+=" "+ue+" ";else{if(W&&W[J]){i+=" if ( "+qe+" === undefined ",M&&(i+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(J)+"') "),i+=") { "+A+" = false; ";var Ae=e.errorPath,ie=u,He=e.util.escapeQuotes(J);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(Ae,J,e.opts.jsonPointers)),u=e.errSchemaPath+"/required";var de=de||[];de.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+He+"' } ",e.opts.messages!==!1&&(i+=" , message: '",e.opts._errorDataPathProperty?i+="is a required property":i+="should have required property \\'"+He+"\\'",i+="' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var te=i;i=de.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+te+"]); ":i+=" validate.errors = ["+te+"]; return false; ":i+=" var err = "+te+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",u=ie,e.errorPath=Ae,i+=" } else { "}else f?(i+=" if ( "+qe+" === undefined ",M&&(i+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(J)+"') "),i+=") { "+A+" = true; } else { "):(i+=" if ("+qe+" !== undefined ",M&&(i+=" && Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(J)+"') "),i+=" ) { ");i+=" "+ue+" } "}}f&&(i+=" if ("+A+") { ",g+="}")}}if(U.length){var le=U;if(le)for(var _e,Ie=-1,Oe=le.length-1;Ie<Oe;){_e=le[Ie+=1];var Z=P[_e];if(e.opts.strictKeywords?typeof Z=="object"&&Object.keys(Z).length>0||Z===!1:e.util.schemaHasRules(Z,e.RULES.all)){h.schema=Z,h.schemaPath=e.schemaPath+".patternProperties"+e.util.getProperty(_e),h.errSchemaPath=e.errSchemaPath+"/patternProperties/"+e.util.escapeFragment(_e),M?i+=" "+T+" = "+T+" || Object.keys("+d+"); for (var "+v+"=0; "+v+"<"+T+".length; "+v+"++) { var "+y+" = "+T+"["+v+"]; ":i+=" for (var "+y+" in "+d+") { ",i+=" if ("+e.usePattern(_e)+".test("+y+")) { ",h.errorPath=e.util.getPathExpr(e.errorPath,y,e.opts.jsonPointers);var me=d+"["+y+"]";h.dataPathArr[S]=y;var ue=e.validate(h);h.baseId=j,e.util.varOccurences(ue,w)<2?i+=" "+e.util.varReplace(ue,w,me)+" ":i+=" var "+w+" = "+me+"; "+ue+" ",f&&(i+=" if (!"+A+") break; "),i+=" } ",f&&(i+=" else "+A+" = true; "),i+=" } ",f&&(i+=" if ("+A+") { ",g+="}")}}}return f&&(i+=" "+g+" if ("+p+" == errors) {"),i}});var lqt=B((eko,aqt)=>{"use strict";aqt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="errs__"+o,h=e.util.copy(e),g="";h.level++;var A="valid"+h.level;if(i+="var "+p+" = errors;",e.opts.strictKeywords?typeof a=="object"&&Object.keys(a).length>0||a===!1:e.util.schemaHasRules(a,e.RULES.all)){h.schema=a,h.schemaPath=c,h.errSchemaPath=u;var y="key"+o,v="idx"+o,S="i"+o,w="' + "+y+" + '",T=h.dataLevel=e.dataLevel+1,N="data"+T,P="dataProperties"+o,U=e.opts.ownProperties,Q=e.baseId;U&&(i+=" var "+P+" = undefined; "),U?i+=" "+P+" = "+P+" || Object.keys("+d+"); for (var "+v+"=0; "+v+"<"+P+".length; "+v+"++) { var "+y+" = "+P+"["+v+"]; ":i+=" for (var "+y+" in "+d+") { ",i+=" var startErrs"+o+" = errors; ";var D=y,F=e.compositeRule;e.compositeRule=h.compositeRule=!0;var O=e.validate(h);h.baseId=Q,e.util.varOccurences(O,N)<2?i+=" "+e.util.varReplace(O,N,D)+" ":i+=" var "+N+" = "+D+"; "+O+" ",e.compositeRule=h.compositeRule=F,i+=" if (!"+A+") { for (var "+S+"=startErrs"+o+"; "+S+"<errors; "+S+"++) { vErrors["+S+"].propertyName = "+y+"; } var err = ",e.createErrors!==!1?(i+=" { keyword: 'propertyNames' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { propertyName: '"+w+"' } ",e.opts.messages!==!1&&(i+=" , message: 'property name \\'"+w+"\\' is invalid' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&f&&(e.async?i+=" throw new ValidationError(vErrors); ":i+=" validate.errors = vErrors; return false; "),f&&(i+=" break; "),i+=" } }"}return f&&(i+=" "+g+" if ("+p+" == errors) {"),i}});var uqt=B((tko,cqt)=>{"use strict";cqt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="valid"+o,h=e.opts.$data&&a&&a.$data,g;h?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",g="schema"+o):g=a;var A="schema"+o;if(!h)if(a.length<e.opts.loopRequired&&e.schema.properties&&Object.keys(e.schema.properties).length){var y=[],v=a;if(v)for(var S,w=-1,T=v.length-1;w<T;){S=v[w+=1];var N=e.schema.properties[S];N&&(e.opts.strictKeywords?typeof N=="object"&&Object.keys(N).length>0||N===!1:e.util.schemaHasRules(N,e.RULES.all))||(y[y.length]=S)}}else var y=a;if(h||y.length){var P=e.errorPath,U=h||y.length>=e.opts.loopRequired,Q=e.opts.ownProperties;if(f)if(i+=" var missing"+o+"; ",U){h||(i+=" var "+A+" = validate.schema"+c+"; ");var D="i"+o,F="schema"+o+"["+D+"]",O="' + "+F+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(P,F,e.opts.jsonPointers)),i+=" var "+p+" = true; ",h&&(i+=" if (schema"+o+" === undefined) "+p+" = true; else if (!Array.isArray(schema"+o+")) "+p+" = false; else {"),i+=" for (var "+D+" = 0; "+D+" < "+A+".length; "+D+"++) { "+p+" = "+d+"["+A+"["+D+"]] !== undefined ",Q&&(i+=" && Object.prototype.hasOwnProperty.call("+d+", "+A+"["+D+"]) "),i+="; if (!"+p+") break; } ",h&&(i+=" } "),i+=" if (!"+p+") { ";var q=q||[];q.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(i+=" , message: '",e.opts._errorDataPathProperty?i+="is a required property":i+="should have required property \\'"+O+"\\'",i+="' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var L=i;i=q.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+L+"]); ":i+=" validate.errors = ["+L+"]; return false; ":i+=" var err = "+L+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } else { "}else{i+=" if ( ";var M=y;if(M)for(var j,D=-1,G=M.length-1;D<G;){j=M[D+=1],D&&(i+=" || ");var W=e.util.getProperty(j),V=d+W;i+=" ( ( "+V+" === undefined ",Q&&(i+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(j)+"') "),i+=") && (missing"+o+" = "+e.util.toQuotedString(e.opts.jsonPointers?j:W)+") ) "}i+=") { ";var F="missing"+o,O="' + "+F+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(P,F,!0):P+" + "+F);var q=q||[];q.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(i+=" , message: '",e.opts._errorDataPathProperty?i+="is a required property":i+="should have required property \\'"+O+"\\'",i+="' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var L=i;i=q.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+L+"]); ":i+=" validate.errors = ["+L+"]; return false; ":i+=" var err = "+L+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } else { "}else if(U){h||(i+=" var "+A+" = validate.schema"+c+"; ");var D="i"+o,F="schema"+o+"["+D+"]",O="' + "+F+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(P,F,e.opts.jsonPointers)),h&&(i+=" if ("+A+" && !Array.isArray("+A+")) { var err = ",e.createErrors!==!1?(i+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(i+=" , message: '",e.opts._errorDataPathProperty?i+="is a required property":i+="should have required property \\'"+O+"\\'",i+="' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if ("+A+" !== undefined) { "),i+=" for (var "+D+" = 0; "+D+" < "+A+".length; "+D+"++) { if ("+d+"["+A+"["+D+"]] === undefined ",Q&&(i+=" || ! Object.prototype.hasOwnProperty.call("+d+", "+A+"["+D+"]) "),i+=") { var err = ",e.createErrors!==!1?(i+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(i+=" , message: '",e.opts._errorDataPathProperty?i+="is a required property":i+="should have required property \\'"+O+"\\'",i+="' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ",h&&(i+=" } ")}else{var X=y;if(X)for(var j,J=-1,he=X.length-1;J<he;){j=X[J+=1];var W=e.util.getProperty(j),O=e.util.escapeQuotes(j),V=d+W;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(P,j,e.opts.jsonPointers)),i+=" if ( "+V+" === undefined ",Q&&(i+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(j)+"') "),i+=") { var err = ",e.createErrors!==!1?(i+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { missingProperty: '"+O+"' } ",e.opts.messages!==!1&&(i+=" , message: '",e.opts._errorDataPathProperty?i+="is a required property":i+="should have required property \\'"+O+"\\'",i+="' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}e.errorPath=P}else f&&(i+=" if (true) {");return i}});var dqt=B((rko,fqt)=>{"use strict";fqt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d="data"+(s||""),p="valid"+o,h=e.opts.$data&&a&&a.$data,g;if(h?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",g="schema"+o):g=a,(a||h)&&e.opts.uniqueItems!==!1){h&&(i+=" var "+p+"; if ("+g+" === false || "+g+" === undefined) "+p+" = true; else if (typeof "+g+" != 'boolean') "+p+" = false; else { "),i+=" var i = "+d+".length , "+p+" = true , j; if (i > 1) { ";var A=e.schema.items&&e.schema.items.type,y=Array.isArray(A);if(!A||A=="object"||A=="array"||y&&(A.indexOf("object")>=0||A.indexOf("array")>=0))i+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+d+"[i], "+d+"[j])) { "+p+" = false; break outer; } } } ";else{i+=" var itemIndices = {}, item; for (;i--;) { var item = "+d+"[i]; ";var v="checkDataType"+(y?"s":"");i+=" if ("+e.util[v](A,"item",e.opts.strictNumbers,!0)+") continue; ",y&&(i+=` if (typeof item == 'string') item = '"' + item; `),i+=" if (typeof itemIndices[item] == 'number') { "+p+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}i+=" } ",h&&(i+=" } "),i+=" if (!"+p+") { ";var S=S||[];S.push(i),i="",e.createErrors!==!1?(i+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { i: i, j: j } ",e.opts.messages!==!1&&(i+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(i+=" , schema: ",h?i+="validate.schema"+c:i+=""+a,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),i+=" } "):i+=" {} ";var w=i;i=S.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+w+"]); ":i+=" validate.errors = ["+w+"]; return false; ":i+=" var err = "+w+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } ",f&&(i+=" else { ")}else f&&(i+=" if (true) { ");return i}});var hqt=B((nko,pqt)=>{"use strict";pqt.exports={$ref:xQt(),allOf:DQt(),anyOf:RQt(),$comment:NQt(),const:MQt(),contains:LQt(),dependencies:FQt(),enum:QQt(),format:HQt(),if:jQt(),items:$Qt(),maximum:Mqe(),minimum:Mqe(),maxItems:kqe(),minItems:kqe(),maxLength:Lqe(),minLength:Lqe(),maxProperties:Pqe(),minProperties:Pqe(),multipleOf:XQt(),not:eqt(),oneOf:rqt(),pattern:iqt(),properties:sqt(),propertyNames:lqt(),required:uqt(),uniqueItems:dqt(),validate:Nqe()}});var Aqt=B((iko,gqt)=>{"use strict";var mqt=hqt(),Fqe=lO().toHash;gqt.exports=function(){var e=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],r=["type","$comment"],n=["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"],i=["number","integer","string","array","object","boolean","null"];return e.all=Fqe(r),e.types=Fqe(i),e.forEach(function(o){o.rules=o.rules.map(function(s){var a;if(typeof s=="object"){var c=Object.keys(s)[0];a=s[c],s=c,a.forEach(function(f){r.push(f),e.all[f]=!0})}r.push(s);var u=e.all[s]={keyword:s,code:mqt[s],implements:a};return u}),e.all.$comment={keyword:"$comment",code:mqt.$comment},o.type&&(e.types[o.type]=o)}),e.keywords=Fqe(r.concat(n)),e.custom={},e}});var vqt=B((oko,Eqt)=>{"use strict";var yqt=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"];Eqt.exports=function(t,e){for(var r=0;r<e.length;r++){t=JSON.parse(JSON.stringify(t));var n=e[r].split("/"),i=t,o;for(o=1;o<n.length;o++)i=i[n[o]];for(o=0;o<yqt.length;o++){var s=yqt[o],a=i[s];a&&(i[s]={anyOf:[a,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]})}}return t}});var _qt=B((sko,Cqt)=>{"use strict";var aHn=Pme().MissingRef;Cqt.exports=bqt;function bqt(t,e,r){var n=this;if(typeof this._opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");typeof e=="function"&&(r=e,e=void 0);var i=o(t).then(function(){var a=n._addSchema(t,void 0,e);return a.validate||s(a)});return r&&i.then(function(a){r(null,a)},r),i;function o(a){var c=a.$schema;return c&&!n.getSchema(c)?bqt.call(n,{$ref:c},!0):Promise.resolve()}function s(a){try{return n._compile(a)}catch(u){if(u instanceof aHn)return c(u);throw u}function c(u){var f=u.missingSchema;if(h(f))throw new Error("Schema "+f+" is loaded but "+u.missingRef+" cannot be resolved");var d=n._loadingSchemas[f];return d||(d=n._loadingSchemas[f]=n._opts.loadSchema(f),d.then(p,p)),d.then(function(g){if(!h(f))return o(g).then(function(){h(f)||n.addSchema(g,f,void 0,e)})}).then(function(){return s(a)});function p(){delete n._loadingSchemas[f]}function h(g){return n._refs[g]||n._schemas[g]}}}}});var wqt=B((ako,Sqt)=>{"use strict";Sqt.exports=function(e,r,n){var i=" ",o=e.level,s=e.dataLevel,a=e.schema[r],c=e.schemaPath+e.util.getProperty(r),u=e.errSchemaPath+"/"+r,f=!e.opts.allErrors,d,p="data"+(s||""),h="valid"+o,g="errs__"+o,A=e.opts.$data&&a&&a.$data,y;A?(i+=" var schema"+o+" = "+e.util.getData(a.$data,s,e.dataPathArr)+"; ",y="schema"+o):y=a;var v=this,S="definition"+o,w=v.definition,T="",N,P,U,Q,D;if(A&&w.$data){D="keywordValidate"+o;var F=w.validateSchema;i+=" var "+S+" = RULES.custom['"+r+"'].definition; var "+D+" = "+S+".validate;"}else{if(Q=e.useCustomRule(v,a,e.schema,e),!Q)return;y="validate.schema"+c,D=Q.code,N=w.compile,P=w.inline,U=w.macro}var O=D+".errors",q="i"+o,L="ruleErr"+o,M=w.async;if(M&&!e.async)throw new Error("async keyword in sync schema");if(P||U||(i+=""+O+" = null;"),i+="var "+g+" = errors;var "+h+";",A&&w.$data&&(T+="}",i+=" if ("+y+" === undefined) { "+h+" = true; } else { ",F&&(T+="}",i+=" "+h+" = "+S+".validateSchema("+y+"); if ("+h+") { ")),P)w.statements?i+=" "+Q.validate+" ":i+=" "+h+" = "+Q.validate+"; ";else if(U){var j=e.util.copy(e),T="";j.level++;var G="valid"+j.level;j.schema=Q.validate,j.schemaPath="";var W=e.compositeRule;e.compositeRule=j.compositeRule=!0;var V=e.validate(j).replace(/validate\.schema/g,D);e.compositeRule=j.compositeRule=W,i+=" "+V}else{var X=X||[];X.push(i),i="",i+=" "+D+".call( ",e.opts.passContext?i+="this":i+="self",N||w.schema===!1?i+=" , "+p+" ":i+=" , "+y+" , "+p+" , validate.schema"+e.schemaPath+" ",i+=" , (dataPath || '')",e.errorPath!='""'&&(i+=" + "+e.errorPath);var J=s?"data"+(s-1||""):"parentData",he=s?e.dataPathArr[s]:"parentDataProperty";i+=" , "+J+" , "+he+" , rootData ) ";var be=i;i=X.pop(),w.errors===!1?(i+=" "+h+" = ",M&&(i+="await "),i+=""+be+"; "):M?(O="customErrors"+o,i+=" var "+O+" = null; try { "+h+" = await "+be+"; } catch (e) { "+h+" = false; if (e instanceof ValidationError) "+O+" = e.errors; else throw e; } "):i+=" "+O+" = null; "+h+" = "+be+"; "}if(w.modifying&&(i+=" if ("+J+") "+p+" = "+J+"["+he+"];"),i+=""+T,w.valid)f&&(i+=" if (true) { ");else{i+=" if ( ",w.valid===void 0?(i+=" !",U?i+=""+G:i+=""+h):i+=" "+!w.valid+" ",i+=") { ",d=v.keyword;var X=X||[];X.push(i),i="";var X=X||[];X.push(i),i="",e.createErrors!==!1?(i+=" { keyword: '"+(d||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { keyword: '"+v.keyword+"' } ",e.opts.messages!==!1&&(i+=` , message: 'should pass "`+v.keyword+`" keyword validation' `),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+p+" "),i+=" } "):i+=" {} ";var ge=i;i=X.pop(),!e.compositeRule&&f?e.async?i+=" throw new ValidationError(["+ge+"]); ":i+=" validate.errors = ["+ge+"]; return false; ":i+=" var err = "+ge+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";var _e=i;i=X.pop(),P?w.errors?w.errors!="full"&&(i+=" for (var "+q+"="+g+"; "+q+"<errors; "+q+"++) { var "+L+" = vErrors["+q+"]; if ("+L+".dataPath === undefined) "+L+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+L+".schemaPath === undefined) { "+L+'.schemaPath = "'+u+'"; } ',e.opts.verbose&&(i+=" "+L+".schema = "+y+"; "+L+".data = "+p+"; "),i+=" } "):w.errors===!1?i+=" "+_e+" ":(i+=" if ("+g+" == errors) { "+_e+" } else { for (var "+q+"="+g+"; "+q+"<errors; "+q+"++) { var "+L+" = vErrors["+q+"]; if ("+L+".dataPath === undefined) "+L+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+L+".schemaPath === undefined) { "+L+'.schemaPath = "'+u+'"; } ',e.opts.verbose&&(i+=" "+L+".schema = "+y+"; "+L+".data = "+p+"; "),i+=" } } "):U?(i+=" var err = ",e.createErrors!==!1?(i+=" { keyword: '"+(d||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(u)+" , params: { keyword: '"+v.keyword+"' } ",e.opts.messages!==!1&&(i+=` , message: 'should pass "`+v.keyword+`" keyword validation' `),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+p+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&f&&(e.async?i+=" throw new ValidationError(vErrors); ":i+=" validate.errors = vErrors; return false; ")):w.errors===!1?i+=" "+_e+" ":(i+=" if (Array.isArray("+O+")) { if (vErrors === null) vErrors = "+O+"; else vErrors = vErrors.concat("+O+"); errors = vErrors.length; for (var "+q+"="+g+"; "+q+"<errors; "+q+"++) { var "+L+" = vErrors["+q+"]; if ("+L+".dataPath === undefined) "+L+".dataPath = (dataPath || '') + "+e.errorPath+"; "+L+'.schemaPath = "'+u+'"; ',e.opts.verbose&&(i+=" "+L+".schema = "+y+"; "+L+".data = "+p+"; "),i+=" } } else { "+_e+" } "),i+=" } ",f&&(i+=" else { ")}return i}});var Uqe=B((lko,lHn)=>{lHn.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var Dqt=B((cko,Tqt)=>{"use strict";var xqt=Uqe();Tqt.exports={$id:"https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",definitions:{simpleTypes:xqt.definitions.simpleTypes},type:"object",dependencies:{schema:["validate"],$data:["validate"],statements:["inline"],valid:{not:{required:["macro"]}}},properties:{type:xqt.properties.type,schema:{type:"boolean"},statements:{type:"boolean"},dependencies:{type:"array",items:{type:"string"}},metaSchema:{type:"object"},modifying:{type:"boolean"},valid:{type:"boolean"},$data:{type:"boolean"},async:{type:"boolean"},errors:{anyOf:[{type:"boolean"},{const:"full"}]}}}});var Rqt=B((uko,Iqt)=>{"use strict";var cHn=/^[a-z_$][a-z0-9_$-]*$/i,uHn=wqt(),fHn=Dqt();Iqt.exports={add:dHn,get:pHn,remove:hHn,validate:Qqe};function dHn(t,e){var r=this.RULES;if(r.keywords[t])throw new Error("Keyword "+t+" is already defined");if(!cHn.test(t))throw new Error("Keyword "+t+" is not a valid identifier");if(e){this.validateKeyword(e,!0);var n=e.type;if(Array.isArray(n))for(var i=0;i<n.length;i++)s(t,n[i],e);else s(t,n,e);var o=e.metaSchema;o&&(e.$data&&this._opts.$data&&(o={anyOf:[o,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]}),e.validateSchema=this.compile(o,!0))}r.keywords[t]=r.all[t]=!0;function s(a,c,u){for(var f,d=0;d<r.length;d++){var p=r[d];if(p.type==c){f=p;break}}f||(f={type:c,rules:[]},r.push(f));var h={keyword:a,definition:u,custom:!0,code:uHn,implements:u.implements};f.rules.push(h),r.custom[a]=h}return this}function pHn(t){var e=this.RULES.custom[t];return e?e.definition:this.RULES.keywords[t]||!1}function hHn(t){var e=this.RULES;delete e.keywords[t],delete e.all[t],delete e.custom[t];for(var r=0;r<e.length;r++)for(var n=e[r].rules,i=0;i<n.length;i++)if(n[i].keyword==t){n.splice(i,1);break}return this}function Qqe(t,e){Qqe.errors=null;var r=this._validateKeyword=this._validateKeyword||this.compile(fHn,!0);if(r(t))return!0;if(Qqe.errors=r.errors,e)throw new Error("custom keyword definition is invalid: "+this.errorsText(r.errors));return!1}});var Bqt=B((fko,mHn)=>{mHn.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON Schema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var qqt=B((dko,Qqt)=>{"use strict";var Oqt=uQt(),cO=Lme(),gHn=dQt(),Mqt=wqe(),AHn=Bqe(),yHn=SQt(),EHn=Aqt(),kqt=vqt(),Lqt=lO();Qqt.exports=Jf;Jf.prototype.validate=bHn;Jf.prototype.compile=CHn;Jf.prototype.addSchema=_Hn;Jf.prototype.addMetaSchema=SHn;Jf.prototype.validateSchema=wHn;Jf.prototype.getSchema=THn;Jf.prototype.removeSchema=IHn;Jf.prototype.addFormat=PHn;Jf.prototype.errorsText=LHn;Jf.prototype._addSchema=RHn;Jf.prototype._compile=BHn;Jf.prototype.compileAsync=_qt();var Vme=Rqt();Jf.prototype.addKeyword=Vme.add;Jf.prototype.getKeyword=Vme.get;Jf.prototype.removeKeyword=Vme.remove;Jf.prototype.validateKeyword=Vme.validate;var Pqt=Pme();Jf.ValidationError=Pqt.Validation;Jf.MissingRefError=Pqt.MissingRef;Jf.$dataMetaSchema=kqt;var jme="http://json-schema.org/draft-07/schema",Nqt=["removeAdditional","useDefaults","coerceTypes","strictDefaults"],vHn=["/properties"];function Jf(t){if(!(this instanceof Jf))return new Jf(t);t=this._opts=Lqt.copy(t)||{},GHn(this),this._schemas={},this._refs={},this._fragments={},this._formats=yHn(t.format),this._cache=t.cache||new gHn,this._loadingSchemas={},this._compilations=[],this.RULES=EHn(),this._getId=NHn(t),t.loopRequired=t.loopRequired||1/0,t.errorDataPath=="property"&&(t._errorDataPathProperty=!0),t.serialize===void 0&&(t.serialize=AHn),this._metaOpts=HHn(this),t.formats&&QHn(this),t.keywords&&qHn(this),FHn(this),typeof t.meta=="object"&&this.addMetaSchema(t.meta),t.nullable&&this.addKeyword("nullable",{metaSchema:{type:"boolean"}}),UHn(this)}function bHn(t,e){var r;if(typeof t=="string"){if(r=this.getSchema(t),!r)throw new Error('no schema with key or ref "'+t+'"')}else{var n=this._addSchema(t);r=n.validate||this._compile(n)}var i=r(e);return r.$async!==!0&&(this.errors=r.errors),i}function CHn(t,e){var r=this._addSchema(t,void 0,e);return r.validate||this._compile(r)}function _Hn(t,e,r,n){if(Array.isArray(t)){for(var i=0;i<t.length;i++)this.addSchema(t[i],void 0,r,n);return this}var o=this._getId(t);if(o!==void 0&&typeof o!="string")throw new Error("schema id must be string");return e=cO.normalizeId(e||o),Uqt(this,e),this._schemas[e]=this._addSchema(t,r,n,!0),this}function SHn(t,e,r){return this.addSchema(t,e,r,!0),this}function wHn(t,e){var r=t.$schema;if(r!==void 0&&typeof r!="string")throw new Error("$schema must be a string");if(r=r||this._opts.defaultMeta||xHn(this),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;var n=this.validate(r,t);if(!n&&e){var i="schema is invalid: "+this.errorsText();if(this._opts.validateSchema=="log")this.logger.error(i);else throw new Error(i)}return n}function xHn(t){var e=t._opts.meta;return t._opts.defaultMeta=typeof e=="object"?t._getId(e)||e:t.getSchema(jme)?jme:void 0,t._opts.defaultMeta}function THn(t){var e=Fqt(this,t);switch(typeof e){case"object":return e.validate||this._compile(e);case"string":return this.getSchema(e);case"undefined":return DHn(this,t)}}function DHn(t,e){var r=cO.schema.call(t,{schema:{}},e);if(r){var n=r.schema,i=r.root,o=r.baseId,s=Oqt.call(t,n,i,void 0,o);return t._fragments[e]=new Mqt({ref:e,fragment:!0,schema:n,root:i,baseId:o,validate:s}),s}}function Fqt(t,e){return e=cO.normalizeId(e),t._schemas[e]||t._refs[e]||t._fragments[e]}function IHn(t){if(t instanceof RegExp)return Gme(this,this._schemas,t),Gme(this,this._refs,t),this;switch(typeof t){case"undefined":return Gme(this,this._schemas),Gme(this,this._refs),this._cache.clear(),this;case"string":var e=Fqt(this,t);return e&&this._cache.del(e.cacheKey),delete this._schemas[t],delete this._refs[t],this;case"object":var r=this._opts.serialize,n=r?r(t):t;this._cache.del(n);var i=this._getId(t);i&&(i=cO.normalizeId(i),delete this._schemas[i],delete this._refs[i])}return this}function Gme(t,e,r){for(var n in e){var i=e[n];!i.meta&&(!r||r.test(n))&&(t._cache.del(i.cacheKey),delete e[n])}}function RHn(t,e,r,n){if(typeof t!="object"&&typeof t!="boolean")throw new Error("schema should be object or boolean");var i=this._opts.serialize,o=i?i(t):t,s=this._cache.get(o);if(s)return s;n=n||this._opts.addUsedSchema!==!1;var a=cO.normalizeId(this._getId(t));a&&n&&Uqt(this,a);var c=this._opts.validateSchema!==!1&&!e,u;c&&!(u=a&&a==cO.normalizeId(t.$schema))&&this.validateSchema(t,!0);var f=cO.ids.call(this,t),d=new Mqt({id:a,schema:t,localRefs:f,cacheKey:o,meta:r});return a[0]!="#"&&n&&(this._refs[a]=d),this._cache.put(o,d),c&&u&&this.validateSchema(t,!0),d}function BHn(t,e){if(t.compiling)return t.validate=i,i.schema=t.schema,i.errors=null,i.root=e||i,t.schema.$async===!0&&(i.$async=!0),i;t.compiling=!0;var r;t.meta&&(r=this._opts,this._opts=this._metaOpts);var n;try{n=Oqt.call(this,t.schema,e,t.localRefs)}catch(o){throw delete t.validate,o}finally{t.compiling=!1,t.meta&&(this._opts=r)}return t.validate=n,t.refs=n.refs,t.refVal=n.refVal,t.root=n.root,n;function i(){var o=t.validate,s=o.apply(this,arguments);return i.errors=o.errors,s}}function NHn(t){switch(t.schemaId){case"auto":return kHn;case"id":return OHn;default:return MHn}}function OHn(t){return t.$id&&this.logger.warn("schema $id ignored",t.$id),t.id}function MHn(t){return t.id&&this.logger.warn("schema id ignored",t.id),t.$id}function kHn(t){if(t.$id&&t.id&&t.$id!=t.id)throw new Error("schema $id is different from id");return t.$id||t.id}function LHn(t,e){if(t=t||this.errors,!t)return"No errors";e=e||{};for(var r=e.separator===void 0?", ":e.separator,n=e.dataVar===void 0?"data":e.dataVar,i="",o=0;o<t.length;o++){var s=t[o];s&&(i+=n+s.dataPath+" "+s.message+r)}return i.slice(0,-r.length)}function PHn(t,e){return typeof e=="string"&&(e=new RegExp(e)),this._formats[t]=e,this}function FHn(t){var e;if(t._opts.$data&&(e=Bqt(),t.addMetaSchema(e,e.$id,!0)),t._opts.meta!==!1){var r=Uqe();t._opts.$data&&(r=kqt(r,vHn)),t.addMetaSchema(r,jme,!0),t._refs["http://json-schema.org/schema"]=jme}}function UHn(t){var e=t._opts.schemas;if(e)if(Array.isArray(e))t.addSchema(e);else for(var r in e)t.addSchema(e[r],r)}function QHn(t){for(var e in t._opts.formats){var r=t._opts.formats[e];t.addFormat(e,r)}}function qHn(t){for(var e in t._opts.keywords){var r=t._opts.keywords[e];t.addKeyword(e,r)}}function Uqt(t,e){if(t._schemas[e]||t._refs[e])throw new Error('schema with key or id "'+e+'" already exists')}function HHn(t){for(var e=Lqt.copy(t._opts),r=0;r<Nqt.length;r++)delete e[Nqt[r]];return e}function GHn(t){var e=t._opts.logger;if(e===!1)t.logger={log:qqe,warn:qqe,error:qqe};else{if(e===void 0&&(e=console),!(typeof e=="object"&&e.log&&e.warn&&e.error))throw new Error("logger must implement log, warn and error methods");t.logger=e}}function qqe(){}});var Hqt,q7,$me=Re(()=>{QUt();Qx();Hqt=ze(qqt(),1),q7=class extends Dme{constructor(e,r){var n;super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=(n=r?.capabilities)!==null&&n!==void 0?n:{},this._ajv=new Hqt.default}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=UUt(this._capabilities,e)}assertCapability(e,r){var n;if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n[e]))throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{let n=await this.request({method:"initialize",params:{protocolVersion:OH,capabilities:this._capabilities,clientInfo:this._clientInfo}},lqe,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!bUt.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"})}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var r,n,i,o,s;switch(e){case"logging/setLevel":if(!(!((r=this._serverCapabilities)===null||r===void 0)&&r.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(!((n=this._serverCapabilities)===null||n===void 0)&&n.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(!((i=this._serverCapabilities)===null||i===void 0)&&i.resources))throw new Error(`Server does not support resources (required for ${e})`);if(e==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(!((o=this._serverCapabilities)===null||o===void 0)&&o.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(!((s=this._serverCapabilities)===null||s===void 0)&&s.completions))throw new Error(`Server does not support completions (required for ${e})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){var r;switch(e){case"notifications/roots/list_changed":if(!(!((r=this._capabilities.roots)===null||r===void 0)&&r.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"ping":break}}async ping(e){return this.request({method:"ping"},aO,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},Aqe,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},aO,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},xee,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},wee,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},uqe,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},fqe,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},dqe,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},aO,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},aO,r)}async callTool(e,r=xme,n){let i=await this.request({method:"tools/call",params:e},r,n),o=this.getToolOutputValidator(e.name);if(o){if(!i.structuredContent&&!i.isError)throw new e4(Z6.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(i.structuredContent)try{if(!o(i.structuredContent))throw new e4(Z6.InvalidParams,`Structured content does not match the tool's output schema: ${this._ajv.errorsText(o.errors)}`)}catch(s){throw s instanceof e4?s:new e4(Z6.InvalidParams,`Failed to validate structured content: ${s instanceof Error?s.message:String(s)}`)}}return i}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(let r of e)if(r.outputSchema)try{let n=this._ajv.compile(r.outputSchema);this._cachedToolOutputValidators.set(r.name,n)}catch{}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){let n=await this.request({method:"tools/list",params:e},gqe,r);return this.cacheToolOutputSchemas(n.tools),n}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}});var Wqt=B((gko,$qt)=>{$qt.exports=Vqt;Vqt.sync=VHn;var Gqt=we("fs");function jHn(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var n=0;n<r.length;n++){var i=r[n].toLowerCase();if(i&&t.substr(-i.length).toLowerCase()===i)return!0}return!1}function jqt(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:jHn(e,r)}function Vqt(t,e,r){Gqt.stat(t,function(n,i){r(n,n?!1:jqt(i,t,e))})}function VHn(t,e){return jqt(Gqt.statSync(t),t,e)}});var Xqt=B((Ako,Kqt)=>{Kqt.exports=zqt;zqt.sync=$Hn;var Yqt=we("fs");function zqt(t,e,r){Yqt.stat(t,function(n,i){r(n,n?!1:Jqt(i,e))})}function $Hn(t,e){return Jqt(Yqt.statSync(t),e)}function Jqt(t,e){return t.isFile()&&WHn(t,e)}function WHn(t,e){var r=t.mode,n=t.uid,i=t.gid,o=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),s=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),u=parseInt("001",8),f=a|c,d=r&u||r&c&&i===s||r&a&&n===o||r&f&&o===0;return d}});var eHt=B((Eko,Zqt)=>{var yko=we("fs"),Wme;process.platform==="win32"||global.TESTING_WINDOWS?Wme=Wqt():Wme=Xqt();Zqt.exports=Hqe;Hqe.sync=YHn;function Hqe(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(n,i){Hqe(t,e||{},function(o,s){o?i(o):n(s)})})}Wme(t,e||{},function(n,i){n&&(n.code==="EACCES"||e&&e.ignoreErrors)&&(n=null,i=!1),r(n,i)})}function YHn(t,e){try{return Wme.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var aHt=B((vko,sHt)=>{var kH=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",tHt=we("path"),zHn=kH?";":":",rHt=eHt(),nHt=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),iHt=(t,e)=>{let r=e.colon||zHn,n=t.match(/\//)||kH&&t.match(/\\/)?[""]:[...kH?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],i=kH?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=kH?i.split(r):[""];return kH&&t.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:n,pathExt:o,pathExtExe:i}},oHt=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:n,pathExt:i,pathExtExe:o}=iHt(t,e),s=[],a=u=>new Promise((f,d)=>{if(u===n.length)return e.all&&s.length?f(s):d(nHt(t));let p=n[u],h=/^".*"$/.test(p)?p.slice(1,-1):p,g=tHt.join(h,t),A=!h&&/^\.[\\\/]/.test(t)?t.slice(0,2)+g:g;f(c(A,u,0))}),c=(u,f,d)=>new Promise((p,h)=>{if(d===i.length)return p(a(f+1));let g=i[d];rHt(u+g,{pathExt:o},(A,y)=>{if(!A&&y)if(e.all)s.push(u+g);else return p(u+g);return p(c(u,f,d+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},JHn=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:n,pathExtExe:i}=iHt(t,e),o=[];for(let s=0;s<r.length;s++){let a=r[s],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=tHt.join(c,t),f=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;for(let d=0;d<n.length;d++){let p=f+n[d];try{if(rHt.sync(p,{pathExt:i}))if(e.all)o.push(p);else return p}catch{}}}if(e.all&&o.length)return o;if(e.nothrow)return null;throw nHt(t)};sHt.exports=oHt;oHt.sync=JHn});var cHt=B((bko,Gqe)=>{"use strict";var lHt=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(n=>n.toUpperCase()==="PATH")||"Path"};Gqe.exports=lHt;Gqe.exports.default=lHt});var pHt=B((Cko,dHt)=>{"use strict";var uHt=we("path"),KHn=aHt(),XHn=cHt();function fHt(t,e){let r=t.options.env||process.env,n=process.cwd(),i=t.options.cwd!=null,o=i&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(t.options.cwd)}catch{}let s;try{s=KHn.sync(t.command,{path:r[XHn({env:r})],pathExt:e?uHt.delimiter:void 0})}catch{}finally{o&&process.chdir(n)}return s&&(s=uHt.resolve(i?t.options.cwd:"",s)),s}function ZHn(t){return fHt(t)||fHt(t,!0)}dHt.exports=ZHn});var hHt=B((_ko,Vqe)=>{"use strict";var jqe=/([()\][%!^"`<>&|;, *?])/g;function eGn(t){return t=t.replace(jqe,"^$1"),t}function tGn(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(jqe,"^$1"),e&&(t=t.replace(jqe,"^$1")),t}Vqe.exports.command=eGn;Vqe.exports.argument=tGn});var gHt=B((Sko,mHt)=>{"use strict";mHt.exports=/^#!(.*)/});var yHt=B((wko,AHt)=>{"use strict";var rGn=gHt();AHt.exports=(t="")=>{let e=t.match(rGn);if(!e)return null;let[r,n]=e[0].replace(/#! ?/,"").split(" "),i=r.split("/").pop();return i==="env"?n:n?`${i} ${n}`:i}});var vHt=B((xko,EHt)=>{"use strict";var $qe=we("fs"),nGn=yHt();function iGn(t){let r=Buffer.alloc(150),n;try{n=$qe.openSync(t,"r"),$qe.readSync(n,r,0,150,0),$qe.closeSync(n)}catch{}return nGn(r.toString())}EHt.exports=iGn});var SHt=B((Tko,_Ht)=>{"use strict";var oGn=we("path"),bHt=pHt(),CHt=hHt(),sGn=vHt(),aGn=process.platform==="win32",lGn=/\.(?:com|exe)$/i,cGn=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function uGn(t){t.file=bHt(t);let e=t.file&&sGn(t.file);return e?(t.args.unshift(t.file),t.command=e,bHt(t)):t.file}function fGn(t){if(!aGn)return t;let e=uGn(t),r=!lGn.test(e);if(t.options.forceShell||r){let n=cGn.test(e);t.command=oGn.normalize(t.command),t.command=CHt.command(t.command),t.args=t.args.map(o=>CHt.argument(o,n));let i=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${i}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function dGn(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let n={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?n:fGn(n)}_Ht.exports=dGn});var THt=B((Dko,xHt)=>{"use strict";var Wqe=process.platform==="win32";function Yqe(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function pGn(t,e){if(!Wqe)return;let r=t.emit;t.emit=function(n,i){if(n==="exit"){let o=wHt(i,e);if(o)return r.call(t,"error",o)}return r.apply(t,arguments)}}function wHt(t,e){return Wqe&&t===1&&!e.file?Yqe(e.original,"spawn"):null}function hGn(t,e){return Wqe&&t===1&&!e.file?Yqe(e.original,"spawnSync"):null}xHt.exports={hookChildProcess:pGn,verifyENOENT:wHt,verifyENOENTSync:hGn,notFoundError:Yqe}});var RHt=B((Iko,LH)=>{"use strict";var DHt=we("child_process"),zqe=SHt(),Jqe=THt();function IHt(t,e,r){let n=zqe(t,e,r),i=DHt.spawn(n.command,n.args,n.options);return Jqe.hookChildProcess(i,n),i}function mGn(t,e,r){let n=zqe(t,e,r),i=DHt.spawnSync(n.command,n.args,n.options);return i.error=i.error||Jqe.verifyENOENTSync(i.status,n),i}LH.exports=IHt;LH.exports.spawn=IHt;LH.exports.sync=mGn;LH.exports._parse=zqe;LH.exports._enoent=Jqe});function gGn(t){return Ux.parse(JSON.parse(t))}function BHt(t){return JSON.stringify(t)+`
|
|
546
546
|
`}var Yme,NHt=Re(()=>{Qx();Yme=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
547
547
|
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),gGn(r)}clear(){this._buffer=void 0}}});import Jme from"node:process";import{PassThrough as AGn}from"node:stream";function EGn(){let t={};for(let e of yGn){let r=Jme.env[e];r!==void 0&&(r.startsWith("()")||(t[e]=r))}return t}function vGn(){return"type"in Jme}var OHt,yGn,zme,MHt=Re(()=>{OHt=ze(RHt(),1);NHt();yGn=Jme.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];zme=class{constructor(e){this._abortController=new AbortController,this._readBuffer=new Yme,this._stderrStream=null,this._serverParams=e,(e.stderr==="pipe"||e.stderr==="overlapped")&&(this._stderrStream=new AGn)}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,r)=>{var n,i,o,s,a;this._process=(0,OHt.default)(this._serverParams.command,(n=this._serverParams.args)!==null&&n!==void 0?n:[],{env:{...EGn(),...this._serverParams.env},stdio:["pipe","pipe",(i=this._serverParams.stderr)!==null&&i!==void 0?i:"inherit"],shell:!1,signal:this._abortController.signal,windowsHide:Jme.platform==="win32"&&vGn(),cwd:this._serverParams.cwd}),this._process.on("error",c=>{var u,f;if(c.name==="AbortError"){(u=this.onclose)===null||u===void 0||u.call(this);return}r(c),(f=this.onerror)===null||f===void 0||f.call(this,c)}),this._process.on("spawn",()=>{e()}),this._process.on("close",c=>{var u;this._process=void 0,(u=this.onclose)===null||u===void 0||u.call(this)}),(o=this._process.stdin)===null||o===void 0||o.on("error",c=>{var u;(u=this.onerror)===null||u===void 0||u.call(this,c)}),(s=this._process.stdout)===null||s===void 0||s.on("data",c=>{this._readBuffer.append(c),this.processReadBuffer()}),(a=this._process.stdout)===null||a===void 0||a.on("error",c=>{var u;(u=this.onerror)===null||u===void 0||u.call(this,c)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){var e,r;return this._stderrStream?this._stderrStream:(r=(e=this._process)===null||e===void 0?void 0:e.stderr)!==null&&r!==void 0?r:null}get pid(){var e,r;return(r=(e=this._process)===null||e===void 0?void 0:e.pid)!==null&&r!==void 0?r:null}processReadBuffer(){for(var e,r;;)try{let n=this._readBuffer.readMessage();if(n===null)break;(e=this.onmessage)===null||e===void 0||e.call(this,n)}catch(n){(r=this.onerror)===null||r===void 0||r.call(this,n)}}async close(){this._abortController.abort(),this._process=void 0,this._readBuffer.clear()}send(e){return new Promise(r=>{var n;if(!(!((n=this._process)===null||n===void 0)&&n.stdin))throw new Error("Not connected");let i=BHt(e);this._process.stdin.write(i)?r():this._process.stdin.once("drain",r)})}}});function Kqe(t){}function Xme(t){if(typeof t=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:e=Kqe,onError:r=Kqe,onRetry:n=Kqe,onComment:i}=t,o="",s=!0,a,c="",u="";function f(A){let y=s?A.replace(/^\xEF\xBB\xBF/,""):A,[v,S]=bGn(`${o}${y}`);for(let w of v)d(w);o=S,s=!1}function d(A){if(A===""){h();return}if(A.startsWith(":")){i&&i(A.slice(A.startsWith(": ")?2:1));return}let y=A.indexOf(":");if(y!==-1){let v=A.slice(0,y),S=A[y+1]===" "?2:1,w=A.slice(y+S);p(v,w,A);return}p(A,"",A)}function p(A,y,v){switch(A){case"event":u=y;break;case"data":c=`${c}${y}
|
|
@@ -2470,7 +2470,7 @@ Error: ${i}`}}};oan={command:"add <name-or-id>",describe:"Add an agent from onli
|
|
|
2470
2470
|
`);let n=r.filter(o=>o.location==="project"),i=r.filter(o=>o.location==="global");if(n.length>0){console.log(`${q5o}Project agents:${wIe}`);for(let o of n){if(console.log(`\u2022 ${aan}${o.name}${wIe} (${o.agentType})`),o.description&&console.log(` Description: ${o.description}`),o.model&&console.log(` Model: ${o.model}`),o.allowedTools&&o.allowedTools.length>0){let s=o.allowedTools.includes("*")?"All tools":o.allowedTools.join(", "),a=o.isInheritTools===!1?" (no inherit)":"";console.log(` Tools: ${s}${a}`)}else o.isInheritTools===!1&&console.log(" Tools: None (no inherit)");o.allowedMcps&&o.allowedMcps.length>0?console.log(` MCPs: ${o.allowedMcps.join(", ")}`):o.isInheritMcps===!1&&console.log(" MCPs: None (no inherit)"),console.log(` Location: ${o.filePath||"unknown"}`),console.log()}}if(i.length>0){console.log(`${Q5o}Global agents:${wIe}`);for(let o of i){if(console.log(`\u2022 ${aan}${o.name}${wIe} (${o.agentType})`),o.description&&console.log(` Description: ${o.description}`),o.model&&console.log(` Model: ${o.model}`),o.allowedTools&&o.allowedTools.length>0){let s=o.allowedTools.includes("*")?"All tools":o.allowedTools.join(", "),a=o.isInheritTools===!1?" (no inherit)":"";console.log(` Tools: ${s}${a}`)}else o.isInheritTools===!1&&console.log(" Tools: None (no inherit)");o.allowedMcps&&o.allowedMcps.length>0?console.log(` MCPs: ${o.allowedMcps.join(", ")}`):o.isInheritMcps===!1&&console.log(" MCPs: None (no inherit)"),console.log(` Location: ${o.filePath||"unknown"}`),console.log()}}console.log(`Total: ${r.length} agent(s) configured`)}catch(r){console.error("Error loading agents:",r),process.exit(1)}}var aan,Q5o,q5o,wIe,lan,can=Re(()=>{"use strict";rn();aan="\x1B[32m",Q5o="\x1B[33m",q5o="\x1B[34m",wIe="\x1B[0m";lan={command:"list",describe:"List configured agents",builder:t=>t.usage("Usage: iflow agent list"),handler:async()=>{await H5o()}}});import*as xIe from"fs";async function G5o(t,e){let{scope:r}=e,n=process.cwd(),i=Km(n);try{let s=(await i.getAgents()).filter(a=>a.name===t||a.agentType===t);if(r&&r!=="all"&&(s=s.filter(a=>a.location===r)),s.length===0){let a=r&&r!=="all"?` in ${r} scope`:"";console.error(`Error: Agent '${t}' not found${a}`),process.exit(1)}if(s.length>1&&!r){console.error(`Error: Multiple agents found with name '${t}'. Please specify scope:`);for(let a of s)console.error(` - ${a.name} (${a.location}): ${a.filePath}`);console.error("Use --scope to specify which one to remove."),process.exit(1)}for(let a of s)try{a.filePath&&xIe.existsSync(a.filePath)?(xIe.unlinkSync(a.filePath),console.log(`Successfully removed agent '${a.name}' from ${a.location} scope`),console.log(`Deleted: ${a.filePath}`)):console.warn(`Warning: Agent file not found: ${a.filePath}`)}catch(c){console.error(`Error removing agent file ${a.filePath}:`,c),process.exit(1)}await i.refresh()}catch(o){console.error("Error removing agent:",o),process.exit(1)}}var uan,fan=Re(()=>{"use strict";rn();uan={command:"remove <name>",describe:"Remove an agent",builder:t=>t.usage("Usage: iflow agent remove <name> [--scope project|global|all]").positional("name",{describe:"Name or type of the agent to remove",type:"string",demandOption:!0}).option("scope",{alias:"s",describe:"Scope to remove from (project, global, or all)",type:"string",choices:["project","global","all"]}),handler:async t=>{await G5o(t.name,{scope:t.scope})}}});import*as TIe from"fs";async function W5o(t){let e=process.cwd(),r=Km(e);try{let i=(await r.getAgents()).filter(o=>o.name===t||o.agentType===t);i.length===0&&(console.error(`Error: Agent '${t}' not found`),process.exit(1));for(let o of i){if(console.log(`${j5o}Agent: ${o.name}${ng}`),console.log(`${My}Type:${ng} ${o.agentType}`),console.log(`${My}Location:${ng} ${o.location}`),console.log(`${My}File:${ng} ${o.filePath}`),o.description&&console.log(`${My}Description:${ng} ${o.description}`),o.whenToUse&&console.log(`${My}When to use:${ng} ${o.whenToUse}`),o.model&&console.log(`${My}Model:${ng} ${o.model}`),o.allowedTools&&o.allowedTools.length>0){let s=o.allowedTools.includes("*")?"All tools":o.allowedTools.join(", "),a=o.isInheritTools===!1?" (no inherit)":"";console.log(`${My}Allowed Tools:${ng} ${s}${a}`)}else o.isInheritTools===!1?console.log(`${My}Allowed Tools:${ng} None (no inherit)`):console.log(`${My}Allowed Tools:${ng} All tools (inherit)`);if(o.allowedMcps&&o.allowedMcps.length>0?console.log(`${My}Allowed MCP Servers:${ng} ${o.allowedMcps.join(", ")}`):o.isInheritMcps===!1?console.log(`${My}Allowed MCP Servers:${ng} None (no inherit)`):console.log(`${My}Allowed MCP Servers:${ng} All MCP servers (inherit)`),o.systemPrompt&&(console.log(`${My}System Prompt:${ng}`),console.log(o.systemPrompt)),o.filePath&&TIe.existsSync(o.filePath))try{let s=TIe.readFileSync(o.filePath,"utf8");console.log(`
|
|
2471
2471
|
${$5o}File Content:${ng}`),console.log("\u2500".repeat(50)),console.log(s),console.log("\u2500".repeat(50))}catch(s){console.warn(`Warning: Could not read file content: ${s}`)}else console.warn(`${V5o}Warning:${ng} Agent file not found at ${o.filePath||"unknown path"}`);i.length>1&&console.log(`
|
|
2472
2472
|
`+"=".repeat(60)+`
|
|
2473
|
-
`)}}catch(n){console.error("Error getting agent details:",n),process.exit(1)}}var j5o,V5o,My,$5o,ng,dan,pan=Re(()=>{"use strict";rn();j5o="\x1B[32m",V5o="\x1B[33m",My="\x1B[34m",$5o="\x1B[36m",ng="\x1B[0m";dan={command:"get <name>",describe:"Get details about an agent",builder:t=>t.usage("Usage: iflow agent get <name>").positional("name",{describe:"Name or type of the agent",type:"string",demandOption:!0}),handler:async t=>{await W5o(t.name)}}});async function K5o(t={}){let{page:e=1,size:r=20,search:n}=t,o=fc(process.cwd()).merged.apiKey;o||(console.error("Error: API key not found."),console.error("Please authenticate first by running the auth command."),process.exit(1)),console.log("Loading online agents...");try{let s=await J5o(o,e,r);s.success||(console.error(`Error: ${s.message}`),process.exit(1));let a=s.agents||[];if(n&&(a=a.filter(c=>c.name.toLowerCase().includes(n.toLowerCase())||c.description.toLowerCase().includes(n.toLowerCase())||c.category.toLowerCase().includes(n.toLowerCase()))),a.length===0){let c=n?` matching "${n}"`:"";console.log(`No agents found${c}`);return}console.log(`\\n${z5o}Online Agents${n?` (filtered by "${n}")`:""}:${Fp}\\n`);for(let c of a){if(console.log(`${Y5o}\u2022 ${c.name}${Fp} (ID: ${c.id})`),console.log(` ${ig}Description:${Fp} ${c.description}`),console.log(` ${ig}Category:${Fp} ${c.category}`),console.log(` ${ig}Model:${Fp} ${c.modelName}`),c.tags&&console.log(` ${ig}Tags:${Fp} ${c.tags}`),console.log(` ${ig}Author:${Fp} ${c.authorId}`),console.log(` ${ig}Version:${Fp} ${c.version}`),c.extInfo){if(c.extInfo["allowed-tools"]){let d=c.extInfo["allowed-tools"].split(",").map(p=>p.trim()).filter(p=>p);d.length>0?console.log(` ${ig}Allowed Tools:${Fp} ${d.join(", ")}`):c.extInfo["is-inherit-tools"]?console.log(` ${ig}Allowed Tools:${Fp} All tools available`):console.log(` ${ig}Allowed Tools:${Fp} No tools available`)}let u=c.extInfo["is-inherit-tools"];if(console.log(` ${ig}Inherit Tools:${Fp} ${u?"Yes":"No"}`),c.extInfo.mcps){let d=c.extInfo.mcps.split(",").map(p=>p.trim()).filter(p=>p);d.length>0?console.log(` ${ig}MCP Servers:${Fp} ${d.join(", ")}`):c.extInfo["is-inherit-mcps"]?console.log(` ${ig}MCP Servers:${Fp} All MCP servers available`):console.log(` ${ig}MCP Servers:${Fp} No MCP servers available`)}else c.extInfo["is-inherit-mcps"]?console.log(` ${ig}MCP Servers:${Fp} All MCP servers available`):console.log(` ${ig}MCP Servers:${Fp} No MCP servers available`);let f=c.extInfo["is-inherit-mcps"];console.log(` ${ig}Inherit MCPs:${Fp} ${f?"Yes":"No"}`)}console.log()}console.log(`${han}Total: ${a.length} agent(s) shown${s.total?` (${s.total} total available)`:""}${Fp}`),console.log(`${han}To install an agent, use: iflow agent add <name-or-id>${Fp}`)}catch(s){console.error("Error browsing online agents:",s),process.exit(1)}}var Y5o,han,z5o,ig,Fp,J5o,man,gan=Re(()=>{"use strict";Mf();Y5o="\x1B[32m",han="\x1B[33m",z5o="\x1B[34m",ig="\x1B[36m",Fp="\x1B[0m",J5o=async(t,e=1,r=20)=>{try{if(!t)return{success:!1,message:"Please authenticate first by running the auth command"};let i=await fetch("https://apis.iflow.cn/v1/agents/list",{method:"POST",headers:{Authorization:`Bearer ${t}`,"User-Agent":"iFlow-Cli","Content-Type":"application/json"},body:JSON.stringify({page:e,size:r})});if(!i.ok){let a="Unable to load agents. Please try again later";return i.status===401?a="Authentication failed. Please check your API key or re-authenticate":i.status===403?a="Access denied. Please check your permissions":i.status===404?a="Agents service not found. Please try again later":i.status>=500&&(a="Server error. Please try again later"),{success:!1,message:a}}let o=await i.json();return o.success?{success:!0,agents:Array.isArray(o.data.data)?o.data.data:[],total:o.data.total||0}:{success:!1,message:o.message||"Failed to load agents from server"}}catch(n){let i="Unable to load agents. Please check your connection and try again";return n instanceof Error&&n.message.includes("Failed to fetch")&&(i="Network error. Please check your internet connection"),{success:!1,message:i}}};man={command:"online",describe:"Browse online agent repository",builder:t=>t.usage("Usage: iflow agent online [options]").option("page",{alias:"p",describe:"Page number (default: 1)",type:"number",default:1}).option("size",{alias:"s",describe:"Number of agents per page (default: 20)",type:"number",default:20}).option("search",{describe:"Search term to filter agents",type:"string"}),handler:async t=>{await K5o({page:t.page,size:t.size,search:t.search})}}});var Aan={};o2(Aan,{agentCommand:()=>WEt});var WEt,YEt=Re(()=>{"use strict";san();can();fan();pan();gan();WEt={command:"agent",describe:"Manage agents",builder:t=>t.command(oan).command(lan).command(uan).command(dan).command(man).demandCommand(1,"You need at least one command before continuing.").version(!1),handler:()=>{}}});var Kan=B((QWs,Jan)=>{"use strict";var Fvo=we("os"),zan=we("tty"),_E=$Q(),{env:k0}=process,NR;_E("no-color")||_E("no-colors")||_E("color=false")||_E("color=never")?NR=0:(_E("color")||_E("colors")||_E("color=true")||_E("color=always"))&&(NR=1);"FORCE_COLOR"in k0&&(k0.FORCE_COLOR==="true"?NR=1:k0.FORCE_COLOR==="false"?NR=0:NR=k0.FORCE_COLOR.length===0?1:Math.min(parseInt(k0.FORCE_COLOR,10),3));function u5t(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function f5t(t,e){if(NR===0)return 0;if(_E("color=16m")||_E("color=full")||_E("color=truecolor"))return 3;if(_E("color=256"))return 2;if(t&&!e&&NR===void 0)return 0;let r=NR||0;if(k0.TERM==="dumb")return r;if(process.platform==="win32"){let n=Fvo.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in k0)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in k0)||k0.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in k0)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(k0.TEAMCITY_VERSION)?1:0;if(k0.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in k0){let n=parseInt((k0.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(k0.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(k0.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(k0.TERM)||"COLORTERM"in k0?1:r}function Uvo(t){let e=f5t(t,t&&t.isTTY);return u5t(e)}Jan.exports={supportsColor:Uvo,stdout:u5t(f5t(!0,zan.isatty(1))),stderr:u5t(f5t(!0,zan.isatty(2)))}});var eln=B((qWs,Zan)=>{"use strict";var Qvo=Kan(),oK=$Q();function Xan(t){if(/^\d{3,4}$/.test(t)){let r=/(\d{1,2})(\d{2})/.exec(t);return{major:0,minor:parseInt(r[1],10),patch:parseInt(r[2],10)}}let e=(t||"").split(".").map(r=>parseInt(r,10));return{major:e[0],minor:e[1],patch:e[2]}}function d5t(t){let{env:e}=process;if("FORCE_HYPERLINK"in e)return!(e.FORCE_HYPERLINK.length>0&&parseInt(e.FORCE_HYPERLINK,10)===0);if(oK("no-hyperlink")||oK("no-hyperlinks")||oK("hyperlink=false")||oK("hyperlink=never"))return!1;if(oK("hyperlink=true")||oK("hyperlink=always")||"NETLIFY"in e)return!0;if(!Qvo.supportsColor(t)||t&&!t.isTTY||process.platform==="win32"||"CI"in e||"TEAMCITY_VERSION"in e)return!1;if("TERM_PROGRAM"in e){let r=Xan(e.TERM_PROGRAM_VERSION);switch(e.TERM_PROGRAM){case"iTerm.app":return r.major===3?r.minor>=1:r.major>3;case"WezTerm":return r.major>=20200620;case"vscode":return r.major>1||r.major===1&&r.minor>=72}}if("VTE_VERSION"in e){if(e.VTE_VERSION==="0.50.0")return!1;let r=Xan(e.VTE_VERSION);return r.major>0||r.minor>=50}return!1}Zan.exports={supportsHyperlink:d5t,stdout:d5t(process.stdout),stderr:d5t(process.stderr)}});var v5t={};o2(v5t,{AuthHandler:()=>E5t});var E5t,b5t=Re(()=>{"use strict";E5t=class{logger;constructor(e={}){this.logger=console}validateToken(e){return e.authToken?e.authToken.length<16?(console.error("Auth token appears to be invalid (too short)"),!1):!0:(console.error("No auth token found in server config"),!1)}buildAuthenticatedUrl(e){if(!this.validateToken(e))throw new Error("Invalid authentication token");return`${e.serverUrl.replace(/^http/,"ws")}/ws?token=${encodeURIComponent(e.authToken)}`}buildAuthHeaders(e){if(!this.validateToken(e))throw new Error("Invalid authentication token");return{Auttion:`Bearer ${e.authToken}`,"X-Auth-Token":e.authToken}}isTokenExpired(e,r=1440*60*1e3){let i=Date.now()-e.timestamp;return i>r?(console.warn(`Token is ${Math.floor(i/1e3/60)} minutes old`),!0):!1}}});var _5t={};o2(_5t,{WebSocketClientImpl:()=>C5t});import{EventEmitter as mbo}from"events";var C5t,S5t=Re(()=>{"use strict";SX();tTe();C5t=class extends mbo{ws;config;isConnectedFlag=!1;heartbeatInterval;reconnectTimer;reconnectAttempts=0;pendingResponses=new Map;options;constructor(e={}){super(),this.options={reconnectAttempts:e.reconnectAttempts??3,reconnectDelay:e.reconnectDelay??1e3,heartbeatInterval:e.heartbeatInterval??3e4,connectionTimeout:e.connectionTimeout??5e3,logger:console},this.on("error",r=>{if(r.code==="EPIPE"){console.debug("WebSocket EPIPE detected, disconnecting gracefully"),this.disconnect();return}this.options.logger.error("WebSocket error:",r)})}async connect(e){return this.config=e,this.reconnectAttempts=0,new Promise((r,n)=>{let i=setTimeout(()=>{n(new Error("Connection timeout")),this.disconnect()},this.options.connectionTimeout);try{let o=`${e.serverUrl}?token=${e.authToken}`;this.ws=new IQ(o),this.ws.on("open",()=>{clearTimeout(i),this.isConnectedFlag=!0,console.debug("WebSocket connected"),this.sendConnectMessage(),this.startHeartbeat(),r()}),this.ws.on("message",s=>{try{let a=JSON.parse(s.toString());this.handleMessage(a)}catch(a){console.log("error","Failed to parse WebSocket message:",a)}}),this.ws.on("error",s=>{if(clearTimeout(i),console.log("error","WebSocket error:",s),s.code==="EPIPE"){this.isConnectedFlag=!1,this.stopHeartbeat(),this.isConnectedFlag||n(new Error("WebSocket connection failed due to EPIPE"));return}this.emit("error",s),this.isConnectedFlag||n(s)}),this.ws.on("close",()=>{clearTimeout(i),this.isConnectedFlag=!1,this.stopHeartbeat(),this.emit("close"),this.reconnectAttempts<this.options.reconnectAttempts&&this.scheduleReconnect()})}catch(o){clearTimeout(i),n(o)}})}async disconnect(){this.isConnectedFlag=!1,this.stopHeartbeat(),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0);for(let[,e]of this.pendingResponses)clearTimeout(e.timeout),e.reject(new Error("Connection closed"));return this.pendingResponses.clear(),new Promise(e=>{this.ws&&this.ws.readyState===IQ.OPEN?(this.ws.once("close",()=>e()),this.ws.close()):e()})}isConnected(){return this.isConnectedFlag&&this.ws?.readyState===IQ.OPEN}async send(e){if(!this.isConnected())throw new Error("WebSocket is not connected");return new Promise((r,n)=>{try{let i=JSON.stringify(e);this.ws.send(i,o=>{o?n(o):r()})}catch(i){n(i)}})}async sendRequest(e,r=3e4){return e.id||(e.id=this.generateId()),new Promise((n,i)=>{let o=setTimeout(()=>{this.pendingResponses.delete(e.id),i(new Error(`Timeout for message ${e.id}`))},r);this.pendingResponses.set(e.id,{resolve:n,reject:i,timeout:o}),this.send(e).catch(s=>{this.pendingResponses.delete(e.id),clearTimeout(o),i(s)})})}onMessage(e){this.on("message",e)}onError(e){this.on("error",e)}onClose(e){this.on("close",e)}handleMessage(e){if(e.type==="response"&&e.id){let r=this.pendingResponses.get(e.id);if(r){clearTimeout(r.timeout),this.pendingResponses.delete(e.id);let n=e.payload;n.success?r.resolve(n.data):r.reject(new Error(n.error||"Request failed"));return}}if(e.type!=="pong"){if(e.type==="active_file_changed"){this.emit("activeFileChanged",e.payload);return}if(e.type==="selection_changed"){this.emit("selectionChanged",e.payload);return}this.emit("message",e)}}sendConnectMessage(){let e={clientInfo:{version:"0.2.13",platform:process.platform,workingDirectory:process.cwd()}},r={type:"cli_connect",timestamp:Date.now(),payload:e};this.send(r).catch(n=>{console.log("error","Failed to send connect message:",n)})}startHeartbeat(){this.heartbeatInterval=setInterval(()=>{if(this.isConnected()){let e={type:"ping",timestamp:Date.now()};this.send(e).catch(r=>{console.log("error","Failed to send ping:",r)})}},this.options.heartbeatInterval)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=void 0)}scheduleReconnect(){this.reconnectAttempts++;let e=this.options.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.info(`Scheduling reconnect attempt ${this.reconnectAttempts} in ${e}ms`),this.reconnectTimer=setTimeout(()=>{this.config&&this.connect(this.config).catch(r=>{console.log("error","Reconnect failed:",r)})},e)}generateId(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}}});var eun=B(VF=>{VF.parse=VF.decode=Kbo;VF.stringify=VF.encode=Kcn;VF.safe=yK;VF.unsafe=fRe;var W5t=typeof process<"u"&&process.platform==="win32"?`\r
|
|
2473
|
+
`)}}catch(n){console.error("Error getting agent details:",n),process.exit(1)}}var j5o,V5o,My,$5o,ng,dan,pan=Re(()=>{"use strict";rn();j5o="\x1B[32m",V5o="\x1B[33m",My="\x1B[34m",$5o="\x1B[36m",ng="\x1B[0m";dan={command:"get <name>",describe:"Get details about an agent",builder:t=>t.usage("Usage: iflow agent get <name>").positional("name",{describe:"Name or type of the agent",type:"string",demandOption:!0}),handler:async t=>{await W5o(t.name)}}});async function K5o(t={}){let{page:e=1,size:r=20,search:n}=t,o=fc(process.cwd()).merged.apiKey;o||(console.error("Error: API key not found."),console.error("Please authenticate first by running the auth command."),process.exit(1)),console.log("Loading online agents...");try{let s=await J5o(o,e,r);s.success||(console.error(`Error: ${s.message}`),process.exit(1));let a=s.agents||[];if(n&&(a=a.filter(c=>c.name.toLowerCase().includes(n.toLowerCase())||c.description.toLowerCase().includes(n.toLowerCase())||c.category.toLowerCase().includes(n.toLowerCase()))),a.length===0){let c=n?` matching "${n}"`:"";console.log(`No agents found${c}`);return}console.log(`\\n${z5o}Online Agents${n?` (filtered by "${n}")`:""}:${Fp}\\n`);for(let c of a){if(console.log(`${Y5o}\u2022 ${c.name}${Fp} (ID: ${c.id})`),console.log(` ${ig}Description:${Fp} ${c.description}`),console.log(` ${ig}Category:${Fp} ${c.category}`),console.log(` ${ig}Model:${Fp} ${c.modelName}`),c.tags&&console.log(` ${ig}Tags:${Fp} ${c.tags}`),console.log(` ${ig}Author:${Fp} ${c.authorId}`),console.log(` ${ig}Version:${Fp} ${c.version}`),c.extInfo){if(c.extInfo["allowed-tools"]){let d=c.extInfo["allowed-tools"].split(",").map(p=>p.trim()).filter(p=>p);d.length>0?console.log(` ${ig}Allowed Tools:${Fp} ${d.join(", ")}`):c.extInfo["is-inherit-tools"]?console.log(` ${ig}Allowed Tools:${Fp} All tools available`):console.log(` ${ig}Allowed Tools:${Fp} No tools available`)}let u=c.extInfo["is-inherit-tools"];if(console.log(` ${ig}Inherit Tools:${Fp} ${u?"Yes":"No"}`),c.extInfo.mcps){let d=c.extInfo.mcps.split(",").map(p=>p.trim()).filter(p=>p);d.length>0?console.log(` ${ig}MCP Servers:${Fp} ${d.join(", ")}`):c.extInfo["is-inherit-mcps"]?console.log(` ${ig}MCP Servers:${Fp} All MCP servers available`):console.log(` ${ig}MCP Servers:${Fp} No MCP servers available`)}else c.extInfo["is-inherit-mcps"]?console.log(` ${ig}MCP Servers:${Fp} All MCP servers available`):console.log(` ${ig}MCP Servers:${Fp} No MCP servers available`);let f=c.extInfo["is-inherit-mcps"];console.log(` ${ig}Inherit MCPs:${Fp} ${f?"Yes":"No"}`)}console.log()}console.log(`${han}Total: ${a.length} agent(s) shown${s.total?` (${s.total} total available)`:""}${Fp}`),console.log(`${han}To install an agent, use: iflow agent add <name-or-id>${Fp}`)}catch(s){console.error("Error browsing online agents:",s),process.exit(1)}}var Y5o,han,z5o,ig,Fp,J5o,man,gan=Re(()=>{"use strict";Mf();Y5o="\x1B[32m",han="\x1B[33m",z5o="\x1B[34m",ig="\x1B[36m",Fp="\x1B[0m",J5o=async(t,e=1,r=20)=>{try{if(!t)return{success:!1,message:"Please authenticate first by running the auth command"};let i=await fetch("https://apis.iflow.cn/v1/agents/list",{method:"POST",headers:{Authorization:`Bearer ${t}`,"User-Agent":"iFlow-Cli","Content-Type":"application/json"},body:JSON.stringify({page:e,size:r})});if(!i.ok){let a="Unable to load agents. Please try again later";return i.status===401?a="Authentication failed. Please check your API key or re-authenticate":i.status===403?a="Access denied. Please check your permissions":i.status===404?a="Agents service not found. Please try again later":i.status>=500&&(a="Server error. Please try again later"),{success:!1,message:a}}let o=await i.json();return o.success?{success:!0,agents:Array.isArray(o.data.data)?o.data.data:[],total:o.data.total||0}:{success:!1,message:o.message||"Failed to load agents from server"}}catch(n){let i="Unable to load agents. Please check your connection and try again";return n instanceof Error&&n.message.includes("Failed to fetch")&&(i="Network error. Please check your internet connection"),{success:!1,message:i}}};man={command:"online",describe:"Browse online agent repository",builder:t=>t.usage("Usage: iflow agent online [options]").option("page",{alias:"p",describe:"Page number (default: 1)",type:"number",default:1}).option("size",{alias:"s",describe:"Number of agents per page (default: 20)",type:"number",default:20}).option("search",{describe:"Search term to filter agents",type:"string"}),handler:async t=>{await K5o({page:t.page,size:t.size,search:t.search})}}});var Aan={};o2(Aan,{agentCommand:()=>WEt});var WEt,YEt=Re(()=>{"use strict";san();can();fan();pan();gan();WEt={command:"agent",describe:"Manage agents",builder:t=>t.command(oan).command(lan).command(uan).command(dan).command(man).demandCommand(1,"You need at least one command before continuing.").version(!1),handler:()=>{}}});var Kan=B((QWs,Jan)=>{"use strict";var Fvo=we("os"),zan=we("tty"),_E=$Q(),{env:k0}=process,NR;_E("no-color")||_E("no-colors")||_E("color=false")||_E("color=never")?NR=0:(_E("color")||_E("colors")||_E("color=true")||_E("color=always"))&&(NR=1);"FORCE_COLOR"in k0&&(k0.FORCE_COLOR==="true"?NR=1:k0.FORCE_COLOR==="false"?NR=0:NR=k0.FORCE_COLOR.length===0?1:Math.min(parseInt(k0.FORCE_COLOR,10),3));function u5t(t){return t===0?!1:{level:t,hasBasic:!0,has256:t>=2,has16m:t>=3}}function f5t(t,e){if(NR===0)return 0;if(_E("color=16m")||_E("color=full")||_E("color=truecolor"))return 3;if(_E("color=256"))return 2;if(t&&!e&&NR===void 0)return 0;let r=NR||0;if(k0.TERM==="dumb")return r;if(process.platform==="win32"){let n=Fvo.release().split(".");return Number(n[0])>=10&&Number(n[2])>=10586?Number(n[2])>=14931?3:2:1}if("CI"in k0)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE"].some(n=>n in k0)||k0.CI_NAME==="codeship"?1:r;if("TEAMCITY_VERSION"in k0)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(k0.TEAMCITY_VERSION)?1:0;if(k0.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in k0){let n=parseInt((k0.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(k0.TERM_PROGRAM){case"iTerm.app":return n>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(k0.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(k0.TERM)||"COLORTERM"in k0?1:r}function Uvo(t){let e=f5t(t,t&&t.isTTY);return u5t(e)}Jan.exports={supportsColor:Uvo,stdout:u5t(f5t(!0,zan.isatty(1))),stderr:u5t(f5t(!0,zan.isatty(2)))}});var eln=B((qWs,Zan)=>{"use strict";var Qvo=Kan(),oK=$Q();function Xan(t){if(/^\d{3,4}$/.test(t)){let r=/(\d{1,2})(\d{2})/.exec(t);return{major:0,minor:parseInt(r[1],10),patch:parseInt(r[2],10)}}let e=(t||"").split(".").map(r=>parseInt(r,10));return{major:e[0],minor:e[1],patch:e[2]}}function d5t(t){let{env:e}=process;if("FORCE_HYPERLINK"in e)return!(e.FORCE_HYPERLINK.length>0&&parseInt(e.FORCE_HYPERLINK,10)===0);if(oK("no-hyperlink")||oK("no-hyperlinks")||oK("hyperlink=false")||oK("hyperlink=never"))return!1;if(oK("hyperlink=true")||oK("hyperlink=always")||"NETLIFY"in e)return!0;if(!Qvo.supportsColor(t)||t&&!t.isTTY||process.platform==="win32"||"CI"in e||"TEAMCITY_VERSION"in e)return!1;if("TERM_PROGRAM"in e){let r=Xan(e.TERM_PROGRAM_VERSION);switch(e.TERM_PROGRAM){case"iTerm.app":return r.major===3?r.minor>=1:r.major>3;case"WezTerm":return r.major>=20200620;case"vscode":return r.major>1||r.major===1&&r.minor>=72}}if("VTE_VERSION"in e){if(e.VTE_VERSION==="0.50.0")return!1;let r=Xan(e.VTE_VERSION);return r.major>0||r.minor>=50}return!1}Zan.exports={supportsHyperlink:d5t,stdout:d5t(process.stdout),stderr:d5t(process.stderr)}});var v5t={};o2(v5t,{AuthHandler:()=>E5t});var E5t,b5t=Re(()=>{"use strict";E5t=class{logger;constructor(e={}){this.logger=console}validateToken(e){return e.authToken?e.authToken.length<16?(console.error("Auth token appears to be invalid (too short)"),!1):!0:(console.error("No auth token found in server config"),!1)}buildAuthenticatedUrl(e){if(!this.validateToken(e))throw new Error("Invalid authentication token");return`${e.serverUrl.replace(/^http/,"ws")}/ws?token=${encodeURIComponent(e.authToken)}`}buildAuthHeaders(e){if(!this.validateToken(e))throw new Error("Invalid authentication token");return{Auttion:`Bearer ${e.authToken}`,"X-Auth-Token":e.authToken}}isTokenExpired(e,r=1440*60*1e3){let i=Date.now()-e.timestamp;return i>r?(console.warn(`Token is ${Math.floor(i/1e3/60)} minutes old`),!0):!1}}});var _5t={};o2(_5t,{WebSocketClientImpl:()=>C5t});import{EventEmitter as mbo}from"events";var C5t,S5t=Re(()=>{"use strict";SX();tTe();C5t=class extends mbo{ws;config;isConnectedFlag=!1;heartbeatInterval;reconnectTimer;reconnectAttempts=0;pendingResponses=new Map;options;constructor(e={}){super(),this.options={reconnectAttempts:e.reconnectAttempts??3,reconnectDelay:e.reconnectDelay??1e3,heartbeatInterval:e.heartbeatInterval??3e4,connectionTimeout:e.connectionTimeout??5e3,logger:console},this.on("error",r=>{if(r.code==="EPIPE"){console.debug("WebSocket EPIPE detected, disconnecting gracefully"),this.disconnect();return}this.options.logger.error("WebSocket error:",r)})}async connect(e){return this.config=e,this.reconnectAttempts=0,new Promise((r,n)=>{let i=setTimeout(()=>{n(new Error("Connection timeout")),this.disconnect()},this.options.connectionTimeout);try{let o=`${e.serverUrl}?token=${e.authToken}`;this.ws=new IQ(o),this.ws.on("open",()=>{clearTimeout(i),this.isConnectedFlag=!0,console.debug("WebSocket connected"),this.sendConnectMessage(),this.startHeartbeat(),r()}),this.ws.on("message",s=>{try{let a=JSON.parse(s.toString());this.handleMessage(a)}catch(a){console.log("error","Failed to parse WebSocket message:",a)}}),this.ws.on("error",s=>{if(clearTimeout(i),console.log("error","WebSocket error:",s),s.code==="EPIPE"){this.isConnectedFlag=!1,this.stopHeartbeat(),this.isConnectedFlag||n(new Error("WebSocket connection failed due to EPIPE"));return}this.emit("error",s),this.isConnectedFlag||n(s)}),this.ws.on("close",()=>{clearTimeout(i),this.isConnectedFlag=!1,this.stopHeartbeat(),this.emit("close"),this.reconnectAttempts<this.options.reconnectAttempts&&this.scheduleReconnect()})}catch(o){clearTimeout(i),n(o)}})}async disconnect(){this.isConnectedFlag=!1,this.stopHeartbeat(),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0);for(let[,e]of this.pendingResponses)clearTimeout(e.timeout),e.reject(new Error("Connection closed"));return this.pendingResponses.clear(),new Promise(e=>{this.ws&&this.ws.readyState===IQ.OPEN?(this.ws.once("close",()=>e()),this.ws.close()):e()})}isConnected(){return this.isConnectedFlag&&this.ws?.readyState===IQ.OPEN}async send(e){if(!this.isConnected())throw new Error("WebSocket is not connected");return new Promise((r,n)=>{try{let i=JSON.stringify(e);this.ws.send(i,o=>{o?n(o):r()})}catch(i){n(i)}})}async sendRequest(e,r=3e4){return e.id||(e.id=this.generateId()),new Promise((n,i)=>{let o=setTimeout(()=>{this.pendingResponses.delete(e.id),i(new Error(`Timeout for message ${e.id}`))},r);this.pendingResponses.set(e.id,{resolve:n,reject:i,timeout:o}),this.send(e).catch(s=>{this.pendingResponses.delete(e.id),clearTimeout(o),i(s)})})}onMessage(e){this.on("message",e)}onError(e){this.on("error",e)}onClose(e){this.on("close",e)}handleMessage(e){if(e.type==="response"&&e.id){let r=this.pendingResponses.get(e.id);if(r){clearTimeout(r.timeout),this.pendingResponses.delete(e.id);let n=e.payload;n.success?r.resolve(n.data):r.reject(new Error(n.error||"Request failed"));return}}if(e.type!=="pong"){if(e.type==="active_file_changed"){this.emit("activeFileChanged",e.payload);return}if(e.type==="selection_changed"){this.emit("selectionChanged",e.payload);return}this.emit("message",e)}}sendConnectMessage(){let e={clientInfo:{version:"0.2.14",platform:process.platform,workingDirectory:process.cwd()}},r={type:"cli_connect",timestamp:Date.now(),payload:e};this.send(r).catch(n=>{console.log("error","Failed to send connect message:",n)})}startHeartbeat(){this.heartbeatInterval=setInterval(()=>{if(this.isConnected()){let e={type:"ping",timestamp:Date.now()};this.send(e).catch(r=>{console.log("error","Failed to send ping:",r)})}},this.options.heartbeatInterval)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=void 0)}scheduleReconnect(){this.reconnectAttempts++;let e=this.options.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.info(`Scheduling reconnect attempt ${this.reconnectAttempts} in ${e}ms`),this.reconnectTimer=setTimeout(()=>{this.config&&this.connect(this.config).catch(r=>{console.log("error","Reconnect failed:",r)})},e)}generateId(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}}});var eun=B(VF=>{VF.parse=VF.decode=Kbo;VF.stringify=VF.encode=Kcn;VF.safe=yK;VF.unsafe=fRe;var W5t=typeof process<"u"&&process.platform==="win32"?`\r
|
|
2474
2474
|
`:`
|
|
2475
2475
|
`;function Kcn(t,e){var r=[],n="";typeof e=="string"?e={section:e,whitespace:!1}:(e=e||{},e.whitespace=e.whitespace===!0);var i=e.whitespace?" = ":"=";return Object.keys(t).forEach(function(o,s,a){var c=t[o];c&&Array.isArray(c)?c.forEach(function(u){n+=yK(o+"[]")+i+yK(u)+`
|
|
2476
2476
|
`}):c&&typeof c=="object"?r.push(o):n+=yK(o)+i+yK(c)+W5t}),e.section&&n.length&&(n="["+yK(e.section)+"]"+W5t+n),r.forEach(function(o,s,a){var c=Xcn(o).join("\\."),u=(e.section?e.section+".":"")+c,f=Kcn(t[o],{section:u,whitespace:e.whitespace});n.length&&f.length&&(n+=W5t),n+=f}),n}function Xcn(t){return t.replace(/\1/g,"LITERAL\\1LITERAL").replace(/\\\./g,"").split(/\./).map(function(e){return e.replace(/\1/g,"\\.").replace(/\2LITERAL\\1LITERAL\2/g,"")})}function Kbo(t){var e={},r=e,n=null,i=/^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i,o=t.split(/[\r\n]+/g);return o.forEach(function(s,a,c){if(!(!s||s.match(/^\s*[;#]/))){var u=s.match(i);if(u){if(u[1]!==void 0){if(n=fRe(u[1]),n==="__proto__"){r={};return}r=e[n]=e[n]||{};return}var f=fRe(u[2]);if(f!=="__proto__"){var d=u[3]?fRe(u[4]):!0;switch(d){case"true":case"false":case"null":d=JSON.parse(d)}if(f.length>2&&f.slice(-2)==="[]"){if(f=f.substring(0,f.length-2),f==="__proto__")return;r[f]?Array.isArray(r[f])||(r[f]=[r[f]]):r[f]=[]}Array.isArray(r[f])?r[f].push(d):r[f]=d}}}}),Object.keys(e).filter(function(s,a,c){if(!e[s]||typeof e[s]!="object"||Array.isArray(e[s]))return!1;var u=Xcn(s),f=e,d=u.pop(),p=d.replace(/\\\./g,".");return u.forEach(function(h,g,A){h!=="__proto__"&&((!f[h]||typeof f[h]!="object")&&(f[h]={}),f=f[h])}),f===e&&p===d?!1:(f[p]=e[s],!0)}).forEach(function(s,a,c){delete e[s]}),e}function Zcn(t){return t.charAt(0)==='"'&&t.slice(-1)==='"'||t.charAt(0)==="'"&&t.slice(-1)==="'"}function yK(t){return typeof t!="string"||t.match(/[=\r\n]/)||t.match(/^\[/)||t.length>1&&Zcn(t)||t!==t.trim()?JSON.stringify(t):t.replace(/;/g,"\\;").replace(/#/g,"\\#")}function fRe(t,e){if(t=(t||"").trim(),Zcn(t)){t.charAt(0)==="'"&&(t=t.substr(1,t.length-2));try{t=JSON.parse(t)}catch{}}else{for(var r=!1,n="",i=0,o=t.length;i<o;i++){var s=t.charAt(i);if(r)"\\;#".indexOf(s)!==-1?n+=s:n+="\\"+s,r=!1;else{if(";#".indexOf(s)!==-1)break;s==="\\"?r=!0:n+=s}}return r&&(n+="\\"),n.trim()}return t}});var nun=B((uta,run)=>{"use strict";var Y5t=1,tun=2;function Xbo(){return""}function Zbo(t,e,r){return t.slice(e,r).replace(/\S/g," ")}run.exports=function(t,e){e=e||{};for(var r,n,i=!1,o=!1,s=0,a="",c=e.whitespace===!1?Xbo:Zbo,u=0;u<t.length;u++){if(r=t[u],n=t[u+1],!o&&r==='"'){var f=t[u-1]==="\\"&&t[u-2]!=="\\";f||(i=!i)}if(!i){if(!o&&r+n==="//")a+=t.slice(s,u),s=u,o=Y5t,u++;else if(o===Y5t&&r+n===`\r
|
|
@@ -2687,7 +2687,7 @@ Logging in with Google... Please restart iFlow CLI to continue.
|
|
|
2687
2687
|
`,e-1);return{line:r===-1?0:t.slice(0,r+1).match(/\n/g).length,column:e-r-1}}function kyt(t,e,{oneBased:r=!1}={}){if(typeof t!="string")throw new TypeError("Text parameter should be a string");if(!Number.isInteger(e))throw new TypeError("Index parameter should be an integer");if(e<0||e>t.length)throw new RangeError("Index out of bounds");let n=Gmo(t,e);return r?{line:n.line+1,column:n.column+1}:n}var jmo=t=>`\\u{${t.codePointAt(0).toString(16)}}`,Lyt=class t extends Error{name="JSONError";fileName;#e;#t;#r;#n;#o;constructor(e){if(typeof e=="string")super(),this.#r=e;else{let{jsonParseError:r,fileName:n,input:i}=e;super(void 0,{cause:r}),this.#e=i,this.#t=r,this.fileName=n}Error.captureStackTrace?.(this,t)}get message(){this.#r??=`${$mo(this.#t.message)}${this.#e===""?" while parsing empty string":""}`;let{codeFrame:e}=this;return`${this.#r}${this.fileName?` in ${this.fileName}`:""}${e?`
|
|
2688
2688
|
|
|
2689
2689
|
${e}
|
|
2690
|
-
`:""}`}set message(e){this.#r=e}#i(e){if(!this.#t)return;let r=this.#e,n=Vmo(r,this.#t.message);if(n)return(0,yKr.codeFrameColumns)(r,{start:n},{highlightCode:e})}get codeFrame(){return this.#n??=this.#i(!0),this.#n}get rawCodeFrame(){return this.#o??=this.#i(!1),this.#o}},Vmo=(t,e)=>{let r=e.match(/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/);if(!r)return;let{index:n,line:i,column:o}=r.groups;return i&&o?{line:Number(i),column:Number(o)}:kyt(t,Number(n),{oneBased:!0})},$mo=t=>t.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(e,r,n)=>`"${n}"(${jmo(n)})`);function Pyt(t,e,r){typeof e=="string"&&(r=e,e=void 0);try{return JSON.parse(t,e)}catch(n){throw new Lyt({jsonParseError:n,fileName:r,input:t})}}var mXr=ze(pXr(),1);import{fileURLToPath as jgo}from"node:url";function hXr(t){return t instanceof URL?jgo(t):t}var Wgo=t=>$go.resolve(hXr(t)??".","package.json"),Ygo=(t,e)=>{let r=typeof t=="string"?Pyt(t):t;return e&&(0,mXr.default)(r),r};async function gXr({cwd:t,normalize:e=!0}={}){let r=await Vgo.readFile(Wgo(t),"utf8");return Ygo(r,e)}async function AXr(t){let e=await WJr("package.json",t);if(e)return{packageJson:await gXr({...t,cwd:zgo.dirname(e)}),path:e}}import{fileURLToPath as Jgo}from"url";import Kgo from"path";var Xgo=Jgo(import.meta.url),Zgo=Kgo.dirname(Xgo),TTe;async function hJ(){if(TTe)return TTe;let t=await AXr({cwd:Zgo});if(t)return TTe=t.packageJson,TTe}async function Y9(){let t=await hJ();return"0.2.
|
|
2690
|
+
`:""}`}set message(e){this.#r=e}#i(e){if(!this.#t)return;let r=this.#e,n=Vmo(r,this.#t.message);if(n)return(0,yKr.codeFrameColumns)(r,{start:n},{highlightCode:e})}get codeFrame(){return this.#n??=this.#i(!0),this.#n}get rawCodeFrame(){return this.#o??=this.#i(!1),this.#o}},Vmo=(t,e)=>{let r=e.match(/in JSON at position (?<index>\d+)(?: \(line (?<line>\d+) column (?<column>\d+)\))?$/);if(!r)return;let{index:n,line:i,column:o}=r.groups;return i&&o?{line:Number(i),column:Number(o)}:kyt(t,Number(n),{oneBased:!0})},$mo=t=>t.replace(/(?<=^Unexpected token )(?<quote>')?(.)\k<quote>/,(e,r,n)=>`"${n}"(${jmo(n)})`);function Pyt(t,e,r){typeof e=="string"&&(r=e,e=void 0);try{return JSON.parse(t,e)}catch(n){throw new Lyt({jsonParseError:n,fileName:r,input:t})}}var mXr=ze(pXr(),1);import{fileURLToPath as jgo}from"node:url";function hXr(t){return t instanceof URL?jgo(t):t}var Wgo=t=>$go.resolve(hXr(t)??".","package.json"),Ygo=(t,e)=>{let r=typeof t=="string"?Pyt(t):t;return e&&(0,mXr.default)(r),r};async function gXr({cwd:t,normalize:e=!0}={}){let r=await Vgo.readFile(Wgo(t),"utf8");return Ygo(r,e)}async function AXr(t){let e=await WJr("package.json",t);if(e)return{packageJson:await gXr({...t,cwd:zgo.dirname(e)}),path:e}}import{fileURLToPath as Jgo}from"url";import Kgo from"path";var Xgo=Jgo(import.meta.url),Zgo=Kgo.dirname(Xgo),TTe;async function hJ(){if(TTe)return TTe;let t=await AXr({cwd:Zgo});if(t)return TTe=t.packageJson,TTe}async function Y9(){let t=await hJ();return"0.2.14"}Oa();import aF from"node:process";var yXr={name:"about",description:"show version info",kind:"built-in",action:async t=>{let e=aF.platform,r="no sandbox";aF.env.SANDBOX&&aF.env.SANDBOX!=="sandbox-exec"?r=aF.env.SANDBOX:aF.env.SANDBOX==="sandbox-exec"&&(r=`sandbox-exec (${aF.env.SEATBELT_PROFILE||"unknown"})`);let n=t.services.config?.getModel()||"Unknown",i=await Y9(),o=t.services.settings.merged.selectedAuthType||"",s=aF.env.GOOGLE_CLOUD_PROJECT||"",a={type:"about",cliVersion:i,osVersion:e,sandboxEnv:r,modelVersion:n,selectedAuthType:o,gcpProject:s};t.ui.addItem(a,Date.now())}};rn();Oa();var ITe="\x1B[32m";var vXr="\x1B[31m",Fv="\x1B[36m",H2="\x1B[90m";var Pa="\x1B[0m";function DTe(t,e,r,n=!1){let i="";if(t.length===0)return i="\u{1F534} ",`${i}${e}
|
|
2691
2691
|
${vXr}No agents found${Pa}
|
|
2692
2692
|
`;i="\u{1F7E2} ";let o=`${i}${e}
|
|
2693
2693
|
`;for(let s of t)n?o+=e1o(s):o+=`${ITe}- ${s.agentType}${Pa}
|
|
@@ -2730,7 +2730,7 @@ ${H2}Built-in agents (always available)${Pa}
|
|
|
2730
2730
|
${H2}- general-purpose
|
|
2731
2731
|
${Pa}`;let c=n.length+i.length;t.ui.addItem({type:"info",text:`${ITe}Agents refreshed successfully. Found ${c} agents.${Pa}
|
|
2732
2732
|
|
|
2733
|
-
${ITe}${a.trim()}${Pa}`},Date.now())}catch(e){let r=_r(e);t.ui.addItem({type:"error",text:`${vXr}Error refreshing agents: ${r}${Pa}`},Date.now())}}},{name:"online",description:"Browse and install agents from online repository",kind:"built-in",action:(t,e)=>({type:"dialog",dialog:"agents-online"})},{name:"install",description:"Install a new agent with guided setup",kind:"built-in",action:(t,e)=>({type:"dialog",dialog:"agent-install"})}]};Oa();var CXr={name:"auth",description:"change the auth method",kind:"built-in",action:(t,e)=>({type:"dialog",dialog:"auth"})};Bq();Oa();import GS from"node:process";import t1o from"node:os";var mJ="
|
|
2733
|
+
${ITe}${a.trim()}${Pa}`},Date.now())}catch(e){let r=_r(e);t.ui.addItem({type:"error",text:`${vXr}Error refreshing agents: ${r}${Pa}`},Date.now())}}},{name:"online",description:"Browse and install agents from online repository",kind:"built-in",action:(t,e)=>({type:"dialog",dialog:"agents-online"})},{name:"install",description:"Install a new agent with guided setup",kind:"built-in",action:(t,e)=>({type:"dialog",dialog:"agent-install"})}]};Oa();var CXr={name:"auth",description:"change the auth method",kind:"built-in",action:(t,e)=>({type:"dialog",dialog:"auth"})};Bq();Oa();import GS from"node:process";import t1o from"node:os";var mJ="b5f3ea2a (local modifications)";rn();var _Xr={name:"bug",description:"submit a bug report",kind:"built-in",action:async(t,e)=>{let r=(e||"").trim(),{config:n}=t.services,i=HN(),o=`${GS.platform} ${GS.version}`,s="no sandbox";GS.env.SANDBOX&&GS.env.SANDBOX!=="sandbox-exec"?s=GS.env.SANDBOX.replace(/^iflow-(?:code-)?/,""):GS.env.SANDBOX==="sandbox-exec"&&(s=`sandbox-exec (${GS.env.SEATBELT_PROFILE||"unknown"})`);let a=n?.getModel()||"Unknown",c=await Y9(),u=iJ(GS.memoryUsage().rss),f=i.getInMemoryErrors(),d="No recent errors";f.length>0&&(d=f.slice(-3).map(N=>`Error (${N.timestamp}):
|
|
2734
2734
|
${N.error}`).join(`
|
|
2735
2735
|
|
|
2736
2736
|
`));let p=t1o.userInfo().username,h=T=>{if(!p)return T;let N=new RegExp(`/${p}/`,"g");return T.replace(N,"/user/")},g=`CLI Version: ${c}
|
|
@@ -3485,7 +3485,7 @@ def fibonacci(n):
|
|
|
3485
3485
|
`,availableTerminalHeight:de,terminalWidth:G,theme:te})]})})()]})]}),(0,R0.jsx)(Ee,{marginTop:1,children:(0,R0.jsxs)(se,{color:ve.Gray,wrap:"truncate",children:["(Use Enter to select",ge?", Tab to change focus":"",")"]})})]})}var nC=ze(wr(),1);var GJ=ze(wr(),1);var F6o=/^[a-zA-Z0-9!@#$%^&*()\-_=+\[\]{}|\\:;"'<>,.?/~]+$/;function $De(t){return!t||t.trim().length===0?!1:F6o.test(t)}var xy=ze(Wt(),1);function jJ({onSubmit:t,onCancel:e,placeholder:r="Enter your API key...",label:n="API Key:",isFocused:i=!0,validateApiKey:o=!1,validationError:s="Invalid API key format. Only English letters, digits, and special characters are allowed."}){let[a,c]=(0,GJ.useState)(""),[u,f]=(0,GJ.useState)(!0),[d,p]=(0,GJ.useState)(null);(0,GJ.useEffect)(()=>{if(!i)return;let A=setInterval(()=>{f(y=>!y)},500);return()=>clearInterval(A)},[i]),kJ(A=>{if(A.name==="return"||A.name==="enter"){if(a.trim()){let y=a.trim().replace(/^~+|~+$/g,"");if(o&&!$De(y)){p(s);return}p(null),t(y)}return}if(A.name==="escape"){e?.();return}if(A.name==="backspace"||A.name==="delete"){c(y=>y.slice(0,-1));return}if(A.paste&&A.sequence){let y=A.sequence.split("").filter(v=>{let S=v.charCodeAt(0);return S>=32&&S<=126||o&&$De(v)}).join("");y&&c(v=>v+y);return}if(A.sequence&&!A.ctrl&&!A.meta&&A.sequence.length===1){let y=A.sequence;(y.charCodeAt(0)>=32&&y.charCodeAt(0)<=126||o&&$De(y))&&c(v=>v+y)}},{isActive:i});let h="\u2022".repeat(a.length),g=u&&i?"\u2502":"";return(0,xy.jsxs)(Ee,{flexDirection:"column",children:[(0,xy.jsx)(Ee,{children:(0,xy.jsxs)(se,{color:ve.Gray,children:[n," "]})}),(0,xy.jsx)(Ee,{marginTop:1,children:(0,xy.jsx)(Ee,{borderStyle:"round",borderColor:d?ve.AccentRed:i?ve.AccentBlue:ve.Gray,paddingX:1,width:"100%",children:(0,xy.jsxs)(se,{children:[h||(0,xy.jsx)(se,{color:ve.Gray,children:r}),g]})})}),d&&(0,xy.jsx)(Ee,{marginTop:1,children:(0,xy.jsx)(se,{color:ve.AccentRed,children:d})}),(0,xy.jsx)(Ee,{marginTop:1,children:(0,xy.jsx)(se,{color:ve.Gray,dimColor:!0,children:"Press Enter to confirm, Escape to cancel"})})]})}var Que=ze(wr(),1);var Uv=ze(Wt(),1);function Ty({onSubmit:t,onCancel:e,placeholder:r="Enter value...",label:n="Input:",isFocused:i=!0,defaultValue:o="",allowEmpty:s=!1}){let[a,c]=(0,Que.useState)(o),[u,f]=(0,Que.useState)(!0);(0,Que.useEffect)(()=>{if(!i)return;let p=setInterval(()=>{f(h=>!h)},500);return()=>clearInterval(p)},[i]),kJ(p=>{if(p.name==="return"||p.name==="enter"){(a.trim()||s)&&t(a.trim());return}if(p.name==="escape"){e?.();return}if(!(p.name==="up"||p.name==="down"||p.name==="left"||p.name==="right")){if(p.name==="backspace"||p.name==="delete"){c(h=>h.slice(0,-1));return}p.sequence&&!p.ctrl&&!p.meta&&c(h=>h+p.sequence)}},{isActive:i});let d=u&&i?"\u2502":"";return(0,Uv.jsxs)(Ee,{flexDirection:"column",children:[(0,Uv.jsx)(Ee,{children:(0,Uv.jsxs)(se,{color:ve.Gray,children:[n," "]})}),(0,Uv.jsx)(Ee,{marginTop:1,children:(0,Uv.jsx)(Ee,{borderStyle:"round",borderColor:i?ve.AccentBlue:ve.Gray,paddingX:1,width:"100%",children:(0,Uv.jsxs)(se,{children:[a||(0,Uv.jsx)(se,{color:ve.Gray,children:r}),d]})})}),(0,Uv.jsx)(Ee,{marginTop:1,children:(0,Uv.jsx)(se,{color:ve.Gray,dimColor:!0,children:"Press Enter to confirm, Escape to cancel"})})]})}Mf();rn();rn();Mf();var yF=t=>{if(PTe(),t===Jr.LOGIN_WITH_GOOGLE||t===Jr.CLOUD_SHELL)return null;if(t===Jr.USE_GEMINI)return process.env.GEMINI_API_KEY?null:"GEMINI_API_KEY environment variable not found. Add that to your environment and try again (no reload needed if using .env)!";if(t===Jr.USE_VERTEX_AI){let e=!!process.env.GOOGLE_CLOUD_PROJECT&&!!process.env.GOOGLE_CLOUD_LOCATION,r=!!process.env.GOOGLE_API_KEY;return!e&&!r?`When using Vertex AI, you must specify either:
|
|
3486
3486
|
\u2022 GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables.
|
|
3487
3487
|
\u2022 GOOGLE_API_KEY environment variable (if using express mode).
|
|
3488
|
-
Update your environment and try again (no reload needed if using .env)!`:null}return[...Kh,Jr.OPENAI_COMPATIBLE].includes(t)?null:"Invalid auth method selected."};var li=ze(Wt(),1);function $nn(t){return t&&Object.values(Jr).includes(t)?t:null}function Wnn({onSelect:t,settings:e,initialErrorMessage:r}){let[n,i]=(0,nC.useState)("select"),[o,s]=(0,nC.useState)(null),[a,c]=(0,nC.useState)({baseUrl:"",apiKey:""}),[u,f]=(0,nC.useState)("baseUrl"),[d,p]=(0,nC.useState)(""),[h,g]=(0,nC.useState)(""),[A,y]=(0,nC.useState)(""),[v,S]=(0,nC.useState)(""),[w,T]=(0,nC.useState)(()=>{if(r)return r;let X=$nn(process.env.GEMINI_DEFAULT_AUTH_TYPE);return null}),N=[{label:"iFlow: Quick setup and free model to use(recommend)",value:Jr.IFLOW},{label:"OpenAI Compatible API",value:Jr.OPENAI_COMPATIBLE}],P=Math.max(0,N.findIndex(X=>{if(e.merged.selectedAuthType)return X.value===e.merged.selectedAuthType;let J=$nn(process.env.GEMINI_DEFAULT_AUTH_TYPE);return J?X.value===J:process.env.GEMINI_API_KEY?X.value===Jr.USE_GEMINI:X.value===Jr.LOGIN_WITH_GOOGLE})),U=X=>{if(Kh.includes(X))s(X),i("input-api-key"),T(null);else if(X===Jr.OPENAI_COMPATIBLE)s(X),i("input-openai-config"),f("baseUrl"),c({baseUrl:"",apiKey:""}),T(null);else{let J=yF(X);J?T(J):(T(null),t(X,"User"))}},Q=X=>{o&&Kh.includes(o)&&(y(X),i("input-model-name"),p(""))},D=X=>{if(u==="baseUrl")c(J=>({...J,baseUrl:X})),f("apiKey");else if(u==="apiKey")c(J=>({...J,apiKey:X})),f("modelName");else if(u==="modelName"){if(c(he=>({...he,modelName:X})),p(X),!z6.isMultimodalModel(X)){i("input-multimodal-model"),g("");return}i("input-search-api-key"),S("")}},F=()=>{i("select"),s(null),T(null)},O=()=>{u==="modelName"?f("apiKey"):u==="apiKey"?f("baseUrl"):(i("select"),s(null),c({baseUrl:"",apiKey:""}),f("baseUrl"),T(null))},q=X=>{if(o&&Kh.includes(o)){if(p(X),!z6.isMultimodalModel(X)&&o!==Jr.IFLOW){i("input-multimodal-model"),g("");return}if(o===Jr.IFLOW){let he={baseUrl:"https://apis.iflow.cn/v1",apiKey:A,modelName:X,searchApiKey:A,multimodalModelName:"qwen-vl-max"};t(o,"User",he)}else i("input-search-api-key"),S("")}},L=X=>{if(o&&Kh.includes(o)){if(p(X),!z6.isMultimodalModel(X)&&o!==Jr.IFLOW){i("input-multimodal-model"),g("");return}if(o===Jr.IFLOW){let he={baseUrl:"https://apis.iflow.cn/v1",apiKey:A,modelName:X,searchApiKey:A,multimodalModelName:"qwen-vl-max"};t(o,"User",he)}else i("input-search-api-key"),S("")}},M=()=>{o&&Kh.includes(o)?i("input-api-key"):(i("input-openai-config"),f("apiKey"))},j=X=>{let J=X.trim();g(J),(o&&Kh.includes(o)||o===Jr.OPENAI_COMPATIBLE)&&(i("input-search-api-key"),S(""))},G=()=>{o===Jr.OPENAI_COMPATIBLE?(i("input-openai-config"),f("modelName")):i("input-model-name")},W=X=>{if(o&&Kh.includes(o)){let J={...o===Jr.IFLOW&&{baseUrl:"https://apis.iflow.cn/v1"},apiKey:A,modelName:d,searchApiKey:o===Jr.IFLOW?A:X,multimodalModelName:h||"qwen-vl-max"};t(o,"User",J)}else if(o===Jr.OPENAI_COMPATIBLE){let J={...a,searchApiKey:X,multimodalModelName:h||""};t(o,"User",J)}},V=()=>{o===Jr.OPENAI_COMPATIBLE?h!==""?i("input-multimodal-model"):(i("input-openai-config"),f("modelName")):i(h!==""?"input-multimodal-model":"input-model-name")};if(Vi((X,J)=>{if(J.escape){if(w)return;if(e.merged.selectedAuthType===void 0){T("You must select an auth method to proceed. Press Ctrl+C twice to exit.");return}t(void 0,"User")}}),n==="input-api-key")return(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"iFlow Authentication"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Please enter your iFlow API key. See: https://docs.iflow.cn/docs/"})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(jJ,{onSubmit:Q,onCancel:F,label:"API Key:",placeholder:"Enter your iFlow API key...",isFocused:!0,validateApiKey:!0})})]});if(n==="input-model-name"){if(o===Jr.IFLOW){let X=[{label:"Qwen3-Coder-480B-A35B(recommend)",value:"Qwen3-Coder"},{label:"Qwen3-Max",value:"qwen3-max-preview"},{label:"Kimi-K2-0905",value:"kimi-k2-0905"},{label:"Qwen3-235B-A22B",value:"Qwen3-235B"},{label:"GLM-4.5",value:"glm-4.5"},{label:"DeepSeek-V3.1",value:"deepseek-v3.1"},{label:"Qwen3-235B-A22B-Thinking",value:"Qwen3-235B-A22B-Thinking-2507"},{label:"Qwen3-235B-A22B-Instruct",value:"Qwen3-235B-A22B-Instruct"},{label:"Qwen-VL-Max(direct multimodal)",value:"qwen-vl-max"}];return(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"Model Configuration"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Please select the model you want to use."})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{color:ve.AccentBlue,children:"Enter To Use Default selection: Qwen3 Coder"})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(Pp,{items:X,initialIndex:0,onSelect:L,isFocused:!0})})]})}return(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"Model Configuration"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Please enter the model name you want to use."})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(Ty,{onSubmit:q,onCancel:M,label:"Model Name:",placeholder:"Enter model name (e.g. Qwen3-Coder)",isFocused:!0})})]})}return n==="input-multimodal-model"?(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"Multimodal Model Configuration"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Please enter a multimodal model name for image description generation."})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{color:ve.AccentYellow,children:"Leave empty to disable multimodal support."})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(Ty,{onSubmit:j,onCancel:G,label:"Multimodal Model:",placeholder:"Enter multimodal model name or leave empty",isFocused:!0,allowEmpty:!0})})]}):n==="input-search-api-key"?(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"Search API Configuration"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Please enter your Search API key for web search functionality."})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(jJ,{onSubmit:W,onCancel:V,label:"Search API Key:",placeholder:"https://docs.iflow.cn/docs/ Enter your iFlow search API key... ",isFocused:!0,validateApiKey:!0})})]}):n==="input-openai-config"?(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"OpenAI Compatible API Configuration"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:u==="baseUrl"?"Please enter the base URL for your OpenAI compatible API.":u==="apiKey"?"Please enter your API key.":"Please enter the model name."})}),(0,li.jsx)(Ee,{marginTop:1,children:u==="baseUrl"?(0,li.jsx)(Ty,{onSubmit:D,onCancel:O,label:"Base URL:",placeholder:"https://api.openai.com/v1",isFocused:!0}):u==="apiKey"?(0,li.jsx)(jJ,{onSubmit:D,onCancel:O,label:"API Key:",placeholder:"Enter your API key...",isFocused:!0,validateApiKey:!0}):(0,li.jsx)(Ty,{onSubmit:D,onCancel:O,label:"Model Name:",placeholder:"Enter model name (e.g. gpt-4)",isFocused:!0})}),u==="baseUrl"&&a.baseUrl&&(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsxs)(se,{color:ve.Gray,children:["Current: ",a.baseUrl]})})]}):(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"Get started"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"How would you like to authenticate for this project?"})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(Pp,{items:N,initialIndex:P,onSelect:U,isFocused:!0})}),w&&(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{color:ve.AccentRed,children:w})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{color:ve.Gray,children:"(Use Enter to select)"})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Terms of Services and Privacy Notice for iFlow CLI"})})]})}var WDe=ze(wr(),1);var EF=ze(Wt(),1);function Ynn({onTimeout:t}){let[e,r]=(0,WDe.useState)(!1);return Vi((n,i)=>{i.escape&&t()}),(0,WDe.useEffect)(()=>{let n=setTimeout(()=>{r(!0),t()},18e4);return()=>clearTimeout(n)},[t]),(0,EF.jsx)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:e?(0,EF.jsx)(se,{color:ve.AccentRed,children:"Authentication timed out. Please try again."}):(0,EF.jsx)(Ee,{children:(0,EF.jsxs)(se,{children:[(0,EF.jsx)(TJ,{type:"dots"})," Waiting for auth... (Press ESC to cancel)"]})})})}var pf=ze(Wt(),1);function znn({onContinue:t}){return Vi((e,r)=>{(r.return||e===" ")&&t()}),(0,pf.jsxs)(Ee,{borderStyle:"round",borderColor:ve.AccentBlue,flexDirection:"column",padding:1,width:"100%",children:[(0,pf.jsx)(se,{bold:!0,color:ve.AccentBlue,children:"\u{1F680} Examples & Getting Started"}),(0,pf.jsx)(Ee,{marginTop:1,children:(0,pf.jsx)(se,{children:"Welcome to iFlow CLI! Check out these examples to get the most out of your experience:"})}),(0,pf.jsx)(Ee,{marginTop:1,children:(0,pf.jsx)(se,{bold:!0,color:ve.AccentPurple,children:"\u{1F4DA} Examples Repository:"})}),(0,pf.jsx)(Ee,{marginTop:1,marginLeft:2,children:(0,pf.jsx)(se,{color:ve.AccentBlue,children:"https://platform.iflow.cn/cli/examples/"})}),(0,pf.jsx)(Ee,{marginTop:1,children:(0,pf.jsx)(se,{bold:!0,color:ve.AccentPurple,children:"\u{1F4A1} Quick Tips:"})}),(0,pf.jsx)(Ee,{marginTop:1,marginLeft:2,children:(0,pf.jsx)(se,{children:"\u2022 Use @ to include file contents in your prompt"})}),(0,pf.jsx)(Ee,{marginLeft:2,children:(0,pf.jsx)(se,{children:"\u2022 Use ! to execute shell commands directly"})}),(0,pf.jsx)(Ee,{marginLeft:2,children:(0,pf.jsx)(se,{children:"\u2022 Use /init to create IFLOW.md for better context"})}),(0,pf.jsx)(Ee,{marginLeft:2,children:(0,pf.jsx)(se,{children:"\u2022 Use /demo to try research and brainstorming workflows"})}),(0,pf.jsx)(Ee,{marginLeft:2,children:(0,pf.jsx)(se,{children:"\u2022 Use /help to see all available commands"})}),(0,pf.jsx)(Ee,{marginTop:2,children:(0,pf.jsx)(se,{bold:!0,color:ve.AccentGreen,children:"Press Enter or Space to continue to chat \u2192"})})]})}var Jnn=ze(wr(),1);Mf();rn();var hf=ze(Wt(),1);function Knn({onSelect:t,onCancel:e,settings:r,initialErrorMessage:n}){let i=r.merged.selectedAuthType===Jr.IFLOW?"model-select":"model-input",[o,s]=(0,Jnn.useState)(n||null),a=f=>{t(f,"User")},c=f=>{if(!f.trim()){s("Model name cannot be empty");return}t(f.trim(),"User")},u=()=>{e()};if(Vi((f,d)=>{d.escape&&e()}),i==="model-select"){let f=[{label:"Qwen3-Coder-480B-A35B(recommend)",value:"Qwen3-Coder"},{label:"Qwen3-Max",value:"qwen3-max-preview"},{label:"Kimi-K2-0905",value:"kimi-k2-0905"},{label:"Qwen3-235B-A22B",value:"Qwen3-235B"},{label:"GLM-4.5",value:"glm-4.5"},{label:"DeepSeek-V3.1",value:"deepseek-v3.1"},{label:"Qwen3-235B-A22B-Thinking",value:"Qwen3-235B-A22B-Thinking-2507"},{label:"Qwen3-235B-A22B-Instruct",value:"Qwen3-235B-A22B-Instruct"},{label:"Qwen-VL-Max(direct multimodal)",value:"qwen-vl-max"}];return(0,hf.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,hf.jsx)(se,{bold:!0,children:"Model Selection"}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{children:"Please select the model you want to use with iFlow."})}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{color:ve.AccentBlue,children:"Enter To Use Default selection: Qwen3 Coder"})}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(Pp,{items:f,initialIndex:0,onSelect:a,isFocused:!0})}),o&&(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{color:ve.AccentRed,children:o})}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{color:ve.Gray,children:"(Use Enter to select, Esc to cancel)"})})]})}return(0,hf.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,hf.jsx)(se,{bold:!0,children:"Model Configuration"}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{children:"Please enter the model name you want to use."})}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(Ty,{onSubmit:c,onCancel:u,label:"Model Name:",placeholder:"Enter model name (e.g. gpt-4o, claude-3-5-sonnet)",isFocused:!0})}),o&&(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{color:ve.AccentRed,children:o})}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{color:ve.Gray,children:"(Press Enter to confirm, Esc to cancel)"})})]})}var YDe=ze(wr(),1);var B0=ze(Wt(),1);function zDe({serverName:t,values:e,onComplete:r,onCancel:n}){let i=Object.keys(e),[o,s]=(0,YDe.useState)(0),[a,c]=(0,YDe.useState)({}),[u,f]=(0,YDe.useState)(null),d=i[o],p=e[d],h=o===i.length-1,g=v=>{if(p.type==="int"){let w=Number(v);if(isNaN(w)||!Number.isInteger(w)){f("Please enter a valid integer number");return}}f(null);let S={...a,[d]:v};c(S),h?r(S):s(o+1)},A=()=>{o>0?(s(o-1),f(null)):n()},y=()=>{let v=p.default||`Enter ${d.toLowerCase()}...`,S=`${d}:`;switch(p.type){case"password":return(0,B0.jsx)(jJ,{onSubmit:g,onCancel:A,label:S,placeholder:v,isFocused:!0,validateApiKey:!0});case"int":return(0,B0.jsx)(Ty,{onSubmit:g,onCancel:A,label:S,placeholder:v,isFocused:!0});case"string":default:return(0,B0.jsx)(Ty,{onSubmit:g,onCancel:A,label:S,placeholder:v,isFocused:!0})}};return(0,B0.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,B0.jsxs)(se,{bold:!0,children:["MCP Server Configuration: ",t]}),(0,B0.jsx)(Ee,{marginTop:1,children:(0,B0.jsxs)(se,{children:["Step ",o+1," of ",i.length,": Configure ",d]})}),(0,B0.jsx)(Ee,{marginTop:1,children:(0,B0.jsx)(se,{color:ve.AccentBlue,children:p.description})}),p.type==="int"&&(0,B0.jsx)(Ee,{marginTop:1,children:(0,B0.jsx)(se,{color:ve.Gray,children:"Expected type: Integer number"})}),(0,B0.jsx)(Ee,{marginTop:2,children:y()}),u&&(0,B0.jsx)(Ee,{marginTop:1,children:(0,B0.jsx)(se,{color:ve.AccentRed,children:u})}),(0,B0.jsx)(Ee,{marginTop:1,children:(0,B0.jsx)(se,{color:ve.Gray,children:o>0?"Press Escape to go back":"Press Escape to cancel"})})]})}var JDe=ze(wr(),1);rn();var kl=ze(Wt(),1);function Xnn({onSelect:t,onCancel:e,requestedModel:r,reason:n,availableModels:i,suggestedModel:o,taskPrompt:s}){let[a,c]=(0,JDe.useState)(null),[u,f]=(0,JDe.useState)("model_selection"),[d,p]=(0,JDe.useState)(""),h=N=>{p(N),f("preference_selection")},g=N=>{t({selectedModel:d,preference:N})},A=()=>{e()},y=()=>{f("model_selection"),p("")};Vi((N,P)=>{P.escape&&(u==="preference_selection"?y():e())});let v=i.findIndex(N=>N.value===o),S=v>=0?v:0;if(u==="model_selection")return(0,kl.jsxs)(Ee,{borderStyle:"round",borderColor:ve.AccentRed,flexDirection:"column",padding:1,width:"100%",children:[(0,kl.jsx)(se,{bold:!0,color:ve.AccentRed,children:"Model Validation Required"}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{color:ve.AccentRed,children:["Model '",r,"' is not supported."]})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{color:ve.Gray,children:["Reason: ",n]})}),s&&(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{color:ve.Gray,children:["Task: ",s.length>100?`${s.substring(0,100)}...`:s]})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(se,{children:"Please select a supported model to continue:"})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{color:ve.AccentBlue,children:["Suggested: ",i.find(N=>N.value===o)?.label||o]})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(Pp,{items:i,initialIndex:S,onSelect:h,isFocused:!0})}),a&&(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(se,{color:ve.AccentRed,children:a})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(se,{color:ve.Gray,children:"(Use Enter to select, Esc to cancel)"})})]});let w=[{label:"No, ask me each time",value:s1.OnceOnly},{label:"Yes, remember for this session",value:s1.RememberSession},{label:"Yes, remember always",value:s1.RememberAlways}],T=i.find(N=>N.value===d)?.label||d;return(0,kl.jsxs)(Ee,{borderStyle:"round",borderColor:ve.AccentBlue,flexDirection:"column",padding:1,width:"100%",children:[(0,kl.jsx)(se,{bold:!0,color:ve.AccentBlue,children:"Model Preference"}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{children:["You selected: ",(0,kl.jsx)(se,{color:ve.AccentGreen,children:T})]})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{children:["In the future, when '",r,"' is not supported, would you like to always use '",T,"'?"]})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(Pp,{items:w,initialIndex:0,onSelect:g,isFocused:!0})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(se,{color:ve.Gray,children:"(Use Enter to select, Esc to go back)"})})]})}var D4t=ze(wr(),1);rn();var KDe={cursor:"Cursor",emacs:"Emacs",neovim:"Neovim",vim:"Vim",vscode:"VS Code",vscodium:"VSCodium",windsurf:"Windsurf",zed:"Zed"},T4t=class{availableEditors;constructor(){let e=Object.keys(KDe).sort();this.availableEditors=[{name:"None",type:"not_set",disabled:!1},...e.map(r=>{let n=DW(r),i=IW(r),o=i?"":" (Not available in sandbox)";return o=n?o:" (Not installed)",{name:KDe[r]+o,type:r,disabled:!n||!i}})]}getAvailableEditorDisplays(){return this.availableEditors}},Znn=new T4t;Mf();rn();var N0=ze(Wt(),1);function ein({onSelect:t,settings:e,onExit:r}){let[n,i]=(0,D4t.useState)("User"),[o,s]=(0,D4t.useState)("editor");Vi((y,v)=>{v.tab&&s(S=>S==="editor"?"scope":"editor"),v.escape&&r()});let a=Znn.getAvailableEditorDisplays(),c=e.forScope(n).settings.preferredEditor,u=c?a.findIndex(y=>y.type===c):0;u===-1&&(console.error(`Editor is not supported: ${c}`),u=0);let f=[{label:"User Settings",value:"User"},{label:"Workspace Settings",value:"Workspace"}],d=y=>{if(y==="not_set"){t(void 0,n);return}t(y,n)},p=y=>{i(y),s("editor")},h="",g=n==="User"?"Workspace":"User";e.forScope(g).settings.preferredEditor!==void 0&&(h=e.forScope(n).settings.preferredEditor!==void 0?`(Also modified in ${g})`:`(Modified in ${g})`);let A="None";return e.merged.preferredEditor&&xae(e.merged.preferredEditor)&&(A=KDe[e.merged.preferredEditor]),(0,N0.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"row",padding:1,width:"100%",children:[(0,N0.jsxs)(Ee,{flexDirection:"column",width:"45%",paddingRight:2,children:[(0,N0.jsxs)(se,{bold:o==="editor",children:[o==="editor"?"> ":" ","Select Editor"," ",(0,N0.jsx)(se,{color:ve.Gray,children:h})]}),(0,N0.jsx)(Pp,{items:a.map(y=>({label:y.name,value:y.type,disabled:y.disabled})),initialIndex:u,onSelect:d,isFocused:o==="editor"},n),(0,N0.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,N0.jsxs)(se,{bold:o==="scope",children:[o==="scope"?"> ":" ","Apply To"]}),(0,N0.jsx)(Pp,{items:f,initialIndex:0,onSelect:p,isFocused:o==="scope"})]}),(0,N0.jsx)(Ee,{marginTop:1,children:(0,N0.jsx)(se,{color:ve.Gray,children:"(Use Enter to select, Tab to change focus)"})})]}),(0,N0.jsxs)(Ee,{flexDirection:"column",width:"55%",paddingLeft:2,children:[(0,N0.jsx)(se,{bold:!0,children:"Editor Preference"}),(0,N0.jsxs)(Ee,{flexDirection:"column",gap:1,marginTop:1,children:[(0,N0.jsx)(se,{color:ve.Gray,children:"These editors are currently supported. Please note that some editors cannot be used in sandbox mode."}),(0,N0.jsxs)(se,{color:ve.Gray,children:["Your preferred editor is:"," ",(0,N0.jsx)(se,{color:A==="None"?ve.AccentRed:ve.AccentCyan,bold:!0,children:A}),"."]})]})]})]})}rn();var Qv=ze(Wt(),1);var tin=({request:t})=>{let{commands:e,onConfirm:r}=t;Vi((o,s)=>{s.escape&&r(ni.Cancel)});let n=o=>{o===ni.Cancel?r(o):r(o,e)},i=[{label:"Yes, allow once",value:ni.ProceedOnce},{label:"Yes, allow always for this session",value:ni.ProceedAlways},{label:"No (esc)",value:ni.Cancel}];return(0,Qv.jsxs)(Ee,{flexDirection:"column",borderStyle:"round",borderColor:ve.AccentYellow,padding:1,width:"100%",marginLeft:1,children:[(0,Qv.jsxs)(Ee,{flexDirection:"column",marginBottom:1,children:[(0,Qv.jsx)(se,{bold:!0,children:"Shell Command Execution"}),(0,Qv.jsx)(se,{children:"A custom command wants to run the following shell commands:"}),(0,Qv.jsx)(Ee,{flexDirection:"column",borderStyle:"round",borderColor:ve.Gray,paddingX:1,marginTop:1,children:e.map(o=>(0,Qv.jsx)(se,{color:ve.AccentCyan,children:o},o))})]}),(0,Qv.jsx)(Ee,{marginBottom:1,children:(0,Qv.jsx)(se,{children:"Do you want to proceed?"})}),(0,Qv.jsx)(Pp,{items:i,onSelect:n,isFocused:!0})]})};var W2=ze(Wt(),1);var rin=({servers:t,cwd:e,selectedIndex:r,onSelect:n,onCancel:i})=>{let o=[{id:"connect",label:"Connect to the current IDE",action:()=>n()},{id:"disconnect",label:"Disconnect from IDE",action:()=>i}];return(0,W2.jsxs)(Ee,{flexDirection:"column",paddingX:1,paddingY:1,borderStyle:"round",borderColor:ve.AccentPurple,children:[(0,W2.jsx)(Ee,{marginBottom:1,children:(0,W2.jsx)(se,{bold:!0,color:ve.AccentPurple,children:"Connect IDE"})}),(0,W2.jsx)(Ee,{marginBottom:1,children:(0,W2.jsx)(se,{children:"Connect to an IDE for integrated development features."})}),(0,W2.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,W2.jsx)(se,{color:ve.Gray,children:"Select an option (use arrow keys to navigate):"}),o.map((s,a)=>(0,W2.jsx)(Ee,{marginTop:1,marginLeft:2,children:(0,W2.jsxs)(se,{color:a===r?ve.AccentBlue:ve.Gray,children:[a===r?"\u2192 ":" ",s.label]})},s.id)),(0,W2.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,W2.jsxs)(se,{color:ve.Gray,children:["Found ",t.length||0," other running IDE(s)."]}),t.map(s=>(0,W2.jsx)(Ee,{marginTop:1,marginLeft:2,children:(0,W2.jsx)(se,{color:ve.Gray,children:s.workspaceFolders&&s.workspaceFolders[0]?`${s.ideType} : ${s.workspaceFolders[0]}`:`${s.ideType} : \u65E0\u5DE5\u4F5C\u533A\u76EE\u5F55`})},s.pid))]}),(0,W2.jsx)(Ee,{marginTop:1,children:(0,W2.jsx)(se,{color:ve.Gray,children:"Press Esc to cancel"})})]})]})};var nin=ze(wr(),1);var Dy=ze(Wt(),1);var iin=({plan:t,onApprove:e,onKeepPlanning:r,onExit:n})=>{let[i,o]=(0,nin.useState)(0),s=[{key:"1",label:"Yes, and use yolo mode edits",action:()=>e("yolo")},{key:"2",label:"Yes, and manually approve edits",action:()=>e("default")},{key:"3",label:"No, keep planning",action:r}];return Vi((a,c)=>{if(c.escape&&n){n();return}if(c.upArrow)o(u=>u>0?u-1:s.length-1);else if(c.downArrow)o(u=>u<s.length-1?u+1:0);else if(c.return)s[i].action();else if(a>="1"&&a<="3"){let u=parseInt(a)-1;u>=0&&u<s.length&&s[u].action()}}),(0,Dy.jsxs)(Ee,{flexDirection:"column",padding:1,borderStyle:"round",borderColor:ve.AccentBlue,children:[(0,Dy.jsx)(Ee,{marginBottom:1,children:(0,Dy.jsx)(se,{color:ve.AccentBlue,bold:!0,children:"Plan Ready for Review"})}),(0,Dy.jsx)(Ee,{marginBottom:2,flexDirection:"column",children:(0,Dy.jsx)(se,{color:ve.Foreground,children:t})}),(0,Dy.jsx)(Ee,{marginBottom:1,children:(0,Dy.jsx)(se,{color:ve.AccentBlue,bold:!0,children:"Would you like to proceed?"})}),s.map((a,c)=>(0,Dy.jsx)(Ee,{marginBottom:c===s.length-1?1:0,children:(0,Dy.jsxs)(se,{color:i===c?ve.AccentBlue:ve.Foreground,children:[i===c?"\u25B6 ":" ",a.key,". ",a.label]})},a.key)),(0,Dy.jsx)(Ee,{marginTop:1,children:(0,Dy.jsx)(se,{color:ve.Comment,dimColor:!0,children:"Use \u2191\u2193 arrows to navigate, Enter to select, or press 1-3"})})]})};var gE=ze(wr(),1);var Ci=ze(Wt(),1);import{readFileSync as U6o,writeFileSync as Q6o,existsSync as q6o,mkdirSync as H6o}from"fs";import{homedir as I4t}from"os";import{join as que}from"path";function oin({settings:t,config:e,onExit:r,onStatusUpdate:n}){let[i,o]=(0,gE.useState)("loading"),[s,a]=(0,gE.useState)([]),[c,u]=(0,gE.useState)(0),[f,d]=(0,gE.useState)(0),[p,h]=(0,gE.useState)(null),[g,A]=(0,gE.useState)(null),[y,v]=(0,gE.useState)(null),[S,w]=(0,gE.useState)(null),[T,N]=(0,gE.useState)(null),P=10,U=Math.max(1,Math.ceil(s.length/P));(0,gE.useEffect)(()=>{let V=async()=>{try{let J=t.merged.apiKey;if(!J)return{success:!1,message:"Please authenticate first by running the auth command"};let he=await fetch("https://apis.iflow.cn/v1/mcp-servers?pageNumber=1&pageSize=100",{method:"GET",headers:{Authorization:`Bearer ${J}`,"User-Agent":"iFlow-Cli"}});if(!he.ok){let ge="Unable to load MCP servers. Please try again later";return he.status===401?ge="Authentication failed. Please check your API key or re-authenticate":he.status===403?ge="Access denied. Please check your permissions":he.status===404?ge="MCP servers service not found. Please try again later":he.status>=500&&(ge="Server error. Please try again later"),{success:!1,message:ge}}return{success:!0,data:(await he.json()).result||[]}}catch(J){let he="Unable to load MCP servers. Please check your connection and try again";return J instanceof Error&&J.message.includes("Failed to fetch")&&(he="Network error. Please check your internet connection"),{success:!1,message:he}}};(async()=>{let J=await V();J.success&&J.data?(a(J.data),o("list"),J.data.length===0&&A("No MCP servers found in the online repository.")):(A(J.message||"Failed to load servers"),o("list"))})()},[]);let Q=V=>{let X=Object.keys(V);if(X.length===0)return null;let J=X[0],he=V[J];return he.values?he.values:null},D=V=>V?typeof V=="string"?V.includes("${")&&V.includes("}"):Array.isArray(V)?V.some(X=>D(X)):typeof V=="object"?Object.values(V).some(X=>D(X)):!1:!1,F=V=>V.startsWith("~/")?que(I4t(),V.slice(2)):V,O=(V,X)=>{let J=he=>{if(typeof he=="string"){let be=he;for(let[ge,_e]of Object.entries(X)){let Se=`\${${ge}}`,pe=F(_e);be=be.replace(new RegExp(Se.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),pe)}return be}if(Array.isArray(he))return he.map(be=>J(be));if(he&&typeof he=="object"){let be={};for(let[ge,_e]of Object.entries(he))be[ge]=J(_e);return be}return he};return J(JSON.parse(JSON.stringify(V)))},q=async(V,X,J)=>{try{let he=X==="user"?que(I4t(),".iflow","settings.json"):que(process.cwd(),".iflow","settings.json"),be=X==="user"?que(I4t(),".iflow"):que(process.cwd(),".iflow");q6o(be)||H6o(be,{recursive:!0});let ge={};try{let ie=U6o(he,"utf8");ge=JSON.parse(ie)}catch{}ge.mcpServers||(ge.mcpServers={});let _e=Object.keys(V.serverConfig)[0],Se=Object.values(V.serverConfig)[0];J&&(Se=O(Se,J));let{values:pe,...Ae}=Se;ge.mcpServers[_e]={description:V.description,...Ae},Q6o(he,JSON.stringify(ge,null,2));let ae="";try{n?.(`Loading MCP server '${V.name}' and discovering tools...`);let{MCPServerConfig:ie}=await Promise.resolve().then(()=>(rn(),fE)),de=new ie(Se.command,Se.args,Se.env,Se.cwd,Se.url,Se.httpUrl,Se.headers,Se.tcp,Se.timeout,Se.trust,V.description,Se.includeTools,Se.excludeTools,void 0,Se.oauth,Se.authProviderType);typeof e.addMcpServer=="function"?e.addMcpServer(_e,de):console.warn("Config.addMcpServer method not available, skipping dynamic loading");let te=await e.getToolRegistry();if(te){await te.discoverToolsForServer(_e);let oe=e.getGeminiClient();oe&&await oe.setTools();let me=te.getToolsByServer(_e);ae=` - ${me.length} tools loaded and ready to use`,n?.(`\u2705 MCP server '${V.name}' loaded successfully with ${me.length} tools`)}}catch(ie){console.warn("Failed to auto-discover tools from newly installed server:",ie),n?.(`\u26A0\uFE0F MCP server '${V.name}' installed but failed to load tools: ${ie}`)}return{success:!0,message:`Successfully installed ${V.name} for ${X} (${he})${ae}`}}catch(he){return{success:!1,message:`Failed to install ${V.name}: ${he}`}}},L=async(V,X)=>{let J=Q(V.serverConfig),he=Object.keys(V.serverConfig),be=he.length>0?V.serverConfig[he[0]]:{};if(J&&Object.keys(J).length>0&&D(be))h(V),w(X),N(J),o("value-input");else try{n?.(`Installing ${V.name}...`);let ge=await q(V,X);ge.success?(v(ge.message),A(null),n?.(ge.message)):(A(ge.message),v(null),n?.(`\u274C ${ge.message}`))}catch(ge){let _e=ge instanceof Error?ge.message:"Installation failed";A(_e),v(null),n?.(`\u274C ${_e}`)}},M=async V=>{if(!(!p||!S))try{n?.(`Installing ${p.name} with configuration...`);let X=await q(p,S,V);X.success?(v(X.message),A(null),n?.(X.message),o("detail"),N(null),w(null)):(A(X.message),v(null),n?.(`\u274C ${X.message}`),o("detail"),N(null),w(null))}catch(X){let J=X instanceof Error?X.message:"Installation failed";A(J),v(null),n?.(`\u274C ${J}`),o("detail"),N(null),w(null)}},j=()=>{o("detail"),N(null),w(null)};Vi((V,X)=>{if(i!=="value-input"){if(X.escape){i==="detail"?(o("list"),h(null),A(null),v(null)):r();return}if(i==="list"){if(s.length===0){V==="q"&&r();return}if(X.upArrow||V==="k"){let J=Math.max(f-1,0);d(J);let he=Math.floor(J/P);u(he)}else if(X.downArrow||V==="j"){let J=Math.min(f+1,s.length-1);d(J);let he=Math.floor(J/P);u(he)}else if(X.leftArrow||V==="h"){if(U>1){let J=Math.max(c-1,0);u(J),d(Math.min(J*P,s.length-1))}}else if(X.rightArrow||V==="l"){if(U>1){let J=Math.min(c+1,U-1);u(J),d(Math.min(J*P,s.length-1))}}else X.return||V===""?f>=0&&f<s.length&&(h(s[f]),o("detail"),A(null),v(null)):V==="q"&&r()}else i==="detail"&&p&&(V==="1"?L(p,"project"):V==="2"?L(p,"user"):V==="b"?(o("list"),h(null),A(null),v(null)):V==="q"&&r())}});let G=()=>{if(s.length===0)return(0,Ci.jsxs)(Ee,{flexDirection:"column",children:[(0,Ci.jsx)(se,{bold:!0,children:"Available MCP Servers"}),(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsx)(se,{color:ve.AccentRed,children:g||"No servers available"})})]});let V=Math.min(c*P,s.length),X=Math.min(V+P,s.length),J=s.slice(V,X);return(0,Ci.jsxs)(Ee,{flexDirection:"column",children:[(0,Ci.jsxs)(se,{bold:!0,children:["Available MCP Servers (",s.length," total)"]}),(0,Ci.jsx)(Ee,{marginTop:1,flexDirection:"column",children:J.map((he,be)=>{let _e=V+be===f;return(0,Ci.jsxs)(Ee,{marginBottom:1,children:[(0,Ci.jsxs)(se,{color:_e?ve.AccentCyan:void 0,children:[_e?"\u25B6 ":" ",be+1,". ",he.name]}),(0,Ci.jsx)(Ee,{marginLeft:4,children:(0,Ci.jsx)(se,{color:ve.Gray,children:he.description})}),(0,Ci.jsx)(Ee,{marginLeft:4,children:(0,Ci.jsxs)(se,{color:ve.Gray,children:["Tools: ",he.tools?.length||0," | Visits: ",he.visitCount||0]})})]},he.id)})}),(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsxs)(se,{color:ve.AccentBlue,children:["Page ",c+1," of ",U]})}),(0,Ci.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Ci.jsx)(se,{color:ve.Gray,children:"Navigation:"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 \u2191/\u2193 or j/k - Navigate up/down"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 \u2190/\u2192 or h/l - Previous/Next page"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 Enter - View details"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]})},W=()=>p?(0,Ci.jsxs)(Ee,{flexDirection:"column",children:[(0,Ci.jsx)(se,{bold:!0,children:p.name}),(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsx)(se,{color:ve.AccentBlue,children:p.description})}),(0,Ci.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Ci.jsx)(se,{color:ve.AccentCyan,children:"Details:"}),(0,Ci.jsxs)(se,{children:[" \u2022 Version: ",p.versionType]}),(0,Ci.jsxs)(se,{children:[" \u2022 Protocol: ",p.protocolVersion]}),(0,Ci.jsxs)(se,{children:[" \u2022 Transports: ",p.transports?.join(", ")||"N/A"]}),(0,Ci.jsxs)(se,{children:[" \u2022 Auth Types: ",p.authTypes?.join(", ")||"N/A"]}),(0,Ci.jsxs)(se,{children:[" \u2022 Visits: ",p.visitCount||0]})]}),p.tools&&p.tools.length>0&&(0,Ci.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Ci.jsxs)(se,{color:ve.AccentCyan,children:["Available Tools (",p.tools.length,"):"]}),p.tools.map((V,X)=>(0,Ci.jsxs)(Ee,{marginLeft:2,children:[(0,Ci.jsxs)(se,{children:[X+1,". ",V.name]}),(0,Ci.jsx)(Ee,{marginLeft:2,children:(0,Ci.jsx)(se,{color:ve.Gray,children:V.description})})]},X))]}),(0,Ci.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Ci.jsx)(se,{color:ve.AccentYellow,children:"Actions:"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 1 - Install for project"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 2 - Install for user"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 b - Back to list"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]}),y&&(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsxs)(se,{color:ve.AccentGreen,children:["\u2705 ",y]})}),g&&(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsx)(se,{color:ve.AccentRed,children:g})})]}):null;return i==="loading"?(0,Ci.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,Ci.jsx)(se,{bold:!0,children:"Loading MCP Servers..."}),(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsx)(se,{children:"Please wait while we fetch available servers..."})})]}):i==="value-input"&&p&&T?(0,Ci.jsx)(zDe,{serverName:p.name,values:T,onComplete:M,onCancel:j}):(0,Ci.jsx)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:i==="list"?G():W()})}var iC=ze(wr(),1);Bq();rn();var Wr=ze(Wt(),1);import{readFileSync as sin,writeFileSync as G6o}from"fs";import{homedir as j6o}from"os";import{join as ain}from"path";function lin({settings:t,config:e,onExit:r,onStatusUpdate:n}){let[i,o]=(0,iC.useState)("loading"),[s,a]=(0,iC.useState)([]),[c,u]=(0,iC.useState)(0),[f,d]=(0,iC.useState)(0),[p,h]=(0,iC.useState)(null),[g,A]=(0,iC.useState)(null),[y,v]=(0,iC.useState)(null),S=10,w=Math.max(1,Math.ceil(s.length/S));(0,iC.useEffect)(()=>{(async()=>{try{let F=e.getMcpServers()||{},O=Object.keys(F);if(O.length===0){a([]),o("list");return}let q=await e.getToolRegistry(),L=await e.getPromptRegistry(),M=[];for(let j of O){let G=F[j],W=Wx(j),X=(q?.getAllTools()||[]).filter(ge=>ge instanceof f2&&ge.serverName===j),J=L?.getPromptsByServer(j)||[],he=$H.get(j)||!1,be="";if(G.oauth?.enabled)try{let{MCPOAuthTokenStorage:ge}=await Promise.resolve().then(()=>(rn(),fE)),_e=await ge.getToken(j);_e?be=ge.isTokenExpired(_e.token)?"expired":"authenticated":be="not authenticated"}catch{be="unknown"}M.push({name:j,config:G,status:W,tools:X,prompts:J,needsAuth:he,oauthStatus:be})}a(M),o("list"),d(0),u(0)}catch(F){A(F instanceof Error?F.message:"Failed to load servers"),o("list"),d(0),u(0)}})()},[e]);let T=async D=>{try{let F="project",O=ain(process.cwd(),".iflow","settings.json"),q=ain(j6o(),".iflow","settings.json");try{let G=sin(q,"utf8"),W=JSON.parse(G);W.mcpServers&&W.mcpServers[D.name]&&(F="user",O=q)}catch{}let L=sin(O,"utf8"),M=JSON.parse(L);if(!M.mcpServers||!M.mcpServers[D.name])return{success:!1,message:`Server "${D.name}" not found in ${F} settings.`};delete M.mcpServers[D.name],G6o(O,JSON.stringify(M,null,2)),e.removeMcpServer(D.name);let j=await e.getToolRegistry();if(j){await j.discoverMcpTools();let G=e.getGeminiClient();G&&await G.setTools()}return{success:!0,message:`Successfully removed "${D.name}" from ${F} settings.`}}catch(F){return{success:!1,message:`Failed to remove "${D.name}": ${F}`}}},N=async()=>{if(y)try{n?.(`Removing server "${y.name}"...`);let D=await T(y);if(D.success){n?.(D.message);let F=s.filter(O=>O.name!==y.name);a(F),d(Math.max(0,Math.min(f,F.length-1))),v(null),o("list")}else A(D.message),n?.(`\u274C ${D.message}`),v(null),o("list")}catch(D){let F=D instanceof Error?D.message:"Removal failed";A(F),n?.(`\u274C ${F}`),v(null),o("list")}};Vi((D,F)=>{if(F.escape){i==="detail"?(o("list"),h(null),A(null)):i==="confirm-remove"?(o("list"),v(null)):r();return}if(i==="list"){if(s.length===0){if(D==="q")r();else if(D==="o"){let O="https://platform.iflow.cn/mcp";n?.(`Opening MCP platform in your browser: ${O}`),zb(O).catch(q=>{A(`Failed to open MCP platform: ${q.message}`)})}return}if(F.upArrow||D==="k"){let O=Math.max(f-1,0);d(O);let q=Math.floor(O/S);u(q)}else if(F.downArrow||D==="j"){let O=Math.min(f+1,s.length-1);d(O);let q=Math.floor(O/S);u(q)}else if(F.leftArrow||D==="h"){if(w>1){let O=Math.max(c-1,0);u(O),d(Math.min(O*S,s.length-1))}}else if(F.rightArrow||D==="l"){if(w>1){let O=Math.min(c+1,w-1);u(O),d(Math.min(O*S,s.length-1))}}else D===" "||F.return?f>=0&&f<s.length&&(h(s[f]),o("detail"),A(null)):D==="d"||F.delete?f>=0&&f<s.length&&(v(s[f]),o("confirm-remove")):D==="q"&&r()}else i==="detail"&&p?D==="d"||F.delete?(v(p),o("confirm-remove")):D==="b"?(o("list"),h(null),A(null)):D==="q"&&r():i==="confirm-remove"&&(D==="y"||D==="Y"?N():(D==="n"||D==="N")&&(o(p?"detail":"list"),v(null)))});let P=()=>{if(s.length===0)return(0,Wr.jsxs)(Ee,{flexDirection:"column",children:[(0,Wr.jsx)(se,{bold:!0,children:"Configured MCP Servers"}),(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{color:ve.AccentYellow,children:g||"No MCP servers configured. Use /mcp online to browse and install servers."})}),(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsx)(se,{color:ve.Gray,children:"Navigation:"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 o - Open MCP platform"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]});let D=Math.min(c*S,s.length),F=Math.min(D+S,s.length),O=s.slice(D,F);return(0,Wr.jsxs)(Ee,{flexDirection:"column",children:[(0,Wr.jsxs)(se,{bold:!0,children:["Configured MCP Servers (",s.length," total)"]}),(0,Wr.jsx)(Ee,{marginTop:1,flexDirection:"column",children:O.map((q,L)=>{let j=D+L===f,G="",W="";switch(q.status){case es.CONNECTED:G="\u{1F7E2}",W="Ready";break;case es.CONNECTING:G="\u{1F504}",W="Starting...";break;case es.DISCONNECTED:default:G="\u{1F534}",W="Disconnected";break}return(0,Wr.jsxs)(Ee,{marginBottom:1,children:[(0,Wr.jsxs)(se,{color:j?ve.AccentCyan:void 0,children:[j?"\u25B6 ":" ",G," ",q.name," - ",W]}),(0,Wr.jsx)(Ee,{marginLeft:4,children:(0,Wr.jsx)(se,{color:ve.Gray,children:q.config.description||"No description"})}),(0,Wr.jsx)(Ee,{marginLeft:4,children:(0,Wr.jsxs)(se,{color:ve.Gray,children:["Tools: ",q.tools.length," | Prompts: ",q.prompts.length,q.config.extensionName&&` | From: ${q.config.extensionName}`]})})]},q.name)})}),w>1&&(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsxs)(se,{color:ve.AccentBlue,children:["Page ",c+1," of ",w]})}),(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsx)(se,{color:ve.Gray,children:"Navigation:"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 \u2191/\u2193 or j/k - Navigate up/down"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 Space/Enter - View server details"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 d/Delete - Remove server"}),w>1&&(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 \u2190/\u2192 or h/l - Previous/Next page"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]}),g&&(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{color:ve.AccentRed,children:g})})]})},U=()=>{if(!p)return null;let D=p;return(0,Wr.jsxs)(Ee,{flexDirection:"column",children:[(0,Wr.jsx)(se,{bold:!0,children:D.name}),(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{color:ve.AccentBlue,children:D.config.description||"No description available"})}),(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsx)(se,{color:ve.AccentCyan,children:"Server Details:"}),(0,Wr.jsxs)(se,{children:[" \u2022 Status: ",D.status===es.CONNECTED?"\u{1F7E2} Connected":D.status===es.CONNECTING?"\u{1F504} Connecting":"\u{1F534} Disconnected"]}),D.config.command&&(0,Wr.jsxs)(se,{children:[" \u2022 Command: ",D.config.command," ",D.config.args?.join(" ")||""]}),D.config.httpUrl&&(0,Wr.jsxs)(se,{children:[" \u2022 HTTP URL: ",D.config.httpUrl]}),D.config.url&&(0,Wr.jsxs)(se,{children:[" \u2022 SSE URL: ",D.config.url]}),D.config.extensionName&&(0,Wr.jsxs)(se,{children:[" \u2022 Source: ",D.config.extensionName," extension"]}),D.config.oauth?.enabled&&(0,Wr.jsxs)(se,{children:[" \u2022 OAuth: ",D.oauthStatus==="authenticated"?"\u{1F7E2} Authenticated":D.oauthStatus==="expired"?"\u{1F7E1} Token Expired":"\u{1F534} Not Authenticated"]})]}),D.tools.length>0&&(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsxs)(se,{color:ve.AccentCyan,children:["Available Tools (",D.tools.length,"):"]}),D.tools.slice(0,10).map((F,O)=>(0,Wr.jsxs)(Ee,{marginLeft:2,children:[(0,Wr.jsxs)(se,{children:[O+1,". ",F.name]}),F.description&&(0,Wr.jsx)(Ee,{marginLeft:2,children:(0,Wr.jsx)(se,{color:ve.Gray,children:F.description})})]},O)),D.tools.length>10&&(0,Wr.jsxs)(se,{color:ve.Gray,children:[" ... and ",D.tools.length-10," more tools"]})]}),D.prompts.length>0&&(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsxs)(se,{color:ve.AccentCyan,children:["Available Prompts (",D.prompts.length,"):"]}),D.prompts.slice(0,5).map((F,O)=>(0,Wr.jsxs)(Ee,{marginLeft:2,children:[(0,Wr.jsxs)(se,{children:[O+1,". ",F.name]}),F.description&&(0,Wr.jsx)(Ee,{marginLeft:2,children:(0,Wr.jsx)(se,{color:ve.Gray,children:F.description})})]},O)),D.prompts.length>5&&(0,Wr.jsxs)(se,{color:ve.Gray,children:[" ... and ",D.prompts.length-5," more prompts"]})]}),(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsx)(se,{color:ve.AccentYellow,children:"Actions:"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 d/Delete - Remove this server"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 b - Back to list"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 Esc - Back to list"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]}),g&&(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{color:ve.AccentRed,children:g})})]})},Q=()=>y?(0,Wr.jsxs)(Ee,{flexDirection:"column",children:[(0,Wr.jsx)(se,{bold:!0,color:ve.AccentRed,children:"Confirm Server Removal"}),(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{children:"Are you sure you want to remove the following MCP server?"})}),(0,Wr.jsxs)(Ee,{marginTop:1,marginLeft:2,children:[(0,Wr.jsx)(se,{bold:!0,children:y.name}),(0,Wr.jsx)(Ee,{marginLeft:2,children:(0,Wr.jsx)(se,{color:ve.Gray,children:y.config.description||"No description"})}),(0,Wr.jsx)(Ee,{marginLeft:2,children:(0,Wr.jsxs)(se,{color:ve.Gray,children:["Tools: ",y.tools.length," | Prompts: ",y.prompts.length]})})]}),(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{color:ve.AccentYellow,children:"This will remove the server from your configuration and stop all its tools."})}),(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsx)(se,{color:ve.AccentCyan,children:"Actions:"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 y/Y - Yes, remove server"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 n/N - No, cancel"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 Esc - Cancel"})]})]}):null;return i==="loading"?(0,Wr.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,Wr.jsx)(se,{bold:!0,children:"Loading MCP Servers..."}),(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{children:"Please wait while we load your configured servers..."})})]}):(0,Wr.jsx)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:i==="list"?P():i==="detail"?U():Q()})}var oC=ze(wr(),1);var hn=ze(Wt(),1);function cin({settings:t,config:e,onExit:r,onStatusUpdate:n}){let[i,o]=(0,oC.useState)("loading"),[s,a]=(0,oC.useState)([]),[c,u]=(0,oC.useState)(0),[f,d]=(0,oC.useState)(0),[p,h]=(0,oC.useState)(null),[g,A]=(0,oC.useState)(null),[y,v]=(0,oC.useState)(null),S=10,w=Math.ceil(s.length/S);(0,oC.useEffect)(()=>{let Q=async()=>{try{let F=t.merged.apiKey;if(!F)return{success:!1,message:"Please authenticate first by running the auth command"};let O=await fetch("https://apis.iflow.cn/v1/agents/list",{method:"POST",headers:{Authorization:`Bearer ${F}`,"User-Agent":"iFlow-Cli","Content-Type":"application/json"},body:JSON.stringify({page:1,size:100,usePage:!0})});if(!O.ok){let L="Unable to load agents. Please try again later";return O.status===401?L="Authentication failed. Please check your API key or re-authenticate":O.status===403?L="Access denied. Please check your permissions":O.status===404?L="Agents service not found. Please try again later":O.status>=500&&(L="Server error. Please try again later"),{success:!1,message:L}}let q=await O.json();return q.success?{success:!0,data:q.data?.data||[]}:{success:!1,message:q.message||"Failed to load agents from server"}}catch(F){let O="Unable to load agents. Please check your connection and try again";return F instanceof Error&&F.message.includes("Failed to fetch")&&(O="Network error. Please check your internet connection"),{success:!1,message:O}}};(async()=>{let F=await Q();F.success&&F.data?(a(F.data),o("list"),F.data.length===0&&A("No agents found in the online repository.")):(A(F.message||"Failed to load agents"),o("list"))})()},[]);let T=async(Q,D)=>{try{let{AgentRegistry:F}=await Promise.resolve().then(()=>(rn(),fE)),O=new F,q=[],L=!0,M=!0,j,G=null;if(Q.extInfo&&typeof Q.extInfo=="string")try{G=JSON.parse(Q.extInfo)}catch{}if(G){if(L=G["is-inherit-tools"],M=G["is-inherit-mcps"]!==void 0?G["is-inherit-mcps"]:!0,G["allowed-tools"]){let X=G["allowed-tools"].split(",").map(J=>J.trim()).filter(J=>J);X.length>0?q=X:q=G["is-inherit-tools"]?["*"]:[]}else q=G["is-inherit-tools"]?["*"]:[];if(G.mcps){let X=G.mcps.split(",").map(J=>J.trim()).filter(J=>J);X.length>0?j=X:j=G["is-inherit-mcps"]?void 0:[]}else j=G["is-inherit-mcps"]?void 0:[]}else{try{let X=JSON.parse(Q.tools||"[]");q=Array.isArray(X)?X:["*"]}catch{q=["*"]}if(Q.mcps)try{let X=JSON.parse(Q.mcps);Array.isArray(X)&&X.length>0&&(j=X)}catch{let X=Q.mcps.split(",").map(J=>J.trim()).filter(J=>J.length>0);X.length>0&&(j=X)}}let W={agentType:Q.name.toLowerCase().replace(/[^a-z0-9]/g,"-"),name:Q.name,description:Q.description,whenToUse:Q.description,allowedTools:q,allowedMcps:j,systemPrompt:Q.detailContext||Q.description,location:D==="user"?"global":"project",model:Q.modelName,isInheritTools:L,isInheritMcps:M};return await O.createAgent(W)?{success:!0,message:`Successfully installed agent '${Q.name}' for ${D}`}:{success:!1,message:`Failed to create agent for '${Q.name}'`}}catch(F){return{success:!1,message:`Failed to install ${Q.name}: ${F}`}}},N=async(Q,D)=>{try{n?.(`Installing ${Q.name}...`);let F=await T(Q,D);F.success?(v(F.message),A(null),n?.(F.message)):(A(F.message),v(null),n?.(`\u274C ${F.message}`))}catch(F){let O=F instanceof Error?F.message:"Installation failed";A(O),v(null),n?.(`\u274C ${O}`)}};Vi((Q,D)=>{if(D.escape){i==="detail"?(o("list"),h(null),A(null),v(null)):r();return}if(i==="list")if(D.upArrow||Q==="k"){let F=Math.max(f-1,0);d(F);let O=Math.floor(F/S);u(O)}else if(D.downArrow||Q==="j"){let F=Math.min(f+1,s.length-1);d(F);let O=Math.floor(F/S);u(O)}else if(D.leftArrow||Q==="h"){let F=Math.max(c-1,0);u(F),d(F*S)}else if(D.rightArrow||Q==="l"){let F=Math.min(c+1,w-1);u(F),d(Math.min(F*S,s.length-1))}else D.return||Q===""?s.length>0&&f>=0&&f<s.length&&(h(s[f]),o("detail"),A(null),v(null)):Q==="q"&&r();else i==="detail"&&p&&(Q==="1"?N(p,"project"):Q==="2"?N(p,"user"):Q==="b"?(o("list"),h(null),A(null),v(null)):Q==="q"&&r())});let P=()=>{if(s.length===0)return(0,hn.jsxs)(Ee,{flexDirection:"column",children:[(0,hn.jsx)(se,{bold:!0,children:"Available Agents"}),(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsx)(se,{color:ve.AccentRed,children:g||"No agents available"})})]});let Q=c*S,D=Math.min(Q+S,s.length),F=s.slice(Q,D);return(0,hn.jsxs)(Ee,{flexDirection:"column",children:[(0,hn.jsxs)(se,{bold:!0,children:["Available Agents (",s.length," total)"]}),(0,hn.jsx)(Ee,{marginTop:1,flexDirection:"column",children:F.map((O,q)=>{let M=Q+q===f;return(0,hn.jsxs)(Ee,{marginBottom:1,flexDirection:"row",children:[(0,hn.jsxs)(Ee,{width:30,flexShrink:0,flexDirection:"column",children:[(0,hn.jsxs)(se,{color:M?ve.AccentCyan:void 0,children:[M?"\u25B6 ":" ",q+1,". ",O.name]}),(0,hn.jsx)(Ee,{marginLeft:4,flexDirection:"column",children:(0,hn.jsxs)(se,{color:ve.Gray,children:["Category:",O.category]})})]}),(0,hn.jsx)(Ee,{marginLeft:3,flexGrow:1,children:(0,hn.jsx)(se,{color:ve.Gray,children:O.description})})]},O.id)})}),(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsxs)(se,{color:ve.AccentBlue,children:["Page ",c+1," of ",w]})}),(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.Gray,children:"Navigation:"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 \u2191/\u2193 or j/k - Navigate up/down"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 \u2190/\u2192 or h/l - Previous/Next page"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 Enter - View details"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]})},U=()=>p?(0,hn.jsxs)(Ee,{flexDirection:"column",children:[(0,hn.jsx)(se,{bold:!0,children:p.name}),(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsx)(se,{color:ve.AccentBlue,children:p.description})}),(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"Details:"}),(0,hn.jsxs)(se,{children:[" \u2022 Model: ",p.modelName]}),(0,hn.jsxs)(se,{children:[" \u2022 Category: ",p.category]}),(0,hn.jsxs)(se,{children:[" \u2022 Version: ",p.version]})]}),(()=>{let Q=null;if(p.extInfo&&typeof p.extInfo=="string")try{Q=JSON.parse(p.extInfo)}catch{}return Q?(0,hn.jsxs)(hn.Fragment,{children:[(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"Tools:"}),(0,hn.jsx)(Ee,{marginLeft:2,children:(0,hn.jsx)(se,{children:(()=>{let D=Q["allowed-tools"]?Q["allowed-tools"].split(",").map(O=>O.trim()).filter(O=>O):[],F=Q["is-inherit-tools"]?" (inherit)":" (no inherit)";return D.length>0?D.join(", ")+F:Q["is-inherit-tools"]?"All tools available (inherit)":"No tools available (no inherit)"})()})})]}),(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"MCP Servers:"}),(0,hn.jsx)(Ee,{marginLeft:2,children:(0,hn.jsx)(se,{children:(()=>{let D=Q.mcps?Q.mcps.split(",").map(O=>O.trim()).filter(O=>O):[],F=Q["is-inherit-mcps"]?" (inherit)":" (no inherit)";return D.length>0?D.join(", ")+F:Q["is-inherit-mcps"]?"All MCP servers available (inherit)":"No MCP servers available (no inherit)"})()})})]})]}):(0,hn.jsxs)(hn.Fragment,{children:[(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"Tools:"}),(0,hn.jsx)(Ee,{marginLeft:2,children:(0,hn.jsx)(se,{children:(()=>{if(!p.tools)return"All tools available (inherit)";try{let D=JSON.parse(p.tools);return Array.isArray(D)?D.length>0?D.join(", ")+" (inherit)":"All tools available (inherit)":(p.tools||"All tools available")+" (inherit)"}catch{return(p.tools||"All tools available")+" (inherit)"}})()})})]}),(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"MCP Servers:"}),(0,hn.jsx)(Ee,{marginLeft:2,children:(0,hn.jsx)(se,{children:(()=>{if(!p.mcps||p.mcps.trim()==="")return"All MCP servers available (inherit)";try{let D=JSON.parse(p.mcps);return Array.isArray(D)?D.length>0?D.join(", ")+" (inherit)":"All MCP servers available (inherit)":(p.mcps||"All MCP servers available")+" (inherit)"}catch{return(p.mcps||"All MCP servers available")+" (inherit)"}})()})})]})]})})(),p.detailContext&&(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"System Prompt:"}),(0,hn.jsx)(Ee,{marginLeft:2,children:(0,hn.jsx)(se,{children:p.detailContext.length>800?`${p.detailContext.substring(0,800)}...`:p.detailContext})})]}),(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentYellow,children:"Actions:"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 1 - Install for project"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 2 - Install for user"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 b - Back to list"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]}),y&&(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsxs)(se,{color:ve.AccentGreen,children:["\u2705 ",y]})}),g&&(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsx)(se,{color:ve.AccentRed,children:g})})]}):null;return i==="loading"?(0,hn.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,hn.jsx)(se,{bold:!0,children:"Loading Agents..."}),(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsx)(se,{children:"Please wait while we fetch available agents..."})})]}):(0,hn.jsx)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:i==="list"?P():U()})}var E1=ze(wr(),1);var or=ze(Wt(),1);function uin({settings:t,config:e,onExit:r,onStatusUpdate:n}){let[i,o]=(0,E1.useState)("location"),[s,a]=(0,E1.useState)(0),[c,u]=(0,E1.useState)({}),[f,d]=(0,E1.useState)(null),[p,h]=(0,E1.useState)(null),[g,A]=(0,E1.useState)(!1),[y,v]=(0,E1.useState)([]),[S,w]=(0,E1.useState)([]),[T,N]=(0,E1.useState)(""),[P,U]=(0,E1.useState)(null),[Q,D]=(0,E1.useState)("");(0,E1.useEffect)(()=>{(async()=>{try{let ie=await e.getToolRegistry();if(ie){let oe=["task","exit_plan_mode","save_memory"],K=ie.getAllTools().filter(re=>{let xe="serverName"in re&&re.serverName!==void 0,ye=oe.filter(Z=>Z===re.name).length>0;return!xe&&!ye}).map(re=>re.name);v(K),u(re=>({...re,selectedTools:K}))}let de=e.getMcpServers()||{},te=Object.keys(de);w(te),u(oe=>({...oe,selectedMcps:te}))}catch(ie){console.error("Failed to initialize data:",ie)}})()},[e]);let O={location:{name:"location",title:"Choose Installation Location",description:"Where would you like to install the agent?",type:"select",options:[{id:"project",title:"Project Agent",description:"Install in the current project (accessible only to this project)",available:!0},{id:"user",title:"User Agent",description:"Install globally for your user (accessible across all projects)",available:!0}]},method:{name:"method",title:"Choose Creation Method",description:"How would you like to create the agent?",type:"select",options:[{id:"iFlow",title:"Generate with iFlow (recommended)",description:"Create through the intelligent guidance of iFlow",available:!0},{id:"template",title:"Manual configuration",description:"Create it step by step by hand",available:!0},{id:"online",title:"From Online Repository",description:"Browse and install from the online agent repository",available:!0}]},agentGoal:{name:"agentGoal",title:"Describe Your Agent Goal",description:"What do you want this agent to do? Be specific about its purpose and capabilities.",type:"input",placeholder:"e.g. Review code for security vulnerabilities and best practices"},agentType:{name:"agentType",title:"Agent Type (identifier)",description:"Enter a unique identifier for your agent",type:"input",placeholder:"e.g. code-reviewer, tech-lead, etc"},systemPrompt:{name:"systemPrompt",title:"System Prompt",description:"Define the agent's behavior and capabilities",type:"input",placeholder:"Enter system prompt. Be comprehensive for best results"},description:{name:"description",title:"Agent Description",description:"Provide a brief description of what this agent does",type:"input",placeholder:"Enter agent description"},tools:{name:"tools",title:"Select Tools",description:"Choose which tools this agent can use",type:"multiselect",options:y.map(ae=>({id:ae,title:ae,description:`Allow access to ${ae} tool`,available:!0}))},mcps:{name:"mcps",title:"Select MCP Servers",description:"Choose which MCP servers this agent can access",type:"multiselect",options:S.map(ae=>({id:ae,title:ae,description:`Allow access to ${ae} MCP server`,available:!0}))},color:{name:"color",title:"Choose Background Color",description:"Select a color for your agent",type:"select",options:[{id:"automatic",title:"Automatic color",description:"Let the system choose a color automatically",available:!0},{id:"red",title:"Red",description:"",available:!0},{id:"blue",title:"Blue",description:"",available:!0},{id:"green",title:"Green",description:"",available:!0},{id:"yellow",title:"Yellow",description:"",available:!0},{id:"purple",title:"Purple",description:"",available:!0},{id:"orange",title:"Orange",description:"",available:!0},{id:"pink",title:"Pink",description:"",available:!0},{id:"cyan",title:"Cyan",description:"",available:!0}]},"generated-preview":{name:"generated-preview",title:"Review Generated Configuration",description:"Review and edit the AI-generated agent configuration",type:"edit",options:[{id:"agentType",title:"Agent Type",description:`${c.agentType||"(not set)"}`,available:!0},{id:"description",title:"Description",description:`${c.description||"(not set)"}`,available:!0},{id:"systemPrompt",title:"System Prompt",description:`${c.systemPrompt?c.systemPrompt.length>600?c.systemPrompt.substring(0,600)+"...":c.systemPrompt:"(not set)"}`,available:!0}]},preview:{name:"preview",title:"Preview Agent Configuration",description:"Review your agent configuration before creating",type:"preview"},generating:null,installing:null,success:null,error:null}[i],q=O?.options?.filter(ae=>ae.available)||[];(0,E1.useEffect)(()=>{a(0),d(null),A(!1),U(null),D("")},[i]);let L=ae=>{let ie=["location","method","agentType","systemPrompt","description","tools","mcps","color","preview"],de=["location","method","agentGoal","generating","generated-preview","tools","mcps","color","preview"];if(ae==="method")return c.method==="template"?"agentType":c.method==="iFlow"?"agentGoal":null;let te=c.method==="iFlow"?de:ie,oe=te.indexOf(ae);return oe<te.length-1?te[oe+1]:null},M=ae=>{let ie=["location","method","agentType","systemPrompt","description","tools","mcps","color","preview"],de=["location","method","agentGoal","generating","generated-preview","tools","mcps","color","preview"],te=c.method==="iFlow"?de:ie,oe=te.indexOf(ae);return oe>0?te[oe-1]:null},j=()=>{switch(i){case"agentGoal":return c.agentGoal||"";case"agentType":return c.agentType||"";case"systemPrompt":return c.systemPrompt||"";case"description":return c.description||"";default:return""}},G=ae=>{if(i==="agentGoal"){if(u(de=>({...de,agentGoal:ae})),c.method==="iFlow"){J(ae);return}}else i==="agentType"?u(de=>({...de,agentType:ae})):i==="systemPrompt"?u(de=>({...de,systemPrompt:ae})):i==="description"&&u(de=>({...de,description:ae}));A(!1);let ie=L(i);ie&&(o(ie),a(0))},W=()=>{A(!1),U(null),D("")},V=ae=>{P==="agentType"?u(ie=>({...ie,agentType:ae})):P==="description"?u(ie=>({...ie,description:ae})):P==="systemPrompt"&&u(ie=>({...ie,systemPrompt:ae})),U(null),D("")},X=()=>{U(null),D("")},J=async ae=>{try{o("generating"),d(null),n?.("Generating agent configuration from your goal...");let{generateAgentConfig:ie}=await Promise.resolve().then(()=>(rn(),fE)),de=await ie(e,{agentGoal:ae,onProgress:te=>{N(te),n?.(te)}});u(te=>({...te,agentType:de.identifier,systemPrompt:de.systemPrompt,description:de.whenToUse})),o("generated-preview"),a(0),n?.("\u2705 Agent configuration generated successfully!")}catch(ie){o("error");let de=ie instanceof Error?ie.message:String(ie);d(`Failed to generate agent configuration: ${de}`),n?.(`\u274C Failed to generate configuration: ${de}`)}},he=async()=>{try{o("installing"),n?.(`Creating agent '${c.agentType}'...`);let{createAgent:ae}=await Promise.resolve().then(()=>(rn(),fE)),ie={agentType:c.agentType,name:c.agentType,description:c.description,whenToUse:c.description,allowedTools:c.selectedTools?.length?c.selectedTools:["*"],allowedMcps:c.selectedMcps?.length?c.selectedMcps:void 0,systemPrompt:c.systemPrompt,location:c.location==="user"?"global":"project",isInheritTools:!0,isInheritMcps:!0},de=await ae(ie);o("success"),h(`Successfully created agent '${c.agentType}' at ${de}`),n?.(`\u2705 Successfully created agent '${c.agentType}'`),setTimeout(()=>{r()},3e3)}catch(ae){o("error");let ie=ae instanceof Error?ae.message:String(ae);d(`Failed to create agent: ${ie}`),n?.(`\u274C Failed to create agent: ${ie}`)}},be=()=>{let ae=O;if(!ae)return;if(ae.type==="select"){let de=q[s];if(de)if(i==="location")u(te=>({...te,location:de.id}));else if(i==="method"){let te=de.id;if(u(me=>({...me,method:te})),te==="online"){h("Redirecting to online repository..."),n?.("Use /agents online to browse and install agents from the online repository"),setTimeout(()=>{r()},2e3);return}let oe=null;te==="template"?oe="agentType":te==="iFlow"&&(oe="agentGoal"),oe&&(o(oe),a(0),A(!1),d(null));return}else i==="color"&&u(te=>({...te,color:de.id}))}else if(ae.type==="input"){if(!g){A(!0);return}}else if(ae.type==="multiselect")if(s===0){let de=L(i);de&&(o(de),a(0),A(!1),d(null));return}else{let de=q[s-1];if(i==="tools"){let te=c.selectedTools||[],oe=te.includes(de.id);u(oe?me=>({...me,selectedTools:te.filter(ue=>ue!==de.id)}):me=>({...me,selectedTools:[...te,de.id]}))}else if(i==="mcps"){let te=c.selectedMcps||[],oe=te.includes(de.id);u(oe?me=>({...me,selectedMcps:te.filter(ue=>ue!==de.id)}):me=>({...me,selectedMcps:[...te,de.id]}))}return}else if(ae.type==="edit"){if(P)return;if(s===0){let de=L(i);de&&(o(de),a(0),A(!1),d(null))}else{let de=q[s-1];U(de.id);let te="";de.id==="agentType"?te=c.agentType||"":de.id==="description"?te=c.description||"":de.id==="systemPrompt"&&(te=c.systemPrompt||""),D(te)}return}else if(ae.type==="preview"){he();return}let ie=L(i);ie&&(o(ie),a(0),A(!1),d(null))},ge=()=>{if(g){A(!1);return}if(P){U(null),D("");return}let ae=M(i);ae?(o(ae),a(0),d(null)):r()};Vi((ae,ie)=>{if(g||P)return;if(ie.escape){ge();return}if(ae==="q"){r();return}let de=O;if(de){if(de.type==="select"||de.type==="multiselect"||de.type==="edit"){let te=de.type==="multiselect"||de.type==="edit"?q.length:q.length-1;ie.upArrow||ae==="k"?a(oe=>Math.max(0,oe-1)):ie.downArrow||ae==="j"?a(oe=>Math.min(te,oe+1)):(ie.return||ae==="")&&be()}else if(de.type==="input")(ie.return||ae==="")&&be();else if(de.type==="preview"){if(ie.upArrow||ie.downArrow||ae==="k"||ae==="j")return;(ie.return||ae==="")&&be()}}});let _e=()=>{if(c.method==="online"){let oe=["location","method"],me=oe.indexOf(i);return(0,or.jsxs)(Ee,{marginBottom:1,children:[(0,or.jsxs)(se,{color:ve.Gray,children:["Step ",me+1," of ",oe.length]}),(0,or.jsx)(Ee,{marginLeft:2,children:(0,or.jsx)(se,{color:ve.Gray,children:oe.map((ue,K)=>K<me?"\u2713 ":K===me?"\u25CF ":"\u25CB ").join("")})})]})}let ae=["location","method","agentType","systemPrompt","description","tools","mcps","color","preview"],ie=["location","method","agentGoal","generating","generated-preview","tools","mcps","color","preview"],de=c.method==="iFlow"?ie:ae,te=de.indexOf(i);return(0,or.jsxs)(Ee,{marginBottom:1,children:[(0,or.jsxs)(se,{color:ve.Gray,children:["Step ",te+1," of ",de.length]}),(0,or.jsx)(Ee,{marginLeft:2,children:(0,or.jsx)(se,{color:ve.Gray,children:de.map((oe,me)=>me<te?"\u2713 ":me===te?"\u25CF ":"\u25CB ").join("")})})]})},Se=()=>{if(P){let ae={agentType:"Agent Type (identifier)",description:"Description",systemPrompt:"System Prompt"};return(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsxs)(se,{bold:!0,color:ve.AccentCyan,children:["Edit ",ae[P]]}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsxs)(se,{color:ve.Gray,children:["Modify the ",P," for your agent"]})}),(0,or.jsx)(Ee,{marginTop:2,children:(0,or.jsx)(Ty,{onSubmit:V,onCancel:X,placeholder:`Enter ${P}`,label:ae[P],defaultValue:Q,isFocused:!0})})]})}return(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentCyan,children:"Review Generated Configuration"}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:"Review and edit the AI-generated agent configuration"})}),(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[(0,or.jsxs)(Ee,{marginBottom:2,flexDirection:"column",children:[(0,or.jsx)(Ee,{flexDirection:"row",children:(0,or.jsxs)(se,{color:s===0?ve.AccentCyan:void 0,children:[s===0?"\u25B6 ":" ","[Continue to Tools Selection]"]})}),(0,or.jsx)(Ee,{marginLeft:4,children:(0,or.jsx)(se,{color:ve.Gray,children:"Proceed to next step"})})]},"continue"),q.map((ae,ie)=>{let te=ie+1===s;return(0,or.jsxs)(Ee,{marginBottom:1,flexDirection:"column",children:[(0,or.jsx)(Ee,{flexDirection:"row",children:(0,or.jsxs)(se,{color:te?ve.AccentCyan:void 0,children:[te?"\u25B6 ":" ",ae.title]})}),(0,or.jsx)(Ee,{marginLeft:4,children:(0,or.jsx)(se,{color:ve.Gray,children:ae.description})})]},ae.id)})]}),(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.Gray,children:"Navigation:"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 \u2191/\u2193 or j/k - Navigate options"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 Enter - Edit field or continue"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 ESC - Back"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]})},pe=()=>(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentCyan,children:"Preview Agent Configuration"}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:"Review your agent configuration before creating"})}),(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,children:c.agentType}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.AccentBlue,children:c.description})}),(0,or.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.AccentCyan,children:"Details:"}),(0,or.jsxs)(se,{children:[" \u2022 Location: ",c.location]}),(0,or.jsx)(se,{children:" \u2022 Model: gemini-1.5-pro"}),(0,or.jsxs)(se,{children:[" \u2022 Color: ",c.color]})]}),(0,or.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.AccentCyan,children:"Tools:"}),(0,or.jsx)(Ee,{marginLeft:2,children:(0,or.jsx)(se,{children:c.selectedTools?.length?c.selectedTools.join(", "):"All tools available"})})]}),(0,or.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.AccentCyan,children:"MCP Servers:"}),(0,or.jsx)(Ee,{marginLeft:2,children:(0,or.jsx)(se,{children:c.selectedMcps?.length?c.selectedMcps.join(", "):"All MCP servers available"})})]}),c.systemPrompt&&(0,or.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.AccentCyan,children:"System Prompt:"}),(0,or.jsx)(Ee,{marginLeft:2,children:(0,or.jsx)(se,{children:c.systemPrompt.length>200?`${c.systemPrompt.substring(0,200)}...`:c.systemPrompt})})]})]}),(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.AccentYellow,children:"Actions:"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 Enter - Create agent"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 ESC - Back to edit"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]}),Ae=()=>O?i==="preview"?pe():i==="generated-preview"?Se():i==="generating"?(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentCyan,children:"Generating Agent Configuration"}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:"Using AI to create your agent from the goal description..."})}),(0,or.jsx)(Ee,{marginTop:2,children:(0,or.jsx)(se,{color:ve.AccentYellow,children:T||"Starting generation..."})}),(0,or.jsx)(Ee,{marginTop:2,children:(0,or.jsx)(se,{color:ve.Gray,children:"Please wait while the configuration is generated."})})]}):g&&O.type==="input"?(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentCyan,children:O.title}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:O.description})}),(0,or.jsx)(Ee,{marginTop:2,children:(0,or.jsx)(Ty,{onSubmit:G,onCancel:W,placeholder:O.placeholder,label:O.title,defaultValue:j(),isFocused:!0})})]}):(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentCyan,children:O.title}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:O.description})}),O.type==="input"&&!g&&(0,or.jsxs)(Ee,{marginTop:2,children:[(0,or.jsxs)(se,{color:ve.AccentYellow,children:["Current value: ",j()||"(not set)"]}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:"Press Enter to edit"})})]}),(O.type==="select"||O.type==="multiselect")&&(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[O.type==="multiselect"&&(0,or.jsxs)(Ee,{marginBottom:2,flexDirection:"column",children:[(0,or.jsx)(Ee,{flexDirection:"row",children:(0,or.jsxs)(se,{color:s===0?ve.AccentCyan:void 0,children:[s===0?"\u25B6 ":" ","[Continue]"]})}),(0,or.jsx)(Ee,{marginLeft:4,children:(0,or.jsx)(se,{color:ve.Gray,children:"Proceed to next step"})})]},"continue"),q.map((ae,ie)=>{let te=(O.type==="multiselect"?ie+1:ie)===s,oe=O.type==="multiselect"?i==="tools"?(c.selectedTools||[]).includes(ae.id):(c.selectedMcps||[]).includes(ae.id):!1;return(0,or.jsxs)(Ee,{marginBottom:1,flexDirection:"column",children:[(0,or.jsx)(Ee,{flexDirection:"row",children:(0,or.jsxs)(se,{color:te?ve.AccentCyan:void 0,children:[te?"\u25B6 ":" ",O.type==="multiselect"&&(0,or.jsx)(se,{children:oe?"[\u2713] ":"[ ] "}),O.type==="select"&&ae.id==="red"&&(0,or.jsx)(se,{color:ve.AccentRed,children:"\u2588 "}),O.type==="select"&&ae.id==="blue"&&(0,or.jsx)(se,{color:ve.AccentBlue,children:"\u2588 "}),O.type==="select"&&ae.id==="green"&&(0,or.jsx)(se,{color:ve.AccentGreen,children:"\u2588 "}),O.type==="select"&&ae.id==="yellow"&&(0,or.jsx)(se,{color:ve.AccentYellow,children:"\u2588 "}),O.type==="select"&&ae.id==="purple"&&(0,or.jsx)(se,{color:ve.AccentPurple,children:"\u2588 "}),O.type==="select"&&ae.id==="orange"&&(0,or.jsx)(se,{color:ve.AccentYellow,children:"\u2588 "}),O.type==="select"&&ae.id==="pink"&&(0,or.jsx)(se,{color:ve.AccentPurple,children:"\u2588 "}),O.type==="select"&&ae.id==="cyan"&&(0,or.jsx)(se,{color:ve.AccentCyan,children:"\u2588 "}),ae.title]})}),ae.description&&(0,or.jsx)(Ee,{marginLeft:4,children:(0,or.jsx)(se,{color:ve.Gray,children:ae.description})})]},ae.id)})]}),(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.Gray,children:"Navigation:"}),O.type==="input"&&!g&&(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 Enter - Edit value"}),(O.type==="select"||O.type==="multiselect"||O.type==="edit")&&(0,or.jsxs)(or.Fragment,{children:[(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 \u2191/\u2193 or j/k - Navigate options"}),(0,or.jsxs)(se,{color:ve.Gray,children:[" \u2022 Enter - ",O.type==="edit"?"Edit field or continue":"Select option"]})]}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 ESC - Back"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]}):(0,or.jsx)(Ee,{flexDirection:"column",children:(0,or.jsx)(se,{color:ve.Gray,children:"Generating"})});return p?(0,or.jsxs)(Ee,{borderStyle:"round",borderColor:ve.AccentGreen,flexDirection:"column",padding:1,width:"100%",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentGreen,children:"Agent Installation"}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsxs)(se,{color:ve.AccentGreen,children:["\u2705 ",p]})})]}):(0,or.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,or.jsx)(se,{bold:!0,children:"Install New Agent"}),_e(),Ae(),f&&(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsxs)(se,{color:ve.AccentRed,children:["\u274C ",f]})})]})}var qv=ze(wr(),1);var Ei=ze(Wt(),1);import R4t from"fs/promises";import B4t from"path";import V6o from"os";function fin({config:t,onExit:e,onStatusUpdate:r}){let[n,i]=(0,qv.useState)("loading"),[o,s]=(0,qv.useState)([]),[a,c]=(0,qv.useState)(1),[u,f]=(0,qv.useState)(0),[d,p]=(0,qv.useState)(null),[h,g]=(0,qv.useState)(null),[A,y]=(0,qv.useState)(null),[v,S]=(0,qv.useState)(0),w=10,T=Math.ceil(v/w);(0,qv.useEffect)(()=>{let O=async L=>{try{let M=t?.getContentGeneratorConfig()?.apiKey;if(!M)throw new Error("API key not found. Please authenticate first.");let j=new URL("https://apis.iflow.cn/v1/commands/list"),G=await fetch(j.toString(),{method:"POST",headers:{Authorization:`Bearer ${M}`,"User-Agent":"iFlow-Cli","Content-Type":"application/json"},body:JSON.stringify({page:L,size:w})});if(!G.ok){let J="Unable to load commands. Please try again later";throw G.status===401?J="Authentication failed. Please check your API key or re-authenticate":G.status===403?J="Access denied. Please check your permissions":G.status===404?J="Commands service not found. Please try again later":G.status>=500&&(J="Server error. Please try again later"),new Error(J)}let W=await G.json();if(!W.success)throw new Error(W.message||"Failed to fetch commands");let V=Array.isArray(W.data?.data)?W.data.data:[],X=W.data?.total||V.length;return{commands:V,total:X}}catch(M){throw new Error(`Failed to fetch commands: ${M}`)}};(async()=>{try{let L=await O(a);s(L.commands),S(L.total),i("list"),f(0),L.commands.length===0&&g("No commands found in the online repository.")}catch(L){g(L instanceof Error?L.message:"Failed to load commands"),i("list"),f(0)}})()},[a,t]);let N=O=>O.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),P=O=>O==="user"?B4t.join(V6o.homedir(),".iflow","commands"):B4t.join(process.cwd(),".iflow","commands"),U=async(O,q)=>{try{let L=P(q);await R4t.mkdir(L,{recursive:!0});let M=`${N(O.name)}.toml`,j=B4t.join(L,M);try{return await R4t.access(j),{success:!1,message:`Command '${O.name}' is already installed in your ${q} scope.`}}catch{}let G=`# Command: ${O.name}
|
|
3488
|
+
Update your environment and try again (no reload needed if using .env)!`:null}return[...Kh,Jr.OPENAI_COMPATIBLE].includes(t)?null:"Invalid auth method selected."};var li=ze(Wt(),1);function $nn(t){return t&&Object.values(Jr).includes(t)?t:null}function Wnn({onSelect:t,settings:e,initialErrorMessage:r}){let[n,i]=(0,nC.useState)("select"),[o,s]=(0,nC.useState)(null),[a,c]=(0,nC.useState)({baseUrl:"",apiKey:""}),[u,f]=(0,nC.useState)("baseUrl"),[d,p]=(0,nC.useState)(""),[h,g]=(0,nC.useState)(""),[A,y]=(0,nC.useState)(""),[v,S]=(0,nC.useState)(""),[w,T]=(0,nC.useState)(()=>{if(r)return r;let X=$nn(process.env.GEMINI_DEFAULT_AUTH_TYPE);return null}),N=[{label:"iFlow: Quick setup and free model to use(recommend)",value:Jr.IFLOW},{label:"OpenAI Compatible API",value:Jr.OPENAI_COMPATIBLE}],P=Math.max(0,N.findIndex(X=>{if(e.merged.selectedAuthType)return X.value===e.merged.selectedAuthType;let J=$nn(process.env.GEMINI_DEFAULT_AUTH_TYPE);return J?X.value===J:process.env.GEMINI_API_KEY?X.value===Jr.USE_GEMINI:X.value===Jr.LOGIN_WITH_GOOGLE})),U=X=>{if(Kh.includes(X))s(X),i("input-api-key"),T(null);else if(X===Jr.OPENAI_COMPATIBLE)s(X),i("input-openai-config"),f("baseUrl"),c({baseUrl:"",apiKey:""}),T(null);else{let J=yF(X);J?T(J):(T(null),t(X,"User"))}},Q=X=>{o&&Kh.includes(o)&&(y(X),i("input-model-name"),p(""))},D=X=>{if(u==="baseUrl")c(J=>({...J,baseUrl:X})),f("apiKey");else if(u==="apiKey")c(J=>({...J,apiKey:X})),f("modelName");else if(u==="modelName"){if(c(he=>({...he,modelName:X})),p(X),!z6.isMultimodalModel(X)){i("input-multimodal-model"),g("");return}i("input-search-api-key"),S("")}},F=()=>{i("select"),s(null),T(null)},O=()=>{u==="modelName"?f("apiKey"):u==="apiKey"?f("baseUrl"):(i("select"),s(null),c({baseUrl:"",apiKey:""}),f("baseUrl"),T(null))},q=X=>{if(o&&Kh.includes(o)){if(p(X),!z6.isMultimodalModel(X)&&o!==Jr.IFLOW){i("input-multimodal-model"),g("");return}if(o===Jr.IFLOW){let he={baseUrl:"https://apis.iflow.cn/v1",apiKey:A,modelName:X,searchApiKey:A,multimodalModelName:"qwen-vl-max"};t(o,"User",he)}else i("input-search-api-key"),S("")}},L=X=>{if(o&&Kh.includes(o)){if(p(X),!z6.isMultimodalModel(X)&&o!==Jr.IFLOW){i("input-multimodal-model"),g("");return}if(o===Jr.IFLOW){let he={baseUrl:"https://apis.iflow.cn/v1",apiKey:A,modelName:X,searchApiKey:A,multimodalModelName:"qwen-vl-max"};t(o,"User",he)}else i("input-search-api-key"),S("")}},M=()=>{o&&Kh.includes(o)?i("input-api-key"):(i("input-openai-config"),f("apiKey"))},j=X=>{let J=X.trim();g(J),(o&&Kh.includes(o)||o===Jr.OPENAI_COMPATIBLE)&&(i("input-search-api-key"),S(""))},G=()=>{o===Jr.OPENAI_COMPATIBLE?(i("input-openai-config"),f("modelName")):i("input-model-name")},W=X=>{if(o&&Kh.includes(o)){let J={...o===Jr.IFLOW&&{baseUrl:"https://apis.iflow.cn/v1"},apiKey:A,modelName:d,searchApiKey:o===Jr.IFLOW?A:X,multimodalModelName:h||"qwen-vl-max"};t(o,"User",J)}else if(o===Jr.OPENAI_COMPATIBLE){let J={...a,searchApiKey:X,multimodalModelName:h||""};t(o,"User",J)}},V=()=>{o===Jr.OPENAI_COMPATIBLE?h!==""?i("input-multimodal-model"):(i("input-openai-config"),f("modelName")):i(h!==""?"input-multimodal-model":"input-model-name")};if(Vi((X,J)=>{if(J.escape){if(w)return;if(e.merged.selectedAuthType===void 0){T("You must select an auth method to proceed. Press Ctrl+C twice to exit.");return}t(void 0,"User")}}),n==="input-api-key")return(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"iFlow Authentication"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Please enter your iFlow API key. See: https://docs.iflow.cn/docs/"})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(jJ,{onSubmit:Q,onCancel:F,label:"API Key:",placeholder:"Enter your iFlow API key...",isFocused:!0,validateApiKey:!0})})]});if(n==="input-model-name"){if(o===Jr.IFLOW){let X=[{label:"Qwen3-Coder-480B-A35B(recommend)",value:"Qwen3-Coder"},{label:"Qwen3-235B-A22B",value:"Qwen3-235B"},{label:"Kimi K2",value:"KIMI-K2"},{label:"GLM-4.5",value:"glm-4.5"},{label:"DeepSeek-V3.1",value:"deepseek-v3.1"},{label:"Qwen3-235B-A22B-Thinking",value:"Qwen3-235B-A22B-Thinking-2507"},{label:"Qwen3-235B-A22B-Instruct",value:"Qwen3-235B-A22B-Instruct"},{label:"Qwen-VL-Max(direct multimodal)",value:"qwen-vl-max"}];return(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"Model Configuration"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Please select the model you want to use."})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{color:ve.AccentBlue,children:"Enter To Use Default selection: Qwen3 Coder"})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(Pp,{items:X,initialIndex:0,onSelect:L,isFocused:!0})})]})}return(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"Model Configuration"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Please enter the model name you want to use."})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(Ty,{onSubmit:q,onCancel:M,label:"Model Name:",placeholder:"Enter model name (e.g. Qwen3-Coder)",isFocused:!0})})]})}return n==="input-multimodal-model"?(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"Multimodal Model Configuration"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Please enter a multimodal model name for image description generation."})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{color:ve.AccentYellow,children:"Leave empty to disable multimodal support."})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(Ty,{onSubmit:j,onCancel:G,label:"Multimodal Model:",placeholder:"Enter multimodal model name or leave empty",isFocused:!0,allowEmpty:!0})})]}):n==="input-search-api-key"?(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"Search API Configuration"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Please enter your Search API key for web search functionality."})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(jJ,{onSubmit:W,onCancel:V,label:"Search API Key:",placeholder:"https://docs.iflow.cn/docs/ Enter your iFlow search API key... ",isFocused:!0,validateApiKey:!0})})]}):n==="input-openai-config"?(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"OpenAI Compatible API Configuration"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:u==="baseUrl"?"Please enter the base URL for your OpenAI compatible API.":u==="apiKey"?"Please enter your API key.":"Please enter the model name."})}),(0,li.jsx)(Ee,{marginTop:1,children:u==="baseUrl"?(0,li.jsx)(Ty,{onSubmit:D,onCancel:O,label:"Base URL:",placeholder:"https://api.openai.com/v1",isFocused:!0}):u==="apiKey"?(0,li.jsx)(jJ,{onSubmit:D,onCancel:O,label:"API Key:",placeholder:"Enter your API key...",isFocused:!0,validateApiKey:!0}):(0,li.jsx)(Ty,{onSubmit:D,onCancel:O,label:"Model Name:",placeholder:"Enter model name (e.g. gpt-4)",isFocused:!0})}),u==="baseUrl"&&a.baseUrl&&(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsxs)(se,{color:ve.Gray,children:["Current: ",a.baseUrl]})})]}):(0,li.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,li.jsx)(se,{bold:!0,children:"Get started"}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"How would you like to authenticate for this project?"})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(Pp,{items:N,initialIndex:P,onSelect:U,isFocused:!0})}),w&&(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{color:ve.AccentRed,children:w})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{color:ve.Gray,children:"(Use Enter to select)"})}),(0,li.jsx)(Ee,{marginTop:1,children:(0,li.jsx)(se,{children:"Terms of Services and Privacy Notice for iFlow CLI"})})]})}var WDe=ze(wr(),1);var EF=ze(Wt(),1);function Ynn({onTimeout:t}){let[e,r]=(0,WDe.useState)(!1);return Vi((n,i)=>{i.escape&&t()}),(0,WDe.useEffect)(()=>{let n=setTimeout(()=>{r(!0),t()},18e4);return()=>clearTimeout(n)},[t]),(0,EF.jsx)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:e?(0,EF.jsx)(se,{color:ve.AccentRed,children:"Authentication timed out. Please try again."}):(0,EF.jsx)(Ee,{children:(0,EF.jsxs)(se,{children:[(0,EF.jsx)(TJ,{type:"dots"})," Waiting for auth... (Press ESC to cancel)"]})})})}var pf=ze(Wt(),1);function znn({onContinue:t}){return Vi((e,r)=>{(r.return||e===" ")&&t()}),(0,pf.jsxs)(Ee,{borderStyle:"round",borderColor:ve.AccentBlue,flexDirection:"column",padding:1,width:"100%",children:[(0,pf.jsx)(se,{bold:!0,color:ve.AccentBlue,children:"\u{1F680} Examples & Getting Started"}),(0,pf.jsx)(Ee,{marginTop:1,children:(0,pf.jsx)(se,{children:"Welcome to iFlow CLI! Check out these examples to get the most out of your experience:"})}),(0,pf.jsx)(Ee,{marginTop:1,children:(0,pf.jsx)(se,{bold:!0,color:ve.AccentPurple,children:"\u{1F4DA} Examples Repository:"})}),(0,pf.jsx)(Ee,{marginTop:1,marginLeft:2,children:(0,pf.jsx)(se,{color:ve.AccentBlue,children:"https://platform.iflow.cn/cli/examples/"})}),(0,pf.jsx)(Ee,{marginTop:1,children:(0,pf.jsx)(se,{bold:!0,color:ve.AccentPurple,children:"\u{1F4A1} Quick Tips:"})}),(0,pf.jsx)(Ee,{marginTop:1,marginLeft:2,children:(0,pf.jsx)(se,{children:"\u2022 Use @ to include file contents in your prompt"})}),(0,pf.jsx)(Ee,{marginLeft:2,children:(0,pf.jsx)(se,{children:"\u2022 Use ! to execute shell commands directly"})}),(0,pf.jsx)(Ee,{marginLeft:2,children:(0,pf.jsx)(se,{children:"\u2022 Use /init to create IFLOW.md for better context"})}),(0,pf.jsx)(Ee,{marginLeft:2,children:(0,pf.jsx)(se,{children:"\u2022 Use /demo to try research and brainstorming workflows"})}),(0,pf.jsx)(Ee,{marginLeft:2,children:(0,pf.jsx)(se,{children:"\u2022 Use /help to see all available commands"})}),(0,pf.jsx)(Ee,{marginTop:2,children:(0,pf.jsx)(se,{bold:!0,color:ve.AccentGreen,children:"Press Enter or Space to continue to chat \u2192"})})]})}var Jnn=ze(wr(),1);Mf();rn();var hf=ze(Wt(),1);function Knn({onSelect:t,onCancel:e,settings:r,initialErrorMessage:n}){let i=r.merged.selectedAuthType===Jr.IFLOW?"model-select":"model-input",[o,s]=(0,Jnn.useState)(n||null),a=f=>{t(f,"User")},c=f=>{if(!f.trim()){s("Model name cannot be empty");return}t(f.trim(),"User")},u=()=>{e()};if(Vi((f,d)=>{d.escape&&e()}),i==="model-select"){let f=[{label:"Qwen3-Coder-480B-A35B(recommend)",value:"Qwen3-Coder"},{label:"Qwen3-235B-A22B",value:"Qwen3-235B"},{label:"Kimi K2",value:"KIMI-K2"},{label:"GLM-4.5",value:"glm-4.5"},{label:"DeepSeek-V3.1",value:"deepseek-v3.1"},{label:"Qwen3-235B-A22B-Thinking",value:"Qwen3-235B-A22B-Thinking-2507"},{label:"Qwen3-235B-A22B-Instruct",value:"Qwen3-235B-A22B-Instruct"},{label:"Qwen-VL-Max(direct multimodal)",value:"qwen-vl-max"}];return(0,hf.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,hf.jsx)(se,{bold:!0,children:"Model Selection"}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{children:"Please select the model you want to use with iFlow."})}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{color:ve.AccentBlue,children:"Enter To Use Default selection: Qwen3 Coder"})}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(Pp,{items:f,initialIndex:0,onSelect:a,isFocused:!0})}),o&&(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{color:ve.AccentRed,children:o})}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{color:ve.Gray,children:"(Use Enter to select, Esc to cancel)"})})]})}return(0,hf.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,hf.jsx)(se,{bold:!0,children:"Model Configuration"}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{children:"Please enter the model name you want to use."})}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(Ty,{onSubmit:c,onCancel:u,label:"Model Name:",placeholder:"Enter model name (e.g. gpt-4o, claude-3-5-sonnet)",isFocused:!0})}),o&&(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{color:ve.AccentRed,children:o})}),(0,hf.jsx)(Ee,{marginTop:1,children:(0,hf.jsx)(se,{color:ve.Gray,children:"(Press Enter to confirm, Esc to cancel)"})})]})}var YDe=ze(wr(),1);var B0=ze(Wt(),1);function zDe({serverName:t,values:e,onComplete:r,onCancel:n}){let i=Object.keys(e),[o,s]=(0,YDe.useState)(0),[a,c]=(0,YDe.useState)({}),[u,f]=(0,YDe.useState)(null),d=i[o],p=e[d],h=o===i.length-1,g=v=>{if(p.type==="int"){let w=Number(v);if(isNaN(w)||!Number.isInteger(w)){f("Please enter a valid integer number");return}}f(null);let S={...a,[d]:v};c(S),h?r(S):s(o+1)},A=()=>{o>0?(s(o-1),f(null)):n()},y=()=>{let v=p.default||`Enter ${d.toLowerCase()}...`,S=`${d}:`;switch(p.type){case"password":return(0,B0.jsx)(jJ,{onSubmit:g,onCancel:A,label:S,placeholder:v,isFocused:!0,validateApiKey:!0});case"int":return(0,B0.jsx)(Ty,{onSubmit:g,onCancel:A,label:S,placeholder:v,isFocused:!0});case"string":default:return(0,B0.jsx)(Ty,{onSubmit:g,onCancel:A,label:S,placeholder:v,isFocused:!0})}};return(0,B0.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,B0.jsxs)(se,{bold:!0,children:["MCP Server Configuration: ",t]}),(0,B0.jsx)(Ee,{marginTop:1,children:(0,B0.jsxs)(se,{children:["Step ",o+1," of ",i.length,": Configure ",d]})}),(0,B0.jsx)(Ee,{marginTop:1,children:(0,B0.jsx)(se,{color:ve.AccentBlue,children:p.description})}),p.type==="int"&&(0,B0.jsx)(Ee,{marginTop:1,children:(0,B0.jsx)(se,{color:ve.Gray,children:"Expected type: Integer number"})}),(0,B0.jsx)(Ee,{marginTop:2,children:y()}),u&&(0,B0.jsx)(Ee,{marginTop:1,children:(0,B0.jsx)(se,{color:ve.AccentRed,children:u})}),(0,B0.jsx)(Ee,{marginTop:1,children:(0,B0.jsx)(se,{color:ve.Gray,children:o>0?"Press Escape to go back":"Press Escape to cancel"})})]})}var JDe=ze(wr(),1);rn();var kl=ze(Wt(),1);function Xnn({onSelect:t,onCancel:e,requestedModel:r,reason:n,availableModels:i,suggestedModel:o,taskPrompt:s}){let[a,c]=(0,JDe.useState)(null),[u,f]=(0,JDe.useState)("model_selection"),[d,p]=(0,JDe.useState)(""),h=N=>{p(N),f("preference_selection")},g=N=>{t({selectedModel:d,preference:N})},A=()=>{e()},y=()=>{f("model_selection"),p("")};Vi((N,P)=>{P.escape&&(u==="preference_selection"?y():e())});let v=i.findIndex(N=>N.value===o),S=v>=0?v:0;if(u==="model_selection")return(0,kl.jsxs)(Ee,{borderStyle:"round",borderColor:ve.AccentRed,flexDirection:"column",padding:1,width:"100%",children:[(0,kl.jsx)(se,{bold:!0,color:ve.AccentRed,children:"Model Validation Required"}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{color:ve.AccentRed,children:["Model '",r,"' is not supported."]})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{color:ve.Gray,children:["Reason: ",n]})}),s&&(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{color:ve.Gray,children:["Task: ",s.length>100?`${s.substring(0,100)}...`:s]})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(se,{children:"Please select a supported model to continue:"})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{color:ve.AccentBlue,children:["Suggested: ",i.find(N=>N.value===o)?.label||o]})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(Pp,{items:i,initialIndex:S,onSelect:h,isFocused:!0})}),a&&(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(se,{color:ve.AccentRed,children:a})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(se,{color:ve.Gray,children:"(Use Enter to select, Esc to cancel)"})})]});let w=[{label:"No, ask me each time",value:s1.OnceOnly},{label:"Yes, remember for this session",value:s1.RememberSession},{label:"Yes, remember always",value:s1.RememberAlways}],T=i.find(N=>N.value===d)?.label||d;return(0,kl.jsxs)(Ee,{borderStyle:"round",borderColor:ve.AccentBlue,flexDirection:"column",padding:1,width:"100%",children:[(0,kl.jsx)(se,{bold:!0,color:ve.AccentBlue,children:"Model Preference"}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{children:["You selected: ",(0,kl.jsx)(se,{color:ve.AccentGreen,children:T})]})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsxs)(se,{children:["In the future, when '",r,"' is not supported, would you like to always use '",T,"'?"]})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(Pp,{items:w,initialIndex:0,onSelect:g,isFocused:!0})}),(0,kl.jsx)(Ee,{marginTop:1,children:(0,kl.jsx)(se,{color:ve.Gray,children:"(Use Enter to select, Esc to go back)"})})]})}var D4t=ze(wr(),1);rn();var KDe={cursor:"Cursor",emacs:"Emacs",neovim:"Neovim",vim:"Vim",vscode:"VS Code",vscodium:"VSCodium",windsurf:"Windsurf",zed:"Zed"},T4t=class{availableEditors;constructor(){let e=Object.keys(KDe).sort();this.availableEditors=[{name:"None",type:"not_set",disabled:!1},...e.map(r=>{let n=DW(r),i=IW(r),o=i?"":" (Not available in sandbox)";return o=n?o:" (Not installed)",{name:KDe[r]+o,type:r,disabled:!n||!i}})]}getAvailableEditorDisplays(){return this.availableEditors}},Znn=new T4t;Mf();rn();var N0=ze(Wt(),1);function ein({onSelect:t,settings:e,onExit:r}){let[n,i]=(0,D4t.useState)("User"),[o,s]=(0,D4t.useState)("editor");Vi((y,v)=>{v.tab&&s(S=>S==="editor"?"scope":"editor"),v.escape&&r()});let a=Znn.getAvailableEditorDisplays(),c=e.forScope(n).settings.preferredEditor,u=c?a.findIndex(y=>y.type===c):0;u===-1&&(console.error(`Editor is not supported: ${c}`),u=0);let f=[{label:"User Settings",value:"User"},{label:"Workspace Settings",value:"Workspace"}],d=y=>{if(y==="not_set"){t(void 0,n);return}t(y,n)},p=y=>{i(y),s("editor")},h="",g=n==="User"?"Workspace":"User";e.forScope(g).settings.preferredEditor!==void 0&&(h=e.forScope(n).settings.preferredEditor!==void 0?`(Also modified in ${g})`:`(Modified in ${g})`);let A="None";return e.merged.preferredEditor&&xae(e.merged.preferredEditor)&&(A=KDe[e.merged.preferredEditor]),(0,N0.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"row",padding:1,width:"100%",children:[(0,N0.jsxs)(Ee,{flexDirection:"column",width:"45%",paddingRight:2,children:[(0,N0.jsxs)(se,{bold:o==="editor",children:[o==="editor"?"> ":" ","Select Editor"," ",(0,N0.jsx)(se,{color:ve.Gray,children:h})]}),(0,N0.jsx)(Pp,{items:a.map(y=>({label:y.name,value:y.type,disabled:y.disabled})),initialIndex:u,onSelect:d,isFocused:o==="editor"},n),(0,N0.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,N0.jsxs)(se,{bold:o==="scope",children:[o==="scope"?"> ":" ","Apply To"]}),(0,N0.jsx)(Pp,{items:f,initialIndex:0,onSelect:p,isFocused:o==="scope"})]}),(0,N0.jsx)(Ee,{marginTop:1,children:(0,N0.jsx)(se,{color:ve.Gray,children:"(Use Enter to select, Tab to change focus)"})})]}),(0,N0.jsxs)(Ee,{flexDirection:"column",width:"55%",paddingLeft:2,children:[(0,N0.jsx)(se,{bold:!0,children:"Editor Preference"}),(0,N0.jsxs)(Ee,{flexDirection:"column",gap:1,marginTop:1,children:[(0,N0.jsx)(se,{color:ve.Gray,children:"These editors are currently supported. Please note that some editors cannot be used in sandbox mode."}),(0,N0.jsxs)(se,{color:ve.Gray,children:["Your preferred editor is:"," ",(0,N0.jsx)(se,{color:A==="None"?ve.AccentRed:ve.AccentCyan,bold:!0,children:A}),"."]})]})]})]})}rn();var Qv=ze(Wt(),1);var tin=({request:t})=>{let{commands:e,onConfirm:r}=t;Vi((o,s)=>{s.escape&&r(ni.Cancel)});let n=o=>{o===ni.Cancel?r(o):r(o,e)},i=[{label:"Yes, allow once",value:ni.ProceedOnce},{label:"Yes, allow always for this session",value:ni.ProceedAlways},{label:"No (esc)",value:ni.Cancel}];return(0,Qv.jsxs)(Ee,{flexDirection:"column",borderStyle:"round",borderColor:ve.AccentYellow,padding:1,width:"100%",marginLeft:1,children:[(0,Qv.jsxs)(Ee,{flexDirection:"column",marginBottom:1,children:[(0,Qv.jsx)(se,{bold:!0,children:"Shell Command Execution"}),(0,Qv.jsx)(se,{children:"A custom command wants to run the following shell commands:"}),(0,Qv.jsx)(Ee,{flexDirection:"column",borderStyle:"round",borderColor:ve.Gray,paddingX:1,marginTop:1,children:e.map(o=>(0,Qv.jsx)(se,{color:ve.AccentCyan,children:o},o))})]}),(0,Qv.jsx)(Ee,{marginBottom:1,children:(0,Qv.jsx)(se,{children:"Do you want to proceed?"})}),(0,Qv.jsx)(Pp,{items:i,onSelect:n,isFocused:!0})]})};var W2=ze(Wt(),1);var rin=({servers:t,cwd:e,selectedIndex:r,onSelect:n,onCancel:i})=>{let o=[{id:"connect",label:"Connect to the current IDE",action:()=>n()},{id:"disconnect",label:"Disconnect from IDE",action:()=>i}];return(0,W2.jsxs)(Ee,{flexDirection:"column",paddingX:1,paddingY:1,borderStyle:"round",borderColor:ve.AccentPurple,children:[(0,W2.jsx)(Ee,{marginBottom:1,children:(0,W2.jsx)(se,{bold:!0,color:ve.AccentPurple,children:"Connect IDE"})}),(0,W2.jsx)(Ee,{marginBottom:1,children:(0,W2.jsx)(se,{children:"Connect to an IDE for integrated development features."})}),(0,W2.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,W2.jsx)(se,{color:ve.Gray,children:"Select an option (use arrow keys to navigate):"}),o.map((s,a)=>(0,W2.jsx)(Ee,{marginTop:1,marginLeft:2,children:(0,W2.jsxs)(se,{color:a===r?ve.AccentBlue:ve.Gray,children:[a===r?"\u2192 ":" ",s.label]})},s.id)),(0,W2.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,W2.jsxs)(se,{color:ve.Gray,children:["Found ",t.length||0," other running IDE(s)."]}),t.map(s=>(0,W2.jsx)(Ee,{marginTop:1,marginLeft:2,children:(0,W2.jsx)(se,{color:ve.Gray,children:s.workspaceFolders&&s.workspaceFolders[0]?`${s.ideType} : ${s.workspaceFolders[0]}`:`${s.ideType} : \u65E0\u5DE5\u4F5C\u533A\u76EE\u5F55`})},s.pid))]}),(0,W2.jsx)(Ee,{marginTop:1,children:(0,W2.jsx)(se,{color:ve.Gray,children:"Press Esc to cancel"})})]})]})};var nin=ze(wr(),1);var Dy=ze(Wt(),1);var iin=({plan:t,onApprove:e,onKeepPlanning:r,onExit:n})=>{let[i,o]=(0,nin.useState)(0),s=[{key:"1",label:"Yes, and use yolo mode edits",action:()=>e("yolo")},{key:"2",label:"Yes, and manually approve edits",action:()=>e("default")},{key:"3",label:"No, keep planning",action:r}];return Vi((a,c)=>{if(c.escape&&n){n();return}if(c.upArrow)o(u=>u>0?u-1:s.length-1);else if(c.downArrow)o(u=>u<s.length-1?u+1:0);else if(c.return)s[i].action();else if(a>="1"&&a<="3"){let u=parseInt(a)-1;u>=0&&u<s.length&&s[u].action()}}),(0,Dy.jsxs)(Ee,{flexDirection:"column",padding:1,borderStyle:"round",borderColor:ve.AccentBlue,children:[(0,Dy.jsx)(Ee,{marginBottom:1,children:(0,Dy.jsx)(se,{color:ve.AccentBlue,bold:!0,children:"Plan Ready for Review"})}),(0,Dy.jsx)(Ee,{marginBottom:2,flexDirection:"column",children:(0,Dy.jsx)(se,{color:ve.Foreground,children:t})}),(0,Dy.jsx)(Ee,{marginBottom:1,children:(0,Dy.jsx)(se,{color:ve.AccentBlue,bold:!0,children:"Would you like to proceed?"})}),s.map((a,c)=>(0,Dy.jsx)(Ee,{marginBottom:c===s.length-1?1:0,children:(0,Dy.jsxs)(se,{color:i===c?ve.AccentBlue:ve.Foreground,children:[i===c?"\u25B6 ":" ",a.key,". ",a.label]})},a.key)),(0,Dy.jsx)(Ee,{marginTop:1,children:(0,Dy.jsx)(se,{color:ve.Comment,dimColor:!0,children:"Use \u2191\u2193 arrows to navigate, Enter to select, or press 1-3"})})]})};var gE=ze(wr(),1);var Ci=ze(Wt(),1);import{readFileSync as U6o,writeFileSync as Q6o,existsSync as q6o,mkdirSync as H6o}from"fs";import{homedir as I4t}from"os";import{join as que}from"path";function oin({settings:t,config:e,onExit:r,onStatusUpdate:n}){let[i,o]=(0,gE.useState)("loading"),[s,a]=(0,gE.useState)([]),[c,u]=(0,gE.useState)(0),[f,d]=(0,gE.useState)(0),[p,h]=(0,gE.useState)(null),[g,A]=(0,gE.useState)(null),[y,v]=(0,gE.useState)(null),[S,w]=(0,gE.useState)(null),[T,N]=(0,gE.useState)(null),P=10,U=Math.max(1,Math.ceil(s.length/P));(0,gE.useEffect)(()=>{let V=async()=>{try{let J=t.merged.apiKey;if(!J)return{success:!1,message:"Please authenticate first by running the auth command"};let he=await fetch("https://apis.iflow.cn/v1/mcp-servers?pageNumber=1&pageSize=100",{method:"GET",headers:{Authorization:`Bearer ${J}`,"User-Agent":"iFlow-Cli"}});if(!he.ok){let ge="Unable to load MCP servers. Please try again later";return he.status===401?ge="Authentication failed. Please check your API key or re-authenticate":he.status===403?ge="Access denied. Please check your permissions":he.status===404?ge="MCP servers service not found. Please try again later":he.status>=500&&(ge="Server error. Please try again later"),{success:!1,message:ge}}return{success:!0,data:(await he.json()).result||[]}}catch(J){let he="Unable to load MCP servers. Please check your connection and try again";return J instanceof Error&&J.message.includes("Failed to fetch")&&(he="Network error. Please check your internet connection"),{success:!1,message:he}}};(async()=>{let J=await V();J.success&&J.data?(a(J.data),o("list"),J.data.length===0&&A("No MCP servers found in the online repository.")):(A(J.message||"Failed to load servers"),o("list"))})()},[]);let Q=V=>{let X=Object.keys(V);if(X.length===0)return null;let J=X[0],he=V[J];return he.values?he.values:null},D=V=>V?typeof V=="string"?V.includes("${")&&V.includes("}"):Array.isArray(V)?V.some(X=>D(X)):typeof V=="object"?Object.values(V).some(X=>D(X)):!1:!1,F=V=>V.startsWith("~/")?que(I4t(),V.slice(2)):V,O=(V,X)=>{let J=he=>{if(typeof he=="string"){let be=he;for(let[ge,_e]of Object.entries(X)){let Se=`\${${ge}}`,pe=F(_e);be=be.replace(new RegExp(Se.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),pe)}return be}if(Array.isArray(he))return he.map(be=>J(be));if(he&&typeof he=="object"){let be={};for(let[ge,_e]of Object.entries(he))be[ge]=J(_e);return be}return he};return J(JSON.parse(JSON.stringify(V)))},q=async(V,X,J)=>{try{let he=X==="user"?que(I4t(),".iflow","settings.json"):que(process.cwd(),".iflow","settings.json"),be=X==="user"?que(I4t(),".iflow"):que(process.cwd(),".iflow");q6o(be)||H6o(be,{recursive:!0});let ge={};try{let ie=U6o(he,"utf8");ge=JSON.parse(ie)}catch{}ge.mcpServers||(ge.mcpServers={});let _e=Object.keys(V.serverConfig)[0],Se=Object.values(V.serverConfig)[0];J&&(Se=O(Se,J));let{values:pe,...Ae}=Se;ge.mcpServers[_e]={description:V.description,...Ae},Q6o(he,JSON.stringify(ge,null,2));let ae="";try{n?.(`Loading MCP server '${V.name}' and discovering tools...`);let{MCPServerConfig:ie}=await Promise.resolve().then(()=>(rn(),fE)),de=new ie(Se.command,Se.args,Se.env,Se.cwd,Se.url,Se.httpUrl,Se.headers,Se.tcp,Se.timeout,Se.trust,V.description,Se.includeTools,Se.excludeTools,void 0,Se.oauth,Se.authProviderType);typeof e.addMcpServer=="function"?e.addMcpServer(_e,de):console.warn("Config.addMcpServer method not available, skipping dynamic loading");let te=await e.getToolRegistry();if(te){await te.discoverToolsForServer(_e);let oe=e.getGeminiClient();oe&&await oe.setTools();let me=te.getToolsByServer(_e);ae=` - ${me.length} tools loaded and ready to use`,n?.(`\u2705 MCP server '${V.name}' loaded successfully with ${me.length} tools`)}}catch(ie){console.warn("Failed to auto-discover tools from newly installed server:",ie),n?.(`\u26A0\uFE0F MCP server '${V.name}' installed but failed to load tools: ${ie}`)}return{success:!0,message:`Successfully installed ${V.name} for ${X} (${he})${ae}`}}catch(he){return{success:!1,message:`Failed to install ${V.name}: ${he}`}}},L=async(V,X)=>{let J=Q(V.serverConfig),he=Object.keys(V.serverConfig),be=he.length>0?V.serverConfig[he[0]]:{};if(J&&Object.keys(J).length>0&&D(be))h(V),w(X),N(J),o("value-input");else try{n?.(`Installing ${V.name}...`);let ge=await q(V,X);ge.success?(v(ge.message),A(null),n?.(ge.message)):(A(ge.message),v(null),n?.(`\u274C ${ge.message}`))}catch(ge){let _e=ge instanceof Error?ge.message:"Installation failed";A(_e),v(null),n?.(`\u274C ${_e}`)}},M=async V=>{if(!(!p||!S))try{n?.(`Installing ${p.name} with configuration...`);let X=await q(p,S,V);X.success?(v(X.message),A(null),n?.(X.message),o("detail"),N(null),w(null)):(A(X.message),v(null),n?.(`\u274C ${X.message}`),o("detail"),N(null),w(null))}catch(X){let J=X instanceof Error?X.message:"Installation failed";A(J),v(null),n?.(`\u274C ${J}`),o("detail"),N(null),w(null)}},j=()=>{o("detail"),N(null),w(null)};Vi((V,X)=>{if(i!=="value-input"){if(X.escape){i==="detail"?(o("list"),h(null),A(null),v(null)):r();return}if(i==="list"){if(s.length===0){V==="q"&&r();return}if(X.upArrow||V==="k"){let J=Math.max(f-1,0);d(J);let he=Math.floor(J/P);u(he)}else if(X.downArrow||V==="j"){let J=Math.min(f+1,s.length-1);d(J);let he=Math.floor(J/P);u(he)}else if(X.leftArrow||V==="h"){if(U>1){let J=Math.max(c-1,0);u(J),d(Math.min(J*P,s.length-1))}}else if(X.rightArrow||V==="l"){if(U>1){let J=Math.min(c+1,U-1);u(J),d(Math.min(J*P,s.length-1))}}else X.return||V===""?f>=0&&f<s.length&&(h(s[f]),o("detail"),A(null),v(null)):V==="q"&&r()}else i==="detail"&&p&&(V==="1"?L(p,"project"):V==="2"?L(p,"user"):V==="b"?(o("list"),h(null),A(null),v(null)):V==="q"&&r())}});let G=()=>{if(s.length===0)return(0,Ci.jsxs)(Ee,{flexDirection:"column",children:[(0,Ci.jsx)(se,{bold:!0,children:"Available MCP Servers"}),(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsx)(se,{color:ve.AccentRed,children:g||"No servers available"})})]});let V=Math.min(c*P,s.length),X=Math.min(V+P,s.length),J=s.slice(V,X);return(0,Ci.jsxs)(Ee,{flexDirection:"column",children:[(0,Ci.jsxs)(se,{bold:!0,children:["Available MCP Servers (",s.length," total)"]}),(0,Ci.jsx)(Ee,{marginTop:1,flexDirection:"column",children:J.map((he,be)=>{let _e=V+be===f;return(0,Ci.jsxs)(Ee,{marginBottom:1,children:[(0,Ci.jsxs)(se,{color:_e?ve.AccentCyan:void 0,children:[_e?"\u25B6 ":" ",be+1,". ",he.name]}),(0,Ci.jsx)(Ee,{marginLeft:4,children:(0,Ci.jsx)(se,{color:ve.Gray,children:he.description})}),(0,Ci.jsx)(Ee,{marginLeft:4,children:(0,Ci.jsxs)(se,{color:ve.Gray,children:["Tools: ",he.tools?.length||0," | Visits: ",he.visitCount||0]})})]},he.id)})}),(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsxs)(se,{color:ve.AccentBlue,children:["Page ",c+1," of ",U]})}),(0,Ci.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Ci.jsx)(se,{color:ve.Gray,children:"Navigation:"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 \u2191/\u2193 or j/k - Navigate up/down"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 \u2190/\u2192 or h/l - Previous/Next page"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 Enter - View details"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]})},W=()=>p?(0,Ci.jsxs)(Ee,{flexDirection:"column",children:[(0,Ci.jsx)(se,{bold:!0,children:p.name}),(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsx)(se,{color:ve.AccentBlue,children:p.description})}),(0,Ci.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Ci.jsx)(se,{color:ve.AccentCyan,children:"Details:"}),(0,Ci.jsxs)(se,{children:[" \u2022 Version: ",p.versionType]}),(0,Ci.jsxs)(se,{children:[" \u2022 Protocol: ",p.protocolVersion]}),(0,Ci.jsxs)(se,{children:[" \u2022 Transports: ",p.transports?.join(", ")||"N/A"]}),(0,Ci.jsxs)(se,{children:[" \u2022 Auth Types: ",p.authTypes?.join(", ")||"N/A"]}),(0,Ci.jsxs)(se,{children:[" \u2022 Visits: ",p.visitCount||0]})]}),p.tools&&p.tools.length>0&&(0,Ci.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Ci.jsxs)(se,{color:ve.AccentCyan,children:["Available Tools (",p.tools.length,"):"]}),p.tools.map((V,X)=>(0,Ci.jsxs)(Ee,{marginLeft:2,children:[(0,Ci.jsxs)(se,{children:[X+1,". ",V.name]}),(0,Ci.jsx)(Ee,{marginLeft:2,children:(0,Ci.jsx)(se,{color:ve.Gray,children:V.description})})]},X))]}),(0,Ci.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Ci.jsx)(se,{color:ve.AccentYellow,children:"Actions:"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 1 - Install for project"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 2 - Install for user"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 b - Back to list"}),(0,Ci.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]}),y&&(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsxs)(se,{color:ve.AccentGreen,children:["\u2705 ",y]})}),g&&(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsx)(se,{color:ve.AccentRed,children:g})})]}):null;return i==="loading"?(0,Ci.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,Ci.jsx)(se,{bold:!0,children:"Loading MCP Servers..."}),(0,Ci.jsx)(Ee,{marginTop:1,children:(0,Ci.jsx)(se,{children:"Please wait while we fetch available servers..."})})]}):i==="value-input"&&p&&T?(0,Ci.jsx)(zDe,{serverName:p.name,values:T,onComplete:M,onCancel:j}):(0,Ci.jsx)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:i==="list"?G():W()})}var iC=ze(wr(),1);Bq();rn();var Wr=ze(Wt(),1);import{readFileSync as sin,writeFileSync as G6o}from"fs";import{homedir as j6o}from"os";import{join as ain}from"path";function lin({settings:t,config:e,onExit:r,onStatusUpdate:n}){let[i,o]=(0,iC.useState)("loading"),[s,a]=(0,iC.useState)([]),[c,u]=(0,iC.useState)(0),[f,d]=(0,iC.useState)(0),[p,h]=(0,iC.useState)(null),[g,A]=(0,iC.useState)(null),[y,v]=(0,iC.useState)(null),S=10,w=Math.max(1,Math.ceil(s.length/S));(0,iC.useEffect)(()=>{(async()=>{try{let F=e.getMcpServers()||{},O=Object.keys(F);if(O.length===0){a([]),o("list");return}let q=await e.getToolRegistry(),L=await e.getPromptRegistry(),M=[];for(let j of O){let G=F[j],W=Wx(j),X=(q?.getAllTools()||[]).filter(ge=>ge instanceof f2&&ge.serverName===j),J=L?.getPromptsByServer(j)||[],he=$H.get(j)||!1,be="";if(G.oauth?.enabled)try{let{MCPOAuthTokenStorage:ge}=await Promise.resolve().then(()=>(rn(),fE)),_e=await ge.getToken(j);_e?be=ge.isTokenExpired(_e.token)?"expired":"authenticated":be="not authenticated"}catch{be="unknown"}M.push({name:j,config:G,status:W,tools:X,prompts:J,needsAuth:he,oauthStatus:be})}a(M),o("list"),d(0),u(0)}catch(F){A(F instanceof Error?F.message:"Failed to load servers"),o("list"),d(0),u(0)}})()},[e]);let T=async D=>{try{let F="project",O=ain(process.cwd(),".iflow","settings.json"),q=ain(j6o(),".iflow","settings.json");try{let G=sin(q,"utf8"),W=JSON.parse(G);W.mcpServers&&W.mcpServers[D.name]&&(F="user",O=q)}catch{}let L=sin(O,"utf8"),M=JSON.parse(L);if(!M.mcpServers||!M.mcpServers[D.name])return{success:!1,message:`Server "${D.name}" not found in ${F} settings.`};delete M.mcpServers[D.name],G6o(O,JSON.stringify(M,null,2)),e.removeMcpServer(D.name);let j=await e.getToolRegistry();if(j){await j.discoverMcpTools();let G=e.getGeminiClient();G&&await G.setTools()}return{success:!0,message:`Successfully removed "${D.name}" from ${F} settings.`}}catch(F){return{success:!1,message:`Failed to remove "${D.name}": ${F}`}}},N=async()=>{if(y)try{n?.(`Removing server "${y.name}"...`);let D=await T(y);if(D.success){n?.(D.message);let F=s.filter(O=>O.name!==y.name);a(F),d(Math.max(0,Math.min(f,F.length-1))),v(null),o("list")}else A(D.message),n?.(`\u274C ${D.message}`),v(null),o("list")}catch(D){let F=D instanceof Error?D.message:"Removal failed";A(F),n?.(`\u274C ${F}`),v(null),o("list")}};Vi((D,F)=>{if(F.escape){i==="detail"?(o("list"),h(null),A(null)):i==="confirm-remove"?(o("list"),v(null)):r();return}if(i==="list"){if(s.length===0){if(D==="q")r();else if(D==="o"){let O="https://platform.iflow.cn/mcp";n?.(`Opening MCP platform in your browser: ${O}`),zb(O).catch(q=>{A(`Failed to open MCP platform: ${q.message}`)})}return}if(F.upArrow||D==="k"){let O=Math.max(f-1,0);d(O);let q=Math.floor(O/S);u(q)}else if(F.downArrow||D==="j"){let O=Math.min(f+1,s.length-1);d(O);let q=Math.floor(O/S);u(q)}else if(F.leftArrow||D==="h"){if(w>1){let O=Math.max(c-1,0);u(O),d(Math.min(O*S,s.length-1))}}else if(F.rightArrow||D==="l"){if(w>1){let O=Math.min(c+1,w-1);u(O),d(Math.min(O*S,s.length-1))}}else D===" "||F.return?f>=0&&f<s.length&&(h(s[f]),o("detail"),A(null)):D==="d"||F.delete?f>=0&&f<s.length&&(v(s[f]),o("confirm-remove")):D==="q"&&r()}else i==="detail"&&p?D==="d"||F.delete?(v(p),o("confirm-remove")):D==="b"?(o("list"),h(null),A(null)):D==="q"&&r():i==="confirm-remove"&&(D==="y"||D==="Y"?N():(D==="n"||D==="N")&&(o(p?"detail":"list"),v(null)))});let P=()=>{if(s.length===0)return(0,Wr.jsxs)(Ee,{flexDirection:"column",children:[(0,Wr.jsx)(se,{bold:!0,children:"Configured MCP Servers"}),(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{color:ve.AccentYellow,children:g||"No MCP servers configured. Use /mcp online to browse and install servers."})}),(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsx)(se,{color:ve.Gray,children:"Navigation:"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 o - Open MCP platform"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]});let D=Math.min(c*S,s.length),F=Math.min(D+S,s.length),O=s.slice(D,F);return(0,Wr.jsxs)(Ee,{flexDirection:"column",children:[(0,Wr.jsxs)(se,{bold:!0,children:["Configured MCP Servers (",s.length," total)"]}),(0,Wr.jsx)(Ee,{marginTop:1,flexDirection:"column",children:O.map((q,L)=>{let j=D+L===f,G="",W="";switch(q.status){case es.CONNECTED:G="\u{1F7E2}",W="Ready";break;case es.CONNECTING:G="\u{1F504}",W="Starting...";break;case es.DISCONNECTED:default:G="\u{1F534}",W="Disconnected";break}return(0,Wr.jsxs)(Ee,{marginBottom:1,children:[(0,Wr.jsxs)(se,{color:j?ve.AccentCyan:void 0,children:[j?"\u25B6 ":" ",G," ",q.name," - ",W]}),(0,Wr.jsx)(Ee,{marginLeft:4,children:(0,Wr.jsx)(se,{color:ve.Gray,children:q.config.description||"No description"})}),(0,Wr.jsx)(Ee,{marginLeft:4,children:(0,Wr.jsxs)(se,{color:ve.Gray,children:["Tools: ",q.tools.length," | Prompts: ",q.prompts.length,q.config.extensionName&&` | From: ${q.config.extensionName}`]})})]},q.name)})}),w>1&&(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsxs)(se,{color:ve.AccentBlue,children:["Page ",c+1," of ",w]})}),(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsx)(se,{color:ve.Gray,children:"Navigation:"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 \u2191/\u2193 or j/k - Navigate up/down"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 Space/Enter - View server details"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 d/Delete - Remove server"}),w>1&&(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 \u2190/\u2192 or h/l - Previous/Next page"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]}),g&&(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{color:ve.AccentRed,children:g})})]})},U=()=>{if(!p)return null;let D=p;return(0,Wr.jsxs)(Ee,{flexDirection:"column",children:[(0,Wr.jsx)(se,{bold:!0,children:D.name}),(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{color:ve.AccentBlue,children:D.config.description||"No description available"})}),(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsx)(se,{color:ve.AccentCyan,children:"Server Details:"}),(0,Wr.jsxs)(se,{children:[" \u2022 Status: ",D.status===es.CONNECTED?"\u{1F7E2} Connected":D.status===es.CONNECTING?"\u{1F504} Connecting":"\u{1F534} Disconnected"]}),D.config.command&&(0,Wr.jsxs)(se,{children:[" \u2022 Command: ",D.config.command," ",D.config.args?.join(" ")||""]}),D.config.httpUrl&&(0,Wr.jsxs)(se,{children:[" \u2022 HTTP URL: ",D.config.httpUrl]}),D.config.url&&(0,Wr.jsxs)(se,{children:[" \u2022 SSE URL: ",D.config.url]}),D.config.extensionName&&(0,Wr.jsxs)(se,{children:[" \u2022 Source: ",D.config.extensionName," extension"]}),D.config.oauth?.enabled&&(0,Wr.jsxs)(se,{children:[" \u2022 OAuth: ",D.oauthStatus==="authenticated"?"\u{1F7E2} Authenticated":D.oauthStatus==="expired"?"\u{1F7E1} Token Expired":"\u{1F534} Not Authenticated"]})]}),D.tools.length>0&&(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsxs)(se,{color:ve.AccentCyan,children:["Available Tools (",D.tools.length,"):"]}),D.tools.slice(0,10).map((F,O)=>(0,Wr.jsxs)(Ee,{marginLeft:2,children:[(0,Wr.jsxs)(se,{children:[O+1,". ",F.name]}),F.description&&(0,Wr.jsx)(Ee,{marginLeft:2,children:(0,Wr.jsx)(se,{color:ve.Gray,children:F.description})})]},O)),D.tools.length>10&&(0,Wr.jsxs)(se,{color:ve.Gray,children:[" ... and ",D.tools.length-10," more tools"]})]}),D.prompts.length>0&&(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsxs)(se,{color:ve.AccentCyan,children:["Available Prompts (",D.prompts.length,"):"]}),D.prompts.slice(0,5).map((F,O)=>(0,Wr.jsxs)(Ee,{marginLeft:2,children:[(0,Wr.jsxs)(se,{children:[O+1,". ",F.name]}),F.description&&(0,Wr.jsx)(Ee,{marginLeft:2,children:(0,Wr.jsx)(se,{color:ve.Gray,children:F.description})})]},O)),D.prompts.length>5&&(0,Wr.jsxs)(se,{color:ve.Gray,children:[" ... and ",D.prompts.length-5," more prompts"]})]}),(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsx)(se,{color:ve.AccentYellow,children:"Actions:"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 d/Delete - Remove this server"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 b - Back to list"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 Esc - Back to list"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]}),g&&(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{color:ve.AccentRed,children:g})})]})},Q=()=>y?(0,Wr.jsxs)(Ee,{flexDirection:"column",children:[(0,Wr.jsx)(se,{bold:!0,color:ve.AccentRed,children:"Confirm Server Removal"}),(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{children:"Are you sure you want to remove the following MCP server?"})}),(0,Wr.jsxs)(Ee,{marginTop:1,marginLeft:2,children:[(0,Wr.jsx)(se,{bold:!0,children:y.name}),(0,Wr.jsx)(Ee,{marginLeft:2,children:(0,Wr.jsx)(se,{color:ve.Gray,children:y.config.description||"No description"})}),(0,Wr.jsx)(Ee,{marginLeft:2,children:(0,Wr.jsxs)(se,{color:ve.Gray,children:["Tools: ",y.tools.length," | Prompts: ",y.prompts.length]})})]}),(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{color:ve.AccentYellow,children:"This will remove the server from your configuration and stop all its tools."})}),(0,Wr.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,Wr.jsx)(se,{color:ve.AccentCyan,children:"Actions:"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 y/Y - Yes, remove server"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 n/N - No, cancel"}),(0,Wr.jsx)(se,{color:ve.Gray,children:" \u2022 Esc - Cancel"})]})]}):null;return i==="loading"?(0,Wr.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,Wr.jsx)(se,{bold:!0,children:"Loading MCP Servers..."}),(0,Wr.jsx)(Ee,{marginTop:1,children:(0,Wr.jsx)(se,{children:"Please wait while we load your configured servers..."})})]}):(0,Wr.jsx)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:i==="list"?P():i==="detail"?U():Q()})}var oC=ze(wr(),1);var hn=ze(Wt(),1);function cin({settings:t,config:e,onExit:r,onStatusUpdate:n}){let[i,o]=(0,oC.useState)("loading"),[s,a]=(0,oC.useState)([]),[c,u]=(0,oC.useState)(0),[f,d]=(0,oC.useState)(0),[p,h]=(0,oC.useState)(null),[g,A]=(0,oC.useState)(null),[y,v]=(0,oC.useState)(null),S=10,w=Math.ceil(s.length/S);(0,oC.useEffect)(()=>{let Q=async()=>{try{let F=t.merged.apiKey;if(!F)return{success:!1,message:"Please authenticate first by running the auth command"};let O=await fetch("https://apis.iflow.cn/v1/agents/list",{method:"POST",headers:{Authorization:`Bearer ${F}`,"User-Agent":"iFlow-Cli","Content-Type":"application/json"},body:JSON.stringify({page:1,size:100,usePage:!0})});if(!O.ok){let L="Unable to load agents. Please try again later";return O.status===401?L="Authentication failed. Please check your API key or re-authenticate":O.status===403?L="Access denied. Please check your permissions":O.status===404?L="Agents service not found. Please try again later":O.status>=500&&(L="Server error. Please try again later"),{success:!1,message:L}}let q=await O.json();return q.success?{success:!0,data:q.data?.data||[]}:{success:!1,message:q.message||"Failed to load agents from server"}}catch(F){let O="Unable to load agents. Please check your connection and try again";return F instanceof Error&&F.message.includes("Failed to fetch")&&(O="Network error. Please check your internet connection"),{success:!1,message:O}}};(async()=>{let F=await Q();F.success&&F.data?(a(F.data),o("list"),F.data.length===0&&A("No agents found in the online repository.")):(A(F.message||"Failed to load agents"),o("list"))})()},[]);let T=async(Q,D)=>{try{let{AgentRegistry:F}=await Promise.resolve().then(()=>(rn(),fE)),O=new F,q=[],L=!0,M=!0,j,G=null;if(Q.extInfo&&typeof Q.extInfo=="string")try{G=JSON.parse(Q.extInfo)}catch{}if(G){if(L=G["is-inherit-tools"],M=G["is-inherit-mcps"]!==void 0?G["is-inherit-mcps"]:!0,G["allowed-tools"]){let X=G["allowed-tools"].split(",").map(J=>J.trim()).filter(J=>J);X.length>0?q=X:q=G["is-inherit-tools"]?["*"]:[]}else q=G["is-inherit-tools"]?["*"]:[];if(G.mcps){let X=G.mcps.split(",").map(J=>J.trim()).filter(J=>J);X.length>0?j=X:j=G["is-inherit-mcps"]?void 0:[]}else j=G["is-inherit-mcps"]?void 0:[]}else{try{let X=JSON.parse(Q.tools||"[]");q=Array.isArray(X)?X:["*"]}catch{q=["*"]}if(Q.mcps)try{let X=JSON.parse(Q.mcps);Array.isArray(X)&&X.length>0&&(j=X)}catch{let X=Q.mcps.split(",").map(J=>J.trim()).filter(J=>J.length>0);X.length>0&&(j=X)}}let W={agentType:Q.name.toLowerCase().replace(/[^a-z0-9]/g,"-"),name:Q.name,description:Q.description,whenToUse:Q.description,allowedTools:q,allowedMcps:j,systemPrompt:Q.detailContext||Q.description,location:D==="user"?"global":"project",model:Q.modelName,isInheritTools:L,isInheritMcps:M};return await O.createAgent(W)?{success:!0,message:`Successfully installed agent '${Q.name}' for ${D}`}:{success:!1,message:`Failed to create agent for '${Q.name}'`}}catch(F){return{success:!1,message:`Failed to install ${Q.name}: ${F}`}}},N=async(Q,D)=>{try{n?.(`Installing ${Q.name}...`);let F=await T(Q,D);F.success?(v(F.message),A(null),n?.(F.message)):(A(F.message),v(null),n?.(`\u274C ${F.message}`))}catch(F){let O=F instanceof Error?F.message:"Installation failed";A(O),v(null),n?.(`\u274C ${O}`)}};Vi((Q,D)=>{if(D.escape){i==="detail"?(o("list"),h(null),A(null),v(null)):r();return}if(i==="list")if(D.upArrow||Q==="k"){let F=Math.max(f-1,0);d(F);let O=Math.floor(F/S);u(O)}else if(D.downArrow||Q==="j"){let F=Math.min(f+1,s.length-1);d(F);let O=Math.floor(F/S);u(O)}else if(D.leftArrow||Q==="h"){let F=Math.max(c-1,0);u(F),d(F*S)}else if(D.rightArrow||Q==="l"){let F=Math.min(c+1,w-1);u(F),d(Math.min(F*S,s.length-1))}else D.return||Q===""?s.length>0&&f>=0&&f<s.length&&(h(s[f]),o("detail"),A(null),v(null)):Q==="q"&&r();else i==="detail"&&p&&(Q==="1"?N(p,"project"):Q==="2"?N(p,"user"):Q==="b"?(o("list"),h(null),A(null),v(null)):Q==="q"&&r())});let P=()=>{if(s.length===0)return(0,hn.jsxs)(Ee,{flexDirection:"column",children:[(0,hn.jsx)(se,{bold:!0,children:"Available Agents"}),(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsx)(se,{color:ve.AccentRed,children:g||"No agents available"})})]});let Q=c*S,D=Math.min(Q+S,s.length),F=s.slice(Q,D);return(0,hn.jsxs)(Ee,{flexDirection:"column",children:[(0,hn.jsxs)(se,{bold:!0,children:["Available Agents (",s.length," total)"]}),(0,hn.jsx)(Ee,{marginTop:1,flexDirection:"column",children:F.map((O,q)=>{let M=Q+q===f;return(0,hn.jsxs)(Ee,{marginBottom:1,flexDirection:"row",children:[(0,hn.jsxs)(Ee,{width:30,flexShrink:0,flexDirection:"column",children:[(0,hn.jsxs)(se,{color:M?ve.AccentCyan:void 0,children:[M?"\u25B6 ":" ",q+1,". ",O.name]}),(0,hn.jsx)(Ee,{marginLeft:4,flexDirection:"column",children:(0,hn.jsxs)(se,{color:ve.Gray,children:["Category:",O.category]})})]}),(0,hn.jsx)(Ee,{marginLeft:3,flexGrow:1,children:(0,hn.jsx)(se,{color:ve.Gray,children:O.description})})]},O.id)})}),(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsxs)(se,{color:ve.AccentBlue,children:["Page ",c+1," of ",w]})}),(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.Gray,children:"Navigation:"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 \u2191/\u2193 or j/k - Navigate up/down"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 \u2190/\u2192 or h/l - Previous/Next page"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 Enter - View details"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]})},U=()=>p?(0,hn.jsxs)(Ee,{flexDirection:"column",children:[(0,hn.jsx)(se,{bold:!0,children:p.name}),(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsx)(se,{color:ve.AccentBlue,children:p.description})}),(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"Details:"}),(0,hn.jsxs)(se,{children:[" \u2022 Model: ",p.modelName]}),(0,hn.jsxs)(se,{children:[" \u2022 Category: ",p.category]}),(0,hn.jsxs)(se,{children:[" \u2022 Version: ",p.version]})]}),(()=>{let Q=null;if(p.extInfo&&typeof p.extInfo=="string")try{Q=JSON.parse(p.extInfo)}catch{}return Q?(0,hn.jsxs)(hn.Fragment,{children:[(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"Tools:"}),(0,hn.jsx)(Ee,{marginLeft:2,children:(0,hn.jsx)(se,{children:(()=>{let D=Q["allowed-tools"]?Q["allowed-tools"].split(",").map(O=>O.trim()).filter(O=>O):[],F=Q["is-inherit-tools"]?" (inherit)":" (no inherit)";return D.length>0?D.join(", ")+F:Q["is-inherit-tools"]?"All tools available (inherit)":"No tools available (no inherit)"})()})})]}),(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"MCP Servers:"}),(0,hn.jsx)(Ee,{marginLeft:2,children:(0,hn.jsx)(se,{children:(()=>{let D=Q.mcps?Q.mcps.split(",").map(O=>O.trim()).filter(O=>O):[],F=Q["is-inherit-mcps"]?" (inherit)":" (no inherit)";return D.length>0?D.join(", ")+F:Q["is-inherit-mcps"]?"All MCP servers available (inherit)":"No MCP servers available (no inherit)"})()})})]})]}):(0,hn.jsxs)(hn.Fragment,{children:[(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"Tools:"}),(0,hn.jsx)(Ee,{marginLeft:2,children:(0,hn.jsx)(se,{children:(()=>{if(!p.tools)return"All tools available (inherit)";try{let D=JSON.parse(p.tools);return Array.isArray(D)?D.length>0?D.join(", ")+" (inherit)":"All tools available (inherit)":(p.tools||"All tools available")+" (inherit)"}catch{return(p.tools||"All tools available")+" (inherit)"}})()})})]}),(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"MCP Servers:"}),(0,hn.jsx)(Ee,{marginLeft:2,children:(0,hn.jsx)(se,{children:(()=>{if(!p.mcps||p.mcps.trim()==="")return"All MCP servers available (inherit)";try{let D=JSON.parse(p.mcps);return Array.isArray(D)?D.length>0?D.join(", ")+" (inherit)":"All MCP servers available (inherit)":(p.mcps||"All MCP servers available")+" (inherit)"}catch{return(p.mcps||"All MCP servers available")+" (inherit)"}})()})})]})]})})(),p.detailContext&&(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentCyan,children:"System Prompt:"}),(0,hn.jsx)(Ee,{marginLeft:2,children:(0,hn.jsx)(se,{children:p.detailContext.length>800?`${p.detailContext.substring(0,800)}...`:p.detailContext})})]}),(0,hn.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,hn.jsx)(se,{color:ve.AccentYellow,children:"Actions:"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 1 - Install for project"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 2 - Install for user"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 b - Back to list"}),(0,hn.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]}),y&&(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsxs)(se,{color:ve.AccentGreen,children:["\u2705 ",y]})}),g&&(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsx)(se,{color:ve.AccentRed,children:g})})]}):null;return i==="loading"?(0,hn.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,hn.jsx)(se,{bold:!0,children:"Loading Agents..."}),(0,hn.jsx)(Ee,{marginTop:1,children:(0,hn.jsx)(se,{children:"Please wait while we fetch available agents..."})})]}):(0,hn.jsx)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:i==="list"?P():U()})}var E1=ze(wr(),1);var or=ze(Wt(),1);function uin({settings:t,config:e,onExit:r,onStatusUpdate:n}){let[i,o]=(0,E1.useState)("location"),[s,a]=(0,E1.useState)(0),[c,u]=(0,E1.useState)({}),[f,d]=(0,E1.useState)(null),[p,h]=(0,E1.useState)(null),[g,A]=(0,E1.useState)(!1),[y,v]=(0,E1.useState)([]),[S,w]=(0,E1.useState)([]),[T,N]=(0,E1.useState)(""),[P,U]=(0,E1.useState)(null),[Q,D]=(0,E1.useState)("");(0,E1.useEffect)(()=>{(async()=>{try{let ie=await e.getToolRegistry();if(ie){let oe=["task","exit_plan_mode","save_memory"],K=ie.getAllTools().filter(re=>{let xe="serverName"in re&&re.serverName!==void 0,ye=oe.filter(Z=>Z===re.name).length>0;return!xe&&!ye}).map(re=>re.name);v(K),u(re=>({...re,selectedTools:K}))}let de=e.getMcpServers()||{},te=Object.keys(de);w(te),u(oe=>({...oe,selectedMcps:te}))}catch(ie){console.error("Failed to initialize data:",ie)}})()},[e]);let O={location:{name:"location",title:"Choose Installation Location",description:"Where would you like to install the agent?",type:"select",options:[{id:"project",title:"Project Agent",description:"Install in the current project (accessible only to this project)",available:!0},{id:"user",title:"User Agent",description:"Install globally for your user (accessible across all projects)",available:!0}]},method:{name:"method",title:"Choose Creation Method",description:"How would you like to create the agent?",type:"select",options:[{id:"iFlow",title:"Generate with iFlow (recommended)",description:"Create through the intelligent guidance of iFlow",available:!0},{id:"template",title:"Manual configuration",description:"Create it step by step by hand",available:!0},{id:"online",title:"From Online Repository",description:"Browse and install from the online agent repository",available:!0}]},agentGoal:{name:"agentGoal",title:"Describe Your Agent Goal",description:"What do you want this agent to do? Be specific about its purpose and capabilities.",type:"input",placeholder:"e.g. Review code for security vulnerabilities and best practices"},agentType:{name:"agentType",title:"Agent Type (identifier)",description:"Enter a unique identifier for your agent",type:"input",placeholder:"e.g. code-reviewer, tech-lead, etc"},systemPrompt:{name:"systemPrompt",title:"System Prompt",description:"Define the agent's behavior and capabilities",type:"input",placeholder:"Enter system prompt. Be comprehensive for best results"},description:{name:"description",title:"Agent Description",description:"Provide a brief description of what this agent does",type:"input",placeholder:"Enter agent description"},tools:{name:"tools",title:"Select Tools",description:"Choose which tools this agent can use",type:"multiselect",options:y.map(ae=>({id:ae,title:ae,description:`Allow access to ${ae} tool`,available:!0}))},mcps:{name:"mcps",title:"Select MCP Servers",description:"Choose which MCP servers this agent can access",type:"multiselect",options:S.map(ae=>({id:ae,title:ae,description:`Allow access to ${ae} MCP server`,available:!0}))},color:{name:"color",title:"Choose Background Color",description:"Select a color for your agent",type:"select",options:[{id:"automatic",title:"Automatic color",description:"Let the system choose a color automatically",available:!0},{id:"red",title:"Red",description:"",available:!0},{id:"blue",title:"Blue",description:"",available:!0},{id:"green",title:"Green",description:"",available:!0},{id:"yellow",title:"Yellow",description:"",available:!0},{id:"purple",title:"Purple",description:"",available:!0},{id:"orange",title:"Orange",description:"",available:!0},{id:"pink",title:"Pink",description:"",available:!0},{id:"cyan",title:"Cyan",description:"",available:!0}]},"generated-preview":{name:"generated-preview",title:"Review Generated Configuration",description:"Review and edit the AI-generated agent configuration",type:"edit",options:[{id:"agentType",title:"Agent Type",description:`${c.agentType||"(not set)"}`,available:!0},{id:"description",title:"Description",description:`${c.description||"(not set)"}`,available:!0},{id:"systemPrompt",title:"System Prompt",description:`${c.systemPrompt?c.systemPrompt.length>600?c.systemPrompt.substring(0,600)+"...":c.systemPrompt:"(not set)"}`,available:!0}]},preview:{name:"preview",title:"Preview Agent Configuration",description:"Review your agent configuration before creating",type:"preview"},generating:null,installing:null,success:null,error:null}[i],q=O?.options?.filter(ae=>ae.available)||[];(0,E1.useEffect)(()=>{a(0),d(null),A(!1),U(null),D("")},[i]);let L=ae=>{let ie=["location","method","agentType","systemPrompt","description","tools","mcps","color","preview"],de=["location","method","agentGoal","generating","generated-preview","tools","mcps","color","preview"];if(ae==="method")return c.method==="template"?"agentType":c.method==="iFlow"?"agentGoal":null;let te=c.method==="iFlow"?de:ie,oe=te.indexOf(ae);return oe<te.length-1?te[oe+1]:null},M=ae=>{let ie=["location","method","agentType","systemPrompt","description","tools","mcps","color","preview"],de=["location","method","agentGoal","generating","generated-preview","tools","mcps","color","preview"],te=c.method==="iFlow"?de:ie,oe=te.indexOf(ae);return oe>0?te[oe-1]:null},j=()=>{switch(i){case"agentGoal":return c.agentGoal||"";case"agentType":return c.agentType||"";case"systemPrompt":return c.systemPrompt||"";case"description":return c.description||"";default:return""}},G=ae=>{if(i==="agentGoal"){if(u(de=>({...de,agentGoal:ae})),c.method==="iFlow"){J(ae);return}}else i==="agentType"?u(de=>({...de,agentType:ae})):i==="systemPrompt"?u(de=>({...de,systemPrompt:ae})):i==="description"&&u(de=>({...de,description:ae}));A(!1);let ie=L(i);ie&&(o(ie),a(0))},W=()=>{A(!1),U(null),D("")},V=ae=>{P==="agentType"?u(ie=>({...ie,agentType:ae})):P==="description"?u(ie=>({...ie,description:ae})):P==="systemPrompt"&&u(ie=>({...ie,systemPrompt:ae})),U(null),D("")},X=()=>{U(null),D("")},J=async ae=>{try{o("generating"),d(null),n?.("Generating agent configuration from your goal...");let{generateAgentConfig:ie}=await Promise.resolve().then(()=>(rn(),fE)),de=await ie(e,{agentGoal:ae,onProgress:te=>{N(te),n?.(te)}});u(te=>({...te,agentType:de.identifier,systemPrompt:de.systemPrompt,description:de.whenToUse})),o("generated-preview"),a(0),n?.("\u2705 Agent configuration generated successfully!")}catch(ie){o("error");let de=ie instanceof Error?ie.message:String(ie);d(`Failed to generate agent configuration: ${de}`),n?.(`\u274C Failed to generate configuration: ${de}`)}},he=async()=>{try{o("installing"),n?.(`Creating agent '${c.agentType}'...`);let{createAgent:ae}=await Promise.resolve().then(()=>(rn(),fE)),ie={agentType:c.agentType,name:c.agentType,description:c.description,whenToUse:c.description,allowedTools:c.selectedTools?.length?c.selectedTools:["*"],allowedMcps:c.selectedMcps?.length?c.selectedMcps:void 0,systemPrompt:c.systemPrompt,location:c.location==="user"?"global":"project",isInheritTools:!0,isInheritMcps:!0},de=await ae(ie);o("success"),h(`Successfully created agent '${c.agentType}' at ${de}`),n?.(`\u2705 Successfully created agent '${c.agentType}'`),setTimeout(()=>{r()},3e3)}catch(ae){o("error");let ie=ae instanceof Error?ae.message:String(ae);d(`Failed to create agent: ${ie}`),n?.(`\u274C Failed to create agent: ${ie}`)}},be=()=>{let ae=O;if(!ae)return;if(ae.type==="select"){let de=q[s];if(de)if(i==="location")u(te=>({...te,location:de.id}));else if(i==="method"){let te=de.id;if(u(me=>({...me,method:te})),te==="online"){h("Redirecting to online repository..."),n?.("Use /agents online to browse and install agents from the online repository"),setTimeout(()=>{r()},2e3);return}let oe=null;te==="template"?oe="agentType":te==="iFlow"&&(oe="agentGoal"),oe&&(o(oe),a(0),A(!1),d(null));return}else i==="color"&&u(te=>({...te,color:de.id}))}else if(ae.type==="input"){if(!g){A(!0);return}}else if(ae.type==="multiselect")if(s===0){let de=L(i);de&&(o(de),a(0),A(!1),d(null));return}else{let de=q[s-1];if(i==="tools"){let te=c.selectedTools||[],oe=te.includes(de.id);u(oe?me=>({...me,selectedTools:te.filter(ue=>ue!==de.id)}):me=>({...me,selectedTools:[...te,de.id]}))}else if(i==="mcps"){let te=c.selectedMcps||[],oe=te.includes(de.id);u(oe?me=>({...me,selectedMcps:te.filter(ue=>ue!==de.id)}):me=>({...me,selectedMcps:[...te,de.id]}))}return}else if(ae.type==="edit"){if(P)return;if(s===0){let de=L(i);de&&(o(de),a(0),A(!1),d(null))}else{let de=q[s-1];U(de.id);let te="";de.id==="agentType"?te=c.agentType||"":de.id==="description"?te=c.description||"":de.id==="systemPrompt"&&(te=c.systemPrompt||""),D(te)}return}else if(ae.type==="preview"){he();return}let ie=L(i);ie&&(o(ie),a(0),A(!1),d(null))},ge=()=>{if(g){A(!1);return}if(P){U(null),D("");return}let ae=M(i);ae?(o(ae),a(0),d(null)):r()};Vi((ae,ie)=>{if(g||P)return;if(ie.escape){ge();return}if(ae==="q"){r();return}let de=O;if(de){if(de.type==="select"||de.type==="multiselect"||de.type==="edit"){let te=de.type==="multiselect"||de.type==="edit"?q.length:q.length-1;ie.upArrow||ae==="k"?a(oe=>Math.max(0,oe-1)):ie.downArrow||ae==="j"?a(oe=>Math.min(te,oe+1)):(ie.return||ae==="")&&be()}else if(de.type==="input")(ie.return||ae==="")&&be();else if(de.type==="preview"){if(ie.upArrow||ie.downArrow||ae==="k"||ae==="j")return;(ie.return||ae==="")&&be()}}});let _e=()=>{if(c.method==="online"){let oe=["location","method"],me=oe.indexOf(i);return(0,or.jsxs)(Ee,{marginBottom:1,children:[(0,or.jsxs)(se,{color:ve.Gray,children:["Step ",me+1," of ",oe.length]}),(0,or.jsx)(Ee,{marginLeft:2,children:(0,or.jsx)(se,{color:ve.Gray,children:oe.map((ue,K)=>K<me?"\u2713 ":K===me?"\u25CF ":"\u25CB ").join("")})})]})}let ae=["location","method","agentType","systemPrompt","description","tools","mcps","color","preview"],ie=["location","method","agentGoal","generating","generated-preview","tools","mcps","color","preview"],de=c.method==="iFlow"?ie:ae,te=de.indexOf(i);return(0,or.jsxs)(Ee,{marginBottom:1,children:[(0,or.jsxs)(se,{color:ve.Gray,children:["Step ",te+1," of ",de.length]}),(0,or.jsx)(Ee,{marginLeft:2,children:(0,or.jsx)(se,{color:ve.Gray,children:de.map((oe,me)=>me<te?"\u2713 ":me===te?"\u25CF ":"\u25CB ").join("")})})]})},Se=()=>{if(P){let ae={agentType:"Agent Type (identifier)",description:"Description",systemPrompt:"System Prompt"};return(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsxs)(se,{bold:!0,color:ve.AccentCyan,children:["Edit ",ae[P]]}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsxs)(se,{color:ve.Gray,children:["Modify the ",P," for your agent"]})}),(0,or.jsx)(Ee,{marginTop:2,children:(0,or.jsx)(Ty,{onSubmit:V,onCancel:X,placeholder:`Enter ${P}`,label:ae[P],defaultValue:Q,isFocused:!0})})]})}return(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentCyan,children:"Review Generated Configuration"}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:"Review and edit the AI-generated agent configuration"})}),(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[(0,or.jsxs)(Ee,{marginBottom:2,flexDirection:"column",children:[(0,or.jsx)(Ee,{flexDirection:"row",children:(0,or.jsxs)(se,{color:s===0?ve.AccentCyan:void 0,children:[s===0?"\u25B6 ":" ","[Continue to Tools Selection]"]})}),(0,or.jsx)(Ee,{marginLeft:4,children:(0,or.jsx)(se,{color:ve.Gray,children:"Proceed to next step"})})]},"continue"),q.map((ae,ie)=>{let te=ie+1===s;return(0,or.jsxs)(Ee,{marginBottom:1,flexDirection:"column",children:[(0,or.jsx)(Ee,{flexDirection:"row",children:(0,or.jsxs)(se,{color:te?ve.AccentCyan:void 0,children:[te?"\u25B6 ":" ",ae.title]})}),(0,or.jsx)(Ee,{marginLeft:4,children:(0,or.jsx)(se,{color:ve.Gray,children:ae.description})})]},ae.id)})]}),(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.Gray,children:"Navigation:"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 \u2191/\u2193 or j/k - Navigate options"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 Enter - Edit field or continue"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 ESC - Back"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]})},pe=()=>(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentCyan,children:"Preview Agent Configuration"}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:"Review your agent configuration before creating"})}),(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,children:c.agentType}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.AccentBlue,children:c.description})}),(0,or.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.AccentCyan,children:"Details:"}),(0,or.jsxs)(se,{children:[" \u2022 Location: ",c.location]}),(0,or.jsx)(se,{children:" \u2022 Model: gemini-1.5-pro"}),(0,or.jsxs)(se,{children:[" \u2022 Color: ",c.color]})]}),(0,or.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.AccentCyan,children:"Tools:"}),(0,or.jsx)(Ee,{marginLeft:2,children:(0,or.jsx)(se,{children:c.selectedTools?.length?c.selectedTools.join(", "):"All tools available"})})]}),(0,or.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.AccentCyan,children:"MCP Servers:"}),(0,or.jsx)(Ee,{marginLeft:2,children:(0,or.jsx)(se,{children:c.selectedMcps?.length?c.selectedMcps.join(", "):"All MCP servers available"})})]}),c.systemPrompt&&(0,or.jsxs)(Ee,{marginTop:1,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.AccentCyan,children:"System Prompt:"}),(0,or.jsx)(Ee,{marginLeft:2,children:(0,or.jsx)(se,{children:c.systemPrompt.length>200?`${c.systemPrompt.substring(0,200)}...`:c.systemPrompt})})]})]}),(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.AccentYellow,children:"Actions:"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 Enter - Create agent"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 ESC - Back to edit"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]}),Ae=()=>O?i==="preview"?pe():i==="generated-preview"?Se():i==="generating"?(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentCyan,children:"Generating Agent Configuration"}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:"Using AI to create your agent from the goal description..."})}),(0,or.jsx)(Ee,{marginTop:2,children:(0,or.jsx)(se,{color:ve.AccentYellow,children:T||"Starting generation..."})}),(0,or.jsx)(Ee,{marginTop:2,children:(0,or.jsx)(se,{color:ve.Gray,children:"Please wait while the configuration is generated."})})]}):g&&O.type==="input"?(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentCyan,children:O.title}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:O.description})}),(0,or.jsx)(Ee,{marginTop:2,children:(0,or.jsx)(Ty,{onSubmit:G,onCancel:W,placeholder:O.placeholder,label:O.title,defaultValue:j(),isFocused:!0})})]}):(0,or.jsxs)(Ee,{flexDirection:"column",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentCyan,children:O.title}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:O.description})}),O.type==="input"&&!g&&(0,or.jsxs)(Ee,{marginTop:2,children:[(0,or.jsxs)(se,{color:ve.AccentYellow,children:["Current value: ",j()||"(not set)"]}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsx)(se,{color:ve.Gray,children:"Press Enter to edit"})})]}),(O.type==="select"||O.type==="multiselect")&&(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[O.type==="multiselect"&&(0,or.jsxs)(Ee,{marginBottom:2,flexDirection:"column",children:[(0,or.jsx)(Ee,{flexDirection:"row",children:(0,or.jsxs)(se,{color:s===0?ve.AccentCyan:void 0,children:[s===0?"\u25B6 ":" ","[Continue]"]})}),(0,or.jsx)(Ee,{marginLeft:4,children:(0,or.jsx)(se,{color:ve.Gray,children:"Proceed to next step"})})]},"continue"),q.map((ae,ie)=>{let te=(O.type==="multiselect"?ie+1:ie)===s,oe=O.type==="multiselect"?i==="tools"?(c.selectedTools||[]).includes(ae.id):(c.selectedMcps||[]).includes(ae.id):!1;return(0,or.jsxs)(Ee,{marginBottom:1,flexDirection:"column",children:[(0,or.jsx)(Ee,{flexDirection:"row",children:(0,or.jsxs)(se,{color:te?ve.AccentCyan:void 0,children:[te?"\u25B6 ":" ",O.type==="multiselect"&&(0,or.jsx)(se,{children:oe?"[\u2713] ":"[ ] "}),O.type==="select"&&ae.id==="red"&&(0,or.jsx)(se,{color:ve.AccentRed,children:"\u2588 "}),O.type==="select"&&ae.id==="blue"&&(0,or.jsx)(se,{color:ve.AccentBlue,children:"\u2588 "}),O.type==="select"&&ae.id==="green"&&(0,or.jsx)(se,{color:ve.AccentGreen,children:"\u2588 "}),O.type==="select"&&ae.id==="yellow"&&(0,or.jsx)(se,{color:ve.AccentYellow,children:"\u2588 "}),O.type==="select"&&ae.id==="purple"&&(0,or.jsx)(se,{color:ve.AccentPurple,children:"\u2588 "}),O.type==="select"&&ae.id==="orange"&&(0,or.jsx)(se,{color:ve.AccentYellow,children:"\u2588 "}),O.type==="select"&&ae.id==="pink"&&(0,or.jsx)(se,{color:ve.AccentPurple,children:"\u2588 "}),O.type==="select"&&ae.id==="cyan"&&(0,or.jsx)(se,{color:ve.AccentCyan,children:"\u2588 "}),ae.title]})}),ae.description&&(0,or.jsx)(Ee,{marginLeft:4,children:(0,or.jsx)(se,{color:ve.Gray,children:ae.description})})]},ae.id)})]}),(0,or.jsxs)(Ee,{marginTop:2,flexDirection:"column",children:[(0,or.jsx)(se,{color:ve.Gray,children:"Navigation:"}),O.type==="input"&&!g&&(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 Enter - Edit value"}),(O.type==="select"||O.type==="multiselect"||O.type==="edit")&&(0,or.jsxs)(or.Fragment,{children:[(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 \u2191/\u2193 or j/k - Navigate options"}),(0,or.jsxs)(se,{color:ve.Gray,children:[" \u2022 Enter - ",O.type==="edit"?"Edit field or continue":"Select option"]})]}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 ESC - Back"}),(0,or.jsx)(se,{color:ve.Gray,children:" \u2022 q - Exit"})]})]}):(0,or.jsx)(Ee,{flexDirection:"column",children:(0,or.jsx)(se,{color:ve.Gray,children:"Generating"})});return p?(0,or.jsxs)(Ee,{borderStyle:"round",borderColor:ve.AccentGreen,flexDirection:"column",padding:1,width:"100%",children:[(0,or.jsx)(se,{bold:!0,color:ve.AccentGreen,children:"Agent Installation"}),(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsxs)(se,{color:ve.AccentGreen,children:["\u2705 ",p]})})]}):(0,or.jsxs)(Ee,{borderStyle:"round",borderColor:ve.Gray,flexDirection:"column",padding:1,width:"100%",children:[(0,or.jsx)(se,{bold:!0,children:"Install New Agent"}),_e(),Ae(),f&&(0,or.jsx)(Ee,{marginTop:1,children:(0,or.jsxs)(se,{color:ve.AccentRed,children:["\u274C ",f]})})]})}var qv=ze(wr(),1);var Ei=ze(Wt(),1);import R4t from"fs/promises";import B4t from"path";import V6o from"os";function fin({config:t,onExit:e,onStatusUpdate:r}){let[n,i]=(0,qv.useState)("loading"),[o,s]=(0,qv.useState)([]),[a,c]=(0,qv.useState)(1),[u,f]=(0,qv.useState)(0),[d,p]=(0,qv.useState)(null),[h,g]=(0,qv.useState)(null),[A,y]=(0,qv.useState)(null),[v,S]=(0,qv.useState)(0),w=10,T=Math.ceil(v/w);(0,qv.useEffect)(()=>{let O=async L=>{try{let M=t?.getContentGeneratorConfig()?.apiKey;if(!M)throw new Error("API key not found. Please authenticate first.");let j=new URL("https://apis.iflow.cn/v1/commands/list"),G=await fetch(j.toString(),{method:"POST",headers:{Authorization:`Bearer ${M}`,"User-Agent":"iFlow-Cli","Content-Type":"application/json"},body:JSON.stringify({page:L,size:w})});if(!G.ok){let J="Unable to load commands. Please try again later";throw G.status===401?J="Authentication failed. Please check your API key or re-authenticate":G.status===403?J="Access denied. Please check your permissions":G.status===404?J="Commands service not found. Please try again later":G.status>=500&&(J="Server error. Please try again later"),new Error(J)}let W=await G.json();if(!W.success)throw new Error(W.message||"Failed to fetch commands");let V=Array.isArray(W.data?.data)?W.data.data:[],X=W.data?.total||V.length;return{commands:V,total:X}}catch(M){throw new Error(`Failed to fetch commands: ${M}`)}};(async()=>{try{let L=await O(a);s(L.commands),S(L.total),i("list"),f(0),L.commands.length===0&&g("No commands found in the online repository.")}catch(L){g(L instanceof Error?L.message:"Failed to load commands"),i("list"),f(0)}})()},[a,t]);let N=O=>O.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),P=O=>O==="user"?B4t.join(V6o.homedir(),".iflow","commands"):B4t.join(process.cwd(),".iflow","commands"),U=async(O,q)=>{try{let L=P(q);await R4t.mkdir(L,{recursive:!0});let M=`${N(O.name)}.toml`,j=B4t.join(L,M);try{return await R4t.access(j),{success:!1,message:`Command '${O.name}' is already installed in your ${q} scope.`}}catch{}let G=`# Command: ${O.name}
|
|
3489
3489
|
# Description: ${O.description}
|
|
3490
3490
|
# Category: ${O.category}
|
|
3491
3491
|
# Version: ${O.version}
|
|
@@ -3614,7 +3614,7 @@ CRITICAL: Unhandled Promise Rejection!
|
|
|
3614
3614
|
=========================================
|
|
3615
3615
|
Reason: ${e}${e instanceof Error&&e.stack?`
|
|
3616
3616
|
Stack trace:
|
|
3617
|
-
${e.stack}`:""}`;Ma.emit("log-error",n),t||(t=!0,Ma.emit("open-debug-console"))})}function yCo(){console.log("\u{1F50D} Crash diagnostics enabled - Core dump and crash files will be generated on crash"),process.setUncaughtExceptionCaptureCallback(t=>{let e={timestamp:new Date().toISOString(),error:{name:t.name,message:t.message,stack:t.stack},memory:process.memoryUsage(),pid:process.pid,cwd:process.cwd(),nodeVersion:process.version,platform:process.platform,arch:process.arch,uptime:process.uptime(),env:{NODE_ENV:process.env.NODE_ENV,SANDBOX:process.env.SANDBOX,CLI_VERSION:"0.2.
|
|
3617
|
+
${e.stack}`:""}`;Ma.emit("log-error",n),t||(t=!0,Ma.emit("open-debug-console"))})}function yCo(){console.log("\u{1F50D} Crash diagnostics enabled - Core dump and crash files will be generated on crash"),process.setUncaughtExceptionCaptureCallback(t=>{let e={timestamp:new Date().toISOString(),error:{name:t.name,message:t.message,stack:t.stack},memory:process.memoryUsage(),pid:process.pid,cwd:process.cwd(),nodeVersion:process.version,platform:process.platform,arch:process.arch,uptime:process.uptime(),env:{NODE_ENV:process.env.NODE_ENV,SANDBOX:process.env.SANDBOX,CLI_VERSION:"0.2.14"}},r=`crash-${Date.now()}-${process.pid}.json`,n=lCo.join(process.cwd(),r);try{pCo.writeFileSync(n,JSON.stringify(e,null,2)),console.error(`\u{1F4A5} Crash detected! Crash info written to: ${n}`),console.error("\u{1F4CB} Core dump will be generated...")}catch(i){console.error("\u274C Failed to write crash file:",i)}process.abort()}),process.on("warning",t=>{console.warn("\u26A0\uFE0F Node.js Warning:",{name:t.name,message:t.message,stack:t.stack})}),process.on("unhandledRejection",(t,e)=>{console.error("\u{1F6A8} Unhandled Promise Rejection detected:",{reason:t,promise:e.toString()})})}async function spn(){ACo();let t=process.cwd(),e=fc(t);if(await HJr(),e.errors.length>0){for(let f of e.errors){let d=`Error in ${f.path}: ${f.message}`;process.env.NO_COLOR||(d=`\x1B[31m${d}\x1B[0m`),console.error(d),console.error(`Please fix ${f.path} and try again.`)}process.exit(1)}let r=await DIe(),n=RR(t),i=await ife(e.merged,n,nJ,r);if(i.getDebugMode()&&yCo(),fCo.setDefaultResultOrder(hCo(e.merged.dnsResolutionOrder)),r.promptInteractive&&!process.stdin.isTTY&&(console.error("Error: The --prompt-interactive flag is not supported when piping input from stdin."),process.exit(1)),i.getListExtensions()){console.log("Installed extensions:");for(let f of n)console.log(`- ${f.config.name}`);process.exit(0)}if(r._&&r._[0]==="agent"){let{agentCommand:f}=await Promise.resolve().then(()=>(YEt(),Aan)),d=(await Promise.resolve().then(()=>(ebt(),Zvt))).default;await d().scriptName("iflow").command(f).help().version(!1).parse(),process.exit(0)}if(r._&&r._[0]==="commands"){let{commandsCommand:f}=await Promise.resolve().then(()=>($Et(),ian)),d=(await Promise.resolve().then(()=>(ebt(),Zvt))).default;await d().scriptName("iflow").command(f).help().version(!1).parse(),process.exit(0)}if(e.merged.selectedAuthType||process.env.CLOUD_SHELL==="true"&&e.setValue("User","selectedAuthType",Jr.CLOUD_SHELL),qnn(i.getDebugMode()),await i.initialize(),Xl.loadCustomThemes(e.merged.customThemes),e.merged.theme&&(Xl.setActiveTheme(e.merged.theme)||console.warn(`Warning: Theme "${e.merged.theme}" not found.`)),!process.env.SANDBOX){let f=e.merged.autoConfigureMaxOldSpaceSize?mCo(i):[],d=i.getSandbox();if(d){if(e.merged.selectedAuthType&&!e.merged.useExternalAuth)try{let p=yF(e.merged.selectedAuthType);if(p)throw new Error(p);await i.refreshAuth(e.merged.selectedAuthType,{apiKey:e.merged.apiKey,baseUrl:e.merged.baseUrl,modelName:e.merged.modelName,multimodalModelName:e.merged.multimodalModelName})}catch(p){console.error("Error authenticating:",p),process.exit(1)}await ocn(d,f,i),process.exit(0)}else f.length>0&&(await gCo(f),process.exit(0))}if(e.merged.selectedAuthType===Jr.LOGIN_WITH_GOOGLE&&i.isBrowserLaunchSuppressed()&&await dZ(e.merged.selectedAuthType,i),i.getExperimentalAcp())return i.getAcpPort()?await gdn(i,e,i.getAcpPort()):Adn(i,e);let o=i.getQuestion(),s=[...await scn(),...await lcn(t)];if(!!r.promptInteractive||!!r.continue||!!r.resume||process.stdin.isTTY&&o?.length===0){console.clear();let f=await Y9();opn(ipn(t),e);let d,p=async()=>{try{if(console.clear(),opn(ipn(t),e),process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.resume()),d)try{d.unmount(),await new Promise(h=>process.nextTick(h))}catch(h){console.error("Error during unmount:",h)}d=tpe((0,kfe.jsx)(tbt.default.StrictMode,{children:(0,kfe.jsx)(w5t,{config:i,settings:e,startupWarnings:s,version:f,continueMode:!!r.continue,resumeMode:!!r.resume,resumeSessionId:r.resume,fgMode:!0})}),{exitOnCtrlC:!1,stdout:i6t(),stdin:process.stdin,patchConsole:!0})}catch(h){console.error("Error during resume:",h)}};process.on("SIGCONT",p),fue(()=>{process.off("SIGCONT",p)}),process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.resume()),d=tpe((0,kfe.jsx)(tbt.default.StrictMode,{children:(0,kfe.jsx)(w5t,{config:i,settings:e,startupWarnings:s,version:f,continueMode:!!r.continue,resumeMode:!!r.resume,resumeSessionId:r.resume})}),{exitOnCtrlC:!1,stdout:i6t()}),e.merged.disableAutoUpdate||sdn().then(h=>{Fln(h,e,i.getProjectRoot())}).catch(h=>{i.getDebugMode()&&console.error("Update check failed:",h)}),fue(()=>d.unmount());return}!process.stdin.isTTY&&!o&&(o+=await tcn()),o||(console.error("No input provided via stdin."),process.exit(1));let c=Math.random().toString(16).slice(2);kz(i,{"event.name":"user_prompt","event.timestamp":new Date().toISOString(),prompt:o,prompt_id:c,auth_type:i.getContentGeneratorConfig()?.authType,prompt_length:o.length});let u=await ECo(i,n,e,r);await ccn(u,o,c),process.exit(0)}function opn(t,e){if(!e.merged.hideWindowTitle){let r=(process.env.CLI_TITLE||`iFlow - ${t}`).replace(/[\x00-\x1F\x7F]/g,"");process.stdout.write(`\x1B]2;${r}\x07`),process.on("exit",()=>{process.stdout.write("\x1B]2;\x07")})}}async function ECo(t,e,r,n){let i=t;if(t.getApprovalMode()!==Ti.YOLO){let o=r.merged.excludeTools||[],s=[o1.Name,M2.Name,Lm.Name],a=[...new Set([...o,...s])],c={...r.merged,excludeTools:a};i=await ife(c,e,t.getSessionId(),n),await i.initialize()}return await vCo(r.merged.selectedAuthType,i,r)}async function vCo(t,e,r){!t&&!process.env.GEMINI_API_KEY&&!sme()&&(console.error(`Please set an Auth method in your ${lF} or specify one of the following environment variables before running:
|
|
3618
3618
|
- apiKey, APIKEY, API_KEY, api_key
|
|
3619
3619
|
- baseUrl, BASEURL, BASE_URL, base_url
|
|
3620
3620
|
- modelName, MODELNAME, MODEL_NAME, model_name `),process.exit(1)),t||(sme()?t=Jr.IFLOW:t=Jr.IFLOW);let n=yF(t);return n!=null&&(console.error(n),process.exit(1)),await e.refreshAuth(t,{apiKey:r.merged.apiKey,baseUrl:r.merged.baseUrl,modelName:r.merged.modelName,multimodalModelName:r.merged.multimodalModelName}),e}spn().catch(t=>{console.error("An unexpected critical error occurred:"),t instanceof Error?console.error(t.stack):console.error(String(t)),process.exit(1)});
|