blink 1.1.35 → 1.1.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/{dist-Ceoe3h7v.js → auth-B9qq4cSL.js} +108 -65
- package/dist/cli/chat-DY4IWEHl.js +1 -0
- package/dist/cli/{chat-manager-cUXPlLU4.js → chat-manager-CIKM5Z0y.js} +1 -1
- package/dist/cli/{compute-server-BFNeHOmk.js → compute-server-qi2ObZrP.js} +1 -1
- package/dist/cli/config-jZRQMoaY.js +1 -0
- package/dist/cli/connect-CrE2QpMS.js +1 -0
- package/dist/cli/connect-CxdtUbca.js +1 -0
- package/dist/cli/{create-github-app-CaCP607a.js → create-github-app-BeSDE8GT.js} +1 -1
- package/dist/cli/{dev-DOvBAIjm.js → dev-DRc-HUQD.js} +69 -69
- package/dist/cli/{esm-BiWxO8S7.js → esm-C6nUlmX4.js} +1 -1
- package/dist/cli/{getMachineId-bsd-BfwVPdTh.js → getMachineId-bsd-B09GfpQE.js} +1 -1
- package/dist/cli/{getMachineId-bsd-BmhpEQU_.js → getMachineId-bsd-B5inCcKX.js} +1 -1
- package/dist/cli/{getMachineId-bsd-C1eeoY31.js → getMachineId-bsd-BVOanLuZ.js} +1 -1
- package/dist/cli/{getMachineId-bsd-CO9ne--Y.js → getMachineId-bsd-BXrGuboa.js} +1 -1
- package/dist/cli/getMachineId-bsd-CBL_TGNf.js +1 -0
- package/dist/cli/getMachineId-bsd-CbC9XZ_w.js +1 -0
- package/dist/cli/{getMachineId-bsd-D4uBPoNF.js → getMachineId-bsd-CrOdTUu4.js} +1 -1
- package/dist/cli/getMachineId-bsd-Cxy148LG.js +1 -0
- package/dist/cli/{getMachineId-darwin-C0EZ3sY3.js → getMachineId-darwin-BU-w-BnC.js} +1 -1
- package/dist/cli/{getMachineId-darwin-CSfD7gS4.js → getMachineId-darwin-BWTc5KWy.js} +1 -1
- package/dist/cli/{getMachineId-darwin-CgQ9n4TU.js → getMachineId-darwin-BbUfrHce.js} +1 -1
- package/dist/cli/{getMachineId-darwin-CuAzoP7O.js → getMachineId-darwin-BlZzCAQ6.js} +1 -1
- package/dist/cli/getMachineId-darwin-BmmSRa_d.js +2 -0
- package/dist/cli/{getMachineId-darwin-Cpq0Lloc.js → getMachineId-darwin-UHAuN405.js} +1 -1
- package/dist/cli/getMachineId-darwin-hJWBup80.js +2 -0
- package/dist/cli/getMachineId-darwin-rxU3ohHe.js +2 -0
- package/dist/cli/{getMachineId-linux-B1XJTHUh.js → getMachineId-linux-B4EFTMpj.js} +1 -1
- package/dist/cli/{getMachineId-linux-CRUR6LbQ.js → getMachineId-linux-CKBueRrt.js} +1 -1
- package/dist/cli/{getMachineId-linux-CVQNNGui.js → getMachineId-linux-CNhTYXGA.js} +1 -1
- package/dist/cli/{getMachineId-linux-CtdZRCaX.js → getMachineId-linux-D3K2OTZn.js} +1 -1
- package/dist/cli/getMachineId-linux-DaUV--ii.js +1 -0
- package/dist/cli/getMachineId-linux-DrZ26-WQ.js +1 -0
- package/dist/cli/getMachineId-linux-DzK7jzi5.js +1 -0
- package/dist/cli/getMachineId-linux-fpVhDYCz.js +1 -0
- package/dist/cli/{getMachineId-unsupported-B-xvzil1.js → getMachineId-unsupported-16ooXsXU.js} +1 -1
- package/dist/cli/{getMachineId-unsupported-BA3eQjiV.js → getMachineId-unsupported-72ceFIVM.js} +1 -1
- package/dist/cli/{getMachineId-unsupported-BZCOxs7n.js → getMachineId-unsupported-BKotHSFu.js} +1 -1
- package/dist/cli/{getMachineId-unsupported-BjGFauqb.js → getMachineId-unsupported-BSdFT2aC.js} +1 -1
- package/dist/cli/getMachineId-unsupported-CDM0TBdr.js +1 -0
- package/dist/cli/getMachineId-unsupported-Cw89MFW-.js +1 -0
- package/dist/cli/getMachineId-unsupported-DBSoWxG_.js +1 -0
- package/dist/cli/getMachineId-unsupported-cHJvhp02.js +1 -0
- package/dist/cli/{getMachineId-win-AW-Mv9PG.js → getMachineId-win-BAPC_wWc.js} +1 -1
- package/dist/cli/{getMachineId-win-B_2C1cwE.js → getMachineId-win-Bn_WM7bG.js} +1 -1
- package/dist/cli/{getMachineId-win-CUeKGXdr.js → getMachineId-win-Cc69o1Nq.js} +1 -1
- package/dist/cli/{getMachineId-win-BbYxddZ9.js → getMachineId-win-DR3Dm4-5.js} +1 -1
- package/dist/cli/{getMachineId-win-BkozcdSh.js → getMachineId-win-DdInvJHL.js} +1 -1
- package/dist/cli/getMachineId-win-Dig4HMmA.js +1 -0
- package/dist/cli/getMachineId-win-DwHWO0Id.js +1 -0
- package/dist/cli/getMachineId-win-gVqg_Qhn.js +1 -0
- package/dist/cli/index.js +9 -9
- package/dist/cli/{init-LtTUYXzn.js → init-CO5TBme9.js} +1 -1
- package/dist/cli/{init-templates-jGRvqLQ6.js → init-templates-Br3bKUNT.js} +3 -3
- package/dist/cli/login-C60LmqjM.js +1 -0
- package/dist/cli/logout-2bj6PyZi.js +1 -0
- package/dist/cli/pull-BGcjDkHJ.js +18 -0
- package/dist/cli/run-SQMvtzUV.js +1 -0
- package/dist/cli/setup-github-app-DOhdofIm.js +9 -0
- package/dist/cli/{token-v4NJW7VU.js → token-MaTAy4hv.js} +1 -1
- package/dist/cli/{token-util-BgEcL2NM.js → token-util-Bn01WxFK.js} +1 -1
- package/dist/cli/token-util-DbgI6oFx.js +1 -0
- package/dist/cli/undici-mM2IfLwA.js +1 -0
- package/dist/cli/{util-k3x8m_i5.js → util-DcqmsBrE.js} +1 -1
- package/dist/node/agent/index.node.cjs +1 -1
- package/dist/node/agent/index.node.d.ts +1 -1
- package/dist/node/agent/index.node.js +1 -1
- package/dist/node/build/index.cjs +1 -1
- package/dist/node/build/index.d.ts +1 -1
- package/dist/node/build/index.js +1 -1
- package/dist/node/context-Ch5QyxHM.js +1 -0
- package/dist/node/context-Cp_cUqvc.cjs +1 -0
- package/dist/node/esm-CSXsVdYr.js +1 -0
- package/dist/node/esm-DAl5TNhv.cjs +1 -0
- package/dist/node/{getMachineId-bsd-O0bNSuuh.cjs → getMachineId-bsd-C0y5EQEK.cjs} +1 -1
- package/dist/node/getMachineId-bsd-j5NqIOc8.js +1 -0
- package/dist/node/getMachineId-darwin-EKLAsCHs.js +2 -0
- package/dist/node/{getMachineId-darwin-DivkCgLG.cjs → getMachineId-darwin-QptN2GTZ.cjs} +1 -1
- package/dist/node/{getMachineId-linux-C8A0ak4z.cjs → getMachineId-linux-B7sBt1Ji.cjs} +1 -1
- package/dist/node/getMachineId-linux-BkKZQ4pT.js +1 -0
- package/dist/node/getMachineId-unsupported-C_PGk8nf.js +1 -0
- package/dist/node/{getMachineId-unsupported-DSRCXJha.cjs → getMachineId-unsupported-DwYXVQg7.cjs} +1 -1
- package/dist/node/getMachineId-win-BJspkM2m.js +1 -0
- package/dist/node/{getMachineId-win-B_okYUv6.cjs → getMachineId-win-C2mMnKyH.cjs} +1 -1
- package/dist/node/index.node-CU27y0G9.js +50 -0
- package/dist/node/index.node-DfJSk6zl.cjs +50 -0
- package/dist/node/internal/index.cjs +1 -0
- package/dist/node/internal/index.d.cts +24 -0
- package/dist/node/internal/index.d.ts +24 -0
- package/dist/node/internal/index.js +1 -0
- package/dist/node/react/index.node.cjs +110 -110
- package/dist/node/react/index.node.d.ts +2 -2
- package/dist/node/react/index.node.js +48 -48
- package/dist/node/{token-BQ-EqDMB.cjs → token-BQFROC8n.cjs} +1 -1
- package/dist/node/{token-B2MtKe6w.js → token-Qko9jH1t.js} +1 -1
- package/dist/node/token-util-BRjrHLnr.cjs +1 -0
- package/dist/node/{token-util-CtaB7NzM.js → token-util-uzFo5Esl.js} +1 -1
- package/package.json +7 -1
- package/dist/cli/auth-DbpOUCTO.js +0 -2
- package/dist/cli/chat-BfOX7Zpn.js +0 -1
- package/dist/cli/connect-3pBvxI6u.js +0 -1
- package/dist/cli/connect-XRcF_tn8.js +0 -1
- package/dist/cli/getMachineId-bsd-DVGtITCk.js +0 -1
- package/dist/cli/getMachineId-bsd-MA4oFaCa.js +0 -1
- package/dist/cli/getMachineId-bsd-dbToLPez.js +0 -1
- package/dist/cli/getMachineId-darwin-D6_tdcZj.js +0 -2
- package/dist/cli/getMachineId-darwin-DkExT2qu.js +0 -2
- package/dist/cli/getMachineId-darwin-xoAzTD7x.js +0 -2
- package/dist/cli/getMachineId-linux-DMILcDJR.js +0 -1
- package/dist/cli/getMachineId-linux-Deja7F2k.js +0 -1
- package/dist/cli/getMachineId-linux-DqOGXYgv.js +0 -1
- package/dist/cli/getMachineId-linux-FRx9q8NV.js +0 -1
- package/dist/cli/getMachineId-unsupported-CLWxRb7f.js +0 -1
- package/dist/cli/getMachineId-unsupported-CSVFDvWp.js +0 -1
- package/dist/cli/getMachineId-unsupported-Cp_95R-6.js +0 -1
- package/dist/cli/getMachineId-unsupported-Nd0_Z7NT.js +0 -1
- package/dist/cli/getMachineId-win-CPhFagnx.js +0 -1
- package/dist/cli/getMachineId-win-D3-sMfSu.js +0 -1
- package/dist/cli/getMachineId-win-DFVpvzl3.js +0 -1
- package/dist/cli/login-POW3H6LQ.js +0 -1
- package/dist/cli/run-BHKBjgkK.js +0 -1
- package/dist/cli/setup-github-app-DBiuq7cy.js +0 -9
- package/dist/cli/token-util-3NkPUSqu.js +0 -1
- package/dist/cli/undici-JD4hDNWZ.js +0 -1
- package/dist/cli/util-CUfifM0g.js +0 -5
- package/dist/node/esm-0UNjvroT.cjs +0 -1
- package/dist/node/esm-CbZfjZBn.js +0 -1
- package/dist/node/getMachineId-bsd-Ckr9jSoT.js +0 -1
- package/dist/node/getMachineId-darwin-36SFRv2R.js +0 -2
- package/dist/node/getMachineId-linux-ZoT5w75D.js +0 -1
- package/dist/node/getMachineId-unsupported-XVp8oFCM.js +0 -1
- package/dist/node/getMachineId-win-CGqZ4f4O.js +0 -1
- package/dist/node/index.node-CFR7FTuY.cjs +0 -50
- package/dist/node/index.node-CITcyk6b.js +0 -50
- package/dist/node/token-util-P8_cV3Yu.cjs +0 -1
- /package/dist/cli/{devtools-CwQnB6v7.js → devtools-CS3ukAFj.js} +0 -0
- /package/dist/cli/{execAsync-4IyNgpoN.js → execAsync-9jtK4I3l.js} +0 -0
- /package/dist/cli/{execAsync-B6xSGvuk.js → execAsync-B4_pEoEJ.js} +0 -0
- /package/dist/cli/{execAsync-B8_ZTafx.js → execAsync-BdK7RB6d.js} +0 -0
- /package/dist/cli/{execAsync-B8nelpRN.js → execAsync-Bjxs-bO2.js} +0 -0
- /package/dist/cli/{execAsync-Cj_jF8MF.js → execAsync-CM_C8SBr.js} +0 -0
- /package/dist/cli/{execAsync-Ckbi9Yqe.js → execAsync-CNFaXJjR.js} +0 -0
- /package/dist/cli/{execAsync-CvOpnFex.js → execAsync-Dl3hbWiU.js} +0 -0
- /package/dist/cli/{execAsync-DDBH3pWg.js → execAsync-qGIZ8XA8.js} +0 -0
- /package/dist/cli/{ignore-NA4V6Pjc.js → ignore-ltyKbzfl.js} +0 -0
- /package/dist/cli/{token-error-BHDo_48c.js → token-error-CGIVaIg6.js} +0 -0
- /package/dist/cli/{undici-B5tM_IT9.js → undici-BiTrd9-R.js} +0 -0
- /package/dist/cli/{usingCtx-B1FpoePI.js → usingCtx-CCxav2be.js} +0 -0
- /package/dist/cli/{utils-B3iC7vdW.js → utils-BWKsfIcI.js} +0 -0
- /package/dist/node/{build-EgdtUZTI.cjs → build-BoU84guF.cjs} +0 -0
- /package/dist/node/{build-DYI55eX2.js → build-DBcSkHHH.js} +0 -0
- /package/dist/node/{execAsync-BMxJf0Eg.cjs → execAsync-BN6E2M46.cjs} +0 -0
- /package/dist/node/{execAsync-CY8juV7n.js → execAsync-CoM0jMb2.js} +0 -0
- /package/dist/node/{index-B4OXlWm3.d.ts → index-BcKU69uH.d.ts} +0 -0
- /package/dist/node/{index.node-BbqFCkOX.d.ts → index.node-Cl9AwUCW.d.ts} +0 -0
- /package/dist/node/{token-util--zh4M6Ze.cjs → token-util-CzDIlVhL.cjs} +0 -0
- /package/dist/node/{token-util-RdQsj3MK.js → token-util-DwGWB0np.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require(`../chunk-iXuH7AlR.cjs`),t=require(`../index.node-CFR7FTuY.cjs`);require(`../token-error-BoNG8ooW.cjs`),require(`../esm-0UNjvroT.cjs`);const n=require(`../build-EgdtUZTI.cjs`);let r=require(`zod/v4`);r=e.__toESM(r);let i=require(`zod/v3`);i=e.__toESM(i);let a=require(`node:buffer`);a=e.__toESM(a);let o=require(`node:fs`);o=e.__toESM(o);let s=require(`node:url`);s=e.__toESM(s);let c=require(`node:stream`);c=e.__toESM(c);let l=require(`node:util`);l=e.__toESM(l);let u=require(`node:crypto`);u=e.__toESM(u);let d=require(`http`);d=e.__toESM(d);let f=require(`path`);f=e.__toESM(f);let p=require(`fs`);p=e.__toESM(p);let m=require(`ai`);m=e.__toESM(m);let h=require(`fs/promises`);h=e.__toESM(h);let g=require(`child_process`);g=e.__toESM(g);let _=require(`react`);_=e.__toESM(_);let v=require(`node:module`);v=e.__toESM(v);let y=require(`zod`);y=e.__toESM(y);let b=require(`node:path`);b=e.__toESM(b);let x=require(`node:process`);x=e.__toESM(x);let S=require(`node:os`);S=e.__toESM(S);let C=require(`node:tty`);C=e.__toESM(C);let w=require(`node:readline`);w=e.__toESM(w);let T=require(`node:child_process`);T=e.__toESM(T);let E=require(`node:fs/promises`);E=e.__toESM(E),require(`@blink-sdk/compute-protocol/client`);let D=require(`@blink-sdk/compute-protocol/transport`);D=e.__toESM(D);function O(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}function k(e){return Object.fromEntries([...e.headers])}function A(e=globalThis){return e.window?`runtime/browser`:e.navigator?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:e.process?.versions?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function j(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null))}function M(e,...t){let n=j(e??{}),r=new Headers(n),i=r.get(`user-agent`)||``;return r.set(`user-agent`,[i,...t].filter(Boolean).join(` `)),Object.fromEntries(r)}var N=({prefix:e,size:n=16,alphabet:r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:i=`-`}={})=>{let a=()=>{let e=r.length,t=Array(n);for(let i=0;i<n;i++)t[i]=r[Math.random()*e|0];return t.join(``)};if(e==null)return a;if(r.includes(i))throw new t.InvalidArgumentError({argument:`separator`,message:`The separator "${i}" must not be part of the alphabet "${r}".`});return()=>`${e}${i}${a()}`},P=N();function F(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var ee=[`fetch failed`,`failed to fetch`];function te({error:e,url:n,requestBodyValues:r}){if(F(e))return e;if(e instanceof TypeError&&ee.includes(e.message.toLowerCase())){let i=e.cause;if(i!=null)return new t.APICallError({message:`Cannot connect to API: ${i.message}`,cause:i,url:n,requestBodyValues:r,isRetryable:!0})}return e}var I=`3.0.10`;function ne({apiKey:e,environmentVariableName:n,apiKeyParameterName:r=`apiKey`,description:i}){if(typeof e==`string`)return e;if(e!=null)throw new t.LoadAPIKeyError({message:`${i} API key must be a string.`});if(typeof process>`u`)throw new t.LoadAPIKeyError({message:`${i} API key is missing. Pass it using the '${r}' parameter. Environment variables is not supported in this environment.`});if(e=process.env[n],e==null)throw new t.LoadAPIKeyError({message:`${i} API key is missing. Pass it using the '${r}' parameter or the ${n} environment variable.`});if(typeof e!=`string`)throw new t.LoadAPIKeyError({message:`${i} API key must be a string. The value of the ${n} environment variable is not a string.`});return e}var L=/"__proto__"\s*:/,re=/"constructor"\s*:/;function R(e){let t=JSON.parse(e);return typeof t!=`object`||!t||L.test(e)===!1&&re.test(e)===!1?t:z(t)}function z(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function B(e){let{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return R(e)}finally{Error.stackTraceLimit=t}}var ie=Symbol.for(`vercel.ai.validator`);function ae(e){return{[ie]:!0,validate:e}}function oe(e){return typeof e==`object`&&!!e&&ie in e&&e[ie]===!0&&`validate`in e}function se(e){return oe(e)?e:ce(e)}function ce(e){return ae(async n=>{let r=await e[`~standard`].validate(n);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new t.TypeValidationError({value:n,cause:r.issues})}})}async function V({value:e,schema:n}){let r=await le({value:e,schema:n});if(!r.success)throw t.TypeValidationError.wrap({value:e,cause:r.error});return r.value}async function le({value:e,schema:n}){let r=se(n);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let n=await r.validate(e);return n.success?{success:!0,value:n.value,rawValue:e}:{success:!1,error:t.TypeValidationError.wrap({value:e,cause:n.error}),rawValue:e}}catch(n){return{success:!1,error:t.TypeValidationError.wrap({value:e,cause:n}),rawValue:e}}}async function ue({text:e,schema:n}){try{let t=B(e);return n==null?t:V({value:t,schema:n})}catch(n){throw t.JSONParseError.isInstance(n)||t.TypeValidationError.isInstance(n)?n:new t.JSONParseError({text:e,cause:n})}}async function de({text:e,schema:n}){try{let t=B(e);return n==null?{success:!0,value:t,rawValue:t}:await le({value:t,schema:n})}catch(n){return{success:!1,error:t.JSONParseError.isInstance(n)?n:new t.JSONParseError({text:e,cause:n}),rawValue:void 0}}}function fe({stream:e,schema:n}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new t.EventSourceParserStream).pipeThrough(new TransformStream({async transform({data:e},t){e!==`[DONE]`&&t.enqueue(await de({text:e,schema:n}))}}))}async function pe({provider:e,providerOptions:n,schema:r}){if(n?.[e]==null)return;let i=await le({value:n[e],schema:r});if(!i.success)throw new t.InvalidArgumentError({argument:`providerOptions`,message:`invalid ${e} provider options`,cause:i.error});return i.value}var me=()=>globalThis.fetch,he=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>ge({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),ge=async({url:e,headers:n={},body:r,successfulResponseHandler:i,failedResponseHandler:a,abortSignal:o,fetch:s=me()})=>{try{let c=await s(e,{method:`POST`,headers:M(n,`ai-sdk/provider-utils/${I}`,A()),body:r.content,signal:o}),l=k(c);if(!c.ok){let n;try{n=await a({response:c,url:e,requestBodyValues:r.values})}catch(n){throw F(n)||t.APICallError.isInstance(n)?n:new t.APICallError({message:`Failed to process error response`,cause:n,statusCode:c.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw n.value}try{return await i({response:c,url:e,requestBodyValues:r.values})}catch(n){throw n instanceof Error&&(F(n)||t.APICallError.isInstance(n))?n:new t.APICallError({message:`Failed to process successful response`,cause:n,statusCode:c.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(t){throw te({error:t,url:e,requestBodyValues:r.values})}};function _e(e){return e}function ve({id:e,name:t,inputSchema:n}){return({execute:r,outputSchema:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c,...l})=>_e({type:`provider-defined`,id:e,name:t,args:l,inputSchema:n,outputSchema:i,execute:r,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c})}function ye({id:e,name:t,inputSchema:n,outputSchema:r}){return({execute:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c,...l})=>_e({type:`provider-defined`,id:e,name:t,args:l,inputSchema:n,outputSchema:r,execute:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c})}async function be(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}var H=({errorSchema:e,errorToMessage:n,isRetryable:r})=>async({response:i,url:a,requestBodyValues:o})=>{let s=await i.text(),c=k(i);if(s.trim()===``)return{responseHeaders:c,value:new t.APICallError({message:i.statusText,url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,isRetryable:r?.(i)})};try{let l=await ue({text:s,schema:e});return{responseHeaders:c,value:new t.APICallError({message:n(l),url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,data:l,isRetryable:r?.(i,l)})}}catch{return{responseHeaders:c,value:new t.APICallError({message:i.statusText,url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,isRetryable:r?.(i)})}}},xe=e=>async({response:n})=>{let r=k(n);if(n.body==null)throw new t.EmptyResponseBodyError({});return{responseHeaders:r,value:fe({stream:n.body,schema:e})}},Se=e=>async({response:n,url:r,requestBodyValues:i})=>{let a=await n.text(),o=await de({text:a,schema:e}),s=k(n);if(!o.success)throw new t.APICallError({message:`Invalid JSON response`,cause:o.error,statusCode:n.status,responseHeaders:s,responseBody:a,url:r,requestBodyValues:i});return{responseHeaders:s,value:o.value,rawValue:o.rawValue}},Ce=Symbol(`Let zodToJsonSchema decide on which parser to use`),we=Symbol.for(`vercel.ai.schema`),{btoa:Te,atob:Ee}=globalThis;function De(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return Te(t)}function Oe(e){return e instanceof Uint8Array?De(e):e}function ke(e){return e?.replace(/\/$/,``)}var Ae=`2.0.23`,je=r.z.object({type:r.z.literal(`error`),error:r.z.object({type:r.z.string(),message:r.z.string()})}),Me=H({errorSchema:je,errorToMessage:e=>e.error.message}),U=r.z.object({citations:r.z.object({enabled:r.z.boolean()}).optional(),title:r.z.string().optional(),context:r.z.string().optional()}),Ne=r.z.object({sendReasoning:r.z.boolean().optional(),thinking:r.z.object({type:r.z.union([r.z.literal(`enabled`),r.z.literal(`disabled`)]),budgetTokens:r.z.number().optional()}).optional(),disableParallelToolUse:r.z.boolean().optional(),cacheControl:r.z.object({type:r.z.literal(`ephemeral`),ttl:r.z.union([r.z.literal(`5m`),r.z.literal(`1h`)]).optional()}).optional()});function Pe(e){let t=e?.anthropic;return t?.cacheControl??t?.cache_control}var Fe=r.z.object({maxCharacters:r.z.number().optional()}),Ie=ve({id:`anthropic.text_editor_20250728`,name:`str_replace_based_edit_tool`,inputSchema:r.z.object({command:r.z.enum([`view`,`create`,`str_replace`,`insert`]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()})}),Le=(e={})=>Ie(e),Re=r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),userLocation:r.z.object({type:r.z.literal(`approximate`),city:r.z.string().optional(),region:r.z.string().optional(),country:r.z.string().optional(),timezone:r.z.string().optional()}).optional()}),ze=r.z.array(r.z.object({url:r.z.string(),title:r.z.string(),pageAge:r.z.string().nullable(),encryptedContent:r.z.string(),type:r.z.literal(`web_search_result`)})),Be=ye({id:`anthropic.web_search_20250305`,name:`web_search`,inputSchema:r.z.object({query:r.z.string()}),outputSchema:ze}),Ve=(e={})=>Be(e),He=r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),citations:r.z.object({enabled:r.z.boolean()}).optional(),maxContentTokens:r.z.number().optional()}),Ue=r.z.object({type:r.z.literal(`web_fetch_result`),url:r.z.string(),content:r.z.object({type:r.z.literal(`document`),title:r.z.string(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal(`base64`),mediaType:r.z.literal(`application/pdf`),data:r.z.string()}),r.z.object({type:r.z.literal(`text`),mediaType:r.z.literal(`text/plain`),data:r.z.string()})])}),retrievedAt:r.z.string().nullable()}),We=ye({id:`anthropic.web_fetch_20250910`,name:`web_fetch`,inputSchema:r.z.object({url:r.z.string()}),outputSchema:Ue}),Ge=(e={})=>We(e);function Ke({tools:e,toolChoice:n,disableParallelToolUse:r}){e=e?.length?e:void 0;let i=[],a=new Set;if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:i,betas:a};let o=[];for(let t of e)switch(t.type){case`function`:{let e=Pe(t.providerOptions);o.push({name:t.name,description:t.description,input_schema:t.inputSchema,cache_control:e});break}case`provider-defined`:switch(t.id){case`anthropic.code_execution_20250522`:a.add(`code-execution-2025-05-22`),o.push({type:`code_execution_20250522`,name:`code_execution`});break;case`anthropic.computer_20250124`:a.add(`computer-use-2025-01-24`),o.push({name:`computer`,type:`computer_20250124`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber});break;case`anthropic.computer_20241022`:a.add(`computer-use-2024-10-22`),o.push({name:`computer`,type:`computer_20241022`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber});break;case`anthropic.text_editor_20250124`:a.add(`computer-use-2025-01-24`),o.push({name:`str_replace_editor`,type:`text_editor_20250124`});break;case`anthropic.text_editor_20241022`:a.add(`computer-use-2024-10-22`),o.push({name:`str_replace_editor`,type:`text_editor_20241022`});break;case`anthropic.text_editor_20250429`:a.add(`computer-use-2025-01-24`),o.push({name:`str_replace_based_edit_tool`,type:`text_editor_20250429`});break;case`anthropic.text_editor_20250728`:{let e=Fe.parse(t.args);o.push({name:`str_replace_based_edit_tool`,type:`text_editor_20250728`,max_characters:e.maxCharacters});break}case`anthropic.bash_20250124`:a.add(`computer-use-2025-01-24`),o.push({name:`bash`,type:`bash_20250124`});break;case`anthropic.bash_20241022`:a.add(`computer-use-2024-10-22`),o.push({name:`bash`,type:`bash_20241022`});break;case`anthropic.web_fetch_20250910`:{a.add(`web-fetch-2025-09-10`);let e=He.parse(t.args);o.push({type:`web_fetch_20250910`,name:`web_fetch`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens});break}case`anthropic.web_search_20250305`:{let e=Re.parse(t.args);o.push({type:`web_search_20250305`,name:`web_search`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation});break}default:i.push({type:`unsupported-tool`,tool:t});break}break;default:i.push({type:`unsupported-tool`,tool:t});break}if(n==null)return{tools:o,toolChoice:r?{type:`auto`,disable_parallel_tool_use:r}:void 0,toolWarnings:i,betas:a};let s=n.type;switch(s){case`auto`:return{tools:o,toolChoice:{type:`auto`,disable_parallel_tool_use:r},toolWarnings:i,betas:a};case`required`:return{tools:o,toolChoice:{type:`any`,disable_parallel_tool_use:r},toolWarnings:i,betas:a};case`none`:return{tools:void 0,toolChoice:void 0,toolWarnings:i,betas:a};case`tool`:return{tools:o,toolChoice:{type:`tool`,name:n.toolName,disable_parallel_tool_use:r},toolWarnings:i,betas:a};default:throw new t.UnsupportedFunctionalityError({functionality:`tool choice type: ${s}`})}}var qe=r.z.object({type:r.z.literal(`code_execution_result`),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),Je=ye({id:`anthropic.code_execution_20250522`,name:`code_execution`,inputSchema:r.z.object({code:r.z.string()}),outputSchema:qe}),Ye=(e={})=>Je(e);function Xe(e){if(typeof e==`string`)return Buffer.from(e,`base64`).toString(`utf-8`);if(e instanceof Uint8Array)return new TextDecoder().decode(e);throw e instanceof URL?new t.UnsupportedFunctionalityError({functionality:`URL-based text documents are not supported for citations`}):new t.UnsupportedFunctionalityError({functionality:`unsupported data type for text documents: ${typeof e}`})}async function Ze({prompt:e,sendReasoning:n,warnings:r}){let i=new Set,a=Qe(e),o,s=[];async function c(e){return(await pe({provider:`anthropic`,providerOptions:e,schema:U}))?.citations?.enabled??!1}async function l(e){let t=await pe({provider:`anthropic`,providerOptions:e,schema:U});return{title:t?.title,context:t?.context}}for(let e=0;e<a.length;e++){let u=a[e],d=e===a.length-1,f=u.type;switch(f){case`system`:if(o!=null)throw new t.UnsupportedFunctionalityError({functionality:`Multiple system messages that are separated by user/assistant messages`});o=u.messages.map(({content:e,providerOptions:t})=>({type:`text`,text:e,cache_control:Pe(t)}));break;case`user`:{let e=[];for(let n of u.messages){let{role:r,content:a}=n;switch(r){case`user`:for(let r=0;r<a.length;r++){let o=a[r],s=r===a.length-1,u=Pe(o.providerOptions)??(s?Pe(n.providerOptions):void 0);switch(o.type){case`text`:e.push({type:`text`,text:o.text,cache_control:u});break;case`file`:if(o.mediaType.startsWith(`image/`))e.push({type:`image`,source:o.data instanceof URL?{type:`url`,url:o.data.toString()}:{type:`base64`,media_type:o.mediaType===`image/*`?`image/jpeg`:o.mediaType,data:Oe(o.data)},cache_control:u});else if(o.mediaType===`application/pdf`){i.add(`pdfs-2024-09-25`);let t=await c(o.providerOptions),n=await l(o.providerOptions);e.push({type:`document`,source:o.data instanceof URL?{type:`url`,url:o.data.toString()}:{type:`base64`,media_type:`application/pdf`,data:Oe(o.data)},title:n.title??o.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:u})}else if(o.mediaType===`text/plain`){let t=await c(o.providerOptions),n=await l(o.providerOptions);e.push({type:`document`,source:o.data instanceof URL?{type:`url`,url:o.data.toString()}:{type:`text`,media_type:`text/plain`,data:Xe(o.data)},title:n.title??o.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:u})}else throw new t.UnsupportedFunctionalityError({functionality:`media type: ${o.mediaType}`});break}}break;case`tool`:for(let r=0;r<a.length;r++){let i=a[r],o=r===a.length-1,s=Pe(i.providerOptions)??(o?Pe(n.providerOptions):void 0),c=i.output,l;switch(c.type){case`content`:l=c.value.map(e=>{switch(e.type){case`text`:return{type:`text`,text:e.text,cache_control:void 0};case`media`:if(e.mediaType.startsWith(`image/`))return{type:`image`,source:{type:`base64`,media_type:e.mediaType,data:e.data},cache_control:void 0};throw new t.UnsupportedFunctionalityError({functionality:`media type: ${e.mediaType}`})}});break;case`text`:case`error-text`:l=c.value;break;case`json`:case`error-json`:default:l=JSON.stringify(c.value);break}e.push({type:`tool_result`,tool_use_id:i.toolCallId,content:l,is_error:c.type===`error-text`||c.type===`error-json`?!0:void 0,cache_control:s})}break;default:{let e=r;throw Error(`Unsupported role: ${e}`)}}}s.push({role:`user`,content:e});break}case`assistant`:{let e=[];for(let t=0;t<u.messages.length;t++){let i=u.messages[t],a=t===u.messages.length-1,{content:o}=i;for(let t=0;t<o.length;t++){let s=o[t],c=t===o.length-1,l=Pe(s.providerOptions)??(c?Pe(i.providerOptions):void 0);switch(s.type){case`text`:e.push({type:`text`,text:d&&a&&c?s.text.trim():s.text,cache_control:l});break;case`reasoning`:if(n){let t=await pe({provider:`anthropic`,providerOptions:s.providerOptions,schema:st});t==null?r.push({type:`other`,message:`unsupported reasoning metadata`}):t.signature==null?t.redactedData==null?r.push({type:`other`,message:`unsupported reasoning metadata`}):e.push({type:`redacted_thinking`,data:t.redactedData,cache_control:l}):e.push({type:`thinking`,thinking:s.text,signature:t.signature,cache_control:l})}else r.push({type:`other`,message:`sending reasoning content is disabled for this model`});break;case`tool-call`:if(s.providerExecuted){s.toolName===`code_execution`||s.toolName===`web_fetch`||s.toolName===`web_search`?e.push({type:`server_tool_use`,id:s.toolCallId,name:s.toolName,input:s.input,cache_control:l}):r.push({type:`other`,message:`provider executed tool call for tool ${s.toolName} is not supported`});break}e.push({type:`tool_use`,id:s.toolCallId,name:s.toolName,input:s.input,cache_control:l});break;case`tool-result`:if(s.toolName===`code_execution`){let t=s.output;if(t.type!==`json`){r.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let n=qe.parse(t.value);e.push({type:`code_execution_tool_result`,tool_use_id:s.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code},cache_control:l});break}if(s.toolName===`web_fetch`){let t=s.output;if(t.type!==`json`){r.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let n=Ue.parse(t.value);e.push({type:`web_fetch_tool_result`,tool_use_id:s.toolCallId,content:{type:`web_fetch_result`,url:n.url,retrieved_at:n.retrievedAt,content:{type:`document`,title:n.content.title,citations:n.content.citations,source:{type:n.content.source.type,media_type:n.content.source.mediaType,data:n.content.source.data}}},cache_control:l});break}if(s.toolName===`web_search`){let t=s.output;if(t.type!==`json`){r.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let n=ze.parse(t.value);e.push({type:`web_search_tool_result`,tool_use_id:s.toolCallId,content:n.map(e=>({url:e.url,title:e.title,page_age:e.pageAge,encrypted_content:e.encryptedContent,type:e.type})),cache_control:l});break}r.push({type:`other`,message:`provider executed tool result for tool ${s.toolName} is not supported`});break}}}s.push({role:`assistant`,content:e});break}default:{let e=f;throw Error(`content type: ${e}`)}}}return{prompt:{system:o,messages:s},betas:i}}function Qe(e){let t=[],n;for(let r of e){let{role:e}=r;switch(e){case`system`:n?.type!==`system`&&(n={type:`system`,messages:[]},t.push(n)),n.messages.push(r);break;case`assistant`:n?.type!==`assistant`&&(n={type:`assistant`,messages:[]},t.push(n)),n.messages.push(r);break;case`user`:n?.type!==`user`&&(n={type:`user`,messages:[]},t.push(n)),n.messages.push(r);break;case`tool`:n?.type!==`user`&&(n={type:`user`,messages:[]},t.push(n)),n.messages.push(r);break;default:{let t=e;throw Error(`Unsupported role: ${t}`)}}}return t}function $e({finishReason:e,isJsonResponseFromTool:t}){switch(e){case`pause_turn`:case`end_turn`:case`stop_sequence`:return`stop`;case`refusal`:return`content-filter`;case`tool_use`:return t?`stop`:`tool-calls`;case`max_tokens`:return`length`;default:return`unknown`}}var et={webSearchResult:r.z.object({type:r.z.literal(`web_search_result_location`),cited_text:r.z.string(),url:r.z.string(),title:r.z.string(),encrypted_index:r.z.string()}),pageLocation:r.z.object({type:r.z.literal(`page_location`),cited_text:r.z.string(),document_index:r.z.number(),document_title:r.z.string().nullable(),start_page_number:r.z.number(),end_page_number:r.z.number()}),charLocation:r.z.object({type:r.z.literal(`char_location`),cited_text:r.z.string(),document_index:r.z.number(),document_title:r.z.string().nullable(),start_char_index:r.z.number(),end_char_index:r.z.number()})},tt=r.z.discriminatedUnion(`type`,[et.webSearchResult,et.pageLocation,et.charLocation]);r.z.discriminatedUnion(`type`,[et.pageLocation,et.charLocation]);function nt(e,t,n,r){if(e.type===`page_location`||e.type===`char_location`){let i=rt(e,t,n);i&&r(i)}}function rt(e,t,n){let r=t[e.document_index];if(!r)return null;let i=e.type===`page_location`?{citedText:e.cited_text,startPageNumber:e.start_page_number,endPageNumber:e.end_page_number}:{citedText:e.cited_text,startCharIndex:e.start_char_index,endCharIndex:e.end_char_index};return{type:`source`,sourceType:`document`,id:n(),mediaType:r.mediaType,title:e.document_title??r.title,filename:r.filename,providerMetadata:{anthropic:i}}}var it=class{constructor(e,t){this.specificationVersion=`v2`,this.modelId=e,this.config=t,this.generateId=t.generateId??P}supportsUrl(e){return e.protocol===`https:`}get provider(){return this.config.provider}get supportedUrls(){var e;return(e=this.config).supportedUrls?.call(e)??{}}async getArgs({prompt:e,maxOutputTokens:n=4096,temperature:r,topP:i,topK:a,frequencyPenalty:o,presencePenalty:s,stopSequences:c,responseFormat:l,seed:u,tools:d,toolChoice:f,providerOptions:p}){let m=[];o!=null&&m.push({type:`unsupported-setting`,setting:`frequencyPenalty`}),s!=null&&m.push({type:`unsupported-setting`,setting:`presencePenalty`}),u!=null&&m.push({type:`unsupported-setting`,setting:`seed`}),l?.type===`json`&&(l.schema==null?m.push({type:`unsupported-setting`,setting:`responseFormat`,details:`JSON response format requires a schema. The response format is ignored.`}):d!=null&&m.push({type:`unsupported-setting`,setting:`tools`,details:`JSON response format does not support tools. The provided tools are ignored.`}));let h=l?.type===`json`&&l.schema!=null?{type:`function`,name:`json`,description:`Respond with a JSON object.`,inputSchema:l.schema}:void 0,g=await pe({provider:`anthropic`,providerOptions:p,schema:Ne}),{prompt:_,betas:v}=await Ze({prompt:e,sendReasoning:g?.sendReasoning??!0,warnings:m}),y=g?.thinking?.type===`enabled`,b=g?.thinking?.budgetTokens,x={model:this.modelId,max_tokens:n,temperature:r,top_k:a,top_p:i,stop_sequences:c,...y&&{thinking:{type:`enabled`,budget_tokens:b}},system:_.system,messages:_.messages};if(y){if(b==null)throw new t.UnsupportedFunctionalityError({functionality:`thinking requires a budget`});x.temperature!=null&&(x.temperature=void 0,m.push({type:`unsupported-setting`,setting:`temperature`,details:`temperature is not supported when thinking is enabled`})),a!=null&&(x.top_k=void 0,m.push({type:`unsupported-setting`,setting:`topK`,details:`topK is not supported when thinking is enabled`})),i!=null&&(x.top_p=void 0,m.push({type:`unsupported-setting`,setting:`topP`,details:`topP is not supported when thinking is enabled`})),x.max_tokens=n+b}let{tools:S,toolChoice:C,toolWarnings:w,betas:T}=Ke(h==null?{tools:d??[],toolChoice:f,disableParallelToolUse:g?.disableParallelToolUse}:{tools:[h],toolChoice:{type:`tool`,toolName:h.name},disableParallelToolUse:!0});return{args:{...x,tools:S,tool_choice:C},warnings:[...m,...w],betas:new Set([...v,...T]),usesJsonResponseTool:h!=null}}async getHeaders({betas:e,headers:t}){return O(await be(this.config.headers),e.size>0?{"anthropic-beta":Array.from(e).join(`,`)}:{},t)}buildRequestUrl(e){var t;return(t=this.config).buildRequestUrl?.call(t,this.config.baseURL,e)??`${this.config.baseURL}/messages`}transformRequestBody(e){var t;return(t=this.config).transformRequestBody?.call(t,e)??e}extractCitationDocuments(e){return e.filter(e=>e.role===`user`).flatMap(e=>e.content).filter(e=>e.type!==`file`||e.mediaType!==`application/pdf`&&e.mediaType!==`text/plain`?!1:e.providerOptions?.anthropic?.citations?.enabled??!1).map(e=>{let t=e;return{title:t.filename??`Untitled Document`,filename:t.filename,mediaType:t.mediaType}})}async doGenerate(e){let{args:t,warnings:n,betas:r,usesJsonResponseTool:i}=await this.getArgs(e),a=this.extractCitationDocuments(e.prompt),{responseHeaders:o,value:s,rawValue:c}=await he({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:r,headers:e.headers}),body:this.transformRequestBody(t),failedResponseHandler:Me,successfulResponseHandler:Se(at),abortSignal:e.abortSignal,fetch:this.config.fetch}),l=[];for(let e of s.content)switch(e.type){case`text`:if(!i&&(l.push({type:`text`,text:e.text}),e.citations))for(let t of e.citations)nt(t,a,this.generateId,e=>l.push(e));break;case`thinking`:l.push({type:`reasoning`,text:e.thinking,providerMetadata:{anthropic:{signature:e.signature}}});break;case`redacted_thinking`:l.push({type:`reasoning`,text:``,providerMetadata:{anthropic:{redactedData:e.data}}});break;case`tool_use`:l.push(i?{type:`text`,text:JSON.stringify(e.input)}:{type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input)});break;case`server_tool_use`:(e.name===`web_search`||e.name===`code_execution`||e.name===`web_fetch`)&&l.push({type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0});break;case`web_fetch_tool_result`:e.content.type===`web_fetch_result`?l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_fetch`,result:{type:`web_fetch_result`,url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}},providerExecuted:!0}):e.content.type===`web_fetch_tool_result_error`&&l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_fetch`,isError:!0,result:{type:`web_fetch_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});break;case`web_search_tool_result`:if(Array.isArray(e.content)){l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_search`,result:e.content.map(e=>({url:e.url,title:e.title,pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type})),providerExecuted:!0});for(let t of e.content)l.push({type:`source`,sourceType:`url`,id:this.generateId(),url:t.url,title:t.title,providerMetadata:{anthropic:{pageAge:t.page_age??null}}})}else l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_search`,isError:!0,result:{type:`web_search_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});break;case`code_execution_tool_result`:e.content.type===`code_execution_result`?l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`code_execution`,result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code},providerExecuted:!0}):e.content.type===`code_execution_tool_result_error`&&l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`code_execution`,isError:!0,result:{type:`code_execution_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});break}return{content:l,finishReason:$e({finishReason:s.stop_reason,isJsonResponseFromTool:i}),usage:{inputTokens:s.usage.input_tokens,outputTokens:s.usage.output_tokens,totalTokens:s.usage.input_tokens+s.usage.output_tokens,cachedInputTokens:s.usage.cache_read_input_tokens??void 0},request:{body:t},response:{id:s.id??void 0,modelId:s.model??void 0,headers:o,body:c},warnings:n,providerMetadata:{anthropic:{usage:s.usage,cacheCreationInputTokens:s.usage.cache_creation_input_tokens??null,stopSequence:s.stop_sequence??null}}}}async doStream(e){let{args:t,warnings:n,betas:r,usesJsonResponseTool:i}=await this.getArgs(e),a=this.extractCitationDocuments(e.prompt),o={...t,stream:!0},{responseHeaders:s,value:c}=await he({url:this.buildRequestUrl(!0),headers:await this.getHeaders({betas:r,headers:e.headers}),body:this.transformRequestBody(o),failedResponseHandler:Me,successfulResponseHandler:xe(ot),abortSignal:e.abortSignal,fetch:this.config.fetch}),l=`unknown`,u={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},d={},f,p=null,m=null,h,g=this.generateId;return{stream:c.pipeThrough(new TransformStream({start(e){e.enqueue({type:`stream-start`,warnings:n})},transform(t,n){if(e.includeRawChunks&&n.enqueue({type:`raw`,rawValue:t.rawValue}),!t.success){n.enqueue({type:`error`,error:t.error});return}let r=t.value;switch(r.type){case`ping`:return;case`content_block_start`:{let e=r.content_block.type;switch(h=e,e){case`text`:d[r.index]={type:`text`},n.enqueue({type:`text-start`,id:String(r.index)});return;case`thinking`:d[r.index]={type:`reasoning`},n.enqueue({type:`reasoning-start`,id:String(r.index)});return;case`redacted_thinking`:d[r.index]={type:`reasoning`},n.enqueue({type:`reasoning-start`,id:String(r.index),providerMetadata:{anthropic:{redactedData:r.content_block.data}}});return;case`tool_use`:d[r.index]=i?{type:`text`}:{type:`tool-call`,toolCallId:r.content_block.id,toolName:r.content_block.name,input:``},n.enqueue(i?{type:`text-start`,id:String(r.index)}:{type:`tool-input-start`,id:r.content_block.id,toolName:r.content_block.name});return;case`server_tool_use`:(r.content_block.name===`web_fetch`||r.content_block.name===`web_search`||r.content_block.name===`code_execution`)&&(d[r.index]={type:`tool-call`,toolCallId:r.content_block.id,toolName:r.content_block.name,input:``,providerExecuted:!0},n.enqueue({type:`tool-input-start`,id:r.content_block.id,toolName:r.content_block.name,providerExecuted:!0}));return;case`web_fetch_tool_result`:{let e=r.content_block;e.content.type===`web_fetch_result`?n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_fetch`,result:{type:`web_fetch_result`,url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}}}):e.content.type===`web_fetch_tool_result_error`&&n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_fetch`,isError:!0,result:{type:`web_fetch_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});return}case`web_search_tool_result`:{let e=r.content_block;if(Array.isArray(e.content)){n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_search`,result:e.content.map(e=>({url:e.url,title:e.title,pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type})),providerExecuted:!0});for(let t of e.content)n.enqueue({type:`source`,sourceType:`url`,id:g(),url:t.url,title:t.title,providerMetadata:{anthropic:{pageAge:t.page_age??null}}})}else n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_search`,isError:!0,result:{type:`web_search_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});return}case`code_execution_tool_result`:{let e=r.content_block;e.content.type===`code_execution_result`?n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`code_execution`,result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code},providerExecuted:!0}):e.content.type===`code_execution_tool_result_error`&&n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`code_execution`,isError:!0,result:{type:`code_execution_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});return}default:{let t=e;throw Error(`Unsupported content block type: ${t}`)}}}case`content_block_stop`:if(d[r.index]!=null){let e=d[r.index];switch(e.type){case`text`:n.enqueue({type:`text-end`,id:String(r.index)});break;case`reasoning`:n.enqueue({type:`reasoning-end`,id:String(r.index)});break;case`tool-call`:i||(n.enqueue({type:`tool-input-end`,id:e.toolCallId}),n.enqueue(e));break}delete d[r.index]}h=void 0;return;case`content_block_delta`:{let e=r.delta.type;switch(e){case`text_delta`:if(i)return;n.enqueue({type:`text-delta`,id:String(r.index),delta:r.delta.text});return;case`thinking_delta`:n.enqueue({type:`reasoning-delta`,id:String(r.index),delta:r.delta.thinking});return;case`signature_delta`:h===`thinking`&&n.enqueue({type:`reasoning-delta`,id:String(r.index),delta:``,providerMetadata:{anthropic:{signature:r.delta.signature}}});return;case`input_json_delta`:{let e=d[r.index],t=r.delta.partial_json;if(i){if(e?.type!==`text`)return;n.enqueue({type:`text-delta`,id:String(r.index),delta:t})}else{if(e?.type!==`tool-call`)return;n.enqueue({type:`tool-input-delta`,id:e.toolCallId,delta:t}),e.input+=t}return}case`citations_delta`:{let e=r.delta.citation;nt(e,a,g,e=>n.enqueue(e));return}default:{let t=e;throw Error(`Unsupported delta type: ${t}`)}}}case`message_start`:u.inputTokens=r.message.usage.input_tokens,u.cachedInputTokens=r.message.usage.cache_read_input_tokens??void 0,f={...r.message.usage},p=r.message.usage.cache_creation_input_tokens??null,n.enqueue({type:`response-metadata`,id:r.message.id??void 0,modelId:r.message.model??void 0});return;case`message_delta`:u.outputTokens=r.usage.output_tokens,u.totalTokens=(u.inputTokens??0)+(r.usage.output_tokens??0),l=$e({finishReason:r.delta.stop_reason,isJsonResponseFromTool:i}),m=r.delta.stop_sequence??null,f={...f,...r.usage};return;case`message_stop`:n.enqueue({type:`finish`,finishReason:l,usage:u,providerMetadata:{anthropic:{usage:f??null,cacheCreationInputTokens:p,stopSequence:m}}});return;case`error`:n.enqueue({type:`error`,error:r.error});return;default:{let e=r;throw Error(`Unsupported chunk type: ${e}`)}}}})),request:{body:o},response:{headers:s}}}},at=r.z.object({type:r.z.literal(`message`),id:r.z.string().nullish(),model:r.z.string().nullish(),content:r.z.array(r.z.discriminatedUnion(`type`,[r.z.object({type:r.z.literal(`text`),text:r.z.string(),citations:r.z.array(tt).optional()}),r.z.object({type:r.z.literal(`thinking`),thinking:r.z.string(),signature:r.z.string()}),r.z.object({type:r.z.literal(`redacted_thinking`),data:r.z.string()}),r.z.object({type:r.z.literal(`tool_use`),id:r.z.string(),name:r.z.string(),input:r.z.unknown()}),r.z.object({type:r.z.literal(`server_tool_use`),id:r.z.string(),name:r.z.string(),input:r.z.record(r.z.string(),r.z.unknown()).nullish()}),r.z.object({type:r.z.literal(`web_fetch_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal(`web_fetch_result`),url:r.z.string(),retrieved_at:r.z.string(),content:r.z.object({type:r.z.literal(`document`),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.object({type:r.z.literal(`text`),media_type:r.z.string(),data:r.z.string()})})}),r.z.object({type:r.z.literal(`web_fetch_tool_result_error`),error_code:r.z.string()})])}),r.z.object({type:r.z.literal(`web_search_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.array(r.z.object({type:r.z.literal(`web_search_result`),url:r.z.string(),title:r.z.string(),encrypted_content:r.z.string(),page_age:r.z.string().nullish()})),r.z.object({type:r.z.literal(`web_search_tool_result_error`),error_code:r.z.string()})])}),r.z.object({type:r.z.literal(`code_execution_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal(`code_execution_result`),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal(`code_execution_tool_result_error`),error_code:r.z.string()})])})])),stop_reason:r.z.string().nullish(),stop_sequence:r.z.string().nullish(),usage:r.z.looseObject({input_tokens:r.z.number(),output_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish()})}),ot=r.z.discriminatedUnion(`type`,[r.z.object({type:r.z.literal(`message_start`),message:r.z.object({id:r.z.string().nullish(),model:r.z.string().nullish(),usage:r.z.looseObject({input_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish()})})}),r.z.object({type:r.z.literal(`content_block_start`),index:r.z.number(),content_block:r.z.discriminatedUnion(`type`,[r.z.object({type:r.z.literal(`text`),text:r.z.string()}),r.z.object({type:r.z.literal(`thinking`),thinking:r.z.string()}),r.z.object({type:r.z.literal(`tool_use`),id:r.z.string(),name:r.z.string()}),r.z.object({type:r.z.literal(`redacted_thinking`),data:r.z.string()}),r.z.object({type:r.z.literal(`server_tool_use`),id:r.z.string(),name:r.z.string(),input:r.z.record(r.z.string(),r.z.unknown()).nullish()}),r.z.object({type:r.z.literal(`web_fetch_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal(`web_fetch_result`),url:r.z.string(),retrieved_at:r.z.string(),content:r.z.object({type:r.z.literal(`document`),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.object({type:r.z.literal(`text`),media_type:r.z.string(),data:r.z.string()})})}),r.z.object({type:r.z.literal(`web_fetch_tool_result_error`),error_code:r.z.string()})])}),r.z.object({type:r.z.literal(`web_search_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.array(r.z.object({type:r.z.literal(`web_search_result`),url:r.z.string(),title:r.z.string(),encrypted_content:r.z.string(),page_age:r.z.string().nullish()})),r.z.object({type:r.z.literal(`web_search_tool_result_error`),error_code:r.z.string()})])}),r.z.object({type:r.z.literal(`code_execution_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal(`code_execution_result`),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal(`code_execution_tool_result_error`),error_code:r.z.string()})])})])}),r.z.object({type:r.z.literal(`content_block_delta`),index:r.z.number(),delta:r.z.discriminatedUnion(`type`,[r.z.object({type:r.z.literal(`input_json_delta`),partial_json:r.z.string()}),r.z.object({type:r.z.literal(`text_delta`),text:r.z.string()}),r.z.object({type:r.z.literal(`thinking_delta`),thinking:r.z.string()}),r.z.object({type:r.z.literal(`signature_delta`),signature:r.z.string()}),r.z.object({type:r.z.literal(`citations_delta`),citation:tt})])}),r.z.object({type:r.z.literal(`content_block_stop`),index:r.z.number()}),r.z.object({type:r.z.literal(`error`),error:r.z.object({type:r.z.string(),message:r.z.string()})}),r.z.object({type:r.z.literal(`message_delta`),delta:r.z.object({stop_reason:r.z.string().nullish(),stop_sequence:r.z.string().nullish()}),usage:r.z.looseObject({output_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish()})}),r.z.object({type:r.z.literal(`message_stop`)}),r.z.object({type:r.z.literal(`ping`)})]),st=r.z.object({signature:r.z.string().optional(),redactedData:r.z.string().optional()}),ct=ve({id:`anthropic.bash_20241022`,name:`bash`,inputSchema:r.default.object({command:r.default.string(),restart:r.default.boolean().optional()})}),lt=ve({id:`anthropic.bash_20250124`,name:`bash`,inputSchema:r.default.object({command:r.default.string(),restart:r.default.boolean().optional()})}),ut=ve({id:`anthropic.computer_20241022`,name:`computer`,inputSchema:r.z.object({action:r.z.enum([`key`,`type`,`mouse_move`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`screenshot`,`cursor_position`]),coordinate:r.z.array(r.z.number().int()).optional(),text:r.z.string().optional()})}),dt=ve({id:`anthropic.computer_20250124`,name:`computer`,inputSchema:r.z.object({action:r.z.enum([`key`,`hold_key`,`type`,`cursor_position`,`mouse_move`,`left_mouse_down`,`left_mouse_up`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`wait`,`screenshot`]),coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),duration:r.z.number().optional(),scroll_amount:r.z.number().optional(),scroll_direction:r.z.enum([`up`,`down`,`left`,`right`]).optional(),start_coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),text:r.z.string().optional()})}),ft=ve({id:`anthropic.text_editor_20241022`,name:`str_replace_editor`,inputSchema:r.z.object({command:r.z.enum([`view`,`create`,`str_replace`,`insert`,`undo_edit`]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()})}),pt=ve({id:`anthropic.text_editor_20250124`,name:`str_replace_editor`,inputSchema:r.z.object({command:r.z.enum([`view`,`create`,`str_replace`,`insert`,`undo_edit`]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()})}),mt=ve({id:`anthropic.text_editor_20250429`,name:`str_replace_based_edit_tool`,inputSchema:r.z.object({command:r.z.enum([`view`,`create`,`str_replace`,`insert`]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()})}),ht={bash_20241022:ct,bash_20250124:lt,codeExecution_20250522:Ye,computer_20241022:ut,computer_20250124:dt,textEditor_20241022:ft,textEditor_20250124:pt,textEditor_20250429:mt,textEditor_20250728:Le,webFetch_20250910:Ge,webSearch_20250305:Ve};function gt(e={}){let n=ke(e.baseURL)??`https://api.anthropic.com/v1`,r=()=>M({"anthropic-version":`2023-06-01`,"x-api-key":ne({apiKey:e.apiKey,environmentVariableName:`ANTHROPIC_API_KEY`,description:`Anthropic`}),...e.headers},`ai-sdk/anthropic/${Ae}`),i=t=>new it(t,{provider:`anthropic.messages`,baseURL:n,headers:r,fetch:e.fetch,generateId:e.generateId??P,supportedUrls:()=>({"image/*":[/^https?:\/\/.*$/]})}),a=function(e){if(new.target)throw Error(`The Anthropic model function cannot be called with the new keyword.`);return i(e)};return a.languageModel=i,a.chat=i,a.messages=i,a.textEmbeddingModel=e=>{throw new t.NoSuchModelError({modelId:e,modelType:`textEmbeddingModel`})},a.imageModel=e=>{throw new t.NoSuchModelError({modelId:e,modelType:`imageModel`})},a.tools=ht,a}var _t=gt();function vt(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}function yt(e){return Object.fromEntries([...e.headers])}function bt(e=globalThis){return e.window?`runtime/browser`:e.navigator?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:e.process?.versions?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function xt(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null))}function St(e,...t){let n=xt(e??{}),r=new Headers(n),i=r.get(`user-agent`)||``;return r.set(`user-agent`,[i,...t].filter(Boolean).join(` `)),Object.fromEntries(r)}var Ct=({prefix:e,size:n=16,alphabet:r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:i=`-`}={})=>{let a=()=>{let e=r.length,t=Array(n);for(let i=0;i<n;i++)t[i]=r[Math.random()*e|0];return t.join(``)};if(e==null)return a;if(r.includes(i))throw new t.InvalidArgumentError({argument:`separator`,message:`The separator "${i}" must not be part of the alphabet "${r}".`});return()=>`${e}${i}${a()}`},wt=Ct();function Tt(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var Et=[`fetch failed`,`failed to fetch`];function Dt({error:e,url:n,requestBodyValues:r}){if(Tt(e))return e;if(e instanceof TypeError&&Et.includes(e.message.toLowerCase())){let i=e.cause;if(i!=null)return new t.APICallError({message:`Cannot connect to API: ${i.message}`,cause:i,url:n,requestBodyValues:r,isRetryable:!0})}return e}var Ot=`3.0.10`;function kt({apiKey:e,environmentVariableName:n,apiKeyParameterName:r=`apiKey`,description:i}){if(typeof e==`string`)return e;if(e!=null)throw new t.LoadAPIKeyError({message:`${i} API key must be a string.`});if(typeof process>`u`)throw new t.LoadAPIKeyError({message:`${i} API key is missing. Pass it using the '${r}' parameter. Environment variables is not supported in this environment.`});if(e=process.env[n],e==null)throw new t.LoadAPIKeyError({message:`${i} API key is missing. Pass it using the '${r}' parameter or the ${n} environment variable.`});if(typeof e!=`string`)throw new t.LoadAPIKeyError({message:`${i} API key must be a string. The value of the ${n} environment variable is not a string.`});return e}var At=/"__proto__"\s*:/,jt=/"constructor"\s*:/;function Mt(e){let t=JSON.parse(e);return typeof t!=`object`||!t||At.test(e)===!1&&jt.test(e)===!1?t:Nt(t)}function Nt(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function Pt(e){let{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return Mt(e)}finally{Error.stackTraceLimit=t}}var Ft=Symbol.for(`vercel.ai.validator`);function It(e){return{[Ft]:!0,validate:e}}function Lt(e){return typeof e==`object`&&!!e&&Ft in e&&e[Ft]===!0&&`validate`in e}function Rt(e){return Lt(e)?e:zt(e)}function zt(e){return It(async n=>{let r=await e[`~standard`].validate(n);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new t.TypeValidationError({value:n,cause:r.issues})}})}async function Bt({value:e,schema:n}){let r=await Vt({value:e,schema:n});if(!r.success)throw t.TypeValidationError.wrap({value:e,cause:r.error});return r.value}async function Vt({value:e,schema:n}){let r=Rt(n);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let n=await r.validate(e);return n.success?{success:!0,value:n.value,rawValue:e}:{success:!1,error:t.TypeValidationError.wrap({value:e,cause:n.error}),rawValue:e}}catch(n){return{success:!1,error:t.TypeValidationError.wrap({value:e,cause:n}),rawValue:e}}}async function Ht({text:e,schema:n}){try{let t=Pt(e);return n==null?t:Bt({value:t,schema:n})}catch(n){throw t.JSONParseError.isInstance(n)||t.TypeValidationError.isInstance(n)?n:new t.JSONParseError({text:e,cause:n})}}async function Ut({text:e,schema:n}){try{let t=Pt(e);return n==null?{success:!0,value:t,rawValue:t}:await Vt({value:t,schema:n})}catch(n){return{success:!1,error:t.JSONParseError.isInstance(n)?n:new t.JSONParseError({text:e,cause:n}),rawValue:void 0}}}function Wt({stream:e,schema:n}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new t.EventSourceParserStream).pipeThrough(new TransformStream({async transform({data:e},t){e!==`[DONE]`&&t.enqueue(await Ut({text:e,schema:n}))}}))}async function Gt({provider:e,providerOptions:n,schema:r}){if(n?.[e]==null)return;let i=await Vt({value:n[e],schema:r});if(!i.success)throw new t.InvalidArgumentError({argument:`providerOptions`,message:`invalid ${e} provider options`,cause:i.error});return i.value}var Kt=()=>globalThis.fetch,qt=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>Jt({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),Jt=async({url:e,headers:n={},body:r,successfulResponseHandler:i,failedResponseHandler:a,abortSignal:o,fetch:s=Kt()})=>{try{let c=await s(e,{method:`POST`,headers:St(n,`ai-sdk/provider-utils/${Ot}`,bt()),body:r.content,signal:o}),l=yt(c);if(!c.ok){let n;try{n=await a({response:c,url:e,requestBodyValues:r.values})}catch(n){throw Tt(n)||t.APICallError.isInstance(n)?n:new t.APICallError({message:`Failed to process error response`,cause:n,statusCode:c.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw n.value}try{return await i({response:c,url:e,requestBodyValues:r.values})}catch(n){throw n instanceof Error&&(Tt(n)||t.APICallError.isInstance(n))?n:new t.APICallError({message:`Failed to process successful response`,cause:n,statusCode:c.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(t){throw Dt({error:t,url:e,requestBodyValues:r.values})}};function Yt(e){return e}function Xt({id:e,name:t,inputSchema:n}){return({execute:r,outputSchema:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c,...l})=>Yt({type:`provider-defined`,id:e,name:t,args:l,inputSchema:n,outputSchema:i,execute:r,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c})}function Zt({id:e,name:t,inputSchema:n,outputSchema:r}){return({execute:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c,...l})=>Yt({type:`provider-defined`,id:e,name:t,args:l,inputSchema:n,outputSchema:r,execute:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c})}async function Qt(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}var $t=({errorSchema:e,errorToMessage:n,isRetryable:r})=>async({response:i,url:a,requestBodyValues:o})=>{let s=await i.text(),c=yt(i);if(s.trim()===``)return{responseHeaders:c,value:new t.APICallError({message:i.statusText,url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,isRetryable:r?.(i)})};try{let l=await Ht({text:s,schema:e});return{responseHeaders:c,value:new t.APICallError({message:n(l),url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,data:l,isRetryable:r?.(i,l)})}}catch{return{responseHeaders:c,value:new t.APICallError({message:i.statusText,url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,isRetryable:r?.(i)})}}},en=e=>async({response:n})=>{let r=yt(n);if(n.body==null)throw new t.EmptyResponseBodyError({});return{responseHeaders:r,value:Wt({stream:n.body,schema:e})}},tn=e=>async({response:n,url:r,requestBodyValues:i})=>{let a=await n.text(),o=await Ut({text:a,schema:e}),s=yt(n);if(!o.success)throw new t.APICallError({message:`Invalid JSON response`,cause:o.error,statusCode:n.status,responseHeaders:s,responseBody:a,url:r,requestBodyValues:i});return{responseHeaders:s,value:o.value,rawValue:o.rawValue}},nn=Symbol(`Let zodToJsonSchema decide on which parser to use`),rn=Symbol.for(`vercel.ai.schema`),{btoa:an,atob:on}=globalThis;function sn(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return an(t)}function cn(e){return e instanceof Uint8Array?sn(e):e}function ln(e){return e?.replace(/\/$/,``)}var un=`2.0.17`,dn=r.z.object({error:r.z.object({code:r.z.number().nullable(),message:r.z.string(),status:r.z.string()})}),fn=$t({errorSchema:dn,errorToMessage:e=>e.error.message}),pn=r.z.object({outputDimensionality:r.z.number().optional(),taskType:r.z.enum([`SEMANTIC_SIMILARITY`,`CLASSIFICATION`,`CLUSTERING`,`RETRIEVAL_DOCUMENT`,`RETRIEVAL_QUERY`,`QUESTION_ANSWERING`,`FACT_VERIFICATION`,`CODE_RETRIEVAL_QUERY`]).optional()}),mn=class{constructor(e,t){this.specificationVersion=`v2`,this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0,this.modelId=e,this.config=t}get provider(){return this.config.provider}async doEmbed({values:e,headers:n,abortSignal:r,providerOptions:i}){let a=await Gt({provider:`google`,providerOptions:i,schema:pn});if(e.length>this.maxEmbeddingsPerCall)throw new t.TooManyEmbeddingValuesForCallError({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:e});let o=vt(await Qt(this.config.headers),n);if(e.length===1){let{responseHeaders:t,value:n,rawValue:i}=await qt({url:`${this.config.baseURL}/models/${this.modelId}:embedContent`,headers:o,body:{model:`models/${this.modelId}`,content:{parts:[{text:e[0]}]},outputDimensionality:a?.outputDimensionality,taskType:a?.taskType},failedResponseHandler:fn,successfulResponseHandler:tn(gn),abortSignal:r,fetch:this.config.fetch});return{embeddings:[n.embedding.values],usage:void 0,response:{headers:t,body:i}}}let{responseHeaders:s,value:c,rawValue:l}=await qt({url:`${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,headers:o,body:{requests:e.map(e=>({model:`models/${this.modelId}`,content:{role:`user`,parts:[{text:e}]},outputDimensionality:a?.outputDimensionality,taskType:a?.taskType}))},failedResponseHandler:fn,successfulResponseHandler:tn(hn),abortSignal:r,fetch:this.config.fetch});return{embeddings:c.embeddings.map(e=>e.values),usage:void 0,response:{headers:s,body:l}}}},hn=r.z.object({embeddings:r.z.array(r.z.object({values:r.z.array(r.z.number())}))}),gn=r.z.object({embedding:r.z.object({values:r.z.array(r.z.number())})});function _n(e){if(e==null||vn(e))return;if(typeof e==`boolean`)return{type:`boolean`,properties:{}};let{type:t,description:n,required:r,properties:i,items:a,allOf:o,anyOf:s,oneOf:c,format:l,const:u,minLength:d,enum:f}=e,p={};if(n&&(p.description=n),r&&(p.required=r),l&&(p.format=l),u!==void 0&&(p.enum=[u]),t&&(Array.isArray(t)?t.includes(`null`)?(p.type=t.filter(e=>e!==`null`)[0],p.nullable=!0):p.type=t:t===`null`?p.type=`null`:p.type=t),f!==void 0&&(p.enum=f),i!=null&&(p.properties=Object.entries(i).reduce((e,[t,n])=>(e[t]=_n(n),e),{})),a&&(p.items=Array.isArray(a)?a.map(_n):_n(a)),o&&(p.allOf=o.map(_n)),s)if(s.some(e=>typeof e==`object`&&e?.type===`null`)){let e=s.filter(e=>!(typeof e==`object`&&e?.type===`null`));if(e.length===1){let t=_n(e[0]);typeof t==`object`&&(p.nullable=!0,Object.assign(p,t))}else p.anyOf=e.map(_n),p.nullable=!0}else p.anyOf=s.map(_n);return c&&(p.oneOf=c.map(_n)),d!==void 0&&(p.minLength=d),p}function vn(e){return typeof e==`object`&&!!e&&e.type===`object`&&(e.properties==null||Object.keys(e.properties).length===0)&&!e.additionalProperties}function yn(e,n){let r=[],i=[],a=!0,o=n?.isGemmaModel??!1;for(let{role:n,content:o}of e)switch(n){case`system`:if(!a)throw new t.UnsupportedFunctionalityError({functionality:`system messages are only supported at the beginning of the conversation`});r.push({text:o});break;case`user`:{a=!1;let e=[];for(let t of o)switch(t.type){case`text`:e.push({text:t.text});break;case`file`:{let n=t.mediaType===`image/*`?`image/jpeg`:t.mediaType;e.push(t.data instanceof URL?{fileData:{mimeType:n,fileUri:t.data.toString()}}:{inlineData:{mimeType:n,data:cn(t.data)}});break}}i.push({role:`user`,parts:e});break}case`assistant`:a=!1,i.push({role:`model`,parts:o.map(e=>{switch(e.type){case`text`:return e.text.length===0?void 0:{text:e.text,thoughtSignature:e.providerOptions?.google?.thoughtSignature};case`reasoning`:return e.text.length===0?void 0:{text:e.text,thought:!0,thoughtSignature:e.providerOptions?.google?.thoughtSignature};case`file`:if(e.mediaType!==`image/png`)throw new t.UnsupportedFunctionalityError({functionality:`Only PNG images are supported in assistant messages`});if(e.data instanceof URL)throw new t.UnsupportedFunctionalityError({functionality:`File data URLs in assistant messages are not supported`});return{inlineData:{mimeType:e.mediaType,data:cn(e.data)}};case`tool-call`:return{functionCall:{name:e.toolName,args:e.input},thoughtSignature:e.providerOptions?.google?.thoughtSignature}}}).filter(e=>e!==void 0)});break;case`tool`:{a=!1;let e=[];for(let t of o){let n=t.output;if(n.type===`content`)for(let r of n.value)switch(r.type){case`text`:e.push({functionResponse:{name:t.toolName,response:{name:t.toolName,content:r.text}}});break;case`media`:e.push({inlineData:{mimeType:r.mediaType,data:r.data}},{text:`Tool executed successfully and returned this image as a response`});break;default:e.push({text:JSON.stringify(r)});break}else e.push({functionResponse:{name:t.toolName,response:{name:t.toolName,content:n.value}}})}i.push({role:`user`,parts:e});break}}if(o&&r.length>0&&i.length>0&&i[0].role===`user`){let e=r.map(e=>e.text).join(`
|
|
1
|
+
const e=require(`../chunk-iXuH7AlR.cjs`),t=require(`../index.node-DfJSk6zl.cjs`);require(`../token-error-BoNG8ooW.cjs`),require(`../esm-DAl5TNhv.cjs`),require(`../context-Cp_cUqvc.cjs`);const n=require(`../build-BoU84guF.cjs`);let r=require(`zod/v4`);r=e.__toESM(r);let i=require(`zod/v3`);i=e.__toESM(i);let a=require(`node:buffer`);a=e.__toESM(a);let o=require(`node:fs`);o=e.__toESM(o);let s=require(`node:url`);s=e.__toESM(s);let c=require(`node:stream`);c=e.__toESM(c);let l=require(`node:util`);l=e.__toESM(l);let u=require(`node:crypto`);u=e.__toESM(u);let d=require(`http`);d=e.__toESM(d);let f=require(`path`);f=e.__toESM(f);let p=require(`fs`);p=e.__toESM(p);let m=require(`ai`);m=e.__toESM(m);let h=require(`fs/promises`);h=e.__toESM(h);let g=require(`child_process`);g=e.__toESM(g);let _=require(`react`);_=e.__toESM(_);let v=require(`node:module`);v=e.__toESM(v);let y=require(`zod`);y=e.__toESM(y);let b=require(`node:path`);b=e.__toESM(b);let x=require(`node:process`);x=e.__toESM(x);let S=require(`node:readline`);S=e.__toESM(S);let C=require(`node:os`);C=e.__toESM(C);let w=require(`node:tty`);w=e.__toESM(w);let T=require(`node:child_process`);T=e.__toESM(T);let E=require(`node:fs/promises`);E=e.__toESM(E),require(`@blink-sdk/compute-protocol/client`);let D=require(`@blink-sdk/compute-protocol/transport`);D=e.__toESM(D);function O(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}function k(e){return Object.fromEntries([...e.headers])}function A(e=globalThis){return e.window?`runtime/browser`:e.navigator?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:e.process?.versions?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function j(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null))}function M(e,...t){let n=j(e??{}),r=new Headers(n),i=r.get(`user-agent`)||``;return r.set(`user-agent`,[i,...t].filter(Boolean).join(` `)),Object.fromEntries(r)}var N=({prefix:e,size:n=16,alphabet:r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:i=`-`}={})=>{let a=()=>{let e=r.length,t=Array(n);for(let i=0;i<n;i++)t[i]=r[Math.random()*e|0];return t.join(``)};if(e==null)return a;if(r.includes(i))throw new t.InvalidArgumentError({argument:`separator`,message:`The separator "${i}" must not be part of the alphabet "${r}".`});return()=>`${e}${i}${a()}`},P=N();function F(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var ee=[`fetch failed`,`failed to fetch`];function te({error:e,url:n,requestBodyValues:r}){if(F(e))return e;if(e instanceof TypeError&&ee.includes(e.message.toLowerCase())){let i=e.cause;if(i!=null)return new t.APICallError({message:`Cannot connect to API: ${i.message}`,cause:i,url:n,requestBodyValues:r,isRetryable:!0})}return e}var I=`3.0.10`;function ne({apiKey:e,environmentVariableName:n,apiKeyParameterName:r=`apiKey`,description:i}){if(typeof e==`string`)return e;if(e!=null)throw new t.LoadAPIKeyError({message:`${i} API key must be a string.`});if(typeof process>`u`)throw new t.LoadAPIKeyError({message:`${i} API key is missing. Pass it using the '${r}' parameter. Environment variables is not supported in this environment.`});if(e=process.env[n],e==null)throw new t.LoadAPIKeyError({message:`${i} API key is missing. Pass it using the '${r}' parameter or the ${n} environment variable.`});if(typeof e!=`string`)throw new t.LoadAPIKeyError({message:`${i} API key must be a string. The value of the ${n} environment variable is not a string.`});return e}var L=/"__proto__"\s*:/,re=/"constructor"\s*:/;function R(e){let t=JSON.parse(e);return typeof t!=`object`||!t||L.test(e)===!1&&re.test(e)===!1?t:z(t)}function z(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function B(e){let{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return R(e)}finally{Error.stackTraceLimit=t}}var ie=Symbol.for(`vercel.ai.validator`);function ae(e){return{[ie]:!0,validate:e}}function oe(e){return typeof e==`object`&&!!e&&ie in e&&e[ie]===!0&&`validate`in e}function se(e){return oe(e)?e:ce(e)}function ce(e){return ae(async n=>{let r=await e[`~standard`].validate(n);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new t.TypeValidationError({value:n,cause:r.issues})}})}async function V({value:e,schema:n}){let r=await le({value:e,schema:n});if(!r.success)throw t.TypeValidationError.wrap({value:e,cause:r.error});return r.value}async function le({value:e,schema:n}){let r=se(n);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let n=await r.validate(e);return n.success?{success:!0,value:n.value,rawValue:e}:{success:!1,error:t.TypeValidationError.wrap({value:e,cause:n.error}),rawValue:e}}catch(n){return{success:!1,error:t.TypeValidationError.wrap({value:e,cause:n}),rawValue:e}}}async function ue({text:e,schema:n}){try{let t=B(e);return n==null?t:V({value:t,schema:n})}catch(n){throw t.JSONParseError.isInstance(n)||t.TypeValidationError.isInstance(n)?n:new t.JSONParseError({text:e,cause:n})}}async function de({text:e,schema:n}){try{let t=B(e);return n==null?{success:!0,value:t,rawValue:t}:await le({value:t,schema:n})}catch(n){return{success:!1,error:t.JSONParseError.isInstance(n)?n:new t.JSONParseError({text:e,cause:n}),rawValue:void 0}}}function fe({stream:e,schema:n}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new t.EventSourceParserStream).pipeThrough(new TransformStream({async transform({data:e},t){e!==`[DONE]`&&t.enqueue(await de({text:e,schema:n}))}}))}async function pe({provider:e,providerOptions:n,schema:r}){if(n?.[e]==null)return;let i=await le({value:n[e],schema:r});if(!i.success)throw new t.InvalidArgumentError({argument:`providerOptions`,message:`invalid ${e} provider options`,cause:i.error});return i.value}var me=()=>globalThis.fetch,he=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>ge({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),ge=async({url:e,headers:n={},body:r,successfulResponseHandler:i,failedResponseHandler:a,abortSignal:o,fetch:s=me()})=>{try{let c=await s(e,{method:`POST`,headers:M(n,`ai-sdk/provider-utils/${I}`,A()),body:r.content,signal:o}),l=k(c);if(!c.ok){let n;try{n=await a({response:c,url:e,requestBodyValues:r.values})}catch(n){throw F(n)||t.APICallError.isInstance(n)?n:new t.APICallError({message:`Failed to process error response`,cause:n,statusCode:c.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw n.value}try{return await i({response:c,url:e,requestBodyValues:r.values})}catch(n){throw n instanceof Error&&(F(n)||t.APICallError.isInstance(n))?n:new t.APICallError({message:`Failed to process successful response`,cause:n,statusCode:c.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(t){throw te({error:t,url:e,requestBodyValues:r.values})}};function _e(e){return e}function ve({id:e,name:t,inputSchema:n}){return({execute:r,outputSchema:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c,...l})=>_e({type:`provider-defined`,id:e,name:t,args:l,inputSchema:n,outputSchema:i,execute:r,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c})}function ye({id:e,name:t,inputSchema:n,outputSchema:r}){return({execute:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c,...l})=>_e({type:`provider-defined`,id:e,name:t,args:l,inputSchema:n,outputSchema:r,execute:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c})}async function be(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}var H=({errorSchema:e,errorToMessage:n,isRetryable:r})=>async({response:i,url:a,requestBodyValues:o})=>{let s=await i.text(),c=k(i);if(s.trim()===``)return{responseHeaders:c,value:new t.APICallError({message:i.statusText,url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,isRetryable:r?.(i)})};try{let l=await ue({text:s,schema:e});return{responseHeaders:c,value:new t.APICallError({message:n(l),url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,data:l,isRetryable:r?.(i,l)})}}catch{return{responseHeaders:c,value:new t.APICallError({message:i.statusText,url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,isRetryable:r?.(i)})}}},xe=e=>async({response:n})=>{let r=k(n);if(n.body==null)throw new t.EmptyResponseBodyError({});return{responseHeaders:r,value:fe({stream:n.body,schema:e})}},Se=e=>async({response:n,url:r,requestBodyValues:i})=>{let a=await n.text(),o=await de({text:a,schema:e}),s=k(n);if(!o.success)throw new t.APICallError({message:`Invalid JSON response`,cause:o.error,statusCode:n.status,responseHeaders:s,responseBody:a,url:r,requestBodyValues:i});return{responseHeaders:s,value:o.value,rawValue:o.rawValue}},Ce=Symbol(`Let zodToJsonSchema decide on which parser to use`),we=Symbol.for(`vercel.ai.schema`),{btoa:Te,atob:Ee}=globalThis;function De(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return Te(t)}function Oe(e){return e instanceof Uint8Array?De(e):e}function ke(e){return e?.replace(/\/$/,``)}var Ae=`2.0.23`,je=r.z.object({type:r.z.literal(`error`),error:r.z.object({type:r.z.string(),message:r.z.string()})}),Me=H({errorSchema:je,errorToMessage:e=>e.error.message}),U=r.z.object({citations:r.z.object({enabled:r.z.boolean()}).optional(),title:r.z.string().optional(),context:r.z.string().optional()}),Ne=r.z.object({sendReasoning:r.z.boolean().optional(),thinking:r.z.object({type:r.z.union([r.z.literal(`enabled`),r.z.literal(`disabled`)]),budgetTokens:r.z.number().optional()}).optional(),disableParallelToolUse:r.z.boolean().optional(),cacheControl:r.z.object({type:r.z.literal(`ephemeral`),ttl:r.z.union([r.z.literal(`5m`),r.z.literal(`1h`)]).optional()}).optional()});function Pe(e){let t=e?.anthropic;return t?.cacheControl??t?.cache_control}var Fe=r.z.object({maxCharacters:r.z.number().optional()}),Ie=ve({id:`anthropic.text_editor_20250728`,name:`str_replace_based_edit_tool`,inputSchema:r.z.object({command:r.z.enum([`view`,`create`,`str_replace`,`insert`]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()})}),Le=(e={})=>Ie(e),Re=r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),userLocation:r.z.object({type:r.z.literal(`approximate`),city:r.z.string().optional(),region:r.z.string().optional(),country:r.z.string().optional(),timezone:r.z.string().optional()}).optional()}),ze=r.z.array(r.z.object({url:r.z.string(),title:r.z.string(),pageAge:r.z.string().nullable(),encryptedContent:r.z.string(),type:r.z.literal(`web_search_result`)})),Be=ye({id:`anthropic.web_search_20250305`,name:`web_search`,inputSchema:r.z.object({query:r.z.string()}),outputSchema:ze}),Ve=(e={})=>Be(e),He=r.z.object({maxUses:r.z.number().optional(),allowedDomains:r.z.array(r.z.string()).optional(),blockedDomains:r.z.array(r.z.string()).optional(),citations:r.z.object({enabled:r.z.boolean()}).optional(),maxContentTokens:r.z.number().optional()}),Ue=r.z.object({type:r.z.literal(`web_fetch_result`),url:r.z.string(),content:r.z.object({type:r.z.literal(`document`),title:r.z.string(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.union([r.z.object({type:r.z.literal(`base64`),mediaType:r.z.literal(`application/pdf`),data:r.z.string()}),r.z.object({type:r.z.literal(`text`),mediaType:r.z.literal(`text/plain`),data:r.z.string()})])}),retrievedAt:r.z.string().nullable()}),We=ye({id:`anthropic.web_fetch_20250910`,name:`web_fetch`,inputSchema:r.z.object({url:r.z.string()}),outputSchema:Ue}),Ge=(e={})=>We(e);function Ke({tools:e,toolChoice:n,disableParallelToolUse:r}){e=e?.length?e:void 0;let i=[],a=new Set;if(e==null)return{tools:void 0,toolChoice:void 0,toolWarnings:i,betas:a};let o=[];for(let t of e)switch(t.type){case`function`:{let e=Pe(t.providerOptions);o.push({name:t.name,description:t.description,input_schema:t.inputSchema,cache_control:e});break}case`provider-defined`:switch(t.id){case`anthropic.code_execution_20250522`:a.add(`code-execution-2025-05-22`),o.push({type:`code_execution_20250522`,name:`code_execution`});break;case`anthropic.computer_20250124`:a.add(`computer-use-2025-01-24`),o.push({name:`computer`,type:`computer_20250124`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber});break;case`anthropic.computer_20241022`:a.add(`computer-use-2024-10-22`),o.push({name:`computer`,type:`computer_20241022`,display_width_px:t.args.displayWidthPx,display_height_px:t.args.displayHeightPx,display_number:t.args.displayNumber});break;case`anthropic.text_editor_20250124`:a.add(`computer-use-2025-01-24`),o.push({name:`str_replace_editor`,type:`text_editor_20250124`});break;case`anthropic.text_editor_20241022`:a.add(`computer-use-2024-10-22`),o.push({name:`str_replace_editor`,type:`text_editor_20241022`});break;case`anthropic.text_editor_20250429`:a.add(`computer-use-2025-01-24`),o.push({name:`str_replace_based_edit_tool`,type:`text_editor_20250429`});break;case`anthropic.text_editor_20250728`:{let e=Fe.parse(t.args);o.push({name:`str_replace_based_edit_tool`,type:`text_editor_20250728`,max_characters:e.maxCharacters});break}case`anthropic.bash_20250124`:a.add(`computer-use-2025-01-24`),o.push({name:`bash`,type:`bash_20250124`});break;case`anthropic.bash_20241022`:a.add(`computer-use-2024-10-22`),o.push({name:`bash`,type:`bash_20241022`});break;case`anthropic.web_fetch_20250910`:{a.add(`web-fetch-2025-09-10`);let e=He.parse(t.args);o.push({type:`web_fetch_20250910`,name:`web_fetch`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,citations:e.citations,max_content_tokens:e.maxContentTokens});break}case`anthropic.web_search_20250305`:{let e=Re.parse(t.args);o.push({type:`web_search_20250305`,name:`web_search`,max_uses:e.maxUses,allowed_domains:e.allowedDomains,blocked_domains:e.blockedDomains,user_location:e.userLocation});break}default:i.push({type:`unsupported-tool`,tool:t});break}break;default:i.push({type:`unsupported-tool`,tool:t});break}if(n==null)return{tools:o,toolChoice:r?{type:`auto`,disable_parallel_tool_use:r}:void 0,toolWarnings:i,betas:a};let s=n.type;switch(s){case`auto`:return{tools:o,toolChoice:{type:`auto`,disable_parallel_tool_use:r},toolWarnings:i,betas:a};case`required`:return{tools:o,toolChoice:{type:`any`,disable_parallel_tool_use:r},toolWarnings:i,betas:a};case`none`:return{tools:void 0,toolChoice:void 0,toolWarnings:i,betas:a};case`tool`:return{tools:o,toolChoice:{type:`tool`,name:n.toolName,disable_parallel_tool_use:r},toolWarnings:i,betas:a};default:throw new t.UnsupportedFunctionalityError({functionality:`tool choice type: ${s}`})}}var qe=r.z.object({type:r.z.literal(`code_execution_result`),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),Je=ye({id:`anthropic.code_execution_20250522`,name:`code_execution`,inputSchema:r.z.object({code:r.z.string()}),outputSchema:qe}),Ye=(e={})=>Je(e);function Xe(e){if(typeof e==`string`)return Buffer.from(e,`base64`).toString(`utf-8`);if(e instanceof Uint8Array)return new TextDecoder().decode(e);throw e instanceof URL?new t.UnsupportedFunctionalityError({functionality:`URL-based text documents are not supported for citations`}):new t.UnsupportedFunctionalityError({functionality:`unsupported data type for text documents: ${typeof e}`})}async function Ze({prompt:e,sendReasoning:n,warnings:r}){let i=new Set,a=Qe(e),o,s=[];async function c(e){return(await pe({provider:`anthropic`,providerOptions:e,schema:U}))?.citations?.enabled??!1}async function l(e){let t=await pe({provider:`anthropic`,providerOptions:e,schema:U});return{title:t?.title,context:t?.context}}for(let e=0;e<a.length;e++){let u=a[e],d=e===a.length-1,f=u.type;switch(f){case`system`:if(o!=null)throw new t.UnsupportedFunctionalityError({functionality:`Multiple system messages that are separated by user/assistant messages`});o=u.messages.map(({content:e,providerOptions:t})=>({type:`text`,text:e,cache_control:Pe(t)}));break;case`user`:{let e=[];for(let n of u.messages){let{role:r,content:a}=n;switch(r){case`user`:for(let r=0;r<a.length;r++){let o=a[r],s=r===a.length-1,u=Pe(o.providerOptions)??(s?Pe(n.providerOptions):void 0);switch(o.type){case`text`:e.push({type:`text`,text:o.text,cache_control:u});break;case`file`:if(o.mediaType.startsWith(`image/`))e.push({type:`image`,source:o.data instanceof URL?{type:`url`,url:o.data.toString()}:{type:`base64`,media_type:o.mediaType===`image/*`?`image/jpeg`:o.mediaType,data:Oe(o.data)},cache_control:u});else if(o.mediaType===`application/pdf`){i.add(`pdfs-2024-09-25`);let t=await c(o.providerOptions),n=await l(o.providerOptions);e.push({type:`document`,source:o.data instanceof URL?{type:`url`,url:o.data.toString()}:{type:`base64`,media_type:`application/pdf`,data:Oe(o.data)},title:n.title??o.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:u})}else if(o.mediaType===`text/plain`){let t=await c(o.providerOptions),n=await l(o.providerOptions);e.push({type:`document`,source:o.data instanceof URL?{type:`url`,url:o.data.toString()}:{type:`text`,media_type:`text/plain`,data:Xe(o.data)},title:n.title??o.filename,...n.context&&{context:n.context},...t&&{citations:{enabled:!0}},cache_control:u})}else throw new t.UnsupportedFunctionalityError({functionality:`media type: ${o.mediaType}`});break}}break;case`tool`:for(let r=0;r<a.length;r++){let i=a[r],o=r===a.length-1,s=Pe(i.providerOptions)??(o?Pe(n.providerOptions):void 0),c=i.output,l;switch(c.type){case`content`:l=c.value.map(e=>{switch(e.type){case`text`:return{type:`text`,text:e.text,cache_control:void 0};case`media`:if(e.mediaType.startsWith(`image/`))return{type:`image`,source:{type:`base64`,media_type:e.mediaType,data:e.data},cache_control:void 0};throw new t.UnsupportedFunctionalityError({functionality:`media type: ${e.mediaType}`})}});break;case`text`:case`error-text`:l=c.value;break;case`json`:case`error-json`:default:l=JSON.stringify(c.value);break}e.push({type:`tool_result`,tool_use_id:i.toolCallId,content:l,is_error:c.type===`error-text`||c.type===`error-json`?!0:void 0,cache_control:s})}break;default:{let e=r;throw Error(`Unsupported role: ${e}`)}}}s.push({role:`user`,content:e});break}case`assistant`:{let e=[];for(let t=0;t<u.messages.length;t++){let i=u.messages[t],a=t===u.messages.length-1,{content:o}=i;for(let t=0;t<o.length;t++){let s=o[t],c=t===o.length-1,l=Pe(s.providerOptions)??(c?Pe(i.providerOptions):void 0);switch(s.type){case`text`:e.push({type:`text`,text:d&&a&&c?s.text.trim():s.text,cache_control:l});break;case`reasoning`:if(n){let t=await pe({provider:`anthropic`,providerOptions:s.providerOptions,schema:st});t==null?r.push({type:`other`,message:`unsupported reasoning metadata`}):t.signature==null?t.redactedData==null?r.push({type:`other`,message:`unsupported reasoning metadata`}):e.push({type:`redacted_thinking`,data:t.redactedData,cache_control:l}):e.push({type:`thinking`,thinking:s.text,signature:t.signature,cache_control:l})}else r.push({type:`other`,message:`sending reasoning content is disabled for this model`});break;case`tool-call`:if(s.providerExecuted){s.toolName===`code_execution`||s.toolName===`web_fetch`||s.toolName===`web_search`?e.push({type:`server_tool_use`,id:s.toolCallId,name:s.toolName,input:s.input,cache_control:l}):r.push({type:`other`,message:`provider executed tool call for tool ${s.toolName} is not supported`});break}e.push({type:`tool_use`,id:s.toolCallId,name:s.toolName,input:s.input,cache_control:l});break;case`tool-result`:if(s.toolName===`code_execution`){let t=s.output;if(t.type!==`json`){r.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let n=qe.parse(t.value);e.push({type:`code_execution_tool_result`,tool_use_id:s.toolCallId,content:{type:n.type,stdout:n.stdout,stderr:n.stderr,return_code:n.return_code},cache_control:l});break}if(s.toolName===`web_fetch`){let t=s.output;if(t.type!==`json`){r.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let n=Ue.parse(t.value);e.push({type:`web_fetch_tool_result`,tool_use_id:s.toolCallId,content:{type:`web_fetch_result`,url:n.url,retrieved_at:n.retrievedAt,content:{type:`document`,title:n.content.title,citations:n.content.citations,source:{type:n.content.source.type,media_type:n.content.source.mediaType,data:n.content.source.data}}},cache_control:l});break}if(s.toolName===`web_search`){let t=s.output;if(t.type!==`json`){r.push({type:`other`,message:`provider executed tool result output type ${t.type} for tool ${s.toolName} is not supported`});break}let n=ze.parse(t.value);e.push({type:`web_search_tool_result`,tool_use_id:s.toolCallId,content:n.map(e=>({url:e.url,title:e.title,page_age:e.pageAge,encrypted_content:e.encryptedContent,type:e.type})),cache_control:l});break}r.push({type:`other`,message:`provider executed tool result for tool ${s.toolName} is not supported`});break}}}s.push({role:`assistant`,content:e});break}default:{let e=f;throw Error(`content type: ${e}`)}}}return{prompt:{system:o,messages:s},betas:i}}function Qe(e){let t=[],n;for(let r of e){let{role:e}=r;switch(e){case`system`:n?.type!==`system`&&(n={type:`system`,messages:[]},t.push(n)),n.messages.push(r);break;case`assistant`:n?.type!==`assistant`&&(n={type:`assistant`,messages:[]},t.push(n)),n.messages.push(r);break;case`user`:n?.type!==`user`&&(n={type:`user`,messages:[]},t.push(n)),n.messages.push(r);break;case`tool`:n?.type!==`user`&&(n={type:`user`,messages:[]},t.push(n)),n.messages.push(r);break;default:{let t=e;throw Error(`Unsupported role: ${t}`)}}}return t}function $e({finishReason:e,isJsonResponseFromTool:t}){switch(e){case`pause_turn`:case`end_turn`:case`stop_sequence`:return`stop`;case`refusal`:return`content-filter`;case`tool_use`:return t?`stop`:`tool-calls`;case`max_tokens`:return`length`;default:return`unknown`}}var et={webSearchResult:r.z.object({type:r.z.literal(`web_search_result_location`),cited_text:r.z.string(),url:r.z.string(),title:r.z.string(),encrypted_index:r.z.string()}),pageLocation:r.z.object({type:r.z.literal(`page_location`),cited_text:r.z.string(),document_index:r.z.number(),document_title:r.z.string().nullable(),start_page_number:r.z.number(),end_page_number:r.z.number()}),charLocation:r.z.object({type:r.z.literal(`char_location`),cited_text:r.z.string(),document_index:r.z.number(),document_title:r.z.string().nullable(),start_char_index:r.z.number(),end_char_index:r.z.number()})},tt=r.z.discriminatedUnion(`type`,[et.webSearchResult,et.pageLocation,et.charLocation]);r.z.discriminatedUnion(`type`,[et.pageLocation,et.charLocation]);function nt(e,t,n,r){if(e.type===`page_location`||e.type===`char_location`){let i=rt(e,t,n);i&&r(i)}}function rt(e,t,n){let r=t[e.document_index];if(!r)return null;let i=e.type===`page_location`?{citedText:e.cited_text,startPageNumber:e.start_page_number,endPageNumber:e.end_page_number}:{citedText:e.cited_text,startCharIndex:e.start_char_index,endCharIndex:e.end_char_index};return{type:`source`,sourceType:`document`,id:n(),mediaType:r.mediaType,title:e.document_title??r.title,filename:r.filename,providerMetadata:{anthropic:i}}}var it=class{constructor(e,t){this.specificationVersion=`v2`,this.modelId=e,this.config=t,this.generateId=t.generateId??P}supportsUrl(e){return e.protocol===`https:`}get provider(){return this.config.provider}get supportedUrls(){var e;return(e=this.config).supportedUrls?.call(e)??{}}async getArgs({prompt:e,maxOutputTokens:n=4096,temperature:r,topP:i,topK:a,frequencyPenalty:o,presencePenalty:s,stopSequences:c,responseFormat:l,seed:u,tools:d,toolChoice:f,providerOptions:p}){let m=[];o!=null&&m.push({type:`unsupported-setting`,setting:`frequencyPenalty`}),s!=null&&m.push({type:`unsupported-setting`,setting:`presencePenalty`}),u!=null&&m.push({type:`unsupported-setting`,setting:`seed`}),l?.type===`json`&&(l.schema==null?m.push({type:`unsupported-setting`,setting:`responseFormat`,details:`JSON response format requires a schema. The response format is ignored.`}):d!=null&&m.push({type:`unsupported-setting`,setting:`tools`,details:`JSON response format does not support tools. The provided tools are ignored.`}));let h=l?.type===`json`&&l.schema!=null?{type:`function`,name:`json`,description:`Respond with a JSON object.`,inputSchema:l.schema}:void 0,g=await pe({provider:`anthropic`,providerOptions:p,schema:Ne}),{prompt:_,betas:v}=await Ze({prompt:e,sendReasoning:g?.sendReasoning??!0,warnings:m}),y=g?.thinking?.type===`enabled`,b=g?.thinking?.budgetTokens,x={model:this.modelId,max_tokens:n,temperature:r,top_k:a,top_p:i,stop_sequences:c,...y&&{thinking:{type:`enabled`,budget_tokens:b}},system:_.system,messages:_.messages};if(y){if(b==null)throw new t.UnsupportedFunctionalityError({functionality:`thinking requires a budget`});x.temperature!=null&&(x.temperature=void 0,m.push({type:`unsupported-setting`,setting:`temperature`,details:`temperature is not supported when thinking is enabled`})),a!=null&&(x.top_k=void 0,m.push({type:`unsupported-setting`,setting:`topK`,details:`topK is not supported when thinking is enabled`})),i!=null&&(x.top_p=void 0,m.push({type:`unsupported-setting`,setting:`topP`,details:`topP is not supported when thinking is enabled`})),x.max_tokens=n+b}let{tools:S,toolChoice:C,toolWarnings:w,betas:T}=Ke(h==null?{tools:d??[],toolChoice:f,disableParallelToolUse:g?.disableParallelToolUse}:{tools:[h],toolChoice:{type:`tool`,toolName:h.name},disableParallelToolUse:!0});return{args:{...x,tools:S,tool_choice:C},warnings:[...m,...w],betas:new Set([...v,...T]),usesJsonResponseTool:h!=null}}async getHeaders({betas:e,headers:t}){return O(await be(this.config.headers),e.size>0?{"anthropic-beta":Array.from(e).join(`,`)}:{},t)}buildRequestUrl(e){var t;return(t=this.config).buildRequestUrl?.call(t,this.config.baseURL,e)??`${this.config.baseURL}/messages`}transformRequestBody(e){var t;return(t=this.config).transformRequestBody?.call(t,e)??e}extractCitationDocuments(e){return e.filter(e=>e.role===`user`).flatMap(e=>e.content).filter(e=>e.type!==`file`||e.mediaType!==`application/pdf`&&e.mediaType!==`text/plain`?!1:e.providerOptions?.anthropic?.citations?.enabled??!1).map(e=>{let t=e;return{title:t.filename??`Untitled Document`,filename:t.filename,mediaType:t.mediaType}})}async doGenerate(e){let{args:t,warnings:n,betas:r,usesJsonResponseTool:i}=await this.getArgs(e),a=this.extractCitationDocuments(e.prompt),{responseHeaders:o,value:s,rawValue:c}=await he({url:this.buildRequestUrl(!1),headers:await this.getHeaders({betas:r,headers:e.headers}),body:this.transformRequestBody(t),failedResponseHandler:Me,successfulResponseHandler:Se(at),abortSignal:e.abortSignal,fetch:this.config.fetch}),l=[];for(let e of s.content)switch(e.type){case`text`:if(!i&&(l.push({type:`text`,text:e.text}),e.citations))for(let t of e.citations)nt(t,a,this.generateId,e=>l.push(e));break;case`thinking`:l.push({type:`reasoning`,text:e.thinking,providerMetadata:{anthropic:{signature:e.signature}}});break;case`redacted_thinking`:l.push({type:`reasoning`,text:``,providerMetadata:{anthropic:{redactedData:e.data}}});break;case`tool_use`:l.push(i?{type:`text`,text:JSON.stringify(e.input)}:{type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input)});break;case`server_tool_use`:(e.name===`web_search`||e.name===`code_execution`||e.name===`web_fetch`)&&l.push({type:`tool-call`,toolCallId:e.id,toolName:e.name,input:JSON.stringify(e.input),providerExecuted:!0});break;case`web_fetch_tool_result`:e.content.type===`web_fetch_result`?l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_fetch`,result:{type:`web_fetch_result`,url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}},providerExecuted:!0}):e.content.type===`web_fetch_tool_result_error`&&l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_fetch`,isError:!0,result:{type:`web_fetch_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});break;case`web_search_tool_result`:if(Array.isArray(e.content)){l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_search`,result:e.content.map(e=>({url:e.url,title:e.title,pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type})),providerExecuted:!0});for(let t of e.content)l.push({type:`source`,sourceType:`url`,id:this.generateId(),url:t.url,title:t.title,providerMetadata:{anthropic:{pageAge:t.page_age??null}}})}else l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_search`,isError:!0,result:{type:`web_search_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});break;case`code_execution_tool_result`:e.content.type===`code_execution_result`?l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`code_execution`,result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code},providerExecuted:!0}):e.content.type===`code_execution_tool_result_error`&&l.push({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`code_execution`,isError:!0,result:{type:`code_execution_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});break}return{content:l,finishReason:$e({finishReason:s.stop_reason,isJsonResponseFromTool:i}),usage:{inputTokens:s.usage.input_tokens,outputTokens:s.usage.output_tokens,totalTokens:s.usage.input_tokens+s.usage.output_tokens,cachedInputTokens:s.usage.cache_read_input_tokens??void 0},request:{body:t},response:{id:s.id??void 0,modelId:s.model??void 0,headers:o,body:c},warnings:n,providerMetadata:{anthropic:{usage:s.usage,cacheCreationInputTokens:s.usage.cache_creation_input_tokens??null,stopSequence:s.stop_sequence??null}}}}async doStream(e){let{args:t,warnings:n,betas:r,usesJsonResponseTool:i}=await this.getArgs(e),a=this.extractCitationDocuments(e.prompt),o={...t,stream:!0},{responseHeaders:s,value:c}=await he({url:this.buildRequestUrl(!0),headers:await this.getHeaders({betas:r,headers:e.headers}),body:this.transformRequestBody(o),failedResponseHandler:Me,successfulResponseHandler:xe(ot),abortSignal:e.abortSignal,fetch:this.config.fetch}),l=`unknown`,u={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},d={},f,p=null,m=null,h,g=this.generateId;return{stream:c.pipeThrough(new TransformStream({start(e){e.enqueue({type:`stream-start`,warnings:n})},transform(t,n){if(e.includeRawChunks&&n.enqueue({type:`raw`,rawValue:t.rawValue}),!t.success){n.enqueue({type:`error`,error:t.error});return}let r=t.value;switch(r.type){case`ping`:return;case`content_block_start`:{let e=r.content_block.type;switch(h=e,e){case`text`:d[r.index]={type:`text`},n.enqueue({type:`text-start`,id:String(r.index)});return;case`thinking`:d[r.index]={type:`reasoning`},n.enqueue({type:`reasoning-start`,id:String(r.index)});return;case`redacted_thinking`:d[r.index]={type:`reasoning`},n.enqueue({type:`reasoning-start`,id:String(r.index),providerMetadata:{anthropic:{redactedData:r.content_block.data}}});return;case`tool_use`:d[r.index]=i?{type:`text`}:{type:`tool-call`,toolCallId:r.content_block.id,toolName:r.content_block.name,input:``},n.enqueue(i?{type:`text-start`,id:String(r.index)}:{type:`tool-input-start`,id:r.content_block.id,toolName:r.content_block.name});return;case`server_tool_use`:(r.content_block.name===`web_fetch`||r.content_block.name===`web_search`||r.content_block.name===`code_execution`)&&(d[r.index]={type:`tool-call`,toolCallId:r.content_block.id,toolName:r.content_block.name,input:``,providerExecuted:!0},n.enqueue({type:`tool-input-start`,id:r.content_block.id,toolName:r.content_block.name,providerExecuted:!0}));return;case`web_fetch_tool_result`:{let e=r.content_block;e.content.type===`web_fetch_result`?n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_fetch`,result:{type:`web_fetch_result`,url:e.content.url,retrievedAt:e.content.retrieved_at,content:{type:e.content.content.type,title:e.content.content.title,citations:e.content.content.citations,source:{type:e.content.content.source.type,mediaType:e.content.content.source.media_type,data:e.content.content.source.data}}}}):e.content.type===`web_fetch_tool_result_error`&&n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_fetch`,isError:!0,result:{type:`web_fetch_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});return}case`web_search_tool_result`:{let e=r.content_block;if(Array.isArray(e.content)){n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_search`,result:e.content.map(e=>({url:e.url,title:e.title,pageAge:e.page_age??null,encryptedContent:e.encrypted_content,type:e.type})),providerExecuted:!0});for(let t of e.content)n.enqueue({type:`source`,sourceType:`url`,id:g(),url:t.url,title:t.title,providerMetadata:{anthropic:{pageAge:t.page_age??null}}})}else n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`web_search`,isError:!0,result:{type:`web_search_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});return}case`code_execution_tool_result`:{let e=r.content_block;e.content.type===`code_execution_result`?n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`code_execution`,result:{type:e.content.type,stdout:e.content.stdout,stderr:e.content.stderr,return_code:e.content.return_code},providerExecuted:!0}):e.content.type===`code_execution_tool_result_error`&&n.enqueue({type:`tool-result`,toolCallId:e.tool_use_id,toolName:`code_execution`,isError:!0,result:{type:`code_execution_tool_result_error`,errorCode:e.content.error_code},providerExecuted:!0});return}default:{let t=e;throw Error(`Unsupported content block type: ${t}`)}}}case`content_block_stop`:if(d[r.index]!=null){let e=d[r.index];switch(e.type){case`text`:n.enqueue({type:`text-end`,id:String(r.index)});break;case`reasoning`:n.enqueue({type:`reasoning-end`,id:String(r.index)});break;case`tool-call`:i||(n.enqueue({type:`tool-input-end`,id:e.toolCallId}),n.enqueue(e));break}delete d[r.index]}h=void 0;return;case`content_block_delta`:{let e=r.delta.type;switch(e){case`text_delta`:if(i)return;n.enqueue({type:`text-delta`,id:String(r.index),delta:r.delta.text});return;case`thinking_delta`:n.enqueue({type:`reasoning-delta`,id:String(r.index),delta:r.delta.thinking});return;case`signature_delta`:h===`thinking`&&n.enqueue({type:`reasoning-delta`,id:String(r.index),delta:``,providerMetadata:{anthropic:{signature:r.delta.signature}}});return;case`input_json_delta`:{let e=d[r.index],t=r.delta.partial_json;if(i){if(e?.type!==`text`)return;n.enqueue({type:`text-delta`,id:String(r.index),delta:t})}else{if(e?.type!==`tool-call`)return;n.enqueue({type:`tool-input-delta`,id:e.toolCallId,delta:t}),e.input+=t}return}case`citations_delta`:{let e=r.delta.citation;nt(e,a,g,e=>n.enqueue(e));return}default:{let t=e;throw Error(`Unsupported delta type: ${t}`)}}}case`message_start`:u.inputTokens=r.message.usage.input_tokens,u.cachedInputTokens=r.message.usage.cache_read_input_tokens??void 0,f={...r.message.usage},p=r.message.usage.cache_creation_input_tokens??null,n.enqueue({type:`response-metadata`,id:r.message.id??void 0,modelId:r.message.model??void 0});return;case`message_delta`:u.outputTokens=r.usage.output_tokens,u.totalTokens=(u.inputTokens??0)+(r.usage.output_tokens??0),l=$e({finishReason:r.delta.stop_reason,isJsonResponseFromTool:i}),m=r.delta.stop_sequence??null,f={...f,...r.usage};return;case`message_stop`:n.enqueue({type:`finish`,finishReason:l,usage:u,providerMetadata:{anthropic:{usage:f??null,cacheCreationInputTokens:p,stopSequence:m}}});return;case`error`:n.enqueue({type:`error`,error:r.error});return;default:{let e=r;throw Error(`Unsupported chunk type: ${e}`)}}}})),request:{body:o},response:{headers:s}}}},at=r.z.object({type:r.z.literal(`message`),id:r.z.string().nullish(),model:r.z.string().nullish(),content:r.z.array(r.z.discriminatedUnion(`type`,[r.z.object({type:r.z.literal(`text`),text:r.z.string(),citations:r.z.array(tt).optional()}),r.z.object({type:r.z.literal(`thinking`),thinking:r.z.string(),signature:r.z.string()}),r.z.object({type:r.z.literal(`redacted_thinking`),data:r.z.string()}),r.z.object({type:r.z.literal(`tool_use`),id:r.z.string(),name:r.z.string(),input:r.z.unknown()}),r.z.object({type:r.z.literal(`server_tool_use`),id:r.z.string(),name:r.z.string(),input:r.z.record(r.z.string(),r.z.unknown()).nullish()}),r.z.object({type:r.z.literal(`web_fetch_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal(`web_fetch_result`),url:r.z.string(),retrieved_at:r.z.string(),content:r.z.object({type:r.z.literal(`document`),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.object({type:r.z.literal(`text`),media_type:r.z.string(),data:r.z.string()})})}),r.z.object({type:r.z.literal(`web_fetch_tool_result_error`),error_code:r.z.string()})])}),r.z.object({type:r.z.literal(`web_search_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.array(r.z.object({type:r.z.literal(`web_search_result`),url:r.z.string(),title:r.z.string(),encrypted_content:r.z.string(),page_age:r.z.string().nullish()})),r.z.object({type:r.z.literal(`web_search_tool_result_error`),error_code:r.z.string()})])}),r.z.object({type:r.z.literal(`code_execution_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal(`code_execution_result`),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal(`code_execution_tool_result_error`),error_code:r.z.string()})])})])),stop_reason:r.z.string().nullish(),stop_sequence:r.z.string().nullish(),usage:r.z.looseObject({input_tokens:r.z.number(),output_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish()})}),ot=r.z.discriminatedUnion(`type`,[r.z.object({type:r.z.literal(`message_start`),message:r.z.object({id:r.z.string().nullish(),model:r.z.string().nullish(),usage:r.z.looseObject({input_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish(),cache_read_input_tokens:r.z.number().nullish()})})}),r.z.object({type:r.z.literal(`content_block_start`),index:r.z.number(),content_block:r.z.discriminatedUnion(`type`,[r.z.object({type:r.z.literal(`text`),text:r.z.string()}),r.z.object({type:r.z.literal(`thinking`),thinking:r.z.string()}),r.z.object({type:r.z.literal(`tool_use`),id:r.z.string(),name:r.z.string()}),r.z.object({type:r.z.literal(`redacted_thinking`),data:r.z.string()}),r.z.object({type:r.z.literal(`server_tool_use`),id:r.z.string(),name:r.z.string(),input:r.z.record(r.z.string(),r.z.unknown()).nullish()}),r.z.object({type:r.z.literal(`web_fetch_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal(`web_fetch_result`),url:r.z.string(),retrieved_at:r.z.string(),content:r.z.object({type:r.z.literal(`document`),title:r.z.string().nullable(),citations:r.z.object({enabled:r.z.boolean()}).optional(),source:r.z.object({type:r.z.literal(`text`),media_type:r.z.string(),data:r.z.string()})})}),r.z.object({type:r.z.literal(`web_fetch_tool_result_error`),error_code:r.z.string()})])}),r.z.object({type:r.z.literal(`web_search_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.array(r.z.object({type:r.z.literal(`web_search_result`),url:r.z.string(),title:r.z.string(),encrypted_content:r.z.string(),page_age:r.z.string().nullish()})),r.z.object({type:r.z.literal(`web_search_tool_result_error`),error_code:r.z.string()})])}),r.z.object({type:r.z.literal(`code_execution_tool_result`),tool_use_id:r.z.string(),content:r.z.union([r.z.object({type:r.z.literal(`code_execution_result`),stdout:r.z.string(),stderr:r.z.string(),return_code:r.z.number()}),r.z.object({type:r.z.literal(`code_execution_tool_result_error`),error_code:r.z.string()})])})])}),r.z.object({type:r.z.literal(`content_block_delta`),index:r.z.number(),delta:r.z.discriminatedUnion(`type`,[r.z.object({type:r.z.literal(`input_json_delta`),partial_json:r.z.string()}),r.z.object({type:r.z.literal(`text_delta`),text:r.z.string()}),r.z.object({type:r.z.literal(`thinking_delta`),thinking:r.z.string()}),r.z.object({type:r.z.literal(`signature_delta`),signature:r.z.string()}),r.z.object({type:r.z.literal(`citations_delta`),citation:tt})])}),r.z.object({type:r.z.literal(`content_block_stop`),index:r.z.number()}),r.z.object({type:r.z.literal(`error`),error:r.z.object({type:r.z.string(),message:r.z.string()})}),r.z.object({type:r.z.literal(`message_delta`),delta:r.z.object({stop_reason:r.z.string().nullish(),stop_sequence:r.z.string().nullish()}),usage:r.z.looseObject({output_tokens:r.z.number(),cache_creation_input_tokens:r.z.number().nullish()})}),r.z.object({type:r.z.literal(`message_stop`)}),r.z.object({type:r.z.literal(`ping`)})]),st=r.z.object({signature:r.z.string().optional(),redactedData:r.z.string().optional()}),ct=ve({id:`anthropic.bash_20241022`,name:`bash`,inputSchema:r.default.object({command:r.default.string(),restart:r.default.boolean().optional()})}),lt=ve({id:`anthropic.bash_20250124`,name:`bash`,inputSchema:r.default.object({command:r.default.string(),restart:r.default.boolean().optional()})}),ut=ve({id:`anthropic.computer_20241022`,name:`computer`,inputSchema:r.z.object({action:r.z.enum([`key`,`type`,`mouse_move`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`screenshot`,`cursor_position`]),coordinate:r.z.array(r.z.number().int()).optional(),text:r.z.string().optional()})}),dt=ve({id:`anthropic.computer_20250124`,name:`computer`,inputSchema:r.z.object({action:r.z.enum([`key`,`hold_key`,`type`,`cursor_position`,`mouse_move`,`left_mouse_down`,`left_mouse_up`,`left_click`,`left_click_drag`,`right_click`,`middle_click`,`double_click`,`triple_click`,`scroll`,`wait`,`screenshot`]),coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),duration:r.z.number().optional(),scroll_amount:r.z.number().optional(),scroll_direction:r.z.enum([`up`,`down`,`left`,`right`]).optional(),start_coordinate:r.z.tuple([r.z.number().int(),r.z.number().int()]).optional(),text:r.z.string().optional()})}),ft=ve({id:`anthropic.text_editor_20241022`,name:`str_replace_editor`,inputSchema:r.z.object({command:r.z.enum([`view`,`create`,`str_replace`,`insert`,`undo_edit`]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()})}),pt=ve({id:`anthropic.text_editor_20250124`,name:`str_replace_editor`,inputSchema:r.z.object({command:r.z.enum([`view`,`create`,`str_replace`,`insert`,`undo_edit`]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()})}),mt=ve({id:`anthropic.text_editor_20250429`,name:`str_replace_based_edit_tool`,inputSchema:r.z.object({command:r.z.enum([`view`,`create`,`str_replace`,`insert`]),path:r.z.string(),file_text:r.z.string().optional(),insert_line:r.z.number().int().optional(),new_str:r.z.string().optional(),old_str:r.z.string().optional(),view_range:r.z.array(r.z.number().int()).optional()})}),ht={bash_20241022:ct,bash_20250124:lt,codeExecution_20250522:Ye,computer_20241022:ut,computer_20250124:dt,textEditor_20241022:ft,textEditor_20250124:pt,textEditor_20250429:mt,textEditor_20250728:Le,webFetch_20250910:Ge,webSearch_20250305:Ve};function gt(e={}){let n=ke(e.baseURL)??`https://api.anthropic.com/v1`,r=()=>M({"anthropic-version":`2023-06-01`,"x-api-key":ne({apiKey:e.apiKey,environmentVariableName:`ANTHROPIC_API_KEY`,description:`Anthropic`}),...e.headers},`ai-sdk/anthropic/${Ae}`),i=t=>new it(t,{provider:`anthropic.messages`,baseURL:n,headers:r,fetch:e.fetch,generateId:e.generateId??P,supportedUrls:()=>({"image/*":[/^https?:\/\/.*$/]})}),a=function(e){if(new.target)throw Error(`The Anthropic model function cannot be called with the new keyword.`);return i(e)};return a.languageModel=i,a.chat=i,a.messages=i,a.textEmbeddingModel=e=>{throw new t.NoSuchModelError({modelId:e,modelType:`textEmbeddingModel`})},a.imageModel=e=>{throw new t.NoSuchModelError({modelId:e,modelType:`imageModel`})},a.tools=ht,a}var _t=gt();function vt(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}function yt(e){return Object.fromEntries([...e.headers])}function bt(e=globalThis){return e.window?`runtime/browser`:e.navigator?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:e.process?.versions?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function xt(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null))}function St(e,...t){let n=xt(e??{}),r=new Headers(n),i=r.get(`user-agent`)||``;return r.set(`user-agent`,[i,...t].filter(Boolean).join(` `)),Object.fromEntries(r)}var Ct=({prefix:e,size:n=16,alphabet:r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:i=`-`}={})=>{let a=()=>{let e=r.length,t=Array(n);for(let i=0;i<n;i++)t[i]=r[Math.random()*e|0];return t.join(``)};if(e==null)return a;if(r.includes(i))throw new t.InvalidArgumentError({argument:`separator`,message:`The separator "${i}" must not be part of the alphabet "${r}".`});return()=>`${e}${i}${a()}`},wt=Ct();function Tt(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var Et=[`fetch failed`,`failed to fetch`];function Dt({error:e,url:n,requestBodyValues:r}){if(Tt(e))return e;if(e instanceof TypeError&&Et.includes(e.message.toLowerCase())){let i=e.cause;if(i!=null)return new t.APICallError({message:`Cannot connect to API: ${i.message}`,cause:i,url:n,requestBodyValues:r,isRetryable:!0})}return e}var Ot=`3.0.10`;function kt({apiKey:e,environmentVariableName:n,apiKeyParameterName:r=`apiKey`,description:i}){if(typeof e==`string`)return e;if(e!=null)throw new t.LoadAPIKeyError({message:`${i} API key must be a string.`});if(typeof process>`u`)throw new t.LoadAPIKeyError({message:`${i} API key is missing. Pass it using the '${r}' parameter. Environment variables is not supported in this environment.`});if(e=process.env[n],e==null)throw new t.LoadAPIKeyError({message:`${i} API key is missing. Pass it using the '${r}' parameter or the ${n} environment variable.`});if(typeof e!=`string`)throw new t.LoadAPIKeyError({message:`${i} API key must be a string. The value of the ${n} environment variable is not a string.`});return e}var At=/"__proto__"\s*:/,jt=/"constructor"\s*:/;function Mt(e){let t=JSON.parse(e);return typeof t!=`object`||!t||At.test(e)===!1&&jt.test(e)===!1?t:Nt(t)}function Nt(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function Pt(e){let{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return Mt(e)}finally{Error.stackTraceLimit=t}}var Ft=Symbol.for(`vercel.ai.validator`);function It(e){return{[Ft]:!0,validate:e}}function Lt(e){return typeof e==`object`&&!!e&&Ft in e&&e[Ft]===!0&&`validate`in e}function Rt(e){return Lt(e)?e:zt(e)}function zt(e){return It(async n=>{let r=await e[`~standard`].validate(n);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new t.TypeValidationError({value:n,cause:r.issues})}})}async function Bt({value:e,schema:n}){let r=await Vt({value:e,schema:n});if(!r.success)throw t.TypeValidationError.wrap({value:e,cause:r.error});return r.value}async function Vt({value:e,schema:n}){let r=Rt(n);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let n=await r.validate(e);return n.success?{success:!0,value:n.value,rawValue:e}:{success:!1,error:t.TypeValidationError.wrap({value:e,cause:n.error}),rawValue:e}}catch(n){return{success:!1,error:t.TypeValidationError.wrap({value:e,cause:n}),rawValue:e}}}async function Ht({text:e,schema:n}){try{let t=Pt(e);return n==null?t:Bt({value:t,schema:n})}catch(n){throw t.JSONParseError.isInstance(n)||t.TypeValidationError.isInstance(n)?n:new t.JSONParseError({text:e,cause:n})}}async function Ut({text:e,schema:n}){try{let t=Pt(e);return n==null?{success:!0,value:t,rawValue:t}:await Vt({value:t,schema:n})}catch(n){return{success:!1,error:t.JSONParseError.isInstance(n)?n:new t.JSONParseError({text:e,cause:n}),rawValue:void 0}}}function Wt({stream:e,schema:n}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new t.EventSourceParserStream).pipeThrough(new TransformStream({async transform({data:e},t){e!==`[DONE]`&&t.enqueue(await Ut({text:e,schema:n}))}}))}async function Gt({provider:e,providerOptions:n,schema:r}){if(n?.[e]==null)return;let i=await Vt({value:n[e],schema:r});if(!i.success)throw new t.InvalidArgumentError({argument:`providerOptions`,message:`invalid ${e} provider options`,cause:i.error});return i.value}var Kt=()=>globalThis.fetch,qt=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>Jt({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),Jt=async({url:e,headers:n={},body:r,successfulResponseHandler:i,failedResponseHandler:a,abortSignal:o,fetch:s=Kt()})=>{try{let c=await s(e,{method:`POST`,headers:St(n,`ai-sdk/provider-utils/${Ot}`,bt()),body:r.content,signal:o}),l=yt(c);if(!c.ok){let n;try{n=await a({response:c,url:e,requestBodyValues:r.values})}catch(n){throw Tt(n)||t.APICallError.isInstance(n)?n:new t.APICallError({message:`Failed to process error response`,cause:n,statusCode:c.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw n.value}try{return await i({response:c,url:e,requestBodyValues:r.values})}catch(n){throw n instanceof Error&&(Tt(n)||t.APICallError.isInstance(n))?n:new t.APICallError({message:`Failed to process successful response`,cause:n,statusCode:c.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(t){throw Dt({error:t,url:e,requestBodyValues:r.values})}};function Yt(e){return e}function Xt({id:e,name:t,inputSchema:n}){return({execute:r,outputSchema:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c,...l})=>Yt({type:`provider-defined`,id:e,name:t,args:l,inputSchema:n,outputSchema:i,execute:r,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c})}function Zt({id:e,name:t,inputSchema:n,outputSchema:r}){return({execute:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c,...l})=>Yt({type:`provider-defined`,id:e,name:t,args:l,inputSchema:n,outputSchema:r,execute:i,toModelOutput:a,onInputStart:o,onInputDelta:s,onInputAvailable:c})}async function Qt(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}var $t=({errorSchema:e,errorToMessage:n,isRetryable:r})=>async({response:i,url:a,requestBodyValues:o})=>{let s=await i.text(),c=yt(i);if(s.trim()===``)return{responseHeaders:c,value:new t.APICallError({message:i.statusText,url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,isRetryable:r?.(i)})};try{let l=await Ht({text:s,schema:e});return{responseHeaders:c,value:new t.APICallError({message:n(l),url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,data:l,isRetryable:r?.(i,l)})}}catch{return{responseHeaders:c,value:new t.APICallError({message:i.statusText,url:a,requestBodyValues:o,statusCode:i.status,responseHeaders:c,responseBody:s,isRetryable:r?.(i)})}}},en=e=>async({response:n})=>{let r=yt(n);if(n.body==null)throw new t.EmptyResponseBodyError({});return{responseHeaders:r,value:Wt({stream:n.body,schema:e})}},tn=e=>async({response:n,url:r,requestBodyValues:i})=>{let a=await n.text(),o=await Ut({text:a,schema:e}),s=yt(n);if(!o.success)throw new t.APICallError({message:`Invalid JSON response`,cause:o.error,statusCode:n.status,responseHeaders:s,responseBody:a,url:r,requestBodyValues:i});return{responseHeaders:s,value:o.value,rawValue:o.rawValue}},nn=Symbol(`Let zodToJsonSchema decide on which parser to use`),rn=Symbol.for(`vercel.ai.schema`),{btoa:an,atob:on}=globalThis;function sn(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return an(t)}function cn(e){return e instanceof Uint8Array?sn(e):e}function ln(e){return e?.replace(/\/$/,``)}var un=`2.0.17`,dn=r.z.object({error:r.z.object({code:r.z.number().nullable(),message:r.z.string(),status:r.z.string()})}),fn=$t({errorSchema:dn,errorToMessage:e=>e.error.message}),pn=r.z.object({outputDimensionality:r.z.number().optional(),taskType:r.z.enum([`SEMANTIC_SIMILARITY`,`CLASSIFICATION`,`CLUSTERING`,`RETRIEVAL_DOCUMENT`,`RETRIEVAL_QUERY`,`QUESTION_ANSWERING`,`FACT_VERIFICATION`,`CODE_RETRIEVAL_QUERY`]).optional()}),mn=class{constructor(e,t){this.specificationVersion=`v2`,this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0,this.modelId=e,this.config=t}get provider(){return this.config.provider}async doEmbed({values:e,headers:n,abortSignal:r,providerOptions:i}){let a=await Gt({provider:`google`,providerOptions:i,schema:pn});if(e.length>this.maxEmbeddingsPerCall)throw new t.TooManyEmbeddingValuesForCallError({provider:this.provider,modelId:this.modelId,maxEmbeddingsPerCall:this.maxEmbeddingsPerCall,values:e});let o=vt(await Qt(this.config.headers),n);if(e.length===1){let{responseHeaders:t,value:n,rawValue:i}=await qt({url:`${this.config.baseURL}/models/${this.modelId}:embedContent`,headers:o,body:{model:`models/${this.modelId}`,content:{parts:[{text:e[0]}]},outputDimensionality:a?.outputDimensionality,taskType:a?.taskType},failedResponseHandler:fn,successfulResponseHandler:tn(gn),abortSignal:r,fetch:this.config.fetch});return{embeddings:[n.embedding.values],usage:void 0,response:{headers:t,body:i}}}let{responseHeaders:s,value:c,rawValue:l}=await qt({url:`${this.config.baseURL}/models/${this.modelId}:batchEmbedContents`,headers:o,body:{requests:e.map(e=>({model:`models/${this.modelId}`,content:{role:`user`,parts:[{text:e}]},outputDimensionality:a?.outputDimensionality,taskType:a?.taskType}))},failedResponseHandler:fn,successfulResponseHandler:tn(hn),abortSignal:r,fetch:this.config.fetch});return{embeddings:c.embeddings.map(e=>e.values),usage:void 0,response:{headers:s,body:l}}}},hn=r.z.object({embeddings:r.z.array(r.z.object({values:r.z.array(r.z.number())}))}),gn=r.z.object({embedding:r.z.object({values:r.z.array(r.z.number())})});function _n(e){if(e==null||vn(e))return;if(typeof e==`boolean`)return{type:`boolean`,properties:{}};let{type:t,description:n,required:r,properties:i,items:a,allOf:o,anyOf:s,oneOf:c,format:l,const:u,minLength:d,enum:f}=e,p={};if(n&&(p.description=n),r&&(p.required=r),l&&(p.format=l),u!==void 0&&(p.enum=[u]),t&&(Array.isArray(t)?t.includes(`null`)?(p.type=t.filter(e=>e!==`null`)[0],p.nullable=!0):p.type=t:t===`null`?p.type=`null`:p.type=t),f!==void 0&&(p.enum=f),i!=null&&(p.properties=Object.entries(i).reduce((e,[t,n])=>(e[t]=_n(n),e),{})),a&&(p.items=Array.isArray(a)?a.map(_n):_n(a)),o&&(p.allOf=o.map(_n)),s)if(s.some(e=>typeof e==`object`&&e?.type===`null`)){let e=s.filter(e=>!(typeof e==`object`&&e?.type===`null`));if(e.length===1){let t=_n(e[0]);typeof t==`object`&&(p.nullable=!0,Object.assign(p,t))}else p.anyOf=e.map(_n),p.nullable=!0}else p.anyOf=s.map(_n);return c&&(p.oneOf=c.map(_n)),d!==void 0&&(p.minLength=d),p}function vn(e){return typeof e==`object`&&!!e&&e.type===`object`&&(e.properties==null||Object.keys(e.properties).length===0)&&!e.additionalProperties}function yn(e,n){let r=[],i=[],a=!0,o=n?.isGemmaModel??!1;for(let{role:n,content:o}of e)switch(n){case`system`:if(!a)throw new t.UnsupportedFunctionalityError({functionality:`system messages are only supported at the beginning of the conversation`});r.push({text:o});break;case`user`:{a=!1;let e=[];for(let t of o)switch(t.type){case`text`:e.push({text:t.text});break;case`file`:{let n=t.mediaType===`image/*`?`image/jpeg`:t.mediaType;e.push(t.data instanceof URL?{fileData:{mimeType:n,fileUri:t.data.toString()}}:{inlineData:{mimeType:n,data:cn(t.data)}});break}}i.push({role:`user`,parts:e});break}case`assistant`:a=!1,i.push({role:`model`,parts:o.map(e=>{switch(e.type){case`text`:return e.text.length===0?void 0:{text:e.text,thoughtSignature:e.providerOptions?.google?.thoughtSignature};case`reasoning`:return e.text.length===0?void 0:{text:e.text,thought:!0,thoughtSignature:e.providerOptions?.google?.thoughtSignature};case`file`:if(e.mediaType!==`image/png`)throw new t.UnsupportedFunctionalityError({functionality:`Only PNG images are supported in assistant messages`});if(e.data instanceof URL)throw new t.UnsupportedFunctionalityError({functionality:`File data URLs in assistant messages are not supported`});return{inlineData:{mimeType:e.mediaType,data:cn(e.data)}};case`tool-call`:return{functionCall:{name:e.toolName,args:e.input},thoughtSignature:e.providerOptions?.google?.thoughtSignature}}}).filter(e=>e!==void 0)});break;case`tool`:{a=!1;let e=[];for(let t of o){let n=t.output;if(n.type===`content`)for(let r of n.value)switch(r.type){case`text`:e.push({functionResponse:{name:t.toolName,response:{name:t.toolName,content:r.text}}});break;case`media`:e.push({inlineData:{mimeType:r.mediaType,data:r.data}},{text:`Tool executed successfully and returned this image as a response`});break;default:e.push({text:JSON.stringify(r)});break}else e.push({functionResponse:{name:t.toolName,response:{name:t.toolName,content:n.value}}})}i.push({role:`user`,parts:e});break}}if(o&&r.length>0&&i.length>0&&i[0].role===`user`){let e=r.map(e=>e.text).join(`
|
|
2
2
|
|
|
3
3
|
`);i[0].parts.unshift({text:e+`
|
|
4
4
|
|
|
@@ -36,143 +36,143 @@ Error message: ${dc(t)}`,cause:t}),this[Tc]=!0,this.value=e}static isInstance(e)
|
|
|
36
36
|
`));let r=e.pax;if(r)for(let e in r)n+=y(` `+e+`=`+r[e]+`
|
|
37
37
|
`);return t.from(n)},e.decodePax=function(e){let n={};for(;e.length;){let r=0;for(;r<e.length&&e[r]!==32;)r++;let i=parseInt(t.toString(e.subarray(0,r)),10);if(!i)return n;let a=t.toString(e.subarray(r+1,i-1)),o=a.indexOf(`=`);if(o===-1)return n;n[a.slice(0,o)]=a.slice(o+1),e=e.subarray(i)}return n},e.encode=function(e){let i=t.alloc(512),a=e.name,o=``;if(e.typeflag===5&&a[a.length-1]!==`/`&&(a+=`/`),t.byteLength(a)!==a.length)return null;for(;t.byteLength(a)>100;){let e=a.indexOf(`/`);if(e===-1)return null;o+=o?`/`+a.slice(0,e):a.slice(0,e),a=a.slice(e+1)}return t.byteLength(a)>100||t.byteLength(o)>155||e.linkname&&t.byteLength(e.linkname)>100?null:(t.write(i,a),t.write(i,p(e.mode&4095,6),100),t.write(i,p(e.uid,6),108),t.write(i,p(e.gid,6),116),h(e.size,i,124),t.write(i,p(e.mtime.getTime()/1e3|0,11),136),i[156]=48+u(e.type),e.linkname&&t.write(i,e.linkname,157),t.copy(n,i,257),t.copy(r,i,263),e.uname&&t.write(i,e.uname,265),e.gname&&t.write(i,e.gname,297),t.write(i,p(e.devmajor||0,6),329),t.write(i,p(e.devminor||0,6),337),o&&t.write(i,o,345),t.write(i,p(f(i),6),148),i)},e.decode=function(e,t,n){let r=e[156]===0?0:e[156]-48,i=v(e,0,100,t),a=_(e,100,8),c=_(e,108,8),u=_(e,116,8),d=_(e,124,12),p=_(e,136,12),m=l(r),h=e[157]===0?null:v(e,157,100,t),g=v(e,265,32),y=v(e,297,32),b=_(e,329,8),x=_(e,337,8),S=f(e);if(S===256)return null;if(S!==_(e,148,8))throw Error(`Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?`);if(o(e))e[345]&&(i=v(e,345,155,t)+`/`+i);else if(!s(e)&&!n)throw Error(`Invalid tar header: unknown format.`);return r===0&&i&&i[i.length-1]===`/`&&(r=5),{name:i,mode:a,uid:c,gid:u,size:d,mtime:new Date(1e3*p),type:m,linkname:h,uname:g,gname:y,devmajor:b,devminor:x,pax:null}};function o(e){return t.equals(n,e.subarray(257,263))}function s(e){return t.equals(i,e.subarray(257,263))&&t.equals(a,e.subarray(263,265))}function c(e,t,n){return typeof e==`number`?(e=~~e,e>=t?t:e>=0||(e+=t,e>=0)?e:0):n}function l(e){switch(e){case 0:return`file`;case 1:return`link`;case 2:return`symlink`;case 3:return`character-device`;case 4:return`block-device`;case 5:return`directory`;case 6:return`fifo`;case 7:return`contiguous-file`;case 72:return`pax-header`;case 55:return`pax-global-header`;case 27:return`gnu-long-link-path`;case 28:case 30:return`gnu-long-path`}return null}function u(e){switch(e){case`file`:return 0;case`link`:return 1;case`symlink`:return 2;case`character-device`:return 3;case`block-device`:return 4;case`directory`:return 5;case`fifo`:return 6;case`contiguous-file`:return 7;case`pax-header`:return 72}return 0}function d(e,t,n,r){for(;n<r;n++)if(e[n]===t)return n;return r}function f(e){let t=256;for(let n=0;n<148;n++)t+=e[n];for(let n=156;n<512;n++)t+=e[n];return t}function p(e,t){return e=e.toString(8),e.length>t?`7777777777777777777`.slice(0,t)+` `:`0000000000000000000`.slice(0,t-e.length)+e+` `}function m(e,t,n){t[n]=128;for(let r=11;r>0;r--)t[n+r]=e&255,e=Math.floor(e/256)}function h(e,n,r){e.toString(8).length>11?m(e,n,r):t.write(n,p(e,11),r)}function g(e){let t;if(e[0]===128)t=!0;else if(e[0]===255)t=!1;else return null;let n=[],r;for(r=e.length-1;r>0;r--){let i=e[r];t?n.push(i):n.push(255-i)}let i=0,a=n.length;for(r=0;r<a;r++)i+=n[r]*256**r;return t?i:-1*i}function _(e,n,r){if(e=e.subarray(n,n+r),n=0,e[n]&128)return g(e);{for(;n<e.length&&e[n]===32;)n++;let r=c(d(e,32,n,e.length),e.length,e.length);for(;n<r&&e[n]===0;)n++;return r===n?0:parseInt(t.toString(e.subarray(n,r)),8)}}function v(e,n,r,i){return t.toString(e.subarray(n,d(e,0,n,n+r)),i)}function y(e){let n=t.byteLength(e),r=Math.floor(Math.log(n)/Math.log(10))+1;return n+r>=10**r&&r++,n+r+e}})}),Nt=a.__commonJS({"../../node_modules/tar-stream/extract.js":((e,t)=>{let{Writable:n,Readable:r,getStreamError:i}=jt(),a=Et(),o=Dt(),s=Mt(),c=o.alloc(0);var l=class{constructor(){this.buffered=0,this.shifted=0,this.queue=new a,this._offset=0}push(e){this.buffered+=e.byteLength,this.queue.push(e)}shiftFirst(e){return this._buffered===0?null:this._next(e)}shift(e){if(e>this.buffered)return null;if(e===0)return c;let t=this._next(e);if(e===t.byteLength)return t;let n=[t];for(;(e-=t.byteLength)>0;)t=this._next(e),n.push(t);return o.concat(n)}_next(e){let t=this.queue.peek(),n=t.byteLength-this._offset;if(e>=n){let e=this._offset?t.subarray(this._offset,t.byteLength):t;return this.queue.shift(),this._offset=0,this.buffered-=n,this.shifted+=n,e}return this.buffered-=e,this.shifted+=e,t.subarray(this._offset,this._offset+=e)}},u=class extends r{constructor(e,t,n){super(),this.header=t,this.offset=n,this._parent=e}_read(e){this.header.size===0&&this.push(null),this._parent._stream===this&&this._parent._update(),e(null)}_predestroy(){this._parent.destroy(i(this))}_detach(){this._parent._stream===this&&(this._parent._stream=null,this._parent._missing=p(this.header.size),this._parent._update())}_destroy(e){this._detach(),e(null)}},d=class extends n{constructor(e){super(e),e||={},this._buffer=new l,this._offset=0,this._header=null,this._stream=null,this._missing=0,this._longHeader=!1,this._callback=f,this._locked=!1,this._finished=!1,this._pax=null,this._paxGlobal=null,this._gnuLongPath=null,this._gnuLongLinkPath=null,this._filenameEncoding=e.filenameEncoding||`utf-8`,this._allowUnknownFormat=!!e.allowUnknownFormat,this._unlockBound=this._unlock.bind(this)}_unlock(e){if(this._locked=!1,e){this.destroy(e),this._continueWrite(e);return}this._update()}_consumeHeader(){if(this._locked)return!1;this._offset=this._buffer.shifted;try{this._header=s.decode(this._buffer.shift(512),this._filenameEncoding,this._allowUnknownFormat)}catch(e){return this._continueWrite(e),!1}if(!this._header)return!0;switch(this._header.type){case`gnu-long-path`:case`gnu-long-link-path`:case`pax-global-header`:case`pax-header`:return this._longHeader=!0,this._missing=this._header.size,!0}return this._locked=!0,this._applyLongHeaders(),this._header.size===0||this._header.type===`directory`?(this.emit(`entry`,this._header,this._createStream(),this._unlockBound),!0):(this._stream=this._createStream(),this._missing=this._header.size,this.emit(`entry`,this._header,this._stream,this._unlockBound),!0)}_applyLongHeaders(){this._gnuLongPath&&=(this._header.name=this._gnuLongPath,null),this._gnuLongLinkPath&&=(this._header.linkname=this._gnuLongLinkPath,null),this._pax&&=(this._pax.path&&(this._header.name=this._pax.path),this._pax.linkpath&&(this._header.linkname=this._pax.linkpath),this._pax.size&&(this._header.size=parseInt(this._pax.size,10)),this._header.pax=this._pax,null)}_decodeLongHeader(e){switch(this._header.type){case`gnu-long-path`:this._gnuLongPath=s.decodeLongPath(e,this._filenameEncoding);break;case`gnu-long-link-path`:this._gnuLongLinkPath=s.decodeLongPath(e,this._filenameEncoding);break;case`pax-global-header`:this._paxGlobal=s.decodePax(e);break;case`pax-header`:this._pax=this._paxGlobal===null?s.decodePax(e):Object.assign({},this._paxGlobal,s.decodePax(e));break}}_consumeLongHeader(){this._longHeader=!1,this._missing=p(this._header.size);let e=this._buffer.shift(this._header.size);try{this._decodeLongHeader(e)}catch(e){return this._continueWrite(e),!1}return!0}_consumeStream(){let e=this._buffer.shiftFirst(this._missing);if(e===null)return!1;this._missing-=e.byteLength;let t=this._stream.push(e);return this._missing===0?(this._stream.push(null),t&&this._stream._detach(),t&&this._locked===!1):t}_createStream(){return new u(this,this._header,this._offset)}_update(){for(;this._buffer.buffered>0&&!this.destroying;){if(this._missing>0){if(this._stream!==null){if(this._consumeStream()===!1)return;continue}if(this._longHeader===!0){if(this._missing>this._buffer.buffered)break;if(this._consumeLongHeader()===!1)return!1;continue}let e=this._buffer.shiftFirst(this._missing);e!==null&&(this._missing-=e.byteLength);continue}if(this._buffer.buffered<512)break;if(this._stream!==null||this._consumeHeader()===!1)return}this._continueWrite(null)}_continueWrite(e){let t=this._callback;this._callback=f,t(e)}_write(e,t){this._callback=t,this._buffer.push(e),this._update()}_final(e){this._finished=this._missing===0&&this._buffer.buffered===0,e(this._finished?null:Error(`Unexpected end of data`))}_predestroy(){this._continueWrite(null)}_destroy(e){this._stream&&this._stream.destroy(i(this)),e(null)}[Symbol.asyncIterator](){let e=null,t=null,n=null,r=null,i=null,a=this;return this.on(`entry`,c),this.on(`error`,t=>{e=t}),this.on(`close`,l),{[Symbol.asyncIterator](){return this},next(){return new Promise(s)},return(){return u(null)},throw(e){return u(e)}};function o(e){if(!i)return;let t=i;i=null,t(e)}function s(i,s){if(e)return s(e);if(r){i({value:r,done:!1}),r=null;return}t=i,n=s,o(null),a._finished&&t&&(t({value:void 0,done:!0}),t=n=null)}function c(e,a,o){i=o,a.on(`error`,f),t?(t({value:a,done:!1}),t=n=null):r=a}function l(){o(e),t&&=(e?n(e):t({value:void 0,done:!0}),n=null)}function u(e){return a.destroy(e),o(e),new Promise((t,n)=>{if(a.destroyed)return t({value:void 0,done:!0});a.once(`close`,function(){e?n(e):t({value:void 0,done:!0})})})}}};t.exports=function(e){return new d(e)};function f(){}function p(e){return e&=511,e&&512-e}})}),Pt=a.__commonJS({"../../node_modules/tar-stream/constants.js":((e,t)=>{let n={S_IFMT:61440,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960};try{t.exports=G(`fs`).constants||n}catch{t.exports=n}})}),Ft=a.__commonJS({"../../node_modules/tar-stream/pack.js":((e,t)=>{let{Readable:n,Writable:r,getStreamError:i}=jt(),a=Dt(),o=Pt(),s=Mt(),c=a.alloc(1024);var l=class extends r{constructor(e,t,n){super({mapWritable:m,eagerOpen:!0}),this.written=0,this.header=t,this._callback=n,this._linkname=null,this._isLinkname=t.type===`symlink`&&!t.linkname,this._isVoid=t.type!==`file`&&t.type!==`contiguous-file`,this._finished=!1,this._pack=e,this._openCallback=null,this._pack._stream===null?this._pack._stream=this:this._pack._pending.push(this)}_open(e){this._openCallback=e,this._pack._stream===this&&this._continueOpen()}_continuePack(e){if(this._callback===null)return;let t=this._callback;this._callback=null,t(e)}_continueOpen(){this._pack._stream===null&&(this._pack._stream=this);let e=this._openCallback;if(this._openCallback=null,e!==null){if(this._pack.destroying)return e(Error(`pack stream destroyed`));if(this._pack._finalized)return e(Error(`pack stream is already finalized`));this._pack._stream=this,this._isLinkname||this._pack._encode(this.header),this._isVoid&&(this._finish(),this._continuePack(null)),e(null)}}_write(e,t){if(this._isLinkname)return this._linkname=this._linkname?a.concat([this._linkname,e]):e,t(null);if(this._isVoid)return e.byteLength>0?t(Error(`No body allowed for this entry`)):t();if(this.written+=e.byteLength,this._pack.push(e))return t();this._pack._drain=t}_finish(){this._finished||(this._finished=!0,this._isLinkname&&(this.header.linkname=this._linkname?a.toString(this._linkname,`utf-8`):``,this._pack._encode(this.header)),p(this._pack,this.header.size),this._pack._done(this))}_final(e){if(this.written!==this.header.size)return e(Error(`Size mismatch`));this._finish(),e(null)}_getError(){return i(this)||Error(`tar entry destroyed`)}_predestroy(){this._pack.destroy(this._getError())}_destroy(e){this._pack._done(this),this._continuePack(this._finished?null:this._getError()),e()}},u=class extends n{constructor(e){super(e),this._drain=f,this._finalized=!1,this._finalizing=!1,this._pending=[],this._stream=null}entry(e,t,n){if(this._finalized||this.destroying)throw Error(`already finalized or destroyed`);typeof t==`function`&&(n=t,t=null),n||=f,(!e.size||e.type===`symlink`)&&(e.size=0),e.type||=d(e.mode),e.mode||=e.type===`directory`?493:420,e.uid||=0,e.gid||=0,e.mtime||=new Date,typeof t==`string`&&(t=a.from(t));let r=new l(this,e,n);return a.isBuffer(t)?(e.size=t.byteLength,r.write(t),r.end(),r):(r._isVoid,r)}finalize(){if(this._stream||this._pending.length>0){this._finalizing=!0;return}this._finalized||(this._finalized=!0,this.push(c),this.push(null))}_done(e){e===this._stream&&(this._stream=null,this._finalizing&&this.finalize(),this._pending.length&&this._pending.shift()._continueOpen())}_encode(e){if(!e.pax){let t=s.encode(e);if(t){this.push(t);return}}this._encodePax(e)}_encodePax(e){let t=s.encodePax({name:e.name,linkname:e.linkname,pax:e.pax}),n={name:`PaxHeader`,mode:e.mode,uid:e.uid,gid:e.gid,size:t.byteLength,mtime:e.mtime,type:`pax-header`,linkname:e.linkname&&`PaxHeader`,uname:e.uname,gname:e.gname,devmajor:e.devmajor,devminor:e.devminor};this.push(s.encode(n)),this.push(t),p(this,t.byteLength),n.size=e.size,n.type=e.type,this.push(s.encode(n))}_doDrain(){let e=this._drain;this._drain=f,e()}_predestroy(){let e=i(this);for(this._stream&&this._stream.destroy(e);this._pending.length;){let t=this._pending.shift();t.destroy(e),t._continueOpen()}this._doDrain()}_read(e){this._doDrain(),e()}};t.exports=function(e){return new u(e)};function d(e){switch(e&o.S_IFMT){case o.S_IFBLK:return`block-device`;case o.S_IFCHR:return`character-device`;case o.S_IFDIR:return`directory`;case o.S_IFIFO:return`fifo`;case o.S_IFLNK:return`symlink`}return`file`}function f(){}function p(e,t){t&=511,t&&e.push(c.subarray(0,512-t))}function m(e){return a.isBuffer(e)?e:a.from(e)}})}),It=a.__commonJS({"../../node_modules/tar-stream/index.js":(e=>{e.extract=Nt(),e.pack=Ft()})}),Lt=a.__toESM(It(),1);let Rt=async(e,t)=>{let{maxBytes:n=50*1024*1024}=t??{};if(!(await o.stat(e)).isDirectory())throw Error(`Path is not a directory: ${e}`);let r=Lt.pack(),i=async(e,t=``)=>{let n=await o.readdir(e,{withFileTypes:!0});for(let a of n){let n=`${e}/${a.name}`,s=t?`${t}/${a.name}`:a.name;if(a.isDirectory()){r.entry({name:`${s}/`,type:`directory`}),await i(n,s);continue}if(a.isSymbolicLink?.()){let e=await o.readlink(n);r.entry({name:s,type:`symlink`,linkname:e});continue}if(a.isFile()){let e=await o.stat(n);await new Promise((t,i)=>{let a=(0,d.createReadStream)(n),o=r.entry({name:s,size:e.size,mode:e.mode,mtime:e.mtime},e=>{e&&i(e)});a.on(`error`,i),a.on(`data`,e=>o.write(e)),a.on(`end`,()=>{o.end(),t()})});continue}}};(async()=>{try{await i(e),r.finalize()}catch(e){r.destroy(e)}})();let a=r,s=0,c=!1;return new ReadableStream({start(e){a.on(`data`,t=>{if(!c){if(s+=t.length,s>n){c=!0,e.error(Error(`Archive exceeds size limit (${n} bytes). Emitted=${s} bytes.`));try{a.destroy()}catch{}return}e.enqueue(new Uint8Array(t))}}),a.once(`error`,t=>{c||(c=!0,e.error(t instanceof Error?t:Error(String(t))))}),a.once(`end`,()=>{c||(c=!0,e.close())})},cancel(){try{a.destroy()}catch{}}})},zt=(e,t)=>e.length<=t?e:e.slice(e.length-t),Bt=(e,t)=>{if(e.length===0)return{lines:[],truncated:!1};let n=0,r=e.length;for(let i=e.length-1;i>=0;i--){let a=e[i].length;if(n+a>t&&r!==e.length)break;n+=a,r=i}return r===0?{lines:e,truncated:!1}:{lines:e.slice(r),truncated:!0}};var Vt=class{constructor(e){this.decoder=new TextDecoder,this.encoder=new TextEncoder,this.createDeploymentFromTar=e.createDeploymentFromTar,this.proxyOnly=e.proxyOnly,this.fetchProxyRequest=e.fetchProxyRequest,this.multiplexer=new y({send:t=>{e.send(t)}}),this.multiplexer.onStream(e=>{this.handleStream(e)}),this.notificationStream=this.multiplexer.createStream(),this.processManager=new Ct({env:e.env,nodePty:e.nodePty}),this.processManager.onSpawn(e=>{let t=()=>{this.sendNotification({type:`process_status`,payload:{status:this.processManager.status(e.pid)}})};t(),e.terminal.onTitleChange(()=>{t()}),e.onExit(()=>{this.sendNotification({type:`process_status`,payload:{status:this.processManager.status(e.pid)}})}),e.onOutput(t=>{let n=g.getMaxPayloadSize()-1;for(let r=0;r<t.length;r+=n){let i=t.slice(r,r+n);this.sendNotification({type:`process_output`,payload:{pid:e.pid,output:i}})}})})}handleMessage(e){this.multiplexer.handleMessage(e)}handleStream(e){let t=new AbortController;e.onClose(()=>{t.abort()}),e.onData(n=>{let r=n[0],i=n.subarray(1);switch(r){case a.ClientMessageType.REQUEST:{let n=JSON.parse(this.decoder.decode(i));if(this.proxyOnly){this.sendResponse(e,{id:n.id,error:`This server is in proxy only mode.`});return}this.handleRequest(e,n,t.signal).catch(t=>{this.sendResponse(e,{id:n.id,error:t instanceof Error?t.message:String(t)})});break}case a.ClientMessageType.PROXY_INIT:{let t=a.ClientMessageSchema[a.ClientMessageType.PROXY_INIT].safeParse(JSON.parse(this.decoder.decode(i)));if(!t.success)throw Error(`Invalid proxy init message`);let n;n=t.data.headers.upgrade===`websocket`?this.handleProxyWebSocket(e,t.data):this.handleProxyRequest(e,t.data),n.catch(t=>{e.error(t.message)});break}}})}async handleProxyWebSocket(e,t){let n=new URL(t.url);n.protocol===`http:`?n.protocol=`ws:`:n.protocol===`https:`&&(n.protocol=`wss:`);let r=new u.WebSocket(n.toString(),t.headers[`sec-websocket-protocol`]?t.headers[`sec-websocket-protocol`]:void 0,{headers:t.headers,perMessageDeflate:!1});r.addEventListener(`open`,()=>{e.writeTyped(a.ServerMessageType.PROXY_INIT,this.encoder.encode(JSON.stringify({status_code:101,status_message:`Switching Protocols`,headers:{}})))}),r.addEventListener(`message`,t=>{e.disposed||e.writeTyped(a.ServerMessageType.PROXY_WEBSOCKET_MESSAGE,a.createWebSocketMessagePayload(t.data,this.encoder))}),r.addEventListener(`close`,t=>{if(e.disposed)return;let n={code:t.code,reason:t.reason};e.writeTyped(a.ServerMessageType.PROXY_WEBSOCKET_CLOSE,this.encoder.encode(JSON.stringify(n))),e.close()}),r.addEventListener(`error`,e=>{console.log(`err`,e)}),e.onClose(()=>{r.close()}),e.onError(e=>{r.close(1011,e)}),e.onData(t=>{let n=t.subarray(1);switch(t[0]){case a.ClientMessageType.PROXY_WEBSOCKET_MESSAGE:{let e=a.parseWebSocketMessagePayload(n,this.decoder);r.send(e);break}case a.ClientMessageType.PROXY_WEBSOCKET_CLOSE:{let e=a.ClientMessageSchema[a.ClientMessageType.PROXY_WEBSOCKET_CLOSE].safeParse(JSON.parse(this.decoder.decode(n)));if(!e.success)throw Error(`Invalid proxy websocket close message`);try{r.close(e.data.code,e.data.reason)}catch(t){console.error(`Error closing websocket`,t,e.data)}break}default:e.error(`Unexpected message type: ${t[0]}`)}})}async handleProxyRequest(e,t){let n,r;if(t.method!==`GET`&&t.method!==`HEAD`&&t.method!==`OPTIONS`){let e=new TransformStream;n=e.writable.getWriter(),r=e.readable}e.onData(t=>{switch(t[0]){case a.ClientMessageType.PROXY_BODY:if(n){let e=t.subarray(1);e.length===0?n.close():n.write(e)}break;default:e.error(`Unexpected message type: ${t[0]}`)}});let i={headers:t.headers,method:t.method,body:r},o;o=this.fetchProxyRequest?await this.fetchProxyRequest(t.url,i):await fetch(t.url,i);let s={};o.headers.forEach((e,t)=>{s[t]=e});let c={headers:s,status_code:o.status,status_message:o.statusText};e.writeTyped(a.ServerMessageType.PROXY_INIT,this.encoder.encode(JSON.stringify(c)));let l=o.headers.get(`content-length`),u=l?parseInt(l):0,d=g.getMaxPayloadSize()-1;if(u>=d){if(!o.body){e.close();return}let t=o.body.getReader();try{for(;;){let{done:n,value:r}=await t.read();if(n)break;if(r){let t=0;for(;t<r.length;){let n=Math.min(d,r.length-t),i=r.subarray(t,t+n);e.writeTyped(a.ServerMessageType.PROXY_DATA,i),t+=n}}}}finally{t.releaseLock()}}else o.body&&await o.body.pipeTo(new WritableStream({write:t=>{e.writeTyped(a.ServerMessageType.PROXY_DATA,t)}}));e.close()}async handleRequest(e,t,n){let r=a.RequestSchema[t.type].safeParse(t.payload);if(!r.success)throw Error(`Invalid request payload: ${r.error.message}`);switch(t.type){case`process_execute`:{let n=this.processManager.execute(t.payload.command,t.payload.args,{cwd:t.payload.cwd,env:t.payload.env});this.sendResponse(e,{id:t.id,payload:{pid:n.pid}});break}case`process_wait`:this.handleProcessWait(e,t,n);break;case`process_kill`:this.mustGetProcess(t.payload.pid).kill(t.payload.signal),this.sendResponse(e,{id:t.id,payload:{}});break;case`process_list`:this.sendResponse(e,{id:t.id,payload:{processes:this.processManager.list(t.payload.include_dead??!1)}});break;case`process_read_plain_output`:{let n=this.mustGetProcess(t.payload.pid),r=this.processManager.readPlainOutput(t.payload.pid,t.payload.start_line,t.payload.end_line),i=Bt(r.lines,256e3);this.sendResponse(e,{id:t.id,payload:{lines:i.lines,total_lines:r.totalLines,duration_ms:Date.now()-n.startTimeMS,exit_code:n.exitCode,exit_signal:n.exitSignal}});break}case`process_send_input`:this.mustGetProcess(t.payload.pid).sendInput(t.payload.data),this.sendResponse(e,{id:t.id,payload:{}});break;case`set_env`:this.processManager.setEnv(t.payload.env),this.sendResponse(e,{id:t.id,payload:{}});break;case`deploy_static_files`:{if(!this.createDeploymentFromTar)throw Error(`This server does not support static file deployments!`);let n=await Rt(t.payload.path),r=await this.createDeploymentFromTar(n);this.sendResponse(e,{id:t.id,payload:{deployment_id:r}});break}case`read_file`:{let n=await c.readFile(t.payload.path),r=await ht(n);if(!(!r||r?.mime===`text/plain`)){this.sendResponse(e,{id:t.id,payload:{content:n.toString(`base64`),mime_type:r?.mime,total_lines:0,lines_read:0,start_line:0}});break}let i=n.toString(`utf-8`).split(`
|
|
38
38
|
`),a=(t.payload.line_start??1)-1,o=t.payload.line_end??i.length,s=i.slice(a,o);this.sendResponse(e,{id:t.id,payload:{content:s.join(`
|
|
39
|
-
`),mime_type:`text/plain`,total_lines:i.length,lines_read:s.length,start_line:a}});break}case`write_file`:t.payload.base64?await c.writeFile(t.payload.path,Buffer.from(t.payload.content,`base64`)):await c.writeFile(t.payload.path,t.payload.content),typeof t.payload.mode==`number`&&await c.chmod(t.payload.path,t.payload.mode),this.sendResponse(e,{id:t.id,payload:{}});break;case`read_directory`:{let n=await c.readdir(t.payload.path,{withFileTypes:!0});this.sendResponse(e,{id:t.id,payload:{entries:n.map(e=>({name:e.name,type:e.isDirectory()?`directory`:e.isSymbolicLink()?`symlink`:`file`}))}});break}default:throw Error(`Unknown request type: ${t.type}`)}}sendResponse(e,t){e.writeTyped(a.ServerMessageType.RESPONSE,this.encoder.encode(JSON.stringify(t)))}sendNotification(e){this.notificationStream.write(new Uint8Array([a.ServerMessageType.NOTIFICATION,...this.encoder.encode(JSON.stringify(e))]))}handleProcessWait(e,t,n){let r=t.payload,i=this.mustGetProcess(r.pid),a,o,s=!1,c,l;typeof r.timeout_ms==`number`&&(l=setTimeout(()=>{u()},r.timeout_ms));let u=()=>{if(s||(s=!0,a&&a.dispose(),o&&o.dispose(),l&&clearTimeout(l),c&&clearTimeout(c),n?.aborted))return;let i=this.processManager.status(r.pid),u=this.processManager.readPlainOutput(i.pid),d=zt(this.processManager.readANSIOutput(i.pid),64e3),f=Bt(u.lines,256e3);this.sendResponse(e,{id:t.id,payload:{...i,ansi_output:d,plain_output:{lines:f.lines,total_lines:u.totalLines}}})};if(typeof i.exitCode==`number`||typeof i.exitSignal==`number`){u();return}a=i.onOutput(()=>{c&&clearTimeout(c),typeof r.output_idle_timeout_ms==`number`&&(c=setTimeout(()=>{u()},r.output_idle_timeout_ms))}),o=i.onExit(()=>{setTimeout(()=>{u()},10)}),n.addEventListener(`abort`,()=>{u()})}mustGetProcess(e){let t=this.processManager.getProcess(e);if(!t)throw Error(`Process ${e} not found`);return t}};Object.defineProperty(e,`Multiplexer`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,`Server`,{enumerable:!0,get:function(){return Vt}})})}),ed=W({"../../node_modules/@blink-sdk/compute-protocol/dist/server.cjs":(e=>{Ru(),e.Server=$u().Server})}),td=class{constructor(e){this.client=e}listen(e){let t,n,r=!1,i=1e4,a=250,o=()=>{n&&=(clearTimeout(n),void 0)},s=()=>{if(r)return;o();let e=a*.2*Math.random(),t=Math.min(i,Math.floor(a+e));n=setTimeout(()=>{f()},t),a=Math.min(i,Math.floor(a*1.5))},c=()=>{a=250},{Server:l}=ed(),u=new l({send:e=>{let n=t;!n||n.readyState!==WebSocket.OPEN||n.send(e)},fetchProxyRequest(t,n){return e.onRequest(new Request(t,{...n,duplex:n.body?`half`:void 0}))}}),d=t=>{t.binaryType=`arraybuffer`,t.addEventListener(`open`,()=>{r||(c(),e.onConnect?.())}),t.addEventListener(`close`,()=>{r||(e.onDisconnect?.(),s())}),t.addEventListener(`error`,n=>{try{e.onError?.(n)}catch{}try{t.close()}catch{}}),t.addEventListener(`message`,e=>{if(typeof e.data==`string`){console.warn(`Message skipped because it is not a buffer.`);return}try{u.handleMessage(new Uint8Array(e.data))}catch(e){console.error(`message handler error`,e);try{t.close(1011)}catch{}}})},f=()=>{if(!r)try{let n=this.client.websocket(`/api/devhook/${e.id}`);t=n,d(n)}catch(t){try{e.onError?.(t)}catch{}s()}};return f(),{dispose:()=>{if(r)return;r=!0,o();let e=t;t=void 0;try{e&&(e.readyState===WebSocket.OPEN||e.readyState===WebSocket.CONNECTING)&&e.close(1e3)}catch{}}}}};let nd=function(e){return e[e.REQUEST=0]=`REQUEST`,e[e.PROXY_INIT=1]=`PROXY_INIT`,e[e.PROXY_BODY=2]=`PROXY_BODY`,e[e.PROXY_WEBSOCKET_MESSAGE=3]=`PROXY_WEBSOCKET_MESSAGE`,e[e.PROXY_WEBSOCKET_CLOSE=4]=`PROXY_WEBSOCKET_CLOSE`,e}({}),rd=function(e){return e[e.RESPONSE=0]=`RESPONSE`,e[e.NOTIFICATION=1]=`NOTIFICATION`,e[e.PROXY_INIT=2]=`PROXY_INIT`,e[e.PROXY_DATA=3]=`PROXY_DATA`,e[e.PROXY_WEBSOCKET_MESSAGE=4]=`PROXY_WEBSOCKET_MESSAGE`,e[e.PROXY_WEBSOCKET_CLOSE=5]=`PROXY_WEBSOCKET_CLOSE`,e}({});nd.REQUEST,y.z.string(),nd.PROXY_INIT,y.z.object({method:y.z.string(),headers:y.z.record(y.z.string(),y.z.string()),url:y.z.string()}),nd.PROXY_BODY,y.z.instanceof(Uint8Array),nd.PROXY_WEBSOCKET_MESSAGE,y.z.object({type:y.z.enum([`text`,`binary`]),data:y.z.instanceof(Uint8Array)}),nd.PROXY_WEBSOCKET_CLOSE,y.z.object({code:y.z.number().optional(),reason:y.z.string().optional()}),rd.RESPONSE,y.z.string(),rd.NOTIFICATION,y.z.string(),rd.PROXY_INIT,y.z.object({status_code:y.z.number(),status_message:y.z.string(),headers:y.z.record(y.z.string(),y.z.string())}),rd.PROXY_DATA,y.z.instanceof(Uint8Array),rd.PROXY_WEBSOCKET_MESSAGE,y.z.instanceof(Uint8Array),rd.PROXY_WEBSOCKET_CLOSE,y.z.object({code:y.z.number(),reason:y.z.string()}),nd.PROXY_INIT,y.z.string(),y.z.record(y.z.string(),y.z.string()),y.z.string(),y.z.object({command:y.z.string(),args:y.z.array(y.z.string()),env:y.z.record(y.z.string(),y.z.string()).optional(),cwd:y.z.string().optional()}),y.z.object({pid:y.z.number(),data:y.z.string()}),y.z.object({pid:y.z.number(),output_idle_timeout_ms:y.z.number().optional(),timeout_ms:y.z.number().optional()}),y.z.object({include_dead:y.z.boolean().optional()}),y.z.object({pid:y.z.number(),start_line:y.z.number().optional(),end_line:y.z.number().optional()}),y.z.object({pid:y.z.number(),signal:y.z.string().optional()}),y.z.object({env:y.z.record(y.z.string(),y.z.string())}),y.z.object({path:y.z.string(),line_start:y.z.number().optional(),line_end:y.z.number().optional()}),y.z.object({path:y.z.string(),content:y.z.string(),base64:y.z.boolean().optional(),mode:y.z.number().optional()}),y.z.object({path:y.z.string()}),y.z.object({path:y.z.string()}),y.z.object({path:y.z.string()});const id=y.z.object({pid:y.z.number(),command:y.z.string(),args:y.z.array(y.z.string()),title:y.z.string().optional(),cwd:y.z.string(),env:y.z.record(y.z.string(),y.z.string()),exit_code:y.z.number().optional(),exit_signal:y.z.number().optional(),duration_ms:y.z.number().optional(),output_total_lines:y.z.number()});id.extend({ansi_output:y.z.string(),plain_output:y.z.object({lines:y.z.array(y.z.string()),total_lines:y.z.number()})}),y.z.object({pid:y.z.number()}),y.z.object({}),y.z.object({processes:y.z.array(id)}),y.z.object({lines:y.z.array(y.z.string()),total_lines:y.z.number(),duration_ms:y.z.number(),exit_code:y.z.number().optional(),exit_signal:y.z.number().optional()}),y.z.object({}),y.z.object({}),y.z.object({total_lines:y.z.number(),lines_read:y.z.number(),start_line:y.z.number(),content:y.z.string(),mime_type:y.z.string()}),y.z.object({}),y.z.object({entries:y.z.array(y.z.object({name:y.z.string(),type:y.z.enum([`file`,`directory`,`symlink`])}))}),y.z.object({}),y.z.object({deployment_id:y.z.string()});const ad=y.z.object({type:y.z.enum([`create`,`update`,`delete`]),path:y.z.string()}),od=y.z.object({type:y.z.enum([`context`,`added`,`deleted`]),content:y.z.string(),oldLineNumber:y.z.number().optional(),newLineNumber:y.z.number().optional()}),sd=y.z.object({oldStart:y.z.number(),oldLines:y.z.number(),newStart:y.z.number(),newLines:y.z.number(),lines:y.z.array(od)}),cd=y.z.object({path:y.z.string(),status:y.z.enum([`added`,`modified`,`deleted`,`renamed`,`copied`,`untracked`,`ignored`,`unmerged`,`typechange`]),oldPath:y.z.string().optional(),insertions:y.z.number(),deletions:y.z.number(),chunks:y.z.array(sd)}),ld=y.z.object({totalFiles:y.z.number(),totalInsertions:y.z.number(),totalDeletions:y.z.number(),netChange:y.z.number(),startHash:y.z.string().optional(),currentHash:y.z.string().optional(),timespan:y.z.number(),files:y.z.array(cd)}),ud=y.z.object({path:y.z.string(),status:y.z.enum([`added`,`modified`,`deleted`,`renamed`,`copied`,`untracked`,`ignored`,`unmerged`,`typechange`]),staged:y.z.boolean()}),dd=y.z.object({hash:y.z.string(),shortHash:y.z.string(),message:y.z.string(),author:y.z.string(),email:y.z.string(),date:y.z.date(),timestamp:y.z.date(),filesChanged:y.z.number(),insertions:y.z.number(),deletions:y.z.number(),commitDiff:y.z.array(cd).optional()});y.z.object({files:y.z.array(ud),branch:y.z.string(),ahead:y.z.number(),behind:y.z.number(),timestamp:y.z.date(),sessionDiff:ld.optional(),workingDirectoryDiff:ld.optional(),newCommits:y.z.array(dd),currentCommit:y.z.object({hash:y.z.string(),shortHash:y.z.string(),message:y.z.string(),author:y.z.string(),date:y.z.date()}).optional(),diffSkipped:y.z.boolean().optional(),payloadTruncated:y.z.boolean().optional(),estimatedSizeKB:y.z.number().optional()}),y.z.object({debounceDelay:y.z.number().optional(),gitStatusInterval:y.z.number().optional(),ignoreDotfiles:y.z.boolean().optional(),ignored:y.z.array(y.z.string()).optional(),watchGit:y.z.boolean().optional(),includeDiffs:y.z.boolean().optional(),maxDiffFiles:y.z.number().optional(),maxPayloadSizeKB:y.z.number().optional(),truncateLargeDiffs:y.z.boolean().optional()}),y.z.object({status:id}),y.z.object({pid:y.z.number(),output:y.z.string()}),y.z.object({changes:y.z.array(ad)});var fd=class{constructor({send:e,jwt:t,requestTimeoutMS:n}){this.notificationCallbacks=new Map,this.disposables=[],this.requestHandlers=new Map,this.send=e,this.jwt=t,this.requestTimeoutMS=n}handleMessage(e){if(typeof e!=`string`)return;let t=JSON.parse(e);if(`id`in t){let e=this.requestHandlers.get(t.id);if(!e)return;e(t.payload,t.error)}else if(`type`in t)this.notificationCallbacks.get(t.type)?.forEach(e=>{e(t.payload)});else return}dispose(e){this.disposables.forEach(t=>t.dispose(e))}async request(e,t,n){let r=crypto.randomUUID(),i,a,o=new Promise((e,t)=>{i=e,a=t}),s={dispose:e=>{l();let t=`Client was disposed!`;e&&(t+=` Reason: ${e}`),a(Error(t))}};this.disposables.push(s);let c;this.requestTimeoutMS&&(c=setTimeout(()=>{a(Error(`Request timed out`))},this.requestTimeoutMS));let l=()=>{this.disposables.splice(this.disposables.indexOf(s),1),this.requestHandlers.delete(r),c&&clearTimeout(c)};n?.signal&&n.signal.addEventListener(`abort`,()=>{l(),a(n.signal?.reason)}),this.requestHandlers.set(r,(e,t)=>{if(l(),t)return a(Error(t));i(e)});let u={id:r,type:e,payload:t,jwt:this.jwt};return this.send(JSON.stringify(u)),o}onNotification(e,t){let n=this.notificationCallbacks.get(e)??[];return n.push(t),this.notificationCallbacks.set(e,n),{dispose:()=>{let n=this.notificationCallbacks.get(e)??[],r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}};y.z.object({}),y.z.object({id:y.z.string(),token:y.z.string()});var pd=class{constructor(e){this.client=e}async token(){let e=await this.client.request(`POST`,`/api/tools/compute`);return await K(e,201),e.json()}async connect(e){let t=this.client.websocket(`/api/tools/compute/connect?id=${e}`);return new fd({send:e=>t.send(e)})}},md=class{constructor(e){this.client=e,this.compute=new pd(this.client)}},hd=class extends Lu{constructor(e){super({...e,baseURL:e?.baseURL??process.env.BLINK_API_URL}),this.devhook=new td(this),this.tools=new md(this)}},gd=e.__commonJSMin((e=>{e.__esModule=!0;function t(e){return i(e)===`boolean`}function n(e){return i(e)===`object`}function r(e){return i(e)===`string`}function i(e){return typeof e}function a(e){var i=e.meta,a=e.path,o=e.xdg;return{XDGAppPaths:new(function(){function e(s){s===void 0&&(s={});function c(t){return t===void 0&&(t={}),new e(t)}var l=n(s)?s:{name:s},u=l.suffix??``,d=l.isolated??!0,f=[l.name,i.pkgMainFilename(),i.mainFilename()],p=a.parse((f.find(function(e){return r(e)})??`$eval`)+u).name;c.$name=function(){return p},c.$isolated=function(){return d};function m(e){return e??={isolated:d},t(e)?e:e.isolated??d}function h(e){return m(e)?p:``}return c.cache=function(e){return a.join(o.cache(),h(e))},c.config=function(e){return a.join(o.config(),h(e))},c.data=function(e){return a.join(o.data(),h(e))},c.runtime=function(e){return o.runtime()?a.join(o.runtime(),h(e)):void 0},c.state=function(e){return a.join(o.state(),h(e))},c.configDirs=function(e){return o.configDirs().map(function(t){return a.join(t,h(e))})},c.dataDirs=function(e){return o.dataDirs().map(function(t){return a.join(t,h(e))})},c}return e}())}}e.Adapt=a})),_d=e.__commonJSMin((e=>{var t=e&&e.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};e.__esModule=!0;function n(e){var n=e.env,r=e.osPaths,i=e.path,a=/^darwin$/i.test(e.process.platform),o=/^win/i.test(e.process.platform);function s(){return r.home()||r.temp()}function c(e,t){return e||i.join.apply(i,t)}var l=function(){return{cache:function(){return c(n.get(`XDG_CACHE_HOME`),[s(),`.cache`])},config:function(){return c(n.get(`XDG_CONFIG_HOME`),[s(),`.config`])},data:function(){return c(n.get(`XDG_DATA_HOME`),[s(),`.local`,`share`])},runtime:function(){return n.get(`XDG_RUNTIME_DIR`)||void 0},state:function(){return c(n.get(`XDG_STATE_HOME`),[s(),`.local`,`state`])}}},u=function(){return{cache:function(){return c(n.get(`XDG_CACHE_HOME`),[s(),`Library`,`Caches`])},config:function(){return c(n.get(`XDG_CONFIG_HOME`),[s(),`Library`,`Preferences`])},data:function(){return c(n.get(`XDG_DATA_HOME`),[s(),`Library`,`Application Support`])},runtime:function(){return n.get(`XDG_RUNTIME_DIR`)||void 0},state:function(){return c(n.get(`XDG_STATE_HOME`),[s(),`Library`,`State`])}}},d=function(){function e(){return c(n.get(`APPDATA`),[s(),`AppData`,`Roaming`])}function t(){return c(n.get(`LOCALAPPDATA`),[s(),`AppData`,`Local`])}return{cache:function(){return c(n.get(`XDG_CACHE_HOME`),[t(),`xdg.cache`])},config:function(){return c(n.get(`XDG_CONFIG_HOME`),[e(),`xdg.config`])},data:function(){return c(n.get(`XDG_DATA_HOME`),[e(),`xdg.data`])},runtime:function(){return n.get(`XDG_RUNTIME_DIR`)||void 0},state:function(){return c(n.get(`XDG_STATE_HOME`),[t(),`xdg.state`])}}};return{XDG:new(function(){function e(){function r(){return new e}var s=a?u():o?d():l();return r.cache=s.cache,r.config=s.config,r.data=s.data,r.runtime=s.runtime,r.state=s.state,r.configDirs=function(){var e=n.get(`XDG_CONFIG_DIRS`);return t([s.config()],e?e.split(i.delimiter):[])},r.dataDirs=function(){var e=n.get(`XDG_DATA_DIRS`);return t([s.data()],e?e.split(i.delimiter):[])},r}return e}())}}e.Adapt=n})),vd=e.__commonJSMin((e=>{var t=e&&e.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};e.__esModule=!0;function n(e){return!e}function r(e){var r=e.env,i=e.os,a=e.path,o=/^win/i.test(e.process.platform);function s(t){return t?e.path.normalize(e.path.join(t,`.`)):void 0}function c(){return o?function(){var e=[typeof i.homedir==`function`?i.homedir():void 0,r.get(`USERPROFILE`),r.get(`HOME`),r.get(`HOMEDRIVE`)||r.get(`HOMEPATH`)?a.join(r.get(`HOMEDRIVE`)||``,r.get(`HOMEPATH`)||``):void 0];return s(e.find(function(e){return!n(e)}))}():function(){return s((typeof i.homedir==`function`?i.homedir():void 0)||r.get(`HOME`))}()}function l(){function e(e,n){return e?a.join.apply(a,t([e],n)):void 0}function l(){var e=`/tmp`,t=[typeof i.tmpdir==`function`?i.tmpdir():void 0,r.get(`TMPDIR`),r.get(`TEMP`),r.get(`TMP`)];return s(t.find(function(e){return!n(e)}))||e}function u(){var t=`C:\\Temp`,a=[typeof i.tmpdir==`function`?i.tmpdir:function(){},function(){return r.get(`TEMP`)},function(){return r.get(`TMP`)},function(){return e(r.get(`LOCALAPPDATA`),[`Temp`])},function(){return e(c(),[`AppData`,`Local`,`Temp`])},function(){return e(r.get(`ALLUSERSPROFILE`),[`Temp`])},function(){return e(r.get(`SystemRoot`),[`Temp`])},function(){return e(r.get(`windir`),[`Temp`])},function(){return e(r.get(`SystemDrive`),[`\\`,`Temp`])}].find(function(e){return e&&!n(e())});return a&&s(a())||t}return o?u():l()}return{OSPaths:new(function(){function e(){function t(){return new e}return t.home=c,t.temp=l,t}return e}())}}e.Adapt=r})),yd=e.__commonJSMin((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};e.__esModule=!0;var i=r(require(`os`)),a=r(require(`path`));e.adapter={atImportPermissions:{env:!0},env:{get:function(e){return process.env[e]}},os:i,path:a,process}})),bd=e.__commonJSMin(((e,t)=>{var n=vd(),r=yd();t.exports=n.Adapt(r.adapter).OSPaths})),xd=e.__export({default:()=>wd}),Sd,Cd,wd,Td=e.__esmMin((()=>{Sd=e.__toESM(bd()),Cd=Sd.default,wd=Cd})),Ed=e.__commonJSMin((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},a=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0;var o=i(require(`path`));t.adapter={atImportPermissions:{env:!0},env:{get:function(e){return process.env[e]}},osPaths:a((Td(),e.__toCommonJS(xd))).default,path:o,process}})),Dd=e.__commonJSMin(((e,t)=>{var n=_d(),r=Ed();t.exports=n.Adapt(r.adapter).XDG})),Od=e.__export({default:()=>Ad}),kd,Ad,jd=e.__esmMin((()=>{kd=e.__toESM(Dd()),e.__reExport(Od,e.__toESM(Dd())),Ad=kd.default})),Md=e.__commonJSMin((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},a=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0;var o=i(require(`path`)),s=a((jd(),e.__toCommonJS(Od)));t.adapter={atImportPermissions:{env:!0,read:!0},meta:{mainFilename:function(){var e=(typeof require<`u`&&require!==null&&require.main?require.main:{filename:void 0}).filename;return(e===process.execArgv[0]?void 0:e)||(process._eval===void 0?process.argv[1]:void 0)},pkgMainFilename:function(){return process.pkg?process.execPath:void 0}},path:o,process,xdg:s.default}})),Nd=e.__commonJSMin(((e,t)=>{var n=gd(),r=Md();t.exports=n.Adapt(r.adapter).XDGAppPaths})),Pd=e.__toESM(Nd()),Fd=Pd.default;const Id=10,Ld=(e=0)=>t=>`\u001B[${t+e}m`,Rd=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,zd=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,q={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Bd=Object.keys(q.modifier),Vd=Object.keys(q.color),Hd=Object.keys(q.bgColor),Ud=[...Vd,...Hd];function Wd(){let e=new Map;for(let[t,n]of Object.entries(q)){for(let[t,r]of Object.entries(n))q[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=q[t],e.set(r[0],r[1]);Object.defineProperty(q,t,{value:n,enumerable:!1})}return Object.defineProperty(q,`codes`,{value:e,enumerable:!1}),q.color.close=`\x1B[39m`,q.bgColor.close=`\x1B[49m`,q.color.ansi=Ld(),q.color.ansi256=Rd(),q.color.ansi16m=zd(),q.bgColor.ansi=Ld(10),q.bgColor.ansi256=Rd(10),q.bgColor.ansi16m=zd(10),Object.defineProperties(q,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>q.rgbToAnsi256(...q.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>q.ansi256ToAnsi(q.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>q.ansi256ToAnsi(q.hexToAnsi256(e)),enumerable:!1}}),q}const Gd=Wd();var Kd=Gd;function qd(e,t=globalThis.Deno?globalThis.Deno.args:x.default.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}const{env:J}=x.default;let Jd;qd(`no-color`)||qd(`no-colors`)||qd(`color=false`)||qd(`color=never`)?Jd=0:(qd(`color`)||qd(`colors`)||qd(`color=true`)||qd(`color=always`))&&(Jd=1);function Yd(){if(`FORCE_COLOR`in J)return J.FORCE_COLOR===`true`?1:J.FORCE_COLOR===`false`?0:J.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(J.FORCE_COLOR,10),3)}function Xd(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Zd(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=Yd();r!==void 0&&(Jd=r);let i=n?Jd:r;if(i===0)return 0;if(n){if(qd(`color=16m`)||qd(`color=full`)||qd(`color=truecolor`))return 3;if(qd(`color=256`))return 2}if(`TF_BUILD`in J&&`AGENT_NAME`in J)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(J.TERM===`dumb`)return a;if(x.default.platform===`win32`){let e=S.default.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in J)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in J)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in J)||J.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in J)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(J.TEAMCITY_VERSION)?1:0;if(J.COLORTERM===`truecolor`||J.TERM===`xterm-kitty`||J.TERM===`xterm-ghostty`||J.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in J){let e=Number.parseInt((J.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(J.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(J.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(J.TERM)||`COLORTERM`in J?1:a}function Qd(e,t={}){let n=Zd(e,{streamIsTTY:e&&e.isTTY,...t});return Xd(n)}const $d={stdout:Qd({isTTY:C.default.isatty(1)}),stderr:Qd({isTTY:C.default.isatty(2)})};var ef=$d;function tf(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function nf(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
`);return a!==-1&&(t=nf(t,i,r,a)),r+t+i};Object.defineProperties(mf.prototype,df);const bf=mf(),xf=mf({level:af?af.level:0});var Sf=bf,Cf=e.__commonJSMin(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),wf=e.__commonJSMin(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),Tf=e.__toESM(Cf(),1),Ef=e.__toESM(wf(),1);function Df({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const Of=Df();function kf(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(Of,``)}function Af(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var jf={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-(u==2?1:0))if(o+u<=i)a+=l;else break;o+=u}return a}})(jf);var Mf=jf.exports;const Nf=Af(Mf);var Pf=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g};const Ff=Af(Pf);function If(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=kf(e),e.length===0))return 0;e=e.replace(Ff(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(Nf.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}const Lf=10,Rf=(e=0)=>t=>`\x1B[${t+e}m`,zf=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Bf=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,Y={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(Y.modifier);const Vf=Object.keys(Y.color),Hf=Object.keys(Y.bgColor);[...Vf,...Hf];function Uf(){let e=new Map;for(let[t,n]of Object.entries(Y)){for(let[t,r]of Object.entries(n))Y[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=Y[t],e.set(r[0],r[1]);Object.defineProperty(Y,t,{value:n,enumerable:!1})}return Object.defineProperty(Y,`codes`,{value:e,enumerable:!1}),Y.color.close=`\x1B[39m`,Y.bgColor.close=`\x1B[49m`,Y.color.ansi=Rf(),Y.color.ansi256=zf(),Y.color.ansi16m=Bf(),Y.bgColor.ansi=Rf(10),Y.bgColor.ansi256=zf(10),Y.bgColor.ansi16m=Bf(10),Object.defineProperties(Y,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>Y.rgbToAnsi256(...Y.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>Y.ansi256ToAnsi(Y.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>Y.ansi256ToAnsi(Y.hexToAnsi256(e)),enumerable:!1}}),Y}const Wf=Uf(),Gf=new Set([`\x1B`,``]),Kf=39,qf=`\x07`,Jf=`[`,Yf=`]`,Xf=`m`,Zf=`]8;;`,Qf=e=>`${Gf.values().next().value}[${e}m`,$f=e=>`${Gf.values().next().value}${Zf}${e}`,ep=e=>e.split(` `).map(e=>If(e)),tp=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=If(kf(e[e.length-1]));for(let[t,s]of r.entries()){let c=If(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),Gf.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(Zf)),i){a?s===`\x07`&&(i=!1,a=!1):s===`m`&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},np=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(If(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},rp=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=ep(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=If(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),tp(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){tp(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){tp(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>np(e)));let c=[...s.join(`
|
|
44
|
-
`)];for(let[e,t]of c.entries()){if(r+=t,Gf.has(t)){let{groups:t}=RegExp(`(?:\\[(?<code>\\d+)m|\\${Zf}(?<uri>.*))`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=Wf.codes.get(Number(i));c[e+1]===`
|
|
45
|
-
`?(a&&(r+=$f(``)),i&&n&&(r+=Qf(n))):t===`
|
|
46
|
-
`&&(i&&n&&(r+=Qf(i)),a&&(r+=$f(a)))}return r};function ip(e,t,n){return String(e).normalize().replace(/\r\n/g,`
|
|
39
|
+
`),mime_type:`text/plain`,total_lines:i.length,lines_read:s.length,start_line:a}});break}case`write_file`:t.payload.base64?await c.writeFile(t.payload.path,Buffer.from(t.payload.content,`base64`)):await c.writeFile(t.payload.path,t.payload.content),typeof t.payload.mode==`number`&&await c.chmod(t.payload.path,t.payload.mode),this.sendResponse(e,{id:t.id,payload:{}});break;case`read_directory`:{let n=await c.readdir(t.payload.path,{withFileTypes:!0});this.sendResponse(e,{id:t.id,payload:{entries:n.map(e=>({name:e.name,type:e.isDirectory()?`directory`:e.isSymbolicLink()?`symlink`:`file`}))}});break}default:throw Error(`Unknown request type: ${t.type}`)}}sendResponse(e,t){e.writeTyped(a.ServerMessageType.RESPONSE,this.encoder.encode(JSON.stringify(t)))}sendNotification(e){this.notificationStream.write(new Uint8Array([a.ServerMessageType.NOTIFICATION,...this.encoder.encode(JSON.stringify(e))]))}handleProcessWait(e,t,n){let r=t.payload,i=this.mustGetProcess(r.pid),a,o,s=!1,c,l;typeof r.timeout_ms==`number`&&(l=setTimeout(()=>{u()},r.timeout_ms));let u=()=>{if(s||(s=!0,a&&a.dispose(),o&&o.dispose(),l&&clearTimeout(l),c&&clearTimeout(c),n?.aborted))return;let i=this.processManager.status(r.pid),u=this.processManager.readPlainOutput(i.pid),d=zt(this.processManager.readANSIOutput(i.pid),64e3),f=Bt(u.lines,256e3);this.sendResponse(e,{id:t.id,payload:{...i,ansi_output:d,plain_output:{lines:f.lines,total_lines:u.totalLines}}})};if(typeof i.exitCode==`number`||typeof i.exitSignal==`number`){u();return}a=i.onOutput(()=>{c&&clearTimeout(c),typeof r.output_idle_timeout_ms==`number`&&(c=setTimeout(()=>{u()},r.output_idle_timeout_ms))}),o=i.onExit(()=>{setTimeout(()=>{u()},10)}),n.addEventListener(`abort`,()=>{u()})}mustGetProcess(e){let t=this.processManager.getProcess(e);if(!t)throw Error(`Process ${e} not found`);return t}};Object.defineProperty(e,`Multiplexer`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,`Server`,{enumerable:!0,get:function(){return Vt}})})}),ed=W({"../../node_modules/@blink-sdk/compute-protocol/dist/server.cjs":(e=>{Ru(),e.Server=$u().Server})}),td=class{constructor(e){this.client=e}listen(e){let t,n,r=!1,i=1e4,a=250,o=()=>{n&&=(clearTimeout(n),void 0)},s=()=>{if(r)return;o();let e=a*.2*Math.random(),t=Math.min(i,Math.floor(a+e));n=setTimeout(()=>{f()},t),a=Math.min(i,Math.floor(a*1.5))},c=()=>{a=250},{Server:l}=ed(),u=new l({send:e=>{let n=t;!n||n.readyState!==WebSocket.OPEN||n.send(e)},fetchProxyRequest(t,n){return e.onRequest(new Request(t,{...n,duplex:n.body?`half`:void 0}))}}),d=t=>{t.binaryType=`arraybuffer`,t.addEventListener(`open`,()=>{r||(c(),e.onConnect?.())}),t.addEventListener(`close`,()=>{r||(e.onDisconnect?.(),s())}),t.addEventListener(`error`,n=>{try{e.onError?.(n)}catch{}try{t.close()}catch{}}),t.addEventListener(`message`,e=>{if(typeof e.data==`string`){console.warn(`Message skipped because it is not a buffer.`);return}try{u.handleMessage(new Uint8Array(e.data))}catch(e){console.error(`message handler error`,e);try{t.close(1011)}catch{}}})},f=()=>{if(!r)try{let n=this.client.websocket(`/api/devhook/${e.id}`);t=n,d(n)}catch(t){try{e.onError?.(t)}catch{}s()}};return f(),{dispose:()=>{if(r)return;r=!0,o();let e=t;t=void 0;try{e&&(e.readyState===WebSocket.OPEN||e.readyState===WebSocket.CONNECTING)&&e.close(1e3)}catch{}}}}};let nd=function(e){return e[e.REQUEST=0]=`REQUEST`,e[e.PROXY_INIT=1]=`PROXY_INIT`,e[e.PROXY_BODY=2]=`PROXY_BODY`,e[e.PROXY_WEBSOCKET_MESSAGE=3]=`PROXY_WEBSOCKET_MESSAGE`,e[e.PROXY_WEBSOCKET_CLOSE=4]=`PROXY_WEBSOCKET_CLOSE`,e}({}),rd=function(e){return e[e.RESPONSE=0]=`RESPONSE`,e[e.NOTIFICATION=1]=`NOTIFICATION`,e[e.PROXY_INIT=2]=`PROXY_INIT`,e[e.PROXY_DATA=3]=`PROXY_DATA`,e[e.PROXY_WEBSOCKET_MESSAGE=4]=`PROXY_WEBSOCKET_MESSAGE`,e[e.PROXY_WEBSOCKET_CLOSE=5]=`PROXY_WEBSOCKET_CLOSE`,e}({});nd.REQUEST,y.z.string(),nd.PROXY_INIT,y.z.object({method:y.z.string(),headers:y.z.record(y.z.string(),y.z.string()),url:y.z.string()}),nd.PROXY_BODY,y.z.instanceof(Uint8Array),nd.PROXY_WEBSOCKET_MESSAGE,y.z.object({type:y.z.enum([`text`,`binary`]),data:y.z.instanceof(Uint8Array)}),nd.PROXY_WEBSOCKET_CLOSE,y.z.object({code:y.z.number().optional(),reason:y.z.string().optional()}),rd.RESPONSE,y.z.string(),rd.NOTIFICATION,y.z.string(),rd.PROXY_INIT,y.z.object({status_code:y.z.number(),status_message:y.z.string(),headers:y.z.record(y.z.string(),y.z.string())}),rd.PROXY_DATA,y.z.instanceof(Uint8Array),rd.PROXY_WEBSOCKET_MESSAGE,y.z.instanceof(Uint8Array),rd.PROXY_WEBSOCKET_CLOSE,y.z.object({code:y.z.number(),reason:y.z.string()}),nd.PROXY_INIT,y.z.string(),y.z.record(y.z.string(),y.z.string()),y.z.string(),y.z.object({command:y.z.string(),args:y.z.array(y.z.string()),env:y.z.record(y.z.string(),y.z.string()).optional(),cwd:y.z.string().optional()}),y.z.object({pid:y.z.number(),data:y.z.string()}),y.z.object({pid:y.z.number(),output_idle_timeout_ms:y.z.number().optional(),timeout_ms:y.z.number().optional()}),y.z.object({include_dead:y.z.boolean().optional()}),y.z.object({pid:y.z.number(),start_line:y.z.number().optional(),end_line:y.z.number().optional()}),y.z.object({pid:y.z.number(),signal:y.z.string().optional()}),y.z.object({env:y.z.record(y.z.string(),y.z.string())}),y.z.object({path:y.z.string(),line_start:y.z.number().optional(),line_end:y.z.number().optional()}),y.z.object({path:y.z.string(),content:y.z.string(),base64:y.z.boolean().optional(),mode:y.z.number().optional()}),y.z.object({path:y.z.string()}),y.z.object({path:y.z.string()}),y.z.object({path:y.z.string()});const id=y.z.object({pid:y.z.number(),command:y.z.string(),args:y.z.array(y.z.string()),title:y.z.string().optional(),cwd:y.z.string(),env:y.z.record(y.z.string(),y.z.string()),exit_code:y.z.number().optional(),exit_signal:y.z.number().optional(),duration_ms:y.z.number().optional(),output_total_lines:y.z.number()});id.extend({ansi_output:y.z.string(),plain_output:y.z.object({lines:y.z.array(y.z.string()),total_lines:y.z.number()})}),y.z.object({pid:y.z.number()}),y.z.object({}),y.z.object({processes:y.z.array(id)}),y.z.object({lines:y.z.array(y.z.string()),total_lines:y.z.number(),duration_ms:y.z.number(),exit_code:y.z.number().optional(),exit_signal:y.z.number().optional()}),y.z.object({}),y.z.object({}),y.z.object({total_lines:y.z.number(),lines_read:y.z.number(),start_line:y.z.number(),content:y.z.string(),mime_type:y.z.string()}),y.z.object({}),y.z.object({entries:y.z.array(y.z.object({name:y.z.string(),type:y.z.enum([`file`,`directory`,`symlink`])}))}),y.z.object({}),y.z.object({deployment_id:y.z.string()});const ad=y.z.object({type:y.z.enum([`create`,`update`,`delete`]),path:y.z.string()}),od=y.z.object({type:y.z.enum([`context`,`added`,`deleted`]),content:y.z.string(),oldLineNumber:y.z.number().optional(),newLineNumber:y.z.number().optional()}),sd=y.z.object({oldStart:y.z.number(),oldLines:y.z.number(),newStart:y.z.number(),newLines:y.z.number(),lines:y.z.array(od)}),cd=y.z.object({path:y.z.string(),status:y.z.enum([`added`,`modified`,`deleted`,`renamed`,`copied`,`untracked`,`ignored`,`unmerged`,`typechange`]),oldPath:y.z.string().optional(),insertions:y.z.number(),deletions:y.z.number(),chunks:y.z.array(sd)}),ld=y.z.object({totalFiles:y.z.number(),totalInsertions:y.z.number(),totalDeletions:y.z.number(),netChange:y.z.number(),startHash:y.z.string().optional(),currentHash:y.z.string().optional(),timespan:y.z.number(),files:y.z.array(cd)}),ud=y.z.object({path:y.z.string(),status:y.z.enum([`added`,`modified`,`deleted`,`renamed`,`copied`,`untracked`,`ignored`,`unmerged`,`typechange`]),staged:y.z.boolean()}),dd=y.z.object({hash:y.z.string(),shortHash:y.z.string(),message:y.z.string(),author:y.z.string(),email:y.z.string(),date:y.z.date(),timestamp:y.z.date(),filesChanged:y.z.number(),insertions:y.z.number(),deletions:y.z.number(),commitDiff:y.z.array(cd).optional()});y.z.object({files:y.z.array(ud),branch:y.z.string(),ahead:y.z.number(),behind:y.z.number(),timestamp:y.z.date(),sessionDiff:ld.optional(),workingDirectoryDiff:ld.optional(),newCommits:y.z.array(dd),currentCommit:y.z.object({hash:y.z.string(),shortHash:y.z.string(),message:y.z.string(),author:y.z.string(),date:y.z.date()}).optional(),diffSkipped:y.z.boolean().optional(),payloadTruncated:y.z.boolean().optional(),estimatedSizeKB:y.z.number().optional()}),y.z.object({debounceDelay:y.z.number().optional(),gitStatusInterval:y.z.number().optional(),ignoreDotfiles:y.z.boolean().optional(),ignored:y.z.array(y.z.string()).optional(),watchGit:y.z.boolean().optional(),includeDiffs:y.z.boolean().optional(),maxDiffFiles:y.z.number().optional(),maxPayloadSizeKB:y.z.number().optional(),truncateLargeDiffs:y.z.boolean().optional()}),y.z.object({status:id}),y.z.object({pid:y.z.number(),output:y.z.string()}),y.z.object({changes:y.z.array(ad)});var fd=class{constructor({send:e,jwt:t,requestTimeoutMS:n}){this.notificationCallbacks=new Map,this.disposables=[],this.requestHandlers=new Map,this.send=e,this.jwt=t,this.requestTimeoutMS=n}handleMessage(e){if(typeof e!=`string`)return;let t=JSON.parse(e);if(`id`in t){let e=this.requestHandlers.get(t.id);if(!e)return;e(t.payload,t.error)}else if(`type`in t)this.notificationCallbacks.get(t.type)?.forEach(e=>{e(t.payload)});else return}dispose(e){this.disposables.forEach(t=>t.dispose(e))}async request(e,t,n){let r=crypto.randomUUID(),i,a,o=new Promise((e,t)=>{i=e,a=t}),s={dispose:e=>{l();let t=`Client was disposed!`;e&&(t+=` Reason: ${e}`),a(Error(t))}};this.disposables.push(s);let c;this.requestTimeoutMS&&(c=setTimeout(()=>{a(Error(`Request timed out`))},this.requestTimeoutMS));let l=()=>{this.disposables.splice(this.disposables.indexOf(s),1),this.requestHandlers.delete(r),c&&clearTimeout(c)};n?.signal&&n.signal.addEventListener(`abort`,()=>{l(),a(n.signal?.reason)}),this.requestHandlers.set(r,(e,t)=>{if(l(),t)return a(Error(t));i(e)});let u={id:r,type:e,payload:t,jwt:this.jwt};return this.send(JSON.stringify(u)),o}onNotification(e,t){let n=this.notificationCallbacks.get(e)??[];return n.push(t),this.notificationCallbacks.set(e,n),{dispose:()=>{let n=this.notificationCallbacks.get(e)??[],r=n.indexOf(t);r!==-1&&n.splice(r,1)}}}};y.z.object({}),y.z.object({id:y.z.string(),token:y.z.string()});var pd=class{constructor(e){this.client=e}async token(){let e=await this.client.request(`POST`,`/api/tools/compute`);return await K(e,201),e.json()}async connect(e){let t=this.client.websocket(`/api/tools/compute/connect?id=${e}`);return new fd({send:e=>t.send(e)})}},md=class{constructor(e){this.client=e,this.compute=new pd(this.client)}},hd=class extends Lu{constructor(e){super({...e,baseURL:e?.baseURL??process.env.BLINK_API_URL}),this.devhook=new td(this),this.tools=new md(this)}},gd=e.__commonJSMin(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})),_d=e.__commonJSMin(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c})),vd=e.__toESM(gd(),1),yd=e.__toESM(_d(),1);function bd({onlyFirst:e=!1}={}){let t=[`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`,`(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))`].join(`|`);return new RegExp(t,e?void 0:`g`)}const xd=bd();function Sd(e){if(typeof e!=`string`)throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);return e.replace(xd,``)}function Cd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var wd={exports:{}};(function(e){var t={};e.exports=t,t.eastAsianWidth=function(e){var t=e.charCodeAt(0),n=e.length==2?e.charCodeAt(1):0,r=t;return 55296<=t&&t<=56319&&56320<=n&&n<=57343&&(t&=1023,n&=1023,r=t<<10|n,r+=65536),r==12288||65281<=r&&r<=65376||65504<=r&&r<=65510?`F`:r==8361||65377<=r&&r<=65470||65474<=r&&r<=65479||65482<=r&&r<=65487||65490<=r&&r<=65495||65498<=r&&r<=65500||65512<=r&&r<=65518?`H`:4352<=r&&r<=4447||4515<=r&&r<=4519||4602<=r&&r<=4607||9001<=r&&r<=9002||11904<=r&&r<=11929||11931<=r&&r<=12019||12032<=r&&r<=12245||12272<=r&&r<=12283||12289<=r&&r<=12350||12353<=r&&r<=12438||12441<=r&&r<=12543||12549<=r&&r<=12589||12593<=r&&r<=12686||12688<=r&&r<=12730||12736<=r&&r<=12771||12784<=r&&r<=12830||12832<=r&&r<=12871||12880<=r&&r<=13054||13056<=r&&r<=19903||19968<=r&&r<=42124||42128<=r&&r<=42182||43360<=r&&r<=43388||44032<=r&&r<=55203||55216<=r&&r<=55238||55243<=r&&r<=55291||63744<=r&&r<=64255||65040<=r&&r<=65049||65072<=r&&r<=65106||65108<=r&&r<=65126||65128<=r&&r<=65131||110592<=r&&r<=110593||127488<=r&&r<=127490||127504<=r&&r<=127546||127552<=r&&r<=127560||127568<=r&&r<=127569||131072<=r&&r<=194367||177984<=r&&r<=196605||196608<=r&&r<=262141?`W`:32<=r&&r<=126||162<=r&&r<=163||165<=r&&r<=166||r==172||r==175||10214<=r&&r<=10221||10629<=r&&r<=10630?`Na`:r==161||r==164||167<=r&&r<=168||r==170||173<=r&&r<=174||176<=r&&r<=180||182<=r&&r<=186||188<=r&&r<=191||r==198||r==208||215<=r&&r<=216||222<=r&&r<=225||r==230||232<=r&&r<=234||236<=r&&r<=237||r==240||242<=r&&r<=243||247<=r&&r<=250||r==252||r==254||r==257||r==273||r==275||r==283||294<=r&&r<=295||r==299||305<=r&&r<=307||r==312||319<=r&&r<=322||r==324||328<=r&&r<=331||r==333||338<=r&&r<=339||358<=r&&r<=359||r==363||r==462||r==464||r==466||r==468||r==470||r==472||r==474||r==476||r==593||r==609||r==708||r==711||713<=r&&r<=715||r==717||r==720||728<=r&&r<=731||r==733||r==735||768<=r&&r<=879||913<=r&&r<=929||931<=r&&r<=937||945<=r&&r<=961||963<=r&&r<=969||r==1025||1040<=r&&r<=1103||r==1105||r==8208||8211<=r&&r<=8214||8216<=r&&r<=8217||8220<=r&&r<=8221||8224<=r&&r<=8226||8228<=r&&r<=8231||r==8240||8242<=r&&r<=8243||r==8245||r==8251||r==8254||r==8308||r==8319||8321<=r&&r<=8324||r==8364||r==8451||r==8453||r==8457||r==8467||r==8470||8481<=r&&r<=8482||r==8486||r==8491||8531<=r&&r<=8532||8539<=r&&r<=8542||8544<=r&&r<=8555||8560<=r&&r<=8569||r==8585||8592<=r&&r<=8601||8632<=r&&r<=8633||r==8658||r==8660||r==8679||r==8704||8706<=r&&r<=8707||8711<=r&&r<=8712||r==8715||r==8719||r==8721||r==8725||r==8730||8733<=r&&r<=8736||r==8739||r==8741||8743<=r&&r<=8748||r==8750||8756<=r&&r<=8759||8764<=r&&r<=8765||r==8776||r==8780||r==8786||8800<=r&&r<=8801||8804<=r&&r<=8807||8810<=r&&r<=8811||8814<=r&&r<=8815||8834<=r&&r<=8835||8838<=r&&r<=8839||r==8853||r==8857||r==8869||r==8895||r==8978||9312<=r&&r<=9449||9451<=r&&r<=9547||9552<=r&&r<=9587||9600<=r&&r<=9615||9618<=r&&r<=9621||9632<=r&&r<=9633||9635<=r&&r<=9641||9650<=r&&r<=9651||9654<=r&&r<=9655||9660<=r&&r<=9661||9664<=r&&r<=9665||9670<=r&&r<=9672||r==9675||9678<=r&&r<=9681||9698<=r&&r<=9701||r==9711||9733<=r&&r<=9734||r==9737||9742<=r&&r<=9743||9748<=r&&r<=9749||r==9756||r==9758||r==9792||r==9794||9824<=r&&r<=9825||9827<=r&&r<=9829||9831<=r&&r<=9834||9836<=r&&r<=9837||r==9839||9886<=r&&r<=9887||9918<=r&&r<=9919||9924<=r&&r<=9933||9935<=r&&r<=9953||r==9955||9960<=r&&r<=9983||r==10045||r==10071||10102<=r&&r<=10111||11093<=r&&r<=11097||12872<=r&&r<=12879||57344<=r&&r<=63743||65024<=r&&r<=65039||r==65533||127232<=r&&r<=127242||127248<=r&&r<=127277||127280<=r&&r<=127337||127344<=r&&r<=127386||917760<=r&&r<=917999||983040<=r&&r<=1048573||1048576<=r&&r<=1114109?`A`:`N`},t.characterLength=function(e){var t=this.eastAsianWidth(e);return t==`F`||t==`W`||t==`A`?2:1};function n(e){return e.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[^\uD800-\uDFFF]/g)||[]}t.length=function(e){for(var t=n(e),r=0,i=0;i<t.length;i++)r+=this.characterLength(t[i]);return r},t.slice=function(e,r,i){textLen=t.length(e),r||=0,i||=1,r<0&&(r=textLen+r),i<0&&(i=textLen+i);for(var a=``,o=0,s=n(e),c=0;c<s.length;c++){var l=s[c],u=t.length(l);if(o>=r-(u==2?1:0))if(o+u<=i)a+=l;else break;o+=u}return a}})(wd);var Td=wd.exports;const Ed=Cd(Td);var Dd=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g};const Od=Cd(Dd);function kd(e,t={}){if(typeof e!=`string`||e.length===0||(t={ambiguousIsNarrow:!0,...t},e=Sd(e),e.length===0))return 0;e=e.replace(Od(),` `);let n=t.ambiguousIsNarrow?1:2,r=0;for(let t of e){let e=t.codePointAt(0);if(!(e<=31||e>=127&&e<=159||e>=768&&e<=879))switch(Ed.eastAsianWidth(t)){case`F`:case`W`:r+=2;break;case`A`:r+=n;break;default:r+=1}}return r}const Ad=10,jd=(e=0)=>t=>`\x1B[${t+e}m`,Md=(e=0)=>t=>`\x1B[${38+e};5;${t}m`,Nd=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,q={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(q.modifier);const Pd=Object.keys(q.color),Fd=Object.keys(q.bgColor);[...Pd,...Fd];function Id(){let e=new Map;for(let[t,n]of Object.entries(q)){for(let[t,r]of Object.entries(n))q[t]={open:`\x1B[${r[0]}m`,close:`\x1B[${r[1]}m`},n[t]=q[t],e.set(r[0],r[1]);Object.defineProperty(q,t,{value:n,enumerable:!1})}return Object.defineProperty(q,`codes`,{value:e,enumerable:!1}),q.color.close=`\x1B[39m`,q.bgColor.close=`\x1B[49m`,q.color.ansi=jd(),q.color.ansi256=Md(),q.color.ansi16m=Nd(),q.bgColor.ansi=jd(10),q.bgColor.ansi256=Md(10),q.bgColor.ansi16m=Nd(10),Object.defineProperties(q,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value:e=>{let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>q.rgbToAnsi256(...q.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value:e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>q.ansi256ToAnsi(q.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>q.ansi256ToAnsi(q.hexToAnsi256(e)),enumerable:!1}}),q}const Ld=Id(),Rd=new Set([`\x1B`,``]),zd=39,Bd=`\x07`,Vd=`[`,Hd=`]`,Ud=`m`,Wd=`]8;;`,Gd=e=>`${Rd.values().next().value}[${e}m`,Kd=e=>`${Rd.values().next().value}${Wd}${e}`,qd=e=>e.split(` `).map(e=>kd(e)),Jd=(e,t,n)=>{let r=[...t],i=!1,a=!1,o=kd(Sd(e[e.length-1]));for(let[t,s]of r.entries()){let c=kd(s);if(o+c<=n?e[e.length-1]+=s:(e.push(s),o=0),Rd.has(s)&&(i=!0,a=r.slice(t+1).join(``).startsWith(Wd)),i){a?s===`\x07`&&(i=!1,a=!1):s===`m`&&(i=!1);continue}o+=c,o===n&&t<r.length-1&&(e.push(``),o=0)}!o&&e[e.length-1].length>0&&e.length>1&&(e[e.length-2]+=e.pop())},Yd=e=>{let t=e.split(` `),n=t.length;for(;n>0&&!(kd(t[n-1])>0);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Xd=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=qd(e),s=[``];for(let[r,i]of e.split(` `).entries()){n.trim!==!1&&(s[s.length-1]=s[s.length-1].trimStart());let e=kd(s[s.length-1]);if(r!==0&&(e>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),e=0),(e>0||n.trim===!1)&&(s[s.length-1]+=` `,e++)),n.hard&&o[r]>t){let n=t-e,a=1+Math.floor((o[r]-n-1)/t);Math.floor((o[r]-1)/t)<a&&s.push(``),Jd(s,i,t);continue}if(e+o[r]>t&&e>0&&o[r]>0){if(n.wordWrap===!1&&e<t){Jd(s,i,t);continue}s.push(``)}if(e+o[r]>t&&n.wordWrap===!1){Jd(s,i,t);continue}s[s.length-1]+=i}n.trim!==!1&&(s=s.map(e=>Yd(e)));let c=[...s.join(`
|
|
40
|
+
`)];for(let[e,t]of c.entries()){if(r+=t,Rd.has(t)){let{groups:t}=RegExp(`(?:\\[(?<code>\\d+)m|\\${Wd}(?<uri>.*))`).exec(c.slice(e).join(``))||{groups:{}};if(t.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}let n=Ld.codes.get(Number(i));c[e+1]===`
|
|
41
|
+
`?(a&&(r+=Kd(``)),i&&n&&(r+=Gd(n))):t===`
|
|
42
|
+
`&&(i&&n&&(r+=Gd(i)),a&&(r+=Kd(a)))}return r};function Zd(e,t,n){return String(e).normalize().replace(/\r\n/g,`
|
|
47
43
|
`).split(`
|
|
48
|
-
`).map(e=>
|
|
49
|
-
`)}const
|
|
44
|
+
`).map(e=>Xd(e,t,n)).join(`
|
|
45
|
+
`)}const Qd={actions:new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]])};function $d(e,t){if(typeof e==`string`)return Qd.aliases.get(e)===t;for(let n of e)if(n!==void 0&&$d(n,t))return!0;return!1}function ef(e,t){if(e===t)return;let n=e.split(`
|
|
50
46
|
`),r=t.split(`
|
|
51
|
-
`),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}const
|
|
52
|
-
`),
|
|
53
|
-
`).length-1;this.output.write(
|
|
54
|
-
`);this.output.write(r[n]),this._prevFrame=e,this.output.write(
|
|
47
|
+
`),i=[];for(let e=0;e<Math.max(n.length,r.length);e++)n[e]!==r[e]&&i.push(e);return i}const tf=globalThis.process.platform.startsWith(`win`),nf=Symbol(`clack:cancel`);function rf(e){return e===nf}function af(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function sf({input:e=x.stdin,output:t=x.stdout,overwrite:n=!0,hideCursor:r=!0}={}){let i=S.createInterface({input:e,output:t,prompt:``,tabSize:1});S.emitKeypressEvents(e,i),e.isTTY&&e.setRawMode(!0);let a=(i,{name:o,sequence:s})=>{if($d([String(i),o,s],`cancel`)){r&&t.write(vd.cursor.show),process.exit(0);return}if(!n)return;let c=o===`return`?0:-1,l=o===`return`?-1:0;S.moveCursor(t,c,l,()=>{S.clearLine(t,1,()=>{e.once(`keypress`,a)})})};return r&&t.write(vd.cursor.hide),e.once(`keypress`,a),()=>{e.off(`keypress`,a),r&&t.write(vd.cursor.show),e.isTTY&&!tf&&e.setRawMode(!1),i.terminal=!1,i.close()}}var cf=Object.defineProperty,lf=(e,t,n)=>t in e?cf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uf=(e,t,n)=>(lf(e,typeof t==`symbol`?t:t+``,n),n),df=class{constructor(e,t=!0){uf(this,`input`),uf(this,`output`),uf(this,`_abortSignal`),uf(this,`rl`),uf(this,`opts`),uf(this,`_render`),uf(this,`_track`,!1),uf(this,`_prevFrame`,``),uf(this,`_subscribers`,new Map),uf(this,`_cursor`,0),uf(this,`state`,`initial`),uf(this,`error`,``),uf(this,`value`);let{input:n=x.stdin,output:r=x.stdout,render:i,signal:a,...o}=e;this.opts=o,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=i.bind(this),this._track=t,this._abortSignal=a,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise((e,t)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(nf);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}let n=new c.Writable;n._write=(e,t,n)=>{this._track&&(this.value=this.rl?.line.replace(/\t/g,``),this._cursor=this.rl?.cursor??0,this.emit(`value`,this.value)),n()},this.input.pipe(n),this.rl=S.default.createInterface({input:this.input,output:n,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),S.default.emitKeypressEvents(this.input,this.rl),this.rl.prompt(),this.opts.initialValue!==void 0&&this._track&&this.rl.write(this.opts.initialValue),this.input.on(`keypress`,this.onKeypress),af(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(vd.cursor.show),this.output.off(`resize`,this.render),af(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(vd.cursor.show),this.output.off(`resize`,this.render),af(this.input,!1),e(nf)})})}onKeypress(e,t){if(this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&Qd.aliases.has(t.name)&&this.emit(`cursor`,Qd.aliases.get(t.name)),Qd.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),e===` `&&this.opts.placeholder&&(this.value||(this.rl?.write(this.opts.placeholder),this.emit(`value`,this.opts.placeholder))),e&&this.emit(`key`,e.toLowerCase()),t?.name===`return`){if(this.opts.validate){let e=this.opts.validate(this.value);e&&(this.error=e instanceof Error?e.message:e,this.state=`error`,this.rl?.write(this.value))}this.state!==`error`&&(this.state=`submit`)}$d([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
|
|
48
|
+
`),af(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Zd(this._prevFrame,process.stdout.columns,{hard:!0}).split(`
|
|
49
|
+
`).length-1;this.output.write(vd.cursor.move(-999,e*-1))}render(){let e=Zd(this._render(this)??``,process.stdout.columns,{hard:!0});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(vd.cursor.hide);else{let t=ef(this._prevFrame,e);if(this.restoreCursor(),t&&t?.length===1){let n=t[0];this.output.write(vd.cursor.move(0,n)),this.output.write(vd.erase.lines(1));let r=e.split(`
|
|
50
|
+
`);this.output.write(r[n]),this._prevFrame=e,this.output.write(vd.cursor.move(0,r.length-n-1));return}if(t&&t?.length>1){let n=t[0];this.output.write(vd.cursor.move(0,n)),this.output.write(vd.erase.down());let r=e.split(`
|
|
55
51
|
`).slice(n);this.output.write(r.join(`
|
|
56
|
-
`)),this._prevFrame=e;return}this.output.write(
|
|
57
|
-
${
|
|
58
|
-
`,n=e.placeholder?
|
|
59
|
-
${
|
|
60
|
-
${
|
|
61
|
-
`;case`submit`:return`${t}${
|
|
62
|
-
${
|
|
63
|
-
${
|
|
64
|
-
`}}}).prompt(),
|
|
65
|
-
${
|
|
52
|
+
`)),this._prevFrame=e;return}this.output.write(vd.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},ff=class extends df{get cursor(){return this.value?0:1}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`value`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(vd.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},pf=Object.defineProperty,mf=(e,t,n)=>t in e?pf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hf=(e,t,n)=>(mf(e,typeof t==`symbol`?t:t+``,n),n),gf=(e,t,n)=>{if(!t.has(e))throw TypeError(`Cannot `+n)},_f=(e,t,n)=>(gf(e,t,`read from private field`),n?n.call(e):t.get(e)),vf=(e,t,n)=>{if(t.has(e))throw TypeError(`Cannot add the same private member more than once`);t instanceof WeakSet?t.add(e):t.set(e,n)},yf=(e,t,n,r)=>(gf(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n),bf;let xf=class extends df{constructor(e){super(e,!1),hf(this,`options`),hf(this,`cursor`,0),vf(this,bf,void 0);let{options:t}=e;yf(this,bf,e.selectableGroups!==!1),this.options=Object.entries(t).flatMap(([e,t])=>[{value:e,group:!0,label:e},...t.map(t=>({...t,group:e}))]),this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),_f(this,bf)?0:1),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let e=this.options[this.cursor]?.group===!0;!_f(this,bf)&&e&&(this.cursor=this.cursor===0?this.options.length-1:this.cursor-1);break}case`down`:case`right`:{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let e=this.options[this.cursor]?.group===!0;!_f(this,bf)&&e&&(this.cursor=this.cursor===this.options.length-1?0:this.cursor+1);break}case`space`:this.toggleValue();break}})}getGroupItems(e){return this.options.filter(t=>t.group===e)}isGroupSelected(e){return this.getGroupItems(e).every(e=>this.value.includes(e.value))}toggleValue(){let e=this.options[this.cursor];if(e.group===!0){let t=e.value,n=this.getGroupItems(t);this.isGroupSelected(t)?this.value=this.value.filter(e=>n.findIndex(t=>t.value===e)===-1):this.value=[...this.value,...n.map(e=>e.value)],this.value=Array.from(new Set(this.value))}else this.value=this.value.includes(e.value)?this.value.filter(t=>t!==e.value):[...this.value,e.value]}};bf=new WeakMap;var Sf=Object.defineProperty,Cf=(e,t,n)=>t in e?Sf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wf=(e,t,n)=>(Cf(e,typeof t==`symbol`?t:t+``,n),n);let Tf=class extends df{constructor(e){super(e,!1),wf(this,`options`),wf(this,`cursor`,0),this.options=e.options,this.value=[...e.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0),this.on(`key`,e=>{e===`a`&&this.toggleAll()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break;case`space`:this.toggleValue();break}})}get _value(){return this.options[this.cursor].value}toggleAll(){this.value=this.value.length===this.options.length?[]:this.options.map(e=>e.value)}toggleValue(){this.value=this.value.includes(this._value)?this.value.filter(e=>e!==this._value):[...this.value,this._value]}};var Ef=Object.defineProperty,Df=(e,t,n)=>t in e?Ef(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Of=(e,t,n)=>(Df(e,typeof t==`symbol`?t:t+``,n),n),kf=class extends df{constructor({mask:e,...t}){super(t),Of(this,`valueWithCursor`,``),Of(this,`_mask`,`•`),this._mask=e??`•`,this.on(`finalize`,()=>{this.valueWithCursor=this.masked}),this.on(`value`,()=>{if(this.cursor>=this.value.length)this.valueWithCursor=`${this.masked}${yd.default.inverse(yd.default.hidden(`_`))}`;else{let e=this.masked.slice(0,this.cursor),t=this.masked.slice(this.cursor);this.valueWithCursor=`${e}${yd.default.inverse(t[0])}${t.slice(1)}`}})}get cursor(){return this._cursor}get masked(){return this.value.replaceAll(/./g,this._mask)}},Af=Object.defineProperty,jf=(e,t,n)=>t in e?Af(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mf=(e,t,n)=>(jf(e,typeof t==`symbol`?t:t+``,n),n),Nf=class extends df{constructor(e){super(e,!1),Mf(this,`options`),Mf(this,`cursor`,0),this.options=e.options,this.cursor=this.options.findIndex(({value:t})=>t===e.initialValue),this.cursor===-1&&(this.cursor=0),this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break;case`down`:case`right`:this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}this.changeValue()})}get _value(){return this.options[this.cursor]}changeValue(){this.value=this._value.value}},Pf=Object.defineProperty,Ff=(e,t,n)=>t in e?Pf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,If=(e,t,n)=>(Ff(e,typeof t==`symbol`?t:t+``,n),n),Lf=class extends df{constructor(e){super(e,!1),If(this,`options`),If(this,`cursor`,0),this.options=e.options;let t=this.options.map(({value:[e]})=>e?.toLowerCase());this.cursor=Math.max(t.indexOf(e.initialValue),0),this.on(`key`,e=>{if(!t.includes(e))return;let n=this.options.find(({value:[t]})=>t?.toLowerCase()===e);n&&(this.value=n.value,this.state=`submit`,this.emit(`submit`))})}},Rf=class extends df{get valueWithCursor(){if(this.state===`submit`)return this.value;if(this.cursor>=this.value.length)return`${this.value}\u2588`;let e=this.value.slice(0,this.cursor),[t,...n]=this.value.slice(this.cursor);return`${e}${yd.default.inverse(t)}${n.join(``)}`}get cursor(){return this._cursor}constructor(e){super(e),this.on(`finalize`,()=>{this.value||=e.defaultValue})}},J=e.__toESM(_d(),1),zf=e.__toESM(gd(),1);function Bf(){return x.default.platform===`win32`?!!x.default.env.CI||!!x.default.env.WT_SESSION||!!x.default.env.TERMINUS_SUBLIME||x.default.env.ConEmuTask===`{cmd::Cmder}`||x.default.env.TERM_PROGRAM===`Terminus-Sublime`||x.default.env.TERM_PROGRAM===`vscode`||x.default.env.TERM===`xterm-256color`||x.default.env.TERM===`alacritty`||x.default.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:x.default.env.TERM!==`linux`}const Vf=Bf(),Y=(e,t)=>Vf?e:t,Hf=Y(`◆`,`*`),Uf=Y(`■`,`x`),Wf=Y(`▲`,`x`),Gf=Y(`◇`,`o`),Kf=Y(`┌`,`T`),X=Y(`│`,`|`),qf=Y(`└`,`—`),Jf=Y(`●`,`>`),Yf=Y(`○`,` `),Xf=Y(`◻`,`[•]`),Zf=Y(`◼`,`[+]`),Qf=Y(`◻`,`[ ]`),$f=Y(`▪`,`•`),ep=Y(`─`,`-`),tp=Y(`╮`,`+`),np=Y(`├`,`+`),rp=Y(`╯`,`+`),ip=Y(`●`,`•`),ap=Y(`◆`,`*`),op=Y(`▲`,`!`),sp=Y(`■`,`x`),cp=e=>{switch(e){case`initial`:case`active`:return J.default.cyan(Hf);case`cancel`:return J.default.red(Uf);case`error`:return J.default.yellow(Wf);case`submit`:return J.default.green(Gf)}},lp=e=>{let{cursor:t,options:n,style:r}=e,i=e.maxItems??1/0,a=Math.max(process.stdout.rows-4,0),o=Math.min(a,Math.max(i,5)),s=0;t>=s+o-3?s=Math.max(Math.min(t-o+3,n.length-o),0):t<s+2&&(s=Math.max(t-2,0));let c=o<n.length&&s>0,l=o<n.length&&s+o<n.length;return n.slice(s,s+o).map((e,n,i)=>{let a=n===0&&c,o=n===i.length-1&&l;return a||o?J.default.dim(`...`):r(e,n+s===t)})},up=e=>new Rf({validate:e.validate,placeholder:e.placeholder,defaultValue:e.defaultValue,initialValue:e.initialValue,render(){let t=`${J.default.gray(X)}
|
|
53
|
+
${cp(this.state)} ${e.message}
|
|
54
|
+
`,n=e.placeholder?J.default.inverse(e.placeholder[0])+J.default.dim(e.placeholder.slice(1)):J.default.inverse(J.default.hidden(`_`)),r=this.value?this.valueWithCursor:n;switch(this.state){case`error`:return`${t.trim()}
|
|
55
|
+
${J.default.yellow(X)} ${r}
|
|
56
|
+
${J.default.yellow(qf)} ${J.default.yellow(this.error)}
|
|
57
|
+
`;case`submit`:return`${t}${J.default.gray(X)} ${J.default.dim(this.value||e.placeholder)}`;case`cancel`:return`${t}${J.default.gray(X)} ${J.default.strikethrough(J.default.dim(this.value??``))}${this.value?.trim()?`
|
|
58
|
+
${J.default.gray(X)}`:``}`;default:return`${t}${J.default.cyan(X)} ${r}
|
|
59
|
+
${J.default.cyan(qf)}
|
|
60
|
+
`}}}).prompt(),dp=e=>new kf({validate:e.validate,mask:e.mask??$f,render(){let t=`${J.default.gray(X)}
|
|
61
|
+
${cp(this.state)} ${e.message}
|
|
66
62
|
`,n=this.valueWithCursor,r=this.masked;switch(this.state){case`error`:return`${t.trim()}
|
|
67
|
-
${
|
|
68
|
-
${
|
|
69
|
-
`;case`submit`:return`${t}${
|
|
70
|
-
${
|
|
71
|
-
${
|
|
72
|
-
`}}}).prompt(),
|
|
73
|
-
${
|
|
74
|
-
`,i=this.value?t:n;switch(this.state){case`submit`:return`${r}${
|
|
75
|
-
${
|
|
76
|
-
${
|
|
77
|
-
`}}}).prompt()},
|
|
78
|
-
${
|
|
79
|
-
`;switch(this.state){case`submit`:return`${n}${
|
|
80
|
-
${
|
|
81
|
-
${
|
|
82
|
-
${
|
|
83
|
-
`}}}).prompt()},
|
|
84
|
-
${
|
|
85
|
-
`;switch(this.state){case`submit`:return`${n}${
|
|
86
|
-
${
|
|
87
|
-
${
|
|
88
|
-
${
|
|
89
|
-
`}}}).prompt()},
|
|
90
|
-
${
|
|
91
|
-
${
|
|
92
|
-
`,r=(e,n)=>{let r=this.value.includes(e.value);return n&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,n?`active`:`inactive`)};switch(this.state){case`submit`:return`${n}${
|
|
93
|
-
${
|
|
94
|
-
`).map((e,t)=>t===0?`${
|
|
95
|
-
`);return`${n+
|
|
96
|
-
${
|
|
63
|
+
${J.default.yellow(X)} ${r}
|
|
64
|
+
${J.default.yellow(qf)} ${J.default.yellow(this.error)}
|
|
65
|
+
`;case`submit`:return`${t}${J.default.gray(X)} ${J.default.dim(r)}`;case`cancel`:return`${t}${J.default.gray(X)} ${J.default.strikethrough(J.default.dim(r??``))}${r?`
|
|
66
|
+
${J.default.gray(X)}`:``}`;default:return`${t}${J.default.cyan(X)} ${n}
|
|
67
|
+
${J.default.cyan(qf)}
|
|
68
|
+
`}}}).prompt(),fp=e=>{let t=e.active??`Yes`,n=e.inactive??`No`;return new ff({active:t,inactive:n,initialValue:e.initialValue??!0,render(){let r=`${J.default.gray(X)}
|
|
69
|
+
${cp(this.state)} ${e.message}
|
|
70
|
+
`,i=this.value?t:n;switch(this.state){case`submit`:return`${r}${J.default.gray(X)} ${J.default.dim(i)}`;case`cancel`:return`${r}${J.default.gray(X)} ${J.default.strikethrough(J.default.dim(i))}
|
|
71
|
+
${J.default.gray(X)}`;default:return`${r}${J.default.cyan(X)} ${this.value?`${J.default.green(Jf)} ${t}`:`${J.default.dim(Yf)} ${J.default.dim(t)}`} ${J.default.dim(`/`)} ${this.value?`${J.default.dim(Yf)} ${J.default.dim(n)}`:`${J.default.green(Jf)} ${n}`}
|
|
72
|
+
${J.default.cyan(qf)}
|
|
73
|
+
`}}}).prompt()},pp=e=>{let t=(e,t)=>{let n=e.label??String(e.value);switch(t){case`selected`:return`${J.default.dim(n)}`;case`active`:return`${J.default.green(Jf)} ${n} ${e.hint?J.default.dim(`(${e.hint})`):``}`;case`cancelled`:return`${J.default.strikethrough(J.default.dim(n))}`;default:return`${J.default.dim(Yf)} ${J.default.dim(n)}`}};return new Nf({options:e.options,initialValue:e.initialValue,render(){let n=`${J.default.gray(X)}
|
|
74
|
+
${cp(this.state)} ${e.message}
|
|
75
|
+
`;switch(this.state){case`submit`:return`${n}${J.default.gray(X)} ${t(this.options[this.cursor],`selected`)}`;case`cancel`:return`${n}${J.default.gray(X)} ${t(this.options[this.cursor],`cancelled`)}
|
|
76
|
+
${J.default.gray(X)}`;default:return`${n}${J.default.cyan(X)} ${lp({cursor:this.cursor,options:this.options,maxItems:e.maxItems,style:(e,n)=>t(e,n?`active`:`inactive`)}).join(`
|
|
77
|
+
${J.default.cyan(X)} `)}
|
|
78
|
+
${J.default.cyan(qf)}
|
|
79
|
+
`}}}).prompt()},mp=e=>{let t=(e,t=`inactive`)=>{let n=e.label??String(e.value);return t===`selected`?`${J.default.dim(n)}`:t===`cancelled`?`${J.default.strikethrough(J.default.dim(n))}`:t===`active`?`${J.default.bgCyan(J.default.gray(` ${e.value} `))} ${n} ${e.hint?J.default.dim(`(${e.hint})`):``}`:`${J.default.gray(J.default.bgWhite(J.default.inverse(` ${e.value} `)))} ${n} ${e.hint?J.default.dim(`(${e.hint})`):``}`};return new Lf({options:e.options,initialValue:e.initialValue,render(){let n=`${J.default.gray(X)}
|
|
80
|
+
${cp(this.state)} ${e.message}
|
|
81
|
+
`;switch(this.state){case`submit`:return`${n}${J.default.gray(X)} ${t(this.options.find(e=>e.value===this.value)??e.options[0],`selected`)}`;case`cancel`:return`${n}${J.default.gray(X)} ${t(this.options[0],`cancelled`)}
|
|
82
|
+
${J.default.gray(X)}`;default:return`${n}${J.default.cyan(X)} ${this.options.map((e,n)=>t(e,n===this.cursor?`active`:`inactive`)).join(`
|
|
83
|
+
${J.default.cyan(X)} `)}
|
|
84
|
+
${J.default.cyan(qf)}
|
|
85
|
+
`}}}).prompt()},hp=e=>{let t=(e,t)=>{let n=e.label??String(e.value);return t===`active`?`${J.default.cyan(Xf)} ${n} ${e.hint?J.default.dim(`(${e.hint})`):``}`:t===`selected`?`${J.default.green(Zf)} ${J.default.dim(n)} ${e.hint?J.default.dim(`(${e.hint})`):``}`:t===`cancelled`?`${J.default.strikethrough(J.default.dim(n))}`:t===`active-selected`?`${J.default.green(Zf)} ${n} ${e.hint?J.default.dim(`(${e.hint})`):``}`:t===`submitted`?`${J.default.dim(n)}`:`${J.default.dim(Qf)} ${J.default.dim(n)}`};return new Tf({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
|
|
86
|
+
${J.default.reset(J.default.dim(`Press ${J.default.gray(J.default.bgWhite(J.default.inverse(` space `)))} to select, ${J.default.gray(J.default.bgWhite(J.default.inverse(` enter `)))} to submit`))}`},render(){let n=`${J.default.gray(X)}
|
|
87
|
+
${cp(this.state)} ${e.message}
|
|
88
|
+
`,r=(e,n)=>{let r=this.value.includes(e.value);return n&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,n?`active`:`inactive`)};switch(this.state){case`submit`:return`${n}${J.default.gray(X)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`submitted`)).join(J.default.dim(`, `))||J.default.dim(`none`)}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>t(e,`cancelled`)).join(J.default.dim(`, `));return`${n}${J.default.gray(X)} ${e.trim()?`${e}
|
|
89
|
+
${J.default.gray(X)}`:``}`}case`error`:{let t=this.error.split(`
|
|
90
|
+
`).map((e,t)=>t===0?`${J.default.yellow(qf)} ${J.default.yellow(e)}`:` ${e}`).join(`
|
|
91
|
+
`);return`${n+J.default.yellow(X)} ${lp({options:this.options,cursor:this.cursor,maxItems:e.maxItems,style:r}).join(`
|
|
92
|
+
${J.default.yellow(X)} `)}
|
|
97
93
|
${t}
|
|
98
|
-
`}default:return`${n}${
|
|
99
|
-
${
|
|
100
|
-
${
|
|
101
|
-
`}}}).prompt()},
|
|
102
|
-
${
|
|
103
|
-
${
|
|
104
|
-
`;switch(this.state){case`submit`:return`${t}${
|
|
105
|
-
${
|
|
106
|
-
`).map((e,t)=>t===0?`${
|
|
107
|
-
`);return`${t}${
|
|
108
|
-
${
|
|
94
|
+
`}default:return`${n}${J.default.cyan(X)} ${lp({options:this.options,cursor:this.cursor,maxItems:e.maxItems,style:r}).join(`
|
|
95
|
+
${J.default.cyan(X)} `)}
|
|
96
|
+
${J.default.cyan(qf)}
|
|
97
|
+
`}}}).prompt()},gp=e=>{let{selectableGroups:t=!0}=e,n=(e,n,r=[])=>{let i=e.label??String(e.value),a=typeof e.group==`string`,o=a&&(r[r.indexOf(e)+1]??{group:!0}),s=a&&o.group===!0,c=a?t?`${s?qf:X} `:` `:``;if(n===`active`)return`${J.default.dim(c)}${J.default.cyan(Xf)} ${i} ${e.hint?J.default.dim(`(${e.hint})`):``}`;if(n===`group-active`)return`${c}${J.default.cyan(Xf)} ${J.default.dim(i)}`;if(n===`group-active-selected`)return`${c}${J.default.green(Zf)} ${J.default.dim(i)}`;if(n===`selected`){let n=a||t?J.default.green(Zf):``;return`${J.default.dim(c)}${n} ${J.default.dim(i)} ${e.hint?J.default.dim(`(${e.hint})`):``}`}if(n===`cancelled`)return`${J.default.strikethrough(J.default.dim(i))}`;if(n===`active-selected`)return`${J.default.dim(c)}${J.default.green(Zf)} ${i} ${e.hint?J.default.dim(`(${e.hint})`):``}`;if(n===`submitted`)return`${J.default.dim(i)}`;let l=a||t?J.default.dim(Qf):``;return`${J.default.dim(c)}${l} ${J.default.dim(i)}`};return new xf({options:e.options,initialValues:e.initialValues,required:e.required??!0,cursorAt:e.cursorAt,selectableGroups:t,validate(e){if(this.required&&e.length===0)return`Please select at least one option.
|
|
98
|
+
${J.default.reset(J.default.dim(`Press ${J.default.gray(J.default.bgWhite(J.default.inverse(` space `)))} to select, ${J.default.gray(J.default.bgWhite(J.default.inverse(` enter `)))} to submit`))}`},render(){let t=`${J.default.gray(X)}
|
|
99
|
+
${cp(this.state)} ${e.message}
|
|
100
|
+
`;switch(this.state){case`submit`:return`${t}${J.default.gray(X)} ${this.options.filter(({value:e})=>this.value.includes(e)).map(e=>n(e,`submitted`)).join(J.default.dim(`, `))}`;case`cancel`:{let e=this.options.filter(({value:e})=>this.value.includes(e)).map(e=>n(e,`cancelled`)).join(J.default.dim(`, `));return`${t}${J.default.gray(X)} ${e.trim()?`${e}
|
|
101
|
+
${J.default.gray(X)}`:``}`}case`error`:{let e=this.error.split(`
|
|
102
|
+
`).map((e,t)=>t===0?`${J.default.yellow(qf)} ${J.default.yellow(e)}`:` ${e}`).join(`
|
|
103
|
+
`);return`${t}${J.default.yellow(X)} ${this.options.map((e,t,r)=>{let i=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),a=t===this.cursor;return!a&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?n(e,i?`group-active-selected`:`group-active`,r):a&&i?n(e,`active-selected`,r):i?n(e,`selected`,r):n(e,a?`active`:`inactive`,r)}).join(`
|
|
104
|
+
${J.default.yellow(X)} `)}
|
|
109
105
|
${e}
|
|
110
|
-
`}default:return`${t}${
|
|
111
|
-
${
|
|
112
|
-
${
|
|
113
|
-
`}}}).prompt()},
|
|
106
|
+
`}default:return`${t}${J.default.cyan(X)} ${this.options.map((e,t,r)=>{let i=this.value.includes(e.value)||e.group===!0&&this.isGroupSelected(`${e.value}`),a=t===this.cursor;return!a&&typeof e.group==`string`&&this.options[this.cursor].value===e.group?n(e,i?`group-active-selected`:`group-active`,r):a&&i?n(e,`active-selected`,r):i?n(e,`selected`,r):n(e,a?`active`:`inactive`,r)}).join(`
|
|
107
|
+
${J.default.cyan(X)} `)}
|
|
108
|
+
${J.default.cyan(qf)}
|
|
109
|
+
`}}}).prompt()},_p=(e=``,t=``)=>{let n=`
|
|
114
110
|
${e}
|
|
115
111
|
`.split(`
|
|
116
|
-
`),r=(0,l.stripVTControlCharacters)(t).length,i=Math.max(n.reduce((e,t)=>{let n=(0,l.stripVTControlCharacters)(t);return n.length>e?n.length:e},0),r)+2,a=n.map(e=>`${
|
|
117
|
-
`);process.stdout.write(`${
|
|
118
|
-
${
|
|
112
|
+
`),r=(0,l.stripVTControlCharacters)(t).length,i=Math.max(n.reduce((e,t)=>{let n=(0,l.stripVTControlCharacters)(t);return n.length>e?n.length:e},0),r)+2,a=n.map(e=>`${J.default.gray(X)} ${J.default.dim(e)}${` `.repeat(i-(0,l.stripVTControlCharacters)(e).length)}${J.default.gray(X)}`).join(`
|
|
113
|
+
`);process.stdout.write(`${J.default.gray(X)}
|
|
114
|
+
${J.default.green(Gf)} ${J.default.reset(t)} ${J.default.gray(ep.repeat(Math.max(i-r-1,1))+tp)}
|
|
119
115
|
${a}
|
|
120
|
-
${
|
|
121
|
-
`)},
|
|
116
|
+
${J.default.gray(np+ep.repeat(i+2)+rp)}
|
|
117
|
+
`)},vp=(e=``)=>{process.stdout.write(`${J.default.gray(qf)} ${J.default.red(e)}
|
|
122
118
|
|
|
123
|
-
`)},
|
|
124
|
-
`)},
|
|
125
|
-
${
|
|
119
|
+
`)},yp=(e=``)=>{process.stdout.write(`${J.default.gray(Kf)} ${e}
|
|
120
|
+
`)},bp=(e=``)=>{process.stdout.write(`${J.default.gray(X)}
|
|
121
|
+
${J.default.gray(qf)} ${e}
|
|
126
122
|
|
|
127
|
-
`)},
|
|
128
|
-
`);n.push(`${t} ${r}`,...i.map(e=>`${
|
|
123
|
+
`)},xp={message:(e=``,{symbol:t=J.default.gray(X)}={})=>{let n=[`${J.default.gray(X)}`];if(e){let[r,...i]=e.split(`
|
|
124
|
+
`);n.push(`${t} ${r}`,...i.map(e=>`${J.default.gray(X)} ${e}`))}process.stdout.write(`${n.join(`
|
|
129
125
|
`)}
|
|
130
|
-
`)},info:e=>{
|
|
126
|
+
`)},info:e=>{xp.message(e,{symbol:J.default.blue(ip)})},success:e=>{xp.message(e,{symbol:J.default.green(ap)})},step:e=>{xp.message(e,{symbol:J.default.green(Gf)})},warn:e=>{xp.message(e,{symbol:J.default.yellow(op)})},warning:e=>{xp.warn(e)},error:e=>{xp.message(e,{symbol:J.default.red(sp)})}},Sp=`${J.default.gray(X)} `,Cp={message:async(e,{symbol:t=J.default.gray(X)}={})=>{process.stdout.write(`${J.default.gray(X)}
|
|
131
127
|
${t} `);let n=3;for await(let t of e){t=t.replace(/\n/g,`
|
|
132
|
-
${
|
|
128
|
+
${Sp}`),t.includes(`
|
|
133
129
|
`)&&(n=3+(0,l.stripVTControlCharacters)(t.slice(t.lastIndexOf(`
|
|
134
130
|
`))).length);let e=(0,l.stripVTControlCharacters)(t).length;n+e<process.stdout.columns?(n+=e,process.stdout.write(t)):(process.stdout.write(`
|
|
135
|
-
${
|
|
136
|
-
`)},info:e=>
|
|
131
|
+
${Sp}${t.trimStart()}`),n=3+(0,l.stripVTControlCharacters)(t.trimStart()).length)}process.stdout.write(`
|
|
132
|
+
`)},info:e=>Cp.message(e,{symbol:J.default.blue(ip)}),success:e=>Cp.message(e,{symbol:J.default.green(ap)}),step:e=>Cp.message(e,{symbol:J.default.green(Gf)}),warn:e=>Cp.message(e,{symbol:J.default.yellow(op)}),warning:e=>Cp.warn(e),error:e=>Cp.message(e,{symbol:J.default.red(sp)})},wp=({indicator:e=`dots`}={})=>{let t=Vf?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],n=Vf?80:120,r=process.env.CI===`true`,i,a,o=!1,s=``,c,l=performance.now(),u=e=>{o&&y(e>1?`Something went wrong`:`Canceled`,e)},d=()=>u(2),f=()=>u(1),p=()=>{process.on(`uncaughtExceptionMonitor`,d),process.on(`unhandledRejection`,d),process.on(`SIGINT`,f),process.on(`SIGTERM`,f),process.on(`exit`,u)},m=()=>{process.removeListener(`uncaughtExceptionMonitor`,d),process.removeListener(`unhandledRejection`,d),process.removeListener(`SIGINT`,f),process.removeListener(`SIGTERM`,f),process.removeListener(`exit`,u)},h=()=>{if(c===void 0)return;r&&process.stdout.write(`
|
|
137
133
|
`);let e=c.split(`
|
|
138
|
-
`);process.stdout.write(
|
|
139
|
-
`);let d=0,f=0;p(),a=setInterval(()=>{if(r&&s===c)return;h(),c=s;let n=
|
|
134
|
+
`);process.stdout.write(zf.cursor.move(-999,e.length-1)),process.stdout.write(zf.erase.down(e.length))},g=e=>e.replace(/\.+$/,``),_=e=>{let t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},v=(u=``)=>{o=!0,i=sf(),s=g(u),l=performance.now(),process.stdout.write(`${J.default.gray(X)}
|
|
135
|
+
`);let d=0,f=0;p(),a=setInterval(()=>{if(r&&s===c)return;h(),c=s;let n=J.default.magenta(t[d]);if(r)process.stdout.write(`${n} ${s}...`);else if(e===`timer`)process.stdout.write(`${n} ${s} ${_(l)}`);else{let e=`.`.repeat(Math.floor(f)).slice(0,3);process.stdout.write(`${n} ${s}${e}`)}d=d+1<t.length?d+1:0,f=f<t.length?f+.125:0},n)},y=(t=``,n=0)=>{o=!1,clearInterval(a),h();let r=n===0?J.default.green(Gf):n===1?J.default.red(Uf):J.default.red(Wf);s=g(t??s),e===`timer`?process.stdout.write(`${r} ${s} ${_(l)}
|
|
140
136
|
`):process.stdout.write(`${r} ${s}
|
|
141
|
-
`),m(),i()};return{start:v,stop:y,message:(e=``)=>{s=g(e??s)}}},Am=async(e,t)=>{let n={},r=Object.keys(e);for(let i of r){let r=e[i],a=await r({results:n})?.catch(e=>{throw e});if(typeof t?.onCancel==`function`&&up(a)){n[i]=`canceled`,t.onCancel({results:n});continue}n[i]=a}return n},jm=async e=>{for(let t of e){if(t.enabled===!1)continue;let e=km();e.start(t.title);let n=await t.task(e.message);e.stop(n||t.title)}};let Mm;function Nm(){try{return o.default.statSync(`/.dockerenv`),!0}catch{return!1}}function Pm(){try{return o.default.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`docker`)}catch{return!1}}function Fm(){return Mm===void 0&&(Mm=Nm()||Pm()),Mm}let Im;const Lm=()=>{try{return o.default.statSync(`/run/.containerenv`),!0}catch{return!1}};function Rm(){return Im===void 0&&(Im=Lm()||Fm()),Im}const zm=()=>{if(x.default.platform!==`linux`)return!1;if(S.default.release().toLowerCase().includes(`microsoft`))return!Rm();try{return o.default.readFileSync(`/proc/version`,`utf8`).toLowerCase().includes(`microsoft`)?!Rm():!1}catch{return!1}};var Bm=x.default.env.__IS_WSL_TEST__?zm:zm();const Vm=(()=>{let e=`/mnt/`,t;return async function(){if(t)return t;let n=`/etc/wsl.conf`,r=!1;try{await E.default.access(n,E.constants.F_OK),r=!0}catch{}if(!r)return e;let i=await E.default.readFile(n,{encoding:`utf8`}),a=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(i);return a?(t=a.groups.mountPoint.trim(),t=t.endsWith(`/`)?t:`${t}/`,t):e}})(),Hm=async()=>`${await Vm()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,Um=async()=>Bm?Hm():`${x.default.env.SYSTEMROOT||x.default.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;function Wm(e,t,n){let r=n=>Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let e=n();return r(e),e},set(e){r(e)}}),e}const Gm=(0,l.promisify)(T.execFile);async function Km(){if(x.default.platform!==`darwin`)throw Error(`macOS only`);let{stdout:e}=await Gm(`defaults`,[`read`,`com.apple.LaunchServices/com.apple.launchservices.secure`,`LSHandlers`]);return/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??`com.apple.Safari`}const qm=(0,l.promisify)(T.execFile);async function Jm(e,{humanReadableOutput:t=!0,signal:n}={}){if(x.default.platform!==`darwin`)throw Error(`macOS only`);let r=t?[]:[`-ss`],i={};n&&(i.signal=n);let{stdout:a}=await qm(`osascript`,[`-e`,e,r],i);return a.trim()}async function Ym(e){return Jm(`tell application "Finder" to set app_path to application file id "${e}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}const Xm=(0,l.promisify)(T.execFile),Zm={AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:`Edge`,id:`com.microsoft.edge.old`},MSEdgeDHTML:{name:`Edge`,id:`com.microsoft.edge`},MSEdgeHTM:{name:`Edge`,id:`com.microsoft.edge`},"IE.HTTP":{name:`Internet Explorer`,id:`com.microsoft.ie`},FirefoxURL:{name:`Firefox`,id:`org.mozilla.firefox`},ChromeHTML:{name:`Chrome`,id:`com.google.chrome`},BraveHTML:{name:`Brave`,id:`com.brave.Browser`},BraveBHTML:{name:`Brave Beta`,id:`com.brave.Browser.beta`},BraveSSHTM:{name:`Brave Nightly`,id:`com.brave.Browser.nightly`}};var Qm=class extends Error{};async function $m(e=Xm){let{stdout:t}=await e(`reg`,[`QUERY`,` HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice`,`/v`,`ProgId`]),n=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!n)throw new Qm(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:r}=n.groups,i=Zm[r];if(!i)throw new Qm(`Unknown browser ID: ${r}`);return i}const eh=(0,l.promisify)(T.execFile),th=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase());async function nh(){if(x.default.platform===`darwin`){let e=await Km();return{name:await Ym(e),id:e}}if(x.default.platform===`linux`){let{stdout:e}=await eh(`xdg-mime`,[`query`,`default`,`x-scheme-handler/http`]),t=e.trim();return{name:th(t.replace(/.desktop$/,``).replace(`-`,` `)),id:t}}if(x.default.platform===`win32`)return $m();throw Error(`Only macOS, Linux, and Windows are supported`)}const rh=(0,l.promisify)(T.default.execFile),ih=b.default.dirname((0,s.fileURLToPath)(require(`url`).pathToFileURL(__filename).href)),ah=b.default.join(ih,`xdg-open`),{platform:oh,arch:sh}=x.default;async function ch(){let e=await Um(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,n=a.Buffer.from(t,`utf16le`).toString(`base64`),{stdout:r}=await rh(e,[`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`,n],{encoding:`utf8`}),i=r.trim(),o={ChromeHTML:`com.google.chrome`,BraveHTML:`com.brave.Browser`,MSEdgeHTM:`com.microsoft.edge`,FirefoxURL:`org.mozilla.firefox`};return o[i]?{id:o[i]}:{}}const lh=async(e,t)=>{let n;for(let r of e)try{return await t(r)}catch(e){n=e}throw n},uh=async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return lh(e.app,t=>uh({...e,app:t}));let{name:t,arguments:n=[]}=e.app??{};if(n=[...n],Array.isArray(t))return lh(t,t=>uh({...e,app:{name:t,arguments:n}}));if(t===`browser`||t===`browserPrivate`){let r={"com.google.chrome":`chrome`,"google-chrome.desktop":`chrome`,"com.brave.Browser":`brave`,"org.mozilla.firefox":`firefox`,"firefox.desktop":`firefox`,"com.microsoft.msedge":`edge`,"com.microsoft.edge":`edge`,"com.microsoft.edgemac":`edge`,"microsoft-edge.desktop":`edge`},i={chrome:`--incognito`,brave:`--incognito`,firefox:`--private-window`,edge:`--inPrivate`},a=Bm?await ch():await nh();if(a.id in r){let o=r[a.id];return t===`browserPrivate`&&n.push(i[o]),uh({...e,app:{name:mh[o],arguments:n}})}throw Error(`${a.name} is not supported as a default browser`)}let r,i=[],o={};if(oh===`darwin`)r=`open`,e.wait&&i.push(`--wait-apps`),e.background&&i.push(`--background`),e.newInstance&&i.push(`--new`),t&&i.push(`-a`,t);else if(oh===`win32`||Bm&&!Rm()&&!t){r=await Um(),i.push(`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`),Bm||(o.windowsVerbatimArguments=!0);let s=[`Start`];e.wait&&s.push(`-Wait`),t?(s.push(`"\`"${t}\`""`),e.target&&n.push(e.target)):e.target&&s.push(`"${e.target}"`),n.length>0&&(n=n.map(e=>`"\`"${e}\`""`),s.push(`-ArgumentList`,n.join(`,`))),e.target=a.Buffer.from(s.join(` `),`utf16le`).toString(`base64`)}else{if(t)r=t;else{let e=!ih||ih===`/`,t=!1;try{await E.default.access(ah,E.constants.X_OK),t=!0}catch{}r=x.default.versions.electron??(oh===`android`||e||!t)?`xdg-open`:ah}n.length>0&&i.push(...n),e.wait||(o.stdio=`ignore`,o.detached=!0)}oh===`darwin`&&n.length>0&&i.push(`--args`,...n),e.target&&i.push(e.target);let s=T.default.spawn(r,i,o);return e.wait?new Promise((t,n)=>{s.once(`error`,n),s.once(`close`,r=>{if(!e.allowNonzeroExitCode&&r>0){n(Error(`Exited with code ${r}`));return}t(s)})}):(s.unref(),s)},dh=(e,t)=>{if(typeof e!=`string`)throw TypeError("Expected a `target`");return uh({...t,target:e})};function fh(e){if(typeof e==`string`||Array.isArray(e))return e;let{[sh]:t}=e;if(!t)throw Error(`${sh} is not supported`);return t}function ph({[oh]:e},{wsl:t}){if(t&&Bm)return fh(t);if(!e)throw Error(`${oh} is not supported`);return fh(e)}const mh={};Wm(mh,`chrome`,()=>ph({darwin:`google chrome`,win32:`chrome`,linux:[`google-chrome`,`google-chrome-stable`,`chromium`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`,x64:[`/mnt/c/Program Files/Google/Chrome/Application/chrome.exe`,`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`]}})),Wm(mh,`brave`,()=>ph({darwin:`brave browser`,win32:`brave`,linux:[`brave-browser`,`brave`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`,x64:[`/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe`,`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`]}})),Wm(mh,`firefox`,()=>ph({darwin:`firefox`,win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:`firefox`},{wsl:`/mnt/c/Program Files/Mozilla Firefox/firefox.exe`})),Wm(mh,`edge`,()=>ph({darwin:`microsoft edge`,win32:`msedge`,linux:[`microsoft-edge`,`microsoft-edge-dev`]},{wsl:`/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`})),Wm(mh,`browser`,()=>`browser`),Wm(mh,`browserPrivate`,()=>`browserPrivate`);var hh=dh;async function gh(e,t=void 0){try{(await hh(e)).once(`error`,n=>{console.log(Sf.yellow(t??`Could not open the browser. Please visit the URL manually: ${e}`))})}catch{console.log(Sf.yellow(t??`Could not open the browser. Please visit the URL manually: ${e}`))}}function _h(e){let t=e||bh();if((0,o.existsSync)(t)){let e=(0,o.readFileSync)(t,`utf8`);return JSON.parse(e).token}}function vh(e,t){let n=t||bh();(0,o.existsSync)((0,b.dirname)(n))||(0,o.mkdirSync)((0,b.dirname)(n),{recursive:!0}),(0,o.writeFileSync)(n,JSON.stringify({_:`This is your Blink credentials file. DO NOT SHARE THIS FILE WITH ANYONE!`,token:e}))}function yh(e){let t=e||bh();(0,o.existsSync)(t)&&(0,o.unlinkSync)(t)}function bh(){let e=Fd(`blink`).dataDirs();if(e.length===0)throw Error(`No suitable data directory for Blink storage found!`);return(0,b.join)(e[0],`auth.json`)}function xh(e={}){let{autoCheck:t=!0,onAuthChange:n,onLoginUrl:r,testAuthPath:i}=e,[a,o]=(0,_.useState)(),[s,c]=(0,_.useState)(()=>_h(i)),[l,u]=(0,_.useState)(),d=(0,_.useRef)(n),f=(0,_.useRef)(r);(0,_.useEffect)(()=>{d.current=n,f.current=r},[n,r]);let p=(0,_.useCallback)(async()=>{u(void 0);try{let e=_h(i);if(c(e),!e){o(void 0),d.current?.(void 0);return}let t=new hd({baseURL:`https://blink.coder.com`});t.authToken=e;let n={email:(await t.users.me()).email};o(n),d.current?.(n)}catch(e){o(void 0),u(e instanceof Error?e.message:String(e)),d.current?.(void 0)}},[i]),m=(0,_.useCallback)(async()=>{u(void 0);try{let e=new hd,t=await e.auth.token((e,t)=>{f.current?.(e,t)});e.authToken=t;let n=await e.users.me();vh(t,i),c(t);let r={email:n.email};return o(r),d.current?.(r),r}catch(e){let t=e instanceof Error?e.message:String(e);throw u(t),e}},[i]),h=(0,_.useCallback)(()=>{yh(i),c(void 0),o(void 0),u(void 0),d.current?.(void 0)},[i]);return(0,_.useEffect)(()=>{t&&p()},[t,p]),{user:a,token:s,error:l,login:m,logout:h}}let Sh=Promise.resolve();var Ch=class{constructor(e){this.printLog=e}setPrintLog(e){this.printLog=e}error(e,...t){Sh=Sh.then(()=>this.printLog(`error`,e,...t).catch(e=>{console.error(`Error printing log:`,e)}))}log(e,...t){Sh=Sh.then(()=>this.printLog(`log`,e,...t).catch(e=>{console.error(`Error printing log:`,e)}))}flush(){return Sh}};const wh=(0,_.createContext)(void 0);function Th(e){let{directory:t,logger:r,onBuildStart:i,onBuildSuccess:a,onBuildError:o}=typeof e==`string`?{directory:e,logger:new Ch(async()=>{})}:e,s=(0,_.useMemo)(()=>n.resolveConfig(t),[t]),[c,l]=(0,_.useState)(void 0),[u,d]=(0,_.useState)(void 0),[f,p]=(0,_.useState)(`building`),m=(0,_.useRef)(i),h=(0,_.useRef)(a),g=(0,_.useRef)(o);return(0,_.useEffect)(()=>{m.current=i,h.current=a,g.current=o},[i,a,o]),(0,_.useEffect)(()=>{let e=new AbortController;return s.build({cwd:t,entry:s.entry,outdir:s.outdir,watch:!0,dev:!0,signal:e.signal,onStart:()=>{p(`building`),l(void 0),d(void 0),m.current?.()},onResult:e=>{`error`in e?(l(e.error),p(`error`),g.current?.(e.error)):(d(e),p(`success`),h.current?.(e))}}).catch(e=>{r.error(`system`,`error`,e),p(`error`),l(e),g.current?.(e)}),()=>{e.abort()}},[t]),(0,_.useMemo)(()=>({error:c,status:f,result:u,entry:s.entry,outdir:s.outdir}),[c,f,u,s.entry,s.outdir])}function Eh(){return/[<>:"/\\|?*\u0000-\u001F]|[. ]$/g}function Dh(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}const Oh=100,kh=/^\.+(\\|\/)|^\.+$/,Ah=/[. ]+$/,jh=/[\p{Control}\p{Format}\p{Zl}\p{Zp}\uFFF0-\uFFFF]/gu,Mh=/[\p{Control}\p{Format}\p{Zl}\p{Zp}\uFFF0-\uFFFF]/u,Nh=e=>e===``,Ph=/([<>:"/\\|?*\u0000-\u001F]){2,}/g,Fh=/[\t\n\r\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+/g;let Ih;function Lh(){return Ih??=new Intl.Segmenter(void 0,{granularity:`grapheme`}),Ih}function Rh(e,t={}){if(typeof e!=`string`)throw TypeError(`Expected a string`);let n=t.replacement??`!`;if(Eh().test(n)||[...n].some(e=>Mh.test(e)&&!Nh(e)))throw Error(`Replacement string cannot contain reserved filename characters`);e=e.normalize(`NFC`),e=e.replaceAll(Fh,` `),n.length>0&&(e=e.replaceAll(Ph,`$1`)),e=e.replace(Ah,``),e=e.replace(kh,n),e=e.replace(Eh(),n),e=e.replaceAll(jh,e=>Nh(e)?e:n),e.length===0&&(e=n),e=Dh().test(e)?e+n:e;let r=typeof t.maxLength==`number`?t.maxLength:100;if(e.length>r){let t=e.lastIndexOf(`.`);if(t===-1)e=zh(e,r);else{let n=e.slice(0,t),i=e.slice(t),a=Math.max(0,r-i.length);e=zh(n,a)+i}}return e}function zh(e,t){if(e.length<=t)return e;let n=0,r=``;for(let{segment:i}of Lh().segment(e)){let e=n+i.length;if(e>t)break;r+=i,n=e}return r}function Bh(e){return`${e}.lock`}function Vh(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function Hh(e,t={}){let n=Bh(e),r=process.pid.toString();try{return o.writeFileSync(n,r,{flag:`wx`}),!0}catch(r){if(r.code!==`EEXIST`)throw r;if(t.stale===0)return!1;let i;try{i=parseInt(o.readFileSync(n,`utf8`),10)}catch{return o.unlinkSync(n),Hh(e,{...t,stale:0})}if(!Vh(i))try{return o.unlinkSync(n),Hh(e,{...t,stale:0})}catch(n){if(n.code===`ENOENT`)return Hh(e,{...t,stale:0});throw n}return!1}}async function Uh(e,t={}){let n={stale:!0,retries:0,retryInterval:100,...t},r=b.resolve(e),i=0;for(;i<=n.retries;){if(Hh(r,n))return()=>Wh(r);i<n.retries&&await new Promise(e=>setTimeout(e,n.retryInterval)),i++}let a=Error(`Lock file is already being held`);throw a.code=`ELOCKED`,a.file=r,a}function Wh(e){let t=b.resolve(e),n=Bh(t);try{if(parseInt(o.readFileSync(n,`utf8`),10)!==process.pid){let e=Error(`Lock is not owned by this process`);throw e.code=`ENOTACQUIRED`,e}o.unlinkSync(n)}catch(e){if(e.code===`ENOENT`){let e=Error(`Lock is not acquired`);throw e.code=`ENOTACQUIRED`,e}throw e}}function Gh(e){let t=b.resolve(e),n=Bh(t);try{if(!o.existsSync(n))return{locked:!1};let e=o.readFileSync(n,`utf8`),t=parseInt(e,10);return Vh(t)?{locked:!0,pid:t}:{locked:!1}}catch(e){return e.code,{locked:!1}}}const Kh=e=>{o.mkdirSync(e,{recursive:!0})},qh=e=>{try{o.fdatasyncSync(e)}catch{}try{o.closeSync(e)}catch{}},Jh=e=>{try{let t=o.openSync(e,`r`);try{o.fsyncSync(t)}finally{o.closeSync(t)}}catch{}},Yh=(e,t)=>{let n=b.dirname(e);Kh(n);let r=b.join(n,`.tmp-`+process.pid+`-`+Math.random().toString(36).slice(2)),i;try{i=o.openSync(r,`w`),o.writeFileSync(i,t,`utf-8`),qh(i),i=void 0,o.renameSync(r,e),Jh(e),Jh(n)}catch(e){if(i!==void 0)try{o.closeSync(i)}catch{}try{o.rmSync(r,{force:!0})}catch{}throw e}},Xh=(e,t)=>{let n=new Map,r,i=e=>{if(o.statSync(e,{throwIfNoEntry:!1}))return JSON.parse(o.readFileSync(e,`utf-8`))},a=(e,t)=>{Yh(e,JSON.stringify(t,null,2))},s=async()=>{if(r)throw Error(`Index is already locked`);let t=b.join(e,`index.json`);Kh(e),o.existsSync(t)||o.writeFileSync(t,JSON.stringify({ids:{}}),`utf-8`);let n=await Uh(t,{stale:!0,retries:5,retryInterval:100});return r=()=>Promise.resolve(n()),()=>{n(),r=void 0}},c=async()=>{let t=b.join(e,`index.json`),n=i(t)??{ids:{}};return n.ids||={},n},l=async t=>{let n=b.join(e,`index.json`);a(n,t)},u=async t=>{let n=(await c()).ids[t];if(n)return b.join(e,n)},d=async t=>{let n=(await c()).ids[t];if(!n)return;let r=b.join(e,n);if(o.statSync(r,{throwIfNoEntry:!1}))return JSON.parse(o.readFileSync(r,`utf-8`))},f=async n=>{let r=n[t],i=String(r),o=Rh(i,{replacement:`_`})+`.json`,u=await s();try{let t=await c();t.ids[i]=o,t.current=i;let r=b.join(e,o);a(r,n),await l(t)}finally{await u()}};return{async get(e){return await d(e)},async list(){if(!o.statSync(e,{throwIfNoEntry:!1}))return[];let t=await c(),n=[];for(let[r,i]of Object.entries(t.ids)){let t=b.join(e,i),a=o.statSync(t,{throwIfNoEntry:!1});if(!a)continue;let s=Gh(t);n.push({key:r,locked:s.locked,pid:s.pid,mtime:a.mtimeMs})}return n.sort((e,t)=>t.mtime-e.mtime),n},async lock(r,i){if(n.has(r))throw Error(`Key "${r}" is already locked in this process`);let a=await u(r);if(!a){let t=Rh(r,{replacement:`_`})+`.json`,n=await s();try{let n=await c();n.ids[r]=t;let i=b.join(e,t);Kh(e),o.writeFileSync(i,JSON.stringify({}),`utf-8`),await l(n),a=i}finally{await n()}}if(i?.force){let e=Gh(a);if(e.locked&&e.pid&&e.pid!==process.pid)try{process.kill(e.pid,`SIGTERM`),await new Promise(e=>setTimeout(e,100))}catch(t){t.code!==`ESRCH`&&console.warn(`Failed to kill process ${e.pid}:`,t.message)}}let p=await Uh(a,{stale:!0,retries:i?.force?10:5,retryInterval:(i?.force,100)});return n.set(r,()=>Promise.resolve(p())),{async get(){let e=await d(r);if(!e)throw Error(`Key ${r} not found`);return e},async set(e){await f(e)},async update(e){let n=await d(r);if(!n||!(t in n))throw Error(`Key ${r} not found`);await f({...n,...e})},async delete(){let t=await s();try{let t=await c(),n=t.ids[r];if(n){delete t.ids[r],t.current===r&&(t.current=void 0),await l(t);let i=b.join(e,n);try{o.rmSync(i,{force:!0}),Jh(e)}catch{}}}finally{await t()}},async release(){try{p()}finally{n.delete(r)}}}},dispose(){n.clear()}}},Zh=(e,t)=>{let n=t?.pollInterval??200,r=t?.debounce??50,i=new Set,a,s,c=new Map,l=new Map,u=b.join(e,`index.json`),d=()=>{try{if(!o.statSync(u,{throwIfNoEntry:!1}))return{ids:{}};let e=o.readFileSync(u,`utf-8`);return{ids:JSON.parse(e).ids??{}}}catch{return{ids:{}}}},f=(e,t,n,r)=>{for(let a of i)try{a({key:e,value:t,locked:n,pid:r})}catch(e){console.error(`Error in onChange callback:`,e)}},p=(t,n,r=!1)=>{let i=b.join(e,n);try{let e=o.statSync(i,{throwIfNoEntry:!1}),a=l.get(n);if(!e){a&&(l.delete(n),f(t,void 0,!1));return}let s=e.mtimeMs,c=a?{locked:a.locked,pid:a.pid}:{locked:!1,pid:void 0};if((r||!a)&&(c=Gh(i)),!a||a.mtime!==s||a.locked!==c.locked||a.pid!==c.pid){let e;e=!a||a.mtime!==s?JSON.parse(o.readFileSync(i,`utf-8`)):a.cachedValue,l.set(n,{mtime:s,key:t,locked:c.locked,pid:c.pid,cachedValue:e}),f(t,e,c.locked,c.pid)}}catch{}},m=()=>{try{let e=d(),t=new Set(Object.keys(e.ids));for(let[t,n]of Object.entries(e.ids))p(t,n,!0);for(let[e,n]of l.entries())t.has(n.key)||(l.delete(e),f(n.key,void 0,!1))}catch{}},h=(e,t,n=!1)=>{let i=c.get(e);i&&clearTimeout(i),c.set(e,setTimeout(()=>{c.delete(e),p(e,t,n)},r))},g=()=>{if(a)return;try{o.mkdirSync(e,{recursive:!0})}catch{}a=o.watch(e,(e,t)=>{if(!t||t.startsWith(`.tmp-`))return;if(t===`index.json`){m();return}if(t.endsWith(`.lock`)){let e=t.replace(`.lock`,``),n=d(),r=Object.keys(n.ids).find(t=>n.ids[t]===e);r&&p(r,e,!0);return}let n=d(),r=Object.keys(n.ids).find(e=>n.ids[e]===t);r&&h(r,t,!1)});let t=()=>{m(),s=setTimeout(t,n)};m(),s=setTimeout(t,n)};return{onChange(e){return i.size===0&&g(),i.add(e),()=>{if(i.delete(e),i.size===0){a&&=(a.close(),void 0),s&&=(clearTimeout(s),void 0);for(let e of c.values())clearTimeout(e);c.clear(),l.clear()}}},dispose(){a&&=(a.close(),void 0),s&&=(clearTimeout(s),void 0);for(let e of c.values())clearTimeout(e);c.clear(),i.clear(),l.clear()}}};async function Qh({id:e,agent:t,messages:n,signal:r,shouldContinueStreaming:i=$h}){n=[...n];let a=new TransformStream,o=a.writable.getWriter(),s=async()=>{let a;try{let c=await t.chat({messages:n,id:e},{signal:r}),l=(0,m.readUIMessageStream)({message:{id:crypto.randomUUID(),role:`assistant`,parts:[],metadata:{}},stream:c,onError:e=>{e instanceof Error&&e.name===`AbortError`||o.abort(e)}});for await(let e of l)o.write(e),a=e;if(a&&i(a)){n.push(a),await s();return}await o.close()}catch(e){if(e?.name===`AbortError`||r?.aborted)return;await o.abort(e)}finally{await o.close()}};return s().catch(e=>{o.abort(e)}),a.readable}const $h=e=>{if(e.role!==`assistant`)return!1;let n=e.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=e.parts.slice(n+1).filter(m.isToolOrDynamicToolUIPart);return r.length===0||r.some(e=>t.isToolApprovalOutput(e.output)&&e.output.outcome===`pending`)?!1:r.every(e=>e.state.startsWith(`output-`))},eg=(e,t,n=crypto.randomUUID())=>({created_at:new Date().toISOString(),...e,id:n,metadata:e.metadata,mode:t});function tg(e){return typeof e==`object`&&e?.__blink_internal!==void 0}function ng(e){return typeof e.metadata==`object`&&e.metadata!==null&&`__blink_log`in e.metadata&&e.metadata.__blink_log===!0&&`level`in e.metadata&&`source`in e.metadata&&`message`in e.metadata}var rg=class{chatId;agent;chatStore;serializeMessage;filterMessages;onError;chat;loading=!1;streamingMessage;status=`idle`;queue=[];logQueue=[];abortController;isProcessingQueue=!1;listeners=new Set;watcher;disposed=!1;constructor(e){this.chatId=e.chatId??`00000000-0000-0000-0000-000000000000`,this.chat={id:this.chatId,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),messages:[]},this.loading=!0,this.chatStore=Xh(e.chatsDirectory,`id`),this.serializeMessage=e.serializeMessage,this.filterMessages=e.filterMessages,this.onError=e.onError,this.watcher=Zh(e.chatsDirectory,{pollInterval:1e3,debounce:50}),this.watcher.onChange(e=>{if(e.key!==this.chatId||this.isProcessingQueue)return;if(!e.value){this.chat={id:this.chatId,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),messages:[]},this.status=`idle`,this.streamingMessage=void 0,this.notifyListeners();return}if(this.chat.updated_at===e.value?.updated_at)return;let t=e.value,n=e.locked?`streaming`:`idle`,r=this.chat.updated_at!==t?.updated_at||this.status!==n;this.chat=t,this.streamingMessage=void 0,this.status=n,r&&this.notifyListeners()}),this.chatStore.get(this.chatId).then(e=>{this.disposed||e&&(this.chat=e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);this.onError?.(t)}).finally(()=>{this.loading=!1,this.notifyListeners()})}setAgent(e){this.agent=e}getState(){return{id:this.chatId,key:this.chat?.key,messages:(this.chat?.messages??[]).filter(e=>!tg(e.metadata)),created_at:this.chat?.created_at,updated_at:this.chat?.updated_at,status:this.status,streamingMessage:this.streamingMessage,loading:this.loading,queuedMessages:this.queue,queuedLogs:this.logQueue}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}async upsertMessages(e,t){let n=!1,r;t?r=t:(r=await this.chatStore.lock(this.chatId),n=!0);try{let t=await r.get();(!t.id||!Array.isArray(t.messages))&&(t={id:this.chatId,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),messages:[]});let n=[...t.messages];for(let t of e){let e;if(this.serializeMessage){let n=this.serializeMessage(t);if(n===void 0)return;e=n}else e={...t,created_at:new Date().toISOString(),mode:`run`,metadata:t.metadata,id:t.id??crypto.randomUUID()};let r=n.findIndex(t=>t.id===e.id);r===-1?n.push(e):n.splice(r,1,e)}this.chat={...t,updated_at:new Date().toISOString(),messages:n},await r.set(this.chat),this.notifyListeners()}finally{n&&await r.release()}}async deleteMessages(e){let t;try{t=await this.chatStore.lock(this.chatId);let n=await t.get();this.chat.messages=n.messages.filter(t=>!e.includes(t.id)),this.chat.updated_at=new Date().toISOString(),await t.set(this.chat),this.notifyListeners()}finally{t&&await t.release()}}async queueLogMessage({message:e,level:t,source:n}){let r=`(EDIT MODE NOTE) ${n===`agent`?`The agent`:"The `blink dev` CLI"} printed the following ${t}:\n\`\`\`\n${(0,l.stripVTControlCharacters)(e)}\n\`\`\`\n`,i={id:crypto.randomUUID(),created_at:new Date().toISOString(),role:`user`,parts:[{type:`text`,text:r}],metadata:{__blink_log:!0,level:t,source:n,message:e},mode:`edit`};this.logQueue.push(i),this.notifyListeners()}async flushLogQueue(e){if(this.logQueue.length===0)return;let t=[...this.logQueue];this.logQueue=[],await this.upsertMessages(t,e)}async sendMessages(e){if(this.status=`idle`,this.notifyListeners(),this.isProcessingQueue){this.queue.push(...e),this.notifyListeners();return}this.queue=e,this.processQueueOrRun()}async start(){this.status=`idle`,this.notifyListeners(),this.processQueueOrRun()}async stop(){this.status=`idle`,this.abortController?.abort(),this.notifyListeners()}async processQueueOrRun(){if(!this.agent){this.onError?.(`The agent is not available. Please wait for the build to succeed.`),this.queue=[];return}if(this.isProcessingQueue)return;this.isProcessingQueue=!0;let e;try{e=await this.chatStore.lock(this.chatId),await this.flushLogQueue(e);let n=!0;for(;this.queue.length>0||n;)try{var t=Xs();n=!1;let r=new AbortController;this.abortController=r;let i=[...this.queue];this.queue=[],this.streamingMessage=void 0,this.status=`streaming`,this.notifyListeners(),i.length>0&&await this.upsertMessages(i,e);let a=this.chat.messages;this.filterMessages&&(a=a.filter(this.filterMessages)),a=a.map(e=>({...e,parts:e.parts.map(e=>!(0,m.isToolOrDynamicToolUIPart)(e)||e.input!==``?e:{...e,input:{}})})),t.u(await this.agent.lock.read());let o=performance.now(),s=await Qh({agent:this.agent.client,id:this.chatId,signal:r.signal,messages:a}),c=async t=>{let n=t;if(this.serializeMessage){let e=this.serializeMessage(t);if(e===void 0)return;n=e}this.chat.updated_at=new Date().toISOString(),this.chat.messages.push(n),this.streamingMessage=void 0,await e?.set(this.chat)},l=s.getReader();r.signal.addEventListener(`abort`,()=>{l.cancel().catch(()=>{})},{once:!0});let u;try{for(;;){let{done:e,value:t}=await l.read();if(e||r.signal.aborted)break;u||=performance.now()-o,this.streamingMessage&&t.id!==this.streamingMessage.id&&await c(this.streamingMessage);let n={...t,metadata:{...typeof t.metadata==`object`&&t.metadata!==null?t.metadata:{},ttft:u}};this.streamingMessage=this.serializeMessage?this.serializeMessage(n):n,this.notifyListeners()}}finally{l.releaseLock()}this.streamingMessage&&await c(this.streamingMessage)}catch(e){t.e=e}finally{t.d()}}catch(e){let t=e instanceof Error?e.message:String(e);this.onError?.(t)}finally{this.isProcessingQueue=!1,this.streamingMessage=void 0,this.status=`idle`,e&&(await this.flushLogQueue(e),this.chat.updated_at=new Date().toISOString(),await e.set(this.chat),await e.release(),this.notifyListeners())}}stopStreaming(){this.abortController?.abort()}clearQueue(){this.queue=[],this.notifyListeners()}async resetChat(){this.abortController?.abort(),this.resetChatState(),this.notifyListeners();let e;try{e=await this.chatStore.lock(this.chatId),await e.delete()}catch{}finally{if(e)try{await e.release()}catch{}}}dispose(){this.disposed=!0,this.watcher.dispose(),this.listeners.clear(),this.stopStreaming()}resetChatState(){this.chat={id:this.chatId,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),messages:[]},this.streamingMessage=void 0,this.status=`idle`,this.queue=[],this.logQueue=[]}notifyListeners(){let e=this.getState();for(let t of this.listeners)t(e)}};function ig(e){let{chatId:t,agent:n,chatsDirectory:r,serializeMessage:i,filterMessages:a,onError:o}=e,s=(0,_.useRef)(null),[c,l]=(0,_.useState)({id:t,messages:[],status:`idle`,loading:!0,queuedMessages:[],queuedLogs:[]});(0,_.useEffect)(()=>{s.current&&s.current.dispose();let e=new rg({chatId:t,chatsDirectory:r,serializeMessage:i,filterMessages:a,onError:o}),n=e.subscribe(e=>{l(e)});return l(e.getState()),s.current=e,()=>{n(),e.dispose(),s.current=null}},[t,r]),(0,_.useEffect)(()=>{s.current&&s.current.setAgent(n)},[n]);let u=(0,_.useCallback)(async e=>{s.current&&await s.current.sendMessages([e])},[]),d=(0,_.useCallback)(async e=>{s.current&&await s.current.upsertMessages([e])},[]),f=(0,_.useCallback)(async e=>{s.current&&await s.current.queueLogMessage(e)},[]),p=(0,_.useCallback)(()=>{s.current&&s.current.stopStreaming()},[]),m=(0,_.useCallback)(async()=>{s.current&&await s.current.resetChat()},[]),h=(0,_.useCallback)(()=>{s.current&&s.current.clearQueue()},[]),g=(0,_.useCallback)(async e=>{s.current&&await s.current.deleteMessages([e])},[]),v=(0,_.useCallback)(async()=>{s.current&&await s.current.start()},[]);return{...c,sendMessage:u,upsertMessage:d,queueLogMessage:f,stopStreaming:p,resetChat:m,clearQueue:h,deleteMessage:g,start:v}}function ag(e){return(0,f.join)(e,`.blink`,`devhook.txt`)}function og(e){return(0,p.existsSync)(ag(e))}function sg(e){let t=ag(e);if((0,p.existsSync)(t))return(0,p.readFileSync)(t,`utf-8`).trim()}function cg(e){let t=ag(e);if((0,p.mkdirSync)((0,f.dirname)(t),{recursive:!0}),(0,p.existsSync)(t))return(0,p.readFileSync)(t,`utf-8`);let n=crypto.randomUUID();return(0,p.writeFileSync)(t,n),n}const lg=(e,t)=>e.json({error:t},400),ug=e=>{let t=e.req.param(`key`);return!t||t===``?{key:t,err:`Key is required`}:t.length>475?{key:t,err:`Key is too long. Max length is 475 characters.`}:{key:t}},dg=()=>new t.Hono,fg=dg().get(`/:key`,async e=>{let{key:t,err:n}=ug(e);if(n)return lg(e,n);let r=await e.env.store.get(t);return e.json({value:r},200)}).post(`/:key`,t.validator(`json`,(e,t)=>{let n=e.value;return n?typeof n==`string`?n.length>2e4?lg(t,`Value is too long. Max length is 20,000 characters.`):{value:n}:lg(t,`Value must be a string`):lg(t,`Value is required`)}),async e=>{let{key:t,err:n}=ug(e);if(n)return lg(e,n);let{value:r}=e.req.valid(`json`);return await e.env.store.set(t,r),e.body(null,204)}).delete(`/:key`,async e=>{let{key:t,err:n}=ug(e);return n?lg(e,n):(await e.env.store.delete(t),e.body(null,204))}).get(`/`,async e=>{let{cursor:t,limit:n,prefix:r}=e.req.query(),{entries:i,cursor:a}=await e.env.store.list(r,{cursor:t?String(t):void 0,limit:n?Number(n):100});return e.json({entries:i,cursor:a})}),pg=e=>{let t=e.req.param(`key`);return t?t.length>475?{key:t,err:`Key is too long. Max length is 475 characters.`}:{key:t}:{key:t,err:`Key is required`}},mg=t.validator(`param`,e=>({id:e.id})),hg=dg().post(`/:key`,async e=>{let{key:t,err:n}=pg(e);return n?lg(e,n):e.json(await e.env.chat.upsert(t),200)}).get(`/:id`,mg,async e=>{let{id:t}=e.req.valid(`param`);return e.json(await e.env.chat.get(t),200)}).get(`/:id/messages`,mg,async e=>{let{id:t}=e.req.valid(`param`);return e.json(await e.env.chat.getMessages(t),200)}).post(`/:id/sendMessages`,t.validator(`json`,e=>({id:e.id,messages:e.messages,options:e.options})),async e=>{let{id:t,messages:n,options:r}=e.req.valid(`json`);return t?(await e.env.chat.sendMessages(t,n,r),e.body(null,204)):lg(e,`ID is required`)}).delete(`/:id/messages`,mg,t.validator(`query`,e=>(typeof e.message==`string`&&(e.message=[e.message]),{messages:e.message})),async e=>{let{id:t}=e.req.valid(`param`),{messages:n}=e.req.valid(`query`);return await e.env.chat.deleteMessages(t,n),e.body(null,204)}).post(`/:id/start`,mg,async e=>{let{id:t}=e.req.valid(`param`);return await e.env.chat.start(t),e.body(null,204)}).post(`/:id/stop`,mg,async e=>{let{id:t}=e.req.valid(`param`);return await e.env.chat.stop(t),e.body(null,204)}).delete(`/:id`,mg,async e=>{let{id:t}=e.req.valid(`param`);return await e.env.chat.delete(t),e.body(null,204)}),gg=dg().post(`/v1/traces`,async e=>e.env.otlp?e.env.otlp.traces(e.req.raw):e.body(null,204)),_g=new t.Hono().onError((e,t)=>t.json({error:e instanceof Error?e.message:`Unknown error`},500)).route(`/kv`,fg).route(`/chat`,hg).route(`/otlp`,gg);var vg=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function yg(e){return typeof e==`string`&&vg.test(e)}var bg=yg;function xg(e){if(!bg(e))throw TypeError(`Invalid UUID`);let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var Sg=xg;const $=[];for(let e=0;e<256;++e)$.push((e+256).toString(16).slice(1));function Cg(e,t=0){return($[e[t+0]]+$[e[t+1]]+$[e[t+2]]+$[e[t+3]]+`-`+$[e[t+4]]+$[e[t+5]]+`-`+$[e[t+6]]+$[e[t+7]]+`-`+$[e[t+8]]+$[e[t+9]]+`-`+$[e[t+10]]+$[e[t+11]]+$[e[t+12]]+$[e[t+13]]+$[e[t+14]]+$[e[t+15]]).toLowerCase()}function wg(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let n=0;n<e.length;++n)t[n]=e.charCodeAt(n);return t}const Tg=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,Eg=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`;function Dg(e,t,n,r,i,a){let o=typeof n==`string`?wg(n):n,s=typeof r==`string`?Sg(r):r;if(typeof r==`string`&&(r=Sg(r)),r?.length!==16)throw TypeError(`Namespace must be array-like (16 iterable integer values, 0-255)`);let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,i){a||=0;for(let e=0;e<16;++e)i[a+e]=c[e];return i}return Cg(c)}function Og(e){return Array.isArray(e)?e=Buffer.from(e):typeof e==`string`&&(e=Buffer.from(e,`utf8`)),(0,u.createHash)(`sha1`).update(e).digest()}var kg=Og;function Ag(e,t,n,r){return Dg(80,kg,e,t,n,r)}Ag.DNS=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,Ag.URL=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`;var jg=Ag;function Mg(e){let n=(0,b.join)(e.dataDirectory,`chats`),r={},i=(0,b.join)(e.dataDirectory,`storage.json`);o.existsSync(i)&&(r=JSON.parse(o.readFileSync(i,`utf-8`)));let a=new Map,s=t=>{let r=a.get(t);return r||(r=new rg({chatId:t,chatsDirectory:n}),a.set(t,r)),r.setAgent(e.getAgent()),r},c={async upsert(e){let t=jg(JSON.stringify(e),jg.URL),n=s(t).getState(),r=n.messages.length===0&&!n.created_at;return{id:n.id,created:r,createdAt:n.created_at??new Date().toISOString(),key:e}},async get(e){let t=s(e).getState();return{id:t.id,createdAt:t.created_at??new Date().toISOString()}},async getMessages(e){return s(e).getState().messages},async sendMessages(e,t,n){let r=s(e),i=t.map(e=>eg(e,`run`));if(n?.behavior===`append`){await r.upsertMessages(i);return}if(n?.behavior===`interrupt`){await r.sendMessages(i);return}await r.sendMessages(i)},async deleteMessages(e,t){await s(e).deleteMessages(t)},async start(e){await s(e).start()},async stop(e){await s(e).stop()},async delete(e){await s(e).resetChat()}},l={get(e){return Promise.resolve(r[e])},set(e,t){return r[e]=t,o.writeFileSync(i,JSON.stringify(r),`utf-8`),Promise.resolve()},delete(e){return delete r[e],o.writeFileSync(i,JSON.stringify(r),`utf-8`),Promise.resolve()},list(e,t){let n=Math.min(t?.limit??100,1e3),i=t?.cursor,a=Object.keys(r).filter(t=>t.startsWith(e??``)).sort(),o=0;if(i){let e=a.indexOf(i);e!==-1&&(o=e+1)}let s=a.slice(o,o+n),c=o+n<a.length?s[s.length-1]:void 0;return Promise.resolve({entries:s.map(e=>({key:e})),cursor:c})}},u=(0,d.createServer)(t.createServerAdapter(e=>_g.fetch(e,{chat:c,store:l})));u.listen(e.port??0);let f=Xh(n,`id`);return{url:`http://127.0.0.1:${u.address().port}`,chatsDirectory:n,getChatManager:s,listChats:()=>f.list(),dispose:()=>{for(let e of a.values())e.dispose();a.clear(),f.dispose(),u.close()}}}function Ng({agent:e,capabilities:n,messages:r}){let[i,a]=(0,_.useState)(void 0),[o,s]=(0,_.useState)(!0),[c,l]=(0,_.useState)(void 0),u=(0,_.useRef)(c);(0,_.useEffect)(()=>{u.current=c},[c]);let[d,f]=(0,_.useState)(()=>t.lastUIOptions(r));(0,_.useEffect)(()=>{f(e=>{let n=t.lastUIOptions(r);return JSON.stringify(n)===JSON.stringify(e)?e:n})},[r]);let[p,m]=(0,_.useState)(void 0),h=(0,_.useCallback)((e,t)=>{if(!u.current)return!1;let n=u.current[e];return n?n.values.some(e=>e.id===t):!1},[]),g=(0,_.useCallback)(e=>{m(t=>{let n={...d,...t,...e};for(let[e,t]of Object.entries(n))h(e,t)||delete n[e];for(let[e,t]of Object.entries(u.current??{}))!n[e]&&t.defaultValue!==void 0&&(n[e]=t.defaultValue);return JSON.stringify(n)===JSON.stringify(t)?t:n})},[d,h]);(0,_.useEffect)(()=>{if(!d&&!c){m(void 0);return}g()},[d,c,g]);let v=(0,_.useRef)(void 0),y=(0,_.useRef)(void 0);(0,_.useEffect)(()=>{e!==y.current&&(y.current=e,l(void 0),m(void 0),a(void 0),s(!0),v.current=void 0)},[e]),(0,_.useEffect)(()=>{if(n&&!n.ui||!e){l(void 0),m(void 0),a(void 0),v.current=void 0;return}let t=p?JSON.stringify(p):``;if(v.current===t){s(!1),a(void 0);return}let r=new AbortController;return s(!0),a(void 0),e.ui(p?{selectedOptions:p}:{},{signal:r.signal}).then(e=>{if(!e){l(void 0);return}r.signal.aborted||(l(t=>JSON.stringify(t)===JSON.stringify(e)?t:e),v.current=t)}).catch(e=>{r.signal.aborted||a(e instanceof Error?e:Error(String(e)))}).finally(()=>{s(!1)}),()=>{r.abort()}},[e,n,p]);let b=(0,_.useCallback)((e,t)=>{g({[e]:t})},[g]);return{schema:c,options:p,setOption:b,loading:o,error:i}}function Pg(e){let t=(0,_.useRef)(e.onRequest);(0,_.useEffect)(()=>{t.current=e.onRequest},[e.onRequest]);let[n,r]=(0,_.useState)(`disconnected`);return(0,_.useEffect)(()=>{if(e.disabled||!e.id){r(`disconnected`);return}let n=!1,i,a,o=!1,s,c=(0,b.join)(e.directory,`.blink`,`devhook`);return(async()=>{try{s=await Uh(c,{stale:!0,retries:0})}catch(t){if(t&&typeof t==`object`&&`code`in t&&t.code===`ELOCKED`){let e=``;try{let t=Gh(c);t.locked&&t.pid&&(e=` (PID: ${t.pid})`)}catch{}console.error(Sf.red(`\nError: Another ${Sf.bold(`blink dev`)} process is already running in this directory${e}.`)),console.error(Sf.red(`Please stop the other process and try again.
|
|
142
|
-
|
|
137
|
+
`),m(),i()};return{start:v,stop:y,message:(e=``)=>{s=g(e??s)}}},Tp=async(e,t)=>{let n={},r=Object.keys(e);for(let i of r){let r=e[i],a=await r({results:n})?.catch(e=>{throw e});if(typeof t?.onCancel==`function`&&rf(a)){n[i]=`canceled`,t.onCancel({results:n});continue}n[i]=a}return n},Ep=async e=>{for(let t of e){if(t.enabled===!1)continue;let e=wp();e.start(t.title);let n=await t.task(e.message);e.stop(n||t.title)}},Dp=10,Op=(e=0)=>t=>`\u001B[${t+e}m`,kp=(e=0)=>t=>`\u001B[${38+e};5;${t}m`,Ap=(e=0)=>(t,n,r)=>`\u001B[${38+e};2;${t};${n};${r}m`,Z={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},jp=Object.keys(Z.modifier),Mp=Object.keys(Z.color),Np=Object.keys(Z.bgColor),Pp=[...Mp,...Np];function Fp(){let e=new Map;for(let[t,n]of Object.entries(Z)){for(let[t,r]of Object.entries(n))Z[t]={open:`\u001B[${r[0]}m`,close:`\u001B[${r[1]}m`},n[t]=Z[t],e.set(r[0],r[1]);Object.defineProperty(Z,t,{value:n,enumerable:!1})}return Object.defineProperty(Z,`codes`,{value:e,enumerable:!1}),Z.color.close=`\x1B[39m`,Z.bgColor.close=`\x1B[49m`,Z.color.ansi=Op(),Z.color.ansi256=kp(),Z.color.ansi16m=Ap(),Z.bgColor.ansi=Op(10),Z.bgColor.ansi256=kp(10),Z.bgColor.ansi16m=Ap(10),Object.defineProperties(Z,{rgbToAnsi256:{value(e,t,n){return e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5)},enumerable:!1},hexToRgb:{value(e){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,r&255]},enumerable:!1},hexToAnsi256:{value:e=>Z.rgbToAnsi256(...Z.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,r;if(e>=232)t=((e-232)*10+8)/255,n=t,r=t;else{e-=16;let i=e%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}let i=Math.max(t,n,r)*2;if(i===0)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return i===2&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>Z.ansi256ToAnsi(Z.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>Z.ansi256ToAnsi(Z.hexToAnsi256(e)),enumerable:!1}}),Z}const Ip=Fp();var Lp=Ip;function Rp(e,t=globalThis.Deno?globalThis.Deno.args:x.default.argv){let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}const{env:Q}=x.default;let zp;Rp(`no-color`)||Rp(`no-colors`)||Rp(`color=false`)||Rp(`color=never`)?zp=0:(Rp(`color`)||Rp(`colors`)||Rp(`color=true`)||Rp(`color=always`))&&(zp=1);function Bp(){if(`FORCE_COLOR`in Q)return Q.FORCE_COLOR===`true`?1:Q.FORCE_COLOR===`false`?0:Q.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(Q.FORCE_COLOR,10),3)}function Vp(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Hp(e,{streamIsTTY:t,sniffFlags:n=!0}={}){let r=Bp();r!==void 0&&(zp=r);let i=n?zp:r;if(i===0)return 0;if(n){if(Rp(`color=16m`)||Rp(`color=full`)||Rp(`color=truecolor`))return 3;if(Rp(`color=256`))return 2}if(`TF_BUILD`in Q&&`AGENT_NAME`in Q)return 1;if(e&&!t&&i===void 0)return 0;let a=i||0;if(Q.TERM===`dumb`)return a;if(x.default.platform===`win32`){let e=C.default.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in Q)return[`GITHUB_ACTIONS`,`GITEA_ACTIONS`,`CIRCLECI`].some(e=>e in Q)?3:[`TRAVIS`,`APPVEYOR`,`GITLAB_CI`,`BUILDKITE`,`DRONE`].some(e=>e in Q)||Q.CI_NAME===`codeship`?1:a;if(`TEAMCITY_VERSION`in Q)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(Q.TEAMCITY_VERSION)?1:0;if(Q.COLORTERM===`truecolor`||Q.TERM===`xterm-kitty`||Q.TERM===`xterm-ghostty`||Q.TERM===`wezterm`)return 3;if(`TERM_PROGRAM`in Q){let e=Number.parseInt((Q.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(Q.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(Q.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(Q.TERM)||`COLORTERM`in Q?1:a}function Up(e,t={}){let n=Hp(e,{streamIsTTY:e&&e.isTTY,...t});return Vp(n)}const Wp={stdout:Up({isTTY:w.default.isatty(1)}),stderr:Up({isTTY:w.default.isatty(2)})};var Gp=Wp;function Kp(e,t,n){let r=e.indexOf(t);if(r===-1)return e;let i=t.length,a=0,o=``;do o+=e.slice(a,r)+t+n,a=r+i,r=e.indexOf(t,a);while(r!==-1);return o+=e.slice(a),o}function qp(e,t,n,r){let i=0,a=``;do{let o=e[r-1]===`\r`;a+=e.slice(i,o?r-1:r)+t+(o?`\r
|
|
138
|
+
`:`
|
|
139
|
+
`)+n,i=r+1,r=e.indexOf(`
|
|
140
|
+
`,i)}while(r!==-1);return a+=e.slice(i),a}const{stdout:Jp,stderr:Yp}=Gp,Xp=Symbol(`GENERATOR`),Zp=Symbol(`STYLER`),Qp=Symbol(`IS_EMPTY`),$p=[`ansi`,`ansi`,`ansi256`,`ansi16m`],em=Object.create(null),tm=(e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw Error("The `level` option should be an integer from 0 to 3");let n=Jp?Jp.level:0;e.level=t.level===void 0?n:t.level},nm=e=>{let t=(...e)=>e.join(` `);return tm(t,e),Object.setPrototypeOf(t,rm.prototype),t};function rm(e){return nm(e)}Object.setPrototypeOf(rm.prototype,Function.prototype);for(let[e,t]of Object.entries(Lp))em[e]={get(){let n=sm(this,om(t.open,t.close,this[Zp]),this[Qp]);return Object.defineProperty(this,e,{value:n}),n}};em.visible={get(){let e=sm(this,this[Zp],!0);return Object.defineProperty(this,`visible`,{value:e}),e}};const im=(e,t,n,...r)=>e===`rgb`?t===`ansi16m`?Lp[n].ansi16m(...r):t===`ansi256`?Lp[n].ansi256(Lp.rgbToAnsi256(...r)):Lp[n].ansi(Lp.rgbToAnsi(...r)):e===`hex`?im(`rgb`,t,n,...Lp.hexToRgb(...r)):Lp[n][e](...r);for(let e of[`rgb`,`hex`,`ansi256`]){em[e]={get(){let{level:t}=this;return function(...n){let r=om(im(e,$p[t],`color`,...n),Lp.color.close,this[Zp]);return sm(this,r,this[Qp])}}};let t=`bg`+e[0].toUpperCase()+e.slice(1);em[t]={get(){let{level:t}=this;return function(...n){let r=om(im(e,$p[t],`bgColor`,...n),Lp.bgColor.close,this[Zp]);return sm(this,r,this[Qp])}}}}const am=Object.defineProperties(()=>{},{...em,level:{enumerable:!0,get(){return this[Xp].level},set(e){this[Xp].level=e}}}),om=(e,t,n)=>{let r,i;return n===void 0?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},sm=(e,t,n)=>{let r=(...e)=>cm(r,e.length===1?``+e[0]:e.join(` `));return Object.setPrototypeOf(r,am),r[Xp]=e,r[Zp]=t,r[Qp]=n,r},cm=(e,t)=>{if(e.level<=0||!t)return e[Qp]?``:t;let n=e[Zp];if(n===void 0)return t;let{openAll:r,closeAll:i}=n;if(t.includes(`\x1B`))for(;n!==void 0;)t=Kp(t,n.close,n.open),n=n.parent;let a=t.indexOf(`
|
|
141
|
+
`);return a!==-1&&(t=qp(t,i,r,a)),r+t+i};Object.defineProperties(rm.prototype,em);const lm=rm(),um=rm({level:Yp?Yp.level:0});var dm=lm,fm=e.__commonJSMin((e=>{e.__esModule=!0;function t(e){return i(e)===`boolean`}function n(e){return i(e)===`object`}function r(e){return i(e)===`string`}function i(e){return typeof e}function a(e){var i=e.meta,a=e.path,o=e.xdg;return{XDGAppPaths:new(function(){function e(s){s===void 0&&(s={});function c(t){return t===void 0&&(t={}),new e(t)}var l=n(s)?s:{name:s},u=l.suffix??``,d=l.isolated??!0,f=[l.name,i.pkgMainFilename(),i.mainFilename()],p=a.parse((f.find(function(e){return r(e)})??`$eval`)+u).name;c.$name=function(){return p},c.$isolated=function(){return d};function m(e){return e??={isolated:d},t(e)?e:e.isolated??d}function h(e){return m(e)?p:``}return c.cache=function(e){return a.join(o.cache(),h(e))},c.config=function(e){return a.join(o.config(),h(e))},c.data=function(e){return a.join(o.data(),h(e))},c.runtime=function(e){return o.runtime()?a.join(o.runtime(),h(e)):void 0},c.state=function(e){return a.join(o.state(),h(e))},c.configDirs=function(e){return o.configDirs().map(function(t){return a.join(t,h(e))})},c.dataDirs=function(e){return o.dataDirs().map(function(t){return a.join(t,h(e))})},c}return e}())}}e.Adapt=a})),pm=e.__commonJSMin((e=>{var t=e&&e.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};e.__esModule=!0;function n(e){var n=e.env,r=e.osPaths,i=e.path,a=/^darwin$/i.test(e.process.platform),o=/^win/i.test(e.process.platform);function s(){return r.home()||r.temp()}function c(e,t){return e||i.join.apply(i,t)}var l=function(){return{cache:function(){return c(n.get(`XDG_CACHE_HOME`),[s(),`.cache`])},config:function(){return c(n.get(`XDG_CONFIG_HOME`),[s(),`.config`])},data:function(){return c(n.get(`XDG_DATA_HOME`),[s(),`.local`,`share`])},runtime:function(){return n.get(`XDG_RUNTIME_DIR`)||void 0},state:function(){return c(n.get(`XDG_STATE_HOME`),[s(),`.local`,`state`])}}},u=function(){return{cache:function(){return c(n.get(`XDG_CACHE_HOME`),[s(),`Library`,`Caches`])},config:function(){return c(n.get(`XDG_CONFIG_HOME`),[s(),`Library`,`Preferences`])},data:function(){return c(n.get(`XDG_DATA_HOME`),[s(),`Library`,`Application Support`])},runtime:function(){return n.get(`XDG_RUNTIME_DIR`)||void 0},state:function(){return c(n.get(`XDG_STATE_HOME`),[s(),`Library`,`State`])}}},d=function(){function e(){return c(n.get(`APPDATA`),[s(),`AppData`,`Roaming`])}function t(){return c(n.get(`LOCALAPPDATA`),[s(),`AppData`,`Local`])}return{cache:function(){return c(n.get(`XDG_CACHE_HOME`),[t(),`xdg.cache`])},config:function(){return c(n.get(`XDG_CONFIG_HOME`),[e(),`xdg.config`])},data:function(){return c(n.get(`XDG_DATA_HOME`),[e(),`xdg.data`])},runtime:function(){return n.get(`XDG_RUNTIME_DIR`)||void 0},state:function(){return c(n.get(`XDG_STATE_HOME`),[t(),`xdg.state`])}}};return{XDG:new(function(){function e(){function r(){return new e}var s=a?u():o?d():l();return r.cache=s.cache,r.config=s.config,r.data=s.data,r.runtime=s.runtime,r.state=s.state,r.configDirs=function(){var e=n.get(`XDG_CONFIG_DIRS`);return t([s.config()],e?e.split(i.delimiter):[])},r.dataDirs=function(){var e=n.get(`XDG_DATA_DIRS`);return t([s.data()],e?e.split(i.delimiter):[])},r}return e}())}}e.Adapt=n})),mm=e.__commonJSMin((e=>{var t=e&&e.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};e.__esModule=!0;function n(e){return!e}function r(e){var r=e.env,i=e.os,a=e.path,o=/^win/i.test(e.process.platform);function s(t){return t?e.path.normalize(e.path.join(t,`.`)):void 0}function c(){return o?function(){var e=[typeof i.homedir==`function`?i.homedir():void 0,r.get(`USERPROFILE`),r.get(`HOME`),r.get(`HOMEDRIVE`)||r.get(`HOMEPATH`)?a.join(r.get(`HOMEDRIVE`)||``,r.get(`HOMEPATH`)||``):void 0];return s(e.find(function(e){return!n(e)}))}():function(){return s((typeof i.homedir==`function`?i.homedir():void 0)||r.get(`HOME`))}()}function l(){function e(e,n){return e?a.join.apply(a,t([e],n)):void 0}function l(){var e=`/tmp`,t=[typeof i.tmpdir==`function`?i.tmpdir():void 0,r.get(`TMPDIR`),r.get(`TEMP`),r.get(`TMP`)];return s(t.find(function(e){return!n(e)}))||e}function u(){var t=`C:\\Temp`,a=[typeof i.tmpdir==`function`?i.tmpdir:function(){},function(){return r.get(`TEMP`)},function(){return r.get(`TMP`)},function(){return e(r.get(`LOCALAPPDATA`),[`Temp`])},function(){return e(c(),[`AppData`,`Local`,`Temp`])},function(){return e(r.get(`ALLUSERSPROFILE`),[`Temp`])},function(){return e(r.get(`SystemRoot`),[`Temp`])},function(){return e(r.get(`windir`),[`Temp`])},function(){return e(r.get(`SystemDrive`),[`\\`,`Temp`])}].find(function(e){return e&&!n(e())});return a&&s(a())||t}return o?u():l()}return{OSPaths:new(function(){function e(){function t(){return new e}return t.home=c,t.temp=l,t}return e}())}}e.Adapt=r})),hm=e.__commonJSMin((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};e.__esModule=!0;var i=r(require(`os`)),a=r(require(`path`));e.adapter={atImportPermissions:{env:!0},env:{get:function(e){return process.env[e]}},os:i,path:a,process}})),gm=e.__commonJSMin(((e,t)=>{var n=mm(),r=hm();t.exports=n.Adapt(r.adapter).OSPaths})),_m=e.__export({default:()=>bm}),vm,ym,bm,xm=e.__esmMin((()=>{vm=e.__toESM(gm()),ym=vm.default,bm=ym})),Sm=e.__commonJSMin((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},a=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0;var o=i(require(`path`));t.adapter={atImportPermissions:{env:!0},env:{get:function(e){return process.env[e]}},osPaths:a((xm(),e.__toCommonJS(_m))).default,path:o,process}})),Cm=e.__commonJSMin(((e,t)=>{var n=pm(),r=Sm();t.exports=n.Adapt(r.adapter).XDG})),wm=e.__export({default:()=>Em}),Tm,Em,Dm=e.__esmMin((()=>{Tm=e.__toESM(Cm()),e.__reExport(wm,e.__toESM(Cm())),Em=Tm.default})),Om=e.__commonJSMin((t=>{var n=t&&t.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=t&&t.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),i=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&n(t,e,i);return r(t,e),t},a=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};t.__esModule=!0;var o=i(require(`path`)),s=a((Dm(),e.__toCommonJS(wm)));t.adapter={atImportPermissions:{env:!0,read:!0},meta:{mainFilename:function(){var e=(typeof require<`u`&&require!==null&&require.main?require.main:{filename:void 0}).filename;return(e===process.execArgv[0]?void 0:e)||(process._eval===void 0?process.argv[1]:void 0)},pkgMainFilename:function(){return process.pkg?process.execPath:void 0}},path:o,process,xdg:s.default}})),km=e.__commonJSMin(((e,t)=>{var n=fm(),r=Om();t.exports=n.Adapt(r.adapter).XDGAppPaths})),Am=e.__toESM(km()),jm=Am.default;let Mm;function Nm(){try{return o.default.statSync(`/.dockerenv`),!0}catch{return!1}}function Pm(){try{return o.default.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`docker`)}catch{return!1}}function Fm(){return Mm===void 0&&(Mm=Nm()||Pm()),Mm}let Im;const Lm=()=>{try{return o.default.statSync(`/run/.containerenv`),!0}catch{return!1}};function Rm(){return Im===void 0&&(Im=Lm()||Fm()),Im}const zm=()=>{if(x.default.platform!==`linux`)return!1;if(C.default.release().toLowerCase().includes(`microsoft`))return!Rm();try{return o.default.readFileSync(`/proc/version`,`utf8`).toLowerCase().includes(`microsoft`)?!Rm():!1}catch{return!1}};var Bm=x.default.env.__IS_WSL_TEST__?zm:zm();const Vm=(()=>{let e=`/mnt/`,t;return async function(){if(t)return t;let n=`/etc/wsl.conf`,r=!1;try{await E.default.access(n,E.constants.F_OK),r=!0}catch{}if(!r)return e;let i=await E.default.readFile(n,{encoding:`utf8`}),a=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(i);return a?(t=a.groups.mountPoint.trim(),t=t.endsWith(`/`)?t:`${t}/`,t):e}})(),Hm=async()=>`${await Vm()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,Um=async()=>Bm?Hm():`${x.default.env.SYSTEMROOT||x.default.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;function Wm(e,t,n){let r=n=>Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let e=n();return r(e),e},set(e){r(e)}}),e}const Gm=(0,l.promisify)(T.execFile);async function Km(){if(x.default.platform!==`darwin`)throw Error(`macOS only`);let{stdout:e}=await Gm(`defaults`,[`read`,`com.apple.LaunchServices/com.apple.launchservices.secure`,`LSHandlers`]);return/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??`com.apple.Safari`}const qm=(0,l.promisify)(T.execFile);async function Jm(e,{humanReadableOutput:t=!0,signal:n}={}){if(x.default.platform!==`darwin`)throw Error(`macOS only`);let r=t?[]:[`-ss`],i={};n&&(i.signal=n);let{stdout:a}=await qm(`osascript`,[`-e`,e,r],i);return a.trim()}async function Ym(e){return Jm(`tell application "Finder" to set app_path to application file id "${e}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}const Xm=(0,l.promisify)(T.execFile),Zm={AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:`Edge`,id:`com.microsoft.edge.old`},MSEdgeDHTML:{name:`Edge`,id:`com.microsoft.edge`},MSEdgeHTM:{name:`Edge`,id:`com.microsoft.edge`},"IE.HTTP":{name:`Internet Explorer`,id:`com.microsoft.ie`},FirefoxURL:{name:`Firefox`,id:`org.mozilla.firefox`},ChromeHTML:{name:`Chrome`,id:`com.google.chrome`},BraveHTML:{name:`Brave`,id:`com.brave.Browser`},BraveBHTML:{name:`Brave Beta`,id:`com.brave.Browser.beta`},BraveSSHTM:{name:`Brave Nightly`,id:`com.brave.Browser.nightly`}};var Qm=class extends Error{};async function $m(e=Xm){let{stdout:t}=await e(`reg`,[`QUERY`,` HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice`,`/v`,`ProgId`]),n=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!n)throw new Qm(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:r}=n.groups,i=Zm[r];if(!i)throw new Qm(`Unknown browser ID: ${r}`);return i}const eh=(0,l.promisify)(T.execFile),th=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase());async function nh(){if(x.default.platform===`darwin`){let e=await Km();return{name:await Ym(e),id:e}}if(x.default.platform===`linux`){let{stdout:e}=await eh(`xdg-mime`,[`query`,`default`,`x-scheme-handler/http`]),t=e.trim();return{name:th(t.replace(/.desktop$/,``).replace(`-`,` `)),id:t}}if(x.default.platform===`win32`)return $m();throw Error(`Only macOS, Linux, and Windows are supported`)}const rh=(0,l.promisify)(T.default.execFile),ih=b.default.dirname((0,s.fileURLToPath)(require(`url`).pathToFileURL(__filename).href)),ah=b.default.join(ih,`xdg-open`),{platform:oh,arch:sh}=x.default;async function ch(){let e=await Um(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,n=a.Buffer.from(t,`utf16le`).toString(`base64`),{stdout:r}=await rh(e,[`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`,n],{encoding:`utf8`}),i=r.trim(),o={ChromeHTML:`com.google.chrome`,BraveHTML:`com.brave.Browser`,MSEdgeHTM:`com.microsoft.edge`,FirefoxURL:`org.mozilla.firefox`};return o[i]?{id:o[i]}:{}}const lh=async(e,t)=>{let n;for(let r of e)try{return await t(r)}catch(e){n=e}throw n},uh=async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return lh(e.app,t=>uh({...e,app:t}));let{name:t,arguments:n=[]}=e.app??{};if(n=[...n],Array.isArray(t))return lh(t,t=>uh({...e,app:{name:t,arguments:n}}));if(t===`browser`||t===`browserPrivate`){let r={"com.google.chrome":`chrome`,"google-chrome.desktop":`chrome`,"com.brave.Browser":`brave`,"org.mozilla.firefox":`firefox`,"firefox.desktop":`firefox`,"com.microsoft.msedge":`edge`,"com.microsoft.edge":`edge`,"com.microsoft.edgemac":`edge`,"microsoft-edge.desktop":`edge`},i={chrome:`--incognito`,brave:`--incognito`,firefox:`--private-window`,edge:`--inPrivate`},a=Bm?await ch():await nh();if(a.id in r){let o=r[a.id];return t===`browserPrivate`&&n.push(i[o]),uh({...e,app:{name:mh[o],arguments:n}})}throw Error(`${a.name} is not supported as a default browser`)}let r,i=[],o={};if(oh===`darwin`)r=`open`,e.wait&&i.push(`--wait-apps`),e.background&&i.push(`--background`),e.newInstance&&i.push(`--new`),t&&i.push(`-a`,t);else if(oh===`win32`||Bm&&!Rm()&&!t){r=await Um(),i.push(`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`),Bm||(o.windowsVerbatimArguments=!0);let s=[`Start`];e.wait&&s.push(`-Wait`),t?(s.push(`"\`"${t}\`""`),e.target&&n.push(e.target)):e.target&&s.push(`"${e.target}"`),n.length>0&&(n=n.map(e=>`"\`"${e}\`""`),s.push(`-ArgumentList`,n.join(`,`))),e.target=a.Buffer.from(s.join(` `),`utf16le`).toString(`base64`)}else{if(t)r=t;else{let e=!ih||ih===`/`,t=!1;try{await E.default.access(ah,E.constants.X_OK),t=!0}catch{}r=x.default.versions.electron??(oh===`android`||e||!t)?`xdg-open`:ah}n.length>0&&i.push(...n),e.wait||(o.stdio=`ignore`,o.detached=!0)}oh===`darwin`&&n.length>0&&i.push(`--args`,...n),e.target&&i.push(e.target);let s=T.default.spawn(r,i,o);return e.wait?new Promise((t,n)=>{s.once(`error`,n),s.once(`close`,r=>{if(!e.allowNonzeroExitCode&&r>0){n(Error(`Exited with code ${r}`));return}t(s)})}):(s.unref(),s)},dh=(e,t)=>{if(typeof e!=`string`)throw TypeError("Expected a `target`");return uh({...t,target:e})};function fh(e){if(typeof e==`string`||Array.isArray(e))return e;let{[sh]:t}=e;if(!t)throw Error(`${sh} is not supported`);return t}function ph({[oh]:e},{wsl:t}){if(t&&Bm)return fh(t);if(!e)throw Error(`${oh} is not supported`);return fh(e)}const mh={};Wm(mh,`chrome`,()=>ph({darwin:`google chrome`,win32:`chrome`,linux:[`google-chrome`,`google-chrome-stable`,`chromium`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`,x64:[`/mnt/c/Program Files/Google/Chrome/Application/chrome.exe`,`/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe`]}})),Wm(mh,`brave`,()=>ph({darwin:`brave browser`,win32:`brave`,linux:[`brave-browser`,`brave`]},{wsl:{ia32:`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`,x64:[`/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe`,`/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe`]}})),Wm(mh,`firefox`,()=>ph({darwin:`firefox`,win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:`firefox`},{wsl:`/mnt/c/Program Files/Mozilla Firefox/firefox.exe`})),Wm(mh,`edge`,()=>ph({darwin:`microsoft edge`,win32:`msedge`,linux:[`microsoft-edge`,`microsoft-edge-dev`]},{wsl:`/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`})),Wm(mh,`browser`,()=>`browser`),Wm(mh,`browserPrivate`,()=>`browserPrivate`);var hh=dh;async function gh(e,t=void 0){try{(await hh(e)).once(`error`,n=>{console.log(dm.yellow(t??`Could not open the browser. Please visit the URL manually: ${e}`))})}catch{console.log(dm.yellow(t??`Could not open the browser. Please visit the URL manually: ${e}`))}}const _h=`https://blink.coder.com`;function vh(e){let t=e||Ch();if((0,o.existsSync)(t)){let e=(0,o.readFileSync)(t,`utf8`),n=JSON.parse(e);return n.host||=`https://blink.coder.com`,n}}function yh(e,t){let n=t||Ch();(0,o.existsSync)((0,b.dirname)(n))||(0,o.mkdirSync)((0,b.dirname)(n),{recursive:!0}),(0,o.writeFileSync)(n,JSON.stringify({_:`This is your Blink credentials file. DO NOT SHARE THIS FILE WITH ANYONE!`,...e}))}function bh(e){return vh(e)?.token}function xh(e,t){let n=vh(t)??{};yh({...n,token:e},t)}function Sh(e){let t=e||Ch();(0,o.existsSync)(t)&&(0,o.unlinkSync)(t)}function Ch(){let e=jm(`blink`).dataDirs();if(e.length===0)throw Error(`No suitable data directory for Blink storage found!`);return(0,b.join)(e[0],`auth.json`)}function wh(e={}){let{autoCheck:t=!0,onAuthChange:n,onLoginUrl:r,testAuthPath:i}=e,[a,o]=(0,_.useState)(),[s,c]=(0,_.useState)(()=>bh(i)),[l,u]=(0,_.useState)(),d=(0,_.useRef)(n),f=(0,_.useRef)(r);(0,_.useEffect)(()=>{d.current=n,f.current=r},[n,r]);let p=(0,_.useCallback)(async()=>{u(void 0);try{let e=bh(i);if(c(e),!e){o(void 0),d.current?.(void 0);return}let t=new hd({baseURL:`https://blink.coder.com`});t.authToken=e;let n={email:(await t.users.me()).email};o(n),d.current?.(n)}catch(e){o(void 0),u(e instanceof Error?e.message:String(e)),d.current?.(void 0)}},[i]),m=(0,_.useCallback)(async()=>{u(void 0);try{let e=new hd,t=await e.auth.token((e,t)=>{f.current?.(e,t)});e.authToken=t;let n=await e.users.me();xh(t,i),c(t);let r={email:n.email};return o(r),d.current?.(r),r}catch(e){let t=e instanceof Error?e.message:String(e);throw u(t),e}},[i]),h=(0,_.useCallback)(()=>{Sh(i),c(void 0),o(void 0),u(void 0),d.current?.(void 0)},[i]);return(0,_.useEffect)(()=>{t&&p()},[t,p]),{user:a,token:s,error:l,login:m,logout:h}}let Th=Promise.resolve();var Eh=class{constructor(e){this.printLog=e}setPrintLog(e){this.printLog=e}error(e,...t){Th=Th.then(()=>this.printLog(`error`,e,...t).catch(e=>{console.error(`Error printing log:`,e)}))}log(e,...t){Th=Th.then(()=>this.printLog(`log`,e,...t).catch(e=>{console.error(`Error printing log:`,e)}))}flush(){return Th}};const Dh=(0,_.createContext)(void 0);function Oh(e){let{directory:t,logger:r,onBuildStart:i,onBuildSuccess:a,onBuildError:o}=typeof e==`string`?{directory:e,logger:new Eh(async()=>{})}:e,s=(0,_.useMemo)(()=>n.resolveConfig(t),[t]),[c,l]=(0,_.useState)(void 0),[u,d]=(0,_.useState)(void 0),[f,p]=(0,_.useState)(`building`),m=(0,_.useRef)(i),h=(0,_.useRef)(a),g=(0,_.useRef)(o);return(0,_.useEffect)(()=>{m.current=i,h.current=a,g.current=o},[i,a,o]),(0,_.useEffect)(()=>{let e=new AbortController;return s.build({cwd:t,entry:s.entry,outdir:s.outdir,watch:!0,dev:!0,signal:e.signal,onStart:()=>{p(`building`),l(void 0),d(void 0),m.current?.()},onResult:e=>{`error`in e?(l(e.error),p(`error`),g.current?.(e.error)):(d(e),p(`success`),h.current?.(e))}}).catch(e=>{r.error(`system`,`error`,e),p(`error`),l(e),g.current?.(e)}),()=>{e.abort()}},[t]),(0,_.useMemo)(()=>({error:c,status:f,result:u,entry:s.entry,outdir:s.outdir}),[c,f,u,s.entry,s.outdir])}function kh(){return/[<>:"/\\|?*\u0000-\u001F]|[. ]$/g}function Ah(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}const jh=100,Mh=/^\.+(\\|\/)|^\.+$/,Nh=/[. ]+$/,Ph=/[\p{Control}\p{Format}\p{Zl}\p{Zp}\uFFF0-\uFFFF]/gu,Fh=/[\p{Control}\p{Format}\p{Zl}\p{Zp}\uFFF0-\uFFFF]/u,Ih=e=>e===``,Lh=/([<>:"/\\|?*\u0000-\u001F]){2,}/g,Rh=/[\t\n\r\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+/g;let zh;function Bh(){return zh??=new Intl.Segmenter(void 0,{granularity:`grapheme`}),zh}function Vh(e,t={}){if(typeof e!=`string`)throw TypeError(`Expected a string`);let n=t.replacement??`!`;if(kh().test(n)||[...n].some(e=>Fh.test(e)&&!Ih(e)))throw Error(`Replacement string cannot contain reserved filename characters`);e=e.normalize(`NFC`),e=e.replaceAll(Rh,` `),n.length>0&&(e=e.replaceAll(Lh,`$1`)),e=e.replace(Nh,``),e=e.replace(Mh,n),e=e.replace(kh(),n),e=e.replaceAll(Ph,e=>Ih(e)?e:n),e.length===0&&(e=n),e=Ah().test(e)?e+n:e;let r=typeof t.maxLength==`number`?t.maxLength:100;if(e.length>r){let t=e.lastIndexOf(`.`);if(t===-1)e=Hh(e,r);else{let n=e.slice(0,t),i=e.slice(t),a=Math.max(0,r-i.length);e=Hh(n,a)+i}}return e}function Hh(e,t){if(e.length<=t)return e;let n=0,r=``;for(let{segment:i}of Bh().segment(e)){let e=n+i.length;if(e>t)break;r+=i,n=e}return r}function Uh(e){return`${e}.lock`}function Wh(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function Gh(e,t={}){let n=Uh(e),r=process.pid.toString();try{return o.writeFileSync(n,r,{flag:`wx`}),!0}catch(r){if(r.code!==`EEXIST`)throw r;if(t.stale===0)return!1;let i;try{i=parseInt(o.readFileSync(n,`utf8`),10)}catch{return o.unlinkSync(n),Gh(e,{...t,stale:0})}if(!Wh(i))try{return o.unlinkSync(n),Gh(e,{...t,stale:0})}catch(n){if(n.code===`ENOENT`)return Gh(e,{...t,stale:0});throw n}return!1}}async function Kh(e,t={}){let n={stale:!0,retries:0,retryInterval:100,...t},r=b.resolve(e),i=0;for(;i<=n.retries;){if(Gh(r,n))return()=>qh(r);i<n.retries&&await new Promise(e=>setTimeout(e,n.retryInterval)),i++}let a=Error(`Lock file is already being held`);throw a.code=`ELOCKED`,a.file=r,a}function qh(e){let t=b.resolve(e),n=Uh(t);try{if(parseInt(o.readFileSync(n,`utf8`),10)!==process.pid){let e=Error(`Lock is not owned by this process`);throw e.code=`ENOTACQUIRED`,e}o.unlinkSync(n)}catch(e){if(e.code===`ENOENT`){let e=Error(`Lock is not acquired`);throw e.code=`ENOTACQUIRED`,e}throw e}}function Jh(e){let t=b.resolve(e),n=Uh(t);try{if(!o.existsSync(n))return{locked:!1};let e=o.readFileSync(n,`utf8`),t=parseInt(e,10);return Wh(t)?{locked:!0,pid:t}:{locked:!1}}catch(e){return e.code,{locked:!1}}}const Yh=e=>{o.mkdirSync(e,{recursive:!0})},Xh=e=>{try{o.fdatasyncSync(e)}catch{}try{o.closeSync(e)}catch{}},Zh=e=>{try{let t=o.openSync(e,`r`);try{o.fsyncSync(t)}finally{o.closeSync(t)}}catch{}},Qh=(e,t)=>{let n=b.dirname(e);Yh(n);let r=b.join(n,`.tmp-`+process.pid+`-`+Math.random().toString(36).slice(2)),i;try{i=o.openSync(r,`w`),o.writeFileSync(i,t,`utf-8`),Xh(i),i=void 0,o.renameSync(r,e),Zh(e),Zh(n)}catch(e){if(i!==void 0)try{o.closeSync(i)}catch{}try{o.rmSync(r,{force:!0})}catch{}throw e}},$h=(e,t)=>{let n=new Map,r,i=e=>{if(o.statSync(e,{throwIfNoEntry:!1}))return JSON.parse(o.readFileSync(e,`utf-8`))},a=(e,t)=>{Qh(e,JSON.stringify(t,null,2))},s=async()=>{if(r)throw Error(`Index is already locked`);let t=b.join(e,`index.json`);Yh(e),o.existsSync(t)||o.writeFileSync(t,JSON.stringify({ids:{}}),`utf-8`);let n=await Kh(t,{stale:!0,retries:5,retryInterval:100});return r=()=>Promise.resolve(n()),()=>{n(),r=void 0}},c=async()=>{let t=b.join(e,`index.json`),n=i(t)??{ids:{}};return n.ids||={},n},l=async t=>{let n=b.join(e,`index.json`);a(n,t)},u=async t=>{let n=(await c()).ids[t];if(n)return b.join(e,n)},d=async t=>{let n=(await c()).ids[t];if(!n)return;let r=b.join(e,n);if(o.statSync(r,{throwIfNoEntry:!1}))return JSON.parse(o.readFileSync(r,`utf-8`))},f=async n=>{let r=n[t],i=String(r),o=Vh(i,{replacement:`_`})+`.json`,u=await s();try{let t=await c();t.ids[i]=o,t.current=i;let r=b.join(e,o);a(r,n),await l(t)}finally{await u()}};return{async get(e){return await d(e)},async list(){if(!o.statSync(e,{throwIfNoEntry:!1}))return[];let t=await c(),n=[];for(let[r,i]of Object.entries(t.ids)){let t=b.join(e,i),a=o.statSync(t,{throwIfNoEntry:!1});if(!a)continue;let s=Jh(t);n.push({key:r,locked:s.locked,pid:s.pid,mtime:a.mtimeMs})}return n.sort((e,t)=>t.mtime-e.mtime),n},async lock(r,i){if(n.has(r))throw Error(`Key "${r}" is already locked in this process`);let a=await u(r);if(!a){let t=Vh(r,{replacement:`_`})+`.json`,n=await s();try{let n=await c();n.ids[r]=t;let i=b.join(e,t);Yh(e),o.writeFileSync(i,JSON.stringify({}),`utf-8`),await l(n),a=i}finally{await n()}}if(i?.force){let e=Jh(a);if(e.locked&&e.pid&&e.pid!==process.pid)try{process.kill(e.pid,`SIGTERM`),await new Promise(e=>setTimeout(e,100))}catch(t){t.code!==`ESRCH`&&console.warn(`Failed to kill process ${e.pid}:`,t.message)}}let p=await Kh(a,{stale:!0,retries:i?.force?10:5,retryInterval:(i?.force,100)});return n.set(r,()=>Promise.resolve(p())),{async get(){let e=await d(r);if(!e)throw Error(`Key ${r} not found`);return e},async set(e){await f(e)},async update(e){let n=await d(r);if(!n||!(t in n))throw Error(`Key ${r} not found`);await f({...n,...e})},async delete(){let t=await s();try{let t=await c(),n=t.ids[r];if(n){delete t.ids[r],t.current===r&&(t.current=void 0),await l(t);let i=b.join(e,n);try{o.rmSync(i,{force:!0}),Zh(e)}catch{}}}finally{await t()}},async release(){try{p()}finally{n.delete(r)}}}},dispose(){n.clear()}}},eg=(e,t)=>{let n=t?.pollInterval??200,r=t?.debounce??50,i=new Set,a,s,c=new Map,l=new Map,u=b.join(e,`index.json`),d=()=>{try{if(!o.statSync(u,{throwIfNoEntry:!1}))return{ids:{}};let e=o.readFileSync(u,`utf-8`);return{ids:JSON.parse(e).ids??{}}}catch{return{ids:{}}}},f=(e,t,n,r)=>{for(let a of i)try{a({key:e,value:t,locked:n,pid:r})}catch(e){console.error(`Error in onChange callback:`,e)}},p=(t,n,r=!1)=>{let i=b.join(e,n);try{let e=o.statSync(i,{throwIfNoEntry:!1}),a=l.get(n);if(!e){a&&(l.delete(n),f(t,void 0,!1));return}let s=e.mtimeMs,c=a?{locked:a.locked,pid:a.pid}:{locked:!1,pid:void 0};if((r||!a)&&(c=Jh(i)),!a||a.mtime!==s||a.locked!==c.locked||a.pid!==c.pid){let e;e=!a||a.mtime!==s?JSON.parse(o.readFileSync(i,`utf-8`)):a.cachedValue,l.set(n,{mtime:s,key:t,locked:c.locked,pid:c.pid,cachedValue:e}),f(t,e,c.locked,c.pid)}}catch{}},m=()=>{try{let e=d(),t=new Set(Object.keys(e.ids));for(let[t,n]of Object.entries(e.ids))p(t,n,!0);for(let[e,n]of l.entries())t.has(n.key)||(l.delete(e),f(n.key,void 0,!1))}catch{}},h=(e,t,n=!1)=>{let i=c.get(e);i&&clearTimeout(i),c.set(e,setTimeout(()=>{c.delete(e),p(e,t,n)},r))},g=()=>{if(a)return;try{o.mkdirSync(e,{recursive:!0})}catch{}a=o.watch(e,(e,t)=>{if(!t||t.startsWith(`.tmp-`))return;if(t===`index.json`){m();return}if(t.endsWith(`.lock`)){let e=t.replace(`.lock`,``),n=d(),r=Object.keys(n.ids).find(t=>n.ids[t]===e);r&&p(r,e,!0);return}let n=d(),r=Object.keys(n.ids).find(e=>n.ids[e]===t);r&&h(r,t,!1)});let t=()=>{m(),s=setTimeout(t,n)};m(),s=setTimeout(t,n)};return{onChange(e){return i.size===0&&g(),i.add(e),()=>{if(i.delete(e),i.size===0){a&&=(a.close(),void 0),s&&=(clearTimeout(s),void 0);for(let e of c.values())clearTimeout(e);c.clear(),l.clear()}}},dispose(){a&&=(a.close(),void 0),s&&=(clearTimeout(s),void 0);for(let e of c.values())clearTimeout(e);c.clear(),i.clear(),l.clear()}}};async function tg({id:e,agent:t,messages:n,signal:r,shouldContinueStreaming:i=ng}){n=[...n];let a=new TransformStream,o=a.writable.getWriter(),s=async()=>{let a;try{let c=await t.chat({messages:n,id:e},{signal:r}),l=(0,m.readUIMessageStream)({message:{id:crypto.randomUUID(),role:`assistant`,parts:[],metadata:{}},stream:c,onError:e=>{e instanceof Error&&e.name===`AbortError`||o.abort(e)}});for await(let e of l)o.write(e),a=e;if(a&&i(a)){n.push(a),await s();return}await o.close()}catch(e){if(e?.name===`AbortError`||r?.aborted)return;await o.abort(e)}finally{await o.close()}};return s().catch(e=>{o.abort(e)}),a.readable}const ng=e=>{if(e.role!==`assistant`)return!1;let n=e.parts.reduce((e,t,n)=>t.type===`step-start`?n:e,-1),r=e.parts.slice(n+1).filter(m.isToolOrDynamicToolUIPart);return r.length===0||r.some(e=>t.isToolApprovalOutput(e.output)&&e.output.outcome===`pending`)?!1:r.every(e=>e.state.startsWith(`output-`))},rg=(e,t,n=crypto.randomUUID())=>({created_at:new Date().toISOString(),...e,id:n,metadata:e.metadata,mode:t});function ig(e){return typeof e==`object`&&e?.__blink_internal!==void 0}function ag(e){return typeof e.metadata==`object`&&e.metadata!==null&&`__blink_log`in e.metadata&&e.metadata.__blink_log===!0&&`level`in e.metadata&&`source`in e.metadata&&`message`in e.metadata}var og=class{chatId;agent;chatStore;serializeMessage;filterMessages;onError;chat;loading=!1;streamingMessage;status=`idle`;queue=[];logQueue=[];abortController;isProcessingQueue=!1;listeners=new Set;watcher;disposed=!1;constructor(e){this.chatId=e.chatId??`00000000-0000-0000-0000-000000000000`,this.chat={id:this.chatId,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),messages:[]},this.loading=!0,this.chatStore=$h(e.chatsDirectory,`id`),this.serializeMessage=e.serializeMessage,this.filterMessages=e.filterMessages,this.onError=e.onError,this.watcher=eg(e.chatsDirectory,{pollInterval:1e3,debounce:50}),this.watcher.onChange(e=>{if(e.key!==this.chatId||this.isProcessingQueue)return;if(!e.value){this.chat={id:this.chatId,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),messages:[]},this.status=`idle`,this.streamingMessage=void 0,this.notifyListeners();return}if(this.chat.updated_at===e.value?.updated_at)return;let t=e.value,n=e.locked?`streaming`:`idle`,r=this.chat.updated_at!==t?.updated_at||this.status!==n;this.chat=t,this.streamingMessage=void 0,this.status=n,r&&this.notifyListeners()}),this.chatStore.get(this.chatId).then(e=>{this.disposed||e&&(this.chat=e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);this.onError?.(t)}).finally(()=>{this.loading=!1,this.notifyListeners()})}setAgent(e){this.agent=e}getState(){return{id:this.chatId,key:this.chat?.key,messages:(this.chat?.messages??[]).filter(e=>!ig(e.metadata)),created_at:this.chat?.created_at,updated_at:this.chat?.updated_at,status:this.status,streamingMessage:this.streamingMessage,loading:this.loading,queuedMessages:this.queue,queuedLogs:this.logQueue}}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}async upsertMessages(e,t){let n=!1,r;t?r=t:(r=await this.chatStore.lock(this.chatId),n=!0);try{let t=await r.get();(!t.id||!Array.isArray(t.messages))&&(t={id:this.chatId,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),messages:[]});let n=[...t.messages];for(let t of e){let e;if(this.serializeMessage){let n=this.serializeMessage(t);if(n===void 0)return;e=n}else e={...t,created_at:new Date().toISOString(),mode:`run`,metadata:t.metadata,id:t.id??crypto.randomUUID()};let r=n.findIndex(t=>t.id===e.id);r===-1?n.push(e):n.splice(r,1,e)}this.chat={...t,updated_at:new Date().toISOString(),messages:n},await r.set(this.chat),this.notifyListeners()}finally{n&&await r.release()}}async deleteMessages(e){let t;try{t=await this.chatStore.lock(this.chatId);let n=await t.get();this.chat.messages=n.messages.filter(t=>!e.includes(t.id)),this.chat.updated_at=new Date().toISOString(),await t.set(this.chat),this.notifyListeners()}finally{t&&await t.release()}}async queueLogMessage({message:e,level:t,source:n}){let r=`(EDIT MODE NOTE) ${n===`agent`?`The agent`:"The `blink dev` CLI"} printed the following ${t}:\n\`\`\`\n${(0,l.stripVTControlCharacters)(e)}\n\`\`\`\n`,i={id:crypto.randomUUID(),created_at:new Date().toISOString(),role:`user`,parts:[{type:`text`,text:r}],metadata:{__blink_log:!0,level:t,source:n,message:e},mode:`edit`};this.logQueue.push(i),this.notifyListeners()}async flushLogQueue(e){if(this.logQueue.length===0)return;let t=[...this.logQueue];this.logQueue=[],await this.upsertMessages(t,e)}async sendMessages(e){if(this.status=`idle`,this.notifyListeners(),this.isProcessingQueue){this.queue.push(...e),this.notifyListeners();return}this.queue=e,this.processQueueOrRun()}async start(){this.status=`idle`,this.notifyListeners(),this.processQueueOrRun()}async stop(){this.status=`idle`,this.abortController?.abort(),this.notifyListeners()}async processQueueOrRun(){if(!this.agent){this.onError?.(`The agent is not available. Please wait for the build to succeed.`),this.queue=[];return}if(this.isProcessingQueue)return;this.isProcessingQueue=!0;let e;try{e=await this.chatStore.lock(this.chatId),await this.flushLogQueue(e);let n=!0;for(;this.queue.length>0||n;)try{var t=Xs();n=!1;let r=new AbortController;this.abortController=r;let i=[...this.queue];this.queue=[],this.streamingMessage=void 0,this.status=`streaming`,this.notifyListeners(),i.length>0&&await this.upsertMessages(i,e);let a=this.chat.messages;this.filterMessages&&(a=a.filter(this.filterMessages)),a=a.map(e=>({...e,parts:e.parts.map(e=>!(0,m.isToolOrDynamicToolUIPart)(e)||e.input!==``?e:{...e,input:{}})})),t.u(await this.agent.lock.read());let o=performance.now(),s=await tg({agent:this.agent.client,id:this.chatId,signal:r.signal,messages:a}),c=async t=>{let n=t;if(this.serializeMessage){let e=this.serializeMessage(t);if(e===void 0)return;n=e}this.chat.updated_at=new Date().toISOString(),this.chat.messages.push(n),this.streamingMessage=void 0,await e?.set(this.chat)},l=s.getReader();r.signal.addEventListener(`abort`,()=>{l.cancel().catch(()=>{})},{once:!0});let u;try{for(;;){let{done:e,value:t}=await l.read();if(e||r.signal.aborted)break;u||=performance.now()-o,this.streamingMessage&&t.id!==this.streamingMessage.id&&await c(this.streamingMessage);let n={...t,metadata:{...typeof t.metadata==`object`&&t.metadata!==null?t.metadata:{},ttft:u}};this.streamingMessage=this.serializeMessage?this.serializeMessage(n):n,this.notifyListeners()}}finally{l.releaseLock()}this.streamingMessage&&await c(this.streamingMessage)}catch(e){t.e=e}finally{t.d()}}catch(e){let t=e instanceof Error?e.message:String(e);this.onError?.(t)}finally{this.isProcessingQueue=!1,this.streamingMessage=void 0,this.status=`idle`,e&&(await this.flushLogQueue(e),this.chat.updated_at=new Date().toISOString(),await e.set(this.chat),await e.release(),this.notifyListeners())}}stopStreaming(){this.abortController?.abort()}clearQueue(){this.queue=[],this.notifyListeners()}async resetChat(){this.abortController?.abort(),this.resetChatState(),this.notifyListeners();let e;try{e=await this.chatStore.lock(this.chatId),await e.delete()}catch{}finally{if(e)try{await e.release()}catch{}}}dispose(){this.disposed=!0,this.watcher.dispose(),this.listeners.clear(),this.stopStreaming()}resetChatState(){this.chat={id:this.chatId,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),messages:[]},this.streamingMessage=void 0,this.status=`idle`,this.queue=[],this.logQueue=[]}notifyListeners(){let e=this.getState();for(let t of this.listeners)t(e)}};function sg(e){let{chatId:t,agent:n,chatsDirectory:r,serializeMessage:i,filterMessages:a,onError:o}=e,s=(0,_.useRef)(null),[c,l]=(0,_.useState)({id:t,messages:[],status:`idle`,loading:!0,queuedMessages:[],queuedLogs:[]});(0,_.useEffect)(()=>{s.current&&s.current.dispose();let e=new og({chatId:t,chatsDirectory:r,serializeMessage:i,filterMessages:a,onError:o}),n=e.subscribe(e=>{l(e)});return l(e.getState()),s.current=e,()=>{n(),e.dispose(),s.current=null}},[t,r]),(0,_.useEffect)(()=>{s.current&&s.current.setAgent(n)},[n]);let u=(0,_.useCallback)(async e=>{s.current&&await s.current.sendMessages([e])},[]),d=(0,_.useCallback)(async e=>{s.current&&await s.current.upsertMessages([e])},[]),f=(0,_.useCallback)(async e=>{s.current&&await s.current.queueLogMessage(e)},[]),p=(0,_.useCallback)(()=>{s.current&&s.current.stopStreaming()},[]),m=(0,_.useCallback)(async()=>{s.current&&await s.current.resetChat()},[]),h=(0,_.useCallback)(()=>{s.current&&s.current.clearQueue()},[]),g=(0,_.useCallback)(async e=>{s.current&&await s.current.deleteMessages([e])},[]),v=(0,_.useCallback)(async()=>{s.current&&await s.current.start()},[]);return{...c,sendMessage:u,upsertMessage:d,queueLogMessage:f,stopStreaming:p,resetChat:m,clearQueue:h,deleteMessage:g,start:v}}function cg(e){return(0,f.join)(e,`.blink`,`devhook.txt`)}function lg(e){return(0,p.existsSync)(cg(e))}function ug(e){let t=cg(e);if((0,p.existsSync)(t))return(0,p.readFileSync)(t,`utf-8`).trim()}function dg(e){let t=cg(e);if((0,p.mkdirSync)((0,f.dirname)(t),{recursive:!0}),(0,p.existsSync)(t))return(0,p.readFileSync)(t,`utf-8`);let n=crypto.randomUUID();return(0,p.writeFileSync)(t,n),n}const fg=(e,t)=>e.json({error:t},400),pg=e=>{let t=e.req.param(`key`);return!t||t===``?{key:t,err:`Key is required`}:t.length>475?{key:t,err:`Key is too long. Max length is 475 characters.`}:{key:t}},mg=()=>new t.Hono,hg=mg().get(`/:key`,async e=>{let{key:t,err:n}=pg(e);if(n)return fg(e,n);let r=await e.env.store.get(t);return e.json({value:r},200)}).post(`/:key`,t.validator(`json`,(e,t)=>{let n=e.value;return n?typeof n==`string`?n.length>2e4?fg(t,`Value is too long. Max length is 20,000 characters.`):{value:n}:fg(t,`Value must be a string`):fg(t,`Value is required`)}),async e=>{let{key:t,err:n}=pg(e);if(n)return fg(e,n);let{value:r}=e.req.valid(`json`);return await e.env.store.set(t,r),e.body(null,204)}).delete(`/:key`,async e=>{let{key:t,err:n}=pg(e);return n?fg(e,n):(await e.env.store.delete(t),e.body(null,204))}).get(`/`,async e=>{let{cursor:t,limit:n,prefix:r}=e.req.query(),{entries:i,cursor:a}=await e.env.store.list(r,{cursor:t?String(t):void 0,limit:n?Number(n):100});return e.json({entries:i,cursor:a})}),gg=e=>{let t=e.req.param(`key`);return t?t.length>475?{key:t,err:`Key is too long. Max length is 475 characters.`}:{key:t}:{key:t,err:`Key is required`}},_g=t.validator(`param`,e=>({id:e.id})),vg=mg().post(`/:key`,async e=>{let{key:t,err:n}=gg(e);return n?fg(e,n):e.json(await e.env.chat.upsert(t),200)}).get(`/:id`,_g,async e=>{let{id:t}=e.req.valid(`param`);return e.json(await e.env.chat.get(t),200)}).get(`/:id/messages`,_g,async e=>{let{id:t}=e.req.valid(`param`);return e.json(await e.env.chat.getMessages(t),200)}).post(`/:id/sendMessages`,t.validator(`json`,e=>({id:e.id,messages:e.messages,options:e.options})),async e=>{let{id:t,messages:n,options:r}=e.req.valid(`json`);return t?(await e.env.chat.sendMessages(t,n,r),e.body(null,204)):fg(e,`ID is required`)}).delete(`/:id/messages`,_g,t.validator(`query`,e=>(typeof e.message==`string`&&(e.message=[e.message]),{messages:e.message})),async e=>{let{id:t}=e.req.valid(`param`),{messages:n}=e.req.valid(`query`);return await e.env.chat.deleteMessages(t,n),e.body(null,204)}).post(`/:id/start`,_g,async e=>{let{id:t}=e.req.valid(`param`);return await e.env.chat.start(t),e.body(null,204)}).post(`/:id/stop`,_g,async e=>{let{id:t}=e.req.valid(`param`);return await e.env.chat.stop(t),e.body(null,204)}).delete(`/:id`,_g,async e=>{let{id:t}=e.req.valid(`param`);return await e.env.chat.delete(t),e.body(null,204)}),yg=mg().post(`/v1/traces`,async e=>e.env.otlp?e.env.otlp.traces(e.req.raw):e.body(null,204)),bg=new t.Hono().onError((e,t)=>t.json({error:e instanceof Error?e.message:`Unknown error`},500)).route(`/kv`,hg).route(`/chat`,vg).route(`/otlp`,yg);var xg=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function Sg(e){return typeof e==`string`&&xg.test(e)}var Cg=Sg;function wg(e){if(!Cg(e))throw TypeError(`Invalid UUID`);let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var Tg=wg;const $=[];for(let e=0;e<256;++e)$.push((e+256).toString(16).slice(1));function Eg(e,t=0){return($[e[t+0]]+$[e[t+1]]+$[e[t+2]]+$[e[t+3]]+`-`+$[e[t+4]]+$[e[t+5]]+`-`+$[e[t+6]]+$[e[t+7]]+`-`+$[e[t+8]]+$[e[t+9]]+`-`+$[e[t+10]]+$[e[t+11]]+$[e[t+12]]+$[e[t+13]]+$[e[t+14]]+$[e[t+15]]).toLowerCase()}function Dg(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let n=0;n<e.length;++n)t[n]=e.charCodeAt(n);return t}const Og=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,kg=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`;function Ag(e,t,n,r,i,a){let o=typeof n==`string`?Dg(n):n,s=typeof r==`string`?Tg(r):r;if(typeof r==`string`&&(r=Tg(r)),r?.length!==16)throw TypeError(`Namespace must be array-like (16 iterable integer values, 0-255)`);let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,i){a||=0;for(let e=0;e<16;++e)i[a+e]=c[e];return i}return Eg(c)}function jg(e){return Array.isArray(e)?e=Buffer.from(e):typeof e==`string`&&(e=Buffer.from(e,`utf8`)),(0,u.createHash)(`sha1`).update(e).digest()}var Mg=jg;function Ng(e,t,n,r){return Ag(80,Mg,e,t,n,r)}Ng.DNS=`6ba7b810-9dad-11d1-80b4-00c04fd430c8`,Ng.URL=`6ba7b811-9dad-11d1-80b4-00c04fd430c8`;var Pg=Ng;function Fg(e){let n=(0,b.join)(e.dataDirectory,`chats`),r={},i=(0,b.join)(e.dataDirectory,`storage.json`);o.existsSync(i)&&(r=JSON.parse(o.readFileSync(i,`utf-8`)));let a=new Map,s=t=>{let r=a.get(t);return r||(r=new og({chatId:t,chatsDirectory:n}),a.set(t,r)),r.setAgent(e.getAgent()),r},c={async upsert(e){let t=Pg(JSON.stringify(e),Pg.URL),n=s(t).getState(),r=n.messages.length===0&&!n.created_at;return{id:n.id,created:r,createdAt:n.created_at??new Date().toISOString(),key:e}},async get(e){let t=s(e).getState();return{id:t.id,createdAt:t.created_at??new Date().toISOString()}},async getMessages(e){return s(e).getState().messages},async sendMessages(e,t,n){let r=s(e),i=t.map(e=>rg(e,`run`));if(n?.behavior===`append`){await r.upsertMessages(i);return}if(n?.behavior===`interrupt`){await r.sendMessages(i);return}await r.sendMessages(i)},async deleteMessages(e,t){await s(e).deleteMessages(t)},async start(e){await s(e).start()},async stop(e){await s(e).stop()},async delete(e){await s(e).resetChat()}},l={get(e){return Promise.resolve(r[e])},set(e,t){return r[e]=t,o.writeFileSync(i,JSON.stringify(r),`utf-8`),Promise.resolve()},delete(e){return delete r[e],o.writeFileSync(i,JSON.stringify(r),`utf-8`),Promise.resolve()},list(e,t){let n=Math.min(t?.limit??100,1e3),i=t?.cursor,a=Object.keys(r).filter(t=>t.startsWith(e??``)).sort(),o=0;if(i){let e=a.indexOf(i);e!==-1&&(o=e+1)}let s=a.slice(o,o+n),c=o+n<a.length?s[s.length-1]:void 0;return Promise.resolve({entries:s.map(e=>({key:e})),cursor:c})}},u=(0,d.createServer)(t.createServerAdapter(e=>bg.fetch(e,{chat:c,store:l})));u.listen(e.port??0);let f=$h(n,`id`);return{url:`http://127.0.0.1:${u.address().port}`,chatsDirectory:n,getChatManager:s,listChats:()=>f.list(),dispose:()=>{for(let e of a.values())e.dispose();a.clear(),f.dispose(),u.close()}}}function Ig({agent:e,capabilities:n,messages:r}){let[i,a]=(0,_.useState)(void 0),[o,s]=(0,_.useState)(!0),[c,l]=(0,_.useState)(void 0),u=(0,_.useRef)(c);(0,_.useEffect)(()=>{u.current=c},[c]);let[d,f]=(0,_.useState)(()=>t.lastUIOptions(r));(0,_.useEffect)(()=>{f(e=>{let n=t.lastUIOptions(r);return JSON.stringify(n)===JSON.stringify(e)?e:n})},[r]);let[p,m]=(0,_.useState)(void 0),h=(0,_.useCallback)((e,t)=>{if(!u.current)return!1;let n=u.current[e];return n?n.values.some(e=>e.id===t):!1},[]),g=(0,_.useCallback)(e=>{m(t=>{let n={...d,...t,...e};for(let[e,t]of Object.entries(n))h(e,t)||delete n[e];for(let[e,t]of Object.entries(u.current??{}))!n[e]&&t.defaultValue!==void 0&&(n[e]=t.defaultValue);return JSON.stringify(n)===JSON.stringify(t)?t:n})},[d,h]);(0,_.useEffect)(()=>{if(!d&&!c){m(void 0);return}g()},[d,c,g]);let v=(0,_.useRef)(void 0),y=(0,_.useRef)(void 0);(0,_.useEffect)(()=>{e!==y.current&&(y.current=e,l(void 0),m(void 0),a(void 0),s(!0),v.current=void 0)},[e]),(0,_.useEffect)(()=>{if(n&&!n.ui||!e){l(void 0),m(void 0),a(void 0),v.current=void 0;return}let t=p?JSON.stringify(p):``;if(v.current===t){s(!1),a(void 0);return}let r=new AbortController;return s(!0),a(void 0),e.ui(p?{selectedOptions:p}:{},{signal:r.signal}).then(e=>{if(!e){l(void 0);return}r.signal.aborted||(l(t=>JSON.stringify(t)===JSON.stringify(e)?t:e),v.current=t)}).catch(e=>{r.signal.aborted||a(e instanceof Error?e:Error(String(e)))}).finally(()=>{s(!1)}),()=>{r.abort()}},[e,n,p]);let b=(0,_.useCallback)((e,t)=>{g({[e]:t})},[g]);return{schema:c,options:p,setOption:b,loading:o,error:i}}function Lg(e){let t=(0,_.useRef)(e.onRequest);(0,_.useEffect)(()=>{t.current=e.onRequest},[e.onRequest]);let[n,r]=(0,_.useState)(`disconnected`);return(0,_.useEffect)(()=>{if(e.disabled||!e.id){r(`disconnected`);return}let n=!1,i,a,o=!1,s,c=(0,b.join)(e.directory,`.blink`,`devhook`);return(async()=>{try{s=await Kh(c,{stale:!0,retries:0})}catch(t){if(t&&typeof t==`object`&&`code`in t&&t.code===`ELOCKED`){let e=``;try{let t=Jh(c);t.locked&&t.pid&&(e=` (PID: ${t.pid})`)}catch{}console.error(dm.red(`\nError: Another ${dm.bold(`blink dev`)} process is already running in this directory${e}.`)),console.error(dm.red(`Please stop the other process and try again.
|
|
142
|
+
`)),process.exit(1)}let n=t&&typeof t==`object`&&`message`in t?String(t.message):String(t);e.logger.error(`system`,dm.yellow(`\nWarning: Failed to acquire devhook lock: ${n}`)),e.logger.error(`system`,dm.yellow(`Continuing without lock. Multiple ${dm.bold(`blink dev`)} processes may conflict with each other.\n`))}let l=()=>{if(!(n||o)){if(o=!0,i){try{i.dispose()}catch{}i=void 0}i=new hd({baseURL:`https://blink.coder.com`}).devhook.listen({id:e.id,onRequest:async e=>t.current(e),onConnect:()=>{o=!1,r(`connected`)},onDisconnect:()=>{o=!1,r(`disconnected`),!n&&!a&&(a=setTimeout(()=>{a=void 0,l()},2e3))},onError:e=>{o=!1,r(`error`),!n&&!a&&(a=setTimeout(()=>{a=void 0,l()},2e3))}})}};l()})(),()=>{if(n=!0,a&&=(clearTimeout(a),void 0),i){try{i.dispose()}catch{}i=void 0}if(s)try{s()}catch(t){e.logger.error(`system`,`Failed to release devhook lock:`,t)}}},[e.disabled,e.directory]),{id:e.id,url:e.id?`https://${e.id}.blink.host`:void 0,status:n}}var Rg=e.__commonJSMin(((e,t)=>{t.exports={name:`dotenv`,version:`17.2.3`,description:`Loads environment variables from .env file`,main:`lib/main.js`,types:`lib/main.d.ts`,exports:{".":{types:`./lib/main.d.ts`,require:`./lib/main.js`,default:`./lib/main.js`},"./config":`./config.js`,"./config.js":`./config.js`,"./lib/env-options":`./lib/env-options.js`,"./lib/env-options.js":`./lib/env-options.js`,"./lib/cli-options":`./lib/cli-options.js`,"./lib/cli-options.js":`./lib/cli-options.js`,"./package.json":`./package.json`},scripts:{"dts-check":`tsc --project tests/types/tsconfig.json`,lint:`standard`,pretest:`npm run lint && npm run dts-check`,test:`tap run tests/**/*.js --allow-empty-coverage --disable-coverage --timeout=60000`,"test:coverage":`tap run tests/**/*.js --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov`,prerelease:`npm test`,release:`standard-version`},repository:{type:`git`,url:`git://github.com/motdotla/dotenv.git`},homepage:`https://github.com/motdotla/dotenv#readme`,funding:`https://dotenvx.com`,keywords:[`dotenv`,`env`,`.env`,`environment`,`variables`,`config`,`settings`],readmeFilename:`README.md`,license:`BSD-2-Clause`,devDependencies:{"@types/node":`^18.11.3`,decache:`^4.6.2`,sinon:`^14.0.1`,standard:`^17.0.0`,"standard-version":`^9.5.0`,tap:`^19.2.0`,typescript:`^4.8.4`},engines:{node:`>=12`},browser:{fs:!1}}})),zg=e.__commonJSMin(((e,t)=>{let n=require(`fs`),r=require(`path`),i=require(`os`),a=require(`crypto`),o=Rg().version,s=[`🔐 encrypt with Dotenvx: https://dotenvx.com`,`🔐 prevent committing .env to code: https://dotenvx.com/precommit`,`🔐 prevent building .env in docker: https://dotenvx.com/prebuild`,`📡 add observability to secrets: https://dotenvx.com/ops`,`👥 sync secrets across teammates & machines: https://dotenvx.com/ops`,`🗂️ backup and recover secrets: https://dotenvx.com/ops`,`✅ audit secrets and track compliance: https://dotenvx.com/ops`,`🔄 add secrets lifecycle management: https://dotenvx.com/ops`,`🔑 add access controls to secrets: https://dotenvx.com/ops`,"🛠️ run anywhere with `dotenvx run -- yourcommand`",`⚙️ specify custom .env file path with { path: '/custom/path/.env' }`,`⚙️ enable debug logging with { debug: true }`,`⚙️ override existing env vars with { override: true }`,`⚙️ suppress all logs with { quiet: true }`,`⚙️ write to custom object with { processEnv: myObject }`,`⚙️ load multiple .env files with { path: ['.env.local', '.env'] }`];function c(){return s[Math.floor(Math.random()*s.length)]}function l(e){return typeof e==`string`?![`false`,`0`,`no`,`off`,``].includes(e.toLowerCase()):!!e}function u(){return process.stdout.isTTY}function d(e){return u()?`\x1b[2m${e}\x1b[0m`:e}let f=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function p(e){let t={},n=e.toString();n=n.replace(/\r\n?/gm,`
|
|
143
143
|
`);let r;for(;(r=f.exec(n))!=null;){let e=r[1],n=r[2]||``;n=n.trim();let i=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),i===`"`&&(n=n.replace(/\\n/g,`
|
|
144
|
-
`),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function m(e){e||={};let t=b(e);e.path=t;let n=D.configDotenv(e);if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=v(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=r[e].trim(),i=y(n,t);a=D.decrypt(i.ciphertext,i.key);break}catch(t){if(e+1>=i)throw t}return D.parse(a)}function h(e){console.error(`[dotenv@${o}][WARN] ${e}`)}function g(e){console.log(`[dotenv@${o}][DEBUG] ${e}`)}function _(e){console.log(`[dotenv@${o}] ${e}`)}function v(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:``}function y(e,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function b(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)n.existsSync(r)&&(t=r.endsWith(`.vault`)?r:`${r}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=r.resolve(process.cwd(),`.env.vault`);return n.existsSync(t)?t:null}function x(e){return e[0]===`~`?r.join(i.homedir(),e.slice(1)):e}function S(e){let t=l(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),n=l(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!n)&&_(`Loading env from encrypted .env.vault`);let r=D._parseVault(e),i=process.env;return e&&e.processEnv!=null&&(i=e.processEnv),D.populate(i,r,e),{parsed:r}}function C(e){let t=r.resolve(process.cwd(),`.env`),i=`utf8`,a=process.env;e&&e.processEnv!=null&&(a=e.processEnv);let o=l(a.DOTENV_CONFIG_DEBUG||e&&e.debug),s=l(a.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?i=e.encoding:o&&g(`No encoding is specified. UTF-8 is used by default`);let u=[t];if(e&&e.path)if(!Array.isArray(e.path))u=[x(e.path)];else{u=[];for(let t of e.path)u.push(x(t))}let f,p={};for(let t of u)try{let r=D.parse(n.readFileSync(t,{encoding:i}));D.populate(p,r,e)}catch(e){o&&g(`Failed to load ${t} ${e.message}`),f=e}let m=D.populate(a,p,e);if(o=l(a.DOTENV_CONFIG_DEBUG||o),s=l(a.DOTENV_CONFIG_QUIET||s),o||!s){let e=Object.keys(m).length,t=[];for(let e of u)try{let n=r.relative(process.cwd(),e);t.push(n)}catch(t){o&&g(`Failed to load ${e} ${t.message}`),f=t}_(`injecting env (${e}) from ${t.join(`,`)} ${d(`-- tip: ${c()}`)}`)}return f?{parsed:p,error:f}:{parsed:p}}function w(e){if(v(e).length===0)return D.configDotenv(e);let t=b(e);return t?D._configVault(e):(h(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),D.configDotenv(e))}function T(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),o=r.subarray(-16);r=r.subarray(12,-16);try{let e=a.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(o),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function E(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override),a={};if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n],a[n]=t[n]),r&&g(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):(e[n]=t[n],a[n]=t[n]);return a}let D={configDotenv:C,_configVault:S,_parseVault:m,config:w,decrypt:T,parse:p,populate:E};t.exports.configDotenv=D.configDotenv,t.exports._configVault=D._configVault,t.exports._parseVault=D._parseVault,t.exports.config=D.config,t.exports.decrypt=D.decrypt,t.exports.parse=D.parse,t.exports.populate=D.populate,t.exports=D})),Lg=e.__toESM(Ig());async function Rg(e,t){let n=e;for(;n!==(0,f.dirname)(n);){let e=(0,f.join)(n,t);try{return await(0,h.stat)(e),e}catch{}n=(0,f.dirname)(n)}}function zg(e,t,n=`.env.local`){let[r,i]=(0,_.useState)({});return(0,_.useEffect)(()=>{let r,a=e=>{try{let t=(0,p.readFileSync)(e,`utf-8`),n=(0,Lg.parse)(t);i(n)}catch(e){t.error(`system`,`Error reading ${n}:`,e),i({})}};return Rg(e,n).then(e=>{if(!e){i({});return}a(e),r=(0,p.watch)(e,{persistent:!1},()=>{a(e)})}),()=>{r&&r.close()}},[e,n]),r}var Bg=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},Vg=class extends Bg{};new Vg;function Hg(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Ug(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function Wg(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function Gg(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function Kg(e,t){return Wg(e,t,``)}function qg(e,t){return Gg(e,t,``)}function Jg(e,t){return t.slice(0,Yg(e,t))}function Yg(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function Xg(e){let t;for(t=e.length-1;t>=0&&e[t].match(/\s/);t--);return e.substring(t+1)}function Zg(e){let t=e.match(/^\s*/);return t?t[0]:``}const Qg=`a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,$g=RegExp(`[${Qg}]+|\\s+|[^${Qg}]`,`ug`);var e_=class extends Bg{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Array.from(r.segment(e),e=>e.segment)}else n=e.match($g)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&t_(n,i,r,e),n=e,r=null,i=null)}),(r||i)&&t_(n,i,r,null),e}};new e_;function t_(e,t,n,r){if(t&&n){let i=Zg(t.value),a=Xg(t.value),o=Zg(n.value),s=Xg(n.value);if(e){let r=Hg(i,o);e.value=Gg(e.value,o,r),t.value=Kg(t.value,r),n.value=Kg(n.value,r)}if(r){let e=Ug(a,s);r.value=Wg(r.value,s,e),t.value=qg(t.value,e),n.value=qg(n.value,e)}}else if(n){if(e){let e=Zg(n.value);n.value=n.value.substring(e.length)}if(r){let e=Zg(r.value);r.value=r.value.substring(e.length)}}else if(e&&r){let n=Zg(r.value),i=Zg(t.value),a=Xg(t.value),o=Hg(n,i);t.value=Kg(t.value,o);let s=Ug(Kg(n,o),a);t.value=qg(t.value,s),r.value=Wg(r.value,n,s),e.value=Gg(e.value,n,n.slice(0,n.length-s.length))}else if(r){let e=Zg(r.value),n=Jg(Xg(t.value),e);t.value=qg(t.value,n)}else if(e){let n=Jg(Xg(e.value),Zg(t.value));t.value=Kg(t.value,n)}}var n_=class extends Bg{tokenize(e){let t=RegExp(`(\\r?\\n)|[${Qg}]+|[^\\S\\n\\r]+|[^${Qg}]`,`ug`);return e.match(t)||[]}};new n_;var r_=class extends Bg{constructor(){super(...arguments),this.tokenize=o_}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
144
|
+
`),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function m(e){e||={};let t=b(e);e.path=t;let n=D.configDotenv(e);if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=v(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=r[e].trim(),i=y(n,t);a=D.decrypt(i.ciphertext,i.key);break}catch(t){if(e+1>=i)throw t}return D.parse(a)}function h(e){console.error(`[dotenv@${o}][WARN] ${e}`)}function g(e){console.log(`[dotenv@${o}][DEBUG] ${e}`)}function _(e){console.log(`[dotenv@${o}] ${e}`)}function v(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:``}function y(e,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function b(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let r of e.path)n.existsSync(r)&&(t=r.endsWith(`.vault`)?r:`${r}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=r.resolve(process.cwd(),`.env.vault`);return n.existsSync(t)?t:null}function x(e){return e[0]===`~`?r.join(i.homedir(),e.slice(1)):e}function S(e){let t=l(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),n=l(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!n)&&_(`Loading env from encrypted .env.vault`);let r=D._parseVault(e),i=process.env;return e&&e.processEnv!=null&&(i=e.processEnv),D.populate(i,r,e),{parsed:r}}function C(e){let t=r.resolve(process.cwd(),`.env`),i=`utf8`,a=process.env;e&&e.processEnv!=null&&(a=e.processEnv);let o=l(a.DOTENV_CONFIG_DEBUG||e&&e.debug),s=l(a.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?i=e.encoding:o&&g(`No encoding is specified. UTF-8 is used by default`);let u=[t];if(e&&e.path)if(!Array.isArray(e.path))u=[x(e.path)];else{u=[];for(let t of e.path)u.push(x(t))}let f,p={};for(let t of u)try{let r=D.parse(n.readFileSync(t,{encoding:i}));D.populate(p,r,e)}catch(e){o&&g(`Failed to load ${t} ${e.message}`),f=e}let m=D.populate(a,p,e);if(o=l(a.DOTENV_CONFIG_DEBUG||o),s=l(a.DOTENV_CONFIG_QUIET||s),o||!s){let e=Object.keys(m).length,t=[];for(let e of u)try{let n=r.relative(process.cwd(),e);t.push(n)}catch(t){o&&g(`Failed to load ${e} ${t.message}`),f=t}_(`injecting env (${e}) from ${t.join(`,`)} ${d(`-- tip: ${c()}`)}`)}return f?{parsed:p,error:f}:{parsed:p}}function w(e){if(v(e).length===0)return D.configDotenv(e);let t=b(e);return t?D._configVault(e):(h(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),D.configDotenv(e))}function T(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),o=r.subarray(-16);r=r.subarray(12,-16);try{let e=a.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(o),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function E(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override),a={};if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n],a[n]=t[n]),r&&g(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):(e[n]=t[n],a[n]=t[n]);return a}let D={configDotenv:C,_configVault:S,_parseVault:m,config:w,decrypt:T,parse:p,populate:E};t.exports.configDotenv=D.configDotenv,t.exports._configVault=D._configVault,t.exports._parseVault=D._parseVault,t.exports.config=D.config,t.exports.decrypt=D.decrypt,t.exports.parse=D.parse,t.exports.populate=D.populate,t.exports=D})),Bg=e.__toESM(zg());async function Vg(e,t){let n=e;for(;n!==(0,f.dirname)(n);){let e=(0,f.join)(n,t);try{return await(0,h.stat)(e),e}catch{}n=(0,f.dirname)(n)}}function Hg(e,t,n=`.env.local`){let[r,i]=(0,_.useState)({});return(0,_.useEffect)(()=>{let r,a=e=>{try{let t=(0,p.readFileSync)(e,`utf-8`),n=(0,Bg.parse)(t);i(n)}catch(e){t.error(`system`,`Error reading ${n}:`,e),i({})}};return Vg(e,n).then(e=>{if(!e){i({});return}a(e),r=(0,p.watch)(e,{persistent:!1},()=>{a(e)})}),()=>{r&&r.close()}},[e,n]),r}var Ug=class{diff(e,t,n={}){let r;typeof n==`function`?(r=n,n={}):`callback`in n&&(r=n.callback);let i=this.castInput(e,n),a=this.castInput(t,n),o=this.removeEmpty(this.tokenize(i,n)),s=this.removeEmpty(this.tokenize(a,n));return this.diffWithOptionsObj(o,s,n,r)}diffWithOptionsObj(e,t,n,r){let i=e=>{if(e=this.postProcess(e,n),r){setTimeout(function(){r(e)},0);return}else return e},a=t.length,o=e.length,s=1,c=a+o;n.maxEditLength!=null&&(c=Math.min(c,n.maxEditLength));let l=n.timeout??1/0,u=Date.now()+l,d=[{oldPos:-1,lastComponent:void 0}],f=this.extractCommon(d[0],t,e,0,n);if(d[0].oldPos+1>=o&&f+1>=a)return i(this.buildValues(d[0].lastComponent,t,e));let p=-1/0,m=1/0,h=()=>{for(let r=Math.max(p,-s);r<=Math.min(m,s);r+=2){let s,c=d[r-1],l=d[r+1];c&&(d[r-1]=void 0);let u=!1;if(l){let e=l.oldPos-r;u=l&&0<=e&&e<a}let h=c&&c.oldPos+1<o;if(!u&&!h){d[r]=void 0;continue}if(s=!h||u&&c.oldPos<l.oldPos?this.addToPath(l,!0,!1,0,n):this.addToPath(c,!1,!0,1,n),f=this.extractCommon(s,t,e,r,n),s.oldPos+1>=o&&f+1>=a)return i(this.buildValues(s.lastComponent,t,e))||!0;d[r]=s,s.oldPos+1>=o&&(m=Math.min(m,r-1)),f+1>=a&&(p=Math.max(p,r+1))}s++};if(r)(function e(){setTimeout(function(){if(s>c||Date.now()>u)return r(void 0);h()||e()},0)})();else for(;s<=c&&Date.now()<=u;){let e=h();if(e)return e}}addToPath(e,t,n,r,i){let a=e.lastComponent;return a&&!i.oneChangePerToken&&a.added===t&&a.removed===n?{oldPos:e.oldPos+r,lastComponent:{count:a.count+1,added:t,removed:n,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+r,lastComponent:{count:1,added:t,removed:n,previousComponent:a}}}extractCommon(e,t,n,r,i){let a=t.length,o=n.length,s=e.oldPos,c=s-r,l=0;for(;c+1<a&&s+1<o&&this.equals(n[s+1],t[c+1],i);)c++,s++,l++,i.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return l&&!i.oneChangePerToken&&(e.lastComponent={count:l,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=s,c}equals(e,t,n){return n.comparator?n.comparator(e,t):e===t||!!n.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){let t=[];for(let n=0;n<e.length;n++)e[n]&&t.push(e[n]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join(``)}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,n){let r=[],i;for(;e;)r.push(e),i=e.previousComponent,delete e.previousComponent,e=i;r.reverse();let a=r.length,o=0,s=0,c=0;for(;o<a;o++){let e=r[o];if(e.removed)e.value=this.join(n.slice(c,c+e.count)),c+=e.count;else{if(!e.added&&this.useLongestToken){let r=t.slice(s,s+e.count);r=r.map(function(e,t){let r=n[c+t];return r.length>e.length?r:e}),e.value=this.join(r)}else e.value=this.join(t.slice(s,s+e.count));s+=e.count,e.added||(c+=e.count)}}return r}},Wg=class extends Ug{};new Wg;function Gg(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function Kg(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return``;for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function qg(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function Jg(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function Yg(e,t){return qg(e,t,``)}function Xg(e,t){return Jg(e,t,``)}function Zg(e,t){return t.slice(0,Qg(e,t))}function Qg(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);let i=Array(r),a=0;i[0]=0;for(let e=1;e<r;e++){for(t[e]==t[a]?i[e]=i[a]:i[e]=a;a>0&&t[e]!=t[a];)a=i[a];t[e]==t[a]&&a++}a=0;for(let r=n;r<e.length;r++){for(;a>0&&e[r]!=t[a];)a=i[a];e[r]==t[a]&&a++}return a}function $g(e){let t;for(t=e.length-1;t>=0&&e[t].match(/\s/);t--);return e.substring(t+1)}function e_(e){let t=e.match(/^\s*/);return t?t[0]:``}const t_=`a-zA-Z0-9_\\u{C0}-\\u{FF}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}`,n_=RegExp(`[${t_}]+|\\s+|[^${t_}]`,`ug`);var r_=class extends Ug{equals(e,t,n){return n.ignoreCase&&(e=e.toLowerCase(),t=t.toLowerCase()),e.trim()===t.trim()}tokenize(e,t={}){let n;if(t.intlSegmenter){let r=t.intlSegmenter;if(r.resolvedOptions().granularity!=`word`)throw Error(`The segmenter passed must have a granularity of "word"`);n=Array.from(r.segment(e),e=>e.segment)}else n=e.match(n_)||[];let r=[],i=null;return n.forEach(e=>{/\s/.test(e)?i==null?r.push(e):r.push(r.pop()+e):i!=null&&/\s/.test(i)?r[r.length-1]==i?r.push(r.pop()+e):r.push(i+e):r.push(e),i=e}),r}join(e){return e.map((e,t)=>t==0?e:e.replace(/^\s+/,``)).join(``)}postProcess(e,t){if(!e||t.oneChangePerToken)return e;let n=null,r=null,i=null;return e.forEach(e=>{e.added?r=e:e.removed?i=e:((r||i)&&i_(n,i,r,e),n=e,r=null,i=null)}),(r||i)&&i_(n,i,r,null),e}};new r_;function i_(e,t,n,r){if(t&&n){let i=e_(t.value),a=$g(t.value),o=e_(n.value),s=$g(n.value);if(e){let r=Gg(i,o);e.value=Jg(e.value,o,r),t.value=Yg(t.value,r),n.value=Yg(n.value,r)}if(r){let e=Kg(a,s);r.value=qg(r.value,s,e),t.value=Xg(t.value,e),n.value=Xg(n.value,e)}}else if(n){if(e){let e=e_(n.value);n.value=n.value.substring(e.length)}if(r){let e=e_(r.value);r.value=r.value.substring(e.length)}}else if(e&&r){let n=e_(r.value),i=e_(t.value),a=$g(t.value),o=Gg(n,i);t.value=Yg(t.value,o);let s=Kg(Yg(n,o),a);t.value=Xg(t.value,s),r.value=qg(r.value,n,s),e.value=Jg(e.value,n,n.slice(0,n.length-s.length))}else if(r){let e=e_(r.value),n=$g(t.value),i=Zg(n,e);t.value=Xg(t.value,i)}else if(e){let n=$g(e.value),r=e_(t.value),i=Zg(n,r);t.value=Yg(t.value,i)}}var a_=class extends Ug{tokenize(e){let t=RegExp(`(\\r?\\n)|[${t_}]+|[^\\S\\n\\r]+|[^${t_}]`,`ug`);return e.match(t)||[]}};new a_;var o_=class extends Ug{constructor(){super(...arguments),this.tokenize=l_}equals(e,t,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
|
|
145
145
|
`))&&(e=e.trim()),(!n.newlineIsToken||!t.includes(`
|
|
146
146
|
`))&&(t=t.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
|
|
147
147
|
`)&&(e=e.slice(0,-1)),t.endsWith(`
|
|
148
|
-
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};const
|
|
149
|
-
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function
|
|
150
|
-
`)?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,`\`),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:o}}}function
|
|
148
|
+
`)&&(t=t.slice(0,-1))),super.equals(e,t,n)}};const s_=new o_;function c_(e,t,n){return s_.diff(e,t,n)}function l_(e,t){t.stripTrailingCr&&(e=e.replace(/\r\n/g,`
|
|
149
|
+
`));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function u_(e){return e==`.`||e==`!`||e==`?`}var d_=class extends Ug{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if(u_(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}};new d_;var f_=class extends Ug{tokenize(e){return e.split(/([{}:;,]|\s+)/)}};new f_;var p_=class extends Ug{constructor(){super(...arguments),this.tokenize=l_}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(m_(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};new p_;function m_(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a;for(a=0;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=m_(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=m_(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}var h_=class extends Ug{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};new h_;function g_(e,t,n,r,i,a,o){let s;s=o?typeof o==`function`?{callback:o}:o:{},s.context===void 0&&(s.context=4);let c=s.context;if(s.newlineIsToken)throw Error(`newlineIsToken may not be used with patch-generation functions, only with diffing functions`);if(s.callback){let{callback:e}=s;c_(n,r,Object.assign(Object.assign({},s),{callback:t=>{let n=l(t);e(n)}}))}else return l(c_(n,r,s));function l(n){if(!n)return;n.push({value:``,lines:[]});function r(e){return e.map(function(e){return` `+e})}let o=[],s=0,l=0,u=[],d=1,f=1;for(let e=0;e<n.length;e++){let t=n[e],i=t.lines||__(t.value);if(t.lines=i,t.added||t.removed){if(!s){let t=n[e-1];s=d,l=f,t&&(u=c>0?r(t.lines.slice(-c)):[],s-=u.length,l-=u.length)}for(let e of i)u.push((t.added?`+`:`-`)+e);t.added?f+=i.length:d+=i.length}else{if(s)if(i.length<=c*2&&e<n.length-2)for(let e of r(i))u.push(e);else{let e=Math.min(i.length,c);for(let t of r(i.slice(0,e)))u.push(t);let t={oldStart:s,oldLines:d-s+e,newStart:l,newLines:f-l+e,lines:u};o.push(t),s=0,l=0,u=[]}d+=i.length,f+=i.length}}for(let e of o)for(let t=0;t<e.lines.length;t++)e.lines[t].endsWith(`
|
|
150
|
+
`)?e.lines[t]=e.lines[t].slice(0,-1):(e.lines.splice(t+1,0,`\`),t++);return{oldFileName:e,newFileName:t,oldHeader:i,newHeader:a,hunks:o}}}function __(e){let t=e.endsWith(`
|
|
151
151
|
`),n=e.split(`
|
|
152
152
|
`).map(e=>e+`
|
|
153
|
-
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}const
|
|
153
|
+
`);return t?n.pop():n.push(n.pop().slice(0,-1)),n}const v_={readLineLimit:2e3,readLineLengthLimit:2e3,plainOutputCharacterLimit:8192};let y_;const b_=e=>{let t=()=>y_||(y_=Promise.resolve((0,D.createInMemoryClientServer)().client),y_);return{...e({client(){return t()}}),withContext:n=>{if(n.client||=t(),typeof n.client==`function`){let t=n.client;return e({client:t})}return e({client:()=>Promise.resolve(n.client)})}}},x_=e=>{let{ansiOutput:t,...n}=e;return{type:`json`,value:n}},S_={execute_bash:b_(({client:e})=>({description:"Execute a bash command in a compute instance. **ALL OUTPUT IS AUTOMATICALLY CAPTURED AND STORED** - never use pipes to filter output during execution.\n\n**Process Management:**\n- Use the returned PID with `process_wait` to get complete results\n- Use `process_grep_output` to search through the FULL stored output\n- Use `process_read_output` to read any portion of the stored output\n- **NEVER use pipes like `| grep`, `| head`, `| tail`** - run commands cleanly and analyze afterward\n\n**Output Storage:**\n- Every command's complete stdout/stderr is permanently stored\n- You can search, filter, and read from this stored output multiple times\n- No information is ever lost, even from long-running processes\n\nExample workflow:\n1. `execute_bash` returns PID 123\n2. `process_wait` on PID 123 to see if it completed\n3. `process_grep_output` on PID 123 to find errors",inputSchema:y.z.object({command:y.z.string(),working_directory:y.z.string().describe(`The working directory to execute the command in. Use '.' for the current directory.`),env:y.z.record(y.z.string(),y.z.string()),env_file:y.z.string().optional().describe(`A file to read environment variables from. e.g. .env.local`)}),execute:async(t,n)=>(await e()).request(`process_execute`,{command:`bash`,args:[`-c`,t.command],cwd:t.working_directory,env:t.env,env_file:t.env_file},{signal:n.abortSignal})})),execute_bash_sync:b_(({client:e})=>({description:`Execute a bash command and return output synchronously in a compute instance. **ALL OUTPUT IS AUTOMATICALLY CAPTURED AND STORED** - never use pipes to filter output during execution.
|
|
154
154
|
|
|
155
|
-
Use the same rules as \`execute_bash\`, but the output is returned synchronously.`,inputSchema:y.z.object({command:y.z.string(),working_directory:y.z.string().describe(`The working directory to execute the command in. Use '.' for the current directory.`),env:y.z.record(y.z.string(),y.z.string()),env_file:y.z.string().optional().describe(`A file to read environment variables from. e.g. .env.local`)}),async*execute(t,n){let r=await(await e()).request(`process_execute`,{command:`bash`,args:[`-c`,t.command],cwd:t.working_directory,env:t.env,env_file:t.env_file},{signal:n.abortSignal});for await(let t of
|
|
155
|
+
Use the same rules as \`execute_bash\`, but the output is returned synchronously.`,inputSchema:y.z.object({command:y.z.string(),working_directory:y.z.string().describe(`The working directory to execute the command in. Use '.' for the current directory.`),env:y.z.record(y.z.string(),y.z.string()),env_file:y.z.string().optional().describe(`A file to read environment variables from. e.g. .env.local`)}),async*execute(t,n){let r=await(await e()).request(`process_execute`,{command:`bash`,args:[`-c`,t.command],cwd:t.working_directory,env:t.env,env_file:t.env_file},{signal:n.abortSignal});for await(let t of C_({client:await e(),pid:r.pid,abortSignal:n.abortSignal}))yield t},toModelOutput:x_})),process_send_input:b_(({client:e})=>({description:`Send input to a process by PID that was started by the execute_bash tool.
|
|
156
156
|
|
|
157
157
|
Use "\r
|
|
158
|
-
" to send a newline (e.g. for an interactive prompt).`,inputSchema:y.z.object({pid:y.z.number(),data:y.z.string()}),execute:async(t,n)=>(await e()).request(`process_send_input`,{pid:t.pid,data:t.data},{signal:n.abortSignal})})),process_kill:
|
|
158
|
+
" to send a newline (e.g. for an interactive prompt).`,inputSchema:y.z.object({pid:y.z.number(),data:y.z.string()}),execute:async(t,n)=>(await e()).request(`process_send_input`,{pid:t.pid,data:t.data},{signal:n.abortSignal})})),process_kill:b_(({client:e})=>({description:`Kill a process by PID that was started by the execute_bash tool.`,inputSchema:y.z.object({pid:y.z.number(),signal:y.z.string()}),execute:async(t,n)=>(await e()).request(`process_kill`,{pid:t.pid,signal:t.signal},{signal:n.abortSignal})})),process_wait:b_(({client:e})=>({description:`This tool waits for a process to exit, or returns instantly if the process already has exited.
|
|
159
159
|
|
|
160
160
|
Output from the process will be returned along with it's exit code, duration, and whether the process is still running.
|
|
161
161
|
|
|
162
162
|
IMPORTANT: ALWAYS use this tool to determine the status of a process. NEVER use "ps".
|
|
163
|
-
`,inputSchema:y.z.object({pid:y.z.number(),timeout_ms:y.z.number().optional().describe(`The timeout in milliseconds to wait to return output. This does *not* kill the process, it simply returns early with current output of the process. Defaults to 25 seconds.`)}),async*execute(t,n){for await(let r of
|
|
163
|
+
`,inputSchema:y.z.object({pid:y.z.number(),timeout_ms:y.z.number().optional().describe(`The timeout in milliseconds to wait to return output. This does *not* kill the process, it simply returns early with current output of the process. Defaults to 25 seconds.`)}),async*execute(t,n){for await(let r of C_({client:await e(),pid:t.pid,abortSignal:n.abortSignal,timeoutMs:t.timeout_ms}))yield r},toModelOutput:x_})),read_file:b_(({client:e})=>(0,m.tool)({description:`Reads a file from the workspace filesystem. You can access any file directly by using this tool.
|
|
164
164
|
Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
|
|
165
165
|
|
|
166
166
|
Usage:
|
|
167
167
|
- The path parameter can be a relative path or an absolute path
|
|
168
|
-
- By default, it reads up to ${
|
|
168
|
+
- By default, it reads up to ${v_.readLineLimit} lines starting from the beginning of the file
|
|
169
169
|
- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters
|
|
170
|
-
- Any lines longer than ${
|
|
170
|
+
- Any lines longer than ${v_.readLineLengthLimit} characters will be truncated
|
|
171
171
|
- Results are returned using cat -n format, with line numbers starting at 1
|
|
172
172
|
- This tool allows Blink to read images (eg PNG, JPG, etc). When reading an image file the contents are presented visually as Blink is a multimodal LLM
|
|
173
173
|
- You have the capability to call multiple tools in a single response. It is always better to speculatively read multiple files as a batch that are potentially useful.
|
|
174
174
|
- You will regularly be asked to read screenshots. If the user provides a path to a screenshot ALWAYS use this tool to view the file at the path. This tool will work with all temporary file paths like /var/folders/123/abc/T/TemporaryItems/NSIRD_screencaptureui_ZfB1tD/Screenshot.png
|
|
175
|
-
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`,inputSchema:y.z.object({file_path:y.z.string(),line_offset:y.z.number(),line_limit:y.z.number()}),execute:async(t,n)=>await(await e()).request(`read_file`,{path:t.file_path,line_start:t.line_offset,line_end:t.line_offset+t.line_limit},{signal:n.abortSignal}),toModelOutput:e=>e.mime_type?.startsWith(`image/`)?{type:`content`,value:[{type:`media`,data:e.content,mediaType:e.mime_type}]}:{type:`json`,value:e}})),write_file:
|
|
175
|
+
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.`,inputSchema:y.z.object({file_path:y.z.string(),line_offset:y.z.number(),line_limit:y.z.number()}),execute:async(t,n)=>await(await e()).request(`read_file`,{path:t.file_path,line_start:t.line_offset,line_end:t.line_offset+t.line_limit},{signal:n.abortSignal}),toModelOutput:e=>e.mime_type?.startsWith(`image/`)?{type:`content`,value:[{type:`media`,data:e.content,mediaType:e.mime_type}]}:{type:`json`,value:e}})),write_file:b_(({client:e})=>({description:`Write a file to the filesystem.`,inputSchema:y.z.object({file_path:y.z.string(),content:y.z.string()}),execute:async(t,n)=>{await(await e()).request(`write_file`,{path:t.file_path,content:t.content},{signal:n.abortSignal})}})),read_directory:b_(({client:e})=>(0,m.tool)({description:`Reads a directory from the workspace filesystem.`,inputSchema:y.z.object({directory_path:y.z.string()}),execute:async(t,n)=>(await e()).request(`read_directory`,{path:t.directory_path})})),edit_file:b_(({client:e})=>({description:`This is a tool for making multiple edits to a single file in one operation. It is built on top of the "workspace_edit_file" tool and allows you to perform multiple find-and-replace operations efficiently. Prefer this tool over the "workspace_edit_file" tool when you need to make multiple edits to the same file.
|
|
176
176
|
|
|
177
177
|
Before using this tool:
|
|
178
178
|
|
|
@@ -210,7 +210,7 @@ When making edits:
|
|
|
210
210
|
If you want to create a new file, use:
|
|
211
211
|
- A new file path, including dir name if needed
|
|
212
212
|
- First edit: empty old_string and the new file's contents as new_string
|
|
213
|
-
- Subsequent edits: normal edit operations on the created content`,inputSchema:y.z.object({file_path:y.z.string(),edits:y.z.array(y.z.object({old_string:y.z.string(),new_string:y.z.string(),expected_replacements:y.z.number()}))}),execute:async(t,n)=>{let r=await e(),i;try{i=(await r.request(`read_file`,{path:t.file_path},{signal:n.abortSignal})).content}catch{if(i=t.edits[0].new_string,t.edits.length>0&&t.edits[0].old_string===``)i=t.edits[0].new_string,t.edits.shift();else throw Error(`input is invalid: File does not exist and first edit is not for file creation.\nFile: ${t.file_path}`)}let a=i,o=[];for(let e of t.edits){let t=e.expected_replacements??1,n=e.old_string;if(n===
|
|
213
|
+
- Subsequent edits: normal edit operations on the created content`,inputSchema:y.z.object({file_path:y.z.string(),edits:y.z.array(y.z.object({old_string:y.z.string(),new_string:y.z.string(),expected_replacements:y.z.number()}))}),execute:async(t,n)=>{let r=await e(),i;try{i=(await r.request(`read_file`,{path:t.file_path},{signal:n.abortSignal})).content}catch{if(i=t.edits[0].new_string,t.edits.length>0&&t.edits[0].old_string===``)i=t.edits[0].new_string,t.edits.shift();else throw Error(`input is invalid: File does not exist and first edit is not for file creation.\nFile: ${t.file_path}`)}let a=i,o=[];for(let e of t.edits){let t=e.expected_replacements??1,n=e.old_string,r=e.new_string;if(n===r)throw Error(`input is invalid: old_string and new_string are identical.\nString: ${n}`);let i=w_(a,n);if(i===0)throw Error(`input is invalid: String to replace not found in file.\nString: ${n}`);if(i!==t)throw Error(`input is invalid: Found ${i} matches of the string to replace, but expected ${t}. The number of actual matches must equal the expected replacements. Please adjust your string to match or update the expected count.\nString: ${n}`)}for(let e of t.edits){let t=e.old_string,n=e.new_string;a=T_(a,t,n),o.push({old_string:t,new_string:n})}await r.request(`write_file`,{path:t.file_path,content:a},{signal:n.abortSignal});let s=g_(t.file_path,t.file_path,i,a);return{edits:o,file_path:t.file_path,structured_patch:s.hunks.map(e=>({old_start:e.oldStart,old_end:e.oldLines,new_start:e.newStart,new_end:e.newLines,lines:e.lines}))}}})),process_grep_output:b_(({client:e})=>({description:`Search through the output of a running or completed process. **This is the PRIMARY tool for analyzing command output** - use this instead of piping commands to grep, tail, or re-running commands with filters.
|
|
214
214
|
|
|
215
215
|
Use this for:
|
|
216
216
|
- Finding test failures and error messages
|
|
@@ -218,7 +218,7 @@ Use this for:
|
|
|
218
218
|
- Extracting relevant information from verbose output
|
|
219
219
|
- Analyzing build or test results
|
|
220
220
|
|
|
221
|
-
Example: After running tests with \`workspace_bash\`, use this to find all FAIL: lines rather than re-running the test command.`,inputSchema:y.z.object({pid:y.z.number(),pattern:y.z.string(),before_lines:y.z.number(),after_lines:y.z.number()}),execute:async(t,n)=>{let r;try{r=new RegExp(t.pattern)}catch{throw Error(`Invalid regex pattern: ${t.pattern}`)}let{lines:i}=await(await e()).request(`process_read_plain_output`,{pid:t.pid},{signal:n.abortSignal}),a=[];for(let e=0;e<i.length;e++)if(i[e].match(r)){let n=Math.max(0,e-t.before_lines),r=Math.min(i.length-1,e+t.after_lines),o=i.slice(n,r+1);a.push({line_number:e,lines:o})}if(a.length>256)throw Error(`Too many matches. Please refine your search.`);return{matches:a,total_matches:a.length}}}))},
|
|
221
|
+
Example: After running tests with \`workspace_bash\`, use this to find all FAIL: lines rather than re-running the test command.`,inputSchema:y.z.object({pid:y.z.number(),pattern:y.z.string(),before_lines:y.z.number(),after_lines:y.z.number()}),execute:async(t,n)=>{let r;try{r=new RegExp(t.pattern)}catch{throw Error(`Invalid regex pattern: ${t.pattern}`)}let{lines:i}=await(await e()).request(`process_read_plain_output`,{pid:t.pid},{signal:n.abortSignal}),a=[];for(let e=0;e<i.length;e++)if(i[e].match(r)){let n=Math.max(0,e-t.before_lines),r=Math.min(i.length-1,e+t.after_lines),o=i.slice(n,r+1);a.push({line_number:e,lines:o})}if(a.length>256)throw Error(`Too many matches. Please refine your search.`);return{matches:a,total_matches:a.length}}}))},C_=async function*({client:e,pid:t,abortSignal:n,timeoutMs:r}){let i=await e,a=[],o=null,s=!1,c=null,l=``,u=i.onNotification(`process_output`,e=>{e.pid===t&&(l+=e.output,a.push({pid:t,ansiOutput:l}),o?.())}),d=i.request(`process_wait`,{pid:t,output_idle_timeout_ms:3e3,timeout_ms:r??25e3},{signal:n}).then(e=>{a.push({pid:e.pid,title:e.title,command:e.command,args:e.args,cwd:e.cwd,env:e.env,ansiOutput:e.ansi_output,plainOutput:{totalLines:e.plain_output.total_lines,lines:e.plain_output.lines},durationMs:e.duration_ms,exitCode:e.exit_code,exitSignal:e.exit_signal,stillRunning:typeof e.exit_code!=`number`&&typeof e.exit_signal!=`number`}),s=!0,o?.()}).catch(e=>{c=e,s=!0,o?.()});try{for(;!s||a.length>0;){if(c)throw c;for(a.length===0&&(await new Promise(e=>{o=e}),o=null);a.length>0;)yield a.shift()}await d}finally{u.dispose()}};y.z.union([y.z.object({pid:y.z.number(),ansiOutput:y.z.string()}),y.z.object({pid:y.z.number(),title:y.z.string().optional(),command:y.z.string(),args:y.z.array(y.z.string()),cwd:y.z.string(),env:y.z.record(y.z.string(),y.z.string()),ansiOutput:y.z.string(),plainOutput:y.z.object({totalLines:y.z.number(),lines:y.z.array(y.z.string())}),durationMs:y.z.number(),exitCode:y.z.number().optional(),exitSignal:y.z.number().optional(),stillRunning:y.z.boolean()})]);const w_=(e,t)=>{if(t.length===0)return 0;let n=0,r=0;for(;(r=e.indexOf(t,r))!==-1;)n++,r+=t.length;return n},T_=(e,t,n)=>t.length===0?e:e.split(t).join(n),E_={scout:{".env.local.hbs":`# Store local environment variables here.
|
|
222
222
|
# They will be used by blink dev for development.
|
|
223
223
|
{{#each envLocal}}
|
|
224
224
|
{{this.[0]}}={{this.[1]}}
|
|
@@ -793,7 +793,7 @@ agent.serve();
|
|
|
793
793
|
},
|
|
794
794
|
"devDependencies": {
|
|
795
795
|
"zod": "latest",
|
|
796
|
-
"ai": "
|
|
796
|
+
"ai": "^5",
|
|
797
797
|
{{#if (eq aiProvider "anthropic")}}
|
|
798
798
|
"@ai-sdk/anthropic": "latest",
|
|
799
799
|
{{else if (eq aiProvider "openai")}}
|
|
@@ -1330,7 +1330,7 @@ agent.serve();
|
|
|
1330
1330
|
},
|
|
1331
1331
|
"devDependencies": {
|
|
1332
1332
|
"zod": "latest",
|
|
1333
|
-
"ai": "
|
|
1333
|
+
"ai": "^5",
|
|
1334
1334
|
{{#if (eq aiProvider "anthropic")}}
|
|
1335
1335
|
"@ai-sdk/anthropic": "latest",
|
|
1336
1336
|
{{else if (eq aiProvider "openai")}}
|
|
@@ -1935,7 +1935,7 @@ agent.serve();`,"package.json.hbs":`{
|
|
|
1935
1935
|
},
|
|
1936
1936
|
"devDependencies": {
|
|
1937
1937
|
"zod": "latest",
|
|
1938
|
-
"ai": "
|
|
1938
|
+
"ai": "^5",
|
|
1939
1939
|
{{#if (eq aiProvider "anthropic")}}
|
|
1940
1940
|
"@ai-sdk/anthropic": "latest",
|
|
1941
1941
|
{{else if (eq aiProvider "openai")}}
|
|
@@ -1974,7 +1974,7 @@ agent.serve();`,"package.json.hbs":`{
|
|
|
1974
1974
|
"types": ["node"]
|
|
1975
1975
|
}
|
|
1976
1976
|
}
|
|
1977
|
-
`}};function
|
|
1977
|
+
`}};function D_(e,n,r){let i,a=d.default.createServer(t.createServerAdapter(async t=>{let o=new URL(t.url,i);if(o.pathname!==`/`)return new Response(`Not found`,{status:404});let s=o.searchParams.get(`code`);if(s)try{let e=await fetch(`https://api.github.com/app-manifests/${s}/conversions`,{method:`POST`,headers:{Accept:`application/vnd.github+json`,"User-Agent":`blink.so`,"X-GitHub-Api-Version":`2022-11-28`}});if(!e.ok){let t=await e.text();throw Error(`GitHub API error: ${e.status} ${e.statusText}${t?` - ${t}`:``}`)}let t=await e.json();return await r?.(null,t),new Response(`GitHub App created successfully! Return to your terminal to continue.`,{headers:{"Content-Type":`text/plain`}})}catch(e){let t=e instanceof Error?e:Error(String(e));try{await r?.(t,null)}catch(e){t=e instanceof Error?e:Error(String(e))}let n=t.message;return new Response(`Error: ${n}\n\nReturn to your terminal for more details.`,{status:500,headers:{"Content-Type":`text/plain`}})}finally{a.close()}let c={...e,redirect_url:i},l=`<!DOCTYPE html>
|
|
1978
1978
|
<html>
|
|
1979
1979
|
<body>
|
|
1980
1980
|
<form id="f" method="POST" action="${n?`https://github.com/organizations/${n}/settings/apps/new`:`https://github.com/settings/apps/new`}">
|
|
@@ -1982,7 +1982,7 @@ agent.serve();`,"package.json.hbs":`{
|
|
|
1982
1982
|
</form>
|
|
1983
1983
|
<script>document.getElementById('f').submit()<\/script>
|
|
1984
1984
|
</body>
|
|
1985
|
-
</html>`;return new Response(l,{headers:{"Content-Type":`text/html`}})}));return new Promise((e,t)=>{a.on(`error`,t),a.listen(0,`127.0.0.1`,()=>{let n=a.address();if(!n||typeof n==`string`){t(Error(`Failed to get server address`));return}i=`http://127.0.0.1:${n.port}`,e(i)})})}const T_=y.z.enum([`read`,`write`]),E_=y.z.union([y.z.literal(`branch_protection_rule`).describe(`Branch protection rule created, edited, or deleted`),y.z.literal(`check_run`).describe(`Check run created, completed, or requested`),y.z.literal(`check_suite`).describe(`Check suite completed or requested`),y.z.literal(`code_scanning_alert`).describe(`Code scanning alert created, fixed, or reopened`),y.z.literal(`commit_comment`).describe(`Commit comment created`),y.z.literal(`create`).describe(`Branch or tag created`),y.z.literal(`delete`).describe(`Branch or tag deleted`),y.z.literal(`deployment`).describe(`Deployment created`),y.z.literal(`deployment_status`).describe(`Deployment status created`),y.z.literal(`deployment_protection_rule`).describe(`Deployment protection rule requested`),y.z.literal(`discussion`).describe(`Discussion created, edited, or deleted`),y.z.literal(`discussion_comment`).describe(`Discussion comment created, edited, or deleted`),y.z.literal(`fork`).describe(`Repository forked`),y.z.literal(`gollum`).describe(`Wiki page created or updated`),y.z.literal(`issue_comment`).describe(`Issue comment created, edited, or deleted`),y.z.literal(`issues`).describe(`Issue opened, edited, closed, or labeled`),y.z.literal(`label`).describe(`Label created, edited, or deleted`),y.z.literal(`member`).describe(`Collaborator added, removed, or edited`),y.z.literal(`membership`).describe(`Team membership added or removed`),y.z.literal(`meta`).describe(`GitHub App webhook configuration changed`),y.z.literal(`milestone`).describe(`Milestone created, closed, or deleted`),y.z.literal(`organization`).describe(`Organization member added, removed, or invited`),y.z.literal(`org_block`).describe(`Organization blocked or unblocked a user`),y.z.literal(`package`).describe(`Package published or updated`),y.z.literal(`page_build`).describe(`GitHub Pages site built`),y.z.literal(`project`).describe(`Project created, updated, or deleted`),y.z.literal(`project_card`).describe(`Project card created, edited, or deleted`),y.z.literal(`project_column`).describe(`Project column created, updated, or deleted`),y.z.literal(`public`).describe(`Repository visibility changed to public`),y.z.literal(`pull_request`).describe(`Pull request opened, closed, edited, or synchronized`),y.z.literal(`pull_request_review`).describe(`Pull request review submitted, edited, or dismissed`),y.z.literal(`pull_request_review_comment`).describe(`Pull request review comment created or edited`),y.z.literal(`pull_request_review_thread`).describe(`Pull request review thread resolved or unresolved`),y.z.literal(`push`).describe(`Git push to a repository`),y.z.literal(`registry_package`).describe(`Registry package published or updated`),y.z.literal(`release`).describe(`Release published or edited`),y.z.literal(`repository`).describe(`Repository created, deleted, archived, or publicized`),y.z.literal(`repository_dispatch`).describe(`Custom webhook event triggered`),y.z.literal(`secret_scanning_alert`).describe(`Secret scanning alert created or resolved`),y.z.literal(`security_and_analysis`).describe(`Security features enabled or disabled`),y.z.literal(`star`).describe(`Repository starred or unstarred`),y.z.literal(`status`).describe(`Commit status created`),y.z.literal(`team`).describe(`Team created, deleted, or edited`),y.z.literal(`team_add`).describe(`Repository added to team`),y.z.literal(`watch`).describe(`User started watching repository`),y.z.literal(`workflow_dispatch`).describe(`Workflow manually triggered`),y.z.literal(`workflow_job`).describe(`Workflow job queued, started, or completed`),y.z.literal(`workflow_run`).describe(`Workflow run requested or completed`)]),D_=y.z.object({name:y.z.string().optional().describe(`The name of the GitHub App. Leave blank to let the user name it on GitHub.`),url:y.z.url().describe(`The homepage URL of the GitHub App. If unknown, set to https://blink.coder.com.`),description:y.z.string().optional().describe(`The description of the GitHub App.`),public:y.z.boolean().optional().describe(`Whether the GitHub App is public. Always default to false unless the user explicitly requests otherwise.`),hook_attributes:y.z.object({url:y.z.url(),active:y.z.boolean().optional().default(!0)}).optional().describe(`The webhook configuration for the GitHub App.`),callback_urls:y.z.array(y.z.url()).max(10).optional().describe(`Callback URLs for the GitHub App after the user authenticates with GitHub.`),setup_url:y.z.url().optional().describe(`The URL to redirect the user to after they install the GitHub App.`),setup_on_update:y.z.boolean().optional().describe(`Whether to redirect the user to the setup URL after an update to the installed app.`),request_oauth_on_install:y.z.boolean().optional().describe(`Whether to request OAuth on install.`),default_events:y.z.array(E_).optional().describe(`Webhook events sent to the webhook URL.`),default_permissions:y.z.record(y.z.string(),T_).optional().describe(`Repository and organization permissions for the GitHub App. Available permissions: actions (GitHub Actions workflows), administration (repository settings), checks (check runs), contents (repository code), deployments, environments, issues, metadata (always granted), packages, pages, pull_requests, repository_hooks (webhooks), repository_projects, secret_scanning_alerts, secrets (Actions secrets), security_events (code scanning/Dependabot), single_file, statuses (commit statuses), vulnerability_alerts (Dependabot), workflows (workflow files), members (collaborators). Values can be 'read' or 'write'.`)});function O_(e){return`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(e))}`}const k_=y.z.union([y.z.literal(`app_mention`).describe(`Bot is @mentioned in a channel or conversation. Requires scope: app_mentions:read`),y.z.literal(`app_home_opened`).describe(`User opened the app's Home tab. No additional scope required beyond bot token`),y.z.literal(`app_installed`).describe(`App was installed to a workspace. No additional scope required beyond bot token`),y.z.literal(`app_uninstalled`).describe(`App was uninstalled from a workspace. No additional scope required beyond bot token`),y.z.literal(`assistant_thread_context_changed`).describe(`Context changed in an assistant thread. Requires scope: assistant:write`),y.z.literal(`assistant_thread_started`).describe(`New assistant thread was started. Requires scope: assistant:write`),y.z.literal(`channel_archive`).describe(`Public channel was archived. Requires scope: channels:read`),y.z.literal(`channel_created`).describe(`Public channel was created. Requires scope: channels:read`),y.z.literal(`channel_deleted`).describe(`Public channel was deleted. Requires scope: channels:read`),y.z.literal(`channel_rename`).describe(`Public channel was renamed. Requires scope: channels:read`),y.z.literal(`channel_unarchive`).describe(`Public channel was unarchived. Requires scope: channels:read`),y.z.literal(`dnd_updated_user`).describe(`User's Do Not Disturb settings changed. Requires scope: dnd:read`),y.z.literal(`email_domain_changed`).describe(`Workspace's email domain changed. Requires scope: team:read`),y.z.literal(`emoji_changed`).describe(`Custom emoji was added or changed. Requires scope: emoji:read`),y.z.literal(`file_change`).describe(`File was changed. Requires scope: files:read`),y.z.literal(`file_created`).describe(`File was created. Requires scope: files:read`),y.z.literal(`file_deleted`).describe(`File was deleted. Requires scope: files:read`),y.z.literal(`file_public`).describe(`File was made public. Requires scope: files:read`),y.z.literal(`file_shared`).describe(`File was shared. Requires scope: files:read`),y.z.literal(`file_unshared`).describe(`File was unshared. Requires scope: files:read`),y.z.literal(`group_archive`).describe(`Private channel was archived. Requires scope: groups:read`),y.z.literal(`group_deleted`).describe(`Private channel was deleted. Requires scope: groups:read`),y.z.literal(`group_rename`).describe(`Private channel was renamed. Requires scope: groups:read`),y.z.literal(`group_unarchive`).describe(`Private channel was unarchived. Requires scope: groups:read`),y.z.literal(`link_shared`).describe(`Link from a registered domain was shared. Requires scope: links:read`),y.z.literal(`member_joined_channel`).describe(`User joined a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),y.z.literal(`member_left_channel`).describe(`User left a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),y.z.literal(`message.channels`).describe(`Message was posted in a public channel. Requires scope: channels:history`),y.z.literal(`message.groups`).describe(`Message was posted in a private channel. Requires scope: groups:history`),y.z.literal(`message.im`).describe(`Message was posted in a direct message. Requires scope: im:history`),y.z.literal(`message.mpim`).describe(`Message was posted in a multi-party direct message. Requires scope: mpim:history`),y.z.literal(`pin_added`).describe(`Item was pinned in a channel. Requires scope: pins:read`),y.z.literal(`pin_removed`).describe(`Item was unpinned from a channel. Requires scope: pins:read`),y.z.literal(`reaction_added`).describe(`Reaction was added to a message. Requires scope: reactions:read`),y.z.literal(`reaction_removed`).describe(`Reaction was removed from a message. Requires scope: reactions:read`),y.z.literal(`team_join`).describe(`New user joined the workspace. Requires scope: users:read`),y.z.literal(`user_change`).describe(`User's profile or settings changed. Requires scope: users:read`)]),A_=y.z.union([y.z.literal(`app_mentions:read`).describe(`Read messages that directly mention the bot. Required for: app_mention event`),y.z.literal(`assistant:write`).describe(`Update bot status and write assistant messages. This should *always* be included for Slack bots. It improves the UX dramatically for users. Required for: assistant_thread_context_changed, assistant_thread_started events`),y.z.literal(`channels:history`).describe(`Read message history in public channels the bot has access to. Required for: message.channels event`),y.z.literal(`channels:join`).describe(`Join public channels`),y.z.literal(`channels:manage`).describe(`Manage public channels (archive, rename, etc.)`),y.z.literal(`channels:read`).describe(`View basic information about public channels. Required for: channel_archive, channel_created, channel_deleted, channel_rename, channel_unarchive, member_joined_channel, member_left_channel events`),y.z.literal(`chat:write`).describe(`Send messages as the bot`),y.z.literal(`chat:write.customize`).describe(`Send messages with a customized username and avatar`),y.z.literal(`chat:write.public`).describe(`Send messages to public channels without joining`),y.z.literal(`commands`).describe(`Add and use slash commands`),y.z.literal(`dnd:read`).describe(`View Do Not Disturb settings for users. Required for: dnd_updated_user event`),y.z.literal(`emoji:read`).describe(`View custom emoji in the workspace. Required for: emoji_changed event`),y.z.literal(`files:read`).describe(`View files shared in channels and conversations. Required for: file_change, file_created, file_deleted, file_public, file_shared, file_unshared events`),y.z.literal(`files:write`).describe(`Upload, edit, and delete files`),y.z.literal(`groups:history`).describe(`Read message history in private channels the bot has access to. Required for: message.groups event`),y.z.literal(`groups:read`).describe(`View basic information about private channels. Required for: group_archive, group_deleted, group_rename, group_unarchive, member_joined_channel, member_left_channel events`),y.z.literal(`groups:write`).describe(`Manage private channels (archive, rename, create, etc.)`),y.z.literal(`im:history`).describe(`Read message history in direct messages with the bot. Required for: message.im event`),y.z.literal(`im:read`).describe(`View basic information about direct messages with the bot`),y.z.literal(`im:write`).describe(`Start and manage direct messages with users`),y.z.literal(`links:read`).describe(`View URLs in messages. Required for: link_shared event`),y.z.literal(`links:write`).describe(`Show previews of URLs (unfurling)`),y.z.literal(`metadata.message:read`).describe(`Read message metadata`),y.z.literal(`mpim:history`).describe(`Read message history in multi-party direct messages. Required for: message.mpim event`),y.z.literal(`mpim:read`).describe(`View basic information about multi-party direct messages`),y.z.literal(`mpim:write`).describe(`Start and manage multi-party direct messages`),y.z.literal(`pins:read`).describe(`View pinned items in channels and conversations. Required for: pin_added, pin_removed events`),y.z.literal(`pins:write`).describe(`Pin and unpin items in channels and conversations`),y.z.literal(`reactions:read`).describe(`View emoji reactions on messages. Required for: reaction_added, reaction_removed events`),y.z.literal(`reactions:write`).describe(`Add and remove emoji reactions to messages`),y.z.literal(`reminders:read`).describe(`View reminders created by the bot`),y.z.literal(`reminders:write`).describe(`Create, update, and delete reminders`),y.z.literal(`team:read`).describe(`View workspace name, domain, and other basic information. Required for: email_domain_changed event`),y.z.literal(`usergroups:read`).describe(`View user groups and their members`),y.z.literal(`usergroups:write`).describe(`Create, update, and archive user groups`),y.z.literal(`users.profile:read`).describe(`View profile information about users`),y.z.literal(`users:read`).describe(`View users in the workspace. Required for: team_join, user_change events`),y.z.literal(`users:read.email`).describe(`View email addresses of users in the workspace`),y.z.literal(`users:write`).describe(`Set presence and status for the bot user`)]),j_=y.z.union([y.z.literal(`channels:history`).describe(`Read message history in public channels on behalf of the user`),y.z.literal(`channels:read`).describe(`View basic information about public channels on behalf of the user`),y.z.literal(`channels:write`).describe(`Manage public channels on behalf of the user`),y.z.literal(`chat:write`).describe(`Send messages on behalf of the user`),y.z.literal(`emoji:read`).describe(`View custom emoji on behalf of the user`),y.z.literal(`files:read`).describe(`View files on behalf of the user`),y.z.literal(`files:write`).describe(`Upload, edit, and delete files on behalf of the user`),y.z.literal(`groups:history`).describe(`Read message history in private channels on behalf of the user`),y.z.literal(`groups:read`).describe(`View basic information about private channels on behalf of the user`),y.z.literal(`groups:write`).describe(`Manage private channels on behalf of the user`),y.z.literal(`im:history`).describe(`Read direct message history on behalf of the user`),y.z.literal(`im:read`).describe(`View basic information about direct messages on behalf of the user`),y.z.literal(`im:write`).describe(`Manage direct messages on behalf of the user`),y.z.literal(`links:read`).describe(`View URLs in messages on behalf of the user`),y.z.literal(`links:write`).describe(`Show URL previews on behalf of the user`),y.z.literal(`mpim:history`).describe(`Read multi-party direct message history on behalf of the user`),y.z.literal(`mpim:read`).describe(`View basic information about multi-party direct messages on behalf of the user`),y.z.literal(`mpim:write`).describe(`Manage multi-party direct messages on behalf of the user`),y.z.literal(`pins:read`).describe(`View pinned items on behalf of the user`),y.z.literal(`pins:write`).describe(`Pin and unpin items on behalf of the user`),y.z.literal(`reactions:read`).describe(`View emoji reactions on behalf of the user`),y.z.literal(`reactions:write`).describe(`Add and remove emoji reactions on behalf of the user`),y.z.literal(`reminders:read`).describe(`View reminders on behalf of the user`),y.z.literal(`reminders:write`).describe(`Create, update, and delete reminders on behalf of the user`),y.z.literal(`search:read`).describe(`Search messages and files on behalf of the user`),y.z.literal(`stars:read`).describe(`View starred items on behalf of the user`),y.z.literal(`stars:write`).describe(`Star and unstar items on behalf of the user`),y.z.literal(`team:read`).describe(`View workspace information on behalf of the user`),y.z.literal(`usergroups:read`).describe(`View user groups on behalf of the user`),y.z.literal(`usergroups:write`).describe(`Manage user groups on behalf of the user`),y.z.literal(`users.profile:read`).describe(`View user profile information on behalf of the user`),y.z.literal(`users.profile:write`).describe(`Edit the user's profile information`),y.z.literal(`users:read`).describe(`View users in the workspace on behalf of the user`),y.z.literal(`users:read.email`).describe(`View email addresses on behalf of the user`),y.z.literal(`users:write`).describe(`Set presence for the user`)]),M_=y.z.object({display_information:y.z.object({name:y.z.string().describe(`The name of the Slack app.`),description:y.z.string().optional().describe(`A short description of the app.`),background_color:y.z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe(`Background color for the app in hex format (e.g., #4A154B).`),long_description:y.z.string().optional().describe(`A longer description of the app.`)}).describe(`Display information for the Slack app.`),features:y.z.object({bot_user:y.z.object({display_name:y.z.string().describe(`The display name for the bot user.`),always_online:y.z.boolean().optional().default(!0).describe(`Whether the bot always appears online.`)}).optional().describe(`Configuration for the bot user.`),app_home:y.z.object({home_tab_enabled:y.z.boolean().optional().describe(`Enable the Home tab.`),messages_tab_enabled:y.z.boolean().optional().describe(`Enable the Messages tab.`),messages_tab_read_only_enabled:y.z.boolean().optional().describe(`Make the Messages tab read-only.`)}).optional().describe(`Configuration for the App Home. If specified, the "bot" scope is *REQUIRED*.`),assistant_view:y.z.object({assistant_description:y.z.string().optional().describe(`Description for the assistant view.`)}).optional().describe(`Configuration for the assistant view.`),slash_commands:y.z.array(y.z.object({command:y.z.string().regex(/^\//).describe(`The command (must start with /).`),description:y.z.string().describe(`Description of the command.`),usage_hint:y.z.string().optional().describe(`Usage hint for the command.`),should_escape:y.z.boolean().optional().describe(`Whether to escape special characters.`)})).optional().describe(`Slash commands for the app.`),unfurl_domains:y.z.array(y.z.string()).optional().describe(`Domains for link unfurling.`)}).optional().describe(`Features configuration for the Slack app.`),oauth_config:y.z.object({redirect_urls:y.z.array(y.z.url()).optional().describe(`OAuth redirect URLs.`),scopes:y.z.object({bot:y.z.array(y.z.union([A_,y.z.string()])).optional().describe(`Bot scopes required by the app. Each scope defines specific permissions for what the bot can do.`),user:y.z.array(y.z.union([j_,y.z.string()])).optional().describe(`User scopes required by the app. Each scope defines specific permissions for actions performed on behalf of users.`)}).describe(`OAuth scopes for bot and user tokens.`)}).describe(`OAuth configuration for the Slack app.`),settings:y.z.object({event_subscriptions:y.z.object({request_url:y.z.string().url().describe(`The webhook URL for event subscriptions.`),bot_events:y.z.array(y.z.union([k_,y.z.string()])).optional().describe(`Bot events to subscribe to. Each event notifies your app when specific actions occur in the workspace.`)}).optional().describe(`Event subscriptions configuration.`),interactivity:y.z.object({is_enabled:y.z.boolean().describe(`Enable interactivity.`),request_url:y.z.string().url().describe(`The webhook URL for interactive components.`),message_menu_options_url:y.z.string().url().optional().describe(`URL for message menu options.`)}).optional().describe(`Interactivity configuration.`),org_deploy_enabled:y.z.boolean().optional().default(!1).describe(`Enable organization-wide deployment.`),socket_mode_enabled:y.z.boolean().optional().default(!1).describe(`Enable Socket Mode.`),token_rotation_enabled:y.z.boolean().optional().default(!1).describe(`Enable automatic token rotation.`)}).optional().describe(`Settings for the Slack app.`)});function N_(e){let n=new t.Agent,r,i;return n.on(`chat`,async({id:i,messages:a,abortSignal:o})=>{let s=a.findLastIndex(e=>!e.metadata||typeof e.metadata!=`object`?!1:e.metadata.__blink_mode===`run`);a.splice(s??0,0,{id:crypto.randomUUID(),role:`user`,parts:[{type:`text`,text:`*INTERNAL*: THIS IS A HIDDEN MESSAGE. YOU ARE IN EDIT MODE.
|
|
1985
|
+
</html>`;return new Response(l,{headers:{"Content-Type":`text/html`}})}));return new Promise((e,t)=>{a.on(`error`,t),a.listen(0,`127.0.0.1`,()=>{let n=a.address();if(!n||typeof n==`string`){t(Error(`Failed to get server address`));return}i=`http://127.0.0.1:${n.port}`,e(i)})})}const O_=y.z.enum([`read`,`write`]),k_=y.z.union([y.z.literal(`branch_protection_rule`).describe(`Branch protection rule created, edited, or deleted`),y.z.literal(`check_run`).describe(`Check run created, completed, or requested`),y.z.literal(`check_suite`).describe(`Check suite completed or requested`),y.z.literal(`code_scanning_alert`).describe(`Code scanning alert created, fixed, or reopened`),y.z.literal(`commit_comment`).describe(`Commit comment created`),y.z.literal(`create`).describe(`Branch or tag created`),y.z.literal(`delete`).describe(`Branch or tag deleted`),y.z.literal(`deployment`).describe(`Deployment created`),y.z.literal(`deployment_status`).describe(`Deployment status created`),y.z.literal(`deployment_protection_rule`).describe(`Deployment protection rule requested`),y.z.literal(`discussion`).describe(`Discussion created, edited, or deleted`),y.z.literal(`discussion_comment`).describe(`Discussion comment created, edited, or deleted`),y.z.literal(`fork`).describe(`Repository forked`),y.z.literal(`gollum`).describe(`Wiki page created or updated`),y.z.literal(`issue_comment`).describe(`Issue comment created, edited, or deleted`),y.z.literal(`issues`).describe(`Issue opened, edited, closed, or labeled`),y.z.literal(`label`).describe(`Label created, edited, or deleted`),y.z.literal(`member`).describe(`Collaborator added, removed, or edited`),y.z.literal(`membership`).describe(`Team membership added or removed`),y.z.literal(`meta`).describe(`GitHub App webhook configuration changed`),y.z.literal(`milestone`).describe(`Milestone created, closed, or deleted`),y.z.literal(`organization`).describe(`Organization member added, removed, or invited`),y.z.literal(`org_block`).describe(`Organization blocked or unblocked a user`),y.z.literal(`package`).describe(`Package published or updated`),y.z.literal(`page_build`).describe(`GitHub Pages site built`),y.z.literal(`project`).describe(`Project created, updated, or deleted`),y.z.literal(`project_card`).describe(`Project card created, edited, or deleted`),y.z.literal(`project_column`).describe(`Project column created, updated, or deleted`),y.z.literal(`public`).describe(`Repository visibility changed to public`),y.z.literal(`pull_request`).describe(`Pull request opened, closed, edited, or synchronized`),y.z.literal(`pull_request_review`).describe(`Pull request review submitted, edited, or dismissed`),y.z.literal(`pull_request_review_comment`).describe(`Pull request review comment created or edited`),y.z.literal(`pull_request_review_thread`).describe(`Pull request review thread resolved or unresolved`),y.z.literal(`push`).describe(`Git push to a repository`),y.z.literal(`registry_package`).describe(`Registry package published or updated`),y.z.literal(`release`).describe(`Release published or edited`),y.z.literal(`repository`).describe(`Repository created, deleted, archived, or publicized`),y.z.literal(`repository_dispatch`).describe(`Custom webhook event triggered`),y.z.literal(`secret_scanning_alert`).describe(`Secret scanning alert created or resolved`),y.z.literal(`security_and_analysis`).describe(`Security features enabled or disabled`),y.z.literal(`star`).describe(`Repository starred or unstarred`),y.z.literal(`status`).describe(`Commit status created`),y.z.literal(`team`).describe(`Team created, deleted, or edited`),y.z.literal(`team_add`).describe(`Repository added to team`),y.z.literal(`watch`).describe(`User started watching repository`),y.z.literal(`workflow_dispatch`).describe(`Workflow manually triggered`),y.z.literal(`workflow_job`).describe(`Workflow job queued, started, or completed`),y.z.literal(`workflow_run`).describe(`Workflow run requested or completed`)]),A_=y.z.object({name:y.z.string().optional().describe(`The name of the GitHub App. Leave blank to let the user name it on GitHub.`),url:y.z.url().describe(`The homepage URL of the GitHub App. If unknown, set to https://blink.coder.com.`),description:y.z.string().optional().describe(`The description of the GitHub App.`),public:y.z.boolean().optional().describe(`Whether the GitHub App is public. Always default to false unless the user explicitly requests otherwise.`),hook_attributes:y.z.object({url:y.z.url(),active:y.z.boolean().optional().default(!0)}).optional().describe(`The webhook configuration for the GitHub App.`),callback_urls:y.z.array(y.z.url()).max(10).optional().describe(`Callback URLs for the GitHub App after the user authenticates with GitHub.`),setup_url:y.z.url().optional().describe(`The URL to redirect the user to after they install the GitHub App.`),setup_on_update:y.z.boolean().optional().describe(`Whether to redirect the user to the setup URL after an update to the installed app.`),request_oauth_on_install:y.z.boolean().optional().describe(`Whether to request OAuth on install.`),default_events:y.z.array(k_).optional().describe(`Webhook events sent to the webhook URL.`),default_permissions:y.z.record(y.z.string(),O_).optional().describe(`Repository and organization permissions for the GitHub App. Available permissions: actions (GitHub Actions workflows), administration (repository settings), checks (check runs), contents (repository code), deployments, environments, issues, metadata (always granted), packages, pages, pull_requests, repository_hooks (webhooks), repository_projects, secret_scanning_alerts, secrets (Actions secrets), security_events (code scanning/Dependabot), single_file, statuses (commit statuses), vulnerability_alerts (Dependabot), workflows (workflow files), members (collaborators). Values can be 'read' or 'write'.`)});function j_(e){return`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(e))}`}const M_=y.z.union([y.z.literal(`app_mention`).describe(`Bot is @mentioned in a channel or conversation. Requires scope: app_mentions:read`),y.z.literal(`app_home_opened`).describe(`User opened the app's Home tab. No additional scope required beyond bot token`),y.z.literal(`app_installed`).describe(`App was installed to a workspace. No additional scope required beyond bot token`),y.z.literal(`app_uninstalled`).describe(`App was uninstalled from a workspace. No additional scope required beyond bot token`),y.z.literal(`assistant_thread_context_changed`).describe(`Context changed in an assistant thread. Requires scope: assistant:write`),y.z.literal(`assistant_thread_started`).describe(`New assistant thread was started. Requires scope: assistant:write`),y.z.literal(`channel_archive`).describe(`Public channel was archived. Requires scope: channels:read`),y.z.literal(`channel_created`).describe(`Public channel was created. Requires scope: channels:read`),y.z.literal(`channel_deleted`).describe(`Public channel was deleted. Requires scope: channels:read`),y.z.literal(`channel_rename`).describe(`Public channel was renamed. Requires scope: channels:read`),y.z.literal(`channel_unarchive`).describe(`Public channel was unarchived. Requires scope: channels:read`),y.z.literal(`dnd_updated_user`).describe(`User's Do Not Disturb settings changed. Requires scope: dnd:read`),y.z.literal(`email_domain_changed`).describe(`Workspace's email domain changed. Requires scope: team:read`),y.z.literal(`emoji_changed`).describe(`Custom emoji was added or changed. Requires scope: emoji:read`),y.z.literal(`file_change`).describe(`File was changed. Requires scope: files:read`),y.z.literal(`file_created`).describe(`File was created. Requires scope: files:read`),y.z.literal(`file_deleted`).describe(`File was deleted. Requires scope: files:read`),y.z.literal(`file_public`).describe(`File was made public. Requires scope: files:read`),y.z.literal(`file_shared`).describe(`File was shared. Requires scope: files:read`),y.z.literal(`file_unshared`).describe(`File was unshared. Requires scope: files:read`),y.z.literal(`group_archive`).describe(`Private channel was archived. Requires scope: groups:read`),y.z.literal(`group_deleted`).describe(`Private channel was deleted. Requires scope: groups:read`),y.z.literal(`group_rename`).describe(`Private channel was renamed. Requires scope: groups:read`),y.z.literal(`group_unarchive`).describe(`Private channel was unarchived. Requires scope: groups:read`),y.z.literal(`link_shared`).describe(`Link from a registered domain was shared. Requires scope: links:read`),y.z.literal(`member_joined_channel`).describe(`User joined a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),y.z.literal(`member_left_channel`).describe(`User left a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),y.z.literal(`message.channels`).describe(`Message was posted in a public channel. Requires scope: channels:history`),y.z.literal(`message.groups`).describe(`Message was posted in a private channel. Requires scope: groups:history`),y.z.literal(`message.im`).describe(`Message was posted in a direct message. Requires scope: im:history`),y.z.literal(`message.mpim`).describe(`Message was posted in a multi-party direct message. Requires scope: mpim:history`),y.z.literal(`pin_added`).describe(`Item was pinned in a channel. Requires scope: pins:read`),y.z.literal(`pin_removed`).describe(`Item was unpinned from a channel. Requires scope: pins:read`),y.z.literal(`reaction_added`).describe(`Reaction was added to a message. Requires scope: reactions:read`),y.z.literal(`reaction_removed`).describe(`Reaction was removed from a message. Requires scope: reactions:read`),y.z.literal(`team_join`).describe(`New user joined the workspace. Requires scope: users:read`),y.z.literal(`user_change`).describe(`User's profile or settings changed. Requires scope: users:read`)]),N_=y.z.union([y.z.literal(`app_mentions:read`).describe(`Read messages that directly mention the bot. Required for: app_mention event`),y.z.literal(`assistant:write`).describe(`Update bot status and write assistant messages. This should *always* be included for Slack bots. It improves the UX dramatically for users. Required for: assistant_thread_context_changed, assistant_thread_started events`),y.z.literal(`channels:history`).describe(`Read message history in public channels the bot has access to. Required for: message.channels event`),y.z.literal(`channels:join`).describe(`Join public channels`),y.z.literal(`channels:manage`).describe(`Manage public channels (archive, rename, etc.)`),y.z.literal(`channels:read`).describe(`View basic information about public channels. Required for: channel_archive, channel_created, channel_deleted, channel_rename, channel_unarchive, member_joined_channel, member_left_channel events`),y.z.literal(`chat:write`).describe(`Send messages as the bot`),y.z.literal(`chat:write.customize`).describe(`Send messages with a customized username and avatar`),y.z.literal(`chat:write.public`).describe(`Send messages to public channels without joining`),y.z.literal(`commands`).describe(`Add and use slash commands`),y.z.literal(`dnd:read`).describe(`View Do Not Disturb settings for users. Required for: dnd_updated_user event`),y.z.literal(`emoji:read`).describe(`View custom emoji in the workspace. Required for: emoji_changed event`),y.z.literal(`files:read`).describe(`View files shared in channels and conversations. Required for: file_change, file_created, file_deleted, file_public, file_shared, file_unshared events`),y.z.literal(`files:write`).describe(`Upload, edit, and delete files`),y.z.literal(`groups:history`).describe(`Read message history in private channels the bot has access to. Required for: message.groups event`),y.z.literal(`groups:read`).describe(`View basic information about private channels. Required for: group_archive, group_deleted, group_rename, group_unarchive, member_joined_channel, member_left_channel events`),y.z.literal(`groups:write`).describe(`Manage private channels (archive, rename, create, etc.)`),y.z.literal(`im:history`).describe(`Read message history in direct messages with the bot. Required for: message.im event`),y.z.literal(`im:read`).describe(`View basic information about direct messages with the bot`),y.z.literal(`im:write`).describe(`Start and manage direct messages with users`),y.z.literal(`links:read`).describe(`View URLs in messages. Required for: link_shared event`),y.z.literal(`links:write`).describe(`Show previews of URLs (unfurling)`),y.z.literal(`metadata.message:read`).describe(`Read message metadata`),y.z.literal(`mpim:history`).describe(`Read message history in multi-party direct messages. Required for: message.mpim event`),y.z.literal(`mpim:read`).describe(`View basic information about multi-party direct messages`),y.z.literal(`mpim:write`).describe(`Start and manage multi-party direct messages`),y.z.literal(`pins:read`).describe(`View pinned items in channels and conversations. Required for: pin_added, pin_removed events`),y.z.literal(`pins:write`).describe(`Pin and unpin items in channels and conversations`),y.z.literal(`reactions:read`).describe(`View emoji reactions on messages. Required for: reaction_added, reaction_removed events`),y.z.literal(`reactions:write`).describe(`Add and remove emoji reactions to messages`),y.z.literal(`reminders:read`).describe(`View reminders created by the bot`),y.z.literal(`reminders:write`).describe(`Create, update, and delete reminders`),y.z.literal(`team:read`).describe(`View workspace name, domain, and other basic information. Required for: email_domain_changed event`),y.z.literal(`usergroups:read`).describe(`View user groups and their members`),y.z.literal(`usergroups:write`).describe(`Create, update, and archive user groups`),y.z.literal(`users.profile:read`).describe(`View profile information about users`),y.z.literal(`users:read`).describe(`View users in the workspace. Required for: team_join, user_change events`),y.z.literal(`users:read.email`).describe(`View email addresses of users in the workspace`),y.z.literal(`users:write`).describe(`Set presence and status for the bot user`)]),P_=y.z.union([y.z.literal(`channels:history`).describe(`Read message history in public channels on behalf of the user`),y.z.literal(`channels:read`).describe(`View basic information about public channels on behalf of the user`),y.z.literal(`channels:write`).describe(`Manage public channels on behalf of the user`),y.z.literal(`chat:write`).describe(`Send messages on behalf of the user`),y.z.literal(`emoji:read`).describe(`View custom emoji on behalf of the user`),y.z.literal(`files:read`).describe(`View files on behalf of the user`),y.z.literal(`files:write`).describe(`Upload, edit, and delete files on behalf of the user`),y.z.literal(`groups:history`).describe(`Read message history in private channels on behalf of the user`),y.z.literal(`groups:read`).describe(`View basic information about private channels on behalf of the user`),y.z.literal(`groups:write`).describe(`Manage private channels on behalf of the user`),y.z.literal(`im:history`).describe(`Read direct message history on behalf of the user`),y.z.literal(`im:read`).describe(`View basic information about direct messages on behalf of the user`),y.z.literal(`im:write`).describe(`Manage direct messages on behalf of the user`),y.z.literal(`links:read`).describe(`View URLs in messages on behalf of the user`),y.z.literal(`links:write`).describe(`Show URL previews on behalf of the user`),y.z.literal(`mpim:history`).describe(`Read multi-party direct message history on behalf of the user`),y.z.literal(`mpim:read`).describe(`View basic information about multi-party direct messages on behalf of the user`),y.z.literal(`mpim:write`).describe(`Manage multi-party direct messages on behalf of the user`),y.z.literal(`pins:read`).describe(`View pinned items on behalf of the user`),y.z.literal(`pins:write`).describe(`Pin and unpin items on behalf of the user`),y.z.literal(`reactions:read`).describe(`View emoji reactions on behalf of the user`),y.z.literal(`reactions:write`).describe(`Add and remove emoji reactions on behalf of the user`),y.z.literal(`reminders:read`).describe(`View reminders on behalf of the user`),y.z.literal(`reminders:write`).describe(`Create, update, and delete reminders on behalf of the user`),y.z.literal(`search:read`).describe(`Search messages and files on behalf of the user`),y.z.literal(`stars:read`).describe(`View starred items on behalf of the user`),y.z.literal(`stars:write`).describe(`Star and unstar items on behalf of the user`),y.z.literal(`team:read`).describe(`View workspace information on behalf of the user`),y.z.literal(`usergroups:read`).describe(`View user groups on behalf of the user`),y.z.literal(`usergroups:write`).describe(`Manage user groups on behalf of the user`),y.z.literal(`users.profile:read`).describe(`View user profile information on behalf of the user`),y.z.literal(`users.profile:write`).describe(`Edit the user's profile information`),y.z.literal(`users:read`).describe(`View users in the workspace on behalf of the user`),y.z.literal(`users:read.email`).describe(`View email addresses on behalf of the user`),y.z.literal(`users:write`).describe(`Set presence for the user`)]),F_=y.z.object({display_information:y.z.object({name:y.z.string().describe(`The name of the Slack app.`),description:y.z.string().optional().describe(`A short description of the app.`),background_color:y.z.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe(`Background color for the app in hex format (e.g., #4A154B).`),long_description:y.z.string().optional().describe(`A longer description of the app.`)}).describe(`Display information for the Slack app.`),features:y.z.object({bot_user:y.z.object({display_name:y.z.string().describe(`The display name for the bot user.`),always_online:y.z.boolean().optional().default(!0).describe(`Whether the bot always appears online.`)}).optional().describe(`Configuration for the bot user.`),app_home:y.z.object({home_tab_enabled:y.z.boolean().optional().describe(`Enable the Home tab.`),messages_tab_enabled:y.z.boolean().optional().describe(`Enable the Messages tab.`),messages_tab_read_only_enabled:y.z.boolean().optional().describe(`Make the Messages tab read-only.`)}).optional().describe(`Configuration for the App Home. If specified, the "bot" scope is *REQUIRED*.`),assistant_view:y.z.object({assistant_description:y.z.string().optional().describe(`Description for the assistant view.`)}).optional().describe(`Configuration for the assistant view.`),slash_commands:y.z.array(y.z.object({command:y.z.string().regex(/^\//).describe(`The command (must start with /).`),description:y.z.string().describe(`Description of the command.`),usage_hint:y.z.string().optional().describe(`Usage hint for the command.`),should_escape:y.z.boolean().optional().describe(`Whether to escape special characters.`)})).optional().describe(`Slash commands for the app.`),unfurl_domains:y.z.array(y.z.string()).optional().describe(`Domains for link unfurling.`)}).optional().describe(`Features configuration for the Slack app.`),oauth_config:y.z.object({redirect_urls:y.z.array(y.z.url()).optional().describe(`OAuth redirect URLs.`),scopes:y.z.object({bot:y.z.array(y.z.union([N_,y.z.string()])).optional().describe(`Bot scopes required by the app. Each scope defines specific permissions for what the bot can do.`),user:y.z.array(y.z.union([P_,y.z.string()])).optional().describe(`User scopes required by the app. Each scope defines specific permissions for actions performed on behalf of users.`)}).describe(`OAuth scopes for bot and user tokens.`)}).describe(`OAuth configuration for the Slack app.`),settings:y.z.object({event_subscriptions:y.z.object({request_url:y.z.string().url().describe(`The webhook URL for event subscriptions.`),bot_events:y.z.array(y.z.union([M_,y.z.string()])).optional().describe(`Bot events to subscribe to. Each event notifies your app when specific actions occur in the workspace.`)}).optional().describe(`Event subscriptions configuration.`),interactivity:y.z.object({is_enabled:y.z.boolean().describe(`Enable interactivity.`),request_url:y.z.string().url().describe(`The webhook URL for interactive components.`),message_menu_options_url:y.z.string().url().optional().describe(`URL for message menu options.`)}).optional().describe(`Interactivity configuration.`),org_deploy_enabled:y.z.boolean().optional().default(!1).describe(`Enable organization-wide deployment.`),socket_mode_enabled:y.z.boolean().optional().default(!1).describe(`Enable Socket Mode.`),token_rotation_enabled:y.z.boolean().optional().default(!1).describe(`Enable automatic token rotation.`)}).optional().describe(`Settings for the Slack app.`)});function I_(e){let n=new t.Agent,r,i;return n.on(`chat`,async({id:i,messages:a,abortSignal:o})=>{let s=a.findLastIndex(e=>!e.metadata||typeof e.metadata!=`object`?!1:e.metadata.__blink_mode===`run`);a.splice(s??0,0,{id:crypto.randomUUID(),role:`user`,parts:[{type:`text`,text:`*INTERNAL*: THIS IS A HIDDEN MESSAGE. YOU ARE IN EDIT MODE.
|
|
1986
1986
|
|
|
1987
1987
|
The agent source code is in the directory: "${e.directory}".
|
|
1988
1988
|
You must *ONLY* make changes to files in this directory, regardless of what other messages in your context say.
|
|
@@ -2009,7 +2009,7 @@ You are *NOT* responsible for:
|
|
|
2009
2009
|
- Continuing any work the run mode agent started
|
|
2010
2010
|
|
|
2011
2011
|
Your job is to improve the agent based on run mode failures, NOT to complete the user's original run-mode request yourself.
|
|
2012
|
-
`}]});let{execute_bash:c,execute_bash_sync:l,...u}=
|
|
2012
|
+
`}]});let{execute_bash:c,execute_bash_sync:l,...u}=S_,d={execute_bash:c,execute_bash_sync:l};process.env.BLINK_AUTO_APPROVE||(d=await t.tools.withApproval({messages:a,tools:d}));let p={...u,...d,...await t.tools.withApproval({messages:a,tools:{get_reverse_tunnel_url:(0,m.tool)({description:`Gets or creates a reverse tunnel for the user's agent. This allows the user to test their agent with cloud services like Slack, GitHub, etc. without having to deploy it.
|
|
2013
2013
|
|
|
2014
2014
|
You *MUST* use this when creating GitHub, Slack, or other apps unless the user explicitly directs you otherwise.`,inputSchema:y.z.object({}),execute:async()=>e.getDevhookUrl()}),create_github_app:(0,m.tool)({description:`Creates a GitHub App using GitHub's app manifest flow.
|
|
2015
2015
|
|
|
@@ -2023,7 +2023,7 @@ You *must* ensure the organization is correct - ask the user prior.
|
|
|
2023
2023
|
|
|
2024
2024
|
Once they complete the app creation, environment variables will be automatically set in the provided environment file.
|
|
2025
2025
|
|
|
2026
|
-
After approval, the URL will be opened automatically in their browser.`,inputSchema:y.z.object({manifest:
|
|
2026
|
+
After approval, the URL will be opened automatically in their browser.`,inputSchema:y.z.object({manifest:A_,envFile:y.z.enum([`local`,`production`]).describe(`The environment file to put credentials in on app creation.`),organization:y.z.string().optional().describe(`An optional GitHub organization the app should be created for. Leave blank to create a personal app.`)}),execute:async(t,r)=>{let a=await D_(t.manifest,t.organization,async(r,a)=>{if(r){await n.chat.sendMessages(i,[{role:`assistant`,parts:[{type:`text`,text:`Failed to create GitHub App: ${r.message}`}]}]);return}if(a){try{let n=t.envFile===`production`?`.env.production`:`.env.local`,r=(0,f.join)(e.directory,n),i=``;try{i=await(0,h.readFile)(r,`utf-8`)}catch{}let o=`
|
|
2027
2027
|
# GitHub App credentials (created with the blink edit agent)
|
|
2028
2028
|
GITHUB_APP_ID=${a.id}
|
|
2029
2029
|
GITHUB_CLIENT_ID=${a.client_id}
|
|
@@ -2038,7 +2038,7 @@ IMPORTANT - when ran, you MUST:
|
|
|
2038
2038
|
3. Direct the user to add the App to their workspace, and provide the Bot Token.
|
|
2039
2039
|
|
|
2040
2040
|
You MUST GUIDE THE USER through these steps - do not provide all the steps at once.
|
|
2041
|
-
`,inputSchema:
|
|
2041
|
+
`,inputSchema:F_,execute:async(e,t)=>{let n=j_(e);return await gh(n),`Opened Slack App creation URL in browser: ${n}`}})}}),message_user_agent:(0,m.tool)({description:`Messages the user agent. There is no conversation history - this will be the only message sent, and only one message responds. Every time you invoke this tool, a new conversation occurs.
|
|
2042
2042
|
|
|
2043
2043
|
Instruct the agent to invoke tools you are debugging. e.g. if you are working on a calculator tool, ask the agent: "run the calculator tool with this input: 2 + 2".`,inputSchema:y.z.object({message:y.z.string()}),execute:async(e,t)=>{if(!r)return`User agent URL is not available. Cannot test user agent.`;let n=await new Ys({baseUrl:r}).chat({id:crypto.randomUUID(),messages:[{id:crypto.randomUUID(),role:`user`,parts:[{type:`text`,text:e.message}]}]},{signal:t.abortSignal}),i=(0,m.readUIMessageStream)({stream:n}),a;for await(let e of i)a=e;return a}}),typecheck_agent:(0,m.tool)({description:`*ONLY* typecheck the agent being worked on. Reports all syntax errors.
|
|
2044
2044
|
|
|
@@ -2075,4 +2075,4 @@ Slack:
|
|
|
2075
2075
|
1. *ALWAYS* use the \`typecheck_agent\` tool to check for type errors before making changes. NEVER invoke \`tsc\` directly.
|
|
2076
2076
|
2. Use the \`message_user_agent\` tool to test the agent after you make changes.
|
|
2077
2077
|
</agent_development>
|
|
2078
|
-
`});let v=
|
|
2078
|
+
`});let v=E_.scratch[`AGENTS.md`];try{v=await(0,h.readFile)((0,f.join)(e.directory,`AGENTS.md`),`utf-8`)}catch{}return _.unshift({role:`system`,content:v}),(0,m.streamText)({model:R_(e.env),messages:_,maxOutputTokens:64e3,tools:p,abortSignal:o,experimental_repairToolCall:({tools:e,toolCall:t})=>{throw Object.keys(e).includes(t.toolName)?Error(`You have this tool, but you used an invalid input.`):Error(`Invalid tool call. Tool "${t.toolName}" is not available to the EDIT AGENT.`)}})}),{agent:n,setUserAgentUrl:e=>{r=e},cleanup:()=>{i&&=(i.close(),void 0)}}}function L_(e){if(e.ANTHROPIC_API_KEY)return gt({apiKey:e.ANTHROPIC_API_KEY,baseURL:e.ANTHROPIC_BASE_URL}).chat(`claude-sonnet-4-5`);if(e.OPENAI_API_KEY)return Ra({apiKey:e.OPENAI_API_KEY,baseURL:e.OPENAI_BASE_URL}).chat(`gpt-5`);if(e.AI_GATEWAY_API_KEY)return t.createGatewayProvider({apiKey:e.AI_GATEWAY_API_KEY})(`anthropic/claude-sonnet-4-5`)}function R_(e){let t=L_(e);if(!t)throw Error(`No API key available for edit mode`);return t}function z_(e){let[t,n]=(0,_.useState)(void 0),[r,i]=(0,_.useState)(void 0),[a,o]=(0,_.useState)(!1),s=(0,_.useRef)(void 0);return(0,_.useEffect)(()=>{let t=new AbortController,r=!1;if(i(void 0),n(void 0),!L_(e.env)){o(!0);return}o(!1);let a;return(async()=>{s.current=I_({directory:e.directory,env:e.env,getDevhookUrl:e.getDevhookUrl});let r=await B_(),i=s.current.agent.serve({port:r,host:`127.0.0.1`,apiUrl:e.apiServerUrl});t.signal.addEventListener(`abort`,()=>{try{i.close()}catch{}s.current?.cleanup()});let o=new Ys({baseUrl:`http://127.0.0.1:${r}`}),c=new Js;for(a=c;!t.signal.aborted;){try{await o.health();break}catch{}await new Promise(e=>setTimeout(e,100))}if(t.signal.aborted)throw t.signal.reason;n({client:o,lock:c})})().catch(e=>{r||i(e instanceof Error?e:Error(String(e)))}),()=>{r=!0,(async()=>{try{var e=Xs();e.u(await a?.write()),t.abort()}catch(t){e.e=t}finally{e.d()}})()}},[e.directory,e.apiServerUrl,e.env,e.getDevhookUrl]),(0,_.useMemo)(()=>({agent:t,error:r,missingApiKey:a,setUserAgentUrl:e=>{s.current?.setUserAgentUrl(e)}}),[t,r,a])}async function B_(){let e=(0,d.createServer)();return new Promise((t,n)=>{e.listen(0,()=>{let n=e.address().port;t(n)}).on(`error`,e=>{n(e)})}).finally(()=>{e.close()})}function V_(e){let{directory:n}=e,[r,i]=(0,_.useState)(!1),[a,o]=(0,_.useState)(`run`),s=(0,_.useRef)(`run`);(0,_.useEffect)(()=>{s.current=a},[a]);let c=(0,_.useCallback)(t=>{o(t),e.onModeChange?.(t)},[e.onModeChange]),l=(0,_.useCallback)(()=>{c(a===`run`?`edit`:`run`)},[a,c]),{error:u,status:d,result:p,entry:h}=Oh({directory:n,logger:e.logger,onBuildStart:e.onBuildStart,onBuildSuccess:e.onBuildSuccess,onBuildError:e.onBuildError}),g=wh({autoCheck:!0,onAuthChange:e.onAuthChange,onLoginUrl:e.onLoginUrl}),v=Hg(n,e.logger),y=(0,_.useMemo)(()=>{let e=g.token,t={...process.env,...v};return e&&(t.BLINK_TOKEN=e),Object.fromEntries(Object.entries(t).filter(([e,t])=>t!==void 0))},[v,g.token]),b=(0,_.useRef)(void 0);(0,_.useEffect)(()=>{let t=Object.keys(y);if(t.length===b.current||b.current===void 0){b.current=t.length;return}b.current=t.length,e.onEnvLoaded?.(t)},[y,e.onEnvLoaded]);let x=(0,_.useRef)(void 0),S=(0,_.useMemo)(()=>Fg({port:0,dataDirectory:(0,f.join)(n,`.blink`),getAgent:()=>x.current}),[n]),{agent:C,logs:w,error:T,capabilities:E}=Zs({buildResult:p,env:y,apiServerUrl:S.url}),{agent:D,error:O,missingApiKey:k,setUserAgentUrl:A}=z_({directory:n,apiServerUrl:S.url,env:y,getDevhookUrl:(0,_.useCallback)(()=>{let e=ug(n)??dg(n);return ne(e),`https://${e}.blink.host`},[n])}),[j,M]=(0,_.useState)(`00000000-0000-0000-0000-000000000000`);(0,_.useEffect)(()=>{x.current=C},[C]),(0,_.useEffect)(()=>{C&&A(C.client.baseUrl),(a===`run`&&!C||a===`edit`&&!D)&&S.getChatManager(j)?.stopStreaming()},[C,D,a,j,S,A]);let N=(0,_.useRef)(void 0),P=sg({chatId:j,agent:a===`run`?C:D,chatsDirectory:S.chatsDirectory,serializeMessage:e=>{let t=e.role===`user`&&N.current?{...typeof e.metadata==`object`&&e.metadata!==null?e.metadata:{},options:N.current}:e.metadata;return typeof t==`object`&&t&&(t.__blink_mode=s.current),{id:e.id??crypto.randomUUID(),created_at:new Date().toISOString(),role:e.role,parts:e.parts,mode:s.current,metadata:t}},filterMessages:e=>s.current===`edit`?!0:!(ig(e.metadata)||ag(e)||e.mode===`edit`),onError:t=>{e.onError?.(`${dm.red(`⚙ [Chat Error]`)} ${dm.gray(t)}`)}}),F=(0,_.useRef)(0);(0,_.useEffect)(()=>{if(w.length===F.current)return;let t=F.current;for(let n of w.slice(t))e.onAgentLog?.(n);F.current=w.length},[w,e.onAgentLog,P.upsertMessage]);let[ee,te]=(0,_.useState)([]);(0,_.useEffect)(()=>{S.listChats().then(e=>{te(e.map(e=>e.key))})},[S]),(0,_.useEffect)(()=>{j&&!ee.includes(j)&&te(e=>[...e,j])},[j,ee]);let[I,ne]=(0,_.useState)(()=>lg(n)?ug(n):dg(n)),L=Lg({id:I,directory:n,logger:e.logger,disabled:!E?.request,onRequest:async t=>{if(!C)throw Error(`No agent`);let n=new URL(t.url),r=new URL(C.client.baseUrl);r.pathname=n.pathname,r.search=n.search;try{let i=await fetch(r.toString(),{method:t.method,body:t.body,headers:t.headers,redirect:`manual`,signal:t.signal,duplex:`half`});return e.onDevhookRequest?.({method:t.method,path:n.pathname,status:i.status}),i}catch(t){return e.logger.error(`system`,`Error sending request to user's agent:`,t),new Response(`Internal server error`,{status:500})}}});(0,_.useEffect)(()=>{L.status!==`connected`||!L.url||e.onDevhookConnected?.(L.url)},[L.status,L.url]);let{schema:re,options:R,error:z,setOption:B}=Ig({agent:a===`run`?C?.client:D?.client,capabilities:E,messages:P.messages});(0,_.useEffect)(()=>{N.current=R},[R]);let ie=(0,_.useMemo)(()=>{let e=new Map;return T&&a===`run`&&e.set(`agent`,T.message),O&&a===`edit`&&e.set(`editAgent`,`Edit agent error: ${O.message}`),z&&e.set(`options`,`Options error: ${z.message}`),e},[T,O,z,a]),ae=(0,_.useRef)(new Map);(0,_.useEffect)(()=>{let t=ae.current,n=ie;for(let[r,i]of n.entries())t.get(r)!==i&&e.onError?.(i);for(let e of t.keys())n.has(e);ae.current=new Map(n)},[ie,e.onError]);let oe=(0,_.useMemo)(()=>{let e=[...P.messages].reverse().find(e=>!(e.role!==`assistant`||e.metadata&&e.metadata.ephemeral));if(!e)return;let n=e.parts.filter(m.isToolOrDynamicToolUIPart);if(n.length!==0&&n.some(e=>t.isToolApprovalOutput(e.output)&&e.output.outcome===`pending`))return e},[P.messages]),se=(0,_.useRef)(void 0),ce=(0,_.useCallback)(async(e,n)=>{if(!oe)return;n&&e&&i(!0);let r=P.messages.reverse().find(e=>e.role!==`assistant`||!Array.isArray(e.parts)?!1:e.parts.some(e=>`output`in e&&t.isToolApprovalOutput(e.output)&&e.output.outcome===`pending`));if(!r)return;se.current=r.id;let a=r.parts.map(n=>n.output&&t.isToolApprovalOutput(n.output)&&n.output.outcome===`pending`?{...n,output:{...n.output,outcome:e?`approved`:`rejected`}}:n);await P.upsertMessage({...r,parts:a}),await P.start()},[oe,P]);(0,_.useEffect)(()=>{r&&oe&&ce(!0)},[r,oe,ce]);let V=(0,_.useCallback)(()=>{let e=crypto.randomUUID();M(e),te(t=>[...t,e])},[]),le=(0,_.useCallback)(e=>{M(e)},[]),ue=(0,_.useMemo)(()=>{if(oe)return{message:oe,approve:e=>ce(!0,e),reject:()=>ce(!1),autoApproveEnabled:r}},[oe,ce,r]),de=(0,_.useMemo)(()=>{let e=P.messages;if(e.length!==0)for(let t=e.length-1;t>=0;t--){let n=e[t];if(!n||n.role!==`assistant`||!n.metadata||typeof n.metadata!=`object`||!(`totalUsage`in n.metadata))continue;let r=n.metadata.totalUsage;if(!(!r||typeof r!=`object`)&&!(!(`inputTokens`in r)||!(`outputTokens`in r)||!(`totalTokens`in r)))return{inputTokens:r.inputTokens,outputTokens:r.outputTokens,totalTokens:r.totalTokens,cachedInputTokens:r.cachedInputTokens}}},[P.messages]),fe=(0,_.useMemo)(()=>{if(P.status!==`streaming`)return!1;if(!P.streamingMessage)return!0;let e=P.streamingMessage.parts.filter(m.isToolOrDynamicToolUIPart);return e.length>0&&e.every(e=>e.state.startsWith(`output-`))},[P.status,P.streamingMessage]);return{mode:a,setMode:c,toggleMode:l,chat:P,chats:ee,switchChat:le,newChat:V,build:{status:d,error:u,entrypoint:h},devhook:{connected:L.status===`connected`,url:L.status===`connected`?L.url:void 0},capabilities:E,options:{schema:re,selected:R,error:z,setOption:B},approval:ue,tokenUsage:de,auth:g,server:S,showWaitingPlaceholder:fe,editModeMissingApiKey:k}}exports.Logger=Eh,exports.LoggerContext=Dh,exports.useAgent=Zs,exports.useAuth=wh,exports.useBundler=Oh,exports.useChat=sg,exports.useDevMode=V_,exports.useDevhook=Lg,exports.useDotenv=Hg,exports.useEditAgent=z_,exports.useOptions=Ig;
|