@shipstatic/ship 3.3.2 → 3.4.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -132,7 +132,7 @@ ship ping
132
132
  ```typescript
133
133
  ship.account.get() // → whoami
134
134
  ship.ping() // → { timestamp } (server clock; reachability is the absence of a throw)
135
- ship.getLimits() // → platform plan limits (cached)
135
+ ship.getLimits() // → the account's platform limits, read now
136
136
  ```
137
137
 
138
138
  ## CLI reference
@@ -5,7 +5,7 @@ Their copyright notices travel with that copy, and are reproduced here in
5
5
  full. This file is GENERATED from the build's own metafile — edit the
6
6
  bundle, not this list.
7
7
 
8
- ## @shipstatic/types 3.7.0
8
+ ## @shipstatic/types 3.8.0-beta.4
9
9
 
10
10
  License: MIT
11
11
 
package/dist/browser.d.ts CHANGED
@@ -786,18 +786,34 @@ type AccountRole = 'owner' | 'member';
786
786
  * account automation, not a person, and is always `active`.
787
787
  */
788
788
  type AccountAccess = 'active' | 'paused';
789
+ /**
790
+ * The word a refusal about the account carries in `details.account`, so a
791
+ * client can tell the two apart without reading the sentence:
792
+ *
793
+ * - `paused`: a 403. The person is a member, and the account holds more
794
+ * members than its plan allows (see {@link AccountAccess}).
795
+ * - `unknown`: a 404. The account the request names ({@link ACCOUNT_HEADER})
796
+ * is one the person is not a member of, or one that does not exist; the
797
+ * two are indistinguishable by design. A tab whose person was removed from
798
+ * the account meets it on its next request.
799
+ */
800
+ declare const AccountRefusal: {
801
+ readonly PAUSED: "paused";
802
+ readonly UNKNOWN: "unknown";
803
+ };
804
+ type AccountRefusalType = (typeof AccountRefusal)[keyof typeof AccountRefusal];
789
805
  /**
790
806
  * Core account object - used in both API responses and SDK
791
807
  * All fields are readonly to prevent accidental mutations
792
808
  */
793
809
  interface Account {
794
810
  /**
795
- * The account this response describes, by id. A person may belong to
796
- * several accounts and a browser session selects one, so a client names
797
- * the one it means on every request (`X-Account`) and this is where it
798
- * learns the name. Optional by the additive-evolution law.
811
+ * The account this response describes, by id: the name the console's URL
812
+ * carries (`/<account>/`) and a session request sends in
813
+ * {@link ACCOUNT_HEADER}. A machine credential IS its account, so the
814
+ * response names the account the credential belongs to.
799
815
  */
800
- readonly account?: string;
816
+ readonly account: string;
801
817
  /** User email address */
802
818
  readonly email: string;
803
819
  /**
@@ -941,20 +957,6 @@ interface PlanDestination {
941
957
  readonly plan: AccountPlanType;
942
958
  readonly intervals: BillingInterval[];
943
959
  }
944
- /**
945
- * Account as returned by `GET /account` — the entity plus how the request
946
- * was authorized, so `whoami` can answer "what credential am I holding?".
947
- * Request-scoped fields live on the response type, never on the entity
948
- * (the `DeploymentCreateResponse` pattern).
949
- */
950
- interface AccountGetResponse extends Account {
951
- /** How the request that produced this response was authorized. */
952
- readonly authMethod: AuthMethodType;
953
- /** Present (and true) only when the caller is an operator acting as themselves. */
954
- readonly isAdmin?: true;
955
- /** Present only during read-only admin impersonation: the operator's account id. */
956
- readonly impersonatedBy?: string;
957
- }
958
960
  /**
959
961
  * Acknowledgement of `DELETE /account` (202). Termination is asynchronous —
960
962
  * a cleanup consumer finishes the job — so the account survives long enough
@@ -1703,16 +1705,18 @@ declare const CALLER: {
1703
1705
  readonly PATTERN: RegExp;
1704
1706
  };
1705
1707
  /**
1706
- * The account a session request MEANS.
1708
+ * The account a session request is about.
1707
1709
  *
1708
- * A browser session selects one account for every tab at once, so a tab that
1709
- * switched leaves its siblings acting for an account they no longer show. A
1710
- * session caller may name the account it means in this header; the API
1711
- * answers 409 `details.account: 'select'` when it differs from the account the
1712
- * session resolves to, and the client re-selects. A precondition check the
1713
- * client volunteers, never authority: a request without it resolves exactly as
1714
- * before, and machine credentials never send it. One owner for the name, since
1715
- * the API's CORS allowlist and every browser transport spell it.
1710
+ * A person may belong to several accounts, so a request made with a browser
1711
+ * session names the one it means, on every request to an account route; the
1712
+ * console takes the value from its URL (`/<account>/`). The header names and
1713
+ * membership authorizes: the API resolves the person's membership in the
1714
+ * account named, answers 404 `details.account: 'unknown'` for an account the
1715
+ * person is not in (or one that does not exist), and 400 when a session
1716
+ * request names none. Machine credentials never send it, since a key, a
1717
+ * deploy token or an OAuth grant already belongs to one account. One owner
1718
+ * for the name, since the API's CORS allowlist and every browser transport
1719
+ * spell it.
1716
1720
  */
1717
1721
  declare const ACCOUNT_HEADER = "X-Account";
1718
1722
  /**
@@ -2005,6 +2009,122 @@ interface StaticFile {
2005
2009
  /** The size of the file in bytes. */
2006
2010
  size: number;
2007
2011
  }
2012
+ /**
2013
+ * The sections of an account, by first segment, each mounted twice by the
2014
+ * console: under `/<account>/` and at the root.
2015
+ *
2016
+ * `owner` marks a section that means the person's OWN account: a bare path
2017
+ * into it opens the person's own account rather than the one entered last,
2018
+ * since a pricing link's `/upgrade/pro` and the published API-key link speak
2019
+ * about the reader's plan and key. Modals inside a section carry their own
2020
+ * owner rule in the console; this flag is the section's alone.
2021
+ */
2022
+ declare const SECTIONS: {
2023
+ readonly new: {
2024
+ readonly owner: false;
2025
+ };
2026
+ readonly deployments: {
2027
+ readonly owner: false;
2028
+ };
2029
+ readonly domains: {
2030
+ readonly owner: false;
2031
+ };
2032
+ readonly settings: {
2033
+ readonly owner: false;
2034
+ };
2035
+ readonly upgrade: {
2036
+ readonly owner: true;
2037
+ };
2038
+ readonly success: {
2039
+ readonly owner: false;
2040
+ };
2041
+ readonly 'api-key': {
2042
+ readonly owner: true;
2043
+ };
2044
+ };
2045
+ /** A section's first segment. */
2046
+ type ConsoleSection = keyof typeof SECTIONS;
2047
+ /** The two fragments of the settings page a link may name. */
2048
+ type SettingsFragment = 'members' | 'api-key';
2049
+ /**
2050
+ * The query markers a Stripe return lands with, each written by a builder
2051
+ * below and read by `billingReturnOf`, so neither side spells one.
2052
+ */
2053
+ declare const BILLING_RETURNS: {
2054
+ readonly checkout: readonly ["upgrading", "true"];
2055
+ readonly portal: readonly ["billing", "returned"];
2056
+ };
2057
+ type BillingReturn = keyof typeof BILLING_RETURNS;
2058
+ /**
2059
+ * The paths inside one account, or, with no account, the bare form the
2060
+ * console opens in the account entered last.
2061
+ *
2062
+ * ```ts
2063
+ * consolePaths(account).domains.connect('www.example.com')
2064
+ * // '/<account>/domains/www.example.com/connect'
2065
+ * consolePaths().apiKey()
2066
+ * // '/api-key'
2067
+ * ```
2068
+ */
2069
+ declare function consolePaths(account?: string): {
2070
+ dashboard: () => string;
2071
+ newSite: () => string;
2072
+ deployments: (() => string) & {
2073
+ upload: () => string;
2074
+ };
2075
+ domains: (() => string) & {
2076
+ connect: (domain: string) => string;
2077
+ deployment: (domain: string) => string;
2078
+ };
2079
+ settings: (fragment?: SettingsFragment) => string;
2080
+ /** Settings, marked as the landing of a Stripe Customer Portal return. */
2081
+ settingsAfterBilling: () => string;
2082
+ upgrade: (plan?: AccountPlanType) => string;
2083
+ success: () => string;
2084
+ /** The success page, marked as the landing of a Stripe Checkout return. */
2085
+ successAfterCheckout: () => string;
2086
+ apiKey: () => string;
2087
+ };
2088
+ /** The builders `consolePaths` returns. */
2089
+ type ConsolePaths = ReturnType<typeof consolePaths>;
2090
+ /** The doors: the pages that exist before an account is known. */
2091
+ declare const doors: {
2092
+ readonly login: (next?: string) => string;
2093
+ readonly register: (next?: string) => string;
2094
+ readonly logout: () => string;
2095
+ readonly invitation: (invitation: string) => string;
2096
+ readonly claim: (code: string) => string;
2097
+ readonly consent: () => string;
2098
+ };
2099
+ /**
2100
+ * Which Stripe return a query string marks: `checkout` for the success page
2101
+ * after Checkout, `portal` for settings after the Customer Portal, or null.
2102
+ */
2103
+ declare function billingReturnOf(search: string): BillingReturn | null;
2104
+ /**
2105
+ * The account a path names, or null for a door, the operator partition, or
2106
+ * the bare form. Any first segment that is not a section, a door or the
2107
+ * partition is an account: the grammar has no other reading, and whether
2108
+ * the account exists is the server's answer, never the path's.
2109
+ */
2110
+ declare function accountOfPath(path: string): string | null;
2111
+ /** Whether a path names a claim link (`/claim/:code`, a bearer credential). */
2112
+ declare const isClaimPath: (path: string) => boolean;
2113
+ /** Whether a path names an invitation (`/invitations/:invitation`). */
2114
+ declare const isInvitationPath: (path: string) => boolean;
2115
+ /**
2116
+ * Whether a path names the upgrade section, in either form: `/upgrade`,
2117
+ * `/upgrade/:plan`, and the same under `/<account>/`.
2118
+ */
2119
+ declare const isUpgradePath: (path: string) => boolean;
2120
+ /** The errand a destination path carries, as the sign-in doors read it. */
2121
+ type ConsoleErrand = 'claim' | 'invite' | 'upgrade';
2122
+ /**
2123
+ * The errand a destination path carries, in specificity order: a pricing
2124
+ * link is the broadest, and the narrower ones do not normally coexist with
2125
+ * it.
2126
+ */
2127
+ declare function errandOf(path: string): ConsoleErrand | null;
2008
2128
  /** Default API URL if not otherwise configured. */
2009
2129
  declare const DEFAULT_API = "https://api.shipstatic.com";
2010
2130
  /**
@@ -2044,15 +2164,15 @@ declare const SHIP_ENV: {
2044
2164
  */
2045
2165
  declare const SHIP_VIA_ENV = "SHIP_VIA";
2046
2166
  /**
2047
- * Where a human creates an API key — the console deep link quoted by every
2167
+ * Where a human creates an API key: the console deep link quoted by every
2048
2168
  * surface that teaches authentication (the CLI's config wizard, the VS Code
2049
- * and n8n listings, the n8n rate-limit hint and credential copy). Written
2050
- * out in five files across three repos until this export.
2169
+ * and n8n listings, the n8n rate-limit hint and credential copy). The bare
2170
+ * form of the path, which the console opens in the reader's own account.
2051
2171
  *
2052
2172
  * Production-branded by design: published artifacts name the product, never
2053
2173
  * an environment (root `CLAUDE.md`, "Environment-Aware URLs").
2054
2174
  */
2055
- declare const MY_API_KEY_URL = "https://my.shipstatic.com/api-key";
2175
+ declare const MY_API_KEY_URL: string;
2056
2176
  /**
2057
2177
  * How long an anonymous deployment lives before it expires.
2058
2178
  *
@@ -2267,7 +2387,7 @@ interface DomainResource {
2267
2387
  * Account resource interface - the contract all implementations must follow
2268
2388
  */
2269
2389
  interface AccountResource {
2270
- get: () => Promise<AccountGetResponse>;
2390
+ get: () => Promise<Account>;
2271
2391
  }
2272
2392
  /**
2273
2393
  * Token resource interface - the contract all implementations must follow
@@ -3246,17 +3366,9 @@ declare abstract class Ship$1 {
3246
3366
  readonly tokens: TokenResource;
3247
3367
  private readonly http;
3248
3368
  private readonly clientOptions;
3249
- private initPromise;
3250
- protected platformLimits: PlatformLimits | null;
3251
3369
  private credential;
3252
3370
  constructor(options?: ShipClientOptions);
3253
- protected abstract processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
3254
- /**
3255
- * Lazy initialization — fetches platform limits (file size / count caps) once,
3256
- * on the first API call. Subsequent calls reuse the resolved promise.
3257
- */
3258
- protected ensureInitialized(): Promise<void>;
3259
- private fetchPlatformLimits;
3371
+ protected abstract processInput(input: DeployInput, options: DeploymentOptions, limits: PlatformLimits): Promise<StaticFile[]>;
3260
3372
  /**
3261
3373
  * Ping the API server, resolving its answer: `{ success, timestamp }`, where
3262
3374
  * `timestamp` is the server clock in unix SECONDS.
@@ -3275,11 +3387,11 @@ declare abstract class Ship$1 {
3275
3387
  /**
3276
3388
  * Get current account information (convenience shortcut to `ship.account.get()`).
3277
3389
  */
3278
- whoami(): Promise<AccountGetResponse>;
3390
+ whoami(): Promise<Account>;
3279
3391
  /**
3280
- * Get platform limits (max file size, file count, total size).
3281
- * Reuses the response fetched during initialization. Per-instance state —
3282
- * does not leak between concurrent Ships against different API URLs.
3392
+ * Get the platform limits the server states now (max file size, file count,
3393
+ * total size, and the blocked extensions). Asked every time and never held,
3394
+ * since a plan move or an operator's grant changes them.
3283
3395
  */
3284
3396
  getLimits(): Promise<PlatformLimits>;
3285
3397
  on<K extends keyof ShipEvents>(event: K, handler: (...args: ShipEvents[K]) => void): void;
