@kingsoftcloud/agentkit-harness-node 0.0.0-stage → 0.0.2
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/LICENSE +201 -0
- package/NOTICE +1 -0
- package/README.md +124 -2
- package/THIRD_PARTY_NOTICES.md +66 -0
- package/ZCode-LICENSE +202 -0
- package/dist/index.mjs +4871 -0
- package/dist/native-command-plan.LICENSE.txt +221 -0
- package/dist/native-command-plan.json +16 -0
- package/dist/native-command-plan.mjs +8 -0
- package/dist/rpc-entry.mjs +5682 -0
- package/package.json +169 -4
- package/src/native/a2a-receipt-source.mjs +19 -0
- package/src/native/a2a-tools.mjs +517 -0
- package/src/native/activity-status.mjs +30 -0
- package/src/native/artifact-codec.mjs +481 -0
- package/src/native/artifact-store.mjs +1162 -0
- package/src/native/assistant-stream.mjs +76 -0
- package/src/native/background-command-port.mjs +95 -0
- package/src/native/browser-action-observation.mjs +43 -0
- package/src/native/browser-availability.mjs +22 -0
- package/src/native/browser-canvas-metrics.mjs +71 -0
- package/src/native/browser-dom.mjs +193 -0
- package/src/native/browser-playwright.mjs +1249 -0
- package/src/native/browser-vision.mjs +369 -0
- package/src/native/browser-workspace-policy.mjs +22 -0
- package/src/native/browser-workspace-protocol.mjs +95 -0
- package/src/native/browser-workspace-server.mjs +164 -0
- package/src/native/browser-workspace.mjs +355 -0
- package/src/native/captured-source.mjs +3 -0
- package/src/native/child-budget-allocation.mjs +87 -0
- package/src/native/child-capabilities.mjs +35 -0
- package/src/native/child-command-resource.mjs +20 -0
- package/src/native/child-history.mjs +188 -0
- package/src/native/child-merge.mjs +98 -0
- package/src/native/child-model-surface.mjs +19 -0
- package/src/native/child-observation.mjs +100 -0
- package/src/native/child-owner.mjs +620 -0
- package/src/native/child-publication.mjs +76 -0
- package/src/native/child-readers.mjs +366 -0
- package/src/native/child-tools.mjs +46 -0
- package/src/native/child-workspace-binding.mjs +29 -0
- package/src/native/child-workspace-tools.mjs +1 -0
- package/src/native/child-workspaces.mjs +655 -0
- package/src/native/children.mjs +365 -0
- package/src/native/command-plan-worker.mjs +14 -0
- package/src/native/command-plan.mjs +31 -0
- package/src/native/command-progress.mjs +64 -0
- package/src/native/command-shell.mjs +9 -0
- package/src/native/command-workspace-observation.mjs +36 -0
- package/src/native/component-tools.mjs +280 -0
- package/src/native/context-counter.mjs +133 -0
- package/src/native/context-markers.mjs +51 -0
- package/src/native/context-profile.mjs +72 -0
- package/src/native/context-status.mjs +27 -0
- package/src/native/conversation-command-control.mjs +133 -0
- package/src/native/delivery-timeline.mjs +39 -0
- package/src/native/dsh-background-ownership.mjs +102 -0
- package/src/native/dsh-managed-ownership.mjs +23 -0
- package/src/native/dsh-turn-contract.mjs +3 -0
- package/src/native/dsh-turn-ownership.mjs +54 -0
- package/src/native/dsh-turn-runtime.mjs +498 -0
- package/src/native/e2b-background-supervisor.mjs +347 -0
- package/src/native/e2b-background.mjs +368 -0
- package/src/native/e2b-command-state.mjs +40 -0
- package/src/native/e2b-command-tools.mjs +486 -0
- package/src/native/e2b-sandbox-owner.mjs +227 -0
- package/src/native/hook-executor.mjs +249 -0
- package/src/native/instruction-assembly.mjs +60 -0
- package/src/native/instruction-context.mjs +54 -0
- package/src/native/local-background-supervisor.mjs +108 -0
- package/src/native/local-background.mjs +207 -0
- package/src/native/local-command-evidence.mjs +57 -0
- package/src/native/local-command-policy-worker.mjs +197 -0
- package/src/native/local-command-policy.mjs +46 -0
- package/src/native/local-command-state.mjs +177 -0
- package/src/native/local-command-tools.mjs +302 -0
- package/src/native/local-execution-profile.mjs +36 -0
- package/src/native/local-output-policy.mjs +92 -0
- package/src/native/local-process-bin/darwin-arm64/launcher +0 -0
- package/src/native/local-process-bin/darwin-x64/launcher +0 -0
- package/src/native/local-process-bin/linux-arm64/launcher +0 -0
- package/src/native/local-process-bin/linux-x64/launcher +0 -0
- package/src/native/local-process-launcher.c +183 -0
- package/src/native/local-process-licenses/GCC-COPYING.RUNTIME +72 -0
- package/src/native/local-process-licenses/GCC-COPYING3 +674 -0
- package/src/native/local-process-licenses/NOTICE +21 -0
- package/src/native/local-process-licenses/musl-COPYRIGHT +193 -0
- package/src/native/local-process-manifest.json +32 -0
- package/src/native/local-process.mjs +246 -0
- package/src/native/local-resource-profile.mjs +32 -0
- package/src/native/memory-candidate.mjs +121 -0
- package/src/native/memory-extraction-run.mjs +60 -0
- package/src/native/memory-extraction-tools.mjs +116 -0
- package/src/native/memory-recall.mjs +65 -0
- package/src/native/memory-store.mjs +334 -0
- package/src/native/memory-tools.mjs +329 -0
- package/src/native/model-anthropic-cache.mjs +49 -0
- package/src/native/model-anthropic-tool-search.mjs +85 -0
- package/src/native/model-anthropic.mjs +753 -0
- package/src/native/model-chat-usage.mjs +24 -0
- package/src/native/model-inline-reasoning.mjs +111 -0
- package/src/native/model-media.mjs +174 -0
- package/src/native/model-normalize.mjs +228 -0
- package/src/native/model-openai-chat.mjs +561 -0
- package/src/native/model-port.mjs +361 -0
- package/src/native/model-provider-compat.mjs +129 -0
- package/src/native/model-replay.mjs +153 -0
- package/src/native/model-request.mjs +15 -0
- package/src/native/model-responses.mjs +1205 -0
- package/src/native/model-sse.mjs +171 -0
- package/src/native/model-surface-host.mjs +27 -0
- package/src/native/model-tool-search-policy.mjs +16 -0
- package/src/native/model-transport-observation.mjs +27 -0
- package/src/native/owned-child.mjs +114 -0
- package/src/native/owned-command.mjs +106 -0
- package/src/native/python-syntax-worker.mjs +60 -0
- package/src/native/python-syntax.mjs +50 -0
- package/src/native/read-interruption.mjs +16 -0
- package/src/native/result-stream.mjs +63 -0
- package/src/native/ruff-ast.mjs +95 -0
- package/src/native/run-observation.mjs +128 -0
- package/src/native/session-delivery-journal.mjs +96 -0
- package/src/native/session-delivery.mjs +434 -0
- package/src/native/shell-analysis.mjs +50 -0
- package/src/native/skill-disclosure.mjs +404 -0
- package/src/native/skill-events.mjs +164 -0
- package/src/native/skill-tools.mjs +813 -0
- package/src/native/source-page.mjs +73 -0
- package/src/native/sqlite-session-inbox.mjs +42 -0
- package/src/native/sqlite-store.mjs +617 -0
- package/src/native/tool-authority.mjs +99 -0
- package/src/native/tool-guidance.mjs +12 -0
- package/src/native/tool-observation.mjs +75 -0
- package/src/native/tool-states.mjs +14 -0
- package/src/native/verification-authority.mjs +37 -0
- package/src/native/web-tools.mjs +643 -0
- package/src/native/workspace-checkpoints.mjs +312 -0
- package/src/native/workspace-context.mjs +61 -0
- package/src/native/workspace-display.mjs +39 -0
- package/src/native/workspace-edit-match.mjs +19 -0
- package/src/native/workspace-edit-worker.mjs +15 -0
- package/src/native/workspace-editing.mjs +447 -0
- package/src/native/workspace-image.mjs +72 -0
- package/src/native/workspace-instructions.mjs +107 -0
- package/src/native/workspace-mutation-lock.mjs +74 -0
- package/src/native/workspace-patch-worker.mjs +17 -0
- package/src/native/workspace-patch.mjs +17 -0
- package/src/native/workspace-paths.mjs +225 -0
- package/src/native/workspace-state.mjs +272 -0
- package/src/native/workspace-subject-observer.mjs +84 -0
- package/src/native/workspace-tools.mjs +1740 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
ZCode 3c5b227649371507ddc4eb46ac5133afe6db1cab
|
|
2
|
+
|
|
3
|
+
Apache License
|
|
4
|
+
Version 2.0, January 2004
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
12
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
13
|
+
|
|
14
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
15
|
+
the copyright owner that is granting the License.
|
|
16
|
+
|
|
17
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
18
|
+
other entities that control, are controlled by, or are under common
|
|
19
|
+
control with that entity. For the purposes of this definition,
|
|
20
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
21
|
+
direction or management of such entity, whether by contract or
|
|
22
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
23
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
26
|
+
exercising permissions granted by this License.
|
|
27
|
+
|
|
28
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
29
|
+
including but not limited to software source code, documentation
|
|
30
|
+
source, and configuration files.
|
|
31
|
+
|
|
32
|
+
"Object" form shall mean any form resulting from mechanical
|
|
33
|
+
transformation or translation of a Source form, including but
|
|
34
|
+
not limited to compiled object code, generated documentation,
|
|
35
|
+
and conversions to other media types.
|
|
36
|
+
|
|
37
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
38
|
+
Object form, made available under the License, as indicated by a
|
|
39
|
+
copyright notice that is included in or attached to the work
|
|
40
|
+
(an example is provided in the Appendix below).
|
|
41
|
+
|
|
42
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
43
|
+
form, that is based on (or derived from) the Work and for which the
|
|
44
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
45
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
46
|
+
of this License, Derivative Works shall not include works that remain
|
|
47
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
48
|
+
the Work and Derivative Works thereof.
|
|
49
|
+
|
|
50
|
+
"Contribution" shall mean any work of authorship, including
|
|
51
|
+
the original version of the Work and any modifications or additions
|
|
52
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
53
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
54
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
55
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
56
|
+
means any form of electronic, verbal, or written communication sent
|
|
57
|
+
to the Licensor or its representatives, including but not limited to
|
|
58
|
+
communication on electronic mailing lists, source code control systems,
|
|
59
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
60
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
61
|
+
excluding communication that is conspicuously marked or otherwise
|
|
62
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
63
|
+
|
|
64
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
65
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
66
|
+
subsequently incorporated within the Work.
|
|
67
|
+
|
|
68
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
69
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
70
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
71
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
72
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
73
|
+
Work and such Derivative Works in Source or Object form.
|
|
74
|
+
|
|
75
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
76
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
77
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
78
|
+
(except as stated in this section) patent license to make, have made,
|
|
79
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
80
|
+
where such license applies only to those patent claims licensable
|
|
81
|
+
by such Contributor that are necessarily infringed by their
|
|
82
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
83
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
84
|
+
institute patent litigation against any entity (including a
|
|
85
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
86
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
87
|
+
or contributory patent infringement, then any patent licenses
|
|
88
|
+
granted to You under this License for that Work shall terminate
|
|
89
|
+
as of the date such litigation is filed.
|
|
90
|
+
|
|
91
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
92
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
93
|
+
modifications, and in Source or Object form, provided that You
|
|
94
|
+
meet the following conditions:
|
|
95
|
+
|
|
96
|
+
(a) You must give any other recipients of the Work or
|
|
97
|
+
Derivative Works a copy of this License; and
|
|
98
|
+
|
|
99
|
+
(b) You must cause any modified files to carry prominent notices
|
|
100
|
+
stating that You changed the files; and
|
|
101
|
+
|
|
102
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
103
|
+
that You distribute, all copyright, patent, trademark, and
|
|
104
|
+
attribution notices from the Source form of the Work,
|
|
105
|
+
excluding those notices that do not pertain to any part of
|
|
106
|
+
the Derivative Works; and
|
|
107
|
+
|
|
108
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
109
|
+
distribution, then any Derivative Works that You distribute must
|
|
110
|
+
include a readable copy of the attribution notices contained
|
|
111
|
+
within such NOTICE file, excluding those notices that do not
|
|
112
|
+
pertain to any part of the Derivative Works, in at least one
|
|
113
|
+
of the following places: within a NOTICE text file distributed
|
|
114
|
+
as part of the Derivative Works; within the Source form or
|
|
115
|
+
documentation, if provided along with the Derivative Works; or,
|
|
116
|
+
within a display generated by the Derivative Works, if and
|
|
117
|
+
wherever such third-party notices normally appear. The contents
|
|
118
|
+
of the NOTICE file are for informational purposes only and
|
|
119
|
+
do not modify the License. You may add Your own attribution
|
|
120
|
+
notices within Derivative Works that You distribute, alongside
|
|
121
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
122
|
+
that such additional attribution notices cannot be construed
|
|
123
|
+
as modifying the License.
|
|
124
|
+
|
|
125
|
+
You may add Your own copyright statement to Your modifications and
|
|
126
|
+
may provide additional or different license terms and conditions
|
|
127
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
128
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
129
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
130
|
+
the conditions stated in this License.
|
|
131
|
+
|
|
132
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
133
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
134
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
135
|
+
this License, without any additional terms or conditions.
|
|
136
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
137
|
+
the terms of any separate license agreement you may have executed
|
|
138
|
+
with Licensor regarding such Contributions.
|
|
139
|
+
|
|
140
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
141
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
142
|
+
except as required for reasonable and customary use in describing the
|
|
143
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
144
|
+
|
|
145
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
146
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
147
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
148
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
149
|
+
implied, including, without limitation, any warranties or conditions
|
|
150
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
151
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
152
|
+
appropriateness of using or redistributing the Work and assume any
|
|
153
|
+
risks associated with Your exercise of permissions under this License.
|
|
154
|
+
|
|
155
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
156
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
157
|
+
unless required by applicable law (such as deliberate and grossly
|
|
158
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
159
|
+
liable to You for damages, including any direct, indirect, special,
|
|
160
|
+
incidental, or consequential damages of any character arising as a
|
|
161
|
+
result of this License or out of the use or inability to use the
|
|
162
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
163
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
164
|
+
other commercial damages or losses), even if such Contributor
|
|
165
|
+
has been advised of the possibility of such damages.
|
|
166
|
+
|
|
167
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
168
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
169
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
170
|
+
or other liability obligations and/or rights consistent with this
|
|
171
|
+
License. However, in accepting such obligations, You may act only
|
|
172
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
173
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
174
|
+
defend, and hold each Contributor harmless for any liability
|
|
175
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
176
|
+
of your accepting any such warranty or additional liability.
|
|
177
|
+
|
|
178
|
+
END OF TERMS AND CONDITIONS
|
|
179
|
+
|
|
180
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
181
|
+
|
|
182
|
+
To apply the Apache License to your work, attach the following
|
|
183
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
184
|
+
replaced with your own identifying information. (Don't include
|
|
185
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
186
|
+
comment syntax for the file format. We also recommend that a
|
|
187
|
+
file or class name and description of purpose be included on the
|
|
188
|
+
same "printed page" as the copyright notice for easier
|
|
189
|
+
identification within third-party archives.
|
|
190
|
+
|
|
191
|
+
Copyright 2026 Z.AI Co., Ltd
|
|
192
|
+
|
|
193
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
194
|
+
you may not use this file except in compliance with the License.
|
|
195
|
+
You may obtain a copy of the License at
|
|
196
|
+
|
|
197
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
198
|
+
|
|
199
|
+
Unless required by applicable law or agreed to in writing, software
|
|
200
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
201
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
202
|
+
See the License for the specific language governing permissions and
|
|
203
|
+
limitations under the License.
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
unbash@4.0.1
|
|
207
|
+
ISC License
|
|
208
|
+
|
|
209
|
+
Copyright (c) Lars Kappert
|
|
210
|
+
|
|
211
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
212
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
213
|
+
copyright notice and this permission notice appear in all copies.
|
|
214
|
+
|
|
215
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
216
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
217
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
218
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
219
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
220
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
221
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contract": "zcode-posix-readonly/v1",
|
|
3
|
+
"sha256": "4e30dda34d35e7533f2ea0cf1589fa04d65f04f86224b30e460e542c7df7788b",
|
|
4
|
+
"referenceCommit": "3c5b227649371507ddc4eb46ac5133afe6db1cab",
|
|
5
|
+
"sourceDigest": "3fe8242201637dc4c4a5cdcb0634462d9be5b99de6e830531bfc3b4f2303c5b4",
|
|
6
|
+
"adapterDigest": "6d0b81b7bd65bb52d2926359cfec518adb1747dac920d5a6ae3901d709cbff1f",
|
|
7
|
+
"syntaxContract": "unbash-4.0.1/v1",
|
|
8
|
+
"dependencies": [
|
|
9
|
+
{
|
|
10
|
+
"name": "unbash",
|
|
11
|
+
"version": "4.0.1",
|
|
12
|
+
"license": "ISC"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"bytes": 105393
|
|
16
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function Xn(o){switch(o){case",":return 1;case"=":case"+=":case"-=":case"*=":case"/=":case"%=":case"<<=":case">>=":case"&=":case"|=":case"^=":return 2;case"||":return 4;case"&&":return 5;case"|":return 6;case"^":return 7;case"&":return 8;case"==":case"!=":return 9;case"<":case"<=":case">":case">=":return 10;case"<<":case">>":return 11;case"+":case"-":return 12;case"*":case"/":case"%":return 13;case"**":return 14;default:return-1}}function Jn(o){switch(o){case"=":case"+=":case"-=":case"*=":case"/=":case"%=":case"<<=":case">>=":case"&=":case"|=":case"^=":case"**":return!0;default:return!1}}var Fe=null;function De(){let o=Fe;return Fe=null,o}function ue(o,e=0){Fe=null;let t=0,n=o.length;function s(){for(;t<n;){let m=o.charCodeAt(t);if(m===32||m===9||m===10)t++;else break}}function r(){if(t>=n)return null;let m=o.charCodeAt(t),p=t+1<n?o.charCodeAt(t+1):0,C=t+2<n?o.charCodeAt(t+2):0;switch(m){case 44:return t++,",";case 61:return p===61?(t+=2,"=="):(t++,"=");case 33:return p===61?(t+=2,"!="):null;case 60:return p===60?C===61?(t+=3,"<<="):(t+=2,"<<"):p===61?(t+=2,"<="):(t++,"<");case 62:return p===62?C===61?(t+=3,">>="):(t+=2,">>"):p===61?(t+=2,">="):(t++,">");case 43:return p===61?(t+=2,"+="):p===43?null:(t++,"+");case 45:return p===61?(t+=2,"-="):p===45?null:(t++,"-");case 42:return p===42?(t+=2,"**"):p===61?(t+=2,"*="):(t++,"*");case 47:return p===61?(t+=2,"/="):(t++,"/");case 37:return p===61?(t+=2,"%="):(t++,"%");case 124:return p===124?(t+=2,"||"):p===61?(t+=2,"|="):(t++,"|");case 38:return p===38?(t+=2,"&&"):p===61?(t+=2,"&="):(t++,"&");case 94:return p===61?(t+=2,"^="):(t++,"^");case 63:return t++,"?";default:return null}}function i(m){let p=a();for(;s(),!(t>=n);){let C=t,A=r();if(!A)break;if(A==="?"){if(3<m){t=C;break}let $e=i(1);s(),t<n&&o.charCodeAt(t)===58&&t++;let Ae=i(3);p={type:"ArithmeticTernary",pos:p.pos,end:Ae.end,test:p,consequent:$e,alternate:Ae};continue}let le=Xn(A);if(le<m){t=C;break}let ee=Jn(A)?le:le+1,M=i(ee);p={type:"ArithmeticBinary",pos:p.pos,end:M.end,operator:A,left:p,right:M}}return p}function a(){if(s(),t>=n)return{type:"ArithmeticWord",pos:t+e,end:t+e,value:""};let m=t,p=o.charCodeAt(t),C=t+1<n?o.charCodeAt(t+1):0;if(p===43&&C===43){t+=2;let A=a();return{type:"ArithmeticUnary",pos:m+e,end:A.end,operator:"++",operand:A,prefix:!0}}if(p===45&&C===45){t+=2;let A=a();return{type:"ArithmeticUnary",pos:m+e,end:A.end,operator:"--",operand:A,prefix:!0}}if(p===33){t++;let A=a();return{type:"ArithmeticUnary",pos:m+e,end:A.end,operator:"!",operand:A,prefix:!0}}if(p===126){t++;let A=a();return{type:"ArithmeticUnary",pos:m+e,end:A.end,operator:"~",operand:A,prefix:!0}}if(p===43&&C!==43&&C!==61){t++;let A=a();return{type:"ArithmeticUnary",pos:m+e,end:A.end,operator:"+",operand:A,prefix:!0}}if(p===45&&C!==45&&C!==61){t++;let A=a();return{type:"ArithmeticUnary",pos:m+e,end:A.end,operator:"-",operand:A,prefix:!0}}return c()}function c(){let m=h();if(s(),t+1<n){let p=o.charCodeAt(t),C=o.charCodeAt(t+1);if(p===43&&C===43)return t+=2,{type:"ArithmeticUnary",pos:m.pos,end:t+e,operator:"++",operand:m,prefix:!1};if(p===45&&C===45)return t+=2,{type:"ArithmeticUnary",pos:m.pos,end:t+e,operator:"--",operand:m,prefix:!1}}return m}function h(){if(s(),t>=n)return{type:"ArithmeticWord",pos:t+e,end:t+e,value:""};let m=o.charCodeAt(t);if(m===40){let p=t;t++;let C=i(0);return s(),t<n&&o.charCodeAt(t)===41&&t++,{type:"ArithmeticGroup",pos:p+e,end:t+e,expression:C}}return m===36?u():f()}function u(){let m=t;if(t++,t>=n)return{type:"ArithmeticWord",pos:m+e,end:t+e,value:"$"};let p=o.charCodeAt(t);if(p===40)if(t+1<n&&o.charCodeAt(t+1)===40){t+=2;let C=1;for(;t<n&&C>0;)o.charCodeAt(t)===40&&t+1<n&&o.charCodeAt(t+1)===40?(C++,t+=2):o.charCodeAt(t)===41&&t+1<n&&o.charCodeAt(t+1)===41?(C--,C>0,t+=2):t++}else{t++;let C=1;for(;t<n&&C>0;){let M=o.charCodeAt(t);M===40?C++:M===41&&C--,t++}let A=o.slice(m,t),le=A.slice(2,-1),ee={type:"ArithmeticCommandExpansion",pos:m+e,end:t+e,text:A,inner:le,script:void 0};return(Fe??=[]).push(ee),ee}else if(p===123){t++;let C=1;for(;t<n&&C>0;){let A=o.charCodeAt(t);A===123?C++:A===125&&C--,t++}}else for(;t<n;){let C=o.charCodeAt(t);if(C>=97&&C<=122||C>=65&&C<=90||C>=48&&C<=57||C===95)t++;else break}return{type:"ArithmeticWord",pos:m+e,end:t+e,value:o.slice(m,t)}}function f(){let m=t;for(;t<n;){let p=o.charCodeAt(t);if(p>=48&&p<=57||p>=65&&p<=90||p>=97&&p<=122||p===95||p===35)t++;else break}if(t>m&&t<n&&o.charCodeAt(t)===91){t++;let p=1;for(;t<n&&p>0;){let C=o.charCodeAt(t);C===91?p++:C===93&&p--,t++}}return t===m?(t++,{type:"ArithmeticWord",pos:m+e,end:t+e,value:o.slice(m,t)}):{type:"ArithmeticWord",pos:m+e,end:t+e,value:o.slice(m,t)}}if(s(),t>=n)return null;let g=i(0);return s(),g}function es(o){let e="";for(let t of o)e+=t.type==="Literal"?t.value:t.text;return e}var w=class o{static _resolveWord;static _resolveHeredocBody;text;pos;end;#e;#s;#t;#n=null;constructor(e,t,n,s,r){this.text=e,this.pos=t,this.end=n,this.#e=s??"",this.#s=r??o._resolveWord,this.#t=s!==void 0?null:void 0}get value(){if(this.#n===null){let e=this.parts;if(!e)this.#n=this.text;else{let t="";for(let n of e)switch(n.type){case"Literal":case"SingleQuoted":case"AnsiCQuoted":t+=n.value;break;case"DoubleQuoted":case"LocaleString":t+=es(n.parts);break;default:t+=n.text;break}this.#n=t}}return this.#n}get parts(){return this.#t===null&&(this.#t=this.#s(this.#e,this)??void 0),this.#t}set parts(e){this.#t=e??void 0}toJSON(){return{text:this.text,pos:this.pos,end:this.end,parts:this.parts,value:this.value}}};var l={Word:0,Assignment:1,Semi:2,Newline:3,Pipe:4,And:5,Or:6,Amp:7,LParen:8,RParen:9,LBrace:10,RBrace:11,Bang:12,If:13,Then:14,Else:15,Elif:16,Fi:17,Do:18,Done:19,For:20,While:21,Until:22,In:23,Case:24,Esac:25,Function:26,DoubleSemi:27,SemiAmp:28,DoubleSemiAmp:29,Select:30,DblLBracket:31,DblRBracket:32,EOF:33,ArithCmd:34,Coproc:35,Redirect:36},Pe=class{token=l.EOF;value="";pos=0;end=0;fileDescriptor=void 0;variableName=void 0;content=void 0;targetPos=0;targetEnd=0;reset(){this.token=l.EOF,this.value="",this.pos=0,this.end=0,this.fileDescriptor=void 0,this.variableName=void 0,this.content=void 0,this.targetPos=0,this.targetEnd=0}copyFrom(e){this.token=e.token,this.value=e.value,this.pos=e.pos,this.end=e.end,this.fileDescriptor=e.fileDescriptor,this.variableName=e.variableName,this.content=e.content,this.targetPos=e.targetPos,this.targetEnd=e.targetEnd}},_t={if:l.If,then:l.Then,else:l.Else,elif:l.Elif,fi:l.Fi,do:l.Do,done:l.Done,for:l.For,while:l.While,until:l.Until,in:l.In,case:l.Case,esac:l.Esac,function:l.Function,select:l.Select,coproc:l.Coproc,"!":l.Bang,"{":l.LBrace,"}":l.RBrace},_=new Uint8Array(128);_[124]=1;_[38]=1;_[59]=1;_[40]=1;_[41]=1;_[60]=1;_[62]=1;_[32]=1;_[9]=1;_[10]=1;_[92]=2;_[39]=2;_[34]=2;_[36]=2;_[96]=2;_[123]=2;function St(o,e){let t=0;for(let n=0;n<o.length;n++){let s=o.charCodeAt(n);if(s===92){n++;continue}if(s===123){t++;continue}if(s===125){t>0&&t--;continue}if(s===39){for(n++;n<o.length&&o.charCodeAt(n)!==39;)n++;continue}if(s===34){for(n++;n<o.length&&o.charCodeAt(n)!==34;)o.charCodeAt(n)===92&&n++,n++;continue}if(s===e&&t===0)return n}return-1}var oe=new Uint8Array(128);for(let o=97;o<=122;o++)oe[o]=3;for(let o=65;o<=90;o++)oe[o]=3;for(let o=48;o<=57;o++)oe[o]=2;oe[95]=3;var re=new Uint8Array(128);re[63]=1;re[64]=1;re[42]=1;re[43]=1;re[33]=1;re[61]=1;var ts={63:"?",64:"@",42:"*",43:"+",33:"!"};function yt(o){let e=o.type;return e==="Literal"||e==="SimpleExpansion"||e==="ParameterExpansion"||e==="CommandExpansion"||e==="ArithmeticExpansion"}function ns(o){for(let e=0;e<o.length;e++){let t=o.charCodeAt(e);if(t<48||t>57)return!1}return o.length>0}function ss(o){let e=o.indexOf("=");if(e<=0)return!1;let t=o.charCodeAt(0);if(t>=128||!(oe[t]&1))return!1;let n=1;for(;n<e&&(t=o.charCodeAt(n),!(t>=128||!(oe[t]&2)));n++);if(n===e||t===43&&n+1===e)return!0;if(t===91){let s=o.indexOf("]",n+1);if(s>n&&(s+1===e||o.charCodeAt(s+1)===43&&s+2===e))return!0}return!1}function y(o,e,t,n=0,s=0){o.token=e,o.value=t,o.pos=n,o.end=s,o.fileDescriptor=void 0,o.variableName=void 0,o.content=void 0}var d={Normal:0,CommandStart:1,TestMode:2};function os(o,e,t){let n=e+1<t?o.charCodeAt(e+1):0;if(n<=32||n===125)return-1;let s=1,r=!1,i=e+1;for(;i<t&&s>0;){let a=o.charCodeAt(i);if(a===123)s++;else if(a===125){if(--s===0)break}else{if(a<=32||a===59||a===124||a===38)return-1;s===1&&(a===44||a===46&&i+1<t&&o.charCodeAt(i+1)===46)&&(r=!0)}a===92&&i++,i++}return s===0&&r?i+1:-1}var ie=class{src;srcEnd;pos;current;nextState;hasPeek;pendingHereDocs;collectedExpansions;_errors=null;_buildParts=!1;constructor(e,t=0,n=e.length){if(this.src=e,this.srcEnd=n,this.pos=t,this.current=new Pe,this.nextState=new Pe,this.hasPeek=!1,this.pendingHereDocs=[],this.collectedExpansions=[],t===0&&e.charCodeAt(0)===35&&e.charCodeAt(1)===33){let s=e.indexOf(`
|
|
2
|
+
`);this.pos=s===-1?this.srcEnd:s+1}}getSource(){return this.src}get errors(){return this._errors??(this._errors=[])}getCollectedExpansions(){return this.collectedExpansions}getPos(){return this.pos}buildWordParts(e){this._buildParts=!0,this.pos=e;let t=this.src.charCodeAt(e);if((t===60||t===62)&&e+1<this.srcEnd&&this.src.charCodeAt(e+1)===40){this.pos=e+2;let n=this.extractBalanced(),r={type:"ProcessSubstitution",text:this.src.slice(e,this.pos),operator:t===60?"<":">",script:void 0,inner:n??void 0,innerStart:e+2};this.collectedExpansions.push(r),this.pos<this.srcEnd?(this.readWordText(),this._wordParts?this._wordParts.unshift(r):this._wordParts=[r]):this._wordParts=[r]}else this.readWordText();return this._wordParts}buildHereDocParts(e,t){this._buildParts=!0;let n=this.src,s=[],r="",i=e,a=e,c=()=>{r&&(s.push({type:"Literal",value:r,text:n.slice(i,a)}),r="")};for(;a<t;){let h=n.charCodeAt(a);if(h===92){if(a+1<t){let u=n.charCodeAt(a+1);if(u===36||u===96||u===92){r+=String.fromCharCode(u),a+=2;continue}}r+="\\",a++;continue}if(h===36){c(),i=a,this.pos=a,this.readDollar(),this._resultPart?(s.push(this._resultPart),i=this.pos):r+=n.slice(a,this.pos),a=this.pos;continue}if(h===96){c(),i=a,this.pos=a,this.readBacktickExpansion(),this._resultPart?(s.push(this._resultPart),i=this.pos):r+=n.slice(a,this.pos),a=this.pos;continue}r+=n[a],a++}return c(),s.length>1||s.length===1&&s[0].type!=="Literal"?s:null}registerHereDocTarget(e){for(let t of this.pendingHereDocs)if(!t.target){t.target=e;return}}readTestRegexWord(){this.hasPeek=!1;let e=[40,41,124,60,62],t=e.map(n=>_[n]);for(let n of e)_[n]=0;try{return this.skipSpacesAndTabs(),this.readWord(this.current,d.Normal,this.pos),this.current}finally{for(let n=0;n<e.length;n++)_[e[n]]=t[n]}}readCStyleForExprs(){this.hasPeek=!1;let e=this.src,t=this.srcEnd;for(;this.pos<t&&(e.charCodeAt(this.pos)===32||e.charCodeAt(this.pos)===9);)this.pos++;this.pos<t&&e.charCodeAt(this.pos)===40&&this.pos++;let n=[this.pos,0,0],s=["","","",0,0,0],r=0,i=1,a=this.pos;for(;this.pos<t&&i>0;){let c=e.charCodeAt(this.pos);if(c===40)i++,this.pos++;else if(c===41){if(i--,i===0){let h=e.slice(a,this.pos);for(s[r]=h.trim(),s[3+r]=n[r]+h.length-h.trimStart().length,this.pos++;this.pos<t&&(e.charCodeAt(this.pos)===32||e.charCodeAt(this.pos)===9);)this.pos++;this.pos<t&&e.charCodeAt(this.pos)===41&&this.pos++;break}this.pos++}else if(c===59&&i===1){let h=e.slice(a,this.pos);s[r]=h.trim(),s[3+r]=n[r]+h.length-h.trimStart().length,r<2&&r++,this.pos++,a=this.pos,n[r]=a}else c===39?(this.pos++,this.skipSQ()):c===34?(this.pos++,this.skipDQ()):this.pos++}return s}peek(e=d.Normal){return this.hasPeek||(this.readNext(this.nextState,e),this.hasPeek=!0),this.nextState}next(e=d.Normal){if(this.hasPeek){this.hasPeek=!1;let t=this.current;return this.current=this.nextState,this.nextState=t,this.current}return this.readNext(this.current,e),this.current}unshift(e){this.nextState.copyFrom(e),this.hasPeek=!0}readNext(e,t){let n=this.src,s=this.srcEnd,r=this.pos;for(;r<s;){let c=n.charCodeAt(r);if(c===32||c===9){r++;continue}if(c===92&&r+1<s&&n.charCodeAt(r+1)===10){r+=2;continue}if(c===10&&t===d.TestMode){r++;continue}break}if(this.pos=r,r>=s){y(e,l.EOF,"",r,r);return}let i=r,a=n.charCodeAt(r);if(a===35){for(;this.pos<s&&n.charCodeAt(this.pos)!==10;)this.pos++;this.readNext(e,t);return}if(a===10){this.pos++,this.consumePendingHereDocs(),y(e,l.Newline,`
|
|
3
|
+
`,i,this.pos);return}if(t===d.TestMode&&(a===60||a===62)){this.pos++,y(e,l.Word,a===60?"<":">",i,this.pos);return}this.tryReadOperator(e,a,t,i)||this.readWord(e,t,i)}tryReadOperator(e,t,n,s){let r=this.src,i=this.pos,a=i+1<this.srcEnd?r.charCodeAt(i+1):0;switch(t){case 59:return a===59?i+2<this.srcEnd&&r.charCodeAt(i+2)===38?(this.pos+=3,y(e,l.DoubleSemiAmp,";;&",s,this.pos),!0):(this.pos+=2,y(e,l.DoubleSemi,";;",s,this.pos),!0):a===38?(this.pos+=2,y(e,l.SemiAmp,";&",s,this.pos),!0):(this.pos++,y(e,l.Semi,";",s,this.pos),!0);case 124:return a===124?(this.pos+=2,y(e,l.Or,"||",s,this.pos),!0):a===38?(this.pos+=2,y(e,l.Pipe,"|&",s,this.pos),!0):(this.pos++,y(e,l.Pipe,"|",s,this.pos),!0);case 38:if(a===38)return this.pos+=2,y(e,l.And,"&&",s,this.pos),!0;if(a===62){this.pos+=2;let c=this.pos<this.srcEnd&&r.charCodeAt(this.pos)===62;return c&&this.pos++,this.skipSpacesAndTabs(),this._redirectTargetPos=this.pos,this.pos<this.srcEnd&&r.charCodeAt(this.pos)!==10&&this.readWordText(),this.redirectToken(e,c?"&>>":"&>",s),!0}return this.pos++,y(e,l.Amp,"&",s,this.pos),!0;case 40:return n===d.CommandStart&&a===40?(this.readArithmeticCommand(e,s),!0):(this.pos++,y(e,l.LParen,"(",s,this.pos),!0);case 41:return this.pos++,y(e,l.RParen,")",s,this.pos),!0;case 60:case 62:return this.readRedirection(e,s);default:return!1}}readRedirection(e,t){let n=this.src,s=n.charCodeAt(this.pos),r="";if(s===60){this.pos++;let i=this.pos<this.srcEnd?n.charCodeAt(this.pos):0;if(i===60){this.pos++;let a=this.pos<this.srcEnd?n.charCodeAt(this.pos):0;if(a===60)return this.pos++,this.skipSpacesAndTabs(),this._redirectTargetPos=this.pos,this.pos<this.srcEnd&&n.charCodeAt(this.pos)!==10&&this.readWordText(),this.redirectToken(e,"<<<",t),!0;let c=a===45;return c&&this.pos++,this.skipSpacesAndTabs(),this.readHereDocDelimiter(),this.pendingHereDocs.push({delimiter:this._hereDelim,strip:c,quoted:this._hereQuoted}),y(e,l.Redirect,c?"<<-":"<<",t,this.pos),e.content=this._hereDelim,!0}if(i===40)return this.readProcessSubstitution(e,"<",t),!0;i===62?(r="<>",this.pos++):i===38?(r="<&",this.pos++):r="<"}else if(s===62){this.pos++;let i=this.pos<this.srcEnd?n.charCodeAt(this.pos):0;if(i===40)return this.readProcessSubstitution(e,">",t),!0;i===62?(r=">>",this.pos++):i===38?(r=">&",this.pos++):i===124?(r=">|",this.pos++):r=">"}if(this.skipSpacesAndTabs(),this.pos<this.srcEnd){let i=n.charCodeAt(this.pos);if((i===60||i===62)&&this.pos+1<this.srcEnd&&n.charCodeAt(this.pos+1)===40){let a=this.pos;this.pos+=2,this.extractBalanced();let c=n.slice(a,this.pos);return y(e,l.Redirect,r,t,this.pos),e.content=c,e.targetPos=a,e.targetEnd=this.pos,!0}this._redirectTargetPos=this.pos,i!==10&&this.readWordText()}return this.redirectToken(e,r,t),!0}redirectToken(e,t,n){y(e,l.Redirect,t,n,this.pos),e.content=this._wordText,e.targetPos=this._redirectTargetPos,e.targetEnd=this.pos}readProcessSubstitution(e,t,n){this.pos++,this.extractBalanced();let s=this.src.slice(n,this.pos);y(e,l.Word,s,n,this.pos)}readHereDocDelimiter(){let e=this.src,t=this.srcEnd,n="";if(this.pos<t&&e.charCodeAt(this.pos)===39){this.pos++;let s=this.pos;for(;this.pos<t&&e.charCodeAt(this.pos)!==39;)this.pos++;n=e.slice(s,this.pos),this.pos<t&&this.pos++,this._hereDelim=n,this._hereQuoted=!0;return}else if(this.pos<t&&e.charCodeAt(this.pos)===34){for(this.pos++;this.pos<t&&e.charCodeAt(this.pos)!==34;)e.charCodeAt(this.pos)===92&&this.pos++,n+=e[this.pos],this.pos++;this.pos<t&&this.pos++,this._hereDelim=n,this._hereQuoted=!0;return}else if(this.pos<t&&e.charCodeAt(this.pos)===92){for(;this.pos<t;){let s=e.charCodeAt(this.pos);if(s<128&&_[s]&1)break;s===92&&this.pos++,this.pos<t&&(n+=e[this.pos],this.pos++)}this._hereDelim=n,this._hereQuoted=!0;return}else{let s=this.pos;for(;this.pos<t;){let r=e.charCodeAt(this.pos);if(r<128&&_[r]&1)break;this.pos++}this._hereDelim=e.slice(s,this.pos),this._hereQuoted=!1}}consumePendingHereDocs(){for(let e of this.pendingHereDocs){let t=this.pos,n=this.readHereDocBody(e.delimiter,e.strip);if(e.target){if(e.target.content=n,e.quoted)e.target.heredocQuoted=!0;else if(n){let s=this.parseHereDocBody(n,t);s&&(e.target.body=s)}}}this.pendingHereDocs.length=0}readHereDocBody(e,t){let n=this.src,s=this.srcEnd,r=e.length,i=this.pos;for(;this.pos<s;){let a=this.pos,c=n.indexOf(`
|
|
4
|
+
`,this.pos);if(c===-1&&(c=s),t)for(;a<c&&n.charCodeAt(a)===9;)a++;if(c-a===r&&n.startsWith(e,a)){let h=n.slice(i,this.pos);return this.pos=c<s?c+1:c,h}this.pos=c<s?c+1:c}return n.slice(i,this.pos)}parseHereDocBody(e,t){let n=!1;for(let s=0;s<e.length;s++){let r=e.charCodeAt(s);if(r===96){n=!0;break}if(r===36){let i=s+1<e.length?e.charCodeAt(s+1):0;if(i===123||i===40||i===36||i>=97&&i<=122||i>=65&&i<=90||i===95||i===33||i===35||i===64||i===42||i===63||i===45||i>=48&&i<=57){n=!0;break}}r===92&&s++}return n?new w(e,t,t+e.length,this.src,w._resolveHeredocBody):null}_wordText="";_wordQuoted=!1;_wordHasExpansions=!1;_wordParts=null;_redirectTargetPos=0;_resultText="";_resultHasExpansion=!1;_resultPart;_dqText="";_dqHasExpansions=!1;_dqParts=null;_hereDelim="";_hereQuoted=!1;readWord(e,t,n=0){this.readWordText();let s=this._wordText,r=this._wordHasExpansions,i=this._wordQuoted,a=this.pos;if(t===d.CommandStart){if(!r&&!i){let c=s.charCodeAt(0);if((c>=97&&c<=122&&s.length<=8||c===33||c===123||c===125)&&s in _t){y(e,_t[s],s,n,a);return}if(c===91&&s==="[["){y(e,l.DblLBracket,s,n,a);return}}if(ss(s)){y(e,l.Assignment,s,n,a);return}}if(!r&&!i&&s==="]]"){y(e,l.DblRBracket,s,n,a);return}if(!r&&this.pos<this.srcEnd){let c=this.src.charCodeAt(this.pos);if(c===60||c===62){if(s.charCodeAt(0)>=48&&s.charCodeAt(0)<=57&&ns(s)){let h=Number.parseInt(s,10);if(this.readRedirection(e,n)){e.fileDescriptor=h;return}}if(s.charCodeAt(0)===123&&s.charCodeAt(s.length-1)===125&&s.length>2){let h=s.slice(1,-1);if(this.readRedirection(e,n)){e.variableName=h;return}}}}y(e,l.Word,s,n,a)}readWordText(){let e=this.src,t=this.srcEnd,n=this.pos,s=n;for(;n<t;){let m=e.charCodeAt(n);if(m<128&&_[m])break;n++}let r=n<t?e.charCodeAt(n):0;if(n>=t||_[r]&1&&!(r===40&&n>s&&re[e.charCodeAt(n-1)])){this.pos=n,this._wordText=n>s?e.slice(s,n):"",this._wordQuoted=!1,this._wordHasExpansions=!1,this._buildParts&&(this._wordParts=null);return}let i=n>s?e.slice(s,n):"",a=!1,c=!1,h=this._buildParts,u,f="",g=0;for(h&&(u=[],f=i,g=s);n<t;){let m=e.charCodeAt(n);if(m>=128||!_[m]){let p=n;for(n++;n<t;){let A=e.charCodeAt(n);if(A<128&&_[A])break;n++}let C=e.slice(p,n);i+=C,h&&(f+=C);continue}if(_[m]&1){if(m===40&&i.length>0&&re[i.charCodeAt(i.length-1)]){let p=i.charCodeAt(i.length-1);n++;let C=n,A=1;for(;n<t&&A>0;){let M=e.charCodeAt(n);M===40?A++:M===41&&A--,n++}let le=e.slice(C,n-1),ee="("+e.slice(C,n);if(i+=ee,h&&p!==61){if(f.length>0){let Ae=f.slice(0,-1);Ae&&u.push({type:"Literal",value:Ae,text:e.slice(g,C-2)}),f=""}let M=ts[p],$e=M+ee;u.push({type:"ExtendedGlob",text:$e,operator:M,pattern:le}),g=n}else h&&(f+=ee);continue}break}if(m===92){if(n++,n<t)if(e.charCodeAt(n)===10)n++;else{a=!0;let p=e[n++];i+=p,h&&(f+=p)}continue}if(m===39){let p=n;a=!0,n++;let C=n;for(;n<t&&e.charCodeAt(n)!==39;)n++;let A=e.slice(C,n);i+=A,n<t?n++:this.errors.push({message:"unterminated single quote",pos:C-1}),h&&(f&&(u.push({type:"Literal",value:f,text:e.slice(g,p)}),f=""),u.push({type:"SingleQuoted",value:A,text:e.slice(p,n)}),g=n);continue}if(m===34){let p=n;if(a=!0,n++,this.pos=n,this.readDoubleQuoted(),n=this.pos,i+=this._dqText,this._dqHasExpansions&&(c=!0),h){f&&(u.push({type:"Literal",value:f,text:e.slice(g,p)}),f="");let C=e.slice(p,n);u.push({type:"DoubleQuoted",text:C,parts:this._dqParts??[{type:"Literal",value:this._dqText,text:e.slice(p+1,n-1)}]}),g=n}continue}if(m===36){let p=n;this.pos=n,this.readDollar(),n=this.pos,i+=this._resultText,this._resultHasExpansion&&(c=!0),h&&(this._resultPart?(f&&(u.push({type:"Literal",value:f,text:e.slice(g,p)}),f=""),u.push(this._resultPart),g=n):f+=this._resultText);continue}if(m===96){let p=n;this.pos=n,this.readBacktickExpansion(),n=this.pos,i+=this._resultText,c=!0,h&&(f&&(u.push({type:"Literal",value:f,text:e.slice(g,p)}),f=""),u.push(this._resultPart),g=n);continue}if(m===123){let p=os(e,n,t);if(p>0){let C=e.slice(n,p);i+=C,h&&(f&&(u.push({type:"Literal",value:f,text:e.slice(g,n)}),f=""),u.push({type:"BraceExpansion",text:C}),g=p),n=p;continue}i+="{",h&&(f+="{"),n++;continue}n++}h&&f&&u.push({type:"Literal",value:f,text:e.slice(g,n)}),this.pos=n,this._wordText=i,this._wordQuoted=a,this._wordHasExpansions=c,h&&(this._wordParts=u.length>1||u.length===1&&u[0].type!=="Literal"?u:null)}readInnerWordText(){let e=this.src,t=this.srcEnd,n=this.pos,s="",r=this._buildParts,i,a="",c=0;for(r&&(i=[],c=n);n<t;){let h=e.charCodeAt(n);if(h===92){if(n++,n<t)if(e.charCodeAt(n)===10)n++;else{let u=e[n++];s+=u,r&&(a+=u)}continue}if(h===39){let u=n;n++;let f=n;for(;n<t&&e.charCodeAt(n)!==39;)n++;let g=e.slice(f,n);s+=g,n<t&&n++,r&&(a&&(i.push({type:"Literal",value:a,text:e.slice(c,u)}),a=""),i.push({type:"SingleQuoted",value:g,text:e.slice(u,n)}),c=n);continue}if(h===34){let u=n;if(n++,this.pos=n,this.readDoubleQuoted(),n=this.pos,s+=this._dqText,r){a&&(i.push({type:"Literal",value:a,text:e.slice(c,u)}),a="");let f=e.slice(u,n);i.push({type:"DoubleQuoted",text:f,parts:this._dqParts??[{type:"Literal",value:this._dqText,text:e.slice(u+1,n-1)}]}),c=n}continue}if(h===36){let u=n;this.pos=n,this.readDollar(),n=this.pos,s+=this._resultText,r&&(this._resultPart?(a&&(i.push({type:"Literal",value:a,text:e.slice(c,u)}),a=""),i.push(this._resultPart),c=n):a+=this._resultText);continue}if(h===96){let u=n;this.pos=n,this.readBacktickExpansion(),n=this.pos,s+=this._resultText,r&&(a&&(i.push({type:"Literal",value:a,text:e.slice(c,u)}),a=""),i.push(this._resultPart),c=n);continue}s+=e[n],r&&(a+=e[n]),n++}r&&a&&i.push({type:"Literal",value:a,text:e.slice(c,n)}),this.pos=n,this._wordText=s,this._wordQuoted=!1,this._wordHasExpansions=!1,r&&(this._wordParts=i.length>1||i.length===1&&i[0].type!=="Literal"?i:null)}parseSubFieldWord(e,t){if(e>=t)return new w("",e,e);let n=this.srcEnd,s=this.pos,r=this._wordText,i=this._wordParts,a=this._wordQuoted;this.srcEnd=t,this.pos=e,this.readInnerWordText();let c=new w(this.src.slice(e,t),e,t);return this._buildParts&&this._wordParts&&(c.parts=this._wordParts),this.srcEnd=n,this.pos=s,this._wordText=r,this._wordParts=i,this._wordQuoted=a,c}skipSQ(){for(;this.pos<this.srcEnd&&this.src.charCodeAt(this.pos)!==39;)this.pos++;this.pos<this.srcEnd&&this.pos++}skipDQ(){let e=this.src,t=this.srcEnd;for(;this.pos<t;){let n=e.charCodeAt(this.pos);if(n===34){this.pos++;return}if(n===92){this.pos+=2;continue}if(n===36&&this.pos+1<t){let s=e.charCodeAt(this.pos+1);if(s===40){this.pos+=2,this.extractBalanced();continue}if(s===123){this.pos+=2;let r=1;for(;this.pos<t&&r>0;){let i=e.charCodeAt(this.pos);if(i===125){if(--r===0){this.pos++;break}}else if(i===123&&this.pos>0&&e.charCodeAt(this.pos-1)===36)r++;else if(i===92)this.pos++;else if(i===39){this.pos++,this.skipSQ();continue}else if(i===34){this.pos++,this.skipDQ();continue}this.pos++}continue}}if(n===96){for(this.pos++;this.pos<t&&e.charCodeAt(this.pos)!==96;)e.charCodeAt(this.pos)===92&&this.pos++,this.pos++;this.pos<t&&this.pos++;continue}this.pos++}}skipSpacesAndTabs(){let e=this.src,t=this.srcEnd;for(;this.pos<t;){let n=e.charCodeAt(this.pos);if(n===32||n===9)this.pos++;else if(n===92&&this.pos+1<t&&e.charCodeAt(this.pos+1)===10)this.pos+=2;else break}}readDoubleQuoted(){let e=this.src,t=this.srcEnd,n=this.pos,s=!1,r=this._buildParts;if(!r){let u=this.pos;for(;u<t;){let f=e.charCodeAt(u);if(f===34){this._dqText=e.slice(n,u),this.pos=u+1,this._dqHasExpansions=!1,this._dqParts=null;return}if(f===36||f===96||f===92)break;u++}}let i="",a=null,c="",h=r?this.pos:0;for(;this.pos<t&&e.charCodeAt(this.pos)!==34;){let u=this.pos;for(;this.pos<t;){let g=e.charCodeAt(this.pos);if(g===34||g===92||g===36||g===96)break;this.pos++}if(this.pos>u){let g=e.slice(u,this.pos);i+=g,r&&(c+=g)}if(this.pos>=t||e.charCodeAt(this.pos)===34)break;let f=e.charCodeAt(this.pos);if(f===92){if(this.pos++,this.pos<t){let g=e.charCodeAt(this.pos);if(g===10){this.pos++;continue}if(g===36||g===96||g===34||g===92){let m=e[this.pos];i+=m,r&&(c+=m)}else{let m="\\"+e[this.pos];i+=m,r&&(c+=m)}this.pos++}continue}if(f===36){if(this.pos+1<t&&e.charCodeAt(this.pos+1)===34){i+="$",r&&(c+="$"),this.pos++;continue}let g=this.pos;if(this.readDollar(),i+=this._resultText,this._resultHasExpansion&&(s=!0),r){let m=this._resultPart;m&&yt(m)?(a||(a=[]),c&&(a.push({type:"Literal",value:c,text:e.slice(h,g)}),c=""),a.push(m),h=this.pos):c+=this._resultText}continue}if(f===96){let g=this.pos;this.readBacktickExpansion(),i+=this._resultText,s=!0,r&&this._resultPart&&yt(this._resultPart)&&(a||(a=[]),c&&(a.push({type:"Literal",value:c,text:e.slice(h,g)}),c=""),a.push(this._resultPart),h=this.pos);continue}}r&&a&&c&&a.push({type:"Literal",value:c,text:e.slice(h,this.pos)}),this.pos<t?this.pos++:this.errors.push({message:"unterminated double quote",pos:n-1}),this._dqText=i,this._dqHasExpansions=s,this._dqParts=a}readDollar(){let e=this.pos;this.pos++;let t=this.src,n=this.srcEnd;if(this.pos>=n){this._resultText="$",this._resultHasExpansion=!1,this._resultPart=void 0;return}let s=t.charCodeAt(this.pos);if(s===40){if(this.pos+1<n&&t.charCodeAt(this.pos+1)===40){this.readArithmeticExpansion();return}this.readCommandSubstitution();return}if(s===123){let r=this.pos+1<n?t.charCodeAt(this.pos+1):0;if(r===32||r===9||r===10){this.readBraceCommandSubstitution();return}if(r===124){this.readValueSubstitution();return}this.readParameterExpansion();return}if(s===39){this.pos++;let r=this.readAnsiCQuoted();this._resultText=r,this._resultHasExpansion=!1,this._resultPart=this._buildParts?{type:"AnsiCQuoted",text:t.slice(e,this.pos),value:r}:void 0;return}if(s===34){if(this.pos++,this.readDoubleQuoted(),this._resultText=this._dqText,this._resultHasExpansion=this._dqHasExpansions,this._buildParts){let r=t.slice(e,this.pos);this._resultPart={type:"LocaleString",text:r,parts:this._dqParts??[{type:"Literal",value:this._dqText,text:t.slice(e+2,this.pos-1)}]}}else this._resultPart=void 0;return}if(s===64||s===42||s===35||s===63||s===45||s===36||s===33){this.pos++;let r=t.slice(this.pos-2,this.pos);this._resultText=r,this._resultHasExpansion=!1,this._resultPart=this._buildParts?{type:"SimpleExpansion",text:r}:void 0;return}if(s>=48&&s<=57){this.pos++;let r=t.slice(this.pos-2,this.pos);this._resultText=r,this._resultHasExpansion=!1,this._resultPart=this._buildParts?{type:"SimpleExpansion",text:r}:void 0;return}if(s<128&&oe[s]&1){let r=this.pos-1;for(;this.pos<n;){let a=t.charCodeAt(this.pos);if(a<128&&oe[a]&2)this.pos++;else break}let i=t.slice(r,this.pos);this._resultText=i,this._resultHasExpansion=!1,this._resultPart=this._buildParts?{type:"SimpleExpansion",text:i}:void 0;return}this._resultText="$",this._resultHasExpansion=!1,this._resultPart=void 0}scanArithmeticBody(){this.pos+=2;let e=1,t=this.src,n=this.srcEnd,s=this.pos;for(;this.pos<n&&e>0;){let r=t.charCodeAt(this.pos);if(r===40&&this.pos+1<n&&t.charCodeAt(this.pos+1)===40)e++,this.pos+=2;else if(r===41&&this.pos+1<n&&t.charCodeAt(this.pos+1)===41){if(--e===0){this.pos+=2;break}this.pos+=2}else this.pos++}return t.slice(s,this.pos-2)}readArithmeticExpansion(){let e=this.pos+2,t=this.scanArithmeticBody(),n="$(("+t+"))";if(this._resultText=n,this._resultHasExpansion=!1,this._buildParts){let s=ue(t,e)??void 0,r=De();if(r)for(let i of r)i.innerStart=i.pos+2,this.collectedExpansions.push(i);this._resultPart={type:"ArithmeticExpansion",text:n,expression:s}}else this._resultPart=void 0}readArithmeticCommand(e,t){let n=this.scanArithmeticBody();y(e,l.ArithCmd,n,t,this.pos)}readCommandSubstitution(){let e=this.pos-1;this.pos++,this.extractBalanced();let t=this.src.slice(e,this.pos);if(this._resultText=t,this._resultHasExpansion=!0,this._buildParts){let n=t.slice(2,-1);this._resultPart={type:"CommandExpansion",text:t,script:void 0,inner:n,innerStart:e+2},this.collectedExpansions.push(this._resultPart)}else this._resultPart=void 0}readBraceCommandSubstitution(){this.readBraceSubstitution("${ ",1)}readValueSubstitution(){this.readBraceSubstitution("${| ",2)}readBraceSubstitution(e,t){this.pos+=t;let n=this.src,s=this.srcEnd,r=1,i=this.pos;for(;this.pos<s;){let u=n.charCodeAt(this.pos);if(u===123)r++;else if(u===125){if(--r===0){this.pos++;break}}else if(u===39){this.pos++,this.skipSQ();continue}else if(u===34){this.pos++,this.skipDQ();continue}else u===92&&this.pos++;this.pos++}let a=n.slice(i,this.pos-1),c=a.trim(),h=e+c+" }";if(this._resultText=h,this._resultHasExpansion=!0,this._buildParts){let u=i+(a.length-a.trimStart().length);this._resultPart={type:"CommandExpansion",text:h,script:void 0,inner:c,innerStart:u},this.collectedExpansions.push(this._resultPart)}else this._resultPart=void 0}readBacktickExpansion(){this.pos++;let e=this.src,t=this.srcEnd,n="",s=this.pos,r=!1;for(;this.pos<t&&e.charCodeAt(this.pos)!==96;){if(e.charCodeAt(this.pos)===92){r=!0;break}this.pos++}if(!r)n=e.slice(s,this.pos);else for(n=e.slice(s,this.pos);this.pos<t&&e.charCodeAt(this.pos)!==96;)if(e.charCodeAt(this.pos)===92){if(this.pos++,this.pos<t){let a=e.charCodeAt(this.pos);a===36||a===96||a===92?n+=e[this.pos]:n+="\\"+e[this.pos],this.pos++}}else{let a=this.pos;for(;this.pos<t;){let c=e.charCodeAt(this.pos);if(c===96||c===92)break;this.pos++}n+=e.slice(a,this.pos)}this.pos<t?this.pos++:this.errors.push({message:"unterminated backtick",pos:s-1});let i=e.slice(s-1,this.pos);this._resultText=n,this._resultHasExpansion=!0,this._buildParts?(this._resultPart={type:"CommandExpansion",text:i,script:void 0,inner:n,innerStart:r?void 0:s},this.collectedExpansions.push(this._resultPart)):this._resultPart=void 0}readParameterExpansion(){let e=this.src,t=this.srcEnd,n=this.pos;this.pos++;let s=1;for(;this.pos<t&&s>0;){let i=e.charCodeAt(this.pos);if(i===123&&this.pos>0&&e.charCodeAt(this.pos-1)===36)s++;else if(i===125){if(--s===0){this.pos++;break}}else if(i===92)this.pos++;else if(i===39){this.pos++,this.skipSQ();continue}else if(i===34){this.pos++,this.skipDQ();continue}this.pos++}let r=e.slice(n-1,this.pos);if(this._resultText=r,this._resultHasExpansion=!1,this._buildParts){let i=e.slice(n+1,this.pos-1);this._resultPart=this.parseParamInner(r,i,n+1)}else this._resultPart=void 0}parseParamInner(e,t,n){let s={type:"ParameterExpansion",text:e,parameter:"",index:void 0,indirect:void 0,length:void 0,operator:void 0,operand:void 0,slice:void 0,replace:void 0},r=t.length;if(r===0)return s;let i=(h,u)=>this.parseSubFieldWord(n+h,n+u),a=0;if(t.charCodeAt(0)===33&&(s.indirect=!0,a=1),!s.indirect&&t.charCodeAt(0)===35){if(r===1)return s.parameter="#",s;if(t.charCodeAt(1)===35)s.parameter="#",a=1;else{let h=this.scanParamName(t,1);if(h>1){let u=h;if(u<r&&t.charCodeAt(u)===91){let f=this.findCloseBracket(t,u+1);f!==-1&&(u=f+1)}if(u>=r){if(s.length=!0,s.parameter=t.slice(1,h),h<r&&t.charCodeAt(h)===91){let f=this.findCloseBracket(t,h+1);f!==-1&&(s.index=t.slice(h+1,f))}return s}}s.parameter="#",a=1}}if(!s.parameter){let h=a;a=this.scanParamName(t,a),s.parameter=t.slice(h,a)}if(a<r&&t.charCodeAt(a)===91){let h=this.findCloseBracket(t,a+1);h!==-1&&(s.index=t.slice(a+1,h),a=h+1)}if(a>=r)return s;let c=t.charCodeAt(a);if(c===58){if(a+1<r){let f=t.charCodeAt(a+1);if(f===45||f===61||f===43||f===63)return s.operator=t.slice(a,a+2),s.operand=i(a+2,r),s}a++;let h=t.slice(a),u=St(h,58);return u===-1?s.slice={offset:i(a,r),length:void 0}:s.slice={offset:i(a,a+u),length:i(a+u+1,r)},s}if(c===45||c===61||c===43||c===63)return s.operator=t[a],s.operand=i(a+1,r),s;if(c===35)return a+1<r&&t.charCodeAt(a+1)===35?(s.operator="##",s.operand=i(a+2,r)):(s.operator="#",s.operand=i(a+1,r)),s;if(c===37)return a+1<r&&t.charCodeAt(a+1)===37?(s.operator="%%",s.operand=i(a+2,r)):(s.operator="%",s.operand=i(a+1,r)),s;if(c===47){a++;let h="/";if(a<r){let g=t.charCodeAt(a);g===47?(h="//",a++):g===35?(h="/#",a++):g===37&&(h="/%",a++)}s.operator=h;let u=t.slice(a),f=St(u,47);return f===-1?s.replace={pattern:i(a,r),replacement:new w("",n+r,n+r)}:s.replace={pattern:i(a,a+f),replacement:i(a+f+1,r)},s}return c===94?(a+1<r&&t.charCodeAt(a+1)===94?(s.operator="^^",a+2<r&&(s.operand=i(a+2,r))):(s.operator="^",a+1<r&&(s.operand=i(a+1,r))),s):c===44?(a+1<r&&t.charCodeAt(a+1)===44?(s.operator=",,",a+2<r&&(s.operand=i(a+2,r))):(s.operator=",",a+1<r&&(s.operand=i(a+1,r))),s):c===64?(s.operator="@",s.operand=i(a+1,r),s):(s.operator=t.slice(a),s)}scanParamName(e,t){let n=t;if(n>=e.length)return n;let s=e.charCodeAt(n);if(s===64||s===42||s===35||s===63||s===45||s===36||s===33)return n+1;if(s>=48&&s<=57){for(;n<e.length&&e.charCodeAt(n)>=48&&e.charCodeAt(n)<=57;)n++;return n}if(s>=97&&s<=122||s>=65&&s<=90||s===95)for(n++;n<e.length;){let r=e.charCodeAt(n);if(r>=97&&r<=122||r>=65&&r<=90||r>=48&&r<=57||r===95)n++;else break}return n}findCloseBracket(e,t){let n=1;for(let s=t;s<e.length;s++){let r=e.charCodeAt(s);if(r===91)n++;else if(r===93&&--n===0)return s}return-1}readAnsiCQuoted(){let e=this.src,t=this.srcEnd,n="";for(;this.pos<t&&e.charCodeAt(this.pos)!==39;)if(e.charCodeAt(this.pos)===92&&this.pos+1<t){this.pos++;let s=e[this.pos];switch(s){case"n":n+=`
|
|
5
|
+
`;break;case"t":n+=" ";break;case"r":n+="\r";break;case"\\":n+="\\";break;case"'":n+="'";break;case'"':n+='"';break;case"a":n+="\x07";break;case"b":n+="\b";break;case"e":case"E":n+="\x1B";break;case"f":n+="\f";break;case"v":n+="\v";break;default:n+="\\"+s;break}this.pos++}else{let s=this.pos;for(;this.pos<t;){let r=e.charCodeAt(this.pos);if(r===39||r===92)break;this.pos++}n+=e.slice(s,this.pos)}return this.pos<t&&this.pos++,n}extractBalanced(){let e=this.src,t=this.srcEnd,n=1,s=this.pos;for(;this.pos<t&&n>0;){let i=e.charCodeAt(this.pos);if(i===41){if(n--,n===0){let a=e.slice(s,this.pos);return this.pos++,a}this.pos++}else{if(i===40||i===92||i===39||i===34||i===96)break;if(i===99&&(this.pos===s||e.charCodeAt(this.pos-1)<128&&_[e.charCodeAt(this.pos-1)]!==0)&&this.pos+3<t&&e.charCodeAt(this.pos+1)===97&&e.charCodeAt(this.pos+2)===115&&e.charCodeAt(this.pos+3)===101&&(this.pos+4>=t||e.charCodeAt(this.pos+4)<128&&_[e.charCodeAt(this.pos+4)]&1))break;this.pos++}}if(n===0)return e.slice(s,this.pos);let r=0;for(;this.pos<t&&n>0;){let i=e.charCodeAt(this.pos);if(i===40)n++,this.pos++;else if(i===41)if(r>0)this.pos++;else{if(n--,n===0){let a=e.slice(s,this.pos);return this.pos++,a}this.pos++}else if(i===92)this.pos++,this.pos<t&&this.pos++;else if(i===39)this.pos++,this.skipSQ();else if(i===34)this.pos++,this.skipDQ();else if(i===96){for(this.pos++;this.pos<t&&e.charCodeAt(this.pos)!==96;)e.charCodeAt(this.pos)===92&&this.pos++,this.pos<t&&this.pos++;this.pos<t&&this.pos++}else{let a=this.pos;for(;this.pos<t;){let c=e.charCodeAt(this.pos);if(c<128&&_[c])break;this.pos++}if(this.pos>a){if(this.pos-a===4){let h=e.charCodeAt(a);h===99&&e.charCodeAt(a+1)===97&&e.charCodeAt(a+2)===115&&e.charCodeAt(a+3)===101?r++:h===101&&e.charCodeAt(a+1)===115&&e.charCodeAt(a+2)===97&&e.charCodeAt(a+3)===99&&r>0&&r--}}else this.pos++}}return e.slice(s,this.pos)}};function bt(o,e){let t=new ie(o,e.pos,e.end),n=t.buildWordParts(e.pos);if(n)return kt(t),n}function Et(o,e){let t=new ie(o,e.pos,e.end),n=t.buildHereDocParts(e.pos,e.end);if(n)return kt(t),n}function kt(o){let e=o.getSource();for(let t of o.getCollectedExpansions())t.inner!==void 0&&(t.script=t.innerStart!==void 0?Rt(e,t.innerStart,t.innerStart+t.inner.length):me(t.inner),t.inner=void 0,t.innerStart=void 0)}w._resolveWord=bt;w._resolveHeredocBody=Et;var Xe=class{type="ArithmeticCommand";pos;end;body;#e=null;constructor(e,t,n){this.pos=e,this.end=t,this.body=n}get expression(){return this.#e===null&&(this.#e=ue(this.body,this.pos+2)??void 0,Ie()),this.#e}set expression(e){this.#e=e??void 0}},Ge=class{type="ArithmeticFor";pos;end;body;#e;#s;#t;#n;#a;#l;#o=null;#r=null;#i=null;constructor(e,t,n,s,r,i,a,c,h){this.pos=e,this.end=t,this.body=n,this.#e=s,this.#s=r,this.#t=i,this.#n=a,this.#a=c,this.#l=h}get initialize(){if(this.#o===null)if(this.#e){let e=ue(this.#e);e&&j(e,this.#n),Ie(),this.#o=e??void 0}else this.#o=void 0;return this.#o}set initialize(e){this.#o=e??void 0}get test(){if(this.#r===null)if(this.#s){let e=ue(this.#s);e&&j(e,this.#a),Ie(),this.#r=e??void 0}else this.#r=void 0;return this.#r}set test(e){this.#r=e??void 0}get update(){if(this.#i===null)if(this.#t){let e=ue(this.#t);e&&j(e,this.#l),Ie(),this.#i=e??void 0}else this.#i=void 0;return this.#i}set update(e){this.#i=e??void 0}},rs={[l.DoubleSemi]:";;",[l.SemiAmp]:";&",[l.DoubleSemiAmp]:";;&"},is={">":">",">>":">>","<":"<","<<":"<<","<<-":"<<-","<<<":"<<<","<>":"<>","<&":"<&",">&":">&",">|":">|","&>":"&>","&>>":"&>>"};function j(o,e){switch(o.pos+=e,o.end+=e,o.type){case"ArithmeticBinary":j(o.left,e),j(o.right,e);break;case"ArithmeticUnary":j(o.operand,e);break;case"ArithmeticTernary":j(o.test,e),j(o.consequent,e),j(o.alternate,e);break;case"ArithmeticGroup":j(o.expression,e);break}}function Ie(){let o=De();if(o)for(let e of o)e.inner!==void 0&&(e.script=me(e.inner),e.inner=void 0)}var N=new Uint8Array(37);N[l.EOF]=1;N[l.RParen]=1;N[l.RBrace]=1;N[l.Then]=1;N[l.Else]=1;N[l.Elif]=1;N[l.Fi]=1;N[l.Do]=1;N[l.Done]=1;N[l.Esac]=1;N[l.DoubleSemi]=1;N[l.SemiAmp]=1;N[l.DoubleSemiAmp]=1;var F=new Uint8Array(37);F[l.Word]=1;F[l.Assignment]=1;F[l.Bang]=1;F[l.LParen]=1;F[l.LBrace]=1;F[l.DblLBracket]=1;F[l.If]=1;F[l.For]=1;F[l.While]=1;F[l.Until]=1;F[l.Case]=1;F[l.Function]=1;F[l.Select]=1;F[l.ArithCmd]=1;F[l.Coproc]=1;F[l.Redirect]=1;var as={"-a":1,"-b":1,"-c":1,"-d":1,"-e":1,"-f":1,"-g":1,"-h":1,"-k":1,"-p":1,"-r":1,"-s":1,"-t":1,"-u":1,"-v":1,"-w":1,"-x":1,"-z":1,"-n":1,"-N":1,"-S":1,"-L":1,"-G":1,"-O":1,"-R":1},ls={"==":1,"!=":1,"=~":1,"=":1,"-eq":1,"-ne":1,"-lt":1,"-le":1,"-gt":1,"-ge":1,"-nt":1,"-ot":1,"-ef":1,"<":1,">":1},Ze=[],Oe=[],Ke=[];function me(o){return new Ne(o,0,o.length).run()}function Rt(o,e,t){return new Ne(o,e,t).run()}var Ne=class{tok;source;start;end;errors=[];_redirects=[];constructor(e,t,n){this.tok=new ie(e,t,n),this.source=e,this.start=t,this.end=n}run(){let e=this.start,t;if(e===0&&this.source.charCodeAt(0)===35&&this.source.charCodeAt(1)===33){let i=this.source.indexOf(`
|
|
6
|
+
`);t=i===-1?this.source:this.source.slice(0,i)}let n=this.list(),s=this.tok._errors;if(s!==null)for(let i=0;i<s.length;i++)this.errors.push(s[i]);return{type:"Script",pos:e,end:this.end,shebang:t,commands:n,errors:this.errors.length>0?this.errors:void 0}}error(e,t){this.errors.push({message:e,pos:t})}skipSemi(){this.tok.peek(d.Normal).token===l.Semi&&this.tok.next(d.Normal)}accept(e,t=d.Normal){return this.tok.peek(t).token===e?this.tok.next(t):null}acceptEnd(e,t=d.Normal){return this.tok.peek(t).token===e?this.tok.next(t).end:-1}skipNewlines(e=d.Normal){for(;this.tok.peek(e).token===l.Newline;)this.tok.next(e)}makeStatement(e,t){let n=t.length>0?t[t.length-1].end:e.end;return{type:"Statement",pos:e.pos,end:n,command:e,background:void 0,redirects:t}}list(){let e=[];this.skipNewlines(d.CommandStart);let t=this.tok.peek(d.CommandStart).token;if(N[t]||!F[t])return e;let n=this.andOr();if(n){let s=this._redirects;this._redirects=[],e.push(this.makeStatement(n,s))}for(;t=this.tok.peek(d.Normal).token,!(t!==l.Semi&&t!==l.Newline&&t!==l.Amp);){let s=t===l.Amp,r=this.tok.next(d.Normal).end;if(s){let a=e[e.length-1];a.background=!0,a.end=r}if(this.skipNewlines(d.CommandStart),t=this.tok.peek(d.CommandStart).token,N[t]||!F[t])break;let i=this.andOr();if(i){let a=this._redirects;this._redirects=[],e.push(this.makeStatement(i,a))}}return e}andOr(){let e=this.pipeline();if(!e)return null;let t=this.tok.peek(d.Normal).token;if(t!==l.And&&t!==l.Or)return e;let n=e;this._redirects.length>0&&(n=this.makeStatement(e,this._redirects),this._redirects=[]);let s=[n],r=[];do{r.push(this.tok.next(d.Normal).token===l.And?"&&":"||"),this.skipNewlines(d.CommandStart);let i=this.pipeline();if(!i)break;s.push(i),t=this.tok.peek(d.Normal).token}while(t===l.And||t===l.Or);return{type:"AndOr",pos:e.pos,end:s[s.length-1].end,commands:s,operators:r}}wrapCompoundRedirects(e){let t=this._redirects;return this._redirects=[],t.length===0?e:this.makeStatement(e,t)}pipeline(){let e=!1,t=0;this.tok.peek(d.CommandStart).token===l.Word&&this.tok.peek(d.CommandStart).value==="time"&&(e=!0,t=this.tok.next(d.CommandStart).pos,this.tok.peek(d.CommandStart).token===l.Word&&this.tok.peek(d.CommandStart).value==="-p"&&this.tok.next(d.CommandStart));let n=this.tok.peek(d.CommandStart).token===l.Bang;n&&(e||(t=this.tok.peek(d.CommandStart).pos),this.tok.next(d.CommandStart));let s=this.command();if(!s)return e||n?{type:"Pipeline",pos:t,end:t,commands:[],negated:n?!0:void 0,operators:[],time:e?!0:void 0}:null;!e&&!n&&(t=s.pos);let r=[s],i=[],a=this._redirects;for(this._redirects=[];this.tok.peek(d.Normal).token===l.Pipe;){r.length===1&&a.length>0&&(r[0]=this.makeStatement(s,a),a=[]);let h=this.tok.next(d.Normal).value;i.push(h==="|&"?"|&":"|"),this.skipNewlines(d.CommandStart);let u=this.command();u&&r.push(this.wrapCompoundRedirects(u))}return r.length===1&&!n&&!e?(this._redirects=a,r[0]):(a.length>0&&(r[0]=this.makeStatement(s,a)),{type:"Pipeline",pos:t,end:r[r.length-1].end,commands:r,negated:n?!0:void 0,operators:i,time:e?!0:void 0})}command(){switch(this.tok.peek(d.CommandStart).token){case l.LParen:return this.subshell();case l.LBrace:return this.braceGroup();case l.If:return this.ifClause();case l.For:return this.forClause();case l.While:return this.whileClause();case l.Until:return this.untilClause();case l.Case:return this.caseClause();case l.Function:return this.functionDef();case l.Select:return this.selectClause();case l.DblLBracket:return this.testCommand();case l.ArithCmd:return this.arithCommand();case l.Coproc:return this.coprocCommand();case l.Word:case l.Assignment:case l.Redirect:return this.simpleCommandOrFunction();default:return null}}collectTrailingRedirects(){let e=[];for(;this.tok.peek(d.Normal).token===l.Redirect;)e=this.collectRedirect(e,d.Normal);return e}arithCommand(){let e=this.tok.next(d.CommandStart);return this._redirects=this.collectTrailingRedirects(),new Xe(e.pos,e.end,e.value)}coprocCommand(){let e=this.tok.next(d.CommandStart),t=e.pos,n=e.end,s=this.tok.peek(d.CommandStart);if(s.token!==l.Word&&s.token!==l.Assignment&&s.token!==l.Redirect){let f=this.pipeline()??{type:"Command",pos:t,end:n,name:void 0,prefix:Ze,suffix:Oe,redirects:Ke},g=this._redirects;this._redirects=[];let m=this.collectTrailingRedirects(),p=[...g,...m],C=p.length>0?p[p.length-1].end:f.end;return{type:"Coproc",pos:t,end:C,name:void 0,body:f,redirects:p}}let r=this.toWord(this.tok.next(d.CommandStart)),i=this.pipeline();if(i===null){let f={type:"Command",pos:r.pos,end:r.end,name:r,prefix:Ze,suffix:Oe,redirects:Ke},g=this.collectTrailingRedirects(),m=g.length>0?g[g.length-1].end:f.end;return{type:"Coproc",pos:t,end:m,name:void 0,body:f,redirects:g}}if(i.type==="Command"){let f=i;f.name&&(f.suffix=[f.name,...f.suffix]),f.name=r,f.pos=r.pos;let g=this.collectTrailingRedirects(),m=g.length>0?g[g.length-1].end:f.end;return{type:"Coproc",pos:t,end:m,name:void 0,body:f,redirects:g}}let a=this._redirects;this._redirects=[];let c=this.collectTrailingRedirects(),h=[...a,...c],u=h.length>0?h[h.length-1].end:i.end;return{type:"Coproc",pos:t,end:u,name:r,body:i,redirects:h}}subshell(){let e=this.tok.next(d.CommandStart).pos,t=this.list(),n=this.acceptEnd(l.RParen,d.Normal);n<0&&this.error("expected ')' to close subshell",this.tok.getPos());let s=n>=0?n:e;return this._redirects=this.collectTrailingRedirects(),{type:"Subshell",pos:e,end:s,body:this.makeCompoundList(t)}}braceGroup(){let e=this.tok.next(d.CommandStart).pos,t=this.list(),n=this.acceptEnd(l.RBrace,d.Normal);n<0&&this.error("expected '}' to close brace group",this.tok.getPos());let s=n>=0?n:e;return this._redirects=this.collectTrailingRedirects(),{type:"BraceGroup",pos:e,end:s,body:this.makeCompoundList(t)}}ifClause(){let e=this.tok.next(d.CommandStart).pos,t=this.makeCompoundList(this.list());this.skipSemi(),this.accept(l.Then,d.CommandStart)||this.error("expected 'then'",this.tok.getPos());let n=this.makeCompoundList(this.list());this.skipSemi();let s,r;if(this.tok.peek(d.CommandStart).token===l.Elif)s=this.ifClause(),r=s.end;else if(this.accept(l.Else,d.CommandStart)){s=this.makeCompoundList(this.list()),this.skipSemi();let i=this.acceptEnd(l.Fi,d.CommandStart);i<0&&this.error("expected 'fi' to close 'if'",this.tok.getPos()),r=i>=0?i:e}else{let i=this.acceptEnd(l.Fi,d.CommandStart);i<0&&this.error("expected 'fi' to close 'if'",this.tok.getPos()),r=i>=0?i:e}return this._redirects=this.collectTrailingRedirects(),{type:"If",pos:e,end:r,clause:t,then:n,else:s}}forClause(){let e=this.tok.next(d.CommandStart).pos;if(this.tok.peek(d.Normal).token===l.LParen)return this.cStyleFor(e);let t=this.readWord(d.Normal),n=[];if(this.skipNewlines(d.CommandStart),this.tok.peek(d.CommandStart).token===l.In)for(this.tok.next(d.CommandStart);this.tok.peek(d.Normal).token===l.Word;)n.push(this.readWord(d.Normal));this.skipSemi(),this.skipNewlines(d.CommandStart),this.accept(l.Do,d.CommandStart)||this.error("expected 'do'",this.tok.getPos());let s=this.list();this.skipSemi();let r=this.acceptEnd(l.Done,d.CommandStart);r<0&&this.error("expected 'done' to close 'for'",this.tok.getPos());let i=r>=0?r:e;return this._redirects=this.collectTrailingRedirects(),{type:"For",pos:e,end:i,name:t,wordlist:n,body:this.makeCompoundList(s)}}cStyleFor(e){let[t,n,s,r,i,a]=this.tok.readCStyleForExprs();if(this.tok.peek(d.CommandStart).token===l.Semi&&this.tok.next(d.CommandStart),this.skipNewlines(d.CommandStart),this.tok.peek(d.CommandStart).token===l.LBrace){let f=this.braceGroup();return new Ge(e,f.end,f.body,t,n,s,r,i,a)}this.accept(l.Do,d.CommandStart)||this.error("expected 'do'",this.tok.getPos());let c=this.list(),h=this.acceptEnd(l.Done,d.CommandStart);h<0&&this.error("expected 'done' to close 'for'",this.tok.getPos());let u=h>=0?h:e;return this._redirects=this.collectTrailingRedirects(),new Ge(e,u,this.makeCompoundList(c),t,n,s,r,i,a)}whileClause(){return this.whileOrUntil("while")}untilClause(){return this.whileOrUntil("until")}whileOrUntil(e){let t=this.tok.next(d.CommandStart).pos,n=this.makeCompoundList(this.list());this.skipSemi(),this.accept(l.Do,d.CommandStart)||this.error("expected 'do'",this.tok.getPos());let s=this.list();this.skipSemi();let r=this.acceptEnd(l.Done,d.CommandStart);r<0&&this.error(`expected 'done' to close '${e}'`,this.tok.getPos());let i=r>=0?r:t;return this._redirects=this.collectTrailingRedirects(),{type:"While",pos:t,end:i,kind:e,clause:n,body:this.makeCompoundList(s)}}caseClause(){let e=this.tok.next(d.CommandStart).pos,t=this.readWord(d.Normal);this.skipNewlines(d.CommandStart),this.accept(l.In,d.CommandStart)||this.error("expected 'in' after 'case' word",this.tok.getPos()),this.skipNewlines(d.CommandStart);let n=[],s=this.tok.peek(d.CommandStart).token;for(;s!==l.Esac&&s!==l.EOF;){let a=this.tok.peek(d.Normal).pos;this.accept(l.LParen,d.Normal);let c=[];for(s=this.tok.peek(d.Normal).token;s!==l.RParen&&s!==l.EOF;)s!==l.Pipe?c.push(this.toWord(this.tok.next(d.Normal))):this.tok.next(d.Normal),s=this.tok.peek(d.Normal).token;let h=this.acceptEnd(l.RParen,d.Normal),u=this.list(),f=h>=0?h:a;u.length>0&&(f=u[u.length-1].end);let g={type:"CaseItem",pos:a,end:f,pattern:c,body:this.makeCompoundList(u),terminator:void 0};if(s=this.tok.peek(d.CommandStart).token,s===l.DoubleSemi||s===l.SemiAmp||s===l.DoubleSemiAmp){let m=this.tok.next(d.CommandStart);g.terminator=rs[m.token],g.end=m.end}n.push(g),this.skipNewlines(d.CommandStart),s=this.tok.peek(d.CommandStart).token}let r=this.acceptEnd(l.Esac,d.CommandStart);r<0&&this.error("expected 'esac' to close 'case'",this.tok.getPos());let i=r>=0?r:e;return this._redirects=this.collectTrailingRedirects(),{type:"Case",pos:e,end:i,word:t,items:n}}selectClause(){let e=this.tok.next(d.CommandStart).pos,t=this.readWord(d.Normal),n=[];if(this.skipNewlines(d.CommandStart),this.tok.peek(d.CommandStart).token===l.In)for(this.tok.next(d.CommandStart);this.tok.peek(d.Normal).token===l.Word;)n.push(this.readWord(d.Normal));this.skipSemi(),this.skipNewlines(d.CommandStart),this.accept(l.Do,d.CommandStart)||this.error("expected 'do'",this.tok.getPos());let s=this.list();this.skipSemi();let r=this.acceptEnd(l.Done,d.CommandStart);r<0&&this.error("expected 'done' to close 'select'",this.tok.getPos());let i=r>=0?r:e;return this._redirects=this.collectTrailingRedirects(),{type:"Select",pos:e,end:i,name:t,wordlist:n,body:this.makeCompoundList(s)}}testCommand(){let e=this.tok.next(d.CommandStart).pos,t=this.parseTestOr(),n=this.acceptEnd(l.DblRBracket,d.TestMode);n<0&&this.tok.peek(d.Normal).token===l.EOF&&this.error("expected ']]' to close '[['",this.tok.getPos());let s=n>=0?n:e;return this._redirects=this.collectTrailingRedirects(),{type:"TestCommand",pos:e,end:s,expression:t}}parseTestOr(){let e=this.parseTestAnd();for(;this.tok.peek(d.TestMode).token===l.Or;){this.tok.next(d.TestMode);let t=this.parseTestAnd();e={type:"TestLogical",pos:e.pos,end:t.end,operator:"||",left:e,right:t}}return e}parseTestAnd(){let e=this.parseTestNot();for(;this.tok.peek(d.TestMode).token===l.And;){this.tok.next(d.TestMode);let t=this.parseTestNot();e={type:"TestLogical",pos:e.pos,end:t.end,operator:"&&",left:e,right:t}}return e}parseTestNot(){if(this.tok.peek(d.TestMode).token===l.Word&&this.tok.peek(d.TestMode).value==="!"){let e=this.tok.next(d.TestMode).pos,t=this.parseTestNot();return{type:"TestNot",pos:e,end:t.end,operand:t}}return this.parseTestPrimary()}parseTestPrimary(){if(this.tok.peek(d.TestMode).token===l.LParen){let a=this.tok.next(d.TestMode).pos,c=this.parseTestOr(),h=this.acceptEnd(l.RParen,d.TestMode);h<0&&this.error("expected ')' to close test group",this.tok.getPos());let u=h>=0?h:a;return{type:"TestGroup",pos:a,end:u,expression:c}}let e=this.tok.next(d.TestMode),t=e.value,n=e.pos,s=e.end;if(as[t]===1&&this.tok.peek(d.TestMode).token===l.Word){let c=this.readWord(d.TestMode);return{type:"TestUnary",pos:n,end:c.end,operator:t,operand:c}}let r=this.tok.peek(d.TestMode);if(r.token===l.Word&&ls[r.value]===1){let a=this.tok.next(d.TestMode).value,c;a==="=~"?c=this.toWord(this.tok.readTestRegexWord()):c=this.readWord(d.TestMode);let h=this.toWordFromPosEnd(e,n,s);return{type:"TestBinary",pos:n,end:c.end,operator:a,left:h,right:c}}let i=this.toWordFromPosEnd(e,n,s);return{type:"TestUnary",pos:n,end:i.end,operator:"-n",operand:i}}functionDef(){let e=this.tok.next(d.CommandStart).pos,t=this.readWord(d.Normal);this.tok.peek(d.CommandStart).token===l.LParen&&(this.tok.next(d.CommandStart),this.accept(l.RParen,d.CommandStart)||this.error("expected ')' after '('",this.tok.getPos())),this.skipNewlines(d.CommandStart);let n=this.commandAsBody(),s=this._redirects;this._redirects=[];let r=s.length>0?s[s.length-1].end:n.end;return{type:"Function",pos:e,end:r,name:t,body:n,redirects:s}}simpleCommandOrFunction(){let e=[],t=[],n=this.tok.peek(d.CommandStart).pos,s=n;for(;this.tok.peek(d.CommandStart).token===l.Assignment;){let a=this.tok.next(d.CommandStart);s=a.end,e.push(this.parseAssignment(a))}for(;this.tok.peek(d.CommandStart).token===l.Redirect;)t=this.collectRedirect(t,d.CommandStart),s=t[t.length-1].end;if(this.tok.peek(d.Normal).token!==l.Word)return e.length>0?{type:"Command",pos:n,end:s,name:void 0,prefix:e,suffix:Oe,redirects:t}:{type:"Command",pos:n,end:s,name:void 0,prefix:Ze,suffix:Oe,redirects:Ke};let r=this.readWord(d.Normal);if(s=r.end,this.tok.peek(d.Normal).token===l.LParen&&(this.tok.next(d.Normal),this.tok.peek(d.Normal).token===l.RParen)){this.tok.next(d.Normal),this.skipNewlines(d.CommandStart);let a=this.commandAsBody(),c=this._redirects;this._redirects=[];let h=c.length>0?c[c.length-1].end:a.end;return{type:"Function",pos:r.pos,end:h,name:r,body:a,redirects:c}}let i=[];for(;;){let a=this.tok.peek(d.Normal).token;if(a===l.Word||a===l.Assignment){let c=this.readWord(d.Normal);i.push(c),s=c.end}else if(a===l.Redirect)t=this.collectRedirect(t,d.Normal),s=t[t.length-1].end;else break}return{type:"Command",pos:n,end:s,name:r,prefix:e,suffix:i,redirects:t}}collectRedirect(e,t){let n=this.tok.next(t),s=n.pos,r=n.end,i={pos:s,end:r,operator:is[n.value]??">",target:void 0,fileDescriptor:n.fileDescriptor,variableName:n.variableName,content:n.content,heredocQuoted:void 0,body:void 0};return n.content!=null&&(i.target=new w(n.content,n.targetPos,n.targetEnd,this.source)),(n.value==="<<"||n.value==="<<-")&&this.tok.registerHereDocTarget(i),e.push(i),e}commandAsBody(){let e=this.tok.peek(d.CommandStart).token;if(e===l.LBrace)return this.braceGroup();if(e===l.LParen)return this.subshell();let t=this.command(),n=this.tok.getPos();return t??{type:"CompoundList",pos:n,end:n,commands:[]}}readWord(e){return this.toWord(this.tok.next(e))}toWord(e){return new w(this.source.slice(e.pos,e.end),e.pos,e.end,this.source)}toWordFromPosEnd(e,t,n){return new w(this.source.slice(t,n),t,n,this.source)}parseAssignment(e){let t=this.source.slice(e.pos,e.end),n=e.pos,s=e.end,r={type:"Assignment",pos:n,end:s,text:t,name:void 0,value:void 0,append:void 0,index:void 0,array:void 0},i=t.indexOf("=");if(i<=0)return r;let a=i,c=!1,h;t.charCodeAt(i-1)===43&&(c=!0,a=i-1);let u=t.indexOf("[");if(u>0&&u<a){let p=t.indexOf("]",u);p>u&&p+1===a&&(h=t.slice(u+1,p),a=u)}let f=t.slice(0,a);r.name=f,c&&(r.append=!0),h!==void 0&&(r.index=h);let g=i+1,m=t.slice(g);if(m.charCodeAt(0)===40&&m.charCodeAt(m.length-1)===41){let p=m.slice(1,-1),C=n+g+1,A=this.parseArrayElements(p,C);r.array=A}else r.value=new w(m,n+g,s,this.source);return r}parseArrayElements(e,t=0){let n=new ie(e),s=[];for(;n.peek(d.Normal).token!==l.EOF;){if(n.peek(d.Normal).token===l.Newline){n.next(d.Normal);continue}let r=n.next(d.Normal);if(r.token===l.Word||r.token===l.Assignment){let i=r.pos+t,a=r.end+t;s.push(new w(this.source.slice(i,a),i,a,this.source))}}return s}makeCompoundList(e){let t=this.tok.getPos(),n=e.length>0?e[0].pos:t,s=e.length>0?e[e.length-1].end:t;return{type:"CompoundList",pos:n,end:s,commands:e}}};function Je(o,e,t){let n="",s="",r=!1,i=!1;for(let a=0;a<o.length;a++){let c=o[a];if(c===s){s="";continue}if(s!=="'"&&c==="\\"){let h=o[a+1];if(h===void 0){r=!0;break}if(!s||["$","`",'"',"\\",`
|
|
7
|
+
`].includes(h)){h!==`
|
|
8
|
+
`&&(n+=h),a++;continue}}if(!s&&(c==="'"||c==='"')){s=c;continue}s!=="'"&&(c==="$"||c==="`")&&(r=!0),!s&&/[*?[{}~]/.test(c)&&(r=!0),!s&&/[*?[]/.test(c)&&(i=!0),n+=c}return{value:n,dynamic:r||!!s,hasUnquotedGlob:i,start:e,end:t}}var cs=1e4,ds=new Set(["AndOr","Pipeline","Statement"]);function Ft(o){if(o.trim().length===0)return et();if(o.length>cs)return{...et(),hasParseErrors:!0};let t;try{t=me(o)}catch{return{...et(),hasParseErrors:!0}}let n={commands:[],hasDynamicWords:!1,hasParseErrors:!!t.errors?.length,hasRedirects:!1,unsupportedNodeTypes:new Set};for(let s=0;s<t.commands.length;s+=1)Lt(o,t.commands[s],{analysis:n,operatorBefore:s===0?void 0:"sequence",statementRedirects:[]});return gs(n)}function Tt(o){return!o.hasParseErrors&&!o.hasUnsupportedSyntax&&!o.hasDynamicWords}function Lt(o,e,t){e.background&&t.analysis.unsupportedNodeTypes.add("background"),e.redirects.length>0&&(t.analysis.hasRedirects=!0,wt(e.redirects)&&(t.analysis.hasDynamicWords=!0)),tt(o,e.command,{...t,statementRedirects:[...t.statementRedirects,...e.redirects]})}function tt(o,e,t){switch(e.type){case"Command":ps(o,e,t);return;case"AndOr":hs(o,e,t);return;case"Pipeline":us(o,e,t);return;case"Statement":Lt(o,e,t);return;default:t.analysis.unsupportedNodeTypes.add(e.type)}}function hs(o,e,t){for(let n=0;n<e.commands.length;n+=1)tt(o,e.commands[n],{...t,operatorBefore:n===0?t.operatorBefore:e.operators[n-1]})}function us(o,e,t){let n=t.analysis.commands.length;for(let r=0;r<e.commands.length;r+=1)tt(o,e.commands[r],{...t,operatorBefore:r===0?t.operatorBefore:e.operators[r-1]});let s=t.analysis.commands[n];if(e.time&&s){let r=o.slice(e.pos,s.words[0]?.start),i=/\btime\b/.exec(r);i&&s.words.unshift({value:"time",dynamic:!1,hasUnquotedGlob:!1,start:e.pos+i.index,end:e.pos+i.index+4})}}function ps(o,e,t){let n=[...t.statementRedirects,...e.redirects],s=[e.name,...e.suffix].filter(ms),r=s.map(ve),i=e.prefix.map(h=>({name:h.name,value:h.value?ve(h.value):void 0})),a=s.some(Be)||e.prefix.some(h=>h.value!==void 0&&Be(h.value))||wt(n);a&&(t.analysis.hasDynamicWords=!0),n.length>0&&(t.analysis.hasRedirects=!0);let c=e.name?ve(e.name):"";t.analysis.commands.push({words:s.map(h=>{let u=Je(h.text,h.pos,h.end);return h.parts&&(u.hasUnquotedGlob=h.parts.some(f=>f.type==="Literal"&&Je(f.text,0,f.text.length).hasUnquotedGlob)),u}),argv:r,commandText:o.slice(e.pos,e.end),envAssignments:i,hasAssignmentPrefix:e.prefix.length>0,hasDynamicWords:a,hasRedirects:n.length>0,name:c,operatorBefore:t.operatorBefore,redirects:n.map(h=>({fileDescriptor:h.fileDescriptor,operator:h.operator,target:fs(h)}))})}function fs(o){return o.target!==void 0?ve(o.target):o.content??""}function wt(o){return o.some(e=>e.target!==void 0&&Be(e.target)||e.body!==void 0&&Be(e.body))}function Be(o){return o.parts?.some(Dt)??!1}function Dt(o){switch(o.type){case"AnsiCQuoted":case"Literal":case"SingleQuoted":return!1;case"DoubleQuoted":case"LocaleString":return o.parts.some(Dt);case"CommandExpansion":case"ProcessSubstitution":return!0;case"ArithmeticExpansion":case"BraceExpansion":case"ExtendedGlob":case"ParameterExpansion":case"SimpleExpansion":return!0;default:return!0}}function ve(o){return o.value??o.text}function ms(o){return o!==void 0}function et(){return{commands:[],hasDynamicWords:!1,hasParseErrors:!1,hasRedirects:!1,hasUnsupportedSyntax:!1,unsupportedNodeTypes:[]}}function gs(o){let e=[...o.unsupportedNodeTypes].filter(t=>!ds.has(t));return{commands:o.commands,hasDynamicWords:o.hasDynamicWords,hasParseErrors:o.hasParseErrors,hasRedirects:o.hasRedirects,hasUnsupportedSyntax:e.length>0,unsupportedNodeTypes:e}}import{accessSync as Cs,constants as As,lstatSync as st,readFileSync as It,readlinkSync as xs,realpathSync as _s,statSync as nt}from"node:fs";import{dirname as Ss,isAbsolute as Gt,join as ae,resolve as ys}from"node:path";function Nt(o){return o.some(e=>(Bt(e.argv)??e.name)==="git")}function vt(o){let e=!1,t=!1;for(let n of o){let s=Bt(n.argv)??n.name;e||=s==="git",t||=s==="cd"||s==="pushd"||s==="popd"}return e&&t}function Bt(o){let e=[...o];for(;;){if(e[0]==="command"){let t=1;for(;e[t]!==void 0&&/^-p+$/.test(e[t]??"");)t+=1;if(e[t]==="--"&&(t+=1),t>=e.length||e[t]?.startsWith("-"))return e[0];e=e.slice(t);continue}if(e[0]==="builtin"){let t=e[1]==="--"?2:1;if(t>=e.length)return e[0];e=e.slice(t);continue}if(e[0]==="noglob"){if(e.length<=1)return e[0];e=e.slice(1);continue}return e[0]}}var bs=32*1024;function Ht(o){let e=o?.workingDirectory;if(!e)return!1;let t=Mt(e);if(!t)return!0;let n=Pt(e,t);if(n==="trusted")return!1;if(n==="unsafe")return!0;let s=e;for(;;){if(Rs(s))return!0;let r=Ss(s);if(r===s)return!1;let i=Pt(r,t);if(i==="trusted")return!1;if(i==="unsafe")return!0;s=r}}function Pt(o,e){let t=ae(o,".git");try{let n=st(t);if(n.isSymbolicLink()){let s=Es(t,o);return s?Ot(s,e):"unsafe"}if(n.isFile()){if(n.size>bs)return"unsafe";let s=It(t,"utf8");if(s.includes("\0"))return"unsafe";if(!s.startsWith("gitdir: "))return"none";let r=s.slice(8).replace(/[\r\n]+$/,"");return Ot(Gt(r)?r:ae(o,r),e)}if(n.isDirectory())return ks(t)?"trusted":"none"}catch{return"none"}return"none"}function Ot(o,e){let t=Mt(o);return!t||Ts(t,e)||!Ls(t)?"unsafe":Wt(t)?"trusted":"none"}function Es(o,e){try{let t=xs(o);return Gt(t)?t:ae(e,t)}catch{return}}function ks(o){if(!Wt(o))return!1;try{for(let e of["objects","refs"]){let t=ae(o,e);if(!nt(t).isDirectory())return!1;Cs(t,As.X_OK)}try{return nt(ae(o,"commondir")),!1}catch{return!0}}catch{return!1}}function Wt(o){try{let e=ae(o,"HEAD"),t=st(e);if(!t.isFile()||t.size>4096)return!1;let n=It(e,"utf8").slice(0,255);return/^ref:[ \t]*refs\//.test(n)||/^[0-9a-f]{40}([0-9a-f]{24})?[ \t\n\r]*$/.test(n)}catch{return!1}}function Rs(o){let e=ae(o,"HEAD");try{let t=st(e);if(t.isFile()||t.isSymbolicLink())return!0}catch{}return["objects","refs"].some(t=>ws(ae(o,t)))}function Mt(o){try{return Fs(_s.native(ys(o)))}catch{return}}function Fs(o){return o.replace(/\\/g,"/").normalize("NFC").toLowerCase()}function Ts(o,e){let t=e.endsWith("/")?e:`${e}/`;return o===e||o.startsWith(t)}function Ls(o){return o.split(/[\\/]+/).some(e=>e.toLowerCase()===".git")}function ws(o){try{return nt(o),!0}catch{return!1}}function pe(o,e){for(let t=0;t<e.length;t+=1){let n=e[t]??"",s=n.includes("=")?n.slice(n.indexOf("=")+1):e[t+1];if((n==="--format"||n==="--pretty"||n.startsWith("--format=")||n.startsWith("--pretty="))&&s&&/%[-+ ]?G|%\(\*?signature/.test(s))return!0}return!1}function Ut(o,e){let t=new Set(["show","list"]),n=new Set(["expire","delete","exists","drop","write"]),s=e.find(r=>r&&!r.startsWith("-"));return s&&!t.has(s)?!0:e.some(r=>n.has(r))}function Vt(o,e){let t=!1;for(let n=0;n<e.length;n+=1){let s=e[n]??"";if(!t&&s==="--"){t=!0;continue}if(!t&&(s.startsWith("-")||!s)){s==="--sort"&&(n+=1);continue}return!0}return!1}function qt(o,e){let t=e.indexOf("--"),n=t===-1?e:e.slice(0,t),s=(t===-1?[]:e.slice(t+1)).concat(n.filter(r=>r!=="-n"));return!n.includes("-n")||s.length!==1?!0:!/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/.test(s[0]??"")}function zt(o,e){return Yt(e,new Set(["--contains","--no-contains","--merged","--no-merged","--points-at","--sort","--format","-n"]))}function Qt(o,e){return Yt(e,new Set(["--contains","--no-contains","--points-at","--sort"]))}function Yt(o,e){let t=!1,n=!1,s="";for(let r=0;r<o.length;r+=1){let i=o[r]??"";if(i){if(i==="--"&&!n){n=!0,s="";continue}if(!n&&i.startsWith("-")){(i==="--list"||i==="-l"||i[0]==="-"&&i[1]!=="-"&&i.slice(1).includes("l"))&&(t=!0),s=i.includes("=")?i.slice(0,i.indexOf("=")):i,!i.includes("=")&&e.has(s)&&(r+=1);continue}if(!t&&s!=="--merged"&&s!=="--no-merged")return!0}}return!1}function We(o){return o.startsWith("-i")||o==="--in-place"||o.startsWith("--in-place=")}function Zt(o,e){for(let t=0;t<e.length;t+=1){let n=e[t]??"";if(n){if(Ds(n))return!0;if(n==="--")return $t(e[t+1]??"");if(n==="--indent"){t+=1;continue}if(!n.startsWith("-"))return $t(n)}}return!1}function Ds(o){return o==="-f"||o.startsWith("-f")||o==="-L"||o.startsWith("-L")||o==="--argfile"||o.startsWith("--argfile=")||o==="--from-file"||o.startsWith("--from-file=")||o==="--library-path"||o.startsWith("--library-path=")||o==="--rawfile"||o.startsWith("--rawfile=")||o==="--run-tests"||o.startsWith("--run-tests=")||o==="--slurpfile"||o.startsWith("--slurpfile=")}function $t(o){return/\$ENV\b/.test(o)||/(^|[^A-Za-z0-9_$.])env(?=$|[^A-Za-z0-9_])/.test(o)||/(^|[^A-Za-z0-9_])(?:include|import)(?=$|[^A-Za-z0-9_])/.test(o)}function Kt(o,e){let t=!1;for(let n=0;n<e.length;n+=1){let s=e[n]??"";if(s){if(We(s))return!0;if(s==="-e"||s==="--expression"){if(n+=1,He(e[n]??""))return!0;continue}if(s.startsWith("--expression=")){if(He(s.slice(13)))return!0;continue}if(s==="-l"||s==="--line-length"){n+=1;continue}if(!s.startsWith("--line-length=")){if(s==="--"){let r=e[n+1]??"";return He(r)}if(!s.startsWith("-")&&!t&&(t=!0,He(s)))return!0}}}return!1}function He(o){return/(?:^|[;{\n])\s*(?:[0-9,$!+~-]+)?\s*w(?:\s|$)/.test(o)}function Xt(o,e){let t=new Set(["-d","--date","-r","--reference","--rfc-3339"]);for(let n=0;n<e.length;){let s=e[n]??"";if(s.startsWith("--")&&s.includes("=")){n+=1;continue}if(s.startsWith("-")){n+=t.has(s)?2:1;continue}if(!s.startsWith("+"))return!0;n+=1}return!1}function Jt(o,e){return e.some(t=>!t.startsWith("-")&&/^[a-zA-Z]*e[a-zA-Z]*$/.test(t))}function en(o,e){return e.some(t=>t==="--watch"||t==="-w")}function tn(o,e){let t=new Set(["-k","-f","--apropos","--whatis"]),n=new Set(["-S","-s"]),s=!1,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i]??"";if(!r&&a==="--"){r=!0;continue}if(!r&&a.startsWith("-")&&a!=="-"){t.has(a)&&(s=!0),n.has(a)&&(i+=1);continue}if(r=!0,a.includes("/"))return!s}return!1}function nn(o,e){for(let t=0;t<e.length;t+=1){let n=e[t]??"";if(n==="+m"||n.startsWith("+m"))return!0;if(/^-[a-zA-Z]*i\S*@/.test(n)){let s=n.slice(n.indexOf("@")+1).split(":")[0]??"";if(/[a-zA-Z]/.test(s))return!0}if(/^-[a-zA-Z]*i$/.test(n)){let s=e[t+1]??"";if(s.includes("@")){let r=s.slice(s.indexOf("@")+1).split(":")[0]??"";if(/[a-zA-Z]/.test(r))return!0}}}return!1}var Ps=new Set(["clear","flash","if","init","iprog","is1","is2","is3","mc0","mc4","mc5","mc5i","mc5p","pfkey","pfloc","pfx","pfxl","reset","rf","rmcup","rs1","rs2","rs3","smcup"]);function sn(o,e){let t=!1;for(let n=0;n<e.length;){let s=e[n]??"";if(s==="--"){t=!0,n+=1;continue}if(!t&&s.startsWith("-")){if(s==="-S"||!s.startsWith("--")&&s.length>2&&s.includes("S"))return!0;n+=s==="-T"?2:1;continue}if(Ps.has(s))return!0;n+=1}return!1}function on(o,e){let t=/^(dst|src|dport|sport|and|or|not|eq|ne|ge|le|gt|lt|autobound|state|exclude|dev|fwmark|cgroup)$/,n=/^(state|exclude|dport|sport|dev|fwmark|cgroup)$/,s=/^(-f|--family|-A|--query|--socket)$/,r=[],i=!1;for(let h=0;h<e.length;h+=1){let u=e[h]??"";if(!i&&u==="--"){i=!0;continue}if(!i&&u.startsWith("-")){s.test(u)&&(h+=1);continue}r.push(u)}let a=r.join(" ").split(/[\s()=!<>&|,]+/).filter(Boolean),c=!1;for(let h of a){if(c){c=!1;continue}if(t.test(h)){c=n.test(h);continue}if(/[g-zG-Z]/.test(h)||/[a-fA-F]/.test(h)&&(h.includes(".")||!h.includes(":")))return!0}return!1}var Os=new Set(["-eq","-ne","-lt","-le","-gt","-ge"]),jt=/^-?(0[xX][0-9a-fA-F]+|[0-9]+#[0-9a-zA-Z]+|[0-9]+)$/;function Me(o,e){if(e.some(t=>t==="-v"||t==="-R"||t==="-a"||t==="-o"||/\[/.test(t)))return!0;for(let t=0;t<e.length;t+=1){let n=e[t]??"";if(Os.has(n)){for(let s of[e[t-1],e[t+1]])if(s!==void 0&&!jt.test(s))return!0}if(n==="-t"){let s=e[t+1];if(s!==void 0&&!jt.test(s))return!0}}return!1}var ot=new Set(["echo","printf","wc","grep","egrep","fgrep","head","tail"]),Is=new Set(["-I","-n","-P","-L","-s","-E","-d"]);function rn(o,e){for(let t=0;t<e.length;t+=1){let n=e[t]??"";if(n){if(n==="--"&&t+1<e.length&&(t+=1,n=e[t]??""),n.startsWith("-")&&n!=="-"){Is.has(n)&&(t+=1);continue}return!ot.has(n)}}return!1}function R(o,e){for(let t of e){if(!t)continue;let n=t;if(t.startsWith("-")){let s=t.indexOf("=");if(s===-1||(n=t.slice(s+1),!n))continue}if(!(!n.includes("/")&&!n.includes("://")&&!n.includes("@"))&&(n.includes("://")||n.includes("@")||(n.match(/\//g)??[]).length>=2))return!0}return!1}var an=["-H","-c","--config","--context","--host","--tlscacert","--tlscert","--tlskey"],Gs=new Set(an.filter(o=>o.length===2).map(o=>o[1]));function rt(o,e){return it(e)}function it(o){return o.some(e=>{if(an.some(n=>e===n||e.startsWith(`${n}=`)||n.length===2&&e.length>2&&e.startsWith(n)))return!0;let t=e.match(/^-([A-Za-z]+)/)?.[1];if(t!==void 0&&t.length>=2){for(let n of t)if(Gs.has(n))return!0}return!1})}var at={"-0":"none","-1":"none","-E":"string","-F":"none","-H":"none","-I":"none","-L":"none","-S":"string","-V":"none","-a":"none","-c":"string","-d":"number","-e":"string","-g":"none","-h":"none","-i":"none","-j":"number","-o":"string","-p":"none","-q":"none","-s":"none","-t":"string","--absolute-path":"none","--and":"string","--base-directory":"string","--batch-size":"number","--case-sensitive":"none","--changed-before":"string","--changed-within":"string","--color":"string","--exact-depth":"number","--exclude":"string","--extension":"string","--fixed-strings":"none","--follow":"none","--format":"string","--full-path":"none","--glob":"none","--help":"none","--hidden":"none","--hyperlink":"string","--ignore-case":"none","--ignore-file":"string","--max-buffer-time":"string","--max-depth":"number","--max-results":"number","--min-depth":"number","--no-ignore":"none","--no-ignore-parent":"none","--no-ignore-vcs":"none","--no-require-git":"none","--one-file-system":"none","--owner":"string","--path-separator":"string","--print0":"none","--prune":"none","--quiet":"none","--regex":"none","--search-path":"string","--show-errors":"none","--size":"string","--strip-cwd-prefix":"none","--threads":"number","--type":"string","--version":"none"},ln={"-C":"none","-M":"none","-R":"none","-S":"string","-V":"none","-b":"none","-c":"none","-d":"none","-f":"none","-g":"none","-h":"none","-i":"none","-k":"string","-m":"none","-n":"none","-r":"none","-s":"none","-t":"string","-u":"none","-z":"none","--batch-size":"number","--buffer-size":"string","--check":"none","--check-char-order":"none","--dictionary-order":"none","--field-separator":"string","--general-numeric-sort":"none","--help":"none","--human-numeric-sort":"none","--ignore-case":"none","--ignore-leading-blanks":"none","--ignore-nonprinting":"none","--key":"string","--merge":"none","--month-sort":"none","--numeric-sort":"none","--parallel":"number","--random-sort":"none","--reverse":"none","--sort":"string","--stable":"none","--unique":"none","--version":"none","--version-sort":"none","--zero-terminated":"none"},cn={"-D":"none","-b":"number","-d":"none","-h":"none","-i":"string","-w":"number","--break":"number","--decode":"none","--help":"none","--ignore-garbage":"none","--input":"string","--version":"none","--wrap":"number"},Ue={"-b":"none","-c":"none","-t":"none","-w":"none","-z":"none","--binary":"none","--check":"none","--help":"none","--ignore-missing":"none","--quiet":"none","--status":"none","--strict":"none","--tag":"none","--text":"none","--version":"none","--warn":"none","--zero":"none"},dn={"-I":"none","-R":"none","-d":"string","-r":"string","-u":"none","--date":"string","--debug":"none","--help":"none","--iso-8601":"string","--reference":"string","--rfc-3339":"string","--rfc-email":"none","--universal":"none","--utc":"none","--version":"none"},hn={"-A":"none","-V":"none","-a":"none","-d":"none","-f":"none","-h":"none","-i":"none","-I":"none","-s":"none","-v":"none","--alias":"none","--all-fqdns":"none","--all-ip-addresses":"none","--domain":"none","--fqdn":"none","--help":"none","--ip-address":"none","--long":"none","--short":"none","--verbose":"none","--version":"none"};var ge={"--all":"none","--branches":"none","--remotes":"none","--tags":"none"},ye={"--after":"string","--before":"string","--since":"string","--until":"string"},be={"--date":"string","--decorate":"none","--graph":"none","--no-decorate":"none","--oneline":"none","--relative-date":"none"},Ee={"-n":"number","--max-count":"number"},ke={"--name-only":"none","--name-status":"none","--numstat":"none","--shortstat":"none","--stat":"none"},Ce={"--color":"none","--no-color":"none"},Ve={"-p":"none","-s":"none","--no-ext-diff":"none","--no-patch":"none","--patch":"none"},un={"-b":"none","-M":"string","-s":"none","-u":"string","--ahead-behind":"none","--branch":"none","--column":"none","--find-renames":"string","--ignore-submodules":"string","--ignored":"none","--long":"none","--no-ahead-behind":"none","--no-column":"none","--no-renames":"none","--porcelain":"none","--renames":"none","--short":"none","--untracked-files":"string","--verbose":"none","-v":"none"},pn={"-B":"none","-C":"none","-D":"none","-G":"string","-M":"none","-O":"string","-R":"none","-S":"string","-l":"none","-p":"none","-s":"none","-u":"none","--cached":"none","--check":"none","--color":"none","--color-words":"none","--diff-algorithm":"string","--diff-filter":"string","--dirstat":"none","--exit-code":"none","--find-copies":"none","--find-copies-harder":"none","--find-renames":"none","--full-index":"none","--function-context":"none","--histogram":"none","--ignore-all-space":"none","--ignore-blank-lines":"none","--ignore-space-at-eol":"none","--ignore-space-change":"none","--inter-hunk-context":"number","--irreversible-delete":"none","--minimal":"none","--name-only":"none","--name-status":"none","--no-ext-diff":"none","--no-index":"none","--no-renames":"none","--no-color":"none","--numstat":"none","--patch-with-stat":"none","--patience":"none","--pickaxe-all":"none","--pickaxe-regex":"none","--quiet":"none","--relative":"string","--shortstat":"none","--staged":"none","--stat":"none","--summary":"none","--word-diff":"none","--word-diff-regex":"string","--ws-error-highlight":"string"},fn={...be,...ge,...ye,...Ee,...ke,...Ce,...Ve,"-G":"string","-S":"string","--abbrev-commit":"none","--ancestry-path":"none","--author":"string","--author-date-order":"none","--boundary":"none","--cherry-mark":"none","--cherry-pick":"none","--committer":"string","--date-order":"none","--dense":"none","--diff-filter":"string","--first-parent":"none","--format":"string","--full-history":"none","--grep":"string","--left-right":"none","--max-age":"number","--min-age":"number","--merges":"none","--no-max-parents":"none","--no-merges":"none","--no-min-parents":"none","--no-walk":"none","--pickaxe-all":"none","--pickaxe-regex":"none","--pretty":"string","--reverse":"none","--simplify-merges":"none","--skip":"number","--source":"none","--sparse":"none","--topo-order":"none","--walk-reflogs":"none"},mn={...be,...ke,...Ce,...Ve,"-m":"none","--abbrev-commit":"none","--color-words":"none","--diff-filter":"string","--first-parent":"none","--format":"string","--pretty":"string","--quiet":"none","--raw":"none","--word-diff":"none","--word-diff-regex":"string"},gn={"-A":"number","-B":"number","-C":"number","-E":"none","-F":"none","-G":"none","-H":"none","-L":"none","-P":"none","-c":"none","-e":"string","-h":"none","-i":"none","-l":"none","-n":"none","-o":"none","-q":"none","-v":"none","-w":"none","--after-context":"number","--and":"none","--basic-regexp":"none","--break":"none","--cached":"none","--color":"none","--context":"number","--count":"none","--extended-regexp":"none","--files-with-matches":"none","--files-without-match":"none","--fixed-strings":"none","--full-name":"none","--heading":"none","--ignore-case":"none","--invert-match":"none","--line-number":"none","--max-depth":"number","--no-color":"none","--no-index":"none","--not":"none","--only-matching":"none","--or":"none","--perl-regexp":"none","--quiet":"none","--recurse-submodules":"none","--threads":"number","--untracked":"none","--word-regexp":"none"};var Cn={"-A":"none","-C":"string","-F":"none","-G":"string","-H":"none","-L":"none","-N":"none","-T":"none","-U":"string","-V":"none","-a":"none","-c":"none","-d":"none","-e":"none","-f":"none","-g":"string","-j":"none","-l":"none","-m":"none","-n":"string","-p":"string","-q":"string","-s":"string","-t":"string","-u":"string","-w":"none","-ww":"none","-y":"none","--deselect":"none","--forest":"none","--headers":"none","--help":"none","--info":"none","--no-headers":"none","--pid":"string","--quick-pid":"string","--sid":"string","--sort":"string","--tty":"string","--user":"string","--version":"none","--width":"number"},An={"--dependencies":"none","--level":"string","--outputjson":"none","--pythonplatform":"string","--pythonversion":"string","--stats":"none","--verbose":"none","--version":"none","--warnings":"none"},xn={"-S":"string","-a":"none","-d":"none","-f":"none","-h":"none","-k":"none","-s":"string","-w":"none","--all":"none","--apropos":"none","--whatis":"none"},_n={"-I":"string","-L":"none","-a":"none","-f":"string","-g":"none","-i":"none","-l":"none","-m":"none","-n":"none","-r":"none","-s":"none","-v":"none"},Sn={"-?":"none","-A":"string","-C":"none","-E":"none","-F":"none","-H":"none","-K":"none","-L":"none","-N":"none","-O":"none","-P":"none","-Q":"none","-R":"none","-S":"none","-T":"none","-U":"none","-V":"none","-X":"none","-a":"none","-b":"none","-c":"string","-d":"string","-e":"string","-g":"none","-h":"none","-i":"none","-k":"string","-l":"none","-n":"none","-o":"none","-p":"string","-r":"none","-s":"none","-t":"none","-u":"string","-v":"none","-x":"none"},yn={"-F":"string","-G":"string","-L":"none","-O":"string","-P":"string","-U":"string","-V":"none","-a":"none","-c":"none","-d":"string","-f":"none","-g":"string","-i":"none","-l":"none","-n":"none","-o":"none","-r":"string","-s":"string","-t":"string","-u":"string","-v":"none","-w":"none","-x":"none","--count":"none","--delimiter":"string","--euid":"string","--exact":"none","--full":"none","--group":"string","--help":"none","--ignore-case":"none","--inverse":"none","--lightweight":"none","--list-full":"none","--list-name":"none","--logpidfile":"none","--newest":"none","--ns":"string","--nslist":"string","--older":"string","--oldest":"none","--parent":"string","--pgroup":"string","--pidfile":"string","--runstates":"string","--session":"string","--terminal":"string","--uid":"string","--version":"none"},bn={"-T":"string","-V":"none","-x":"none"},En={"-0":"none","-4":"none","-6":"none","-A":"string","-E":"none","-H":"none","-M":"none","-O":"none","-S":"none","-V":"none","-Z":"none","-a":"none","-b":"none","-d":"none","-e":"none","-f":"string","-h":"none","-i":"none","-l":"none","-m":"none","-n":"none","-o":"none","-p":"none","-s":"none","-t":"none","-u":"none","-w":"none","-x":"none","-z":"none","--all":"none","--bpf":"none","--cgroup":"none","--contexts":"none","--context":"none","--dccp":"none","--events":"none","--extended":"none","--family":"string","--help":"none","--inet-sockopt":"none","--info":"none","--ipv4":"none","--ipv6":"none","--listening":"none","--memory":"none","--mptcp":"none","--no-header":"none","--numeric":"none","--oneline":"none","--options":"none","--packet":"none","--processes":"none","--query":"string","--raw":"none","--sctp":"none","--socket":"string","--summary":"none","--tcp":"none","--tipc":"none","--tipcinfo":"none","--tos":"none","--udp":"none","--unix":"none","--version":"none","--vsock":"none"},qe={"-b":"string","-c":"string","-d":"string","-e":"string","-ef":"string","-eq":"string","-f":"string","-g":"string","-G":"string","-ge":"string","-gt":"string","-h":"string","-k":"string","-L":"string","-le":"string","-lt":"string","-N":"string","-n":"string","-ne":"string","-nt":"string","-O":"string","-ot":"string","-p":"string","-r":"string","-s":"string","-S":"string","-t":"string","-u":"string","-w":"string","-x":"string","-z":"string"},kn={"-f":"none","-n":"string","-t":"none","--details":"none","--follow":"none","--since":"string","--tail":"string","--timestamps":"none","--until":"string"},Rn={"-f":"string","-s":"none","--format":"string","--size":"none","--type":"string"},ze={"-R":"string","--repo":"string"},J={...ze,"--json":"string"},W={...J,"-L":"number","--limit":"number"};var lt=/^-[a-zA-Z0-9_-]/,Fn={"-A":"none","-C":"none","-D":"none","-F":"none","-H":"string","-I":"string","-J":"none","-L":"number","-N":"none","-P":"string","-Q":"none","-S":"none","-T":"string","-U":"none","-X":"none","-a":"none","-c":"none","-d":"none","-f":"none","-g":"none","-h":"none","-i":"none","-l":"none","-n":"none","-p":"none","-q":"none","-r":"none","-s":"none","-t":"none","-u":"none","-v":"none","-x":"none","--authority":"string","--charset":"string","--device":"none","--dirsfirst":"none","--du":"none","--fflinks":"none","--filelimit":"number","--filesfirst":"none","--fromfile":"none","--fromtabfile":"none","--gitfile":"string","--gitignore":"none","--help":"none","--hintro":"string","--houtro":"string","--hyperlink":"none","--ignore-case":"none","--inodes":"none","--info":"none","--infofile":"string","--matchdirs":"none","--metafirst":"none","--nolinks":"none","--noreport":"none","--prune":"none","--scheme":"string","--si":"none","--sort":"string","--timefmt":"string","--version":"none"},Tn={"-A":"none","-E":"none","-T":"none","-b":"none","-e":"none","-n":"none","-s":"none","-t":"none","-u":"none","-v":"none","--number":"none","--number-nonblank":"none","--show-all":"none","--show-ends":"none","--show-nonprinting":"none","--show-tabs":"none","--squeeze-blank":"none"},ct={"-c":"number","-n":"number","-q":"none","-v":"none","--bytes":"number","--lines":"number","--quiet":"none","--silent":"none","--verbose":"none"},Ln={"-L":"none","-c":"none","-l":"none","-m":"none","-w":"none","--bytes":"none","--chars":"none","--lines":"none","--max-line-length":"none","--words":"none"},wn={"-A":"number","-B":"number","-C":"number","-F":"none","-H":"none","-L":"none","-N":"none","-S":"none","-T":"string","-c":"none","-e":"string","-g":"string","-h":"none","-i":"none","-l":"none","-m":"number","-n":"none","-s":"none","-t":"string","-u":"none","-v":"none","-w":"none","-x":"none","--after-context":"number","--before-context":"number","--case-sensitive":"none","--context":"number","--count":"none","--count-matches":"none","--files":"none","--files-with-matches":"none","--fixed-strings":"none","--follow":"none","--glob":"string","--hidden":"none","--ignore-case":"none","--ignore-file":"string","--iglob":"string","--invert-match":"none","--json":"none","--line-number":"none","--line-regexp":"none","--max-count":"number","--max-depth":"number","--max-filesize":"string","--no-filename":"none","--no-ignore":"none","--no-ignore-parent":"none","--no-ignore-vcs":"none","--no-line-number":"none","--pcre2":"none","--regexp":"string","--smart-case":"none","--sort":"string","--sortr":"string","--type":"string","--type-not":"string","--unrestricted":"none","--with-filename":"none","--word-regexp":"none"},Qe={"-A":"number","-B":"number","-C":"number","-E":"none","-F":"none","-G":"none","-H":"none","-I":"none","-L":"none","-P":"none","-R":"none","-a":"none","-b":"none","-c":"none","-D":"string","-d":"string","-e":"string","-f":"string","-h":"none","-i":"none","-l":"none","-m":"number","-n":"none","-o":"none","-q":"none","-r":"none","-s":"none","-T":"none","-u":"none","-U":"none","-v":"none","-V":"none","-w":"none","-x":"none","-Z":"none","-z":"none","--after-context":"number","--basic-regexp":"none","--before-context":"number","--binary":"none","--binary-files":"string","--byte-offset":"none","--color":"string","--colour":"string","--context":"number","--count":"none","--dereference-recursive":"none","--directories":"string","--devices":"string","--exclude":"string","--exclude-dir":"string","--exclude-from":"string","--extended-regexp":"none","--file":"string","--files-with-matches":"none","--files-without-match":"none","--fixed-strings":"none","--group-separator":"string","--help":"none","--ignore-case":"none","--include":"string","--initial-tab":"none","--invert-match":"none","--label":"string","--line-buffered":"none","--line-number":"none","--line-regexp":"none","--max-count":"number","--no-group-separator":"none","--no-filename":"none","--no-ignore-case":"none","--no-messages":"none","--null":"none","--null-data":"none","--only-matching":"none","--perl-regexp":"none","--quiet":"none","--recursive":"none","--regexp":"string","--silent":"none","--text":"none","--unix-byte-offsets":"none","--version":"none","--with-filename":"none","--word-regexp":"none"},Dn={"-E":"none","-e":"string","-l":"number","-n":"none","-r":"none","-s":"none","-u":"none","-z":"none","--debug":"none","--expression":"string","--help":"none","--line-length":"number","--posix":"none","--quiet":"none","--regexp-extended":"none","--separate":"none","--silent":"none","--unbuffered":"none","--version":"none","--zero-terminated":"none"},Pn={"-0":"none","-E":"EOF","-I":"{}","-L":"number","-P":"number","-d":"char","-n":"number","-r":"none","-s":"number","-t":"none","-x":"none"},On={"-0":"none","-F":"string","-L":"none","-b":"none","-c":"none","-f":"string","-h":"none","-i":"none","-k":"none","-l":"none","-m":"string","-n":"none","-p":"none","-r":"none","-s":"none","-v":"none","--apple":"none","--brief":"none","--check-encoding":"none","--dereference":"none","--exclude":"string","--exclude-quiet":"string","--help":"none","--keep-going":"none","--list":"none","--magic-file":"string","--mime":"none","--mime-encoding":"none","--mime-type":"none","--no-buffer":"none","--no-dereference":"none","--preserve-date":"none","--print0":"none","--raw":"none","--separator":"string","--special-files":"none","--version":"none"},In={"-C":"none","-M":"none","-S":"none","-c":"none","-e":"none","-n":"none","-r":"none","-s":"none","--color-output":"none","--compact-output":"none","--exit-status":"none","--indent":"number","--monochrome-output":"none","--null-input":"none","--raw-output":"none","--slurp":"none","--sort-keys":"none","--tab":"none"};var Gn=[["git blame",{safeFlags:{...Ce,"-C":"none","-L":"string","-M":"none","-e":"none","-f":"none","-l":"none","-n":"none","-p":"none","-s":"none","-t":"none","-w":"none","--abbrev":"number","--date":"string","--ignore-rev":"string","--ignore-revs-file":"string","--incremental":"none","--line-porcelain":"none","--porcelain":"none","--root":"none","--score-debug":"none","--show-email":"none","--show-name":"none","--show-number":"none","--show-stats":"none"}}],["git branch",{safeFlags:{"-a":"none","-i":"none","-l":"none","-r":"none","-v":"none","-vv":"none","--abbrev":"number","--all":"none","--color":"none","--column":"none","--contains":"string","--ignore-case":"none","--list":"none","--merged":"none","--no-abbrev":"none","--no-color":"none","--no-column":"none","--no-contains":"string","--no-merged":"none","--points-at":"string","--remotes":"none","--show-current":"none","--sort":"string","--verbose":"none"},additionalCommandIsDangerousCallback:Qt}],["git cat-file",{safeFlags:{"-e":"none","-p":"none","-s":"none","-t":"none","--allow-undetermined-type":"none","--batch-check":"none"}}],["git config --get",{safeFlags:{"-z":"none","--bool":"none","--bool-or-int":"none","--default":"string","--expiry-date":"none","--global":"none","--int":"none","--local":"none","--name-only":"none","--null":"none","--path":"none","--show-origin":"none","--show-scope":"none","--system":"none","--type":"string","--worktree":"none"}}],["git describe",{safeFlags:{"--abbrev":"number","--always":"none","--broken":"none","--candidates":"number","--contains":"none","--dirty":"none","--exclude":"string","--exact-match":"none","--first-match":"none","--long":"none","--match":"string","--tags":"none"}}],["git diff",{safeFlags:pn}],["git for-each-ref",{safeFlags:{"--contains":"string","--count":"number","--format":"string","--merged":"string","--no-contains":"string","--no-merged":"string","--points-at":"string","--sort":"string"},additionalCommandIsDangerousCallback:pe}],["git grep",{safeFlags:gn}],["git log",{allowCompactNumericCountFlag:!0,safeFlags:fn,additionalCommandIsDangerousCallback:pe}],["git ls-files",{safeFlags:{"-c":"none","-d":"none","-f":"none","-i":"none","-k":"none","-m":"none","-o":"none","-s":"none","-t":"none","-u":"none","-v":"none","-x":"string","-X":"string","-z":"none","--abbrev":"number","--cached":"none","--debug":"none","--deleted":"none","--directory":"none","--eol":"none","--error-unmatch":"none","--exclude":"string","--exclude-from":"string","--exclude-per-directory":"string","--exclude-standard":"none","--full-name":"none","--ignored":"none","--killed":"none","--modified":"none","--no-empty-directory":"none","--others":"none","--recurse-submodules":"none","--stage":"none","--unmerged":"none"}}]];var Nn=[["git ls-remote",{safeFlags:{"-b":"none","-h":"none","-q":"none","-t":"none","--branches":"none","--exit-code":"none","--get-url":"none","--heads":"none","--quiet":"none","--refs":"none","--sort":"string","--symref":"none","--tags":"none"},additionalCommandIsDangerousCallback:Vt}],["git merge-base",{safeFlags:{"--all":"none","--fork-point":"none","--independent":"none","--is-ancestor":"none","--octopus":"none"}}],["git reflog",{safeFlags:{...be,...ge,...ye,...Ee,...ke,"--grep":"string"},additionalCommandIsDangerousCallback:Ut}],["git remote show",{safeFlags:{"-n":"none"},additionalCommandIsDangerousCallback:qt}],["git remote",{safeFlags:{"-v":"none","--verbose":"none"},additionalCommandIsDangerousCallback:(o,e)=>e.some(t=>t!=="-v"&&t!=="--verbose")}],["git rev-list",{safeFlags:{...ge,...ye,...Ee,"--abbrev":"number","--abbrev-commit":"none","--ancestry-path":"none","--count":"none","--dense":"none","--first-parent":"none","--format":"string","--full-history":"none","--graph":"none","--grep":"string","--max-age":"number","--max-parents":"number","--merges":"none","--min-age":"number","--min-parents":"number","--no-max-parents":"none","--no-merges":"none","--no-min-parents":"none","--oneline":"none","--pretty":"string","--reverse":"none","--skip":"number","--source":"none","--sparse":"none","--walk-reflogs":"none"},additionalCommandIsDangerousCallback:pe}],["git rev-parse",{safeFlags:{"--abbrev-ref":"none","--absolute-git-dir":"none","--git-common-dir":"none","--git-dir":"none","--is-bare-repository":"none","--is-inside-git-dir":"none","--is-inside-work-tree":"none","--is-shallow-repository":"none","--is-shallow-update":"none","--path-prefix":"none","--short":"string","--show-cdup":"none","--show-prefix":"none","--show-superproject-working-tree":"none","--show-toplevel":"none","--symbolic":"none","--symbolic-full-name":"none","--verify":"none"}}],["git shortlog",{safeFlags:{...ge,...ye,"-c":"none","-e":"none","-n":"none","-s":"none","--author":"string","--committer":"none","--email":"none","--format":"string","--group":"string","--no-merges":"none","--numbered":"none","--summary":"none"},additionalCommandIsDangerousCallback:pe}],["git show",{safeFlags:mn,additionalCommandIsDangerousCallback:pe}],["git stash list",{safeFlags:{...be,...ge,...Ee}}],["git stash show",{safeFlags:{...ke,...Ce,...Ve,"--abbrev":"number","--diff-filter":"string","--word-diff":"none","--word-diff-regex":"string"}}],["git status",{safeFlags:un}],["git tag",{safeFlags:{"-i":"none","-l":"none","-n":"number","--column":"none","--contains":"string","--format":"string","--ignore-case":"none","--list":"none","--merged":"string","--no-column":"none","--no-contains":"string","--no-merged":"string","--points-at":"string","--sort":"string"},additionalCommandIsDangerousCallback:zt}],["git worktree list",{safeFlags:{"-v":"none","--expire":"string","--porcelain":"none","--verbose":"none"}}]];var vn=[["docker inspect",{safeFlags:Rn,additionalCommandIsDangerousCallback:rt}],["docker logs",{safeFlags:kn,additionalCommandIsDangerousCallback:rt}],["gh auth status",{safeFlags:{"-a":"none","-h":"string","--active":"none","--hostname":"string","--json":"string"},additionalCommandIsDangerousCallback:R}]];var Bn=[["gh issue list",{safeFlags:{...W,"-s":"string","--app":"string","--assignee":"string","--author":"string","--label":"string","--milestone":"string","--search":"string","--state":"string"},additionalCommandIsDangerousCallback:R}],["gh issue status",{safeFlags:J,additionalCommandIsDangerousCallback:R}],["gh issue view",{safeFlags:{...J,"--comments":"none"},additionalCommandIsDangerousCallback:R}],["gh label list",{safeFlags:{...W,"-S":"string","--order":"string","--search":"string","--sort":"string"},additionalCommandIsDangerousCallback:R}],["gh pr checks",{safeFlags:{...J,"--fail-fast":"none","--interval":"number","--required":"none","--watch":"none"},additionalCommandIsDangerousCallback:R}],["gh pr diff",{safeFlags:{...ze,"--color":"string","--name-only":"none","--patch":"none"},additionalCommandIsDangerousCallback:R}],["gh pr list",{safeFlags:{...W,"-L":"number","-s":"string","--app":"string","--assignee":"string","--author":"string","--base":"string","--draft":"none","--head":"string","--label":"string","--search":"string","--state":"string"},additionalCommandIsDangerousCallback:R}],["gh pr status",{safeFlags:{...J,"-c":"none","--conflict-status":"none"},additionalCommandIsDangerousCallback:R}],["gh pr view",{safeFlags:{...J,"--comments":"none"},additionalCommandIsDangerousCallback:R}],["gh release list",{safeFlags:{...W,"-O":"string","--exclude-drafts":"none","--exclude-pre-releases":"none","--order":"string"},additionalCommandIsDangerousCallback:R}],["gh release view",{safeFlags:J,additionalCommandIsDangerousCallback:R}],["gh repo view",{safeFlags:{"--json":"string"},additionalCommandIsDangerousCallback:R}],["gh run list",{safeFlags:{...W,"-b":"string","-c":"string","-e":"string","-s":"string","-u":"string","-w":"string","--branch":"string","--commit":"string","--created":"string","--event":"string","--status":"string","--user":"string","--workflow":"string"},additionalCommandIsDangerousCallback:R}],["gh run view",{safeFlags:{...J,"-a":"number","-j":"string","-v":"none","--attempt":"number","--exit-status":"none","--job":"string","--log":"none","--log-failed":"none","--verbose":"none"},additionalCommandIsDangerousCallback:R}],["gh search code",{safeFlags:{...W,"--extension":"string","--filename":"string","--language":"string","--match":"string","--owner":"string","--size":"string"}}],["gh search commits",{safeFlags:{...W,"--author":"string","--author-date":"string","--author-email":"string","--author-name":"string","--committer":"string","--committer-date":"string","--committer-email":"string","--committer-name":"string","--hash":"string","--merge":"none","--order":"string","--owner":"string","--parent":"string","--sort":"string","--tree":"string","--visibility":"string"}}],["gh search issues",{safeFlags:{...W,"-R":"string","--app":"string","--assignee":"string","--author":"string","--closed":"string","--commenter":"string","--comments":"string","--created":"string","--include-prs":"none","--interactions":"string","--involves":"string","--label":"string","--language":"string","--locked":"none","--match":"string","--mentions":"string","--milestone":"string","--no-assignee":"none","--no-label":"none","--no-milestone":"none","--no-project":"none","--order":"string","--owner":"string","--project":"string","--reactions":"string","--sort":"string","--state":"string","--team-mentions":"string","--updated":"string","--visibility":"string"}}],["gh search prs",{safeFlags:{...W,"-B":"string","-H":"string","-R":"string","--app":"string","--assignee":"string","--author":"string","--base":"string","--checks":"string","--closed":"string","--commenter":"string","--comments":"string","--created":"string","--draft":"none","--head":"string","--interactions":"string","--involves":"string","--label":"string","--language":"string","--locked":"none","--match":"string","--mentions":"string","--merged":"none","--merged-at":"string","--milestone":"string","--no-assignee":"none","--no-label":"none","--no-milestone":"none","--no-project":"none","--order":"string","--owner":"string","--project":"string","--reactions":"string","--review":"string","--review-requested":"string","--reviewed-by":"string","--sort":"string","--state":"string","--team-mentions":"string","--updated":"string","--visibility":"string"}}],["gh search repos",{safeFlags:{...W,"--archived":"none","--created":"string","--followers":"string","--forks":"string","--good-first-issues":"string","--help-wanted-issues":"string","--include-forks":"string","--language":"string","--license":"string","--match":"string","--number-topics":"string","--order":"string","--owner":"string","--size":"string","--sort":"string","--stars":"string","--topic":"string","--updated":"string","--visibility":"string"}}],["gh workflow list",{safeFlags:{...W,"-a":"none","--all":"none"},additionalCommandIsDangerousCallback:R}],["gh workflow view",{safeFlags:{...ze,"-r":"string","-y":"none","--ref":"string","--yaml":"none"},additionalCommandIsDangerousCallback:R}]];var dt=new Set(["--no-pager","--paginate"]),ht=new Set,Ye=new Set(["-c","-C","--attr-source","--bare","--config-env","--exec-path","--git-dir","--namespace","--shallow-file","--super-prefix","--work-tree"]),ut=new Map([["alias",{commandOnly:!0}],["base64",{safeFlags:cn,respectsDoubleDash:!1}],["cat",{safeFlags:Tn}],["cd",{allowAnyArgs:!0}],["cut",{allowAnyArgs:!0}],["date",{safeFlags:dn,additionalCommandIsDangerousCallback:Xt}],["diff",{allowAnyArgs:!0}],["dirname",{allowAnyArgs:!0}],["du",{allowAnyArgs:!0}],["echo",{allowAnyArgs:!0}],["egrep",{safeFlags:Qe}],["false",{commandOnly:!0}],["fd",{safeFlags:at}],["file",{safeFlags:On}],["find",{allowAnyArgs:!0}],["fgrep",{safeFlags:Qe}],["fdfind",{safeFlags:at}],["grep",{safeFlags:Qe}],["head",{safeFlags:ct}],["help",{safeFlags:{"-d":"none","-m":"none","-s":"none"}}],["hexdump",{allowAnyArgs:!0}],["hostname",{safeFlags:hn,regex:/^hostname(?:\s+(?:-[a-zA-Z]|--[a-zA-Z-]+))*\s*$/}],["id",{allowAnyArgs:!0}],["jq",{safeFlags:In,additionalCommandIsDangerousCallback:Zt}],["lsof",{safeFlags:Sn,additionalCommandIsDangerousCallback:nn}],["ls",{allowAnyArgs:!0}],["man",{safeFlags:xn,additionalCommandIsDangerousCallback:tn}],["md5sum",{safeFlags:Ue}],["netstat",{safeFlags:_n}],["nl",{allowAnyArgs:!0}],["pgrep",{safeFlags:yn}],["ps",{safeFlags:Cn,additionalCommandIsDangerousCallback:Jt}],["pyright",{safeFlags:An,respectsDoubleDash:!1,additionalCommandIsDangerousCallback:en}],["printf",{allowAnyArgs:!0}],["pwd",{commandOnly:!0}],["readlink",{allowAnyArgs:!0}],["realpath",{allowAnyArgs:!0}],["rev",{allowAnyArgs:!0}],["rg",{safeFlags:wn}],["sed",{safeFlags:Dn,additionalCommandIsDangerousCallback:Kt}],["sha1sum",{safeFlags:Ue}],["sha256sum",{safeFlags:Ue}],["sort",{safeFlags:ln}],["ss",{safeFlags:En,additionalCommandIsDangerousCallback:on}],["stat",{allowAnyArgs:!0}],["strings",{allowAnyArgs:!0}],["tail",{safeFlags:ct}],["test",{safeFlags:qe,respectsDoubleDash:!1,additionalCommandIsDangerousCallback:Me}],["tput",{safeFlags:bn,additionalCommandIsDangerousCallback:sn}],["tr",{allowAnyArgs:!0}],["tree",{safeFlags:Fn}],["true",{commandOnly:!0}],["uniq",{allowAnyArgs:!0}],["uname",{allowAnyArgs:!0}],["wc",{safeFlags:Ln}],["which",{allowAnyArgs:!0}],["whoami",{commandOnly:!0}],["xargs",{safeFlags:Pn,additionalCommandIsDangerousCallback:rn}],["[",{safeFlags:qe,respectsDoubleDash:!1,additionalCommandIsDangerousCallback:Me}],["[[",{safeFlags:qe,respectsDoubleDash:!1,additionalCommandIsDangerousCallback:Me}]]),pt=new Set(["basename","cal","cat","cmp","column","comm","cut","df","diff","dirname","du","expand","expr","false","fmt","fold","free","groups","head","hexdump","id","locale","nl","nproc","numfmt","od","paste","pr","readlink","realpath","rev","seq","sleep","stat","strings","tac","tail","tr","true","tsort","type","uname","unexpand","uptime","wc","which"]),ft=[["docker","images"],["docker","ps"]];var Hn=new Map([...Gn,...Nn]),Wn=new Map([...vn,...Bn]);var Ns=new Set(["-delete","-exec","-execdir","-files0-from","-fls","-fprint","-fprint0","-fprintf","-ok","-okdir"]);function mt(o){return Ns.has(o)}var vs=new Set(["-Bmin","-Bnewer","-Btime","-D","-amin","-anewer","-atime","-cmin","-cnewer","-context","-ctime","-f","-flags","-fstype","-gid","-group","-ilname","-iname","-inum","-ipath","-iregex","-iwholename","-lname","-links","-maxdepth","-mindepth","-mmin","-mnewer","-mtime","-name","-newer","-path","-perm","-printf","-regex","-regextype","-samefile","-size","-type","-used","-user","-wholename","-xattrname","-xtype","-uid"]);function Mn(o){if(Hs(o,Bs))return!0;if(o[0]==="docker"&&Ws(o,ft))return!it(o);if(o[0]==="printf")return Ms(o);if(o[0]==="find")return Us(o);if(o[0]==="history")return o.length===1||o.length===2&&/^\d+$/.test(o[1]??"");if(o[0]==="arch")return o.length===1||o.length===2&&(o[1]==="-h"||o[1]==="--help");if(o[0]==="ifconfig")return o.length===1||o.length===2&&/^[a-zA-Z]/.test(o[1]??"")}var Bs=[["ip","addr"],["node","-v"],["node","--version"],["python","--version"],["python3","--version"]];function Hs(o,e){return e.some(t=>o.length===t.length&&t.every((n,s)=>o[s]===n))}function Ws(o,e){return e.some(t=>o.length>=t.length&&t.every((n,s)=>o[s]===n))}function Ms(o){if(o[1]?.startsWith("-")&&o[1]!=="--")return!1;let e=o[1]==="--"?2:1,t=o[e]??"";if(t.includes("$"))return!1;let n=t.replace(/%%/g,"");if(/%[^%a-zA-Z]*(?:hh|ll|[lLhqjzZt])?\\[0-7xX]/.test(n)||/\\[uU]/.test(n))return!1;if(/%[-+ 0#']*[0-9.*]*(?:hh|ll|[lLhqjzZt])?[diouxXeEfFgGaAn]/.test(n)||/%[^%a-zA-Z]*\*/.test(n))for(let r=e+1;r<o.length;r+=1){let i=o[r]??"";if(i.includes("[")||i.includes("`")||i.includes("$(")||!/^[-+]?(0[xX][0-9a-fA-F]+|[0-9]+#[0-9a-zA-Z]+|[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)$/.test(i))return!1}return!0}function Us(o){for(let e=1;e<o.length;e+=1){let t=o[e]??"";if(mt(t))return!1;if(vs.has(t)||/^-newer[aBcm][aBcmt]$/.test(t)){e+=1;continue}}return!0}function Re(o,e,t,n=1){return o.length===0?!1:e.allowAnyArgs?!0:e.commandOnly?o.length===n:e.safeFlags?Vs(o,e,t,n):!1}function Vs(o,e,t,n){let s=e.safeFlags??{},r=n;for(;r<o.length;){let i=o[r];if(!i){r+=1;continue}if(t==="xargs"&&(!i.startsWith("-")||i==="--")){let a=i==="--"?o[r+1]:i;if(!a||!ot.has(a))return!1;break}if(i==="--"){if(e.respectsDoubleDash===!1){r+=1;continue}break}if(zs(t,i)){r+=1;continue}if(e.allowCompactNumericCountFlag&&Qs(i)){r+=1;continue}if(i.startsWith("-")&&i.length>1&<.test(i)){let a=Ys(i),c=s[a.flag];if(!c){let u=qs(i,s);if(u){if(!Un(u.value,t,u.flag)||!Vn(u.value,u.kind))return!1;r+=1;continue}if($s(a.flag,s)){r+=1;continue}return!1}if(c==="none"){if(a.hasInlineValue)return!1;r+=1;continue}if(c==="optionalString"){r+=1;continue}let h=a.hasInlineValue?a.inlineValue:o[r+1];if(!js(h)||c==="string"&&!a.hasInlineValue&&!Un(h,t,a.flag)||!Vn(h,c))return!1;r+=a.hasInlineValue?1:2;continue}r+=1}return!0}function qs(o,e){if(!o.startsWith("-")||o.startsWith("--")||o.length<=2)return;let t=o.slice(0,2),n=e[t];if(!(!n||n==="none"))return{flag:t,kind:n,value:o.slice(2)}}function zs(o,e){return(o==="head"||o==="tail")&&/^-\d+$/.test(e)}function Qs(o){return/^-\d+$/.test(o)}function Ys(o){let e=o.indexOf("=");return e<0?{flag:o,hasInlineValue:!1,inlineValue:""}:{flag:o.slice(0,e),hasInlineValue:!0,inlineValue:o.slice(e+1)}}function $s(o,e){if(!o.startsWith("-")||o.startsWith("--")||o.length<=2)return!1;for(let t of o.slice(1).split("").map(n=>`-${n}`))if(e[t]!=="none")return!1;return!0}function js(o){return o!==void 0}function Un(o,e,t){return!o.startsWith("-")||o.length<=1||!lt.test(o)?!0:e==="git"&&t==="--sort"&&/^-[a-zA-Z]/.test(o)}function Vn(o,e){switch(e){case"none":return!1;case"number":return/^\d+$/.test(o);case"optionalString":return!0;case"string":return!0;case"char":return o.length===1;case"{}":return o==="{}";case"EOF":return o==="EOF"}}var Zs=["-c","-C"];function zn(o){let e=Ks(o);if(!e)return!1;for(let[t,n]of Js()){let s=t.split(" ");if(s.every((r,i)=>e[i]===r))return n.additionalCommandIsDangerousCallback?.(t,e.slice(s.length))?!1:Re(e,n,"git",s.length)}return!1}function Ks(o){let e=["git"];for(let t=1;t<o.length;t+=1){let n=o[t];if(n&&!dt.has(n)){if(Yn(n))return;if(ht.has(n)){if(t+=1,!o[t])return;continue}return n.startsWith("-")?void 0:(e.push(...o.slice(t)),e)}}}function Qn(o){return o.some(Yn)}function Yn(o){return Xs(o)||Ye.has(o)?!0:[...Ye].some(e=>o.startsWith(`${e}=`))}function Xs(o){return Zs.some(e=>o.length>e.length&&o.startsWith(e)&&(e==="-C"||o[e.length]!=="-"))}var qn;function Js(){return qn??=[...Hn.entries()].sort((o,e)=>e[0].split(" ").length-o[0].split(" ").length),qn}var eo=new Set(["ANTHROPIC_API_KEY","BLOCK_SIZE","BLOCKSIZE","CGO_ENABLED","CHARSET","CI","CLICOLOR","CLICOLOR_FORCE","COLORTERM","COLUMNS","DEBIAN_FRONTEND","FORCE_COLOR","GCC_COLORS","GIT_TERMINAL_PROMPT","GO111MODULE","GOARCH","GOEXPERIMENT","GOOS","GREP_COLOR","GREP_COLORS","LANG","LANGUAGE","LC_ALL","LC_CTYPE","LC_TIME","LINES","LSCOLORS","LS_COLORS","NO_COLOR","NODE_ENV","PYTEST_DEBUG","PYTEST_DISABLE_PLUGIN_AUTOLOAD","PYTHONDONTWRITEBYTECODE","PYTHONUNBUFFERED","RUST_BACKTRACE","RUST_LOG","TERM","TIME_STYLE","TZ"]);function $n(o){return o.envAssignments.every(e=>e.name!==void 0&&eo.has(e.name))}var to=new Set(["<","<<","<&","<<<"]);function jn(o){for(let e of o.redirects){if(no(e.target))return!1;if(!(e.operator===">&"&&/^\d+$/.test(e.target))&&e.target!=="/dev/null"){if(to.has(e.operator)){if(gt(e.target))return!1;continue}return!1}}return!0}function no(o){return/^\/dev\/(?:tcp|udp)\//.test(o)}function gt(o){return/^(?:\/\/|\\\\)[^/\\]/.test(o)}function Ct(o){let e=[...o];for(;;){if(e[0]==="command"){let t=1;for(;e[t]!==void 0&&/^-p+$/.test(e[t]??"");)t+=1;if(e[t]==="--"&&(t+=1),t>=e.length||e[t]?.startsWith("-"))return e;e=e.slice(t);continue}if(e[0]==="builtin"){let t=e[1]==="--"?2:1;if(t>=e.length)return e;e=e.slice(t);continue}if(e[0]==="noglob"){if(e.length<=1)return e;e=e.slice(1);continue}return e}}function At(o){if(!$n(o)||!jn(o))return!1;let e=Ct(o.argv);if(e.length===0||e.some(gt))return!1;if(e[0]==="git")return zn(e);let t=Mn(e);if(t!==void 0)return t;let n=so(e,o.commandText);if(n!==void 0)return n;if(pt.has(e[0]??""))return!0;if(process.platform==="win32"&&e[0]==="xargs")return;let s=ut.get(e[0]??"");if(s)return!(e[0]==="cd"&&e.length>2||s.additionalCommandIsDangerousCallback?.(o.commandText,e.slice(1))||!Re(e,s,e[0]??"")||s.regex&&!s.regex.test(o.commandText))}function xt(o){let e=Ct(o.argv),t=e[0];return t==="sed"?e.some(We):t==="find"?e.some(mt):t==="tree"?io(e):t==="git"?Qn(e):!1}function so(o,e){for(let[t,n]of oo()){let s=t.split(" ");if(!s.every((i,a)=>o[a]===i))continue;let r=o.slice(s.length);return!(ro(r)||n.additionalCommandIsDangerousCallback?.(t,r)||!Re(o,n,o[0]??"",s.length)||n.regex&&!n.regex.test(e))}}var Zn;function oo(){return Zn??=[...Wn.entries()].sort((o,e)=>e[0].split(" ").length-o[0].split(" ").length),Zn}function ro(o){return o.some(e=>e.includes("$")||e.includes("{")&&(e.includes(",")||e.includes("..")))}function io(o){for(let e=1;e<o.length;e+=1){let t=o[e];if(t){if(t==="--")return!1;if(t==="-o"||t==="--output"||t.startsWith("--output=")||t.startsWith("-")&&!t.startsWith("--")&&t.slice(1).includes("o"))return!0}}return!1}function ao(o,e){let t=Ft(o);if(!Tt(t)||t.commands.length===0||vt(t.commands)||Nt(t.commands)&&Ht(e))return!1;let n=!1;for(let s of t.commands){if(xt(s))return!1;let r=At(s);if(r===!1)return!1;if(r===!0){n=!0;continue}return!1}return n}export{ao as isRuntimeReadOnlyBashCommand,me as parseBashSyntax};
|