var _=Object.create;var a=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var G=(t,e)=>{for(var o in e)a(t,o,{get:e[o],enumerable:!0})},N=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of T(e))!k.call(t,n)&&n!==o&&a(t,n,{get:()=>e[n],enumerable:!(r=S(e,n))||r.enumerable});return t};var y=(t,e,o)=>(o=t!=null?_(D(t)):{},N(e||!t||!t.__esModule?a(o,"default",{value:t,enumerable:!0}):o,t)),M=t=>N(a({},"__esModule",{value:!0}),t);var K={};G(K,{getAndroidBuildNumber:()=>f,getBuildNumber:()=>I,getNextVersion:()=>q,getXcodeBuildBumber:()=>g,incrementBuildNumber:()=>H,updateAndroidBuildNumber:()=>l,updateAndroidVersion:()=>u,updateBuildNumber:()=>X,updateFastlaneVersion:()=>j,updateInfoPlist:()=>P,updateVersion:()=>z,updateXcodeBuildNumber:()=>b,updateXcodeVersion:()=>x});module.exports=M(K);var O=require("fs/promises");var p=require("fs/promises");async function s(t,e){let o=await(0,p.readFile)(t,"utf-8"),r=e(o);await(0,p.writeFile)(t,r)}var i=class extends Error{clipanion={type:"none"}};var F=/versionCode (\d+)/,J=/versionName "(.+)"/,d="android/app/build.gradle";async function u(t,{gradlePath:e=d}={}){await s(e,o=>o.replace(J,`versionName "${t}"`))}async function l(t,{gradlePath:e=d}={}){await s(e,o=>o.replace(F,`versionCode ${t}`))}async function f({gradlePath:t=d}={}){let e=await(0,O.readFile)(t,"utf-8"),[o,r]=e.match(F)||[];if(!r)throw new Error(`No versionCode found inside ${t}`);let n=parseFloat(r);if(isNaN(n))throw new i(`Invalid build number found in ${t}: ${r}`);return n}var C=require("fs/promises"),V=y(require("fast-glob")),rt=require("plist");var m=y(require("plist"));function v(t){return m.default.parse(t)}function h(t){return m.default.build(t,{indent:" "}).replace(/^\t/gm,"").replaceAll("","")+` `}var B="**/*.xcodeproj/project.pbxproj",U=["**/Info.plist","!**/Pods/**","!**/build/**"],E="CURRENT_PROJECT_VERSION = ([0-9.]+)";async function w(t,e=`No such file ${t}`){let o=await V.default.async(t);if(o.length===0)throw new i(e);return o}function P(t,e){return s(t,o=>{let r=v(o);if(typeof r!="object")throw new i(`Invalid Info.plist at ${t}`);return h(Object.assign(r,e))})}function $(){return w(U,"No Info.plist found")}async function x(t,e={}){let o=e.infoPlists||await $();for(let r of o)await P(r,{CFBundleShortVersionString:t})}async function W(t,{buildNumber:e}){await s(t,o=>o.replace(new RegExp(E,"g"),`CURRENT_PROJECT_VERSION = ${e}`))}async function b(t,e={}){let o=e.infoPlists||await $();for(let n of o)await P(n,{CFBundleVersion:`${t}`});let[r]=await w(B,"No project.pbxproj found");await W(r,{buildNumber:t})}async function g(t){let[e]=await w(B,"No project.pbxproj found"),o=await(0,C.readFile)(e,"utf-8"),[,r]=o.match(new RegExp(E))||[];if(!r)throw new i(`No build number found in ${e}`);let n=parseFloat(r);if(isNaN(n))throw new i(`Invalid build number found in ${e}: ${r}`);return n}var c=require("fs/promises"),A=require("path");async function j(t,{fastlaneDir:e="./fastlane"}={}){let o=(0,A.join)(e,"/Deliverfile");try{let n=(await(0,c.readFile)(o,"utf8")).replace(/^app_version.+$/m,`app_version '${t}'`);await(0,c.writeFile)(o,n)}catch(r){if(r.code==="ENOENT")return console.warn(`No Deliverfile detected (tried ${o})`);throw r}}var R=require("changesets-preview");async function q({packageName:t,rootDir:e=process.cwd()}){return(await(0,R.previewPackageRelease)({package:t,cwd:e})).newVersion}async function z(t,e){await x(t,e),await u(t,e),await j(t,e)}async function X(t,e){await b(t,e),await l(t,e)}async function I(t){return(await Promise.all([g(t),f(t)])).reduce((o,r)=>Math.max(o,r))}async function H(t){let e=await I(t);return X(e+1,t)}0&&(module.exports={getAndroidBuildNumber,getBuildNumber,getNextVersion,getXcodeBuildBumber,incrementBuildNumber,updateAndroidBuildNumber,updateAndroidVersion,updateBuildNumber,updateFastlaneVersion,updateInfoPlist,updateVersion,updateXcodeBuildNumber,updateXcodeVersion});