@inkeep/open-knowledge 0.27.1-beta.1 → 0.28.0-beta.1
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/THIRD_PARTY_NOTICES.md +24 -9
- package/dist/assets/skills/discovery/SKILL.md +1 -1
- package/dist/assets/skills/project/SKILL.md +1 -1
- package/dist/awk2-BBAGSFUB-Clvg_OoV.mjs +1 -0
- package/dist/chunk-2TRDZQLB-C2G-sahM.mjs +18 -0
- package/dist/{chunk-UNYNJIFU-HSzsM3a6.mjs → chunk-3BS5SKQH-HZ1-1bfb.mjs} +36 -36
- package/dist/{chunk-YS3AZT3J-DwQ3GyQR.mjs → chunk-3H6UQG3A-DdNaIxPm.mjs} +9 -9
- package/dist/{chunk-XORM457F-CJbQLVgU.mjs → chunk-6Z5SFZXK-C3WlMqq-.mjs} +53 -53
- package/dist/{chunk-YNYSPYQ5-DHter9G3.mjs → chunk-B74TABJS-DlbqoTuk.mjs} +13 -13
- package/dist/{chunk-FEIOJCZD-D6YUa1Xl.mjs → chunk-BGSUD5R5-DQ0_iOyO.mjs} +2 -2
- package/dist/{chunk-F55TLFGB-AEzanSfe.mjs → chunk-DBKNVD4L-BVx-WyDG.mjs} +2 -2
- package/dist/{chunk-BRGMQKJV-DtyxDw61.mjs → chunk-HKLCLINH-DwmCAW4U.mjs} +16 -16
- package/dist/chunk-HL6NGDO2-978327U5.mjs +24 -0
- package/dist/{chunk-LPQPILI2-GOcK96AE.mjs → chunk-K6LIBGJA-DpjaSGfc.mjs} +2 -2
- package/dist/{chunk-BBXLRYSX-OVlWa2B-.mjs → chunk-KRBPSX3W-nYEMVABW.mjs} +2 -2
- package/dist/chunk-KX3P26DQ-Cli1PSKS.mjs +2 -0
- package/dist/{chunk-SYMJJMQ4-DUF5hY-A.mjs → chunk-PXTK5WE2-B17f9YTq.mjs} +1 -1
- package/dist/{chunk-J642UCRS-C1PS8Hwf.mjs → chunk-SNN4IESC-C-P75V1I.mjs} +2 -2
- package/dist/chunk-TP4BZANS-eJW0TOjs.mjs +21 -0
- package/dist/{chunk-YFG2CMIF-DBRGs_rZ.mjs → chunk-V5MWI2OL-CDEVEp7K.mjs} +2 -2
- package/dist/chunk-XKWWSDBF-XuPgN5BP.mjs +37 -0
- package/dist/{chunk-NYQYO467-KfHLMnUW.mjs → chunk-YMMW5UAP-uYgeXT56.mjs} +5 -5
- package/dist/chunk-YULBWSET-BYBVdNmi.mjs +14 -0
- package/dist/{chunk-OL3S66CO-CBdL6pp1.mjs → chunk-ZZO3UDB3-CdVtmXn4.mjs} +2 -2
- package/dist/cli.mjs +7 -7
- package/dist/constants-BnzVSpjR.mjs +2 -0
- package/dist/{dist-CgMyk9vp.mjs → dist-BSd2Ezzl.mjs} +1 -1
- package/dist/{dist-C_yx5tj0.mjs → dist-CPsLcVzP.mjs} +153 -153
- package/dist/expansion-VBDYWVZR-k3W3Rc7R.mjs +1 -0
- package/dist/expr-YYCVMXE3-CHnBeIXW.mjs +1 -0
- package/dist/file-IGDTDPLG-DQaFkvTu.mjs +1 -0
- package/dist/find-DH2ALKQS-6y8KktlA.mjs +1 -0
- package/dist/{flag-coverage-QT4N2Z44-BlPYKPtd.mjs → flag-coverage-6JEX67RU-BqC6mFKB.mjs} +2 -2
- package/dist/grep-2HUTXO5U-Dbnjl3Iq.mjs +1 -0
- package/dist/index.d.mts +30 -1
- package/dist/index.mjs +1 -1
- package/dist/{init-JVcJVxEY.mjs → init-CqjCm8Nv.mjs} +24 -24
- package/dist/init-DNwD_Pli.mjs +1 -0
- package/dist/jq-LYZFFBZB-CSF_TJhe.mjs +1 -0
- package/dist/{js-exec-M6UR76J5-ZESSNIAK.mjs → js-exec-VXN6TZ7U-fCXuAS2-.mjs} +2 -2
- package/dist/loader-B8SvxN0m.mjs +1 -0
- package/dist/{loader-ixEy1_13.mjs → loader-C6DwSh1a.mjs} +2 -2
- package/dist/{preview-Cv6PfUmC.mjs → preview-CPq8NQ67.mjs} +2 -2
- package/dist/preview-wdPR6Env.mjs +1 -0
- package/dist/public/assets/{ActivityModeContent-C5aUKw04.js → ActivityModeContent-FXULq3P6.js} +1 -1
- package/dist/public/assets/DocumentContext-AziEfQFy.js +36 -0
- package/dist/public/assets/{EnableSyncConfirmDialog-CM7n_hoC.js → EnableSyncConfirmDialog-D8UuFHxQ.js} +1 -1
- package/dist/public/assets/{GraphPanel-CTza81SW.js → GraphPanel-CHb0qJOI.js} +2 -2
- package/dist/public/assets/{ManagedArtifactProperties-CWVjllTE.js → ManagedArtifactProperties-70ooWd7O.js} +1 -1
- package/dist/public/assets/{McpConsentDialogBody-DEYxioBK.js → McpConsentDialogBody-BKvKmtg_.js} +1 -1
- package/dist/public/assets/PropertyPanel-Cq1sqsH4.js +2 -0
- package/dist/public/assets/SettingsDialogBody-BX4GP2gS.js +7 -0
- package/dist/public/assets/{ShareBranchSwitchDialog-CiPv0nQI.js → ShareBranchSwitchDialog-Clk_4Io5.js} +1 -1
- package/dist/public/assets/{ShareReceiveDialog-Cqyj-wkq.js → ShareReceiveDialog-BDmjkthD.js} +1 -1
- package/dist/public/assets/{ShareReceiveMissDialog-FpCznbtQ.js → ShareReceiveMissDialog-Ds4kHbjr.js} +1 -1
- package/dist/public/assets/{SkillEditorActions-Ccafet7G.js → SkillEditorActions-pVw4b49f.js} +1 -1
- package/dist/public/assets/SourceEditor-DXcSGXCG.js +2 -0
- package/dist/public/assets/{TerminalPanel-EQQLq46y.js → TerminalPanel-Cfp4xEGm.js} +3 -3
- package/dist/public/assets/{auth-state-cache-Bc_I9bTu.js → auth-state-cache-De8QvFee.js} +3 -3
- package/dist/public/assets/{config-provider-CEZVcaXZ.js → config-provider-DY1ejnq-.js} +1 -1
- package/dist/public/assets/{dist-CNSnGZ9C.js → dist-BQeT9ICH.js} +41 -41
- package/dist/public/assets/{doc-hash-DgyRTkQv.js → doc-hash-eLdowlcO.js} +1 -1
- package/dist/public/assets/{documents-events-DnqtZXe7.js → documents-events-DftWTO_p.js} +1 -1
- package/dist/public/assets/{file-tree-adapter-CRZV1_Rs.js → file-tree-adapter-BHXYt6U1.js} +1 -1
- package/dist/public/assets/index-Br8R5akq.js +2003 -0
- package/dist/public/assets/keyboard-shortcuts-C5JAtPtb.js +1 -0
- package/dist/public/assets/{navigation-targets-DYgvWZ49.js → navigation-targets-fzjpgS0d.js} +1 -1
- package/dist/public/assets/{open-managed-artifact-tab-CIoFOyAR.js → open-managed-artifact-tab-BiLs1dgV.js} +1 -1
- package/dist/public/assets/{pending-receive-nav-store-BDS56-vQ.js → pending-receive-nav-store-eEQMXb1T.js} +1 -1
- package/dist/public/assets/{prop-types-s-LFwB3O.js → prop-types-DVWxeasv.js} +1 -1
- package/dist/public/assets/{receive-store-C29GivX_.js → receive-store-Ckz3u5Dv.js} +1 -1
- package/dist/public/assets/{selection-context-BCk-SXA9.js → selection-context-DaymKQhd.js} +1 -1
- package/dist/public/assets/{skill-actions-jPAfbBub.js → skill-actions-CBRvSwTx.js} +1 -1
- package/dist/public/assets/{skills-api-DuXrVXK8.js → skills-api-c0dJMBt0.js} +1 -1
- package/dist/public/assets/{target-navigation-intent-D1jqbtay.js → target-navigation-intent-DJtJaVBl.js} +1 -1
- package/dist/public/assets/{typing-burst-detector--cTSnkpJ.js → typing-burst-detector-fx0Rb57X.js} +3 -3
- package/dist/public/index.html +21 -21
- package/dist/{python3-AUFTPCU6-B7_jrPM3.mjs → python3-DNGS4G3E-bGzU9nm-.mjs} +2 -2
- package/dist/{repair-launch-json-DjycVQkK.mjs → repair-launch-json-Bx6AIRnT.mjs} +2 -2
- package/dist/repair-mcp-configs-C0PHLK4Q.mjs +2 -0
- package/dist/repair-skills-D5IllzJm.mjs +3 -0
- package/dist/repair-skills-J5Ty5dNP.mjs +1 -0
- package/dist/rg-XNF3R3II-ivb6d3Sm.mjs +1 -0
- package/dist/sed-JAPPVBEU-BvDbOHs0.mjs +1 -0
- package/dist/{sqlite3-56UMWEY3-DNmhrHQv.mjs → sqlite3-TE5AIOTF-DW7pT7NE.mjs} +1 -1
- package/dist/{src-BF8Wntv3.mjs → src-Cvy2rszo.mjs} +3 -3
- package/dist/start-Dp2rloGz.mjs +1 -0
- package/dist/{start-C7JWIgQb.mjs → start-aKZT__Ag.mjs} +2 -2
- package/dist/tar-MZQD7NO4-46pC0DHj.mjs +1 -0
- package/dist/{write-project-skill-GLroKiE7.mjs → write-project-skill-f17OygUR.mjs} +3 -3
- package/dist/xan-UD7JYIL2-DnWVVFeC.mjs +1 -0
- package/dist/xan-view-OW2TB7Z3-DBl8NjSB.mjs +1 -0
- package/dist/yq-OAKYHSXH-CpYttz-E.mjs +1 -0
- package/package.json +1 -1
- package/dist/awk2-POPGKRAI-6Q9HKhoL.mjs +0 -1
- package/dist/chunk-CR5AFCPT-BD_awIEP.mjs +0 -24
- package/dist/chunk-HWBSOZZR-DaPTwPxK.mjs +0 -37
- package/dist/chunk-OARHFVLG-Csb_cJVS.mjs +0 -21
- package/dist/chunk-VLGZJRPG-CHtdu0KZ.mjs +0 -17
- package/dist/chunk-XHM67O4N-2lBQUjKO.mjs +0 -2
- package/dist/chunk-YCFVLTST-CKzPj8PR.mjs +0 -13
- package/dist/constants-KS-9Bzpo.mjs +0 -2
- package/dist/expansion-ENLSRCXJ-C5xjxYTl.mjs +0 -1
- package/dist/expr-5T3UU5KE-DrJUreFq.mjs +0 -1
- package/dist/file-ZIGAJ4YS-D07ChhI1.mjs +0 -1
- package/dist/find-TPUOAIUQ-ZPOxwUwf.mjs +0 -1
- package/dist/grep-3AIAIJVR-Bh6KBg6d.mjs +0 -1
- package/dist/init-rHPP9Y_Z.mjs +0 -1
- package/dist/jq-ODXZBPLY-D3tmTL1R.mjs +0 -1
- package/dist/loader-DdezjzEN.mjs +0 -1
- package/dist/preview-CygJcmSs.mjs +0 -1
- package/dist/public/assets/DocumentContext-cOp7rOof.js +0 -36
- package/dist/public/assets/PropertyPanel-CUfe4JDc.js +0 -2
- package/dist/public/assets/SettingsDialogBody-Bdcmgui3.js +0 -7
- package/dist/public/assets/SourceEditor-BjxKq1og.js +0 -2
- package/dist/public/assets/index-CVsw5c62.js +0 -2003
- package/dist/public/assets/keyboard-shortcuts-DWlSJLXo.js +0 -1
- package/dist/repair-mcp-configs-y4y4K-24.mjs +0 -2
- package/dist/repair-skills-B-VIYM77.mjs +0 -1
- package/dist/repair-skills-DJmyw_aE.mjs +0 -3
- package/dist/rg-FOQSCCX3-ViKChHv5.mjs +0 -1
- package/dist/sed-VFTTATXJ-BfHBQ11q.mjs +0 -1
- package/dist/start-KHoZRBpK.mjs +0 -1
- package/dist/tar-ANUBEFJY-Db9qg5B2.mjs +0 -1
- package/dist/xan-BXDXYEIB-I8yansvE.mjs +0 -1
- package/dist/xan-view-ECQUO7AJ-DJhdCPf3.mjs +0 -1
- package/dist/yq-MJMAR36V-BXyMiYfX.mjs +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{It as e,S as t,an as n,wt as r}from"./server-lock-iLcBw_q0-D_cD26E0.mjs";import{d as i,ei as a,ut as o}from"./dist-
|
|
1
|
+
import{It as e,S as t,an as n,wt as r}from"./server-lock-iLcBw_q0-D_cD26E0.mjs";import{d as i,ei as a,ut as o}from"./dist-CPsLcVzP.mjs";import{basename as s,dirname as c,isAbsolute as l,join as u,posix as d,relative as f,resolve as p,sep as m,win32 as h}from"node:path";import{homedir as g}from"node:os";import{cpSync as ee,existsSync as _,lstatSync as v,mkdirSync as y,realpathSync as b,rmSync as x}from"node:fs";const S=t,C=r,w=e,T=`node`,E={MCP_DEBUG:`1`,OK_LOG_FILE:`/tmp/ok-mcp.log`},D=`# ok-mcp-v1`,O=`# ok-mcp-v1
|
|
2
2
|
USER_BUNDLE="$HOME/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
|
|
3
3
|
[ -f "$USER_BUNDLE" ] && [ -x "$USER_BUNDLE" ] && exec "$USER_BUNDLE" mcp
|
|
4
4
|
BUNDLE="/Applications/OpenKnowledge.app/Contents/Resources/cli/bin/ok.sh"
|
|
@@ -32,5 +32,5 @@ foreach ($d in $dirs) {
|
|
|
32
32
|
if (Test-Path -LiteralPath $probe -PathType Leaf) { & $probe -y '@inkeep/open-knowledge@latest' mcp; exit $LASTEXITCODE }
|
|
33
33
|
}
|
|
34
34
|
[Console]::Error.WriteLine('OpenKnowledge: install Node.js 24+ (npm i -g @inkeep/open-knowledge), then restart your editor')
|
|
35
|
-
exit 127`,j=`// ok-pi-bridge`,M=`${j}-v1`,N=`ok-pi-managed-extension`;function P(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v1`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v1`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(M)}return!1}function F(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=
|
|
36
|
-
//# sourceMappingURL=write-project-skill-
|
|
35
|
+
exit 127`,j=`// ok-pi-bridge`,M=`${j}-v1`,N=`ok-pi-managed-extension`;function P(e){if(typeof e!=`object`||!e)return!1;let t=e;if(t.command===`/bin/sh`){if(!Array.isArray(t.args)||t.args[0]!==`-l`||t.args[1]!==`-c`)return!1;let e=t.args[2];return typeof e==`string`&&e.includes(`# ok-mcp-v1`)}if(t.command===`powershell`){if(!Array.isArray(t.args)||t.args[0]!==`-NoProfile`||t.args[1]!==`-NonInteractive`||t.args[2]!==`-Command`)return!1;let e=t.args[3];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}if(t.type===`local`&&Array.isArray(t.command)){if(t.command[0]===`/bin/sh`){if(t.command[1]!==`-l`||t.command[2]!==`-c`)return!1;let e=t.command[3];return typeof e==`string`&&e.includes(`# ok-mcp-v1`)}if(t.command[0]===`powershell`){if(t.command[1]!==`-NoProfile`||t.command[2]!==`-NonInteractive`||t.command[3]!==`-Command`)return!1;let e=t.command[4];return typeof e==`string`&&e.includes(`# ok-mcp-win-v1`)}return!1}if(t.command===`ok-pi-managed-extension`){if(!Array.isArray(t.args))return!1;let e=t.args[0];return typeof e==`string`&&e.startsWith(M)}return!1}function F(e=process.argv[1]){if(!e)throw Error(`Cannot infer the local CLI entry for --dev-mcp because process.argv[1] is empty.`);let t=p(e);if(s(t)===`cli.mjs`&&s(c(t))===`dist`)return t;let n=t.split(m),r=n.lastIndexOf(`packages`);if(r===-1||n[r+1]!==`cli`)throw Error(`Cannot infer the repo root for --dev-mcp from ${t}. Run the local CLI from this repo so the built dist path can be derived.`);let i=n.slice(0,r);return u(i.length===0?m:i.join(m),`packages`,`cli`,`dist`,`cli.mjs`)}function I(e={}){return e.mode===`dev`?{command:T,args:[F(),`mcp`],env:{...E}}:(e.platformName??process.platform)===`win32`?{command:`powershell`,args:[`-NoProfile`,`-NonInteractive`,`-Command`,A]}:{command:`/bin/sh`,args:[`-l`,`-c`,O]}}function L(e={}){return e.mode===`dev`?{type:`local`,enabled:!0,command:[T,F(),`mcp`],environment:{...E}}:(e.platformName??process.platform)===`win32`?{type:`local`,enabled:!0,command:[`powershell`,`-NoProfile`,`-NonInteractive`,`-Command`,A]}:{type:`local`,enabled:!0,command:[`/bin/sh`,`-l`,`-c`,O]}}function te(e){if(typeof e!=`object`||!e)return!1;let t=e;return R(t,I({mode:`published`,platformName:`darwin`}))||R(t,I({mode:`published`,platformName:`win32`}))}function R(e,t){if(Object.keys(e).length!==Object.keys(t).length||e.command!==t.command)return!1;let n=t.args;return!Array.isArray(n)||!Array.isArray(e.args)||e.args.length!==n.length?!1:e.args.every((e,t)=>e===n[t])}function z(e){return e===`win32`?h:d}function B(e={}){let t=e.platformName??process.platform,n=e.home??g(),r=e.env??process.env,i=z(t);return t===`darwin`?i.join(n,`Library`,`Application Support`):t===`win32`?r.APPDATA??i.join(n,`AppData`,`Roaming`):r.XDG_CONFIG_HOME??i.join(n,`.config`)}function V(e={}){let t=e.platformName??process.platform,n=e.home??g();return z(t).join(n,`.claude.json`)}function H(e={}){let t=e.platformName??process.platform,n=e.home??g(),r=e.env??process.env;if(t===`darwin`)return d.join(n,`Library`,`Application Support`,`Claude`,`claude_desktop_config.json`);if(t===`win32`){let e=r.APPDATA??h.join(n,`AppData`,`Roaming`);return h.join(e,`Claude`,`claude_desktop_config.json`)}throw Error(`Claude Desktop is not available on ${t}. Supported: macOS, Windows.`)}function U(e={}){let t=e.platformName??process.platform,n=e.home??g();return z(t).join(n,`.cursor`,`mcp.json`)}function W(e={}){let t=e.platformName??process.platform,n=e.home??g();return(e.env??process.env).CODEX_HOME??z(t).join(n,`.codex`)}function G(e={}){return z(e.platformName??process.platform).join(W(e),`config.toml`)}function K(e={}){let t=e.platformName??process.platform,n=e.home??g(),r=e.env??process.env,i=z(t);if(t===`win32`){let e=r.APPDATA??i.join(n,`AppData`,`Roaming`);return i.join(e,`opencode`)}let a=r.XDG_CONFIG_HOME??i.join(n,`.config`);return i.join(a,`opencode`)}function q(e={}){return z(e.platformName??process.platform).join(K(e),`opencode.json`)}function J(e={}){let t=e.platformName??process.platform,n=e.home??g();return z(t).join(n,`.openclaw`,`openclaw.json`)}function Y(e={}){let t=e.platformName??process.platform,n=e.home??g();return(e.env??process.env).PI_CODING_AGENT_DIR??z(t).join(n,`.pi`,`agent`)}const X={claude:{id:`claude`,label:C.claude,configPath:(e,t)=>V({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>I(t),scope:`global`,detectPath:(e,t)=>u(t??g(),`.claude`),projectConfigPath:e=>u(e,`.mcp.json`),projectSkillPath:e=>u(e,`.claude`,`skills`,`open-knowledge`,`SKILL.md`)},"claude-desktop":{id:`claude-desktop`,label:C[`claude-desktop`],configPath:(e,t)=>H({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>I(t),scope:`global`,detectPath:(e,t)=>c(H({home:t}))},cursor:{id:`cursor`,label:C.cursor,configPath:(e,t)=>U({home:t}),format:`json`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:(e,t)=>I(t),scope:`global`,detectPath:(e,t)=>c(U({home:t})),projectConfigPath:e=>u(e,`.cursor`,`mcp.json`),projectSkillPath:e=>u(e,`.cursor`,`skills`,`open-knowledge`,`SKILL.md`)},codex:{id:`codex`,label:C.codex,configPath:(e,t)=>G({home:t}),format:`toml`,topLevelKey:`mcp_servers`,serverName:()=>n,buildEntry:(e,t)=>I(t),scope:`global`,detectPath:(e,t)=>c(G({home:t})),projectConfigPath:e=>u(e,`.codex`,`config.toml`),projectSkillPath:e=>u(e,`.codex`,`skills`,`open-knowledge`,`SKILL.md`)},opencode:{id:`opencode`,label:C.opencode,configPath:(e,t)=>q({home:t}),format:`json`,topLevelKey:`mcp`,serverName:()=>n,buildEntry:(e,t)=>L(t),scope:`global`,detectPath:(e,t)=>c(q({home:t})),projectConfigPath:e=>u(e,`opencode.json`),projectSkillPath:e=>u(e,`.opencode`,`skills`,`open-knowledge`,`SKILL.md`)},openclaw:{id:`openclaw`,label:C.openclaw,configPath:(e,t)=>J({home:t}),format:`json`,topLevelKey:`mcp`,serverMapSubKey:`servers`,serverName:()=>n,buildEntry:(e,t)=>I(t),scope:`global`,detectPath:(e,t)=>u(t??g(),`.openclaw`),offerOnlyWhenDetected:!0},pi:{id:`pi`,label:C.pi,configPath:()=>{throw Error("Pi has no user-global MCP config; OK's integration is the project-scoped bridge extension at .pi/extensions/open-knowledge.ts (run `ok init` in the project).")},format:`file`,topLevelKey:`mcpServers`,serverName:()=>n,buildEntry:()=>{throw Error(`Pi has no MCP entry shape; the managed bridge file is built by buildPiExtensionSource (integrations/pi-extension.ts).`)},scope:`project`,detectPath:(e,t)=>Y({home:t}),projectConfigPath:e=>u(e,`.pi`,`extensions`,`open-knowledge.ts`),projectSkillPath:e=>u(e,`.pi`,`skills`,`open-knowledge`,`SKILL.md`)}};function Z(e){let t=e.filter(e=>!Object.hasOwn(X,e));if(t.length>0)throw Error(`Unknown editor(s): ${t.join(`, `)}. Valid options: ${S.join(`, `)}`);return e.map(e=>X[e])}function Q(e){let t=[];for(let n of o){let r=i[n];t.push({path:u(e,`.agents`,`skills`,r),bundleId:n,scope:`central`});for(let i of w)t.push({path:u(e,i.hostDir,`skills`,r),bundleId:n,scope:`host`,hostDir:i.hostDir})}return t}function ne(e,t){let n=[];for(let r of Q(e))if(r.bundleId===t)try{x(r.path,{recursive:!0,force:!0})}catch(e){n.push(e instanceof Error?e:Error(String(e)))}if(n.length>0)throw AggregateError(n,`Failed to remove ${n.length} path(s) for ${t}`)}function $(e,t){let n;try{n=b(t)}catch{n=p(t)}let r;try{r=v(e)}catch(e){if(e.code!==`ENOENT`)throw e}if(r?.isSymbolicLink())throw Error(`Refusing to write through a symbolic link at ${e}. Remove the symlink and re-run project setup.`);let i=c(e);for(;i.length>1&&i!==m;){let t;try{t=b(i)}catch(e){if(e.code===`ENOENT`){i=c(i);continue}throw e}let r=f(n,t);if(r===``||!r.startsWith(`..`)&&!l(r))return;throw Error(`Refusing to write at ${e}: ancestor ${i} resolves to ${t}, which is outside the project directory ${n}. A symbolic link in the path likely escapes the project. Remove the symlink and re-run project setup.`)}}function re(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=a(`project`,{checkDesktop:!0}),i=c(n);$(i,t);let o=_(n)?`overwritten`:`written`;return x(i,{recursive:!0,force:!0}),y(c(i),{recursive:!0}),ee(r,i,{recursive:!0}),{editorId:e.id,label:e.label,action:o,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}function ie(e,t){let n=e.projectSkillPath?.(t);if(!n)return{editorId:e.id,label:e.label,action:`skipped-unsupported`,path:``};try{let r=c(n);return _(n)?($(r,t),x(r,{recursive:!0,force:!0}),{editorId:e.id,label:e.label,action:`removed`,path:n}):{editorId:e.id,label:e.label,action:`not-present`,path:n}}catch(t){return{editorId:e.id,label:e.label,action:`failed`,path:n,error:t instanceof Error?t.message:String(t)}}}export{te as _,Q as a,Z as b,k as c,w as d,j as f,P as g,I as h,ne as i,C as l,N as m,ie as n,S as o,M as p,re as r,D as s,$ as t,X as u,B as v,F as y};
|
|
36
|
+
//# sourceMappingURL=write-project-skill-f17OygUR.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-B74TABJS-DlbqoTuk.mjs";import"./chunk-DXB73IDG-Bx-Ikbnu.mjs";import"./chunk-5QMZ5MUS-_0tQyQsf.mjs";import"./chunk-24IMIIXA-BoP5OA93.mjs";import"./chunk-PXTK5WE2-B17f9YTq.mjs";import"./chunk-7TSDKFEO-CMVuiOdP.mjs";import"./chunk-KRBPSX3W-nYEMVABW.mjs";import"./chunk-DBKNVD4L-BVx-WyDG.mjs";import{t as e}from"./chunk-3BS5SKQH-HZ1-1bfb.mjs";export{e as xanCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-DXB73IDG-Bx-Ikbnu.mjs";import"./chunk-PXTK5WE2-B17f9YTq.mjs";import{c as e}from"./chunk-DBKNVD4L-BVx-WyDG.mjs";export{e as cmdView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-B74TABJS-DlbqoTuk.mjs";import"./chunk-DXB73IDG-Bx-Ikbnu.mjs";import"./chunk-5QMZ5MUS-_0tQyQsf.mjs";import"./chunk-24IMIIXA-BoP5OA93.mjs";import"./chunk-PXTK5WE2-B17f9YTq.mjs";import"./chunk-7TSDKFEO-CMVuiOdP.mjs";import"./chunk-KRBPSX3W-nYEMVABW.mjs";import{t as e}from"./chunk-6Z5SFZXK-C3WlMqq-.mjs";export{e as yqCommand};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-YNYSPYQ5-DHter9G3.mjs";import"./chunk-DXB73IDG-Bx-Ikbnu.mjs";import"./chunk-5QMZ5MUS-_0tQyQsf.mjs";import"./chunk-24IMIIXA-BoP5OA93.mjs";import{n as e}from"./chunk-OARHFVLG-Csb_cJVS.mjs";export{e as awkCommand2};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import{a as e,r as t,t as n}from"./chunk-DXB73IDG-Bx-Ikbnu.mjs";import{n as r,r as i,t as a}from"./chunk-74CEPOFO-V0JXh91S.mjs";import{open as o}from"node:fs/promises";var s=t(e=>{e.read=function(e,t,n,r,i){var a,o,s=i*8-r-1,c=(1<<s)-1,l=c>>1,u=-7,d=n?i-1:0,f=n?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-u)-1,p>>=-u,u+=s;u>0;a=a*256+e[t+d],d+=f,u-=8);for(o=a&(1<<-u)-1,a>>=-u,u+=r;u>0;o=o*256+e[t+d],d+=f,u-=8);if(a===0)a=1-l;else{if(a===c)return o?NaN:(p?-1:1)*(1/0);o+=2**r,a-=l}return(p?-1:1)*o*2**(a-r)},e.write=function(e,t,n,r,i,a){var o,s,c,l=a*8-i-1,u=(1<<l)-1,d=u>>1,f=i===23?2**-24-2**-77:0,p=r?0:a-1,m=r?1:-1,h=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=2**-o)<1&&(o--,c*=2),o+d>=1?t+=f/c:t+=f*2**(1-d),t*c>=2&&(o++,c/=2),o+d>=u?(s=0,o=u):o+d>=1?(s=(t*c-1)*2**i,o+=d):(s=t*2**(d-1)*2**i,o=0));i>=8;e[n+p]=s&255,p+=m,s/=256,i-=8);for(o=o<<i|s,l+=i;l>0;e[n+p]=o&255,p+=m,o/=256,l-=8);e[n+p-m]|=h*128}}),c=t((e,t)=>{var n=1e3,r=n*60,i=r*60,a=i*24,o=a*7,s=a*365.25;t.exports=function(e,t){t||={};var n=typeof e;if(n===`string`&&e.length>0)return c(e);if(n===`number`&&isFinite(e))return t.long?u(e):l(e);throw Error(`val is not a non-empty string or a valid number. val=`+JSON.stringify(e))};function c(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var c=parseFloat(t[1]);switch((t[2]||`ms`).toLowerCase()){case`years`:case`year`:case`yrs`:case`yr`:case`y`:return c*s;case`weeks`:case`week`:case`w`:return c*o;case`days`:case`day`:case`d`:return c*a;case`hours`:case`hour`:case`hrs`:case`hr`:case`h`:return c*i;case`minutes`:case`minute`:case`mins`:case`min`:case`m`:return c*r;case`seconds`:case`second`:case`secs`:case`sec`:case`s`:return c*n;case`milliseconds`:case`millisecond`:case`msecs`:case`msec`:case`ms`:return c;default:return}}}}function l(e){var t=Math.abs(e);return t>=a?Math.round(e/a)+`d`:t>=i?Math.round(e/i)+`h`:t>=r?Math.round(e/r)+`m`:t>=n?Math.round(e/n)+`s`:e+`ms`}function u(e){var t=Math.abs(e);return t>=a?d(e,t,a,`day`):t>=i?d(e,t,i,`hour`):t>=r?d(e,t,r,`minute`):t>=n?d(e,t,n,`second`):e+` ms`}function d(e,t,n,r){var i=t>=n*1.5;return Math.round(e/n)+` `+r+(i?`s`:``)}}),l=t((e,t)=>{function n(e){n.debug=n,n.default=n,n.coerce=l,n.disable=o,n.enable=i,n.enabled=s,n.humanize=c(),n.destroy=u,Object.keys(e).forEach(t=>{n[t]=e[t]}),n.names=[],n.skips=[],n.formatters={};function t(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return n.colors[Math.abs(t)%n.colors.length]}n.selectColor=t;function n(e){let t,i=null,a,o;function s(...e){if(!s.enabled)return;let r=s,i=Number(new Date);r.diff=i-(t||i),r.prev=t,r.curr=i,t=i,e[0]=n.coerce(e[0]),typeof e[0]!=`string`&&e.unshift(`%O`);let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(t,i)=>{if(t===`%%`)return`%`;a++;let o=n.formatters[i];if(typeof o==`function`){let n=e[a];t=o.call(r,n),e.splice(a,1),a--}return t}),n.formatArgs.call(r,e),(r.log||n.log).apply(r,e)}return s.namespace=e,s.useColors=n.useColors(),s.color=n.selectColor(e),s.extend=r,s.destroy=n.destroy,Object.defineProperty(s,`enabled`,{enumerable:!0,configurable:!1,get:()=>i===null?(a!==n.namespaces&&(a=n.namespaces,o=n.enabled(e)),o):i,set:e=>{i=e}}),typeof n.init==`function`&&n.init(s),s}function r(e,t){let r=n(this.namespace+(typeof t>`u`?`:`:t)+e);return r.log=this.log,r}function i(e){n.save(e),n.namespaces=e,n.names=[],n.skips=[];let t=(typeof e==`string`?e:``).trim().replace(/\s+/g,`,`).split(`,`).filter(Boolean);for(let e of t)e[0]===`-`?n.skips.push(e.slice(1)):n.names.push(e)}function a(e,t){let n=0,r=0,i=-1,a=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||t[r]===`*`))t[r]===`*`?(i=r,a=n,r++):(n++,r++);else if(i!==-1)r=i+1,a++,n=a;else return!1;for(;r<t.length&&t[r]===`*`;)r++;return r===t.length}function o(){let e=[...n.names,...n.skips.map(e=>`-`+e)].join(`,`);return n.enable(``),e}function s(e){for(let t of n.skips)if(a(e,t))return!1;for(let t of n.names)if(a(e,t))return!0;return!1}function l(e){return e instanceof Error?e.stack||e.message:e}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return n.enable(n.load()),n}t.exports=n}),u=t((e,t)=>{e.formatArgs=r,e.save=i,e.load=a,e.useColors=n,e.storage=o(),e.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),e.colors=`#0000CC.#0000FF.#0033CC.#0033FF.#0066CC.#0066FF.#0099CC.#0099FF.#00CC00.#00CC33.#00CC66.#00CC99.#00CCCC.#00CCFF.#3300CC.#3300FF.#3333CC.#3333FF.#3366CC.#3366FF.#3399CC.#3399FF.#33CC00.#33CC33.#33CC66.#33CC99.#33CCCC.#33CCFF.#6600CC.#6600FF.#6633CC.#6633FF.#66CC00.#66CC33.#9900CC.#9900FF.#9933CC.#9933FF.#99CC00.#99CC33.#CC0000.#CC0033.#CC0066.#CC0099.#CC00CC.#CC00FF.#CC3300.#CC3333.#CC3366.#CC3399.#CC33CC.#CC33FF.#CC6600.#CC6633.#CC9900.#CC9933.#CCCC00.#CCCC33.#FF0000.#FF0033.#FF0066.#FF0099.#FF00CC.#FF00FF.#FF3300.#FF3333.#FF3366.#FF3399.#FF33CC.#FF33FF.#FF6600.#FF6633.#FF9900.#FF9933.#FFCC00.#FFCC33`.split(`.`);function n(){if(typeof window<`u`&&window.process&&(window.process.type===`renderer`||window.process.__nwjs))return!0;if(typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return typeof document<`u`&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<`u`&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<`u`&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function r(e){if(e[0]=(this.useColors?`%c`:``)+this.namespace+(this.useColors?` %c`:` `)+e[0]+(this.useColors?`%c `:` `)+`+`+t.exports.humanize(this.diff),!this.useColors)return;let n=`color: `+this.color;e.splice(1,0,n,`color: inherit`);let r=0,i=0;e[0].replace(/%[a-zA-Z%]/g,e=>{e!==`%%`&&(r++,e===`%c`&&(i=r))}),e.splice(i,0,n)}e.log=console.debug||console.log||(()=>{});function i(t){try{t?e.storage.setItem(`debug`,t):e.storage.removeItem(`debug`)}catch{}}function a(){let t;try{t=e.storage.getItem(`debug`)||e.storage.getItem(`DEBUG`)}catch{}return!t&&typeof process<`u`&&`env`in process&&(t=process.env.DEBUG),t}function o(){try{return localStorage}catch{}}t.exports=l()(e);var{formatters:s}=t.exports;s.j=function(e){try{return JSON.stringify(e)}catch(e){return`[UnexpectedJSONParseError]: `+e.message}}}),d=t((e,t)=>{t.exports=(e,t=process.argv)=>{let n=e.startsWith(`-`)?``:e.length===1?`-`:`--`,r=t.indexOf(n+e),i=t.indexOf(`--`);return r!==-1&&(i===-1||r<i)}}),f=t((e,t)=>{var r=n(`os`),i=n(`tty`),a=d(),{env:o}=process,s;a(`no-color`)||a(`no-colors`)||a(`color=false`)||a(`color=never`)?s=0:(a(`color`)||a(`colors`)||a(`color=true`)||a(`color=always`))&&(s=1),`FORCE_COLOR`in o&&(s=o.FORCE_COLOR===`true`?1:o.FORCE_COLOR===`false`?0:o.FORCE_COLOR.length===0?1:Math.min(parseInt(o.FORCE_COLOR,10),3));function c(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function l(e,t){if(s===0)return 0;if(a(`color=16m`)||a(`color=full`)||a(`color=truecolor`))return 3;if(a(`color=256`))return 2;if(e&&!t&&s===void 0)return 0;let n=s||0;if(o.TERM===`dumb`)return n;if(process.platform===`win32`){let e=r.release().split(`.`);return Number(e[0])>=10&&Number(e[2])>=10586?Number(e[2])>=14931?3:2:1}if(`CI`in o)return[`TRAVIS`,`CIRCLECI`,`APPVEYOR`,`GITLAB_CI`,`GITHUB_ACTIONS`,`BUILDKITE`].some(e=>e in o)||o.CI_NAME===`codeship`?1:n;if(`TEAMCITY_VERSION`in o)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(o.TEAMCITY_VERSION)?1:0;if(o.COLORTERM===`truecolor`)return 3;if(`TERM_PROGRAM`in o){let e=parseInt((o.TERM_PROGRAM_VERSION||``).split(`.`)[0],10);switch(o.TERM_PROGRAM){case`iTerm.app`:return e>=3?3:2;case`Apple_Terminal`:return 2}}return/-256(color)?$/i.test(o.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(o.TERM)||`COLORTERM`in o?1:n}function u(e){return c(l(e,e&&e.isTTY))}t.exports={supportsColor:u,stdout:c(l(!0,i.isatty(1))),stderr:c(l(!0,i.isatty(2)))}}),p=t((e,t)=>{var r=n(`tty`),i=n(`util`);e.init=p,e.log=c,e.formatArgs=o,e.save=u,e.load=d,e.useColors=a,e.destroy=i.deprecate(()=>{},"Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."),e.colors=[6,2,3,4,5,1];try{let t=f();t&&(t.stderr||t).level>=2&&(e.colors=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,128,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221])}catch{}e.inspectOpts=Object.keys(process.env).filter(e=>/^debug_/i.test(e)).reduce((e,t)=>{let n=t.substring(6).toLowerCase().replace(/_([a-z])/g,(e,t)=>t.toUpperCase()),r=process.env[t];return r=/^(yes|on|true|enabled)$/i.test(r)?!0:/^(no|off|false|disabled)$/i.test(r)?!1:r===`null`?null:Number(r),e[n]=r,e},{});function a(){return`colors`in e.inspectOpts?!!e.inspectOpts.colors:r.isatty(process.stderr.fd)}function o(e){let{namespace:n,useColors:r}=this;if(r){let r=this.color,i=`\x1B[3`+(r<8?r:`8;5;`+r),a=` ${i};1m${n} \x1B[0m`;e[0]=a+e[0].split(`
|
|
2
|
-
`).join(`
|
|
3
|
-
`+a),e.push(i+`m+`+t.exports.humanize(this.diff)+`\x1B[0m`)}else e[0]=s()+n+` `+e[0]}function s(){return e.inspectOpts.hideDate?``:new Date().toISOString()+` `}function c(...t){return process.stderr.write(i.formatWithOptions(e.inspectOpts,...t)+`
|
|
4
|
-
`)}function u(e){e?process.env.DEBUG=e:delete process.env.DEBUG}function d(){return process.env.DEBUG}function p(t){t.inspectOpts={};let n=Object.keys(e.inspectOpts);for(let r=0;r<n.length;r++)t.inspectOpts[n[r]]=e.inspectOpts[n[r]]}t.exports=l()(e);var{formatters:m}=t.exports;m.o=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts).split(`
|
|
5
|
-
`).map(e=>e.trim()).join(` `)},m.O=function(e){return this.inspectOpts.colors=this.useColors,i.inspect(e,this.inspectOpts)}}),m=t((e,t)=>{typeof process>`u`||process.type===`renderer`||process.browser===!0||process.__nwjs?t.exports=u():t.exports=p()}),h=`End-Of-Stream`,g=class extends Error{constructor(){super(h),this.name=`EndOfStreamError`}},_=class extends Error{constructor(e=`The operation was aborted`){super(e),this.name=`AbortError`}},v=class{constructor(){this.endOfStream=!1,this.interrupted=!1,this.peekQueue=[]}async peek(e,t=!1){let n=await this.read(e,t);return this.peekQueue.push(e.subarray(0,n)),n}async read(e,t=!1){if(e.length===0)return 0;let n=this.readFromPeekBuffer(e);if(this.endOfStream||(n+=await this.readRemainderFromStream(e.subarray(n),t)),n===0&&!t)throw new g;return n}readFromPeekBuffer(e){let t=e.length,n=0;for(;this.peekQueue.length>0&&t>0;){let r=this.peekQueue.pop();if(!r)throw Error(`peekData should be defined`);let i=Math.min(r.length,t);e.set(r.subarray(0,i),n),n+=i,t-=i,i<r.length&&this.peekQueue.push(r.subarray(i))}return n}async readRemainderFromStream(e,t){let n=0;for(;n<e.length&&!this.endOfStream;){if(this.interrupted)throw new _;let r=await this.readFromStream(e.subarray(n),t);if(r===0)break;n+=r}if(!t&&n<e.length)throw new g;return n}},y=class extends v{constructor(e){super(),this.reader=e}async abort(){return this.close()}async close(){this.reader.releaseLock()}},ee=class extends y{async readFromStream(e,t){if(e.length===0)return 0;let n=await this.reader.read(new Uint8Array(e.length),{min:t?void 0:e.length});return n.done&&(this.endOfStream=n.done),n.value?(e.set(n.value),n.value.length):0}},b=class extends v{constructor(e){super(),this.reader=e,this.buffer=null}writeChunk(e,t){let n=Math.min(t.length,e.length);return e.set(t.subarray(0,n)),n<t.length?this.buffer=t.subarray(n):this.buffer=null,n}async readFromStream(e,t){if(e.length===0)return 0;let n=0;for(this.buffer&&(n+=this.writeChunk(e,this.buffer));n<e.length&&!this.endOfStream;){let t=await this.reader.read();if(t.done){this.endOfStream=!0;break}t.value&&(n+=this.writeChunk(e.subarray(n),t.value))}if(!t&&n===0&&this.endOfStream)throw new g;return n}abort(){return this.interrupted=!0,this.reader.cancel()}async close(){await this.abort(),this.reader.releaseLock()}};function x(e){try{let t=e.getReader({mode:`byob`});return t instanceof ReadableStreamDefaultReader?new b(t):new ee(t)}catch(t){if(t instanceof TypeError)return new b(e.getReader());throw t}}var S=class{constructor(e){this.numBuffer=new Uint8Array(8),this.position=0,this.onClose=e?.onClose,e?.abortSignal&&e.abortSignal.addEventListener(`abort`,()=>{this.abort()})}async readToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.readBuffer(n,{position:t})<e.len)throw new g;return e.get(n,0)}async peekToken(e,t=this.position){let n=new Uint8Array(e.len);if(await this.peekBuffer(n,{position:t})<e.len)throw new g;return e.get(n,0)}async readNumber(e){if(await this.readBuffer(this.numBuffer,{length:e.len})<e.len)throw new g;return e.get(this.numBuffer,0)}async peekNumber(e){if(await this.peekBuffer(this.numBuffer,{length:e.len})<e.len)throw new g;return e.get(this.numBuffer,0)}async ignore(e){if(this.fileInfo.size!==void 0){let t=this.fileInfo.size-this.position;if(e>t)return this.position+=t,t}return this.position+=e,e}async close(){await this.abort(),await this.onClose?.()}normalizeOptions(e,t){if(!this.supportsRandomAccess()&&t&&t.position!==void 0&&t.position<this.position)throw Error("`options.position` must be equal or greater than `tokenizer.position`");return{mayBeLess:!1,offset:0,length:e.length,position:this.position,...t}}abort(){return Promise.resolve()}},C=256e3,w=class extends S{constructor(e,t){super(t),this.streamReader=e,this.fileInfo=t?.fileInfo??{}}async readBuffer(e,t){let n=this.normalizeOptions(e,t),r=n.position-this.position;if(r>0)return await this.ignore(r),this.readBuffer(e,t);if(r<0)throw Error("`options.position` must be equal or greater than `tokenizer.position`");if(n.length===0)return 0;let i=await this.streamReader.read(e.subarray(0,n.length),n.mayBeLess);if(this.position+=i,(!t||!t.mayBeLess)&&i<n.length)throw new g;return i}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=0;if(n.position){let t=n.position-this.position;if(t>0){let i=new Uint8Array(n.length+t);return r=await this.peekBuffer(i,{mayBeLess:n.mayBeLess}),e.set(i.subarray(t)),r-t}if(t<0)throw Error(`Cannot peek from a negative offset in a stream`)}if(n.length>0){try{r=await this.streamReader.peek(e.subarray(0,n.length),n.mayBeLess)}catch(e){if(t?.mayBeLess&&e instanceof g)return 0;throw e}if(!n.mayBeLess&&r<n.length)throw new g}return r}async ignore(e){let t=Math.min(C,e),n=new Uint8Array(t),r=0;for(;r<e;){let i=e-r,a=await this.readBuffer(n,{length:Math.min(t,i)});if(a<0)return a;r+=a}return r}abort(){return this.streamReader.abort()}async close(){return this.streamReader.close()}supportsRandomAccess(){return!1}},T=class extends S{constructor(e,t){super(t),this.uint8Array=e,this.fileInfo={...t?.fileInfo??{},size:e.length}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.uint8Array.length-n.position,n.length);if(!n.mayBeLess&&r<n.length)throw new g;return e.set(this.uint8Array.subarray(n.position,n.position+r)),r}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}},E=class extends S{constructor(e,t){super(t),this.blob=e,this.fileInfo={...t?.fileInfo??{},size:e.size,mimeType:e.type}}async readBuffer(e,t){t?.position&&(this.position=t.position);let n=await this.peekBuffer(e,t);return this.position+=n,n}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=Math.min(this.blob.size-n.position,n.length);if(!n.mayBeLess&&r<n.length)throw new g;let i=await this.blob.slice(n.position,n.position+r).arrayBuffer();return e.set(new Uint8Array(i)),r}close(){return super.close()}supportsRandomAccess(){return!0}setPosition(e){this.position=e}};function D(e,t){let n=x(e),r=t??{},i=r.onClose;return r.onClose=async()=>{if(await n.close(),i)return i()},new w(n,r)}function te(e,t){return new T(e,t)}function ne(e,t){return new E(e,t)}(class e extends S{static async fromFile(t){let n=await o(t,`r`);return new e(n,{fileInfo:{path:t,size:(await n.stat()).size}})}constructor(e,t){super(t),this.fileHandle=e,this.fileInfo=t.fileInfo}async readBuffer(e,t){let n=this.normalizeOptions(e,t);if(this.position=n.position,n.length===0)return 0;let r=await this.fileHandle.read(e,0,n.length,n.position);if(this.position+=r.bytesRead,r.bytesRead<n.length&&(!t||!t.mayBeLess))throw new g;return r.bytesRead}async peekBuffer(e,t){let n=this.normalizeOptions(e,t),r=await this.fileHandle.read(e,0,n.length,n.position);if(!n.mayBeLess&&r.bytesRead<n.length)throw new g;return r.bytesRead}async close(){return await this.fileHandle.close(),super.close()}setPosition(e){this.position=e}supportsRandomAccess(){return!0}}).fromFile,e(s(),1);var O={128:`€`,130:`‚`,131:`ƒ`,132:`„`,133:`…`,134:`†`,135:`‡`,136:`ˆ`,137:`‰`,138:`Š`,139:`‹`,140:`Œ`,142:`Ž`,145:`‘`,146:`’`,147:`“`,148:`”`,149:`•`,150:`–`,151:`—`,152:`˜`,153:`™`,154:`š`,155:`›`,156:`œ`,158:`ž`,159:`Ÿ`},re={};for(let[e,t]of Object.entries(O))re[t]=Number.parseInt(e);function ie(e,t=`utf-8`){switch(t.toLowerCase()){case`utf-8`:case`utf8`:return typeof globalThis.TextDecoder<`u`?new globalThis.TextDecoder(`utf-8`).decode(e):ae(e);case`utf-16le`:return oe(e);case`ascii`:return se(e);case`latin1`:case`iso-8859-1`:return ce(e);case`windows-1252`:return k(e);default:throw RangeError(`Encoding '${t}' not supported`)}}function ae(e){let t=``,n=0;for(;n<e.length;){let r=e[n++];if(r<128)t+=String.fromCharCode(r);else if(r<224){let i=e[n++]&63;t+=String.fromCharCode((r&31)<<6|i)}else if(r<240){let i=e[n++]&63,a=e[n++]&63;t+=String.fromCharCode((r&15)<<12|i<<6|a)}else{let i=e[n++]&63,a=e[n++]&63,o=e[n++]&63,s=(r&7)<<18|i<<12|a<<6|o;s-=65536,t+=String.fromCharCode(55296+(s>>10&1023),56320+(s&1023))}}return t}function oe(e){let t=``;for(let n=0;n<e.length;n+=2)t+=String.fromCharCode(e[n]|e[n+1]<<8);return t}function se(e){return String.fromCharCode(...e.map(e=>e&127))}function ce(e){return String.fromCharCode(...e)}function k(e){let t=``;for(let n of e)n>=128&&n<=159&&O[n]?t+=O[n]:t+=String.fromCharCode(n);return t}function A(e){return new DataView(e.buffer,e.byteOffset)}var j={len:1,get(e,t){return A(e).getUint8(t)},put(e,t,n){return A(e).setUint8(t,n),t+1}},M={len:2,get(e,t){return A(e).getUint16(t,!0)},put(e,t,n){return A(e).setUint16(t,n,!0),t+2}},N={len:2,get(e,t){return A(e).getUint16(t)},put(e,t,n){return A(e).setUint16(t,n),t+2}},P={len:4,get(e,t){return A(e).getUint32(t,!0)},put(e,t,n){return A(e).setUint32(t,n,!0),t+4}},F={len:4,get(e,t){return A(e).getUint32(t)},put(e,t,n){return A(e).setUint32(t,n),t+4}},I={len:4,get(e,t){return A(e).getInt32(t)},put(e,t,n){return A(e).setInt32(t,n),t+4}},L={len:8,get(e,t){return A(e).getBigUint64(t,!0)},put(e,t,n){return A(e).setBigUint64(t,n,!0),t+8}},R=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t=0){return ie(e.subarray(t,t+this.len),this.encoding)}},z=e(m(),1),B={LocalFileHeader:67324752,DataDescriptor:134695760,CentralFileHeader:33639248,EndOfCentralDirectory:101010256},V={get(e){return{signature:P.get(e,0),compressedSize:P.get(e,8),uncompressedSize:P.get(e,12)}},len:16},H={get(e){let t=M.get(e,6);return{signature:P.get(e,0),minVersion:M.get(e,4),dataDescriptor:!!(t&8),compressedMethod:M.get(e,8),compressedSize:P.get(e,18),uncompressedSize:P.get(e,22),filenameLength:M.get(e,26),extraFieldLength:M.get(e,28),filename:null}},len:30},U={get(e){return{signature:P.get(e,0),nrOfThisDisk:M.get(e,4),nrOfThisDiskWithTheStart:M.get(e,6),nrOfEntriesOnThisDisk:M.get(e,8),nrOfEntriesOfSize:M.get(e,10),sizeOfCd:P.get(e,12),offsetOfStartOfCd:P.get(e,16),zipFileCommentLength:M.get(e,20)}},len:22},W={get(e){let t=M.get(e,8);return{signature:P.get(e,0),minVersion:M.get(e,6),dataDescriptor:!!(t&8),compressedMethod:M.get(e,10),compressedSize:P.get(e,20),uncompressedSize:P.get(e,24),filenameLength:M.get(e,28),extraFieldLength:M.get(e,30),fileCommentLength:M.get(e,32),relativeOffsetOfLocalHeader:P.get(e,42),filename:null}},len:46};function G(e){let t=new Uint8Array(P.len);return P.put(t,0,e),t}var K=(0,z.default)(`tokenizer:inflate`),q=256*1024,le=G(B.DataDescriptor),J=G(B.EndOfCentralDirectory),ue=class e{constructor(e){this.tokenizer=e,this.syncBuffer=new Uint8Array(q)}async isZip(){return await this.peekSignature()===B.LocalFileHeader}peekSignature(){return this.tokenizer.peekToken(P)}async findEndOfCentralDirectoryLocator(){let e=this.tokenizer,t=Math.min(16*1024,e.fileInfo.size),n=this.syncBuffer.subarray(0,t);await this.tokenizer.readBuffer(n,{position:e.fileInfo.size-t});for(let r=n.length-4;r>=0;r--)if(n[r]===J[0]&&n[r+1]===J[1]&&n[r+2]===J[2]&&n[r+3]===J[3])return e.fileInfo.size-t+r;return-1}async readCentralDirectory(){if(!this.tokenizer.supportsRandomAccess()){K(`Cannot reading central-directory without random-read support`);return}K(`Reading central-directory...`);let e=this.tokenizer.position,t=await this.findEndOfCentralDirectoryLocator();if(t>0){K(`Central-directory 32-bit signature found`);let n=await this.tokenizer.readToken(U,t),r=[];this.tokenizer.setPosition(n.offsetOfStartOfCd);for(let e=0;e<n.nrOfEntriesOfSize;++e){let t=await this.tokenizer.readToken(W);if(t.signature!==B.CentralFileHeader)throw Error(`Expected Central-File-Header signature`);t.filename=await this.tokenizer.readToken(new R(t.filenameLength,`utf-8`)),await this.tokenizer.ignore(t.extraFieldLength),await this.tokenizer.ignore(t.fileCommentLength),r.push(t),K(`Add central-directory file-entry: n=${e+1}/${r.length}: filename=${r[e].filename}`)}return this.tokenizer.setPosition(e),r}this.tokenizer.setPosition(e)}async unzip(e){let t=await this.readCentralDirectory();if(t)return this.iterateOverCentralDirectory(t,e);let n=!1;do{let t=await this.readLocalFileHeader();if(!t)break;let r=e(t);n=!!r.stop;let i;if(await this.tokenizer.ignore(t.extraFieldLength),t.dataDescriptor&&t.compressedSize===0){let e=[],n=q;K(`Compressed-file-size unknown, scanning for next data-descriptor-signature....`);let i=-1;for(;i<0&&n===q;){n=await this.tokenizer.peekBuffer(this.syncBuffer,{mayBeLess:!0}),i=de(this.syncBuffer.subarray(0,n),le);let t=i>=0?i:n;if(r.handler){let n=new Uint8Array(t);await this.tokenizer.readBuffer(n),e.push(n)}else await this.tokenizer.ignore(t)}K(`Found data-descriptor-signature at pos=${this.tokenizer.position}`),r.handler&&await this.inflate(t,fe(e),r.handler)}else r.handler?(K(`Reading compressed-file-data: ${t.compressedSize} bytes`),i=new Uint8Array(t.compressedSize),await this.tokenizer.readBuffer(i),await this.inflate(t,i,r.handler)):(K(`Ignoring compressed-file-data: ${t.compressedSize} bytes`),await this.tokenizer.ignore(t.compressedSize));if(K(`Reading data-descriptor at pos=${this.tokenizer.position}`),t.dataDescriptor&&(await this.tokenizer.readToken(V)).signature!==134695760)throw Error(`Expected data-descriptor-signature at position ${this.tokenizer.position-V.len}`)}while(!n)}async iterateOverCentralDirectory(e,t){for(let n of e){let e=t(n);if(e.handler){this.tokenizer.setPosition(n.relativeOffsetOfLocalHeader);let t=await this.readLocalFileHeader();if(t){await this.tokenizer.ignore(t.extraFieldLength);let r=new Uint8Array(n.compressedSize);await this.tokenizer.readBuffer(r),await this.inflate(t,r,e.handler)}}if(e.stop)break}}async inflate(t,n,r){if(t.compressedMethod===0)return r(n);if(t.compressedMethod!==8)throw Error(`Unsupported ZIP compression method: ${t.compressedMethod}`);return K(`Decompress filename=${t.filename}, compressed-size=${n.length}`),r(await e.decompressDeflateRaw(n))}static async decompressDeflateRaw(e){let t=new ReadableStream({start(t){t.enqueue(e),t.close()}}),n=new DecompressionStream(`deflate-raw`),r=t.pipeThrough(n);try{let e=await new Response(r).arrayBuffer();return new Uint8Array(e)}catch(e){let t=e instanceof Error?`Failed to deflate ZIP entry: ${e.message}`:`Unknown decompression error in ZIP entry`;throw TypeError(t)}}async readLocalFileHeader(){let e=await this.tokenizer.peekToken(P);if(e===B.LocalFileHeader){let e=await this.tokenizer.readToken(H);return e.filename=await this.tokenizer.readToken(new R(e.filenameLength,`utf-8`)),e}if(e===B.CentralFileHeader)return!1;throw Error(e===3759263696?`Encrypted ZIP`:`Unexpected signature`)}};function de(e,t){let n=e.length,r=t.length;if(r>n)return-1;for(let i=0;i<=n-r;i++){let n=!0;for(let a=0;a<r;a++)if(e[i+a]!==t[a]){n=!1;break}if(n)return i}return-1}function fe(e){let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}var pe=class{constructor(e){this.tokenizer=e}inflate(){let e=this.tokenizer;return new ReadableStream({async pull(t){let n=new Uint8Array(1024),r=await e.readBuffer(n,{mayBeLess:!0});if(r===0){t.close();return}t.enqueue(n.subarray(0,r))}}).pipeThrough(new DecompressionStream(`gzip`))}};new globalThis.TextDecoder(`utf8`),new globalThis.TextEncoder,Array.from({length:256},(e,t)=>t.toString(16).padStart(2,`0`));function Y(e){let{byteLength:t}=e;if(t===6)return e.getUint16(0)*2**32+e.getUint32(2);if(t===5)return e.getUint8(0)*2**32+e.getUint32(1);if(t===4)return e.getUint32(0);if(t===3)return e.getUint8(0)*2**16+e.getUint16(1);if(t===2)return e.getUint16(0);if(t===1)return e.getUint8(0)}function me(e,t){if(t===`utf-16le`){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t.push(r&255,r>>8&255)}return t}if(t===`utf-16be`){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t.push(r>>8&255,r&255)}return t}return[...e].map(e=>e.charCodeAt(0))}function he(e,t=0){let n=Number.parseInt(new R(6).get(e,148).replace(/\0.*$/,``).trim(),8);if(Number.isNaN(n))return!1;let r=256;for(let n=t;n<t+148;n++)r+=e[n];for(let n=t+156;n<t+512;n++)r+=e[n];return n===r}var ge={get:(e,t)=>e[t+3]&127|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4},_e=`jpg,png,apng,gif,webp,flif,xcf,cr2,cr3,orf,arw,dng,nef,rw2,raf,tif,bmp,icns,jxr,psd,indd,zip,tar,rar,gz,bz2,7z,dmg,mp4,mid,mkv,webm,mov,avi,mpg,mp2,mp3,m4a,oga,ogg,ogv,opus,flac,wav,spx,amr,pdf,epub,elf,macho,exe,swf,rtf,wasm,woff,woff2,eot,ttf,otf,ttc,ico,flv,ps,xz,sqlite,nes,crx,xpi,cab,deb,ar,rpm,Z,lz,cfb,mxf,mts,blend,bpg,docx,pptx,xlsx,3gp,3g2,j2c,jp2,jpm,jpx,mj2,aif,qcp,odt,ods,odp,xml,mobi,heic,cur,ktx,ape,wv,dcm,ics,glb,pcap,dsf,lnk,alias,voc,ac3,m4v,m4p,m4b,f4v,f4p,f4b,f4a,mie,asf,ogm,ogx,mpc,arrow,shp,aac,mp1,it,s3m,xm,skp,avif,eps,lzh,pgp,asar,stl,chm,3mf,zst,jxl,vcf,jls,pst,dwg,parquet,class,arj,cpio,ace,avro,icc,fbx,vsdx,vtt,apk,drc,lz4,potx,xltx,dotx,xltm,ott,ots,otp,odg,otg,xlsm,docm,dotm,potm,pptm,jar,jmp,rm,sav,ppsm,ppsx,tar.gz,reg,dat`.split(`,`),ve=`image/jpeg,image/png,image/gif,image/webp,image/flif,image/x-xcf,image/x-canon-cr2,image/x-canon-cr3,image/tiff,image/bmp,image/vnd.ms-photo,image/vnd.adobe.photoshop,application/x-indesign,application/epub+zip,application/x-xpinstall,application/vnd.ms-powerpoint.slideshow.macroenabled.12,application/vnd.oasis.opendocument.text,application/vnd.oasis.opendocument.spreadsheet,application/vnd.oasis.opendocument.presentation,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.openxmlformats-officedocument.presentationml.slideshow,application/zip,application/x-tar,application/x-rar-compressed,application/gzip,application/x-bzip2,application/x-7z-compressed,application/x-apple-diskimage,application/vnd.apache.arrow.file,video/mp4,audio/midi,video/matroska,video/webm,video/quicktime,video/vnd.avi,audio/wav,audio/qcelp,audio/x-ms-asf,video/x-ms-asf,application/vnd.ms-asf,video/mpeg,video/3gpp,audio/mpeg,audio/mp4,video/ogg,audio/ogg,audio/ogg; codecs=opus,application/ogg,audio/flac,audio/ape,audio/wavpack,audio/amr,application/pdf,application/x-elf,application/x-mach-binary,application/x-msdownload,application/x-shockwave-flash,application/rtf,application/wasm,font/woff,font/woff2,application/vnd.ms-fontobject,font/ttf,font/otf,font/collection,image/x-icon,video/x-flv,application/postscript,application/eps,application/x-xz,application/x-sqlite3,application/x-nintendo-nes-rom,application/x-google-chrome-extension,application/vnd.ms-cab-compressed,application/x-deb,application/x-unix-archive,application/x-rpm,application/x-compress,application/x-lzip,application/x-cfb,application/x-mie,application/mxf,video/mp2t,application/x-blender,image/bpg,image/j2c,image/jp2,image/jpx,image/jpm,image/mj2,audio/aiff,application/xml,application/x-mobipocket-ebook,image/heif,image/heif-sequence,image/heic,image/heic-sequence,image/icns,image/ktx,application/dicom,audio/x-musepack,text/calendar,text/vcard,text/vtt,model/gltf-binary,application/vnd.tcpdump.pcap,audio/x-dsf,application/x.ms.shortcut,application/x.apple.alias,audio/x-voc,audio/vnd.dolby.dd-raw,audio/x-m4a,image/apng,image/x-olympus-orf,image/x-sony-arw,image/x-adobe-dng,image/x-nikon-nef,image/x-panasonic-rw2,image/x-fujifilm-raf,video/x-m4v,video/3gpp2,application/x-esri-shape,audio/aac,audio/x-it,audio/x-s3m,audio/x-xm,video/MP1S,video/MP2P,application/vnd.sketchup.skp,image/avif,application/x-lzh-compressed,application/pgp-encrypted,application/x-asar,model/stl,application/vnd.ms-htmlhelp,model/3mf,image/jxl,application/zstd,image/jls,application/vnd.ms-outlook,image/vnd.dwg,application/vnd.apache.parquet,application/java-vm,application/x-arj,application/x-cpio,application/x-ace-compressed,application/avro,application/vnd.iccprofile,application/x.autodesk.fbx,application/vnd.visio,application/vnd.android.package-archive,application/vnd.google.draco,application/x-lz4,application/vnd.openxmlformats-officedocument.presentationml.template,application/vnd.openxmlformats-officedocument.spreadsheetml.template,application/vnd.openxmlformats-officedocument.wordprocessingml.template,application/vnd.ms-excel.template.macroenabled.12,application/vnd.oasis.opendocument.text-template,application/vnd.oasis.opendocument.spreadsheet-template,application/vnd.oasis.opendocument.presentation-template,application/vnd.oasis.opendocument.graphics,application/vnd.oasis.opendocument.graphics-template,application/vnd.ms-excel.sheet.macroenabled.12,application/vnd.ms-word.document.macroenabled.12,application/vnd.ms-word.template.macroenabled.12,application/vnd.ms-powerpoint.template.macroenabled.12,application/vnd.ms-powerpoint.presentation.macroenabled.12,application/java-archive,application/vnd.rn-realmedia,application/x-spss-sav,application/x-ms-regedit,application/x-ft-windows-registry-hive,application/x-jmp-data`.split(`,`),X=4100;async function ye(e,t){return new be(t).fromBuffer(e)}function Z(e){switch(e=e.toLowerCase(),e){case`application/epub+zip`:return{ext:`epub`,mime:e};case`application/vnd.oasis.opendocument.text`:return{ext:`odt`,mime:e};case`application/vnd.oasis.opendocument.text-template`:return{ext:`ott`,mime:e};case`application/vnd.oasis.opendocument.spreadsheet`:return{ext:`ods`,mime:e};case`application/vnd.oasis.opendocument.spreadsheet-template`:return{ext:`ots`,mime:e};case`application/vnd.oasis.opendocument.presentation`:return{ext:`odp`,mime:e};case`application/vnd.oasis.opendocument.presentation-template`:return{ext:`otp`,mime:e};case`application/vnd.oasis.opendocument.graphics`:return{ext:`odg`,mime:e};case`application/vnd.oasis.opendocument.graphics-template`:return{ext:`otg`,mime:e};case`application/vnd.openxmlformats-officedocument.presentationml.slideshow`:return{ext:`ppsx`,mime:e};case`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`:return{ext:`xlsx`,mime:e};case`application/vnd.ms-excel.sheet.macroenabled`:return{ext:`xlsm`,mime:`application/vnd.ms-excel.sheet.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.spreadsheetml.template`:return{ext:`xltx`,mime:e};case`application/vnd.ms-excel.template.macroenabled`:return{ext:`xltm`,mime:`application/vnd.ms-excel.template.macroenabled.12`};case`application/vnd.ms-powerpoint.slideshow.macroenabled`:return{ext:`ppsm`,mime:`application/vnd.ms-powerpoint.slideshow.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.wordprocessingml.document`:return{ext:`docx`,mime:e};case`application/vnd.ms-word.document.macroenabled`:return{ext:`docm`,mime:`application/vnd.ms-word.document.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.wordprocessingml.template`:return{ext:`dotx`,mime:e};case`application/vnd.ms-word.template.macroenabledtemplate`:return{ext:`dotm`,mime:`application/vnd.ms-word.template.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.presentationml.template`:return{ext:`potx`,mime:e};case`application/vnd.ms-powerpoint.template.macroenabled`:return{ext:`potm`,mime:`application/vnd.ms-powerpoint.template.macroenabled.12`};case`application/vnd.openxmlformats-officedocument.presentationml.presentation`:return{ext:`pptx`,mime:e};case`application/vnd.ms-powerpoint.presentation.macroenabled`:return{ext:`pptm`,mime:`application/vnd.ms-powerpoint.presentation.macroenabled.12`};case`application/vnd.ms-visio.drawing`:return{ext:`vsdx`,mime:`application/vnd.visio`};case`application/vnd.ms-package.3dmanufacturing-3dmodel+xml`:return{ext:`3mf`,mime:`model/3mf`};default:}}function Q(e,t,n){n={offset:0,...n};for(let[r,i]of t.entries())if(n.mask){if(i!==(n.mask[r]&e[r+n.offset]))return!1}else if(i!==e[r+n.offset])return!1;return!0}var be=class{constructor(e){this.options={mpegOffsetTolerance:0,...e},this.detectors=[...e?.customDetectors??[],{id:`core`,detect:this.detectConfident},{id:`core.imprecise`,detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:e?.signal}}async fromTokenizer(e){let t=e.position;for(let n of this.detectors){let r=await n.detect(e);if(r)return r;if(t!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);let t=e instanceof Uint8Array?e:new Uint8Array(e);if(t?.length>1)return this.fromTokenizer(te(t,this.tokenizerOptions))}async fromBlob(e){let t=ne(e,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async fromStream(e){let t=D(e,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(e,t){let{sampleSize:n=X}=t,r,i,a=e.getReader({mode:`byob`});try{let{value:e,done:t}=await a.read(new Uint8Array(n));if(i=e,!t&&e)try{r=await this.fromBuffer(e.subarray(0,n))}catch(e){if(!(e instanceof g))throw e;r=void 0}i=e}finally{a.releaseLock()}let o=new TransformStream({async start(e){e.enqueue(i)},transform(e,t){t.enqueue(e)}}),s=e.pipeThrough(o);return s.fileType=r,s}check(e,t){return Q(this.buffer,e,t)}checkString(e,t){return this.check(me(e,t?.encoding),t)}detectConfident=async e=>{if(this.buffer=new Uint8Array(X),e.fileInfo.size===void 0&&(e.fileInfo.size=2**53-1),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:32,mayBeLess:!0}),this.check([66,77]))return{ext:`bmp`,mime:`image/bmp`};if(this.check([11,119]))return{ext:`ac3`,mime:`audio/vnd.dolby.dd-raw`};if(this.check([120,1]))return{ext:`dmg`,mime:`application/x-apple-diskimage`};if(this.check([77,90]))return{ext:`exe`,mime:`application/x-msdownload`};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString(`PS-Adobe-`,{offset:2})&&this.checkString(` EPSF-`,{offset:14})?{ext:`eps`,mime:`application/eps`}:{ext:`ps`,mime:`application/postscript`};if(this.check([31,160])||this.check([31,157]))return{ext:`Z`,mime:`application/x-compress`};if(this.check([199,113]))return{ext:`cpio`,mime:`application/x-cpio`};if(this.check([96,234]))return{ext:`arj`,mime:`application/x-arj`};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:`gif`,mime:`image/gif`};if(this.check([73,73,188]))return{ext:`jxr`,mime:`image/vnd.ms-photo`};if(this.check([31,139,8])){let t=new pe(e).inflate(),n=!0;try{let e;try{e=await this.fromStream(t)}catch{n=!1}if(e&&e.ext===`tar`)return{ext:`tar.gz`,mime:`application/gzip`}}finally{n&&await t.cancel()}return{ext:`gz`,mime:`application/gzip`}}if(this.check([66,90,104]))return{ext:`bz2`,mime:`application/x-bzip2`};if(this.checkString(`ID3`)){await e.ignore(6);let t=await e.readToken(ge);return e.position+t>e.fileInfo.size?{ext:`mp3`,mime:`audio/mpeg`}:(await e.ignore(t),this.fromTokenizer(e))}if(this.checkString(`MP+`))return{ext:`mpc`,mime:`audio/x-musepack`};if((this.buffer[0]===67||this.buffer[0]===70)&&this.check([87,83],{offset:1}))return{ext:`swf`,mime:`application/x-shockwave-flash`};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:`jls`,mime:`image/jls`}:{ext:`jpg`,mime:`image/jpeg`};if(this.check([79,98,106,1]))return{ext:`avro`,mime:`application/avro`};if(this.checkString(`FLIF`))return{ext:`flif`,mime:`image/flif`};if(this.checkString(`8BPS`))return{ext:`psd`,mime:`image/vnd.adobe.photoshop`};if(this.checkString(`MPCK`))return{ext:`mpc`,mime:`audio/x-musepack`};if(this.checkString(`FORM`))return{ext:`aif`,mime:`audio/aiff`};if(this.checkString(`icns`,{offset:0}))return{ext:`icns`,mime:`image/icns`};if(this.check([80,75,3,4])){let t;return await new ue(e).unzip(e=>{switch(e.filename){case`META-INF/mozilla.rsa`:return t={ext:`xpi`,mime:`application/x-xpinstall`},{stop:!0};case`META-INF/MANIFEST.MF`:return t={ext:`jar`,mime:`application/java-archive`},{stop:!0};case`mimetype`:return{async handler(e){t=Z(new TextDecoder(`utf-8`).decode(e).trim())},stop:!0};case`[Content_Types].xml`:return{async handler(e){let n=new TextDecoder(`utf-8`).decode(e),r=n.indexOf(`.main+xml"`);if(r===-1){let e=`application/vnd.ms-package.3dmanufacturing-3dmodel+xml`;n.includes(`ContentType="${e}"`)&&(t=Z(e))}else{n=n.slice(0,Math.max(0,r));let e=n.lastIndexOf(`"`);t=Z(n.slice(Math.max(0,e+1)))}},stop:!0};default:return/classes\d*\.dex/.test(e.filename)?(t={ext:`apk`,mime:`application/vnd.android.package-archive`},{stop:!0}):{}}}).catch(e=>{if(!(e instanceof g))throw e}),t??{ext:`zip`,mime:`application/zip`}}if(this.checkString(`OggS`)){await e.ignore(28);let t=new Uint8Array(8);return await e.readBuffer(t),Q(t,[79,112,117,115,72,101,97,100])?{ext:`opus`,mime:`audio/ogg; codecs=opus`}:Q(t,[128,116,104,101,111,114,97])?{ext:`ogv`,mime:`video/ogg`}:Q(t,[1,118,105,100,101,111,0])?{ext:`ogm`,mime:`video/ogg`}:Q(t,[127,70,76,65,67])?{ext:`oga`,mime:`audio/ogg`}:Q(t,[83,112,101,101,120,32,32])?{ext:`spx`,mime:`audio/ogg`}:Q(t,[1,118,111,114,98,105,115])?{ext:`ogg`,mime:`audio/ogg`}:{ext:`ogx`,mime:`application/ogg`}}if(this.check([80,75])&&(this.buffer[2]===3||this.buffer[2]===5||this.buffer[2]===7)&&(this.buffer[3]===4||this.buffer[3]===6||this.buffer[3]===8))return{ext:`zip`,mime:`application/zip`};if(this.checkString(`MThd`))return{ext:`mid`,mime:`audio/midi`};if(this.checkString(`wOFF`)&&(this.check([0,1,0,0],{offset:4})||this.checkString(`OTTO`,{offset:4})))return{ext:`woff`,mime:`font/woff`};if(this.checkString(`wOF2`)&&(this.check([0,1,0,0],{offset:4})||this.checkString(`OTTO`,{offset:4})))return{ext:`woff2`,mime:`font/woff2`};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:`pcap`,mime:`application/vnd.tcpdump.pcap`};if(this.checkString(`DSD `))return{ext:`dsf`,mime:`audio/x-dsf`};if(this.checkString(`LZIP`))return{ext:`lz`,mime:`application/x-lzip`};if(this.checkString(`fLaC`))return{ext:`flac`,mime:`audio/flac`};if(this.check([66,80,71,251]))return{ext:`bpg`,mime:`image/bpg`};if(this.checkString(`wvpk`))return{ext:`wv`,mime:`audio/wavpack`};if(this.checkString(`%PDF`))return{ext:`pdf`,mime:`application/pdf`};if(this.check([0,97,115,109]))return{ext:`wasm`,mime:`application/wasm`};if(this.check([73,73])){let e=await this.readTiffHeader(!1);if(e)return e}if(this.check([77,77])){let e=await this.readTiffHeader(!0);if(e)return e}if(this.checkString(`MAC `))return{ext:`ape`,mime:`audio/ape`};if(this.check([26,69,223,163])){async function t(){let t=await e.peekNumber(j),n=128,r=0;for(;(t&n)===0&&n!==0;)++r,n>>=1;let i=new Uint8Array(r+1);return await e.readBuffer(i),i}async function n(){let e=await t(),n=await t();n[0]^=128>>n.length-1;let r=Math.min(6,n.length),i=new DataView(e.buffer),a=new DataView(n.buffer,n.length-r,r);return{id:Y(i),len:Y(a)}}async function r(t){for(;t>0;){let r=await n();if(r.id===17026)return(await e.readToken(new R(r.len))).replaceAll(/\00.*$/g,``);await e.ignore(r.len),--t}}switch(await r((await n()).len)){case`webm`:return{ext:`webm`,mime:`video/webm`};case`matroska`:return{ext:`mkv`,mime:`video/matroska`};default:return}}if(this.checkString(`SQLi`))return{ext:`sqlite`,mime:`application/x-sqlite3`};if(this.check([78,69,83,26]))return{ext:`nes`,mime:`application/x-nintendo-nes-rom`};if(this.checkString(`Cr24`))return{ext:`crx`,mime:`application/x-google-chrome-extension`};if(this.checkString(`MSCF`)||this.checkString(`ISc(`))return{ext:`cab`,mime:`application/vnd.ms-cab-compressed`};if(this.check([237,171,238,219]))return{ext:`rpm`,mime:`application/x-rpm`};if(this.check([197,208,211,198]))return{ext:`eps`,mime:`application/eps`};if(this.check([40,181,47,253]))return{ext:`zst`,mime:`application/zstd`};if(this.check([127,69,76,70]))return{ext:`elf`,mime:`application/x-elf`};if(this.check([33,66,68,78]))return{ext:`pst`,mime:`application/vnd.ms-outlook`};if(this.checkString(`PAR1`)||this.checkString(`PARE`))return{ext:`parquet`,mime:`application/vnd.apache.parquet`};if(this.checkString(`ttcf`))return{ext:`ttc`,mime:`font/collection`};if(this.check([207,250,237,254]))return{ext:`macho`,mime:`application/x-mach-binary`};if(this.check([4,34,77,24]))return{ext:`lz4`,mime:`application/x-lz4`};if(this.checkString(`regf`))return{ext:`dat`,mime:`application/x-ft-windows-registry-hive`};if(this.checkString(`$FL2`)||this.checkString(`$FL3`))return{ext:`sav`,mime:`application/x-spss-sav`};if(this.check([79,84,84,79,0]))return{ext:`otf`,mime:`font/otf`};if(this.checkString(`#!AMR`))return{ext:`amr`,mime:`audio/amr`};if(this.checkString(`{\\rtf`))return{ext:`rtf`,mime:`application/rtf`};if(this.check([70,76,86,1]))return{ext:`flv`,mime:`video/x-flv`};if(this.checkString(`IMPM`))return{ext:`it`,mime:`audio/x-it`};if(this.checkString(`-lh0-`,{offset:2})||this.checkString(`-lh1-`,{offset:2})||this.checkString(`-lh2-`,{offset:2})||this.checkString(`-lh3-`,{offset:2})||this.checkString(`-lh4-`,{offset:2})||this.checkString(`-lh5-`,{offset:2})||this.checkString(`-lh6-`,{offset:2})||this.checkString(`-lh7-`,{offset:2})||this.checkString(`-lzs-`,{offset:2})||this.checkString(`-lz4-`,{offset:2})||this.checkString(`-lz5-`,{offset:2})||this.checkString(`-lhd-`,{offset:2}))return{ext:`lzh`,mime:`application/x-lzh-compressed`};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:`mpg`,mime:`video/MP1S`};if(this.check([68],{offset:4,mask:[196]}))return{ext:`mpg`,mime:`video/MP2P`}}if(this.checkString(`ITSF`))return{ext:`chm`,mime:`application/vnd.ms-htmlhelp`};if(this.check([202,254,186,190]))return{ext:`class`,mime:`application/java-vm`};if(this.checkString(`.RMF`))return{ext:`rm`,mime:`application/vnd.rn-realmedia`};if(this.checkString(`DRACO`))return{ext:`drc`,mime:`application/vnd.google.draco`};if(this.check([253,55,122,88,90,0]))return{ext:`xz`,mime:`application/x-xz`};if(this.checkString(`<?xml `))return{ext:`xml`,mime:`application/xml`};if(this.check([55,122,188,175,39,28]))return{ext:`7z`,mime:`application/x-7z-compressed`};if(this.check([82,97,114,33,26,7])&&(this.buffer[6]===0||this.buffer[6]===1))return{ext:`rar`,mime:`application/x-rar-compressed`};if(this.checkString(`solid `))return{ext:`stl`,mime:`model/stl`};if(this.checkString(`AC`)){let e=new R(4,`latin1`).get(this.buffer,2);if(e.match(`^d*`)&&e>=1e3&&e<=1050)return{ext:`dwg`,mime:`image/vnd.dwg`}}if(this.checkString(`070707`))return{ext:`cpio`,mime:`application/x-cpio`};if(this.checkString(`BLENDER`))return{ext:`blend`,mime:`application/x-blender`};if(this.checkString(`!<arch>`))return await e.ignore(8),await e.readToken(new R(13,`ascii`))===`debian-binary`?{ext:`deb`,mime:`application/x-deb`}:{ext:`ar`,mime:`application/x-unix-archive`};if(this.checkString(`WEBVTT`)&&[`
|
|
6
|
-
`,`\r`,` `,` `,`\0`].some(e=>this.checkString(e,{offset:6})))return{ext:`vtt`,mime:`text/vtt`};if(this.check([137,80,78,71,13,10,26,10])){await e.ignore(8);async function t(){return{length:await e.readToken(I),type:await e.readToken(new R(4,`latin1`))}}do{let n=await t();if(n.length<0)return;switch(n.type){case`IDAT`:return{ext:`png`,mime:`image/png`};case`acTL`:return{ext:`apng`,mime:`image/apng`};default:await e.ignore(n.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:`png`,mime:`image/png`}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:`arrow`,mime:`application/vnd.apache.arrow.file`};if(this.check([103,108,84,70,2,0,0,0]))return{ext:`glb`,mime:`model/gltf-binary`};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:`mov`,mime:`video/quicktime`};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:`orf`,mime:`image/x-olympus-orf`};if(this.checkString(`gimp xcf `))return{ext:`xcf`,mime:`image/x-xcf`};if(this.checkString(`ftyp`,{offset:4})&&this.buffer[8]&96){let e=new R(4,`latin1`).get(this.buffer,8).replace(`\0`,` `).trim();switch(e){case`avif`:case`avis`:return{ext:`avif`,mime:`image/avif`};case`mif1`:return{ext:`heic`,mime:`image/heif`};case`msf1`:return{ext:`heic`,mime:`image/heif-sequence`};case`heic`:case`heix`:return{ext:`heic`,mime:`image/heic`};case`hevc`:case`hevx`:return{ext:`heic`,mime:`image/heic-sequence`};case`qt`:return{ext:`mov`,mime:`video/quicktime`};case`M4V`:case`M4VH`:case`M4VP`:return{ext:`m4v`,mime:`video/x-m4v`};case`M4P`:return{ext:`m4p`,mime:`video/mp4`};case`M4B`:return{ext:`m4b`,mime:`audio/mp4`};case`M4A`:return{ext:`m4a`,mime:`audio/x-m4a`};case`F4V`:return{ext:`f4v`,mime:`video/mp4`};case`F4P`:return{ext:`f4p`,mime:`video/mp4`};case`F4A`:return{ext:`f4a`,mime:`audio/mp4`};case`F4B`:return{ext:`f4b`,mime:`audio/mp4`};case`crx`:return{ext:`cr3`,mime:`image/x-canon-cr3`};default:return e.startsWith(`3g`)?e.startsWith(`3g2`)?{ext:`3g2`,mime:`video/3gpp2`}:{ext:`3gp`,mime:`video/3gpp`}:{ext:`mp4`,mime:`video/mp4`}}}if(this.checkString(`REGEDIT4\r
|
|
7
|
-
`))return{ext:`reg`,mime:`application/x-ms-regedit`};if(this.check([82,73,70,70])){if(this.checkString(`WEBP`,{offset:8}))return{ext:`webp`,mime:`image/webp`};if(this.check([65,86,73],{offset:8}))return{ext:`avi`,mime:`video/vnd.avi`};if(this.check([87,65,86,69],{offset:8}))return{ext:`wav`,mime:`audio/wav`};if(this.check([81,76,67,77],{offset:8}))return{ext:`qcp`,mime:`audio/qcelp`}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:`rw2`,mime:`image/x-panasonic-rw2`};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function t(){let t=new Uint8Array(16);return await e.readBuffer(t),{id:t,size:Number(await e.readToken(L))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){let n=await t(),r=n.size-24;if(Q(n.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){let t=new Uint8Array(16);if(r-=await e.readBuffer(t),Q(t,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:`asf`,mime:`audio/x-ms-asf`};if(Q(t,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:`asf`,mime:`video/x-ms-asf`};break}await e.ignore(r)}return{ext:`asf`,mime:`application/vnd.ms-asf`}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:`ktx`,mime:`image/ktx`};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:`mie`,mime:`application/x-mie`};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:`shp`,mime:`application/x-esri-shape`};if(this.check([255,79,255,81]))return{ext:`j2c`,mime:`image/j2c`};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10]))switch(await e.ignore(20),await e.readToken(new R(4,`ascii`))){case`jp2 `:return{ext:`jp2`,mime:`image/jp2`};case`jpx `:return{ext:`jpx`,mime:`image/jpx`};case`jpm `:return{ext:`jpm`,mime:`image/jpm`};case`mjp2`:return{ext:`mj2`,mime:`image/mj2`};default:return}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:`jxl`,mime:`image/jxl`};if(this.check([254,255]))return this.checkString(`<?xml `,{offset:2,encoding:`utf-16be`})?{ext:`xml`,mime:`application/xml`}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:`cfb`,mime:`application/x-cfb`};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:`icc`,mime:`application/vnd.iccprofile`};if(this.checkString(`**ACE`,{offset:7})&&this.checkString(`**`,{offset:12}))return{ext:`ace`,mime:`application/x-ace-compressed`};if(this.checkString(`BEGIN:`)){if(this.checkString(`VCARD`,{offset:6}))return{ext:`vcf`,mime:`text/vcard`};if(this.checkString(`VCALENDAR`,{offset:6}))return{ext:`ics`,mime:`text/calendar`}}if(this.checkString(`FUJIFILMCCD-RAW`))return{ext:`raf`,mime:`image/x-fujifilm-raf`};if(this.checkString(`Extended Module:`))return{ext:`xm`,mime:`audio/x-xm`};if(this.checkString(`Creative Voice File`))return{ext:`voc`,mime:`audio/x-voc`};if(this.check([4,0,0,0])&&this.buffer.length>=16){let e=new DataView(this.buffer.buffer).getUint32(12,!0);if(e>12&&this.buffer.length>=e+16)try{let t=new TextDecoder().decode(this.buffer.subarray(16,e+16));if(JSON.parse(t).files)return{ext:`asar`,mime:`application/x-asar`}}catch{}}if(this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2]))return{ext:`mxf`,mime:`application/mxf`};if(this.checkString(`SCRM`,{offset:44}))return{ext:`s3m`,mime:`audio/x-s3m`};if(this.check([71])&&this.check([71],{offset:188})||this.check([71],{offset:4})&&this.check([71],{offset:196}))return{ext:`mts`,mime:`video/mp2t`};if(this.check([66,79,79,75,77,79,66,73],{offset:60}))return{ext:`mobi`,mime:`application/x-mobipocket-ebook`};if(this.check([68,73,67,77],{offset:128}))return{ext:`dcm`,mime:`application/dicom`};if(this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70]))return{ext:`lnk`,mime:`application/x.ms.shortcut`};if(this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0]))return{ext:`alias`,mime:`application/x.apple.alias`};if(this.checkString(`Kaydara FBX Binary \0`))return{ext:`fbx`,mime:`application/x.autodesk.fbx`};if(this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8})))return{ext:`eot`,mime:`application/vnd.ms-fontobject`};if(this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29]))return{ext:`indd`,mime:`application/x-indesign`};if(this.check([255,255,0,0,7,0,0,0,4,0,0,0,1,0,1,0])||this.check([0,0,255,255,0,0,0,7,0,0,0,4,0,1,0,1]))return{ext:`jmp`,mime:`application/x-jmp-data`};if(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString(`ustar`,{offset:257})&&(this.checkString(`\0`,{offset:262})||this.checkString(` `,{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&he(this.buffer))return{ext:`tar`,mime:`application/x-tar`};if(this.check([255,254])){let e=`utf-16le`;return this.checkString(`<?xml `,{offset:2,encoding:e})?{ext:`xml`,mime:`application/xml`}:this.check([255,14],{offset:2})&&this.checkString(`SketchUp Model`,{offset:4,encoding:e})?{ext:`skp`,mime:`application/vnd.sketchup.skp`}:this.checkString(`Windows Registry Editor Version 5.00\r
|
|
8
|
-
`,{offset:2,encoding:e})?{ext:`reg`,mime:`application/x-ms-regedit`}:void 0}if(this.checkString(`-----BEGIN PGP MESSAGE-----`))return{ext:`pgp`,mime:`application/pgp-encrypted`}};detectImprecise=async e=>{if(this.buffer=new Uint8Array(X),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:`mpg`,mime:`video/mpeg`};if(this.check([0,1,0,0,0]))return{ext:`ttf`,mime:`font/ttf`};if(this.check([0,0,1,0]))return{ext:`ico`,mime:`image/x-icon`};if(this.check([0,0,2,0]))return{ext:`cur`,mime:`image/x-icon`};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let e=0;e<=this.options.mpegOffsetTolerance;++e){let t=this.scanMpeg(e);if(t)return t}};async readTiffTag(e){let t=await this.tokenizer.readToken(e?N:M);switch(this.tokenizer.ignore(10),t){case 50341:return{ext:`arw`,mime:`image/x-sony-arw`};case 50706:return{ext:`dng`,mime:`image/x-adobe-dng`};default:}}async readTiffIFD(e){let t=await this.tokenizer.readToken(e?N:M);for(let n=0;n<t;++n){let t=await this.readTiffTag(e);if(t)return t}}async readTiffHeader(e){let t=(e?N:M).get(this.buffer,2),n=(e?F:P).get(this.buffer,4);if(t===42){if(n>=6){if(this.checkString(`CR`,{offset:8}))return{ext:`cr2`,mime:`image/x-canon-cr2`};if(n>=8){let t=(e?N:M).get(this.buffer,8),n=(e?N:M).get(this.buffer,10);if(t===28&&n===254||t===31&&n===11)return{ext:`nef`,mime:`image/x-nikon-nef`}}}return await this.tokenizer.ignore(n),await this.readTiffIFD(e)??{ext:`tif`,mime:`image/tiff`}}if(t===43)return{ext:`tif`,mime:`image/tiff`}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]}),{ext:`aac`,mime:`audio/aac`};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:`mp3`,mime:`audio/mpeg`};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:`mp2`,mime:`audio/mpeg`};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:`mp1`,mime:`audio/mpeg`}}}};new Set(_e),new Set(ve);var $={name:`file`,summary:`determine file type`,usage:`file [OPTION]... FILE...`,options:[`-b, --brief do not prepend filenames to output`,`-i, --mime output MIME type strings`,`-L, --dereference follow symlinks`,` --help display this help and exit`]},xe=new Map([[`.js`,{description:`JavaScript source`,mime:`text/javascript`}],[`.mjs`,{description:`JavaScript module`,mime:`text/javascript`}],[`.cjs`,{description:`CommonJS module`,mime:`text/javascript`}],[`.ts`,{description:`TypeScript source`,mime:`text/typescript`}],[`.tsx`,{description:`TypeScript JSX source`,mime:`text/typescript`}],[`.jsx`,{description:`JavaScript JSX source`,mime:`text/javascript`}],[`.py`,{description:`Python script`,mime:`text/x-python`}],[`.rb`,{description:`Ruby script`,mime:`text/x-ruby`}],[`.go`,{description:`Go source`,mime:`text/x-go`}],[`.rs`,{description:`Rust source`,mime:`text/x-rust`}],[`.c`,{description:`C source`,mime:`text/x-c`}],[`.h`,{description:`C header`,mime:`text/x-c`}],[`.cpp`,{description:`C++ source`,mime:`text/x-c++`}],[`.hpp`,{description:`C++ header`,mime:`text/x-c++`}],[`.java`,{description:`Java source`,mime:`text/x-java`}],[`.sh`,{description:`Bourne-Again shell script`,mime:`text/x-shellscript`}],[`.bash`,{description:`Bourne-Again shell script`,mime:`text/x-shellscript`}],[`.zsh`,{description:`Zsh shell script`,mime:`text/x-shellscript`}],[`.json`,{description:`JSON data`,mime:`application/json`}],[`.yaml`,{description:`YAML data`,mime:`text/yaml`}],[`.yml`,{description:`YAML data`,mime:`text/yaml`}],[`.xml`,{description:`XML document`,mime:`application/xml`}],[`.csv`,{description:`CSV text`,mime:`text/csv`}],[`.toml`,{description:`TOML data`,mime:`text/toml`}],[`.html`,{description:`HTML document`,mime:`text/html`}],[`.htm`,{description:`HTML document`,mime:`text/html`}],[`.css`,{description:`CSS stylesheet`,mime:`text/css`}],[`.svg`,{description:`SVG image`,mime:`image/svg+xml`}],[`.md`,{description:`Markdown document`,mime:`text/markdown`}],[`.markdown`,{description:`Markdown document`,mime:`text/markdown`}],[`.txt`,{description:`ASCII text`,mime:`text/plain`}],[`.rst`,{description:`reStructuredText`,mime:`text/x-rst`}],[`.env`,{description:`ASCII text`,mime:`text/plain`}],[`.gitignore`,{description:`ASCII text`,mime:`text/plain`}],[`.dockerignore`,{description:`ASCII text`,mime:`text/plain`}]]),Se=new Map([[`jpg`,`JPEG image data`],[`jpeg`,`JPEG image data`],[`png`,`PNG image data`],[`gif`,`GIF image data`],[`webp`,`WebP image data`],[`bmp`,`PC bitmap`],[`ico`,`MS Windows icon resource`],[`tif`,`TIFF image data`],[`tiff`,`TIFF image data`],[`psd`,`Adobe Photoshop Document`],[`avif`,`AVIF image`],[`heic`,`HEIC image`],[`heif`,`HEIF image`],[`jxl`,`JPEG XL image`],[`icns`,`Mac OS X icon`],[`svg`,`SVG Scalable Vector Graphics image`],[`pdf`,`PDF document`],[`epub`,`EPUB document`],[`mobi`,`Mobipocket E-book`],[`djvu`,`DjVu document`],[`zip`,`Zip archive data`],[`gz`,`gzip compressed data`],[`gzip`,`gzip compressed data`],[`bz2`,`bzip2 compressed data`],[`xz`,`XZ compressed data`],[`tar`,`POSIX tar archive`],[`rar`,`RAR archive data`],[`7z`,`7-zip archive data`],[`lz`,`lzip compressed data`],[`lzma`,`LZMA compressed data`],[`zst`,`Zstandard compressed data`],[`cab`,`Microsoft Cabinet archive`],[`ar`,`Unix ar archive`],[`rpm`,`RPM package`],[`deb`,`Debian binary package`],[`apk`,`Android Package`],[`dmg`,`Apple disk image`],[`iso`,`ISO 9660 CD-ROM filesystem data`],[`vhd`,`Microsoft Virtual Hard Disk`],[`vhdx`,`Microsoft Virtual Hard Disk (new format)`],[`qcow2`,`QEMU QCOW Image`],[`mp3`,`Audio file with ID3`],[`m4a`,`MPEG-4 audio`],[`aac`,`AAC audio`],[`wav`,`RIFF (little-endian) data, WAVE audio`],[`flac`,`FLAC audio bitstream data`],[`ogg`,`Ogg data`],[`oga`,`Ogg audio`],[`opus`,`Ogg Opus audio`],[`aiff`,`AIFF audio`],[`wma`,`Windows Media Audio`],[`amr`,`AMR audio`],[`mid`,`MIDI audio`],[`midi`,`MIDI audio`],[`ape`,`Monkey's Audio`],[`mp4`,`ISO Media, MPEG-4`],[`m4v`,`MPEG-4 video`],[`webm`,`WebM`],[`avi`,`RIFF (little-endian) data, AVI`],[`mov`,`ISO Media, Apple QuickTime movie`],[`mkv`,`Matroska data`],[`wmv`,`Windows Media Video`],[`flv`,`Flash Video`],[`3gp`,`3GPP multimedia`],[`3g2`,`3GPP2 multimedia`],[`ogv`,`Ogg video`],[`mts`,`MPEG transport stream`],[`m2ts`,`MPEG transport stream`],[`ts`,`MPEG transport stream`],[`mpg`,`MPEG video`],[`mpeg`,`MPEG video`],[`exe`,`PE32 executable`],[`dll`,`PE32 DLL`],[`elf`,`ELF executable`],[`mach`,`Mach-O executable`],[`wasm`,`WebAssembly (wasm) binary module`],[`dex`,`Android Dalvik executable`],[`class`,`Java class file`],[`swf`,`Adobe Flash`],[`doc`,`Microsoft Word Document`],[`docx`,`Microsoft Word 2007+ Document`],[`xls`,`Microsoft Excel Spreadsheet`],[`xlsx`,`Microsoft Excel 2007+ Spreadsheet`],[`ppt`,`Microsoft PowerPoint Presentation`],[`pptx`,`Microsoft PowerPoint 2007+ Presentation`],[`odt`,`OpenDocument Text`],[`ods`,`OpenDocument Spreadsheet`],[`odp`,`OpenDocument Presentation`],[`ttf`,`TrueType Font`],[`otf`,`OpenType Font`],[`woff`,`Web Open Font Format`],[`woff2`,`Web Open Font Format 2`],[`eot`,`Embedded OpenType font`],[`stl`,`Stereolithography CAD`],[`obj`,`Wavefront 3D Object`],[`gltf`,`GL Transmission Format`],[`glb`,`GL Transmission Format (binary)`],[`sqlite`,`SQLite 3.x database`],[`mdb`,`Microsoft Access Database`],[`xml`,`XML document`],[`json`,`JSON data`],[`macho`,`Mach-O binary`],[`ics`,`iCalendar data`],[`vcf`,`vCard data`],[`msi`,`Microsoft Installer`],[`ps`,`PostScript`],[`ai`,`Adobe Illustrator`],[`indd`,`Adobe InDesign`],[`sketch`,`Sketch design file`],[`fig`,`Figma design file`],[`xd`,`Adobe XD`],[`blend`,`Blender`],[`fbx`,`Autodesk FBX`],[`lnk`,`MS Windows shortcut`],[`alias`,`Mac OS alias`],[`torrent`,`BitTorrent file`],[`pcap`,`pcap capture file`],[`arrow`,`Apache Arrow`],[`parquet`,`Apache Parquet`]]);function Ce(e,t){let n=Se.get(e);if(n)return n;let[r,i]=t.split(`/`),a=i?.split(`+`)[0]?.replace(/-/g,` `)||e;switch(r){case`image`:return`${a.toUpperCase()} image data`;case`audio`:return`${a.toUpperCase()} audio`;case`video`:return`${a.toUpperCase()} video`;case`font`:return`${a} font`;case`model`:return`${a} 3D model`;case`application`:return i?.includes(`zip`)||i?.includes(`compressed`)?`${a} archive data`:i?.includes(`executable`)?`${a} executable`:`${e.toUpperCase()} data`;default:return`${e.toUpperCase()} data`}}function we(e){let t=e.split(`/`).pop()||e;if(t.startsWith(`.`)&&!t.includes(`.`,1))return t;let n=t.lastIndexOf(`.`);return n===-1||n===0?``:t.slice(n).toLowerCase()}function Te(e,t){if(e.startsWith(`#!`)){let t=e.split(`
|
|
9
|
-
`)[0];return t.includes(`python`)?{description:`Python script, ASCII text executable`,mime:`text/x-python`}:t.includes(`node`)||t.includes(`bun`)||t.includes(`deno`)?{description:`JavaScript script, ASCII text executable`,mime:`text/javascript`}:t.includes(`bash`)?{description:`Bourne-Again shell script, ASCII text executable`,mime:`text/x-shellscript`}:t.includes(`sh`)?{description:`POSIX shell script, ASCII text executable`,mime:`text/x-shellscript`}:t.includes(`ruby`)?{description:`Ruby script, ASCII text executable`,mime:`text/x-ruby`}:t.includes(`perl`)?{description:`Perl script, ASCII text executable`,mime:`text/x-perl`}:{description:`script, ASCII text executable`,mime:`text/plain`}}let n=e.trimStart();if(n.startsWith(`<?xml`))return{description:`XML document`,mime:`application/xml`};if(n.startsWith(`<!DOCTYPE html`)||n.toLowerCase().startsWith(`<html`))return{description:`HTML document`,mime:`text/html`};let r=e.includes(`\r
|
|
10
|
-
`),i=e.includes(`\r`)&&!r,a=``;r?a=`, with CRLF line terminators`:i&&(a=`, with CR line terminators`);let o=we(t),s=o?xe.get(o):void 0;if(s)return s.mime.startsWith(`text/`)&&a?{description:`${s.description}${a}`,mime:s.mime}:s;let c=!1;for(let t=0;t<Math.min(e.length,8192);t++)if(e.charCodeAt(t)>127){c=!0;break}return c?{description:`UTF-8 Unicode text${a}`,mime:`text/plain; charset=utf-8`}:{description:`ASCII text${a}`,mime:`text/plain`}}async function Ee(e,t){if(t.length===0)return{description:`empty`,mime:`inode/x-empty`};let n=await ye(t);return n?{description:Ce(n.ext,n.mime),mime:n.mime}:Te(new TextDecoder(`utf-8`,{fatal:!1}).decode(t),e)}var De={name:`file`,async execute(e,t){if(a(e))return i($);let n=!1,o=!1,s=[];for(let t of e)if(t.startsWith(`--`)){if(t===`--brief`)n=!0;else if(t===`--mime`||t===`--mime-type`)o=!0;else if(t!==`--dereference`)return r(`file`,t)}else if(t.startsWith(`-`)&&t!==`-`){for(let e of t.slice(1))if(e===`b`)n=!0;else if(e===`i`)o=!0;else if(e!==`L`)return r(`file`,`-${e}`)}else s.push(t);if(s.length===0)return{stdout:``,stderr:`Usage: file [-bLi] FILE...
|
|
11
|
-
`,exitCode:1};let c=``,l=0;for(let e of s)try{let r=t.fs.resolvePath(t.cwd,e);if((await t.fs.stat(r)).isDirectory){let t=o?`inode/directory`:`directory`;c+=n?`${t}
|
|
12
|
-
`:`${e}: ${t}
|
|
13
|
-
`;continue}let i=await Ee(e,await t.fs.readFileBuffer(r)),a=o?i.mime:i.description;c+=n?`${a}
|
|
14
|
-
`:`${e}: ${a}
|
|
15
|
-
`}catch{c+=n?`cannot open
|
|
16
|
-
`:`${e}: cannot open (No such file or directory)
|
|
17
|
-
`,l=1}return{stdout:c,stderr:``,exitCode:l}}},Oe={name:`file`,flags:[{flag:`-b`,type:`boolean`},{flag:`-i`,type:`boolean`},{flag:`-L`,type:`boolean`}],needsArgs:!0};
|
|
18
|
-
/*! Bundled license information:
|
|
19
|
-
|
|
20
|
-
ieee754/index.js:
|
|
21
|
-
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
|
22
|
-
*/
|
|
23
|
-
export{Oe as n,De as t};
|
|
24
|
-
//# sourceMappingURL=chunk-CR5AFCPT-BD_awIEP.mjs.map
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import{a as e,s as t,t as n}from"./chunk-C94x7I9S.mjs";import{t as r}from"./chunk-5QMZ5MUS-_0tQyQsf.mjs";import{n as i,t as a}from"./chunk-A5O5YHGN-Kbs3GRxW.mjs";import{n as o}from"./chunk-24IMIIXA-BoP5OA93.mjs";import{n as s,t as c}from"./chunk-3THT3N7L-CBWmNncQ.mjs";import{r as l,t as u}from"./chunk-74CEPOFO-V0JXh91S.mjs";import{dirname as d,join as f}from"node:path";import{fileURLToPath as p}from"node:url";import{existsSync as m}from"node:fs";import{randomBytes as h}from"node:crypto";import{Worker as g}from"node:worker_threads";var _=t(n(((t,n)=>{var r=void 0,i=function(t){return r||(r=new Promise(function(r,i){var a=t===void 0?{}:t,o=a.onAbort;a.onAbort=function(e){i(Error(e)),o&&o(e)},a.postRun=a.postRun||[],a.postRun.push(function(){r(a)}),n=void 0;var s;s||=a===void 0?{}:a;var c=!!globalThis.window,l=!!globalThis.WorkerGlobalScope,u=globalThis.process?.versions?.node&&globalThis.process?.type!=`renderer`;s.onRuntimeInitialized=function(){function e(e,t){switch(typeof t){case`boolean`:fe(e,t?1:0);break;case`number`:ue(e,t);break;case`string`:j(e,t,-1,-1);break;case`object`:if(t===null)de(e);else if(t.length!=null){var n=Mt(t.length);C.set(t,n),M(e,n,t.length,-1),Nt(n)}else P(e,`Wrong API use : tried to return a value of an unknown type (`+t+`).`,-1);break;default:de(e)}}function t(e,t){for(var n=[],r=0;r<e;r+=1){var i=N(t+4*r,`i32`),a=ae(i);if(a===1||a===2)i=le(i);else if(a===3)i=se(i);else if(a===4){a=i,i=oe(a),a=ce(a);for(var o=new Uint8Array(i),s=0;s<i;s+=1)o[s]=C[a+s];i=o}else i=null;n.push(i)}return n}function n(e,t){this.Qa=e,this.db=t,this.Oa=1,this.mb=[]}function r(e,t){if(this.db=t,this.fb=Et(e),this.fb===null)throw Error(`Unable to allocate memory for the SQL string`);this.lb=this.fb,this.$a=this.sb=null}function i(e){if(this.filename=`dbfile_`+(4294967295*Math.random()>>>0),e!=null){var t=this.filename,n=`/`,r=t;if(n&&(n=typeof n==`string`?n:Re(n),r=t?ge(n+`/`+t):n),t=ke(!0,!0),r=Qe(r,t),e){if(typeof e==`string`){n=Array(e.length);for(var i=0,o=e.length;i<o;++i)n[i]=e.charCodeAt(i);e=n}at(r,t|146),n=st(r,577),dt(n,e,0,e.length,0),ct(n),at(r,t)}}this.handleError(c(this.filename,a)),this.db=N(a,`i32`),he(this.db),this.gb={},this.Sa={}}var a=Q(4),o=s.cwrap,c=o(`sqlite3_open`,`number`,[`string`,`number`]),l=o(`sqlite3_close_v2`,`number`,[`number`]),u=o(`sqlite3_exec`,`number`,[`number`,`string`,`number`,`number`,`number`]),d=o(`sqlite3_changes`,`number`,[`number`]),f=o(`sqlite3_prepare_v2`,`number`,[`number`,`string`,`number`,`number`,`number`]),p=o(`sqlite3_sql`,`string`,[`number`]),m=o(`sqlite3_normalized_sql`,`string`,[`number`]),h=o(`sqlite3_prepare_v2`,`number`,[`number`,`number`,`number`,`number`,`number`]),g=o(`sqlite3_bind_text`,`number`,[`number`,`number`,`number`,`number`,`number`]),_=o(`sqlite3_bind_blob`,`number`,[`number`,`number`,`number`,`number`,`number`]),ee=o(`sqlite3_bind_double`,`number`,[`number`,`number`,`number`]),v=o(`sqlite3_bind_int`,`number`,[`number`,`number`,`number`]),y=o(`sqlite3_bind_parameter_index`,`number`,[`number`,`string`]),b=o(`sqlite3_step`,`number`,[`number`]),x=o(`sqlite3_errmsg`,`string`,[`number`]),S=o(`sqlite3_column_count`,`number`,[`number`]),w=o(`sqlite3_data_count`,`number`,[`number`]),T=o(`sqlite3_column_double`,`number`,[`number`,`number`]),E=o(`sqlite3_column_text`,`string`,[`number`,`number`]),D=o(`sqlite3_column_blob`,`number`,[`number`,`number`]),te=o(`sqlite3_column_bytes`,`number`,[`number`,`number`]),ne=o(`sqlite3_column_type`,`number`,[`number`,`number`]),O=o(`sqlite3_column_name`,`string`,[`number`,`number`]),re=o(`sqlite3_reset`,`number`,[`number`]),k=o(`sqlite3_clear_bindings`,`number`,[`number`]),A=o(`sqlite3_finalize`,`number`,[`number`]),ie=o(`sqlite3_create_function_v2`,`number`,`number string number number number number number number number`.split(` `)),ae=o(`sqlite3_value_type`,`number`,[`number`]),oe=o(`sqlite3_value_bytes`,`number`,[`number`]),se=o(`sqlite3_value_text`,`string`,[`number`]),ce=o(`sqlite3_value_blob`,`number`,[`number`]),le=o(`sqlite3_value_double`,`number`,[`number`]),ue=o(`sqlite3_result_double`,``,[`number`,`number`]),de=o(`sqlite3_result_null`,``,[`number`]),j=o(`sqlite3_result_text`,``,[`number`,`string`,`number`,`number`]),M=o(`sqlite3_result_blob`,``,[`number`,`number`,`number`,`number`]),fe=o(`sqlite3_result_int`,``,[`number`,`number`]),P=o(`sqlite3_result_error`,``,[`number`,`string`,`number`]),me=o(`sqlite3_aggregate_context`,`number`,[`number`,`number`]),he=o(`RegisterExtensionFunctions`,`number`,[`number`]),_e=o(`sqlite3_update_hook`,`number`,[`number`,`number`,`number`]);n.prototype.bind=function(e){if(!this.Qa)throw`Statement closed`;return this.reset(),Array.isArray(e)?this.Gb(e):typeof e==`object`&&e?this.Hb(e):!0},n.prototype.step=function(){if(!this.Qa)throw`Statement closed`;this.Oa=1;var e=b(this.Qa);switch(e){case 100:return!0;case 101:return!1;default:throw this.db.handleError(e)}},n.prototype.Ab=function(e){return e??(e=this.Oa,this.Oa+=1),T(this.Qa,e)},n.prototype.Ob=function(e){if(e??(e=this.Oa,this.Oa+=1),e=E(this.Qa,e),typeof BigInt!=`function`)throw Error(`BigInt is not supported`);return BigInt(e)},n.prototype.Tb=function(e){return e??(e=this.Oa,this.Oa+=1),E(this.Qa,e)},n.prototype.getBlob=function(e){e??(e=this.Oa,this.Oa+=1);var t=te(this.Qa,e);e=D(this.Qa,e);for(var n=new Uint8Array(t),r=0;r<t;r+=1)n[r]=C[e+r];return n},n.prototype.get=function(e,t){t||={},e!=null&&this.bind(e)&&this.step(),e=[];for(var n=w(this.Qa),r=0;r<n;r+=1)switch(ne(this.Qa,r)){case 1:var i=t.useBigInt?this.Ob(r):this.Ab(r);e.push(i);break;case 2:e.push(this.Ab(r));break;case 3:e.push(this.Tb(r));break;case 4:e.push(this.getBlob(r));break;default:e.push(null)}return e},n.prototype.qb=function(){for(var e=[],t=S(this.Qa),n=0;n<t;n+=1)e.push(O(this.Qa,n));return e},n.prototype.zb=function(e,t){e=this.get(e,t),t=this.qb();for(var n={},r=0;r<t.length;r+=1)n[t[r]]=e[r];return n},n.prototype.Sb=function(){return p(this.Qa)},n.prototype.Pb=function(){return m(this.Qa)},n.prototype.run=function(e){return e!=null&&this.bind(e),this.step(),this.reset()},n.prototype.wb=function(e,t){t??(t=this.Oa,this.Oa+=1),e=Et(e),this.mb.push(e),this.db.handleError(g(this.Qa,t,e,-1,0))},n.prototype.Fb=function(e,t){t??(t=this.Oa,this.Oa+=1);var n=Mt(e.length);C.set(e,n),this.mb.push(n),this.db.handleError(_(this.Qa,t,n,e.length,0))},n.prototype.vb=function(e,t){t??(t=this.Oa,this.Oa+=1),this.db.handleError((e===(e|0)?v:ee)(this.Qa,t,e))},n.prototype.Ib=function(e){e??(e=this.Oa,this.Oa+=1),_(this.Qa,e,0,0,0)},n.prototype.xb=function(e,t){switch(t??(t=this.Oa,this.Oa+=1),typeof e){case`string`:this.wb(e,t);return;case`number`:this.vb(e,t);return;case`bigint`:this.wb(e.toString(),t);return;case`boolean`:this.vb(e+0,t);return;case`object`:if(e===null){this.Ib(t);return}if(e.length!=null){this.Fb(e,t);return}}throw`Wrong API use : tried to bind a value of an unknown type (`+e+`).`},n.prototype.Hb=function(e){var t=this;return Object.keys(e).forEach(function(n){var r=y(t.Qa,n);r!==0&&t.xb(e[n],r)}),!0},n.prototype.Gb=function(e){for(var t=0;t<e.length;t+=1)this.xb(e[t],t+1);return!0},n.prototype.reset=function(){return this.freemem(),k(this.Qa)===0&&re(this.Qa)===0},n.prototype.freemem=function(){for(var e;(e=this.mb.pop())!==void 0;)Nt(e)},n.prototype.Ya=function(){this.freemem();var e=A(this.Qa)===0;return delete this.db.gb[this.Qa],this.Qa=0,e},r.prototype.next=function(){if(this.fb===null)return{done:!0};if(this.$a!==null&&(this.$a.Ya(),this.$a=null),!this.db.db)throw this.ob(),Error(`Database closed`);var e=Lt(),t=Q(4);pe(a),pe(t);try{this.db.handleError(h(this.db.db,this.lb,-1,a,t)),this.lb=N(t,`i32`);var r=N(a,`i32`);return r===0?(this.ob(),{done:!0}):(this.$a=new n(r,this.db),this.db.gb[r]=this.$a,{value:this.$a,done:!1})}catch(e){throw this.sb=F(this.lb),this.ob(),e}finally{It(e)}},r.prototype.ob=function(){Nt(this.fb),this.fb=null},r.prototype.Qb=function(){return this.sb===null?F(this.lb):this.sb},typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`&&(r.prototype[Symbol.iterator]=function(){return this}),i.prototype.run=function(e,t){if(!this.db)throw`Database closed`;if(t){e=this.tb(e,t);try{e.step()}finally{e.Ya()}}else this.handleError(u(this.db,e,0,0,a));return this},i.prototype.exec=function(e,t,r){if(!this.db)throw`Database closed`;var i=null,o=null,s=null;try{s=o=Et(e);var c=Q(4);for(e=[];N(s,`i8`)!==0;){pe(a),pe(c),this.handleError(h(this.db,s,-1,a,c));var l=N(a,`i32`);if(s=N(c,`i32`),l!==0){var u=null;for(i=new n(l,this),t!=null&&i.bind(t);i.step();)u===null&&(u={columns:i.qb(),values:[]},e.push(u)),u.values.push(i.get(null,r));i.Ya()}}return e}catch(e){throw i&&i.Ya(),e}finally{o&&Nt(o)}},i.prototype.Mb=function(e,t,n,r,i){typeof t==`function`&&(r=n,n=t,t=void 0),e=this.tb(e,t);try{for(;e.step();)n(e.zb(null,i))}finally{e.Ya()}if(typeof r==`function`)return r()},i.prototype.tb=function(e,t){if(pe(a),this.handleError(f(this.db,e,-1,a,0)),e=N(a,`i32`),e===0)throw`Nothing to prepare`;var r=new n(e,this);return t!=null&&r.bind(t),this.gb[e]=r},i.prototype.Ub=function(e){return new r(e,this)},i.prototype.Nb=function(){Object.values(this.gb).forEach(function(e){e.Ya()}),Object.values(this.Sa).forEach(Z),this.Sa={},this.handleError(l(this.db));var e=ft(this.filename);return this.handleError(c(this.filename,a)),this.db=N(a,`i32`),he(this.db),e},i.prototype.close=function(){this.db!==null&&(Object.values(this.gb).forEach(function(e){e.Ya()}),Object.values(this.Sa).forEach(Z),this.Sa={},this.Za&&=(Z(this.Za),void 0),this.handleError(l(this.db)),nt(`/`+this.filename),this.db=null)},i.prototype.handleError=function(e){if(e===0)return null;throw e=x(this.db),Error(e)},i.prototype.Rb=function(){return d(this.db)},i.prototype.Kb=function(n,r){Object.prototype.hasOwnProperty.call(this.Sa,n)&&(Z(this.Sa[n]),delete this.Sa[n]);var i=jt(function(n,i,a){i=t(i,a);try{var o=r.apply(null,i)}catch(e){P(n,e,-1);return}e(n,o)},`viii`);return this.Sa[n]=i,this.handleError(ie(this.db,n,r.length,1,0,i,0,0,0)),this},i.prototype.Jb=function(n,r){var i=r.init||function(){return null},a=r.finalize||function(e){return e},o=r.step;if(!o)throw`An aggregate function must have a step function in `+n;var s={};Object.hasOwnProperty.call(this.Sa,n)&&(Z(this.Sa[n]),delete this.Sa[n]),r=n+`__finalize`,Object.hasOwnProperty.call(this.Sa,r)&&(Z(this.Sa[r]),delete this.Sa[r]);var c=jt(function(e,n,r){var a=me(e,1);Object.hasOwnProperty.call(s,a)||(s[a]=i()),n=t(n,r),n=[s[a]].concat(n);try{s[a]=o.apply(null,n)}catch(t){delete s[a],P(e,t,-1)}},`viii`),l=jt(function(t){var n=me(t,1);try{var r=a(s[n])}catch(e){delete s[n],P(t,e,-1);return}e(t,r),delete s[n]},`vi`);return this.Sa[n]=c,this.Sa[r]=l,this.handleError(ie(this.db,n,o.length-1,1,0,0,c,l,0)),this},i.prototype.Zb=function(e){return this.Za&&=(_e(this.db,0,0),Z(this.Za),void 0),e?(this.Za=jt(function(t,n,r,i,a){switch(n){case 18:t=`insert`;break;case 23:t=`update`;break;case 9:t=`delete`;break;default:throw`unknown operationCode in updateHook callback: `+n}if(r=F(r),i=F(i),a>2**53-1)throw`rowId too big to fit inside a Number`;e(t,r,i,Number(a))},`viiiij`),_e(this.db,this.Za,0),this):this},n.prototype.bind=n.prototype.bind,n.prototype.step=n.prototype.step,n.prototype.get=n.prototype.get,n.prototype.getColumnNames=n.prototype.qb,n.prototype.getAsObject=n.prototype.zb,n.prototype.getSQL=n.prototype.Sb,n.prototype.getNormalizedSQL=n.prototype.Pb,n.prototype.run=n.prototype.run,n.prototype.reset=n.prototype.reset,n.prototype.freemem=n.prototype.freemem,n.prototype.free=n.prototype.Ya,r.prototype.next=r.prototype.next,r.prototype.getRemainingSQL=r.prototype.Qb,i.prototype.run=i.prototype.run,i.prototype.exec=i.prototype.exec,i.prototype.each=i.prototype.Mb,i.prototype.prepare=i.prototype.tb,i.prototype.iterateStatements=i.prototype.Ub,i.prototype.export=i.prototype.Nb,i.prototype.close=i.prototype.close,i.prototype.handleError=i.prototype.handleError,i.prototype.getRowsModified=i.prototype.Rb,i.prototype.create_function=i.prototype.Kb,i.prototype.create_aggregate=i.prototype.Jb,i.prototype.updateHook=i.prototype.Zb,s.Database=i};var d=`./this.program`,f=(e,t)=>{throw t},p=globalThis.document?.currentScript?.src;typeof __filename<`u`?p=__filename:l&&(p=self.location.href);var m=``,h,g;if(u){var _=e(`node:fs`);m=__dirname+`/`,g=e=>(e=S(e)?new URL(e):e,_.readFileSync(e)),h=async e=>(e=S(e)?new URL(e):e,_.readFileSync(e,void 0)),1<process.argv.length&&(d=process.argv[1].replace(/\\/g,`/`)),process.argv.slice(2),n!==void 0&&(n.exports=s),f=(e,t)=>{throw process.exitCode=e,t}}else if(c||l){try{m=new URL(`.`,p).href}catch{}l&&(g=e=>{var t=new XMLHttpRequest;return t.open(`GET`,e,!1),t.responseType=`arraybuffer`,t.send(null),new Uint8Array(t.response)}),h=async e=>{if(S(e))return new Promise((t,n)=>{var r=new XMLHttpRequest;r.open(`GET`,e,!0),r.responseType=`arraybuffer`,r.onload=()=>{r.status==200||r.status==0&&r.response?t(r.response):n(r.status)},r.onerror=n,r.send(null)});var t=await fetch(e,{credentials:`same-origin`});if(t.ok)return t.arrayBuffer();throw Error(t.status+` : `+t.url)}}var ee=console.log.bind(console),v=console.error.bind(console),y,b=!1,x,S=e=>e.startsWith(`file://`),C,w,T,E,D,te,ne,O;function re(){var e=Rt.buffer;C=new Int8Array(e),T=new Int16Array(e),w=new Uint8Array(e),new Uint16Array(e),E=new Int32Array(e),D=new Uint32Array(e),te=new Float32Array(e),ne=new Float64Array(e),O=new BigInt64Array(e),new BigUint64Array(e)}function k(e){throw s.onAbort?.(e),e=`Aborted(`+e+`)`,v(e),b=!0,new WebAssembly.RuntimeError(e+`. Build with -sASSERTIONS for more info.`)}var A;async function ie(e){if(!y)try{var t=await h(e);return new Uint8Array(t)}catch{}if(e==A&&y)e=new Uint8Array(y);else if(g)e=g(e);else throw`both async and sync fetching of the wasm failed`;return e}async function ae(e,t){try{var n=await ie(e);return await WebAssembly.instantiate(n,t)}catch(e){v(`failed to asynchronously prepare wasm: ${e}`),k(e)}}async function oe(e){var t=A;if(!y&&!S(t)&&!u)try{var n=fetch(t,{credentials:`same-origin`});return await WebAssembly.instantiateStreaming(n,e)}catch(e){v(`wasm streaming compile failed: ${e}`),v(`falling back to ArrayBuffer instantiation`)}return ae(t,e)}class se{name=`ExitStatus`;constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var ce=e=>{for(;0<e.length;)e.shift()(s)},le=[],ue=[],de=()=>{var e=s.preRun.shift();ue.push(e)},j=0,M=null;function N(e,t=`i8`){switch(t.endsWith(`*`)&&(t=`*`),t){case`i1`:return C[e];case`i8`:return C[e];case`i16`:return T[e>>1];case`i32`:return E[e>>2];case`i64`:return O[e>>3];case`float`:return te[e>>2];case`double`:return ne[e>>3];case`*`:return D[e>>2];default:k(`invalid type for getValue: ${t}`)}}var fe=!0;function pe(e){var t=`i32`;switch(t.endsWith(`*`)&&(t=`*`),t){case`i1`:C[e]=0;break;case`i8`:C[e]=0;break;case`i16`:T[e>>1]=0;break;case`i32`:E[e>>2]=0;break;case`i64`:O[e>>3]=BigInt(0);break;case`float`:te[e>>2]=0;break;case`double`:ne[e>>3]=0;break;case`*`:D[e>>2]=0;break;default:k(`invalid type for setValue: ${t}`)}}var P=new TextDecoder,me=(e,t,n,r)=>{if(n=t+n,r)return n;for(;e[t]&&!(t>=n);)++t;return t},F=(e,t,n)=>e?P.decode(w.subarray(e,me(w,e,t,n))):``,he=(e,t)=>{for(var n=0,r=e.length-1;0<=r;r--){var i=e[r];i===`.`?e.splice(r,1):i===`..`?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n;n--)e.unshift(`..`);return e},ge=e=>{var t=e.charAt(0)===`/`,n=e.slice(-1)===`/`;return(e=he(e.split(`/`).filter(e=>!!e),!t).join(`/`))||t||(e=`.`),e&&n&&(e+=`/`),(t?`/`:``)+e},_e=e=>{var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],!e&&!t?`.`:(t&&=t.slice(0,-1),e+t)},ve=e=>e&&e.match(/([^\/]+|\/)\/*$/)[1],ye=()=>{if(u){var t=e(`node:crypto`);return e=>t.randomFillSync(e)}return e=>crypto.getRandomValues(e)},be=e=>{(be=ye())(e)},xe=(...e)=>{for(var t=``,n=!1,r=e.length-1;-1<=r&&!n;r--){if(n=0<=r?e[r]:`/`,typeof n!=`string`)throw TypeError(`Arguments to path.resolve must be strings`);if(!n)return``;t=n+`/`+t,n=n.charAt(0)===`/`}return t=he(t.split(`/`).filter(e=>!!e),!n).join(`/`),(n?`/`:``)+t||`.`},Se=e=>{var t=me(e,0);return P.decode(e.buffer?e.subarray(0,t):new Uint8Array(e.slice(0,t)))},Ce=[],I=e=>{for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);127>=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t},L=(e,t,n,r)=>{if(!(0<r))return 0;var i=n;r=n+r-1;for(var a=0;a<e.length;++a){var o=e.codePointAt(a);if(127>=o){if(n>=r)break;t[n++]=o}else if(2047>=o){if(n+1>=r)break;t[n++]=192|o>>6,t[n++]=128|o&63}else if(65535>=o){if(n+2>=r)break;t[n++]=224|o>>12,t[n++]=128|o>>6&63,t[n++]=128|o&63}else{if(n+3>=r)break;t[n++]=240|o>>18,t[n++]=128|o>>12&63,t[n++]=128|o>>6&63,t[n++]=128|o&63,a++}}return t[n]=0,n-i},we=[];function Te(e,t){we[e]={input:[],output:[],eb:t},Ye(e,Ee)}var Ee={open(e){var t=we[e.node.rdev];if(!t)throw new B(43);e.tty=t,e.seekable=!1},close(e){e.tty.eb.fsync(e.tty)},fsync(e){e.tty.eb.fsync(e.tty)},read(e,t,n,r){if(!e.tty||!e.tty.eb.Bb)throw new B(60);for(var i=0,a=0;a<r;a++){try{var o=e.tty.eb.Bb(e.tty)}catch{throw new B(29)}if(o===void 0&&i===0)throw new B(6);if(o==null)break;i++,t[n+a]=o}return i&&(e.node.atime=Date.now()),i},write(e,t,n,r){if(!e.tty||!e.tty.eb.ub)throw new B(60);try{for(var i=0;i<r;i++)e.tty.eb.ub(e.tty,t[n+i])}catch{throw new B(29)}return r&&(e.node.mtime=e.node.ctime=Date.now()),i}},De={Bb(){a:{if(!Ce.length){var e=null;if(u){var t=Buffer.alloc(256),n=0,r=process.stdin.fd;try{n=_.readSync(r,t,0,256)}catch(e){if(e.toString().includes(`EOF`))n=0;else throw e}0<n&&(e=t.slice(0,n).toString(`utf-8`))}else globalThis.window?.prompt&&(e=window.prompt(`Input: `),e!==null&&(e+=`
|
|
2
|
-
`));if(!e){e=null;break a}t=Array(I(e)+1),e=L(e,t,0,t.length),t.length=e,Ce=t}e=Ce.shift()}return e},ub(e,t){t===null||t===10?(ee(Se(e.output)),e.output=[]):t!=0&&e.output.push(t)},fsync(e){0<e.output?.length&&(ee(Se(e.output)),e.output=[])},hc(){return{bc:25856,dc:5,ac:191,cc:35387,$b:[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},ic(){return 0},jc(){return[24,80]}},Oe={ub(e,t){t===null||t===10?(v(Se(e.output)),e.output=[]):t!=0&&e.output.push(t)},fsync(e){0<e.output?.length&&(v(Se(e.output)),e.output=[])}},R={Wa:null,Xa(){return R.createNode(null,`/`,16895,0)},createNode(e,t,n,r){if((n&61440)==24576||(n&61440)==4096)throw new B(63);return R.Wa||={dir:{node:{Ta:R.La.Ta,Ua:R.La.Ua,lookup:R.La.lookup,ib:R.La.ib,rename:R.La.rename,unlink:R.La.unlink,rmdir:R.La.rmdir,readdir:R.La.readdir,symlink:R.La.symlink},stream:{Va:R.Ma.Va}},file:{node:{Ta:R.La.Ta,Ua:R.La.Ua},stream:{Va:R.Ma.Va,read:R.Ma.read,write:R.Ma.write,jb:R.Ma.jb,kb:R.Ma.kb}},link:{node:{Ta:R.La.Ta,Ua:R.La.Ua,readlink:R.La.readlink},stream:{}},yb:{node:{Ta:R.La.Ta,Ua:R.La.Ua},stream:Je}},n=Ve(e,t,n,r),U(n.mode)?(n.La=R.Wa.dir.node,n.Ma=R.Wa.dir.stream,n.Na={}):(n.mode&61440)==32768?(n.La=R.Wa.file.node,n.Ma=R.Wa.file.stream,n.Ra=0,n.Na=null):(n.mode&61440)==40960?(n.La=R.Wa.link.node,n.Ma=R.Wa.link.stream):(n.mode&61440)==8192&&(n.La=R.Wa.yb.node,n.Ma=R.Wa.yb.stream),n.atime=n.mtime=n.ctime=Date.now(),e&&(e.Na[t]=n,e.atime=e.mtime=e.ctime=n.atime),n},fc(e){return e.Na?e.Na.subarray?e.Na.subarray(0,e.Ra):new Uint8Array(e.Na):new Uint8Array},La:{Ta(e){var t={};return t.dev=(e.mode&61440)==8192?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,U(e.mode)?t.size=4096:(e.mode&61440)==32768?t.size=e.Ra:(e.mode&61440)==40960?t.size=e.link.length:t.size=0,t.atime=new Date(e.atime),t.mtime=new Date(e.mtime),t.ctime=new Date(e.ctime),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},Ua(e,t){for(var n of[`mode`,`atime`,`mtime`,`ctime`])t[n]!=null&&(e[n]=t[n]);t.size!==void 0&&(t=t.size,e.Ra!=t&&(t==0?(e.Na=null,e.Ra=0):(n=e.Na,e.Na=new Uint8Array(t),n&&e.Na.set(n.subarray(0,Math.min(t,e.Ra))),e.Ra=t)))},lookup(){throw R.nb||(R.nb=new B(44),R.nb.stack=`<generic error, no stack>`),R.nb},ib(e,t,n,r){return R.createNode(e,t,n,r)},rename(e,t,n){try{var r=H(t,n)}catch{}if(r){if(U(e.mode))for(var i in r.Na)throw new B(55);Be(r)}delete e.parent.Na[e.name],t.Na[n]=e,e.name=n,t.ctime=t.mtime=e.parent.ctime=e.parent.mtime=Date.now()},unlink(e,t){delete e.Na[t],e.ctime=e.mtime=Date.now()},rmdir(e,t){var n=H(e,t),r;for(r in n.Na)throw new B(55);delete e.Na[t],e.ctime=e.mtime=Date.now()},readdir(e){return[`.`,`..`,...Object.keys(e.Na)]},symlink(e,t,n){return e=R.createNode(e,t,41471,0),e.link=n,e},readlink(e){if((e.mode&61440)!=40960)throw new B(28);return e.link}},Ma:{read(e,t,n,r,i){var a=e.node.Na;if(i>=e.node.Ra)return 0;if(e=Math.min(e.node.Ra-i,r),8<e&&a.subarray)t.set(a.subarray(i,i+e),n);else for(r=0;r<e;r++)t[n+r]=a[i+r];return e},write(e,t,n,r,i,a){if(t.buffer===C.buffer&&(a=!1),!r)return 0;if(e=e.node,e.mtime=e.ctime=Date.now(),t.subarray&&(!e.Na||e.Na.subarray)){if(a)return e.Na=t.subarray(n,n+r),e.Ra=r;if(e.Ra===0&&i===0)return e.Na=t.slice(n,n+r),e.Ra=r;if(i+r<=e.Ra)return e.Na.set(t.subarray(n,n+r),i),r}a=i+r;var o=e.Na?e.Na.length:0;if(o>=a||(a=Math.max(a,o*(1048576>o?2:1.125)>>>0),o!=0&&(a=Math.max(a,256)),o=e.Na,e.Na=new Uint8Array(a),0<e.Ra&&e.Na.set(o.subarray(0,e.Ra),0)),e.Na.subarray&&t.subarray)e.Na.set(t.subarray(n,n+r),i);else for(a=0;a<r;a++)e.Na[i+a]=t[n+a];return e.Ra=Math.max(e.Ra,i+r),r},Va(e,t,n){if(n===1?t+=e.position:n===2&&(e.node.mode&61440)==32768&&(t+=e.node.Ra),0>t)throw new B(28);return t},jb(e,t,n,r,i){if((e.node.mode&61440)!=32768)throw new B(43);if(e=e.node.Na,i&2||!e||e.buffer!==C.buffer){i=!0,r=65536*Math.ceil(t/65536);var a=Pt(65536,r);if(a&&w.fill(0,a,a+r),r=a,!r)throw new B(48);e&&((0<n||n+t<e.length)&&(e=e.subarray?e.subarray(n,n+t):Array.prototype.slice.call(e,n,n+t)),C.set(e,r))}else i=!1,r=e.byteOffset;return{Xb:r,Eb:i}},kb(e,t,n,r){return R.Ma.write(e,t,0,r,n,!1),0}}},ke=(e,t)=>{var n=0;return e&&(n|=365),t&&(n|=146),n},Ae=null,je={},Me=[],Ne=1,z=null,Pe=!1,Fe=!0,B=class{name=`ErrnoError`;constructor(e){this.Pa=e}},Ie=class{hb={};node=null;get flags(){return this.hb.flags}set flags(e){this.hb.flags=e}get position(){return this.hb.position}set position(e){this.hb.position=e}},Le=class{La={};Ma={};bb=null;constructor(e,t,n,r){e||=this,this.parent=e,this.Xa=e.Xa,this.id=Ne++,this.name=t,this.mode=n,this.rdev=r,this.atime=this.mtime=this.ctime=Date.now()}get read(){return(this.mode&365)==365}set read(e){e?this.mode|=365:this.mode&=-366}get write(){return(this.mode&146)==146}set write(e){e?this.mode|=146:this.mode&=-147}};function V(e,t={}){if(!e)throw new B(44);t.pb??=!0,e.charAt(0)===`/`||(e=`//`+e);var n=0;a:for(;40>n;n++){e=e.split(`/`).filter(e=>!!e);for(var r=Ae,i=`/`,a=0;a<e.length;a++){var o=a===e.length-1;if(o&&t.parent)break;if(e[a]!==`.`)if(e[a]===`..`)if(i=_e(i),r===r.parent){e=i+`/`+e.slice(a+1).join(`/`),n--;continue a}else r=r.parent;else{i=ge(i+`/`+e[a]);try{r=H(r,e[a])}catch(e){if(e?.Pa===44&&o&&t.Wb)return{path:i};throw e}if(!r.bb||o&&!t.pb||(r=r.bb.root),(r.mode&61440)==40960&&(!o||t.ab)){if(!r.La.readlink)throw new B(52);r=r.La.readlink(r),r.charAt(0)===`/`||(r=_e(i)+`/`+r),e=r+`/`+e.slice(a+1).join(`/`);continue a}}}return{path:i,node:r}}throw new B(32)}function Re(e){for(var t;;){if(e===e.parent)return e=e.Xa.Db,t?e[e.length-1]===`/`?e+t:`${e}/${t}`:e;t=t?`${e.name}/${t}`:e.name,e=e.parent}}function ze(e,t){for(var n=0,r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r)|0;return(e+n>>>0)%z.length}function Be(e){var t=ze(e.parent.id,e.name);if(z[t]===e)z[t]=e.cb;else for(t=z[t];t;){if(t.cb===e){t.cb=e.cb;break}t=t.cb}}function H(e,t){var n=U(e.mode)?(n=W(e,`x`))?n:e.La.lookup?0:2:54;if(n)throw new B(n);for(n=z[ze(e.id,t)];n;n=n.cb){var r=n.name;if(n.parent.id===e.id&&r===t)return n}return e.La.lookup(e,t)}function Ve(e,t,n,r){return e=new Le(e,t,n,r),t=ze(e.parent.id,e.name),e.cb=z[t],z[t]=e}function U(e){return(e&61440)==16384}function W(e,t){return Fe?0:t.includes(`r`)&&!(e.mode&292)||t.includes(`w`)&&!(e.mode&146)||t.includes(`x`)&&!(e.mode&73)?2:0}function He(e,t){if(!U(e.mode))return 54;try{return H(e,t),20}catch{}return W(e,`wx`)}function Ue(e,t,n){try{var r=H(e,t)}catch(e){return e.Pa}if(e=W(e,`wx`))return e;if(n){if(!U(r.mode))return 54;if(r===r.parent||Re(r)===`/`)return 10}else if(U(r.mode))return 31;return 0}function We(e){if(!e)throw new B(63);return e}function G(e){if(e=Me[e],!e)throw new B(8);return e}function Ge(e,t=-1){if(e=Object.assign(new Ie,e),t==-1)a:{for(t=0;4096>=t;t++)if(!Me[t])break a;throw new B(33)}return e.fd=t,Me[t]=e}function Ke(e,t=-1){return e=Ge(e,t),e.Ma?.ec?.(e),e}function qe(e,t,n){var r=e?.Ma.Ua;e=r?e:t,r??=t.La.Ua,We(r),r(e,n)}var Je={open(e){e.Ma=je[e.node.rdev].Ma,e.Ma.open?.(e)},Va(){throw new B(70)}};function Ye(e,t){je[e]={Ma:t}}function Xe(e,t){var n=t===`/`;if(n&&Ae)throw new B(10);if(!n&&t){var r=V(t,{pb:!1});if(t=r.path,r=r.node,r.bb)throw new B(10);if(!U(r.mode))throw new B(54)}t={type:e,kc:{},Db:t,Vb:[]},e=e.Xa(t),e.Xa=t,t.root=e,n?Ae=e:r&&(r.bb=t,r.Xa&&r.Xa.Vb.push(t))}function Ze(e,t,n){var r=V(e,{parent:!0}).node;if(e=ve(e),!e)throw new B(28);if(e===`.`||e===`..`)throw new B(20);var i=He(r,e);if(i)throw new B(i);if(!r.La.ib)throw new B(63);return r.La.ib(r,e,t,n)}function Qe(e,t=438){return Ze(e,t&4095|32768,0)}function K(e,t=511){return Ze(e,t&1023|16384,0)}function $e(e,t,n){n===void 0&&(n=t,t=438),Ze(e,t|8192,n)}function et(e,t){if(!xe(e))throw new B(44);var n=V(t,{parent:!0}).node;if(!n)throw new B(44);t=ve(t);var r=He(n,t);if(r)throw new B(r);if(!n.La.symlink)throw new B(63);n.La.symlink(n,t,e)}function tt(e){var t=V(e,{parent:!0}).node;e=ve(e);var n=H(t,e),r=Ue(t,e,!0);if(r)throw new B(r);if(!t.La.rmdir)throw new B(63);if(n.bb)throw new B(10);t.La.rmdir(t,e),Be(n)}function nt(e){var t=V(e,{parent:!0}).node;if(!t)throw new B(44);e=ve(e);var n=H(t,e),r=Ue(t,e,!1);if(r)throw new B(r);if(!t.La.unlink)throw new B(63);if(n.bb)throw new B(10);t.La.unlink(t,e),Be(n)}function rt(e,t){return e=V(e,{ab:!t}).node,We(e.La.Ta)(e)}function it(e,t,n,r){qe(e,t,{mode:n&4095|t.mode&-4096,ctime:Date.now(),Lb:r})}function at(e,t){e=typeof e==`string`?V(e,{ab:!0}).node:e,it(null,e,t)}function ot(e,t,n){if(U(t.mode))throw new B(31);if((t.mode&61440)!=32768)throw new B(28);var r=W(t,`w`);if(r)throw new B(r);qe(e,t,{size:n,timestamp:Date.now()})}function st(e,t,n=438){if(e===``)throw new B(44);if(typeof t==`string`){var r={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[t];if(r===void 0)throw Error(`Unknown file open mode: ${t}`);t=r}if(n=t&64?n&4095|32768:0,typeof e==`object`)r=e;else{var i=e.endsWith(`/`),a=V(e,{ab:!(t&131072),Wb:!0});r=a.node,e=a.path}if(a=!1,t&64)if(r){if(t&128)throw new B(20)}else{if(i)throw new B(31);r=Ze(e,n|511,0),a=!0}if(!r)throw new B(44);if((r.mode&61440)==8192&&(t&=-513),t&65536&&!U(r.mode))throw new B(54);if(!a&&(r?(r.mode&61440)==40960?i=32:(i=[`r`,`w`,`rw`][t&3],t&512&&(i+=`w`),i=U(r.mode)&&(i!==`r`||t&576)?31:W(r,i)):i=44,i))throw new B(i);return t&512&&!a&&(i=r,i=typeof i==`string`?V(i,{ab:!0}).node:i,ot(null,i,0)),t=Ge({node:r,path:Re(r),flags:t&-131713,seekable:!0,position:0,Ma:r.Ma,Yb:[],error:!1}),t.Ma.open&&t.Ma.open(t),a&&at(r,n&511),t}function ct(e){if(e.fd===null)throw new B(8);e.rb&&=null;try{e.Ma.close&&e.Ma.close(e)}catch(e){throw e}finally{Me[e.fd]=null}e.fd=null}function lt(e,t,n){if(e.fd===null)throw new B(8);if(!e.seekable||!e.Ma.Va)throw new B(70);if(n!=0&&n!=1&&n!=2)throw new B(28);e.position=e.Ma.Va(e,t,n),e.Yb=[]}function ut(e,t,n,r,i){if(0>r||0>i)throw new B(28);if(e.fd===null||(e.flags&2097155)==1)throw new B(8);if(U(e.node.mode))throw new B(31);if(!e.Ma.read)throw new B(28);var a=i!==void 0;if(!a)i=e.position;else if(!e.seekable)throw new B(70);return t=e.Ma.read(e,t,n,r,i),a||(e.position+=t),t}function dt(e,t,n,r,i){if(0>r||0>i)throw new B(28);if(e.fd===null||!(e.flags&2097155))throw new B(8);if(U(e.node.mode))throw new B(31);if(!e.Ma.write)throw new B(28);e.seekable&&e.flags&1024&<(e,0,2);var a=i!==void 0;if(!a)i=e.position;else if(!e.seekable)throw new B(70);return t=e.Ma.write(e,t,n,r,i,void 0),a||(e.position+=t),t}function ft(e){var t=t||0,n=`binary`;n!==`utf8`&&n!==`binary`&&k(`Invalid encoding type "${n}"`),t=st(e,t),e=rt(e).size;var r=new Uint8Array(e);return ut(t,r,0,e,0),n===`utf8`&&(r=Se(r)),ct(t),r}function q(e,t,n){e=ge(`/dev/`+e);var r=ke(!!t,!!n);q.Cb??=64;var i=q.Cb++<<8|0;Ye(i,{open(e){e.seekable=!1},close(){n?.buffer?.length&&n(10)},read(e,n,r,i){for(var a=0,o=0;o<i;o++){try{var s=t()}catch{throw new B(29)}if(s===void 0&&a===0)throw new B(6);if(s==null)break;a++,n[r+o]=s}return a&&(e.node.atime=Date.now()),a},write(e,t,r,i){for(var a=0;a<i;a++)try{n(t[r+a])}catch{throw new B(29)}return i&&(e.node.mtime=e.node.ctime=Date.now()),a}}),$e(e,r,i)}var J={};function Y(e,t,n){if(t.charAt(0)===`/`)return t;if(e=e===-100?`/`:G(e).path,t.length==0){if(!n)throw new B(44);return e}return e+`/`+t}function pt(e,t){D[e>>2]=t.dev,D[e+4>>2]=t.mode,D[e+8>>2]=t.nlink,D[e+12>>2]=t.uid,D[e+16>>2]=t.gid,D[e+20>>2]=t.rdev,O[e+24>>3]=BigInt(t.size),E[e+32>>2]=4096,E[e+36>>2]=t.blocks;var n=t.atime.getTime(),r=t.mtime.getTime(),i=t.ctime.getTime();return O[e+40>>3]=BigInt(Math.floor(n/1e3)),D[e+48>>2]=n%1e3*1e6,O[e+56>>3]=BigInt(Math.floor(r/1e3)),D[e+64>>2]=r%1e3*1e6,O[e+72>>3]=BigInt(Math.floor(i/1e3)),D[e+80>>2]=i%1e3*1e6,O[e+88>>3]=BigInt(t.ino),0}var mt=void 0,ht=()=>{var e=E[mt>>2];return mt+=4,e},gt=0,_t=[0,31,60,91,121,152,182,213,244,274,305,335],vt=[0,31,59,90,120,151,181,212,243,273,304,334],yt={},bt=e=>{x=e,fe||0<gt||(s.onExit?.(e),b=!0),f(e,new se(e))},xt=e=>{if(!b)try{e()}catch(e){e instanceof se||e==`unwind`||f(1,e)}finally{if(!(fe||0<gt))try{x=e=x,bt(e)}catch(e){e instanceof se||e==`unwind`||f(1,e)}}},St={},Ct=()=>{if(!wt){var e={USER:`web_user`,LOGNAME:`web_user`,PATH:`/`,PWD:`/`,HOME:`/home/web_user`,LANG:(globalThis.navigator?.language??`C`).replace(`-`,`_`)+`.UTF-8`,_:d||`./this.program`},t;for(t in St)St[t]===void 0?delete e[t]:e[t]=St[t];var n=[];for(t in e)n.push(`${t}=${e[t]}`);wt=n}return wt},wt,Tt=(e,t,n,r)=>{var i={string:e=>{var t=0;if(e!=null&&e!==0){t=I(e)+1;var n=Q(t);L(e,w,n,t),t=n}return t},array:e=>{var t=Q(e.length);return C.set(e,t),t}};e=s[`_`+e];var a=[],o=0;if(r)for(var c=0;c<r.length;c++){var l=i[n[c]];l?(o===0&&(o=Lt()),a[c]=l(r[c])):a[c]=r[c]}return n=e(...a),n=function(e){return o!==0&&It(o),t===`string`?F(e):t===`boolean`?!!e:e}(n)},Et=e=>{var t=I(e)+1,n=Mt(t);return n&&L(e,w,n,t),n},X,Dt=[],Z=e=>{X.delete($.get(e)),$.set(e,null),Dt.push(e)},Ot=e=>{let t=e.length;return[t%128|128,t>>7,...e]},kt={i:127,p:127,j:126,f:125,d:124,e:111},At=e=>Ot(Array.from(e,e=>kt[e])),jt=(e,t)=>{if(!X){X=new WeakMap;var n=$.length;if(X)for(var r=0;r<0+n;r++){var i=$.get(r);i&&X.set(i,r)}}if(n=X.get(e)||0)return n;n=Dt.length?Dt.pop():$.grow(1);try{$.set(n,e)}catch(r){if(!(r instanceof TypeError))throw r;t=Uint8Array.of(0,97,115,109,1,0,0,0,1,...Ot([1,96,...At(t.slice(1)),...At(t[0]===`v`?``:t[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),t=new WebAssembly.Module(t),t=new WebAssembly.Instance(t,{e:{f:e}}).exports.f,$.set(n,t)}return X.set(e,n),n};if(z=Array(4096),Xe(R,`/`),K(`/tmp`),K(`/home`),K(`/home/web_user`),(function(){K(`/dev`),Ye(259,{read:()=>0,write:(e,t,n,r)=>r,Va:()=>0}),$e(`/dev/null`,259),Te(1280,De),Te(1536,Oe),$e(`/dev/tty`,1280),$e(`/dev/tty1`,1536);var e=new Uint8Array(1024),t=0,n=()=>(t===0&&(be(e),t=e.byteLength),e[--t]);q(`random`,n),q(`urandom`,n),K(`/dev/shm`),K(`/dev/shm/tmp`)})(),(function(){K(`/proc`);var e=K(`/proc/self`);K(`/proc/self/fd`),Xe({Xa(){var t=Ve(e,`fd`,16895,73);return t.Ma={Va:R.Ma.Va},t.La={lookup(e,t){e=+t;var n=G(e);return e={parent:null,Xa:{Db:`fake`},La:{readlink:()=>n.path},id:e+1},e.parent=e},readdir(){return Array.from(Me.entries()).filter(([,e])=>e).map(([e])=>e.toString())}},t}},`/proc/self/fd`)})(),s.noExitRuntime&&(fe=s.noExitRuntime),s.print&&(ee=s.print),s.printErr&&(v=s.printErr),s.wasmBinary&&(y=s.wasmBinary),s.thisProgram&&(d=s.thisProgram),s.preInit)for(typeof s.preInit==`function`&&(s.preInit=[s.preInit]);0<s.preInit.length;)s.preInit.shift()();s.stackSave=()=>Lt(),s.stackRestore=e=>It(e),s.stackAlloc=e=>Q(e),s.cwrap=(e,t,n,r)=>{var i=!n||n.every(e=>e===`number`||e===`boolean`);return t!==`string`&&i&&!r?s[`_`+e]:(...r)=>Tt(e,t,n,r)},s.addFunction=jt,s.removeFunction=Z,s.UTF8ToString=F,s.stringToNewUTF8=Et,s.writeArrayToMemory=(e,t)=>{C.set(e,t)};var Mt,Nt,Pt,Ft,It,Q,Lt,Rt,$,zt={a:(e,t,n,r)=>k(`Assertion failed: ${F(e)}, at: `+[t?F(t):`unknown filename`,n,r?F(r):`unknown function`]),i:function(e,t){try{return e=F(e),at(e,t),0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},L:function(e,t,n){try{if(t=F(t),t=Y(e,t),n&-8)return-28;var r=V(t,{ab:!0}).node;return r?(e=``,n&4&&(e+=`r`),n&2&&(e+=`w`),n&1&&(e+=`x`),e&&W(r,e)?-2:0):-44}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},j:function(e,t){try{var n=G(e);return it(n,n.node,t,!1),0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},h:function(e){try{var t=G(e);return qe(t,t.node,{timestamp:Date.now(),Lb:!1}),0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},b:function(e,t,n){mt=n;try{var r=G(e);switch(t){case 0:var i=ht();if(0>i)break;for(;Me[i];)i++;return Ke(r,i).fd;case 1:case 2:return 0;case 3:return r.flags;case 4:return i=ht(),r.flags|=i,0;case 12:return i=ht(),T[i+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},g:function(e,t){try{var n=G(e),r=n.node,i=n.Ma.Ta;return e=i?n:r,i??=r.La.Ta,We(i),pt(t,i(e))}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},H:function(e,t){t=-9007199254740992>t||9007199254740992<t?NaN:Number(t);try{if(isNaN(t))return-61;var n=G(e);if(0>t||!(n.flags&2097155))throw new B(28);return ot(n,n.node,t),0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},G:function(e,t){try{if(t===0)return-28;var n=I(`/`)+1;return t<n?-68:(L(`/`,w,e,t),n)}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},K:function(e,t){try{return e=F(e),pt(t,rt(e,!0))}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},C:function(e,t,n){try{return t=F(t),t=Y(e,t),K(t,n),0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},J:function(e,t,n,r){try{t=F(t);var i=r&256;return t=Y(e,t,r&4096),pt(n,i?rt(t,!0):rt(t))}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},x:function(e,t,n,r){mt=r;try{t=F(t),t=Y(e,t);var i=r?ht():0;return st(t,n,i).fd}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},v:function(e,t,n,r){try{if(t=F(t),t=Y(e,t),0>=r)return-28;var i=V(t).node;if(!i)throw new B(44);if(!i.La.readlink)throw new B(28);var a=i.La.readlink(i),o=Math.min(r,I(a)),s=C[n+o];return L(a,w,n,r+1),C[n+o]=s,o}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},u:function(e){try{return e=F(e),tt(e),0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},f:function(e,t){try{return e=F(e),pt(t,rt(e))}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},r:function(e,t,n){try{if(t=F(t),t=Y(e,t),n)if(n===512)tt(t);else return-28;else nt(t);return 0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},q:function(e,t,n){try{t=F(t),t=Y(e,t,!0);var r=Date.now(),i,a;if(n){var o=D[n>>2]+4294967296*E[n+4>>2],s=E[n+8>>2];i=s==1073741823?r:s==1073741822?null:1e3*o+s/1e6,n+=16,o=D[n>>2]+4294967296*E[n+4>>2],s=E[n+8>>2],a=s==1073741823?r:s==1073741822?null:1e3*o+s/1e6}else a=i=r;if((a??i)!==null){e=i;var c=V(t,{ab:!0}).node;We(c.La.Ua)(c,{atime:e,mtime:a})}return 0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},m:()=>k(``),l:()=>{fe=!1,gt=0},A:function(e,t){e=-9007199254740992>e||9007199254740992<e?NaN:Number(e),e=new Date(1e3*e),E[t>>2]=e.getSeconds(),E[t+4>>2]=e.getMinutes(),E[t+8>>2]=e.getHours(),E[t+12>>2]=e.getDate(),E[t+16>>2]=e.getMonth(),E[t+20>>2]=e.getFullYear()-1900,E[t+24>>2]=e.getDay();var n=e.getFullYear();E[t+28>>2]=(n%4!=0||n%100==0&&n%400!=0?vt:_t)[e.getMonth()]+e.getDate()-1|0,E[t+36>>2]=-(60*e.getTimezoneOffset()),n=new Date(e.getFullYear(),6,1).getTimezoneOffset();var r=new Date(e.getFullYear(),0,1).getTimezoneOffset();E[t+32>>2]=(n!=r&&e.getTimezoneOffset()==Math.min(r,n))|0},y:function(e,t,n,r,i,a,o){i=-9007199254740992>i||9007199254740992<i?NaN:Number(i);try{var s=G(r);if(t&2&&!(n&2)&&(s.flags&2097155)!=2||(s.flags&2097155)==1)throw new B(2);if(!s.Ma.jb)throw new B(43);if(!e)throw new B(28);var c=s.Ma.jb(s,e,i,t,n),l=c.Xb;return E[a>>2]=c.Eb,D[o>>2]=l,0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},z:function(e,t,n,r,i,a){a=-9007199254740992>a||9007199254740992<a?NaN:Number(a);try{var o=G(i);if(n&2){if(n=a,(o.node.mode&61440)!=32768)throw new B(43);if(!(r&2)){var s=w.slice(e,e+t);o.Ma.kb&&o.Ma.kb(o,s,n,t,r)}}}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return-e.Pa}},n:(e,t)=>(yt[e]&&(clearTimeout(yt[e].id),delete yt[e]),t&&(yt[e]={id:setTimeout(()=>{delete yt[e],xt(()=>Ft(e,performance.now()))},t),lc:t}),0),B:(e,t,n,r)=>{var i=new Date().getFullYear(),a=new Date(i,0,1).getTimezoneOffset();i=new Date(i,6,1).getTimezoneOffset(),D[e>>2]=60*Math.max(a,i),E[t>>2]=Number(a!=i),t=e=>{var t=Math.abs(e);return`UTC${0<=e?`-`:`+`}${String(Math.floor(t/60)).padStart(2,`0`)}${String(t%60).padStart(2,`0`)}`},e=t(a),t=t(i),i<a?(L(e,w,n,17),L(t,w,r,17)):(L(e,w,r,17),L(t,w,n,17))},d:()=>Date.now(),s:()=>2147483648,c:()=>performance.now(),o:e=>{var t=w.length;if(e>>>=0,2147483648<e)return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);a:{r=(Math.min(2147483648,65536*Math.ceil(Math.max(e,r)/65536))-Rt.buffer.byteLength+65535)/65536|0;try{Rt.grow(r),re();var i=1;break a}catch{}i=void 0}if(i)return!0}return!1},E:(e,t)=>{var n=0,r=0,i;for(i of Ct()){var a=t+n;D[e+r>>2]=a,n+=L(i,w,a,1/0)+1,r+=4}return 0},F:(e,t)=>{var n=Ct();D[e>>2]=n.length,e=0;for(var r of n)e+=I(r)+1;return D[t>>2]=e,0},e:function(e){try{return ct(G(e)),0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return e.Pa}},p:function(e,t){try{var n=G(e);return C[t]=n.tty?2:U(n.mode)?3:(n.mode&61440)==40960?7:4,T[t+2>>1]=0,O[t+8>>3]=BigInt(0),O[t+16>>3]=BigInt(0),0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return e.Pa}},w:function(e,t,n,r){try{a:{var i=G(e);e=t;for(var a,o=t=0;o<n;o++){var s=D[e>>2],c=D[e+4>>2];e+=8;var l=ut(i,C,s,c,a);if(0>l){var u=-1;break a}if(t+=l,l<c)break;a!==void 0&&(a+=l)}u=t}return D[r>>2]=u,0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return e.Pa}},D:function(e,t,n,r){t=-9007199254740992>t||9007199254740992<t?NaN:Number(t);try{if(isNaN(t))return 61;var i=G(e);return lt(i,t,n),O[r>>3]=BigInt(i.position),i.rb&&t===0&&n===0&&(i.rb=null),0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return e.Pa}},I:function(e){try{var t=G(e);return t.Ma?.fsync?.(t)}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return e.Pa}},t:function(e,t,n,r){try{a:{var i=G(e);e=t;for(var a,o=t=0;o<n;o++){var s=D[e>>2],c=D[e+4>>2];e+=8;var l=dt(i,C,s,c,a);if(0>l){var u=-1;break a}if(t+=l,l<c)break;a!==void 0&&(a+=l)}u=t}return D[r>>2]=u,0}catch(e){if(J===void 0||e.name!==`ErrnoError`)throw e;return e.Pa}},k:bt};function Bt(){function e(){if(s.calledRun=!0,!b){if(!s.noFSInit&&!Pe){var e,t;Pe=!0,e??=s.stdin,t??=s.stdout,n??=s.stderr,e?q(`stdin`,e):et(`/dev/tty`,`/dev/stdin`),t?q(`stdout`,null,t):et(`/dev/tty`,`/dev/stdout`),n?q(`stderr`,null,n):et(`/dev/tty1`,`/dev/stderr`),st(`/dev/stdin`,0),st(`/dev/stdout`,1),st(`/dev/stderr`,1)}if(Vt.N(),Fe=!1,s.onRuntimeInitialized?.(),s.postRun)for(typeof s.postRun==`function`&&(s.postRun=[s.postRun]);s.postRun.length;){var n=s.postRun.shift();le.push(n)}ce(le)}}if(0<j)M=Bt;else{if(s.preRun)for(typeof s.preRun==`function`&&(s.preRun=[s.preRun]);s.preRun.length;)de();ce(ue),0<j?M=Bt:s.setStatus?(s.setStatus(`Running...`),setTimeout(()=>{setTimeout(()=>s.setStatus(``),1),e()},1)):e()}}var Vt;return(async function(){function e(e){return e=Vt=e.exports,s._sqlite3_free=e.P,s._sqlite3_value_text=e.Q,s._sqlite3_prepare_v2=e.R,s._sqlite3_step=e.S,s._sqlite3_reset=e.T,s._sqlite3_exec=e.U,s._sqlite3_finalize=e.V,s._sqlite3_column_name=e.W,s._sqlite3_column_text=e.X,s._sqlite3_column_type=e.Y,s._sqlite3_errmsg=e.Z,s._sqlite3_clear_bindings=e._,s._sqlite3_value_blob=e.$,s._sqlite3_value_bytes=e.aa,s._sqlite3_value_double=e.ba,s._sqlite3_value_int=e.ca,s._sqlite3_value_type=e.da,s._sqlite3_result_blob=e.ea,s._sqlite3_result_double=e.fa,s._sqlite3_result_error=e.ga,s._sqlite3_result_int=e.ha,s._sqlite3_result_int64=e.ia,s._sqlite3_result_null=e.ja,s._sqlite3_result_text=e.ka,s._sqlite3_aggregate_context=e.la,s._sqlite3_column_count=e.ma,s._sqlite3_data_count=e.na,s._sqlite3_column_blob=e.oa,s._sqlite3_column_bytes=e.pa,s._sqlite3_column_double=e.qa,s._sqlite3_bind_blob=e.ra,s._sqlite3_bind_double=e.sa,s._sqlite3_bind_int=e.ta,s._sqlite3_bind_text=e.ua,s._sqlite3_bind_parameter_index=e.va,s._sqlite3_sql=e.wa,s._sqlite3_normalized_sql=e.xa,s._sqlite3_changes=e.ya,s._sqlite3_close_v2=e.za,s._sqlite3_create_function_v2=e.Aa,s._sqlite3_update_hook=e.Ba,s._sqlite3_open=e.Ca,Mt=s._malloc=e.Da,Nt=s._free=e.Ea,s._RegisterExtensionFunctions=e.Fa,Pt=e.Ga,Ft=e.Ha,It=e.Ia,Q=e.Ja,Lt=e.Ka,Rt=e.M,$=e.O,re(),j--,s.monitorRunDependencies?.(j),j==0&&M&&(e=M,M=null,e()),Vt}j++,s.monitorRunDependencies?.(j);var t={a:zt};return s.instantiateWasm?new Promise(n=>{s.instantiateWasm(t,(t,r)=>{n(e(t,r))})}):(A??=s.locateFile?s.locateFile(`sql-wasm.wasm`,m):m+`sql-wasm.wasm`,e((await oe(t)).instance))})(),Bt(),a}),r)};typeof t==`object`&&typeof n==`object`?(n.exports=i,n.exports.default=i):typeof define==`function`&&define.amd?define([],function(){return i}):typeof t==`object`&&(t.Module=i)}))(),1);function ee(e,t,n){switch(n.mode){case`list`:return y(e,t,n);case`csv`:return b(e,t,n);case`json`:return w(e,t);case`line`:return T(e,t,n);case`column`:return E(e,t,n);case`table`:return D(e,t,n);case`markdown`:return te(e,t,n);case`tabs`:return ne(e,t,n);case`box`:return O(e,t,n);case`quote`:return re(e,t,n);case`html`:return k(e,t,n);case`ascii`:return ie(e,t,n)}}function v(e,t){return e==null?t:e instanceof Uint8Array||Buffer.isBuffer(e)?Buffer.from(e).toString(`utf8`):typeof e==`number`&&!Number.isInteger(e)?e.toPrecision(17).replace(/\.?0+$/,``):String(e)}function y(e,t,n){let r=[];n.header&&e.length>0&&r.push(e.join(n.separator));for(let e of t)r.push(e.map(e=>v(e,n.nullValue)).join(n.separator));return r.length>0?`${r.join(n.newline)}${n.newline}`:``}function b(e,t,n){let r=[];n.header&&e.length>0&&r.push(e.map(x).join(`,`));for(let e of t)r.push(e.map(e=>x(v(e,n.nullValue))).join(`,`));return r.length>0?`${r.join(`
|
|
3
|
-
`)}
|
|
4
|
-
`:``}function x(e){return e.includes(`,`)||e.includes(`"`)||e.includes(`'`)||e.includes(`
|
|
5
|
-
`)?`"${e.replace(/"/g,`""`)}"`:e}function S(e){return e.toPrecision(17).replace(/\.?0+$/,``)}function C(e){return e===null?`null`:typeof e==`number`?Number.isInteger(e)?String(e):S(e):JSON.stringify(e)}function w(e,t){return t.length===0?``:`[${t.map(t=>`{${e.map((e,n)=>`${JSON.stringify(e)}:${C(t[n])}`).join(`,`)}}`).join(`,
|
|
6
|
-
`)}]
|
|
7
|
-
`}function T(e,t,n){if(e.length===0||t.length===0)return``;let r=Math.max(5,...e.map(e=>e.length)),i=[];for(let a of t)for(let t=0;t<e.length;t++){let o=e[t].padStart(r);i.push(`${o} = ${v(a[t],n.nullValue)}`)}return`${i.join(`
|
|
8
|
-
`)}
|
|
9
|
-
`}function E(e,t,n){if(e.length===0)return``;let r=e.map(e=>e.length);for(let e of t)for(let t=0;t<e.length;t++){let i=v(e[t],n.nullValue).length;i>r[t]&&(r[t]=i)}let i=[];n.header&&(i.push(e.map((e,t)=>e.padEnd(r[t])).join(` `)),i.push(r.map(e=>`-`.repeat(e)).join(` `)));for(let e of t)i.push(e.map((e,t)=>v(e,n.nullValue).padEnd(r[t])).join(` `));return i.length>0?`${i.join(`
|
|
10
|
-
`)}
|
|
11
|
-
`:``}function D(e,t,n){if(e.length===0)return``;let r=e.map(e=>e.length);for(let e of t)for(let t=0;t<e.length;t++){let i=v(e[t],n.nullValue).length;i>r[t]&&(r[t]=i)}let i=[],a=`+${r.map(e=>`-`.repeat(e+2)).join(`+`)}+`;i.push(a),n.header&&(i.push(`| ${e.map((e,t)=>e.padEnd(r[t])).join(` | `)} |`),i.push(a));for(let e of t)i.push(`| ${e.map((e,t)=>v(e,n.nullValue).padEnd(r[t])).join(` | `)} |`);return i.push(a),`${i.join(`
|
|
12
|
-
`)}
|
|
13
|
-
`}function te(e,t,n){if(e.length===0)return``;let r=[];n.header&&(r.push(`| ${e.join(` | `)} |`),r.push(`|${e.map(()=>`---`).join(`|`)}|`));for(let e of t)r.push(`| ${e.map(e=>v(e,n.nullValue)).join(` | `)} |`);return r.length>0?`${r.join(`
|
|
14
|
-
`)}
|
|
15
|
-
`:``}function ne(e,t,n){let r=[];n.header&&e.length>0&&r.push(e.join(` `));for(let e of t)r.push(e.map(e=>v(e,n.nullValue)).join(` `));return r.length>0?`${r.join(n.newline)}${n.newline}`:``}function O(e,t,n){if(e.length===0)return``;let r=e.map(e=>e.length);for(let e of t)for(let t=0;t<e.length;t++){let i=v(e[t],n.nullValue).length;i>r[t]&&(r[t]=i)}let i=[];i.push(`\u250C${r.map(e=>`─`.repeat(e+2)).join(`┬`)}\u2510`),i.push(`\u2502 ${e.map((e,t)=>e.padEnd(r[t])).join(` │ `)} \u2502`),i.push(`\u251C${r.map(e=>`─`.repeat(e+2)).join(`┼`)}\u2524`);for(let e of t)i.push(`\u2502 ${e.map((e,t)=>v(e,n.nullValue).padEnd(r[t])).join(` │ `)} \u2502`);return i.push(`\u2514${r.map(e=>`─`.repeat(e+2)).join(`┴`)}\u2518`),`${i.join(`
|
|
16
|
-
`)}
|
|
17
|
-
`}function re(e,t,n){let r=[];n.header&&e.length>0&&r.push(e.map(e=>`'${e}'`).join(`,`));for(let e of t)r.push(e.map(e=>e==null?`NULL`:typeof e==`number`?Number.isInteger(e)?String(e):S(e):`'${String(e)}'`).join(`,`));return r.length>0?`${r.join(n.newline)}${n.newline}`:``}function k(e,t,n){let r=[];n.header&&e.length>0&&(r.push(`<TR>${e.map(e=>`<TH>${A(e)}</TH>`).join(``)}`),r.push(`</TR>`));for(let e of t)r.push(`<TR>${e.map(e=>`<TD>${A(v(e,n.nullValue))}</TD>`).join(``)}`),r.push(`</TR>`);return r.length>0?`${r.join(`
|
|
18
|
-
`)}
|
|
19
|
-
`:``}function A(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function ie(e,t,n){let r=[];n.header&&e.length>0&&r.push(e.join(``));for(let e of t)r.push(e.map(e=>v(e,n.nullValue)).join(``));return r.length>0?r.join(``)+``:``}var ae=5e3,oe={name:`sqlite3`,summary:`SQLite database CLI`,usage:`sqlite3 [OPTIONS] DATABASE [SQL]`,options:[`-list output in list mode (default)`,`-csv output in CSV mode`,`-json output in JSON mode`,`-line output in line mode`,`-column output in column mode`,`-table output as ASCII table`,`-markdown output as markdown table`,`-tabs output in tab-separated mode`,`-box output in Unicode box mode`,`-quote output in SQL quote mode`,`-html output as HTML table`,`-ascii output in ASCII mode (control chars)`,`-header show column headers`,`-noheader hide column headers`,`-separator SEP field separator for list mode (default: |)`,`-newline SEP row separator (default: \\n)`,`-nullvalue TEXT text for NULL values (default: empty)`,`-readonly open database read-only (no writeback)`,`-bail stop on first error`,`-echo print SQL before execution`,`-cmd COMMAND run SQL command before main SQL`,`-version show SQLite version`,`-- end of options`,`--help show this help`],examples:[`sqlite3 :memory: "CREATE TABLE t(x); INSERT INTO t VALUES(1); SELECT * FROM t"`,`sqlite3 -json data.db "SELECT * FROM users"`,`sqlite3 -csv -header data.db "SELECT id, name FROM products"`,`sqlite3 -box data.db "SELECT * FROM users"`]};function se(e){let t={mode:`list`,header:!1,separator:`|`,newline:`
|
|
20
|
-
`,nullValue:``,readonly:!1,bail:!1,echo:!1,cmd:null},n=null,r=null,i=!1,a=!1;for(let o=0;o<e.length;o++){let s=e[o];if(a){n===null?n=s:r===null&&(r=s);continue}if(s===`--`)a=!0;else if(s===`-version`)i=!0;else if(s===`-list`)t.mode=`list`;else if(s===`-csv`)t.mode=`csv`;else if(s===`-json`)t.mode=`json`;else if(s===`-line`)t.mode=`line`;else if(s===`-column`)t.mode=`column`;else if(s===`-table`)t.mode=`table`;else if(s===`-markdown`)t.mode=`markdown`;else if(s===`-tabs`)t.mode=`tabs`;else if(s===`-box`)t.mode=`box`;else if(s===`-quote`)t.mode=`quote`;else if(s===`-html`)t.mode=`html`;else if(s===`-ascii`)t.mode=`ascii`;else if(s===`-header`)t.header=!0;else if(s===`-noheader`)t.header=!1;else if(s===`-readonly`)t.readonly=!0;else if(s===`-bail`)t.bail=!0;else if(s===`-echo`)t.echo=!0;else if(s===`-separator`){if(o+1>=e.length)return{stdout:``,stderr:`sqlite3: Error: missing argument to -separator
|
|
21
|
-
`,exitCode:1};t.separator=e[++o]}else if(s===`-newline`){if(o+1>=e.length)return{stdout:``,stderr:`sqlite3: Error: missing argument to -newline
|
|
22
|
-
`,exitCode:1};t.newline=e[++o]}else if(s===`-nullvalue`){if(o+1>=e.length)return{stdout:``,stderr:`sqlite3: Error: missing argument to -nullvalue
|
|
23
|
-
`,exitCode:1};t.nullValue=e[++o]}else if(s===`-cmd`){if(o+1>=e.length)return{stdout:``,stderr:`sqlite3: Error: missing argument to -cmd
|
|
24
|
-
`,exitCode:1};t.cmd=e[++o]}else{if(s.startsWith(`-`))return{stdout:``,stderr:`sqlite3: Error: unknown option: ${s.startsWith(`--`)?s.slice(1):s}
|
|
25
|
-
Use -help for a list of options.
|
|
26
|
-
`,exitCode:1};n===null?n=s:r===null&&(r=s)}}return{options:t,database:n,sql:r,showVersion:i}}async function ce(){let e=new(await(r.runTrustedAsync(()=>(0,_.default)()))).Database;try{let t=e.exec(`SELECT sqlite_version()`);return t.length>0&&t[0].values.length>0?String(t[0].values[0][0]):`unknown`}finally{e.close()}}function le(){let e=d(p(import.meta.url)),t=f(e,`../../commands/sqlite3/worker.js`);if(m(t))return t;let n=f(e,`worker.js`);if(m(n))return n;let r=f(e,`../../../dist/commands/sqlite3/worker.js`);if(m(r))return r;throw Error(`sqlite3 worker not found. Run 'pnpm build' to compile the worker.`)}var ue={createWorker(e,t){return new g(e,{workerData:t})}};function de(){return h(16).toString(`hex`)}function j(e,t){if(!e||typeof e!=`object`)return{success:!1,error:`Malformed worker response`};let n=e;return typeof n.protocolToken!=`string`||n.protocolToken!==t?{success:!1,error:`Malformed worker response: invalid protocol token`}:n.type===`security-violation`?{success:!1,error:`Security violation: ${typeof n.violation?.type==`string`?n.violation.type:`unknown`}`}:typeof n.success==`boolean`?n.success?Array.isArray(n.results)?typeof n.hasModifications==`boolean`?n.dbBuffer!==null&&n.dbBuffer!==void 0&&!(n.dbBuffer instanceof Uint8Array)?{success:!1,error:`Malformed worker response: invalid dbBuffer`}:{success:!0,results:n.results,hasModifications:n.hasModifications,dbBuffer:n.dbBuffer===void 0?null:n.dbBuffer,defenseStats:n.defenseStats}:{success:!1,error:`Malformed worker response: missing hasModifications flag`}:{success:!1,error:`Malformed worker response: missing results array`}:{success:!1,error:typeof n.error==`string`&&n.error.length>0?n.error:`Worker execution failed`}:{success:!1,error:`Malformed worker response: missing success flag`}}async function M(e,t,n){try{let s=le();return await new Promise((l,u)=>{let d=r.runTrusted(()=>ue.createWorker(s,e)),f=o(n,`sqlite3`,`worker timeout callback`,()=>{d.terminate(),l({success:!1,error:`Query timeout: execution exceeded ${t}ms limit`})}),p=a(()=>{try{f()}catch(e){l({success:!1,error:c(e instanceof Error?e.message:String(e))})}},t),m=o(n,`sqlite3`,`worker message callback`,t=>{i(p),l(j(t,e.protocolToken))}),h=o(n,`sqlite3`,`worker error callback`,e=>{i(p),u(e)}),g=o(n,`sqlite3`,`worker exit callback`,e=>{i(p),e!==0&&l({success:!1,error:`Worker exited with code ${e}`})});d.on(`message`,e=>{try{m(e)}catch(e){i(p),l({success:!1,error:c(e instanceof Error?e.message:String(e))})}}),d.on(`error`,e=>{try{h(e)}catch(e){i(p);let t=e instanceof Error?e.message:String(e);u(Error(c(t)))}}),d.on(`exit`,e=>{try{g(e)}catch(e){i(p),l({success:!1,error:c(e instanceof Error?e.message:String(e))})}})})}catch(e){let t=c(e.message);throw Error(`sqlite3 worker failed to load: ${t}`)}}var N={name:`sqlite3`,async execute(e,t){if(u(e)||e.includes(`-help`))return l(oe);let n=se(e);if(`exitCode`in n)return n;let{options:r,database:i,sql:a,showVersion:o}=n;if(o)return{stdout:`${await ce()}
|
|
27
|
-
`,stderr:``,exitCode:0};if(!i)return{stdout:``,stderr:`sqlite3: missing database argument
|
|
28
|
-
`,exitCode:1};let d=a||t.stdin.trim();if(r.cmd&&(d=r.cmd+(d?`; ${d}`:``)),!d)return{stdout:``,stderr:`sqlite3: no SQL provided
|
|
29
|
-
`,exitCode:1};let f=i===`:memory:`,p=``,m=null;try{f||(p=t.fs.resolvePath(t.cwd,i),await t.fs.exists(p)&&(m=await t.fs.readFileBuffer(p)))}catch(e){return{stdout:``,stderr:`sqlite3: unable to open database "${i}": ${s(e.message)}
|
|
30
|
-
`,exitCode:1}}let h=t.limits?.maxSqliteTimeoutMs??ae,g={protocolToken:de(),dbBuffer:m,sql:d,options:{bail:r.bail,echo:r.echo}},_;try{_=await M(g,h,t.requireDefenseContext)}catch(e){return{stdout:``,stderr:`sqlite3: worker error: ${c(e.message)}
|
|
31
|
-
`,exitCode:1}}if(!_.success)return{stdout:``,stderr:`sqlite3: ${c(_.error)}
|
|
32
|
-
`,exitCode:1};let v={mode:r.mode,header:r.header,separator:r.separator,newline:r.newline,nullValue:r.nullValue},y=``;r.echo&&(y+=`${d}
|
|
33
|
-
`);let b=!1;for(let e of _.results)if(e.type===`error`){if(r.bail)return{stdout:y,stderr:`Error: ${e.error}
|
|
34
|
-
`,exitCode:1};y+=`Error: ${e.error}
|
|
35
|
-
`,b=!0}else e.columns&&e.rows&&(e.rows.length>0||r.header)&&(y+=ee(e.columns,e.rows,v));if(_.hasModifications&&!r.readonly&&!f&&p&&_.dbBuffer)try{await t.fs.writeFile(p,_.dbBuffer)}catch(e){let t=s(e.message);return{stdout:y,stderr:`sqlite3: failed to write database: ${t}
|
|
36
|
-
`,exitCode:1}}return{stdout:y,stderr:``,exitCode:b&&r.bail?1:0}}},fe={name:`sqlite3`,flags:[],needsArgs:!0};export{ue as n,fe as r,N as t};
|
|
37
|
-
//# sourceMappingURL=chunk-HWBSOZZR-DaPTwPxK.mjs.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./chunk-YNYSPYQ5-DHter9G3.mjs";import{i as n}from"./chunk-GFQRA5P5-DigWkxW2.mjs";import{n as r}from"./chunk-5QMZ5MUS-_0tQyQsf.mjs";import{r as i}from"./chunk-OJDRYQWQ-LGuZyK6R.mjs";import{r as a,t as o}from"./chunk-24IMIIXA-BoP5OA93.mjs";import{n as s,r as c,t as l}from"./chunk-74CEPOFO-V0JXh91S.mjs";var u=1e4,d=100,f=new e(/\s+/);function p(e={}){let{fieldSep:t=f,maxIterations:n=u,maxRecursionDepth:r=d,maxOutputSize:i=0,fs:a,cwd:o,exec:s,coverage:c,requireDefenseContext:l}=e;return{FS:` `,OFS:` `,ORS:`
|
|
2
|
-
`,OFMT:`%.6g`,NR:0,NF:0,FNR:0,FILENAME:``,RSTART:0,RLENGTH:-1,SUBSEP:``,fields:[],line:``,vars:Object.create(null),arrays:Object.create(null),arrayAliases:new Map,ARGC:0,ARGV:Object.create(null),ENVIRON:Object.create(null),functions:new Map,fieldSep:t,maxIterations:n,maxRecursionDepth:r,maxOutputSize:i,currentRecursionDepth:0,exitCode:0,shouldExit:!1,shouldNext:!1,shouldNextFile:!1,loopBreak:!1,loopContinue:!1,hasReturn:!1,inEndBlock:!1,output:``,openedFiles:new Set,fs:a,cwd:o,exec:s,coverage:c,requireDefenseContext:l}}function m(e,t,n){switch(n){case`+`:return e+t;case`-`:return e-t;case`*`:return e*t;case`/`:return t===0?0:e/t;case`%`:return t===0?0:e%t;case`^`:case`**`:return e**t;default:return 0}}function h(e){if(typeof e==`number`)return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function g(e){return typeof e==`string`?e:String(e)}async function _(e,t){if(e.type===`regex`)return e.pattern;let n=g(await t.evalExpr(e));return n.startsWith(`/`)&&n.endsWith(`/`)&&(n=n.slice(1,-1)),n}async function v(e,t){return e?e.type===`variable`?e.name:e.type===`field`?`$${Math.floor(h(await t.evalExpr(e.index)))}`:`$0`:`$0`}function y(e,t){if(e===`$0`)return t.line;if(e.startsWith(`$`)){let n=parseInt(e.slice(1),10)-1;return t.fields[n]||``}return g(t.vars[e]??``)}function b(e,t,n){if(e===`$0`)n.line=t,n.fields=n.FS===` `?t.trim().split(/\s+/).filter(Boolean):n.fieldSep.split(t),n.NF=n.fields.length;else if(e.startsWith(`$`)){let r=parseInt(e.slice(1),10)-1;for(;n.fields.length<=r;)n.fields.push(``);n.fields[r]=t,n.NF=n.fields.length,n.line=n.fields.join(n.OFS)}else n.vars[e]=t}async function ee(e,t,n){return e.length===0?t.line.length:g(await n.evalExpr(e[0])).length}async function x(e,t,n){if(e.length<2)return``;let r=g(await n.evalExpr(e[0])),i=Math.floor(h(await n.evalExpr(e[1])))-1;if(e.length>=3){let t=Math.floor(h(await n.evalExpr(e[2])));return r.substr(Math.max(0,i),t)}return r.substr(Math.max(0,i))}async function S(e,t,n){if(e.length<2)return 0;let r=g(await n.evalExpr(e[0])),i=g(await n.evalExpr(e[1])),a=r.indexOf(i);return a===-1?0:a+1}async function C(e,n,r){if(e.length<2)return 0;let i=g(await r.evalExpr(e[0])),a=e[1];if(a.type!==`variable`)return 0;let o=a.name,s=n.FS;if(e.length>=3){let n=e[2];if(n.type===`regex`)s=t(n.pattern);else{let e=g(await r.evalExpr(n));s=e===` `?t(`\\s+`):e}}else n.FS===` `&&(s=t(`\\s+`));let c=typeof s==`string`?i.split(s):s.split(i);n.arrays[o]=Object.create(null);for(let e=0;e<c.length;e++)n.arrays[o][String(e+1)]=c[e];return c.length}async function te(e,n,r){if(e.length<2)return 0;let i=await _(e[0],r),a=g(await r.evalExpr(e[1])),o=await v(e[2],r),s=y(o,n);try{let e=t(i).replace(s,re(a)),r=e===s?0:1;return b(o,e,n),r}catch{return 0}}async function ne(e,n,r){if(e.length<2)return 0;let i=await _(e[0],r),a=g(await r.evalExpr(e[1])),o=await v(e[2],r),s=y(o,n);try{let e=t(i,`g`),r=e.match(s),c=r?r.length:0;return b(o,e.replace(s,re(a)),n),c}catch{return 0}}function re(e){return t=>{let n=``,r=0;for(;r<e.length;)if(e[r]===`\\`&&r+1<e.length){let t=e[r+1];t===`&`?(n+=`&`,r+=2):t===`\\`?(n+=`\\`,r+=2):(n+=e[r+1],r+=2)}else e[r]===`&`?(n+=t,r++):(n+=e[r],r++);return n}}async function ie(e,n,r){if(e.length<2)return n.RSTART=0,n.RLENGTH=-1,0;let i=g(await r.evalExpr(e[0])),a=await _(e[1],r);try{let e=t(a).exec(i);if(e)return n.RSTART=e.index+1,n.RLENGTH=e[0].length,n.RSTART}catch{}return n.RSTART=0,n.RLENGTH=-1,0}async function ae(e,n,r){if(e.length<3)return``;let i=await _(e[0],r),a=g(await r.evalExpr(e[1])),o=g(await r.evalExpr(e[2])),s=e.length>=4?g(await r.evalExpr(e[3])):n.line;try{let e=o.toLowerCase()===`g`,n=e?0:parseInt(o,10)||1;if(e)return t(i,`g`).replace(s,(e,...t)=>oe(a,e,t.slice(0,-2)));{let e=0;return t(i,`g`).replace(s,(t,...r)=>(e++,e===n?oe(a,t,r.slice(0,-2)):t))}}catch{return s}}function oe(e,t,n){let r=``,i=0;for(;i<e.length;)if(e[i]===`\\`&&i+1<e.length){let a=e[i+1];if(a===`&`)r+=`&`,i+=2;else if(a===`0`)r+=t,i+=2;else if(a>=`1`&&a<=`9`){let e=parseInt(a,10)-1;r+=n[e]||``,i+=2}else a===`n`?(r+=`
|
|
3
|
-
`,i+=2):a===`t`?(r+=` `,i+=2):(r+=a,i+=2)}else e[i]===`&`?(r+=t,i++):(r+=e[i],i++);return r}async function se(e,t,n){return e.length===0?``:g(await n.evalExpr(e[0])).toLowerCase()}async function ce(e,t,n){return e.length===0?``:g(await n.evalExpr(e[0])).toUpperCase()}async function le(e,t,n){if(e.length===0)return``;let r=g(await n.evalExpr(e[0])),i=[];for(let t=1;t<e.length;t++)i.push(await n.evalExpr(e[t]));return E(r,i)}async function ue(e,t,n){return e.length===0?0:Math.floor(h(await n.evalExpr(e[0])))}async function de(e,t,n){return e.length===0?0:Math.sqrt(h(await n.evalExpr(e[0])))}async function fe(e,t,n){return e.length===0?0:Math.sin(h(await n.evalExpr(e[0])))}async function pe(e,t,n){return e.length===0?0:Math.cos(h(await n.evalExpr(e[0])))}async function me(e,t,n){let r=e.length>0?h(await n.evalExpr(e[0])):0,i=e.length>1?h(await n.evalExpr(e[1])):0;return Math.atan2(r,i)}async function he(e,t,n){return e.length===0?0:Math.log(h(await n.evalExpr(e[0])))}async function ge(e,t,n){return e.length===0?1:Math.exp(h(await n.evalExpr(e[0])))}function _e(e,t,n){return t.random?t.random():Math.random()}async function ve(e,t,n){let r=e.length>0?h(await n.evalExpr(e[0])):Date.now();return t.vars._srand_seed=r,r}function ye(e,t){return()=>{throw Error(`${e}() is not supported - ${t}`)}}function w(e){return()=>{throw Error(`function '${e}()' is not implemented`)}}var T=1e4;function E(e,t){let n=0,r=``,i=0;for(;i<e.length;)if(e[i]===`%`&&i+1<e.length){let a=i+1,o=``,s=``,c=``,l,u=a;for(;a<e.length&&/\d/.test(e[a]);)a++;a>u&&e[a]===`$`?(l=parseInt(e.substring(u,a),10)-1,a++):a=u;let d=()=>{if(a<e.length){if(a+1<e.length&&(e[a]===`h`&&e[a+1]===`h`||e[a]===`l`&&e[a+1]===`l`)){a+=2;return}/[lzjh]/.test(e[a])&&a++}};for(;a<e.length&&/[-+ #0]/.test(e[a]);)o+=e[a++];if(e[a]===`*`){let e=t[n++],r=e===void 0?0:Math.floor(Number(e));r<0?(o+=`-`,s=String(Math.min(-r,T))):s=String(Math.min(r,T)),a++}else for(;a<e.length&&/\d/.test(e[a]);)s+=e[a++];if(s&&parseInt(s,10)>T&&(s=String(T)),e[a]===`.`){if(a++,e[a]===`*`){let e=t[n++];c=String(Math.min(e===void 0?0:Math.floor(Number(e)),T)),a++}else for(;a<e.length&&/\d/.test(e[a]);)c+=e[a++];c&&parseInt(c,10)>T&&(c=String(T))}d();let f=e[a],p=t[l===void 0?n:l];switch(f){case`s`:{let e=p===void 0?``:String(p);if(c&&(e=e.substring(0,parseInt(c,10))),s){let t=parseInt(s,10);e=o.includes(`-`)?e.padEnd(t):e.padStart(t)}r+=e,l===void 0&&n++;break}case`d`:case`i`:{let e=p===void 0?0:Math.floor(Number(p));Number.isNaN(e)&&(e=0);let t=e<0,i=Math.abs(e).toString();if(c){let e=parseInt(c,10);i=i.padStart(e,`0`)}let a=``;t?a=`-`:o.includes(`+`)?a=`+`:o.includes(` `)&&(a=` `);let u=a+i;if(s){let e=parseInt(s,10);u=o.includes(`-`)?u.padEnd(e):o.includes(`0`)&&!c?a+i.padStart(e-a.length,`0`):u.padStart(e)}r+=u,l===void 0&&n++;break}case`f`:{let e=p===void 0?0:Number(p);Number.isNaN(e)&&(e=0);let t=c?parseInt(c,10):6,i=e.toFixed(t);if(s){let e=parseInt(s,10);i=o.includes(`-`)?i.padEnd(e):i.padStart(e)}r+=i,l===void 0&&n++;break}case`e`:case`E`:{let e=p===void 0?0:Number(p);Number.isNaN(e)&&(e=0);let t=c?parseInt(c,10):6,i=e.toExponential(t);if(f===`E`&&(i=i.toUpperCase()),s){let e=parseInt(s,10);i=o.includes(`-`)?i.padEnd(e):i.padStart(e)}r+=i,l===void 0&&n++;break}case`g`:case`G`:{let e=p===void 0?0:Number(p);Number.isNaN(e)&&(e=0);let t=c?parseInt(c,10):6,i=e===0?0:Math.floor(Math.log10(Math.abs(e))),a;if(e===0?a=`0`:i<-4||i>=t?(a=e.toExponential(t-1),f===`G`&&(a=a.toUpperCase())):a=e.toPrecision(t),a.includes(`.`)&&(a=a.replace(/\.?0+$/,``).replace(/\.?0+e/,`e`)),a.includes(`e`)&&(a=a.replace(/\.?0+e/,`e`)),s){let e=parseInt(s,10);a=o.includes(`-`)?a.padEnd(e):a.padStart(e)}r+=a,l===void 0&&n++;break}case`x`:case`X`:{let e=p===void 0?0:Math.floor(Number(p));Number.isNaN(e)&&(e=0);let t=Math.abs(e).toString(16);if(f===`X`&&(t=t.toUpperCase()),c){let e=parseInt(c,10);t=t.padStart(e,`0`)}let i=e<0?`-`:``,a=i+t;if(s){let e=parseInt(s,10);a=o.includes(`-`)?a.padEnd(e):o.includes(`0`)&&!c?i+t.padStart(e-i.length,`0`):a.padStart(e)}r+=a,l===void 0&&n++;break}case`o`:{let e=p===void 0?0:Math.floor(Number(p));Number.isNaN(e)&&(e=0);let t=Math.abs(e).toString(8);if(c){let e=parseInt(c,10);t=t.padStart(e,`0`)}let i=e<0?`-`:``,a=i+t;if(s){let e=parseInt(s,10);a=o.includes(`-`)?a.padEnd(e):o.includes(`0`)&&!c?i+t.padStart(e-i.length,`0`):a.padStart(e)}r+=a,l===void 0&&n++;break}case`c`:typeof p==`number`?r+=String.fromCharCode(p):r+=String(p??``).charAt(0)||``,l===void 0&&n++;break;case`%`:r+=`%`;break;default:r+=e.substring(i,a+1)}i=a+1}else if(e[i]===`\\`&&i+1<e.length){let t=e[i+1];switch(t){case`n`:r+=`
|
|
4
|
-
`;break;case`t`:r+=` `;break;case`r`:r+=`\r`;break;case`\\`:r+=`\\`;break;default:r+=t}i+=2}else r+=e[i++];return r}var be=new Map([[`length`,ee],[`substr`,x],[`index`,S],[`split`,C],[`sub`,te],[`gsub`,ne],[`match`,ie],[`gensub`,ae],[`tolower`,se],[`toupper`,ce],[`sprintf`,le],[`int`,ue],[`sqrt`,de],[`sin`,fe],[`cos`,pe],[`atan2`,me],[`log`,he],[`exp`,ge],[`rand`,_e],[`srand`,ve],[`system`,ye(`system`,`shell execution not allowed in sandboxed environment`)],[`close`,()=>0],[`fflush`,()=>0],[`systime`,w(`systime`)],[`mktime`,w(`mktime`)],[`strftime`,w(`strftime`)]]);function D(e){return typeof e==`number`?e!==0:!(e===``||e===`0`)}function O(e){if(typeof e==`number`)return e;let t=parseFloat(e);return Number.isNaN(t)?0:t}function k(e){return typeof e==`string`?e:String(e)}function xe(e){if(typeof e==`number`)return!0;let t=String(e).trim();return t===``?!1:!Number.isNaN(Number(t))}function A(e,n){try{return t(e).test(n)}catch{return!1}}function j(e,t){return t===``?[]:e.FS===` `?t.trim().split(/\s+/).filter(Boolean):e.fieldSep.split(t)}function M(e,t){return t===0?e.line:t<0||t>e.fields.length?``:e.fields[t-1]??``}function N(e,t,n){if(t===0)e.line=k(n),e.fields=j(e,e.line),e.NF=e.fields.length;else if(t>0){for(;e.fields.length<t;)e.fields.push(``);e.fields[t-1]=k(n),e.NF=e.fields.length,e.line=e.fields.join(e.OFS)}}function P(e,t){e.line=t,e.fields=j(e,t),e.NF=e.fields.length}function Se(n,r){if(n.FS=r,r===` `)n.fieldSep=new e(/\s+/);else try{n.fieldSep=t(r)}catch{n.fieldSep=t(r.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`))}}function F(e,t){switch(t){case`FS`:return e.FS;case`OFS`:return e.OFS;case`ORS`:return e.ORS;case`OFMT`:return e.OFMT;case`NR`:return e.NR;case`NF`:return e.NF;case`FNR`:return e.FNR;case`FILENAME`:return e.FILENAME;case`RSTART`:return e.RSTART;case`RLENGTH`:return e.RLENGTH;case`SUBSEP`:return e.SUBSEP;case`ARGC`:return e.ARGC}return e.vars[t]??``}function I(e,t,n){switch(t){case`FS`:Se(e,k(n));return;case`OFS`:e.OFS=k(n);return;case`ORS`:e.ORS=k(n);return;case`OFMT`:e.OFMT=k(n);return;case`NR`:e.NR=Math.floor(O(n));return;case`NF`:{let t=Math.floor(O(n));if(t<e.NF)e.fields=e.fields.slice(0,t),e.line=e.fields.join(e.OFS);else if(t>e.NF){for(;e.fields.length<t;)e.fields.push(``);e.line=e.fields.join(e.OFS)}e.NF=t;return}case`FNR`:e.FNR=Math.floor(O(n));return;case`FILENAME`:e.FILENAME=k(n);return;case`RSTART`:e.RSTART=Math.floor(O(n));return;case`RLENGTH`:e.RLENGTH=Math.floor(O(n));return;case`SUBSEP`:e.SUBSEP=k(n);return}e.vars[t]=n}function L(e,t){let n=t,r=new Set,i=e.arrayAliases.get(n);for(;i!==void 0&&!r.has(n);)r.add(n),n=i,i=e.arrayAliases.get(n);return n}function R(e,t,n){if(t===`ARGV`)return e.ARGV[n]??``;if(t===`ENVIRON`)return e.ENVIRON[n]??``;let r=L(e,t);return e.arrays[r]?.[n]??``}function Ce(e,t,n,r){let i=L(e,t);e.arrays[i]||(e.arrays[i]=Object.create(null)),e.arrays[i][n]=r}function we(e,t,n){if(t===`ARGV`)return e.ARGV[n]!==void 0;if(t===`ENVIRON`)return e.ENVIRON[n]!==void 0;let r=L(e,t);return e.arrays[r]?.[n]!==void 0}function Te(e,t,n){let r=L(e,t);e.arrays[r]&&delete e.arrays[r][n]}function Ee(e,t){let n=L(e,t);delete e.arrays[n]}var De=null;function Oe(e){De=e}function z(e,t){o(e.requireDefenseContext,`awk`,t)}function B(e,t,n){return a(e.requireDefenseContext,`awk`,t,n)}async function V(e,t){switch(z(e,`expression evaluation`),e.coverage?.hit(`awk:expr:${t.type}`),t.type){case`number`:return t.value;case`string`:return t.value;case`regex`:return A(t.pattern,e.line)?1:0;case`field`:return ke(e,t);case`variable`:return F(e,t.name);case`array_access`:return Ae(e,t);case`binary`:return je(e,t);case`unary`:return Pe(e,t);case`ternary`:return D(await B(e,`ternary condition evaluation`,()=>V(e,t.condition)))?await B(e,`ternary consequent evaluation`,()=>V(e,t.consequent)):await B(e,`ternary alternate evaluation`,()=>V(e,t.alternate));case`call`:return Fe(e,t.name,t.args);case`assignment`:return Le(e,t);case`pre_increment`:return Re(e,t.operand);case`pre_decrement`:return ze(e,t.operand);case`post_increment`:return Be(e,t.operand);case`post_decrement`:return Ve(e,t.operand);case`in`:return He(e,t.key,t.array);case`getline`:return Ue(e,t.variable,t.file,t.command);case`tuple`:return Ke(e,t.elements);default:return``}}async function ke(e,t){return z(e,`field reference evaluation`),M(e,Math.floor(O(await B(e,`field index evaluation`,()=>V(e,t.index)))))}async function Ae(e,t){z(e,`array access evaluation`);let n=k(await B(e,`array key evaluation`,()=>V(e,t.key)));return R(e,t.array,n)}async function je(e,r){z(e,`binary expression evaluation`);let i=r.operator;if(i===`||`)return D(await B(e,`logical-or left evaluation`,()=>V(e,r.left)))||D(await B(e,`logical-or right evaluation`,()=>V(e,r.right)))?1:0;if(i===`&&`)return D(await B(e,`logical-and left evaluation`,()=>V(e,r.left)))&&D(await B(e,`logical-and right evaluation`,()=>V(e,r.right)))?1:0;if(i===`~`){let n=await B(e,`regex left evaluation`,()=>V(e,r.left));r.right.type===`regex`&&e.coverage?.hit(`awk:expr:regex`);let i=r.right.type===`regex`?r.right.pattern:k(await B(e,`regex right evaluation`,()=>V(e,r.right)));try{return t(i).test(k(n))?1:0}catch{return 0}}if(i===`!~`){let n=await B(e,`negated-regex left evaluation`,()=>V(e,r.left));r.right.type===`regex`&&e.coverage?.hit(`awk:expr:regex`);let i=r.right.type===`regex`?r.right.pattern:k(await B(e,`negated-regex right evaluation`,()=>V(e,r.right)));try{return t(i).test(k(n))?0:1}catch{return 1}}let a=await B(e,`binary left evaluation`,()=>V(e,r.left)),o=await B(e,`binary right evaluation`,()=>V(e,r.right));if(i===` `){let t=k(a)+k(o);if(e.maxOutputSize>0&&t.length>e.maxOutputSize)throw new n(`awk: string concatenation size limit exceeded (${e.maxOutputSize} bytes)`,`string_length`,e.output);return t}return Me(i)?Ne(a,o,i):m(O(a),O(o),i)}function Me(e){return[`<`,`<=`,`>`,`>=`,`==`,`!=`].includes(e)}function Ne(e,t,n){let r=xe(e),i=xe(t);if(r&&i){let r=O(e),i=O(t);switch(n){case`<`:return r<i?1:0;case`<=`:return r<=i?1:0;case`>`:return r>i?1:0;case`>=`:return r>=i?1:0;case`==`:return r===i?1:0;case`!=`:return r===i?0:1}}let a=k(e),o=k(t);switch(n){case`<`:return a<o?1:0;case`<=`:return a<=o?1:0;case`>`:return a>o?1:0;case`>=`:return a>=o?1:0;case`==`:return a===o?1:0;case`!=`:return a===o?0:1}return 0}async function Pe(e,t){z(e,`unary expression evaluation`);let n=await B(e,`unary operand evaluation`,()=>V(e,t.operand));switch(t.operator){case`!`:return D(n)?0:1;case`-`:return-O(n);case`+`:return+O(n);default:return n}}async function Fe(e,t,n){z(e,`function call evaluation`);let r=be.get(t);if(r)return r(n,e,{evalExpr:t=>V(e,t)});let i=e.functions.get(t);return i?Ie(e,i,n):``}async function Ie(e,t,r){if(z(e,`user function call`),e.currentRecursionDepth++,e.currentRecursionDepth>e.maxRecursionDepth)throw e.currentRecursionDepth--,new n(`awk: recursion depth exceeded maximum (${e.maxRecursionDepth})`,`recursion`,e.output);let i=Object.create(null);for(let n of t.params)i[n]=e.vars[n];let a=[];for(let n=0;n<t.params.length;n++){let i=t.params[n];if(n<r.length){let t=r[n];t.type===`variable`&&(e.arrayAliases.set(i,t.name),a.push(i));let o=await B(e,`user function argument evaluation`,()=>V(e,t));e.vars[i]=o}else e.vars[i]=``}e.hasReturn=!1,e.returnValue=void 0;let o=De;o&&await B(e,`user function body execution`,()=>o(e,t.body.statements));let s=e.returnValue??``;for(let n of t.params)i[n]===void 0?delete e.vars[n]:e.vars[n]=i[n];for(let t of a)e.arrayAliases.delete(t);return e.hasReturn=!1,e.returnValue=void 0,e.currentRecursionDepth--,s}async function Le(e,t){z(e,`assignment evaluation`);let n=await B(e,`assignment value evaluation`,()=>V(e,t.value)),r=t.target,i=t.operator,a;if(i===`=`)a=n;else{let t;if(r.type===`field`)t=M(e,Math.floor(O(await B(e,`assignment field index`,()=>V(e,r.index)))));else if(r.type===`variable`)t=F(e,r.name);else{let n=k(await B(e,`assignment array key`,()=>V(e,r.key)));t=R(e,r.array,n)}let o=O(t),s=O(n);switch(i){case`+=`:a=o+s;break;case`-=`:a=o-s;break;case`*=`:a=o*s;break;case`/=`:a=s===0?0:o/s;break;case`%=`:a=s===0?0:o%s;break;case`^=`:a=o**s;break;default:a=n}}if(r.type===`field`)N(e,Math.floor(O(await B(e,`assignment target field index`,()=>V(e,r.index)))),a);else if(r.type===`variable`)I(e,r.name,a);else{let t=k(await B(e,`assignment target array key`,()=>V(e,r.key)));Ce(e,r.array,t,a)}return a}async function H(e,t,n,r){z(e,`inc/dec evaluation`);let i;if(t.type===`field`){let r=Math.floor(O(await B(e,`inc/dec field index`,()=>V(e,t.index))));i=O(M(e,r)),N(e,r,i+n)}else if(t.type===`variable`)i=O(F(e,t.name)),I(e,t.name,i+n);else{let r=k(await B(e,`inc/dec array key`,()=>V(e,t.key)));i=O(R(e,t.array,r)),Ce(e,t.array,r,i+n)}return r?i+n:i}async function Re(e,t){return H(e,t,1,!0)}async function ze(e,t){return H(e,t,-1,!0)}async function Be(e,t){return H(e,t,1,!1)}async function Ve(e,t){return H(e,t,-1,!1)}async function He(e,t,n){z(e,`in-expression evaluation`);let r;if(t.type===`tuple`){e.coverage?.hit(`awk:expr:tuple`);let n=[];for(let r of t.elements)n.push(k(await B(e,`tuple key element evaluation`,()=>V(e,r))));r=n.join(e.SUBSEP)}else r=k(await B(e,`in-expression key evaluation`,()=>V(e,t)));return we(e,n,r)?1:0}async function Ue(e,t,n,r){if(z(e,`getline evaluation`),r)return We(e,t,r);if(n)return Ge(e,t,n);if(!e.lines||e.lineIndex===void 0)return-1;let i=e.lineIndex+1;if(i>=e.lines.length)return 0;let a=e.lines[i];return t?I(e,t,a):P(e,a),e.NR++,e.lineIndex=i,1}async function We(e,t,n){let i=e.exec;if(!i)return-1;z(e,`getline command source`);let a=k(await B(e,`getline command expression`,()=>V(e,n))),o=`__cmd_${a}`,s=`__cmdi_${a}`,c,l;if(e.vars[o]===void 0)try{c=(await B(e,`getline command exec`,()=>i(a))).stdout.split(`
|
|
5
|
-
`),c.length>0&&c[c.length-1]===``&&c.pop(),e.vars[o]=JSON.stringify(c),e.vars[s]=-1,l=-1}catch(e){if(e instanceof r)throw e;return-1}else c=JSON.parse(e.vars[o]),l=e.vars[s];let u=l+1;if(u>=c.length)return 0;let d=c[u];return e.vars[s]=u,t?I(e,t,d):P(e,d),1}async function Ge(e,t,n){let i=e.fs;if(!i||!e.cwd)return-1;z(e,`getline file source`);let a=k(await B(e,`getline filename evaluation`,()=>V(e,n)));if(a===`/dev/null`)return 0;let o=i.resolvePath(e.cwd,a),s=`__fc_${o}`,c=`__fi_${o}`,l,u;if(e.vars[s]===void 0)try{l=(await B(e,`getline file read`,()=>i.readFile(o))).split(`
|
|
6
|
-
`),l.length>0&&l[l.length-1]===``&&l.pop(),e.vars[s]=JSON.stringify(l),e.vars[c]=-1,u=-1}catch(e){if(e instanceof r)throw e;return-1}else l=JSON.parse(e.vars[s]),u=e.vars[c];let d=u+1;if(d>=l.length)return 0;let f=l[d];return e.vars[c]=d,t?I(e,t,f):P(e,f),1}async function Ke(e,t){if(z(e,`tuple evaluation`),t.length===0)return``;for(let n=0;n<t.length-1;n++)await B(e,`tuple intermediate element`,()=>V(e,t[n]));return B(e,`tuple final element`,()=>V(e,t[t.length-1]))}Oe(K);function U(e){if(e.maxOutputSize>0&&e.output.length>e.maxOutputSize)throw new n(`awk: output size limit exceeded (${e.maxOutputSize} bytes)`,`string_length`,e.output)}function W(e,t){o(e.requireDefenseContext,`awk`,t)}function G(e,t,n){return a(e.requireDefenseContext,`awk`,t,n)}async function K(e,t){W(e,`block execution`);for(let n of t)if(await G(e,`statement execution`,()=>q(e,n)),qe(e))break}function qe(e){return e.shouldExit||e.shouldNext||e.shouldNextFile||e.loopBreak||e.loopContinue||e.hasReturn}async function q(e,t){switch(W(e,`single statement execution`),e.coverage?.hit(`awk:stmt:${t.type}`),t.type){case`block`:await G(e,`nested block statement`,()=>K(e,t.statements));break;case`expr_stmt`:await G(e,`expression statement`,()=>V(e,t.expression));break;case`print`:await G(e,`print statement`,()=>Je(e,t.args,t.output));break;case`printf`:await G(e,`printf statement`,()=>Ye(e,t.format,t.args,t.output));break;case`if`:await G(e,`if statement`,()=>Ze(e,t));break;case`while`:await G(e,`while statement`,()=>Qe(e,t));break;case`do_while`:await G(e,`do-while statement`,()=>$e(e,t));break;case`for`:await G(e,`for statement`,()=>et(e,t));break;case`for_in`:await G(e,`for-in statement`,()=>tt(e,t));break;case`break`:e.loopBreak=!0;break;case`continue`:e.loopContinue=!0;break;case`next`:e.shouldNext=!0;break;case`nextfile`:e.shouldNextFile=!0;break;case`exit`:e.shouldExit=!0;{let n=t.code;e.exitCode=n?Math.floor(O(await G(e,`exit code expression`,()=>V(e,n)))):0}break;case`return`:e.hasReturn=!0;{let n=t.value;e.returnValue=n?await G(e,`return expression`,()=>V(e,n)):``}break;case`delete`:await G(e,`delete statement`,()=>nt(e,t.target));break}}async function Je(e,t,n){W(e,`print execution`);let r=[];for(let n of t){let t=await G(e,`print argument evaluation`,()=>V(e,n));typeof t==`number`?Number.isInteger(t)&&Math.abs(t)<2**53-1?r.push(String(t)):r.push(E(e.OFMT,[t])):r.push(k(t))}let i=r.join(e.OFS)+e.ORS;n?await G(e,`print redirection write`,()=>Xe(e,n.redirect,n.file,i)):(e.output+=i,U(e))}async function Ye(e,t,n,r){W(e,`printf execution`);let i=k(await G(e,`printf format evaluation`,()=>V(e,t))),a=[];for(let t of n)a.push(await G(e,`printf argument evaluation`,()=>V(e,t)));let o=E(i,a);r?await G(e,`printf redirection write`,()=>Xe(e,r.redirect,r.file,o)):(e.output+=o,U(e))}async function Xe(e,t,n,r){W(e,`file write execution`);let i=e.fs;if(!i||!e.cwd){e.output+=r,U(e);return}let a=k(await G(e,`redirection filename evaluation`,()=>V(e,n))),o=i.resolvePath(e.cwd,a);t===`>`?e.openedFiles.has(o)?await G(e,`redirection append write`,()=>i.appendFile(o,r)):(await G(e,`redirection overwrite write`,()=>i.writeFile(o,r)),e.openedFiles.add(o)):(e.openedFiles.has(o)||e.openedFiles.add(o),await G(e,`redirection append mode write`,()=>i.appendFile(o,r)))}async function Ze(e,t){if(W(e,`if execution`),D(await G(e,`if condition evaluation`,()=>V(e,t.condition))))await G(e,`if consequent execution`,()=>q(e,t.consequent));else if(t.alternate){let n=t.alternate;await G(e,`if alternate execution`,()=>q(e,n))}}async function Qe(e,t){W(e,`while execution`);let r=0;for(;D(await G(e,`while condition evaluation`,()=>V(e,t.condition)));){if(r++,r>e.maxIterations)throw new n(`awk: while loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await G(e,`while body execution`,()=>q(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function $e(e,t){W(e,`do-while execution`);let r=0;do{if(r++,r>e.maxIterations)throw new n(`awk: do-while loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await G(e,`do-while body execution`,()=>q(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}while(D(await G(e,`do-while condition evaluation`,()=>V(e,t.condition))))}async function et(e,t){W(e,`for execution`);let r=t.init,i=t.condition,a=t.update;r&&await G(e,`for init evaluation`,()=>V(e,r));let o=0;for(;!i||D(await G(e,`for condition evaluation`,()=>V(e,i)));){if(o++,o>e.maxIterations)throw new n(`awk: for loop exceeded maximum iterations (${e.maxIterations})`,`iterations`,e.output);if(e.loopContinue=!1,await G(e,`for body execution`,()=>q(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break;a&&await G(e,`for update evaluation`,()=>V(e,a))}}async function tt(e,t){W(e,`for-in execution`);let n=e.arrays[t.array];if(n)for(let r of Object.keys(n)){if(e.vars[t.variable]=r,e.loopContinue=!1,await G(e,`for-in body execution`,()=>q(e,t.body)),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext||e.hasReturn)break}}async function nt(e,t){if(W(e,`delete execution`),t.type===`array_access`){let n=k(await G(e,`delete key evaluation`,()=>V(e,t.key)));Te(e,t.array,n)}else t.type===`variable`&&Ee(e,t.name)}var rt=class{ctx;program=null;rangeStates=[];constructor(e){this.ctx=e}assertDefenseContext(e){o(this.ctx.requireDefenseContext,`awk`,e)}withDefenseContext(e,t){return a(this.ctx.requireDefenseContext,`awk`,e,t)}execute(e){this.assertDefenseContext(`program initialization`),this.program=e,this.ctx.output=``;for(let t of e.functions)this.ctx.functions.set(t.name,t);this.rangeStates=e.rules.map(()=>!1)}async executeBegin(){if(this.assertDefenseContext(`BEGIN execution entry`),this.program){for(let e of this.program.rules)if(e.pattern?.type===`begin`&&(await this.withDefenseContext(`BEGIN block execution`,()=>K(this.ctx,e.action.statements)),this.ctx.shouldExit))break}}async executeLine(e){if(this.assertDefenseContext(`line execution entry`),!(!this.program||this.ctx.shouldExit)){P(this.ctx,e),this.ctx.NR++,this.ctx.FNR++,this.ctx.shouldNext=!1;for(let e=0;e<this.program.rules.length&&!(this.ctx.shouldExit||this.ctx.shouldNext||this.ctx.shouldNextFile);e++){let t=this.program.rules[e];t.pattern?.type===`begin`||t.pattern?.type===`end`||await this.withDefenseContext(`rule match`,()=>this.matchesRule(t,e))&&await this.withDefenseContext(`rule block execution`,()=>K(this.ctx,t.action.statements))}}}async executeEnd(){if(this.assertDefenseContext(`END execution entry`),this.program&&!this.ctx.inEndBlock){this.ctx.inEndBlock=!0,this.ctx.shouldExit=!1;for(let e of this.program.rules)if(e.pattern?.type===`end`&&(await this.withDefenseContext(`END block execution`,()=>K(this.ctx,e.action.statements)),this.ctx.shouldExit))break;this.ctx.inEndBlock=!1}}getOutput(){return this.ctx.output}getExitCode(){return this.ctx.exitCode}getContext(){return this.ctx}async matchesRule(e,t){this.assertDefenseContext(`rule matching`);let n=e.pattern;if(!n)return!0;switch(n.type){case`begin`:case`end`:return!1;case`regex_pattern`:return A(n.pattern,this.ctx.line);case`expr_pattern`:return D(await this.withDefenseContext(`expression pattern evaluation`,()=>V(this.ctx,n.expression)));case`range`:{let e=await this.withDefenseContext(`range start pattern`,()=>this.matchPattern(n.start)),r=await this.withDefenseContext(`range end pattern`,()=>this.matchPattern(n.end));return this.rangeStates[t]?(r&&(this.rangeStates[t]=!1),!0):e?(this.rangeStates[t]=!0,r&&(this.rangeStates[t]=!1),!0):!1}default:return!1}}async matchPattern(e){switch(this.assertDefenseContext(`pattern matching`),e.type){case`regex_pattern`:return A(e.pattern,this.ctx.line);case`expr_pattern`:return D(await this.withDefenseContext(`nested expression pattern`,()=>V(this.ctx,e.expression)));default:return!1}}},J;(function(e){e.NUMBER=`NUMBER`,e.STRING=`STRING`,e.REGEX=`REGEX`,e.IDENT=`IDENT`,e.BEGIN=`BEGIN`,e.END=`END`,e.IF=`IF`,e.ELSE=`ELSE`,e.WHILE=`WHILE`,e.DO=`DO`,e.FOR=`FOR`,e.IN=`IN`,e.BREAK=`BREAK`,e.CONTINUE=`CONTINUE`,e.NEXT=`NEXT`,e.NEXTFILE=`NEXTFILE`,e.EXIT=`EXIT`,e.RETURN=`RETURN`,e.DELETE=`DELETE`,e.FUNCTION=`FUNCTION`,e.PRINT=`PRINT`,e.PRINTF=`PRINTF`,e.GETLINE=`GETLINE`,e.PLUS=`PLUS`,e.MINUS=`MINUS`,e.STAR=`STAR`,e.SLASH=`SLASH`,e.PERCENT=`PERCENT`,e.CARET=`CARET`,e.EQ=`EQ`,e.NE=`NE`,e.LT=`LT`,e.GT=`GT`,e.LE=`LE`,e.GE=`GE`,e.MATCH=`MATCH`,e.NOT_MATCH=`NOT_MATCH`,e.AND=`AND`,e.OR=`OR`,e.NOT=`NOT`,e.ASSIGN=`ASSIGN`,e.PLUS_ASSIGN=`PLUS_ASSIGN`,e.MINUS_ASSIGN=`MINUS_ASSIGN`,e.STAR_ASSIGN=`STAR_ASSIGN`,e.SLASH_ASSIGN=`SLASH_ASSIGN`,e.PERCENT_ASSIGN=`PERCENT_ASSIGN`,e.CARET_ASSIGN=`CARET_ASSIGN`,e.INCREMENT=`INCREMENT`,e.DECREMENT=`DECREMENT`,e.QUESTION=`QUESTION`,e.COLON=`COLON`,e.COMMA=`COMMA`,e.SEMICOLON=`SEMICOLON`,e.NEWLINE=`NEWLINE`,e.LPAREN=`LPAREN`,e.RPAREN=`RPAREN`,e.LBRACE=`LBRACE`,e.RBRACE=`RBRACE`,e.LBRACKET=`LBRACKET`,e.RBRACKET=`RBRACKET`,e.DOLLAR=`DOLLAR`,e.APPEND=`APPEND`,e.PIPE=`PIPE`,e.EOF=`EOF`})(J||={});var it=new Map([[`BEGIN`,J.BEGIN],[`END`,J.END],[`if`,J.IF],[`else`,J.ELSE],[`while`,J.WHILE],[`do`,J.DO],[`for`,J.FOR],[`in`,J.IN],[`break`,J.BREAK],[`continue`,J.CONTINUE],[`next`,J.NEXT],[`nextfile`,J.NEXTFILE],[`exit`,J.EXIT],[`return`,J.RETURN],[`delete`,J.DELETE],[`function`,J.FUNCTION],[`print`,J.PRINT],[`printf`,J.PRINTF],[`getline`,J.GETLINE]]);function at(e){return e.replace(/\[\[:space:\]\]/g,`[ \\t\\n\\r\\f\\v]`).replace(/\[\[:blank:\]\]/g,`[ \\t]`).replace(/\[\[:alpha:\]\]/g,`[a-zA-Z]`).replace(/\[\[:digit:\]\]/g,`[0-9]`).replace(/\[\[:alnum:\]\]/g,`[a-zA-Z0-9]`).replace(/\[\[:upper:\]\]/g,`[A-Z]`).replace(/\[\[:lower:\]\]/g,`[a-z]`).replace(/\[\[:punct:\]\]/g,`[!"#$%&'()*+,\\-./:;<=>?@\\[\\]\\\\^_\`{|}~]`).replace(/\[\[:xdigit:\]\]/g,`[0-9A-Fa-f]`).replace(/\[\[:graph:\]\]/g,`[!-~]`).replace(/\[\[:print:\]\]/g,`[ -~]`).replace(/\[\[:cntrl:\]\]/g,`[\\x00-\\x1f\\x7f]`)}var ot=class{input;pos=0;line=1;column=1;lastTokenType=null;constructor(e){this.input=e}tokenize(){let e=[];for(;this.pos<this.input.length;){let t=this.nextToken();t&&(e.push(t),this.lastTokenType=t.type)}return e.push(this.makeToken(J.EOF,``)),e}makeToken(e,t){return{type:e,value:t,line:this.line,column:this.column}}peek(e=0){return this.input[this.pos+e]||``}advance(){let e=this.input[this.pos++]||``;return e===`
|
|
7
|
-
`?(this.line++,this.column=1):this.column++,e}skipWhitespace(){for(;this.pos<this.input.length;){let e=this.peek();if(e===` `||e===` `||e===`\r`)this.advance();else if(e===`\\`)if(this.peek(1)===`
|
|
8
|
-
`)this.advance(),this.advance();else break;else if(e===`#`)for(;this.pos<this.input.length&&this.peek()!==`
|
|
9
|
-
`;)this.advance();else break}}nextToken(){if(this.skipWhitespace(),this.pos>=this.input.length)return null;let e=this.line,t=this.column,n=this.peek();return n===`
|
|
10
|
-
`?(this.advance(),{type:J.NEWLINE,value:`
|
|
11
|
-
`,line:e,column:t}):n===`"`?this.readString():n===`/`&&this.canBeRegex()?this.readRegex():this.isDigit(n)||n===`.`&&this.isDigit(this.peek(1))?this.readNumber():this.isAlpha(n)||n===`_`?this.readIdentifier():this.readOperator()}canBeRegex(){return new Set([null,J.NEWLINE,J.SEMICOLON,J.LBRACE,J.RBRACE,J.LPAREN,J.LBRACKET,J.COMMA,J.ASSIGN,J.PLUS_ASSIGN,J.MINUS_ASSIGN,J.STAR_ASSIGN,J.SLASH_ASSIGN,J.PERCENT_ASSIGN,J.CARET_ASSIGN,J.AND,J.OR,J.NOT,J.MATCH,J.NOT_MATCH,J.QUESTION,J.COLON,J.LT,J.GT,J.LE,J.GE,J.EQ,J.NE,J.PLUS,J.MINUS,J.STAR,J.PERCENT,J.CARET,J.PRINT,J.PRINTF,J.IF,J.WHILE,J.DO,J.FOR,J.RETURN]).has(this.lastTokenType)}readString(){let e=this.line,t=this.column;this.advance();let n=``;for(;this.pos<this.input.length&&this.peek()!==`"`;)if(this.peek()===`\\`){this.advance();let e=this.advance();switch(e){case`n`:n+=`
|
|
12
|
-
`;break;case`t`:n+=` `;break;case`r`:n+=`\r`;break;case`f`:n+=`\f`;break;case`b`:n+=`\b`;break;case`v`:n+=`\v`;break;case`a`:n+=`\x07`;break;case`\\`:n+=`\\`;break;case`"`:n+=`"`;break;case`/`:n+=`/`;break;case`x`:{let e=``;for(;e.length<2&&/[0-9a-fA-F]/.test(this.peek());)e+=this.advance();e.length>0?n+=String.fromCharCode(parseInt(e,16)):n+=`x`;break}default:if(/[0-7]/.test(e)){let t=e;for(;t.length<3&&/[0-7]/.test(this.peek());)t+=this.advance();n+=String.fromCharCode(parseInt(t,8))}else n+=e}}else n+=this.advance();return this.peek()===`"`&&this.advance(),{type:J.STRING,value:n,line:e,column:t}}readRegex(){let e=this.line,t=this.column;this.advance();let n=``;for(;this.pos<this.input.length&&this.peek()!==`/`;)if(this.peek()===`\\`)n+=this.advance(),this.pos<this.input.length&&(n+=this.advance());else{if(this.peek()===`
|
|
13
|
-
`)break;n+=this.advance()}return this.peek()===`/`&&this.advance(),n=at(n),{type:J.REGEX,value:n,line:e,column:t}}readNumber(){let e=this.line,t=this.column,n=``;for(;this.isDigit(this.peek());)n+=this.advance();if(this.peek()===`.`&&this.isDigit(this.peek(1)))for(n+=this.advance();this.isDigit(this.peek());)n+=this.advance();if(this.peek()===`e`||this.peek()===`E`)for(n+=this.advance(),(this.peek()===`+`||this.peek()===`-`)&&(n+=this.advance());this.isDigit(this.peek());)n+=this.advance();return{type:J.NUMBER,value:parseFloat(n),line:e,column:t}}readIdentifier(){let e=this.line,t=this.column,n=``;for(;this.isAlphaNumeric(this.peek())||this.peek()===`_`;)n+=this.advance();let r=it.get(n);return r===void 0?{type:J.IDENT,value:n,line:e,column:t}:{type:r,value:n,line:e,column:t}}readOperator(){let e=this.line,t=this.column,n=this.advance(),r=this.peek();switch(n){case`+`:return r===`+`?(this.advance(),{type:J.INCREMENT,value:`++`,line:e,column:t}):r===`=`?(this.advance(),{type:J.PLUS_ASSIGN,value:`+=`,line:e,column:t}):{type:J.PLUS,value:`+`,line:e,column:t};case`-`:return r===`-`?(this.advance(),{type:J.DECREMENT,value:`--`,line:e,column:t}):r===`=`?(this.advance(),{type:J.MINUS_ASSIGN,value:`-=`,line:e,column:t}):{type:J.MINUS,value:`-`,line:e,column:t};case`*`:return r===`*`?(this.advance(),{type:J.CARET,value:`**`,line:e,column:t}):r===`=`?(this.advance(),{type:J.STAR_ASSIGN,value:`*=`,line:e,column:t}):{type:J.STAR,value:`*`,line:e,column:t};case`/`:return r===`=`?(this.advance(),{type:J.SLASH_ASSIGN,value:`/=`,line:e,column:t}):{type:J.SLASH,value:`/`,line:e,column:t};case`%`:return r===`=`?(this.advance(),{type:J.PERCENT_ASSIGN,value:`%=`,line:e,column:t}):{type:J.PERCENT,value:`%`,line:e,column:t};case`^`:return r===`=`?(this.advance(),{type:J.CARET_ASSIGN,value:`^=`,line:e,column:t}):{type:J.CARET,value:`^`,line:e,column:t};case`=`:return r===`=`?(this.advance(),{type:J.EQ,value:`==`,line:e,column:t}):{type:J.ASSIGN,value:`=`,line:e,column:t};case`!`:return r===`=`?(this.advance(),{type:J.NE,value:`!=`,line:e,column:t}):r===`~`?(this.advance(),{type:J.NOT_MATCH,value:`!~`,line:e,column:t}):{type:J.NOT,value:`!`,line:e,column:t};case`<`:return r===`=`?(this.advance(),{type:J.LE,value:`<=`,line:e,column:t}):{type:J.LT,value:`<`,line:e,column:t};case`>`:return r===`=`?(this.advance(),{type:J.GE,value:`>=`,line:e,column:t}):r===`>`?(this.advance(),{type:J.APPEND,value:`>>`,line:e,column:t}):{type:J.GT,value:`>`,line:e,column:t};case`&`:return r===`&`?(this.advance(),{type:J.AND,value:`&&`,line:e,column:t}):{type:J.IDENT,value:`&`,line:e,column:t};case`|`:return r===`|`?(this.advance(),{type:J.OR,value:`||`,line:e,column:t}):{type:J.PIPE,value:`|`,line:e,column:t};case`~`:return{type:J.MATCH,value:`~`,line:e,column:t};case`?`:return{type:J.QUESTION,value:`?`,line:e,column:t};case`:`:return{type:J.COLON,value:`:`,line:e,column:t};case`,`:return{type:J.COMMA,value:`,`,line:e,column:t};case`;`:return{type:J.SEMICOLON,value:`;`,line:e,column:t};case`(`:return{type:J.LPAREN,value:`(`,line:e,column:t};case`)`:return{type:J.RPAREN,value:`)`,line:e,column:t};case`{`:return{type:J.LBRACE,value:`{`,line:e,column:t};case`}`:return{type:J.RBRACE,value:`}`,line:e,column:t};case`[`:return{type:J.LBRACKET,value:`[`,line:e,column:t};case`]`:return{type:J.RBRACKET,value:`]`,line:e,column:t};case`$`:return{type:J.DOLLAR,value:`$`,line:e,column:t};default:return{type:J.IDENT,value:n,line:e,column:t}}}isDigit(e){return e>=`0`&&e<=`9`}isAlpha(e){return e>=`a`&&e<=`z`||e>=`A`&&e<=`Z`}isAlphaNumeric(e){return this.isDigit(e)||this.isAlpha(e)}},Y={LPAREN:`LPAREN`,RPAREN:`RPAREN`,QUESTION:`QUESTION`,NEWLINE:`NEWLINE`,SEMICOLON:`SEMICOLON`,RBRACE:`RBRACE`,COMMA:`COMMA`,PIPE:`PIPE`,GT:`GT`,APPEND:`APPEND`,AND:`AND`,OR:`OR`,ASSIGN:`ASSIGN`,PLUS_ASSIGN:`PLUS_ASSIGN`,MINUS_ASSIGN:`MINUS_ASSIGN`,STAR_ASSIGN:`STAR_ASSIGN`,SLASH_ASSIGN:`SLASH_ASSIGN`,PERCENT_ASSIGN:`PERCENT_ASSIGN`,CARET_ASSIGN:`CARET_ASSIGN`,RBRACKET:`RBRACKET`,COLON:`COLON`,IN:`IN`,PRINT:`PRINT`,PRINTF:`PRINTF`,IDENT:`IDENT`,LT:`LT`,LE:`LE`,GE:`GE`,EQ:`EQ`,NE:`NE`,MATCH:`MATCH`,NOT_MATCH:`NOT_MATCH`,NUMBER:`NUMBER`,STRING:`STRING`,DOLLAR:`DOLLAR`,NOT:`NOT`,MINUS:`MINUS`,PLUS:`PLUS`,INCREMENT:`INCREMENT`,DECREMENT:`DECREMENT`};function st(e){e.expect(Y.PRINT);let t=[];if(e.check(Y.NEWLINE)||e.check(Y.SEMICOLON)||e.check(Y.RBRACE)||e.check(Y.PIPE)||e.check(Y.GT)||e.check(Y.APPEND))t.push({type:`field`,index:{type:`number`,value:0}});else for(t.push(X(e));e.check(Y.COMMA);)e.advance(),t.push(X(e));let n;return e.check(Y.GT)?(e.advance(),n={redirect:`>`,file:e.parsePrimary()}):e.check(Y.APPEND)&&(e.advance(),n={redirect:`>>`,file:e.parsePrimary()}),{type:`print`,args:t,output:n}}function X(e){return ct(e)?Z(e,!0):Z(e,!1)}function Z(e,t){let n=t?e.parseTernary():lt(e);if(e.match(Y.ASSIGN,Y.PLUS_ASSIGN,Y.MINUS_ASSIGN,Y.STAR_ASSIGN,Y.SLASH_ASSIGN,Y.PERCENT_ASSIGN,Y.CARET_ASSIGN)){let r=e.advance(),i=Z(e,t);if(n.type!==`variable`&&n.type!==`field`&&n.type!==`array_access`)throw Error(`Invalid assignment target`);return{type:`assignment`,operator:new Map([[`=`,`=`],[`+=`,`+=`],[`-=`,`-=`],[`*=`,`*=`],[`/=`,`/=`],[`%=`,`%=`],[`^=`,`^=`]]).get(r.value)??`=`,target:n,value:i}}return n}function ct(e){let t=0,n=e.pos;for(;n<e.tokens.length;){let r=e.tokens[n];if(r.type===Y.LPAREN&&t++,r.type===Y.RPAREN&&t--,r.type===Y.QUESTION&&t===0)return!0;if(r.type===Y.NEWLINE||r.type===Y.SEMICOLON||r.type===Y.RBRACE||r.type===Y.COMMA||r.type===Y.PIPE)return!1;n++}return!1}function lt(e){let t=ut(e);for(;e.check(Y.OR);){e.advance();let n=ut(e);t={type:`binary`,operator:`||`,left:t,right:n}}return t}function ut(e){let t=dt(e);for(;e.check(Y.AND);){e.advance();let n=dt(e);t={type:`binary`,operator:`&&`,left:t,right:n}}return t}function dt(e){let t=ft(e);return e.check(Y.IN)?(e.advance(),{type:`in`,key:t,array:String(e.expect(Y.IDENT).value)}):t}function ft(e){let t=pt(e);for(;mt(e)&&!ht(e);){let n=pt(e);t={type:`binary`,operator:` `,left:t,right:n}}return t}function pt(e){let t=Q(e);for(;e.match(Y.MATCH,Y.NOT_MATCH);){let n=e.advance().type===Y.MATCH?`~`:`!~`,r=Q(e);t={type:`binary`,operator:n,left:t,right:r}}return t}function Q(e){let t=e.parseAddSub();for(;e.match(Y.LT,Y.LE,Y.GE,Y.EQ,Y.NE);){let n=e.advance(),r=e.parseAddSub();t={type:`binary`,operator:new Map([[`<`,`<`],[`<=`,`<=`],[`>=`,`>=`],[`==`,`==`],[`!=`,`!=`]]).get(n.value)??`==`,left:t,right:r}}return t}function mt(e){return e.match(Y.NUMBER,Y.STRING,Y.IDENT,Y.DOLLAR,Y.LPAREN,Y.NOT,Y.MINUS,Y.PLUS,Y.INCREMENT,Y.DECREMENT)}function ht(e){return e.match(Y.AND,Y.OR,Y.QUESTION,Y.ASSIGN,Y.PLUS_ASSIGN,Y.MINUS_ASSIGN,Y.STAR_ASSIGN,Y.SLASH_ASSIGN,Y.PERCENT_ASSIGN,Y.CARET_ASSIGN,Y.COMMA,Y.SEMICOLON,Y.NEWLINE,Y.RBRACE,Y.RPAREN,Y.RBRACKET,Y.COLON,Y.PIPE,Y.APPEND,Y.GT,Y.IN)}function gt(e){e.expect(Y.PRINTF);let t=e.check(Y.LPAREN);t&&(e.advance(),e.skipNewlines());let n=t?e.parseExpression():X(e),r=[];for(;e.check(Y.COMMA);)e.advance(),t&&e.skipNewlines(),r.push(t?e.parseExpression():X(e));t&&(e.skipNewlines(),e.expect(Y.RPAREN));let i;return e.check(Y.GT)?(e.advance(),i={redirect:`>`,file:e.parsePrimary()}):e.check(Y.APPEND)&&(e.advance(),i={redirect:`>>`,file:e.parsePrimary()}),{type:`printf`,format:n,args:r,output:i}}var _t=class{tokens=[];pos=0;parse(e){return this.tokens=new ot(e).tokenize(),this.pos=0,this.parseProgram()}setPos(e){this.pos=e}current(){return this.tokens[this.pos]||{type:J.EOF,value:``,line:0,column:0}}advance(){let e=this.current();return this.pos<this.tokens.length&&this.pos++,e}match(...e){return e.includes(this.current().type)}check(e){return this.current().type===e}expect(e,t){if(!this.check(e)){let n=this.current();throw Error(t||`Expected ${e}, got ${n.type} at line ${n.line}:${n.column}`)}return this.advance()}skipNewlines(){for(;this.check(J.NEWLINE);)this.advance()}skipTerminators(){for(;this.check(J.NEWLINE)||this.check(J.SEMICOLON);)this.advance()}parseProgram(){let e=[],t=[];for(this.skipNewlines();!this.check(J.EOF)&&(this.skipNewlines(),!this.check(J.EOF));)this.check(J.FUNCTION)?e.push(this.parseFunction()):t.push(this.parseRule()),this.skipTerminators();return{functions:e,rules:t}}parseFunction(){this.expect(J.FUNCTION);let e=this.expect(J.IDENT).value;this.expect(J.LPAREN);let t=[];if(!this.check(J.RPAREN))for(t.push(this.expect(J.IDENT).value);this.check(J.COMMA);)this.advance(),t.push(this.expect(J.IDENT).value);return this.expect(J.RPAREN),this.skipNewlines(),{name:e,params:t,body:this.parseBlock()}}parseRule(){let e;if(this.check(J.BEGIN))this.advance(),e={type:`begin`};else if(this.check(J.END))this.advance(),e={type:`end`};else if(this.check(J.LBRACE))e=void 0;else if(this.check(J.REGEX)){let t=this.advance();if(this.check(J.AND)||this.check(J.OR)){let n={type:`binary`,operator:`~`,left:{type:`field`,index:{type:`number`,value:0}},right:{type:`regex`,pattern:t.value}};e={type:`expr_pattern`,expression:this.parseLogicalOrRest(n)}}else{let n={type:`regex_pattern`,pattern:t.value};if(this.check(J.COMMA)){this.advance();let t;t=this.check(J.REGEX)?{type:`regex_pattern`,pattern:this.advance().value}:{type:`expr_pattern`,expression:this.parseExpression()},e={type:`range`,start:n,end:t}}else e=n}}else{let t={type:`expr_pattern`,expression:this.parseExpression()};if(this.check(J.COMMA)){this.advance();let n;n=this.check(J.REGEX)?{type:`regex_pattern`,pattern:this.advance().value}:{type:`expr_pattern`,expression:this.parseExpression()},e={type:`range`,start:t,end:n}}else e=t}this.skipNewlines();let t;return t=this.check(J.LBRACE)?this.parseBlock():{type:`block`,statements:[{type:`print`,args:[{type:`field`,index:{type:`number`,value:0}}]}]},{pattern:e,action:t}}parseBlock(){this.expect(J.LBRACE),this.skipNewlines();let e=[];for(;!this.check(J.RBRACE)&&!this.check(J.EOF);)e.push(this.parseStatement()),this.skipTerminators();return this.expect(J.RBRACE),{type:`block`,statements:e}}parseStatement(){if(this.check(J.SEMICOLON)||this.check(J.NEWLINE))return this.advance(),{type:`block`,statements:[]};if(this.check(J.LBRACE))return this.parseBlock();if(this.check(J.IF))return this.parseIf();if(this.check(J.WHILE))return this.parseWhile();if(this.check(J.DO))return this.parseDoWhile();if(this.check(J.FOR))return this.parseFor();if(this.check(J.BREAK))return this.advance(),{type:`break`};if(this.check(J.CONTINUE))return this.advance(),{type:`continue`};if(this.check(J.NEXT))return this.advance(),{type:`next`};if(this.check(J.NEXTFILE))return this.advance(),{type:`nextfile`};if(this.check(J.EXIT)){this.advance();let e;return!this.check(J.NEWLINE)&&!this.check(J.SEMICOLON)&&!this.check(J.RBRACE)&&!this.check(J.EOF)&&(e=this.parseExpression()),{type:`exit`,code:e}}if(this.check(J.RETURN)){this.advance();let e;return!this.check(J.NEWLINE)&&!this.check(J.SEMICOLON)&&!this.check(J.RBRACE)&&!this.check(J.EOF)&&(e=this.parseExpression()),{type:`return`,value:e}}if(this.check(J.DELETE)){this.advance();let e=this.parsePrimary();if(e.type!==`array_access`&&e.type!==`variable`)throw Error(`delete requires array element or array`);return{type:`delete`,target:e}}return this.check(J.PRINT)?st(this):this.check(J.PRINTF)?gt(this):{type:`expr_stmt`,expression:this.parseExpression()}}parseIf(){this.expect(J.IF),this.expect(J.LPAREN);let e=this.parseExpression();this.expect(J.RPAREN),this.skipNewlines();let t=this.parseStatement();this.skipTerminators();let n;return this.check(J.ELSE)&&(this.advance(),this.skipNewlines(),n=this.parseStatement()),{type:`if`,condition:e,consequent:t,alternate:n}}parseWhile(){this.expect(J.WHILE),this.expect(J.LPAREN);let e=this.parseExpression();return this.expect(J.RPAREN),this.skipNewlines(),{type:`while`,condition:e,body:this.parseStatement()}}parseDoWhile(){this.expect(J.DO),this.skipNewlines();let e=this.parseStatement();this.skipNewlines(),this.expect(J.WHILE),this.expect(J.LPAREN);let t=this.parseExpression();return this.expect(J.RPAREN),{type:`do_while`,body:e,condition:t}}parseFor(){if(this.expect(J.FOR),this.expect(J.LPAREN),this.check(J.IDENT)){let e=this.advance();if(this.check(J.IN)){this.advance();let t=this.expect(J.IDENT).value;this.expect(J.RPAREN),this.skipNewlines();let n=this.parseStatement();return{type:`for_in`,variable:e.value,array:t,body:n}}this.pos--}let e;this.check(J.SEMICOLON)||(e=this.parseExpression()),this.expect(J.SEMICOLON);let t;this.check(J.SEMICOLON)||(t=this.parseExpression()),this.expect(J.SEMICOLON);let n;this.check(J.RPAREN)||(n=this.parseExpression()),this.expect(J.RPAREN),this.skipNewlines();let r=this.parseStatement();return{type:`for`,init:e,condition:t,update:n,body:r}}parseExpression(){return this.parseAssignment()}parseAssignment(){let e=this.parseTernary();if(this.match(J.ASSIGN,J.PLUS_ASSIGN,J.MINUS_ASSIGN,J.STAR_ASSIGN,J.SLASH_ASSIGN,J.PERCENT_ASSIGN,J.CARET_ASSIGN)){let t=this.advance(),n=this.parseAssignment();if(e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`)throw Error(`Invalid assignment target`);let r=new Set([`=`,`+=`,`-=`,`*=`,`/=`,`%=`,`^=`]),i=t.value;if(!r.has(i))throw Error(`Unknown assignment operator: ${i}`);return{type:`assignment`,operator:i,target:e,value:n}}return e}parseTernary(){let e=this.parsePipeGetline();if(this.check(J.QUESTION)){this.advance();let t=this.parseExpression();this.expect(J.COLON);let n=this.parseExpression();e={type:`ternary`,condition:e,consequent:t,alternate:n}}return e}parsePipeGetline(){let e=this.parseOr();if(this.check(J.PIPE)){if(this.advance(),!this.check(J.GETLINE))throw Error(`Expected 'getline' after '|' in expression context`);this.advance();let t;return this.check(J.IDENT)&&(t=this.advance().value),{type:`getline`,command:e,variable:t}}return e}parseOr(){let e=this.parseAnd();for(;this.check(J.OR);){this.advance();let t=this.parseAnd();e={type:`binary`,operator:`||`,left:e,right:t}}return e}parseLogicalOrRest(e){for(e=this.parseLogicalAndRest(e);this.check(J.OR);){this.advance();let t=this.parseAnd();e={type:`binary`,operator:`||`,left:e,right:t}}return e}parseLogicalAndRest(e){for(;this.check(J.AND);){this.advance();let t=this.parseIn();e={type:`binary`,operator:`&&`,left:e,right:t}}return e}parseAnd(){let e=this.parseIn();for(;this.check(J.AND);){this.advance();let t=this.parseIn();e={type:`binary`,operator:`&&`,left:e,right:t}}return e}parseIn(){let e=this.parseConcatenation();return this.check(J.IN)?(this.advance(),{type:`in`,key:e,array:this.expect(J.IDENT).value}):e}parseConcatenation(){let e=this.parseMatch();for(;this.canStartExpression()&&!this.isConcatTerminator();){let t=this.parseMatch();e={type:`binary`,operator:` `,left:e,right:t}}return e}parseMatch(){let e=this.parseComparison();for(;this.match(J.MATCH,J.NOT_MATCH);){let t=this.advance().type===J.MATCH?`~`:`!~`,n=this.parseComparison();e={type:`binary`,operator:t,left:e,right:n}}return e}parseComparison(){let e=this.parseAddSub();for(;this.match(J.LT,J.LE,J.GT,J.GE,J.EQ,J.NE);){let t=this.advance(),n=this.parseAddSub();e={type:`binary`,operator:new Map([[`<`,`<`],[`<=`,`<=`],[`>`,`>`],[`>=`,`>=`],[`==`,`==`],[`!=`,`!=`]]).get(t.value)??`==`,left:e,right:n}}return e}canStartExpression(){return this.match(J.NUMBER,J.STRING,J.IDENT,J.DOLLAR,J.LPAREN,J.NOT,J.MINUS,J.PLUS,J.INCREMENT,J.DECREMENT)}isConcatTerminator(){return this.match(J.AND,J.OR,J.QUESTION,J.ASSIGN,J.PLUS_ASSIGN,J.MINUS_ASSIGN,J.STAR_ASSIGN,J.SLASH_ASSIGN,J.PERCENT_ASSIGN,J.CARET_ASSIGN,J.COMMA,J.SEMICOLON,J.NEWLINE,J.RBRACE,J.RPAREN,J.RBRACKET,J.COLON,J.PIPE,J.APPEND,J.IN)}parseAddSub(){let e=this.parseMulDiv();for(;this.match(J.PLUS,J.MINUS);){let t=this.advance().value,n=this.parseMulDiv();e={type:`binary`,operator:t,left:e,right:n}}return e}parseMulDiv(){let e=this.parseUnary();for(;this.match(J.STAR,J.SLASH,J.PERCENT);){let t=this.advance(),n=this.parseUnary();e={type:`binary`,operator:new Map([[`*`,`*`],[`/`,`/`],[`%`,`%`]]).get(t.value)??`*`,left:e,right:n}}return e}parseUnary(){if(this.check(J.INCREMENT)){this.advance();let e=this.parseUnary();return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`+`,operand:{type:`unary`,operator:`+`,operand:e}}:{type:`pre_increment`,operand:e}}if(this.check(J.DECREMENT)){this.advance();let e=this.parseUnary();return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`-`,operand:{type:`unary`,operator:`-`,operand:e}}:{type:`pre_decrement`,operand:e}}return this.match(J.NOT,J.MINUS,J.PLUS)?{type:`unary`,operator:this.advance().value,operand:this.parseUnary()}:this.parsePower()}parsePower(){let e=this.parsePostfix();if(this.check(J.CARET)){this.advance();let t=this.parsePower();e={type:`binary`,operator:`^`,left:e,right:t}}return e}parsePostfix(){let e=this.parsePrimary();if(this.check(J.INCREMENT)){if(this.advance(),e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`)throw Error(`Invalid increment operand`);return{type:`post_increment`,operand:e}}if(this.check(J.DECREMENT)){if(this.advance(),e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`)throw Error(`Invalid decrement operand`);return{type:`post_decrement`,operand:e}}return e}parseFieldIndex(){if(this.check(J.INCREMENT)){this.advance();let e=this.parseFieldIndex();return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`+`,operand:{type:`unary`,operator:`+`,operand:e}}:{type:`pre_increment`,operand:e}}if(this.check(J.DECREMENT)){this.advance();let e=this.parseFieldIndex();return e.type!==`variable`&&e.type!==`field`&&e.type!==`array_access`?{type:`unary`,operator:`-`,operand:{type:`unary`,operator:`-`,operand:e}}:{type:`pre_decrement`,operand:e}}return this.match(J.NOT,J.MINUS,J.PLUS)?{type:`unary`,operator:this.advance().value,operand:this.parseFieldIndex()}:this.parseFieldIndexPower()}parseFieldIndexPower(){let e=this.parseFieldIndexPrimary();if(this.check(J.CARET)){this.advance();let t=this.parseFieldIndexPower();e={type:`binary`,operator:`^`,left:e,right:t}}return e}parseFieldIndexPrimary(){if(this.check(J.NUMBER))return{type:`number`,value:this.advance().value};if(this.check(J.STRING))return{type:`string`,value:this.advance().value};if(this.check(J.DOLLAR))return this.advance(),{type:`field`,index:this.parseFieldIndex()};if(this.check(J.LPAREN)){this.advance();let e=this.parseExpression();return this.expect(J.RPAREN),e}if(this.check(J.IDENT)){let e=this.advance().value;if(this.check(J.LPAREN)){this.advance();let t=[];if(!this.check(J.RPAREN))for(t.push(this.parseExpression());this.check(J.COMMA);)this.advance(),t.push(this.parseExpression());return this.expect(J.RPAREN),{type:`call`,name:e,args:t}}if(this.check(J.LBRACKET)){this.advance();let t=this.parseExpression();if(this.check(J.COMMA)){let n=[t];for(;this.check(J.COMMA);)this.advance(),n.push(this.parseExpression());return this.expect(J.RBRACKET),{type:`array_access`,array:e,key:n.reduce((e,t)=>({type:`binary`,operator:` `,left:{type:`binary`,operator:` `,left:e,right:{type:`variable`,name:`SUBSEP`}},right:t}))}}return this.expect(J.RBRACKET),{type:`array_access`,array:e,key:t}}return{type:`variable`,name:e}}throw Error(`Unexpected token in field index: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}parsePrimary(){if(this.check(J.NUMBER))return{type:`number`,value:this.advance().value};if(this.check(J.STRING))return{type:`string`,value:this.advance().value};if(this.check(J.REGEX))return{type:`regex`,pattern:this.advance().value};if(this.check(J.DOLLAR))return this.advance(),{type:`field`,index:this.parseFieldIndex()};if(this.check(J.LPAREN)){this.advance();let e=this.parseExpression();if(this.check(J.COMMA)){let t=[e];for(;this.check(J.COMMA);)this.advance(),t.push(this.parseExpression());return this.expect(J.RPAREN),{type:`tuple`,elements:t}}return this.expect(J.RPAREN),e}if(this.check(J.GETLINE)){this.advance();let e,t;return this.check(J.IDENT)&&(e=this.advance().value),this.check(J.LT)&&(this.advance(),t=this.parsePrimary()),{type:`getline`,variable:e,file:t}}if(this.check(J.IDENT)){let e=this.advance().value;if(this.check(J.LPAREN)){this.advance();let t=[];if(this.skipNewlines(),!this.check(J.RPAREN))for(t.push(this.parseExpression());this.check(J.COMMA);)this.advance(),this.skipNewlines(),t.push(this.parseExpression());return this.skipNewlines(),this.expect(J.RPAREN),{type:`call`,name:e,args:t}}if(this.check(J.LBRACKET)){this.advance();let t=[this.parseExpression()];for(;this.check(J.COMMA);)this.advance(),t.push(this.parseExpression());this.expect(J.RBRACKET);let n;if(t.length===1)n=t[0];else{n=t[0];for(let e=1;e<t.length;e++)n={type:`binary`,operator:` `,left:{type:`binary`,operator:` `,left:n,right:{type:`variable`,name:`SUBSEP`}},right:t[e]}}return{type:`array_access`,array:e,key:n}}return{type:`variable`,name:e}}throw Error(`Unexpected token: ${this.current().type} at line ${this.current().line}:${this.current().column}`)}},vt={name:`awk`,summary:`pattern scanning and text processing language`,usage:`awk [OPTIONS] 'PROGRAM' [FILE...]`,options:[`-F FS use FS as field separator`,`-v VAR=VAL assign VAL to variable VAR`,` --help display this help and exit`]},yt={name:`awk`,async execute(t,u){o(u.requireDefenseContext,`awk`,`execution entry`);let d=(e,t)=>a(u.requireDefenseContext,`awk`,e,t);if(l(t))return c(vt);let f=new e(/\s+/),m=` `,h=Object.create(null),g=0;for(let e=0;e<t.length;e++){let n=t[e];if(n===`-F`&&e+1<t.length)m=$(t[++e]),f=bt(m),g=e+1;else if(n.startsWith(`-F`))m=$(n.slice(2)),f=bt(m),g=e+1;else if(n===`-v`&&e+1<t.length){let n=t[++e],r=n.indexOf(`=`);if(r>0){let e=n.slice(0,r);h[e]=$(n.slice(r+1))}g=e+1}else{if(n.startsWith(`--`))return s(`awk`,n);if(n.startsWith(`-`)&&n.length>1){let t=n[1];if(t!==`F`&&t!==`v`)return s(`awk`,`-${t}`);g=e+1}else if(!n.startsWith(`-`)){g=e;break}}}if(g>=t.length)return{stdout:``,stderr:`awk: missing program
|
|
14
|
-
`,exitCode:1};let _=t[g],v=t.slice(g+1),y=new _t,b;try{b=y.parse(_)}catch(e){return{stdout:``,stderr:`awk: ${e instanceof Error?e.message:String(e)}
|
|
15
|
-
`,exitCode:1}}let ee={readFile:u.fs.readFile.bind(u.fs),writeFile:u.fs.writeFile.bind(u.fs),appendFile:async(e,t)=>{try{let n=await d(`appendFile read`,()=>u.fs.readFile(e));await d(`appendFile write`,()=>u.fs.writeFile(e,n+t))}catch(n){if(n instanceof r)throw n;await d(`appendFile create`,()=>u.fs.writeFile(e,t))}},resolvePath:u.fs.resolvePath.bind(u.fs)},x=u.exec,S=p({fieldSep:f,maxIterations:u.limits?.maxAwkIterations,maxOutputSize:u.limits?.maxStringLength,fs:ee,cwd:u.cwd,exec:x?e=>d(`command pipe exec`,()=>x(e,{cwd:u.cwd,signal:u.signal})):void 0,coverage:u.coverage,requireDefenseContext:u.requireDefenseContext});S.FS=m,S.vars=Object.assign(Object.create(null),h),S.ARGC=v.length+1,S.ARGV=Object.create(null),S.ARGV[0]=`awk`;for(let e=0;e<v.length;e++)S.ARGV[String(e+1)]=v[e];S.ENVIRON=i(u.env);let C=new rt(S);C.execute(b);let te=b.rules.some(e=>e.pattern?.type!==`begin`&&e.pattern?.type!==`end`),ne=b.rules.some(e=>e.pattern?.type===`end`);try{if(await d(`BEGIN execution`,()=>C.executeBegin()),S.shouldExit)return await d(`END execution after BEGIN exit`,()=>C.executeEnd()),{stdout:C.getOutput(),stderr:``,exitCode:C.getExitCode()};if(!te&&!ne)return{stdout:C.getOutput(),stderr:``,exitCode:C.getExitCode()};let e=[];if(v.length>0)for(let t of v)try{let n=u.fs.resolvePath(u.cwd,t),r=(await d(`input file read`,()=>u.fs.readFile(n))).split(`
|
|
16
|
-
`);r.length>0&&r[r.length-1]===``&&r.pop(),e.push({filename:t,lines:r})}catch(e){if(e instanceof r)throw e;return{stdout:``,stderr:`awk: ${t}: No such file or directory
|
|
17
|
-
`,exitCode:1}}else{let t=u.stdin.split(`
|
|
18
|
-
`);t.length>0&&t[t.length-1]===``&&t.pop(),e.push({filename:``,lines:t})}for(let t of e){for(S.FILENAME=t.filename,S.FNR=0,S.lines=t.lines,S.lineIndex=-1,S.shouldNextFile=!1;S.lineIndex<t.lines.length-1;){S.lineIndex++;let e=S.lineIndex;if(await d(`line execution`,()=>C.executeLine(t.lines[e])),S.shouldExit||S.shouldNextFile)break}if(S.shouldExit)break}return await d(`END execution`,()=>C.executeEnd()),{stdout:C.getOutput(),stderr:``,exitCode:C.getExitCode()}}catch(e){if(e instanceof r)throw e;let t=e instanceof Error?e.message:String(e),i=e instanceof n?n.EXIT_CODE:2;return{stdout:C.getOutput(),stderr:`awk: ${t}
|
|
19
|
-
`,exitCode:i}}}};function $(e){return e.replace(/\\t/g,` `).replace(/\\n/g,`
|
|
20
|
-
`).replace(/\\r/g,`\r`).replace(/\\b/g,`\b`).replace(/\\f/g,`\f`).replace(/\\a/g,`\x07`).replace(/\\v/g,`\v`).replace(/\\\\/g,`\\`)}function bt(e){if(e===` `)return t(`\\s+`);if(/[[\](){}.*+?^$|\\]/.test(e))try{return t(e)}catch{return t(xt(e))}return t(xt(e))}function xt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var St={name:`awk`,flags:[{flag:`-F`,type:`value`,valueHint:`delimiter`},{flag:`-v`,type:`value`,valueHint:`string`}],stdinType:`text`,needsArgs:!0};export{yt as n,St as t};
|
|
21
|
-
//# sourceMappingURL=chunk-OARHFVLG-Csb_cJVS.mjs.map
|