ignitify 0.0.1 → 1.0.0

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/ignitify.cjs ADDED
@@ -0,0 +1,1326 @@
1
+ #!/usr/bin/env node
2
+ var __bundle_url = require("node:url").pathToFileURL(__filename).href;
3
+ "use strict";var Py=Object.create;var Fu=Object.defineProperty;var Cy=Object.getOwnPropertyDescriptor;var Ly=Object.getOwnPropertyNames;var Dy=Object.getPrototypeOf,My=Object.prototype.hasOwnProperty;var Uy=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(r){throw n=[r],r}};var C=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(n){throw t=0,n}};var Fy=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ly(t))!My.call(e,o)&&o!==n&&Fu(e,o,{get:()=>t[o],enumerable:!(r=Cy(t,o))||r.enumerable});return e};var ye=(e,t,n)=>(n=e!=null?Py(Dy(e)):{},Fy(t||!e||!e.__esModule?Fu(n,"default",{value:e,enumerable:!0}):n,e));var y,f=Uy(()=>{y={"runtime-go/go.mod":`// \u26A0\uFE0F PLACEHOLDER module path: Saeed chooses the public name and account (ADR-29 Decision 11, S6).
4
+ // Until then a task carries this directory in its upload and points at it with a \`replace\`.
5
+ module ignitify.local/runtime
6
+
7
+ go 1.22
8
+ `,"runtime-go/runtime.go":`// Package ignitify is the Go client for the Ignitify runtime API (ADR-29 Decision 11).
9
+ //
10
+ // A Go task is a program whose main() calls Start. The build compiles it to /app/bootstrap, and the
11
+ // supervisor starts it with the runtime API's address in the environment and a per-boot token on
12
+ // fd 3. Start then polls for work until the platform says there is none:
13
+ //
14
+ // func main() {
15
+ // ignitify.Start(run, ignitify.WithInit(setup))
16
+ // }
17
+ //
18
+ // func run(payload json.RawMessage, ctx *ignitify.Ctx) (any, error) { ... }
19
+ //
20
+ // The contract is the same as the Node and Python shims (packages/runtime-node, packages/runtime-python):
21
+ // - the token is read from fd 3 FIRST, and never from the environment;
22
+ // - the secrets variable is read and removed before init, so no child process inherits it;
23
+ // - init runs once, before the first invocation;
24
+ // - a warm-up frame runs init and NEVER run: at build time the tenant consented to no effect;
25
+ // - an error or a panic in run is reported, and the loop continues;
26
+ // - exit 0 when there is no more work, 1 when init fails, 2 when the API cannot be reached;
27
+ // - a callback signature is checked by the supervisor (ADR-32 D11): the task never holds the secret.
28
+ //
29
+ // Standard library only: this package is compiled into the tenant's binary, next to their own
30
+ // dependencies, so a dependency of ours could clash with one of theirs.
31
+ package ignitify
32
+
33
+ import (
34
+ "bytes"
35
+ "encoding/hex"
36
+ "encoding/json"
37
+ "errors"
38
+ "fmt"
39
+ "io"
40
+ "net/http"
41
+ "os"
42
+ "strings"
43
+ )
44
+
45
+ const (
46
+ addrEnv = "IGNITIFY_RUNTIME_API"
47
+ codeRootEnv = "IGNITIFY_CODE_ROOT"
48
+ secretsEnv = "__IGNITIFY_SECRETS"
49
+ tokenFD = 3
50
+
51
+ pathNext = "/runtime/invocation/next"
52
+ pathInitError = "/runtime/init/error"
53
+
54
+ exitOK = 0
55
+ exitInitFailed = 1
56
+ exitTransportFailed = 2
57
+ )
58
+
59
+ // RunFunc handles one invocation. The result is sent as JSON.
60
+ type RunFunc func(payload json.RawMessage, ctx *Ctx) (any, error)
61
+
62
+ type options struct {
63
+ init func() error
64
+ }
65
+
66
+ // Option configures Start.
67
+ type Option func(*options)
68
+
69
+ // WithInit sets a function run once, before the first invocation (and for a warm-up).
70
+ func WithInit(f func() error) Option { return func(o *options) { o.init = f } }
71
+
72
+ // CodeRoot is where the task's code drive is mounted (/app in the guest).
73
+ func CodeRoot() string {
74
+ if r := os.Getenv(codeRootEnv); r != "" {
75
+ return r
76
+ }
77
+ return "/app"
78
+ }
79
+
80
+ // Ctx is what run receives for one invocation.
81
+ type Ctx struct {
82
+ // Secrets are the run's secrets, by name.
83
+ Secrets map[string]string
84
+ // Callback is set when this run has an inbound callback; nil otherwise.
85
+ Callback *Callback
86
+
87
+ api *client
88
+ id string
89
+ }
90
+
91
+ // Chunk streams a progress update. It is sent before run returns, so it always arrives before the
92
+ // result. A failure to send is ignored: a chunk is advisory.
93
+ func (c *Ctx) Chunk(data any) { c.signal("chunk", data) }
94
+
95
+ // Ready says the task's inbound listener is up; the platform publishes its route after this.
96
+ func (c *Ctx) Ready() { c.signal("ready", nil) }
97
+
98
+ // Metric records a task metric (a counter unless typ says otherwise). The platform keeps 100 per run.
99
+ func (c *Ctx) Metric(name string, value float64, typ string, attrs map[string]any) {
100
+ if typ == "" {
101
+ typ = "counter"
102
+ }
103
+ c.signal("metric", map[string]any{"name": name, "value": value, "type": typ, "attrs": attrs})
104
+ }
105
+
106
+ func (c *Ctx) signal(kind string, body any) {
107
+ _, _, _ = c.api.post(fmt.Sprintf("/runtime/invocation/%s/%s", c.id, kind), body)
108
+ }
109
+
110
+ // Callback is this run's inbound callback. It holds no secret: the supervisor keeps it (ADR-32 D11).
111
+ type Callback struct {
112
+ URL string
113
+
114
+ api *client
115
+ id string
116
+ }
117
+
118
+ // Verify asks the supervisor whether signature signs the RAW request body
119
+ // (POST \u2026/callback/verify). The supervisor checks it with this run's own secret, the host's scheme:
120
+ // HMAC-SHA256, hex, an optional "sha256=" prefix. It fails closed: false for a transport error, any
121
+ // status but 200, or a reply that is not {"valid": true}.
122
+ func (cb *Callback) Verify(body []byte, signature string) bool {
123
+ if cb == nil || cb.api == nil {
124
+ return false
125
+ }
126
+ req := map[string]string{"body_hex": hex.EncodeToString(body), "signature": signature}
127
+ status, reply, err := cb.api.post("/runtime/invocation/"+cb.id+"/callback/verify", req)
128
+ if err != nil || status != http.StatusOK {
129
+ return false
130
+ }
131
+ var r struct {
132
+ Valid bool \`json:"valid"\`
133
+ }
134
+ return json.Unmarshal(reply, &r) == nil && r.Valid
135
+ }
136
+
137
+ type client struct {
138
+ base string
139
+ token string
140
+ http *http.Client
141
+ }
142
+
143
+ func (c *client) do(method, path string, body io.Reader) (int, []byte, error) {
144
+ req, err := http.NewRequest(method, c.base+path, body)
145
+ if err != nil {
146
+ return 0, nil, err
147
+ }
148
+ req.Header.Set("Authorization", "Bearer "+c.token)
149
+ if body != nil {
150
+ req.Header.Set("Content-Type", "application/json")
151
+ }
152
+ res, err := c.http.Do(req)
153
+ if err != nil {
154
+ return 0, nil, err
155
+ }
156
+ defer res.Body.Close()
157
+ b, err := io.ReadAll(res.Body)
158
+ return res.StatusCode, b, err
159
+ }
160
+
161
+ func (c *client) post(path string, v any) (int, []byte, error) {
162
+ b, err := json.Marshal(v)
163
+ if err != nil {
164
+ return 0, nil, err
165
+ }
166
+ return c.do(http.MethodPost, path, bytes.NewReader(b))
167
+ }
168
+
169
+ type invocation struct {
170
+ ID string \`json:"id"\`
171
+ TaskName string \`json:"task_name"\`
172
+ Payload json.RawMessage \`json:"payload"\`
173
+ Warmup bool \`json:"warmup"\`
174
+ Callback *struct {
175
+ URL string \`json:"url"\`
176
+ } \`json:"callback"\`
177
+ }
178
+
179
+ func readToken() (string, error) {
180
+ f := os.NewFile(tokenFD, "ignitify-token")
181
+ if f == nil {
182
+ return "", errors.New("runtime token: fd 3 is not open. This process must be started by the supervisor")
183
+ }
184
+ defer f.Close()
185
+ raw, err := io.ReadAll(f)
186
+ if err != nil {
187
+ return "", fmt.Errorf("runtime token: fd 3 is not readable (%v). This process must be started by the supervisor", err)
188
+ }
189
+ t := strings.TrimSpace(string(raw))
190
+ if t == "" {
191
+ return "", errors.New("runtime token: fd 3 was empty")
192
+ }
193
+ return t, nil
194
+ }
195
+
196
+ func readSecrets() map[string]string {
197
+ raw, ok := os.LookupEnv(secretsEnv)
198
+ os.Unsetenv(secretsEnv)
199
+ out := map[string]string{}
200
+ if ok && raw != "" {
201
+ _ = json.Unmarshal([]byte(raw), &out)
202
+ }
203
+ return out
204
+ }
205
+
206
+ // Start runs the poll loop and exits the process; it never returns.
207
+ func Start(run RunFunc, opts ...Option) {
208
+ os.Exit(serve(run, opts...))
209
+ }
210
+
211
+ func fail(format string, a ...any) {
212
+ fmt.Fprintf(os.Stderr, "[bootstrap] "+format+"\\n", a...)
213
+ }
214
+
215
+ // protect calls f, turning a panic into an error.
216
+ func protect(f func() (any, error)) (v any, err error) {
217
+ defer func() {
218
+ if r := recover(); r != nil {
219
+ err = fmt.Errorf("panic: %v", r)
220
+ }
221
+ }()
222
+ return f()
223
+ }
224
+
225
+ func serve(run RunFunc, opts ...Option) int {
226
+ o := &options{}
227
+ for _, opt := range opts {
228
+ opt(o)
229
+ }
230
+ base := os.Getenv(addrEnv)
231
+ if base == "" {
232
+ fail("%s is not set \u2014 this process must be started by the supervisor", addrEnv)
233
+ return exitInitFailed
234
+ }
235
+ // Token FIRST, before the secrets and before any tenant code.
236
+ token, err := readToken()
237
+ if err != nil {
238
+ fail("%v", err)
239
+ return exitInitFailed
240
+ }
241
+ secrets := readSecrets()
242
+ // \u26D4 No proxy: an HTTP_PROXY in the tenant's environment must never carry our loopback calls.
243
+ api := &client{base: base, token: token, http: &http.Client{Transport: &http.Transport{Proxy: nil}}}
244
+
245
+ initDone := false
246
+ for {
247
+ status, body, err := api.do(http.MethodGet, pathNext, nil)
248
+ if err != nil {
249
+ fail("runtime api unreachable: %v", err)
250
+ return exitTransportFailed
251
+ }
252
+ switch {
253
+ case status == http.StatusGone:
254
+ return exitOK
255
+ case status == http.StatusUnauthorized:
256
+ fail("runtime api rejected the token")
257
+ return exitTransportFailed
258
+ case status != http.StatusOK:
259
+ fail("runtime api returned %d", status)
260
+ return exitTransportFailed
261
+ }
262
+ var inv invocation
263
+ if err := json.Unmarshal(body, &inv); err != nil {
264
+ fail("runtime api sent an invalid invocation: %v", err)
265
+ return exitTransportFailed
266
+ }
267
+
268
+ if !initDone {
269
+ initDone = true // once, even when it fails: the process exits below
270
+ if o.init != nil {
271
+ if _, err := protect(func() (any, error) { return nil, o.init() }); err != nil {
272
+ fail("init failed: %v", err)
273
+ _, _, _ = api.post(pathInitError, map[string]string{"error": err.Error()})
274
+ return exitInitFailed
275
+ }
276
+ }
277
+ }
278
+
279
+ // \u26D4 A warm-up ends here: init is the whole check, and run would be an effect nobody asked for.
280
+ if inv.Warmup {
281
+ if _, _, err := api.post("/runtime/invocation/"+inv.ID+"/response", nil); err != nil {
282
+ fail("runtime api unreachable: %v", err)
283
+ return exitTransportFailed
284
+ }
285
+ continue
286
+ }
287
+
288
+ ctx := &Ctx{Secrets: secrets, api: api, id: inv.ID}
289
+ if inv.Callback != nil && inv.Callback.URL != "" {
290
+ ctx.Callback = &Callback{URL: inv.Callback.URL, api: api, id: inv.ID}
291
+ }
292
+ payload := inv.Payload
293
+ if len(payload) == 0 {
294
+ payload = json.RawMessage("null")
295
+ }
296
+ result, runErr := protect(func() (any, error) { return run(payload, ctx) })
297
+ var encoded []byte
298
+ if runErr == nil {
299
+ encoded, runErr = json.Marshal(result)
300
+ if runErr != nil {
301
+ runErr = fmt.Errorf("the result of run is not JSON: %w", runErr)
302
+ }
303
+ }
304
+ var postErr error
305
+ if runErr != nil {
306
+ fail("run failed: %v", runErr)
307
+ _, _, postErr = api.post("/runtime/invocation/"+inv.ID+"/error", map[string]string{"error": runErr.Error()})
308
+ } else {
309
+ _, _, postErr = api.do(http.MethodPost, "/runtime/invocation/"+inv.ID+"/response", bytes.NewReader(encoded))
310
+ }
311
+ if postErr != nil {
312
+ fail("runtime api unreachable: %v", postErr)
313
+ return exitTransportFailed
314
+ }
315
+ }
316
+ }
317
+ `,"runtime-rust/Cargo.toml":`# \u26A0\uFE0F PLACEHOLDER name: Saeed chooses the public name and account (ADR-29 Decision 11, S6). Until then a
318
+ # task carries this directory in its upload and depends on it with \`path = \u2026\`.
319
+ [package]
320
+ name = "ignitify-runtime"
321
+ version = "0.1.0"
322
+ edition = "2021"
323
+ rust-version = "1.75"
324
+ description = "The Rust client for the Ignitify runtime API"
325
+ # The terms of this client: section 2 of the Ignitify CLI licence (the file LICENSE in the npm
326
+ # package \`ignitify\`, source \`apps/cli/LICENSE\`; ADR-42 D6). You may use, copy, change and share it
327
+ # as part of your own code. \`LicenseRef-\` is the SPDX form for a licence that has no SPDX id.
328
+ license = "LicenseRef-Ignitify-CLI-Licence"
329
+ publish = false
330
+
331
+ # Its OWN workspace: the repository root is a Cargo workspace (the host daemon), and a crate below it
332
+ # that is not a member would otherwise be refused. This crate is compiled into TENANT binaries, never
333
+ # into the platform, so it must not share the daemon's lockfile.
334
+ [workspace]
335
+
336
+ [dependencies]
337
+ serde_json = "1"
338
+ `,"runtime-rust/src/lib.rs":`//! The Rust client for the Ignitify runtime API (ADR-29 Decision 11).
339
+ //!
340
+ //! A Rust task is a program whose \`main\` calls [\`start\`]. The build compiles it to \`/app/bootstrap\`,
341
+ //! and the supervisor starts it with the runtime API's address in the environment and a per-boot
342
+ //! token on fd 3. \`start\` polls for work until the platform says there is none:
343
+ //!
344
+ //! \`\`\`no_run
345
+ //! // in main():
346
+ //! ignitify_runtime::start(
347
+ //! || Ok(()),
348
+ //! |payload, ctx| {
349
+ //! ctx.chunk(&serde_json::json!({ "step": 1 }));
350
+ //! Ok(payload)
351
+ //! },
352
+ //! );
353
+ //! \`\`\`
354
+ //!
355
+ //! The contract is the Node and Python shims' (packages/runtime-node, packages/runtime-python):
356
+ //! - the token is read from fd 3 FIRST, never from the environment;
357
+ //! - the secrets variable is read and removed before \`init\`, so no child process inherits it;
358
+ //! - \`init\` runs once, before the first invocation;
359
+ //! - a warm-up frame runs \`init\` and NEVER \`run\`: at build time the tenant consented to no effect;
360
+ //! - an error or a panic in \`run\` is reported, and the loop continues;
361
+ //! - exit 0 when there is no more work, 1 when \`init\` fails, 2 when the API cannot be reached;
362
+ //! - a callback signature is checked by the supervisor (ADR-32 D11): the task never holds the secret.
363
+ //!
364
+ //! No async runtime and no HTTP crate: a small blocking HTTP/1.1 client on loopback, so this crate
365
+ //! adds one well-known dependency (\`serde_json\`) to the tenant's build and nothing else. A task
366
+ //! that needs async makes its own runtime in \`init\`.
367
+
368
+ use serde_json::{json, Value};
369
+ use std::collections::HashMap;
370
+ use std::error::Error;
371
+ use std::fs::File;
372
+ use std::io::{Read, Write};
373
+ use std::net::TcpStream;
374
+ use std::os::fd::FromRawFd;
375
+ use std::panic::{self, AssertUnwindSafe};
376
+
377
+ const ADDR_ENV: &str = "IGNITIFY_RUNTIME_API";
378
+ const CODE_ROOT_ENV: &str = "IGNITIFY_CODE_ROOT";
379
+ const SECRETS_ENV: &str = "__IGNITIFY_SECRETS";
380
+ const TOKEN_FD: i32 = 3;
381
+
382
+ const EXIT_OK: i32 = 0;
383
+ const EXIT_INIT_FAILED: i32 = 1;
384
+ const EXIT_TRANSPORT_FAILED: i32 = 2;
385
+
386
+ /// What \`run\` and \`init\` may return as an error.
387
+ pub type BoxError = Box<dyn Error + Send + Sync>;
388
+
389
+ /// Where the task's code drive is mounted (\`/app\` in the guest).
390
+ pub fn code_root() -> String {
391
+ std::env::var(CODE_ROOT_ENV).unwrap_or_else(|_| "/app".to_string())
392
+ }
393
+
394
+ /// This run's inbound callback. It holds no secret: the supervisor keeps it (ADR-32 D11).
395
+ pub struct Callback {
396
+ pub url: String,
397
+ api: Client,
398
+ id: String,
399
+ }
400
+
401
+ impl Callback {
402
+ /// Ask the supervisor whether \`signature\` signs the RAW request body (\`POST \u2026/callback/verify\`).
403
+ /// The supervisor checks it with this run's own secret, the host's scheme: HMAC-SHA256, hex, an
404
+ /// optional \`sha256=\` prefix. Fails closed: false for a transport error, any status but 200, or
405
+ /// a reply that is not \`{"valid": true}\`.
406
+ pub fn verify(&self, body: &[u8], signature: &str) -> bool {
407
+ let req = json!({ "body_hex": hex(body), "signature": signature });
408
+ match self.api.post(
409
+ &format!("/runtime/invocation/{}/callback/verify", self.id),
410
+ req.to_string().as_bytes(),
411
+ ) {
412
+ Ok((200, reply)) => serde_json::from_slice::<Value>(&reply)
413
+ .map(|v| v["valid"].as_bool() == Some(true))
414
+ .unwrap_or(false),
415
+ _ => false,
416
+ }
417
+ }
418
+ }
419
+
420
+ /// Lower-case hex of \`bytes\`, with std only.
421
+ fn hex(bytes: &[u8]) -> String {
422
+ use std::fmt::Write as _;
423
+ let mut out = String::with_capacity(bytes.len() * 2);
424
+ for b in bytes {
425
+ let _ = write!(out, "{b:02x}");
426
+ }
427
+ out
428
+ }
429
+
430
+ /// What \`run\` receives for one invocation.
431
+ pub struct Ctx {
432
+ /// The run's secrets, by name.
433
+ pub secrets: HashMap<String, String>,
434
+ /// Set when this run has an inbound callback.
435
+ pub callback: Option<Callback>,
436
+ api: Client,
437
+ id: String,
438
+ }
439
+
440
+ impl Ctx {
441
+ /// Stream a progress update. Sent before \`run\` returns, so it always arrives before the result.
442
+ /// A failure to send is ignored: a chunk is advisory.
443
+ pub fn chunk(&self, data: &Value) {
444
+ self.signal("chunk", data);
445
+ }
446
+ /// Say the task's inbound listener is up; the platform publishes its route after this.
447
+ pub fn ready(&self) {
448
+ self.signal("ready", &Value::Null);
449
+ }
450
+ /// Record a task metric (\`"counter"\` unless \`kind\` says otherwise). The platform keeps 100 per run.
451
+ pub fn metric(&self, name: &str, value: f64, kind: Option<&str>, attrs: Option<Value>) {
452
+ let body = json!({ "name": name, "value": value, "type": kind.unwrap_or("counter"), "attrs": attrs });
453
+ self.signal("metric", &body);
454
+ }
455
+ fn signal(&self, kind: &str, body: &Value) {
456
+ let _ = self.api.post(
457
+ &format!("/runtime/invocation/{}/{}", self.id, kind),
458
+ body.to_string().as_bytes(),
459
+ );
460
+ }
461
+ }
462
+
463
+ #[derive(Clone)]
464
+ struct Client {
465
+ host_port: String,
466
+ token: String,
467
+ }
468
+
469
+ impl Client {
470
+ fn new(base: &str, token: String) -> Result<Self, String> {
471
+ let rest = base
472
+ .strip_prefix("http://")
473
+ .ok_or_else(|| format!("{ADDR_ENV} must be an http:// URL, got {base:?}"))?;
474
+ Ok(Client {
475
+ host_port: rest.trim_end_matches('/').to_string(),
476
+ token,
477
+ })
478
+ }
479
+
480
+ /// One request on its own connection (\`Connection: close\`): on loopback it costs well under a
481
+ /// millisecond, and a long GET /next cut by the supervisor leaves nothing half-open.
482
+ fn request(
483
+ &self,
484
+ method: &str,
485
+ path: &str,
486
+ body: Option<&[u8]>,
487
+ ) -> Result<(u16, Vec<u8>), String> {
488
+ let mut s = TcpStream::connect(&self.host_port)
489
+ .map_err(|e| format!("runtime api unreachable: {e}"))?;
490
+ let body = body.unwrap_or(b"");
491
+ let head = format!(
492
+ "{method} {path} HTTP/1.1\\r\\nHost: {}\\r\\nAuthorization: Bearer {}\\r\\nContent-Type: application/json\\r\\nContent-Length: {}\\r\\nConnection: close\\r\\n\\r\\n",
493
+ self.host_port,
494
+ self.token,
495
+ body.len()
496
+ );
497
+ s.write_all(head.as_bytes())
498
+ .and_then(|_| s.write_all(body))
499
+ .map_err(|e| format!("runtime api unreachable: {e}"))?;
500
+ let mut raw = Vec::new();
501
+ s.read_to_end(&mut raw)
502
+ .map_err(|e| format!("runtime api unreachable: {e}"))?;
503
+ let split = raw
504
+ .windows(4)
505
+ .position(|w| w == b"\\r\\n\\r\\n")
506
+ .ok_or("runtime api sent no header")?;
507
+ let head = String::from_utf8_lossy(&raw[..split]);
508
+ let status: u16 = head
509
+ .split_whitespace()
510
+ .nth(1)
511
+ .and_then(|c| c.parse().ok())
512
+ .ok_or("runtime api sent no status")?;
513
+ // The runtime API always answers with Content-Length (\`runtime-api.js\` \`send\`), never
514
+ // chunked, and \`Connection: close\` ends the body \u2014 so the rest of the stream IS the body.
515
+ Ok((status, raw[split + 4..].to_vec()))
516
+ }
517
+
518
+ fn post(&self, path: &str, body: &[u8]) -> Result<(u16, Vec<u8>), String> {
519
+ self.request("POST", path, Some(body))
520
+ }
521
+ }
522
+
523
+ fn fail(msg: &str) {
524
+ eprintln!("[bootstrap] {msg}");
525
+ }
526
+
527
+ fn read_token() -> Result<String, String> {
528
+ // SAFETY: fd 3 is the pipe the supervisor opened for this process; it is read once, then closed.
529
+ let mut f = unsafe { File::from_raw_fd(TOKEN_FD) };
530
+ let mut raw = String::new();
531
+ f.read_to_string(&mut raw)
532
+ .map_err(|e| format!("runtime token: fd 3 is not readable ({e}). This process must be started by the supervisor"))?;
533
+ let t = raw.trim().to_string();
534
+ if t.is_empty() {
535
+ return Err("runtime token: fd 3 was empty".into());
536
+ }
537
+ Ok(t)
538
+ }
539
+
540
+ fn read_secrets() -> HashMap<String, String> {
541
+ let raw = std::env::var(SECRETS_ENV).ok();
542
+ std::env::remove_var(SECRETS_ENV);
543
+ raw.and_then(|r| serde_json::from_str(&r).ok())
544
+ .unwrap_or_default()
545
+ }
546
+
547
+ fn panic_message(p: Box<dyn std::any::Any + Send>) -> String {
548
+ if let Some(s) = p.downcast_ref::<&str>() {
549
+ format!("panic: {s}")
550
+ } else if let Some(s) = p.downcast_ref::<String>() {
551
+ format!("panic: {s}")
552
+ } else {
553
+ "panic".into()
554
+ }
555
+ }
556
+
557
+ /// Run the poll loop and exit the process; never returns.
558
+ pub fn start<I, R>(init: I, run: R) -> !
559
+ where
560
+ I: FnOnce() -> Result<(), BoxError>,
561
+ R: FnMut(Value, &Ctx) -> Result<Value, BoxError>,
562
+ {
563
+ let code = serve(init, run);
564
+ let _ = std::io::stdout().flush();
565
+ std::process::exit(code)
566
+ }
567
+
568
+ fn serve<I, R>(init: I, mut run: R) -> i32
569
+ where
570
+ I: FnOnce() -> Result<(), BoxError>,
571
+ R: FnMut(Value, &Ctx) -> Result<Value, BoxError>,
572
+ {
573
+ let Ok(base) = std::env::var(ADDR_ENV) else {
574
+ fail(&format!(
575
+ "{ADDR_ENV} is not set \u2014 this process must be started by the supervisor"
576
+ ));
577
+ return EXIT_INIT_FAILED;
578
+ };
579
+ // Token FIRST, before the secrets and before any tenant code.
580
+ let token = match read_token() {
581
+ Ok(t) => t,
582
+ Err(e) => {
583
+ fail(&e);
584
+ return EXIT_INIT_FAILED;
585
+ }
586
+ };
587
+ let secrets = read_secrets();
588
+ let api = match Client::new(&base, token) {
589
+ Ok(c) => c,
590
+ Err(e) => {
591
+ fail(&e);
592
+ return EXIT_INIT_FAILED;
593
+ }
594
+ };
595
+
596
+ let mut init = Some(init);
597
+ loop {
598
+ let (status, body) = match api.request("GET", "/runtime/invocation/next", None) {
599
+ Ok(r) => r,
600
+ Err(e) => {
601
+ fail(&e);
602
+ return EXIT_TRANSPORT_FAILED;
603
+ }
604
+ };
605
+ match status {
606
+ 410 => return EXIT_OK,
607
+ 401 => {
608
+ fail("runtime api rejected the token");
609
+ return EXIT_TRANSPORT_FAILED;
610
+ }
611
+ 200 => {}
612
+ other => {
613
+ fail(&format!("runtime api returned {other}"));
614
+ return EXIT_TRANSPORT_FAILED;
615
+ }
616
+ }
617
+ let inv: Value = match serde_json::from_slice(&body) {
618
+ Ok(v) => v,
619
+ Err(e) => {
620
+ fail(&format!("runtime api sent an invalid invocation: {e}"));
621
+ return EXIT_TRANSPORT_FAILED;
622
+ }
623
+ };
624
+ let id = inv["id"].as_str().unwrap_or_default().to_string();
625
+
626
+ if let Some(f) = init.take() {
627
+ let outcome = panic::catch_unwind(AssertUnwindSafe(f))
628
+ .unwrap_or_else(|p| Err(panic_message(p).into()));
629
+ if let Err(e) = outcome {
630
+ let msg = e.to_string();
631
+ fail(&format!("init failed: {msg}"));
632
+ let _ = api.post(
633
+ "/runtime/init/error",
634
+ json!({ "error": msg }).to_string().as_bytes(),
635
+ );
636
+ return EXIT_INIT_FAILED;
637
+ }
638
+ }
639
+
640
+ // \u26D4 A warm-up ends here: init is the whole check, and run would be an effect nobody asked for.
641
+ if inv["warmup"].as_bool() == Some(true) {
642
+ if let Err(e) = api.post(&format!("/runtime/invocation/{id}/response"), b"null") {
643
+ fail(&e);
644
+ return EXIT_TRANSPORT_FAILED;
645
+ }
646
+ continue;
647
+ }
648
+
649
+ let callback = match inv["callback"]["url"].as_str() {
650
+ Some(url) if !url.is_empty() => Some(Callback {
651
+ url: url.to_string(),
652
+ api: api.clone(),
653
+ id: id.clone(),
654
+ }),
655
+ _ => None,
656
+ };
657
+ let ctx = Ctx {
658
+ secrets: secrets.clone(),
659
+ callback,
660
+ api: api.clone(),
661
+ id: id.clone(),
662
+ };
663
+ let payload = inv.get("payload").cloned().unwrap_or(Value::Null);
664
+ let outcome = panic::catch_unwind(AssertUnwindSafe(|| run(payload, &ctx)))
665
+ .unwrap_or_else(|p| Err(panic_message(p).into()));
666
+ let sent = match outcome {
667
+ Ok(v) => api.post(
668
+ &format!("/runtime/invocation/{id}/response"),
669
+ v.to_string().as_bytes(),
670
+ ),
671
+ Err(e) => {
672
+ fail(&format!("run failed: {e}"));
673
+ api.post(
674
+ &format!("/runtime/invocation/{id}/error"),
675
+ json!({ "error": e.to_string() }).to_string().as_bytes(),
676
+ )
677
+ }
678
+ };
679
+ if let Err(e) = sent {
680
+ fail(&e);
681
+ return EXIT_TRANSPORT_FAILED;
682
+ }
683
+ }
684
+ }
685
+
686
+ #[cfg(test)]
687
+ mod tests {
688
+ use super::*;
689
+ use std::net::TcpListener;
690
+ use std::thread;
691
+
692
+ /// A one-request server: answers \`reply\` and hands back the raw request it read.
693
+ fn serve_once(reply: String) -> (Callback, thread::JoinHandle<String>) {
694
+ let l = TcpListener::bind("127.0.0.1:0").unwrap();
695
+ let base = format!("http://{}", l.local_addr().unwrap());
696
+ let h = thread::spawn(move || {
697
+ let (mut s, _) = l.accept().unwrap();
698
+ let mut raw = Vec::new();
699
+ let mut buf = [0u8; 4096];
700
+ // Read the head, then exactly Content-Length bytes of body.
701
+ loop {
702
+ let n = s.read(&mut buf).unwrap();
703
+ raw.extend_from_slice(&buf[..n]);
704
+ let text = String::from_utf8_lossy(&raw).to_string();
705
+ if let Some(at) = text.find("\\r\\n\\r\\n") {
706
+ let len: usize = text
707
+ .lines()
708
+ .find_map(|l| l.strip_prefix("Content-Length: "))
709
+ .and_then(|v| v.trim().parse().ok())
710
+ .unwrap_or(0);
711
+ if raw.len() >= at + 4 + len || n == 0 {
712
+ break;
713
+ }
714
+ }
715
+ }
716
+ s.write_all(reply.as_bytes()).unwrap();
717
+ String::from_utf8_lossy(&raw).to_string()
718
+ });
719
+ let cb = Callback {
720
+ url: "https://cb.example/n".into(),
721
+ api: Client::new(&base, "tok".into()).unwrap(),
722
+ id: "inv-1".into(),
723
+ };
724
+ (cb, h)
725
+ }
726
+
727
+ fn http(status: &str, body: &str) -> String {
728
+ let len = body.len();
729
+ format!("HTTP/1.1 {status}\\r\\nContent-Length: {len}\\r\\nConnection: close\\r\\n\\r\\n{body}")
730
+ }
731
+
732
+ #[test]
733
+ fn verify_asks_the_supervisor_with_the_raw_body_as_hex() {
734
+ let (cb, h) = serve_once(http("200 OK", r#"{"valid":true}"#));
735
+ assert!(cb.verify(&[b'{', 0xff, b'}'], " sha256=ABC"));
736
+ let req = h.join().unwrap();
737
+ assert!(req.starts_with("POST /runtime/invocation/inv-1/callback/verify HTTP/1.1\\r\\n"));
738
+ assert!(req.contains("Authorization: Bearer tok\\r\\n"));
739
+ assert!(req.contains("Content-Type: application/json\\r\\n"));
740
+ let body: Value = serde_json::from_str(req.split("\\r\\n\\r\\n").nth(1).unwrap()).unwrap();
741
+ assert_eq!(
742
+ body,
743
+ json!({ "body_hex": "7bff7d", "signature": " sha256=ABC" })
744
+ );
745
+ }
746
+
747
+ #[test]
748
+ fn verify_fails_closed() {
749
+ for reply in [
750
+ http("200 OK", r#"{"valid":false}"#),
751
+ http(
752
+ "404 Not Found",
753
+ r#"{"error":"no callback for this invocation"}"#,
754
+ ),
755
+ http("500 Internal Server Error", r#"{"valid":true}"#),
756
+ http("200 OK", "yes"),
757
+ http("200 OK", r#"{"valid":"true"}"#),
758
+ ] {
759
+ let (cb, h) = serve_once(reply.clone());
760
+ assert!(!cb.verify(b"{}", "sha256=00"), "verified on {reply:?}");
761
+ h.join().unwrap();
762
+ }
763
+ // Nothing listens on the port any more: a transport error.
764
+ let l = TcpListener::bind("127.0.0.1:0").unwrap();
765
+ let base = format!("http://{}", l.local_addr().unwrap());
766
+ drop(l);
767
+ let cb = Callback {
768
+ url: String::new(),
769
+ api: Client::new(&base, "tok".into()).unwrap(),
770
+ id: "x".into(),
771
+ };
772
+ assert!(!cb.verify(b"{}", "s"));
773
+ }
774
+ }
775
+ `,"runtime-rust/Cargo.lock":`# This file is automatically @generated by Cargo.
776
+ # It is not intended for manual editing.
777
+ version = 3
778
+
779
+ [[package]]
780
+ name = "ignitify-runtime"
781
+ version = "0.1.0"
782
+ dependencies = [
783
+ "serde_json",
784
+ ]
785
+
786
+ [[package]]
787
+ name = "itoa"
788
+ version = "1.0.18"
789
+ source = "registry+https://github.com/rust-lang/crates.io-index"
790
+ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
791
+
792
+ [[package]]
793
+ name = "memchr"
794
+ version = "2.8.3"
795
+ source = "registry+https://github.com/rust-lang/crates.io-index"
796
+ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
797
+
798
+ [[package]]
799
+ name = "proc-macro2"
800
+ version = "1.0.107"
801
+ source = "registry+https://github.com/rust-lang/crates.io-index"
802
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
803
+ dependencies = [
804
+ "unicode-ident",
805
+ ]
806
+
807
+ [[package]]
808
+ name = "quote"
809
+ version = "1.0.47"
810
+ source = "registry+https://github.com/rust-lang/crates.io-index"
811
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
812
+ dependencies = [
813
+ "proc-macro2",
814
+ ]
815
+
816
+ [[package]]
817
+ name = "serde"
818
+ version = "1.0.229"
819
+ source = "registry+https://github.com/rust-lang/crates.io-index"
820
+ checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
821
+ dependencies = [
822
+ "serde_core",
823
+ ]
824
+
825
+ [[package]]
826
+ name = "serde_core"
827
+ version = "1.0.229"
828
+ source = "registry+https://github.com/rust-lang/crates.io-index"
829
+ checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
830
+ dependencies = [
831
+ "serde_derive",
832
+ ]
833
+
834
+ [[package]]
835
+ name = "serde_derive"
836
+ version = "1.0.229"
837
+ source = "registry+https://github.com/rust-lang/crates.io-index"
838
+ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
839
+ dependencies = [
840
+ "proc-macro2",
841
+ "quote",
842
+ "syn",
843
+ ]
844
+
845
+ [[package]]
846
+ name = "serde_json"
847
+ version = "1.0.151"
848
+ source = "registry+https://github.com/rust-lang/crates.io-index"
849
+ checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"
850
+ dependencies = [
851
+ "itoa",
852
+ "memchr",
853
+ "serde",
854
+ "serde_core",
855
+ "zmij",
856
+ ]
857
+
858
+ [[package]]
859
+ name = "syn"
860
+ version = "3.0.6"
861
+ source = "registry+https://github.com/rust-lang/crates.io-index"
862
+ checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
863
+ dependencies = [
864
+ "proc-macro2",
865
+ "quote",
866
+ "unicode-ident",
867
+ ]
868
+
869
+ [[package]]
870
+ name = "unicode-ident"
871
+ version = "1.0.26"
872
+ source = "registry+https://github.com/rust-lang/crates.io-index"
873
+ checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
874
+
875
+ [[package]]
876
+ name = "zmij"
877
+ version = "1.0.23"
878
+ source = "registry+https://github.com/rust-lang/crates.io-index"
879
+ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
880
+ `}});var zr=C(ce=>{"use strict";f();Object.defineProperty(ce,"__esModule",{value:!0});ce.regexpCode=ce.getEsmExportName=ce.getProperty=ce.safeStringify=ce.stringify=ce.strConcat=ce.addCodeArg=ce.str=ce._=ce.nil=ce._Code=ce.Name=ce.IDENTIFIER=ce._CodeOrName=void 0;var Yr=class{};ce._CodeOrName=Yr;ce.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Tn=class extends Yr{constructor(t){if(super(),!ce.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};ce.Name=Tn;var nt=class extends Yr{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((n,r)=>`${n}${r}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((n,r)=>(r instanceof Tn&&(n[r.str]=(n[r.str]||0)+1),n),{})}};ce._Code=nt;ce.nil=new nt("");function Ip(e,...t){let n=[e[0]],r=0;for(;r<t.length;)Ka(n,t[r]),n.push(e[++r]);return new nt(n)}ce._=Ip;var qa=new nt("+");function Np(e,...t){let n=[Wr(e[0])],r=0;for(;r<t.length;)n.push(qa),Ka(n,t[r]),n.push(qa,Wr(e[++r]));return fS(n),new nt(n)}ce.str=Np;function Ka(e,t){t instanceof nt?e.push(...t._items):t instanceof Tn?e.push(t):e.push(hS(t))}ce.addCodeArg=Ka;function fS(e){let t=1;for(;t<e.length-1;){if(e[t]===qa){let n=pS(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]="+"}t++}}function pS(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Tn||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Tn))return`"${e}${t.slice(1)}`}function mS(e,t){return t.emptyStr()?e:e.emptyStr()?t:Np`${e}${t}`}ce.strConcat=mS;function hS(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Wr(Array.isArray(e)?e.join(","):e)}function gS(e){return new nt(Wr(e))}ce.stringify=gS;function Wr(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}ce.safeStringify=Wr;function yS(e){return typeof e=="string"&&ce.IDENTIFIER.test(e)?new nt(`.${e}`):Ip`[${e}]`}ce.getProperty=yS;function _S(e){if(typeof e=="string"&&ce.IDENTIFIER.test(e))return new nt(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}ce.getEsmExportName=_S;function ES(e){return new nt(e.toString())}ce.regexpCode=ES});var Wa=C(Ye=>{"use strict";f();Object.defineProperty(Ye,"__esModule",{value:!0});Ye.ValueScope=Ye.ValueScopeName=Ye.Scope=Ye.varKinds=Ye.UsedValueState=void 0;var Be=zr(),Ba=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},li;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(li||(Ye.UsedValueState=li={}));Ye.varKinds={const:new Be.Name("const"),let:new Be.Name("let"),var:new Be.Name("var")};var ci=class{constructor({prefixes:t,parent:n}={}){this._names={},this._prefixes=t,this._parent=n}toName(t){return t instanceof Be.Name?t:this.name(t)}name(t){return new Be.Name(this._newName(t))}_newName(t){let n=this._names[t]||this._nameGroup(t);return`${t}${n.index++}`}_nameGroup(t){var n,r;if(!((r=(n=this._parent)===null||n===void 0?void 0:n._prefixes)===null||r===void 0)&&r.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Ye.Scope=ci;var ui=class extends Be.Name{constructor(t,n){super(n),this.prefix=t}setValue(t,{property:n,itemIndex:r}){this.value=t,this.scopePath=(0,Be._)`.${new Be.Name(n)}[${r}]`}};Ye.ValueScopeName=ui;var SS=(0,Be._)`\n`,Ya=class extends ci{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?SS:Be.nil}}get(){return this._scope}name(t){return new ui(t,this._newName(t))}value(t,n){var r;if(n.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:i}=o,a=(r=n.key)!==null&&r!==void 0?r:n.ref,l=this._values[i];if(l){let p=l.get(a);if(p)return p}else l=this._values[i]=new Map;l.set(a,o);let c=this._scope[i]||(this._scope[i]=[]),u=c.length;return c[u]=n.ref,o.setValue(n,{property:i,itemIndex:u}),o}getValue(t,n){let r=this._values[t];if(r)return r.get(n)}scopeRefs(t,n=this._values){return this._reduceValues(n,r=>{if(r.scopePath===void 0)throw new Error(`CodeGen: name "${r}" has no value`);return(0,Be._)`${t}${r.scopePath}`})}scopeCode(t=this._values,n,r){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},n,r)}_reduceValues(t,n,r={},o){let i=Be.nil;for(let a in t){let l=t[a];if(!l)continue;let c=r[a]=r[a]||new Map;l.forEach(u=>{if(c.has(u))return;c.set(u,li.Started);let p=n(u);if(p){let m=this.opts.es5?Ye.varKinds.var:Ye.varKinds.const;i=(0,Be._)`${i}${m} ${u} = ${p};${this.opts._n}`}else if(p=o?.(u))i=(0,Be._)`${i}${p}${this.opts._n}`;else throw new Ba(u);c.set(u,li.Completed)})}return i}};Ye.ValueScope=Ya});var X=C(re=>{"use strict";f();Object.defineProperty(re,"__esModule",{value:!0});re.or=re.and=re.not=re.CodeGen=re.operators=re.varKinds=re.ValueScopeName=re.ValueScope=re.Scope=re.Name=re.regexpCode=re.stringify=re.getProperty=re.nil=re.strConcat=re.str=re._=void 0;var se=zr(),mt=Wa(),nn=zr();Object.defineProperty(re,"_",{enumerable:!0,get:function(){return nn._}});Object.defineProperty(re,"str",{enumerable:!0,get:function(){return nn.str}});Object.defineProperty(re,"strConcat",{enumerable:!0,get:function(){return nn.strConcat}});Object.defineProperty(re,"nil",{enumerable:!0,get:function(){return nn.nil}});Object.defineProperty(re,"getProperty",{enumerable:!0,get:function(){return nn.getProperty}});Object.defineProperty(re,"stringify",{enumerable:!0,get:function(){return nn.stringify}});Object.defineProperty(re,"regexpCode",{enumerable:!0,get:function(){return nn.regexpCode}});Object.defineProperty(re,"Name",{enumerable:!0,get:function(){return nn.Name}});var mi=Wa();Object.defineProperty(re,"Scope",{enumerable:!0,get:function(){return mi.Scope}});Object.defineProperty(re,"ValueScope",{enumerable:!0,get:function(){return mi.ValueScope}});Object.defineProperty(re,"ValueScopeName",{enumerable:!0,get:function(){return mi.ValueScopeName}});Object.defineProperty(re,"varKinds",{enumerable:!0,get:function(){return mi.varKinds}});re.operators={GT:new se._Code(">"),GTE:new se._Code(">="),LT:new se._Code("<"),LTE:new se._Code("<="),EQ:new se._Code("==="),NEQ:new se._Code("!=="),NOT:new se._Code("!"),OR:new se._Code("||"),AND:new se._Code("&&"),ADD:new se._Code("+")};var Pt=class{optimizeNodes(){return this}optimizeNames(t,n){return this}},za=class extends Pt{constructor(t,n,r){super(),this.varKind=t,this.name=n,this.rhs=r}render({es5:t,_n:n}){let r=t?mt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${r} ${this.name}${o};`+n}optimizeNames(t,n){if(t[this.name.str])return this.rhs&&(this.rhs=rr(this.rhs,t,n)),this}get names(){return this.rhs instanceof se._CodeOrName?this.rhs.names:{}}},di=class extends Pt{constructor(t,n,r){super(),this.lhs=t,this.rhs=n,this.sideEffects=r}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,n){if(!(this.lhs instanceof se.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=rr(this.rhs,t,n),this}get names(){let t=this.lhs instanceof se.Name?{}:{...this.lhs.names};return pi(t,this.rhs)}},Xa=class extends di{constructor(t,n,r,o){super(t,r,o),this.op=n}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Ja=class extends Pt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Qa=class extends Pt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},Za=class extends Pt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},el=class extends Pt{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,n){return this.code=rr(this.code,t,n),this}get names(){return this.code instanceof se._CodeOrName?this.code.names:{}}},Xr=class extends Pt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((n,r)=>n+r.render(t),"")}optimizeNodes(){let{nodes:t}=this,n=t.length;for(;n--;){let r=t[n].optimizeNodes();Array.isArray(r)?t.splice(n,1,...r):r?t[n]=r:t.splice(n,1)}return t.length>0?this:void 0}optimizeNames(t,n){let{nodes:r}=this,o=r.length;for(;o--;){let i=r[o];i.optimizeNames(t,n)||(bS(t,i.names),r.splice(o,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce((t,n)=>kn(t,n.names),{})}},Ct=class extends Xr{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},tl=class extends Xr{},nr=class extends Ct{};nr.kind="else";var Rn=class e extends Ct{constructor(t,n){super(n),this.condition=t}render(t){let n=`if(${this.condition})`+super.render(t);return this.else&&(n+="else "+this.else.render(t)),n}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let r=n.optimizeNodes();n=this.else=Array.isArray(r)?new nr(r):r}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e($p(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,n){var r;if(this.else=(r=this.else)===null||r===void 0?void 0:r.optimizeNames(t,n),!!(super.optimizeNames(t,n)||this.else))return this.condition=rr(this.condition,t,n),this}get names(){let t=super.names;return pi(t,this.condition),this.else&&kn(t,this.else.names),t}};Rn.kind="if";var An=class extends Ct{};An.kind="for";var nl=class extends An{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,n){if(super.optimizeNames(t,n))return this.iteration=rr(this.iteration,t,n),this}get names(){return kn(super.names,this.iteration.names)}},rl=class extends An{constructor(t,n,r,o){super(),this.varKind=t,this.name=n,this.from=r,this.to=o}render(t){let n=t.es5?mt.varKinds.var:this.varKind,{name:r,from:o,to:i}=this;return`for(${n} ${r}=${o}; ${r}<${i}; ${r}++)`+super.render(t)}get names(){let t=pi(super.names,this.from);return pi(t,this.to)}},fi=class extends An{constructor(t,n,r,o){super(),this.loop=t,this.varKind=n,this.name=r,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,n){if(super.optimizeNames(t,n))return this.iterable=rr(this.iterable,t,n),this}get names(){return kn(super.names,this.iterable.names)}},Jr=class extends Ct{constructor(t,n,r){super(),this.name=t,this.args=n,this.async=r}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};Jr.kind="func";var Qr=class extends Xr{render(t){return"return "+super.render(t)}};Qr.kind="return";var ol=class extends Ct{render(t){let n="try"+super.render(t);return this.catch&&(n+=this.catch.render(t)),this.finally&&(n+=this.finally.render(t)),n}optimizeNodes(){var t,n;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(n=this.finally)===null||n===void 0||n.optimizeNodes(),this}optimizeNames(t,n){var r,o;return super.optimizeNames(t,n),(r=this.catch)===null||r===void 0||r.optimizeNames(t,n),(o=this.finally)===null||o===void 0||o.optimizeNames(t,n),this}get names(){let t=super.names;return this.catch&&kn(t,this.catch.names),this.finally&&kn(t,this.finally.names),t}},Zr=class extends Ct{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Zr.kind="catch";var eo=class extends Ct{render(t){return"finally"+super.render(t)}};eo.kind="finally";var il=class{constructor(t,n={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...n,_n:n.lines?`
881
+ `:""},this._extScope=t,this._scope=new mt.Scope({parent:t}),this._nodes=[new tl]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,n){let r=this._extScope.value(t,n);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(t,n){return this._extScope.getValue(t,n)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,n,r,o){let i=this._scope.toName(n);return r!==void 0&&o&&(this._constants[i.str]=r),this._leafNode(new za(t,i,r)),i}const(t,n,r){return this._def(mt.varKinds.const,t,n,r)}let(t,n,r){return this._def(mt.varKinds.let,t,n,r)}var(t,n,r){return this._def(mt.varKinds.var,t,n,r)}assign(t,n,r){return this._leafNode(new di(t,n,r))}add(t,n){return this._leafNode(new Xa(t,re.operators.ADD,n))}code(t){return typeof t=="function"?t():t!==se.nil&&this._leafNode(new el(t)),this}object(...t){let n=["{"];for(let[r,o]of t)n.length>1&&n.push(","),n.push(r),(r!==o||this.opts.es5)&&(n.push(":"),(0,se.addCodeArg)(n,o));return n.push("}"),new se._Code(n)}if(t,n,r){if(this._blockNode(new Rn(t)),n&&r)this.code(n).else().code(r).endIf();else if(n)this.code(n).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Rn(t))}else(){return this._elseNode(new nr)}endIf(){return this._endBlockNode(Rn,nr)}_for(t,n){return this._blockNode(t),n&&this.code(n).endFor(),this}for(t,n){return this._for(new nl(t),n)}forRange(t,n,r,o,i=this.opts.es5?mt.varKinds.var:mt.varKinds.let){let a=this._scope.toName(t);return this._for(new rl(i,a,n,r),()=>o(a))}forOf(t,n,r,o=mt.varKinds.const){let i=this._scope.toName(t);if(this.opts.es5){let a=n instanceof se.Name?n:this.var("_arr",n);return this.forRange("_i",0,(0,se._)`${a}.length`,l=>{this.var(i,(0,se._)`${a}[${l}]`),r(i)})}return this._for(new fi("of",o,i,n),()=>r(i))}forIn(t,n,r,o=this.opts.es5?mt.varKinds.var:mt.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,se._)`Object.keys(${n})`,r);let i=this._scope.toName(t);return this._for(new fi("in",o,i,n),()=>r(i))}endFor(){return this._endBlockNode(An)}label(t){return this._leafNode(new Ja(t))}break(t){return this._leafNode(new Qa(t))}return(t){let n=new Qr;if(this._blockNode(n),this.code(t),n.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Qr)}try(t,n,r){if(!n&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new ol;if(this._blockNode(o),this.code(t),n){let i=this.name("e");this._currNode=o.catch=new Zr(i),n(i)}return r&&(this._currNode=o.finally=new eo,this.code(r)),this._endBlockNode(Zr,eo)}throw(t){return this._leafNode(new Za(t))}block(t,n){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(n),this}endBlock(t){let n=this._blockStarts.pop();if(n===void 0)throw new Error("CodeGen: not in self-balancing block");let r=this._nodes.length-n;if(r<0||t!==void 0&&r!==t)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${t} expected`);return this._nodes.length=n,this}func(t,n=se.nil,r,o){return this._blockNode(new Jr(t,n,r)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Jr)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,n){let r=this._currNode;if(r instanceof t||n&&r instanceof n)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${n?`${t.kind}/${n.kind}`:t.kind}"`)}_elseNode(t){let n=this._currNode;if(!(n instanceof Rn))throw new Error('CodeGen: "else" without "if"');return this._currNode=n.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let n=this._nodes;n[n.length-1]=t}};re.CodeGen=il;function kn(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function pi(e,t){return t instanceof se._CodeOrName?kn(e,t.names):e}function rr(e,t,n){if(e instanceof se.Name)return r(e);if(!o(e))return e;return new se._Code(e._items.reduce((i,a)=>(a instanceof se.Name&&(a=r(a)),a instanceof se._Code?i.push(...a._items):i.push(a),i),[]));function r(i){let a=n[i.str];return a===void 0||t[i.str]!==1?i:(delete t[i.str],a)}function o(i){return i instanceof se._Code&&i._items.some(a=>a instanceof se.Name&&t[a.str]===1&&n[a.str]!==void 0)}}function bS(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function $p(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,se._)`!${sl(e)}`}re.not=$p;var TS=Op(re.operators.AND);function RS(...e){return e.reduce(TS)}re.and=RS;var AS=Op(re.operators.OR);function kS(...e){return e.reduce(AS)}re.or=kS;function Op(e){return(t,n)=>t===se.nil?n:n===se.nil?t:(0,se._)`${sl(t)} ${e} ${sl(n)}`}function sl(e){return e instanceof se.Name?e:(0,se._)`(${e})`}});var ie=C(oe=>{"use strict";f();Object.defineProperty(oe,"__esModule",{value:!0});oe.checkStrictMode=oe.getErrorPath=oe.Type=oe.useFunc=oe.setEvaluated=oe.evaluatedPropsToName=oe.mergeEvaluated=oe.eachItem=oe.unescapeJsonPointer=oe.escapeJsonPointer=oe.escapeFragment=oe.unescapeFragment=oe.schemaRefOrVal=oe.schemaHasRulesButRef=oe.schemaHasRules=oe.checkUnknownRules=oe.alwaysValidSchema=oe.toHash=void 0;var he=X(),wS=zr();function vS(e){let t={};for(let n of e)t[n]=!0;return t}oe.toHash=vS;function IS(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Cp(e,t),!Lp(t,e.self.RULES.all))}oe.alwaysValidSchema=IS;function Cp(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t=="boolean")return;let o=r.RULES.keywords;for(let i in t)o[i]||Up(e,`unknown keyword: "${i}"`)}oe.checkUnknownRules=Cp;function Lp(e,t){if(typeof e=="boolean")return!e;for(let n in e)if(t[n])return!0;return!1}oe.schemaHasRules=Lp;function NS(e,t){if(typeof e=="boolean")return!e;for(let n in e)if(n!=="$ref"&&t.all[n])return!0;return!1}oe.schemaHasRulesButRef=NS;function $S({topSchemaRef:e,schemaPath:t},n,r,o){if(!o){if(typeof n=="number"||typeof n=="boolean")return n;if(typeof n=="string")return(0,he._)`${n}`}return(0,he._)`${e}${t}${(0,he.getProperty)(r)}`}oe.schemaRefOrVal=$S;function OS(e){return Dp(decodeURIComponent(e))}oe.unescapeFragment=OS;function xS(e){return encodeURIComponent(ll(e))}oe.escapeFragment=xS;function ll(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}oe.escapeJsonPointer=ll;function Dp(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}oe.unescapeJsonPointer=Dp;function PS(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}oe.eachItem=PS;function xp({mergeNames:e,mergeToName:t,mergeValues:n,resultToName:r}){return(o,i,a,l)=>{let c=a===void 0?i:a instanceof he.Name?(i instanceof he.Name?e(o,i,a):t(o,i,a),a):i instanceof he.Name?(t(o,a,i),i):n(i,a);return l===he.Name&&!(c instanceof he.Name)?r(o,c):c}}oe.mergeEvaluated={props:xp({mergeNames:(e,t,n)=>e.if((0,he._)`${n} !== true && ${t} !== undefined`,()=>{e.if((0,he._)`${t} === true`,()=>e.assign(n,!0),()=>e.assign(n,(0,he._)`${n} || {}`).code((0,he._)`Object.assign(${n}, ${t})`))}),mergeToName:(e,t,n)=>e.if((0,he._)`${n} !== true`,()=>{t===!0?e.assign(n,!0):(e.assign(n,(0,he._)`${n} || {}`),cl(e,n,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Mp}),items:xp({mergeNames:(e,t,n)=>e.if((0,he._)`${n} !== true && ${t} !== undefined`,()=>e.assign(n,(0,he._)`${t} === true ? true : ${n} > ${t} ? ${n} : ${t}`)),mergeToName:(e,t,n)=>e.if((0,he._)`${n} !== true`,()=>e.assign(n,t===!0?!0:(0,he._)`${n} > ${t} ? ${n} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Mp(e,t){if(t===!0)return e.var("props",!0);let n=e.var("props",(0,he._)`{}`);return t!==void 0&&cl(e,n,t),n}oe.evaluatedPropsToName=Mp;function cl(e,t,n){Object.keys(n).forEach(r=>e.assign((0,he._)`${t}${(0,he.getProperty)(r)}`,!0))}oe.setEvaluated=cl;var Pp={};function CS(e,t){return e.scopeValue("func",{ref:t,code:Pp[t.code]||(Pp[t.code]=new wS._Code(t.code))})}oe.useFunc=CS;var al;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(al||(oe.Type=al={}));function LS(e,t,n){if(e instanceof he.Name){let r=t===al.Num;return n?r?(0,he._)`"[" + ${e} + "]"`:(0,he._)`"['" + ${e} + "']"`:r?(0,he._)`"/" + ${e}`:(0,he._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,he.getProperty)(e).toString():"/"+ll(e)}oe.getErrorPath=LS;function Up(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw new Error(t);e.self.logger.warn(t)}}oe.checkStrictMode=Up});var rt=C(ul=>{"use strict";f();Object.defineProperty(ul,"__esModule",{value:!0});var Le=X(),DS={data:new Le.Name("data"),valCxt:new Le.Name("valCxt"),instancePath:new Le.Name("instancePath"),parentData:new Le.Name("parentData"),parentDataProperty:new Le.Name("parentDataProperty"),rootData:new Le.Name("rootData"),dynamicAnchors:new Le.Name("dynamicAnchors"),vErrors:new Le.Name("vErrors"),errors:new Le.Name("errors"),this:new Le.Name("this"),self:new Le.Name("self"),scope:new Le.Name("scope"),json:new Le.Name("json"),jsonPos:new Le.Name("jsonPos"),jsonLen:new Le.Name("jsonLen"),jsonPart:new Le.Name("jsonPart")};ul.default=DS});var to=C(De=>{"use strict";f();Object.defineProperty(De,"__esModule",{value:!0});De.extendErrors=De.resetErrorsCount=De.reportExtraError=De.reportError=De.keyword$DataError=De.keywordError=void 0;var ae=X(),hi=ie(),je=rt();De.keywordError={message:({keyword:e})=>(0,ae.str)`must pass "${e}" keyword validation`};De.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,ae.str)`"${e}" keyword must be ${t} ($data)`:(0,ae.str)`"${e}" keyword is invalid ($data)`};function MS(e,t=De.keywordError,n,r){let{it:o}=e,{gen:i,compositeRule:a,allErrors:l}=o,c=Gp(e,t,n);r??(a||l)?Fp(i,c):jp(o,(0,ae._)`[${c}]`)}De.reportError=MS;function US(e,t=De.keywordError,n){let{it:r}=e,{gen:o,compositeRule:i,allErrors:a}=r,l=Gp(e,t,n);Fp(o,l),i||a||jp(r,je.default.vErrors)}De.reportExtraError=US;function FS(e,t){e.assign(je.default.errors,t),e.if((0,ae._)`${je.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,ae._)`${je.default.vErrors}.length`,t),()=>e.assign(je.default.vErrors,null)))}De.resetErrorsCount=FS;function jS({gen:e,keyword:t,schemaValue:n,data:r,errsCount:o,it:i}){if(o===void 0)throw new Error("ajv implementation error");let a=e.name("err");e.forRange("i",o,je.default.errors,l=>{e.const(a,(0,ae._)`${je.default.vErrors}[${l}]`),e.if((0,ae._)`${a}.instancePath === undefined`,()=>e.assign((0,ae._)`${a}.instancePath`,(0,ae.strConcat)(je.default.instancePath,i.errorPath))),e.assign((0,ae._)`${a}.schemaPath`,(0,ae.str)`${i.errSchemaPath}/${t}`),i.opts.verbose&&(e.assign((0,ae._)`${a}.schema`,n),e.assign((0,ae._)`${a}.data`,r))})}De.extendErrors=jS;function Fp(e,t){let n=e.const("err",t);e.if((0,ae._)`${je.default.vErrors} === null`,()=>e.assign(je.default.vErrors,(0,ae._)`[${n}]`),(0,ae._)`${je.default.vErrors}.push(${n})`),e.code((0,ae._)`${je.default.errors}++`)}function jp(e,t){let{gen:n,validateName:r,schemaEnv:o}=e;o.$async?n.throw((0,ae._)`new ${e.ValidationError}(${t})`):(n.assign((0,ae._)`${r}.errors`,t),n.return(!1))}var wn={keyword:new ae.Name("keyword"),schemaPath:new ae.Name("schemaPath"),params:new ae.Name("params"),propertyName:new ae.Name("propertyName"),message:new ae.Name("message"),schema:new ae.Name("schema"),parentSchema:new ae.Name("parentSchema")};function Gp(e,t,n){let{createErrors:r}=e.it;return r===!1?(0,ae._)`{}`:GS(e,t,n)}function GS(e,t,n={}){let{gen:r,it:o}=e,i=[VS(o,n),HS(e,n)];return qS(e,t,i),r.object(...i)}function VS({errorPath:e},{instancePath:t}){let n=t?(0,ae.str)`${e}${(0,hi.getErrorPath)(t,hi.Type.Str)}`:e;return[je.default.instancePath,(0,ae.strConcat)(je.default.instancePath,n)]}function HS({keyword:e,it:{errSchemaPath:t}},{schemaPath:n,parentSchema:r}){let o=r?t:(0,ae.str)`${t}/${e}`;return n&&(o=(0,ae.str)`${o}${(0,hi.getErrorPath)(n,hi.Type.Str)}`),[wn.schemaPath,o]}function qS(e,{params:t,message:n},r){let{keyword:o,data:i,schemaValue:a,it:l}=e,{opts:c,propertyName:u,topSchemaRef:p,schemaPath:m}=l;r.push([wn.keyword,o],[wn.params,typeof t=="function"?t(e):t||(0,ae._)`{}`]),c.messages&&r.push([wn.message,typeof n=="function"?n(e):n]),c.verbose&&r.push([wn.schema,a],[wn.parentSchema,(0,ae._)`${p}${m}`],[je.default.data,i]),u&&r.push([wn.propertyName,u])}});var Hp=C(or=>{"use strict";f();Object.defineProperty(or,"__esModule",{value:!0});or.boolOrEmptySchema=or.topBoolOrEmptySchema=void 0;var KS=to(),BS=X(),YS=rt(),WS={message:"boolean schema is false"};function zS(e){let{gen:t,schema:n,validateName:r}=e;n===!1?Vp(e,!1):typeof n=="object"&&n.$async===!0?t.return(YS.default.data):(t.assign((0,BS._)`${r}.errors`,null),t.return(!0))}or.topBoolOrEmptySchema=zS;function XS(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),Vp(e)):n.var(t,!0)}or.boolOrEmptySchema=XS;function Vp(e,t){let{gen:n,data:r}=e,o={gen:n,keyword:"false schema",data:r,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,KS.reportError)(o,WS,void 0,t)}});var dl=C(ir=>{"use strict";f();Object.defineProperty(ir,"__esModule",{value:!0});ir.getRules=ir.isJSONType=void 0;var JS=["string","number","integer","boolean","null","object","array"],QS=new Set(JS);function ZS(e){return typeof e=="string"&&QS.has(e)}ir.isJSONType=ZS;function eb(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}ir.getRules=eb});var fl=C(rn=>{"use strict";f();Object.defineProperty(rn,"__esModule",{value:!0});rn.shouldUseRule=rn.shouldUseGroup=rn.schemaHasRulesForType=void 0;function tb({schema:e,self:t},n){let r=t.RULES.types[n];return r&&r!==!0&&qp(e,r)}rn.schemaHasRulesForType=tb;function qp(e,t){return t.rules.some(n=>Kp(e,n))}rn.shouldUseGroup=qp;function Kp(e,t){var n;return e[t.keyword]!==void 0||((n=t.definition.implements)===null||n===void 0?void 0:n.some(r=>e[r]!==void 0))}rn.shouldUseRule=Kp});var no=C(Me=>{"use strict";f();Object.defineProperty(Me,"__esModule",{value:!0});Me.reportTypeError=Me.checkDataTypes=Me.checkDataType=Me.coerceAndCheckDataType=Me.getJSONTypes=Me.getSchemaTypes=Me.DataType=void 0;var nb=dl(),rb=fl(),ob=to(),Z=X(),Bp=ie(),sr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(sr||(Me.DataType=sr={}));function ib(e){let t=Yp(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Me.getSchemaTypes=ib;function Yp(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(nb.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Me.getJSONTypes=Yp;function sb(e,t){let{gen:n,data:r,opts:o}=e,i=ab(t,o.coerceTypes),a=t.length>0&&!(i.length===0&&t.length===1&&(0,rb.schemaHasRulesForType)(e,t[0]));if(a){let l=ml(t,r,o.strictNumbers,sr.Wrong);n.if(l,()=>{i.length?lb(e,t,i):hl(e)})}return a}Me.coerceAndCheckDataType=sb;var Wp=new Set(["string","number","integer","boolean","null"]);function ab(e,t){return t?e.filter(n=>Wp.has(n)||t==="array"&&n==="array"):[]}function lb(e,t,n){let{gen:r,data:o,opts:i}=e,a=r.let("dataType",(0,Z._)`typeof ${o}`),l=r.let("coerced",(0,Z._)`undefined`);i.coerceTypes==="array"&&r.if((0,Z._)`${a} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>r.assign(o,(0,Z._)`${o}[0]`).assign(a,(0,Z._)`typeof ${o}`).if(ml(t,o,i.strictNumbers),()=>r.assign(l,o))),r.if((0,Z._)`${l} !== undefined`);for(let u of n)(Wp.has(u)||u==="array"&&i.coerceTypes==="array")&&c(u);r.else(),hl(e),r.endIf(),r.if((0,Z._)`${l} !== undefined`,()=>{r.assign(o,l),cb(e,l)});function c(u){switch(u){case"string":r.elseIf((0,Z._)`${a} == "number" || ${a} == "boolean"`).assign(l,(0,Z._)`"" + ${o}`).elseIf((0,Z._)`${o} === null`).assign(l,(0,Z._)`""`);return;case"number":r.elseIf((0,Z._)`${a} == "boolean" || ${o} === null
882
+ || (${a} == "string" && ${o} && ${o} == +${o})`).assign(l,(0,Z._)`+${o}`);return;case"integer":r.elseIf((0,Z._)`${a} === "boolean" || ${o} === null
883
+ || (${a} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(l,(0,Z._)`+${o}`);return;case"boolean":r.elseIf((0,Z._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(l,!1).elseIf((0,Z._)`${o} === "true" || ${o} === 1`).assign(l,!0);return;case"null":r.elseIf((0,Z._)`${o} === "" || ${o} === 0 || ${o} === false`),r.assign(l,null);return;case"array":r.elseIf((0,Z._)`${a} === "string" || ${a} === "number"
884
+ || ${a} === "boolean" || ${o} === null`).assign(l,(0,Z._)`[${o}]`)}}}function cb({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,Z._)`${t} !== undefined`,()=>e.assign((0,Z._)`${t}[${n}]`,r))}function pl(e,t,n,r=sr.Correct){let o=r===sr.Correct?Z.operators.EQ:Z.operators.NEQ,i;switch(e){case"null":return(0,Z._)`${t} ${o} null`;case"array":i=(0,Z._)`Array.isArray(${t})`;break;case"object":i=(0,Z._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":i=a((0,Z._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":i=a();break;default:return(0,Z._)`typeof ${t} ${o} ${e}`}return r===sr.Correct?i:(0,Z.not)(i);function a(l=Z.nil){return(0,Z.and)((0,Z._)`typeof ${t} == "number"`,l,n?(0,Z._)`isFinite(${t})`:Z.nil)}}Me.checkDataType=pl;function ml(e,t,n,r){if(e.length===1)return pl(e[0],t,n,r);let o,i=(0,Bp.toHash)(e);if(i.array&&i.object){let a=(0,Z._)`typeof ${t} != "object"`;o=i.null?a:(0,Z._)`!${t} || ${a}`,delete i.null,delete i.array,delete i.object}else o=Z.nil;i.number&&delete i.integer;for(let a in i)o=(0,Z.and)(o,pl(a,t,n,r));return o}Me.checkDataTypes=ml;var ub={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,Z._)`{type: ${e}}`:(0,Z._)`{type: ${t}}`};function hl(e){let t=db(e);(0,ob.reportError)(t,ub)}Me.reportTypeError=hl;function db(e){let{gen:t,data:n,schema:r}=e,o=(0,Bp.schemaRefOrVal)(e,r,"type");return{gen:t,keyword:"type",data:n,schema:r.type,schemaCode:o,schemaValue:o,parentSchema:r,params:{},it:e}}});var Xp=C(gi=>{"use strict";f();Object.defineProperty(gi,"__esModule",{value:!0});gi.assignDefaults=void 0;var ar=X(),fb=ie();function pb(e,t){let{properties:n,items:r}=e.schema;if(t==="object"&&n)for(let o in n)zp(e,o,n[o].default);else t==="array"&&Array.isArray(r)&&r.forEach((o,i)=>zp(e,i,o.default))}gi.assignDefaults=pb;function zp(e,t,n){let{gen:r,compositeRule:o,data:i,opts:a}=e;if(n===void 0)return;let l=(0,ar._)`${i}${(0,ar.getProperty)(t)}`;if(o){(0,fb.checkStrictMode)(e,`default is ignored for: ${l}`);return}let c=(0,ar._)`${l} === undefined`;a.useDefaults==="empty"&&(c=(0,ar._)`${c} || ${l} === null || ${l} === ""`),r.if(c,(0,ar._)`${l} = ${(0,ar.stringify)(n)}`)}});var ot=C(me=>{"use strict";f();Object.defineProperty(me,"__esModule",{value:!0});me.validateUnion=me.validateArray=me.usePattern=me.callValidateCode=me.schemaProperties=me.allSchemaProperties=me.noPropertyInData=me.propertyInData=me.isOwnProperty=me.hasPropFunc=me.reportMissingProp=me.checkMissingProp=me.checkReportMissingProp=void 0;var Ee=X(),gl=ie(),on=rt(),mb=ie();function hb(e,t){let{gen:n,data:r,it:o}=e;n.if(_l(n,r,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Ee._)`${t}`},!0),e.error()})}me.checkReportMissingProp=hb;function gb({gen:e,data:t,it:{opts:n}},r,o){return(0,Ee.or)(...r.map(i=>(0,Ee.and)(_l(e,t,i,n.ownProperties),(0,Ee._)`${o} = ${i}`)))}me.checkMissingProp=gb;function yb(e,t){e.setParams({missingProperty:t},!0),e.error()}me.reportMissingProp=yb;function Jp(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ee._)`Object.prototype.hasOwnProperty`})}me.hasPropFunc=Jp;function yl(e,t,n){return(0,Ee._)`${Jp(e)}.call(${t}, ${n})`}me.isOwnProperty=yl;function _b(e,t,n,r){let o=(0,Ee._)`${t}${(0,Ee.getProperty)(n)} !== undefined`;return r?(0,Ee._)`${o} && ${yl(e,t,n)}`:o}me.propertyInData=_b;function _l(e,t,n,r){let o=(0,Ee._)`${t}${(0,Ee.getProperty)(n)} === undefined`;return r?(0,Ee.or)(o,(0,Ee.not)(yl(e,t,n))):o}me.noPropertyInData=_l;function Qp(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}me.allSchemaProperties=Qp;function Eb(e,t){return Qp(t).filter(n=>!(0,gl.alwaysValidSchema)(e,t[n]))}me.schemaProperties=Eb;function Sb({schemaCode:e,data:t,it:{gen:n,topSchemaRef:r,schemaPath:o,errorPath:i},it:a},l,c,u){let p=u?(0,Ee._)`${e}, ${t}, ${r}${o}`:t,m=[[on.default.instancePath,(0,Ee.strConcat)(on.default.instancePath,i)],[on.default.parentData,a.parentData],[on.default.parentDataProperty,a.parentDataProperty],[on.default.rootData,on.default.rootData]];a.opts.dynamicRef&&m.push([on.default.dynamicAnchors,on.default.dynamicAnchors]);let h=(0,Ee._)`${p}, ${n.object(...m)}`;return c!==Ee.nil?(0,Ee._)`${l}.call(${c}, ${h})`:(0,Ee._)`${l}(${h})`}me.callValidateCode=Sb;var bb=(0,Ee._)`new RegExp`;function Tb({gen:e,it:{opts:t}},n){let r=t.unicodeRegExp?"u":"",{regExp:o}=t.code,i=o(n,r);return e.scopeValue("pattern",{key:i.toString(),ref:i,code:(0,Ee._)`${o.code==="new RegExp"?bb:(0,mb.useFunc)(e,o)}(${n}, ${r})`})}me.usePattern=Tb;function Rb(e){let{gen:t,data:n,keyword:r,it:o}=e,i=t.name("valid");if(o.allErrors){let l=t.let("valid",!0);return a(()=>t.assign(l,!1)),l}return t.var(i,!0),a(()=>t.break()),i;function a(l){let c=t.const("len",(0,Ee._)`${n}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:r,dataProp:u,dataPropType:gl.Type.Num},i),t.if((0,Ee.not)(i),l)})}}me.validateArray=Rb;function Ab(e){let{gen:t,schema:n,keyword:r,it:o}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(n.some(c=>(0,gl.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let a=t.let("valid",!1),l=t.name("_valid");t.block(()=>n.forEach((c,u)=>{let p=e.subschema({keyword:r,schemaProp:u,compositeRule:!0},l);t.assign(a,(0,Ee._)`${a} || ${l}`),e.mergeValidEvaluated(p,l)||t.if((0,Ee.not)(a))})),e.result(a,()=>e.reset(),()=>e.error(!0))}me.validateUnion=Ab});var tm=C(St=>{"use strict";f();Object.defineProperty(St,"__esModule",{value:!0});St.validateKeywordUsage=St.validSchemaType=St.funcKeywordCode=St.macroKeywordCode=void 0;var Ge=X(),vn=rt(),kb=ot(),wb=to();function vb(e,t){let{gen:n,keyword:r,schema:o,parentSchema:i,it:a}=e,l=t.macro.call(a.self,o,i,a),c=em(n,r,l);a.opts.validateSchema!==!1&&a.self.validateSchema(l,!0);let u=n.name("valid");e.subschema({schema:l,schemaPath:Ge.nil,errSchemaPath:`${a.errSchemaPath}/${r}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}St.macroKeywordCode=vb;function Ib(e,t){var n;let{gen:r,keyword:o,schema:i,parentSchema:a,$data:l,it:c}=e;$b(c,t);let u=!l&&t.compile?t.compile.call(c.self,i,a,c):t.validate,p=em(r,o,u),m=r.let("valid");e.block$data(m,h),e.ok((n=t.valid)!==null&&n!==void 0?n:m);function h(){if(t.errors===!1)S(),t.modifying&&Zp(e),v(()=>e.error());else{let R=t.async?b():g();t.modifying&&Zp(e),v(()=>Nb(e,R))}}function b(){let R=r.let("ruleErrs",null);return r.try(()=>S((0,Ge._)`await `),P=>r.assign(m,!1).if((0,Ge._)`${P} instanceof ${c.ValidationError}`,()=>r.assign(R,(0,Ge._)`${P}.errors`),()=>r.throw(P))),R}function g(){let R=(0,Ge._)`${p}.errors`;return r.assign(R,null),S(Ge.nil),R}function S(R=t.async?(0,Ge._)`await `:Ge.nil){let P=c.opts.passContext?vn.default.this:vn.default.self,M=!("compile"in t&&!l||t.schema===!1);r.assign(m,(0,Ge._)`${R}${(0,kb.callValidateCode)(e,p,P,M)}`,t.modifying)}function v(R){var P;r.if((0,Ge.not)((P=t.valid)!==null&&P!==void 0?P:m),R)}}St.funcKeywordCode=Ib;function Zp(e){let{gen:t,data:n,it:r}=e;t.if(r.parentData,()=>t.assign(n,(0,Ge._)`${r.parentData}[${r.parentDataProperty}]`))}function Nb(e,t){let{gen:n}=e;n.if((0,Ge._)`Array.isArray(${t})`,()=>{n.assign(vn.default.vErrors,(0,Ge._)`${vn.default.vErrors} === null ? ${t} : ${vn.default.vErrors}.concat(${t})`).assign(vn.default.errors,(0,Ge._)`${vn.default.vErrors}.length`),(0,wb.extendErrors)(e)},()=>e.error())}function $b({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function em(e,t,n){if(n===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof n=="function"?{ref:n}:{ref:n,code:(0,Ge.stringify)(n)})}function Ob(e,t,n=!1){return!t.length||t.some(r=>r==="array"?Array.isArray(e):r==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==r||n&&typeof e>"u")}St.validSchemaType=Ob;function xb({schema:e,opts:t,self:n,errSchemaPath:r},o,i){if(Array.isArray(o.keyword)?!o.keyword.includes(i):o.keyword!==i)throw new Error("ajv implementation error");let a=o.dependencies;if(a?.some(l=>!Object.prototype.hasOwnProperty.call(e,l)))throw new Error(`parent schema must have dependencies of ${i}: ${a.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[i])){let c=`keyword "${i}" value is invalid at path "${r}": `+n.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")n.logger.error(c);else throw new Error(c)}}St.validateKeywordUsage=xb});var rm=C(sn=>{"use strict";f();Object.defineProperty(sn,"__esModule",{value:!0});sn.extendSubschemaMode=sn.extendSubschemaData=sn.getSubschema=void 0;var bt=X(),nm=ie();function Pb(e,{keyword:t,schemaProp:n,schema:r,schemaPath:o,errSchemaPath:i,topSchemaRef:a}){if(t!==void 0&&r!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let l=e.schema[t];return n===void 0?{schema:l,schemaPath:(0,bt._)`${e.schemaPath}${(0,bt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:l[n],schemaPath:(0,bt._)`${e.schemaPath}${(0,bt.getProperty)(t)}${(0,bt.getProperty)(n)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,nm.escapeFragment)(n)}`}}if(r!==void 0){if(o===void 0||i===void 0||a===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:r,schemaPath:o,topSchemaRef:a,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')}sn.getSubschema=Pb;function Cb(e,t,{dataProp:n,dataPropType:r,data:o,dataTypes:i,propertyName:a}){if(o!==void 0&&n!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:l}=t;if(n!==void 0){let{errorPath:u,dataPathArr:p,opts:m}=t,h=l.let("data",(0,bt._)`${t.data}${(0,bt.getProperty)(n)}`,!0);c(h),e.errorPath=(0,bt.str)`${u}${(0,nm.getErrorPath)(n,r,m.jsPropertySyntax)}`,e.parentDataProperty=(0,bt._)`${n}`,e.dataPathArr=[...p,e.parentDataProperty]}if(o!==void 0){let u=o instanceof bt.Name?o:l.let("data",o,!0);c(u),a!==void 0&&(e.propertyName=a)}i&&(e.dataTypes=i);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}sn.extendSubschemaData=Cb;function Lb(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:o,allErrors:i}){r!==void 0&&(e.compositeRule=r),o!==void 0&&(e.createErrors=o),i!==void 0&&(e.allErrors=i),e.jtdDiscriminator=t,e.jtdMetadata=n}sn.extendSubschemaMode=Lb});var El=C((mC,om)=>{"use strict";f();om.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t=="object"&&typeof n=="object"){if(t.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!e(t[o],n[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(i=Object.keys(t),r=i.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;o--!==0;){var a=i[o];if(!e(t[a],n[a]))return!1}return!0}return t!==t&&n!==n}});var sm=C((gC,im)=>{"use strict";f();var an=im.exports=function(e,t,n){typeof t=="function"&&(n=t,t={}),n=t.cb||n;var r=typeof n=="function"?n:n.pre||function(){},o=n.post||function(){};yi(t,r,o,e,"",e)};an.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};an.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};an.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};an.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function yi(e,t,n,r,o,i,a,l,c,u){if(r&&typeof r=="object"&&!Array.isArray(r)){t(r,o,i,a,l,c,u);for(var p in r){var m=r[p];if(Array.isArray(m)){if(p in an.arrayKeywords)for(var h=0;h<m.length;h++)yi(e,t,n,m[h],o+"/"+p+"/"+h,i,o,p,r,h)}else if(p in an.propsKeywords){if(m&&typeof m=="object")for(var b in m)yi(e,t,n,m[b],o+"/"+p+"/"+Db(b),i,o,p,r,b)}else(p in an.keywords||e.allKeys&&!(p in an.skipKeywords))&&yi(e,t,n,m,o+"/"+p,i,o,p,r)}n(r,o,i,a,l,c,u)}}function Db(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var ro=C(We=>{"use strict";f();Object.defineProperty(We,"__esModule",{value:!0});We.getSchemaRefs=We.resolveUrl=We.normalizeId=We._getFullPath=We.getFullPath=We.inlineRef=void 0;var Mb=ie(),Ub=El(),Fb=sm(),jb=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Gb(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Sl(e):t?am(e)<=t:!1}We.inlineRef=Gb;var Vb=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Sl(e){for(let t in e){if(Vb.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(Sl)||typeof n=="object"&&Sl(n))return!0}return!1}function am(e){let t=0;for(let n in e){if(n==="$ref")return 1/0;if(t++,!jb.has(n)&&(typeof e[n]=="object"&&(0,Mb.eachItem)(e[n],r=>t+=am(r)),t===1/0))return 1/0}return t}function lm(e,t="",n){n!==!1&&(t=lr(t));let r=e.parse(t);return cm(e,r)}We.getFullPath=lm;function cm(e,t){return e.serialize(t).split("#")[0]+"#"}We._getFullPath=cm;var Hb=/#\/?$/;function lr(e){return e?e.replace(Hb,""):""}We.normalizeId=lr;function qb(e,t,n){return n=lr(n),e.resolve(t,n)}We.resolveUrl=qb;var Kb=/^[a-z_][-a-z0-9._]*$/i;function Bb(e,t){if(typeof e=="boolean")return{};let{schemaId:n,uriResolver:r}=this.opts,o=lr(e[n]||t),i={"":o},a=lm(r,o,!1),l={},c=new Set;return Fb(e,{allKeys:!0},(m,h,b,g)=>{if(g===void 0)return;let S=a+h,v=i[g];typeof m[n]=="string"&&(v=R.call(this,m[n])),P.call(this,m.$anchor),P.call(this,m.$dynamicAnchor),i[h]=v;function R(M){let H=this.opts.uriResolver.resolve;if(M=lr(v?H(v,M):M),c.has(M))throw p(M);c.add(M);let G=this.refs[M];return typeof G=="string"&&(G=this.refs[G]),typeof G=="object"?u(m,G.schema,M):M!==lr(S)&&(M[0]==="#"?(u(m,l[M],M),l[M]=m):this.refs[M]=S),M}function P(M){if(typeof M=="string"){if(!Kb.test(M))throw new Error(`invalid anchor "${M}"`);R.call(this,`#${M}`)}}}),l;function u(m,h,b){if(h!==void 0&&!Ub(m,h))throw p(b)}function p(m){return new Error(`reference "${m}" resolves to more than one schema`)}}We.getSchemaRefs=Bb});var so=C(ln=>{"use strict";f();Object.defineProperty(ln,"__esModule",{value:!0});ln.getData=ln.KeywordCxt=ln.validateFunctionCode=void 0;var mm=Hp(),um=no(),Tl=fl(),_i=no(),Yb=Xp(),io=tm(),bl=rm(),V=X(),Y=rt(),Wb=ro(),Lt=ie(),oo=to();function zb(e){if(ym(e)&&(_m(e),gm(e))){Qb(e);return}hm(e,()=>(0,mm.topBoolOrEmptySchema)(e))}ln.validateFunctionCode=zb;function hm({gen:e,validateName:t,schema:n,schemaEnv:r,opts:o},i){o.code.es5?e.func(t,(0,V._)`${Y.default.data}, ${Y.default.valCxt}`,r.$async,()=>{e.code((0,V._)`"use strict"; ${dm(n,o)}`),Jb(e,o),e.code(i)}):e.func(t,(0,V._)`${Y.default.data}, ${Xb(o)}`,r.$async,()=>e.code(dm(n,o)).code(i))}function Xb(e){return(0,V._)`{${Y.default.instancePath}="", ${Y.default.parentData}, ${Y.default.parentDataProperty}, ${Y.default.rootData}=${Y.default.data}${e.dynamicRef?(0,V._)`, ${Y.default.dynamicAnchors}={}`:V.nil}}={}`}function Jb(e,t){e.if(Y.default.valCxt,()=>{e.var(Y.default.instancePath,(0,V._)`${Y.default.valCxt}.${Y.default.instancePath}`),e.var(Y.default.parentData,(0,V._)`${Y.default.valCxt}.${Y.default.parentData}`),e.var(Y.default.parentDataProperty,(0,V._)`${Y.default.valCxt}.${Y.default.parentDataProperty}`),e.var(Y.default.rootData,(0,V._)`${Y.default.valCxt}.${Y.default.rootData}`),t.dynamicRef&&e.var(Y.default.dynamicAnchors,(0,V._)`${Y.default.valCxt}.${Y.default.dynamicAnchors}`)},()=>{e.var(Y.default.instancePath,(0,V._)`""`),e.var(Y.default.parentData,(0,V._)`undefined`),e.var(Y.default.parentDataProperty,(0,V._)`undefined`),e.var(Y.default.rootData,Y.default.data),t.dynamicRef&&e.var(Y.default.dynamicAnchors,(0,V._)`{}`)})}function Qb(e){let{schema:t,opts:n,gen:r}=e;hm(e,()=>{n.$comment&&t.$comment&&Sm(e),rT(e),r.let(Y.default.vErrors,null),r.let(Y.default.errors,0),n.unevaluated&&Zb(e),Em(e),sT(e)})}function Zb(e){let{gen:t,validateName:n}=e;e.evaluated=t.const("evaluated",(0,V._)`${n}.evaluated`),t.if((0,V._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,V._)`${e.evaluated}.props`,(0,V._)`undefined`)),t.if((0,V._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,V._)`${e.evaluated}.items`,(0,V._)`undefined`))}function dm(e,t){let n=typeof e=="object"&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,V._)`/*# sourceURL=${n} */`:V.nil}function eT(e,t){if(ym(e)&&(_m(e),gm(e))){tT(e,t);return}(0,mm.boolOrEmptySchema)(e,t)}function gm({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function ym(e){return typeof e.schema!="boolean"}function tT(e,t){let{schema:n,gen:r,opts:o}=e;o.$comment&&n.$comment&&Sm(e),oT(e),iT(e);let i=r.const("_errs",Y.default.errors);Em(e,i),r.var(t,(0,V._)`${i} === ${Y.default.errors}`)}function _m(e){(0,Lt.checkUnknownRules)(e),nT(e)}function Em(e,t){if(e.opts.jtd)return fm(e,[],!1,t);let n=(0,um.getSchemaTypes)(e.schema),r=(0,um.coerceAndCheckDataType)(e,n);fm(e,n,!r,t)}function nT(e){let{schema:t,errSchemaPath:n,opts:r,self:o}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,Lt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function rT(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,Lt.checkStrictMode)(e,"default is ignored in the schema root")}function oT(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Wb.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function iT(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Sm({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:o}){let i=n.$comment;if(o.$comment===!0)e.code((0,V._)`${Y.default.self}.logger.log(${i})`);else if(typeof o.$comment=="function"){let a=(0,V.str)`${r}/$comment`,l=e.scopeValue("root",{ref:t.root});e.code((0,V._)`${Y.default.self}.opts.$comment(${i}, ${a}, ${l}.schema)`)}}function sT(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:o,opts:i}=e;n.$async?t.if((0,V._)`${Y.default.errors} === 0`,()=>t.return(Y.default.data),()=>t.throw((0,V._)`new ${o}(${Y.default.vErrors})`)):(t.assign((0,V._)`${r}.errors`,Y.default.vErrors),i.unevaluated&&aT(e),t.return((0,V._)`${Y.default.errors} === 0`))}function aT({gen:e,evaluated:t,props:n,items:r}){n instanceof V.Name&&e.assign((0,V._)`${t}.props`,n),r instanceof V.Name&&e.assign((0,V._)`${t}.items`,r)}function fm(e,t,n,r){let{gen:o,schema:i,data:a,allErrors:l,opts:c,self:u}=e,{RULES:p}=u;if(i.$ref&&(c.ignoreKeywordsWithRef||!(0,Lt.schemaHasRulesButRef)(i,p))){o.block(()=>Tm(e,"$ref",p.all.$ref.definition));return}c.jtd||lT(e,t),o.block(()=>{for(let h of p.rules)m(h);m(p.post)});function m(h){(0,Tl.shouldUseGroup)(i,h)&&(h.type?(o.if((0,_i.checkDataType)(h.type,a,c.strictNumbers)),pm(e,h),t.length===1&&t[0]===h.type&&n&&(o.else(),(0,_i.reportTypeError)(e)),o.endIf()):pm(e,h),l||o.if((0,V._)`${Y.default.errors} === ${r||0}`))}}function pm(e,t){let{gen:n,schema:r,opts:{useDefaults:o}}=e;o&&(0,Yb.assignDefaults)(e,t.type),n.block(()=>{for(let i of t.rules)(0,Tl.shouldUseRule)(r,i)&&Tm(e,i.keyword,i.definition,t.type)})}function lT(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(cT(e,t),e.opts.allowUnionTypes||uT(e,t),dT(e,e.dataTypes))}function cT(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(n=>{bm(e.dataTypes,n)||Rl(e,`type "${n}" not allowed by context "${e.dataTypes.join(",")}"`)}),pT(e,t)}}function uT(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Rl(e,"use allowUnionTypes to allow union type keyword")}function dT(e,t){let n=e.self.RULES.all;for(let r in n){let o=n[r];if(typeof o=="object"&&(0,Tl.shouldUseRule)(e.schema,o)){let{type:i}=o.definition;i.length&&!i.some(a=>fT(t,a))&&Rl(e,`missing type "${i.join(",")}" for keyword "${r}"`)}}}function fT(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function bm(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function pT(e,t){let n=[];for(let r of e.dataTypes)bm(t,r)?n.push(r):t.includes("integer")&&r==="number"&&n.push("integer");e.dataTypes=n}function Rl(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,Lt.checkStrictMode)(e,t,e.opts.strictTypes)}var Ei=class{constructor(t,n,r){if((0,io.validateKeywordUsage)(t,n,r),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=r,this.data=t.data,this.schema=t.schema[r],this.$data=n.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Lt.schemaRefOrVal)(t,this.schema,r,this.$data),this.schemaType=n.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=n,this.$data)this.schemaCode=t.gen.const("vSchema",Rm(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,io.validSchemaType)(this.schema,n.schemaType,n.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(n.schemaType)}`);("code"in n?n.trackErrors:n.errors!==!1)&&(this.errsCount=t.gen.const("_errs",Y.default.errors))}result(t,n,r){this.failResult((0,V.not)(t),n,r)}failResult(t,n,r){this.gen.if(t),r?r():this.error(),n?(this.gen.else(),n(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,n){this.failResult((0,V.not)(t),void 0,n)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:n}=this;this.fail((0,V._)`${n} !== undefined && (${(0,V.or)(this.invalid$data(),t)})`)}error(t,n,r){if(n){this.setParams(n),this._error(t,r),this.setParams({});return}this._error(t,r)}_error(t,n){(t?oo.reportExtraError:oo.reportError)(this,this.def.error,n)}$dataError(){(0,oo.reportError)(this,this.def.$dataError||oo.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,oo.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,n){n?Object.assign(this.params,t):this.params=t}block$data(t,n,r=V.nil){this.gen.block(()=>{this.check$data(t,r),n()})}check$data(t=V.nil,n=V.nil){if(!this.$data)return;let{gen:r,schemaCode:o,schemaType:i,def:a}=this;r.if((0,V.or)((0,V._)`${o} === undefined`,n)),t!==V.nil&&r.assign(t,!0),(i.length||a.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),t!==V.nil&&r.assign(t,!1)),r.else()}invalid$data(){let{gen:t,schemaCode:n,schemaType:r,def:o,it:i}=this;return(0,V.or)(a(),l());function a(){if(r.length){if(!(n instanceof V.Name))throw new Error("ajv implementation error");let c=Array.isArray(r)?r:[r];return(0,V._)`${(0,_i.checkDataTypes)(c,n,i.opts.strictNumbers,_i.DataType.Wrong)}`}return V.nil}function l(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,V._)`!${c}(${n})`}return V.nil}}subschema(t,n){let r=(0,bl.getSubschema)(this.it,t);(0,bl.extendSubschemaData)(r,this.it,t),(0,bl.extendSubschemaMode)(r,t);let o={...this.it,...r,items:void 0,props:void 0};return eT(o,n),o}mergeEvaluated(t,n){let{it:r,gen:o}=this;r.opts.unevaluated&&(r.props!==!0&&t.props!==void 0&&(r.props=Lt.mergeEvaluated.props(o,t.props,r.props,n)),r.items!==!0&&t.items!==void 0&&(r.items=Lt.mergeEvaluated.items(o,t.items,r.items,n)))}mergeValidEvaluated(t,n){let{it:r,gen:o}=this;if(r.opts.unevaluated&&(r.props!==!0||r.items!==!0))return o.if(n,()=>this.mergeEvaluated(t,V.Name)),!0}};ln.KeywordCxt=Ei;function Tm(e,t,n,r){let o=new Ei(e,n,t);"code"in n?n.code(o,r):o.$data&&n.validate?(0,io.funcKeywordCode)(o,n):"macro"in n?(0,io.macroKeywordCode)(o,n):(n.compile||n.validate)&&(0,io.funcKeywordCode)(o,n)}var mT=/^\/(?:[^~]|~0|~1)*$/,hT=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Rm(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let o,i;if(e==="")return Y.default.rootData;if(e[0]==="/"){if(!mT.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,i=Y.default.rootData}else{let u=hT.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let p=+u[1];if(o=u[2],o==="#"){if(p>=t)throw new Error(c("property/index",p));return r[t-p]}if(p>t)throw new Error(c("data",p));if(i=n[t-p],!o)return i}let a=i,l=o.split("/");for(let u of l)u&&(i=(0,V._)`${i}${(0,V.getProperty)((0,Lt.unescapeJsonPointer)(u))}`,a=(0,V._)`${a} && ${i}`);return a;function c(u,p){return`Cannot access ${u} ${p} levels up, current level is ${t}`}}ln.getData=Rm});var Si=C(kl=>{"use strict";f();Object.defineProperty(kl,"__esModule",{value:!0});var Al=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};kl.default=Al});var ao=C(Il=>{"use strict";f();Object.defineProperty(Il,"__esModule",{value:!0});var wl=ro(),vl=class extends Error{constructor(t,n,r,o){super(o||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,wl.resolveUrl)(t,n,r),this.missingSchema=(0,wl.normalizeId)((0,wl.getFullPath)(t,this.missingRef))}};Il.default=vl});var lo=C(it=>{"use strict";f();Object.defineProperty(it,"__esModule",{value:!0});it.resolveSchema=it.getCompilingSchema=it.resolveRef=it.compileSchema=it.SchemaEnv=void 0;var ht=X(),gT=Si(),In=rt(),gt=ro(),Am=ie(),yT=so(),cr=class{constructor(t){var n;this.refs={},this.dynamicAnchors={};let r;typeof t.schema=="object"&&(r=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(n=t.baseId)!==null&&n!==void 0?n:(0,gt.normalizeId)(r?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=r?.$async,this.refs={}}};it.SchemaEnv=cr;function $l(e){let t=km.call(this,e);if(t)return t;let n=(0,gt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:r,lines:o}=this.opts.code,{ownProperties:i}=this.opts,a=new ht.CodeGen(this.scope,{es5:r,lines:o,ownProperties:i}),l;e.$async&&(l=a.scopeValue("Error",{ref:gT.default,code:(0,ht._)`require("ajv/dist/runtime/validation_error").default`}));let c=a.scopeName("validate");e.validateName=c;let u={gen:a,allErrors:this.opts.allErrors,data:In.default.data,parentData:In.default.parentData,parentDataProperty:In.default.parentDataProperty,dataNames:[In.default.data],dataPathArr:[ht.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:a.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,ht.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:l,schema:e.schema,schemaEnv:e,rootId:n,baseId:e.baseId||n,schemaPath:ht.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,ht._)`""`,opts:this.opts,self:this},p;try{this._compilations.add(e),(0,yT.validateFunctionCode)(u),a.optimize(this.opts.code.optimize);let m=a.toString();p=`${a.scopeRefs(In.default.scope)}return ${m}`,this.opts.code.process&&(p=this.opts.code.process(p,e));let b=new Function(`${In.default.self}`,`${In.default.scope}`,p)(this,this.scope.get());if(this.scope.value(c,{ref:b}),b.errors=null,b.schema=e.schema,b.schemaEnv=e,e.$async&&(b.$async=!0),this.opts.code.source===!0&&(b.source={validateName:c,validateCode:m,scopeValues:a._values}),this.opts.unevaluated){let{props:g,items:S}=u;b.evaluated={props:g instanceof ht.Name?void 0:g,items:S instanceof ht.Name?void 0:S,dynamicProps:g instanceof ht.Name,dynamicItems:S instanceof ht.Name},b.source&&(b.source.evaluated=(0,ht.stringify)(b.evaluated))}return e.validate=b,e}catch(m){throw delete e.validate,delete e.validateName,p&&this.logger.error("Error compiling schema, function code:",p),m}finally{this._compilations.delete(e)}}it.compileSchema=$l;function _T(e,t,n){var r;n=(0,gt.resolveUrl)(this.opts.uriResolver,t,n);let o=e.refs[n];if(o)return o;let i=bT.call(this,e,n);if(i===void 0){let a=(r=e.localRefs)===null||r===void 0?void 0:r[n],{schemaId:l}=this.opts;a&&(i=new cr({schema:a,schemaId:l,root:e,baseId:t}))}if(i!==void 0)return e.refs[n]=ET.call(this,i)}it.resolveRef=_T;function ET(e){return(0,gt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:$l.call(this,e)}function km(e){for(let t of this._compilations)if(ST(t,e))return t}it.getCompilingSchema=km;function ST(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function bT(e,t){let n;for(;typeof(n=this.refs[t])=="string";)t=n;return n||this.schemas[t]||bi.call(this,e,t)}function bi(e,t){let n=this.opts.uriResolver.parse(t),r=(0,gt._getFullPath)(this.opts.uriResolver,n),o=(0,gt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===o)return Nl.call(this,n,e);let i=(0,gt.normalizeId)(r),a=this.refs[i]||this.schemas[i];if(typeof a=="string"){let l=bi.call(this,e,a);return typeof l?.schema!="object"?void 0:Nl.call(this,n,l)}if(typeof a?.schema=="object"){if(a.validate||$l.call(this,a),i===(0,gt.normalizeId)(t)){let{schema:l}=a,{schemaId:c}=this.opts,u=l[c];return u&&(o=(0,gt.resolveUrl)(this.opts.uriResolver,o,u)),new cr({schema:l,schemaId:c,root:e,baseId:o})}return Nl.call(this,n,a)}}it.resolveSchema=bi;var TT=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Nl(e,{baseId:t,schema:n,root:r}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let l of e.fragment.slice(1).split("/")){if(typeof n=="boolean")return;let c=n[(0,Am.unescapeFragment)(l)];if(c===void 0)return;n=c;let u=typeof n=="object"&&n[this.opts.schemaId];!TT.has(l)&&u&&(t=(0,gt.resolveUrl)(this.opts.uriResolver,t,u))}let i;if(typeof n!="boolean"&&n.$ref&&!(0,Am.schemaHasRulesButRef)(n,this.RULES)){let l=(0,gt.resolveUrl)(this.opts.uriResolver,t,n.$ref);i=bi.call(this,r,l)}let{schemaId:a}=this.opts;if(i=i||new cr({schema:n,schemaId:a,root:r,baseId:t}),i.schema!==i.root.schema)return i}});var wm=C((IC,RT)=>{RT.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var Dl=C((NC,Pm)=>{"use strict";f();var AT=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),xl=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),kT=RegExp.prototype.test.bind(/^\d*$/u),Nn=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Pl=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Im=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Cl=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),wT=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),ze=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)ze[t]="%"+e[t>>4]+e[t&15]}function Ue(e){return e<2048?ze[192|e>>6]+ze[128|e&63]:e<65536?ze[224|e>>12]+ze[128|e>>6&63]+ze[128|e&63]:ze[240|e>>18]+ze[128|e>>12&63]+ze[128|e>>6&63]+ze[128|e&63]}function vT(e){let t="",n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return"";t+=e[r]}return t}var IT=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),NT=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),$T=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),OT=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function xT(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!$T(e[t])){if(e[t]==="%"&&t+2<e.length&&Nn(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function vm(e){let t=-1,n=0,r=-1,o=0;for(let l=0;l<e.length;l++)e[l]==="0"?(r===-1&&(r=l),o++,o>n&&(n=o,t=r)):(r=-1,o=0);if(n<2)return e.join(":");let i=e.slice(0,t).join(":"),a=e.slice(t+n).join(":");return i+"::"+a}function PT(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let n=t===-1?e.split(":"):e.slice(0,t).split(":"),r=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(n.length===1&&n[0]===""&&(n.length=0),r.length===1&&r[0]===""&&(r.length=0));let o=n.concat(r),i=0;for(let l=0;l<o.length;l++){let c=o[l];if(c==="")return;if(c.indexOf(".")!==-1){if(l!==o.length-1||t!==-1&&r.length===0||!xl(c))return;i+=2;continue}if(!IT(c))return;o[l]=parseInt(c,16).toString(16),i++}if(t===-1)return i!==8?void 0:vm(o);if(i>=8)return;let a=o.slice(0,n.length);for(let l=i;l<8;l++)a.push("0");for(let l=n.length;l<o.length;l++)a.push(o[l]);return vm(a)}function Ol(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let r=t?e.slice(1,-1):e;if(t&&NT(r))return r=r.toLowerCase(),{host:`[${r}]`,escapedHost:r,isIPV6:!1,isIPVFuture:!0};if(CT(r,":")<2)return{host:e,isIPV6:!1,error:t};let o="",i=r.indexOf("%");if(i!==-1){let l=r.slice(i,i+3).toLowerCase()==="%25"?3:1;if(o=r.slice(i+l),!xT(o))return{host:e,isIPV6:!1,error:!0};r=r.slice(0,i)}let a=PT(r);return a===void 0?{host:e,isIPV6:!1,error:!0}:{host:a+(o?"%"+o:""),escapedHost:a+(o?"%25"+o:""),isIPV6:!0}}function CT(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function LT(e){let t=e,n=[],r=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){n.push("/");break}else{n.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){n.push("/");break}}else if(o===3&&t==="/.."){n.length!==0&&n.pop(),n.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf("/",1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join("")}var DT={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},MT=/[@/?#:]/g,UT=/[@/?#]/g;function Nm(e,t){let n=t?UT:MT;return n.lastIndex=0,e.replace(n,r=>DT[r])}function $m(e,t=!1){if(e.indexOf("%")===-1)return e;let n="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(Nn(o)){let i=o.toUpperCase(),a=String.fromCharCode(parseInt(i,16));t&&Pl(a)?n+=a:n+="%"+i,r+=2;continue}}n+=e[r]}return n}function FT(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(r==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(Nn(o)){let i=o.toUpperCase(),a=String.fromCharCode(parseInt(i,16));a!=="."&&Pl(a)?t+=a:t+="%"+i,n+=2;continue}}if(Im(r))t+=r;else{let o=e.charCodeAt(n);if(o<128)t+=xm(o)?r:ze[o];else if(o<55296||o>57343)t+=Ue(o);else if(o<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(t+=Ue(65536+(o-55296<<10)+(i-56320)),n++):t+=Ue(65533)}else t+=Ue(65533)}}return t}function jT(e,t=!1){let n="",r=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let i=e[o];if(i==="%"&&o+2<e.length){let a=e.slice(o+1,o+3);if(Nn(a)){n+="%"+a.toUpperCase(),o+=2;continue}}if(i==="/"&&(r=!1),Im(i)&&(i!==":"||!r))n+=i;else{let a=e.charCodeAt(o);if(a<128)n+=ze[a];else if(a<55296||a>57343)n+=Ue(a);else if(a<=56319&&o+1<e.length){let l=e.charCodeAt(o+1);l>=56320&&l<=57343?(n+=Ue(65536+(a-55296<<10)+(l-56320)),o++):n+=Ue(65533)}else n+=Ue(65533)}}return n}function Ll(e,t){let n="";for(let r=0;r<e.length;r++){let o=e[r];if(o==="%"&&r+2<e.length){let i=e.slice(r+1,r+3);if(Nn(i)){n+="%"+i.toUpperCase(),r+=2;continue}}if(t(o))n+=o;else{let i=e.charCodeAt(r);if(i<128)n+=ze[i];else if(i<55296||i>57343)n+=Ue(i);else if(i<=56319&&r+1<e.length){let a=e.charCodeAt(r+1);a>=56320&&a<=57343?(n+=Ue(65536+(i-55296<<10)+(a-56320)),r++):n+=Ue(65533)}else n+=Ue(65533)}}return n}function Om(e){return Ll(e,wT)}function GT(e){return Ll(e,Cl)}function VT(e){return Ll(e,Cl)}function xm(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function HT(e){let t="";for(let n=0;n<e.length;n++){let r=e[n];if(r==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(Nn(o)){let i=o.toUpperCase(),a=String.fromCharCode(parseInt(i,16));Pl(a)?t+=a:t+="%"+i,n+=2;continue}}if(Cl(r))t+=r;else{let o=e.charCodeAt(n);if(o<128)t+=xm(o)?r:ze[o];else if(o<55296||o>57343)t+=Ue(o);else if(o<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(t+=Ue(65536+(o-55296<<10)+(i-56320)),n++):t+=Ue(65533)}else t+=Ue(65533)}}return t}function qT(e){let t="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let r=e.slice(n+1,n+3);if(Nn(r)){t+="%"+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function KT(e){let t=[];if(e.userinfo!==void 0&&(t.push(Om(e.userinfo)),t.push("@")),e.host!==void 0){let n=e.host;if(!xl(n)){let r=Ol(n);r.isIPV6!==!0&&r.isIPVFuture!==!0&&(n=$m(n,!0),r=Ol(n)),r.isIPV6===!0||r.isIPVFuture===!0?n=`[${r.escapedHost}]`:n=Nm(n,!1)}t.push(n)}if(typeof e.port=="number"||typeof e.port=="string"){let n=String(e.port);if(!kT(n))throw new TypeError("URI port is malformed.");t.push(":"),t.push(n)}return t.length?t.join(""):void 0}Pm.exports={nonSimpleDomain:OT,recomposeAuthority:KT,reescapeHostDelimiters:Nm,normalizePercentEncoding:$m,normalizePathEncoding:FT,serializePathEncoding:jT,normalizeQueryFragmentEncoding:HT,encodeUserinfo:Om,encodeQuery:GT,encodeFragment:VT,escapePreservingEscapes:qT,removeDotSegments:LT,isIPv4:xl,isUUID:AT,normalizeIPv6:Ol,stringArrayToHexStripped:vT}});var Um=C((OC,Mm)=>{"use strict";f();var{isUUID:BT}=Dl(),YT=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,WT=["http","https","ws","wss","urn","urn:uuid"];function zT(e){return WT.indexOf(e)!==-1}function Ml(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function Cm(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Lm(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function XT(e){return e.secure=Ml(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function JT(e){if((e.port===(Ml(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),n=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=n&&n!=="/"?n:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function QT(e,t){if(!e.path)return e.error="URN can not be parsed",e;let n=e.path.match(YT);if(n&&n[0]===e.path){let r=t.scheme||e.scheme||"urn";e.nid=n[1].toLowerCase(),e.nss=n[2];let o=`${r}:${t.nid||e.nid}`,i=Ul(o);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function ZT(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let n=t.scheme||e.scheme||"urn",r=e.nid.toLowerCase(),o=`${n}:${t.nid||r}`,i=Ul(o);i&&(e=i.serialize(e,t));let a=e,l=e.nss;return a.path=`${r||t.nid}:${l}`,t.skipEscape=!0,a}function eR(e,t){let n=e;return n.uuid=n.nss,n.nss=void 0,!t.tolerant&&(!n.uuid||!BT(n.uuid))&&(n.error=n.error||"UUID is not valid."),n}function tR(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Dm={scheme:"http",domainHost:!0,parse:Cm,serialize:Lm},nR={scheme:"https",domainHost:Dm.domainHost,parse:Cm,serialize:Lm},Ti={scheme:"ws",domainHost:!0,parse:XT,serialize:JT},rR={scheme:"wss",domainHost:Ti.domainHost,parse:Ti.parse,serialize:Ti.serialize},oR={scheme:"urn",parse:QT,serialize:ZT,skipNormalize:!0},iR={scheme:"urn:uuid",parse:eR,serialize:tR,skipNormalize:!0},Ri={http:Dm,https:nR,ws:Ti,wss:rR,urn:oR,"urn:uuid":iR};Object.setPrototypeOf(Ri,null);function Ul(e){return e&&(Ri[e]||Ri[e.toLowerCase()])||void 0}Mm.exports={wsIsSecure:Ml,SCHEMES:Ri,isValidSchemeName:zT,getSchemeHandler:Ul}});var Jm=C((PC,wi)=>{"use strict";f();var{normalizeIPv6:Hm,removeDotSegments:uo,recomposeAuthority:sR,normalizePercentEncoding:Fl,normalizePathEncoding:aR,serializePathEncoding:Fm,normalizeQueryFragmentEncoding:jm,encodeQuery:lR,encodeFragment:cR,reescapeHostDelimiters:uR,isIPv4:qm,nonSimpleDomain:dR}=Dl(),{SCHEMES:Km,getSchemeHandler:jl}=Um(),Bm=/^[A-Za-z][A-Za-z0-9+.-]*$/u,Ym="URI scheme is malformed.";function Gm(e){let t=unescape(String(e));if(!Bm.test(t))throw new TypeError(Ym);return t}function fR(e,t){return typeof e=="string"?e=SR(e,t):typeof e=="object"&&(e=ki($n(e,t),t)),e}function pR(e,t,n){let r=n?Object.assign({scheme:"null"},n):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:i,malformedPercentEncoding:a,malformedSchemeSpecific:l,malformedHost:c,malformedScheme:u}=Ai(e,r),{parsed:p,malformedAuthorityOrPort:m,malformedPercentEncoding:h,malformedSchemeSpecific:b,malformedHost:g,malformedScheme:S}=Ai(t,r);if(i||m||a||h||l||b||c||g||u||S)throw new Error(o.error||p.error||"URI is malformed.");let v=Wm(o,p,r,!0),R=jl(n&&n.scheme||v.scheme),P=v.host,M=P!==void 0&&P!==""&&(qm(P)||Hm(P).isIPV6);zm(v,n||{},R,M);let H=P&&P.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(P);if(v.error&&!H)throw new Error(v.error);return r.skipEscape=!0,$n(v,r)}function Wm(e,t,n,r){let o={};return r||(e=ki($n(e,n),n),t=ki($n(t,n),n)),n=n||{},!n.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=uo(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=uo(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=uo(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=uo(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function mR(e,t,n){let r=Vm(e,n),o=Vm(t,n);return r!==void 0&&o!==void 0&&r===o}function $n(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},r=Object.assign({},t),o=[];n.scheme&&(n.scheme=Gm(n.scheme));let i=jl(r.scheme||n.scheme);i&&i.serialize&&i.serialize(n,r);let a=n.userinfo!==void 0||n.host!==void 0||n.port!==void 0,l=!r.skipEscape&&n.scheme===void 0&&!a;n.path!==void 0&&(r.skipEscape?n.path=Fl(n.path):n.path=Fm(n.path,l)),r.reference!=="suffix"&&n.scheme&&(n.scheme=Gm(n.scheme),o.push(n.scheme,":"));let c=sR(n);if(c!==void 0&&(r.reference!=="suffix"&&o.push("//"),o.push(c),n.path&&n.path[0]!=="/"&&o.push("/")),n.path!==void 0){let u=n.path;!r.absolutePath&&(!i||!i.absolutePath)&&(u=uo(u)),l&&(u=Fm(u,!0)),c===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return n.query!==void 0&&o.push("?",lR(n.query)),n.fragment!==void 0&&o.push("#",cR(n.fragment)),o.join("")}var hR=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,gR=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,yR=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function _R(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function co(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function Gl(e){return e[0]==="["&&e[e.length-1]==="]"}function ER(e){let t=e[4];return co(e[3])||t!==void 0&&!Gl(t)&&co(t)||co(e[6])||co(e[7])||co(e[8])}function zm(e,t,n,r){if(!t.unicodeSupport&&(!n||!n.unicodeSupport)&&e.host&&!Gl(e.host)&&(t.domainHost||n&&n.domainHost)&&r===!1&&dR(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(o){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}function Ai(e,t){let n=Object.assign({},t),r={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,i=!1,a=!1,l=!1,c=!1,u=!1,p=!1;n.reference==="suffix"&&(n.scheme?e=n.scheme+":"+e:e="//"+e);let m=e.match(gR);m!==null&&m[1].indexOf("\\")!==-1&&(r.error="URI authority must not contain a literal backslash.",o=!0);let h=e.match(yR);if(h!==null){let g=h[1],S=g.replace(/[\t\n\r]/g,"");S.length>=2&&(S.slice(0,2)!=="//"?(r.error=r.error||"URI authority must not contain a literal backslash.",o=!0):g.length!==S.length&&(r.error=r.error||"URI authority introducer must not contain whitespace.",o=!0))}let b=e.match(hR);if(b){if(r.scheme=b[1],r.userinfo=b[3],r.host=b[4],r.port=parseInt(b[5],10),r.path=b[6]||"",r.query=b[7],r.fragment=b[8],r.scheme!==void 0){let v=unescape(r.scheme);Bm.test(v)?r.scheme=v.toLowerCase():(r.error=r.error||Ym,u=!0)}i=ER(b),i&&(r.error=r.error||"URI contains malformed percent-encoding."),isNaN(r.port)&&(r.port=b[5]);let g=_R(r,b);if(g!==void 0&&(r.error=r.error||g,o=!0),r.host)if(qm(r.host)===!1){let R=Gl(r.host),P=r.host.indexOf("[")!==-1||r.host.indexOf("]")!==-1,M=Hm(r.host);p=M.isIPV6||M.isIPVFuture===!0,c=P&&(!R||M.error===!0),r.host=p?M.host:M.host.toLowerCase(),c&&(r.error=r.error||"URI host is malformed.",o=!0)}else p=!0;r.scheme===void 0&&r.userinfo===void 0&&r.host===void 0&&r.port===void 0&&r.query===void 0&&!r.path?r.reference="same-document":r.scheme===void 0?r.reference="relative":r.fragment===void 0?r.reference="absolute":r.reference="uri",n.reference&&n.reference!=="suffix"&&n.reference!==r.reference&&(r.error=r.error||"URI is not a "+n.reference+" reference.");let S=jl(n.scheme||r.scheme);if(c||(l=zm(r,n,S,p)),e.indexOf("%")!==-1&&r.host!==void 0&&!c){let v=p?r.host:Fl(r.host,!0);p||(v=Fl(v.toLowerCase())),r.host=uR(v,p)}(!S||S&&!S.skipNormalize)&&(r.path&&(r.path=aR(r.path)),r.query&&(r.query=jm(r.query)),r.fragment&&(r.fragment=jm(r.fragment))),S&&S.parse&&(S.parse(r,n),S===Km.urn&&r.nid===void 0&&(a=!0))}else r.error=r.error||"URI can not be parsed.";return{parsed:r,malformedAuthorityOrPort:o,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:l,malformedScheme:u}}function ki(e,t){return Ai(e,t).parsed}function SR(e,t){return Xm(e,t).normalized}function Xm(e,t){let{parsed:n,malformedAuthorityOrPort:r,malformedPercentEncoding:o,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:l}=Ai(e,t);return{normalized:r||o||i||a||l?e:$n(n,t),malformedAuthorityOrPort:r,malformedPercentEncoding:o,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:l}}function Vm(e,t){if(typeof e!="string"&&typeof e!="object")return;let n;try{n=typeof e=="string"?e:$n(e,t)}catch{return}let{normalized:r,malformedAuthorityOrPort:o,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:l,malformedScheme:c}=Xm(n,t);return o||i||a||l||c?void 0:r}var Vl={SCHEMES:Km,normalize:fR,resolve:pR,resolveComponent:Wm,equal:mR,serialize:$n,parse:ki};wi.exports=Vl;wi.exports.default=Vl;wi.exports.fastUri=Vl});var Zm=C(Hl=>{"use strict";f();Object.defineProperty(Hl,"__esModule",{value:!0});var Qm=Jm();Qm.code='require("ajv/dist/runtime/uri").default';Hl.default=Qm});var ah=C(Ne=>{"use strict";f();Object.defineProperty(Ne,"__esModule",{value:!0});Ne.CodeGen=Ne.Name=Ne.nil=Ne.stringify=Ne.str=Ne._=Ne.KeywordCxt=void 0;var bR=so();Object.defineProperty(Ne,"KeywordCxt",{enumerable:!0,get:function(){return bR.KeywordCxt}});var ur=X();Object.defineProperty(Ne,"_",{enumerable:!0,get:function(){return ur._}});Object.defineProperty(Ne,"str",{enumerable:!0,get:function(){return ur.str}});Object.defineProperty(Ne,"stringify",{enumerable:!0,get:function(){return ur.stringify}});Object.defineProperty(Ne,"nil",{enumerable:!0,get:function(){return ur.nil}});Object.defineProperty(Ne,"Name",{enumerable:!0,get:function(){return ur.Name}});Object.defineProperty(Ne,"CodeGen",{enumerable:!0,get:function(){return ur.CodeGen}});var TR=Si(),oh=ao(),RR=dl(),fo=lo(),AR=X(),po=ro(),vi=no(),Kl=ie(),eh=wm(),kR=Zm(),ih=(e,t)=>new RegExp(e,t);ih.code="new RegExp";var wR=["removeAdditional","useDefaults","coerceTypes"],vR=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),IR={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},NR={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},th=200;function $R(e){var t,n,r,o,i,a,l,c,u,p,m,h,b,g,S,v,R,P,M,H,G,ge,Oe,et,Rt;let At=e.strict,kt=(t=e.code)===null||t===void 0?void 0:t.optimize,dn=kt===!0||kt===void 0?1:kt||0,Mt=(r=(n=e.code)===null||n===void 0?void 0:n.regExp)!==null&&r!==void 0?r:ih,ke=(o=e.uriResolver)!==null&&o!==void 0?o:kR.default;return{strictSchema:(a=(i=e.strictSchema)!==null&&i!==void 0?i:At)!==null&&a!==void 0?a:!0,strictNumbers:(c=(l=e.strictNumbers)!==null&&l!==void 0?l:At)!==null&&c!==void 0?c:!0,strictTypes:(p=(u=e.strictTypes)!==null&&u!==void 0?u:At)!==null&&p!==void 0?p:"log",strictTuples:(h=(m=e.strictTuples)!==null&&m!==void 0?m:At)!==null&&h!==void 0?h:"log",strictRequired:(g=(b=e.strictRequired)!==null&&b!==void 0?b:At)!==null&&g!==void 0?g:!1,code:e.code?{...e.code,optimize:dn,regExp:Mt}:{optimize:dn,regExp:Mt},loopRequired:(S=e.loopRequired)!==null&&S!==void 0?S:th,loopEnum:(v=e.loopEnum)!==null&&v!==void 0?v:th,meta:(R=e.meta)!==null&&R!==void 0?R:!0,messages:(P=e.messages)!==null&&P!==void 0?P:!0,inlineRefs:(M=e.inlineRefs)!==null&&M!==void 0?M:!0,schemaId:(H=e.schemaId)!==null&&H!==void 0?H:"$id",addUsedSchema:(G=e.addUsedSchema)!==null&&G!==void 0?G:!0,validateSchema:(ge=e.validateSchema)!==null&&ge!==void 0?ge:!0,validateFormats:(Oe=e.validateFormats)!==null&&Oe!==void 0?Oe:!0,unicodeRegExp:(et=e.unicodeRegExp)!==null&&et!==void 0?et:!0,int32range:(Rt=e.int32range)!==null&&Rt!==void 0?Rt:!0,uriResolver:ke}}var mo=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...$R(t)};let{es5:n,lines:r}=this.opts.code;this.scope=new AR.ValueScope({scope:{},prefixes:vR,es5:n,lines:r}),this.logger=DR(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,RR.getRules)(),nh.call(this,IR,t,"NOT SUPPORTED"),nh.call(this,NR,t,"DEPRECATED","warn"),this._metaOpts=CR.call(this),t.formats&&xR.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&PR.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),OR.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:n,schemaId:r}=this.opts,o=eh;r==="id"&&(o={...eh},o.id=o.$id,delete o.$id),n&&t&&this.addMetaSchema(o,o[r],!1)}defaultMeta(){let{meta:t,schemaId:n}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[n]||t:void 0}validate(t,n){let r;if(typeof t=="string"){if(r=this.getSchema(t),!r)throw new Error(`no schema with key or ref "${t}"`)}else r=this.compile(t);let o=r(n);return"$async"in r||(this.errors=r.errors),o}compile(t,n){let r=this._addSchema(t,n);return r.validate||this._compileSchemaEnv(r)}compileAsync(t,n){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:r}=this.opts;return o.call(this,t,n);async function o(p,m){await i.call(this,p.$schema);let h=this._addSchema(p,m);return h.validate||a.call(this,h)}async function i(p){p&&!this.getSchema(p)&&await o.call(this,{$ref:p},!0)}async function a(p){try{return this._compileSchemaEnv(p)}catch(m){if(!(m instanceof oh.default))throw m;return l.call(this,m),await c.call(this,m.missingSchema),a.call(this,p)}}function l({missingSchema:p,missingRef:m}){if(this.refs[p])throw new Error(`AnySchema ${p} is loaded but ${m} cannot be resolved`)}async function c(p){let m=await u.call(this,p);this.refs[p]||await i.call(this,m.$schema),this.refs[p]||this.addSchema(m,p,n)}async function u(p){let m=this._loading[p];if(m)return m;try{return await(this._loading[p]=r(p))}finally{delete this._loading[p]}}}addSchema(t,n,r,o=this.opts.validateSchema){if(Array.isArray(t)){for(let a of t)this.addSchema(a,void 0,r,o);return this}let i;if(typeof t=="object"){let{schemaId:a}=this.opts;if(i=t[a],i!==void 0&&typeof i!="string")throw new Error(`schema ${a} must be string`)}return n=(0,po.normalizeId)(n||i),this._checkUnique(n),this.schemas[n]=this._addSchema(t,r,n,o,!0),this}addMetaSchema(t,n,r=this.opts.validateSchema){return this.addSchema(t,n,!0,r),this}validateSchema(t,n){if(typeof t=="boolean")return!0;let r;if(r=t.$schema,r!==void 0&&typeof r!="string")throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(r,t);if(!o&&n){let i="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(i);else throw new Error(i)}return o}getSchema(t){let n;for(;typeof(n=rh.call(this,t))=="string";)t=n;if(n===void 0){let{schemaId:r}=this.opts,o=new fo.SchemaEnv({schema:{},schemaId:r});if(n=fo.resolveSchema.call(this,o,t),!n)return;this.refs[t]=n}return n.validate||this._compileSchemaEnv(n)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let n=rh.call(this,t);return typeof n=="object"&&this._cache.delete(n.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let n=t;this._cache.delete(n);let r=t[this.opts.schemaId];return r&&(r=(0,po.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let n of t)this.addKeyword(n);return this}addKeyword(t,n){let r;if(typeof t=="string")r=t,typeof n=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),n.keyword=r);else if(typeof t=="object"&&n===void 0){if(n=t,r=n.keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(UR.call(this,r,n),!n)return(0,Kl.eachItem)(r,i=>ql.call(this,i)),this;jR.call(this,n);let o={...n,type:(0,vi.getJSONTypes)(n.type),schemaType:(0,vi.getJSONTypes)(n.schemaType)};return(0,Kl.eachItem)(r,o.type.length===0?i=>ql.call(this,i,o):i=>o.type.forEach(a=>ql.call(this,i,o,a))),this}getKeyword(t){let n=this.RULES.all[t];return typeof n=="object"?n.definition:!!n}removeKeyword(t){let{RULES:n}=this;delete n.keywords[t],delete n.all[t];for(let r of n.rules){let o=r.rules.findIndex(i=>i.keyword===t);o>=0&&r.rules.splice(o,1)}return this}addFormat(t,n){return typeof n=="string"&&(n=new RegExp(n)),this.formats[t]=n,this}errorsText(t=this.errors,{separator:n=", ",dataVar:r="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${r}${o.instancePath} ${o.message}`).reduce((o,i)=>o+n+i)}$dataMetaSchema(t,n){let r=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of n){let i=o.split("/").slice(1),a=t;for(let l of i)a=a[l];for(let l in r){let c=r[l];if(typeof c!="object")continue;let{$data:u}=c.definition,p=a[l];u&&p&&(a[l]=sh(p))}}return t}_removeAllSchemas(t,n){for(let r in t){let o=t[r];(!n||n.test(r))&&(typeof o=="string"?delete t[r]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[r]))}}_addSchema(t,n,r,o=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:l}=this.opts;if(typeof t=="object")a=t[l];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;r=(0,po.normalizeId)(a||r);let u=po.getSchemaRefs.call(this,t,r);return c=new fo.SchemaEnv({schema:t,schemaId:l,meta:n,baseId:r,localRefs:u}),this._cache.set(c.schema,c),i&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=c),o&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):fo.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let n=this.opts;this.opts=this._metaOpts;try{fo.compileSchema.call(this,t)}finally{this.opts=n}}};mo.ValidationError=TR.default;mo.MissingRefError=oh.default;Ne.default=mo;function nh(e,t,n,r="error"){for(let o in e){let i=o;i in t&&this.logger[r](`${n}: option ${o}. ${e[i]}`)}}function rh(e){return e=(0,po.normalizeId)(e),this.schemas[e]||this.refs[e]}function OR(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function xR(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function PR(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let n=e[t];n.keyword||(n.keyword=t),this.addKeyword(n)}}function CR(){let e={...this.opts};for(let t of wR)delete e[t];return e}var LR={log(){},warn(){},error(){}};function DR(e){if(e===!1)return LR;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var MR=/^[a-z_$][a-z0-9_$:-]*$/i;function UR(e,t){let{RULES:n}=this;if((0,Kl.eachItem)(e,r=>{if(n.keywords[r])throw new Error(`Keyword ${r} is already defined`);if(!MR.test(r))throw new Error(`Keyword ${r} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function ql(e,t,n){var r;let o=t?.post;if(n&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:i}=this,a=o?i.post:i.rules.find(({type:c})=>c===n);if(a||(a={type:n,rules:[]},i.rules.push(a)),i.keywords[e]=!0,!t)return;let l={keyword:e,definition:{...t,type:(0,vi.getJSONTypes)(t.type),schemaType:(0,vi.getJSONTypes)(t.schemaType)}};t.before?FR.call(this,a,l,t.before):a.rules.push(l),i.all[e]=l,(r=t.implements)===null||r===void 0||r.forEach(c=>this.addKeyword(c))}function FR(e,t,n){let r=e.rules.findIndex(o=>o.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function jR(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=sh(t)),e.validateSchema=this.compile(t,!0))}var GR={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function sh(e){return{anyOf:[e,GR]}}});var lh=C(Bl=>{"use strict";f();Object.defineProperty(Bl,"__esModule",{value:!0});var VR={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Bl.default=VR});var $i=C(On=>{"use strict";f();Object.defineProperty(On,"__esModule",{value:!0});On.callRef=On.getValidate=void 0;var HR=ao(),ch=ot(),Xe=X(),dr=rt(),uh=lo(),Ii=ie(),qR={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:n,it:r}=e,{baseId:o,schemaEnv:i,validateName:a,opts:l,self:c}=r,{root:u}=i;if((n==="#"||n==="#/")&&o===u.baseId)return m();let p=uh.resolveRef.call(c,u,o,n);if(p===void 0)throw new HR.default(r.opts.uriResolver,o,n);if(p instanceof uh.SchemaEnv)return h(p);return b(p);function m(){if(i===u)return Ni(e,a,i,i.$async);let g=t.scopeValue("root",{ref:u});return Ni(e,(0,Xe._)`${g}.validate`,u,u.$async)}function h(g){let S=dh(e,g);Ni(e,S,g,g.$async)}function b(g){let S=t.scopeValue("schema",l.code.source===!0?{ref:g,code:(0,Xe.stringify)(g)}:{ref:g}),v=t.name("valid"),R=e.subschema({schema:g,dataTypes:[],schemaPath:Xe.nil,topSchemaRef:S,errSchemaPath:n},v);e.mergeEvaluated(R),e.ok(v)}}};function dh(e,t){let{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):(0,Xe._)`${n.scopeValue("wrapper",{ref:t})}.validate`}On.getValidate=dh;function Ni(e,t,n,r){let{gen:o,it:i}=e,{allErrors:a,schemaEnv:l,opts:c}=i,u=c.passContext?dr.default.this:Xe.nil;r?p():m();function p(){if(!l.$async)throw new Error("async schema referenced by sync schema");let g=o.let("valid");o.try(()=>{o.code((0,Xe._)`await ${(0,ch.callValidateCode)(e,t,u)}`),b(t),a||o.assign(g,!0)},S=>{o.if((0,Xe._)`!(${S} instanceof ${i.ValidationError})`,()=>o.throw(S)),h(S),a||o.assign(g,!1)}),e.ok(g)}function m(){e.result((0,ch.callValidateCode)(e,t,u),()=>b(t),()=>h(t))}function h(g){let S=(0,Xe._)`${g}.errors`;o.assign(dr.default.vErrors,(0,Xe._)`${dr.default.vErrors} === null ? ${S} : ${dr.default.vErrors}.concat(${S})`),o.assign(dr.default.errors,(0,Xe._)`${dr.default.vErrors}.length`)}function b(g){var S;if(!i.opts.unevaluated)return;let v=(S=n?.validate)===null||S===void 0?void 0:S.evaluated;if(i.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(i.props=Ii.mergeEvaluated.props(o,v.props,i.props));else{let R=o.var("props",(0,Xe._)`${g}.evaluated.props`);i.props=Ii.mergeEvaluated.props(o,R,i.props,Xe.Name)}if(i.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(i.items=Ii.mergeEvaluated.items(o,v.items,i.items));else{let R=o.var("items",(0,Xe._)`${g}.evaluated.items`);i.items=Ii.mergeEvaluated.items(o,R,i.items,Xe.Name)}}}On.callRef=Ni;On.default=qR});var fh=C(Yl=>{"use strict";f();Object.defineProperty(Yl,"__esModule",{value:!0});var KR=lh(),BR=$i(),YR=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",KR.default,BR.default];Yl.default=YR});var ph=C(Wl=>{"use strict";f();Object.defineProperty(Wl,"__esModule",{value:!0});var Oi=X(),cn=Oi.operators,xi={maximum:{okStr:"<=",ok:cn.LTE,fail:cn.GT},minimum:{okStr:">=",ok:cn.GTE,fail:cn.LT},exclusiveMaximum:{okStr:"<",ok:cn.LT,fail:cn.GTE},exclusiveMinimum:{okStr:">",ok:cn.GT,fail:cn.LTE}},WR={message:({keyword:e,schemaCode:t})=>(0,Oi.str)`must be ${xi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Oi._)`{comparison: ${xi[e].okStr}, limit: ${t}}`},zR={keyword:Object.keys(xi),type:"number",schemaType:"number",$data:!0,error:WR,code(e){let{keyword:t,data:n,schemaCode:r}=e;e.fail$data((0,Oi._)`${n} ${xi[t].fail} ${r} || isNaN(${n})`)}};Wl.default=zR});var mh=C(zl=>{"use strict";f();Object.defineProperty(zl,"__esModule",{value:!0});var ho=X(),XR={message:({schemaCode:e})=>(0,ho.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,ho._)`{multipleOf: ${e}}`},JR={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:XR,code(e){let{gen:t,data:n,schemaCode:r,it:o}=e,i=o.opts.multipleOfPrecision,a=t.let("res"),l=i?(0,ho._)`Math.abs(Math.round(${a}) - ${a}) > 1e-${i}`:(0,ho._)`${a} !== parseInt(${a})`;e.fail$data((0,ho._)`(${r} === 0 || (${a} = ${n}/${r}, ${l}))`)}};zl.default=JR});var gh=C(Xl=>{"use strict";f();Object.defineProperty(Xl,"__esModule",{value:!0});function hh(e){let t=e.length,n=0,r=0,o;for(;r<t;)n++,o=e.charCodeAt(r++),o>=55296&&o<=56319&&r<t&&(o=e.charCodeAt(r),(o&64512)===56320&&r++);return n}Xl.default=hh;hh.code='require("ajv/dist/runtime/ucs2length").default'});var yh=C(Jl=>{"use strict";f();Object.defineProperty(Jl,"__esModule",{value:!0});var xn=X(),QR=ie(),ZR=gh(),eA={message({keyword:e,schemaCode:t}){let n=e==="maxLength"?"more":"fewer";return(0,xn.str)`must NOT have ${n} than ${t} characters`},params:({schemaCode:e})=>(0,xn._)`{limit: ${e}}`},tA={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:eA,code(e){let{keyword:t,data:n,schemaCode:r,it:o}=e,i=t==="maxLength"?xn.operators.GT:xn.operators.LT,a=o.opts.unicode===!1?(0,xn._)`${n}.length`:(0,xn._)`${(0,QR.useFunc)(e.gen,ZR.default)}(${n})`;e.fail$data((0,xn._)`${a} ${i} ${r}`)}};Jl.default=tA});var _h=C(Ql=>{"use strict";f();Object.defineProperty(Ql,"__esModule",{value:!0});var nA=ot(),rA=ie(),fr=X(),oA={message:({schemaCode:e})=>(0,fr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,fr._)`{pattern: ${e}}`},iA={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:oA,code(e){let{gen:t,data:n,$data:r,schema:o,schemaCode:i,it:a}=e,l=a.opts.unicodeRegExp?"u":"";if(r){let{regExp:c}=a.opts.code,u=c.code==="new RegExp"?(0,fr._)`new RegExp`:(0,rA.useFunc)(t,c),p=t.let("valid");t.try(()=>t.assign(p,(0,fr._)`${u}(${i}, ${l}).test(${n})`),()=>t.assign(p,!1)),e.fail$data((0,fr._)`!${p}`)}else{let c=(0,nA.usePattern)(e,o);e.fail$data((0,fr._)`!${c}.test(${n})`)}}};Ql.default=iA});var Eh=C(Zl=>{"use strict";f();Object.defineProperty(Zl,"__esModule",{value:!0});var go=X(),sA={message({keyword:e,schemaCode:t}){let n=e==="maxProperties"?"more":"fewer";return(0,go.str)`must NOT have ${n} than ${t} properties`},params:({schemaCode:e})=>(0,go._)`{limit: ${e}}`},aA={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:sA,code(e){let{keyword:t,data:n,schemaCode:r}=e,o=t==="maxProperties"?go.operators.GT:go.operators.LT;e.fail$data((0,go._)`Object.keys(${n}).length ${o} ${r}`)}};Zl.default=aA});var Sh=C(ec=>{"use strict";f();Object.defineProperty(ec,"__esModule",{value:!0});var yo=ot(),_o=X(),lA=ie(),cA={message:({params:{missingProperty:e}})=>(0,_o.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,_o._)`{missingProperty: ${e}}`},uA={keyword:"required",type:"object",schemaType:"array",$data:!0,error:cA,code(e){let{gen:t,schema:n,schemaCode:r,data:o,$data:i,it:a}=e,{opts:l}=a;if(!i&&n.length===0)return;let c=n.length>=l.loopRequired;if(a.allErrors?u():p(),l.strictRequired){let b=e.parentSchema.properties,{definedProperties:g}=e.it;for(let S of n)if(b?.[S]===void 0&&!g.has(S)){let v=a.schemaEnv.baseId+a.errSchemaPath,R=`required property "${S}" is not defined at "${v}" (strictRequired)`;(0,lA.checkStrictMode)(a,R,a.opts.strictRequired)}}function u(){if(c||i)e.block$data(_o.nil,m);else for(let b of n)(0,yo.checkReportMissingProp)(e,b)}function p(){let b=t.let("missing");if(c||i){let g=t.let("valid",!0);e.block$data(g,()=>h(b,g)),e.ok(g)}else t.if((0,yo.checkMissingProp)(e,n,b)),(0,yo.reportMissingProp)(e,b),t.else()}function m(){t.forOf("prop",r,b=>{e.setParams({missingProperty:b}),t.if((0,yo.noPropertyInData)(t,o,b,l.ownProperties),()=>e.error())})}function h(b,g){e.setParams({missingProperty:b}),t.forOf(b,r,()=>{t.assign(g,(0,yo.propertyInData)(t,o,b,l.ownProperties)),t.if((0,_o.not)(g),()=>{e.error(),t.break()})},_o.nil)}}};ec.default=uA});var bh=C(tc=>{"use strict";f();Object.defineProperty(tc,"__esModule",{value:!0});var Eo=X(),dA={message({keyword:e,schemaCode:t}){let n=e==="maxItems"?"more":"fewer";return(0,Eo.str)`must NOT have ${n} than ${t} items`},params:({schemaCode:e})=>(0,Eo._)`{limit: ${e}}`},fA={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:dA,code(e){let{keyword:t,data:n,schemaCode:r}=e,o=t==="maxItems"?Eo.operators.GT:Eo.operators.LT;e.fail$data((0,Eo._)`${n}.length ${o} ${r}`)}};tc.default=fA});var Pi=C(nc=>{"use strict";f();Object.defineProperty(nc,"__esModule",{value:!0});var Th=El();Th.code='require("ajv/dist/runtime/equal").default';nc.default=Th});var Rh=C(oc=>{"use strict";f();Object.defineProperty(oc,"__esModule",{value:!0});var rc=no(),$e=X(),pA=ie(),mA=Pi(),hA={message:({params:{i:e,j:t}})=>(0,$e.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,$e._)`{i: ${e}, j: ${t}}`},gA={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:hA,code(e){let{gen:t,data:n,$data:r,schema:o,parentSchema:i,schemaCode:a,it:l}=e;if(!r&&!o)return;let c=t.let("valid"),u=i.items?(0,rc.getSchemaTypes)(i.items):[];e.block$data(c,p,(0,$e._)`${a} === false`),e.ok(c);function p(){let g=t.let("i",(0,$e._)`${n}.length`),S=t.let("j");e.setParams({i:g,j:S}),t.assign(c,!0),t.if((0,$e._)`${g} > 1`,()=>(m()?h:b)(g,S))}function m(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}function h(g,S){let v=t.name("item"),R=(0,rc.checkDataTypes)(u,v,l.opts.strictNumbers,rc.DataType.Wrong),P=t.const("indices",(0,$e._)`{}`);t.for((0,$e._)`;${g}--;`,()=>{t.let(v,(0,$e._)`${n}[${g}]`),t.if(R,(0,$e._)`continue`),u.length>1&&t.if((0,$e._)`typeof ${v} == "string"`,(0,$e._)`${v} += "_"`),t.if((0,$e._)`typeof ${P}[${v}] == "number"`,()=>{t.assign(S,(0,$e._)`${P}[${v}]`),e.error(),t.assign(c,!1).break()}).code((0,$e._)`${P}[${v}] = ${g}`)})}function b(g,S){let v=(0,pA.useFunc)(t,mA.default),R=t.name("outer");t.label(R).for((0,$e._)`;${g}--;`,()=>t.for((0,$e._)`${S} = ${g}; ${S}--;`,()=>t.if((0,$e._)`${v}(${n}[${g}], ${n}[${S}])`,()=>{e.error(),t.assign(c,!1).break(R)})))}}};oc.default=gA});var Ah=C(sc=>{"use strict";f();Object.defineProperty(sc,"__esModule",{value:!0});var ic=X(),yA=ie(),_A=Pi(),EA={message:"must be equal to constant",params:({schemaCode:e})=>(0,ic._)`{allowedValue: ${e}}`},SA={keyword:"const",$data:!0,error:EA,code(e){let{gen:t,data:n,$data:r,schemaCode:o,schema:i}=e;r||i&&typeof i=="object"?e.fail$data((0,ic._)`!${(0,yA.useFunc)(t,_A.default)}(${n}, ${o})`):e.fail((0,ic._)`${i} !== ${n}`)}};sc.default=SA});var kh=C(ac=>{"use strict";f();Object.defineProperty(ac,"__esModule",{value:!0});var So=X(),bA=ie(),TA=Pi(),RA={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,So._)`{allowedValues: ${e}}`},AA={keyword:"enum",schemaType:"array",$data:!0,error:RA,code(e){let{gen:t,data:n,$data:r,schema:o,schemaCode:i,it:a}=e;if(!r&&o.length===0)throw new Error("enum must have non-empty array");let l=o.length>=a.opts.loopEnum,c,u=()=>c??(c=(0,bA.useFunc)(t,TA.default)),p;if(l||r)p=t.let("valid"),e.block$data(p,m);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let b=t.const("vSchema",i);p=(0,So.or)(...o.map((g,S)=>h(b,S)))}e.pass(p);function m(){t.assign(p,!1),t.forOf("v",i,b=>t.if((0,So._)`${u()}(${n}, ${b})`,()=>t.assign(p,!0).break()))}function h(b,g){let S=o[g];return typeof S=="object"&&S!==null?(0,So._)`${u()}(${n}, ${b}[${g}])`:(0,So._)`${n} === ${S}`}}};ac.default=AA});var wh=C(lc=>{"use strict";f();Object.defineProperty(lc,"__esModule",{value:!0});var kA=ph(),wA=mh(),vA=yh(),IA=_h(),NA=Eh(),$A=Sh(),OA=bh(),xA=Rh(),PA=Ah(),CA=kh(),LA=[kA.default,wA.default,vA.default,IA.default,NA.default,$A.default,OA.default,xA.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},PA.default,CA.default];lc.default=LA});var uc=C(bo=>{"use strict";f();Object.defineProperty(bo,"__esModule",{value:!0});bo.validateAdditionalItems=void 0;var Pn=X(),cc=ie(),DA={message:({params:{len:e}})=>(0,Pn.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Pn._)`{limit: ${e}}`},MA={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:DA,code(e){let{parentSchema:t,it:n}=e,{items:r}=t;if(!Array.isArray(r)){(0,cc.checkStrictMode)(n,'"additionalItems" is ignored when "items" is not an array of schemas');return}vh(e,r)}};function vh(e,t){let{gen:n,schema:r,data:o,keyword:i,it:a}=e;a.items=!0;let l=n.const("len",(0,Pn._)`${o}.length`);if(r===!1)e.setParams({len:t.length}),e.pass((0,Pn._)`${l} <= ${t.length}`);else if(typeof r=="object"&&!(0,cc.alwaysValidSchema)(a,r)){let u=n.var("valid",(0,Pn._)`${l} <= ${t.length}`);n.if((0,Pn.not)(u),()=>c(u)),e.ok(u)}function c(u){n.forRange("i",t.length,l,p=>{e.subschema({keyword:i,dataProp:p,dataPropType:cc.Type.Num},u),a.allErrors||n.if((0,Pn.not)(u),()=>n.break())})}}bo.validateAdditionalItems=vh;bo.default=MA});var dc=C(To=>{"use strict";f();Object.defineProperty(To,"__esModule",{value:!0});To.validateTuple=void 0;var Ih=X(),Ci=ie(),UA=ot(),FA={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:n}=e;if(Array.isArray(t))return Nh(e,"additionalItems",t);n.items=!0,!(0,Ci.alwaysValidSchema)(n,t)&&e.ok((0,UA.validateArray)(e))}};function Nh(e,t,n=e.schema){let{gen:r,parentSchema:o,data:i,keyword:a,it:l}=e;p(o),l.opts.unevaluated&&n.length&&l.items!==!0&&(l.items=Ci.mergeEvaluated.items(r,n.length,l.items));let c=r.name("valid"),u=r.const("len",(0,Ih._)`${i}.length`);n.forEach((m,h)=>{(0,Ci.alwaysValidSchema)(l,m)||(r.if((0,Ih._)`${u} > ${h}`,()=>e.subschema({keyword:a,schemaProp:h,dataProp:h},c)),e.ok(c))});function p(m){let{opts:h,errSchemaPath:b}=l,g=n.length,S=g===m.minItems&&(g===m.maxItems||m[t]===!1);if(h.strictTuples&&!S){let v=`"${a}" is ${g}-tuple, but minItems or maxItems/${t} are not specified or different at path "${b}"`;(0,Ci.checkStrictMode)(l,v,h.strictTuples)}}}To.validateTuple=Nh;To.default=FA});var $h=C(fc=>{"use strict";f();Object.defineProperty(fc,"__esModule",{value:!0});var jA=dc(),GA={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,jA.validateTuple)(e,"items")};fc.default=GA});var xh=C(pc=>{"use strict";f();Object.defineProperty(pc,"__esModule",{value:!0});var Oh=X(),VA=ie(),HA=ot(),qA=uc(),KA={message:({params:{len:e}})=>(0,Oh.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Oh._)`{limit: ${e}}`},BA={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:KA,code(e){let{schema:t,parentSchema:n,it:r}=e,{prefixItems:o}=n;r.items=!0,!(0,VA.alwaysValidSchema)(r,t)&&(o?(0,qA.validateAdditionalItems)(e,o):e.ok((0,HA.validateArray)(e)))}};pc.default=BA});var Ph=C(mc=>{"use strict";f();Object.defineProperty(mc,"__esModule",{value:!0});var st=X(),Li=ie(),YA={message:({params:{min:e,max:t}})=>t===void 0?(0,st.str)`must contain at least ${e} valid item(s)`:(0,st.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,st._)`{minContains: ${e}}`:(0,st._)`{minContains: ${e}, maxContains: ${t}}`},WA={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:YA,code(e){let{gen:t,schema:n,parentSchema:r,data:o,it:i}=e,a,l,{minContains:c,maxContains:u}=r;i.opts.next?(a=c===void 0?1:c,l=u):a=1;let p=t.const("len",(0,st._)`${o}.length`);if(e.setParams({min:a,max:l}),l===void 0&&a===0){(0,Li.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(l!==void 0&&a>l){(0,Li.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,Li.alwaysValidSchema)(i,n)){let S=(0,st._)`${p} >= ${a}`;l!==void 0&&(S=(0,st._)`${S} && ${p} <= ${l}`),e.pass(S);return}i.items=!0;let m=t.name("valid");l===void 0&&a===1?b(m,()=>t.if(m,()=>t.break())):a===0?(t.let(m,!0),l!==void 0&&t.if((0,st._)`${o}.length > 0`,h)):(t.let(m,!1),h()),e.result(m,()=>e.reset());function h(){let S=t.name("_valid"),v=t.let("count",0);b(S,()=>t.if(S,()=>g(v)))}function b(S,v){t.forRange("i",0,p,R=>{e.subschema({keyword:"contains",dataProp:R,dataPropType:Li.Type.Num,compositeRule:!0},S),v()})}function g(S){t.code((0,st._)`${S}++`),l===void 0?t.if((0,st._)`${S} >= ${a}`,()=>t.assign(m,!0).break()):(t.if((0,st._)`${S} > ${l}`,()=>t.assign(m,!1).break()),a===1?t.assign(m,!0):t.if((0,st._)`${S} >= ${a}`,()=>t.assign(m,!0)))}}};mc.default=WA});var Di=C(Tt=>{"use strict";f();Object.defineProperty(Tt,"__esModule",{value:!0});Tt.validateSchemaDeps=Tt.validatePropertyDeps=Tt.error=void 0;var hc=X(),zA=ie(),Ro=ot();Tt.error={message:({params:{property:e,depsCount:t,deps:n}})=>{let r=t===1?"property":"properties";return(0,hc.str)`must have ${r} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:n,missingProperty:r}})=>(0,hc._)`{property: ${e},
885
+ missingProperty: ${r},
886
+ depsCount: ${t},
887
+ deps: ${n}}`};var XA={keyword:"dependencies",type:"object",schemaType:"object",error:Tt.error,code(e){let[t,n]=JA(e);Ch(e,t),Lh(e,n)}};function JA({schema:e}){let t={},n={};for(let r in e){if(r==="__proto__")continue;let o=Array.isArray(e[r])?t:n;o[r]=e[r]}return[t,n]}function Ch(e,t=e.schema){let{gen:n,data:r,it:o}=e;if(Object.keys(t).length===0)return;let i=n.let("missing");for(let a in t){let l=t[a];if(l.length===0)continue;let c=(0,Ro.propertyInData)(n,r,a,o.opts.ownProperties);e.setParams({property:a,depsCount:l.length,deps:l.join(", ")}),o.allErrors?n.if(c,()=>{for(let u of l)(0,Ro.checkReportMissingProp)(e,u)}):(n.if((0,hc._)`${c} && (${(0,Ro.checkMissingProp)(e,l,i)})`),(0,Ro.reportMissingProp)(e,i),n.else())}}Tt.validatePropertyDeps=Ch;function Lh(e,t=e.schema){let{gen:n,data:r,keyword:o,it:i}=e,a=n.name("valid");for(let l in t)(0,zA.alwaysValidSchema)(i,t[l])||(n.if((0,Ro.propertyInData)(n,r,l,i.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:l},a);e.mergeValidEvaluated(c,a)},()=>n.var(a,!0)),e.ok(a))}Tt.validateSchemaDeps=Lh;Tt.default=XA});var Mh=C(gc=>{"use strict";f();Object.defineProperty(gc,"__esModule",{value:!0});var Dh=X(),QA=ie(),ZA={message:"property name must be valid",params:({params:e})=>(0,Dh._)`{propertyName: ${e.propertyName}}`},ek={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:ZA,code(e){let{gen:t,schema:n,data:r,it:o}=e;if((0,QA.alwaysValidSchema)(o,n))return;let i=t.name("valid");t.forIn("key",r,a=>{e.setParams({propertyName:a}),e.subschema({keyword:"propertyNames",data:a,dataTypes:["string"],propertyName:a,compositeRule:!0},i),t.if((0,Dh.not)(i),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(i)}};gc.default=ek});var _c=C(yc=>{"use strict";f();Object.defineProperty(yc,"__esModule",{value:!0});var Mi=ot(),yt=X(),tk=rt(),Ui=ie(),nk={message:"must NOT have additional properties",params:({params:e})=>(0,yt._)`{additionalProperty: ${e.additionalProperty}}`},rk={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:nk,code(e){let{gen:t,schema:n,parentSchema:r,data:o,errsCount:i,it:a}=e;if(!i)throw new Error("ajv implementation error");let{allErrors:l,opts:c}=a;if(a.props=!0,c.removeAdditional!=="all"&&(0,Ui.alwaysValidSchema)(a,n))return;let u=(0,Mi.allSchemaProperties)(r.properties),p=(0,Mi.allSchemaProperties)(r.patternProperties);m(),e.ok((0,yt._)`${i} === ${tk.default.errors}`);function m(){t.forIn("key",o,v=>{!u.length&&!p.length?g(v):t.if(h(v),()=>g(v))})}function h(v){let R;if(u.length>8){let P=(0,Ui.schemaRefOrVal)(a,r.properties,"properties");R=(0,Mi.isOwnProperty)(t,P,v)}else u.length?R=(0,yt.or)(...u.map(P=>(0,yt._)`${v} === ${P}`)):R=yt.nil;return p.length&&(R=(0,yt.or)(R,...p.map(P=>(0,yt._)`${(0,Mi.usePattern)(e,P)}.test(${v})`))),(0,yt.not)(R)}function b(v){t.code((0,yt._)`delete ${o}[${v}]`)}function g(v){if(c.removeAdditional==="all"||c.removeAdditional&&n===!1){b(v);return}if(n===!1){e.setParams({additionalProperty:v}),e.error(),l||t.break();return}if(typeof n=="object"&&!(0,Ui.alwaysValidSchema)(a,n)){let R=t.name("valid");c.removeAdditional==="failing"?(S(v,R,!1),t.if((0,yt.not)(R),()=>{e.reset(),b(v)})):(S(v,R),l||t.if((0,yt.not)(R),()=>t.break()))}}function S(v,R,P){let M={keyword:"additionalProperties",dataProp:v,dataPropType:Ui.Type.Str};P===!1&&Object.assign(M,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(M,R)}}};yc.default=rk});var jh=C(Sc=>{"use strict";f();Object.defineProperty(Sc,"__esModule",{value:!0});var ok=so(),Uh=ot(),Ec=ie(),Fh=_c(),ik={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:n,parentSchema:r,data:o,it:i}=e;i.opts.removeAdditional==="all"&&r.additionalProperties===void 0&&Fh.default.code(new ok.KeywordCxt(i,Fh.default,"additionalProperties"));let a=(0,Uh.allSchemaProperties)(n);for(let m of a)i.definedProperties.add(m);i.opts.unevaluated&&a.length&&i.props!==!0&&(i.props=Ec.mergeEvaluated.props(t,(0,Ec.toHash)(a),i.props));let l=a.filter(m=>!(0,Ec.alwaysValidSchema)(i,n[m]));if(l.length===0)return;let c=t.name("valid");for(let m of l)u(m)?p(m):(t.if((0,Uh.propertyInData)(t,o,m,i.opts.ownProperties)),p(m),i.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(m),e.ok(c);function u(m){return i.opts.useDefaults&&!i.compositeRule&&n[m].default!==void 0}function p(m){e.subschema({keyword:"properties",schemaProp:m,dataProp:m},c)}}};Sc.default=ik});var qh=C(bc=>{"use strict";f();Object.defineProperty(bc,"__esModule",{value:!0});var Gh=ot(),Fi=X(),Vh=ie(),Hh=ie(),sk={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:n,data:r,parentSchema:o,it:i}=e,{opts:a}=i,l=(0,Gh.allSchemaProperties)(n),c=l.filter(S=>(0,Vh.alwaysValidSchema)(i,n[S]));if(l.length===0||c.length===l.length&&(!i.opts.unevaluated||i.props===!0))return;let u=a.strictSchema&&!a.allowMatchingProperties&&o.properties,p=t.name("valid");i.props!==!0&&!(i.props instanceof Fi.Name)&&(i.props=(0,Hh.evaluatedPropsToName)(t,i.props));let{props:m}=i;h();function h(){for(let S of l)u&&b(S),i.allErrors?g(S):(t.var(p,!0),g(S),t.if(p))}function b(S){for(let v in u)new RegExp(S).test(v)&&(0,Vh.checkStrictMode)(i,`property ${v} matches pattern ${S} (use allowMatchingProperties)`)}function g(S){t.forIn("key",r,v=>{t.if((0,Fi._)`${(0,Gh.usePattern)(e,S)}.test(${v})`,()=>{let R=c.includes(S);R||e.subschema({keyword:"patternProperties",schemaProp:S,dataProp:v,dataPropType:Hh.Type.Str},p),i.opts.unevaluated&&m!==!0?t.assign((0,Fi._)`${m}[${v}]`,!0):!R&&!i.allErrors&&t.if((0,Fi.not)(p),()=>t.break())})})}}};bc.default=sk});var Kh=C(Tc=>{"use strict";f();Object.defineProperty(Tc,"__esModule",{value:!0});var ak=ie(),lk={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:n,it:r}=e;if((0,ak.alwaysValidSchema)(r,n)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Tc.default=lk});var Bh=C(Rc=>{"use strict";f();Object.defineProperty(Rc,"__esModule",{value:!0});var ck=ot(),uk={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:ck.validateUnion,error:{message:"must match a schema in anyOf"}};Rc.default=uk});var Yh=C(Ac=>{"use strict";f();Object.defineProperty(Ac,"__esModule",{value:!0});var ji=X(),dk=ie(),fk={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ji._)`{passingSchemas: ${e.passing}}`},pk={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:fk,code(e){let{gen:t,schema:n,parentSchema:r,it:o}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");if(o.opts.discriminator&&r.discriminator)return;let i=n,a=t.let("valid",!1),l=t.let("passing",null),c=t.name("_valid");e.setParams({passing:l}),t.block(u),e.result(a,()=>e.reset(),()=>e.error(!0));function u(){i.forEach((p,m)=>{let h;(0,dk.alwaysValidSchema)(o,p)?t.var(c,!0):h=e.subschema({keyword:"oneOf",schemaProp:m,compositeRule:!0},c),m>0&&t.if((0,ji._)`${c} && ${a}`).assign(a,!1).assign(l,(0,ji._)`[${l}, ${m}]`).else(),t.if(c,()=>{t.assign(a,!0),t.assign(l,m),h&&e.mergeEvaluated(h,ji.Name)})})}}};Ac.default=pk});var Wh=C(kc=>{"use strict";f();Object.defineProperty(kc,"__esModule",{value:!0});var mk=ie(),hk={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:n,it:r}=e;if(!Array.isArray(n))throw new Error("ajv implementation error");let o=t.name("valid");n.forEach((i,a)=>{if((0,mk.alwaysValidSchema)(r,i))return;let l=e.subschema({keyword:"allOf",schemaProp:a},o);e.ok(o),e.mergeEvaluated(l)})}};kc.default=hk});var Jh=C(wc=>{"use strict";f();Object.defineProperty(wc,"__esModule",{value:!0});var Gi=X(),Xh=ie(),gk={message:({params:e})=>(0,Gi.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Gi._)`{failingKeyword: ${e.ifClause}}`},yk={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:gk,code(e){let{gen:t,parentSchema:n,it:r}=e;n.then===void 0&&n.else===void 0&&(0,Xh.checkStrictMode)(r,'"if" without "then" and "else" is ignored');let o=zh(r,"then"),i=zh(r,"else");if(!o&&!i)return;let a=t.let("valid",!0),l=t.name("_valid");if(c(),e.reset(),o&&i){let p=t.let("ifClause");e.setParams({ifClause:p}),t.if(l,u("then",p),u("else",p))}else o?t.if(l,u("then")):t.if((0,Gi.not)(l),u("else"));e.pass(a,()=>e.error(!0));function c(){let p=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},l);e.mergeEvaluated(p)}function u(p,m){return()=>{let h=e.subschema({keyword:p},l);t.assign(a,l),e.mergeValidEvaluated(h,a),m?t.assign(m,(0,Gi._)`${p}`):e.setParams({ifClause:p})}}}};function zh(e,t){let n=e.schema[t];return n!==void 0&&!(0,Xh.alwaysValidSchema)(e,n)}wc.default=yk});var Qh=C(vc=>{"use strict";f();Object.defineProperty(vc,"__esModule",{value:!0});var _k=ie(),Ek={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:n}){t.if===void 0&&(0,_k.checkStrictMode)(n,`"${e}" without "if" is ignored`)}};vc.default=Ek});var Zh=C(Ic=>{"use strict";f();Object.defineProperty(Ic,"__esModule",{value:!0});var Sk=uc(),bk=$h(),Tk=dc(),Rk=xh(),Ak=Ph(),kk=Di(),wk=Mh(),vk=_c(),Ik=jh(),Nk=qh(),$k=Kh(),Ok=Bh(),xk=Yh(),Pk=Wh(),Ck=Jh(),Lk=Qh();function Dk(e=!1){let t=[$k.default,Ok.default,xk.default,Pk.default,Ck.default,Lk.default,wk.default,vk.default,kk.default,Ik.default,Nk.default];return e?t.push(bk.default,Rk.default):t.push(Sk.default,Tk.default),t.push(Ak.default),t}Ic.default=Dk});var $c=C(Ao=>{"use strict";f();Object.defineProperty(Ao,"__esModule",{value:!0});Ao.dynamicAnchor=void 0;var Nc=X(),Mk=rt(),eg=lo(),Uk=$i(),Fk={keyword:"$dynamicAnchor",schemaType:"string",code:e=>tg(e,e.schema)};function tg(e,t){let{gen:n,it:r}=e;r.schemaEnv.root.dynamicAnchors[t]=!0;let o=(0,Nc._)`${Mk.default.dynamicAnchors}${(0,Nc.getProperty)(t)}`,i=r.errSchemaPath==="#"?r.validateName:jk(e);n.if((0,Nc._)`!${o}`,()=>n.assign(o,i))}Ao.dynamicAnchor=tg;function jk(e){let{schemaEnv:t,schema:n,self:r}=e.it,{root:o,baseId:i,localRefs:a,meta:l}=t.root,{schemaId:c}=r.opts,u=new eg.SchemaEnv({schema:n,schemaId:c,root:o,baseId:i,localRefs:a,meta:l});return eg.compileSchema.call(r,u),(0,Uk.getValidate)(e,u)}Ao.default=Fk});var Oc=C(ko=>{"use strict";f();Object.defineProperty(ko,"__esModule",{value:!0});ko.dynamicRef=void 0;var ng=X(),Gk=rt(),rg=$i(),Vk={keyword:"$dynamicRef",schemaType:"string",code:e=>og(e,e.schema)};function og(e,t){let{gen:n,keyword:r,it:o}=e;if(t[0]!=="#")throw new Error(`"${r}" only supports hash fragment reference`);let i=t.slice(1);if(o.allErrors)a();else{let c=n.let("valid",!1);a(c),e.ok(c)}function a(c){if(o.schemaEnv.root.dynamicAnchors[i]){let u=n.let("_v",(0,ng._)`${Gk.default.dynamicAnchors}${(0,ng.getProperty)(i)}`);n.if(u,l(u,c),l(o.validateName,c))}else l(o.validateName,c)()}function l(c,u){return u?()=>n.block(()=>{(0,rg.callRef)(e,c),n.let(u,!0)}):()=>(0,rg.callRef)(e,c)}}ko.dynamicRef=og;ko.default=Vk});var ig=C(xc=>{"use strict";f();Object.defineProperty(xc,"__esModule",{value:!0});var Hk=$c(),qk=ie(),Kk={keyword:"$recursiveAnchor",schemaType:"boolean",code(e){e.schema?(0,Hk.dynamicAnchor)(e,""):(0,qk.checkStrictMode)(e.it,"$recursiveAnchor: false is ignored")}};xc.default=Kk});var sg=C(Pc=>{"use strict";f();Object.defineProperty(Pc,"__esModule",{value:!0});var Bk=Oc(),Yk={keyword:"$recursiveRef",schemaType:"string",code:e=>(0,Bk.dynamicRef)(e,e.schema)};Pc.default=Yk});var ag=C(Cc=>{"use strict";f();Object.defineProperty(Cc,"__esModule",{value:!0});var Wk=$c(),zk=Oc(),Xk=ig(),Jk=sg(),Qk=[Wk.default,zk.default,Xk.default,Jk.default];Cc.default=Qk});var cg=C(Lc=>{"use strict";f();Object.defineProperty(Lc,"__esModule",{value:!0});var lg=Di(),Zk={keyword:"dependentRequired",type:"object",schemaType:"object",error:lg.error,code:e=>(0,lg.validatePropertyDeps)(e)};Lc.default=Zk});var ug=C(Dc=>{"use strict";f();Object.defineProperty(Dc,"__esModule",{value:!0});var ew=Di(),tw={keyword:"dependentSchemas",type:"object",schemaType:"object",code:e=>(0,ew.validateSchemaDeps)(e)};Dc.default=tw});var dg=C(Mc=>{"use strict";f();Object.defineProperty(Mc,"__esModule",{value:!0});var nw=ie(),rw={keyword:["maxContains","minContains"],type:"array",schemaType:"number",code({keyword:e,parentSchema:t,it:n}){t.contains===void 0&&(0,nw.checkStrictMode)(n,`"${e}" without "contains" is ignored`)}};Mc.default=rw});var fg=C(Uc=>{"use strict";f();Object.defineProperty(Uc,"__esModule",{value:!0});var ow=cg(),iw=ug(),sw=dg(),aw=[ow.default,iw.default,sw.default];Uc.default=aw});var mg=C(Fc=>{"use strict";f();Object.defineProperty(Fc,"__esModule",{value:!0});var un=X(),pg=ie(),lw=rt(),cw={message:"must NOT have unevaluated properties",params:({params:e})=>(0,un._)`{unevaluatedProperty: ${e.unevaluatedProperty}}`},uw={keyword:"unevaluatedProperties",type:"object",schemaType:["boolean","object"],trackErrors:!0,error:cw,code(e){let{gen:t,schema:n,data:r,errsCount:o,it:i}=e;if(!o)throw new Error("ajv implementation error");let{allErrors:a,props:l}=i;l instanceof un.Name?t.if((0,un._)`${l} !== true`,()=>t.forIn("key",r,m=>t.if(u(l,m),()=>c(m)))):l!==!0&&t.forIn("key",r,m=>l===void 0?c(m):t.if(p(l,m),()=>c(m))),i.props=!0,e.ok((0,un._)`${o} === ${lw.default.errors}`);function c(m){if(n===!1){e.setParams({unevaluatedProperty:m}),e.error(),a||t.break();return}if(!(0,pg.alwaysValidSchema)(i,n)){let h=t.name("valid");e.subschema({keyword:"unevaluatedProperties",dataProp:m,dataPropType:pg.Type.Str},h),a||t.if((0,un.not)(h),()=>t.break())}}function u(m,h){return(0,un._)`!${m} || !${m}[${h}]`}function p(m,h){let b=[];for(let g in m)m[g]===!0&&b.push((0,un._)`${h} !== ${g}`);return(0,un.and)(...b)}}};Fc.default=uw});var gg=C(jc=>{"use strict";f();Object.defineProperty(jc,"__esModule",{value:!0});var Cn=X(),hg=ie(),dw={message:({params:{len:e}})=>(0,Cn.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Cn._)`{limit: ${e}}`},fw={keyword:"unevaluatedItems",type:"array",schemaType:["boolean","object"],error:dw,code(e){let{gen:t,schema:n,data:r,it:o}=e,i=o.items||0;if(i===!0)return;let a=t.const("len",(0,Cn._)`${r}.length`);if(n===!1)e.setParams({len:i}),e.fail((0,Cn._)`${a} > ${i}`);else if(typeof n=="object"&&!(0,hg.alwaysValidSchema)(o,n)){let c=t.var("valid",(0,Cn._)`${a} <= ${i}`);t.if((0,Cn.not)(c),()=>l(c,i)),e.ok(c)}o.items=!0;function l(c,u){t.forRange("i",u,a,p=>{e.subschema({keyword:"unevaluatedItems",dataProp:p,dataPropType:hg.Type.Num},c),o.allErrors||t.if((0,Cn.not)(c),()=>t.break())})}}};jc.default=fw});var yg=C(Gc=>{"use strict";f();Object.defineProperty(Gc,"__esModule",{value:!0});var pw=mg(),mw=gg(),hw=[pw.default,mw.default];Gc.default=hw});var _g=C(Vc=>{"use strict";f();Object.defineProperty(Vc,"__esModule",{value:!0});var Ae=X(),gw={message:({schemaCode:e})=>(0,Ae.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Ae._)`{format: ${e}}`},yw={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:gw,code(e,t){let{gen:n,data:r,$data:o,schema:i,schemaCode:a,it:l}=e,{opts:c,errSchemaPath:u,schemaEnv:p,self:m}=l;if(!c.validateFormats)return;o?h():b();function h(){let g=n.scopeValue("formats",{ref:m.formats,code:c.code.formats}),S=n.const("fDef",(0,Ae._)`${g}[${a}]`),v=n.let("fType"),R=n.let("format");n.if((0,Ae._)`typeof ${S} == "object" && !(${S} instanceof RegExp)`,()=>n.assign(v,(0,Ae._)`${S}.type || "string"`).assign(R,(0,Ae._)`${S}.validate`),()=>n.assign(v,(0,Ae._)`"string"`).assign(R,S)),e.fail$data((0,Ae.or)(P(),M()));function P(){return c.strictSchema===!1?Ae.nil:(0,Ae._)`${a} && !${R}`}function M(){let H=p.$async?(0,Ae._)`(${S}.async ? await ${R}(${r}) : ${R}(${r}))`:(0,Ae._)`${R}(${r})`,G=(0,Ae._)`(typeof ${R} == "function" ? ${H} : ${R}.test(${r}))`;return(0,Ae._)`${R} && ${R} !== true && ${v} === ${t} && !${G}`}}function b(){let g=m.formats[i];if(!g){P();return}if(g===!0)return;let[S,v,R]=M(g);S===t&&e.pass(H());function P(){if(c.strictSchema===!1){m.logger.warn(G());return}throw new Error(G());function G(){return`unknown format "${i}" ignored in schema at path "${u}"`}}function M(G){let ge=G instanceof RegExp?(0,Ae.regexpCode)(G):c.code.formats?(0,Ae._)`${c.code.formats}${(0,Ae.getProperty)(i)}`:void 0,Oe=n.scopeValue("formats",{key:i,ref:G,code:ge});return typeof G=="object"&&!(G instanceof RegExp)?[G.type||"string",G.validate,(0,Ae._)`${Oe}.validate`]:["string",G,Oe]}function H(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!p.$async)throw new Error("async format in sync schema");return(0,Ae._)`await ${R}(${r})`}return typeof v=="function"?(0,Ae._)`${R}(${r})`:(0,Ae._)`${R}.test(${r})`}}}};Vc.default=yw});var Eg=C(Hc=>{"use strict";f();Object.defineProperty(Hc,"__esModule",{value:!0});var _w=_g(),Ew=[_w.default];Hc.default=Ew});var Sg=C(pr=>{"use strict";f();Object.defineProperty(pr,"__esModule",{value:!0});pr.contentVocabulary=pr.metadataVocabulary=void 0;pr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];pr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Tg=C(qc=>{"use strict";f();Object.defineProperty(qc,"__esModule",{value:!0});var Sw=fh(),bw=wh(),Tw=Zh(),Rw=ag(),Aw=fg(),kw=yg(),ww=Eg(),bg=Sg(),vw=[Rw.default,Sw.default,bw.default,(0,Tw.default)(!0),ww.default,bg.metadataVocabulary,bg.contentVocabulary,Aw.default,kw.default];qc.default=vw});var Ag=C(Vi=>{"use strict";f();Object.defineProperty(Vi,"__esModule",{value:!0});Vi.DiscrError=void 0;var Rg;(function(e){e.Tag="tag",e.Mapping="mapping"})(Rg||(Vi.DiscrError=Rg={}))});var wg=C(Bc=>{"use strict";f();Object.defineProperty(Bc,"__esModule",{value:!0});var mr=X(),Kc=Ag(),kg=lo(),Iw=ao(),Nw=ie(),$w={message:({params:{discrError:e,tagName:t}})=>e===Kc.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:n}})=>(0,mr._)`{error: ${e}, tag: ${n}, tagValue: ${t}}`},Ow={keyword:"discriminator",type:"object",schemaType:"object",error:$w,code(e){let{gen:t,data:n,schema:r,parentSchema:o,it:i}=e,{oneOf:a}=o;if(!i.opts.discriminator)throw new Error("discriminator: requires discriminator option");let l=r.propertyName;if(typeof l!="string")throw new Error("discriminator: requires propertyName");if(r.mapping)throw new Error("discriminator: mapping is not supported");if(!a)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,mr._)`${n}${(0,mr.getProperty)(l)}`);t.if((0,mr._)`typeof ${u} == "string"`,()=>p(),()=>e.error(!1,{discrError:Kc.DiscrError.Tag,tag:u,tagName:l})),e.ok(c);function p(){let b=h();t.if(!1);for(let g in b)t.elseIf((0,mr._)`${u} === ${g}`),t.assign(c,m(b[g]));t.else(),e.error(!1,{discrError:Kc.DiscrError.Mapping,tag:u,tagName:l}),t.endIf()}function m(b){let g=t.name("valid"),S=e.subschema({keyword:"oneOf",schemaProp:b},g);return e.mergeEvaluated(S,mr.Name),g}function h(){var b;let g={},S=R(o),v=!0;for(let H=0;H<a.length;H++){let G=a[H];if(G?.$ref&&!(0,Nw.schemaHasRulesButRef)(G,i.self.RULES)){let Oe=G.$ref;if(G=kg.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,Oe),G instanceof kg.SchemaEnv&&(G=G.schema),G===void 0)throw new Iw.default(i.opts.uriResolver,i.baseId,Oe)}let ge=(b=G?.properties)===null||b===void 0?void 0:b[l];if(typeof ge!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${l}"`);v=v&&(S||R(G)),P(ge,H)}if(!v)throw new Error(`discriminator: "${l}" must be required`);return g;function R({required:H}){return Array.isArray(H)&&H.includes(l)}function P(H,G){if(H.const)M(H.const,G);else if(H.enum)for(let ge of H.enum)M(ge,G);else throw new Error(`discriminator: "properties/${l}" must have "const" or "enum"`)}function M(H,G){if(typeof H!="string"||H in g)throw new Error(`discriminator: "${l}" values must be unique strings`);g[H]=G}}}};Bc.default=Ow});var vg=C((PD,xw)=>{xw.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/schema",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0,"https://json-schema.org/draft/2020-12/vocab/applicator":!0,"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0,"https://json-schema.org/draft/2020-12/vocab/validation":!0,"https://json-schema.org/draft/2020-12/vocab/meta-data":!0,"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0,"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Core and Validation specifications meta-schema",allOf:[{$ref:"meta/core"},{$ref:"meta/applicator"},{$ref:"meta/unevaluated"},{$ref:"meta/validation"},{$ref:"meta/meta-data"},{$ref:"meta/format-annotation"},{$ref:"meta/content"}],type:["object","boolean"],$comment:"This meta-schema also defines keywords that have appeared in previous drafts in order to prevent incompatible extensions as they remain in common use.",properties:{definitions:{$comment:'"definitions" has been replaced by "$defs".',type:"object",additionalProperties:{$dynamicRef:"#meta"},deprecated:!0,default:{}},dependencies:{$comment:'"dependencies" has been split and replaced by "dependentSchemas" and "dependentRequired" in order to serve their differing semantics.',type:"object",additionalProperties:{anyOf:[{$dynamicRef:"#meta"},{$ref:"meta/validation#/$defs/stringArray"}]},deprecated:!0,default:{}},$recursiveAnchor:{$comment:'"$recursiveAnchor" has been replaced by "$dynamicAnchor".',$ref:"meta/core#/$defs/anchorString",deprecated:!0},$recursiveRef:{$comment:'"$recursiveRef" has been replaced by "$dynamicRef".',$ref:"meta/core#/$defs/uriReferenceString",deprecated:!0}}}});var Ig=C((CD,Pw)=>{Pw.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/applicator",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/applicator":!0},$dynamicAnchor:"meta",title:"Applicator vocabulary meta-schema",type:["object","boolean"],properties:{prefixItems:{$ref:"#/$defs/schemaArray"},items:{$dynamicRef:"#meta"},contains:{$dynamicRef:"#meta"},additionalProperties:{$dynamicRef:"#meta"},properties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},patternProperties:{type:"object",additionalProperties:{$dynamicRef:"#meta"},propertyNames:{format:"regex"},default:{}},dependentSchemas:{type:"object",additionalProperties:{$dynamicRef:"#meta"},default:{}},propertyNames:{$dynamicRef:"#meta"},if:{$dynamicRef:"#meta"},then:{$dynamicRef:"#meta"},else:{$dynamicRef:"#meta"},allOf:{$ref:"#/$defs/schemaArray"},anyOf:{$ref:"#/$defs/schemaArray"},oneOf:{$ref:"#/$defs/schemaArray"},not:{$dynamicRef:"#meta"}},$defs:{schemaArray:{type:"array",minItems:1,items:{$dynamicRef:"#meta"}}}}});var Ng=C((LD,Cw)=>{Cw.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/unevaluated",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/unevaluated":!0},$dynamicAnchor:"meta",title:"Unevaluated applicator vocabulary meta-schema",type:["object","boolean"],properties:{unevaluatedItems:{$dynamicRef:"#meta"},unevaluatedProperties:{$dynamicRef:"#meta"}}}});var $g=C((DD,Lw)=>{Lw.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/content",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/content":!0},$dynamicAnchor:"meta",title:"Content vocabulary meta-schema",type:["object","boolean"],properties:{contentEncoding:{type:"string"},contentMediaType:{type:"string"},contentSchema:{$dynamicRef:"#meta"}}}});var Og=C((MD,Dw)=>{Dw.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/core",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/core":!0},$dynamicAnchor:"meta",title:"Core vocabulary meta-schema",type:["object","boolean"],properties:{$id:{$ref:"#/$defs/uriReferenceString",$comment:"Non-empty fragments not allowed.",pattern:"^[^#]*#?$"},$schema:{$ref:"#/$defs/uriString"},$ref:{$ref:"#/$defs/uriReferenceString"},$anchor:{$ref:"#/$defs/anchorString"},$dynamicRef:{$ref:"#/$defs/uriReferenceString"},$dynamicAnchor:{$ref:"#/$defs/anchorString"},$vocabulary:{type:"object",propertyNames:{$ref:"#/$defs/uriString"},additionalProperties:{type:"boolean"}},$comment:{type:"string"},$defs:{type:"object",additionalProperties:{$dynamicRef:"#meta"}}},$defs:{anchorString:{type:"string",pattern:"^[A-Za-z_][-A-Za-z0-9._]*$"},uriString:{type:"string",format:"uri"},uriReferenceString:{type:"string",format:"uri-reference"}}}});var xg=C((UD,Mw)=>{Mw.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/format-annotation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/format-annotation":!0},$dynamicAnchor:"meta",title:"Format vocabulary meta-schema for annotation results",type:["object","boolean"],properties:{format:{type:"string"}}}});var Pg=C((FD,Uw)=>{Uw.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/meta-data",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/meta-data":!0},$dynamicAnchor:"meta",title:"Meta-data vocabulary meta-schema",type:["object","boolean"],properties:{title:{type:"string"},description:{type:"string"},default:!0,deprecated:{type:"boolean",default:!1},readOnly:{type:"boolean",default:!1},writeOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0}}}});var Cg=C((jD,Fw)=>{Fw.exports={$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://json-schema.org/draft/2020-12/meta/validation",$vocabulary:{"https://json-schema.org/draft/2020-12/vocab/validation":!0},$dynamicAnchor:"meta",title:"Validation vocabulary meta-schema",type:["object","boolean"],properties:{type:{anyOf:[{$ref:"#/$defs/simpleTypes"},{type:"array",items:{$ref:"#/$defs/simpleTypes"},minItems:1,uniqueItems:!0}]},const:!0,enum:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/$defs/nonNegativeInteger"},minLength:{$ref:"#/$defs/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},maxItems:{$ref:"#/$defs/nonNegativeInteger"},minItems:{$ref:"#/$defs/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},maxContains:{$ref:"#/$defs/nonNegativeInteger"},minContains:{$ref:"#/$defs/nonNegativeInteger",default:1},maxProperties:{$ref:"#/$defs/nonNegativeInteger"},minProperties:{$ref:"#/$defs/nonNegativeIntegerDefault0"},required:{$ref:"#/$defs/stringArray"},dependentRequired:{type:"object",additionalProperties:{$ref:"#/$defs/stringArray"}}},$defs:{nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{$ref:"#/$defs/nonNegativeInteger",default:0},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}}});var Lg=C(Yc=>{"use strict";f();Object.defineProperty(Yc,"__esModule",{value:!0});var jw=vg(),Gw=Ig(),Vw=Ng(),Hw=$g(),qw=Og(),Kw=xg(),Bw=Pg(),Yw=Cg(),Ww=["/properties"];function zw(e){return[jw,Gw,Vw,Hw,qw,t(this,Kw),Bw,t(this,Yw)].forEach(n=>this.addMetaSchema(n,void 0,!1)),this;function t(n,r){return e?n.$dataMetaSchema(r,Ww):r}}Yc.default=zw});var Dg=C((Se,zc)=>{"use strict";f();Object.defineProperty(Se,"__esModule",{value:!0});Se.MissingRefError=Se.ValidationError=Se.CodeGen=Se.Name=Se.nil=Se.stringify=Se.str=Se._=Se.KeywordCxt=Se.Ajv2020=void 0;var Xw=ah(),Jw=Tg(),Qw=wg(),Zw=Lg(),Wc="https://json-schema.org/draft/2020-12/schema",hr=class extends Xw.default{constructor(t={}){super({...t,dynamicRef:!0,next:!0,unevaluated:!0})}_addVocabularies(){super._addVocabularies(),Jw.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(Qw.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();let{$data:t,meta:n}=this.opts;n&&(Zw.default.call(this,t),this.refs["http://json-schema.org/schema"]=Wc)}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Wc)?Wc:void 0)}};Se.Ajv2020=hr;zc.exports=Se=hr;zc.exports.Ajv2020=hr;Object.defineProperty(Se,"__esModule",{value:!0});Se.default=hr;var e0=so();Object.defineProperty(Se,"KeywordCxt",{enumerable:!0,get:function(){return e0.KeywordCxt}});var gr=X();Object.defineProperty(Se,"_",{enumerable:!0,get:function(){return gr._}});Object.defineProperty(Se,"str",{enumerable:!0,get:function(){return gr.str}});Object.defineProperty(Se,"stringify",{enumerable:!0,get:function(){return gr.stringify}});Object.defineProperty(Se,"nil",{enumerable:!0,get:function(){return gr.nil}});Object.defineProperty(Se,"Name",{enumerable:!0,get:function(){return gr.Name}});Object.defineProperty(Se,"CodeGen",{enumerable:!0,get:function(){return gr.CodeGen}});var t0=Si();Object.defineProperty(Se,"ValidationError",{enumerable:!0,get:function(){return t0.default}});var n0=ao();Object.defineProperty(Se,"MissingRefError",{enumerable:!0,get:function(){return n0.default}})});f();f();f();f();f();f();f();f();f();var ju=["getPayload","postResult","postError","heartbeat","postChunk","ready","hello"];f();var Gu=["spawn","relay-payload","relay-settle","relay-hello","policy-apply","teardown","identify","metrics"];f();f();var Gy=16*1024;var Vy=8*1024*1024,Hy=2*1024*1024;f();var Vu={"relay-payload":"/host/claim","relay-hello":"/host/claim","relay-settle":"/host/settle","relay-ready":"/host/ready","relay-progress":"/host/settle"},qy=e=>Object.prototype.hasOwnProperty.call(Vu,e),Ky=Gu.filter(qy);f();var By=new Set([".",".."]);function ee(e,...t){let n=0,r=e.replace(/:[A-Za-z_][A-Za-z0-9_]*/g,()=>{let o=t[n++];if(o===void 0)throw new Error(`route ${e}: parameter ${n} is missing`);if(By.has(String(o)))throw new Error(`route ${e}: parameter ${n} is a dot segment (${String(o)})`);return encodeURIComponent(String(o))});if(n!==t.length)throw new Error(`route ${e}: takes ${n} parameter(s), given ${t.length}`);return r}var B={METRICS:"/metrics",INGRESS_DEAD_LETTER:"/internal/ingress-dead-letter",INGRESS_DEAD_LETTERS:"/admin/ingress-dead-letters",OUTBOX_REDRIVE:"/admin/outbox/:id/redrive",TENANTS:"/admin/tenants",TIERS:"/admin/tiers",TIER_MIGRATE:"/admin/tiers/migrate-cohort",TIER_VERIFY:"/admin/tiers/verify",TIER_BY_NAME:"/admin/tiers/:name",TIER_DEPRECATE:"/admin/tiers/:name/:version/deprecate",TENANT_GRANTS:"/admin/tenants/:id/grants",TENANT_POLICY_EXPLAIN:"/admin/tenants/:id/policy/explain",TENANT_BY_ID:"/admin/tenants/:id",TENANT_ENABLE:"/admin/tenants/:id/enable",TENANT_DISABLE:"/admin/tenants/:id/disable",TENANT_TASKS:"/admin/tenants/:id/tasks",TENANT_DEPLOYMENTS:"/admin/tenants/:id/deployments",TENANT_RUNS:"/admin/tenants/:id/runs",TENANT_KEYS:"/admin/tenants/:id/keys",TENANT_USAGE:"/admin/tenants/:id/usage",USAGE_RECONCILE:"/admin/usage/reconcile",PLAN_PRICES:"/admin/plan-prices",INVOICES:"/admin/invoices",INVOICE_RUN:"/admin/invoices/run",KEY_REVOKE:"/admin/tenants/:id/keys/:kid/revoke",DEVICE_APPROVE:"/admin/device/approve",ACCOUNTS:"/admin/accounts",ACCOUNT_BY_ID:"/admin/accounts/:id",ACCOUNT_DISABLE:"/admin/accounts/:id/disable",ACCOUNT_ENABLE:"/admin/accounts/:id/enable",ACCOUNT_LINK:"/admin/accounts/:id/link",GC_DEPLOYMENTS:"/admin/gc/deployments",GC_ARTIFACT_STORE:"/admin/gc/artifact-store",INTEGRITY_LIST:"/admin/integrity/deployments",VMS:"/admin/vms",VM_BY_ID:"/admin/vms/:id",CAPACITY:"/admin/capacity",HOSTS:"/admin/hosts",HOST_APPROVE:"/admin/hosts/:id/approve",HOST_ACTIVATE:"/admin/hosts/:id/activate",HOST_RETIRE:"/admin/hosts/:id/retire",HOST_QUARANTINE:"/admin/hosts/:id/quarantine",HOST_DRAIN:"/admin/hosts/:id/drain",HOST_REKEY:"/admin/hosts/:id/rekey",HOST_BY_ID:"/admin/hosts/:id",FLEET_CONFIG_TARGET:"/admin/fleet/config-target",FLEET_POLICY_KEY:"/admin/fleet/policy-key",FLEET_HOST_CONFIG:"/admin/fleet/host-config"},de={TASKS:"/tasks",TASK_BY_ID:"/tasks/:id",TASK_DELETION_PREVIEW:"/tasks/:id/deletion-preview",DEPLOYMENTS:"/deployments",DEPLOYMENT_BY_ID:"/deployments/:id",RUNS:"/runs",RUN_BY_ID:"/runs/:id",RUN_CANCEL:"/runs/:id/cancel",WHOAMI:"/whoami",PACKAGE_ADVICE:"/packages/advice",VMS:"/vms",VM_BY_ID:"/vms/:id",HOOKS:"/hooks",TRIGGER:"/hooks/trigger",TRIGGER_HOOK:"/hooks/trigger/:hookId",SECRETS:"/secrets",SECRET_BY_NAME:"/secrets/:name",SCHEDULES:"/schedules",SCHEDULE_BY_ID:"/schedules/:id",USAGE:"/usage",RUN_LOGS:"/runs/:id/logs",DEPLOYMENT_HOOKS:"/deployments/:id/hooks",DEPLOYMENT_NOTIFY:"/deployments/:id/notify",HOOK_BY_ID:"/hooks/:id",READYZ:"/readyz",LIVEZ:"/livez",AUTH_DEVICE:"/auth/device",AUTH_DEVICE_TOKEN:"/auth/device/token",AUTH_KEY:"/auth/key"};var ls="API key has expired",Yy={METRICS:B.METRICS,INGRESS_DEAD_LETTER:B.INGRESS_DEAD_LETTER,INGRESS_DEAD_LETTERS:B.INGRESS_DEAD_LETTERS,TENANTS:B.TENANTS,TIERS:B.TIERS,TIER_MIGRATE:B.TIER_MIGRATE,TIER_VERIFY:B.TIER_VERIFY,PLAN_PRICES:B.PLAN_PRICES,INVOICES:B.INVOICES,INVOICE_RUN:B.INVOICE_RUN,TIER_BY_NAME:e=>ee(B.TIER_BY_NAME,e),TIER_DEPRECATE:(e,t)=>ee(B.TIER_DEPRECATE,e,t),TENANT_GRANTS:e=>ee(B.TENANT_GRANTS,e),TENANT_POLICY_EXPLAIN:e=>ee(B.TENANT_POLICY_EXPLAIN,e),OUTBOX_REDRIVE:e=>ee(B.OUTBOX_REDRIVE,e),TENANT_BY_ID:e=>ee(B.TENANT_BY_ID,e),TENANT_ENABLE:e=>ee(B.TENANT_ENABLE,e),TENANT_DISABLE:e=>ee(B.TENANT_DISABLE,e),TENANT_TASKS:e=>ee(B.TENANT_TASKS,e),TENANT_DEPLOYMENTS:e=>ee(B.TENANT_DEPLOYMENTS,e),TENANT_RUNS:e=>ee(B.TENANT_RUNS,e),TENANT_KEYS:e=>ee(B.TENANT_KEYS,e),TENANT_USAGE:e=>ee(B.TENANT_USAGE,e),USAGE_RECONCILE:B.USAGE_RECONCILE,KEY_REVOKE:(e,t)=>ee(B.KEY_REVOKE,e,t),DEVICE_APPROVE:B.DEVICE_APPROVE,ACCOUNTS:B.ACCOUNTS,ACCOUNT_BY_ID:e=>ee(B.ACCOUNT_BY_ID,e),ACCOUNT_DISABLE:e=>ee(B.ACCOUNT_DISABLE,e),ACCOUNT_ENABLE:e=>ee(B.ACCOUNT_ENABLE,e),ACCOUNT_LINK:e=>ee(B.ACCOUNT_LINK,e),GC_DEPLOYMENTS:B.GC_DEPLOYMENTS,GC_ARTIFACT_STORE:B.GC_ARTIFACT_STORE,INTEGRITY_LIST:B.INTEGRITY_LIST,VMS:B.VMS,VM_BY_ID:e=>ee(B.VM_BY_ID,e),CAPACITY:B.CAPACITY,HOSTS:B.HOSTS,HOST_APPROVE:e=>ee(B.HOST_APPROVE,e),HOST_ACTIVATE:e=>ee(B.HOST_ACTIVATE,e),HOST_RETIRE:e=>ee(B.HOST_RETIRE,e),HOST_QUARANTINE:e=>ee(B.HOST_QUARANTINE,e),HOST_DRAIN:e=>ee(B.HOST_DRAIN,e),HOST_REKEY:e=>ee(B.HOST_REKEY,e),HOST_BY_ID:e=>ee(B.HOST_BY_ID,e),FLEET_CONFIG_TARGET:B.FLEET_CONFIG_TARGET,FLEET_POLICY_KEY:B.FLEET_POLICY_KEY,FLEET_HOST_CONFIG:B.FLEET_HOST_CONFIG},ne={TASKS:de.TASKS,TASK_BY_ID:e=>ee(de.TASK_BY_ID,e),TASK_DELETION_PREVIEW:e=>ee(de.TASK_DELETION_PREVIEW,e),DEPLOYMENTS:de.DEPLOYMENTS,DEPLOYMENT_BY_ID:e=>ee(de.DEPLOYMENT_BY_ID,e),RUNS:de.RUNS,RUN_BY_ID:e=>ee(de.RUN_BY_ID,e),RUN_CANCEL:e=>ee(de.RUN_CANCEL,e),RUN_LOGS:e=>ee(de.RUN_LOGS,e),WHOAMI:de.WHOAMI,PACKAGE_ADVICE:de.PACKAGE_ADVICE,VMS:de.VMS,VM_BY_ID:e=>ee(de.VM_BY_ID,e),HOOKS:de.HOOKS,TRIGGER:de.TRIGGER,TRIGGER_HOOK:e=>ee(de.TRIGGER_HOOK,e),SECRETS:de.SECRETS,SECRET_BY_NAME:e=>ee(de.SECRET_BY_NAME,e),SCHEDULES:de.SCHEDULES,SCHEDULE_BY_ID:e=>ee(de.SCHEDULE_BY_ID,e),USAGE:de.USAGE,DEPLOYMENT_HOOKS:e=>ee(de.DEPLOYMENT_HOOKS,e),DEPLOYMENT_NOTIFY:e=>ee(de.DEPLOYMENT_NOTIFY,e),HOOK_BY_ID:e=>ee(de.HOOK_BY_ID,e),READYZ:de.READYZ,LIVEZ:de.LIVEZ,AUTH_DEVICE:de.AUTH_DEVICE,AUTH_DEVICE_TOKEN:de.AUTH_DEVICE_TOKEN,AUTH_KEY:de.AUTH_KEY},cs="1",us="X-Api-Version",Ho="X-Client-Floor",ds="X-Ignitify-Cli";f();var fs=["compute","network","network_in","disk","scratch","runs","pin","build"];f();f();var Hu=e=>{if(!ju.includes(e))throw new Error(`hop-10 has no op named ${e}`);return e},kv=Hu("postResult"),wv=Hu("postError");f();f();f();f();var Vt=["task.yaml","task.yml","task.json"],at=Object.freeze({node:Object.freeze({entryFile:"index.ts",depManifest:"package.json",lockfile:"package-lock.json",wireRuntime:"node22",status:"live"}),python:Object.freeze({entryFile:"main.py",depManifest:"requirements.txt",lockfile:"requirements.txt",wireRuntime:"python3.11",status:"live"}),go:Object.freeze({entryFile:"main.go",depManifest:"go.mod",lockfile:"go.sum",wireRuntime:"go",status:"live"}),rust:Object.freeze({entryFile:"src/main.rs",depManifest:"Cargo.toml",lockfile:"Cargo.lock",wireRuntime:"rust",status:"live"})}),qo=Object.keys(at),ps=qo.filter(e=>at[e].status==="live"),qu=e=>typeof e=="string"&&Object.prototype.hasOwnProperty.call(at,e),Ku=Object.freeze({allErrors:!0,strict:!0,useDefaults:!1}),ms=Object.freeze({$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://ignitify.dev/schemas/task-config/v1.json",title:"Ignitify task configuration",type:"object",required:["schema_version","slug","runtime"],additionalProperties:!1,properties:{schema_version:{const:1},slug:{type:"string",minLength:1},runtime:{enum:[...qo]},entry:{type:"string",minLength:1},execution:{type:"object"},secrets:{type:"array",items:{type:"string",minLength:1},uniqueItems:!0},run:{type:"object",additionalProperties:!1,properties:{payload:{type:"object"},preset:{type:"string",minLength:1},timeout_sec:{type:"integer",exclusiveMinimum:0}}},build:{type:"object",additionalProperties:!1,properties:{allowed_hosts:{type:"array",items:{type:"string",minLength:1},uniqueItems:!0},ship:{type:"array",items:{type:"string",minLength:1},uniqueItems:!0},system_packages:{type:"array",items:{type:"string",minLength:1}}}}}}),Wy=["read","fetch","build","smoke"],Vv=["done",...Wy,"builder","image","cap"];f();var zy="v2",Xy=Object.freeze(["execution","secrets","run"]),hs=64*1024,Yu=64*1024*1024,Bu=64;function gs(e){return Vt.find(t=>e.includes(t))??null}function Jy(e){let t=e!==null&&typeof e=="object"&&!Array.isArray(e)?Object.fromEntries(Object.entries(e).filter(([l])=>!Xy.includes(l))):e,n=[],r=0,o=()=>{throw new Error(`its build settings are over ${hs/1024} KiB as canonical JSON (a YAML alias is expanded each time it is used)`)},i=l=>{r+=Qy(l),r>hs&&o(),n.push(l)},a=(l,c)=>{if(c>Bu)throw new Error(`it is nested deeper than ${Bu} levels`);if(l===null||typeof l=="boolean")return i(String(l));if(typeof l=="number"){if(!Number.isFinite(l))throw new Error(`it holds ${String(l)}, which JSON cannot state`);return i(JSON.stringify(l))}if(typeof l=="string")return l.length>hs&&o(),i(JSON.stringify(l));if(Array.isArray(l))return i("["),l.forEach((u,p)=>{p>0&&i(","),a(u,c+1)}),i("]");if(typeof l=="object")return i("{"),Object.keys(l).sort((u,p)=>u<p?-1:u>p?1:0).forEach((u,p)=>{p>0&&i(","),i(`${JSON.stringify(u)}:`),a(l[u],c+1)}),i("}");throw new Error(`it holds a ${typeof l}, which is not a YAML 1.2 core value`)};return a(t,0),n.join("")}function Qy(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t+=r<128?1:r<2048||r>=55296&&r<57344?2:3}return t}var Zy=Object.freeze([".git",".ignitify","node_modules","__pycache__",".venv","venv",".mypy_cache",".pytest_cache"]),e_=Object.freeze(["target","dist"]),t_=Object.freeze([".env"]),Wu=Object.freeze({".npmrc":/^[ \t]*(?![#;])[^=\n]*_(?:authToken|auth|password)[ \t]*=[ \t]*(?!\$\{\w+\}[ \t]*$)\S/m,".yarnrc.yml":/^[ \t]*npmAuth(?:Token|Ident)[ \t]*:[ \t]*(?!["']?\$\{\w+\}["']?[ \t]*$)\S/m}),zu=Object.freeze(Object.keys(Wu));function Xu(e,t){let n=e.slice(e.lastIndexOf("/")+1),r=Wu[n];return r===void 0||!r.test(t)?null:`${e} holds a registry credential \u2014 it would be stored with the source and the image. Remove it; a build reaches public registries without one`}function Ju(e){let t=e.split("/"),n=t.length-1;for(let[o,i]of t.entries()){let a=o===n?"excluded directory":"inside excluded directory";if(Zy.includes(i))return`${a} "${i}"`;if(o===0&&e_.includes(i))return`${a} "${i}" (build output at the task root)`}let r=t[n]??"";for(let o of t_)if(r===o||r.startsWith(o+"."))return`"${r}" may hold secrets \u2014 use \`secret:set\` instead`;return null}function Qu(e){let t=e.slice(e.lastIndexOf("/")+1).toLowerCase();return t.endsWith(".pem")||t.endsWith(".key")||t.startsWith("id_rsa")&&!t.endsWith(".pub")?`${e} looks like a private key and is uploaded with the task, then stored in the image. If it is a secret, remove it (secrets go through \`secret:set\`); to keep a harmless file out, list it in \`.ignitifyignore\``:null}var n_=/^[0-9a-f]{64}$/,r_=e=>!e.startsWith("/")&&!e.includes("\\")&&e.split("/").every(t=>t!==""&&t!=="."&&t!=="..");function Zu(e,t){let n=gs(e.map(a=>a.path));if((t?.name??null)!==n)throw new Error(`source manifest: the task config in the key must be ${n??"none"}, not ${t?.name??"none"}`);let r=[];if(t!==null)try{r=[`config ${t.name} ${Jy(t.value)}`]}catch(a){throw new Error(`source manifest: ${t.name}: ${a.message}`,{cause:a})}let o=new Set;for(let a of e){if(typeof a.path!="string"||a.path==="")throw new Error("source manifest: empty path");if(a.path.includes("\\"))throw new Error(`source manifest: path contains a backslash: ${JSON.stringify(a.path)}. Separators must be normalised to "/" before hashing, or the same tree hashes differently per platform.`);if(a.path.startsWith("/"))throw new Error(`source manifest: absolute path: ${a.path}`);if(!r_(a.path))throw new Error(`source manifest: non-canonical path: ${a.path}`);if(a.path.includes(`
888
+ `)||a.path.includes(" "))throw new Error(`source manifest: path contains a tab or newline: ${JSON.stringify(a.path)}`);if(!Number.isSafeInteger(a.size)||a.size<0)throw new Error(`source manifest: bad size for ${a.path}: ${String(a.size)}`);if(!n_.test(a.sha256))throw new Error(`source manifest: sha256 for ${a.path} must be 64 lowercase hex chars`);if(o.has(a.path))throw new Error(`source manifest: duplicate path: ${a.path}`);o.add(a.path)}let i=e.filter(a=>a.path!==t?.name).sort((a,l)=>a.path<l.path?-1:a.path>l.path?1:0).map(a=>`${a.exec?"755":"644"} ${a.size} ${a.sha256} ${a.path}`);return[`ignitify-source/${zy}`,...r,...i,""].join(`
889
+ `)}f();f();f();f();var i_=/^[a-z0-9][a-z0-9+.-]+$/;function s_(e){return[...new Set(e)].sort()}function ed(e){let t=s_(e),n=t.filter(r=>r.length>64||!i_.test(r));return n.length>0?{ok:!1,reason:"bad-names",bad:n}:t.length>64?{ok:!1,reason:"too-many",count:t.length}:{ok:!0,names:t}}f();f();var td="[a-z0-9]([a-z0-9-]*[a-z0-9])?",iI=new RegExp(`^${td}(\\.${td})*$`);f();f();var nd="/artifact/sha256",a_=`^${nd}/(?<aa>[0-9a-f]{2})(?<rest>[0-9a-f]{62})$`,rd="/publish/sha256",l_=256*1024*1024;var c_=`^${rd}/(?<aa>[0-9a-f]{2})(?<rest>[0-9a-f]{62})$`;var od="/retire/sha256",u_=`^${od}/(?<aa>[0-9a-f]{2})(?<rest>[0-9a-f]{62})$`,id="/list/sha256",d_=`^${id}/((?<aa>[0-9a-f]{2})/)?$`;f();var kr="/etc/ignitify/ingress-hop",f_=`${kr}/root.crt`,p_=`${kr}/hop.crt`,m_=`${kr}/hop.key`;var h_=`${kr}/sds-hop.json`;f();f();var Ko={console:"console",prom:"prom",timeline:"timeline",pg:"pg"};var Fn="/__callback/",fN={metric:[Ko.prom],log:[Ko.timeline,Ko.console],event:[Ko.timeline]};var D={HELP:"help",LOGIN:"login",LOGOUT:"logout",WHOAMI:"whoami",QUOTA:"quota",TASK_CREATE:"task:create",TASK_LIST:"task:list",TASK_GET:"task:get",TASK_DELETE:"task:delete",TASK_VALIDATE:"task:validate",TASK_PACK:"task:pack",TASK_DEPLOY:"task:deploy",TASK_RUN:"task:run",DEPLOYMENT_LIST:"deployment:list",DEPLOYMENT_GET:"deployment:get",DEPLOYMENT_DELETE:"deployment:delete",RUN_LIST:"run:list",RUN_GET:"run:get",RUN_LOGS:"run:logs",RUN_DELETE:"run:delete",RUN_CANCEL:"run:cancel",VM_LIST:"vm:list",VM_GET:"vm:get",VM_DELETE:"vm:delete",SECRET_SET:"secret:set",SECRET_LIST:"secret:list",SECRET_DELETE:"secret:delete",SCHEDULE_LIST:"schedule:list",SCHEDULE_CANCEL:"schedule:cancel",HOOK_CREATE:"hook:create",HOOK_LIST:"hook:list",HOOK_DELETE:"hook:delete",NOTIFY_SET:"notify:set",USAGE:"usage",USAGE_EXPORT:"usage:export"},mn=".ignitifyignore",It={DIR:".ignitify",FILE:"state.json",GITIGNORE_FILE:".gitignore",GITIGNORE_TEXT:`# written by ignitify: local state, never commit
890
+ *
891
+ `},sd=fs.join("|"),wr={DIR_NAME:"ignitify",FILE_NAME:"credentials.json",DIR_MODE:448,FILE_MODE:384},jn={MAX_RETRIES:3,KEY_TTL_DAYS:90,MIN_POLL_INTERVAL_SEC:5,BROWSER_SCHEMES:["https:","http:"]},qt={REASONS:{ECONNREFUSED:"nothing accepts connections there",ENOTFOUND:"the host name is unknown",EAI_AGAIN:"the host name lookup failed",ETIMEDOUT:"the connection timed out",UND_ERR_CONNECT_TIMEOUT:"the connection timed out",ECONNRESET:"the connection was reset"},TLS_WORDS:"the TLS certificate was not accepted",TLS_CODES:["CERT_HAS_EXPIRED","CERT_NOT_YET_VALID","DEPTH_ZERO_SELF_SIGNED_CERT","SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_VERIFY_LEAF_SIGNATURE","UNABLE_TO_GET_ISSUER_CERT_LOCALLY"],TLS_CODE_PREFIXES:["ERR_TLS_","ERR_SSL_"],CODE_PATTERN:/^[A-Z][A-Z0-9_]*$/,DETAIL_MAX_CHARS:80},Gn={TASKS_DIR:"IGNITIFY_TASKS_DIR",KEY:"IGNITIFY_API_KEY"},cd="tasks",Vn={API_URL:"https://api.ignitify.dev"},Kt=10240,ud=10240,Bt={limit:"limit",after:"after","after-id":"after_id"},Ss={status:"status","deployment-id":"deployment_id","task-name":"task_name",preset:"preset","correlation-id":"correlation_id","vm-id":"vm_id",...Bt},bs={"deployment-id":"deployment_id","task-name":"task_name",preset:"preset","older-than":"older_than",limit:"limit",after:"after","after-vm-id":"after_vm_id"},Bo={json:"bool",help:"bool","show-log":"bool"},le={api:"value"},dd=["api","show-log"],fd={h:"help",y:"yes"},Ts=["--version","-v"];function Es(e){return Object.fromEntries(Object.keys(e).map(t=>[t,"value"]))}var Ve={VALID:"\u2713 task config valid",OK:"\u2713",ERR:"\u2717",WARN:"\u26A0"},fe={FLAG:"review-packages",TIMEOUT_MS:6e4,FAULT_STATUSES:[400,401,403],SECONDS_ONLY_BELOW:60,SECONDS_PER_MINUTE:60,NO_PACKAGES:"this task lists no build.system_packages",NO_CONCERNS:"AI check: no concerns found",SUGGEST_LABEL:"AI suggestion, not checked against Debian",SKIPPED:e=>`AI check skipped: ${e}`,RATE_LIMITED:e=>`rate limited, try again in ${e} s`,UNAVAILABLE:e=>`the review is unavailable (${e})`,NO_ANSWER:(e,t)=>e===null?t:`server answered ${e}`,FAULT:(e,t)=>`AI check failed (HTTP ${e}): ${t}`,BAD_NAMES:e=>`not valid package names: ${e.join(", ")}`,TOO_MANY:(e,t)=>`${e} packages listed, the most is ${t}`,ITEM:(e,t,n)=>`${e}: ${t} \u2014 ${n}`,SUGGEST:e=>`suggest: ${e.join(", ")} (AI suggestion, not checked against Debian)`,ESTIMATE_REUSED:"adds no build time: your tenant already holds the drive for this list",ESTIMATE:(e,t)=>`adds about ${e} to the first build of this list (${t}; a later code-only redeploy reuses the drive)`,BASIS:{measured:"measured",model:"model estimate"},EXCLUDED:e=>`left out of the estimate: ${e.join(", ")}`,NO_FIT:(e,t)=>`does not fit: ${e} MiB of packages against the ${t} MiB image store of your tier`,NOT_ANSWERED:e=>`no AI answer for: ${e.join(", ")}`,NOT_REVIEWED:e=>`not double-checked: ${e.join(", ")}`},ad={},pn={dir:"value"},_s=Es(Bt),Ht={yes:"bool"},ld={period:"value",axis:"value",vm:"value",run:"value"},Hn={[D.HELP]:{flags:ad,positionals:1,confirms:!1},[D.LOGIN]:{flags:{...le,"no-browser":"bool",name:"value"},positionals:0,confirms:!1},[D.LOGOUT]:{flags:ad,positionals:0,confirms:!1},[D.WHOAMI]:{flags:le,positionals:0,confirms:!1},[D.QUOTA]:{flags:le,positionals:0,confirms:!1},[D.TASK_CREATE]:{flags:{...le,...pn,lang:"value",local:"bool","no-init":"bool","no-scaffold":"bool"},positionals:1,confirms:!1},[D.TASK_LIST]:{flags:{...le,..._s},positionals:0,confirms:!1},[D.TASK_GET]:{flags:{...le,...pn},positionals:1,confirms:!1},[D.TASK_DELETE]:{flags:{...le,...pn,...Ht},positionals:1,confirms:!0},[D.TASK_VALIDATE]:{flags:{...le,...pn,[fe.FLAG]:"bool"},positionals:1,confirms:!1},[D.TASK_PACK]:{flags:pn,positionals:1,confirms:!1},[D.TASK_DEPLOY]:{flags:{...le,...pn,check:"bool"},positionals:1,confirms:!1},[D.TASK_RUN]:{flags:{deployment:"value",payload:"value","timeout-sec":"value","on-busy":"value",at:"value",wait:"bool",...pn,...le},positionals:1,confirms:!1},[D.DEPLOYMENT_LIST]:{flags:{...le,..._s},positionals:0,confirms:!1},[D.DEPLOYMENT_GET]:{flags:le,positionals:1,confirms:!1},[D.DEPLOYMENT_DELETE]:{flags:{...le,...Ht},positionals:1,confirms:!0},[D.RUN_LIST]:{flags:{...le,...Es(Ss)},positionals:0,confirms:!1},[D.RUN_GET]:{flags:{...le,full:"bool"},positionals:1,confirms:!1},[D.RUN_LOGS]:{flags:le,positionals:1,confirms:!1},[D.RUN_DELETE]:{flags:{...le,...Ht},positionals:1,confirms:!0},[D.RUN_CANCEL]:{flags:{...le,...Ht,force:"bool",grace:"value"},positionals:1,confirms:!0},[D.VM_LIST]:{flags:{...le,...Es(bs),pinned:"bool"},positionals:0,confirms:!1},[D.VM_GET]:{flags:le,positionals:1,confirms:!1},[D.VM_DELETE]:{flags:{...le,...Ht,force:"bool"},positionals:1,confirms:!0},[D.SECRET_SET]:{flags:{...le,stdin:"bool",value:"value"},positionals:1,confirms:!1,secretArgv:!0},[D.SECRET_LIST]:{flags:le,positionals:0,confirms:!1},[D.SECRET_DELETE]:{flags:{...le,...Ht},positionals:1,confirms:!0},[D.SCHEDULE_LIST]:{flags:le,positionals:0,confirms:!1},[D.SCHEDULE_CANCEL]:{flags:{...le,...Ht},positionals:1,confirms:!0},[D.HOOK_CREATE]:{flags:{...le,"task-name":"value"},positionals:1,confirms:!1},[D.HOOK_LIST]:{flags:{...le,..._s},positionals:1,confirms:!1},[D.HOOK_DELETE]:{flags:{...le,...Ht},positionals:1,confirms:!0},[D.NOTIFY_SET]:{flags:{...le,url:"value",clear:"bool","secret-stdin":"bool",secret:"value"},positionals:1,confirms:!1,secretArgv:!0},[D.USAGE]:{flags:{...le,...ld,runs:"bool",vms:"bool"},positionals:0,confirms:!1},[D.USAGE_EXPORT]:{flags:{...le,...ld,csv:"bool"},positionals:0,confirms:!1}},Rs={flags:le,positionals:0,confirms:!1},k={USAGE:`ignitify \u2014 create, deploy, and run tasks
892
+
893
+ Every command is <resource>:<verb>.
894
+
895
+ Tasks:
896
+ ignitify task:create <task-id> [--lang node|python|go|rust] [--local] [--no-init] [--no-scaffold]
897
+ [--dir <base-dir>] # --lang defaults to node; --local = scaffold only, no server
898
+ ignitify task:list [--limit N] [--after-id <id>] [--after <iso>]
899
+ ignitify task:get <task-id> [--dir <base-dir>] # status report: deployed? usage, deployments+runs,
900
+ # new-deployment / new-VM verdicts with reasons
901
+ ignitify task:validate <task-id> [--dir <base-dir>] [--review-packages]
902
+ # check task.yaml offline; --review-packages then asks the
903
+ # server for an AI review of build.system_packages
904
+ # (advice only: the exit code never changes). Only
905
+ # package names and the runtime id leave this machine;
906
+ # never code, slug or secrets.
907
+ ignitify task:pack <task-id> [--dir <base-dir>] # what task:deploy would upload: files, size, hash;
908
+ # builds nothing
909
+ ignitify task:deploy <task-id> [--dir <base-dir>] [--check] # --check = validate only, no upload
910
+ ignitify task:run <task-id> [--dir <base-dir>] [--deployment <id>]
911
+ [--payload <json>] [--timeout-sec <n>]
912
+ [--on-busy queue|reject] [--at <iso>] [--wait]
913
+ # --wait follows the run to its end with a progress
914
+ # line, then shows run:get (result included); exit 0
915
+ # only if COMPLETED. Ctrl+C stops waiting, not the run.
916
+ # --at schedules the run for a future instant:
917
+ # answers a schedule_id, and NO run exists until it
918
+ # fires. Needs a server with scheduling; the CLI fails
919
+ # loudly if the response has no schedule_id.
920
+ # overrides task.yaml's run.payload/timeout_sec for
921
+ # this invocation only \u2014 task.yaml is never written
922
+ # --on-busy: what a run does when it cannot start at once.
923
+ # queue (default) waits for room, for a limited time;
924
+ # reject fails the run at once. It covers a fleet with
925
+ # no room and a BIDIRECTIONAL task, which runs ONE VM at
926
+ # a time (concurrent VMs for bidirectional-network
927
+ # tasks are not supported).
928
+ ignitify task:delete <task-id> [--dir <base-dir>] [--yes] [--json]
929
+ # also removes the .ignitify/ link of every
930
+ # local folder linked to it; files are kept
931
+
932
+ Deployments:
933
+ ignitify deployment:list [--limit N] [--after-id <id>] [--after <iso>]
934
+ # deployments with image SIZE + tenant total
935
+ ignitify deployment:get <deployment-id> # detail: size, integrity (ok/missing/quarantined)
936
+ ignitify deployment:delete <deployment-id> [--yes]
937
+
938
+ Runs:
939
+ ignitify run:list [--status S] [--deployment-id D] [--task-name N] [--preset P]
940
+ [--correlation-id C] [--vm-id V] [--limit N] [--after-id <id>] [--after <iso>]
941
+ # --after-id = the id of the last row printed: the next page
942
+ ignitify run:get <run-id> [--full] # --full = the whole API response for the run (JSON)
943
+ ignitify run:logs <run-id> # this run's guest output, straight to stdout
944
+ # (a truncated answer says so on stderr)
945
+ ignitify run:delete <run-id> [--yes] # soft-delete the record (does NOT stop a live run)
946
+ ignitify run:cancel <run-id> [--yes] [--force] [--grace <ms>] # stop a live run (graceful by default)
947
+ # --force: kill now; also required if it is on a pinned VM
948
+ # --grace: ask for a longer wind-down; the server clamps it
949
+
950
+ VMs:
951
+ ignitify vm:list [--pinned] [--deployment-id D] [--task-name N] [--preset P]
952
+ [--older-than 24h] [--limit N] [--after <booted_at> --after-vm-id <vm-id>]
953
+ # next page: both values from the last row of --json
954
+ ignitify vm:get <vm-id> # residency, state, age, nature axes
955
+ ignitify vm:delete <vm-id> [--yes] [--force] # pinned VMs REQUIRE --force
956
+
957
+ Webhooks:
958
+ ignitify hook:create <deployment-id> --task-name <name>
959
+ # --task-name is REQUIRED: the task each run starts
960
+ # \u26A0\uFE0F the reply carries a \`secret\` shown ONCE \u2014
961
+ # hook:list never returns it
962
+ ignitify hook:list <deployment-id> [--limit N] [--after-id <id>] [--after <iso>]
963
+ ignitify hook:delete <hook-resource-id> [--yes] # the HOOK's id, not the deployment's
964
+ ignitify notify:set <deployment-id> --url <https://\u2026> --secret-stdin
965
+ ignitify notify:set <deployment-id> --clear # clears the outbound-notify target
966
+ # \u26D4 no --secret flag: a value on argv is in
967
+ # \`ps\` and in your shell history
968
+
969
+ Secrets:
970
+ ignitify secret:set <NAME> --stdin # the value is read from stdin, never argv
971
+ ignitify secret:list
972
+ ignitify secret:delete <NAME> [--yes]
973
+
974
+ Schedules:
975
+ ignitify schedule:list # pending scheduled runs, soonest fire first
976
+ ignitify schedule:cancel <sch-id> [--yes] # cancel one; "0 rows" = already firing or fired
977
+
978
+ Usage (metered):
979
+ ignitify usage [--period YYYY-MM] [--axis ${sd}]
980
+ [--vm <vm-id>] [--run <run-id>] [--runs|--vms] [--json]
981
+ # what you consumed in a period \u2014 the statement
982
+ ignitify usage:export [--period YYYY-MM] [--axis ${sd}]
983
+ [--vm <vm-id>] [--run <run-id>] (--json|--csv)
984
+ # one line per ledger row; the machine statement
985
+
986
+ Sign in:
987
+ ignitify login [--name <label>] [--no-browser]
988
+ # sign this machine in; the key is saved in
989
+ # ~/.config/ignitify/credentials.json (mode 0600).
990
+ # --name keeps two machines with one hostname apart
991
+ ignitify logout # revoke this machine's key and delete the saved file
992
+
993
+ Other:
994
+ ignitify whoami # tenant identity + limits + usage
995
+ ignitify quota # entitlements and what is left of them
996
+ ignitify --version # client + API version; warns if below the API's floor
997
+ ignitify help [<command>] # or: ignitify <command> --help (only that command's lines)
998
+
999
+ Delete commands always ask for confirmation; pass --yes to skip (required when non-interactive).
1000
+ --force unlocks a refusal (e.g. a pinned VM); it does NOT skip the question.
1001
+ Short flags: -h = --help and -y = --yes (anywhere); -v = --version (first word only). No other
1002
+ short flags exist. A flag or argument a command does not take is refused, not ignored.
1003
+ On error the CLI prints a clean message and exits non-zero (scripts and CI see
1004
+ the failure).
1005
+ Auth: run 'ignitify login' once per machine. The IGNITIFY_API_KEY environment variable, when set, wins
1006
+ over the saved key (for CI). Never put a key in task.yaml.`,NOT_SIGNED_IN:"Not signed in. Run 'ignitify login', or set the IGNITIFY_API_KEY environment variable.",CREDENTIALS_SYMLINK:e=>`${e} is a symbolic link. Remove it and run 'ignitify login' again.`,CREDENTIALS_NOT_FILE:e=>`${e} is not a regular file. Remove it and run 'ignitify login' again.`,CREDENTIALS_NOT_OWNED:e=>`${e} belongs to another user. Remove it and run 'ignitify login' again.`,CREDENTIALS_TOO_OPEN:(e,t)=>`${e} can be read by other users (mode 0${t}). Run: chmod 600 ${e}`,CREDENTIALS_UNREADABLE:e=>`${e} is not a valid credentials file. Remove it and run 'ignitify login' again.`,CREDENTIALS_OTHER_URL:(e,t)=>`The saved key is for ${e}, not ${t}. Run 'ignitify login --api ${t}'.`,LOGIN_OPEN_PAGE:"To sign in, open this page:",LOGIN_ASK_OPERATOR:"To sign in, give this code to your operator, who approves it:",LOGIN_CHECK_CODE:e=>`Check that the page shows this code: ${e}`,LOGIN_CODE:e=>` Code: ${e}`,LOGIN_WAITING:e=>`Waiting for approval. The code expires in ${e} minutes.`,LOGIN_OK:(e,t)=>`\u2713 Signed in as ${e} (${t})`,LOGIN_SAVED:(e,t)=>` Key "${e}" is saved in ${t}`,LOGIN_LIFE:e=>` It expires after ${e} days without use. Each use renews it.`,LOGIN_REPLACED:e=>`Note: replaced the key "${e}" of another machine. Use 'ignitify login --name <other-label>' to keep both.`,LOGIN_EXPIRED:e=>`The code ${e} expired before it was approved. Run 'ignitify login' again.`,LOGIN_REFUSED:e=>`The sign-in was refused: ${e}.`,LOGIN_UNKNOWN:"The sign-in code is unknown or was already used. Run 'ignitify login' again.",LOGIN_BAD_ANSWER:"The server sent a sign-in answer with no usable key. Nothing was saved.",LOGIN_BAD_START:"The server sent a sign-in start that the CLI cannot use (no code, or no wait times). Nothing was started.",ENV_KEY_OVERRIDES_LOGIN:"Note: the IGNITIFY_API_KEY environment variable is set, so it is used instead of your saved login.",KEY_EXPIRED_HINT:"Run 'ignitify login' to sign in again.",LOGIN_TOO_MANY:"Too many sign-in attempts from this network. Try again later.",LOGIN_CAP:e=>`This account already has the most API keys its plan allows${e===null?"":` (${e})`}. Remove one, or approve with "replace", then run 'ignitify login' again.`,CANNOT_REACH:(e,t)=>`Cannot reach ${e}${t===null?"":` (${t})`}. Check your network and run 'ignitify login' again.`,UNREACHABLE:(e,t)=>`Cannot reach ${e}${t===null?"":` (${t})`}.`,LOGOUT_OK:"\u2713 Signed out. The key was revoked and the saved credentials were deleted.",LOGOUT_NOTHING:"Not signed in. There are no saved credentials.",LOGOUT_ENV_NOTE:"Note: the IGNITIFY_API_KEY environment variable is still set. Logout does not change it.",LOGOUT_NOT_REVOKED:e=>`Warning: the server did not revoke the key, so it may still work. The saved credentials were deleted. Ask your operator to revoke the key "${e}".`,SLUG_MISSING:e=>`'slug' is required in ${e}`,SLUG_INVALID:(e,t)=>`${e}: 'slug' ${t}`,PRESET_INVALID:"run.preset must be a non-empty string",PRESET_UNKNOWN:(e,t,n)=>`${e}: unknown run.preset "${t}" (valid: ${n.join(", ")}). An unrecognised preset would silently fall back to the platform default, giving you a different instance class than you declared.`,TIMEOUT_INVALID:"run.timeout_sec must be a positive number",TASK_ID_REQUIRED:"a <task-id> is required",TASK_ID_INVALID:(e,t)=>`task id ${JSON.stringify(e)} ${t}`,ERROR:e=>`Error: ${e}`,SERVER_TRACE_ID:e=>`server trace id: ${e}`,ARG_REQUIRED:e=>`${e} is required`,UNKNOWN_COMMAND:"unknown command",UNKNOWN_SHORT_FLAG:(e,t,n)=>`unknown flag ${e} (--${t}) for ${n}`,GRACE_INVALID:e=>`--grace must be a whole number of milliseconds, 0 or more (got ${JSON.stringify(e)})`,GRACE_WITH_FORCE:"--grace has no effect with --force (force stops the run now)",TASK_LIMITS:(e,t)=>`payload max ${e}, result max ${t}; over the limit the run fails`,PAYLOAD_OVER_LIMIT:(e,t)=>`payload is ${e} bytes; the limit is ${t} bytes`,PAYLOAD_REFUSED_BY_SERVER:e=>`the server refused the payload as too large; the limit is ${e} bytes`,DEFAULT_PAYLOAD_OVER_LIMIT:(e,t,n)=>`${e}: run.payload is ${t} bytes; the offline limit is ${n} bytes (the server may allow more)`,IGNORED_BY_FILE:`ignored by ${mn}`,IGNORED_COUNT:e=>`${e} path(s) left out by ${mn}`,TASK_DELETED:"task deleted",TASK_LINK_REMOVED:"Removed local link",TASK_LINK_NOT_REMOVED:(e,t)=>`Warning: the task is deleted, but its local link was not removed (${t}). Remove ${e} by hand.`,DEPLOY_DELETED:"deployment deleted",RUN_DELETED:"run deleted",ABORTED:"Aborted.",SECRET_SET_USAGE:"usage: ignitify secret:set <NAME> --stdin (the value is read from stdin)",SECRET_VALUE_EMPTY:"secret:set read an empty value from stdin \u2014 nothing was stored (pipe the value in: `--stdin < value-file`)",SECRET_VALUE_ON_ARGV:`secret:set takes no value on argv: it is visible in \`ps\` and is written to your shell history. Pipe it on stdin, e.g.
1007
+ ignitify secret:set <NAME> --stdin < value-file
1008
+ printf %s "$VALUE" | ignitify secret:set <NAME> --stdin
1009
+ \u26A0\uFE0F The value you just typed is already in your history \u2014 rotate it.`,NOTIFY_SECRET_ON_ARGV:'--secret is not accepted: a value on argv is visible in `ps` and is written to your shell history. Use --secret-stdin, e.g.\n printf %s "$SECRET" | ignitify notify:set <deployment-id> --url <https://\u2026> --secret-stdin\n\u26A0\uFE0F The value you just typed is already in your history \u2014 rotate it.',HOOK_CREATE_USAGE:"usage: ignitify hook:create <deployment-id> --task-name <name>",HOOK_TASK_NAME_REQUIRED:`--task-name <name> is required: a hook starts a run of ONE task in the deployment, and a run without a task name fails.
1010
+ usage: ignitify hook:create <deployment-id> --task-name <name>`,HOOK_LIST_USAGE:"usage: ignitify hook:list <deployment-id>",HOOK_DELETE_USAGE:"usage: ignitify hook:delete <hook-resource-id> (the HOOK id, not the deployment)",NOTIFY_SET_USAGE:`usage: ignitify notify:set <deployment-id> --url <https://\u2026> --secret-stdin
1011
+ ignitify notify:set <deployment-id> --clear
1012
+ --secret-stdin reads the signing secret (at least ${32} characters) from stdin; it is
1013
+ required with --url. There is no --secret flag: a value on argv is visible in \`ps\`
1014
+ and lands in your shell history.`,NOTIFY_URL_NEEDS_SECRET:"--url needs --secret-stdin: the server refuses a notify target with no signing secret.",NOTIFY_SECRET_EMPTY:"--secret-stdin read an empty value from stdin.",NOTIFY_URL_WITH_CLEAR:"--url and --clear cannot be used together.",NOTIFY_SECRET_STDIN_VALUE:"--secret-stdin takes no value: pipe the secret on stdin.",HOOK_SECRET_SHOWN_ONCE:"\u26A0\uFE0F The secret below is shown ONCE and cannot be read back \u2014 hook:list never returns it. Store it now; if it is lost, delete the hook and create a new one.",HOOK_PAYLOAD_LIMIT:e=>`A webhook body over ${e} is refused with 413 before the signature is checked.`,SECRET_DELETE_USAGE:"usage: ignitify secret:delete <NAME>",USAGE_EXPORT_USAGE:"usage: ignitify usage:export [--period YYYY-MM] (--json|--csv) (name exactly one format)",LATEST_DEPLOY_BUILDING:(e,t)=>`the latest deploy of ${e} is still building (${t}). Wait for it ('ignitify deployment:get ${t}'), or pass --deployment <id> to run an older one.`,LATEST_DEPLOY_FAILED:(e,t)=>`the latest deploy of ${e} failed: ${t??"no reason recorded"}. Fix the task and run 'ignitify task:deploy ${e}' again, or pass --deployment <id> to run an older one.`,RUN_AT_WITH_WAIT:"--wait cannot be used with --at: a scheduled run has no run id until it fires. Drop --wait; follow it later with 'ignitify schedule:list' and 'ignitify run:list'.",SECRET_STORED:e=>`${Ve.OK} secret ${e} stored`,SECRET_REMOVED:e=>`${Ve.OK} secret ${e} removed`},Qe={PENDING:"PENDING",PROVISIONING:"PROVISIONING",RUNNING:"RUNNING",RETRYING:"RETRYING",COMPLETED:"COMPLETED",FAILED:"FAILED",CANCELLED:"CANCELLED"},y_=[Qe.COMPLETED,Qe.FAILED,Qe.CANCELLED];function qn(e){return y_.includes(e)}var pd=new Set([Qe.PENDING,Qe.PROVISIONING,Qe.RUNNING,Qe.RETRYING]),hn={BUILDING:"BUILDING",READY:"READY",FAILED:"FAILED",QUARANTINED:"QUARANTINED",ARCHIVED:"ARCHIVED"},lt={DEPLOY:{BASE_MS:500,MAX_MS:1e3,TIMEOUT_MS:900*1e3},RUN:{BASE_MS:500,MAX_MS:3e3,TIMEOUT_MS:1800*1e3},ERROR:{MIN_TRIES:3,GRACE_MS:6e4}},ue={UPLOADING:(e,t)=>`Uploading ${e}${t?` (${t})`:""}`,UPLOAD_FAILED:"Upload failed",BUILDING:e=>`Building image ${e}`,BUILT:"Image built",REUSED:"Image already built \u2014 reused",BUILD_FAILED:"Build failed",BUILD_FAILED_DETAIL:(e,t)=>`Error: deployment ${e} failed to build \u2014 ${t}`,BUILD_TIMEOUT:"Still building after 15 minutes \u2014 stopped waiting",BUILD_TIMEOUT_DETAIL:e=>`Error: deployment ${e} is still building after 15 minutes. The build has NOT been cancelled \u2014 check it with 'ignitify deployment:get ${e}'.`,RUN:(e,t)=>`Run ${e} ${t}`,RUN_SUBMITTED:e=>`Run ${e} submitted`,RUN_ENDED:e=>`Run ${e}`,RUN_TIMEOUT:e=>`Run is still ${e} after 30 minutes \u2014 stopped waiting`,RUN_TIMEOUT_DETAIL:e=>`The run has NOT been cancelled \u2014 check it with 'ignitify run:get ${e}'.`,HINT_RETRYING:"lost contact with the server \u2014 retrying",LOST:"Lost contact with the server \u2014 stopped waiting",LOST_BUILD_DETAIL:(e,t)=>`Error: stopped waiting for deployment ${e}: ${t}. The build has NOT been cancelled \u2014 check it with 'ignitify deployment:get ${e}'.`,LOST_RUN_DETAIL:(e,t)=>`Error: stopped waiting for run ${e}: ${t}. The run has NOT been cancelled \u2014 check it with 'ignitify run:get ${e}'.`,HINT_BUILD:"Ctrl+C stops waiting, not the build",HINT_RUN:"Ctrl+C stops waiting, not the run",INTERRUPTED_BUILD:(e,t)=>`Stopped waiting. The build ${t?"keeps running":"is queued"} on the server \u2014 nothing was cancelled.
1015
+ Check it with: ignitify deployment:get ${e}`,INTERRUPTED_RUN:e=>`Stopped waiting. The run keeps going on the server \u2014 nothing was cancelled.
1016
+ Check it with: ignitify run:get ${e}`};f();f();var ct={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},__=process.stdout.isTTY;function Nt(e,t){return __?`${e}${t}${ct.reset}`:String(t)}var z={bold:e=>Nt(ct.bold,e),dim:e=>Nt(ct.dim,e),red:e=>Nt(ct.red,e),green:e=>Nt(ct.green,e),yellow:e=>Nt(ct.yellow,e),blue:e=>Nt(ct.blue,e),magenta:e=>Nt(ct.magenta,e),cyan:e=>Nt(ct.cyan,e),white:e=>Nt(ct.white,e)};function Yo(e){let t=String(e).toUpperCase();return["COMPLETED","READY","ACTIVE"].includes(t)?z.green(t):["PENDING","PROVISIONING","RUNNING","RETRYING","BUILDING"].includes(t)?z.yellow(t):["FAILED","QUARANTINED"].includes(t)?z.red(t):z.cyan(t)}var He={NEXT_STEP:"Next Step:",SYSTEM_RESOURCES:"System Resources:",RESULT:"Result:",MORE_LINES:e=>`\u2026 ${e} more lines (run:get --full shows all)`,BUILD_LOG:"Build log:",PLATFORM_BUILT_IMAGE:"Image: built and stored by the platform; there is nothing for you to download.",EARLIER_LINES:e=>`\u2026 ${e} earlier lines (deployment:get <id> shows all)`,NO_RESULTS:"(No results)"},As={SPINNER_FRAMES:["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],FRAME_MS:100,CLEAR_LINE:"\r\x1B[2K"},vr={RESULT_MAX_LINES:40,BUILD_LOG_TAIL_LINES:30},Ze={TENANT_PROFILE:"Tenant Profile",TASK_REGISTERED:"\u2713 Task Registered",SOURCE_PACK:"Source Upload (nothing built, nothing sent)",DEPLOYMENT_CREATED:"\u2713 Deployment Created",RUN_SUBMITTED:"\u2713 Run Submitted",RUN_DETAILS:"Run Details",DEPLOYMENT_DETAILS:"Deployment Details",VM_DETAILS:"VM Details",USAGE:"Usage & Limits",ENTITLEMENTS:"Entitlements (tier policy)",ENFORCED:"Enforced Limits (what this server applies)"},md="(per server)",hd=" (per server) \u2014 each server applies this limit on its own, so the limit across all servers is at least this.",ks={max_compute_seconds_month:"(run seconds, not the VM time `usage` shows as compute)"},Wo={SCALAR:["payload","result","slug"],LIST:["payload","result","execution"]},tt={TASK_GET_OFFLINE:e=>`Note: ${e.replace(/\.$/,"")}. The server sections show UNKNOWN.`,TASK_CREATED_LOCAL:(e,t,n)=>`Created ${e} task ${t} at ${n} (local only \u2014 not registered)`,HOOK_CREATED_TITLE:"\u2713 Webhook Created",HOOK_SECRET_KEY:"secret (shown ONCE)",HOOK_DELETED:e=>`Webhook deleted: ${e}`,NOTIFY_SET:(e,t)=>`Notify URL for ${e} set to ${t}`,NOTIFY_CLEARED:e=>`Notify URL for ${e} cleared`,SCHEDULE_CANCELLED:e=>`Schedule cancelled: ${e}`},Ir={ALREADY_TERMINAL:"already-terminal",DRAINING:"draining",CANCELLED:"cancelled"};function Et(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function zo(e){return e==null?"-":typeof e=="object"?JSON.stringify(e):String(e)}function gn(){return process.stdout.columns??80}function gd(e,t){let n=t.map(o=>o.map(zo)),r=e.map((o,i)=>{let a=[o,...n.map(l=>l[i]??"")];return Math.max(...a.map(l=>Et(l).length))});return r.reduce((o,i)=>o+i,0)+Math.max(0,r.length-1)*2}function yn(e,t){let n=t.map(c=>c.map(zo)),r=e.map((c,u)=>{let p=[c,...n.map(m=>m[u]??"")];return Math.max(...p.map(m=>Et(m).length))}),o=(c,u)=>{let p=Et(c).length;return c+" ".repeat(Math.max(0,u-p))},i=[],a=e.map((c,u)=>z.bold(o(c,r[u]??0))).join(" ");i.push(a);let l=r.map(c=>z.dim("-".repeat(c))).join(" ");i.push(l);for(let c of n){let u=c.map((p,m)=>o(p,r[m]??0)).join(" ");i.push(u)}return i.join(`
1017
+ `)}function yd(e,t,n){let r=t.map(c=>c.map(zo)),o=Math.max(...e.map(c=>Et(c).length)),i=Math.max(0,n-o-2),a=z.dim("\u2500".repeat(Math.min(n,60))),l=[];for(let c of r){let u=[];for(let p=0;p<e.length;p++){let m=e[p]??"",h=c[p]??"",b=z.bold(z.cyan(m+" ".repeat(Math.max(0,o-Et(m).length)))),g=i>4&&Et(h).length>i?h.slice(0,i-1)+"\u2026":h;u.push(`${b} ${g}`)}l.push(u.join(`
1018
+ `))}return l.join(`
1019
+ ${a}
1020
+ `)}function ws(e,t,n=gn()){return gd(e,t)<=n?yn(e,t):yd(e,t,n)}function ut(e,t){let n=[],r=Object.entries(e).filter(([,i])=>i!==void 0);if(r.length===0)return z.dim("(empty)");let o=Math.max(...r.map(([i])=>Et(i).length));for(let[i,a]of r){let l=i+" ".repeat(Math.max(0,o-Et(i).length)),c=zo(a),u=t&&t>4&&Et(c).length>t?c.slice(0,t-1)+"\u2026":c;n.push(`${z.bold(z.cyan(l))} ${u}`)}return n.join(`
1021
+ `)}function Kn(e,t={}){let{max:n=vr.RESULT_MAX_LINES,keep:r="head",note:o=He.MORE_LINES}=t,i=e.split(`
1022
+ `),a=Math.max(0,i.length-n),l=(r==="head"?i.slice(0,n):i.slice(a)).map(u=>` ${u}`);if(a===0)return l.join(`
1023
+ `);let c=z.dim(` ${o(a)}`);return(r==="head"?[...l,c]:[c,...l]).join(`
1024
+ `)}f();f();var E_="a positive integer of MiB";function S_(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}var Nr={cardinality:"one",duration:"short",state:"independent",interaction:"boundary-only",network:"none",residency:"auto",egress_tls_only:!1},b_=["one","many","continuous"],T_=["short","long","unbounded"],R_=["independent","across-runs","across-crashes"],A_=["boundary-only","continuous"],_d=["none","egress","bidirectional"],k_=["auto","pinned"],Ed=["queue","reject"];var w_=/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i;function v_(e){if(e.length===0||e.length>253)return!1;let t=e.split(".");return t.length<2?!1:t.every((n,r)=>r===0&&n==="*"||w_.test(n))}var Sd=32,bd=256;function I_(e){if(typeof e!="object"||e===null||Array.isArray(e))return`invalid entry ${JSON.stringify(e)??String(e)} (each entry is an object: {prefix} or {path})`;let t=e,n=Object.keys(t),r="prefix"in t,o="path"in t;if(r===o||n.length!==1)return`invalid entry ${JSON.stringify(t)} (each entry is exactly one of {prefix: "\u2026"} or {path: "\u2026"})`;let i=r?t.prefix:t.path;return typeof i!="string"||!i.startsWith("/")||/\s|[\x00-\x1f\x7f]/.test(i)||i.length>bd?`invalid route "${String(i)}" (must start with "/", contain no whitespace or control characters, and be \u2264${bd} chars)`:(r?Fn.startsWith(i)||i.startsWith(Fn):i===Fn||i.startsWith(Fn))?`"${i}" shadows the reserved platform namespace "${Fn}" and cannot be declared (it would be dead config: the platform's own routes match first)`:null}var Td={duration:["unbounded"],state:["across-crashes"]},N_={state:["across-runs"]};function Rd(e,t){return typeof e=="string"&&t.includes(e)}function $r(e,t,n){if(e!==void 0&&(typeof e!="object"||e===null||Array.isArray(e)))return{ok:!1,error:`execution must be an object, got ${e===null?"null":Array.isArray(e)?"an array":`"${String(e)}"`}. Omit it entirely to take the platform defaults.`};let r=e??{},o=[],i=["cardinality","duration","state","interaction","storage_mib","residency","network","on_busy"],a=Object.keys(r).filter(P=>!i.includes(P)),l=["egress_allow","egress_tls_only","egress_mbit","inbound_port","inbound_rps","inbound_burst","inbound_max_concurrent","inbound_routes"],c=a.filter(P=>!l.includes(P));if(c.length>0)return{ok:!1,error:`execution.${c[0]}: unknown key (allowed: ${i.join(", ")}). A misspelled key would be silently ignored, so it is rejected here.`};if(r.on_busy!==void 0&&!Rd(r.on_busy,Ed))return{ok:!1,error:`execution.on_busy: unknown value "${String(r.on_busy)}" (allowed: ${Ed.join(", ")})`};let u=["egress_allow","egress_tls_only","egress_mbit","inbound_port","inbound_rps","inbound_burst","inbound_max_concurrent","inbound_routes"],p=u.filter(P=>r[P]!==void 0);if(p.length>0)return{ok:!1,error:`execution.${p[0]} must now live inside execution.network. Move ${p.map(P=>`"${P}"`).join(", ")} into the network object: network: { type: "egress", ${p[0]}: \u2026 }`};let m=r.network;if(m!==void 0&&(typeof m!="object"||m===null||Array.isArray(m)))return{ok:!1,error:`execution.network must be an object, got ${Array.isArray(m)?"an array":`"${String(m)}"`}. Use network: { type: "${String(m)}" }`};let h=m??{};if(m!==void 0&&h.type===void 0)return{ok:!1,error:`execution.network.type is required when execution.network is declared (allowed: ${_d.join(", ")})`};let b=Object.keys(h).filter(P=>P!=="type"&&!u.includes(P));if(b.length>0)return{ok:!1,error:`execution.network.${b[0]}: unknown key (allowed: type, ${u.join(", ")})`};let g={...r,network:h.type,...h};delete g.type,m===void 0&&delete g.network;let S=[["cardinality",b_],["duration",T_],["state",R_],["interaction",A_],["network",_d],["residency",k_]];for(let[P,M]of S)if(g[P]!==void 0&&!Rd(g[P],M))return{ok:!1,error:`execution.${P}: unknown value "${String(g[P])}" (allowed: ${M.join(", ")})`};if(g.storage_mib!==void 0&&!S_(g.storage_mib))return{ok:!1,error:`execution.storage_mib: invalid value "${String(g.storage_mib)}" (must be ${E_})`};if(g.egress_allow!==void 0){if(!Array.isArray(g.egress_allow))return{ok:!1,error:"execution.egress_allow: must be an array of hostnames"};if(g.egress_allow.length>32)return{ok:!1,error:`execution.egress_allow: too many entries (${g.egress_allow.length} > ${32})`};for(let P of g.egress_allow)if(typeof P!="string"||!v_(P))return{ok:!1,error:`execution.egress_allow: invalid hostname "${String(P)}" (dotted DNS name; '*' allowed only as the left-most label)`}}if(g.egress_tls_only!==void 0&&typeof g.egress_tls_only!="boolean")return{ok:!1,error:`execution.egress_tls_only: must be a boolean (got "${String(g.egress_tls_only)}")`};if(g.inbound_port!==void 0&&!(typeof g.inbound_port=="number"&&Number.isInteger(g.inbound_port)&&g.inbound_port>=1024&&g.inbound_port<=65535))return{ok:!1,error:`execution.inbound_port: invalid value "${String(g.inbound_port)}" (must be an integer in ${1024}\u2013${65535})`};let v=["inbound_rps","inbound_burst","inbound_max_concurrent"];for(let P of v){let M=g[P];if(M!==void 0&&!(typeof M=="number"&&Number.isInteger(M)&&M>0))return{ok:!1,error:`execution.${P}: invalid value "${String(M)}" (must be a positive integer)`}}if(g.egress_mbit!==void 0&&!(typeof g.egress_mbit=="number"&&Number.isInteger(g.egress_mbit)&&g.egress_mbit>0))return{ok:!1,error:`execution.egress_mbit: invalid value "${String(g.egress_mbit)}" (must be a positive integer of Mbit/s)`};if(g.inbound_routes!==void 0){if(!Array.isArray(g.inbound_routes))return{ok:!1,error:"execution.network.inbound_routes: must be an array of {prefix} or {path} entries"};if(g.inbound_routes.length>Sd)return{ok:!1,error:`execution.network.inbound_routes: too many entries (${g.inbound_routes.length} > ${Sd})`};for(let H of g.inbound_routes){let G=I_(H);if(G!==null)return{ok:!1,error:`execution.network.inbound_routes: ${G}`}}let P=new Set,M=[];for(let H of g.inbound_routes){let G="prefix"in H,ge=G?H.prefix:H.path,Oe=`${G?"prefix":"path"}:${ge}`;if(P.has(Oe)&&o.push(`execution.network.inbound_routes: duplicate entry ${JSON.stringify(H)} (harmless \u2014 first match wins \u2014 but likely unintended)`),P.add(Oe),G){ge.endsWith("/")||o.push(`execution.network.inbound_routes: prefix "${ge}" does not end in "/" \u2014 it also matches "${ge}-admin" and "${ge}X". Use "${ge}/" for just that path segment, or { path: "${ge}" } for an exact match.`);for(let et of M)(ge.startsWith(et)||et.startsWith(ge))&&o.push(`execution.network.inbound_routes: prefixes "${et}" and "${ge}" overlap (harmless \u2014 both reach the same task \u2014 but likely unintended)`);M.push(ge)}}}let R={cardinality:g.cardinality??t.cardinality,duration:g.duration??t.duration,state:g.state??t.state,interaction:g.interaction??t.interaction,network:g.network??t.network,residency:g.residency??t.residency,egress_tls_only:g.egress_tls_only??(g.egress_allow!==void 0?!0:t.egress_tls_only)};if(g.egress_allow!==void 0&&(R.egress_allow=[...g.egress_allow]),g.inbound_port!==void 0&&(R.inbound_port=g.inbound_port),g.storage_mib!==void 0&&(R.storage_mib=g.storage_mib),g.inbound_rps!==void 0&&(R.inbound_rps=g.inbound_rps),g.inbound_burst!==void 0&&(R.inbound_burst=g.inbound_burst),g.inbound_max_concurrent!==void 0&&(R.inbound_max_concurrent=g.inbound_max_concurrent),g.egress_mbit!==void 0&&(R.egress_mbit=g.egress_mbit),R.network==="bidirectional"?R.inbound_routes=g.inbound_routes?[...g.inbound_routes]:[]:g.inbound_routes!==void 0&&(R.inbound_routes=[...g.inbound_routes]),n!==void 0&&R.storage_mib!==void 0&&R.storage_mib>n)return{ok:!1,error:`execution.storage_mib=${R.storage_mib} exceeds the scratch limit (${n} MiB)`};if(R.cardinality==="one"&&R.state==="across-runs")return{ok:!1,error:'execution.state="across-runs" requires cardinality "many" or "continuous" (a one-shot VM has no state to carry)'};if(R.residency==="pinned"&&R.cardinality==="one")return{ok:!1,error:'execution.residency="pinned" requires cardinality "many" or "continuous" (a one-shot VM tears down after its unit \u2014 there is nothing to pin)'};if(R.egress_allow!==void 0&&R.network==="none")return{ok:!1,error:'execution.egress_allow requires network "egress" or "bidirectional" (network "none" has no egress path to allow)'};if(R.egress_tls_only&&R.network==="none")return{ok:!1,error:'execution.egress_tls_only requires network "egress" or "bidirectional" (network "none" has no egress path to restrict)'};if(R.network==="bidirectional"&&R.inbound_port===void 0)return{ok:!1,error:`execution.inbound_port is required with network "bidirectional" (the port the guest listens on, ${1024}\u2013${65535})`};if(R.inbound_port!==void 0&&R.network!=="bidirectional")return{ok:!1,error:`execution.inbound_port requires network "bidirectional" (network "${R.network}" has no inbound path to route)`};if(R.network!=="bidirectional"){for(let P of v)if(R[P]!==void 0)return{ok:!1,error:`execution.${P} requires network "bidirectional" (network "${R.network}" has no inbound path to rate-limit)`}}return R.inbound_routes!==void 0&&R.network!=="bidirectional"?{ok:!1,error:`execution.network.inbound_routes requires network "bidirectional" (network "${R.network}" has no inbound path to allow)`}:R.egress_mbit!==void 0&&R.network==="none"?{ok:!1,error:'execution.egress_mbit requires network "egress" or "bidirectional" (network "none" has no NIC to shape)'}:Td.duration.includes(R.duration)?{ok:!1,error:`execution.duration="${R.duration}" is not supported yet (needs checkpoint/resume)`}:Td.state.includes(R.state)?{ok:!1,error:`execution.state="${R.state}" is not supported yet (needs checkpoint/resume)`}:(N_.state.includes(R.state)&&o.push(`execution.state="${R.state}": snapshots are deferred \u2014 running as booted-VM warm (state reused but not snapshot-persisted)`),{ok:!0,nature:R,warnings:o})}f();var $s=["std.micro","std.small","std.medium","std.large","std.xlarge","mem.large","mem.xlarge","cpu.large"],Ad="std.micro";function kd(e){return $s.includes(e)}f();var wd={aboveCap:(e,t)=>`execution.storage_mib: ${e} MiB is above your plan's scratch limit (${t} MiB). Declare ${t} or less.`,defaultAboveCap:(e,t,n)=>`preset ${e} needs at least ${t} MiB of scratch disk, above your plan's scratch limit (${n} MiB). Choose a smaller preset.`,clamped:(e,t,n)=>`Note: storage_mib ${e} is below the ${t} default (${n} MiB). The run uses ${n} MiB.`};f();f();f();var vd=require("crypto"),Id=10;function Nd(e){return(0,vd.createHash)("sha256").update(e).digest("hex").slice(0,Id)}var s$=new RegExp(`^([0-9a-f]{${Id}})--([^.]+)\\.`);var $_=e=>Object.entries(e).map(([t,n])=>[t,t==="status"?Yo(String(n)):n]),dt=(e,t=!1)=>`
1025
+ ${z.bold(t?z.green(e):e)}
1026
+ `,ft=(e,t,n="")=>`${e}${t}${n?`
1027
+ `+n:`
1028
+ `}`,O_=e=>{let t={};for(let[n,r]of Object.entries(e))typeof r!="object"&&!Wo.SCALAR.includes(n)&&(t[n]=r);return t},x_=e=>{let{slug:t,...n}=e;return n},_n=e=>$_(x_(e)),$d=["B","KiB","MiB","GiB","TiB"],we=e=>{if(!Number.isFinite(e)||e<=0)return"0 B";let t=Math.min(Math.floor(Math.log2(e)/10),$d.length-1),n=e/2**(10*t);return`${t===0?n:n.toFixed(1)} ${$d[t]}`},Os=(e,t)=>`${e} / ${t??"unlimited"}`,P_=(e,t)=>t===void 0?we(e):`${we(e)} / ${t===null?"unlimited":we(t)}`,xs=e=>{if(!e)return"";let{limits:t,usage:n,tier:r,policy:o,bound_by:i,status_reason:a,policy_scope:l,enforced:c,...u}=e,p={...u};typeof a=="string"&&a!==""&&(p.status_reason=a),r&&(p.tier=`${r.name} v${r.version}`),i&&(p.bound_by=i);let m=Object.fromEntries(_n(p)),h=ft(dt(Ze.TENANT_PROFILE),ut(m));return(t||n)&&(h+=Pd(t,n)),o&&(h+=L_(o,l?.per_brain??[])),c&&c.length>0&&(h+=C_(c)),h},Od=e=>e===null?"\u2014":String(e),C_=e=>{let t={};for(let n of e){let r=Od(n.enforced);t[n.column]=n.winner==="host-clamp"?`${r} (platform cap; tier asked ${Od(n.tier)})`:n.winner==="host-default"?`${r} (platform default)`:r}return ft(dt(Ze.ENFORCED),ut(t))},xd=(e,t)=>e==="allowed_presets"?Array.isArray(t)?t.join(", "):"all":t==null?"unlimited":typeof t=="boolean"?t?"yes":"no":String(t),L_=(e,t=[])=>{let n=new Set(t),r={};for(let[i,a]of Object.entries(e)){if(i==="tier_id"||i==="tier_name"||i==="tier_version")continue;let l=ks[i]?`${xd(i,a)} ${ks[i]}`:xd(i,a);r[i]=n.has(i)?`${l} ${md}`:l}let o=ft(dt(Ze.ENTITLEMENTS),ut(r));return n.size===0?o:`${o}
1029
+ ${hd}
1030
+ `},Pd=(e,t)=>{let n={tasks:Os(t?.task_count??0,e?.max_tasks),active_runs:Os(t?.active_runs??0,e?.max_running_vms),pinned_vms:Os(t?.pinned_vms??0,e?.max_pinned_vms),deployments:String(t?.deployment_count??0),disk_used:P_(t?.total_image_bytes??0,e?.max_total_image_bytes),...e?.max_storage_mib!==void 0?{scratch_ceiling:`${e.max_storage_mib} MiB`}:{},...t?.net_egress_bytes!==void 0?{egress_out_this_month:we(t.net_egress_bytes)}:{},...t?.deployments_created!==void 0?{deployments_this_month:String(t.deployments_created)}:{},...t?.api_requests_approx!==void 0?{api_requests_this_month:`~${t.api_requests_approx} (approx)`}:{}};return ft(dt(Ze.USAGE),ut(n))},Ps=e=>{if(!e)return"";let{limits:t,usage:n}=e;return Pd(t,n)},Cs=e=>ft(dt(Ze.TASK_REGISTERED,!0),yn(["Key","Value"],_n(e))),Ls=e=>{let t=e.files??[],n=t.map(a=>[a.path,we(a.size)]),r=`${t.length} file${t.length===1?"":"s"} \xB7 ${we(e.total_bytes)} \xB7 ${e.content_hash??""}`,o=e.ignored??[],i=o.length>0?`${k.IGNORED_BY_FILE}: ${o.join(", ")}
1031
+ `:"";return ft(dt(Ze.SOURCE_PACK),i+yn(["Path","Size"],n),r)},Ds=e=>{let{capacity:t,...n}=e,r=yn(["Key","Value"],_n(n));return ft(dt(Ze.DEPLOYMENT_CREATED,!0),`${r}
1032
+
1033
+ ${z.bold(He.SYSTEM_RESOURCES)}
1034
+ ${z.dim("\u2022")} ${He.PLATFORM_BUILT_IMAGE}
1035
+ `)+Cd(t)},Ms=e=>{let{capacity:t,notices:n,...r}=e,o=Or(n);return ft(dt(Ze.RUN_SUBMITTED,!0),yn(["Key","Value"],_n(r)))+(o?`
1036
+ ${o}
1037
+ `:"")+Cd(t)},Or=e=>Array.isArray(e)?e.map(t=>t.code==="storage-clamped"?wd.clamped(t.requested,t.preset,t.effective):"").filter(t=>t!=="").join(`
1038
+ `):"",xr=e=>{let t=e;if(!t||!Array.isArray(t.limits)||t.limits.length===0)return"";let n=t.limits.map(r=>`Monthly ${r.text}`);return n.push(`Resets ${t.resets_at??"at the next UTC month"} \xB7 details: ${t.usage_command??"ignitify usage"}`),n.join(`
1039
+ `)},Cd=e=>{let t=xr(e);return t?`
1040
+ ${t}
1041
+ `:""},Us=(e,t=gn())=>{if(!e)return"";let n=O_(Object.fromEntries(_n(e))),r=Math.max(20,t-22),o=ut(n,r),i=e.result,a=i==null?"":`
1042
+ ${z.bold(He.RESULT)}
1043
+ ${Kn(JSON.stringify(i,null,2))}
1044
+ `;return ft(dt(Ze.RUN_DETAILS),o,a)},$t=(e,t=gn())=>{if(!Array.isArray(e)||e.length===0)return`
1045
+ ${z.dim(He.NO_RESULTS)}
1046
+ `;let n=Array.from(new Set(e.flatMap(Object.keys))).filter(o=>!Wo.LIST.includes(o)),r=e.map(o=>n.map(i=>i==="status"?Yo(String(o[i])):o[i]));return`
1047
+ ${ws(n,r,t)}
1048
+ `},Ld=(e,t)=>t===!1?"(missing)":e===null?"unknown":we(Number(e)),Fs=(e,t=gn())=>{let n=e.deployments??[],r=e.tenant_total_bytes,o=e.tenant_limit_bytes,i=n.map(({image_bytes:l,image_present:c,...u})=>({...u,...l!==void 0?{size:Ld(l,c)}:{}})),a=$t(i,t);if(r!==void 0&&n.length>0){let l=typeof o=="number"?` of ${we(o)}`:"";a+=`${z.dim(`Tenant total: ${we(r)}${l}`)}
1049
+ `}return a},D_=e=>{if(typeof e!="object"||e===null)return;let{names:t,drive:n}=e;if(!Array.isArray(t)||t.length===0)return;let r=n,o=r!=null&&typeof r.bytes=="number"?`drive ${we(r.bytes)} (snapshot ${String(r.snapshot)})`:"drive not built yet";return`${t.join(", ")} \xB7 ${o}`},js=e=>{if(!e)return"";let{image_bytes:t,image_present:n,build_log:r,system_packages:o,...i}=e,a=D_(o),l={...Object.fromEntries(_n(i)),...t!==void 0?{size:Ld(t,n)}:{},...a!==void 0?{packages:a}:{}},c=typeof r=="string"&&r!==""?`
1050
+ ${z.bold(He.BUILD_LOG)}
1051
+ ${Kn(r,{max:Number.POSITIVE_INFINITY})}
1052
+ `:"";return ft(dt(Ze.DEPLOYMENT_DETAILS),ut(l),c)},Xo=e=>e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${(e/6e4).toFixed(1)}m`:e<864e5?`${(e/36e5).toFixed(1)}h`:`${(e/864e5).toFixed(1)}d`,Gs=(e,t=gn())=>[U_(e.vms??[],t),...M_(e)].join(`
1053
+ `),M_=e=>{let t=e.lost_pins??[],n=e.remote_pins??[];return[...t.length===0?[]:[`
1054
+ Lost pins (VM did not survive a restart \u2014 re-pins on its next run):`,...t.map(r=>` ${r.vm_id} task=${r.task_slug} lost_at=${r.lost_at??"?"}`)],...n.length===0?[]:[`
1055
+ Pinned standbys with no VM row (ACTIVE pins; no live VM detail to show):`,...n.map(r=>` ${r.vm_id} task=${r.task_slug} pinned_at=${r.pinned_at}`)]]},U_=(e,t)=>{if(e.length===0)return`
1056
+ ${z.dim(He.NO_RESULTS)}
1057
+ `;let n=e.map(({age_ms:r,idle_ms:o,idle_warning:i,boot_fingerprint:a,nature:l,booted_at:c,tenant_id:u,...p})=>({...p,age:Xo(Number(r??0)),idle:o==null?"-":`${Xo(Number(o))}${i?" \u26A0":""}`}));return $t(n,t)},Vs=e=>{if(!e)return"";let{nature:t,age_ms:n,idle_ms:r,idle_warning:o,...i}=e,a={...Object.fromEntries(_n(i)),age:Xo(Number(n??0)),...r!=null?{idle:`${Xo(Number(r))}${o?" \u26A0 (past warning window)":""}`}:{},...t&&typeof t=="object"?Object.fromEntries(Object.entries(t).map(([l,c])=>[`nature.${l}`,c])):{}};return ft(dt(Ze.VM_DETAILS),ut(a))},Hs=(e,t)=>`
1058
+ ${z.dim("Command template for next step:")} ${z.bold(He.NEXT_STEP)} ${e}
1059
+ ${z.dim("Full command:")} ${t}
1060
+ `;f();var Jo=e=>typeof e=="string"&&e!==""?e:void 0,qs=e=>Jo(e.slug)??Jo(e.task_id)??"<task_id>",F_={"task:create":{template:"ignitify task:deploy <task_id>",resolve:e=>`ignitify task:deploy ${qs(e)}`},"task:pack":{template:"ignitify task:deploy <task_id>",resolve:e=>`ignitify task:deploy ${qs(e)}`},"task:deploy":{template:"ignitify task:run <task_id>",resolve:e=>`ignitify task:run ${qs(e)}`},"task:run":{template:"ignitify run:get <run_id>",resolve:e=>`ignitify run:get ${Jo(e.resource_id)??Jo(e.run_id)??"<run_id>"}`}},j_=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Ks=(e,t)=>{let n=F_[e];return n?{template:n.template,actual:n.resolve(j_(t)?t:{})}:null};var G_={whoami:xs,quota:Ps,"task:create":Cs,"task:pack":Ls,"task:deploy":Ds,"task:run":Ms,"run:get":Us,"task:list":$t,"deployment:list":Fs,"deployment:get":js,"run:list":$t,"vm:list":Gs,"vm:get":Vs,"schedule:list":$t},Pr=!1;function Bs(e){Pr=e}function Yt(){return Pr}function j(e){Pr?console.error(e):console.log(e)}function pe(e,t){Pr?console.log(JSON.stringify(e,null,2)):t&&console.log(t())}var be={render(e,t){if(Pr)return pe(t);let n=G_[e](t),r=Ks(e,t);r&&(n+=Hs(r.template,r.actual)),console.log(n)}};f();var{SPINNER_FRAMES:Ys,FRAME_MS:V_,CLEAR_LINE:Dd}=As;function Ws(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m ${String(t%60).padStart(2,"0")}s`:`${Math.floor(n/60)}h ${String(n%60).padStart(2,"0")}m`}function H_(e,t,n,r){let o=Ys[n%Ys.length]??Ys[0];return`${z.cyan(o)} ${e} ${z.dim(`\xB7 ${Ws(t)}`)}${r?z.dim(` (${r})`):""}`}var q_={update(){},succeed(){},fail(){},stop(){}};function Cr(e,t={}){if(t.silent??Yt())return q_;let n=t.stream??process.stderr,r=t.tty??!!n.isTTY,o=t.now??Date.now,i=o(),a=i,l=e,c,u=0,p=null,m=()=>{n.write(`${Dd}${H_(l,o()-a,u++,c)}`)},h=()=>{p&&clearInterval(p),p=null,r&&n.write(Dd)},b=(g,S)=>{h(),n.write(`${g} ${S} ${z.dim(`\xB7 ${Ws(o()-i)}`)}
1061
+ `)};return r?(m(),p=setInterval(m,V_),p.unref()):n.write(`${e}\u2026
1062
+ `),{update(g,S){g===l&&S===c||(l=g,c=S,a=o(),r?m():n.write(`${g}\u2026
1063
+ `))},succeed:g=>b(z.green(Ve.OK),g),fail:g=>b(z.red(Ve.ERR),g),stop:h}}async function Qo(e,t,n){let r=()=>{e.stop(),process.stderr.write(`
1064
+ ${t()}
1065
+ `),process.exit(130)};process.once("SIGINT",r);try{return await n()}finally{process.removeListener("SIGINT",r)}}f();function K_(e,t){if(t<fe.SECONDS_ONLY_BELOW)return`${Math.round(e)}\u2013${Math.round(t)} s`;let n=r=>Math.max(1,Math.round(r/fe.SECONDS_PER_MINUTE));return`${n(e)}\u2013${n(t)} min`}function B_(e){let t=`${Ve.WARN} ${fe.ITEM(e.name,e.verdict,e.note)}`;return e.suggest.length>0?`${t} \xB7 ${fe.SUGGEST(e.suggest)}`:t}function Y_(e){return[e.basis==="reused"?fe.ESTIMATE_REUSED:fe.ESTIMATE(K_(e.extra_build_seconds.low,e.extra_build_seconds.high),fe.BASIS[e.basis]),...e.excluded.length>0?[fe.EXCLUDED(e.excluded)]:[],...!e.fits_cap&&e.cap_mib!==null?[`${Ve.WARN} ${fe.NO_FIT(e.drive_mib,e.cap_mib)}`]:[]]}function W_(e){let t=e.advice.filter(r=>r.verdict!=="ok"),n=e.advice.filter(r=>r.verdict==="ok"&&!r.reviewed).map(r=>r.name);return[...t.map(B_),...n.length>0?[fe.NOT_REVIEWED(n)]:[],...t.length===0&&n.length===0&&e.unavailable.length===0?[fe.NO_CONCERNS]:[],...e.unavailable.length>0?[fe.NOT_ANSWERED(e.unavailable)]:[],...e.estimate!==null?Y_(e.estimate):[]]}function z_(e){switch(e.kind){case"rate-limited":return fe.RATE_LIMITED(e.retryAfterS);case"unavailable":return fe.UNAVAILABLE(e.reason);case"error":return fe.NO_ANSWER(e.status,e.message)}}function zs(e){return e.kind==="ok"?{lines:W_(e.response),fault:!1}:e.kind==="error"&&e.status!==null&&fe.FAULT_STATUSES.includes(e.status)?{lines:[fe.FAULT(e.status,e.message)],fault:!0}:{lines:[fe.SKIPPED(z_(e))],fault:!1}}f();var X_={"cancelled-via-vm-teardown":"its VM is destroyed and the run is recorded as CANCELLED","deleted-while-pending":"never dispatched \u2014 deleted before it could start","unknown-status":"unrecognised status; this CLI cannot say what happens to it"};function Xs(e){j("The following will be deleted:"),j(` \u2022 task (server, soft-delete): ${e.taskSlug}`),j(` \u2022 deployments: ${e.deploymentCount}`),j(` \u2022 runs: ${e.runCount}`),e.unlinkDirs.length===0&&j(" \u2022 local link (.ignitify/): (none found)");for(let t of e.unlinkDirs)j(` \u2022 local link (.ignitify/): ${t} (files kept)`);if(e.hasInFlight){j(""),j(`WARNING: ${e.affected.length} run(s) are still live and will be terminated:`);for(let t of e.affected)j(` \u2022 ${t.runId} [${t.status}]${t.vmId?` vm ${t.vmId}`:""}`),j(` \u21B3 ${X_[t.fate]}`)}}function Lr(e){return e.flatMap(([t,n])=>typeof n=="number"?[`${t}: ${n}`]:[]).join(", ")}f();function Js(e){let t=Zo(e)?.body,n=t?.reason==="bidirectional-busy"?t.pinned===!0:e.includes("bidirectional deployment runs one VM at a time")?e.includes("PINNED"):null;if(n===null)return null;let r=["\u2717 Run refused \u2014 this bidirectional deployment already has a live VM.",""," Concurrent VMs for bidirectional-network tasks are not supported"," (one VM at a time)."];if(n){let o=typeof t?.vm_id=="string"&&t.vm_id!==""?t.vm_id:"<vm-id>";r.push(""," Why it was not queued, even if you asked for --on-busy=queue:"," A PINNED VM has no idle timeout \u2014 it stays up until it is explicitly"," removed, so queueing behind it could wait forever.",""," What you can do now:"," \u2022 Reuse the pinned VM \u2014 submit the run against it instead",' \u2022 Use network.type "egress" if this task needs no inbound traffic',` \u2022 Remove it yourself: ignitify vm:delete ${o} --force`)}else r.push(""," Retry when the live VM finishes, or omit --on-busy=reject to queue instead.");return r.join(`
1066
+ `)}function Qs(e){let t=Zo(e);if(!t||t.status!==429)return null;let n=t.body;return typeof n.summary!="string"||n.summary===""?null:[`\u2717 Run refused \u2014 a monthly limit is reached (${n.reason??"429"}).`,` ${n.summary}`].join(`
1067
+ `)}var Zs=e=>Zo(e)?.status===413;function Zo(e){let t=/^API (\d{3}): (\{[\s\S]*\})$/.exec(e.trim());if(!t)return null;try{let n=JSON.parse(t[2]);return typeof n!="object"||n===null||Array.isArray(n)?null:{status:Number(t[1]),body:n}}catch{return null}}f();f();f();f();f();function ea(e,t){let[n="",...r]=e,o={},i=[];for(let a=0;a<r.length;a++){let l=r[a];if(l.startsWith("--")){let c=l.slice(2),u=c.indexOf("=");if(u!==-1)o[c.slice(0,u)]=c.slice(u+1);else{let p=r[a+1];t?.boolFlags?.has(c)?o[c]=!0:p!==void 0&&!p.startsWith("--")?(o[c]=p,a++):o[c]=!0}}else i.push(l)}return{command:n,options:o,positionals:i}}function Dr(e,t){return t.find(n=>e.options[n]===!0)}function En(e){return`--${e} needs a value`}f();function ei(e,t){return`unknown flag ${e} for ${t}`}var J_=e=>`Did you mean --${e}?`,Q_=(e,t)=>`Its flags: ${e.length===0?"(none)":e.map(n=>`--${n}`).join(" ")}. Global: ${t.map(n=>`--${n}`).join(" ")}.`,Z_=e=>`--${e} takes no value`,eE=(e,t,n,r)=>`${e} takes ${t} argument${t===1?"":"s"}; got ${r} (${n.map(o=>JSON.stringify(o)).join(", ")} ${n.length===1?"is":"are"} extra)`;function tE(e,t){let n=Array.from({length:t.length+1},(r,o)=>o);for(let r=1;r<=e.length;r++){let o=[r];for(let i=1;i<=t.length;i++)o[i]=Math.min(n[i]+1,o[i-1]+1,n[i-1]+(e[r-1]===t[i-1]?0:1));n=o}return n[t.length]}function Md(e,t){let n,r=3;for(let o of t){let i=tE(e,o);i>0&&i<r&&(n=o,r=i)}return n}function ta(e,t,n,r,o=[]){let i=ei(`--${e}`,t),a=c=>c.filter(u=>!o.includes(u)),l=Md(e,a([...n,...r]));return l!==void 0?`${i}. ${J_(l)}`:`${i}. ${Q_(a(n),a(r))}`}function na(e,t,n,r){for(let[o,i]of Object.entries(t.options))if(n[o]==="value"&&i===!0)return En(o);for(let[o,i]of Object.entries(t.options))if(n[o]==="bool"&&typeof i=="string")return Z_(o);return t.positionals.length>r?eE(e,r,t.positionals.slice(r),t.positionals.length):null}var nE=["","help","--help","-h"];function ra(e){return nE.includes(e.command)||e.options.help===!0}f();function oa(e){return e.map(t=>`"${t.replace(/"/g,'""')}"`).join(",")}var rE=12e4,oE="x-correlation-id",ve=class extends Error{status;body;traceId;constructor(t,n,r,o=null){super(`API ${t}: ${n||r}`),this.name="HttpError",this.status=t,this.body=n,this.traceId=o}};async function iE(e){let t=await e.text();if(!e.ok)throw new ve(e.status,t,e.statusText,e.headers.get(oE));return t?JSON.parse(t):{}}function Wt(e){let t=Object.entries(e).filter(([,r])=>r!==void 0&&r!==""),n=new URLSearchParams(t).toString();return n?`?${n}`:""}async function Ot(e,t={}){let n=t.fetchImpl??fetch,r=typeof FormData<"u"&&t.body instanceof FormData,o=t.body===void 0?void 0:r?t.body:JSON.stringify(t.body),i=t.method??"GET",a=t.timeoutMs??rE;try{let l=await n(e,{method:i,headers:t.headers,body:o,signal:AbortSignal.timeout(a)});return t.onCorrelationId?.(l.headers.get("x-correlation-id")),t.onHeaders?.(l.headers),await iE(l)}catch(l){if(l?.name!=="TimeoutError")throw l;let c=i==="GET"?"":" \u2014 the server may still complete it; check before you repeat";throw new Error(`no answer from ${i} ${e} within ${Math.round(a/1e3)} s${c}`,{cause:l})}}f();function Ud(e){let t=e.build?.system_packages??[];if(t.length===0)return{kind:"skip",reason:fe.NO_PACKAGES};let n=ed(t);return n.ok?{kind:"call",request:{names:n.names,runtime:e.runtime}}:{kind:"skip",reason:n.reason==="bad-names"?fe.BAD_NAMES(n.bad):fe.TOO_MANY(n.count,64)}}function sE(e){try{let t=JSON.parse(e);return typeof t=="object"&&t!==null?t:{}}catch{return{}}}function Fd(e,t){let n=sE(t);return e===429&&typeof n.retry_after_s=="number"?{kind:"rate-limited",retryAfterS:n.retry_after_s}:e===503&&typeof n.reason=="string"?{kind:"unavailable",reason:n.reason}:{kind:"error",status:e,message:t}}f();var jd={name:"@ignitify/cli",version:"1.0.0",description:"Developer CLI for Ignitify: pack, deploy, and run tasks",type:"module",main:"src/index.ts",engines:{node:">=22.13"},bin:{ignitify:"bin/ignitify.mjs"},scripts:{start:"tsx --env-file-if-exists=../../.env --env-file-if-exists=.env src/cli.ts",typecheck:"tsc --noEmit","build:binary":"node build-binary.mjs","build:release":"node build-binary.mjs release","build:npm":"node scripts/build-npm.mjs","smoke:npm":"node scripts/smoke-npm.mjs",test:"vitest run","test:watch":"vitest"},dependencies:{"@ignitify/contract":"*","@ignitify/execution":"*","@ignitify/http-client":"*","@ignitify/task-config":"*","@ignitify/validate":"*"},devDependencies:{"@types/js-yaml":"^4.0.9","js-yaml":"^4.2.0","@types/node":"^22.20.0",esbuild:"0.28.1",tsx:"^4.22.4",typescript:"^5.9.3",vitest:"^4.1.9"}};f();f();var zt=e=>[...e].sort((t,n)=>(n.created_at??"").localeCompare(t.created_at??""));f();var Mr=e=>e.replace(/^sha256:/,"");f();function _e(e,t){let n=Dr(e,[t]);if(n!==void 0)throw new Error(En(n));let r=e.options[t];return typeof r=="string"?r:void 0}function pt(e,t){let n={};for(let[r,o]of Object.entries(t)){let i=_e(e,r);i!==void 0&&(n[o]=i)}return n}function Re(e,t){return e.options[t]===!0}function Bn(e){return e.positionals[0]}function qe(e,t){let n=Bn(e);return n||(console.error(k.ARG_REQUIRED(t)),null)}f();var Yn=e=>e.forEach(t=>console.error(`${Ve.WARN} ${t}`)),ti=e=>e.forEach(t=>console.error(`${Ve.ERR} ${t}`));f();function Ke(e){return e instanceof Error?e.message:String(e)}function ni(e){return e instanceof ve&&e.traceId?k.SERVER_TRACE_ID(e.traceId):null}function lE(e){if(!(e instanceof ve)||e.status!==401)return null;try{return JSON.parse(e.body)?.error===ls?k.KEY_EXPIRED_HINT:null}catch{return null}}function Ur(e){console.error(k.ERROR(Ke(e)));let t=lE(e);t!==null&&console.error(t);let n=ni(e);n!==null&&console.error(n)}async function J(e){try{return await e()}catch(t){return Ur(t),1}}async function ia(e){try{return await e()}catch(t){Ur(t);return}}f();f();var Gd=ye(require("node:readline"),1),Ie={async confirm(e){if(!process.stdin.isTTY)return console.error("Refusing to proceed: not a TTY. Re-run with --yes to confirm non-interactively."),!1;let t=Gd.default.createInterface({input:process.stdin,output:process.stderr});try{let n=await new Promise(r=>t.question(`${e} [y/N] `,r));return/^y(es)?$/i.test(n.trim())}finally{t.close()}}};async function xe(e,t=Ie){return Re(e,"yes")||await t.confirm("Proceed?")?!0:(j(k.ABORTED),!1)}f();var Wn={sleep:e=>new Promise(t=>setTimeout(t,e)),now:()=>Date.now()};f();function zn(e){return Array.isArray(e)?e.map(zn):typeof e!="object"||e===null?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t.replace(/([a-z0-9])([A-Z])/g,(r,o,i)=>`${o}_${i.toLowerCase()}`),zn(n)]))}var Xn=jd.version,cE=3e3;function uE(e,t){let n=i=>/^\d+\.\d+\.\d+$/.test(i)?i.split(".").map(Number):null,r=n(e),o=n(t);if(!r||!o)return null;for(let i=0;i<3;i++){let a=r[i]-o[i];if(a!==0)return a}return 0}function dE(e,t){if(!t)return null;let n=uE(e,t);return n===null||n>=0?null:`warning: ignitify ${e} is older than this API supports (minimum ${t}) \u2014 upgrade ignitify to ${t} or newer`}function fE(e,t){let n=!1;return r=>{if(n)return;let o=dE(e,r.get(Ho));o&&(n=!0,t(o))}}var sa=fE(Xn,e=>console.error(e));async function pE(e,t=fetch,n=sa){let r;try{r=await t(`${e}${ne.LIVEZ}`,{signal:AbortSignal.timeout(cE)})}catch{return`API: unreachable at ${e}`}n(r.headers);let o=r.headers.get(us);if(!o)return`API: version not reported by ${e} (an API older than this client)`;let i=r.headers.get(Ho);return`API: ${o} at ${e}${i?` (minimum client ${i})`:""}`}async function Vd(e,t=fetch){let n=_e(e,"api")??Vn.API_URL;return console.log(`ignitify ${Xn} (built for API ${cs})`),console.log(await pE(n,t)),0}f();var Sn=ye(require("node:fs"),1),Hd=ye(require("node:os"),1),Fr=ye(require("node:path"),1),qd=require("node:crypto");function Jn(e=process.env,t=Hd.default.homedir()){let n=e.XDG_CONFIG_HOME,r=n&&Fr.default.isAbsolute(n)?n:Fr.default.join(t,".config");return Fr.default.join(r,wr.DIR_NAME,wr.FILE_NAME)}function mE(e,t,n){return t.isFile?n!==null&&t.uid!==n?k.CREDENTIALS_NOT_OWNED(e):(t.mode&63)!==0?k.CREDENTIALS_TOO_OPEN(e,(t.mode&511).toString(8)):null:k.CREDENTIALS_NOT_FILE(e)}function hE(e){let t;try{t=JSON.parse(e)}catch{return null}let n=t;if(!n||typeof n!="object"||n.version!==1)return null;for(let r of["api_url","api_key","key_id","label","saved_at"])if(typeof n[r]!="string"||n[r]==="")return null;return n}var gE=()=>typeof process.getuid=="function"?process.getuid():null,Kd=e=>e?.code==="ENOENT",yE=Sn.default.constants.O_RDONLY|(Sn.default.constants.O_NOFOLLOW??0)|(Sn.default.constants.O_NONBLOCK??0);function jr(e=Jn(),t=Sn.default){let n;try{n=t.openSync(e,yE)}catch(r){if(Kd(r))return{kind:"none"};if(r?.code==="ELOOP")return{kind:"refused",message:k.CREDENTIALS_SYMLINK(e)};throw r}try{let r=t.fstatSync(n),o=mE(e,{isFile:r.isFile(),uid:r.uid,mode:r.mode},gE());if(o!==null)return{kind:"refused",message:o};let i=hE(String(t.readFileSync(n,"utf8")));return i===null?{kind:"refused",message:k.CREDENTIALS_UNREADABLE(e)}:{kind:"ok",creds:i}}finally{t.closeSync(n)}}function Bd(e,t=Jn(),n=Sn.default){n.mkdirSync(Fr.default.dirname(t),{recursive:!0,mode:wr.DIR_MODE});let r=`${t}.${(0,qd.randomBytes)(6).toString("hex")}.tmp`,o=n.openSync(r,"wx",wr.FILE_MODE);try{n.writeSync(o,`${JSON.stringify(e,null,2)}
1068
+ `),n.fsyncSync(o)}catch(i){throw n.closeSync(o),n.unlinkSync(r),i}n.closeSync(o);try{n.renameSync(r,t)}catch(i){throw n.unlinkSync(r),i}}function Yd(e=Jn(),t=Sn.default){try{return t.unlinkSync(e),!0}catch(n){if(Kd(n))return!1;throw n}}f();var Qn=class extends TypeError{origin;detail;constructor(t,n,r){super(k.UNREACHABLE(t,n),{cause:r}),this.name="UnreachableError",this.origin=t,this.detail=n}};function _E(e){let t=e?.code;return typeof t=="string"&&qt.CODE_PATTERN.test(t)?t:null}function EE(e){return qt.TLS_CODES.includes(e)||qt.TLS_CODE_PREFIXES.some(t=>e.startsWith(t))}function SE(e){return qt.REASONS[e]??(EE(e)?qt.TLS_WORDS:null)}function bE(e){if(!(e instanceof Error))return null;let t=e.message.replace(/\s+/g," ").trim();return t===""?null:t.length>qt.DETAIL_MAX_CHARS?`${t.slice(0,qt.DETAIL_MAX_CHARS)}\u2026`:t}function TE(e){let t=_E(e);if(t===null)return bE(e);let n=SE(t);return n===null?t:`${t}: ${n}`}function RE(e){try{let t=typeof e=="string"?e:e instanceof URL?e.href:e.url;return new URL(t).origin}catch{return null}}function Wd(e,t){if(!(e instanceof TypeError)||e instanceof Qn||e.cause===void 0)return e;let n=RE(t);return n===null?e:new Qn(n,TE(e.cause),e)}var Xt={onHeaders:sa};function zd(e,t=process.env,n=()=>jr(),r=wE){let o=e??Vn.API_URL,i=t[Gn.KEY];if(i)return AE(o,kE(n))&&r(k.ENV_KEY_OVERRIDES_LOGIN),{baseUrl:o,token:i};let a=n();if(a.kind==="none")throw new Error(k.NOT_SIGNED_IN);if(a.kind==="refused")throw new Error(a.message);if(a.creds.api_url!==o)throw new Error(k.CREDENTIALS_OTHER_URL(a.creds.api_url,o));return{baseUrl:o,token:a.creds.api_key}}function AE(e,t){return t.kind==="ok"&&t.creds.api_url===e}function kE(e){try{return e()}catch{return{kind:"none"}}}var wE=(()=>{let e=!1;return t=>{e||(e=!0,console.error(t))}})();function vE(e=fetch){return(t,n)=>e(t,{...n,redirect:"manual"})}function Jt(e){let t=vE(e);return async(n,r)=>{try{return await t(n,r)}catch(o){throw Wd(o,n)}}}var aa={[ds]:Xn};function er(e){return{authorization:`Bearer ${e.token}`,...aa}}var Zn=class extends Error{};async function Xd(e,t,n){let r=await Ot(`${e.baseUrl}${ne.AUTH_DEVICE}`,{method:"POST",headers:{"content-type":"application/json",...aa},body:t,fetchImpl:Jt(n),...Xt});if(!IE(r))throw new Zn(k.LOGIN_BAD_START);return r}function IE(e){let t=e,n=i=>typeof i=="string"&&i!=="",r=i=>typeof i=="number"&&Number.isFinite(i)&&i>0,o=i=>i===null||typeof i=="string";return!!t&&n(t.device_code)&&n(t.user_code)&&o(t.verification_uri)&&o(t.verification_uri_complete)&&r(t.expires_in)&&r(t.interval)}async function Jd(e,t,n){let r;try{r=await Ot(`${e.baseUrl}${ne.AUTH_DEVICE_TOKEN}`,{method:"POST",headers:{"content-type":"application/json",...aa},body:{device_code:t},fetchImpl:Jt(n),...Xt})}catch(a){let l=a instanceof ve&&a.status===429?NE(a.body):null;if(l===null)throw a;return{kind:"wait",interval:l}}let o=r;if(o.status==="authorization_pending"&&typeof o.interval=="number")return{kind:"wait",interval:o.interval};let i=r;if(!i||typeof i.api_key!="string"||i.api_key===""||typeof i.key_id!="string"||typeof i.label!="string"||typeof i.tenant?.resource_id!="string")throw new Zn(k.LOGIN_BAD_ANSWER);return{kind:"key",key:i}}function NE(e){try{let t=JSON.parse(e);return t.status==="slow_down"&&typeof t.interval=="number"?t.interval:null}catch{return null}}function Qd(e,t){return Qt(e,ne.AUTH_KEY,t)}function $E(e){return e?"?force=true":""}async function Zd(e,t,n,r,o){let i=new FormData;return i.set("task_id",t),i.set("manifest",JSON.stringify(n)),i.set("bundle",new Blob([new Uint8Array(r)],{type:"application/x-tar"}),"bundle.tar"),await Ot(`${e.baseUrl}${ne.DEPLOYMENTS}`,{method:"POST",headers:er(e),body:i,fetchImpl:Jt(o),timeoutMs:3e5,...Xt})}async function ef(e,t,n){return await Ot(`${e.baseUrl}${ne.RUNS}`,{method:"POST",headers:{...er(e),"content-type":"application/json"},body:{deployment_id:t.deploymentId,task_name:t.taskName,payload:t.payload,preset:t.preset,timeout_sec:t.timeoutSec,execution:t.execution,at:t.at},fetchImpl:Jt(n),...Xt})}async function tf(e,t){return Pe(e,ne.SCHEDULES,t)}function nf(e,t,n){return Qt(e,ne.SCHEDULE_BY_ID(t),n)}function Pe(e,t,n){return Ot(`${e.baseUrl}${t}`,{headers:er(e),fetchImpl:Jt(n),...Xt})}function Gr(e,t,n,r,o){return Ot(`${e.baseUrl}${t}`,{method:"POST",headers:{...er(e),"content-type":"application/json"},body:n,fetchImpl:Jt(r),timeoutMs:o,...Xt})}function Qt(e,t,n){return Ot(`${e.baseUrl}${t}`,{method:"DELETE",headers:er(e),fetchImpl:Jt(n),...Xt})}function OE(e,t,n,r){return Ot(`${e.baseUrl}${t}`,{method:"PUT",headers:{...er(e),"content-type":"application/json"},body:n,fetchImpl:Jt(r),...Xt})}function Zt(e,t){return Pe(e,ne.WHOAMI,t)}function la(e,t={},n){return Pe(e,`${ne.USAGE}${Wt(t)}`,n)}function rf(e,t,n,r){return Gr(e,ne.SECRETS,{name:t,value:n},r)}function of(e,t){return Pe(e,ne.SECRETS,t)}function sf(e,t,n){return Qt(e,ne.SECRET_BY_NAME(t),n)}function af(e,t,n,r){return Gr(e,ne.DEPLOYMENT_HOOKS(t),n,r)}function lf(e,t,n={},r){return Pe(e,`${ne.DEPLOYMENT_HOOKS(t)}${Wt(n)}`,r)}function cf(e,t,n){return Qt(e,ne.HOOK_BY_ID(t),n)}function uf(e,t,n,r){return OE(e,ne.DEPLOYMENT_NOTIFY(t),n,r)}async function df(e,t,n){try{return{kind:"ok",response:await Gr(e,ne.PACKAGE_ADVICE,t,n,fe.TIMEOUT_MS)}}catch(r){return r instanceof ve?Fd(r.status,r.body):{kind:"error",status:null,message:r instanceof Error?r.message:String(r)}}}async function ff(e,t,n){return Gr(e,ne.TASKS,{slug:t},n)}async function pf(e,t={},n){return Pe(e,`${ne.TASKS}${Wt(t)}`,n)}function mf(e,t,n){return Qt(e,ne.TASK_BY_ID(t),n)}async function hf(e,t={},n){return Pe(e,`${ne.DEPLOYMENTS}${Wt(t)}`,n)}async function ca(e,t,n,r={}){let o=Wt({task_id:t,...r.limit!==void 0?{limit:String(r.limit)}:{}});return Pe(e,`${ne.DEPLOYMENTS}${o}`,n)}async function ri(e,t,n){return Pe(e,ne.DEPLOYMENT_BY_ID(t),n)}async function gf(e,t,n){return Pe(e,ne.TASK_DELETION_PREVIEW(t),n)}function yf(e,t,n){return Pe(e,ne.DEPLOYMENT_BY_ID(t),n)}function _f(e,t,n){return Qt(e,ne.DEPLOYMENT_BY_ID(t),n)}async function oi(e,t={},n){return Pe(e,`${ne.RUNS}${Wt(t)}`,n)}function Vr(e,t,n){return Pe(e,ne.RUN_BY_ID(t),n)}function Ef(e,t,n){return Pe(e,ne.RUN_LOGS(t),n)}function Sf(e,t,n){return Qt(e,ne.RUN_BY_ID(t),n)}function bf(e,t,n=!1,r,o){let i=new URLSearchParams;n&&i.set("force","true"),r!==void 0&&i.set("grace_ms",String(r));let a=i.size>0?`?${i}`:"";return Gr(e,`${ne.RUN_CANCEL(t)}${a}`,void 0,o)}async function Tf(e,t={},n){return Pe(e,`${ne.VMS}${Wt(t)}`,n)}async function ua(e,t,n){return Pe(e,ne.VM_BY_ID(t),n)}function Rf(e,t,n=!1,r){return Qt(e,`${ne.VM_BY_ID(t)}${$E(n)}`,r)}f();f();var Hr=e=>Buffer.byteLength(JSON.stringify(e)??"","utf8"),Af=(e,t)=>typeof e=="number"&&Number.isFinite(e)&&e>0?e:t;function kf(e,t){let n=Hr(e);return n>t?k.PAYLOAD_OVER_LIMIT(n,t):null}var ii=e=>we(e).replace(/\.0 /," "),xt=()=>k.TASK_LIMITS(ii(Kt),ii(ud));function Q(e){return zd(_e(e,"api"))}async function qr(e){let t=await Zt(e).catch(()=>null);return Af(t?.limits.max_payload_bytes,Kt)}async function da(e){return J(async()=>{let t=Q(e);return be.render("whoami",await Zt(t)),0})}async function fa(e){return J(async()=>{let t=Q(e);return be.render("quota",await Zt(t)),0})}f();var vf=ye(require("node:os"),1),If=require("node:child_process");function pa(e){return e.length===8?`${e.slice(0,4)}-${e.slice(4)}`:e}function xE(e,t,n){return!e||e===t?null:k.LOGIN_REPLACED(n)}function PE(e){try{let t=new URL(e);return jn.BROWSER_SCHEMES.includes(t.protocol)?t.href:null}catch{return null}}function wf(e){return Number.isFinite(e)&&e>jn.MIN_POLL_INTERVAL_SEC?e:jn.MIN_POLL_INTERVAL_SEC}function CE(e){let t=process.platform==="darwin"?"open":"xdg-open";try{let n=(0,If.spawn)(t,[e],{stdio:"ignore",detached:!0});n.on("error",()=>{}),n.unref()}catch{}}var LE=1e3,DE=e=>!(e instanceof Zn)&&(!(e instanceof ve)||e.status>=500),ME=e=>e instanceof Qn?e.detail:null;async function Nf(e,t,n,r){for(let o=0;;o++)try{return await r()}catch(i){if(!DE(i))throw i;if(o+1>=jn.MAX_RETRIES)throw new Error(k.CANNOT_REACH(e,ME(i)),{cause:i});await t.sleep(n)}}function UE(e){try{return JSON.parse(e.body)}catch{return{}}}function FE(e,t){let n=UE(e);switch(e.status){case 410:return k.LOGIN_EXPIRED(pa(t));case 403:return k.LOGIN_REFUSED(typeof n.error=="string"?n.error:e.message);case 404:return k.LOGIN_UNKNOWN;case 409:return k.LOGIN_CAP(typeof n.limit=="number"?n.limit:null);default:return e.message}}async function jE(e,t,n){let r=n.clock.now()+t.expires_in*1e3,o=wf(t.interval);for(;;){if(await n.clock.sleep(o*1e3),n.clock.now()>=r)throw new Error(k.LOGIN_EXPIRED(pa(t.user_code)));try{let i=await Nf(e,n.clock,o*1e3,()=>Jd({baseUrl:e},t.device_code,n.fetchImpl));if(i.kind==="key")return i.key;o=wf(i.interval)}catch(i){throw i instanceof ve?new Error(FE(i,t.user_code),{cause:i}):i}}}async function ma(e,t={}){return J(async()=>{let n=t.clock??Wn,r=_e(e,"api")??Vn.API_URL,o=_e(e,"name")??(t.hostname??vf.default.hostname)(),i=t.file??Jn(t.env),a=await Nf(r,n,LE,()=>Xd({baseUrl:r},{label:o,cli_version:Xn},t.fetchImpl)).catch(h=>{throw h instanceof ve&&h.status===429?new Error(k.LOGIN_TOO_MANY,{cause:h}):h}),l=pa(a.user_code);if(a.verification_uri_complete!==null){j(k.LOGIN_OPEN_PAGE),j(` ${a.verification_uri_complete}`),j(k.LOGIN_CHECK_CODE(l));let h=PE(a.verification_uri_complete);h!==null&&!Re(e,"no-browser")&&(t.openBrowser??CE)(h)}else j(k.LOGIN_ASK_OPERATOR),j(k.LOGIN_CODE(l));j(k.LOGIN_WAITING(Math.round(a.expires_in/60)));let c=await jE(r,a,{...t,clock:n}),u=null,p=!0;try{let h=jr(i,t.fsx);h.kind==="ok"?u=h.creds.key_id:h.kind==="refused"&&(p=!1)}catch{p=!1}Bd({version:1,api_url:r,api_key:c.api_key,key_id:c.key_id,label:c.label,saved_at:new Date(n.now()).toISOString()},i,t.fsx),j(k.LOGIN_OK(c.tenant.name,c.tenant.resource_id)),j(k.LOGIN_SAVED(c.label,i)),j(k.LOGIN_LIFE(jn.KEY_TTL_DAYS));let m=p?xE(c.replaced_key_id,u,c.label):null;return m!==null&&j(m),0})}async function ha(e,t={}){return J(async()=>{let n=t.env??process.env,r=t.file??Jn(n),o=()=>{n[Gn.KEY]&&j(k.LOGOUT_ENV_NOTE)},i=jr(r,t.fsx);if(i.kind==="none")return j(k.LOGOUT_NOTHING),o(),0;if(i.kind==="refused")throw new Error(i.message);let a;try{await Qd({baseUrl:i.creds.api_url,token:i.creds.api_key},t.fetchImpl),a=!0}catch(l){a=l instanceof ve&&l.status===401}return Yd(r,t.fsx),a?(j(k.LOGOUT_OK),o(),0):(console.error(k.LOGOUT_NOT_REVOKED(i.creds.label)),o(),1)})}f();f();function ga(e,t){return t==="bytes"?VE(e):t==="ms"?HE(e):t==="byte-hours"?GE(e):`${e}`}function GE(e){let t=["B\xB7h","KiB\xB7h","MiB\xB7h","GiB\xB7h","TiB\xB7h","PiB\xB7h"],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n+=1;return n===0?`${e} B\xB7h`:`${r.toFixed(1)} ${t[n]}`}function VE(e){let t=["B","KB","MB","GB","TB"],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n+=1;return n===0?`${e} B`:`${r.toFixed(1)} ${t[n]}`}function HE(e){if(e<1e3)return`${e} ms`;let t=Math.round(e/1e3);if(t<60)return`${t} s`;let n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function $f(e,t={lines:!1}){console.log(`usage for ${e.period}${e.filtered?" (filtered)":""}`),console.log(""),console.log(" AXIS QUANTITY LINES RECONCILIATION");for(let n of e.totals){let r=ga(n.quantity,n.unit).padEnd(18);console.log(` ${n.axis.padEnd(11)} ${r} ${String(n.lines).padStart(5)} ${qE(n)}`)}if(e.totals.some(n=>n.axis==="disk"||n.axis==="scratch")&&(console.log(""),console.log(" note: `disk` = your build images \xD7 the hours each was held this month (still-held images included);"),console.log(" `scratch` = each VM's scratch drive \xD7 the hours the VM ran. 1 GiB\xB7h = 1 GiB for one hour.")),e.totals.some(n=>n.axis==="compute")&&(console.log(""),console.log(" note: `compute` = VM time (boot to teardown). Your monthly compute limit counts run seconds instead.")),console.log(""),console.log(` runs started ${e.counters.runs_started} deployments created ${e.counters.deployments_created} API requests ${e.counters.api_requests_approx} (approx)`),!!t.lines){console.log(""),console.log(" AXIS QUANTITY VM / RUN DETAIL");for(let n of e.lines){let r=ga(n.quantity,n.unit).padEnd(18),o=(n.run_id??n.vm_id??n.deployment_id??"\u2014").padEnd(38);console.log(` ${n.axis.padEnd(11)} ${r} ${o} ${n.detail??""}`)}}}function qE(e){return!e.reconcilable||e.counter===null||e.drift===null?e.reconciliation==="none"?"\u2014":"not checked (filtered)":e.drift===0?"agrees with the meter":e.reconciliation==="inequality"&&e.drift>0?`${e.drift} still in flight`:`meter differs by ${ga(Math.abs(e.drift),e.unit)}`}function Of(e){let t="axis,vm_id,run_id,deployment_id,window_start,window_end,quantity,unit,detail",n=e.lines.map(r=>oa([r.axis,r.vm_id??"",r.run_id??"",r.deployment_id??"",r.window_start??"",r.window_end??"",String(r.quantity),r.unit,r.detail??""]));return[t,...n].join(`
1069
+ `)}function xf(e){let t={},n=_e(e,"period");n!==void 0&&(t.period=n);let r=_e(e,"axis");r!==void 0&&(t.axis=r);let o=_e(e,"vm");o!==void 0&&(t.vm=o);let i=_e(e,"run");return i!==void 0&&(t.run=i),t}function KE(e,t,n){return e.filter(r=>t&&r.run_id!==null||n&&r.vm_id!==null)}async function ya(e){return J(async()=>{let t=await la(Q(e),xf(e));if(Re(e,"json"))return console.log(JSON.stringify(t,null,2)),0;let n=Re(e,"runs"),r=Re(e,"vms"),o={...t,lines:KE(t.lines,n,r)};return $f(o,{lines:n||r}),0})}async function _a(e){return J(async()=>{let t=Re(e,"json"),n=Re(e,"csv");if(t===n)return console.error(k.USAGE_EXPORT_USAGE),1;let r=await la(Q(e),xf(e));return console.log(t?JSON.stringify(r.lines,null,2):Of(r)),0})}f();var Ty=ye(require("fs"),1),ts=ye(require("path"),1);f();function Pf(e){let t=[];for(let n of e.runs)qn(n.status)||t.push({runId:n.id,status:n.status,...n.vm_id?{vmId:n.vm_id}:{},fate:YE(n.status)});return{taskSlug:e.taskSlug,deploymentCount:e.deploymentCount,runCount:e.runCount,affected:t,unlinkDirs:BE(e.taskId,e.folders),hasInFlight:t.length>0}}function BE(e,t){return t.filter(n=>n.state.task_id===e).map(n=>n.dir)}function YE(e){return e===Qe.PENDING?"deleted-while-pending":e===Qe.PROVISIONING||e===Qe.RUNNING?"cancelled-via-vm-teardown":"unknown-status"}f();function Cf(e){if(e.flag)return{ok:!0,deploymentId:e.flag,source:"flag"};if(e.localStateId)return{ok:!0,deploymentId:e.localStateId,source:"local-state"};let t=zt(e.serverDeployments)[0];return t?{ok:!0,deploymentId:t.id,source:"server",latest:t}:{ok:!1,error:`no deployment found for '${e.taskSlug}' \u2014 run \`ignitify task:deploy ${e.taskSlug}\` first, or pass --deployment <id> explicitly.`}}function Lf(e,t,n){return n.status===hn.BUILDING?k.LATEST_DEPLOY_BUILDING(e,t):n.status===hn.FAILED?k.LATEST_DEPLOY_FAILED(e,n.failure_reason??null):null}f();var WE=Object.entries(Hn[D.TASK_RUN].flags).filter(([,e])=>e==="value").map(([e])=>e);function Df(e,t){let n=Dr(e,WE);if(n!==void 0)return{ok:!1,error:En(n)};let r=_e(e,"payload"),o=r===void 0?{ok:!0,value:t.run?.payload??{}}:zE(r);if(!o.ok)return{ok:!1,error:`--payload is not valid JSON: ${r}`};let i=_e(e,"timeout-sec"),a=i===void 0?void 0:Number(i);if(a!==void 0&&!(Number.isFinite(a)&&a>0))return{ok:!1,error:`--timeout-sec must be a positive number, got: ${i}`};let l=_e(e,"on-busy");if(l!==void 0&&l!=="queue"&&l!=="reject")return{ok:!1,error:`--on-busy must be 'queue' or 'reject', got: ${l}`};let c=_e(e,"at");if(c!==void 0&&Number.isNaN(new Date(c).getTime()))return{ok:!1,error:`--at is not a valid ISO-8601 timestamp: ${c}`};let u=Re(e,"wait");return c!==void 0&&u?{ok:!1,error:k.RUN_AT_WITH_WAIT}:{ok:!0,deploymentFlag:_e(e,"deployment"),wait:u,run:{payload:o.value,preset:t.run?.preset,timeoutSec:a??t.run?.timeout_sec,execution:l===void 0?t.execution:{...t.execution??{},on_busy:l},at:c}}}function zE(e){try{return{ok:!0,value:JSON.parse(e)}}catch{return{ok:!1}}}f();var en=ye(require("fs"),1),tr=ye(require("path"),1);var XE=["task_id","task_resource_id","deployment_id"];function JE(e){let t;try{t=JSON.parse(e)}catch{return{}}if(typeof t!="object"||t===null)return{};let n=t,r={};for(let o of XE)typeof n[o]=="string"&&(r[o]=n[o]);return r}function QE(e){return JSON.stringify(e,null,2)}function bn(e){let t=tr.default.join(e,It.DIR,It.FILE);return en.default.existsSync(t)?JE(en.default.readFileSync(t,"utf8")):{}}function Ea(e,t){let r={...bn(e),...t},o=tr.default.join(e,It.DIR,It.FILE);en.default.mkdirSync(tr.default.dirname(o),{recursive:!0});let i=tr.default.join(tr.default.dirname(o),It.GITIGNORE_FILE);en.default.existsSync(i)||en.default.writeFileSync(i,It.GITIGNORE_TEXT);let a=`${o}.tmp`;return en.default.writeFileSync(a,QE(r)),en.default.renameSync(a,o),r}f();var ZE=["network","storage_mib","cardinality","state","interaction","duration","residency"],Sa=e=>{let t=$r(e,Nr);return t.ok?t.nature:null},eS=e=>{let t=e.execution??void 0;return Sa(t)??$r(void 0,Nr).nature},tS=(e,t,n,r)=>{let o=[];n!==void 0&&r!==void 0&&n!==r&&o.push(`preset ${n}\u2192${r}`);for(let i of ZE)e[i]!==t[i]&&o.push(`${i} ${String(e[i]??"default")}\u2192${String(t[i]??"default")}`);return o},nS=(e,t)=>e==null!=(t==null),rS=(e,t)=>{if(t===null)return{needed:"unknown",reasons:["server unreachable \u2014 cannot compare against live deployments"]};if(t.length===0)return{needed:!0,reasons:["no live deployment exists for this task (never deployed, or all deleted)"]};if(e===null)return{needed:"unknown",reasons:["the local content hash could not be computed \u2014 the upload would be refused (run `ignitify task:pack` to see why)"]};let n=Mr(e),r=t.find(i=>Mr(i.content_hash??"")===n);if(r){let i=r.image_present===!1;return{needed:!1,reasons:[`local code is identical to deployment ${r.id??"?"} (content_hash dedup \u2014 deploy would return reused: true)`,...i?["note: its image is no longer in the store (archived by the GC) \u2014 a deploy would rebuild the image under the SAME deployment id"]:[]]}}let o=zt(t)[0];return{needed:!0,reasons:[`local content hash ${n.slice(0,12)}\u2026 matches no live deployment (latest: ${o?.id??"?"} @ ${o?.created_at??"?"}) \u2014 the code changed`]}},oS=(e,t,n,r,o)=>{if(r.needed===!0)return{needed:!0,reasons:["a new deployment is needed (above) \u2014 the warm pool is keyed by deployment_id, so the first runs after it always cold-boot"]};let i=Sa(e);if(i===null)return{needed:"unknown",reasons:["task.yaml execution block is invalid \u2014 run `ignitify task:validate` first"]};if(i.cardinality==="one"&&i.residency==="auto")return{needed:!0,reasons:["cardinality 'one' \u2192 one-shot lifecycle: every run boots a fresh VM and tears it down"]};if(o===null)return{needed:"unknown",reasons:["server unreachable \u2014 cannot compare against the last run"]};let a=zt(o)[0];if(!a)return{needed:!0,reasons:["no prior runs \u2014 the first run always cold-boots"]};if(n&&a.deployment_id&&a.deployment_id!==n)return{needed:!0,reasons:[`the last run used deployment ${a.deployment_id}, but the next run targets ${n} (state.json) \u2014 the warm pool is keyed by deployment_id, so no warm VM can match`]};let l=eS(a),c=tS(l,i,a.preset??void 0,t);return c.length>0?{needed:!0,reasons:[`boot fingerprint will differ from the last run: ${c.join(", ")}`,"a warm VM is sealed at boot \u2014 a fingerprint mismatch forces a cold boot (stale idles are evicted)",...c.some(u=>u.startsWith("residency "))?["residency changed: switching away from pinned leaves the old pinned VM standing (kill it with `ignitify vm:delete <vm-id> --force`)"]:[]]}:nS(a.preset,t??null)?{needed:"unknown",reasons:[`preset is explicit on one side only (last run: ${a.preset??"(omitted)"}, task.yaml: ${t??"(omitted)"}) \u2014 an omitted preset resolves to the SERVER's default, which the CLI cannot know offline`,"if the explicit value equals the server default the fingerprint matches (reuse); otherwise it differs (cold boot)"]}:{needed:!1,reasons:["config is unchanged since the last run \u2014 the boot fingerprint matches",i.residency==="pinned"?"residency pinned: the standby VM is reused as long as the pin lives (it is never reaper-evicted)":"a warm VM is reused IF one is still idle server-side (hot TTL / lifetime / pressure may have evicted it, or the pool may be disabled \u2014 then a cold boot happens); check `ignitify vm:list`","advisory: compared against the platform defaults \u2014 platform overrides could shift omitted axes"]}},iS=(e,t,n)=>{let r=Sa(e);if(r===null||r.network!=="bidirectional"||r.inbound_port===void 0)return null;let o=(n??[]).some(a=>pd.has(a.status??"")),i=t===null?"unknown":t.filter(a=>a.id).map(a=>({deploymentId:a.id,routeId:Nd(a.id)}));return{port:r.inbound_port,serving:o,routes:i}};function Uf(e){let{slug:t,deployments:n,runs:r,usage:o}=e,i=n===null?null:n.filter(h=>h.task_slug===t),a=h=>h.length>=e.pageLimit?` (first ${e.pageLimit} shown; more may exist)`:"",l=rS(e.localContentHash,i),c=oS(e.declared,e.declaredPreset,e.stateDeploymentId,l,r),u=i===null?{yes:"unknown",detail:e.stateDeploymentId?`server unreachable; .ignitify/state.json points at ${e.stateDeploymentId}`:"server unreachable; no local deployment pointer either"}:i.length>0?{yes:!0,detail:`${i.length} live deployment(s)${a(i)}${e.stateDeploymentId&&!i.some(h=>h.id===e.stateDeploymentId)?` \u2014 WARNING: state.json points at ${e.stateDeploymentId}, which is not among them (deleted?)`:""}`}:{yes:!1,detail:"no live deployments for this task"},p=i===null?"unknown":zt(i).map(h=>({id:h.id??"?",created_at:h.created_at??"?",status:h.status??"?",content_hash:Mr(h.content_hash??"").slice(0,12),image_bytes:h.image_bytes??0,detailCommand:`ignitify deployment:get ${h.id??"<id>"}`})),m=r===null?"unknown":{total:r.length,firstPageOnly:r.length>=e.pageLimit,byStatus:r.reduce((h,b)=>{let g=b.status??"?";return h[g]=(h[g]??0)+1,h},Object.create(null)),recent:zt(r).slice(0,5).map(h=>({id:h.id??"?",created_at:h.created_at??"?",status:h.status??"?",detailCommand:`ignitify run:get ${h.id??"<id>"}`})),listCommand:`ignitify run:list --task-name ${t}`};return{slug:t,deployed:u,resources:{taskImageBytes:i===null?"unknown":i.reduce((h,b)=>h+(b.image_bytes??0),0),tenant:o},deployments:p,runs:m,newDeployment:l,newVm:c,inbound:iS(e.declared,i,r)}}var Mf=e=>e.needed==="unknown"?"UNKNOWN":e.needed?"YES":"NO";function Ff(e){let t=[];if(t.push(`Task report: ${e.slug}`),t.push(""),t.push(`Deployed: ${e.deployed.yes==="unknown"?"UNKNOWN":e.deployed.yes?"YES":"NO"} \u2014 ${e.deployed.detail}`),t.push(""),t.push("Resources:"),t.push(` task images on disk: ${e.resources.taskImageBytes==="unknown"?"unknown (server unreachable)":we(e.resources.taskImageBytes)}`),e.resources.tenant){let n=e.resources.tenant;t.push(` tenant-wide (whoami): tasks ${n.task_count??"?"}, active runs ${n.active_runs??"?"}, deployments ${n.deployment_count??"?"}, images ${we(n.total_image_bytes??0)}, egress this month ${we(n.net_egress_bytes??0)}`),t.push(" more: ignitify quota")}if(t.push(""),t.push("Deployments:"),e.deployments==="unknown")t.push(" unknown (server unreachable)");else if(e.deployments.length===0)t.push(" (none)");else for(let n of e.deployments)t.push(` ${n.created_at} ${n.id} [${n.status}] hash ${n.content_hash}\u2026 ${we(n.image_bytes)}`),t.push(` detail: ${n.detailCommand}`);if(t.push(""),t.push("Runs:"),e.runs==="unknown")t.push(" unknown (server unreachable)");else{let n=Object.entries(e.runs.byStatus).map(([o,i])=>`${o} ${i}`).join(", "),r=e.runs.firstPageOnly?`first ${e.runs.total} shown (more may exist)`:`total ${e.runs.total}`;t.push(` ${r}${n?` (${n})`:""}`);for(let o of e.runs.recent)t.push(` ${o.created_at} ${o.id} [${o.status}]`),t.push(` detail: ${o.detailCommand}`);t.push(` list: ${e.runs.listCommand}`)}if(t.push(""),e.inbound){if(t.push("Inbound (secure HTTPS ingress):"),t.push(` listen port: ${e.inbound.port} \xB7 serving now: ${e.inbound.serving?"YES":"no"}`),e.inbound.routes==="unknown")t.push(" route-ids: unknown (server unreachable)");else if(e.inbound.routes.length===0)t.push(" route-ids: (none \u2014 no live deployment)");else{for(let n of e.inbound.routes)t.push(` ${n.deploymentId} \u2192 hostname ${n.routeId}--<tenant>.<base-domain>`);t.push(" (the <tenant> + <base-domain> come from the server; route-id is stable across redeploys)")}t.push("")}t.push(`New deployment needed: ${Mf(e.newDeployment)}`);for(let n of e.newDeployment.reasons)t.push(` - ${n}`);t.push(""),t.push(`New VM on next run: ${Mf(e.newVm)}`);for(let n of e.newVm.reasons)t.push(` - ${n}`);return t.join(`
1070
+ `)}f();var vo=ye(require("fs"),1),Io=ye(require("path"),1);f();var Ki=ye(require("node:fs"),1),Bi=ye(require("node:path"),1);f();f();function sS(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ce={},si={},tn={},jf;function Kr(){if(jf)return tn;jf=1;function e(a){return typeof a>"u"||a===null}function t(a){return typeof a=="object"&&a!==null}function n(a){return Array.isArray(a)?a:e(a)?[]:[a]}function r(a,l){if(l){let c=Object.keys(l);for(let u=0,p=c.length;u<p;u+=1){let m=c[u];a[m]=l[m]}}return a}function o(a,l){let c="";for(let u=0;u<l;u+=1)c+=a;return c}function i(a){return a===0&&Number.NEGATIVE_INFINITY===1/a}return tn.isNothing=e,tn.isObject=t,tn.toArray=n,tn.repeat=o,tn.isNegativeZero=i,tn.extend=r,tn}var ba,Gf;function Br(){if(Gf)return ba;Gf=1;function e(n,r){let o="",i=n.reason||"(unknown reason)";return n.mark?(n.mark.name&&(o+='in "'+n.mark.name+'" '),o+="("+(n.mark.line+1)+":"+(n.mark.column+1)+")",!r&&n.mark.snippet&&(o+=`
1071
+
1072
+ `+n.mark.snippet),i+" "+o):i}function t(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=e(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t.prototype.toString=function(r){return this.name+": "+e(this,r)},ba=t,ba}var Ta,Vf;function aS(){if(Vf)return Ta;Vf=1;let e=Kr();function t(o,i,a,l,c){let u="",p="",m=Math.floor(c/2)-1;return l-i>m&&(u=" ... ",i=l-m+u.length),a-l>m&&(p=" ...",a=l+m-p.length),{str:u+o.slice(i,a).replace(/\t/g,"\u2192")+p,pos:l-i+u.length}}function n(o,i){return e.repeat(" ",i-o.length)+o}function r(o,i){if(i=Object.create(i||null),!o.buffer)return null;i.maxLength||(i.maxLength=79),typeof i.indent!="number"&&(i.indent=1),typeof i.linesBefore!="number"&&(i.linesBefore=3),typeof i.linesAfter!="number"&&(i.linesAfter=2);let a=/\r?\n|\r|\0/g,l=[0],c=[],u,p=-1;for(;u=a.exec(o.buffer);)c.push(u.index),l.push(u.index+u[0].length),o.position<=u.index&&p<0&&(p=l.length-2);p<0&&(p=l.length-1);let m="",h=Math.min(o.line+i.linesAfter,c.length).toString().length,b=i.maxLength-(i.indent+h+3);for(let S=1;S<=i.linesBefore&&!(p-S<0);S++){let v=t(o.buffer,l[p-S],c[p-S],o.position-(l[p]-l[p-S]),b);m=e.repeat(" ",i.indent)+n((o.line-S+1).toString(),h)+" | "+v.str+`
1073
+ `+m}let g=t(o.buffer,l[p],c[p],o.position,b);m+=e.repeat(" ",i.indent)+n((o.line+1).toString(),h)+" | "+g.str+`
1074
+ `,m+=e.repeat("-",i.indent+h+3+g.pos)+`^
1075
+ `;for(let S=1;S<=i.linesAfter&&!(p+S>=c.length);S++){let v=t(o.buffer,l[p+S],c[p+S],o.position-(l[p]-l[p+S]),b);m+=e.repeat(" ",i.indent)+n((o.line+S+1).toString(),h)+" | "+v.str+`
1076
+ `}return m.replace(/\n$/,"")}return Ta=r,Ta}var Ra,Hf;function Fe(){if(Hf)return Ra;Hf=1;let e=Br(),t=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(i){let a={};return i!==null&&Object.keys(i).forEach(function(l){i[l].forEach(function(c){a[String(c)]=l})}),a}function o(i,a){if(a=a||{},Object.keys(a).forEach(function(l){if(t.indexOf(l)===-1)throw new e('Unknown option "'+l+'" is met in definition of "'+i+'" YAML type.')}),this.options=a,this.tag=i,this.kind=a.kind||null,this.resolve=a.resolve||function(){return!0},this.construct=a.construct||function(l){return l},this.instanceOf=a.instanceOf||null,this.predicate=a.predicate||null,this.represent=a.represent||null,this.representName=a.representName||null,this.defaultStyle=a.defaultStyle||null,this.multi=a.multi||!1,this.styleAliases=r(a.styleAliases||null),n.indexOf(this.kind)===-1)throw new e('Unknown kind "'+this.kind+'" is specified for "'+i+'" YAML type.')}return Ra=o,Ra}var Aa,qf;function dp(){if(qf)return Aa;qf=1;let e=Br(),t=Fe();function n(i,a){let l=[];return i[a].forEach(function(c){let u=l.length;l.forEach(function(p,m){p.tag===c.tag&&p.kind===c.kind&&p.multi===c.multi&&(u=m)}),l[u]=c}),l}function r(){let i={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function a(l){l.multi?(i.multi[l.kind].push(l),i.multi.fallback.push(l)):i[l.kind][l.tag]=i.fallback[l.tag]=l}for(let l=0,c=arguments.length;l<c;l+=1)arguments[l].forEach(a);return i}function o(i){return this.extend(i)}return o.prototype.extend=function(a){let l=[],c=[];if(a instanceof t)c.push(a);else if(Array.isArray(a))c=c.concat(a);else if(a&&(Array.isArray(a.implicit)||Array.isArray(a.explicit)))a.implicit&&(l=l.concat(a.implicit)),a.explicit&&(c=c.concat(a.explicit));else throw new e("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");l.forEach(function(p){if(!(p instanceof t))throw new e("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(p.loadKind&&p.loadKind!=="scalar")throw new e("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(p.multi)throw new e("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),c.forEach(function(p){if(!(p instanceof t))throw new e("Specified list of YAML types (or a single Type object) contains a non-Type object.")});let u=Object.create(o.prototype);return u.implicit=(this.implicit||[]).concat(l),u.explicit=(this.explicit||[]).concat(c),u.compiledImplicit=n(u,"implicit"),u.compiledExplicit=n(u,"explicit"),u.compiledTypeMap=r(u.compiledImplicit,u.compiledExplicit),u},Aa=o,Aa}var ka,Kf;function fp(){if(Kf)return ka;Kf=1;let e=Fe();return ka=new e("tag:yaml.org,2002:str",{kind:"scalar",construct:function(t){return t!==null?t:""}}),ka}var wa,Bf;function pp(){if(Bf)return wa;Bf=1;let e=Fe();return wa=new e("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(t){return t!==null?t:[]}}),wa}var va,Yf;function mp(){if(Yf)return va;Yf=1;let e=Fe();return va=new e("tag:yaml.org,2002:map",{kind:"mapping",construct:function(t){return t!==null?t:{}}}),va}var Ia,Wf;function hp(){if(Wf)return Ia;Wf=1;let e=dp();return Ia=new e({explicit:[fp(),pp(),mp()]}),Ia}var Na,zf;function gp(){if(zf)return Na;zf=1;let e=Fe();function t(o){if(o===null)return!0;let i=o.length;return i===1&&o==="~"||i===4&&(o==="null"||o==="Null"||o==="NULL")}function n(){return null}function r(o){return o===null}return Na=new e("tag:yaml.org,2002:null",{kind:"scalar",resolve:t,construct:n,predicate:r,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"}),Na}var $a,Xf;function yp(){if(Xf)return $a;Xf=1;let e=Fe();function t(o){if(o===null)return!1;let i=o.length;return i===4&&(o==="true"||o==="True"||o==="TRUE")||i===5&&(o==="false"||o==="False"||o==="FALSE")}function n(o){return o==="true"||o==="True"||o==="TRUE"}function r(o){return Object.prototype.toString.call(o)==="[object Boolean]"}return $a=new e("tag:yaml.org,2002:bool",{kind:"scalar",resolve:t,construct:n,predicate:r,represent:{lowercase:function(o){return o?"true":"false"},uppercase:function(o){return o?"TRUE":"FALSE"},camelcase:function(o){return o?"True":"False"}},defaultStyle:"lowercase"}),$a}var Oa,Jf;function _p(){if(Jf)return Oa;Jf=1;let e=Kr(),t=Fe();function n(u){return u>=48&&u<=57||u>=65&&u<=70||u>=97&&u<=102}function r(u){return u>=48&&u<=55}function o(u){return u>=48&&u<=57}function i(u){if(u===null)return!1;let p=u.length,m=0,h=!1;if(!p)return!1;let b=u[m];if((b==="-"||b==="+")&&(b=u[++m]),b==="0"){if(m+1===p)return!0;if(b=u[++m],b==="b"){for(m++;m<p;m++){if(b=u[m],b!=="0"&&b!=="1")return!1;h=!0}return h&&isFinite(a(u))}if(b==="x"){for(m++;m<p;m++){if(!n(u.charCodeAt(m)))return!1;h=!0}return h&&isFinite(a(u))}if(b==="o"){for(m++;m<p;m++){if(!r(u.charCodeAt(m)))return!1;h=!0}return h&&isFinite(a(u))}}for(;m<p;m++){if(!o(u.charCodeAt(m)))return!1;h=!0}return h?isFinite(a(u)):!1}function a(u){let p=u,m=1,h=p[0];if((h==="-"||h==="+")&&(h==="-"&&(m=-1),p=p.slice(1),h=p[0]),p==="0")return 0;if(h==="0"){if(p[1]==="b")return m*parseInt(p.slice(2),2);if(p[1]==="x")return m*parseInt(p.slice(2),16);if(p[1]==="o")return m*parseInt(p.slice(2),8)}return m*parseInt(p,10)}function l(u){return a(u)}function c(u){return Object.prototype.toString.call(u)==="[object Number]"&&u%1===0&&!e.isNegativeZero(u)}return Oa=new t("tag:yaml.org,2002:int",{kind:"scalar",resolve:i,construct:l,predicate:c,represent:{binary:function(u){return u>=0?"0b"+u.toString(2):"-0b"+u.toString(2).slice(1)},octal:function(u){return u>=0?"0o"+u.toString(8):"-0o"+u.toString(8).slice(1)},decimal:function(u){return u.toString(10)},hexadecimal:function(u){return u>=0?"0x"+u.toString(16).toUpperCase():"-0x"+u.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Oa}var xa,Qf;function Ep(){if(Qf)return xa;Qf=1;let e=Kr(),t=Fe(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function o(u){return u===null||!n.test(u)?!1:isFinite(parseFloat(u,10))?!0:r.test(u)}function i(u){let p=u.toLowerCase(),m=p[0]==="-"?-1:1;return"+-".indexOf(p[0])>=0&&(p=p.slice(1)),p===".inf"?m===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:p===".nan"?NaN:m*parseFloat(p,10)}let a=/^[-+]?[0-9]+e/;function l(u,p){if(isNaN(u))switch(p){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===u)switch(p){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===u)switch(p){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(e.isNegativeZero(u))return"-0.0";let m=u.toString(10);return a.test(m)?m.replace("e",".e"):m}function c(u){return Object.prototype.toString.call(u)==="[object Number]"&&(u%1!==0||e.isNegativeZero(u))}return xa=new t("tag:yaml.org,2002:float",{kind:"scalar",resolve:o,construct:i,predicate:c,represent:l,defaultStyle:"lowercase"}),xa}var Pa,Zf;function Sp(){return Zf||(Zf=1,Pa=hp().extend({implicit:[gp(),yp(),_p(),Ep()]})),Pa}var Ca,ep;function bp(){return ep||(ep=1,Ca=Sp()),Ca}var La,tp;function Tp(){if(tp)return La;tp=1;let e=Fe(),t=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(a){return a===null?!1:t.exec(a)!==null||n.exec(a)!==null}function o(a){let l=0,c=null,u=t.exec(a);if(u===null&&(u=n.exec(a)),u===null)throw new Error("Date resolve error");let p=+u[1],m=+u[2]-1,h=+u[3];if(!u[4])return new Date(Date.UTC(p,m,h));let b=+u[4],g=+u[5],S=+u[6];if(u[7]){for(l=u[7].slice(0,3);l.length<3;)l+="0";l=+l}if(u[9]){let R=+u[10],P=+(u[11]||0);c=(R*60+P)*6e4,u[9]==="-"&&(c=-c)}let v=new Date(Date.UTC(p,m,h,b,g,S,l));return c&&v.setTime(v.getTime()-c),v}function i(a){return a.toISOString()}return La=new e("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:o,instanceOf:Date,represent:i}),La}var Da,np;function Rp(){if(np)return Da;np=1;let e=Fe();function t(n){return n==="<<"||n===null}return Da=new e("tag:yaml.org,2002:merge",{kind:"scalar",resolve:t}),Da}var Ma,rp;function Ap(){if(rp)return Ma;rp=1;let e=Fe(),t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
1077
+ \r`;function n(a){if(a===null)return!1;let l=0,c=a.length,u=t;for(let p=0;p<c;p++){let m=u.indexOf(a.charAt(p));if(!(m>64)){if(m<0)return!1;l+=6}}return l%8===0}function r(a){let l=a.replace(/[\r\n=]/g,""),c=l.length,u=t,p=0,m=[];for(let b=0;b<c;b++)b%4===0&&b&&(m.push(p>>16&255),m.push(p>>8&255),m.push(p&255)),p=p<<6|u.indexOf(l.charAt(b));let h=c%4*6;return h===0?(m.push(p>>16&255),m.push(p>>8&255),m.push(p&255)):h===18?(m.push(p>>10&255),m.push(p>>2&255)):h===12&&m.push(p>>4&255),new Uint8Array(m)}function o(a){let l="",c=0,u=a.length,p=t;for(let h=0;h<u;h++)h%3===0&&h&&(l+=p[c>>18&63],l+=p[c>>12&63],l+=p[c>>6&63],l+=p[c&63]),c=(c<<8)+a[h];let m=u%3;return m===0?(l+=p[c>>18&63],l+=p[c>>12&63],l+=p[c>>6&63],l+=p[c&63]):m===2?(l+=p[c>>10&63],l+=p[c>>4&63],l+=p[c<<2&63],l+=p[64]):m===1&&(l+=p[c>>2&63],l+=p[c<<4&63],l+=p[64],l+=p[64]),l}function i(a){return Object.prototype.toString.call(a)==="[object Uint8Array]"}return Ma=new e("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:i,represent:o}),Ma}var Ua,op;function kp(){if(op)return Ua;op=1;let e=Fe(),t=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(i){if(i===null)return!0;let a={},l=i;for(let c=0,u=l.length;c<u;c+=1){let p=l[c],m=!1;if(n.call(p)!=="[object Object]")return!1;let h;for(h in p)if(t.call(p,h))if(!m)m=!0;else return!1;if(!m||t.call(a,h))return!1;Object.defineProperty(a,h,{value:!0})}return!0}function o(i){return i!==null?i:[]}return Ua=new e("tag:yaml.org,2002:omap",{kind:"sequence",resolve:r,construct:o}),Ua}var Fa,ip;function wp(){if(ip)return Fa;ip=1;let e=Fe(),t=Object.prototype.toString;function n(o){if(o===null)return!0;let i=o,a=new Array(i.length);for(let l=0,c=i.length;l<c;l+=1){let u=i[l];if(t.call(u)!=="[object Object]")return!1;let p=Object.keys(u);if(p.length!==1)return!1;a[l]=[p[0],u[p[0]]]}return!0}function r(o){if(o===null)return[];let i=o,a=new Array(i.length);for(let l=0,c=i.length;l<c;l+=1){let u=i[l],p=Object.keys(u);a[l]=[p[0],u[p[0]]]}return a}return Fa=new e("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:n,construct:r}),Fa}var ja,sp;function vp(){if(sp)return ja;sp=1;let e=Fe(),t=Object.prototype.hasOwnProperty;function n(o){if(o===null)return!0;let i=o;for(let a in i)if(t.call(i,a)&&i[a]!==null)return!1;return!0}function r(o){return o!==null?o:{}}return ja=new e("tag:yaml.org,2002:set",{kind:"mapping",resolve:n,construct:r}),ja}var Ga,ap;function Ha(){return ap||(ap=1,Ga=bp().extend({implicit:[Tp(),Rp()],explicit:[Ap(),kp(),wp(),vp()]})),Ga}var lp;function lS(){if(lp)return si;lp=1;let e=Kr(),t=Br(),n=aS(),r=Ha(),o=Object.prototype.hasOwnProperty,i=1,a=2,l=3,c=4,u=1,p=2,m=3,h=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,b=/[\x85\u2028\u2029]/,g=/[,\[\]{}]/,S=/^(?:!|!!|![0-9A-Za-z-]+!)$/,v=/^(?:!|[^,\[\]{}])(?:%[0-9a-f]{2}|[0-9a-z\-#;/?:@&=+$,_.!~*'()\[\]])*$/i;function R(s){return Object.prototype.toString.call(s)}function P(s){return s===10||s===13}function M(s){return s===9||s===32}function H(s){return s===9||s===32||s===10||s===13}function G(s){return s===44||s===91||s===93||s===123||s===125}function ge(s){if(s>=48&&s<=57)return s-48;let _=s|32;return _>=97&&_<=102?_-97+10:-1}function Oe(s){return s===120?2:s===117?4:s===85?8:0}function et(s){return s>=48&&s<=57?s-48:-1}function Rt(s){switch(s){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return`
1078
+ `;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"\x85";case 95:return"\xA0";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function At(s){return s<=65535?String.fromCharCode(s):String.fromCharCode((s-65536>>10)+55296,(s-65536&1023)+56320)}function kt(s,_,I){_==="__proto__"?Object.defineProperty(s,_,{configurable:!0,enumerable:!0,writable:!0,value:I}):s[_]=I}let dn=new Array(256),Mt=new Array(256);for(let s=0;s<256;s++)dn[s]=Rt(s)?1:0,Mt[s]=Rt(s);function ke(s,_){this.input=s,this.filename=_.filename||null,this.schema=_.schema||r,this.onWarning=_.onWarning||null,this.legacy=_.legacy||!1,this.json=_.json||!1,this.listener=_.listener||null,this.maxDepth=typeof _.maxDepth=="number"?_.maxDepth:100,this.maxTotalMergeKeys=typeof _.maxTotalMergeKeys=="number"?_.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=s.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function Po(s,_){let I={name:s.filename,buffer:s.input.slice(0,-1),position:s.position,line:s.line,column:s.position-s.lineStart};return I.snippet=n(I),new t(_,I)}function F(s,_){throw Po(s,_)}function Dn(s,_){s.onWarning&&s.onWarning.call(null,Po(s,_))}function wt(s,_,I){let N=s.anchorMapTransactions;if(N.length!==0){let A=N[N.length-1];o.call(A,_)||(A[_]={existed:o.call(s.anchorMap,_),value:s.anchorMap[_]})}s.anchorMap[_]=I}function ns(s){s.anchorMapTransactions.push(Object.create(null))}function fn(s){let _=s.anchorMapTransactions.pop(),I=s.anchorMapTransactions;if(I.length===0)return;let N=I[I.length-1],A=Object.keys(_);for(let d=0,E=A.length;d<E;d+=1){let T=A[d];o.call(N,T)||(N[T]=_[T])}}function rs(s){let _=s.anchorMapTransactions.pop(),I=Object.keys(_);for(let N=I.length-1;N>=0;N-=1){let A=_[I[N]];A.existed?s.anchorMap[I[N]]=A.value:delete s.anchorMap[I[N]]}}function _r(s){return{position:s.position,line:s.line,lineStart:s.lineStart,lineIndent:s.lineIndent,firstTabInLine:s.firstTabInLine,tag:s.tag,anchor:s.anchor,kind:s.kind,result:s.result}}function Mn(s,_){s.position=_.position,s.line=_.line,s.lineStart=_.lineStart,s.lineIndent=_.lineIndent,s.firstTabInLine=_.firstTabInLine,s.tag=_.tag,s.anchor=_.anchor,s.kind=_.kind,s.result=_.result}let Co={YAML:function(_,I,N){_.version!==null&&F(_,"duplication of %YAML directive"),N.length!==1&&F(_,"YAML directive accepts exactly one argument");let A=/^([0-9]+)\.([0-9]+)$/.exec(N[0]);A===null&&F(_,"ill-formed argument of the YAML directive");let d=parseInt(A[1],10),E=parseInt(A[2],10);d!==1&&F(_,"unacceptable YAML version of the document"),_.version=N[0],_.checkLineBreaks=E<2,E!==1&&E!==2&&Dn(_,"unsupported YAML version of the document")},TAG:function(_,I,N){let A;N.length!==2&&F(_,"TAG directive accepts exactly two arguments");let d=N[0];A=N[1],S.test(d)||F(_,"ill-formed tag handle (first argument) of the TAG directive"),o.call(_.tagMap,d)&&F(_,'there is a previously declared suffix for "'+d+'" tag handle'),v.test(A)||F(_,"ill-formed tag prefix (second argument) of the TAG directive");try{A=decodeURIComponent(A)}catch{F(_,"tag prefix is malformed: "+A)}_.tagMap[d]=A}};function Je(s,_,I,N){if(_<I){let A=s.input.slice(_,I);if(N)for(let d=0,E=A.length;d<E;d+=1){let T=A.charCodeAt(d);T===9||T>=32&&T<=1114111||F(s,"expected valid JSON character")}else h.test(A)&&F(s,"the stream contains non-printable characters");s.result+=A}}function Ut(s){s.totalMergeKeys++,s.maxTotalMergeKeys!==-1&&s.totalMergeKeys>s.maxTotalMergeKeys&&F(s,"merge keys exceeded maxTotalMergeKeys ("+s.maxTotalMergeKeys+")")}function Er(s,_,I,N){e.isObject(I)||F(s,"cannot merge mappings; the provided source object is unacceptable"),Ut(s);let A=Object.keys(I);for(let d=0,E=A.length;d<E;d+=1){let T=A[d];Ut(s),o.call(_,T)||(kt(_,T,I[T]),N[T]=!0)}}function vt(s,_,I,N,A,d,E,T,$){if(Array.isArray(A)){A=Array.prototype.slice.call(A);for(let O=0,x=A.length;O<x;O+=1)Array.isArray(A[O])&&F(s,"nested arrays are not supported inside keys"),typeof A=="object"&&R(A[O])==="[object Object]"&&(A[O]="[object Object]")}if(typeof A=="object"&&R(A)==="[object Object]"&&(A="[object Object]"),A=String(A),_===null&&(_={}),N==="tag:yaml.org,2002:merge")if(Array.isArray(d)){d.length>100&&F(s,"abnormal merge sequence size");for(let O=0,x=d.length;O<x;O+=1)Er(s,_,d[O],I)}else Er(s,_,d,I);else!s.json&&!o.call(I,A)&&o.call(_,A)&&(s.line=E||s.line,s.lineStart=T||s.lineStart,s.position=$||s.position,F(s,"duplicated mapping key")),kt(_,A,d),delete I[A];return _}function Sr(s){let _=s.input.charCodeAt(s.position);_===10?s.position++:_===13?(s.position++,s.input.charCodeAt(s.position)===10&&s.position++):F(s,"a line break is expected"),s.line+=1,s.lineStart=s.position,s.firstTabInLine=-1}function Te(s,_,I){let N=0,A=s.input.charCodeAt(s.position);for(;A!==0;){for(;M(A);)A===9&&s.firstTabInLine===-1&&(s.firstTabInLine=s.position),A=s.input.charCodeAt(++s.position);if(_&&A===35)do A=s.input.charCodeAt(++s.position);while(A!==10&&A!==13&&A!==0);if(P(A))for(Sr(s),A=s.input.charCodeAt(s.position),N++,s.lineIndent=0;A===32;)s.lineIndent++,A=s.input.charCodeAt(++s.position);else break}return I!==-1&&N!==0&&s.lineIndent<I&&Dn(s,"deficient indentation"),N}function _t(s){let _=s.position,I=s.input.charCodeAt(_);return!!((I===45||I===46)&&I===s.input.charCodeAt(_+1)&&I===s.input.charCodeAt(_+2)&&(_+=3,I=s.input.charCodeAt(_),I===0||H(I)))}function Un(s,_){_===1?s.result+=" ":_>1&&(s.result+=e.repeat(`
1079
+ `,_-1))}function Lo(s,_,I){let N,A,d,E,T,$,O=s.kind,x=s.result,w=s.input.charCodeAt(s.position);if(H(w)||G(w)||w===35||w===38||w===42||w===33||w===124||w===62||w===39||w===34||w===37||w===64||w===96)return!1;if(w===63||w===45){let L=s.input.charCodeAt(s.position+1);if(H(L)||I&&G(L))return!1}for(s.kind="scalar",s.result="",N=A=s.position,d=!1;w!==0;){if(w===58){let L=s.input.charCodeAt(s.position+1);if(H(L)||I&&G(L))break}else if(w===35){let L=s.input.charCodeAt(s.position-1);if(H(L))break}else{if(s.position===s.lineStart&&_t(s)||I&&G(w))break;if(P(w))if(E=s.line,T=s.lineStart,$=s.lineIndent,Te(s,!1,-1),s.lineIndent>=_){d=!0,w=s.input.charCodeAt(s.position);continue}else{s.position=A,s.line=E,s.lineStart=T,s.lineIndent=$;break}}d&&(Je(s,N,A,!1),Un(s,s.line-E),N=A=s.position,d=!1),M(w)||(A=s.position+1),w=s.input.charCodeAt(++s.position)}return Je(s,N,A,!1),s.result?!0:(s.kind=O,s.result=x,!1)}function br(s,_){let I,N,A=s.input.charCodeAt(s.position);if(A!==39)return!1;for(s.kind="scalar",s.result="",s.position++,I=N=s.position;(A=s.input.charCodeAt(s.position))!==0;)if(A===39)if(Je(s,I,s.position,!0),A=s.input.charCodeAt(++s.position),A===39)I=s.position,s.position++,N=s.position;else return!0;else P(A)?(Je(s,I,N,!0),Un(s,Te(s,!1,_)),I=N=s.position):s.position===s.lineStart&&_t(s)?F(s,"unexpected end of the document within a single quoted scalar"):(s.position++,M(A)||(N=s.position));F(s,"unexpected end of the stream within a single quoted scalar")}function Do(s,_){let I,N,A,d=s.input.charCodeAt(s.position);if(d!==34)return!1;for(s.kind="scalar",s.result="",s.position++,I=N=s.position;(d=s.input.charCodeAt(s.position))!==0;){if(d===34)return Je(s,I,s.position,!0),s.position++,!0;if(d===92){if(Je(s,I,s.position,!0),d=s.input.charCodeAt(++s.position),P(d))Te(s,!1,_);else if(d<256&&dn[d])s.result+=Mt[d],s.position++;else if((A=Oe(d))>0){let E=A,T=0;for(;E>0;E--)d=s.input.charCodeAt(++s.position),(A=ge(d))>=0?T=(T<<4)+A:F(s,"expected hexadecimal character");s.result+=At(T),s.position++}else F(s,"unknown escape sequence");I=N=s.position}else P(d)?(Je(s,I,N,!0),Un(s,Te(s,!1,_)),I=N=s.position):s.position===s.lineStart&&_t(s)?F(s,"unexpected end of the document within a double quoted scalar"):(s.position++,M(d)||(N=s.position))}F(s,"unexpected end of the stream within a double quoted scalar")}function Mo(s,_){let I=!0,N,A,d,E=s.tag,T,$=s.anchor,O,x,w,L,U=Object.create(null),q,K,W,te=s.input.charCodeAt(s.position);if(te===91)O=93,L=!1,T=[];else if(te===123)O=125,L=!0,T={};else return!1;for(s.anchor!==null&&wt(s,s.anchor,T),te=s.input.charCodeAt(++s.position);te!==0;){if(Te(s,!0,_),te=s.input.charCodeAt(s.position),te===O)return s.position++,s.tag=E,s.anchor=$,s.kind=L?"mapping":"sequence",s.result=T,!0;if(I?te===44&&F(s,"expected the node content, but found ','"):F(s,"missed comma between flow collection entries"),K=q=W=null,x=w=!1,te===63){let Gt=s.input.charCodeAt(s.position+1);H(Gt)&&(x=w=!0,s.position++,Te(s,!0,_))}N=s.line,A=s.lineStart,d=s.position,jt(s,_,i,!1,!0),K=s.tag,q=s.result,Te(s,!0,_),te=s.input.charCodeAt(s.position),(w||s.line===N)&&te===58&&(x=!0,te=s.input.charCodeAt(++s.position),Te(s,!0,_),jt(s,_,i,!1,!0),W=s.result),L?vt(s,T,U,K,q,W,N,A,d):x?T.push(vt(s,null,U,K,q,W,N,A,d)):T.push(q),Te(s,!0,_),te=s.input.charCodeAt(s.position),te===44?(I=!0,te=s.input.charCodeAt(++s.position)):I=!1}F(s,"unexpected end of the stream within a flow collection")}function Ft(s,_){let I,N=u,A=!1,d=!1,E=_,T=0,$=!1,O,x=s.input.charCodeAt(s.position);if(x===124)I=!1;else if(x===62)I=!0;else return!1;for(s.kind="scalar",s.result="";x!==0;)if(x=s.input.charCodeAt(++s.position),x===43||x===45)u===N?N=x===43?m:p:F(s,"repeat of a chomping mode identifier");else if((O=et(x))>=0)O===0?F(s,"bad explicit indentation width of a block scalar; it cannot be less than one"):d?F(s,"repeat of an indentation width identifier"):(E=_+O-1,d=!0);else break;if(M(x)){do x=s.input.charCodeAt(++s.position);while(M(x));if(x===35)do x=s.input.charCodeAt(++s.position);while(!P(x)&&x!==0)}for(;x!==0;){for(Sr(s),s.lineIndent=0,x=s.input.charCodeAt(s.position);(!d||s.lineIndent<E)&&x===32;)s.lineIndent++,x=s.input.charCodeAt(++s.position);if(!d&&s.lineIndent>E&&(E=s.lineIndent),P(x)){T++;continue}if(!d&&E===0&&F(s,"missing indentation for block scalar"),s.lineIndent<E){N===m?s.result+=e.repeat(`
1080
+ `,A?1+T:T):N===u&&A&&(s.result+=`
1081
+ `);break}I?M(x)?($=!0,s.result+=e.repeat(`
1082
+ `,A?1+T:T)):$?($=!1,s.result+=e.repeat(`
1083
+ `,T+1)):T===0?A&&(s.result+=" "):s.result+=e.repeat(`
1084
+ `,T):s.result+=e.repeat(`
1085
+ `,A?1+T:T),A=!0,d=!0,T=0;let w=s.position;for(;!P(x)&&x!==0;)x=s.input.charCodeAt(++s.position);Je(s,w,s.position,!1)}return!0}function Uo(s,_){let I=s.tag,N=s.anchor,A=[],d=!1;if(s.firstTabInLine!==-1)return!1;s.anchor!==null&&wt(s,s.anchor,A);let E=s.input.charCodeAt(s.position);for(;E!==0&&(s.firstTabInLine!==-1&&(s.position=s.firstTabInLine,F(s,"tab characters must not be used in indentation")),E===45);){let T=s.input.charCodeAt(s.position+1);if(!H(T))break;if(d=!0,s.position++,Te(s,!0,-1)&&s.lineIndent<=_){A.push(null),E=s.input.charCodeAt(s.position);continue}let $=s.line;if(jt(s,_,l,!1,!0),A.push(s.result),Te(s,!0,-1),E=s.input.charCodeAt(s.position),(s.line===$||s.lineIndent>_)&&E!==0)F(s,"bad indentation of a sequence entry");else if(s.lineIndent<_)break}return d?(s.tag=I,s.anchor=N,s.kind="sequence",s.result=A,!0):!1}function Fo(s,_,I){let N,A,d,E,T=s.tag,$=s.anchor,O={},x=Object.create(null),w=null,L=null,U=null,q=!1,K=!1;if(s.firstTabInLine!==-1)return!1;s.anchor!==null&&wt(s,s.anchor,O);let W=s.input.charCodeAt(s.position);for(;W!==0;){!q&&s.firstTabInLine!==-1&&(s.position=s.firstTabInLine,F(s,"tab characters must not be used in indentation"));let te=s.input.charCodeAt(s.position+1),Gt=s.line;if((W===63||W===58)&&H(te))W===63?(q&&(vt(s,O,x,w,L,null,A,d,E),w=L=U=null),K=!0,q=!0,N=!0):q?(q=!1,N=!0):F(s,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),s.position+=1,W=te;else{if(A=s.line,d=s.lineStart,E=s.position,!jt(s,I,a,!1,!0))break;if(s.line===Gt){for(W=s.input.charCodeAt(s.position);M(W);)W=s.input.charCodeAt(++s.position);if(W===58)W=s.input.charCodeAt(++s.position),H(W)||F(s,"a whitespace character is expected after the key-value separator within a block mapping"),q&&(vt(s,O,x,w,L,null,A,d,E),w=L=U=null),K=!0,q=!1,N=!1,w=s.tag,L=s.result;else if(K)F(s,"can not read an implicit mapping pair; a colon is missed");else return s.tag=T,s.anchor=$,!0}else if(K)F(s,"can not read a block mapping entry; a multiline key may not be an implicit key");else return s.tag=T,s.anchor=$,!0}if((s.line===Gt||s.lineIndent>_)&&(q&&(A=s.line,d=s.lineStart,E=s.position),jt(s,_,c,!0,N)&&(q?L=s.result:U=s.result),q||(vt(s,O,x,w,L,U,A,d,E),w=L=U=null),Te(s,!0,-1),W=s.input.charCodeAt(s.position)),(s.line===Gt||s.lineIndent>_)&&W!==0)F(s,"bad indentation of a mapping entry");else if(s.lineIndent<_)break}return q&&vt(s,O,x,w,L,null,A,d,E),K&&(s.tag=T,s.anchor=$,s.kind="mapping",s.result=O),K}function jo(s){let _=!1,I=!1,N,A,d=s.input.charCodeAt(s.position);if(d!==33)return!1;s.tag!==null&&F(s,"duplication of a tag property"),d=s.input.charCodeAt(++s.position),d===60?(_=!0,d=s.input.charCodeAt(++s.position)):d===33?(I=!0,N="!!",d=s.input.charCodeAt(++s.position)):N="!";let E=s.position;if(_){do d=s.input.charCodeAt(++s.position);while(d!==0&&d!==62);s.position<s.length?(A=s.input.slice(E,s.position),d=s.input.charCodeAt(++s.position)):F(s,"unexpected end of the stream within a verbatim tag")}else{for(;d!==0&&!H(d);)d===33&&(I?F(s,"tag suffix cannot contain exclamation marks"):(N=s.input.slice(E-1,s.position+1),S.test(N)||F(s,"named tag handle cannot contain such characters"),I=!0,E=s.position+1)),d=s.input.charCodeAt(++s.position);A=s.input.slice(E,s.position),g.test(A)&&F(s,"tag suffix cannot contain flow indicator characters")}A&&!v.test(A)&&F(s,"tag name cannot contain such characters: "+A);try{A=decodeURIComponent(A)}catch{F(s,"tag name is malformed: "+A)}return _?s.tag=A:o.call(s.tagMap,N)?s.tag=s.tagMap[N]+A:N==="!"?s.tag="!"+A:N==="!!"?s.tag="tag:yaml.org,2002:"+A:F(s,'undeclared tag handle "'+N+'"'),!0}function Go(s){let _=s.input.charCodeAt(s.position);if(_!==38)return!1;s.anchor!==null&&F(s,"duplication of an anchor property"),_=s.input.charCodeAt(++s.position);let I=s.position;for(;_!==0&&!H(_)&&!G(_);)_=s.input.charCodeAt(++s.position);return s.position===I&&F(s,"name of an anchor node must contain at least one character"),s.anchor=s.input.slice(I,s.position),!0}function os(s){let _=s.input.charCodeAt(s.position);if(_!==42)return!1;_=s.input.charCodeAt(++s.position);let I=s.position;for(;_!==0&&!H(_)&&!G(_);)_=s.input.charCodeAt(++s.position);s.position===I&&F(s,"name of an alias node must contain at least one character");let N=s.input.slice(I,s.position);return o.call(s.anchorMap,N)||F(s,'unidentified alias "'+N+'"'),s.result=s.anchorMap[N],Te(s,!0,-1),!0}function Vo(s,_,I,N){let A=_r(s);return ns(s),Mn(s,_),s.tag=null,s.anchor=null,s.kind=null,s.result=null,Fo(s,I,N)&&s.kind==="mapping"?(fn(s),!0):(rs(s),Mn(s,A),!1)}function jt(s,_,I,N,A){let d,E,T=1,$=!1,O=!1,x=null,w,L,U;s.depth>=s.maxDepth&&F(s,"nesting exceeded maxDepth ("+s.maxDepth+")"),s.depth+=1,s.listener!==null&&s.listener("open",s),s.tag=null,s.anchor=null,s.kind=null,s.result=null;let q=d=E=c===I||l===I;if(N&&Te(s,!0,-1)&&($=!0,s.lineIndent>_?T=1:s.lineIndent===_?T=0:s.lineIndent<_&&(T=-1)),T===1)for(;;){let K=s.input.charCodeAt(s.position),W=_r(s);if($&&(K===33&&s.tag!==null||K===38&&s.anchor!==null)||!jo(s)&&!Go(s))break;x===null&&(x=W),Te(s,!0,-1)?($=!0,E=q,s.lineIndent>_?T=1:s.lineIndent===_?T=0:s.lineIndent<_&&(T=-1)):E=!1}if(E&&(E=$||A),T===1||c===I)if(i===I||a===I?L=_:L=_+1,U=s.position-s.lineStart,T===1)if(E&&(Uo(s,U)||Fo(s,U,L))||Mo(s,L))O=!0;else{let K=s.input.charCodeAt(s.position);x!==null&&q&&!E&&K!==124&&K!==62&&Vo(s,x,x.position-x.lineStart,L)||d&&Ft(s,L)||br(s,L)||Do(s,L)?O=!0:os(s)?(O=!0,(s.tag!==null||s.anchor!==null)&&F(s,"alias node should not have any properties")):Lo(s,L,i===I)&&(O=!0,s.tag===null&&(s.tag="?")),s.anchor!==null&&wt(s,s.anchor,s.result)}else T===0&&(O=E&&Uo(s,U));if(s.tag===null)s.anchor!==null&&wt(s,s.anchor,s.result);else if(s.tag==="?"){s.result!==null&&s.kind!=="scalar"&&F(s,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+s.kind+'"');for(let K=0,W=s.implicitTypes.length;K<W;K+=1)if(w=s.implicitTypes[K],w.resolve(s.result)){s.result=w.construct(s.result),s.tag=w.tag,s.anchor!==null&&wt(s,s.anchor,s.result);break}}else if(s.tag!=="!"){if(o.call(s.typeMap[s.kind||"fallback"],s.tag))w=s.typeMap[s.kind||"fallback"][s.tag];else{w=null;let K=s.typeMap.multi[s.kind||"fallback"];for(let W=0,te=K.length;W<te;W+=1)if(s.tag.slice(0,K[W].tag.length)===K[W].tag){w=K[W];break}}w||F(s,"unknown tag !<"+s.tag+">"),s.result!==null&&w.kind!==s.kind&&F(s,"unacceptable node kind for !<"+s.tag+'> tag; it should be "'+w.kind+'", not "'+s.kind+'"'),w.resolve(s.result,s.tag)?(s.result=w.construct(s.result,s.tag),s.anchor!==null&&wt(s,s.anchor,s.result)):F(s,"cannot resolve a node with !<"+s.tag+"> explicit tag")}return s.listener!==null&&s.listener("close",s),s.depth-=1,s.tag!==null||s.anchor!==null||O}function is(s){let _=s.position,I=!1,N;for(s.version=null,s.checkLineBreaks=s.legacy,s.tagMap=Object.create(null),s.anchorMap=Object.create(null);(N=s.input.charCodeAt(s.position))!==0&&(Te(s,!0,-1),N=s.input.charCodeAt(s.position),!(s.lineIndent>0||N!==37));){I=!0,N=s.input.charCodeAt(++s.position);let A=s.position;for(;N!==0&&!H(N);)N=s.input.charCodeAt(++s.position);let d=s.input.slice(A,s.position),E=[];for(d.length<1&&F(s,"directive name must not be less than one character in length");N!==0;){for(;M(N);)N=s.input.charCodeAt(++s.position);if(N===35){do N=s.input.charCodeAt(++s.position);while(N!==0&&!P(N));break}if(P(N))break;for(A=s.position;N!==0&&!H(N);)N=s.input.charCodeAt(++s.position);E.push(s.input.slice(A,s.position))}N!==0&&Sr(s),o.call(Co,d)?Co[d](s,d,E):Dn(s,'unknown document directive "'+d+'"')}if(Te(s,!0,-1),s.lineIndent===0&&s.input.charCodeAt(s.position)===45&&s.input.charCodeAt(s.position+1)===45&&s.input.charCodeAt(s.position+2)===45?(s.position+=3,Te(s,!0,-1)):I&&F(s,"directives end mark is expected"),jt(s,s.lineIndent-1,c,!1,!0),Te(s,!0,-1),s.checkLineBreaks&&b.test(s.input.slice(_,s.position))&&Dn(s,"non-ASCII line breaks are interpreted as content"),s.documents.push(s.result),s.position===s.lineStart&&_t(s)){s.input.charCodeAt(s.position)===46&&(s.position+=3,Te(s,!0,-1));return}s.position<s.length-1&&F(s,"end of the stream or a document separator is expected")}function Tr(s,_){s=String(s),_=_||{},s.length!==0&&(s.charCodeAt(s.length-1)!==10&&s.charCodeAt(s.length-1)!==13&&(s+=`
1086
+ `),s.charCodeAt(0)===65279&&(s=s.slice(1)));let I=new ke(s,_),N=s.indexOf("\0");for(N!==-1&&(I.position=N,F(I,"null byte is not allowed in input")),I.input+="\0";I.input.charCodeAt(I.position)===32;)I.lineIndent+=1,I.position+=1;for(;I.position<I.length-1;)is(I);return I.documents}function ss(s,_,I){_!==null&&typeof _=="object"&&typeof I>"u"&&(I=_,_=null);let N=Tr(s,I);if(typeof _!="function")return N;for(let A=0,d=N.length;A<d;A+=1)_(N[A])}function as(s,_){let I=Tr(s,_);if(I.length!==0){if(I.length===1)return I[0];throw new t("expected a single document in the stream, but found more")}}return si.loadAll=ss,si.load=as,si}var Va={},cp;function cS(){if(cp)return Va;cp=1;let e=Kr(),t=Br(),n=Ha(),r=Object.prototype.toString,o=Object.prototype.hasOwnProperty,i=65279,a=9,l=10,c=13,u=32,p=33,m=34,h=35,b=37,g=38,S=39,v=42,R=44,P=45,M=58,H=61,G=62,ge=63,Oe=64,et=91,Rt=93,At=96,kt=123,dn=124,Mt=125,ke={};ke[0]="\\0",ke[7]="\\a",ke[8]="\\b",ke[9]="\\t",ke[10]="\\n",ke[11]="\\v",ke[12]="\\f",ke[13]="\\r",ke[27]="\\e",ke[34]='\\"',ke[92]="\\\\",ke[133]="\\N",ke[160]="\\_",ke[8232]="\\L",ke[8233]="\\P";let Po=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],F=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Dn(d,E){if(E===null)return{};let T={},$=Object.keys(E);for(let O=0,x=$.length;O<x;O+=1){let w=$[O],L=String(E[w]);w.slice(0,2)==="!!"&&(w="tag:yaml.org,2002:"+w.slice(2));let U=d.compiledTypeMap.fallback[w];U&&o.call(U.styleAliases,L)&&(L=U.styleAliases[L]),T[w]=L}return T}function wt(d){let E,T,$=d.toString(16).toUpperCase();if(d<=255)E="x",T=2;else if(d<=65535)E="u",T=4;else if(d<=4294967295)E="U",T=8;else throw new t("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+E+e.repeat("0",T-$.length)+$}let ns=1,fn=2;function rs(d){this.schema=d.schema||n,this.indent=Math.max(1,d.indent||2),this.noArrayIndent=d.noArrayIndent||!1,this.skipInvalid=d.skipInvalid||!1,this.flowLevel=e.isNothing(d.flowLevel)?-1:d.flowLevel,this.styleMap=Dn(this.schema,d.styles||null),this.sortKeys=d.sortKeys||!1,this.lineWidth=d.lineWidth||80,this.noRefs=d.noRefs||!1,this.noCompatMode=d.noCompatMode||!1,this.condenseFlow=d.condenseFlow||!1,this.quotingType=d.quotingType==='"'?fn:ns,this.forceQuotes=d.forceQuotes||!1,this.replacer=typeof d.replacer=="function"?d.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function _r(d,E){let T=e.repeat(" ",E),$=0,O="",x=d.length;for(;$<x;){let w,L=d.indexOf(`
1087
+ `,$);L===-1?(w=d.slice($),$=x):(w=d.slice($,L+1),$=L+1),w.length&&w!==`
1088
+ `&&(O+=T),O+=w}return O}function Mn(d,E){return`
1089
+ `+e.repeat(" ",d.indent*E)}function Co(d,E){for(let T=0,$=d.implicitTypes.length;T<$;T+=1)if(d.implicitTypes[T].resolve(E))return!0;return!1}function Je(d){return d===u||d===a}function Ut(d){return d>=32&&d<=126||d>=161&&d<=55295&&d!==8232&&d!==8233||d>=57344&&d<=65533&&d!==i||d>=65536&&d<=1114111}function Er(d){return Ut(d)&&d!==i&&d!==c&&d!==l}function vt(d,E,T){let $=Er(d),O=$&&!Je(d);return(T?$:$&&d!==R&&d!==et&&d!==Rt&&d!==kt&&d!==Mt)&&d!==h&&!(E===M&&!O)||Er(E)&&!Je(E)&&d===h||E===M&&O}function Sr(d){return Ut(d)&&d!==i&&!Je(d)&&d!==P&&d!==ge&&d!==M&&d!==R&&d!==et&&d!==Rt&&d!==kt&&d!==Mt&&d!==h&&d!==g&&d!==v&&d!==p&&d!==dn&&d!==H&&d!==G&&d!==S&&d!==m&&d!==b&&d!==Oe&&d!==At}function Te(d){return!Je(d)&&d!==M}function _t(d,E){let T=d.charCodeAt(E),$;return T>=55296&&T<=56319&&E+1<d.length&&($=d.charCodeAt(E+1),$>=56320&&$<=57343)?(T-55296)*1024+$-56320+65536:T}function Un(d){return/^\n* /.test(d)}let Lo=1,br=2,Do=3,Mo=4,Ft=5;function Uo(d,E,T,$,O,x,w,L){let U,q=0,K=null,W=!1,te=!1,Gt=$!==-1,Rr=-1,Ar=Sr(_t(d,0))&&Te(_t(d,d.length-1));if(E||w)for(U=0;U<d.length;q>=65536?U+=2:U++){if(q=_t(d,U),!Ut(q))return Ft;Ar=Ar&&vt(q,K,L),K=q}else{for(U=0;U<d.length;q>=65536?U+=2:U++){if(q=_t(d,U),q===l)W=!0,Gt&&(te=te||U-Rr-1>$&&d[Rr+1]!==" ",Rr=U);else if(!Ut(q))return Ft;Ar=Ar&&vt(q,K,L),K=q}te=te||Gt&&U-Rr-1>$&&d[Rr+1]!==" "}return!W&&!te?Ar&&!w&&!O(d)?Lo:x===fn?Ft:br:T>9&&Un(d)?Ft:w?x===fn?Ft:br:te?Mo:Do}function Fo(d,E,T,$,O){d.dump=(function(){if(E.length===0)return d.quotingType===fn?'""':"''";if(!d.noCompatMode&&(Po.indexOf(E)!==-1||F.test(E)))return d.quotingType===fn?'"'+E+'"':"'"+E+"'";let x=d.indent*Math.max(1,T),w=d.lineWidth===-1?-1:Math.max(Math.min(d.lineWidth,40),d.lineWidth-x),L=$||d.flowLevel>-1&&T>=d.flowLevel;function U(q){return Co(d,q)}switch(Uo(E,L,d.indent,w,U,d.quotingType,d.forceQuotes&&!$,O)){case Lo:return E;case br:return"'"+E.replace(/'/g,"''")+"'";case Do:return"|"+jo(E,d.indent)+Go(_r(E,x));case Mo:return">"+jo(E,d.indent)+Go(_r(os(E,w),x));case Ft:return'"'+jt(E)+'"';default:throw new t("impossible error: invalid scalar style")}})()}function jo(d,E){let T=Un(d)?String(E):"",$=d[d.length-1]===`
1090
+ `,x=$&&(d[d.length-2]===`
1091
+ `||d===`
1092
+ `)?"+":$?"":"-";return T+x+`
1093
+ `}function Go(d){return d[d.length-1]===`
1094
+ `?d.slice(0,-1):d}function os(d,E){let T=/(\n+)([^\n]*)/g,$=(function(){let L=d.indexOf(`
1095
+ `);return L=L!==-1?L:d.length,T.lastIndex=L,Vo(d.slice(0,L),E)})(),O=d[0]===`
1096
+ `||d[0]===" ",x,w;for(;w=T.exec(d);){let L=w[1],U=w[2];x=U[0]===" ",$+=L+(!O&&!x&&U!==""?`
1097
+ `:"")+Vo(U,E),O=x}return $}function Vo(d,E){if(d===""||d[0]===" ")return d;let T=/ [^ ]/g,$,O=0,x,w=0,L=0,U="";for(;$=T.exec(d);)L=$.index,L-O>E&&(x=w>O?w:L,U+=`
1098
+ `+d.slice(O,x),O=x+1),w=L;return U+=`
1099
+ `,d.length-O>E&&w>O?U+=d.slice(O,w)+`
1100
+ `+d.slice(w+1):U+=d.slice(O),U.slice(1)}function jt(d){let E="",T=0;for(let $=0;$<d.length;T>=65536?$+=2:$++){T=_t(d,$);let O=ke[T];!O&&Ut(T)?(E+=d[$],T>=65536&&(E+=d[$+1])):E+=O||wt(T)}return E}function is(d,E,T){let $="",O=d.tag;for(let x=0,w=T.length;x<w;x+=1){let L=T[x];d.replacer&&(L=d.replacer.call(T,String(x),L)),(_(d,E,L,!1,!1)||typeof L>"u"&&_(d,E,null,!1,!1))&&($!==""&&($+=","+(d.condenseFlow?"":" ")),$+=d.dump)}d.tag=O,d.dump="["+$+"]"}function Tr(d,E,T,$){let O="",x=d.tag;for(let w=0,L=T.length;w<L;w+=1){let U=T[w];d.replacer&&(U=d.replacer.call(T,String(w),U)),(_(d,E+1,U,!0,!0,!1,!0)||typeof U>"u"&&_(d,E+1,null,!0,!0,!1,!0))&&((!$||O!=="")&&(O+=Mn(d,E)),d.dump&&l===d.dump.charCodeAt(0)?O+="-":O+="- ",O+=d.dump)}d.tag=x,d.dump=O||"[]"}function ss(d,E,T){let $="",O=d.tag,x=Object.keys(T);for(let w=0,L=x.length;w<L;w+=1){let U="";$!==""&&(U+=", "),d.condenseFlow&&(U+='"');let q=x[w],K=T[q];d.replacer&&(K=d.replacer.call(T,q,K)),_(d,E,q,!1,!1)&&(d.dump.length>1024&&(U+="? "),U+=d.dump+(d.condenseFlow?'"':"")+":"+(d.condenseFlow?"":" "),_(d,E,K,!1,!1)&&(U+=d.dump,$+=U))}d.tag=O,d.dump="{"+$+"}"}function as(d,E,T,$){let O="",x=d.tag,w=Object.keys(T);if(d.sortKeys===!0)w.sort();else if(typeof d.sortKeys=="function")w.sort(d.sortKeys);else if(d.sortKeys)throw new t("sortKeys must be a boolean or a function");for(let L=0,U=w.length;L<U;L+=1){let q="";(!$||O!=="")&&(q+=Mn(d,E));let K=w[L],W=T[K];if(d.replacer&&(W=d.replacer.call(T,K,W)),!_(d,E+1,K,!0,!0,!0))continue;let te=d.tag!==null&&d.tag!=="?"||d.dump&&d.dump.length>1024;te&&(d.dump&&l===d.dump.charCodeAt(0)?q+="?":q+="? "),q+=d.dump,te&&(q+=Mn(d,E)),_(d,E+1,W,!0,te)&&(d.dump&&l===d.dump.charCodeAt(0)?q+=":":q+=": ",q+=d.dump,O+=q)}d.tag=x,d.dump=O||"{}"}function s(d,E,T){let $=T?d.explicitTypes:d.implicitTypes;for(let O=0,x=$.length;O<x;O+=1){let w=$[O];if((w.instanceOf||w.predicate)&&(!w.instanceOf||typeof E=="object"&&E instanceof w.instanceOf)&&(!w.predicate||w.predicate(E))){if(T?w.multi&&w.representName?d.tag=w.representName(E):d.tag=w.tag:d.tag="?",w.represent){let L=d.styleMap[w.tag]||w.defaultStyle,U;if(r.call(w.represent)==="[object Function]")U=w.represent(E,L);else if(o.call(w.represent,L))U=w.represent[L](E,L);else throw new t("!<"+w.tag+'> tag resolver accepts not "'+L+'" style');d.dump=U}return!0}}return!1}function _(d,E,T,$,O,x,w){d.tag=null,d.dump=T,s(d,T,!1)||s(d,T,!0);let L=r.call(d.dump),U=$;$&&($=d.flowLevel<0||d.flowLevel>E);let q=L==="[object Object]"||L==="[object Array]",K,W;if(q&&(K=d.duplicates.indexOf(T),W=K!==-1),(d.tag!==null&&d.tag!=="?"||W||d.indent!==2&&E>0)&&(O=!1),W&&d.usedDuplicates[K])d.dump="*ref_"+K;else{if(q&&W&&!d.usedDuplicates[K]&&(d.usedDuplicates[K]=!0),L==="[object Object]")$&&Object.keys(d.dump).length!==0?(as(d,E,d.dump,O),W&&(d.dump="&ref_"+K+d.dump)):(ss(d,E,d.dump),W&&(d.dump="&ref_"+K+" "+d.dump));else if(L==="[object Array]")$&&d.dump.length!==0?(d.noArrayIndent&&!w&&E>0?Tr(d,E-1,d.dump,O):Tr(d,E,d.dump,O),W&&(d.dump="&ref_"+K+d.dump)):(is(d,E,d.dump),W&&(d.dump="&ref_"+K+" "+d.dump));else if(L==="[object String]")d.tag!=="?"&&Fo(d,d.dump,E,x,U);else{if(L==="[object Undefined]")return!1;if(d.skipInvalid)return!1;throw new t("unacceptable kind of an object to dump "+L)}if(d.tag!==null&&d.tag!=="?"){let te=encodeURI(d.tag[0]==="!"?d.tag.slice(1):d.tag).replace(/!/g,"%21");d.tag[0]==="!"?te="!"+te:te.slice(0,18)==="tag:yaml.org,2002:"?te="!!"+te.slice(18):te="!<"+te+">",d.dump=te+" "+d.dump}}return!0}function I(d,E){let T=[],$=[];N(d,T,$);let O=$.length;for(let x=0;x<O;x+=1)E.duplicates.push(T[$[x]]);E.usedDuplicates=new Array(O)}function N(d,E,T){if(d!==null&&typeof d=="object"){let $=E.indexOf(d);if($!==-1)T.indexOf($)===-1&&T.push($);else if(E.push(d),Array.isArray(d))for(let O=0,x=d.length;O<x;O+=1)N(d[O],E,T);else{let O=Object.keys(d);for(let x=0,w=O.length;x<w;x+=1)N(d[O[x]],E,T)}}}function A(d,E){E=E||{};let T=new rs(E);T.noRefs||I(d,T);let $=d;return T.replacer&&($=T.replacer.call({"":$},"",$)),_(T,0,$,!0,!0)?T.dump+`
1101
+ `:""}return Va.dump=A,Va}var up;function uS(){if(up)return Ce;up=1;let e=lS(),t=cS();function n(r,o){return function(){throw new Error("Function yaml."+r+" is removed in js-yaml 4. Use yaml."+o+" instead, which is now safe by default.")}}return Ce.Type=Fe(),Ce.Schema=dp(),Ce.FAILSAFE_SCHEMA=hp(),Ce.JSON_SCHEMA=Sp(),Ce.CORE_SCHEMA=bp(),Ce.DEFAULT_SCHEMA=Ha(),Ce.load=e.load,Ce.loadAll=e.loadAll,Ce.dump=t.dump,Ce.YAMLException=Br(),Ce.types={binary:Ap(),float:Ep(),map:mp(),null:gp(),pairs:wp(),set:vp(),timestamp:Tp(),bool:yp(),int:_p(),merge:Rp(),omap:kp(),seq:pp(),str:fp()},Ce.safeLoad=n("safeLoad","load"),Ce.safeLoadAll=n("safeLoadAll","loadAll"),Ce.safeDump=n("safeDump","dump"),Ce}var dS=uS(),ai=sS(dS),{Type:AP,Schema:kP,FAILSAFE_SCHEMA:wP,JSON_SCHEMA:vP,CORE_SCHEMA:IP,DEFAULT_SCHEMA:NP,load:$P,loadAll:OP,dump:xP,YAMLException:PP,types:CP,safeLoad:LP,safeLoadAll:DP,safeDump:MP}=ai;var Ug=ye(Dg(),1);var Mg=new Ug.default(Ku).compile(ms);function r0(e,t){try{return{ok:!0,value:ai.load(e,{filename:t,schema:ai.CORE_SCHEMA})}}catch(n){let r=n instanceof Error?n.message.split(`
1102
+ `)[0]:String(n);return{ok:!1,error:`${t}: not valid YAML or JSON \u2014 ${r}`}}}function Fg(e,t){let n=r0(e,t);if(!n.ok)return{ok:!1,errors:[n.error]};let r=n.value;return r==null?{ok:!1,errors:[`${t}: is empty`]}:typeof r!="object"||Array.isArray(r)?{ok:!1,errors:[`${t}: must be a mapping of keys to values, not ${Array.isArray(r)?"a list":typeof r}`]}:Mg(r)?{ok:!0,config:r}:{ok:!1,errors:[...new Set((Mg.errors??[]).map(o=>o0(t,o)))]}}function o0(e,t){if(t.keyword==="additionalProperties"){let n=String(t.params.additionalProperty),r=Object.keys(ms.properties).join(", "),o=t.instancePath===""?"top-level":`"${t.instancePath}"`;return`${e}: unknown ${o} key "${n}" (allowed: ${r}). A misspelled key would be silently ignored, so it is rejected here.`}if(t.keyword==="const"&&t.instancePath==="/schema_version")return`${e}: 'schema_version' must be ${JSON.stringify(t.params.allowedValue)} \u2014 this reader does not understand any other version`;if(t.keyword==="enum"){let n=t.params.allowedValues??[];return`${e}: ${t.instancePath||"value"} must be one of: ${n.join(", ")}`}return t.keyword==="required"?`${e}: '${String(t.params.missingProperty)}' is required`:`${e}:${t.instancePath===""?"":` at ${t.instancePath}`} ${t.message??"is invalid"}`}f();f();f();function Hi(e){return{ok:!0,value:e}}function Ln(e){return{ok:!1,reason:e}}f();var i0=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,Gg=`lowercase letters, digits and interior hyphens only, ${1}\u2013${63} characters (e.g. "my-task")`;function wo(e){return typeof e!="string"?Ln("must be a string"):e.length<1?Ln("is required"):e.length>63?Ln(`must be at most ${63} characters`):i0.test(e)?Hi(e):Ln(`must use ${Gg}`)}f();function Vg(e,t="task.yaml",n=Kt){let r=[],o=[];if(e.slug===void 0||e.slug===null||e.slug==="")r.push(k.SLUG_MISSING(t));else{let l=wo(e.slug);l.ok||r.push(k.SLUG_INVALID(t,l.reason))}let i=e.run;if(i){i.preset!==void 0&&(typeof i.preset!="string"||i.preset.trim()==="")?r.push(k.PRESET_INVALID):i.preset!==void 0&&!kd(i.preset)&&r.push(k.PRESET_UNKNOWN(t,i.preset,$s)),i.timeout_sec!==void 0&&!(typeof i.timeout_sec=="number"&&i.timeout_sec>0)&&r.push(k.TIMEOUT_INVALID);let l=i.payload===void 0?0:Hr(i.payload);l>n&&r.push(k.DEFAULT_PAYLOAD_OVER_LIMIT(t,l,n))}let a=$r(e.execution,Nr);return a.ok?o.push(...a.warnings):r.push(a.error),{ok:r.length===0,errors:r,warnings:o}}function s0(e,t){let n=Fg(e,t);if(!n.ok)return{ok:!1,errors:n.errors,warnings:[]};let r=n.config,o=[];ps.includes(r.runtime)||o.push(`${t}: runtime "${r.runtime}" is known but not available yet (available now: ${ps.join(", ")})`);let i=Vg(r,t);return o.push(...i.errors),o.length>0?{ok:!1,errors:o,warnings:i.warnings}:{ok:!0,config:r,errors:o,warnings:i.warnings}}function a0(e,t){let n=Bi.default.basename(t);return e===n?null:`task.yaml slug "${e}" must match the task directory name "${n}". Every local lookup names the task by its directory, but runs dispatch by slug. Set slug: "${n}" or rename the directory.`}function l0(e){let t=Ki.default.existsSync(e)?gs(Ki.default.readdirSync(e)):null;return t===null?null:Bi.default.join(e,t)}function Yi(e){let t=l0(e);if(!t)return{ok:!1,file:null,errors:[`No ${Vt.join(" / ")} found in ${e}`],warnings:[]};let n=s0(Ki.default.readFileSync(t,"utf8"),Bi.default.basename(t)),r=n.ok?a0(n.config.slug,e):null;return r!==null?{ok:!1,file:t,errors:[r],warnings:n.warnings}:{...n,file:t}}function Hg(e){return e.entry??at[e.runtime].entryFile}function Xc(e,t){return Io.default.resolve(t,_e(e,"dir")||process.env[Gn.TASKS_DIR]||cd)}function qg(e){return vo.default.existsSync(e)?vo.default.readdirSync(e,{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>{let n=Io.default.join(e,t.name);try{return{dir:n,state:bn(n)}}catch(r){throw new Error(`cannot read ${Jc(n)}: ${Ke(r)}`,{cause:r})}}):[]}function Jc(e){return Io.default.join(e,It.DIR)}function Qc(e,t){let n=Bn(e),r=_e(e,"dir");return{taskId:n,taskDir:n?Io.default.resolve(Xc(e,t),n):"",dirFlag:r}}function Wi(e,t){let{taskId:n,taskDir:r}=Qc(e,t);return n?!vo.default.existsSync(r)||!vo.default.statSync(r).isDirectory()?(console.error(k.ERROR(`Task directory not found at ${r}`)),null):r:(console.error(k.ERROR(k.TASK_ID_REQUIRED)),null)}async function zi(e,t){let n=Wi(e,t);if(!n)return null;let r=Yi(n);if(!r.ok){for(let o of r.errors)console.error(k.ERROR(o));return null}return{taskDir:n,config:r.config,warnings:r.warnings}}f();var nu=ye(require("node:fs"),1),ru=ye(require("node:path"),1);f();var c0=/[[\]\\]/,u0=e=>e.replace(/[.+^${}()|]/g,"\\$&"),d0=e=>[...e].map(t=>t==="*"?"[^/]*":t==="?"?"[^/]":u0(t)).join("");function f0(e,t){let n=e.split("/");if(n.some(i=>i===""))return"an empty path segment";if(n.some(i=>i.includes("**")&&i!=="**"))return'"**" must be a whole path segment';let r=n.length-1,o=n.map((i,a)=>i==="**"?a===r?".*":"(?:[^/]+/)*":d0(i)+(a===r?"":"/")).join("");return new RegExp(`^${t?"":"(?:.*/)?"}${o}$`)}function Kg(e,t,n){let r=[],o=[];return e.split(/\r?\n/).forEach((i,a)=>{let l=a+1,c=`${t}:${l}`,u=i.trim();if(u===""||u.startsWith("#"))return;if(u.startsWith("!")){o.push(`${c}: "!" (re-include) is not supported; ${t} can only leave files out`);return}if(c0.test(u)){o.push(`${c}: "${u}" uses "[...]" or "\\", which are not supported`);return}let p=u.endsWith("/"),m=p?u.slice(0,-1):u,h=m.startsWith("/");h&&(m=m.slice(1));let b=f0(m,h||m.includes("/"));if(typeof b=="string"){o.push(`${c}: "${u}" has ${b}`);return}let g={line:l,pattern:u,dirOnly:p,regex:b},S=n.find(v=>Zc([g],v,!1));if(S!==void 0){o.push(`${c}: "${u}" would leave out ${S}, which the deploy needs`);return}r.push(g)}),o.length>0?{ok:!1,errors:o}:{ok:!0,rules:r}}function Zc(e,t,n){return e.some(r=>(!r.dirOnly||n)&&r.regex.test(t))}f();var No=ye(require("node:fs"),1),Xi=ye(require("node:path"),1),eu=ye(require("node:crypto"),1);var p0=1024*1024;function Bg(e,t=Yu,n=[]){let r=[],o=new Map,i=[],a=[],l=[],c=0,u=!1;if(!No.default.existsSync(e))return{entries:r,data:o,errors:[`Task directory does not exist: ${e}`],warnings:a,ignored:l,totalBytes:c};let p=m=>{for(let h of No.default.readdirSync(m,{withFileTypes:!0}).sort((b,g)=>b.name<g.name?-1:1)){if(u)return;let b=Xi.default.join(m,h.name),g=Xi.default.relative(e,b).split(Xi.default.sep).join("/"),S=Ju(g);if(S){h.isDirectory()||a.push(`excluded ${g} \u2014 ${S}`);continue}if(g===mn)continue;if(Zc(n,g,h.isDirectory())){l.push(h.isDirectory()?`${g}/`:g);continue}if(h.isSymbolicLink()){i.push(`${g}: symlinks are not uploaded (a link can reach outside the task directory)`);continue}if(h.isDirectory()){p(b);continue}if(!h.isFile()){i.push(`${g}: not a regular file (sockets, FIFOs and device nodes are not uploaded)`);continue}let v=No.default.statSync(b);if(c+v.size>t){u=!0,i.push(`the task directory holds more than ${t/p0} MiB of files (reached at ${g}); the server refuses a larger upload`);return}let R=No.default.readFileSync(b);if(zu.includes(h.name)){let M=Xu(g,R.toString("utf8"));if(M!==null){i.push(M);continue}}let P=Qu(g);P!==null&&a.push(P),r.push({path:g,exec:(v.mode&73)!==0,size:R.length,sha256:eu.default.createHash("sha256").update(R).digest("hex")}),o.set(g,R),c+=R.length}};return p(e),{entries:r,data:o,errors:i,warnings:a,ignored:l,totalBytes:c}}function Yg(e,t){return`sha256:${eu.default.createHash("sha256").update(Zu(e,t),"utf8").digest("hex")}`}function Wg(e,t){let n=at[t].lockfile;return e.some(r=>r.path===n)?null:`${n} is missing. A ${t} task must upload its lockfile: without one the build is not reproducible and two deployments of the same source can resolve different versions.`}f();function Jg(e){let t=[],n=(r,o)=>{t.push(r,o);let i=(512-o.length%512)%512;i>0&&t.push(Buffer.alloc(i))};for(let{name:r,data:o,exec:i}of e){if(Buffer.byteLength(r,"utf8")>tu){let a=_0("path",r);n(Xg(y0,a.length,zg,g0),a)}n(Xg(E0(r),o.length,i?m0:zg,h0),o)}return t.push(Buffer.alloc(1024)),Buffer.concat(t)}var tu=100,zg=420,m0=493,h0="0",g0="x",y0="PaxHeader";function _0(e,t){let n=` ${e}=${t}
1103
+ `,r=Buffer.byteLength(n,"utf8"),o=r+1;for(;String(o).length+r!==o;)o=String(o).length+r;return Buffer.from(`${o}${n}`,"utf8")}function E0(e){if(Buffer.byteLength(e,"utf8")<=tu)return e;let t="";for(let n of e){if(Buffer.byteLength(t+n,"utf8")>tu)break;t+=n}return t}function Xg(e,t,n,r){let o=Buffer.alloc(512);o.write(e,0,"utf8"),o.write(n.toString(8).padStart(7,"0")+"\0",100,"ascii"),o.write("0000000\0",108,"ascii"),o.write("0000000\0",116,"ascii"),o.write(t.toString(8).padStart(11,"0")+"\0",124,"ascii"),o.write("00000000000\0",136,"ascii"),o.write(r,156,"ascii"),o.write("ustar\0",257,"ascii"),o.write("00",263,"ascii"),o.write(" ",148,"ascii");let i=0;for(let a of o)i+=a;return o.write(i.toString(8).padStart(6,"0")+"\0 ",148,"ascii"),o}function S0(e,t){let n=ru.default.join(e,mn);return nu.default.existsSync(n)?Kg(nu.default.readFileSync(n,"utf8"),mn,t):{ok:!0,rules:[]}}function $o(e){let t=Yi(e),n=[...t.warnings];if(!t.ok)return{ok:!1,errors:t.errors,warnings:n};let r=t.config,o=at[r.runtime],i=S0(e,[...Vt,o.depManifest,o.lockfile]);if(!i.ok)return{ok:!1,errors:i.errors,warnings:n};let a=[],l=Bg(e,void 0,i.rules);n.push(...l.warnings),a.push(...l.errors);let c=Wg(l.entries,r.runtime);c!==null&&a.push(c);let u=Hg(r);if(l.entries.some(m=>m.path===u)||a.push(`the entry file "${u}" is not in the upload.`),a.length>0)return{ok:!1,errors:a,warnings:n};let p;try{p=Yg(l.entries,{name:ru.default.basename(t.file??""),value:r})}catch(m){return{ok:!1,errors:[m.message.replace(/^source manifest: /,"")],warnings:n}}return{ok:!0,source:{config:r,entries:l.entries,data:l.data,totalBytes:l.totalBytes,ignored:l.ignored,contentHash:p},warnings:n}}function Qg(e){let t=$o(e);if(!t.ok)return t;let{warnings:n}=t,{config:r,entries:o,data:i,totalBytes:a,ignored:l,contentHash:c}=t.source,u=Jg(o.map(m=>({name:m.path,data:i.get(m.path),exec:m.exec})));return{ok:!0,upload:{manifest:{contentHash:c,format:"source",...r.execution?{execution:r.execution}:{},...r.secrets?.length?{secrets:[...r.secrets]}:{}},tar:u,slug:r.slug,files:o.length,totalBytes:a,ignored:l},warnings:n}}f();var xo=ye(require("fs"),1),Qi=ye(require("path"),1);f();function Zg(e,t){return`# The task's configuration: data only, read by the CLI and the platform (never executed).
1104
+ schema_version: 1
1105
+ slug: ${e} # must match this directory's name
1106
+ runtime: ${t}
1107
+
1108
+ # \u2500\u2500 Auth \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
1109
+ # Set the IGNITIFY_API_KEY env var to your tenant API key \u2014 never put it in this file.
1110
+
1111
+ # \u2500\u2500 Optional \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
1112
+ # Secret NAMES this task reads from ctx.secrets. Values are set with \`secret:set\`, never here.
1113
+ # secrets: [DB_PASSWORD]
1114
+
1115
+ # Declared task nature: you DECLARE what the task is, the platform DERIVES how to run it (heartbeat /
1116
+ # warm reuse / streaming / NIC). Every field is optional; omitted ones use the default shown first.
1117
+ # Values marked \u23F3 are REJECTED today (they need checkpoint/resume); everything else is live.
1118
+ # execution:
1119
+ # cardinality: one # one | many | continuous
1120
+ # duration: short # short | long | \u23F3unbounded
1121
+ # state: independent # independent | across-runs | \u23F3across-crashes
1122
+ # interaction: boundary-only # boundary-only | continuous
1123
+ # storage_mib: 512 # optional: scratch disk (MiB). Default = your preset's size; less is raised to it
1124
+ #
1125
+ # # "auto" (DEFAULT): the VM is reaped when idle, at the age cap, or under capacity pressure.
1126
+ # # "pinned": \u26A0\uFE0F PERMANENT STANDBY \u2014 the VM boots once, is reused across runs and is NEVER
1127
+ # # auto-reaped; it holds its vCPU/RAM until you run \`ignitify vm:delete <vm-id> --force\`.
1128
+ # # Requires cardinality "many" or "continuous".
1129
+ # residency: auto # auto | pinned
1130
+ #
1131
+ # # Everything about the network lives in this ONE object. Every key but "type" needs a NIC:
1132
+ # # egress_* need "egress" or "bidirectional"; inbound_* need "bidirectional". A policy key
1133
+ # # while type stays "none" is REJECTED. All keys except inbound_port apply on your NEXT run.
1134
+ # network:
1135
+ # type: none # REQUIRED. none | egress | bidirectional
1136
+ # egress_allow: [api.github.com] # omit = anywhere; [] = nowhere; "*.a.com" matches ONE label
1137
+ # egress_tls_only: true # plaintext port 80 dropped; defaults to true with egress_allow
1138
+ # egress_mbit: 5 # you may only LOWER the platform default
1139
+ # inbound_port: 8080 # bidirectional only, 1024-65535; call ctx.ready() once listening
1140
+ # inbound_rps: 100 # you may only LOWER these three
1141
+ # inbound_burst: 200
1142
+ # inbound_max_concurrent: 64
1143
+
1144
+ # How the platform builds the task:
1145
+ # build:
1146
+ # allowed_hosts: [registry.example.com] # extra hosts the BUILD may fetch from
1147
+ # ship: [models/] # upload paths copied onto the code drive as they are
1148
+ # system_packages: [ffmpeg, git] # Debian tools the task runs (bare names, no versions)
1149
+
1150
+ # Default parameters for \`task:run\` (all optional):
1151
+ run:
1152
+ payload: {} # JSON passed to run(payload, ctx); ${xt()}
1153
+ preset: ${Ad} # instance class
1154
+ timeout_sec: 120 # hard cap in seconds
1155
+ `}var Ji=(e,t)=>[`${e} ${t.secrets.padEnd(22)} the run's secrets, by name (declare the names in task.yaml)`,`${e} ${t.chunk.padEnd(22)} stream a progress update; it always arrives before the result`,`${e} ${t.ready.padEnd(22)} "my inbound listener is up" (bidirectional network tasks only)`,`${e} ${t.metric.padEnd(22)} record a task metric`,`${e} ${t.callback.padEnd(22)} this run's inbound callback: url + verify(rawBody, signature), or none`].join(`
1156
+ `);function ey(e,t){let n=t?`
1157
+ let _db: unknown; // example: a shared resource opened in init (underscore = intentionally unused)
1158
+
1159
+ export async function init() {
1160
+ // One-time setup \u2014 runs before the first job, not repeated between jobs.
1161
+ // Example: _db = await openDatabase();
1162
+ console.log("Task ${e} initialised");
1163
+ }
1164
+ `:"";return`// Task entry point for ${e}.
1165
+ //
1166
+ ${t?`// init() runs ONCE per process, before the first job \u2014 open a DB pool, load a model.
1167
+ `:`// Export an init() function if you need one-time setup (DB pool, model load, etc.).
1168
+ `}// run(payload, ctx) runs once per job; return any JSON-serialisable value.
1169
+ // Limits: ${xt()}.
1170
+ //
1171
+ ${Ji("//",{secrets:"ctx.secrets",chunk:"ctx.chunk(data)",ready:"ctx.ready()",metric:"ctx.metric(name, v)",callback:"ctx.callback"})}
1172
+ ${n}
1173
+ export async function run(payload: Record<string, unknown>, _ctx: unknown) {
1174
+ // JSON.stringify: the guest console joins its arguments as strings, and an object would print as [object Object].
1175
+ console.log("Running task ${e} with payload:", JSON.stringify(payload));
1176
+ return { success: true, task: "${e}" };
1177
+ }
1178
+ `}function ty(e){return`${JSON.stringify({name:e,version:"1.0.0",private:!0,type:"module"},null,2)}
1179
+ `}function ny(e){return`${JSON.stringify({name:e,version:"1.0.0",lockfileVersion:3,requires:!0,packages:{"":{name:e,version:"1.0.0"}}},null,2)}
1180
+ `}function ry(e,t){let n=t?`
1181
+ def init():
1182
+ # One-time setup \u2014 runs before the first job, not repeated between jobs.
1183
+ print("Task ${e} initialised")
1184
+
1185
+ `:`
1186
+ `;return`# Task entry point for ${e}.
1187
+ #
1188
+ ${t?`# init() runs ONCE per process, before the first job \u2014 open a DB pool, load a model.
1189
+ `:`# Define init() if you need one-time setup (DB pool, model load, etc.).
1190
+ `}# run(payload, ctx) runs once per job; return any JSON-serialisable value. \`async def\` works too.
1191
+ # Limits: ${xt()}.
1192
+ #
1193
+ ${Ji("#",{secrets:"ctx.secrets",chunk:"ctx.chunk(data)",ready:"ctx.ready()",metric:"ctx.metric(name, v)",callback:"ctx.callback"})}
1194
+ ${n}
1195
+ def run(payload, ctx):
1196
+ print(f"Running task ${e} with payload: {payload}")
1197
+ return {"success": True, "task": "${e}"}
1198
+ `}function oy(){return`# The lockfile: every requirement pinned WITH a --hash (the build installs with --require-hashes).
1199
+ # No dependencies yet. To add some, list them in requirements.in and generate this file:
1200
+ # uv pip compile --universal --generate-hashes --python-version 3.11 requirements.in -o requirements.txt
1201
+ `}function iy(e,t,n){let r=t?"ignitify.Start(run, ignitify.WithInit(initialise))":"ignitify.Start(run)",o=t?`
1202
+ // initialise runs ONCE per process, before the first job \u2014 open a DB pool, load a model.
1203
+ func initialise() error {
1204
+ log.Println("Task ${e} initialised")
1205
+ return nil
1206
+ }
1207
+ `:"";return`// Task entry point for ${e}.
1208
+ //
1209
+ // main() hands the platform your run function (and, optionally, an init function with
1210
+ // ignitify.WithInit). The build compiles this program; the platform starts it and calls run once per
1211
+ // job with the job payload. Return any value that encodes as JSON.
1212
+ // Limits: ${xt()}.
1213
+ //
1214
+ ${Ji("//",{secrets:"ctx.Secrets",chunk:"ctx.Chunk(data)",ready:"ctx.Ready()",metric:"ctx.Metric(...)",callback:"ctx.Callback"})}
1215
+ package main
1216
+
1217
+ import (
1218
+ "encoding/json"
1219
+ "log"
1220
+
1221
+ ignitify "${n}"
1222
+ )
1223
+
1224
+ func main() {
1225
+ ${r}
1226
+ }
1227
+ ${o}
1228
+ func run(payload json.RawMessage, ctx *ignitify.Ctx) (any, error) {
1229
+ log.Printf("Running task ${e} with payload: %s", payload)
1230
+ return map[string]any{"success": true, "task": "${e}"}, nil
1231
+ }
1232
+ `}function sy(e,t,n){return`module example.com/${e}
1233
+
1234
+ go ${n}
1235
+
1236
+ require ${t} v0.0.0
1237
+
1238
+ // The runtime client travels with the task until it is published.
1239
+ replace ${t} => ./ignitify
1240
+ `}function ay(e,t){let n=t?` // init: runs ONCE per process, before the first job \u2014 open a DB pool, load a model.
1241
+ || {
1242
+ eprintln!("Task ${e} initialised");
1243
+ Ok(())
1244
+ },`:` // init: nothing to set up. Do one-time setup here (DB pool, model load, etc.).
1245
+ || Ok(()),`;return`// Task entry point for ${e}.
1246
+ //
1247
+ // main() hands the platform an init closure and a run closure. The build compiles this program; the
1248
+ // platform starts it and calls run once per job with the job payload. Return any JSON value.
1249
+ // Limits: ${xt()}.
1250
+ //
1251
+ ${Ji("//",{secrets:"ctx.secrets",chunk:"ctx.chunk(&data)",ready:"ctx.ready()",metric:"ctx.metric(...)",callback:"ctx.callback"})}
1252
+ use serde_json::{json, Value};
1253
+
1254
+ fn main() {
1255
+ ignitify_runtime::start(
1256
+ ${n}
1257
+ |payload: Value, _ctx| {
1258
+ eprintln!("Running task ${e} with payload: {payload}");
1259
+ Ok(json!({ "success": true, "task": "${e}" }))
1260
+ },
1261
+ )
1262
+ }
1263
+ `}function ly(e,t){return`[package]
1264
+ name = "${e}"
1265
+ version = "0.1.0"
1266
+ edition = "2021"
1267
+
1268
+ [dependencies]
1269
+ # The runtime client travels with the task until it is published.
1270
+ ${t} = { path = "ignitify" }
1271
+ serde_json = "1"
1272
+ `}var b0={node:"- `index.ts` \u2014 your task code: `run(payload, ctx)`, and an optional `init()`.\n- `package.json` + `package-lock.json` \u2014 dependencies. `npm install <pkg>` updates both; upload both.",python:"- `main.py` \u2014 your task code: `run(payload, ctx)`, and an optional `init()`.\n- `requirements.txt` \u2014 the lockfile, a `--hash` on every line (see its header for the command).",go:"- `main.go` \u2014 your task code: `main()` calls `ignitify.Start(run, \u2026)`.\n- `go.mod` + `go.sum` \u2014 dependencies. `go get <module>` then `go mod tidy` update both; upload both.\n- `ignitify/` \u2014 the runtime client, carried with the task until it is published. Do not edit it.",rust:"- `src/main.rs` \u2014 your task code: `main()` calls `ignitify_runtime::start(init, run)`.\n- `Cargo.toml` + `Cargo.lock` \u2014 dependencies. `cargo add <crate>` updates both; upload both.\n- `ignitify/` \u2014 the runtime client, carried with the task until it is published. Do not edit it."};function cy(e,t,n,r){let o=r?` --dir ${r}`:"",i=n?"":" --no-init";return`# ${e}
1273
+
1274
+ A ${t} task scaffolded by the Ignitify CLI (\`ignitify task:create --lang ${t}\`).
1275
+
1276
+ ## Files
1277
+
1278
+ - \`task.yaml\` \u2014 slug, runtime, execution nature and default run parameters (data, never executed).
1279
+ ${b0[t]}
1280
+
1281
+ The platform builds the task from this source: no toolchain is needed on your machine to deploy it.
1282
+
1283
+ ## Lifecycle
1284
+
1285
+ \`\`\`bash
1286
+ export IGNITIFY_API_KEY=<tenant-raw-key> # never commit this \u2014 needed from 'deploy' on
1287
+
1288
+ ./ignitify task:validate ${e}${o} # 1. check task.yaml offline (no server, no key)
1289
+ ./ignitify task:deploy ${e}${o} # 2. upload the source; the platform builds it
1290
+ ./ignitify task:run ${e}${o} --wait # 3. execute in a MicroVM
1291
+ \`\`\`
1292
+
1293
+ Inspect a run afterwards:
1294
+
1295
+ \`\`\`bash
1296
+ ./ignitify run:list --task-name ${e}
1297
+ ./ignitify run:get <run-id> --full # status + result + last streamed chunk
1298
+ \`\`\`
1299
+
1300
+ ## Re-scaffolding
1301
+
1302
+ \`\`\`bash
1303
+ ./ignitify task:create ${e} --local --lang ${t}${i}${o}
1304
+ \`\`\`
1305
+ `}f();var uy=ye(require("node:fs"),1),dy=ye(require("node:path"),1),fy=ye(require("node:sea"),1),py=require("node:url"),T0="ignitify",Dt={go:{pkg:"runtime-go",files:["go.mod","runtime.go"]},rust:{pkg:"runtime-rust",files:["Cargo.toml","src/lib.rs"]}};function R0(){return(0,py.fileURLToPath)(new URL("../../../../packages/",__bundle_url))}function A0(e=R0()){return(t,n)=>{let r=dy.default.join(e,t,n);try{return uy.default.readFileSync(r,"utf8")}catch{throw new Error(`the runtime client source ${r} is not readable. A Go or Rust scaffold carries the client from packages/${t}, so this CLI must run from a checkout of the repository.`)}}}function k0(e){return(t,n)=>{let r=`${t}/${n}`;try{return e.getAsset(r,"utf8")}catch{throw new Error(`this ignitify binary carries no runtime client file "${r}" \u2014 it was built without it`)}}}function w0(e){return(t,n)=>{let r=`${t}/${n}`,o=e[r];if(o===void 0)throw new Error(`this ignitify package carries no runtime client file "${r}" \u2014 it was built without it`);return o}}function Oo(e=fy.default,t=typeof y>"u"?void 0:y){return t?w0(t):e.isSea()?k0(e):A0()}function v0(e){let t=e.split(`
1306
+ `),n=t.findIndex(a=>a.trim()==="[workspace]");if(n===-1)return e;let r=n;for(;r>0&&t[r-1].trimStart().startsWith("#");)r--;let o=n+1;for(;o<t.length&&t[o].trim()!==""&&!t[o].trimStart().startsWith("[");)o++;return[...t.slice(0,r),...t.slice(o)].join(`
1307
+ `).replace(/\n{3,}/g,`
1308
+
1309
+ `)}function ou(e,t=Oo()){let{pkg:n,files:r}=Dt[e],o={};for(let i of r){let a=t(n,i);o[`${T0}/${i}`]=i==="Cargo.toml"?v0(a):a}return o}function my(e=Oo()){let t=/^module\s+(\S+)/m.exec(e(Dt.go.pkg,"go.mod"));if(!t)throw new Error(`packages/${Dt.go.pkg}/go.mod names no module`);return t[1]}function hy(e=Oo()){let t=/^go\s+(\S+)/m.exec(e(Dt.go.pkg,"go.mod"));if(!t)throw new Error(`packages/${Dt.go.pkg}/go.mod has no go line`);return t[1]}function iu(e=Oo()){let t=/^name\s*=\s*"([^"]+)"/m.exec(e(Dt.rust.pkg,"Cargo.toml"));if(!t)throw new Error(`packages/${Dt.rust.pkg}/Cargo.toml names no package`);return t[1]}var I0=new Set(["build","deps","examples","incremental"]);function gy(e){return/^[a-z]/.test(e)&&!I0.has(e)?e:`task-${e}`}function yy(e,t=Oo()){let n=t(Dt.rust.pkg,"Cargo.lock"),r=iu(t),[o,...i]=n.trimEnd().split(`
1310
+
1311
+ `),a=i.map(m=>/^name = "([^"]+)"/m.exec(m)?.[1]??"");if(!a.includes(r)||!a.includes("serde_json"))throw new Error(`packages/${Dt.rust.pkg}/Cargo.lock lists no ${r} or serde_json package`);if(a.includes(e))throw new Error(`the package name "${e}" is already a crate in the client's Cargo.lock; choose another slug`);let l=[r,"serde_json"].sort(),c=["[[package]]",`name = "${e}"`,'version = "0.1.0"',"dependencies = [",...l.map(m=>` "${m}",`),"]"].join(`
1312
+ `),u=a.findIndex(m=>m>e),p=u===-1?[...i,c]:[...i.slice(0,u),c,...i.slice(u)];return[o,...p].join(`
1313
+
1314
+ `)+`
1315
+ `}function N0(e,t,n,r){let o=at[t],i={"task.yaml":Zg(e,t),"README.md":cy(e,t,n,r)};switch(t){case"node":return{...i,[o.entryFile]:ey(e,n),[o.depManifest]:ty(e),[o.lockfile]:ny(e)};case"python":return{...i,[o.entryFile]:ry(e,n),[o.lockfile]:oy()};case"go":{let a=my();return{...i,[o.entryFile]:iy(e,n,a),[o.depManifest]:sy(e,a,hy()),[o.lockfile]:"",...ou("go")}}case"rust":{let a=gy(e);return{...i,[o.entryFile]:ay(e,n),[o.depManifest]:ly(a,iu()),[o.lockfile]:yy(a),...ou("rust")}}}}function su(e,t,n,r,o="node"){let i;try{i=N0(e,o,n,r)}catch(a){return a instanceof Error?a.message:String(a)}if(xo.default.existsSync(t)){let a=[...new Set([...Vt,...Object.keys(i)])].filter(l=>xo.default.existsSync(Qi.default.join(t,l)));if(a.length>0)return`Task files already exist at ${t}: ${a.join(", ")}`}for(let[a,l]of Object.entries(i)){let c=Qi.default.join(t,a);xo.default.mkdirSync(Qi.default.dirname(c),{recursive:!0}),xo.default.writeFileSync(c,l)}return null}f();f();f();var $0=e=>e.kind==="wait",yr=e=>"kind"in e&&e.kind==="lost";function Zi(e,t){return Math.min(t.BASE_MS*2**Math.max(0,e),t.MAX_MS)}function O0(e){return e instanceof ve?e.status===408||e.status===429||e.status>=500&&e.status<=599:e instanceof TypeError?!0:e instanceof Error&&e.cause?.name==="TimeoutError"}function x0(e,t,n){return O0(e)?t>=lt.ERROR.MIN_TRIES&&n>=lt.ERROR.GRACE_MS?"give-up":"retry":"give-up"}async function es(e){let t=e.clock?.sleep??Wn.sleep,n=e.clock?.now??Wn.now,r=n(),o=0,i=0;for(let a=0;;){let l;try{l=await e.fetch()}catch(u){if(o===0&&(i=n()),o+=1,x0(u,o,n()-i)==="give-up")return{kind:"lost",error:u};e.onRetry?.(u),await t(e.retryDelayMs);continue}o=0,e.onView?.(l);let c=e.decide(l,n()-r,a);if(!$0(c))return{action:c,view:l};e.onWait?.(l,a),await t(c.delayMs),a+=1}}var{BUILDING:P0,READY:C0,FAILED:L0}=hn;function D0(e,t,n,r){return e===C0?{kind:"ready"}:e===L0?{kind:"failed",reason:r??"the build failed without recording a reason"}:e!==P0?{kind:"failed",reason:`deployment entered an unexpected status: ${e}`}:t>=lt.DEPLOY.TIMEOUT_MS?{kind:"timeout"}:{kind:"wait",delayMs:M0(n)}}function M0(e){return Zi(e,lt.DEPLOY)}async function _y(e){let t=await es({fetch:e.fetchStatus,retryDelayMs:lt.DEPLOY.MAX_MS,onRetry:e.onRetry,decide:(o,i,a)=>D0(o.status,i,a,o.failure_reason),onWait:(o,i)=>{i===0&&e.onBuilding?.()},clock:e});if(yr(t))return t;let{action:n,view:r}=t;return n.kind==="failed"?{...n,log:r.build_log??null}:n}f();function U0(e,t,n){return qn(e)?{kind:"settled",status:e}:t>=lt.RUN.TIMEOUT_MS?{kind:"timeout",status:e}:{kind:"wait",delayMs:Zi(n,lt.RUN)}}async function Ey(e){let t=r=>r.status??"UNKNOWN",n=await es({fetch:e.fetchRun,retryDelayMs:lt.RUN.MAX_MS,onRetry:e.onRetry,decide:(r,o,i)=>U0(t(r),o,i),onView:r=>e.onStatus?.(t(r)),clock:e});return yr(n)?n:{action:n.action,run:n.view}}async function Sy(e,t,n,r=!1){let o=!1,i=!1,a=await Qo(n,()=>ue.INTERRUPTED_BUILD(t,o),()=>_y({fetchStatus:async()=>{let l=await ri(e,t);return i&&(i=!1,n.update(ue.BUILDING(t),ue.HINT_BUILD)),l},onBuilding:()=>{o=!0,n.update(ue.BUILDING(t),ue.HINT_BUILD)},onRetry:()=>{i=!0,n.update(ue.BUILDING(t),ue.HINT_RETRYING)}}));return a.kind==="lost"?(n.fail(ue.LOST),console.error(ue.LOST_BUILD_DETAIL(t,Ke(a.error))),1):a.kind==="failed"?(n.fail(ue.BUILD_FAILED),console.error(ue.BUILD_FAILED_DETAIL(t,a.reason)),a.log&&console.error(`
1316
+ ${z.bold(He.BUILD_LOG)}
1317
+ `+Kn(a.log,{max:vr.BUILD_LOG_TAIL_LINES,keep:"tail",note:He.EARLIER_LINES})),1):a.kind==="timeout"?(n.fail(ue.BUILD_TIMEOUT),console.error(ue.BUILD_TIMEOUT_DETAIL(t)),1):(n.succeed(r&&!o?ue.REUSED:ue.BUILT),0)}async function by(e,t){let n=Cr(ue.RUN_SUBMITTED(t)),r,o=await Qo(n,()=>ue.INTERRUPTED_RUN(t),()=>Ey({fetchRun:()=>Vr(e,t),onStatus:c=>{r=c,n.update(ue.RUN(t,c),ue.HINT_RUN)},onRetry:()=>n.update(r===void 0?ue.RUN_SUBMITTED(t):ue.RUN(t,r),ue.HINT_RETRYING)}));if(yr(o))return n.fail(ue.LOST),console.error(ue.LOST_RUN_DETAIL(t,Ke(o.error))),1;let{action:i,run:a}=o;if(i.kind==="timeout")return n.fail(ue.RUN_TIMEOUT(i.status)),console.error(ue.RUN_TIMEOUT_DETAIL(t)),1;let l=i.status===Qe.COMPLETED;return l?n.succeed(ue.RUN_ENDED(i.status)):n.fail(ue.RUN_ENDED(i.status)),be.render("run:get",a),l?0:1}async function F0(e,t,n){let r=Ud(t);if(r.kind==="skip")return j(fe.SKIPPED(r.reason));try{let o=await df(Q(e),r.request,n),{lines:i,fault:a}=zs(o);for(let l of i)(a?console.error:j)(l)}catch(o){console.error(k.ERROR(Ke(o)))}}async function lu(e,t=process.cwd(),n){let r=await zi(e,t);return r?(Yn([...r.warnings]),pe({task_id:r.config.slug??ts.default.basename(r.taskDir),valid:!0},()=>Ve.VALID),Re(e,fe.FLAG)&&await F0(e,r.config,n),0):1}var au=100;async function cu(e,t=process.cwd()){let n=await zi(e,t);if(!n)return 1;let r=n.config.slug??ts.default.basename(n.taskDir),o=bn(n.taskDir),i=$o(n.taskDir),a=i.ok?i.source.contentHash:null,l=j0(e),c=b=>b.catch(()=>null),[u,p,m]=l?await Promise.all([c(Zt(l)),c(ca(l,r,void 0,{limit:au})),c(oi(l,{task_name:r,limit:String(au)}))]):[null,null,null],h=Uf({slug:r,declared:n.config.execution,declaredPreset:n.config.run?.preset,stateDeploymentId:o.deployment_id??null,localContentHash:a,deployments:p?.deployments??null,runs:m?.runs??null,pageLimit:au,usage:u?.usage??null});return pe(zn(h),()=>Ff(h)),0}function j0(e){try{return Q(e)}catch(t){return console.error(tt.TASK_GET_OFFLINE(Ke(t))),null}}async function G0(e,t){let n=await gf(e,t),r=n.live_runs.map(o=>({id:o.id,status:o.status,...o.vm_id?{vm_id:o.vm_id}:{}}));return{taskId:n.task_id,runs:r,deploymentCount:n.deployments,runCount:n.runs}}async function uu(e,t=process.cwd()){let n=Wi(e,t);if(!n)return 1;let r=$o(n);if(Yn([...r.warnings]),!r.ok)return ti([...r.errors]),1;let{config:o,entries:i,totalBytes:a,ignored:l,contentHash:c}=r.source;return be.render("task:pack",{task_id:o.slug,files:i.map(u=>({path:u.path,size:u.size})),total_bytes:a,ignored:l,content_hash:c}),0}async function du(e,t=process.cwd()){let n=Wi(e,t);if(!n)return 1;let r=e.options.check?$o(n):Qg(n);if(Yn([...r.warnings]),!r.ok)return ti([...r.errors]),1;let o="upload"in r?r.upload.ignored:r.source.ignored;if(o.length>0&&j(k.IGNORED_COUNT(o.length)),!("upload"in r)){let{config:l,totalBytes:c,contentHash:u}=r.source;return pe({task_id:l.slug,valid:!0,total_bytes:c,content_hash:u},()=>Ve.VALID),0}let i=bn(n);if(!i.task_id)return console.error("Error: task_id not found in .ignitify/state.json \u2014 run `ignitify task:create <task-id>` first"),1;let{upload:a}=r;return V0(Q(e),n,i.task_id,a.manifest,a.tar,a.slug)}async function V0(e,t,n,r,o,i){let a=Cr(ue.UPLOADING(i,we(o.length))),l,c;try{[l,c]=await Promise.all([Zd(e,n,r,o),Zt(e).catch(()=>null)])}catch(p){throw a.fail(ue.UPLOAD_FAILED),p}Ea(t,{deployment_id:l.deployment_id});let u=await Sy(e,l.deployment_id,a,l.reused);return u!==0?u:(be.render("task:deploy",{...l,status:hn.READY,task_id:n,slug:i,...c?{tenant_id:c.tenant_id}:{},content_hash:r.contentHash}),0)}async function fu(e,t=process.cwd()){let n=await zi(e,t);if(!n)return 1;Yn([...n.warnings]);let r=Df(e,n.config);if(!r.ok)return console.error(`Error: ${r.error}`),1;let{run:o}=r,i=n.config.slug??ts.default.basename(n.taskDir),a=Q(e);if(Hr(o.payload)>Kt){let h=kf(o.payload,await qr(a));if(h!==null)return console.error(k.ERROR(h)),1}let l=r.deploymentFlag,c=bn(n.taskDir).deployment_id??null,u=l||c?[]:(await ca(a,i)).deployments,p=Cf({flag:l,localStateId:c,serverDeployments:u,taskSlug:i});if(!p.ok)return console.error(`Error: ${p.error}`),1;let m=p.deploymentId;if(p.source!=="flag"){let h=p.source==="server"?p.latest:await ri(a,m),b=Lf(i,m,h);if(b!==null)return console.error(k.ERROR(b)),1}return p.source==="server"&&j(`Using deployment ${m} (resolved from the server \u2014 no local state).`),await J(async()=>{let h;try{h=await ef(a,{deploymentId:m,taskName:i,...o})}catch(S){if(Yt())throw S;let v=ni(S);if(Zs(Ke(S)))return console.error(k.ERROR(k.PAYLOAD_REFUSED_BY_SERVER(await qr(a)))),v!==null&&console.error(v),1;let R=Js(Ke(S))??Qs(Ke(S));if(!R)throw S;return console.error(R),v!==null&&console.error(v),1}if(o.at!==void 0){if(!h.schedule_id)return console.error(h.run_id?`Error: this server does not support scheduling \u2014 it IGNORED --at and ran the job NOW (run ${h.run_id}). Cancel it with 'ignitify run:cancel ${h.run_id}' if that is not what you wanted.`:"Error: this server does not support scheduling (no schedule_id in the response)."),1;if(Yt())return pe(h),0;console.log(`Scheduled: ${h.schedule_id} fires at ${h.fires_at??o.at}`),console.log(`No run exists until it fires. List with 'ignitify schedule:list'; cancel with 'ignitify schedule:cancel ${h.schedule_id}'.`);let S=Or(h.notices);S&&console.log(S);let v=xr(h.capacity);return v&&console.log(v),0}if(!r.wait||!h.run_id)return be.render("task:run",{...h}),0;let b=Yt()?"":Or(h.notices);b&&console.log(b);let g=Yt()?"":xr(h.capacity);return g&&console.log(g),by(a,h.run_id)})}async function pu(e,t=process.cwd()){let{taskId:n,taskDir:r,dirFlag:o}=Qc(e,t);if(!n)return console.error(k.TASK_ID_REQUIRED),1;let i=wo(n);if(!i.ok)return console.error(k.ERROR(k.TASK_ID_INVALID(n,i.reason))),1;let a=e.options.lang??"node";if(!qu(a))return console.error(`Error: --lang must be one of ${qo.join(", ")}${typeof a=="string"?` (got "${a}")`:""}`),1;let l=!e.options["no-init"];if(Re(e,"local")){let c=su(n,r,l,o,a);return c?(console.error(`Error: ${c}`),1):(pe({slug:n,runtime:a,local_dir:r,registered:!1},()=>tt.TASK_CREATED_LOCAL(a,n,r)),j(xt()),0)}return J(async()=>{let c=Q(e),u=await ff(c,n);Ea(r,{task_id:u.task_id,task_resource_id:u.resource_id});let p;if(!e.options["no-scaffold"]){let m=su(n,r,l,o,a);m?console.warn(`Note: skipped scaffolding \u2014 ${m}`):p=r}return be.render("task:create",{...u,slug:n,...p?{local_dir:p}:{}}),j(xt()),0})}async function mu(e,t=process.cwd()){return J(async()=>{let n=Q(e),r=await pf(n,pt(e,Bt));return be.render("task:list",r.tasks),0})}async function hu(e,t=process.cwd(),n=Ie){let r=Bn(e);if(!r)return console.error(k.TASK_ID_REQUIRED),1;let o=await ia(async()=>{let i=Xc(e,t),a=Q(e),{taskId:l,runs:c,deploymentCount:u,runCount:p}=await G0(a,r),m=qg(i);return Pf({taskSlug:r,taskId:l,runs:c,deploymentCount:u,runCount:p,folders:m})});return o===void 0||(Xs(o),!await xe(e,n))?1:J(async()=>{let i=Q(e),l=(await mf(i,r)).deleted;l?j(`${k.TASK_DELETED}: ${l.task_id} (${Lr([["deployments",l.deployments],["runs",l.runs],["vms",l.vms],["forfeited pins",l.forfeited_pins]])})`):j(k.TASK_DELETED);for(let c of o.unlinkDirs){let u=Jc(c);try{Ty.default.rmSync(u,{recursive:!0,force:!0}),j(`${k.TASK_LINK_REMOVED}: ${u}`)}catch(p){console.error(k.TASK_LINK_NOT_REMOVED(u,Ke(p)))}}return pe({plan:zn(o),deleted:l??null}),0})}f();async function gu(e){return J(async()=>{let t=Q(e),n=await hf(t,pt(e,Bt));return be.render("deployment:list",n),0})}async function yu(e){let t=qe(e,"deployment-id");return t?J(async()=>{let n=Q(e);return be.render("deployment:get",await yf(n,t)),0}):1}async function _u(e,t=Ie){let n=qe(e,"deployment-id");return n?J(async()=>{let r=Q(e);if(j(`Will soft-delete deployment ${n} and all its runs (cascade).`),!await xe(e,t))return 1;let o=await _f(r,n);pe(o);let i=o.deleted;return j(i?`${k.DEPLOY_DELETED}: ${i.deployment_id} (${Lr([["runs",i.runs],["vms",i.vms],["forfeited pins",i.forfeited_pins]])})`:k.DEPLOY_DELETED),0}):1}f();f();var H0=/^\d+$/;function Ry(e,t){if(e===void 0)return{ok:!0,graceMs:void 0};let n=Number(e);return!H0.test(e)||!Number.isSafeInteger(n)?{ok:!1,error:k.GRACE_INVALID(e)}:t?{ok:!1,error:k.GRACE_WITH_FORCE}:{ok:!0,graceMs:n}}async function Eu(e){return J(async()=>{let t=Q(e),n=await oi(t,pt(e,Ss));return be.render("run:list",n.runs),0})}async function Su(e){let t=qe(e,"run-id");return t?J(async()=>{let n=Q(e),r=await Vr(n,t);return Re(e,"full")?console.log(JSON.stringify(r,null,2)):be.render("run:get",r),0}):1}async function bu(e){let t=qe(e,"run-id");return t?J(async()=>{let n=Q(e),r=await Ef(n,t);return process.stdout.write(typeof r?.bytes=="string"?r.bytes:""),r?.truncated===!0&&console.error(`
1318
+ \u26A0 truncated \u2014 ${r.lines??0} line(s) shown; the tail was cut at the size cap.`),0}):1}async function Tu(e,t=Ie){let n=qe(e,"run-id");return n?J(async()=>{let r=Q(e);return j(`Will soft-delete run ${n}.`),await xe(e,t)?(pe(await Sf(r,n)),j(`${k.RUN_DELETED}: ${n}`),0):1}):1}async function Ru(e,t=Ie){let n=qe(e,"run-id");if(!n)return 1;let r=Re(e,"force");return J(async()=>{let o=Ry(_e(e,"grace"),r);if(!o.ok)return console.error(k.ERROR(o.error)),1;let i=o.graceMs,a=Q(e),l=await Vr(a,n);if(l?.status&&qn(l.status))return pe({run_id:n,outcome:Ir.ALREADY_TERMINAL,status:l.status}),j(`Run ${n} is already ${l.status} \u2014 nothing to cancel.`),0;if(j(r?`Will cancel run ${n} immediately (force: destroys the VM even if it is pinned).`:`Will ask run ${n} to stop gracefully; it is killed if it does not finish in time.`),!await xe(e,t))return 1;let c=await bf(a,n,r,i);pe({run_id:n,outcome:c?.cancelled?.draining?Ir.DRAINING:Ir.CANCELLED,...c});let u=c?.cancelled?.prior_state,p=u?` (was ${u})`:"";if(c?.cancelled?.draining){let m=c.cancelled.grace_ms,h=m===void 0?"":` (grace ${m} ms)`;return j(`Run ${n} is stopping${h}${p} \u2014 still RUNNING until it finishes or the grace expires.`),0}return j(`Run cancelled: ${n}${p}`),0})}f();f();function Au(e,t,n){if(e.residency==="pinned"&&!t){let i=e.age_ms!==void 0?(e.age_ms/36e5).toFixed(1):"?";return{refuse:!0,message:`Refusing to delete ${n}: this VM is PINNED (permanent standby, alive ${i}h).
1319
+ Deleting it is exactly what "permanent" protects against \u2014 re-run with --force if you mean it.`}}let r=e.residency==="pinned"?" (PINNED \u2014 --force given)":"",o=e.state==="busy"?" \u2014 BUSY: its in-flight run will FAIL":"";return{refuse:!1,notice:`Will tear down VM ${n}${r}${o}.`}}async function ku(e){return J(async()=>{let t=Q(e),n=pt(e,bs);return Re(e,"pinned")&&(n.residency="pinned"),be.render("vm:list",await Tf(t,n)),0})}async function wu(e){let t=qe(e,"vm-id");return t?J(async()=>{let n=Q(e),r=await ua(n,t);return be.render("vm:get",{...r}),0}):1}async function vu(e,t=Ie){let n=qe(e,"vm-id");if(!n)return 1;let r=Re(e,"force");return J(async()=>{let o=Q(e),i=await ua(o,n),a=Au(i,r,n);if(a.refuse)return console.error(a.message),1;if(j(a.notice),!await xe(e,t))return 1;let l=await Rf(o,n,r);pe(l);let c=l.deleted;return j(c?`VM deleted: ${c.vm_id}${c.failed_runs?` (failed in-flight runs: ${c.failed_runs})`:""}`:"VM deleted"),0})}f();var Ay=ye(require("fs"),1);var q0=e=>e.positionals[1]!==void 0||e.options.value!==void 0||typeof e.options.stdin=="string";async function Iu(e){let t=e.positionals[0];if(!t)return console.error(k.SECRET_SET_USAGE),1;if(q0(e))return console.error(k.SECRET_VALUE_ON_ARGV),1;if(e.options.stdin!==!0)return console.error(k.SECRET_SET_USAGE),1;let n=Ay.default.readFileSync(0,"utf8").replace(/\n$/,"");return n===""?(console.error(k.SECRET_VALUE_EMPTY),1):J(async()=>{let r=Q(e),o=await rf(r,t,n);return pe(o),j(k.SECRET_STORED(t)),0})}async function Nu(e){return J(async()=>{let t=Q(e),n=await of(t);return pe(n,()=>n.secrets.length===0?"(no secrets)":n.secrets.map(r=>`${r.name} ${r.updated_at}`).join(`
1320
+ `)),0})}async function $u(e,t=Ie){let n=e.positionals[0];return n?J(async()=>{let r=Q(e);if(console.error(`Will delete secret ${n}. Its value cannot be read back.`),!await xe(e,t))return 1;let o=await sf(r,n);return pe(o),j(k.SECRET_REMOVED(n)),0}):(console.error(k.SECRET_DELETE_USAGE),1)}f();async function Ou(e){return J(async()=>{let t=Q(e),n=await tf(t);return be.render("schedule:list",n.schedules.map(r=>({...r}))),0})}async function xu(e,t=Ie){let n=qe(e,"schedule-id");return n?J(async()=>{let r=Q(e);if(j(`Will cancel schedule ${n} \u2014 it will never fire.`),!await xe(e,t))return 1;try{await nf(r,n)}catch(o){if(o instanceof ve&&o.status===404)return console.error(`Schedule ${n} was NOT cancelled: not found, already fired, or currently firing.`),1;throw o}return pe({schedule_id:n,cancelled:!0}),j(tt.SCHEDULE_CANCELLED(n)),0}):1}f();var wy=ye(require("fs"),1);var vy=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{};function K0(e,t){let n=e.url;return typeof n!="string"||!n.startsWith("/")?e:{...e,url:`${t.replace(/\/+$/,"")}${n}`}}function B0(e){let{secret:t,...n}=e,r=t===void 0?n:{...n,[tt.HOOK_SECRET_KEY]:z.bold(z.yellow(String(t)))};return`
1321
+ ${z.bold(z.green(tt.HOOK_CREATED_TITLE))}
1322
+ ${ut(r)}
1323
+ `}async function Pu(e){let t=e.positionals[0];if(!t)return console.error(k.HOOK_CREATE_USAGE),1;let n=e.options["task-name"];return typeof n!="string"||n.trim()===""?(console.error(k.HOOK_TASK_NAME_REQUIRED),1):J(async()=>{let r=Q(e),o=K0(vy(await af(r,t,{task_name:n})),r.baseUrl);return console.error(k.HOOK_SECRET_SHOWN_ONCE),console.error(k.HOOK_PAYLOAD_LIMIT(ii(await qr(r)))),pe(o,()=>B0(o)),0})}async function Cu(e){let t=e.positionals[0];return t?J(async()=>{let n=Q(e),r=vy(await lf(n,t,pt(e,Bt))),o=Array.isArray(r.hooks)?r.hooks:[];return pe(r,()=>$t(o)),0}):(console.error(k.HOOK_LIST_USAGE),1)}async function Lu(e,t=Ie){let n=e.positionals[0];return n?J(async()=>{let r=Q(e);return console.error(`Will delete webhook ${n}. A sender that posts to it is refused from then on.`),await xe(e,t)?(pe(await cf(r,n)),j(tt.HOOK_DELETED(n)),0):1}):(console.error(k.HOOK_DELETE_USAGE),1)}async function Du(e){let t=e.positionals[0],n=e.options.clear===!0,r=e.options.url;if(!t||!n&&typeof r!="string")return console.error(k.NOTIFY_SET_USAGE),1;if(e.options.secret!==void 0)return console.error(k.NOTIFY_SECRET_ON_ARGV),1;let o=Y0(e,r!==void 0,n);if(o!==null)return ky(o);let i;return e.options["secret-stdin"]===!0&&(i=wy.default.readFileSync(0,"utf8").replace(/\n$/,""),i==="")?ky(k.NOTIFY_SECRET_EMPTY):J(async()=>{let a=Q(e),l={url:n?null:r};return i!==void 0&&(l.secret=i),pe(await uf(a,t,l)),j(l.url===null?tt.NOTIFY_CLEARED(t):tt.NOTIFY_SET(t,l.url)),0})}function Y0(e,t,n){let r=e.options["secret-stdin"];return t&&n?k.NOTIFY_URL_WITH_CLEAR:typeof r=="string"?k.NOTIFY_SECRET_STDIN_VALUE:t&&r!==!0?k.NOTIFY_URL_NEEDS_SECRET:null}function ky(e){return console.error(k.ERROR(e)),console.error(k.NOTIFY_SET_USAGE),1}f();function Mu(e){return Ts.includes(e)?Rs:Object.hasOwn(Hn,e)?Hn[e]:void 0}function W0(e){return{...e.flags,...Bo}}function z0(e){let t=new Set(Object.keys(Bo));if(e!==void 0&&e.secretArgv!==!0)for(let[n,r]of Object.entries(e.flags))r==="bool"&&t.add(n);return{boolFlags:t}}function Uu(e){return ea([...e],z0(Mu(e[0]??"")))}var X0=e=>e.length>1&&e.startsWith("-")&&!e.startsWith("--");function J0(e,t){let n={...e.options},r={},o=[],i=[];for(let a of e.positionals){if(!X0(a)){i.push(a);continue}let l=a.length===2?fd[a.slice(1)]:void 0;l!==void 0?(n[l]=!0,r[l]=a):t?i.push(a):o.push(a)}return{args:{...e,options:n,positionals:i},typed:r,unknown:o}}function Iy(e,t,n){let{args:r,typed:o}=n,i=W0(t);for(let l of Object.keys(r.options)){if(Object.hasOwn(i,l))continue;let c=o[l];return c!==void 0?k.UNKNOWN_SHORT_FLAG(c,l,e):ta(l,e,Object.keys(t.flags),Object.keys(Bo),dd)}let a=n.unknown[0];return a!==void 0?ei(a,e):t.secretArgv===!0?null:na(e,r,i,t.positionals)}function Ny(e){let t=e[0]??"",n=Mu(t),r=J0(Uu(e),n?.secretArgv===!0),o=r.args,i=Object.hasOwn(Hn,t);if(ra(o)){let l=t===D.HELP?o.positionals[0]:t,c=l!==void 0&&l!==D.HELP&&Mu(l)!==void 0?l:null;return t===D.HELP&&l!==void 0&&l!==D.HELP&&c===null?{kind:"unknown",command:l}:{kind:"help",command:c}}if(Ts.includes(t)){let l=Iy("--version",Rs,r);return l===null?{kind:"version",args:o}:{kind:"error",message:l}}if(!i||n===void 0)return{kind:"unknown",command:t};let a=Iy(t,n,r);return a===null?{kind:"run",command:t,args:o}:{kind:"error",message:a}}function $y(e,t){let n=/^ {2}ignitify (\S+)/,r=[],o=!1;for(let i of e.split(`
1324
+ `)){let a=n.exec(i);a!==null?o=a[1]===t:(i.trim()===""||!i.startsWith(" "))&&(o=!1),o&&r.push(i)}return r.length===0?null:r.join(`
1325
+ `)}async function Q0(e){switch(e.kind){case"help":return console.log((e.command===null?null:$y(k.USAGE,e.command))??k.USAGE),0;case"error":return console.error(k.ERROR(e.message)),1;case"unknown":return console.error(`${k.UNKNOWN_COMMAND}: ${e.command}
1326
+ `),console.error(k.USAGE),1;case"version":return Vd(e.args);case"run":return Z0(e.command,e.args)}}function Z0(e,t){switch(e){case D.HELP:return Promise.resolve(0);case D.TASK_VALIDATE:return lu(t);case D.TASK_GET:return cu(t);case D.TASK_PACK:return uu(t);case D.TASK_DEPLOY:return du(t);case D.TASK_RUN:return fu(t);case D.LOGIN:return ma(t);case D.LOGOUT:return ha(t);case D.WHOAMI:return da(t);case D.QUOTA:return fa(t);case D.USAGE:return ya(t);case D.USAGE_EXPORT:return _a(t);case D.TASK_CREATE:return pu(t);case D.TASK_LIST:return mu(t);case D.TASK_DELETE:return hu(t);case D.DEPLOYMENT_LIST:return gu(t);case D.DEPLOYMENT_GET:return yu(t);case D.DEPLOYMENT_DELETE:return _u(t);case D.RUN_LIST:return Eu(t);case D.RUN_GET:return Su(t);case D.RUN_LOGS:return bu(t);case D.RUN_DELETE:return Tu(t);case D.RUN_CANCEL:return Ru(t);case D.VM_LIST:return ku(t);case D.VM_GET:return wu(t);case D.VM_DELETE:return vu(t);case D.SECRET_SET:return Iu(t);case D.SECRET_LIST:return Nu(t);case D.SECRET_DELETE:return $u(t);case D.SCHEDULE_LIST:return Ou(t);case D.SCHEDULE_CANCEL:return xu(t);case D.HOOK_CREATE:return Pu(t);case D.HOOK_LIST:return Cu(t);case D.HOOK_DELETE:return Lu(t);case D.NOTIFY_SET:return Du(t)}}async function ev(e){let t=Ny(e);return Bs((t.kind==="run"||t.kind==="version")&&t.args.options.json===!0),Q0(t)}function Oy(e,t,n){return!!n.npm_lifecycle_event&&!t?0:e}function xy(e){let t=Uu(e).options["show-log"]===!0;ev(e).then(n=>process.exit(Oy(n,t,process.env)),n=>{Ur(n),process.exit(Oy(1,t,process.env))})}xy(process.argv.slice(2));