@viaalink/caddy-api-client 0.10.0 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,13 +1,32 @@
1
1
  # @viaalink/caddy-api-client
2
2
 
3
3
  TypeScript client for Caddy Admin API with MITMproxy integration.
4
- Maintained by [Viaalink](https://github.com/viaalink).
4
+ Maintained by [Viaalink](https://viaalink.com).
5
+
6
+ > Formerly `@accelerated-software-development/caddy-api-client`. Same API: replace the
7
+ > package name in your `package.json` and imports; subpaths stay the same. The old name is
8
+ > deprecated and its last version (0.10.1) only re-exports this package.
5
9
 
6
10
  Package pages:
7
11
 
8
12
  - npm: https://www.npmjs.com/package/@viaalink/caddy-api-client
9
13
  - Yarn Classic: https://classic.yarnpkg.com/en/package/@viaalink/caddy-api-client
10
14
 
15
+ ## VS Code extension
16
+
17
+ [![VS Marketplace](https://vsmarketplacebadges.dev/version-short/Viaalink.vscode-caddy-tools.svg)](https://marketplace.visualstudio.com/items?itemName=Viaalink.vscode-caddy-tools)
18
+ [![Installs](https://vsmarketplacebadges.dev/installs-short/Viaalink.vscode-caddy-tools.svg)](https://marketplace.visualstudio.com/items?itemName=Viaalink.vscode-caddy-tools)
19
+
20
+ Writing Caddy JSON by hand? **[Caddy Configuration Tools for VS Code](https://marketplace.visualstudio.com/items?itemName=Viaalink.vscode-caddy-tools)** is built on this library: IntelliSense that knows every Caddy handler and matcher, checks with quick fixes for the mistakes Caddy only rejects at load time, caddy-security snippets and wizards, and _Apply File to Running Caddy_ straight from the editor.
21
+
22
+ [![Watch the 2:16 demo on YouTube](https://img.youtube.com/vi/IIfOw6wbDMQ/maxresdefault.jpg)](https://youtu.be/IIfOw6wbDMQ)
23
+
24
+ ▶ **[Watch the demo on YouTube](https://youtu.be/IIfOw6wbDMQ)** (2:16). Everything in it is the real extension against a real Caddy.
25
+
26
+ ```
27
+ ext install Viaalink.vscode-caddy-tools
28
+ ```
29
+
11
30
  ## Features
12
31
 
13
32
  - ✅ **Type-safe Caddy API client** - Full TypeScript support with Zod validation
@@ -1,5 +1,5 @@
1
- export { a6 as CaddyClient, f as CaddyClientOptionsSchema, e as CaddyRouteSchema, l as HealthCheckRouteOptionsSchema, m as HostRouteOptionsSchema, L as LoadBalancerRouteOptionsSchema, P as PathRouteOptionsSchema, k as ServiceRouteOptionsSchema } from '../client-Bf2QoSWQ.js';
2
- export { aJ as ACME_DNS_PROVIDER_MODULE_MAP, aL as AcmeDnsPolicyOptions, aE as AutomaticHttpsConfigOptions, B as BasicAuthRouteOptions, C as CaddyAdapter, x as CertificateManager, z as CertificateWithMetadata, af as ErrorRouteOptions, E as ExpirationCheckResult, ab as FileServerRouteOptions, av as HTTP1_ALPN_PROTOCOLS, au as HTTP2_ALPN_PROTOCOLS, at as HTTP_ALPN_PROTOCOLS, H as HealthRouteOptions, a3 as IframeProxyRouteOptions, aB as InternalFallbackPoliciesOptions, aA as InternalIssuerJson, t as LoadBalancerRouteOptions, L as LoadConfigOptions, ar as MODERN_CIPHER_SUITES, an as MapHandlerOptions, as as RECOMMENDED_CURVES, R as ROUTE_PRIORITIES, ah as RequestBodyHandlerOptions, w as RewriteRouteOptions, A as RotateCertificateOptions, D as RotationResult, S as ServiceRouteOptions, aq as TLS_1_2_CIPHER_SUITES, ap as TLS_1_3_CIPHER_SUITES, ad as TemplatesRouteOptions, aw as TlsConnectionPolicyOptions, al as TracingHandlerOptions, aj as VarsHandlerOptions, a6 as WebSocketProxyRouteOptions, b as addDomainWithAutoTls, c as addDomainWithTls, aH as applyLocalCaInstallTrust, aM as buildAcmeDnsPolicy, aF as buildAutomaticHttpsConfig, aC as buildAutomationPoliciesWithInternalFallback, V as buildBasicAuthHandler, az as buildCompatibleTlsPolicy, $ as buildCompressionHandler, aa as buildDnsRebindingBypassHandler, ag as buildErrorRoute, ac as buildFileServerRoute, N as buildHealthCheckRoute, O as buildHostRoute, Z as buildIframeHeadersHandler, a9 as buildIframePermissiveHandler, a4 as buildIframeProxyRoute, X as buildIngressTagHeadersHandler, Q as buildLoadBalancerRoute, ao as buildMapHandler, a1 as buildMitmproxyRoute, a2 as buildMitmproxyRoutePair, a8 as buildMitmproxyWebSocketRoute, a5 as buildMitmproxyWebUiRoute, ay as buildModernTlsPolicy, P as buildPathRoute, Y as buildProjectIdHeadersHandler, _ as buildRedirectRoute, ai as buildRequestBodyHandler, T as buildReverseProxyHandler, W as buildRewriteHandler, U as buildSecurityHeadersHandler, M as buildServiceRoutes, ae as buildTemplatesRoute, ax as buildTlsConnectionPolicy, am as buildTracingHandler, ak as buildVarsHandler, a7 as buildWebSocketProxyRoute, a0 as buildWwwRedirect, i as calculateRoutePriority, aD as collectExternalHostsFromRoutes, J as createBasicAuthAccount, K as createBasicAuthAccounts, n as createBasicAuthRoute, y as createCertificateManager, k as createHealthRoute, o as createLoadBalancerRoute, q as createRedirectRoute, p as createRewriteRoute, m as createServiceRoute, e as deleteDomain, d as detectAdapter, aG as filterAcmeManagedFromSkip, g as getDomainConfig, F as hashPassword, I as hashPasswordWithCaddy, aI as hostMatchesPattern, j as insertRouteRelative, f as listDomains, a as loadCaddyfile, l as loadConfig, h as removeOldCertificates, aK as resolveAcmeDnsProviderModule, r as rotateCertificate, s as sortRoutes, u as updateDomain, v as validateRouteOrdering, G as verifyPassword } from '../index-BmimANG7.js';
3
- export { C as CaddyClientOptions, k as CaddyRoute, j as CaddyRouteHandler, i as CaddyRouteMatcher, l as HealthCheckRouteOptions, m as HostRouteOptions, P as PathRouteOptions, T as TlsConnectionPolicy } from '../types-DIjkvykh.js';
1
+ export { e as CaddyClient, f as CaddyClientOptionsSchema, k as CaddyRouteSchema, t as HealthCheckRouteOptionsSchema, v as HostRouteOptionsSchema, L as LoadBalancerRouteOptionsSchema, O as PathRouteOptionsSchema, X as ServiceRouteOptionsSchema } from '../client--uI2vvWr.js';
2
+ export { A as ACME_DNS_PROVIDER_MODULE_MAP, a as AcmeDnsPolicyOptions, b as AutomaticHttpsConfigOptions, B as BasicAuthRouteOptions, C as CaddyAdapter, d as CertificateManager, e as CertificateWithMetadata, E as ErrorRouteOptions, f as ExpirationCheckResult, F as FileServerRouteOptions, H as HTTP1_ALPN_PROTOCOLS, g as HTTP2_ALPN_PROTOCOLS, h as HTTP_ALPN_PROTOCOLS, i as HealthRouteOptions, I as IframeProxyRouteOptions, j as InternalFallbackPoliciesOptions, k as InternalIssuerJson, L as LoadBalancerRouteOptions, l as LoadConfigOptions, M as MODERN_CIPHER_SUITES, m as MapHandlerOptions, R as RECOMMENDED_CURVES, n as ROUTE_PRIORITIES, o as RequestBodyHandlerOptions, p as RewriteRouteOptions, q as RotateCertificateOptions, r as RotationResult, S as ServiceRouteOptions, T as TLS_1_2_CIPHER_SUITES, s as TLS_1_3_CIPHER_SUITES, t as TemplatesRouteOptions, u as TlsConnectionPolicyOptions, v as TracingHandlerOptions, V as VarsHandlerOptions, W as WebSocketProxyRouteOptions, w as addDomainWithAutoTls, x as addDomainWithTls, y as applyLocalCaInstallTrust, z as buildAcmeDnsPolicy, D as buildAutomaticHttpsConfig, G as buildAutomationPoliciesWithInternalFallback, J as buildBasicAuthHandler, K as buildCompatibleTlsPolicy, N as buildCompressionHandler, O as buildDnsRebindingBypassHandler, P as buildErrorRoute, Q as buildFileServerRoute, U as buildHealthCheckRoute, X as buildHostRoute, Y as buildIframeHeadersHandler, Z as buildIframePermissiveHandler, _ as buildIframeProxyRoute, $ as buildIngressTagHeadersHandler, a0 as buildLoadBalancerRoute, a1 as buildMapHandler, a2 as buildMitmproxyRoute, a3 as buildMitmproxyRoutePair, a4 as buildMitmproxyWebSocketRoute, a5 as buildMitmproxyWebUiRoute, a6 as buildModernTlsPolicy, a7 as buildPathRoute, a8 as buildProjectIdHeadersHandler, a9 as buildRedirectRoute, aa as buildRequestBodyHandler, ab as buildReverseProxyHandler, ac as buildRewriteHandler, ad as buildSecurityHeadersHandler, ae as buildServiceRoutes, af as buildTemplatesRoute, ag as buildTlsConnectionPolicy, ah as buildTracingHandler, ai as buildVarsHandler, aj as buildWebSocketProxyRoute, ak as buildWwwRedirect, al as calculateRoutePriority, am as collectExternalHostsFromRoutes, an as createBasicAuthAccount, ao as createBasicAuthAccounts, ap as createBasicAuthRoute, aq as createCertificateManager, ar as createHealthRoute, as as createLoadBalancerRoute, at as createRedirectRoute, au as createRewriteRoute, av as createServiceRoute, aw as deleteDomain, ax as detectAdapter, az as filterAcmeManagedFromSkip, aC as getDomainConfig, aD as hashPassword, aE as hashPasswordWithCaddy, aF as hostMatchesPattern, aG as insertRouteRelative, aJ as listDomains, aK as loadCaddyfile, aL as loadConfig, aN as removeOldCertificates, aO as resolveAcmeDnsProviderModule, aP as rotateCertificate, aQ as sortRoutes, aS as updateDomain, aT as validateRouteOrdering, aU as verifyPassword } from '../index-Bgl6uVxd.js';
3
+ export { C as CaddyClientOptions, e as CaddyRoute, f as CaddyRouteHandler, g as CaddyRouteMatcher, n as HealthCheckRouteOptions, o as HostRouteOptions, P as PathRouteOptions, $ as TlsConnectionPolicy } from '../types-WSyYaJZ9.js';
4
4
  import 'zod';
5
- import '../caddy-http-DLxwstYo.js';
5
+ import '../caddy-http-jhg7B7CZ.js';
@@ -1,5 +1,5 @@
1
- import {z as z$1,ZodError}from'zod';import {normalize,isAbsolute,resolve}from'path';import {X509Certificate}from'@peculiar/x509';import {readFile}from'fs/promises';var Mo=Object.defineProperty;var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var Do=(t,e)=>{for(var r in e)Mo(t,r,{get:e[r],enumerable:true});};var j,z,G,re,ne,W,V,Z=S(()=>{j=class t extends Error{constructor(r,n){super(r);this.context=n;this.name="CaddyApiClientError",Object.setPrototypeOf(this,t.prototype);}},z=class t extends j{constructor(r,n){super(r,{errors:n});this.errors=n;this.name="ValidationError",Object.setPrototypeOf(this,t.prototype);}},G=class t extends j{constructor(r,n,i,s,u){super(r,{statusCode:n,responseBody:i,url:s,method:u});this.statusCode=n;this.responseBody=i;this.url=s;this.method=u;this.name="CaddyApiError",Object.setPrototypeOf(this,t.prototype);}},re=class t extends j{constructor(r,n){super(r,{cause:n?.message});this.cause=n;this.name="NetworkError",Object.setPrototypeOf(this,t.prototype);}},ne=class t extends j{constructor(r,n){super(r,{timeoutMs:n});this.timeoutMs=n;this.name="TimeoutError",Object.setPrototypeOf(this,t.prototype);}},W=class t extends j{constructor(r){super(`Domain not found: ${r}`,{domain:r});this.domain=r;this.name="DomainNotFoundError",Object.setPrototypeOf(this,t.prototype);}},V=class t extends j{constructor(r){super(`Domain already exists: ${r}`,{domain:r});this.domain=r;this.name="DomainAlreadyExistsError",Object.setPrototypeOf(this,t.prototype);}};});var Lo,st,zo,$o,No,Fo,ct,qo,Wo,Bo,Uo,Xo,Go,lt,pt,fe,dt=S(()=>{Lo=z$1.object({identifiers:z$1.array(z$1.string()).optional(),issuers:z$1.array(z$1.unknown()).optional()}),st=z$1.union([z$1.number(),z$1.string()]),zo=z$1.object({paths:z$1.array(z$1.string()).optional(),methods:z$1.array(z$1.string()).optional()}),z$1.any(),$o=z$1.any(),z$1.any(),z$1.object({error:z$1.string()}),No=z$1.record(z$1.string(),z$1.unknown()),z$1.any(),z$1.any(),z$1.object({id:z$1.string(),source:z$1.string(),specversion:z$1.string(),type:z$1.string(),time:z$1.string(),datacontenttype:z$1.string().optional(),data:z$1.unknown().optional()}),z$1.string(),z$1.object({Context:z$1.unknown()}),z$1.any(),z$1.object({Network:z$1.string(),Host:z$1.string(),StartPort:z$1.number(),EndPort:z$1.number()}),z$1.any(),z$1.any(),z$1.any(),z$1.unknown(),Fo=z$1.object({interval:z$1.union([z$1.number(),z$1.string()]).optional(),first:z$1.number().optional(),thereafter:z$1.number().optional()}),ct=z$1.object({writer:z$1.unknown().optional(),encoder:z$1.unknown().optional(),core:z$1.unknown().optional(),level:z$1.string().optional(),sampling:Fo.optional(),with_caller:z$1.boolean().optional(),with_caller_skip:z$1.number().optional(),with_stacktrace:z$1.string().optional()}),qo=z$1.object({BaseLog:ct,include:z$1.array(z$1.string()).optional(),exclude:z$1.array(z$1.string()).optional()}),z$1.object({}),z$1.object({}),z$1.object({}),z$1.any(),z$1.any(),Wo=z$1.string(),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.object({}),z$1.any(),z$1.any(),z$1.any(),z$1.object({RWMutex:z$1.unknown()}),z$1.any(),z$1.any(),Bo=z$1.object({persist:z$1.boolean().optional(),load:z$1.unknown().optional(),load_delay:st.optional()}),Uo=z$1.object({public_keys:z$1.array(z$1.string()).optional(),permissions:z$1.array(zo).optional()}),z$1.object({Pattern:z$1.string(),Handler:$o}),Xo=z$1.object({BaseLog:ct}),z$1.object({ID:Wo,New:z$1.any()}),Go=z$1.object({listen:z$1.string().optional(),access_control:z$1.array(z$1.union([Uo,z$1.undefined()])).optional()}),lt=z$1.object({disabled:z$1.boolean().optional(),listen:z$1.string().optional(),enforce_origin:z$1.boolean().optional(),origins:z$1.array(z$1.string()).optional(),config:Bo.optional(),identity:Lo.optional(),remote:Go.optional()}),pt=z$1.object({sink:Xo.optional(),logs:z$1.record(z$1.string(),z$1.union([qo,z$1.undefined()])).optional()}),fe=z$1.object({admin:lt.optional(),logging:pt.optional(),storage:z$1.unknown().optional(),apps:No.optional()});});var ut,mt,Vo,ye,be,Se,xe,Jo,_e,Ce,ae,Re,rr,ht,we,D,ar,ir,cr,B,U,gt,J,ie=S(()=>{ut=z$1.object({per_host:z$1.boolean().optional(),observe_catchall_hosts:z$1.boolean().optional(),otlp:z$1.boolean().optional()}),mt=z$1.object({disable:z$1.boolean().optional(),disable_redirects:z$1.boolean().optional(),disable_certificates:z$1.boolean().optional(),skip:z$1.array(z$1.string()).optional(),skip_certificates:z$1.array(z$1.string()).optional(),ignore_loaded_certificates:z$1.boolean().optional()}),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.any(),Vo=z$1.object({status_code:z$1.array(z$1.number()).optional(),headers:z$1.record(z$1.string(),z$1.array(z$1.string())).optional()}),ye=z$1.string(),z$1.object({expr:z$1.string().optional(),name:z$1.string().optional()}),z$1.any(),z$1.any(),z$1.any(),z$1.object({max_header_bytes:z$1.number().optional()}),be=z$1.object({name:z$1.string().optional()}),Se=z$1.object({ranges:z$1.array(z$1.string()).optional()}),xe=z$1.object({ranges:z$1.array(z$1.string()).optional()}),z$1.any(),z$1.object({ranges:z$1.array(z$1.string()).optional()}),Jo=z$1.array(z$1.string()),z$1.object({}),z$1.object({Request:z$1.unknown().optional(),ShouldLogCredentials:z$1.boolean()}),z$1.any(),z$1.any(),z$1.unknown(),z$1.array(z$1.string()),z$1.array(z$1.string()),_e=z$1.object({name:z$1.string().optional(),pattern:z$1.string()}),z$1.array(z$1.string()),z$1.record(z$1.string(),z$1.array(z$1.string())),z$1.record(z$1.string(),z$1.array(z$1.string())),Ce=z$1.record(z$1.string(),z$1.union([_e,z$1.undefined()])),ae=z$1.string(),Re=z$1.object({handshake_complete:z$1.boolean().optional()}),z$1.object({}),z$1.object({ResponseWriter:z$1.unknown()}),z$1.unknown(),z$1.any(),rr=z$1.array(z$1.any()),z$1.array(rr),ht=z$1.object({default_logger_name:z$1.string().optional(),logger_names:z$1.record(z$1.string(),Jo).optional(),skip_hosts:z$1.array(z$1.string()).optional(),skip_unmapped_hosts:z$1.boolean().optional(),should_log_credentials:z$1.boolean().optional(),trace:z$1.boolean().optional()}),we=z$1.object({error:z$1.string().optional(),status_code:ye.optional()}),z$1.object({status_code:ye.optional(),headers:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),body:z$1.string().optional(),close:z$1.boolean().optional(),abort:z$1.boolean().optional()}),z$1.record(z$1.string(),z$1.any()),z$1.record(z$1.string(),z$1.array(z$1.string())),z$1.record(z$1.string(),z$1.union([_e,z$1.undefined()])),D=z$1.any(),ar=z$1.any(),ir=z$1.any(),z$1.object({MatchRegexp:_e}),cr=z$1.array(ar),B=z$1.object({group:z$1.string().optional(),match:cr.optional(),handle:z$1.array(z$1.unknown()).optional(),terminal:z$1.boolean().optional()}),U=z$1.array(B),gt=z$1.object({routes:U.optional()}),z$1.object({routes:U.optional(),errors:gt.optional()}),J=z$1.object({listen:z$1.array(z$1.string()).optional(),listener_wrappers:z$1.array(z$1.unknown()).optional(),packet_conn_wrappers:z$1.array(z$1.unknown()).optional(),read_timeout:D.optional(),read_header_timeout:D.optional(),write_timeout:D.optional(),idle_timeout:D.optional(),keepalive_interval:D.optional(),keepalive_idle:D.optional(),keepalive_count:z$1.number().optional(),max_header_bytes:z$1.number().optional(),enable_full_duplex:z$1.boolean().optional(),routes:U.optional(),errors:gt.optional(),named_routes:z$1.record(z$1.string(),z$1.union([B,z$1.undefined()])).optional(),tls_connection_policies:ir.optional(),automatic_https:mt.optional(),strict_sni_host:z$1.boolean().optional(),trusted_proxies:z$1.unknown().optional(),client_ip_headers:z$1.array(z$1.string()).optional(),trusted_proxies_strict:z$1.number().optional(),trusted_proxies_unix:z$1.boolean().optional(),logs:ht.optional(),protocols:z$1.array(z$1.string()).optional(),listen_protocols:z$1.array(z$1.array(z$1.string())).optional(),allow_0rtt:z$1.boolean().optional(),metrics:ut.optional()}),z$1.object({match:Vo.optional(),status_code:ye.optional(),routes:U.optional()}),z$1.object({http_port:z$1.number().optional(),https_port:z$1.number().optional(),grace_period:D.optional(),shutdown_delay:D.optional(),servers:z$1.record(z$1.string(),z$1.union([J,z$1.undefined()])).optional(),metrics:ut.optional()});});var ft,yt,dr,bt,St,ur,xt,_t,mr,Ct,fr,br,Rt,_r,I,ve,wt,He,Cr,vt,Rr,Ht,vr,Pr,Pt=S(()=>{ft=z$1.object({smallest:z$1.boolean().optional(),root_common_name:z$1.array(z$1.string()).optional(),any_common_name:z$1.array(z$1.string()).optional()}),yt=z$1.object({subjects:z$1.array(z$1.string()).optional(),issuers:z$1.array(z$1.unknown()).optional(),get_certificate:z$1.array(z$1.unknown()).optional(),must_staple:z$1.boolean().optional(),renewal_window_ratio:z$1.number().optional(),key_type:z$1.string().optional(),storage:z$1.unknown().optional(),on_demand:z$1.boolean().optional(),reuse_private_keys:z$1.boolean().optional(),disable_ocsp_stapling:z$1.boolean().optional(),ocsp_overrides:z$1.record(z$1.string(),z$1.string()).optional()}),dr=z$1.object({ask:z$1.string().optional(),permission:z$1.unknown().optional()}),bt=z$1.object({disabled:z$1.boolean().optional(),alternate_port:z$1.number().optional()}),St=z$1.object({disabled:z$1.boolean().optional(),alternate_port:z$1.number().optional()}),z$1.any(),z$1.any(),z$1.any(),z$1.object({trusted_ca_certs:z$1.array(z$1.string()).optional()}),z$1.object({pem_files:z$1.array(z$1.string()).optional()}),z$1.object({authority:z$1.array(z$1.string()).optional()}),z$1.object({authority:z$1.array(z$1.string()).optional()}),z$1.object({storage:z$1.unknown().optional(),pem_keys:z$1.array(z$1.string()).optional()}),z$1.object({}),z$1.object({sources:z$1.array(z$1.unknown()).optional()}),z$1.object({}),z$1.object({url:z$1.string().optional()}),ur=z$1.number(),xt=z$1.object({serial_number:z$1.array(z$1.string()).optional(),subject_organization:z$1.array(z$1.string()).optional(),public_key_algorithm:ur.optional(),any_tag:z$1.array(z$1.string()).optional(),all_tags:z$1.array(z$1.string()).optional()}),_t=z$1.object({ca:z$1.unknown().optional(),trusted_ca_certs:z$1.array(z$1.string()).optional(),trusted_ca_certs_pem_files:z$1.array(z$1.string()).optional(),trusted_leaf_certs:z$1.array(z$1.string()).optional(),verifiers:z$1.array(z$1.unknown()).optional(),mode:z$1.string().optional()}),z$1.any(),z$1.object({leaf_certs_loaders:z$1.array(z$1.unknown()).optional()}),z$1.any(),z$1.any(),z$1.any(),mr=z$1.object({public_name:z$1.string()}),z$1.unknown().and(z$1.unknown()),z$1.object({provider:z$1.unknown().optional()}),z$1.any(),Ct=z$1.object({certificate:z$1.string(),key:z$1.string(),format:z$1.string().optional(),tags:z$1.array(z$1.string()).optional()}),z$1.array(z$1.string()),z$1.object({files:z$1.array(z$1.string()).optional()}),z$1.object({folders:z$1.array(z$1.string()).optional()}),z$1.object({certificates:z$1.array(z$1.string()).optional()}),z$1.object({certificates:z$1.array(z$1.string()).optional(),storage:z$1.unknown().optional()}),z$1.array(z$1.string()),fr=z$1.object({name:z$1.string().optional(),pattern:z$1.string()}),z$1.object({MatchRegexp:fr}),z$1.object({ranges:z$1.array(z$1.string()).optional(),not_ranges:z$1.array(z$1.string()).optional()}),z$1.object({ranges:z$1.array(z$1.string()).optional()}),z$1.any(),z$1.object({endpoint:z$1.string()}),br=z$1.object({certificate:z$1.string(),key:z$1.string(),tags:z$1.array(z$1.string()).optional()}),z$1.any(),z$1.object({pairs:z$1.array(Ct).optional()}),Rt=z$1.object({capacity:z$1.number().optional()}),z$1.any(),_r=z$1.lazy(()=>z$1.object({Certificate:_r,Tags:z$1.array(z$1.string())})),z$1.array(z$1.string()),I=z$1.any(),ve=z$1.any(),wt=z$1.object({policies:z$1.array(z$1.union([yt,z$1.undefined()])).optional(),on_demand:dr.optional(),ocsp_interval:I.optional(),renew_interval:I.optional(),storage_clean_interval:I.optional()}),He=z$1.object({provider:z$1.unknown().optional(),ttl:I.optional(),propagation_delay:I.optional(),propagation_timeout:I.optional(),resolvers:z$1.array(z$1.string()).optional(),override_domain:z$1.string().optional()}),Cr=z$1.object({ca:z$1.unknown().optional(),insecure_skip_verify:z$1.boolean().optional(),handshake_timeout:I.optional(),server_name:z$1.string().optional(),renegotiation:z$1.string().optional()}),z$1.object({endpoints:z$1.array(z$1.string()).optional(),tls:Cr.optional()}),vt=z$1.object({match:ve.optional(),certificate_selection:xt.optional(),cipher_suites:z$1.array(z$1.string()).optional(),curves:z$1.array(z$1.string()).optional(),alpn:z$1.array(z$1.string()).optional(),protocol_min:z$1.string().optional(),protocol_max:z$1.string().optional(),drop:z$1.boolean().optional(),client_authentication:_t.optional(),default_sni:z$1.string().optional(),fallback_sni:z$1.string().optional(),insecure_secrets_log:z$1.string().optional(),handshake_context:z$1.unknown().optional()}),Rr=z$1.object({configs:z$1.array(z$1.string()).optional(),domains:z$1.array(z$1.string()).optional(),publishers:ve.optional()}),z$1.array(Ct),z$1.object({ca:z$1.string().optional(),lifetime:I.optional(),sign_with_root:z$1.boolean().optional()}),z$1.array(br),Ht=z$1.object({key_source:z$1.unknown().optional(),rotation_interval:I.optional(),max_keys:z$1.number().optional(),disable_rotation:z$1.boolean().optional(),disabled:z$1.boolean().optional()}),vr=z$1.object({configs:z$1.array(mr).optional(),publication:z$1.array(z$1.union([Rr,z$1.undefined()])).optional()}),z$1.object({api_key:z$1.string().optional(),validity_days:z$1.number().optional(),listen_host:z$1.string().optional(),alternate_http_port:z$1.number().optional(),cname_validation:He.optional()}),Pr=z$1.object({http:bt.optional(),"tls-alpn":St.optional(),dns:He.optional(),bind_host:z$1.string().optional(),distributed:z$1.boolean().optional()}),z$1.array(z$1.union([vt,z$1.undefined()])),z$1.object({certificates:ve.optional(),automation:wt.optional(),session_tickets:Ht.optional(),cache:Rt.optional(),disable_ocsp_stapling:z$1.boolean().optional(),disable_storage_check:z$1.boolean().optional(),disable_storage_clean:z$1.boolean().optional(),encrypted_client_hello:vr.optional(),dns:z$1.unknown().optional(),resolvers:z$1.array(z$1.string()).optional()}),z$1.object({ca:z$1.string().optional(),test_ca:z$1.string().optional(),email:z$1.string().optional(),profile:z$1.string().optional(),account_key:z$1.string().optional(),external_account:z$1.object({kid:z$1.string().optional(),hmacEncoded:z$1.string().optional()}).optional(),acme_timeout:I.optional(),challenges:Pr.optional(),trusted_roots_pem_files:z$1.array(z$1.string()).optional(),preferred_chains:ft.optional(),certificate_lifetime:I.optional(),network_proxy:z$1.unknown().optional()});});var se=S(()=>{dt();ie();ie();Pt();});var Ir,jt,kr,Or,At,It=S(()=>{Ir=z$1.object({template_file:z$1.string().optional(),reveal_symlinks:z$1.boolean().optional(),sort:z$1.array(z$1.string()).optional(),file_limit:z$1.number().optional()}),jt=z$1.object({fs:z$1.string().optional(),root:z$1.string().optional(),try_files:z$1.array(z$1.string()).optional(),try_policy:z$1.string().optional(),split_path:z$1.array(z$1.string()).optional()}),kr=z$1.any(),Or=z$1.any(),At=z$1.object({fs:z$1.string().optional(),root:z$1.string().optional(),hide:z$1.array(z$1.string()).optional(),index_names:z$1.array(z$1.string()).optional(),browse:Ir.optional(),canonical_uris:z$1.boolean().optional(),status_code:kr.optional(),pass_thru:z$1.boolean().optional(),precompressed:Or.optional(),precompressed_order:z$1.array(z$1.string()).optional(),etag_file_extensions:z$1.array(z$1.string()).optional()});});var Tr,Er,Pe,Mr,je,kt=S(()=>{Tr=z$1.object({find:z$1.string().optional(),replace:z$1.string().optional(),limit:z$1.number().optional()}),Er=z$1.object({find:z$1.string().optional(),replace:z$1.string().optional()}),Pe=z$1.object({key:z$1.string(),val:z$1.string()}),Mr=z$1.object({key:z$1.string().optional(),search:z$1.string().optional(),search_regexp:z$1.string().optional(),replace:z$1.string().optional()}),je=z$1.object({delete:z$1.array(z$1.string()).optional(),set:z$1.array(Pe).optional(),add:z$1.array(Pe).optional(),replace:z$1.array(Mr).optional(),rename:z$1.array(Pe).optional()}),z$1.object({method:z$1.string().optional(),uri:z$1.string().optional(),strip_path_prefix:z$1.string().optional(),strip_path_suffix:z$1.string().optional(),uri_substring:z$1.array(Tr).optional(),path_regexp:z$1.array(Er).optional(),query:je.optional()});});var Dr,Lr,Ot,Tt=S(()=>{z$1.any(),Dr=z$1.object({Header:z$1.record(z$1.string(),z$1.array(z$1.string()))}),Lr=z$1.any(),Ot=z$1.object({file_root:z$1.string().optional(),mime_types:z$1.array(z$1.string()).optional(),delimiters:z$1.array(z$1.string()).optional(),match:Lr.optional()}),z$1.object({Root:z$1.unknown(),Req:z$1.unknown().optional(),Args:z$1.array(z$1.any()),RespHeader:Dr,CustomFuncs:z$1.array(z$1.record(z$1.string(),z$1.unknown()))});});var zr,Et,Mt=S(()=>{zr=z$1.object({input:z$1.string().optional(),input_regexp:z$1.string().optional(),outputs:z$1.array(z$1.any()).optional()}),Et=z$1.object({source:z$1.string().optional(),destinations:z$1.array(z$1.string()).optional(),mappings:z$1.array(zr).optional(),defaults:z$1.array(z$1.string()).optional()});});var $r,Nr,Fr,Dt,Lt=S(()=>{$r=z$1.object({method:z$1.string().optional(),target:z$1.string().optional()}),Nr=z$1.any(),Fr=z$1.object({HeaderOps:Nr}),Dt=z$1.object({resources:z$1.array($r).optional(),headers:Fr.optional()});});var zt,$t=S(()=>{zt=z$1.object({max_size:z$1.number().optional(),read_timeout:z$1.union([z$1.number(),z$1.string()]).optional(),write_timeout:z$1.union([z$1.number(),z$1.string()]).optional(),set:z$1.string().optional()});});var qr,Nt,Ft=S(()=>{qr=z$1.any(),Nt=z$1.object({handle_response:z$1.array(qr).optional()});});var qt,Wt=S(()=>{qt=z$1.object({span:z$1.string(),span_attributes:z$1.record(z$1.string(),z$1.string()).optional()});});var Bt,Ut=S(()=>{Bt=z$1.object({key:z$1.string().optional(),value:z$1.string().optional(),early:z$1.boolean().optional()});});var Xt,Gt,Ie,Wr,Br,Ur,b,Xr,Gr,Vr,Zr,Vt,Jr,Yr,Kr,Qr,en,tn,Zt=S(()=>{Xt=z$1.object({include:z$1.array(z$1.string()).optional(),exclude:z$1.array(z$1.string()).optional()}),z$1.any(),Gt=z$1.object({dial:z$1.string().optional(),max_requests:z$1.number().optional()}),z$1.object({}),z$1.object({Upstream:Gt.optional(),Network:z$1.string(),Address:z$1.string(),Host:z$1.string(),Port:z$1.string()}),z$1.object({AddrPort:z$1.string()}),Ie=z$1.object({addresses:z$1.array(z$1.string()).optional()}),Wr=z$1.array(z$1.union([Gt,z$1.undefined()])),z$1.any(),z$1.any(),z$1.object({}),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.object({}),z$1.object({weights:z$1.array(z$1.number()).optional()}),z$1.object({choose:z$1.number().optional()}),z$1.object({}),z$1.object({}),z$1.object({}),z$1.object({}),z$1.object({}),z$1.object({}),z$1.object({key:z$1.string().optional(),fallback:z$1.unknown().optional()}),z$1.object({field:z$1.string().optional(),fallback:z$1.unknown().optional()}),Br=z$1.object({ipv4:z$1.boolean().optional(),ipv6:z$1.boolean().optional()}),z$1.object({sources:z$1.array(z$1.unknown()).optional()}),Ur=z$1.any(),b=z$1.any(),Xr=z$1.any(),Gr=z$1.any(),Vr=z$1.any(),Zr=z$1.any(),Vt=z$1.object({status_code:Ur.optional()}),Jr=z$1.object({path:z$1.string().optional(),uri:z$1.string().optional(),upstream:z$1.string().optional(),port:z$1.number().optional(),headers:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),method:z$1.string().optional(),body:z$1.string().optional(),follow_redirects:z$1.boolean().optional(),interval:b.optional(),timeout:b.optional(),passes:z$1.number().optional(),fails:z$1.number().optional(),max_size:z$1.number().optional(),expect_status:z$1.number().optional(),expect_body:z$1.string().optional()}),Yr=z$1.object({fail_duration:b.optional(),max_fails:z$1.number().optional(),unhealthy_request_count:z$1.number().optional(),unhealthy_status:z$1.array(z$1.number()).optional(),unhealthy_latency:b.optional()}),Kr=z$1.object({ca:z$1.unknown().optional(),root_ca_pool:z$1.array(z$1.string()).optional(),root_ca_pem_files:z$1.array(z$1.string()).optional(),client_certificate_file:z$1.string().optional(),client_certificate_key_file:z$1.string().optional(),client_certificate_automate:z$1.string().optional(),insecure_skip_verify:z$1.boolean().optional(),handshake_timeout:b.optional(),server_name:z$1.string().optional(),renegotiation:z$1.string().optional(),except_ports:z$1.array(z$1.string()).optional(),curves:z$1.array(z$1.string()).optional()}),Qr=z$1.object({enabled:z$1.boolean().optional(),probe_interval:b.optional(),max_idle_conns:z$1.number().optional(),max_idle_conns_per_host:z$1.number().optional(),idle_timeout:b.optional()}),en=z$1.object({selection_policy:z$1.unknown().optional(),retries:z$1.number().optional(),try_duration:b.optional(),try_interval:b.optional(),retry_match:Zr.optional()}),tn=z$1.object({active:Jr.optional(),passive:Yr.optional()}),z$1.object({name:z$1.string().optional(),secret:z$1.string().optional(),max_age:b.optional(),fallback:z$1.unknown().optional()}),z$1.object({service:z$1.string().optional(),proto:z$1.string().optional(),name:z$1.string().optional(),refresh:b.optional(),grace_period:b.optional(),resolver:Ie.optional(),dial_timeout:b.optional(),dial_fallback_delay:b.optional(),dial_network:z$1.string().optional()}),z$1.object({name:z$1.string().optional(),port:z$1.string().optional(),refresh:b.optional(),resolver:Ie.optional(),dial_timeout:b.optional(),dial_fallback_delay:b.optional(),versions:Br.optional()}),z$1.object({resolver:Ie.optional(),tls:Kr.optional(),keep_alive:Qr.optional(),compression:z$1.boolean().optional(),max_conns_per_host:z$1.number().optional(),proxy_protocol:z$1.string().optional(),forward_proxy_url:z$1.string().optional(),dial_timeout:b.optional(),dial_fallback_delay:b.optional(),response_header_timeout:b.optional(),expect_continue_timeout:b.optional(),max_response_header_size:z$1.number().optional(),write_buffer_size:z$1.number().optional(),read_buffer_size:z$1.number().optional(),read_timeout:b.optional(),write_timeout:b.optional(),versions:z$1.array(z$1.string()).optional(),local_address:z$1.string().optional(),network_proxy:z$1.unknown().optional()}),z$1.object({transport:z$1.unknown().optional(),circuit_breaker:z$1.unknown().optional(),load_balancing:en.optional(),health_checks:tn.optional(),upstreams:Wr.optional(),dynamic_upstreams:z$1.unknown().optional(),flush_interval:b.optional(),trusted_proxies:z$1.array(z$1.string()).optional(),headers:Xr.optional(),request_buffers:z$1.number().optional(),response_buffers:z$1.number().optional(),stream_timeout:b.optional(),stream_buffer_size:z$1.number().optional(),stream_close_delay:b.optional(),rewrite:Gr.optional(),handle_response:z$1.array(Vr).optional(),verbose_logs:z$1.boolean().optional()});});var nn,Jt=S(()=>{z$1.any(),z$1.object({route_matcher:z$1.string().optional(),portal_name:z$1.string().optional()}),z$1.object({route_matcher:z$1.string().optional(),gatekeeper_name:z$1.string().optional()}),nn=z$1.any(),z$1.object({config:nn.optional(),secrets_managers:z$1.array(z$1.unknown()).optional()});});var ke,sn,cn,ln,pn,dn,un,mn,hn,Yt,Kt,gn,fn,yn,bn,Sn,xn,_n,Cn,Rn,wn,vn,Hn,Pn,Qt=S(()=>{Jt();ke=z$1.object({handler:z$1.literal("authenticator"),portal_name:z$1.string().optional(),route_matcher:z$1.string().optional()}),sn=z$1.object({gatekeeper_name:z$1.string().optional(),route_matcher:z$1.string().optional()}),cn=z$1.object({handler:z$1.literal("authentication"),providers:z$1.object({authorizer:sn})}),z$1.discriminatedUnion("handler",[ke,cn]),ln=z$1.object({realm:z$1.string().optional(),path:z$1.string()}),pn=z$1.object({name:z$1.string(),kind:z$1.literal("local"),params:ln}),dn=z$1.object({address:z$1.string(),port:z$1.number().int().positive().max(65535).optional()}),un=z$1.object({dn:z$1.string(),roles:z$1.array(z$1.string()).optional()}),mn=z$1.object({realm:z$1.string().optional(),servers:z$1.array(dn).optional(),bind_username:z$1.string().optional(),bind_password:z$1.string().optional(),search_base_dn:z$1.string().optional(),search_user_filter:z$1.string().optional(),groups:z$1.array(un).optional()}),hn=z$1.object({name:z$1.string(),kind:z$1.literal("ldap"),params:mn.passthrough()}),Yt=z$1.object({driver:z$1.string().optional(),realm:z$1.string().optional(),client_id:z$1.string().optional(),client_secret:z$1.string().optional(),scopes:z$1.array(z$1.string()).optional(),authorization_url:z$1.string().optional(),token_url:z$1.string().optional()}),z$1.object({name:z$1.string(),kind:z$1.literal("oauth"),params:Yt}),Kt=z$1.object({driver:z$1.string().optional(),realm:z$1.string().optional(),client_id:z$1.string().optional(),client_secret:z$1.string().optional(),metadata_url:z$1.string().optional(),scopes:z$1.array(z$1.string()).optional()}),z$1.object({name:z$1.string(),kind:z$1.literal("oauth"),params:Kt}),gn=z$1.discriminatedUnion("kind",[pn,hn]),fn=z$1.object({name:z$1.string(),kind:z$1.literal("oauth"),params:z$1.union([Yt.passthrough(),Kt.passthrough()])}),yn=z$1.object({theme:z$1.string().optional(),logo_url:z$1.string().optional(),custom_css:z$1.string().optional()}),bn=z$1.object({lifetime:z$1.number().optional(),insecure:z$1.boolean().optional(),same_site:z$1.string().optional()}),Sn=z$1.object({domains:z$1.record(z$1.string(),bn).optional(),path:z$1.string().optional(),lifetime:z$1.number().optional(),insecure:z$1.boolean().optional(),same_site:z$1.string().optional()}),xn=z$1.object({name:z$1.string(),ui:yn.optional(),cookie_config:Sn.optional(),identity_stores:z$1.array(z$1.string()).optional(),identity_providers:z$1.array(z$1.string()).optional(),user_transformer_configs:z$1.array(z$1.record(z$1.string(),z$1.unknown())).optional()}),_n=z$1.object({comment:z$1.string().optional(),conditions:z$1.array(z$1.string()).optional(),action:z$1.enum(["allow","deny"]).optional()}),Cn=z$1.object({token_name:z$1.string().optional(),source:z$1.string().optional()}),Rn=z$1.object({match_type:z$1.string(),uri:z$1.string().optional()}),wn=z$1.object({name:z$1.string(),access_list_rules:z$1.array(_n).optional(),crypto_key_configs:z$1.array(Cn).optional(),bypass_configs:z$1.array(Rn).optional()}),vn=z$1.object({generic:z$1.record(z$1.string(),z$1.unknown()).optional()}),Hn=z$1.object({authentication_portals:z$1.array(xn).optional(),authorization_policies:z$1.array(wn).optional(),credentials:vn.optional(),identity_stores:z$1.array(gn).optional(),identity_providers:z$1.array(fn).optional()}),Pn=z$1.object({driver:z$1.string()}).passthrough(),z$1.object({config:Hn.optional(),secrets_managers:z$1.array(Pn).optional()});});var N,le,to,Oe,oo,ro,jn,An,In,no,L,Te,kn,ao,Ee,Me,io,so,co,De,Le,ze,$e,Ne,Fe,M,On,Tn,En,Mn,Dn,Ln,eo,zn,$n,lo,Nn,Fn,qn,Wn,Bn,Un,Xn,Gn,Vn,Zn,Jn,Yn,Kn,Qn,ea,ta,oa,ra,na,aa,po,K=S(()=>{Z();se();se();It();kt();Tt();Mt();Lt();$t();Ft();Wt();Ut();ie();Zt();Qt();N=z$1.string().min(1,"Domain cannot be empty").regex(/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,"Invalid domain format"),le=z$1.string().regex(/^.+:\d+$/,"Dial address must be in host:port format"),to=z$1.string(),Oe=z$1.enum(["DENY","SAMEORIGIN"]),oo=z$1.enum(["none","www_to_domain","domain_to_www"]),ro=z$1.union([z$1.literal(301),z$1.literal(302),z$1.literal(307),z$1.literal(308)]),z$1.enum(["letsencrypt","zerossl","acme"]),jn=z$1.record(z$1.string(),z$1.array(z$1.string())),An=z$1.record(z$1.string(),z$1.array(z$1.string())),In=z$1.object({host:z$1.array(z$1.string()).optional(),path:z$1.array(z$1.string()).optional(),path_regexp:z$1.object({name:z$1.string().optional(),pattern:z$1.string()}).optional(),method:z$1.array(to).optional(),header:An.optional(),header_regexp:Ce.optional(),query:jn.optional(),client_ip:xe.optional(),remote_ip:Se.optional(),protocol:ae.optional(),tls:Re.optional(),file:jt.optional(),not:z$1.array(z$1.record(z$1.string(),z$1.unknown())).optional(),expression:z$1.string().optional()}),no=z$1.object({handler:z$1.string()}).passthrough(),L=z$1.object({"@id":z$1.string().optional(),match:z$1.array(In).optional(),handle:z$1.array(no).min(1,"Route must have at least one handler"),terminal:z$1.boolean().optional(),priority:z$1.number().int().optional()}),Te=z$1.object({adminUrl:z$1.string().url().optional().default("http://127.0.0.1:2019"),timeout:z$1.number().int().positive().optional().default(5e3)}),kn=z$1.enum(["caddyfile","json","yaml","nginx","apache"]),ao=z$1.object({config:z$1.string().min(1,"Config cannot be empty"),adapter:kn.optional().default("caddyfile")}),Ee=z$1.object({enableHsts:z$1.boolean().optional().default(false),hstsMaxAge:z$1.number().int().positive().optional().default(31536e3),frameOptions:Oe.optional().default("DENY"),enableCompression:z$1.boolean().optional().default(true)}),Me=z$1.object({domain:N,target:z$1.string().min(1,"Target cannot be empty"),targetPort:z$1.number().int().positive().max(65535,"Port must be between 1 and 65535"),enableSecurityHeaders:z$1.boolean().optional().default(true),enableHsts:z$1.boolean().optional().default(false),hstsMaxAge:z$1.number().int().positive().optional().default(31536e3),frameOptions:Oe.optional().default("DENY"),enableCompression:z$1.boolean().optional().default(true),redirectMode:oo.optional().default("none"),redirectStatusCode:ro.optional().default(308),adminUrl:z$1.string().url().optional()}),io=Me.extend({certFile:z$1.string().min(1,"Certificate file path cannot be empty"),keyFile:z$1.string().min(1,"Key file path cannot be empty")}),so=z$1.object({domain:N,target:z$1.string().min(1).optional(),targetPort:z$1.number().int().positive().max(65535).optional(),enableSecurityHeaders:z$1.boolean().optional(),enableHsts:z$1.boolean().optional(),hstsMaxAge:z$1.number().int().positive().optional(),frameOptions:Oe.optional(),enableCompression:z$1.boolean().optional(),redirectMode:oo.optional(),redirectStatusCode:ro.optional(),adminUrl:z$1.string().url().optional()}),co=z$1.object({domain:N,adminUrl:z$1.string().url().optional()}),De=z$1.object({enabled:z$1.boolean(),username:z$1.string().min(1).optional(),passwordHash:z$1.string().min(1).optional(),realm:z$1.string().optional(),routes:z$1.array(z$1.enum(["host","path","tunnel"])).optional()}),Le=z$1.object({host:z$1.string().optional(),path:z$1.string().optional(),pathRouteHost:z$1.string().optional().default("asd.localhost"),dial:le,serviceId:z$1.string().optional().default("unknown"),enableHostRoute:z$1.boolean().optional().default(true),enablePathRoute:z$1.boolean().optional().default(true),stripPrefix:z$1.boolean().optional().default(true),priority:z$1.number().int().optional().default(50),securityHeaders:Ee.optional(),basicAuth:De.optional(),ingressTag:z$1.string().nullable().optional(),iframeOrigin:z$1.string().nullable().optional(),deleteResponseHeaders:z$1.array(z$1.string()).optional(),serviceType:z$1.string().optional(),isTunnelDomain:z$1.boolean().optional().default(false),flushInterval:z$1.number().optional(),projectId:z$1.string().nullable().optional()}),ze=z$1.object({host:z$1.string().min(1),serviceId:z$1.string().min(1),priority:z$1.number().int().optional(),ingressTag:z$1.string().nullable().optional(),dial:z$1.string().min(1).optional(),projectId:z$1.string().nullable().optional()}),$e=z$1.object({host:z$1.string().min(1),dial:le,securityHeaders:Ee.optional(),basicAuth:De.optional(),priority:z$1.number().int().optional(),ingressTag:z$1.string().nullable().optional(),iframeOrigin:z$1.string().nullable().optional(),deleteResponseHeaders:z$1.array(z$1.string()).optional(),serviceId:z$1.string().optional(),serviceType:z$1.string().optional(),flushInterval:z$1.number().optional(),projectId:z$1.string().nullable().optional()}),Ne=z$1.object({path:z$1.string().min(1),host:z$1.string().min(1),dial:le,stripPrefix:z$1.boolean().optional().default(true),securityHeaders:Ee.optional(),basicAuth:De.optional(),priority:z$1.number().int().optional(),ingressTag:z$1.string().nullable().optional(),iframeOrigin:z$1.string().nullable().optional(),deleteResponseHeaders:z$1.array(z$1.string()).optional(),serviceId:z$1.string().optional(),serviceType:z$1.string().optional(),flushInterval:z$1.number().optional(),projectId:z$1.string().nullable().optional()}),Fe=z$1.object({host:z$1.string().min(1),upstreams:z$1.array(le).min(1,"At least one upstream is required"),healthCheckPath:z$1.string().optional().default("/health"),healthCheckInterval:z$1.string().optional().default("10s"),policy:z$1.enum(["first","random","least_conn","round_robin"]).optional().default("first"),priority:z$1.number().int().optional()}),M=z$1.union([z$1.number().int(),z$1.literal("0"),z$1.string().regex(/^-?(\d+(\.\d+)?(ns|us|µs|ms|s|m|h|d))+$/,"Invalid Go duration format. Use units: ns, us, \xB5s, ms, s, m, h, d (e.g., '30s', '1h30m', '1.5d')")]),On=z$1.object({uri:z$1.string().optional(),path:z$1.string().optional(),port:z$1.number().int().positive().max(65535).optional(),headers:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),follow_redirects:z$1.boolean().optional(),interval:M.optional(),timeout:M.optional(),passes:z$1.number().int().positive().optional(),fails:z$1.number().int().positive().optional(),max_size:z$1.number().int().positive().optional(),expect_status:z$1.number().int().min(100).max(599).optional(),expect_body:z$1.string().optional()}),Tn=z$1.object({fail_duration:M.optional(),max_fails:z$1.number().int().positive().optional(),unhealthy_request_count:z$1.number().int().positive().optional(),unhealthy_status:z$1.array(z$1.number().int().min(100).max(599)).optional(),unhealthy_latency:M.optional()}),En=z$1.object({active:On.optional(),passive:Tn.optional()}),Mn=z$1.object({selection_policy:z$1.object({policy:z$1.enum(["first","random","least_conn","round_robin","ip_hash","uri_hash","header","cookie"])}).passthrough().optional(),retries:z$1.number().int().nonnegative().optional(),try_duration:M.optional(),try_interval:M.optional()}),Dn=z$1.object({dial:z$1.string().min(1),max_requests:z$1.number().int().positive().optional()}),Ln=z$1.object({name:z$1.string().optional(),pattern:z$1.string()}),eo=z$1.object({host:z$1.array(z$1.string()).optional(),path:z$1.array(z$1.string()).optional(),path_regexp:z$1.object({name:z$1.string().optional(),pattern:z$1.string()}).optional(),method:z$1.array(to).optional(),header:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),header_regexp:z$1.record(z$1.string(),Ln).optional(),query:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),client_ip:z$1.object({ranges:z$1.array(z$1.string())}).optional(),remote_ip:z$1.object({ranges:z$1.array(z$1.string())}).optional(),protocol:ae.optional(),expression:z$1.string().optional(),tls:z$1.object({handshake_complete:z$1.boolean().optional()}).optional(),file:z$1.object({fs:z$1.string().optional(),root:z$1.string().optional(),try_files:z$1.array(z$1.string()).optional(),try_policy:z$1.enum(["first_exist","first_exist_fallback","smallest_size","largest_size","most_recently_modified"]).optional(),split_path:z$1.array(z$1.string()).optional()}).optional()}),eo.extend({not:z$1.array(z$1.lazy(()=>eo)).optional()}),zn=z$1.object({handler:z$1.literal("reverse_proxy"),upstreams:z$1.array(Dn).optional(),load_balancing:Mn.optional(),health_checks:En.optional(),transport:z$1.object({protocol:z$1.string()}).passthrough().optional(),circuit_breaker:z$1.object({type:z$1.string()}).passthrough().optional(),dynamic_upstreams:z$1.object({source:z$1.string()}).passthrough().optional(),flush_interval:M.optional(),stream_timeout:M.optional(),stream_close_delay:M.optional(),trusted_proxies:z$1.array(z$1.string()).optional(),request_buffers:z$1.number().int().nonnegative().optional(),response_buffers:z$1.number().int().nonnegative().optional(),headers:z$1.object({request:z$1.object({add:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),set:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),delete:z$1.array(z$1.string()).optional()}).optional(),response:z$1.object({add:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),set:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),delete:z$1.array(z$1.string()).optional()}).optional()}).optional(),rewrite:z$1.object({uri:z$1.string().optional(),strip_path_prefix:z$1.string().optional(),strip_path_suffix:z$1.string().optional()}).passthrough().optional(),handle_response:z$1.array(z$1.object({match:z$1.object({status_code:z$1.array(z$1.number().int()).optional()}).passthrough().optional(),routes:z$1.array(z$1.any()).optional()}).passthrough()).optional(),verbose_logs:z$1.boolean().optional()}),$n=z$1.object({handler:z$1.literal("headers"),response:z$1.object({deferred:z$1.boolean().optional(),set:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),add:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),delete:z$1.array(z$1.string()).optional()}).optional(),request:z$1.object({set:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),add:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),delete:z$1.array(z$1.string()).optional()}).optional()}),lo=z$1.union([z$1.number().int(),z$1.string()]).optional(),Nn=z$1.object({handler:z$1.literal("static_response"),status_code:lo,body:z$1.string().optional(),headers:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),close:z$1.boolean().optional(),abort:z$1.boolean().optional()}),Fn=z$1.object({handler:z$1.literal("authentication"),providers:z$1.object({http_basic:z$1.object({accounts:z$1.array(z$1.object({username:z$1.string(),password:z$1.string()})).optional(),realm:z$1.string().optional(),hash:z$1.object({algorithm:z$1.string().optional()}).optional()}).optional()}).optional()}),qn=z$1.object({handler:z$1.literal("rewrite"),uri:z$1.string().optional(),strip_path_prefix:z$1.string().optional(),strip_path_suffix:z$1.string().optional(),uri_substring:z$1.array(z$1.object({find:z$1.string(),replace:z$1.string(),limit:z$1.number().int().optional()})).optional(),query:je.optional()}),Wn=z$1.object({handler:z$1.literal("encode"),encodings:z$1.object({gzip:z$1.object({}).passthrough().optional(),zstd:z$1.object({}).passthrough().optional(),br:z$1.object({}).passthrough().optional()}).passthrough().optional(),prefer:z$1.array(z$1.string()).optional(),minimum_length:z$1.number().int().positive().optional()}),Bn=At.extend({handler:z$1.literal("file_server")}),Un=Ot.extend({handler:z$1.literal("templates")}),Xn=Et.extend({handler:z$1.literal("map")}),Gn=Dt.extend({handler:z$1.literal("push")}),Vn=zt.extend({handler:z$1.literal("request_body")}),Zn=z$1.object({handler:z$1.literal("vars")}).passthrough(),Jn=Nt.extend({handler:z$1.literal("intercept")}),Yn=be.extend({handler:z$1.literal("invoke")}),Kn=qt.extend({handler:z$1.literal("tracing")}),Qn=Bt.extend({handler:z$1.literal("log_append")}),ea=we.extend({handler:z$1.literal("error"),status_code:lo}),ta=Vt.extend({handler:z$1.literal("copy_response")}),oa=Xt.extend({handler:z$1.literal("copy_response_headers")}),ra=z$1.object({handler:z$1.literal("subroute"),routes:z$1.array(z$1.lazy(()=>L)).optional(),errors:z$1.any().optional()}),na=z$1.discriminatedUnion("handler",[zn,$n,Nn,Fn,qn,Wn,Bn,Un,Xn,Gn,Vn,Zn,Jn,Yn,Kn,Qn,ea,ta,oa,ra,ke]),z$1.union([na,no]),aa=z$1.object({address:z$1.string(),num_requests:z$1.number(),fails:z$1.number(),healthy:z$1.boolean()}),po=z$1.array(aa),z$1.object({webPort:z$1.number().int().positive().max(65535).optional().default(8081),proxyPort:z$1.number().int().positive().max(65535).optional().default(8080),listenAddress:z$1.string().optional().default("127.0.0.1"),openBrowser:z$1.boolean().optional().default(true),scripts:z$1.array(z$1.string()).optional(),workingDir:z$1.string().optional()});});function F(t,e){let{baseDir:r,requireWithinBase:n=false}={};if(t.includes(".."))throw new z(`Path traversal detected: "${t}" contains ".." segments`,[{code:"custom",path:["filePath"],message:'Path must not contain ".." traversal segments'}]);let i=normalize(t),s=isAbsolute(i)?i:resolve(r??process.cwd(),i);if(n&&r){let u=resolve(r);if(!s.startsWith(u))throw new z(`Path "${t}" resolves outside allowed directory "${r}"`,[{code:"custom",path:["filePath"],message:"Path must be within the allowed directory"}])}return s}function x(t,e,r){try{return t.parse(e)}catch(n){if(n instanceof ZodError){let i=r?`${r}: ${mo(n)}`:mo(n);throw new z(i,n.errors)}throw n}}function mo(t){if(t.issues.length===1){let e=t.issues[0];return ho(e)}return t.issues.map((e,r)=>`${r+1}. ${ho(e)}`).join("; ")}function ho(t){return `${t.path.length>0?`${t.path.join(".")}: `:""}${t.message}`}var Q=S(()=>{Z();});var qe,go,la,pa,da,ua,P,pe=S(()=>{Z();K();se();Q();qe=fe.extend({logging:z$1.any().optional()}).passthrough(),go=J.passthrough(),la=z$1.record(z$1.string(),go),pa=B.passthrough(),da=z$1.array(pa),ua=z$1.object({version:z$1.string().optional()}).passthrough(),P=class{adminUrl;timeout;origin;constructor(e={}){let r=x(Te,e,"client options");this.adminUrl=r.adminUrl,this.timeout=r.timeout;let n=new URL(this.adminUrl);this.origin=n.origin;}async request(e,r={}){let n=`${this.adminUrl}${e}`,i=(r.method??"GET").toUpperCase(),s=new AbortController,u=setTimeout(()=>s.abort(),this.timeout);try{let m=await fetch(n,{...r,signal:s.signal,headers:{"Content-Type":"application/json",Origin:this.origin,...r.headers}});if(clearTimeout(u),!m.ok){let h=await m.text().catch(()=>"");throw new G(`Caddy API request failed: ${i} ${n} - ${m.status} ${m.statusText}`,m.status,h,n,i)}return m}catch(m){throw clearTimeout(u),m instanceof G?m:m.name==="AbortError"?new ne(`Request to ${e} timed out after ${this.timeout}ms`,this.timeout):new re(`Network request to ${e} failed: ${m.message}`,m)}}async getConfig(){let r=await(await this.request("/config/")).json();return qe.parse(r)}escapeServerName(e){return e.replace(/\./g,"%2E")}async getRoutes(e){let r=this.escapeServerName(e),i=await(await this.request(`/config/apps/http/servers/${r}/routes`)).json(),s=da.safeParse(i);if(!s.success)throw new j(`Invalid routes response from Caddy: ${s.error.message}`);return s.data}async addRoute(e,r){x(L,r,"route");try{let i=await this.getRoutes(e),s=r.match?.[0];if(s&&this.routeExists(i,s))return !1}catch{}let n=this.escapeServerName(e);return await this.request(`/config/apps/http/servers/${n}/routes`,{method:"POST",body:JSON.stringify(r)}),true}async addRoutes(e,r){let n=0,i=0,s=[];try{s=await this.getRoutes(e);}catch{}let u=this.escapeServerName(e);for(let m of r){x(L,m,"route");let h=m.match?.[0];if(h&&this.routeExists(s,h)){i++;continue}await this.request(`/config/apps/http/servers/${u}/routes`,{method:"POST",body:JSON.stringify(m)}),s.push(m),n++;}return {added:n,skipped:i}}routeExists(e,r){return e.some(n=>{let i=n.match?.[0];if(!i)return false;let s=JSON.stringify(i.host)===JSON.stringify(r.host),u=JSON.stringify(i.path)===JSON.stringify(r.path);return s&&u})}async patchRoutes(e,r){r.forEach((i,s)=>x(L,i,`route[${s}]`));let n=this.escapeServerName(e);await this.request(`/config/apps/http/servers/${n}/routes`,{method:"PATCH",body:JSON.stringify(r)});}async removeRoutesByHost(e,r="https_server"){if(!e||typeof e!="string")throw new j("hostname is required and must be a string");let n;try{n=await this.getRoutes(r);}catch{return 0}let i=n.filter(u=>u.match?.[0]?.host?.[0]!==e),s=n.length-i.length;if(s>0)try{await this.patchRoutes(r,i);}catch{return 0}return s}async removeHostFromRoutes(e,r="https_server"){if(!e||typeof e!="string")throw new j("hostname is required and must be a string");let n;try{n=await this.getRoutes(r);}catch{return {stripped:0,dropped:0}}let i=0,s=0,u=false,m=[];for(let h of n){let g=false,C=[];for(let w of h.match??[])if(Array.isArray(w.host)&&w.host.includes(e)){let O=w.host.filter(v=>v!==e);if(g=true,O.length===0)continue;C.push({...w,host:O});}else C.push(w);if(g){if(u=true,C.length===0){s++;continue}m.push({...h,match:C}),i++;}else m.push(h);}if(u)try{await this.patchRoutes(r,m);}catch{return {stripped:0,dropped:0}}return {stripped:i,dropped:s}}async getServers(){let r=await(await this.request("/config/apps/http/servers")).json();return la.parse(r)}async getServerConfig(e){let r=this.escapeServerName(e),i=await(await this.request(`/config/apps/http/servers/${r}`)).json();return go.parse(i)}async patchServer(e){await this.request("/config/apps/http/servers",{method:"PATCH",body:JSON.stringify(e)});}async reload(){await this.request("/load",{method:"POST"});}async getVersion(){let r=await(await this.request("/")).json();return ua.parse(r)}async insertRoute(e,r,n="after-health-checks"){let i=x(L,r,"route"),s=await this.getRoutes(e),u=0;if(n==="after-health-checks"){let h=-1;for(let g=0;g<s.length;g++)s[g].handle?.[0]?.handler==="static_response"&&(h=g);u=h+1;}else n==="end"&&(u=s.length);s.splice(u,0,i);let m=await this.getServerConfig(e);await this.patchServer({[e]:{...m,routes:s}});}async replaceRouteById(e,r,n){let i=x(L,n,"route"),s=await this.getRoutes(e),u=s.findIndex(h=>h["@id"]===r);if(u===-1)return false;s[u]={...i,"@id":r};let m=await this.getServerConfig(e);return await this.patchServer({[e]:{...m,routes:s}}),true}async removeRouteById(e,r){let n=await this.getRoutes(e),i=n.length,s=n.filter(m=>m["@id"]!==r);if(s.length===i)return false;let u=await this.getServerConfig(e);return await this.patchServer({[e]:{...u,routes:s}}),true}async stop(){await this.request("/stop",{method:"POST"});}async getUpstreams(){let r=await(await this.request("/reverse_proxy/upstreams")).json();return po.parse(r)}async adapt(e,r="caddyfile"){let n=x(ao,{config:e,adapter:r},"adapt options"),s=await(await this.request("/adapt",{method:"POST",headers:{"Content-Type":"text/caddyfile"},body:JSON.stringify({config:n.config,adapter:n.adapter})})).json();return qe.parse(s)}async applyConfig(e){x(qe,e,"config"),await this.request("/load",{method:"POST",body:JSON.stringify(e)});}};});function Il(t){let e=x(Le,t,"buildServiceRoutes options"),r=[],n=e.basicAuth?.routes??["host","path","tunnel"],i=s=>{if(!e.basicAuth)return;let u=e.isTunnelDomain?"tunnel":s;return n.includes(u)?e.basicAuth:void 0};if(e.enableHostRoute&&e.host&&(r.push(fo({host:e.host,serviceId:e.serviceId??"unknown",priority:e.priority!==void 0?e.priority+1e3:void 0,ingressTag:e.ingressTag,projectId:e.projectId})),r.push(We({host:e.host,dial:e.dial,securityHeaders:e.securityHeaders,basicAuth:i("host"),priority:e.priority,ingressTag:e.ingressTag,iframeOrigin:e.iframeOrigin,deleteResponseHeaders:e.deleteResponseHeaders,serviceId:e.serviceId,serviceType:e.serviceType,flushInterval:e.flushInterval,projectId:e.projectId}))),e.enablePathRoute&&e.path&&e.path!=="/"){let s=e.pathRouteHost??"asd.localhost";r.push(fo({host:s,serviceId:e.serviceId??"unknown",priority:e.priority!==void 0?e.priority+1e3:void 0,ingressTag:e.ingressTag,projectId:e.projectId})),r.push(ma({path:e.path,host:s,dial:e.dial,stripPrefix:e.stripPrefix??true,securityHeaders:e.securityHeaders,basicAuth:i("path"),priority:e.priority,ingressTag:e.ingressTag,iframeOrigin:e.iframeOrigin,deleteResponseHeaders:e.deleteResponseHeaders,serviceId:e.serviceId,serviceType:e.serviceType,flushInterval:e.flushInterval,projectId:e.projectId}));}return r}function fo(t){let e=x(ze,t,"buildHealthCheckRoute options"),r=[];e.ingressTag&&r.push(Be(e.ingressTag)),e.projectId&&r.push(Ue(e.projectId)),r.push({handler:"headers",response:{set:{"X-ASD-Health":["ok"],"X-ASD-Service-ID":[e.serviceId]}}}),e.dial?r.push({handler:"reverse_proxy",upstreams:[{dial:e.dial}],headers:{request:{set:{"X-Forwarded-Proto":["{http.request.scheme}"],"X-Forwarded-Host":["{http.request.host}"],"X-Forwarded-Port":["{http.request.port}"]}}}}):r.push({handler:"static_response",body:`{"status":"ok","service":"${e.serviceId}","timestamp":"{http.time.now.unix}"}`,status_code:200,headers:{"Content-Type":["application/json"]}});let n={match:[{host:[e.host],path:["/asd/healthcheck"]}],handle:r,terminal:true};return e.priority!==void 0&&(n.priority=e.priority),n}function We(t){let e=x($e,t,"buildHostRoute options"),r=[];e.ingressTag&&r.push(Be(e.ingressTag)),e.projectId&&r.push(Ue(e.projectId)),e.iframeOrigin&&r.push(Co(e.iframeOrigin));let n=_o(e.serviceId,e.serviceType);n&&r.push(n),e.securityHeaders&&r.push(bo(e.securityHeaders)),e.basicAuth?.enabled&&e.basicAuth.username&&e.basicAuth.passwordHash&&r.push(So(e.basicAuth)),r.push(yo(e.dial,{deleteResponseHeaders:e.deleteResponseHeaders,flushInterval:e.flushInterval}));let i={match:[{host:[e.host]}],handle:r,terminal:true};return e.priority!==void 0&&(i.priority=e.priority),i}function ma(t){let e=x(Ne,t,"buildPathRoute options"),r=[];e.ingressTag&&r.push(Be(e.ingressTag)),e.projectId&&r.push(Ue(e.projectId)),e.iframeOrigin&&r.push(Co(e.iframeOrigin));let n=_o(e.serviceId,e.serviceType);n&&r.push(n),e.stripPrefix&&r.push(xo(e.path)),e.securityHeaders&&r.push(bo(e.securityHeaders)),e.basicAuth?.enabled&&e.basicAuth.username&&e.basicAuth.passwordHash&&r.push(So(e.basicAuth)),r.push(yo(e.dial,{deleteResponseHeaders:e.deleteResponseHeaders,flushInterval:e.flushInterval}));let i={match:[{host:[e.host],path:[e.path.endsWith("*")?e.path:`${e.path}*`]}],handle:r,terminal:true};return e.priority!==void 0&&(i.priority=e.priority),i}function kl(t){let e=x(Fe,t,"buildLoadBalancerRoute options"),r={match:[{host:[e.host]}],handle:[{handler:"reverse_proxy",upstreams:e.upstreams.map(n=>({dial:n})),transport:{protocol:"http"},...e.policy!=="first"&&{load_balancing:{selection_policy:{policy:e.policy}}},health_checks:{active:{path:e.healthCheckPath,interval:e.healthCheckInterval,timeout:"5s",expect_status:200}}}],terminal:true};return e.priority!==void 0&&(r.priority=e.priority),r}function yo(t,e){let r=typeof t=="string"&&t.startsWith("https://"),n=r?t.replace("https://",""):t,i=e?.tls??r,s={handler:"reverse_proxy",upstreams:[{dial:n}]};if(i){let u={};e?.tlsServerName&&(u.server_name=e.tlsServerName),e?.tlsInsecureSkipVerify===true&&(u.insecure_skip_verify=true),e?.tlsTrustedCACerts&&(u.ca=e.tlsTrustedCACerts),s.transport={protocol:"http",tls:u};}else s.transport={protocol:"http"};return e?.deleteResponseHeaders&&e.deleteResponseHeaders.length>0&&(s.headers={response:{delete:e.deleteResponseHeaders}}),e?.flushInterval!==void 0&&(s.flush_interval=e.flushInterval),s}function bo(t){let e={"X-Frame-Options":[t.frameOptions??"DENY"],"X-Content-Type-Options":["nosniff"],"X-XSS-Protection":["1; mode=block"]};return t.enableHsts&&(e["Strict-Transport-Security"]=[`max-age=${t.hstsMaxAge??31536e3}; includeSubDomains`]),{handler:"headers",response:{set:e}}}function So(t){let e=t.accounts??(t.username&&t.passwordHash?[{username:t.username,password:t.passwordHash}]:[]);if(e.length===0)throw new Error("Basic auth requires at least one account (username + passwordHash or accounts array)");let r={handler:"authentication",providers:{http_basic:{accounts:e,realm:t.realm??"Restricted Area"}}};return t.hash?.algorithm&&t.hash.algorithm!=="bcrypt"&&r.providers?.http_basic&&(r.providers.http_basic.hash={algorithm:t.hash.algorithm}),r}function xo(t){return {handler:"rewrite",strip_path_prefix:t}}function _o(t,e){let r={};return t&&(r["X-ASD-Service-ID"]=[t]),e&&(r["X-ASD-Service-Type"]=[e]),Object.keys(r).length?{handler:"headers",response:{set:r}}:null}function Be(t){return {handler:"headers",response:{set:{"X-ASD-Ingress":[t]}}}}function Ue(t){return {handler:"headers",response:{set:{"X-ASD-Project":[t]}}}}function Co(t="*"){let e=t.trim();return {handler:"headers",response:{set:{...e==="*"||ha.test(e)?{"Access-Control-Allow-Origin":[e],"Access-Control-Allow-Methods":["GET","POST","PUT","DELETE","OPTIONS"],"Access-Control-Allow-Headers":["Content-Type","Authorization"]}:{},"Content-Security-Policy":[`frame-ancestors ${t}`]}}}}function Xe(t){let e=t.statusCode??(t.permanent!==false?308:307);return {"@id":t.id,match:[{host:[t.fromHost]}],handle:[{handler:"static_response",status_code:e,headers:{Location:[`https://${t.toHost}{http.request.uri}`]}}],terminal:true}}function Ge(t){let e={};return t?.gzip!==false&&(e.gzip={}),t?.zstd!==false&&(e.zstd={}),t?.brotli===true&&(e.br={}),{handler:"encode",encodings:e}}function Ve(t){let{domain:e,mode:r,permanent:n=true,priority:i}=t,s=e.replace(/^www\./,"");return r==="www-to-domain"?{"@id":`redirect-www-to-domain-${s}`,match:[{host:[`www.${s}`]}],handle:[{handler:"static_response",status_code:n?301:302,headers:{Location:[`https://${s}{http.request.uri}`]}}],terminal:true,...i!==void 0&&{priority:i}}:{"@id":`redirect-domain-to-www-${s}`,match:[{host:[s]}],handle:[{handler:"static_response",status_code:n?301:302,headers:{Location:[`https://www.${s}{http.request.uri}`]}}],terminal:true,...i!==void 0&&{priority:i}}}function ga(t){let e=t.mitmproxyPort??8080,r=`${t.mitmproxyHost}:${e}`,n=We({host:t.host,dial:r,priority:t.priority});return t.id&&(n["@id"]=t.id),n}function Ol(t){let e=`${t.backendHost}:${t.backendPort}`,r=t.mitmproxyPort??8080,n=We({host:t.host,dial:e,priority:t.priority});n["@id"]=t.routeId;let i=ga({host:t.host,mitmproxyHost:t.mitmproxyHost,mitmproxyPort:r,backendHost:t.backendHost,backendPort:t.backendPort,id:t.routeId,priority:t.priority});return {direct:n,proxied:i}}function fa(t){let e=`${t.upstreamHost}:${t.upstreamPort}`,r=t.routeId??`iframe_proxy_${t.pathPrefix.replace(/\//g,"_")}`,n=t.iframeEmbed!==false,i=[xo(t.pathPrefix)];n&&i.push(ba());let s={handler:"reverse_proxy",transport:{protocol:"http"},upstreams:[{dial:e}]};return t.overrideHost&&(s.headers={request:{set:{Host:[t.overrideHost],Origin:[`http://${t.overrideHost}/`]}}}),i.push(s),{"@id":r,match:[{path:[t.pathPrefix,`${t.pathPrefix}/*`]}],handle:i,terminal:true}}function Tl(t){let e=t.mitmproxyWebPort??8081;return fa({pathPrefix:t.pathPrefix,upstreamHost:t.mitmproxyHost,upstreamPort:e,routeId:t.routeId,iframeEmbed:t.iframeEmbed,overrideHost:`127.0.0.1:${e}`})}function ya(t){let e=`${t.upstreamHost}:${t.upstreamPort}`,r=t.routeId??`ws_proxy_${t.path.replace(/\//g,"_")}`,n={handler:"reverse_proxy",transport:{protocol:"http"},upstreams:[{dial:e}]};return t.overrideHost&&(n.headers={request:{set:{Host:[t.overrideHost],Origin:[`http://${t.overrideHost}/`]}}}),{"@id":r,match:[{path:[t.path]}],handle:[n],terminal:true}}function El(t){let e=t.mitmproxyWebPort??8081;return ya({path:t.path??"/updates",upstreamHost:t.mitmproxyHost,upstreamPort:e,routeId:t.routeId,overrideHost:`127.0.0.1:${e}`})}function ba(t){let e=t?.deleteHeaders??["X-Frame-Options","Content-Security-Policy","X-Xss-Protection"],r=t?.corsOrigin??"*";return {handler:"headers",response:{deferred:true,delete:e,set:{"Access-Control-Allow-Origin":[r],"X-Frame-Options":["ALLOWALL"]}}}}function Ml(t){return {handler:"headers",request:{set:{Host:[t.targetHost],Origin:[`http://${t.targetHost}/`]}}}}function Dl(t){let e={handler:"file_server",root:t.root};t.indexNames&&t.indexNames.length>0&&(e.index_names=t.indexNames),t.browse&&(e.browse=t.browseTemplate?{template_file:t.browseTemplate}:{}),t.hidePatterns&&t.hidePatterns.length>0&&(e.hide=t.hidePatterns),t.precompressed&&(e.precompressed={gzip:{},br:{}});let r={match:[{path:[t.path]}],handle:[e],terminal:true};return t.id&&(r["@id"]=t.id),t.priority!==void 0&&(r.priority=t.priority),r}function Ll(t){let e={handler:"templates",file_root:t.fileRoot};t.mimeTypes&&t.mimeTypes.length>0&&(e.mime_types=t.mimeTypes),t.delimiters&&(e.delimiters=t.delimiters);let r={handler:"file_server",root:t.fileRoot},n={match:[{path:[t.path]}],handle:[e,r],terminal:true};return t.id&&(n["@id"]=t.id),t.priority!==void 0&&(n.priority=t.priority),n}function zl(t){let e={handler:"error",status_code:String(t.statusCode)};t.message&&(e.error=t.message);let r={handle:[e],terminal:true};if(t.match){let n={};t.match.path&&(n.path=t.match.path),t.match.host&&(n.host=t.match.host),r.match=[n];}return t.id&&(r["@id"]=t.id),t.priority!==void 0&&(r.priority=t.priority),r}function $l(t){return {handler:"request_body",max_size:t.maxSize}}function Nl(t){return {handler:"vars",...t.vars}}function Fl(t){let e={handler:"tracing"};return t?.span&&(e.span=t.span),e}function ql(t){let e={handler:"map",source:t.source,destinations:t.destinations,mappings:t.mappings};return t.defaults&&(e.defaults=t.defaults),e}var ha,Ze=S(()=>{K();Q();ha=/^https?:\/\/[^\s*/]+$/;});function de(t){let e=new X509Certificate(t);return {serialNumber:e.serialNumber,subject:e.subject,issuer:e.issuer,notBefore:e.notBefore,notAfter:e.notAfter}}function te(t,e){let r=new Date().toISOString().replace(/[:-]/g,"").replace("T","").slice(0,14);return `${t}-${e}-${r}`}function Je(t){let e=[],r=t.split(`
1
+ import {z as z$1,ZodError}from'zod';import {normalize,isAbsolute,resolve}from'path';import {X509Certificate}from'@peculiar/x509';import {readFile}from'fs/promises';var Do=Object.defineProperty;var S=(t,e)=>()=>(t&&(e=t(t=0)),e);var Lo=(t,e)=>{for(var r in e)Do(t,r,{get:e[r],enumerable:true});};var j,z,G,re,ne,W,V,Z=S(()=>{j=class t extends Error{constructor(r,n){super(r);this.context=n;this.name="CaddyApiClientError",Object.setPrototypeOf(this,t.prototype);}},z=class t extends j{constructor(r,n){super(r,{errors:n});this.errors=n;this.name="ValidationError",Object.setPrototypeOf(this,t.prototype);}},G=class t extends j{constructor(r,n,i,s,u){super(r,{statusCode:n,responseBody:i,url:s,method:u});this.statusCode=n;this.responseBody=i;this.url=s;this.method=u;this.name="CaddyApiError",Object.setPrototypeOf(this,t.prototype);}},re=class t extends j{constructor(r,n){super(r,{cause:n?.message});this.cause=n;this.name="NetworkError",Object.setPrototypeOf(this,t.prototype);}},ne=class t extends j{constructor(r,n){super(r,{timeoutMs:n});this.timeoutMs=n;this.name="TimeoutError",Object.setPrototypeOf(this,t.prototype);}},W=class t extends j{constructor(r){super(`Domain not found: ${r}`,{domain:r});this.domain=r;this.name="DomainNotFoundError",Object.setPrototypeOf(this,t.prototype);}},V=class t extends j{constructor(r){super(`Domain already exists: ${r}`,{domain:r});this.domain=r;this.name="DomainAlreadyExistsError",Object.setPrototypeOf(this,t.prototype);}};});var zo,ct,$o,No,Fo,qo,lt,Wo,Bo,Uo,Xo,Go,Vo,pt,dt,fe,ut=S(()=>{zo=z$1.object({identifiers:z$1.array(z$1.string()).optional(),issuers:z$1.array(z$1.unknown()).optional()}),ct=z$1.union([z$1.number(),z$1.string()]),$o=z$1.object({paths:z$1.array(z$1.string()).optional(),methods:z$1.array(z$1.string()).optional()}),z$1.any(),No=z$1.any(),z$1.any(),z$1.object({error:z$1.string()}),Fo=z$1.record(z$1.string(),z$1.unknown()),z$1.any(),z$1.any(),z$1.object({id:z$1.string(),source:z$1.string(),specversion:z$1.string(),type:z$1.string(),time:z$1.string(),datacontenttype:z$1.string().optional(),data:z$1.unknown().optional()}),z$1.string(),z$1.object({Context:z$1.unknown()}),z$1.any(),z$1.object({Network:z$1.string(),Host:z$1.string(),StartPort:z$1.number(),EndPort:z$1.number()}),z$1.any(),z$1.any(),z$1.any(),z$1.unknown(),qo=z$1.object({interval:z$1.union([z$1.number(),z$1.string()]).optional(),first:z$1.number().optional(),thereafter:z$1.number().optional()}),lt=z$1.object({writer:z$1.unknown().optional(),encoder:z$1.unknown().optional(),core:z$1.unknown().optional(),level:z$1.string().optional(),sampling:qo.optional(),with_caller:z$1.boolean().optional(),with_caller_skip:z$1.number().optional(),with_stacktrace:z$1.string().optional()}),Wo=z$1.object({BaseLog:lt,include:z$1.array(z$1.string()).optional(),exclude:z$1.array(z$1.string()).optional()}),z$1.object({}),z$1.object({}),z$1.object({}),z$1.any(),z$1.any(),Bo=z$1.string(),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.object({}),z$1.any(),z$1.any(),z$1.any(),z$1.object({RWMutex:z$1.unknown()}),z$1.any(),z$1.any(),Uo=z$1.object({persist:z$1.boolean().optional(),load:z$1.unknown().optional(),load_delay:ct.optional()}),Xo=z$1.object({public_keys:z$1.array(z$1.string()).optional(),permissions:z$1.array($o).optional()}),z$1.object({Pattern:z$1.string(),Handler:No}),Go=z$1.object({BaseLog:lt}),z$1.object({ID:Bo,New:z$1.any()}),Vo=z$1.object({listen:z$1.string().optional(),access_control:z$1.array(z$1.union([Xo,z$1.undefined()])).optional()}),pt=z$1.object({disabled:z$1.boolean().optional(),listen:z$1.string().optional(),enforce_origin:z$1.boolean().optional(),origins:z$1.array(z$1.string()).optional(),config:Uo.optional(),identity:zo.optional(),remote:Vo.optional()}),dt=z$1.object({sink:Go.optional(),logs:z$1.record(z$1.string(),z$1.union([Wo,z$1.undefined()])).optional()}),fe=z$1.object({admin:pt.optional(),logging:dt.optional(),storage:z$1.unknown().optional(),apps:Fo.optional()});});var mt,ht,Zo,ye,be,Se,xe,Yo,_e,Ce,ae,Re,nr,gt,we,D,ir,sr,lr,B,U,ft,J,ie=S(()=>{mt=z$1.object({per_host:z$1.boolean().optional(),observe_catchall_hosts:z$1.boolean().optional(),otlp:z$1.boolean().optional()}),ht=z$1.object({disable:z$1.boolean().optional(),disable_redirects:z$1.boolean().optional(),disable_certificates:z$1.boolean().optional(),skip:z$1.array(z$1.string()).optional(),skip_certificates:z$1.array(z$1.string()).optional(),ignore_loaded_certificates:z$1.boolean().optional()}),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.any(),Zo=z$1.object({status_code:z$1.array(z$1.number()).optional(),headers:z$1.record(z$1.string(),z$1.array(z$1.string())).optional()}),ye=z$1.string(),z$1.object({expr:z$1.string().optional(),name:z$1.string().optional()}),z$1.any(),z$1.any(),z$1.any(),z$1.object({max_header_bytes:z$1.number().optional()}),be=z$1.object({name:z$1.string().optional()}),Se=z$1.object({ranges:z$1.array(z$1.string()).optional()}),xe=z$1.object({ranges:z$1.array(z$1.string()).optional()}),z$1.any(),z$1.object({ranges:z$1.array(z$1.string()).optional()}),Yo=z$1.array(z$1.string()),z$1.object({}),z$1.object({Request:z$1.unknown().optional(),ShouldLogCredentials:z$1.boolean()}),z$1.any(),z$1.any(),z$1.unknown(),z$1.array(z$1.string()),z$1.array(z$1.string()),_e=z$1.object({name:z$1.string().optional(),pattern:z$1.string()}),z$1.array(z$1.string()),z$1.record(z$1.string(),z$1.array(z$1.string())),z$1.record(z$1.string(),z$1.array(z$1.string())),Ce=z$1.record(z$1.string(),z$1.union([_e,z$1.undefined()])),ae=z$1.string(),Re=z$1.object({handshake_complete:z$1.boolean().optional()}),z$1.object({}),z$1.object({ResponseWriter:z$1.unknown()}),z$1.unknown(),z$1.any(),nr=z$1.array(z$1.any()),z$1.array(nr),gt=z$1.object({default_logger_name:z$1.string().optional(),logger_names:z$1.record(z$1.string(),Yo).optional(),skip_hosts:z$1.array(z$1.string()).optional(),skip_unmapped_hosts:z$1.boolean().optional(),should_log_credentials:z$1.boolean().optional(),trace:z$1.boolean().optional()}),we=z$1.object({error:z$1.string().optional(),status_code:ye.optional()}),z$1.object({status_code:ye.optional(),headers:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),body:z$1.string().optional(),close:z$1.boolean().optional(),abort:z$1.boolean().optional()}),z$1.record(z$1.string(),z$1.any()),z$1.record(z$1.string(),z$1.array(z$1.string())),z$1.record(z$1.string(),z$1.union([_e,z$1.undefined()])),D=z$1.any(),ir=z$1.any(),sr=z$1.any(),z$1.object({MatchRegexp:_e}),lr=z$1.array(ir),B=z$1.object({group:z$1.string().optional(),match:lr.optional(),handle:z$1.array(z$1.unknown()).optional(),terminal:z$1.boolean().optional()}),U=z$1.array(B),ft=z$1.object({routes:U.optional()}),z$1.object({routes:U.optional(),errors:ft.optional()}),J=z$1.object({listen:z$1.array(z$1.string()).optional(),listener_wrappers:z$1.array(z$1.unknown()).optional(),packet_conn_wrappers:z$1.array(z$1.unknown()).optional(),read_timeout:D.optional(),read_header_timeout:D.optional(),write_timeout:D.optional(),idle_timeout:D.optional(),keepalive_interval:D.optional(),keepalive_idle:D.optional(),keepalive_count:z$1.number().optional(),max_header_bytes:z$1.number().optional(),enable_full_duplex:z$1.boolean().optional(),routes:U.optional(),errors:ft.optional(),named_routes:z$1.record(z$1.string(),z$1.union([B,z$1.undefined()])).optional(),tls_connection_policies:sr.optional(),automatic_https:ht.optional(),strict_sni_host:z$1.boolean().optional(),trusted_proxies:z$1.unknown().optional(),client_ip_headers:z$1.array(z$1.string()).optional(),trusted_proxies_strict:z$1.number().optional(),trusted_proxies_unix:z$1.boolean().optional(),logs:gt.optional(),protocols:z$1.array(z$1.string()).optional(),listen_protocols:z$1.array(z$1.array(z$1.string())).optional(),allow_0rtt:z$1.boolean().optional(),metrics:mt.optional()}),z$1.object({match:Zo.optional(),status_code:ye.optional(),routes:U.optional()}),z$1.object({http_port:z$1.number().optional(),https_port:z$1.number().optional(),grace_period:D.optional(),shutdown_delay:D.optional(),servers:z$1.record(z$1.string(),z$1.union([J,z$1.undefined()])).optional(),metrics:mt.optional()});});var yt,bt,ur,St,xt,mr,_t,Ct,hr,Rt,yr,Sr,wt,Cr,k,ve,vt,He,Rr,Ht,wr,Pt,Hr,jr,jt=S(()=>{yt=z$1.object({smallest:z$1.boolean().optional(),root_common_name:z$1.array(z$1.string()).optional(),any_common_name:z$1.array(z$1.string()).optional()}),bt=z$1.object({subjects:z$1.array(z$1.string()).optional(),issuers:z$1.array(z$1.unknown()).optional(),get_certificate:z$1.array(z$1.unknown()).optional(),must_staple:z$1.boolean().optional(),renewal_window_ratio:z$1.number().optional(),key_type:z$1.string().optional(),storage:z$1.unknown().optional(),on_demand:z$1.boolean().optional(),reuse_private_keys:z$1.boolean().optional(),disable_ocsp_stapling:z$1.boolean().optional(),ocsp_overrides:z$1.record(z$1.string(),z$1.string()).optional()}),ur=z$1.object({ask:z$1.string().optional(),permission:z$1.unknown().optional()}),St=z$1.object({disabled:z$1.boolean().optional(),alternate_port:z$1.number().optional()}),xt=z$1.object({disabled:z$1.boolean().optional(),alternate_port:z$1.number().optional()}),z$1.any(),z$1.any(),z$1.any(),z$1.object({trusted_ca_certs:z$1.array(z$1.string()).optional()}),z$1.object({pem_files:z$1.array(z$1.string()).optional()}),z$1.object({authority:z$1.array(z$1.string()).optional()}),z$1.object({authority:z$1.array(z$1.string()).optional()}),z$1.object({storage:z$1.unknown().optional(),pem_keys:z$1.array(z$1.string()).optional()}),z$1.object({}),z$1.object({sources:z$1.array(z$1.unknown()).optional()}),z$1.object({}),z$1.object({url:z$1.string().optional()}),mr=z$1.number(),_t=z$1.object({serial_number:z$1.array(z$1.string()).optional(),subject_organization:z$1.array(z$1.string()).optional(),public_key_algorithm:mr.optional(),any_tag:z$1.array(z$1.string()).optional(),all_tags:z$1.array(z$1.string()).optional()}),Ct=z$1.object({ca:z$1.unknown().optional(),trusted_ca_certs:z$1.array(z$1.string()).optional(),trusted_ca_certs_pem_files:z$1.array(z$1.string()).optional(),trusted_leaf_certs:z$1.array(z$1.string()).optional(),verifiers:z$1.array(z$1.unknown()).optional(),mode:z$1.string().optional()}),z$1.any(),z$1.object({leaf_certs_loaders:z$1.array(z$1.unknown()).optional()}),z$1.any(),z$1.any(),z$1.any(),hr=z$1.object({public_name:z$1.string()}),z$1.unknown().and(z$1.unknown()),z$1.object({provider:z$1.unknown().optional()}),z$1.any(),Rt=z$1.object({certificate:z$1.string(),key:z$1.string(),format:z$1.string().optional(),tags:z$1.array(z$1.string()).optional()}),z$1.array(z$1.string()),z$1.object({files:z$1.array(z$1.string()).optional()}),z$1.object({folders:z$1.array(z$1.string()).optional()}),z$1.object({certificates:z$1.array(z$1.string()).optional()}),z$1.object({certificates:z$1.array(z$1.string()).optional(),storage:z$1.unknown().optional()}),z$1.array(z$1.string()),yr=z$1.object({name:z$1.string().optional(),pattern:z$1.string()}),z$1.object({MatchRegexp:yr}),z$1.object({ranges:z$1.array(z$1.string()).optional(),not_ranges:z$1.array(z$1.string()).optional()}),z$1.object({ranges:z$1.array(z$1.string()).optional()}),z$1.any(),z$1.object({endpoint:z$1.string()}),Sr=z$1.object({certificate:z$1.string(),key:z$1.string(),tags:z$1.array(z$1.string()).optional()}),z$1.any(),z$1.object({pairs:z$1.array(Rt).optional()}),wt=z$1.object({capacity:z$1.number().optional()}),z$1.any(),Cr=z$1.lazy(()=>z$1.object({Certificate:Cr,Tags:z$1.array(z$1.string())})),z$1.array(z$1.string()),k=z$1.any(),ve=z$1.any(),vt=z$1.object({policies:z$1.array(z$1.union([bt,z$1.undefined()])).optional(),on_demand:ur.optional(),ocsp_interval:k.optional(),renew_interval:k.optional(),storage_clean_interval:k.optional()}),He=z$1.object({provider:z$1.unknown().optional(),ttl:k.optional(),propagation_delay:k.optional(),propagation_timeout:k.optional(),resolvers:z$1.array(z$1.string()).optional(),override_domain:z$1.string().optional()}),Rr=z$1.object({ca:z$1.unknown().optional(),insecure_skip_verify:z$1.boolean().optional(),handshake_timeout:k.optional(),server_name:z$1.string().optional(),renegotiation:z$1.string().optional()}),z$1.object({endpoints:z$1.array(z$1.string()).optional(),tls:Rr.optional()}),Ht=z$1.object({match:ve.optional(),certificate_selection:_t.optional(),cipher_suites:z$1.array(z$1.string()).optional(),curves:z$1.array(z$1.string()).optional(),alpn:z$1.array(z$1.string()).optional(),protocol_min:z$1.string().optional(),protocol_max:z$1.string().optional(),drop:z$1.boolean().optional(),client_authentication:Ct.optional(),default_sni:z$1.string().optional(),fallback_sni:z$1.string().optional(),insecure_secrets_log:z$1.string().optional(),handshake_context:z$1.unknown().optional()}),wr=z$1.object({configs:z$1.array(z$1.string()).optional(),domains:z$1.array(z$1.string()).optional(),publishers:ve.optional()}),z$1.array(Rt),z$1.object({ca:z$1.string().optional(),lifetime:k.optional(),sign_with_root:z$1.boolean().optional()}),z$1.array(Sr),Pt=z$1.object({key_source:z$1.unknown().optional(),rotation_interval:k.optional(),max_keys:z$1.number().optional(),disable_rotation:z$1.boolean().optional(),disabled:z$1.boolean().optional()}),Hr=z$1.object({configs:z$1.array(hr).optional(),publication:z$1.array(z$1.union([wr,z$1.undefined()])).optional()}),z$1.object({api_key:z$1.string().optional(),validity_days:z$1.number().optional(),listen_host:z$1.string().optional(),alternate_http_port:z$1.number().optional(),cname_validation:He.optional()}),jr=z$1.object({http:St.optional(),"tls-alpn":xt.optional(),dns:He.optional(),bind_host:z$1.string().optional(),distributed:z$1.boolean().optional()}),z$1.array(z$1.union([Ht,z$1.undefined()])),z$1.object({certificates:ve.optional(),automation:vt.optional(),session_tickets:Pt.optional(),cache:wt.optional(),disable_ocsp_stapling:z$1.boolean().optional(),disable_storage_check:z$1.boolean().optional(),disable_storage_clean:z$1.boolean().optional(),encrypted_client_hello:Hr.optional(),dns:z$1.unknown().optional(),resolvers:z$1.array(z$1.string()).optional()}),z$1.object({ca:z$1.string().optional(),test_ca:z$1.string().optional(),email:z$1.string().optional(),profile:z$1.string().optional(),account_key:z$1.string().optional(),external_account:z$1.object({kid:z$1.string().optional(),hmacEncoded:z$1.string().optional()}).optional(),acme_timeout:k.optional(),challenges:jr.optional(),trusted_roots_pem_files:z$1.array(z$1.string()).optional(),preferred_chains:yt.optional(),certificate_lifetime:k.optional(),network_proxy:z$1.unknown().optional()});});var se=S(()=>{ut();ie();ie();jt();});var Ir,At,Or,Tr,kt,It=S(()=>{Ir=z$1.object({template_file:z$1.string().optional(),reveal_symlinks:z$1.boolean().optional(),sort:z$1.array(z$1.string()).optional(),file_limit:z$1.number().optional()}),At=z$1.object({fs:z$1.string().optional(),root:z$1.string().optional(),try_files:z$1.array(z$1.string()).optional(),try_policy:z$1.string().optional(),split_path:z$1.array(z$1.string()).optional()}),Or=z$1.any(),Tr=z$1.any(),kt=z$1.object({fs:z$1.string().optional(),root:z$1.string().optional(),hide:z$1.array(z$1.string()).optional(),index_names:z$1.array(z$1.string()).optional(),browse:Ir.optional(),canonical_uris:z$1.boolean().optional(),status_code:Or.optional(),pass_thru:z$1.boolean().optional(),precompressed:Tr.optional(),precompressed_order:z$1.array(z$1.string()).optional(),etag_file_extensions:z$1.array(z$1.string()).optional()});});var Er,Mr,Pe,Dr,je,Ot=S(()=>{Er=z$1.object({find:z$1.string().optional(),replace:z$1.string().optional(),limit:z$1.number().optional()}),Mr=z$1.object({find:z$1.string().optional(),replace:z$1.string().optional()}),Pe=z$1.object({key:z$1.string(),val:z$1.string()}),Dr=z$1.object({key:z$1.string().optional(),search:z$1.string().optional(),search_regexp:z$1.string().optional(),replace:z$1.string().optional()}),je=z$1.object({delete:z$1.array(z$1.string()).optional(),set:z$1.array(Pe).optional(),add:z$1.array(Pe).optional(),replace:z$1.array(Dr).optional(),rename:z$1.array(Pe).optional()}),z$1.object({method:z$1.string().optional(),uri:z$1.string().optional(),strip_path_prefix:z$1.string().optional(),strip_path_suffix:z$1.string().optional(),uri_substring:z$1.array(Er).optional(),path_regexp:z$1.array(Mr).optional(),query:je.optional()});});var Lr,zr,Tt,Et=S(()=>{z$1.any(),Lr=z$1.object({Header:z$1.record(z$1.string(),z$1.array(z$1.string()))}),zr=z$1.any(),Tt=z$1.object({file_root:z$1.string().optional(),mime_types:z$1.array(z$1.string()).optional(),delimiters:z$1.array(z$1.string()).optional(),match:zr.optional()}),z$1.object({Root:z$1.unknown(),Req:z$1.unknown().optional(),Args:z$1.array(z$1.any()),RespHeader:Lr,CustomFuncs:z$1.array(z$1.record(z$1.string(),z$1.unknown()))});});var $r,Mt,Dt=S(()=>{$r=z$1.object({input:z$1.string().optional(),input_regexp:z$1.string().optional(),outputs:z$1.array(z$1.any()).optional()}),Mt=z$1.object({source:z$1.string().optional(),destinations:z$1.array(z$1.string()).optional(),mappings:z$1.array($r).optional(),defaults:z$1.array(z$1.string()).optional()});});var Nr,Fr,qr,Lt,zt=S(()=>{Nr=z$1.object({method:z$1.string().optional(),target:z$1.string().optional()}),Fr=z$1.any(),qr=z$1.object({HeaderOps:Fr}),Lt=z$1.object({resources:z$1.array(Nr).optional(),headers:qr.optional()});});var $t,Nt=S(()=>{$t=z$1.object({max_size:z$1.number().optional(),read_timeout:z$1.union([z$1.number(),z$1.string()]).optional(),write_timeout:z$1.union([z$1.number(),z$1.string()]).optional(),set:z$1.string().optional()});});var Wr,Ft,qt=S(()=>{Wr=z$1.any(),Ft=z$1.object({handle_response:z$1.array(Wr).optional()});});var Wt,Bt=S(()=>{Wt=z$1.object({span:z$1.string(),span_attributes:z$1.record(z$1.string(),z$1.string()).optional()});});var Ut,Xt=S(()=>{Ut=z$1.object({key:z$1.string().optional(),value:z$1.string().optional(),early:z$1.boolean().optional()});});var Gt,Vt,ke,Br,Ur,Xr,b,Gr,Vr,Zr,Jr,Zt,Yr,Kr,Qr,en,tn,on,Jt=S(()=>{Gt=z$1.object({include:z$1.array(z$1.string()).optional(),exclude:z$1.array(z$1.string()).optional()}),z$1.any(),Vt=z$1.object({dial:z$1.string().optional(),max_requests:z$1.number().optional()}),z$1.object({}),z$1.object({Upstream:Vt.optional(),Network:z$1.string(),Address:z$1.string(),Host:z$1.string(),Port:z$1.string()}),z$1.object({AddrPort:z$1.string()}),ke=z$1.object({addresses:z$1.array(z$1.string()).optional()}),Br=z$1.array(z$1.union([Vt,z$1.undefined()])),z$1.any(),z$1.any(),z$1.object({}),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.any(),z$1.object({}),z$1.object({weights:z$1.array(z$1.number()).optional()}),z$1.object({choose:z$1.number().optional()}),z$1.object({}),z$1.object({}),z$1.object({}),z$1.object({}),z$1.object({}),z$1.object({}),z$1.object({key:z$1.string().optional(),fallback:z$1.unknown().optional()}),z$1.object({field:z$1.string().optional(),fallback:z$1.unknown().optional()}),Ur=z$1.object({ipv4:z$1.boolean().optional(),ipv6:z$1.boolean().optional()}),z$1.object({sources:z$1.array(z$1.unknown()).optional()}),Xr=z$1.any(),b=z$1.any(),Gr=z$1.any(),Vr=z$1.any(),Zr=z$1.any(),Jr=z$1.any(),Zt=z$1.object({status_code:Xr.optional()}),Yr=z$1.object({path:z$1.string().optional(),uri:z$1.string().optional(),upstream:z$1.string().optional(),port:z$1.number().optional(),headers:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),method:z$1.string().optional(),body:z$1.string().optional(),follow_redirects:z$1.boolean().optional(),interval:b.optional(),timeout:b.optional(),passes:z$1.number().optional(),fails:z$1.number().optional(),max_size:z$1.number().optional(),expect_status:z$1.number().optional(),expect_body:z$1.string().optional()}),Kr=z$1.object({fail_duration:b.optional(),max_fails:z$1.number().optional(),unhealthy_request_count:z$1.number().optional(),unhealthy_status:z$1.array(z$1.number()).optional(),unhealthy_latency:b.optional()}),Qr=z$1.object({ca:z$1.unknown().optional(),root_ca_pool:z$1.array(z$1.string()).optional(),root_ca_pem_files:z$1.array(z$1.string()).optional(),client_certificate_file:z$1.string().optional(),client_certificate_key_file:z$1.string().optional(),client_certificate_automate:z$1.string().optional(),insecure_skip_verify:z$1.boolean().optional(),handshake_timeout:b.optional(),server_name:z$1.string().optional(),renegotiation:z$1.string().optional(),except_ports:z$1.array(z$1.string()).optional(),curves:z$1.array(z$1.string()).optional()}),en=z$1.object({enabled:z$1.boolean().optional(),probe_interval:b.optional(),max_idle_conns:z$1.number().optional(),max_idle_conns_per_host:z$1.number().optional(),idle_timeout:b.optional()}),tn=z$1.object({selection_policy:z$1.unknown().optional(),retries:z$1.number().optional(),try_duration:b.optional(),try_interval:b.optional(),retry_match:Jr.optional()}),on=z$1.object({active:Yr.optional(),passive:Kr.optional()}),z$1.object({name:z$1.string().optional(),secret:z$1.string().optional(),max_age:b.optional(),fallback:z$1.unknown().optional()}),z$1.object({service:z$1.string().optional(),proto:z$1.string().optional(),name:z$1.string().optional(),refresh:b.optional(),grace_period:b.optional(),resolver:ke.optional(),dial_timeout:b.optional(),dial_fallback_delay:b.optional(),dial_network:z$1.string().optional()}),z$1.object({name:z$1.string().optional(),port:z$1.string().optional(),refresh:b.optional(),resolver:ke.optional(),dial_timeout:b.optional(),dial_fallback_delay:b.optional(),versions:Ur.optional()}),z$1.object({resolver:ke.optional(),tls:Qr.optional(),keep_alive:en.optional(),compression:z$1.boolean().optional(),max_conns_per_host:z$1.number().optional(),proxy_protocol:z$1.string().optional(),forward_proxy_url:z$1.string().optional(),dial_timeout:b.optional(),dial_fallback_delay:b.optional(),response_header_timeout:b.optional(),expect_continue_timeout:b.optional(),max_response_header_size:z$1.number().optional(),write_buffer_size:z$1.number().optional(),read_buffer_size:z$1.number().optional(),read_timeout:b.optional(),write_timeout:b.optional(),versions:z$1.array(z$1.string()).optional(),local_address:z$1.string().optional(),network_proxy:z$1.unknown().optional()}),z$1.object({transport:z$1.unknown().optional(),circuit_breaker:z$1.unknown().optional(),load_balancing:tn.optional(),health_checks:on.optional(),upstreams:Br.optional(),dynamic_upstreams:z$1.unknown().optional(),flush_interval:b.optional(),trusted_proxies:z$1.array(z$1.string()).optional(),headers:Gr.optional(),request_buffers:z$1.number().optional(),response_buffers:z$1.number().optional(),stream_timeout:b.optional(),stream_buffer_size:z$1.number().optional(),stream_close_delay:b.optional(),rewrite:Vr.optional(),handle_response:z$1.array(Zr).optional(),verbose_logs:z$1.boolean().optional()});});var an,Yt=S(()=>{z$1.any(),z$1.object({route_matcher:z$1.string().optional(),portal_name:z$1.string().optional()}),z$1.object({route_matcher:z$1.string().optional(),gatekeeper_name:z$1.string().optional()}),an=z$1.any(),z$1.object({config:an.optional(),secrets_managers:z$1.array(z$1.unknown()).optional()});});var Ie,Oe,cn,ln,pn,dn,un,mn,hn,Kt,Qt,gn,fn,yn,bn,Sn,xn,_n,Cn,Rn,wn,vn,Hn,Pn,eo=S(()=>{Yt();Ie=z$1.object({handler:z$1.literal("authenticator"),portal_name:z$1.string().optional(),route_matcher:z$1.string().optional()}),Oe=z$1.object({gatekeeper_name:z$1.string().optional(),route_matcher:z$1.string().optional()}),cn=z$1.object({handler:z$1.literal("authentication"),providers:z$1.object({authorizer:Oe})}),z$1.discriminatedUnion("handler",[Ie,cn]),ln=z$1.object({realm:z$1.string().optional(),path:z$1.string()}),pn=z$1.object({name:z$1.string(),kind:z$1.literal("local"),params:ln}),dn=z$1.object({address:z$1.string(),port:z$1.number().int().positive().max(65535).optional()}),un=z$1.object({dn:z$1.string(),roles:z$1.array(z$1.string()).optional()}),mn=z$1.object({realm:z$1.string().optional(),servers:z$1.array(dn).optional(),bind_username:z$1.string().optional(),bind_password:z$1.string().optional(),search_base_dn:z$1.string().optional(),search_user_filter:z$1.string().optional(),groups:z$1.array(un).optional()}),hn=z$1.object({name:z$1.string(),kind:z$1.literal("ldap"),params:mn.passthrough()}),Kt=z$1.object({driver:z$1.string().optional(),realm:z$1.string().optional(),client_id:z$1.string().optional(),client_secret:z$1.string().optional(),scopes:z$1.array(z$1.string()).optional(),authorization_url:z$1.string().optional(),token_url:z$1.string().optional()}),z$1.object({name:z$1.string(),kind:z$1.literal("oauth"),params:Kt}),Qt=z$1.object({driver:z$1.string().optional(),realm:z$1.string().optional(),client_id:z$1.string().optional(),client_secret:z$1.string().optional(),metadata_url:z$1.string().optional(),scopes:z$1.array(z$1.string()).optional()}),z$1.object({name:z$1.string(),kind:z$1.literal("oauth"),params:Qt}),gn=z$1.discriminatedUnion("kind",[pn,hn]),fn=z$1.object({name:z$1.string(),kind:z$1.literal("oauth"),params:z$1.union([Kt.passthrough(),Qt.passthrough()])}),yn=z$1.object({theme:z$1.string().optional(),logo_url:z$1.string().optional(),custom_css:z$1.string().optional()}),bn=z$1.object({lifetime:z$1.number().optional(),insecure:z$1.boolean().optional(),same_site:z$1.string().optional()}),Sn=z$1.object({domains:z$1.record(z$1.string(),bn).optional(),path:z$1.string().optional(),lifetime:z$1.number().optional(),insecure:z$1.boolean().optional(),same_site:z$1.string().optional()}),xn=z$1.object({name:z$1.string(),ui:yn.optional(),cookie_config:Sn.optional(),identity_stores:z$1.array(z$1.string()).optional(),identity_providers:z$1.array(z$1.string()).optional(),user_transformer_configs:z$1.array(z$1.record(z$1.string(),z$1.unknown())).optional()}),_n=z$1.object({comment:z$1.string().optional(),conditions:z$1.array(z$1.string()).optional(),action:z$1.enum(["allow","deny"]).optional()}),Cn=z$1.object({token_name:z$1.string().optional(),source:z$1.string().optional()}),Rn=z$1.object({match_type:z$1.string(),uri:z$1.string().optional()}),wn=z$1.object({name:z$1.string(),access_list_rules:z$1.array(_n).optional(),crypto_key_configs:z$1.array(Cn).optional(),bypass_configs:z$1.array(Rn).optional()}),vn=z$1.object({generic:z$1.record(z$1.string(),z$1.unknown()).optional()}),Hn=z$1.object({authentication_portals:z$1.array(xn).optional(),authorization_policies:z$1.array(wn).optional(),credentials:vn.optional(),identity_stores:z$1.array(gn).optional(),identity_providers:z$1.array(fn).optional()}),Pn=z$1.object({driver:z$1.string()}).passthrough(),z$1.object({config:Hn.optional(),secrets_managers:z$1.array(Pn).optional()});});var N,le,oo,Te,ro,no,jn,An,kn,ao,L,Ee,In,io,Me,De,so,co,lo,Le,ze,$e,Ne,Fe,qe,M,On,Tn,En,Mn,Dn,Ln,to,zn,$n,po,Nn,Fn,qn,Wn,Bn,Un,Xn,Gn,Vn,Zn,Jn,Yn,Kn,Qn,ea,ta,oa,ra,na,aa,uo,K=S(()=>{Z();se();se();It();Ot();Et();Dt();zt();Nt();qt();Bt();Xt();ie();Jt();eo();N=z$1.string().min(1,"Domain cannot be empty").regex(/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,"Invalid domain format"),le=z$1.string().refine(t=>t.includes("{")||/^(unix|unix\+h2c|unixgram|unixpacket)\/.+$/.test(t)||/^((tcp|udp)[46]?\/)?[^/]+:\d+$/.test(t),"Dial address must be host:port, network/host:port (tcp, udp) or a unix socket (unix//path/to.sock)"),oo=z$1.string(),Te=z$1.enum(["DENY","SAMEORIGIN"]),ro=z$1.enum(["none","www_to_domain","domain_to_www"]),no=z$1.union([z$1.literal(301),z$1.literal(302),z$1.literal(307),z$1.literal(308)]),z$1.enum(["letsencrypt","zerossl","acme"]),jn=z$1.record(z$1.string(),z$1.array(z$1.string())),An=z$1.record(z$1.string(),z$1.array(z$1.string())),kn=z$1.object({host:z$1.array(z$1.string()).optional(),path:z$1.array(z$1.string()).optional(),path_regexp:z$1.object({name:z$1.string().optional(),pattern:z$1.string()}).optional(),method:z$1.array(oo).optional(),header:An.optional(),header_regexp:Ce.optional(),query:jn.optional(),client_ip:xe.optional(),remote_ip:Se.optional(),protocol:ae.optional(),tls:Re.optional(),file:At.optional(),not:z$1.array(z$1.record(z$1.string(),z$1.unknown())).optional(),expression:z$1.string().optional()}),ao=z$1.object({handler:z$1.string()}).passthrough(),L=z$1.object({"@id":z$1.string().optional(),match:z$1.array(kn).optional(),handle:z$1.array(ao).min(1,"Route must have at least one handler"),terminal:z$1.boolean().optional(),priority:z$1.number().int().optional()}),Ee=z$1.object({adminUrl:z$1.string().url().optional().default("http://127.0.0.1:2019"),timeout:z$1.number().int().positive().optional().default(5e3)}),In=z$1.enum(["caddyfile","json","yaml","nginx","apache"]),io=z$1.object({config:z$1.string().min(1,"Config cannot be empty"),adapter:In.optional().default("caddyfile")}),Me=z$1.object({enableHsts:z$1.boolean().optional().default(false),hstsMaxAge:z$1.number().int().positive().optional().default(31536e3),frameOptions:Te.optional().default("DENY"),enableCompression:z$1.boolean().optional().default(true)}),De=z$1.object({domain:N,target:z$1.string().min(1,"Target cannot be empty"),targetPort:z$1.number().int().positive().max(65535,"Port must be between 1 and 65535"),enableSecurityHeaders:z$1.boolean().optional().default(true),enableHsts:z$1.boolean().optional().default(false),hstsMaxAge:z$1.number().int().positive().optional().default(31536e3),frameOptions:Te.optional().default("DENY"),enableCompression:z$1.boolean().optional().default(true),redirectMode:ro.optional().default("none"),redirectStatusCode:no.optional().default(308),adminUrl:z$1.string().url().optional()}),so=De.extend({certFile:z$1.string().min(1,"Certificate file path cannot be empty"),keyFile:z$1.string().min(1,"Key file path cannot be empty")}),co=z$1.object({domain:N,target:z$1.string().min(1).optional(),targetPort:z$1.number().int().positive().max(65535).optional(),enableSecurityHeaders:z$1.boolean().optional(),enableHsts:z$1.boolean().optional(),hstsMaxAge:z$1.number().int().positive().optional(),frameOptions:Te.optional(),enableCompression:z$1.boolean().optional(),redirectMode:ro.optional(),redirectStatusCode:no.optional(),adminUrl:z$1.string().url().optional()}),lo=z$1.object({domain:N,adminUrl:z$1.string().url().optional()}),Le=z$1.object({enabled:z$1.boolean(),username:z$1.string().min(1).optional(),passwordHash:z$1.string().min(1).optional(),realm:z$1.string().optional(),routes:z$1.array(z$1.enum(["host","path","tunnel"])).optional()}),ze=z$1.object({host:z$1.string().optional(),path:z$1.string().optional(),pathRouteHost:z$1.string().optional().default("asd.localhost"),dial:le,serviceId:z$1.string().optional().default("unknown"),enableHostRoute:z$1.boolean().optional().default(true),enablePathRoute:z$1.boolean().optional().default(true),stripPrefix:z$1.boolean().optional().default(true),priority:z$1.number().int().optional().default(50),securityHeaders:Me.optional(),basicAuth:Le.optional(),ingressTag:z$1.string().nullable().optional(),iframeOrigin:z$1.string().nullable().optional(),deleteResponseHeaders:z$1.array(z$1.string()).optional(),serviceType:z$1.string().optional(),isTunnelDomain:z$1.boolean().optional().default(false),flushInterval:z$1.number().optional(),projectId:z$1.string().nullable().optional()}),$e=z$1.object({host:z$1.string().min(1),serviceId:z$1.string().min(1),priority:z$1.number().int().optional(),ingressTag:z$1.string().nullable().optional(),dial:z$1.string().min(1).optional(),projectId:z$1.string().nullable().optional()}),Ne=z$1.object({host:z$1.string().min(1),dial:le,securityHeaders:Me.optional(),basicAuth:Le.optional(),priority:z$1.number().int().optional(),ingressTag:z$1.string().nullable().optional(),iframeOrigin:z$1.string().nullable().optional(),deleteResponseHeaders:z$1.array(z$1.string()).optional(),serviceId:z$1.string().optional(),serviceType:z$1.string().optional(),flushInterval:z$1.number().optional(),projectId:z$1.string().nullable().optional()}),Fe=z$1.object({path:z$1.string().min(1),host:z$1.string().min(1),dial:le,stripPrefix:z$1.boolean().optional().default(true),securityHeaders:Me.optional(),basicAuth:Le.optional(),priority:z$1.number().int().optional(),ingressTag:z$1.string().nullable().optional(),iframeOrigin:z$1.string().nullable().optional(),deleteResponseHeaders:z$1.array(z$1.string()).optional(),serviceId:z$1.string().optional(),serviceType:z$1.string().optional(),flushInterval:z$1.number().optional(),projectId:z$1.string().nullable().optional()}),qe=z$1.object({host:z$1.string().min(1),upstreams:z$1.array(le).min(1,"At least one upstream is required"),healthCheckPath:z$1.string().optional().default("/health"),healthCheckInterval:z$1.string().optional().default("10s"),policy:z$1.enum(["first","random","least_conn","round_robin"]).optional().default("first"),priority:z$1.number().int().optional()}),M=z$1.union([z$1.number().int(),z$1.literal("0"),z$1.string().regex(/^-?(\d+(\.\d+)?(ns|us|µs|ms|s|m|h|d))+$/,"Invalid Go duration format. Use units: ns, us, \xB5s, ms, s, m, h, d (e.g., '30s', '1h30m', '1.5d')")]),On=z$1.object({uri:z$1.string().optional(),path:z$1.string().optional(),port:z$1.number().int().positive().max(65535).optional(),headers:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),follow_redirects:z$1.boolean().optional(),interval:M.optional(),timeout:M.optional(),passes:z$1.number().int().positive().optional(),fails:z$1.number().int().positive().optional(),max_size:z$1.number().int().positive().optional(),expect_status:z$1.number().int().min(100).max(599).optional(),expect_body:z$1.string().optional()}),Tn=z$1.object({fail_duration:M.optional(),max_fails:z$1.number().int().positive().optional(),unhealthy_request_count:z$1.number().int().positive().optional(),unhealthy_status:z$1.array(z$1.number().int().min(100).max(599)).optional(),unhealthy_latency:M.optional()}),En=z$1.object({active:On.optional(),passive:Tn.optional()}),Mn=z$1.object({selection_policy:z$1.object({policy:z$1.enum(["first","random","least_conn","round_robin","ip_hash","uri_hash","header","cookie"])}).passthrough().optional(),retries:z$1.number().int().nonnegative().optional(),try_duration:M.optional(),try_interval:M.optional()}),Dn=z$1.object({dial:z$1.string().min(1),max_requests:z$1.number().int().positive().optional()}),Ln=z$1.object({name:z$1.string().optional(),pattern:z$1.string()}),to=z$1.object({host:z$1.array(z$1.string()).optional(),path:z$1.array(z$1.string()).optional(),path_regexp:z$1.object({name:z$1.string().optional(),pattern:z$1.string()}).optional(),method:z$1.array(oo).optional(),header:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),header_regexp:z$1.record(z$1.string(),Ln).optional(),query:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),client_ip:z$1.object({ranges:z$1.array(z$1.string())}).optional(),remote_ip:z$1.object({ranges:z$1.array(z$1.string())}).optional(),protocol:ae.optional(),expression:z$1.string().optional(),tls:z$1.object({handshake_complete:z$1.boolean().optional()}).optional(),file:z$1.object({fs:z$1.string().optional(),root:z$1.string().optional(),try_files:z$1.array(z$1.string()).optional(),try_policy:z$1.enum(["first_exist","first_exist_fallback","smallest_size","largest_size","most_recently_modified"]).optional(),split_path:z$1.array(z$1.string()).optional()}).optional()}),to.extend({not:z$1.array(z$1.lazy(()=>to)).optional()}),zn=z$1.object({handler:z$1.literal("reverse_proxy"),upstreams:z$1.array(Dn).optional(),load_balancing:Mn.optional(),health_checks:En.optional(),transport:z$1.object({protocol:z$1.string()}).passthrough().optional(),circuit_breaker:z$1.object({type:z$1.string()}).passthrough().optional(),dynamic_upstreams:z$1.object({source:z$1.string()}).passthrough().optional(),flush_interval:M.optional(),stream_timeout:M.optional(),stream_close_delay:M.optional(),trusted_proxies:z$1.array(z$1.string()).optional(),request_buffers:z$1.number().int().nonnegative().optional(),response_buffers:z$1.number().int().nonnegative().optional(),headers:z$1.object({request:z$1.object({add:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),set:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),delete:z$1.array(z$1.string()).optional()}).optional(),response:z$1.object({add:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),set:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),delete:z$1.array(z$1.string()).optional()}).optional()}).optional(),rewrite:z$1.object({uri:z$1.string().optional(),strip_path_prefix:z$1.string().optional(),strip_path_suffix:z$1.string().optional()}).passthrough().optional(),handle_response:z$1.array(z$1.object({match:z$1.object({status_code:z$1.array(z$1.number().int()).optional()}).passthrough().optional(),routes:z$1.array(z$1.any()).optional()}).passthrough()).optional(),verbose_logs:z$1.boolean().optional()}),$n=z$1.object({handler:z$1.literal("headers"),response:z$1.object({deferred:z$1.boolean().optional(),set:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),add:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),delete:z$1.array(z$1.string()).optional()}).optional(),request:z$1.object({set:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),add:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),delete:z$1.array(z$1.string()).optional()}).optional()}),po=z$1.union([z$1.number().int(),z$1.string()]).optional(),Nn=z$1.object({handler:z$1.literal("static_response"),status_code:po,body:z$1.string().optional(),headers:z$1.record(z$1.string(),z$1.array(z$1.string())).optional(),close:z$1.boolean().optional(),abort:z$1.boolean().optional()}),Fn=z$1.object({handler:z$1.literal("authentication"),providers:z$1.object({http_basic:z$1.object({accounts:z$1.array(z$1.object({username:z$1.string(),password:z$1.string()})).optional(),realm:z$1.string().optional(),hash:z$1.object({algorithm:z$1.string().optional()}).optional()}).optional(),authorizer:Oe.optional()}).optional()}),qn=z$1.object({handler:z$1.literal("rewrite"),uri:z$1.string().optional(),strip_path_prefix:z$1.string().optional(),strip_path_suffix:z$1.string().optional(),uri_substring:z$1.array(z$1.object({find:z$1.string(),replace:z$1.string(),limit:z$1.number().int().optional()})).optional(),query:je.optional()}),Wn=z$1.object({handler:z$1.literal("encode"),encodings:z$1.object({gzip:z$1.object({}).passthrough().optional(),zstd:z$1.object({}).passthrough().optional(),br:z$1.object({}).passthrough().optional()}).passthrough().optional(),prefer:z$1.array(z$1.string()).optional(),minimum_length:z$1.number().int().positive().optional()}),Bn=kt.extend({handler:z$1.literal("file_server")}),Un=Tt.extend({handler:z$1.literal("templates")}),Xn=Mt.extend({handler:z$1.literal("map")}),Gn=Lt.extend({handler:z$1.literal("push")}),Vn=$t.extend({handler:z$1.literal("request_body")}),Zn=z$1.object({handler:z$1.literal("vars")}).passthrough(),Jn=Ft.extend({handler:z$1.literal("intercept")}),Yn=be.extend({handler:z$1.literal("invoke")}),Kn=Wt.extend({handler:z$1.literal("tracing")}),Qn=Ut.extend({handler:z$1.literal("log_append")}),ea=we.extend({handler:z$1.literal("error"),status_code:po}),ta=Zt.extend({handler:z$1.literal("copy_response")}),oa=Gt.extend({handler:z$1.literal("copy_response_headers")}),ra=z$1.object({handler:z$1.literal("subroute"),routes:z$1.array(z$1.lazy(()=>L)).optional(),errors:z$1.any().optional()}),na=z$1.discriminatedUnion("handler",[zn,$n,Nn,Fn,qn,Wn,Bn,Un,Xn,Gn,Vn,Zn,Jn,Yn,Kn,Qn,ea,ta,oa,ra,Ie]),z$1.union([na,ao]),aa=z$1.object({address:z$1.string(),num_requests:z$1.number(),fails:z$1.number(),healthy:z$1.boolean()}),uo=z$1.array(aa),z$1.object({webPort:z$1.number().int().positive().max(65535).optional().default(8081),proxyPort:z$1.number().int().positive().max(65535).optional().default(8080),listenAddress:z$1.string().optional().default("127.0.0.1"),openBrowser:z$1.boolean().optional().default(true),scripts:z$1.array(z$1.string()).optional(),workingDir:z$1.string().optional()});});function F(t,e){let{baseDir:r,requireWithinBase:n=false}={};if(t.includes(".."))throw new z(`Path traversal detected: "${t}" contains ".." segments`,[{code:"custom",path:["filePath"],message:'Path must not contain ".." traversal segments'}]);let i=normalize(t),s=isAbsolute(i)?i:resolve(r??process.cwd(),i);if(n&&r){let u=resolve(r);if(!s.startsWith(u))throw new z(`Path "${t}" resolves outside allowed directory "${r}"`,[{code:"custom",path:["filePath"],message:"Path must be within the allowed directory"}])}return s}function x(t,e,r){try{return t.parse(e)}catch(n){if(n instanceof ZodError){let i=r?`${r}: ${ho(n)}`:ho(n);throw new z(i,n.errors)}throw n}}function ho(t){if(t.issues.length===1){let e=t.issues[0];return go(e)}return t.issues.map((e,r)=>`${r+1}. ${go(e)}`).join("; ")}function go(t){return `${t.path.length>0?`${t.path.join(".")}: `:""}${t.message}`}var Q=S(()=>{Z();});var We,fo,la,pa,da,ua,P,pe=S(()=>{Z();K();se();Q();We=fe.extend({logging:z$1.any().optional()}).passthrough(),fo=J.passthrough(),la=z$1.record(z$1.string(),fo),pa=B.passthrough(),da=z$1.array(pa),ua=z$1.object({version:z$1.string().optional()}).passthrough(),P=class{adminUrl;timeout;origin;constructor(e={}){let r=x(Ee,e,"client options");this.adminUrl=r.adminUrl,this.timeout=r.timeout;let n=new URL(this.adminUrl);this.origin=n.origin;}async request(e,r={}){let n=`${this.adminUrl}${e}`,i=(r.method??"GET").toUpperCase(),s=new AbortController,u=setTimeout(()=>s.abort(),this.timeout);try{let m=await fetch(n,{...r,signal:s.signal,headers:{"Content-Type":"application/json",Origin:this.origin,...r.headers}});if(clearTimeout(u),!m.ok){let h=await m.text().catch(()=>"");throw new G(`Caddy API request failed: ${i} ${n} - ${m.status} ${m.statusText}`,m.status,h,n,i)}return m}catch(m){throw clearTimeout(u),m instanceof G?m:m.name==="AbortError"?new ne(`Request to ${e} timed out after ${this.timeout}ms`,this.timeout):new re(`Network request to ${e} failed: ${m.message}`,m)}}async getConfig(){let r=await(await this.request("/config/")).json();return We.parse(r)}escapeServerName(e){return e.replace(/\./g,"%2E")}async getRoutes(e){let r=this.escapeServerName(e),i=await(await this.request(`/config/apps/http/servers/${r}/routes`)).json(),s=da.safeParse(i);if(!s.success)throw new j(`Invalid routes response from Caddy: ${s.error.message}`);return s.data}async addRoute(e,r){x(L,r,"route");try{let i=await this.getRoutes(e),s=r.match?.[0];if(s&&this.routeExists(i,s))return !1}catch{}let n=this.escapeServerName(e);return await this.request(`/config/apps/http/servers/${n}/routes`,{method:"POST",body:JSON.stringify(r)}),true}async addRoutes(e,r){let n=0,i=0,s=[];try{s=await this.getRoutes(e);}catch{}let u=this.escapeServerName(e);for(let m of r){x(L,m,"route");let h=m.match?.[0];if(h&&this.routeExists(s,h)){i++;continue}await this.request(`/config/apps/http/servers/${u}/routes`,{method:"POST",body:JSON.stringify(m)}),s.push(m),n++;}return {added:n,skipped:i}}routeExists(e,r){return e.some(n=>{let i=n.match?.[0];if(!i)return false;let s=JSON.stringify(i.host)===JSON.stringify(r.host),u=JSON.stringify(i.path)===JSON.stringify(r.path);return s&&u})}async patchRoutes(e,r){r.forEach((i,s)=>x(L,i,`route[${s}]`));let n=this.escapeServerName(e);await this.request(`/config/apps/http/servers/${n}/routes`,{method:"PATCH",body:JSON.stringify(r)});}async removeRoutesByHost(e,r="https_server"){if(!e||typeof e!="string")throw new j("hostname is required and must be a string");let n;try{n=await this.getRoutes(r);}catch{return 0}let i=n.filter(u=>u.match?.[0]?.host?.[0]!==e),s=n.length-i.length;if(s>0)try{await this.patchRoutes(r,i);}catch{return 0}return s}async removeHostFromRoutes(e,r="https_server"){if(!e||typeof e!="string")throw new j("hostname is required and must be a string");let n;try{n=await this.getRoutes(r);}catch{return {stripped:0,dropped:0}}let i=0,s=0,u=false,m=[];for(let h of n){let g=false,C=[];for(let w of h.match??[])if(Array.isArray(w.host)&&w.host.includes(e)){let O=w.host.filter(v=>v!==e);if(g=true,O.length===0)continue;C.push({...w,host:O});}else C.push(w);if(g){if(u=true,C.length===0){s++;continue}m.push({...h,match:C}),i++;}else m.push(h);}if(u)try{await this.patchRoutes(r,m);}catch{return {stripped:0,dropped:0}}return {stripped:i,dropped:s}}async getServers(){let r=await(await this.request("/config/apps/http/servers")).json();return la.parse(r)}async getServerConfig(e){let r=this.escapeServerName(e),i=await(await this.request(`/config/apps/http/servers/${r}`)).json();return fo.parse(i)}async patchServer(e){await this.request("/config/apps/http/servers",{method:"PATCH",body:JSON.stringify(e)});}async reload(){await this.request("/load",{method:"POST"});}async getVersion(){let r=await(await this.request("/")).json();return ua.parse(r)}async insertRoute(e,r,n="after-health-checks"){let i=x(L,r,"route"),s=await this.getRoutes(e),u=0;if(n==="after-health-checks"){let h=-1;for(let g=0;g<s.length;g++)s[g].handle?.[0]?.handler==="static_response"&&(h=g);u=h+1;}else n==="end"&&(u=s.length);s.splice(u,0,i);let m=await this.getServerConfig(e);await this.patchServer({[e]:{...m,routes:s}});}async replaceRouteById(e,r,n){let i=x(L,n,"route"),s=await this.getRoutes(e),u=s.findIndex(h=>h["@id"]===r);if(u===-1)return false;s[u]={...i,"@id":r};let m=await this.getServerConfig(e);return await this.patchServer({[e]:{...m,routes:s}}),true}async removeRouteById(e,r){let n=await this.getRoutes(e),i=n.length,s=n.filter(m=>m["@id"]!==r);if(s.length===i)return false;let u=await this.getServerConfig(e);return await this.patchServer({[e]:{...u,routes:s}}),true}async stop(){await this.request("/stop",{method:"POST"});}async getUpstreams(){let r=await(await this.request("/reverse_proxy/upstreams")).json();return uo.parse(r)}async adapt(e,r="caddyfile"){let n=x(io,{config:e,adapter:r},"adapt options"),s=await(await this.request("/adapt",{method:"POST",headers:{"Content-Type":"text/caddyfile"},body:JSON.stringify({config:n.config,adapter:n.adapter})})).json();return We.parse(s)}async applyConfig(e){x(We,e,"config"),await this.request("/load",{method:"POST",body:JSON.stringify(e)});}};});function kl(t){let e=x(ze,t,"buildServiceRoutes options"),r=[],n=e.basicAuth?.routes??["host","path","tunnel"],i=s=>{if(!e.basicAuth)return;let u=e.isTunnelDomain?"tunnel":s;return n.includes(u)?e.basicAuth:void 0};if(e.enableHostRoute&&e.host&&(r.push(yo({host:e.host,serviceId:e.serviceId??"unknown",priority:e.priority!==void 0?e.priority+1e3:void 0,ingressTag:e.ingressTag,projectId:e.projectId})),r.push(Be({host:e.host,dial:e.dial,securityHeaders:e.securityHeaders,basicAuth:i("host"),priority:e.priority,ingressTag:e.ingressTag,iframeOrigin:e.iframeOrigin,deleteResponseHeaders:e.deleteResponseHeaders,serviceId:e.serviceId,serviceType:e.serviceType,flushInterval:e.flushInterval,projectId:e.projectId}))),e.enablePathRoute&&e.path&&e.path!=="/"){let s=e.pathRouteHost??"asd.localhost";r.push(yo({host:s,serviceId:e.serviceId??"unknown",priority:e.priority!==void 0?e.priority+1e3:void 0,ingressTag:e.ingressTag,projectId:e.projectId})),r.push(ma({path:e.path,host:s,dial:e.dial,stripPrefix:e.stripPrefix??true,securityHeaders:e.securityHeaders,basicAuth:i("path"),priority:e.priority,ingressTag:e.ingressTag,iframeOrigin:e.iframeOrigin,deleteResponseHeaders:e.deleteResponseHeaders,serviceId:e.serviceId,serviceType:e.serviceType,flushInterval:e.flushInterval,projectId:e.projectId}));}return r}function yo(t){let e=x($e,t,"buildHealthCheckRoute options"),r=[];e.ingressTag&&r.push(Ue(e.ingressTag)),e.projectId&&r.push(Xe(e.projectId)),r.push({handler:"headers",response:{set:{"X-ASD-Health":["ok"],"X-ASD-Service-ID":[e.serviceId]}}}),e.dial?r.push({handler:"reverse_proxy",upstreams:[{dial:e.dial}],headers:{request:{set:{"X-Forwarded-Proto":["{http.request.scheme}"],"X-Forwarded-Host":["{http.request.host}"],"X-Forwarded-Port":["{http.request.port}"]}}}}):r.push({handler:"static_response",body:`{"status":"ok","service":"${e.serviceId}","timestamp":"{http.time.now.unix}"}`,status_code:200,headers:{"Content-Type":["application/json"]}});let n={match:[{host:[e.host],path:["/asd/healthcheck"]}],handle:r,terminal:true};return e.priority!==void 0&&(n.priority=e.priority),n}function Be(t){let e=x(Ne,t,"buildHostRoute options"),r=[];e.ingressTag&&r.push(Ue(e.ingressTag)),e.projectId&&r.push(Xe(e.projectId)),e.iframeOrigin&&r.push(Ro(e.iframeOrigin));let n=Co(e.serviceId,e.serviceType);n&&r.push(n),e.securityHeaders&&r.push(So(e.securityHeaders)),e.basicAuth?.enabled&&e.basicAuth.username&&e.basicAuth.passwordHash&&r.push(xo(e.basicAuth)),r.push(bo(e.dial,{deleteResponseHeaders:e.deleteResponseHeaders,flushInterval:e.flushInterval}));let i={match:[{host:[e.host]}],handle:r,terminal:true};return e.priority!==void 0&&(i.priority=e.priority),i}function ma(t){let e=x(Fe,t,"buildPathRoute options"),r=[];e.ingressTag&&r.push(Ue(e.ingressTag)),e.projectId&&r.push(Xe(e.projectId)),e.iframeOrigin&&r.push(Ro(e.iframeOrigin));let n=Co(e.serviceId,e.serviceType);n&&r.push(n),e.stripPrefix&&r.push(_o(e.path)),e.securityHeaders&&r.push(So(e.securityHeaders)),e.basicAuth?.enabled&&e.basicAuth.username&&e.basicAuth.passwordHash&&r.push(xo(e.basicAuth)),r.push(bo(e.dial,{deleteResponseHeaders:e.deleteResponseHeaders,flushInterval:e.flushInterval}));let i={match:[{host:[e.host],path:[e.path.endsWith("*")?e.path:`${e.path}*`]}],handle:r,terminal:true};return e.priority!==void 0&&(i.priority=e.priority),i}function Il(t){let e=x(qe,t,"buildLoadBalancerRoute options"),r={match:[{host:[e.host]}],handle:[{handler:"reverse_proxy",upstreams:e.upstreams.map(n=>({dial:n})),transport:{protocol:"http"},...e.policy!=="first"&&{load_balancing:{selection_policy:{policy:e.policy}}},health_checks:{active:{path:e.healthCheckPath,interval:e.healthCheckInterval,timeout:"5s",expect_status:200}}}],terminal:true};return e.priority!==void 0&&(r.priority=e.priority),r}function bo(t,e){let r=typeof t=="string"&&t.startsWith("https://"),n=r?t.replace("https://",""):t,i=e?.tls??r,s={handler:"reverse_proxy",upstreams:[{dial:n}]};if(i){let u={};e?.tlsServerName&&(u.server_name=e.tlsServerName),e?.tlsInsecureSkipVerify===true&&(u.insecure_skip_verify=true),e?.tlsTrustedCACerts&&(u.ca=e.tlsTrustedCACerts),s.transport={protocol:"http",tls:u};}else s.transport={protocol:"http"};return e?.deleteResponseHeaders&&e.deleteResponseHeaders.length>0&&(s.headers={response:{delete:e.deleteResponseHeaders}}),e?.flushInterval!==void 0&&(s.flush_interval=e.flushInterval),s}function So(t){let e={"X-Frame-Options":[t.frameOptions??"DENY"],"X-Content-Type-Options":["nosniff"],"X-XSS-Protection":["1; mode=block"]};return t.enableHsts&&(e["Strict-Transport-Security"]=[`max-age=${t.hstsMaxAge??31536e3}; includeSubDomains`]),{handler:"headers",response:{set:e}}}function xo(t){let e=t.accounts??(t.username&&t.passwordHash?[{username:t.username,password:t.passwordHash}]:[]);if(e.length===0)throw new Error("Basic auth requires at least one account (username + passwordHash or accounts array)");let r={handler:"authentication",providers:{http_basic:{accounts:e,realm:t.realm??"Restricted Area"}}};return t.hash?.algorithm&&t.hash.algorithm!=="bcrypt"&&r.providers?.http_basic&&(r.providers.http_basic.hash={algorithm:t.hash.algorithm}),r}function _o(t){return {handler:"rewrite",strip_path_prefix:t}}function Co(t,e){let r={};return t&&(r["X-ASD-Service-ID"]=[t]),e&&(r["X-ASD-Service-Type"]=[e]),Object.keys(r).length?{handler:"headers",response:{set:r}}:null}function Ue(t){return {handler:"headers",response:{set:{"X-ASD-Ingress":[t]}}}}function Xe(t){return {handler:"headers",response:{set:{"X-ASD-Project":[t]}}}}function Ro(t="*"){let e=t.trim();return {handler:"headers",response:{set:{...e==="*"||ha.test(e)?{"Access-Control-Allow-Origin":[e],"Access-Control-Allow-Methods":["GET","POST","PUT","DELETE","OPTIONS"],"Access-Control-Allow-Headers":["Content-Type","Authorization"]}:{},"Content-Security-Policy":[`frame-ancestors ${t}`]}}}}function Ge(t){let e=t.statusCode??(t.permanent!==false?308:307);return {"@id":t.id,match:[{host:[t.fromHost]}],handle:[{handler:"static_response",status_code:e,headers:{Location:[`https://${t.toHost}{http.request.uri}`]}}],terminal:true}}function Ve(t){let e={};return t?.gzip!==false&&(e.gzip={}),t?.zstd!==false&&(e.zstd={}),t?.brotli===true&&(e.br={}),{handler:"encode",encodings:e}}function Ze(t){let{domain:e,mode:r,permanent:n=true,priority:i}=t,s=e.replace(/^www\./,"");return r==="www-to-domain"?{"@id":`redirect-www-to-domain-${s}`,match:[{host:[`www.${s}`]}],handle:[{handler:"static_response",status_code:n?301:302,headers:{Location:[`https://${s}{http.request.uri}`]}}],terminal:true,...i!==void 0&&{priority:i}}:{"@id":`redirect-domain-to-www-${s}`,match:[{host:[s]}],handle:[{handler:"static_response",status_code:n?301:302,headers:{Location:[`https://www.${s}{http.request.uri}`]}}],terminal:true,...i!==void 0&&{priority:i}}}function ga(t){let e=t.mitmproxyPort??8080,r=`${t.mitmproxyHost}:${e}`,n=Be({host:t.host,dial:r,priority:t.priority});return t.id&&(n["@id"]=t.id),n}function Ol(t){let e=`${t.backendHost}:${t.backendPort}`,r=t.mitmproxyPort??8080,n=Be({host:t.host,dial:e,priority:t.priority});n["@id"]=t.routeId;let i=ga({host:t.host,mitmproxyHost:t.mitmproxyHost,mitmproxyPort:r,backendHost:t.backendHost,backendPort:t.backendPort,id:t.routeId,priority:t.priority});return {direct:n,proxied:i}}function fa(t){let e=`${t.upstreamHost}:${t.upstreamPort}`,r=t.routeId??`iframe_proxy_${t.pathPrefix.replace(/\//g,"_")}`,n=t.iframeEmbed!==false,i=[_o(t.pathPrefix)];n&&i.push(ba());let s={handler:"reverse_proxy",transport:{protocol:"http"},upstreams:[{dial:e}]};return t.overrideHost&&(s.headers={request:{set:{Host:[t.overrideHost],Origin:[`http://${t.overrideHost}/`]}}}),i.push(s),{"@id":r,match:[{path:[t.pathPrefix,`${t.pathPrefix}/*`]}],handle:i,terminal:true}}function Tl(t){let e=t.mitmproxyWebPort??8081;return fa({pathPrefix:t.pathPrefix,upstreamHost:t.mitmproxyHost,upstreamPort:e,routeId:t.routeId,iframeEmbed:t.iframeEmbed,overrideHost:`127.0.0.1:${e}`})}function ya(t){let e=`${t.upstreamHost}:${t.upstreamPort}`,r=t.routeId??`ws_proxy_${t.path.replace(/\//g,"_")}`,n={handler:"reverse_proxy",transport:{protocol:"http"},upstreams:[{dial:e}]};return t.overrideHost&&(n.headers={request:{set:{Host:[t.overrideHost],Origin:[`http://${t.overrideHost}/`]}}}),{"@id":r,match:[{path:[t.path]}],handle:[n],terminal:true}}function El(t){let e=t.mitmproxyWebPort??8081;return ya({path:t.path??"/updates",upstreamHost:t.mitmproxyHost,upstreamPort:e,routeId:t.routeId,overrideHost:`127.0.0.1:${e}`})}function ba(t){let e=t?.deleteHeaders??["X-Frame-Options","Content-Security-Policy","X-Xss-Protection"],r=t?.corsOrigin??"*";return {handler:"headers",response:{deferred:true,delete:e,set:{"Access-Control-Allow-Origin":[r],"X-Frame-Options":["ALLOWALL"]}}}}function Ml(t){return {handler:"headers",request:{set:{Host:[t.targetHost],Origin:[`http://${t.targetHost}/`]}}}}function Dl(t){let e={handler:"file_server",root:t.root};t.indexNames&&t.indexNames.length>0&&(e.index_names=t.indexNames),t.browse&&(e.browse=t.browseTemplate?{template_file:t.browseTemplate}:{}),t.hidePatterns&&t.hidePatterns.length>0&&(e.hide=t.hidePatterns),t.precompressed&&(e.precompressed={gzip:{},br:{}});let r={match:[{path:[t.path]}],handle:[e],terminal:true};return t.id&&(r["@id"]=t.id),t.priority!==void 0&&(r.priority=t.priority),r}function Ll(t){let e={handler:"templates",file_root:t.fileRoot};t.mimeTypes&&t.mimeTypes.length>0&&(e.mime_types=t.mimeTypes),t.delimiters&&(e.delimiters=t.delimiters);let r={handler:"file_server",root:t.fileRoot},n={match:[{path:[t.path]}],handle:[e,r],terminal:true};return t.id&&(n["@id"]=t.id),t.priority!==void 0&&(n.priority=t.priority),n}function zl(t){let e={handler:"error",status_code:String(t.statusCode)};t.message&&(e.error=t.message);let r={handle:[e],terminal:true};if(t.match){let n={};t.match.path&&(n.path=t.match.path),t.match.host&&(n.host=t.match.host),r.match=[n];}return t.id&&(r["@id"]=t.id),t.priority!==void 0&&(r.priority=t.priority),r}function $l(t){return {handler:"request_body",max_size:t.maxSize}}function Nl(t){return {handler:"vars",...t.vars}}function Fl(t){let e={handler:"tracing"};return t?.span&&(e.span=t.span),e}function ql(t){let e={handler:"map",source:t.source,destinations:t.destinations,mappings:t.mappings};return t.defaults&&(e.defaults=t.defaults),e}var ha,Je=S(()=>{K();Q();ha=/^https?:\/\/[^\s*/]+$/;});function de(t){let e=new X509Certificate(t);return {serialNumber:e.serialNumber,subject:e.subject,issuer:e.issuer,notBefore:e.notBefore,notAfter:e.notAfter}}function te(t,e){let r=new Date().toISOString().replace(/[:-]/g,"").replace("T","").slice(0,14);return `${t}-${e}-${r}`}function Ye(t){let e=[],r=t.split(`
2
2
  `),n=[],i=false;for(let s of r)s.includes("-----BEGIN CERTIFICATE-----")?(i=true,n=[s]):s.includes("-----END CERTIFICATE-----")?(n.push(s),e.push(n.join(`
3
- `)),n=[],i=false):i&&n.push(s);return e}function Ye(t){return new X509Certificate(t).serialNumber}function Ke(t){let e=new X509Certificate(t);return new Date>e.notAfter}function Qe(t,e){let r=new X509Certificate(t),n=new Date;return n.setDate(n.getDate()+e),r.notAfter<=n}function et(t){let e=new X509Certificate(t),r=new Date,n=e.notAfter.getTime()-r.getTime();return Math.floor(n/(1e3*60*60*24))}var tt=S(()=>{});var at={};Do(at,{addDomainWithAutoTls:()=>ot,addDomainWithTls:()=>rt,deleteDomain:()=>nt,getDomainConfig:()=>q,listDomains:()=>jo,removeOldCertificates:()=>Po,rotateCertificate:()=>Ho,updateDomain:()=>vo});async function ot(t){let e=x(Me,t,"addDomainWithAutoTls options"),r=new P({adminUrl:e.adminUrl});if(await q(e.domain,e.adminUrl))throw new V(e.domain);let i=[];e.redirectMode==="www_to_domain"?i.push(Ve({domain:e.domain,mode:"www-to-domain",permanent:true})):e.redirectMode==="domain_to_www"&&i.push(Ve({domain:e.domain,mode:"domain-to-www",permanent:true}));let s=[];e.enableSecurityHeaders&&s.push({handler:"headers",response:{set:{"X-Frame-Options":[e.frameOptions??"DENY"],"X-Content-Type-Options":["nosniff"],...e.enableHsts?{"Strict-Transport-Security":[`max-age=${e.hstsMaxAge}; includeSubDomains`]}:{}}}}),e.enableCompression!==false&&s.push(Ge()),s.push({handler:"reverse_proxy",upstreams:[{dial:`${e.target}:${e.targetPort}`}]}),i.push({"@id":e.domain,handle:s});let u={[e.domain]:{listen:[":443"],routes:i,automatic_https:{disable:false}}},h=await r.getConfig();return h.apps??={},h.apps.tls??={},h.apps.tls.automation??={policies:[]},h.apps.tls.automation.policies??=[],h.apps.tls.automation.policies.push({subjects:[e.domain],issuers:[{module:"acme"}]}),await r.patchServer(u),{domain:e.domain,target:e.target,targetPort:e.targetPort,tlsEnabled:true,autoTls:true,securityHeaders:{enableHsts:e.enableHsts??false,hstsMaxAge:e.hstsMaxAge??31536e3,frameOptions:e.frameOptions??"DENY",enableCompression:e.enableCompression??true},redirectMode:e.redirectMode??"none"}}async function rt(t){let e=x(io,t,"addDomainWithTls options"),r=new P({adminUrl:e.adminUrl});if(await q(e.domain,e.adminUrl))throw new V(e.domain);let i=[];e.redirectMode==="www_to_domain"?i.push(Xe({fromHost:`www.${e.domain}`,toHost:e.domain,permanent:true,statusCode:e.redirectStatusCode,id:`${e.domain}-redirect`})):e.redirectMode==="domain_to_www"&&i.push(Xe({fromHost:e.domain,toHost:`www.${e.domain}`,permanent:true,statusCode:e.redirectStatusCode,id:`${e.domain}-redirect`}));let s=[];e.enableSecurityHeaders&&s.push({handler:"headers",response:{set:{"X-Frame-Options":[e.frameOptions??"DENY"],"X-Content-Type-Options":["nosniff"],...e.enableHsts?{"Strict-Transport-Security":[`max-age=${e.hstsMaxAge}; includeSubDomains`]}:{}}}}),e.enableCompression!==false&&s.push(Ge()),s.push({handler:"reverse_proxy",upstreams:[{dial:`${e.target}:${e.targetPort}`}]}),i.push({"@id":e.domain,match:[{host:[e.domain]}],handle:s,terminal:true});let u={[e.domain]:{listen:[":443"],routes:i,tls_connection_policies:[{certificate_selection:{any_tag:["manual"]}}]}},h=await r.getConfig();h.apps??={},h.apps.tls??={},h.apps.tls.certificates??={load_files:[]},h.apps.tls.certificates.load_files??=[];let g=F(e.certFile),C=F(e.keyFile),O=await(await import('fs/promises')).readFile(g,"utf-8"),T=Je(O)[0],H=Ye(T),oe=te(e.domain,H);return h.apps.tls.certificates.load_files.push({certificate:g,key:C,tags:[oe,"manual"]}),await r.request("/config/apps/tls",{method:"POST",body:JSON.stringify(h.apps.tls)}),await r.patchServer(u),{domain:e.domain,target:e.target,targetPort:e.targetPort,tlsEnabled:true,autoTls:false,certFile:e.certFile,keyFile:e.keyFile,securityHeaders:{enableHsts:e.enableHsts??false,hstsMaxAge:e.hstsMaxAge??31536e3,frameOptions:e.frameOptions??"DENY",enableCompression:e.enableCompression??true},redirectMode:e.redirectMode??"none"}}async function vo(t){let e=x(so,t,"updateDomain options"),r=await q(e.domain,e.adminUrl);if(!r)throw new W(e.domain);let n={...r,...e.target&&{target:e.target},...e.targetPort&&{targetPort:e.targetPort},securityHeaders:{...r.securityHeaders,...e.enableHsts!==void 0&&{enableHsts:e.enableHsts},...e.hstsMaxAge!==void 0&&{hstsMaxAge:e.hstsMaxAge},...e.frameOptions!==void 0&&{frameOptions:e.frameOptions},...e.enableCompression!==void 0&&{enableCompression:e.enableCompression}},...e.redirectMode!==void 0&&{redirectMode:e.redirectMode}};return await nt({domain:e.domain,adminUrl:e.adminUrl}),n.autoTls?ot({domain:n.domain,target:n.target,targetPort:n.targetPort,enableSecurityHeaders:true,enableHsts:n.securityHeaders.enableHsts,hstsMaxAge:n.securityHeaders.hstsMaxAge,frameOptions:n.securityHeaders.frameOptions,enableCompression:n.securityHeaders.enableCompression,redirectMode:n.redirectMode,adminUrl:e.adminUrl}):n.certFile&&n.keyFile?rt({domain:n.domain,target:n.target,targetPort:n.targetPort,certFile:n.certFile,keyFile:n.keyFile,enableSecurityHeaders:true,enableHsts:n.securityHeaders.enableHsts,hstsMaxAge:n.securityHeaders.hstsMaxAge,frameOptions:n.securityHeaders.frameOptions,enableCompression:n.securityHeaders.enableCompression,redirectMode:n.redirectMode,adminUrl:e.adminUrl}):n}async function nt(t){let e=x(co,t,"deleteDomain options"),r=new P({adminUrl:e.adminUrl});if(!await q(e.domain,e.adminUrl))throw new W(e.domain);let i=await r.getConfig();i.apps?.http?.servers?.[e.domain]&&delete i.apps.http.servers[e.domain],i.apps?.tls?.certificates&&(i.apps.tls.certificates.load_files&&(i.apps.tls.certificates.load_files=i.apps.tls.certificates.load_files.filter(s=>{let u=s.tags?.some(h=>h.includes(e.domain)),m=s.certificate?.includes(e.domain)??s.key?.includes(e.domain);return !u&&!m})),i.apps.tls.certificates.load_pem&&(i.apps.tls.certificates.load_pem=i.apps.tls.certificates.load_pem.filter(s=>!s.tags?.some(m=>m.includes(e.domain))))),i.apps?.tls?.automation?.policies&&(i.apps.tls.automation.policies=i.apps.tls.automation.policies.filter(s=>!s.subjects?.includes(e.domain))),await r.request("/config/",{method:"POST",body:JSON.stringify(i)});}async function q(t,e){let r=x(N,t,"domain"),n=new P({adminUrl:e});try{let s=(await n.getServers())[r];if(!s)return null;let u="127.0.0.1",m=3e3,h=!1,g="DENY",C=31536e3;if(s.routes&&s.routes.length>0){for(let O of s.routes)if(O.handle)for(let v of O.handle){if(v.handler==="reverse_proxy"&&v.upstreams?.[0]?.dial){let T=v.upstreams[0].dial,H=/^(.+):(\d+)$/.exec(T);H&&(u=H[1],m=parseInt(H[2],10));}if(v.handler==="headers"&&v.headers?.response?.set){let T=v.headers.response.set;if(T["Strict-Transport-Security"]){h=!0;let H=T["Strict-Transport-Security"][0],oe=/max-age=(\d+)/.exec(H);oe&&(C=parseInt(oe[1],10));}if(T["X-Frame-Options"]){let H=T["X-Frame-Options"][0];(H==="SAMEORIGIN"||H==="DENY")&&(g=H);}}}}let w=s.automatic_https?.disable!==!0;return {domain:r,target:u,targetPort:m,tlsEnabled:!0,autoTls:w,securityHeaders:{enableHsts:h,hstsMaxAge:C,frameOptions:g,enableCompression:!0},redirectMode:"none"}}catch{return null}}async function Ho(t,e,r,n){let i=x(N,t,"domain"),s=F(e),u=F(r),m=new P({adminUrl:n});if(!await q(i,n))throw new W(i);let g=await m.getConfig(),w=await(await import('fs/promises')).readFile(s,"utf-8"),v=Je(w)[0],T=Ye(v),H=te(i,T);return de(v),g.apps??={},g.apps.tls??={},g.apps.tls.certificates??={load_files:[]},g.apps.tls.certificates.load_files??=[],g.apps.tls.certificates.load_files.push({certificate:s,key:u,tags:[H,"manual"]}),await m.request("/config/apps/tls/certificates",{method:"PATCH",body:JSON.stringify(g.apps.tls.certificates)}),H}async function Po(t,e,r){let n=x(N,t,"domain"),i=new P({adminUrl:r}),s=await i.getConfig();if(!s.apps?.tls?.certificates?.load_files)return 0;let u=s.apps.tls.certificates.load_files.length;s.apps.tls.certificates.load_files=s.apps.tls.certificates.load_files.filter(h=>{let g=h.tags?.some(w=>w.includes(n)),C=h.tags?.includes(e);return !g||C});let m=u-s.apps.tls.certificates.load_files.length;return m>0&&await i.request("/config/apps/tls/certificates",{method:"PATCH",body:JSON.stringify(s.apps.tls.certificates)}),m}async function jo(t){let e=new P({adminUrl:t});try{let r=await e.getServers(),n=new Set;for(let i of Object.values(r))if(i.routes){for(let s of i.routes)if(s.match){for(let u of s.match)if(u.host)for(let m of u.host)n.add(m);}}return Array.from(n).sort()}catch{return []}}var ue=S(()=>{K();pe();Z();Q();tt();Ze();});pe();Ze();pe();Q();function Ro(t){let e=t.toLowerCase();return e.endsWith(".json")?"json":e.endsWith(".yaml")||e.endsWith(".yml")?"yaml":e.endsWith(".nginx")||e.includes("nginx.conf")?"nginx":e.endsWith(".apache")||e.includes("httpd.conf")?"apache":"caddyfile"}async function wo(t,e,r){let n=F(t),i=await readFile(n,"utf-8"),s=e??Ro(t);return new P(r).adapt(i,s)}async function xa(t,e){return wo(t,"caddyfile",e)}ue();function it(t,e){if(e===t)return true;if(!e.includes("*"))return false;if(e.startsWith("*.")&&!e.slice(2).includes("*")){let n=e.slice(2);if(!t.endsWith("."+n))return false;let i=t.slice(0,t.length-n.length-1);return i.length>0&&!i.includes(".")}return new RegExp("^"+e.split(/\*+/).map(_a).join(".*")+"$").test(t)}function _a(t){return t.replace(/[.+?^${}()|[\]\\]/g,"\\$&")}var Ca=["TLS_AES_128_GCM_SHA256","TLS_AES_256_GCM_SHA384","TLS_CHACHA20_POLY1305_SHA256"],Ra=["TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256","TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"],wa=[...Ca,...Ra],va=["x25519","secp256r1","secp384r1"],Ha=["h3","h2","http/1.1"],Pa=["h2","http/1.1"],ja=["http/1.1"];function Ao(t){let e={};return t.sni&&t.sni.length>0&&(e.match={sni:t.sni}),(t.certificateTags||t.requiredCertificateTags)&&(e.certificate_selection={},t.certificateTags&&(e.certificate_selection.any_tag=t.certificateTags),t.requiredCertificateTags&&(e.certificate_selection.all_tags=t.requiredCertificateTags)),t.protocolMin&&(e.protocol_min=t.protocolMin==="1.2"?"tls1.2":"tls1.3"),t.protocolMax&&(e.protocol_max=t.protocolMax==="1.2"?"tls1.2":"tls1.3"),t.cipherSuites&&(t.cipherSuites==="modern"?e.cipher_suites=[...wa]:e.cipher_suites=t.cipherSuites),t.curves&&(t.curves==="recommended"?e.curves=[...va]:e.curves=t.curves),t.alpn&&(t.alpn==="http3"?e.alpn=[...Ha]:t.alpn==="http2"?e.alpn=[...Pa]:t.alpn==="http1"?e.alpn=[...ja]:e.alpn=t.alpn),(t.clientAuthMode||t.clientCaCertFiles)&&(e.client_authentication={},t.clientAuthMode&&(e.client_authentication.mode=t.clientAuthMode),t.clientCaCertFiles&&(e.client_authentication.trusted_ca_certs_pem_files=t.clientCaCertFiles)),e}function np(t){return Ao({...t,protocolMin:"1.3",cipherSuites:"modern",curves:"recommended",alpn:"http3"})}function ap(t){return Ao({...t,protocolMin:"1.2",cipherSuites:"modern",curves:"recommended",alpn:"http2"})}function ip(t={}){let e={module:"internal",...t.internalIssuer??{}},r=[];return t.includeLocalhostPolicy!==false&&r.push({subjects:["*.localhost","localhost"],issuers:[{...e}]}),r.push({issuers:[{...e}]}),{policies:r}}function Io(t){let e=t.toLowerCase().trim();return !!(!e||e==="localhost"||e==="*.localhost"||e.endsWith(".localhost")||/^\d{1,3}(\.\d{1,3}){3}(:\d+)?$/.test(e)||/^\[[0-9a-f:]+\](:\d+)?$/.test(e))}function sp(t){let e=new Set,r=n=>{if(!n)return;if(Array.isArray(n)){for(let s of n)r(s);return}if(typeof n!="object")return;let i=n;if(Array.isArray(i.match))for(let s of i.match){if(!s||typeof s!="object")continue;let u=s.host;if(Array.isArray(u))for(let m of u)typeof m!="string"||!m||Io(m)||e.add(m);}if(Array.isArray(i.handle))for(let s of i.handle)r(s);if(Array.isArray(i.routes))for(let s of i.routes)r(s);};return r(t),Array.from(e).sort()}function cp(t={}){let e={};t.disable&&(e.disable=true),t.disableRedirects&&(e.disable_redirects=true),t.disableCertificates&&(e.disable_certificates=true),t.ignoreLoadedCertificates&&(e.ignore_loaded_certificates=true);let r=s=>{if(!s||s.length===0)return [];let u=new Set;for(let m of s)typeof m!="string"||!m||Io(m)||u.add(m);return Array.from(u).sort()},n=r(t.skip);n.length>0&&(e.skip=n);let i=r(t.skipCerts);return i.length>0&&(e.skip_certificates=i),Object.keys(e).length>0?e:void 0}function lp(t,e){if(e.size===0)return [...t];let r=new Set,n=[];for(let i of e){let s=i.toLowerCase();r.add(s),s.includes("*")&&n.push(s);}return t.filter(i=>{let s=i.toLowerCase();if(r.has(s))return false;if(s.includes("*")){for(let u of r)if(it(u,s))return false}for(let u of n)if(it(s,u))return false;return true})}function pp(t,e){if(!t||typeof t!="object")throw new Error("applyLocalCaInstallTrust: `config` must be an object");let r=me(t,"apps","config.apps"),n=me(r,"pki","config.apps.pki"),i=me(n,"certificate_authorities","config.apps.pki.certificate_authorities"),s=me(i,"local","config.apps.pki.certificate_authorities.local");s.install_trust=e;}function me(t,e,r){let n=t[e];if(n==null){let i={};return t[e]=i,i}if(typeof n!="object"||Array.isArray(n))throw new Error(`applyLocalCaInstallTrust: ${r} exists but is not an object (got ${Array.isArray(n)?"array":typeof n})`);return n}var Aa=Object.freeze({porkbun:"porkbun",cloudflare:"cloudflare",route53:"route53",digitalocean:"digitalocean",godaddy:"godaddy"});function Ia(t){let e=t.trim().toLowerCase();return Aa[e]??e}function up(t){if(!Array.isArray(t.subjects)||t.subjects.length===0)throw new Error("buildAcmeDnsPolicy: `subjects` must be a non-empty array");let e=[];for(let s of t.subjects){if(typeof s!="string"||!s.trim())throw new Error("buildAcmeDnsPolicy: `subjects` entries must be non-empty strings");e.push(s.trim());}if(typeof t.dnsProvider!="string"||!t.dnsProvider.trim())throw new Error("buildAcmeDnsPolicy: `dnsProvider` is required");if(t.providerConfig){if(Object.prototype.hasOwnProperty.call(t.providerConfig,"name"))throw new Error("buildAcmeDnsPolicy: `providerConfig.name` is reserved \u2014 set the provider via `dnsProvider`");if(Object.prototype.hasOwnProperty.call(t.providerConfig,"module"))throw new Error("buildAcmeDnsPolicy: `providerConfig.module` is reserved \u2014 `module` is the issuer-level discriminator, not a provider field")}let r=Ia(t.dnsProvider),i={module:"acme",challenges:{dns:{provider:{...t.providerConfig??{},name:r}}}};return t.email&&(i.email=t.email),t.ca&&(i.ca=t.ca),{subjects:e,issuers:[i]}}var R={HEALTH:0,AUTH_DOMAIN:10,AUTH_PATH:20,SPECIFIC_PATH:30,REWRITE:40,SERVICE:50,WILDCARD:90,FALLBACK:100};function he(t){if(typeof t.priority=="number")return t.priority;if(t["@id"]==="global-health"||ko(t))return R.HEALTH;let e=t.match??[];if(e.length===0)return R.FALLBACK;let r=R.SERVICE;for(let n of e){let i=n.path??[];for(let s of i)s==="/health"?r=Math.min(r,R.HEALTH):s.includes("/admin")||s.includes("/auth")?r=Math.min(r,R.AUTH_PATH):s==="/*"?r=Math.max(r,R.WILDCARD):(s.includes("*"),r=Math.min(r,R.SPECIFIC_PATH));}return r}function ko(t){return (t.match??[]).some(r=>r.path?.some(n=>n==="/health"||n.includes("health")))}function ka(t){return !t.includes("*")&&!t.includes("{")?100:t.includes("{")?50:t.endsWith("*")?30+t.split("/").filter(r=>r&&r!=="*").length*5:t==="/*"?10:20}function Oa(t){let e=t.map(r=>({route:r,priority:he(r),specificity:Ta(r)}));return e.sort((r,n)=>r.priority!==n.priority?r.priority-n.priority:n.specificity-r.specificity),e.map(r=>{let{priority:n,...i}=r.route;return i})}function Ta(t){let e=t.match??[];if(e.length===0)return 0;let r=0;for(let n of e){let i=n.path??[];for(let u of i)r+=ka(u);let s=n.host??[];for(let u of s)u.includes("*")?r+=10:r+=20;r+=Object.keys(n).length*5;}return r}function Ea(t){if(t.length===0)return;let e=t.findIndex(n=>n["@id"]==="global-health"||ko(n));if(e>0)throw new Error(`Route ordering violation: Health check route must be first, but found at index ${e}`);for(let n=0;n<t.length-1;n++){let i=he(t[n]),s=he(t[n+1]);if(i>s){let u=t[n]["@id"]??`route-${n}`,m=t[n+1]["@id"]??`route-${n+1}`;throw new Error(`Route ordering violation: Route "${u}" (priority ${i}) should come after route "${m}" (priority ${s})`)}}let r=Ma(t);for(let[n,i]of Object.entries(r)){let s=i.findIndex(u=>u.match?.some(m=>m.path?.some(h=>h==="/*")));if(s!==-1)for(let u=s+1;u<i.length;u++){let m=i[u];if(m.match?.some(g=>g.path?.some(C=>C!=="/*"&&!C.includes("*")))){let g=i[s]["@id"]??`route-${s}`,C=m["@id"]??`route-${u}`;throw new Error(`Route ordering violation on host "${n}": Specific path route "${C}" should come before wildcard route "${g}"`)}}}}function Ma(t){let e={};for(let r of t){let n=r.match?.flatMap(i=>i.host??[])??["*"];for(let i of n)e[i]||(e[i]=[]),e[i].push(r);}return e}function Da(t,e,r={}){let n=[...t];if(r.position==="beginning")return n.unshift(e),n;if(r.position==="end")return n.push(e),n;if(r.beforeId){let i=n.findIndex(s=>s["@id"]===r.beforeId);if(i===-1)throw new Error(`Route with @id "${r.beforeId}" not found`);return n.splice(i,0,e),n}if(r.afterId){let i=n.findIndex(s=>s["@id"]===r.afterId);if(i===-1)throw new Error(`Route with @id "${r.afterId}" not found`);return n.splice(i+1,0,e),n}return n.push(e),n}function La(t){let e=t.path??"/health",r=JSON.stringify({status:"healthy",...t.services!==void 0&&{services:t.services},...t.version&&{version:t.version}});return {"@id":"global-health",priority:R.HEALTH,match:[{path:[e]}],handle:[{handler:"headers",response:{set:{"X-ASD-Health":["ok"],"X-ASD-Service-ID":[t.instanceId],...t.projectId?{"X-ASD-Project":[t.projectId]}:{}}}},{handler:"static_response",status_code:200,headers:{"Content-Type":["application/json"]},body:r}],terminal:true}}function za(t){let e=t.path??"/*",r=typeof t.upstream=="string"?[{dial:t.upstream}]:t.upstream,n={"X-Content-Type-Options":["nosniff"],"X-Frame-Options":["DENY"],...t.headers};t.serviceId&&(n["X-ASD-Service-ID"]=[t.serviceId]),t.serviceType&&(n["X-ASD-Service-Type"]=[t.serviceType]),t.projectId&&(n["X-ASD-Project"]=[t.projectId]);let i=[];t.enableCompression!==false&&i.push({handler:"encode",encodings:{gzip:{},zstd:{}}}),i.push({handler:"headers",response:{set:n}}),i.push({handler:"reverse_proxy",upstreams:r});let s=t.priority??(e==="/*"?R.WILDCARD:R.SPECIFIC_PATH);return {"@id":t.id,priority:s,match:[{host:[t.host],path:[e]}],handle:i,terminal:true}}function $a(t){let e=t.id??`auth-${t.host}${t.path?`-${t.path.replace(/[/*]/g,"")}`:""}`,r=t.path,n=typeof t.upstream=="string"?[{dial:t.upstream}]:t.upstream,i={"X-Content-Type-Options":["nosniff"],"X-Frame-Options":["DENY"],"X-ASD-Auth-Type":[r?"path-level":"domain-level"],...t.headers};t.serviceId&&(i["X-ASD-Service-ID"]=[t.serviceId]),t.serviceType&&(i["X-ASD-Service-Type"]=[t.serviceType]),t.projectId&&(i["X-ASD-Project"]=[t.projectId]);let s=t.priority??(r?R.AUTH_PATH:R.AUTH_DOMAIN);return {"@id":e,priority:s,match:[{host:[t.host],...r&&{path:[r]}}],handle:[{handler:"authentication",providers:{http_basic:{accounts:t.accounts,realm:t.realm??"Protected Area"}}},{handler:"headers",response:{set:i}},{handler:"reverse_proxy",upstreams:n}],terminal:true}}function Na(t){let e=t.path??"/*",r=t.upstreams.map(s=>typeof s=="string"?{dial:s}:s),n={"X-Content-Type-Options":["nosniff"],"X-Frame-Options":["DENY"],...t.headers};t.serviceId&&(n["X-ASD-Service-ID"]=[t.serviceId]);let i={handler:"reverse_proxy",upstreams:r};return t.policy&&(i.load_balancing={selection_policy:{policy:t.policy}}),t.healthCheck&&(i.health_checks={active:{path:t.healthCheck.path??"/health",interval:t.healthCheck.interval??"10s",timeout:t.healthCheck.timeout??"2s"}}),{"@id":t.id,priority:R.SERVICE,match:[{host:[t.host],path:[e]}],handle:[{handler:"headers",response:{set:n}},i],terminal:true}}function Fa(t){let e=typeof t.upstream=="string"?[{dial:t.upstream}]:t.upstream,r={"X-ASD-Path-Rewrite":["true"],"X-Content-Type-Options":["nosniff"],"X-Frame-Options":["SAMEORIGIN"],...t.headers};return t.serviceId&&(r["X-ASD-Service-ID"]=[t.serviceId]),{"@id":t.id,priority:R.REWRITE,match:[{host:[t.host],path:[`${t.pathPrefix}/*`]}],handle:[{handler:"rewrite",strip_path_prefix:t.pathPrefix},{handler:"headers",response:{set:r}},{handler:"reverse_proxy",upstreams:e}],terminal:true}}function qa(t){let e=t.statusCode??(t.permanent===false?307:308);return {"@id":t.id??`redirect-${t.from}-to-${t.to}`,priority:R.SERVICE,match:[{host:[t.from]}],handle:[{handler:"static_response",status_code:e,headers:{Location:[`https://${t.to}{http.request.uri}`]}}],terminal:true}}tt();var ge=class{constructor(e){this.client=e;}inspect(e){return Promise.resolve(de(e))}async rotate(e){let{domain:r,certPath:n,keyPath:i,adminUrl:s,cleanupOld:u=false}=e,{rotateCertificate:m}=await Promise.resolve().then(()=>(ue(),at)),h=await m(r,n,i,s),g={tag:h};return u&&(g.removedCount=await this.cleanupOld(r,h,s)),g}async cleanupOld(e,r,n){let{removeOldCertificates:i}=await Promise.resolve().then(()=>(ue(),at));return i(e,r,n)}async list(e){let n=(await this.client.getConfig()).apps?.tls;if(!n)return [];let i=n.certificates?.load_files??[],s=[];for(let u of i){let h=(u.tags??[]).find(C=>C.startsWith(`${e}-`));if(!h)continue;let g=u.certificate;if(typeof g=="string")try{let w=await(await import('fs/promises')).readFile(g,"utf-8"),O=await this.inspect(w),v=et(w);s.push({...O,tag:h,isExpired:Ke(w),expiringSoon:Qe(w,30),daysUntilExpiration:v});}catch{continue}}return s}async checkExpiration(e,r=30){let n=await this.list(e),i=n.filter(s=>s.isExpired||s.daysUntilExpiration<=r);return {hasExpiring:i.length>0,expiringCertificates:i,allCertificates:n}}generateTag(e,r){return Promise.resolve(te(e,r))}async isExpired(e){return Promise.resolve(Ke(e))}async isExpiringSoon(e,r=30){return Promise.resolve(Qe(e,r))}async getDaysUntilExpiration(e){return Promise.resolve(et(e))}};function Wa(t){return new ge(t)}async function Oo(t,e=10){if(e<4||e>31)throw new Error("Bcrypt rounds must be between 4 and 31");try{return await(await import('bcrypt')).hash(t,e)}catch{throw new Error("bcrypt module not found. Install it with: npm install bcrypt @types/bcrypt")}}async function Ba(t,e){try{return await(await import('bcrypt')).compare(t,e)}catch{throw new Error("bcrypt module not found. Install it with: npm install bcrypt @types/bcrypt")}}async function To(t){let{execFile:e}=await import('child_process'),{promisify:r}=await import('util'),n=r(e);try{let{stdout:i}=await n("caddy",["hash-password","--plaintext",t]);return i.trim()}catch{throw new Error(`Failed to hash password with Caddy CLI. Is Caddy installed?
3
+ `)),n=[],i=false):i&&n.push(s);return e}function Ke(t){return new X509Certificate(t).serialNumber}function Qe(t){let e=new X509Certificate(t);return new Date>e.notAfter}function et(t,e){let r=new X509Certificate(t),n=new Date;return n.setDate(n.getDate()+e),r.notAfter<=n}function tt(t){let e=new X509Certificate(t),r=new Date,n=e.notAfter.getTime()-r.getTime();return Math.floor(n/(1e3*60*60*24))}var ot=S(()=>{});var it={};Lo(it,{addDomainWithAutoTls:()=>rt,addDomainWithTls:()=>nt,deleteDomain:()=>at,getDomainConfig:()=>q,listDomains:()=>Ao,removeOldCertificates:()=>jo,rotateCertificate:()=>Po,updateDomain:()=>Ho});async function rt(t){let e=x(De,t,"addDomainWithAutoTls options"),r=new P({adminUrl:e.adminUrl});if(await q(e.domain,e.adminUrl))throw new V(e.domain);let i=[];e.redirectMode==="www_to_domain"?i.push(Ze({domain:e.domain,mode:"www-to-domain",permanent:true})):e.redirectMode==="domain_to_www"&&i.push(Ze({domain:e.domain,mode:"domain-to-www",permanent:true}));let s=[];e.enableSecurityHeaders&&s.push({handler:"headers",response:{set:{"X-Frame-Options":[e.frameOptions??"DENY"],"X-Content-Type-Options":["nosniff"],...e.enableHsts?{"Strict-Transport-Security":[`max-age=${e.hstsMaxAge}; includeSubDomains`]}:{}}}}),e.enableCompression!==false&&s.push(Ve()),s.push({handler:"reverse_proxy",upstreams:[{dial:`${e.target}:${e.targetPort}`}]}),i.push({"@id":e.domain,handle:s});let u={[e.domain]:{listen:[":443"],routes:i,automatic_https:{disable:false}}},h=await r.getConfig();return h.apps??={},h.apps.tls??={},h.apps.tls.automation??={policies:[]},h.apps.tls.automation.policies??=[],h.apps.tls.automation.policies.push({subjects:[e.domain],issuers:[{module:"acme"}]}),await r.patchServer(u),{domain:e.domain,target:e.target,targetPort:e.targetPort,tlsEnabled:true,autoTls:true,securityHeaders:{enableHsts:e.enableHsts??false,hstsMaxAge:e.hstsMaxAge??31536e3,frameOptions:e.frameOptions??"DENY",enableCompression:e.enableCompression??true},redirectMode:e.redirectMode??"none"}}async function nt(t){let e=x(so,t,"addDomainWithTls options"),r=new P({adminUrl:e.adminUrl});if(await q(e.domain,e.adminUrl))throw new V(e.domain);let i=[];e.redirectMode==="www_to_domain"?i.push(Ge({fromHost:`www.${e.domain}`,toHost:e.domain,permanent:true,statusCode:e.redirectStatusCode,id:`${e.domain}-redirect`})):e.redirectMode==="domain_to_www"&&i.push(Ge({fromHost:e.domain,toHost:`www.${e.domain}`,permanent:true,statusCode:e.redirectStatusCode,id:`${e.domain}-redirect`}));let s=[];e.enableSecurityHeaders&&s.push({handler:"headers",response:{set:{"X-Frame-Options":[e.frameOptions??"DENY"],"X-Content-Type-Options":["nosniff"],...e.enableHsts?{"Strict-Transport-Security":[`max-age=${e.hstsMaxAge}; includeSubDomains`]}:{}}}}),e.enableCompression!==false&&s.push(Ve()),s.push({handler:"reverse_proxy",upstreams:[{dial:`${e.target}:${e.targetPort}`}]}),i.push({"@id":e.domain,match:[{host:[e.domain]}],handle:s,terminal:true});let u={[e.domain]:{listen:[":443"],routes:i,tls_connection_policies:[{certificate_selection:{any_tag:["manual"]}}]}},h=await r.getConfig();h.apps??={},h.apps.tls??={},h.apps.tls.certificates??={load_files:[]},h.apps.tls.certificates.load_files??=[];let g=F(e.certFile),C=F(e.keyFile),O=await(await import('fs/promises')).readFile(g,"utf-8"),T=Ye(O)[0],H=Ke(T),oe=te(e.domain,H);return h.apps.tls.certificates.load_files.push({certificate:g,key:C,tags:[oe,"manual"]}),await r.request("/config/apps/tls",{method:"POST",body:JSON.stringify(h.apps.tls)}),await r.patchServer(u),{domain:e.domain,target:e.target,targetPort:e.targetPort,tlsEnabled:true,autoTls:false,certFile:e.certFile,keyFile:e.keyFile,securityHeaders:{enableHsts:e.enableHsts??false,hstsMaxAge:e.hstsMaxAge??31536e3,frameOptions:e.frameOptions??"DENY",enableCompression:e.enableCompression??true},redirectMode:e.redirectMode??"none"}}async function Ho(t){let e=x(co,t,"updateDomain options"),r=await q(e.domain,e.adminUrl);if(!r)throw new W(e.domain);let n={...r,...e.target&&{target:e.target},...e.targetPort&&{targetPort:e.targetPort},securityHeaders:{...r.securityHeaders,...e.enableHsts!==void 0&&{enableHsts:e.enableHsts},...e.hstsMaxAge!==void 0&&{hstsMaxAge:e.hstsMaxAge},...e.frameOptions!==void 0&&{frameOptions:e.frameOptions},...e.enableCompression!==void 0&&{enableCompression:e.enableCompression}},...e.redirectMode!==void 0&&{redirectMode:e.redirectMode}};return await at({domain:e.domain,adminUrl:e.adminUrl}),n.autoTls?rt({domain:n.domain,target:n.target,targetPort:n.targetPort,enableSecurityHeaders:true,enableHsts:n.securityHeaders.enableHsts,hstsMaxAge:n.securityHeaders.hstsMaxAge,frameOptions:n.securityHeaders.frameOptions,enableCompression:n.securityHeaders.enableCompression,redirectMode:n.redirectMode,adminUrl:e.adminUrl}):n.certFile&&n.keyFile?nt({domain:n.domain,target:n.target,targetPort:n.targetPort,certFile:n.certFile,keyFile:n.keyFile,enableSecurityHeaders:true,enableHsts:n.securityHeaders.enableHsts,hstsMaxAge:n.securityHeaders.hstsMaxAge,frameOptions:n.securityHeaders.frameOptions,enableCompression:n.securityHeaders.enableCompression,redirectMode:n.redirectMode,adminUrl:e.adminUrl}):n}async function at(t){let e=x(lo,t,"deleteDomain options"),r=new P({adminUrl:e.adminUrl});if(!await q(e.domain,e.adminUrl))throw new W(e.domain);let i=await r.getConfig();i.apps?.http?.servers?.[e.domain]&&delete i.apps.http.servers[e.domain],i.apps?.tls?.certificates&&(i.apps.tls.certificates.load_files&&(i.apps.tls.certificates.load_files=i.apps.tls.certificates.load_files.filter(s=>{let u=s.tags?.some(h=>h.includes(e.domain)),m=s.certificate?.includes(e.domain)??s.key?.includes(e.domain);return !u&&!m})),i.apps.tls.certificates.load_pem&&(i.apps.tls.certificates.load_pem=i.apps.tls.certificates.load_pem.filter(s=>!s.tags?.some(m=>m.includes(e.domain))))),i.apps?.tls?.automation?.policies&&(i.apps.tls.automation.policies=i.apps.tls.automation.policies.filter(s=>!s.subjects?.includes(e.domain))),await r.request("/config/",{method:"POST",body:JSON.stringify(i)});}async function q(t,e){let r=x(N,t,"domain"),n=new P({adminUrl:e});try{let s=(await n.getServers())[r];if(!s)return null;let u="127.0.0.1",m=3e3,h=!1,g="DENY",C=31536e3;if(s.routes&&s.routes.length>0){for(let O of s.routes)if(O.handle)for(let v of O.handle){if(v.handler==="reverse_proxy"&&v.upstreams?.[0]?.dial){let T=v.upstreams[0].dial,H=/^(.+):(\d+)$/.exec(T);H&&(u=H[1],m=parseInt(H[2],10));}if(v.handler==="headers"&&v.headers?.response?.set){let T=v.headers.response.set;if(T["Strict-Transport-Security"]){h=!0;let H=T["Strict-Transport-Security"][0],oe=/max-age=(\d+)/.exec(H);oe&&(C=parseInt(oe[1],10));}if(T["X-Frame-Options"]){let H=T["X-Frame-Options"][0];(H==="SAMEORIGIN"||H==="DENY")&&(g=H);}}}}let w=s.automatic_https?.disable!==!0;return {domain:r,target:u,targetPort:m,tlsEnabled:!0,autoTls:w,securityHeaders:{enableHsts:h,hstsMaxAge:C,frameOptions:g,enableCompression:!0},redirectMode:"none"}}catch{return null}}async function Po(t,e,r,n){let i=x(N,t,"domain"),s=F(e),u=F(r),m=new P({adminUrl:n});if(!await q(i,n))throw new W(i);let g=await m.getConfig(),w=await(await import('fs/promises')).readFile(s,"utf-8"),v=Ye(w)[0],T=Ke(v),H=te(i,T);return de(v),g.apps??={},g.apps.tls??={},g.apps.tls.certificates??={load_files:[]},g.apps.tls.certificates.load_files??=[],g.apps.tls.certificates.load_files.push({certificate:s,key:u,tags:[H,"manual"]}),await m.request("/config/apps/tls/certificates",{method:"PATCH",body:JSON.stringify(g.apps.tls.certificates)}),H}async function jo(t,e,r){let n=x(N,t,"domain"),i=new P({adminUrl:r}),s=await i.getConfig();if(!s.apps?.tls?.certificates?.load_files)return 0;let u=s.apps.tls.certificates.load_files.length;s.apps.tls.certificates.load_files=s.apps.tls.certificates.load_files.filter(h=>{let g=h.tags?.some(w=>w.includes(n)),C=h.tags?.includes(e);return !g||C});let m=u-s.apps.tls.certificates.load_files.length;return m>0&&await i.request("/config/apps/tls/certificates",{method:"PATCH",body:JSON.stringify(s.apps.tls.certificates)}),m}async function Ao(t){let e=new P({adminUrl:t});try{let r=await e.getServers(),n=new Set;for(let i of Object.values(r))if(i.routes){for(let s of i.routes)if(s.match){for(let u of s.match)if(u.host)for(let m of u.host)n.add(m);}}return Array.from(n).sort()}catch{return []}}var ue=S(()=>{K();pe();Z();Q();ot();Je();});pe();Je();pe();Q();function wo(t){let e=t.toLowerCase();return e.endsWith(".json")?"json":e.endsWith(".yaml")||e.endsWith(".yml")?"yaml":e.endsWith(".nginx")||e.includes("nginx.conf")?"nginx":e.endsWith(".apache")||e.includes("httpd.conf")?"apache":"caddyfile"}async function vo(t,e,r){let n=F(t),i=await readFile(n,"utf-8"),s=e??wo(t);return new P(r).adapt(i,s)}async function xa(t,e){return vo(t,"caddyfile",e)}ue();function st(t,e){if(e===t)return true;if(!e.includes("*"))return false;if(e.startsWith("*.")&&!e.slice(2).includes("*")){let n=e.slice(2);if(!t.endsWith("."+n))return false;let i=t.slice(0,t.length-n.length-1);return i.length>0&&!i.includes(".")}return new RegExp("^"+e.split(/\*+/).map(_a).join(".*")+"$").test(t)}function _a(t){return t.replace(/[.+?^${}()|[\]\\]/g,"\\$&")}var Ca=["TLS_AES_128_GCM_SHA256","TLS_AES_256_GCM_SHA384","TLS_CHACHA20_POLY1305_SHA256"],Ra=["TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256","TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256"],wa=[...Ca,...Ra],va=["x25519","secp256r1","secp384r1"],Ha=["h3","h2","http/1.1"],Pa=["h2","http/1.1"],ja=["http/1.1"];function ko(t){let e={};return t.sni&&t.sni.length>0&&(e.match={sni:t.sni}),(t.certificateTags||t.requiredCertificateTags)&&(e.certificate_selection={},t.certificateTags&&(e.certificate_selection.any_tag=t.certificateTags),t.requiredCertificateTags&&(e.certificate_selection.all_tags=t.requiredCertificateTags)),t.protocolMin&&(e.protocol_min=t.protocolMin==="1.2"?"tls1.2":"tls1.3"),t.protocolMax&&(e.protocol_max=t.protocolMax==="1.2"?"tls1.2":"tls1.3"),t.cipherSuites&&(t.cipherSuites==="modern"?e.cipher_suites=[...wa]:e.cipher_suites=t.cipherSuites),t.curves&&(t.curves==="recommended"?e.curves=[...va]:e.curves=t.curves),t.alpn&&(t.alpn==="http3"?e.alpn=[...Ha]:t.alpn==="http2"?e.alpn=[...Pa]:t.alpn==="http1"?e.alpn=[...ja]:e.alpn=t.alpn),(t.clientAuthMode||t.clientCaCertFiles)&&(e.client_authentication={},t.clientAuthMode&&(e.client_authentication.mode=t.clientAuthMode),t.clientCaCertFiles&&(e.client_authentication.trusted_ca_certs_pem_files=t.clientCaCertFiles)),e}function np(t){return ko({...t,protocolMin:"1.3",cipherSuites:"modern",curves:"recommended",alpn:"http3"})}function ap(t){return ko({...t,protocolMin:"1.2",cipherSuites:"modern",curves:"recommended",alpn:"http2"})}function ip(t={}){let e={module:"internal",...t.internalIssuer??{}},r=[];return t.includeLocalhostPolicy!==false&&r.push({subjects:["*.localhost","localhost"],issuers:[{...e}]}),r.push({issuers:[{...e}]}),{policies:r}}function Io(t){let e=t.toLowerCase().trim();return !!(!e||e==="localhost"||e==="*.localhost"||e.endsWith(".localhost")||/^\d{1,3}(\.\d{1,3}){3}(:\d+)?$/.test(e)||/^\[[0-9a-f:]+\](:\d+)?$/.test(e))}function sp(t){let e=new Set,r=n=>{if(!n)return;if(Array.isArray(n)){for(let s of n)r(s);return}if(typeof n!="object")return;let i=n;if(Array.isArray(i.match))for(let s of i.match){if(!s||typeof s!="object")continue;let u=s.host;if(Array.isArray(u))for(let m of u)typeof m!="string"||!m||Io(m)||e.add(m);}if(Array.isArray(i.handle))for(let s of i.handle)r(s);if(Array.isArray(i.routes))for(let s of i.routes)r(s);};return r(t),Array.from(e).sort()}function cp(t={}){let e={};t.disable&&(e.disable=true),t.disableRedirects&&(e.disable_redirects=true),t.disableCertificates&&(e.disable_certificates=true),t.ignoreLoadedCertificates&&(e.ignore_loaded_certificates=true);let r=s=>{if(!s||s.length===0)return [];let u=new Set;for(let m of s)typeof m!="string"||!m||Io(m)||u.add(m);return Array.from(u).sort()},n=r(t.skip);n.length>0&&(e.skip=n);let i=r(t.skipCerts);return i.length>0&&(e.skip_certificates=i),Object.keys(e).length>0?e:void 0}function lp(t,e){if(e.size===0)return [...t];let r=new Set,n=[];for(let i of e){let s=i.toLowerCase();r.add(s),s.includes("*")&&n.push(s);}return t.filter(i=>{let s=i.toLowerCase();if(r.has(s))return false;if(s.includes("*")){for(let u of r)if(st(u,s))return false}for(let u of n)if(st(s,u))return false;return true})}function pp(t,e){if(!t||typeof t!="object")throw new Error("applyLocalCaInstallTrust: `config` must be an object");let r=me(t,"apps","config.apps"),n=me(r,"pki","config.apps.pki"),i=me(n,"certificate_authorities","config.apps.pki.certificate_authorities"),s=me(i,"local","config.apps.pki.certificate_authorities.local");s.install_trust=e;}function me(t,e,r){let n=t[e];if(n==null){let i={};return t[e]=i,i}if(typeof n!="object"||Array.isArray(n))throw new Error(`applyLocalCaInstallTrust: ${r} exists but is not an object (got ${Array.isArray(n)?"array":typeof n})`);return n}var Aa=Object.freeze({porkbun:"porkbun",cloudflare:"cloudflare",route53:"route53",digitalocean:"digitalocean",godaddy:"godaddy"});function ka(t){let e=t.trim().toLowerCase();return Aa[e]??e}function up(t){if(!Array.isArray(t.subjects)||t.subjects.length===0)throw new Error("buildAcmeDnsPolicy: `subjects` must be a non-empty array");let e=[];for(let s of t.subjects){if(typeof s!="string"||!s.trim())throw new Error("buildAcmeDnsPolicy: `subjects` entries must be non-empty strings");e.push(s.trim());}if(typeof t.dnsProvider!="string"||!t.dnsProvider.trim())throw new Error("buildAcmeDnsPolicy: `dnsProvider` is required");if(t.providerConfig){if(Object.prototype.hasOwnProperty.call(t.providerConfig,"name"))throw new Error("buildAcmeDnsPolicy: `providerConfig.name` is reserved \u2014 set the provider via `dnsProvider`");if(Object.prototype.hasOwnProperty.call(t.providerConfig,"module"))throw new Error("buildAcmeDnsPolicy: `providerConfig.module` is reserved \u2014 `module` is the issuer-level discriminator, not a provider field")}let r=ka(t.dnsProvider),i={module:"acme",challenges:{dns:{provider:{...t.providerConfig??{},name:r}}}};return t.email&&(i.email=t.email),t.ca&&(i.ca=t.ca),{subjects:e,issuers:[i]}}var R={HEALTH:0,AUTH_DOMAIN:10,AUTH_PATH:20,SPECIFIC_PATH:30,REWRITE:40,SERVICE:50,WILDCARD:90,FALLBACK:100};function he(t){if(typeof t.priority=="number")return t.priority;if(t["@id"]==="global-health"||Oo(t))return R.HEALTH;let e=t.match??[];if(e.length===0)return R.FALLBACK;let r=R.SERVICE;for(let n of e){let i=n.path??[];for(let s of i)s==="/health"?r=Math.min(r,R.HEALTH):s.includes("/admin")||s.includes("/auth")?r=Math.min(r,R.AUTH_PATH):s==="/*"?r=Math.max(r,R.WILDCARD):(s.includes("*"),r=Math.min(r,R.SPECIFIC_PATH));}return r}function Oo(t){return (t.match??[]).some(r=>r.path?.some(n=>n==="/health"||n.includes("health")))}function Ia(t){return !t.includes("*")&&!t.includes("{")?100:t.includes("{")?50:t.endsWith("*")?30+t.split("/").filter(r=>r&&r!=="*").length*5:t==="/*"?10:20}function Oa(t){let e=t.map(r=>({route:r,priority:he(r),specificity:Ta(r)}));return e.sort((r,n)=>r.priority!==n.priority?r.priority-n.priority:n.specificity-r.specificity),e.map(r=>{let{priority:n,...i}=r.route;return i})}function Ta(t){let e=t.match??[];if(e.length===0)return 0;let r=0;for(let n of e){let i=n.path??[];for(let u of i)r+=Ia(u);let s=n.host??[];for(let u of s)u.includes("*")?r+=10:r+=20;r+=Object.keys(n).length*5;}return r}function Ea(t){if(t.length===0)return;let e=t.findIndex(n=>n["@id"]==="global-health"||Oo(n));if(e>0)throw new Error(`Route ordering violation: Health check route must be first, but found at index ${e}`);for(let n=0;n<t.length-1;n++){let i=he(t[n]),s=he(t[n+1]);if(i>s){let u=t[n]["@id"]??`route-${n}`,m=t[n+1]["@id"]??`route-${n+1}`;throw new Error(`Route ordering violation: Route "${u}" (priority ${i}) should come after route "${m}" (priority ${s})`)}}let r=Ma(t);for(let[n,i]of Object.entries(r)){let s=i.findIndex(u=>u.match?.some(m=>m.path?.some(h=>h==="/*")));if(s!==-1)for(let u=s+1;u<i.length;u++){let m=i[u];if(m.match?.some(g=>g.path?.some(C=>C!=="/*"&&!C.includes("*")))){let g=i[s]["@id"]??`route-${s}`,C=m["@id"]??`route-${u}`;throw new Error(`Route ordering violation on host "${n}": Specific path route "${C}" should come before wildcard route "${g}"`)}}}}function Ma(t){let e={};for(let r of t){let n=r.match?.flatMap(i=>i.host??[])??["*"];for(let i of n)e[i]||(e[i]=[]),e[i].push(r);}return e}function Da(t,e,r={}){let n=[...t];if(r.position==="beginning")return n.unshift(e),n;if(r.position==="end")return n.push(e),n;if(r.beforeId){let i=n.findIndex(s=>s["@id"]===r.beforeId);if(i===-1)throw new Error(`Route with @id "${r.beforeId}" not found`);return n.splice(i,0,e),n}if(r.afterId){let i=n.findIndex(s=>s["@id"]===r.afterId);if(i===-1)throw new Error(`Route with @id "${r.afterId}" not found`);return n.splice(i+1,0,e),n}return n.push(e),n}function La(t){let e=t.path??"/health",r=JSON.stringify({status:"healthy",...t.services!==void 0&&{services:t.services},...t.version&&{version:t.version}});return {"@id":"global-health",priority:R.HEALTH,match:[{path:[e]}],handle:[{handler:"headers",response:{set:{"X-ASD-Health":["ok"],"X-ASD-Service-ID":[t.instanceId],...t.projectId?{"X-ASD-Project":[t.projectId]}:{}}}},{handler:"static_response",status_code:200,headers:{"Content-Type":["application/json"]},body:r}],terminal:true}}function za(t){let e=t.path??"/*",r=typeof t.upstream=="string"?[{dial:t.upstream}]:t.upstream,n={"X-Content-Type-Options":["nosniff"],"X-Frame-Options":["DENY"],...t.headers};t.serviceId&&(n["X-ASD-Service-ID"]=[t.serviceId]),t.serviceType&&(n["X-ASD-Service-Type"]=[t.serviceType]),t.projectId&&(n["X-ASD-Project"]=[t.projectId]);let i=[];t.enableCompression!==false&&i.push({handler:"encode",encodings:{gzip:{},zstd:{}}}),i.push({handler:"headers",response:{set:n}}),i.push({handler:"reverse_proxy",upstreams:r});let s=t.priority??(e==="/*"?R.WILDCARD:R.SPECIFIC_PATH);return {"@id":t.id,priority:s,match:[{host:[t.host],path:[e]}],handle:i,terminal:true}}function $a(t){let e=t.id??`auth-${t.host}${t.path?`-${t.path.replace(/[/*]/g,"")}`:""}`,r=t.path,n=typeof t.upstream=="string"?[{dial:t.upstream}]:t.upstream,i={"X-Content-Type-Options":["nosniff"],"X-Frame-Options":["DENY"],"X-ASD-Auth-Type":[r?"path-level":"domain-level"],...t.headers};t.serviceId&&(i["X-ASD-Service-ID"]=[t.serviceId]),t.serviceType&&(i["X-ASD-Service-Type"]=[t.serviceType]),t.projectId&&(i["X-ASD-Project"]=[t.projectId]);let s=t.priority??(r?R.AUTH_PATH:R.AUTH_DOMAIN);return {"@id":e,priority:s,match:[{host:[t.host],...r&&{path:[r]}}],handle:[{handler:"authentication",providers:{http_basic:{accounts:t.accounts,realm:t.realm??"Protected Area"}}},{handler:"headers",response:{set:i}},{handler:"reverse_proxy",upstreams:n}],terminal:true}}function Na(t){let e=t.path??"/*",r=t.upstreams.map(s=>typeof s=="string"?{dial:s}:s),n={"X-Content-Type-Options":["nosniff"],"X-Frame-Options":["DENY"],...t.headers};t.serviceId&&(n["X-ASD-Service-ID"]=[t.serviceId]);let i={handler:"reverse_proxy",upstreams:r};return t.policy&&(i.load_balancing={selection_policy:{policy:t.policy}}),t.healthCheck&&(i.health_checks={active:{path:t.healthCheck.path??"/health",interval:t.healthCheck.interval??"10s",timeout:t.healthCheck.timeout??"2s"}}),{"@id":t.id,priority:R.SERVICE,match:[{host:[t.host],path:[e]}],handle:[{handler:"headers",response:{set:n}},i],terminal:true}}function Fa(t){let e=typeof t.upstream=="string"?[{dial:t.upstream}]:t.upstream,r={"X-ASD-Path-Rewrite":["true"],"X-Content-Type-Options":["nosniff"],"X-Frame-Options":["SAMEORIGIN"],...t.headers};return t.serviceId&&(r["X-ASD-Service-ID"]=[t.serviceId]),{"@id":t.id,priority:R.REWRITE,match:[{host:[t.host],path:[`${t.pathPrefix}/*`]}],handle:[{handler:"rewrite",strip_path_prefix:t.pathPrefix},{handler:"headers",response:{set:r}},{handler:"reverse_proxy",upstreams:e}],terminal:true}}function qa(t){let e=t.statusCode??(t.permanent===false?307:308);return {"@id":t.id??`redirect-${t.from}-to-${t.to}`,priority:R.SERVICE,match:[{host:[t.from]}],handle:[{handler:"static_response",status_code:e,headers:{Location:[`https://${t.to}{http.request.uri}`]}}],terminal:true}}ot();var ge=class{constructor(e){this.client=e;}inspect(e){return Promise.resolve(de(e))}async rotate(e){let{domain:r,certPath:n,keyPath:i,adminUrl:s,cleanupOld:u=false}=e,{rotateCertificate:m}=await Promise.resolve().then(()=>(ue(),it)),h=await m(r,n,i,s),g={tag:h};return u&&(g.removedCount=await this.cleanupOld(r,h,s)),g}async cleanupOld(e,r,n){let{removeOldCertificates:i}=await Promise.resolve().then(()=>(ue(),it));return i(e,r,n)}async list(e){let n=(await this.client.getConfig()).apps?.tls;if(!n)return [];let i=n.certificates?.load_files??[],s=[];for(let u of i){let h=(u.tags??[]).find(C=>C.startsWith(`${e}-`));if(!h)continue;let g=u.certificate;if(typeof g=="string")try{let w=await(await import('fs/promises')).readFile(g,"utf-8"),O=await this.inspect(w),v=tt(w);s.push({...O,tag:h,isExpired:Qe(w),expiringSoon:et(w,30),daysUntilExpiration:v});}catch{continue}}return s}async checkExpiration(e,r=30){let n=await this.list(e),i=n.filter(s=>s.isExpired||s.daysUntilExpiration<=r);return {hasExpiring:i.length>0,expiringCertificates:i,allCertificates:n}}generateTag(e,r){return Promise.resolve(te(e,r))}async isExpired(e){return Promise.resolve(Qe(e))}async isExpiringSoon(e,r=30){return Promise.resolve(et(e,r))}async getDaysUntilExpiration(e){return Promise.resolve(tt(e))}};function Wa(t){return new ge(t)}async function To(t,e=10){if(e<4||e>31)throw new Error("Bcrypt rounds must be between 4 and 31");try{return await(await import('bcrypt')).hash(t,e)}catch{throw new Error("bcrypt module not found. Install it with: npm install bcrypt @types/bcrypt")}}async function Ba(t,e){try{return await(await import('bcrypt')).compare(t,e)}catch{throw new Error("bcrypt module not found. Install it with: npm install bcrypt @types/bcrypt")}}async function Eo(t){let{execFile:e}=await import('child_process'),{promisify:r}=await import('util'),n=r(e);try{let{stdout:i}=await n("caddy",["hash-password","--plaintext",t]);return i.trim()}catch{throw new Error(`Failed to hash password with Caddy CLI. Is Caddy installed?
4
4
  Alternative: Use hashPassword() with npm install bcrypt
5
- Or manually run: caddy hash-password --plaintext <your-password>`)}}async function Eo(t,e,r){let n=r?.useCaddyCLI?await To(e):await Oo(e,r?.rounds);return {username:t,password:n}}async function Ua(t,e){return Promise.all(t.map(r=>Eo(r.username,r.password,e)))}K();export{Aa as ACME_DNS_PROVIDER_MODULE_MAP,P as CaddyClient,Te as CaddyClientOptionsSchema,L as CaddyRouteSchema,ge as CertificateManager,ja as HTTP1_ALPN_PROTOCOLS,Pa as HTTP2_ALPN_PROTOCOLS,Ha as HTTP_ALPN_PROTOCOLS,ze as HealthCheckRouteOptionsSchema,$e as HostRouteOptionsSchema,Fe as LoadBalancerRouteOptionsSchema,wa as MODERN_CIPHER_SUITES,Ne as PathRouteOptionsSchema,va as RECOMMENDED_CURVES,R as ROUTE_PRIORITIES,Le as ServiceRouteOptionsSchema,Ra as TLS_1_2_CIPHER_SUITES,Ca as TLS_1_3_CIPHER_SUITES,ot as addDomainWithAutoTls,rt as addDomainWithTls,pp as applyLocalCaInstallTrust,up as buildAcmeDnsPolicy,cp as buildAutomaticHttpsConfig,ip as buildAutomationPoliciesWithInternalFallback,So as buildBasicAuthHandler,ap as buildCompatibleTlsPolicy,Ge as buildCompressionHandler,Ml as buildDnsRebindingBypassHandler,zl as buildErrorRoute,Dl as buildFileServerRoute,fo as buildHealthCheckRoute,We as buildHostRoute,Co as buildIframeHeadersHandler,ba as buildIframePermissiveHandler,fa as buildIframeProxyRoute,Be as buildIngressTagHeadersHandler,kl as buildLoadBalancerRoute,ql as buildMapHandler,ga as buildMitmproxyRoute,Ol as buildMitmproxyRoutePair,El as buildMitmproxyWebSocketRoute,Tl as buildMitmproxyWebUiRoute,np as buildModernTlsPolicy,ma as buildPathRoute,Ue as buildProjectIdHeadersHandler,Xe as buildRedirectRoute,$l as buildRequestBodyHandler,yo as buildReverseProxyHandler,xo as buildRewriteHandler,bo as buildSecurityHeadersHandler,Il as buildServiceRoutes,Ll as buildTemplatesRoute,Ao as buildTlsConnectionPolicy,Fl as buildTracingHandler,Nl as buildVarsHandler,ya as buildWebSocketProxyRoute,Ve as buildWwwRedirect,he as calculateRoutePriority,sp as collectExternalHostsFromRoutes,Eo as createBasicAuthAccount,Ua as createBasicAuthAccounts,$a as createBasicAuthRoute,Wa as createCertificateManager,La as createHealthRoute,Na as createLoadBalancerRoute,qa as createRedirectRoute,Fa as createRewriteRoute,za as createServiceRoute,nt as deleteDomain,Ro as detectAdapter,lp as filterAcmeManagedFromSkip,q as getDomainConfig,Oo as hashPassword,To as hashPasswordWithCaddy,it as hostMatchesPattern,Da as insertRouteRelative,jo as listDomains,xa as loadCaddyfile,wo as loadConfig,Po as removeOldCertificates,Ia as resolveAcmeDnsProviderModule,Ho as rotateCertificate,Oa as sortRoutes,vo as updateDomain,Ea as validateRouteOrdering,Ba as verifyPassword};
5
+ Or manually run: caddy hash-password --plaintext <your-password>`)}}async function Mo(t,e,r){let n=r?.useCaddyCLI?await Eo(e):await To(e,r?.rounds);return {username:t,password:n}}async function Ua(t,e){return Promise.all(t.map(r=>Mo(r.username,r.password,e)))}K();export{Aa as ACME_DNS_PROVIDER_MODULE_MAP,P as CaddyClient,Ee as CaddyClientOptionsSchema,L as CaddyRouteSchema,ge as CertificateManager,ja as HTTP1_ALPN_PROTOCOLS,Pa as HTTP2_ALPN_PROTOCOLS,Ha as HTTP_ALPN_PROTOCOLS,$e as HealthCheckRouteOptionsSchema,Ne as HostRouteOptionsSchema,qe as LoadBalancerRouteOptionsSchema,wa as MODERN_CIPHER_SUITES,Fe as PathRouteOptionsSchema,va as RECOMMENDED_CURVES,R as ROUTE_PRIORITIES,ze as ServiceRouteOptionsSchema,Ra as TLS_1_2_CIPHER_SUITES,Ca as TLS_1_3_CIPHER_SUITES,rt as addDomainWithAutoTls,nt as addDomainWithTls,pp as applyLocalCaInstallTrust,up as buildAcmeDnsPolicy,cp as buildAutomaticHttpsConfig,ip as buildAutomationPoliciesWithInternalFallback,xo as buildBasicAuthHandler,ap as buildCompatibleTlsPolicy,Ve as buildCompressionHandler,Ml as buildDnsRebindingBypassHandler,zl as buildErrorRoute,Dl as buildFileServerRoute,yo as buildHealthCheckRoute,Be as buildHostRoute,Ro as buildIframeHeadersHandler,ba as buildIframePermissiveHandler,fa as buildIframeProxyRoute,Ue as buildIngressTagHeadersHandler,Il as buildLoadBalancerRoute,ql as buildMapHandler,ga as buildMitmproxyRoute,Ol as buildMitmproxyRoutePair,El as buildMitmproxyWebSocketRoute,Tl as buildMitmproxyWebUiRoute,np as buildModernTlsPolicy,ma as buildPathRoute,Xe as buildProjectIdHeadersHandler,Ge as buildRedirectRoute,$l as buildRequestBodyHandler,bo as buildReverseProxyHandler,_o as buildRewriteHandler,So as buildSecurityHeadersHandler,kl as buildServiceRoutes,Ll as buildTemplatesRoute,ko as buildTlsConnectionPolicy,Fl as buildTracingHandler,Nl as buildVarsHandler,ya as buildWebSocketProxyRoute,Ze as buildWwwRedirect,he as calculateRoutePriority,sp as collectExternalHostsFromRoutes,Mo as createBasicAuthAccount,Ua as createBasicAuthAccounts,$a as createBasicAuthRoute,Wa as createCertificateManager,La as createHealthRoute,Na as createLoadBalancerRoute,qa as createRedirectRoute,Fa as createRewriteRoute,za as createServiceRoute,at as deleteDomain,wo as detectAdapter,lp as filterAcmeManagedFromSkip,q as getDomainConfig,To as hashPassword,Eo as hashPasswordWithCaddy,st as hostMatchesPattern,Da as insertRouteRelative,Ao as listDomains,xa as loadCaddyfile,vo as loadConfig,jo as removeOldCertificates,ka as resolveAcmeDnsProviderModule,Po as rotateCertificate,Oa as sortRoutes,Ho as updateDomain,Ea as validateRouteOrdering,Ba as verifyPassword};
@@ -2732,4 +2732,4 @@ interface StaticResponse {
2732
2732
  abort?: boolean;
2733
2733
  }
2734
2734
 
2735
- export { type RemoteAdmin as $, type App as A, type ClientAuthentication as B, type ConnectionPolicy as C, type CertCacheOptions as D, type CertificateLoader as E, type CustomCertSelectionPolicy as F, type ACMEIssuer as G, type Handler as H, type Invoke as I, type ChainPreference as J, type HTTPChallengeConfig as K, type TLSALPNChallengeConfig as L, type MatcherSet as M, type DNSChallengeConfig as N, type InternalIssuer as O, type MatchRemoteIP$1 as P, type MatchServerName as Q, type Route as R, type Server as S, type TLS as T, type SessionTicketService as U, type StorageLoader as V, type FolderLoader as W, type AdminConfig as X, type ConfigSettings as Y, type ZeroSSLIssuer as Z, type IdentityConfig as _, type RouteList as a, type AdminAccess as a0, type AdminPermissions as a1, type AdminRouter as a2, type AdminRoute as a3, type AdminHandler as a4, type AdminHandlerFunc as a5, type APIError as a6, type Config as a7, type App$1 as a8, type ConfigLoader as a9, type Provisioner as aA, type Validator as aB, type CleanerUpper as aC, type ProxyFuncProducer as aD, type Replacer as aE, type ReplacerFunc as aF, type ReplacementFunc as aG, ReplacerCtxKey as aH, ExitCodeSuccess as aI, ExitCodeFailedStartup as aJ, ExitCodeForceQuit as aK, ExitCodeFailedQuit as aL, type StorageConverter as aM, type UsagePool as aN, type Constructor as aO, type Destructor as aP, type Duration as aa, type Event as ab, type CloudEvent as ac, type CtxKey as ad, ImportPath as ae, type Context as af, type FileSystems as ag, type NetworkAddress as ah, type ListenerFunc as ai, type ListenerWrapper as aj, type PacketConnWrapper as ak, type Logging as al, type WriterOpener as am, type BaseLog as an, type SinkLog as ao, type CustomLog as ap, type LogSampling as aq, type StdoutWriter as ar, type StderrWriter as as, type DiscardWriter as at, type ConfiguresFormatterDefault as au, DefaultLoggerName as av, type Module as aw, type ModuleInfo as ax, type ModuleID as ay, type ModuleMap as az, type RawMatcherSets as b, type MatcherSets as c, type AutoHTTPSConfig as d, type RequestMatcher as e, type RequestMatcherWithError as f, type HandlerError as g, type MiddlewareHandler as h, type ResponseHandler as i, type MatchExpression as j, type MatchPath as k, type MatchPathRE as l, type MatchMethod as m, type MatchQuery as n, type MatchHeader as o, type MatchHeaderRE as p, type MatchProtocol as q, type MatchNot as r, type MatchRemoteIP as s, type MatchClientIP as t, type MatchHost as u, type ServerLogConfig as v, type StaticError as w, type StaticResponse as x, type AutomationConfig as y, type AutomationPolicy as z };
2735
+ export { type Logging as $, type ACMEIssuer as A, type BaseLog as B, type CertCacheOptions as C, type CustomCertSelectionPolicy as D, type CustomLog as E, type DNSChallengeConfig as F, DefaultLoggerName as G, type Destructor as H, type DiscardWriter as I, type Duration as J, type Event as K, ExitCodeFailedQuit as L, ExitCodeFailedStartup as M, ExitCodeForceQuit as N, ExitCodeSuccess as O, type FileSystems as P, type FolderLoader as Q, type HTTPChallengeConfig as R, type Handler as S, type HandlerError as T, type IdentityConfig as U, ImportPath as V, type InternalIssuer as W, type Invoke as X, type ListenerFunc as Y, type ListenerWrapper as Z, type LogSampling as _, type APIError as a, type MatchClientIP as a0, type MatchExpression as a1, type MatchHeader as a2, type MatchHeaderRE as a3, type MatchHost as a4, type MatchMethod as a5, type MatchNot as a6, type MatchPath as a7, type MatchPathRE as a8, type MatchProtocol as a9, type Server as aA, type ServerLogConfig as aB, type SessionTicketService as aC, type SinkLog as aD, type StaticError as aE, type StaticResponse as aF, type StderrWriter as aG, type StdoutWriter as aH, type StorageConverter as aI, type StorageLoader as aJ, type TLS as aK, type TLSALPNChallengeConfig as aL, type UsagePool as aM, type Validator as aN, type WriterOpener as aO, type ZeroSSLIssuer as aP, type MatchQuery as aa, type MatchRemoteIP as ab, type MatchRemoteIP$1 as ac, type MatchServerName as ad, type MatcherSet as ae, type MatcherSets as af, type MiddlewareHandler as ag, type Module as ah, type ModuleID as ai, type ModuleInfo as aj, type ModuleMap as ak, type NetworkAddress as al, type PacketConnWrapper as am, type Provisioner as an, type ProxyFuncProducer as ao, type RawMatcherSets as ap, type RemoteAdmin as aq, type ReplacementFunc as ar, type Replacer as as, ReplacerCtxKey as at, type ReplacerFunc as au, type RequestMatcher as av, type RequestMatcherWithError as aw, type ResponseHandler as ax, type Route as ay, type RouteList as az, type AdminAccess as b, type AdminConfig as c, type AdminHandler as d, type AdminHandlerFunc as e, type AdminPermissions as f, type AdminRoute as g, type AdminRouter as h, type App$1 as i, type App as j, type AutoHTTPSConfig as k, type AutomationConfig as l, type AutomationPolicy as m, type CertificateLoader as n, type ChainPreference as o, type CleanerUpper as p, type ClientAuthentication as q, type CloudEvent as r, type Config as s, type ConfigLoader as t, type ConfigSettings as u, type ConfiguresFormatterDefault as v, type ConnectionPolicy as w, type Constructor as x, type Context as y, type CtxKey as z };
@@ -2240,4 +2240,4 @@ declare const appSchema: z.ZodObject<{
2240
2240
  } | undefined> | undefined;
2241
2241
  }>;
2242
2242
 
2243
- export { cleanerUpperSchema as $, adminRouterSchema as A, adminHandlerSchema as B, adminHandlerFuncSchema as C, apiErrorSchema as D, moduleMapSchema as E, appSchema$1 as F, configLoaderSchema as G, cloudEventSchema as H, ctxKeySchema as I, contextSchema as J, fileSystemsSchema as K, networkAddressSchema as L, listenerFuncSchema as M, listenerWrapperSchema as N, packetConnWrapperSchema as O, writerOpenerSchema as P, logSamplingSchema as Q, baseLogSchema as R, customLogSchema as S, stdoutWriterSchema as T, stderrWriterSchema as U, discardWriterSchema as V, configuresFormatterDefaultSchema as W, moduleSchema as X, moduleIdSchema as Y, provisionerSchema as Z, validatorSchema as _, appSchema as a, proxyFuncProducerSchema as a0, replacerSchema as a1, replacerFuncSchema as a2, replacementFuncSchema as a3, storageConverterSchema as a4, usagePoolSchema as a5, constructorSchema as a6, destructorSchema as a7, configSettingsSchema as a8, adminAccessSchema as a9, adminRouteSchema as aa, sinkLogSchema as ab, moduleInfoSchema as ac, remoteAdminSchema as ad, adminConfigSchema as ae, loggingSchema as af, configSchema as ag, routeListSchema as b, autoHttpsConfigSchema as c, responseHandlerSchema as d, matchPathSchema as e, matchPathReSchema as f, matchMethodSchema as g, matchQuerySchema as h, invokeSchema as i, matchHeaderSchema as j, matchHeaderReSchema as k, matchProtocolSchema as l, matchExpressionSchema as m, matchNotSchema as n, matchRemoteIpSchema as o, matchClientIpSchema as p, matchHostSchema as q, routeSchema as r, serverSchema as s, matchTlsSchema as t, serverLogConfigSchema as u, staticErrorSchema as v, staticResponseSchema as w, identityConfigSchema as x, durationSchema as y, adminPermissionsSchema as z };
2243
+ export { remoteAdminSchema as $, identityConfigSchema as A, invokeSchema as B, listenerFuncSchema as C, listenerWrapperSchema as D, logSamplingSchema as E, loggingSchema as F, matchClientIpSchema as G, matchExpressionSchema as H, matchHeaderReSchema as I, matchHeaderSchema as J, matchHostSchema as K, matchMethodSchema as L, matchNotSchema as M, matchPathReSchema as N, matchPathSchema as O, matchProtocolSchema as P, matchQuerySchema as Q, matchRemoteIpSchema as R, matchTlsSchema as S, moduleIdSchema as T, moduleInfoSchema as U, moduleMapSchema as V, moduleSchema as W, networkAddressSchema as X, packetConnWrapperSchema as Y, provisionerSchema as Z, proxyFuncProducerSchema as _, adminAccessSchema as a, replacementFuncSchema as a0, replacerFuncSchema as a1, replacerSchema as a2, responseHandlerSchema as a3, routeListSchema as a4, routeSchema as a5, serverLogConfigSchema as a6, serverSchema as a7, sinkLogSchema as a8, staticErrorSchema as a9, staticResponseSchema as aa, stderrWriterSchema as ab, stdoutWriterSchema as ac, storageConverterSchema as ad, usagePoolSchema as ae, validatorSchema as af, writerOpenerSchema as ag, adminConfigSchema as b, adminHandlerFuncSchema as c, adminHandlerSchema as d, adminPermissionsSchema as e, adminRouteSchema as f, adminRouterSchema as g, apiErrorSchema as h, appSchema$1 as i, appSchema as j, autoHttpsConfigSchema as k, baseLogSchema as l, cleanerUpperSchema as m, cloudEventSchema as n, configLoaderSchema as o, configSchema as p, configSettingsSchema as q, configuresFormatterDefaultSchema as r, constructorSchema as s, contextSchema as t, ctxKeySchema as u, customLogSchema as v, destructorSchema as w, discardWriterSchema as x, durationSchema as y, fileSystemsSchema as z };
@@ -1,5 +1,5 @@
1
- export { G as ACMEIssuer, a6 as APIError, a0 as AdminAccess, X as AdminConfig, a4 as AdminHandler, a5 as AdminHandlerFunc, a1 as AdminPermissions, a3 as AdminRoute, a2 as AdminRouter, a8 as App, d as AutoHTTPSConfig, y as AutomationConfig, z as AutomationPolicy, an as BaseLog, D as CertCacheOptions, E as CertificateLoader, J as ChainPreference, aC as CleanerUpper, B as ClientAuthentication, ac as CloudEvent, a7 as Config, a9 as ConfigLoader, Y as ConfigSettings, au as ConfiguresFormatterDefault, C as ConnectionPolicy, aO as Constructor, af as Context, ad as CtxKey, F as CustomCertSelectionPolicy, ap as CustomLog, N as DNSChallengeConfig, av as DefaultLoggerName, aP as Destructor, at as DiscardWriter, aa as Duration, ab as Event, aL as ExitCodeFailedQuit, aJ as ExitCodeFailedStartup, aK as ExitCodeForceQuit, aI as ExitCodeSuccess, ag as FileSystems, W as FolderLoader, K as HTTPChallengeConfig, H as Handler, g as HandlerError, A as HttpApp, s as HttpMatchRemoteIP, _ as IdentityConfig, ae as ImportPath, O as InternalIssuer, I as Invoke, ai as ListenerFunc, aj as ListenerWrapper, aq as LogSampling, al as Logging, t as MatchClientIP, j as MatchExpression, o as MatchHeader, p as MatchHeaderRE, u as MatchHost, m as MatchMethod, r as MatchNot, k as MatchPath, l as MatchPathRE, q as MatchProtocol, n as MatchQuery, Q as MatchServerName, M as MatcherSet, c as MatcherSets, h as MiddlewareHandler, aw as Module, ay as ModuleID, ax as ModuleInfo, az as ModuleMap, ah as NetworkAddress, ak as PacketConnWrapper, aA as Provisioner, aD as ProxyFuncProducer, b as RawMatcherSets, $ as RemoteAdmin, aG as ReplacementFunc, aE as Replacer, aH as ReplacerCtxKey, aF as ReplacerFunc, e as RequestMatcher, f as RequestMatcherWithError, i as ResponseHandler, R as Route, a as RouteList, S as Server, v as ServerLogConfig, U as SessionTicketService, ao as SinkLog, w as StaticError, x as StaticResponse, as as StderrWriter, ar as StdoutWriter, aM as StorageConverter, V as StorageLoader, T as TLS, L as TLSALPNChallengeConfig, P as TlsMatchRemoteIP, aN as UsagePool, aB as Validator, am as WriterOpener, Z as ZeroSSLIssuer } from './caddy-http-DLxwstYo.js';
2
- export { a9 as adminAccessSchema, ae as adminConfigSchema, C as adminHandlerFuncSchema, B as adminHandlerSchema, z as adminPermissionsSchema, aa as adminRouteSchema, A as adminRouterSchema, D as apiErrorSchema, F as appSchema, c as autoHttpsConfigSchema, R as baseLogSchema, $ as cleanerUpperSchema, H as cloudEventSchema, G as configLoaderSchema, ag as configSchema, a8 as configSettingsSchema, W as configuresFormatterDefaultSchema, a6 as constructorSchema, J as contextSchema, I as ctxKeySchema, S as customLogSchema, a7 as destructorSchema, V as discardWriterSchema, y as durationSchema, K as fileSystemsSchema, a as httpAppSchema, o as httpMatchRemoteIpSchema, t as httpMatchTlsSchema, x as identityConfigSchema, i as invokeSchema, M as listenerFuncSchema, N as listenerWrapperSchema, Q as logSamplingSchema, af as loggingSchema, p as matchClientIpSchema, m as matchExpressionSchema, k as matchHeaderReSchema, j as matchHeaderSchema, q as matchHostSchema, g as matchMethodSchema, n as matchNotSchema, f as matchPathReSchema, e as matchPathSchema, l as matchProtocolSchema, h as matchQuerySchema, Y as moduleIdSchema, ac as moduleInfoSchema, E as moduleMapSchema, X as moduleSchema, L as networkAddressSchema, O as packetConnWrapperSchema, Z as provisionerSchema, a0 as proxyFuncProducerSchema, ad as remoteAdminSchema, a3 as replacementFuncSchema, a2 as replacerFuncSchema, a1 as replacerSchema, d as responseHandlerSchema, b as routeListSchema, r as routeSchema, u as serverLogConfigSchema, s as serverSchema, ab as sinkLogSchema, v as staticErrorSchema, w as staticResponseSchema, U as stderrWriterSchema, T as stdoutWriterSchema, a4 as storageConverterSchema, a5 as usagePoolSchema, _ as validatorSchema, P as writerOpenerSchema } from './caddy-http.zod-Cx-dcFkE.js';
1
+ export { A as ACMEIssuer, a as APIError, b as AdminAccess, c as AdminConfig, d as AdminHandler, e as AdminHandlerFunc, f as AdminPermissions, g as AdminRoute, h as AdminRouter, i as App, k as AutoHTTPSConfig, l as AutomationConfig, m as AutomationPolicy, B as BaseLog, C as CertCacheOptions, n as CertificateLoader, o as ChainPreference, p as CleanerUpper, q as ClientAuthentication, r as CloudEvent, s as Config, t as ConfigLoader, u as ConfigSettings, v as ConfiguresFormatterDefault, w as ConnectionPolicy, x as Constructor, y as Context, z as CtxKey, D as CustomCertSelectionPolicy, E as CustomLog, F as DNSChallengeConfig, G as DefaultLoggerName, H as Destructor, I as DiscardWriter, J as Duration, K as Event, L as ExitCodeFailedQuit, M as ExitCodeFailedStartup, N as ExitCodeForceQuit, O as ExitCodeSuccess, P as FileSystems, Q as FolderLoader, R as HTTPChallengeConfig, S as Handler, T as HandlerError, j as HttpApp, ab as HttpMatchRemoteIP, U as IdentityConfig, V as ImportPath, W as InternalIssuer, X as Invoke, Y as ListenerFunc, Z as ListenerWrapper, _ as LogSampling, $ as Logging, a0 as MatchClientIP, a1 as MatchExpression, a2 as MatchHeader, a3 as MatchHeaderRE, a4 as MatchHost, a5 as MatchMethod, a6 as MatchNot, a7 as MatchPath, a8 as MatchPathRE, a9 as MatchProtocol, aa as MatchQuery, ad as MatchServerName, ae as MatcherSet, af as MatcherSets, ag as MiddlewareHandler, ah as Module, ai as ModuleID, aj as ModuleInfo, ak as ModuleMap, al as NetworkAddress, am as PacketConnWrapper, an as Provisioner, ao as ProxyFuncProducer, ap as RawMatcherSets, aq as RemoteAdmin, ar as ReplacementFunc, as as Replacer, at as ReplacerCtxKey, au as ReplacerFunc, av as RequestMatcher, aw as RequestMatcherWithError, ax as ResponseHandler, ay as Route, az as RouteList, aA as Server, aB as ServerLogConfig, aC as SessionTicketService, aD as SinkLog, aE as StaticError, aF as StaticResponse, aG as StderrWriter, aH as StdoutWriter, aI as StorageConverter, aJ as StorageLoader, aK as TLS, aL as TLSALPNChallengeConfig, ac as TlsMatchRemoteIP, aM as UsagePool, aN as Validator, aO as WriterOpener, aP as ZeroSSLIssuer } from './caddy-http-jhg7B7CZ.js';
2
+ export { a as adminAccessSchema, b as adminConfigSchema, c as adminHandlerFuncSchema, d as adminHandlerSchema, e as adminPermissionsSchema, f as adminRouteSchema, g as adminRouterSchema, h as apiErrorSchema, i as appSchema, k as autoHttpsConfigSchema, l as baseLogSchema, m as cleanerUpperSchema, n as cloudEventSchema, o as configLoaderSchema, p as configSchema, q as configSettingsSchema, r as configuresFormatterDefaultSchema, s as constructorSchema, t as contextSchema, u as ctxKeySchema, v as customLogSchema, w as destructorSchema, x as discardWriterSchema, y as durationSchema, z as fileSystemsSchema, j as httpAppSchema, R as httpMatchRemoteIpSchema, S as httpMatchTlsSchema, A as identityConfigSchema, B as invokeSchema, C as listenerFuncSchema, D as listenerWrapperSchema, E as logSamplingSchema, F as loggingSchema, G as matchClientIpSchema, H as matchExpressionSchema, I as matchHeaderReSchema, J as matchHeaderSchema, K as matchHostSchema, L as matchMethodSchema, M as matchNotSchema, N as matchPathReSchema, O as matchPathSchema, P as matchProtocolSchema, Q as matchQuerySchema, T as moduleIdSchema, U as moduleInfoSchema, V as moduleMapSchema, W as moduleSchema, X as networkAddressSchema, Y as packetConnWrapperSchema, Z as provisionerSchema, _ as proxyFuncProducerSchema, $ as remoteAdminSchema, a0 as replacementFuncSchema, a1 as replacerFuncSchema, a2 as replacerSchema, a3 as responseHandlerSchema, a4 as routeListSchema, a5 as routeSchema, a6 as serverLogConfigSchema, a7 as serverSchema, a8 as sinkLogSchema, a9 as staticErrorSchema, aa as staticResponseSchema, ab as stderrWriterSchema, ac as stdoutWriterSchema, ad as storageConverterSchema, ae as usagePoolSchema, af as validatorSchema, ag as writerOpenerSchema } from './caddy-http.zod-T9FvybMd.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  declare const chainPreferenceSchema: z.ZodObject<{