@shipstatic/ship 2.2.0-beta.5 → 2.2.0-beta.6

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/dist/browser.d.ts CHANGED
@@ -2436,6 +2436,56 @@ interface MD5Result {
2436
2436
  }
2437
2437
  declare function calculateMD5(input: Blob | Buffer | string): Promise<MD5Result>;
2438
2438
 
2439
+ /**
2440
+ * @file One ordered table of deploy-file rules, and the single evaluation two
2441
+ * renderers share.
2442
+ *
2443
+ * **The defect this closes:** one rule was rendering as three sentences. A
2444
+ * file over the size cap said `File x is too large. Maximum allowed size is
2445
+ * 20MB.` from the deploy pipelines, `File size (21 MB) exceeds limit of 20 MB`
2446
+ * from `validateFiles`, and `File too large. Maximum 20971520 bytes allowed`
2447
+ * from the API — against the dual-validation doctrine that an error reads the
2448
+ * same wherever it was caught (root `CLAUDE.md`). Both pipelines also restated
2449
+ * the whole ordered check, so node/browser parity was a comment.
2450
+ *
2451
+ * **A rule states a predicate and a sentence; a renderer chooses only how to
2452
+ * DELIVER it.** That is the `SHAPES`-table move (`cli/formatters.ts`) applied
2453
+ * to validation: the throwing renderer raises the first broken rule, the
2454
+ * collecting renderer records it, and neither authors prose. Adding a rule is
2455
+ * a row, and both surfaces get it in the same position by construction.
2456
+ *
2457
+ * **Wording follows the API where a choice existed**, so the deferred Phase B
2458
+ * — promoting this table to `@shipstatic/types` with the API consuming it —
2459
+ * has less to move. Two deliberate deviations, recorded rather than silent:
2460
+ *
2461
+ * - **Sizes are formatted, not raw bytes.** The API says `20971520 bytes`;
2462
+ * a browser upload UI showing that is worse for the person reading it, and
2463
+ * the unit is the smaller half of the sentence to reconcile later.
2464
+ * - **The path is named.** The API has no path to name; the throwing renderer
2465
+ * has nothing BUT the message, so dropping it would leave a CLI user asking
2466
+ * which file.
2467
+ *
2468
+ * Out of scope, and left where they are: `validateDeployPath` (a rule about
2469
+ * the deploy PATH rather than the file, and pipelines-only), and
2470
+ * `validateFiles`' UI-tier pre-checks — empty, negative, count, unbuilt
2471
+ * marker, processing error — which have one holder each and no drift.
2472
+ */
2473
+
2474
+ /** What a rule is asked about: one file, and the deploy so far. */
2475
+ interface FileRuleInput {
2476
+ /** The path this file will be served at. */
2477
+ readonly path: string;
2478
+ /** This file's size in bytes. */
2479
+ readonly size: number;
2480
+ /** Bytes accumulated INCLUDING this file — the total rule's subject. */
2481
+ readonly totalSize: number;
2482
+ }
2483
+
2484
+ /**
2485
+ * @file Shared security validation for the deploy pipeline.
2486
+ * Used by both Node.js and browser file processing pipelines.
2487
+ */
2488
+
2439
2489
  /**
2440
2490
  * Validate a deploy path for security concerns.
2441
2491
  * Rejects paths containing path traversal patterns or null bytes.
@@ -2454,24 +2504,22 @@ declare function calculateMD5(input: Blob | Buffer | string): Promise<MD5Result>
2454
2504
  */
2455
2505
  declare function validateDeployPath(deployPath: string, sourceIdentifier: string): void;
2456
2506
  /**
2457
- * Validate a deploy file's name and extension.
2458
- * Rejects unsafe filenames (shell/URL-dangerous chars, reserved names)
2459
- * and file extensions the platform refuses to host.
2507
+ * The THROWING renderer of `FILE_RULES` — the deploy pipelines' shape.
2460
2508
  *
2461
- * **The blocklist is the platform's, delivered not this package's.** It
2462
- * arrives as `PlatformLimits.blockedExtensions` from `GET /limits`, which the
2463
- * client has already fetched by the time any file is processed. That is what
2464
- * keeps a pinned CLI from enforcing a policy the platform has moved on from,
2465
- * in either direction. Callers pass `[]` when the API sent no list (one that
2466
- * predates the field): the check then does nothing and the API refuses the
2467
- * file at the boundary, which is the correct place for it to be refused.
2509
+ * It raises the first rule the file breaks and nothing else: the rules, their
2510
+ * order and their sentences all live in `file-rules.ts`, so this function
2511
+ * cannot re-order, skip or reword one. That is what makes node/browser parity
2512
+ * structural both pipelines call this, and this calls the one table.
2468
2513
  *
2469
- * @param deployPath - The deployment path to validate
2470
- * @param sourceIdentifier - Human-readable identifier for error messages
2471
- * @param blockedExtensions - The platform's blocklist, from `/limits`
2472
- * @throws {ShipError} If the filename is unsafe or the extension is blocked
2514
+ * Its counterpart is the collecting renderer in `file-validation.ts`
2515
+ * (`validateFiles`), which reaches the same verdict and reports it as a list
2516
+ * instead of a throw.
2517
+ *
2518
+ * @param input - The file and the deploy so far (`totalSize` INCLUDES it)
2519
+ * @param limits - The platform's limits, from `/limits`
2520
+ * @throws {ShipError} The first broken rule's sentence
2473
2521
  */
2474
- declare function validateDeployFile(deployPath: string, sourceIdentifier: string, blockedExtensions: readonly string[]): void;
2522
+ declare function validateDeployFile(input: FileRuleInput, limits: PlatformLimits): void;
2475
2523
 
