blink 1.1.35 → 1.1.37
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/auth-B7pruQew.js +126 -0
- package/dist/cli/chat-Dza83RvU.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-D_lhQ36A.js +1 -0
- package/dist/cli/connect-C6BJxbG5.js +1 -0
- package/dist/cli/connect-lEKh-OPL.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-oYr5PvLk.js} +71 -71
- 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-Cq-SlOHe.js} +1 -1
- package/dist/cli/{init-templates-jGRvqLQ6.js → init-templates-Br3bKUNT.js} +3 -3
- package/dist/cli/login-DW6LzfRW.js +1 -0
- package/dist/cli/logout-CSXmq3nW.js +1 -0
- package/dist/cli/pull-B0kjDWZn.js +18 -0
- package/dist/cli/run-CY74Ar9q.js +1 -0
- package/dist/cli/setup-github-app-BB-iG8Lx.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-D7HypBza.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 +128 -130
- package/dist/node/react/index.node.d.cts +1 -1
- package/dist/node/react/index.node.d.ts +3 -3
- package/dist/node/react/index.node.js +56 -58
- 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 +8 -2
- 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/dist-Ceoe3h7v.js +0 -85
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{import_websocket as e}from"./wrapper-DRdRnzOz.js";import{getHost as t,openUrl as n,toWsUrl as r}from"./auth-B7pruQew.js";import{WorkspaceConnect as i}from"./connect-lEKh-OPL.js";async function a(){let a=t();if(!a)throw Error("No Blink host configured. Set the BLINK_HOST environment variable or run `blink login <host>`.");let o=r(a),s=crypto.randomUUID(),c=new e.default(`${o}/legacy-auth?id=${s}`);await new Promise((e,t)=>{c.onopen=()=>{e()},c.onerror=e=>{t(e)}});let l=new Promise((e,t)=>{c.onmessage=t=>{e(t.data.toString())}}),u=`${a}/legacy-auth?id=${s}&type=workspace`;console.log(`Opening the following URL in your browser: ${u}`),await n(u);let d=await l,f=new i({url:`${o}/api/connect`,token:d});f.onConnect(()=>{console.log(`Connected to Blink`)}),f.onDisconnect(()=>{console.log(`Disconnected from Blink`)})}export{a as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_usingCtx as e}from"./usingCtx-B1FpoePI.js";import{isAsyncIterable as t}from"./utils-B3iC7vdW.js";import*as n from"node:path";import*as r from"node:fs";import i,{z as a}from"zod/v4";import{ZodFirstPartyTypeKind as o}from"zod/v3";import{stripVTControlCharacters as s}from"node:util";import{convertToModelMessages as c,createUIMessageStream as l,getToolName as u,isToolOrDynamicToolUIPart as d,isToolUIPart as f,readUIMessageStream as p,streamText as m}from"ai";var h=class extends Error{constructor(e,t){super(e),this.response=t}};const g=Object.freeze({withContext(e,t){let n={};for(let r of Object.keys(e))n[r]=e[r].withContext(t);return n},with(e,t){let n={};for(let r of Object.keys(e))n[r]=e[r].withContext(t);return n},async withApproval(e){let n={};for(let[t,r]of Object.entries(e.tools)){let e=r.execute;n[t]={...r,execute:async(t,n)=>r.autoApprove&&e&&await r.autoApprove(t)?e(t,n):{type:`tool-approval`,outcome:`pending`}}}let r=e.messages[e.messages.length-1];if(!r?.parts)return n;let i=[];for(let t of r.parts){if(!f(t))continue;let n=u(t),r=e.tools[n];r&&t.state===`output-available`&&r.execute&&_(t.output)&&t.output.outcome===`approved`&&i.push({toolName:u(t),tool:r,input:t.input,toolCallId:t.toolCallId})}if(i.length>0){let n=l({execute:async({writer:n})=>{n.write({type:`start-step`}),await Promise.all(i.map(async r=>{if(!r.tool.execute)throw Error(`Tool does not support execute.`);n.write({type:`tool-input-available`,toolCallId:r.toolCallId,toolName:r.toolName,input:r.input});try{let i=await r.tool.execute(r.input,{toolCallId:r.toolCallId,messages:c(e.messages,{tools:e.tools}),abortSignal:e.abortSignal}),a=i;if(t(i))for await(let e of i)a=e,n.write({type:`tool-output-available`,toolCallId:r.toolCallId,output:e,preliminary:!0});n.write({type:`tool-output-available`,toolCallId:r.toolCallId,output:a})}catch(e){n.write({type:`tool-output-error`,toolCallId:r.toolCallId,errorText:e instanceof Error?e.message:String(e)})}})),n.write({type:`finish`})}});throw new h(`Executing tools`,n)}return n},prefix(e,t){let n={};for(let[r,i]of Object.entries(e))n[`${t}${r}`]=i;return n}});function _(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`tool-approval`}var v=e=>{let t=e.split(`/`);return t[0]===``&&t.shift(),t},y=e=>{let{groups:t,path:n}=b(e),r=v(n);return x(r,t)},b=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(e,n)=>{let r=`@${n}`;return t.push([r,e]),r}),{groups:t,path:e}},x=(e,t)=>{for(let n=t.length-1;n>=0;n--){let[r]=t[n];for(let i=e.length-1;i>=0;i--)if(e[i].includes(r)){e[i]=e[i].replace(r,t[n][1]);break}}return e},S={},C=(e,t)=>{if(e===`*`)return`*`;let n=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){let r=`${e}#${t}`;return S[r]||(n[2]?S[r]=t&&t[0]!==`:`&&t[0]!==`*`?[r,n[1],RegExp(`^${n[2]}(?=/${t})`)]:[e,n[1],RegExp(`^${n[2]}$`)]:S[r]=[e,n[1],!0]),S[r]}return null},w=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return t(e)}catch{return e}})}},ee=e=>w(e,decodeURI),te=e=>{let t=e.url,n=t.indexOf(`/`,t.indexOf(`:`)+4),r=n;for(;r<t.length;r++){let e=t.charCodeAt(r);if(e===37){let e=t.indexOf(`?`,r),i=t.slice(n,e===-1?void 0:e);return ee(i.includes(`%25`)?i.replace(/%25/g,`%2525`):i)}else if(e===63)break}return t.slice(n,r)},ne=e=>{let t=te(e);return t.length>1&&t.at(-1)===`/`?t.slice(0,-1):t},re=(e,t,...n)=>(n.length&&(t=re(t,...n)),`${e?.[0]===`/`?``:`/`}${e}${t===`/`?``:`${e?.at(-1)===`/`?``:`/`}${t?.[0]===`/`?t.slice(1):t}`}`),ie=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(`:`))return null;let t=e.split(`/`),n=[],r=``;return t.forEach(e=>{if(e!==``&&!/\:/.test(e))r+=`/`+e;else if(/\:/.test(e))if(/\?/.test(e)){n.length===0&&r===``?n.push(`/`):n.push(r);let t=e.replace(`?`,``);r+=`/`+t,n.push(r)}else r+=`/`+e}),n.filter((e,t,n)=>n.indexOf(e)===t)},ae=e=>/[%+]/.test(e)?(e.indexOf(`+`)!==-1&&(e=e.replace(/\+/g,` `)),e.indexOf(`%`)===-1?e:w(e,le)):e,oe=(e,t,n)=>{let r;if(!n&&t&&!/[%+]/.test(t)){let n=e.indexOf(`?${t}`,8);for(n===-1&&(n=e.indexOf(`&${t}`,8));n!==-1;){let r=e.charCodeAt(n+t.length+1);if(r===61){let r=n+t.length+2,i=e.indexOf(`&`,r);return ae(e.slice(r,i===-1?void 0:i))}else if(r==38||isNaN(r))return``;n=e.indexOf(`&${t}`,n+1)}if(r=/[%+]/.test(e),!r)return}let i={};r??=/[%+]/.test(e);let a=e.indexOf(`?`,8);for(;a!==-1;){let t=e.indexOf(`&`,a+1),o=e.indexOf(`=`,a);o>t&&t!==-1&&(o=-1);let s=e.slice(a+1,o===-1?t===-1?void 0:t:o);if(r&&(s=ae(s)),a=t,s===``)continue;let c;o===-1?c=``:(c=e.slice(o+1,t===-1?void 0:t),r&&(c=ae(c))),n?(i[s]&&Array.isArray(i[s])||(i[s]=[]),i[s].push(c)):i[s]??=c}return t?i[t]:i},se=oe,ce=(e,t)=>oe(e,t,!0),le=decodeURIComponent,ue=/^[\w!#$%&'*.^`|~+-]+$/,de=/^[ !#-:<-[\]-~]*$/,fe=(e,t)=>{if(t&&e.indexOf(t)===-1)return{};let n=e.trim().split(`;`),r={};for(let e of n){e=e.trim();let n=e.indexOf(`=`);if(n===-1)continue;let i=e.substring(0,n).trim();if(t&&t!==i||!ue.test(i))continue;let a=e.substring(n+1).trim();if(a.startsWith(`"`)&&a.endsWith(`"`)&&(a=a.slice(1,-1)),de.test(a)&&(r[i]=a.indexOf(`%`)===-1?a:w(a,le),t))break}return r},pe=(e,t,n={})=>{let r=`${e}=${t}`;if(e.startsWith(`__Secure-`)&&!n.secure)throw Error(`__Secure- Cookie must have Secure attributes`);if(e.startsWith(`__Host-`)){if(!n.secure)throw Error(`__Host- Cookie must have Secure attributes`);if(n.path!==`/`)throw Error(`__Host- Cookie must have Path attributes with "/"`);if(n.domain)throw Error(`__Host- Cookie must not have Domain attributes`)}if(n&&typeof n.maxAge==`number`&&n.maxAge>=0){if(n.maxAge>3456e4)throw Error(`Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.`);r+=`; Max-Age=${n.maxAge|0}`}if(n.domain&&n.prefix!==`host`&&(r+=`; Domain=${n.domain}`),n.path&&(r+=`; Path=${n.path}`),n.expires){if(n.expires.getTime()-Date.now()>3456e7)throw Error(`Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.`);r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+=`; HttpOnly`),n.secure&&(r+=`; Secure`),n.sameSite&&(r+=`; SameSite=${n.sameSite.charAt(0).toUpperCase()+n.sameSite.slice(1)}`),n.priority&&(r+=`; Priority=${n.priority.charAt(0).toUpperCase()+n.priority.slice(1)}`),n.partitioned){if(!n.secure)throw Error(`Partitioned Cookie must have Secure attributes`);r+=`; Partitioned`}return r},me=(e,t,n)=>(t=encodeURIComponent(t),pe(e,t,n));function he(){return/[<>:"/\\|?*\u0000-\u001F]|[. ]$/g}function ge(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}const _e=/^\.+(\\|\/)|^\.+$/,ve=/[. ]+$/,ye=/[\p{Control}\p{Format}\p{Zl}\p{Zp}\uFFF0-\uFFFF]/gu,be=/[\p{Control}\p{Format}\p{Zl}\p{Zp}\uFFF0-\uFFFF]/u,xe=e=>e===``,Se=/([<>:"/\\|?*\u0000-\u001F]){2,}/g,Ce=/[\t\n\r\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+/g;let we;function Te(){return we??=new Intl.Segmenter(void 0,{granularity:`grapheme`}),we}function Ee(e,t={}){if(typeof e!=`string`)throw TypeError(`Expected a string`);let n=t.replacement??`!`;if(he().test(n)||[...n].some(e=>be.test(e)&&!xe(e)))throw Error(`Replacement string cannot contain reserved filename characters`);e=e.normalize(`NFC`),e=e.replaceAll(Ce,` `),n.length>0&&(e=e.replaceAll(Se,`$1`)),e=e.replace(ve,``),e=e.replace(_e,n),e=e.replace(he(),n),e=e.replaceAll(ye,e=>xe(e)?e:n),e.length===0&&(e=n),e=ge().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=De(e,r);else{let n=e.slice(0,t),i=e.slice(t),a=Math.max(0,r-i.length);e=De(n,a)+i}}return e}function De(e,t){if(e.length<=t)return e;let n=0,r=``;for(let{segment:i}of Te().segment(e)){let e=n+i.length;if(e>t)break;r+=i,n=e}return r}function Oe(e){return`${e}.lock`}function ke(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function T(e,t={}){let n=Oe(e),i=process.pid.toString();try{return r.writeFileSync(n,i,{flag:`wx`}),!0}catch(i){if(i.code!==`EEXIST`)throw i;if(t.stale===0)return!1;let a;try{a=parseInt(r.readFileSync(n,`utf8`),10)}catch{return r.unlinkSync(n),T(e,{...t,stale:0})}if(!ke(a))try{return r.unlinkSync(n),T(e,{...t,stale:0})}catch(n){if(n.code===`ENOENT`)return T(e,{...t,stale:0});throw n}return!1}}async function Ae(e,t={}){let r={stale:!0,retries:0,retryInterval:100,...t},i=n.resolve(e),a=0;for(;a<=r.retries;){if(T(i,r))return()=>je(i);a<r.retries&&await new Promise(e=>setTimeout(e,r.retryInterval)),a++}let o=Error(`Lock file is already being held`);throw o.code=`ELOCKED`,o.file=i,o}function je(e){let t=n.resolve(e),i=Oe(t);try{if(parseInt(r.readFileSync(i,`utf8`),10)!==process.pid){let e=Error(`Lock is not owned by this process`);throw e.code=`ENOTACQUIRED`,e}r.unlinkSync(i)}catch(e){if(e.code===`ENOENT`){let e=Error(`Lock is not acquired`);throw e.code=`ENOTACQUIRED`,e}throw e}}function Me(e){let t=n.resolve(e),i=Oe(t);try{if(!r.existsSync(i))return{locked:!1};let e=r.readFileSync(i,`utf8`),t=parseInt(e,10);return ke(t)?{locked:!0,pid:t}:{locked:!1}}catch(e){return e.code,{locked:!1}}}const Ne=e=>{r.mkdirSync(e,{recursive:!0})},Pe=e=>{try{r.fdatasyncSync(e)}catch{}try{r.closeSync(e)}catch{}},Fe=e=>{try{let t=r.openSync(e,`r`);try{r.fsyncSync(t)}finally{r.closeSync(t)}}catch{}},Ie=(e,t)=>{let i=n.dirname(e);Ne(i);let a=n.join(i,`.tmp-`+process.pid+`-`+Math.random().toString(36).slice(2)),o;try{o=r.openSync(a,`w`),r.writeFileSync(o,t,`utf-8`),Pe(o),o=void 0,r.renameSync(a,e),Fe(e),Fe(i)}catch(e){if(o!==void 0)try{r.closeSync(o)}catch{}try{r.rmSync(a,{force:!0})}catch{}throw e}},Le=(e,t)=>{let i=new Map,a,o=e=>{if(r.statSync(e,{throwIfNoEntry:!1}))return JSON.parse(r.readFileSync(e,`utf-8`))},s=(e,t)=>{Ie(e,JSON.stringify(t,null,2))},c=async()=>{if(a)throw Error(`Index is already locked`);let t=n.join(e,`index.json`);Ne(e),r.existsSync(t)||r.writeFileSync(t,JSON.stringify({ids:{}}),`utf-8`);let i=await Ae(t,{stale:!0,retries:5,retryInterval:100});return a=()=>Promise.resolve(i()),()=>{i(),a=void 0}},l=async()=>{let t=n.join(e,`index.json`),r=o(t)??{ids:{}};return r.ids||={},r},u=async t=>{let r=n.join(e,`index.json`);s(r,t)},d=async t=>{let r=(await l()).ids[t];if(r)return n.join(e,r)},f=async t=>{let i=(await l()).ids[t];if(!i)return;let a=n.join(e,i);if(r.statSync(a,{throwIfNoEntry:!1}))return JSON.parse(r.readFileSync(a,`utf-8`))},p=async r=>{let i=r[t],a=String(i),o=Ee(a,{replacement:`_`})+`.json`,d=await c();try{let t=await l();t.ids[a]=o,t.current=a;let i=n.join(e,o);s(i,r),await u(t)}finally{await d()}};return{async get(e){return await f(e)},async list(){if(!r.statSync(e,{throwIfNoEntry:!1}))return[];let t=await l(),i=[];for(let[a,o]of Object.entries(t.ids)){let t=n.join(e,o),s=r.statSync(t,{throwIfNoEntry:!1});if(!s)continue;let c=Me(t);i.push({key:a,locked:c.locked,pid:c.pid,mtime:s.mtimeMs})}return i.sort((e,t)=>t.mtime-e.mtime),i},async lock(a,o){if(i.has(a))throw Error(`Key "${a}" is already locked in this process`);let s=await d(a);if(!s){let t=Ee(a,{replacement:`_`})+`.json`,i=await c();try{let i=await l();i.ids[a]=t;let o=n.join(e,t);Ne(e),r.writeFileSync(o,JSON.stringify({}),`utf-8`),await u(i),s=o}finally{await i()}}if(o?.force){let e=Me(s);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 m=await Ae(s,{stale:!0,retries:o?.force?10:5,retryInterval:(o?.force,100)});return i.set(a,()=>Promise.resolve(m())),{async get(){let e=await f(a);if(!e)throw Error(`Key ${a} not found`);return e},async set(e){await p(e)},async update(e){let n=await f(a);if(!n||!(t in n))throw Error(`Key ${a} not found`);await p({...n,...e})},async delete(){let t=await c();try{let t=await l(),i=t.ids[a];if(i){delete t.ids[a],t.current===a&&(t.current=void 0),await u(t);let o=n.join(e,i);try{r.rmSync(o,{force:!0}),Fe(e)}catch{}}}finally{await t()}},async release(){try{m()}finally{i.delete(a)}}}},dispose(){i.clear()}}},Re=(e,t)=>{let i=t?.pollInterval??200,a=t?.debounce??50,o=new Set,s,c,l=new Map,u=new Map,d=n.join(e,`index.json`),f=()=>{try{if(!r.statSync(d,{throwIfNoEntry:!1}))return{ids:{}};let e=r.readFileSync(d,`utf-8`);return{ids:JSON.parse(e).ids??{}}}catch{return{ids:{}}}},p=(e,t,n,r)=>{for(let i of o)try{i({key:e,value:t,locked:n,pid:r})}catch(e){console.error(`Error in onChange callback:`,e)}},m=(t,i,a=!1)=>{let o=n.join(e,i);try{let e=r.statSync(o,{throwIfNoEntry:!1}),n=u.get(i);if(!e){n&&(u.delete(i),p(t,void 0,!1));return}let s=e.mtimeMs,c=n?{locked:n.locked,pid:n.pid}:{locked:!1,pid:void 0};if((a||!n)&&(c=Me(o)),!n||n.mtime!==s||n.locked!==c.locked||n.pid!==c.pid){let e;e=!n||n.mtime!==s?JSON.parse(r.readFileSync(o,`utf-8`)):n.cachedValue,u.set(i,{mtime:s,key:t,locked:c.locked,pid:c.pid,cachedValue:e}),p(t,e,c.locked,c.pid)}}catch{}},h=()=>{try{let e=f(),t=new Set(Object.keys(e.ids));for(let[t,n]of Object.entries(e.ids))m(t,n,!0);for(let[e,n]of u.entries())t.has(n.key)||(u.delete(e),p(n.key,void 0,!1))}catch{}},g=(e,t,n=!1)=>{let r=l.get(e);r&&clearTimeout(r),l.set(e,setTimeout(()=>{l.delete(e),m(e,t,n)},a))},_=()=>{if(s)return;try{r.mkdirSync(e,{recursive:!0})}catch{}s=r.watch(e,(e,t)=>{if(!t||t.startsWith(`.tmp-`))return;if(t===`index.json`){h();return}if(t.endsWith(`.lock`)){let e=t.replace(`.lock`,``),n=f(),r=Object.keys(n.ids).find(t=>n.ids[t]===e);r&&m(r,e,!0);return}let n=f(),r=Object.keys(n.ids).find(e=>n.ids[e]===t);r&&g(r,t,!1)});let t=()=>{h(),c=setTimeout(t,i)};h(),c=setTimeout(t,i)};return{onChange(e){return o.size===0&&_(),o.add(e),()=>{if(o.delete(e),o.size===0){s&&=(s.close(),void 0),c&&=(clearTimeout(c),void 0);for(let e of l.values())clearTimeout(e);l.clear(),u.clear()}}},dispose(){s&&=(s.close(),void 0),c&&=(clearTimeout(c),void 0);for(let e of l.values())clearTimeout(e);l.clear(),o.clear(),u.clear()}}};var ze=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function Be(e){}function Ve(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Be,onError:n=Be,onRetry:r=Be,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=He(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1,i=e.slice(t+r);f(n,i,e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
|
|
1
|
+
import{_usingCtx as e}from"./usingCtx-CCxav2be.js";import{isAsyncIterable as t}from"./utils-BWKsfIcI.js";import*as n from"node:path";import*as r from"node:fs";import i,{z as a}from"zod/v4";import{ZodFirstPartyTypeKind as o}from"zod/v3";import{stripVTControlCharacters as s}from"node:util";import{convertToModelMessages as c,createUIMessageStream as l,getToolName as u,isToolOrDynamicToolUIPart as d,isToolUIPart as f,readUIMessageStream as p,streamText as m}from"ai";var h=class extends Error{constructor(e,t){super(e),this.response=t}};const g=Object.freeze({withContext(e,t){let n={};for(let r of Object.keys(e))n[r]=e[r].withContext(t);return n},with(e,t){let n={};for(let r of Object.keys(e))n[r]=e[r].withContext(t);return n},async withApproval(e){let n={};for(let[t,r]of Object.entries(e.tools)){let e=r.execute;n[t]={...r,execute:async(t,n)=>r.autoApprove&&e&&await r.autoApprove(t)?e(t,n):{type:`tool-approval`,outcome:`pending`}}}let r=e.messages[e.messages.length-1];if(!r?.parts)return n;let i=[];for(let t of r.parts){if(!f(t))continue;let n=u(t),r=e.tools[n];r&&t.state===`output-available`&&r.execute&&_(t.output)&&t.output.outcome===`approved`&&i.push({toolName:u(t),tool:r,input:t.input,toolCallId:t.toolCallId})}if(i.length>0){let n=l({execute:async({writer:n})=>{n.write({type:`start-step`}),await Promise.all(i.map(async r=>{if(!r.tool.execute)throw Error(`Tool does not support execute.`);n.write({type:`tool-input-available`,toolCallId:r.toolCallId,toolName:r.toolName,input:r.input});try{let i=await r.tool.execute(r.input,{toolCallId:r.toolCallId,messages:c(e.messages,{tools:e.tools}),abortSignal:e.abortSignal}),a=i;if(t(i))for await(let e of i)a=e,n.write({type:`tool-output-available`,toolCallId:r.toolCallId,output:e,preliminary:!0});n.write({type:`tool-output-available`,toolCallId:r.toolCallId,output:a})}catch(e){n.write({type:`tool-output-error`,toolCallId:r.toolCallId,errorText:e instanceof Error?e.message:String(e)})}})),n.write({type:`finish`})}});throw new h(`Executing tools`,n)}return n},prefix(e,t){let n={};for(let[r,i]of Object.entries(e))n[`${t}${r}`]=i;return n}});function _(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`tool-approval`}var v=e=>{let t=e.split(`/`);return t[0]===``&&t.shift(),t},y=e=>{let{groups:t,path:n}=b(e),r=v(n);return x(r,t)},b=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(e,n)=>{let r=`@${n}`;return t.push([r,e]),r}),{groups:t,path:e}},x=(e,t)=>{for(let n=t.length-1;n>=0;n--){let[r]=t[n];for(let i=e.length-1;i>=0;i--)if(e[i].includes(r)){e[i]=e[i].replace(r,t[n][1]);break}}return e},S={},C=(e,t)=>{if(e===`*`)return`*`;let n=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(n){let r=`${e}#${t}`;return S[r]||(n[2]?S[r]=t&&t[0]!==`:`&&t[0]!==`*`?[r,n[1],RegExp(`^${n[2]}(?=/${t})`)]:[e,n[1],RegExp(`^${n[2]}$`)]:S[r]=[e,n[1],!0]),S[r]}return null},w=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return t(e)}catch{return e}})}},ee=e=>w(e,decodeURI),te=e=>{let t=e.url,n=t.indexOf(`/`,t.indexOf(`:`)+4),r=n;for(;r<t.length;r++){let e=t.charCodeAt(r);if(e===37){let e=t.indexOf(`?`,r),i=t.slice(n,e===-1?void 0:e);return ee(i.includes(`%25`)?i.replace(/%25/g,`%2525`):i)}else if(e===63)break}return t.slice(n,r)},ne=e=>{let t=te(e);return t.length>1&&t.at(-1)===`/`?t.slice(0,-1):t},re=(e,t,...n)=>(n.length&&(t=re(t,...n)),`${e?.[0]===`/`?``:`/`}${e}${t===`/`?``:`${e?.at(-1)===`/`?``:`/`}${t?.[0]===`/`?t.slice(1):t}`}`),ie=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(`:`))return null;let t=e.split(`/`),n=[],r=``;return t.forEach(e=>{if(e!==``&&!/\:/.test(e))r+=`/`+e;else if(/\:/.test(e))if(/\?/.test(e)){n.length===0&&r===``?n.push(`/`):n.push(r);let t=e.replace(`?`,``);r+=`/`+t,n.push(r)}else r+=`/`+e}),n.filter((e,t,n)=>n.indexOf(e)===t)},ae=e=>/[%+]/.test(e)?(e.indexOf(`+`)!==-1&&(e=e.replace(/\+/g,` `)),e.indexOf(`%`)===-1?e:w(e,le)):e,oe=(e,t,n)=>{let r;if(!n&&t&&!/[%+]/.test(t)){let n=e.indexOf(`?${t}`,8);for(n===-1&&(n=e.indexOf(`&${t}`,8));n!==-1;){let r=e.charCodeAt(n+t.length+1);if(r===61){let r=n+t.length+2,i=e.indexOf(`&`,r);return ae(e.slice(r,i===-1?void 0:i))}else if(r==38||isNaN(r))return``;n=e.indexOf(`&${t}`,n+1)}if(r=/[%+]/.test(e),!r)return}let i={};r??=/[%+]/.test(e);let a=e.indexOf(`?`,8);for(;a!==-1;){let t=e.indexOf(`&`,a+1),o=e.indexOf(`=`,a);o>t&&t!==-1&&(o=-1);let s=e.slice(a+1,o===-1?t===-1?void 0:t:o);if(r&&(s=ae(s)),a=t,s===``)continue;let c;o===-1?c=``:(c=e.slice(o+1,t===-1?void 0:t),r&&(c=ae(c))),n?(i[s]&&Array.isArray(i[s])||(i[s]=[]),i[s].push(c)):i[s]??=c}return t?i[t]:i},se=oe,ce=(e,t)=>oe(e,t,!0),le=decodeURIComponent,ue=/^[\w!#$%&'*.^`|~+-]+$/,de=/^[ !#-:<-[\]-~]*$/,fe=(e,t)=>{if(t&&e.indexOf(t)===-1)return{};let n=e.trim().split(`;`),r={};for(let e of n){e=e.trim();let n=e.indexOf(`=`);if(n===-1)continue;let i=e.substring(0,n).trim();if(t&&t!==i||!ue.test(i))continue;let a=e.substring(n+1).trim();if(a.startsWith(`"`)&&a.endsWith(`"`)&&(a=a.slice(1,-1)),de.test(a)&&(r[i]=a.indexOf(`%`)===-1?a:w(a,le),t))break}return r},pe=(e,t,n={})=>{let r=`${e}=${t}`;if(e.startsWith(`__Secure-`)&&!n.secure)throw Error(`__Secure- Cookie must have Secure attributes`);if(e.startsWith(`__Host-`)){if(!n.secure)throw Error(`__Host- Cookie must have Secure attributes`);if(n.path!==`/`)throw Error(`__Host- Cookie must have Path attributes with "/"`);if(n.domain)throw Error(`__Host- Cookie must not have Domain attributes`)}if(n&&typeof n.maxAge==`number`&&n.maxAge>=0){if(n.maxAge>3456e4)throw Error(`Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.`);r+=`; Max-Age=${n.maxAge|0}`}if(n.domain&&n.prefix!==`host`&&(r+=`; Domain=${n.domain}`),n.path&&(r+=`; Path=${n.path}`),n.expires){if(n.expires.getTime()-Date.now()>3456e7)throw Error(`Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.`);r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+=`; HttpOnly`),n.secure&&(r+=`; Secure`),n.sameSite&&(r+=`; SameSite=${n.sameSite.charAt(0).toUpperCase()+n.sameSite.slice(1)}`),n.priority&&(r+=`; Priority=${n.priority.charAt(0).toUpperCase()+n.priority.slice(1)}`),n.partitioned){if(!n.secure)throw Error(`Partitioned Cookie must have Secure attributes`);r+=`; Partitioned`}return r},me=(e,t,n)=>(t=encodeURIComponent(t),pe(e,t,n));function he(){return/[<>:"/\\|?*\u0000-\u001F]|[. ]$/g}function ge(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}const _e=/^\.+(\\|\/)|^\.+$/,ve=/[. ]+$/,ye=/[\p{Control}\p{Format}\p{Zl}\p{Zp}\uFFF0-\uFFFF]/gu,be=/[\p{Control}\p{Format}\p{Zl}\p{Zp}\uFFF0-\uFFFF]/u,xe=e=>e===``,Se=/([<>:"/\\|?*\u0000-\u001F]){2,}/g,Ce=/[\t\n\r\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]+/g;let we;function Te(){return we??=new Intl.Segmenter(void 0,{granularity:`grapheme`}),we}function Ee(e,t={}){if(typeof e!=`string`)throw TypeError(`Expected a string`);let n=t.replacement??`!`;if(he().test(n)||[...n].some(e=>be.test(e)&&!xe(e)))throw Error(`Replacement string cannot contain reserved filename characters`);e=e.normalize(`NFC`),e=e.replaceAll(Ce,` `),n.length>0&&(e=e.replaceAll(Se,`$1`)),e=e.replace(ve,``),e=e.replace(_e,n),e=e.replace(he(),n),e=e.replaceAll(ye,e=>xe(e)?e:n),e.length===0&&(e=n),e=ge().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=De(e,r);else{let n=e.slice(0,t),i=e.slice(t),a=Math.max(0,r-i.length);e=De(n,a)+i}}return e}function De(e,t){if(e.length<=t)return e;let n=0,r=``;for(let{segment:i}of Te().segment(e)){let e=n+i.length;if(e>t)break;r+=i,n=e}return r}function Oe(e){return`${e}.lock`}function ke(e){try{return process.kill(e,0),!0}catch(e){return e.code===`EPERM`}}function T(e,t={}){let n=Oe(e),i=process.pid.toString();try{return r.writeFileSync(n,i,{flag:`wx`}),!0}catch(i){if(i.code!==`EEXIST`)throw i;if(t.stale===0)return!1;let a;try{a=parseInt(r.readFileSync(n,`utf8`),10)}catch{return r.unlinkSync(n),T(e,{...t,stale:0})}if(!ke(a))try{return r.unlinkSync(n),T(e,{...t,stale:0})}catch(n){if(n.code===`ENOENT`)return T(e,{...t,stale:0});throw n}return!1}}async function Ae(e,t={}){let r={stale:!0,retries:0,retryInterval:100,...t},i=n.resolve(e),a=0;for(;a<=r.retries;){if(T(i,r))return()=>je(i);a<r.retries&&await new Promise(e=>setTimeout(e,r.retryInterval)),a++}let o=Error(`Lock file is already being held`);throw o.code=`ELOCKED`,o.file=i,o}function je(e){let t=n.resolve(e),i=Oe(t);try{if(parseInt(r.readFileSync(i,`utf8`),10)!==process.pid){let e=Error(`Lock is not owned by this process`);throw e.code=`ENOTACQUIRED`,e}r.unlinkSync(i)}catch(e){if(e.code===`ENOENT`){let e=Error(`Lock is not acquired`);throw e.code=`ENOTACQUIRED`,e}throw e}}function Me(e){let t=n.resolve(e),i=Oe(t);try{if(!r.existsSync(i))return{locked:!1};let e=r.readFileSync(i,`utf8`),t=parseInt(e,10);return ke(t)?{locked:!0,pid:t}:{locked:!1}}catch(e){return e.code,{locked:!1}}}const Ne=e=>{r.mkdirSync(e,{recursive:!0})},Pe=e=>{try{r.fdatasyncSync(e)}catch{}try{r.closeSync(e)}catch{}},Fe=e=>{try{let t=r.openSync(e,`r`);try{r.fsyncSync(t)}finally{r.closeSync(t)}}catch{}},Ie=(e,t)=>{let i=n.dirname(e);Ne(i);let a=n.join(i,`.tmp-`+process.pid+`-`+Math.random().toString(36).slice(2)),o;try{o=r.openSync(a,`w`),r.writeFileSync(o,t,`utf-8`),Pe(o),o=void 0,r.renameSync(a,e),Fe(e),Fe(i)}catch(e){if(o!==void 0)try{r.closeSync(o)}catch{}try{r.rmSync(a,{force:!0})}catch{}throw e}},Le=(e,t)=>{let i=new Map,a,o=e=>{if(r.statSync(e,{throwIfNoEntry:!1}))return JSON.parse(r.readFileSync(e,`utf-8`))},s=(e,t)=>{Ie(e,JSON.stringify(t,null,2))},c=async()=>{if(a)throw Error(`Index is already locked`);let t=n.join(e,`index.json`);Ne(e),r.existsSync(t)||r.writeFileSync(t,JSON.stringify({ids:{}}),`utf-8`);let i=await Ae(t,{stale:!0,retries:5,retryInterval:100});return a=()=>Promise.resolve(i()),()=>{i(),a=void 0}},l=async()=>{let t=n.join(e,`index.json`),r=o(t)??{ids:{}};return r.ids||={},r},u=async t=>{let r=n.join(e,`index.json`);s(r,t)},d=async t=>{let r=(await l()).ids[t];if(r)return n.join(e,r)},f=async t=>{let i=(await l()).ids[t];if(!i)return;let a=n.join(e,i);if(r.statSync(a,{throwIfNoEntry:!1}))return JSON.parse(r.readFileSync(a,`utf-8`))},p=async r=>{let i=r[t],a=String(i),o=Ee(a,{replacement:`_`})+`.json`,d=await c();try{let t=await l();t.ids[a]=o,t.current=a;let i=n.join(e,o);s(i,r),await u(t)}finally{await d()}};return{async get(e){return await f(e)},async list(){if(!r.statSync(e,{throwIfNoEntry:!1}))return[];let t=await l(),i=[];for(let[a,o]of Object.entries(t.ids)){let t=n.join(e,o),s=r.statSync(t,{throwIfNoEntry:!1});if(!s)continue;let c=Me(t);i.push({key:a,locked:c.locked,pid:c.pid,mtime:s.mtimeMs})}return i.sort((e,t)=>t.mtime-e.mtime),i},async lock(a,o){if(i.has(a))throw Error(`Key "${a}" is already locked in this process`);let s=await d(a);if(!s){let t=Ee(a,{replacement:`_`})+`.json`,i=await c();try{let i=await l();i.ids[a]=t;let o=n.join(e,t);Ne(e),r.writeFileSync(o,JSON.stringify({}),`utf-8`),await u(i),s=o}finally{await i()}}if(o?.force){let e=Me(s);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 m=await Ae(s,{stale:!0,retries:o?.force?10:5,retryInterval:(o?.force,100)});return i.set(a,()=>Promise.resolve(m())),{async get(){let e=await f(a);if(!e)throw Error(`Key ${a} not found`);return e},async set(e){await p(e)},async update(e){let n=await f(a);if(!n||!(t in n))throw Error(`Key ${a} not found`);await p({...n,...e})},async delete(){let t=await c();try{let t=await l(),i=t.ids[a];if(i){delete t.ids[a],t.current===a&&(t.current=void 0),await u(t);let o=n.join(e,i);try{r.rmSync(o,{force:!0}),Fe(e)}catch{}}}finally{await t()}},async release(){try{m()}finally{i.delete(a)}}}},dispose(){i.clear()}}},Re=(e,t)=>{let i=t?.pollInterval??200,a=t?.debounce??50,o=new Set,s,c,l=new Map,u=new Map,d=n.join(e,`index.json`),f=()=>{try{if(!r.statSync(d,{throwIfNoEntry:!1}))return{ids:{}};let e=r.readFileSync(d,`utf-8`);return{ids:JSON.parse(e).ids??{}}}catch{return{ids:{}}}},p=(e,t,n,r)=>{for(let i of o)try{i({key:e,value:t,locked:n,pid:r})}catch(e){console.error(`Error in onChange callback:`,e)}},m=(t,i,a=!1)=>{let o=n.join(e,i);try{let e=r.statSync(o,{throwIfNoEntry:!1}),n=u.get(i);if(!e){n&&(u.delete(i),p(t,void 0,!1));return}let s=e.mtimeMs,c=n?{locked:n.locked,pid:n.pid}:{locked:!1,pid:void 0};if((a||!n)&&(c=Me(o)),!n||n.mtime!==s||n.locked!==c.locked||n.pid!==c.pid){let e;e=!n||n.mtime!==s?JSON.parse(r.readFileSync(o,`utf-8`)):n.cachedValue,u.set(i,{mtime:s,key:t,locked:c.locked,pid:c.pid,cachedValue:e}),p(t,e,c.locked,c.pid)}}catch{}},h=()=>{try{let e=f(),t=new Set(Object.keys(e.ids));for(let[t,n]of Object.entries(e.ids))m(t,n,!0);for(let[e,n]of u.entries())t.has(n.key)||(u.delete(e),p(n.key,void 0,!1))}catch{}},g=(e,t,n=!1)=>{let r=l.get(e);r&&clearTimeout(r),l.set(e,setTimeout(()=>{l.delete(e),m(e,t,n)},a))},_=()=>{if(s)return;try{r.mkdirSync(e,{recursive:!0})}catch{}s=r.watch(e,(e,t)=>{if(!t||t.startsWith(`.tmp-`))return;if(t===`index.json`){h();return}if(t.endsWith(`.lock`)){let e=t.replace(`.lock`,``),n=f(),r=Object.keys(n.ids).find(t=>n.ids[t]===e);r&&m(r,e,!0);return}let n=f(),r=Object.keys(n.ids).find(e=>n.ids[e]===t);r&&g(r,t,!1)});let t=()=>{h(),c=setTimeout(t,i)};h(),c=setTimeout(t,i)};return{onChange(e){return o.size===0&&_(),o.add(e),()=>{if(o.delete(e),o.size===0){s&&=(s.close(),void 0),c&&=(clearTimeout(c),void 0);for(let e of l.values())clearTimeout(e);l.clear(),u.clear()}}},dispose(){s&&=(s.close(),void 0),c&&=(clearTimeout(c),void 0);for(let e of l.values())clearTimeout(e);l.clear(),o.clear(),u.clear()}}};var ze=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function Be(e){}function Ve(e){if(typeof e==`function`)throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:t=Be,onError:n=Be,onRetry:r=Be,onComment:i}=e,a=``,o=!0,s,c=``,l=``;function u(e){let t=o?e.replace(/^\xEF\xBB\xBF/,``):e,[n,r]=He(`${a}${t}`);for(let e of n)d(e);a=r,o=!1}function d(e){if(e===``){p();return}if(e.startsWith(`:`)){i&&i(e.slice(e.startsWith(`: `)?2:1));return}let t=e.indexOf(`:`);if(t!==-1){let n=e.slice(0,t),r=e[t+1]===` `?2:1,i=e.slice(t+r);f(n,i,e);return}f(e,``,e)}function f(e,t,i){switch(e){case`event`:l=t;break;case`data`:c=`${c}${t}
|
|
2
2
|
`;break;case`id`:s=t.includes(`\0`)?void 0:t;break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new ze(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new ze(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}));break}}function p(){c.length>0&&t({id:s,event:l||void 0,data:c.endsWith(`
|
|
3
3
|
`)?c.slice(0,-1):c}),s=void 0,c=``,l=``}function m(e={}){a&&e.consume&&d(a),o=!0,s=void 0,c=``,l=``,a=``}return{feed:u,reset:m}}function He(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e.indexOf(`\r`,r),a=e.indexOf(`
|
|
4
4
|
`,r),o=-1;if(i!==-1&&a!==-1?o=Math.min(i,a):i===-1?a!==-1&&(o=a):o=i===e.length-1?-1:i,o===-1){n=e.slice(r);break}else{let n=e.slice(r,o);t.push(n),r=o+1,e[r-1]===`\r`&&e[r]===`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__require as e}from"./chunk-D9KrCrVq.js";import{import_websocket_server as t}from"./wrapper-DRdRnzOz.js";import{_usingCtx as n}from"./usingCtx-
|
|
1
|
+
import{__require as e}from"./chunk-D9KrCrVq.js";import{import_websocket_server as t}from"./wrapper-DRdRnzOz.js";import{_usingCtx as n}from"./usingCtx-CCxav2be.js";import{Buffer as r}from"node:buffer";import{Server as i}from"@blink-sdk/compute-protocol/server";let a=function(e){return e[e.DATA=0]=`DATA`,e[e.CLOSE=1]=`CLOSE`,e[e.ERROR=2]=`ERROR`,e}({});var o=class{static MAX_POOL_SIZE=100;static COMMON_SIZES=[64,256,1024,4096,16384];static pools=new Map;static{for(let e of this.COMMON_SIZES)this.pools.set(e,[])}static acquire(e){for(let t of this.COMMON_SIZES)if(t>=e){let e=this.pools.get(t);if(e&&e.length>0)return e.pop();break}return new Uint8Array(e)}static release(e){let t=e.length;for(let n of this.COMMON_SIZES)if(n===t){let t=this.pools.get(n);t&&t.length<this.MAX_POOL_SIZE&&t.push(e);break}}},s=class e{static HEADER_SIZE=4;static MAX_FRAME_SIZE=1024*1024-e.HEADER_SIZE;static encode(e){let t=e.payload.length;if(t>this.MAX_FRAME_SIZE)throw Error(`Frame payload too large: ${t} > ${this.MAX_FRAME_SIZE}`);let n=this.HEADER_SIZE+t,r=o.acquire(n),i=e.streamId<<8|e.type<<4|e.flags&15;return r[0]=i>>>24&255,r[1]=i>>>16&255,r[2]=i>>>8&255,r[3]=i&255,t>0&&r.set(e.payload,this.HEADER_SIZE),r.length===n?r:r.subarray(0,n)}static encodeTyped(t,n,r,i,a){let s=1+a.length;if(s>this.MAX_FRAME_SIZE)throw Error(`Frame payload too large: ${s} > ${this.MAX_FRAME_SIZE}`);let c=this.HEADER_SIZE+s,l=o.acquire(c),u=t<<8|n<<4|r&15;return l[0]=u>>>24&255,l[1]=u>>>16&255,l[2]=u>>>8&255,l[3]=u&255,l[e.HEADER_SIZE]=i&255,a.length>0&&l.set(a,e.HEADER_SIZE+1),l.length===c?l:l.subarray(0,c)}static decode(t){if(t.length<e.HEADER_SIZE)throw Error(`Invalid frame: too short (${t.length} < ${e.HEADER_SIZE})`);let n=t[0]<<24|t[1]<<16|t[2]<<8|t[3],r=n>>>8,i=n&255;return{streamId:r,type:i>>>4,flags:i&15,payload:t.length>e.HEADER_SIZE?t.subarray(e.HEADER_SIZE):new Uint8Array}}static releaseBuffer(e){o.release(e)}static getMaxPayloadSize(){return e.MAX_FRAME_SIZE}};const c={GIT_TERMINAL_PROMPT:`0`,GIT_PAGER:`cat`,GIT_AUTHOR_NAME:`blink-so[bot]`,GIT_AUTHOR_EMAIL:`211532188+blink-so[bot]@users.noreply.github.com`,GIT_COMMITTER_NAME:`blink-so[bot]`,GIT_COMMITTER_EMAIL:`211532188+blink-so[bot]@users.noreply.github.com`,GIT_CONFIG_COUNT:`1`,GIT_CONFIG_KEY_0:`credential.https://github.com.helper`,GIT_CONFIG_VALUE_0:`!gh auth git-credential`},l=e=>{if(Array.isArray(e)){let t=r.concat(e);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}return e instanceof Uint8Array?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)},u=(e,t)=>{let n=s.encode({streamId:t,type:e.type,flags:e.flags,payload:e.payload});return{buffer:r.from(n.buffer,n.byteOffset,n.byteLength),release:()=>s.releaseBuffer(n)}},d=(e,t)=>s.encode({streamId:t,type:e.type,flags:e.flags,payload:e.payload}),f=e=>new Promise(t=>{if(e.address()){t();return}e.once(`listening`,()=>t())}),p=(e,t)=>{let n=e.address();return typeof n==`object`&&n?n.port:typeof n==`number`?n:t};async function m(o={}){let m=o.logger??console;for(let[e,t]of Object.entries(c))process.env[e]===void 0&&(process.env[e]=t);let h=o.port??(process.env.PORT?parseInt(process.env.PORT,10):22137);if(isNaN(h))throw Error(`PORT environment variable is not a number`);let g=o.host??process.env.HOST??`127.0.0.1`,_;try{_=e(`@lydell/node-pty`)}catch{}typeof Bun<`u`&&(_=void 0);let v=new Set,y=new Map,b=1,x=e=>{for(let t of v)t.ws.send(r.from(e))},S=(e,t)=>{let n=e.serverToClientStream.get(t);n!==void 0&&(e.serverToClientStream.delete(t),e.clientToServerStream.delete(n)),y.delete(t)},C=new i({nodePty:_,send:e=>{try{var t=n();let r;t.u({[Symbol.dispose](){s.releaseBuffer(e)}});try{r=s.decode(e)}catch(e){m.error(`Failed to decode server frame`,e);return}let i=y.get(r.streamId);if(i){let e=i.serverToClientStream.get(r.streamId);if(e===void 0){S(i,r.streamId);return}let{buffer:t,release:n}=u(r,e);try{i.ws.send(t)}finally{n()}(r.type===a.CLOSE||r.type===a.ERROR)&&S(i,r.streamId);return}r.streamId%2==0&&x(e)}catch(e){t.e=e}finally{t.d()}}}),w=()=>{let e=b;return b+=2,e},T=e=>{let t=d(e,e.streamId);try{C.handleMessage(t)}finally{s.releaseBuffer(t)}},E=o.createWebSocketServer?.({port:h,host:g})??new t.default({port:h,host:g});await f(E);let D=p(E,h);return m.info(`Compute server running on ${g}:${D}`),E.on(`connection`,e=>{m.info(`Client connected`);let t={ws:e,clientToServerStream:new Map,serverToClientStream:new Map};v.add(t),e.on(`message`,n=>{if(typeof n==`string`){m.warn(`Ignoring unexpected text message from client`);return}let r=l(n),i;try{i=s.decode(r)}catch(t){m.error(`Failed to decode client frame`,t),e.close(1002,`invalid frame`);return}let o=t.clientToServerStream.get(i.streamId);o===void 0&&(o=w(),t.clientToServerStream.set(i.streamId,o),t.serverToClientStream.set(o,i.streamId),y.set(o,t)),i.streamId=o,T(i),(i.type===a.CLOSE||i.type===a.ERROR)&&S(t,o)});let n=()=>{for(let e of[...t.serverToClientStream.keys()]){let n={streamId:e,type:a.CLOSE,flags:0,payload:new Uint8Array};T(n),S(t,e)}};e.on(`close`,()=>{n(),v.delete(t),m.info(`Client disconnected`)}),e.on(`error`,()=>{n(),v.delete(t)})}),E}export{m as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dirname as e,join as t}from"node:path";import{mkdir as n,writeFile as r}from"node:fs/promises";var i=`1.1.37`;async function a(i,a){let o=t(i,`.blink`,`config.json`);await n(e(o),{recursive:!0}),await r(o,JSON.stringify({_:`This file can be source controlled. It contains no secrets.`,...a},null,2),`utf-8`)}export{i as version,a as writeBlinkConfig};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./wrapper-DRdRnzOz.js";import"./auth-B7pruQew.js";import{WorkspaceConnect as e,connect as t}from"./connect-lEKh-OPL.js";export{e as WorkspaceConnect,t as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__require as e}from"./chunk-D9KrCrVq.js";import{wrapper_default as t}from"./wrapper-DRdRnzOz.js";import{getHost as n,toWsUrl as r}from"./auth-B7pruQew.js";import i from"node:path";import a from"node:fs";import o from"node:os";import{Server as s}from"@blink-sdk/compute-protocol/server";var c=class{listeners=[];get event(){return e=>(this.listeners.push(e),{dispose:()=>{this.listeners=this.listeners.filter(t=>t!==e)}})}emit(e){for(let t=this.listeners.length-1;t>=0;t--)this.listeners[t]?.(e)}dispose(){this.listeners=[]}};const l=i.join(o.tmpdir(),`blink-connect-${process.pid}.log`),u=e=>{if(e instanceof Error)return e.stack??e.message;try{return JSON.stringify(e)}catch{return String(e)}},d=async e=>{let t=`${new Date().toISOString()} ${e}\n`;try{await a.promises.appendFile(l,t,`utf8`)}catch{}},f=`https://blink.coder.com`;async function p(){let e=process.env.BLINK_URL,t=process.env.BLINK_TOKEN;delete process.env.BLINK_TOKEN,process.env.GIT_TERMINAL_PROMPT=`0`,process.env.GIT_PAGER=`cat`,process.env.GIT_AUTHOR_NAME=`blink-so[bot]`,process.env.GIT_AUTHOR_EMAIL=`211532188+blink-so[bot]@users.noreply.github.com`,process.env.GIT_COMMITTER_NAME=`blink-so[bot]`,process.env.GIT_COMMITTER_EMAIL=`211532188+blink-so[bot]@users.noreply.github.com`,process.env.GIT_CONFIG_COUNT=`1`,process.env.GIT_CONFIG_KEY_0=`credential.https://github.com.helper`,process.env.GIT_CONFIG_VALUE_0=`!gh auth git-credential`,process.addListener(`uncaughtException`,e=>{d(`uncaughtException: ${u(e)}`),m(t,e)}),process.addListener(`unhandledRejection`,e=>{d(`unhandledRejection: ${u(e)}`),m(t,e)});let i=n()??f,a=new h({url:e??`${r(i)}/api/connect`,token:t,createDeploymentFromTar:async n=>{let r=new URL(`/api/static-deployment`,e??i);return(await(await fetch(r,{method:`POST`,body:n,headers:{"Content-Type":`application/tar`,Authorization:`Bearer ${t}`},duplex:`half`})).json()).deployment_id}});a.onConnect(()=>{console.log(`Connected`),d(`Connected`)}),a.onDisconnect(()=>{console.log(`Disconnected`),d(`Disconnected`)})}const m=async(e,t)=>{let r=n()??f,i=new URL(`${r}/api/connect-error`);await fetch(i.toString(),{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${e}`},body:JSON.stringify({error:t})})};var h=class{_onConnect=new c;onConnect=this._onConnect.event;_onDisconnect=new c;onDisconnect=this._onDisconnect.event;reconnectTimeout=null;disposed=!1;ws;server;hasReconnectedOnce=!1;constructor(n){this.opts=n;let r;try{r=e(`@lydell/node-pty`)}catch{}typeof Bun<`u`&&(r=void 0),this.server=new s({send:e=>{this.ws.readyState===t.OPEN?this.ws.send(e):console.warn(`Message skipped because connection is closed.`)},createDeploymentFromTar:this.opts.createDeploymentFromTar,nodePty:r}),this.connect()}dispose(){this.disposed||(this.disposed=!0,this.ws.close(),this.reconnectTimeout&&clearTimeout(this.reconnectTimeout))}scheduleReconnect(){if(this.disposed)return;let e=this.opts.immediateReconnectFirst??!0,t=this.opts.reconnectionDelay??2500;!this.hasReconnectedOnce&&e&&(t=0),this.hasReconnectedOnce=!0,this.reconnectTimeout&&clearTimeout(this.reconnectTimeout),this.reconnectTimeout=setTimeout(()=>{this.connect()},t)}connect(){let e=new URL(this.opts.url);e.protocol===`http:`?e.protocol=`ws:`:e.protocol===`https:`&&(e.protocol=`wss:`);let n={};this.opts.token&&(n.Authorization=`Bearer ${this.opts.token}`),this.ws=new t(e.toString(),{headers:n}),this.ws.addEventListener(`open`,()=>{this._onConnect.emit(void 0)}),this.ws.addEventListener(`close`,()=>{this._onDisconnect.emit(void 0),!this.disposed&&this.scheduleReconnect()}),this.ws.addEventListener(`error`,e=>{console.error(`Error`,e.message??e)}),this.ws.addEventListener(`message`,e=>{if(typeof e.data==`string`){console.warn(`Message skipped because it is not a buffer.`);return}try{this.server.handleMessage(new Uint8Array(e.data))}catch(e){console.error(`message handler error`,e);try{this.ws.close(1011)}catch{}}})}};export{h as WorkspaceConnect,p as connect};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__commonJSMin as e,__esmMin as t,__export as n,__require as r,__toCommonJS as i,__toESM as a}from"./chunk-D9KrCrVq.js";import{completeAssign as o,createCustomAbortControllerSignal as s,ensureDisposableStackRegisteredForTerminateEvents as c,fakePromise as l,handleAbortSignalAndPromiseResponse as u,handleErrorFromRequestHandler as d,handleMaybePromise as f,isFetchEvent as p,isNodeRequest as m,isPromise as h,isRequestInit as g,isServerResponse as _,isolateObject as v,iterateAsync as y,normalizeNodeRequest as b,sendNodeResponse as x,unfakePromise as S}from"./utils-B3iC7vdW.js";import C from"http";import{dirname as w,join as T}from"path";import{existsSync as E,mkdirSync as D,readFileSync as O,unlinkSync as k,writeFileSync as A}from"fs";import{z as j}from"zod";function M(e){return T(e,`.blink`,`devhook.txt`)}function N(e){return E(M(e))}function P(e){let t=M(e);if(E(t))return O(t,`utf-8`).trim()}function F(e){let t=M(e);if(D(w(t),{recursive:!0}),E(t))return O(t,`utf-8`);let n=crypto.randomUUID();return A(t,n),n}function I(e){let t=M(e);E(t)&&k(t)}function L(e){return`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(e))}`}const R=j.union([j.literal(`app_mention`).describe(`Bot is @mentioned in a channel or conversation. Requires scope: app_mentions:read`),j.literal(`app_home_opened`).describe(`User opened the app's Home tab. No additional scope required beyond bot token`),j.literal(`app_installed`).describe(`App was installed to a workspace. No additional scope required beyond bot token`),j.literal(`app_uninstalled`).describe(`App was uninstalled from a workspace. No additional scope required beyond bot token`),j.literal(`assistant_thread_context_changed`).describe(`Context changed in an assistant thread. Requires scope: assistant:write`),j.literal(`assistant_thread_started`).describe(`New assistant thread was started. Requires scope: assistant:write`),j.literal(`channel_archive`).describe(`Public channel was archived. Requires scope: channels:read`),j.literal(`channel_created`).describe(`Public channel was created. Requires scope: channels:read`),j.literal(`channel_deleted`).describe(`Public channel was deleted. Requires scope: channels:read`),j.literal(`channel_rename`).describe(`Public channel was renamed. Requires scope: channels:read`),j.literal(`channel_unarchive`).describe(`Public channel was unarchived. Requires scope: channels:read`),j.literal(`dnd_updated_user`).describe(`User's Do Not Disturb settings changed. Requires scope: dnd:read`),j.literal(`email_domain_changed`).describe(`Workspace's email domain changed. Requires scope: team:read`),j.literal(`emoji_changed`).describe(`Custom emoji was added or changed. Requires scope: emoji:read`),j.literal(`file_change`).describe(`File was changed. Requires scope: files:read`),j.literal(`file_created`).describe(`File was created. Requires scope: files:read`),j.literal(`file_deleted`).describe(`File was deleted. Requires scope: files:read`),j.literal(`file_public`).describe(`File was made public. Requires scope: files:read`),j.literal(`file_shared`).describe(`File was shared. Requires scope: files:read`),j.literal(`file_unshared`).describe(`File was unshared. Requires scope: files:read`),j.literal(`group_archive`).describe(`Private channel was archived. Requires scope: groups:read`),j.literal(`group_deleted`).describe(`Private channel was deleted. Requires scope: groups:read`),j.literal(`group_rename`).describe(`Private channel was renamed. Requires scope: groups:read`),j.literal(`group_unarchive`).describe(`Private channel was unarchived. Requires scope: groups:read`),j.literal(`link_shared`).describe(`Link from a registered domain was shared. Requires scope: links:read`),j.literal(`member_joined_channel`).describe(`User joined a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),j.literal(`member_left_channel`).describe(`User left a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),j.literal(`message.channels`).describe(`Message was posted in a public channel. Requires scope: channels:history`),j.literal(`message.groups`).describe(`Message was posted in a private channel. Requires scope: groups:history`),j.literal(`message.im`).describe(`Message was posted in a direct message. Requires scope: im:history`),j.literal(`message.mpim`).describe(`Message was posted in a multi-party direct message. Requires scope: mpim:history`),j.literal(`pin_added`).describe(`Item was pinned in a channel. Requires scope: pins:read`),j.literal(`pin_removed`).describe(`Item was unpinned from a channel. Requires scope: pins:read`),j.literal(`reaction_added`).describe(`Reaction was added to a message. Requires scope: reactions:read`),j.literal(`reaction_removed`).describe(`Reaction was removed from a message. Requires scope: reactions:read`),j.literal(`team_join`).describe(`New user joined the workspace. Requires scope: users:read`),j.literal(`user_change`).describe(`User's profile or settings changed. Requires scope: users:read`)]),z=j.union([j.literal(`app_mentions:read`).describe(`Read messages that directly mention the bot. Required for: app_mention event`),j.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`),j.literal(`channels:history`).describe(`Read message history in public channels the bot has access to. Required for: message.channels event`),j.literal(`channels:join`).describe(`Join public channels`),j.literal(`channels:manage`).describe(`Manage public channels (archive, rename, etc.)`),j.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`),j.literal(`chat:write`).describe(`Send messages as the bot`),j.literal(`chat:write.customize`).describe(`Send messages with a customized username and avatar`),j.literal(`chat:write.public`).describe(`Send messages to public channels without joining`),j.literal(`commands`).describe(`Add and use slash commands`),j.literal(`dnd:read`).describe(`View Do Not Disturb settings for users. Required for: dnd_updated_user event`),j.literal(`emoji:read`).describe(`View custom emoji in the workspace. Required for: emoji_changed event`),j.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`),j.literal(`files:write`).describe(`Upload, edit, and delete files`),j.literal(`groups:history`).describe(`Read message history in private channels the bot has access to. Required for: message.groups event`),j.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`),j.literal(`groups:write`).describe(`Manage private channels (archive, rename, create, etc.)`),j.literal(`im:history`).describe(`Read message history in direct messages with the bot. Required for: message.im event`),j.literal(`im:read`).describe(`View basic information about direct messages with the bot`),j.literal(`im:write`).describe(`Start and manage direct messages with users`),j.literal(`links:read`).describe(`View URLs in messages. Required for: link_shared event`),j.literal(`links:write`).describe(`Show previews of URLs (unfurling)`),j.literal(`metadata.message:read`).describe(`Read message metadata`),j.literal(`mpim:history`).describe(`Read message history in multi-party direct messages. Required for: message.mpim event`),j.literal(`mpim:read`).describe(`View basic information about multi-party direct messages`),j.literal(`mpim:write`).describe(`Start and manage multi-party direct messages`),j.literal(`pins:read`).describe(`View pinned items in channels and conversations. Required for: pin_added, pin_removed events`),j.literal(`pins:write`).describe(`Pin and unpin items in channels and conversations`),j.literal(`reactions:read`).describe(`View emoji reactions on messages. Required for: reaction_added, reaction_removed events`),j.literal(`reactions:write`).describe(`Add and remove emoji reactions to messages`),j.literal(`reminders:read`).describe(`View reminders created by the bot`),j.literal(`reminders:write`).describe(`Create, update, and delete reminders`),j.literal(`team:read`).describe(`View workspace name, domain, and other basic information. Required for: email_domain_changed event`),j.literal(`usergroups:read`).describe(`View user groups and their members`),j.literal(`usergroups:write`).describe(`Create, update, and archive user groups`),j.literal(`users.profile:read`).describe(`View profile information about users`),j.literal(`users:read`).describe(`View users in the workspace. Required for: team_join, user_change events`),j.literal(`users:read.email`).describe(`View email addresses of users in the workspace`),j.literal(`users:write`).describe(`Set presence and status for the bot user`)]),B=j.union([j.literal(`channels:history`).describe(`Read message history in public channels on behalf of the user`),j.literal(`channels:read`).describe(`View basic information about public channels on behalf of the user`),j.literal(`channels:write`).describe(`Manage public channels on behalf of the user`),j.literal(`chat:write`).describe(`Send messages on behalf of the user`),j.literal(`emoji:read`).describe(`View custom emoji on behalf of the user`),j.literal(`files:read`).describe(`View files on behalf of the user`),j.literal(`files:write`).describe(`Upload, edit, and delete files on behalf of the user`),j.literal(`groups:history`).describe(`Read message history in private channels on behalf of the user`),j.literal(`groups:read`).describe(`View basic information about private channels on behalf of the user`),j.literal(`groups:write`).describe(`Manage private channels on behalf of the user`),j.literal(`im:history`).describe(`Read direct message history on behalf of the user`),j.literal(`im:read`).describe(`View basic information about direct messages on behalf of the user`),j.literal(`im:write`).describe(`Manage direct messages on behalf of the user`),j.literal(`links:read`).describe(`View URLs in messages on behalf of the user`),j.literal(`links:write`).describe(`Show URL previews on behalf of the user`),j.literal(`mpim:history`).describe(`Read multi-party direct message history on behalf of the user`),j.literal(`mpim:read`).describe(`View basic information about multi-party direct messages on behalf of the user`),j.literal(`mpim:write`).describe(`Manage multi-party direct messages on behalf of the user`),j.literal(`pins:read`).describe(`View pinned items on behalf of the user`),j.literal(`pins:write`).describe(`Pin and unpin items on behalf of the user`),j.literal(`reactions:read`).describe(`View emoji reactions on behalf of the user`),j.literal(`reactions:write`).describe(`Add and remove emoji reactions on behalf of the user`),j.literal(`reminders:read`).describe(`View reminders on behalf of the user`),j.literal(`reminders:write`).describe(`Create, update, and delete reminders on behalf of the user`),j.literal(`search:read`).describe(`Search messages and files on behalf of the user`),j.literal(`stars:read`).describe(`View starred items on behalf of the user`),j.literal(`stars:write`).describe(`Star and unstar items on behalf of the user`),j.literal(`team:read`).describe(`View workspace information on behalf of the user`),j.literal(`usergroups:read`).describe(`View user groups on behalf of the user`),j.literal(`usergroups:write`).describe(`Manage user groups on behalf of the user`),j.literal(`users.profile:read`).describe(`View user profile information on behalf of the user`),j.literal(`users.profile:write`).describe(`Edit the user's profile information`),j.literal(`users:read`).describe(`View users in the workspace on behalf of the user`),j.literal(`users:read.email`).describe(`View email addresses on behalf of the user`),j.literal(`users:write`).describe(`Set presence for the user`)]),V=j.object({display_information:j.object({name:j.string().describe(`The name of the Slack app.`),description:j.string().optional().describe(`A short description of the app.`),background_color:j.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe(`Background color for the app in hex format (e.g., #4A154B).`),long_description:j.string().optional().describe(`A longer description of the app.`)}).describe(`Display information for the Slack app.`),features:j.object({bot_user:j.object({display_name:j.string().describe(`The display name for the bot user.`),always_online:j.boolean().optional().default(!0).describe(`Whether the bot always appears online.`)}).optional().describe(`Configuration for the bot user.`),app_home:j.object({home_tab_enabled:j.boolean().optional().describe(`Enable the Home tab.`),messages_tab_enabled:j.boolean().optional().describe(`Enable the Messages tab.`),messages_tab_read_only_enabled:j.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:j.object({assistant_description:j.string().optional().describe(`Description for the assistant view.`)}).optional().describe(`Configuration for the assistant view.`),slash_commands:j.array(j.object({command:j.string().regex(/^\//).describe(`The command (must start with /).`),description:j.string().describe(`Description of the command.`),usage_hint:j.string().optional().describe(`Usage hint for the command.`),should_escape:j.boolean().optional().describe(`Whether to escape special characters.`)})).optional().describe(`Slash commands for the app.`),unfurl_domains:j.array(j.string()).optional().describe(`Domains for link unfurling.`)}).optional().describe(`Features configuration for the Slack app.`),oauth_config:j.object({redirect_urls:j.array(j.url()).optional().describe(`OAuth redirect URLs.`),scopes:j.object({bot:j.array(j.union([z,j.string()])).optional().describe(`Bot scopes required by the app. Each scope defines specific permissions for what the bot can do.`),user:j.array(j.union([B,j.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:j.object({event_subscriptions:j.object({request_url:j.string().url().describe(`The webhook URL for event subscriptions.`),bot_events:j.array(j.union([R,j.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:j.object({is_enabled:j.boolean().describe(`Enable interactivity.`),request_url:j.string().url().describe(`The webhook URL for interactive components.`),message_menu_options_url:j.string().url().optional().describe(`URL for message menu options.`)}).optional().describe(`Interactivity configuration.`),org_deploy_enabled:j.boolean().optional().default(!1).describe(`Enable organization-wide deployment.`),socket_mode_enabled:j.boolean().optional().default(!1).describe(`Enable Socket Mode.`),token_rotation_enabled:j.boolean().optional().default(!1).describe(`Enable automatic token rotation.`)}).optional().describe(`Settings for the Slack app.`)});function ee(e,t){let n={...t,...e};for(let r of Object.keys(n))r in e&&r in t&&(n[r]=(n,i)=>e[r](n,()=>t[r](n,i)));return n}const te=e=>({fn(t,n){return t?(...r)=>{let i;return t(e,()=>{i=n(...r)}),i}:n},asyncFn(t,n){return t?(...r)=>{let i;return f(()=>t(e,()=>(i=n(...r),h(i)?i.then(()=>void 0):void 0)),()=>i)}:n}});var ne=class extends Error{error;suppressed;constructor(e,t,n){super(n),this.error=e,this.suppressed=t,this.name=`SuppressedError`,Error.captureStackTrace(this,this.constructor)}};const H={get dispose(){return Symbol.dispose||Symbol.for(`dispose`)},get asyncDispose(){return Symbol.asyncDispose||Symbol.for(`asyncDispose`)}};function re(e){return e?.[H.dispose]!=null}function ie(e){return e?.[H.asyncDispose]!=null}const ae=globalThis.SuppressedError||ne;var oe=class e{callbacks=[];get disposed(){return this.callbacks.length===0}use(e){return ie(e)?this.callbacks.push(()=>e[H.asyncDispose]()):re(e)&&this.callbacks.push(()=>e[H.dispose]()),e}adopt(e,t){return t&&this.callbacks.push(()=>t(e)),e}defer(e){e&&this.callbacks.push(e)}move(){let t=new e;return t.callbacks=this.callbacks,this.callbacks=[],t}disposeAsync(){return this[H.asyncDispose]()}_error;_iterateCallbacks(){let e=this.callbacks.pop();if(e)return f(e,()=>this._iterateCallbacks(),e=>(this._error=this._error?new ae(e,this._error):e,this._iterateCallbacks()))}[H.asyncDispose](){let e=this._iterateCallbacks();if(e?.then)return e.then(()=>{if(this._error){let e=this._error;throw this._error=void 0,e}});if(this._error){let e=this._error;throw this._error=void 0,e}}[Symbol.toStringTag]=`AsyncDisposableStack`};globalThis.SuppressedError,H.dispose,Symbol.toStringTag,globalThis.DisposableStack;const se=globalThis.AsyncDisposableStack||oe;globalThis.SuppressedError;var ce=e(((e,t)=>{function n(){return Object.keys(globalThis).some(e=>e.startsWith(`__NEXT`))}t.exports=function(){return!!(globalThis.Deno||globalThis.Bun||n())}})),le=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>n(e,`name`,{value:t,configurable:!0}),s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{URLPattern:()=>J}),t.exports=l(u);var d=class{type=3;name=``;prefix=``;value=``;suffix=``;modifier=3;constructor(e,t,n,r,i,a){this.type=e,this.name=t,this.prefix=n,this.value=r,this.suffix=i,this.modifier=a}hasCustomName(){return this.name!==``&&typeof this.name!=`number`}};o(d,`Part`);var f=/[$_\p{ID_Start}]/u,p=/[$_\u200C\u200D\p{ID_Continue}]/u,m=`.*`;function h(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}o(h,`isASCII`);function g(e,t=!1){let n=[],r=0;for(;r<e.length;){let i=e[r],a=o(function(i){if(!t)throw TypeError(i);n.push({type:`INVALID_CHAR`,index:r,value:e[r++]})},`ErrorOrInvalid`);if(i===`*`){n.push({type:`ASTERISK`,index:r,value:e[r++]});continue}if(i===`+`||i===`?`){n.push({type:`OTHER_MODIFIER`,index:r,value:e[r++]});continue}if(i===`\\`){n.push({type:`ESCAPED_CHAR`,index:r++,value:e[r++]});continue}if(i===`{`){n.push({type:`OPEN`,index:r,value:e[r++]});continue}if(i===`}`){n.push({type:`CLOSE`,index:r,value:e[r++]});continue}if(i===`:`){let t=``,i=r+1;for(;i<e.length;){let n=e.substr(i,1);if(i===r+1&&f.test(n)||i!==r+1&&p.test(n)){t+=e[i++];continue}break}if(!t){a(`Missing parameter name at ${r}`);continue}n.push({type:`NAME`,index:r,value:t}),r=i;continue}if(i===`(`){let t=1,i=``,o=r+1,s=!1;if(e[o]===`?`){a(`Pattern cannot start with "?" at ${o}`);continue}for(;o<e.length;){if(!h(e[o],!1)){a(`Invalid character '${e[o]}' at ${o}.`),s=!0;break}if(e[o]===`\\`){i+=e[o++]+e[o++];continue}if(e[o]===`)`){if(t--,t===0){o++;break}}else if(e[o]===`(`&&(t++,e[o+1]!==`?`)){a(`Capturing groups are not allowed at ${o}`),s=!0;break}i+=e[o++]}if(s)continue;if(t){a(`Unbalanced pattern at ${r}`);continue}if(!i){a(`Missing pattern at ${r}`);continue}n.push({type:`REGEX`,index:r,value:i}),r=o;continue}n.push({type:`CHAR`,index:r,value:e[r++]})}return n.push({type:`END`,index:r,value:``}),n}o(g,`lexer`);function _(e,t={}){let n=g(e);t.delimiter??=`/#?`,t.prefixes??=`./`;let r=`[^${v(t.delimiter)}]+?`,i=[],a=0,s=0,c=new Set,l=o(e=>{if(s<n.length&&n[s].type===e)return n[s++].value},`tryConsume`),u=o(()=>l(`OTHER_MODIFIER`)??l(`ASTERISK`),`tryConsumeModifier`),f=o(e=>{let t=l(e);if(t!==void 0)return t;let{type:r,index:i}=n[s];throw TypeError(`Unexpected ${r} at ${i}, expected ${e}`)},`mustConsume`),p=o(()=>{let e=``,t;for(;t=l(`CHAR`)??l(`ESCAPED_CHAR`);)e+=t;return e},`consumeText`),h=o(e=>e,`DefaultEncodePart`),_=t.encodePart||h,y=``,b=o(e=>{y+=e},`appendToPendingFixedValue`),x=o(()=>{y.length&&(i.push(new d(3,``,``,_(y),``,3)),y=``)},`maybeAddPartFromPendingFixedValue`),S=o((e,t,n,o,s)=>{let l=3;switch(s){case`?`:l=1;break;case`*`:l=0;break;case`+`:l=2;break}if(!t&&!n&&l===3){b(e);return}if(x(),!t&&!n){if(!e)return;i.push(new d(3,``,``,_(e),``,l));return}let u;u=n?n===`*`?m:n:r;let f=2;u===r?(f=1,u=``):u===m&&(f=0,u=``);let p;if(t?p=t:n&&(p=a++),c.has(p))throw TypeError(`Duplicate name '${p}'.`);c.add(p),i.push(new d(f,p,_(e),u,_(o),l))},`addPart`);for(;s<n.length;){let e=l(`CHAR`),n=l(`NAME`),r=l(`REGEX`);if(!n&&!r&&(r=l(`ASTERISK`)),n||r){let i=e??``;t.prefixes.indexOf(i)===-1&&(b(i),i=``),x();let a=u();S(i,n,r,``,a);continue}let i=e??l(`ESCAPED_CHAR`);if(i){b(i);continue}if(l(`OPEN`)){let e=p(),t=l(`NAME`),n=l(`REGEX`);!t&&!n&&(n=l(`ASTERISK`));let r=p();f(`CLOSE`);let i=u();S(e,t,n,r,i);continue}x(),f(`END`)}return i}o(_,`parse`);function v(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,`\\$1`)}o(v,`escapeString`);function y(e){return e&&e.ignoreCase?`ui`:`u`}o(y,`flags`);function b(e,t,n){return S(_(e,n),t,n)}o(b,`stringToRegexp`);function x(e){switch(e){case 0:return`*`;case 1:return`?`;case 2:return`+`;case 3:return``}}o(x,`modifierToString`);function S(e,t,n={}){n.delimiter??=`/#?`,n.prefixes??=`./`,n.sensitive??=!1,n.strict??=!1,n.end??=!0,n.start??=!0,n.endsWith=``;let r=n.start?`^`:``;for(let i of e){if(i.type===3){i.modifier===3?r+=v(i.value):r+=`(?:${v(i.value)})${x(i.modifier)}`;continue}t&&t.push(i.name);let e=`[^${v(n.delimiter)}]+?`,a=i.value;if(i.type===1?a=e:i.type===0&&(a=m),!i.prefix.length&&!i.suffix.length){i.modifier===3||i.modifier===1?r+=`(${a})${x(i.modifier)}`:r+=`((?:${a})${x(i.modifier)})`;continue}if(i.modifier===3||i.modifier===1){r+=`(?:${v(i.prefix)}(${a})${v(i.suffix)})`,r+=x(i.modifier);continue}r+=`(?:${v(i.prefix)}`,r+=`((?:${a})(?:`,r+=v(i.suffix),r+=v(i.prefix),r+=`(?:${a}))*)${v(i.suffix)})`,i.modifier===0&&(r+=`?`)}let i=`[${v(n.endsWith)}]|$`,a=`[${v(n.delimiter)}]`;if(n.end)return n.strict||(r+=`${a}?`),n.endsWith.length?r+=`(?=${i})`:r+=`$`,new RegExp(r,y(n));n.strict||(r+=`(?:${a}(?=${i}))?`);let o=!1;if(e.length){let t=e[e.length-1];t.type===3&&t.modifier===3&&(o=n.delimiter.indexOf(t)>-1)}return o||(r+=`(?=${a}|${i})`),new RegExp(r,y(n))}o(S,`partsToRegexp`);var C={delimiter:``,prefixes:``,sensitive:!0,strict:!0},w={delimiter:`.`,prefixes:``,sensitive:!0,strict:!0},T={delimiter:`/`,prefixes:`/`,sensitive:!0,strict:!0};function E(e,t){return e.length?e[0]===`/`?!0:!t||e.length<2?!1:(e[0]==`\\`||e[0]==`{`)&&e[1]==`/`:!1}o(E,`isAbsolutePathname`);function D(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}o(D,`maybeStripPrefix`);function O(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}o(O,`maybeStripSuffix`);function k(e){return!e||e.length<2?!1:e[0]===`[`||(e[0]===`\\`||e[0]===`{`)&&e[1]===`[`}o(k,`treatAsIPv6Hostname`);var A=[`ftp`,`file`,`http`,`https`,`ws`,`wss`];function j(e){if(!e)return!0;for(let t of A)if(e.test(t))return!0;return!1}o(j,`isSpecialScheme`);function M(e,t){if(e=D(e,`#`),t||e===``)return e;let n=new URL(`https://example.com`);return n.hash=e,n.hash?n.hash.substring(1,n.hash.length):``}o(M,`canonicalizeHash`);function N(e,t){if(e=D(e,`?`),t||e===``)return e;let n=new URL(`https://example.com`);return n.search=e,n.search?n.search.substring(1,n.search.length):``}o(N,`canonicalizeSearch`);function P(e,t){return t||e===``?e:k(e)?H(e):ne(e)}o(P,`canonicalizeHostname`);function F(e,t){if(t||e===``)return e;let n=new URL(`https://example.com`);return n.password=e,n.password}o(F,`canonicalizePassword`);function I(e,t){if(t||e===``)return e;let n=new URL(`https://example.com`);return n.username=e,n.username}o(I,`canonicalizeUsername`);function L(e,t,n){if(n||e===``)return e;if(t&&!A.includes(t))return new URL(`${t}:${e}`).pathname;let r=e[0]==`/`;return e=new URL(r?e:`/-`+e,`https://example.com`).pathname,r||(e=e.substring(2,e.length)),e}o(L,`canonicalizePathname`);function R(e,t,n){return B(t)===e&&(e=``),n||e===``?e:re(e)}o(R,`canonicalizePort`);function z(e,t){return e=O(e,`:`),t||e===``?e:V(e)}o(z,`canonicalizeProtocol`);function B(e){switch(e){case`ws`:case`http`:return`80`;case`wws`:case`https`:return`443`;case`ftp`:return`21`;default:return``}}o(B,`defaultPortForProtocol`);function V(e){if(e===``)return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw TypeError(`Invalid protocol '${e}'.`)}o(V,`protocolEncodeCallback`);function ee(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.username=e,t.username}o(ee,`usernameEncodeCallback`);function te(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.password=e,t.password}o(te,`passwordEncodeCallback`);function ne(e){if(e===``)return e;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(e))throw TypeError(`Invalid hostname '${e}'`);let t=new URL(`https://example.com`);return t.hostname=e,t.hostname}o(ne,`hostnameEncodeCallback`);function H(e){if(e===``)return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw TypeError(`Invalid IPv6 hostname '${e}'`);return e.toLowerCase()}o(H,`ipv6HostnameEncodeCallback`);function re(e){if(e===``||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw TypeError(`Invalid port '${e}'.`)}o(re,`portEncodeCallback`);function ie(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.pathname=e[0]===`/`?e:`/-`+e,e[0]===`/`?t.pathname:t.pathname.substring(2,t.pathname.length)}o(ie,`standardURLPathnameEncodeCallback`);function ae(e){return e===``?e:new URL(`data:${e}`).pathname}o(ae,`pathURLPathnameEncodeCallback`);function oe(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.search=e,t.search.substring(1,t.search.length)}o(oe,`searchEncodeCallback`);function se(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.hash=e,t.hash.substring(1,t.hash.length)}o(se,`hashEncodeCallback`);var ce=class{#i;#n=[];#t={};#e=0;#s=1;#l=0;#o=0;#d=0;#p=0;#g=!1;constructor(e){this.#i=e}get result(){return this.#t}parse(){for(this.#n=g(this.#i,!0);this.#e<this.#n.length;this.#e+=this.#s){if(this.#s=1,this.#n[this.#e].type===`END`){if(this.#o===0){this.#b(),this.#f()?this.#r(9,1):this.#h()?this.#r(8,1):this.#r(7,0);continue}else if(this.#o===2){this.#u(5);continue}this.#r(10,0);break}if(this.#d>0)if(this.#A())--this.#d;else continue;if(this.#T()){this.#d+=1;continue}switch(this.#o){case 0:this.#P()&&this.#u(1);break;case 1:if(this.#P()){this.#C();let e=7,t=1;this.#E()?(e=2,t=3):this.#g&&(e=2),this.#r(e,t)}break;case 2:this.#S()?this.#u(3):(this.#x()||this.#h()||this.#f())&&this.#u(5);break;case 3:this.#O()?this.#r(4,1):this.#S()&&this.#r(5,1);break;case 4:this.#S()&&this.#r(5,1);break;case 5:this.#y()?this.#p+=1:this.#w()&&--this.#p,this.#k()&&!this.#p?this.#r(6,1):this.#x()?this.#r(7,0):this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 6:this.#x()?this.#r(7,0):this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 7:this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 8:this.#f()&&this.#r(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port=``)}#r(e,t){switch(this.#o){case 0:break;case 1:this.#t.protocol=this.#c();break;case 2:break;case 3:this.#t.username=this.#c();break;case 4:this.#t.password=this.#c();break;case 5:this.#t.hostname=this.#c();break;case 6:this.#t.port=this.#c();break;case 7:this.#t.pathname=this.#c();break;case 8:this.#t.search=this.#c();break;case 9:this.#t.hash=this.#c();break;case 10:break}this.#o!==0&&e!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(e)&&(this.#t.hostname??=``),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(e)&&(this.#t.pathname??=this.#g?`/`:``),[1,2,3,4,5,6,7].includes(this.#o)&&e===9&&(this.#t.search??=``)),this.#R(e,t)}#R(e,t){this.#o=e,this.#l=this.#e+t,this.#e+=t,this.#s=0}#b(){this.#e=this.#l,this.#s=0}#u(e){this.#b(),this.#o=e}#m(e){return e<0&&(e=this.#n.length-e),e<this.#n.length?this.#n[e]:this.#n[this.#n.length-1]}#a(e,t){let n=this.#m(e);return n.value===t&&(n.type===`CHAR`||n.type===`ESCAPED_CHAR`||n.type===`INVALID_CHAR`)}#P(){return this.#a(this.#e,`:`)}#E(){return this.#a(this.#e+1,`/`)&&this.#a(this.#e+2,`/`)}#S(){return this.#a(this.#e,`@`)}#O(){return this.#a(this.#e,`:`)}#k(){return this.#a(this.#e,`:`)}#x(){return this.#a(this.#e,`/`)}#h(){if(this.#a(this.#e,`?`))return!0;if(this.#n[this.#e].value!==`?`)return!1;let e=this.#m(this.#e-1);return e.type!==`NAME`&&e.type!==`REGEX`&&e.type!==`CLOSE`&&e.type!==`ASTERISK`}#f(){return this.#a(this.#e,`#`)}#T(){return this.#n[this.#e].type==`OPEN`}#A(){return this.#n[this.#e].type==`CLOSE`}#y(){return this.#a(this.#e,`[`)}#w(){return this.#a(this.#e,`]`)}#c(){let e=this.#n[this.#e],t=this.#m(this.#l).index;return this.#i.substring(t,e.index)}#C(){let e={};Object.assign(e,C),e.encodePart=V;let t=b(this.#c(),void 0,e);this.#g=j(t)}};o(ce,`Parser`);var le=[`protocol`,`username`,`password`,`hostname`,`port`,`pathname`,`search`,`hash`],U=`*`;function W(e,t){if(typeof e!=`string`)throw TypeError(`parameter 1 is not of type 'string'.`);let n=new URL(e,t);return{protocol:n.protocol.substring(0,n.protocol.length-1),username:n.username,password:n.password,hostname:n.hostname,port:n.port,pathname:n.pathname,search:n.search===``?void 0:n.search.substring(1,n.search.length),hash:n.hash===``?void 0:n.hash.substring(1,n.hash.length)}}o(W,`extractValues`);function G(e,t){return t?q(e):e}o(G,`processBaseURLString`);function K(e,t,n){let r;if(typeof t.baseURL==`string`)try{r=new URL(t.baseURL),t.protocol===void 0&&(e.protocol=G(r.protocol.substring(0,r.protocol.length-1),n)),!n&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&(e.username=G(r.username,n)),!n&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&t.password===void 0&&(e.password=G(r.password,n)),t.protocol===void 0&&t.hostname===void 0&&(e.hostname=G(r.hostname,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&(e.port=G(r.port,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&(e.pathname=G(r.pathname,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&(e.search=G(r.search.substring(1,r.search.length),n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&t.hash===void 0&&(e.hash=G(r.hash.substring(1,r.hash.length),n))}catch{throw TypeError(`invalid baseURL '${t.baseURL}'.`)}if(typeof t.protocol==`string`&&(e.protocol=z(t.protocol,n)),typeof t.username==`string`&&(e.username=I(t.username,n)),typeof t.password==`string`&&(e.password=F(t.password,n)),typeof t.hostname==`string`&&(e.hostname=P(t.hostname,n)),typeof t.port==`string`&&(e.port=R(t.port,e.protocol,n)),typeof t.pathname==`string`){if(e.pathname=t.pathname,r&&!E(e.pathname,n)){let t=r.pathname.lastIndexOf(`/`);t>=0&&(e.pathname=G(r.pathname.substring(0,t+1),n)+e.pathname)}e.pathname=L(e.pathname,e.protocol,n)}return typeof t.search==`string`&&(e.search=N(t.search,n)),typeof t.hash==`string`&&(e.hash=M(t.hash,n)),e}o(K,`applyInit`);function q(e){return e.replace(/([+*?:{}()\\])/g,`\\$1`)}o(q,`escapePatternString`);function ue(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,`\\$1`)}o(ue,`escapeRegexpString`);function de(e,t){t.delimiter??=`/#?`,t.prefixes??=`./`,t.sensitive??=!1,t.strict??=!1,t.end??=!0,t.start??=!0,t.endsWith=``;let n=`[^${ue(t.delimiter)}]+?`,r=/[$_\u200C\u200D\p{ID_Continue}]/u,i=``;for(let a=0;a<e.length;++a){let o=e[a];if(o.type===3){if(o.modifier===3){i+=q(o.value);continue}i+=`{${q(o.value)}}${x(o.modifier)}`;continue}let s=o.hasCustomName(),c=!!o.suffix.length||!!o.prefix.length&&(o.prefix.length!==1||!t.prefixes.includes(o.prefix)),l=a>0?e[a-1]:null,u=a<e.length-1?e[a+1]:null;if(!c&&s&&o.type===1&&o.modifier===3&&u&&!u.prefix.length&&!u.suffix.length)if(u.type===3){let e=u.value.length>0?u.value[0]:``;c=r.test(e)}else c=!u.hasCustomName();if(!c&&!o.prefix.length&&l&&l.type===3){let e=l.value[l.value.length-1];c=t.prefixes.includes(e)}c&&(i+=`{`),i+=q(o.prefix),s&&(i+=`:${o.name}`),o.type===2?i+=`(${o.value})`:o.type===1?s||(i+=`(${n})`):o.type===0&&(!s&&(!l||l.type===3||l.modifier!==3||c||o.prefix!==``)?i+=`*`:i+=`(.*)`),o.type===1&&s&&o.suffix.length&&r.test(o.suffix[0])&&(i+=`\\`),i+=q(o.suffix),c&&(i+=`}`),o.modifier!==3&&(i+=x(o.modifier))}return i}o(de,`partsToPattern`);var J=class{#i;#n={};#t={};#e={};#s={};#l=!1;constructor(e={},t,n){try{let r;if(typeof t==`string`?r=t:n=t,typeof e==`string`){let t=new ce(e);if(t.parse(),e=t.result,r===void 0&&typeof e.protocol!=`string`)throw TypeError(`A base URL must be provided for a relative constructor string.`);e.baseURL=r}else{if(!e||typeof e!=`object`)throw TypeError(`parameter 1 is not of type 'string' and cannot convert to dictionary.`);if(r)throw TypeError(`parameter 1 is not of type 'string'.`)}typeof n>`u`&&(n={ignoreCase:!1});let i={ignoreCase:n.ignoreCase===!0};this.#i=K({pathname:U,protocol:U,username:U,password:U,hostname:U,port:U,search:U,hash:U},e,!0),B(this.#i.protocol)===this.#i.port&&(this.#i.port=``);let a;for(a of le){if(!(a in this.#i))continue;let e={},t=this.#i[a];switch(this.#t[a]=[],a){case`protocol`:Object.assign(e,C),e.encodePart=V;break;case`username`:Object.assign(e,C),e.encodePart=ee;break;case`password`:Object.assign(e,C),e.encodePart=te;break;case`hostname`:Object.assign(e,w),k(t)?e.encodePart=H:e.encodePart=ne;break;case`port`:Object.assign(e,C),e.encodePart=re;break;case`pathname`:j(this.#n.protocol)?(Object.assign(e,T,i),e.encodePart=ie):(Object.assign(e,C,i),e.encodePart=ae);break;case`search`:Object.assign(e,C,i),e.encodePart=oe;break;case`hash`:Object.assign(e,C,i),e.encodePart=se;break}try{this.#s[a]=_(t,e),this.#n[a]=S(this.#s[a],this.#t[a],e),this.#e[a]=de(this.#s[a],e),this.#l=this.#l||this.#s[a].some(e=>e.type===2)}catch{throw TypeError(`invalid ${a} pattern '${this.#i[a]}'.`)}}}catch(e){throw TypeError(`Failed to construct 'URLPattern': ${e.message}`)}}get[Symbol.toStringTag](){return`URLPattern`}test(e={},t){let n={pathname:``,protocol:``,username:``,password:``,hostname:``,port:``,search:``,hash:``};if(typeof e!=`string`&&t)throw TypeError(`parameter 1 is not of type 'string'.`);if(typeof e>`u`)return!1;try{n=typeof e==`object`?K(n,e,!1):K(n,W(e,t),!1)}catch{return!1}let r;for(r of le)if(!this.#n[r].exec(n[r]))return!1;return!0}exec(e={},t){let n={pathname:``,protocol:``,username:``,password:``,hostname:``,port:``,search:``,hash:``};if(typeof e!=`string`&&t)throw TypeError(`parameter 1 is not of type 'string'.`);if(typeof e>`u`)return;try{n=typeof e==`object`?K(n,e,!1):K(n,W(e,t),!1)}catch{return null}let r={};t?r.inputs=[e,t]:r.inputs=[e];let i;for(i of le){let e=this.#n[i].exec(n[i]);if(!e)return null;let t={};for(let[n,r]of this.#t[i].entries())(typeof r==`string`||typeof r==`number`)&&(t[r]=e[n+1]);r[i]={input:n[i]??``,groups:t}}return r}static compareComponent(e,t,n){let r=o((e,t)=>{for(let n of[`type`,`modifier`,`prefix`,`value`,`suffix`]){if(e[n]<t[n])return-1;if(e[n]!==t[n])return 1}return 0},`comparePart`),i=new d(3,``,``,``,``,3),a=new d(0,``,``,``,``,3),s=o((e,t)=>{let n=0;for(;n<Math.min(e.length,t.length);++n){let i=r(e[n],t[n]);if(i)return i}return e.length===t.length?0:r(e[n]??i,t[n]??i)},`comparePartList`);return!t.#e[e]&&!n.#e[e]?0:t.#e[e]&&!n.#e[e]?s(t.#s[e],[a]):!t.#e[e]&&n.#e[e]?s([a],n.#s[e]):s(t.#s[e],n.#s[e])}get protocol(){return this.#e.protocol}get username(){return this.#e.username}get password(){return this.#e.password}get hostname(){return this.#e.hostname}get port(){return this.#e.port}get pathname(){return this.#e.pathname}get search(){return this.#e.search}get hash(){return this.#e.hash}get hasRegExpGroups(){return this.#l}};o(J,`URLPattern`)})),U=e(((e,t)=>{let{URLPattern:n}=le();t.exports={URLPattern:n},globalThis.URLPattern||(globalThis.URLPattern=n)})),W=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isPromise=n,e.isActualPromise=r,e.handleMaybePromise=i,e.fakePromise=a,e.createDeferredPromise=o,e.iterateAsync=s,e.iterateAsyncVoid=s,e.fakeRejectPromise=c,e.mapMaybePromise=l,e.mapAsyncIterator=u,e.promiseLikeFinally=m,e.unfakePromise=h;let t=Symbol.for(`@whatwg-node/promise-helpers/FakePromise`);function n(e){return e?.then!=null}function r(e){let t=e;return t&&t.then&&t.catch&&t.finally}function i(e,t,n,r){let i=a().then(e).then(t,n);return r&&(i=i.finally(r)),h(i)}function a(e){return e&&r(e)?e:n(e)?{then:(t,n)=>a(e.then(t,n)),catch:t=>a(e.then(e=>e,t)),finally:t=>a(t?m(e,t):e),[Symbol.toStringTag]:`Promise`}:{then(t){if(t)try{return a(t(e))}catch(e){return c(e)}return this},catch(){return this},finally(t){if(t)try{return a(t()).then(()=>e,()=>e)}catch(e){return c(e)}return this},[Symbol.toStringTag]:`Promise`,__fakePromiseValue:e,[t]:`resolved`}}function o(){if(Promise.withResolvers)return Promise.withResolvers();let e,t;return{promise:new Promise(function(n,r){e=n,t=r}),get resolve(){return e},get reject(){return t}}}function s(e,t,n){if(e?.length===0)return;let r=e[Symbol.iterator](),a=0;function o(){let{done:e,value:s}=r.next();if(e)return;let c=!1;function l(){c=!0}return i(function(){return t(s,l,a++)},function(e){if(e&&n?.push(e),!c)return o()})}return o()}function c(e){return{then(t,n){if(n)try{return a(n(e))}catch(e){return c(e)}return this},catch(t){if(t)try{return a(t(e))}catch(e){return c(e)}return this},finally(e){if(e)try{e()}catch(e){return c(e)}return this},__fakeRejectError:e,[Symbol.toStringTag]:`Promise`,[t]:`rejected`}}function l(e,t,n){return i(()=>e,t,n)}function u(e,t,n,r){Symbol.asyncIterator in e&&(e=e[Symbol.asyncIterator]());let o,s,l;if(r){let e;l=t=>(e||=i(r,()=>t,()=>t),e)}typeof e.return==`function`&&(o=e.return,s=t=>{let n=()=>{throw t};return o.call(e).then(n,n)});function u(e){return e.done?l?l(e):e:i(()=>e.value,e=>i(()=>t(e),d,s))}let f;if(n){let e,t=n;f=n=>(e||=i(()=>n,e=>i(()=>t(e),d,s)),e)}return{next(){return e.next().then(u,f)},return(){let t=o?o.call(e).then(u,f):a({value:void 0,done:!0});return l?t.then(l):t},throw(t){return typeof e.throw==`function`?e.throw(t).then(u,f):s?s(t):c(t)},[Symbol.asyncIterator](){return this}}}function d(e){return{value:e,done:!1}}function f(e){return e?.[t]===`resolved`}function p(e){return e?.[t]===`rejected`}function m(e,t){return`finally`in e?e.finally(t):e.then(e=>{let r=t();return n(r)?r.then(()=>e):e},e=>{let r=t();if(n(r))return r.then(()=>{throw e});throw e})}function h(e){if(f(e))return e.__fakePromiseValue;if(p(e))throw e.__fakeRejectError;return e}})),G=e(((e,t)=>{let{EventEmitter:n}=r(`node:events`),{inherits:i}=r(`node:util`);function a(e){if(typeof e==`string`&&(e=Buffer.from(e)),!Buffer.isBuffer(e))throw TypeError(`The needle has to be a String or a Buffer.`);let t=e.length,n=t-1;if(t===0)throw Error(`The needle cannot be an empty String/Buffer.`);if(t>256)throw Error(`The needle cannot have a length bigger than 256.`);this.maxMatches=1/0,this.matches=0,this._occ=new Uint8Array(256).fill(t),this._lookbehind_size=0,this._needle=e,this._bufpos=0,this._lookbehind=Buffer.alloc(n);for(var r=0;r<n;++r)this._occ[e[r]]=n-r}i(a,n),a.prototype.reset=function(){this._lookbehind_size=0,this.matches=0,this._bufpos=0},a.prototype.push=function(e,t){Buffer.isBuffer(e)||(e=Buffer.from(e,`binary`));let n=e.length;this._bufpos=t||0;let r;for(;r!==n&&this.matches<this.maxMatches;)r=this._sbmh_feed(e);return r},a.prototype._sbmh_feed=function(e){let t=e.length,n=this._needle,r=n.length,i=r-1,a=n[i],o=-this._lookbehind_size,s;if(o<0){for(;o<0&&o<=t-r;){if(s=e[o+i],s===a&&this._sbmh_memcmp(e,o,i))return this._lookbehind_size=0,++this.matches,this.emit(`info`,!0),this._bufpos=o+r;o+=this._occ[s]}for(;o<0&&!this._sbmh_memcmp(e,o,t-o);)++o;if(o>=0)this.emit(`info`,!1,this._lookbehind,0,this._lookbehind_size),this._lookbehind_size=0;else{let n=this._lookbehind_size+o;return n>0&&this.emit(`info`,!1,this._lookbehind,0,n),this._lookbehind_size-=n,this._lookbehind.copy(this._lookbehind,0,n,this._lookbehind_size),e.copy(this._lookbehind,this._lookbehind_size),this._lookbehind_size+=t,this._bufpos=t,t}}if(o=e.indexOf(n,o+this._bufpos),o!==-1)return++this.matches,o===0?this.emit(`info`,!0):this.emit(`info`,!0,e,this._bufpos,o),this._bufpos=o+r;for(o=t-i,o<0&&(o=0);o!==t&&(e[o]!==n[0]||Buffer.compare(e.subarray(o+1,t),n.subarray(1,t-o))!==0);)++o;return o!==t&&(e.copy(this._lookbehind,0,o,t),this._lookbehind_size=t-o),o!==0&&this.emit(`info`,!1,e,this._bufpos,o),this._bufpos=t,t},a.prototype._sbmh_lookup_char=function(e,t){return t<0?this._lookbehind[this._lookbehind_size+t]:e[t]},a.prototype._sbmh_memcmp=function(e,t,n){for(var r=0;r<n;++r)if(this._sbmh_lookup_char(e,t+r)!==this._needle[r])return!1;return!0},t.exports=a})),K=e(((e,t)=>{let n=r(`node:util`).inherits,i=r(`node:stream`).Readable;function a(e){i.call(this,e)}n(a,i),a.prototype._read=function(e){},t.exports=a})),q=e(((e,t)=>{t.exports=function(e,t,n){if(!e||e[t]===void 0||e[t]===null)return n;if(typeof e[t]!=`number`||isNaN(e[t]))throw TypeError(`Limit `+t+` is not a valid number`);return e[t]}})),ue=e(((e,t)=>{let n=r(`node:events`).EventEmitter,i=r(`node:util`).inherits,a=q(),o=G(),s=Buffer.from(`\r
|
|
1
|
+
import{__commonJSMin as e,__esmMin as t,__export as n,__require as r,__toCommonJS as i,__toESM as a}from"./chunk-D9KrCrVq.js";import{completeAssign as o,createCustomAbortControllerSignal as s,ensureDisposableStackRegisteredForTerminateEvents as c,fakePromise as l,handleAbortSignalAndPromiseResponse as u,handleErrorFromRequestHandler as d,handleMaybePromise as f,isFetchEvent as p,isNodeRequest as m,isPromise as h,isRequestInit as g,isServerResponse as _,isolateObject as v,iterateAsync as y,normalizeNodeRequest as b,sendNodeResponse as x,unfakePromise as S}from"./utils-BWKsfIcI.js";import C from"http";import{dirname as w,join as T}from"path";import{existsSync as E,mkdirSync as D,readFileSync as O,unlinkSync as k,writeFileSync as A}from"fs";import{z as j}from"zod";function M(e){return T(e,`.blink`,`devhook.txt`)}function N(e){return E(M(e))}function P(e){let t=M(e);if(E(t))return O(t,`utf-8`).trim()}function F(e){let t=M(e);if(D(w(t),{recursive:!0}),E(t))return O(t,`utf-8`);let n=crypto.randomUUID();return A(t,n),n}function I(e){let t=M(e);E(t)&&k(t)}function L(e){return`https://api.slack.com/apps?new_app=1&manifest_json=${encodeURIComponent(JSON.stringify(e))}`}const R=j.union([j.literal(`app_mention`).describe(`Bot is @mentioned in a channel or conversation. Requires scope: app_mentions:read`),j.literal(`app_home_opened`).describe(`User opened the app's Home tab. No additional scope required beyond bot token`),j.literal(`app_installed`).describe(`App was installed to a workspace. No additional scope required beyond bot token`),j.literal(`app_uninstalled`).describe(`App was uninstalled from a workspace. No additional scope required beyond bot token`),j.literal(`assistant_thread_context_changed`).describe(`Context changed in an assistant thread. Requires scope: assistant:write`),j.literal(`assistant_thread_started`).describe(`New assistant thread was started. Requires scope: assistant:write`),j.literal(`channel_archive`).describe(`Public channel was archived. Requires scope: channels:read`),j.literal(`channel_created`).describe(`Public channel was created. Requires scope: channels:read`),j.literal(`channel_deleted`).describe(`Public channel was deleted. Requires scope: channels:read`),j.literal(`channel_rename`).describe(`Public channel was renamed. Requires scope: channels:read`),j.literal(`channel_unarchive`).describe(`Public channel was unarchived. Requires scope: channels:read`),j.literal(`dnd_updated_user`).describe(`User's Do Not Disturb settings changed. Requires scope: dnd:read`),j.literal(`email_domain_changed`).describe(`Workspace's email domain changed. Requires scope: team:read`),j.literal(`emoji_changed`).describe(`Custom emoji was added or changed. Requires scope: emoji:read`),j.literal(`file_change`).describe(`File was changed. Requires scope: files:read`),j.literal(`file_created`).describe(`File was created. Requires scope: files:read`),j.literal(`file_deleted`).describe(`File was deleted. Requires scope: files:read`),j.literal(`file_public`).describe(`File was made public. Requires scope: files:read`),j.literal(`file_shared`).describe(`File was shared. Requires scope: files:read`),j.literal(`file_unshared`).describe(`File was unshared. Requires scope: files:read`),j.literal(`group_archive`).describe(`Private channel was archived. Requires scope: groups:read`),j.literal(`group_deleted`).describe(`Private channel was deleted. Requires scope: groups:read`),j.literal(`group_rename`).describe(`Private channel was renamed. Requires scope: groups:read`),j.literal(`group_unarchive`).describe(`Private channel was unarchived. Requires scope: groups:read`),j.literal(`link_shared`).describe(`Link from a registered domain was shared. Requires scope: links:read`),j.literal(`member_joined_channel`).describe(`User joined a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),j.literal(`member_left_channel`).describe(`User left a public or private channel. Requires scope: channels:read (public) or groups:read (private)`),j.literal(`message.channels`).describe(`Message was posted in a public channel. Requires scope: channels:history`),j.literal(`message.groups`).describe(`Message was posted in a private channel. Requires scope: groups:history`),j.literal(`message.im`).describe(`Message was posted in a direct message. Requires scope: im:history`),j.literal(`message.mpim`).describe(`Message was posted in a multi-party direct message. Requires scope: mpim:history`),j.literal(`pin_added`).describe(`Item was pinned in a channel. Requires scope: pins:read`),j.literal(`pin_removed`).describe(`Item was unpinned from a channel. Requires scope: pins:read`),j.literal(`reaction_added`).describe(`Reaction was added to a message. Requires scope: reactions:read`),j.literal(`reaction_removed`).describe(`Reaction was removed from a message. Requires scope: reactions:read`),j.literal(`team_join`).describe(`New user joined the workspace. Requires scope: users:read`),j.literal(`user_change`).describe(`User's profile or settings changed. Requires scope: users:read`)]),z=j.union([j.literal(`app_mentions:read`).describe(`Read messages that directly mention the bot. Required for: app_mention event`),j.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`),j.literal(`channels:history`).describe(`Read message history in public channels the bot has access to. Required for: message.channels event`),j.literal(`channels:join`).describe(`Join public channels`),j.literal(`channels:manage`).describe(`Manage public channels (archive, rename, etc.)`),j.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`),j.literal(`chat:write`).describe(`Send messages as the bot`),j.literal(`chat:write.customize`).describe(`Send messages with a customized username and avatar`),j.literal(`chat:write.public`).describe(`Send messages to public channels without joining`),j.literal(`commands`).describe(`Add and use slash commands`),j.literal(`dnd:read`).describe(`View Do Not Disturb settings for users. Required for: dnd_updated_user event`),j.literal(`emoji:read`).describe(`View custom emoji in the workspace. Required for: emoji_changed event`),j.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`),j.literal(`files:write`).describe(`Upload, edit, and delete files`),j.literal(`groups:history`).describe(`Read message history in private channels the bot has access to. Required for: message.groups event`),j.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`),j.literal(`groups:write`).describe(`Manage private channels (archive, rename, create, etc.)`),j.literal(`im:history`).describe(`Read message history in direct messages with the bot. Required for: message.im event`),j.literal(`im:read`).describe(`View basic information about direct messages with the bot`),j.literal(`im:write`).describe(`Start and manage direct messages with users`),j.literal(`links:read`).describe(`View URLs in messages. Required for: link_shared event`),j.literal(`links:write`).describe(`Show previews of URLs (unfurling)`),j.literal(`metadata.message:read`).describe(`Read message metadata`),j.literal(`mpim:history`).describe(`Read message history in multi-party direct messages. Required for: message.mpim event`),j.literal(`mpim:read`).describe(`View basic information about multi-party direct messages`),j.literal(`mpim:write`).describe(`Start and manage multi-party direct messages`),j.literal(`pins:read`).describe(`View pinned items in channels and conversations. Required for: pin_added, pin_removed events`),j.literal(`pins:write`).describe(`Pin and unpin items in channels and conversations`),j.literal(`reactions:read`).describe(`View emoji reactions on messages. Required for: reaction_added, reaction_removed events`),j.literal(`reactions:write`).describe(`Add and remove emoji reactions to messages`),j.literal(`reminders:read`).describe(`View reminders created by the bot`),j.literal(`reminders:write`).describe(`Create, update, and delete reminders`),j.literal(`team:read`).describe(`View workspace name, domain, and other basic information. Required for: email_domain_changed event`),j.literal(`usergroups:read`).describe(`View user groups and their members`),j.literal(`usergroups:write`).describe(`Create, update, and archive user groups`),j.literal(`users.profile:read`).describe(`View profile information about users`),j.literal(`users:read`).describe(`View users in the workspace. Required for: team_join, user_change events`),j.literal(`users:read.email`).describe(`View email addresses of users in the workspace`),j.literal(`users:write`).describe(`Set presence and status for the bot user`)]),B=j.union([j.literal(`channels:history`).describe(`Read message history in public channels on behalf of the user`),j.literal(`channels:read`).describe(`View basic information about public channels on behalf of the user`),j.literal(`channels:write`).describe(`Manage public channels on behalf of the user`),j.literal(`chat:write`).describe(`Send messages on behalf of the user`),j.literal(`emoji:read`).describe(`View custom emoji on behalf of the user`),j.literal(`files:read`).describe(`View files on behalf of the user`),j.literal(`files:write`).describe(`Upload, edit, and delete files on behalf of the user`),j.literal(`groups:history`).describe(`Read message history in private channels on behalf of the user`),j.literal(`groups:read`).describe(`View basic information about private channels on behalf of the user`),j.literal(`groups:write`).describe(`Manage private channels on behalf of the user`),j.literal(`im:history`).describe(`Read direct message history on behalf of the user`),j.literal(`im:read`).describe(`View basic information about direct messages on behalf of the user`),j.literal(`im:write`).describe(`Manage direct messages on behalf of the user`),j.literal(`links:read`).describe(`View URLs in messages on behalf of the user`),j.literal(`links:write`).describe(`Show URL previews on behalf of the user`),j.literal(`mpim:history`).describe(`Read multi-party direct message history on behalf of the user`),j.literal(`mpim:read`).describe(`View basic information about multi-party direct messages on behalf of the user`),j.literal(`mpim:write`).describe(`Manage multi-party direct messages on behalf of the user`),j.literal(`pins:read`).describe(`View pinned items on behalf of the user`),j.literal(`pins:write`).describe(`Pin and unpin items on behalf of the user`),j.literal(`reactions:read`).describe(`View emoji reactions on behalf of the user`),j.literal(`reactions:write`).describe(`Add and remove emoji reactions on behalf of the user`),j.literal(`reminders:read`).describe(`View reminders on behalf of the user`),j.literal(`reminders:write`).describe(`Create, update, and delete reminders on behalf of the user`),j.literal(`search:read`).describe(`Search messages and files on behalf of the user`),j.literal(`stars:read`).describe(`View starred items on behalf of the user`),j.literal(`stars:write`).describe(`Star and unstar items on behalf of the user`),j.literal(`team:read`).describe(`View workspace information on behalf of the user`),j.literal(`usergroups:read`).describe(`View user groups on behalf of the user`),j.literal(`usergroups:write`).describe(`Manage user groups on behalf of the user`),j.literal(`users.profile:read`).describe(`View user profile information on behalf of the user`),j.literal(`users.profile:write`).describe(`Edit the user's profile information`),j.literal(`users:read`).describe(`View users in the workspace on behalf of the user`),j.literal(`users:read.email`).describe(`View email addresses on behalf of the user`),j.literal(`users:write`).describe(`Set presence for the user`)]),V=j.object({display_information:j.object({name:j.string().describe(`The name of the Slack app.`),description:j.string().optional().describe(`A short description of the app.`),background_color:j.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().describe(`Background color for the app in hex format (e.g., #4A154B).`),long_description:j.string().optional().describe(`A longer description of the app.`)}).describe(`Display information for the Slack app.`),features:j.object({bot_user:j.object({display_name:j.string().describe(`The display name for the bot user.`),always_online:j.boolean().optional().default(!0).describe(`Whether the bot always appears online.`)}).optional().describe(`Configuration for the bot user.`),app_home:j.object({home_tab_enabled:j.boolean().optional().describe(`Enable the Home tab.`),messages_tab_enabled:j.boolean().optional().describe(`Enable the Messages tab.`),messages_tab_read_only_enabled:j.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:j.object({assistant_description:j.string().optional().describe(`Description for the assistant view.`)}).optional().describe(`Configuration for the assistant view.`),slash_commands:j.array(j.object({command:j.string().regex(/^\//).describe(`The command (must start with /).`),description:j.string().describe(`Description of the command.`),usage_hint:j.string().optional().describe(`Usage hint for the command.`),should_escape:j.boolean().optional().describe(`Whether to escape special characters.`)})).optional().describe(`Slash commands for the app.`),unfurl_domains:j.array(j.string()).optional().describe(`Domains for link unfurling.`)}).optional().describe(`Features configuration for the Slack app.`),oauth_config:j.object({redirect_urls:j.array(j.url()).optional().describe(`OAuth redirect URLs.`),scopes:j.object({bot:j.array(j.union([z,j.string()])).optional().describe(`Bot scopes required by the app. Each scope defines specific permissions for what the bot can do.`),user:j.array(j.union([B,j.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:j.object({event_subscriptions:j.object({request_url:j.string().url().describe(`The webhook URL for event subscriptions.`),bot_events:j.array(j.union([R,j.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:j.object({is_enabled:j.boolean().describe(`Enable interactivity.`),request_url:j.string().url().describe(`The webhook URL for interactive components.`),message_menu_options_url:j.string().url().optional().describe(`URL for message menu options.`)}).optional().describe(`Interactivity configuration.`),org_deploy_enabled:j.boolean().optional().default(!1).describe(`Enable organization-wide deployment.`),socket_mode_enabled:j.boolean().optional().default(!1).describe(`Enable Socket Mode.`),token_rotation_enabled:j.boolean().optional().default(!1).describe(`Enable automatic token rotation.`)}).optional().describe(`Settings for the Slack app.`)});function ee(e,t){let n={...t,...e};for(let r of Object.keys(n))r in e&&r in t&&(n[r]=(n,i)=>e[r](n,()=>t[r](n,i)));return n}const te=e=>({fn(t,n){return t?(...r)=>{let i;return t(e,()=>{i=n(...r)}),i}:n},asyncFn(t,n){return t?(...r)=>{let i;return f(()=>t(e,()=>(i=n(...r),h(i)?i.then(()=>void 0):void 0)),()=>i)}:n}});var ne=class extends Error{error;suppressed;constructor(e,t,n){super(n),this.error=e,this.suppressed=t,this.name=`SuppressedError`,Error.captureStackTrace(this,this.constructor)}};const H={get dispose(){return Symbol.dispose||Symbol.for(`dispose`)},get asyncDispose(){return Symbol.asyncDispose||Symbol.for(`asyncDispose`)}};function re(e){return e?.[H.dispose]!=null}function ie(e){return e?.[H.asyncDispose]!=null}const ae=globalThis.SuppressedError||ne;var oe=class e{callbacks=[];get disposed(){return this.callbacks.length===0}use(e){return ie(e)?this.callbacks.push(()=>e[H.asyncDispose]()):re(e)&&this.callbacks.push(()=>e[H.dispose]()),e}adopt(e,t){return t&&this.callbacks.push(()=>t(e)),e}defer(e){e&&this.callbacks.push(e)}move(){let t=new e;return t.callbacks=this.callbacks,this.callbacks=[],t}disposeAsync(){return this[H.asyncDispose]()}_error;_iterateCallbacks(){let e=this.callbacks.pop();if(e)return f(e,()=>this._iterateCallbacks(),e=>(this._error=this._error?new ae(e,this._error):e,this._iterateCallbacks()))}[H.asyncDispose](){let e=this._iterateCallbacks();if(e?.then)return e.then(()=>{if(this._error){let e=this._error;throw this._error=void 0,e}});if(this._error){let e=this._error;throw this._error=void 0,e}}[Symbol.toStringTag]=`AsyncDisposableStack`};globalThis.SuppressedError,H.dispose,Symbol.toStringTag,globalThis.DisposableStack;const se=globalThis.AsyncDisposableStack||oe;globalThis.SuppressedError;var ce=e(((e,t)=>{function n(){return Object.keys(globalThis).some(e=>e.startsWith(`__NEXT`))}t.exports=function(){return!!(globalThis.Deno||globalThis.Bun||n())}})),le=e(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>n(e,`name`,{value:t,configurable:!0}),s=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},c=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},l=e=>c(n({},`__esModule`,{value:!0}),e),u={};s(u,{URLPattern:()=>J}),t.exports=l(u);var d=class{type=3;name=``;prefix=``;value=``;suffix=``;modifier=3;constructor(e,t,n,r,i,a){this.type=e,this.name=t,this.prefix=n,this.value=r,this.suffix=i,this.modifier=a}hasCustomName(){return this.name!==``&&typeof this.name!=`number`}};o(d,`Part`);var f=/[$_\p{ID_Start}]/u,p=/[$_\u200C\u200D\p{ID_Continue}]/u,m=`.*`;function h(e,t){return(t?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test(e)}o(h,`isASCII`);function g(e,t=!1){let n=[],r=0;for(;r<e.length;){let i=e[r],a=o(function(i){if(!t)throw TypeError(i);n.push({type:`INVALID_CHAR`,index:r,value:e[r++]})},`ErrorOrInvalid`);if(i===`*`){n.push({type:`ASTERISK`,index:r,value:e[r++]});continue}if(i===`+`||i===`?`){n.push({type:`OTHER_MODIFIER`,index:r,value:e[r++]});continue}if(i===`\\`){n.push({type:`ESCAPED_CHAR`,index:r++,value:e[r++]});continue}if(i===`{`){n.push({type:`OPEN`,index:r,value:e[r++]});continue}if(i===`}`){n.push({type:`CLOSE`,index:r,value:e[r++]});continue}if(i===`:`){let t=``,i=r+1;for(;i<e.length;){let n=e.substr(i,1);if(i===r+1&&f.test(n)||i!==r+1&&p.test(n)){t+=e[i++];continue}break}if(!t){a(`Missing parameter name at ${r}`);continue}n.push({type:`NAME`,index:r,value:t}),r=i;continue}if(i===`(`){let t=1,i=``,o=r+1,s=!1;if(e[o]===`?`){a(`Pattern cannot start with "?" at ${o}`);continue}for(;o<e.length;){if(!h(e[o],!1)){a(`Invalid character '${e[o]}' at ${o}.`),s=!0;break}if(e[o]===`\\`){i+=e[o++]+e[o++];continue}if(e[o]===`)`){if(t--,t===0){o++;break}}else if(e[o]===`(`&&(t++,e[o+1]!==`?`)){a(`Capturing groups are not allowed at ${o}`),s=!0;break}i+=e[o++]}if(s)continue;if(t){a(`Unbalanced pattern at ${r}`);continue}if(!i){a(`Missing pattern at ${r}`);continue}n.push({type:`REGEX`,index:r,value:i}),r=o;continue}n.push({type:`CHAR`,index:r,value:e[r++]})}return n.push({type:`END`,index:r,value:``}),n}o(g,`lexer`);function _(e,t={}){let n=g(e);t.delimiter??=`/#?`,t.prefixes??=`./`;let r=`[^${v(t.delimiter)}]+?`,i=[],a=0,s=0,c=new Set,l=o(e=>{if(s<n.length&&n[s].type===e)return n[s++].value},`tryConsume`),u=o(()=>l(`OTHER_MODIFIER`)??l(`ASTERISK`),`tryConsumeModifier`),f=o(e=>{let t=l(e);if(t!==void 0)return t;let{type:r,index:i}=n[s];throw TypeError(`Unexpected ${r} at ${i}, expected ${e}`)},`mustConsume`),p=o(()=>{let e=``,t;for(;t=l(`CHAR`)??l(`ESCAPED_CHAR`);)e+=t;return e},`consumeText`),h=o(e=>e,`DefaultEncodePart`),_=t.encodePart||h,y=``,b=o(e=>{y+=e},`appendToPendingFixedValue`),x=o(()=>{y.length&&(i.push(new d(3,``,``,_(y),``,3)),y=``)},`maybeAddPartFromPendingFixedValue`),S=o((e,t,n,o,s)=>{let l=3;switch(s){case`?`:l=1;break;case`*`:l=0;break;case`+`:l=2;break}if(!t&&!n&&l===3){b(e);return}if(x(),!t&&!n){if(!e)return;i.push(new d(3,``,``,_(e),``,l));return}let u;u=n?n===`*`?m:n:r;let f=2;u===r?(f=1,u=``):u===m&&(f=0,u=``);let p;if(t?p=t:n&&(p=a++),c.has(p))throw TypeError(`Duplicate name '${p}'.`);c.add(p),i.push(new d(f,p,_(e),u,_(o),l))},`addPart`);for(;s<n.length;){let e=l(`CHAR`),n=l(`NAME`),r=l(`REGEX`);if(!n&&!r&&(r=l(`ASTERISK`)),n||r){let i=e??``;t.prefixes.indexOf(i)===-1&&(b(i),i=``),x();let a=u();S(i,n,r,``,a);continue}let i=e??l(`ESCAPED_CHAR`);if(i){b(i);continue}if(l(`OPEN`)){let e=p(),t=l(`NAME`),n=l(`REGEX`);!t&&!n&&(n=l(`ASTERISK`));let r=p();f(`CLOSE`);let i=u();S(e,t,n,r,i);continue}x(),f(`END`)}return i}o(_,`parse`);function v(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,`\\$1`)}o(v,`escapeString`);function y(e){return e&&e.ignoreCase?`ui`:`u`}o(y,`flags`);function b(e,t,n){return S(_(e,n),t,n)}o(b,`stringToRegexp`);function x(e){switch(e){case 0:return`*`;case 1:return`?`;case 2:return`+`;case 3:return``}}o(x,`modifierToString`);function S(e,t,n={}){n.delimiter??=`/#?`,n.prefixes??=`./`,n.sensitive??=!1,n.strict??=!1,n.end??=!0,n.start??=!0,n.endsWith=``;let r=n.start?`^`:``;for(let i of e){if(i.type===3){i.modifier===3?r+=v(i.value):r+=`(?:${v(i.value)})${x(i.modifier)}`;continue}t&&t.push(i.name);let e=`[^${v(n.delimiter)}]+?`,a=i.value;if(i.type===1?a=e:i.type===0&&(a=m),!i.prefix.length&&!i.suffix.length){i.modifier===3||i.modifier===1?r+=`(${a})${x(i.modifier)}`:r+=`((?:${a})${x(i.modifier)})`;continue}if(i.modifier===3||i.modifier===1){r+=`(?:${v(i.prefix)}(${a})${v(i.suffix)})`,r+=x(i.modifier);continue}r+=`(?:${v(i.prefix)}`,r+=`((?:${a})(?:`,r+=v(i.suffix),r+=v(i.prefix),r+=`(?:${a}))*)${v(i.suffix)})`,i.modifier===0&&(r+=`?`)}let i=`[${v(n.endsWith)}]|$`,a=`[${v(n.delimiter)}]`;if(n.end)return n.strict||(r+=`${a}?`),n.endsWith.length?r+=`(?=${i})`:r+=`$`,new RegExp(r,y(n));n.strict||(r+=`(?:${a}(?=${i}))?`);let o=!1;if(e.length){let t=e[e.length-1];t.type===3&&t.modifier===3&&(o=n.delimiter.indexOf(t)>-1)}return o||(r+=`(?=${a}|${i})`),new RegExp(r,y(n))}o(S,`partsToRegexp`);var C={delimiter:``,prefixes:``,sensitive:!0,strict:!0},w={delimiter:`.`,prefixes:``,sensitive:!0,strict:!0},T={delimiter:`/`,prefixes:`/`,sensitive:!0,strict:!0};function E(e,t){return e.length?e[0]===`/`?!0:!t||e.length<2?!1:(e[0]==`\\`||e[0]==`{`)&&e[1]==`/`:!1}o(E,`isAbsolutePathname`);function D(e,t){return e.startsWith(t)?e.substring(t.length,e.length):e}o(D,`maybeStripPrefix`);function O(e,t){return e.endsWith(t)?e.substr(0,e.length-t.length):e}o(O,`maybeStripSuffix`);function k(e){return!e||e.length<2?!1:e[0]===`[`||(e[0]===`\\`||e[0]===`{`)&&e[1]===`[`}o(k,`treatAsIPv6Hostname`);var A=[`ftp`,`file`,`http`,`https`,`ws`,`wss`];function j(e){if(!e)return!0;for(let t of A)if(e.test(t))return!0;return!1}o(j,`isSpecialScheme`);function M(e,t){if(e=D(e,`#`),t||e===``)return e;let n=new URL(`https://example.com`);return n.hash=e,n.hash?n.hash.substring(1,n.hash.length):``}o(M,`canonicalizeHash`);function N(e,t){if(e=D(e,`?`),t||e===``)return e;let n=new URL(`https://example.com`);return n.search=e,n.search?n.search.substring(1,n.search.length):``}o(N,`canonicalizeSearch`);function P(e,t){return t||e===``?e:k(e)?H(e):ne(e)}o(P,`canonicalizeHostname`);function F(e,t){if(t||e===``)return e;let n=new URL(`https://example.com`);return n.password=e,n.password}o(F,`canonicalizePassword`);function I(e,t){if(t||e===``)return e;let n=new URL(`https://example.com`);return n.username=e,n.username}o(I,`canonicalizeUsername`);function L(e,t,n){if(n||e===``)return e;if(t&&!A.includes(t))return new URL(`${t}:${e}`).pathname;let r=e[0]==`/`;return e=new URL(r?e:`/-`+e,`https://example.com`).pathname,r||(e=e.substring(2,e.length)),e}o(L,`canonicalizePathname`);function R(e,t,n){return B(t)===e&&(e=``),n||e===``?e:re(e)}o(R,`canonicalizePort`);function z(e,t){return e=O(e,`:`),t||e===``?e:V(e)}o(z,`canonicalizeProtocol`);function B(e){switch(e){case`ws`:case`http`:return`80`;case`wws`:case`https`:return`443`;case`ftp`:return`21`;default:return``}}o(B,`defaultPortForProtocol`);function V(e){if(e===``)return e;if(/^[-+.A-Za-z0-9]*$/.test(e))return e.toLowerCase();throw TypeError(`Invalid protocol '${e}'.`)}o(V,`protocolEncodeCallback`);function ee(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.username=e,t.username}o(ee,`usernameEncodeCallback`);function te(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.password=e,t.password}o(te,`passwordEncodeCallback`);function ne(e){if(e===``)return e;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test(e))throw TypeError(`Invalid hostname '${e}'`);let t=new URL(`https://example.com`);return t.hostname=e,t.hostname}o(ne,`hostnameEncodeCallback`);function H(e){if(e===``)return e;if(/[^0-9a-fA-F[\]:]/g.test(e))throw TypeError(`Invalid IPv6 hostname '${e}'`);return e.toLowerCase()}o(H,`ipv6HostnameEncodeCallback`);function re(e){if(e===``||/^[0-9]*$/.test(e)&&parseInt(e)<=65535)return e;throw TypeError(`Invalid port '${e}'.`)}o(re,`portEncodeCallback`);function ie(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.pathname=e[0]===`/`?e:`/-`+e,e[0]===`/`?t.pathname:t.pathname.substring(2,t.pathname.length)}o(ie,`standardURLPathnameEncodeCallback`);function ae(e){return e===``?e:new URL(`data:${e}`).pathname}o(ae,`pathURLPathnameEncodeCallback`);function oe(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.search=e,t.search.substring(1,t.search.length)}o(oe,`searchEncodeCallback`);function se(e){if(e===``)return e;let t=new URL(`https://example.com`);return t.hash=e,t.hash.substring(1,t.hash.length)}o(se,`hashEncodeCallback`);var ce=class{#i;#n=[];#t={};#e=0;#s=1;#l=0;#o=0;#d=0;#p=0;#g=!1;constructor(e){this.#i=e}get result(){return this.#t}parse(){for(this.#n=g(this.#i,!0);this.#e<this.#n.length;this.#e+=this.#s){if(this.#s=1,this.#n[this.#e].type===`END`){if(this.#o===0){this.#b(),this.#f()?this.#r(9,1):this.#h()?this.#r(8,1):this.#r(7,0);continue}else if(this.#o===2){this.#u(5);continue}this.#r(10,0);break}if(this.#d>0)if(this.#A())--this.#d;else continue;if(this.#T()){this.#d+=1;continue}switch(this.#o){case 0:this.#P()&&this.#u(1);break;case 1:if(this.#P()){this.#C();let e=7,t=1;this.#E()?(e=2,t=3):this.#g&&(e=2),this.#r(e,t)}break;case 2:this.#S()?this.#u(3):(this.#x()||this.#h()||this.#f())&&this.#u(5);break;case 3:this.#O()?this.#r(4,1):this.#S()&&this.#r(5,1);break;case 4:this.#S()&&this.#r(5,1);break;case 5:this.#y()?this.#p+=1:this.#w()&&--this.#p,this.#k()&&!this.#p?this.#r(6,1):this.#x()?this.#r(7,0):this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 6:this.#x()?this.#r(7,0):this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 7:this.#h()?this.#r(8,1):this.#f()&&this.#r(9,1);break;case 8:this.#f()&&this.#r(9,1);break;case 9:break;case 10:break}}this.#t.hostname!==void 0&&this.#t.port===void 0&&(this.#t.port=``)}#r(e,t){switch(this.#o){case 0:break;case 1:this.#t.protocol=this.#c();break;case 2:break;case 3:this.#t.username=this.#c();break;case 4:this.#t.password=this.#c();break;case 5:this.#t.hostname=this.#c();break;case 6:this.#t.port=this.#c();break;case 7:this.#t.pathname=this.#c();break;case 8:this.#t.search=this.#c();break;case 9:this.#t.hash=this.#c();break;case 10:break}this.#o!==0&&e!==10&&([1,2,3,4].includes(this.#o)&&[6,7,8,9].includes(e)&&(this.#t.hostname??=``),[1,2,3,4,5,6].includes(this.#o)&&[8,9].includes(e)&&(this.#t.pathname??=this.#g?`/`:``),[1,2,3,4,5,6,7].includes(this.#o)&&e===9&&(this.#t.search??=``)),this.#R(e,t)}#R(e,t){this.#o=e,this.#l=this.#e+t,this.#e+=t,this.#s=0}#b(){this.#e=this.#l,this.#s=0}#u(e){this.#b(),this.#o=e}#m(e){return e<0&&(e=this.#n.length-e),e<this.#n.length?this.#n[e]:this.#n[this.#n.length-1]}#a(e,t){let n=this.#m(e);return n.value===t&&(n.type===`CHAR`||n.type===`ESCAPED_CHAR`||n.type===`INVALID_CHAR`)}#P(){return this.#a(this.#e,`:`)}#E(){return this.#a(this.#e+1,`/`)&&this.#a(this.#e+2,`/`)}#S(){return this.#a(this.#e,`@`)}#O(){return this.#a(this.#e,`:`)}#k(){return this.#a(this.#e,`:`)}#x(){return this.#a(this.#e,`/`)}#h(){if(this.#a(this.#e,`?`))return!0;if(this.#n[this.#e].value!==`?`)return!1;let e=this.#m(this.#e-1);return e.type!==`NAME`&&e.type!==`REGEX`&&e.type!==`CLOSE`&&e.type!==`ASTERISK`}#f(){return this.#a(this.#e,`#`)}#T(){return this.#n[this.#e].type==`OPEN`}#A(){return this.#n[this.#e].type==`CLOSE`}#y(){return this.#a(this.#e,`[`)}#w(){return this.#a(this.#e,`]`)}#c(){let e=this.#n[this.#e],t=this.#m(this.#l).index;return this.#i.substring(t,e.index)}#C(){let e={};Object.assign(e,C),e.encodePart=V;let t=b(this.#c(),void 0,e);this.#g=j(t)}};o(ce,`Parser`);var le=[`protocol`,`username`,`password`,`hostname`,`port`,`pathname`,`search`,`hash`],U=`*`;function W(e,t){if(typeof e!=`string`)throw TypeError(`parameter 1 is not of type 'string'.`);let n=new URL(e,t);return{protocol:n.protocol.substring(0,n.protocol.length-1),username:n.username,password:n.password,hostname:n.hostname,port:n.port,pathname:n.pathname,search:n.search===``?void 0:n.search.substring(1,n.search.length),hash:n.hash===``?void 0:n.hash.substring(1,n.hash.length)}}o(W,`extractValues`);function G(e,t){return t?q(e):e}o(G,`processBaseURLString`);function K(e,t,n){let r;if(typeof t.baseURL==`string`)try{r=new URL(t.baseURL),t.protocol===void 0&&(e.protocol=G(r.protocol.substring(0,r.protocol.length-1),n)),!n&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&(e.username=G(r.username,n)),!n&&t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.username===void 0&&t.password===void 0&&(e.password=G(r.password,n)),t.protocol===void 0&&t.hostname===void 0&&(e.hostname=G(r.hostname,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&(e.port=G(r.port,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&(e.pathname=G(r.pathname,n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&(e.search=G(r.search.substring(1,r.search.length),n)),t.protocol===void 0&&t.hostname===void 0&&t.port===void 0&&t.pathname===void 0&&t.search===void 0&&t.hash===void 0&&(e.hash=G(r.hash.substring(1,r.hash.length),n))}catch{throw TypeError(`invalid baseURL '${t.baseURL}'.`)}if(typeof t.protocol==`string`&&(e.protocol=z(t.protocol,n)),typeof t.username==`string`&&(e.username=I(t.username,n)),typeof t.password==`string`&&(e.password=F(t.password,n)),typeof t.hostname==`string`&&(e.hostname=P(t.hostname,n)),typeof t.port==`string`&&(e.port=R(t.port,e.protocol,n)),typeof t.pathname==`string`){if(e.pathname=t.pathname,r&&!E(e.pathname,n)){let t=r.pathname.lastIndexOf(`/`);t>=0&&(e.pathname=G(r.pathname.substring(0,t+1),n)+e.pathname)}e.pathname=L(e.pathname,e.protocol,n)}return typeof t.search==`string`&&(e.search=N(t.search,n)),typeof t.hash==`string`&&(e.hash=M(t.hash,n)),e}o(K,`applyInit`);function q(e){return e.replace(/([+*?:{}()\\])/g,`\\$1`)}o(q,`escapePatternString`);function ue(e){return e.replace(/([.+*?^${}()[\]|/\\])/g,`\\$1`)}o(ue,`escapeRegexpString`);function de(e,t){t.delimiter??=`/#?`,t.prefixes??=`./`,t.sensitive??=!1,t.strict??=!1,t.end??=!0,t.start??=!0,t.endsWith=``;let n=`[^${ue(t.delimiter)}]+?`,r=/[$_\u200C\u200D\p{ID_Continue}]/u,i=``;for(let a=0;a<e.length;++a){let o=e[a];if(o.type===3){if(o.modifier===3){i+=q(o.value);continue}i+=`{${q(o.value)}}${x(o.modifier)}`;continue}let s=o.hasCustomName(),c=!!o.suffix.length||!!o.prefix.length&&(o.prefix.length!==1||!t.prefixes.includes(o.prefix)),l=a>0?e[a-1]:null,u=a<e.length-1?e[a+1]:null;if(!c&&s&&o.type===1&&o.modifier===3&&u&&!u.prefix.length&&!u.suffix.length)if(u.type===3){let e=u.value.length>0?u.value[0]:``;c=r.test(e)}else c=!u.hasCustomName();if(!c&&!o.prefix.length&&l&&l.type===3){let e=l.value[l.value.length-1];c=t.prefixes.includes(e)}c&&(i+=`{`),i+=q(o.prefix),s&&(i+=`:${o.name}`),o.type===2?i+=`(${o.value})`:o.type===1?s||(i+=`(${n})`):o.type===0&&(!s&&(!l||l.type===3||l.modifier!==3||c||o.prefix!==``)?i+=`*`:i+=`(.*)`),o.type===1&&s&&o.suffix.length&&r.test(o.suffix[0])&&(i+=`\\`),i+=q(o.suffix),c&&(i+=`}`),o.modifier!==3&&(i+=x(o.modifier))}return i}o(de,`partsToPattern`);var J=class{#i;#n={};#t={};#e={};#s={};#l=!1;constructor(e={},t,n){try{let r;if(typeof t==`string`?r=t:n=t,typeof e==`string`){let t=new ce(e);if(t.parse(),e=t.result,r===void 0&&typeof e.protocol!=`string`)throw TypeError(`A base URL must be provided for a relative constructor string.`);e.baseURL=r}else{if(!e||typeof e!=`object`)throw TypeError(`parameter 1 is not of type 'string' and cannot convert to dictionary.`);if(r)throw TypeError(`parameter 1 is not of type 'string'.`)}typeof n>`u`&&(n={ignoreCase:!1});let i={ignoreCase:n.ignoreCase===!0};this.#i=K({pathname:U,protocol:U,username:U,password:U,hostname:U,port:U,search:U,hash:U},e,!0),B(this.#i.protocol)===this.#i.port&&(this.#i.port=``);let a;for(a of le){if(!(a in this.#i))continue;let e={},t=this.#i[a];switch(this.#t[a]=[],a){case`protocol`:Object.assign(e,C),e.encodePart=V;break;case`username`:Object.assign(e,C),e.encodePart=ee;break;case`password`:Object.assign(e,C),e.encodePart=te;break;case`hostname`:Object.assign(e,w),k(t)?e.encodePart=H:e.encodePart=ne;break;case`port`:Object.assign(e,C),e.encodePart=re;break;case`pathname`:j(this.#n.protocol)?(Object.assign(e,T,i),e.encodePart=ie):(Object.assign(e,C,i),e.encodePart=ae);break;case`search`:Object.assign(e,C,i),e.encodePart=oe;break;case`hash`:Object.assign(e,C,i),e.encodePart=se;break}try{this.#s[a]=_(t,e),this.#n[a]=S(this.#s[a],this.#t[a],e),this.#e[a]=de(this.#s[a],e),this.#l=this.#l||this.#s[a].some(e=>e.type===2)}catch{throw TypeError(`invalid ${a} pattern '${this.#i[a]}'.`)}}}catch(e){throw TypeError(`Failed to construct 'URLPattern': ${e.message}`)}}get[Symbol.toStringTag](){return`URLPattern`}test(e={},t){let n={pathname:``,protocol:``,username:``,password:``,hostname:``,port:``,search:``,hash:``};if(typeof e!=`string`&&t)throw TypeError(`parameter 1 is not of type 'string'.`);if(typeof e>`u`)return!1;try{n=typeof e==`object`?K(n,e,!1):K(n,W(e,t),!1)}catch{return!1}let r;for(r of le)if(!this.#n[r].exec(n[r]))return!1;return!0}exec(e={},t){let n={pathname:``,protocol:``,username:``,password:``,hostname:``,port:``,search:``,hash:``};if(typeof e!=`string`&&t)throw TypeError(`parameter 1 is not of type 'string'.`);if(typeof e>`u`)return;try{n=typeof e==`object`?K(n,e,!1):K(n,W(e,t),!1)}catch{return null}let r={};t?r.inputs=[e,t]:r.inputs=[e];let i;for(i of le){let e=this.#n[i].exec(n[i]);if(!e)return null;let t={};for(let[n,r]of this.#t[i].entries())(typeof r==`string`||typeof r==`number`)&&(t[r]=e[n+1]);r[i]={input:n[i]??``,groups:t}}return r}static compareComponent(e,t,n){let r=o((e,t)=>{for(let n of[`type`,`modifier`,`prefix`,`value`,`suffix`]){if(e[n]<t[n])return-1;if(e[n]!==t[n])return 1}return 0},`comparePart`),i=new d(3,``,``,``,``,3),a=new d(0,``,``,``,``,3),s=o((e,t)=>{let n=0;for(;n<Math.min(e.length,t.length);++n){let i=r(e[n],t[n]);if(i)return i}return e.length===t.length?0:r(e[n]??i,t[n]??i)},`comparePartList`);return!t.#e[e]&&!n.#e[e]?0:t.#e[e]&&!n.#e[e]?s(t.#s[e],[a]):!t.#e[e]&&n.#e[e]?s([a],n.#s[e]):s(t.#s[e],n.#s[e])}get protocol(){return this.#e.protocol}get username(){return this.#e.username}get password(){return this.#e.password}get hostname(){return this.#e.hostname}get port(){return this.#e.port}get pathname(){return this.#e.pathname}get search(){return this.#e.search}get hash(){return this.#e.hash}get hasRegExpGroups(){return this.#l}};o(J,`URLPattern`)})),U=e(((e,t)=>{let{URLPattern:n}=le();t.exports={URLPattern:n},globalThis.URLPattern||(globalThis.URLPattern=n)})),W=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.isPromise=n,e.isActualPromise=r,e.handleMaybePromise=i,e.fakePromise=a,e.createDeferredPromise=o,e.iterateAsync=s,e.iterateAsyncVoid=s,e.fakeRejectPromise=c,e.mapMaybePromise=l,e.mapAsyncIterator=u,e.promiseLikeFinally=m,e.unfakePromise=h;let t=Symbol.for(`@whatwg-node/promise-helpers/FakePromise`);function n(e){return e?.then!=null}function r(e){let t=e;return t&&t.then&&t.catch&&t.finally}function i(e,t,n,r){let i=a().then(e).then(t,n);return r&&(i=i.finally(r)),h(i)}function a(e){return e&&r(e)?e:n(e)?{then:(t,n)=>a(e.then(t,n)),catch:t=>a(e.then(e=>e,t)),finally:t=>a(t?m(e,t):e),[Symbol.toStringTag]:`Promise`}:{then(t){if(t)try{return a(t(e))}catch(e){return c(e)}return this},catch(){return this},finally(t){if(t)try{return a(t()).then(()=>e,()=>e)}catch(e){return c(e)}return this},[Symbol.toStringTag]:`Promise`,__fakePromiseValue:e,[t]:`resolved`}}function o(){if(Promise.withResolvers)return Promise.withResolvers();let e,t;return{promise:new Promise(function(n,r){e=n,t=r}),get resolve(){return e},get reject(){return t}}}function s(e,t,n){if(e?.length===0)return;let r=e[Symbol.iterator](),a=0;function o(){let{done:e,value:s}=r.next();if(e)return;let c=!1;function l(){c=!0}return i(function(){return t(s,l,a++)},function(e){if(e&&n?.push(e),!c)return o()})}return o()}function c(e){return{then(t,n){if(n)try{return a(n(e))}catch(e){return c(e)}return this},catch(t){if(t)try{return a(t(e))}catch(e){return c(e)}return this},finally(e){if(e)try{e()}catch(e){return c(e)}return this},__fakeRejectError:e,[Symbol.toStringTag]:`Promise`,[t]:`rejected`}}function l(e,t,n){return i(()=>e,t,n)}function u(e,t,n,r){Symbol.asyncIterator in e&&(e=e[Symbol.asyncIterator]());let o,s,l;if(r){let e;l=t=>(e||=i(r,()=>t,()=>t),e)}typeof e.return==`function`&&(o=e.return,s=t=>{let n=()=>{throw t};return o.call(e).then(n,n)});function u(e){return e.done?l?l(e):e:i(()=>e.value,e=>i(()=>t(e),d,s))}let f;if(n){let e,t=n;f=n=>(e||=i(()=>n,e=>i(()=>t(e),d,s)),e)}return{next(){return e.next().then(u,f)},return(){let t=o?o.call(e).then(u,f):a({value:void 0,done:!0});return l?t.then(l):t},throw(t){return typeof e.throw==`function`?e.throw(t).then(u,f):s?s(t):c(t)},[Symbol.asyncIterator](){return this}}}function d(e){return{value:e,done:!1}}function f(e){return e?.[t]===`resolved`}function p(e){return e?.[t]===`rejected`}function m(e,t){return`finally`in e?e.finally(t):e.then(e=>{let r=t();return n(r)?r.then(()=>e):e},e=>{let r=t();if(n(r))return r.then(()=>{throw e});throw e})}function h(e){if(f(e))return e.__fakePromiseValue;if(p(e))throw e.__fakeRejectError;return e}})),G=e(((e,t)=>{let{EventEmitter:n}=r(`node:events`),{inherits:i}=r(`node:util`);function a(e){if(typeof e==`string`&&(e=Buffer.from(e)),!Buffer.isBuffer(e))throw TypeError(`The needle has to be a String or a Buffer.`);let t=e.length,n=t-1;if(t===0)throw Error(`The needle cannot be an empty String/Buffer.`);if(t>256)throw Error(`The needle cannot have a length bigger than 256.`);this.maxMatches=1/0,this.matches=0,this._occ=new Uint8Array(256).fill(t),this._lookbehind_size=0,this._needle=e,this._bufpos=0,this._lookbehind=Buffer.alloc(n);for(var r=0;r<n;++r)this._occ[e[r]]=n-r}i(a,n),a.prototype.reset=function(){this._lookbehind_size=0,this.matches=0,this._bufpos=0},a.prototype.push=function(e,t){Buffer.isBuffer(e)||(e=Buffer.from(e,`binary`));let n=e.length;this._bufpos=t||0;let r;for(;r!==n&&this.matches<this.maxMatches;)r=this._sbmh_feed(e);return r},a.prototype._sbmh_feed=function(e){let t=e.length,n=this._needle,r=n.length,i=r-1,a=n[i],o=-this._lookbehind_size,s;if(o<0){for(;o<0&&o<=t-r;){if(s=e[o+i],s===a&&this._sbmh_memcmp(e,o,i))return this._lookbehind_size=0,++this.matches,this.emit(`info`,!0),this._bufpos=o+r;o+=this._occ[s]}for(;o<0&&!this._sbmh_memcmp(e,o,t-o);)++o;if(o>=0)this.emit(`info`,!1,this._lookbehind,0,this._lookbehind_size),this._lookbehind_size=0;else{let n=this._lookbehind_size+o;return n>0&&this.emit(`info`,!1,this._lookbehind,0,n),this._lookbehind_size-=n,this._lookbehind.copy(this._lookbehind,0,n,this._lookbehind_size),e.copy(this._lookbehind,this._lookbehind_size),this._lookbehind_size+=t,this._bufpos=t,t}}if(o=e.indexOf(n,o+this._bufpos),o!==-1)return++this.matches,o===0?this.emit(`info`,!0):this.emit(`info`,!0,e,this._bufpos,o),this._bufpos=o+r;for(o=t-i,o<0&&(o=0);o!==t&&(e[o]!==n[0]||Buffer.compare(e.subarray(o+1,t),n.subarray(1,t-o))!==0);)++o;return o!==t&&(e.copy(this._lookbehind,0,o,t),this._lookbehind_size=t-o),o!==0&&this.emit(`info`,!1,e,this._bufpos,o),this._bufpos=t,t},a.prototype._sbmh_lookup_char=function(e,t){return t<0?this._lookbehind[this._lookbehind_size+t]:e[t]},a.prototype._sbmh_memcmp=function(e,t,n){for(var r=0;r<n;++r)if(this._sbmh_lookup_char(e,t+r)!==this._needle[r])return!1;return!0},t.exports=a})),K=e(((e,t)=>{let n=r(`node:util`).inherits,i=r(`node:stream`).Readable;function a(e){i.call(this,e)}n(a,i),a.prototype._read=function(e){},t.exports=a})),q=e(((e,t)=>{t.exports=function(e,t,n){if(!e||e[t]===void 0||e[t]===null)return n;if(typeof e[t]!=`number`||isNaN(e[t]))throw TypeError(`Limit `+t+` is not a valid number`);return e[t]}})),ue=e(((e,t)=>{let n=r(`node:events`).EventEmitter,i=r(`node:util`).inherits,a=q(),o=G(),s=Buffer.from(`\r
|
|
2
2
|
\r
|
|
3
3
|
`),c=/\r\n/g,l=/^([^:]+):[ \t]?([\x00-\xFF]+)?$/;function u(e){n.call(this),e||={};let t=this;this.nread=0,this.maxed=!1,this.npairs=0,this.maxHeaderPairs=a(e,`maxHeaderPairs`,2e3),this.maxHeaderSize=a(e,`maxHeaderSize`,80*1024),this.buffer=``,this.header={},this.finished=!1,this.ss=new o(s),this.ss.on(`info`,function(e,n,r,i){n&&!t.maxed&&(t.nread+i-r>=t.maxHeaderSize?(i=t.maxHeaderSize-t.nread+r,t.nread=t.maxHeaderSize,t.maxed=!0):t.nread+=i-r,t.buffer+=n.toString(`binary`,r,i)),e&&t._finish()})}i(u,n),u.prototype.push=function(e){let t=this.ss.push(e);if(this.finished)return t},u.prototype.reset=function(){this.finished=!1,this.buffer=``,this.header={},this.ss.reset()},u.prototype._finish=function(){this.buffer&&this._parseHeader(),this.ss.matches=this.ss.maxMatches;let e=this.header;this.header={},this.buffer=``,this.finished=!0,this.nread=this.npairs=0,this.maxed=!1,this.emit(`header`,e)},u.prototype._parseHeader=function(){if(this.npairs===this.maxHeaderPairs)return;let e=this.buffer.split(c),t=e.length,n,r;for(var i=0;i<t;++i){if(e[i].length===0)continue;if((e[i][0]===` `||e[i][0]===` `)&&r){this.header[r][this.header[r].length-1]+=e[i];continue}let t=e[i].indexOf(`:`);if(t===-1||t===0)return;if(n=l.exec(e[i]),r=n[1].toLowerCase(),this.header[r]=this.header[r]||[],this.header[r].push(n[2]||``),++this.npairs===this.maxHeaderPairs)break}},t.exports=u})),de=e(((e,t)=>{let n=r(`node:stream`).Writable,i=r(`node:util`).inherits,a=G(),o=K(),s=ue(),c=Buffer.from(`-`),l=Buffer.from(`\r
|
|
4
4
|
`),u=function(){};function d(e){if(!(this instanceof d))return new d(e);if(n.call(this,e),!e||!e.headerFirst&&typeof e.boundary!=`string`)throw TypeError(`Boundary required`);typeof e.boundary==`string`?this.setBoundary(e.boundary):this._bparser=void 0,this._headerFirst=e.headerFirst,this._dashes=0,this._parts=0,this._finished=!1,this._realFinish=!1,this._isPreamble=!0,this._justMatched=!1,this._firstWrite=!0,this._inHeader=!0,this._part=void 0,this._cb=void 0,this._ignoreData=!1,this._partOpts={highWaterMark:e.partHwm},this._pause=!1;let t=this;this._hparser=new s(e),this._hparser.on(`header`,function(e){t._inHeader=!1,t._part.emit(`header`,e)})}i(d,n),d.prototype.emit=function(e){if(e===`finish`&&!this._realFinish){if(!this._finished){let e=this;process.nextTick(function(){if(e.emit(`error`,Error(`Unexpected end of multipart data`)),e._part&&!e._ignoreData){let t=e._isPreamble?`Preamble`:`Part`;e._part.emit(`error`,Error(t+` terminated early due to unexpected end of multipart data`)),e._part.push(null),process.nextTick(function(){e._realFinish=!0,e.emit(`finish`),e._realFinish=!1});return}e._realFinish=!0,e.emit(`finish`),e._realFinish=!1})}}else n.prototype.emit.apply(this,arguments)},d.prototype._write=function(e,t,n){if(!this._hparser&&!this._bparser)return n();if(this._headerFirst&&this._isPreamble){this._part||(this._part=new o(this._partOpts),this.listenerCount(`preamble`)===0?this._ignore():this.emit(`preamble`,this._part));let t=this._hparser.push(e);if(!this._inHeader&&t!==void 0&&t<e.length)e=e.slice(t);else return n()}this._firstWrite&&=(this._bparser.push(l),!1),this._bparser.push(e),this._pause?this._cb=n:n()},d.prototype.reset=function(){this._part=void 0,this._bparser=void 0,this._hparser=void 0},d.prototype.setBoundary=function(e){let t=this;this._bparser=new a(`\r
|