"use strict";var t=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(o,s){function r(t){try{c(i.next(t))}catch(t){s(t)}}function u(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,u)}c((i=i.apply(t,e||[])).next())}))},e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.init=void 0;const n=require("../../util"),i=e(require("path")),o=require("./util"),s=e(require("./interactiveInput")),r=require("../../common/Constants"),u=require("../../util/FsUtil"),c={name:"",version:"1.0.0",description:"",main:"index.ets",author:"",license:"ISC",dependencies:{}};exports.init=function(e){return t(this,void 0,void 0,(function*(){const a=process.cwd(),l=a.split(i.default.sep);let d=l[l.length-1].toLowerCase();const f=i.default.join(a,r.Constants.MyPackageJson);(yield u.FsUtil.exists(f))&&(d=(yield u.FsUtil.readJSON5(f)).name||d),e.group&&(d.startsWith("@")&&d.includes("/")&&(d=d.split("/")[1]),d=`@${e.group}/${d}`),e.yes?function(t){const e=(0,o.validateNameFun)(t);if(!e)return;c.name=e;const s=JSON.stringify(c,null," "),u=i.default.join(process.cwd(),r.Constants.MyPackageJson);(0,o.output)(`Wrote to ${u}:\n`),(0,o.output)(`${s}\n\n`),n.FsBlockingUtil.writeFileSync(u,s)}(d):yield function(e){return t(this,void 0,void 0,(function*(){yield(0,s.default)(e)}))}(d)}))};