2476
2524
  /**
2477
2525
  * Utility functions for string manipulation.
package/dist/browser.js CHANGED
@@ -1,2 +1,2 @@
1
- var Je=Object.create;var H=Object.defineProperty;var Qe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var et=Object.getPrototypeOf,tt=Object.prototype.hasOwnProperty;var nt=(t,n,e)=>n in t?H(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var P=(t,n)=>()=>(t&&(n=t(t=0)),n);var ye=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),rt=(t,n)=>{for(var e in n)H(t,e,{get:n[e],enumerable:!0})},it=(t,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of Ze(n))!tt.call(t,l)&&l!==e&&H(t,l,{get:()=>n[l],enumerable:!(o=Qe(n,l))||o.enumerable});return t};var G=(t,n,e)=>(e=t!=null?Je(et(t)):{},it(n||!t||!t.__esModule?H(e,"default",{value:t,enumerable:!0}):e,t));var k=(t,n,e)=>nt(t,typeof n!="symbol"?n+"":n,e);function Bt(t){if(!t||typeof t!="string")return;let n=t.trim().toLowerCase();return Object.values(st).includes(n)?n:void 0}function Ee(t){if(t==null)return;if(typeof t!="string")throw m.validation("Idempotency key must be a string.");let n=t.trim();if(!n)throw m.validation("Idempotency key must not be empty.");if(n.length>U.MAX_LENGTH)throw m.validation(`Idempotency key must be at most ${U.MAX_LENGTH} characters.`);return n}function pt(t){let n=t.code;return n==="ERR_INVALID_URL"?!1:typeof n=="string"?!0:t instanceof TypeError?!/\burl\b/i.test(t.message):!1}function Ae(t){return t!==null&&typeof t=="object"&&"name"in t&&t.name==="ShipError"&&"status"in t}function ut(t){let n=t.replace(/\\/g,"/").split("/").pop()??"",e=n.lastIndexOf(".");return e<=0||e===n.length-1?null:n.slice(e+1).toLowerCase()}function V(t,n){let e=ut(t);return e===null?!1:Array.isArray(n)?n.includes(e):n.has(e)}function De(t){return dt.test(t)}function K(t){return t.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>ft.has(e))}function mt(t){return t.startsWith(Te.PREFIX)?C.API_KEY:t.startsWith(Se.PREFIX)?C.DEPLOY_TOKEN:C.OPAQUE}function be(t){let n=t.charCodeAt(0)===65279?t.slice(1):t,e;try{e=JSON.parse(n)}catch(o){throw m.config(`invalid JSON format in config: ${o.message}`,{filePath:x})}if(e===null||typeof e!="object"||Array.isArray(e))throw m.config(`${x} must contain a JSON object`,{filePath:x})}function Ie(t,n,e){if(!t.startsWith(n.PREFIX))throw m.validation(`${e} must start with "${n.PREFIX}"`);if(t.length!==n.TOTAL_LENGTH)throw m.validation(`${e} must be ${n.TOTAL_LENGTH} characters total (${n.PREFIX} + ${n.HEX_LENGTH} hex chars)`);let o=t.slice(n.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${n.HEX_LENGTH}}$`,"i").test(o))throw m.validation(`${e} must contain ${n.HEX_LENGTH} hexadecimal characters after "${n.PREFIX}" prefix`)}function ht(t){Ie(t,Te,"API key")}function yt(t){Ie(t,Se,"Deploy token")}function ee(t){switch(mt(t)){case C.API_KEY:ht(t);return;case C.DEPLOY_TOKEN:yt(t);return;case C.OPAQUE:if(!t)throw m.validation("Token must be a non-empty string")}}function we(t){if(!t||t.length>$.MAX_LENGTH||!$.PATTERN.test(t))throw m.validation(`Caller must be 1-${$.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function Vt(t){try{let n=new URL(t);if(!["http:","https:"].includes(n.protocol))throw m.validation("API URL must use http:// or https:// protocol");if(n.pathname!=="/"&&n.pathname!=="")throw m.validation("API URL must not contain a path");if(n.search||n.hash)throw m.validation("API URL must not contain query parameters or fragments")}catch(n){throw Ae(n)?n:m.validation("API URL must be a valid URL")}}function Kt(t){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(t)}function Le(t,n){return t.endsWith(`.${n}`)}function Xt(t,n){return!Le(t,n)}function Wt(t,n){return Le(t,n)?t.slice(0,-(n.length+1)):null}function Jt(t){return`https://${t}`}function Qt(t){return`https://${t}`}function Zt(t){return!t||t.length===0?null:JSON.stringify(t)}function en(t){if(!t)return[];try{let n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function ne(t){if(t==null)return;if(typeof t!="string")throw m.validation("Password must be a string");let n=t.trim();if(n.length<z.MIN_LENGTH||n.length>z.MAX_LENGTH)throw m.validation(`Password must be between ${z.MIN_LENGTH} and ${z.MAX_LENGTH} characters`);return n}var Ut,st,Mt,U,Ht,T,_,E,ot,Z,at,lt,m,ct,Gt,dt,ft,kt,ge,Te,Se,$,C,zt,x,Re,Y,te,Yt,jt,qt,R,F,Pe,z,b=P(()=>{"use strict";Ut={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},st={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc"},Mt={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},U={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};Ht={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},T={DEPLOYMENTS:"/deployments",DEPLOYMENT:t=>`/deployments/${t}`,DEPLOYMENT_CONFIG:t=>`/deployments/${t}/config`,DOMAINS:"/domains",DOMAIN:t=>`/domains/${t}`,DOMAIN_VERIFY:t=>`/domains/${t}/verify`,DOMAIN_DNS:t=>`/domains/${t}/dns`,DOMAIN_RECORDS:t=>`/domains/${t}/records`,DOMAIN_SHARE:t=>`/domains/${t}/share`,DOMAIN_PROPAGATION:t=>`/domains/${t}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:t=>`/tokens/${t}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},_={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",BUILD:"build",PRERENDER:"prerender",SPA:"spa",CAPTCHA:"captcha"},E={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",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},ot=new Set([E.Network,E.Cancelled,E.File,E.Config]),Z={client:new Set([E.Business,E.Cancelled,E.Config,E.File,E.Forbidden,E.NotFound,E.RateLimit,E.Validation]),network:new Set([E.Network]),auth:new Set([E.Authentication])},at=new Set(Object.values(E).filter(t=>!ot.has(t))),lt=200;m=class t extends Error{constructor(e,o,l,c){super(o);k(this,"type");k(this,"status");k(this,"details");this.type=e,this.status=l,this.details=c,this.name="ShipError"}toResponse(){let e=this.details,o=this.type===E.Authentication&&e?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:o}}static async fromHttpResponse(e,o){let l,c,f;try{if(e.headers.get("content-type")?.includes("application/json")){let h=await e.json();if(h&&typeof h=="object"){let D=h;typeof D.message=="string"?l=D.message:typeof D.error=="string"&&(l=D.error),c=D.details,typeof D.error=="string"&&at.has(D.error)&&(f=D.error)}}else{let h=(await e.text()).trim();h&&!h.startsWith("<")&&h.length<=lt&&(l=h)}}catch{}let y=e.headers.get("retry-after");if(y!==null){let g=y.trim(),h=/^\d+$/.test(g)?Number(g):Math.ceil((Date.parse(g)-Date.now())/1e3);if(Number.isFinite(h)&&h>=0){let D=c&&typeof c=="object"?c:{};D.retryAfter===void 0&&(c={...D,retryAfter:h})}}l=l||`${o||"Request"} failed with status ${e.status}`;let d=f??(e.status===401?E.Authentication:e.status===403?E.Forbidden:e.status===429?E.RateLimit:E.Api);return new t(d,l,e.status,c)}static fromFetchError(e,o){if(Ae(e))return e;let l=o||"Request",c=e?.name;return c==="AbortError"?t.cancelled(`${l} was cancelled`):c==="TimeoutError"?t.network(`${l} timed out`,{cause:e}):e instanceof Error?pt(e)?t.network(`${l} failed: ${e.message}`,{cause:e}):new t(E.Api,`${l} failed: ${e.message}`):new t(E.Api,`${l} failed: Unknown error`)}static validation(e,o){return new t(E.Validation,e,400,o)}static notFound(e,o){let l=o?`${e} ${o} not found`:`${e} not found`;return new t(E.NotFound,l,404)}static forbidden(e,o){return new t(E.Forbidden,e,403,o)}static rateLimit(e="Too many requests",o){return new t(E.RateLimit,e,429,o)}static authentication(e="Authentication required",o){return new t(E.Authentication,e,401,o)}static business(e,o=400,l){return new t(E.Business,e,o,l)}static network(e,o){return new t(E.Network,e,void 0,o)}static cancelled(e,o){return new t(E.Cancelled,e,void 0,o)}static file(e,o){return new t(E.File,e,void 0,o)}static config(e,o){return new t(E.Config,e,void 0,o)}static api(e,o=500,l){return new t(E.Api,e,o,l)}static maintenance(e,o){return new t(E.Maintenance,e,503,o)}isClientError(){return Z.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return Z.network.has(this.type)}isAuthError(){return Z.auth.has(this.type)}isType(e){return this.type===e}};ct=["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"],Gt=ct.map(t=>`.${t}`).join(","),dt=/[\x00-\x1f\x7f#?%\\<>"]/;ft=new Set(["node_modules","package.json"]);kt="/auth",ge={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},Te={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},Se={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},$={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},C={API_KEY:ge.API_KEY,DEPLOY_TOKEN:ge.TOKEN,OPAQUE:"opaque"};zt={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},x="ship.json",Re={rewrites:[{source:"/(.*)",destination:"/index.html"}]},Y={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};te="https://api.shipstatic.com",Yt={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},jt="https://my.shipstatic.com/api-key",qt=4320*60,R={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};F={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Pe=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;z={MIN_LENGTH:6,MAX_LENGTH:128}});var Oe=ye((xe,Ne)=>{"use strict";(function(t){if(typeof xe=="object")Ne.exports=t();else if(typeof define=="function"&&define.amd)define(t);else{var n;try{n=window}catch{n=self}n.SparkMD5=t()}})(function(t){"use strict";var n=function(u,p){return u+p&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function o(u,p,i,r,a,s){return p=n(n(p,u),n(r,s)),n(p<<a|p>>>32-a,i)}function l(u,p){var i=u[0],r=u[1],a=u[2],s=u[3];i+=(r&a|~r&s)+p[0]-680876936|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[1]-389564586|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[2]+606105819|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[3]-1044525330|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&s)+p[4]-176418897|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[5]+1200080426|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[6]-1473231341|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[7]-45705983|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&s)+p[8]+1770035416|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[9]-1958414417|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[10]-42063|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[11]-1990404162|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&s)+p[12]+1804603682|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[13]-40341101|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[14]-1502002290|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[15]+1236535329|0,r=(r<<22|r>>>10)+a|0,i+=(r&s|a&~s)+p[1]-165796510|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[6]-1069501632|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[11]+643717713|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[0]-373897302|0,r=(r<<20|r>>>12)+a|0,i+=(r&s|a&~s)+p[5]-701558691|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[10]+38016083|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[15]-660478335|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[4]-405537848|0,r=(r<<20|r>>>12)+a|0,i+=(r&s|a&~s)+p[9]+568446438|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[14]-1019803690|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[3]-187363961|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[8]+1163531501|0,r=(r<<20|r>>>12)+a|0,i+=(r&s|a&~s)+p[13]-1444681467|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[2]-51403784|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[7]+1735328473|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[12]-1926607734|0,r=(r<<20|r>>>12)+a|0,i+=(r^a^s)+p[5]-378558|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[8]-2022574463|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[11]+1839030562|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[14]-35309556|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^s)+p[1]-1530992060|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[4]+1272893353|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[7]-155497632|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[10]-1094730640|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^s)+p[13]+681279174|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[0]-358537222|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[3]-722521979|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[6]+76029189|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^s)+p[9]-640364487|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[12]-421815835|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[15]+530742520|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[2]-995338651|0,r=(r<<23|r>>>9)+a|0,i+=(a^(r|~s))+p[0]-198630844|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[7]+1126891415|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[14]-1416354905|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[5]-57434055|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~s))+p[12]+1700485571|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[3]-1894986606|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[10]-1051523|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[1]-2054922799|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~s))+p[8]+1873313359|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[15]-30611744|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[6]-1560198380|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[13]+1309151649|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~s))+p[4]-145523070|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[11]-1120210379|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[2]+718787259|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[9]-343485551|0,r=(r<<21|r>>>11)+a|0,u[0]=i+u[0]|0,u[1]=r+u[1]|0,u[2]=a+u[2]|0,u[3]=s+u[3]|0}function c(u){var p=[],i;for(i=0;i<64;i+=4)p[i>>2]=u.charCodeAt(i)+(u.charCodeAt(i+1)<<8)+(u.charCodeAt(i+2)<<16)+(u.charCodeAt(i+3)<<24);return p}function f(u){var p=[],i;for(i=0;i<64;i+=4)p[i>>2]=u[i]+(u[i+1]<<8)+(u[i+2]<<16)+(u[i+3]<<24);return p}function y(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,a,s,w,v,O;for(r=64;r<=p;r+=64)l(i,c(u.substring(r-64,r)));for(u=u.substring(r-64),a=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<a;r+=1)s[r>>2]|=u.charCodeAt(r)<<(r%4<<3);if(s[r>>2]|=128<<(r%4<<3),r>55)for(l(i,s),r=0;r<16;r+=1)s[r]=0;return w=p*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),v=parseInt(w[2],16),O=parseInt(w[1],16)||0,s[14]=v,s[15]=O,l(i,s),i}function d(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,a,s,w,v,O;for(r=64;r<=p;r+=64)l(i,f(u.subarray(r-64,r)));for(u=r-64<p?u.subarray(r-64):new Uint8Array(0),a=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<a;r+=1)s[r>>2]|=u[r]<<(r%4<<3);if(s[r>>2]|=128<<(r%4<<3),r>55)for(l(i,s),r=0;r<16;r+=1)s[r]=0;return w=p*8,w=w.toString(16).match(/(.*?)(.{0,8})$/),v=parseInt(w[2],16),O=parseInt(w[1],16)||0,s[14]=v,s[15]=O,l(i,s),i}function g(u){var p="",i;for(i=0;i<4;i+=1)p+=e[u>>i*8+4&15]+e[u>>i*8&15];return p}function h(u){var p;for(p=0;p<u.length;p+=1)u[p]=g(u[p]);return u.join("")}h(y("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(n=function(u,p){var i=(u&65535)+(p&65535),r=(u>>16)+(p>>16)+(i>>16);return r<<16|i&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(p,i){return p=p|0||0,p<0?Math.max(p+i,0):Math.min(p,i)}ArrayBuffer.prototype.slice=function(p,i){var r=this.byteLength,a=u(p,r),s=r,w,v,O,he;return i!==t&&(s=u(i,r)),a>s?new ArrayBuffer(0):(w=s-a,v=new ArrayBuffer(w),O=new Uint8Array(v),he=new Uint8Array(this,a,w),O.set(he),v)}})();function D(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function S(u,p){var i=u.length,r=new ArrayBuffer(i),a=new Uint8Array(r),s;for(s=0;s<i;s+=1)a[s]=u.charCodeAt(s);return p?a:r}function I(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function L(u,p,i){var r=new Uint8Array(u.byteLength+p.byteLength);return r.set(new Uint8Array(u)),r.set(new Uint8Array(p),u.byteLength),i?r:r.buffer}function N(u){var p=[],i=u.length,r;for(r=0;r<i-1;r+=2)p.push(parseInt(u.substr(r,2),16));return String.fromCharCode.apply(String,p)}function A(){this.reset()}return A.prototype.append=function(u){return this.appendBinary(D(u)),this},A.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var p=this._buff.length,i;for(i=64;i<=p;i+=64)l(this._hash,c(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},A.prototype.end=function(u){var p=this._buff,i=p.length,r,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(r=0;r<i;r+=1)a[r>>2]|=p.charCodeAt(r)<<(r%4<<3);return this._finish(a,i),s=h(this._hash),u&&(s=N(s)),this.reset(),s},A.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},A.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},A.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},A.prototype._finish=function(u,p){var i=p,r,a,s;if(u[i>>2]|=128<<(i%4<<3),i>55)for(l(this._hash,u),i=0;i<16;i+=1)u[i]=0;r=this._length*8,r=r.toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(r[2],16),s=parseInt(r[1],16)||0,u[14]=a,u[15]=s,l(this._hash,u)},A.hash=function(u,p){return A.hashBinary(D(u),p)},A.hashBinary=function(u,p){var i=y(u),r=h(i);return p?N(r):r},A.ArrayBuffer=function(){this.reset()},A.ArrayBuffer.prototype.append=function(u){var p=L(this._buff.buffer,u,!0),i=p.length,r;for(this._length+=u.byteLength,r=64;r<=i;r+=64)l(this._hash,f(p.subarray(r-64,r)));return this._buff=r-64<i?new Uint8Array(p.buffer.slice(r-64)):new Uint8Array(0),this},A.ArrayBuffer.prototype.end=function(u){var p=this._buff,i=p.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,s;for(a=0;a<i;a+=1)r[a>>2]|=p[a]<<(a%4<<3);return this._finish(r,i),s=h(this._hash),u&&(s=N(s)),this.reset(),s},A.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},A.ArrayBuffer.prototype.getState=function(){var u=A.prototype.getState.call(this);return u.buff=I(u.buff),u},A.ArrayBuffer.prototype.setState=function(u){return u.buff=S(u.buff,!0),A.prototype.setState.call(this,u)},A.ArrayBuffer.prototype.destroy=A.prototype.destroy,A.ArrayBuffer.prototype._finish=A.prototype._finish,A.ArrayBuffer.hash=function(u,p){var i=d(new Uint8Array(u)),r=h(i);return p?N(r):r},A})});var X=ye((dn,Fe)=>{"use strict";Fe.exports={}});async function wt(t){let n=(await Promise.resolve().then(()=>G(Oe(),1))).default,e=new n.ArrayBuffer,o=2097152;for(let l=0;l<t.size;l+=o){let c=Math.min(l+o,t.size);e.append(await t.slice(l,c).arrayBuffer())}return{md5:e.end()}}async function Lt(t){let{createHash:n}=await Promise.resolve().then(()=>G(X(),1)),e=n("md5");return e.update(t),{md5:e.digest("hex")}}async function Pt(t){let{createHash:n}=await Promise.resolve().then(()=>G(X(),1)),{createReadStream:e}=await Promise.resolve().then(()=>G(X(),1));return new Promise((o,l)=>{let c=n("md5"),f=e(t);f.on("error",y=>l(m.file(`Failed to read file for MD5: ${y.message}`,{filePath:t}))),f.on("data",y=>c.update(y)),f.on("end",()=>o({md5:c.digest("hex")}))})}async function B(t){if(t instanceof Blob)return wt(t);if(typeof Buffer<"u"&&Buffer.isBuffer(t))return Lt(t);if(typeof t=="string")return Pt(t);throw m.business("Invalid input for MD5 calculation")}var W=P(()=>{"use strict";b()});function Q(t){return t.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var Ge=P(()=>{"use strict"});function ke(t,n={}){if(n.flatten===!1)return t.map(o=>({path:Q(o),name:ie(o)}));let e=vt(t);return t.map(o=>{let l=Q(o);if(e){let c=e.endsWith("/")?e:`${e}/`;l.startsWith(c)&&(l=l.substring(c.length))}return l||(l=ie(o)),{path:l,name:ie(o)}})}function vt(t){if(!t.length)return"";let e=t.map(c=>Q(c)).map(c=>c.split("/")),o=[],l=Math.min(...e.map(c=>c.length));for(let c=0;c<l-1;c++){let f=e[0][c];if(e.every(y=>y[c]===f))o.push(f);else break}return o.join("/")}function ie(t){return t.split(/[/\\]/).pop()||t}var se=P(()=>{"use strict";Ge()});function Nn(t){oe=t}function xt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function ze(){return oe||xt()}var oe,ae=P(()=>{"use strict";oe=null});function le(t,n=1){if(t===0)return"0 Bytes";let e=1024,o=["Bytes","KB","MB","GB"],l=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/e**l).toFixed(n))} ${o[l]}`}function pe(t){if(De(t))return{valid:!1,reason:"File name contains unsafe characters"};if(t.startsWith(" ")||t.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(t.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let n=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=t.split("/").pop()||t;return n.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:t.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function Cn(t,n){let e=[],o=[],l=[];if(t.length===0){let d={file:"(no files)",message:"At least one file must be provided"};return e.push(d),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let d of t)if(K(d.name))return e.push({file:d.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:t.map(g=>({...g,status:R.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(t.length>n.maxFilesCount){let d={file:`(${t.length} files)`,message:`File count (${t.length}) exceeds limit of ${n.maxFilesCount}`};return e.push(d),{files:t.map(g=>({...g,status:R.VALIDATION_FAILED,statusMessage:d.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let c=0;for(let d of t){let g=R.READY,h="Ready for upload",D=d.name?pe(d.name):{valid:!1,reason:"File name cannot be empty"};if(d.status===R.PROCESSING_ERROR)g=R.VALIDATION_FAILED,h=d.statusMessage||"File failed during processing",e.push({file:d.name,message:h});else if(d.size===0){g=R.EXCLUDED,h="File is empty (0 bytes) and cannot be deployed due to storage limitations",o.push({file:d.name,message:h}),l.push({...d,status:g,statusMessage:h});continue}else d.size<0?(g=R.VALIDATION_FAILED,h="File size must be positive",e.push({file:d.name,message:h})):!d.name||d.name.trim().length===0?(g=R.VALIDATION_FAILED,h="File name cannot be empty",e.push({file:d.name||"(empty)",message:h})):d.name.includes("\0")?(g=R.VALIDATION_FAILED,h="File name contains invalid characters (null byte)",e.push({file:d.name,message:h})):D.valid?V(d.name,n.blockedExtensions??[])?(g=R.VALIDATION_FAILED,h=`File extension not allowed: "${d.name}"`,e.push({file:d.name,message:h})):d.size>n.maxFileSize?(g=R.VALIDATION_FAILED,h=`File size (${le(d.size)}) exceeds limit of ${le(n.maxFileSize)}`,e.push({file:d.name,message:h})):(c+=d.size,c>n.maxTotalSize&&(g=R.VALIDATION_FAILED,h=`Total size would exceed limit of ${le(n.maxTotalSize)}`,e.push({file:d.name,message:h}))):(g=R.VALIDATION_FAILED,h=D.reason||"Invalid file name",e.push({file:d.name,message:h}));l.push({...d,status:g,statusMessage:h})}e.length>0&&(l=l.map(d=>d.status===R.EXCLUDED?d:{...d,status:R.VALIDATION_FAILED,statusMessage:d.status===R.VALIDATION_FAILED?d.statusMessage:"Deployment failed due to validation errors in bundle"}));let f=e.length===0?l.filter(d=>d.status===R.READY):[],y=e.length===0;return{files:l,validFiles:f,errors:e,warnings:o,canDeploy:y}}function Nt(t){return t.filter(n=>n.status===R.READY)}function $n(t){return Nt(t).length>0}var ue=P(()=>{"use strict";b()});function Ve(t){return Ft.test(t)}var Ot,Ft,Ke=P(()=>{"use strict";Ot=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],Ft=new RegExp(Ot.join("|"))});function Ye(t,n){if(!t||t.length===0)return[];if(!n?.allowUnbuilt&&t.find(o=>o&&K(o)))throw m.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return t.filter(e=>{if(!e)return!1;let o=e.replace(/\\/g,"/").split("/").filter(Boolean);if(o.length===0)return!0;let l=o[o.length-1];if(Ve(l))return!1;for(let f of o)if(f!==".well-known"&&(f.startsWith(".")||f.length>255))return!1;let c=o.slice(0,-1);for(let f of c)if(Ct.some(y=>f.toLowerCase()===y.toLowerCase()))return!1;return!0})}var Ct,ce=P(()=>{"use strict";b();Ke();Ct=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function je(t,n){if(t.includes("\0")||t.includes("/../")||t.startsWith("../")||t.endsWith("/.."))throw m.business(`Security error: Unsafe file path "${t}" for file: ${n}`)}function qe(t,n,e){let o=pe(t);if(!o.valid)throw m.business(o.reason||"Invalid file name");if(V(t,e))throw m.business(`File extension not allowed: "${n}"`)}var de=P(()=>{"use strict";b();ue()});var We={};rt(We,{processFilesForBrowser:()=>Xe});async function Xe(t,n={},e){if(ze()!=="browser")throw m.business("processFilesForBrowser can only be called in a browser environment.");let o=t.map(S=>S.webkitRelativePath||S.name),l=n.build||n.prerender,c=ke(o,{flatten:n.pathDetect!==!1}),f=c.map(S=>S.path),y=new Set(Ye(f,{allowUnbuilt:l})),d=[];for(let S=0;S<t.length;S++)y.has(f[S])&&d.push({file:t[S],deployPath:c[S].path});if(d.length===0)return[];if(l){let S=[];for(let I=0;I<d.length;I++){let{file:L,deployPath:N}=d[I];if(L.size===0)continue;let{md5:A}=await B(L);S.push({path:N,content:L,size:L.size,md5:A})}return S}if(!e)throw m.config("Platform limits not provided. processFilesForBrowser requires the limits argument for deploy-mode validation \u2014 pass `ship.getLimits()` result.");let g=[],h=0,D=e.blockedExtensions??[];for(let S=0;S<d.length;S++){let{file:I,deployPath:L}=d[S];if(je(L,I.name),I.size===0)continue;if(qe(L,I.name,D),I.size>e.maxFileSize)throw m.business(`File ${I.name} is too large. Maximum allowed size is ${e.maxFileSize/(1024*1024)}MB.`);if(h+=I.size,h>e.maxTotalSize)throw m.business(`Total deploy size is too large. Maximum allowed is ${e.maxTotalSize/(1024*1024)}MB.`);let{md5:N}=await B(I);g.push({path:L,content:I,size:I.size,md5:N})}if(g.length>e.maxFilesCount)throw m.business(`Too many files to deploy. Maximum allowed is ${e.maxFilesCount} files.`);return g}var fe=P(()=>{"use strict";b();se();ae();ce();W();de()});b();b();b();var j=class{constructor(){this.handlers=new Map}on(n,e){this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n)?.add(e)}off(n,e){let o=this.handlers.get(n);o&&(o.delete(e),o.size===0&&this.handlers.delete(n))}emit(n,...e){let o=this.handlers.get(n);if(!o)return;let l=Array.from(o);for(let c of l)try{c(...e)}catch(f){o.delete(c),n!=="error"&&setTimeout(()=>{let y=f instanceof Error?f:new Error(String(f));this.emit("error",y,String(n))},0)}}};b();b();function M(t){if(t==null)return;if(t.length===0)return t;if(t.length>F.MAX_COUNT)throw m.validation(`Maximum ${F.MAX_COUNT} labels allowed`);let n=t.map((o,l)=>{if(typeof o!="string")throw m.validation(`Label at index ${l} must be a string`);let c=o.trim().toLowerCase();if(c.length<F.MIN_LENGTH)throw m.validation(`Labels must be at least ${F.MIN_LENGTH} characters long`);if(c.length>F.MAX_LENGTH)throw m.validation(`Labels must be no more than ${F.MAX_LENGTH} characters long`);if(!Pe.test(c))throw m.validation(`Labels must start and end with alphanumeric characters, with optional separators (${F.SEPARATORS}) between segments`);return c}),e=[...new Set(n)];if(e.length!==n.length)throw m.validation("Duplicate labels are not allowed");return e}async function _e(t){let n=t.find(l=>l.path===x||l.path===`/${x}`);if(!n)return;let e=n.content,o=typeof e.text=="function"?await e.text():n.content.toString("utf8");be(o)}var gt=3e4,Et=2,At=300,Dt=2e3,Tt=new Set([500,502,503,504]);function St(t,n){return new Promise((e,o)=>{if(n?.aborted){o(n.reason);return}let l=()=>{clearTimeout(f),n?.removeEventListener("abort",c)},c=()=>{l(),o(n?.reason)},f=setTimeout(()=>{l(),e()},t);n?.addEventListener("abort",c)})}var ve=3e5,Rt=3e5,bt=ve+Rt,It="sdk";function re(t){let n=new URLSearchParams;t?.limit!==void 0&&n.set("limit",String(t.limit)),t?.cursor!==void 0&&n.set("cursor",t.cursor);let e=n.toString();return e?`?${e}`:""}var q=class extends j{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||te,this.getAuthHeadersCallback=e.getAuthHeaders,this.session=e.session??!1,this.caller=e.caller,this.timeout=e.timeout??gt,this.maxRetries=Math.max(0,e.maxRetries??Et),this.deployTimeout=e.timeout??ve,this.deployBuildTimeout=e.timeout??bt,this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||T.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}async executeRequest(e,o,l,c=this.timeout){for(let f=0;;f++)try{return await this.attemptOnce(e,o,l,c)}catch(y){let d=m.fromFetchError(y,l);if(f>=this.maxRetries||!this.isRetryable(d,o))throw d;let g=Math.min(Dt,At*2**f);try{await St(Math.random()*g,o.signal)}catch(h){let D=m.fromFetchError(h,l);throw this.emit("error",D,e),D}}}isRetryable(e,o){if(o.signal?.aborted||e.isType(E.Maintenance)||e.isType(E.Cancelled)||!(e.isNetworkError()||e.status!==void 0&&Tt.has(e.status)))return!1;let c=(o.method??"GET").toUpperCase();return c==="GET"||c==="HEAD"?!0:c==="PUT"||c==="DELETE"?!1:this.hasIdempotencyKey(o.headers)}hasIdempotencyKey(e){if(!e)return!1;let o=U.HEADER.toLowerCase(),l=!1,c=f=>{f.toLowerCase()===o&&(l=!0)};if(e instanceof Headers)e.forEach((f,y)=>{c(y)});else if(Array.isArray(e))for(let[f]of e)c(f);else for(let f of Object.keys(e))c(f);return l}async attemptOnce(e,o,l,c=this.timeout){let f=()=>{};try{let y=await this.mergeHeaders(o.headers),d=this.createTimeoutSignal(o.signal,c);f=d.cleanup;let g={...o,headers:y,credentials:this.session&&!y.Authorization?"include":void 0,signal:d.signal};this.emit("request",e,g);let h=await this.fetch(e,g);if(f(),!h.ok)throw await m.fromHttpResponse(h,l);return this.emit("response",this.safeClone(h),e),{data:await this.parseResponse(this.safeClone(h)),status:h.status}}catch(y){f();let d=m.fromFetchError(y,l);throw this.emit("error",d,e),d}}async request(e,o,l,c){let{data:f}=await this.executeRequest(e,o,l,c);return f}async requestWithStatus(e,o,l){return this.executeRequest(e,o,l)}async mergeHeaders(e={}){return{...this.globalHeaders,...this.caller?{[$.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e,o=this.timeout){let l=new AbortController,c=setTimeout(()=>l.abort(new DOMException(`Timed out after ${o}ms`,"TimeoutError")),o),f=e?()=>l.abort(e.reason):void 0;return e&&f&&(e.addEventListener("abort",f),e.aborted&&l.abort(e.reason)),{signal:l.signal,cleanup:()=>{clearTimeout(c),e&&f&&e.removeEventListener("abort",f)}}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async deploy(e,o={}){if(!e.length)throw m.business("No files to deploy");for(let g of e)if(!g.md5)throw m.file(`MD5 checksum missing for file: ${g.path}`,{filePath:g.path});ne(o.password);let l=Ee(o.idempotencyKey),c=M(o.labels);await _e(e);let f=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa}:void 0,{body:y,headers:d}=await this.createDeployBody(e,{labels:c,via:o.via??It,password:o.password,flags:f,captcha:o.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:y,headers:l?{...d,[U.HEADER]:l}:d,signal:o.signal||null},"Deploy",o.build||o.prerender?this.deployBuildTimeout:this.deployTimeout)}async listDeployments(e){return this.request(`${this.apiUrl}${T.DEPLOYMENTS}${re(e)}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,o){let l=M(o);return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:l})},"Update deployment labels")}async deleteDeployment(e){return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"DELETE"},"Delete deployment")}async setDomain(e,o,l){let c=M(l),f={};o&&(f.deployment=o),c!==void 0&&(f.labels=c);let{data:y,status:d}=await this.requestWithStatus(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)},"Set domain");return{...y,isCreate:d===201}}async listDomains(e){return this.request(`${this.apiUrl}${T.DOMAINS}${re(e)}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"GET"},"Get domain")}async deleteDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"DELETE"},"Delete domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN_VERIFY(encodeURIComponent(e))}`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${T.DOMAIN_DNS(encodeURIComponent(e))}`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${T.DOMAIN_RECORDS(encodeURIComponent(e))}`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${T.DOMAIN_SHARE(encodeURIComponent(e))}`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${T.DOMAINS_VALIDATE}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,o){let l=M(o),c={};return e!==void 0&&(c.ttl=e),l!==void 0&&(c.labels=l),this.request(`${this.apiUrl}${T.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"Create token")}async listTokens(e){return this.request(`${this.apiUrl}${T.TOKENS}${re(e)}`,{method:"GET"},"List tokens")}async deleteToken(e){return this.request(`${this.apiUrl}${T.TOKEN(encodeURIComponent(e))}`,{method:"DELETE"},"Delete token")}async getToken(e){return this.request(`${this.apiUrl}${T.TOKEN(encodeURIComponent(e))}`,{method:"GET"},"Get token")}async getAccount(){return this.request(`${this.apiUrl}${T.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${T.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return this.request(`${this.apiUrl}${T.PING}`,{method:"GET"},"Ping")}async checkSPA(e,o={}){let l=e.find(d=>d.path===Y.INDEX_FILE||d.path===`/${Y.INDEX_FILE}`);if(!l||l.size>Y.MAX_INDEX_BYTES)return!1;let c;if(typeof Buffer<"u"&&Buffer.isBuffer(l.content))c=l.content.toString("utf-8");else if(typeof Blob<"u"&&l.content instanceof Blob)c=await l.content.text();else if(typeof File<"u"&&l.content instanceof File)c=await l.content.text();else return!1;let f={files:e.map(d=>d.path),index:c};return(await this.request(`${this.apiUrl}${T.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)},"SPA check")).isSPA}};b();b();W();async function _t(){let t=JSON.stringify(Re,null,2),n;typeof Buffer<"u"?n=Buffer.from(t,"utf-8"):n=new Blob([t],{type:"application/json"});let{md5:e}=await B(n);return{path:x,content:n,size:t.length,md5:e}}async function Ce(t,n,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||t.some(o=>o.path===x))return t;try{if(await n.checkSPA(t,e)){let l=await _t();return[...t,l]}}catch{}return t}function $e(t){let{getApi:n,ensureInit:e,processInput:o}=t;return{upload:async(l,c={})=>{if(await e(),!o)throw m.config("processInput function is not provided.");let f=n(),y=await o(l,c);return y=await Ce(y,f,c),f.deploy(y,c)},list:async l=>(await e(),n().listDeployments(l)),get:async l=>(await e(),n().getDeployment(l)),set:async(l,c)=>(await e(),n().updateDeploymentLabels(l,c.labels)),delete:async l=>(await e(),n().deleteDeployment(l))}}function Ue(t){let{getApi:n,ensureInit:e}=t;return{set:async(o,l={})=>(await e(),n().setDomain(o,l.deployment,l.labels)),list:async o=>(await e(),n().listDomains(o)),get:async o=>(await e(),n().getDomain(o)),delete:async o=>(await e(),n().deleteDomain(o)),verify:async o=>(await e(),n().verifyDomain(o)),validate:async o=>(await e(),n().validateDomain(o)),dns:async o=>(await e(),n().getDomainDns(o)),records:async o=>(await e(),n().getDomainRecords(o)),share:async o=>(await e(),n().getDomainShare(o))}}function Me(t){let{getApi:n,ensureInit:e}=t;return{get:async()=>(await e(),n().getAccount())}}function Be(t){let{getApi:n,ensureInit:e}=t;return{create:async(o={})=>(await e(),n().createToken(o.ttl,o.labels)),list:async o=>(await e(),n().listTokens(o)),get:async o=>(await e(),n().getToken(o)),delete:async o=>(await e(),n().deleteToken(o))}}var J=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&&we(n.caller),n.token&&n.session)throw m.config("Provide either `token` or `session`, not both.");typeof n.token=="string"?(ee(n.token),this.credential=n.token):n.token&&(this.credential=n.token),this.http=new q({...n,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let e={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=$e({...e,processInput:(o,l)=>this.processInput(o,l)}),this.domains=Ue(e),this.account=Me(e),this.tokens=Be(e)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(n){throw this.initPromise=null,n}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(n,e){return this.deployments.upload(n,e)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(n,e){this.http.on(n,e)}off(n,e){this.http.off(n,e)}setHeaders(n){this.http.setGlobalHeaders(n)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(n){if(this.clientOptions.session)throw m.config("Provide either `token` or `session`, not both.");if(typeof n=="string"){if(!n)throw m.business("Invalid token provided. Token must be a non-empty string.");ee(n),this.credential=n;return}if(typeof n!="function")throw m.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 m.authentication("Token provider returned no token.");if(typeof n!="string")throw m.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${n}`}}};b();async function He(t,n={}){let{labels:e,via:o,password:l,flags:c,captcha:f}=n,y=new FormData,d=[];for(let g of t){if(!(g.content instanceof File||g.content instanceof Blob))throw m.file(`Unsupported file.content type for browser: ${g.path}`,{filePath:g.path});if(!g.md5)throw m.file(`File missing md5 checksum: ${g.path}`,{filePath:g.path});let h=new File([g.content],g.path,{type:"application/octet-stream"});y.append(_.FILES,h),d.push(g.md5)}return y.append(_.CHECKSUMS,JSON.stringify(d)),e&&e.length>0&&y.append(_.LABELS,JSON.stringify(e)),o&&y.append(_.VIA,o),l&&y.append(_.PASSWORD,l),c?.build&&y.append(_.BUILD,"true"),c?.prerender&&y.append(_.PRERENDER,"true"),c?.spa&&y.append(_.SPA,"true"),f&&y.append(_.CAPTCHA,f),{body:y,headers:{}}}b();b();se();ae();ue();ce();W();de();function Kn(t,n,e,o=!0){let l=t===1?n:e;return o?`${t} ${l}`:l}fe();var me=class extends J{async deploy(n,e){return super.deploy(n,e)}async processInput(n,e){if(!Array.isArray(n)||!n.every(l=>l instanceof File))throw m.business("Invalid input type for browser environment. Expected File[].");if(n.length===0)throw m.business("No files to deploy.");let{processFilesForBrowser:o}=await Promise.resolve().then(()=>(fe(),We));return o(n,e,this.platformLimits??void 0)}getDeployBodyCreator(){return He}},hr=me;export{Te as API_KEY,T as API_PATHS,kt as AUTH_BASE_PATH,Ht as AccountPlan,q as ApiHttp,ge as AuthMethod,$ as CALLER,te as DEFAULT_API,x as DEPLOYMENT_CONFIG_FILENAME,_ as DEPLOY_FIELDS,Se as DEPLOY_TOKEN,Ut as DeploymentStatus,st as DeploymentVia,Mt as DomainStatus,E as ErrorType,R as FILE_VALIDATION_STATUS,R as FileValidationStatus,U as IDEMPOTENCY_KEY_CONSTRAINTS,Ct as JUNK_DIRECTORIES,F as LABEL_CONSTRAINTS,Pe as LABEL_PATTERN,jt as MY_API_KEY_URL,zt as OAuthScope,z as PASSWORD_CONSTRAINTS,qt as PUBLIC_DEPLOYMENT_TTL_SECONDS,Yt as SHIP_ENV,Y as SPA_CHECK_CONSTRAINTS,Re as SPA_DEFAULT_CONFIG,me as Ship,m as ShipError,C as TokenKind,ft as UNBUILT_PROJECT_MARKERS,dt as UNSAFE_FILENAME_CHARS,Gt as WEB_FILE_ACCEPT,Nn as __setTestEnvironment,$n as allValidFilesReady,be as assertShipJsonSyntax,B as calculateMD5,mt as classifyToken,Me as createAccountResource,$e as createDeploymentResource,Ue as createDomainResource,Be as createTokenResource,hr as default,en as deserializeLabels,Wt as extractSubdomain,Ye as filterJunk,le as formatFileSize,Jt as generateDeploymentUrl,Qt as generateDomainUrl,ze as getENV,Nt as getValidFiles,K as hasUnbuiltMarker,De as hasUnsafeChars,V as isBlockedExtension,Xt as isCustomDomain,Kt as isDeployment,Le as isPlatformDomain,Ae as isShipError,Bt as normalizeVia,ke as optimizeDeployPaths,Kn as pluralize,Xe as processFilesForBrowser,Zt as serializeLabels,ht as validateApiKey,Vt as validateApiUrl,we as validateCaller,qe as validateDeployFile,je as validateDeployPath,yt as validateDeployToken,pe as validateFileName,Cn as validateFiles,Ee as validateIdempotencyKey,ne as validatePassword,ee as validateToken};
1
+ var Ze=Object.create;var H=Object.defineProperty;var et=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty;var it=(t,n,e)=>n in t?H(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var w=(t,n)=>()=>(t&&(n=t(t=0)),n);var ge=(t,n)=>()=>(n||t((n={exports:{}}).exports,n),n.exports),st=(t,n)=>{for(var e in n)H(t,e,{get:n[e],enumerable:!0})},ot=(t,n,e,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of tt(n))!rt.call(t,l)&&l!==e&&H(t,l,{get:()=>n[l],enumerable:!(o=et(n,l))||o.enumerable});return t};var k=(t,n,e)=>(e=t!=null?Ze(nt(t)):{},ot(n||!t||!t.__esModule?H(e,"default",{value:t,enumerable:!0}):e,t));var G=(t,n,e)=>it(t,typeof n!="symbol"?n+"":n,e);function Gt(t){if(!t||typeof t!="string")return;let n=t.trim().toLowerCase();return Object.values(at).includes(n)?n:void 0}function Ae(t){if(t==null)return;if(typeof t!="string")throw m.validation("Idempotency key must be a string.");let n=t.trim();if(!n)throw m.validation("Idempotency key must not be empty.");if(n.length>U.MAX_LENGTH)throw m.validation(`Idempotency key must be at most ${U.MAX_LENGTH} characters.`);return n}function ct(t){let n=t.code;return n==="ERR_INVALID_URL"?!1:typeof n=="string"?!0:t instanceof TypeError?!/\burl\b/i.test(t.message):!1}function De(t){return t!==null&&typeof t=="object"&&"name"in t&&t.name==="ShipError"&&"status"in t}function ft(t){let n=t.replace(/\\/g,"/").split("/").pop()??"",e=n.lastIndexOf(".");return e<=0||e===n.length-1?null:n.slice(e+1).toLowerCase()}function Te(t,n){let e=ft(t);return e===null?!1:Array.isArray(n)?n.includes(e):n.has(e)}function Se(t){return mt.test(t)}function K(t){return t.replace(/\\/g,"/").split("/").filter(Boolean).some(e=>ht.has(e))}function yt(t){return t.startsWith(Re.PREFIX)?O.API_KEY:t.startsWith(be.PREFIX)?O.DEPLOY_TOKEN:O.OPAQUE}function we(t){let n=t.charCodeAt(0)===65279?t.slice(1):t,e;try{e=JSON.parse(n)}catch(o){throw m.config(`invalid JSON format in config: ${o.message}`,{filePath:v})}if(e===null||typeof e!="object"||Array.isArray(e))throw m.config(`${v} must contain a JSON object`,{filePath:v})}function Le(t,n,e){if(!t.startsWith(n.PREFIX))throw m.validation(`${e} must start with "${n.PREFIX}"`);if(t.length!==n.TOTAL_LENGTH)throw m.validation(`${e} must be ${n.TOTAL_LENGTH} characters total (${n.PREFIX} + ${n.HEX_LENGTH} hex chars)`);let o=t.slice(n.PREFIX.length);if(!new RegExp(`^[a-f0-9]{${n.HEX_LENGTH}}$`,"i").test(o))throw m.validation(`${e} must contain ${n.HEX_LENGTH} hexadecimal characters after "${n.PREFIX}" prefix`)}function gt(t){Le(t,Re,"API key")}function Et(t){Le(t,be,"Deploy token")}function te(t){switch(yt(t)){case O.API_KEY:gt(t);return;case O.DEPLOY_TOKEN:Et(t);return;case O.OPAQUE:if(!t)throw m.validation("Token must be a non-empty string")}}function Pe(t){if(!t||t.length>$.MAX_LENGTH||!$.PATTERN.test(t))throw m.validation(`Caller must be 1-${$.MAX_LENGTH} characters: letters, digits, dots, underscores, or hyphens`)}function jt(t){try{let n=new URL(t);if(!["http:","https:"].includes(n.protocol))throw m.validation("API URL must use http:// or https:// protocol");if(n.pathname!=="/"&&n.pathname!=="")throw m.validation("API URL must not contain a path");if(n.search||n.hash)throw m.validation("API URL must not contain query parameters or fragments")}catch(n){throw De(n)?n:m.validation("API URL must be a valid URL")}}function qt(t){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(t)}function _e(t,n){return t.endsWith(`.${n}`)}function Qt(t,n){return!_e(t,n)}function Zt(t,n){return _e(t,n)?t.slice(0,-(n.length+1)):null}function en(t){return`https://${t}`}function tn(t){return`https://${t}`}function nn(t){return!t||t.length===0?null:JSON.stringify(t)}function rn(t){if(!t)return[];try{let n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function re(t){if(t==null)return;if(typeof t!="string")throw m.validation("Password must be a string");let n=t.trim();if(n.length<z.MIN_LENGTH||n.length>z.MAX_LENGTH)throw m.validation(`Password must be between ${z.MIN_LENGTH} and ${z.MAX_LENGTH} characters`);return n}var Ht,at,kt,U,zt,T,P,A,lt,ee,pt,ut,m,dt,Kt,mt,ht,Vt,Ee,Re,be,$,O,Yt,v,Ie,V,ne,Xt,Wt,Jt,b,N,ve,z,R=w(()=>{"use strict";Ht={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},at={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc"},kt={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},U={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};zt={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},T={DEPLOYMENTS:"/deployments",DEPLOYMENT:t=>`/deployments/${t}`,DEPLOYMENT_CONFIG:t=>`/deployments/${t}/config`,DOMAINS:"/domains",DOMAIN:t=>`/domains/${t}`,DOMAIN_VERIFY:t=>`/domains/${t}/verify`,DOMAIN_DNS:t=>`/domains/${t}/dns`,DOMAIN_RECORDS:t=>`/domains/${t}/records`,DOMAIN_SHARE:t=>`/domains/${t}/share`,DOMAIN_PROPAGATION:t=>`/domains/${t}/propagation`,DOMAINS_VALIDATE:"/domains/validate",TOKENS:"/tokens",TOKEN:t=>`/tokens/${t}`,ACCOUNT:"/account",ACCOUNT_KEY:"/account/key",ACCOUNT_CLAIM:"/account/claim",ACTIVITIES:"/activities",LABELS:"/labels",LIMITS:"/limits",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},P={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",BUILD:"build",PRERENDER:"prerender",SPA:"spa",CAPTCHA:"captcha"},A={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",Network:"network_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},lt=new Set([A.Network,A.Cancelled,A.File,A.Config]),ee={client:new Set([A.Business,A.Cancelled,A.Config,A.File,A.Forbidden,A.NotFound,A.RateLimit,A.Validation]),network:new Set([A.Network]),auth:new Set([A.Authentication])},pt=new Set(Object.values(A).filter(t=>!lt.has(t))),ut=200;m=class t extends Error{constructor(e,o,l,c){super(o);G(this,"type");G(this,"status");G(this,"details");this.type=e,this.status=l,this.details=c,this.name="ShipError"}toResponse(){let e=this.details,o=this.type===A.Authentication&&e?.internal?void 0:this.details;return{error:this.type,message:this.message,status:this.status,details:o}}static async fromHttpResponse(e,o){let l,c,d;try{if(e.headers.get("content-type")?.includes("application/json")){let y=await e.json();if(y&&typeof y=="object"){let E=y;typeof E.message=="string"?l=E.message:typeof E.error=="string"&&(l=E.error),c=E.details,typeof E.error=="string"&&pt.has(E.error)&&(d=E.error)}}else{let y=(await e.text()).trim();y&&!y.startsWith("<")&&y.length<=ut&&(l=y)}}catch{}let h=e.headers.get("retry-after");if(h!==null){let g=h.trim(),y=/^\d+$/.test(g)?Number(g):Math.ceil((Date.parse(g)-Date.now())/1e3);if(Number.isFinite(y)&&y>=0){let E=c&&typeof c=="object"?c:{};E.retryAfter===void 0&&(c={...E,retryAfter:y})}}l=l||`${o||"Request"} failed with status ${e.status}`;let f=d??(e.status===401?A.Authentication:e.status===403?A.Forbidden:e.status===429?A.RateLimit:A.Api);return new t(f,l,e.status,c)}static fromFetchError(e,o){if(De(e))return e;let l=o||"Request",c=e?.name;return c==="AbortError"?t.cancelled(`${l} was cancelled`):c==="TimeoutError"?t.network(`${l} timed out`,{cause:e}):e instanceof Error?ct(e)?t.network(`${l} failed: ${e.message}`,{cause:e}):new t(A.Api,`${l} failed: ${e.message}`):new t(A.Api,`${l} failed: Unknown error`)}static validation(e,o){return new t(A.Validation,e,400,o)}static notFound(e,o){let l=o?`${e} ${o} not found`:`${e} not found`;return new t(A.NotFound,l,404)}static forbidden(e,o){return new t(A.Forbidden,e,403,o)}static rateLimit(e="Too many requests",o){return new t(A.RateLimit,e,429,o)}static authentication(e="Authentication required",o){return new t(A.Authentication,e,401,o)}static business(e,o=400,l){return new t(A.Business,e,o,l)}static network(e,o){return new t(A.Network,e,void 0,o)}static cancelled(e,o){return new t(A.Cancelled,e,void 0,o)}static file(e,o){return new t(A.File,e,void 0,o)}static config(e,o){return new t(A.Config,e,void 0,o)}static api(e,o=500,l){return new t(A.Api,e,o,l)}static maintenance(e,o){return new t(A.Maintenance,e,503,o)}isClientError(){return ee.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return ee.network.has(this.type)}isAuthError(){return ee.auth.has(this.type)}isType(e){return this.type===e}};dt=["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"],Kt=dt.map(t=>`.${t}`).join(","),mt=/[\x00-\x1f\x7f#?%\\<>"]/;ht=new Set(["node_modules","package.json"]);Vt="/auth",Ee={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},Re={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},be={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},$={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},O={API_KEY:Ee.API_KEY,DEPLOY_TOKEN:Ee.TOKEN,OPAQUE:"opaque"};Yt={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},v="ship.json",Ie={rewrites:[{source:"/(.*)",destination:"/index.html"}]},V={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};ne="https://api.shipstatic.com",Xt={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},Wt="https://my.shipstatic.com/api-key",Jt=4320*60,b={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};N={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},ve=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;z={MIN_LENGTH:6,MAX_LENGTH:128}});var Ce=ge((Fe,Oe)=>{"use strict";(function(t){if(typeof Fe=="object")Oe.exports=t();else if(typeof define=="function"&&define.amd)define(t);else{var n;try{n=window}catch{n=self}n.SparkMD5=t()}})(function(t){"use strict";var n=function(u,p){return u+p&4294967295},e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function o(u,p,i,r,a,s){return p=n(n(p,u),n(r,s)),n(p<<a|p>>>32-a,i)}function l(u,p){var i=u[0],r=u[1],a=u[2],s=u[3];i+=(r&a|~r&s)+p[0]-680876936|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[1]-389564586|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[2]+606105819|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[3]-1044525330|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&s)+p[4]-176418897|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[5]+1200080426|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[6]-1473231341|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[7]-45705983|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&s)+p[8]+1770035416|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[9]-1958414417|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[10]-42063|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[11]-1990404162|0,r=(r<<22|r>>>10)+a|0,i+=(r&a|~r&s)+p[12]+1804603682|0,i=(i<<7|i>>>25)+r|0,s+=(i&r|~i&a)+p[13]-40341101|0,s=(s<<12|s>>>20)+i|0,a+=(s&i|~s&r)+p[14]-1502002290|0,a=(a<<17|a>>>15)+s|0,r+=(a&s|~a&i)+p[15]+1236535329|0,r=(r<<22|r>>>10)+a|0,i+=(r&s|a&~s)+p[1]-165796510|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[6]-1069501632|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[11]+643717713|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[0]-373897302|0,r=(r<<20|r>>>12)+a|0,i+=(r&s|a&~s)+p[5]-701558691|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[10]+38016083|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[15]-660478335|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[4]-405537848|0,r=(r<<20|r>>>12)+a|0,i+=(r&s|a&~s)+p[9]+568446438|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[14]-1019803690|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[3]-187363961|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[8]+1163531501|0,r=(r<<20|r>>>12)+a|0,i+=(r&s|a&~s)+p[13]-1444681467|0,i=(i<<5|i>>>27)+r|0,s+=(i&a|r&~a)+p[2]-51403784|0,s=(s<<9|s>>>23)+i|0,a+=(s&r|i&~r)+p[7]+1735328473|0,a=(a<<14|a>>>18)+s|0,r+=(a&i|s&~i)+p[12]-1926607734|0,r=(r<<20|r>>>12)+a|0,i+=(r^a^s)+p[5]-378558|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[8]-2022574463|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[11]+1839030562|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[14]-35309556|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^s)+p[1]-1530992060|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[4]+1272893353|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[7]-155497632|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[10]-1094730640|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^s)+p[13]+681279174|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[0]-358537222|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[3]-722521979|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[6]+76029189|0,r=(r<<23|r>>>9)+a|0,i+=(r^a^s)+p[9]-640364487|0,i=(i<<4|i>>>28)+r|0,s+=(i^r^a)+p[12]-421815835|0,s=(s<<11|s>>>21)+i|0,a+=(s^i^r)+p[15]+530742520|0,a=(a<<16|a>>>16)+s|0,r+=(a^s^i)+p[2]-995338651|0,r=(r<<23|r>>>9)+a|0,i+=(a^(r|~s))+p[0]-198630844|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[7]+1126891415|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[14]-1416354905|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[5]-57434055|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~s))+p[12]+1700485571|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[3]-1894986606|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[10]-1051523|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[1]-2054922799|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~s))+p[8]+1873313359|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[15]-30611744|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[6]-1560198380|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[13]+1309151649|0,r=(r<<21|r>>>11)+a|0,i+=(a^(r|~s))+p[4]-145523070|0,i=(i<<6|i>>>26)+r|0,s+=(r^(i|~a))+p[11]-1120210379|0,s=(s<<10|s>>>22)+i|0,a+=(i^(s|~r))+p[2]+718787259|0,a=(a<<15|a>>>17)+s|0,r+=(s^(a|~i))+p[9]-343485551|0,r=(r<<21|r>>>11)+a|0,u[0]=i+u[0]|0,u[1]=r+u[1]|0,u[2]=a+u[2]|0,u[3]=s+u[3]|0}function c(u){var p=[],i;for(i=0;i<64;i+=4)p[i>>2]=u.charCodeAt(i)+(u.charCodeAt(i+1)<<8)+(u.charCodeAt(i+2)<<16)+(u.charCodeAt(i+3)<<24);return p}function d(u){var p=[],i;for(i=0;i<64;i+=4)p[i>>2]=u[i]+(u[i+1]<<8)+(u[i+2]<<16)+(u[i+3]<<24);return p}function h(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,a,s,I,_,x;for(r=64;r<=p;r+=64)l(i,c(u.substring(r-64,r)));for(u=u.substring(r-64),a=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<a;r+=1)s[r>>2]|=u.charCodeAt(r)<<(r%4<<3);if(s[r>>2]|=128<<(r%4<<3),r>55)for(l(i,s),r=0;r<16;r+=1)s[r]=0;return I=p*8,I=I.toString(16).match(/(.*?)(.{0,8})$/),_=parseInt(I[2],16),x=parseInt(I[1],16)||0,s[14]=_,s[15]=x,l(i,s),i}function f(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,a,s,I,_,x;for(r=64;r<=p;r+=64)l(i,d(u.subarray(r-64,r)));for(u=r-64<p?u.subarray(r-64):new Uint8Array(0),a=u.length,s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],r=0;r<a;r+=1)s[r>>2]|=u[r]<<(r%4<<3);if(s[r>>2]|=128<<(r%4<<3),r>55)for(l(i,s),r=0;r<16;r+=1)s[r]=0;return I=p*8,I=I.toString(16).match(/(.*?)(.{0,8})$/),_=parseInt(I[2],16),x=parseInt(I[1],16)||0,s[14]=_,s[15]=x,l(i,s),i}function g(u){var p="",i;for(i=0;i<4;i+=1)p+=e[u>>i*8+4&15]+e[u>>i*8&15];return p}function y(u){var p;for(p=0;p<u.length;p+=1)u[p]=g(u[p]);return u.join("")}y(h("hello"))!=="5d41402abc4b2a76b9719d911017c592"&&(n=function(u,p){var i=(u&65535)+(p&65535),r=(u>>16)+(p>>16)+(i>>16);return r<<16|i&65535}),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&(function(){function u(p,i){return p=p|0||0,p<0?Math.max(p+i,0):Math.min(p,i)}ArrayBuffer.prototype.slice=function(p,i){var r=this.byteLength,a=u(p,r),s=r,I,_,x,ye;return i!==t&&(s=u(i,r)),a>s?new ArrayBuffer(0):(I=s-a,_=new ArrayBuffer(I),x=new Uint8Array(_),ye=new Uint8Array(this,a,I),x.set(ye),_)}})();function E(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function S(u,p){var i=u.length,r=new ArrayBuffer(i),a=new Uint8Array(r),s;for(s=0;s<i;s+=1)a[s]=u.charCodeAt(s);return p?a:r}function L(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function C(u,p,i){var r=new Uint8Array(u.byteLength+p.byteLength);return r.set(new Uint8Array(u)),r.set(new Uint8Array(p),u.byteLength),i?r:r.buffer}function F(u){var p=[],i=u.length,r;for(r=0;r<i-1;r+=2)p.push(parseInt(u.substr(r,2),16));return String.fromCharCode.apply(String,p)}function D(){this.reset()}return D.prototype.append=function(u){return this.appendBinary(E(u)),this},D.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var p=this._buff.length,i;for(i=64;i<=p;i+=64)l(this._hash,c(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},D.prototype.end=function(u){var p=this._buff,i=p.length,r,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],s;for(r=0;r<i;r+=1)a[r>>2]|=p.charCodeAt(r)<<(r%4<<3);return this._finish(a,i),s=y(this._hash),u&&(s=F(s)),this.reset(),s},D.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},D.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},D.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},D.prototype._finish=function(u,p){var i=p,r,a,s;if(u[i>>2]|=128<<(i%4<<3),i>55)for(l(this._hash,u),i=0;i<16;i+=1)u[i]=0;r=this._length*8,r=r.toString(16).match(/(.*?)(.{0,8})$/),a=parseInt(r[2],16),s=parseInt(r[1],16)||0,u[14]=a,u[15]=s,l(this._hash,u)},D.hash=function(u,p){return D.hashBinary(E(u),p)},D.hashBinary=function(u,p){var i=h(u),r=y(i);return p?F(r):r},D.ArrayBuffer=function(){this.reset()},D.ArrayBuffer.prototype.append=function(u){var p=C(this._buff.buffer,u,!0),i=p.length,r;for(this._length+=u.byteLength,r=64;r<=i;r+=64)l(this._hash,d(p.subarray(r-64,r)));return this._buff=r-64<i?new Uint8Array(p.buffer.slice(r-64)):new Uint8Array(0),this},D.ArrayBuffer.prototype.end=function(u){var p=this._buff,i=p.length,r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,s;for(a=0;a<i;a+=1)r[a>>2]|=p[a]<<(a%4<<3);return this._finish(r,i),s=y(this._hash),u&&(s=F(s)),this.reset(),s},D.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},D.ArrayBuffer.prototype.getState=function(){var u=D.prototype.getState.call(this);return u.buff=L(u.buff),u},D.ArrayBuffer.prototype.setState=function(u){return u.buff=S(u.buff,!0),D.prototype.setState.call(this,u)},D.ArrayBuffer.prototype.destroy=D.prototype.destroy,D.ArrayBuffer.prototype._finish=D.prototype._finish,D.ArrayBuffer.hash=function(u,p){var i=f(new Uint8Array(u)),r=y(i);return p?F(r):r},D})});var q=ge((hn,$e)=>{"use strict";$e.exports={}});async function Pt(t){let n=(await Promise.resolve().then(()=>k(Ce(),1))).default,e=new n.ArrayBuffer,o=2097152;for(let l=0;l<t.size;l+=o){let c=Math.min(l+o,t.size);e.append(await t.slice(l,c).arrayBuffer())}return{md5:e.end()}}async function _t(t){let{createHash:n}=await Promise.resolve().then(()=>k(q(),1)),e=n("md5");return e.update(t),{md5:e.digest("hex")}}async function vt(t){let{createHash:n}=await Promise.resolve().then(()=>k(q(),1)),{createReadStream:e}=await Promise.resolve().then(()=>k(q(),1));return new Promise((o,l)=>{let c=n("md5"),d=e(t);d.on("error",h=>l(m.file(`Failed to read file for MD5: ${h.message}`,{filePath:t}))),d.on("data",h=>c.update(h)),d.on("end",()=>o({md5:c.digest("hex")}))})}async function B(t){if(t instanceof Blob)return Pt(t);if(typeof Buffer<"u"&&Buffer.isBuffer(t))return _t(t);if(typeof t=="string")return vt(t);throw m.business("Invalid input for MD5 calculation")}var X=w(()=>{"use strict";R()});function J(t){return t.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var ze=w(()=>{"use strict"});function Ke(t,n={}){if(n.flatten===!1)return t.map(o=>({path:J(o),name:se(o)}));let e=Nt(t);return t.map(o=>{let l=J(o);if(e){let c=e.endsWith("/")?e:`${e}/`;l.startsWith(c)&&(l=l.substring(c.length))}return l||(l=se(o)),{path:l,name:se(o)}})}function Nt(t){if(!t.length)return"";let e=t.map(c=>J(c)).map(c=>c.split("/")),o=[],l=Math.min(...e.map(c=>c.length));for(let c=0;c<l-1;c++){let d=e[0][c];if(e.every(h=>h[c]===d))o.push(d);else break}return o.join("/")}function se(t){return t.split(/[/\\]/).pop()||t}var oe=w(()=>{"use strict";ze()});function Cn(t){ae=t}function Ft(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function Ve(){return ae||Ft()}var ae,le=w(()=>{"use strict";ae=null});function Z(t,n){return Ot.find(e=>e.broken(t,n))}var Ot,ue=w(()=>{"use strict";R();ce();Ot=[{name:"name",broken:({path:t})=>!pe(t).valid,sentence:({path:t})=>pe(t).reason??"Invalid file name"},{name:"extension",broken:({path:t},n)=>Te(t,n.blockedExtensions??[]),sentence:({path:t})=>`File extension not allowed: "${t}"`},{name:"fileSize",broken:({size:t},n)=>t>n.maxFileSize,sentence:({path:t},n)=>`File "${t}" too large. Maximum ${Q(n.maxFileSize)} allowed`},{name:"totalSize",broken:({totalSize:t},n)=>t>n.maxTotalSize,sentence:({totalSize:t},n)=>`Total upload size too large. ${Q(t)} exceeds maximum of ${Q(n.maxTotalSize)}`}]});function Q(t,n=1){if(t===0)return"0 Bytes";let e=1024,o=["Bytes","KB","MB","GB"],l=Math.floor(Math.log(t)/Math.log(e));return`${parseFloat((t/e**l).toFixed(n))} ${o[l]}`}function pe(t){if(Se(t))return{valid:!1,reason:"File name contains unsafe characters"};if(t.startsWith(" ")||t.endsWith(" "))return{valid:!1,reason:"File name cannot start/end with spaces"};if(t.endsWith("."))return{valid:!1,reason:"File name cannot end with dots"};let n=/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])(\.|$)/i,e=t.split("/").pop()||t;return n.test(e)?{valid:!1,reason:"File name uses a reserved system name"}:t.includes("..")?{valid:!1,reason:"File name contains path traversal pattern"}:{valid:!0}}function Gn(t,n){let e=[],o=[],l=[];if(t.length===0){let f={file:"(no files)",message:"At least one file must be provided"};return e.push(f),{files:[],validFiles:[],errors:e,warnings:[],canDeploy:!1}}for(let f of t)if(K(f.name))return e.push({file:f.name,message:"Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder"}),{files:t.map(g=>({...g,status:b.VALIDATION_FAILED,statusMessage:"Unbuilt project detected"})),validFiles:[],errors:e,warnings:[],canDeploy:!1};if(t.length>n.maxFilesCount){let f={file:`(${t.length} files)`,message:`File count (${t.length}) exceeds limit of ${n.maxFilesCount}`};return e.push(f),{files:t.map(g=>({...g,status:b.VALIDATION_FAILED,statusMessage:f.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let c=0;for(let f of t){let g=b.READY,y="Ready for upload";if(f.status===b.PROCESSING_ERROR)g=b.VALIDATION_FAILED,y=f.statusMessage||"File failed during processing",e.push({file:f.name,message:y});else if(f.size===0){g=b.EXCLUDED,y="File is empty (0 bytes) and cannot be deployed due to storage limitations",o.push({file:f.name,message:y}),l.push({...f,status:g,statusMessage:y});continue}else if(f.size<0)g=b.VALIDATION_FAILED,y="File size must be positive",e.push({file:f.name,message:y});else if(!f.name||f.name.trim().length===0)g=b.VALIDATION_FAILED,y="File name cannot be empty",e.push({file:f.name||"(empty)",message:y});else if(f.name.includes("\0"))g=b.VALIDATION_FAILED,y="File name contains invalid characters (null byte)",e.push({file:f.name,message:y});else{let E={path:f.name,size:f.size,totalSize:c+f.size},S=Z(E,n);S?(g=b.VALIDATION_FAILED,y=S.sentence(E,n),e.push({file:S.name==="totalSize"?`(${t.length} files)`:f.name,message:y})):c=E.totalSize}l.push({...f,status:g,statusMessage:y})}e.length>0&&(l=l.map(f=>f.status===b.EXCLUDED?f:{...f,status:b.VALIDATION_FAILED,statusMessage:f.status===b.VALIDATION_FAILED?f.statusMessage:"Deployment failed due to validation errors in bundle"}));let d=e.length===0?l.filter(f=>f.status===b.READY):[],h=e.length===0;return{files:l,validFiles:d,errors:e,warnings:o,canDeploy:h}}function Ct(t){return t.filter(n=>n.status===b.READY)}function zn(t){return Ct(t).length>0}var ce=w(()=>{"use strict";R();ue()});function Ye(t){return Ut.test(t)}var $t,Ut,je=w(()=>{"use strict";$t=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],Ut=new RegExp($t.join("|"))});function qe(t,n){if(!t||t.length===0)return[];if(!n?.allowUnbuilt&&t.find(o=>o&&K(o)))throw m.business("Unbuilt project detected \u2014 deploy your build output (dist/, build/, out/), not the project folder");return t.filter(e=>{if(!e)return!1;let o=e.replace(/\\/g,"/").split("/").filter(Boolean);if(o.length===0)return!0;let l=o[o.length-1];if(Ye(l))return!1;for(let d of o)if(d!==".well-known"&&(d.startsWith(".")||d.length>255))return!1;let c=o.slice(0,-1);for(let d of c)if(Mt.some(h=>d.toLowerCase()===h.toLowerCase()))return!1;return!0})}var Mt,fe=w(()=>{"use strict";R();je();Mt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Xe(t,n){if(t.includes("\0")||t.includes("/../")||t.startsWith("../")||t.endsWith("/.."))throw m.business(`Security error: Unsafe file path "${t}" for file: ${n}`)}function We(t,n){let e=Z(t,n);if(e)throw m.business(e.sentence(t,n))}var de=w(()=>{"use strict";R();ue()});var Qe={};st(Qe,{processFilesForBrowser:()=>Je});async function Je(t,n={},e){if(Ve()!=="browser")throw m.business("processFilesForBrowser can only be called in a browser environment.");let o=t.map(E=>E.webkitRelativePath||E.name),l=n.build||n.prerender,c=Ke(o,{flatten:n.pathDetect!==!1}),d=c.map(E=>E.path),h=new Set(qe(d,{allowUnbuilt:l})),f=[];for(let E=0;E<t.length;E++)h.has(d[E])&&f.push({file:t[E],deployPath:c[E].path});if(f.length===0)return[];if(l){let E=[];for(let S=0;S<f.length;S++){let{file:L,deployPath:C}=f[S];if(L.size===0)continue;let{md5:F}=await B(L);E.push({path:C,content:L,size:L.size,md5:F})}return E}if(!e)throw m.config("Platform limits not provided. processFilesForBrowser requires the limits argument for deploy-mode validation \u2014 pass `ship.getLimits()` result.");let g=[],y=0;for(let E=0;E<f.length;E++){let{file:S,deployPath:L}=f[E];if(Xe(L,S.name),S.size===0)continue;y+=S.size,We({path:L,size:S.size,totalSize:y},e);let{md5:C}=await B(S);g.push({path:L,content:S,size:S.size,md5:C})}if(g.length>e.maxFilesCount)throw m.business(`Too many files to deploy. Maximum allowed is ${e.maxFilesCount} files.`);return g}var me=w(()=>{"use strict";R();oe();le();fe();X();de()});R();R();R();var Y=class{constructor(){this.handlers=new Map}on(n,e){this.handlers.has(n)||this.handlers.set(n,new Set),this.handlers.get(n)?.add(e)}off(n,e){let o=this.handlers.get(n);o&&(o.delete(e),o.size===0&&this.handlers.delete(n))}emit(n,...e){let o=this.handlers.get(n);if(!o)return;let l=Array.from(o);for(let c of l)try{c(...e)}catch(d){o.delete(c),n!=="error"&&setTimeout(()=>{let h=d instanceof Error?d:new Error(String(d));this.emit("error",h,String(n))},0)}}};R();R();function M(t){if(t==null)return;if(t.length===0)return t;if(t.length>N.MAX_COUNT)throw m.validation(`Maximum ${N.MAX_COUNT} labels allowed`);let n=t.map((o,l)=>{if(typeof o!="string")throw m.validation(`Label at index ${l} must be a string`);let c=o.trim().toLowerCase();if(c.length<N.MIN_LENGTH)throw m.validation(`Labels must be at least ${N.MIN_LENGTH} characters long`);if(c.length>N.MAX_LENGTH)throw m.validation(`Labels must be no more than ${N.MAX_LENGTH} characters long`);if(!ve.test(c))throw m.validation(`Labels must start and end with alphanumeric characters, with optional separators (${N.SEPARATORS}) between segments`);return c}),e=[...new Set(n)];if(e.length!==n.length)throw m.validation("Duplicate labels are not allowed");return e}async function xe(t){let n=t.find(l=>l.path===v||l.path===`/${v}`);if(!n)return;let e=n.content,o=typeof e.text=="function"?await e.text():n.content.toString("utf8");we(o)}var At=3e4,Dt=2,Tt=300,St=2e3,Rt=new Set([500,502,503,504]);function bt(t,n){return new Promise((e,o)=>{if(n?.aborted){o(n.reason);return}let l=()=>{clearTimeout(d),n?.removeEventListener("abort",c)},c=()=>{l(),o(n?.reason)},d=setTimeout(()=>{l(),e()},t);n?.addEventListener("abort",c)})}var Ne=3e5,It=3e5,wt=Ne+It,Lt="sdk";function ie(t){let n=new URLSearchParams;t?.limit!==void 0&&n.set("limit",String(t.limit)),t?.cursor!==void 0&&n.set("cursor",t.cursor);let e=n.toString();return e?`?${e}`:""}var j=class extends Y{constructor(e){super();this.globalHeaders={};this.apiUrl=e.apiUrl||ne,this.getAuthHeadersCallback=e.getAuthHeaders,this.session=e.session??!1,this.caller=e.caller,this.timeout=e.timeout??At,this.maxRetries=Math.max(0,e.maxRetries??Dt),this.deployTimeout=e.timeout??Ne,this.deployBuildTimeout=e.timeout??wt,this.fetch=e.fetch??globalThis.fetch.bind(globalThis),this.createDeployBody=e.createDeployBody,this.deployEndpoint=e.deployEndpoint||T.DEPLOYMENTS}setGlobalHeaders(e){this.globalHeaders=e}async executeRequest(e,o,l,c=this.timeout){for(let d=0;;d++)try{return await this.attemptOnce(e,o,l,c)}catch(h){let f=m.fromFetchError(h,l);if(d>=this.maxRetries||!this.isRetryable(f,o))throw f;let g=Math.min(St,Tt*2**d);try{await bt(Math.random()*g,o.signal)}catch(y){let E=m.fromFetchError(y,l);throw this.emit("error",E,e),E}}}isRetryable(e,o){if(o.signal?.aborted||e.isType(A.Maintenance)||e.isType(A.Cancelled)||!(e.isNetworkError()||e.status!==void 0&&Rt.has(e.status)))return!1;let c=(o.method??"GET").toUpperCase();return c==="GET"||c==="HEAD"?!0:c==="PUT"||c==="DELETE"?!1:this.hasIdempotencyKey(o.headers)}hasIdempotencyKey(e){if(!e)return!1;let o=U.HEADER.toLowerCase(),l=!1,c=d=>{d.toLowerCase()===o&&(l=!0)};if(e instanceof Headers)e.forEach((d,h)=>{c(h)});else if(Array.isArray(e))for(let[d]of e)c(d);else for(let d of Object.keys(e))c(d);return l}async attemptOnce(e,o,l,c=this.timeout){let d=()=>{};try{let h=await this.mergeHeaders(o.headers),f=this.createTimeoutSignal(o.signal,c);d=f.cleanup;let g={...o,headers:h,credentials:this.session&&!h.Authorization?"include":void 0,signal:f.signal};this.emit("request",e,g);let y=await this.fetch(e,g);if(d(),!y.ok)throw await m.fromHttpResponse(y,l);return this.emit("response",this.safeClone(y),e),{data:await this.parseResponse(this.safeClone(y)),status:y.status}}catch(h){d();let f=m.fromFetchError(h,l);throw this.emit("error",f,e),f}}async request(e,o,l,c){let{data:d}=await this.executeRequest(e,o,l,c);return d}async requestWithStatus(e,o,l){return this.executeRequest(e,o,l)}async mergeHeaders(e={}){return{...this.globalHeaders,...this.caller?{[$.HEADER]:this.caller}:{},...await this.getAuthHeadersCallback(),...e}}createTimeoutSignal(e,o=this.timeout){let l=new AbortController,c=setTimeout(()=>l.abort(new DOMException(`Timed out after ${o}ms`,"TimeoutError")),o),d=e?()=>l.abort(e.reason):void 0;return e&&d&&(e.addEventListener("abort",d),e.aborted&&l.abort(e.reason)),{signal:l.signal,cleanup:()=>{clearTimeout(c),e&&d&&e.removeEventListener("abort",d)}}}safeClone(e){try{return e.clone()}catch{return e}}async parseResponse(e){if(!(e.headers.get("Content-Length")==="0"||e.status===204))return e.json()}async deploy(e,o={}){if(!e.length)throw m.business("No files to deploy");for(let g of e)if(!g.md5)throw m.file(`MD5 checksum missing for file: ${g.path}`,{filePath:g.path});re(o.password);let l=Ae(o.idempotencyKey),c=M(o.labels);await xe(e);let d=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa}:void 0,{body:h,headers:f}=await this.createDeployBody(e,{labels:c,via:o.via??Lt,password:o.password,flags:d,captcha:o.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:h,headers:l?{...f,[U.HEADER]:l}:f,signal:o.signal||null},"Deploy",o.build||o.prerender?this.deployBuildTimeout:this.deployTimeout)}async listDeployments(e){return this.request(`${this.apiUrl}${T.DEPLOYMENTS}${ie(e)}`,{method:"GET"},"List deployments")}async getDeployment(e){return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"GET"},"Get deployment")}async updateDeploymentLabels(e,o){let l=M(o);return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({labels:l})},"Update deployment labels")}async deleteDeployment(e){return this.request(`${this.apiUrl}${T.DEPLOYMENT(encodeURIComponent(e))}`,{method:"DELETE"},"Delete deployment")}async setDomain(e,o,l){let c=M(l),d={};o&&(d.deployment=o),c!==void 0&&(d.labels=c);let{data:h,status:f}=await this.requestWithStatus(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)},"Set domain");return{...h,isCreate:f===201}}async listDomains(e){return this.request(`${this.apiUrl}${T.DOMAINS}${ie(e)}`,{method:"GET"},"List domains")}async getDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"GET"},"Get domain")}async deleteDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN(encodeURIComponent(e))}`,{method:"DELETE"},"Delete domain")}async verifyDomain(e){return this.request(`${this.apiUrl}${T.DOMAIN_VERIFY(encodeURIComponent(e))}`,{method:"POST"},"Verify domain")}async getDomainDns(e){return this.request(`${this.apiUrl}${T.DOMAIN_DNS(encodeURIComponent(e))}`,{method:"GET"},"Get domain DNS")}async getDomainRecords(e){return this.request(`${this.apiUrl}${T.DOMAIN_RECORDS(encodeURIComponent(e))}`,{method:"GET"},"Get domain records")}async getDomainShare(e){return this.request(`${this.apiUrl}${T.DOMAIN_SHARE(encodeURIComponent(e))}`,{method:"GET"},"Get domain share")}async validateDomain(e){return this.request(`${this.apiUrl}${T.DOMAINS_VALIDATE}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({domain:e})},"Validate domain")}async createToken(e,o){let l=M(o),c={};return e!==void 0&&(c.ttl=e),l!==void 0&&(c.labels=l),this.request(`${this.apiUrl}${T.TOKENS}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)},"Create token")}async listTokens(e){return this.request(`${this.apiUrl}${T.TOKENS}${ie(e)}`,{method:"GET"},"List tokens")}async deleteToken(e){return this.request(`${this.apiUrl}${T.TOKEN(encodeURIComponent(e))}`,{method:"DELETE"},"Delete token")}async getToken(e){return this.request(`${this.apiUrl}${T.TOKEN(encodeURIComponent(e))}`,{method:"GET"},"Get token")}async getAccount(){return this.request(`${this.apiUrl}${T.ACCOUNT}`,{method:"GET"},"Get account")}async getLimits(){return this.request(`${this.apiUrl}${T.LIMITS}`,{method:"GET"},"Get limits")}async ping(){return this.request(`${this.apiUrl}${T.PING}`,{method:"GET"},"Ping")}async checkSPA(e,o={}){let l=e.find(f=>f.path===V.INDEX_FILE||f.path===`/${V.INDEX_FILE}`);if(!l||l.size>V.MAX_INDEX_BYTES)return!1;let c;if(typeof Buffer<"u"&&Buffer.isBuffer(l.content))c=l.content.toString("utf-8");else if(typeof Blob<"u"&&l.content instanceof Blob)c=await l.content.text();else if(typeof File<"u"&&l.content instanceof File)c=await l.content.text();else return!1;let d={files:e.map(f=>f.path),index:c};return(await this.request(`${this.apiUrl}${T.SPA_CHECK}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)},"SPA check")).isSPA}};R();R();X();async function xt(){let t=JSON.stringify(Ie,null,2),n;typeof Buffer<"u"?n=Buffer.from(t,"utf-8"):n=new Blob([t],{type:"application/json"});let{md5:e}=await B(n);return{path:v,content:n,size:t.length,md5:e}}async function Ue(t,n,e){if(e.spaDetect===!1||e.spa||e.build||e.prerender||t.some(o=>o.path===v))return t;try{if(await n.checkSPA(t,e)){let l=await xt();return[...t,l]}}catch{}return t}function Me(t){let{getApi:n,ensureInit:e,processInput:o}=t;return{upload:async(l,c={})=>{if(await e(),!o)throw m.config("processInput function is not provided.");let d=n(),h=await o(l,c);return h=await Ue(h,d,c),d.deploy(h,c)},list:async l=>(await e(),n().listDeployments(l)),get:async l=>(await e(),n().getDeployment(l)),set:async(l,c)=>(await e(),n().updateDeploymentLabels(l,c.labels)),delete:async l=>(await e(),n().deleteDeployment(l))}}function Be(t){let{getApi:n,ensureInit:e}=t;return{set:async(o,l={})=>(await e(),n().setDomain(o,l.deployment,l.labels)),list:async o=>(await e(),n().listDomains(o)),get:async o=>(await e(),n().getDomain(o)),delete:async o=>(await e(),n().deleteDomain(o)),verify:async o=>(await e(),n().verifyDomain(o)),validate:async o=>(await e(),n().validateDomain(o)),dns:async o=>(await e(),n().getDomainDns(o)),records:async o=>(await e(),n().getDomainRecords(o)),share:async o=>(await e(),n().getDomainShare(o))}}function He(t){let{getApi:n,ensureInit:e}=t;return{get:async()=>(await e(),n().getAccount())}}function ke(t){let{getApi:n,ensureInit:e}=t;return{create:async(o={})=>(await e(),n().createToken(o.ttl,o.labels)),list:async o=>(await e(),n().listTokens(o)),get:async o=>(await e(),n().getToken(o)),delete:async o=>(await e(),n().deleteToken(o))}}var W=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&&Pe(n.caller),n.token&&n.session)throw m.config("Provide either `token` or `session`, not both.");typeof n.token=="string"?(te(n.token),this.credential=n.token):n.token&&(this.credential=n.token),this.http=new j({...n,getAuthHeaders:()=>this.getAuthHeaders(),createDeployBody:this.getDeployBodyCreator()});let e={getApi:()=>this.http,ensureInit:()=>this.ensureInitialized()};this.deployments=Me({...e,processInput:(o,l)=>this.processInput(o,l)}),this.domains=Be(e),this.account=He(e),this.tokens=ke(e)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.getLimits()}catch(n){throw this.initPromise=null,n}}async ping(){return await this.ensureInitialized(),this.http.ping()}async deploy(n,e){return this.deployments.upload(n,e)}async whoami(){return this.account.get()}async getLimits(){return this.platformLimits?this.platformLimits:(await this.ensureInitialized(),this.platformLimits)}on(n,e){this.http.on(n,e)}off(n,e){this.http.off(n,e)}setHeaders(n){this.http.setGlobalHeaders(n)}clearHeaders(){this.http.setGlobalHeaders({})}setToken(n){if(this.clientOptions.session)throw m.config("Provide either `token` or `session`, not both.");if(typeof n=="string"){if(!n)throw m.business("Invalid token provided. Token must be a non-empty string.");te(n),this.credential=n;return}if(typeof n!="function")throw m.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 m.authentication("Token provider returned no token.");if(typeof n!="string")throw m.authentication("Token provider returned a non-string value.");return{Authorization:`Bearer ${n}`}}};R();async function Ge(t,n={}){let{labels:e,via:o,password:l,flags:c,captcha:d}=n,h=new FormData,f=[];for(let g of t){if(!(g.content instanceof File||g.content instanceof Blob))throw m.file(`Unsupported file.content type for browser: ${g.path}`,{filePath:g.path});if(!g.md5)throw m.file(`File missing md5 checksum: ${g.path}`,{filePath:g.path});let y=new File([g.content],g.path,{type:"application/octet-stream"});h.append(P.FILES,y),f.push(g.md5)}return h.append(P.CHECKSUMS,JSON.stringify(f)),e&&e.length>0&&h.append(P.LABELS,JSON.stringify(e)),o&&h.append(P.VIA,o),l&&h.append(P.PASSWORD,l),c?.build&&h.append(P.BUILD,"true"),c?.prerender&&h.append(P.PRERENDER,"true"),c?.spa&&h.append(P.SPA,"true"),d&&h.append(P.CAPTCHA,d),{body:h,headers:{}}}R();R();oe();le();ce();fe();X();de();function Qn(t,n,e,o=!0){let l=t===1?n:e;return o?`${t} ${l}`:l}me();var he=class extends W{async deploy(n,e){return super.deploy(n,e)}async processInput(n,e){if(!Array.isArray(n)||!n.every(l=>l instanceof File))throw m.business("Invalid input type for browser environment. Expected File[].");if(n.length===0)throw m.business("No files to deploy.");let{processFilesForBrowser:o}=await Promise.resolve().then(()=>(me(),Qe));return o(n,e,this.platformLimits??void 0)}getDeployBodyCreator(){return Ge}},Sr=he;export{Re as API_KEY,T as API_PATHS,Vt as AUTH_BASE_PATH,zt as AccountPlan,j as ApiHttp,Ee as AuthMethod,$ as CALLER,ne as DEFAULT_API,v as DEPLOYMENT_CONFIG_FILENAME,P as DEPLOY_FIELDS,be as DEPLOY_TOKEN,Ht as DeploymentStatus,at as DeploymentVia,kt as DomainStatus,A as ErrorType,b as FILE_VALIDATION_STATUS,b as FileValidationStatus,U as IDEMPOTENCY_KEY_CONSTRAINTS,Mt as JUNK_DIRECTORIES,N as LABEL_CONSTRAINTS,ve as LABEL_PATTERN,Wt as MY_API_KEY_URL,Yt as OAuthScope,z as PASSWORD_CONSTRAINTS,Jt as PUBLIC_DEPLOYMENT_TTL_SECONDS,Xt as SHIP_ENV,V as SPA_CHECK_CONSTRAINTS,Ie as SPA_DEFAULT_CONFIG,he as Ship,m as ShipError,O as TokenKind,ht as UNBUILT_PROJECT_MARKERS,mt as UNSAFE_FILENAME_CHARS,Kt as WEB_FILE_ACCEPT,Cn as __setTestEnvironment,zn as allValidFilesReady,we as assertShipJsonSyntax,B as calculateMD5,yt as classifyToken,He as createAccountResource,Me as createDeploymentResource,Be as createDomainResource,ke as createTokenResource,Sr as default,rn as deserializeLabels,Zt as extractSubdomain,qe as filterJunk,Q as formatFileSize,en as generateDeploymentUrl,tn as generateDomainUrl,Ve as getENV,Ct as getValidFiles,K as hasUnbuiltMarker,Se as hasUnsafeChars,Te as isBlockedExtension,Qt as isCustomDomain,qt as isDeployment,_e as isPlatformDomain,De as isShipError,Gt as normalizeVia,Ke as optimizeDeployPaths,Qn as pluralize,Je as processFilesForBrowser,nn as serializeLabels,gt as validateApiKey,jt as validateApiUrl,Pe as validateCaller,We as validateDeployFile,Xe as validateDeployPath,Et as validateDeployToken,pe as validateFileName,Gn as validateFiles,Ae as validateIdempotencyKey,re as validatePassword,te as validateToken};
2
2
  //# sourceMappingURL=browser.js.map