@shipstatic/ship 2.0.0-beta.7 → 2.0.0-beta.8

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
@@ -53,7 +53,7 @@ ship deployments list --limit 20 # Page size; a hint shows the
53
53
  ship deployments list --cursor <cursor> # Continue from a previous page
54
54
  ship deployments get <deployment>
55
55
  ship deployments set <deployment> --label production
56
- ship deployments remove <deployment>
56
+ ship deployments delete <deployment>
57
57
  ```
58
58
 
59
59
  ```typescript
@@ -62,7 +62,7 @@ ship.deployments.upload(input, options?)
62
62
  ship.deployments.list(options?) // { limit?, cursor? } — response carries the next cursor
63
63
  ship.deployments.get(deployment)
64
64
  ship.deployments.set(deployment, { labels })
65
- ship.deployments.remove(deployment)
65
+ ship.deployments.delete(deployment)
66
66
  ```
67
67
 
68
68
  ### Domains
@@ -78,7 +78,7 @@ ship domains verify www.example.com
78
78
  ship domains records www.example.com
79
79
  ship domains dns www.example.com
80
80
  ship domains share www.example.com
81
- ship domains remove www.example.com
81
+ ship domains delete www.example.com
82
82
  ```
83
83
 
84
84
  ```typescript
@@ -90,7 +90,7 @@ ship.domains.verify(name)
90
90
  ship.domains.records(name)
91
91
  ship.domains.dns(name)
92
92
  ship.domains.share(name)
93
- ship.domains.remove(name)
93
+ ship.domains.delete(name)
94
94
  ```
95
95
 
96
96
  `domains.set()` is a merge-upsert — omitted fields are preserved on update, defaulted on create. Once linked, a domain cannot be unlinked (`{ deployment: null }` → 400). Switch deployments or delete the domain instead.
@@ -107,13 +107,13 @@ ship.domains.set('www.münchen.de'); // → Unicode supported
107
107
  ```bash
108
108
  ship tokens create --ttl 3600 --label ci
109
109
  ship tokens list
110
- ship tokens remove <token>
110
+ ship tokens delete <token>
111
111
  ```
112
112
 
113
113
  ```typescript
114
114
  ship.tokens.create({ ttl?, labels? })
115
115
  ship.tokens.list()
116
- ship.tokens.remove(token)
116
+ ship.tokens.delete(token)
117
117
  ```
118
118
 
119
119
  ### Account
@@ -143,8 +143,8 @@ ship ./dist -q | ship domains set www.example.com
143
143
  # Deploy and open in browser
144
144
  open https://$(ship ./dist -q)
145
145
 
