@ampt/cli 1.1.8-beta.0 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs-loader.js +12 -12
- package/dist/cjs-loader.js.map +3 -3
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/esm-loader.mjs +7 -7
- package/dist/esm-loader.mjs.map +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -139,7 +139,7 @@ Url: `+ob(e)),!0)}fm._shouldDropEvent=BY;function Z7e(e,t){return!t||!t.length?!
|
|
|
139
139
|
`;n.auth&&(o["Proxy-Authorization"]=`Basic ${Buffer.from(n.auth).toString("base64")}`);let{host:l,port:f,secureEndpoint:d}=r;BKe(f,d)||(l+=`:${f}`),o.Host=l,o.Connection="close";for(let S of Object.keys(o))u+=`${S}: ${o[S]}\r
|
|
140
140
|
`;let h=MKe.default(s);s.write(`${u}\r
|
|
141
141
|
`);let{statusCode:m,buffered:g}=yield h;if(m===200){if(t.once("socket",jKe),r.secureEndpoint){mm("Upgrading socket connection to TLS");let S=r.servername||r.host;return QY.default.connect(Object.assign(Object.assign({},$Ke(r,"host","hostname","path","port")),{socket:s,servername:S}))}return s}s.destroy();let _=new JY.default.Socket({writable:!1});return _.readable=!0,t.once("socket",S=>{mm("replaying proxy buffer for failed request"),DKe.default(S.listenerCount("data")>0),S.push(g),S.push(null)}),_})}};Gc.default=LO;function jKe(e){e.resume()}function BKe(e,t){return!!(!t&&e===80||t&&e===443)}function UKe(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function $Ke(e,...t){let r={},n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}});var lb=v((jO,tZ)=>{"use strict";var HKe=jO&&jO.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},FO=HKe(eZ());function MO(e){return new FO.default(e)}(function(e){e.HttpsProxyAgent=FO.default,e.prototype=FO.default.prototype})(MO||(MO={}));tZ.exports=MO});var iZ=v(BO=>{Object.defineProperty(BO,"__esModule",{value:!0});var WKe=(gn(),mt(mn)),rZ=Yr(),nZ=require("http"),zKe=ub(),VKe=function(e){WKe.__extends(t,e);function t(r){var n=e.call(this,r)||this;n.options=r;var i=n._getProxy("http");return n.module=nZ,n.client=i?new(lb())(i):new nZ.Agent({keepAlive:!1,maxSockets:30,timeout:2e3}),n}return t.prototype.sendEvent=function(r){return this._send(rZ.eventToSentryRequest(r,this._api),r)},t.prototype.sendSession=function(r){return this._send(rZ.sessionToSentryRequest(r,this._api),r)},t}(zKe.BaseTransport);BO.HTTPTransport=VKe});var aZ=v(UO=>{Object.defineProperty(UO,"__esModule",{value:!0});var GKe=(gn(),mt(mn)),sZ=Yr(),oZ=require("https"),KKe=ub(),XKe=function(e){GKe.__extends(t,e);function t(r){var n=e.call(this,r)||this;n.options=r;var i=n._getProxy("https");return n.module=oZ,n.client=i?new(lb())(i):new oZ.Agent({keepAlive:!1,maxSockets:30,timeout:2e3}),n}return t.prototype.sendEvent=function(r){return this._send(sZ.eventToSentryRequest(r,this._api),r)},t.prototype.sendSession=function(r){return this._send(sZ.sessionToSentryRequest(r,this._api),r)},t}(KKe.BaseTransport);UO.HTTPSTransport=XKe});var cZ=v($O=>{Object.defineProperty($O,"__esModule",{value:!0});var YKe=Yr(),ZKe=Rt(),JKe=require("http"),QKe=require("https"),uZ=require("url");function eXe(e){var t,r=new uZ.URL(e.url),n=r.protocol==="https:",i=tXe(r,e.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),s=n?QKe:JKe,o=i?new(lb())(i):new s.Agent({keepAlive:!1,maxSockets:30,timeout:2e3}),a=rXe(e,(t=e.httpModule,t??s),o);return YKe.createTransport({bufferSize:e.bufferSize},a)}$O.makeNodeTransport=eXe;function tXe(e,t){var r=process.env.no_proxy,n=r&&r.split(",").some(function(i){return e.host.endsWith(i)||e.hostname.endsWith(i)});if(!n)return t}function rXe(e,t,r){var n=new uZ.URL(e.url),i=n.hostname,s=n.pathname,o=n.port,a=n.protocol,u=n.search;return function(f){return new Promise(function(d,h){var m=t.request({method:"POST",agent:r,headers:e.headers,hostname:i,path:""+s+u,port:o,protocol:a,ca:e.caCerts},function(g){var _,S,b;g.on("data",function(){}),g.on("end",function(){});var C=(_=g.statusCode,_??500),T=ZKe.eventStatusFromHttpCode(C);g.setEncoding("utf8");var w=(S=g.headers["retry-after"],S??null),E=(b=g.headers["x-sentry-rate-limits"],b??null);d({headers:{"retry-after":w,"x-sentry-rate-limits":Array.isArray(E)?E[0]:E},reason:T,statusCode:C})});m.on("error",h),m.end(f.body)})}}});var HO=v(hp=>{Object.defineProperty(hp,"__esModule",{value:!0});var nXe=ub();hp.BaseTransport=nXe.BaseTransport;var iXe=iZ();hp.HTTPTransport=iXe.HTTPTransport;var sXe=aZ();hp.HTTPSTransport=sXe.HTTPSTransport;var oXe=cZ();hp.makeNodeTransport=oXe.makeNodeTransport});var KO=v(GO=>{Object.defineProperty(GO,"__esModule",{value:!0});var mp=(gn(),mt(mn)),WO=Yr(),aXe=Jf(),zO=Rt(),lZ=CO(),VO=HO(),uXe=function(e){mp.__extends(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.eventFromException=function(r,n){return zO.resolvedSyncPromise(lZ.eventFromUnknownInput(r,n))},t.prototype.eventFromMessage=function(r,n,i){return n===void 0&&(n=aXe.Severity.Info),zO.resolvedSyncPromise(lZ.eventFromMessage(r,n,i,this._options.attachStacktrace))},t.prototype._setupTransport=function(){if(!this._options.dsn)return e.prototype._setupTransport.call(this);var r=zO.makeDsn(this._options.dsn),n=mp.__assign(mp.__assign(mp.__assign(mp.__assign(mp.__assign({},this._options.transportOptions),this._options.httpProxy&&{httpProxy:this._options.httpProxy}),this._options.httpsProxy&&{httpsProxy:this._options.httpsProxy}),this._options.caCerts&&{caCerts:this._options.caCerts}),{dsn:this._options.dsn,tunnel:this._options.tunnel,_metadata:this._options._metadata});if(this._options.transport)return new this._options.transport(n);var i=WO.initAPIDetails(n.dsn,n._metadata,n.tunnel),s=WO.getEnvelopeEndpointWithUrlEncodedAuth(i.dsn,i.tunnel);return this._newTransport=VO.makeNodeTransport({url:s,headers:n.headers,proxy:n.httpProxy,caCerts:n.caCerts}),r.protocol==="http"?new VO.HTTPTransport(n):new VO.HTTPSTransport(n)},t}(WO.BaseBackend);GO.NodeBackend=uXe});var ZO=v(YO=>{Object.defineProperty(YO,"__esModule",{value:!0});var cXe=(gn(),mt(mn)),XO=Yr(),lXe=vo(),fZ=Rt(),fXe=KO(),pZ=bu(),pXe=function(e){cXe.__extends(t,e);function t(r){var n=this;return r._metadata=r._metadata||{},r._metadata.sdk=r._metadata.sdk||{name:"sentry.javascript.node",packages:[{name:"npm:@sentry/node",version:XO.SDK_VERSION}],version:XO.SDK_VERSION},n=e.call(this,fXe.NodeBackend,r)||this,n}return t.prototype.captureException=function(r,n,i){if(this._options.autoSessionTracking&&this._sessionFlusher&&i){var s=i.getRequestSession();s&&s.status==="ok"&&(s.status="errored")}return e.prototype.captureException.call(this,r,n,i)},t.prototype.captureEvent=function(r,n,i){if(this._options.autoSessionTracking&&this._sessionFlusher&&i){var s=r.type||"exception",o=s==="exception"&&r.exception&&r.exception.values&&r.exception.values.length>0;if(o){var a=i.getRequestSession();a&&a.status==="ok"&&(a.status="errored")}}return e.prototype.captureEvent.call(this,r,n,i)},t.prototype.close=function(r){var n;return(n=this._sessionFlusher)===null||n===void 0||n.close(),e.prototype.close.call(this,r)},t.prototype.initSessionFlusher=function(){var r=this._options,n=r.release,i=r.environment;n?this._sessionFlusher=new lXe.SessionFlusher(this.getTransport(),{release:n,environment:i}):pZ.IS_DEBUG_BUILD&&fZ.logger.warn("Cannot initialise an instance of SessionFlusher if no release is provided!")},t.prototype._prepareEvent=function(r,n,i){return r.platform=r.platform||"node",this.getOptions().serverName&&(r.server_name=this.getOptions().serverName),e.prototype._prepareEvent.call(this,r,n,i)},t.prototype._captureRequestSession=function(){this._sessionFlusher?this._sessionFlusher.incrementSessionStatusCount():pZ.IS_DEBUG_BUILD&&fZ.logger.warn("Discarded request mode session because autoSessionTracking option was disabled")},t}(XO.BaseClient);YO.NodeClient=pXe});var vZ=v(JO=>{Object.defineProperty(JO,"__esModule",{value:!0});var hZ=(gn(),mt(mn)),dZ=Yr(),mZ=Rt(),dXe=require("util"),gZ=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(){var t,r;try{for(var n=hZ.__values(["debug","info","warn","error","log"]),i=n.next();!i.done;i=n.next()){var s=i.value;mZ.fill(console,s,hXe(s))}}catch(o){t={error:o}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}},e.id="Console",e}();JO.Console=gZ;function hXe(e){return function(r){var n=mZ.severityFromString(e);return function(){dZ.getCurrentHub().getIntegration(gZ)&&dZ.getCurrentHub().addBreadcrumb({category:"console",level:n,message:dXe.format.apply(void 0,arguments)},{input:hZ.__spread(arguments),level:e}),r.apply(this,arguments)}}}});var bZ=v(Kc=>{Object.defineProperty(Kc,"__esModule",{value:!0});var QO=(gn(),mt(mn)),mXe=Yr(),gXe=Rt(),yZ=require("url"),_Z=gXe.parseSemver(process.versions.node);function vXe(e){var t,r=(t=mXe.getCurrentHub().getClient())===null||t===void 0?void 0:t.getDsn();return r?e.includes(r.host):!1}Kc.isSentryRequest=vXe;function xZ(e){var t=e.protocol||"",r=e.hostname||e.host||"",n=!e.port||e.port===80||e.port===443?"":":"+e.port,i=e.path?e.path:"/";return t+"//"+r+n+i}Kc.extractUrl=xZ;function yXe(e,t,r){var n,i,s;if(!e)return e;var o=QO.__read(e.split(" "),2),a=o[0],u=o[1];return t.host&&!t.protocol&&(t.protocol=(i=(n=r)===null||n===void 0?void 0:n.agent)===null||i===void 0?void 0:i.protocol,u=xZ(t)),!((s=u)===null||s===void 0)&&s.startsWith("///")&&(u=u.slice(2)),a+" "+u}Kc.cleanSpanDescription=yXe;function eR(e){var t={protocol:e.protocol,hostname:typeof e.hostname=="string"&&e.hostname.startsWith("[")?e.hostname.slice(1,-1):e.hostname,hash:e.hash,search:e.search,pathname:e.pathname,path:""+(e.pathname||"")+(e.search||""),href:e.href};return e.port!==""&&(t.port=Number(e.port)),(e.username||e.password)&&(t.auth=e.username+":"+e.password),t}Kc.urlToOptions=eR;function _Xe(e,t){var r,n,i,s,o,a,u,l,f,d;return typeof t[t.length-1]=="function"&&(f=t.pop()),typeof t[0]=="string"?d=eR(new yZ.URL(t[0])):t[0]instanceof yZ.URL?d=eR(t[0]):d=t[0],t.length===2&&(d=QO.__assign(QO.__assign({},d),t[1])),d.protocol===void 0&&(_Z.major&&_Z.major>8?d.protocol=((n=(r=e)===null||r===void 0?void 0:r.globalAgent)===null||n===void 0?void 0:n.protocol)||((i=d.agent)===null||i===void 0?void 0:i.protocol)||((s=d._defaultAgent)===null||s===void 0?void 0:s.protocol):d.protocol=((o=d.agent)===null||o===void 0?void 0:o.protocol)||((a=d._defaultAgent)===null||a===void 0?void 0:a.protocol)||((l=(u=e)===null||u===void 0?void 0:u.globalAgent)===null||l===void 0?void 0:l.protocol)),f?[d,f]:[d]}Kc.normalizeRequestArgs=_Xe});var CZ=v(rR=>{Object.defineProperty(rR,"__esModule",{value:!0});var wZ=(gn(),mt(mn)),tR=Yr(),gp=Rt(),xXe=bu(),gm=bZ(),SZ=gp.parseSemver(process.versions.node),TZ=function(){function e(t){t===void 0&&(t={}),this.name=e.id,this._breadcrumbs=typeof t.breadcrumbs>"u"?!0:t.breadcrumbs,this._tracing=typeof t.tracing>"u"?!1:t.tracing}return e.prototype.setupOnce=function(){if(!(!this._breadcrumbs&&!this._tracing)){var t=bXe(this._breadcrumbs,this._tracing),r=require("http");if(gp.fill(r,"get",t),gp.fill(r,"request",t),SZ.major&&SZ.major>8){var n=require("https");gp.fill(n,"get",t),gp.fill(n,"request",t)}}},e.id="Http",e}();rR.Http=TZ;function bXe(e,t){return function(n){return function(){for(var s=[],o=0;o<arguments.length;o++)s[o]=arguments[o];var a=this,u=gm.normalizeRequestArgs(this,s),l=u[0],f=gm.extractUrl(l);if(gm.isSentryRequest(f))return n.apply(a,u);var d,h,m=tR.getCurrentHub().getScope();if(m&&t&&(h=m.getSpan(),h)){d=h.startChild({description:(l.method||"GET")+" "+f,op:"http.client"});var g=d.toTraceparent();xXe.IS_DEBUG_BUILD&&gp.logger.log("[Tracing] Adding sentry-trace header "+g+" to outgoing request to "+f+": "),l.headers=wZ.__assign(wZ.__assign({},l.headers),{"sentry-trace":g})}return n.apply(a,u).once("response",function(_){var S=this;e&&EZ("response",f,S,_),t&&d&&(_.statusCode&&d.setHttpStatus(_.statusCode),d.description=gm.cleanSpanDescription(d.description,l,S),d.finish())}).once("error",function(){var _=this;e&&EZ("error",f,_),t&&d&&(d.setHttpStatus(500),d.description=gm.cleanSpanDescription(d.description,l,_),d.finish())})}}}function EZ(e,t,r,n){tR.getCurrentHub().getIntegration(TZ)&&tR.getCurrentHub().addBreadcrumb({category:"http",data:{method:r.method,status_code:n&&n.statusCode,url:t},type:"http"},{event:e,request:r,response:n})}});var sR=v(iR=>{Object.defineProperty(iR,"__esModule",{value:!0});var wXe=Yr(),nR=Rt(),AZ=bu(),SXe=2e3;function EXe(e){console.error(e&&e.stack?e.stack:e);var t=wXe.getCurrentHub().getClient();t===void 0&&(AZ.IS_DEBUG_BUILD&&nR.logger.warn("No NodeClient was defined, we are exiting the process now."),global.process.exit(1));var r=t.getOptions(),n=r&&r.shutdownTimeout&&r.shutdownTimeout>0&&r.shutdownTimeout||SXe;nR.forget(t.close(n).then(function(i){i||AZ.IS_DEBUG_BUILD&&nR.logger.warn("We reached the timeout for emptying the request buffer, still exiting now!"),global.process.exit(1)}))}iR.logAndExitProcess=EXe});var OZ=v(oR=>{Object.defineProperty(oR,"__esModule",{value:!0});var IZ=Yr(),TXe=Jf(),CXe=Rt(),AXe=bu(),NZ=sR(),IXe=function(){function e(t){t===void 0&&(t={}),this._options=t,this.name=e.id,this.handler=this._makeErrorHandler()}return e.prototype.setupOnce=function(){global.process.on("uncaughtException",this.handler.bind(this))},e.prototype._makeErrorHandler=function(){var t=this,r=2e3,n=!1,i=!1,s=!1,o;return function(a){var u=NZ.logAndExitProcess,l=IZ.getCurrentHub().getClient();if(t._options.onFatalError?u=t._options.onFatalError:l&&l.getOptions().onFatalError&&(u=l.getOptions().onFatalError),n)s?(AXe.IS_DEBUG_BUILD&&CXe.logger.warn("uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown"),NZ.logAndExitProcess(a)):i||(i=!0,setTimeout(function(){s||(s=!0,u(o,a))},r));else{var f=IZ.getCurrentHub();o=a,n=!0,f.getIntegration(e)?f.withScope(function(d){d.setLevel(TXe.Severity.Fatal),f.captureException(a,{originalException:a,data:{mechanism:{handled:!1,type:"onuncaughtexception"}}}),s||(s=!0,u(a))}):s||(s=!0,u(a))}}},e.id="OnUncaughtException",e}();oR.OnUncaughtException=IXe});var kZ=v(aR=>{Object.defineProperty(aR,"__esModule",{value:!0});var NXe=Yr(),RZ=Rt(),OXe=sR(),RXe=function(){function e(t){t===void 0&&(t={mode:"warn"}),this._options=t,this.name=e.id}return e.prototype.setupOnce=function(){global.process.on("unhandledRejection",this.sendUnhandledPromise.bind(this))},e.prototype.sendUnhandledPromise=function(t,r){var n=NXe.getCurrentHub();if(!n.getIntegration(e)){this._handleRejection(t);return}var i=r.domain&&r.domain.sentryContext||{};n.withScope(function(s){s.setExtra("unhandledPromiseRejection",!0),i.user&&s.setUser(i.user),i.tags&&s.setTags(i.tags),i.extra&&s.setExtras(i.extra),n.captureException(t,{originalException:r,data:{mechanism:{handled:!1,type:"onunhandledrejection"}}})}),this._handleRejection(t)},e.prototype._handleRejection=function(t){var r="This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:";this._options.mode==="warn"?RZ.consoleSandbox(function(){console.warn(r),console.error(t&&t.stack?t.stack:t)}):this._options.mode==="strict"&&(RZ.consoleSandbox(function(){console.warn(r)}),OXe.logAndExitProcess(t))},e.id="OnUnhandledRejection",e}();aR.OnUnhandledRejection=RXe});var PZ=v(fb=>{(function(e,t){let r=typeof fb=="object"?fb:typeof e=="object"?e:{};t(r),typeof define=="function"&&define.amd&&define("lru",r)})(fb,function(e){let t=Symbol("newer"),r=Symbol("older");function n(u,l){typeof u!="number"&&(l=u,u=0),this.size=0,this.limit=u,this.oldest=this.newest=void 0,this._keymap=new Map,l&&(this.assign(l),u<1&&(this.limit=this.size))}e.LRUMap=n;function i(u,l){this.key=u,this.value=l,this[t]=void 0,this[r]=void 0}n.prototype._markEntryAsUsed=function(u){u!==this.newest&&(u[t]&&(u===this.oldest&&(this.oldest=u[t]),u[t][r]=u[r]),u[r]&&(u[r][t]=u[t]),u[t]=void 0,u[r]=this.newest,this.newest&&(this.newest[t]=u),this.newest=u)},n.prototype.assign=function(u){let l,f=this.limit||Number.MAX_VALUE;this._keymap.clear();let d=u[Symbol.iterator]();for(let h=d.next();!h.done;h=d.next()){let m=new i(h.value[0],h.value[1]);if(this._keymap.set(m.key,m),l?(l[t]=m,m[r]=l):this.oldest=m,l=m,f--==0)throw new Error("overflow")}this.newest=l,this.size=this._keymap.size},n.prototype.get=function(u){var l=this._keymap.get(u);if(l)return this._markEntryAsUsed(l),l.value},n.prototype.set=function(u,l){var f=this._keymap.get(u);return f?(f.value=l,this._markEntryAsUsed(f),this):(this._keymap.set(u,f=new i(u,l)),this.newest?(this.newest[t]=f,f[r]=this.newest):this.oldest=f,this.newest=f,++this.size,this.size>this.limit&&this.shift(),this)},n.prototype.shift=function(){var u=this.oldest;if(u)return this.oldest[t]?(this.oldest=this.oldest[t],this.oldest[r]=void 0):(this.oldest=void 0,this.newest=void 0),u[t]=u[r]=void 0,this._keymap.delete(u.key),--this.size,[u.key,u.value]},n.prototype.find=function(u){let l=this._keymap.get(u);return l?l.value:void 0},n.prototype.has=function(u){return this._keymap.has(u)},n.prototype.delete=function(u){var l=this._keymap.get(u);if(l)return this._keymap.delete(l.key),l[t]&&l[r]?(l[r][t]=l[t],l[t][r]=l[r]):l[t]?(l[t][r]=void 0,this.oldest=l[t]):l[r]?(l[r][t]=void 0,this.newest=l[r]):this.oldest=this.newest=void 0,this.size--,l.value},n.prototype.clear=function(){this.oldest=this.newest=void 0,this.size=0,this._keymap.clear()};function s(u){this.entry=u}s.prototype[Symbol.iterator]=function(){return this},s.prototype.next=function(){let u=this.entry;return u?(this.entry=u[t],{done:!1,value:[u.key,u.value]}):{done:!0,value:void 0}};function o(u){this.entry=u}o.prototype[Symbol.iterator]=function(){return this},o.prototype.next=function(){let u=this.entry;return u?(this.entry=u[t],{done:!1,value:u.key}):{done:!0,value:void 0}};function a(u){this.entry=u}a.prototype[Symbol.iterator]=function(){return this},a.prototype.next=function(){let u=this.entry;return u?(this.entry=u[t],{done:!1,value:u.value}):{done:!0,value:void 0}},n.prototype.keys=function(){return new o(this.oldest)},n.prototype.values=function(){return new a(this.oldest)},n.prototype.entries=function(){return this},n.prototype[Symbol.iterator]=function(){return new s(this.oldest)},n.prototype.forEach=function(u,l){typeof l!="object"&&(l=this);let f=this.oldest;for(;f;)u.call(l,f.value,f.key,this),f=f[t]},n.prototype.toJSON=function(){for(var u=new Array(this.size),l=0,f=this.oldest;f;)u[l++]={key:f.key,value:f.value},f=f[t];return u},n.prototype.toString=function(){for(var u="",l=this.oldest;l;)u+=String(l.key)+":"+l.value,l=l[t],l&&(u+=" < ");return u}})});var cR=v(pb=>{Object.defineProperty(pb,"__esModule",{value:!0});var Su=(gn(),mt(mn)),kXe=Yr(),PXe=Rt(),qXe=require("fs"),DXe=PZ(),uR=new DXe.LRUMap(100),LXe=7;function FXe(e){return new Promise(function(t,r){qXe.readFile(e,"utf8",function(n,i){n?r(n):t(i)})})}function MXe(){uR.clear()}pb.resetFileContentCache=MXe;var jXe=function(){function e(t){t===void 0&&(t={}),this._options=t,this.name=e.id}return Object.defineProperty(e.prototype,"_contextLines",{get:function(){var t,r;if(this._options.frameContextLines===void 0){var n=(t=kXe.getCurrentHub().getClient())===null||t===void 0?void 0:t.getOptions();this._options.frameContextLines=(r=n)===null||r===void 0?void 0:r.frameContextLines}return this._options.frameContextLines!==void 0?this._options.frameContextLines:LXe},enumerable:!0,configurable:!0}),e.prototype.setupOnce=function(t){var r=this;t(function(n){return r.addSourceContext(n)})},e.prototype.addSourceContext=function(t){var r,n;return Su.__awaiter(this,void 0,void 0,function(){var i,s,o,a,u,l;return Su.__generator(this,function(f){switch(f.label){case 0:if(!(this._contextLines>0&&(!((r=t.exception)===null||r===void 0)&&r.values)))return[3,8];f.label=1;case 1:f.trys.push([1,6,7,8]),i=Su.__values(t.exception.values),s=i.next(),f.label=2;case 2:return s.done?[3,5]:(o=s.value,!((n=o.stacktrace)===null||n===void 0)&&n.frames?[4,this.addSourceContextToFrames(o.stacktrace.frames)]:[3,4]);case 3:f.sent(),f.label=4;case 4:return s=i.next(),[3,2];case 5:return[3,8];case 6:return a=f.sent(),u={error:a},[3,8];case 7:try{s&&!s.done&&(l=i.return)&&l.call(i)}finally{if(u)throw u.error}return[7];case 8:return[2,t]}})})},e.prototype.addSourceContextToFrames=function(t){return Su.__awaiter(this,void 0,void 0,function(){var r,n,i,s,o,a,u,l,f;return Su.__generator(this,function(d){switch(d.label){case 0:r=this._contextLines,d.label=1;case 1:d.trys.push([1,6,7,8]),n=Su.__values(t),i=n.next(),d.label=2;case 2:return i.done?[3,5]:(s=i.value,s.filename&&s.context_line===void 0?[4,BXe(s.filename)]:[3,4]);case 3:if(o=d.sent(),o)try{a=o.split(`
|
|
142
|
-
`),PXe.addContextToFrame(a,s,r)}catch{}d.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return u=d.sent(),l={error:u},[3,8];case 7:try{i&&!i.done&&(f=n.return)&&f.call(n)}finally{if(l)throw l.error}return[7];case 8:return[2]}})})},e.id="ContextLines",e}();pb.ContextLines=jXe;function BXe(e){return Su.__awaiter(this,void 0,void 0,function(){var t,r,n;return Su.__generator(this,function(i){switch(i.label){case 0:if(t=uR.get(e),t!==void 0)return[2,t];r=null,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,FXe(e)];case 2:return r=i.sent(),[3,4];case 3:return n=i.sent(),[3,4];case 4:return uR.set(e,r),[2,r]}})})}});var qZ=v(fR=>{Object.defineProperty(fR,"__esModule",{value:!0});var db=(gn(),mt(mn)),lR=Yr(),hb=Rt(),UXe=CO(),$Xe=cR(),HXe="cause",WXe=5,zXe=function(){function e(t){t===void 0&&(t={}),this.name=e.id,this._key=t.key||HXe,this._limit=t.limit||WXe}return e.prototype.setupOnce=function(){lR.addGlobalEventProcessor(function(t,r){var n=lR.getCurrentHub().getIntegration(e);if(n){var i=n._handler&&n._handler.bind(n);return typeof i=="function"?i(t,r):t}return t})},e.prototype._handler=function(t,r){var n=this;return!t.exception||!t.exception.values||!r||!hb.isInstanceOf(r.originalException,Error)?hb.resolvedSyncPromise(t):new hb.SyncPromise(function(i){n._walkErrorTree(r.originalException,n._key).then(function(s){t&&t.exception&&t.exception.values&&(t.exception.values=db.__spread(s,t.exception.values)),i(t)}).then(null,function(){i(t)})})},e.prototype._walkErrorTree=function(t,r,n){n===void 0&&(n=[]);var i;return db.__awaiter(this,void 0,void 0,function(){var s,o,a=this;return db.__generator(this,function(u){switch(u.label){case 0:return!hb.isInstanceOf(t[r],Error)||n.length+1>=this._limit?[2,Promise.resolve(n)]:(s=UXe.exceptionFromError(t[r]),o=lR.getCurrentHub().getIntegration($Xe.ContextLines),o&&(!((i=s.stacktrace)===null||i===void 0)&&i.frames)?[4,o.addSourceContextToFrames(s.stacktrace.frames)]:[3,2]);case 1:u.sent(),u.label=2;case 2:return[2,new Promise(function(l,f){a._walkErrorTree(t[r],r,db.__spread([s],n)).then(l).then(null,function(){f()})})]}})})},e.id="LinkedErrors",e}();fR.LinkedErrors=zXe});var MZ=v(dR=>{Object.defineProperty(dR,"__esModule",{value:!0});var DZ=(gn(),mt(mn)),LZ=require("fs"),FZ=require("path"),pR;function VXe(){try{return require.cache?Object.keys(require.cache):[]}catch{return[]}}function GXe(){var e=require.main&&require.main.paths||[],t=VXe(),r={},n={};return t.forEach(function(i){var s=i,o=function(){var a=s;if(s=FZ.dirname(a),!(!s||a===s||n[a])){if(e.indexOf(s)<0)return o();var u=FZ.join(a,"package.json");if(n[a]=!0,!LZ.existsSync(u))return o();try{var l=JSON.parse(LZ.readFileSync(u,"utf8"));r[l.name]=l.version}catch{}}};o()}),r}var KXe=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(t,r){var n=this;t(function(i){return r().getIntegration(e)?DZ.__assign(DZ.__assign({},i),{modules:n._getModules()}):i})},e.prototype._getModules=function(){return pR||(pR=GXe()),pR},e.id="Modules",e}();dR.Modules=KXe});var hR=v(ha=>{Object.defineProperty(ha,"__esModule",{value:!0});var XXe=vZ();ha.Console=XXe.Console;var YXe=CZ();ha.Http=YXe.Http;var ZXe=OZ();ha.OnUncaughtException=ZXe.OnUncaughtException;var JXe=kZ();ha.OnUnhandledRejection=JXe.OnUnhandledRejection;var QXe=qZ();ha.LinkedErrors=QXe.LinkedErrors;var eYe=MZ();ha.Modules=eYe.Modules;var tYe=cR();ha.ContextLines=tYe.ContextLines});var gR=v(_o=>{Object.defineProperty(_o,"__esModule",{value:!0});var vm=(gn(),mt(mn)),Eu=Yr(),jZ=vo(),mR=Rt(),rYe=require("domain"),nYe=ZO(),BZ=bu(),vp=hR();_o.defaultIntegrations=[new Eu.Integrations.InboundFilters,new Eu.Integrations.FunctionToString,new vp.ContextLines,new vp.Console,new vp.Http,new vp.OnUncaughtException,new vp.OnUnhandledRejection,new vp.LinkedErrors];function iYe(e){e===void 0&&(e={});var t,r=jZ.getMainCarrier(),n=((t=r.__SENTRY__)===null||t===void 0?void 0:t.integrations)||[];if(e.defaultIntegrations=e.defaultIntegrations===!1?[]:vm.__spread(Array.isArray(e.defaultIntegrations)?e.defaultIntegrations:_o.defaultIntegrations,n),e.dsn===void 0&&process.env.SENTRY_DSN&&(e.dsn=process.env.SENTRY_DSN),e.tracesSampleRate===void 0&&process.env.SENTRY_TRACES_SAMPLE_RATE){var i=parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE);isFinite(i)&&(e.tracesSampleRate=i)}if(e.release===void 0){var s=UZ();s!==void 0?e.release=s:e.autoSessionTracking=!1}e.environment===void 0&&process.env.SENTRY_ENVIRONMENT&&(e.environment=process.env.SENTRY_ENVIRONMENT),e.autoSessionTracking===void 0&&e.dsn!==void 0&&(e.autoSessionTracking=!0),rYe.active&&jZ.setHubOnCarrier(r,Eu.getCurrentHub()),Eu.initAndBind(nYe.NodeClient,e),e.autoSessionTracking&&cYe()}_o.init=iYe;function sYe(){return Eu.getCurrentHub().lastEventId()}_o.lastEventId=sYe;function oYe(e){return vm.__awaiter(this,void 0,void 0,function(){var t;return vm.__generator(this,function(r){return t=Eu.getCurrentHub().getClient(),t?[2,t.flush(e)]:(BZ.IS_DEBUG_BUILD&&mR.logger.warn("Cannot flush events. No client defined."),[2,Promise.resolve(!1)])})})}_o.flush=oYe;function aYe(e){return vm.__awaiter(this,void 0,void 0,function(){var t;return vm.__generator(this,function(r){return t=Eu.getCurrentHub().getClient(),t?[2,t.close(e)]:(BZ.IS_DEBUG_BUILD&&mR.logger.warn("Cannot flush events and disable SDK. No client defined."),[2,Promise.resolve(!1)])})})}_o.close=aYe;function uYe(e){if(e===void 0)return!1;var t=e&&e.getOptions();return t&&t.autoSessionTracking!==void 0?t.autoSessionTracking:!1}_o.isAutoSessionTrackingEnabled=uYe;function UZ(e){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;var t=mR.getGlobalObject();return t.SENTRY_RELEASE&&t.SENTRY_RELEASE.id?t.SENTRY_RELEASE.id:process.env.GITHUB_SHA||process.env.COMMIT_REF||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA||e}_o.getSentryRelease=UZ;function cYe(){var e=Eu.getCurrentHub();e.startSession(),process.on("beforeExit",function(){var t,r=(t=e.getScope())===null||t===void 0?void 0:t.getSession(),n=["exited","crashed"];r&&!n.includes(r.status)&&e.endSession()})}});var HZ=v(yR=>{Object.defineProperty(yR,"__esModule",{value:!0});var $Z=(gn(),mt(mn)),mb=require("fs"),vR=require("path");function lYe(e){var t=vR.resolve(e);if(!mb.existsSync(t))throw new Error("Cannot read contents of "+t+". Directory does not exist.");if(!mb.statSync(t).isDirectory())throw new Error("Cannot read contents of "+t+", because it is not a directory.");var r=function(n){return mb.readdirSync(n).reduce(function(i,s){var o=vR.join(n,s);return mb.statSync(o).isDirectory()?$Z.__spread(i,r(o)):$Z.__spread(i,[o])},[])};return r(t).map(function(n){return vR.relative(t,n)})}yR.deepReadDirSync=lYe});var WZ=v(_R=>{"use strict";_R.parse=dYe;_R.serialize=hYe;var fYe=decodeURIComponent,pYe=encodeURIComponent,gb=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function dYe(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var r={},n=t||{},i=e.split(";"),s=n.decode||fYe,o=0;o<i.length;o++){var a=i[o],u=a.indexOf("=");if(!(u<0)){var l=a.substring(0,u).trim();if(r[l]==null){var f=a.substring(u+1,a.length).trim();f[0]==='"'&&(f=f.slice(1,-1)),r[l]=mYe(f,s)}}}return r}function hYe(e,t,r){var n=r||{},i=n.encode||pYe;if(typeof i!="function")throw new TypeError("option encode is invalid");if(!gb.test(e))throw new TypeError("argument name is invalid");var s=i(t);if(s&&!gb.test(s))throw new TypeError("argument val is invalid");var o=e+"="+s;if(n.maxAge!=null){var a=n.maxAge-0;if(isNaN(a)||!isFinite(a))throw new TypeError("option maxAge is invalid");o+="; Max-Age="+Math.floor(a)}if(n.domain){if(!gb.test(n.domain))throw new TypeError("option domain is invalid");o+="; Domain="+n.domain}if(n.path){if(!gb.test(n.path))throw new TypeError("option path is invalid");o+="; Path="+n.path}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");o+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(o+="; HttpOnly"),n.secure&&(o+="; Secure"),n.sameSite){var u=typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite;switch(u){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o}function mYe(e,t){try{return t(e)}catch{return e}}});var VZ=v(Zc=>{Object.defineProperty(Zc,"__esModule",{value:!0});var xo=(gn(),mt(mn)),Xc=Yr(),Yc=Rt(),gYe=WZ(),vYe=require("domain"),yYe=require("os"),_Ye=require("url"),xYe=bu(),ym=gR();function bYe(){return function(t,r,n){var i;t.headers&&Yc.isString(t.headers["sentry-trace"])&&(i=Yc.extractTraceparentData(t.headers["sentry-trace"]));var s=Xc.startTransaction(xo.__assign({name:vb(t,{path:!0,method:!0}),op:"http.server"},i),{request:yb(t)});Xc.getCurrentHub().configureScope(function(o){o.setSpan(s)}),r.__sentry_transaction=s,r.once("finish",function(){setImmediate(function(){wYe(s,t),s.setHttpStatus(r.statusCode),s.finish()})}),n()}}Zc.tracingHandler=bYe;function wYe(e,t){e&&(e.name=vb(t,{path:!0,method:!0}),e.setData("url",t.originalUrl),e.setData("baseUrl",t.baseUrl),e.setData("query",t.query))}function vb(e,t){t===void 0&&(t={});var r,n=(r=e.method)===null||r===void 0?void 0:r.toUpperCase(),i="";e.route?i=""+(e.baseUrl||"")+e.route.path:(e.originalUrl||e.url)&&(i=Yc.stripUrlQueryAndFragment(e.originalUrl||e.url||""));var s="";return t.method&&n&&(s+=n),t.method&&t.path&&(s+=" "),t.path&&i&&(s+=i),s}function SYe(e,t){var r;switch(t){case"path":return vb(e,{path:!0});case"handler":return((r=e.route)===null||r===void 0?void 0:r.stack[0].name)||"<anonymous>";case"methodPath":default:return vb(e,{path:!0,method:!0})}}var EYe=["id","username","email"];function TYe(e,t){var r={},n=Array.isArray(t)?t:EYe;return n.forEach(function(i){e&&i in e&&(r[i]=e[i])}),r}var CYe=["cookies","data","headers","method","query_string","url"];function yb(e,t){t===void 0&&(t=CYe);var r={},n=e.headers||e.header||{},i=e.method,s=e.hostname||e.host||n.host||"<no host>",o=e.protocol==="https"||e.secure||(e.socket||{}).encrypted?"https":"http",a=e.originalUrl||e.url||"",u=o+"://"+s+a;return t.forEach(function(l){switch(l){case"headers":r.headers=n;break;case"method":r.method=i;break;case"url":r.url=u;break;case"cookies":r.cookies=e.cookies||gYe.parse(n.cookie||"");break;case"query_string":r.query_string=e.query||_Ye.parse(a||"",!1).query;break;case"data":if(i==="GET"||i==="HEAD")break;e.body!==void 0&&(r.data=Yc.isString(e.body)?e.body:JSON.stringify(Yc.normalize(e.body)));break;default:({}).hasOwnProperty.call(e,l)&&(r[l]=e[l])}}),r}Zc.extractRequestData=yb;function zZ(e,t,r){if(r=xo.__assign({ip:!1,request:!0,serverName:!0,transaction:!0,user:!0,version:!0},r),r.version&&(e.contexts=xo.__assign(xo.__assign({},e.contexts),{runtime:{name:"node",version:global.process.version}})),r.request){var n=Array.isArray(r.request)?yb(t,r.request):yb(t);e.request=xo.__assign(xo.__assign({},e.request),n)}if(r.serverName&&!e.server_name&&(e.server_name=global.process.env.SENTRY_NAME||yYe.hostname()),r.user){var i=t.user&&Yc.isPlainObject(t.user)?TYe(t.user,r.user):{};Object.keys(i)&&(e.user=xo.__assign(xo.__assign({},e.user),i))}if(r.ip){var s=t.ip||t.connection&&t.connection.remoteAddress;s&&(e.user=xo.__assign(xo.__assign({},e.user),{ip_address:s}))}return r.transaction&&!e.transaction&&(e.transaction=SYe(t,r.transaction)),e}Zc.parseRequest=zZ;function AYe(e){var t=Xc.getCurrentHub(),r=t.getClient();if(r&&ym.isAutoSessionTrackingEnabled(r)){r.initSessionFlusher();var n=t.getScope();n&&n.getSession()&&n.setSession()}return function(s,o,a){if(e&&e.flushTimeout&&e.flushTimeout>0){var u=o.end;o.end=function(f,d,h){var m=this;ym.flush(e.flushTimeout).then(function(){u.call(m,f,d,h)}).then(null,function(g){xYe.IS_DEBUG_BUILD&&Yc.logger.error(g),u.call(m,f,d,h)})}}var l=vYe.create();l.add(s),l.add(o),l.on("error",a),l.run(function(){var f=Xc.getCurrentHub();f.configureScope(function(d){d.addEventProcessor(function(g){return zZ(g,s,e)});var h=f.getClient();if(ym.isAutoSessionTrackingEnabled(h)){var m=f.getScope();m&&m.setRequestSession({status:"ok"})}}),o.once("finish",function(){var d=f.getClient();ym.isAutoSessionTrackingEnabled(d)&&setImmediate(function(){d&&d._captureRequestSession&&d._captureRequestSession()})}),a()})}}Zc.requestHandler=AYe;function IYe(e){var t=e.status||e.statusCode||e.status_code||e.output&&e.output.statusCode;return t?parseInt(t,10):500}function NYe(e){var t=IYe(e);return t>=500}function OYe(e){return function(r,n,i,s){var o=e&&e.shouldHandleError||NYe;if(o(r)){Xc.withScope(function(a){var u=i.__sentry_transaction;u&&a.getSpan()===void 0&&a.setSpan(u);var l=Xc.getCurrentHub().getClient();if(l&&ym.isAutoSessionTrackingEnabled(l)){var f=l._sessionFlusher!==void 0;if(f){var d=a.getRequestSession();d&&d.status!==void 0&&(d.status="crashed")}}var h=Xc.captureException(r);i.sentry=h,s(r)});return}s(r)}}Zc.errorHandler=OYe});var KZ=v(vt=>{Object.defineProperty(vt,"__esModule",{value:!0});var GZ=(gn(),mt(mn)),RYe=Jf();vt.Severity=RYe.Severity;var kr=Yr();vt.addGlobalEventProcessor=kr.addGlobalEventProcessor;vt.addBreadcrumb=kr.addBreadcrumb;vt.captureException=kr.captureException;vt.captureEvent=kr.captureEvent;vt.captureMessage=kr.captureMessage;vt.configureScope=kr.configureScope;vt.getHubFromCarrier=kr.getHubFromCarrier;vt.getCurrentHub=kr.getCurrentHub;vt.Hub=kr.Hub;vt.makeMain=kr.makeMain;vt.Scope=kr.Scope;vt.Session=kr.Session;vt.startTransaction=kr.startTransaction;vt.SDK_VERSION=kr.SDK_VERSION;vt.setContext=kr.setContext;vt.setExtra=kr.setExtra;vt.setExtras=kr.setExtras;vt.setTag=kr.setTag;vt.setTags=kr.setTags;vt.setUser=kr.setUser;vt.withScope=kr.withScope;var kYe=KO();vt.NodeBackend=kYe.NodeBackend;var PYe=ZO();vt.NodeClient=PYe.NodeClient;var yp=gR();vt.defaultIntegrations=yp.defaultIntegrations;vt.init=yp.init;vt.lastEventId=yp.lastEventId;vt.flush=yp.flush;vt.close=yp.close;vt.getSentryRelease=yp.getSentryRelease;var qYe=HZ();vt.deepReadDirSync=qYe.deepReadDirSync;var DYe=NO();vt.SDK_NAME=DYe.SDK_NAME;var LYe=Yr(),FYe=vo(),MYe=require("domain"),jYe=VZ();vt.Handlers=jYe;var BYe=hR(),UYe=HO();vt.Transports=UYe;var $Ye=GZ.__assign(GZ.__assign({},LYe.Integrations),BYe);vt.Integrations=$Ye;var _m=FYe.getMainCarrier();_m.__SENTRY__&&(_m.__SENTRY__.extensions=_m.__SENTRY__.extensions||{},_m.__SENTRY__.extensions.domain=_m.__SENTRY__.extensions.domain||MYe)});var XZ,xm,YZ,bm,xR,$t,wo=oe(()=>{"use strict";XZ=ve(iX()),xm=ve(KZ());ur();_p();YZ=()=>{var e;return(process.env.AMPT_STAGE==="prod"||((e=process.env.AMPT_ENDPOINT)==null?void 0:e.endsWith("ampt.dev")))&&!process.env.JEST_WORKER_ID};YZ()&&xm.init({dsn:"https://5f27cbf3265a475abff6b7999ae73179@o1265020.ingest.us.sentry.io/6448443",tracesSampleRate:0});xR=class{constructor(){yr(this,"orgName");yr(this,"user");yr(this,"config");kd(this,bm,(0,XZ.ulid)());yr(this,"auth");yr(this,"captureException",t=>{bo.error({err:t},"captureException"),YZ()&&(xm==null||xm.captureException(t,{tags:{sessionId:Os(this,bm)}}))})}getSessionId(){return Os(this,bm)}loadAmptConfig(){this.config=bR(),bo.debug({config:this.config},"loadAmptConfig")}getLoggedInUser(){var t;if(this.config||this.loadAmptConfig(),this.config&&((t=this.config)!=null&&t.userId)){let{sessions:r}=this.config,n=r==null?void 0:r[this.config.userId];if(n!=null&&n.accessToken&&(this.auth={accessToken:n.accessToken}),n&&n.username&&n.refreshToken)return{userId:this.config.userId,username:n.username,name:n.name,email:n.email,expiresAt:n.expiresAt,refreshToken:n.refreshToken,accessToken:n.accessToken}}return null}saveConfig(t){this.config={...this.config,...t},wR(this.config)}updateLogin(t){if(this.config){let r=this.getLoggedInUser();if(r&&r.userId){let n=Date.now()+t.expiresIn*1e3,{userId:i,username:s,name:o,email:a,refreshToken:u}=r;this.saveConfig({userId:i,sessions:{[i]:{userId:i,username:s,name:o,email:a,refreshToken:u,accessToken:t.accessToken,expiresAt:n}}})}}}storeToken(t,r){this.auth={accessToken:t},this.updateLogin({accessToken:t,expiresIn:r})}writeUpdateCheck(){let t=Math.round(Date.now()/1e3);this.config&&this.saveConfig({...this.config,meta:{...this.config.meta,last_update_check:t}})}shouldCheckForCliUpdate(){var t;if(this.config){let r=(t=this.config.meta)==null?void 0:t.last_update_check,n=Math.round(Date.now()/1e3);return!r||n-r>60*60*24}return!0}setUser(t){this.user=t}onLogin(t,r){if(t){let{refreshToken:n,accessToken:i,expiresIn:s}=r,o=Date.now()+s*1e3;this.saveConfig({userId:t.userId,meta:{created_at:Math.round(Date.now()/1e3)},sessions:{[t.userId]:{userId:t.userId,username:t.username,name:t.name,email:t.email,refreshToken:n,accessToken:i,expiresAt:o}}}),bo.debug({userName:t.username},"saved config file"),this.setUser(t),bo.debug({userName:t.username},"set user in session")}}shouldPromptTutorial(){var t,r,n,i,s,o,a,u,l;if((t=this.user)!=null&&t.preferences){let f=((n=(r=this.user)==null?void 0:r.preferences)==null?void 0:n.connectedCount)>=3,d=((i=this.user)==null?void 0:i.userAgeDays)&&((s=this.user)==null?void 0:s.userAgeDays)>30;return{showTutorial:((a=(o=this.user)==null?void 0:o.preferences)==null?void 0:a.showTutorial)===void 0?!0:(l=(u=this.user)==null?void 0:u.preferences)==null?void 0:l.showTutorial,allowDismiss:d?!0:f}}return{showTutorial:!1,allowDismiss:!1}}};bm=new WeakMap;$t=new xR});var _b,xb,Tu,SR,Se,bo,_p=oe(()=>{"use strict";_b=ve(rX()),xb=ve(require("path")),Tu=ve(mc());wo();SR=class{logger;enabled;logFilePath;logToConsole;pinoArgs;pinoDestination;initLogDestination(){try{(0,Tu.removeSync)(this.logFilePath)}catch(t){process.env.AMPT_DEBUG&&console.error("Error removing log file: ",t)}finally{if(this.enabled)try{(0,Tu.ensureFileSync)(this.logFilePath)}catch{this.enabled=!1}}this.pinoDestination=this.enabled&&!this.logToConsole?_b.default.destination({dest:this.logFilePath,sync:process.platform!=="win32"}):void 0}constructor(){this.enabled=!process.env.AMPT_DISABLE_LOGS,this.logFilePath=process.env.AMPT_LOG_DIR||xb.default.join(process.cwd(),".ampt","logs"),this.logToConsole=process.env.AMPT_LOG_TO_CONSOLE==="true",this.initLogDestination(),this.pinoArgs={enabled:this.enabled,level:process.env.AMPT_LOG_LEVEL||"info",mixin:()=>({sessionId:$t.getSessionId()}),redact:{remove:!0,paths:["credentials","accessKey","token","idToken","refreshToken","accessToken"]}},this.logger=(0,_b.default)(this.pinoArgs,this.pinoDestination)}disable(){this.enabled=!1}enable(){this.enabled=!0;let t=xb.default.join(process.cwd(),".ampt");this.logFilePath=process.env.AMPT_LOG_DIR||xb.default.join(t,"logs"),(0,Tu.existsSync)(t)||(0,Tu.mkdirSync)(t),this.initLogDestination(),this.pinoArgs={...this.pinoArgs,enabled:this.enabled},this.logger=(0,_b.default)(this.pinoArgs,this.pinoDestination)}child(t){return this.logger.child(t)}debug(...t){this.enabled&&this.logger.debug(...t)}warn(...t){this.enabled&&this.logger.warn(...t)}error(...t){this.enabled&&this.logger.error(...t)}info(...t){this.enabled&&this.logger.info(...t)}fatal(...t){this.enabled&&this.logger.fatal(...t)}trace(...t){this.enabled&&this.logger.trace(...t)}},Se=new SR,bo=Se});var wm=v((V2t,HYe)=>{HYe.exports={name:"@ampt/cli",version:"1.1.8-beta.0",description:"Ampt command line interface",main:"./dist/index.js",types:"./types/index.d.ts",engines:{node:">=16.0.0 <21.0.0"},publishConfig:{access:"public"},bin:{ampt:"./bin/bin"},scripts:{prepublishOnly:"npm run build",build:"node esbuild.mjs",watch:"node esbuild.mjs --watch",test:'LOG_LEVEL=silent AWS_REGION=us-east-1 NODE_OPTIONS="--no-warnings --experimental-vm-modules" jest',eslint:"eslint .",prettier:"prettier --check ."},author:"Ampt Inc <hello@getampt.com>",license:"Apache-2.0",optionalDependencies:{fsevents:"~2.3.2"},babel:{presets:["@babel/preset-typescript"]},devDependencies:{"@astrojs/webapi":"^1.1.1","@sentry/node":"^6.16.1","@types/express":"^4.17.13","@types/http-proxy":"^1.17.8","@types/write-file-atomic":"^4.0.0","@types/ws":"^8.5.3","adm-zip":"^0.5.5","ansi-escapes":"^4.3.1",axios:"^1.6.5","axios-retry":"^4.0.0",chalk:"^4.1.0","child-process-ext":"^2.1.1",chokidar:"^3.5.0",chunk:"^0.0.3",dayjs:"^1.10.4",debounce:"^1.2.1",del:"^6.0.0",figures:"^3.2.0","fs-extra":"^9.0.1","get-port":"^5.0.0","git-list-updated":"^1.2.1","github-release-from-cc-changelog":"^2.2.0","http-proxy":"^1.18.1",ignore:"^5.2.0","is-git-url":"^1.0.0","is-installed-globally":"^0.4.0","it-parallel":"^2.0.1","jwt-decode":"^3.1.2",keypress:"^0.2.1","lz4-wasm-nodejs":"^0.9.2",minimist:"^1.2.5","node-emoji":"^1.10.0","node-resolve":"^1.3.4","normalize-path":"^3.0.0",open:"^8.2.0","parse-packagejson-name":"^1.0.1",pluralize:"^8.0.0",ramda:"^0.27.2",semver:"^5.7.1","strip-ansi":"^6.0.0",terminate:"^2.5.0","tree-kill":"^1.2.2",ulid:"^2.3.0",which:"^2.0.2","write-file-atomic":"^4.0.2"},dependencies:{esbuild:"^0.19.5",joycon:"^3.1.1",pirates:"^4.0.6","source-map-support":"^0.5.21","tsconfig-paths":"^4.2.0"}}});var JZ,ZZ,WYe,ER,TR,ze,J2t,CR=oe(()=>{"use strict";JZ=ve(require("https"));hx();Y9();_p();wo();({version:ZZ}=wm()),WYe=new JZ.default.Agent({keepAlive:!0}),ER=class e{axios;static config(){return{apiEndpoint:process.env.AMPT_ENDPOINT,apiKey:process.env.AMPT_API_KEY}}constructor(){this.axios=po.create({httpsAgent:WYe}),mx(this.axios,{retries:10,retryDelay:mx.exponentialDelay,retryCondition:t=>{var s;let r=t.response&&t.response.status||"unknown",n=t.response&&t.response.data&&t.response.data.message||"unknown",i=mx.isNetworkOrIdempotentRequestError(t)&&r!==500||r===429||r===503;return i&&bo.debug({status:r,message:n,response:(s=t.response)==null?void 0:s.data},"retryable request error"),i}}),this.axios.defaults.headers.common={},this.axios.defaults.headers.put={},this.axios.defaults.headers.get={}}async request(t={}){var _,S,b,C,T,w,E,N,U,M,F,k,q,O;let{apiEndpoint:r,apiKey:n}=e.config(),i=t.root||r,s=(_=$t.auth)==null?void 0:_.accessToken,{method:o="POST",params:a,headers:u={},body:l,endpoint:f}=t,{url:d=`${i}${f}`,responseType:h}=t;n&&d.startsWith(r)?u.Authorization=`Basic ${n}`:s&&d.startsWith(r)&&(u.Authorization=`Bearer ${s}`),l&&f&&(u["Content-Type"]="application/json");let m=$t.getSessionId();f&&(u["User-Agent"]=`ampt-cli/${ZZ}`,u["ampt-version"]=ZZ,u["ampt-session-id"]=m);let g={url:d,method:o,headers:u,params:a,data:l,maxContentLength:1/0,maxBodyLength:1/0,onUploadProgress:t.onUploadProgress};h&&(g.responseType=h);try{return bo.debug({method:o,url:d,sessionId:m},"request"),(await this.axios(g)).data}catch(H){if(((S=H.response)==null?void 0:S.status)===403&&((C=(b=H.response)==null?void 0:b.data)==null?void 0:C.code)==="EXPIRED_TOKEN")return bo.debug({status:H.response.status,code:H.response.data.code},"Token expired, refreshing"),await((T=$t.user)==null?void 0:T.refreshAccessToken()),this.request(t);if(((w=H.response)==null?void 0:w.status)===403){let G=new Error("Forbidden");throw G.message="You do not have permission to access this resource.",G.name="ForbiddenError",G}if(((E=H.response)==null?void 0:E.status)===404)return;if(((N=H.response)==null?void 0:N.status)===409){let G=new Error("Conflict");throw G.message="Conflict",G.name="ConflictError",G}if(bo.error({status:(U=H.response)==null?void 0:U.status,data:(M=H.response)==null?void 0:M.data},"request error"),H.response&&H.response.data){let G=new Error(H.response.data.message||H.response.data);throw(F=H.response.data.message)!=null&&F.includes("Request Entity Too Large")?(G.message="Your code size is too large. Try reducing it by adding to .deployignore",G.name="EntityTooLargeError"):(k=H.response.data.message)!=null&&k.includes("User disabled")?(G.message=H.response.data.detail||"Your account has been disabled. Please contact support@getampt.com for more information.",G.name="UserDisabledError"):(q=H.response.data.message)!=null&&q.includes("App limit reached")?(G.message="You have reached your Organization's app limit. Please upgrade your plan or delete an app.",G.name="AppLimitReachedError"):(O=H.response.data.message)!=null&&O.includes("Instance limit reached")?(G.message="You have reached your Organization's environment limit. Please upgrade your plan or delete an environment.",G.name="EnvironmentLimitReachedError"):G.name=H.response.data.name||null,G.statusCode=H.response.data.statusCode||H.response.status||null,G}throw H}}},TR=new ER,ze=TR.request.bind(TR),J2t=TR.request});var QZ,eJ=oe(()=>{"use strict";QZ=async(e,t)=>{let r,n=new Promise(i=>{r=setTimeout(()=>i(null),t)});return Promise.race([e,n]).then(i=>(clearTimeout(r),i))}});var bb,tJ=oe(()=>{"use strict";bb=e=>e?e===0?"less than a second":e===1?"1 second":`${e} seconds`:"a few seconds"});var Cu,AR=oe(()=>{"use strict";Cu=async e=>new Promise(t=>setTimeout(t,e).unref())});var cr,IR,NR=oe(()=>{"use strict";ur();wo();cr=e=>{(async()=>{let{eventName:t,eventData:r={}}=e,n=$t.orgName;if(!n){Se.warn({eventName:t},"Could not send report - no org name found");return}try{await ze({method:"POST",body:{eventName:t,eventData:{...r,shell:!0}},endpoint:`/orgs/${n}/analytics`})}catch(i){$t.captureException(i),process.env.AMPT_DEBUG&&console.error(i)}})()},IR=cr});async function wb(e){try{let t="https://ampt.dev/public/templates/manifest-tags.json",{data:r}=await po.get(t);return r.filter(n=>n.tags.includes("starter"))}catch(t){return process.env.AMPT_DEBUG&&e.logError(t),[]}}var OR=oe(()=>{"use strict";hx()});var RR,rJ,kR=oe(()=>{"use strict";RR=e=>{try{return process.kill(e,0)}catch(t){return t.code==="EPERM"}},rJ=RR});async function Sb(e,t){let r=e.eventNames(),n=new Map;for(let i of r)n.set(i,e.listeners(i));try{return await t()}finally{e.removeAllListeners();for(let i of r)for(let s of n.get(i))e.on(i,s)}}var nJ=oe(()=>{"use strict"});function iJ(e){e=e.trim();let t=0,r=null,n=null,i=null,s=[];for(let o=0;o<e.length;o++){if(r=n,n=e.charAt(o),n===" "&&!i){r!==" "&&t++;continue}if(n===i){i=null;continue}else if((n==="'"||n==='"')&&!i){i=n;continue}s[t]||(s[t]=""),s[t]+=n}return s}var sJ=oe(()=>{"use strict"});var oJ=oe(()=>{"use strict"});var aJ=v((xp,Sm)=>{(function(){var e,t="4.17.21",r=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",i="Expected a function",s="Invalid `variable` option passed into `_.template`",o="__lodash_hash_undefined__",a=500,u="__lodash_placeholder__",l=1,f=2,d=4,h=1,m=2,g=1,_=2,S=4,b=8,C=16,T=32,w=64,E=128,N=256,U=512,M=30,F="...",k=800,q=16,O=1,H=2,G=3,j=1/0,B=9007199254740991,ee=17976931348623157e292,Y=0/0,se=4294967295,pe=se-1,xe=se>>>1,_e=[["ary",E],["bind",g],["bindKey",_],["curry",b],["curryRight",C],["flip",U],["partial",T],["partialRight",w],["rearg",N]],Le="[object Arguments]",Ue="[object Array]",it="[object AsyncFunction]",Ie="[object Boolean]",Lt="[object Date]",st="[object DOMException]",ge="[object Error]",D="[object Function]",A="[object GeneratorFunction]",te="[object Map]",X="[object Number]",Xe="[object Null]",He="[object Object]",zt="[object Promise]",gr="[object Proxy]",jr="[object RegExp]",Re="[object Set]",Xt="[object String]",fn="[object Symbol]",Al="[object Undefined]",Js="[object WeakMap]",$u="[object WeakSet]",Qs="[object ArrayBuffer]",P="[object DataView]",z="[object Float32Array]",K="[object Float64Array]",ie="[object Int8Array]",ce="[object Int16Array]",Ee="[object Int32Array]",Je="[object Uint8Array]",dt="[object Uint8ClampedArray]",Wr="[object Uint16Array]",bi="[object Uint32Array]",Nr=/\b__p \+= '';/g,Ve=/\b(__p \+=) '' \+/g,Ts=/(__e\(.*?\)|\b__t\)) \+\n'';/g,sv=/&(?:amp|lt|gt|quot|#39);/g,Il=/[&<>"']/g,ov=RegExp(sv.source),av=RegExp(Il.source),pd=/<%-([\s\S]+?)%>/g,wi=/<%([\s\S]+?)%>/g,dd=/<%=([\s\S]+?)%>/g,hd=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,uv=/^\w*$/,md=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Hu=/[\\^$.*+?()[\]{}|]/g,Nl=RegExp(Hu.source),Wu=/^\s+/,cv=/\s/,lv=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Jwe=/\{\n\/\* \[wrapped with (.+)\] \*/,Qwe=/,? & /,e0e=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,t0e=/[()=,{}\[\]\/\s]/,r0e=/\\(\\)?/g,n0e=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,XL=/\w*$/,i0e=/^[-+]0x[0-9a-f]+$/i,s0e=/^0b[01]+$/i,o0e=/^\[object .+?Constructor\]$/,a0e=/^0o[0-7]+$/i,u0e=/^(?:0|[1-9]\d*)$/,c0e=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,fv=/($^)/,l0e=/['\n\r\u2028\u2029\\]/g,pv="\\ud800-\\udfff",f0e="\\u0300-\\u036f",p0e="\\ufe20-\\ufe2f",d0e="\\u20d0-\\u20ff",YL=f0e+p0e+d0e,ZL="\\u2700-\\u27bf",JL="a-z\\xdf-\\xf6\\xf8-\\xff",h0e="\\xac\\xb1\\xd7\\xf7",m0e="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",g0e="\\u2000-\\u206f",v0e=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",QL="A-Z\\xc0-\\xd6\\xd8-\\xde",e2="\\ufe0e\\ufe0f",t2=h0e+m0e+g0e+v0e,gS="['\u2019]",y0e="["+pv+"]",r2="["+t2+"]",dv="["+YL+"]",n2="\\d+",_0e="["+ZL+"]",i2="["+JL+"]",s2="[^"+pv+t2+n2+ZL+JL+QL+"]",vS="\\ud83c[\\udffb-\\udfff]",x0e="(?:"+dv+"|"+vS+")",o2="[^"+pv+"]",yS="(?:\\ud83c[\\udde6-\\uddff]){2}",_S="[\\ud800-\\udbff][\\udc00-\\udfff]",Ol="["+QL+"]",a2="\\u200d",u2="(?:"+i2+"|"+s2+")",b0e="(?:"+Ol+"|"+s2+")",c2="(?:"+gS+"(?:d|ll|m|re|s|t|ve))?",l2="(?:"+gS+"(?:D|LL|M|RE|S|T|VE))?",f2=x0e+"?",p2="["+e2+"]?",w0e="(?:"+a2+"(?:"+[o2,yS,_S].join("|")+")"+p2+f2+")*",S0e="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",E0e="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",d2=p2+f2+w0e,T0e="(?:"+[_0e,yS,_S].join("|")+")"+d2,C0e="(?:"+[o2+dv+"?",dv,yS,_S,y0e].join("|")+")",A0e=RegExp(gS,"g"),I0e=RegExp(dv,"g"),xS=RegExp(vS+"(?="+vS+")|"+C0e+d2,"g"),N0e=RegExp([Ol+"?"+i2+"+"+c2+"(?="+[r2,Ol,"$"].join("|")+")",b0e+"+"+l2+"(?="+[r2,Ol+u2,"$"].join("|")+")",Ol+"?"+u2+"+"+c2,Ol+"+"+l2,E0e,S0e,n2,T0e].join("|"),"g"),O0e=RegExp("["+a2+pv+YL+e2+"]"),R0e=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,k0e=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],P0e=-1,rr={};rr[z]=rr[K]=rr[ie]=rr[ce]=rr[Ee]=rr[Je]=rr[dt]=rr[Wr]=rr[bi]=!0,rr[Le]=rr[Ue]=rr[Qs]=rr[Ie]=rr[P]=rr[Lt]=rr[ge]=rr[D]=rr[te]=rr[X]=rr[He]=rr[jr]=rr[Re]=rr[Xt]=rr[Js]=!1;var er={};er[Le]=er[Ue]=er[Qs]=er[P]=er[Ie]=er[Lt]=er[z]=er[K]=er[ie]=er[ce]=er[Ee]=er[te]=er[X]=er[He]=er[jr]=er[Re]=er[Xt]=er[fn]=er[Je]=er[dt]=er[Wr]=er[bi]=!0,er[ge]=er[D]=er[Js]=!1;var q0e={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},D0e={"&":"&","<":"<",">":">",'"':""","'":"'"},L0e={"&":"&","<":"<",">":">",""":'"',"'":"'"},F0e={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},M0e=parseFloat,j0e=parseInt,h2=typeof global=="object"&&global&&global.Object===Object&&global,B0e=typeof self=="object"&&self&&self.Object===Object&&self,tn=h2||B0e||Function("return this")(),bS=typeof xp=="object"&&xp&&!xp.nodeType&&xp,zu=bS&&typeof Sm=="object"&&Sm&&!Sm.nodeType&&Sm,m2=zu&&zu.exports===bS,wS=m2&&h2.process,Vi=function(){try{var Z=zu&&zu.require&&zu.require("util").types;return Z||wS&&wS.binding&&wS.binding("util")}catch{}}(),g2=Vi&&Vi.isArrayBuffer,v2=Vi&&Vi.isDate,y2=Vi&&Vi.isMap,_2=Vi&&Vi.isRegExp,x2=Vi&&Vi.isSet,b2=Vi&&Vi.isTypedArray;function Si(Z,ae,ne){switch(ne.length){case 0:return Z.call(ae);case 1:return Z.call(ae,ne[0]);case 2:return Z.call(ae,ne[0],ne[1]);case 3:return Z.call(ae,ne[0],ne[1],ne[2])}return Z.apply(ae,ne)}function U0e(Z,ae,ne,Ce){for(var Qe=-1,Ot=Z==null?0:Z.length;++Qe<Ot;){var zr=Z[Qe];ae(Ce,zr,ne(zr),Z)}return Ce}function Gi(Z,ae){for(var ne=-1,Ce=Z==null?0:Z.length;++ne<Ce&&ae(Z[ne],ne,Z)!==!1;);return Z}function $0e(Z,ae){for(var ne=Z==null?0:Z.length;ne--&&ae(Z[ne],ne,Z)!==!1;);return Z}function w2(Z,ae){for(var ne=-1,Ce=Z==null?0:Z.length;++ne<Ce;)if(!ae(Z[ne],ne,Z))return!1;return!0}function qa(Z,ae){for(var ne=-1,Ce=Z==null?0:Z.length,Qe=0,Ot=[];++ne<Ce;){var zr=Z[ne];ae(zr,ne,Z)&&(Ot[Qe++]=zr)}return Ot}function hv(Z,ae){var ne=Z==null?0:Z.length;return!!ne&&Rl(Z,ae,0)>-1}function SS(Z,ae,ne){for(var Ce=-1,Qe=Z==null?0:Z.length;++Ce<Qe;)if(ne(ae,Z[Ce]))return!0;return!1}function sr(Z,ae){for(var ne=-1,Ce=Z==null?0:Z.length,Qe=Array(Ce);++ne<Ce;)Qe[ne]=ae(Z[ne],ne,Z);return Qe}function Da(Z,ae){for(var ne=-1,Ce=ae.length,Qe=Z.length;++ne<Ce;)Z[Qe+ne]=ae[ne];return Z}function ES(Z,ae,ne,Ce){var Qe=-1,Ot=Z==null?0:Z.length;for(Ce&&Ot&&(ne=Z[++Qe]);++Qe<Ot;)ne=ae(ne,Z[Qe],Qe,Z);return ne}function H0e(Z,ae,ne,Ce){var Qe=Z==null?0:Z.length;for(Ce&&Qe&&(ne=Z[--Qe]);Qe--;)ne=ae(ne,Z[Qe],Qe,Z);return ne}function TS(Z,ae){for(var ne=-1,Ce=Z==null?0:Z.length;++ne<Ce;)if(ae(Z[ne],ne,Z))return!0;return!1}var W0e=CS("length");function z0e(Z){return Z.split("")}function V0e(Z){return Z.match(e0e)||[]}function S2(Z,ae,ne){var Ce;return ne(Z,function(Qe,Ot,zr){if(ae(Qe,Ot,zr))return Ce=Ot,!1}),Ce}function mv(Z,ae,ne,Ce){for(var Qe=Z.length,Ot=ne+(Ce?1:-1);Ce?Ot--:++Ot<Qe;)if(ae(Z[Ot],Ot,Z))return Ot;return-1}function Rl(Z,ae,ne){return ae===ae?iSe(Z,ae,ne):mv(Z,E2,ne)}function G0e(Z,ae,ne,Ce){for(var Qe=ne-1,Ot=Z.length;++Qe<Ot;)if(Ce(Z[Qe],ae))return Qe;return-1}function E2(Z){return Z!==Z}function T2(Z,ae){var ne=Z==null?0:Z.length;return ne?IS(Z,ae)/ne:Y}function CS(Z){return function(ae){return ae==null?e:ae[Z]}}function AS(Z){return function(ae){return Z==null?e:Z[ae]}}function C2(Z,ae,ne,Ce,Qe){return Qe(Z,function(Ot,zr,Yt){ne=Ce?(Ce=!1,Ot):ae(ne,Ot,zr,Yt)}),ne}function K0e(Z,ae){var ne=Z.length;for(Z.sort(ae);ne--;)Z[ne]=Z[ne].value;return Z}function IS(Z,ae){for(var ne,Ce=-1,Qe=Z.length;++Ce<Qe;){var Ot=ae(Z[Ce]);Ot!==e&&(ne=ne===e?Ot:ne+Ot)}return ne}function NS(Z,ae){for(var ne=-1,Ce=Array(Z);++ne<Z;)Ce[ne]=ae(ne);return Ce}function X0e(Z,ae){return sr(ae,function(ne){return[ne,Z[ne]]})}function A2(Z){return Z&&Z.slice(0,R2(Z)+1).replace(Wu,"")}function Ei(Z){return function(ae){return Z(ae)}}function OS(Z,ae){return sr(ae,function(ne){return Z[ne]})}function gd(Z,ae){return Z.has(ae)}function I2(Z,ae){for(var ne=-1,Ce=Z.length;++ne<Ce&&Rl(ae,Z[ne],0)>-1;);return ne}function N2(Z,ae){for(var ne=Z.length;ne--&&Rl(ae,Z[ne],0)>-1;);return ne}function Y0e(Z,ae){for(var ne=Z.length,Ce=0;ne--;)Z[ne]===ae&&++Ce;return Ce}var Z0e=AS(q0e),J0e=AS(D0e);function Q0e(Z){return"\\"+F0e[Z]}function eSe(Z,ae){return Z==null?e:Z[ae]}function kl(Z){return O0e.test(Z)}function tSe(Z){return R0e.test(Z)}function rSe(Z){for(var ae,ne=[];!(ae=Z.next()).done;)ne.push(ae.value);return ne}function RS(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Ce,Qe){ne[++ae]=[Qe,Ce]}),ne}function O2(Z,ae){return function(ne){return Z(ae(ne))}}function La(Z,ae){for(var ne=-1,Ce=Z.length,Qe=0,Ot=[];++ne<Ce;){var zr=Z[ne];(zr===ae||zr===u)&&(Z[ne]=u,Ot[Qe++]=ne)}return Ot}function gv(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Ce){ne[++ae]=Ce}),ne}function nSe(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Ce){ne[++ae]=[Ce,Ce]}),ne}function iSe(Z,ae,ne){for(var Ce=ne-1,Qe=Z.length;++Ce<Qe;)if(Z[Ce]===ae)return Ce;return-1}function sSe(Z,ae,ne){for(var Ce=ne+1;Ce--;)if(Z[Ce]===ae)return Ce;return Ce}function Pl(Z){return kl(Z)?aSe(Z):W0e(Z)}function Cs(Z){return kl(Z)?uSe(Z):z0e(Z)}function R2(Z){for(var ae=Z.length;ae--&&cv.test(Z.charAt(ae)););return ae}var oSe=AS(L0e);function aSe(Z){for(var ae=xS.lastIndex=0;xS.test(Z);)++ae;return ae}function uSe(Z){return Z.match(xS)||[]}function cSe(Z){return Z.match(N0e)||[]}var lSe=function Z(ae){ae=ae==null?tn:Fa.defaults(tn.Object(),ae,Fa.pick(tn,k0e));var ne=ae.Array,Ce=ae.Date,Qe=ae.Error,Ot=ae.Function,zr=ae.Math,Yt=ae.Object,kS=ae.RegExp,fSe=ae.String,Ki=ae.TypeError,vv=ne.prototype,pSe=Ot.prototype,ql=Yt.prototype,yv=ae["__core-js_shared__"],_v=pSe.toString,Ft=ql.hasOwnProperty,dSe=0,k2=function(){var c=/[^.]+$/.exec(yv&&yv.keys&&yv.keys.IE_PROTO||"");return c?"Symbol(src)_1."+c:""}(),xv=ql.toString,hSe=_v.call(Yt),mSe=tn._,gSe=kS("^"+_v.call(Ft).replace(Hu,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),bv=m2?ae.Buffer:e,Ma=ae.Symbol,wv=ae.Uint8Array,P2=bv?bv.allocUnsafe:e,Sv=O2(Yt.getPrototypeOf,Yt),q2=Yt.create,D2=ql.propertyIsEnumerable,Ev=vv.splice,L2=Ma?Ma.isConcatSpreadable:e,vd=Ma?Ma.iterator:e,Vu=Ma?Ma.toStringTag:e,Tv=function(){try{var c=Zu(Yt,"defineProperty");return c({},"",{}),c}catch{}}(),vSe=ae.clearTimeout!==tn.clearTimeout&&ae.clearTimeout,ySe=Ce&&Ce.now!==tn.Date.now&&Ce.now,_Se=ae.setTimeout!==tn.setTimeout&&ae.setTimeout,Cv=zr.ceil,Av=zr.floor,PS=Yt.getOwnPropertySymbols,xSe=bv?bv.isBuffer:e,F2=ae.isFinite,bSe=vv.join,wSe=O2(Yt.keys,Yt),Vr=zr.max,In=zr.min,SSe=Ce.now,ESe=ae.parseInt,M2=zr.random,TSe=vv.reverse,qS=Zu(ae,"DataView"),yd=Zu(ae,"Map"),DS=Zu(ae,"Promise"),Dl=Zu(ae,"Set"),_d=Zu(ae,"WeakMap"),xd=Zu(Yt,"create"),Iv=_d&&new _d,Ll={},CSe=Ju(qS),ASe=Ju(yd),ISe=Ju(DS),NSe=Ju(Dl),OSe=Ju(_d),Nv=Ma?Ma.prototype:e,bd=Nv?Nv.valueOf:e,j2=Nv?Nv.toString:e;function R(c){if(Sr(c)&&!ot(c)&&!(c instanceof yt)){if(c instanceof Xi)return c;if(Ft.call(c,"__wrapped__"))return BF(c)}return new Xi(c)}var Fl=function(){function c(){}return function(p){if(!vr(p))return{};if(q2)return q2(p);c.prototype=p;var y=new c;return c.prototype=e,y}}();function Ov(){}function Xi(c,p){this.__wrapped__=c,this.__actions__=[],this.__chain__=!!p,this.__index__=0,this.__values__=e}R.templateSettings={escape:pd,evaluate:wi,interpolate:dd,variable:"",imports:{_:R}},R.prototype=Ov.prototype,R.prototype.constructor=R,Xi.prototype=Fl(Ov.prototype),Xi.prototype.constructor=Xi;function yt(c){this.__wrapped__=c,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=se,this.__views__=[]}function RSe(){var c=new yt(this.__wrapped__);return c.__actions__=ti(this.__actions__),c.__dir__=this.__dir__,c.__filtered__=this.__filtered__,c.__iteratees__=ti(this.__iteratees__),c.__takeCount__=this.__takeCount__,c.__views__=ti(this.__views__),c}function kSe(){if(this.__filtered__){var c=new yt(this);c.__dir__=-1,c.__filtered__=!0}else c=this.clone(),c.__dir__*=-1;return c}function PSe(){var c=this.__wrapped__.value(),p=this.__dir__,y=ot(c),x=p<0,I=y?c.length:0,L=zEe(0,I,this.__views__),W=L.start,V=L.end,J=V-W,ue=x?V:W-1,le=this.__iteratees__,de=le.length,we=0,De=In(J,this.__takeCount__);if(!y||!x&&I==J&&De==J)return cF(c,this.__actions__);var Ge=[];e:for(;J--&&we<De;){ue+=p;for(var lt=-1,Ke=c[ue];++lt<de;){var ht=le[lt],St=ht.iteratee,Ai=ht.type,Hn=St(Ke);if(Ai==H)Ke=Hn;else if(!Hn){if(Ai==O)continue e;break e}}Ge[we++]=Ke}return Ge}yt.prototype=Fl(Ov.prototype),yt.prototype.constructor=yt;function Gu(c){var p=-1,y=c==null?0:c.length;for(this.clear();++p<y;){var x=c[p];this.set(x[0],x[1])}}function qSe(){this.__data__=xd?xd(null):{},this.size=0}function DSe(c){var p=this.has(c)&&delete this.__data__[c];return this.size-=p?1:0,p}function LSe(c){var p=this.__data__;if(xd){var y=p[c];return y===o?e:y}return Ft.call(p,c)?p[c]:e}function FSe(c){var p=this.__data__;return xd?p[c]!==e:Ft.call(p,c)}function MSe(c,p){var y=this.__data__;return this.size+=this.has(c)?0:1,y[c]=xd&&p===e?o:p,this}Gu.prototype.clear=qSe,Gu.prototype.delete=DSe,Gu.prototype.get=LSe,Gu.prototype.has=FSe,Gu.prototype.set=MSe;function Mo(c){var p=-1,y=c==null?0:c.length;for(this.clear();++p<y;){var x=c[p];this.set(x[0],x[1])}}function jSe(){this.__data__=[],this.size=0}function BSe(c){var p=this.__data__,y=Rv(p,c);if(y<0)return!1;var x=p.length-1;return y==x?p.pop():Ev.call(p,y,1),--this.size,!0}function USe(c){var p=this.__data__,y=Rv(p,c);return y<0?e:p[y][1]}function $Se(c){return Rv(this.__data__,c)>-1}function HSe(c,p){var y=this.__data__,x=Rv(y,c);return x<0?(++this.size,y.push([c,p])):y[x][1]=p,this}Mo.prototype.clear=jSe,Mo.prototype.delete=BSe,Mo.prototype.get=USe,Mo.prototype.has=$Se,Mo.prototype.set=HSe;function jo(c){var p=-1,y=c==null?0:c.length;for(this.clear();++p<y;){var x=c[p];this.set(x[0],x[1])}}function WSe(){this.size=0,this.__data__={hash:new Gu,map:new(yd||Mo),string:new Gu}}function zSe(c){var p=Hv(this,c).delete(c);return this.size-=p?1:0,p}function VSe(c){return Hv(this,c).get(c)}function GSe(c){return Hv(this,c).has(c)}function KSe(c,p){var y=Hv(this,c),x=y.size;return y.set(c,p),this.size+=y.size==x?0:1,this}jo.prototype.clear=WSe,jo.prototype.delete=zSe,jo.prototype.get=VSe,jo.prototype.has=GSe,jo.prototype.set=KSe;function Ku(c){var p=-1,y=c==null?0:c.length;for(this.__data__=new jo;++p<y;)this.add(c[p])}function XSe(c){return this.__data__.set(c,o),this}function YSe(c){return this.__data__.has(c)}Ku.prototype.add=Ku.prototype.push=XSe,Ku.prototype.has=YSe;function As(c){var p=this.__data__=new Mo(c);this.size=p.size}function ZSe(){this.__data__=new Mo,this.size=0}function JSe(c){var p=this.__data__,y=p.delete(c);return this.size=p.size,y}function QSe(c){return this.__data__.get(c)}function eEe(c){return this.__data__.has(c)}function tEe(c,p){var y=this.__data__;if(y instanceof Mo){var x=y.__data__;if(!yd||x.length<r-1)return x.push([c,p]),this.size=++y.size,this;y=this.__data__=new jo(x)}return y.set(c,p),this.size=y.size,this}As.prototype.clear=ZSe,As.prototype.delete=JSe,As.prototype.get=QSe,As.prototype.has=eEe,As.prototype.set=tEe;function B2(c,p){var y=ot(c),x=!y&&Qu(c),I=!y&&!x&&Ha(c),L=!y&&!x&&!I&&Ul(c),W=y||x||I||L,V=W?NS(c.length,fSe):[],J=V.length;for(var ue in c)(p||Ft.call(c,ue))&&!(W&&(ue=="length"||I&&(ue=="offset"||ue=="parent")||L&&(ue=="buffer"||ue=="byteLength"||ue=="byteOffset")||Ho(ue,J)))&&V.push(ue);return V}function U2(c){var p=c.length;return p?c[VS(0,p-1)]:e}function rEe(c,p){return Wv(ti(c),Xu(p,0,c.length))}function nEe(c){return Wv(ti(c))}function LS(c,p,y){(y!==e&&!Is(c[p],y)||y===e&&!(p in c))&&Bo(c,p,y)}function wd(c,p,y){var x=c[p];(!(Ft.call(c,p)&&Is(x,y))||y===e&&!(p in c))&&Bo(c,p,y)}function Rv(c,p){for(var y=c.length;y--;)if(Is(c[y][0],p))return y;return-1}function iEe(c,p,y,x){return ja(c,function(I,L,W){p(x,I,y(I),W)}),x}function $2(c,p){return c&&to(p,rn(p),c)}function sEe(c,p){return c&&to(p,ni(p),c)}function Bo(c,p,y){p=="__proto__"&&Tv?Tv(c,p,{configurable:!0,enumerable:!0,value:y,writable:!0}):c[p]=y}function FS(c,p){for(var y=-1,x=p.length,I=ne(x),L=c==null;++y<x;)I[y]=L?e:vE(c,p[y]);return I}function Xu(c,p,y){return c===c&&(y!==e&&(c=c<=y?c:y),p!==e&&(c=c>=p?c:p)),c}function Yi(c,p,y,x,I,L){var W,V=p&l,J=p&f,ue=p&d;if(y&&(W=I?y(c,x,I,L):y(c)),W!==e)return W;if(!vr(c))return c;var le=ot(c);if(le){if(W=GEe(c),!V)return ti(c,W)}else{var de=Nn(c),we=de==D||de==A;if(Ha(c))return pF(c,V);if(de==He||de==Le||we&&!I){if(W=J||we?{}:RF(c),!V)return J?LEe(c,sEe(W,c)):DEe(c,$2(W,c))}else{if(!er[de])return I?c:{};W=KEe(c,de,V)}}L||(L=new As);var De=L.get(c);if(De)return De;L.set(c,W),oM(c)?c.forEach(function(Ke){W.add(Yi(Ke,p,y,Ke,c,L))}):iM(c)&&c.forEach(function(Ke,ht){W.set(ht,Yi(Ke,p,y,ht,c,L))});var Ge=ue?J?nE:rE:J?ni:rn,lt=le?e:Ge(c);return Gi(lt||c,function(Ke,ht){lt&&(ht=Ke,Ke=c[ht]),wd(W,ht,Yi(Ke,p,y,ht,c,L))}),W}function oEe(c){var p=rn(c);return function(y){return H2(y,c,p)}}function H2(c,p,y){var x=y.length;if(c==null)return!x;for(c=Yt(c);x--;){var I=y[x],L=p[I],W=c[I];if(W===e&&!(I in c)||!L(W))return!1}return!0}function W2(c,p,y){if(typeof c!="function")throw new Ki(i);return Nd(function(){c.apply(e,y)},p)}function Sd(c,p,y,x){var I=-1,L=hv,W=!0,V=c.length,J=[],ue=p.length;if(!V)return J;y&&(p=sr(p,Ei(y))),x?(L=SS,W=!1):p.length>=r&&(L=gd,W=!1,p=new Ku(p));e:for(;++I<V;){var le=c[I],de=y==null?le:y(le);if(le=x||le!==0?le:0,W&&de===de){for(var we=ue;we--;)if(p[we]===de)continue e;J.push(le)}else L(p,de,x)||J.push(le)}return J}var ja=vF(eo),z2=vF(jS,!0);function aEe(c,p){var y=!0;return ja(c,function(x,I,L){return y=!!p(x,I,L),y}),y}function kv(c,p,y){for(var x=-1,I=c.length;++x<I;){var L=c[x],W=p(L);if(W!=null&&(V===e?W===W&&!Ci(W):y(W,V)))var V=W,J=L}return J}function uEe(c,p,y,x){var I=c.length;for(y=ct(y),y<0&&(y=-y>I?0:I+y),x=x===e||x>I?I:ct(x),x<0&&(x+=I),x=y>x?0:uM(x);y<x;)c[y++]=p;return c}function V2(c,p){var y=[];return ja(c,function(x,I,L){p(x,I,L)&&y.push(x)}),y}function pn(c,p,y,x,I){var L=-1,W=c.length;for(y||(y=YEe),I||(I=[]);++L<W;){var V=c[L];p>0&&y(V)?p>1?pn(V,p-1,y,x,I):Da(I,V):x||(I[I.length]=V)}return I}var MS=yF(),G2=yF(!0);function eo(c,p){return c&&MS(c,p,rn)}function jS(c,p){return c&&G2(c,p,rn)}function Pv(c,p){return qa(p,function(y){return Wo(c[y])})}function Yu(c,p){p=Ua(p,c);for(var y=0,x=p.length;c!=null&&y<x;)c=c[ro(p[y++])];return y&&y==x?c:e}function K2(c,p,y){var x=p(c);return ot(c)?x:Da(x,y(c))}function Un(c){return c==null?c===e?Al:Xe:Vu&&Vu in Yt(c)?WEe(c):nTe(c)}function BS(c,p){return c>p}function cEe(c,p){return c!=null&&Ft.call(c,p)}function lEe(c,p){return c!=null&&p in Yt(c)}function fEe(c,p,y){return c>=In(p,y)&&c<Vr(p,y)}function US(c,p,y){for(var x=y?SS:hv,I=c[0].length,L=c.length,W=L,V=ne(L),J=1/0,ue=[];W--;){var le=c[W];W&&p&&(le=sr(le,Ei(p))),J=In(le.length,J),V[W]=!y&&(p||I>=120&&le.length>=120)?new Ku(W&&le):e}le=c[0];var de=-1,we=V[0];e:for(;++de<I&&ue.length<J;){var De=le[de],Ge=p?p(De):De;if(De=y||De!==0?De:0,!(we?gd(we,Ge):x(ue,Ge,y))){for(W=L;--W;){var lt=V[W];if(!(lt?gd(lt,Ge):x(c[W],Ge,y)))continue e}we&&we.push(Ge),ue.push(De)}}return ue}function pEe(c,p,y,x){return eo(c,function(I,L,W){p(x,y(I),L,W)}),x}function Ed(c,p,y){p=Ua(p,c),c=DF(c,p);var x=c==null?c:c[ro(Ji(p))];return x==null?e:Si(x,c,y)}function X2(c){return Sr(c)&&Un(c)==Le}function dEe(c){return Sr(c)&&Un(c)==Qs}function hEe(c){return Sr(c)&&Un(c)==Lt}function Td(c,p,y,x,I){return c===p?!0:c==null||p==null||!Sr(c)&&!Sr(p)?c!==c&&p!==p:mEe(c,p,y,x,Td,I)}function mEe(c,p,y,x,I,L){var W=ot(c),V=ot(p),J=W?Ue:Nn(c),ue=V?Ue:Nn(p);J=J==Le?He:J,ue=ue==Le?He:ue;var le=J==He,de=ue==He,we=J==ue;if(we&&Ha(c)){if(!Ha(p))return!1;W=!0,le=!1}if(we&&!le)return L||(L=new As),W||Ul(c)?IF(c,p,y,x,I,L):$Ee(c,p,J,y,x,I,L);if(!(y&h)){var De=le&&Ft.call(c,"__wrapped__"),Ge=de&&Ft.call(p,"__wrapped__");if(De||Ge){var lt=De?c.value():c,Ke=Ge?p.value():p;return L||(L=new As),I(lt,Ke,y,x,L)}}return we?(L||(L=new As),HEe(c,p,y,x,I,L)):!1}function gEe(c){return Sr(c)&&Nn(c)==te}function $S(c,p,y,x){var I=y.length,L=I,W=!x;if(c==null)return!L;for(c=Yt(c);I--;){var V=y[I];if(W&&V[2]?V[1]!==c[V[0]]:!(V[0]in c))return!1}for(;++I<L;){V=y[I];var J=V[0],ue=c[J],le=V[1];if(W&&V[2]){if(ue===e&&!(J in c))return!1}else{var de=new As;if(x)var we=x(ue,le,J,c,p,de);if(!(we===e?Td(le,ue,h|m,x,de):we))return!1}}return!0}function Y2(c){if(!vr(c)||JEe(c))return!1;var p=Wo(c)?gSe:o0e;return p.test(Ju(c))}function vEe(c){return Sr(c)&&Un(c)==jr}function yEe(c){return Sr(c)&&Nn(c)==Re}function _Ee(c){return Sr(c)&&Yv(c.length)&&!!rr[Un(c)]}function Z2(c){return typeof c=="function"?c:c==null?ii:typeof c=="object"?ot(c)?eF(c[0],c[1]):Q2(c):_M(c)}function HS(c){if(!Id(c))return wSe(c);var p=[];for(var y in Yt(c))Ft.call(c,y)&&y!="constructor"&&p.push(y);return p}function xEe(c){if(!vr(c))return rTe(c);var p=Id(c),y=[];for(var x in c)x=="constructor"&&(p||!Ft.call(c,x))||y.push(x);return y}function WS(c,p){return c<p}function J2(c,p){var y=-1,x=ri(c)?ne(c.length):[];return ja(c,function(I,L,W){x[++y]=p(I,L,W)}),x}function Q2(c){var p=sE(c);return p.length==1&&p[0][2]?PF(p[0][0],p[0][1]):function(y){return y===c||$S(y,c,p)}}function eF(c,p){return aE(c)&&kF(p)?PF(ro(c),p):function(y){var x=vE(y,c);return x===e&&x===p?yE(y,c):Td(p,x,h|m)}}function qv(c,p,y,x,I){c!==p&&MS(p,function(L,W){if(I||(I=new As),vr(L))bEe(c,p,W,y,qv,x,I);else{var V=x?x(cE(c,W),L,W+"",c,p,I):e;V===e&&(V=L),LS(c,W,V)}},ni)}function bEe(c,p,y,x,I,L,W){var V=cE(c,y),J=cE(p,y),ue=W.get(J);if(ue){LS(c,y,ue);return}var le=L?L(V,J,y+"",c,p,W):e,de=le===e;if(de){var we=ot(J),De=!we&&Ha(J),Ge=!we&&!De&&Ul(J);le=J,we||De||Ge?ot(V)?le=V:Or(V)?le=ti(V):De?(de=!1,le=pF(J,!0)):Ge?(de=!1,le=dF(J,!0)):le=[]:Od(J)||Qu(J)?(le=V,Qu(V)?le=cM(V):(!vr(V)||Wo(V))&&(le=RF(J))):de=!1}de&&(W.set(J,le),I(le,J,x,L,W),W.delete(J)),LS(c,y,le)}function tF(c,p){var y=c.length;if(y)return p+=p<0?y:0,Ho(p,y)?c[p]:e}function rF(c,p,y){p.length?p=sr(p,function(L){return ot(L)?function(W){return Yu(W,L.length===1?L[0]:L)}:L}):p=[ii];var x=-1;p=sr(p,Ei(We()));var I=J2(c,function(L,W,V){var J=sr(p,function(ue){return ue(L)});return{criteria:J,index:++x,value:L}});return K0e(I,function(L,W){return qEe(L,W,y)})}function wEe(c,p){return nF(c,p,function(y,x){return yE(c,x)})}function nF(c,p,y){for(var x=-1,I=p.length,L={};++x<I;){var W=p[x],V=Yu(c,W);y(V,W)&&Cd(L,Ua(W,c),V)}return L}function SEe(c){return function(p){return Yu(p,c)}}function zS(c,p,y,x){var I=x?G0e:Rl,L=-1,W=p.length,V=c;for(c===p&&(p=ti(p)),y&&(V=sr(c,Ei(y)));++L<W;)for(var J=0,ue=p[L],le=y?y(ue):ue;(J=I(V,le,J,x))>-1;)V!==c&&Ev.call(V,J,1),Ev.call(c,J,1);return c}function iF(c,p){for(var y=c?p.length:0,x=y-1;y--;){var I=p[y];if(y==x||I!==L){var L=I;Ho(I)?Ev.call(c,I,1):XS(c,I)}}return c}function VS(c,p){return c+Av(M2()*(p-c+1))}function EEe(c,p,y,x){for(var I=-1,L=Vr(Cv((p-c)/(y||1)),0),W=ne(L);L--;)W[x?L:++I]=c,c+=y;return W}function GS(c,p){var y="";if(!c||p<1||p>B)return y;do p%2&&(y+=c),p=Av(p/2),p&&(c+=c);while(p);return y}function ft(c,p){return lE(qF(c,p,ii),c+"")}function TEe(c){return U2($l(c))}function CEe(c,p){var y=$l(c);return Wv(y,Xu(p,0,y.length))}function Cd(c,p,y,x){if(!vr(c))return c;p=Ua(p,c);for(var I=-1,L=p.length,W=L-1,V=c;V!=null&&++I<L;){var J=ro(p[I]),ue=y;if(J==="__proto__"||J==="constructor"||J==="prototype")return c;if(I!=W){var le=V[J];ue=x?x(le,J,V):e,ue===e&&(ue=vr(le)?le:Ho(p[I+1])?[]:{})}wd(V,J,ue),V=V[J]}return c}var sF=Iv?function(c,p){return Iv.set(c,p),c}:ii,AEe=Tv?function(c,p){return Tv(c,"toString",{configurable:!0,enumerable:!1,value:xE(p),writable:!0})}:ii;function IEe(c){return Wv($l(c))}function Zi(c,p,y){var x=-1,I=c.length;p<0&&(p=-p>I?0:I+p),y=y>I?I:y,y<0&&(y+=I),I=p>y?0:y-p>>>0,p>>>=0;for(var L=ne(I);++x<I;)L[x]=c[x+p];return L}function NEe(c,p){var y;return ja(c,function(x,I,L){return y=p(x,I,L),!y}),!!y}function Dv(c,p,y){var x=0,I=c==null?x:c.length;if(typeof p=="number"&&p===p&&I<=xe){for(;x<I;){var L=x+I>>>1,W=c[L];W!==null&&!Ci(W)&&(y?W<=p:W<p)?x=L+1:I=L}return I}return KS(c,p,ii,y)}function KS(c,p,y,x){var I=0,L=c==null?0:c.length;if(L===0)return 0;p=y(p);for(var W=p!==p,V=p===null,J=Ci(p),ue=p===e;I<L;){var le=Av((I+L)/2),de=y(c[le]),we=de!==e,De=de===null,Ge=de===de,lt=Ci(de);if(W)var Ke=x||Ge;else ue?Ke=Ge&&(x||we):V?Ke=Ge&&we&&(x||!De):J?Ke=Ge&&we&&!De&&(x||!lt):De||lt?Ke=!1:Ke=x?de<=p:de<p;Ke?I=le+1:L=le}return In(L,pe)}function oF(c,p){for(var y=-1,x=c.length,I=0,L=[];++y<x;){var W=c[y],V=p?p(W):W;if(!y||!Is(V,J)){var J=V;L[I++]=W===0?0:W}}return L}function aF(c){return typeof c=="number"?c:Ci(c)?Y:+c}function Ti(c){if(typeof c=="string")return c;if(ot(c))return sr(c,Ti)+"";if(Ci(c))return j2?j2.call(c):"";var p=c+"";return p=="0"&&1/c==-j?"-0":p}function Ba(c,p,y){var x=-1,I=hv,L=c.length,W=!0,V=[],J=V;if(y)W=!1,I=SS;else if(L>=r){var ue=p?null:BEe(c);if(ue)return gv(ue);W=!1,I=gd,J=new Ku}else J=p?[]:V;e:for(;++x<L;){var le=c[x],de=p?p(le):le;if(le=y||le!==0?le:0,W&&de===de){for(var we=J.length;we--;)if(J[we]===de)continue e;p&&J.push(de),V.push(le)}else I(J,de,y)||(J!==V&&J.push(de),V.push(le))}return V}function XS(c,p){return p=Ua(p,c),c=DF(c,p),c==null||delete c[ro(Ji(p))]}function uF(c,p,y,x){return Cd(c,p,y(Yu(c,p)),x)}function Lv(c,p,y,x){for(var I=c.length,L=x?I:-1;(x?L--:++L<I)&&p(c[L],L,c););return y?Zi(c,x?0:L,x?L+1:I):Zi(c,x?L+1:0,x?I:L)}function cF(c,p){var y=c;return y instanceof yt&&(y=y.value()),ES(p,function(x,I){return I.func.apply(I.thisArg,Da([x],I.args))},y)}function YS(c,p,y){var x=c.length;if(x<2)return x?Ba(c[0]):[];for(var I=-1,L=ne(x);++I<x;)for(var W=c[I],V=-1;++V<x;)V!=I&&(L[I]=Sd(L[I]||W,c[V],p,y));return Ba(pn(L,1),p,y)}function lF(c,p,y){for(var x=-1,I=c.length,L=p.length,W={};++x<I;){var V=x<L?p[x]:e;y(W,c[x],V)}return W}function ZS(c){return Or(c)?c:[]}function JS(c){return typeof c=="function"?c:ii}function Ua(c,p){return ot(c)?c:aE(c,p)?[c]:jF(kt(c))}var OEe=ft;function $a(c,p,y){var x=c.length;return y=y===e?x:y,!p&&y>=x?c:Zi(c,p,y)}var fF=vSe||function(c){return tn.clearTimeout(c)};function pF(c,p){if(p)return c.slice();var y=c.length,x=P2?P2(y):new c.constructor(y);return c.copy(x),x}function QS(c){var p=new c.constructor(c.byteLength);return new wv(p).set(new wv(c)),p}function REe(c,p){var y=p?QS(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.byteLength)}function kEe(c){var p=new c.constructor(c.source,XL.exec(c));return p.lastIndex=c.lastIndex,p}function PEe(c){return bd?Yt(bd.call(c)):{}}function dF(c,p){var y=p?QS(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.length)}function hF(c,p){if(c!==p){var y=c!==e,x=c===null,I=c===c,L=Ci(c),W=p!==e,V=p===null,J=p===p,ue=Ci(p);if(!V&&!ue&&!L&&c>p||L&&W&&J&&!V&&!ue||x&&W&&J||!y&&J||!I)return 1;if(!x&&!L&&!ue&&c<p||ue&&y&&I&&!x&&!L||V&&y&&I||!W&&I||!J)return-1}return 0}function qEe(c,p,y){for(var x=-1,I=c.criteria,L=p.criteria,W=I.length,V=y.length;++x<W;){var J=hF(I[x],L[x]);if(J){if(x>=V)return J;var ue=y[x];return J*(ue=="desc"?-1:1)}}return c.index-p.index}function mF(c,p,y,x){for(var I=-1,L=c.length,W=y.length,V=-1,J=p.length,ue=Vr(L-W,0),le=ne(J+ue),de=!x;++V<J;)le[V]=p[V];for(;++I<W;)(de||I<L)&&(le[y[I]]=c[I]);for(;ue--;)le[V++]=c[I++];return le}function gF(c,p,y,x){for(var I=-1,L=c.length,W=-1,V=y.length,J=-1,ue=p.length,le=Vr(L-V,0),de=ne(le+ue),we=!x;++I<le;)de[I]=c[I];for(var De=I;++J<ue;)de[De+J]=p[J];for(;++W<V;)(we||I<L)&&(de[De+y[W]]=c[I++]);return de}function ti(c,p){var y=-1,x=c.length;for(p||(p=ne(x));++y<x;)p[y]=c[y];return p}function to(c,p,y,x){var I=!y;y||(y={});for(var L=-1,W=p.length;++L<W;){var V=p[L],J=x?x(y[V],c[V],V,y,c):e;J===e&&(J=c[V]),I?Bo(y,V,J):wd(y,V,J)}return y}function DEe(c,p){return to(c,oE(c),p)}function LEe(c,p){return to(c,NF(c),p)}function Fv(c,p){return function(y,x){var I=ot(y)?U0e:iEe,L=p?p():{};return I(y,c,We(x,2),L)}}function Ml(c){return ft(function(p,y){var x=-1,I=y.length,L=I>1?y[I-1]:e,W=I>2?y[2]:e;for(L=c.length>3&&typeof L=="function"?(I--,L):e,W&&$n(y[0],y[1],W)&&(L=I<3?e:L,I=1),p=Yt(p);++x<I;){var V=y[x];V&&c(p,V,x,L)}return p})}function vF(c,p){return function(y,x){if(y==null)return y;if(!ri(y))return c(y,x);for(var I=y.length,L=p?I:-1,W=Yt(y);(p?L--:++L<I)&&x(W[L],L,W)!==!1;);return y}}function yF(c){return function(p,y,x){for(var I=-1,L=Yt(p),W=x(p),V=W.length;V--;){var J=W[c?V:++I];if(y(L[J],J,L)===!1)break}return p}}function FEe(c,p,y){var x=p&g,I=Ad(c);function L(){var W=this&&this!==tn&&this instanceof L?I:c;return W.apply(x?y:this,arguments)}return L}function _F(c){return function(p){p=kt(p);var y=kl(p)?Cs(p):e,x=y?y[0]:p.charAt(0),I=y?$a(y,1).join(""):p.slice(1);return x[c]()+I}}function jl(c){return function(p){return ES(vM(gM(p).replace(A0e,"")),c,"")}}function Ad(c){return function(){var p=arguments;switch(p.length){case 0:return new c;case 1:return new c(p[0]);case 2:return new c(p[0],p[1]);case 3:return new c(p[0],p[1],p[2]);case 4:return new c(p[0],p[1],p[2],p[3]);case 5:return new c(p[0],p[1],p[2],p[3],p[4]);case 6:return new c(p[0],p[1],p[2],p[3],p[4],p[5]);case 7:return new c(p[0],p[1],p[2],p[3],p[4],p[5],p[6])}var y=Fl(c.prototype),x=c.apply(y,p);return vr(x)?x:y}}function MEe(c,p,y){var x=Ad(c);function I(){for(var L=arguments.length,W=ne(L),V=L,J=Bl(I);V--;)W[V]=arguments[V];var ue=L<3&&W[0]!==J&&W[L-1]!==J?[]:La(W,J);if(L-=ue.length,L<y)return EF(c,p,Mv,I.placeholder,e,W,ue,e,e,y-L);var le=this&&this!==tn&&this instanceof I?x:c;return Si(le,this,W)}return I}function xF(c){return function(p,y,x){var I=Yt(p);if(!ri(p)){var L=We(y,3);p=rn(p),y=function(V){return L(I[V],V,I)}}var W=c(p,y,x);return W>-1?I[L?p[W]:W]:e}}function bF(c){return $o(function(p){var y=p.length,x=y,I=Xi.prototype.thru;for(c&&p.reverse();x--;){var L=p[x];if(typeof L!="function")throw new Ki(i);if(I&&!W&&$v(L)=="wrapper")var W=new Xi([],!0)}for(x=W?x:y;++x<y;){L=p[x];var V=$v(L),J=V=="wrapper"?iE(L):e;J&&uE(J[0])&&J[1]==(E|b|T|N)&&!J[4].length&&J[9]==1?W=W[$v(J[0])].apply(W,J[3]):W=L.length==1&&uE(L)?W[V]():W.thru(L)}return function(){var ue=arguments,le=ue[0];if(W&&ue.length==1&&ot(le))return W.plant(le).value();for(var de=0,we=y?p[de].apply(this,ue):le;++de<y;)we=p[de].call(this,we);return we}})}function Mv(c,p,y,x,I,L,W,V,J,ue){var le=p&E,de=p&g,we=p&_,De=p&(b|C),Ge=p&U,lt=we?e:Ad(c);function Ke(){for(var ht=arguments.length,St=ne(ht),Ai=ht;Ai--;)St[Ai]=arguments[Ai];if(De)var Hn=Bl(Ke),Ii=Y0e(St,Hn);if(x&&(St=mF(St,x,I,De)),L&&(St=gF(St,L,W,De)),ht-=Ii,De&&ht<ue){var Rr=La(St,Hn);return EF(c,p,Mv,Ke.placeholder,y,St,Rr,V,J,ue-ht)}var Ns=de?y:this,Vo=we?Ns[c]:c;return ht=St.length,V?St=iTe(St,V):Ge&&ht>1&&St.reverse(),le&&J<ht&&(St.length=J),this&&this!==tn&&this instanceof Ke&&(Vo=lt||Ad(Vo)),Vo.apply(Ns,St)}return Ke}function wF(c,p){return function(y,x){return pEe(y,c,p(x),{})}}function jv(c,p){return function(y,x){var I;if(y===e&&x===e)return p;if(y!==e&&(I=y),x!==e){if(I===e)return x;typeof y=="string"||typeof x=="string"?(y=Ti(y),x=Ti(x)):(y=aF(y),x=aF(x)),I=c(y,x)}return I}}function eE(c){return $o(function(p){return p=sr(p,Ei(We())),ft(function(y){var x=this;return c(p,function(I){return Si(I,x,y)})})})}function Bv(c,p){p=p===e?" ":Ti(p);var y=p.length;if(y<2)return y?GS(p,c):p;var x=GS(p,Cv(c/Pl(p)));return kl(p)?$a(Cs(x),0,c).join(""):x.slice(0,c)}function jEe(c,p,y,x){var I=p&g,L=Ad(c);function W(){for(var V=-1,J=arguments.length,ue=-1,le=x.length,de=ne(le+J),we=this&&this!==tn&&this instanceof W?L:c;++ue<le;)de[ue]=x[ue];for(;J--;)de[ue++]=arguments[++V];return Si(we,I?y:this,de)}return W}function SF(c){return function(p,y,x){return x&&typeof x!="number"&&$n(p,y,x)&&(y=x=e),p=zo(p),y===e?(y=p,p=0):y=zo(y),x=x===e?p<y?1:-1:zo(x),EEe(p,y,x,c)}}function Uv(c){return function(p,y){return typeof p=="string"&&typeof y=="string"||(p=Qi(p),y=Qi(y)),c(p,y)}}function EF(c,p,y,x,I,L,W,V,J,ue){var le=p&b,de=le?W:e,we=le?e:W,De=le?L:e,Ge=le?e:L;p|=le?T:w,p&=~(le?w:T),p&S||(p&=~(g|_));var lt=[c,p,I,De,de,Ge,we,V,J,ue],Ke=y.apply(e,lt);return uE(c)&&LF(Ke,lt),Ke.placeholder=x,FF(Ke,c,p)}function tE(c){var p=zr[c];return function(y,x){if(y=Qi(y),x=x==null?0:In(ct(x),292),x&&F2(y)){var I=(kt(y)+"e").split("e"),L=p(I[0]+"e"+(+I[1]+x));return I=(kt(L)+"e").split("e"),+(I[0]+"e"+(+I[1]-x))}return p(y)}}var BEe=Dl&&1/gv(new Dl([,-0]))[1]==j?function(c){return new Dl(c)}:SE;function TF(c){return function(p){var y=Nn(p);return y==te?RS(p):y==Re?nSe(p):X0e(p,c(p))}}function Uo(c,p,y,x,I,L,W,V){var J=p&_;if(!J&&typeof c!="function")throw new Ki(i);var ue=x?x.length:0;if(ue||(p&=~(T|w),x=I=e),W=W===e?W:Vr(ct(W),0),V=V===e?V:ct(V),ue-=I?I.length:0,p&w){var le=x,de=I;x=I=e}var we=J?e:iE(c),De=[c,p,y,x,I,le,de,L,W,V];if(we&&tTe(De,we),c=De[0],p=De[1],y=De[2],x=De[3],I=De[4],V=De[9]=De[9]===e?J?0:c.length:Vr(De[9]-ue,0),!V&&p&(b|C)&&(p&=~(b|C)),!p||p==g)var Ge=FEe(c,p,y);else p==b||p==C?Ge=MEe(c,p,V):(p==T||p==(g|T))&&!I.length?Ge=jEe(c,p,y,x):Ge=Mv.apply(e,De);var lt=we?sF:LF;return FF(lt(Ge,De),c,p)}function CF(c,p,y,x){return c===e||Is(c,ql[y])&&!Ft.call(x,y)?p:c}function AF(c,p,y,x,I,L){return vr(c)&&vr(p)&&(L.set(p,c),qv(c,p,e,AF,L),L.delete(p)),c}function UEe(c){return Od(c)?e:c}function IF(c,p,y,x,I,L){var W=y&h,V=c.length,J=p.length;if(V!=J&&!(W&&J>V))return!1;var ue=L.get(c),le=L.get(p);if(ue&&le)return ue==p&&le==c;var de=-1,we=!0,De=y&m?new Ku:e;for(L.set(c,p),L.set(p,c);++de<V;){var Ge=c[de],lt=p[de];if(x)var Ke=W?x(lt,Ge,de,p,c,L):x(Ge,lt,de,c,p,L);if(Ke!==e){if(Ke)continue;we=!1;break}if(De){if(!TS(p,function(ht,St){if(!gd(De,St)&&(Ge===ht||I(Ge,ht,y,x,L)))return De.push(St)})){we=!1;break}}else if(!(Ge===lt||I(Ge,lt,y,x,L))){we=!1;break}}return L.delete(c),L.delete(p),we}function $Ee(c,p,y,x,I,L,W){switch(y){case P:if(c.byteLength!=p.byteLength||c.byteOffset!=p.byteOffset)return!1;c=c.buffer,p=p.buffer;case Qs:return!(c.byteLength!=p.byteLength||!L(new wv(c),new wv(p)));case Ie:case Lt:case X:return Is(+c,+p);case ge:return c.name==p.name&&c.message==p.message;case jr:case Xt:return c==p+"";case te:var V=RS;case Re:var J=x&h;if(V||(V=gv),c.size!=p.size&&!J)return!1;var ue=W.get(c);if(ue)return ue==p;x|=m,W.set(c,p);var le=IF(V(c),V(p),x,I,L,W);return W.delete(c),le;case fn:if(bd)return bd.call(c)==bd.call(p)}return!1}function HEe(c,p,y,x,I,L){var W=y&h,V=rE(c),J=V.length,ue=rE(p),le=ue.length;if(J!=le&&!W)return!1;for(var de=J;de--;){var we=V[de];if(!(W?we in p:Ft.call(p,we)))return!1}var De=L.get(c),Ge=L.get(p);if(De&&Ge)return De==p&&Ge==c;var lt=!0;L.set(c,p),L.set(p,c);for(var Ke=W;++de<J;){we=V[de];var ht=c[we],St=p[we];if(x)var Ai=W?x(St,ht,we,p,c,L):x(ht,St,we,c,p,L);if(!(Ai===e?ht===St||I(ht,St,y,x,L):Ai)){lt=!1;break}Ke||(Ke=we=="constructor")}if(lt&&!Ke){var Hn=c.constructor,Ii=p.constructor;Hn!=Ii&&"constructor"in c&&"constructor"in p&&!(typeof Hn=="function"&&Hn instanceof Hn&&typeof Ii=="function"&&Ii instanceof Ii)&&(lt=!1)}return L.delete(c),L.delete(p),lt}function $o(c){return lE(qF(c,e,HF),c+"")}function rE(c){return K2(c,rn,oE)}function nE(c){return K2(c,ni,NF)}var iE=Iv?function(c){return Iv.get(c)}:SE;function $v(c){for(var p=c.name+"",y=Ll[p],x=Ft.call(Ll,p)?y.length:0;x--;){var I=y[x],L=I.func;if(L==null||L==c)return I.name}return p}function Bl(c){var p=Ft.call(R,"placeholder")?R:c;return p.placeholder}function We(){var c=R.iteratee||bE;return c=c===bE?Z2:c,arguments.length?c(arguments[0],arguments[1]):c}function Hv(c,p){var y=c.__data__;return ZEe(p)?y[typeof p=="string"?"string":"hash"]:y.map}function sE(c){for(var p=rn(c),y=p.length;y--;){var x=p[y],I=c[x];p[y]=[x,I,kF(I)]}return p}function Zu(c,p){var y=eSe(c,p);return Y2(y)?y:e}function WEe(c){var p=Ft.call(c,Vu),y=c[Vu];try{c[Vu]=e;var x=!0}catch{}var I=xv.call(c);return x&&(p?c[Vu]=y:delete c[Vu]),I}var oE=PS?function(c){return c==null?[]:(c=Yt(c),qa(PS(c),function(p){return D2.call(c,p)}))}:EE,NF=PS?function(c){for(var p=[];c;)Da(p,oE(c)),c=Sv(c);return p}:EE,Nn=Un;(qS&&Nn(new qS(new ArrayBuffer(1)))!=P||yd&&Nn(new yd)!=te||DS&&Nn(DS.resolve())!=zt||Dl&&Nn(new Dl)!=Re||_d&&Nn(new _d)!=Js)&&(Nn=function(c){var p=Un(c),y=p==He?c.constructor:e,x=y?Ju(y):"";if(x)switch(x){case CSe:return P;case ASe:return te;case ISe:return zt;case NSe:return Re;case OSe:return Js}return p});function zEe(c,p,y){for(var x=-1,I=y.length;++x<I;){var L=y[x],W=L.size;switch(L.type){case"drop":c+=W;break;case"dropRight":p-=W;break;case"take":p=In(p,c+W);break;case"takeRight":c=Vr(c,p-W);break}}return{start:c,end:p}}function VEe(c){var p=c.match(Jwe);return p?p[1].split(Qwe):[]}function OF(c,p,y){p=Ua(p,c);for(var x=-1,I=p.length,L=!1;++x<I;){var W=ro(p[x]);if(!(L=c!=null&&y(c,W)))break;c=c[W]}return L||++x!=I?L:(I=c==null?0:c.length,!!I&&Yv(I)&&Ho(W,I)&&(ot(c)||Qu(c)))}function GEe(c){var p=c.length,y=new c.constructor(p);return p&&typeof c[0]=="string"&&Ft.call(c,"index")&&(y.index=c.index,y.input=c.input),y}function RF(c){return typeof c.constructor=="function"&&!Id(c)?Fl(Sv(c)):{}}function KEe(c,p,y){var x=c.constructor;switch(p){case Qs:return QS(c);case Ie:case Lt:return new x(+c);case P:return REe(c,y);case z:case K:case ie:case ce:case Ee:case Je:case dt:case Wr:case bi:return dF(c,y);case te:return new x;case X:case Xt:return new x(c);case jr:return kEe(c);case Re:return new x;case fn:return PEe(c)}}function XEe(c,p){var y=p.length;if(!y)return c;var x=y-1;return p[x]=(y>1?"& ":"")+p[x],p=p.join(y>2?", ":" "),c.replace(lv,`{
|
|
142
|
+
`),PXe.addContextToFrame(a,s,r)}catch{}d.label=4;case 4:return i=n.next(),[3,2];case 5:return[3,8];case 6:return u=d.sent(),l={error:u},[3,8];case 7:try{i&&!i.done&&(f=n.return)&&f.call(n)}finally{if(l)throw l.error}return[7];case 8:return[2]}})})},e.id="ContextLines",e}();pb.ContextLines=jXe;function BXe(e){return Su.__awaiter(this,void 0,void 0,function(){var t,r,n;return Su.__generator(this,function(i){switch(i.label){case 0:if(t=uR.get(e),t!==void 0)return[2,t];r=null,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,FXe(e)];case 2:return r=i.sent(),[3,4];case 3:return n=i.sent(),[3,4];case 4:return uR.set(e,r),[2,r]}})})}});var qZ=v(fR=>{Object.defineProperty(fR,"__esModule",{value:!0});var db=(gn(),mt(mn)),lR=Yr(),hb=Rt(),UXe=CO(),$Xe=cR(),HXe="cause",WXe=5,zXe=function(){function e(t){t===void 0&&(t={}),this.name=e.id,this._key=t.key||HXe,this._limit=t.limit||WXe}return e.prototype.setupOnce=function(){lR.addGlobalEventProcessor(function(t,r){var n=lR.getCurrentHub().getIntegration(e);if(n){var i=n._handler&&n._handler.bind(n);return typeof i=="function"?i(t,r):t}return t})},e.prototype._handler=function(t,r){var n=this;return!t.exception||!t.exception.values||!r||!hb.isInstanceOf(r.originalException,Error)?hb.resolvedSyncPromise(t):new hb.SyncPromise(function(i){n._walkErrorTree(r.originalException,n._key).then(function(s){t&&t.exception&&t.exception.values&&(t.exception.values=db.__spread(s,t.exception.values)),i(t)}).then(null,function(){i(t)})})},e.prototype._walkErrorTree=function(t,r,n){n===void 0&&(n=[]);var i;return db.__awaiter(this,void 0,void 0,function(){var s,o,a=this;return db.__generator(this,function(u){switch(u.label){case 0:return!hb.isInstanceOf(t[r],Error)||n.length+1>=this._limit?[2,Promise.resolve(n)]:(s=UXe.exceptionFromError(t[r]),o=lR.getCurrentHub().getIntegration($Xe.ContextLines),o&&(!((i=s.stacktrace)===null||i===void 0)&&i.frames)?[4,o.addSourceContextToFrames(s.stacktrace.frames)]:[3,2]);case 1:u.sent(),u.label=2;case 2:return[2,new Promise(function(l,f){a._walkErrorTree(t[r],r,db.__spread([s],n)).then(l).then(null,function(){f()})})]}})})},e.id="LinkedErrors",e}();fR.LinkedErrors=zXe});var MZ=v(dR=>{Object.defineProperty(dR,"__esModule",{value:!0});var DZ=(gn(),mt(mn)),LZ=require("fs"),FZ=require("path"),pR;function VXe(){try{return require.cache?Object.keys(require.cache):[]}catch{return[]}}function GXe(){var e=require.main&&require.main.paths||[],t=VXe(),r={},n={};return t.forEach(function(i){var s=i,o=function(){var a=s;if(s=FZ.dirname(a),!(!s||a===s||n[a])){if(e.indexOf(s)<0)return o();var u=FZ.join(a,"package.json");if(n[a]=!0,!LZ.existsSync(u))return o();try{var l=JSON.parse(LZ.readFileSync(u,"utf8"));r[l.name]=l.version}catch{}}};o()}),r}var KXe=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(t,r){var n=this;t(function(i){return r().getIntegration(e)?DZ.__assign(DZ.__assign({},i),{modules:n._getModules()}):i})},e.prototype._getModules=function(){return pR||(pR=GXe()),pR},e.id="Modules",e}();dR.Modules=KXe});var hR=v(ha=>{Object.defineProperty(ha,"__esModule",{value:!0});var XXe=vZ();ha.Console=XXe.Console;var YXe=CZ();ha.Http=YXe.Http;var ZXe=OZ();ha.OnUncaughtException=ZXe.OnUncaughtException;var JXe=kZ();ha.OnUnhandledRejection=JXe.OnUnhandledRejection;var QXe=qZ();ha.LinkedErrors=QXe.LinkedErrors;var eYe=MZ();ha.Modules=eYe.Modules;var tYe=cR();ha.ContextLines=tYe.ContextLines});var gR=v(_o=>{Object.defineProperty(_o,"__esModule",{value:!0});var vm=(gn(),mt(mn)),Eu=Yr(),jZ=vo(),mR=Rt(),rYe=require("domain"),nYe=ZO(),BZ=bu(),vp=hR();_o.defaultIntegrations=[new Eu.Integrations.InboundFilters,new Eu.Integrations.FunctionToString,new vp.ContextLines,new vp.Console,new vp.Http,new vp.OnUncaughtException,new vp.OnUnhandledRejection,new vp.LinkedErrors];function iYe(e){e===void 0&&(e={});var t,r=jZ.getMainCarrier(),n=((t=r.__SENTRY__)===null||t===void 0?void 0:t.integrations)||[];if(e.defaultIntegrations=e.defaultIntegrations===!1?[]:vm.__spread(Array.isArray(e.defaultIntegrations)?e.defaultIntegrations:_o.defaultIntegrations,n),e.dsn===void 0&&process.env.SENTRY_DSN&&(e.dsn=process.env.SENTRY_DSN),e.tracesSampleRate===void 0&&process.env.SENTRY_TRACES_SAMPLE_RATE){var i=parseFloat(process.env.SENTRY_TRACES_SAMPLE_RATE);isFinite(i)&&(e.tracesSampleRate=i)}if(e.release===void 0){var s=UZ();s!==void 0?e.release=s:e.autoSessionTracking=!1}e.environment===void 0&&process.env.SENTRY_ENVIRONMENT&&(e.environment=process.env.SENTRY_ENVIRONMENT),e.autoSessionTracking===void 0&&e.dsn!==void 0&&(e.autoSessionTracking=!0),rYe.active&&jZ.setHubOnCarrier(r,Eu.getCurrentHub()),Eu.initAndBind(nYe.NodeClient,e),e.autoSessionTracking&&cYe()}_o.init=iYe;function sYe(){return Eu.getCurrentHub().lastEventId()}_o.lastEventId=sYe;function oYe(e){return vm.__awaiter(this,void 0,void 0,function(){var t;return vm.__generator(this,function(r){return t=Eu.getCurrentHub().getClient(),t?[2,t.flush(e)]:(BZ.IS_DEBUG_BUILD&&mR.logger.warn("Cannot flush events. No client defined."),[2,Promise.resolve(!1)])})})}_o.flush=oYe;function aYe(e){return vm.__awaiter(this,void 0,void 0,function(){var t;return vm.__generator(this,function(r){return t=Eu.getCurrentHub().getClient(),t?[2,t.close(e)]:(BZ.IS_DEBUG_BUILD&&mR.logger.warn("Cannot flush events and disable SDK. No client defined."),[2,Promise.resolve(!1)])})})}_o.close=aYe;function uYe(e){if(e===void 0)return!1;var t=e&&e.getOptions();return t&&t.autoSessionTracking!==void 0?t.autoSessionTracking:!1}_o.isAutoSessionTrackingEnabled=uYe;function UZ(e){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;var t=mR.getGlobalObject();return t.SENTRY_RELEASE&&t.SENTRY_RELEASE.id?t.SENTRY_RELEASE.id:process.env.GITHUB_SHA||process.env.COMMIT_REF||process.env.VERCEL_GIT_COMMIT_SHA||process.env.VERCEL_GITHUB_COMMIT_SHA||process.env.VERCEL_GITLAB_COMMIT_SHA||process.env.VERCEL_BITBUCKET_COMMIT_SHA||process.env.ZEIT_GITHUB_COMMIT_SHA||process.env.ZEIT_GITLAB_COMMIT_SHA||process.env.ZEIT_BITBUCKET_COMMIT_SHA||e}_o.getSentryRelease=UZ;function cYe(){var e=Eu.getCurrentHub();e.startSession(),process.on("beforeExit",function(){var t,r=(t=e.getScope())===null||t===void 0?void 0:t.getSession(),n=["exited","crashed"];r&&!n.includes(r.status)&&e.endSession()})}});var HZ=v(yR=>{Object.defineProperty(yR,"__esModule",{value:!0});var $Z=(gn(),mt(mn)),mb=require("fs"),vR=require("path");function lYe(e){var t=vR.resolve(e);if(!mb.existsSync(t))throw new Error("Cannot read contents of "+t+". Directory does not exist.");if(!mb.statSync(t).isDirectory())throw new Error("Cannot read contents of "+t+", because it is not a directory.");var r=function(n){return mb.readdirSync(n).reduce(function(i,s){var o=vR.join(n,s);return mb.statSync(o).isDirectory()?$Z.__spread(i,r(o)):$Z.__spread(i,[o])},[])};return r(t).map(function(n){return vR.relative(t,n)})}yR.deepReadDirSync=lYe});var WZ=v(_R=>{"use strict";_R.parse=dYe;_R.serialize=hYe;var fYe=decodeURIComponent,pYe=encodeURIComponent,gb=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function dYe(e,t){if(typeof e!="string")throw new TypeError("argument str must be a string");for(var r={},n=t||{},i=e.split(";"),s=n.decode||fYe,o=0;o<i.length;o++){var a=i[o],u=a.indexOf("=");if(!(u<0)){var l=a.substring(0,u).trim();if(r[l]==null){var f=a.substring(u+1,a.length).trim();f[0]==='"'&&(f=f.slice(1,-1)),r[l]=mYe(f,s)}}}return r}function hYe(e,t,r){var n=r||{},i=n.encode||pYe;if(typeof i!="function")throw new TypeError("option encode is invalid");if(!gb.test(e))throw new TypeError("argument name is invalid");var s=i(t);if(s&&!gb.test(s))throw new TypeError("argument val is invalid");var o=e+"="+s;if(n.maxAge!=null){var a=n.maxAge-0;if(isNaN(a)||!isFinite(a))throw new TypeError("option maxAge is invalid");o+="; Max-Age="+Math.floor(a)}if(n.domain){if(!gb.test(n.domain))throw new TypeError("option domain is invalid");o+="; Domain="+n.domain}if(n.path){if(!gb.test(n.path))throw new TypeError("option path is invalid");o+="; Path="+n.path}if(n.expires){if(typeof n.expires.toUTCString!="function")throw new TypeError("option expires is invalid");o+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(o+="; HttpOnly"),n.secure&&(o+="; Secure"),n.sameSite){var u=typeof n.sameSite=="string"?n.sameSite.toLowerCase():n.sameSite;switch(u){case!0:o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"strict":o+="; SameSite=Strict";break;case"none":o+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return o}function mYe(e,t){try{return t(e)}catch{return e}}});var VZ=v(Zc=>{Object.defineProperty(Zc,"__esModule",{value:!0});var xo=(gn(),mt(mn)),Xc=Yr(),Yc=Rt(),gYe=WZ(),vYe=require("domain"),yYe=require("os"),_Ye=require("url"),xYe=bu(),ym=gR();function bYe(){return function(t,r,n){var i;t.headers&&Yc.isString(t.headers["sentry-trace"])&&(i=Yc.extractTraceparentData(t.headers["sentry-trace"]));var s=Xc.startTransaction(xo.__assign({name:vb(t,{path:!0,method:!0}),op:"http.server"},i),{request:yb(t)});Xc.getCurrentHub().configureScope(function(o){o.setSpan(s)}),r.__sentry_transaction=s,r.once("finish",function(){setImmediate(function(){wYe(s,t),s.setHttpStatus(r.statusCode),s.finish()})}),n()}}Zc.tracingHandler=bYe;function wYe(e,t){e&&(e.name=vb(t,{path:!0,method:!0}),e.setData("url",t.originalUrl),e.setData("baseUrl",t.baseUrl),e.setData("query",t.query))}function vb(e,t){t===void 0&&(t={});var r,n=(r=e.method)===null||r===void 0?void 0:r.toUpperCase(),i="";e.route?i=""+(e.baseUrl||"")+e.route.path:(e.originalUrl||e.url)&&(i=Yc.stripUrlQueryAndFragment(e.originalUrl||e.url||""));var s="";return t.method&&n&&(s+=n),t.method&&t.path&&(s+=" "),t.path&&i&&(s+=i),s}function SYe(e,t){var r;switch(t){case"path":return vb(e,{path:!0});case"handler":return((r=e.route)===null||r===void 0?void 0:r.stack[0].name)||"<anonymous>";case"methodPath":default:return vb(e,{path:!0,method:!0})}}var EYe=["id","username","email"];function TYe(e,t){var r={},n=Array.isArray(t)?t:EYe;return n.forEach(function(i){e&&i in e&&(r[i]=e[i])}),r}var CYe=["cookies","data","headers","method","query_string","url"];function yb(e,t){t===void 0&&(t=CYe);var r={},n=e.headers||e.header||{},i=e.method,s=e.hostname||e.host||n.host||"<no host>",o=e.protocol==="https"||e.secure||(e.socket||{}).encrypted?"https":"http",a=e.originalUrl||e.url||"",u=o+"://"+s+a;return t.forEach(function(l){switch(l){case"headers":r.headers=n;break;case"method":r.method=i;break;case"url":r.url=u;break;case"cookies":r.cookies=e.cookies||gYe.parse(n.cookie||"");break;case"query_string":r.query_string=e.query||_Ye.parse(a||"",!1).query;break;case"data":if(i==="GET"||i==="HEAD")break;e.body!==void 0&&(r.data=Yc.isString(e.body)?e.body:JSON.stringify(Yc.normalize(e.body)));break;default:({}).hasOwnProperty.call(e,l)&&(r[l]=e[l])}}),r}Zc.extractRequestData=yb;function zZ(e,t,r){if(r=xo.__assign({ip:!1,request:!0,serverName:!0,transaction:!0,user:!0,version:!0},r),r.version&&(e.contexts=xo.__assign(xo.__assign({},e.contexts),{runtime:{name:"node",version:global.process.version}})),r.request){var n=Array.isArray(r.request)?yb(t,r.request):yb(t);e.request=xo.__assign(xo.__assign({},e.request),n)}if(r.serverName&&!e.server_name&&(e.server_name=global.process.env.SENTRY_NAME||yYe.hostname()),r.user){var i=t.user&&Yc.isPlainObject(t.user)?TYe(t.user,r.user):{};Object.keys(i)&&(e.user=xo.__assign(xo.__assign({},e.user),i))}if(r.ip){var s=t.ip||t.connection&&t.connection.remoteAddress;s&&(e.user=xo.__assign(xo.__assign({},e.user),{ip_address:s}))}return r.transaction&&!e.transaction&&(e.transaction=SYe(t,r.transaction)),e}Zc.parseRequest=zZ;function AYe(e){var t=Xc.getCurrentHub(),r=t.getClient();if(r&&ym.isAutoSessionTrackingEnabled(r)){r.initSessionFlusher();var n=t.getScope();n&&n.getSession()&&n.setSession()}return function(s,o,a){if(e&&e.flushTimeout&&e.flushTimeout>0){var u=o.end;o.end=function(f,d,h){var m=this;ym.flush(e.flushTimeout).then(function(){u.call(m,f,d,h)}).then(null,function(g){xYe.IS_DEBUG_BUILD&&Yc.logger.error(g),u.call(m,f,d,h)})}}var l=vYe.create();l.add(s),l.add(o),l.on("error",a),l.run(function(){var f=Xc.getCurrentHub();f.configureScope(function(d){d.addEventProcessor(function(g){return zZ(g,s,e)});var h=f.getClient();if(ym.isAutoSessionTrackingEnabled(h)){var m=f.getScope();m&&m.setRequestSession({status:"ok"})}}),o.once("finish",function(){var d=f.getClient();ym.isAutoSessionTrackingEnabled(d)&&setImmediate(function(){d&&d._captureRequestSession&&d._captureRequestSession()})}),a()})}}Zc.requestHandler=AYe;function IYe(e){var t=e.status||e.statusCode||e.status_code||e.output&&e.output.statusCode;return t?parseInt(t,10):500}function NYe(e){var t=IYe(e);return t>=500}function OYe(e){return function(r,n,i,s){var o=e&&e.shouldHandleError||NYe;if(o(r)){Xc.withScope(function(a){var u=i.__sentry_transaction;u&&a.getSpan()===void 0&&a.setSpan(u);var l=Xc.getCurrentHub().getClient();if(l&&ym.isAutoSessionTrackingEnabled(l)){var f=l._sessionFlusher!==void 0;if(f){var d=a.getRequestSession();d&&d.status!==void 0&&(d.status="crashed")}}var h=Xc.captureException(r);i.sentry=h,s(r)});return}s(r)}}Zc.errorHandler=OYe});var KZ=v(vt=>{Object.defineProperty(vt,"__esModule",{value:!0});var GZ=(gn(),mt(mn)),RYe=Jf();vt.Severity=RYe.Severity;var kr=Yr();vt.addGlobalEventProcessor=kr.addGlobalEventProcessor;vt.addBreadcrumb=kr.addBreadcrumb;vt.captureException=kr.captureException;vt.captureEvent=kr.captureEvent;vt.captureMessage=kr.captureMessage;vt.configureScope=kr.configureScope;vt.getHubFromCarrier=kr.getHubFromCarrier;vt.getCurrentHub=kr.getCurrentHub;vt.Hub=kr.Hub;vt.makeMain=kr.makeMain;vt.Scope=kr.Scope;vt.Session=kr.Session;vt.startTransaction=kr.startTransaction;vt.SDK_VERSION=kr.SDK_VERSION;vt.setContext=kr.setContext;vt.setExtra=kr.setExtra;vt.setExtras=kr.setExtras;vt.setTag=kr.setTag;vt.setTags=kr.setTags;vt.setUser=kr.setUser;vt.withScope=kr.withScope;var kYe=KO();vt.NodeBackend=kYe.NodeBackend;var PYe=ZO();vt.NodeClient=PYe.NodeClient;var yp=gR();vt.defaultIntegrations=yp.defaultIntegrations;vt.init=yp.init;vt.lastEventId=yp.lastEventId;vt.flush=yp.flush;vt.close=yp.close;vt.getSentryRelease=yp.getSentryRelease;var qYe=HZ();vt.deepReadDirSync=qYe.deepReadDirSync;var DYe=NO();vt.SDK_NAME=DYe.SDK_NAME;var LYe=Yr(),FYe=vo(),MYe=require("domain"),jYe=VZ();vt.Handlers=jYe;var BYe=hR(),UYe=HO();vt.Transports=UYe;var $Ye=GZ.__assign(GZ.__assign({},LYe.Integrations),BYe);vt.Integrations=$Ye;var _m=FYe.getMainCarrier();_m.__SENTRY__&&(_m.__SENTRY__.extensions=_m.__SENTRY__.extensions||{},_m.__SENTRY__.extensions.domain=_m.__SENTRY__.extensions.domain||MYe)});var XZ,xm,YZ,bm,xR,$t,wo=oe(()=>{"use strict";XZ=ve(iX()),xm=ve(KZ());ur();_p();YZ=()=>{var e;return(process.env.AMPT_STAGE==="prod"||((e=process.env.AMPT_ENDPOINT)==null?void 0:e.endsWith("ampt.dev")))&&!process.env.JEST_WORKER_ID};YZ()&&xm.init({dsn:"https://5f27cbf3265a475abff6b7999ae73179@o1265020.ingest.us.sentry.io/6448443",tracesSampleRate:0});xR=class{constructor(){yr(this,"orgName");yr(this,"user");yr(this,"config");kd(this,bm,(0,XZ.ulid)());yr(this,"auth");yr(this,"captureException",t=>{bo.error({err:t},"captureException"),YZ()&&(xm==null||xm.captureException(t,{tags:{sessionId:Os(this,bm)}}))})}getSessionId(){return Os(this,bm)}loadAmptConfig(){this.config=bR(),bo.debug({config:this.config},"loadAmptConfig")}getLoggedInUser(){var t;if(this.config||this.loadAmptConfig(),this.config&&((t=this.config)!=null&&t.userId)){let{sessions:r}=this.config,n=r==null?void 0:r[this.config.userId];if(n!=null&&n.accessToken&&(this.auth={accessToken:n.accessToken}),n&&n.username&&n.refreshToken)return{userId:this.config.userId,username:n.username,name:n.name,email:n.email,expiresAt:n.expiresAt,refreshToken:n.refreshToken,accessToken:n.accessToken}}return null}saveConfig(t){this.config={...this.config,...t},wR(this.config)}updateLogin(t){if(this.config){let r=this.getLoggedInUser();if(r&&r.userId){let n=Date.now()+t.expiresIn*1e3,{userId:i,username:s,name:o,email:a,refreshToken:u}=r;this.saveConfig({userId:i,sessions:{[i]:{userId:i,username:s,name:o,email:a,refreshToken:u,accessToken:t.accessToken,expiresAt:n}}})}}}storeToken(t,r){this.auth={accessToken:t},this.updateLogin({accessToken:t,expiresIn:r})}writeUpdateCheck(){let t=Math.round(Date.now()/1e3);this.config&&this.saveConfig({...this.config,meta:{...this.config.meta,last_update_check:t}})}shouldCheckForCliUpdate(){var t;if(this.config){let r=(t=this.config.meta)==null?void 0:t.last_update_check,n=Math.round(Date.now()/1e3);return!r||n-r>60*60*24}return!0}setUser(t){this.user=t}onLogin(t,r){if(t){let{refreshToken:n,accessToken:i,expiresIn:s}=r,o=Date.now()+s*1e3;this.saveConfig({userId:t.userId,meta:{created_at:Math.round(Date.now()/1e3)},sessions:{[t.userId]:{userId:t.userId,username:t.username,name:t.name,email:t.email,refreshToken:n,accessToken:i,expiresAt:o}}}),bo.debug({userName:t.username},"saved config file"),this.setUser(t),bo.debug({userName:t.username},"set user in session")}}shouldPromptTutorial(){var t,r,n,i,s,o,a,u,l;if((t=this.user)!=null&&t.preferences){let f=((n=(r=this.user)==null?void 0:r.preferences)==null?void 0:n.connectedCount)>=3,d=((i=this.user)==null?void 0:i.userAgeDays)&&((s=this.user)==null?void 0:s.userAgeDays)>30;return{showTutorial:((a=(o=this.user)==null?void 0:o.preferences)==null?void 0:a.showTutorial)===void 0?!0:(l=(u=this.user)==null?void 0:u.preferences)==null?void 0:l.showTutorial,allowDismiss:d?!0:f}}return{showTutorial:!1,allowDismiss:!1}}};bm=new WeakMap;$t=new xR});var _b,xb,Tu,SR,Se,bo,_p=oe(()=>{"use strict";_b=ve(rX()),xb=ve(require("path")),Tu=ve(mc());wo();SR=class{logger;enabled;logFilePath;logToConsole;pinoArgs;pinoDestination;initLogDestination(){try{(0,Tu.removeSync)(this.logFilePath)}catch(t){process.env.AMPT_DEBUG&&console.error("Error removing log file: ",t)}finally{if(this.enabled)try{(0,Tu.ensureFileSync)(this.logFilePath)}catch{this.enabled=!1}}this.pinoDestination=this.enabled&&!this.logToConsole?_b.default.destination({dest:this.logFilePath,sync:process.platform!=="win32"}):void 0}constructor(){this.enabled=!process.env.AMPT_DISABLE_LOGS,this.logFilePath=process.env.AMPT_LOG_DIR||xb.default.join(process.cwd(),".ampt","logs"),this.logToConsole=process.env.AMPT_LOG_TO_CONSOLE==="true",this.initLogDestination(),this.pinoArgs={enabled:this.enabled,level:process.env.AMPT_LOG_LEVEL||"info",mixin:()=>({sessionId:$t.getSessionId()}),redact:{remove:!0,paths:["credentials","accessKey","token","idToken","refreshToken","accessToken"]}},this.logger=(0,_b.default)(this.pinoArgs,this.pinoDestination)}disable(){this.enabled=!1}enable(){this.enabled=!0;let t=xb.default.join(process.cwd(),".ampt");this.logFilePath=process.env.AMPT_LOG_DIR||xb.default.join(t,"logs"),(0,Tu.existsSync)(t)||(0,Tu.mkdirSync)(t),this.initLogDestination(),this.pinoArgs={...this.pinoArgs,enabled:this.enabled},this.logger=(0,_b.default)(this.pinoArgs,this.pinoDestination)}child(t){return this.logger.child(t)}debug(...t){this.enabled&&this.logger.debug(...t)}warn(...t){this.enabled&&this.logger.warn(...t)}error(...t){this.enabled&&this.logger.error(...t)}info(...t){this.enabled&&this.logger.info(...t)}fatal(...t){this.enabled&&this.logger.fatal(...t)}trace(...t){this.enabled&&this.logger.trace(...t)}},Se=new SR,bo=Se});var wm=v((V2t,HYe)=>{HYe.exports={name:"@ampt/cli",version:"1.1.8",description:"Ampt command line interface",main:"./dist/index.js",types:"./types/index.d.ts",engines:{node:">=16.0.0 <21.0.0"},publishConfig:{access:"public"},bin:{ampt:"./bin/bin"},scripts:{prepublishOnly:"npm run build",build:"node esbuild.mjs",watch:"node esbuild.mjs --watch",test:'LOG_LEVEL=silent AWS_REGION=us-east-1 NODE_OPTIONS="--no-warnings --experimental-vm-modules" jest',eslint:"eslint .",prettier:"prettier --check ."},author:"Ampt Inc <hello@getampt.com>",license:"Apache-2.0",optionalDependencies:{fsevents:"~2.3.2"},babel:{presets:["@babel/preset-typescript"]},devDependencies:{"@astrojs/webapi":"^1.1.1","@sentry/node":"^6.16.1","@types/express":"^4.17.13","@types/http-proxy":"^1.17.8","@types/write-file-atomic":"^4.0.0","@types/ws":"^8.5.3","adm-zip":"^0.5.5","ansi-escapes":"^4.3.1",axios:"^1.6.5","axios-retry":"^4.0.0",chalk:"^4.1.0","child-process-ext":"^2.1.1",chokidar:"^3.5.0",chunk:"^0.0.3",dayjs:"^1.10.4",debounce:"^1.2.1",del:"^6.0.0",figures:"^3.2.0","fs-extra":"^9.0.1","get-port":"^5.0.0","git-list-updated":"^1.2.1","github-release-from-cc-changelog":"^2.2.0","http-proxy":"^1.18.1",ignore:"^5.2.0","is-git-url":"^1.0.0","is-installed-globally":"^0.4.0","it-parallel":"^2.0.1","jwt-decode":"^3.1.2",keypress:"^0.2.1","lz4-wasm-nodejs":"^0.9.2",minimist:"^1.2.5","node-emoji":"^1.10.0","node-resolve":"^1.3.4","normalize-path":"^3.0.0",open:"^8.2.0","parse-packagejson-name":"^1.0.1",pluralize:"^8.0.0",ramda:"^0.27.2",semver:"^5.7.1","strip-ansi":"^6.0.0",terminate:"^2.5.0","tree-kill":"^1.2.2",ulid:"^2.3.0",which:"^2.0.2","write-file-atomic":"^4.0.2"},dependencies:{esbuild:"^0.19.5",joycon:"^3.1.1",pirates:"^4.0.6","source-map-support":"^0.5.21","tsconfig-paths":"^4.2.0"}}});var JZ,ZZ,WYe,ER,TR,ze,J2t,CR=oe(()=>{"use strict";JZ=ve(require("https"));hx();Y9();_p();wo();({version:ZZ}=wm()),WYe=new JZ.default.Agent({keepAlive:!0}),ER=class e{axios;static config(){return{apiEndpoint:process.env.AMPT_ENDPOINT,apiKey:process.env.AMPT_API_KEY}}constructor(){this.axios=po.create({httpsAgent:WYe}),mx(this.axios,{retries:10,retryDelay:mx.exponentialDelay,retryCondition:t=>{var s;let r=t.response&&t.response.status||"unknown",n=t.response&&t.response.data&&t.response.data.message||"unknown",i=mx.isNetworkOrIdempotentRequestError(t)&&r!==500||r===429||r===503;return i&&bo.debug({status:r,message:n,response:(s=t.response)==null?void 0:s.data},"retryable request error"),i}}),this.axios.defaults.headers.common={},this.axios.defaults.headers.put={},this.axios.defaults.headers.get={}}async request(t={}){var _,S,b,C,T,w,E,N,U,M,F,k,q,O;let{apiEndpoint:r,apiKey:n}=e.config(),i=t.root||r,s=(_=$t.auth)==null?void 0:_.accessToken,{method:o="POST",params:a,headers:u={},body:l,endpoint:f}=t,{url:d=`${i}${f}`,responseType:h}=t;n&&d.startsWith(r)?u.Authorization=`Basic ${n}`:s&&d.startsWith(r)&&(u.Authorization=`Bearer ${s}`),l&&f&&(u["Content-Type"]="application/json");let m=$t.getSessionId();f&&(u["User-Agent"]=`ampt-cli/${ZZ}`,u["ampt-version"]=ZZ,u["ampt-session-id"]=m);let g={url:d,method:o,headers:u,params:a,data:l,maxContentLength:1/0,maxBodyLength:1/0,onUploadProgress:t.onUploadProgress};h&&(g.responseType=h);try{return bo.debug({method:o,url:d,sessionId:m},"request"),(await this.axios(g)).data}catch(H){if(((S=H.response)==null?void 0:S.status)===403&&((C=(b=H.response)==null?void 0:b.data)==null?void 0:C.code)==="EXPIRED_TOKEN")return bo.debug({status:H.response.status,code:H.response.data.code},"Token expired, refreshing"),await((T=$t.user)==null?void 0:T.refreshAccessToken()),this.request(t);if(((w=H.response)==null?void 0:w.status)===403){let G=new Error("Forbidden");throw G.message="You do not have permission to access this resource.",G.name="ForbiddenError",G}if(((E=H.response)==null?void 0:E.status)===404)return;if(((N=H.response)==null?void 0:N.status)===409){let G=new Error("Conflict");throw G.message="Conflict",G.name="ConflictError",G}if(bo.error({status:(U=H.response)==null?void 0:U.status,data:(M=H.response)==null?void 0:M.data},"request error"),H.response&&H.response.data){let G=new Error(H.response.data.message||H.response.data);throw(F=H.response.data.message)!=null&&F.includes("Request Entity Too Large")?(G.message="Your code size is too large. Try reducing it by adding to .deployignore",G.name="EntityTooLargeError"):(k=H.response.data.message)!=null&&k.includes("User disabled")?(G.message=H.response.data.detail||"Your account has been disabled. Please contact support@getampt.com for more information.",G.name="UserDisabledError"):(q=H.response.data.message)!=null&&q.includes("App limit reached")?(G.message="You have reached your Organization's app limit. Please upgrade your plan or delete an app.",G.name="AppLimitReachedError"):(O=H.response.data.message)!=null&&O.includes("Instance limit reached")?(G.message="You have reached your Organization's environment limit. Please upgrade your plan or delete an environment.",G.name="EnvironmentLimitReachedError"):G.name=H.response.data.name||null,G.statusCode=H.response.data.statusCode||H.response.status||null,G}throw H}}},TR=new ER,ze=TR.request.bind(TR),J2t=TR.request});var QZ,eJ=oe(()=>{"use strict";QZ=async(e,t)=>{let r,n=new Promise(i=>{r=setTimeout(()=>i(null),t)});return Promise.race([e,n]).then(i=>(clearTimeout(r),i))}});var bb,tJ=oe(()=>{"use strict";bb=e=>e?e===0?"less than a second":e===1?"1 second":`${e} seconds`:"a few seconds"});var Cu,AR=oe(()=>{"use strict";Cu=async e=>new Promise(t=>setTimeout(t,e).unref())});var cr,IR,NR=oe(()=>{"use strict";ur();wo();cr=e=>{(async()=>{let{eventName:t,eventData:r={}}=e,n=$t.orgName;if(!n){Se.warn({eventName:t},"Could not send report - no org name found");return}try{await ze({method:"POST",body:{eventName:t,eventData:{...r,shell:!0}},endpoint:`/orgs/${n}/analytics`})}catch(i){$t.captureException(i),process.env.AMPT_DEBUG&&console.error(i)}})()},IR=cr});async function wb(e){try{let t="https://ampt.dev/public/templates/manifest-tags.json",{data:r}=await po.get(t);return r.filter(n=>n.tags.includes("starter"))}catch(t){return process.env.AMPT_DEBUG&&e.logError(t),[]}}var OR=oe(()=>{"use strict";hx()});var RR,rJ,kR=oe(()=>{"use strict";RR=e=>{try{return process.kill(e,0)}catch(t){return t.code==="EPERM"}},rJ=RR});async function Sb(e,t){let r=e.eventNames(),n=new Map;for(let i of r)n.set(i,e.listeners(i));try{return await t()}finally{e.removeAllListeners();for(let i of r)for(let s of n.get(i))e.on(i,s)}}var nJ=oe(()=>{"use strict"});function iJ(e){e=e.trim();let t=0,r=null,n=null,i=null,s=[];for(let o=0;o<e.length;o++){if(r=n,n=e.charAt(o),n===" "&&!i){r!==" "&&t++;continue}if(n===i){i=null;continue}else if((n==="'"||n==='"')&&!i){i=n;continue}s[t]||(s[t]=""),s[t]+=n}return s}var sJ=oe(()=>{"use strict"});var oJ=oe(()=>{"use strict"});var aJ=v((xp,Sm)=>{(function(){var e,t="4.17.21",r=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",i="Expected a function",s="Invalid `variable` option passed into `_.template`",o="__lodash_hash_undefined__",a=500,u="__lodash_placeholder__",l=1,f=2,d=4,h=1,m=2,g=1,_=2,S=4,b=8,C=16,T=32,w=64,E=128,N=256,U=512,M=30,F="...",k=800,q=16,O=1,H=2,G=3,j=1/0,B=9007199254740991,ee=17976931348623157e292,Y=0/0,se=4294967295,pe=se-1,xe=se>>>1,_e=[["ary",E],["bind",g],["bindKey",_],["curry",b],["curryRight",C],["flip",U],["partial",T],["partialRight",w],["rearg",N]],Le="[object Arguments]",Ue="[object Array]",it="[object AsyncFunction]",Ie="[object Boolean]",Lt="[object Date]",st="[object DOMException]",ge="[object Error]",D="[object Function]",A="[object GeneratorFunction]",te="[object Map]",X="[object Number]",Xe="[object Null]",He="[object Object]",zt="[object Promise]",gr="[object Proxy]",jr="[object RegExp]",Re="[object Set]",Xt="[object String]",fn="[object Symbol]",Al="[object Undefined]",Js="[object WeakMap]",$u="[object WeakSet]",Qs="[object ArrayBuffer]",P="[object DataView]",z="[object Float32Array]",K="[object Float64Array]",ie="[object Int8Array]",ce="[object Int16Array]",Ee="[object Int32Array]",Je="[object Uint8Array]",dt="[object Uint8ClampedArray]",Wr="[object Uint16Array]",bi="[object Uint32Array]",Nr=/\b__p \+= '';/g,Ve=/\b(__p \+=) '' \+/g,Ts=/(__e\(.*?\)|\b__t\)) \+\n'';/g,sv=/&(?:amp|lt|gt|quot|#39);/g,Il=/[&<>"']/g,ov=RegExp(sv.source),av=RegExp(Il.source),pd=/<%-([\s\S]+?)%>/g,wi=/<%([\s\S]+?)%>/g,dd=/<%=([\s\S]+?)%>/g,hd=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,uv=/^\w*$/,md=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Hu=/[\\^$.*+?()[\]{}|]/g,Nl=RegExp(Hu.source),Wu=/^\s+/,cv=/\s/,lv=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Jwe=/\{\n\/\* \[wrapped with (.+)\] \*/,Qwe=/,? & /,e0e=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,t0e=/[()=,{}\[\]\/\s]/,r0e=/\\(\\)?/g,n0e=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,XL=/\w*$/,i0e=/^[-+]0x[0-9a-f]+$/i,s0e=/^0b[01]+$/i,o0e=/^\[object .+?Constructor\]$/,a0e=/^0o[0-7]+$/i,u0e=/^(?:0|[1-9]\d*)$/,c0e=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,fv=/($^)/,l0e=/['\n\r\u2028\u2029\\]/g,pv="\\ud800-\\udfff",f0e="\\u0300-\\u036f",p0e="\\ufe20-\\ufe2f",d0e="\\u20d0-\\u20ff",YL=f0e+p0e+d0e,ZL="\\u2700-\\u27bf",JL="a-z\\xdf-\\xf6\\xf8-\\xff",h0e="\\xac\\xb1\\xd7\\xf7",m0e="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",g0e="\\u2000-\\u206f",v0e=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",QL="A-Z\\xc0-\\xd6\\xd8-\\xde",e2="\\ufe0e\\ufe0f",t2=h0e+m0e+g0e+v0e,gS="['\u2019]",y0e="["+pv+"]",r2="["+t2+"]",dv="["+YL+"]",n2="\\d+",_0e="["+ZL+"]",i2="["+JL+"]",s2="[^"+pv+t2+n2+ZL+JL+QL+"]",vS="\\ud83c[\\udffb-\\udfff]",x0e="(?:"+dv+"|"+vS+")",o2="[^"+pv+"]",yS="(?:\\ud83c[\\udde6-\\uddff]){2}",_S="[\\ud800-\\udbff][\\udc00-\\udfff]",Ol="["+QL+"]",a2="\\u200d",u2="(?:"+i2+"|"+s2+")",b0e="(?:"+Ol+"|"+s2+")",c2="(?:"+gS+"(?:d|ll|m|re|s|t|ve))?",l2="(?:"+gS+"(?:D|LL|M|RE|S|T|VE))?",f2=x0e+"?",p2="["+e2+"]?",w0e="(?:"+a2+"(?:"+[o2,yS,_S].join("|")+")"+p2+f2+")*",S0e="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",E0e="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",d2=p2+f2+w0e,T0e="(?:"+[_0e,yS,_S].join("|")+")"+d2,C0e="(?:"+[o2+dv+"?",dv,yS,_S,y0e].join("|")+")",A0e=RegExp(gS,"g"),I0e=RegExp(dv,"g"),xS=RegExp(vS+"(?="+vS+")|"+C0e+d2,"g"),N0e=RegExp([Ol+"?"+i2+"+"+c2+"(?="+[r2,Ol,"$"].join("|")+")",b0e+"+"+l2+"(?="+[r2,Ol+u2,"$"].join("|")+")",Ol+"?"+u2+"+"+c2,Ol+"+"+l2,E0e,S0e,n2,T0e].join("|"),"g"),O0e=RegExp("["+a2+pv+YL+e2+"]"),R0e=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,k0e=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],P0e=-1,rr={};rr[z]=rr[K]=rr[ie]=rr[ce]=rr[Ee]=rr[Je]=rr[dt]=rr[Wr]=rr[bi]=!0,rr[Le]=rr[Ue]=rr[Qs]=rr[Ie]=rr[P]=rr[Lt]=rr[ge]=rr[D]=rr[te]=rr[X]=rr[He]=rr[jr]=rr[Re]=rr[Xt]=rr[Js]=!1;var er={};er[Le]=er[Ue]=er[Qs]=er[P]=er[Ie]=er[Lt]=er[z]=er[K]=er[ie]=er[ce]=er[Ee]=er[te]=er[X]=er[He]=er[jr]=er[Re]=er[Xt]=er[fn]=er[Je]=er[dt]=er[Wr]=er[bi]=!0,er[ge]=er[D]=er[Js]=!1;var q0e={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},D0e={"&":"&","<":"<",">":">",'"':""","'":"'"},L0e={"&":"&","<":"<",">":">",""":'"',"'":"'"},F0e={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},M0e=parseFloat,j0e=parseInt,h2=typeof global=="object"&&global&&global.Object===Object&&global,B0e=typeof self=="object"&&self&&self.Object===Object&&self,tn=h2||B0e||Function("return this")(),bS=typeof xp=="object"&&xp&&!xp.nodeType&&xp,zu=bS&&typeof Sm=="object"&&Sm&&!Sm.nodeType&&Sm,m2=zu&&zu.exports===bS,wS=m2&&h2.process,Vi=function(){try{var Z=zu&&zu.require&&zu.require("util").types;return Z||wS&&wS.binding&&wS.binding("util")}catch{}}(),g2=Vi&&Vi.isArrayBuffer,v2=Vi&&Vi.isDate,y2=Vi&&Vi.isMap,_2=Vi&&Vi.isRegExp,x2=Vi&&Vi.isSet,b2=Vi&&Vi.isTypedArray;function Si(Z,ae,ne){switch(ne.length){case 0:return Z.call(ae);case 1:return Z.call(ae,ne[0]);case 2:return Z.call(ae,ne[0],ne[1]);case 3:return Z.call(ae,ne[0],ne[1],ne[2])}return Z.apply(ae,ne)}function U0e(Z,ae,ne,Ce){for(var Qe=-1,Ot=Z==null?0:Z.length;++Qe<Ot;){var zr=Z[Qe];ae(Ce,zr,ne(zr),Z)}return Ce}function Gi(Z,ae){for(var ne=-1,Ce=Z==null?0:Z.length;++ne<Ce&&ae(Z[ne],ne,Z)!==!1;);return Z}function $0e(Z,ae){for(var ne=Z==null?0:Z.length;ne--&&ae(Z[ne],ne,Z)!==!1;);return Z}function w2(Z,ae){for(var ne=-1,Ce=Z==null?0:Z.length;++ne<Ce;)if(!ae(Z[ne],ne,Z))return!1;return!0}function qa(Z,ae){for(var ne=-1,Ce=Z==null?0:Z.length,Qe=0,Ot=[];++ne<Ce;){var zr=Z[ne];ae(zr,ne,Z)&&(Ot[Qe++]=zr)}return Ot}function hv(Z,ae){var ne=Z==null?0:Z.length;return!!ne&&Rl(Z,ae,0)>-1}function SS(Z,ae,ne){for(var Ce=-1,Qe=Z==null?0:Z.length;++Ce<Qe;)if(ne(ae,Z[Ce]))return!0;return!1}function sr(Z,ae){for(var ne=-1,Ce=Z==null?0:Z.length,Qe=Array(Ce);++ne<Ce;)Qe[ne]=ae(Z[ne],ne,Z);return Qe}function Da(Z,ae){for(var ne=-1,Ce=ae.length,Qe=Z.length;++ne<Ce;)Z[Qe+ne]=ae[ne];return Z}function ES(Z,ae,ne,Ce){var Qe=-1,Ot=Z==null?0:Z.length;for(Ce&&Ot&&(ne=Z[++Qe]);++Qe<Ot;)ne=ae(ne,Z[Qe],Qe,Z);return ne}function H0e(Z,ae,ne,Ce){var Qe=Z==null?0:Z.length;for(Ce&&Qe&&(ne=Z[--Qe]);Qe--;)ne=ae(ne,Z[Qe],Qe,Z);return ne}function TS(Z,ae){for(var ne=-1,Ce=Z==null?0:Z.length;++ne<Ce;)if(ae(Z[ne],ne,Z))return!0;return!1}var W0e=CS("length");function z0e(Z){return Z.split("")}function V0e(Z){return Z.match(e0e)||[]}function S2(Z,ae,ne){var Ce;return ne(Z,function(Qe,Ot,zr){if(ae(Qe,Ot,zr))return Ce=Ot,!1}),Ce}function mv(Z,ae,ne,Ce){for(var Qe=Z.length,Ot=ne+(Ce?1:-1);Ce?Ot--:++Ot<Qe;)if(ae(Z[Ot],Ot,Z))return Ot;return-1}function Rl(Z,ae,ne){return ae===ae?iSe(Z,ae,ne):mv(Z,E2,ne)}function G0e(Z,ae,ne,Ce){for(var Qe=ne-1,Ot=Z.length;++Qe<Ot;)if(Ce(Z[Qe],ae))return Qe;return-1}function E2(Z){return Z!==Z}function T2(Z,ae){var ne=Z==null?0:Z.length;return ne?IS(Z,ae)/ne:Y}function CS(Z){return function(ae){return ae==null?e:ae[Z]}}function AS(Z){return function(ae){return Z==null?e:Z[ae]}}function C2(Z,ae,ne,Ce,Qe){return Qe(Z,function(Ot,zr,Yt){ne=Ce?(Ce=!1,Ot):ae(ne,Ot,zr,Yt)}),ne}function K0e(Z,ae){var ne=Z.length;for(Z.sort(ae);ne--;)Z[ne]=Z[ne].value;return Z}function IS(Z,ae){for(var ne,Ce=-1,Qe=Z.length;++Ce<Qe;){var Ot=ae(Z[Ce]);Ot!==e&&(ne=ne===e?Ot:ne+Ot)}return ne}function NS(Z,ae){for(var ne=-1,Ce=Array(Z);++ne<Z;)Ce[ne]=ae(ne);return Ce}function X0e(Z,ae){return sr(ae,function(ne){return[ne,Z[ne]]})}function A2(Z){return Z&&Z.slice(0,R2(Z)+1).replace(Wu,"")}function Ei(Z){return function(ae){return Z(ae)}}function OS(Z,ae){return sr(ae,function(ne){return Z[ne]})}function gd(Z,ae){return Z.has(ae)}function I2(Z,ae){for(var ne=-1,Ce=Z.length;++ne<Ce&&Rl(ae,Z[ne],0)>-1;);return ne}function N2(Z,ae){for(var ne=Z.length;ne--&&Rl(ae,Z[ne],0)>-1;);return ne}function Y0e(Z,ae){for(var ne=Z.length,Ce=0;ne--;)Z[ne]===ae&&++Ce;return Ce}var Z0e=AS(q0e),J0e=AS(D0e);function Q0e(Z){return"\\"+F0e[Z]}function eSe(Z,ae){return Z==null?e:Z[ae]}function kl(Z){return O0e.test(Z)}function tSe(Z){return R0e.test(Z)}function rSe(Z){for(var ae,ne=[];!(ae=Z.next()).done;)ne.push(ae.value);return ne}function RS(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Ce,Qe){ne[++ae]=[Qe,Ce]}),ne}function O2(Z,ae){return function(ne){return Z(ae(ne))}}function La(Z,ae){for(var ne=-1,Ce=Z.length,Qe=0,Ot=[];++ne<Ce;){var zr=Z[ne];(zr===ae||zr===u)&&(Z[ne]=u,Ot[Qe++]=ne)}return Ot}function gv(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Ce){ne[++ae]=Ce}),ne}function nSe(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Ce){ne[++ae]=[Ce,Ce]}),ne}function iSe(Z,ae,ne){for(var Ce=ne-1,Qe=Z.length;++Ce<Qe;)if(Z[Ce]===ae)return Ce;return-1}function sSe(Z,ae,ne){for(var Ce=ne+1;Ce--;)if(Z[Ce]===ae)return Ce;return Ce}function Pl(Z){return kl(Z)?aSe(Z):W0e(Z)}function Cs(Z){return kl(Z)?uSe(Z):z0e(Z)}function R2(Z){for(var ae=Z.length;ae--&&cv.test(Z.charAt(ae)););return ae}var oSe=AS(L0e);function aSe(Z){for(var ae=xS.lastIndex=0;xS.test(Z);)++ae;return ae}function uSe(Z){return Z.match(xS)||[]}function cSe(Z){return Z.match(N0e)||[]}var lSe=function Z(ae){ae=ae==null?tn:Fa.defaults(tn.Object(),ae,Fa.pick(tn,k0e));var ne=ae.Array,Ce=ae.Date,Qe=ae.Error,Ot=ae.Function,zr=ae.Math,Yt=ae.Object,kS=ae.RegExp,fSe=ae.String,Ki=ae.TypeError,vv=ne.prototype,pSe=Ot.prototype,ql=Yt.prototype,yv=ae["__core-js_shared__"],_v=pSe.toString,Ft=ql.hasOwnProperty,dSe=0,k2=function(){var c=/[^.]+$/.exec(yv&&yv.keys&&yv.keys.IE_PROTO||"");return c?"Symbol(src)_1."+c:""}(),xv=ql.toString,hSe=_v.call(Yt),mSe=tn._,gSe=kS("^"+_v.call(Ft).replace(Hu,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),bv=m2?ae.Buffer:e,Ma=ae.Symbol,wv=ae.Uint8Array,P2=bv?bv.allocUnsafe:e,Sv=O2(Yt.getPrototypeOf,Yt),q2=Yt.create,D2=ql.propertyIsEnumerable,Ev=vv.splice,L2=Ma?Ma.isConcatSpreadable:e,vd=Ma?Ma.iterator:e,Vu=Ma?Ma.toStringTag:e,Tv=function(){try{var c=Zu(Yt,"defineProperty");return c({},"",{}),c}catch{}}(),vSe=ae.clearTimeout!==tn.clearTimeout&&ae.clearTimeout,ySe=Ce&&Ce.now!==tn.Date.now&&Ce.now,_Se=ae.setTimeout!==tn.setTimeout&&ae.setTimeout,Cv=zr.ceil,Av=zr.floor,PS=Yt.getOwnPropertySymbols,xSe=bv?bv.isBuffer:e,F2=ae.isFinite,bSe=vv.join,wSe=O2(Yt.keys,Yt),Vr=zr.max,In=zr.min,SSe=Ce.now,ESe=ae.parseInt,M2=zr.random,TSe=vv.reverse,qS=Zu(ae,"DataView"),yd=Zu(ae,"Map"),DS=Zu(ae,"Promise"),Dl=Zu(ae,"Set"),_d=Zu(ae,"WeakMap"),xd=Zu(Yt,"create"),Iv=_d&&new _d,Ll={},CSe=Ju(qS),ASe=Ju(yd),ISe=Ju(DS),NSe=Ju(Dl),OSe=Ju(_d),Nv=Ma?Ma.prototype:e,bd=Nv?Nv.valueOf:e,j2=Nv?Nv.toString:e;function R(c){if(Sr(c)&&!ot(c)&&!(c instanceof yt)){if(c instanceof Xi)return c;if(Ft.call(c,"__wrapped__"))return BF(c)}return new Xi(c)}var Fl=function(){function c(){}return function(p){if(!vr(p))return{};if(q2)return q2(p);c.prototype=p;var y=new c;return c.prototype=e,y}}();function Ov(){}function Xi(c,p){this.__wrapped__=c,this.__actions__=[],this.__chain__=!!p,this.__index__=0,this.__values__=e}R.templateSettings={escape:pd,evaluate:wi,interpolate:dd,variable:"",imports:{_:R}},R.prototype=Ov.prototype,R.prototype.constructor=R,Xi.prototype=Fl(Ov.prototype),Xi.prototype.constructor=Xi;function yt(c){this.__wrapped__=c,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=se,this.__views__=[]}function RSe(){var c=new yt(this.__wrapped__);return c.__actions__=ti(this.__actions__),c.__dir__=this.__dir__,c.__filtered__=this.__filtered__,c.__iteratees__=ti(this.__iteratees__),c.__takeCount__=this.__takeCount__,c.__views__=ti(this.__views__),c}function kSe(){if(this.__filtered__){var c=new yt(this);c.__dir__=-1,c.__filtered__=!0}else c=this.clone(),c.__dir__*=-1;return c}function PSe(){var c=this.__wrapped__.value(),p=this.__dir__,y=ot(c),x=p<0,I=y?c.length:0,L=zEe(0,I,this.__views__),W=L.start,V=L.end,J=V-W,ue=x?V:W-1,le=this.__iteratees__,de=le.length,we=0,De=In(J,this.__takeCount__);if(!y||!x&&I==J&&De==J)return cF(c,this.__actions__);var Ge=[];e:for(;J--&&we<De;){ue+=p;for(var lt=-1,Ke=c[ue];++lt<de;){var ht=le[lt],St=ht.iteratee,Ai=ht.type,Hn=St(Ke);if(Ai==H)Ke=Hn;else if(!Hn){if(Ai==O)continue e;break e}}Ge[we++]=Ke}return Ge}yt.prototype=Fl(Ov.prototype),yt.prototype.constructor=yt;function Gu(c){var p=-1,y=c==null?0:c.length;for(this.clear();++p<y;){var x=c[p];this.set(x[0],x[1])}}function qSe(){this.__data__=xd?xd(null):{},this.size=0}function DSe(c){var p=this.has(c)&&delete this.__data__[c];return this.size-=p?1:0,p}function LSe(c){var p=this.__data__;if(xd){var y=p[c];return y===o?e:y}return Ft.call(p,c)?p[c]:e}function FSe(c){var p=this.__data__;return xd?p[c]!==e:Ft.call(p,c)}function MSe(c,p){var y=this.__data__;return this.size+=this.has(c)?0:1,y[c]=xd&&p===e?o:p,this}Gu.prototype.clear=qSe,Gu.prototype.delete=DSe,Gu.prototype.get=LSe,Gu.prototype.has=FSe,Gu.prototype.set=MSe;function Mo(c){var p=-1,y=c==null?0:c.length;for(this.clear();++p<y;){var x=c[p];this.set(x[0],x[1])}}function jSe(){this.__data__=[],this.size=0}function BSe(c){var p=this.__data__,y=Rv(p,c);if(y<0)return!1;var x=p.length-1;return y==x?p.pop():Ev.call(p,y,1),--this.size,!0}function USe(c){var p=this.__data__,y=Rv(p,c);return y<0?e:p[y][1]}function $Se(c){return Rv(this.__data__,c)>-1}function HSe(c,p){var y=this.__data__,x=Rv(y,c);return x<0?(++this.size,y.push([c,p])):y[x][1]=p,this}Mo.prototype.clear=jSe,Mo.prototype.delete=BSe,Mo.prototype.get=USe,Mo.prototype.has=$Se,Mo.prototype.set=HSe;function jo(c){var p=-1,y=c==null?0:c.length;for(this.clear();++p<y;){var x=c[p];this.set(x[0],x[1])}}function WSe(){this.size=0,this.__data__={hash:new Gu,map:new(yd||Mo),string:new Gu}}function zSe(c){var p=Hv(this,c).delete(c);return this.size-=p?1:0,p}function VSe(c){return Hv(this,c).get(c)}function GSe(c){return Hv(this,c).has(c)}function KSe(c,p){var y=Hv(this,c),x=y.size;return y.set(c,p),this.size+=y.size==x?0:1,this}jo.prototype.clear=WSe,jo.prototype.delete=zSe,jo.prototype.get=VSe,jo.prototype.has=GSe,jo.prototype.set=KSe;function Ku(c){var p=-1,y=c==null?0:c.length;for(this.__data__=new jo;++p<y;)this.add(c[p])}function XSe(c){return this.__data__.set(c,o),this}function YSe(c){return this.__data__.has(c)}Ku.prototype.add=Ku.prototype.push=XSe,Ku.prototype.has=YSe;function As(c){var p=this.__data__=new Mo(c);this.size=p.size}function ZSe(){this.__data__=new Mo,this.size=0}function JSe(c){var p=this.__data__,y=p.delete(c);return this.size=p.size,y}function QSe(c){return this.__data__.get(c)}function eEe(c){return this.__data__.has(c)}function tEe(c,p){var y=this.__data__;if(y instanceof Mo){var x=y.__data__;if(!yd||x.length<r-1)return x.push([c,p]),this.size=++y.size,this;y=this.__data__=new jo(x)}return y.set(c,p),this.size=y.size,this}As.prototype.clear=ZSe,As.prototype.delete=JSe,As.prototype.get=QSe,As.prototype.has=eEe,As.prototype.set=tEe;function B2(c,p){var y=ot(c),x=!y&&Qu(c),I=!y&&!x&&Ha(c),L=!y&&!x&&!I&&Ul(c),W=y||x||I||L,V=W?NS(c.length,fSe):[],J=V.length;for(var ue in c)(p||Ft.call(c,ue))&&!(W&&(ue=="length"||I&&(ue=="offset"||ue=="parent")||L&&(ue=="buffer"||ue=="byteLength"||ue=="byteOffset")||Ho(ue,J)))&&V.push(ue);return V}function U2(c){var p=c.length;return p?c[VS(0,p-1)]:e}function rEe(c,p){return Wv(ti(c),Xu(p,0,c.length))}function nEe(c){return Wv(ti(c))}function LS(c,p,y){(y!==e&&!Is(c[p],y)||y===e&&!(p in c))&&Bo(c,p,y)}function wd(c,p,y){var x=c[p];(!(Ft.call(c,p)&&Is(x,y))||y===e&&!(p in c))&&Bo(c,p,y)}function Rv(c,p){for(var y=c.length;y--;)if(Is(c[y][0],p))return y;return-1}function iEe(c,p,y,x){return ja(c,function(I,L,W){p(x,I,y(I),W)}),x}function $2(c,p){return c&&to(p,rn(p),c)}function sEe(c,p){return c&&to(p,ni(p),c)}function Bo(c,p,y){p=="__proto__"&&Tv?Tv(c,p,{configurable:!0,enumerable:!0,value:y,writable:!0}):c[p]=y}function FS(c,p){for(var y=-1,x=p.length,I=ne(x),L=c==null;++y<x;)I[y]=L?e:vE(c,p[y]);return I}function Xu(c,p,y){return c===c&&(y!==e&&(c=c<=y?c:y),p!==e&&(c=c>=p?c:p)),c}function Yi(c,p,y,x,I,L){var W,V=p&l,J=p&f,ue=p&d;if(y&&(W=I?y(c,x,I,L):y(c)),W!==e)return W;if(!vr(c))return c;var le=ot(c);if(le){if(W=GEe(c),!V)return ti(c,W)}else{var de=Nn(c),we=de==D||de==A;if(Ha(c))return pF(c,V);if(de==He||de==Le||we&&!I){if(W=J||we?{}:RF(c),!V)return J?LEe(c,sEe(W,c)):DEe(c,$2(W,c))}else{if(!er[de])return I?c:{};W=KEe(c,de,V)}}L||(L=new As);var De=L.get(c);if(De)return De;L.set(c,W),oM(c)?c.forEach(function(Ke){W.add(Yi(Ke,p,y,Ke,c,L))}):iM(c)&&c.forEach(function(Ke,ht){W.set(ht,Yi(Ke,p,y,ht,c,L))});var Ge=ue?J?nE:rE:J?ni:rn,lt=le?e:Ge(c);return Gi(lt||c,function(Ke,ht){lt&&(ht=Ke,Ke=c[ht]),wd(W,ht,Yi(Ke,p,y,ht,c,L))}),W}function oEe(c){var p=rn(c);return function(y){return H2(y,c,p)}}function H2(c,p,y){var x=y.length;if(c==null)return!x;for(c=Yt(c);x--;){var I=y[x],L=p[I],W=c[I];if(W===e&&!(I in c)||!L(W))return!1}return!0}function W2(c,p,y){if(typeof c!="function")throw new Ki(i);return Nd(function(){c.apply(e,y)},p)}function Sd(c,p,y,x){var I=-1,L=hv,W=!0,V=c.length,J=[],ue=p.length;if(!V)return J;y&&(p=sr(p,Ei(y))),x?(L=SS,W=!1):p.length>=r&&(L=gd,W=!1,p=new Ku(p));e:for(;++I<V;){var le=c[I],de=y==null?le:y(le);if(le=x||le!==0?le:0,W&&de===de){for(var we=ue;we--;)if(p[we]===de)continue e;J.push(le)}else L(p,de,x)||J.push(le)}return J}var ja=vF(eo),z2=vF(jS,!0);function aEe(c,p){var y=!0;return ja(c,function(x,I,L){return y=!!p(x,I,L),y}),y}function kv(c,p,y){for(var x=-1,I=c.length;++x<I;){var L=c[x],W=p(L);if(W!=null&&(V===e?W===W&&!Ci(W):y(W,V)))var V=W,J=L}return J}function uEe(c,p,y,x){var I=c.length;for(y=ct(y),y<0&&(y=-y>I?0:I+y),x=x===e||x>I?I:ct(x),x<0&&(x+=I),x=y>x?0:uM(x);y<x;)c[y++]=p;return c}function V2(c,p){var y=[];return ja(c,function(x,I,L){p(x,I,L)&&y.push(x)}),y}function pn(c,p,y,x,I){var L=-1,W=c.length;for(y||(y=YEe),I||(I=[]);++L<W;){var V=c[L];p>0&&y(V)?p>1?pn(V,p-1,y,x,I):Da(I,V):x||(I[I.length]=V)}return I}var MS=yF(),G2=yF(!0);function eo(c,p){return c&&MS(c,p,rn)}function jS(c,p){return c&&G2(c,p,rn)}function Pv(c,p){return qa(p,function(y){return Wo(c[y])})}function Yu(c,p){p=Ua(p,c);for(var y=0,x=p.length;c!=null&&y<x;)c=c[ro(p[y++])];return y&&y==x?c:e}function K2(c,p,y){var x=p(c);return ot(c)?x:Da(x,y(c))}function Un(c){return c==null?c===e?Al:Xe:Vu&&Vu in Yt(c)?WEe(c):nTe(c)}function BS(c,p){return c>p}function cEe(c,p){return c!=null&&Ft.call(c,p)}function lEe(c,p){return c!=null&&p in Yt(c)}function fEe(c,p,y){return c>=In(p,y)&&c<Vr(p,y)}function US(c,p,y){for(var x=y?SS:hv,I=c[0].length,L=c.length,W=L,V=ne(L),J=1/0,ue=[];W--;){var le=c[W];W&&p&&(le=sr(le,Ei(p))),J=In(le.length,J),V[W]=!y&&(p||I>=120&&le.length>=120)?new Ku(W&&le):e}le=c[0];var de=-1,we=V[0];e:for(;++de<I&&ue.length<J;){var De=le[de],Ge=p?p(De):De;if(De=y||De!==0?De:0,!(we?gd(we,Ge):x(ue,Ge,y))){for(W=L;--W;){var lt=V[W];if(!(lt?gd(lt,Ge):x(c[W],Ge,y)))continue e}we&&we.push(Ge),ue.push(De)}}return ue}function pEe(c,p,y,x){return eo(c,function(I,L,W){p(x,y(I),L,W)}),x}function Ed(c,p,y){p=Ua(p,c),c=DF(c,p);var x=c==null?c:c[ro(Ji(p))];return x==null?e:Si(x,c,y)}function X2(c){return Sr(c)&&Un(c)==Le}function dEe(c){return Sr(c)&&Un(c)==Qs}function hEe(c){return Sr(c)&&Un(c)==Lt}function Td(c,p,y,x,I){return c===p?!0:c==null||p==null||!Sr(c)&&!Sr(p)?c!==c&&p!==p:mEe(c,p,y,x,Td,I)}function mEe(c,p,y,x,I,L){var W=ot(c),V=ot(p),J=W?Ue:Nn(c),ue=V?Ue:Nn(p);J=J==Le?He:J,ue=ue==Le?He:ue;var le=J==He,de=ue==He,we=J==ue;if(we&&Ha(c)){if(!Ha(p))return!1;W=!0,le=!1}if(we&&!le)return L||(L=new As),W||Ul(c)?IF(c,p,y,x,I,L):$Ee(c,p,J,y,x,I,L);if(!(y&h)){var De=le&&Ft.call(c,"__wrapped__"),Ge=de&&Ft.call(p,"__wrapped__");if(De||Ge){var lt=De?c.value():c,Ke=Ge?p.value():p;return L||(L=new As),I(lt,Ke,y,x,L)}}return we?(L||(L=new As),HEe(c,p,y,x,I,L)):!1}function gEe(c){return Sr(c)&&Nn(c)==te}function $S(c,p,y,x){var I=y.length,L=I,W=!x;if(c==null)return!L;for(c=Yt(c);I--;){var V=y[I];if(W&&V[2]?V[1]!==c[V[0]]:!(V[0]in c))return!1}for(;++I<L;){V=y[I];var J=V[0],ue=c[J],le=V[1];if(W&&V[2]){if(ue===e&&!(J in c))return!1}else{var de=new As;if(x)var we=x(ue,le,J,c,p,de);if(!(we===e?Td(le,ue,h|m,x,de):we))return!1}}return!0}function Y2(c){if(!vr(c)||JEe(c))return!1;var p=Wo(c)?gSe:o0e;return p.test(Ju(c))}function vEe(c){return Sr(c)&&Un(c)==jr}function yEe(c){return Sr(c)&&Nn(c)==Re}function _Ee(c){return Sr(c)&&Yv(c.length)&&!!rr[Un(c)]}function Z2(c){return typeof c=="function"?c:c==null?ii:typeof c=="object"?ot(c)?eF(c[0],c[1]):Q2(c):_M(c)}function HS(c){if(!Id(c))return wSe(c);var p=[];for(var y in Yt(c))Ft.call(c,y)&&y!="constructor"&&p.push(y);return p}function xEe(c){if(!vr(c))return rTe(c);var p=Id(c),y=[];for(var x in c)x=="constructor"&&(p||!Ft.call(c,x))||y.push(x);return y}function WS(c,p){return c<p}function J2(c,p){var y=-1,x=ri(c)?ne(c.length):[];return ja(c,function(I,L,W){x[++y]=p(I,L,W)}),x}function Q2(c){var p=sE(c);return p.length==1&&p[0][2]?PF(p[0][0],p[0][1]):function(y){return y===c||$S(y,c,p)}}function eF(c,p){return aE(c)&&kF(p)?PF(ro(c),p):function(y){var x=vE(y,c);return x===e&&x===p?yE(y,c):Td(p,x,h|m)}}function qv(c,p,y,x,I){c!==p&&MS(p,function(L,W){if(I||(I=new As),vr(L))bEe(c,p,W,y,qv,x,I);else{var V=x?x(cE(c,W),L,W+"",c,p,I):e;V===e&&(V=L),LS(c,W,V)}},ni)}function bEe(c,p,y,x,I,L,W){var V=cE(c,y),J=cE(p,y),ue=W.get(J);if(ue){LS(c,y,ue);return}var le=L?L(V,J,y+"",c,p,W):e,de=le===e;if(de){var we=ot(J),De=!we&&Ha(J),Ge=!we&&!De&&Ul(J);le=J,we||De||Ge?ot(V)?le=V:Or(V)?le=ti(V):De?(de=!1,le=pF(J,!0)):Ge?(de=!1,le=dF(J,!0)):le=[]:Od(J)||Qu(J)?(le=V,Qu(V)?le=cM(V):(!vr(V)||Wo(V))&&(le=RF(J))):de=!1}de&&(W.set(J,le),I(le,J,x,L,W),W.delete(J)),LS(c,y,le)}function tF(c,p){var y=c.length;if(y)return p+=p<0?y:0,Ho(p,y)?c[p]:e}function rF(c,p,y){p.length?p=sr(p,function(L){return ot(L)?function(W){return Yu(W,L.length===1?L[0]:L)}:L}):p=[ii];var x=-1;p=sr(p,Ei(We()));var I=J2(c,function(L,W,V){var J=sr(p,function(ue){return ue(L)});return{criteria:J,index:++x,value:L}});return K0e(I,function(L,W){return qEe(L,W,y)})}function wEe(c,p){return nF(c,p,function(y,x){return yE(c,x)})}function nF(c,p,y){for(var x=-1,I=p.length,L={};++x<I;){var W=p[x],V=Yu(c,W);y(V,W)&&Cd(L,Ua(W,c),V)}return L}function SEe(c){return function(p){return Yu(p,c)}}function zS(c,p,y,x){var I=x?G0e:Rl,L=-1,W=p.length,V=c;for(c===p&&(p=ti(p)),y&&(V=sr(c,Ei(y)));++L<W;)for(var J=0,ue=p[L],le=y?y(ue):ue;(J=I(V,le,J,x))>-1;)V!==c&&Ev.call(V,J,1),Ev.call(c,J,1);return c}function iF(c,p){for(var y=c?p.length:0,x=y-1;y--;){var I=p[y];if(y==x||I!==L){var L=I;Ho(I)?Ev.call(c,I,1):XS(c,I)}}return c}function VS(c,p){return c+Av(M2()*(p-c+1))}function EEe(c,p,y,x){for(var I=-1,L=Vr(Cv((p-c)/(y||1)),0),W=ne(L);L--;)W[x?L:++I]=c,c+=y;return W}function GS(c,p){var y="";if(!c||p<1||p>B)return y;do p%2&&(y+=c),p=Av(p/2),p&&(c+=c);while(p);return y}function ft(c,p){return lE(qF(c,p,ii),c+"")}function TEe(c){return U2($l(c))}function CEe(c,p){var y=$l(c);return Wv(y,Xu(p,0,y.length))}function Cd(c,p,y,x){if(!vr(c))return c;p=Ua(p,c);for(var I=-1,L=p.length,W=L-1,V=c;V!=null&&++I<L;){var J=ro(p[I]),ue=y;if(J==="__proto__"||J==="constructor"||J==="prototype")return c;if(I!=W){var le=V[J];ue=x?x(le,J,V):e,ue===e&&(ue=vr(le)?le:Ho(p[I+1])?[]:{})}wd(V,J,ue),V=V[J]}return c}var sF=Iv?function(c,p){return Iv.set(c,p),c}:ii,AEe=Tv?function(c,p){return Tv(c,"toString",{configurable:!0,enumerable:!1,value:xE(p),writable:!0})}:ii;function IEe(c){return Wv($l(c))}function Zi(c,p,y){var x=-1,I=c.length;p<0&&(p=-p>I?0:I+p),y=y>I?I:y,y<0&&(y+=I),I=p>y?0:y-p>>>0,p>>>=0;for(var L=ne(I);++x<I;)L[x]=c[x+p];return L}function NEe(c,p){var y;return ja(c,function(x,I,L){return y=p(x,I,L),!y}),!!y}function Dv(c,p,y){var x=0,I=c==null?x:c.length;if(typeof p=="number"&&p===p&&I<=xe){for(;x<I;){var L=x+I>>>1,W=c[L];W!==null&&!Ci(W)&&(y?W<=p:W<p)?x=L+1:I=L}return I}return KS(c,p,ii,y)}function KS(c,p,y,x){var I=0,L=c==null?0:c.length;if(L===0)return 0;p=y(p);for(var W=p!==p,V=p===null,J=Ci(p),ue=p===e;I<L;){var le=Av((I+L)/2),de=y(c[le]),we=de!==e,De=de===null,Ge=de===de,lt=Ci(de);if(W)var Ke=x||Ge;else ue?Ke=Ge&&(x||we):V?Ke=Ge&&we&&(x||!De):J?Ke=Ge&&we&&!De&&(x||!lt):De||lt?Ke=!1:Ke=x?de<=p:de<p;Ke?I=le+1:L=le}return In(L,pe)}function oF(c,p){for(var y=-1,x=c.length,I=0,L=[];++y<x;){var W=c[y],V=p?p(W):W;if(!y||!Is(V,J)){var J=V;L[I++]=W===0?0:W}}return L}function aF(c){return typeof c=="number"?c:Ci(c)?Y:+c}function Ti(c){if(typeof c=="string")return c;if(ot(c))return sr(c,Ti)+"";if(Ci(c))return j2?j2.call(c):"";var p=c+"";return p=="0"&&1/c==-j?"-0":p}function Ba(c,p,y){var x=-1,I=hv,L=c.length,W=!0,V=[],J=V;if(y)W=!1,I=SS;else if(L>=r){var ue=p?null:BEe(c);if(ue)return gv(ue);W=!1,I=gd,J=new Ku}else J=p?[]:V;e:for(;++x<L;){var le=c[x],de=p?p(le):le;if(le=y||le!==0?le:0,W&&de===de){for(var we=J.length;we--;)if(J[we]===de)continue e;p&&J.push(de),V.push(le)}else I(J,de,y)||(J!==V&&J.push(de),V.push(le))}return V}function XS(c,p){return p=Ua(p,c),c=DF(c,p),c==null||delete c[ro(Ji(p))]}function uF(c,p,y,x){return Cd(c,p,y(Yu(c,p)),x)}function Lv(c,p,y,x){for(var I=c.length,L=x?I:-1;(x?L--:++L<I)&&p(c[L],L,c););return y?Zi(c,x?0:L,x?L+1:I):Zi(c,x?L+1:0,x?I:L)}function cF(c,p){var y=c;return y instanceof yt&&(y=y.value()),ES(p,function(x,I){return I.func.apply(I.thisArg,Da([x],I.args))},y)}function YS(c,p,y){var x=c.length;if(x<2)return x?Ba(c[0]):[];for(var I=-1,L=ne(x);++I<x;)for(var W=c[I],V=-1;++V<x;)V!=I&&(L[I]=Sd(L[I]||W,c[V],p,y));return Ba(pn(L,1),p,y)}function lF(c,p,y){for(var x=-1,I=c.length,L=p.length,W={};++x<I;){var V=x<L?p[x]:e;y(W,c[x],V)}return W}function ZS(c){return Or(c)?c:[]}function JS(c){return typeof c=="function"?c:ii}function Ua(c,p){return ot(c)?c:aE(c,p)?[c]:jF(kt(c))}var OEe=ft;function $a(c,p,y){var x=c.length;return y=y===e?x:y,!p&&y>=x?c:Zi(c,p,y)}var fF=vSe||function(c){return tn.clearTimeout(c)};function pF(c,p){if(p)return c.slice();var y=c.length,x=P2?P2(y):new c.constructor(y);return c.copy(x),x}function QS(c){var p=new c.constructor(c.byteLength);return new wv(p).set(new wv(c)),p}function REe(c,p){var y=p?QS(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.byteLength)}function kEe(c){var p=new c.constructor(c.source,XL.exec(c));return p.lastIndex=c.lastIndex,p}function PEe(c){return bd?Yt(bd.call(c)):{}}function dF(c,p){var y=p?QS(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.length)}function hF(c,p){if(c!==p){var y=c!==e,x=c===null,I=c===c,L=Ci(c),W=p!==e,V=p===null,J=p===p,ue=Ci(p);if(!V&&!ue&&!L&&c>p||L&&W&&J&&!V&&!ue||x&&W&&J||!y&&J||!I)return 1;if(!x&&!L&&!ue&&c<p||ue&&y&&I&&!x&&!L||V&&y&&I||!W&&I||!J)return-1}return 0}function qEe(c,p,y){for(var x=-1,I=c.criteria,L=p.criteria,W=I.length,V=y.length;++x<W;){var J=hF(I[x],L[x]);if(J){if(x>=V)return J;var ue=y[x];return J*(ue=="desc"?-1:1)}}return c.index-p.index}function mF(c,p,y,x){for(var I=-1,L=c.length,W=y.length,V=-1,J=p.length,ue=Vr(L-W,0),le=ne(J+ue),de=!x;++V<J;)le[V]=p[V];for(;++I<W;)(de||I<L)&&(le[y[I]]=c[I]);for(;ue--;)le[V++]=c[I++];return le}function gF(c,p,y,x){for(var I=-1,L=c.length,W=-1,V=y.length,J=-1,ue=p.length,le=Vr(L-V,0),de=ne(le+ue),we=!x;++I<le;)de[I]=c[I];for(var De=I;++J<ue;)de[De+J]=p[J];for(;++W<V;)(we||I<L)&&(de[De+y[W]]=c[I++]);return de}function ti(c,p){var y=-1,x=c.length;for(p||(p=ne(x));++y<x;)p[y]=c[y];return p}function to(c,p,y,x){var I=!y;y||(y={});for(var L=-1,W=p.length;++L<W;){var V=p[L],J=x?x(y[V],c[V],V,y,c):e;J===e&&(J=c[V]),I?Bo(y,V,J):wd(y,V,J)}return y}function DEe(c,p){return to(c,oE(c),p)}function LEe(c,p){return to(c,NF(c),p)}function Fv(c,p){return function(y,x){var I=ot(y)?U0e:iEe,L=p?p():{};return I(y,c,We(x,2),L)}}function Ml(c){return ft(function(p,y){var x=-1,I=y.length,L=I>1?y[I-1]:e,W=I>2?y[2]:e;for(L=c.length>3&&typeof L=="function"?(I--,L):e,W&&$n(y[0],y[1],W)&&(L=I<3?e:L,I=1),p=Yt(p);++x<I;){var V=y[x];V&&c(p,V,x,L)}return p})}function vF(c,p){return function(y,x){if(y==null)return y;if(!ri(y))return c(y,x);for(var I=y.length,L=p?I:-1,W=Yt(y);(p?L--:++L<I)&&x(W[L],L,W)!==!1;);return y}}function yF(c){return function(p,y,x){for(var I=-1,L=Yt(p),W=x(p),V=W.length;V--;){var J=W[c?V:++I];if(y(L[J],J,L)===!1)break}return p}}function FEe(c,p,y){var x=p&g,I=Ad(c);function L(){var W=this&&this!==tn&&this instanceof L?I:c;return W.apply(x?y:this,arguments)}return L}function _F(c){return function(p){p=kt(p);var y=kl(p)?Cs(p):e,x=y?y[0]:p.charAt(0),I=y?$a(y,1).join(""):p.slice(1);return x[c]()+I}}function jl(c){return function(p){return ES(vM(gM(p).replace(A0e,"")),c,"")}}function Ad(c){return function(){var p=arguments;switch(p.length){case 0:return new c;case 1:return new c(p[0]);case 2:return new c(p[0],p[1]);case 3:return new c(p[0],p[1],p[2]);case 4:return new c(p[0],p[1],p[2],p[3]);case 5:return new c(p[0],p[1],p[2],p[3],p[4]);case 6:return new c(p[0],p[1],p[2],p[3],p[4],p[5]);case 7:return new c(p[0],p[1],p[2],p[3],p[4],p[5],p[6])}var y=Fl(c.prototype),x=c.apply(y,p);return vr(x)?x:y}}function MEe(c,p,y){var x=Ad(c);function I(){for(var L=arguments.length,W=ne(L),V=L,J=Bl(I);V--;)W[V]=arguments[V];var ue=L<3&&W[0]!==J&&W[L-1]!==J?[]:La(W,J);if(L-=ue.length,L<y)return EF(c,p,Mv,I.placeholder,e,W,ue,e,e,y-L);var le=this&&this!==tn&&this instanceof I?x:c;return Si(le,this,W)}return I}function xF(c){return function(p,y,x){var I=Yt(p);if(!ri(p)){var L=We(y,3);p=rn(p),y=function(V){return L(I[V],V,I)}}var W=c(p,y,x);return W>-1?I[L?p[W]:W]:e}}function bF(c){return $o(function(p){var y=p.length,x=y,I=Xi.prototype.thru;for(c&&p.reverse();x--;){var L=p[x];if(typeof L!="function")throw new Ki(i);if(I&&!W&&$v(L)=="wrapper")var W=new Xi([],!0)}for(x=W?x:y;++x<y;){L=p[x];var V=$v(L),J=V=="wrapper"?iE(L):e;J&&uE(J[0])&&J[1]==(E|b|T|N)&&!J[4].length&&J[9]==1?W=W[$v(J[0])].apply(W,J[3]):W=L.length==1&&uE(L)?W[V]():W.thru(L)}return function(){var ue=arguments,le=ue[0];if(W&&ue.length==1&&ot(le))return W.plant(le).value();for(var de=0,we=y?p[de].apply(this,ue):le;++de<y;)we=p[de].call(this,we);return we}})}function Mv(c,p,y,x,I,L,W,V,J,ue){var le=p&E,de=p&g,we=p&_,De=p&(b|C),Ge=p&U,lt=we?e:Ad(c);function Ke(){for(var ht=arguments.length,St=ne(ht),Ai=ht;Ai--;)St[Ai]=arguments[Ai];if(De)var Hn=Bl(Ke),Ii=Y0e(St,Hn);if(x&&(St=mF(St,x,I,De)),L&&(St=gF(St,L,W,De)),ht-=Ii,De&&ht<ue){var Rr=La(St,Hn);return EF(c,p,Mv,Ke.placeholder,y,St,Rr,V,J,ue-ht)}var Ns=de?y:this,Vo=we?Ns[c]:c;return ht=St.length,V?St=iTe(St,V):Ge&&ht>1&&St.reverse(),le&&J<ht&&(St.length=J),this&&this!==tn&&this instanceof Ke&&(Vo=lt||Ad(Vo)),Vo.apply(Ns,St)}return Ke}function wF(c,p){return function(y,x){return pEe(y,c,p(x),{})}}function jv(c,p){return function(y,x){var I;if(y===e&&x===e)return p;if(y!==e&&(I=y),x!==e){if(I===e)return x;typeof y=="string"||typeof x=="string"?(y=Ti(y),x=Ti(x)):(y=aF(y),x=aF(x)),I=c(y,x)}return I}}function eE(c){return $o(function(p){return p=sr(p,Ei(We())),ft(function(y){var x=this;return c(p,function(I){return Si(I,x,y)})})})}function Bv(c,p){p=p===e?" ":Ti(p);var y=p.length;if(y<2)return y?GS(p,c):p;var x=GS(p,Cv(c/Pl(p)));return kl(p)?$a(Cs(x),0,c).join(""):x.slice(0,c)}function jEe(c,p,y,x){var I=p&g,L=Ad(c);function W(){for(var V=-1,J=arguments.length,ue=-1,le=x.length,de=ne(le+J),we=this&&this!==tn&&this instanceof W?L:c;++ue<le;)de[ue]=x[ue];for(;J--;)de[ue++]=arguments[++V];return Si(we,I?y:this,de)}return W}function SF(c){return function(p,y,x){return x&&typeof x!="number"&&$n(p,y,x)&&(y=x=e),p=zo(p),y===e?(y=p,p=0):y=zo(y),x=x===e?p<y?1:-1:zo(x),EEe(p,y,x,c)}}function Uv(c){return function(p,y){return typeof p=="string"&&typeof y=="string"||(p=Qi(p),y=Qi(y)),c(p,y)}}function EF(c,p,y,x,I,L,W,V,J,ue){var le=p&b,de=le?W:e,we=le?e:W,De=le?L:e,Ge=le?e:L;p|=le?T:w,p&=~(le?w:T),p&S||(p&=~(g|_));var lt=[c,p,I,De,de,Ge,we,V,J,ue],Ke=y.apply(e,lt);return uE(c)&&LF(Ke,lt),Ke.placeholder=x,FF(Ke,c,p)}function tE(c){var p=zr[c];return function(y,x){if(y=Qi(y),x=x==null?0:In(ct(x),292),x&&F2(y)){var I=(kt(y)+"e").split("e"),L=p(I[0]+"e"+(+I[1]+x));return I=(kt(L)+"e").split("e"),+(I[0]+"e"+(+I[1]-x))}return p(y)}}var BEe=Dl&&1/gv(new Dl([,-0]))[1]==j?function(c){return new Dl(c)}:SE;function TF(c){return function(p){var y=Nn(p);return y==te?RS(p):y==Re?nSe(p):X0e(p,c(p))}}function Uo(c,p,y,x,I,L,W,V){var J=p&_;if(!J&&typeof c!="function")throw new Ki(i);var ue=x?x.length:0;if(ue||(p&=~(T|w),x=I=e),W=W===e?W:Vr(ct(W),0),V=V===e?V:ct(V),ue-=I?I.length:0,p&w){var le=x,de=I;x=I=e}var we=J?e:iE(c),De=[c,p,y,x,I,le,de,L,W,V];if(we&&tTe(De,we),c=De[0],p=De[1],y=De[2],x=De[3],I=De[4],V=De[9]=De[9]===e?J?0:c.length:Vr(De[9]-ue,0),!V&&p&(b|C)&&(p&=~(b|C)),!p||p==g)var Ge=FEe(c,p,y);else p==b||p==C?Ge=MEe(c,p,V):(p==T||p==(g|T))&&!I.length?Ge=jEe(c,p,y,x):Ge=Mv.apply(e,De);var lt=we?sF:LF;return FF(lt(Ge,De),c,p)}function CF(c,p,y,x){return c===e||Is(c,ql[y])&&!Ft.call(x,y)?p:c}function AF(c,p,y,x,I,L){return vr(c)&&vr(p)&&(L.set(p,c),qv(c,p,e,AF,L),L.delete(p)),c}function UEe(c){return Od(c)?e:c}function IF(c,p,y,x,I,L){var W=y&h,V=c.length,J=p.length;if(V!=J&&!(W&&J>V))return!1;var ue=L.get(c),le=L.get(p);if(ue&&le)return ue==p&&le==c;var de=-1,we=!0,De=y&m?new Ku:e;for(L.set(c,p),L.set(p,c);++de<V;){var Ge=c[de],lt=p[de];if(x)var Ke=W?x(lt,Ge,de,p,c,L):x(Ge,lt,de,c,p,L);if(Ke!==e){if(Ke)continue;we=!1;break}if(De){if(!TS(p,function(ht,St){if(!gd(De,St)&&(Ge===ht||I(Ge,ht,y,x,L)))return De.push(St)})){we=!1;break}}else if(!(Ge===lt||I(Ge,lt,y,x,L))){we=!1;break}}return L.delete(c),L.delete(p),we}function $Ee(c,p,y,x,I,L,W){switch(y){case P:if(c.byteLength!=p.byteLength||c.byteOffset!=p.byteOffset)return!1;c=c.buffer,p=p.buffer;case Qs:return!(c.byteLength!=p.byteLength||!L(new wv(c),new wv(p)));case Ie:case Lt:case X:return Is(+c,+p);case ge:return c.name==p.name&&c.message==p.message;case jr:case Xt:return c==p+"";case te:var V=RS;case Re:var J=x&h;if(V||(V=gv),c.size!=p.size&&!J)return!1;var ue=W.get(c);if(ue)return ue==p;x|=m,W.set(c,p);var le=IF(V(c),V(p),x,I,L,W);return W.delete(c),le;case fn:if(bd)return bd.call(c)==bd.call(p)}return!1}function HEe(c,p,y,x,I,L){var W=y&h,V=rE(c),J=V.length,ue=rE(p),le=ue.length;if(J!=le&&!W)return!1;for(var de=J;de--;){var we=V[de];if(!(W?we in p:Ft.call(p,we)))return!1}var De=L.get(c),Ge=L.get(p);if(De&&Ge)return De==p&&Ge==c;var lt=!0;L.set(c,p),L.set(p,c);for(var Ke=W;++de<J;){we=V[de];var ht=c[we],St=p[we];if(x)var Ai=W?x(St,ht,we,p,c,L):x(ht,St,we,c,p,L);if(!(Ai===e?ht===St||I(ht,St,y,x,L):Ai)){lt=!1;break}Ke||(Ke=we=="constructor")}if(lt&&!Ke){var Hn=c.constructor,Ii=p.constructor;Hn!=Ii&&"constructor"in c&&"constructor"in p&&!(typeof Hn=="function"&&Hn instanceof Hn&&typeof Ii=="function"&&Ii instanceof Ii)&&(lt=!1)}return L.delete(c),L.delete(p),lt}function $o(c){return lE(qF(c,e,HF),c+"")}function rE(c){return K2(c,rn,oE)}function nE(c){return K2(c,ni,NF)}var iE=Iv?function(c){return Iv.get(c)}:SE;function $v(c){for(var p=c.name+"",y=Ll[p],x=Ft.call(Ll,p)?y.length:0;x--;){var I=y[x],L=I.func;if(L==null||L==c)return I.name}return p}function Bl(c){var p=Ft.call(R,"placeholder")?R:c;return p.placeholder}function We(){var c=R.iteratee||bE;return c=c===bE?Z2:c,arguments.length?c(arguments[0],arguments[1]):c}function Hv(c,p){var y=c.__data__;return ZEe(p)?y[typeof p=="string"?"string":"hash"]:y.map}function sE(c){for(var p=rn(c),y=p.length;y--;){var x=p[y],I=c[x];p[y]=[x,I,kF(I)]}return p}function Zu(c,p){var y=eSe(c,p);return Y2(y)?y:e}function WEe(c){var p=Ft.call(c,Vu),y=c[Vu];try{c[Vu]=e;var x=!0}catch{}var I=xv.call(c);return x&&(p?c[Vu]=y:delete c[Vu]),I}var oE=PS?function(c){return c==null?[]:(c=Yt(c),qa(PS(c),function(p){return D2.call(c,p)}))}:EE,NF=PS?function(c){for(var p=[];c;)Da(p,oE(c)),c=Sv(c);return p}:EE,Nn=Un;(qS&&Nn(new qS(new ArrayBuffer(1)))!=P||yd&&Nn(new yd)!=te||DS&&Nn(DS.resolve())!=zt||Dl&&Nn(new Dl)!=Re||_d&&Nn(new _d)!=Js)&&(Nn=function(c){var p=Un(c),y=p==He?c.constructor:e,x=y?Ju(y):"";if(x)switch(x){case CSe:return P;case ASe:return te;case ISe:return zt;case NSe:return Re;case OSe:return Js}return p});function zEe(c,p,y){for(var x=-1,I=y.length;++x<I;){var L=y[x],W=L.size;switch(L.type){case"drop":c+=W;break;case"dropRight":p-=W;break;case"take":p=In(p,c+W);break;case"takeRight":c=Vr(c,p-W);break}}return{start:c,end:p}}function VEe(c){var p=c.match(Jwe);return p?p[1].split(Qwe):[]}function OF(c,p,y){p=Ua(p,c);for(var x=-1,I=p.length,L=!1;++x<I;){var W=ro(p[x]);if(!(L=c!=null&&y(c,W)))break;c=c[W]}return L||++x!=I?L:(I=c==null?0:c.length,!!I&&Yv(I)&&Ho(W,I)&&(ot(c)||Qu(c)))}function GEe(c){var p=c.length,y=new c.constructor(p);return p&&typeof c[0]=="string"&&Ft.call(c,"index")&&(y.index=c.index,y.input=c.input),y}function RF(c){return typeof c.constructor=="function"&&!Id(c)?Fl(Sv(c)):{}}function KEe(c,p,y){var x=c.constructor;switch(p){case Qs:return QS(c);case Ie:case Lt:return new x(+c);case P:return REe(c,y);case z:case K:case ie:case ce:case Ee:case Je:case dt:case Wr:case bi:return dF(c,y);case te:return new x;case X:case Xt:return new x(c);case jr:return kEe(c);case Re:return new x;case fn:return PEe(c)}}function XEe(c,p){var y=p.length;if(!y)return c;var x=y-1;return p[x]=(y>1?"& ":"")+p[x],p=p.join(y>2?", ":" "),c.replace(lv,`{
|
|
143
143
|
/* [wrapped with `+p+`] */
|
|
144
144
|
`)}function YEe(c){return ot(c)||Qu(c)||!!(L2&&c&&c[L2])}function Ho(c,p){var y=typeof c;return p=p??B,!!p&&(y=="number"||y!="symbol"&&u0e.test(c))&&c>-1&&c%1==0&&c<p}function $n(c,p,y){if(!vr(y))return!1;var x=typeof p;return(x=="number"?ri(y)&&Ho(p,y.length):x=="string"&&p in y)?Is(y[p],c):!1}function aE(c,p){if(ot(c))return!1;var y=typeof c;return y=="number"||y=="symbol"||y=="boolean"||c==null||Ci(c)?!0:uv.test(c)||!hd.test(c)||p!=null&&c in Yt(p)}function ZEe(c){var p=typeof c;return p=="string"||p=="number"||p=="symbol"||p=="boolean"?c!=="__proto__":c===null}function uE(c){var p=$v(c),y=R[p];if(typeof y!="function"||!(p in yt.prototype))return!1;if(c===y)return!0;var x=iE(y);return!!x&&c===x[0]}function JEe(c){return!!k2&&k2 in c}var QEe=yv?Wo:TE;function Id(c){var p=c&&c.constructor,y=typeof p=="function"&&p.prototype||ql;return c===y}function kF(c){return c===c&&!vr(c)}function PF(c,p){return function(y){return y==null?!1:y[c]===p&&(p!==e||c in Yt(y))}}function eTe(c){var p=Kv(c,function(x){return y.size===a&&y.clear(),x}),y=p.cache;return p}function tTe(c,p){var y=c[1],x=p[1],I=y|x,L=I<(g|_|E),W=x==E&&y==b||x==E&&y==N&&c[7].length<=p[8]||x==(E|N)&&p[7].length<=p[8]&&y==b;if(!(L||W))return c;x&g&&(c[2]=p[2],I|=y&g?0:S);var V=p[3];if(V){var J=c[3];c[3]=J?mF(J,V,p[4]):V,c[4]=J?La(c[3],u):p[4]}return V=p[5],V&&(J=c[5],c[5]=J?gF(J,V,p[6]):V,c[6]=J?La(c[5],u):p[6]),V=p[7],V&&(c[7]=V),x&E&&(c[8]=c[8]==null?p[8]:In(c[8],p[8])),c[9]==null&&(c[9]=p[9]),c[0]=p[0],c[1]=I,c}function rTe(c){var p=[];if(c!=null)for(var y in Yt(c))p.push(y);return p}function nTe(c){return xv.call(c)}function qF(c,p,y){return p=Vr(p===e?c.length-1:p,0),function(){for(var x=arguments,I=-1,L=Vr(x.length-p,0),W=ne(L);++I<L;)W[I]=x[p+I];I=-1;for(var V=ne(p+1);++I<p;)V[I]=x[I];return V[p]=y(W),Si(c,this,V)}}function DF(c,p){return p.length<2?c:Yu(c,Zi(p,0,-1))}function iTe(c,p){for(var y=c.length,x=In(p.length,y),I=ti(c);x--;){var L=p[x];c[x]=Ho(L,y)?I[L]:e}return c}function cE(c,p){if(!(p==="constructor"&&typeof c[p]=="function")&&p!="__proto__")return c[p]}var LF=MF(sF),Nd=_Se||function(c,p){return tn.setTimeout(c,p)},lE=MF(AEe);function FF(c,p,y){var x=p+"";return lE(c,XEe(x,sTe(VEe(x),y)))}function MF(c){var p=0,y=0;return function(){var x=SSe(),I=q-(x-y);if(y=x,I>0){if(++p>=k)return arguments[0]}else p=0;return c.apply(e,arguments)}}function Wv(c,p){var y=-1,x=c.length,I=x-1;for(p=p===e?x:p;++y<p;){var L=VS(y,I),W=c[L];c[L]=c[y],c[y]=W}return c.length=p,c}var jF=eTe(function(c){var p=[];return c.charCodeAt(0)===46&&p.push(""),c.replace(md,function(y,x,I,L){p.push(I?L.replace(r0e,"$1"):x||y)}),p});function ro(c){if(typeof c=="string"||Ci(c))return c;var p=c+"";return p=="0"&&1/c==-j?"-0":p}function Ju(c){if(c!=null){try{return _v.call(c)}catch{}try{return c+""}catch{}}return""}function sTe(c,p){return Gi(_e,function(y){var x="_."+y[0];p&y[1]&&!hv(c,x)&&c.push(x)}),c.sort()}function BF(c){if(c instanceof yt)return c.clone();var p=new Xi(c.__wrapped__,c.__chain__);return p.__actions__=ti(c.__actions__),p.__index__=c.__index__,p.__values__=c.__values__,p}function oTe(c,p,y){(y?$n(c,p,y):p===e)?p=1:p=Vr(ct(p),0);var x=c==null?0:c.length;if(!x||p<1)return[];for(var I=0,L=0,W=ne(Cv(x/p));I<x;)W[L++]=Zi(c,I,I+=p);return W}function aTe(c){for(var p=-1,y=c==null?0:c.length,x=0,I=[];++p<y;){var L=c[p];L&&(I[x++]=L)}return I}function uTe(){var c=arguments.length;if(!c)return[];for(var p=ne(c-1),y=arguments[0],x=c;x--;)p[x-1]=arguments[x];return Da(ot(y)?ti(y):[y],pn(p,1))}var cTe=ft(function(c,p){return Or(c)?Sd(c,pn(p,1,Or,!0)):[]}),lTe=ft(function(c,p){var y=Ji(p);return Or(y)&&(y=e),Or(c)?Sd(c,pn(p,1,Or,!0),We(y,2)):[]}),fTe=ft(function(c,p){var y=Ji(p);return Or(y)&&(y=e),Or(c)?Sd(c,pn(p,1,Or,!0),e,y):[]});function pTe(c,p,y){var x=c==null?0:c.length;return x?(p=y||p===e?1:ct(p),Zi(c,p<0?0:p,x)):[]}function dTe(c,p,y){var x=c==null?0:c.length;return x?(p=y||p===e?1:ct(p),p=x-p,Zi(c,0,p<0?0:p)):[]}function hTe(c,p){return c&&c.length?Lv(c,We(p,3),!0,!0):[]}function mTe(c,p){return c&&c.length?Lv(c,We(p,3),!0):[]}function gTe(c,p,y,x){var I=c==null?0:c.length;return I?(y&&typeof y!="number"&&$n(c,p,y)&&(y=0,x=I),uEe(c,p,y,x)):[]}function UF(c,p,y){var x=c==null?0:c.length;if(!x)return-1;var I=y==null?0:ct(y);return I<0&&(I=Vr(x+I,0)),mv(c,We(p,3),I)}function $F(c,p,y){var x=c==null?0:c.length;if(!x)return-1;var I=x-1;return y!==e&&(I=ct(y),I=y<0?Vr(x+I,0):In(I,x-1)),mv(c,We(p,3),I,!0)}function HF(c){var p=c==null?0:c.length;return p?pn(c,1):[]}function vTe(c){var p=c==null?0:c.length;return p?pn(c,j):[]}function yTe(c,p){var y=c==null?0:c.length;return y?(p=p===e?1:ct(p),pn(c,p)):[]}function _Te(c){for(var p=-1,y=c==null?0:c.length,x={};++p<y;){var I=c[p];x[I[0]]=I[1]}return x}function WF(c){return c&&c.length?c[0]:e}function xTe(c,p,y){var x=c==null?0:c.length;if(!x)return-1;var I=y==null?0:ct(y);return I<0&&(I=Vr(x+I,0)),Rl(c,p,I)}function bTe(c){var p=c==null?0:c.length;return p?Zi(c,0,-1):[]}var wTe=ft(function(c){var p=sr(c,ZS);return p.length&&p[0]===c[0]?US(p):[]}),STe=ft(function(c){var p=Ji(c),y=sr(c,ZS);return p===Ji(y)?p=e:y.pop(),y.length&&y[0]===c[0]?US(y,We(p,2)):[]}),ETe=ft(function(c){var p=Ji(c),y=sr(c,ZS);return p=typeof p=="function"?p:e,p&&y.pop(),y.length&&y[0]===c[0]?US(y,e,p):[]});function TTe(c,p){return c==null?"":bSe.call(c,p)}function Ji(c){var p=c==null?0:c.length;return p?c[p-1]:e}function CTe(c,p,y){var x=c==null?0:c.length;if(!x)return-1;var I=x;return y!==e&&(I=ct(y),I=I<0?Vr(x+I,0):In(I,x-1)),p===p?sSe(c,p,I):mv(c,E2,I,!0)}function ATe(c,p){return c&&c.length?tF(c,ct(p)):e}var ITe=ft(zF);function zF(c,p){return c&&c.length&&p&&p.length?zS(c,p):c}function NTe(c,p,y){return c&&c.length&&p&&p.length?zS(c,p,We(y,2)):c}function OTe(c,p,y){return c&&c.length&&p&&p.length?zS(c,p,e,y):c}var RTe=$o(function(c,p){var y=c==null?0:c.length,x=FS(c,p);return iF(c,sr(p,function(I){return Ho(I,y)?+I:I}).sort(hF)),x});function kTe(c,p){var y=[];if(!(c&&c.length))return y;var x=-1,I=[],L=c.length;for(p=We(p,3);++x<L;){var W=c[x];p(W,x,c)&&(y.push(W),I.push(x))}return iF(c,I),y}function fE(c){return c==null?c:TSe.call(c)}function PTe(c,p,y){var x=c==null?0:c.length;return x?(y&&typeof y!="number"&&$n(c,p,y)?(p=0,y=x):(p=p==null?0:ct(p),y=y===e?x:ct(y)),Zi(c,p,y)):[]}function qTe(c,p){return Dv(c,p)}function DTe(c,p,y){return KS(c,p,We(y,2))}function LTe(c,p){var y=c==null?0:c.length;if(y){var x=Dv(c,p);if(x<y&&Is(c[x],p))return x}return-1}function FTe(c,p){return Dv(c,p,!0)}function MTe(c,p,y){return KS(c,p,We(y,2),!0)}function jTe(c,p){var y=c==null?0:c.length;if(y){var x=Dv(c,p,!0)-1;if(Is(c[x],p))return x}return-1}function BTe(c){return c&&c.length?oF(c):[]}function UTe(c,p){return c&&c.length?oF(c,We(p,2)):[]}function $Te(c){var p=c==null?0:c.length;return p?Zi(c,1,p):[]}function HTe(c,p,y){return c&&c.length?(p=y||p===e?1:ct(p),Zi(c,0,p<0?0:p)):[]}function WTe(c,p,y){var x=c==null?0:c.length;return x?(p=y||p===e?1:ct(p),p=x-p,Zi(c,p<0?0:p,x)):[]}function zTe(c,p){return c&&c.length?Lv(c,We(p,3),!1,!0):[]}function VTe(c,p){return c&&c.length?Lv(c,We(p,3)):[]}var GTe=ft(function(c){return Ba(pn(c,1,Or,!0))}),KTe=ft(function(c){var p=Ji(c);return Or(p)&&(p=e),Ba(pn(c,1,Or,!0),We(p,2))}),XTe=ft(function(c){var p=Ji(c);return p=typeof p=="function"?p:e,Ba(pn(c,1,Or,!0),e,p)});function YTe(c){return c&&c.length?Ba(c):[]}function ZTe(c,p){return c&&c.length?Ba(c,We(p,2)):[]}function JTe(c,p){return p=typeof p=="function"?p:e,c&&c.length?Ba(c,e,p):[]}function pE(c){if(!(c&&c.length))return[];var p=0;return c=qa(c,function(y){if(Or(y))return p=Vr(y.length,p),!0}),NS(p,function(y){return sr(c,CS(y))})}function VF(c,p){if(!(c&&c.length))return[];var y=pE(c);return p==null?y:sr(y,function(x){return Si(p,e,x)})}var QTe=ft(function(c,p){return Or(c)?Sd(c,p):[]}),eCe=ft(function(c){return YS(qa(c,Or))}),tCe=ft(function(c){var p=Ji(c);return Or(p)&&(p=e),YS(qa(c,Or),We(p,2))}),rCe=ft(function(c){var p=Ji(c);return p=typeof p=="function"?p:e,YS(qa(c,Or),e,p)}),nCe=ft(pE);function iCe(c,p){return lF(c||[],p||[],wd)}function sCe(c,p){return lF(c||[],p||[],Cd)}var oCe=ft(function(c){var p=c.length,y=p>1?c[p-1]:e;return y=typeof y=="function"?(c.pop(),y):e,VF(c,y)});function GF(c){var p=R(c);return p.__chain__=!0,p}function aCe(c,p){return p(c),c}function zv(c,p){return p(c)}var uCe=$o(function(c){var p=c.length,y=p?c[0]:0,x=this.__wrapped__,I=function(L){return FS(L,c)};return p>1||this.__actions__.length||!(x instanceof yt)||!Ho(y)?this.thru(I):(x=x.slice(y,+y+(p?1:0)),x.__actions__.push({func:zv,args:[I],thisArg:e}),new Xi(x,this.__chain__).thru(function(L){return p&&!L.length&&L.push(e),L}))});function cCe(){return GF(this)}function lCe(){return new Xi(this.value(),this.__chain__)}function fCe(){this.__values__===e&&(this.__values__=aM(this.value()));var c=this.__index__>=this.__values__.length,p=c?e:this.__values__[this.__index__++];return{done:c,value:p}}function pCe(){return this}function dCe(c){for(var p,y=this;y instanceof Ov;){var x=BF(y);x.__index__=0,x.__values__=e,p?I.__wrapped__=x:p=x;var I=x;y=y.__wrapped__}return I.__wrapped__=c,p}function hCe(){var c=this.__wrapped__;if(c instanceof yt){var p=c;return this.__actions__.length&&(p=new yt(this)),p=p.reverse(),p.__actions__.push({func:zv,args:[fE],thisArg:e}),new Xi(p,this.__chain__)}return this.thru(fE)}function mCe(){return cF(this.__wrapped__,this.__actions__)}var gCe=Fv(function(c,p,y){Ft.call(c,y)?++c[y]:Bo(c,y,1)});function vCe(c,p,y){var x=ot(c)?w2:aEe;return y&&$n(c,p,y)&&(p=e),x(c,We(p,3))}function yCe(c,p){var y=ot(c)?qa:V2;return y(c,We(p,3))}var _Ce=xF(UF),xCe=xF($F);function bCe(c,p){return pn(Vv(c,p),1)}function wCe(c,p){return pn(Vv(c,p),j)}function SCe(c,p,y){return y=y===e?1:ct(y),pn(Vv(c,p),y)}function KF(c,p){var y=ot(c)?Gi:ja;return y(c,We(p,3))}function XF(c,p){var y=ot(c)?$0e:z2;return y(c,We(p,3))}var ECe=Fv(function(c,p,y){Ft.call(c,y)?c[y].push(p):Bo(c,y,[p])});function TCe(c,p,y,x){c=ri(c)?c:$l(c),y=y&&!x?ct(y):0;var I=c.length;return y<0&&(y=Vr(I+y,0)),Zv(c)?y<=I&&c.indexOf(p,y)>-1:!!I&&Rl(c,p,y)>-1}var CCe=ft(function(c,p,y){var x=-1,I=typeof p=="function",L=ri(c)?ne(c.length):[];return ja(c,function(W){L[++x]=I?Si(p,W,y):Ed(W,p,y)}),L}),ACe=Fv(function(c,p,y){Bo(c,y,p)});function Vv(c,p){var y=ot(c)?sr:J2;return y(c,We(p,3))}function ICe(c,p,y,x){return c==null?[]:(ot(p)||(p=p==null?[]:[p]),y=x?e:y,ot(y)||(y=y==null?[]:[y]),rF(c,p,y))}var NCe=Fv(function(c,p,y){c[y?0:1].push(p)},function(){return[[],[]]});function OCe(c,p,y){var x=ot(c)?ES:C2,I=arguments.length<3;return x(c,We(p,4),y,I,ja)}function RCe(c,p,y){var x=ot(c)?H0e:C2,I=arguments.length<3;return x(c,We(p,4),y,I,z2)}function kCe(c,p){var y=ot(c)?qa:V2;return y(c,Xv(We(p,3)))}function PCe(c){var p=ot(c)?U2:TEe;return p(c)}function qCe(c,p,y){(y?$n(c,p,y):p===e)?p=1:p=ct(p);var x=ot(c)?rEe:CEe;return x(c,p)}function DCe(c){var p=ot(c)?nEe:IEe;return p(c)}function LCe(c){if(c==null)return 0;if(ri(c))return Zv(c)?Pl(c):c.length;var p=Nn(c);return p==te||p==Re?c.size:HS(c).length}function FCe(c,p,y){var x=ot(c)?TS:NEe;return y&&$n(c,p,y)&&(p=e),x(c,We(p,3))}var MCe=ft(function(c,p){if(c==null)return[];var y=p.length;return y>1&&$n(c,p[0],p[1])?p=[]:y>2&&$n(p[0],p[1],p[2])&&(p=[p[0]]),rF(c,pn(p,1),[])}),Gv=ySe||function(){return tn.Date.now()};function jCe(c,p){if(typeof p!="function")throw new Ki(i);return c=ct(c),function(){if(--c<1)return p.apply(this,arguments)}}function YF(c,p,y){return p=y?e:p,p=c&&p==null?c.length:p,Uo(c,E,e,e,e,e,p)}function ZF(c,p){var y;if(typeof p!="function")throw new Ki(i);return c=ct(c),function(){return--c>0&&(y=p.apply(this,arguments)),c<=1&&(p=e),y}}var dE=ft(function(c,p,y){var x=g;if(y.length){var I=La(y,Bl(dE));x|=T}return Uo(c,x,p,y,I)}),JF=ft(function(c,p,y){var x=g|_;if(y.length){var I=La(y,Bl(JF));x|=T}return Uo(p,x,c,y,I)});function QF(c,p,y){p=y?e:p;var x=Uo(c,b,e,e,e,e,e,p);return x.placeholder=QF.placeholder,x}function eM(c,p,y){p=y?e:p;var x=Uo(c,C,e,e,e,e,e,p);return x.placeholder=eM.placeholder,x}function tM(c,p,y){var x,I,L,W,V,J,ue=0,le=!1,de=!1,we=!0;if(typeof c!="function")throw new Ki(i);p=Qi(p)||0,vr(y)&&(le=!!y.leading,de="maxWait"in y,L=de?Vr(Qi(y.maxWait)||0,p):L,we="trailing"in y?!!y.trailing:we);function De(Rr){var Ns=x,Vo=I;return x=I=e,ue=Rr,W=c.apply(Vo,Ns),W}function Ge(Rr){return ue=Rr,V=Nd(ht,p),le?De(Rr):W}function lt(Rr){var Ns=Rr-J,Vo=Rr-ue,xM=p-Ns;return de?In(xM,L-Vo):xM}function Ke(Rr){var Ns=Rr-J,Vo=Rr-ue;return J===e||Ns>=p||Ns<0||de&&Vo>=L}function ht(){var Rr=Gv();if(Ke(Rr))return St(Rr);V=Nd(ht,lt(Rr))}function St(Rr){return V=e,we&&x?De(Rr):(x=I=e,W)}function Ai(){V!==e&&fF(V),ue=0,x=J=I=V=e}function Hn(){return V===e?W:St(Gv())}function Ii(){var Rr=Gv(),Ns=Ke(Rr);if(x=arguments,I=this,J=Rr,Ns){if(V===e)return Ge(J);if(de)return fF(V),V=Nd(ht,p),De(J)}return V===e&&(V=Nd(ht,p)),W}return Ii.cancel=Ai,Ii.flush=Hn,Ii}var BCe=ft(function(c,p){return W2(c,1,p)}),UCe=ft(function(c,p,y){return W2(c,Qi(p)||0,y)});function $Ce(c){return Uo(c,U)}function Kv(c,p){if(typeof c!="function"||p!=null&&typeof p!="function")throw new Ki(i);var y=function(){var x=arguments,I=p?p.apply(this,x):x[0],L=y.cache;if(L.has(I))return L.get(I);var W=c.apply(this,x);return y.cache=L.set(I,W)||L,W};return y.cache=new(Kv.Cache||jo),y}Kv.Cache=jo;function Xv(c){if(typeof c!="function")throw new Ki(i);return function(){var p=arguments;switch(p.length){case 0:return!c.call(this);case 1:return!c.call(this,p[0]);case 2:return!c.call(this,p[0],p[1]);case 3:return!c.call(this,p[0],p[1],p[2])}return!c.apply(this,p)}}function HCe(c){return ZF(2,c)}var WCe=OEe(function(c,p){p=p.length==1&&ot(p[0])?sr(p[0],Ei(We())):sr(pn(p,1),Ei(We()));var y=p.length;return ft(function(x){for(var I=-1,L=In(x.length,y);++I<L;)x[I]=p[I].call(this,x[I]);return Si(c,this,x)})}),hE=ft(function(c,p){var y=La(p,Bl(hE));return Uo(c,T,e,p,y)}),rM=ft(function(c,p){var y=La(p,Bl(rM));return Uo(c,w,e,p,y)}),zCe=$o(function(c,p){return Uo(c,N,e,e,e,p)});function VCe(c,p){if(typeof c!="function")throw new Ki(i);return p=p===e?p:ct(p),ft(c,p)}function GCe(c,p){if(typeof c!="function")throw new Ki(i);return p=p==null?0:Vr(ct(p),0),ft(function(y){var x=y[p],I=$a(y,0,p);return x&&Da(I,x),Si(c,this,I)})}function KCe(c,p,y){var x=!0,I=!0;if(typeof c!="function")throw new Ki(i);return vr(y)&&(x="leading"in y?!!y.leading:x,I="trailing"in y?!!y.trailing:I),tM(c,p,{leading:x,maxWait:p,trailing:I})}function XCe(c){return YF(c,1)}function YCe(c,p){return hE(JS(p),c)}function ZCe(){if(!arguments.length)return[];var c=arguments[0];return ot(c)?c:[c]}function JCe(c){return Yi(c,d)}function QCe(c,p){return p=typeof p=="function"?p:e,Yi(c,d,p)}function e1e(c){return Yi(c,l|d)}function t1e(c,p){return p=typeof p=="function"?p:e,Yi(c,l|d,p)}function r1e(c,p){return p==null||H2(c,p,rn(p))}function Is(c,p){return c===p||c!==c&&p!==p}var n1e=Uv(BS),i1e=Uv(function(c,p){return c>=p}),Qu=X2(function(){return arguments}())?X2:function(c){return Sr(c)&&Ft.call(c,"callee")&&!D2.call(c,"callee")},ot=ne.isArray,s1e=g2?Ei(g2):dEe;function ri(c){return c!=null&&Yv(c.length)&&!Wo(c)}function Or(c){return Sr(c)&&ri(c)}function o1e(c){return c===!0||c===!1||Sr(c)&&Un(c)==Ie}var Ha=xSe||TE,a1e=v2?Ei(v2):hEe;function u1e(c){return Sr(c)&&c.nodeType===1&&!Od(c)}function c1e(c){if(c==null)return!0;if(ri(c)&&(ot(c)||typeof c=="string"||typeof c.splice=="function"||Ha(c)||Ul(c)||Qu(c)))return!c.length;var p=Nn(c);if(p==te||p==Re)return!c.size;if(Id(c))return!HS(c).length;for(var y in c)if(Ft.call(c,y))return!1;return!0}function l1e(c,p){return Td(c,p)}function f1e(c,p,y){y=typeof y=="function"?y:e;var x=y?y(c,p):e;return x===e?Td(c,p,e,y):!!x}function mE(c){if(!Sr(c))return!1;var p=Un(c);return p==ge||p==st||typeof c.message=="string"&&typeof c.name=="string"&&!Od(c)}function p1e(c){return typeof c=="number"&&F2(c)}function Wo(c){if(!vr(c))return!1;var p=Un(c);return p==D||p==A||p==it||p==gr}function nM(c){return typeof c=="number"&&c==ct(c)}function Yv(c){return typeof c=="number"&&c>-1&&c%1==0&&c<=B}function vr(c){var p=typeof c;return c!=null&&(p=="object"||p=="function")}function Sr(c){return c!=null&&typeof c=="object"}var iM=y2?Ei(y2):gEe;function d1e(c,p){return c===p||$S(c,p,sE(p))}function h1e(c,p,y){return y=typeof y=="function"?y:e,$S(c,p,sE(p),y)}function m1e(c){return sM(c)&&c!=+c}function g1e(c){if(QEe(c))throw new Qe(n);return Y2(c)}function v1e(c){return c===null}function y1e(c){return c==null}function sM(c){return typeof c=="number"||Sr(c)&&Un(c)==X}function Od(c){if(!Sr(c)||Un(c)!=He)return!1;var p=Sv(c);if(p===null)return!0;var y=Ft.call(p,"constructor")&&p.constructor;return typeof y=="function"&&y instanceof y&&_v.call(y)==hSe}var gE=_2?Ei(_2):vEe;function _1e(c){return nM(c)&&c>=-B&&c<=B}var oM=x2?Ei(x2):yEe;function Zv(c){return typeof c=="string"||!ot(c)&&Sr(c)&&Un(c)==Xt}function Ci(c){return typeof c=="symbol"||Sr(c)&&Un(c)==fn}var Ul=b2?Ei(b2):_Ee;function x1e(c){return c===e}function b1e(c){return Sr(c)&&Nn(c)==Js}function w1e(c){return Sr(c)&&Un(c)==$u}var S1e=Uv(WS),E1e=Uv(function(c,p){return c<=p});function aM(c){if(!c)return[];if(ri(c))return Zv(c)?Cs(c):ti(c);if(vd&&c[vd])return rSe(c[vd]());var p=Nn(c),y=p==te?RS:p==Re?gv:$l;return y(c)}function zo(c){if(!c)return c===0?c:0;if(c=Qi(c),c===j||c===-j){var p=c<0?-1:1;return p*ee}return c===c?c:0}function ct(c){var p=zo(c),y=p%1;return p===p?y?p-y:p:0}function uM(c){return c?Xu(ct(c),0,se):0}function Qi(c){if(typeof c=="number")return c;if(Ci(c))return Y;if(vr(c)){var p=typeof c.valueOf=="function"?c.valueOf():c;c=vr(p)?p+"":p}if(typeof c!="string")return c===0?c:+c;c=A2(c);var y=s0e.test(c);return y||a0e.test(c)?j0e(c.slice(2),y?2:8):i0e.test(c)?Y:+c}function cM(c){return to(c,ni(c))}function T1e(c){return c?Xu(ct(c),-B,B):c===0?c:0}function kt(c){return c==null?"":Ti(c)}var C1e=Ml(function(c,p){if(Id(p)||ri(p)){to(p,rn(p),c);return}for(var y in p)Ft.call(p,y)&&wd(c,y,p[y])}),lM=Ml(function(c,p){to(p,ni(p),c)}),Jv=Ml(function(c,p,y,x){to(p,ni(p),c,x)}),A1e=Ml(function(c,p,y,x){to(p,rn(p),c,x)}),I1e=$o(FS);function N1e(c,p){var y=Fl(c);return p==null?y:$2(y,p)}var O1e=ft(function(c,p){c=Yt(c);var y=-1,x=p.length,I=x>2?p[2]:e;for(I&&$n(p[0],p[1],I)&&(x=1);++y<x;)for(var L=p[y],W=ni(L),V=-1,J=W.length;++V<J;){var ue=W[V],le=c[ue];(le===e||Is(le,ql[ue])&&!Ft.call(c,ue))&&(c[ue]=L[ue])}return c}),R1e=ft(function(c){return c.push(e,AF),Si(fM,e,c)});function k1e(c,p){return S2(c,We(p,3),eo)}function P1e(c,p){return S2(c,We(p,3),jS)}function q1e(c,p){return c==null?c:MS(c,We(p,3),ni)}function D1e(c,p){return c==null?c:G2(c,We(p,3),ni)}function L1e(c,p){return c&&eo(c,We(p,3))}function F1e(c,p){return c&&jS(c,We(p,3))}function M1e(c){return c==null?[]:Pv(c,rn(c))}function j1e(c){return c==null?[]:Pv(c,ni(c))}function vE(c,p,y){var x=c==null?e:Yu(c,p);return x===e?y:x}function B1e(c,p){return c!=null&&OF(c,p,cEe)}function yE(c,p){return c!=null&&OF(c,p,lEe)}var U1e=wF(function(c,p,y){p!=null&&typeof p.toString!="function"&&(p=xv.call(p)),c[p]=y},xE(ii)),$1e=wF(function(c,p,y){p!=null&&typeof p.toString!="function"&&(p=xv.call(p)),Ft.call(c,p)?c[p].push(y):c[p]=[y]},We),H1e=ft(Ed);function rn(c){return ri(c)?B2(c):HS(c)}function ni(c){return ri(c)?B2(c,!0):xEe(c)}function W1e(c,p){var y={};return p=We(p,3),eo(c,function(x,I,L){Bo(y,p(x,I,L),x)}),y}function z1e(c,p){var y={};return p=We(p,3),eo(c,function(x,I,L){Bo(y,I,p(x,I,L))}),y}var V1e=Ml(function(c,p,y){qv(c,p,y)}),fM=Ml(function(c,p,y,x){qv(c,p,y,x)}),G1e=$o(function(c,p){var y={};if(c==null)return y;var x=!1;p=sr(p,function(L){return L=Ua(L,c),x||(x=L.length>1),L}),to(c,nE(c),y),x&&(y=Yi(y,l|f|d,UEe));for(var I=p.length;I--;)XS(y,p[I]);return y});function K1e(c,p){return pM(c,Xv(We(p)))}var X1e=$o(function(c,p){return c==null?{}:wEe(c,p)});function pM(c,p){if(c==null)return{};var y=sr(nE(c),function(x){return[x]});return p=We(p),nF(c,y,function(x,I){return p(x,I[0])})}function Y1e(c,p,y){p=Ua(p,c);var x=-1,I=p.length;for(I||(I=1,c=e);++x<I;){var L=c==null?e:c[ro(p[x])];L===e&&(x=I,L=y),c=Wo(L)?L.call(c):L}return c}function Z1e(c,p,y){return c==null?c:Cd(c,p,y)}function J1e(c,p,y,x){return x=typeof x=="function"?x:e,c==null?c:Cd(c,p,y,x)}var dM=TF(rn),hM=TF(ni);function Q1e(c,p,y){var x=ot(c),I=x||Ha(c)||Ul(c);if(p=We(p,4),y==null){var L=c&&c.constructor;I?y=x?new L:[]:vr(c)?y=Wo(L)?Fl(Sv(c)):{}:y={}}return(I?Gi:eo)(c,function(W,V,J){return p(y,W,V,J)}),y}function eAe(c,p){return c==null?!0:XS(c,p)}function tAe(c,p,y){return c==null?c:uF(c,p,JS(y))}function rAe(c,p,y,x){return x=typeof x=="function"?x:e,c==null?c:uF(c,p,JS(y),x)}function $l(c){return c==null?[]:OS(c,rn(c))}function nAe(c){return c==null?[]:OS(c,ni(c))}function iAe(c,p,y){return y===e&&(y=p,p=e),y!==e&&(y=Qi(y),y=y===y?y:0),p!==e&&(p=Qi(p),p=p===p?p:0),Xu(Qi(c),p,y)}function sAe(c,p,y){return p=zo(p),y===e?(y=p,p=0):y=zo(y),c=Qi(c),fEe(c,p,y)}function oAe(c,p,y){if(y&&typeof y!="boolean"&&$n(c,p,y)&&(p=y=e),y===e&&(typeof p=="boolean"?(y=p,p=e):typeof c=="boolean"&&(y=c,c=e)),c===e&&p===e?(c=0,p=1):(c=zo(c),p===e?(p=c,c=0):p=zo(p)),c>p){var x=c;c=p,p=x}if(y||c%1||p%1){var I=M2();return In(c+I*(p-c+M0e("1e-"+((I+"").length-1))),p)}return VS(c,p)}var aAe=jl(function(c,p,y){return p=p.toLowerCase(),c+(y?mM(p):p)});function mM(c){return _E(kt(c).toLowerCase())}function gM(c){return c=kt(c),c&&c.replace(c0e,Z0e).replace(I0e,"")}function uAe(c,p,y){c=kt(c),p=Ti(p);var x=c.length;y=y===e?x:Xu(ct(y),0,x);var I=y;return y-=p.length,y>=0&&c.slice(y,I)==p}function cAe(c){return c=kt(c),c&&av.test(c)?c.replace(Il,J0e):c}function lAe(c){return c=kt(c),c&&Nl.test(c)?c.replace(Hu,"\\$&"):c}var fAe=jl(function(c,p,y){return c+(y?"-":"")+p.toLowerCase()}),pAe=jl(function(c,p,y){return c+(y?" ":"")+p.toLowerCase()}),dAe=_F("toLowerCase");function hAe(c,p,y){c=kt(c),p=ct(p);var x=p?Pl(c):0;if(!p||x>=p)return c;var I=(p-x)/2;return Bv(Av(I),y)+c+Bv(Cv(I),y)}function mAe(c,p,y){c=kt(c),p=ct(p);var x=p?Pl(c):0;return p&&x<p?c+Bv(p-x,y):c}function gAe(c,p,y){c=kt(c),p=ct(p);var x=p?Pl(c):0;return p&&x<p?Bv(p-x,y)+c:c}function vAe(c,p,y){return y||p==null?p=0:p&&(p=+p),ESe(kt(c).replace(Wu,""),p||0)}function yAe(c,p,y){return(y?$n(c,p,y):p===e)?p=1:p=ct(p),GS(kt(c),p)}function _Ae(){var c=arguments,p=kt(c[0]);return c.length<3?p:p.replace(c[1],c[2])}var xAe=jl(function(c,p,y){return c+(y?"_":"")+p.toLowerCase()});function bAe(c,p,y){return y&&typeof y!="number"&&$n(c,p,y)&&(p=y=e),y=y===e?se:y>>>0,y?(c=kt(c),c&&(typeof p=="string"||p!=null&&!gE(p))&&(p=Ti(p),!p&&kl(c))?$a(Cs(c),0,y):c.split(p,y)):[]}var wAe=jl(function(c,p,y){return c+(y?" ":"")+_E(p)});function SAe(c,p,y){return c=kt(c),y=y==null?0:Xu(ct(y),0,c.length),p=Ti(p),c.slice(y,y+p.length)==p}function EAe(c,p,y){var x=R.templateSettings;y&&$n(c,p,y)&&(p=e),c=kt(c),p=Jv({},p,x,CF);var I=Jv({},p.imports,x.imports,CF),L=rn(I),W=OS(I,L),V,J,ue=0,le=p.interpolate||fv,de="__p += '",we=kS((p.escape||fv).source+"|"+le.source+"|"+(le===dd?n0e:fv).source+"|"+(p.evaluate||fv).source+"|$","g"),De="//# sourceURL="+(Ft.call(p,"sourceURL")?(p.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++P0e+"]")+`
|
|
145
145
|
`;c.replace(we,function(Ke,ht,St,Ai,Hn,Ii){return St||(St=Ai),de+=c.slice(ue,Ii).replace(l0e,Q0e),ht&&(V=!0,de+=`' +
|
|
@@ -277,7 +277,7 @@ your project to use the Ampt SDK.
|
|
|
277
277
|
${r("Discord:")} https://getampt.com/discord
|
|
278
278
|
`;e.isShellActive&&(n=n.replaceAll("ampt ","")),e.log(n)}});var y1t,xwe=oe(()=>{"use strict";An();y1t=async e=>{e.viewSpinner("Loading");let t=e.args[0],{fs:r,user:n}=e;if(await r.read(),!r.serviceFile)throw new Error("You must be inside an Ampt app directory to run this command.");let i=e.options.overwrite||e.options.o||!1,s=e.options.app||r.serviceFile.ampt.app,o=e.options.org||r.serviceFile.ampt.org,a=e.options.stage||e.options.instance||n.username;o||(o=await e.selectOrg(n)),e.viewSpinner("Loading");let u=new Kt({orgName:o});await u.isAuthorized()||(e.logError(`You don't have access to the "${o}" org.`),o=await e.selectOrg(n)),u.update({orgName:o}),e.viewSpinner("Importing");let l=new Dt({org:u,serviceName:s}),f=new tr({org:u,service:l,instanceName:a}),d=new Fu({fs:r,org:u,service:l,instance:f});if(t&&!r.fileExists(t)){e.logError(`File "${t}" not found.`);return}await d.import({dataFileName:t,overwrite:i});let h=`Data imported from "${t||r.dataFileName}"`;e.logSuccess(h)}});var _1t,bwe=oe(()=>{"use strict";_1t=async e=>{var n;let t=e.fs;if(await t.read(),!t.serviceFile)throw new Error("You must be inside an Ampt app directory to run this command.");let r=t.servicePackageManager;e.args.length===0?e.viewSpinner(`[${r}] Installing dependencies`):e.args.length===1?e.viewSpinner(`[${r}] Installing ${e.args[0]}`):e.args.length>1&&e.viewSpinner(`[${r}] Installing ${String(e.args.length)} packages`);try{let i=e.args.length===0,s=e.argv.includes("--dev");s&&(e.argv=e.argv.filter(o=>o!=="--dev")),i?await t.installDependenciesIfExists({cleanInstall:!1}):await t.installDependency(e.argv.slice(1),s),e.args.length===0?e.logSuccess("Successfully installed dependencies."):e.args.length===1?e.logSuccess(`Successfully installed the ${(n=e.styles)==null?void 0:n.bold(e.args[0])} package.`):e.args.length>1&&e.logSuccess(`Successfully installed ${String(e.args.length)} packages.`)}catch(i){e.session.captureException(i);let s=i.stdBuffer.toString();throw new Error(`Failed to install due to the following error:
|
|
279
279
|
${s}`)}}});var x1t,wwe=oe(()=>{"use strict";An();x1t=async e=>{if(e.user&&e.user.isLoggedIn())return e.logInfo(`Already logged in as ${e.styles.bold(e.user.username)}.`);e.user||(e.user=await Fo.init()),await e.user.performLogin(e)}});var b1t,Swe=oe(()=>{"use strict";b1t=async e=>{e.viewSpinner("Logging out"),e.user&&e.user.isLoggedIn()?(e.user.logout(),e.logSuccess("Successfully logged out of Ampt CLI."),await e.quit()):e.logInfo("You are already logged out of Ampt CLI.")}});var w1t,Ewe=oe(()=>{"use strict";An();w1t=async e=>{e.viewSpinner("Loading");let t=e.fs;if(await t.read(),!t.serviceFile)throw new Error("You must be inside an Ampt app directory to run this command.");e.viewSpinner("Opening Dashboard");let{user:r}=e,n=t.serviceFile.ampt.org,i=t.serviceFile.ampt.app;n||(n=await e.selectOrg(r)),e.viewSpinner("Loading");let s=new Kt({orgName:n});await s.isAuthorized()||(e.logError(`You don't have access to the "${n}" org.`),n=await e.selectOrg(r)),s.update({orgName:n});let o=new Dt({org:s,serviceName:i});e.logInfo("Your browser should open automatically"),e.logInfo("If not, open the following app page url:");let a=o.getDashboardUrl();e.logUrl(a),e.openUrl(a)}});var S1t,Twe=oe(()=>{"use strict";An();S1t=async e=>{var w,E;e.viewSpinner("Loading");let t=e.fs;if(await t.read(),!t.serviceFile)throw new Error("You must be inside an Ampt app directory to run this command.");let{user:r}=e,n=e.options.app||t.serviceFile.ampt.app,i=e.options.org||t.serviceFile.ampt.org;i||(i=await e.selectOrg(r)),e.viewSpinner("Loading");let s=new Kt({orgName:i});await s.isAuthorized()||(e.logError(`You don't have access to the "${i}" org.`),i=await e.selectOrg(r)),s.update({orgName:i});let o=new Dt({org:s,serviceName:n}),a=await o.listInstances(),u=(w=e.args)==null?void 0:w[0],l=(E=e.args)==null?void 0:E[1];if(!u){if(!e.isInteractive)throw new Error('Please specify a source stage name: "ampt promote dev"');e.logInfo("Please enter the name of the stage you want to promote."),u=await e.prompt("type a stage name")}if(!l){if(!e.isInteractive)throw new Error('Please specify a target stage name: "ampt promote dev prod"');e.logInfo("Please enter the name of the stage you want to promote to."),l=await e.prompt("type a stage name")}if(u===l)throw new Error("The stage names you specified are identical. Please specify two different stages.");let f=a.find(N=>N.instanceName===u);if(!f)throw new Error(`The specified source instance does not exist: ${u}.`);let d=a.find(N=>N.instanceName===l);if(f&&f.instanceType!=="stage"||d&&d.instanceType!=="stage")throw new Error('One of the instances you specified are not of type "stage". You can only promote between stage environments.');let h=new tr({org:s,service:o,instanceName:l}),m=await o.get();if(!m)return e.logWarning(`Unexpected error: App ${n} was not found.`);let[g,_]=await Promise.all([s.fetch(),s.getRegions()]),S=await e.selectRegion({orgInfo:g,instanceInfo:d,serviceInfo:m,regions:_});if(!S)return e.logWarning("Promote cancelled.");e.viewSpinner(`Promoting ${u} to ${l} (${S.name})`),e.updateSpinnerStep("syncing");let{operationId:b}=await o.copy({sourceInstanceName:u,targetInstanceName:l,copyCode:!0,copyData:!1,copyStorage:!1,instanceType:"stage",region:S.code}),{success:C,message:T}=await e.messenger.waitForOperation({operationId:b,context:e,orgName:i,appName:n});if(T&&(C?e.logInfo(T):e.logError(T)),!C){e.logError("Promote command failed");return}await h.get(),e.logSuccess(`Successfully promoted from the "${u}" stage to the "${l} (${S.name})" stage.`),e.logUrl(h.url)}});var Cwe,Awe,Iwe,Nwe,E1t,T1t,Owe=oe(()=>{"use strict";An();ur();Cwe=ve(require("path")),Awe=ve(require("os")),Iwe=ve(mc()),Nwe=ve(require("assert")),E1t=(e,t)=>Cwe.default.join(Awe.default.homedir(),".serverless",`cloud_shell_activity_${e}_${t}.json`),T1t=async e=>{var b,C,T,w;e.viewSpinner("Running");let t,r=e.options.login,n=e.user;if(!n)throw new Error("User not found");r&&(delete e.options.login,t=await n.restoreOrgLogin(r),e.logSuccess("Successfully logged in."));let i=e.fs;if(await i.read(),!i.serviceFile)throw new Error("You must be inside an Ampt app directory to run this command.");t=t||e.options.org||((C=(b=i.serviceFile)==null?void 0:b.ampt)==null?void 0:C.org);let s=e.options.app||((w=(T=i.serviceFile)==null?void 0:T.ampt)==null?void 0:w.app),o=e.args[0];if(o||(e.logInfo("Please specify a script name available in package.json that is prefixed with ampt:{name}, or a path to any TS or JS file."),o=await e.prompt("type a script name")),!e.isInteractive&&o==="dev")throw new Error("dev command not available in non-interactive mode.");t||(cr({eventName:"ampt.dev.prompt",eventData:{promptName:"org"}}),t=await e.selectOrg(n),await i.writeServiceFile({orgName:t})),(0,Nwe.default)(t,"orgName is required");let a=new Kt({orgName:t});await a.isAuthorized()||(cr({eventName:"ampt.dev.prompt",eventData:{promptName:"org"}}),e.logError(`You don't have access to the "${t}" org.`),t=await e.selectOrg(n)),a.update({orgName:t}),s||(cr({eventName:"ampt.dev.prompt",eventData:{promptName:"service"}}),s=await e.promptServiceName(i.defaults.app),await i.writeServiceFile({serviceName:s}));let u=e.options["test-env"]||e.options["test-stage"],l=u?`test-${Math.random().toString(36).substring(2,7)}`:e.options.env||e.options.stage||e.options.instance||n.username,f=new Dt({org:a,serviceName:s}),d=new tr({org:a,service:f,instanceName:l,instanceType:"test"});if(u)e.viewSpinner(`Starting test stage (${l})`);else if(!await d.get()){e.logError(`Stage "${l}" does not exist. Try running "deploy ${l}" first.`);return}let h=new Bi({org:a,service:f,instance:d,sandboxMode:!0,cli:e});await h.getUrlsAndMap();let{url:m,region:g}=d,{env:_}=h;e.onQuit(async()=>{(0,Iwe.removeSync)(E1t(t,s)),await Qn.stop(e,{hasQuit:!0,orgName:t,serviceName:s})}),e.viewSpinner(`Running ${o}`);let S=await Qn.start({env:_,region:g,url:m,cli:e,user:n,fs:i,scriptName:o,ifPresent:!1,orgName:t,serviceName:s});return e.setExitCode(S),null}});async function C1t(e){var f,d,h,m;Se.trace("refreshing sandbox credentials");let t=await owe.init();if(!t.isLoggedIn())throw new Error("You must be logged in");let r=e.fs;await r.read();let n=process.env.AMPT_ORG_NAME||((d=(f=r.serviceFile)==null?void 0:f.ampt)==null?void 0:d.org),i=process.env.AMPT_APP_NAME||process.env.AMPT_SERVICE_NAME||((m=(h=r.serviceFile)==null?void 0:h.ampt)==null?void 0:m.app);if(!n)throw new Error("orgName is required");if(!i)throw new Error("serviceName is required");let s=new rwe({orgName:n});if(!await s.isAuthorized())throw new Error("Not authorized to access this org");let o=new iS({org:s,serviceName:i}),a=process.env.AMPT_ENVIRONMENT_NAME||process.env.AMPT_INSTANCE_NAME||t.username,u=new afe({org:s,service:o,instanceName:a});await u.get();let l=new nue({org:s,service:o,instance:u,sandboxMode:!0,cli:e});if(await l.getUrlsAndMap(),!l.credentials)throw new Error("No credentials");Se.trace({expiration:l.credentials.expiration},"refreshed sandbox credentials"),console.log(JSON.stringify({Version:1,AccessKeyId:l.credentials.accessKeyId,SecretAccessKey:l.credentials.secretAccessKey,SessionToken:l.credentials.sessionToken,Expiration:l.credentials.expiration}))}var Rwe=oe(()=>{"use strict";vq();LL();kL();_D();sS();_p()});var pS,kwe,Pwe,A1t,qwe=oe(()=>{"use strict";pS=ve(require("fs")),kwe=ve(require("path")),Pwe=require("child_process"),A1t=async e=>{e.pause();let t={js(){throw new Error("Not implemented")},ts(){throw new Error("Not implemented")},json(){throw new Error("Not implemented")},yml(r){return new Promise(n=>{var a,u;let i=pS.default.readFileSync(r);pS.default.writeFileSync("ampt.serverless.yml",i);let s=process.argv.slice(3),o=(0,Pwe.spawn)("npx",["serverless","-c","ampt.serverless.yml"].concat(s),{env:{},stdio:"inherit",detached:!0});e.onQuit(()=>{o.kill(),n()}),(a=o.stdout)==null||a.pipe(process.stdout),(u=o.stderr)==null||u.pipe(process.stderr),o.on("exit",()=>{n()})})},yaml(r){return this.yml(r)}};for(let r of Object.keys(t)){let n=kwe.default.join(process.cwd(),`serverless.${r}`);if(pS.default.existsSync(n)){await t[r](n);return}}}});var I1t,Dwe=oe(()=>{"use strict";An();I1t=async e=>{var k;e.viewSpinner("Loading");let t=e.fs;if(await t.read(),!t.serviceFile)throw new Error("You must be inside an Ampt app directory to run this command.");let{user:r}=e,n=e.options.overwrite,i=r.username,s=((k=e.args)==null?void 0:k[0])||`${i}-${Math.random().toString(36).substr(2,5)}`,o=e.options.app||t.serviceFile.ampt.app,a=e.options.org||t.serviceFile.ampt.org;a||(a=await e.selectOrg(r)),e.viewSpinner("Loading");let u=new Kt({orgName:a}),[l,f]=await Promise.all([u.isAuthorized(),u.getPlan()]);if(l||(e.logError(`You don't have access to the "${a}" org.`),a=await e.selectOrg(r)),f&&!f.previewsEnabled){e.logWarning("Preview environments are not available on your current plan."),e.logInfo(`You can enable preview environments by upgrading to the ${e.styles.bold(e.styles.darkPurple("Team"))} plan.`),e.logUrl(`https://ampt.dev/orgs/${u.orgName}/settings/billing`);return}u.update({orgName:a});let d=new Dt({org:u,serviceName:o}),m=(await d.listInstances()).find(q=>q.instanceName===s);if(m&&m.instanceType!=="preview")throw new Error(`You cannot overwrite an existing ${m.instanceType} environment.`);if(m&&!n&&(e.logInfo("This preview environment already exists. Are you sure you want to overwrite it?"),n=await e.confirm(),!n))if(e.isShellActive){await e.logCancelled();return}else await e.quit();let g=r.username,_=new tr({org:u,service:d,instanceName:g}),[S,b,C,T]=await Promise.all([d.get().catch(()=>({serviceName:o})),u.fetch(),m?_.get().catch(()=>{}):void 0,u.getRegions()]),w=await e.selectRegion({orgInfo:b,instanceInfo:C,serviceInfo:S,regions:T});if(!w)return e.logWarning("Deployment cancelled.");let E=new Bi({org:u,service:d,instance:_,fullSync:e.options["full-sync"],cli:e}),N=e.styles.bold(e.styles.blue(s)),U=e.styles.dim(`(${w.name})`),M=n?`Overwriting existing preview environment ${N} ${U}`:`Creating new preview environment ${N} ${U}`;e.viewSpinner(M,{timer:!0}),e.updateSpinnerStep("syncing"),await E.sync();let F=new tr({org:u,service:d,instanceName:s});if(i!==s){let{operationId:q}=await d.copy({sourceInstanceName:i,targetInstanceName:s,copyCode:!0,copyData:!0,copyStorage:!0,instanceType:"preview",region:w.code}),{success:O,message:H}=await e.messenger.waitForOperation({operationId:q,context:e,orgName:a,appName:o});if(H&&(O?e.logInfo(H):e.logError(H)),!O){e.logError("Share command failed"),e.setExitCode(1);return}}await F.get(),e.logSuccess(`Successfully created preview environment ${e.styles.bold(s)} (${w.name}).`),e.logUrl(F.url)}});var N1t,Lwe=oe(()=>{"use strict";N1t=async e=>{await e.startSession()}});var O1t,Fwe=oe(()=>{"use strict";An();O1t=async e=>{e.viewSpinner("Loading");let t=e.fs;if(await t.read(),!t.serviceFile||!t.serviceFile.ampt||!t.serviceFile.ampt.app||!t.serviceFile.ampt.org){e.logInfo("This command must be run inside a service directory.");return}let{org:r,app:n}=t.serviceFile.ampt;if(!await Qn.isRunning({orgName:r,serviceName:n})){e.logInfo(`There's no dev server running for app "${n}" in org "${r}" at the moment.`);return}await Qn.stop(e,{orgName:r,serviceName:n}),e.logSuccess(`Successfully stopped the dev server for app "${n}" in org "${r}".`)}});var R1t,Mwe=oe(()=>{"use strict";ur();An();os();R1t=async e=>{e.viewSpinner("Loading");let t=new Fo,r=e.fs;if(await r.read(),!r.serviceFile)throw new Error("You must be inside an Ampt app directory to run this command.");let n=e.options.org||r.serviceFile.ampt.org,i=e.options.service||r.serviceFile.ampt.app||r.serviceFile.ampt.service,s=e.isShellActive?e.user.username:`test-${Math.random().toString(36).substring(2,7)}`;n||(n=await e.selectOrg(t)),e.viewSpinner("Loading");let o=new Kt({orgName:n});await o.isAuthorized()||(e.logError(`You don't have access to the "${n}" org.`),n=await e.selectOrg(t)),o.update({orgName:n}),e.isShellActive||e.viewSpinner(`Starting test stage (${s})`);let a=new Dt({org:o,serviceName:i}),u=new tr({org:o,service:a,instanceType:"test",instanceName:s,cli:e});e.isShellActive||(await new Bi({org:o,service:a,instance:u,fullSync:e.options["full-sync"],cli:e}).sync(),e.logSuccess(`Test instance started: ${u.url}`)),await u.get();let l=await u.connect({cli:e});try{e.viewSpinner("Running tests");let f=e.options.coverage||e.options.collectCoverage,d=e.args[0],h=e.options.workers,{timeout:m=3e5}=await u.test({coverage:f,pattern:d,workers:h}),g=await(l==null?void 0:l.waitForEvent({eventType:"ampt.test.completed",timeout:m+5e3}));pV(e,g),g.data.coverage&&g.data.coverage.length&&f&&(e.viewSpinner("Collecting test coverage report"),await u.downloadTestCoverage(r.serviceRoot),e.logSuccess("Coverage report saved")),process.exitCode=g.data.results&&g.data.results.success?0:1}catch(f){e.logError(f)}e.isShellActive||(l==null||l.close(),e.viewSpinner("Deleting instance"),await u.delete(),e.logSuccess("Test instance deleted"),e.log(`Exiting with status code ${process.exitCode}`))}});var k1t,jwe=oe(()=>{"use strict";k1t=async e=>{var n;let t=e.fs;if(await t.read(),!t.serviceFile)throw new Error("You must be inside an Ampt app directory to run this command.");if(e.args.length===0){e.logInfo("Please enter the name of the npm package you want to uninstall.");let i=await e.prompt("type a package name");e.args.push(i)}let r=t.servicePackageManager;e.args.length===1?e.viewSpinner(`[${r}] Uninstalling ${e.args[0]}`):e.args.length>1&&e.viewSpinner(`[${r}] Uninstalling ${String(e.args.length)} packages`);try{let i=e.argv.includes("--dev");i&&(e.argv=e.argv.filter(s=>s!=="--dev")),await t.removeDependency(e.argv.slice(1),i),e.args.length===1?e.logSuccess(`Successfully uninstalled the ${(n=e.styles)==null?void 0:n.bold(e.args[0])} package.`):e.args.length>1&&e.logSuccess(`Successfully uninstalled ${String(e.args.length)} packages.`)}catch(i){e.session.captureException(i);let s=i.stdBuffer.toString();throw new Error(`Failed to uninstall due to the following error:
|
|
280
|
-
${s}`)}}});var P1t,Bwe=oe(()=>{"use strict";An();P1t=async e=>{e.viewSpinner("Loading");let t=e.fs;if(await t.read(),!t.serviceFile)throw new Error("You must be inside an Ampt app directory to run this command.");let{user:r}=e,n=e.options.org||t.serviceFile.ampt.org,i=e.options.app||t.serviceFile.ampt.app,s=e.args[0]||r.username;n||(n=await e.selectOrg(r)),e.viewSpinner("Loading");let o=new Kt({orgName:n});await o.isAuthorized()||(e.logError(`You don't have access to the "${n}" org.`),n=await e.selectOrg(r)),o.update({orgName:n}),e.viewSpinner("Loading");let a=new Dt({org:o,serviceName:i}),u=new tr({org:o,service:a,instanceName:s});await u.get(),e.logUrl(u.url)}});var Uwe,q1t,$we=oe(()=>{"use strict";Uwe=ve(wm()),q1t=async e=>{e.log(`v${Uwe.version}`)}});var UL={};ec(UL,{bash:()=>l1t,clone:()=>f1t,dashboard:()=>p1t,delete:()=>d1t,deploy:()=>h1t,docs:()=>m1t,export:()=>g1t,help:()=>v1t,import:()=>y1t,install:()=>_1t,login:()=>x1t,logout:()=>b1t,open:()=>w1t,promote:()=>S1t,run:()=>T1t,sandbox:()=>C1t,serverless:()=>A1t,setup:()=>FL,share:()=>I1t,start:()=>N1t,stop:()=>O1t,test:()=>R1t,uninstall:()=>k1t,url:()=>P1t,version:()=>q1t});var $L=oe(()=>{"use strict";lwe();pwe();dwe();hwe();mwe();gwe();vwe();_we();xwe();bwe();wwe();Swe();Ewe();Twe();Owe();Rwe();qwe();ML();Dwe();Lwe();Fwe();Mwe();jwe();Bwe();$we()});var HL=ve(require("os")),ld=ve(Qv()),zwe=ve(SM()),Vwe=ve(EM()),Es=ve(NM()),Gwe=ve(HM()),Zs=ve(bj()),Kwe=ve(Ej()),Cl=ve(Cj()),Xwe=ve(Oj()),WL=ve(qj()),Ywe=ve(ZU()),zL=ve(n1()),VL=ve(s1()),GL=require("child_process"),KL=ve(I5()),Zwe=require("fs/promises"),fd=ve(mc()),mS=ve(V1());ur();Vk();An();Pp();An();ur();os();var uwe=ve(mc()),BL=ve(require("path")),uS=ve(require("assert"));An();os();ur();OR();ML();ur();wo();function jL(e){(async()=>{let{orgName:t,serviceName:r,instanceName:n}=e;try{await ze({method:"POST",body:e,endpoint:`/orgs/${t}/services/${r}/instances/${n}/metrics`})}catch(i){$t.captureException(i),process.env.AMPT_DEBUG&&console.error(i)}})()}var Uu=class extends Error{function=null;constructor(t,r){super(t),this.function=r}};var cS=class e{initialized=!1;cli;org;service;instance;data;code;isGitInstalled=!1;isCodeInstalled=!1;isSeedingEnabled=!1;isReseedingEnabled=!1;devModeStart=void 0;messenger;sandboxActive=!1;syncInProgress=!1;queuedFilePaths=new Set;constructor(t){this.cli=t}static async checkIfServiceExists(t){return!!await t.get().catch(()=>{})}async handleGitError(){return this.cli.logWarning(`"${this.cli.styles.bold("git")}" is not installed on this system.`),await this.cli.quit("Please install git and try again.")}async runSystemChecks(){let[t,r]=await Promise.all([this.cli.fs.detectGit(),this.cli.fs.detectVsCode()]);this.isGitInstalled=t,this.isCodeInstalled=r}getSandboxUrl(){if(this.instance)return this.instance.url}getDashboardUrl(){if(this.org&&this.service&&this.instance)return`${process.env.AMPT_DASHBOARD_URL_ROOT}/orgs/${this.org.orgName}/apps/${this.service.serviceName}/environments/${this.instance.instanceName}`}async boot(t){let r=new Set(t);r&&r.size>0?(r.has("analyze")&&await this.analyze(),r.has("detect")&&await this.detect(),r.has("connect")&&await this.connect(),r.has("dev")&&await this.dev()):(await this.analyze(),await this.detect(),await this.connect(),await this.dev())}async selectOrg(){var s,o,a;let t=this.cli,r=t.user;if(!r)return await this.cli.quit("You must be logged in to use this command.");if(await r.listOrgs(),((s=r.orgs)==null?void 0:s.length)===0)return await t.quit("You do not have access to any organizations.");let n=t.options.org;((o=r.orgs)==null?void 0:o.length)===1&&!n?n=r.orgs[0].orgName:((a=r.orgs)==null?void 0:a.length)>1&&!n&&(n=await t.selectOrg(r));let i=new Kt({orgName:n});i.update({orgName:n}),this.org=i}async authorize(){var n,i,s;let t=this.cli.user,r=this.cli.options.org||((i=(n=this.cli.fs.serviceFile)==null?void 0:n.ampt)==null?void 0:i.org);if(r&&!t.hasAccessToOrg(r)&&(this.cli.logWarning(`Org "${r}" has either been deleted, renamed, or you no longer have access to it.`),r=void 0),r?this.org=new Kt({orgName:r}):(cr({eventName:"ampt.dev.prompt",eventData:{promptName:"org"}}),await this.selectOrg(),await this.cli.fs.readServiceFileIfExists({orgName:r||((s=this.org)==null?void 0:s.orgName)})),!this.org)return await this.cli.quit("Ampt Organization is required");await this.org.isAuthorized()||(this.cli.logError(`You don't have access to the "${r}" org.`),await this.selectOrg()),this.cli._activeOrgName=this.org.orgName}async analyze(){this.cli.viewSpinner("Analyzing Project"),await FL(this.cli),await this.cli.checkForAmptPackageUpdates()}async hydrate(){if(!this.org){await this.cli.quit("Ampt Organization is required");return}if(!this.service){await this.cli.quit("Ampt App is required");return}if(!this.instance){await this.cli.quit("Ampt Environment is required");return}let[t,r,n,i]=await Promise.all([this.instance.get(),this.service.get(),this.org.fetch(),this.org.getRegions()]),s=this.cli.selectRegion({orgInfo:n,serviceInfo:r,instanceInfo:t,regions:i});if(!s){this.cli.logError("No region selected."),await this.cli.quit();return}this.instance.region=s.code}async detect(){var r,n,i;this.cli.viewSpinner("Starting");let t=this.cli.options.app||((n=(r=this.cli.fs.serviceFile)==null?void 0:r.ampt)==null?void 0:n.app);t||(cr({eventName:"ampt.dev.prompt",eventData:{promptName:"service"}}),t=await this.cli.promptServiceName(),this.cli.viewSpinner("Saving"),await this.cli.fs.writeServiceFile({serviceName:t})),this.cli._activeServiceName=t,this.service||(this.service=new Dt({org:this.org,serviceName:t})),this.instance||(this.instance=new tr({org:this.org,service:this.service,instanceName:(i=this.cli.user)==null?void 0:i.generateSandboxName()})),await this.hydrate()}async connect(){if((0,uS.default)(this.org,"Org is required"),(0,uS.default)(this.service,"Service is required"),(0,uS.default)(this.instance,"Instance is required"),!this.cli.user)return await this.cli.quit("You must be logged in");let t=this.org.orgName,r=this.service.serviceName;if(this.cli.viewSpinner("Connecting to your personal sandbox environment..."),this.devModeStart=process.hrtime.bigint(),await this.cli.isAmptShellRunning({orgName:t,serviceName:r}))return this.cli.logError(`The Ampt shell for app "${r}" in org "${t}" is already running in another terminal.`),await this.cli.quit();await this.cli.writeAmptShellActivityFile({orgName:t,serviceName:r}),this.cli.bindService({orgName:t,serviceName:r}),this.cli.onQuit(async()=>{var f;(0,uwe.removeSync)(Tp(t,r)),await Qn.stop(this.cli,{hasQuit:!0,orgName:t,serviceName:r});let u=await this.cli.fs.readJsonFileIfExists(this.cli.fs.serviceFilePath),l=process.hrtime.bigint();(f=this.messenger)==null||f.close(),cr({eventName:"ampt.dev.ended",eventData:{source:this.cli.isGitPod?"gitpod":"local",timeInSeconds:this.devModeStart?Number(l-this.devModeStart)/1e9:0,dependencies:Object.keys((u==null?void 0:u.dependencies)||{}),appName:`${t}:${r}`}})}),this.code=new Bi({org:this.org,service:this.service,instance:this.instance,user:this.cli.user,fullSync:this.cli.options["full-sync"],cli:this.cli,verbose:this.cli.options.verbose}),this.data=new Fu({fs:this.cli.fs,org:this.org,service:this.service,instance:this.instance}),this.cli.viewSpinner("Syncing");let i=this.cli.viewSpinner.bind(this.cli),s=u=>i(`Syncing (${u})`),o=await this.code.sync(void 0,s);this.cli.updateLastSyncedAt(Date.now()),jL({...o,source:this.cli.isGitPod?"gitpod":"local",orgName:t,serviceName:this.service.serviceName,instanceName:this.instance.instanceName,appName:`${t}:${r}`,region:this.instance.region}),this.cli.viewSpinner("Connecting to real time logs");let[a]=await Promise.all([this.instance.connect({cli:this.cli}),this.cli.messenger.subscribe({userUid:this.cli.user.userId,orgName:t,appName:r,instanceName:this.instance.instanceName})]);this.messenger=a}async dev(t){var _;let{logDashboard:r=!1}=t||{},n=this.org,i=this.service,s=this.instance,o=this.code,a=n.orgName,u=i.serviceName,l=s.instanceName,f=this.cli.styles.purple(`@${a}`),d=this.cli.styles.blue(u),h=this.cli.styles.green(l),m=this.cli.styles.dim("/"),g=`Connected to ${this.cli.styles.bold(`${f}${m}${d}${m}${h}`)}`;if(this.cli.logSuccess(g),this.cli.logUrl(s.url),r){this.cli.logSpace(),this.cli.logInfo("View your app in the dashboard");let S=`${process.env.AMPT_DASHBOARD_URL_ROOT}/orgs/${a}/apps/${u}/environments/${l}`;this.cli.logUrl(S)}if(this.isReseedingEnabled&&this.cli.logSuccess("Enabled automatic data reseeding"),this.cli.viewInput(),this.cli.options.dev){let{url:S,region:b}=s,{credentials:C,env:T}=o;Qn.start({credentials:C,env:T,url:S,cli:this.cli,fs:this.cli.fs,user:this.cli.user,scriptName:"dev",ifPresent:!1,orgName:a,serviceName:u,region:b}).catch(w=>{Se.error({err:w},"Error starting dev server"),this.cli.logError("Something went wrong starting the dev server.")})}cr({eventName:"ampt.dev.enabled",eventData:{dependencies:Object.keys(((_=this.cli.fs.serviceFile)==null?void 0:_.dependencies)||{}),appName:`${a}:${u}`}}),this.isSeedingEnabled&&await this.seed(),this.cli.fs.watch(o.workspaceRoot,this.onFileChange.bind(this)),this.sandboxActive=!0}async onFileChange(t){(async()=>{let r=this.org.orgName,n=this.service.serviceName,i=this.instance.instanceName;if(!this.code)return await this.cli.quit("Sync engine is not active");for(let l of t)this.queuedFilePaths.add(l);let s=this.queuedFilePaths,o=await Qn.isRunning({orgName:r,serviceName:n}),a=this.cli.buildRunningInShell;if(this.cli.isCommandRunningInShell&&!o&&(Se.trace("waiting for command to finish"),await this.cli.commandRunningInShellPromise,Se.trace("command finished")),this.syncInProgress){Se.trace("sync in progress, skipping");return}this.syncInProgress=!0;let u;if(a)await this.cli.commandRunningInShellPromise,u=await this.code.sync();else for(;this.queuedFilePaths.size>0;){let l=this.queuedFilePaths;this.queuedFilePaths=new Set,this.isReseedingEnabled&&this.cli.fs.dataFilePath&&l.has(this.cli.fs.dataFilePath)&&(this.cli.viewSpinner("Seeding",{timer:!0}),await this.seed()),(!this.cli.isCommandRunningInShell||o)&&this.cli.spinInput(),Se.trace({size:l.size,queued:this.queuedFilePaths.size},"starting sync"),u=await this.code.sync(l),Se.trace({size:l.size,queued:this.queuedFilePaths.size},"sync complete")}jL({...u,source:this.cli.isGitPod?"gitpod":"local",orgName:r,serviceName:n,instanceName:i,appName:`${r}:${n}`,region:this.instance.region}),this.syncInProgress=!1,this.cli.updateLastSyncedAt(Date.now()),this.cli.isAnimationEnabled||this.cli.logSuccess("Successfully updated your code"),(!this.cli.isCommandRunningInShell||o)&&this.cli.stopSpinningInput(),this.cli.tutorial.inProgress&&await this.cli.tutorial.onSync(s)})().catch(r=>{Se.error({method:"sync-callback",err:r},"Error syncing code"),this.cli.logError("Something went wrong syncing your code. Please try again.")})}async seed(){var t;this.data&&(this.cli.viewSpinner("Seeding"),await this.data.import(),this.cli.logSuccess(`Seeded data from the ${(t=this.cli.styles)==null?void 0:t.bold(this.cli.fs.dataFileName)} file.`),this.cli.viewInput())}async setupApp(t){var l,f,d,h;let{name:r}=t||{},{org:n}=this,{fs:i}=this.cli;if(n||await this.authorize(),!n)return await this.cli.quit("Ampt Organization is required");let s=r||((f=(l=i.serviceFile)==null?void 0:l.ampt)==null?void 0:f.app)||this.cli.options.app,o=await this.cli.promptServiceName(s),a=new Dt({org:n,serviceName:o});if(await e.checkIfServiceExists(a)&&(this.cli.logWarning(`App ${(h=this.cli.styles)==null?void 0:h.purple((d=this.cli.styles)==null?void 0:d.bold(`"${o}"`))} already exists for this org.`),this.cli.logQuestion("Would you like to overwrite it?"),!await this.cli.confirm()))return this.setupApp({name:r});Se.info({serviceName:a.serviceName,orgName:n.orgName},"app init"),this.service=a}async assureServiceDir(){var i;let{fs:t}=this.cli;if(!this.service||!this.service.serviceName)throw new Uu("Expected App to be defined","assureServiceDir");let r=!1;if(await t.isCwdEmpty()&&(r=await this.cli.confirm(!0,"Would you like to use the current directory?")),!r){if(t.dirExists(this.service.serviceName)){this.cli.logWarning(`Directory "./${this.service.serviceName}" already exists.`);let s=await this.cli.confirm(!1,"Would you like to overwrite it?"),o=await this.cli.confirm(!1,"Are you sure? This will delete all files in the directory.");if(s&&o)t.deleteServiceDir(this.service.serviceName),Se.debug(`Deleted directory ${this.service.serviceName}`);else return this.assureServiceDir()}t.createServiceDir(this.service.serviceName),this.cli.logSuccess(`Created directory ${this.cli.styles.bold(this.cli.styles.darkPurple(`./${this.service.serviceName}`))}`),await t.read({orgName:(i=this.org)==null?void 0:i.orgName}),Se.debug(`Created directory ${this.service.serviceName}`)}}async setupTemplate(){let{fs:t}=this.cli,{template:r}=this.cli.options;if(!this.org)throw new Uu("Expected Org to be defined","setupTemplate");let n=r,[i,s]=await Promise.all([wb(this.cli),this.org.validateLimits()]);if(Se.trace({templates:i.length,limitResult:s},"setupTemplate"),s.serviceExceeded)return this.cli.handleServiceLimitExceeded();if(s.instanceExceeded)return this.cli.handleInstanceLimitExceeded();if(!this.isGitInstalled)return await this.handleGitError();let o=i.find(a=>a.name===n);if(!o){this.cli.logWarning(`Template "${n}" not found.`),this.cli.logInfo("Please choose a template to generate.");let a=await this.cli.select(i);o=a,n=a.name}if(await this.setupApp({name:n}),await this.assureServiceDir(),!this.service)throw new Uu("Expected App to be defined","setupTemplate");if(!t.serviceRoot)throw new Uu("Expected serviceRoot to be defined","setupTemplate");await t.initService({orgName:this.org.orgName,serviceName:this.service.serviceName,template:o,existingProject:!1}),await t.installDependenciesIfExists({viewSpinner:this.cli.viewSpinner.bind(this.cli)})}async setup(){let{fs:t}=this.cli;if(this.org||await this.authorize(),!this.org)return await this.cli.quit("Ampt Organization is required");let[r,n]=await Promise.all([t.readJsonFileIfExists(BL.default.join(t.serviceRoot,"package.json")),t.isCwdEmpty()]);if(n&&await this.shouldStartTutorial())return await this.cli.tutorial.initTutorial();if(r&&!r.ampt){if(cr({eventName:"ampt.dev.prompt",eventData:{promptName:"migrateExistingApp"}}),this.cli.logInfo("This directory does not contain an Ampt project."),this.cli.logQuestion("Would you like to initialize it?"),await this.cli.confirm()){if(this.cli.viewSpinner("Migrating project to Ampt"),await this.setupApp({name:r.name||BL.default.basename(t.serviceRoot)}),!this.service||!this.service.serviceName)throw new Uu("Expected App to be defined","setup");if(await t.initService({orgName:this.org.orgName,serviceName:this.service.serviceName,existingProject:!0}),this.cli.logInfo(`${this.cli.styles.bold(this.cli.styles.darkPurple(this.service.serviceName))} initialized`),await this.shouldStartTutorial())return await this.cli.tutorial.initTutorial();this.cli.viewSpinner("Installing Dependencies"),await t.installDependenciesIfExists({viewSpinner:this.cli.viewSpinner.bind(this.cli)});return}}else if(r)await t.initService({orgName:this.org.orgName,existingProject:!0});else{if(this.cli.logQuestion("Would you like to create a new app?"),!await this.cli.confirm())return await this.cli.quit("Stopped");this.cli.viewSpinner("Loading");let[s,o]=await Promise.all([wb(this.cli),this.org.validateLimits()]);if(o.serviceExceeded)return this.cli.handleServiceLimitExceeded();if(o.instanceExceeded)return this.cli.handleInstanceLimitExceeded();if(!this.isGitInstalled)return await this.handleGitError();cr({eventName:"ampt.dev.prompt",eventData:{promptName:"template"}}),this.cli.logInfo("Choose a template to generate.");let a=await this.cli.select(s);if(await this.setupApp({name:a.name}),await this.assureServiceDir(),!this.service||!this.service.serviceName)throw new Uu("Expected App to be defined","setup");if(this.cli.viewSpinner("Generating template..."),await t.initService({orgName:this.org.orgName,serviceName:this.service.serviceName,template:a,existingProject:!1}),t.dataFile&&(this.isSeedingEnabled=!0),this.cli._clearScreen(),this.cli.logSuccess(`${this.cli.styles.bold(this.service.serviceName)} initialized`),await this.shouldStartTutorial())return await this.cli.tutorial.initTutorial();await t.installDependenciesIfExists({viewSpinner:this.cli.viewSpinner.bind(this.cli)})}}async shouldStartTutorial(){var s,o;let{cli:t}=this,{session:r}=t,{showTutorial:n,allowDismiss:i}=r.shouldPromptTutorial();if(n){let a=["Yes","Skip for now"];i&&a.push("Don't show again"),t.logQuestion("Would you like to start the tutorial?");let u=await t.select(a);if(u==="Yes")return this.isSeedingEnabled=!0,!0;if(u=="Don't show again"){t.logInfo(`You can always run ${(s=t.styles)==null?void 0:s.bold("ampt tutorial")} to go through the tutorial.`),t.viewSpinner("Saving Preferences");try{await((o=t.user)==null?void 0:o.updatePreferences({showTutorial:!1}))}catch{t.logError("Failed to save preferences")}}}return!1}async init(){let{cli:t}=this,r=t.user;if(!r)return await t.quit("You must be logged in to use this command.");if(!r.orgs||!r.orgs.length)return await t.quit("You do not have access to any organizations.");await t.fs.read();try{await Promise.all([this.authorize(),this.runSystemChecks()]),this.isSeedingEnabled=t.options.seed||t.options.s||!1,this.isReseedingEnabled=t.options.reseed||t.options.rs||!1;let n=t.options.tutorial??!1,i=t.options.template??!1;if(Se.debug({tutorialPassed:n,templatePassed:i},"Project.init"),i&&await this.setupTemplate(),n)return await t.tutorial.initTutorial();await this.setup(),this.initialized=!0}catch(n){return await t.quit(n.message)}}};var Hwe=($L(),mt(UL));var cd=class extends Error{function=null;constructor(t,r){super(t),this.function=r}},dS=class e{static tutorialGitUrl="https://github.com/ampt-templates/tutorial";static exitCmd="end";static iterationCmds=["skip","next","done"];static fullTutorialSteps=["editor","sandbox","postSandbox","importData","postImportData","staticAssets","postStaticAssets","runningScripts","postRunningScripts","deploy","postDeploy","dashboard"];static basicTutorialSteps=["editor","sandbox","postSandbox","staticAssets","build","postBuild","importData","postImportData","runningScripts","deploy","dashboard"];welcomeMessage=["Welcome to Ampt!","This Ampt CLI tutorial allows you to exit anytime with 'end' and skip steps using 'skip'."];cli;name;type="basic";inProgress=!1;tutorialModeStart=void 0;nextCommand;activeStepIndex=null;stepOrder=e.fullTutorialSteps;steps={editor:async()=>{let t="To begin, let's open the project in a code editor.";return{title:"Open the project in an editor",pre:this.cli.project.isCodeInstalled?[t,'Run `code .` in the terminal to open the project in Visual Studio Code or type "done" to continue']:[t,'Open the project in your favorite code editor and type "done" to continue'],command:"code"}},sandbox:async()=>{var r,n;let t=["The URL above is your developer sandbox. Code changes are synced here in real-time","Your sandbox goes offline when you disconnect from the CLI","Open the URL in your favorite browser to see your app in action"];return this.type==="full"?t.push('Try making a change to "index.tsx", refresh, and see the changes in real-time!'):(t.push("Try making a change to the code, refresh, and see the changes in real-time!"),(n=(r=this.cli.fs.serviceFile)==null?void 0:r.scripts)!=null&&n["ampt:dev"]&&t.push(`Note, if you're building a frontend app, you can use the "dev" command to start the local development server`)),{title:"The Developer Sandbox",pre:t,event:"sync"}},postSandbox:async()=>({title:"Sandbox Synced",pre:["Sandbox synced!","Any logs or errors from your sandbox are displayed here",'The "main" field in your package.json is the entry point to your app, and is the first file that is executed when your app starts.','By default, this is "index.js" or "index.ts" in the root of your project.'],postAction:!0}),staticAssets:async()=>{let t=["The `static` directory is automatically synced and served from your Ampt environment","This is useful for serving images, fonts, and other static assets"];this.type==="full"?t.push('Try moving "test.html" into the "static" directory and see it update in the sandbox'):t.push("Add a file to your static directory, or hit enter to skip");let r=this.type==="full"?"sync":void 0;return{title:"Static Assets",pre:t,event:r}},postStaticAssets:async()=>{let t=this.cli.project.getSandboxUrl();return{postAction:!0,title:"Static Assets Synced",pre:["Static assets synced!",t?`Now, try navigating to ${t}/test.html to see the changes`:"Try navigating to the /test.html route to see the changes"]}},importData:async()=>({title:"Importing Data to @ampt/data",pre:['You can import data into your Ampt environment using the "import" command',"This command is useful for seeding your database with data for development and testing","Try running the import command now by typing `import` into the terminal"],command:"import"}),postImportData:async()=>({title:"Data Imported!",pre:["Data imported!",this.type==="full"?"Now, try refreshing the sandbox to see the changes in the environment":"Data seeded from your data file is now available in your environment"],postAction:!0}),runningScripts:async()=>{let t=["The Ampt shell allows you to run scripts within the context of your app","For scripts within your package.json, prefix them with 'ampt', e.g. 'ampt:test'"];this.type==="full"&&t.push('Try running the test script by typing "run test" into the terminal'),this.type==="basic"&&(t.push('To run a script, just type "run" followed by the script name, e.g. "run test" for "ampt:test"'),t.push('Ampt automatically handles JS or TS files, just provide the path after the "run" command, e.g. "run scripts/list-todos.ts"'));let r=this.type==="full"?"run":void 0,n=this.type==="full"?"test":void 0;return{title:"Running scripts within the Ampt context",pre:t,command:r,runArg:n}},postRunningScripts:()=>Promise.resolve({title:"Scripts Run!",pre:["Nice, you just ran the test script!",'Ampt also automatically handles JS or TS files, just provide the path after the "run" command, e.g. "run scripts/list-todos.ts"'],postAction:!0}),deploy:()=>Promise.resolve({title:"Deploying to a permanent environment",pre:["To deploy your current sandbox, use the 'deploy prod' command to create a new stage environment named 'prod'","Note, this can take a second, as Ampt provisions an entirely new environment for you in a separate AWS account"],post:["Stage deployed!","The URL above is a stage environment, and is always available."],command:"deploy"}),postDeploy:()=>Promise.resolve({title:"Stage Deployed!",pre:["Stage deployed!","The URL above is a stage environment, and is always available",'Updates to the stage environment are made using the "deploy" command, or automatically using Git CI/CD.'],postAction:!0}),dashboard:()=>Promise.resolve({title:"The Ampt Dashboard",pre:["The dashboard is where you can manage your Ampt environments, view logs, data, and more",'Try opening the your dashboard with the "dashboard" command'],command:"dashboard"}),build:()=>Promise.resolve({title:"Building the app",pre:['For projects with a build step, use "build" to execute the "ampt:build" script in package.json',"Build output is automatically synced and is available at your sandbox url"],command:"run",runArg:"build"}),postBuild:()=>Promise.resolve({title:"App built!",pre:["Depending on your project, you might need to configure its output to be served from the 'static' directory","For more details on your specific framework, check out the Ampt documentation at https://getampt.com/docs"],postAction:!0})};constructor(t){if(!t.project)throw new cd("Project should be set before Tutorial is initialized","constructor");this.cli=t}isExitCmd(t){return t===e.exitCmd}isIterationCmd(t){return e.iterationCmds.includes(t)}async iterateStep(t){let{skip:r=!1}=t||{skip:!1};if(this.inProgress&&this.activeStepIndex!==null){let n=this.activeStepIndex+1;if(this.activeStepIndex===0&&!this.cli.project.sandboxActive&&(this.cli.logSpace(),await this.cli.project.dev({logDashboard:!1})),this.reportAnalytics({exit:!1,step:this.stepOrder[this.activeStepIndex],event:"ampt.tutorial.step_completed"}),n<this.stepOrder.length){this.activeStepIndex=n;let i=await this.steps[this.stepOrder[this.activeStepIndex]]();r&&i.postAction&&n+1<this.stepOrder.length&&(this.activeStepIndex=n+1,i=await this.steps[this.stepOrder[this.activeStepIndex]]()),this.nextCommand=i.command||void 0,this.logStep({step:i}),!i.command&&!i.event&&!i.postAction&&await this.iterateStep()}else await this.complete()}}async onSync(t){if(this.inProgress&&this.activeStepIndex!==null){let r=this.stepOrder[this.activeStepIndex];t.size>0&&(r==="sandbox"||r==="staticAssets"&&Array.from(t).some(n=>n.includes("static")))&&await this.iterateStep()}}async handle(t){var r;if(this.inProgress&&this.activeStepIndex!==null){let n=this.stepOrder[this.activeStepIndex],i=await this.steps[n]();if(this.isExitCmd(t))return this.cli.project.sandboxActive||await this.cli.project.dev(),await this.complete({exit:!0});if(i.postAction&&(this.cli._staticViewInputMsg=void 0),this.isIterationCmd(t))return this.reportAnalytics({exit:!1,step:this.stepOrder[this.activeStepIndex]}),await this.iterateStep({skip:!0});if(i.command==="run"&&t==="run"&&(!this.cli.args[0]||i.runArg&&i.runArg!==this.cli.args[0])){this.cli.logWarning(`Invalid command: "${this.cli.styles.bold(this.cli.styles.red(t))}" - expected "${i.runArg}"`);return}else if(i.command&&t!==i.command){let s=this.cli.styles.purple(n==="build"?"build":i.command);this.cli.logWarning(`Invalid command: "${this.cli.styles.bold(this.cli.styles.red(t))}" - expected "${this.cli.styles.bold(s)}"`);return}else{if(i.command==="deploy"&&t==="deploy"&&!((r=this.cli.names)!=null&&r.instanceName)){this.cli.logWarning('You must provide a stage name to deploy to. Example: "deploy prod"');return}if(n==="editor"&&t==="code")await Hwe.bash(this.cli);else{let s=Hwe[t];if(t&&i.event==="sync"){this.cli.logWarning("Waiting for changes to sync to the sandbox...");return}if(!s){this.cli.logError(`Command "${t}" not found - expected "${i.command}"`);return}this.cli.logSpace(),await s(this.cli)}try{return this.cli.viewInput(),this.iterateStep()}catch(s){throw new cd(s.message,"handle")}}}}async initTutorial(){var i,s,o,a,u,l,f,d;if(!this.cli.user)return await this.cli.quit("You must be logged in to start the Ampt tutorial");if(!this.cli.project.org)return await this.cli.quit("Expected Ampt organization to start the Ampt tutorial");this.name=`${(i=this.cli.user)==null?void 0:i.username}-ampt-tutorial`,this.inProgress=!0,this.tutorialModeStart=process.hrtime.bigint(),this.type=this.cli.fs.serviceFile?"basic":"full",Se.debug({type:this.type,name:this.name},"initTutorial");let t=this.cli.project.org;switch(this.type){case"full":{if(!await this.cli.fs.detectGit())return await this.cli.quit("Git is required to start the Ampt tutorial");let h=async()=>{this.name=await this.cli.promptServiceName(this.name);let g=new Dt({org:this.cli.project.org,serviceName:this.name});if(await g.get().catch(()=>{}))return this.cli.logWarning(`App ${this.cli.styles.bold(this.cli.styles.purple(this.name))} already exists in ${this.cli.styles.bold(this.cli.styles.darkPurple(t.orgName))}`),await this.cli.confirm(!0,"Would you like to overwrite it?")?g:h();let S=await this.cli.fs.isCwdEmpty(),b=!1;if(S&&(b=await this.cli.confirm(!0,"Would you like to start the tutorial in the current directory?")),!b){if(this.cli.fs.dirExists(this.name))if(this.cli.logWarning(`Directory "./${this.name}" already exists.`),await this.cli.confirm(!0,"Would you like to overwrite it?"))this.cli.logInfo(`Overwriting directory: ${this.cli.styles.bold(this.name)}`),this.cli.fs.deleteServiceDir(this.name);else return h();this.cli.fs.createServiceDir(this.name),this.cli.logInfo(`Created directory: ${this.cli.styles.bold(this.name)}`)}return g};this.cli.project.service=await h();let m=(s=this.cli.user)==null?void 0:s.generateSandboxName();this.cli.project.instance=new tr({org:t,service:this.cli.project.service,instanceName:m,cli:this.cli}),this.cli.viewSpinner("Cloning @ampt-templates/tutorial"),await this.cli.fs.cloneGitRepo({repoUrl:e.tutorialGitUrl}),await this.cli.fs.read({orgName:t.orgName,appName:this.name});break}case"basic":{if((a=(o=this.cli.fs.serviceFile)==null?void 0:o.ampt)!=null&&a.app){this.name=(l=(u=this.cli.fs.serviceFile)==null?void 0:u.ampt)==null?void 0:l.app,await this.cli.fs.read({orgName:t.orgName,appName:this.name}),this.stepOrder=e.basicTutorialSteps;let h=!!this.cli.fs.dataFile,m=(d=(f=this.cli.fs.serviceFile)==null?void 0:f.scripts)==null?void 0:d["ampt:build"],g=this.stepOrder.reduce((_,S)=>(S==="importData"||S==="postImportData")&&!h||(S==="build"||S==="postBuild")&&!m?_:[..._,S],[]);this.stepOrder=g}else return await this.cli.quit("Expected an Ampt app to start the Ampt tutorial");break}default:return await this.cli.quit("Expected a valid Ampt tutorial type")}await this.cli.fs.installDependenciesIfExists({viewSpinner:this.cli.viewSpinner.bind(this.cli)}),await this.cli.project.boot(this.type==="basic"?["analyze","detect","connect"]:["connect"]),this.type==="full"&&this.cli.logSpace(),this.cli.logGroup(this.welcomeMessage),this.activeStepIndex=0;let r=this.stepOrder[this.activeStepIndex],n=await this.steps[r]();this.reportAnalytics({exit:!1,event:"ampt.tutorial.started",step:r}),this.logStep({step:n})}logStep(t){let{step:r}=t;this.cli.logSpace(),r.postAction?(this.cli.logGroup([r.pre].flat(),!0),this.cli._staticViewInputMsg='Type "next" or hit enter to continue',this.cli.viewInput()):this.cli.logGroup([r.title,r.pre].flat(),!0)}setType(t){this.type=t}getDurationMins(){let t=process.hrtime.bigint()-this.tutorialModeStart;return Math.round(Number(t)/6e10)}async complete(t){var i,s;let{exit:r=!1}=t||{exit:!1},n=this.stepOrder[this.activeStepIndex];this.reportAnalytics({exit:r,step:r?n:void 0}),this.inProgress=!1,this.activeStepIndex=null,await((s=(i=this.cli)==null?void 0:i.user)==null?void 0:s.updatePreferences({showTutorial:!1})),this.completeMsg()}reportAnalytics(t){var s,o,a;let{event:r,step:n,exit:i=!1}=t;cr({eventName:r||(i?"ampt.tutorial.skipped":"ampt.tutorial.completed"),eventData:{type:this.type,step:n,durationMinutes:r?void 0:this.getDurationMins(),userName:(s=this.cli.user)==null?void 0:s.username,orgName:(o=this.cli.project.org)==null?void 0:o.orgName,serviceName:(a=this.cli.project.service)==null?void 0:a.serviceName}})}completeMsg(){this.cli.logGroup([this.cli.styles.bold("We hope you enjoy using Ampt!"),"If you have any questions or feedback, join our discord: https://getampt.com/discord","To read up on everything Ampt, check out our docs: https://getampt.com/docs",`You can always re-run this tutorial with the command "${this.cli.styles.bold("tutorial")}"`,`You can clear this output with the command "${this.cli.styles.bold("clear")}"`,"Happy coding! \u{1F680}"])}};ld.default.extend(zwe.default);ld.default.extend(Vwe.default);ld.default.updateLocale("en",{relativeTime:{future:"in %s",past:"%s ago",s:(e,t,r,n)=>e<=10?`${e} seconds`:e<=30?"several seconds":e<60?"less than a minute":`${e} seconds`,m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}});var iv=($L(),mt(UL)),{version:Wwe}=wm(),D1t={dim:Zs.default.dim,darkPurple:Zs.default.hex("#B367FF"),purple:Zs.default.hex("#F952FF"),yellow:Zs.default.hex("#FFC700"),blue:Zs.default.hex("#727aff"),red:Zs.default.rgb(255,99,99),grey:Zs.default.hex("#324f59"),pastel:Zs.default.hex("#dbd8ca"),bold:Zs.default.bold,green:Zs.default.hex("#22b9b7")},hS=class e{static defaultSpinnerFrames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];session;messenger;version=Wwe;installedGlobally=KL.default;os=process.platform;user;fs;tutorial;project;showLogo=!0;fromClone=!1;inputValue;timer;isShellActive;isInteractive;isDevServerActive;isAnimationEnabled=!1;isCommandRunningInShell;buildRunningInShell;commandRunningInShellPromise;styles;icons;argv;startupOptions;options;args;names;command;orgName;org;service;serviceName;_exitCode=0;isGitPod=!1;isCodeSpaces=!1;isWebIde=!1;isBeta=!1;_lastSyncedAt;_lastSyncedAtInterval;_staticViewInputMsg;_activeOrgName;_activeServiceName;_allowedInputCharacter;_isLoggedTopPadding;_commandsHistory;_viewType;_viewMessage;_spinnerMessage;_spinnerStep;_isPromptActive;_promptResponse;_timerInterval;_spinnerInterval;_inputSpinnerInterval;_inputSpinnerStartedAt;_inputSpinnerStoppedAt;_tipsInterval;_tipsFrequency;_tipsCollectionIndex;_spinnerFrequency;_spinnerFrames;_spinnerFrameIndex;_selectItems;_selectedItemIndex;_selectedItem;_onQuit;_quitting;_suggestions;_commandsHistoryIndex;_devTipsCollection=["type `dev` to start running the dev server","type `stop` to stop a running dev server"];_cloudScriptsCollection=["add a `ampt:dev` script to package.json to run code within the Ampt context"];_tipsCollection=[];_xdgOpenInstalled=null;constructor(t){process.title="Ampt CLI",this.session=t,this.session.loadAmptConfig(),this.messenger=new F0,this.messenger.on("offline",(0,VL.default)(()=>{this.logError("Event Messenger offline")},1e3,!0)),this.messenger.on("online",(0,VL.default)(()=>{this.logInfo("Event Messenger online")},1e3,!0)),this.inputValue="",this.startupOptions={},this.options={},this.args=[],this.argv=[],this.command=void 0,this.names=void 0,this.icons={},this.commandRunningInShellPromise=null,this._allowedInputCharacter=/^[a-zA-Z0-9 ~:!@#$%^&*()-_=+.<>{}[\]"'/]+$/,this._viewType=null,this._viewMessage=void 0,this._spinnerMessage=null,this._spinnerStep=null,this._isPromptActive=void 0,this._promptResponse=void 0,this._commandsHistory=[],this._spinnerFrequency=100,this._spinnerFrames=e.defaultSpinnerFrames,this._spinnerFrameIndex=0,this.showLogo=!process.env.IS_CHILD_PROCESS&&!this.isGitPod&&this._canRenderBolt(),this.styles=D1t,this._startLastSyncedAtInterval(),this._initIcons(),this._initSuggestions(),process.env.AMPT_IS_GITPOD==="true"&&(this.isGitPod=!0,this.isWebIde=!0),process.env.AMPT_IS_CODESPACES==="true"&&(this.isCodeSpaces=!0,this.isWebIde=!0),this.isWebIde&&(this.isAnimationEnabled=!1),this.isBeta=this.version.includes("beta"),this.isInteractive=process.stdin.isTTY,this.fs=new tw({session:this.session}),this.project=new cS(this),this.tutorial=new dS(this)}async login(){return new Fo}setExitCode(t){this._exitCode=t}async start(t){let{_:r,...n}=(0,WL.default)(process.argv);if(this.startupOptions=n,this.fs.verbose=this.startupOptions.verbose,this.fromClone=(t==null?void 0:t.fromClone)||!1,this.os==="linux"&&(this._xdgOpenInstalled=await this.fs.detectXdgOpen()),r[2]!=="clone"&&process.platform!=="win32")try{Se.enable()}catch(i){console.error(i)}return this.run()}async run(t){try{if(this._parseCommand(t),this.tutorial.inProgress)return await this.tutorial.handle(this.command);if(this.command==="sandbox")return await iv.sandbox(this);if(this.command==="git"||this.command==="code")return await iv.bash(this);this.isShellActive||(this._hideCursor(),this._logLogo(),this.viewSpinner("Loading"),(this.command==="start"||this.command==="tutorial")&&await this._autoUpdate()),this._watchKeyboard();let r=["clone"],n=["promote","test"];if((this.command==="start"||this.command==="tutorial")&&(this.isShellActive=!0),this.isShellActive&&r.includes(this.command))throw new il(`Command "${this.command}" is currently not supported in the shell`);if(n.includes(this.command))throw new il(`Command "${this.command}" is not available.`);if(!iv[this.command]&&this.command!=="tutorial")throw new il(`Command "${this.command}" is not a valid command`);if(!this.user&&(this.user=await Fo.init(),!this.user.isLoggedIn())){this.logInfo("You must login to proceeed.");try{await this.user.performLogin(this)}catch(i){if(i.name==="UserDisabledError")return this.logError(i.message||"Your account has been disabled. Please contact support."),this._stop(0);throw i}}await this.messenger.connect(),this.command==="tutorial"&&(this.command="start",this.options.tutorial=!0),this.command==="dashboard"&&(this.command="open"),await iv[this.command](this),this.options={}}catch(r){if(r instanceof cd||r instanceof il)this.logError(r.message);else{if(r instanceof Rp)return this.logError(r.message),this._stop(this._exitCode);if(r.name==="InstancesLimitError"){let n=["share","deploy"].includes(this.command);return this.handleInstanceLimitExceeded({isDeploying:n})}else return r.name==="ServicesLimitError"?this.handleServiceLimitExceeded():(console.error({error:r},"CLI Error"),this.session.captureException(r),this.logError(`Something went wrong - please contact support and provide ${this.session.getSessionId()} as a reference ID`),this._stop(1))}}return this.isShellActive?this.viewInput():this._stop(this._exitCode)}handleServiceLimitExceeded(){let t="You have reached your app limit. Please upgrade your plan or delete an app.";return this.quit(t)}handleInstanceLimitExceeded(t){let{isDeploying:r=!1}=t||{},n="You have reached your environment limit. Please upgrade your plan or delete an environment.";if(!r)return this.quit(n);this.logWarning("Deployment failed"),this.logError(n),this.viewInput()}setProject(t){this.project=t}viewInput(t=this._formatLastSyncedAt()){this._timerInterval=clearInterval(this._timerInterval),this._spinnerInterval=clearInterval(this._spinnerInterval),this._startLastSyncedAtInterval(),this._switchView({viewType:"input",viewMessage:t})}spinInput(){if(this._viewType!=="input"){Se.error({_viewType:this._viewType},"wrong viewType in spinInput");return}this.isAnimationEnabled&&(this._inputSpinnerStartedAt=Date.now(),clearInterval(this._inputSpinnerInterval),this._inputSpinnerInterval=setInterval(()=>this.updateInputSpinner(),this._spinnerFrequency).unref())}viewSpinner(t="Loading",r){let{timer:n=!1}=r||{};if(!this.isInteractive){console.log(t);return}if(!this.isAnimationEnabled){this._switchView({viewType:"spinner",viewMessage:t});return}this._spinnerMessage=t,this._spinnerStep="",clearInterval(this._timerInterval),clearInterval(this._spinnerInterval),clearInterval(this._inputSpinnerInterval),this._timerInterval=void 0,this._spinnerInterval=void 0,this._inputSpinnerInterval=void 0,n&&(this.timer=0,this._timerInterval=setInterval(()=>this.timer=+this.timer+1,1e3).unref()),this._spinnerInterval=setInterval(()=>this._updateSpinner((this._spinnerMessage||"Loading")+(this._spinnerStep?` (${this._spinnerStep})`:""),{timer:n}),this._spinnerFrequency).unref()}updateLastSyncedAt(t){this._lastSyncedAt=t}updateInputSpinner(){this._spinnerFrameIndex=++this._spinnerFrameIndex%this._spinnerFrames.length,this._switchView({viewType:"input"})}stopSpinningInput(){this._inputSpinnerInterval&&(clearInterval(this._inputSpinnerInterval),this._inputSpinnerStoppedAt=Date.now(),this._inputSpinnerInterval=void 0),this.viewInput()}updateSpinnerStep(t){if(!process.stdin.isTTY){console.log(t);return}this._spinnerStep=t}pause(){this._clearIntervals(),this._switchView({viewType:"pause"}),this._eraseCursorLineAndBelow()}async prompt(t,r={}){for(this._isPromptActive=!0,r.default&&(this.inputValue=r.default),this.viewInput(t);!this._promptResponse;)await Cu(50);let n=this._promptResponse;return this.logInfo(`You've entered ${this.styles.bold(n)}.`),this._promptResponse=null,this._isPromptActive=!1,n}async promptServiceName(t=null){let r=await this.prompt("Enter a name for your app",{default:t});return r.match(/^[a-z0-9-]+$/)?r:(this.logError("App name must consist only of lowercase characters and hyphens. Please try again."),await this.promptServiceName())}async confirm(t=!1,r){r&&this.logQuestion(r);let n=["no","yes"],i=await this.select(t?n.reverse():n);return i==="yes"}async select(t=[],r=0){if(clearInterval(this._timerInterval),clearInterval(this._spinnerInterval),clearInterval(this._inputSpinnerInterval),this._timerInterval=void 0,this._spinnerInterval=void 0,this._inputSpinnerInterval=void 0,this._selectItems=t,this._selectedItemIndex=r,this._switchView({viewType:"select"}),this._selectItems.length===1)return this._selectedItem=this._selectItems[0],this._selectedItem;for(;!this._selectedItem;)await Cu(50);let n=this._selectedItem;return typeof n=="object"?this.logInfo(`You've selected ${this.styles.bold(n.title)}.`):this.logInfo(`You've selected ${this.styles.bold(n)}.`),this._selectedItem=null,this._selectedItemIndex=null,this._selectItems=[],n}async selectOrg(t,r){this.viewSpinner("Loading");let n,i=(t.orgs||[]).map(s=>s.orgName);return i.length>1?(this.logInfo(r||"Please select an organization."),n=await this.select(i)):n=i[0],n}async selectService(t,r){let n;this.viewSpinner("Loading");let i=(await t.listServicesWithInstances()).map(s=>s.serviceName);return Se.debug({servicesList:i},"select service"),i.length>1?(this.logInfo(r||"Please select a service."),n=await this.select(i)):n=i[0],n}async selectInstance({service:t,instanceType:r,instanceName:n,message:i}){let o=(await(t==null?void 0:t.listInstances().catch(()=>[]))||[]).filter(l=>!r||l.instanceType===r).map(l=>({instanceName:l.instanceName,region:l.region,displayRegion:l.region||"",display:`${l.instanceName} (${l.region})`}));if(n)return o.find(l=>l.instanceName===n)||{instanceName:n,isNewInstance:!0};if(o.length===0)return{instanceName:void 0};if(o.length===1)return{instanceName:o[0].instanceName,isNewInstance:!1};this.logInfo(i||"Please select a stage.");let a=await this.select(o.map(l=>l.display));return{instanceName:o.find(l=>l.display===a).instanceName,isNewInstance:!1}}logSuccess(t,r=0){this.log(`${this.icons.tick} ${t}`,r)}logError(t,r=0){this.log(`${this.icons.cross} ${this.styles.bold(this.styles.red(t))}`,r)}logCancelled(){this.logError("Cancelled")}logInfo(t,r=0){this.log(`${this.icons.info} ${t}`,r)}logWarning(t,r=0){this.log(`${this.icons.warning} ${t}`,r)}logQuestion(t,r=0){this.log(`${this.icons.question} ${t}`,r)}logGroup(t,r=!0){t.forEach((n,i)=>{let o=r&&i===0?`${this.icons.arrow} ${this.styles.bold(n)}`:` ${this.icons.dot} ${n}`;this.log(o,i>0?2:0)})}logUrl(t,r=0){this.log(`${this.icons.arrow} ${t}`,r)}logTime(t,r=0){this.log(`${this.styles.dim(`${new Date(Date.now()).toLocaleTimeString()} ${this.icons.line}`)} ${t}`,r)}log(t="",r=0){this._ensureTopPadding(),this._eraseCursorLineAndBelow(),this._log(`${" ".repeat(r)}${t}
|
|
280
|
+
${s}`)}}});var P1t,Bwe=oe(()=>{"use strict";An();P1t=async e=>{e.viewSpinner("Loading");let t=e.fs;if(await t.read(),!t.serviceFile)throw new Error("You must be inside an Ampt app directory to run this command.");let{user:r}=e,n=e.options.org||t.serviceFile.ampt.org,i=e.options.app||t.serviceFile.ampt.app,s=e.args[0]||r.username;n||(n=await e.selectOrg(r)),e.viewSpinner("Loading");let o=new Kt({orgName:n});await o.isAuthorized()||(e.logError(`You don't have access to the "${n}" org.`),n=await e.selectOrg(r)),o.update({orgName:n}),e.viewSpinner("Loading");let a=new Dt({org:o,serviceName:i}),u=new tr({org:o,service:a,instanceName:s});await u.get(),e.logUrl(u.url)}});var Uwe,q1t,$we=oe(()=>{"use strict";Uwe=ve(wm()),q1t=async e=>{e.log(`v${Uwe.version}`)}});var UL={};ec(UL,{bash:()=>l1t,clone:()=>f1t,dashboard:()=>p1t,delete:()=>d1t,deploy:()=>h1t,docs:()=>m1t,export:()=>g1t,help:()=>v1t,import:()=>y1t,install:()=>_1t,login:()=>x1t,logout:()=>b1t,open:()=>w1t,promote:()=>S1t,run:()=>T1t,sandbox:()=>C1t,serverless:()=>A1t,setup:()=>FL,share:()=>I1t,start:()=>N1t,stop:()=>O1t,test:()=>R1t,uninstall:()=>k1t,url:()=>P1t,version:()=>q1t});var $L=oe(()=>{"use strict";lwe();pwe();dwe();hwe();mwe();gwe();vwe();_we();xwe();bwe();wwe();Swe();Ewe();Twe();Owe();Rwe();qwe();ML();Dwe();Lwe();Fwe();Mwe();jwe();Bwe();$we()});var HL=ve(require("os")),ld=ve(Qv()),zwe=ve(SM()),Vwe=ve(EM()),Es=ve(NM()),Gwe=ve(HM()),Zs=ve(bj()),Kwe=ve(Ej()),Cl=ve(Cj()),Xwe=ve(Oj()),WL=ve(qj()),Ywe=ve(ZU()),zL=ve(n1()),VL=ve(s1()),GL=require("child_process"),KL=ve(I5()),Zwe=require("fs/promises"),fd=ve(mc()),mS=ve(V1());ur();Vk();An();Pp();An();ur();os();var uwe=ve(mc()),BL=ve(require("path")),uS=ve(require("assert"));An();os();ur();OR();ML();ur();wo();function jL(e){(async()=>{let{orgName:t,serviceName:r,instanceName:n}=e;try{await ze({method:"POST",body:e,endpoint:`/orgs/${t}/services/${r}/instances/${n}/metrics`})}catch(i){$t.captureException(i),process.env.AMPT_DEBUG&&console.error(i)}})()}var Uu=class extends Error{function=null;constructor(t,r){super(t),this.function=r}};var cS=class e{initialized=!1;cli;org;service;instance;data;code;isGitInstalled=!1;isCodeInstalled=!1;isSeedingEnabled=!1;isReseedingEnabled=!1;devModeStart=void 0;messenger;sandboxActive=!1;syncInProgress=!1;queuedFilePaths=new Set;constructor(t){this.cli=t}static async checkIfServiceExists(t){return!!await t.get().catch(()=>{})}async handleGitError(){return this.cli.logWarning(`"${this.cli.styles.bold("git")}" is not installed on this system.`),await this.cli.quit("Please install git and try again.")}async runSystemChecks(){let[t,r]=await Promise.all([this.cli.fs.detectGit(),this.cli.fs.detectVsCode()]);this.isGitInstalled=t,this.isCodeInstalled=r}getSandboxUrl(){if(this.instance)return this.instance.url}getDashboardUrl(){if(this.org&&this.service&&this.instance)return`${process.env.AMPT_DASHBOARD_URL_ROOT}/orgs/${this.org.orgName}/apps/${this.service.serviceName}/environments/${this.instance.instanceName}`}async boot(t){let r=new Set(t);r&&r.size>0?(r.has("analyze")&&await this.analyze(),r.has("detect")&&await this.detect(),r.has("connect")&&await this.connect(),r.has("dev")&&await this.dev()):(await this.analyze(),await this.detect(),await this.connect(),await this.dev())}async selectOrg(){var s,o,a;let t=this.cli,r=t.user;if(!r)return await this.cli.quit("You must be logged in to use this command.");if(await r.listOrgs(),((s=r.orgs)==null?void 0:s.length)===0)return await t.quit("You do not have access to any organizations.");let n=t.options.org;((o=r.orgs)==null?void 0:o.length)===1&&!n?n=r.orgs[0].orgName:((a=r.orgs)==null?void 0:a.length)>1&&!n&&(n=await t.selectOrg(r));let i=new Kt({orgName:n});i.update({orgName:n}),this.org=i}async authorize(){var n,i,s;let t=this.cli.user,r=this.cli.options.org||((i=(n=this.cli.fs.serviceFile)==null?void 0:n.ampt)==null?void 0:i.org);if(r&&!t.hasAccessToOrg(r)&&(this.cli.logWarning(`Org "${r}" has either been deleted, renamed, or you no longer have access to it.`),r=void 0),r?this.org=new Kt({orgName:r}):(cr({eventName:"ampt.dev.prompt",eventData:{promptName:"org"}}),await this.selectOrg(),await this.cli.fs.readServiceFileIfExists({orgName:r||((s=this.org)==null?void 0:s.orgName)})),!this.org)return await this.cli.quit("Ampt Organization is required");await this.org.isAuthorized()||(this.cli.logError(`You don't have access to the "${r}" org.`),await this.selectOrg()),this.cli._activeOrgName=this.org.orgName}async analyze(){this.cli.viewSpinner("Analyzing Project"),await FL(this.cli),await this.cli.checkForAmptPackageUpdates()}async hydrate(){if(!this.org){await this.cli.quit("Ampt Organization is required");return}if(!this.service){await this.cli.quit("Ampt App is required");return}if(!this.instance){await this.cli.quit("Ampt Environment is required");return}let[t,r,n,i]=await Promise.all([this.instance.get().catch(()=>{}),this.service.get().catch(()=>{}),this.org.fetch(),this.org.getRegions()]),s=this.cli.selectRegion({orgInfo:n,serviceInfo:r,instanceInfo:t,regions:i});if(!s){this.cli.logError("No region selected."),await this.cli.quit();return}this.instance.region=s.code}async detect(){var r,n,i;this.cli.viewSpinner("Starting");let t=this.cli.options.app||((n=(r=this.cli.fs.serviceFile)==null?void 0:r.ampt)==null?void 0:n.app);t||(cr({eventName:"ampt.dev.prompt",eventData:{promptName:"service"}}),t=await this.cli.promptServiceName(),this.cli.viewSpinner("Saving"),await this.cli.fs.writeServiceFile({serviceName:t})),this.cli._activeServiceName=t,this.service||(this.service=new Dt({org:this.org,serviceName:t})),this.instance||(this.instance=new tr({org:this.org,service:this.service,instanceName:(i=this.cli.user)==null?void 0:i.generateSandboxName()})),await this.hydrate()}async connect(){if((0,uS.default)(this.org,"Org is required"),(0,uS.default)(this.service,"Service is required"),(0,uS.default)(this.instance,"Instance is required"),!this.cli.user)return await this.cli.quit("You must be logged in");let t=this.org.orgName,r=this.service.serviceName;if(this.cli.viewSpinner("Connecting to your personal sandbox environment..."),this.devModeStart=process.hrtime.bigint(),await this.cli.isAmptShellRunning({orgName:t,serviceName:r}))return this.cli.logError(`The Ampt shell for app "${r}" in org "${t}" is already running in another terminal.`),await this.cli.quit();await this.cli.writeAmptShellActivityFile({orgName:t,serviceName:r}),this.cli.bindService({orgName:t,serviceName:r}),this.cli.onQuit(async()=>{var f;(0,uwe.removeSync)(Tp(t,r)),await Qn.stop(this.cli,{hasQuit:!0,orgName:t,serviceName:r});let u=await this.cli.fs.readJsonFileIfExists(this.cli.fs.serviceFilePath),l=process.hrtime.bigint();(f=this.messenger)==null||f.close(),cr({eventName:"ampt.dev.ended",eventData:{source:this.cli.isGitPod?"gitpod":"local",timeInSeconds:this.devModeStart?Number(l-this.devModeStart)/1e9:0,dependencies:Object.keys((u==null?void 0:u.dependencies)||{}),appName:`${t}:${r}`}})}),this.code=new Bi({org:this.org,service:this.service,instance:this.instance,user:this.cli.user,fullSync:this.cli.options["full-sync"],cli:this.cli,verbose:this.cli.options.verbose}),this.data=new Fu({fs:this.cli.fs,org:this.org,service:this.service,instance:this.instance}),this.cli.viewSpinner("Syncing");let i=this.cli.viewSpinner.bind(this.cli),s=u=>i(`Syncing (${u})`),o=await this.code.sync(void 0,s);this.cli.updateLastSyncedAt(Date.now()),jL({...o,source:this.cli.isGitPod?"gitpod":"local",orgName:t,serviceName:this.service.serviceName,instanceName:this.instance.instanceName,appName:`${t}:${r}`,region:this.instance.region}),this.cli.viewSpinner("Connecting to real time logs");let[a]=await Promise.all([this.instance.connect({cli:this.cli}),this.cli.messenger.subscribe({userUid:this.cli.user.userId,orgName:t,appName:r,instanceName:this.instance.instanceName})]);this.messenger=a}async dev(t){var _;let{logDashboard:r=!1}=t||{},n=this.org,i=this.service,s=this.instance,o=this.code,a=n.orgName,u=i.serviceName,l=s.instanceName,f=this.cli.styles.purple(`@${a}`),d=this.cli.styles.blue(u),h=this.cli.styles.green(l),m=this.cli.styles.dim("/"),g=`Connected to ${this.cli.styles.bold(`${f}${m}${d}${m}${h}`)}`;if(this.cli.logSuccess(g),this.cli.logUrl(s.url),r){this.cli.logSpace(),this.cli.logInfo("View your app in the dashboard");let S=`${process.env.AMPT_DASHBOARD_URL_ROOT}/orgs/${a}/apps/${u}/environments/${l}`;this.cli.logUrl(S)}if(this.isReseedingEnabled&&this.cli.logSuccess("Enabled automatic data reseeding"),this.cli.viewInput(),this.cli.options.dev){let{url:S,region:b}=s,{credentials:C,env:T}=o;Qn.start({credentials:C,env:T,url:S,cli:this.cli,fs:this.cli.fs,user:this.cli.user,scriptName:"dev",ifPresent:!1,orgName:a,serviceName:u,region:b}).catch(w=>{Se.error({err:w},"Error starting dev server"),this.cli.logError("Something went wrong starting the dev server.")})}cr({eventName:"ampt.dev.enabled",eventData:{dependencies:Object.keys(((_=this.cli.fs.serviceFile)==null?void 0:_.dependencies)||{}),appName:`${a}:${u}`}}),this.isSeedingEnabled&&await this.seed(),this.cli.fs.watch(o.workspaceRoot,this.onFileChange.bind(this)),this.sandboxActive=!0}async onFileChange(t){(async()=>{let r=this.org.orgName,n=this.service.serviceName,i=this.instance.instanceName;if(!this.code)return await this.cli.quit("Sync engine is not active");for(let l of t)this.queuedFilePaths.add(l);let s=this.queuedFilePaths,o=await Qn.isRunning({orgName:r,serviceName:n}),a=this.cli.buildRunningInShell;if(this.cli.isCommandRunningInShell&&!o&&(Se.trace("waiting for command to finish"),await this.cli.commandRunningInShellPromise,Se.trace("command finished")),this.syncInProgress){Se.trace("sync in progress, skipping");return}this.syncInProgress=!0;let u;if(a)await this.cli.commandRunningInShellPromise,u=await this.code.sync();else for(;this.queuedFilePaths.size>0;){let l=this.queuedFilePaths;this.queuedFilePaths=new Set,this.isReseedingEnabled&&this.cli.fs.dataFilePath&&l.has(this.cli.fs.dataFilePath)&&(this.cli.viewSpinner("Seeding",{timer:!0}),await this.seed()),(!this.cli.isCommandRunningInShell||o)&&this.cli.spinInput(),Se.trace({size:l.size,queued:this.queuedFilePaths.size},"starting sync"),u=await this.code.sync(l),Se.trace({size:l.size,queued:this.queuedFilePaths.size},"sync complete")}jL({...u,source:this.cli.isGitPod?"gitpod":"local",orgName:r,serviceName:n,instanceName:i,appName:`${r}:${n}`,region:this.instance.region}),this.syncInProgress=!1,this.cli.updateLastSyncedAt(Date.now()),this.cli.isAnimationEnabled||this.cli.logSuccess("Successfully updated your code"),(!this.cli.isCommandRunningInShell||o)&&this.cli.stopSpinningInput(),this.cli.tutorial.inProgress&&await this.cli.tutorial.onSync(s)})().catch(r=>{Se.error({method:"sync-callback",err:r},"Error syncing code"),this.cli.logError("Something went wrong syncing your code. Please try again.")})}async seed(){var t;this.data&&(this.cli.viewSpinner("Seeding"),await this.data.import(),this.cli.logSuccess(`Seeded data from the ${(t=this.cli.styles)==null?void 0:t.bold(this.cli.fs.dataFileName)} file.`),this.cli.viewInput())}async setupApp(t){var l,f,d,h;let{name:r}=t||{},{org:n}=this,{fs:i}=this.cli;if(n||await this.authorize(),!n)return await this.cli.quit("Ampt Organization is required");let s=r||((f=(l=i.serviceFile)==null?void 0:l.ampt)==null?void 0:f.app)||this.cli.options.app,o=await this.cli.promptServiceName(s),a=new Dt({org:n,serviceName:o});if(await e.checkIfServiceExists(a)&&(this.cli.logWarning(`App ${(h=this.cli.styles)==null?void 0:h.purple((d=this.cli.styles)==null?void 0:d.bold(`"${o}"`))} already exists for this org.`),this.cli.logQuestion("Would you like to overwrite it?"),!await this.cli.confirm()))return this.setupApp({name:r});Se.info({serviceName:a.serviceName,orgName:n.orgName},"app init"),this.service=a}async assureServiceDir(){var i;let{fs:t}=this.cli;if(!this.service||!this.service.serviceName)throw new Uu("Expected App to be defined","assureServiceDir");let r=!1;if(await t.isCwdEmpty()&&(r=await this.cli.confirm(!0,"Would you like to use the current directory?")),!r){if(t.dirExists(this.service.serviceName)){this.cli.logWarning(`Directory "./${this.service.serviceName}" already exists.`);let s=await this.cli.confirm(!1,"Would you like to overwrite it?"),o=await this.cli.confirm(!1,"Are you sure? This will delete all files in the directory.");if(s&&o)t.deleteServiceDir(this.service.serviceName),Se.debug(`Deleted directory ${this.service.serviceName}`);else return this.assureServiceDir()}t.createServiceDir(this.service.serviceName),this.cli.logSuccess(`Created directory ${this.cli.styles.bold(this.cli.styles.darkPurple(`./${this.service.serviceName}`))}`),await t.read({orgName:(i=this.org)==null?void 0:i.orgName}),Se.debug(`Created directory ${this.service.serviceName}`)}}async setupTemplate(){let{fs:t}=this.cli,{template:r}=this.cli.options;if(!this.org)throw new Uu("Expected Org to be defined","setupTemplate");let n=r,[i,s]=await Promise.all([wb(this.cli),this.org.validateLimits()]);if(Se.trace({templates:i.length,limitResult:s},"setupTemplate"),s.serviceExceeded)return this.cli.handleServiceLimitExceeded();if(s.instanceExceeded)return this.cli.handleInstanceLimitExceeded();if(!this.isGitInstalled)return await this.handleGitError();let o=i.find(a=>a.name===n);if(!o){this.cli.logWarning(`Template "${n}" not found.`),this.cli.logInfo("Please choose a template to generate.");let a=await this.cli.select(i);o=a,n=a.name}if(await this.setupApp({name:n}),await this.assureServiceDir(),!this.service)throw new Uu("Expected App to be defined","setupTemplate");if(!t.serviceRoot)throw new Uu("Expected serviceRoot to be defined","setupTemplate");await t.initService({orgName:this.org.orgName,serviceName:this.service.serviceName,template:o,existingProject:!1}),await t.installDependenciesIfExists({viewSpinner:this.cli.viewSpinner.bind(this.cli)})}async setup(){let{fs:t}=this.cli;if(this.org||await this.authorize(),!this.org)return await this.cli.quit("Ampt Organization is required");let[r,n]=await Promise.all([t.readJsonFileIfExists(BL.default.join(t.serviceRoot,"package.json")),t.isCwdEmpty()]);if(n&&await this.shouldStartTutorial())return await this.cli.tutorial.initTutorial();if(r&&!r.ampt){if(cr({eventName:"ampt.dev.prompt",eventData:{promptName:"migrateExistingApp"}}),this.cli.logInfo("This directory does not contain an Ampt project."),this.cli.logQuestion("Would you like to initialize it?"),await this.cli.confirm()){if(this.cli.viewSpinner("Migrating project to Ampt"),await this.setupApp({name:r.name||BL.default.basename(t.serviceRoot)}),!this.service||!this.service.serviceName)throw new Uu("Expected App to be defined","setup");if(await t.initService({orgName:this.org.orgName,serviceName:this.service.serviceName,existingProject:!0}),this.cli.logInfo(`${this.cli.styles.bold(this.cli.styles.darkPurple(this.service.serviceName))} initialized`),await this.shouldStartTutorial())return await this.cli.tutorial.initTutorial();this.cli.viewSpinner("Installing Dependencies"),await t.installDependenciesIfExists({viewSpinner:this.cli.viewSpinner.bind(this.cli)});return}}else if(r)await t.initService({orgName:this.org.orgName,existingProject:!0});else{if(this.cli.logQuestion("Would you like to create a new app?"),!await this.cli.confirm())return await this.cli.quit("Stopped");this.cli.viewSpinner("Loading");let[s,o]=await Promise.all([wb(this.cli),this.org.validateLimits()]);if(o.serviceExceeded)return this.cli.handleServiceLimitExceeded();if(o.instanceExceeded)return this.cli.handleInstanceLimitExceeded();if(!this.isGitInstalled)return await this.handleGitError();cr({eventName:"ampt.dev.prompt",eventData:{promptName:"template"}}),this.cli.logInfo("Choose a template to generate.");let a=await this.cli.select(s);if(await this.setupApp({name:a.name}),await this.assureServiceDir(),!this.service||!this.service.serviceName)throw new Uu("Expected App to be defined","setup");if(this.cli.viewSpinner("Generating template..."),await t.initService({orgName:this.org.orgName,serviceName:this.service.serviceName,template:a,existingProject:!1}),t.dataFile&&(this.isSeedingEnabled=!0),this.cli._clearScreen(),this.cli.logSuccess(`${this.cli.styles.bold(this.service.serviceName)} initialized`),await this.shouldStartTutorial())return await this.cli.tutorial.initTutorial();await t.installDependenciesIfExists({viewSpinner:this.cli.viewSpinner.bind(this.cli)})}}async shouldStartTutorial(){var s,o;let{cli:t}=this,{session:r}=t,{showTutorial:n,allowDismiss:i}=r.shouldPromptTutorial();if(n){let a=["Yes","Skip for now"];i&&a.push("Don't show again"),t.logQuestion("Would you like to start the tutorial?");let u=await t.select(a);if(u==="Yes")return this.isSeedingEnabled=!0,!0;if(u=="Don't show again"){t.logInfo(`You can always run ${(s=t.styles)==null?void 0:s.bold("ampt tutorial")} to go through the tutorial.`),t.viewSpinner("Saving Preferences");try{await((o=t.user)==null?void 0:o.updatePreferences({showTutorial:!1}))}catch{t.logError("Failed to save preferences")}}}return!1}async init(){let{cli:t}=this,r=t.user;if(!r)return await t.quit("You must be logged in to use this command.");if(!r.orgs||!r.orgs.length)return await t.quit("You do not have access to any organizations.");await t.fs.read();try{await Promise.all([this.authorize(),this.runSystemChecks()]),this.isSeedingEnabled=t.options.seed||t.options.s||!1,this.isReseedingEnabled=t.options.reseed||t.options.rs||!1;let n=t.options.tutorial??!1,i=t.options.template??!1;if(Se.debug({tutorialPassed:n,templatePassed:i},"Project.init"),i&&await this.setupTemplate(),n)return await t.tutorial.initTutorial();await this.setup(),this.initialized=!0}catch(n){return await t.quit(n.message)}}};var Hwe=($L(),mt(UL));var cd=class extends Error{function=null;constructor(t,r){super(t),this.function=r}},dS=class e{static tutorialGitUrl="https://github.com/ampt-templates/tutorial";static exitCmd="end";static iterationCmds=["skip","next","done"];static fullTutorialSteps=["editor","sandbox","postSandbox","importData","postImportData","staticAssets","postStaticAssets","runningScripts","postRunningScripts","deploy","postDeploy","dashboard"];static basicTutorialSteps=["editor","sandbox","postSandbox","staticAssets","build","postBuild","importData","postImportData","runningScripts","deploy","dashboard"];welcomeMessage=["Welcome to Ampt!","This Ampt CLI tutorial allows you to exit anytime with 'end' and skip steps using 'skip'."];cli;name;type="basic";inProgress=!1;tutorialModeStart=void 0;nextCommand;activeStepIndex=null;stepOrder=e.fullTutorialSteps;steps={editor:async()=>{let t="To begin, let's open the project in a code editor.";return{title:"Open the project in an editor",pre:this.cli.project.isCodeInstalled?[t,'Run `code .` in the terminal to open the project in Visual Studio Code or type "done" to continue']:[t,'Open the project in your favorite code editor and type "done" to continue'],command:"code"}},sandbox:async()=>{var r,n;let t=["The URL above is your developer sandbox. Code changes are synced here in real-time","Your sandbox goes offline when you disconnect from the CLI","Open the URL in your favorite browser to see your app in action"];return this.type==="full"?t.push('Try making a change to "index.tsx", refresh, and see the changes in real-time!'):(t.push("Try making a change to the code, refresh, and see the changes in real-time!"),(n=(r=this.cli.fs.serviceFile)==null?void 0:r.scripts)!=null&&n["ampt:dev"]&&t.push(`Note, if you're building a frontend app, you can use the "dev" command to start the local development server`)),{title:"The Developer Sandbox",pre:t,event:"sync"}},postSandbox:async()=>({title:"Sandbox Synced",pre:["Sandbox synced!","Any logs or errors from your sandbox are displayed here",'The "main" field in your package.json is the entry point to your app, and is the first file that is executed when your app starts.','By default, this is "index.js" or "index.ts" in the root of your project.'],postAction:!0}),staticAssets:async()=>{let t=["The `static` directory is automatically synced and served from your Ampt environment","This is useful for serving images, fonts, and other static assets"];this.type==="full"?t.push('Try moving "test.html" into the "static" directory and see it update in the sandbox'):t.push("Add a file to your static directory, or hit enter to skip");let r=this.type==="full"?"sync":void 0;return{title:"Static Assets",pre:t,event:r}},postStaticAssets:async()=>{let t=this.cli.project.getSandboxUrl();return{postAction:!0,title:"Static Assets Synced",pre:["Static assets synced!",t?`Now, try navigating to ${t}/test.html to see the changes`:"Try navigating to the /test.html route to see the changes"]}},importData:async()=>({title:"Importing Data to @ampt/data",pre:['You can import data into your Ampt environment using the "import" command',"This command is useful for seeding your database with data for development and testing","Try running the import command now by typing `import` into the terminal"],command:"import"}),postImportData:async()=>({title:"Data Imported!",pre:["Data imported!",this.type==="full"?"Now, try refreshing the sandbox to see the changes in the environment":"Data seeded from your data file is now available in your environment"],postAction:!0}),runningScripts:async()=>{let t=["The Ampt shell allows you to run scripts within the context of your app","For scripts within your package.json, prefix them with 'ampt', e.g. 'ampt:test'"];this.type==="full"&&t.push('Try running the test script by typing "run test" into the terminal'),this.type==="basic"&&(t.push('To run a script, just type "run" followed by the script name, e.g. "run test" for "ampt:test"'),t.push('Ampt automatically handles JS or TS files, just provide the path after the "run" command, e.g. "run scripts/list-todos.ts"'));let r=this.type==="full"?"run":void 0,n=this.type==="full"?"test":void 0;return{title:"Running scripts within the Ampt context",pre:t,command:r,runArg:n}},postRunningScripts:()=>Promise.resolve({title:"Scripts Run!",pre:["Nice, you just ran the test script!",'Ampt also automatically handles JS or TS files, just provide the path after the "run" command, e.g. "run scripts/list-todos.ts"'],postAction:!0}),deploy:()=>Promise.resolve({title:"Deploying to a permanent environment",pre:["To deploy your current sandbox, use the 'deploy prod' command to create a new stage environment named 'prod'","Note, this can take a second, as Ampt provisions an entirely new environment for you in a separate AWS account"],post:["Stage deployed!","The URL above is a stage environment, and is always available."],command:"deploy"}),postDeploy:()=>Promise.resolve({title:"Stage Deployed!",pre:["Stage deployed!","The URL above is a stage environment, and is always available",'Updates to the stage environment are made using the "deploy" command, or automatically using Git CI/CD.'],postAction:!0}),dashboard:()=>Promise.resolve({title:"The Ampt Dashboard",pre:["The dashboard is where you can manage your Ampt environments, view logs, data, and more",'Try opening the your dashboard with the "dashboard" command'],command:"dashboard"}),build:()=>Promise.resolve({title:"Building the app",pre:['For projects with a build step, use "build" to execute the "ampt:build" script in package.json',"Build output is automatically synced and is available at your sandbox url"],command:"run",runArg:"build"}),postBuild:()=>Promise.resolve({title:"App built!",pre:["Depending on your project, you might need to configure its output to be served from the 'static' directory","For more details on your specific framework, check out the Ampt documentation at https://getampt.com/docs"],postAction:!0})};constructor(t){if(!t.project)throw new cd("Project should be set before Tutorial is initialized","constructor");this.cli=t}isExitCmd(t){return t===e.exitCmd}isIterationCmd(t){return e.iterationCmds.includes(t)}async iterateStep(t){let{skip:r=!1}=t||{skip:!1};if(this.inProgress&&this.activeStepIndex!==null){let n=this.activeStepIndex+1;if(this.activeStepIndex===0&&!this.cli.project.sandboxActive&&(this.cli.logSpace(),await this.cli.project.dev({logDashboard:!1})),this.reportAnalytics({exit:!1,step:this.stepOrder[this.activeStepIndex],event:"ampt.tutorial.step_completed"}),n<this.stepOrder.length){this.activeStepIndex=n;let i=await this.steps[this.stepOrder[this.activeStepIndex]]();r&&i.postAction&&n+1<this.stepOrder.length&&(this.activeStepIndex=n+1,i=await this.steps[this.stepOrder[this.activeStepIndex]]()),this.nextCommand=i.command||void 0,this.logStep({step:i}),!i.command&&!i.event&&!i.postAction&&await this.iterateStep()}else await this.complete()}}async onSync(t){if(this.inProgress&&this.activeStepIndex!==null){let r=this.stepOrder[this.activeStepIndex];t.size>0&&(r==="sandbox"||r==="staticAssets"&&Array.from(t).some(n=>n.includes("static")))&&await this.iterateStep()}}async handle(t){var r;if(this.inProgress&&this.activeStepIndex!==null){let n=this.stepOrder[this.activeStepIndex],i=await this.steps[n]();if(this.isExitCmd(t))return this.cli.project.sandboxActive||await this.cli.project.dev(),await this.complete({exit:!0});if(i.postAction&&(this.cli._staticViewInputMsg=void 0),this.isIterationCmd(t))return this.reportAnalytics({exit:!1,step:this.stepOrder[this.activeStepIndex]}),await this.iterateStep({skip:!0});if(i.command==="run"&&t==="run"&&(!this.cli.args[0]||i.runArg&&i.runArg!==this.cli.args[0])){this.cli.logWarning(`Invalid command: "${this.cli.styles.bold(this.cli.styles.red(t))}" - expected "${i.runArg}"`);return}else if(i.command&&t!==i.command){let s=this.cli.styles.purple(n==="build"?"build":i.command);this.cli.logWarning(`Invalid command: "${this.cli.styles.bold(this.cli.styles.red(t))}" - expected "${this.cli.styles.bold(s)}"`);return}else{if(i.command==="deploy"&&t==="deploy"&&!((r=this.cli.names)!=null&&r.instanceName)){this.cli.logWarning('You must provide a stage name to deploy to. Example: "deploy prod"');return}if(n==="editor"&&t==="code")await Hwe.bash(this.cli);else{let s=Hwe[t];if(t&&i.event==="sync"){this.cli.logWarning("Waiting for changes to sync to the sandbox...");return}if(!s){this.cli.logError(`Command "${t}" not found - expected "${i.command}"`);return}this.cli.logSpace(),await s(this.cli)}try{return this.cli.viewInput(),this.iterateStep()}catch(s){throw new cd(s.message,"handle")}}}}async initTutorial(){var i,s,o,a,u,l,f,d;if(!this.cli.user)return await this.cli.quit("You must be logged in to start the Ampt tutorial");if(!this.cli.project.org)return await this.cli.quit("Expected Ampt organization to start the Ampt tutorial");this.name=`${(i=this.cli.user)==null?void 0:i.username}-ampt-tutorial`,this.inProgress=!0,this.tutorialModeStart=process.hrtime.bigint(),this.type=this.cli.fs.serviceFile?"basic":"full",Se.debug({type:this.type,name:this.name},"initTutorial");let t=this.cli.project.org;switch(this.type){case"full":{if(!await this.cli.fs.detectGit())return await this.cli.quit("Git is required to start the Ampt tutorial");let h=async()=>{this.name=await this.cli.promptServiceName(this.name);let g=new Dt({org:this.cli.project.org,serviceName:this.name});if(await g.get().catch(()=>{}))return this.cli.logWarning(`App ${this.cli.styles.bold(this.cli.styles.purple(this.name))} already exists in ${this.cli.styles.bold(this.cli.styles.darkPurple(t.orgName))}`),await this.cli.confirm(!0,"Would you like to overwrite it?")?g:h();let S=await this.cli.fs.isCwdEmpty(),b=!1;if(S&&(b=await this.cli.confirm(!0,"Would you like to start the tutorial in the current directory?")),!b){if(this.cli.fs.dirExists(this.name))if(this.cli.logWarning(`Directory "./${this.name}" already exists.`),await this.cli.confirm(!0,"Would you like to overwrite it?"))this.cli.logInfo(`Overwriting directory: ${this.cli.styles.bold(this.name)}`),this.cli.fs.deleteServiceDir(this.name);else return h();this.cli.fs.createServiceDir(this.name),this.cli.logInfo(`Created directory: ${this.cli.styles.bold(this.name)}`)}return g};this.cli.project.service=await h();let m=(s=this.cli.user)==null?void 0:s.generateSandboxName();this.cli.project.instance=new tr({org:t,service:this.cli.project.service,instanceName:m,cli:this.cli}),this.cli.viewSpinner("Cloning @ampt-templates/tutorial"),await this.cli.fs.cloneGitRepo({repoUrl:e.tutorialGitUrl}),await this.cli.fs.read({orgName:t.orgName,appName:this.name});break}case"basic":{if((a=(o=this.cli.fs.serviceFile)==null?void 0:o.ampt)!=null&&a.app){this.name=(l=(u=this.cli.fs.serviceFile)==null?void 0:u.ampt)==null?void 0:l.app,await this.cli.fs.read({orgName:t.orgName,appName:this.name}),this.stepOrder=e.basicTutorialSteps;let h=!!this.cli.fs.dataFile,m=(d=(f=this.cli.fs.serviceFile)==null?void 0:f.scripts)==null?void 0:d["ampt:build"],g=this.stepOrder.reduce((_,S)=>(S==="importData"||S==="postImportData")&&!h||(S==="build"||S==="postBuild")&&!m?_:[..._,S],[]);this.stepOrder=g}else return await this.cli.quit("Expected an Ampt app to start the Ampt tutorial");break}default:return await this.cli.quit("Expected a valid Ampt tutorial type")}await this.cli.fs.installDependenciesIfExists({viewSpinner:this.cli.viewSpinner.bind(this.cli)}),await this.cli.project.boot(this.type==="basic"?["analyze","detect","connect"]:["connect"]),this.type==="full"&&this.cli.logSpace(),this.cli.logGroup(this.welcomeMessage),this.activeStepIndex=0;let r=this.stepOrder[this.activeStepIndex],n=await this.steps[r]();this.reportAnalytics({exit:!1,event:"ampt.tutorial.started",step:r}),this.logStep({step:n})}logStep(t){let{step:r}=t;this.cli.logSpace(),r.postAction?(this.cli.logGroup([r.pre].flat(),!0),this.cli._staticViewInputMsg='Type "next" or hit enter to continue',this.cli.viewInput()):this.cli.logGroup([r.title,r.pre].flat(),!0)}setType(t){this.type=t}getDurationMins(){let t=process.hrtime.bigint()-this.tutorialModeStart;return Math.round(Number(t)/6e10)}async complete(t){var i,s;let{exit:r=!1}=t||{exit:!1},n=this.stepOrder[this.activeStepIndex];this.reportAnalytics({exit:r,step:r?n:void 0}),this.inProgress=!1,this.activeStepIndex=null,await((s=(i=this.cli)==null?void 0:i.user)==null?void 0:s.updatePreferences({showTutorial:!1})),this.completeMsg()}reportAnalytics(t){var s,o,a;let{event:r,step:n,exit:i=!1}=t;cr({eventName:r||(i?"ampt.tutorial.skipped":"ampt.tutorial.completed"),eventData:{type:this.type,step:n,durationMinutes:r?void 0:this.getDurationMins(),userName:(s=this.cli.user)==null?void 0:s.username,orgName:(o=this.cli.project.org)==null?void 0:o.orgName,serviceName:(a=this.cli.project.service)==null?void 0:a.serviceName}})}completeMsg(){this.cli.logGroup([this.cli.styles.bold("We hope you enjoy using Ampt!"),"If you have any questions or feedback, join our discord: https://getampt.com/discord","To read up on everything Ampt, check out our docs: https://getampt.com/docs",`You can always re-run this tutorial with the command "${this.cli.styles.bold("tutorial")}"`,`You can clear this output with the command "${this.cli.styles.bold("clear")}"`,"Happy coding! \u{1F680}"])}};ld.default.extend(zwe.default);ld.default.extend(Vwe.default);ld.default.updateLocale("en",{relativeTime:{future:"in %s",past:"%s ago",s:(e,t,r,n)=>e<=10?`${e} seconds`:e<=30?"several seconds":e<60?"less than a minute":`${e} seconds`,m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"}});var iv=($L(),mt(UL)),{version:Wwe}=wm(),D1t={dim:Zs.default.dim,darkPurple:Zs.default.hex("#B367FF"),purple:Zs.default.hex("#F952FF"),yellow:Zs.default.hex("#FFC700"),blue:Zs.default.hex("#727aff"),red:Zs.default.rgb(255,99,99),grey:Zs.default.hex("#324f59"),pastel:Zs.default.hex("#dbd8ca"),bold:Zs.default.bold,green:Zs.default.hex("#22b9b7")},hS=class e{static defaultSpinnerFrames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];session;messenger;version=Wwe;installedGlobally=KL.default;os=process.platform;user;fs;tutorial;project;showLogo=!0;fromClone=!1;inputValue;timer;isShellActive;isInteractive;isDevServerActive;isAnimationEnabled=!1;isCommandRunningInShell;buildRunningInShell;commandRunningInShellPromise;styles;icons;argv;startupOptions;options;args;names;command;orgName;org;service;serviceName;_exitCode=0;isGitPod=!1;isCodeSpaces=!1;isWebIde=!1;isBeta=!1;_lastSyncedAt;_lastSyncedAtInterval;_staticViewInputMsg;_activeOrgName;_activeServiceName;_allowedInputCharacter;_isLoggedTopPadding;_commandsHistory;_viewType;_viewMessage;_spinnerMessage;_spinnerStep;_isPromptActive;_promptResponse;_timerInterval;_spinnerInterval;_inputSpinnerInterval;_inputSpinnerStartedAt;_inputSpinnerStoppedAt;_tipsInterval;_tipsFrequency;_tipsCollectionIndex;_spinnerFrequency;_spinnerFrames;_spinnerFrameIndex;_selectItems;_selectedItemIndex;_selectedItem;_onQuit;_quitting;_suggestions;_commandsHistoryIndex;_devTipsCollection=["type `dev` to start running the dev server","type `stop` to stop a running dev server"];_cloudScriptsCollection=["add a `ampt:dev` script to package.json to run code within the Ampt context"];_tipsCollection=[];_xdgOpenInstalled=null;constructor(t){process.title="Ampt CLI",this.session=t,this.session.loadAmptConfig(),this.messenger=new F0,this.messenger.on("offline",(0,VL.default)(()=>{this.logError("Event Messenger offline")},1e3,!0)),this.messenger.on("online",(0,VL.default)(()=>{this.logInfo("Event Messenger online")},1e3,!0)),this.inputValue="",this.startupOptions={},this.options={},this.args=[],this.argv=[],this.command=void 0,this.names=void 0,this.icons={},this.commandRunningInShellPromise=null,this._allowedInputCharacter=/^[a-zA-Z0-9 ~:!@#$%^&*()-_=+.<>{}[\]"'/]+$/,this._viewType=null,this._viewMessage=void 0,this._spinnerMessage=null,this._spinnerStep=null,this._isPromptActive=void 0,this._promptResponse=void 0,this._commandsHistory=[],this._spinnerFrequency=100,this._spinnerFrames=e.defaultSpinnerFrames,this._spinnerFrameIndex=0,this.showLogo=!process.env.IS_CHILD_PROCESS&&!this.isGitPod&&this._canRenderBolt(),this.styles=D1t,this._startLastSyncedAtInterval(),this._initIcons(),this._initSuggestions(),process.env.AMPT_IS_GITPOD==="true"&&(this.isGitPod=!0,this.isWebIde=!0),process.env.AMPT_IS_CODESPACES==="true"&&(this.isCodeSpaces=!0,this.isWebIde=!0),this.isWebIde&&(this.isAnimationEnabled=!1),this.isBeta=this.version.includes("beta"),this.isInteractive=process.stdin.isTTY,this.fs=new tw({session:this.session}),this.project=new cS(this),this.tutorial=new dS(this)}async login(){return new Fo}setExitCode(t){this._exitCode=t}async start(t){let{_:r,...n}=(0,WL.default)(process.argv);if(this.startupOptions=n,this.fs.verbose=this.startupOptions.verbose,this.fromClone=(t==null?void 0:t.fromClone)||!1,this.os==="linux"&&(this._xdgOpenInstalled=await this.fs.detectXdgOpen()),r[2]!=="clone"&&process.platform!=="win32")try{Se.enable()}catch(i){console.error(i)}return this.run()}async run(t){try{if(this._parseCommand(t),this.tutorial.inProgress)return await this.tutorial.handle(this.command);if(this.command==="sandbox")return await iv.sandbox(this);if(this.command==="git"||this.command==="code")return await iv.bash(this);this.isShellActive||(this._hideCursor(),this._logLogo(),this.viewSpinner("Loading"),(this.command==="start"||this.command==="tutorial")&&await this._autoUpdate()),this._watchKeyboard();let r=["clone"],n=["promote","test"];if((this.command==="start"||this.command==="tutorial")&&(this.isShellActive=!0),this.isShellActive&&r.includes(this.command))throw new il(`Command "${this.command}" is currently not supported in the shell`);if(n.includes(this.command))throw new il(`Command "${this.command}" is not available.`);if(!iv[this.command]&&this.command!=="tutorial")throw new il(`Command "${this.command}" is not a valid command`);if(!this.user&&(this.user=await Fo.init(),!this.user.isLoggedIn())){this.logInfo("You must login to proceeed.");try{await this.user.performLogin(this)}catch(i){if(i.name==="UserDisabledError")return this.logError(i.message||"Your account has been disabled. Please contact support."),this._stop(0);throw i}}await this.messenger.connect(),this.command==="tutorial"&&(this.command="start",this.options.tutorial=!0),this.command==="dashboard"&&(this.command="open"),await iv[this.command](this),this.options={}}catch(r){if(r instanceof cd||r instanceof il)this.logError(r.message);else{if(r instanceof Rp)return this.logError(r.message),this._stop(this._exitCode);if(r.name==="InstancesLimitError"){let n=["share","deploy"].includes(this.command);return this.handleInstanceLimitExceeded({isDeploying:n})}else return r.name==="ServicesLimitError"?this.handleServiceLimitExceeded():(this.session.captureException(r),this.logError(`Something went wrong - please contact support and provide ${this.session.getSessionId()} as a reference ID`),this._stop(1))}}return this.isShellActive?this.viewInput():this._stop(this._exitCode)}handleServiceLimitExceeded(){let t="You have reached your app limit. Please upgrade your plan or delete an app.";return this.quit(t)}handleInstanceLimitExceeded(t){let{isDeploying:r=!1}=t||{},n="You have reached your environment limit. Please upgrade your plan or delete an environment.";if(!r)return this.quit(n);this.logWarning("Deployment failed"),this.logError(n),this.viewInput()}setProject(t){this.project=t}viewInput(t=this._formatLastSyncedAt()){this._timerInterval=clearInterval(this._timerInterval),this._spinnerInterval=clearInterval(this._spinnerInterval),this._startLastSyncedAtInterval(),this._switchView({viewType:"input",viewMessage:t})}spinInput(){if(this._viewType!=="input"){Se.error({_viewType:this._viewType},"wrong viewType in spinInput");return}this.isAnimationEnabled&&(this._inputSpinnerStartedAt=Date.now(),clearInterval(this._inputSpinnerInterval),this._inputSpinnerInterval=setInterval(()=>this.updateInputSpinner(),this._spinnerFrequency).unref())}viewSpinner(t="Loading",r){let{timer:n=!1}=r||{};if(!this.isInteractive){console.log(t);return}if(!this.isAnimationEnabled){this._switchView({viewType:"spinner",viewMessage:t});return}this._spinnerMessage=t,this._spinnerStep="",clearInterval(this._timerInterval),clearInterval(this._spinnerInterval),clearInterval(this._inputSpinnerInterval),this._timerInterval=void 0,this._spinnerInterval=void 0,this._inputSpinnerInterval=void 0,n&&(this.timer=0,this._timerInterval=setInterval(()=>this.timer=+this.timer+1,1e3).unref()),this._spinnerInterval=setInterval(()=>this._updateSpinner((this._spinnerMessage||"Loading")+(this._spinnerStep?` (${this._spinnerStep})`:""),{timer:n}),this._spinnerFrequency).unref()}updateLastSyncedAt(t){this._lastSyncedAt=t}updateInputSpinner(){this._spinnerFrameIndex=++this._spinnerFrameIndex%this._spinnerFrames.length,this._switchView({viewType:"input"})}stopSpinningInput(){this._inputSpinnerInterval&&(clearInterval(this._inputSpinnerInterval),this._inputSpinnerStoppedAt=Date.now(),this._inputSpinnerInterval=void 0),this.viewInput()}updateSpinnerStep(t){if(!process.stdin.isTTY){console.log(t);return}this._spinnerStep=t}pause(){this._clearIntervals(),this._switchView({viewType:"pause"}),this._eraseCursorLineAndBelow()}async prompt(t,r={}){for(this._isPromptActive=!0,r.default&&(this.inputValue=r.default),this.viewInput(t);!this._promptResponse;)await Cu(50);let n=this._promptResponse;return this.logInfo(`You've entered ${this.styles.bold(n)}.`),this._promptResponse=null,this._isPromptActive=!1,n}async promptServiceName(t=null){let r=await this.prompt("Enter a name for your app",{default:t});return r.match(/^[a-z0-9-]+$/)?r:(this.logError("App name must consist only of lowercase characters and hyphens. Please try again."),await this.promptServiceName())}async confirm(t=!1,r){r&&this.logQuestion(r);let n=["no","yes"],i=await this.select(t?n.reverse():n);return i==="yes"}async select(t=[],r=0){if(clearInterval(this._timerInterval),clearInterval(this._spinnerInterval),clearInterval(this._inputSpinnerInterval),this._timerInterval=void 0,this._spinnerInterval=void 0,this._inputSpinnerInterval=void 0,this._selectItems=t,this._selectedItemIndex=r,this._switchView({viewType:"select"}),this._selectItems.length===1)return this._selectedItem=this._selectItems[0],this._selectedItem;for(;!this._selectedItem;)await Cu(50);let n=this._selectedItem;return typeof n=="object"?this.logInfo(`You've selected ${this.styles.bold(n.title)}.`):this.logInfo(`You've selected ${this.styles.bold(n)}.`),this._selectedItem=null,this._selectedItemIndex=null,this._selectItems=[],n}async selectOrg(t,r){this.viewSpinner("Loading");let n,i=(t.orgs||[]).map(s=>s.orgName);return i.length>1?(this.logInfo(r||"Please select an organization."),n=await this.select(i)):n=i[0],n}async selectService(t,r){let n;this.viewSpinner("Loading");let i=(await t.listServicesWithInstances()).map(s=>s.serviceName);return Se.debug({servicesList:i},"select service"),i.length>1?(this.logInfo(r||"Please select a service."),n=await this.select(i)):n=i[0],n}async selectInstance({service:t,instanceType:r,instanceName:n,message:i}){let o=(await(t==null?void 0:t.listInstances().catch(()=>[]))||[]).filter(l=>!r||l.instanceType===r).map(l=>({instanceName:l.instanceName,region:l.region,displayRegion:l.region||"",display:`${l.instanceName} (${l.region})`}));if(n)return o.find(l=>l.instanceName===n)||{instanceName:n,isNewInstance:!0};if(o.length===0)return{instanceName:void 0};if(o.length===1)return{instanceName:o[0].instanceName,isNewInstance:!1};this.logInfo(i||"Please select a stage.");let a=await this.select(o.map(l=>l.display));return{instanceName:o.find(l=>l.display===a).instanceName,isNewInstance:!1}}logSuccess(t,r=0){this.log(`${this.icons.tick} ${t}`,r)}logError(t,r=0){this.log(`${this.icons.cross} ${this.styles.bold(this.styles.red(t))}`,r)}logCancelled(){this.logError("Cancelled")}logInfo(t,r=0){this.log(`${this.icons.info} ${t}`,r)}logWarning(t,r=0){this.log(`${this.icons.warning} ${t}`,r)}logQuestion(t,r=0){this.log(`${this.icons.question} ${t}`,r)}logGroup(t,r=!0){t.forEach((n,i)=>{let o=r&&i===0?`${this.icons.arrow} ${this.styles.bold(n)}`:` ${this.icons.dot} ${n}`;this.log(o,i>0?2:0)})}logUrl(t,r=0){this.log(`${this.icons.arrow} ${t}`,r)}logTime(t,r=0){this.log(`${this.styles.dim(`${new Date(Date.now()).toLocaleTimeString()} ${this.icons.line}`)} ${t}`,r)}log(t="",r=0){this._ensureTopPadding(),this._eraseCursorLineAndBelow(),this._log(`${" ".repeat(r)}${t}
|
|
281
281
|
`),this._view()}logSpace(){this.log(" ")}write(t=""){this._ensureTopPadding(),this._eraseCursorLineAndBelow(),this._log(t),this._view()}onQuit(t){this._onQuit=t}async quit(t="Stopped"){return this.inputValue="",this._clearIntervals(),this._quitting||this.logError(t),this._eraseCursorLineAndBelow(),!this._quitting&&this._onQuit&&(this._quitting=!0,await QZ(this._onQuit(),1e3)),this.isDevServerActive&&await Qn.stop(this,{orgName:this.orgName,serviceName:this.serviceName}),this._stop()}async startSession(){var t;try{await this.project.init()}catch(r){return await this.quit(`Something went wrong while starting the session: ${r.message}`)}if(!this.project)return await this.quit("Project was not initialized");this.tutorial.inProgress&&((t=this._suggestions)==null||t.push("skip","next","done")),this.tutorial.inProgress||await this.project.boot()}async checkForAmptPackageUpdates(){if(this.fs.shouldCheckForAmptDependencyUpdates()&&!this.isWebIde){this.viewSpinner("Checking for package updates");let t=await this.fs.detectOutdatedAmptDependencies();if(t.length&&!this.fromClone){this._printOutOfDatePackages(t),this.logSpace();let r=t.filter(n=>!n.majorChange);r.length&&(this.logQuestion("Would you like to update them now?"),await this.confirm(!0)?await this.fs.updateOutdatedAmptDependencies(this,r):(this.logInfo("Skipping package updates"),this.logWarning("You may experience issues using outdated @ampt packages.")))}}}async isAmptShellRunning(t){let{orgName:r,serviceName:n}=t;try{let i=Tp(r,n),s=JSON.parse(await(0,Zwe.readFile)(i,"utf8"));return RR(s.pid)?!0:((0,fd.removeSync)(Tp(r,n)),!1)}catch{return!1}}async writeAmptShellActivityFile(t){let{orgName:r,serviceName:n}=t,i=Tp(r,n);(0,fd.ensureFileSync)(i),(0,fd.writeFileSync)(i,JSON.stringify({pid:process.pid},null,4))}devServerOn(){this.isDevServerActive=!0,this.viewInput()}devServerOff(){this.isDevServerActive=!1,this.viewInput()}buildRunning(t){this.buildRunningInShell=t}bindService({orgName:t,serviceName:r}){this.orgName=t,this.serviceName=r}_switchView({viewType:t,viewMessage:r}){return t&&(this._viewType=t),typeof r<"u"&&(this._viewMessage=r),this._staticViewInputMsg&&(this._viewMessage=this._staticViewInputMsg),this._view()}_stop(t=0){this._clearIntervals(),process.stdin.pause(),this._eraseCursorLineAndBelow(),t===0&&this._log(`
|
|
282
282
|
`),this._showCursor();try{if(/^win/.test(process.platform))(0,GL.execSync)(`taskkill /PID ${process.pid} /T /F`);else try{process.kill(-process.pid,"SIGINT")}catch{process.kill(-process.ppid,"SIGINT")}}catch(r){Se.debug({error:r.message},"process.kill failed"),process.env.SLS_DEBUG&&this._log(r.message)}process.exit(t)}_clearIntervals(){clearInterval(this._timerInterval),clearInterval(this._spinnerInterval),clearInterval(this._inputSpinnerInterval),clearInterval(this._tipsInterval),clearInterval(this._lastSyncedAtInterval),this._timerInterval=void 0,this._spinnerInterval=void 0,this._inputSpinnerInterval=void 0,this._tipsInterval=void 0,this._lastSyncedAtInterval=void 0}_parseCommand(t){var a,u;let r=t&&t.length>0?iJ(t):process.argv.slice(2),n=(0,WL.default)(r);this.command=(a=n._[0])==null?void 0:a.toLowerCase(),this.args=(u=n._)==null?void 0:u.slice(1);let{_:i,...s}=n;this.options=Object.assign({},this.startupOptions,s),this.argv=r,(this.options.help||this.options.h)&&(this.command="help"),(this.options.version||this.options.v)&&(this.command="version"),this.names=hV(this.args[0]),this.names.orgName=this.names.orgName||this.options.org,this.names.serviceName=this.names.serviceName||this.options.app,this.names.instanceName=this.names.instanceName||this.options.stage||this.options.env||this.options.instance,t==="start"&&delete iv.start,!t&&(!this.command||this.command==="start")&&(this.command="start"),this.command==="dev"&&(this.isShellActive?(this.args[0]=this.command,this.command="run"):(this.command="start",this.options.dev=!0)),this.command==="build"&&(this.args[0]=this.command,this.command="run"),this.command==="npm"&&(this.command=this.args[0],this.args.shift(),this.argv.shift()),this.isAnimationEnabled=this.options.animation!==!1,Se.debug({args:this.args},"cli args"),Se.debug({...this.options},"cli options"),Se.debug({...this.names},"cli names")}_logLogo(){if(!this.showLogo)return;let t=HL.default.EOL;t+="ampt ",t+=`${this.icons.bolt}`,process.env.AMPT_STAGE!=="prod"&&(t+=`(${process.env.AMPT_STAGE})`),this.isBeta&&(t+=`${this.styles.dim("[beta]")}`),t+=HL.default.EOL,this._log(t)}_log(t){process.stdout.write(t)}_showCursor(){this._log(Cl.default.cursorShow)}_hideCursor(){this._log(Cl.default.cursorHide)}_moveCursorLeft(){this._log(Cl.default.cursorLeft)}_moveCursorUp(t){this._log(Cl.default.cursorUp(t))}_eraseCursorLineAndBelow(){this._log(Cl.default.eraseDown)}_restorCursorPosition(t){let r=this._getRelativeVerticalCursorPosition(t);this._moveCursorUp(r),this._moveCursorLeft()}_getRelativeVerticalCursorPosition(t){let n=(0,Xwe.default)(t).split(`
|
|
283
283
|
`),i=n.length;for(let o of n){let a=Number(o.length),u=Number(process.stdout.columns),l=Math.floor(a/u);i+=l}return 1+i}_view(){this._hideCursor();let t=this._getView();t&&(this._eraseCursorLineAndBelow(),this._log(`
|