@shipstatic/ship 2.2.0-beta.7 → 2.2.0-beta.9
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 +36 -1
- package/SKILL.md +26 -1
- package/THIRD-PARTY-LICENSES.md +1 -57
- package/dist/browser.d.ts +182 -66
- package/dist/browser.js +1 -1
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +136 -147
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +177 -59
- package/dist/index.d.ts +177 -59
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
- package/dist/metafile-cjs.json +0 -1
- package/dist/metafile-esm.json +0 -1
package/dist/browser.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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 G=(t,n,e)=>(e=t!=null?Ze(nt(t)):{},ot(n||!t||!t.__esModule?H(e,"default",{value:t,enumerable:!0}):e,t));var k=(t,n,e)=>it(t,typeof n!="symbol"?n+"":n,e);function kt(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,Gt,U,zt,T,P,E,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"},Gt={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"},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",Timeout:"timeout_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},lt=new Set([E.Network,E.Timeout,E.Cancelled,E.File,E.Config]),ee={client:new Set([E.Business,E.Cancelled,E.Config,E.File,E.Forbidden,E.NotFound,E.RateLimit,E.Validation]),network:new Set([E.Network,E.Timeout]),auth:new Set([E.Authentication])},pt=new Set(Object.values(E).filter(t=>!lt.has(t))),ut=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 y=await e.json();if(y&&typeof y=="object"){let A=y;typeof A.message=="string"?l=A.message:typeof A.error=="string"&&(l=A.error),c=A.details,typeof A.error=="string"&&pt.has(A.error)&&(f=A.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 A=c&&typeof c=="object"?c:{};A.retryAfter===void 0&&(c={...A,retryAfter:y})}}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(De(e))return e;let l=o||"Request",c=e?.name;return c==="AbortError"?t.cancelled(`${l} was cancelled`):c==="TimeoutError"?t.timeout(`${l} timed out`,{cause:e}):e instanceof Error?ct(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 timeout(e,o){return new t(E.Timeout,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 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 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 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 d(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,a,s,I,_,x;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 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 A(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(A(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(A(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,f(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=d(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(()=>G(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(()=>G(q(),1)),e=n("md5");return e.update(t),{md5:e.digest("hex")}}async function vt(t){let{createHash:n}=await Promise.resolve().then(()=>G(q(),1)),{createReadStream:e}=await Promise.resolve().then(()=>G(q(),1));return new Promise((o,l)=>{let c=n("md5"),f=e(t);f.on("error",h=>l(m.file(`Failed to read file for MD5: ${h.message}`,{filePath:t}))),f.on("data",h=>c.update(h)),f.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 f=e[0][c];if(e.every(h=>h[c]===f))o.push(f);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 kn(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:b.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:b.VALIDATION_FAILED,statusMessage:d.message})),validFiles:[],errors:e,warnings:[],canDeploy:!1}}let c=0;for(let d of t){let g=b.READY,y="Ready for upload";if(d.status===b.PROCESSING_ERROR)g=b.VALIDATION_FAILED,y=d.statusMessage||"File failed during processing",e.push({file:d.name,message:y});else if(d.size===0){g=b.EXCLUDED,y="File is empty (0 bytes) and cannot be deployed due to storage limitations",o.push({file:d.name,message:y}),l.push({...d,status:g,statusMessage:y});continue}else if(d.size<0)g=b.VALIDATION_FAILED,y="File size must be positive",e.push({file:d.name,message:y});else if(!d.name||d.name.trim().length===0)g=b.VALIDATION_FAILED,y="File name cannot be empty",e.push({file:d.name||"(empty)",message:y});else if(d.name.includes("\0"))g=b.VALIDATION_FAILED,y="File name contains invalid characters (null byte)",e.push({file:d.name,message:y});else{let A={path:d.name,size:d.size,totalSize:c+d.size},S=Z(A,n);S?(g=b.VALIDATION_FAILED,y=S.sentence(A,n),e.push({file:S.name==="totalSize"?`(${t.length} files)`:d.name,message:y})):c=A.totalSize}l.push({...d,status:g,statusMessage:y})}e.length>0&&(l=l.map(d=>d.status===b.EXCLUDED?d:{...d,status:b.VALIDATION_FAILED,statusMessage:d.status===b.VALIDATION_FAILED?d.statusMessage:"Deployment failed due to validation errors in bundle"}));let f=e.length===0?l.filter(d=>d.status===b.READY):[],h=e.length===0;return{files:l,validFiles:f,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 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(Mt.some(h=>f.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(A=>A.webkitRelativePath||A.name),l=n.build||n.prerender,c=Ke(o,{flatten:n.pathDetect!==!1}),f=c.map(A=>A.path),h=new Set(qe(f,{allowUnbuilt:l})),d=[];for(let A=0;A<t.length;A++)h.has(f[A])&&d.push({file:t[A],deployPath:c[A].path});if(d.length===0)return[];if(l){let A=[];for(let S=0;S<d.length;S++){let{file:L,deployPath:C}=d[S];if(L.size===0)continue;let{md5:F}=await B(L);A.push({path:C,content:L,size:L.size,md5:F})}return A}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 A=0;A<d.length;A++){let{file:S,deployPath:L}=d[A];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(f){o.delete(c),n!=="error"&&setTimeout(()=>{let h=f instanceof Error?f:new Error(String(f));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(f),n?.removeEventListener("abort",c)},c=()=>{l(),o(n?.reason)},f=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 f=0;;f++)try{return await this.attemptOnce(e,o,l,c)}catch(h){let d=m.fromFetchError(h,l);if(f>=this.maxRetries||!this.isRetryable(d,o))throw this.emit("error",d,e),d;this.emit("retry",d,e,f+1);let g=Math.min(St,Tt*2**f);try{await bt(Math.random()*g,o.signal)}catch(y){let A=m.fromFetchError(y,l);throw this.emit("error",A,e),A}}}isRetryable(e,o){if(o.signal?.aborted||e.isType(E.Maintenance)||e.isType(E.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=f=>{f.toLowerCase()===o&&(l=!0)};if(e instanceof Headers)e.forEach((f,h)=>{c(h)});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 h=await this.mergeHeaders(o.headers),d=this.createTimeoutSignal(o.signal,c);f=d.cleanup;let g={...o,headers:h,credentials:this.session&&!h.Authorization?"include":void 0,signal:d.signal};this.emit("request",e,g);let y=await this.fetch(e,g);if(f(),!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){throw f(),m.fromFetchError(h,l)}}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});re(o.password);let l=Ae(o.idempotencyKey),c=M(o.labels);await xe(e);let f=o.build||o.prerender||o.spa?{build:o.build,prerender:o.prerender,spa:o.spa}:void 0,{body:h,headers:d}=await this.createDeployBody(e,{labels:c,via:o.via??Lt,password:o.password,flags:f,captcha:o.captcha});return this.request(`${this.apiUrl}${this.deployEndpoint}`,{method:"POST",body:h,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}${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),f={};o&&(f.deployment=o),c!==void 0&&(f.labels=c);let{data:h,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{...h,isCreate:d===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(d=>d.path===V.INDEX_FILE||d.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 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}};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 f=n(),h=await o(l,c);return h=await Ue(h,f,c),f.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 Ge(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=Ge(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 ke(t,n={}){let{labels:e,via:o,password:l,flags:c,captcha:f}=n,h=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 y=new File([g.content],g.path,{type:"application/octet-stream"});h.append(P.FILES,y),d.push(g.md5)}return h.append(P.CHECKSUMS,JSON.stringify(d)),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"),f&&h.append(P.CAPTCHA,f),{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 ke}},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,Gt as DomainStatus,E 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,Ge 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,kt 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,kn as validateFiles,Ae as validateIdempotencyKey,re as validatePassword,te as validateToken};
|
|
1
|
+
var it=Object.create;var $=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var st=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty;var pt=(e,n,t)=>n in e?$(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var I=(e,n)=>()=>(e&&(n=e(e=0)),n);var Ae=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports),ut=(e,n)=>{for(var t in n)$(e,t,{get:n[t],enumerable:!0})},ct=(e,n,t,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of st(n))!lt.call(e,l)&&l!==t&&$(e,l,{get:()=>n[l],enumerable:!(a=ot(n,l))||a.enumerable});return e};var B=(e,n,t)=>(t=e!=null?it(at(e)):{},ct(n||!e||!e.__esModule?$(t,"default",{value:e,enumerable:!0}):t,e));var H=(e,n,t)=>pt(e,typeof n!="symbol"?n+"":n,t);function jt(e){if(!e||typeof e!="string")return;let n=e.trim().toLowerCase();return Object.values(ft).includes(n)?n:void 0}function Se(e){if(e==null)return;if(typeof e!="string")throw m.validation("Idempotency key must be a string.");let n=e.trim();if(!n)throw m.validation("Idempotency key must not be empty.");if(n.length>F.MAX_LENGTH)throw m.validation(`Idempotency key must be at most ${F.MAX_LENGTH} characters.`);return n}function yt(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 De(e){return e!==null&&typeof e=="object"&&"name"in e&&e.name==="ShipError"&&"status"in e}function gt(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 Re(e,n){let t=gt(e);return t===null?!1:Array.isArray(n)?n.includes(t):n.has(t)}function be(e){return At.test(e)}function z(e){return e.replace(/\\/g,"/").split("/").filter(Boolean).some(t=>Tt.has(t))}function St(e){return e.startsWith(Ie.PREFIX)?v.API_KEY:e.startsWith(Le.PREFIX)?v.DEPLOY_TOKEN:v.OPAQUE}function _e(e){let n=e.charCodeAt(0)===65279?e.slice(1):e,t;try{t=JSON.parse(n)}catch(a){throw m.config(`invalid JSON format in config: ${a.message}`,{filePath:N})}if(t===null||typeof t!="object"||Array.isArray(t))throw m.config(`${N} must contain a JSON object`,{filePath:N})}function Ne(e,n,t){if(!e.startsWith(n.PREFIX))throw m.validation(`${t} must start with "${n.PREFIX}"`);if(e.length!==n.TOTAL_LENGTH)throw m.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 m.validation(`${t} must contain ${n.HEX_LENGTH} hexadecimal characters after "${n.PREFIX}" prefix`)}function Dt(e){Ne(e,Ie,"API key")}function Rt(e){Ne(e,Le,"Deploy token")}function ne(e){switch(St(e)){case v.API_KEY:Dt(e);return;case v.DEPLOY_TOKEN:Rt(e);return;case v.OPAQUE:if(!e)throw m.validation("Token must be a non-empty string")}}function Pe(e){if(!e||e.length>C.MAX_LENGTH||!C.PATTERN.test(e))throw m.validation(`Caller must be 1-${C.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 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 tn(e){return/^[a-z]+-[a-z]+-[a-z0-9]{7}(\.[a-z0-9.-]+)?$/i.test(e)}function re(e){if(e!=null){if(typeof e!="number"||!Number.isFinite(e))throw m.validation("TTL must be a number of seconds");if(!Number.isInteger(e))throw m.validation("TTL must be a whole number of seconds");if(e<G.MIN_SECONDS||e>G.MAX_SECONDS)throw m.validation(`TTL must be between ${G.MIN_SECONDS} and ${G.MAX_SECONDS} seconds`);return e}}function xe(e,n){return e.endsWith(`.${n}`)}function sn(e,n){return!xe(e,n)}function an(e,n){return xe(e,n)?e.slice(0,-(n.length+1)):null}function ln(e){return`https://${e}`}function pn(e){return`https://${e}`}function un(e){return!e||e.length===0?null:JSON.stringify(e)}function cn(e){if(!e)return[];try{let n=JSON.parse(e);return Array.isArray(n)?n:[]}catch{return[]}}function oe(e){if(e==null)return;if(typeof e!="string")throw m.validation("Password must be a string");let n=e.trim();if(n.length<k.MIN_LENGTH||n.length>k.MAX_LENGTH)throw m.validation(`Password must be between ${k.MIN_LENGTH} and ${k.MAX_LENGTH} characters`);return n}var Yt,ft,Xt,F,Wt,T,L,g,dt,te,mt,ht,m,Et,Jt,At,Tt,Qt,Te,Ie,Le,C,v,Zt,N,we,K,G,ie,nn,rn,on,R,x,Oe,k,D=I(()=>{"use strict";Yt={PENDING:"pending",SUCCESS:"success",FAILED:"failed",DELETING:"deleting"},ft={WEB:"web",SDK:"sdk",CLI:"cli",MCP:"mcp",GIT:"git",N8N:"n8n",GPT:"gpt",VSC:"vsc"},Xt={PENDING:"pending",PARTIAL:"partial",SUCCESS:"success",PAUSED:"paused"},F={HEADER:"Idempotency-Key",MAX_LENGTH:256,WINDOW_SECONDS:1440*60};Wt={FREE:"free",STANDARD:"standard",SPONSORED:"sponsored",ENTERPRISE:"enterprise",SUSPENDED:"suspended",TERMINATING:"terminating",TERMINATED:"terminated"},T={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",PING:"/ping",SETUP:"/setup",SPA_CHECK:"/spa-check",UPLOAD:"/upload"},L={FILES:"files[]",CHECKSUMS:"checksums",LABELS:"labels",VIA:"via",PASSWORD:"password",TTL:"ttl",BUILD:"build",PRERENDER:"prerender",SPA:"spa",CAPTCHA:"captcha"},g={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",Timeout:"timeout_error",Cancelled:"operation_cancelled",File:"file_error",Config:"config_error"},dt=new Set([g.Network,g.Timeout,g.Cancelled,g.File,g.Config]),te={client:new Set([g.Business,g.Cancelled,g.Config,g.File,g.Forbidden,g.NotFound,g.RateLimit,g.Validation]),network:new Set([g.Network,g.Timeout]),auth:new Set([g.Authentication])},mt=new Set(Object.values(g).filter(e=>!dt.has(e))),ht=200;m=class e extends Error{constructor(t,a,l,c){super(a);H(this,"type");H(this,"status");H(this,"details");this.type=t,this.status=l,this.details=c,this.name="ShipError"}toResponse(){let t=this.details,a=this.type===g.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 A=f;typeof A.message=="string"?l=A.message:typeof A.error=="string"&&(l=A.error),c=A.details,typeof A.error=="string"&&mt.has(A.error)&&(h=A.error)}}else{let f=(await t.text()).trim();f&&!f.startsWith("<")&&f.length<=ht&&(l=f)}}catch{}let y=t.headers.get("retry-after");if(y!==null){let E=y.trim(),f=/^\d+$/.test(E)?Number(E):Math.ceil((Date.parse(E)-Date.now())/1e3);if(Number.isFinite(f)&&f>=0){let A=c&&typeof c=="object"?c:{};A.retryAfter===void 0&&(c={...A,retryAfter:f})}}l=l||`${a||"Request"} failed with status ${t.status}`;let d=h??(t.status===401?g.Authentication:t.status===403?g.Forbidden:t.status===429?g.RateLimit:g.Api);return new e(d,l,t.status,c)}static fromFetchError(t,a){if(De(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?yt(t)?e.network(`${l} failed: ${t.message}`,{cause:t}):new e(g.Api,`${l} failed: ${t.message}`):new e(g.Api,`${l} failed: Unknown error`)}static validation(t,a){return new e(g.Validation,t,400,a)}static notFound(t,a){let l=a?`${t} ${a} not found`:`${t} not found`;return new e(g.NotFound,l,404)}static forbidden(t,a){return new e(g.Forbidden,t,403,a)}static rateLimit(t="Too many requests",a){return new e(g.RateLimit,t,429,a)}static authentication(t="Authentication required",a){return new e(g.Authentication,t,401,a)}static business(t,a=400,l){return new e(g.Business,t,a,l)}static network(t,a){return new e(g.Network,t,void 0,a)}static timeout(t,a){return new e(g.Timeout,t,void 0,a)}static cancelled(t,a){return new e(g.Cancelled,t,void 0,a)}static file(t,a){return new e(g.File,t,void 0,a)}static config(t,a){return new e(g.Config,t,void 0,a)}static api(t,a=500,l){return new e(g.Api,t,a,l)}static maintenance(t,a){return new e(g.Maintenance,t,503,a)}isClientError(){return te.client.has(this.type)?!0:this.status!==void 0&&this.status>=400&&this.status<500}isNetworkError(){return te.network.has(this.type)}isAuthError(){return te.auth.has(this.type)}isType(t){return this.type===t}};Et=["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"],Jt=Et.map(e=>`.${e}`).join(","),At=/[\x00-\x1f\x7f#?%\\<>"]/;Tt=new Set(["node_modules","package.json"]);Qt="/auth",Te={SESSION:"session",API_KEY:"apiKey",TOKEN:"token",AGENT:"agent",OAUTH:"oauth",WEBHOOK:"webhook",SYSTEM:"system"},Ie={PREFIX:"ship-",HEX_LENGTH:32,TOTAL_LENGTH:37,HINT_LENGTH:4},Le={PREFIX:"deploy-",HEX_LENGTH:32,TOTAL_LENGTH:39},C={HEADER:"X-Caller",MAX_LENGTH:128,PATTERN:/^[a-zA-Z0-9._-]+$/},v={API_KEY:Te.API_KEY,DEPLOY_TOKEN:Te.TOKEN,OPAQUE:"opaque"};Zt={ACCOUNT_READ:"account:read",DEPLOYMENTS_READ:"deployments:read",DEPLOYMENTS_WRITE:"deployments:write",DOMAINS_READ:"domains:read",DOMAINS_WRITE:"domains:write"},N="ship.json",we={rewrites:[{source:"/(.*)",destination:"/index.html"}]},K={INDEX_FILE:"index.html",MAX_INDEX_BYTES:100*1024};G={MIN_SECONDS:1,MAX_SECONDS:365*24*60*60};ie="https://api.shipstatic.com",nn={TOKEN:"SHIP_TOKEN",API_URL:"SHIP_API_URL"},rn="https://my.shipstatic.com/api-key",on=4320*60,R={PENDING:"pending",PROCESSING_ERROR:"processing_error",EXCLUDED:"excluded",VALIDATION_FAILED:"validation_failed",READY:"ready"};x={MIN_LENGTH:3,MAX_LENGTH:25,MAX_COUNT:10,SEPARATORS:"._-"},Oe=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/;k={MIN_LENGTH:6,MAX_LENGTH:128}});var Ue=Ae((Ce,Me)=>{"use strict";(function(e){if(typeof Ce=="object")Me.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(u,p){return u+p&4294967295},t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function a(u,p,i,r,s,o){return p=n(n(p,u),n(r,o)),n(p<<s|p>>>32-s,i)}function l(u,p){var i=u[0],r=u[1],s=u[2],o=u[3];i+=(r&s|~r&o)+p[0]-680876936|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[1]-389564586|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[2]+606105819|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[3]-1044525330|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+p[4]-176418897|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[5]+1200080426|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[6]-1473231341|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[7]-45705983|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+p[8]+1770035416|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[9]-1958414417|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[10]-42063|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[11]-1990404162|0,r=(r<<22|r>>>10)+s|0,i+=(r&s|~r&o)+p[12]+1804603682|0,i=(i<<7|i>>>25)+r|0,o+=(i&r|~i&s)+p[13]-40341101|0,o=(o<<12|o>>>20)+i|0,s+=(o&i|~o&r)+p[14]-1502002290|0,s=(s<<17|s>>>15)+o|0,r+=(s&o|~s&i)+p[15]+1236535329|0,r=(r<<22|r>>>10)+s|0,i+=(r&o|s&~o)+p[1]-165796510|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[6]-1069501632|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[11]+643717713|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[0]-373897302|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+p[5]-701558691|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[10]+38016083|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[15]-660478335|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[4]-405537848|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+p[9]+568446438|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[14]-1019803690|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[3]-187363961|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[8]+1163531501|0,r=(r<<20|r>>>12)+s|0,i+=(r&o|s&~o)+p[13]-1444681467|0,i=(i<<5|i>>>27)+r|0,o+=(i&s|r&~s)+p[2]-51403784|0,o=(o<<9|o>>>23)+i|0,s+=(o&r|i&~r)+p[7]+1735328473|0,s=(s<<14|s>>>18)+o|0,r+=(s&i|o&~i)+p[12]-1926607734|0,r=(r<<20|r>>>12)+s|0,i+=(r^s^o)+p[5]-378558|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[8]-2022574463|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[11]+1839030562|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[14]-35309556|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+p[1]-1530992060|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[4]+1272893353|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[7]-155497632|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[10]-1094730640|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+p[13]+681279174|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[0]-358537222|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[3]-722521979|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[6]+76029189|0,r=(r<<23|r>>>9)+s|0,i+=(r^s^o)+p[9]-640364487|0,i=(i<<4|i>>>28)+r|0,o+=(i^r^s)+p[12]-421815835|0,o=(o<<11|o>>>21)+i|0,s+=(o^i^r)+p[15]+530742520|0,s=(s<<16|s>>>16)+o|0,r+=(s^o^i)+p[2]-995338651|0,r=(r<<23|r>>>9)+s|0,i+=(s^(r|~o))+p[0]-198630844|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[7]+1126891415|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[14]-1416354905|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[5]-57434055|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+p[12]+1700485571|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[3]-1894986606|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[10]-1051523|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[1]-2054922799|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+p[8]+1873313359|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[15]-30611744|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[6]-1560198380|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[13]+1309151649|0,r=(r<<21|r>>>11)+s|0,i+=(s^(r|~o))+p[4]-145523070|0,i=(i<<6|i>>>26)+r|0,o+=(r^(i|~s))+p[11]-1120210379|0,o=(o<<10|o>>>22)+i|0,s+=(i^(o|~r))+p[2]+718787259|0,s=(s<<15|s>>>17)+o|0,r+=(o^(s|~i))+p[9]-343485551|0,r=(r<<21|r>>>11)+s|0,u[0]=i+u[0]|0,u[1]=r+u[1]|0,u[2]=s+u[2]|0,u[3]=o+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 h(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,s,o,b,_,P;for(r=64;r<=p;r+=64)l(i,c(u.substring(r-64,r)));for(u=u.substring(r-64),s=u.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]|=u.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=p*8,b=b.toString(16).match(/(.*?)(.{0,8})$/),_=parseInt(b[2],16),P=parseInt(b[1],16)||0,o[14]=_,o[15]=P,l(i,o),i}function d(u){var p=u.length,i=[1732584193,-271733879,-1732584194,271733878],r,s,o,b,_,P;for(r=64;r<=p;r+=64)l(i,h(u.subarray(r-64,r)));for(u=r-64<p?u.subarray(r-64):new Uint8Array(0),s=u.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]|=u[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=p*8,b=b.toString(16).match(/(.*?)(.{0,8})$/),_=parseInt(b[2],16),P=parseInt(b[1],16)||0,o[14]=_,o[15]=P,l(i,o),i}function E(u){var p="",i;for(i=0;i<4;i+=1)p+=t[u>>i*8+4&15]+t[u>>i*8&15];return p}function f(u){var p;for(p=0;p<u.length;p+=1)u[p]=E(u[p]);return u.join("")}f(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,s=u(p,r),o=r,b,_,P,Ee;return i!==e&&(o=u(i,r)),s>o?new ArrayBuffer(0):(b=o-s,_=new ArrayBuffer(b),P=new Uint8Array(_),Ee=new Uint8Array(this,s,b),P.set(Ee),_)}})();function A(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function w(u,p){var i=u.length,r=new ArrayBuffer(i),s=new Uint8Array(r),o;for(o=0;o<i;o+=1)s[o]=u.charCodeAt(o);return p?s:r}function O(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function rt(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 U(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 S(){this.reset()}return S.prototype.append=function(u){return this.appendBinary(A(u)),this},S.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},S.prototype.end=function(u){var p=this._buff,i=p.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]|=p.charCodeAt(r)<<(r%4<<3);return this._finish(s,i),o=f(this._hash),u&&(o=U(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(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},S.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},S.prototype._finish=function(u,p){var i=p,r,s,o;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})$/),s=parseInt(r[2],16),o=parseInt(r[1],16)||0,u[14]=s,u[15]=o,l(this._hash,u)},S.hash=function(u,p){return S.hashBinary(A(u),p)},S.hashBinary=function(u,p){var i=y(u),r=f(i);return p?U(r):r},S.ArrayBuffer=function(){this.reset()},S.ArrayBuffer.prototype.append=function(u){var p=rt(this._buff.buffer,u,!0),i=p.length,r;for(this._length+=u.byteLength,r=64;r<=i;r+=64)l(this._hash,h(p.subarray(r-64,r)));return this._buff=r-64<i?new Uint8Array(p.buffer.slice(r-64)):new Uint8Array(0),this},S.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],s,o;for(s=0;s<i;s+=1)r[s>>2]|=p[s]<<(s%4<<3);return this._finish(r,i),o=f(this._hash),u&&(o=U(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 u=S.prototype.getState.call(this);return u.buff=O(u.buff),u},S.ArrayBuffer.prototype.setState=function(u){return u.buff=w(u.buff,!0),S.prototype.setState.call(this,u)},S.ArrayBuffer.prototype.destroy=S.prototype.destroy,S.ArrayBuffer.prototype._finish=S.prototype._finish,S.ArrayBuffer.hash=function(u,p){var i=d(new Uint8Array(u)),r=f(i);return p?U(r):r},S})});var Y=Ae((Tn,$e)=>{"use strict";$e.exports={}});async function Ot(e){let n=(await Promise.resolve().then(()=>B(Ue(),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 vt(e){let{createHash:n}=await Promise.resolve().then(()=>B(Y(),1)),t=n("md5");return t.update(e),{md5:t.digest("hex")}}async function Ft(e){let{createHash:n}=await Promise.resolve().then(()=>B(Y(),1)),{createReadStream:t}=await Promise.resolve().then(()=>B(Y(),1));return new Promise((a,l)=>{let c=n("md5"),h=t(e);h.on("error",y=>l(m.file(`Failed to read file for MD5: ${y.message}`,{filePath:e}))),h.on("data",y=>c.update(y)),h.on("end",()=>a({md5:c.digest("hex")}))})}async function X(e){if(e instanceof Blob)return Ot(e);if(typeof Buffer<"u"&&Buffer.isBuffer(e))return vt(e);if(typeof e=="string")return Ft(e);throw m.business("Invalid input for MD5 calculation")}var j=I(()=>{"use strict";D()});function Q(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+/,"")}var qe=I(()=>{"use strict"});function Ve(e,n={}){if(n.flatten===!1)return e.map(a=>({path:Q(a),name:ae(a)}));let t=$t(e);return e.map(a=>{let l=Q(a);if(t){let c=t.endsWith("/")?t:`${t}/`;l.startsWith(c)&&(l=l.substring(c.length))}return l||(l=ae(a)),{path:l,name:ae(a)}})}function $t(e){if(!e.length)return"";let t=e.map(c=>Q(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(y=>y[c]===h))a.push(h);else break}return a.join("/")}function ae(e){return e.split(/[/\\]/).pop()||e}var le=I(()=>{"use strict";qe()});function zn(e){pe=e}function Bt(){return typeof process<"u"&&process.versions&&process.versions.node?"node":typeof window<"u"||typeof self<"u"?"browser":"unknown"}function Ye(){return pe||Bt()}var pe,ue=I(()=>{"use strict";pe=null});function ee(e,n){return Ht.find(t=>t.broken(e,n))}var Ht,fe=I(()=>{"use strict";D();de();Ht=[{name:"name",broken:({path:e})=>!ce(e).valid,sentence:({path:e})=>ce(e).reason??"Invalid file name"},{name:"extension",broken:({path:e},n)=>Re(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 ${Z(n.maxFileSize)} allowed`},{name:"totalSize",broken:({totalSize:e},n)=>e>n.maxTotalSize,sentence:({totalSize:e},n)=>`Total upload size too large. ${Z(e)} exceeds maximum of ${Z(n.maxTotalSize)}`}]});function Z(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`${parseFloat((e/t**l).toFixed(n))} ${a[l]}`}function ce(e){if(be(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 Wn(e,n){let t=[],a=[],l=[];if(e.length===0){let d={file:"(no files)",message:"At least one file must be provided"};return t.push(d),{files:[],validFiles:[],errors:t,warnings:[],canDeploy:!1}}for(let d of e)if(z(d.name))return t.push({file:d.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 d={file:`(${e.length} files)`,message:`File count (${e.length}) exceeds limit of ${n.maxFilesCount}`};return t.push(d),{files:e.map(E=>({...E,status:R.VALIDATION_FAILED,statusMessage:d.message})),validFiles:[],errors:t,warnings:[],canDeploy:!1}}let c=0;for(let d of e){let E=R.READY,f="Ready for upload";if(d.status===R.PROCESSING_ERROR)E=R.VALIDATION_FAILED,f=d.statusMessage||"File failed during processing",t.push({file:d.name,message:f});else if(d.size===0){E=R.EXCLUDED,f="File is empty (0 bytes) and cannot be deployed due to storage limitations",a.push({file:d.name,message:f}),l.push({...d,status:E,statusMessage:f});continue}else if(d.size<0)E=R.VALIDATION_FAILED,f="File size must be positive",t.push({file:d.name,message:f});else if(!d.name||d.name.trim().length===0)E=R.VALIDATION_FAILED,f="File name cannot be empty",t.push({file:d.name||"(empty)",message:f});else if(d.name.includes("\0"))E=R.VALIDATION_FAILED,f="File name contains invalid characters (null byte)",t.push({file:d.name,message:f});else{let A={path:d.name,size:d.size,totalSize:c+d.size},w=ee(A,n);w?(E=R.VALIDATION_FAILED,f=w.sentence(A,n),t.push({file:w.name==="totalSize"?`(${e.length} files)`:d.name,message:f})):c=A.totalSize}l.push({...d,status:E,statusMessage:f})}t.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 h=t.length===0?l.filter(d=>d.status===R.READY):[],y=t.length===0;return{files:l,validFiles:h,errors:t,warnings:a,canDeploy:y}}function Gt(e){return e.filter(n=>n.status===R.READY)}function Jn(e){return Gt(e).length>0}var de=I(()=>{"use strict";D();fe()});function Xe(e){return zt.test(e)}var kt,zt,je=I(()=>{"use strict";kt=["^npm-debug\\.log$","^\\..*\\.swp$","^\\.DS_Store$","^\\.AppleDouble$","^\\.LSOverride$","^Icon\\r$","^\\._.*","^\\.Spotlight-V100(?:$|\\/)","\\.Trashes","^__MACOSX$","~$","^Thumbs\\.db$","^ehthumbs\\.db$","^[Dd]esktop\\.ini$","@eaDir$"],zt=new RegExp(kt.join("|"))});function We(e,n){if(!e||e.length===0)return[];if(!n?.allowUnbuilt&&e.find(a=>a&&z(a)))throw m.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(Xe(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(Kt.some(y=>h.toLowerCase()===y.toLowerCase()))return!1;return!0})}var Kt,me=I(()=>{"use strict";D();je();Kt=["__MACOSX",".Trashes",".fseventsd",".Spotlight-V100"]});function Je(e,n){if(e.includes("\0")||e.includes("/../")||e.startsWith("../")||e.endsWith("/.."))throw m.business(`Security error: Unsafe file path "${e}" for file: ${n}`)}function Qe(e,n){let t=ee(e,n);if(t)throw m.business(t.sentence(e,n))}var he=I(()=>{"use strict";D();fe()});async function Ze(e,n={},t){let a=!!(n.build||n.prerender),l=Ve(e.map(f=>f.path),{flatten:n.pathDetect!==!1}).map(f=>f.path),c=new Set(We(l,{allowUnbuilt:a})),h=e.map((f,A)=>({source:f,deployPath:l[A]})).filter(({deployPath:f})=>c.has(f));if(h.length===0)return[];let y=a?null:qt(t),d=[],E=0;for(let{source:f,deployPath:A}of h){if(y&&Je(A,f.origin),f.size===0)continue;y&&(E+=f.size,Qe({path:A,size:f.size,totalSize:E},y));let w=await f.read(),{md5:O}=await X(w);d.push({path:A,content:w,size:f.size,md5:O})}if(y&&d.length>y.maxFilesCount)throw m.business(`Too many files to deploy. Maximum allowed is ${y.maxFilesCount} files.`);return d}function qt(e){if(!e)throw m.config("Platform limits not provided. Deploy-mode validation requires the limits argument \u2014 pass `ship.getLimits()` result.");return e}var et=I(()=>{"use strict";D();le();me();j();he()});var nt={};ut(nt,{processFilesForBrowser:()=>tt});async function tt(e,n={},t){if(Ye()!=="browser")throw m.business("processFilesForBrowser can only be called in a browser environment.");return Ze(e.map(a=>({path:a.webkitRelativePath||a.name,origin:a.name,size:a.size,read:async()=>a})),n,t)}var ye=I(()=>{"use strict";D();et();ue()});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 y=h instanceof Error?h:new Error(String(h));this.emit("error",y,String(n))},0)}}};var bt=3e4,It=2,Lt=300,wt=2e3,_t=new Set([500,502,503,504]);function Nt(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 ve=3e5,Pt=3e5,xt=ve+Pt,V=class extends q{constructor(t){super();this.globalHeaders={};this.apiUrl=t.apiUrl||ie,this.getAuthHeadersCallback=t.getAuthHeaders,this.session=t.session??!1,this.caller=t.caller,this.timeout=t.timeout??bt,this.maxRetries=Math.max(0,t.maxRetries??It),this.fetch=t.fetch??globalThis.fetch.bind(globalThis),this.deploy={endpoint:t.deployEndpoint||T.DEPLOYMENTS,timeout:t.timeout??ve,buildTimeout:t.timeout??xt}}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(y){let d=m.fromFetchError(y,l);if(h>=this.maxRetries||!this.isRetryable(d,a))throw this.emit("error",d,t),d;this.emit("retry",d,t,h+1);let E=Math.min(wt,Lt*2**h);try{await Nt(Math.random()*E,a.signal)}catch(f){let A=m.fromFetchError(f,l);throw this.emit("error",A,t),A}}}isRetryable(t,a){if(a.signal?.aborted||t.isType(g.Maintenance)||t.isType(g.Cancelled)||!(t.isNetworkError()||t.status!==void 0&&_t.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 y=await this.mergeHeaders(a.headers),d=this.createTimeoutSignal(a.signal,c);h=d.cleanup;let E={...a,headers:y,credentials:this.session&&!y.Authorization?"include":void 0,signal:d.signal};this.emit("request",t,E);let f=await this.fetch(t,E);if(h(),!f.ok)throw await m.fromHttpResponse(f,l);return this.emit("response",this.safeClone(f),t),{data:await this.parseResponse(this.safeClone(f)),status:f.status}}catch(y){throw h(),m.fromFetchError(y,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?{[C.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 Fe(e,n={}){let{labels:t,via:a,password:l,ttl:c,flags:h,captcha:y}=n,d=new FormData,E=[];for(let f of e){if(typeof f.content=="string"||f.content===null||f.content===void 0)throw m.file(`Unsupported file.content type: ${f.path}`,{filePath:f.path});if(!f.md5)throw m.file(`File missing md5 checksum: ${f.path}`,{filePath:f.path});d.append(L.FILES,new File([f.content],f.path,{type:"application/octet-stream"})),E.push(f.md5)}return d.append(L.CHECKSUMS,JSON.stringify(E)),t&&t.length>0&&d.append(L.LABELS,JSON.stringify(t)),a&&d.append(L.VIA,a),l&&d.append(L.PASSWORD,l),c!==void 0&&d.append(L.TTL,String(c)),h?.build&&d.append(L.BUILD,"true"),h?.prerender&&d.append(L.PRERENDER,"true"),h?.spa&&d.append(L.SPA,"true"),y&&d.append(L.CAPTCHA,y),d}D();j();async function Ct(){let e=JSON.stringify(we,null,2),n;typeof Buffer<"u"?n=Buffer.from(e,"utf-8"):n=new Blob([e],{type:"application/json"});let{md5:t}=await X(n);return{path:N,content:n,size:e.length,md5:t}}async function Mt(e,n){let t=e.find(h=>h.path===K.INDEX_FILE||h.path===`/${K.INDEX_FILE}`);if(!t||t.size>K.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(T.SPA_CHECK,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)},"SPA check")).isSPA}async function Be(e,n,t){if(t.spaDetect===!1||t.spa||t.build||t.prerender||e.some(a=>a.path===N))return e;try{if(await Mt(e,n)){let l=await Ct();return[...e,l]}}catch{}return e}D();D();function M(e){if(e==null)return;if(e.length===0)return e;if(e.length>x.MAX_COUNT)throw m.validation(`Maximum ${x.MAX_COUNT} labels allowed`);let n=e.map((a,l)=>{if(typeof a!="string")throw m.validation(`Label at index ${l} must be a string`);let c=a.trim().toLowerCase();if(c.length<x.MIN_LENGTH)throw m.validation(`Labels must be at least ${x.MIN_LENGTH} characters long`);if(c.length>x.MAX_LENGTH)throw m.validation(`Labels must be no more than ${x.MAX_LENGTH} characters long`);if(!Oe.test(c))throw m.validation(`Labels must start and end with alphanumeric characters, with optional separators (${x.SEPARATORS}) between segments`);return c}),t=[...new Set(n)];if(t.length!==n.length)throw m.validation("Duplicate labels are not allowed");return t}async function He(e){let n=e.find(l=>l.path===N||l.path===`/${N}`);if(!n)return;let t=n.content,a=typeof t.text=="function"?await t.text():n.content.toString("utf8");_e(a)}var W={"Content-Type":"application/json"},Ut="sdk";function se(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 Ge(e){let{getApi:n,processInput:t}=e;return{upload:async(a,l={})=>{if(!t)throw m.config("processInput function is not provided.");let c=n(),h=await t(a,l),y=await Be(h,c,l);if(!y.length)throw m.business("No files to deploy");for(let O of y)if(!O.md5)throw m.file(`MD5 checksum missing for file: ${O.path}`,{filePath:O.path});oe(l.password);let d=re(l.ttl),E=Se(l.idempotencyKey),f=M(l.labels);await He(y);let A=l.build||l.prerender||l.spa?{build:l.build,prerender:l.prerender,spa:l.spa}:void 0,w=await Fe(y,{labels:f,via:l.via??Ut,password:l.password,ttl:d,flags:A,captcha:l.captcha});return c.request(c.deploy.endpoint,{method:"POST",body:w,...E?{headers:{[F.HEADER]:E}}:{},signal:l.signal||null},"Deploy",l.build||l.prerender?c.deploy.buildTimeout:c.deploy.timeout)},list:async a=>n().request(`${T.DEPLOYMENTS}${se(a)}`,{method:"GET"},"List deployments"),get:async a=>n().request(T.DEPLOYMENT(encodeURIComponent(a)),{method:"GET"},"Get deployment"),set:async(a,l)=>n().request(T.DEPLOYMENT(encodeURIComponent(a)),{method:"PATCH",headers:W,body:JSON.stringify({labels:M(l.labels)})},"Update deployment labels"),delete:async a=>n().request(T.DEPLOYMENT(encodeURIComponent(a)),{method:"DELETE"},"Delete deployment")}}function ke(e){let{getApi:n}=e;return{set:async(t,a={})=>{let l=M(a.labels),c={};a.deployment&&(c.deployment=a.deployment),l!==void 0&&(c.labels=l);let{data:h,status:y}=await n().requestWithStatus(T.DOMAIN(encodeURIComponent(t)),{method:"PUT",headers:W,body:JSON.stringify(c)},"Set domain");return{...h,isCreate:y===201}},list:async t=>n().request(`${T.DOMAINS}${se(t)}`,{method:"GET"},"List domains"),get:async t=>n().request(T.DOMAIN(encodeURIComponent(t)),{method:"GET"},"Get domain"),delete:async t=>n().request(T.DOMAIN(encodeURIComponent(t)),{method:"DELETE"},"Delete domain"),verify:async t=>n().request(T.DOMAIN_VERIFY(encodeURIComponent(t)),{method:"POST"},"Verify domain"),validate:async t=>n().request(T.DOMAINS_VALIDATE,{method:"POST",headers:W,body:JSON.stringify({domain:t})},"Validate domain"),dns:async t=>n().request(T.DOMAIN_DNS(encodeURIComponent(t)),{method:"GET"},"Get domain DNS"),records:async t=>n().request(T.DOMAIN_RECORDS(encodeURIComponent(t)),{method:"GET"},"Get domain records"),share:async t=>n().request(T.DOMAIN_SHARE(encodeURIComponent(t)),{method:"GET"},"Get domain share")}}function ze(e){let{getApi:n}=e;return{get:async()=>n().request(T.ACCOUNT,{method:"GET"},"Get account")}}function Ke(e){let{getApi:n}=e;return{create:async(t={})=>{let a=re(t.ttl),l=M(t.labels),c={};return a!==void 0&&(c.ttl=a),l!==void 0&&(c.labels=l),n().request(T.TOKENS,{method:"POST",headers:W,body:JSON.stringify(c)},"Create token")},list:async t=>n().request(`${T.TOKENS}${se(t)}`,{method:"GET"},"List tokens"),get:async t=>n().request(T.TOKEN(encodeURIComponent(t)),{method:"GET"},"Get token"),delete:async t=>n().request(T.TOKEN(encodeURIComponent(t)),{method:"DELETE"},"Delete token")}}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&&Pe(n.caller),n.token&&n.session)throw m.config("Provide either `token` or `session`, not both.");typeof n.token=="string"?(ne(n.token),this.credential=n.token):n.token&&(this.credential=n.token),this.http=new V({...n,getAuthHeaders:()=>this.getAuthHeaders()});let t={getApi:()=>this.http};this.deployments=Ge({...t,processInput:async(a,l)=>(await this.ensureInitialized(),this.processInput(a,l))}),this.domains=ke(t),this.account=ze(t),this.tokens=Ke(t)}async ensureInitialized(){return this.initPromise||(this.initPromise=this.fetchPlatformLimits()),this.initPromise}async fetchPlatformLimits(){try{this.platformLimits=await this.http.request(T.LIMITS,{method:"GET"},"Get limits")}catch(n){throw this.initPromise=null,n}}async ping(){return this.http.request(T.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 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.");ne(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}`}}};D();D();le();ue();de();me();j();he();function sr(e,n,t,a=!0){let l=e===1?n:t;return a?`${e} ${l}`:l}ye();var ge=class extends J{async deploy(n,t){return super.deploy(n,t)}async processInput(n,t){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:a}=await Promise.resolve().then(()=>(ye(),nt));return a(n,t,this.platformLimits??void 0)}},Or=ge;export{Ie as API_KEY,T as API_PATHS,Qt as AUTH_BASE_PATH,Wt as AccountPlan,V as ApiHttp,Te as AuthMethod,C as CALLER,ie as DEFAULT_API,N as DEPLOYMENT_CONFIG_FILENAME,L as DEPLOY_FIELDS,Le as DEPLOY_TOKEN,Yt as DeploymentStatus,ft as DeploymentVia,Xt as DomainStatus,g as ErrorType,R as FILE_VALIDATION_STATUS,R as FileValidationStatus,F as IDEMPOTENCY_KEY_CONSTRAINTS,Kt as JUNK_DIRECTORIES,x as LABEL_CONSTRAINTS,Oe as LABEL_PATTERN,rn as MY_API_KEY_URL,Zt as OAuthScope,k as PASSWORD_CONSTRAINTS,on as PUBLIC_DEPLOYMENT_TTL_SECONDS,nn as SHIP_ENV,K as SPA_CHECK_CONSTRAINTS,we as SPA_DEFAULT_CONFIG,ge as Ship,m as ShipError,G as TTL_CONSTRAINTS,v as TokenKind,Tt as UNBUILT_PROJECT_MARKERS,At as UNSAFE_FILENAME_CHARS,Jt as WEB_FILE_ACCEPT,zn as __setTestEnvironment,Jn as allValidFilesReady,_e as assertShipJsonSyntax,X as calculateMD5,St as classifyToken,ze as createAccountResource,Ge as createDeploymentResource,ke as createDomainResource,Ke as createTokenResource,Or as default,cn as deserializeLabels,an as extractSubdomain,We as filterJunk,Z as formatFileSize,ln as generateDeploymentUrl,pn as generateDomainUrl,Ye as getENV,Gt as getValidFiles,z as hasUnbuiltMarker,be as hasUnsafeChars,Re as isBlockedExtension,sn as isCustomDomain,tn as isDeployment,xe as isPlatformDomain,De as isShipError,jt as normalizeVia,Ve as optimizeDeployPaths,sr as pluralize,tt as processFilesForBrowser,un as serializeLabels,Dt as validateApiKey,en as validateApiUrl,Pe as validateCaller,Qe as validateDeployFile,Je as validateDeployPath,Rt as validateDeployToken,ce as validateFileName,Wn as validateFiles,Se as validateIdempotencyKey,oe as validatePassword,ne as validateToken,re as validateTtl};
|
|
2
2
|
//# sourceMappingURL=browser.js.map
|