146
- # Batch remove all deployments
147
- ship deployments list -q | xargs -I{} ship deployments remove {} -q
146
+ # Batch delete all deployments
147
+ ship deployments list -q | xargs -I{} ship deployments delete {} -q
148
148
  ```
149
149
 
150
150
  ### Shell Completion
package/dist/browser.d.ts CHANGED
@@ -276,6 +276,10 @@ interface DnsLookup {
276
276
  /** The provider serving this domain's DNS, absent when unidentified */
277
277
  provider?: DnsProvider;
278
278
  }
279
+ /**
280
+ * A report: it answers a question and carries only the answer (`CLAUDE.md`,
281
+ * "A report answers a question").
282
+ */
279
283
  interface DomainDnsResponse {
280
284
  /** The domain name */
281
285
  domain: string;
@@ -288,6 +292,9 @@ interface DomainDnsResponse {
288
292
  *
289
293
  * `/admin/domains/:domain/share` answers the same shape, which is the admin
290
294
  * law working: the operator surface is the public grammar with a prefix.
295
+ *
296
+ * A report: it answers a question and carries only the answer (`CLAUDE.md`,
297
+ * "A report answers a question").
291
298
  */
292
299
  interface DomainShareResponse {
293
300
  /** The domain the setup link is for */
@@ -297,6 +304,9 @@ interface DomainShareResponse {
297
304
  }
298
305
  /**
299
306
  * Response for domain DNS records
307
+ *
308
+ * A report: it answers a question and carries only the answer (`CLAUDE.md`,
309
+ * "A report answers a question").
300
310
  */
301
311
  interface DomainRecordsResponse {
302
312
  /** The domain name */
@@ -332,6 +342,9 @@ declare function validateIdempotencyKey(value: unknown): string | undefined;
332
342
  * no identity, no row and no `created`, so there is nothing for a keyset
333
343
  * cursor to resume after, and its consumer is an autocomplete that wants the
334
344
  * whole set. Bounded by `PAGINATION.GLOBAL_LIMIT` rather than paginated.
345
+ *
346
+ * A report: it answers a question and carries only the answer (`CLAUDE.md`,
347
+ * "A report answers a question").
335
348
  */
336
349
  interface LabelsResponse {
337
350
  readonly labels: string[];
@@ -342,8 +355,13 @@ interface LabelsResponse {
342
355
  *
343
356
  * `custom` is the provider-specific walkthrough when the provider is known;
344
357
  * `generic` always answers, so a caller never has nothing to show.
358
+ *
359
+ * A report: it answers a question and carries only the answer (`CLAUDE.md`,
360
+ * "A report answers a question").
345
361
  */
346
362
  interface SetupInstructionsResponse {
363
+ /** The domain the instructions are for — a report names its subject */
364
+ readonly domain: string;
347
365
  /** One-line summary of what to do */
348
366
  readonly tldr: string;
349
367
  /** Provider-specific instructions, null when the provider is unknown */
@@ -354,7 +372,14 @@ interface SetupInstructionsResponse {
354
372
  readonly provider: string | null;
355
373
  }
356
374
  /**
357
- * Response for domain validation
375
+ * `POST /domains/validate` a report answering "is this name usable, and if
376
+ * not, why".
377
+ *
378
+ * An unusable name is a legitimate ANSWER, not a failure, so this is a 200 and
379
+ * the verdict rides the body. `reason` was named `error` until 2026-07-29,
380
+ * which collided with {@link ErrorResponse}'s reserved key — there `error` is
381
+ * an `ErrorType` a client branches on, here it is prose a client displays, and
382
+ * one key cannot mean both. See {@link DeploymentDeleteResponse} for the law.
358
383
  */
359
384
  interface DomainValidateResponse {
360
385
  /** Whether the domain is valid */
@@ -363,8 +388,8 @@ interface DomainValidateResponse {
363
388
  normalized: string | null;
364
389
  /** Whether the domain is available, null when invalid */
365
390
  available: boolean | null;
366
- /** Error message, null when valid */
367
- error: string | null;
391
+ /** Why the name is unusable, null when valid — displayed verbatim. */
392
+ reason: string | null;
368
393
  }
369
394
  /**
370
395
  * Core deploy token object - used in both API responses and SDK.
@@ -521,6 +546,9 @@ interface AccountDeleteResponse {
521
546
  * (`Account.hint`), and the plaintext exists exactly once, in this response.
522
547
  * The raw credential is `secret` on every surface that mints one — the same
523
548
  * field `TokenCreateResponse` carries — because one concept gets one name.
549
+ *
550
+ * A report: it answers a question and carries only the answer (`CLAUDE.md`,
551
+ * "A report answers a question").
524
552
  */
525
553
  interface AccountKeyResponse {
526
554
  /** The raw API key (shown once at mint, then never again) */
@@ -711,6 +739,9 @@ declare function isShipError(error: unknown): error is ShipError;
711
739
  *
712
740
  * These are the *platform's* posted caps for the current account — server
713
741
  * truth delivered at runtime, never hard-coded on the client.
742
+ *
743
+ * A report: it answers a question and carries only the answer (`CLAUDE.md`,
744
+ * "A report answers a question").
714
745
  */
715
746
  interface PlatformLimits {
716
747
  /** Maximum size in bytes for a single file. */
@@ -781,13 +812,20 @@ declare const UNBUILT_PROJECT_MARKERS: ReadonlySet<string>;
781
812
  */
782
813
  declare function hasUnbuiltMarker(filePath: string): boolean;
783
814
  /**
784
- * Simple ping response for health checks
815
+ * `GET /ping` a report of the server clock.
816
+ *
817
+ * Liveness is the STATUS CODE's answer, not a field's: a 200 means reachable,
818
+ * and any other outcome throws before a body is read. So the body carries the
819
+ * one thing a status code cannot — the server's own clock, which is what lets a
820
+ * client detect skew against a token expiry. It read `{ success: true,
821
+ * timestamp? }` until 2026-07-29, where `success` was a literal constant in the
822
+ * route (zero bits, and the platform's own named anti-pattern) while the field
823
+ * that IS the payload was optional. See {@link DeploymentDeleteResponse} for
824
+ * the law, and `tests/response-shapes.test.ts` for the fence that holds it.
785
825
  */
786
826
  interface PingResponse {
787
- /** Always true if service is healthy */
788
- success: boolean;
789
827
  /** Server time in unix seconds — the one wire unit for timestamps. */
790
- timestamp?: number;
828
+ readonly timestamp: number;
791
829
  }
792
830
  /**
793
831
  * Where human identity is mounted on the API host. The API mounts Better
@@ -992,6 +1030,10 @@ interface SPACheckDebug {
992
1030
  /** The reason for the detection result */
993
1031
  reason: string;
994
1032
  }
1033
+ /**
1034
+ * A report: it answers a question and carries only the answer (`CLAUDE.md`,
1035
+ * "A report answers a question").
1036
+ */
995
1037
  interface SPACheckResponse {
996
1038
  /** Whether the project is detected as a Single Page Application */
997
1039
  isSPA: boolean;
@@ -1150,7 +1192,7 @@ interface DeploymentResource<UploadOptions extends DeploymentUploadOptions = Dep
1150
1192
  list: (options?: ListOptions) => Promise<DeploymentListResponse>;
1151
1193
  get: (id: string) => Promise<Deployment>;
1152
1194
  set: (id: string, options: DeploymentSetOptions) => Promise<Deployment>;
1153
- remove: (id: string) => Promise<DeploymentDeleteResponse>;
1195
+ delete: (id: string) => Promise<DeploymentDeleteResponse>;
1154
1196
  }
1155
1197
  /**
1156
1198
  * Domain resource interface - the contract all implementations must follow
@@ -1159,7 +1201,7 @@ interface DomainResource {
1159
1201
  set: (name: string, options?: DomainSetOptions) => Promise<DomainSetResult>;
1160
1202
  list: (options?: ListOptions) => Promise<DomainListResponse>;
1161
1203
  get: (name: string) => Promise<Domain>;
1162
- remove: (name: string) => Promise<DomainDeleteResponse>;
1204
+ delete: (name: string) => Promise<DomainDeleteResponse>;
1163
1205
  verify: (name: string) => Promise<DomainVerifyResponse>;
1164
1206
  validate: (name: string) => Promise<DomainValidateResponse>;
1165
1207
  dns: (name: string) => Promise<DomainDnsResponse>;
@@ -1179,7 +1221,7 @@ interface TokenResource {
1179
1221
  create: (options?: TokenCreateOptions) => Promise<TokenCreateResponse>;
1180
1222
  list: (options?: ListOptions) => Promise<TokenListResponse>;
1181
1223
  get: (token: string) => Promise<Token>;
1182
- remove: (token: string) => Promise<TokenDeleteResponse>;
1224
+ delete: (token: string) => Promise<TokenDeleteResponse>;
1183
1225
  }
1184
1226
  /**
1185
1227
  * Billing status response from GET /billing/status
@@ -1199,6 +1241,25 @@ interface BillingStatus {
1199
1241
  /** Link to Creem customer portal for billing management, null if unavailable */
1200
1242
  portal: string | null;
1201
1243
  }
1244
+ /**
1245
+ * Acknowledgement of `POST /billing/cancel`.
1246
+ *
1247
+ * Cancelling leaves no billing entity to return, so it answers with the
1248
+ * account and the one field of the account the call changed — the plan it
1249
+ * landed on. See {@link DeploymentDeleteResponse} for the law.
1250
+ *
1251
+ * This read `{ success: true, message: 'Subscription canceled successfully…' }`
1252
+ * until 2026-07-29, an anonymous shape that `web/my` redeclared inline and
1253
+ * whose prose no surface ever displayed: both callers await the promise and
1254
+ * discard the body, then compose their own toast. The message was written,
1255
+ * serialized, and thrown away on every cancellation.
1256
+ */
1257
+ interface BillingCancelResponse {
1258
+ /** The account whose subscription was cancelled */
1259
+ readonly account: string;
1260
+ /** The plan the account now holds — `free` on a successful cancellation */
1261
+ readonly plan: AccountPlanType;
1262
+ }
1202
1263
  /**
1203
1264
  * Checkout session response from POST /billing/checkout
1204
1265
  */
@@ -1723,11 +1784,11 @@ declare class ApiHttp extends SimpleEvents {
1723
1784
  listDeployments(options?: ListOptions): Promise<DeploymentListResponse>;
1724
1785
  getDeployment(id: string): Promise<Deployment>;
1725
1786
  updateDeploymentLabels(id: string, labels: string[]): Promise<Deployment>;
1726
- removeDeployment(id: string): Promise<DeploymentDeleteResponse>;
1787
+ deleteDeployment(id: string): Promise<DeploymentDeleteResponse>;
1727
1788
  setDomain(name: string, deployment?: string, labels?: string[]): Promise<DomainSetResult>;
1728
1789
  listDomains(options?: ListOptions): Promise<DomainListResponse>;
1729
1790
  getDomain(name: string): Promise<Domain>;
1730
- removeDomain(name: string): Promise<DomainDeleteResponse>;
1791
+ deleteDomain(name: string): Promise<DomainDeleteResponse>;
1731
1792
  verifyDomain(name: string): Promise<DomainVerifyResponse>;
1732
1793
  getDomainDns(name: string): Promise<DomainDnsResponse>;
1733
1794
  getDomainRecords(name: string): Promise<DomainRecordsResponse>;
@@ -1735,11 +1796,11 @@ declare class ApiHttp extends SimpleEvents {
1735
1796
  validateDomain(name: string): Promise<DomainValidateResponse>;
1736
1797
  createToken(ttl?: number, labels?: string[]): Promise<TokenCreateResponse>;
1737
1798
  listTokens(options?: ListOptions): Promise<TokenListResponse>;
1738
- removeToken(token: string): Promise<TokenDeleteResponse>;
1799
+ deleteToken(token: string): Promise<TokenDeleteResponse>;
1739
1800
  getToken(token: string): Promise<Token>;
1740
1801
  getAccount(): Promise<AccountGetResponse>;
1741
1802
  getLimits(): Promise<PlatformLimits>;
1742
- ping(): Promise<boolean>;
1803
+ ping(): Promise<PingResponse>;
1743
1804
  checkSPA(files: StaticFile[], _options?: ApiDeployOptions): Promise<boolean>;
1744
1805
  }
1745
1806
 
@@ -1809,9 +1870,16 @@ declare abstract class Ship$1 {
1809
1870
  protected ensureInitialized(): Promise<void>;
1810
1871
  private fetchPlatformLimits;
1811
1872
  /**
1812
- * Ping the API server to check connectivity.
1873
+ * Ping the API server, resolving its answer: `{ success, timestamp }`, where
1874
+ * `timestamp` is the server clock in unix SECONDS.
1875
+ *
1876
+ * It resolves the response rather than a bare `true` because every other
1877
+ * method here does — narrowing to a boolean discarded the one thing ping
1878
+ * carries beyond liveness, and made `success` mean a boolean on the wire and
1879
+ * something else by the time it reached a caller. A non-OK response throws in
1880
+ * transport, so a resolved value always means the API answered.
1813
1881
  */
1814
- ping(): Promise<boolean>;
1882
+ ping(): Promise<PingResponse>;
1815
1883
  /**
1816
1884
  * Deploy project (convenience shortcut to `ship.deployments.upload()`).
1817
1885
  */
@@ -2170,4 +2238,4 @@ declare class Ship extends Ship$1 {
2170
2238
  protected getDeployBodyCreator(): DeployBodyCreator;
2171
2239
  }
2172
2240
 
2173
- export { API_KEY, API_PATHS, AUTH_BASE_PATH, type Account, type AccountDeleteResponse, type AccountGetResponse, type AccountKeyResponse, type AccountOverrides, AccountPlan, type AccountPlanType, type AccountResource, type AccountUsage, type Activity, type ActivityEvent, type ActivityListResponse, type ActivityMeta, type ApiDeployOptions, ApiHttp, type ApiHttpOptions, AuthMethod, type AuthMethodType, BLOCKED_EXTENSIONS, type BillingStatus, CALLER, type CheckoutSession, DEFAULT_API, DEPLOYMENT_CONFIG_FILENAME, DEPLOY_TOKEN, type DeployBody, type DeployBodyContext, type DeployBodyCreator, type DeployFile, type DeployInput, type Deployment, type DeploymentCreateResponse, type DeploymentDeleteResponse, type DeploymentListResponse, type DeploymentOptions, type DeploymentResource, type DeploymentResourceContext, type DeploymentSetOptions, DeploymentStatus, type DeploymentStatusType, type DeploymentUploadOptions, type DnsLookup, type DnsProvider, type DnsRecord, type DnsRecordType, type Domain, type DomainDeleteResponse, type DomainDnsResponse, type DomainListResponse, type DomainRecordsResponse, type DomainResource, type DomainSetOptions, type DomainSetResult, type DomainShareResponse, DomainStatus, type DomainStatusType, type DomainValidateResponse, type DomainVerifyResponse, type ErrorResponse, ErrorType, type ExecutionEnvironment, FileValidationStatus as FILE_VALIDATION_STATUS, type Fetch, type FileValidationResult, FileValidationStatus, type FileValidationStatusType, IDEMPOTENCY_KEY_CONSTRAINTS, JUNK_DIRECTORIES, LABEL_CONSTRAINTS, LABEL_PATTERN, type LabelsResponse, type ListOptions, type ListResponse, type MD5Result, OAuthScope, type OAuthScopeType, PASSWORD_CONSTRAINTS, type PingResponse, type PlatformLimits, type ResourceContext, type SPACheckDebug, type SPACheckRequest, type SPACheckResponse, SPA_DEFAULT_CONFIG, type SetupInstructionsResponse, Ship, type ShipClientOptions, ShipError, type ShipEvents, type StaticFile, type Token, type TokenCreateOptions, type TokenCreateResponse, type TokenDeleteResponse, TokenKind, type TokenKindType, type TokenListResponse, type TokenProvider, type TokenResource, UNBUILT_PROJECT_MARKERS, UNSAFE_FILENAME_CHARS, type UploadedFile, type UserVisibleActivityEvent, type ValidatableFile, type ValidationIssue, __setTestEnvironment, allValidFilesReady, assertShipJsonSyntax, calculateMD5, classifyToken, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, deserializeLabels, extractSubdomain, filterJunk, formatFileSize, generateDeploymentUrl, generateDomainUrl, getENV, getValidFiles, hasUnbuiltMarker, hasUnsafeChars, isBlockedExtension, isCustomDomain, isDeployment, isPlatformDomain, isShipError, optimizeDeployPaths, pluralize, processFilesForBrowser, serializeLabels, validateApiKey, validateApiUrl, validateCaller, validateDeployFile, validateDeployPath, validateDeployToken, validateFileName, validateFiles, validateIdempotencyKey, validatePassword, validateToken };
2241
+ export { API_KEY, API_PATHS, AUTH_BASE_PATH, type Account, type AccountDeleteResponse, type AccountGetResponse, type AccountKeyResponse, type AccountOverrides, AccountPlan, type AccountPlanType, type AccountResource, type AccountUsage, type Activity, type ActivityEvent, type ActivityListResponse, type ActivityMeta, type ApiDeployOptions, ApiHttp, type ApiHttpOptions, AuthMethod, type AuthMethodType, BLOCKED_EXTENSIONS, type BillingCancelResponse, type BillingStatus, CALLER, type CheckoutSession, DEFAULT_API, DEPLOYMENT_CONFIG_FILENAME, DEPLOY_TOKEN, type DeployBody, type DeployBodyContext, type DeployBodyCreator, type DeployFile, type DeployInput, type Deployment, type DeploymentCreateResponse, type DeploymentDeleteResponse, type DeploymentListResponse, type DeploymentOptions, type DeploymentResource, type DeploymentResourceContext, type DeploymentSetOptions, DeploymentStatus, type DeploymentStatusType, type DeploymentUploadOptions, type DnsLookup, type DnsProvider, type DnsRecord, type DnsRecordType, type Domain, type DomainDeleteResponse, type DomainDnsResponse, type DomainListResponse, type DomainRecordsResponse, type DomainResource, type DomainSetOptions, type DomainSetResult, type DomainShareResponse, DomainStatus, type DomainStatusType, type DomainValidateResponse, type DomainVerifyResponse, type ErrorResponse, ErrorType, type ExecutionEnvironment, FileValidationStatus as FILE_VALIDATION_STATUS, type Fetch, type FileValidationResult, FileValidationStatus, type FileValidationStatusType, IDEMPOTENCY_KEY_CONSTRAINTS, JUNK_DIRECTORIES, LABEL_CONSTRAINTS, LABEL_PATTERN, type LabelsResponse, type ListOptions, type ListResponse, type MD5Result, OAuthScope, type OAuthScopeType, PASSWORD_CONSTRAINTS, type PingResponse, type PlatformLimits, type ResourceContext, type SPACheckDebug, type SPACheckRequest, type SPACheckResponse, SPA_DEFAULT_CONFIG, type SetupInstructionsResponse, Ship, type ShipClientOptions, ShipError, type ShipEvents, type StaticFile, type Token, type TokenCreateOptions, type TokenCreateResponse, type TokenDeleteResponse, TokenKind, type TokenKindType, type TokenListResponse, type TokenProvider, type TokenResource, UNBUILT_PROJECT_MARKERS, UNSAFE_FILENAME_CHARS, type UploadedFile, type UserVisibleActivityEvent, type ValidatableFile, type ValidationIssue, __setTestEnvironment, allValidFilesReady, assertShipJsonSyntax, calculateMD5, classifyToken, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, deserializeLabels, extractSubdomain, filterJunk, formatFileSize, generateDeploymentUrl, generateDomainUrl, getENV, getValidFiles, hasUnbuiltMarker, hasUnsafeChars, isBlockedExtension, isCustomDomain, isDeployment, isPlatformDomain, isShipError, optimizeDeployPaths, pluralize, processFilesForBrowser, serializeLabels, validateApiKey, validateApiUrl, validateCaller, validateDeployFile, validateDeployPath, validateDeployToken, validateFileName, validateFiles, validateIdempotencyKey, validatePassword, validateToken };
package/dist/browser.js CHANGED
@@ -1,2 +1,2 @@
1
- var Ye=Object.create;var U=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty;var et=(t,r,e)=>r in t?U(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;var v=(t,r)=>()=>(t&&(r=t(t=0)),r);var fe=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports),tt=(t,r)=>{for(var e in r)U(t,e,{get:r[e],enumerable:!0})},nt=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let p of Je(r))!Ze.call(t,p)&&p!==e&&U(t,p,{get:()=>r[p],enumerable:!(a=We(r,p))||a.enumerable});return t};var M=(t,r,e)=>(e=t!=null?Ye(Qe(t)):{},nt(r||!t||!t.__esModule?U(e,"default",{value:t,enumerable:!0}):e,t));var B=(t,r,e)=>et(t,typeof r!="symbol"?r+"":r,e);function ye(t){if(t==null)return;if(typeof t!="string")throw f.validation("Idempotency key must be a string.");let r=t.trim();if(!r)throw f.validation("Idempotency key must not be empty.");if(r.length>me.MAX_LENGTH)throw f.validation(`Idempotency key must be at most ${me.MAX_LENGTH} characters.`);return r}function ge(t){return t!==null&&typeof t=="object"&&"name"in t&&t.name==="ShipError"&&"status"in t}function G(t){let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return!1;let e=t.slice(r+1).toLowerCase();return ot.has(e)}function Ee(t){return at.test(t)}function k(t){return t.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>lt.has(e))}function pt(t){return t.startsWith(Ae.PREFIX)?O.API_KEY:t.startsWith(De.PREFIX)?O.DEPLOY_TOKEN:O.OPAQUE}function Se(t){let r=t.charCodeAt(0)===65279?t.slice(1):t,e;try{e=JSON.parse(r)}catch(a){throw f.config(`invalid JSON format in config: ${a.message}`,{filePath:x})}if(e===null||typeof e!="object"||Array.isArray(e))throw f.config(`${x} must contain a JSON object`,{filePath:x})}function be(t,r,e){if(!t.startsWith(r.PREFIX))throw f.validation(`${e} must start with "${r.PREFIX}"`);if(t.length!==r.TOTAL_LENGTH)throw f.validation(`${e} must be ${r.TOTAL_LENGTH} characters total (${r.PREFIX} + ${r.HEX_LENGTH} hex chars)`);let a=t.slice(r.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${r.HEX_LENGTH}}$`,"i").test(a))throw f.validation(`${e} must contain ${r.HEX_LENGTH} hexadecimal characters after "${r.PREFIX}" prefix`)}function ut(t){be(t,Ae,"API key")}function ct(t){be(t,De,"Deploy token")}function J(t){switch(pt(t)){case O.API_KEY:ut(t);return;case O.DEPLOY_TOKEN:ct(t);return;case O.OPAQUE:if(!t)throw f.validation("Token must be a non-empty string")}}function Re(t){if(!t||t.length>W.MAX_LENGTH||!W.PATTERN.test(t))throw f.validation(`Caller must be 1-${W.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function Ft(t){try{let r=new URL(t);if(!["http:","https:"].includes(r.protocol))throw f.validation("API URL must use http:// or https:// protocol");if(r.pathname!=="/"&&r.pathname!=="")throw f.validation("API URL must not contain a path");if(r.search||r.hash)throw f.validation("API URL must not contain query parameters or fragments")}catch(r){throw ge(r)?r:f.validation("API URL must be a valid URL")}}function Ot(t){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(t)}function we(t,r){return t.endsWith(`.${r}`)}function _t(t,r){return!we(t,r)}function Ct(t,r){return we(t,r)?t.slice(0,-(r.length+1)):null}function $t(t){return`https://${t}`}function Ut(t){return`https://${t}`}function Mt(t){return!t||t.length===0?null:JSON.stringify(t)}function Bt(t){if(!t)return[];try{let r=JSON.parse(t);return Array.isArray(r)?r:[]}catch{return[]}}function Z(t){if(t==null)return;if(typeof t!="string")throw f.validation("Password must be a string");let r=t.trim();if(r.length<H.MIN_LENGTH||r.length>H.MAX_LENGTH)throw f.validation(`Password must be between ${H.MIN_LENGTH} and ${H.MAX_LENGTH} characters`);return r}var vt,T,Pt,me,xt,A,rt,Y,it,st,f,ot,at,lt,Lt,he,Ae,De,W,O,Nt,x,Te,Q,S,N,Ie,H,b=v(()=>{"use strict";vt={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},T={DEPLOYMENTS:"/deployments",DEPLOYMENT:t=>`/deployments/${t}`,DEPLOYMENT_CONFIG:t=>`/deployments/${t}/config`,DOMAINS:"/domains",DOMAIN:t=>`/domains/${t}`,DOMAIN_VERIFY:t=>`/domains/${t}/verify`,DOMAIN_DNS:t=>`/domains/${t}/dns`,DOMAIN_RECORDS:t=>`/domains/${t}/records`,DOMAIN_SHARE:t=>`/domains/${t}/share`,DOMAIN_PROPAGATION:t=>`/domains/${t}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:t=>`/tokens/${t}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},Pt={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},me={MAX_LENGTH:256,WINDOW_SECONDS:1440*60};xt={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},A={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},rt=new Set([A.Network,A.Cancelled,A.File,A.Config]),Y={client:new Set([A.Business,A.Config,A.File,A.Forbidden,A.NotFound,A.RateLimit,A.Validation]),network:new Set([A.Network]),auth:new Set([A.Authentication])},it=new Set(Object.values(A).filter(t=>!rt.has(t))),st=200,f=class t extends Error{constructor(e,a,p,c){super(a);B(this,"type");B(this,"status");B(this,"details");this.type=e,this.status=p,this.details=c,this.name="ShipError"}toResponse(){let e=this.details,a=this.type===A.Authentication&&e?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:a}}static async fromHttpResponse(e,a){let p,c,h;try{if(e.headers.get("content-type")?.includes("application/json")){let m=await e.json();if(m&&typeof m=="object"){let E=m;typeof E.message=="string"?p=E.message:typeof E.error=="string"&&(p=E.error),c=E.details,typeof E.error=="string"&&it.has(E.error)&&(h=E.error)}}else{let m=(await e.text()).trim();m&&!m.startsWith("<")&&m.length<=st&&(p=m)}}catch{}let y=e.headers.get("retry-after");if(y!==null){let g=y.trim(),m=/^\d+$/.test(g)?Number(g):Math.ceil((Date.parse(g)-Date.now())/1e3);if(Number.isFinite(m)&&m>=0){let E=c&&typeof c=="object"?c:{};E.retryAfter===void 0&&(c={...E,retryAfter:m})}}p=p||`${a||"Request"} failed with status ${e.status}`;let d=h??(e.status===401?A.Authentication:e.status===403?A.Forbidden:e.status===429?A.RateLimit:A.Api);return new t(d,p,e.status,c)}static fromFetchError(e,a){if(ge(e))return e;let p=a||"Request";return e instanceof Error?e.name==="AbortError"?t.cancelled(`${p} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?t.network(`${p} failed: ${e.message}`,{cause:e}):new t(A.Api,`${p} failed: ${e.message}`):new t(A.Api,`${p} failed: Unknown error`)}static validation(e,a){return new t(A.Validation,e,400,a)}static notFound(e,a){let p=a?`${e} ${a} not found`:`${e} not found`;return new t(A.NotFound,p,404)}static forbidden(e,a){return new t(A.Forbidden,e,403,a)}static rateLimit(e="Too many requests",a){return new t(A.RateLimit,e,429,a)}static authentication(e="Authentication required",a){return new t(A.Authentication,e,401,a)}static business(e,a=400,p){return new t(A.Business,e,a,p)}static network(e,a){return new t(A.Network,e,void 0,a)}static cancelled(e,a){return new t(A.Cancelled,e,void 0,a)}static file(e,a){return new t(A.File,e,void 0,a)}static config(e,a){return new t(A.Config,e,void 0,a)}static api(e,a=500,p){return new t(A.Api,e,a,p)}isClientError(){return Y.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return Y.network.has(this.type)}isAuthError(){return Y.auth.has(this.type)}isType(e){return this.type===e}};ot=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);at=/[\x00-\x1f\x7f#?%\\<>"]/;lt=new Set(["node_modules","package.json"]);Lt="/auth",he={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},Ae={PREFIX:"ship-",HEX_LENGTH:64,TOTAL_LENGTH:69,HINT_LENGTH:4},De={PREFIX:"deploy-",HEX_LENGTH:64,TOTAL_LENGTH:71},W={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},O={API_KEY:he.API_KEY,DEPLOY_TOKEN:he.TOKEN,OPAQUE:"opaque"};Nt={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},x="ship.json",Te={rewrites:[{source:"/(.*)",destination:"/index.html"}]};Q="https://api.shipstatic.com",S={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};N={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Ie=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;H={MIN_LENGTH:6,MAX_LENGTH:128}});var Ne=fe((xe,Le)=>{"use strict";(function(t){if(typeof xe=="object")Le.exports=t();else if(typeof define=="function"&&define.amd)define(t);else{var r;try{r=window}catch{r=self}r.SparkMD5=t()}})(function(t){"use strict";var r=function(u,l){return u+l&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(u,l,i,n,o,s){return l=r(r(l,u),r(n,s)),r(l<<o|l>>>32-o,i)}function p(u,l){var i=u[0],n=u[1],o=u[2],s=u[3];i+=(n&o|~n&s)+l[0]-680876936|0,i=(i<<7|i>>>25)+n|0,s+=(i&n|~i&o)+l[1]-389564586|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&n)+l[2]+606105819|0,o=(o<<17|o>>>15)+s|0,n+=(o&s|~o&i)+l[3]-1044525330|0,n=(n<<22|n>>>10)+o|0,i+=(n&o|~n&s)+l[4]-176418897|0,i=(i<<7|i>>>25)+n|0,s+=(i&n|~i&o)+l[5]+1200080426|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&n)+l[6]-1473231341|0,o=(o<<17|o>>>15)+s|0,n+=(o&s|~o&i)+l[7]-45705983|0,n=(n<<22|n>>>10)+o|0,i+=(n&o|~n&s)+l[8]+1770035416|0,i=(i<<7|i>>>25)+n|0,s+=(i&n|~i&o)+l[9]-1958414417|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&n)+l[10]-42063|0,o=(o<<17|o>>>15)+s|0,n+=(o&s|~o&i)+l[11]-1990404162|0,n=(n<<22|n>>>10)+o|0,i+=(n&o|~n&s)+l[12]+1804603682|0,i=(i<<7|i>>>25)+n|0,s+=(i&n|~i&o)+l[13]-40341101|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&n)+l[14]-1502002290|0,o=(o<<17|o>>>15)+s|0,n+=(o&s|~o&i)+l[15]+1236535329|0,n=(n<<22|n>>>10)+o|0,i+=(n&s|o&~s)+l[1]-165796510|0,i=(i<<5|i>>>27)+n|0,s+=(i&o|n&~o)+l[6]-1069501632|0,s=(s<<9|s>>>23)+i|0,o+=(s&n|i&~n)+l[11]+643717713|0,o=(o<<14|o>>>18)+s|0,n+=(o&i|s&~i)+l[0]-373897302|0,n=(n<<20|n>>>12)+o|0,i+=(n&s|o&~s)+l[5]-701558691|0,i=(i<<5|i>>>27)+n|0,s+=(i&o|n&~o)+l[10]+38016083|0,s=(s<<9|s>>>23)+i|0,o+=(s&n|i&~n)+l[15]-660478335|0,o=(o<<14|o>>>18)+s|0,n+=(o&i|s&~i)+l[4]-405537848|0,n=(n<<20|n>>>12)+o|0,i+=(n&s|o&~s)+l[9]+568446438|0,i=(i<<5|i>>>27)+n|0,s+=(i&o|n&~o)+l[14]-1019803690|0,s=(s<<9|s>>>23)+i|0,o+=(s&n|i&~n)+l[3]-187363961|0,o=(o<<14|o>>>18)+s|0,n+=(o&i|s&~i)+l[8]+1163531501|0,n=(n<<20|n>>>12)+o|0,i+=(n&s|o&~s)+l[13]-1444681467|0,i=(i<<5|i>>>27)+n|0,s+=(i&o|n&~o)+l[2]-51403784|0,s=(s<<9|s>>>23)+i|0,o+=(s&n|i&~n)+l[7]+1735328473|0,o=(o<<14|o>>>18)+s|0,n+=(o&i|s&~i)+l[12]-1926607734|0,n=(n<<20|n>>>12)+o|0,i+=(n^o^s)+l[5]-378558|0,i=(i<<4|i>>>28)+n|0,s+=(i^n^o)+l[8]-2022574463|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^n)+l[11]+1839030562|0,o=(o<<16|o>>>16)+s|0,n+=(o^s^i)+l[14]-35309556|0,n=(n<<23|n>>>9)+o|0,i+=(n^o^s)+l[1]-1530992060|0,i=(i<<4|i>>>28)+n|0,s+=(i^n^o)+l[4]+1272893353|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^n)+l[7]-155497632|0,o=(o<<16|o>>>16)+s|0,n+=(o^s^i)+l[10]-1094730640|0,n=(n<<23|n>>>9)+o|0,i+=(n^o^s)+l[13]+681279174|0,i=(i<<4|i>>>28)+n|0,s+=(i^n^o)+l[0]-358537222|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^n)+l[3]-722521979|0,o=(o<<16|o>>>16)+s|0,n+=(o^s^i)+l[6]+76029189|0,n=(n<<23|n>>>9)+o|0,i+=(n^o^s)+l[9]-640364487|0,i=(i<<4|i>>>28)+n|0,s+=(i^n^o)+l[12]-421815835|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^n)+l[15]+530742520|0,o=(o<<16|o>>>16)+s|0,n+=(o^s^i)+l[2]-995338651|0,n=(n<<23|n>>>9)+o|0,i+=(o^(n|~s))+l[0]-198630844|0,i=(i<<6|i>>>26)+n|0,s+=(n^(i|~o))+l[7]+1126891415|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~n))+l[14]-1416354905|0,o=(o<<15|o>>>17)+s|0,n+=(s^(o|~i))+l[5]-57434055|0,n=(n<<21|n>>>11)+o|0,i+=(o^(n|~s))+l[12]+1700485571|0,i=(i<<6|i>>>26)+n|0,s+=(n^(i|~o))+l[3]-1894986606|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~n))+l[10]-1051523|0,o=(o<<15|o>>>17)+s|0,n+=(s^(o|~i))+l[1]-2054922799|0,n=(n<<21|n>>>11)+o|0,i+=(o^(n|~s))+l[8]+1873313359|0,i=(i<<6|i>>>26)+n|0,s+=(n^(i|~o))+l[15]-30611744|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~n))+l[6]-1560198380|0,o=(o<<15|o>>>17)+s|0,n+=(s^(o|~i))+l[13]+1309151649|0,n=(n<<21|n>>>11)+o|0,i+=(o^(n|~s))+l[4]-145523070|0,i=(i<<6|i>>>26)+n|0,s+=(n^(i|~o))+l[11]-1120210379|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~n))+l[2]+718787259|0,o=(o<<15|o>>>17)+s|0,n+=(s^(o|~i))+l[9]-343485551|0,n=(n<<21|n>>>11)+o|0,u[0]=i+u[0]|0,u[1]=n+u[1]|0,u[2]=o+u[2]|0,u[3]=s+u[3]|0}function c(u){var l=[],i;for(i=0;i<64;i+=4)l[i>>2]=u.charCodeAt(i)+(u.charCodeAt(i+1)<<8)+(u.charCodeAt(i+2)<<16)+(u.charCodeAt(i+3)<<24);return l}function h(u){var l=[],i;for(i=0;i<64;i+=4)l[i>>2]=u[i]+(u[i+1]<<8)+(u[i+2]<<16)+(u[i+3]<<24);return l}function y(u){var l=u.length,i=[1732584193,-271733879,-1732584194,271733878],n,o,s,w,P,L;for(n=64;n<=l;n+=64)p(i,c(u.substring(n-64,n)));for(u=u.substring(n-64),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<o;n+=1)s[n>>2]|=u.charCodeAt(n)<<(n%4<<3);if(s[n>>2]|=128<<(n%4<<3),n>55)for(p(i,s),n=0;n<16;n+=1)s[n]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),P=parseInt(w[2],16),L=parseInt(w[1],16)||0,s[14]=P,s[15]=L,p(i,s),i}function d(u){var l=u.length,i=[1732584193,-271733879,-1732584194,271733878],n,o,s,w,P,L;for(n=64;n<=l;n+=64)p(i,h(u.subarray(n-64,n)));for(u=n-64<l?u.subarray(n-64):new Uint8Array(0),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<o;n+=1)s[n>>2]|=u[n]<<(n%4<<3);if(s[n>>2]|=128<<(n%4<<3),n>55)for(p(i,s),n=0;n<16;n+=1)s[n]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),P=parseInt(w[2],16),L=parseInt(w[1],16)||0,s[14]=P,s[15]=L,p(i,s),i}function g(u){var l="",i;for(i=0;i<4;i+=1)l+=e[u>>i*8+4&15]+e[u>>i*8&15];return l}function m(u){var l;for(l=0;l<u.length;l+=1)u[l]=g(u[l]);return u.join("")}m(y("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(r=function(u,l){var i=(u&65535)+(l&65535),n=(u>>16)+(l>>16)+(i>>16);return n<<16|i&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(l,i){return l=l|0||0,l<0?Math.max(l+i,0):Math.min(l,i)}ArrayBuffer.prototype.slice=function(l,i){var n=this.byteLength,o=u(l,n),s=n,w,P,L,de;return i!==t&&(s=u(i,n)),o>s?new ArrayBuffer(0):(w=s-o,P=new ArrayBuffer(w),L=new Uint8Array(P),de=new Uint8Array(this,o,w),L.set(de),P)}})();function E(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function R(u,l){var i=u.length,n=new ArrayBuffer(i),o=new Uint8Array(n),s;for(s=0;s<i;s+=1)o[s]=u.charCodeAt(s);return l?o:n}function I(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function _(u,l,i){var n=new Uint8Array(u.byteLength+l.byteLength);return n.set(new Uint8Array(u)),n.set(new Uint8Array(l),u.byteLength),i?n:n.buffer}function F(u){var l=[],i=u.length,n;for(n=0;n<i-1;n+=2)l.push(parseInt(u.substr(n,2),16));return String.fromCharCode.apply(String,l)}function D(){this.reset()}return D.prototype.append=function(u){return this.appendBinary(E(u)),this},D.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var l=this._buff.length,i;for(i=64;i<=l;i+=64)p(this._hash,c(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},D.prototype.end=function(u){var l=this._buff,i=l.length,n,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(n=0;n<i;n+=1)o[n>>2]|=l.charCodeAt(n)<<(n%4<<3);return this._finish(o,i),s=m(this._hash),u&&(s=F(s)),this.reset(),s},D.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},D.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},D.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},D.prototype._finish=function(u,l){var i=l,n,o,s;if(u[i>>2]|=128<<(i%4<<3),i>55)for(p(this._hash,u),i=0;i<16;i+=1)u[i]=0;n=this._length*8,n=n.toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(n[2],16),s=parseInt(n[1],16)||0,u[14]=o,u[15]=s,p(this._hash,u)},D.hash=function(u,l){return D.hashBinary(E(u),l)},D.hashBinary=function(u,l){var i=y(u),n=m(i);return l?F(n):n},D.ArrayBuffer=function(){this.reset()},D.ArrayBuffer.prototype.append=function(u){var l=_(this._buff.buffer,u,!0),i=l.length,n;for(this._length+=u.byteLength,n=64;n<=i;n+=64)p(this._hash,h(l.subarray(n-64,n)));return this._buff=n-64<i?new Uint8Array(l.buffer.slice(n-64)):new Uint8Array(0),this},D.ArrayBuffer.prototype.end=function(u){var l=this._buff,i=l.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,s;for(o=0;o<i;o+=1)n[o>>2]|=l[o]<<(o%4<<3);return this._finish(n,i),s=m(this._hash),u&&(s=F(s)),this.reset(),s},D.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.ArrayBuffer.prototype.getState=function(){var u=D.prototype.getState.call(this);return u.buff=I(u.buff),u},D.ArrayBuffer.prototype.setState=function(u){return u.buff=R(u.buff,!0),D.prototype.setState.call(this,u)},D.ArrayBuffer.prototype.destroy=D.prototype.destroy,D.ArrayBuffer.prototype._finish=D.prototype._finish,D.ArrayBuffer.hash=function(u,l){var i=d(new Uint8Array(u)),n=m(i);return l?F(n):n},D})});var K=fe((Wt,Fe)=>{"use strict";Fe.exports={}});async function yt(t){let r=(await Promise.resolve().then(()=>M(Ne(),1))).default,e=new r.ArrayBuffer,a=2097152;for(let p=0;p<t.size;p+=a){let c=Math.min(p+a,t.size);e.append(await t.slice(p,c).arrayBuffer())}return{md5:e.end()}}async function gt(t){let{createHash:r}=await Promise.resolve().then(()=>M(K(),1)),e=r("md5");return e.update(t),{md5:e.digest("hex")}}async function Et(t){let{createHash:r}=await Promise.resolve().then(()=>M(K(),1)),{createReadStream:e}=await Promise.resolve().then(()=>M(K(),1));return new Promise((a,p)=>{let c=r("md5"),h=e(t);h.on("error",y=>p(f.file(`Failed to read file for MD5: ${y.message}`,{filePath:t}))),h.on("data",y=>c.update(y)),h.on("end",()=>a({md5:c.digest("hex")}))})}async function $(t){if(t instanceof Blob)return yt(t);if(typeof Buffer<"u"&&Buffer.isBuffer(t))return gt(t);if(typeof t=="string")return Et(t);throw f.business("Invalid input for MD5 calculation")}var q=v(()=>{"use strict";b()});function X(t){return t.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Be=v(()=>{"use strict"});function He(t,r={}){if(r.flatten===!1)return t.map(a=>({path:X(a),name:te(a)}));let e=Dt(t);return t.map(a=>{let p=X(a);if(e){let c=e.endsWith("/")?e:`${e}/`;p.startsWith(c)&&(p=p.substring(c.length))}return p||(p=te(a)),{path:p,name:te(a)}})}function Dt(t){if(!t.length)return"";let e=t.map(c=>X(c)).map(c=>c.split("/")),a=[],p=Math.min(...e.map(c=>c.length));for(let c=0;c<p-1;c++){let h=e[0][c];if(e.every(y=>y[c]===h))a.push(h);else break}return a.join("/")}function te(t){return t.split(/[/\\]/).pop()||t}var ne=v(()=>{"use strict";Be()});function gn(t){re=t}function Tt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function Ge(){return re||Tt()}var re,ie=v(()=>{"use strict";re=null});function se(t,r=1){if(t===0)return"0 Bytes";let e=1024,a=["Bytes","KB","MB","GB"],p=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/e**p).toFixed(r))} ${a[p]}`}function oe(t){if(Ee(t))return{valid:!1,reason:"File name contains unsafe characters"};if(t.startsWith(" ")||t.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(t.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let r=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=t.split("/").pop()||t;return r.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:t.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function Dn(t,r){let e=[],a=[],p=[];if(t.length===0){let d={file:"(no files)",message:"At least one file must be provided"};return e.push(d),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let d of t)if(k(d.name))return e.push({file:d.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:t.map(g=>({...g,status:S.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(t.length>r.maxFilesCount){let d={file:`(${t.length} files)`,message:`File count (${t.length}) exceeds limit of ${r.maxFilesCount}`};return e.push(d),{files:t.map(g=>({...g,status:S.VALIDATION_FAILED,statusMessage:d.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let c=0;for(let d of t){let g=S.READY,m="Ready for upload",E=d.name?oe(d.name):{valid:!1,reason:"File name cannot be empty"};if(d.status===S.PROCESSING_ERROR)g=S.VALIDATION_FAILED,m=d.statusMessage||"File failed during processing",e.push({file:d.name,message:m});else if(d.size===0){g=S.EXCLUDED,m="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:d.name,message:m}),p.push({...d,status:g,statusMessage:m});continue}else d.size<0?(g=S.VALIDATION_FAILED,m="File size must be positive",e.push({file:d.name,message:m})):!d.name||d.name.trim().length===0?(g=S.VALIDATION_FAILED,m="File name cannot be empty",e.push({file:d.name||"(empty)",message:m})):d.name.includes("\0")?(g=S.VALIDATION_FAILED,m="File name contains invalid characters (null byte)",e.push({file:d.name,message:m})):E.valid?G(d.name)?(g=S.VALIDATION_FAILED,m=`File extension not allowed: "${d.name}"`,e.push({file:d.name,message:m})):d.size>r.maxFileSize?(g=S.VALIDATION_FAILED,m=`File size (${se(d.size)}) exceeds limit of ${se(r.maxFileSize)}`,e.push({file:d.name,message:m})):(c+=d.size,c>r.maxTotalSize&&(g=S.VALIDATION_FAILED,m=`Total size would exceed limit of ${se(r.maxTotalSize)}`,e.push({file:d.name,message:m}))):(g=S.VALIDATION_FAILED,m=E.reason||"Invalid file name",e.push({file:d.name,message:m}));p.push({...d,status:g,statusMessage:m})}e.length>0&&(p=p.map(d=>d.status===S.EXCLUDED?d:{...d,status:S.VALIDATION_FAILED,statusMessage:d.status===S.VALIDATION_FAILED?d.statusMessage:"Deployment failed due to validation errors in bundle"}));let h=e.length===0?p.filter(d=>d.status===S.READY):[],y=e.length===0;return{files:p,validFiles:h,errors:e,warnings:a,canDeploy:y}}function St(t){return t.filter(r=>r.status===S.READY)}function Tn(t){return St(t).length>0}var ae=v(()=>{"use strict";b()});function ke(t){return Rt.test(t)}var bt,Rt,ze=v(()=>{"use strict";bt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],Rt=new RegExp(bt.join("|"))});function Ve(t,r){if(!t||t.length===0)return[];if(!r?.allowUnbuilt&&t.find(a=>a&&k(a)))throw f.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return t.filter(e=>{if(!e)return!1;let a=e.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let p=a[a.length-1];if(ke(p))return!1;for(let h of a)if(h!==".well-known"&&(h.startsWith(".")||h.length>255))return!1;let c=a.slice(0,-1);for(let h of c)if(wt.some(y=>h.toLowerCase()===y.toLowerCase()))return!1;return!0})}var wt,le=v(()=>{"use strict";b();ze();wt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Ke(t,r){if(t.includes("\0")||t.includes("/../")||t.startsWith("../")||t.endsWith("/.."))throw f.business(`Security error: Unsafe file path "${t}" for file: ${r}`)}function qe(t,r){let e=oe(t);if(!e.valid)throw f.business(e.reason||"Invalid file name");if(G(t))throw f.business(`File extension not allowed: "${r}"`)}var pe=v(()=>{"use strict";b();ae()});var Xe={};tt(Xe,{processFilesForBrowser:()=>je});async function je(t,r={},e){if(Ge()!=="browser")throw f.business("processFilesForBrowser can only be called in a browser environment.");let a=t.map(E=>E.webkitRelativePath||E.name),p=r.build||r.prerender,c=He(a,{flatten:r.pathDetect!==!1}),h=c.map(E=>E.path),y=new Set(Ve(h,{allowUnbuilt:p})),d=[];for(let E=0;E<t.length;E++)y.has(h[E])&&d.push({file:t[E],deployPath:c[E].path});if(d.length===0)return[];if(p){let E=[];for(let R=0;R<d.length;R++){let{file:I,deployPath:_}=d[R];if(I.size===0)continue;let{md5:F}=await $(I);E.push({path:_,content:I,size:I.size,md5:F})}return E}if(!e)throw f.config("Platform limits not provided. processFilesForBrowser requires the limits argument for deploy-mode validation \u2014 pass `ship.getLimits()` result.");let g=[],m=0;for(let E=0;E<d.length;E++){let{file:R,deployPath:I}=d[E];if(Ke(I,R.name),R.size===0)continue;if(qe(I,R.name),R.size>e.maxFileSize)throw f.business(`File ${R.name} is too large. Maximum allowed size is ${e.maxFileSize/(1024*1024)}MB.`);if(m+=R.size,m>e.maxTotalSize)throw f.business(`Total deploy size is too large. Maximum allowed is ${e.maxTotalSize/(1024*1024)}MB.`);let{md5:_}=await $(R);g.push({path:I,content:R,size:R.size,md5:_})}if(g.length>e.maxFilesCount)throw f.business(`Too many files to deploy. Maximum allowed is ${e.maxFilesCount} files.`);return g}var ue=v(()=>{"use strict";b();ne();ie();le();q();pe()});b();b();b();var z=class{constructor(){this.handlers=new Map}on(r,e){this.handlers.has(r)||this.handlers.set(r,new Set),this.handlers.get(r)?.add(e)}off(r,e){let a=this.handlers.get(r);a&&(a.delete(e),a.size===0&&this.handlers.delete(r))}emit(r,...e){let a=this.handlers.get(r);if(!a)return;let p=Array.from(a);for(let c of p)try{c(...e)}catch(h){a.delete(c),r!=="error"&&setTimeout(()=>{let y=h instanceof Error?h:new Error(String(h));this.emit("error",y,String(r))},0)}}};b();b();function C(t){if(t==null)return;if(t.length===0)return t;if(t.length>N.MAX_COUNT)throw f.validation(`Maximum ${N.MAX_COUNT} labels allowed`);let r=t.map((a,p)=>{if(typeof a!="string")throw f.validation(`Label at index ${p} must be a string`);let c=a.trim().toLowerCase();if(c.length<N.MIN_LENGTH)throw f.validation(`Labels must be at least ${N.MIN_LENGTH} characters long`);if(c.length>N.MAX_LENGTH)throw f.validation(`Labels must be no more than ${N.MAX_LENGTH} characters long`);if(!Ie.test(c))throw f.validation(`Labels must start and end with alphanumeric characters, with optional separators (${N.SEPARATORS}) between segments`);return c}),e=[...new Set(r)];if(e.length!==r.length)throw f.validation("Duplicate labels are not allowed");return e}async function ve(t){let r=t.find(p=>p.path===x||p.path===`/${x}`);if(!r)return;let e=r.content,a=typeof e.text=="function"?await e.text():r.content.toString("utf8");Se(a)}var dt=3e4,Pe=3e5,ft=3e5,mt=Pe+ft,ht="sdk";function ee(t){let r=new URLSearchParams;t?.limit!==void 0&&r.set("limit",String(t.limit)),t?.cursor!==void 0&&r.set("cursor",t.cursor);let e=r.toString();return e?`?${e}`:""}var V=class extends z{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||Q,this.getAuthHeadersCallback=e.getAuthHeaders,this.session=e.session??!1,this.caller=e.caller,this.timeout=e.timeout??dt,this.deployTimeout=e.timeout??Pe,this.deployBuildTimeout=e.timeout??mt,this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||T.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}async executeRequest(e,a,p,c=this.timeout){let h=()=>{};try{let y=await this.mergeHeaders(a.headers),d=this.createTimeoutSignal(a.signal,c);h=d.cleanup;let g={...a,headers:y,credentials:this.session&&!y.Authorization?"include":void 0,signal:d.signal};this.emit("request",e,g);let m=await this.fetch(e,g);if(h(),!m.ok)throw await f.fromHttpResponse(m,p);return this.emit("response",this.safeClone(m),e),{data:await this.parseResponse(this.safeClone(m)),status:m.status}}catch(y){h();let d=f.fromFetchError(y,p);throw this.emit("error",d,e),d}}async request(e,a,p,c){let{data:h}=await this.executeRequest(e,a,p,c);return h}async requestWithStatus(e,a,p){return this.executeRequest(e,a,p)}async mergeHeaders(e={}){return{...this.globalHeaders,...this.caller?{"X-Caller":this.caller}:{},...await this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e,a=this.timeout){let p=new AbortController,c=setTimeout(()=>p.abort(),a);if(e){let h=()=>p.abort();e.addEventListener("abort",h),e.aborted&&p.abort()}return{signal:p.signal,cleanup:()=>clearTimeout(c)}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async deploy(e,a={}){if(!e.length)throw f.business("No files to deploy");for(let g of e)if(!g.md5)throw f.file(`MD5 checksum missing for file: ${g.path}`,{filePath:g.path});Z(a.password);let p=ye(a.idempotencyKey),c=C(a.labels);await ve(e);let h=a.build||a.prerender||a.spa?{build:a.build,prerender:a.prerender,spa:a.spa}:void 0,{body:y,headers:d}=await this.createDeployBody(e,{labels:c,via:a.via??ht,password:a.password,flags:h,captcha:a.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:y,headers:p?{...d,"Idempotency-Key":p}:d,signal:a.signal||null},"Deploy",a.build||a.prerender?this.deployBuildTimeout:this.deployTimeout)}async listDeployments(e){return this.request(`${this.apiUrl}${T.DEPLOYMENTS}${ee(e)}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,a){let p=C(a);return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:p})},"Update deployment labels")}async removeDeployment(e){return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"DELETE"},"Remove deployment")}async setDomain(e,a,p){let c=C(p),h={};a&&(h.deployment=a),c!==void 0&&(h.labels=c);let{data:y,status:d}=await this.requestWithStatus(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)},"Set domain");return{...y,isCreate:d===201}}async listDomains(e){return this.request(`${this.apiUrl}${T.DOMAINS}${ee(e)}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"GET"},"Get domain")}async removeDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"DELETE"},"Remove domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN_VERIFY(encodeURIComponent(e))}`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${T.DOMAIN_DNS(encodeURIComponent(e))}`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${T.DOMAIN_RECORDS(encodeURIComponent(e))}`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${T.DOMAIN_SHARE(encodeURIComponent(e))}`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${T.DOMAINS_VALIDATE}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,a){let p=C(a),c={};return e!==void 0&&(c.ttl=e),p!==void 0&&(c.labels=p),this.request(`${this.apiUrl}${T.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"Create token")}async listTokens(e){return this.request(`${this.apiUrl}${T.TOKENS}${ee(e)}`,{method:"GET"},"List tokens")}async removeToken(e){return this.request(`${this.apiUrl}${T.TOKEN(encodeURIComponent(e))}`,{method:"DELETE"},"Remove token")}async getToken(e){return this.request(`${this.apiUrl}${T.TOKEN(encodeURIComponent(e))}`,{method:"GET"},"Get token")}async getAccount(){return this.request(`${this.apiUrl}${T.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${T.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return(await this.request(`${this.apiUrl}${T.PING}`,{method:"GET"},"Ping"))?.success||!1}async checkSPA(e,a={}){let p=e.find(d=>d.path==="index.html"||d.path==="/index.html");if(!p||p.size>100*1024)return!1;let c;if(typeof Buffer<"u"&&Buffer.isBuffer(p.content))c=p.content.toString("utf-8");else if(typeof Blob<"u"&&p.content instanceof Blob)c=await p.content.text();else if(typeof File<"u"&&p.content instanceof File)c=await p.content.text();else return!1;let h={files:e.map(d=>d.path),index:c};return(await this.request(`${this.apiUrl}${T.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)},"SPA check")).isSPA}};b();b();q();async function At(){let t=JSON.stringify(Te,null,2),r;typeof Buffer<"u"?r=Buffer.from(t,"utf-8"):r=new Blob([t],{type:"application/json"});let{md5:e}=await $(r);return{path:x,content:r,size:t.length,md5:e}}async function Oe(t,r,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||t.some(a=>a.path===x))return t;try{if(await r.checkSPA(t,e)){let p=await At();return[...t,p]}}catch{}return t}function _e(t){let{getApi:r,ensureInit:e,processInput:a}=t;return{upload:async(p,c={})=>{if(await e(),!a)throw f.config("processInput function is not provided.");let h=r(),y=await a(p,c);return y=await Oe(y,h,c),h.deploy(y,c)},list:async p=>(await e(),r().listDeployments(p)),get:async p=>(await e(),r().getDeployment(p)),set:async(p,c)=>(await e(),r().updateDeploymentLabels(p,c.labels)),remove:async p=>(await e(),r().removeDeployment(p))}}function Ce(t){let{getApi:r,ensureInit:e}=t;return{set:async(a,p={})=>(await e(),r().setDomain(a,p.deployment,p.labels)),list:async a=>(await e(),r().listDomains(a)),get:async a=>(await e(),r().getDomain(a)),remove:async a=>(await e(),r().removeDomain(a)),verify:async a=>(await e(),r().verifyDomain(a)),validate:async a=>(await e(),r().validateDomain(a)),dns:async a=>(await e(),r().getDomainDns(a)),records:async a=>(await e(),r().getDomainRecords(a)),share:async a=>(await e(),r().getDomainShare(a))}}function $e(t){let{getApi:r,ensureInit:e}=t;return{get:async()=>(await e(),r().getAccount())}}function Ue(t){let{getApi:r,ensureInit:e}=t;return{create:async(a={})=>(await e(),r().createToken(a.ttl,a.labels)),list:async a=>(await e(),r().listTokens(a)),get:async a=>(await e(),r().getToken(a)),remove:async a=>(await e(),r().removeToken(a))}}var j=class{constructor(r={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(r={...r,apiUrl:r.apiUrl||void 0,token:r.token||void 0,caller:r.caller||void 0},this.clientOptions=r,r.caller!==void 0&&Re(r.caller),r.token&&r.session)throw f.config("Provide either `token` or `session`, not both.");typeof r.token=="string"?(J(r.token),this.credential=r.token):r.token&&(this.credential=r.token),this.http=new V({...r,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let e={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=_e({...e,processInput:(a,p)=>this.processInput(a,p)}),this.domains=Ce(e),this.account=$e(e),this.tokens=Ue(e)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(r){throw this.initPromise=null,r}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(r,e){return this.deployments.upload(r,e)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(r,e){this.http.on(r,e)}off(r,e){this.http.off(r,e)}setHeaders(r){this.http.setGlobalHeaders(r)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(r){if(this.clientOptions.session)throw f.config("Provide either `token` or `session`, not both.");if(typeof r=="string"){if(!r)throw f.business("Invalid token provided. Token must be a non-empty string.");J(r),this.credential=r;return}if(typeof r!="function")throw f.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=r}async getAuthHeaders(){if(this.credential===null)return{};let r=typeof this.credential=="function"?await this.credential():this.credential;if(!r)throw f.authentication("Token provider returned no token.");if(typeof r!="string")throw f.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${r}`}}};b();async function Me(t,r={}){let{labels:e,via:a,password:p,flags:c,captcha:h}=r,y=new FormData,d=[];for(let g of t){if(!(g.content instanceof File||g.content instanceof Blob))throw f.file(`Unsupported file.content type for browser: ${g.path}`,{filePath:g.path});if(!g.md5)throw f.file(`File missing md5 checksum: ${g.path}`,{filePath:g.path});let m=new File([g.content],g.path,{type:"application/octet-stream"});y.append("files[]",m),d.push(g.md5)}return y.append("checksums",JSON.stringify(d)),e&&e.length>0&&y.append("labels",JSON.stringify(e)),a&&y.append("via",a),p&&y.append("password",p),c?.build&&y.append("build","true"),c?.prerender&&y.append("prerender","true"),c?.spa&&y.append("spa","true"),h&&y.append("captcha",h),{body:y,headers:{}}}b();b();ne();ie();ae();le();q();pe();function Ln(t,r,e,a=!0){let p=t===1?r:e;return a?`${t} ${p}`:p}ue();var ce=class extends j{async deploy(r,e){return super.deploy(r,e)}async processInput(r,e){if(!Array.isArray(r)||!r.every(p=>p instanceof File))throw f.business("Invalid input type for browser environment. Expected File[].");if(r.length===0)throw f.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(ue(),Xe));return a(r,e,this.platformLimits??void 0)}getDeployBodyCreator(){return Me}},er=ce;export{Ae as API_KEY,T as API_PATHS,Lt as AUTH_BASE_PATH,xt as AccountPlan,V as ApiHttp,he as AuthMethod,ot as BLOCKED_EXTENSIONS,W as CALLER,Q as DEFAULT_API,x as DEPLOYMENT_CONFIG_FILENAME,De as DEPLOY_TOKEN,vt as DeploymentStatus,Pt as DomainStatus,A as ErrorType,S as FILE_VALIDATION_STATUS,S as FileValidationStatus,me as IDEMPOTENCY_KEY_CONSTRAINTS,wt as JUNK_DIRECTORIES,N as LABEL_CONSTRAINTS,Ie as LABEL_PATTERN,Nt as OAuthScope,H as PASSWORD_CONSTRAINTS,Te as SPA_DEFAULT_CONFIG,ce as Ship,f as ShipError,O as TokenKind,lt as UNBUILT_PROJECT_MARKERS,at as UNSAFE_FILENAME_CHARS,gn as __setTestEnvironment,Tn as allValidFilesReady,Se as assertShipJsonSyntax,$ as calculateMD5,pt as classifyToken,$e as createAccountResource,_e as createDeploymentResource,Ce as createDomainResource,Ue as createTokenResource,er as default,Bt as deserializeLabels,Ct as extractSubdomain,Ve as filterJunk,se as formatFileSize,$t as generateDeploymentUrl,Ut as generateDomainUrl,Ge as getENV,St as getValidFiles,k as hasUnbuiltMarker,Ee as hasUnsafeChars,G as isBlockedExtension,_t as isCustomDomain,Ot as isDeployment,we as isPlatformDomain,ge as isShipError,He as optimizeDeployPaths,Ln as pluralize,je as processFilesForBrowser,Mt as serializeLabels,ut as validateApiKey,Ft as validateApiUrl,Re as validateCaller,qe as validateDeployFile,Ke as validateDeployPath,ct as validateDeployToken,oe as validateFileName,Dn as validateFiles,ye as validateIdempotencyKey,Z as validatePassword,J as validateToken};
1
+ var Ye=Object.create;var U=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var Qe=Object.getPrototypeOf,Ze=Object.prototype.hasOwnProperty;var et=(t,r,e)=>r in t?U(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;var P=(t,r)=>()=>(t&&(r=t(t=0)),r);var fe=(t,r)=>()=>(r||t((r={exports:{}}).exports,r),r.exports),tt=(t,r)=>{for(var e in r)U(t,e,{get:r[e],enumerable:!0})},nt=(t,r,e,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let p of Je(r))!Ze.call(t,p)&&p!==e&&U(t,p,{get:()=>r[p],enumerable:!(a=We(r,p))||a.enumerable});return t};var M=(t,r,e)=>(e=t!=null?Ye(Qe(t)):{},nt(r||!t||!t.__esModule?U(e,"default",{value:t,enumerable:!0}):e,t));var B=(t,r,e)=>et(t,typeof r!="symbol"?r+"":r,e);function ye(t){if(t==null)return;if(typeof t!="string")throw f.validation("Idempotency key must be a string.");let r=t.trim();if(!r)throw f.validation("Idempotency key must not be empty.");if(r.length>he.MAX_LENGTH)throw f.validation(`Idempotency key must be at most ${he.MAX_LENGTH} characters.`);return r}function ge(t){return t!==null&&typeof t=="object"&&"name"in t&&t.name==="ShipError"&&"status"in t}function G(t){let r=t.lastIndexOf(".");if(r===-1||r===t.length-1)return!1;let e=t.slice(r+1).toLowerCase();return ot.has(e)}function Ee(t){return at.test(t)}function k(t){return t.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>lt.has(e))}function pt(t){return t.startsWith(De.PREFIX)?O.API_KEY:t.startsWith(Ae.PREFIX)?O.DEPLOY_TOKEN:O.OPAQUE}function Se(t){let r=t.charCodeAt(0)===65279?t.slice(1):t,e;try{e=JSON.parse(r)}catch(a){throw f.config(`invalid JSON format in config: ${a.message}`,{filePath:v})}if(e===null||typeof e!="object"||Array.isArray(e))throw f.config(`${v} must contain a JSON object`,{filePath:v})}function be(t,r,e){if(!t.startsWith(r.PREFIX))throw f.validation(`${e} must start with "${r.PREFIX}"`);if(t.length!==r.TOTAL_LENGTH)throw f.validation(`${e} must be ${r.TOTAL_LENGTH} characters total (${r.PREFIX} + ${r.HEX_LENGTH} hex chars)`);let a=t.slice(r.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${r.HEX_LENGTH}}$`,"i").test(a))throw f.validation(`${e} must contain ${r.HEX_LENGTH} hexadecimal characters after "${r.PREFIX}" prefix`)}function ut(t){be(t,De,"API key")}function ct(t){be(t,Ae,"Deploy token")}function J(t){switch(pt(t)){case O.API_KEY:ut(t);return;case O.DEPLOY_TOKEN:ct(t);return;case O.OPAQUE:if(!t)throw f.validation("Token must be a non-empty string")}}function Re(t){if(!t||t.length>W.MAX_LENGTH||!W.PATTERN.test(t))throw f.validation(`Caller must be 1-${W.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function Ft(t){try{let r=new URL(t);if(!["http:","https:"].includes(r.protocol))throw f.validation("API URL must use http:// or https:// protocol");if(r.pathname!=="/"&&r.pathname!=="")throw f.validation("API URL must not contain a path");if(r.search||r.hash)throw f.validation("API URL must not contain query parameters or fragments")}catch(r){throw ge(r)?r:f.validation("API URL must be a valid URL")}}function Ot(t){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(t)}function we(t,r){return t.endsWith(`.${r}`)}function _t(t,r){return!we(t,r)}function Ct(t,r){return we(t,r)?t.slice(0,-(r.length+1)):null}function $t(t){return`https://${t}`}function Ut(t){return`https://${t}`}function Mt(t){return!t||t.length===0?null:JSON.stringify(t)}function Bt(t){if(!t)return[];try{let r=JSON.parse(t);return Array.isArray(r)?r:[]}catch{return[]}}function Z(t){if(t==null)return;if(typeof t!="string")throw f.validation("Password must be a string");let r=t.trim();if(r.length<H.MIN_LENGTH||r.length>H.MAX_LENGTH)throw f.validation(`Password must be between ${H.MIN_LENGTH} and ${H.MAX_LENGTH} characters`);return r}var Pt,T,xt,he,vt,D,rt,Y,it,st,f,ot,at,lt,Lt,me,De,Ae,W,O,Nt,v,Te,Q,S,N,Ie,H,b=P(()=>{"use strict";Pt={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},T={DEPLOYMENTS:"/deployments",DEPLOYMENT:t=>`/deployments/${t}`,DEPLOYMENT_CONFIG:t=>`/deployments/${t}/config`,DOMAINS:"/domains",DOMAIN:t=>`/domains/${t}`,DOMAIN_VERIFY:t=>`/domains/${t}/verify`,DOMAIN_DNS:t=>`/domains/${t}/dns`,DOMAIN_RECORDS:t=>`/domains/${t}/records`,DOMAIN_SHARE:t=>`/domains/${t}/share`,DOMAIN_PROPAGATION:t=>`/domains/${t}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:t=>`/tokens/${t}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},xt={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},he={MAX_LENGTH:256,WINDOW_SECONDS:1440*60};vt={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},D={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},rt=new Set([D.Network,D.Cancelled,D.File,D.Config]),Y={client:new Set([D.Business,D.Cancelled,D.Config,D.File,D.Forbidden,D.NotFound,D.RateLimit,D.Validation]),network:new Set([D.Network]),auth:new Set([D.Authentication])},it=new Set(Object.values(D).filter(t=>!rt.has(t))),st=200,f=class t extends Error{constructor(e,a,p,c){super(a);B(this,"type");B(this,"status");B(this,"details");this.type=e,this.status=p,this.details=c,this.name="ShipError"}toResponse(){let e=this.details,a=this.type===D.Authentication&&e?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:a}}static async fromHttpResponse(e,a){let p,c,m;try{if(e.headers.get("content-type")?.includes("application/json")){let h=await e.json();if(h&&typeof h=="object"){let E=h;typeof E.message=="string"?p=E.message:typeof E.error=="string"&&(p=E.error),c=E.details,typeof E.error=="string"&&it.has(E.error)&&(m=E.error)}}else{let h=(await e.text()).trim();h&&!h.startsWith("<")&&h.length<=st&&(p=h)}}catch{}let y=e.headers.get("retry-after");if(y!==null){let g=y.trim(),h=/^\d+$/.test(g)?Number(g):Math.ceil((Date.parse(g)-Date.now())/1e3);if(Number.isFinite(h)&&h>=0){let E=c&&typeof c=="object"?c:{};E.retryAfter===void 0&&(c={...E,retryAfter:h})}}p=p||`${a||"Request"} failed with status ${e.status}`;let d=m??(e.status===401?D.Authentication:e.status===403?D.Forbidden:e.status===429?D.RateLimit:D.Api);return new t(d,p,e.status,c)}static fromFetchError(e,a){if(ge(e))return e;let p=a||"Request";return e instanceof Error?e.name==="AbortError"?t.cancelled(`${p} was cancelled`):e instanceof TypeError&&e.message.includes("fetch")?t.network(`${p} failed: ${e.message}`,{cause:e}):new t(D.Api,`${p} failed: ${e.message}`):new t(D.Api,`${p} failed: Unknown error`)}static validation(e,a){return new t(D.Validation,e,400,a)}static notFound(e,a){let p=a?`${e} ${a} not found`:`${e} not found`;return new t(D.NotFound,p,404)}static forbidden(e,a){return new t(D.Forbidden,e,403,a)}static rateLimit(e="Too many requests",a){return new t(D.RateLimit,e,429,a)}static authentication(e="Authentication required",a){return new t(D.Authentication,e,401,a)}static business(e,a=400,p){return new t(D.Business,e,a,p)}static network(e,a){return new t(D.Network,e,void 0,a)}static cancelled(e,a){return new t(D.Cancelled,e,void 0,a)}static file(e,a){return new t(D.File,e,void 0,a)}static config(e,a){return new t(D.Config,e,void 0,a)}static api(e,a=500,p){return new t(D.Api,e,a,p)}isClientError(){return Y.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return Y.network.has(this.type)}isAuthError(){return Y.auth.has(this.type)}isType(e){return this.type===e}};ot=new Set(["exe","msi","dll","scr","bat","cmd","com","pif","app","deb","rpm","pkg","mpkg","dmg","iso","img","cab","cpl","chm","ps1","vbs","vbe","ws","wsf","wsc","wsh","reg","jar","jnlp","apk","crx","lnk","inf","hta"]);at=/[\x00-\x1f\x7f#?%\\<>"]/;lt=new Set(["node_modules","package.json"]);Lt="/auth",me={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},De={PREFIX:"ship-",HEX_LENGTH:64,TOTAL_LENGTH:69,HINT_LENGTH:4},Ae={PREFIX:"deploy-",HEX_LENGTH:64,TOTAL_LENGTH:71},W={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},O={API_KEY:me.API_KEY,DEPLOY_TOKEN:me.TOKEN,OPAQUE:"opaque"};Nt={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},v="ship.json",Te={rewrites:[{source:"/(.*)",destination:"/index.html"}]};Q="https://api.shipstatic.com",S={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};N={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Ie=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;H={MIN_LENGTH:6,MAX_LENGTH:128}});var Ne=fe((ve,Le)=>{"use strict";(function(t){if(typeof ve=="object")Le.exports=t();else if(typeof define=="function"&&define.amd)define(t);else{var r;try{r=window}catch{r=self}r.SparkMD5=t()}})(function(t){"use strict";var r=function(u,l){return u+l&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(u,l,i,n,o,s){return l=r(r(l,u),r(n,s)),r(l<<o|l>>>32-o,i)}function p(u,l){var i=u[0],n=u[1],o=u[2],s=u[3];i+=(n&o|~n&s)+l[0]-680876936|0,i=(i<<7|i>>>25)+n|0,s+=(i&n|~i&o)+l[1]-389564586|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&n)+l[2]+606105819|0,o=(o<<17|o>>>15)+s|0,n+=(o&s|~o&i)+l[3]-1044525330|0,n=(n<<22|n>>>10)+o|0,i+=(n&o|~n&s)+l[4]-176418897|0,i=(i<<7|i>>>25)+n|0,s+=(i&n|~i&o)+l[5]+1200080426|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&n)+l[6]-1473231341|0,o=(o<<17|o>>>15)+s|0,n+=(o&s|~o&i)+l[7]-45705983|0,n=(n<<22|n>>>10)+o|0,i+=(n&o|~n&s)+l[8]+1770035416|0,i=(i<<7|i>>>25)+n|0,s+=(i&n|~i&o)+l[9]-1958414417|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&n)+l[10]-42063|0,o=(o<<17|o>>>15)+s|0,n+=(o&s|~o&i)+l[11]-1990404162|0,n=(n<<22|n>>>10)+o|0,i+=(n&o|~n&s)+l[12]+1804603682|0,i=(i<<7|i>>>25)+n|0,s+=(i&n|~i&o)+l[13]-40341101|0,s=(s<<12|s>>>20)+i|0,o+=(s&i|~s&n)+l[14]-1502002290|0,o=(o<<17|o>>>15)+s|0,n+=(o&s|~o&i)+l[15]+1236535329|0,n=(n<<22|n>>>10)+o|0,i+=(n&s|o&~s)+l[1]-165796510|0,i=(i<<5|i>>>27)+n|0,s+=(i&o|n&~o)+l[6]-1069501632|0,s=(s<<9|s>>>23)+i|0,o+=(s&n|i&~n)+l[11]+643717713|0,o=(o<<14|o>>>18)+s|0,n+=(o&i|s&~i)+l[0]-373897302|0,n=(n<<20|n>>>12)+o|0,i+=(n&s|o&~s)+l[5]-701558691|0,i=(i<<5|i>>>27)+n|0,s+=(i&o|n&~o)+l[10]+38016083|0,s=(s<<9|s>>>23)+i|0,o+=(s&n|i&~n)+l[15]-660478335|0,o=(o<<14|o>>>18)+s|0,n+=(o&i|s&~i)+l[4]-405537848|0,n=(n<<20|n>>>12)+o|0,i+=(n&s|o&~s)+l[9]+568446438|0,i=(i<<5|i>>>27)+n|0,s+=(i&o|n&~o)+l[14]-1019803690|0,s=(s<<9|s>>>23)+i|0,o+=(s&n|i&~n)+l[3]-187363961|0,o=(o<<14|o>>>18)+s|0,n+=(o&i|s&~i)+l[8]+1163531501|0,n=(n<<20|n>>>12)+o|0,i+=(n&s|o&~s)+l[13]-1444681467|0,i=(i<<5|i>>>27)+n|0,s+=(i&o|n&~o)+l[2]-51403784|0,s=(s<<9|s>>>23)+i|0,o+=(s&n|i&~n)+l[7]+1735328473|0,o=(o<<14|o>>>18)+s|0,n+=(o&i|s&~i)+l[12]-1926607734|0,n=(n<<20|n>>>12)+o|0,i+=(n^o^s)+l[5]-378558|0,i=(i<<4|i>>>28)+n|0,s+=(i^n^o)+l[8]-2022574463|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^n)+l[11]+1839030562|0,o=(o<<16|o>>>16)+s|0,n+=(o^s^i)+l[14]-35309556|0,n=(n<<23|n>>>9)+o|0,i+=(n^o^s)+l[1]-1530992060|0,i=(i<<4|i>>>28)+n|0,s+=(i^n^o)+l[4]+1272893353|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^n)+l[7]-155497632|0,o=(o<<16|o>>>16)+s|0,n+=(o^s^i)+l[10]-1094730640|0,n=(n<<23|n>>>9)+o|0,i+=(n^o^s)+l[13]+681279174|0,i=(i<<4|i>>>28)+n|0,s+=(i^n^o)+l[0]-358537222|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^n)+l[3]-722521979|0,o=(o<<16|o>>>16)+s|0,n+=(o^s^i)+l[6]+76029189|0,n=(n<<23|n>>>9)+o|0,i+=(n^o^s)+l[9]-640364487|0,i=(i<<4|i>>>28)+n|0,s+=(i^n^o)+l[12]-421815835|0,s=(s<<11|s>>>21)+i|0,o+=(s^i^n)+l[15]+530742520|0,o=(o<<16|o>>>16)+s|0,n+=(o^s^i)+l[2]-995338651|0,n=(n<<23|n>>>9)+o|0,i+=(o^(n|~s))+l[0]-198630844|0,i=(i<<6|i>>>26)+n|0,s+=(n^(i|~o))+l[7]+1126891415|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~n))+l[14]-1416354905|0,o=(o<<15|o>>>17)+s|0,n+=(s^(o|~i))+l[5]-57434055|0,n=(n<<21|n>>>11)+o|0,i+=(o^(n|~s))+l[12]+1700485571|0,i=(i<<6|i>>>26)+n|0,s+=(n^(i|~o))+l[3]-1894986606|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~n))+l[10]-1051523|0,o=(o<<15|o>>>17)+s|0,n+=(s^(o|~i))+l[1]-2054922799|0,n=(n<<21|n>>>11)+o|0,i+=(o^(n|~s))+l[8]+1873313359|0,i=(i<<6|i>>>26)+n|0,s+=(n^(i|~o))+l[15]-30611744|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~n))+l[6]-1560198380|0,o=(o<<15|o>>>17)+s|0,n+=(s^(o|~i))+l[13]+1309151649|0,n=(n<<21|n>>>11)+o|0,i+=(o^(n|~s))+l[4]-145523070|0,i=(i<<6|i>>>26)+n|0,s+=(n^(i|~o))+l[11]-1120210379|0,s=(s<<10|s>>>22)+i|0,o+=(i^(s|~n))+l[2]+718787259|0,o=(o<<15|o>>>17)+s|0,n+=(s^(o|~i))+l[9]-343485551|0,n=(n<<21|n>>>11)+o|0,u[0]=i+u[0]|0,u[1]=n+u[1]|0,u[2]=o+u[2]|0,u[3]=s+u[3]|0}function c(u){var l=[],i;for(i=0;i<64;i+=4)l[i>>2]=u.charCodeAt(i)+(u.charCodeAt(i+1)<<8)+(u.charCodeAt(i+2)<<16)+(u.charCodeAt(i+3)<<24);return l}function m(u){var l=[],i;for(i=0;i<64;i+=4)l[i>>2]=u[i]+(u[i+1]<<8)+(u[i+2]<<16)+(u[i+3]<<24);return l}function y(u){var l=u.length,i=[1732584193,-271733879,-1732584194,271733878],n,o,s,w,x,L;for(n=64;n<=l;n+=64)p(i,c(u.substring(n-64,n)));for(u=u.substring(n-64),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<o;n+=1)s[n>>2]|=u.charCodeAt(n)<<(n%4<<3);if(s[n>>2]|=128<<(n%4<<3),n>55)for(p(i,s),n=0;n<16;n+=1)s[n]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(w[2],16),L=parseInt(w[1],16)||0,s[14]=x,s[15]=L,p(i,s),i}function d(u){var l=u.length,i=[1732584193,-271733879,-1732584194,271733878],n,o,s,w,x,L;for(n=64;n<=l;n+=64)p(i,m(u.subarray(n-64,n)));for(u=n-64<l?u.subarray(n-64):new Uint8Array(0),o=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<o;n+=1)s[n>>2]|=u[n]<<(n%4<<3);if(s[n>>2]|=128<<(n%4<<3),n>55)for(p(i,s),n=0;n<16;n+=1)s[n]=0;return w=l*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),x=parseInt(w[2],16),L=parseInt(w[1],16)||0,s[14]=x,s[15]=L,p(i,s),i}function g(u){var l="",i;for(i=0;i<4;i+=1)l+=e[u>>i*8+4&15]+e[u>>i*8&15];return l}function h(u){var l;for(l=0;l<u.length;l+=1)u[l]=g(u[l]);return u.join("")}h(y("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(r=function(u,l){var i=(u&65535)+(l&65535),n=(u>>16)+(l>>16)+(i>>16);return n<<16|i&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(l,i){return l=l|0||0,l<0?Math.max(l+i,0):Math.min(l,i)}ArrayBuffer.prototype.slice=function(l,i){var n=this.byteLength,o=u(l,n),s=n,w,x,L,de;return i!==t&&(s=u(i,n)),o>s?new ArrayBuffer(0):(w=s-o,x=new ArrayBuffer(w),L=new Uint8Array(x),de=new Uint8Array(this,o,w),L.set(de),x)}})();function E(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function R(u,l){var i=u.length,n=new ArrayBuffer(i),o=new Uint8Array(n),s;for(s=0;s<i;s+=1)o[s]=u.charCodeAt(s);return l?o:n}function I(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function _(u,l,i){var n=new Uint8Array(u.byteLength+l.byteLength);return n.set(new Uint8Array(u)),n.set(new Uint8Array(l),u.byteLength),i?n:n.buffer}function F(u){var l=[],i=u.length,n;for(n=0;n<i-1;n+=2)l.push(parseInt(u.substr(n,2),16));return String.fromCharCode.apply(String,l)}function A(){this.reset()}return A.prototype.append=function(u){return this.appendBinary(E(u)),this},A.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var l=this._buff.length,i;for(i=64;i<=l;i+=64)p(this._hash,c(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},A.prototype.end=function(u){var l=this._buff,i=l.length,n,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(n=0;n<i;n+=1)o[n>>2]|=l.charCodeAt(n)<<(n%4<<3);return this._finish(o,i),s=h(this._hash),u&&(s=F(s)),this.reset(),s},A.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},A.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},A.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},A.prototype._finish=function(u,l){var i=l,n,o,s;if(u[i>>2]|=128<<(i%4<<3),i>55)for(p(this._hash,u),i=0;i<16;i+=1)u[i]=0;n=this._length*8,n=n.toString(16).match(/(.*?)(.{0,8})$/),o=parseInt(n[2],16),s=parseInt(n[1],16)||0,u[14]=o,u[15]=s,p(this._hash,u)},A.hash=function(u,l){return A.hashBinary(E(u),l)},A.hashBinary=function(u,l){var i=y(u),n=h(i);return l?F(n):n},A.ArrayBuffer=function(){this.reset()},A.ArrayBuffer.prototype.append=function(u){var l=_(this._buff.buffer,u,!0),i=l.length,n;for(this._length+=u.byteLength,n=64;n<=i;n+=64)p(this._hash,m(l.subarray(n-64,n)));return this._buff=n-64<i?new Uint8Array(l.buffer.slice(n-64)):new Uint8Array(0),this},A.ArrayBuffer.prototype.end=function(u){var l=this._buff,i=l.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,s;for(o=0;o<i;o+=1)n[o>>2]|=l[o]<<(o%4<<3);return this._finish(n,i),s=h(this._hash),u&&(s=F(s)),this.reset(),s},A.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.ArrayBuffer.prototype.getState=function(){var u=A.prototype.getState.call(this);return u.buff=I(u.buff),u},A.ArrayBuffer.prototype.setState=function(u){return u.buff=R(u.buff,!0),A.prototype.setState.call(this,u)},A.ArrayBuffer.prototype.destroy=A.prototype.destroy,A.ArrayBuffer.prototype._finish=A.prototype._finish,A.ArrayBuffer.hash=function(u,l){var i=d(new Uint8Array(u)),n=h(i);return l?F(n):n},A})});var K=fe((Wt,Fe)=>{"use strict";Fe.exports={}});async function yt(t){let r=(await Promise.resolve().then(()=>M(Ne(),1))).default,e=new r.ArrayBuffer,a=2097152;for(let p=0;p<t.size;p+=a){let c=Math.min(p+a,t.size);e.append(await t.slice(p,c).arrayBuffer())}return{md5:e.end()}}async function gt(t){let{createHash:r}=await Promise.resolve().then(()=>M(K(),1)),e=r("md5");return e.update(t),{md5:e.digest("hex")}}async function Et(t){let{createHash:r}=await Promise.resolve().then(()=>M(K(),1)),{createReadStream:e}=await Promise.resolve().then(()=>M(K(),1));return new Promise((a,p)=>{let c=r("md5"),m=e(t);m.on("error",y=>p(f.file(`Failed to read file for MD5: ${y.message}`,{filePath:t}))),m.on("data",y=>c.update(y)),m.on("end",()=>a({md5:c.digest("hex")}))})}async function $(t){if(t instanceof Blob)return yt(t);if(typeof Buffer<"u"&&Buffer.isBuffer(t))return gt(t);if(typeof t=="string")return Et(t);throw f.business("Invalid input for MD5 calculation")}var q=P(()=>{"use strict";b()});function X(t){return t.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Be=P(()=>{"use strict"});function He(t,r={}){if(r.flatten===!1)return t.map(a=>({path:X(a),name:te(a)}));let e=At(t);return t.map(a=>{let p=X(a);if(e){let c=e.endsWith("/")?e:`${e}/`;p.startsWith(c)&&(p=p.substring(c.length))}return p||(p=te(a)),{path:p,name:te(a)}})}function At(t){if(!t.length)return"";let e=t.map(c=>X(c)).map(c=>c.split("/")),a=[],p=Math.min(...e.map(c=>c.length));for(let c=0;c<p-1;c++){let m=e[0][c];if(e.every(y=>y[c]===m))a.push(m);else break}return a.join("/")}function te(t){return t.split(/[/\\]/).pop()||t}var ne=P(()=>{"use strict";Be()});function gn(t){re=t}function Tt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function Ge(){return re||Tt()}var re,ie=P(()=>{"use strict";re=null});function se(t,r=1){if(t===0)return"0 Bytes";let e=1024,a=["Bytes","KB","MB","GB"],p=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/e**p).toFixed(r))} ${a[p]}`}function oe(t){if(Ee(t))return{valid:!1,reason:"File name contains unsafe characters"};if(t.startsWith(" ")||t.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(t.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let r=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=t.split("/").pop()||t;return r.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:t.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function An(t,r){let e=[],a=[],p=[];if(t.length===0){let d={file:"(no files)",message:"At least one file must be provided"};return e.push(d),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let d of t)if(k(d.name))return e.push({file:d.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:t.map(g=>({...g,status:S.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(t.length>r.maxFilesCount){let d={file:`(${t.length} files)`,message:`File count (${t.length}) exceeds limit of ${r.maxFilesCount}`};return e.push(d),{files:t.map(g=>({...g,status:S.VALIDATION_FAILED,statusMessage:d.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let c=0;for(let d of t){let g=S.READY,h="Ready for upload",E=d.name?oe(d.name):{valid:!1,reason:"File name cannot be empty"};if(d.status===S.PROCESSING_ERROR)g=S.VALIDATION_FAILED,h=d.statusMessage||"File failed during processing",e.push({file:d.name,message:h});else if(d.size===0){g=S.EXCLUDED,h="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:d.name,message:h}),p.push({...d,status:g,statusMessage:h});continue}else d.size<0?(g=S.VALIDATION_FAILED,h="File size must be positive",e.push({file:d.name,message:h})):!d.name||d.name.trim().length===0?(g=S.VALIDATION_FAILED,h="File name cannot be empty",e.push({file:d.name||"(empty)",message:h})):d.name.includes("\0")?(g=S.VALIDATION_FAILED,h="File name contains invalid characters (null byte)",e.push({file:d.name,message:h})):E.valid?G(d.name)?(g=S.VALIDATION_FAILED,h=`File extension not allowed: "${d.name}"`,e.push({file:d.name,message:h})):d.size>r.maxFileSize?(g=S.VALIDATION_FAILED,h=`File size (${se(d.size)}) exceeds limit of ${se(r.maxFileSize)}`,e.push({file:d.name,message:h})):(c+=d.size,c>r.maxTotalSize&&(g=S.VALIDATION_FAILED,h=`Total size would exceed limit of ${se(r.maxTotalSize)}`,e.push({file:d.name,message:h}))):(g=S.VALIDATION_FAILED,h=E.reason||"Invalid file name",e.push({file:d.name,message:h}));p.push({...d,status:g,statusMessage:h})}e.length>0&&(p=p.map(d=>d.status===S.EXCLUDED?d:{...d,status:S.VALIDATION_FAILED,statusMessage:d.status===S.VALIDATION_FAILED?d.statusMessage:"Deployment failed due to validation errors in bundle"}));let m=e.length===0?p.filter(d=>d.status===S.READY):[],y=e.length===0;return{files:p,validFiles:m,errors:e,warnings:a,canDeploy:y}}function St(t){return t.filter(r=>r.status===S.READY)}function Tn(t){return St(t).length>0}var ae=P(()=>{"use strict";b()});function ke(t){return Rt.test(t)}var bt,Rt,ze=P(()=>{"use strict";bt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],Rt=new RegExp(bt.join("|"))});function Ve(t,r){if(!t||t.length===0)return[];if(!r?.allowUnbuilt&&t.find(a=>a&&k(a)))throw f.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return t.filter(e=>{if(!e)return!1;let a=e.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let p=a[a.length-1];if(ke(p))return!1;for(let m of a)if(m!==".well-known"&&(m.startsWith(".")||m.length>255))return!1;let c=a.slice(0,-1);for(let m of c)if(wt.some(y=>m.toLowerCase()===y.toLowerCase()))return!1;return!0})}var wt,le=P(()=>{"use strict";b();ze();wt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Ke(t,r){if(t.includes("\0")||t.includes("/../")||t.startsWith("../")||t.endsWith("/.."))throw f.business(`Security error: Unsafe file path "${t}" for file: ${r}`)}function qe(t,r){let e=oe(t);if(!e.valid)throw f.business(e.reason||"Invalid file name");if(G(t))throw f.business(`File extension not allowed: "${r}"`)}var pe=P(()=>{"use strict";b();ae()});var Xe={};tt(Xe,{processFilesForBrowser:()=>je});async function je(t,r={},e){if(Ge()!=="browser")throw f.business("processFilesForBrowser can only be called in a browser environment.");let a=t.map(E=>E.webkitRelativePath||E.name),p=r.build||r.prerender,c=He(a,{flatten:r.pathDetect!==!1}),m=c.map(E=>E.path),y=new Set(Ve(m,{allowUnbuilt:p})),d=[];for(let E=0;E<t.length;E++)y.has(m[E])&&d.push({file:t[E],deployPath:c[E].path});if(d.length===0)return[];if(p){let E=[];for(let R=0;R<d.length;R++){let{file:I,deployPath:_}=d[R];if(I.size===0)continue;let{md5:F}=await $(I);E.push({path:_,content:I,size:I.size,md5:F})}return E}if(!e)throw f.config("Platform limits not provided. processFilesForBrowser requires the limits argument for deploy-mode validation \u2014 pass `ship.getLimits()` result.");let g=[],h=0;for(let E=0;E<d.length;E++){let{file:R,deployPath:I}=d[E];if(Ke(I,R.name),R.size===0)continue;if(qe(I,R.name),R.size>e.maxFileSize)throw f.business(`File ${R.name} is too large. Maximum allowed size is ${e.maxFileSize/(1024*1024)}MB.`);if(h+=R.size,h>e.maxTotalSize)throw f.business(`Total deploy size is too large. Maximum allowed is ${e.maxTotalSize/(1024*1024)}MB.`);let{md5:_}=await $(R);g.push({path:I,content:R,size:R.size,md5:_})}if(g.length>e.maxFilesCount)throw f.business(`Too many files to deploy. Maximum allowed is ${e.maxFilesCount} files.`);return g}var ue=P(()=>{"use strict";b();ne();ie();le();q();pe()});b();b();b();var z=class{constructor(){this.handlers=new Map}on(r,e){this.handlers.has(r)||this.handlers.set(r,new Set),this.handlers.get(r)?.add(e)}off(r,e){let a=this.handlers.get(r);a&&(a.delete(e),a.size===0&&this.handlers.delete(r))}emit(r,...e){let a=this.handlers.get(r);if(!a)return;let p=Array.from(a);for(let c of p)try{c(...e)}catch(m){a.delete(c),r!=="error"&&setTimeout(()=>{let y=m instanceof Error?m:new Error(String(m));this.emit("error",y,String(r))},0)}}};b();b();function C(t){if(t==null)return;if(t.length===0)return t;if(t.length>N.MAX_COUNT)throw f.validation(`Maximum ${N.MAX_COUNT} labels allowed`);let r=t.map((a,p)=>{if(typeof a!="string")throw f.validation(`Label at index ${p} must be a string`);let c=a.trim().toLowerCase();if(c.length<N.MIN_LENGTH)throw f.validation(`Labels must be at least ${N.MIN_LENGTH} characters long`);if(c.length>N.MAX_LENGTH)throw f.validation(`Labels must be no more than ${N.MAX_LENGTH} characters long`);if(!Ie.test(c))throw f.validation(`Labels must start and end with alphanumeric characters, with optional separators (${N.SEPARATORS}) between segments`);return c}),e=[...new Set(r)];if(e.length!==r.length)throw f.validation("Duplicate labels are not allowed");return e}async function Pe(t){let r=t.find(p=>p.path===v||p.path===`/${v}`);if(!r)return;let e=r.content,a=typeof e.text=="function"?await e.text():r.content.toString("utf8");Se(a)}var dt=3e4,xe=3e5,ft=3e5,ht=xe+ft,mt="sdk";function ee(t){let r=new URLSearchParams;t?.limit!==void 0&&r.set("limit",String(t.limit)),t?.cursor!==void 0&&r.set("cursor",t.cursor);let e=r.toString();return e?`?${e}`:""}var V=class extends z{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||Q,this.getAuthHeadersCallback=e.getAuthHeaders,this.session=e.session??!1,this.caller=e.caller,this.timeout=e.timeout??dt,this.deployTimeout=e.timeout??xe,this.deployBuildTimeout=e.timeout??ht,this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||T.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}async executeRequest(e,a,p,c=this.timeout){let m=()=>{};try{let y=await this.mergeHeaders(a.headers),d=this.createTimeoutSignal(a.signal,c);m=d.cleanup;let g={...a,headers:y,credentials:this.session&&!y.Authorization?"include":void 0,signal:d.signal};this.emit("request",e,g);let h=await this.fetch(e,g);if(m(),!h.ok)throw await f.fromHttpResponse(h,p);return this.emit("response",this.safeClone(h),e),{data:await this.parseResponse(this.safeClone(h)),status:h.status}}catch(y){m();let d=f.fromFetchError(y,p);throw this.emit("error",d,e),d}}async request(e,a,p,c){let{data:m}=await this.executeRequest(e,a,p,c);return m}async requestWithStatus(e,a,p){return this.executeRequest(e,a,p)}async mergeHeaders(e={}){return{...this.globalHeaders,...this.caller?{"X-Caller":this.caller}:{},...await this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e,a=this.timeout){let p=new AbortController,c=setTimeout(()=>p.abort(),a);if(e){let m=()=>p.abort();e.addEventListener("abort",m),e.aborted&&p.abort()}return{signal:p.signal,cleanup:()=>clearTimeout(c)}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async deploy(e,a={}){if(!e.length)throw f.business("No files to deploy");for(let g of e)if(!g.md5)throw f.file(`MD5 checksum missing for file: ${g.path}`,{filePath:g.path});Z(a.password);let p=ye(a.idempotencyKey),c=C(a.labels);await Pe(e);let m=a.build||a.prerender||a.spa?{build:a.build,prerender:a.prerender,spa:a.spa}:void 0,{body:y,headers:d}=await this.createDeployBody(e,{labels:c,via:a.via??mt,password:a.password,flags:m,captcha:a.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:y,headers:p?{...d,"Idempotency-Key":p}:d,signal:a.signal||null},"Deploy",a.build||a.prerender?this.deployBuildTimeout:this.deployTimeout)}async listDeployments(e){return this.request(`${this.apiUrl}${T.DEPLOYMENTS}${ee(e)}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,a){let p=C(a);return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:p})},"Update deployment labels")}async deleteDeployment(e){return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"DELETE"},"Delete deployment")}async setDomain(e,a,p){let c=C(p),m={};a&&(m.deployment=a),c!==void 0&&(m.labels=c);let{data:y,status:d}=await this.requestWithStatus(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)},"Set domain");return{...y,isCreate:d===201}}async listDomains(e){return this.request(`${this.apiUrl}${T.DOMAINS}${ee(e)}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"GET"},"Get domain")}async deleteDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"DELETE"},"Delete domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN_VERIFY(encodeURIComponent(e))}`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${T.DOMAIN_DNS(encodeURIComponent(e))}`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${T.DOMAIN_RECORDS(encodeURIComponent(e))}`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${T.DOMAIN_SHARE(encodeURIComponent(e))}`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${T.DOMAINS_VALIDATE}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,a){let p=C(a),c={};return e!==void 0&&(c.ttl=e),p!==void 0&&(c.labels=p),this.request(`${this.apiUrl}${T.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"Create token")}async listTokens(e){return this.request(`${this.apiUrl}${T.TOKENS}${ee(e)}`,{method:"GET"},"List tokens")}async deleteToken(e){return this.request(`${this.apiUrl}${T.TOKEN(encodeURIComponent(e))}`,{method:"DELETE"},"Delete token")}async getToken(e){return this.request(`${this.apiUrl}${T.TOKEN(encodeURIComponent(e))}`,{method:"GET"},"Get token")}async getAccount(){return this.request(`${this.apiUrl}${T.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${T.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return this.request(`${this.apiUrl}${T.PING}`,{method:"GET"},"Ping")}async checkSPA(e,a={}){let p=e.find(d=>d.path==="index.html"||d.path==="/index.html");if(!p||p.size>100*1024)return!1;let c;if(typeof Buffer<"u"&&Buffer.isBuffer(p.content))c=p.content.toString("utf-8");else if(typeof Blob<"u"&&p.content instanceof Blob)c=await p.content.text();else if(typeof File<"u"&&p.content instanceof File)c=await p.content.text();else return!1;let m={files:e.map(d=>d.path),index:c};return(await this.request(`${this.apiUrl}${T.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)},"SPA check")).isSPA}};b();b();q();async function Dt(){let t=JSON.stringify(Te,null,2),r;typeof Buffer<"u"?r=Buffer.from(t,"utf-8"):r=new Blob([t],{type:"application/json"});let{md5:e}=await $(r);return{path:v,content:r,size:t.length,md5:e}}async function Oe(t,r,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||t.some(a=>a.path===v))return t;try{if(await r.checkSPA(t,e)){let p=await Dt();return[...t,p]}}catch{}return t}function _e(t){let{getApi:r,ensureInit:e,processInput:a}=t;return{upload:async(p,c={})=>{if(await e(),!a)throw f.config("processInput function is not provided.");let m=r(),y=await a(p,c);return y=await Oe(y,m,c),m.deploy(y,c)},list:async p=>(await e(),r().listDeployments(p)),get:async p=>(await e(),r().getDeployment(p)),set:async(p,c)=>(await e(),r().updateDeploymentLabels(p,c.labels)),delete:async p=>(await e(),r().deleteDeployment(p))}}function Ce(t){let{getApi:r,ensureInit:e}=t;return{set:async(a,p={})=>(await e(),r().setDomain(a,p.deployment,p.labels)),list:async a=>(await e(),r().listDomains(a)),get:async a=>(await e(),r().getDomain(a)),delete:async a=>(await e(),r().deleteDomain(a)),verify:async a=>(await e(),r().verifyDomain(a)),validate:async a=>(await e(),r().validateDomain(a)),dns:async a=>(await e(),r().getDomainDns(a)),records:async a=>(await e(),r().getDomainRecords(a)),share:async a=>(await e(),r().getDomainShare(a))}}function $e(t){let{getApi:r,ensureInit:e}=t;return{get:async()=>(await e(),r().getAccount())}}function Ue(t){let{getApi:r,ensureInit:e}=t;return{create:async(a={})=>(await e(),r().createToken(a.ttl,a.labels)),list:async a=>(await e(),r().listTokens(a)),get:async a=>(await e(),r().getToken(a)),delete:async a=>(await e(),r().deleteToken(a))}}var j=class{constructor(r={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(r={...r,apiUrl:r.apiUrl||void 0,token:r.token||void 0,caller:r.caller||void 0},this.clientOptions=r,r.caller!==void 0&&Re(r.caller),r.token&&r.session)throw f.config("Provide either `token` or `session`, not both.");typeof r.token=="string"?(J(r.token),this.credential=r.token):r.token&&(this.credential=r.token),this.http=new V({...r,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let e={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=_e({...e,processInput:(a,p)=>this.processInput(a,p)}),this.domains=Ce(e),this.account=$e(e),this.tokens=Ue(e)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(r){throw this.initPromise=null,r}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(r,e){return this.deployments.upload(r,e)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(r,e){this.http.on(r,e)}off(r,e){this.http.off(r,e)}setHeaders(r){this.http.setGlobalHeaders(r)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(r){if(this.clientOptions.session)throw f.config("Provide either `token` or `session`, not both.");if(typeof r=="string"){if(!r)throw f.business("Invalid token provided. Token must be a non-empty string.");J(r),this.credential=r;return}if(typeof r!="function")throw f.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=r}async getAuthHeaders(){if(this.credential===null)return{};let r=typeof this.credential=="function"?await this.credential():this.credential;if(!r)throw f.authentication("Token provider returned no token.");if(typeof r!="string")throw f.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${r}`}}};b();async function Me(t,r={}){let{labels:e,via:a,password:p,flags:c,captcha:m}=r,y=new FormData,d=[];for(let g of t){if(!(g.content instanceof File||g.content instanceof Blob))throw f.file(`Unsupported file.content type for browser: ${g.path}`,{filePath:g.path});if(!g.md5)throw f.file(`File missing md5 checksum: ${g.path}`,{filePath:g.path});let h=new File([g.content],g.path,{type:"application/octet-stream"});y.append("files[]",h),d.push(g.md5)}return y.append("checksums",JSON.stringify(d)),e&&e.length>0&&y.append("labels",JSON.stringify(e)),a&&y.append("via",a),p&&y.append("password",p),c?.build&&y.append("build","true"),c?.prerender&&y.append("prerender","true"),c?.spa&&y.append("spa","true"),m&&y.append("captcha",m),{body:y,headers:{}}}b();b();ne();ie();ae();le();q();pe();function Ln(t,r,e,a=!0){let p=t===1?r:e;return a?`${t} ${p}`:p}ue();var ce=class extends j{async deploy(r,e){return super.deploy(r,e)}async processInput(r,e){if(!Array.isArray(r)||!r.every(p=>p instanceof File))throw f.business("Invalid input type for browser environment. Expected File[].");if(r.length===0)throw f.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(ue(),Xe));return a(r,e,this.platformLimits??void 0)}getDeployBodyCreator(){return Me}},er=ce;export{De as API_KEY,T as API_PATHS,Lt as AUTH_BASE_PATH,vt as AccountPlan,V as ApiHttp,me as AuthMethod,ot as BLOCKED_EXTENSIONS,W as CALLER,Q as DEFAULT_API,v as DEPLOYMENT_CONFIG_FILENAME,Ae as DEPLOY_TOKEN,Pt as DeploymentStatus,xt as DomainStatus,D as ErrorType,S as FILE_VALIDATION_STATUS,S as FileValidationStatus,he as IDEMPOTENCY_KEY_CONSTRAINTS,wt as JUNK_DIRECTORIES,N as LABEL_CONSTRAINTS,Ie as LABEL_PATTERN,Nt as OAuthScope,H as PASSWORD_CONSTRAINTS,Te as SPA_DEFAULT_CONFIG,ce as Ship,f as ShipError,O as TokenKind,lt as UNBUILT_PROJECT_MARKERS,at as UNSAFE_FILENAME_CHARS,gn as __setTestEnvironment,Tn as allValidFilesReady,Se as assertShipJsonSyntax,$ as calculateMD5,pt as classifyToken,$e as createAccountResource,_e as createDeploymentResource,Ce as createDomainResource,Ue as createTokenResource,er as default,Bt as deserializeLabels,Ct as extractSubdomain,Ve as filterJunk,se as formatFileSize,$t as generateDeploymentUrl,Ut as generateDomainUrl,Ge as getENV,St as getValidFiles,k as hasUnbuiltMarker,Ee as hasUnsafeChars,G as isBlockedExtension,_t as isCustomDomain,Ot as isDeployment,we as isPlatformDomain,ge as isShipError,He as optimizeDeployPaths,Ln as pluralize,je as processFilesForBrowser,Mt as serializeLabels,ut as validateApiKey,Ft as validateApiUrl,Re as validateCaller,qe as validateDeployFile,Ke as validateDeployPath,ct as validateDeployToken,oe as validateFileName,An as validateFiles,ye as validateIdempotencyKey,Z as validatePassword,J as validateToken};
2
2
  //# sourceMappingURL=browser.js.map