@ampt/cli 1.0.38-beta.0 → 1.0.38-beta.1
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/cli.js +2 -2
- package/dist/cli.js.map +2 -2
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -139,7 +139,7 @@ Url: `+ob(e)),!0)}fm._shouldDropEvent=UY;function J7e(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;UKe(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=jKe.default(s);s.write(`${u}\r
|
|
141
141
|
`);let{statusCode:m,buffered:g}=yield h;if(m===200){if(t.once("socket",BKe),r.secureEndpoint){mm("Upgrading socket connection to TLS");let S=r.servername||r.host;return eZ.default.connect(Object.assign(Object.assign({},HKe(r,"host","hostname","path","port")),{socket:s,servername:S}))}return s}s.destroy();let _=new QY.default.Socket({writable:!1});return _.readable=!0,t.once("socket",S=>{mm("replaying proxy buffer for failed request"),LKe.default(S.listenerCount("data")>0),S.push(g),S.push(null)}),_})}};Gc.default=FO;function BKe(e){e.resume()}function UKe(e,t){return!!(!t&&e===80||t&&e===443)}function $Ke(e){return typeof e=="string"?/^https:?$/i.test(e):!1}function HKe(e,...t){let r={},n;for(n in e)t.includes(n)||(r[n]=e[n]);return r}});var lb=v((BO,rZ)=>{"use strict";var WKe=BO&&BO.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},MO=WKe(tZ());function jO(e){return new MO.default(e)}(function(e){e.HttpsProxyAgent=MO.default,e.prototype=MO.default.prototype})(jO||(jO={}));rZ.exports=jO});var sZ=v(UO=>{Object.defineProperty(UO,"__esModule",{value:!0});var zKe=(gn(),mt(mn)),nZ=Yr(),iZ=require("http"),VKe=ub(),GKe=function(e){zKe.__extends(t,e);function t(r){var n=e.call(this,r)||this;n.options=r;var i=n._getProxy("http");return n.module=iZ,n.client=i?new(lb())(i):new iZ.Agent({keepAlive:!1,maxSockets:30,timeout:2e3}),n}return t.prototype.sendEvent=function(r){return this._send(nZ.eventToSentryRequest(r,this._api),r)},t.prototype.sendSession=function(r){return this._send(nZ.sessionToSentryRequest(r,this._api),r)},t}(VKe.BaseTransport);UO.HTTPTransport=GKe});var uZ=v($O=>{Object.defineProperty($O,"__esModule",{value:!0});var KKe=(gn(),mt(mn)),oZ=Yr(),aZ=require("https"),XKe=ub(),YKe=function(e){KKe.__extends(t,e);function t(r){var n=e.call(this,r)||this;n.options=r;var i=n._getProxy("https");return n.module=aZ,n.client=i?new(lb())(i):new aZ.Agent({keepAlive:!1,maxSockets:30,timeout:2e3}),n}return t.prototype.sendEvent=function(r){return this._send(oZ.eventToSentryRequest(r,this._api),r)},t.prototype.sendSession=function(r){return this._send(oZ.sessionToSentryRequest(r,this._api),r)},t}(XKe.BaseTransport);$O.HTTPSTransport=YKe});var lZ=v(HO=>{Object.defineProperty(HO,"__esModule",{value:!0});var ZKe=Yr(),JKe=Rt(),QKe=require("http"),eXe=require("https"),cZ=require("url");function tXe(e){var t,r=new cZ.URL(e.url),n=r.protocol==="https:",i=rXe(r,e.proxy||(n?process.env.https_proxy:void 0)||process.env.http_proxy),s=n?eXe:QKe,o=i?new(lb())(i):new s.Agent({keepAlive:!1,maxSockets:30,timeout:2e3}),a=nXe(e,(t=e.httpModule,t??s),o);return ZKe.createTransport({bufferSize:e.bufferSize},a)}HO.makeNodeTransport=tXe;function rXe(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 nXe(e,t,r){var n=new cZ.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=JKe.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 WO=v(hp=>{Object.defineProperty(hp,"__esModule",{value:!0});var iXe=ub();hp.BaseTransport=iXe.BaseTransport;var sXe=sZ();hp.HTTPTransport=sXe.HTTPTransport;var oXe=uZ();hp.HTTPSTransport=oXe.HTTPSTransport;var aXe=lZ();hp.makeNodeTransport=aXe.makeNodeTransport});var XO=v(KO=>{Object.defineProperty(KO,"__esModule",{value:!0});var mp=(gn(),mt(mn)),zO=Yr(),uXe=Jf(),VO=Rt(),fZ=AO(),GO=WO(),cXe=function(e){mp.__extends(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.eventFromException=function(r,n){return VO.resolvedSyncPromise(fZ.eventFromUnknownInput(r,n))},t.prototype.eventFromMessage=function(r,n,i){return n===void 0&&(n=uXe.Severity.Info),VO.resolvedSyncPromise(fZ.eventFromMessage(r,n,i,this._options.attachStacktrace))},t.prototype._setupTransport=function(){if(!this._options.dsn)return e.prototype._setupTransport.call(this);var r=VO.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=zO.initAPIDetails(n.dsn,n._metadata,n.tunnel),s=zO.getEnvelopeEndpointWithUrlEncodedAuth(i.dsn,i.tunnel);return this._newTransport=GO.makeNodeTransport({url:s,headers:n.headers,proxy:n.httpProxy,caCerts:n.caCerts}),r.protocol==="http"?new GO.HTTPTransport(n):new GO.HTTPSTransport(n)},t}(zO.BaseBackend);KO.NodeBackend=cXe});var JO=v(ZO=>{Object.defineProperty(ZO,"__esModule",{value:!0});var lXe=(gn(),mt(mn)),YO=Yr(),fXe=mo(),pZ=Rt(),pXe=XO(),dZ=xu(),dXe=function(e){lXe.__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:YO.SDK_VERSION}],version:YO.SDK_VERSION},n=e.call(this,pXe.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 fXe.SessionFlusher(this.getTransport(),{release:n,environment:i}):dZ.IS_DEBUG_BUILD&&pZ.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():dZ.IS_DEBUG_BUILD&&pZ.logger.warn("Discarded request mode session because autoSessionTracking option was disabled")},t}(YO.BaseClient);ZO.NodeClient=dXe});var yZ=v(QO=>{Object.defineProperty(QO,"__esModule",{value:!0});var mZ=(gn(),mt(mn)),hZ=Yr(),gZ=Rt(),hXe=require("util"),vZ=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(){var t,r;try{for(var n=mZ.__values(["debug","info","warn","error","log"]),i=n.next();!i.done;i=n.next()){var s=i.value;gZ.fill(console,s,mXe(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}();QO.Console=vZ;function mXe(e){return function(r){var n=gZ.severityFromString(e);return function(){hZ.getCurrentHub().getIntegration(vZ)&&hZ.getCurrentHub().addBreadcrumb({category:"console",level:n,message:hXe.format.apply(void 0,arguments)},{input:mZ.__spread(arguments),level:e}),r.apply(this,arguments)}}}});var wZ=v(Kc=>{Object.defineProperty(Kc,"__esModule",{value:!0});var eR=(gn(),mt(mn)),gXe=Yr(),vXe=Rt(),_Z=require("url"),xZ=vXe.parseSemver(process.versions.node);function yXe(e){var t,r=(t=gXe.getCurrentHub().getClient())===null||t===void 0?void 0:t.getDsn();return r?e.includes(r.host):!1}Kc.isSentryRequest=yXe;function bZ(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=bZ;function _Xe(e,t,r){var n,i,s;if(!e)return e;var o=eR.__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=bZ(t)),!((s=u)===null||s===void 0)&&s.startsWith("///")&&(u=u.slice(2)),a+" "+u}Kc.cleanSpanDescription=_Xe;function tR(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=tR;function xXe(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=tR(new _Z.URL(t[0])):t[0]instanceof _Z.URL?d=tR(t[0]):d=t[0],t.length===2&&(d=eR.__assign(eR.__assign({},d),t[1])),d.protocol===void 0&&(xZ.major&&xZ.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=xXe});var AZ=v(nR=>{Object.defineProperty(nR,"__esModule",{value:!0});var SZ=(gn(),mt(mn)),rR=Yr(),gp=Rt(),bXe=xu(),gm=wZ(),EZ=gp.parseSemver(process.versions.node),CZ=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=wXe(this._breadcrumbs,this._tracing),r=require("http");if(gp.fill(r,"get",t),gp.fill(r,"request",t),EZ.major&&EZ.major>8){var n=require("https");gp.fill(n,"get",t),gp.fill(n,"request",t)}}},e.id="Http",e}();nR.Http=CZ;function wXe(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=rR.getCurrentHub().getScope();if(m&&t&&(h=m.getSpan(),h)){d=h.startChild({description:(l.method||"GET")+" "+f,op:"http.client"});var g=d.toTraceparent();bXe.IS_DEBUG_BUILD&&gp.logger.log("[Tracing] Adding sentry-trace header "+g+" to outgoing request to "+f+": "),l.headers=SZ.__assign(SZ.__assign({},l.headers),{"sentry-trace":g})}return n.apply(a,u).once("response",function(_){var S=this;e&&TZ("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&&TZ("error",f,_),t&&d&&(d.setHttpStatus(500),d.description=gm.cleanSpanDescription(d.description,l,_),d.finish())})}}}function TZ(e,t,r,n){rR.getCurrentHub().getIntegration(CZ)&&rR.getCurrentHub().addBreadcrumb({category:"http",data:{method:r.method,status_code:n&&n.statusCode,url:t},type:"http"},{event:e,request:r,response:n})}});var oR=v(sR=>{Object.defineProperty(sR,"__esModule",{value:!0});var SXe=Yr(),iR=Rt(),IZ=xu(),EXe=2e3;function TXe(e){console.error(e&&e.stack?e.stack:e);var t=SXe.getCurrentHub().getClient();t===void 0&&(IZ.IS_DEBUG_BUILD&&iR.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||EXe;iR.forget(t.close(n).then(function(i){i||IZ.IS_DEBUG_BUILD&&iR.logger.warn("We reached the timeout for emptying the request buffer, still exiting now!"),global.process.exit(1)}))}sR.logAndExitProcess=TXe});var RZ=v(aR=>{Object.defineProperty(aR,"__esModule",{value:!0});var NZ=Yr(),CXe=Jf(),AXe=Rt(),IXe=xu(),OZ=oR(),NXe=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=OZ.logAndExitProcess,l=NZ.getCurrentHub().getClient();if(t._options.onFatalError?u=t._options.onFatalError:l&&l.getOptions().onFatalError&&(u=l.getOptions().onFatalError),n)s?(IXe.IS_DEBUG_BUILD&&AXe.logger.warn("uncaught exception after calling fatal error shutdown callback - this is bad! forcing shutdown"),OZ.logAndExitProcess(a)):i||(i=!0,setTimeout(function(){s||(s=!0,u(o,a))},r));else{var f=NZ.getCurrentHub();o=a,n=!0,f.getIntegration(e)?f.withScope(function(d){d.setLevel(CXe.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}();aR.OnUncaughtException=NXe});var PZ=v(uR=>{Object.defineProperty(uR,"__esModule",{value:!0});var OXe=Yr(),kZ=Rt(),RXe=oR(),kXe=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=OXe.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"?kZ.consoleSandbox(function(){console.warn(r),console.error(t&&t.stack?t.stack:t)}):this._options.mode==="strict"&&(kZ.consoleSandbox(function(){console.warn(r)}),RXe.logAndExitProcess(t))},e.id="OnUnhandledRejection",e}();uR.OnUnhandledRejection=kXe});var qZ=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 lR=v(pb=>{Object.defineProperty(pb,"__esModule",{value:!0});var wu=(gn(),mt(mn)),PXe=Yr(),qXe=Rt(),DXe=require("fs"),LXe=qZ(),cR=new LXe.LRUMap(100),FXe=7;function MXe(e){return new Promise(function(t,r){DXe.readFile(e,"utf8",function(n,i){n?r(n):t(i)})})}function jXe(){cR.clear()}pb.resetFileContentCache=jXe;var BXe=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=PXe.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:FXe},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 wu.__awaiter(this,void 0,void 0,function(){var i,s,o,a,u,l;return wu.__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=wu.__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 wu.__awaiter(this,void 0,void 0,function(){var r,n,i,s,o,a,u,l,f;return wu.__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=wu.__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,UXe(s.filename)]:[3,4]);case 3:if(o=d.sent(),o)try{a=o.split(`
|
|
142
|
-
`),qXe.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=BXe;function UXe(e){return wu.__awaiter(this,void 0,void 0,function(){var t,r,n;return wu.__generator(this,function(i){switch(i.label){case 0:if(t=cR.get(e),t!==void 0)return[2,t];r=null,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,MXe(e)];case 2:return r=i.sent(),[3,4];case 3:return n=i.sent(),[3,4];case 4:return cR.set(e,r),[2,r]}})})}});var DZ=v(pR=>{Object.defineProperty(pR,"__esModule",{value:!0});var db=(gn(),mt(mn)),fR=Yr(),hb=Rt(),$Xe=AO(),HXe=lR(),WXe="cause",zXe=5,VXe=function(){function e(t){t===void 0&&(t={}),this.name=e.id,this._key=t.key||WXe,this._limit=t.limit||zXe}return e.prototype.setupOnce=function(){fR.addGlobalEventProcessor(function(t,r){var n=fR.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=$Xe.exceptionFromError(t[r]),o=fR.getCurrentHub().getIntegration(HXe.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}();pR.LinkedErrors=VXe});var jZ=v(hR=>{Object.defineProperty(hR,"__esModule",{value:!0});var LZ=(gn(),mt(mn)),FZ=require("fs"),MZ=require("path"),dR;function GXe(){try{return require.cache?Object.keys(require.cache):[]}catch{return[]}}function KXe(){var e=require.main&&require.main.paths||[],t=GXe(),r={},n={};return t.forEach(function(i){var s=i,o=function(){var a=s;if(s=MZ.dirname(a),!(!s||a===s||n[a])){if(e.indexOf(s)<0)return o();var u=MZ.join(a,"package.json");if(n[a]=!0,!FZ.existsSync(u))return o();try{var l=JSON.parse(FZ.readFileSync(u,"utf8"));r[l.name]=l.version}catch{}}};o()}),r}var XXe=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(t,r){var n=this;t(function(i){return r().getIntegration(e)?LZ.__assign(LZ.__assign({},i),{modules:n._getModules()}):i})},e.prototype._getModules=function(){return dR||(dR=KXe()),dR},e.id="Modules",e}();hR.Modules=XXe});var mR=v(pa=>{Object.defineProperty(pa,"__esModule",{value:!0});var YXe=yZ();pa.Console=YXe.Console;var ZXe=AZ();pa.Http=ZXe.Http;var JXe=RZ();pa.OnUncaughtException=JXe.OnUncaughtException;var QXe=PZ();pa.OnUnhandledRejection=QXe.OnUnhandledRejection;var eYe=DZ();pa.LinkedErrors=eYe.LinkedErrors;var tYe=jZ();pa.Modules=tYe.Modules;var rYe=lR();pa.ContextLines=rYe.ContextLines});var vR=v(vo=>{Object.defineProperty(vo,"__esModule",{value:!0});var vm=(gn(),mt(mn)),Su=Yr(),BZ=mo(),gR=Rt(),nYe=require("domain"),iYe=JO(),UZ=xu(),vp=mR();vo.defaultIntegrations=[new Su.Integrations.InboundFilters,new Su.Integrations.FunctionToString,new vp.ContextLines,new vp.Console,new vp.Http,new vp.OnUncaughtException,new vp.OnUnhandledRejection,new vp.LinkedErrors];function sYe(e){e===void 0&&(e={});var t,r=BZ.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:vo.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=$Z();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),nYe.active&&BZ.setHubOnCarrier(r,Su.getCurrentHub()),Su.initAndBind(iYe.NodeClient,e),e.autoSessionTracking&&lYe()}vo.init=sYe;function oYe(){return Su.getCurrentHub().lastEventId()}vo.lastEventId=oYe;function aYe(e){return vm.__awaiter(this,void 0,void 0,function(){var t;return vm.__generator(this,function(r){return t=Su.getCurrentHub().getClient(),t?[2,t.flush(e)]:(UZ.IS_DEBUG_BUILD&&gR.logger.warn("Cannot flush events. No client defined."),[2,Promise.resolve(!1)])})})}vo.flush=aYe;function uYe(e){return vm.__awaiter(this,void 0,void 0,function(){var t;return vm.__generator(this,function(r){return t=Su.getCurrentHub().getClient(),t?[2,t.close(e)]:(UZ.IS_DEBUG_BUILD&&gR.logger.warn("Cannot flush events and disable SDK. No client defined."),[2,Promise.resolve(!1)])})})}vo.close=uYe;function cYe(e){if(e===void 0)return!1;var t=e&&e.getOptions();return t&&t.autoSessionTracking!==void 0?t.autoSessionTracking:!1}vo.isAutoSessionTrackingEnabled=cYe;function $Z(e){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;var t=gR.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}vo.getSentryRelease=$Z;function lYe(){var e=Su.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 WZ=v(_R=>{Object.defineProperty(_R,"__esModule",{value:!0});var HZ=(gn(),mt(mn)),mb=require("fs"),yR=require("path");function fYe(e){var t=yR.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=yR.join(n,s);return mb.statSync(o).isDirectory()?HZ.__spread(i,r(o)):HZ.__spread(i,[o])},[])};return r(t).map(function(n){return yR.relative(t,n)})}_R.deepReadDirSync=fYe});var zZ=v(xR=>{"use strict";xR.parse=hYe;xR.serialize=mYe;var pYe=decodeURIComponent,dYe=encodeURIComponent,gb=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function hYe(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||pYe,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]=gYe(f,s)}}}return r}function mYe(e,t,r){var n=r||{},i=n.encode||dYe;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 gYe(e,t){try{return t(e)}catch{return e}}});var GZ=v(Zc=>{Object.defineProperty(Zc,"__esModule",{value:!0});var yo=(gn(),mt(mn)),Xc=Yr(),Yc=Rt(),vYe=zZ(),yYe=require("domain"),_Ye=require("os"),xYe=require("url"),bYe=xu(),ym=vR();function wYe(){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(yo.__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(){SYe(s,t),s.setHttpStatus(r.statusCode),s.finish()})}),n()}}Zc.tracingHandler=wYe;function SYe(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 EYe(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 TYe=["id","username","email"];function CYe(e,t){var r={},n=Array.isArray(t)?t:TYe;return n.forEach(function(i){e&&i in e&&(r[i]=e[i])}),r}var AYe=["cookies","data","headers","method","query_string","url"];function yb(e,t){t===void 0&&(t=AYe);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||vYe.parse(n.cookie||"");break;case"query_string":r.query_string=e.query||xYe.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 VZ(e,t,r){if(r=yo.__assign({ip:!1,request:!0,serverName:!0,transaction:!0,user:!0,version:!0},r),r.version&&(e.contexts=yo.__assign(yo.__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=yo.__assign(yo.__assign({},e.request),n)}if(r.serverName&&!e.server_name&&(e.server_name=global.process.env.SENTRY_NAME||_Ye.hostname()),r.user){var i=t.user&&Yc.isPlainObject(t.user)?CYe(t.user,r.user):{};Object.keys(i)&&(e.user=yo.__assign(yo.__assign({},e.user),i))}if(r.ip){var s=t.ip||t.connection&&t.connection.remoteAddress;s&&(e.user=yo.__assign(yo.__assign({},e.user),{ip_address:s}))}return r.transaction&&!e.transaction&&(e.transaction=EYe(t,r.transaction)),e}Zc.parseRequest=VZ;function IYe(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){bYe.IS_DEBUG_BUILD&&Yc.logger.error(g),u.call(m,f,d,h)})}}var l=yYe.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 VZ(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=IYe;function NYe(e){var t=e.status||e.statusCode||e.status_code||e.output&&e.output.statusCode;return t?parseInt(t,10):500}function OYe(e){var t=NYe(e);return t>=500}function RYe(e){return function(r,n,i,s){var o=e&&e.shouldHandleError||OYe;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=RYe});var XZ=v(vt=>{Object.defineProperty(vt,"__esModule",{value:!0});var KZ=(gn(),mt(mn)),kYe=Jf();vt.Severity=kYe.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 PYe=XO();vt.NodeBackend=PYe.NodeBackend;var qYe=JO();vt.NodeClient=qYe.NodeClient;var yp=vR();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 DYe=WZ();vt.deepReadDirSync=DYe.deepReadDirSync;var LYe=OO();vt.SDK_NAME=LYe.SDK_NAME;var FYe=Yr(),MYe=mo(),jYe=require("domain"),BYe=GZ();vt.Handlers=BYe;var UYe=mR(),$Ye=WO();vt.Transports=$Ye;var HYe=KZ.__assign(KZ.__assign({},FYe.Integrations),UYe);vt.Integrations=HYe;var _m=MYe.getMainCarrier();_m.__SENTRY__&&(_m.__SENTRY__.extensions=_m.__SENTRY__.extensions||{},_m.__SENTRY__.extensions.domain=_m.__SENTRY__.extensions.domain||jYe)});var YZ,bm,ZZ,xm,bR,$t,_o=oe(()=>{"use strict";YZ=ve(sX()),bm=ve(XZ());ur();_p();ZZ=()=>{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};ZZ()&&bm.init({dsn:"https://5f27cbf3265a475abff6b7999ae73179@o1265020.ingest.sentry.io/6448443",tracesSampleRate:1});bR=class{constructor(){Rr(this,"orgName");Rr(this,"user");Rr(this,"config");kd(this,xm,(0,YZ.ulid)());Rr(this,"auth");Rr(this,"captureException",t=>{da.error({err:t},"captureException"),ZZ()&&bm&&bm.captureException(t,{tags:{sessionId:Ns(this,xm)}})})}getSessionId(){return Ns(this,xm)}loadAmptConfig(){this.config=wR(),da.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},SR(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}}}),da.debug({userName:t.username},"saved config file"),this.setUser(t),da.debug({userName:t.username},"set user in session")}}shouldPromptTutorial(){var t,r,n,i,s,o,a;if((t=this.user)!=null&&t.preferences){let u=((n=(r=this.user)==null?void 0:r.preferences)==null?void 0:n.connectedCount)>=3,l=((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)??!1,allowDismiss:l?!0:u}}return{showTutorial:!1,allowDismiss:!1}}};xm=new WeakMap;$t=new bR});var _b,xb,Eu,ER,we,da,_p=oe(()=>{"use strict";_b=ve(nX()),xb=ve(require("path")),Eu=ve(mc());_o();ER=class{logger;enabled;logFilePath;logToConsole;pinoArgs;pinoDestination;initLogDestination(){try{(0,Eu.removeSync)(this.logFilePath)}catch(t){process.env.AMPT_DEBUG&&console.error("Error removing log file: ",t)}finally{if(this.enabled)try{(0,Eu.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,Eu.existsSync)(t)||(0,Eu.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)}},we=new ER,da=we});var wm=v((G2t,WYe)=>{WYe.exports={name:"@ampt/cli",version:"1.0.38-beta.0",description:"Ampt command line interface",main:"./dist/index.js",types:"./types/index.d.ts",engines:{node:">=16.0.0 <=18.19.1"},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 QZ,JZ,zYe,TR,CR,$e,Q2t,AR=oe(()=>{"use strict";QZ=ve(require("https"));hx();Z9();_p();_o();({version:JZ}=wm()),zYe=new QZ.default.Agent({keepAlive:!0}),TR=class e{axios;static config(){return{apiEndpoint:process.env.AMPT_ENDPOINT,apiKey:process.env.AMPT_API_KEY}}constructor(){this.axios=lo.create({httpsAgent:zYe}),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&&da.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,O,U,M,F,R;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/${JZ}`,u["ampt-version"]=JZ,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 da.debug({method:o,url:d,sessionId:m},"request"),(await this.axios(g)).data}catch(P){if(((S=P.response)==null?void 0:S.status)===403&&((C=(b=P.response)==null?void 0:b.data)==null?void 0:C.code)==="EXPIRED_TOKEN")return da.debug({status:P.response.status,code:P.response.data.code},"Token expired, refreshing"),await((T=$t.user)==null?void 0:T.refreshAccessToken()),this.request(t);if(((w=P.response)==null?void 0:w.status)===403){let N=new Error("Forbidden");throw N.message="You do not have permission to access this resource.",N.name="ForbiddenError",N}if(((E=P.response)==null?void 0:E.status)===404)return;if(((O=P.response)==null?void 0:O.status)===409){let N=new Error("Conflict");throw N.message="Conflict",N.name="ConflictError",N}if(P.response&&P.response.data){let N=new Error(P.response.data.message||P.response.data);throw(U=P.response.data.message)!=null&&U.includes("Request Entity Too Large")?(N.message="Your code size is too large. Try reducing it by adding to .deployignore",N.name="EntityTooLargeError"):(M=P.response.data.message)!=null&&M.includes("User disabled")?(N.message=P.response.data.detail||"Your account has been disabled. Please contact support@getampt.com for more information.",N.name="UserDisabledError"):(F=P.response.data.message)!=null&&F.includes("App limit reached")?(N.message="You have reached your Organization's app limit. Please upgrade your plan or delete an app.",N.name="AppLimitReachedError"):(R=P.response.data.message)!=null&&R.includes("Instance limit reached")?(N.message="You have reached your Organization's environment limit. Please upgrade your plan or delete an environment.",N.name="EnvironmentLimitReachedError"):N.name=P.response.data.name||null,N.statusCode=P.response.data.statusCode||P.response.status||null,N}throw P}}},CR=new TR,$e=CR.request.bind(CR),Q2t=CR.request});var eJ,tJ=oe(()=>{"use strict";eJ=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,rJ=oe(()=>{"use strict";bb=e=>e?e===0?"less than a second":e===1?"1 second":`${e} seconds`:"a few seconds"});var Tu,IR=oe(()=>{"use strict";Tu=async e=>new Promise(t=>setTimeout(t,e).unref())});var cr,NR,OR=oe(()=>{"use strict";ur();_o();cr=e=>{(async()=>{let{eventName:t,eventData:r={}}=e,n=$t.orgName;if(!n){we.warn({eventName:t},"Could not send report - no org name found");return}try{await $e({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)}})()},NR=cr});async function wb(e){try{let t="https://ampt.dev/public/templates/manifest-tags.json",{data:r}=await lo.get(t);return r.filter(n=>n.tags.includes("starter"))}catch(t){return process.env.AMPT_DEBUG&&e.logError(t),[]}}var RR=oe(()=>{"use strict";hx()});var kR,nJ,PR=oe(()=>{"use strict";kR=e=>{try{return process.kill(e,0)}catch(t){return t.code==="EPERM"}},nJ=kR});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 iJ=oe(()=>{"use strict"});function sJ(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 oJ=oe(()=>{"use strict"});var aJ=oe(()=>{"use strict"});var uJ=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,O=256,U=512,M=30,F="...",R=800,P=16,N=1,z=2,Y=3,j=1/0,B=9007199254740991,ee=17976931348623157e292,V=0/0,ie=4294967295,pe=ie-1,ye=ie>>>1,He=[["ary",E],["bind",g],["bindKey",_],["curry",b],["curryRight",C],["flip",U],["partial",T],["partialRight",w],["rearg",O]],ot="[object Arguments]",Ye="[object Array]",nt="[object AsyncFunction]",Re="[object Boolean]",Lt="[object Date]",it="[object DOMException]",ge="[object Error]",D="[object Function]",A="[object GeneratorFunction]",te="[object Map]",X="[object Number]",Ge="[object Null]",Be="[object Object]",zt="[object Promise]",gr="[object Proxy]",jr="[object RegExp]",Ne="[object Set]",Xt="[object String]",fn="[object Symbol]",Al="[object Undefined]",Ys="[object WeakMap]",$u="[object WeakSet]",Zs="[object ArrayBuffer]",q="[object DataView]",W="[object Float32Array]",K="[object Float64Array]",se="[object Int8Array]",ce="[object Int16Array]",Se="[object Int32Array]",Ze="[object Uint8Array]",dt="[object Uint8ClampedArray]",Wr="[object Uint16Array]",bi="[object Uint32Array]",Ir=/\b__p \+= '';/g,We=/\b(__p \+=) '' \+/g,Es=/(__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?/,Qwe=/\{\n\/\* \[wrapped with (.+)\] \*/,e0e=/,? & /,t0e=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,r0e=/[()=,{}\[\]\/\s]/,n0e=/\\(\\)?/g,i0e=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,YL=/\w*$/,s0e=/^[-+]0x[0-9a-f]+$/i,o0e=/^0b[01]+$/i,a0e=/^\[object .+?Constructor\]$/,u0e=/^0o[0-7]+$/i,c0e=/^(?:0|[1-9]\d*)$/,l0e=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,fv=/($^)/,f0e=/['\n\r\u2028\u2029\\]/g,pv="\\ud800-\\udfff",p0e="\\u0300-\\u036f",d0e="\\ufe20-\\ufe2f",h0e="\\u20d0-\\u20ff",ZL=p0e+d0e+h0e,JL="\\u2700-\\u27bf",QL="a-z\\xdf-\\xf6\\xf8-\\xff",m0e="\\xac\\xb1\\xd7\\xf7",g0e="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",v0e="\\u2000-\\u206f",y0e=" \\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",e2="A-Z\\xc0-\\xd6\\xd8-\\xde",t2="\\ufe0e\\ufe0f",r2=m0e+g0e+v0e+y0e,vS="['\u2019]",_0e="["+pv+"]",n2="["+r2+"]",dv="["+ZL+"]",i2="\\d+",x0e="["+JL+"]",s2="["+QL+"]",o2="[^"+pv+r2+i2+JL+QL+e2+"]",yS="\\ud83c[\\udffb-\\udfff]",b0e="(?:"+dv+"|"+yS+")",a2="[^"+pv+"]",_S="(?:\\ud83c[\\udde6-\\uddff]){2}",xS="[\\ud800-\\udbff][\\udc00-\\udfff]",Ol="["+e2+"]",u2="\\u200d",c2="(?:"+s2+"|"+o2+")",w0e="(?:"+Ol+"|"+o2+")",l2="(?:"+vS+"(?:d|ll|m|re|s|t|ve))?",f2="(?:"+vS+"(?:D|LL|M|RE|S|T|VE))?",p2=b0e+"?",d2="["+t2+"]?",S0e="(?:"+u2+"(?:"+[a2,_S,xS].join("|")+")"+d2+p2+")*",E0e="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",T0e="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",h2=d2+p2+S0e,C0e="(?:"+[x0e,_S,xS].join("|")+")"+h2,A0e="(?:"+[a2+dv+"?",dv,_S,xS,_0e].join("|")+")",I0e=RegExp(vS,"g"),N0e=RegExp(dv,"g"),bS=RegExp(yS+"(?="+yS+")|"+A0e+h2,"g"),O0e=RegExp([Ol+"?"+s2+"+"+l2+"(?="+[n2,Ol,"$"].join("|")+")",w0e+"+"+f2+"(?="+[n2,Ol+c2,"$"].join("|")+")",Ol+"?"+c2+"+"+l2,Ol+"+"+f2,T0e,E0e,i2,C0e].join("|"),"g"),R0e=RegExp("["+u2+pv+ZL+t2+"]"),k0e=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,P0e=["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"],q0e=-1,rr={};rr[W]=rr[K]=rr[se]=rr[ce]=rr[Se]=rr[Ze]=rr[dt]=rr[Wr]=rr[bi]=!0,rr[ot]=rr[Ye]=rr[Zs]=rr[Re]=rr[q]=rr[Lt]=rr[ge]=rr[D]=rr[te]=rr[X]=rr[Be]=rr[jr]=rr[Ne]=rr[Xt]=rr[Ys]=!1;var er={};er[ot]=er[Ye]=er[Zs]=er[q]=er[Re]=er[Lt]=er[W]=er[K]=er[se]=er[ce]=er[Se]=er[te]=er[X]=er[Be]=er[jr]=er[Ne]=er[Xt]=er[fn]=er[Ze]=er[dt]=er[Wr]=er[bi]=!0,er[ge]=er[D]=er[Ys]=!1;var D0e={\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"},L0e={"&":"&","<":"<",">":">",'"':""","'":"'"},F0e={"&":"&","<":"<",">":">",""":'"',"'":"'"},M0e={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},j0e=parseFloat,B0e=parseInt,m2=typeof global=="object"&&global&&global.Object===Object&&global,U0e=typeof self=="object"&&self&&self.Object===Object&&self,tn=m2||U0e||Function("return this")(),wS=typeof xp=="object"&&xp&&!xp.nodeType&&xp,zu=wS&&typeof Sm=="object"&&Sm&&!Sm.nodeType&&Sm,g2=zu&&zu.exports===wS,SS=g2&&m2.process,Vi=function(){try{var Z=zu&&zu.require&&zu.require("util").types;return Z||SS&&SS.binding&&SS.binding("util")}catch{}}(),v2=Vi&&Vi.isArrayBuffer,y2=Vi&&Vi.isDate,_2=Vi&&Vi.isMap,x2=Vi&&Vi.isRegExp,b2=Vi&&Vi.isSet,w2=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 $0e(Z,ae,ne,Te){for(var Je=-1,Ot=Z==null?0:Z.length;++Je<Ot;){var zr=Z[Je];ae(Te,zr,ne(zr),Z)}return Te}function Gi(Z,ae){for(var ne=-1,Te=Z==null?0:Z.length;++ne<Te&&ae(Z[ne],ne,Z)!==!1;);return Z}function H0e(Z,ae){for(var ne=Z==null?0:Z.length;ne--&&ae(Z[ne],ne,Z)!==!1;);return Z}function S2(Z,ae){for(var ne=-1,Te=Z==null?0:Z.length;++ne<Te;)if(!ae(Z[ne],ne,Z))return!1;return!0}function Pa(Z,ae){for(var ne=-1,Te=Z==null?0:Z.length,Je=0,Ot=[];++ne<Te;){var zr=Z[ne];ae(zr,ne,Z)&&(Ot[Je++]=zr)}return Ot}function hv(Z,ae){var ne=Z==null?0:Z.length;return!!ne&&Rl(Z,ae,0)>-1}function ES(Z,ae,ne){for(var Te=-1,Je=Z==null?0:Z.length;++Te<Je;)if(ne(ae,Z[Te]))return!0;return!1}function sr(Z,ae){for(var ne=-1,Te=Z==null?0:Z.length,Je=Array(Te);++ne<Te;)Je[ne]=ae(Z[ne],ne,Z);return Je}function qa(Z,ae){for(var ne=-1,Te=ae.length,Je=Z.length;++ne<Te;)Z[Je+ne]=ae[ne];return Z}function TS(Z,ae,ne,Te){var Je=-1,Ot=Z==null?0:Z.length;for(Te&&Ot&&(ne=Z[++Je]);++Je<Ot;)ne=ae(ne,Z[Je],Je,Z);return ne}function W0e(Z,ae,ne,Te){var Je=Z==null?0:Z.length;for(Te&&Je&&(ne=Z[--Je]);Je--;)ne=ae(ne,Z[Je],Je,Z);return ne}function CS(Z,ae){for(var ne=-1,Te=Z==null?0:Z.length;++ne<Te;)if(ae(Z[ne],ne,Z))return!0;return!1}var z0e=AS("length");function V0e(Z){return Z.split("")}function G0e(Z){return Z.match(t0e)||[]}function E2(Z,ae,ne){var Te;return ne(Z,function(Je,Ot,zr){if(ae(Je,Ot,zr))return Te=Ot,!1}),Te}function mv(Z,ae,ne,Te){for(var Je=Z.length,Ot=ne+(Te?1:-1);Te?Ot--:++Ot<Je;)if(ae(Z[Ot],Ot,Z))return Ot;return-1}function Rl(Z,ae,ne){return ae===ae?sSe(Z,ae,ne):mv(Z,T2,ne)}function K0e(Z,ae,ne,Te){for(var Je=ne-1,Ot=Z.length;++Je<Ot;)if(Te(Z[Je],ae))return Je;return-1}function T2(Z){return Z!==Z}function C2(Z,ae){var ne=Z==null?0:Z.length;return ne?NS(Z,ae)/ne:V}function AS(Z){return function(ae){return ae==null?e:ae[Z]}}function IS(Z){return function(ae){return Z==null?e:Z[ae]}}function A2(Z,ae,ne,Te,Je){return Je(Z,function(Ot,zr,Yt){ne=Te?(Te=!1,Ot):ae(ne,Ot,zr,Yt)}),ne}function X0e(Z,ae){var ne=Z.length;for(Z.sort(ae);ne--;)Z[ne]=Z[ne].value;return Z}function NS(Z,ae){for(var ne,Te=-1,Je=Z.length;++Te<Je;){var Ot=ae(Z[Te]);Ot!==e&&(ne=ne===e?Ot:ne+Ot)}return ne}function OS(Z,ae){for(var ne=-1,Te=Array(Z);++ne<Z;)Te[ne]=ae(ne);return Te}function Y0e(Z,ae){return sr(ae,function(ne){return[ne,Z[ne]]})}function I2(Z){return Z&&Z.slice(0,k2(Z)+1).replace(Wu,"")}function Ei(Z){return function(ae){return Z(ae)}}function RS(Z,ae){return sr(ae,function(ne){return Z[ne]})}function gd(Z,ae){return Z.has(ae)}function N2(Z,ae){for(var ne=-1,Te=Z.length;++ne<Te&&Rl(ae,Z[ne],0)>-1;);return ne}function O2(Z,ae){for(var ne=Z.length;ne--&&Rl(ae,Z[ne],0)>-1;);return ne}function Z0e(Z,ae){for(var ne=Z.length,Te=0;ne--;)Z[ne]===ae&&++Te;return Te}var J0e=IS(D0e),Q0e=IS(L0e);function eSe(Z){return"\\"+M0e[Z]}function tSe(Z,ae){return Z==null?e:Z[ae]}function kl(Z){return R0e.test(Z)}function rSe(Z){return k0e.test(Z)}function nSe(Z){for(var ae,ne=[];!(ae=Z.next()).done;)ne.push(ae.value);return ne}function kS(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Te,Je){ne[++ae]=[Je,Te]}),ne}function R2(Z,ae){return function(ne){return Z(ae(ne))}}function Da(Z,ae){for(var ne=-1,Te=Z.length,Je=0,Ot=[];++ne<Te;){var zr=Z[ne];(zr===ae||zr===u)&&(Z[ne]=u,Ot[Je++]=ne)}return Ot}function gv(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Te){ne[++ae]=Te}),ne}function iSe(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Te){ne[++ae]=[Te,Te]}),ne}function sSe(Z,ae,ne){for(var Te=ne-1,Je=Z.length;++Te<Je;)if(Z[Te]===ae)return Te;return-1}function oSe(Z,ae,ne){for(var Te=ne+1;Te--;)if(Z[Te]===ae)return Te;return Te}function Pl(Z){return kl(Z)?uSe(Z):z0e(Z)}function Ts(Z){return kl(Z)?cSe(Z):V0e(Z)}function k2(Z){for(var ae=Z.length;ae--&&cv.test(Z.charAt(ae)););return ae}var aSe=IS(F0e);function uSe(Z){for(var ae=bS.lastIndex=0;bS.test(Z);)++ae;return ae}function cSe(Z){return Z.match(bS)||[]}function lSe(Z){return Z.match(O0e)||[]}var fSe=function Z(ae){ae=ae==null?tn:La.defaults(tn.Object(),ae,La.pick(tn,P0e));var ne=ae.Array,Te=ae.Date,Je=ae.Error,Ot=ae.Function,zr=ae.Math,Yt=ae.Object,PS=ae.RegExp,pSe=ae.String,Ki=ae.TypeError,vv=ne.prototype,dSe=Ot.prototype,ql=Yt.prototype,yv=ae["__core-js_shared__"],_v=dSe.toString,Ft=ql.hasOwnProperty,hSe=0,P2=function(){var c=/[^.]+$/.exec(yv&&yv.keys&&yv.keys.IE_PROTO||"");return c?"Symbol(src)_1."+c:""}(),xv=ql.toString,mSe=_v.call(Yt),gSe=tn._,vSe=PS("^"+_v.call(Ft).replace(Hu,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),bv=g2?ae.Buffer:e,Fa=ae.Symbol,wv=ae.Uint8Array,q2=bv?bv.allocUnsafe:e,Sv=R2(Yt.getPrototypeOf,Yt),D2=Yt.create,L2=ql.propertyIsEnumerable,Ev=vv.splice,F2=Fa?Fa.isConcatSpreadable:e,vd=Fa?Fa.iterator:e,Vu=Fa?Fa.toStringTag:e,Tv=function(){try{var c=Zu(Yt,"defineProperty");return c({},"",{}),c}catch{}}(),ySe=ae.clearTimeout!==tn.clearTimeout&&ae.clearTimeout,_Se=Te&&Te.now!==tn.Date.now&&Te.now,xSe=ae.setTimeout!==tn.setTimeout&&ae.setTimeout,Cv=zr.ceil,Av=zr.floor,qS=Yt.getOwnPropertySymbols,bSe=bv?bv.isBuffer:e,M2=ae.isFinite,wSe=vv.join,SSe=R2(Yt.keys,Yt),Vr=zr.max,In=zr.min,ESe=Te.now,TSe=ae.parseInt,j2=zr.random,CSe=vv.reverse,DS=Zu(ae,"DataView"),yd=Zu(ae,"Map"),LS=Zu(ae,"Promise"),Dl=Zu(ae,"Set"),_d=Zu(ae,"WeakMap"),xd=Zu(Yt,"create"),Iv=_d&&new _d,Ll={},ASe=Ju(DS),ISe=Ju(yd),NSe=Ju(LS),OSe=Ju(Dl),RSe=Ju(_d),Nv=Fa?Fa.prototype:e,bd=Nv?Nv.valueOf:e,B2=Nv?Nv.toString:e;function k(c){if(wr(c)&&!st(c)&&!(c instanceof yt)){if(c instanceof Xi)return c;if(Ft.call(c,"__wrapped__"))return UF(c)}return new Xi(c)}var Fl=function(){function c(){}return function(p){if(!vr(p))return{};if(D2)return D2(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}k.templateSettings={escape:pd,evaluate:wi,interpolate:dd,variable:"",imports:{_:k}},k.prototype=Ov.prototype,k.prototype.constructor=k,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__=ie,this.__views__=[]}function kSe(){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 PSe(){if(this.__filtered__){var c=new yt(this);c.__dir__=-1,c.__filtered__=!0}else c=this.clone(),c.__dir__*=-1;return c}function qSe(){var c=this.__wrapped__.value(),p=this.__dir__,y=st(c),x=p<0,I=y?c.length:0,L=VEe(0,I,this.__views__),H=L.start,G=L.end,J=G-H,ue=x?G:H-1,le=this.__iteratees__,de=le.length,be=0,qe=In(J,this.__takeCount__);if(!y||!x&&I==J&&qe==J)return lF(c,this.__actions__);var ze=[];e:for(;J--&&be<qe;){ue+=p;for(var lt=-1,Ve=c[ue];++lt<de;){var ht=le[lt],St=ht.iteratee,Ai=ht.type,Hn=St(Ve);if(Ai==z)Ve=Hn;else if(!Hn){if(Ai==N)continue e;break e}}ze[be++]=Ve}return ze}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 DSe(){this.__data__=xd?xd(null):{},this.size=0}function LSe(c){var p=this.has(c)&&delete this.__data__[c];return this.size-=p?1:0,p}function FSe(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 MSe(c){var p=this.__data__;return xd?p[c]!==e:Ft.call(p,c)}function jSe(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=DSe,Gu.prototype.delete=LSe,Gu.prototype.get=FSe,Gu.prototype.has=MSe,Gu.prototype.set=jSe;function Lo(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 BSe(){this.__data__=[],this.size=0}function USe(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 $Se(c){var p=this.__data__,y=Rv(p,c);return y<0?e:p[y][1]}function HSe(c){return Rv(this.__data__,c)>-1}function WSe(c,p){var y=this.__data__,x=Rv(y,c);return x<0?(++this.size,y.push([c,p])):y[x][1]=p,this}Lo.prototype.clear=BSe,Lo.prototype.delete=USe,Lo.prototype.get=$Se,Lo.prototype.has=HSe,Lo.prototype.set=WSe;function Fo(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 zSe(){this.size=0,this.__data__={hash:new Gu,map:new(yd||Lo),string:new Gu}}function VSe(c){var p=Hv(this,c).delete(c);return this.size-=p?1:0,p}function GSe(c){return Hv(this,c).get(c)}function KSe(c){return Hv(this,c).has(c)}function XSe(c,p){var y=Hv(this,c),x=y.size;return y.set(c,p),this.size+=y.size==x?0:1,this}Fo.prototype.clear=zSe,Fo.prototype.delete=VSe,Fo.prototype.get=GSe,Fo.prototype.has=KSe,Fo.prototype.set=XSe;function Ku(c){var p=-1,y=c==null?0:c.length;for(this.__data__=new Fo;++p<y;)this.add(c[p])}function YSe(c){return this.__data__.set(c,o),this}function ZSe(c){return this.__data__.has(c)}Ku.prototype.add=Ku.prototype.push=YSe,Ku.prototype.has=ZSe;function Cs(c){var p=this.__data__=new Lo(c);this.size=p.size}function JSe(){this.__data__=new Lo,this.size=0}function QSe(c){var p=this.__data__,y=p.delete(c);return this.size=p.size,y}function eEe(c){return this.__data__.get(c)}function tEe(c){return this.__data__.has(c)}function rEe(c,p){var y=this.__data__;if(y instanceof Lo){var x=y.__data__;if(!yd||x.length<r-1)return x.push([c,p]),this.size=++y.size,this;y=this.__data__=new Fo(x)}return y.set(c,p),this.size=y.size,this}Cs.prototype.clear=JSe,Cs.prototype.delete=QSe,Cs.prototype.get=eEe,Cs.prototype.has=tEe,Cs.prototype.set=rEe;function U2(c,p){var y=st(c),x=!y&&Qu(c),I=!y&&!x&&$a(c),L=!y&&!x&&!I&&Ul(c),H=y||x||I||L,G=H?OS(c.length,pSe):[],J=G.length;for(var ue in c)(p||Ft.call(c,ue))&&!(H&&(ue=="length"||I&&(ue=="offset"||ue=="parent")||L&&(ue=="buffer"||ue=="byteLength"||ue=="byteOffset")||Uo(ue,J)))&&G.push(ue);return G}function $2(c){var p=c.length;return p?c[GS(0,p-1)]:e}function nEe(c,p){return Wv(ti(c),Xu(p,0,c.length))}function iEe(c){return Wv(ti(c))}function FS(c,p,y){(y!==e&&!As(c[p],y)||y===e&&!(p in c))&&Mo(c,p,y)}function wd(c,p,y){var x=c[p];(!(Ft.call(c,p)&&As(x,y))||y===e&&!(p in c))&&Mo(c,p,y)}function Rv(c,p){for(var y=c.length;y--;)if(As(c[y][0],p))return y;return-1}function sEe(c,p,y,x){return Ma(c,function(I,L,H){p(x,I,y(I),H)}),x}function H2(c,p){return c&&Qs(p,rn(p),c)}function oEe(c,p){return c&&Qs(p,ni(p),c)}function Mo(c,p,y){p=="__proto__"&&Tv?Tv(c,p,{configurable:!0,enumerable:!0,value:y,writable:!0}):c[p]=y}function MS(c,p){for(var y=-1,x=p.length,I=ne(x),L=c==null;++y<x;)I[y]=L?e:yE(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 H,G=p&l,J=p&f,ue=p&d;if(y&&(H=I?y(c,x,I,L):y(c)),H!==e)return H;if(!vr(c))return c;var le=st(c);if(le){if(H=KEe(c),!G)return ti(c,H)}else{var de=Nn(c),be=de==D||de==A;if($a(c))return dF(c,G);if(de==Be||de==ot||be&&!I){if(H=J||be?{}:kF(c),!G)return J?FEe(c,oEe(H,c)):LEe(c,H2(H,c))}else{if(!er[de])return I?c:{};H=XEe(c,de,G)}}L||(L=new Cs);var qe=L.get(c);if(qe)return qe;L.set(c,H),aM(c)?c.forEach(function(Ve){H.add(Yi(Ve,p,y,Ve,c,L))}):sM(c)&&c.forEach(function(Ve,ht){H.set(ht,Yi(Ve,p,y,ht,c,L))});var ze=ue?J?iE:nE:J?ni:rn,lt=le?e:ze(c);return Gi(lt||c,function(Ve,ht){lt&&(ht=Ve,Ve=c[ht]),wd(H,ht,Yi(Ve,p,y,ht,c,L))}),H}function aEe(c){var p=rn(c);return function(y){return W2(y,c,p)}}function W2(c,p,y){var x=y.length;if(c==null)return!x;for(c=Yt(c);x--;){var I=y[x],L=p[I],H=c[I];if(H===e&&!(I in c)||!L(H))return!1}return!0}function z2(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,H=!0,G=c.length,J=[],ue=p.length;if(!G)return J;y&&(p=sr(p,Ei(y))),x?(L=ES,H=!1):p.length>=r&&(L=gd,H=!1,p=new Ku(p));e:for(;++I<G;){var le=c[I],de=y==null?le:y(le);if(le=x||le!==0?le:0,H&&de===de){for(var be=ue;be--;)if(p[be]===de)continue e;J.push(le)}else L(p,de,x)||J.push(le)}return J}var Ma=yF(Js),V2=yF(BS,!0);function uEe(c,p){var y=!0;return Ma(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],H=p(L);if(H!=null&&(G===e?H===H&&!Ci(H):y(H,G)))var G=H,J=L}return J}function cEe(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:cM(x);y<x;)c[y++]=p;return c}function G2(c,p){var y=[];return Ma(c,function(x,I,L){p(x,I,L)&&y.push(x)}),y}function pn(c,p,y,x,I){var L=-1,H=c.length;for(y||(y=ZEe),I||(I=[]);++L<H;){var G=c[L];p>0&&y(G)?p>1?pn(G,p-1,y,x,I):qa(I,G):x||(I[I.length]=G)}return I}var jS=_F(),K2=_F(!0);function Js(c,p){return c&&jS(c,p,rn)}function BS(c,p){return c&&K2(c,p,rn)}function Pv(c,p){return Pa(p,function(y){return $o(c[y])})}function Yu(c,p){p=Ba(p,c);for(var y=0,x=p.length;c!=null&&y<x;)c=c[eo(p[y++])];return y&&y==x?c:e}function X2(c,p,y){var x=p(c);return st(c)?x:qa(x,y(c))}function Un(c){return c==null?c===e?Al:Ge:Vu&&Vu in Yt(c)?zEe(c):iTe(c)}function US(c,p){return c>p}function lEe(c,p){return c!=null&&Ft.call(c,p)}function fEe(c,p){return c!=null&&p in Yt(c)}function pEe(c,p,y){return c>=In(p,y)&&c<Vr(p,y)}function $S(c,p,y){for(var x=y?ES:hv,I=c[0].length,L=c.length,H=L,G=ne(L),J=1/0,ue=[];H--;){var le=c[H];H&&p&&(le=sr(le,Ei(p))),J=In(le.length,J),G[H]=!y&&(p||I>=120&&le.length>=120)?new Ku(H&&le):e}le=c[0];var de=-1,be=G[0];e:for(;++de<I&&ue.length<J;){var qe=le[de],ze=p?p(qe):qe;if(qe=y||qe!==0?qe:0,!(be?gd(be,ze):x(ue,ze,y))){for(H=L;--H;){var lt=G[H];if(!(lt?gd(lt,ze):x(c[H],ze,y)))continue e}be&&be.push(ze),ue.push(qe)}}return ue}function dEe(c,p,y,x){return Js(c,function(I,L,H){p(x,y(I),L,H)}),x}function Ed(c,p,y){p=Ba(p,c),c=LF(c,p);var x=c==null?c:c[eo(Ji(p))];return x==null?e:Si(x,c,y)}function Y2(c){return wr(c)&&Un(c)==ot}function hEe(c){return wr(c)&&Un(c)==Zs}function mEe(c){return wr(c)&&Un(c)==Lt}function Td(c,p,y,x,I){return c===p?!0:c==null||p==null||!wr(c)&&!wr(p)?c!==c&&p!==p:gEe(c,p,y,x,Td,I)}function gEe(c,p,y,x,I,L){var H=st(c),G=st(p),J=H?Ye:Nn(c),ue=G?Ye:Nn(p);J=J==ot?Be:J,ue=ue==ot?Be:ue;var le=J==Be,de=ue==Be,be=J==ue;if(be&&$a(c)){if(!$a(p))return!1;H=!0,le=!1}if(be&&!le)return L||(L=new Cs),H||Ul(c)?NF(c,p,y,x,I,L):HEe(c,p,J,y,x,I,L);if(!(y&h)){var qe=le&&Ft.call(c,"__wrapped__"),ze=de&&Ft.call(p,"__wrapped__");if(qe||ze){var lt=qe?c.value():c,Ve=ze?p.value():p;return L||(L=new Cs),I(lt,Ve,y,x,L)}}return be?(L||(L=new Cs),WEe(c,p,y,x,I,L)):!1}function vEe(c){return wr(c)&&Nn(c)==te}function HS(c,p,y,x){var I=y.length,L=I,H=!x;if(c==null)return!L;for(c=Yt(c);I--;){var G=y[I];if(H&&G[2]?G[1]!==c[G[0]]:!(G[0]in c))return!1}for(;++I<L;){G=y[I];var J=G[0],ue=c[J],le=G[1];if(H&&G[2]){if(ue===e&&!(J in c))return!1}else{var de=new Cs;if(x)var be=x(ue,le,J,c,p,de);if(!(be===e?Td(le,ue,h|m,x,de):be))return!1}}return!0}function Z2(c){if(!vr(c)||QEe(c))return!1;var p=$o(c)?vSe:a0e;return p.test(Ju(c))}function yEe(c){return wr(c)&&Un(c)==jr}function _Ee(c){return wr(c)&&Nn(c)==Ne}function xEe(c){return wr(c)&&Yv(c.length)&&!!rr[Un(c)]}function J2(c){return typeof c=="function"?c:c==null?ii:typeof c=="object"?st(c)?tF(c[0],c[1]):eF(c):xM(c)}function WS(c){if(!Id(c))return SSe(c);var p=[];for(var y in Yt(c))Ft.call(c,y)&&y!="constructor"&&p.push(y);return p}function bEe(c){if(!vr(c))return nTe(c);var p=Id(c),y=[];for(var x in c)x=="constructor"&&(p||!Ft.call(c,x))||y.push(x);return y}function zS(c,p){return c<p}function Q2(c,p){var y=-1,x=ri(c)?ne(c.length):[];return Ma(c,function(I,L,H){x[++y]=p(I,L,H)}),x}function eF(c){var p=oE(c);return p.length==1&&p[0][2]?qF(p[0][0],p[0][1]):function(y){return y===c||HS(y,c,p)}}function tF(c,p){return uE(c)&&PF(p)?qF(eo(c),p):function(y){var x=yE(y,c);return x===e&&x===p?_E(y,c):Td(p,x,h|m)}}function qv(c,p,y,x,I){c!==p&&jS(p,function(L,H){if(I||(I=new Cs),vr(L))wEe(c,p,H,y,qv,x,I);else{var G=x?x(lE(c,H),L,H+"",c,p,I):e;G===e&&(G=L),FS(c,H,G)}},ni)}function wEe(c,p,y,x,I,L,H){var G=lE(c,y),J=lE(p,y),ue=H.get(J);if(ue){FS(c,y,ue);return}var le=L?L(G,J,y+"",c,p,H):e,de=le===e;if(de){var be=st(J),qe=!be&&$a(J),ze=!be&&!qe&&Ul(J);le=J,be||qe||ze?st(G)?le=G:Nr(G)?le=ti(G):qe?(de=!1,le=dF(J,!0)):ze?(de=!1,le=hF(J,!0)):le=[]:Od(J)||Qu(J)?(le=G,Qu(G)?le=lM(G):(!vr(G)||$o(G))&&(le=kF(J))):de=!1}de&&(H.set(J,le),I(le,J,x,L,H),H.delete(J)),FS(c,y,le)}function rF(c,p){var y=c.length;if(y)return p+=p<0?y:0,Uo(p,y)?c[p]:e}function nF(c,p,y){p.length?p=sr(p,function(L){return st(L)?function(H){return Yu(H,L.length===1?L[0]:L)}:L}):p=[ii];var x=-1;p=sr(p,Ei(Ue()));var I=Q2(c,function(L,H,G){var J=sr(p,function(ue){return ue(L)});return{criteria:J,index:++x,value:L}});return X0e(I,function(L,H){return DEe(L,H,y)})}function SEe(c,p){return iF(c,p,function(y,x){return _E(c,x)})}function iF(c,p,y){for(var x=-1,I=p.length,L={};++x<I;){var H=p[x],G=Yu(c,H);y(G,H)&&Cd(L,Ba(H,c),G)}return L}function EEe(c){return function(p){return Yu(p,c)}}function VS(c,p,y,x){var I=x?K0e:Rl,L=-1,H=p.length,G=c;for(c===p&&(p=ti(p)),y&&(G=sr(c,Ei(y)));++L<H;)for(var J=0,ue=p[L],le=y?y(ue):ue;(J=I(G,le,J,x))>-1;)G!==c&&Ev.call(G,J,1),Ev.call(c,J,1);return c}function sF(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;Uo(I)?Ev.call(c,I,1):YS(c,I)}}return c}function GS(c,p){return c+Av(j2()*(p-c+1))}function TEe(c,p,y,x){for(var I=-1,L=Vr(Cv((p-c)/(y||1)),0),H=ne(L);L--;)H[x?L:++I]=c,c+=y;return H}function KS(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 fE(DF(c,p,ii),c+"")}function CEe(c){return $2($l(c))}function AEe(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=Ba(p,c);for(var I=-1,L=p.length,H=L-1,G=c;G!=null&&++I<L;){var J=eo(p[I]),ue=y;if(J==="__proto__"||J==="constructor"||J==="prototype")return c;if(I!=H){var le=G[J];ue=x?x(le,J,G):e,ue===e&&(ue=vr(le)?le:Uo(p[I+1])?[]:{})}wd(G,J,ue),G=G[J]}return c}var oF=Iv?function(c,p){return Iv.set(c,p),c}:ii,IEe=Tv?function(c,p){return Tv(c,"toString",{configurable:!0,enumerable:!1,value:bE(p),writable:!0})}:ii;function NEe(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 OEe(c,p){var y;return Ma(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<=ye){for(;x<I;){var L=x+I>>>1,H=c[L];H!==null&&!Ci(H)&&(y?H<=p:H<p)?x=L+1:I=L}return I}return XS(c,p,ii,y)}function XS(c,p,y,x){var I=0,L=c==null?0:c.length;if(L===0)return 0;p=y(p);for(var H=p!==p,G=p===null,J=Ci(p),ue=p===e;I<L;){var le=Av((I+L)/2),de=y(c[le]),be=de!==e,qe=de===null,ze=de===de,lt=Ci(de);if(H)var Ve=x||ze;else ue?Ve=ze&&(x||be):G?Ve=ze&&be&&(x||!qe):J?Ve=ze&&be&&!qe&&(x||!lt):qe||lt?Ve=!1:Ve=x?de<=p:de<p;Ve?I=le+1:L=le}return In(L,pe)}function aF(c,p){for(var y=-1,x=c.length,I=0,L=[];++y<x;){var H=c[y],G=p?p(H):H;if(!y||!As(G,J)){var J=G;L[I++]=H===0?0:H}}return L}function uF(c){return typeof c=="number"?c:Ci(c)?V:+c}function Ti(c){if(typeof c=="string")return c;if(st(c))return sr(c,Ti)+"";if(Ci(c))return B2?B2.call(c):"";var p=c+"";return p=="0"&&1/c==-j?"-0":p}function ja(c,p,y){var x=-1,I=hv,L=c.length,H=!0,G=[],J=G;if(y)H=!1,I=ES;else if(L>=r){var ue=p?null:UEe(c);if(ue)return gv(ue);H=!1,I=gd,J=new Ku}else J=p?[]:G;e:for(;++x<L;){var le=c[x],de=p?p(le):le;if(le=y||le!==0?le:0,H&&de===de){for(var be=J.length;be--;)if(J[be]===de)continue e;p&&J.push(de),G.push(le)}else I(J,de,y)||(J!==G&&J.push(de),G.push(le))}return G}function YS(c,p){return p=Ba(p,c),c=LF(c,p),c==null||delete c[eo(Ji(p))]}function cF(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 lF(c,p){var y=c;return y instanceof yt&&(y=y.value()),TS(p,function(x,I){return I.func.apply(I.thisArg,qa([x],I.args))},y)}function ZS(c,p,y){var x=c.length;if(x<2)return x?ja(c[0]):[];for(var I=-1,L=ne(x);++I<x;)for(var H=c[I],G=-1;++G<x;)G!=I&&(L[I]=Sd(L[I]||H,c[G],p,y));return ja(pn(L,1),p,y)}function fF(c,p,y){for(var x=-1,I=c.length,L=p.length,H={};++x<I;){var G=x<L?p[x]:e;y(H,c[x],G)}return H}function JS(c){return Nr(c)?c:[]}function QS(c){return typeof c=="function"?c:ii}function Ba(c,p){return st(c)?c:uE(c,p)?[c]:BF(Pt(c))}var REe=ft;function Ua(c,p,y){var x=c.length;return y=y===e?x:y,!p&&y>=x?c:Zi(c,p,y)}var pF=ySe||function(c){return tn.clearTimeout(c)};function dF(c,p){if(p)return c.slice();var y=c.length,x=q2?q2(y):new c.constructor(y);return c.copy(x),x}function eE(c){var p=new c.constructor(c.byteLength);return new wv(p).set(new wv(c)),p}function kEe(c,p){var y=p?eE(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.byteLength)}function PEe(c){var p=new c.constructor(c.source,YL.exec(c));return p.lastIndex=c.lastIndex,p}function qEe(c){return bd?Yt(bd.call(c)):{}}function hF(c,p){var y=p?eE(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.length)}function mF(c,p){if(c!==p){var y=c!==e,x=c===null,I=c===c,L=Ci(c),H=p!==e,G=p===null,J=p===p,ue=Ci(p);if(!G&&!ue&&!L&&c>p||L&&H&&J&&!G&&!ue||x&&H&&J||!y&&J||!I)return 1;if(!x&&!L&&!ue&&c<p||ue&&y&&I&&!x&&!L||G&&y&&I||!H&&I||!J)return-1}return 0}function DEe(c,p,y){for(var x=-1,I=c.criteria,L=p.criteria,H=I.length,G=y.length;++x<H;){var J=mF(I[x],L[x]);if(J){if(x>=G)return J;var ue=y[x];return J*(ue=="desc"?-1:1)}}return c.index-p.index}function gF(c,p,y,x){for(var I=-1,L=c.length,H=y.length,G=-1,J=p.length,ue=Vr(L-H,0),le=ne(J+ue),de=!x;++G<J;)le[G]=p[G];for(;++I<H;)(de||I<L)&&(le[y[I]]=c[I]);for(;ue--;)le[G++]=c[I++];return le}function vF(c,p,y,x){for(var I=-1,L=c.length,H=-1,G=y.length,J=-1,ue=p.length,le=Vr(L-G,0),de=ne(le+ue),be=!x;++I<le;)de[I]=c[I];for(var qe=I;++J<ue;)de[qe+J]=p[J];for(;++H<G;)(be||I<L)&&(de[qe+y[H]]=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 Qs(c,p,y,x){var I=!y;y||(y={});for(var L=-1,H=p.length;++L<H;){var G=p[L],J=x?x(y[G],c[G],G,y,c):e;J===e&&(J=c[G]),I?Mo(y,G,J):wd(y,G,J)}return y}function LEe(c,p){return Qs(c,aE(c),p)}function FEe(c,p){return Qs(c,OF(c),p)}function Fv(c,p){return function(y,x){var I=st(y)?$0e:sEe,L=p?p():{};return I(y,c,Ue(x,2),L)}}function Ml(c){return ft(function(p,y){var x=-1,I=y.length,L=I>1?y[I-1]:e,H=I>2?y[2]:e;for(L=c.length>3&&typeof L=="function"?(I--,L):e,H&&$n(y[0],y[1],H)&&(L=I<3?e:L,I=1),p=Yt(p);++x<I;){var G=y[x];G&&c(p,G,x,L)}return p})}function yF(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,H=Yt(y);(p?L--:++L<I)&&x(H[L],L,H)!==!1;);return y}}function _F(c){return function(p,y,x){for(var I=-1,L=Yt(p),H=x(p),G=H.length;G--;){var J=H[c?G:++I];if(y(L[J],J,L)===!1)break}return p}}function MEe(c,p,y){var x=p&g,I=Ad(c);function L(){var H=this&&this!==tn&&this instanceof L?I:c;return H.apply(x?y:this,arguments)}return L}function xF(c){return function(p){p=Pt(p);var y=kl(p)?Ts(p):e,x=y?y[0]:p.charAt(0),I=y?Ua(y,1).join(""):p.slice(1);return x[c]()+I}}function jl(c){return function(p){return TS(yM(vM(p).replace(I0e,"")),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 jEe(c,p,y){var x=Ad(c);function I(){for(var L=arguments.length,H=ne(L),G=L,J=Bl(I);G--;)H[G]=arguments[G];var ue=L<3&&H[0]!==J&&H[L-1]!==J?[]:Da(H,J);if(L-=ue.length,L<y)return TF(c,p,Mv,I.placeholder,e,H,ue,e,e,y-L);var le=this&&this!==tn&&this instanceof I?x:c;return Si(le,this,H)}return I}function bF(c){return function(p,y,x){var I=Yt(p);if(!ri(p)){var L=Ue(y,3);p=rn(p),y=function(G){return L(I[G],G,I)}}var H=c(p,y,x);return H>-1?I[L?p[H]:H]:e}}function wF(c){return Bo(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&&!H&&$v(L)=="wrapper")var H=new Xi([],!0)}for(x=H?x:y;++x<y;){L=p[x];var G=$v(L),J=G=="wrapper"?sE(L):e;J&&cE(J[0])&&J[1]==(E|b|T|O)&&!J[4].length&&J[9]==1?H=H[$v(J[0])].apply(H,J[3]):H=L.length==1&&cE(L)?H[G]():H.thru(L)}return function(){var ue=arguments,le=ue[0];if(H&&ue.length==1&&st(le))return H.plant(le).value();for(var de=0,be=y?p[de].apply(this,ue):le;++de<y;)be=p[de].call(this,be);return be}})}function Mv(c,p,y,x,I,L,H,G,J,ue){var le=p&E,de=p&g,be=p&_,qe=p&(b|C),ze=p&U,lt=be?e:Ad(c);function Ve(){for(var ht=arguments.length,St=ne(ht),Ai=ht;Ai--;)St[Ai]=arguments[Ai];if(qe)var Hn=Bl(Ve),Ii=Z0e(St,Hn);if(x&&(St=gF(St,x,I,qe)),L&&(St=vF(St,L,H,qe)),ht-=Ii,qe&&ht<ue){var Or=Da(St,Hn);return TF(c,p,Mv,Ve.placeholder,y,St,Or,G,J,ue-ht)}var Is=de?y:this,Wo=be?Is[c]:c;return ht=St.length,G?St=sTe(St,G):ze&&ht>1&&St.reverse(),le&&J<ht&&(St.length=J),this&&this!==tn&&this instanceof Ve&&(Wo=lt||Ad(Wo)),Wo.apply(Is,St)}return Ve}function SF(c,p){return function(y,x){return dEe(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=uF(y),x=uF(x)),I=c(y,x)}return I}}function tE(c){return Bo(function(p){return p=sr(p,Ei(Ue())),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?KS(p,c):p;var x=KS(p,Cv(c/Pl(p)));return kl(p)?Ua(Ts(x),0,c).join(""):x.slice(0,c)}function BEe(c,p,y,x){var I=p&g,L=Ad(c);function H(){for(var G=-1,J=arguments.length,ue=-1,le=x.length,de=ne(le+J),be=this&&this!==tn&&this instanceof H?L:c;++ue<le;)de[ue]=x[ue];for(;J--;)de[ue++]=arguments[++G];return Si(be,I?y:this,de)}return H}function EF(c){return function(p,y,x){return x&&typeof x!="number"&&$n(p,y,x)&&(y=x=e),p=Ho(p),y===e?(y=p,p=0):y=Ho(y),x=x===e?p<y?1:-1:Ho(x),TEe(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 TF(c,p,y,x,I,L,H,G,J,ue){var le=p&b,de=le?H:e,be=le?e:H,qe=le?L:e,ze=le?e:L;p|=le?T:w,p&=~(le?w:T),p&S||(p&=~(g|_));var lt=[c,p,I,qe,de,ze,be,G,J,ue],Ve=y.apply(e,lt);return cE(c)&&FF(Ve,lt),Ve.placeholder=x,MF(Ve,c,p)}function rE(c){var p=zr[c];return function(y,x){if(y=Qi(y),x=x==null?0:In(ct(x),292),x&&M2(y)){var I=(Pt(y)+"e").split("e"),L=p(I[0]+"e"+(+I[1]+x));return I=(Pt(L)+"e").split("e"),+(I[0]+"e"+(+I[1]-x))}return p(y)}}var UEe=Dl&&1/gv(new Dl([,-0]))[1]==j?function(c){return new Dl(c)}:EE;function CF(c){return function(p){var y=Nn(p);return y==te?kS(p):y==Ne?iSe(p):Y0e(p,c(p))}}function jo(c,p,y,x,I,L,H,G){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),H=H===e?H:Vr(ct(H),0),G=G===e?G:ct(G),ue-=I?I.length:0,p&w){var le=x,de=I;x=I=e}var be=J?e:sE(c),qe=[c,p,y,x,I,le,de,L,H,G];if(be&&rTe(qe,be),c=qe[0],p=qe[1],y=qe[2],x=qe[3],I=qe[4],G=qe[9]=qe[9]===e?J?0:c.length:Vr(qe[9]-ue,0),!G&&p&(b|C)&&(p&=~(b|C)),!p||p==g)var ze=MEe(c,p,y);else p==b||p==C?ze=jEe(c,p,G):(p==T||p==(g|T))&&!I.length?ze=BEe(c,p,y,x):ze=Mv.apply(e,qe);var lt=be?oF:FF;return MF(lt(ze,qe),c,p)}function AF(c,p,y,x){return c===e||As(c,ql[y])&&!Ft.call(x,y)?p:c}function IF(c,p,y,x,I,L){return vr(c)&&vr(p)&&(L.set(p,c),qv(c,p,e,IF,L),L.delete(p)),c}function $Ee(c){return Od(c)?e:c}function NF(c,p,y,x,I,L){var H=y&h,G=c.length,J=p.length;if(G!=J&&!(H&&J>G))return!1;var ue=L.get(c),le=L.get(p);if(ue&&le)return ue==p&&le==c;var de=-1,be=!0,qe=y&m?new Ku:e;for(L.set(c,p),L.set(p,c);++de<G;){var ze=c[de],lt=p[de];if(x)var Ve=H?x(lt,ze,de,p,c,L):x(ze,lt,de,c,p,L);if(Ve!==e){if(Ve)continue;be=!1;break}if(qe){if(!CS(p,function(ht,St){if(!gd(qe,St)&&(ze===ht||I(ze,ht,y,x,L)))return qe.push(St)})){be=!1;break}}else if(!(ze===lt||I(ze,lt,y,x,L))){be=!1;break}}return L.delete(c),L.delete(p),be}function HEe(c,p,y,x,I,L,H){switch(y){case q:if(c.byteLength!=p.byteLength||c.byteOffset!=p.byteOffset)return!1;c=c.buffer,p=p.buffer;case Zs:return!(c.byteLength!=p.byteLength||!L(new wv(c),new wv(p)));case Re:case Lt:case X:return As(+c,+p);case ge:return c.name==p.name&&c.message==p.message;case jr:case Xt:return c==p+"";case te:var G=kS;case Ne:var J=x&h;if(G||(G=gv),c.size!=p.size&&!J)return!1;var ue=H.get(c);if(ue)return ue==p;x|=m,H.set(c,p);var le=NF(G(c),G(p),x,I,L,H);return H.delete(c),le;case fn:if(bd)return bd.call(c)==bd.call(p)}return!1}function WEe(c,p,y,x,I,L){var H=y&h,G=nE(c),J=G.length,ue=nE(p),le=ue.length;if(J!=le&&!H)return!1;for(var de=J;de--;){var be=G[de];if(!(H?be in p:Ft.call(p,be)))return!1}var qe=L.get(c),ze=L.get(p);if(qe&&ze)return qe==p&&ze==c;var lt=!0;L.set(c,p),L.set(p,c);for(var Ve=H;++de<J;){be=G[de];var ht=c[be],St=p[be];if(x)var Ai=H?x(St,ht,be,p,c,L):x(ht,St,be,c,p,L);if(!(Ai===e?ht===St||I(ht,St,y,x,L):Ai)){lt=!1;break}Ve||(Ve=be=="constructor")}if(lt&&!Ve){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 Bo(c){return fE(DF(c,e,WF),c+"")}function nE(c){return X2(c,rn,aE)}function iE(c){return X2(c,ni,OF)}var sE=Iv?function(c){return Iv.get(c)}:EE;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(k,"placeholder")?k:c;return p.placeholder}function Ue(){var c=k.iteratee||wE;return c=c===wE?J2:c,arguments.length?c(arguments[0],arguments[1]):c}function Hv(c,p){var y=c.__data__;return JEe(p)?y[typeof p=="string"?"string":"hash"]:y.map}function oE(c){for(var p=rn(c),y=p.length;y--;){var x=p[y],I=c[x];p[y]=[x,I,PF(I)]}return p}function Zu(c,p){var y=tSe(c,p);return Z2(y)?y:e}function zEe(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 aE=qS?function(c){return c==null?[]:(c=Yt(c),Pa(qS(c),function(p){return L2.call(c,p)}))}:TE,OF=qS?function(c){for(var p=[];c;)qa(p,aE(c)),c=Sv(c);return p}:TE,Nn=Un;(DS&&Nn(new DS(new ArrayBuffer(1)))!=q||yd&&Nn(new yd)!=te||LS&&Nn(LS.resolve())!=zt||Dl&&Nn(new Dl)!=Ne||_d&&Nn(new _d)!=Ys)&&(Nn=function(c){var p=Un(c),y=p==Be?c.constructor:e,x=y?Ju(y):"";if(x)switch(x){case ASe:return q;case ISe:return te;case NSe:return zt;case OSe:return Ne;case RSe:return Ys}return p});function VEe(c,p,y){for(var x=-1,I=y.length;++x<I;){var L=y[x],H=L.size;switch(L.type){case"drop":c+=H;break;case"dropRight":p-=H;break;case"take":p=In(p,c+H);break;case"takeRight":c=Vr(c,p-H);break}}return{start:c,end:p}}function GEe(c){var p=c.match(Qwe);return p?p[1].split(e0e):[]}function RF(c,p,y){p=Ba(p,c);for(var x=-1,I=p.length,L=!1;++x<I;){var H=eo(p[x]);if(!(L=c!=null&&y(c,H)))break;c=c[H]}return L||++x!=I?L:(I=c==null?0:c.length,!!I&&Yv(I)&&Uo(H,I)&&(st(c)||Qu(c)))}function KEe(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 kF(c){return typeof c.constructor=="function"&&!Id(c)?Fl(Sv(c)):{}}function XEe(c,p,y){var x=c.constructor;switch(p){case Zs:return eE(c);case Re:case Lt:return new x(+c);case q:return kEe(c,y);case W:case K:case se:case ce:case Se:case Ze:case dt:case Wr:case bi:return hF(c,y);case te:return new x;case X:case Xt:return new x(c);case jr:return PEe(c);case Ne:return new x;case fn:return qEe(c)}}function YEe(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
|
+
`),qXe.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=BXe;function UXe(e){return wu.__awaiter(this,void 0,void 0,function(){var t,r,n;return wu.__generator(this,function(i){switch(i.label){case 0:if(t=cR.get(e),t!==void 0)return[2,t];r=null,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,MXe(e)];case 2:return r=i.sent(),[3,4];case 3:return n=i.sent(),[3,4];case 4:return cR.set(e,r),[2,r]}})})}});var DZ=v(pR=>{Object.defineProperty(pR,"__esModule",{value:!0});var db=(gn(),mt(mn)),fR=Yr(),hb=Rt(),$Xe=AO(),HXe=lR(),WXe="cause",zXe=5,VXe=function(){function e(t){t===void 0&&(t={}),this.name=e.id,this._key=t.key||WXe,this._limit=t.limit||zXe}return e.prototype.setupOnce=function(){fR.addGlobalEventProcessor(function(t,r){var n=fR.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=$Xe.exceptionFromError(t[r]),o=fR.getCurrentHub().getIntegration(HXe.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}();pR.LinkedErrors=VXe});var jZ=v(hR=>{Object.defineProperty(hR,"__esModule",{value:!0});var LZ=(gn(),mt(mn)),FZ=require("fs"),MZ=require("path"),dR;function GXe(){try{return require.cache?Object.keys(require.cache):[]}catch{return[]}}function KXe(){var e=require.main&&require.main.paths||[],t=GXe(),r={},n={};return t.forEach(function(i){var s=i,o=function(){var a=s;if(s=MZ.dirname(a),!(!s||a===s||n[a])){if(e.indexOf(s)<0)return o();var u=MZ.join(a,"package.json");if(n[a]=!0,!FZ.existsSync(u))return o();try{var l=JSON.parse(FZ.readFileSync(u,"utf8"));r[l.name]=l.version}catch{}}};o()}),r}var XXe=function(){function e(){this.name=e.id}return e.prototype.setupOnce=function(t,r){var n=this;t(function(i){return r().getIntegration(e)?LZ.__assign(LZ.__assign({},i),{modules:n._getModules()}):i})},e.prototype._getModules=function(){return dR||(dR=KXe()),dR},e.id="Modules",e}();hR.Modules=XXe});var mR=v(pa=>{Object.defineProperty(pa,"__esModule",{value:!0});var YXe=yZ();pa.Console=YXe.Console;var ZXe=AZ();pa.Http=ZXe.Http;var JXe=RZ();pa.OnUncaughtException=JXe.OnUncaughtException;var QXe=PZ();pa.OnUnhandledRejection=QXe.OnUnhandledRejection;var eYe=DZ();pa.LinkedErrors=eYe.LinkedErrors;var tYe=jZ();pa.Modules=tYe.Modules;var rYe=lR();pa.ContextLines=rYe.ContextLines});var vR=v(vo=>{Object.defineProperty(vo,"__esModule",{value:!0});var vm=(gn(),mt(mn)),Su=Yr(),BZ=mo(),gR=Rt(),nYe=require("domain"),iYe=JO(),UZ=xu(),vp=mR();vo.defaultIntegrations=[new Su.Integrations.InboundFilters,new Su.Integrations.FunctionToString,new vp.ContextLines,new vp.Console,new vp.Http,new vp.OnUncaughtException,new vp.OnUnhandledRejection,new vp.LinkedErrors];function sYe(e){e===void 0&&(e={});var t,r=BZ.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:vo.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=$Z();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),nYe.active&&BZ.setHubOnCarrier(r,Su.getCurrentHub()),Su.initAndBind(iYe.NodeClient,e),e.autoSessionTracking&&lYe()}vo.init=sYe;function oYe(){return Su.getCurrentHub().lastEventId()}vo.lastEventId=oYe;function aYe(e){return vm.__awaiter(this,void 0,void 0,function(){var t;return vm.__generator(this,function(r){return t=Su.getCurrentHub().getClient(),t?[2,t.flush(e)]:(UZ.IS_DEBUG_BUILD&&gR.logger.warn("Cannot flush events. No client defined."),[2,Promise.resolve(!1)])})})}vo.flush=aYe;function uYe(e){return vm.__awaiter(this,void 0,void 0,function(){var t;return vm.__generator(this,function(r){return t=Su.getCurrentHub().getClient(),t?[2,t.close(e)]:(UZ.IS_DEBUG_BUILD&&gR.logger.warn("Cannot flush events and disable SDK. No client defined."),[2,Promise.resolve(!1)])})})}vo.close=uYe;function cYe(e){if(e===void 0)return!1;var t=e&&e.getOptions();return t&&t.autoSessionTracking!==void 0?t.autoSessionTracking:!1}vo.isAutoSessionTrackingEnabled=cYe;function $Z(e){if(process.env.SENTRY_RELEASE)return process.env.SENTRY_RELEASE;var t=gR.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}vo.getSentryRelease=$Z;function lYe(){var e=Su.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 WZ=v(_R=>{Object.defineProperty(_R,"__esModule",{value:!0});var HZ=(gn(),mt(mn)),mb=require("fs"),yR=require("path");function fYe(e){var t=yR.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=yR.join(n,s);return mb.statSync(o).isDirectory()?HZ.__spread(i,r(o)):HZ.__spread(i,[o])},[])};return r(t).map(function(n){return yR.relative(t,n)})}_R.deepReadDirSync=fYe});var zZ=v(xR=>{"use strict";xR.parse=hYe;xR.serialize=mYe;var pYe=decodeURIComponent,dYe=encodeURIComponent,gb=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;function hYe(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||pYe,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]=gYe(f,s)}}}return r}function mYe(e,t,r){var n=r||{},i=n.encode||dYe;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 gYe(e,t){try{return t(e)}catch{return e}}});var GZ=v(Zc=>{Object.defineProperty(Zc,"__esModule",{value:!0});var yo=(gn(),mt(mn)),Xc=Yr(),Yc=Rt(),vYe=zZ(),yYe=require("domain"),_Ye=require("os"),xYe=require("url"),bYe=xu(),ym=vR();function wYe(){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(yo.__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(){SYe(s,t),s.setHttpStatus(r.statusCode),s.finish()})}),n()}}Zc.tracingHandler=wYe;function SYe(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 EYe(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 TYe=["id","username","email"];function CYe(e,t){var r={},n=Array.isArray(t)?t:TYe;return n.forEach(function(i){e&&i in e&&(r[i]=e[i])}),r}var AYe=["cookies","data","headers","method","query_string","url"];function yb(e,t){t===void 0&&(t=AYe);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||vYe.parse(n.cookie||"");break;case"query_string":r.query_string=e.query||xYe.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 VZ(e,t,r){if(r=yo.__assign({ip:!1,request:!0,serverName:!0,transaction:!0,user:!0,version:!0},r),r.version&&(e.contexts=yo.__assign(yo.__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=yo.__assign(yo.__assign({},e.request),n)}if(r.serverName&&!e.server_name&&(e.server_name=global.process.env.SENTRY_NAME||_Ye.hostname()),r.user){var i=t.user&&Yc.isPlainObject(t.user)?CYe(t.user,r.user):{};Object.keys(i)&&(e.user=yo.__assign(yo.__assign({},e.user),i))}if(r.ip){var s=t.ip||t.connection&&t.connection.remoteAddress;s&&(e.user=yo.__assign(yo.__assign({},e.user),{ip_address:s}))}return r.transaction&&!e.transaction&&(e.transaction=EYe(t,r.transaction)),e}Zc.parseRequest=VZ;function IYe(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){bYe.IS_DEBUG_BUILD&&Yc.logger.error(g),u.call(m,f,d,h)})}}var l=yYe.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 VZ(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=IYe;function NYe(e){var t=e.status||e.statusCode||e.status_code||e.output&&e.output.statusCode;return t?parseInt(t,10):500}function OYe(e){var t=NYe(e);return t>=500}function RYe(e){return function(r,n,i,s){var o=e&&e.shouldHandleError||OYe;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=RYe});var XZ=v(vt=>{Object.defineProperty(vt,"__esModule",{value:!0});var KZ=(gn(),mt(mn)),kYe=Jf();vt.Severity=kYe.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 PYe=XO();vt.NodeBackend=PYe.NodeBackend;var qYe=JO();vt.NodeClient=qYe.NodeClient;var yp=vR();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 DYe=WZ();vt.deepReadDirSync=DYe.deepReadDirSync;var LYe=OO();vt.SDK_NAME=LYe.SDK_NAME;var FYe=Yr(),MYe=mo(),jYe=require("domain"),BYe=GZ();vt.Handlers=BYe;var UYe=mR(),$Ye=WO();vt.Transports=$Ye;var HYe=KZ.__assign(KZ.__assign({},FYe.Integrations),UYe);vt.Integrations=HYe;var _m=MYe.getMainCarrier();_m.__SENTRY__&&(_m.__SENTRY__.extensions=_m.__SENTRY__.extensions||{},_m.__SENTRY__.extensions.domain=_m.__SENTRY__.extensions.domain||jYe)});var YZ,bm,ZZ,xm,bR,$t,_o=oe(()=>{"use strict";YZ=ve(sX()),bm=ve(XZ());ur();_p();ZZ=()=>{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};ZZ()&&bm.init({dsn:"https://5f27cbf3265a475abff6b7999ae73179@o1265020.ingest.sentry.io/6448443",tracesSampleRate:1});bR=class{constructor(){Rr(this,"orgName");Rr(this,"user");Rr(this,"config");kd(this,xm,(0,YZ.ulid)());Rr(this,"auth");Rr(this,"captureException",t=>{da.error({err:t},"captureException"),ZZ()&&bm&&bm.captureException(t,{tags:{sessionId:Ns(this,xm)}})})}getSessionId(){return Ns(this,xm)}loadAmptConfig(){this.config=wR(),da.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},SR(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}}}),da.debug({userName:t.username},"saved config file"),this.setUser(t),da.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}}};xm=new WeakMap;$t=new bR});var _b,xb,Eu,ER,we,da,_p=oe(()=>{"use strict";_b=ve(nX()),xb=ve(require("path")),Eu=ve(mc());_o();ER=class{logger;enabled;logFilePath;logToConsole;pinoArgs;pinoDestination;initLogDestination(){try{(0,Eu.removeSync)(this.logFilePath)}catch(t){process.env.AMPT_DEBUG&&console.error("Error removing log file: ",t)}finally{if(this.enabled)try{(0,Eu.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,Eu.existsSync)(t)||(0,Eu.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)}},we=new ER,da=we});var wm=v((G2t,WYe)=>{WYe.exports={name:"@ampt/cli",version:"1.0.38-beta.1",description:"Ampt command line interface",main:"./dist/index.js",types:"./types/index.d.ts",engines:{node:">=18.0.0 <=18.19.1"},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 QZ,JZ,zYe,TR,CR,$e,Q2t,AR=oe(()=>{"use strict";QZ=ve(require("https"));hx();Z9();_p();_o();({version:JZ}=wm()),zYe=new QZ.default.Agent({keepAlive:!0}),TR=class e{axios;static config(){return{apiEndpoint:process.env.AMPT_ENDPOINT,apiKey:process.env.AMPT_API_KEY}}constructor(){this.axios=lo.create({httpsAgent:zYe}),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&&da.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,O,U,M,F,R;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/${JZ}`,u["ampt-version"]=JZ,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 da.debug({method:o,url:d,sessionId:m},"request"),(await this.axios(g)).data}catch(P){if(((S=P.response)==null?void 0:S.status)===403&&((C=(b=P.response)==null?void 0:b.data)==null?void 0:C.code)==="EXPIRED_TOKEN")return da.debug({status:P.response.status,code:P.response.data.code},"Token expired, refreshing"),await((T=$t.user)==null?void 0:T.refreshAccessToken()),this.request(t);if(((w=P.response)==null?void 0:w.status)===403){let N=new Error("Forbidden");throw N.message="You do not have permission to access this resource.",N.name="ForbiddenError",N}if(((E=P.response)==null?void 0:E.status)===404)return;if(((O=P.response)==null?void 0:O.status)===409){let N=new Error("Conflict");throw N.message="Conflict",N.name="ConflictError",N}if(P.response&&P.response.data){let N=new Error(P.response.data.message||P.response.data);throw(U=P.response.data.message)!=null&&U.includes("Request Entity Too Large")?(N.message="Your code size is too large. Try reducing it by adding to .deployignore",N.name="EntityTooLargeError"):(M=P.response.data.message)!=null&&M.includes("User disabled")?(N.message=P.response.data.detail||"Your account has been disabled. Please contact support@getampt.com for more information.",N.name="UserDisabledError"):(F=P.response.data.message)!=null&&F.includes("App limit reached")?(N.message="You have reached your Organization's app limit. Please upgrade your plan or delete an app.",N.name="AppLimitReachedError"):(R=P.response.data.message)!=null&&R.includes("Instance limit reached")?(N.message="You have reached your Organization's environment limit. Please upgrade your plan or delete an environment.",N.name="EnvironmentLimitReachedError"):N.name=P.response.data.name||null,N.statusCode=P.response.data.statusCode||P.response.status||null,N}throw P}}},CR=new TR,$e=CR.request.bind(CR),Q2t=CR.request});var eJ,tJ=oe(()=>{"use strict";eJ=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,rJ=oe(()=>{"use strict";bb=e=>e?e===0?"less than a second":e===1?"1 second":`${e} seconds`:"a few seconds"});var Tu,IR=oe(()=>{"use strict";Tu=async e=>new Promise(t=>setTimeout(t,e).unref())});var cr,NR,OR=oe(()=>{"use strict";ur();_o();cr=e=>{(async()=>{let{eventName:t,eventData:r={}}=e,n=$t.orgName;if(!n){we.warn({eventName:t},"Could not send report - no org name found");return}try{await $e({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)}})()},NR=cr});async function wb(e){try{let t="https://ampt.dev/public/templates/manifest-tags.json",{data:r}=await lo.get(t);return r.filter(n=>n.tags.includes("starter"))}catch(t){return process.env.AMPT_DEBUG&&e.logError(t),[]}}var RR=oe(()=>{"use strict";hx()});var kR,nJ,PR=oe(()=>{"use strict";kR=e=>{try{return process.kill(e,0)}catch(t){return t.code==="EPERM"}},nJ=kR});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 iJ=oe(()=>{"use strict"});function sJ(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 oJ=oe(()=>{"use strict"});var aJ=oe(()=>{"use strict"});var uJ=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,O=256,U=512,M=30,F="...",R=800,P=16,N=1,z=2,Y=3,j=1/0,B=9007199254740991,ee=17976931348623157e292,V=0/0,ie=4294967295,pe=ie-1,ye=ie>>>1,He=[["ary",E],["bind",g],["bindKey",_],["curry",b],["curryRight",C],["flip",U],["partial",T],["partialRight",w],["rearg",O]],ot="[object Arguments]",Ye="[object Array]",nt="[object AsyncFunction]",Re="[object Boolean]",Lt="[object Date]",it="[object DOMException]",ge="[object Error]",D="[object Function]",A="[object GeneratorFunction]",te="[object Map]",X="[object Number]",Ge="[object Null]",Be="[object Object]",zt="[object Promise]",gr="[object Proxy]",jr="[object RegExp]",Ne="[object Set]",Xt="[object String]",fn="[object Symbol]",Al="[object Undefined]",Ys="[object WeakMap]",$u="[object WeakSet]",Zs="[object ArrayBuffer]",q="[object DataView]",W="[object Float32Array]",K="[object Float64Array]",se="[object Int8Array]",ce="[object Int16Array]",Se="[object Int32Array]",Ze="[object Uint8Array]",dt="[object Uint8ClampedArray]",Wr="[object Uint16Array]",bi="[object Uint32Array]",Ir=/\b__p \+= '';/g,We=/\b(__p \+=) '' \+/g,Es=/(__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?/,Qwe=/\{\n\/\* \[wrapped with (.+)\] \*/,e0e=/,? & /,t0e=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,r0e=/[()=,{}\[\]\/\s]/,n0e=/\\(\\)?/g,i0e=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,YL=/\w*$/,s0e=/^[-+]0x[0-9a-f]+$/i,o0e=/^0b[01]+$/i,a0e=/^\[object .+?Constructor\]$/,u0e=/^0o[0-7]+$/i,c0e=/^(?:0|[1-9]\d*)$/,l0e=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,fv=/($^)/,f0e=/['\n\r\u2028\u2029\\]/g,pv="\\ud800-\\udfff",p0e="\\u0300-\\u036f",d0e="\\ufe20-\\ufe2f",h0e="\\u20d0-\\u20ff",ZL=p0e+d0e+h0e,JL="\\u2700-\\u27bf",QL="a-z\\xdf-\\xf6\\xf8-\\xff",m0e="\\xac\\xb1\\xd7\\xf7",g0e="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",v0e="\\u2000-\\u206f",y0e=" \\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",e2="A-Z\\xc0-\\xd6\\xd8-\\xde",t2="\\ufe0e\\ufe0f",r2=m0e+g0e+v0e+y0e,vS="['\u2019]",_0e="["+pv+"]",n2="["+r2+"]",dv="["+ZL+"]",i2="\\d+",x0e="["+JL+"]",s2="["+QL+"]",o2="[^"+pv+r2+i2+JL+QL+e2+"]",yS="\\ud83c[\\udffb-\\udfff]",b0e="(?:"+dv+"|"+yS+")",a2="[^"+pv+"]",_S="(?:\\ud83c[\\udde6-\\uddff]){2}",xS="[\\ud800-\\udbff][\\udc00-\\udfff]",Ol="["+e2+"]",u2="\\u200d",c2="(?:"+s2+"|"+o2+")",w0e="(?:"+Ol+"|"+o2+")",l2="(?:"+vS+"(?:d|ll|m|re|s|t|ve))?",f2="(?:"+vS+"(?:D|LL|M|RE|S|T|VE))?",p2=b0e+"?",d2="["+t2+"]?",S0e="(?:"+u2+"(?:"+[a2,_S,xS].join("|")+")"+d2+p2+")*",E0e="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",T0e="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",h2=d2+p2+S0e,C0e="(?:"+[x0e,_S,xS].join("|")+")"+h2,A0e="(?:"+[a2+dv+"?",dv,_S,xS,_0e].join("|")+")",I0e=RegExp(vS,"g"),N0e=RegExp(dv,"g"),bS=RegExp(yS+"(?="+yS+")|"+A0e+h2,"g"),O0e=RegExp([Ol+"?"+s2+"+"+l2+"(?="+[n2,Ol,"$"].join("|")+")",w0e+"+"+f2+"(?="+[n2,Ol+c2,"$"].join("|")+")",Ol+"?"+c2+"+"+l2,Ol+"+"+f2,T0e,E0e,i2,C0e].join("|"),"g"),R0e=RegExp("["+u2+pv+ZL+t2+"]"),k0e=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,P0e=["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"],q0e=-1,rr={};rr[W]=rr[K]=rr[se]=rr[ce]=rr[Se]=rr[Ze]=rr[dt]=rr[Wr]=rr[bi]=!0,rr[ot]=rr[Ye]=rr[Zs]=rr[Re]=rr[q]=rr[Lt]=rr[ge]=rr[D]=rr[te]=rr[X]=rr[Be]=rr[jr]=rr[Ne]=rr[Xt]=rr[Ys]=!1;var er={};er[ot]=er[Ye]=er[Zs]=er[q]=er[Re]=er[Lt]=er[W]=er[K]=er[se]=er[ce]=er[Se]=er[te]=er[X]=er[Be]=er[jr]=er[Ne]=er[Xt]=er[fn]=er[Ze]=er[dt]=er[Wr]=er[bi]=!0,er[ge]=er[D]=er[Ys]=!1;var D0e={\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"},L0e={"&":"&","<":"<",">":">",'"':""","'":"'"},F0e={"&":"&","<":"<",">":">",""":'"',"'":"'"},M0e={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},j0e=parseFloat,B0e=parseInt,m2=typeof global=="object"&&global&&global.Object===Object&&global,U0e=typeof self=="object"&&self&&self.Object===Object&&self,tn=m2||U0e||Function("return this")(),wS=typeof xp=="object"&&xp&&!xp.nodeType&&xp,zu=wS&&typeof Sm=="object"&&Sm&&!Sm.nodeType&&Sm,g2=zu&&zu.exports===wS,SS=g2&&m2.process,Vi=function(){try{var Z=zu&&zu.require&&zu.require("util").types;return Z||SS&&SS.binding&&SS.binding("util")}catch{}}(),v2=Vi&&Vi.isArrayBuffer,y2=Vi&&Vi.isDate,_2=Vi&&Vi.isMap,x2=Vi&&Vi.isRegExp,b2=Vi&&Vi.isSet,w2=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 $0e(Z,ae,ne,Te){for(var Je=-1,Ot=Z==null?0:Z.length;++Je<Ot;){var zr=Z[Je];ae(Te,zr,ne(zr),Z)}return Te}function Gi(Z,ae){for(var ne=-1,Te=Z==null?0:Z.length;++ne<Te&&ae(Z[ne],ne,Z)!==!1;);return Z}function H0e(Z,ae){for(var ne=Z==null?0:Z.length;ne--&&ae(Z[ne],ne,Z)!==!1;);return Z}function S2(Z,ae){for(var ne=-1,Te=Z==null?0:Z.length;++ne<Te;)if(!ae(Z[ne],ne,Z))return!1;return!0}function Pa(Z,ae){for(var ne=-1,Te=Z==null?0:Z.length,Je=0,Ot=[];++ne<Te;){var zr=Z[ne];ae(zr,ne,Z)&&(Ot[Je++]=zr)}return Ot}function hv(Z,ae){var ne=Z==null?0:Z.length;return!!ne&&Rl(Z,ae,0)>-1}function ES(Z,ae,ne){for(var Te=-1,Je=Z==null?0:Z.length;++Te<Je;)if(ne(ae,Z[Te]))return!0;return!1}function sr(Z,ae){for(var ne=-1,Te=Z==null?0:Z.length,Je=Array(Te);++ne<Te;)Je[ne]=ae(Z[ne],ne,Z);return Je}function qa(Z,ae){for(var ne=-1,Te=ae.length,Je=Z.length;++ne<Te;)Z[Je+ne]=ae[ne];return Z}function TS(Z,ae,ne,Te){var Je=-1,Ot=Z==null?0:Z.length;for(Te&&Ot&&(ne=Z[++Je]);++Je<Ot;)ne=ae(ne,Z[Je],Je,Z);return ne}function W0e(Z,ae,ne,Te){var Je=Z==null?0:Z.length;for(Te&&Je&&(ne=Z[--Je]);Je--;)ne=ae(ne,Z[Je],Je,Z);return ne}function CS(Z,ae){for(var ne=-1,Te=Z==null?0:Z.length;++ne<Te;)if(ae(Z[ne],ne,Z))return!0;return!1}var z0e=AS("length");function V0e(Z){return Z.split("")}function G0e(Z){return Z.match(t0e)||[]}function E2(Z,ae,ne){var Te;return ne(Z,function(Je,Ot,zr){if(ae(Je,Ot,zr))return Te=Ot,!1}),Te}function mv(Z,ae,ne,Te){for(var Je=Z.length,Ot=ne+(Te?1:-1);Te?Ot--:++Ot<Je;)if(ae(Z[Ot],Ot,Z))return Ot;return-1}function Rl(Z,ae,ne){return ae===ae?sSe(Z,ae,ne):mv(Z,T2,ne)}function K0e(Z,ae,ne,Te){for(var Je=ne-1,Ot=Z.length;++Je<Ot;)if(Te(Z[Je],ae))return Je;return-1}function T2(Z){return Z!==Z}function C2(Z,ae){var ne=Z==null?0:Z.length;return ne?NS(Z,ae)/ne:V}function AS(Z){return function(ae){return ae==null?e:ae[Z]}}function IS(Z){return function(ae){return Z==null?e:Z[ae]}}function A2(Z,ae,ne,Te,Je){return Je(Z,function(Ot,zr,Yt){ne=Te?(Te=!1,Ot):ae(ne,Ot,zr,Yt)}),ne}function X0e(Z,ae){var ne=Z.length;for(Z.sort(ae);ne--;)Z[ne]=Z[ne].value;return Z}function NS(Z,ae){for(var ne,Te=-1,Je=Z.length;++Te<Je;){var Ot=ae(Z[Te]);Ot!==e&&(ne=ne===e?Ot:ne+Ot)}return ne}function OS(Z,ae){for(var ne=-1,Te=Array(Z);++ne<Z;)Te[ne]=ae(ne);return Te}function Y0e(Z,ae){return sr(ae,function(ne){return[ne,Z[ne]]})}function I2(Z){return Z&&Z.slice(0,k2(Z)+1).replace(Wu,"")}function Ei(Z){return function(ae){return Z(ae)}}function RS(Z,ae){return sr(ae,function(ne){return Z[ne]})}function gd(Z,ae){return Z.has(ae)}function N2(Z,ae){for(var ne=-1,Te=Z.length;++ne<Te&&Rl(ae,Z[ne],0)>-1;);return ne}function O2(Z,ae){for(var ne=Z.length;ne--&&Rl(ae,Z[ne],0)>-1;);return ne}function Z0e(Z,ae){for(var ne=Z.length,Te=0;ne--;)Z[ne]===ae&&++Te;return Te}var J0e=IS(D0e),Q0e=IS(L0e);function eSe(Z){return"\\"+M0e[Z]}function tSe(Z,ae){return Z==null?e:Z[ae]}function kl(Z){return R0e.test(Z)}function rSe(Z){return k0e.test(Z)}function nSe(Z){for(var ae,ne=[];!(ae=Z.next()).done;)ne.push(ae.value);return ne}function kS(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Te,Je){ne[++ae]=[Je,Te]}),ne}function R2(Z,ae){return function(ne){return Z(ae(ne))}}function Da(Z,ae){for(var ne=-1,Te=Z.length,Je=0,Ot=[];++ne<Te;){var zr=Z[ne];(zr===ae||zr===u)&&(Z[ne]=u,Ot[Je++]=ne)}return Ot}function gv(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Te){ne[++ae]=Te}),ne}function iSe(Z){var ae=-1,ne=Array(Z.size);return Z.forEach(function(Te){ne[++ae]=[Te,Te]}),ne}function sSe(Z,ae,ne){for(var Te=ne-1,Je=Z.length;++Te<Je;)if(Z[Te]===ae)return Te;return-1}function oSe(Z,ae,ne){for(var Te=ne+1;Te--;)if(Z[Te]===ae)return Te;return Te}function Pl(Z){return kl(Z)?uSe(Z):z0e(Z)}function Ts(Z){return kl(Z)?cSe(Z):V0e(Z)}function k2(Z){for(var ae=Z.length;ae--&&cv.test(Z.charAt(ae)););return ae}var aSe=IS(F0e);function uSe(Z){for(var ae=bS.lastIndex=0;bS.test(Z);)++ae;return ae}function cSe(Z){return Z.match(bS)||[]}function lSe(Z){return Z.match(O0e)||[]}var fSe=function Z(ae){ae=ae==null?tn:La.defaults(tn.Object(),ae,La.pick(tn,P0e));var ne=ae.Array,Te=ae.Date,Je=ae.Error,Ot=ae.Function,zr=ae.Math,Yt=ae.Object,PS=ae.RegExp,pSe=ae.String,Ki=ae.TypeError,vv=ne.prototype,dSe=Ot.prototype,ql=Yt.prototype,yv=ae["__core-js_shared__"],_v=dSe.toString,Ft=ql.hasOwnProperty,hSe=0,P2=function(){var c=/[^.]+$/.exec(yv&&yv.keys&&yv.keys.IE_PROTO||"");return c?"Symbol(src)_1."+c:""}(),xv=ql.toString,mSe=_v.call(Yt),gSe=tn._,vSe=PS("^"+_v.call(Ft).replace(Hu,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),bv=g2?ae.Buffer:e,Fa=ae.Symbol,wv=ae.Uint8Array,q2=bv?bv.allocUnsafe:e,Sv=R2(Yt.getPrototypeOf,Yt),D2=Yt.create,L2=ql.propertyIsEnumerable,Ev=vv.splice,F2=Fa?Fa.isConcatSpreadable:e,vd=Fa?Fa.iterator:e,Vu=Fa?Fa.toStringTag:e,Tv=function(){try{var c=Zu(Yt,"defineProperty");return c({},"",{}),c}catch{}}(),ySe=ae.clearTimeout!==tn.clearTimeout&&ae.clearTimeout,_Se=Te&&Te.now!==tn.Date.now&&Te.now,xSe=ae.setTimeout!==tn.setTimeout&&ae.setTimeout,Cv=zr.ceil,Av=zr.floor,qS=Yt.getOwnPropertySymbols,bSe=bv?bv.isBuffer:e,M2=ae.isFinite,wSe=vv.join,SSe=R2(Yt.keys,Yt),Vr=zr.max,In=zr.min,ESe=Te.now,TSe=ae.parseInt,j2=zr.random,CSe=vv.reverse,DS=Zu(ae,"DataView"),yd=Zu(ae,"Map"),LS=Zu(ae,"Promise"),Dl=Zu(ae,"Set"),_d=Zu(ae,"WeakMap"),xd=Zu(Yt,"create"),Iv=_d&&new _d,Ll={},ASe=Ju(DS),ISe=Ju(yd),NSe=Ju(LS),OSe=Ju(Dl),RSe=Ju(_d),Nv=Fa?Fa.prototype:e,bd=Nv?Nv.valueOf:e,B2=Nv?Nv.toString:e;function k(c){if(wr(c)&&!st(c)&&!(c instanceof yt)){if(c instanceof Xi)return c;if(Ft.call(c,"__wrapped__"))return UF(c)}return new Xi(c)}var Fl=function(){function c(){}return function(p){if(!vr(p))return{};if(D2)return D2(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}k.templateSettings={escape:pd,evaluate:wi,interpolate:dd,variable:"",imports:{_:k}},k.prototype=Ov.prototype,k.prototype.constructor=k,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__=ie,this.__views__=[]}function kSe(){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 PSe(){if(this.__filtered__){var c=new yt(this);c.__dir__=-1,c.__filtered__=!0}else c=this.clone(),c.__dir__*=-1;return c}function qSe(){var c=this.__wrapped__.value(),p=this.__dir__,y=st(c),x=p<0,I=y?c.length:0,L=VEe(0,I,this.__views__),H=L.start,G=L.end,J=G-H,ue=x?G:H-1,le=this.__iteratees__,de=le.length,be=0,qe=In(J,this.__takeCount__);if(!y||!x&&I==J&&qe==J)return lF(c,this.__actions__);var ze=[];e:for(;J--&&be<qe;){ue+=p;for(var lt=-1,Ve=c[ue];++lt<de;){var ht=le[lt],St=ht.iteratee,Ai=ht.type,Hn=St(Ve);if(Ai==z)Ve=Hn;else if(!Hn){if(Ai==N)continue e;break e}}ze[be++]=Ve}return ze}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 DSe(){this.__data__=xd?xd(null):{},this.size=0}function LSe(c){var p=this.has(c)&&delete this.__data__[c];return this.size-=p?1:0,p}function FSe(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 MSe(c){var p=this.__data__;return xd?p[c]!==e:Ft.call(p,c)}function jSe(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=DSe,Gu.prototype.delete=LSe,Gu.prototype.get=FSe,Gu.prototype.has=MSe,Gu.prototype.set=jSe;function Lo(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 BSe(){this.__data__=[],this.size=0}function USe(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 $Se(c){var p=this.__data__,y=Rv(p,c);return y<0?e:p[y][1]}function HSe(c){return Rv(this.__data__,c)>-1}function WSe(c,p){var y=this.__data__,x=Rv(y,c);return x<0?(++this.size,y.push([c,p])):y[x][1]=p,this}Lo.prototype.clear=BSe,Lo.prototype.delete=USe,Lo.prototype.get=$Se,Lo.prototype.has=HSe,Lo.prototype.set=WSe;function Fo(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 zSe(){this.size=0,this.__data__={hash:new Gu,map:new(yd||Lo),string:new Gu}}function VSe(c){var p=Hv(this,c).delete(c);return this.size-=p?1:0,p}function GSe(c){return Hv(this,c).get(c)}function KSe(c){return Hv(this,c).has(c)}function XSe(c,p){var y=Hv(this,c),x=y.size;return y.set(c,p),this.size+=y.size==x?0:1,this}Fo.prototype.clear=zSe,Fo.prototype.delete=VSe,Fo.prototype.get=GSe,Fo.prototype.has=KSe,Fo.prototype.set=XSe;function Ku(c){var p=-1,y=c==null?0:c.length;for(this.__data__=new Fo;++p<y;)this.add(c[p])}function YSe(c){return this.__data__.set(c,o),this}function ZSe(c){return this.__data__.has(c)}Ku.prototype.add=Ku.prototype.push=YSe,Ku.prototype.has=ZSe;function Cs(c){var p=this.__data__=new Lo(c);this.size=p.size}function JSe(){this.__data__=new Lo,this.size=0}function QSe(c){var p=this.__data__,y=p.delete(c);return this.size=p.size,y}function eEe(c){return this.__data__.get(c)}function tEe(c){return this.__data__.has(c)}function rEe(c,p){var y=this.__data__;if(y instanceof Lo){var x=y.__data__;if(!yd||x.length<r-1)return x.push([c,p]),this.size=++y.size,this;y=this.__data__=new Fo(x)}return y.set(c,p),this.size=y.size,this}Cs.prototype.clear=JSe,Cs.prototype.delete=QSe,Cs.prototype.get=eEe,Cs.prototype.has=tEe,Cs.prototype.set=rEe;function U2(c,p){var y=st(c),x=!y&&Qu(c),I=!y&&!x&&$a(c),L=!y&&!x&&!I&&Ul(c),H=y||x||I||L,G=H?OS(c.length,pSe):[],J=G.length;for(var ue in c)(p||Ft.call(c,ue))&&!(H&&(ue=="length"||I&&(ue=="offset"||ue=="parent")||L&&(ue=="buffer"||ue=="byteLength"||ue=="byteOffset")||Uo(ue,J)))&&G.push(ue);return G}function $2(c){var p=c.length;return p?c[GS(0,p-1)]:e}function nEe(c,p){return Wv(ti(c),Xu(p,0,c.length))}function iEe(c){return Wv(ti(c))}function FS(c,p,y){(y!==e&&!As(c[p],y)||y===e&&!(p in c))&&Mo(c,p,y)}function wd(c,p,y){var x=c[p];(!(Ft.call(c,p)&&As(x,y))||y===e&&!(p in c))&&Mo(c,p,y)}function Rv(c,p){for(var y=c.length;y--;)if(As(c[y][0],p))return y;return-1}function sEe(c,p,y,x){return Ma(c,function(I,L,H){p(x,I,y(I),H)}),x}function H2(c,p){return c&&Qs(p,rn(p),c)}function oEe(c,p){return c&&Qs(p,ni(p),c)}function Mo(c,p,y){p=="__proto__"&&Tv?Tv(c,p,{configurable:!0,enumerable:!0,value:y,writable:!0}):c[p]=y}function MS(c,p){for(var y=-1,x=p.length,I=ne(x),L=c==null;++y<x;)I[y]=L?e:yE(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 H,G=p&l,J=p&f,ue=p&d;if(y&&(H=I?y(c,x,I,L):y(c)),H!==e)return H;if(!vr(c))return c;var le=st(c);if(le){if(H=KEe(c),!G)return ti(c,H)}else{var de=Nn(c),be=de==D||de==A;if($a(c))return dF(c,G);if(de==Be||de==ot||be&&!I){if(H=J||be?{}:kF(c),!G)return J?FEe(c,oEe(H,c)):LEe(c,H2(H,c))}else{if(!er[de])return I?c:{};H=XEe(c,de,G)}}L||(L=new Cs);var qe=L.get(c);if(qe)return qe;L.set(c,H),aM(c)?c.forEach(function(Ve){H.add(Yi(Ve,p,y,Ve,c,L))}):sM(c)&&c.forEach(function(Ve,ht){H.set(ht,Yi(Ve,p,y,ht,c,L))});var ze=ue?J?iE:nE:J?ni:rn,lt=le?e:ze(c);return Gi(lt||c,function(Ve,ht){lt&&(ht=Ve,Ve=c[ht]),wd(H,ht,Yi(Ve,p,y,ht,c,L))}),H}function aEe(c){var p=rn(c);return function(y){return W2(y,c,p)}}function W2(c,p,y){var x=y.length;if(c==null)return!x;for(c=Yt(c);x--;){var I=y[x],L=p[I],H=c[I];if(H===e&&!(I in c)||!L(H))return!1}return!0}function z2(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,H=!0,G=c.length,J=[],ue=p.length;if(!G)return J;y&&(p=sr(p,Ei(y))),x?(L=ES,H=!1):p.length>=r&&(L=gd,H=!1,p=new Ku(p));e:for(;++I<G;){var le=c[I],de=y==null?le:y(le);if(le=x||le!==0?le:0,H&&de===de){for(var be=ue;be--;)if(p[be]===de)continue e;J.push(le)}else L(p,de,x)||J.push(le)}return J}var Ma=yF(Js),V2=yF(BS,!0);function uEe(c,p){var y=!0;return Ma(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],H=p(L);if(H!=null&&(G===e?H===H&&!Ci(H):y(H,G)))var G=H,J=L}return J}function cEe(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:cM(x);y<x;)c[y++]=p;return c}function G2(c,p){var y=[];return Ma(c,function(x,I,L){p(x,I,L)&&y.push(x)}),y}function pn(c,p,y,x,I){var L=-1,H=c.length;for(y||(y=ZEe),I||(I=[]);++L<H;){var G=c[L];p>0&&y(G)?p>1?pn(G,p-1,y,x,I):qa(I,G):x||(I[I.length]=G)}return I}var jS=_F(),K2=_F(!0);function Js(c,p){return c&&jS(c,p,rn)}function BS(c,p){return c&&K2(c,p,rn)}function Pv(c,p){return Pa(p,function(y){return $o(c[y])})}function Yu(c,p){p=Ba(p,c);for(var y=0,x=p.length;c!=null&&y<x;)c=c[eo(p[y++])];return y&&y==x?c:e}function X2(c,p,y){var x=p(c);return st(c)?x:qa(x,y(c))}function Un(c){return c==null?c===e?Al:Ge:Vu&&Vu in Yt(c)?zEe(c):iTe(c)}function US(c,p){return c>p}function lEe(c,p){return c!=null&&Ft.call(c,p)}function fEe(c,p){return c!=null&&p in Yt(c)}function pEe(c,p,y){return c>=In(p,y)&&c<Vr(p,y)}function $S(c,p,y){for(var x=y?ES:hv,I=c[0].length,L=c.length,H=L,G=ne(L),J=1/0,ue=[];H--;){var le=c[H];H&&p&&(le=sr(le,Ei(p))),J=In(le.length,J),G[H]=!y&&(p||I>=120&&le.length>=120)?new Ku(H&&le):e}le=c[0];var de=-1,be=G[0];e:for(;++de<I&&ue.length<J;){var qe=le[de],ze=p?p(qe):qe;if(qe=y||qe!==0?qe:0,!(be?gd(be,ze):x(ue,ze,y))){for(H=L;--H;){var lt=G[H];if(!(lt?gd(lt,ze):x(c[H],ze,y)))continue e}be&&be.push(ze),ue.push(qe)}}return ue}function dEe(c,p,y,x){return Js(c,function(I,L,H){p(x,y(I),L,H)}),x}function Ed(c,p,y){p=Ba(p,c),c=LF(c,p);var x=c==null?c:c[eo(Ji(p))];return x==null?e:Si(x,c,y)}function Y2(c){return wr(c)&&Un(c)==ot}function hEe(c){return wr(c)&&Un(c)==Zs}function mEe(c){return wr(c)&&Un(c)==Lt}function Td(c,p,y,x,I){return c===p?!0:c==null||p==null||!wr(c)&&!wr(p)?c!==c&&p!==p:gEe(c,p,y,x,Td,I)}function gEe(c,p,y,x,I,L){var H=st(c),G=st(p),J=H?Ye:Nn(c),ue=G?Ye:Nn(p);J=J==ot?Be:J,ue=ue==ot?Be:ue;var le=J==Be,de=ue==Be,be=J==ue;if(be&&$a(c)){if(!$a(p))return!1;H=!0,le=!1}if(be&&!le)return L||(L=new Cs),H||Ul(c)?NF(c,p,y,x,I,L):HEe(c,p,J,y,x,I,L);if(!(y&h)){var qe=le&&Ft.call(c,"__wrapped__"),ze=de&&Ft.call(p,"__wrapped__");if(qe||ze){var lt=qe?c.value():c,Ve=ze?p.value():p;return L||(L=new Cs),I(lt,Ve,y,x,L)}}return be?(L||(L=new Cs),WEe(c,p,y,x,I,L)):!1}function vEe(c){return wr(c)&&Nn(c)==te}function HS(c,p,y,x){var I=y.length,L=I,H=!x;if(c==null)return!L;for(c=Yt(c);I--;){var G=y[I];if(H&&G[2]?G[1]!==c[G[0]]:!(G[0]in c))return!1}for(;++I<L;){G=y[I];var J=G[0],ue=c[J],le=G[1];if(H&&G[2]){if(ue===e&&!(J in c))return!1}else{var de=new Cs;if(x)var be=x(ue,le,J,c,p,de);if(!(be===e?Td(le,ue,h|m,x,de):be))return!1}}return!0}function Z2(c){if(!vr(c)||QEe(c))return!1;var p=$o(c)?vSe:a0e;return p.test(Ju(c))}function yEe(c){return wr(c)&&Un(c)==jr}function _Ee(c){return wr(c)&&Nn(c)==Ne}function xEe(c){return wr(c)&&Yv(c.length)&&!!rr[Un(c)]}function J2(c){return typeof c=="function"?c:c==null?ii:typeof c=="object"?st(c)?tF(c[0],c[1]):eF(c):xM(c)}function WS(c){if(!Id(c))return SSe(c);var p=[];for(var y in Yt(c))Ft.call(c,y)&&y!="constructor"&&p.push(y);return p}function bEe(c){if(!vr(c))return nTe(c);var p=Id(c),y=[];for(var x in c)x=="constructor"&&(p||!Ft.call(c,x))||y.push(x);return y}function zS(c,p){return c<p}function Q2(c,p){var y=-1,x=ri(c)?ne(c.length):[];return Ma(c,function(I,L,H){x[++y]=p(I,L,H)}),x}function eF(c){var p=oE(c);return p.length==1&&p[0][2]?qF(p[0][0],p[0][1]):function(y){return y===c||HS(y,c,p)}}function tF(c,p){return uE(c)&&PF(p)?qF(eo(c),p):function(y){var x=yE(y,c);return x===e&&x===p?_E(y,c):Td(p,x,h|m)}}function qv(c,p,y,x,I){c!==p&&jS(p,function(L,H){if(I||(I=new Cs),vr(L))wEe(c,p,H,y,qv,x,I);else{var G=x?x(lE(c,H),L,H+"",c,p,I):e;G===e&&(G=L),FS(c,H,G)}},ni)}function wEe(c,p,y,x,I,L,H){var G=lE(c,y),J=lE(p,y),ue=H.get(J);if(ue){FS(c,y,ue);return}var le=L?L(G,J,y+"",c,p,H):e,de=le===e;if(de){var be=st(J),qe=!be&&$a(J),ze=!be&&!qe&&Ul(J);le=J,be||qe||ze?st(G)?le=G:Nr(G)?le=ti(G):qe?(de=!1,le=dF(J,!0)):ze?(de=!1,le=hF(J,!0)):le=[]:Od(J)||Qu(J)?(le=G,Qu(G)?le=lM(G):(!vr(G)||$o(G))&&(le=kF(J))):de=!1}de&&(H.set(J,le),I(le,J,x,L,H),H.delete(J)),FS(c,y,le)}function rF(c,p){var y=c.length;if(y)return p+=p<0?y:0,Uo(p,y)?c[p]:e}function nF(c,p,y){p.length?p=sr(p,function(L){return st(L)?function(H){return Yu(H,L.length===1?L[0]:L)}:L}):p=[ii];var x=-1;p=sr(p,Ei(Ue()));var I=Q2(c,function(L,H,G){var J=sr(p,function(ue){return ue(L)});return{criteria:J,index:++x,value:L}});return X0e(I,function(L,H){return DEe(L,H,y)})}function SEe(c,p){return iF(c,p,function(y,x){return _E(c,x)})}function iF(c,p,y){for(var x=-1,I=p.length,L={};++x<I;){var H=p[x],G=Yu(c,H);y(G,H)&&Cd(L,Ba(H,c),G)}return L}function EEe(c){return function(p){return Yu(p,c)}}function VS(c,p,y,x){var I=x?K0e:Rl,L=-1,H=p.length,G=c;for(c===p&&(p=ti(p)),y&&(G=sr(c,Ei(y)));++L<H;)for(var J=0,ue=p[L],le=y?y(ue):ue;(J=I(G,le,J,x))>-1;)G!==c&&Ev.call(G,J,1),Ev.call(c,J,1);return c}function sF(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;Uo(I)?Ev.call(c,I,1):YS(c,I)}}return c}function GS(c,p){return c+Av(j2()*(p-c+1))}function TEe(c,p,y,x){for(var I=-1,L=Vr(Cv((p-c)/(y||1)),0),H=ne(L);L--;)H[x?L:++I]=c,c+=y;return H}function KS(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 fE(DF(c,p,ii),c+"")}function CEe(c){return $2($l(c))}function AEe(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=Ba(p,c);for(var I=-1,L=p.length,H=L-1,G=c;G!=null&&++I<L;){var J=eo(p[I]),ue=y;if(J==="__proto__"||J==="constructor"||J==="prototype")return c;if(I!=H){var le=G[J];ue=x?x(le,J,G):e,ue===e&&(ue=vr(le)?le:Uo(p[I+1])?[]:{})}wd(G,J,ue),G=G[J]}return c}var oF=Iv?function(c,p){return Iv.set(c,p),c}:ii,IEe=Tv?function(c,p){return Tv(c,"toString",{configurable:!0,enumerable:!1,value:bE(p),writable:!0})}:ii;function NEe(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 OEe(c,p){var y;return Ma(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<=ye){for(;x<I;){var L=x+I>>>1,H=c[L];H!==null&&!Ci(H)&&(y?H<=p:H<p)?x=L+1:I=L}return I}return XS(c,p,ii,y)}function XS(c,p,y,x){var I=0,L=c==null?0:c.length;if(L===0)return 0;p=y(p);for(var H=p!==p,G=p===null,J=Ci(p),ue=p===e;I<L;){var le=Av((I+L)/2),de=y(c[le]),be=de!==e,qe=de===null,ze=de===de,lt=Ci(de);if(H)var Ve=x||ze;else ue?Ve=ze&&(x||be):G?Ve=ze&&be&&(x||!qe):J?Ve=ze&&be&&!qe&&(x||!lt):qe||lt?Ve=!1:Ve=x?de<=p:de<p;Ve?I=le+1:L=le}return In(L,pe)}function aF(c,p){for(var y=-1,x=c.length,I=0,L=[];++y<x;){var H=c[y],G=p?p(H):H;if(!y||!As(G,J)){var J=G;L[I++]=H===0?0:H}}return L}function uF(c){return typeof c=="number"?c:Ci(c)?V:+c}function Ti(c){if(typeof c=="string")return c;if(st(c))return sr(c,Ti)+"";if(Ci(c))return B2?B2.call(c):"";var p=c+"";return p=="0"&&1/c==-j?"-0":p}function ja(c,p,y){var x=-1,I=hv,L=c.length,H=!0,G=[],J=G;if(y)H=!1,I=ES;else if(L>=r){var ue=p?null:UEe(c);if(ue)return gv(ue);H=!1,I=gd,J=new Ku}else J=p?[]:G;e:for(;++x<L;){var le=c[x],de=p?p(le):le;if(le=y||le!==0?le:0,H&&de===de){for(var be=J.length;be--;)if(J[be]===de)continue e;p&&J.push(de),G.push(le)}else I(J,de,y)||(J!==G&&J.push(de),G.push(le))}return G}function YS(c,p){return p=Ba(p,c),c=LF(c,p),c==null||delete c[eo(Ji(p))]}function cF(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 lF(c,p){var y=c;return y instanceof yt&&(y=y.value()),TS(p,function(x,I){return I.func.apply(I.thisArg,qa([x],I.args))},y)}function ZS(c,p,y){var x=c.length;if(x<2)return x?ja(c[0]):[];for(var I=-1,L=ne(x);++I<x;)for(var H=c[I],G=-1;++G<x;)G!=I&&(L[I]=Sd(L[I]||H,c[G],p,y));return ja(pn(L,1),p,y)}function fF(c,p,y){for(var x=-1,I=c.length,L=p.length,H={};++x<I;){var G=x<L?p[x]:e;y(H,c[x],G)}return H}function JS(c){return Nr(c)?c:[]}function QS(c){return typeof c=="function"?c:ii}function Ba(c,p){return st(c)?c:uE(c,p)?[c]:BF(Pt(c))}var REe=ft;function Ua(c,p,y){var x=c.length;return y=y===e?x:y,!p&&y>=x?c:Zi(c,p,y)}var pF=ySe||function(c){return tn.clearTimeout(c)};function dF(c,p){if(p)return c.slice();var y=c.length,x=q2?q2(y):new c.constructor(y);return c.copy(x),x}function eE(c){var p=new c.constructor(c.byteLength);return new wv(p).set(new wv(c)),p}function kEe(c,p){var y=p?eE(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.byteLength)}function PEe(c){var p=new c.constructor(c.source,YL.exec(c));return p.lastIndex=c.lastIndex,p}function qEe(c){return bd?Yt(bd.call(c)):{}}function hF(c,p){var y=p?eE(c.buffer):c.buffer;return new c.constructor(y,c.byteOffset,c.length)}function mF(c,p){if(c!==p){var y=c!==e,x=c===null,I=c===c,L=Ci(c),H=p!==e,G=p===null,J=p===p,ue=Ci(p);if(!G&&!ue&&!L&&c>p||L&&H&&J&&!G&&!ue||x&&H&&J||!y&&J||!I)return 1;if(!x&&!L&&!ue&&c<p||ue&&y&&I&&!x&&!L||G&&y&&I||!H&&I||!J)return-1}return 0}function DEe(c,p,y){for(var x=-1,I=c.criteria,L=p.criteria,H=I.length,G=y.length;++x<H;){var J=mF(I[x],L[x]);if(J){if(x>=G)return J;var ue=y[x];return J*(ue=="desc"?-1:1)}}return c.index-p.index}function gF(c,p,y,x){for(var I=-1,L=c.length,H=y.length,G=-1,J=p.length,ue=Vr(L-H,0),le=ne(J+ue),de=!x;++G<J;)le[G]=p[G];for(;++I<H;)(de||I<L)&&(le[y[I]]=c[I]);for(;ue--;)le[G++]=c[I++];return le}function vF(c,p,y,x){for(var I=-1,L=c.length,H=-1,G=y.length,J=-1,ue=p.length,le=Vr(L-G,0),de=ne(le+ue),be=!x;++I<le;)de[I]=c[I];for(var qe=I;++J<ue;)de[qe+J]=p[J];for(;++H<G;)(be||I<L)&&(de[qe+y[H]]=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 Qs(c,p,y,x){var I=!y;y||(y={});for(var L=-1,H=p.length;++L<H;){var G=p[L],J=x?x(y[G],c[G],G,y,c):e;J===e&&(J=c[G]),I?Mo(y,G,J):wd(y,G,J)}return y}function LEe(c,p){return Qs(c,aE(c),p)}function FEe(c,p){return Qs(c,OF(c),p)}function Fv(c,p){return function(y,x){var I=st(y)?$0e:sEe,L=p?p():{};return I(y,c,Ue(x,2),L)}}function Ml(c){return ft(function(p,y){var x=-1,I=y.length,L=I>1?y[I-1]:e,H=I>2?y[2]:e;for(L=c.length>3&&typeof L=="function"?(I--,L):e,H&&$n(y[0],y[1],H)&&(L=I<3?e:L,I=1),p=Yt(p);++x<I;){var G=y[x];G&&c(p,G,x,L)}return p})}function yF(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,H=Yt(y);(p?L--:++L<I)&&x(H[L],L,H)!==!1;);return y}}function _F(c){return function(p,y,x){for(var I=-1,L=Yt(p),H=x(p),G=H.length;G--;){var J=H[c?G:++I];if(y(L[J],J,L)===!1)break}return p}}function MEe(c,p,y){var x=p&g,I=Ad(c);function L(){var H=this&&this!==tn&&this instanceof L?I:c;return H.apply(x?y:this,arguments)}return L}function xF(c){return function(p){p=Pt(p);var y=kl(p)?Ts(p):e,x=y?y[0]:p.charAt(0),I=y?Ua(y,1).join(""):p.slice(1);return x[c]()+I}}function jl(c){return function(p){return TS(yM(vM(p).replace(I0e,"")),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 jEe(c,p,y){var x=Ad(c);function I(){for(var L=arguments.length,H=ne(L),G=L,J=Bl(I);G--;)H[G]=arguments[G];var ue=L<3&&H[0]!==J&&H[L-1]!==J?[]:Da(H,J);if(L-=ue.length,L<y)return TF(c,p,Mv,I.placeholder,e,H,ue,e,e,y-L);var le=this&&this!==tn&&this instanceof I?x:c;return Si(le,this,H)}return I}function bF(c){return function(p,y,x){var I=Yt(p);if(!ri(p)){var L=Ue(y,3);p=rn(p),y=function(G){return L(I[G],G,I)}}var H=c(p,y,x);return H>-1?I[L?p[H]:H]:e}}function wF(c){return Bo(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&&!H&&$v(L)=="wrapper")var H=new Xi([],!0)}for(x=H?x:y;++x<y;){L=p[x];var G=$v(L),J=G=="wrapper"?sE(L):e;J&&cE(J[0])&&J[1]==(E|b|T|O)&&!J[4].length&&J[9]==1?H=H[$v(J[0])].apply(H,J[3]):H=L.length==1&&cE(L)?H[G]():H.thru(L)}return function(){var ue=arguments,le=ue[0];if(H&&ue.length==1&&st(le))return H.plant(le).value();for(var de=0,be=y?p[de].apply(this,ue):le;++de<y;)be=p[de].call(this,be);return be}})}function Mv(c,p,y,x,I,L,H,G,J,ue){var le=p&E,de=p&g,be=p&_,qe=p&(b|C),ze=p&U,lt=be?e:Ad(c);function Ve(){for(var ht=arguments.length,St=ne(ht),Ai=ht;Ai--;)St[Ai]=arguments[Ai];if(qe)var Hn=Bl(Ve),Ii=Z0e(St,Hn);if(x&&(St=gF(St,x,I,qe)),L&&(St=vF(St,L,H,qe)),ht-=Ii,qe&&ht<ue){var Or=Da(St,Hn);return TF(c,p,Mv,Ve.placeholder,y,St,Or,G,J,ue-ht)}var Is=de?y:this,Wo=be?Is[c]:c;return ht=St.length,G?St=sTe(St,G):ze&&ht>1&&St.reverse(),le&&J<ht&&(St.length=J),this&&this!==tn&&this instanceof Ve&&(Wo=lt||Ad(Wo)),Wo.apply(Is,St)}return Ve}function SF(c,p){return function(y,x){return dEe(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=uF(y),x=uF(x)),I=c(y,x)}return I}}function tE(c){return Bo(function(p){return p=sr(p,Ei(Ue())),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?KS(p,c):p;var x=KS(p,Cv(c/Pl(p)));return kl(p)?Ua(Ts(x),0,c).join(""):x.slice(0,c)}function BEe(c,p,y,x){var I=p&g,L=Ad(c);function H(){for(var G=-1,J=arguments.length,ue=-1,le=x.length,de=ne(le+J),be=this&&this!==tn&&this instanceof H?L:c;++ue<le;)de[ue]=x[ue];for(;J--;)de[ue++]=arguments[++G];return Si(be,I?y:this,de)}return H}function EF(c){return function(p,y,x){return x&&typeof x!="number"&&$n(p,y,x)&&(y=x=e),p=Ho(p),y===e?(y=p,p=0):y=Ho(y),x=x===e?p<y?1:-1:Ho(x),TEe(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 TF(c,p,y,x,I,L,H,G,J,ue){var le=p&b,de=le?H:e,be=le?e:H,qe=le?L:e,ze=le?e:L;p|=le?T:w,p&=~(le?w:T),p&S||(p&=~(g|_));var lt=[c,p,I,qe,de,ze,be,G,J,ue],Ve=y.apply(e,lt);return cE(c)&&FF(Ve,lt),Ve.placeholder=x,MF(Ve,c,p)}function rE(c){var p=zr[c];return function(y,x){if(y=Qi(y),x=x==null?0:In(ct(x),292),x&&M2(y)){var I=(Pt(y)+"e").split("e"),L=p(I[0]+"e"+(+I[1]+x));return I=(Pt(L)+"e").split("e"),+(I[0]+"e"+(+I[1]-x))}return p(y)}}var UEe=Dl&&1/gv(new Dl([,-0]))[1]==j?function(c){return new Dl(c)}:EE;function CF(c){return function(p){var y=Nn(p);return y==te?kS(p):y==Ne?iSe(p):Y0e(p,c(p))}}function jo(c,p,y,x,I,L,H,G){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),H=H===e?H:Vr(ct(H),0),G=G===e?G:ct(G),ue-=I?I.length:0,p&w){var le=x,de=I;x=I=e}var be=J?e:sE(c),qe=[c,p,y,x,I,le,de,L,H,G];if(be&&rTe(qe,be),c=qe[0],p=qe[1],y=qe[2],x=qe[3],I=qe[4],G=qe[9]=qe[9]===e?J?0:c.length:Vr(qe[9]-ue,0),!G&&p&(b|C)&&(p&=~(b|C)),!p||p==g)var ze=MEe(c,p,y);else p==b||p==C?ze=jEe(c,p,G):(p==T||p==(g|T))&&!I.length?ze=BEe(c,p,y,x):ze=Mv.apply(e,qe);var lt=be?oF:FF;return MF(lt(ze,qe),c,p)}function AF(c,p,y,x){return c===e||As(c,ql[y])&&!Ft.call(x,y)?p:c}function IF(c,p,y,x,I,L){return vr(c)&&vr(p)&&(L.set(p,c),qv(c,p,e,IF,L),L.delete(p)),c}function $Ee(c){return Od(c)?e:c}function NF(c,p,y,x,I,L){var H=y&h,G=c.length,J=p.length;if(G!=J&&!(H&&J>G))return!1;var ue=L.get(c),le=L.get(p);if(ue&&le)return ue==p&&le==c;var de=-1,be=!0,qe=y&m?new Ku:e;for(L.set(c,p),L.set(p,c);++de<G;){var ze=c[de],lt=p[de];if(x)var Ve=H?x(lt,ze,de,p,c,L):x(ze,lt,de,c,p,L);if(Ve!==e){if(Ve)continue;be=!1;break}if(qe){if(!CS(p,function(ht,St){if(!gd(qe,St)&&(ze===ht||I(ze,ht,y,x,L)))return qe.push(St)})){be=!1;break}}else if(!(ze===lt||I(ze,lt,y,x,L))){be=!1;break}}return L.delete(c),L.delete(p),be}function HEe(c,p,y,x,I,L,H){switch(y){case q:if(c.byteLength!=p.byteLength||c.byteOffset!=p.byteOffset)return!1;c=c.buffer,p=p.buffer;case Zs:return!(c.byteLength!=p.byteLength||!L(new wv(c),new wv(p)));case Re:case Lt:case X:return As(+c,+p);case ge:return c.name==p.name&&c.message==p.message;case jr:case Xt:return c==p+"";case te:var G=kS;case Ne:var J=x&h;if(G||(G=gv),c.size!=p.size&&!J)return!1;var ue=H.get(c);if(ue)return ue==p;x|=m,H.set(c,p);var le=NF(G(c),G(p),x,I,L,H);return H.delete(c),le;case fn:if(bd)return bd.call(c)==bd.call(p)}return!1}function WEe(c,p,y,x,I,L){var H=y&h,G=nE(c),J=G.length,ue=nE(p),le=ue.length;if(J!=le&&!H)return!1;for(var de=J;de--;){var be=G[de];if(!(H?be in p:Ft.call(p,be)))return!1}var qe=L.get(c),ze=L.get(p);if(qe&&ze)return qe==p&&ze==c;var lt=!0;L.set(c,p),L.set(p,c);for(var Ve=H;++de<J;){be=G[de];var ht=c[be],St=p[be];if(x)var Ai=H?x(St,ht,be,p,c,L):x(ht,St,be,c,p,L);if(!(Ai===e?ht===St||I(ht,St,y,x,L):Ai)){lt=!1;break}Ve||(Ve=be=="constructor")}if(lt&&!Ve){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 Bo(c){return fE(DF(c,e,WF),c+"")}function nE(c){return X2(c,rn,aE)}function iE(c){return X2(c,ni,OF)}var sE=Iv?function(c){return Iv.get(c)}:EE;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(k,"placeholder")?k:c;return p.placeholder}function Ue(){var c=k.iteratee||wE;return c=c===wE?J2:c,arguments.length?c(arguments[0],arguments[1]):c}function Hv(c,p){var y=c.__data__;return JEe(p)?y[typeof p=="string"?"string":"hash"]:y.map}function oE(c){for(var p=rn(c),y=p.length;y--;){var x=p[y],I=c[x];p[y]=[x,I,PF(I)]}return p}function Zu(c,p){var y=tSe(c,p);return Z2(y)?y:e}function zEe(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 aE=qS?function(c){return c==null?[]:(c=Yt(c),Pa(qS(c),function(p){return L2.call(c,p)}))}:TE,OF=qS?function(c){for(var p=[];c;)qa(p,aE(c)),c=Sv(c);return p}:TE,Nn=Un;(DS&&Nn(new DS(new ArrayBuffer(1)))!=q||yd&&Nn(new yd)!=te||LS&&Nn(LS.resolve())!=zt||Dl&&Nn(new Dl)!=Ne||_d&&Nn(new _d)!=Ys)&&(Nn=function(c){var p=Un(c),y=p==Be?c.constructor:e,x=y?Ju(y):"";if(x)switch(x){case ASe:return q;case ISe:return te;case NSe:return zt;case OSe:return Ne;case RSe:return Ys}return p});function VEe(c,p,y){for(var x=-1,I=y.length;++x<I;){var L=y[x],H=L.size;switch(L.type){case"drop":c+=H;break;case"dropRight":p-=H;break;case"take":p=In(p,c+H);break;case"takeRight":c=Vr(c,p-H);break}}return{start:c,end:p}}function GEe(c){var p=c.match(Qwe);return p?p[1].split(e0e):[]}function RF(c,p,y){p=Ba(p,c);for(var x=-1,I=p.length,L=!1;++x<I;){var H=eo(p[x]);if(!(L=c!=null&&y(c,H)))break;c=c[H]}return L||++x!=I?L:(I=c==null?0:c.length,!!I&&Yv(I)&&Uo(H,I)&&(st(c)||Qu(c)))}function KEe(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 kF(c){return typeof c.constructor=="function"&&!Id(c)?Fl(Sv(c)):{}}function XEe(c,p,y){var x=c.constructor;switch(p){case Zs:return eE(c);case Re:case Lt:return new x(+c);case q:return kEe(c,y);case W:case K:case se:case ce:case Se:case Ze:case dt:case Wr:case bi:return hF(c,y);case te:return new x;case X:case Xt:return new x(c);case jr:return PEe(c);case Ne:return new x;case fn:return qEe(c)}}function YEe(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 ZEe(c){return st(c)||Qu(c)||!!(F2&&c&&c[F2])}function Uo(c,p){var y=typeof c;return p=p??B,!!p&&(y=="number"||y!="symbol"&&c0e.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)&&Uo(p,y.length):x=="string"&&p in y)?As(y[p],c):!1}function uE(c,p){if(st(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 JEe(c){var p=typeof c;return p=="string"||p=="number"||p=="symbol"||p=="boolean"?c!=="__proto__":c===null}function cE(c){var p=$v(c),y=k[p];if(typeof y!="function"||!(p in yt.prototype))return!1;if(c===y)return!0;var x=sE(y);return!!x&&c===x[0]}function QEe(c){return!!P2&&P2 in c}var eTe=yv?$o:CE;function Id(c){var p=c&&c.constructor,y=typeof p=="function"&&p.prototype||ql;return c===y}function PF(c){return c===c&&!vr(c)}function qF(c,p){return function(y){return y==null?!1:y[c]===p&&(p!==e||c in Yt(y))}}function tTe(c){var p=Kv(c,function(x){return y.size===a&&y.clear(),x}),y=p.cache;return p}function rTe(c,p){var y=c[1],x=p[1],I=y|x,L=I<(g|_|E),H=x==E&&y==b||x==E&&y==O&&c[7].length<=p[8]||x==(E|O)&&p[7].length<=p[8]&&y==b;if(!(L||H))return c;x&g&&(c[2]=p[2],I|=y&g?0:S);var G=p[3];if(G){var J=c[3];c[3]=J?gF(J,G,p[4]):G,c[4]=J?Da(c[3],u):p[4]}return G=p[5],G&&(J=c[5],c[5]=J?vF(J,G,p[6]):G,c[6]=J?Da(c[5],u):p[6]),G=p[7],G&&(c[7]=G),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 nTe(c){var p=[];if(c!=null)for(var y in Yt(c))p.push(y);return p}function iTe(c){return xv.call(c)}function DF(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),H=ne(L);++I<L;)H[I]=x[p+I];I=-1;for(var G=ne(p+1);++I<p;)G[I]=x[I];return G[p]=y(H),Si(c,this,G)}}function LF(c,p){return p.length<2?c:Yu(c,Zi(p,0,-1))}function sTe(c,p){for(var y=c.length,x=In(p.length,y),I=ti(c);x--;){var L=p[x];c[x]=Uo(L,y)?I[L]:e}return c}function lE(c,p){if(!(p==="constructor"&&typeof c[p]=="function")&&p!="__proto__")return c[p]}var FF=jF(oF),Nd=xSe||function(c,p){return tn.setTimeout(c,p)},fE=jF(IEe);function MF(c,p,y){var x=p+"";return fE(c,YEe(x,oTe(GEe(x),y)))}function jF(c){var p=0,y=0;return function(){var x=ESe(),I=P-(x-y);if(y=x,I>0){if(++p>=R)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=GS(y,I),H=c[L];c[L]=c[y],c[y]=H}return c.length=p,c}var BF=tTe(function(c){var p=[];return c.charCodeAt(0)===46&&p.push(""),c.replace(md,function(y,x,I,L){p.push(I?L.replace(n0e,"$1"):x||y)}),p});function eo(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 oTe(c,p){return Gi(He,function(y){var x="_."+y[0];p&y[1]&&!hv(c,x)&&c.push(x)}),c.sort()}function UF(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 aTe(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,H=ne(Cv(x/p));I<x;)H[L++]=Zi(c,I,I+=p);return H}function uTe(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 cTe(){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 qa(st(y)?ti(y):[y],pn(p,1))}var lTe=ft(function(c,p){return Nr(c)?Sd(c,pn(p,1,Nr,!0)):[]}),fTe=ft(function(c,p){var y=Ji(p);return Nr(y)&&(y=e),Nr(c)?Sd(c,pn(p,1,Nr,!0),Ue(y,2)):[]}),pTe=ft(function(c,p){var y=Ji(p);return Nr(y)&&(y=e),Nr(c)?Sd(c,pn(p,1,Nr,!0),e,y):[]});function dTe(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 hTe(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 mTe(c,p){return c&&c.length?Lv(c,Ue(p,3),!0,!0):[]}function gTe(c,p){return c&&c.length?Lv(c,Ue(p,3),!0):[]}function vTe(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),cEe(c,p,y,x)):[]}function $F(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,Ue(p,3),I)}function HF(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,Ue(p,3),I,!0)}function WF(c){var p=c==null?0:c.length;return p?pn(c,1):[]}function yTe(c){var p=c==null?0:c.length;return p?pn(c,j):[]}function _Te(c,p){var y=c==null?0:c.length;return y?(p=p===e?1:ct(p),pn(c,p)):[]}function xTe(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 zF(c){return c&&c.length?c[0]:e}function bTe(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 wTe(c){var p=c==null?0:c.length;return p?Zi(c,0,-1):[]}var STe=ft(function(c){var p=sr(c,JS);return p.length&&p[0]===c[0]?$S(p):[]}),ETe=ft(function(c){var p=Ji(c),y=sr(c,JS);return p===Ji(y)?p=e:y.pop(),y.length&&y[0]===c[0]?$S(y,Ue(p,2)):[]}),TTe=ft(function(c){var p=Ji(c),y=sr(c,JS);return p=typeof p=="function"?p:e,p&&y.pop(),y.length&&y[0]===c[0]?$S(y,e,p):[]});function CTe(c,p){return c==null?"":wSe.call(c,p)}function Ji(c){var p=c==null?0:c.length;return p?c[p-1]:e}function ATe(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?oSe(c,p,I):mv(c,T2,I,!0)}function ITe(c,p){return c&&c.length?rF(c,ct(p)):e}var NTe=ft(VF);function VF(c,p){return c&&c.length&&p&&p.length?VS(c,p):c}function OTe(c,p,y){return c&&c.length&&p&&p.length?VS(c,p,Ue(y,2)):c}function RTe(c,p,y){return c&&c.length&&p&&p.length?VS(c,p,e,y):c}var kTe=Bo(function(c,p){var y=c==null?0:c.length,x=MS(c,p);return sF(c,sr(p,function(I){return Uo(I,y)?+I:I}).sort(mF)),x});function PTe(c,p){var y=[];if(!(c&&c.length))return y;var x=-1,I=[],L=c.length;for(p=Ue(p,3);++x<L;){var H=c[x];p(H,x,c)&&(y.push(H),I.push(x))}return sF(c,I),y}function pE(c){return c==null?c:CSe.call(c)}function qTe(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 DTe(c,p){return Dv(c,p)}function LTe(c,p,y){return XS(c,p,Ue(y,2))}function FTe(c,p){var y=c==null?0:c.length;if(y){var x=Dv(c,p);if(x<y&&As(c[x],p))return x}return-1}function MTe(c,p){return Dv(c,p,!0)}function jTe(c,p,y){return XS(c,p,Ue(y,2),!0)}function BTe(c,p){var y=c==null?0:c.length;if(y){var x=Dv(c,p,!0)-1;if(As(c[x],p))return x}return-1}function UTe(c){return c&&c.length?aF(c):[]}function $Te(c,p){return c&&c.length?aF(c,Ue(p,2)):[]}function HTe(c){var p=c==null?0:c.length;return p?Zi(c,1,p):[]}function WTe(c,p,y){return c&&c.length?(p=y||p===e?1:ct(p),Zi(c,0,p<0?0:p)):[]}function zTe(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 VTe(c,p){return c&&c.length?Lv(c,Ue(p,3),!1,!0):[]}function GTe(c,p){return c&&c.length?Lv(c,Ue(p,3)):[]}var KTe=ft(function(c){return ja(pn(c,1,Nr,!0))}),XTe=ft(function(c){var p=Ji(c);return Nr(p)&&(p=e),ja(pn(c,1,Nr,!0),Ue(p,2))}),YTe=ft(function(c){var p=Ji(c);return p=typeof p=="function"?p:e,ja(pn(c,1,Nr,!0),e,p)});function ZTe(c){return c&&c.length?ja(c):[]}function JTe(c,p){return c&&c.length?ja(c,Ue(p,2)):[]}function QTe(c,p){return p=typeof p=="function"?p:e,c&&c.length?ja(c,e,p):[]}function dE(c){if(!(c&&c.length))return[];var p=0;return c=Pa(c,function(y){if(Nr(y))return p=Vr(y.length,p),!0}),OS(p,function(y){return sr(c,AS(y))})}function GF(c,p){if(!(c&&c.length))return[];var y=dE(c);return p==null?y:sr(y,function(x){return Si(p,e,x)})}var eCe=ft(function(c,p){return Nr(c)?Sd(c,p):[]}),tCe=ft(function(c){return ZS(Pa(c,Nr))}),rCe=ft(function(c){var p=Ji(c);return Nr(p)&&(p=e),ZS(Pa(c,Nr),Ue(p,2))}),nCe=ft(function(c){var p=Ji(c);return p=typeof p=="function"?p:e,ZS(Pa(c,Nr),e,p)}),iCe=ft(dE);function sCe(c,p){return fF(c||[],p||[],wd)}function oCe(c,p){return fF(c||[],p||[],Cd)}var aCe=ft(function(c){var p=c.length,y=p>1?c[p-1]:e;return y=typeof y=="function"?(c.pop(),y):e,GF(c,y)});function KF(c){var p=k(c);return p.__chain__=!0,p}function uCe(c,p){return p(c),c}function zv(c,p){return p(c)}var cCe=Bo(function(c){var p=c.length,y=p?c[0]:0,x=this.__wrapped__,I=function(L){return MS(L,c)};return p>1||this.__actions__.length||!(x instanceof yt)||!Uo(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 lCe(){return KF(this)}function fCe(){return new Xi(this.value(),this.__chain__)}function pCe(){this.__values__===e&&(this.__values__=uM(this.value()));var c=this.__index__>=this.__values__.length,p=c?e:this.__values__[this.__index__++];return{done:c,value:p}}function dCe(){return this}function hCe(c){for(var p,y=this;y instanceof Ov;){var x=UF(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 mCe(){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:[pE],thisArg:e}),new Xi(p,this.__chain__)}return this.thru(pE)}function gCe(){return lF(this.__wrapped__,this.__actions__)}var vCe=Fv(function(c,p,y){Ft.call(c,y)?++c[y]:Mo(c,y,1)});function yCe(c,p,y){var x=st(c)?S2:uEe;return y&&$n(c,p,y)&&(p=e),x(c,Ue(p,3))}function _Ce(c,p){var y=st(c)?Pa:G2;return y(c,Ue(p,3))}var xCe=bF($F),bCe=bF(HF);function wCe(c,p){return pn(Vv(c,p),1)}function SCe(c,p){return pn(Vv(c,p),j)}function ECe(c,p,y){return y=y===e?1:ct(y),pn(Vv(c,p),y)}function XF(c,p){var y=st(c)?Gi:Ma;return y(c,Ue(p,3))}function YF(c,p){var y=st(c)?H0e:V2;return y(c,Ue(p,3))}var TCe=Fv(function(c,p,y){Ft.call(c,y)?c[y].push(p):Mo(c,y,[p])});function CCe(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 ACe=ft(function(c,p,y){var x=-1,I=typeof p=="function",L=ri(c)?ne(c.length):[];return Ma(c,function(H){L[++x]=I?Si(p,H,y):Ed(H,p,y)}),L}),ICe=Fv(function(c,p,y){Mo(c,y,p)});function Vv(c,p){var y=st(c)?sr:Q2;return y(c,Ue(p,3))}function NCe(c,p,y,x){return c==null?[]:(st(p)||(p=p==null?[]:[p]),y=x?e:y,st(y)||(y=y==null?[]:[y]),nF(c,p,y))}var OCe=Fv(function(c,p,y){c[y?0:1].push(p)},function(){return[[],[]]});function RCe(c,p,y){var x=st(c)?TS:A2,I=arguments.length<3;return x(c,Ue(p,4),y,I,Ma)}function kCe(c,p,y){var x=st(c)?W0e:A2,I=arguments.length<3;return x(c,Ue(p,4),y,I,V2)}function PCe(c,p){var y=st(c)?Pa:G2;return y(c,Xv(Ue(p,3)))}function qCe(c){var p=st(c)?$2:CEe;return p(c)}function DCe(c,p,y){(y?$n(c,p,y):p===e)?p=1:p=ct(p);var x=st(c)?nEe:AEe;return x(c,p)}function LCe(c){var p=st(c)?iEe:NEe;return p(c)}function FCe(c){if(c==null)return 0;if(ri(c))return Zv(c)?Pl(c):c.length;var p=Nn(c);return p==te||p==Ne?c.size:WS(c).length}function MCe(c,p,y){var x=st(c)?CS:OEe;return y&&$n(c,p,y)&&(p=e),x(c,Ue(p,3))}var jCe=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]]),nF(c,pn(p,1),[])}),Gv=_Se||function(){return tn.Date.now()};function BCe(c,p){if(typeof p!="function")throw new Ki(i);return c=ct(c),function(){if(--c<1)return p.apply(this,arguments)}}function ZF(c,p,y){return p=y?e:p,p=c&&p==null?c.length:p,jo(c,E,e,e,e,e,p)}function JF(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 hE=ft(function(c,p,y){var x=g;if(y.length){var I=Da(y,Bl(hE));x|=T}return jo(c,x,p,y,I)}),QF=ft(function(c,p,y){var x=g|_;if(y.length){var I=Da(y,Bl(QF));x|=T}return jo(p,x,c,y,I)});function eM(c,p,y){p=y?e:p;var x=jo(c,b,e,e,e,e,e,p);return x.placeholder=eM.placeholder,x}function tM(c,p,y){p=y?e:p;var x=jo(c,C,e,e,e,e,e,p);return x.placeholder=tM.placeholder,x}function rM(c,p,y){var x,I,L,H,G,J,ue=0,le=!1,de=!1,be=!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,be="trailing"in y?!!y.trailing:be);function qe(Or){var Is=x,Wo=I;return x=I=e,ue=Or,H=c.apply(Wo,Is),H}function ze(Or){return ue=Or,G=Nd(ht,p),le?qe(Or):H}function lt(Or){var Is=Or-J,Wo=Or-ue,bM=p-Is;return de?In(bM,L-Wo):bM}function Ve(Or){var Is=Or-J,Wo=Or-ue;return J===e||Is>=p||Is<0||de&&Wo>=L}function ht(){var Or=Gv();if(Ve(Or))return St(Or);G=Nd(ht,lt(Or))}function St(Or){return G=e,be&&x?qe(Or):(x=I=e,H)}function Ai(){G!==e&&pF(G),ue=0,x=J=I=G=e}function Hn(){return G===e?H:St(Gv())}function Ii(){var Or=Gv(),Is=Ve(Or);if(x=arguments,I=this,J=Or,Is){if(G===e)return ze(J);if(de)return pF(G),G=Nd(ht,p),qe(J)}return G===e&&(G=Nd(ht,p)),H}return Ii.cancel=Ai,Ii.flush=Hn,Ii}var UCe=ft(function(c,p){return z2(c,1,p)}),$Ce=ft(function(c,p,y){return z2(c,Qi(p)||0,y)});function HCe(c){return jo(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 H=c.apply(this,x);return y.cache=L.set(I,H)||L,H};return y.cache=new(Kv.Cache||Fo),y}Kv.Cache=Fo;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 WCe(c){return JF(2,c)}var zCe=REe(function(c,p){p=p.length==1&&st(p[0])?sr(p[0],Ei(Ue())):sr(pn(p,1),Ei(Ue()));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)})}),mE=ft(function(c,p){var y=Da(p,Bl(mE));return jo(c,T,e,p,y)}),nM=ft(function(c,p){var y=Da(p,Bl(nM));return jo(c,w,e,p,y)}),VCe=Bo(function(c,p){return jo(c,O,e,e,e,p)});function GCe(c,p){if(typeof c!="function")throw new Ki(i);return p=p===e?p:ct(p),ft(c,p)}function KCe(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=Ua(y,0,p);return x&&qa(I,x),Si(c,this,I)})}function XCe(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),rM(c,p,{leading:x,maxWait:p,trailing:I})}function YCe(c){return ZF(c,1)}function ZCe(c,p){return mE(QS(p),c)}function JCe(){if(!arguments.length)return[];var c=arguments[0];return st(c)?c:[c]}function QCe(c){return Yi(c,d)}function e1e(c,p){return p=typeof p=="function"?p:e,Yi(c,d,p)}function t1e(c){return Yi(c,l|d)}function r1e(c,p){return p=typeof p=="function"?p:e,Yi(c,l|d,p)}function n1e(c,p){return p==null||W2(c,p,rn(p))}function As(c,p){return c===p||c!==c&&p!==p}var i1e=Uv(US),s1e=Uv(function(c,p){return c>=p}),Qu=Y2(function(){return arguments}())?Y2:function(c){return wr(c)&&Ft.call(c,"callee")&&!L2.call(c,"callee")},st=ne.isArray,o1e=v2?Ei(v2):hEe;function ri(c){return c!=null&&Yv(c.length)&&!$o(c)}function Nr(c){return wr(c)&&ri(c)}function a1e(c){return c===!0||c===!1||wr(c)&&Un(c)==Re}var $a=bSe||CE,u1e=y2?Ei(y2):mEe;function c1e(c){return wr(c)&&c.nodeType===1&&!Od(c)}function l1e(c){if(c==null)return!0;if(ri(c)&&(st(c)||typeof c=="string"||typeof c.splice=="function"||$a(c)||Ul(c)||Qu(c)))return!c.length;var p=Nn(c);if(p==te||p==Ne)return!c.size;if(Id(c))return!WS(c).length;for(var y in c)if(Ft.call(c,y))return!1;return!0}function f1e(c,p){return Td(c,p)}function p1e(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 gE(c){if(!wr(c))return!1;var p=Un(c);return p==ge||p==it||typeof c.message=="string"&&typeof c.name=="string"&&!Od(c)}function d1e(c){return typeof c=="number"&&M2(c)}function $o(c){if(!vr(c))return!1;var p=Un(c);return p==D||p==A||p==nt||p==gr}function iM(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 wr(c){return c!=null&&typeof c=="object"}var sM=_2?Ei(_2):vEe;function h1e(c,p){return c===p||HS(c,p,oE(p))}function m1e(c,p,y){return y=typeof y=="function"?y:e,HS(c,p,oE(p),y)}function g1e(c){return oM(c)&&c!=+c}function v1e(c){if(eTe(c))throw new Je(n);return Z2(c)}function y1e(c){return c===null}function _1e(c){return c==null}function oM(c){return typeof c=="number"||wr(c)&&Un(c)==X}function Od(c){if(!wr(c)||Un(c)!=Be)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)==mSe}var vE=x2?Ei(x2):yEe;function x1e(c){return iM(c)&&c>=-B&&c<=B}var aM=b2?Ei(b2):_Ee;function Zv(c){return typeof c=="string"||!st(c)&&wr(c)&&Un(c)==Xt}function Ci(c){return typeof c=="symbol"||wr(c)&&Un(c)==fn}var Ul=w2?Ei(w2):xEe;function b1e(c){return c===e}function w1e(c){return wr(c)&&Nn(c)==Ys}function S1e(c){return wr(c)&&Un(c)==$u}var E1e=Uv(zS),T1e=Uv(function(c,p){return c<=p});function uM(c){if(!c)return[];if(ri(c))return Zv(c)?Ts(c):ti(c);if(vd&&c[vd])return nSe(c[vd]());var p=Nn(c),y=p==te?kS:p==Ne?gv:$l;return y(c)}function Ho(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=Ho(c),y=p%1;return p===p?y?p-y:p:0}function cM(c){return c?Xu(ct(c),0,ie):0}function Qi(c){if(typeof c=="number")return c;if(Ci(c))return V;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=I2(c);var y=o0e.test(c);return y||u0e.test(c)?B0e(c.slice(2),y?2:8):s0e.test(c)?V:+c}function lM(c){return Qs(c,ni(c))}function C1e(c){return c?Xu(ct(c),-B,B):c===0?c:0}function Pt(c){return c==null?"":Ti(c)}var A1e=Ml(function(c,p){if(Id(p)||ri(p)){Qs(p,rn(p),c);return}for(var y in p)Ft.call(p,y)&&wd(c,y,p[y])}),fM=Ml(function(c,p){Qs(p,ni(p),c)}),Jv=Ml(function(c,p,y,x){Qs(p,ni(p),c,x)}),I1e=Ml(function(c,p,y,x){Qs(p,rn(p),c,x)}),N1e=Bo(MS);function O1e(c,p){var y=Fl(c);return p==null?y:H2(y,p)}var R1e=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],H=ni(L),G=-1,J=H.length;++G<J;){var ue=H[G],le=c[ue];(le===e||As(le,ql[ue])&&!Ft.call(c,ue))&&(c[ue]=L[ue])}return c}),k1e=ft(function(c){return c.push(e,IF),Si(pM,e,c)});function P1e(c,p){return E2(c,Ue(p,3),Js)}function q1e(c,p){return E2(c,Ue(p,3),BS)}function D1e(c,p){return c==null?c:jS(c,Ue(p,3),ni)}function L1e(c,p){return c==null?c:K2(c,Ue(p,3),ni)}function F1e(c,p){return c&&Js(c,Ue(p,3))}function M1e(c,p){return c&&BS(c,Ue(p,3))}function j1e(c){return c==null?[]:Pv(c,rn(c))}function B1e(c){return c==null?[]:Pv(c,ni(c))}function yE(c,p,y){var x=c==null?e:Yu(c,p);return x===e?y:x}function U1e(c,p){return c!=null&&RF(c,p,lEe)}function _E(c,p){return c!=null&&RF(c,p,fEe)}var $1e=SF(function(c,p,y){p!=null&&typeof p.toString!="function"&&(p=xv.call(p)),c[p]=y},bE(ii)),H1e=SF(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]},Ue),W1e=ft(Ed);function rn(c){return ri(c)?U2(c):WS(c)}function ni(c){return ri(c)?U2(c,!0):bEe(c)}function z1e(c,p){var y={};return p=Ue(p,3),Js(c,function(x,I,L){Mo(y,p(x,I,L),x)}),y}function V1e(c,p){var y={};return p=Ue(p,3),Js(c,function(x,I,L){Mo(y,I,p(x,I,L))}),y}var G1e=Ml(function(c,p,y){qv(c,p,y)}),pM=Ml(function(c,p,y,x){qv(c,p,y,x)}),K1e=Bo(function(c,p){var y={};if(c==null)return y;var x=!1;p=sr(p,function(L){return L=Ba(L,c),x||(x=L.length>1),L}),Qs(c,iE(c),y),x&&(y=Yi(y,l|f|d,$Ee));for(var I=p.length;I--;)YS(y,p[I]);return y});function X1e(c,p){return dM(c,Xv(Ue(p)))}var Y1e=Bo(function(c,p){return c==null?{}:SEe(c,p)});function dM(c,p){if(c==null)return{};var y=sr(iE(c),function(x){return[x]});return p=Ue(p),iF(c,y,function(x,I){return p(x,I[0])})}function Z1e(c,p,y){p=Ba(p,c);var x=-1,I=p.length;for(I||(I=1,c=e);++x<I;){var L=c==null?e:c[eo(p[x])];L===e&&(x=I,L=y),c=$o(L)?L.call(c):L}return c}function J1e(c,p,y){return c==null?c:Cd(c,p,y)}function Q1e(c,p,y,x){return x=typeof x=="function"?x:e,c==null?c:Cd(c,p,y,x)}var hM=CF(rn),mM=CF(ni);function eAe(c,p,y){var x=st(c),I=x||$a(c)||Ul(c);if(p=Ue(p,4),y==null){var L=c&&c.constructor;I?y=x?new L:[]:vr(c)?y=$o(L)?Fl(Sv(c)):{}:y={}}return(I?Gi:Js)(c,function(H,G,J){return p(y,H,G,J)}),y}function tAe(c,p){return c==null?!0:YS(c,p)}function rAe(c,p,y){return c==null?c:cF(c,p,QS(y))}function nAe(c,p,y,x){return x=typeof x=="function"?x:e,c==null?c:cF(c,p,QS(y),x)}function $l(c){return c==null?[]:RS(c,rn(c))}function iAe(c){return c==null?[]:RS(c,ni(c))}function sAe(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 oAe(c,p,y){return p=Ho(p),y===e?(y=p,p=0):y=Ho(y),c=Qi(c),pEe(c,p,y)}function aAe(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=Ho(c),p===e?(p=c,c=0):p=Ho(p)),c>p){var x=c;c=p,p=x}if(y||c%1||p%1){var I=j2();return In(c+I*(p-c+j0e("1e-"+((I+"").length-1))),p)}return GS(c,p)}var uAe=jl(function(c,p,y){return p=p.toLowerCase(),c+(y?gM(p):p)});function gM(c){return xE(Pt(c).toLowerCase())}function vM(c){return c=Pt(c),c&&c.replace(l0e,J0e).replace(N0e,"")}function cAe(c,p,y){c=Pt(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 lAe(c){return c=Pt(c),c&&av.test(c)?c.replace(Il,Q0e):c}function fAe(c){return c=Pt(c),c&&Nl.test(c)?c.replace(Hu,"\\$&"):c}var pAe=jl(function(c,p,y){return c+(y?"-":"")+p.toLowerCase()}),dAe=jl(function(c,p,y){return c+(y?" ":"")+p.toLowerCase()}),hAe=xF("toLowerCase");function mAe(c,p,y){c=Pt(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 gAe(c,p,y){c=Pt(c),p=ct(p);var x=p?Pl(c):0;return p&&x<p?c+Bv(p-x,y):c}function vAe(c,p,y){c=Pt(c),p=ct(p);var x=p?Pl(c):0;return p&&x<p?Bv(p-x,y)+c:c}function yAe(c,p,y){return y||p==null?p=0:p&&(p=+p),TSe(Pt(c).replace(Wu,""),p||0)}function _Ae(c,p,y){return(y?$n(c,p,y):p===e)?p=1:p=ct(p),KS(Pt(c),p)}function xAe(){var c=arguments,p=Pt(c[0]);return c.length<3?p:p.replace(c[1],c[2])}var bAe=jl(function(c,p,y){return c+(y?"_":"")+p.toLowerCase()});function wAe(c,p,y){return y&&typeof y!="number"&&$n(c,p,y)&&(p=y=e),y=y===e?ie:y>>>0,y?(c=Pt(c),c&&(typeof p=="string"||p!=null&&!vE(p))&&(p=Ti(p),!p&&kl(c))?Ua(Ts(c),0,y):c.split(p,y)):[]}var SAe=jl(function(c,p,y){return c+(y?" ":"")+xE(p)});function EAe(c,p,y){return c=Pt(c),y=y==null?0:Xu(ct(y),0,c.length),p=Ti(p),c.slice(y,y+p.length)==p}function TAe(c,p,y){var x=k.templateSettings;y&&$n(c,p,y)&&(p=e),c=Pt(c),p=Jv({},p,x,AF);var I=Jv({},p.imports,x.imports,AF),L=rn(I),H=RS(I,L),G,J,ue=0,le=p.interpolate||fv,de="__p += '",be=PS((p.escape||fv).source+"|"+le.source+"|"+(le===dd?i0e:fv).source+"|"+(p.evaluate||fv).source+"|$","g"),qe="//# sourceURL="+(Ft.call(p,"sourceURL")?(p.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++q0e+"]")+`
|
|
145
145
|
`;c.replace(be,function(Ve,ht,St,Ai,Hn,Ii){return St||(St=Ai),de+=c.slice(ue,Ii).replace(f0e,eSe),ht&&(G=!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 _1t,bwe=oe(()=>{"use strict";An();_1t=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 Lu({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 x1t,wwe=oe(()=>{"use strict";x1t=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 b1t,Swe=oe(()=>{"use strict";An();b1t=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 Do.init()),await e.user.performLogin(e)}});var w1t,Ewe=oe(()=>{"use strict";w1t=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 S1t,Twe=oe(()=>{"use strict";An();S1t=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 E1t,Cwe=oe(()=>{"use strict";An();E1t=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(O=>O.instanceName===u);if(!f)throw new Error(`The specified source instance does not exist: ${u}.`);let d=a.find(O=>O.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 Awe,Iwe,Nwe,Owe,T1t,C1t,Rwe=oe(()=>{"use strict";An();ur();Awe=ve(require("path")),Iwe=ve(require("os")),Nwe=ve(mc()),Owe=ve(require("assert")),T1t=(e,t)=>Awe.default.join(Iwe.default.homedir(),".serverless",`cloud_shell_activity_${e}_${t}.json`),C1t=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,Owe.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,Nwe.removeSync)(T1t(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 A1t(e){var f,d,h,m;we.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 sS({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");we.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 kwe=oe(()=>{"use strict";yq();FL();PL();xD();oS();_p()});var dS,Pwe,qwe,I1t,Dwe=oe(()=>{"use strict";dS=ve(require("fs")),Pwe=ve(require("path")),qwe=require("child_process"),I1t=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=dS.default.readFileSync(r);dS.default.writeFileSync("ampt.serverless.yml",i);let s=process.argv.slice(3),o=(0,qwe.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=Pwe.default.join(process.cwd(),`serverless.${r}`);if(dS.default.existsSync(n)){await t[r](n);return}}}});var N1t,Lwe=oe(()=>{"use strict";An();N1t=async e=>{var M;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=((M=e.args)==null?void 0:M[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});await u.isAuthorized()||(e.logError(`You don't have access to the "${a}" org.`),a=await e.selectOrg(r)),u.update({orgName:a});let l=new Dt({org:u,serviceName:o}),d=(await l.listInstances()).find(F=>F.instanceName===s);if(d&&d.instanceType!=="preview")throw new Error(`You cannot overwrite an existing ${d.instanceType} environment.`);if(d&&!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 h=r.username,m=new tr({org:u,service:l,instanceName:h}),[g,_,S,b]=await Promise.all([l.get().catch(()=>({serviceName:o})),u.fetch(),d?m.get().catch(()=>{}):void 0,u.getRegions()]),C=await e.selectRegion({orgInfo:_,instanceInfo:S,serviceInfo:g,regions:b});if(!C)return e.logWarning("Deployment cancelled.");let T=new Bi({org:u,service:l,instance:m,fullSync:e.options["full-sync"],cli:e}),w=e.styles.bold(e.styles.blue(s)),E=e.styles.dim(`(${C.name})`),O=n?`Overwriting existing preview environment ${w} ${E}`:`Creating new preview environment ${w} ${E}`;e.viewSpinner(O,{timer:!0}),e.updateSpinnerStep("syncing"),await T.sync();let U=new tr({org:u,service:l,instanceName:s});if(i!==s){let{operationId:F}=await l.copy({sourceInstanceName:i,targetInstanceName:s,copyCode:!0,copyData:!0,copyStorage:!0,instanceType:"preview",region:C.code}),{success:R,message:P}=await e.messenger.waitForOperation({operationId:F,context:e,orgName:a,appName:o});if(P&&(R?e.logInfo(P):e.logError(P)),!R){e.logError("Share command failed"),e.setExitCode(1);return}}await U.get(),e.logSuccess(`Successfully created preview environment ${e.styles.bold(s)} (${C.name}).`),e.logUrl(U.url)}});var O1t,Fwe=oe(()=>{"use strict";O1t=async e=>{await e.startSession()}});var R1t,Mwe=oe(()=>{"use strict";An();R1t=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 k1t,jwe=oe(()=>{"use strict";ur();An();os();k1t=async e=>{e.viewSpinner("Loading");let t=new Do,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}));dV(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 P1t,Bwe=oe(()=>{"use strict";P1t=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 q1t,Uwe=oe(()=>{"use strict";An();q1t=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 $we,D1t,Hwe=oe(()=>{"use strict";$we=ve(wm()),D1t=async e=>{e.log(`v${$we.version}`)}});var $L={};ec($L,{bash:()=>f1t,clone:()=>p1t,dashboard:()=>d1t,delete:()=>h1t,deploy:()=>m1t,docs:()=>g1t,export:()=>v1t,help:()=>y1t,import:()=>_1t,install:()=>x1t,login:()=>b1t,logout:()=>w1t,open:()=>S1t,promote:()=>E1t,run:()=>C1t,sandbox:()=>A1t,serverless:()=>I1t,setup:()=>ML,share:()=>N1t,start:()=>O1t,stop:()=>R1t,test:()=>k1t,uninstall:()=>P1t,url:()=>q1t,version:()=>D1t});var HL=oe(()=>{"use strict";fwe();dwe();hwe();mwe();gwe();vwe();ywe();xwe();bwe();wwe();Swe();Ewe();Twe();Cwe();Rwe();kwe();Dwe();jL();Lwe();Fwe();Mwe();jwe();Bwe();Uwe();Hwe()});var WL=ve(require("os")),ld=ve(Qv()),Vwe=ve(EM()),Gwe=ve(TM()),Ss=ve(OM()),Kwe=ve(WM()),Xs=ve(wj()),Xwe=ve(Tj()),Cl=ve(Aj()),Ywe=ve(Rj()),zL=ve(Dj()),Zwe=ve(JU()),VL=ve(i1()),GL=ve(o1()),KL=require("child_process"),XL=ve(N5()),Jwe=require("fs/promises"),fd=ve(mc()),gS=ve(G1());ur();Gk();An();Pp();An();ur();os();var cwe=ve(mc()),UL=ve(require("path")),cS=ve(require("assert"));An();os();ur();RR();jL();ur();_o();function BL(e){(async()=>{let{orgName:t,serviceName:r,instanceName:n}=e;try{await $e({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 lS=class e{initialized=!1;cli;org;service;instance;data;code;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(()=>{})}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 ML(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,cS.default)(this.org,"Org is required"),(0,cS.default)(this.service,"Service is required"),(0,cS.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,cwe.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 Lu({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()),BL({...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=>{we.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&&(we.trace("waiting for command to finish"),await this.cli.commandRunningInShellPromise,we.trace("command finished")),this.syncInProgress){we.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(),we.trace({size:l.size,queued:this.queuedFilePaths.size},"starting sync"),u=await this.code.sync(l),we.trace({size:l.size,queued:this.queuedFilePaths.size},"sync complete")}BL({...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=>{we.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});we.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),we.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}),we.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,o]=await Promise.all([wb(this.cli),t.detectGit(),this.org.validateLimits()]);if(we.trace({templates:i.length,isGitInstalled:s,limitResult:o},"setupTemplate"),o.serviceExceeded)return this.cli.handleServiceLimitExceeded();if(o.instanceExceeded)return this.cli.handleInstanceLimitExceeded();if(!s)return this.cli.logError(`"${this.cli.styles.bold("git")}" is not installed on this system.`),this.cli.logInfo("Please install git and try again."),await this.cli.quit();let a=i.find(u=>u.name===n);if(!a){this.cli.logWarning(`Template "${n}" not found.`),this.cli.logInfo("Please choose a template to generate.");let u=await this.cli.select(i);a=u,n=u.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:a,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(UL.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||UL.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("Exiting...");this.cli.viewSpinner("Loading");let[s,o,a]=await Promise.all([wb(this.cli),this.org.validateLimits(),t.detectGit()]);if(o.serviceExceeded)return this.cli.handleServiceLimitExceeded();if(o.instanceExceeded)return this.cli.handleInstanceLimitExceeded();if(!a)return this.cli.logError(`"${this.cli.styles.bold("git")}" is not installed on this system.`),this.cli.logInfo("Please install git and try again."),await this.cli.quit();cr({eventName:"ampt.dev.prompt",eventData:{promptName:"template"}}),this.cli.logInfo("Choose a template to generate.");let u=await this.cli.select(s);if(await this.setupApp({name:u.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:u,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;await t.fs.read();let n=t.options.seed||t.options.s;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.");try{await this.authorize(),t.project.isSeedingEnabled=n,t.project.isReseedingEnabled=t.options.reseed||t.options.rs;let i=t.options.tutorial??!1,s=t.options.template??!1;if(we.debug({tutorialPassed:i,templatePassed:s},"Project.init"),s&&await this.setupTemplate(),i)return await t.tutorial.initTutorial();await this.setup(),this.initialized=!0}catch(i){return await t.quit(i.message)}}};var Wwe=(HL(),mt($L));var cd=class extends Error{function=null;constructor(t,r){super(t),this.function=r}},hS=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=await this.cli.fs.detectVsCode(),r="To begin, let's open the project in a code editor.";return{title:"Open the project in an editor",pre:t?[r,'Run `code .` in the terminal to open the project in Visual Studio Code or type "done" to continue']:[r,'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 Wwe.bash(this.cli);else{let s=Wwe[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",we.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(Vwe.default);ld.default.extend(Gwe.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=(HL(),mt($L)),{version:zwe}=wm(),L1t={dim:Xs.default.dim,darkPurple:Xs.default.hex("#B367FF"),purple:Xs.default.hex("#F952FF"),yellow:Xs.default.hex("#FFC700"),blue:Xs.default.hex("#727aff"),red:Xs.default.rgb(255,99,99),grey:Xs.default.hex("#324f59"),pastel:Xs.default.hex("#dbd8ca"),bold:Xs.default.bold,green:Xs.default.hex("#22b9b7")},mS=class e{static defaultSpinnerFrames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];session;messenger;version=zwe;installedGlobally=XL.default;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;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=[];constructor(t){process.title="Ampt CLI",this.session=t,this.session.loadAmptConfig(),this.messenger=new M0,this.messenger.on("offline",(0,GL.default)(()=>{this.logError("Event Messenger offline")},1e3,!0)),this.messenger.on("online",(0,GL.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=L1t,this._startLastSyncedAtInterval(),this._initIcons(),this._initSuggestions(),process.env.GITPOD_HOST&&process.env.GITPOD_IDE_ALIAS&&(this.isGitPod=!0,this.isWebIde=!0,this.isAnimationEnabled=!1),this.isBeta=this.version.includes("beta"),this.isInteractive=process.stdin.isTTY,this.fs=new rw({session:this.session}),this.project=new lS(this),this.tutorial=new hS(this)}async login(){return new Do}setExitCode(t){this._exitCode=t}async start(t){let{_:r,...n}=(0,zL.default)(process.argv);if(this.startupOptions=n,this.fs.verbose=this.startupOptions.verbose,this.fromClone=(t==null?void 0:t.fromClone)||!1,r[2]!=="clone"&&process.platform!=="win32")try{we.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()),await this.messenger.connect(),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 Do.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}}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.logError(`Something went wrong - please contact support and provide ${this.session.getSessionId()} as a reference ID`),this.session.captureException(r),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"){we.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 Tu(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 Tu(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 we.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 q1t,Uwe=oe(()=>{"use strict";An();q1t=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 $we,D1t,Hwe=oe(()=>{"use strict";$we=ve(wm()),D1t=async e=>{e.log(`v${$we.version}`)}});var $L={};ec($L,{bash:()=>f1t,clone:()=>p1t,dashboard:()=>d1t,delete:()=>h1t,deploy:()=>m1t,docs:()=>g1t,export:()=>v1t,help:()=>y1t,import:()=>_1t,install:()=>x1t,login:()=>b1t,logout:()=>w1t,open:()=>S1t,promote:()=>E1t,run:()=>C1t,sandbox:()=>A1t,serverless:()=>I1t,setup:()=>ML,share:()=>N1t,start:()=>O1t,stop:()=>R1t,test:()=>k1t,uninstall:()=>P1t,url:()=>q1t,version:()=>D1t});var HL=oe(()=>{"use strict";fwe();dwe();hwe();mwe();gwe();vwe();ywe();xwe();bwe();wwe();Swe();Ewe();Twe();Cwe();Rwe();kwe();Dwe();jL();Lwe();Fwe();Mwe();jwe();Bwe();Uwe();Hwe()});var WL=ve(require("os")),ld=ve(Qv()),Vwe=ve(EM()),Gwe=ve(TM()),Ss=ve(OM()),Kwe=ve(WM()),Xs=ve(wj()),Xwe=ve(Tj()),Cl=ve(Aj()),Ywe=ve(Rj()),zL=ve(Dj()),Zwe=ve(JU()),VL=ve(i1()),GL=ve(o1()),KL=require("child_process"),XL=ve(N5()),Jwe=require("fs/promises"),fd=ve(mc()),gS=ve(G1());ur();Gk();An();Pp();An();ur();os();var cwe=ve(mc()),UL=ve(require("path")),cS=ve(require("assert"));An();os();ur();RR();jL();ur();_o();function BL(e){(async()=>{let{orgName:t,serviceName:r,instanceName:n}=e;try{await $e({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 lS=class e{initialized=!1;cli;org;service;instance;data;code;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(()=>{})}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 ML(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,cS.default)(this.org,"Org is required"),(0,cS.default)(this.service,"Service is required"),(0,cS.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,cwe.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 Lu({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()),BL({...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=>{we.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&&(we.trace("waiting for command to finish"),await this.cli.commandRunningInShellPromise,we.trace("command finished")),this.syncInProgress){we.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(),we.trace({size:l.size,queued:this.queuedFilePaths.size},"starting sync"),u=await this.code.sync(l),we.trace({size:l.size,queued:this.queuedFilePaths.size},"sync complete")}BL({...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=>{we.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});we.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),we.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}),we.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,o]=await Promise.all([wb(this.cli),t.detectGit(),this.org.validateLimits()]);if(we.trace({templates:i.length,isGitInstalled:s,limitResult:o},"setupTemplate"),o.serviceExceeded)return this.cli.handleServiceLimitExceeded();if(o.instanceExceeded)return this.cli.handleInstanceLimitExceeded();if(!s)return this.cli.logError(`"${this.cli.styles.bold("git")}" is not installed on this system.`),this.cli.logInfo("Please install git and try again."),await this.cli.quit();let a=i.find(u=>u.name===n);if(!a){this.cli.logWarning(`Template "${n}" not found.`),this.cli.logInfo("Please choose a template to generate.");let u=await this.cli.select(i);a=u,n=u.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:a,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(UL.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||UL.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,a]=await Promise.all([wb(this.cli),this.org.validateLimits(),t.detectGit()]);if(o.serviceExceeded)return this.cli.handleServiceLimitExceeded();if(o.instanceExceeded)return this.cli.handleInstanceLimitExceeded();if(!a)return this.cli.logError(`"${this.cli.styles.bold("git")}" is not installed on this system.`),this.cli.logInfo("Please install git and try again."),await this.cli.quit();cr({eventName:"ampt.dev.prompt",eventData:{promptName:"template"}}),this.cli.logInfo("Choose a template to generate.");let u=await this.cli.select(s);if(await this.setupApp({name:u.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:u,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;await t.fs.read();let n=t.options.seed||t.options.s;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.");try{await this.authorize(),t.project.isSeedingEnabled=n,t.project.isReseedingEnabled=t.options.reseed||t.options.rs;let i=t.options.tutorial??!1,s=t.options.template??!1;if(we.debug({tutorialPassed:i,templatePassed:s},"Project.init"),s&&await this.setupTemplate(),i)return await t.tutorial.initTutorial();await this.setup(),this.initialized=!0}catch(i){return await t.quit(i.message)}}};var Wwe=(HL(),mt($L));var cd=class extends Error{function=null;constructor(t,r){super(t),this.function=r}},hS=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=await this.cli.fs.detectVsCode(),r="To begin, let's open the project in a code editor.";return{title:"Open the project in an editor",pre:t?[r,'Run `code .` in the terminal to open the project in Visual Studio Code or type "done" to continue']:[r,'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 Wwe.bash(this.cli);else{let s=Wwe[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",we.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(Vwe.default);ld.default.extend(Gwe.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=(HL(),mt($L)),{version:zwe}=wm(),L1t={dim:Xs.default.dim,darkPurple:Xs.default.hex("#B367FF"),purple:Xs.default.hex("#F952FF"),yellow:Xs.default.hex("#FFC700"),blue:Xs.default.hex("#727aff"),red:Xs.default.rgb(255,99,99),grey:Xs.default.hex("#324f59"),pastel:Xs.default.hex("#dbd8ca"),bold:Xs.default.bold,green:Xs.default.hex("#22b9b7")},mS=class e{static defaultSpinnerFrames=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];session;messenger;version=zwe;installedGlobally=XL.default;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;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=[];constructor(t){process.title="Ampt CLI",this.session=t,this.session.loadAmptConfig(),this.messenger=new M0,this.messenger.on("offline",(0,GL.default)(()=>{this.logError("Event Messenger offline")},1e3,!0)),this.messenger.on("online",(0,GL.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=L1t,this._startLastSyncedAtInterval(),this._initIcons(),this._initSuggestions(),process.env.GITPOD_HOST&&process.env.GITPOD_IDE_ALIAS&&(this.isGitPod=!0,this.isWebIde=!0,this.isAnimationEnabled=!1),this.isBeta=this.version.includes("beta"),this.isInteractive=process.stdin.isTTY,this.fs=new rw({session:this.session}),this.project=new lS(this),this.tutorial=new hS(this)}async login(){return new Do}setExitCode(t){this._exitCode=t}async start(t){let{_:r,...n}=(0,zL.default)(process.argv);if(this.startupOptions=n,this.fs.verbose=this.startupOptions.verbose,this.fromClone=(t==null?void 0:t.fromClone)||!1,r[2]!=="clone"&&process.platform!=="win32")try{we.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()),await this.messenger.connect(),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 Do.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}}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.logError(`Something went wrong - please contact support and provide ${this.session.getSessionId()} as a reference ID`),this.session.captureException(r),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"){we.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 Tu(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 Tu(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 we.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 eJ(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.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,Jwe.readFile)(i,"utf8"));return kR(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,KL.execSync)(`taskkill /PID ${process.pid} /T /F`);else try{process.kill(-process.pid,"SIGINT")}catch{process.kill(-process.ppid,"SIGINT")}}catch(r){we.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?sJ(t):process.argv.slice(2),n=(0,zL.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=mV(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,we.debug({args:this.args},"cli args"),we.debug({...this.options},"cli options"),we.debug({...this.names},"cli names")}_logLogo(){if(!this.showLogo)return;let t=WL.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+=WL.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,Ywe.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(`
|