@@ -3634,10 +3746,9 @@ declare function pluralize(count: number, singular: string, plural: string, incl
3634
3746
  *
3635
3747
  * @param browserFiles - File[] to process for deploy.
3636
3748
  * @param options - Processing options including pathDetect for automatic path optimization.
3637
- * @param platformLimits - Per-instance platform limits (file-size / count / total-size caps)
3638
- * from the originating Ship's `GET /limits` fetch. Passed in rather than read from a
3639
- * module global so concurrent Ships against different API URLs cannot clobber each
3640
- * other's caps.
3749
+ * @param platformLimits - The platform limits (file-size / count / total-size caps and
3750
+ * the blocked extensions) the deploy read from `GET /limits` at its start. Passed in,
3751
+ * never held, so a validation always meets the limits the server states now.
3641
3752
  * @returns Promise resolving to an array of StaticFile objects.
3642
3753
  * @throws {ShipError} If called outside a browser or with invalid input.
3643
3754
  */
@@ -3678,7 +3789,7 @@ declare class Ship extends Ship$1 {
3678
3789
  * contract stays platform-neutral.
3679
3790
  */
3680
3791
  deploy(input: File[], options?: DeploymentOptions): Promise<DeploymentCreateResponse>;
3681
- protected processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
3792
+ protected processInput(input: DeployInput, options: DeploymentOptions, limits: PlatformLimits): Promise<StaticFile[]>;
3682
3793
  }
3683
3794
 
3684
- export { ACCOUNT_HEADER, API_KEY, API_PATHS, AUTH_BASE_PATH, type Account, type AccountAccess, type AccountDeleteResponse, type AccountGetResponse, type AccountKeyResponse, AccountPlan, type AccountPlanType, type AccountResource, type AccountRole, type Activity, type ActivityEvent, type ActivityListResponse, type ActivityMeta, type ApiDeployOptions, ApiHttp, type ApiHttpOptions, AuthMethod, type AuthMethodType, BUILD_SETTINGS, type BillingInterval, type BillingPortalSession, type BillingSyncResponse, type BuildFailureDetails, CALLER, type Caps, DEFAULT_API, DEPLOYMENT_CONFIG_FILENAME, DEPLOY_FIELDS, DEPLOY_FILE_GRAMMAR, DEPLOY_TOKEN, type DeployBodyContext, type DeployFile, type DeployFileEncoding, type DeployFileSpec, type DeployInput, type DeployTransport, type Deployment, type DeploymentCreateResponse, type DeploymentDeleteResponse, type DeploymentListResponse, type DeploymentOptions, type DeploymentResource, type DeploymentResourceContext, type DeploymentSetOptions, DeploymentStatus, type DeploymentStatusType, type DeploymentUploadOptions, DeploymentVia, type DeploymentViaType, 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, DomainVerification, type DomainVerificationType, 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, MY_API_KEY_URL, OAUTH_TOKEN, OAuthScope, type OAuthScopeType, PASSWORD_CONSTRAINTS, PUBLIC_DEPLOYMENT_TTL_SECONDS, type PingResponse, type Plan, type PlanChangeRequest, type PlanChangeResponse, type PlanDestination, type PlansResponse, type PlatformLimits, type RequestResult, type ResourceContext, SETUP_TROUBLESHOOTING_ANCHOR, SHIP_ENV, SHIP_VIA_ENV, SIGN_IN_RETURN_PARAM, type SPACheckDebug, type SPACheckRequest, type SPACheckResponse, SPA_CHECK_CONSTRAINTS, SPA_DEFAULT_CONFIG, type ScheduledChange, type SetupInstructionsResponse, Ship, type ShipClientOptions, ShipError, type ShipEvents, type ShipRequestInit, type StaticFile, TTL_CONSTRAINTS, type Token, type TokenCreateOptions, type TokenCreateResponse, type TokenDeleteResponse, TokenKind, type TokenKindType, type TokenListResponse, type TokenProvider, type TokenResource, type Transport, UNBUILT_PROJECT_MARKERS, UNSAFE_FILENAME_CHARS, USER_VISIBLE_EVENTS, type UploadedFile, type UserVisibleActivityEvent, type ValidatableFile, type ValidationIssue, WEB_FILE_ACCEPT, __setTestEnvironment, allValidFilesReady, assertShipJsonSyntax, calculateMD5, classifyToken, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, deserializeLabels, extractSubdomain, filterJunk, formatDuration, formatFileSize, formatTimeRemaining, generateDeploymentUrl, generateDomainUrl, getENV, getValidFiles, hasUnbuiltMarker, hasUnsafeChars, isBlockedExtension, isCustomDomain, isDeployment, isPlatformDomain, isShipError, normalizeVia, optimizeDeployPaths, personName, personShortName, pluralize, processFilesForBrowser, readBearerValue, serializeLabels, validateApiKey, validateApiUrl, validateBuildCommand, validateCaller, validateDeployFile, validateDeployPath, validateDeployToken, validateFileName, validateFiles, validateIdempotencyKey, validateOAuthToken, validateOutputDir, validatePassword, validateToken, validateTtl };
3795
+ export { ACCOUNT_HEADER, API_KEY, API_PATHS, AUTH_BASE_PATH, type Account, type AccountAccess, type AccountDeleteResponse, type AccountKeyResponse, AccountPlan, type AccountPlanType, AccountRefusal, type AccountRefusalType, type AccountResource, type AccountRole, type Activity, type ActivityEvent, type ActivityListResponse, type ActivityMeta, type ApiDeployOptions, ApiHttp, type ApiHttpOptions, AuthMethod, type AuthMethodType, BUILD_SETTINGS, type BillingInterval, type BillingPortalSession, type BillingSyncResponse, type BuildFailureDetails, CALLER, type Caps, type ConsoleErrand, type ConsolePaths, type ConsoleSection, DEFAULT_API, DEPLOYMENT_CONFIG_FILENAME, DEPLOY_FIELDS, DEPLOY_FILE_GRAMMAR, DEPLOY_TOKEN, type DeployBodyContext, type DeployFile, type DeployFileEncoding, type DeployFileSpec, type DeployInput, type DeployTransport, type Deployment, type DeploymentCreateResponse, type DeploymentDeleteResponse, type DeploymentListResponse, type DeploymentOptions, type DeploymentResource, type DeploymentResourceContext, type DeploymentSetOptions, DeploymentStatus, type DeploymentStatusType, type DeploymentUploadOptions, DeploymentVia, type DeploymentViaType, 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, DomainVerification, type DomainVerificationType, 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, MY_API_KEY_URL, OAUTH_TOKEN, OAuthScope, type OAuthScopeType, PASSWORD_CONSTRAINTS, PUBLIC_DEPLOYMENT_TTL_SECONDS, type PingResponse, type Plan, type PlanChangeRequest, type PlanChangeResponse, type PlanDestination, type PlansResponse, type PlatformLimits, type RequestResult, type ResourceContext, SECTIONS, SETUP_TROUBLESHOOTING_ANCHOR, SHIP_ENV, SHIP_VIA_ENV, SIGN_IN_RETURN_PARAM, type SPACheckDebug, type SPACheckRequest, type SPACheckResponse, SPA_CHECK_CONSTRAINTS, SPA_DEFAULT_CONFIG, type ScheduledChange, type SettingsFragment, type SetupInstructionsResponse, Ship, type ShipClientOptions, ShipError, type ShipEvents, type ShipRequestInit, type StaticFile, TTL_CONSTRAINTS, type Token, type TokenCreateOptions, type TokenCreateResponse, type TokenDeleteResponse, TokenKind, type TokenKindType, type TokenListResponse, type TokenProvider, type TokenResource, type Transport, UNBUILT_PROJECT_MARKERS, UNSAFE_FILENAME_CHARS, USER_VISIBLE_EVENTS, type UploadedFile, type UserVisibleActivityEvent, type ValidatableFile, type ValidationIssue, WEB_FILE_ACCEPT, __setTestEnvironment, accountOfPath, allValidFilesReady, assertShipJsonSyntax, billingReturnOf, calculateMD5, classifyToken, consolePaths, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, deserializeLabels, doors, errandOf, extractSubdomain, filterJunk, formatDuration, formatFileSize, formatTimeRemaining, generateDeploymentUrl, generateDomainUrl, getENV, getValidFiles, hasUnbuiltMarker, hasUnsafeChars, isBlockedExtension, isClaimPath, isCustomDomain, isDeployment, isInvitationPath, isPlatformDomain, isShipError, isUpgradePath, normalizeVia, optimizeDeployPaths, personName, personShortName, pluralize, processFilesForBrowser, readBearerValue, serializeLabels, validateApiKey, validateApiUrl, validateBuildCommand, validateCaller, validateDeployFile, validateDeployPath, validateDeployToken, validateFileName, validateFiles, validateIdempotencyKey, validateOAuthToken, validateOutputDir, validatePassword, validateToken, validateTtl };
package/dist/browser.js CHANGED
@@ -1,2 +1,2 @@
1
- var pt=Object.create;var $=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var ft=Object.getOwnPropertyNames;var dt=Object.getPrototypeOf,mt=Object.prototype.hasOwnProperty;var ht=(e,n,t)=>n in e?$(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var _=(e,n)=>()=>(e&&(n=e(e=0)),n);var Ie=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),yt=(e,n)=>{for(var t in n)$(e,t,{get:n[t],enumerable:!0})},Et=(e,n,t,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of ft(n))!mt.call(e,l)&&l!==t&&$(e,l,{get:()=>n[l],enumerable:!(a=ct(n,l))||a.enumerable});return e};var G=(e,n,t)=>(t=e!=null?pt(dt(e)):{},Et(n||!e||!e.__esModule?$(t,"default",{value:e,enumerable:!0}):t,e));var k=(e,n,t)=>ht(e,typeof n!="symbol"?n+"":n,t);function sn(e){if(!e||typeof e!="string")return;let n=e.trim().toLowerCase();return Object.values(gt).includes(n)?n:void 0}function _e(e){if(e==null)return;if(typeof e!="string")throw d.validation("Idempotency key must be a string.");let n=e.trim();if(!n)throw d.validation("Idempotency key must not be empty.");if(n.length>F.MAX_LENGTH)throw d.validation(`Idempotency key must be at most ${F.MAX_LENGTH} characters.`);return n}function ln(e){return e.name?.trim()||e.email}function un(e){return e.name?.trim().split(" ")[0]||e.email}function Dt(e){let n=e.code;return n==="ERR_INVALID_URL"?!1:typeof n=="string"?!0:e instanceof TypeError?!/\burl\b/i.test(e.message):!1}function Le(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function Rt(e){let n=e.replace(/\\/g,"/").split("/").pop()??"",t=n.lastIndexOf(".");return t<=0||t===n.length-1?null:n.slice(t+1).toLowerCase()}function Ne(e,n){let t=Rt(e);return t===null?!1:Array.isArray(n)?n.includes(t):n.has(t)}function Pe(e){return It.test(e)}function K(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(t=>_t.has(t))}function Lt(e){return e.startsWith(we.PREFIX)?O.API_KEY:e.startsWith(xe.PREFIX)?O.DEPLOY_TOKEN:e.startsWith(Oe.PREFIX)?O.OAUTH:O.OPAQUE}function hn(e){return e.slice(0,oe.length).toLowerCase()!==oe?null:e.slice(oe.length)||null}function Fe(e){let n=e.charCodeAt(0)===65279?e.slice(1):e,t;try{t=JSON.parse(n)}catch(a){throw d.config(`invalid JSON format in config: ${a.message}`,{filePath:P})}if(t===null||typeof t!="object"||Array.isArray(t))throw d.config(`${P} must contain a JSON object`,{filePath:P})}function ae(e,n,t){if(!e.startsWith(n.PREFIX))throw d.validation(`${t} must start with "${n.PREFIX}"`);if(e.length!==n.TOTAL_LENGTH)throw d.validation(`${t} must be ${n.TOTAL_LENGTH} characters total (${n.PREFIX} + ${n.HEX_LENGTH} hex chars)`);let a=e.slice(n.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${n.HEX_LENGTH}}$`,"i").test(a))throw d.validation(`${t} must contain ${n.HEX_LENGTH} hexadecimal characters after "${n.PREFIX}" prefix`)}function Nt(e){ae(e,we,"API key")}function Pt(e){ae(e,xe,"Deploy token")}function wt(e){ae(e,Oe,"OAuth access token")}function le(e){switch(Lt(e)){case O.API_KEY:Nt(e);return;case O.DEPLOY_TOKEN:Pt(e);return;case O.OAUTH:wt(e);return;case O.OPAQUE:if(!e)throw d.validation("Token must be a non-empty string")}}function Ce(e){if(!e||e.length>M.MAX_LENGTH||!M.PATTERN.test(e))throw d.validation(`Caller must be 1-${M.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function En(e){try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol))throw d.validation("API URL must use http:// or https:// protocol");if(n.pathname!=="/"&&n.pathname!=="")throw d.validation("API URL must not contain a path");if(n.search||n.hash)throw d.validation("API URL must not contain query parameters or fragments")}catch(n){throw Le(n)?n:d.validation("API URL must be a valid URL")}}function gn(e){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(e)}function ue(e){if(e!=null){if(typeof e!="number"||!Number.isFinite(e))throw d.validation("TTL must be a number of seconds");if(!Number.isInteger(e))throw d.validation("TTL must be a whole number of seconds");if(e<z.MIN_SECONDS||e>z.MAX_SECONDS)throw d.validation(`TTL must be between ${z.MIN_SECONDS} and ${z.MAX_SECONDS} seconds`);return e}}function xt(e){let n=Math.round(e/60);if(!(n>=1))return"less than a minute";if(n<120)return se(n,"minute");let t=Math.round(e/3600);return t<48?se(t,"hour"):se(Math.round(e/86400),"day")}function Rn(e,n=Date.now()/1e3){let t=e-n;return t>0?xt(t):null}function se(e,n){return`${e} ${n}${e===1?"":"s"}`}function H(e,n=1){if(e===0)return"0 Bytes";let t=1024,a=["Bytes","KB","MB","GB"],l=Math.floor(Math.log(e)/Math.log(t));return`${Number.parseFloat((e/t**l).toFixed(n))} ${a[l]}`}function Me(e,n){return e.endsWith(`.${n}`)}function In(e,n){return!Me(e,n)}function _n(e,n){return Me(e,n)?e.slice(0,-(n.length+1)):null}function Ln(e){return`https://${e}`}function Nn(e){return`https://${e}`}function Pn(e){return!e||e.length===0?null:JSON.stringify(e)}function wn(e){if(!e)return[];try{let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function He(e){if(e==null||e==="")return;if(typeof e!="string")throw d.validation("Build command must be a string");let n=e.trim();if(n.length===0||n.length>U.COMMAND_MAX_LENGTH)throw d.validation(`Build command must be between 1 and ${U.COMMAND_MAX_LENGTH} characters`);if(/[\x00-\x1f\x7f]/.test(n))throw d.validation("Build command must be a single line");return n}function Be(e){if(e==null||e==="")return;if(typeof e!="string")throw d.validation("Output folder must be a string");let n=e.trim().replace(/\/+$/,"");if(n.length===0||n.length>U.OUTPUT_DIR_MAX_LENGTH)throw d.validation(`Output folder must be between 1 and ${U.OUTPUT_DIR_MAX_LENGTH} characters`);if(!U.OUTPUT_DIR_PATTERN.test(n)||n.split("/").some(t=>t===".."||t==="."))throw d.validation("Output folder must be a relative path inside the project, like dist or dist/site");return n}function ce(e){if(e==null)return;if(typeof e!="string")throw d.validation("Password must be a string");let n=e.trim();if(n.length<V.MIN_LENGTH||n.length>V.MAX_LENGTH)throw d.validation(`Password must be between ${V.MIN_LENGTH} and ${V.MAX_LENGTH} characters`);return n}var tn,gt,nn,rn,on,F,an,A,I,pn,y,Tt,re,At,St,d,bt,cn,It,_t,fn,dn,ie,we,xe,Oe,M,mn,O,oe,yn,P,ve,X,z,pe,Tn,An,Sn,Dn,bn,R,v,Ue,U,V,D=_(()=>{"use strict";tn={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},gt={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc",CLD:"cld",CRS:"crs",GMN:"gmn",API:"api"},nn={LIVE:"live",UNLINKED:"unlinked",UNVERIFIED:"unverified",PAUSED:"paused"},rn={PENDING:"pending",PARTIAL:"partial",VERIFIED:"verified"},on="troubleshooting",F={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};an={FREE:"free",PRO:"pro",TEAM:"team",SCALE:"scale",SPONSORED:"sponsored"};A={DEPLOYMENTS:"/deployments",DEPLOYMENT:e=>`/deployments/${e}`,DEPLOYMENT_CONFIG:e=>`/deployments/${e}/config`,DOMAINS:"/domains",DOMAIN:e=>`/domains/${e}`,DOMAIN_VERIFY:e=>`/domains/${e}/verify`,DOMAIN_DNS:e=>`/domains/${e}/dns`,DOMAIN_RECORDS:e=>`/domains/${e}/records`,DOMAIN_SHARE:e=>`/domains/${e}/share`,DOMAIN_PROPAGATION:e=>`/domains/${e}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:e=>`/tokens/${e}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PLANS:"/plans",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},I={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",TTL:"ttl",BUILD:"build",PRERENDER:"prerender",SPA:"spa",BUILD_COMMAND:"buildCommand",OUTPUT_DIR:"outputDir",CAPTCHA:"captcha"},pn={PATH:"path",CONTENT:"content",ENCODING:"encoding",DEFAULT_ENCODING:"utf-8",ENCODINGS:["utf-8","base64"]},y={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Maintenance:"maintenance",Build:"build_failed",Network:"network_error",Timeout:"timeout_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},Tt=new Set([y.Network,y.Timeout,y.Cancelled,y.File,y.Config]),re={client:new Set([y.Build,y.Business,y.Cancelled,y.Config,y.File,y.Forbidden,y.NotFound,y.RateLimit,y.Validation]),network:new Set([y.Network,y.Timeout]),auth:new Set([y.Authentication])},At=new Set(Object.values(y).filter(e=>!Tt.has(e))),St=200;d=class e extends Error{constructor(t,a,l,c){super(a);k(this,"type");k(this,"status");k(this,"details");this.type=t,this.status=l,this.details=c,this.name="ShipError"}toResponse(){let t=this.details,a=this.type===y.Authentication&&t?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:a}}static async fromHttpResponse(t,a){let l,c,h;try{if(t.headers.get("content-type")?.includes("application/json")){let f=await t.json();if(f&&typeof f=="object"){let T=f;typeof T.message=="string"?l=T.message:typeof T.error=="string"&&(l=T.error),c=T.details,typeof T.error=="string"&&At.has(T.error)&&(h=T.error)}}else{let f=(await t.text()).trim();f&&!f.startsWith("<")&&f.length<=St&&(l=f)}}catch{}let E=t.headers.get("retry-after");if(E!==null){let g=E.trim(),f=/^\d+$/.test(g)?Number(g):Math.ceil((Date.parse(g)-Date.now())/1e3);if(Number.isFinite(f)&&f>=0){let T=c&&typeof c=="object"?c:{};T.retryAfter===void 0&&(c={...T,retryAfter:f})}}l=l||`${a||"Request"} failed with status ${t.status}`;let m=h??(t.status===401?y.Authentication:t.status===403?y.Forbidden:t.status===429?y.RateLimit:y.Api);return new e(m,l,t.status,c)}static fromFetchError(t,a){if(Le(t))return t;let l=a||"Request",c=t?.name;return c==="AbortError"?e.cancelled(`${l} was cancelled`):c==="TimeoutError"?e.timeout(`${l} timed out`,{cause:t}):t instanceof Error?Dt(t)?e.network(`${l} failed: ${t.message}`,{cause:t}):new e(y.Api,`${l} failed: ${t.message}`):new e(y.Api,`${l} failed: Unknown error`)}static validation(t,a){return new e(y.Validation,t,400,a)}static notFound(t,a){let l=a?`${t} ${a} not found`:`${t} not found`;return new e(y.NotFound,l,404)}static forbidden(t,a){return new e(y.Forbidden,t,403,a)}static rateLimit(t="Too many requests",a){return new e(y.RateLimit,t,429,a)}static authentication(t="Authentication required",a){return new e(y.Authentication,t,401,a)}static business(t,a=400,l){return new e(y.Business,t,a,l)}static network(t,a){return new e(y.Network,t,void 0,a)}static timeout(t,a){return new e(y.Timeout,t,void 0,a)}static cancelled(t,a){return new e(y.Cancelled,t,void 0,a)}static file(t,a){return new e(y.File,t,void 0,a)}static config(t,a){return new e(y.Config,t,void 0,a)}static api(t,a=500,l){return new e(y.Api,t,a,l)}static maintenance(t,a){return new e(y.Maintenance,t,503,a)}static build(t,a){return new e(y.Build,t,422,a)}isClientError(){return re.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return re.network.has(this.type)}isAuthError(){return re.auth.has(this.type)}isType(t){return this.type===t}};bt=["html","htm","xhtml","xml","txt","md","markdown","pdf","csv","json","jsonc","webmanifest","map","toml","yaml","yml","rss","atom","css","scss","sass","less","js","mjs","cjs","jsx","ts","tsx","wasm","vue","svelte","png","jpg","jpeg","gif","webp","avif","svg","ico","bmp","tif","tiff","heic","heif","woff","woff2","ttf","otf","eot","mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","mp4","webm","ogv","mov","m4v","avi","glb","gltf","usdz","vtt","srt","zip"],cn=bt.map(e=>`.${e}`).join(","),It=/[\x00-\x1f\x7f#?%\\<>"]/;_t=new Set(["node_modules","package.json"]);fn="/auth",dn="signing-in",ie={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",SYSTEM:"system"},we={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},xe={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},Oe={PREFIX:"oauth-",HEX_LENGTH:32,TOTAL_LENGTH:38},M={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},mn="X-Account",O={API_KEY:ie.API_KEY,DEPLOY_TOKEN:ie.TOKEN,OAUTH:ie.OAUTH,OPAQUE:"opaque"};oe="bearer ";yn={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},P="ship.json",ve={rewrites:[{source:"/(.*)",destination:"/index.html"}]},X={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};z={MIN_SECONDS:1,MAX_SECONDS:365*24*60*60};pe="https://api.shipstatic.com",Tn={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},An="SHIP_VIA",Sn="https://my.shipstatic.com/api-key",Dn=4320*60;bn=["account.create","account.update","account.delete","account.key.generate","account.plan.transition","deployment.create","deployment.update","deployment.delete","deployment.claim","domain.create","domain.update","domain.delete","domain.verify","token.create","token.consume","token.delete","member.join","member.leave","consent.grant"],R={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};v={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Ue=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;U={COMMAND_MAX_LENGTH:200,OUTPUT_DIR_MAX_LENGTH:100,OUTPUT_DIR_PATTERN:/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/};V={MIN_LENGTH:6,MAX_LENGTH:128}});var Ve=Ie((ke,ze)=>{"use strict";(function(e){if(typeof ke=="object")ze.exports=e();else if(typeof define=="function"&&define.amd)define(e);else{var n;try{n=window}catch{n=self}n.SparkMD5=e()}})(function(e){"use strict";var n=function(p,u){return p+u&4294967295},t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(p,u,i,r,s,o){return u=n(n(u,p),n(r,o)),n(u<<s|u>>>32-s,i)}function l(p,u){var i=p[0],r=p[1],s=p[2],o=p[3];i+=(r&s|~r&o)+u[0]-680876936|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+u[1]-389564586|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+u[2]+606105819|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+u[3]-1044525330|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+u[4]-176418897|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+u[5]+1200080426|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+u[6]-1473231341|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+u[7]-45705983|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+u[8]+1770035416|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+u[9]-1958414417|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+u[10]-42063|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+u[11]-1990404162|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+u[12]+1804603682|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+u[13]-40341101|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+u[14]-1502002290|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+u[15]+1236535329|0,r=(r<<22|r>>>10)+s|0,i+=(r&o|s&~o)+u[1]-165796510|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+u[6]-1069501632|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+u[11]+643717713|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+u[0]-373897302|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+u[5]-701558691|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+u[10]+38016083|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+u[15]-660478335|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+u[4]-405537848|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+u[9]+568446438|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+u[14]-1019803690|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+u[3]-187363961|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+u[8]+1163531501|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+u[13]-1444681467|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+u[2]-51403784|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+u[7]+1735328473|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+u[12]-1926607734|0,r=(r<<20|r>>>12)+s|0,i+=(r^s^o)+u[5]-378558|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+u[8]-2022574463|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+u[11]+1839030562|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+u[14]-35309556|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+u[1]-1530992060|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+u[4]+1272893353|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+u[7]-155497632|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+u[10]-1094730640|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+u[13]+681279174|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+u[0]-358537222|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+u[3]-722521979|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+u[6]+76029189|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+u[9]-640364487|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+u[12]-421815835|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+u[15]+530742520|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+u[2]-995338651|0,r=(r<<23|r>>>9)+s|0,i+=(s^(r|~o))+u[0]-198630844|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+u[7]+1126891415|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+u[14]-1416354905|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+u[5]-57434055|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+u[12]+1700485571|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+u[3]-1894986606|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+u[10]-1051523|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+u[1]-2054922799|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+u[8]+1873313359|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+u[15]-30611744|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+u[6]-1560198380|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+u[13]+1309151649|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+u[4]-145523070|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+u[11]-1120210379|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+u[2]+718787259|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+u[9]-343485551|0,r=(r<<21|r>>>11)+s|0,p[0]=i+p[0]|0,p[1]=r+p[1]|0,p[2]=s+p[2]|0,p[3]=o+p[3]|0}function c(p){var u=[],i;for(i=0;i<64;i+=4)u[i>>2]=p.charCodeAt(i)+(p.charCodeAt(i+1)<<8)+(p.charCodeAt(i+2)<<16)+(p.charCodeAt(i+3)<<24);return u}function h(p){var u=[],i;for(i=0;i<64;i+=4)u[i>>2]=p[i]+(p[i+1]<<8)+(p[i+2]<<16)+(p[i+3]<<24);return u}function E(p){var u=p.length,i=[1732584193,-271733879,-1732584194,271733878],r,s,o,b,N,x;for(r=64;r<=u;r+=64)l(i,c(p.substring(r-64,r)));for(p=p.substring(r-64),s=p.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<s;r+=1)o[r>>2]|=p.charCodeAt(r)<<(r%4<<3);if(o[r>>2]|=128<<(r%4<<3),r>55)for(l(i,o),r=0;r<16;r+=1)o[r]=0;return b=u*8,b=b.toString(16).match(/(.*?)(.{0,8})$/),N=parseInt(b[2],16),x=parseInt(b[1],16)||0,o[14]=N,o[15]=x,l(i,o),i}function m(p){var u=p.length,i=[1732584193,-271733879,-1732584194,271733878],r,s,o,b,N,x;for(r=64;r<=u;r+=64)l(i,h(p.subarray(r-64,r)));for(p=r-64<u?p.subarray(r-64):new Uint8Array(0),s=p.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<s;r+=1)o[r>>2]|=p[r]<<(r%4<<3);if(o[r>>2]|=128<<(r%4<<3),r>55)for(l(i,o),r=0;r<16;r+=1)o[r]=0;return b=u*8,b=b.toString(16).match(/(.*?)(.{0,8})$/),N=parseInt(b[2],16),x=parseInt(b[1],16)||0,o[14]=N,o[15]=x,l(i,o),i}function g(p){var u="",i;for(i=0;i<4;i+=1)u+=t[p>>i*8+4&15]+t[p>>i*8&15];return u}function f(p){var u;for(u=0;u<p.length;u+=1)p[u]=g(p[u]);return p.join("")}f(E("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(n=function(p,u){var i=(p&65535)+(u&65535),r=(p>>16)+(u>>16)+(i>>16);return r<<16|i&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function p(u,i){return u=u|0||0,u<0?Math.max(u+i,0):Math.min(u,i)}ArrayBuffer.prototype.slice=function(u,i){var r=this.byteLength,s=p(u,r),o=r,b,N,x,be;return i!==e&&(o=p(i,r)),s>o?new ArrayBuffer(0):(b=o-s,N=new ArrayBuffer(b),x=new Uint8Array(N),be=new Uint8Array(this,s,b),x.set(be),N)}})();function T(p){return/[\u0080-\uFFFF]/.test(p)&&(p=unescape(encodeURIComponent(p))),p}function L(p,u){var i=p.length,r=new ArrayBuffer(i),s=new Uint8Array(r),o;for(o=0;o<i;o+=1)s[o]=p.charCodeAt(o);return u?s:r}function C(p){return String.fromCharCode.apply(null,new Uint8Array(p))}function ne(p,u,i){var r=new Uint8Array(p.byteLength+u.byteLength);return r.set(new Uint8Array(p)),r.set(new Uint8Array(u),p.byteLength),i?r:r.buffer}function w(p){var u=[],i=p.length,r;for(r=0;r<i-1;r+=2)u.push(parseInt(p.substr(r,2),16));return String.fromCharCode.apply(String,u)}function S(){this.reset()}return S.prototype.append=function(p){return this.appendBinary(T(p)),this},S.prototype.appendBinary=function(p){this._buff+=p,this._length+=p.length;var u=this._buff.length,i;for(i=64;i<=u;i+=64)l(this._hash,c(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},S.prototype.end=function(p){var u=this._buff,i=u.length,r,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o;for(r=0;r<i;r+=1)s[r>>2]|=u.charCodeAt(r)<<(r%4<<3);return this._finish(s,i),o=f(this._hash),p&&(o=w(o)),this.reset(),o},S.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},S.prototype.setState=function(p){return this._buff=p.buff,this._length=p.length,this._hash=p.hash,this},S.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},S.prototype._finish=function(p,u){var i=u,r,s,o;if(p[i>>2]|=128<<(i%4<<3),i>55)for(l(this._hash,p),i=0;i<16;i+=1)p[i]=0;r=this._length*8,r=r.toString(16).match(/(.*?)(.{0,8})$/),s=parseInt(r[2],16),o=parseInt(r[1],16)||0,p[14]=s,p[15]=o,l(this._hash,p)},S.hash=function(p,u){return S.hashBinary(T(p),u)},S.hashBinary=function(p,u){var i=E(p),r=f(i);return u?w(r):r},S.ArrayBuffer=function(){this.reset()},S.ArrayBuffer.prototype.append=function(p){var u=ne(this._buff.buffer,p,!0),i=u.length,r;for(this._length+=p.byteLength,r=64;r<=i;r+=64)l(this._hash,h(u.subarray(r-64,r)));return this._buff=r-64<i?new Uint8Array(u.buffer.slice(r-64)):new Uint8Array(0),this},S.ArrayBuffer.prototype.end=function(p){var u=this._buff,i=u.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s,o;for(s=0;s<i;s+=1)r[s>>2]|=u[s]<<(s%4<<3);return this._finish(r,i),o=f(this._hash),p&&(o=w(o)),this.reset(),o},S.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.ArrayBuffer.prototype.getState=function(){var p=S.prototype.getState.call(this);return p.buff=C(p.buff),p},S.ArrayBuffer.prototype.setState=function(p){return p.buff=L(p.buff,!0),S.prototype.setState.call(this,p)},S.ArrayBuffer.prototype.destroy=S.prototype.destroy,S.ArrayBuffer.prototype._finish=S.prototype._finish,S.ArrayBuffer.hash=function(p,u){var i=m(new Uint8Array(p)),r=f(i);return u?w(r):r},S})});var j=Ie((Bn,Ke)=>{"use strict";Ke.exports={}});async function $t(e){let n=(await Promise.resolve().then(()=>G(Ve(),1))).default,t=new n.ArrayBuffer,a=2097152;for(let l=0;l<e.size;l+=a){let c=Math.min(l+a,e.size);t.append(await e.slice(l,c).arrayBuffer())}return{md5:t.end()}}async function Gt(e){let{createHash:n}=await Promise.resolve().then(()=>G(j(),1)),t=n("md5");return t.update(e),{md5:t.digest("hex")}}async function kt(e){let{createHash:n}=await Promise.resolve().then(()=>G(j(),1)),{createReadStream:t}=await Promise.resolve().then(()=>G(j(),1));return new Promise((a,l)=>{let c=n("md5"),h=t(e);h.on("error",E=>l(d.file(`Failed to read file for MD5: ${E.message}`,{filePath:e}))),h.on("data",E=>c.update(E)),h.on("end",()=>a({md5:c.digest("hex")}))})}async function W(e){if(e instanceof Blob)return $t(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return Gt(e);if(typeof e=="string")return kt(e);throw d.business("Invalid input for MD5 calculation")}var J=_(()=>{"use strict";D()});function ee(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Qe=_(()=>{"use strict"});function Ze(e,n={}){if(n.flatten===!1)return e.map(a=>({path:ee(a),name:de(a)}));let t=Xt(e);return e.map(a=>{let l=ee(a);if(t){let c=t.endsWith("/")?t:`${t}/`;l.startsWith(c)&&(l=l.substring(c.length))}return l||(l=de(a)),{path:l,name:de(a)}})}function Xt(e){if(!e.length)return"";let t=e.map(c=>ee(c)).map(c=>c.split("/")),a=[],l=Math.min(...t.map(c=>c.length));for(let c=0;c<l-1;c++){let h=t[0][c];if(t.every(E=>E[c]===h))a.push(h);else break}return a.join("/")}function de(e){return e.split(/[/\\]/).pop()||e}var me=_(()=>{"use strict";Qe()});function lr(e){he=e}function qt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function et(){return he||qt()}var he,ye=_(()=>{"use strict";he=null});function te(e,n){return Yt.find(t=>t.broken(e,n))}var Yt,ge=_(()=>{"use strict";D();Te();Yt=[{name:"name",broken:({path:e})=>!Ee(e).valid,sentence:({path:e})=>Ee(e).reason??"Invalid file name"},{name:"extension",broken:({path:e},n)=>Ne(e,n.blockedExtensions??[]),sentence:({path:e})=>`File extension not allowed: "${e}"`},{name:"fileSize",broken:({size:e},n)=>e>n.maxFileSize,sentence:({path:e},n)=>`File "${e}" too large. Maximum ${H(n.maxFileSize)} allowed`},{name:"totalSize",broken:({totalSize:e},n)=>e>n.maxTotalSize,sentence:({totalSize:e},n)=>`Total upload size too large. ${H(e)} exceeds maximum of ${H(n.maxTotalSize)}`}]});function Ee(e){if(Pe(e))return{valid:!1,reason:"File name contains unsafe characters"};if(e.startsWith(" ")||e.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(e.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let n=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,t=e.split("/").pop()||e;return n.test(t)?{valid:!1,reason:"File name uses a reserved system name"}:e.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function hr(e,n){let t=[],a=[],l=[];if(e.length===0){let m={file:"(no files)",message:"At least one file must be provided"};return t.push(m),{files:[],validFiles:[],errors:t,warnings:[],canDeploy:!1}}for(let m of e)if(K(m.name))return t.push({file:m.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:e.map(g=>({...g,status:R.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:t,warnings:[],canDeploy:!1};if(e.length>n.maxFilesCount){let m={file:`(${e.length} files)`,message:`File count (${e.length}) exceeds limit of ${n.maxFilesCount}`};return t.push(m),{files:e.map(g=>({...g,status:R.VALIDATION_FAILED,statusMessage:m.message})),validFiles:[],errors:t,warnings:[],canDeploy:!1}}let c=0;for(let m of e){let g=R.READY,f="Ready for upload";if(m.status===R.PROCESSING_ERROR)g=R.VALIDATION_FAILED,f=m.statusMessage||"File failed during processing",t.push({file:m.name,message:f});else if(m.size===0){g=R.EXCLUDED,f="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:m.name,message:f}),l.push({...m,status:g,statusMessage:f});continue}else if(m.size<0)g=R.VALIDATION_FAILED,f="File size must be positive",t.push({file:m.name,message:f});else if(!m.name||m.name.trim().length===0)g=R.VALIDATION_FAILED,f="File name cannot be empty",t.push({file:m.name||"(empty)",message:f});else if(m.name.includes("\0"))g=R.VALIDATION_FAILED,f="File name contains invalid characters (null byte)",t.push({file:m.name,message:f});else{let T={path:m.name,size:m.size,totalSize:c+m.size},L=te(T,n);L?(g=R.VALIDATION_FAILED,f=L.sentence(T,n),t.push({file:L.name==="totalSize"?`(${e.length} files)`:m.name,message:f})):c=T.totalSize}l.push({...m,status:g,statusMessage:f})}t.length>0&&(l=l.map(m=>m.status===R.EXCLUDED?m:{...m,status:R.VALIDATION_FAILED,statusMessage:m.status===R.VALIDATION_FAILED?m.statusMessage:"Deployment failed due to validation errors in bundle"}));let h=t.length===0?l.filter(m=>m.status===R.READY):[],E=t.length===0;return{files:l,validFiles:h,errors:t,warnings:a,canDeploy:E}}function jt(e){return e.filter(n=>n.status===R.READY)}function yr(e){return jt(e).length>0}var Te=_(()=>{"use strict";D();ge();D()});function tt(e){return Jt.test(e)}var Wt,Jt,nt=_(()=>{"use strict";Wt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],Jt=new RegExp(Wt.join("|"))});function rt(e,n){if(!e||e.length===0)return[];if(!n?.allowUnbuilt&&e.find(a=>a&&K(a)))throw d.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return e.filter(t=>{if(!t)return!1;let a=t.replace(/\\/g,"/").split("/").filter(Boolean);if(a.length===0)return!0;let l=a[a.length-1];if(tt(l))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(Qt.some(E=>h.toLowerCase()===E.toLowerCase()))return!1;return!0})}var Qt,Ae=_(()=>{"use strict";D();nt();Qt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function it(e,n){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw d.business(`Security error: Unsafe file path "${e}" for file: ${n}`)}function ot(e,n){let t=te(e,n);if(t)throw d.business(t.sentence(e,n))}var Se=_(()=>{"use strict";D();ge()});async function st(e,n={},t){let a=!!(n.build||n.prerender),l=Ze(e.map(f=>f.path),{flatten:n.pathDetect!==!1}).map(f=>f.path),c=new Set(rt(l,{allowUnbuilt:a})),h=e.map((f,T)=>({source:f,deployPath:l[T]})).filter(({deployPath:f})=>c.has(f));if(h.length===0)return[];let E=a?null:Zt(t),m=[],g=0;for(let{source:f,deployPath:T}of h){if(E&&it(T,f.origin),f.size===0)continue;E&&(g+=f.size,ot({path:T,size:f.size,totalSize:g},E));let L=await f.read(),{md5:C}=await W(L);m.push({path:T,content:L,size:f.size,md5:C})}if(E&&m.length>E.maxFilesCount)throw d.business(`Too many files to deploy. Maximum allowed is ${E.maxFilesCount} files.`);return m}function Zt(e){if(!e)throw d.config("Platform limits not provided. Deploy-mode validation requires the limits argument \u2014 pass `ship.getLimits()` result.");return e}var at=_(()=>{"use strict";D();me();Ae();J();Se()});var ut={};yt(ut,{processFilesForBrowser:()=>lt});async function lt(e,n={},t){if(et()!=="browser")throw d.business("processFilesForBrowser can only be called in a browser environment.");return st(e.map(a=>({path:a.webkitRelativePath||a.name,origin:a.name,size:a.size,read:async()=>a})),n,t)}var De=_(()=>{"use strict";D();at();ye()});D();D();D();var q=class{constructor(){this.handlers=new Map}on(n,t){this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n)?.add(t)}off(n,t){let a=this.handlers.get(n);a&&(a.delete(t),a.size===0&&this.handlers.delete(n))}emit(n,...t){let a=this.handlers.get(n);if(!a)return;let l=Array.from(a);for(let c of l)try{c(...t)}catch(h){a.delete(c),n!=="error"&&setTimeout(()=>{let E=h instanceof Error?h:new Error(String(h));this.emit("error",E,String(n))},0)}}};var Ot=3e4,vt=2,Ft=300,Ct=2e3,Mt=new Set([500,502,503,504]);function Ut(e,n){return new Promise((t,a)=>{if(n?.aborted){a(n.reason);return}let l=()=>{clearTimeout(h),n?.removeEventListener("abort",c)},c=()=>{l(),a(n?.reason)},h=setTimeout(()=>{l(),t()},e);n?.addEventListener("abort",c)})}var $e=3e5,Ht=3e5,Bt=$e+Ht,Y=class extends q{constructor(t){super();this.globalHeaders={};this.apiUrl=t.apiUrl||pe,this.getAuthHeadersCallback=t.getAuthHeaders,this.session=t.session??!1,this.caller=t.caller,this.timeout=t.timeout??Ot,this.maxRetries=Math.max(0,t.maxRetries??vt),this.fetch=t.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:t.deployEndpoint||A.DEPLOYMENTS,timeout:t.timeout??$e,buildTimeout:t.timeout??Bt}}setGlobalHeaders(t){this.globalHeaders=t}async executeRequest(t,a,l,c=this.timeout){for(let h=0;;h++)try{return await this.attemptOnce(t,a,l,c)}catch(E){let m=d.fromFetchError(E,l);if(h>=this.maxRetries||!this.isRetryable(m,a))throw this.emit("error",m,t),m;this.emit("retry",m,t,h+1);let g=Math.min(Ct,Ft*2**h);try{await Ut(Math.random()*g,a.signal)}catch(f){let T=d.fromFetchError(f,l);throw this.emit("error",T,t),T}}}isRetryable(t,a){if(a.signal?.aborted||t.isType(y.Maintenance)||t.isType(y.Cancelled)||!(t.isNetworkError()||t.status!==void 0&&Mt.has(t.status)))return!1;let c=(a.method??"GET").toUpperCase();return c==="GET"||c==="HEAD"?!0:c==="PUT"||c==="DELETE"?!1:this.hasIdempotencyKey(a.headers)}hasIdempotencyKey(t){if(!t)return!1;let a=F.HEADER.toLowerCase();return Object.keys(t).some(l=>l.toLowerCase()===a)}async attemptOnce(t,a,l,c=this.timeout){let h=()=>{};try{let E=await this.mergeHeaders(a.headers),m=this.createTimeoutSignal(a.signal,c);h=m.cleanup;let g={...a,headers:E,credentials:this.session&&!E.Authorization?"include":void 0,signal:m.signal};this.emit("request",t,g);let f=await this.fetch(t,g);if(h(),!f.ok)throw await d.fromHttpResponse(f,l);return this.emit("response",this.safeClone(f),t),{data:await this.parseResponse(this.safeClone(f)),status:f.status}}catch(E){throw h(),d.fromFetchError(E,l)}}async request(t,a,l,c){let{data:h}=await this.executeRequest(`${this.apiUrl}${t}`,a,l,c);return h}async requestWithStatus(t,a,l){return this.executeRequest(`${this.apiUrl}${t}`,a,l)}async mergeHeaders(t={}){return{...this.globalHeaders,...this.caller?{[M.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...t}}createTimeoutSignal(t,a=this.timeout){let l=new AbortController,c=setTimeout(()=>l.abort(new DOMException(`Timed out after ${a}ms`,"TimeoutError")),a),h=t?()=>l.abort(t.reason):void 0;return t&&h&&(t.addEventListener("abort",h),t.aborted&&l.abort(t.reason)),{signal:l.signal,cleanup:()=>{clearTimeout(c),t&&h&&t.removeEventListener("abort",h)}}}safeClone(t){try{return t.clone()}catch{return t}}async parseResponse(t){if(!(t.headers.get("Content-Length")==="0"||t.status===204))return t.json()}};D();D();async function Ge(e,n={}){let{labels:t,via:a,password:l,ttl:c,flags:h,captcha:E}=n,m=new FormData,g=[];for(let f of e){if(typeof f.content=="string"||f.content===null||f.content===void 0)throw d.file(`Unsupported file.content type: ${f.path}`,{filePath:f.path});if(!f.md5)throw d.file(`File missing md5 checksum: ${f.path}`,{filePath:f.path});m.append(I.FILES,new File([f.content],f.path,{type:"application/octet-stream"})),g.push(f.md5)}return m.append(I.CHECKSUMS,JSON.stringify(g)),t&&t.length>0&&m.append(I.LABELS,JSON.stringify(t)),a&&m.append(I.VIA,a),l&&m.append(I.PASSWORD,l),c!==void 0&&m.append(I.TTL,String(c)),h?.build&&m.append(I.BUILD,"true"),h?.prerender&&m.append(I.PRERENDER,"true"),h?.spa&&m.append(I.SPA,"true"),h?.buildCommand&&m.append(I.BUILD_COMMAND,h.buildCommand),h?.outputDir&&m.append(I.OUTPUT_DIR,h.outputDir),E&&m.append(I.CAPTCHA,E),m}D();J();async function zt(){let e=JSON.stringify(ve,null,2),n;typeof Buffer<"u"?n=Buffer.from(e,"utf-8"):n=new Blob([e],{type:"application/json"});let{md5:t}=await W(n);return{path:P,content:n,size:e.length,md5:t}}async function Vt(e,n){let t=e.find(h=>h.path===X.INDEX_FILE||h.path===`/${X.INDEX_FILE}`);if(!t||t.size>X.MAX_INDEX_BYTES)return!1;let a;if(typeof Buffer<"u"&&Buffer.isBuffer(t.content))a=t.content.toString("utf-8");else if(typeof Blob<"u"&&t.content instanceof Blob)a=await t.content.text();else if(typeof File<"u"&&t.content instanceof File)a=await t.content.text();else return!1;let l={files:e.map(h=>h.path),index:a};return(await n.request(A.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)},"SPA check")).isSPA}async function Xe(e,n,t){if(t.spaDetect===!1||t.spa||t.build||t.prerender||e.some(a=>a.path===P))return e;try{if(await Vt(e,n)){let l=await zt();return[...e,l]}}catch{}return e}D();D();function B(e){if(e==null)return;if(e.length===0)return e;if(e.length>v.MAX_COUNT)throw d.validation(`Maximum ${v.MAX_COUNT} labels allowed`);let n=e.map((a,l)=>{if(typeof a!="string")throw d.validation(`Label at index ${l} must be a string`);let c=a.trim().toLowerCase();if(c.length<v.MIN_LENGTH)throw d.validation(`Labels must be at least ${v.MIN_LENGTH} characters long`);if(c.length>v.MAX_LENGTH)throw d.validation(`Labels must be no more than ${v.MAX_LENGTH} characters long`);if(!Ue.test(c))throw d.validation(`Labels must start and end with alphanumeric characters, with optional separators (${v.SEPARATORS}) between segments`);return c}),t=[...new Set(n)];if(t.length!==n.length)throw d.validation("Duplicate labels are not allowed");return t}async function qe(e){let n=e.find(l=>l.path===P||l.path===`/${P}`);if(!n)return;let t=n.content,a=typeof t.text=="function"?await t.text():n.content.toString("utf8");Fe(a)}var Q={"Content-Type":"application/json"},Kt="sdk";function fe(e){let n=new URLSearchParams;e?.limit!==void 0&&n.set("limit",String(e.limit)),e?.cursor!==void 0&&n.set("cursor",e.cursor);let t=n.toString();return t?`?${t}`:""}function Ye(e){let{getApi:n,processInput:t}=e;return{upload:async(a,l={})=>{if(!t)throw d.config("processInput function is not provided.");let c=n(),h=await t(a,l),E=await Xe(h,c,l);if(!E.length)throw d.business("No files to deploy");for(let w of E)if(!w.md5)throw d.file(`MD5 checksum missing for file: ${w.path}`,{filePath:w.path});ce(l.password);let m=ue(l.ttl),g=_e(l.idempotencyKey),f=B(l.labels);await qe(E);let T=He(l.buildCommand),L=Be(l.outputDir),C=l.build||l.prerender||l.spa?{build:l.build,prerender:l.prerender,spa:l.spa,buildCommand:T,outputDir:L}:void 0,ne=await Ge(E,{labels:f,via:l.via??Kt,password:l.password,ttl:m,flags:C,captcha:l.captcha});return c.request(c.deploy.endpoint,{method:"POST",body:ne,...g?{headers:{[F.HEADER]:g}}:{},signal:l.signal||null},"Deploy",l.build||l.prerender?c.deploy.buildTimeout:c.deploy.timeout)},list:async a=>n().request(`${A.DEPLOYMENTS}${fe(a)}`,{method:"GET"},"List deployments"),get:async a=>n().request(A.DEPLOYMENT(encodeURIComponent(a)),{method:"GET"},"Get deployment"),set:async(a,l)=>n().request(A.DEPLOYMENT(encodeURIComponent(a)),{method:"PATCH",headers:Q,body:JSON.stringify({labels:B(l.labels)})},"Update deployment labels"),delete:async a=>n().request(A.DEPLOYMENT(encodeURIComponent(a)),{method:"DELETE"},"Delete deployment")}}function je(e){let{getApi:n}=e;return{set:async(t,a={})=>{let l=B(a.labels),c={};a.deployment&&(c.deployment=a.deployment),l!==void 0&&(c.labels=l);let{data:h,status:E}=await n().requestWithStatus(A.DOMAIN(encodeURIComponent(t)),{method:"PUT",headers:Q,body:JSON.stringify(c)},"Set domain");return{...h,isCreate:E===201}},list:async t=>n().request(`${A.DOMAINS}${fe(t)}`,{method:"GET"},"List domains"),get:async t=>n().request(A.DOMAIN(encodeURIComponent(t)),{method:"GET"},"Get domain"),delete:async t=>n().request(A.DOMAIN(encodeURIComponent(t)),{method:"DELETE"},"Delete domain"),verify:async t=>n().request(A.DOMAIN_VERIFY(encodeURIComponent(t)),{method:"POST"},"Verify domain"),validate:async t=>n().request(A.DOMAINS_VALIDATE,{method:"POST",headers:Q,body:JSON.stringify({domain:t})},"Validate domain"),dns:async t=>n().request(A.DOMAIN_DNS(encodeURIComponent(t)),{method:"GET"},"Get domain DNS"),records:async t=>n().request(A.DOMAIN_RECORDS(encodeURIComponent(t)),{method:"GET"},"Get domain records"),share:async t=>n().request(A.DOMAIN_SHARE(encodeURIComponent(t)),{method:"GET"},"Get domain share")}}function We(e){let{getApi:n}=e;return{get:async()=>n().request(A.ACCOUNT,{method:"GET"},"Get account")}}function Je(e){let{getApi:n}=e;return{create:async(t={})=>{let a=ue(t.ttl),l=B(t.labels),c={};return a!==void 0&&(c.ttl=a),l!==void 0&&(c.labels=l),n().request(A.TOKENS,{method:"POST",headers:Q,body:JSON.stringify(c)},"Create token")},list:async t=>n().request(`${A.TOKENS}${fe(t)}`,{method:"GET"},"List tokens"),get:async t=>n().request(A.TOKEN(encodeURIComponent(t)),{method:"GET"},"Get token"),delete:async t=>n().request(A.TOKEN(encodeURIComponent(t)),{method:"DELETE"},"Delete token")}}var Z=class{constructor(n={}){this.initPromise=null;this.platformLimits=null;this.credential=null;if(n={...n,apiUrl:n.apiUrl||void 0,token:n.token||void 0,caller:n.caller||void 0},this.clientOptions=n,n.caller!==void 0&&Ce(n.caller),n.token&&n.session)throw d.config("Provide either `token` or `session`, not both.");typeof n.token=="string"?(le(n.token),this.credential=n.token):n.token&&(this.credential=n.token),this.http=new Y({...n,getAuthHeaders:()=>this.getAuthHeaders()});let t={getApi:()=>this.http};this.deployments=Ye({...t,processInput:async(a,l)=>(await this.ensureInitialized(),this.processInput(a,l))}),this.domains=je(t),this.account=We(t),this.tokens=Je(t)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.request(A.LIMITS,{method:"GET"},"Get limits")}catch(n){throw this.initPromise=null,n}}async ping(){return this.http.request(A.PING,{method:"GET"},"Ping")}async deploy(n,t){return this.deployments.upload(n,t)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(n,t){this.http.on(n,t)}off(n,t){this.http.off(n,t)}setHeaders(n){this.http.setGlobalHeaders(n)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(n){if(this.clientOptions.session)throw d.config("Provide either `token` or `session`, not both.");if(typeof n=="string"){if(!n)throw d.business("Invalid token provided. Token must be a non-empty string.");le(n),this.credential=n;return}if(typeof n!="function")throw d.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=n}async getAuthHeaders(){if(this.credential===null)return{};let n=typeof this.credential=="function"?await this.credential():this.credential;if(!n)throw d.authentication("Token provider returned no token.");if(typeof n!="string")throw d.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${n}`}}};D();D();me();ye();Te();Ae();J();Se();function _r(e,n,t,a=!0){let l=e===1?n:t;return a?`${e} ${l}`:l}De();var Re=class extends Z{async deploy(n,t){return super.deploy(n,t)}async processInput(n,t){if(!Array.isArray(n)||!n.every(l=>l instanceof File))throw d.business("Invalid input type for browser environment. Expected File[].");if(n.length===0)throw d.business("No files to deploy.");let{processFilesForBrowser:a}=await Promise.resolve().then(()=>(De(),ut));return a(n,t,this.platformLimits??void 0)}},Qr=Re;export{mn as ACCOUNT_HEADER,we as API_KEY,A as API_PATHS,fn as AUTH_BASE_PATH,an as AccountPlan,Y as ApiHttp,ie as AuthMethod,U as BUILD_SETTINGS,M as CALLER,pe as DEFAULT_API,P as DEPLOYMENT_CONFIG_FILENAME,I as DEPLOY_FIELDS,pn as DEPLOY_FILE_GRAMMAR,xe as DEPLOY_TOKEN,tn as DeploymentStatus,gt as DeploymentVia,nn as DomainStatus,rn as DomainVerification,y as ErrorType,R as FILE_VALIDATION_STATUS,R as FileValidationStatus,F as IDEMPOTENCY_KEY_CONSTRAINTS,Qt as JUNK_DIRECTORIES,v as LABEL_CONSTRAINTS,Ue as LABEL_PATTERN,Sn as MY_API_KEY_URL,Oe as OAUTH_TOKEN,yn as OAuthScope,V as PASSWORD_CONSTRAINTS,Dn as PUBLIC_DEPLOYMENT_TTL_SECONDS,on as SETUP_TROUBLESHOOTING_ANCHOR,Tn as SHIP_ENV,An as SHIP_VIA_ENV,dn as SIGN_IN_RETURN_PARAM,X as SPA_CHECK_CONSTRAINTS,ve as SPA_DEFAULT_CONFIG,Re as Ship,d as ShipError,z as TTL_CONSTRAINTS,O as TokenKind,_t as UNBUILT_PROJECT_MARKERS,It as UNSAFE_FILENAME_CHARS,bn as USER_VISIBLE_EVENTS,cn as WEB_FILE_ACCEPT,lr as __setTestEnvironment,yr as allValidFilesReady,Fe as assertShipJsonSyntax,W as calculateMD5,Lt as classifyToken,We as createAccountResource,Ye as createDeploymentResource,je as createDomainResource,Je as createTokenResource,Qr as default,wn as deserializeLabels,_n as extractSubdomain,rt as filterJunk,xt as formatDuration,H as formatFileSize,Rn as formatTimeRemaining,Ln as generateDeploymentUrl,Nn as generateDomainUrl,et as getENV,jt as getValidFiles,K as hasUnbuiltMarker,Pe as hasUnsafeChars,Ne as isBlockedExtension,In as isCustomDomain,gn as isDeployment,Me as isPlatformDomain,Le as isShipError,sn as normalizeVia,Ze as optimizeDeployPaths,ln as personName,un as personShortName,_r as pluralize,lt as processFilesForBrowser,hn as readBearerValue,Pn as serializeLabels,Nt as validateApiKey,En as validateApiUrl,He as validateBuildCommand,Ce as validateCaller,ot as validateDeployFile,it as validateDeployPath,Pt as validateDeployToken,Ee as validateFileName,hr as validateFiles,_e as validateIdempotencyKey,wt as validateOAuthToken,Be as validateOutputDir,ce as validatePassword,le as validateToken,ue as validateTtl};
1
+ var ht=Object.create;var H=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var Et=Object.getPrototypeOf,Tt=Object.prototype.hasOwnProperty;var At=(e,n,t)=>n in e?H(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var _=(e,n)=>()=>(e&&(n=e(e=0)),n);var _e=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),St=(e,n)=>{for(var t in n)H(e,t,{get:n[t],enumerable:!0})},Dt=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of gt(n))!Tt.call(e,l)&&l!==t&&H(e,l,{get:()=>n[l],enumerable:!(s=yt(n,l))||s.enumerable});return e};var G=(e,n,t)=>(t=e!=null?ht(Et(e)):{},Dt(n||!e||!e.__esModule?H(t,"default",{value:e,enumerable:!0}):t,e));var k=(e,n,t)=>At(e,typeof n!="symbol"?n+"":n,t);function Tn(e){if(!e||typeof e!="string")return;let n=e.trim().toLowerCase();return Object.values(Rt).includes(n)?n:void 0}function Oe(e){if(e==null)return;if(typeof e!="string")throw f.validation("Idempotency key must be a string.");let n=e.trim();if(!n)throw f.validation("Idempotency key must not be empty.");if(n.length>C.MAX_LENGTH)throw f.validation(`Idempotency key must be at most ${C.MAX_LENGTH} characters.`);return n}function Dn(e){return e.name?.trim()||e.email}function Rn(e){return e.name?.trim().split(" ")[0]||e.email}function Nt(e){let n=e.code;return n==="ERR_INVALID_URL"?!1:typeof n=="string"?!0:e instanceof TypeError?!/\burl\b/i.test(e.message):!1}function xe(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function Lt(e){let n=e.replace(/\\/g,"/").split("/").pop()??"",t=n.lastIndexOf(".");return t<=0||t===n.length-1?null:n.slice(t+1).toLowerCase()}function Pe(e,n){let t=Lt(e);return t===null?!1:Array.isArray(n)?n.includes(t):n.has(t)}function ve(e){return Ot.test(e)}function K(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(t=>xt.has(t))}function Pt(e){return e.startsWith(Ce.PREFIX)?P.API_KEY:e.startsWith(Fe.PREFIX)?P.DEPLOY_TOKEN:e.startsWith(Me.PREFIX)?P.OAUTH:P.OPAQUE}function wn(e){return e.slice(0,se.length).toLowerCase()!==se?null:e.slice(se.length)||null}function $e(e){let n=e.charCodeAt(0)===65279?e.slice(1):e,t;try{t=JSON.parse(n)}catch(s){throw f.config(`invalid JSON format in config: ${s.message}`,{filePath:w})}if(t===null||typeof t!="object"||Array.isArray(t))throw f.config(`${w} must contain a JSON object`,{filePath:w})}function le(e,n,t){if(!e.startsWith(n.PREFIX))throw f.validation(`${t} must start with "${n.PREFIX}"`);if(e.length!==n.TOTAL_LENGTH)throw f.validation(`${t} must be ${n.TOTAL_LENGTH} characters total (${n.PREFIX} + ${n.HEX_LENGTH} hex chars)`);let s=e.slice(n.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${n.HEX_LENGTH}}$`,"i").test(s))throw f.validation(`${t} must contain ${n.HEX_LENGTH} hexadecimal characters after "${n.PREFIX}" prefix`)}function vt(e){le(e,Ce,"API key")}function Ct(e){le(e,Fe,"Deploy token")}function Ft(e){le(e,Me,"OAuth access token")}function ue(e){switch(Pt(e)){case P.API_KEY:vt(e);return;case P.DEPLOY_TOKEN:Ct(e);return;case P.OAUTH:Ft(e);return;case P.OPAQUE:if(!e)throw f.validation("Token must be a non-empty string")}}function Be(e){if(!e||e.length>M.MAX_LENGTH||!M.PATTERN.test(e))throw f.validation(`Caller must be 1-${M.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function xn(e){try{let n=new URL(e);if(!["http:","https:"].includes(n.protocol))throw f.validation("API URL must use http:// or https:// protocol");if(n.pathname!=="/"&&n.pathname!=="")throw f.validation("API URL must not contain a path");if(n.search||n.hash)throw f.validation("API URL must not contain query parameters or fragments")}catch(n){throw xe(n)?n:f.validation("API URL must be a valid URL")}}function Pn(e){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(e)}function ce(e){if(e!=null){if(typeof e!="number"||!Number.isFinite(e))throw f.validation("TTL must be a number of seconds");if(!Number.isInteger(e))throw f.validation("TTL must be a whole number of seconds");if(e<V.MIN_SECONDS||e>V.MAX_SECONDS)throw f.validation(`TTL must be between ${V.MIN_SECONDS} and ${V.MAX_SECONDS} seconds`);return e}}function Bt(e){let n=e?`/${e}`:"",t=s=>`${n}${s}`;return{dashboard:()=>n||"/",newSite:()=>t("/new"),deployments:Object.assign(()=>t("/deployments"),{upload:()=>t("/deployments/upload")}),domains:Object.assign(()=>t("/domains"),{connect:s=>t(`/domains/${s}/connect`),deployment:s=>t(`/domains/${s}/deployment`)}),settings:s=>t(s?`/settings#${s}`:"/settings"),settingsAfterBilling:()=>t(`/settings?${Ne("portal")}`),upgrade:s=>t(s?`/upgrade/${s}`:"/upgrade"),success:()=>t("/success"),successAfterCheckout:()=>t(`/success?${Ne("checkout")}`),apiKey:()=>t("/api-key")}}function Cn(e){let n=new URLSearchParams(e);for(let[t,[s,l]]of Object.entries(He))if(n.get(s)===l)return t;return null}function q(e){let n=e.split(/[?#]/)[0].toLowerCase(),[t="",s=""]=n.split("/").filter(Boolean);return Ht(t)?{kind:"door",door:t}:t===$t?{kind:"admin"}:t===""||we(t)?{kind:"account",account:null,section:t===""?null:t}:{kind:"account",account:t,section:we(s)?s:null}}function Fn(e){let n=q(e);return n.kind==="account"?n.account:null}function Mn(e){return Gt(e)?"claim":kt(e)?"invite":Vt(e)?"upgrade":null}function zt(e){let n=Math.round(e/60);if(!(n>=1))return"less than a minute";if(n<120)return ae(n,"minute");let t=Math.round(e/3600);return t<48?ae(t,"hour"):ae(Math.round(e/86400),"day")}function Gn(e,n=Date.now()/1e3){let t=e-n;return t>0?zt(t):null}function ae(e,n){return`${e} ${n}${e===1?"":"s"}`}function $(e,n=1){if(e===0)return"0 Bytes";let t=1024,s=["Bytes","KB","MB","GB"],l=Math.floor(Math.log(e)/Math.log(t));return`${Number.parseFloat((e/t**l).toFixed(n))} ${s[l]}`}function Ge(e,n){return e.endsWith(`.${n}`)}function Vn(e,n){return!Ge(e,n)}function zn(e,n){return Ge(e,n)?e.slice(0,-(n.length+1)):null}function Kn(e){return`https://${e}`}function Xn(e){return`https://${e}`}function qn(e){return!e||e.length===0?null:JSON.stringify(e)}function jn(e){if(!e)return[];try{let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function Ve(e){if(e==null||e==="")return;if(typeof e!="string")throw f.validation("Build command must be a string");let n=e.trim();if(n.length===0||n.length>U.COMMAND_MAX_LENGTH)throw f.validation(`Build command must be between 1 and ${U.COMMAND_MAX_LENGTH} characters`);if(/[\x00-\x1f\x7f]/.test(n))throw f.validation("Build command must be a single line");return n}function ze(e){if(e==null||e==="")return;if(typeof e!="string")throw f.validation("Output folder must be a string");let n=e.trim().replace(/\/+$/,"");if(n.length===0||n.length>U.OUTPUT_DIR_MAX_LENGTH)throw f.validation(`Output folder must be between 1 and ${U.OUTPUT_DIR_MAX_LENGTH} characters`);if(!U.OUTPUT_DIR_PATTERN.test(n)||n.split("/").some(t=>t===".."||t==="."))throw f.validation("Output folder must be a relative path inside the project, like dist or dist/site");return n}function de(e){if(e==null)return;if(typeof e!="string")throw f.validation("Password must be a string");let n=e.trim();if(n.length<z.MIN_LENGTH||n.length>z.MAX_LENGTH)throw f.validation(`Password must be between ${z.MIN_LENGTH} and ${z.MAX_LENGTH} characters`);return n}var hn,Rt,yn,gn,En,C,An,Sn,A,I,bn,y,bt,ie,It,_t,f,wt,In,Ot,xt,_n,Nn,oe,Ce,Fe,Me,M,Ln,P,se,On,w,Ue,X,V,Mt,Ut,$t,He,Ne,Le,vn,Ht,we,Gt,kt,Vt,pe,Un,$n,Bn,Hn,kn,R,v,ke,U,z,D=_(()=>{"use strict";hn={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},Rt={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc",CLD:"cld",CRS:"crs",GMN:"gmn",API:"api"},yn={LIVE:"live",UNLINKED:"unlinked",UNVERIFIED:"unverified",PAUSED:"paused"},gn={PENDING:"pending",PARTIAL:"partial",VERIFIED:"verified"},En="troubleshooting",C={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};An={FREE:"free",PRO:"pro",TEAM:"team",SCALE:"scale",SPONSORED:"sponsored"},Sn={PAUSED:"paused",UNKNOWN:"unknown"};A={DEPLOYMENTS:"/deployments",DEPLOYMENT:e=>`/deployments/${e}`,DEPLOYMENT_CONFIG:e=>`/deployments/${e}/config`,DOMAINS:"/domains",DOMAIN:e=>`/domains/${e}`,DOMAIN_VERIFY:e=>`/domains/${e}/verify`,DOMAIN_DNS:e=>`/domains/${e}/dns`,DOMAIN_RECORDS:e=>`/domains/${e}/records`,DOMAIN_SHARE:e=>`/domains/${e}/share`,DOMAIN_PROPAGATION:e=>`/domains/${e}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:e=>`/tokens/${e}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PLANS:"/plans",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},I={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",TTL:"ttl",BUILD:"build",PRERENDER:"prerender",SPA:"spa",BUILD_COMMAND:"buildCommand",OUTPUT_DIR:"outputDir",CAPTCHA:"captcha"},bn={PATH:"path",CONTENT:"content",ENCODING:"encoding",DEFAULT_ENCODING:"utf-8",ENCODINGS:["utf-8","base64"]},y={Validation:"validation_failed",NotFound:"not_found",Forbidden:"forbidden",RateLimit:"rate_limit_exceeded",Authentication:"authentication_failed",Business:"business_logic_error",Api:"internal_server_error",Maintenance:"maintenance",Build:"build_failed",Network:"network_error",Timeout:"timeout_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},bt=new Set([y.Network,y.Timeout,y.Cancelled,y.File,y.Config]),ie={client:new Set([y.Build,y.Business,y.Cancelled,y.Config,y.File,y.Forbidden,y.NotFound,y.RateLimit,y.Validation]),network:new Set([y.Network,y.Timeout]),auth:new Set([y.Authentication])},It=new Set(Object.values(y).filter(e=>!bt.has(e))),_t=200;f=class e extends Error{constructor(t,s,l,p){super(s);k(this,"type");k(this,"status");k(this,"details");this.type=t,this.status=l,this.details=p,this.name="ShipError"}toResponse(){let t=this.details,s=this.type===y.Authentication&&t?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:s}}static async fromHttpResponse(t,s){let l,p,h;try{if(t.headers.get("content-type")?.includes("application/json")){let d=await t.json();if(d&&typeof d=="object"){let T=d;typeof T.message=="string"?l=T.message:typeof T.error=="string"&&(l=T.error),p=T.details,typeof T.error=="string"&&It.has(T.error)&&(h=T.error)}}else{let d=(await t.text()).trim();d&&!d.startsWith("<")&&d.length<=_t&&(l=d)}}catch{}let g=t.headers.get("retry-after");if(g!==null){let E=g.trim(),d=/^\d+$/.test(E)?Number(E):Math.ceil((Date.parse(E)-Date.now())/1e3);if(Number.isFinite(d)&&d>=0){let T=p&&typeof p=="object"?p:{};T.retryAfter===void 0&&(p={...T,retryAfter:d})}}l=l||`${s||"Request"} failed with status ${t.status}`;let m=h??(t.status===401?y.Authentication:t.status===403?y.Forbidden:t.status===429?y.RateLimit:y.Api);return new e(m,l,t.status,p)}static fromFetchError(t,s){if(xe(t))return t;let l=s||"Request",p=t?.name;return p==="AbortError"?e.cancelled(`${l} was cancelled`):p==="TimeoutError"?e.timeout(`${l} timed out`,{cause:t}):t instanceof Error?Nt(t)?e.network(`${l} failed: ${t.message}`,{cause:t}):new e(y.Api,`${l} failed: ${t.message}`):new e(y.Api,`${l} failed: Unknown error`)}static validation(t,s){return new e(y.Validation,t,400,s)}static notFound(t,s){let l=s?`${t} ${s} not found`:`${t} not found`;return new e(y.NotFound,l,404)}static forbidden(t,s){return new e(y.Forbidden,t,403,s)}static rateLimit(t="Too many requests",s){return new e(y.RateLimit,t,429,s)}static authentication(t="Authentication required",s){return new e(y.Authentication,t,401,s)}static business(t,s=400,l){return new e(y.Business,t,s,l)}static network(t,s){return new e(y.Network,t,void 0,s)}static timeout(t,s){return new e(y.Timeout,t,void 0,s)}static cancelled(t,s){return new e(y.Cancelled,t,void 0,s)}static file(t,s){return new e(y.File,t,void 0,s)}static config(t,s){return new e(y.Config,t,void 0,s)}static api(t,s=500,l){return new e(y.Api,t,s,l)}static maintenance(t,s){return new e(y.Maintenance,t,503,s)}static build(t,s){return new e(y.Build,t,422,s)}isClientError(){return ie.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return ie.network.has(this.type)}isAuthError(){return ie.auth.has(this.type)}isType(t){return this.type===t}};wt=["html","htm","xhtml","xml","txt","md","markdown","pdf","csv","json","jsonc","webmanifest","map","toml","yaml","yml","rss","atom","css","scss","sass","less","js","mjs","cjs","jsx","ts","tsx","wasm","vue","svelte","png","jpg","jpeg","gif","webp","avif","svg","ico","bmp","tif","tiff","heic","heif","woff","woff2","ttf","otf","eot","mp3","wav","ogg","oga","opus","m4a","aac","flac","weba","mp4","webm","ogv","mov","m4v","avi","glb","gltf","usdz","vtt","srt","zip"],In=wt.map(e=>`.${e}`).join(","),Ot=/[\x00-\x1f\x7f#?%\\<>"]/;xt=new Set(["node_modules","package.json"]);_n="/auth",Nn="signing-in",oe={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",SYSTEM:"system"},Ce={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},Fe={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},Me={PREFIX:"oauth-",HEX_LENGTH:32,TOTAL_LENGTH:38},M={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},Ln="X-Account",P={API_KEY:oe.API_KEY,DEPLOY_TOKEN:oe.TOKEN,OAUTH:oe.OAUTH,OPAQUE:"opaque"};se="bearer ";On={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},w="ship.json",Ue={rewrites:[{source:"/(.*)",destination:"/index.html"}]},X={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};V={MIN_SECONDS:1,MAX_SECONDS:365*24*60*60};Mt={new:{owner:!1},deployments:{owner:!1},domains:{owner:!1},settings:{owner:!1},upgrade:{owner:!0},success:{owner:!1},"api-key":{owner:!0}},Ut=["login","register","logout","invitations","claim","consent"],$t="admin",He={checkout:["upgrading","true"],portal:["billing","returned"]},Ne=e=>He[e].join("="),Le=(e,n)=>n?`${e}?next=${encodeURIComponent(n)}`:e;vn={login:e=>Le("/login",e),register:e=>Le("/register",e),logout:()=>"/logout",invitation:e=>`/invitations/${e}`,claim:e=>`/claim/${e}`,consent:()=>"/consent"};Ht=e=>Ut.includes(e),we=e=>Object.hasOwn(Mt,e);Gt=e=>{let n=q(e);return n.kind==="door"&&n.door==="claim"},kt=e=>{let n=q(e);return n.kind==="door"&&n.door==="invitations"},Vt=e=>{let n=q(e);return n.kind==="account"&&n.section==="upgrade"};pe="https://api.shipstatic.com",Un={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},$n="SHIP_VIA",Bn=`https://my.shipstatic.com${Bt().apiKey()}`,Hn=4320*60;kn=["account.create","account.update","account.delete","account.key.generate","account.plan.transition","deployment.create","deployment.update","deployment.delete","deployment.claim","domain.create","domain.update","domain.delete","domain.verify","token.create","token.consume","token.delete","member.join","member.leave","consent.grant"],R={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};v={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},ke=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;U={COMMAND_MAX_LENGTH:200,OUTPUT_DIR_MAX_LENGTH:100,OUTPUT_DIR_PATTERN:/^[A-Za-z0-9._-]+(\/[A-Za-z0-9._-]+)*$/};z={MIN_LENGTH:6,MAX_LENGTH:128}});var Ye=_e((qe,je)=>{"use strict";(function(e){if(typeof qe=="object")je.exports=e();else if(typeof define=="function"&&define.amd)define(e);else{var n;try{n=window}catch{n=self}n.SparkMD5=e()}})(function(e){"use strict";var n=function(c,u){return c+u&4294967295},t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function s(c,u,i,r,a,o){return u=n(n(u,c),n(r,o)),n(u<<a|u>>>32-a,i)}function l(c,u){var i=c[0],r=c[1],a=c[2],o=c[3];i+=(r&a|~r&o)+u[0]-680876936|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&a)+u[1]-389564586|0,o=(o<<12|o>>>20)+i|0,a+=(o&i|~o&r)+u[2]+606105819|0,a=(a<<17|a>>>15)+o|0,r+=(a&o|~a&i)+u[3]-1044525330|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&o)+u[4]-176418897|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&a)+u[5]+1200080426|0,o=(o<<12|o>>>20)+i|0,a+=(o&i|~o&r)+u[6]-1473231341|0,a=(a<<17|a>>>15)+o|0,r+=(a&o|~a&i)+u[7]-45705983|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&o)+u[8]+1770035416|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&a)+u[9]-1958414417|0,o=(o<<12|o>>>20)+i|0,a+=(o&i|~o&r)+u[10]-42063|0,a=(a<<17|a>>>15)+o|0,r+=(a&o|~a&i)+u[11]-1990404162|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&o)+u[12]+1804603682|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&a)+u[13]-40341101|0,o=(o<<12|o>>>20)+i|0,a+=(o&i|~o&r)+u[14]-1502002290|0,a=(a<<17|a>>>15)+o|0,r+=(a&o|~a&i)+u[15]+1236535329|0,r=(r<<22|r>>>10)+a|0,i+=(r&o|a&~o)+u[1]-165796510|0,i=(i<<5|i>>>27)+r|0,o+=(i&a|r&~a)+u[6]-1069501632|0,o=(o<<9|o>>>23)+i|0,a+=(o&r|i&~r)+u[11]+643717713|0,a=(a<<14|a>>>18)+o|0,r+=(a&i|o&~i)+u[0]-373897302|0,r=(r<<20|r>>>12)+a|0,i+=(r&o|a&~o)+u[5]-701558691|0,i=(i<<5|i>>>27)+r|0,o+=(i&a|r&~a)+u[10]+38016083|0,o=(o<<9|o>>>23)+i|0,a+=(o&r|i&~r)+u[15]-660478335|0,a=(a<<14|a>>>18)+o|0,r+=(a&i|o&~i)+u[4]-405537848|0,r=(r<<20|r>>>12)+a|0,i+=(r&o|a&~o)+u[9]+568446438|0,i=(i<<5|i>>>27)+r|0,o+=(i&a|r&~a)+u[14]-1019803690|0,o=(o<<9|o>>>23)+i|0,a+=(o&r|i&~r)+u[3]-187363961|0,a=(a<<14|a>>>18)+o|0,r+=(a&i|o&~i)+u[8]+1163531501|0,r=(r<<20|r>>>12)+a|0,i+=(r&o|a&~o)+u[13]-1444681467|0,i=(i<<5|i>>>27)+r|0,o+=(i&a|r&~a)+u[2]-51403784|0,o=(o<<9|o>>>23)+i|0,a+=(o&r|i&~r)+u[7]+1735328473|0,a=(a<<14|a>>>18)+o|0,r+=(a&i|o&~i)+u[12]-1926607734|0,r=(r<<20|r>>>12)+a|0,i+=(r^a^o)+u[5]-378558|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^a)+u[8]-2022574463|0,o=(o<<11|o>>>21)+i|0,a+=(o^i^r)+u[11]+1839030562|0,a=(a<<16|a>>>16)+o|0,r+=(a^o^i)+u[14]-35309556|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^o)+u[1]-1530992060|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^a)+u[4]+1272893353|0,o=(o<<11|o>>>21)+i|0,a+=(o^i^r)+u[7]-155497632|0,a=(a<<16|a>>>16)+o|0,r+=(a^o^i)+u[10]-1094730640|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^o)+u[13]+681279174|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^a)+u[0]-358537222|0,o=(o<<11|o>>>21)+i|0,a+=(o^i^r)+u[3]-722521979|0,a=(a<<16|a>>>16)+o|0,r+=(a^o^i)+u[6]+76029189|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^o)+u[9]-640364487|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^a)+u[12]-421815835|0,o=(o<<11|o>>>21)+i|0,a+=(o^i^r)+u[15]+530742520|0,a=(a<<16|a>>>16)+o|0,r+=(a^o^i)+u[2]-995338651|0,r=(r<<23|r>>>9)+a|0,i+=(a^(r|~o))+u[0]-198630844|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~a))+u[7]+1126891415|0,o=(o<<10|o>>>22)+i|0,a+=(i^(o|~r))+u[14]-1416354905|0,a=(a<<15|a>>>17)+o|0,r+=(o^(a|~i))+u[5]-57434055|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~o))+u[12]+1700485571|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~a))+u[3]-1894986606|0,o=(o<<10|o>>>22)+i|0,a+=(i^(o|~r))+u[10]-1051523|0,a=(a<<15|a>>>17)+o|0,r+=(o^(a|~i))+u[1]-2054922799|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~o))+u[8]+1873313359|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~a))+u[15]-30611744|0,o=(o<<10|o>>>22)+i|0,a+=(i^(o|~r))+u[6]-1560198380|0,a=(a<<15|a>>>17)+o|0,r+=(o^(a|~i))+u[13]+1309151649|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~o))+u[4]-145523070|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~a))+u[11]-1120210379|0,o=(o<<10|o>>>22)+i|0,a+=(i^(o|~r))+u[2]+718787259|0,a=(a<<15|a>>>17)+o|0,r+=(o^(a|~i))+u[9]-343485551|0,r=(r<<21|r>>>11)+a|0,c[0]=i+c[0]|0,c[1]=r+c[1]|0,c[2]=a+c[2]|0,c[3]=o+c[3]|0}function p(c){var u=[],i;for(i=0;i<64;i+=4)u[i>>2]=c.charCodeAt(i)+(c.charCodeAt(i+1)<<8)+(c.charCodeAt(i+2)<<16)+(c.charCodeAt(i+3)<<24);return u}function h(c){var u=[],i;for(i=0;i<64;i+=4)u[i>>2]=c[i]+(c[i+1]<<8)+(c[i+2]<<16)+(c[i+3]<<24);return u}function g(c){var u=c.length,i=[1732584193,-271733879,-1732584194,271733878],r,a,o,b,L,x;for(r=64;r<=u;r+=64)l(i,p(c.substring(r-64,r)));for(c=c.substring(r-64),a=c.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<a;r+=1)o[r>>2]|=c.charCodeAt(r)<<(r%4<<3);if(o[r>>2]|=128<<(r%4<<3),r>55)for(l(i,o),r=0;r<16;r+=1)o[r]=0;return b=u*8,b=b.toString(16).match(/(.*?)(.{0,8})$/),L=parseInt(b[2],16),x=parseInt(b[1],16)||0,o[14]=L,o[15]=x,l(i,o),i}function m(c){var u=c.length,i=[1732584193,-271733879,-1732584194,271733878],r,a,o,b,L,x;for(r=64;r<=u;r+=64)l(i,h(c.subarray(r-64,r)));for(c=r-64<u?c.subarray(r-64):new Uint8Array(0),a=c.length,o=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<a;r+=1)o[r>>2]|=c[r]<<(r%4<<3);if(o[r>>2]|=128<<(r%4<<3),r>55)for(l(i,o),r=0;r<16;r+=1)o[r]=0;return b=u*8,b=b.toString(16).match(/(.*?)(.{0,8})$/),L=parseInt(b[2],16),x=parseInt(b[1],16)||0,o[14]=L,o[15]=x,l(i,o),i}function E(c){var u="",i;for(i=0;i<4;i+=1)u+=t[c>>i*8+4&15]+t[c>>i*8&15];return u}function d(c){var u;for(u=0;u<c.length;u+=1)c[u]=E(c[u]);return c.join("")}d(g("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(n=function(c,u){var i=(c&65535)+(u&65535),r=(c>>16)+(u>>16)+(i>>16);return r<<16|i&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function c(u,i){return u=u|0||0,u<0?Math.max(u+i,0):Math.min(u,i)}ArrayBuffer.prototype.slice=function(u,i){var r=this.byteLength,a=c(u,r),o=r,b,L,x,Ie;return i!==e&&(o=c(i,r)),a>o?new ArrayBuffer(0):(b=o-a,L=new ArrayBuffer(b),x=new Uint8Array(L),Ie=new Uint8Array(this,a,b),x.set(Ie),L)}})();function T(c){return/[\u0080-\uFFFF]/.test(c)&&(c=unescape(encodeURIComponent(c))),c}function N(c,u){var i=c.length,r=new ArrayBuffer(i),a=new Uint8Array(r),o;for(o=0;o<i;o+=1)a[o]=c.charCodeAt(o);return u?a:r}function F(c){return String.fromCharCode.apply(null,new Uint8Array(c))}function re(c,u,i){var r=new Uint8Array(c.byteLength+u.byteLength);return r.set(new Uint8Array(c)),r.set(new Uint8Array(u),c.byteLength),i?r:r.buffer}function O(c){var u=[],i=c.length,r;for(r=0;r<i-1;r+=2)u.push(parseInt(c.substr(r,2),16));return String.fromCharCode.apply(String,u)}function S(){this.reset()}return S.prototype.append=function(c){return this.appendBinary(T(c)),this},S.prototype.appendBinary=function(c){this._buff+=c,this._length+=c.length;var u=this._buff.length,i;for(i=64;i<=u;i+=64)l(this._hash,p(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},S.prototype.end=function(c){var u=this._buff,i=u.length,r,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o;for(r=0;r<i;r+=1)a[r>>2]|=u.charCodeAt(r)<<(r%4<<3);return this._finish(a,i),o=d(this._hash),c&&(o=O(o)),this.reset(),o},S.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},S.prototype.setState=function(c){return this._buff=c.buff,this._length=c.length,this._hash=c.hash,this},S.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},S.prototype._finish=function(c,u){var i=u,r,a,o;if(c[i>>2]|=128<<(i%4<<3),i>55)for(l(this._hash,c),i=0;i<16;i+=1)c[i]=0;r=this._length*8,r=r.toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(r[2],16),o=parseInt(r[1],16)||0,c[14]=a,c[15]=o,l(this._hash,c)},S.hash=function(c,u){return S.hashBinary(T(c),u)},S.hashBinary=function(c,u){var i=g(c),r=d(i);return u?O(r):r},S.ArrayBuffer=function(){this.reset()},S.ArrayBuffer.prototype.append=function(c){var u=re(this._buff.buffer,c,!0),i=u.length,r;for(this._length+=c.byteLength,r=64;r<=i;r+=64)l(this._hash,h(u.subarray(r-64,r)));return this._buff=r-64<i?new Uint8Array(u.buffer.slice(r-64)):new Uint8Array(0),this},S.ArrayBuffer.prototype.end=function(c){var u=this._buff,i=u.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,o;for(a=0;a<i;a+=1)r[a>>2]|=u[a]<<(a%4<<3);return this._finish(r,i),o=d(this._hash),c&&(o=O(o)),this.reset(),o},S.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},S.ArrayBuffer.prototype.getState=function(){var c=S.prototype.getState.call(this);return c.buff=F(c.buff),c},S.ArrayBuffer.prototype.setState=function(c){return c.buff=N(c.buff,!0),S.prototype.setState.call(this,c)},S.ArrayBuffer.prototype.destroy=S.prototype.destroy,S.ArrayBuffer.prototype._finish=S.prototype._finish,S.ArrayBuffer.hash=function(c,u){var i=m(new Uint8Array(c)),r=d(i);return u?O(r):r},S})});var W=_e((rr,We)=>{"use strict";We.exports={}});async function Zt(e){let n=(await Promise.resolve().then(()=>G(Ye(),1))).default,t=new n.ArrayBuffer,s=2097152;for(let l=0;l<e.size;l+=s){let p=Math.min(l+s,e.size);t.append(await e.slice(l,p).arrayBuffer())}return{md5:t.end()}}async function en(e){let{createHash:n}=await Promise.resolve().then(()=>G(W(),1)),t=n("md5");return t.update(e),{md5:t.digest("hex")}}async function tn(e){let{createHash:n}=await Promise.resolve().then(()=>G(W(),1)),{createReadStream:t}=await Promise.resolve().then(()=>G(W(),1));return new Promise((s,l)=>{let p=n("md5"),h=t(e);h.on("error",g=>l(f.file(`Failed to read file for MD5: ${g.message}`,{filePath:e}))),h.on("data",g=>p.update(g)),h.on("end",()=>s({md5:p.digest("hex")}))})}async function J(e){if(e instanceof Blob)return Zt(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return en(e);if(typeof e=="string")return tn(e);throw f.business("Invalid input for MD5 calculation")}var Q=_(()=>{"use strict";D()});function te(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var rt=_(()=>{"use strict"});function it(e,n={}){if(n.flatten===!1)return e.map(s=>({path:te(s),name:me(s)}));let t=sn(e);return e.map(s=>{let l=te(s);if(t){let p=t.endsWith("/")?t:`${t}/`;l.startsWith(p)&&(l=l.substring(p.length))}return l||(l=me(s)),{path:l,name:me(s)}})}function sn(e){if(!e.length)return"";let t=e.map(p=>te(p)).map(p=>p.split("/")),s=[],l=Math.min(...t.map(p=>p.length));for(let p=0;p<l-1;p++){let h=t[0][p];if(t.every(g=>g[p]===h))s.push(h);else break}return s.join("/")}function me(e){return e.split(/[/\\]/).pop()||e}var he=_(()=>{"use strict";rt()});function _r(e){ye=e}function an(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function ot(){return ye||an()}var ye,ge=_(()=>{"use strict";ye=null});function ne(e,n){return ln.find(t=>t.broken(e,n))}var ln,Te=_(()=>{"use strict";D();Ae();ln=[{name:"name",broken:({path:e})=>!Ee(e).valid,sentence:({path:e})=>Ee(e).reason??"Invalid file name"},{name:"extension",broken:({path:e},n)=>Pe(e,n.blockedExtensions??[]),sentence:({path:e})=>`File extension not allowed: "${e}"`},{name:"fileSize",broken:({size:e},n)=>e>n.maxFileSize,sentence:({path:e},n)=>`File "${e}" too large. Maximum ${$(n.maxFileSize)} allowed`},{name:"totalSize",broken:({totalSize:e},n)=>e>n.maxTotalSize,sentence:({totalSize:e},n)=>`Total upload size too large. ${$(e)} exceeds maximum of ${$(n.maxTotalSize)}`}]});function Ee(e){if(ve(e))return{valid:!1,reason:"File name contains unsafe characters"};if(e.startsWith(" ")||e.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(e.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let n=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,t=e.split("/").pop()||e;return n.test(t)?{valid:!1,reason:"File name uses a reserved system name"}:e.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function vr(e,n){let t=[],s=[],l=[];if(e.length===0){let m={file:"(no files)",message:"At least one file must be provided"};return t.push(m),{files:[],validFiles:[],errors:t,warnings:[],canDeploy:!1}}for(let m of e)if(K(m.name))return t.push({file:m.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:e.map(E=>({...E,status:R.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:t,warnings:[],canDeploy:!1};if(e.length>n.maxFilesCount){let m={file:`(${e.length} files)`,message:`File count (${e.length}) exceeds limit of ${n.maxFilesCount}`};return t.push(m),{files:e.map(E=>({...E,status:R.VALIDATION_FAILED,statusMessage:m.message})),validFiles:[],errors:t,warnings:[],canDeploy:!1}}let p=0;for(let m of e){let E=R.READY,d="Ready for upload";if(m.status===R.PROCESSING_ERROR)E=R.VALIDATION_FAILED,d=m.statusMessage||"File failed during processing",t.push({file:m.name,message:d});else if(m.size===0){E=R.EXCLUDED,d="File is empty (0 bytes) and cannot be deployed due to storage limitations",s.push({file:m.name,message:d}),l.push({...m,status:E,statusMessage:d});continue}else if(m.size<0)E=R.VALIDATION_FAILED,d="File size must be positive",t.push({file:m.name,message:d});else if(!m.name||m.name.trim().length===0)E=R.VALIDATION_FAILED,d="File name cannot be empty",t.push({file:m.name||"(empty)",message:d});else if(m.name.includes("\0"))E=R.VALIDATION_FAILED,d="File name contains invalid characters (null byte)",t.push({file:m.name,message:d});else{let T={path:m.name,size:m.size,totalSize:p+m.size},N=ne(T,n);N?(E=R.VALIDATION_FAILED,d=N.sentence(T,n),t.push({file:N.name==="totalSize"?`(${e.length} files)`:m.name,message:d})):p=T.totalSize}l.push({...m,status:E,statusMessage:d})}t.length>0&&(l=l.map(m=>m.status===R.EXCLUDED?m:{...m,status:R.VALIDATION_FAILED,statusMessage:m.status===R.VALIDATION_FAILED?m.statusMessage:"Deployment failed due to validation errors in bundle"}));let h=t.length===0?l.filter(m=>m.status===R.READY):[],g=t.length===0;return{files:l,validFiles:h,errors:t,warnings:s,canDeploy:g}}function un(e){return e.filter(n=>n.status===R.READY)}function Cr(e){return un(e).length>0}var Ae=_(()=>{"use strict";D();Te();D()});function st(e){return pn.test(e)}var cn,pn,at=_(()=>{"use strict";cn=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],pn=new RegExp(cn.join("|"))});function lt(e,n){if(!e||e.length===0)return[];if(!n?.allowUnbuilt&&e.find(s=>s&&K(s)))throw f.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return e.filter(t=>{if(!t)return!1;let s=t.replace(/\\/g,"/").split("/").filter(Boolean);if(s.length===0)return!0;let l=s[s.length-1];if(st(l))return!1;for(let h of s)if(h!==".well-known"&&(h.startsWith(".")||h.length>255))return!1;let p=s.slice(0,-1);for(let h of p)if(dn.some(g=>h.toLowerCase()===g.toLowerCase()))return!1;return!0})}var dn,Se=_(()=>{"use strict";D();at();dn=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function ut(e,n){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw f.business(`Security error: Unsafe file path "${e}" for file: ${n}`)}function ct(e,n){let t=ne(e,n);if(t)throw f.business(t.sentence(e,n))}var De=_(()=>{"use strict";D();Te()});async function pt(e,n={},t){let s=!!(n.build||n.prerender),l=it(e.map(d=>d.path),{flatten:n.pathDetect!==!1}).map(d=>d.path),p=new Set(lt(l,{allowUnbuilt:s})),h=e.map((d,T)=>({source:d,deployPath:l[T]})).filter(({deployPath:d})=>p.has(d));if(h.length===0)return[];let g=s?null:fn(t),m=[],E=0;for(let{source:d,deployPath:T}of h){if(g&&ut(T,d.origin),d.size===0)continue;g&&(E+=d.size,ct({path:T,size:d.size,totalSize:E},g));let N=await d.read(),{md5:F}=await J(N);m.push({path:T,content:N,size:d.size,md5:F})}if(g&&m.length>g.maxFilesCount)throw f.business(`Too many files to deploy. Maximum allowed is ${g.maxFilesCount} files.`);return m}function fn(e){if(!e)throw f.config("Platform limits not provided. Deploy-mode validation requires the limits argument \u2014 pass `ship.getLimits()` result.");return e}var dt=_(()=>{"use strict";D();he();Se();Q();De()});var mt={};St(mt,{processFilesForBrowser:()=>ft});async function ft(e,n={},t){if(ot()!=="browser")throw f.business("processFilesForBrowser can only be called in a browser environment.");return pt(e.map(s=>({path:s.webkitRelativePath||s.name,origin:s.name,size:s.size,read:async()=>s})),n,t)}var Re=_(()=>{"use strict";D();dt();ge()});D();D();D();var j=class{constructor(){this.handlers=new Map}on(n,t){this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n)?.add(t)}off(n,t){let s=this.handlers.get(n);s&&(s.delete(t),s.size===0&&this.handlers.delete(n))}emit(n,...t){let s=this.handlers.get(n);if(!s)return;let l=Array.from(s);for(let p of l)try{p(...t)}catch(h){s.delete(p),n!=="error"&&setTimeout(()=>{let g=h instanceof Error?h:new Error(String(h));this.emit("error",g,String(n))},0)}}};var Kt=3e4,Xt=2,qt=300,jt=2e3,Yt=new Set([500,502,503,504]);function Wt(e,n){return new Promise((t,s)=>{if(n?.aborted){s(n.reason);return}let l=()=>{clearTimeout(h),n?.removeEventListener("abort",p)},p=()=>{l(),s(n?.reason)},h=setTimeout(()=>{l(),t()},e);n?.addEventListener("abort",p)})}var Ke=3e5,Jt=3e5,Qt=Ke+Jt,Y=class extends j{constructor(t){super();this.globalHeaders={};this.apiUrl=t.apiUrl||pe,this.getAuthHeadersCallback=t.getAuthHeaders,this.session=t.session??!1,this.caller=t.caller,this.timeout=t.timeout??Kt,this.maxRetries=Math.max(0,t.maxRetries??Xt),this.fetch=t.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:t.deployEndpoint||A.DEPLOYMENTS,timeout:t.timeout??Ke,buildTimeout:t.timeout??Qt}}setGlobalHeaders(t){this.globalHeaders=t}async executeRequest(t,s,l,p=this.timeout){for(let h=0;;h++)try{return await this.attemptOnce(t,s,l,p)}catch(g){let m=f.fromFetchError(g,l);if(h>=this.maxRetries||!this.isRetryable(m,s))throw this.emit("error",m,t),m;this.emit("retry",m,t,h+1);let E=Math.min(jt,qt*2**h);try{await Wt(Math.random()*E,s.signal)}catch(d){let T=f.fromFetchError(d,l);throw this.emit("error",T,t),T}}}isRetryable(t,s){if(s.signal?.aborted||t.isType(y.Maintenance)||t.isType(y.Cancelled)||!(t.isNetworkError()||t.status!==void 0&&Yt.has(t.status)))return!1;let p=(s.method??"GET").toUpperCase();return p==="GET"||p==="HEAD"?!0:p==="PUT"||p==="DELETE"?!1:this.hasIdempotencyKey(s.headers)}hasIdempotencyKey(t){if(!t)return!1;let s=C.HEADER.toLowerCase();return Object.keys(t).some(l=>l.toLowerCase()===s)}async attemptOnce(t,s,l,p=this.timeout){let h=()=>{};try{let g=await this.mergeHeaders(s.headers),m=this.createTimeoutSignal(s.signal,p);h=m.cleanup;let E={...s,headers:g,credentials:this.session&&!g.Authorization?"include":void 0,signal:m.signal};this.emit("request",t,E);let d=await this.fetch(t,E);if(h(),!d.ok)throw await f.fromHttpResponse(d,l);return this.emit("response",this.safeClone(d),t),{data:await this.parseResponse(this.safeClone(d)),status:d.status}}catch(g){throw h(),f.fromFetchError(g,l)}}async request(t,s,l,p){let{data:h}=await this.executeRequest(`${this.apiUrl}${t}`,s,l,p);return h}async requestWithStatus(t,s,l){return this.executeRequest(`${this.apiUrl}${t}`,s,l)}async mergeHeaders(t={}){return{...this.globalHeaders,...this.caller?{[M.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...t}}createTimeoutSignal(t,s=this.timeout){let l=new AbortController,p=setTimeout(()=>l.abort(new DOMException(`Timed out after ${s}ms`,"TimeoutError")),s),h=t?()=>l.abort(t.reason):void 0;return t&&h&&(t.addEventListener("abort",h),t.aborted&&l.abort(t.reason)),{signal:l.signal,cleanup:()=>{clearTimeout(p),t&&h&&t.removeEventListener("abort",h)}}}safeClone(t){try{return t.clone()}catch{return t}}async parseResponse(t){if(!(t.headers.get("Content-Length")==="0"||t.status===204))return t.json()}};D();D();async function Xe(e,n={}){let{labels:t,via:s,password:l,ttl:p,flags:h,captcha:g}=n,m=new FormData,E=[];for(let d of e){if(typeof d.content=="string"||d.content===null||d.content===void 0)throw f.file(`Unsupported file.content type: ${d.path}`,{filePath:d.path});if(!d.md5)throw f.file(`File missing md5 checksum: ${d.path}`,{filePath:d.path});m.append(I.FILES,new File([d.content],d.path,{type:"application/octet-stream"})),E.push(d.md5)}return m.append(I.CHECKSUMS,JSON.stringify(E)),t&&t.length>0&&m.append(I.LABELS,JSON.stringify(t)),s&&m.append(I.VIA,s),l&&m.append(I.PASSWORD,l),p!==void 0&&m.append(I.TTL,String(p)),h?.build&&m.append(I.BUILD,"true"),h?.prerender&&m.append(I.PRERENDER,"true"),h?.spa&&m.append(I.SPA,"true"),h?.buildCommand&&m.append(I.BUILD_COMMAND,h.buildCommand),h?.outputDir&&m.append(I.OUTPUT_DIR,h.outputDir),g&&m.append(I.CAPTCHA,g),m}D();Q();async function nn(){let e=JSON.stringify(Ue,null,2),n;typeof Buffer<"u"?n=Buffer.from(e,"utf-8"):n=new Blob([e],{type:"application/json"});let{md5:t}=await J(n);return{path:w,content:n,size:e.length,md5:t}}async function rn(e,n){let t=e.find(h=>h.path===X.INDEX_FILE||h.path===`/${X.INDEX_FILE}`);if(!t||t.size>X.MAX_INDEX_BYTES)return!1;let s;if(typeof Buffer<"u"&&Buffer.isBuffer(t.content))s=t.content.toString("utf-8");else if(typeof Blob<"u"&&t.content instanceof Blob)s=await t.content.text();else if(typeof File<"u"&&t.content instanceof File)s=await t.content.text();else return!1;let l={files:e.map(h=>h.path),index:s};return(await n.request(A.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)},"SPA check")).isSPA}async function Je(e,n,t){if(t.spaDetect===!1||t.spa||t.build||t.prerender||e.some(s=>s.path===w))return e;try{if(await rn(e,n)){let l=await nn();return[...e,l]}}catch{}return e}D();D();function B(e){if(e==null)return;if(e.length===0)return e;if(e.length>v.MAX_COUNT)throw f.validation(`Maximum ${v.MAX_COUNT} labels allowed`);let n=e.map((s,l)=>{if(typeof s!="string")throw f.validation(`Label at index ${l} must be a string`);let p=s.trim().toLowerCase();if(p.length<v.MIN_LENGTH)throw f.validation(`Labels must be at least ${v.MIN_LENGTH} characters long`);if(p.length>v.MAX_LENGTH)throw f.validation(`Labels must be no more than ${v.MAX_LENGTH} characters long`);if(!ke.test(p))throw f.validation(`Labels must start and end with alphanumeric characters, with optional separators (${v.SEPARATORS}) between segments`);return p}),t=[...new Set(n)];if(t.length!==n.length)throw f.validation("Duplicate labels are not allowed");return t}async function Qe(e){let n=e.find(l=>l.path===w||l.path===`/${w}`);if(!n)return;let t=n.content,s=typeof t.text=="function"?await t.text():n.content.toString("utf8");$e(s)}var Z={"Content-Type":"application/json"},on="sdk";function fe(e){let n=new URLSearchParams;e?.limit!==void 0&&n.set("limit",String(e.limit)),e?.cursor!==void 0&&n.set("cursor",e.cursor);let t=n.toString();return t?`?${t}`:""}function Ze(e){let{getApi:n,processInput:t}=e;return{upload:async(s,l={})=>{if(!t)throw f.config("processInput function is not provided.");let p=n(),h=await t(s,l),g=await Je(h,p,l);if(!g.length)throw f.business("No files to deploy");for(let O of g)if(!O.md5)throw f.file(`MD5 checksum missing for file: ${O.path}`,{filePath:O.path});de(l.password);let m=ce(l.ttl),E=Oe(l.idempotencyKey),d=B(l.labels);await Qe(g);let T=Ve(l.buildCommand),N=ze(l.outputDir),F=l.build||l.prerender||l.spa?{build:l.build,prerender:l.prerender,spa:l.spa,buildCommand:T,outputDir:N}:void 0,re=await Xe(g,{labels:d,via:l.via??on,password:l.password,ttl:m,flags:F,captcha:l.captcha});return p.request(p.deploy.endpoint,{method:"POST",body:re,...E?{headers:{[C.HEADER]:E}}:{},signal:l.signal||null},"Deploy",l.build||l.prerender?p.deploy.buildTimeout:p.deploy.timeout)},list:async s=>n().request(`${A.DEPLOYMENTS}${fe(s)}`,{method:"GET"},"List deployments"),get:async s=>n().request(A.DEPLOYMENT(encodeURIComponent(s)),{method:"GET"},"Get deployment"),set:async(s,l)=>n().request(A.DEPLOYMENT(encodeURIComponent(s)),{method:"PATCH",headers:Z,body:JSON.stringify({labels:B(l.labels)})},"Update deployment labels"),delete:async s=>n().request(A.DEPLOYMENT(encodeURIComponent(s)),{method:"DELETE"},"Delete deployment")}}function et(e){let{getApi:n}=e;return{set:async(t,s={})=>{let l=B(s.labels),p={};s.deployment&&(p.deployment=s.deployment),l!==void 0&&(p.labels=l);let{data:h,status:g}=await n().requestWithStatus(A.DOMAIN(encodeURIComponent(t)),{method:"PUT",headers:Z,body:JSON.stringify(p)},"Set domain");return{...h,isCreate:g===201}},list:async t=>n().request(`${A.DOMAINS}${fe(t)}`,{method:"GET"},"List domains"),get:async t=>n().request(A.DOMAIN(encodeURIComponent(t)),{method:"GET"},"Get domain"),delete:async t=>n().request(A.DOMAIN(encodeURIComponent(t)),{method:"DELETE"},"Delete domain"),verify:async t=>n().request(A.DOMAIN_VERIFY(encodeURIComponent(t)),{method:"POST"},"Verify domain"),validate:async t=>n().request(A.DOMAINS_VALIDATE,{method:"POST",headers:Z,body:JSON.stringify({domain:t})},"Validate domain"),dns:async t=>n().request(A.DOMAIN_DNS(encodeURIComponent(t)),{method:"GET"},"Get domain DNS"),records:async t=>n().request(A.DOMAIN_RECORDS(encodeURIComponent(t)),{method:"GET"},"Get domain records"),share:async t=>n().request(A.DOMAIN_SHARE(encodeURIComponent(t)),{method:"GET"},"Get domain share")}}function tt(e){let{getApi:n}=e;return{get:async()=>n().request(A.ACCOUNT,{method:"GET"},"Get account")}}function nt(e){let{getApi:n}=e;return{create:async(t={})=>{let s=ce(t.ttl),l=B(t.labels),p={};return s!==void 0&&(p.ttl=s),l!==void 0&&(p.labels=l),n().request(A.TOKENS,{method:"POST",headers:Z,body:JSON.stringify(p)},"Create token")},list:async t=>n().request(`${A.TOKENS}${fe(t)}`,{method:"GET"},"List tokens"),get:async t=>n().request(A.TOKEN(encodeURIComponent(t)),{method:"GET"},"Get token"),delete:async t=>n().request(A.TOKEN(encodeURIComponent(t)),{method:"DELETE"},"Delete token")}}var ee=class{constructor(n={}){this.credential=null;if(n={...n,apiUrl:n.apiUrl||void 0,token:n.token||void 0,caller:n.caller||void 0},this.clientOptions=n,n.caller!==void 0&&Be(n.caller),n.token&&n.session)throw f.config("Provide either `token` or `session`, not both.");typeof n.token=="string"?(ue(n.token),this.credential=n.token):n.token&&(this.credential=n.token),this.http=new Y({...n,getAuthHeaders:()=>this.getAuthHeaders()});let t={getApi:()=>this.http};this.deployments=Ze({...t,processInput:async(s,l)=>this.processInput(s,l,await this.getLimits())}),this.domains=et(t),this.account=tt(t),this.tokens=nt(t)}async ping(){return this.http.request(A.PING,{method:"GET"},"Ping")}async deploy(n,t){return this.deployments.upload(n,t)}async whoami(){return this.account.get()}async getLimits(){return this.http.request(A.LIMITS,{method:"GET"},"Get limits")}on(n,t){this.http.on(n,t)}off(n,t){this.http.off(n,t)}setHeaders(n){this.http.setGlobalHeaders(n)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(n){if(this.clientOptions.session)throw f.config("Provide either `token` or `session`, not both.");if(typeof n=="string"){if(!n)throw f.business("Invalid token provided. Token must be a non-empty string.");ue(n),this.credential=n;return}if(typeof n!="function")throw f.business("Invalid token provided. Token must be a non-empty string or a provider function.");this.credential=n}async getAuthHeaders(){if(this.credential===null)return{};let n=typeof this.credential=="function"?await this.credential():this.credential;if(!n)throw f.authentication("Token provider returned no token.");if(typeof n!="string")throw f.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${n}`}}};D();D();he();ge();Ae();Se();Q();De();function zr(e,n,t,s=!0){let l=e===1?n:t;return s?`${e} ${l}`:l}Re();var be=class extends ee{async deploy(n,t){return super.deploy(n,t)}async processInput(n,t,s){if(!Array.isArray(n)||!n.every(p=>p instanceof File))throw f.business("Invalid input type for browser environment. Expected File[].");if(n.length===0)throw f.business("No files to deploy.");let{processFilesForBrowser:l}=await Promise.resolve().then(()=>(Re(),mt));return l(n,t,s)}},yi=be;export{Ln as ACCOUNT_HEADER,Ce as API_KEY,A as API_PATHS,_n as AUTH_BASE_PATH,An as AccountPlan,Sn as AccountRefusal,Y as ApiHttp,oe as AuthMethod,U as BUILD_SETTINGS,M as CALLER,pe as DEFAULT_API,w as DEPLOYMENT_CONFIG_FILENAME,I as DEPLOY_FIELDS,bn as DEPLOY_FILE_GRAMMAR,Fe as DEPLOY_TOKEN,hn as DeploymentStatus,Rt as DeploymentVia,yn as DomainStatus,gn as DomainVerification,y as ErrorType,R as FILE_VALIDATION_STATUS,R as FileValidationStatus,C as IDEMPOTENCY_KEY_CONSTRAINTS,dn as JUNK_DIRECTORIES,v as LABEL_CONSTRAINTS,ke as LABEL_PATTERN,Bn as MY_API_KEY_URL,Me as OAUTH_TOKEN,On as OAuthScope,z as PASSWORD_CONSTRAINTS,Hn as PUBLIC_DEPLOYMENT_TTL_SECONDS,Mt as SECTIONS,En as SETUP_TROUBLESHOOTING_ANCHOR,Un as SHIP_ENV,$n as SHIP_VIA_ENV,Nn as SIGN_IN_RETURN_PARAM,X as SPA_CHECK_CONSTRAINTS,Ue as SPA_DEFAULT_CONFIG,be as Ship,f as ShipError,V as TTL_CONSTRAINTS,P as TokenKind,xt as UNBUILT_PROJECT_MARKERS,Ot as UNSAFE_FILENAME_CHARS,kn as USER_VISIBLE_EVENTS,In as WEB_FILE_ACCEPT,_r as __setTestEnvironment,Fn as accountOfPath,Cr as allValidFilesReady,$e as assertShipJsonSyntax,Cn as billingReturnOf,J as calculateMD5,Pt as classifyToken,Bt as consolePaths,tt as createAccountResource,Ze as createDeploymentResource,et as createDomainResource,nt as createTokenResource,yi as default,jn as deserializeLabels,vn as doors,Mn as errandOf,zn as extractSubdomain,lt as filterJunk,zt as formatDuration,$ as formatFileSize,Gn as formatTimeRemaining,Kn as generateDeploymentUrl,Xn as generateDomainUrl,ot as getENV,un as getValidFiles,K as hasUnbuiltMarker,ve as hasUnsafeChars,Pe as isBlockedExtension,Gt as isClaimPath,Vn as isCustomDomain,Pn as isDeployment,kt as isInvitationPath,Ge as isPlatformDomain,xe as isShipError,Vt as isUpgradePath,Tn as normalizeVia,it as optimizeDeployPaths,Dn as personName,Rn as personShortName,zr as pluralize,ft as processFilesForBrowser,wn as readBearerValue,qn as serializeLabels,vt as validateApiKey,xn as validateApiUrl,Ve as validateBuildCommand,Be as validateCaller,ct as validateDeployFile,ut as validateDeployPath,Ct as validateDeployToken,Ee as validateFileName,vr as validateFiles,Oe as validateIdempotencyKey,Ft as validateOAuthToken,ze as validateOutputDir,de as validatePassword,ue as validateToken,ce as validateTtl};
2
2
  //# sourceMappingURL=browser.js.map