@swifty.js/swifty 0.0.19 → 0.0.20
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.
|
@@ -19,7 +19,7 @@ ${_e}`,A++}else dp(E,B,oe)?d=E.slice(E.charCodeAt(B+6)===Gt?B+7:B+6,P)||void 0:w
|
|
|
19
19
|
${bl}`,A++;return}if(dp(E,B,oe)){d=E.slice(E.charCodeAt(B+6)===Gt?B+7:B+6,P)||void 0;return}if(oe===105&&E.charCodeAt(B+1)===100&&E.charCodeAt(B+2)===58){let mt=E.slice(E.charCodeAt(B+3)===Gt?B+4:B+3,P);u=mt.includes("\0")?void 0:mt;return}if(oe===58){if(s){let mt=E.slice(B,P);s(mt.slice(E.charCodeAt(B+1)===Gt?2:1))}return}let se=E.slice(B,P),_e=se.indexOf(":");if(_e===-1){C(se,"",se);return}let Gr=se.slice(0,_e),as=se.charCodeAt(_e+1)===Gt?2:1,cs=se.slice(_e+as);C(Gr,cs,se)}function C(E,B,P){switch(E){case"event":d=B||void 0;break;case"data":l=A===0?B:`${l}
|
|
20
20
|
${B}`,A++;break;case"id":u=B.includes("\0")?void 0:B;break;case"retry":/^\d+$/.test(B)?o(parseInt(B,10)):r(new Ro(`Invalid \`retry\` value: "${B}"`,{type:"invalid-retry",value:B,line:P}));break;default:r(new Ro(`Unknown field "${E.length>20?`${E.slice(0,20)}\u2026`:E}"`,{type:"unknown-field",field:E,value:B,line:P}));break}}function I(){A>0&&e({id:u,event:d,data:l}),u=void 0,l="",A=0,d=void 0}function b(E={}){if(E.consume&&i.length>0){let B=i.join("");w(B,0,B.length)}c=!0,u=void 0,l="",A=0,d=void 0,i.length=0,a=0,m=!1}return{feed:g,reset:b}}function Ap(t,e,r){return r===100&&t.charCodeAt(e+1)===97&&t.charCodeAt(e+2)===116&&t.charCodeAt(e+3)===97&&t.charCodeAt(e+4)===58}function dp(t,e,r){return r===101&&t.charCodeAt(e+1)===118&&t.charCodeAt(e+2)===101&&t.charCodeAt(e+3)===110&&t.charCodeAt(e+4)===116&&t.charCodeAt(e+5)===58}var fn=class extends Event{constructor(e,r){var o,s;super(e),this.code=(o=r?.code)!=null?o:void 0,this.message=(s=r?.message)!=null?s:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,r,o){return o(pp(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(pp(this),r)}};function CQ(t){let e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function vc(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(vc).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${vc(t.cause)}`:t.message:`${t}`}function pp(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var fp=t=>{throw TypeError(t)},jc=(t,e,r)=>e.has(t)||fp("Cannot "+r),O=(t,e,r)=>(jc(t,e,"read from private field"),r?r.call(t):e.get(t)),ue=(t,e,r)=>e.has(t)?fp("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),te=(t,e,r,o)=>(jc(t,e,"write to private field"),e.set(t,r),r),it=(t,e,r)=>(jc(t,e,"access private method"),r),xe,Ht,Sr,mn,gn,$o,vr,Po,Mt,kr,br,Mr,Do,He,bc,xc,Rc,mp,Dc,Tc,To,$c,Pc,Yt=class extends EventTarget{constructor(e,r){var o,s;super(),ue(this,He),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,ue(this,xe),ue(this,Ht),ue(this,Sr),ue(this,mn),ue(this,gn),ue(this,$o),ue(this,vr),ue(this,Po,null),ue(this,Mt),ue(this,kr),ue(this,br,null),ue(this,Mr,null),ue(this,Do,null),ue(this,xc,async n=>{var i;O(this,kr).reset();let{body:a,redirected:c,status:u,headers:l}=n;if(u===204){it(this,He,To).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?te(this,Sr,new URL(n.url)):te(this,Sr,void 0),u!==200){it(this,He,To).call(this,`Non-200 status code (${u})`,u);return}if(!(l.get("content-type")||"").startsWith("text/event-stream")){it(this,He,To).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(O(this,xe)===this.CLOSED)return;te(this,xe,this.OPEN);let A=new Event("open");if((i=O(this,Do))==null||i.call(this,A),this.dispatchEvent(A),typeof a!="object"||!a||!("getReader"in a)){it(this,He,To).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}let d=new TextDecoder,m=a.getReader(),g=!0;do{let{done:f,value:h}=await m.read();h&&O(this,kr).feed(d.decode(h,{stream:!f})),f&&(g=!1,O(this,kr).reset(),it(this,He,$c).call(this))}while(g)}),ue(this,Rc,n=>{te(this,Mt,void 0),!(n.name==="AbortError"||n.type==="aborted")&&it(this,He,$c).call(this,vc(n))}),ue(this,Dc,n=>{typeof n.id=="string"&&te(this,Po,n.id);let i=new MessageEvent(n.event||"message",{data:n.data,origin:O(this,Sr)?O(this,Sr).origin:O(this,Ht).origin,lastEventId:n.id||""});O(this,Mr)&&(!n.event||n.event==="message")&&O(this,Mr).call(this,i),this.dispatchEvent(i)}),ue(this,Tc,n=>{te(this,$o,n)}),ue(this,Pc,()=>{te(this,vr,void 0),O(this,xe)===this.CONNECTING&&it(this,He,bc).call(this)});try{if(e instanceof URL)te(this,Ht,e);else if(typeof e=="string")te(this,Ht,new URL(e,IQ()));else throw new Error("Invalid URL")}catch{throw CQ("An invalid or illegal string was specified")}te(this,kr,pn({onEvent:O(this,Dc),onRetry:O(this,Tc)})),te(this,xe,this.CONNECTING),te(this,$o,3e3),te(this,gn,(o=r?.fetch)!=null?o:globalThis.fetch),te(this,mn,(s=r?.withCredentials)!=null?s:!1),it(this,He,bc).call(this)}get readyState(){return O(this,xe)}get url(){return O(this,Ht).href}get withCredentials(){return O(this,mn)}get onerror(){return O(this,br)}set onerror(e){te(this,br,e)}get onmessage(){return O(this,Mr)}set onmessage(e){te(this,Mr,e)}get onopen(){return O(this,Do)}set onopen(e){te(this,Do,e)}addEventListener(e,r,o){let s=r;super.addEventListener(e,s,o)}removeEventListener(e,r,o){let s=r;super.removeEventListener(e,s,o)}close(){O(this,vr)&&clearTimeout(O(this,vr)),O(this,xe)!==this.CLOSED&&(O(this,Mt)&&O(this,Mt).abort(),te(this,xe,this.CLOSED),te(this,Mt,void 0))}};xe=new WeakMap,Ht=new WeakMap,Sr=new WeakMap,mn=new WeakMap,gn=new WeakMap,$o=new WeakMap,vr=new WeakMap,Po=new WeakMap,Mt=new WeakMap,kr=new WeakMap,br=new WeakMap,Mr=new WeakMap,Do=new WeakMap,He=new WeakSet,bc=function(){te(this,xe,this.CONNECTING),te(this,Mt,new AbortController),O(this,gn)(O(this,Ht),it(this,He,mp).call(this)).then(O(this,xc)).catch(O(this,Rc))},xc=new WeakMap,Rc=new WeakMap,mp=function(){var t;let e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...O(this,Po)?{"Last-Event-ID":O(this,Po)}:void 0},cache:"no-store",signal:(t=O(this,Mt))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Dc=new WeakMap,Tc=new WeakMap,To=function(t,e){var r;O(this,xe)!==this.CLOSED&&te(this,xe,this.CLOSED);let o=new fn("error",{code:e,message:t});(r=O(this,br))==null||r.call(this,o),this.dispatchEvent(o)},$c=function(t,e){var r;if(O(this,xe)===this.CLOSED)return;te(this,xe,this.CONNECTING);let o=new fn("error",{code:e,message:t});(r=O(this,br))==null||r.call(this,o),this.dispatchEvent(o),te(this,vr,setTimeout(O(this,Pc),O(this,$o)))},Pc=new WeakMap,Yt.CONNECTING=0,Yt.OPEN=1,Yt.CLOSED=2;function IQ(){let t="document"in globalThis?globalThis.document:void 0;return t&&typeof t=="object"&&"baseURI"in t&&typeof t.baseURI=="string"?t.baseURI:void 0}function xr(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function hn(t=fetch,e){return e?async(r,o)=>{let s={...e,...o,headers:o?.headers?{...xr(e.headers),...xr(o.headers)}:e.headers};return t(r,s)}:t}var Nc;Nc=globalThis.crypto?.webcrypto??globalThis.crypto??import("crypto").then(t=>t.webcrypto);async function BQ(t){return(await Nc).getRandomValues(new Uint8Array(t))}async function QQ(t){let e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length,o="";for(;o.length<t;){let s=await BQ(t-o.length);for(let n of s)n<r&&(o+=e[n%e.length])}return o}async function _Q(t){return await QQ(t)}async function SQ(t){let e=await(await Nc).subtle.digest("SHA-256",new TextEncoder().encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function zc(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;let e=await _Q(t),r=await SQ(e);return{code_verifier:e,code_challenge:r}}var he=Pl().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:Ul.custom,message:"URL must be parseable",fatal:!0}),xl}).refine(t=>{let e=new URL(t);return e.protocol!=="javascript:"&&e.protocol!=="data:"&&e.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),hp=ce({resource:p().url(),authorization_servers:_(he).optional(),jwks_uri:p().url().optional(),scopes_supported:_(p()).optional(),bearer_methods_supported:_(p()).optional(),resource_signing_alg_values_supported:_(p()).optional(),resource_name:p().optional(),resource_documentation:p().optional(),resource_policy_uri:p().url().optional(),resource_tos_uri:p().url().optional(),tls_client_certificate_bound_access_tokens:W().optional(),authorization_details_types_supported:_(p()).optional(),dpop_signing_alg_values_supported:_(p()).optional(),dpop_bound_access_tokens_required:W().optional()}),Uc=ce({issuer:p(),authorization_endpoint:he,token_endpoint:he,registration_endpoint:he.optional(),scopes_supported:_(p()).optional(),response_types_supported:_(p()),response_modes_supported:_(p()).optional(),grant_types_supported:_(p()).optional(),token_endpoint_auth_methods_supported:_(p()).optional(),token_endpoint_auth_signing_alg_values_supported:_(p()).optional(),service_documentation:he.optional(),revocation_endpoint:he.optional(),revocation_endpoint_auth_methods_supported:_(p()).optional(),revocation_endpoint_auth_signing_alg_values_supported:_(p()).optional(),introspection_endpoint:p().optional(),introspection_endpoint_auth_methods_supported:_(p()).optional(),introspection_endpoint_auth_signing_alg_values_supported:_(p()).optional(),code_challenge_methods_supported:_(p()).optional(),client_id_metadata_document_supported:W().optional()}),kQ=ce({issuer:p(),authorization_endpoint:he,token_endpoint:he,userinfo_endpoint:he.optional(),jwks_uri:he,registration_endpoint:he.optional(),scopes_supported:_(p()).optional(),response_types_supported:_(p()),response_modes_supported:_(p()).optional(),grant_types_supported:_(p()).optional(),acr_values_supported:_(p()).optional(),subject_types_supported:_(p()),id_token_signing_alg_values_supported:_(p()),id_token_encryption_alg_values_supported:_(p()).optional(),id_token_encryption_enc_values_supported:_(p()).optional(),userinfo_signing_alg_values_supported:_(p()).optional(),userinfo_encryption_alg_values_supported:_(p()).optional(),userinfo_encryption_enc_values_supported:_(p()).optional(),request_object_signing_alg_values_supported:_(p()).optional(),request_object_encryption_alg_values_supported:_(p()).optional(),request_object_encryption_enc_values_supported:_(p()).optional(),token_endpoint_auth_methods_supported:_(p()).optional(),token_endpoint_auth_signing_alg_values_supported:_(p()).optional(),display_values_supported:_(p()).optional(),claim_types_supported:_(p()).optional(),claims_supported:_(p()).optional(),service_documentation:p().optional(),claims_locales_supported:_(p()).optional(),ui_locales_supported:_(p()).optional(),claims_parameter_supported:W().optional(),request_parameter_supported:W().optional(),request_uri_parameter_supported:W().optional(),require_request_uri_registration:W().optional(),op_policy_uri:he.optional(),op_tos_uri:he.optional(),client_id_metadata_document_supported:W().optional()}),Ep=S({...kQ.shape,...Uc.pick({code_challenge_methods_supported:!0}).shape}),yp=S({access_token:p(),id_token:p().optional(),token_type:p(),expires_in:Fl.number().optional(),scope:p().optional(),refresh_token:p().optional()}).strip(),wp=S({error:p(),error_description:p().optional(),error_uri:p().optional()}),gp=he.optional().or(M("").transform(()=>{})),MQ=S({redirect_uris:_(he),token_endpoint_auth_method:p().optional(),grant_types:_(p()).optional(),response_types:_(p()).optional(),client_name:p().optional(),client_uri:he.optional(),logo_uri:gp,scope:p().optional(),contacts:_(p()).optional(),tos_uri:gp,policy_uri:p().optional(),jwks_uri:he.optional(),jwks:Nl().optional(),software_id:p().optional(),software_version:p().optional(),software_statement:p().optional()}).strip(),vQ=S({client_id:p(),client_secret:p().optional(),client_id_issued_at:H().optional(),client_secret_expires_at:H().optional()}).strip(),Cp=MQ.merge(vQ),$D=S({error:p(),error_description:p().optional()}).strip(),PD=S({token:p(),token_type_hint:p().optional()}).strip();function Ip(t){let e=typeof t=="string"?new URL(t):new URL(t.href);return e.hash="",e}function Bp({requestedResource:t,configuredResource:e}){let r=typeof t=="string"?new URL(t):new URL(t.href),o=typeof e=="string"?new URL(e):new URL(e.href);if(r.origin!==o.origin||r.pathname.length<o.pathname.length)return!1;let s=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",n=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return s.startsWith(n)}var ae=class extends Error{constructor(e,r){super(e),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},jo=class extends ae{};jo.errorCode="invalid_request";var Jt=class extends ae{};Jt.errorCode="invalid_client";var Wt=class extends ae{};Wt.errorCode="invalid_grant";var Vt=class extends ae{};Vt.errorCode="unauthorized_client";var No=class extends ae{};No.errorCode="unsupported_grant_type";var zo=class extends ae{};zo.errorCode="invalid_scope";var Uo=class extends ae{};Uo.errorCode="access_denied";var at=class extends ae{};at.errorCode="server_error";var Fo=class extends ae{};Fo.errorCode="temporarily_unavailable";var Oo=class extends ae{};Oo.errorCode="unsupported_response_type";var Lo=class extends ae{};Lo.errorCode="unsupported_token_type";var qo=class extends ae{};qo.errorCode="invalid_token";var Go=class extends ae{};Go.errorCode="method_not_allowed";var Ho=class extends ae{};Ho.errorCode="too_many_requests";var Kt=class extends ae{};Kt.errorCode="invalid_client_metadata";var Yo=class extends ae{};Yo.errorCode="insufficient_scope";var Jo=class extends ae{};Jo.errorCode="invalid_target";var Qp={[jo.errorCode]:jo,[Jt.errorCode]:Jt,[Wt.errorCode]:Wt,[Vt.errorCode]:Vt,[No.errorCode]:No,[zo.errorCode]:zo,[Uo.errorCode]:Uo,[at.errorCode]:at,[Fo.errorCode]:Fo,[Oo.errorCode]:Oo,[Lo.errorCode]:Lo,[qo.errorCode]:qo,[Go.errorCode]:Go,[Ho.errorCode]:Ho,[Kt.errorCode]:Kt,[Yo.errorCode]:Yo,[Jo.errorCode]:Jo};var Qe=class extends Error{constructor(e){super(e??"Unauthorized")}};function bQ(t){return["client_secret_basic","client_secret_post","none"].includes(t)}var Fc="code",Oc="S256";function xQ(t,e){let r=t.client_secret!==void 0;return"token_endpoint_auth_method"in t&&t.token_endpoint_auth_method&&bQ(t.token_endpoint_auth_method)&&(e.length===0||e.includes(t.token_endpoint_auth_method))?t.token_endpoint_auth_method:e.length===0?r?"client_secret_basic":"none":r&&e.includes("client_secret_basic")?"client_secret_basic":r&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":r?"client_secret_post":"none"}function RQ(t,e,r,o){let{client_id:s,client_secret:n}=e;switch(t){case"client_secret_basic":DQ(s,n,r);return;case"client_secret_post":TQ(s,n,o);return;case"none":$Q(s,o);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function DQ(t,e,r){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");let o=btoa(`${t}:${e}`);r.set("Authorization",`Basic ${o}`)}function TQ(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function $Q(t,e){e.set("client_id",t)}async function Sp(t){let e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{let o=wp.parse(JSON.parse(r)),{error:s,error_description:n,error_uri:i}=o,a=Qp[s]||at;return new a(n||"",i)}catch(o){let s=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${o}. Raw body: ${r}`;return new at(s)}}async function ct(t,e){try{return await Lc(t,e)}catch(r){if(r instanceof Jt||r instanceof Vt)return await t.invalidateCredentials?.("all"),await Lc(t,e);if(r instanceof Wt)return await t.invalidateCredentials?.("tokens"),await Lc(t,e);throw r}}async function Lc(t,{serverUrl:e,authorizationCode:r,scope:o,resourceMetadataUrl:s,fetchFn:n}){let i=await t.discoveryState?.(),a,c,u,l=s;if(!l&&i?.resourceMetadataUrl&&(l=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,u=i.authorizationServerMetadata??await Mp(c,{fetchFn:n}),!a)try{a=await kp(e,{resourceMetadataUrl:l},n)}catch{}(u!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await t.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}else{let I=await OQ(e,{resourceMetadataUrl:l,fetchFn:n});c=I.authorizationServerUrl,u=I.authorizationServerMetadata,a=I.resourceMetadata,await t.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let A=await jQ(e,t,a),d=o||a?.scopes_supported?.join(" ")||t.clientMetadata.scope,m=await Promise.resolve(t.clientInformation());if(!m){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let I=u?.client_id_metadata_document_supported===!0,b=t.clientMetadataUrl;if(b&&!PQ(b))throw new Kt(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${b}`);if(I&&b)m={client_id:b},await t.saveClientInformation?.(m);else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");let B=await YQ(c,{metadata:u,clientMetadata:t.clientMetadata,scope:d,fetchFn:n});await t.saveClientInformation(B),m=B}}let g=!t.redirectUrl;if(r!==void 0||g){let I=await HQ(t,c,{metadata:u,resource:A,authorizationCode:r,fetchFn:n});return await t.saveTokens(I),"AUTHORIZED"}let f=await t.tokens();if(f?.refresh_token)try{let I=await GQ(c,{metadata:u,clientInformation:m,refreshToken:f.refresh_token,resource:A,addClientAuthentication:t.addClientAuthentication,fetchFn:n});return await t.saveTokens(I),"AUTHORIZED"}catch(I){if(!(!(I instanceof ae)||I instanceof at))throw I}let h=t.state?await t.state():void 0,{authorizationUrl:w,codeVerifier:C}=await LQ(c,{metadata:u,clientInformation:m,state:h,redirectUrl:t.redirectUrl,scope:d,resource:A});return await t.saveCodeVerifier(C),await t.redirectToAuthorization(w),"REDIRECT"}function PQ(t){if(!t)return!1;try{let e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function jQ(t,e,r){let o=Ip(t);if(e.validateResourceURL)return await e.validateResourceURL(o,r?.resource);if(r){if(!Bp({requestedResource:o,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${o} (or origin)`);return new URL(r.resource)}}function Rr(t){let e=t.headers.get("WWW-Authenticate");if(!e)return{};let[r,o]=e.split(" ");if(r.toLowerCase()!=="bearer"||!o)return{};let s=qc(t,"resource_metadata")||void 0,n;if(s)try{n=new URL(s)}catch{}let i=qc(t,"scope")||void 0,a=qc(t,"error")||void 0;return{resourceMetadataUrl:n,scope:i,error:a}}function qc(t,e){let r=t.headers.get("WWW-Authenticate");if(!r)return null;let o=new RegExp(`${e}=(?:"([^"]+)"|([^\\s,]+))`),s=r.match(o);return s?s[1]||s[2]:null}async function kp(t,e,r=fetch){let o=await UQ(t,"oauth-protected-resource",r,{protocolVersion:e?.protocolVersion,metadataUrl:e?.resourceMetadataUrl});if(!o||o.status===404)throw await o?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw await o.body?.cancel(),new Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return hp.parse(await o.json())}async function Gc(t,e,r=fetch){try{return await r(t,{headers:e})}catch(o){if(o instanceof TypeError)return e?Gc(t,void 0,r):void 0;throw o}}function NQ(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function _p(t,e,r=fetch){return await Gc(t,{"MCP-Protocol-Version":e},r)}function zQ(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function UQ(t,e,r,o){let s=new URL(t),n=o?.protocolVersion??nr,i;if(o?.metadataUrl)i=new URL(o.metadataUrl);else{let c=NQ(e,s.pathname);i=new URL(c,o?.metadataServerUrl??s),i.search=s.search}let a=await _p(i,n,r);if(!o?.metadataUrl&&zQ(a,s.pathname)){let c=new URL(`/.well-known/${e}`,s);a=await _p(c,n,r)}return a}function FQ(t){let e=typeof t=="string"?new URL(t):t,r=e.pathname!=="/",o=[];if(!r)return o.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),o.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),o;let s=e.pathname;return s.endsWith("/")&&(s=s.slice(0,-1)),o.push({url:new URL(`/.well-known/oauth-authorization-server${s}`,e.origin),type:"oauth"}),o.push({url:new URL(`/.well-known/openid-configuration${s}`,e.origin),type:"oidc"}),o.push({url:new URL(`${s}/.well-known/openid-configuration`,e.origin),type:"oidc"}),o}async function Mp(t,{fetchFn:e=fetch,protocolVersion:r=nr}={}){let o={"MCP-Protocol-Version":r,Accept:"application/json"},s=FQ(t);for(let{url:n,type:i}of s){let a=await Gc(n,o,e);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${n}`)}return i==="oauth"?Uc.parse(await a.json()):Ep.parse(await a.json())}}}async function OQ(t,e){let r,o;try{r=await kp(t,{resourceMetadataUrl:e?.resourceMetadataUrl},e?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(o=r.authorization_servers[0])}catch{}o||(o=String(new URL("/",t)));let s=await Mp(o,{fetchFn:e?.fetchFn});return{authorizationServerUrl:o,authorizationServerMetadata:s,resourceMetadata:r}}async function LQ(t,{metadata:e,clientInformation:r,redirectUrl:o,scope:s,state:n,resource:i}){let a;if(e){if(a=new URL(e.authorization_endpoint),!e.response_types_supported.includes(Fc))throw new Error(`Incompatible auth server: does not support response type ${Fc}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(Oc))throw new Error(`Incompatible auth server: does not support code challenge method ${Oc}`)}else a=new URL("/authorize",t);let c=await zc(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",Fc),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",Oc),a.searchParams.set("redirect_uri",String(o)),n&&a.searchParams.set("state",n),s&&a.searchParams.set("scope",s),s?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",i.href),{authorizationUrl:a,codeVerifier:u}}function qQ(t,e,r){return new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:String(r)})}async function vp(t,{metadata:e,tokenRequestParams:r,clientInformation:o,addClientAuthentication:s,resource:n,fetchFn:i}){let a=e?.token_endpoint?new URL(e.token_endpoint):new URL("/token",t),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(n&&r.set("resource",n.href),s)await s(c,r,a,e);else if(o){let l=e?.token_endpoint_auth_methods_supported??[],A=xQ(o,l);RQ(A,o,c,r)}let u=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await Sp(u);return yp.parse(await u.json())}async function GQ(t,{metadata:e,clientInformation:r,refreshToken:o,resource:s,addClientAuthentication:n,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:o}),c=await vp(t,{metadata:e,tokenRequestParams:a,clientInformation:r,addClientAuthentication:n,resource:s,fetchFn:i});return{refresh_token:o,...c}}async function HQ(t,e,{metadata:r,resource:o,authorizationCode:s,fetchFn:n}={}){let i=t.clientMetadata.scope,a;if(t.prepareTokenRequest&&(a=await t.prepareTokenRequest(i)),!a){if(!s)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!t.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let u=await t.codeVerifier();a=qQ(s,u,t.redirectUrl)}let c=await t.clientInformation();return vp(e,{metadata:r,tokenRequestParams:a,clientInformation:c??void 0,addClientAuthentication:t.addClientAuthentication,resource:o,fetchFn:n})}async function YQ(t,{metadata:e,clientMetadata:r,scope:o,fetchFn:s}){let n;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");n=new URL(e.registration_endpoint)}else n=new URL("/register",t);let i=await(s??fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...o!==void 0?{scope:o}:{}})});if(!i.ok)throw await Sp(i);return Cp.parse(await i.json())}var Hc=class extends Error{constructor(e,r,o){super(`SSE error: ${r}`),this.code=e,this.event=o}},En=class{constructor(e,r){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=r?.eventSourceInit,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=hn(r?.fetch,r?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new Qe("No auth provider");let e;try{e=await ct(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new Qe;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let o=await this._authProvider.tokens();o&&(e.Authorization=`Bearer ${o.access_token}`)}this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);let r=xr(this._requestInit?.headers);return new Headers({...e,...r})}_startOrAuth(){let e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((r,o)=>{this._eventSource=new Yt(this._url.href,{...this._eventSourceInit,fetch:async(s,n)=>{let i=await this._commonHeaders();i.set("Accept","text/event-stream");let a=await e(s,{...n,headers:i});if(a.status===401&&a.headers.has("www-authenticate")){let{resourceMetadataUrl:c,scope:u}=Rr(a);this._resourceMetadataUrl=c,this._scope=u}return a}}),this._abortController=new AbortController,this._eventSource.onerror=s=>{if(s.code===401&&this._authProvider){this._authThenStart().then(r,o);return}let n=new Hc(s.code,s.message,s);o(n),this.onerror?.(n)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",s=>{let n=s;try{if(this._endpoint=new URL(n.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(i){o(i),this.onerror?.(i),this.close();return}r()}),this._eventSource.onmessage=s=>{let n=s,i;try{i=Et.parse(JSON.parse(n.data))}catch(a){this.onerror?.(a);return}this.onmessage?.(i)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new Qe("No auth provider");if(await ct(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Qe("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw new Error("Not connected");try{let r=await this._commonHeaders();r.set("content-type","application/json");let o={...this._requestInit,method:"POST",headers:r,body:JSON.stringify(e),signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._endpoint,o);if(!s.ok){let n=await s.text().catch(()=>null);if(s.status===401&&this._authProvider){let{resourceMetadataUrl:i,scope:a}=Rr(s);if(this._resourceMetadataUrl=i,this._scope=a,await ct(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Qe;return this.send(e)}throw new Error(`Error POSTing to endpoint (HTTP ${s.status}): ${n}`)}await s.body?.cancel()}catch(r){throw this.onerror?.(r),r}}setProtocolVersion(e){this._protocolVersion=e}};var ym=ls(hm(),1);import rl from"process";import{PassThrough as I_}from"stream";var w_=10*1024*1024,wn=class{constructor(e){this._maxBufferSize=e?.maxBufferSize??w_}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
21
21
|
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),C_(r)}clear(){this._buffer=void 0}};function C_(t){return Et.parse(JSON.parse(t))}function Em(t){return JSON.stringify(t)+`
|
|
22
|
-
`}var B_=rl.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function Q_(){let t={};for(let e of B_){let r=rl.env[e];r!==void 0&&(r.startsWith("()")||(t[e]=r))}return t}var Cn=class{constructor(e){this._stderrStream=null,this._serverParams=e,this._readBuffer=new wn({maxBufferSize:e.maxBufferSize}),(e.stderr==="pipe"||e.stderr==="overlapped")&&(this._stderrStream=new I_)}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)=>{this._process=(0,ym.default)(this._serverParams.command,this._serverParams.args??[],{env:{...Q_(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:rl.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",o=>{r(o),this.onerror?.(o)}),this._process.on("spawn",()=>{e()}),this._process.on("close",o=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",o=>{this.onerror?.(o)}),this._process.stdout?.on("data",o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}}),this._process.stdout?.on("error",o=>{this.onerror?.(o)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){return this._stderrStream?this._stderrStream:this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._process){let e=this._process;this._process=void 0;let r=new Promise(o=>{e.once("close",()=>{o()})});try{e.stdin?.end()}catch{}if(await Promise.race([r,new Promise(o=>setTimeout(o,2e3).unref())]),e.exitCode===null){try{e.kill("SIGTERM")}catch{}await Promise.race([r,new Promise(o=>setTimeout(o,2e3).unref())])}if(e.exitCode===null)try{e.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(e){return new Promise(r=>{if(!this._process?.stdin)throw new Error("Not connected");let o=Em(e);this._process.stdin.write(o)?r():this._process.stdin.once("drain",r)})}};var Qm=ls(Bm(),1);function _m(t){if(t)try{return Qm.default.parse(t).type}catch{let e=(t.split(";",1)[0]??"").trim().toLowerCase();return e===""||t.slice(e.length).includes(",")?void 0:e}}var In=class extends TransformStream{constructor({onError:e,onRetry:r,onComment:o,maxBufferSize:s}={}){let n;super({start(i){n=pn({onEvent:a=>{i.enqueue(a)},onError(a){typeof e=="function"&&e(a),(e==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:o,maxBufferSize:s})},transform(i){n.feed(i)}})}};var D_={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},vt=class extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}},Bn=class{constructor(e,r){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=hn(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??D_}async _authThenStart(){if(!this._authProvider)throw new Qe("No auth provider");let e;try{e=await ct(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new Qe;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let o=await this._authProvider.tokens();o&&(e.Authorization=`Bearer ${o.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);let r=xr(this._requestInit?.headers);return new Headers({...e,...r})}async _startOrAuthSse(e){let{resumptionToken:r}=e;try{let o=await this._commonHeaders();o.set("Accept","text/event-stream"),r&&o.set("last-event-id",r);let s=await(this._fetch??fetch)(this._url,{method:"GET",headers:o,signal:this._abortController?.signal});if(!s.ok){if(await s.body?.cancel(),s.status===401&&this._authProvider)return await this._authThenStart();if(s.status===405)return;throw new vt(s.status,`Failed to open SSE stream: ${s.statusText}`)}this._handleSseStream(s.body,e,!0)}catch(o){throw this.onerror?.(o),o}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,o=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(o,e),s)}_scheduleReconnection(e,r=0){let o=this._reconnectionOptions.maxRetries;if(r>=o){this.onerror?.(new Error(`Maximum reconnection attempts (${o}) exceeded.`));return}let s=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,r+1)})},s)}_handleSseStream(e,r,o){if(!e)return;let{onresumptiontoken:s,replayMessageId:n}=r,i,a=!1,c=!1;(async()=>{try{let l=e.pipeThrough(new TextDecoderStream).pipeThrough(new In({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){let{value:m,done:g}=await l.read();if(g)break;if(m.id&&(i=m.id,a=!0,s?.(m.id)),!!m.data&&(!m.event||m.event==="message"))try{let f=Et.parse(JSON.parse(m.data));xt(f)&&(c=!0,n!==void 0&&(f.id=n)),this.onmessage?.(f)}catch(f){this.onerror?.(f)}}(o||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:n},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(o||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:n},0)}catch(m){this.onerror?.(new Error(`Failed to reconnect: ${m instanceof Error?m.message:String(m)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Qe("No auth provider");if(await ct(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Qe("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,r){try{let{resumptionToken:o,onresumptiontoken:s}=r||{};if(o){this._startOrAuthSse({resumptionToken:o,replayMessageId:Jr(e)?e.id:void 0}).catch(m=>this.onerror?.(m));return}let n=await this._commonHeaders();n.set("content-type","application/json"),n.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(e),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let m=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new vt(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:g,scope:f}=Rr(a);if(this._resourceMetadataUrl=g,this._scope=f,await ct(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Qe;return this._hasCompletedAuthFlow=!0,this.send(e)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:g,scope:f,error:h}=Rr(a);if(h==="insufficient_scope"){let w=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===w)throw new vt(403,"Server returned 403 after trying upscoping");if(f&&(this._scope=f),g&&(this._resourceMetadataUrl=g),this._lastUpscopingHeader=w??void 0,await ct(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Qe;return this.send(e)}}throw new vt(a.status,`Error POSTing to endpoint: ${m}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),nu(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(m=>this.onerror?.(m));return}let l=(Array.isArray(e)?e:[e]).filter(m=>"method"in m&&"id"in m&&m.id!==void 0).length>0,A=a.headers.get("content-type"),d=_m(A);if(l)if(d==="text/event-stream")this._handleSseStream(a.body,{onresumptiontoken:s},!1);else if(d==="application/json"){let m=await a.json(),g=Array.isArray(m)?m.map(f=>Et.parse(f)):[Et.parse(m)];for(let f of g)this.onmessage?.(f)}else throw await a.body?.cancel(),new vt(-1,`Unexpected content type: ${A}`);else await a.body?.cancel()}catch(o){throw this.onerror?.(o),o}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,r);if(await o.body?.cancel(),!o.ok&&o.status!==405)throw new vt(o.status,`Failed to terminate session: ${o.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r?.onresumptiontoken})}};import{readFileSync as T_,statSync as $_}from"fs";import{extname as P_}from"path";import sl from"sharp";var j_=R({module:"images"});function Sm(t){if(t==="image/png"||t==="image/jpeg"||t==="image/gif"||t==="image/webp")return t;throw new Error(`Unsupported image media type: "${t}"`)}var al=5*1024*1024,nl=al*3/4,bt=2e3,RT=10,$r=class extends Error{constructor(e){super(e),this.name="ImageTooLargeError"}},N_={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"};function z_(t){return N_[P_(t).toLowerCase()]??null}function km(t){return z_(t)!==null}function U_(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?"image/png":t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255?"image/jpeg":t.length>=6&&t[0]===71&&t[1]===73&&t[2]===70?"image/gif":t.length>=12&&t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80?"image/webp":null}async function Mm(t){if(!$_(t).isFile())throw new Error(`Not a file: ${t}`);let r=T_(t),o=U_(r);if(!o)throw new Error(`File ${t} has an image extension but its contents are not a supported image format (png/jpeg/gif/webp)`);let s=await cl(r,o);return{mediaType:s.mediaType,data:s.data,sourcePath:t,byteLength:s.byteLength}}function il(t,e){return{data:t.toString("base64"),mediaType:e,byteLength:t.length}}function Wo(t){return`${(t/(1024*1024)).toFixed(1)}MB`}async function cl(t,e){if(t.length===0)throw new $r("Image file is empty (0 bytes)");if(t.length<=nl)return il(t,e);try{return await F_(t,e)}catch(r){throw r instanceof $r?r:(j_.warn({err:r},"sharp compression failed"),new $r(`Image is ${Wo(t.length)} raw (${Wo(t.length*4/3)} base64-encoded, API limit ${Wo(al)}) and compression failed. Please provide a smaller image.`))}}async function F_(t,e){let r=await sl(t).metadata(),o=r.width??bt,s=r.height??bt;o>bt&&(s=Math.max(1,Math.round(s*bt/o)),o=bt),s>bt&&(o=Math.max(1,Math.round(o*bt/s)),s=bt);let n=e==="image/png"||e==="image/gif";for(let i=0;i<3;i++){if(n){let a=await sl(t).resize(o,s,{fit:"inside",withoutEnlargement:!0}).png({compressionLevel:8,palette:!0}).toBuffer();if(a.length<=nl)return il(a,"image/png")}for(let a of[80,60,40,20]){let c=await sl(t).resize(o,s,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:a}).toBuffer();if(c.length<=nl)return il(c,"image/jpeg")}o=Math.max(1,Math.round(o/2)),s=Math.max(1,Math.round(s/2))}throw new $r(`Unable to compress image (${Wo(t.length)} raw) under the ${Wo(al)} API limit. Please provide a smaller image.`)}import{readFileSync as O_}from"fs";import vm from"path";import{fileURLToPath as L_}from"url";var q_=D.object({version:D.string()});function G_(){return"0.0.19"}var bm=G_();var Rm=R({module:"mcp"});function xm(t){return t.replace(/\$\{(\w+)\}|\$(\w+)/g,(e,r,o)=>process.env[r||o]??"")}function H_(t){let e={};for(let[r,o]of Object.entries(t))e[r]=o??"";return e}var Y_=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function J_(t){let e=[],r=[];for(let s of t){let n=Ol(s)?s:{};if(n.type==="image"&&typeof n.data=="string"&&typeof n.mimeType=="string"&&Y_.has(n.mimeType))try{let i=await cl(Buffer.from(n.data,"base64"),Sm(n.mimeType));r.push({type:"image",source:{type:"base64",media_type:i.mediaType,data:i.data}});continue}catch(i){Rm.warn({err:i},"mcp image dropped (too large to fit the API limit)"),e.push("[note: an image returned by the tool was too large and was dropped]");continue}e.push(n.type==="text"&&typeof n.text=="string"?n.text:JSON.stringify(s))}let o=e.join(`
|
|
22
|
+
`}var B_=rl.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function Q_(){let t={};for(let e of B_){let r=rl.env[e];r!==void 0&&(r.startsWith("()")||(t[e]=r))}return t}var Cn=class{constructor(e){this._stderrStream=null,this._serverParams=e,this._readBuffer=new wn({maxBufferSize:e.maxBufferSize}),(e.stderr==="pipe"||e.stderr==="overlapped")&&(this._stderrStream=new I_)}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)=>{this._process=(0,ym.default)(this._serverParams.command,this._serverParams.args??[],{env:{...Q_(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:rl.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",o=>{r(o),this.onerror?.(o)}),this._process.on("spawn",()=>{e()}),this._process.on("close",o=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",o=>{this.onerror?.(o)}),this._process.stdout?.on("data",o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}}),this._process.stdout?.on("error",o=>{this.onerror?.(o)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){return this._stderrStream?this._stderrStream:this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._process){let e=this._process;this._process=void 0;let r=new Promise(o=>{e.once("close",()=>{o()})});try{e.stdin?.end()}catch{}if(await Promise.race([r,new Promise(o=>setTimeout(o,2e3).unref())]),e.exitCode===null){try{e.kill("SIGTERM")}catch{}await Promise.race([r,new Promise(o=>setTimeout(o,2e3).unref())])}if(e.exitCode===null)try{e.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(e){return new Promise(r=>{if(!this._process?.stdin)throw new Error("Not connected");let o=Em(e);this._process.stdin.write(o)?r():this._process.stdin.once("drain",r)})}};var Qm=ls(Bm(),1);function _m(t){if(t)try{return Qm.default.parse(t).type}catch{let e=(t.split(";",1)[0]??"").trim().toLowerCase();return e===""||t.slice(e.length).includes(",")?void 0:e}}var In=class extends TransformStream{constructor({onError:e,onRetry:r,onComment:o,maxBufferSize:s}={}){let n;super({start(i){n=pn({onEvent:a=>{i.enqueue(a)},onError(a){typeof e=="function"&&e(a),(e==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:o,maxBufferSize:s})},transform(i){n.feed(i)}})}};var D_={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},vt=class extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}},Bn=class{constructor(e,r){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=hn(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??D_}async _authThenStart(){if(!this._authProvider)throw new Qe("No auth provider");let e;try{e=await ct(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new Qe;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let o=await this._authProvider.tokens();o&&(e.Authorization=`Bearer ${o.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);let r=xr(this._requestInit?.headers);return new Headers({...e,...r})}async _startOrAuthSse(e){let{resumptionToken:r}=e;try{let o=await this._commonHeaders();o.set("Accept","text/event-stream"),r&&o.set("last-event-id",r);let s=await(this._fetch??fetch)(this._url,{method:"GET",headers:o,signal:this._abortController?.signal});if(!s.ok){if(await s.body?.cancel(),s.status===401&&this._authProvider)return await this._authThenStart();if(s.status===405)return;throw new vt(s.status,`Failed to open SSE stream: ${s.statusText}`)}this._handleSseStream(s.body,e,!0)}catch(o){throw this.onerror?.(o),o}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,o=this._reconnectionOptions.reconnectionDelayGrowFactor,s=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(o,e),s)}_scheduleReconnection(e,r=0){let o=this._reconnectionOptions.maxRetries;if(r>=o){this.onerror?.(new Error(`Maximum reconnection attempts (${o}) exceeded.`));return}let s=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,r+1)})},s)}_handleSseStream(e,r,o){if(!e)return;let{onresumptiontoken:s,replayMessageId:n}=r,i,a=!1,c=!1;(async()=>{try{let l=e.pipeThrough(new TextDecoderStream).pipeThrough(new In({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){let{value:m,done:g}=await l.read();if(g)break;if(m.id&&(i=m.id,a=!0,s?.(m.id)),!!m.data&&(!m.event||m.event==="message"))try{let f=Et.parse(JSON.parse(m.data));xt(f)&&(c=!0,n!==void 0&&(f.id=n)),this.onmessage?.(f)}catch(f){this.onerror?.(f)}}(o||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:n},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(o||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:n},0)}catch(m){this.onerror?.(new Error(`Failed to reconnect: ${m instanceof Error?m.message:String(m)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Qe("No auth provider");if(await ct(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Qe("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,r){try{let{resumptionToken:o,onresumptiontoken:s}=r||{};if(o){this._startOrAuthSse({resumptionToken:o,replayMessageId:Jr(e)?e.id:void 0}).catch(m=>this.onerror?.(m));return}let n=await this._commonHeaders();n.set("content-type","application/json"),n.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(e),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let m=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new vt(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:g,scope:f}=Rr(a);if(this._resourceMetadataUrl=g,this._scope=f,await ct(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new Qe;return this._hasCompletedAuthFlow=!0,this.send(e)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:g,scope:f,error:h}=Rr(a);if(h==="insufficient_scope"){let w=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===w)throw new vt(403,"Server returned 403 after trying upscoping");if(f&&(this._scope=f),g&&(this._resourceMetadataUrl=g),this._lastUpscopingHeader=w??void 0,await ct(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new Qe;return this.send(e)}}throw new vt(a.status,`Error POSTing to endpoint: ${m}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),nu(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(m=>this.onerror?.(m));return}let l=(Array.isArray(e)?e:[e]).filter(m=>"method"in m&&"id"in m&&m.id!==void 0).length>0,A=a.headers.get("content-type"),d=_m(A);if(l)if(d==="text/event-stream")this._handleSseStream(a.body,{onresumptiontoken:s},!1);else if(d==="application/json"){let m=await a.json(),g=Array.isArray(m)?m.map(f=>Et.parse(f)):[Et.parse(m)];for(let f of g)this.onmessage?.(f)}else throw await a.body?.cancel(),new vt(-1,`Unexpected content type: ${A}`);else await a.body?.cancel()}catch(o){throw this.onerror?.(o),o}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,r);if(await o.body?.cancel(),!o.ok&&o.status!==405)throw new vt(o.status,`Failed to terminate session: ${o.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r?.onresumptiontoken})}};import{readFileSync as T_,statSync as $_}from"fs";import{extname as P_}from"path";import sl from"sharp";var j_=R({module:"images"});function Sm(t){if(t==="image/png"||t==="image/jpeg"||t==="image/gif"||t==="image/webp")return t;throw new Error(`Unsupported image media type: "${t}"`)}var al=5*1024*1024,nl=al*3/4,bt=2e3,RT=10,$r=class extends Error{constructor(e){super(e),this.name="ImageTooLargeError"}},N_={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"};function z_(t){return N_[P_(t).toLowerCase()]??null}function km(t){return z_(t)!==null}function U_(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?"image/png":t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255?"image/jpeg":t.length>=6&&t[0]===71&&t[1]===73&&t[2]===70?"image/gif":t.length>=12&&t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80?"image/webp":null}async function Mm(t){if(!$_(t).isFile())throw new Error(`Not a file: ${t}`);let r=T_(t),o=U_(r);if(!o)throw new Error(`File ${t} has an image extension but its contents are not a supported image format (png/jpeg/gif/webp)`);let s=await cl(r,o);return{mediaType:s.mediaType,data:s.data,sourcePath:t,byteLength:s.byteLength}}function il(t,e){return{data:t.toString("base64"),mediaType:e,byteLength:t.length}}function Wo(t){return`${(t/(1024*1024)).toFixed(1)}MB`}async function cl(t,e){if(t.length===0)throw new $r("Image file is empty (0 bytes)");if(t.length<=nl)return il(t,e);try{return await F_(t,e)}catch(r){throw r instanceof $r?r:(j_.warn({err:r},"sharp compression failed"),new $r(`Image is ${Wo(t.length)} raw (${Wo(t.length*4/3)} base64-encoded, API limit ${Wo(al)}) and compression failed. Please provide a smaller image.`))}}async function F_(t,e){let r=await sl(t).metadata(),o=r.width??bt,s=r.height??bt;o>bt&&(s=Math.max(1,Math.round(s*bt/o)),o=bt),s>bt&&(o=Math.max(1,Math.round(o*bt/s)),s=bt);let n=e==="image/png"||e==="image/gif";for(let i=0;i<3;i++){if(n){let a=await sl(t).resize(o,s,{fit:"inside",withoutEnlargement:!0}).png({compressionLevel:8,palette:!0}).toBuffer();if(a.length<=nl)return il(a,"image/png")}for(let a of[80,60,40,20]){let c=await sl(t).resize(o,s,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:a}).toBuffer();if(c.length<=nl)return il(c,"image/jpeg")}o=Math.max(1,Math.round(o/2)),s=Math.max(1,Math.round(s/2))}throw new $r(`Unable to compress image (${Wo(t.length)} raw) under the ${Wo(al)} API limit. Please provide a smaller image.`)}import{readFileSync as O_}from"fs";import vm from"path";import{fileURLToPath as L_}from"url";var q_=D.object({version:D.string()});function G_(){return"0.0.20"}var bm=G_();var Rm=R({module:"mcp"});function xm(t){return t.replace(/\$\{(\w+)\}|\$(\w+)/g,(e,r,o)=>process.env[r||o]??"")}function H_(t){let e={};for(let[r,o]of Object.entries(t))e[r]=o??"";return e}var Y_=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function J_(t){let e=[],r=[];for(let s of t){let n=Ol(s)?s:{};if(n.type==="image"&&typeof n.data=="string"&&typeof n.mimeType=="string"&&Y_.has(n.mimeType))try{let i=await cl(Buffer.from(n.data,"base64"),Sm(n.mimeType));r.push({type:"image",source:{type:"base64",media_type:i.mediaType,data:i.data}});continue}catch(i){Rm.warn({err:i},"mcp image dropped (too large to fit the API limit)"),e.push("[note: an image returned by the tool was too large and was dropped]");continue}e.push(n.type==="text"&&typeof n.text=="string"?n.text:JSON.stringify(s))}let o=e.join(`
|
|
23
23
|
`);return r.length===0?o:[...o?[{type:"text",text:o}]:[],...r]}var Qn=class{name;config;client=null;transport=null;constructor(e){this.name=e.name,this.config=e}async connect(){if(this.config.command){let e=process.env;if(this.config.env)for(let[r,o]of Object.entries(this.config.env))e[r]=xm(o);this.transport=new Cn({command:this.config.command,args:this.config.args??[],env:H_(e),stderr:"ignore"})}else if(this.config.url){let e=new URL(this.config.url),r={};if(this.config.headers)for(let[s,n]of Object.entries(this.config.headers))r[s]=xm(n);let o={requestInit:{headers:r}};this.transport=this.config.transport==="sse"?new En(e,o):new Bn(e,o)}else throw new Error(`MCP server '${this.name}': needs either 'command' (stdio) or 'url' (http/sse)`);this.client=new dn({name:"swifty",version:bm},{}),await this.client.connect(this.transport)}getInstructions(){return this.client?.getInstructions()??""}async listTools(){if(!this.client)throw new Error("Not connected");return(await this.client.listTools()).tools.map(({name:r,description:o,inputSchema:{properties:s,...n}})=>({name:r,description:o??"",inputSchema:{...n,properties:s??{}}}))}async callTool(e,r){if(!this.client)throw new Error("Not connected");let o=await this.client.callTool({name:e,arguments:r}),s;return o.content&&Array.isArray(o.content)?s=await J_(o.content):s=JSON.stringify(o),{output:s,isError:o.isError===!0}}async disconnect(){try{await this.client?.close()}catch(e){Rm.error({err:e},"mcp operation failed")}this.client=null,this.transport=null}};var W_=R({module:"mcp"}),Dm=class{clients=new Map;async connectAll(e){let r={tools:[],servers:[],errors:[],instructions:[]};for(let o of e){let s=new Qn(o);try{await s.connect(),this.clients.set(o.name,s),r.servers.push(o.name);let n=await s.listTools();for(let a of n)r.tools.push({serverName:o.name,tool:a});let i=s.getInstructions();i&&r.instructions.push({serverName:o.name,text:i})}catch(n){W_.error({err:n},"mcp operation failed"),r.errors.push({serverName:o.name,error:U(n)})}}return r}getClient(e){return this.clients.get(e)}async disconnectAll(){for(let e of this.clients.values())await e.disconnect();this.clients.clear()}};import{execSync as Om}from"child_process";import{platform as V_,arch as K_}from"os";function Tm(){return{name:"Identity",priority:0,content:`You are Swifty, an AI programming assistant running in a terminal.
|
|
24
24
|
You assist users with software engineering tasks, including writing code, debugging, refactoring, explaining code, and executing commands.
|
|
25
25
|
|
package/dist/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __swiftyCreateRequire } from "node:module";
|
|
3
3
|
const require = __swiftyCreateRequire(import.meta.url);
|
|
4
|
-
import{$ as iB,A as mC,B as Xv,C as jv,D as S0,E as Zv,F as ZA,G as Pg,H as $v,I as Fg,J as Gg,K as zg,L as Hg,M as Yg,N as qg,O as Kg,P as Vg,Q as Wg,R as Jg,S as fC,T as eB,U as tB,V as aB,W as EC,X as hC,Y as SC,Z as nB,_ as rB,a as wg,aa as C0,b as Fv,ba as CC,c as Gv,ca as oB,da as sB,e as h0,ea as GE,f as zv,fa as lB,g as Hv,ga as y0,h as uC,ha as yC,i as kg,ia as cB,j as xg,ja as uB,k as Lg,ka as dB,l as Yv,la as AB,m as qv,ma as _B,n as Kv,na as pB,o as Vv,oa as gB,p as dC,q as Wv,r as Qg,s as Jv,t as AC,u as FE,v as _C,x as dd,y as pC,z as gC}from"./chunk-T5HVHWMQ.js";import{c as xE}from"./chunk-XBHVVB5A.js";import{b as Dg}from"./chunk-3USGFIWF.js";import{a as xv,b as PE,c as Lv,d as Qv,e as Uv,f as cC,g as Pv,h as Bg}from"./chunk-5J4WCPY4.js";import{a as ud,d as Ov,e as Og,f as f0,g as E0,h as vv,i as Bv,j as wv,n as kv}from"./chunk-ASZMSWK5.js";import{e as Xc,f as Mv,g as lC,i as UE,j as vg}from"./chunk-KSCFIYHH.js";import"./chunk-FZPTNGTU.js";import{e as Mg}from"./chunk-T74SUDUF.js";import{b as Rg,e as Ng}from"./chunk-P276SKAC.js";import"./chunk-7MHXMDYC.js";import{C as _r,E as Rv,F as LE,G as sC,H as QE,I as xr,K as ml,L as Nv,M as Dv,O as xo,S as ks,e as Iv,f as bv}from"./chunk-ZM2V2A7B.js";import{a as Ug}from"./chunk-A2VR3BC4.js";import"./chunk-E55KH72M.js";import{a as jA,b as Q,c as _z,d as Ke}from"./chunk-X3UA5OZL.js";var RB=Q(oa=>{"use strict";var b0=Symbol.for("react.transitional.element"),pz=Symbol.for("react.portal"),gz=Symbol.for("react.fragment"),mz=Symbol.for("react.strict_mode"),fz=Symbol.for("react.profiler"),Ez=Symbol.for("react.consumer"),hz=Symbol.for("react.context"),Sz=Symbol.for("react.forward_ref"),Cz=Symbol.for("react.suspense"),yz=Symbol.for("react.memo"),SB=Symbol.for("react.lazy"),Tz=Symbol.for("react.activity"),mB=Symbol.iterator;function Iz(e){return e===null||typeof e!="object"?null:(e=mB&&e[mB]||e["@@iterator"],typeof e=="function"?e:null)}var CB={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},yB=Object.assign,TB={};function jg(e,t,a){this.props=e,this.context=t,this.refs=TB,this.updater=a||CB}jg.prototype.isReactComponent={};jg.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};jg.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function IB(){}IB.prototype=jg.prototype;function R0(e,t,a){this.props=e,this.context=t,this.refs=TB,this.updater=a||CB}var N0=R0.prototype=new IB;N0.constructor=R0;yB(N0,jg.prototype);N0.isPureReactComponent=!0;var fB=Array.isArray;function I0(){}var Mn={H:null,A:null,T:null,S:null},bB=Object.prototype.hasOwnProperty;function D0(e,t,a){var i=a.ref;return{$$typeof:b0,type:e,key:t,ref:i!==void 0?i:null,props:a}}function bz(e,t){return D0(e.type,t,e.props)}function O0(e){return typeof e=="object"&&e!==null&&e.$$typeof===b0}function Rz(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(a){return t[a]})}var EB=/\/+/g;function T0(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Rz(""+e.key):t.toString(36)}function Nz(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(I0,I0):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function Xg(e,t,a,i,l){var u=typeof e;(u==="undefined"||u==="boolean")&&(e=null);var _=!1;if(e===null)_=!0;else switch(u){case"bigint":case"string":case"number":_=!0;break;case"object":switch(e.$$typeof){case b0:case pz:_=!0;break;case SB:return _=e._init,Xg(_(e._payload),t,a,i,l)}}if(_)return l=l(e),_=i===""?"."+T0(e,0):i,fB(l)?(a="",_!=null&&(a=_.replace(EB,"$&/")+"/"),Xg(l,t,a,"",function(S){return S})):l!=null&&(O0(l)&&(l=bz(l,a+(l.key==null||e&&e.key===l.key?"":(""+l.key).replace(EB,"$&/")+"/")+_)),t.push(l)),1;_=0;var p=i===""?".":i+":";if(fB(e))for(var E=0;E<e.length;E++)i=e[E],u=p+T0(i,E),_+=Xg(i,t,a,u,l);else if(E=Iz(e),typeof E=="function")for(e=E.call(e),E=0;!(i=e.next()).done;)i=i.value,u=p+T0(i,E++),_+=Xg(i,t,a,u,l);else if(u==="object"){if(typeof e.then=="function")return Xg(Nz(e),t,a,i,l);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return _}function TC(e,t,a){if(e==null)return e;var i=[],l=0;return Xg(e,i,"","",function(u){return t.call(a,u,l++)}),i}function Dz(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(a){(e._status===0||e._status===-1)&&(e._status=1,e._result=a)},function(a){(e._status===0||e._status===-1)&&(e._status=2,e._result=a)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var hB=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Oz={map:TC,forEach:function(e,t,a){TC(e,function(){t.apply(this,arguments)},a)},count:function(e){var t=0;return TC(e,function(){t++}),t},toArray:function(e){return TC(e,function(t){return t})||[]},only:function(e){if(!O0(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};oa.Activity=Tz;oa.Children=Oz;oa.Component=jg;oa.Fragment=gz;oa.Profiler=fz;oa.PureComponent=R0;oa.StrictMode=mz;oa.Suspense=Cz;oa.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Mn;oa.__COMPILER_RUNTIME={__proto__:null,c:function(e){return Mn.H.useMemoCache(e)}};oa.cache=function(e){return function(){return e.apply(null,arguments)}};oa.cacheSignal=function(){return null};oa.cloneElement=function(e,t,a){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var i=yB({},e.props),l=e.key;if(t!=null)for(u in t.key!==void 0&&(l=""+t.key),t)!bB.call(t,u)||u==="key"||u==="__self"||u==="__source"||u==="ref"&&t.ref===void 0||(i[u]=t[u]);var u=arguments.length-2;if(u===1)i.children=a;else if(1<u){for(var _=Array(u),p=0;p<u;p++)_[p]=arguments[p+2];i.children=_}return D0(e.type,l,i)};oa.createContext=function(e){return e={$$typeof:hz,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:Ez,_context:e},e};oa.createElement=function(e,t,a){var i,l={},u=null;if(t!=null)for(i in t.key!==void 0&&(u=""+t.key),t)bB.call(t,i)&&i!=="key"&&i!=="__self"&&i!=="__source"&&(l[i]=t[i]);var _=arguments.length-2;if(_===1)l.children=a;else if(1<_){for(var p=Array(_),E=0;E<_;E++)p[E]=arguments[E+2];l.children=p}if(e&&e.defaultProps)for(i in _=e.defaultProps,_)l[i]===void 0&&(l[i]=_[i]);return D0(e,u,l)};oa.createRef=function(){return{current:null}};oa.forwardRef=function(e){return{$$typeof:Sz,render:e}};oa.isValidElement=O0;oa.lazy=function(e){return{$$typeof:SB,_payload:{_status:-1,_result:e},_init:Dz}};oa.memo=function(e,t){return{$$typeof:yz,type:e,compare:t===void 0?null:t}};oa.startTransition=function(e){var t=Mn.T,a={};Mn.T=a;try{var i=e(),l=Mn.S;l!==null&&l(a,i),typeof i=="object"&&i!==null&&typeof i.then=="function"&&i.then(I0,hB)}catch(u){hB(u)}finally{t!==null&&a.types!==null&&(t.types=a.types),Mn.T=t}};oa.unstable_useCacheRefresh=function(){return Mn.H.useCacheRefresh()};oa.use=function(e){return Mn.H.use(e)};oa.useActionState=function(e,t,a){return Mn.H.useActionState(e,t,a)};oa.useCallback=function(e,t){return Mn.H.useCallback(e,t)};oa.useContext=function(e){return Mn.H.useContext(e)};oa.useDebugValue=function(){};oa.useDeferredValue=function(e,t){return Mn.H.useDeferredValue(e,t)};oa.useEffect=function(e,t){return Mn.H.useEffect(e,t)};oa.useEffectEvent=function(e){return Mn.H.useEffectEvent(e)};oa.useId=function(){return Mn.H.useId()};oa.useImperativeHandle=function(e,t,a){return Mn.H.useImperativeHandle(e,t,a)};oa.useInsertionEffect=function(e,t){return Mn.H.useInsertionEffect(e,t)};oa.useLayoutEffect=function(e,t){return Mn.H.useLayoutEffect(e,t)};oa.useMemo=function(e,t){return Mn.H.useMemo(e,t)};oa.useOptimistic=function(e,t){return Mn.H.useOptimistic(e,t)};oa.useReducer=function(e,t,a){return Mn.H.useReducer(e,t,a)};oa.useRef=function(e){return Mn.H.useRef(e)};oa.useState=function(e){return Mn.H.useState(e)};oa.useSyncExternalStore=function(e,t,a){return Mn.H.useSyncExternalStore(e,t,a)};oa.useTransition=function(){return Mn.H.useTransition()};oa.version="19.2.7"});var NB=Q((ta,IC)=>{"use strict";process.env.NODE_ENV!=="production"&&(function(){function e(v,ee){Object.defineProperty(i.prototype,v,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",ee[0],ee[1])}})}function t(v){return v===null||typeof v!="object"?null:(v=Oe&&v[Oe]||v["@@iterator"],typeof v=="function"?v:null)}function a(v,ee){v=(v=v.constructor)&&(v.displayName||v.name)||"ReactClass";var ye=v+"."+ee;Te[ye]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",ee,v),Te[ye]=!0)}function i(v,ee,ye){this.props=v,this.context=ee,this.refs=Ce,this.updater=ye||Ct}function l(){}function u(v,ee,ye){this.props=v,this.context=ee,this.refs=Ce,this.updater=ye||Ct}function _(){}function p(v){return""+v}function E(v){try{p(v);var ee=!1}catch{ee=!0}if(ee){ee=console;var ye=ee.error,Fe=typeof Symbol=="function"&&Symbol.toStringTag&&v[Symbol.toStringTag]||v.constructor.name||"Object";return ye.call(ee,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Fe),p(v)}}function S(v){if(v==null)return null;if(typeof v=="function")return v.$$typeof===bt?null:v.displayName||v.name||null;if(typeof v=="string")return v;switch(v){case kt:return"Fragment";case pe:return"Profiler";case jt:return"StrictMode";case at:return"Suspense";case Nt:return"SuspenseList";case Se:return"Activity"}if(typeof v=="object")switch(typeof v.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),v.$$typeof){case Ye:return"Portal";case se:return v.displayName||"Context";case ot:return(v._context.displayName||"Context")+".Consumer";case be:var ee=v.render;return v=v.displayName,v||(v=ee.displayName||ee.name||"",v=v!==""?"ForwardRef("+v+")":"ForwardRef"),v;case ct:return ee=v.displayName||null,ee!==null?ee:S(v.type)||"Memo";case ve:ee=v._payload,v=v._init;try{return S(v(ee))}catch{}}return null}function T(v){if(v===kt)return"<>";if(typeof v=="object"&&v!==null&&v.$$typeof===ve)return"<...>";try{var ee=S(v);return ee?"<"+ee+">":"<...>"}catch{return"<...>"}}function D(){var v=We.A;return v===null?null:v.getOwner()}function b(){return Error("react-stack-top-frame")}function N(v){if(sa.call(v,"key")){var ee=Object.getOwnPropertyDescriptor(v,"key").get;if(ee&&ee.isReactWarning)return!1}return v.key!==void 0}function O(v,ee){function ye(){Ma||(Ma=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",ee))}ye.isReactWarning=!0,Object.defineProperty(v,"key",{get:ye,configurable:!0})}function w(){var v=S(this.type);return on[v]||(on[v]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),v=this.props.ref,v!==void 0?v:null}function k(v,ee,ye,Fe,lt,Lt){var Tt=ye.ref;return v={$$typeof:dt,type:v,key:ee,props:ye,_owner:Fe},(Tt!==void 0?Tt:null)!==null?Object.defineProperty(v,"ref",{enumerable:!1,get:w}):Object.defineProperty(v,"ref",{enumerable:!1,value:null}),v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(v,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(v,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:lt}),Object.defineProperty(v,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Lt}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v}function G(v,ee){return ee=k(v.type,ee,v.props,v._owner,v._debugStack,v._debugTask),v._store&&(ee._store.validated=v._store.validated),ee}function $(v){ie(v)?v._store&&(v._store.validated=1):typeof v=="object"&&v!==null&&v.$$typeof===ve&&(v._payload.status==="fulfilled"?ie(v._payload.value)&&v._payload.value._store&&(v._payload.value._store.validated=1):v._store&&(v._store.validated=1))}function ie(v){return typeof v=="object"&&v!==null&&v.$$typeof===dt}function ae(v){var ee={"=":"=0",":":"=2"};return"$"+v.replace(/[=:]/g,function(ye){return ee[ye]})}function Ne(v,ee){return typeof v=="object"&&v!==null&&v.key!=null?(E(v.key),ae(""+v.key)):ee.toString(36)}function we(v){switch(v.status){case"fulfilled":return v.value;case"rejected":throw v.reason;default:switch(typeof v.status=="string"?v.then(_,_):(v.status="pending",v.then(function(ee){v.status==="pending"&&(v.status="fulfilled",v.value=ee)},function(ee){v.status==="pending"&&(v.status="rejected",v.reason=ee)})),v.status){case"fulfilled":return v.value;case"rejected":throw v.reason}}throw v}function Ge(v,ee,ye,Fe,lt){var Lt=typeof v;(Lt==="undefined"||Lt==="boolean")&&(v=null);var Tt=!1;if(v===null)Tt=!0;else switch(Lt){case"bigint":case"string":case"number":Tt=!0;break;case"object":switch(v.$$typeof){case dt:case Ye:Tt=!0;break;case ve:return Tt=v._init,Ge(Tt(v._payload),ee,ye,Fe,lt)}}if(Tt){Tt=v,lt=lt(Tt);var $t=Fe===""?"."+Ne(Tt,0):Fe;return it(lt)?(ye="",$t!=null&&(ye=$t.replace(Cn,"$&/")+"/"),Ge(lt,ee,ye,"",function(sn){return sn})):lt!=null&&(ie(lt)&&(lt.key!=null&&(Tt&&Tt.key===lt.key||E(lt.key)),ye=G(lt,ye+(lt.key==null||Tt&&Tt.key===lt.key?"":(""+lt.key).replace(Cn,"$&/")+"/")+$t),Fe!==""&&Tt!=null&&ie(Tt)&&Tt.key==null&&Tt._store&&!Tt._store.validated&&(ye._store.validated=2),lt=ye),ee.push(lt)),1}if(Tt=0,$t=Fe===""?".":Fe+":",it(v))for(var Vt=0;Vt<v.length;Vt++)Fe=v[Vt],Lt=$t+Ne(Fe,Vt),Tt+=Ge(Fe,ee,ye,Lt,lt);else if(Vt=t(v),typeof Vt=="function")for(Vt===v.entries&&(Sn||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),Sn=!0),v=Vt.call(v),Vt=0;!(Fe=v.next()).done;)Fe=Fe.value,Lt=$t+Ne(Fe,Vt++),Tt+=Ge(Fe,ee,ye,Lt,lt);else if(Lt==="object"){if(typeof v.then=="function")return Ge(we(v),ee,ye,Fe,lt);throw ee=String(v),Error("Objects are not valid as a React child (found: "+(ee==="[object Object]"?"object with keys {"+Object.keys(v).join(", ")+"}":ee)+"). If you meant to render a collection of children, use an array instead.")}return Tt}function xe(v,ee,ye){if(v==null)return v;var Fe=[],lt=0;return Ge(v,Fe,"","",function(Lt){return ee.call(ye,Lt,lt++)}),Fe}function oe(v){if(v._status===-1){var ee=v._ioInfo;ee!=null&&(ee.start=ee.end=performance.now()),ee=v._result;var ye=ee();if(ye.then(function(lt){if(v._status===0||v._status===-1){v._status=1,v._result=lt;var Lt=v._ioInfo;Lt!=null&&(Lt.end=performance.now()),ye.status===void 0&&(ye.status="fulfilled",ye.value=lt)}},function(lt){if(v._status===0||v._status===-1){v._status=2,v._result=lt;var Lt=v._ioInfo;Lt!=null&&(Lt.end=performance.now()),ye.status===void 0&&(ye.status="rejected",ye.reason=lt)}}),ee=v._ioInfo,ee!=null){ee.value=ye;var Fe=ye.displayName;typeof Fe=="string"&&(ee.name=Fe)}v._status===-1&&(v._status=0,v._result=ye)}if(v._status===1)return ee=v._result,ee===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
4
|
+
import{$ as iB,A as mC,B as Xv,C as jv,D as S0,E as Zv,F as ZA,G as Pg,H as $v,I as Fg,J as Gg,K as zg,L as Hg,M as Yg,N as qg,O as Kg,P as Vg,Q as Wg,R as Jg,S as fC,T as eB,U as tB,V as aB,W as EC,X as hC,Y as SC,Z as nB,_ as rB,a as wg,aa as C0,b as Fv,ba as CC,c as Gv,ca as oB,da as sB,e as h0,ea as GE,f as zv,fa as lB,g as Hv,ga as y0,h as uC,ha as yC,i as kg,ia as cB,j as xg,ja as uB,k as Lg,ka as dB,l as Yv,la as AB,m as qv,ma as _B,n as Kv,na as pB,o as Vv,oa as gB,p as dC,q as Wv,r as Qg,s as Jv,t as AC,u as FE,v as _C,x as dd,y as pC,z as gC}from"./chunk-CMG6CZSL.js";import{c as xE}from"./chunk-XBHVVB5A.js";import{b as Dg}from"./chunk-3USGFIWF.js";import{a as xv,b as PE,c as Lv,d as Qv,e as Uv,f as cC,g as Pv,h as Bg}from"./chunk-5J4WCPY4.js";import{a as ud,d as Ov,e as Og,f as f0,g as E0,h as vv,i as Bv,j as wv,n as kv}from"./chunk-ASZMSWK5.js";import{e as Xc,f as Mv,g as lC,i as UE,j as vg}from"./chunk-KSCFIYHH.js";import"./chunk-FZPTNGTU.js";import{e as Mg}from"./chunk-T74SUDUF.js";import{b as Rg,e as Ng}from"./chunk-P276SKAC.js";import"./chunk-7MHXMDYC.js";import{C as _r,E as Rv,F as LE,G as sC,H as QE,I as xr,K as ml,L as Nv,M as Dv,O as xo,S as ks,e as Iv,f as bv}from"./chunk-ZM2V2A7B.js";import{a as Ug}from"./chunk-A2VR3BC4.js";import"./chunk-E55KH72M.js";import{a as jA,b as Q,c as _z,d as Ke}from"./chunk-X3UA5OZL.js";var RB=Q(oa=>{"use strict";var b0=Symbol.for("react.transitional.element"),pz=Symbol.for("react.portal"),gz=Symbol.for("react.fragment"),mz=Symbol.for("react.strict_mode"),fz=Symbol.for("react.profiler"),Ez=Symbol.for("react.consumer"),hz=Symbol.for("react.context"),Sz=Symbol.for("react.forward_ref"),Cz=Symbol.for("react.suspense"),yz=Symbol.for("react.memo"),SB=Symbol.for("react.lazy"),Tz=Symbol.for("react.activity"),mB=Symbol.iterator;function Iz(e){return e===null||typeof e!="object"?null:(e=mB&&e[mB]||e["@@iterator"],typeof e=="function"?e:null)}var CB={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},yB=Object.assign,TB={};function jg(e,t,a){this.props=e,this.context=t,this.refs=TB,this.updater=a||CB}jg.prototype.isReactComponent={};jg.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};jg.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function IB(){}IB.prototype=jg.prototype;function R0(e,t,a){this.props=e,this.context=t,this.refs=TB,this.updater=a||CB}var N0=R0.prototype=new IB;N0.constructor=R0;yB(N0,jg.prototype);N0.isPureReactComponent=!0;var fB=Array.isArray;function I0(){}var Mn={H:null,A:null,T:null,S:null},bB=Object.prototype.hasOwnProperty;function D0(e,t,a){var i=a.ref;return{$$typeof:b0,type:e,key:t,ref:i!==void 0?i:null,props:a}}function bz(e,t){return D0(e.type,t,e.props)}function O0(e){return typeof e=="object"&&e!==null&&e.$$typeof===b0}function Rz(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(a){return t[a]})}var EB=/\/+/g;function T0(e,t){return typeof e=="object"&&e!==null&&e.key!=null?Rz(""+e.key):t.toString(36)}function Nz(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:switch(typeof e.status=="string"?e.then(I0,I0):(e.status="pending",e.then(function(t){e.status==="pending"&&(e.status="fulfilled",e.value=t)},function(t){e.status==="pending"&&(e.status="rejected",e.reason=t)})),e.status){case"fulfilled":return e.value;case"rejected":throw e.reason}}throw e}function Xg(e,t,a,i,l){var u=typeof e;(u==="undefined"||u==="boolean")&&(e=null);var _=!1;if(e===null)_=!0;else switch(u){case"bigint":case"string":case"number":_=!0;break;case"object":switch(e.$$typeof){case b0:case pz:_=!0;break;case SB:return _=e._init,Xg(_(e._payload),t,a,i,l)}}if(_)return l=l(e),_=i===""?"."+T0(e,0):i,fB(l)?(a="",_!=null&&(a=_.replace(EB,"$&/")+"/"),Xg(l,t,a,"",function(S){return S})):l!=null&&(O0(l)&&(l=bz(l,a+(l.key==null||e&&e.key===l.key?"":(""+l.key).replace(EB,"$&/")+"/")+_)),t.push(l)),1;_=0;var p=i===""?".":i+":";if(fB(e))for(var E=0;E<e.length;E++)i=e[E],u=p+T0(i,E),_+=Xg(i,t,a,u,l);else if(E=Iz(e),typeof E=="function")for(e=E.call(e),E=0;!(i=e.next()).done;)i=i.value,u=p+T0(i,E++),_+=Xg(i,t,a,u,l);else if(u==="object"){if(typeof e.then=="function")return Xg(Nz(e),t,a,i,l);throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.")}return _}function TC(e,t,a){if(e==null)return e;var i=[],l=0;return Xg(e,i,"","",function(u){return t.call(a,u,l++)}),i}function Dz(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(a){(e._status===0||e._status===-1)&&(e._status=1,e._result=a)},function(a){(e._status===0||e._status===-1)&&(e._status=2,e._result=a)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var hB=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var t=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Oz={map:TC,forEach:function(e,t,a){TC(e,function(){t.apply(this,arguments)},a)},count:function(e){var t=0;return TC(e,function(){t++}),t},toArray:function(e){return TC(e,function(t){return t})||[]},only:function(e){if(!O0(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};oa.Activity=Tz;oa.Children=Oz;oa.Component=jg;oa.Fragment=gz;oa.Profiler=fz;oa.PureComponent=R0;oa.StrictMode=mz;oa.Suspense=Cz;oa.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=Mn;oa.__COMPILER_RUNTIME={__proto__:null,c:function(e){return Mn.H.useMemoCache(e)}};oa.cache=function(e){return function(){return e.apply(null,arguments)}};oa.cacheSignal=function(){return null};oa.cloneElement=function(e,t,a){if(e==null)throw Error("The argument must be a React element, but you passed "+e+".");var i=yB({},e.props),l=e.key;if(t!=null)for(u in t.key!==void 0&&(l=""+t.key),t)!bB.call(t,u)||u==="key"||u==="__self"||u==="__source"||u==="ref"&&t.ref===void 0||(i[u]=t[u]);var u=arguments.length-2;if(u===1)i.children=a;else if(1<u){for(var _=Array(u),p=0;p<u;p++)_[p]=arguments[p+2];i.children=_}return D0(e.type,l,i)};oa.createContext=function(e){return e={$$typeof:hz,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:Ez,_context:e},e};oa.createElement=function(e,t,a){var i,l={},u=null;if(t!=null)for(i in t.key!==void 0&&(u=""+t.key),t)bB.call(t,i)&&i!=="key"&&i!=="__self"&&i!=="__source"&&(l[i]=t[i]);var _=arguments.length-2;if(_===1)l.children=a;else if(1<_){for(var p=Array(_),E=0;E<_;E++)p[E]=arguments[E+2];l.children=p}if(e&&e.defaultProps)for(i in _=e.defaultProps,_)l[i]===void 0&&(l[i]=_[i]);return D0(e,u,l)};oa.createRef=function(){return{current:null}};oa.forwardRef=function(e){return{$$typeof:Sz,render:e}};oa.isValidElement=O0;oa.lazy=function(e){return{$$typeof:SB,_payload:{_status:-1,_result:e},_init:Dz}};oa.memo=function(e,t){return{$$typeof:yz,type:e,compare:t===void 0?null:t}};oa.startTransition=function(e){var t=Mn.T,a={};Mn.T=a;try{var i=e(),l=Mn.S;l!==null&&l(a,i),typeof i=="object"&&i!==null&&typeof i.then=="function"&&i.then(I0,hB)}catch(u){hB(u)}finally{t!==null&&a.types!==null&&(t.types=a.types),Mn.T=t}};oa.unstable_useCacheRefresh=function(){return Mn.H.useCacheRefresh()};oa.use=function(e){return Mn.H.use(e)};oa.useActionState=function(e,t,a){return Mn.H.useActionState(e,t,a)};oa.useCallback=function(e,t){return Mn.H.useCallback(e,t)};oa.useContext=function(e){return Mn.H.useContext(e)};oa.useDebugValue=function(){};oa.useDeferredValue=function(e,t){return Mn.H.useDeferredValue(e,t)};oa.useEffect=function(e,t){return Mn.H.useEffect(e,t)};oa.useEffectEvent=function(e){return Mn.H.useEffectEvent(e)};oa.useId=function(){return Mn.H.useId()};oa.useImperativeHandle=function(e,t,a){return Mn.H.useImperativeHandle(e,t,a)};oa.useInsertionEffect=function(e,t){return Mn.H.useInsertionEffect(e,t)};oa.useLayoutEffect=function(e,t){return Mn.H.useLayoutEffect(e,t)};oa.useMemo=function(e,t){return Mn.H.useMemo(e,t)};oa.useOptimistic=function(e,t){return Mn.H.useOptimistic(e,t)};oa.useReducer=function(e,t,a){return Mn.H.useReducer(e,t,a)};oa.useRef=function(e){return Mn.H.useRef(e)};oa.useState=function(e){return Mn.H.useState(e)};oa.useSyncExternalStore=function(e,t,a){return Mn.H.useSyncExternalStore(e,t,a)};oa.useTransition=function(){return Mn.H.useTransition()};oa.version="19.2.7"});var NB=Q((ta,IC)=>{"use strict";process.env.NODE_ENV!=="production"&&(function(){function e(v,ee){Object.defineProperty(i.prototype,v,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",ee[0],ee[1])}})}function t(v){return v===null||typeof v!="object"?null:(v=Oe&&v[Oe]||v["@@iterator"],typeof v=="function"?v:null)}function a(v,ee){v=(v=v.constructor)&&(v.displayName||v.name)||"ReactClass";var ye=v+"."+ee;Te[ye]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",ee,v),Te[ye]=!0)}function i(v,ee,ye){this.props=v,this.context=ee,this.refs=Ce,this.updater=ye||Ct}function l(){}function u(v,ee,ye){this.props=v,this.context=ee,this.refs=Ce,this.updater=ye||Ct}function _(){}function p(v){return""+v}function E(v){try{p(v);var ee=!1}catch{ee=!0}if(ee){ee=console;var ye=ee.error,Fe=typeof Symbol=="function"&&Symbol.toStringTag&&v[Symbol.toStringTag]||v.constructor.name||"Object";return ye.call(ee,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Fe),p(v)}}function S(v){if(v==null)return null;if(typeof v=="function")return v.$$typeof===bt?null:v.displayName||v.name||null;if(typeof v=="string")return v;switch(v){case kt:return"Fragment";case pe:return"Profiler";case jt:return"StrictMode";case at:return"Suspense";case Nt:return"SuspenseList";case Se:return"Activity"}if(typeof v=="object")switch(typeof v.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),v.$$typeof){case Ye:return"Portal";case se:return v.displayName||"Context";case ot:return(v._context.displayName||"Context")+".Consumer";case be:var ee=v.render;return v=v.displayName,v||(v=ee.displayName||ee.name||"",v=v!==""?"ForwardRef("+v+")":"ForwardRef"),v;case ct:return ee=v.displayName||null,ee!==null?ee:S(v.type)||"Memo";case ve:ee=v._payload,v=v._init;try{return S(v(ee))}catch{}}return null}function T(v){if(v===kt)return"<>";if(typeof v=="object"&&v!==null&&v.$$typeof===ve)return"<...>";try{var ee=S(v);return ee?"<"+ee+">":"<...>"}catch{return"<...>"}}function D(){var v=We.A;return v===null?null:v.getOwner()}function b(){return Error("react-stack-top-frame")}function N(v){if(sa.call(v,"key")){var ee=Object.getOwnPropertyDescriptor(v,"key").get;if(ee&&ee.isReactWarning)return!1}return v.key!==void 0}function O(v,ee){function ye(){Ma||(Ma=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",ee))}ye.isReactWarning=!0,Object.defineProperty(v,"key",{get:ye,configurable:!0})}function w(){var v=S(this.type);return on[v]||(on[v]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),v=this.props.ref,v!==void 0?v:null}function k(v,ee,ye,Fe,lt,Lt){var Tt=ye.ref;return v={$$typeof:dt,type:v,key:ee,props:ye,_owner:Fe},(Tt!==void 0?Tt:null)!==null?Object.defineProperty(v,"ref",{enumerable:!1,get:w}):Object.defineProperty(v,"ref",{enumerable:!1,value:null}),v._store={},Object.defineProperty(v._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(v,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(v,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:lt}),Object.defineProperty(v,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Lt}),Object.freeze&&(Object.freeze(v.props),Object.freeze(v)),v}function G(v,ee){return ee=k(v.type,ee,v.props,v._owner,v._debugStack,v._debugTask),v._store&&(ee._store.validated=v._store.validated),ee}function $(v){ie(v)?v._store&&(v._store.validated=1):typeof v=="object"&&v!==null&&v.$$typeof===ve&&(v._payload.status==="fulfilled"?ie(v._payload.value)&&v._payload.value._store&&(v._payload.value._store.validated=1):v._store&&(v._store.validated=1))}function ie(v){return typeof v=="object"&&v!==null&&v.$$typeof===dt}function ae(v){var ee={"=":"=0",":":"=2"};return"$"+v.replace(/[=:]/g,function(ye){return ee[ye]})}function Ne(v,ee){return typeof v=="object"&&v!==null&&v.key!=null?(E(v.key),ae(""+v.key)):ee.toString(36)}function we(v){switch(v.status){case"fulfilled":return v.value;case"rejected":throw v.reason;default:switch(typeof v.status=="string"?v.then(_,_):(v.status="pending",v.then(function(ee){v.status==="pending"&&(v.status="fulfilled",v.value=ee)},function(ee){v.status==="pending"&&(v.status="rejected",v.reason=ee)})),v.status){case"fulfilled":return v.value;case"rejected":throw v.reason}}throw v}function Ge(v,ee,ye,Fe,lt){var Lt=typeof v;(Lt==="undefined"||Lt==="boolean")&&(v=null);var Tt=!1;if(v===null)Tt=!0;else switch(Lt){case"bigint":case"string":case"number":Tt=!0;break;case"object":switch(v.$$typeof){case dt:case Ye:Tt=!0;break;case ve:return Tt=v._init,Ge(Tt(v._payload),ee,ye,Fe,lt)}}if(Tt){Tt=v,lt=lt(Tt);var $t=Fe===""?"."+Ne(Tt,0):Fe;return it(lt)?(ye="",$t!=null&&(ye=$t.replace(Cn,"$&/")+"/"),Ge(lt,ee,ye,"",function(sn){return sn})):lt!=null&&(ie(lt)&&(lt.key!=null&&(Tt&&Tt.key===lt.key||E(lt.key)),ye=G(lt,ye+(lt.key==null||Tt&&Tt.key===lt.key?"":(""+lt.key).replace(Cn,"$&/")+"/")+$t),Fe!==""&&Tt!=null&&ie(Tt)&&Tt.key==null&&Tt._store&&!Tt._store.validated&&(ye._store.validated=2),lt=ye),ee.push(lt)),1}if(Tt=0,$t=Fe===""?".":Fe+":",it(v))for(var Vt=0;Vt<v.length;Vt++)Fe=v[Vt],Lt=$t+Ne(Fe,Vt),Tt+=Ge(Fe,ee,ye,Lt,lt);else if(Vt=t(v),typeof Vt=="function")for(Vt===v.entries&&(Sn||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),Sn=!0),v=Vt.call(v),Vt=0;!(Fe=v.next()).done;)Fe=Fe.value,Lt=$t+Ne(Fe,Vt++),Tt+=Ge(Fe,ee,ye,Lt,lt);else if(Lt==="object"){if(typeof v.then=="function")return Ge(we(v),ee,ye,Fe,lt);throw ee=String(v),Error("Objects are not valid as a React child (found: "+(ee==="[object Object]"?"object with keys {"+Object.keys(v).join(", ")+"}":ee)+"). If you meant to render a collection of children, use an array instead.")}return Tt}function xe(v,ee,ye){if(v==null)return v;var Fe=[],lt=0;return Ge(v,Fe,"","",function(Lt){return ee.call(ye,Lt,lt++)}),Fe}function oe(v){if(v._status===-1){var ee=v._ioInfo;ee!=null&&(ee.start=ee.end=performance.now()),ee=v._result;var ye=ee();if(ye.then(function(lt){if(v._status===0||v._status===-1){v._status=1,v._result=lt;var Lt=v._ioInfo;Lt!=null&&(Lt.end=performance.now()),ye.status===void 0&&(ye.status="fulfilled",ye.value=lt)}},function(lt){if(v._status===0||v._status===-1){v._status=2,v._result=lt;var Lt=v._ioInfo;Lt!=null&&(Lt.end=performance.now()),ye.status===void 0&&(ye.status="rejected",ye.reason=lt)}}),ee=v._ioInfo,ee!=null){ee.value=ye;var Fe=ye.displayName;typeof Fe=="string"&&(ee.name=Fe)}v._status===-1&&(v._status=0,v._result=ye)}if(v._status===1)return ee=v._result,ee===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
5
5
|
|
|
6
6
|
Your code should look like:
|
|
7
7
|
const MyComponent = lazy(() => import('./MyComponent'))
|
|
@@ -460,7 +460,7 @@ ${J}`)):L==="feedback"&&U&&M(U)},[Te,pe]),fo=(0,tt.useCallback)(L=>{jr(!1);let U
|
|
|
460
460
|
`+F.map(j=>" "+j).join(`
|
|
461
461
|
`):"";N(j=>[...j,{role:"system",content:`\u27F2 Restored ${String(F.length)} file(s). Conversation unchanged.${J}`}]);break}case"cancel":break}},[Jn]),is=()=>{let L=on.current;L&&L.needsReload()&&(L.reload(),sI(L,sa.current,ke.current))},B=(0,tt.useRef)(!1),M=async L=>{if(B.current)return;if(B.current=!0,is(),Dx(Ct,L),Oe(F=>[...F,L]),L.startsWith("/")&&await vi(L)){B.current=!1;return}if(!Kt.current){Ye("LLM client not ready yet"),B.current=!1;return}N(F=>[...F,{role:"user",content:L}]);let U=await Fx(L,Te);Pe.current.addUserMessage(U),f0(Te,it.current,{role:"user",content:typeof U=="string"?L:[{type:"text",text:L},...U.filter(F=>F.type==="image")],timestamp:Math.floor(Date.now()/1e3)}),we.current=Date.now(),Ne(null),G(!0),w(""),Ye(null),Qe([]);try{await Bi()}catch(F){let J=xo(F);if(ks(Dv(F),"name")==="AbortError"||J.includes("abort")){let te=Ge.current;te&&N(le=>[...le,{role:"assistant",content:te+`
|
|
462
462
|
|
|
463
|
-
*[cancelled]*`}]),N(le=>[...le,{role:"system",content:"(response interrupted)"}])}else{let te=Ge.current;te&&N(le=>[...le,{role:"assistant",content:te}]),Ye(J),N(le=>[...le,{role:"system",content:`Error: ${J}`}])}}finally{let F=Math.floor((Date.now()-we.current)/1e3);Ne(`\u273B ${jv()} for ${String(F)}s`),G(!1),Qe([]),sn.current=null,B.current=!1}};return E==="providerSelect"?(0,qt.jsx)(N7,{providers:e,onSelect:Ln}):(0,qt.jsxs)(et,{flexDirection:"column",width:"100%",children:[(0,qt.jsxs)(et,{flexDirection:"column",paddingTop:0,flexGrow:1,children:[(0,qt.jsx)(Cy,{items:[{type:"brand",_key:"brand",model:T.model||T.name,workDir:Te},...b.map((L,U)=>({type:"message",_key:`message-${String(U)}`,message:L}))],children:L=>L.type==="brand"?(0,qt.jsxs)(et,{flexDirection:"column",children:[(0,qt.jsxs)(X,{children:[(0,qt.jsx)(X,{color:kd.focused,children:" /\\_/\\ "}),(0,qt.jsxs)(X,{dimColor:!0,children:["Swifty v",uC]})]}),(0,qt.jsxs)(X,{children:[(0,qt.jsx)(X,{color:kd.focused,children:"( o o ) "}),(0,qt.jsx)(X,{dimColor:!0,children:L.model})]}),(0,qt.jsxs)(X,{children:[(0,qt.jsx)(X,{color:kd.focused,children:" > < "}),(0,qt.jsx)(X,{dimColor:!0,children:L.workDir})]}),(0,qt.jsx)(X,{children:" "})]},L._key):(0,qt.jsx)(e7,{message:L.message,expanded:Di},L._key)},`transcript-${it.current}-${String(pi)}-${String(Di)}`),(0,qt.jsx)($G,{messages:[],streamingText:k?O:void 0,expanded:Di}),oe.length>0&&!pa&&Fr.length===0&&(0,qt.jsx)(PD,{tools:oe}),Fr.length>0&&!pa&&(0,qt.jsxs)(qt.Fragment,{children:[(0,qt.jsx)(PD,{tools:oe.filter(L=>!(L.toolName==="Agent"&&L.loading))}),(0,qt.jsx)(et,{flexDirection:"column",paddingLeft:1,children:Fr.map((L,U)=>{let F=oe.filter(J=>J.toolName==="Agent"&&J.loading).at(U);return(0,qt.jsxs)(et,{gap:1,children:[F&&(0,qt.jsx)(UD,{tool:F}),(0,qt.jsxs)(X,{color:"magenta",children:[nn.dot," ",L.label," subagent \xB7 turn ",L.turn,L.lastTool?` \xB7 ${L.lastTool}`:""]})]},L.id)})})]}),k&&!pa&&(0,qt.jsxs)(et,{paddingLeft:1,flexDirection:"column",children:[(0,qt.jsx)(xD,{inputTokens:At,outputTokens:Gt}),ir.length>0&&(0,qt.jsx)(LD,{teammates:ir,leaderTokens:At+Gt})]}),!k&&ir.some(L=>L.status==="running")&&(0,qt.jsx)(et,{paddingLeft:1,children:(0,qt.jsx)(LD,{teammates:ir})}),$&&!k&&!pa&&(0,qt.jsx)(et,{paddingLeft:1,children:(0,qt.jsx)(xD,{label:"Compacting conversation"})}),dt&&(0,qt.jsx)(et,{paddingLeft:1,children:(0,qt.jsx)(X,{color:"red",children:dt})}),!k&&ae&&!pa&&!br&&(0,qt.jsx)(et,{paddingLeft:1,children:(0,qt.jsx)(X,{dimColor:!0,children:ae})}),(0,qt.jsx)(X,{children:" "})]}),kt&&(0,qt.jsx)(b7,{onSelect:Er}),Ni&&(0,qt.jsx)(D7,{snapshots:Jn,onComplete:fo,onCancel:()=>{jr(!1)}}),br&&(0,qt.jsx)(I7,{toolName:br.toolName,argsSummary:br.argsSummary,reason:br.reason,onComplete:L=>{Ka.current?.(L),Ka.current=null,Ys(null)}}),pa&&(0,qt.jsx)(Lx,{questions:pa,onComplete:L=>{mr.current?.(L),mr.current=null,Zr(null)}}),di&&(0,qt.jsx)(P7,{teammates:ir,onClose:()=>{Xi(!1)},onKill:(L,U)=>{let F=St.current.get(U);F&&F.stopMember(L)},onShutdown:(L,U)=>{let F=St.current.get(U);F&&F.sendMessage("lead",L,"[shutdown] Please finish and exit")}}),_t&&(0,qt.jsx)(et,{paddingLeft:1,children:(0,qt.jsx)(X,{dimColor:!0,children:"Press Ctrl+C again to exit."})}),(0,qt.jsx)(Q7,{count:ir.filter(L=>L.status==="running"||L.status==="idle").length}),(0,qt.jsx)(y7,{onSubmit:L=>{M(L)},disabled:Ni||br!==null||pa!==null,submitDisabled:k||$,history:Se,commands:sa.current.listCommands(),usageTracker:rn.current,inputState:dt?"error":k||$||Ni||br?"idle":"focused",permMode:ge,onModeChange:L=>{ze(L)},workDir:Te,sessionId:it.current,insertTextRef:go,clearRef:ji,onEscape:()=>{k&&sn.current?.abort()}})]})}function Qle(e,t){return t?a=>e(a)&&t(a):e}var Ule="\x1B[?2026h",Ple="\x1B[?2026l";function Fle(){if(process.env.TMUX)return!1;let e=process.env.TERM_PROGRAM,t=process.env.TERM;if(e==="iTerm.app"||e==="WezTerm"||e==="WarpTerminal"||e==="ghostty"||e==="contour"||e==="vscode"||e==="alacritty"||t?.includes("kitty")||process.env.KITTY_WINDOW_ID||t==="xterm-ghostty"||t?.startsWith("foot")||t?.includes("alacritty")||process.env.ZED_TERM||process.env.WT_SESSION)return!0;let a=process.env.VTE_VERSION;return!!(a&&parseInt(a,10)>=6800)}function Y7(){if(!Fle())return;let e=process.stdout.write.bind(process.stdout),t="",a=!1;process.stdout.write=function(i,l,u){let _=typeof i=="string"?i:Buffer.isBuffer(i)?i.toString():String(i);return t+=_,a||(a=!0,queueMicrotask(()=>{let p=Ule+t+Ple;t="",a=!1,e(p)})),typeof l=="function"?l():typeof u=="function"&&u(),!0}}var q7=Ke(Ha(),1);async function Gle(){fx();let e=process.argv.slice(2),t=Cx(e);if(t){try{await yx(t)}catch(_){console.error(`teammate: ${xo(_)}`),process.exit(1)}return}let a="";for(let _=0;_<e.length;_++)e[_]==="--remote"&&(a=":18888",_+1<e.length&&!e[_+1].startsWith("-")&&(a=e[_+1],_++));let i=_x(e);if(i){try{await px(i)}catch(_){console.error(`Error: ${xo(_)}`),process.exit(1)}return}let l;try{l=vg()}catch(_){console.error(`Error: ${xo(_)}`),process.exit(1)}if(e.includes("--remote")&&a){let{RemoteServer:_}=await import("./server-
|
|
463
|
+
*[cancelled]*`}]),N(le=>[...le,{role:"system",content:"(response interrupted)"}])}else{let te=Ge.current;te&&N(le=>[...le,{role:"assistant",content:te}]),Ye(J),N(le=>[...le,{role:"system",content:`Error: ${J}`}])}}finally{let F=Math.floor((Date.now()-we.current)/1e3);Ne(`\u273B ${jv()} for ${String(F)}s`),G(!1),Qe([]),sn.current=null,B.current=!1}};return E==="providerSelect"?(0,qt.jsx)(N7,{providers:e,onSelect:Ln}):(0,qt.jsxs)(et,{flexDirection:"column",width:"100%",children:[(0,qt.jsxs)(et,{flexDirection:"column",paddingTop:0,flexGrow:1,children:[(0,qt.jsx)(Cy,{items:[{type:"brand",_key:"brand",model:T.model||T.name,workDir:Te},...b.map((L,U)=>({type:"message",_key:`message-${String(U)}`,message:L}))],children:L=>L.type==="brand"?(0,qt.jsxs)(et,{flexDirection:"column",children:[(0,qt.jsxs)(X,{children:[(0,qt.jsx)(X,{color:kd.focused,children:" /\\_/\\ "}),(0,qt.jsxs)(X,{dimColor:!0,children:["Swifty v",uC]})]}),(0,qt.jsxs)(X,{children:[(0,qt.jsx)(X,{color:kd.focused,children:"( o o ) "}),(0,qt.jsx)(X,{dimColor:!0,children:L.model})]}),(0,qt.jsxs)(X,{children:[(0,qt.jsx)(X,{color:kd.focused,children:" > < "}),(0,qt.jsx)(X,{dimColor:!0,children:L.workDir})]}),(0,qt.jsx)(X,{children:" "})]},L._key):(0,qt.jsx)(e7,{message:L.message,expanded:Di},L._key)},`transcript-${it.current}-${String(pi)}-${String(Di)}`),(0,qt.jsx)($G,{messages:[],streamingText:k?O:void 0,expanded:Di}),oe.length>0&&!pa&&Fr.length===0&&(0,qt.jsx)(PD,{tools:oe}),Fr.length>0&&!pa&&(0,qt.jsxs)(qt.Fragment,{children:[(0,qt.jsx)(PD,{tools:oe.filter(L=>!(L.toolName==="Agent"&&L.loading))}),(0,qt.jsx)(et,{flexDirection:"column",paddingLeft:1,children:Fr.map((L,U)=>{let F=oe.filter(J=>J.toolName==="Agent"&&J.loading).at(U);return(0,qt.jsxs)(et,{gap:1,children:[F&&(0,qt.jsx)(UD,{tool:F}),(0,qt.jsxs)(X,{color:"magenta",children:[nn.dot," ",L.label," subagent \xB7 turn ",L.turn,L.lastTool?` \xB7 ${L.lastTool}`:""]})]},L.id)})})]}),k&&!pa&&(0,qt.jsxs)(et,{paddingLeft:1,flexDirection:"column",children:[(0,qt.jsx)(xD,{inputTokens:At,outputTokens:Gt}),ir.length>0&&(0,qt.jsx)(LD,{teammates:ir,leaderTokens:At+Gt})]}),!k&&ir.some(L=>L.status==="running")&&(0,qt.jsx)(et,{paddingLeft:1,children:(0,qt.jsx)(LD,{teammates:ir})}),$&&!k&&!pa&&(0,qt.jsx)(et,{paddingLeft:1,children:(0,qt.jsx)(xD,{label:"Compacting conversation"})}),dt&&(0,qt.jsx)(et,{paddingLeft:1,children:(0,qt.jsx)(X,{color:"red",children:dt})}),!k&&ae&&!pa&&!br&&(0,qt.jsx)(et,{paddingLeft:1,children:(0,qt.jsx)(X,{dimColor:!0,children:ae})}),(0,qt.jsx)(X,{children:" "})]}),kt&&(0,qt.jsx)(b7,{onSelect:Er}),Ni&&(0,qt.jsx)(D7,{snapshots:Jn,onComplete:fo,onCancel:()=>{jr(!1)}}),br&&(0,qt.jsx)(I7,{toolName:br.toolName,argsSummary:br.argsSummary,reason:br.reason,onComplete:L=>{Ka.current?.(L),Ka.current=null,Ys(null)}}),pa&&(0,qt.jsx)(Lx,{questions:pa,onComplete:L=>{mr.current?.(L),mr.current=null,Zr(null)}}),di&&(0,qt.jsx)(P7,{teammates:ir,onClose:()=>{Xi(!1)},onKill:(L,U)=>{let F=St.current.get(U);F&&F.stopMember(L)},onShutdown:(L,U)=>{let F=St.current.get(U);F&&F.sendMessage("lead",L,"[shutdown] Please finish and exit")}}),_t&&(0,qt.jsx)(et,{paddingLeft:1,children:(0,qt.jsx)(X,{dimColor:!0,children:"Press Ctrl+C again to exit."})}),(0,qt.jsx)(Q7,{count:ir.filter(L=>L.status==="running"||L.status==="idle").length}),(0,qt.jsx)(y7,{onSubmit:L=>{M(L)},disabled:Ni||br!==null||pa!==null,submitDisabled:k||$,history:Se,commands:sa.current.listCommands(),usageTracker:rn.current,inputState:dt?"error":k||$||Ni||br?"idle":"focused",permMode:ge,onModeChange:L=>{ze(L)},workDir:Te,sessionId:it.current,insertTextRef:go,clearRef:ji,onEscape:()=>{k&&sn.current?.abort()}})]})}function Qle(e,t){return t?a=>e(a)&&t(a):e}var Ule="\x1B[?2026h",Ple="\x1B[?2026l";function Fle(){if(process.env.TMUX)return!1;let e=process.env.TERM_PROGRAM,t=process.env.TERM;if(e==="iTerm.app"||e==="WezTerm"||e==="WarpTerminal"||e==="ghostty"||e==="contour"||e==="vscode"||e==="alacritty"||t?.includes("kitty")||process.env.KITTY_WINDOW_ID||t==="xterm-ghostty"||t?.startsWith("foot")||t?.includes("alacritty")||process.env.ZED_TERM||process.env.WT_SESSION)return!0;let a=process.env.VTE_VERSION;return!!(a&&parseInt(a,10)>=6800)}function Y7(){if(!Fle())return;let e=process.stdout.write.bind(process.stdout),t="",a=!1;process.stdout.write=function(i,l,u){let _=typeof i=="string"?i:Buffer.isBuffer(i)?i.toString():String(i);return t+=_,a||(a=!0,queueMicrotask(()=>{let p=Ule+t+Ple;t="",a=!1,e(p)})),typeof l=="function"?l():typeof u=="function"&&u(),!0}}var q7=Ke(Ha(),1);async function Gle(){fx();let e=process.argv.slice(2),t=Cx(e);if(t){try{await yx(t)}catch(_){console.error(`teammate: ${xo(_)}`),process.exit(1)}return}let a="";for(let _=0;_<e.length;_++)e[_]==="--remote"&&(a=":18888",_+1<e.length&&!e[_+1].startsWith("-")&&(a=e[_+1],_++));let i=_x(e);if(i){try{await px(i)}catch(_){console.error(`Error: ${xo(_)}`),process.exit(1)}return}let l;try{l=vg()}catch(_){console.error(`Error: ${xo(_)}`),process.exit(1)}if(e.includes("--remote")&&a){let{RemoteServer:_}=await import("./server-QBALAEOH.js");LE({sessionId:Og(),mode:"remote",stdout:!0});let p=new _({providers:l.providers,mcpServers:l.mcp_servers,hookConfigs:l.hooks,addr:a,enableCoordinatorMode:l.enable_coordinator_mode??!1,forkDisabled:!UE(l)});try{await p.run()}catch(E){console.error(`Remote server error: ${xo(E)}`),process.exit(1)}return}LE({sessionId:Og(),mode:"tui"}),Y7(),await Xb((0,q7.jsx)(H7,{providers:l.providers,permissionMode:l.permission_mode,mcpServers:l.mcp_servers,hooks:l.hooks,sandboxConfig:l.sandbox,enableCoordinatorMode:l.enable_coordinator_mode,forkDisabled:!UE(l)}),{exitOnCtrlC:!1}).waitUntilExit()}Gle().then(()=>{aR(0)}).catch(e=>{by("main",e),QE.fatal({err:e},"main() unhandled error"),process.exit(-1)});
|
|
464
464
|
/*! Bundled license information:
|
|
465
465
|
|
|
466
466
|
react/cjs/react.production.js:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __swiftyCreateRequire } from "node:module";
|
|
3
3
|
const require = __swiftyCreateRequire(import.meta.url);
|
|
4
|
-
import{$ as Ci,A as bi,G as gi,I as ue,J as me,K as hi,L as de,M as xe,N as yi,O as wi,P as ve,Q as fe,R as be,S as ki,U as ji,W as Ei,X as qi,Y as Si,Z as Ke,_ as Ve,a as We,ba as Ti,ca as zi,d as vt,da as _i,ea as Pi,fa as Ai,ga as Ri,ha as Oi,i as ci,ia as Li,j as Ze,ja as Mi,k as Ye,ka as Fi,la as Ui,ma as Ni,na as Di,oa as Ii,p as pi,r as li,t as ui,u as mi,v as di,w as xi,x as Je,y as vi,z as fi}from"./chunk-
|
|
4
|
+
import{$ as Ci,A as bi,G as gi,I as ue,J as me,K as hi,L as de,M as xe,N as yi,O as wi,P as ve,Q as fe,R as be,S as ki,U as ji,W as Ei,X as qi,Y as Si,Z as Ke,_ as Ve,a as We,ba as Ti,ca as zi,d as vt,da as _i,ea as Pi,fa as Ai,ga as Ri,ha as Oi,i as ci,ia as Li,j as Ze,ja as Mi,k as Ye,ka as Fi,la as Ui,ma as Ni,na as Di,oa as Ii,p as pi,r as li,t as ui,u as mi,v as di,w as xi,x as Je,y as vi,z as fi}from"./chunk-CMG6CZSL.js";import{a as $e,b as Ya}from"./chunk-XBHVVB5A.js";import{b as Va}from"./chunk-3USGFIWF.js";import{a as ti,b as ri,h as J}from"./chunk-5J4WCPY4.js";import{a as M,d as Qa,e as ei,f as ce,g as Be,h as ai,i as ii,j as pe,n as ni}from"./chunk-ASZMSWK5.js";import{e as Xe,f as si,g as oi}from"./chunk-KSCFIYHH.js";import"./chunk-FZPTNGTU.js";import{e as K}from"./chunk-T74SUDUF.js";import{b as Ja,e as Ka}from"./chunk-P276SKAC.js";import"./chunk-7MHXMDYC.js";import{D as q,I as re,K as R,S as Ge}from"./chunk-ZM2V2A7B.js";import{a as le}from"./chunk-A2VR3BC4.js";import"./chunk-E55KH72M.js";import{a as x,b as l,d as xt}from"./chunk-X3UA5OZL.js";var $i=l((Ul,Hi)=>{"use strict";Hi.exports=ft;function ft(e,a){if(!Array.isArray(e))throw new TypeError("arg must be an array of [ee, events...] arrays");for(var i=[],n=0;n<e.length;n++){var s=e[n];if(!Array.isArray(s)||s.length<2)throw new TypeError("each array member must be [ee, events...]");for(var o=s[0],t=1;t<s.length;t++){var r=s[t],c=bt(r,p);o.on(r,c),i.push({ee:o,event:r,fn:c})}}function p(){m(),a.apply(null,arguments)}function m(){for(var d,f=0;f<i.length;f++)d=i[f],d.ee.removeListener(d.event,d.fn)}function u(d){a=d}return u.cancel=m,u}function bt(e,a){return function(n){for(var s=new Array(arguments.length),o=this,t=e==="error"?n:null,r=0;r<s.length;r++)s[r]=arguments[r];a(t,o,e,s)}}});var ea=l((Nl,Qe)=>{"use strict";Qe.exports=ht;Qe.exports.isFinished=Xi;var Gi=Et(),Bi=$i(),gt=typeof setImmediate=="function"?setImmediate:function(e){process.nextTick(e.bind.apply(e,arguments))};function ht(e,a){return Xi(e)!==!1?(gt(a,null,e),e):(wt(e,qt(a)),e)}function Xi(e){var a=e.socket;if(typeof e.finished=="boolean")return!!(e.finished||a&&!a.writable);if(typeof e.complete=="boolean")return!!(e.upgrade||!a||!a.readable||e.complete&&!e.readable)}function yt(e,a){var i,n,s=!1;function o(r){i.cancel(),n.cancel(),s=!0,a(r)}i=n=Bi([[e,"end","finish"]],o);function t(r){e.removeListener("socket",t),!s&&i===n&&(n=Bi([[r,"error","close"]],o))}if(e.socket){t(e.socket);return}e.on("socket",t),e.socket===void 0&&jt(e,t)}function wt(e,a){var i=e.__onFinished;(!i||!i.queue)&&(i=e.__onFinished=kt(e),yt(e,i)),i.queue.push(a)}function kt(e){function a(i){if(e.__onFinished===a&&(e.__onFinished=null),!!a.queue){var n=a.queue;a.queue=null;for(var s=0;s<n.length;s++)n[s](i,e)}}return a.queue=[],a}function jt(e,a){var i=e.assignSocket;typeof i=="function"&&(e.assignSocket=function(s){i.call(this,s),a(s)})}function Et(){try{return x("async_hooks")}catch{return{}}}function qt(e){var a;return Gi.AsyncResource&&(a=new Gi.AsyncResource(e.name||"bound-anonymous-fn")),!a||!a.runInAsyncScope?e:a.runInAsyncScope.bind(a,e,null)}});var Zi=l((Dl,Wi)=>{"use strict";Wi.exports=St;function St(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(let a of e)if(typeof a!="function")throw new TypeError("Middleware must be composed of functions!");return function(a,i){let n=-1;return s(0);function s(o){if(o<=n)return Promise.reject(new Error("next() called multiple times"));n=o;let t=e[o];if(o===e.length&&(t=i),!t)return Promise.resolve();try{return Promise.resolve(t(a,s.bind(null,o+1)))}catch(r){return Promise.reject(r)}}}}});var Yi=l((Il,Ct)=>{Ct.exports={"100":"Continue","101":"Switching Protocols","102":"Processing","103":"Early Hints","200":"OK","201":"Created","202":"Accepted","203":"Non-Authoritative Information","204":"No Content","205":"Reset Content","206":"Partial Content","207":"Multi-Status","208":"Already Reported","226":"IM Used","300":"Multiple Choices","301":"Moved Permanently","302":"Found","303":"See Other","304":"Not Modified","305":"Use Proxy","307":"Temporary Redirect","308":"Permanent Redirect","400":"Bad Request","401":"Unauthorized","402":"Payment Required","403":"Forbidden","404":"Not Found","405":"Method Not Allowed","406":"Not Acceptable","407":"Proxy Authentication Required","408":"Request Timeout","409":"Conflict","410":"Gone","411":"Length Required","412":"Precondition Failed","413":"Payload Too Large","414":"URI Too Long","415":"Unsupported Media Type","416":"Range Not Satisfiable","417":"Expectation Failed","418":"I'm a Teapot","421":"Misdirected Request","422":"Unprocessable Entity","423":"Locked","424":"Failed Dependency","425":"Too Early","426":"Upgrade Required","428":"Precondition Required","429":"Too Many Requests","431":"Request Header Fields Too Large","451":"Unavailable For Legal Reasons","500":"Internal Server Error","501":"Not Implemented","502":"Bad Gateway","503":"Service Unavailable","504":"Gateway Timeout","505":"HTTP Version Not Supported","506":"Variant Also Negotiates","507":"Insufficient Storage","508":"Loop Detected","509":"Bandwidth Limit Exceeded","510":"Not Extended","511":"Network Authentication Required"}});var V=l((Hl,Ki)=>{"use strict";var aa=Yi();Ki.exports=_;_.message=aa;_.code=Tt(aa);_.codes=zt(aa);_.redirect={300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0};_.empty={204:!0,205:!0,304:!0};_.retry={502:!0,503:!0,504:!0};function Tt(e){var a={};return Object.keys(e).forEach(function(n){var s=e[n],o=Number(n);a[s.toLowerCase()]=o}),a}function zt(e){return Object.keys(e).map(function(i){return Number(i)})}function _t(e){var a=e.toLowerCase();if(!Object.prototype.hasOwnProperty.call(_.code,a))throw new Error('invalid status message: "'+e+'"');return _.code[a]}function Ji(e){if(!Object.prototype.hasOwnProperty.call(_.message,e))throw new Error("invalid status code: "+e);return _.message[e]}function _(e){if(typeof e=="number")return Ji(e);if(typeof e!="string")throw new TypeError("code must be a number or string");var a=parseInt(e,10);return isNaN(a)?_t(e):Ji(a)}});var na=l(($l,an)=>{"use strict";var Pt=x("path").relative;an.exports=Mt;var At=process.cwd();function Qi(e,a){for(var i=e.split(/[ ,]+/),n=String(a).toLowerCase(),s=0;s<i.length;s++){var o=i[s];if(o&&(o==="*"||o.toLowerCase()===n))return!0}return!1}function Rt(e,a,i){var n=Object.getOwnPropertyDescriptor(e,a),s=n.value;return n.get=function(){return s},n.writable&&(n.set=function(t){return s=t}),delete n.value,delete n.writable,Object.defineProperty(e,a,n),n}function Ot(e){for(var a="",i=0;i<e;i++)a+=", arg"+i;return a.substr(2)}function Lt(e){var a=this.name+": "+this.namespace;this.message&&(a+=" deprecated "+this.message);for(var i=0;i<e.length;i++)a+=`
|
|
5
5
|
at `+e[i].toString();return a}function Mt(e){if(!e)throw new TypeError("argument namespace is required");var a=he(),i=$(a[1]),n=i[0];function s(o){ge.call(s,o)}return s._file=n,s._ignored=Ut(e),s._namespace=e,s._traced=Nt(e),s._warned=Object.create(null),s.function=$t,s.property=Gt,s}function Ft(e,a){var i=typeof e.listenerCount!="function"?e.listeners(a).length:e.listenerCount(a);return i>0}function Ut(e){if(process.noDeprecation)return!0;var a=process.env.NO_DEPRECATION||"";return Qi(a,e)}function Nt(e){if(process.traceDeprecation)return!0;var a=process.env.TRACE_DEPRECATION||"";return Qi(a,e)}function ge(e,a){var i=Ft(process,"deprecation");if(!(!i&&this._ignored)){var n,s,o,t,r=0,c=!1,p=he(),m=this._file;for(a?(t=a,o=$(p[1]),o.name=t.name,m=o[0]):(r=2,t=$(p[r]),o=t);r<p.length;r++)if(n=$(p[r]),s=n[0],s===m)c=!0;else if(s===this._file)m=this._file;else if(c)break;var u=n?t.join(":")+"__"+n.join(":"):void 0;if(!(u!==void 0&&u in this._warned)){this._warned[u]=!0;var d=e;if(d||(d=o===t||!o.name?Vi(t):Vi(o)),i){var f=en(this._namespace,d,p.slice(r));process.emit("deprecation",f);return}var g=process.stderr.isTTY?It:Dt,C=g.call(this,d,n,p.slice(r));process.stderr.write(C+`
|
|
6
6
|
`,"utf8")}}}function $(e){var a=e.getFileName()||"<anonymous>",i=e.getLineNumber(),n=e.getColumnNumber();e.isEval()&&(a=e.getEvalOrigin()+", "+a);var s=[a,i,n];return s.callSite=e,s.name=e.getFunctionName(),s}function Vi(e){var a=e.callSite,i=e.name;i||(i="<anonymous@"+ia(e)+">");var n=a.getThis(),s=n&&a.getTypeName();return s==="Object"&&(s=void 0),s==="Function"&&(s=n.name||s),s&&a.getMethodName()?s+"."+i:i}function Dt(e,a,i){var n=new Date().toUTCString(),s=n+" "+this._namespace+" deprecated "+e;if(this._traced){for(var o=0;o<i.length;o++)s+=`
|
|
7
7
|
at `+i[o].toString();return s}return a&&(s+=" at "+ia(a)),s}function It(e,a,i){var n="\x1B[36;1m"+this._namespace+"\x1B[22;39m \x1B[33;1mdeprecated\x1B[22;39m \x1B[0m"+e+"\x1B[39m";if(this._traced){for(var s=0;s<i.length;s++)n+=`
|