rolldown-build-CrPk_lZe.mjs 148 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254
  1. import { n as __toESM, t as require_binding } from "./binding-CXquf8ay.mjs";
  2. import { i as logInputHookInOutputPlugin, n as error } from "./logs-aMKUxRpj.mjs";
  3. import { n as BuiltinPlugin } from "./normalize-string-or-regex-CNPF6PU9.mjs";
  4. import { c as __decorate, d as PlainObjectLike, f as MinimalPluginContextImpl, h as LOG_LEVEL_DEBUG, i as transformModuleInfo, l as transformAssetSource, m as normalizeLog, o as transformToRollupOutput, p as normalizeHook, s as transformRenderedChunk, t as bindingifyInputOptions, u as lazyProp, v as LOG_LEVEL_WARN, x as VERSION, y as logLevelPriority } from "./bindingify-input-options-ClrST5Xx.mjs";
  5. import { i as unimplemented } from "./misc-CoQm4NHO.mjs";
  6. import { i as unwrapBindingResult } from "./error-BuvQYXuZ.mjs";
  7. import { Worker } from "node:worker_threads";
  8. import path, { sep } from "node:path";
  9. import { formatWithOptions, styleText } from "node:util";
  10. import process$1 from "node:process";
  11. import * as tty from "node:tty";
  12. import os from "node:os";
  13. //#region src/log/logger.ts
  14. var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
  15. function getLogger(plugins, onLog, logLevel, watchMode) {
  16. const minimalPriority = logLevelPriority[logLevel];
  17. const logger = (level, log, skipped = /* @__PURE__ */ new Set()) => {
  18. if (logLevelPriority[level] < minimalPriority) return;
  19. for (const plugin of getSortedPlugins("onLog", plugins)) {
  20. if (skipped.has(plugin)) continue;
  21. const { onLog: pluginOnLog } = plugin;
  22. if (pluginOnLog) {
  23. const getLogHandler = (level) => {
  24. if (logLevelPriority[level] < minimalPriority) return () => {};
  25. return (log) => logger(level, normalizeLog(log), new Set(skipped).add(plugin));
  26. };
  27. if (("handler" in pluginOnLog ? pluginOnLog.handler : pluginOnLog).call({
  28. debug: getLogHandler("debug"),
  29. error: (log) => error(normalizeLog(log)),
  30. info: getLogHandler("info"),
  31. meta: {
  32. rollupVersion: "4.23.0",
  33. rolldownVersion: VERSION,
  34. watchMode
  35. },
  36. warn: getLogHandler("warn"),
  37. pluginName: plugin.name || "unknown"
  38. }, level, log) === false) return;
  39. }
  40. }
  41. onLog(level, log);
  42. };
  43. return logger;
  44. }
  45. const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
  46. const { onwarn, onLog } = config;
  47. const defaultOnLog = getDefaultOnLog(printLog, onwarn);
  48. if (onLog) {
  49. const minimalPriority = logLevelPriority[logLevel];
  50. return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
  51. if (level === "error") return error(normalizeLog(handledLog));
  52. if (logLevelPriority[level] >= minimalPriority) defaultOnLog(level, normalizeLog(handledLog));
  53. });
  54. }
  55. return defaultOnLog;
  56. };
  57. const getDefaultOnLog = (printLog, onwarn) => onwarn ? (level, log) => {
  58. if (level === "warn") onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
  59. else printLog(level, log);
  60. } : printLog;
  61. const addLogToString = (log) => {
  62. Object.defineProperty(log, "toString", {
  63. value: () => getExtendedLogMessage(log),
  64. writable: true
  65. });
  66. return log;
  67. };
  68. const defaultPrintLog = (level, log) => {
  69. const message = getExtendedLogMessage(log);
  70. switch (level) {
  71. case LOG_LEVEL_WARN: return console.warn(message);
  72. case LOG_LEVEL_DEBUG: return console.debug(message);
  73. default: return console.info(message);
  74. }
  75. };
  76. const getExtendedLogMessage = (log) => {
  77. let prefix = "";
  78. if (log.plugin) prefix += `(${log.plugin} plugin) `;
  79. if (log.loc) prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
  80. return prefix + log.message;
  81. };
  82. function relativeId(id) {
  83. if (!path.isAbsolute(id)) return id;
  84. return path.relative(path.resolve(), id);
  85. }
  86. //#endregion
  87. //#region src/constants/plugin.ts
  88. const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
  89. "options",
  90. "buildStart",
  91. "resolveId",
  92. "load",
  93. "transform",
  94. "moduleParsed",
  95. "buildEnd",
  96. "onLog",
  97. "resolveDynamicImport",
  98. "closeBundle",
  99. "closeWatcher",
  100. "watchChange"
  101. ];
  102. const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
  103. "augmentChunkHash",
  104. "outputOptions",
  105. "renderChunk",
  106. "renderStart",
  107. "renderError",
  108. "writeBundle",
  109. "generateBundle"
  110. ];
  111. const ENUMERATED_PLUGIN_HOOK_NAMES = [
  112. ...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
  113. ...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
  114. "footer",
  115. "banner",
  116. "intro",
  117. "outro"
  118. ];
  119. ENUMERATED_PLUGIN_HOOK_NAMES[0], ENUMERATED_PLUGIN_HOOK_NAMES[0], ENUMERATED_PLUGIN_HOOK_NAMES[1], ENUMERATED_PLUGIN_HOOK_NAMES[1], ENUMERATED_PLUGIN_HOOK_NAMES[2], ENUMERATED_PLUGIN_HOOK_NAMES[2], ENUMERATED_PLUGIN_HOOK_NAMES[3], ENUMERATED_PLUGIN_HOOK_NAMES[3], ENUMERATED_PLUGIN_HOOK_NAMES[4], ENUMERATED_PLUGIN_HOOK_NAMES[4], ENUMERATED_PLUGIN_HOOK_NAMES[5], ENUMERATED_PLUGIN_HOOK_NAMES[5], ENUMERATED_PLUGIN_HOOK_NAMES[6], ENUMERATED_PLUGIN_HOOK_NAMES[6], ENUMERATED_PLUGIN_HOOK_NAMES[7], ENUMERATED_PLUGIN_HOOK_NAMES[7], ENUMERATED_PLUGIN_HOOK_NAMES[8], ENUMERATED_PLUGIN_HOOK_NAMES[8], ENUMERATED_PLUGIN_HOOK_NAMES[9], ENUMERATED_PLUGIN_HOOK_NAMES[9], ENUMERATED_PLUGIN_HOOK_NAMES[10], ENUMERATED_PLUGIN_HOOK_NAMES[10], ENUMERATED_PLUGIN_HOOK_NAMES[11], ENUMERATED_PLUGIN_HOOK_NAMES[11], ENUMERATED_PLUGIN_HOOK_NAMES[12], ENUMERATED_PLUGIN_HOOK_NAMES[12], ENUMERATED_PLUGIN_HOOK_NAMES[13], ENUMERATED_PLUGIN_HOOK_NAMES[13], ENUMERATED_PLUGIN_HOOK_NAMES[14], ENUMERATED_PLUGIN_HOOK_NAMES[14], ENUMERATED_PLUGIN_HOOK_NAMES[15], ENUMERATED_PLUGIN_HOOK_NAMES[15], ENUMERATED_PLUGIN_HOOK_NAMES[16], ENUMERATED_PLUGIN_HOOK_NAMES[16], ENUMERATED_PLUGIN_HOOK_NAMES[17], ENUMERATED_PLUGIN_HOOK_NAMES[17], ENUMERATED_PLUGIN_HOOK_NAMES[18], ENUMERATED_PLUGIN_HOOK_NAMES[18], ENUMERATED_PLUGIN_HOOK_NAMES[19], ENUMERATED_PLUGIN_HOOK_NAMES[19], ENUMERATED_PLUGIN_HOOK_NAMES[20], ENUMERATED_PLUGIN_HOOK_NAMES[20], ENUMERATED_PLUGIN_HOOK_NAMES[21], ENUMERATED_PLUGIN_HOOK_NAMES[21], ENUMERATED_PLUGIN_HOOK_NAMES[22], ENUMERATED_PLUGIN_HOOK_NAMES[22];
  120. //#endregion
  121. //#region src/utils/async-flatten.ts
  122. async function asyncFlatten(array) {
  123. do
  124. array = (await Promise.all(array)).flat(Infinity);
  125. while (array.some((v) => v?.then));
  126. return array;
  127. }
  128. //#endregion
  129. //#region src/utils/normalize-plugin-option.ts
  130. const normalizePluginOption = async (plugins) => (await asyncFlatten([plugins])).filter(Boolean);
  131. function checkOutputPluginOption(plugins, onLog) {
  132. for (const plugin of plugins) for (const hook of ENUMERATED_INPUT_PLUGIN_HOOK_NAMES) if (hook in plugin) {
  133. delete plugin[hook];
  134. onLog(LOG_LEVEL_WARN, logInputHookInOutputPlugin(plugin.name, hook));
  135. }
  136. return plugins;
  137. }
  138. function normalizePlugins(plugins, anonymousPrefix) {
  139. for (const [index, plugin] of plugins.entries()) {
  140. if ("_parallel" in plugin) continue;
  141. if (plugin instanceof BuiltinPlugin) continue;
  142. if (!plugin.name) plugin.name = `${anonymousPrefix}${index + 1}`;
  143. }
  144. return plugins;
  145. }
  146. const ANONYMOUS_PLUGIN_PREFIX = "at position ";
  147. const ANONYMOUS_OUTPUT_PLUGIN_PREFIX = "at output position ";
  148. //#endregion
  149. //#region src/plugin/plugin-driver.ts
  150. var PluginDriver = class {
  151. static async callOptionsHook(inputOptions, watchMode = false) {
  152. const logLevel = inputOptions.logLevel || "info";
  153. const plugins = getSortedPlugins("options", getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
  154. const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel, watchMode);
  155. for (const plugin of plugins) {
  156. const name = plugin.name || "unknown";
  157. const options = plugin.options;
  158. if (options) {
  159. const { handler } = normalizeHook(options);
  160. const result = await handler.call(new MinimalPluginContextImpl(logger, logLevel, name, watchMode, "onLog"), inputOptions);
  161. if (result) inputOptions = result;
  162. }
  163. }
  164. return inputOptions;
  165. }
  166. static callOutputOptionsHook(rawPlugins, outputOptions, onLog, logLevel, watchMode) {
  167. const sortedPlugins = getSortedPlugins("outputOptions", getObjectPlugins(rawPlugins));
  168. for (const plugin of sortedPlugins) {
  169. const name = plugin.name || "unknown";
  170. const options = plugin.outputOptions;
  171. if (options) {
  172. const { handler } = normalizeHook(options);
  173. const result = handler.call(new MinimalPluginContextImpl(onLog, logLevel, name, watchMode), outputOptions);
  174. if (result) outputOptions = result;
  175. }
  176. }
  177. return outputOptions;
  178. }
  179. };
  180. function getObjectPlugins(plugins) {
  181. return plugins.filter((plugin) => {
  182. if (!plugin) return;
  183. if ("_parallel" in plugin) return;
  184. if (plugin instanceof BuiltinPlugin) return;
  185. return plugin;
  186. });
  187. }
  188. function getSortedPlugins(hookName, plugins) {
  189. const pre = [];
  190. const normal = [];
  191. const post = [];
  192. for (const plugin of plugins) {
  193. const hook = plugin[hookName];
  194. if (hook) {
  195. if (typeof hook === "object") {
  196. if (hook.order === "pre") {
  197. pre.push(plugin);
  198. continue;
  199. }
  200. if (hook.order === "post") {
  201. post.push(plugin);
  202. continue;
  203. }
  204. }
  205. normal.push(plugin);
  206. }
  207. }
  208. return [
  209. ...pre,
  210. ...normal,
  211. ...post
  212. ];
  213. }
  214. const DEFAULT_CONFIG = {
  215. lang: void 0,
  216. message: void 0,
  217. abortEarly: void 0,
  218. abortPipeEarly: void 0
  219. };
  220. /**
  221. * Returns the global configuration.
  222. *
  223. * @param config The config to merge.
  224. *
  225. * @returns The configuration.
  226. */
  227. /* @__NO_SIDE_EFFECTS__ */
  228. function getGlobalConfig(config$1) {
  229. if (!config$1 && true) return DEFAULT_CONFIG;
  230. return {
  231. lang: config$1?.lang ?? void 0,
  232. message: config$1?.message,
  233. abortEarly: config$1?.abortEarly ?? void 0,
  234. abortPipeEarly: config$1?.abortPipeEarly ?? void 0
  235. };
  236. }
  237. /**
  238. * Stringifies an unknown input to a literal or type string.
  239. *
  240. * @param input The unknown input.
  241. *
  242. * @returns A literal or type string.
  243. *
  244. * @internal
  245. */
  246. /* @__NO_SIDE_EFFECTS__ */
  247. function _stringify(input) {
  248. const type = typeof input;
  249. if (type === "string") return `"${input}"`;
  250. if (type === "number" || type === "bigint" || type === "boolean") return `${input}`;
  251. if (type === "object" || type === "function") return (input && Object.getPrototypeOf(input)?.constructor?.name) ?? "null";
  252. return type;
  253. }
  254. /**
  255. * Adds an issue to the dataset.
  256. *
  257. * @param context The issue context.
  258. * @param label The issue label.
  259. * @param dataset The input dataset.
  260. * @param config The configuration.
  261. * @param other The optional props.
  262. *
  263. * @internal
  264. */
  265. function _addIssue(context, label, dataset, config$1, other) {
  266. const input = other && "input" in other ? other.input : dataset.value;
  267. const expected = other?.expected ?? context.expects ?? null;
  268. const received = other?.received ?? /* @__PURE__ */ _stringify(input);
  269. const issue = {
  270. kind: context.kind,
  271. type: context.type,
  272. input,
  273. expected,
  274. received,
  275. message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
  276. requirement: context.requirement,
  277. path: other?.path,
  278. issues: other?.issues,
  279. lang: config$1.lang,
  280. abortEarly: config$1.abortEarly,
  281. abortPipeEarly: config$1.abortPipeEarly
  282. };
  283. const isSchema = context.kind === "schema";
  284. const message$1 = other?.message ?? context.message ?? (context.reference, issue.lang, void 0) ?? (isSchema ? (issue.lang, void 0) : null) ?? config$1.message ?? (issue.lang, void 0);
  285. if (message$1 !== void 0) issue.message = typeof message$1 === "function" ? message$1(issue) : message$1;
  286. if (isSchema) dataset.typed = false;
  287. if (dataset.issues) dataset.issues.push(issue);
  288. else dataset.issues = [issue];
  289. }
  290. const _standardCache = /* @__PURE__ */ new WeakMap();
  291. /**
  292. * Returns the Standard Schema properties.
  293. *
  294. * @param context The schema context.
  295. *
  296. * @returns The Standard Schema properties.
  297. */
  298. /* @__NO_SIDE_EFFECTS__ */
  299. function _getStandardProps(context) {
  300. let cached = _standardCache.get(context);
  301. if (!cached) {
  302. cached = {
  303. version: 1,
  304. vendor: "valibot",
  305. validate(value$1) {
  306. return context["~run"]({ value: value$1 }, /* @__PURE__ */ getGlobalConfig());
  307. }
  308. };
  309. _standardCache.set(context, cached);
  310. }
  311. return cached;
  312. }
  313. /**
  314. * Disallows inherited object properties and prevents object prototype
  315. * pollution by disallowing certain keys.
  316. *
  317. * @param object The object to check.
  318. * @param key The key to check.
  319. *
  320. * @returns Whether the key is allowed.
  321. *
  322. * @internal
  323. */
  324. /* @__NO_SIDE_EFFECTS__ */
  325. function _isValidObjectKey(object$1, key) {
  326. return Object.prototype.hasOwnProperty.call(object$1, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
  327. }
  328. /**
  329. * Joins multiple `expects` values with the given separator.
  330. *
  331. * @param values The `expects` values.
  332. * @param separator The separator.
  333. *
  334. * @returns The joined `expects` property.
  335. *
  336. * @internal
  337. */
  338. /* @__NO_SIDE_EFFECTS__ */
  339. function _joinExpects(values$1, separator) {
  340. const list = [...new Set(values$1)];
  341. if (list.length > 1) return `(${list.join(` ${separator} `)})`;
  342. return list[0] ?? "never";
  343. }
  344. /**
  345. * A Valibot error with useful information.
  346. */
  347. var ValiError = class extends Error {
  348. /**
  349. * Creates a Valibot error with useful information.
  350. *
  351. * @param issues The error issues.
  352. */
  353. constructor(issues) {
  354. super(issues[0].message);
  355. this.name = "ValiError";
  356. this.issues = issues;
  357. }
  358. };
  359. /* @__NO_SIDE_EFFECTS__ */
  360. function args(schema) {
  361. return {
  362. kind: "transformation",
  363. type: "args",
  364. reference: args,
  365. async: false,
  366. schema,
  367. "~run"(dataset, config$1) {
  368. const func = dataset.value;
  369. dataset.value = (...args_) => {
  370. const argsDataset = this.schema["~run"]({ value: args_ }, config$1);
  371. if (argsDataset.issues) throw new ValiError(argsDataset.issues);
  372. return func(...argsDataset.value);
  373. };
  374. return dataset;
  375. }
  376. };
  377. }
  378. /**
  379. * Creates an await transformation action.
  380. *
  381. * @returns An await action.
  382. */
  383. /* @__NO_SIDE_EFFECTS__ */
  384. function awaitAsync() {
  385. return {
  386. kind: "transformation",
  387. type: "await",
  388. reference: awaitAsync,
  389. async: true,
  390. async "~run"(dataset) {
  391. dataset.value = await dataset.value;
  392. return dataset;
  393. }
  394. };
  395. }
  396. /**
  397. * Creates a description metadata action.
  398. *
  399. * @param description_ The description text.
  400. *
  401. * @returns A description action.
  402. */
  403. /* @__NO_SIDE_EFFECTS__ */
  404. function description(description_) {
  405. return {
  406. kind: "metadata",
  407. type: "description",
  408. reference: description,
  409. description: description_
  410. };
  411. }
  412. /* @__NO_SIDE_EFFECTS__ */
  413. function returns(schema) {
  414. return {
  415. kind: "transformation",
  416. type: "returns",
  417. reference: returns,
  418. async: false,
  419. schema,
  420. "~run"(dataset, config$1) {
  421. const func = dataset.value;
  422. dataset.value = (...args_) => {
  423. const returnsDataset = this.schema["~run"]({ value: func(...args_) }, config$1);
  424. if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
  425. return returnsDataset.value;
  426. };
  427. return dataset;
  428. }
  429. };
  430. }
  431. /* @__NO_SIDE_EFFECTS__ */
  432. function returnsAsync(schema) {
  433. return {
  434. kind: "transformation",
  435. type: "returns",
  436. reference: returnsAsync,
  437. async: false,
  438. schema,
  439. "~run"(dataset, config$1) {
  440. const func = dataset.value;
  441. dataset.value = async (...args_) => {
  442. const returnsDataset = await this.schema["~run"]({ value: await func(...args_) }, config$1);
  443. if (returnsDataset.issues) throw new ValiError(returnsDataset.issues);
  444. return returnsDataset.value;
  445. };
  446. return dataset;
  447. }
  448. };
  449. }
  450. const ABORT_EARLY_CONFIG = { abortEarly: true };
  451. /**
  452. * Returns the fallback value of the schema.
  453. *
  454. * @param schema The schema to get it from.
  455. * @param dataset The output dataset if available.
  456. * @param config The config if available.
  457. *
  458. * @returns The fallback value.
  459. */
  460. /* @__NO_SIDE_EFFECTS__ */
  461. function getFallback(schema, dataset, config$1) {
  462. return typeof schema.fallback === "function" ? schema.fallback(dataset, config$1) : schema.fallback;
  463. }
  464. /**
  465. * Returns the default value of the schema.
  466. *
  467. * @param schema The schema to get it from.
  468. * @param dataset The input dataset if available.
  469. * @param config The config if available.
  470. *
  471. * @returns The default value.
  472. */
  473. /* @__NO_SIDE_EFFECTS__ */
  474. function getDefault(schema, dataset, config$1) {
  475. return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
  476. }
  477. /**
  478. * Checks if the input matches the schema. By using a type predicate, this
  479. * function can be used as a type guard.
  480. *
  481. * @param schema The schema to be used.
  482. * @param input The input to be tested.
  483. *
  484. * @returns Whether the input matches the schema.
  485. */
  486. /* @__NO_SIDE_EFFECTS__ */
  487. function is(schema, input) {
  488. return !schema["~run"]({ value: input }, ABORT_EARLY_CONFIG).issues;
  489. }
  490. /**
  491. * Creates an any schema.
  492. *
  493. * Hint: This schema function exists only for completeness and is not
  494. * recommended in practice. Instead, `unknown` should be used to accept
  495. * unknown data.
  496. *
  497. * @returns An any schema.
  498. */
  499. /* @__NO_SIDE_EFFECTS__ */
  500. function any() {
  501. return {
  502. kind: "schema",
  503. type: "any",
  504. reference: any,
  505. expects: "any",
  506. async: false,
  507. get "~standard"() {
  508. return /* @__PURE__ */ _getStandardProps(this);
  509. },
  510. "~run"(dataset) {
  511. dataset.typed = true;
  512. return dataset;
  513. }
  514. };
  515. }
  516. /* @__NO_SIDE_EFFECTS__ */
  517. function array(item, message$1) {
  518. return {
  519. kind: "schema",
  520. type: "array",
  521. reference: array,
  522. expects: "Array",
  523. async: false,
  524. item,
  525. message: message$1,
  526. get "~standard"() {
  527. return /* @__PURE__ */ _getStandardProps(this);
  528. },
  529. "~run"(dataset, config$1) {
  530. const input = dataset.value;
  531. if (Array.isArray(input)) {
  532. dataset.typed = true;
  533. dataset.value = [];
  534. for (let key = 0; key < input.length; key++) {
  535. const value$1 = input[key];
  536. const itemDataset = this.item["~run"]({ value: value$1 }, config$1);
  537. if (itemDataset.issues) {
  538. const pathItem = {
  539. type: "array",
  540. origin: "value",
  541. input,
  542. key,
  543. value: value$1
  544. };
  545. for (const issue of itemDataset.issues) {
  546. if (issue.path) issue.path.unshift(pathItem);
  547. else issue.path = [pathItem];
  548. dataset.issues?.push(issue);
  549. }
  550. if (!dataset.issues) dataset.issues = itemDataset.issues;
  551. if (config$1.abortEarly) {
  552. dataset.typed = false;
  553. break;
  554. }
  555. }
  556. if (!itemDataset.typed) dataset.typed = false;
  557. dataset.value.push(itemDataset.value);
  558. }
  559. } else _addIssue(this, "type", dataset, config$1);
  560. return dataset;
  561. }
  562. };
  563. }
  564. /* @__NO_SIDE_EFFECTS__ */
  565. function boolean(message$1) {
  566. return {
  567. kind: "schema",
  568. type: "boolean",
  569. reference: boolean,
  570. expects: "boolean",
  571. async: false,
  572. message: message$1,
  573. get "~standard"() {
  574. return /* @__PURE__ */ _getStandardProps(this);
  575. },
  576. "~run"(dataset, config$1) {
  577. if (typeof dataset.value === "boolean") dataset.typed = true;
  578. else _addIssue(this, "type", dataset, config$1);
  579. return dataset;
  580. }
  581. };
  582. }
  583. /* @__NO_SIDE_EFFECTS__ */
  584. function custom(check$1, message$1) {
  585. return {
  586. kind: "schema",
  587. type: "custom",
  588. reference: custom,
  589. expects: "unknown",
  590. async: false,
  591. check: check$1,
  592. message: message$1,
  593. get "~standard"() {
  594. return /* @__PURE__ */ _getStandardProps(this);
  595. },
  596. "~run"(dataset, config$1) {
  597. if (this.check(dataset.value)) dataset.typed = true;
  598. else _addIssue(this, "type", dataset, config$1);
  599. return dataset;
  600. }
  601. };
  602. }
  603. /* @__NO_SIDE_EFFECTS__ */
  604. function function_(message$1) {
  605. return {
  606. kind: "schema",
  607. type: "function",
  608. reference: function_,
  609. expects: "Function",
  610. async: false,
  611. message: message$1,
  612. get "~standard"() {
  613. return /* @__PURE__ */ _getStandardProps(this);
  614. },
  615. "~run"(dataset, config$1) {
  616. if (typeof dataset.value === "function") dataset.typed = true;
  617. else _addIssue(this, "type", dataset, config$1);
  618. return dataset;
  619. }
  620. };
  621. }
  622. /* @__NO_SIDE_EFFECTS__ */
  623. function instance(class_, message$1) {
  624. return {
  625. kind: "schema",
  626. type: "instance",
  627. reference: instance,
  628. expects: class_.name,
  629. async: false,
  630. class: class_,
  631. message: message$1,
  632. get "~standard"() {
  633. return /* @__PURE__ */ _getStandardProps(this);
  634. },
  635. "~run"(dataset, config$1) {
  636. if (dataset.value instanceof this.class) dataset.typed = true;
  637. else _addIssue(this, "type", dataset, config$1);
  638. return dataset;
  639. }
  640. };
  641. }
  642. /* @__NO_SIDE_EFFECTS__ */
  643. function literal(literal_, message$1) {
  644. return {
  645. kind: "schema",
  646. type: "literal",
  647. reference: literal,
  648. expects: /* @__PURE__ */ _stringify(literal_),
  649. async: false,
  650. literal: literal_,
  651. message: message$1,
  652. get "~standard"() {
  653. return /* @__PURE__ */ _getStandardProps(this);
  654. },
  655. "~run"(dataset, config$1) {
  656. if (dataset.value === this.literal) dataset.typed = true;
  657. else _addIssue(this, "type", dataset, config$1);
  658. return dataset;
  659. }
  660. };
  661. }
  662. /* @__NO_SIDE_EFFECTS__ */
  663. function never(message$1) {
  664. return {
  665. kind: "schema",
  666. type: "never",
  667. reference: never,
  668. expects: "never",
  669. async: false,
  670. message: message$1,
  671. get "~standard"() {
  672. return /* @__PURE__ */ _getStandardProps(this);
  673. },
  674. "~run"(dataset, config$1) {
  675. _addIssue(this, "type", dataset, config$1);
  676. return dataset;
  677. }
  678. };
  679. }
  680. /* @__NO_SIDE_EFFECTS__ */
  681. function nullish(wrapped, default_) {
  682. return {
  683. kind: "schema",
  684. type: "nullish",
  685. reference: nullish,
  686. expects: `(${wrapped.expects} | null | undefined)`,
  687. async: false,
  688. wrapped,
  689. default: default_,
  690. get "~standard"() {
  691. return /* @__PURE__ */ _getStandardProps(this);
  692. },
  693. "~run"(dataset, config$1) {
  694. if (dataset.value === null || dataset.value === void 0) {
  695. if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
  696. if (dataset.value === null || dataset.value === void 0) {
  697. dataset.typed = true;
  698. return dataset;
  699. }
  700. }
  701. return this.wrapped["~run"](dataset, config$1);
  702. }
  703. };
  704. }
  705. /* @__NO_SIDE_EFFECTS__ */
  706. function number(message$1) {
  707. return {
  708. kind: "schema",
  709. type: "number",
  710. reference: number,
  711. expects: "number",
  712. async: false,
  713. message: message$1,
  714. get "~standard"() {
  715. return /* @__PURE__ */ _getStandardProps(this);
  716. },
  717. "~run"(dataset, config$1) {
  718. if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
  719. else _addIssue(this, "type", dataset, config$1);
  720. return dataset;
  721. }
  722. };
  723. }
  724. /* @__NO_SIDE_EFFECTS__ */
  725. function object(entries$1, message$1) {
  726. return {
  727. kind: "schema",
  728. type: "object",
  729. reference: object,
  730. expects: "Object",
  731. async: false,
  732. entries: entries$1,
  733. message: message$1,
  734. get "~standard"() {
  735. return /* @__PURE__ */ _getStandardProps(this);
  736. },
  737. "~run"(dataset, config$1) {
  738. const input = dataset.value;
  739. if (input && typeof input === "object") {
  740. dataset.typed = true;
  741. dataset.value = {};
  742. for (const key in this.entries) {
  743. const valueSchema = this.entries[key];
  744. if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
  745. const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
  746. const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
  747. if (valueDataset.issues) {
  748. const pathItem = {
  749. type: "object",
  750. origin: "value",
  751. input,
  752. key,
  753. value: value$1
  754. };
  755. for (const issue of valueDataset.issues) {
  756. if (issue.path) issue.path.unshift(pathItem);
  757. else issue.path = [pathItem];
  758. dataset.issues?.push(issue);
  759. }
  760. if (!dataset.issues) dataset.issues = valueDataset.issues;
  761. if (config$1.abortEarly) {
  762. dataset.typed = false;
  763. break;
  764. }
  765. }
  766. if (!valueDataset.typed) dataset.typed = false;
  767. dataset.value[key] = valueDataset.value;
  768. } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
  769. else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
  770. _addIssue(this, "key", dataset, config$1, {
  771. input: void 0,
  772. expected: `"${key}"`,
  773. path: [{
  774. type: "object",
  775. origin: "key",
  776. input,
  777. key,
  778. value: input[key]
  779. }]
  780. });
  781. if (config$1.abortEarly) break;
  782. }
  783. }
  784. } else _addIssue(this, "type", dataset, config$1);
  785. return dataset;
  786. }
  787. };
  788. }
  789. /* @__NO_SIDE_EFFECTS__ */
  790. function optional(wrapped, default_) {
  791. return {
  792. kind: "schema",
  793. type: "optional",
  794. reference: optional,
  795. expects: `(${wrapped.expects} | undefined)`,
  796. async: false,
  797. wrapped,
  798. default: default_,
  799. get "~standard"() {
  800. return /* @__PURE__ */ _getStandardProps(this);
  801. },
  802. "~run"(dataset, config$1) {
  803. if (dataset.value === void 0) {
  804. if (this.default !== void 0) dataset.value = /* @__PURE__ */ getDefault(this, dataset, config$1);
  805. if (dataset.value === void 0) {
  806. dataset.typed = true;
  807. return dataset;
  808. }
  809. }
  810. return this.wrapped["~run"](dataset, config$1);
  811. }
  812. };
  813. }
  814. /* @__NO_SIDE_EFFECTS__ */
  815. function picklist(options, message$1) {
  816. return {
  817. kind: "schema",
  818. type: "picklist",
  819. reference: picklist,
  820. expects: /* @__PURE__ */ _joinExpects(options.map(_stringify), "|"),
  821. async: false,
  822. options,
  823. message: message$1,
  824. get "~standard"() {
  825. return /* @__PURE__ */ _getStandardProps(this);
  826. },
  827. "~run"(dataset, config$1) {
  828. if (this.options.includes(dataset.value)) dataset.typed = true;
  829. else _addIssue(this, "type", dataset, config$1);
  830. return dataset;
  831. }
  832. };
  833. }
  834. /* @__NO_SIDE_EFFECTS__ */
  835. function promise(message$1) {
  836. return {
  837. kind: "schema",
  838. type: "promise",
  839. reference: promise,
  840. expects: "Promise",
  841. async: false,
  842. message: message$1,
  843. get "~standard"() {
  844. return /* @__PURE__ */ _getStandardProps(this);
  845. },
  846. "~run"(dataset, config$1) {
  847. if (dataset.value instanceof Promise) dataset.typed = true;
  848. else _addIssue(this, "type", dataset, config$1);
  849. return dataset;
  850. }
  851. };
  852. }
  853. /* @__NO_SIDE_EFFECTS__ */
  854. function record(key, value$1, message$1) {
  855. return {
  856. kind: "schema",
  857. type: "record",
  858. reference: record,
  859. expects: "Object",
  860. async: false,
  861. key,
  862. value: value$1,
  863. message: message$1,
  864. get "~standard"() {
  865. return /* @__PURE__ */ _getStandardProps(this);
  866. },
  867. "~run"(dataset, config$1) {
  868. const input = dataset.value;
  869. if (input && typeof input === "object") {
  870. dataset.typed = true;
  871. dataset.value = {};
  872. for (const entryKey in input) if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
  873. const entryValue = input[entryKey];
  874. const keyDataset = this.key["~run"]({ value: entryKey }, config$1);
  875. if (keyDataset.issues) {
  876. const pathItem = {
  877. type: "object",
  878. origin: "key",
  879. input,
  880. key: entryKey,
  881. value: entryValue
  882. };
  883. for (const issue of keyDataset.issues) {
  884. issue.path = [pathItem];
  885. dataset.issues?.push(issue);
  886. }
  887. if (!dataset.issues) dataset.issues = keyDataset.issues;
  888. if (config$1.abortEarly) {
  889. dataset.typed = false;
  890. break;
  891. }
  892. }
  893. const valueDataset = this.value["~run"]({ value: entryValue }, config$1);
  894. if (valueDataset.issues) {
  895. const pathItem = {
  896. type: "object",
  897. origin: "value",
  898. input,
  899. key: entryKey,
  900. value: entryValue
  901. };
  902. for (const issue of valueDataset.issues) {
  903. if (issue.path) issue.path.unshift(pathItem);
  904. else issue.path = [pathItem];
  905. dataset.issues?.push(issue);
  906. }
  907. if (!dataset.issues) dataset.issues = valueDataset.issues;
  908. if (config$1.abortEarly) {
  909. dataset.typed = false;
  910. break;
  911. }
  912. }
  913. if (!keyDataset.typed || !valueDataset.typed) dataset.typed = false;
  914. if (keyDataset.typed) dataset.value[keyDataset.value] = valueDataset.value;
  915. }
  916. } else _addIssue(this, "type", dataset, config$1);
  917. return dataset;
  918. }
  919. };
  920. }
  921. /* @__NO_SIDE_EFFECTS__ */
  922. function strictObject(entries$1, message$1) {
  923. return {
  924. kind: "schema",
  925. type: "strict_object",
  926. reference: strictObject,
  927. expects: "Object",
  928. async: false,
  929. entries: entries$1,
  930. message: message$1,
  931. get "~standard"() {
  932. return /* @__PURE__ */ _getStandardProps(this);
  933. },
  934. "~run"(dataset, config$1) {
  935. const input = dataset.value;
  936. if (input && typeof input === "object") {
  937. dataset.typed = true;
  938. dataset.value = {};
  939. for (const key in this.entries) {
  940. const valueSchema = this.entries[key];
  941. if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && valueSchema.default !== void 0) {
  942. const value$1 = key in input ? input[key] : /* @__PURE__ */ getDefault(valueSchema);
  943. const valueDataset = valueSchema["~run"]({ value: value$1 }, config$1);
  944. if (valueDataset.issues) {
  945. const pathItem = {
  946. type: "object",
  947. origin: "value",
  948. input,
  949. key,
  950. value: value$1
  951. };
  952. for (const issue of valueDataset.issues) {
  953. if (issue.path) issue.path.unshift(pathItem);
  954. else issue.path = [pathItem];
  955. dataset.issues?.push(issue);
  956. }
  957. if (!dataset.issues) dataset.issues = valueDataset.issues;
  958. if (config$1.abortEarly) {
  959. dataset.typed = false;
  960. break;
  961. }
  962. }
  963. if (!valueDataset.typed) dataset.typed = false;
  964. dataset.value[key] = valueDataset.value;
  965. } else if (valueSchema.fallback !== void 0) dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
  966. else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
  967. _addIssue(this, "key", dataset, config$1, {
  968. input: void 0,
  969. expected: `"${key}"`,
  970. path: [{
  971. type: "object",
  972. origin: "key",
  973. input,
  974. key,
  975. value: input[key]
  976. }]
  977. });
  978. if (config$1.abortEarly) break;
  979. }
  980. }
  981. if (!dataset.issues || !config$1.abortEarly) {
  982. for (const key in input) if (!(key in this.entries)) {
  983. _addIssue(this, "key", dataset, config$1, {
  984. input: key,
  985. expected: "never",
  986. path: [{
  987. type: "object",
  988. origin: "key",
  989. input,
  990. key,
  991. value: input[key]
  992. }]
  993. });
  994. break;
  995. }
  996. }
  997. } else _addIssue(this, "type", dataset, config$1);
  998. return dataset;
  999. }
  1000. };
  1001. }
  1002. /* @__NO_SIDE_EFFECTS__ */
  1003. function string(message$1) {
  1004. return {
  1005. kind: "schema",
  1006. type: "string",
  1007. reference: string,
  1008. expects: "string",
  1009. async: false,
  1010. message: message$1,
  1011. get "~standard"() {
  1012. return /* @__PURE__ */ _getStandardProps(this);
  1013. },
  1014. "~run"(dataset, config$1) {
  1015. if (typeof dataset.value === "string") dataset.typed = true;
  1016. else _addIssue(this, "type", dataset, config$1);
  1017. return dataset;
  1018. }
  1019. };
  1020. }
  1021. /* @__NO_SIDE_EFFECTS__ */
  1022. function tuple(items, message$1) {
  1023. return {
  1024. kind: "schema",
  1025. type: "tuple",
  1026. reference: tuple,
  1027. expects: "Array",
  1028. async: false,
  1029. items,
  1030. message: message$1,
  1031. get "~standard"() {
  1032. return /* @__PURE__ */ _getStandardProps(this);
  1033. },
  1034. "~run"(dataset, config$1) {
  1035. const input = dataset.value;
  1036. if (Array.isArray(input)) {
  1037. dataset.typed = true;
  1038. dataset.value = [];
  1039. for (let key = 0; key < this.items.length; key++) {
  1040. const value$1 = input[key];
  1041. const itemDataset = this.items[key]["~run"]({ value: value$1 }, config$1);
  1042. if (itemDataset.issues) {
  1043. const pathItem = {
  1044. type: "array",
  1045. origin: "value",
  1046. input,
  1047. key,
  1048. value: value$1
  1049. };
  1050. for (const issue of itemDataset.issues) {
  1051. if (issue.path) issue.path.unshift(pathItem);
  1052. else issue.path = [pathItem];
  1053. dataset.issues?.push(issue);
  1054. }
  1055. if (!dataset.issues) dataset.issues = itemDataset.issues;
  1056. if (config$1.abortEarly) {
  1057. dataset.typed = false;
  1058. break;
  1059. }
  1060. }
  1061. if (!itemDataset.typed) dataset.typed = false;
  1062. dataset.value.push(itemDataset.value);
  1063. }
  1064. } else _addIssue(this, "type", dataset, config$1);
  1065. return dataset;
  1066. }
  1067. };
  1068. }
  1069. /* @__NO_SIDE_EFFECTS__ */
  1070. function undefined_(message$1) {
  1071. return {
  1072. kind: "schema",
  1073. type: "undefined",
  1074. reference: undefined_,
  1075. expects: "undefined",
  1076. async: false,
  1077. message: message$1,
  1078. get "~standard"() {
  1079. return /* @__PURE__ */ _getStandardProps(this);
  1080. },
  1081. "~run"(dataset, config$1) {
  1082. if (dataset.value === void 0) dataset.typed = true;
  1083. else _addIssue(this, "type", dataset, config$1);
  1084. return dataset;
  1085. }
  1086. };
  1087. }
  1088. /**
  1089. * Returns the sub issues of the provided datasets for the union issue.
  1090. *
  1091. * @param datasets The datasets.
  1092. *
  1093. * @returns The sub issues.
  1094. *
  1095. * @internal
  1096. */
  1097. /* @__NO_SIDE_EFFECTS__ */
  1098. function _subIssues(datasets) {
  1099. let issues;
  1100. if (datasets) for (const dataset of datasets) if (issues) for (const issue of dataset.issues) issues.push(issue);
  1101. else issues = dataset.issues;
  1102. return issues;
  1103. }
  1104. /* @__NO_SIDE_EFFECTS__ */
  1105. function union(options, message$1) {
  1106. return {
  1107. kind: "schema",
  1108. type: "union",
  1109. reference: union,
  1110. expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
  1111. async: false,
  1112. options,
  1113. message: message$1,
  1114. get "~standard"() {
  1115. return /* @__PURE__ */ _getStandardProps(this);
  1116. },
  1117. "~run"(dataset, config$1) {
  1118. let validDataset;
  1119. let typedDatasets;
  1120. let untypedDatasets;
  1121. for (const schema of this.options) {
  1122. const optionDataset = schema["~run"]({ value: dataset.value }, config$1);
  1123. if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
  1124. else typedDatasets = [optionDataset];
  1125. else {
  1126. validDataset = optionDataset;
  1127. break;
  1128. }
  1129. else if (untypedDatasets) untypedDatasets.push(optionDataset);
  1130. else untypedDatasets = [optionDataset];
  1131. }
  1132. if (validDataset) return validDataset;
  1133. if (typedDatasets) {
  1134. if (typedDatasets.length === 1) return typedDatasets[0];
  1135. _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
  1136. dataset.typed = true;
  1137. } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
  1138. else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
  1139. return dataset;
  1140. }
  1141. };
  1142. }
  1143. /* @__NO_SIDE_EFFECTS__ */
  1144. function unionAsync(options, message$1) {
  1145. return {
  1146. kind: "schema",
  1147. type: "union",
  1148. reference: unionAsync,
  1149. expects: /* @__PURE__ */ _joinExpects(options.map((option) => option.expects), "|"),
  1150. async: true,
  1151. options,
  1152. message: message$1,
  1153. get "~standard"() {
  1154. return /* @__PURE__ */ _getStandardProps(this);
  1155. },
  1156. async "~run"(dataset, config$1) {
  1157. let validDataset;
  1158. let typedDatasets;
  1159. let untypedDatasets;
  1160. for (const schema of this.options) {
  1161. const optionDataset = await schema["~run"]({ value: dataset.value }, config$1);
  1162. if (optionDataset.typed) if (optionDataset.issues) if (typedDatasets) typedDatasets.push(optionDataset);
  1163. else typedDatasets = [optionDataset];
  1164. else {
  1165. validDataset = optionDataset;
  1166. break;
  1167. }
  1168. else if (untypedDatasets) untypedDatasets.push(optionDataset);
  1169. else untypedDatasets = [optionDataset];
  1170. }
  1171. if (validDataset) return validDataset;
  1172. if (typedDatasets) {
  1173. if (typedDatasets.length === 1) return typedDatasets[0];
  1174. _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(typedDatasets) });
  1175. dataset.typed = true;
  1176. } else if (untypedDatasets?.length === 1) return untypedDatasets[0];
  1177. else _addIssue(this, "type", dataset, config$1, { issues: /* @__PURE__ */ _subIssues(untypedDatasets) });
  1178. return dataset;
  1179. }
  1180. };
  1181. }
  1182. /* @__NO_SIDE_EFFECTS__ */
  1183. function void_(message$1) {
  1184. return {
  1185. kind: "schema",
  1186. type: "void",
  1187. reference: void_,
  1188. expects: "void",
  1189. async: false,
  1190. message: message$1,
  1191. get "~standard"() {
  1192. return /* @__PURE__ */ _getStandardProps(this);
  1193. },
  1194. "~run"(dataset, config$1) {
  1195. if (dataset.value === void 0) dataset.typed = true;
  1196. else _addIssue(this, "type", dataset, config$1);
  1197. return dataset;
  1198. }
  1199. };
  1200. }
  1201. /* @__NO_SIDE_EFFECTS__ */
  1202. function keyof(schema, message$1) {
  1203. return /* @__PURE__ */ picklist(Object.keys(schema.entries), message$1);
  1204. }
  1205. /**
  1206. * Creates a modified copy of an object schema that does not contain the
  1207. * selected entries.
  1208. *
  1209. * @param schema The schema to omit from.
  1210. * @param keys The selected entries.
  1211. *
  1212. * @returns An object schema.
  1213. */
  1214. /* @__NO_SIDE_EFFECTS__ */
  1215. function omit(schema, keys) {
  1216. const entries$1 = { ...schema.entries };
  1217. for (const key of keys) delete entries$1[key];
  1218. return {
  1219. ...schema,
  1220. entries: entries$1,
  1221. get "~standard"() {
  1222. return /* @__PURE__ */ _getStandardProps(this);
  1223. }
  1224. };
  1225. }
  1226. /* @__NO_SIDE_EFFECTS__ */
  1227. function partial(schema, keys) {
  1228. const entries$1 = {};
  1229. for (const key in schema.entries) entries$1[key] = !keys || keys.includes(key) ? /* @__PURE__ */ optional(schema.entries[key]) : schema.entries[key];
  1230. return {
  1231. ...schema,
  1232. entries: entries$1,
  1233. get "~standard"() {
  1234. return /* @__PURE__ */ _getStandardProps(this);
  1235. }
  1236. };
  1237. }
  1238. /* @__NO_SIDE_EFFECTS__ */
  1239. function pipe(...pipe$1) {
  1240. return {
  1241. ...pipe$1[0],
  1242. pipe: pipe$1,
  1243. get "~standard"() {
  1244. return /* @__PURE__ */ _getStandardProps(this);
  1245. },
  1246. "~run"(dataset, config$1) {
  1247. for (const item of pipe$1) if (item.kind !== "metadata") {
  1248. if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
  1249. dataset.typed = false;
  1250. break;
  1251. }
  1252. if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = item["~run"](dataset, config$1);
  1253. }
  1254. return dataset;
  1255. }
  1256. };
  1257. }
  1258. /* @__NO_SIDE_EFFECTS__ */
  1259. function pipeAsync(...pipe$1) {
  1260. return {
  1261. ...pipe$1[0],
  1262. pipe: pipe$1,
  1263. async: true,
  1264. get "~standard"() {
  1265. return /* @__PURE__ */ _getStandardProps(this);
  1266. },
  1267. async "~run"(dataset, config$1) {
  1268. for (const item of pipe$1) if (item.kind !== "metadata") {
  1269. if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
  1270. dataset.typed = false;
  1271. break;
  1272. }
  1273. if (!dataset.issues || !config$1.abortEarly && !config$1.abortPipeEarly) dataset = await item["~run"](dataset, config$1);
  1274. }
  1275. return dataset;
  1276. }
  1277. };
  1278. }
  1279. /**
  1280. * Parses an unknown input based on a schema.
  1281. *
  1282. * @param schema The schema to be used.
  1283. * @param input The input to be parsed.
  1284. * @param config The parse configuration.
  1285. *
  1286. * @returns The parse result.
  1287. */
  1288. /* @__NO_SIDE_EFFECTS__ */
  1289. function safeParse(schema, input, config$1) {
  1290. const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig(config$1));
  1291. return {
  1292. typed: dataset.typed,
  1293. success: !dataset.issues,
  1294. output: dataset.value,
  1295. issues: dataset.issues
  1296. };
  1297. }
  1298. //#endregion
  1299. //#region src/utils/flatten-valibot-schema.ts
  1300. function unwrapSchema(schema) {
  1301. if (!schema) return schema;
  1302. if (schema.type === "optional" && schema.wrapped) return unwrapSchema(schema.wrapped);
  1303. if (schema.type === "nullable" && schema.wrapped) return unwrapSchema(schema.wrapped);
  1304. if (schema.type === "nullish" && schema.wrapped) return unwrapSchema(schema.wrapped);
  1305. return schema;
  1306. }
  1307. function getValibotSchemaType(schema) {
  1308. if (!schema) return "any";
  1309. if (schema.type) switch (schema.type) {
  1310. case "string": return "string";
  1311. case "number": return "number";
  1312. case "boolean": return "boolean";
  1313. case "array": return "array";
  1314. case "object":
  1315. case "strict_object":
  1316. case "loose_object": return "object";
  1317. case "union": return "union";
  1318. case "literal": return typeof schema.literal;
  1319. case "record": return "object";
  1320. case "optional": return getValibotSchemaType(schema.wrapped);
  1321. case "nullable": return getValibotSchemaType(schema.wrapped);
  1322. case "nullish": return getValibotSchemaType(schema.wrapped);
  1323. case "never": return "never";
  1324. case "any": return "any";
  1325. case "custom": return "any";
  1326. case "function": return "never";
  1327. case "instance": return "object";
  1328. default: return "any";
  1329. }
  1330. return "any";
  1331. }
  1332. function getValibotDescription(schema) {
  1333. if (!schema) return void 0;
  1334. if (schema.pipe && Array.isArray(schema.pipe)) {
  1335. for (const action of schema.pipe) if (action.type === "description" && action.description) return action.description;
  1336. }
  1337. if (schema.type === "optional" && schema.wrapped) return getValibotDescription(schema.wrapped);
  1338. }
  1339. function flattenValibotSchema(schema, result = {}, prefix = "") {
  1340. if (!schema || typeof schema !== "object") return result;
  1341. if (schema.type === "strict_object" || schema.type === "object" || schema.type === "loose_object") {
  1342. if (schema.entries && typeof schema.entries === "object") for (const [key, value] of Object.entries(schema.entries)) {
  1343. const fullKey = prefix ? `${prefix}.${key}` : key;
  1344. const valueSchema = value;
  1345. const type = getValibotSchemaType(valueSchema);
  1346. const description = getValibotDescription(valueSchema);
  1347. if (type === "object") {
  1348. const unwrappedSchema = unwrapSchema(valueSchema);
  1349. if (unwrappedSchema && unwrappedSchema.entries) flattenValibotSchema(unwrappedSchema, result, fullKey);
  1350. else result[fullKey] = {
  1351. type,
  1352. description
  1353. };
  1354. } else result[fullKey] = {
  1355. type,
  1356. description
  1357. };
  1358. }
  1359. }
  1360. return result;
  1361. }
  1362. //#endregion
  1363. //#region src/utils/style-text.ts
  1364. /**
  1365. * Cross-platform styleText utility that works in both Node.js and browser environments
  1366. * In Node.js, it uses the native `styleText` from `node:util`
  1367. * In browser, it provides empty styling functions for compatibility
  1368. */
  1369. function styleText$1(...args) {
  1370. return styleText(...args);
  1371. }
  1372. //#endregion
  1373. //#region src/utils/validator.ts
  1374. const StringOrRegExpSchema = /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ instance(RegExp)]);
  1375. function vFunction() {
  1376. return /* @__PURE__ */ function_();
  1377. }
  1378. const LogLevelSchema = /* @__PURE__ */ union([
  1379. /* @__PURE__ */ literal("debug"),
  1380. /* @__PURE__ */ literal("info"),
  1381. /* @__PURE__ */ literal("warn")
  1382. ]);
  1383. const LogLevelOptionSchema = /* @__PURE__ */ union([LogLevelSchema, /* @__PURE__ */ literal("silent")]);
  1384. const LogLevelWithErrorSchema = /* @__PURE__ */ union([LogLevelSchema, /* @__PURE__ */ literal("error")]);
  1385. const RollupLogSchema = /* @__PURE__ */ any();
  1386. const RollupLogWithStringSchema = /* @__PURE__ */ union([RollupLogSchema, /* @__PURE__ */ string()]);
  1387. const InputOptionSchema = /* @__PURE__ */ union([
  1388. /* @__PURE__ */ string(),
  1389. /* @__PURE__ */ array(/* @__PURE__ */ string()),
  1390. /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string())
  1391. ]);
  1392. const ExternalOptionFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([
  1393. /* @__PURE__ */ string(),
  1394. /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1395. /* @__PURE__ */ boolean()
  1396. ])), /* @__PURE__ */ returns(/* @__PURE__ */ nullish(/* @__PURE__ */ boolean())));
  1397. const ExternalOptionSchema = /* @__PURE__ */ union([
  1398. StringOrRegExpSchema,
  1399. /* @__PURE__ */ array(StringOrRegExpSchema),
  1400. ExternalOptionFunctionSchema
  1401. ]);
  1402. const ModuleTypesSchema = /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([
  1403. /* @__PURE__ */ literal("asset"),
  1404. /* @__PURE__ */ literal("base64"),
  1405. /* @__PURE__ */ literal("binary"),
  1406. /* @__PURE__ */ literal("copy"),
  1407. /* @__PURE__ */ literal("css"),
  1408. /* @__PURE__ */ literal("dataurl"),
  1409. /* @__PURE__ */ literal("empty"),
  1410. /* @__PURE__ */ literal("js"),
  1411. /* @__PURE__ */ literal("json"),
  1412. /* @__PURE__ */ literal("jsx"),
  1413. /* @__PURE__ */ literal("text"),
  1414. /* @__PURE__ */ literal("ts"),
  1415. /* @__PURE__ */ literal("tsx")
  1416. ]));
  1417. const TransformOptionsSchema = /* @__PURE__ */ object({
  1418. assumptions: /* @__PURE__ */ optional(/* @__PURE__ */ object({
  1419. ignoreFunctionLength: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1420. noDocumentAll: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1421. objectRestNoSymbols: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1422. pureGetters: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1423. setPublicClassFields: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1424. })),
  1425. typescript: /* @__PURE__ */ optional(/* @__PURE__ */ object({
  1426. jsxPragma: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1427. jsxPragmaFrag: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1428. onlyRemoveTypeImports: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1429. allowNamespaces: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1430. allowDeclareFields: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1431. removeClassFieldsWithoutInitializer: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1432. optimizeConstEnums: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1433. optimizeEnums: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1434. declaration: /* @__PURE__ */ optional(/* @__PURE__ */ object({
  1435. stripInternal: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1436. sourcemap: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1437. })),
  1438. rewriteImportExtensions: /* @__PURE__ */ optional(/* @__PURE__ */ union([
  1439. /* @__PURE__ */ literal("rewrite"),
  1440. /* @__PURE__ */ literal("remove"),
  1441. /* @__PURE__ */ boolean()
  1442. ]))
  1443. })),
  1444. helpers: /* @__PURE__ */ optional(/* @__PURE__ */ object({ mode: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("Runtime"), /* @__PURE__ */ literal("External")])) })),
  1445. decorator: /* @__PURE__ */ optional(/* @__PURE__ */ object({
  1446. legacy: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1447. emitDecoratorMetadata: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1448. strictNullChecks: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1449. })),
  1450. jsx: /* @__PURE__ */ optional(/* @__PURE__ */ union([
  1451. /* @__PURE__ */ literal(false),
  1452. /* @__PURE__ */ literal("preserve"),
  1453. /* @__PURE__ */ literal("react"),
  1454. /* @__PURE__ */ literal("react-jsx"),
  1455. /* @__PURE__ */ strictObject({
  1456. runtime: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("classic"), /* @__PURE__ */ literal("automatic")])), /* @__PURE__ */ description("Which runtime to use")),
  1457. development: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Development specific information")),
  1458. throwIfNamespace: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Toggles whether to throw an error when a tag name uses an XML namespace")),
  1459. pure: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Mark JSX elements and top-level React method calls as pure for tree shaking.")),
  1460. importSource: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Import the factory of element and fragment if mode is classic")),
  1461. pragma: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Jsx element transformation")),
  1462. pragmaFrag: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Jsx fragment transformation")),
  1463. refresh: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ any()])), /* @__PURE__ */ description("Enable react fast refresh"))
  1464. })
  1465. ])),
  1466. target: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ array(/* @__PURE__ */ string())])), /* @__PURE__ */ description("The JavaScript target environment")),
  1467. define: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string())), /* @__PURE__ */ description("Define global variables (syntax: key:value,key2:value2)")),
  1468. inject: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ tuple([/* @__PURE__ */ string(), /* @__PURE__ */ string()])]))), /* @__PURE__ */ description("Inject import statements on demand")),
  1469. dropLabels: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())), /* @__PURE__ */ description("Remove labeled statements with these label names")),
  1470. plugins: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ object({
  1471. styledComponents: /* @__PURE__ */ optional(/* @__PURE__ */ any()),
  1472. taggedTemplateEscape: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1473. })), /* @__PURE__ */ description("Third-party plugins to use"))
  1474. });
  1475. const WatcherFileWatcherOptionsSchema = /* @__PURE__ */ strictObject({
  1476. usePolling: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Use polling-based file watching instead of native OS events")),
  1477. pollInterval: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Poll interval in milliseconds (only used when usePolling is true)")),
  1478. compareContentsForPolling: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Compare file contents for poll-based watchers (only used when usePolling is true)")),
  1479. useDebounce: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Use debounced event delivery at the filesystem level")),
  1480. debounceDelay: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Debounce delay in milliseconds (only used when useDebounce is true)")),
  1481. debounceTickRate: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Tick rate in milliseconds for debouncer (only used when useDebounce is true)"))
  1482. });
  1483. const WatcherOptionsSchema = /* @__PURE__ */ strictObject({
  1484. chokidar: /* @__PURE__ */ optional(/* @__PURE__ */ never(`The "watch.chokidar" option is deprecated, please use "watch.watcher" instead of it`)),
  1485. exclude: /* @__PURE__ */ optional(/* @__PURE__ */ union([StringOrRegExpSchema, /* @__PURE__ */ array(StringOrRegExpSchema)])),
  1486. include: /* @__PURE__ */ optional(/* @__PURE__ */ union([StringOrRegExpSchema, /* @__PURE__ */ array(StringOrRegExpSchema)])),
  1487. watcher: /* @__PURE__ */ optional(WatcherFileWatcherOptionsSchema),
  1488. notify: /* @__PURE__ */ optional(WatcherFileWatcherOptionsSchema),
  1489. skipWrite: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Skip the bundle.write() step")),
  1490. buildDelay: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Throttle watch rebuilds")),
  1491. clearScreen: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to clear the screen when a rebuild is triggered")),
  1492. onInvalidate: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(vFunction()), /* @__PURE__ */ description("An optional function that will be called immediately every time a module changes that is part of the build."))
  1493. });
  1494. const ChecksOptionsSchema = /* @__PURE__ */ strictObject({
  1495. circularDependency: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when detecting circular dependency")),
  1496. eval: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when detecting uses of direct `eval`s")),
  1497. missingGlobalName: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when the `output.globals` option is missing when needed")),
  1498. missingNameOptionForIifeExport: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when the `output.name` option is missing when needed")),
  1499. invalidAnnotation: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a `#__PURE__` / `@__PURE__` annotation has no effect due to its position")),
  1500. mixedExports: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when the way to export values is ambiguous")),
  1501. unresolvedEntry: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when an entrypoint cannot be resolved")),
  1502. unresolvedImport: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when an import cannot be resolved")),
  1503. filenameConflict: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when files generated have the same name with different contents")),
  1504. commonJsVariableInEsm: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a CommonJS variable is used in an ES module")),
  1505. importIsUndefined: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when an imported variable is not exported")),
  1506. emptyImportMeta: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when `import.meta` is not supported with the output format and is replaced with an empty object (`{}`)")),
  1507. toleratedTransform: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when detecting tolerated transform")),
  1508. cannotCallNamespace: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a namespace is called as a function")),
  1509. configurationFieldConflict: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a config value is overridden by another config value with a higher priority")),
  1510. preferBuiltinFeature: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a plugin that is covered by a built-in feature is used")),
  1511. couldNotCleanDirectory: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when Rolldown could not clean the output directory")),
  1512. pluginTimings: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when plugins take significant time during the build process")),
  1513. duplicateShebang: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when both the code and postBanner contain shebang")),
  1514. unsupportedTsconfigOption: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a tsconfig option or combination of options is not supported")),
  1515. ineffectiveDynamicImport: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit warnings when a module is dynamically imported but also statically imported, making the dynamic import ineffective for code splitting")),
  1516. largeBarrelModules: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to emit info logs when a barrel module has a very large number of re-exports (more than 5000)"))
  1517. });
  1518. const MinifyOptionsSchema = /* @__PURE__ */ strictObject({
  1519. compress: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1520. target: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ array(/* @__PURE__ */ string())])),
  1521. dropConsole: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1522. dropDebugger: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1523. keepNames: /* @__PURE__ */ optional(/* @__PURE__ */ strictObject({
  1524. function: /* @__PURE__ */ boolean(),
  1525. class: /* @__PURE__ */ boolean()
  1526. })),
  1527. unused: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ literal("keep_assign")])),
  1528. joinVars: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1529. sequences: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1530. dropLabels: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1531. maxIterations: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1532. treeshake: /* @__PURE__ */ optional(/* @__PURE__ */ strictObject({
  1533. annotations: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1534. manualPureFunctions: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1535. propertyReadSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ literal("always")])),
  1536. propertyWriteSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1537. unknownGlobalSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1538. invalidImportSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1539. }))
  1540. })])),
  1541. mangle: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1542. toplevel: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1543. keepNames: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1544. function: /* @__PURE__ */ boolean(),
  1545. class: /* @__PURE__ */ boolean()
  1546. })])),
  1547. debug: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1548. })])),
  1549. codegen: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1550. removeWhitespace: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1551. legalComments: /* @__PURE__ */ optional(/* @__PURE__ */ union([
  1552. /* @__PURE__ */ literal("none"),
  1553. /* @__PURE__ */ literal("inline"),
  1554. /* @__PURE__ */ literal("eof"),
  1555. /* @__PURE__ */ literal("external"),
  1556. /* @__PURE__ */ strictObject({ linked: /* @__PURE__ */ string() })
  1557. ]))
  1558. })]))
  1559. });
  1560. const ResolveOptionsSchema = /* @__PURE__ */ strictObject({
  1561. alias: /* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([
  1562. /* @__PURE__ */ literal(false),
  1563. /* @__PURE__ */ string(),
  1564. /* @__PURE__ */ array(/* @__PURE__ */ string())
  1565. ]))),
  1566. aliasFields: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ array(/* @__PURE__ */ string()))),
  1567. conditionNames: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1568. extensionAlias: /* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ array(/* @__PURE__ */ string()))),
  1569. exportsFields: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ array(/* @__PURE__ */ string()))),
  1570. extensions: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1571. mainFields: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1572. mainFiles: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1573. modules: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())),
  1574. symlinks: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1575. tsconfigFilename: /* @__PURE__ */ optional(/* @__PURE__ */ string())
  1576. });
  1577. const TreeshakingOptionsSchema = /* @__PURE__ */ strictObject({
  1578. moduleSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ any()),
  1579. annotations: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1580. manualPureFunctions: /* @__PURE__ */ optional(/* @__PURE__ */ custom((input) => /* @__PURE__ */ is(/* @__PURE__ */ array(/* @__PURE__ */ string()), input), "string array")),
  1581. unknownGlobalSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1582. invalidImportSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1583. commonjs: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1584. propertyReadSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal(false), /* @__PURE__ */ literal("always")])),
  1585. propertyWriteSideEffects: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal(false), /* @__PURE__ */ literal("always")]))
  1586. });
  1587. const OptimizationOptionsSchema = /* @__PURE__ */ strictObject({
  1588. inlineConst: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1589. mode: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("all"), /* @__PURE__ */ literal("smart")])),
  1590. pass: /* @__PURE__ */ optional(/* @__PURE__ */ number())
  1591. })])), /* @__PURE__ */ description("Enable crossmodule constant inlining")),
  1592. pifeForModuleWrappers: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Use PIFE pattern for module wrappers"))
  1593. });
  1594. const LogOrStringHandlerSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema])));
  1595. const OnLogSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([
  1596. LogLevelSchema,
  1597. RollupLogSchema,
  1598. LogOrStringHandlerSchema
  1599. ])));
  1600. const OnwarnSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([RollupLogSchema, /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ union([RollupLogWithStringSchema, /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ returns(RollupLogWithStringSchema))])])))])));
  1601. const DevModeSchema = /* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1602. port: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1603. host: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1604. implement: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1605. lazy: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1606. })]);
  1607. const InputOptionsSchema = /* @__PURE__ */ strictObject({
  1608. input: /* @__PURE__ */ optional(InputOptionSchema),
  1609. plugins: /* @__PURE__ */ optional(/* @__PURE__ */ custom(() => true)),
  1610. external: /* @__PURE__ */ optional(ExternalOptionSchema),
  1611. makeAbsoluteExternalsRelative: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ literal("ifRelativeSource")])),
  1612. resolve: /* @__PURE__ */ optional(ResolveOptionsSchema),
  1613. cwd: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Current working directory")),
  1614. platform: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1615. /* @__PURE__ */ literal("browser"),
  1616. /* @__PURE__ */ literal("neutral"),
  1617. /* @__PURE__ */ literal("node")
  1618. ])), /* @__PURE__ */ description(`Platform for which the code should be generated (node, ${styleText$1("underline", "browser")}, neutral)`)),
  1619. shimMissingExports: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Create shim variables for missing exports")),
  1620. treeshake: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), TreeshakingOptionsSchema])),
  1621. optimization: /* @__PURE__ */ optional(OptimizationOptionsSchema),
  1622. logLevel: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(LogLevelOptionSchema), /* @__PURE__ */ description(`Log level (${styleText$1("dim", "silent")}, ${styleText$1(["underline", "gray"], "info")}, debug, ${styleText$1("yellow", "warn")})`)),
  1623. onLog: /* @__PURE__ */ optional(OnLogSchema),
  1624. onwarn: /* @__PURE__ */ optional(OnwarnSchema),
  1625. moduleTypes: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(ModuleTypesSchema), /* @__PURE__ */ description("Module types for customized extensions")),
  1626. experimental: /* @__PURE__ */ optional(/* @__PURE__ */ strictObject({
  1627. viteMode: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1628. resolveNewUrlToAsset: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1629. devMode: /* @__PURE__ */ optional(DevModeSchema),
  1630. chunkModulesOrder: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("module-id"), /* @__PURE__ */ literal("exec-order")])),
  1631. attachDebugInfo: /* @__PURE__ */ optional(/* @__PURE__ */ union([
  1632. /* @__PURE__ */ literal("none"),
  1633. /* @__PURE__ */ literal("simple"),
  1634. /* @__PURE__ */ literal("full")
  1635. ])),
  1636. chunkImportMap: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ object({
  1637. baseUrl: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1638. fileName: /* @__PURE__ */ optional(/* @__PURE__ */ string())
  1639. })])),
  1640. onDemandWrapping: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1641. incrementalBuild: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1642. nativeMagicString: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1643. chunkOptimization: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1644. mergeCommonChunks: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1645. avoidRedundantChunkLoads: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1646. })])),
  1647. lazyBarrel: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1648. })),
  1649. transform: /* @__PURE__ */ optional(TransformOptionsSchema),
  1650. watch: /* @__PURE__ */ optional(/* @__PURE__ */ union([WatcherOptionsSchema, /* @__PURE__ */ literal(false)])),
  1651. checks: /* @__PURE__ */ optional(ChecksOptionsSchema),
  1652. devtools: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ object({ sessionId: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Used to name the build.")) })), /* @__PURE__ */ description("Enable debug mode. Emit debug information to disk. This might slow down the build process significantly.")),
  1653. preserveEntrySignatures: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1654. /* @__PURE__ */ literal("strict"),
  1655. /* @__PURE__ */ literal("allow-extension"),
  1656. /* @__PURE__ */ literal("exports-only"),
  1657. /* @__PURE__ */ literal(false)
  1658. ]))),
  1659. context: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("The value of `this` at the top level of each module.")),
  1660. tsconfig: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ string()])), /* @__PURE__ */ description("Path to the tsconfig.json file."))
  1661. });
  1662. const InputCliOverrideSchema = /* @__PURE__ */ strictObject({
  1663. input: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())), /* @__PURE__ */ description("Entry file")),
  1664. external: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string())), /* @__PURE__ */ description("Comma-separated list of module ids to exclude from the bundle `<module-id>,...`")),
  1665. treeshake: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("enable treeshaking")),
  1666. makeAbsoluteExternalsRelative: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Prevent normalization of external imports")),
  1667. preserveEntrySignatures: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ literal(false)), /* @__PURE__ */ description("Avoid facade chunks for entry points")),
  1668. context: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("The entity top-level `this` represents."))
  1669. });
  1670. const InputCliOptionsSchema = /* @__PURE__ */ omit(/* @__PURE__ */ strictObject({
  1671. ...InputOptionsSchema.entries,
  1672. ...InputCliOverrideSchema.entries
  1673. }), [
  1674. "plugins",
  1675. "onwarn",
  1676. "onLog",
  1677. "resolve",
  1678. "experimental",
  1679. "watch"
  1680. ]);
  1681. const ModuleFormatSchema = /* @__PURE__ */ union([
  1682. /* @__PURE__ */ literal("es"),
  1683. /* @__PURE__ */ literal("cjs"),
  1684. /* @__PURE__ */ literal("esm"),
  1685. /* @__PURE__ */ literal("module"),
  1686. /* @__PURE__ */ literal("commonjs"),
  1687. /* @__PURE__ */ literal("iife"),
  1688. /* @__PURE__ */ literal("umd")
  1689. ]);
  1690. const AddonFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ custom(() => true)])), /* @__PURE__ */ returnsAsync(/* @__PURE__ */ unionAsync([/* @__PURE__ */ string(), /* @__PURE__ */ pipeAsync(/* @__PURE__ */ promise(), /* @__PURE__ */ awaitAsync(), /* @__PURE__ */ string())])));
  1691. const ChunkFileNamesFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ custom(() => true)])), /* @__PURE__ */ returns(/* @__PURE__ */ string()));
  1692. const ChunkFileNamesSchema = /* @__PURE__ */ union([/* @__PURE__ */ string(), ChunkFileNamesFunctionSchema]);
  1693. const AssetFileNamesFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ custom(() => true)])), /* @__PURE__ */ returns(/* @__PURE__ */ string()));
  1694. const AssetFileNamesSchema = /* @__PURE__ */ union([/* @__PURE__ */ string(), AssetFileNamesFunctionSchema]);
  1695. const SanitizeFileNameFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string()])), /* @__PURE__ */ returns(/* @__PURE__ */ string()));
  1696. const SanitizeFileNameSchema = /* @__PURE__ */ union([/* @__PURE__ */ boolean(), SanitizeFileNameFunctionSchema]);
  1697. const GlobalsFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string()])), /* @__PURE__ */ returns(/* @__PURE__ */ string()));
  1698. const PathsFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string()])), /* @__PURE__ */ returns(/* @__PURE__ */ string()));
  1699. const ManualChunksFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string(), /* @__PURE__ */ object({})])), /* @__PURE__ */ returns(/* @__PURE__ */ nullish(/* @__PURE__ */ string())));
  1700. const AdvancedChunksNameFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string(), /* @__PURE__ */ object({})])), /* @__PURE__ */ returns(/* @__PURE__ */ nullish(/* @__PURE__ */ string())));
  1701. const AdvancedChunksTestFunctionSchema = /* @__PURE__ */ pipe(vFunction(), /* @__PURE__ */ args(/* @__PURE__ */ tuple([/* @__PURE__ */ string()])), /* @__PURE__ */ returns(/* @__PURE__ */ union([
  1702. /* @__PURE__ */ boolean(),
  1703. /* @__PURE__ */ void_(),
  1704. /* @__PURE__ */ undefined_()
  1705. ])));
  1706. const AdvancedChunksSchema = /* @__PURE__ */ strictObject({
  1707. includeDependenciesRecursively: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1708. minSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1709. maxSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1710. minModuleSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1711. maxModuleSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1712. minShareCount: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1713. groups: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ strictObject({
  1714. name: /* @__PURE__ */ union([/* @__PURE__ */ string(), AdvancedChunksNameFunctionSchema]),
  1715. test: /* @__PURE__ */ optional(/* @__PURE__ */ union([StringOrRegExpSchema, AdvancedChunksTestFunctionSchema])),
  1716. priority: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1717. minSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1718. minShareCount: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1719. maxSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1720. minModuleSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1721. maxModuleSize: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1722. entriesAware: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1723. entriesAwareMergeThreshold: /* @__PURE__ */ optional(/* @__PURE__ */ number()),
  1724. tags: /* @__PURE__ */ optional(/* @__PURE__ */ array(/* @__PURE__ */ string()))
  1725. })))
  1726. });
  1727. const GeneratedCodeOptionsSchema = /* @__PURE__ */ strictObject({
  1728. symbols: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to use Symbol.toStringTag for namespace objects")),
  1729. preset: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("es5"), /* @__PURE__ */ literal("es2015")])),
  1730. profilerNames: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Whether to add readable names to internal variables for profiling purposes"))
  1731. });
  1732. const OutputOptionsSchema = /* @__PURE__ */ strictObject({
  1733. dir: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Output directory, defaults to `dist` if `file` is not set")),
  1734. file: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Single output file")),
  1735. exports: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1736. /* @__PURE__ */ literal("auto"),
  1737. /* @__PURE__ */ literal("named"),
  1738. /* @__PURE__ */ literal("default"),
  1739. /* @__PURE__ */ literal("none")
  1740. ])), /* @__PURE__ */ description(`Specify a export mode (${styleText$1("underline", "auto")}, named, default, none)`)),
  1741. hashCharacters: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1742. /* @__PURE__ */ literal("base64"),
  1743. /* @__PURE__ */ literal("base36"),
  1744. /* @__PURE__ */ literal("hex")
  1745. ])), /* @__PURE__ */ description("Use the specified character set for file hashes")),
  1746. format: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(ModuleFormatSchema), /* @__PURE__ */ description(`Output format of the generated bundle (supports ${styleText$1("underline", "esm")}, cjs, and iife)`)),
  1747. sourcemap: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1748. /* @__PURE__ */ boolean(),
  1749. /* @__PURE__ */ literal("inline"),
  1750. /* @__PURE__ */ literal("hidden")
  1751. ])), /* @__PURE__ */ description(`Generate sourcemap (\`-s inline\` for inline, or \`-s\` for \`.map\` file)`)),
  1752. sourcemapBaseUrl: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Base URL used to prefix sourcemap paths")),
  1753. sourcemapDebugIds: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Inject sourcemap debug IDs")),
  1754. sourcemapExcludeSources: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Exclude source content from sourcemaps")),
  1755. sourcemapIgnoreList: /* @__PURE__ */ optional(/* @__PURE__ */ union([
  1756. /* @__PURE__ */ boolean(),
  1757. /* @__PURE__ */ custom(() => true),
  1758. StringOrRegExpSchema
  1759. ])),
  1760. sourcemapPathTransform: /* @__PURE__ */ optional(/* @__PURE__ */ custom(() => true)),
  1761. banner: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1762. footer: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1763. postBanner: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1764. postFooter: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1765. intro: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1766. outro: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), AddonFunctionSchema])),
  1767. extend: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Extend global variable defined by name in IIFE / UMD formats")),
  1768. esModule: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ literal("if-default-prop")])),
  1769. assetFileNames: /* @__PURE__ */ optional(AssetFileNamesSchema),
  1770. entryFileNames: /* @__PURE__ */ optional(ChunkFileNamesSchema),
  1771. chunkFileNames: /* @__PURE__ */ optional(ChunkFileNamesSchema),
  1772. sanitizeFileName: /* @__PURE__ */ optional(SanitizeFileNameSchema),
  1773. minify: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([
  1774. /* @__PURE__ */ boolean(),
  1775. /* @__PURE__ */ literal("dce-only"),
  1776. MinifyOptionsSchema
  1777. ])), /* @__PURE__ */ description("Minify the bundled file")),
  1778. name: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Name for UMD / IIFE format outputs")),
  1779. globals: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string()), GlobalsFunctionSchema])), /* @__PURE__ */ description("Global variable of UMD / IIFE dependencies (syntax: `key:value`)")),
  1780. paths: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string()), PathsFunctionSchema])), /* @__PURE__ */ description("Maps external module IDs to paths")),
  1781. generatedCode: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ partial(GeneratedCodeOptionsSchema)), /* @__PURE__ */ description("Generated code options")),
  1782. externalLiveBindings: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("external live bindings")),
  1783. inlineDynamicImports: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Inline dynamic imports")),
  1784. dynamicImportInCjs: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Dynamic import in CJS output")),
  1785. manualChunks: /* @__PURE__ */ optional(ManualChunksFunctionSchema),
  1786. codeSplitting: /* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), AdvancedChunksSchema])),
  1787. advancedChunks: /* @__PURE__ */ optional(AdvancedChunksSchema),
  1788. legalComments: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ literal("none"), /* @__PURE__ */ literal("inline")])), /* @__PURE__ */ description("Control legal comments in the output")),
  1789. comments: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1790. legal: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1791. annotation: /* @__PURE__ */ optional(/* @__PURE__ */ boolean()),
  1792. jsdoc: /* @__PURE__ */ optional(/* @__PURE__ */ boolean())
  1793. })])), /* @__PURE__ */ description("Control comments in the output")),
  1794. plugins: /* @__PURE__ */ optional(/* @__PURE__ */ custom(() => true)),
  1795. polyfillRequire: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Disable require polyfill injection")),
  1796. hoistTransitiveImports: /* @__PURE__ */ optional(/* @__PURE__ */ literal(false)),
  1797. preserveModules: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Preserve module structure")),
  1798. preserveModulesRoot: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Put preserved modules under this path at root level")),
  1799. virtualDirname: /* @__PURE__ */ optional(/* @__PURE__ */ string()),
  1800. minifyInternalExports: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Minify internal exports")),
  1801. topLevelVar: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Rewrite top-level declarations to use `var`.")),
  1802. cleanDir: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Clean output directory before emitting output")),
  1803. keepNames: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Keep function and class names after bundling")),
  1804. strictExecutionOrder: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Lets modules be executed in the order they are declared.")),
  1805. strict: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ literal("auto")])), /* @__PURE__ */ description("Whether to always output `\"use strict\"` directive in non-ES module outputs."))
  1806. });
  1807. const getAddonDescription = (placement, wrapper) => {
  1808. return `Code to insert the ${styleText$1("bold", placement)} of the bundled file (${styleText$1("bold", wrapper)} the wrapper function)`;
  1809. };
  1810. const OutputCliOverrideSchema = /* @__PURE__ */ strictObject({
  1811. assetFileNames: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Name pattern for asset files")),
  1812. entryFileNames: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Name pattern for emitted entry chunks")),
  1813. chunkFileNames: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("Name pattern for emitted secondary chunks")),
  1814. sanitizeFileName: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Sanitize file name")),
  1815. banner: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description(getAddonDescription("top", "outside"))),
  1816. footer: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description(getAddonDescription("bottom", "outside"))),
  1817. postBanner: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("A string to prepend to the top of each chunk. Applied after the `renderChunk` hook and minification")),
  1818. postFooter: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description("A string to append to the bottom of each chunk. Applied after the `renderChunk` hook and minification")),
  1819. intro: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description(getAddonDescription("top", "inside"))),
  1820. outro: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ string()), /* @__PURE__ */ description(getAddonDescription("bottom", "inside"))),
  1821. esModule: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)")),
  1822. globals: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ string())), /* @__PURE__ */ description("Global variable of UMD / IIFE dependencies (syntax: `key:value`)")),
  1823. codeSplitting: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ boolean(), /* @__PURE__ */ strictObject({
  1824. minSize: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Minimum size of the chunk")),
  1825. minShareCount: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Minimum share count of the chunk"))
  1826. })])), /* @__PURE__ */ description("Code splitting options (true, false, or object)")),
  1827. advancedChunks: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ strictObject({
  1828. minSize: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Minimum size of the chunk")),
  1829. minShareCount: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ number()), /* @__PURE__ */ description("Minimum share count of the chunk"))
  1830. })), /* @__PURE__ */ description("Deprecated: use codeSplitting instead")),
  1831. minify: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Minify the bundled file"))
  1832. });
  1833. const OutputCliOptionsSchema = /* @__PURE__ */ omit(/* @__PURE__ */ strictObject({
  1834. ...OutputOptionsSchema.entries,
  1835. ...OutputCliOverrideSchema.entries
  1836. }), [
  1837. "sourcemapIgnoreList",
  1838. "sourcemapPathTransform",
  1839. "plugins",
  1840. "hoistTransitiveImports"
  1841. ]);
  1842. const CliOptionsSchema = /* @__PURE__ */ strictObject({
  1843. config: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ boolean()])), /* @__PURE__ */ description("Path to the config file (default: `rolldown.config.js`)")),
  1844. help: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Show help")),
  1845. environment: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ array(/* @__PURE__ */ string())])), /* @__PURE__ */ description("Pass additional settings to the config file via process.ENV.")),
  1846. version: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Show version number")),
  1847. watch: /* @__PURE__ */ pipe(/* @__PURE__ */ optional(/* @__PURE__ */ boolean()), /* @__PURE__ */ description("Watch files in bundle and rebuild on changes")),
  1848. ...InputCliOptionsSchema.entries,
  1849. ...OutputCliOptionsSchema.entries
  1850. });
  1851. function validateCliOptions(options) {
  1852. let parsed = /* @__PURE__ */ safeParse(CliOptionsSchema, options);
  1853. return [parsed.output, parsed.issues?.map((issue) => {
  1854. return `Invalid value for option ${issue.path?.map((pathItem) => pathItem.key).join(" ")}: ${issue.message}`;
  1855. })];
  1856. }
  1857. const inputHelperMsgRecord = {
  1858. output: { ignored: true },
  1859. "resolve.tsconfigFilename": { issueMsg: "It is deprecated. Please use the top-level `tsconfig` option instead." }
  1860. };
  1861. const outputHelperMsgRecord = {};
  1862. function validateOption(key, options) {
  1863. if (typeof options !== "object") throw new Error(`Invalid ${key} options. Expected an Object but received ${JSON.stringify(options)}.`);
  1864. if (globalThis.process?.env?.ROLLUP_TEST) return;
  1865. let parsed = /* @__PURE__ */ safeParse(key === "input" ? InputOptionsSchema : OutputOptionsSchema, options);
  1866. if (!parsed.success) {
  1867. const errors = parsed.issues.map((issue) => {
  1868. let issueMsg = issue.message;
  1869. const issuePaths = issue.path.map((path) => path.key);
  1870. if (issue.type === "union") {
  1871. const subIssue = issue.issues?.find((i) => !(i.type !== issue.received && i.input === issue.input));
  1872. if (subIssue) {
  1873. if (subIssue.path) issuePaths.push(subIssue.path.map((path) => path.key));
  1874. issueMsg = subIssue.message;
  1875. }
  1876. }
  1877. const stringPath = issuePaths.join(".");
  1878. const helper = key === "input" ? inputHelperMsgRecord[stringPath] : outputHelperMsgRecord[stringPath];
  1879. if (helper && helper.ignored) return "";
  1880. return `- For the "${stringPath}". ${helper?.issueMsg || issueMsg + "."} ${helper?.help ? `\n Help: ${helper.help}` : ""}`;
  1881. }).filter(Boolean);
  1882. if (errors.length) console.warn(`\x1b[33mWarning: Invalid ${key} options (${errors.length} issue${errors.length === 1 ? "" : "s"} found)\n${errors.join("\n")}\x1b[0m`);
  1883. }
  1884. }
  1885. function getInputCliKeys() {
  1886. return (/* @__PURE__ */ keyof(InputCliOptionsSchema)).options;
  1887. }
  1888. function getOutputCliKeys() {
  1889. return (/* @__PURE__ */ keyof(OutputCliOptionsSchema)).options;
  1890. }
  1891. function getCliSchemaInfo() {
  1892. return flattenValibotSchema(CliOptionsSchema);
  1893. }
  1894. //#endregion
  1895. //#region src/types/rolldown-output-impl.ts
  1896. var RolldownOutputImpl = class extends PlainObjectLike {
  1897. bindingOutputs;
  1898. constructor(bindingOutputs) {
  1899. super();
  1900. this.bindingOutputs = bindingOutputs;
  1901. }
  1902. get output() {
  1903. return transformToRollupOutput(this.bindingOutputs).output;
  1904. }
  1905. __rolldown_external_memory_handle__(keepDataAlive) {
  1906. const results = this.output.map((item) => item.__rolldown_external_memory_handle__(keepDataAlive));
  1907. if (!results.every((r) => r.freed)) {
  1908. const reasons = results.filter((r) => !r.freed).map((r) => r.reason).filter(Boolean);
  1909. return {
  1910. freed: false,
  1911. reason: `Failed to free ${reasons.length} item(s): ${reasons.join("; ")}`
  1912. };
  1913. }
  1914. return { freed: true };
  1915. }
  1916. };
  1917. __decorate([lazyProp], RolldownOutputImpl.prototype, "output", null);
  1918. //#endregion
  1919. //#region src/types/chunking-context.ts
  1920. var ChunkingContextImpl = class {
  1921. context;
  1922. constructor(context) {
  1923. this.context = context;
  1924. }
  1925. getModuleInfo(moduleId) {
  1926. const bindingInfo = this.context.getModuleInfo(moduleId);
  1927. if (bindingInfo) return transformModuleInfo(bindingInfo, {
  1928. moduleSideEffects: null,
  1929. meta: {}
  1930. });
  1931. return null;
  1932. }
  1933. };
  1934. //#endregion
  1935. //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/core.mjs
  1936. const LogLevels = {
  1937. silent: Number.NEGATIVE_INFINITY,
  1938. fatal: 0,
  1939. error: 0,
  1940. warn: 1,
  1941. log: 2,
  1942. info: 3,
  1943. success: 3,
  1944. fail: 3,
  1945. ready: 3,
  1946. start: 3,
  1947. box: 3,
  1948. debug: 4,
  1949. trace: 5,
  1950. verbose: Number.POSITIVE_INFINITY
  1951. };
  1952. const LogTypes = {
  1953. silent: { level: -1 },
  1954. fatal: { level: LogLevels.fatal },
  1955. error: { level: LogLevels.error },
  1956. warn: { level: LogLevels.warn },
  1957. log: { level: LogLevels.log },
  1958. info: { level: LogLevels.info },
  1959. success: { level: LogLevels.success },
  1960. fail: { level: LogLevels.fail },
  1961. ready: { level: LogLevels.info },
  1962. start: { level: LogLevels.info },
  1963. box: { level: LogLevels.info },
  1964. debug: { level: LogLevels.debug },
  1965. trace: { level: LogLevels.trace },
  1966. verbose: { level: LogLevels.verbose }
  1967. };
  1968. function isPlainObject$1(value) {
  1969. if (value === null || typeof value !== "object") return false;
  1970. const prototype = Object.getPrototypeOf(value);
  1971. if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) return false;
  1972. if (Symbol.iterator in value) return false;
  1973. if (Symbol.toStringTag in value) return Object.prototype.toString.call(value) === "[object Module]";
  1974. return true;
  1975. }
  1976. function _defu(baseObject, defaults, namespace = ".", merger) {
  1977. if (!isPlainObject$1(defaults)) return _defu(baseObject, {}, namespace, merger);
  1978. const object = Object.assign({}, defaults);
  1979. for (const key in baseObject) {
  1980. if (key === "__proto__" || key === "constructor") continue;
  1981. const value = baseObject[key];
  1982. if (value === null || value === void 0) continue;
  1983. if (merger && merger(object, key, value, namespace)) continue;
  1984. if (Array.isArray(value) && Array.isArray(object[key])) object[key] = [...value, ...object[key]];
  1985. else if (isPlainObject$1(value) && isPlainObject$1(object[key])) object[key] = _defu(value, object[key], (namespace ? `${namespace}.` : "") + key.toString(), merger);
  1986. else object[key] = value;
  1987. }
  1988. return object;
  1989. }
  1990. function createDefu(merger) {
  1991. return (...arguments_) => arguments_.reduce((p, c) => _defu(p, c, "", merger), {});
  1992. }
  1993. const defu = createDefu();
  1994. function isPlainObject(obj) {
  1995. return Object.prototype.toString.call(obj) === "[object Object]";
  1996. }
  1997. function isLogObj(arg) {
  1998. if (!isPlainObject(arg)) return false;
  1999. if (!arg.message && !arg.args) return false;
  2000. if (arg.stack) return false;
  2001. return true;
  2002. }
  2003. let paused = false;
  2004. const queue = [];
  2005. var Consola = class Consola {
  2006. options;
  2007. _lastLog;
  2008. _mockFn;
  2009. /**
  2010. * Creates an instance of Consola with specified options or defaults.
  2011. *
  2012. * @param {Partial<ConsolaOptions>} [options={}] - Configuration options for the Consola instance.
  2013. */
  2014. constructor(options = {}) {
  2015. const types = options.types || LogTypes;
  2016. this.options = defu({
  2017. ...options,
  2018. defaults: { ...options.defaults },
  2019. level: _normalizeLogLevel(options.level, types),
  2020. reporters: [...options.reporters || []]
  2021. }, {
  2022. types: LogTypes,
  2023. throttle: 1e3,
  2024. throttleMin: 5,
  2025. formatOptions: {
  2026. date: true,
  2027. colors: false,
  2028. compact: true
  2029. }
  2030. });
  2031. for (const type in types) {
  2032. const defaults = {
  2033. type,
  2034. ...this.options.defaults,
  2035. ...types[type]
  2036. };
  2037. this[type] = this._wrapLogFn(defaults);
  2038. this[type].raw = this._wrapLogFn(defaults, true);
  2039. }
  2040. if (this.options.mockFn) this.mockTypes();
  2041. this._lastLog = {};
  2042. }
  2043. /**
  2044. * Gets the current log level of the Consola instance.
  2045. *
  2046. * @returns {number} The current log level.
  2047. */
  2048. get level() {
  2049. return this.options.level;
  2050. }
  2051. /**
  2052. * Sets the minimum log level that will be output by the instance.
  2053. *
  2054. * @param {number} level - The new log level to set.
  2055. */
  2056. set level(level) {
  2057. this.options.level = _normalizeLogLevel(level, this.options.types, this.options.level);
  2058. }
  2059. /**
  2060. * Displays a prompt to the user and returns the response.
  2061. * Throw an error if `prompt` is not supported by the current configuration.
  2062. *
  2063. * @template T
  2064. * @param {string} message - The message to display in the prompt.
  2065. * @param {T} [opts] - Optional options for the prompt. See {@link PromptOptions}.
  2066. * @returns {promise<T>} A promise that infer with the prompt options. See {@link PromptOptions}.
  2067. */
  2068. prompt(message, opts) {
  2069. if (!this.options.prompt) throw new Error("prompt is not supported!");
  2070. return this.options.prompt(message, opts);
  2071. }
  2072. /**
  2073. * Creates a new instance of Consola, inheriting options from the current instance, with possible overrides.
  2074. *
  2075. * @param {Partial<ConsolaOptions>} options - Optional overrides for the new instance. See {@link ConsolaOptions}.
  2076. * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
  2077. */
  2078. create(options) {
  2079. const instance = new Consola({
  2080. ...this.options,
  2081. ...options
  2082. });
  2083. if (this._mockFn) instance.mockTypes(this._mockFn);
  2084. return instance;
  2085. }
  2086. /**
  2087. * Creates a new Consola instance with the specified default log object properties.
  2088. *
  2089. * @param {InputLogObject} defaults - Default properties to include in any log from the new instance. See {@link InputLogObject}.
  2090. * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
  2091. */
  2092. withDefaults(defaults) {
  2093. return this.create({
  2094. ...this.options,
  2095. defaults: {
  2096. ...this.options.defaults,
  2097. ...defaults
  2098. }
  2099. });
  2100. }
  2101. /**
  2102. * Creates a new Consola instance with a specified tag, which will be included in every log.
  2103. *
  2104. * @param {string} tag - The tag to include in each log of the new instance.
  2105. * @returns {ConsolaInstance} A new Consola instance. See {@link ConsolaInstance}.
  2106. */
  2107. withTag(tag) {
  2108. return this.withDefaults({ tag: this.options.defaults.tag ? this.options.defaults.tag + ":" + tag : tag });
  2109. }
  2110. /**
  2111. * Adds a custom reporter to the Consola instance.
  2112. * Reporters will be called for each log message, depending on their implementation and log level.
  2113. *
  2114. * @param {ConsolaReporter} reporter - The reporter to add. See {@link ConsolaReporter}.
  2115. * @returns {Consola} The current Consola instance.
  2116. */
  2117. addReporter(reporter) {
  2118. this.options.reporters.push(reporter);
  2119. return this;
  2120. }
  2121. /**
  2122. * Removes a custom reporter from the Consola instance.
  2123. * If no reporter is specified, all reporters will be removed.
  2124. *
  2125. * @param {ConsolaReporter} reporter - The reporter to remove. See {@link ConsolaReporter}.
  2126. * @returns {Consola} The current Consola instance.
  2127. */
  2128. removeReporter(reporter) {
  2129. if (reporter) {
  2130. const i = this.options.reporters.indexOf(reporter);
  2131. if (i !== -1) return this.options.reporters.splice(i, 1);
  2132. } else this.options.reporters.splice(0);
  2133. return this;
  2134. }
  2135. /**
  2136. * Replaces all reporters of the Consola instance with the specified array of reporters.
  2137. *
  2138. * @param {ConsolaReporter[]} reporters - The new reporters to set. See {@link ConsolaReporter}.
  2139. * @returns {Consola} The current Consola instance.
  2140. */
  2141. setReporters(reporters) {
  2142. this.options.reporters = Array.isArray(reporters) ? reporters : [reporters];
  2143. return this;
  2144. }
  2145. wrapAll() {
  2146. this.wrapConsole();
  2147. this.wrapStd();
  2148. }
  2149. restoreAll() {
  2150. this.restoreConsole();
  2151. this.restoreStd();
  2152. }
  2153. /**
  2154. * Overrides console methods with Consola logging methods for consistent logging.
  2155. */
  2156. wrapConsole() {
  2157. for (const type in this.options.types) {
  2158. if (!console["__" + type]) console["__" + type] = console[type];
  2159. console[type] = this[type].raw;
  2160. }
  2161. }
  2162. /**
  2163. * Restores the original console methods, removing Consola overrides.
  2164. */
  2165. restoreConsole() {
  2166. for (const type in this.options.types) if (console["__" + type]) {
  2167. console[type] = console["__" + type];
  2168. delete console["__" + type];
  2169. }
  2170. }
  2171. /**
  2172. * Overrides standard output and error streams to redirect them through Consola.
  2173. */
  2174. wrapStd() {
  2175. this._wrapStream(this.options.stdout, "log");
  2176. this._wrapStream(this.options.stderr, "log");
  2177. }
  2178. _wrapStream(stream, type) {
  2179. if (!stream) return;
  2180. if (!stream.__write) stream.__write = stream.write;
  2181. stream.write = (data) => {
  2182. this[type].raw(String(data).trim());
  2183. };
  2184. }
  2185. /**
  2186. * Restores the original standard output and error streams, removing the Consola redirection.
  2187. */
  2188. restoreStd() {
  2189. this._restoreStream(this.options.stdout);
  2190. this._restoreStream(this.options.stderr);
  2191. }
  2192. _restoreStream(stream) {
  2193. if (!stream) return;
  2194. if (stream.__write) {
  2195. stream.write = stream.__write;
  2196. delete stream.__write;
  2197. }
  2198. }
  2199. /**
  2200. * Pauses logging, queues incoming logs until resumed.
  2201. */
  2202. pauseLogs() {
  2203. paused = true;
  2204. }
  2205. /**
  2206. * Resumes logging, processing any queued logs.
  2207. */
  2208. resumeLogs() {
  2209. paused = false;
  2210. const _queue = queue.splice(0);
  2211. for (const item of _queue) item[0]._logFn(item[1], item[2]);
  2212. }
  2213. /**
  2214. * Replaces logging methods with mocks if a mock function is provided.
  2215. *
  2216. * @param {ConsolaOptions["mockFn"]} mockFn - The function to use for mocking logging methods. See {@link ConsolaOptions["mockFn"]}.
  2217. */
  2218. mockTypes(mockFn) {
  2219. const _mockFn = mockFn || this.options.mockFn;
  2220. this._mockFn = _mockFn;
  2221. if (typeof _mockFn !== "function") return;
  2222. for (const type in this.options.types) {
  2223. this[type] = _mockFn(type, this.options.types[type]) || this[type];
  2224. this[type].raw = this[type];
  2225. }
  2226. }
  2227. _wrapLogFn(defaults, isRaw) {
  2228. return (...args) => {
  2229. if (paused) {
  2230. queue.push([
  2231. this,
  2232. defaults,
  2233. args,
  2234. isRaw
  2235. ]);
  2236. return;
  2237. }
  2238. return this._logFn(defaults, args, isRaw);
  2239. };
  2240. }
  2241. _logFn(defaults, args, isRaw) {
  2242. if ((defaults.level || 0) > this.level) return false;
  2243. const logObj = {
  2244. date: /* @__PURE__ */ new Date(),
  2245. args: [],
  2246. ...defaults,
  2247. level: _normalizeLogLevel(defaults.level, this.options.types)
  2248. };
  2249. if (!isRaw && args.length === 1 && isLogObj(args[0])) Object.assign(logObj, args[0]);
  2250. else logObj.args = [...args];
  2251. if (logObj.message) {
  2252. logObj.args.unshift(logObj.message);
  2253. delete logObj.message;
  2254. }
  2255. if (logObj.additional) {
  2256. if (!Array.isArray(logObj.additional)) logObj.additional = logObj.additional.split("\n");
  2257. logObj.args.push("\n" + logObj.additional.join("\n"));
  2258. delete logObj.additional;
  2259. }
  2260. logObj.type = typeof logObj.type === "string" ? logObj.type.toLowerCase() : "log";
  2261. logObj.tag = typeof logObj.tag === "string" ? logObj.tag : "";
  2262. const resolveLog = (newLog = false) => {
  2263. const repeated = (this._lastLog.count || 0) - this.options.throttleMin;
  2264. if (this._lastLog.object && repeated > 0) {
  2265. const args2 = [...this._lastLog.object.args];
  2266. if (repeated > 1) args2.push(`(repeated ${repeated} times)`);
  2267. this._log({
  2268. ...this._lastLog.object,
  2269. args: args2
  2270. });
  2271. this._lastLog.count = 1;
  2272. }
  2273. if (newLog) {
  2274. this._lastLog.object = logObj;
  2275. this._log(logObj);
  2276. }
  2277. };
  2278. clearTimeout(this._lastLog.timeout);
  2279. const diffTime = this._lastLog.time && logObj.date ? logObj.date.getTime() - this._lastLog.time.getTime() : 0;
  2280. this._lastLog.time = logObj.date;
  2281. if (diffTime < this.options.throttle) try {
  2282. const serializedLog = JSON.stringify([
  2283. logObj.type,
  2284. logObj.tag,
  2285. logObj.args
  2286. ]);
  2287. const isSameLog = this._lastLog.serialized === serializedLog;
  2288. this._lastLog.serialized = serializedLog;
  2289. if (isSameLog) {
  2290. this._lastLog.count = (this._lastLog.count || 0) + 1;
  2291. if (this._lastLog.count > this.options.throttleMin) {
  2292. this._lastLog.timeout = setTimeout(resolveLog, this.options.throttle);
  2293. return;
  2294. }
  2295. }
  2296. } catch {}
  2297. resolveLog(true);
  2298. }
  2299. _log(logObj) {
  2300. for (const reporter of this.options.reporters) reporter.log(logObj, { options: this.options });
  2301. }
  2302. };
  2303. function _normalizeLogLevel(input, types = {}, defaultLevel = 3) {
  2304. if (input === void 0) return defaultLevel;
  2305. if (typeof input === "number") return input;
  2306. if (types[input] && types[input].level !== void 0) return types[input].level;
  2307. return defaultLevel;
  2308. }
  2309. Consola.prototype.add = Consola.prototype.addReporter;
  2310. Consola.prototype.remove = Consola.prototype.removeReporter;
  2311. Consola.prototype.clear = Consola.prototype.removeReporter;
  2312. Consola.prototype.withScope = Consola.prototype.withTag;
  2313. Consola.prototype.mock = Consola.prototype.mockTypes;
  2314. Consola.prototype.pause = Consola.prototype.pauseLogs;
  2315. Consola.prototype.resume = Consola.prototype.resumeLogs;
  2316. function createConsola$1(options = {}) {
  2317. return new Consola(options);
  2318. }
  2319. //#endregion
  2320. //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs
  2321. function parseStack(stack, message) {
  2322. const cwd = process.cwd() + sep;
  2323. return stack.split("\n").splice(message.split("\n").length).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
  2324. }
  2325. function writeStream(data, stream) {
  2326. return (stream.__write || stream.write).call(stream, data);
  2327. }
  2328. const bracket = (x) => x ? `[${x}]` : "";
  2329. var BasicReporter = class {
  2330. formatStack(stack, message, opts) {
  2331. const indent = " ".repeat((opts?.errorLevel || 0) + 1);
  2332. return indent + parseStack(stack, message).join(`
  2333. ${indent}`);
  2334. }
  2335. formatError(err, opts) {
  2336. const message = err.message ?? formatWithOptions(opts, err);
  2337. const stack = err.stack ? this.formatStack(err.stack, message, opts) : "";
  2338. const level = opts?.errorLevel || 0;
  2339. const causedPrefix = level > 0 ? `${" ".repeat(level)}[cause]: ` : "";
  2340. const causedError = err.cause ? "\n\n" + this.formatError(err.cause, {
  2341. ...opts,
  2342. errorLevel: level + 1
  2343. }) : "";
  2344. return causedPrefix + message + "\n" + stack + causedError;
  2345. }
  2346. formatArgs(args, opts) {
  2347. return formatWithOptions(opts, ...args.map((arg) => {
  2348. if (arg && typeof arg.stack === "string") return this.formatError(arg, opts);
  2349. return arg;
  2350. }));
  2351. }
  2352. formatDate(date, opts) {
  2353. return opts.date ? date.toLocaleTimeString() : "";
  2354. }
  2355. filterAndJoin(arr) {
  2356. return arr.filter(Boolean).join(" ");
  2357. }
  2358. formatLogObj(logObj, opts) {
  2359. const message = this.formatArgs(logObj.args, opts);
  2360. if (logObj.type === "box") return "\n" + [
  2361. bracket(logObj.tag),
  2362. logObj.title && logObj.title,
  2363. ...message.split("\n")
  2364. ].filter(Boolean).map((l) => " > " + l).join("\n") + "\n";
  2365. return this.filterAndJoin([
  2366. bracket(logObj.type),
  2367. bracket(logObj.tag),
  2368. message
  2369. ]);
  2370. }
  2371. log(logObj, ctx) {
  2372. return writeStream(this.formatLogObj(logObj, {
  2373. columns: ctx.options.stdout.columns || 0,
  2374. ...ctx.options.formatOptions
  2375. }) + "\n", logObj.level < 2 ? ctx.options.stderr || process.stderr : ctx.options.stdout || process.stdout);
  2376. }
  2377. };
  2378. //#endregion
  2379. //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs
  2380. const { env = {}, argv = [], platform = "" } = typeof process === "undefined" ? {} : process;
  2381. const isDisabled = "NO_COLOR" in env || argv.includes("--no-color");
  2382. const isForced = "FORCE_COLOR" in env || argv.includes("--color");
  2383. const isWindows = platform === "win32";
  2384. const isDumbTerminal = env.TERM === "dumb";
  2385. const isCompatibleTerminal = tty && tty.isatty && tty.isatty(1) && env.TERM && !isDumbTerminal;
  2386. const isCI = "CI" in env && ("GITHUB_ACTIONS" in env || "GITLAB_CI" in env || "CIRCLECI" in env);
  2387. const isColorSupported = !isDisabled && (isForced || isWindows && !isDumbTerminal || isCompatibleTerminal || isCI);
  2388. function replaceClose(index, string, close, replace, head = string.slice(0, Math.max(0, index)) + replace, tail = string.slice(Math.max(0, index + close.length)), next = tail.indexOf(close)) {
  2389. return head + (next < 0 ? tail : replaceClose(next, tail, close, replace));
  2390. }
  2391. function clearBleed(index, string, open, close, replace) {
  2392. return index < 0 ? open + string + close : open + replaceClose(index, string, close, replace) + close;
  2393. }
  2394. function filterEmpty(open, close, replace = open, at = open.length + 1) {
  2395. return (string) => string || !(string === "" || string === void 0) ? clearBleed(("" + string).indexOf(close, at), string, open, close, replace) : "";
  2396. }
  2397. function init(open, close, replace) {
  2398. return filterEmpty(`\x1B[${open}m`, `\x1B[${close}m`, replace);
  2399. }
  2400. const colorDefs = {
  2401. reset: init(0, 0),
  2402. bold: init(1, 22, "\x1B[22m\x1B[1m"),
  2403. dim: init(2, 22, "\x1B[22m\x1B[2m"),
  2404. italic: init(3, 23),
  2405. underline: init(4, 24),
  2406. inverse: init(7, 27),
  2407. hidden: init(8, 28),
  2408. strikethrough: init(9, 29),
  2409. black: init(30, 39),
  2410. red: init(31, 39),
  2411. green: init(32, 39),
  2412. yellow: init(33, 39),
  2413. blue: init(34, 39),
  2414. magenta: init(35, 39),
  2415. cyan: init(36, 39),
  2416. white: init(37, 39),
  2417. gray: init(90, 39),
  2418. bgBlack: init(40, 49),
  2419. bgRed: init(41, 49),
  2420. bgGreen: init(42, 49),
  2421. bgYellow: init(43, 49),
  2422. bgBlue: init(44, 49),
  2423. bgMagenta: init(45, 49),
  2424. bgCyan: init(46, 49),
  2425. bgWhite: init(47, 49),
  2426. blackBright: init(90, 39),
  2427. redBright: init(91, 39),
  2428. greenBright: init(92, 39),
  2429. yellowBright: init(93, 39),
  2430. blueBright: init(94, 39),
  2431. magentaBright: init(95, 39),
  2432. cyanBright: init(96, 39),
  2433. whiteBright: init(97, 39),
  2434. bgBlackBright: init(100, 49),
  2435. bgRedBright: init(101, 49),
  2436. bgGreenBright: init(102, 49),
  2437. bgYellowBright: init(103, 49),
  2438. bgBlueBright: init(104, 49),
  2439. bgMagentaBright: init(105, 49),
  2440. bgCyanBright: init(106, 49),
  2441. bgWhiteBright: init(107, 49)
  2442. };
  2443. function createColors(useColor = isColorSupported) {
  2444. return useColor ? colorDefs : Object.fromEntries(Object.keys(colorDefs).map((key) => [key, String]));
  2445. }
  2446. const colors = createColors();
  2447. function getColor$1(color, fallback = "reset") {
  2448. return colors[color] || colors[fallback];
  2449. }
  2450. const ansiRegex$1 = [String.raw`[\u001B\u009B][[\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\d\/#&.:=?%@~_]+)*|[a-zA-Z\d]+(?:;[-a-zA-Z\d\/#&.:=?%@~_]*)*)?\u0007)`, String.raw`(?:(?:\d{1,4}(?:;\d{0,4})*)?[\dA-PR-TZcf-nq-uy=><~]))`].join("|");
  2451. function stripAnsi$1(text) {
  2452. return text.replace(new RegExp(ansiRegex$1, "g"), "");
  2453. }
  2454. const boxStylePresets = {
  2455. solid: {
  2456. tl: "┌",
  2457. tr: "┐",
  2458. bl: "└",
  2459. br: "┘",
  2460. h: "─",
  2461. v: "│"
  2462. },
  2463. double: {
  2464. tl: "╔",
  2465. tr: "╗",
  2466. bl: "╚",
  2467. br: "╝",
  2468. h: "═",
  2469. v: "║"
  2470. },
  2471. doubleSingle: {
  2472. tl: "╓",
  2473. tr: "╖",
  2474. bl: "╙",
  2475. br: "╜",
  2476. h: "─",
  2477. v: "║"
  2478. },
  2479. doubleSingleRounded: {
  2480. tl: "╭",
  2481. tr: "╮",
  2482. bl: "╰",
  2483. br: "╯",
  2484. h: "─",
  2485. v: "║"
  2486. },
  2487. singleThick: {
  2488. tl: "┏",
  2489. tr: "┓",
  2490. bl: "┗",
  2491. br: "┛",
  2492. h: "━",
  2493. v: "┃"
  2494. },
  2495. singleDouble: {
  2496. tl: "╒",
  2497. tr: "╕",
  2498. bl: "╘",
  2499. br: "╛",
  2500. h: "═",
  2501. v: "│"
  2502. },
  2503. singleDoubleRounded: {
  2504. tl: "╭",
  2505. tr: "╮",
  2506. bl: "╰",
  2507. br: "╯",
  2508. h: "═",
  2509. v: "│"
  2510. },
  2511. rounded: {
  2512. tl: "╭",
  2513. tr: "╮",
  2514. bl: "╰",
  2515. br: "╯",
  2516. h: "─",
  2517. v: "│"
  2518. }
  2519. };
  2520. const defaultStyle = {
  2521. borderColor: "white",
  2522. borderStyle: "rounded",
  2523. valign: "center",
  2524. padding: 2,
  2525. marginLeft: 1,
  2526. marginTop: 1,
  2527. marginBottom: 1
  2528. };
  2529. function box(text, _opts = {}) {
  2530. const opts = {
  2531. ..._opts,
  2532. style: {
  2533. ...defaultStyle,
  2534. ..._opts.style
  2535. }
  2536. };
  2537. const textLines = text.split("\n");
  2538. const boxLines = [];
  2539. const _color = getColor$1(opts.style.borderColor);
  2540. const borderStyle = { ...typeof opts.style.borderStyle === "string" ? boxStylePresets[opts.style.borderStyle] || boxStylePresets.solid : opts.style.borderStyle };
  2541. if (_color) for (const key in borderStyle) borderStyle[key] = _color(borderStyle[key]);
  2542. const paddingOffset = opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
  2543. const height = textLines.length + paddingOffset;
  2544. const width = Math.max(...textLines.map((line) => stripAnsi$1(line).length), opts.title ? stripAnsi$1(opts.title).length : 0) + paddingOffset;
  2545. const widthOffset = width + paddingOffset;
  2546. const leftSpace = opts.style.marginLeft > 0 ? " ".repeat(opts.style.marginLeft) : "";
  2547. if (opts.style.marginTop > 0) boxLines.push("".repeat(opts.style.marginTop));
  2548. if (opts.title) {
  2549. const title = _color ? _color(opts.title) : opts.title;
  2550. const left = borderStyle.h.repeat(Math.floor((width - stripAnsi$1(opts.title).length) / 2));
  2551. const right = borderStyle.h.repeat(width - stripAnsi$1(opts.title).length - stripAnsi$1(left).length + paddingOffset);
  2552. boxLines.push(`${leftSpace}${borderStyle.tl}${left}${title}${right}${borderStyle.tr}`);
  2553. } else boxLines.push(`${leftSpace}${borderStyle.tl}${borderStyle.h.repeat(widthOffset)}${borderStyle.tr}`);
  2554. const valignOffset = opts.style.valign === "center" ? Math.floor((height - textLines.length) / 2) : opts.style.valign === "top" ? height - textLines.length - paddingOffset : height - textLines.length;
  2555. for (let i = 0; i < height; i++) if (i < valignOffset || i >= valignOffset + textLines.length) boxLines.push(`${leftSpace}${borderStyle.v}${" ".repeat(widthOffset)}${borderStyle.v}`);
  2556. else {
  2557. const line = textLines[i - valignOffset];
  2558. const left = " ".repeat(paddingOffset);
  2559. const right = " ".repeat(width - stripAnsi$1(line).length);
  2560. boxLines.push(`${leftSpace}${borderStyle.v}${left}${line}${right}${borderStyle.v}`);
  2561. }
  2562. boxLines.push(`${leftSpace}${borderStyle.bl}${borderStyle.h.repeat(widthOffset)}${borderStyle.br}`);
  2563. if (opts.style.marginBottom > 0) boxLines.push("".repeat(opts.style.marginBottom));
  2564. return boxLines.join("\n");
  2565. }
  2566. //#endregion
  2567. //#region ../../node_modules/.pnpm/consola@3.4.2/node_modules/consola/dist/index.mjs
  2568. const r = Object.create(null), i = (e) => globalThis.process?.env || import.meta.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? r : globalThis), o = new Proxy(r, {
  2569. get(e, s) {
  2570. return i()[s] ?? r[s];
  2571. },
  2572. has(e, s) {
  2573. return s in i() || s in r;
  2574. },
  2575. set(e, s, E) {
  2576. const B = i(true);
  2577. return B[s] = E, true;
  2578. },
  2579. deleteProperty(e, s) {
  2580. if (!s) return false;
  2581. const E = i(true);
  2582. return delete E[s], true;
  2583. },
  2584. ownKeys() {
  2585. const e = i(true);
  2586. return Object.keys(e);
  2587. }
  2588. }), t = typeof process < "u" && process.env && process.env.NODE_ENV || "", f = [
  2589. ["APPVEYOR"],
  2590. [
  2591. "AWS_AMPLIFY",
  2592. "AWS_APP_ID",
  2593. { ci: true }
  2594. ],
  2595. ["AZURE_PIPELINES", "SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],
  2596. ["AZURE_STATIC", "INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],
  2597. ["APPCIRCLE", "AC_APPCIRCLE"],
  2598. ["BAMBOO", "bamboo_planKey"],
  2599. ["BITBUCKET", "BITBUCKET_COMMIT"],
  2600. ["BITRISE", "BITRISE_IO"],
  2601. ["BUDDY", "BUDDY_WORKSPACE_ID"],
  2602. ["BUILDKITE"],
  2603. ["CIRCLE", "CIRCLECI"],
  2604. ["CIRRUS", "CIRRUS_CI"],
  2605. [
  2606. "CLOUDFLARE_PAGES",
  2607. "CF_PAGES",
  2608. { ci: true }
  2609. ],
  2610. ["CODEBUILD", "CODEBUILD_BUILD_ARN"],
  2611. ["CODEFRESH", "CF_BUILD_ID"],
  2612. ["DRONE"],
  2613. ["DRONE", "DRONE_BUILD_EVENT"],
  2614. ["DSARI"],
  2615. ["GITHUB_ACTIONS"],
  2616. ["GITLAB", "GITLAB_CI"],
  2617. ["GITLAB", "CI_MERGE_REQUEST_ID"],
  2618. ["GOCD", "GO_PIPELINE_LABEL"],
  2619. ["LAYERCI"],
  2620. ["HUDSON", "HUDSON_URL"],
  2621. ["JENKINS", "JENKINS_URL"],
  2622. ["MAGNUM"],
  2623. ["NETLIFY"],
  2624. [
  2625. "NETLIFY",
  2626. "NETLIFY_LOCAL",
  2627. { ci: false }
  2628. ],
  2629. ["NEVERCODE"],
  2630. ["RENDER"],
  2631. ["SAIL", "SAILCI"],
  2632. ["SEMAPHORE"],
  2633. ["SCREWDRIVER"],
  2634. ["SHIPPABLE"],
  2635. ["SOLANO", "TDDIUM"],
  2636. ["STRIDER"],
  2637. ["TEAMCITY", "TEAMCITY_VERSION"],
  2638. ["TRAVIS"],
  2639. ["VERCEL", "NOW_BUILDER"],
  2640. [
  2641. "VERCEL",
  2642. "VERCEL",
  2643. { ci: false }
  2644. ],
  2645. [
  2646. "VERCEL",
  2647. "VERCEL_ENV",
  2648. { ci: false }
  2649. ],
  2650. ["APPCENTER", "APPCENTER_BUILD_ID"],
  2651. [
  2652. "CODESANDBOX",
  2653. "CODESANDBOX_SSE",
  2654. { ci: false }
  2655. ],
  2656. [
  2657. "CODESANDBOX",
  2658. "CODESANDBOX_HOST",
  2659. { ci: false }
  2660. ],
  2661. ["STACKBLITZ"],
  2662. ["STORMKIT"],
  2663. ["CLEAVR"],
  2664. ["ZEABUR"],
  2665. [
  2666. "CODESPHERE",
  2667. "CODESPHERE_APP_ID",
  2668. { ci: true }
  2669. ],
  2670. ["RAILWAY", "RAILWAY_PROJECT_ID"],
  2671. ["RAILWAY", "RAILWAY_SERVICE_ID"],
  2672. ["DENO-DEPLOY", "DENO_DEPLOYMENT_ID"],
  2673. [
  2674. "FIREBASE_APP_HOSTING",
  2675. "FIREBASE_APP_HOSTING",
  2676. { ci: true }
  2677. ]
  2678. ];
  2679. function b() {
  2680. if (globalThis.process?.env) for (const e of f) {
  2681. const s = e[1] || e[0];
  2682. if (globalThis.process?.env[s]) return {
  2683. name: e[0].toLowerCase(),
  2684. ...e[2]
  2685. };
  2686. }
  2687. return globalThis.process?.env?.SHELL === "/bin/jsh" && globalThis.process?.versions?.webcontainer ? {
  2688. name: "stackblitz",
  2689. ci: false
  2690. } : {
  2691. name: "",
  2692. ci: false
  2693. };
  2694. }
  2695. const l = b();
  2696. l.name;
  2697. function n(e) {
  2698. return e ? e !== "false" : false;
  2699. }
  2700. const I = globalThis.process?.platform || "", T = n(o.CI) || l.ci !== false, a = n(globalThis.process?.stdout && globalThis.process?.stdout.isTTY), g = n(o.DEBUG), R = t === "test" || n(o.TEST);
  2701. o.MINIMAL;
  2702. const A = /^win/i.test(I);
  2703. !n(o.NO_COLOR) && (n(o.FORCE_COLOR) || (a || A) && o.TERM);
  2704. const C = (globalThis.process?.versions?.node || "").replace(/^v/, "") || null;
  2705. Number(C?.split(".")[0]);
  2706. const y = globalThis.process || Object.create(null), _ = { versions: {} };
  2707. new Proxy(y, { get(e, s) {
  2708. if (s === "env") return o;
  2709. if (s in e) return e[s];
  2710. if (s in _) return _[s];
  2711. } });
  2712. const c = globalThis.process?.release?.name === "node", O = !!globalThis.Bun || !!globalThis.process?.versions?.bun, D = !!globalThis.Deno, L = !!globalThis.fastly, S = !!globalThis.Netlify, u = !!globalThis.EdgeRuntime, N = globalThis.navigator?.userAgent === "Cloudflare-Workers", F = [
  2713. [S, "netlify"],
  2714. [u, "edge-light"],
  2715. [N, "workerd"],
  2716. [L, "fastly"],
  2717. [D, "deno"],
  2718. [O, "bun"],
  2719. [c, "node"]
  2720. ];
  2721. function G() {
  2722. const e = F.find((s) => s[0]);
  2723. if (e) return { name: e[1] };
  2724. }
  2725. G()?.name;
  2726. function ansiRegex({ onlyFirst = false } = {}) {
  2727. const pattern = [`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))`, "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"].join("|");
  2728. return new RegExp(pattern, onlyFirst ? void 0 : "g");
  2729. }
  2730. const regex = ansiRegex();
  2731. function stripAnsi(string) {
  2732. if (typeof string !== "string") throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
  2733. return string.replace(regex, "");
  2734. }
  2735. function isAmbiguous(x) {
  2736. return x === 161 || x === 164 || x === 167 || x === 168 || x === 170 || x === 173 || x === 174 || x >= 176 && x <= 180 || x >= 182 && x <= 186 || x >= 188 && x <= 191 || x === 198 || x === 208 || x === 215 || x === 216 || x >= 222 && x <= 225 || x === 230 || x >= 232 && x <= 234 || x === 236 || x === 237 || x === 240 || x === 242 || x === 243 || x >= 247 && x <= 250 || x === 252 || x === 254 || x === 257 || x === 273 || x === 275 || x === 283 || x === 294 || x === 295 || x === 299 || x >= 305 && x <= 307 || x === 312 || x >= 319 && x <= 322 || x === 324 || x >= 328 && x <= 331 || x === 333 || x === 338 || x === 339 || x === 358 || x === 359 || x === 363 || x === 462 || x === 464 || x === 466 || x === 468 || x === 470 || x === 472 || x === 474 || x === 476 || x === 593 || x === 609 || x === 708 || x === 711 || x >= 713 && x <= 715 || x === 717 || x === 720 || x >= 728 && x <= 731 || x === 733 || x === 735 || x >= 768 && x <= 879 || x >= 913 && x <= 929 || x >= 931 && x <= 937 || x >= 945 && x <= 961 || x >= 963 && x <= 969 || x === 1025 || x >= 1040 && x <= 1103 || x === 1105 || x === 8208 || x >= 8211 && x <= 8214 || x === 8216 || x === 8217 || x === 8220 || x === 8221 || x >= 8224 && x <= 8226 || x >= 8228 && x <= 8231 || x === 8240 || x === 8242 || x === 8243 || x === 8245 || x === 8251 || x === 8254 || x === 8308 || x === 8319 || x >= 8321 && x <= 8324 || x === 8364 || x === 8451 || x === 8453 || x === 8457 || x === 8467 || x === 8470 || x === 8481 || x === 8482 || x === 8486 || x === 8491 || x === 8531 || x === 8532 || x >= 8539 && x <= 8542 || x >= 8544 && x <= 8555 || x >= 8560 && x <= 8569 || x === 8585 || x >= 8592 && x <= 8601 || x === 8632 || x === 8633 || x === 8658 || x === 8660 || x === 8679 || x === 8704 || x === 8706 || x === 8707 || x === 8711 || x === 8712 || x === 8715 || x === 8719 || x === 8721 || x === 8725 || x === 8730 || x >= 8733 && x <= 8736 || x === 8739 || x === 8741 || x >= 8743 && x <= 8748 || x === 8750 || x >= 8756 && x <= 8759 || x === 8764 || x === 8765 || x === 8776 || x === 8780 || x === 8786 || x === 8800 || x === 8801 || x >= 8804 && x <= 8807 || x === 8810 || x === 8811 || x === 8814 || x === 8815 || x === 8834 || x === 8835 || x === 8838 || x === 8839 || x === 8853 || x === 8857 || x === 8869 || x === 8895 || x === 8978 || x >= 9312 && x <= 9449 || x >= 9451 && x <= 9547 || x >= 9552 && x <= 9587 || x >= 9600 && x <= 9615 || x >= 9618 && x <= 9621 || x === 9632 || x === 9633 || x >= 9635 && x <= 9641 || x === 9650 || x === 9651 || x === 9654 || x === 9655 || x === 9660 || x === 9661 || x === 9664 || x === 9665 || x >= 9670 && x <= 9672 || x === 9675 || x >= 9678 && x <= 9681 || x >= 9698 && x <= 9701 || x === 9711 || x === 9733 || x === 9734 || x === 9737 || x === 9742 || x === 9743 || x === 9756 || x === 9758 || x === 9792 || x === 9794 || x === 9824 || x === 9825 || x >= 9827 && x <= 9829 || x >= 9831 && x <= 9834 || x === 9836 || x === 9837 || x === 9839 || x === 9886 || x === 9887 || x === 9919 || x >= 9926 && x <= 9933 || x >= 9935 && x <= 9939 || x >= 9941 && x <= 9953 || x === 9955 || x === 9960 || x === 9961 || x >= 9963 && x <= 9969 || x === 9972 || x >= 9974 && x <= 9977 || x === 9979 || x === 9980 || x === 9982 || x === 9983 || x === 10045 || x >= 10102 && x <= 10111 || x >= 11094 && x <= 11097 || x >= 12872 && x <= 12879 || x >= 57344 && x <= 63743 || x >= 65024 && x <= 65039 || x === 65533 || x >= 127232 && x <= 127242 || x >= 127248 && x <= 127277 || x >= 127280 && x <= 127337 || x >= 127344 && x <= 127373 || x === 127375 || x === 127376 || x >= 127387 && x <= 127404 || x >= 917760 && x <= 917999 || x >= 983040 && x <= 1048573 || x >= 1048576 && x <= 1114109;
  2737. }
  2738. function isFullWidth(x) {
  2739. return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
  2740. }
  2741. function isWide(x) {
  2742. return x >= 4352 && x <= 4447 || x === 8986 || x === 8987 || x === 9001 || x === 9002 || x >= 9193 && x <= 9196 || x === 9200 || x === 9203 || x === 9725 || x === 9726 || x === 9748 || x === 9749 || x >= 9776 && x <= 9783 || x >= 9800 && x <= 9811 || x === 9855 || x >= 9866 && x <= 9871 || x === 9875 || x === 9889 || x === 9898 || x === 9899 || x === 9917 || x === 9918 || x === 9924 || x === 9925 || x === 9934 || x === 9940 || x === 9962 || x === 9970 || x === 9971 || x === 9973 || x === 9978 || x === 9981 || x === 9989 || x === 9994 || x === 9995 || x === 10024 || x === 10060 || x === 10062 || x >= 10067 && x <= 10069 || x === 10071 || x >= 10133 && x <= 10135 || x === 10160 || x === 10175 || x === 11035 || x === 11036 || x === 11088 || x === 11093 || x >= 11904 && x <= 11929 || x >= 11931 && x <= 12019 || x >= 12032 && x <= 12245 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12353 && x <= 12438 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12773 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 42124 || x >= 42128 && x <= 42182 || x >= 43360 && x <= 43388 || x >= 44032 && x <= 55203 || x >= 63744 && x <= 64255 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 94176 && x <= 94180 || x === 94192 || x === 94193 || x >= 94208 && x <= 100343 || x >= 100352 && x <= 101589 || x >= 101631 && x <= 101640 || x >= 110576 && x <= 110579 || x >= 110581 && x <= 110587 || x === 110589 || x === 110590 || x >= 110592 && x <= 110882 || x === 110898 || x >= 110928 && x <= 110930 || x === 110933 || x >= 110948 && x <= 110951 || x >= 110960 && x <= 111355 || x >= 119552 && x <= 119638 || x >= 119648 && x <= 119670 || x === 126980 || x === 127183 || x === 127374 || x >= 127377 && x <= 127386 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x === 127568 || x === 127569 || x >= 127584 && x <= 127589 || x >= 127744 && x <= 127776 || x >= 127789 && x <= 127797 || x >= 127799 && x <= 127868 || x >= 127870 && x <= 127891 || x >= 127904 && x <= 127946 || x >= 127951 && x <= 127955 || x >= 127968 && x <= 127984 || x === 127988 || x >= 127992 && x <= 128062 || x === 128064 || x >= 128066 && x <= 128252 || x >= 128255 && x <= 128317 || x >= 128331 && x <= 128334 || x >= 128336 && x <= 128359 || x === 128378 || x === 128405 || x === 128406 || x === 128420 || x >= 128507 && x <= 128591 || x >= 128640 && x <= 128709 || x === 128716 || x >= 128720 && x <= 128722 || x >= 128725 && x <= 128727 || x >= 128732 && x <= 128735 || x === 128747 || x === 128748 || x >= 128756 && x <= 128764 || x >= 128992 && x <= 129003 || x === 129008 || x >= 129292 && x <= 129338 || x >= 129340 && x <= 129349 || x >= 129351 && x <= 129535 || x >= 129648 && x <= 129660 || x >= 129664 && x <= 129673 || x >= 129679 && x <= 129734 || x >= 129742 && x <= 129756 || x >= 129759 && x <= 129769 || x >= 129776 && x <= 129784 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
  2743. }
  2744. function validate(codePoint) {
  2745. if (!Number.isSafeInteger(codePoint)) throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
  2746. }
  2747. function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
  2748. validate(codePoint);
  2749. if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) return 2;
  2750. return 1;
  2751. }
  2752. const emojiRegex = () => {
  2753. return /[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE89\uDE8F-\uDEC2\uDEC6\uDECE-\uDEDC\uDEDF-\uDEE9]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;
  2754. };
  2755. const segmenter = globalThis.Intl?.Segmenter ? new Intl.Segmenter() : { segment: (str) => str.split("") };
  2756. const defaultIgnorableCodePointRegex = /^\p{Default_Ignorable_Code_Point}$/u;
  2757. function stringWidth$1(string, options = {}) {
  2758. if (typeof string !== "string" || string.length === 0) return 0;
  2759. const { ambiguousIsNarrow = true, countAnsiEscapeCodes = false } = options;
  2760. if (!countAnsiEscapeCodes) string = stripAnsi(string);
  2761. if (string.length === 0) return 0;
  2762. let width = 0;
  2763. const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
  2764. for (const { segment: character } of segmenter.segment(string)) {
  2765. const codePoint = character.codePointAt(0);
  2766. if (codePoint <= 31 || codePoint >= 127 && codePoint <= 159) continue;
  2767. if (codePoint >= 8203 && codePoint <= 8207 || codePoint === 65279) continue;
  2768. if (codePoint >= 768 && codePoint <= 879 || codePoint >= 6832 && codePoint <= 6911 || codePoint >= 7616 && codePoint <= 7679 || codePoint >= 8400 && codePoint <= 8447 || codePoint >= 65056 && codePoint <= 65071) continue;
  2769. if (codePoint >= 55296 && codePoint <= 57343) continue;
  2770. if (codePoint >= 65024 && codePoint <= 65039) continue;
  2771. if (defaultIgnorableCodePointRegex.test(character)) continue;
  2772. if (emojiRegex().test(character)) {
  2773. width += 2;
  2774. continue;
  2775. }
  2776. width += eastAsianWidth(codePoint, eastAsianWidthOptions);
  2777. }
  2778. return width;
  2779. }
  2780. function isUnicodeSupported() {
  2781. const { env } = process$1;
  2782. const { TERM, TERM_PROGRAM } = env;
  2783. if (process$1.platform !== "win32") return TERM !== "linux";
  2784. return Boolean(env.WT_SESSION) || Boolean(env.TERMINUS_SUBLIME) || env.ConEmuTask === "{cmd::Cmder}" || TERM_PROGRAM === "Terminus-Sublime" || TERM_PROGRAM === "vscode" || TERM === "xterm-256color" || TERM === "alacritty" || TERM === "rxvt-unicode" || TERM === "rxvt-unicode-256color" || env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
  2785. }
  2786. const TYPE_COLOR_MAP = {
  2787. info: "cyan",
  2788. fail: "red",
  2789. success: "green",
  2790. ready: "green",
  2791. start: "magenta"
  2792. };
  2793. const LEVEL_COLOR_MAP = {
  2794. 0: "red",
  2795. 1: "yellow"
  2796. };
  2797. const unicode = isUnicodeSupported();
  2798. const s = (c, fallback) => unicode ? c : fallback;
  2799. const TYPE_ICONS = {
  2800. error: s("✖", "×"),
  2801. fatal: s("✖", "×"),
  2802. ready: s("✔", "√"),
  2803. warn: s("⚠", "‼"),
  2804. info: s("ℹ", "i"),
  2805. success: s("✔", "√"),
  2806. debug: s("⚙", "D"),
  2807. trace: s("→", "→"),
  2808. fail: s("✖", "×"),
  2809. start: s("◐", "o"),
  2810. log: ""
  2811. };
  2812. function stringWidth(str) {
  2813. if (!(typeof Intl === "object") || !Intl.Segmenter) return stripAnsi$1(str).length;
  2814. return stringWidth$1(str);
  2815. }
  2816. var FancyReporter = class extends BasicReporter {
  2817. formatStack(stack, message, opts) {
  2818. const indent = " ".repeat((opts?.errorLevel || 0) + 1);
  2819. return `
  2820. ${indent}` + parseStack(stack, message).map((line) => " " + line.replace(/^at +/, (m) => colors.gray(m)).replace(/\((.+)\)/, (_, m) => `(${colors.cyan(m)})`)).join(`
  2821. ${indent}`);
  2822. }
  2823. formatType(logObj, isBadge, opts) {
  2824. const typeColor = TYPE_COLOR_MAP[logObj.type] || LEVEL_COLOR_MAP[logObj.level] || "gray";
  2825. if (isBadge) return getBgColor(typeColor)(colors.black(` ${logObj.type.toUpperCase()} `));
  2826. const _type = typeof TYPE_ICONS[logObj.type] === "string" ? TYPE_ICONS[logObj.type] : logObj.icon || logObj.type;
  2827. return _type ? getColor(typeColor)(_type) : "";
  2828. }
  2829. formatLogObj(logObj, opts) {
  2830. const [message, ...additional] = this.formatArgs(logObj.args, opts).split("\n");
  2831. if (logObj.type === "box") return box(characterFormat(message + (additional.length > 0 ? "\n" + additional.join("\n") : "")), {
  2832. title: logObj.title ? characterFormat(logObj.title) : void 0,
  2833. style: logObj.style
  2834. });
  2835. const date = this.formatDate(logObj.date, opts);
  2836. const coloredDate = date && colors.gray(date);
  2837. const isBadge = logObj.badge ?? logObj.level < 2;
  2838. const type = this.formatType(logObj, isBadge, opts);
  2839. const tag = logObj.tag ? colors.gray(logObj.tag) : "";
  2840. let line;
  2841. const left = this.filterAndJoin([type, characterFormat(message)]);
  2842. const right = this.filterAndJoin(opts.columns ? [tag, coloredDate] : [tag]);
  2843. const space = (opts.columns || 0) - stringWidth(left) - stringWidth(right) - 2;
  2844. line = space > 0 && (opts.columns || 0) >= 80 ? left + " ".repeat(space) + right : (right ? `${colors.gray(`[${right}]`)} ` : "") + left;
  2845. line += characterFormat(additional.length > 0 ? "\n" + additional.join("\n") : "");
  2846. if (logObj.type === "trace") {
  2847. const _err = /* @__PURE__ */ new Error("Trace: " + logObj.message);
  2848. line += this.formatStack(_err.stack || "", _err.message);
  2849. }
  2850. return isBadge ? "\n" + line + "\n" : line;
  2851. }
  2852. };
  2853. function characterFormat(str) {
  2854. return str.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m)).replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `);
  2855. }
  2856. function getColor(color = "white") {
  2857. return colors[color] || colors.white;
  2858. }
  2859. function getBgColor(color = "bgWhite") {
  2860. return colors[`bg${color[0].toUpperCase()}${color.slice(1)}`] || colors.bgWhite;
  2861. }
  2862. function createConsola(options = {}) {
  2863. let level = _getDefaultLogLevel();
  2864. if (process.env.CONSOLA_LEVEL) level = Number.parseInt(process.env.CONSOLA_LEVEL) ?? level;
  2865. return createConsola$1({
  2866. level,
  2867. defaults: { level },
  2868. stdout: process.stdout,
  2869. stderr: process.stderr,
  2870. prompt: (...args) => import("./prompt-DYnaB1Nb.mjs").then((m) => m.prompt(...args)),
  2871. reporters: options.reporters || [options.fancy ?? !(T || R) ? new FancyReporter() : new BasicReporter()],
  2872. ...options
  2873. });
  2874. }
  2875. function _getDefaultLogLevel() {
  2876. if (g) return LogLevels.debug;
  2877. if (R) return LogLevels.warn;
  2878. return LogLevels.info;
  2879. }
  2880. createConsola();
  2881. //#endregion
  2882. //#region src/cli/logger.ts
  2883. /**
  2884. * Console logger
  2885. */
  2886. const logger = process.env.ROLLDOWN_TEST ? createTestingLogger() : createConsola({ formatOptions: { date: false } });
  2887. function createTestingLogger() {
  2888. const types = [
  2889. "silent",
  2890. "fatal",
  2891. "error",
  2892. "warn",
  2893. "log",
  2894. "info",
  2895. "success",
  2896. "fail",
  2897. "ready",
  2898. "start",
  2899. "box",
  2900. "debug",
  2901. "trace",
  2902. "verbose"
  2903. ];
  2904. const ret = Object.create(null);
  2905. for (const type of types) ret[type] = (...args) => console.log(...args);
  2906. return ret;
  2907. }
  2908. //#endregion
  2909. //#region src/utils/bindingify-output-options.ts
  2910. function bindingifyOutputOptions(outputOptions) {
  2911. const { dir, format, exports, hashCharacters, sourcemap, sourcemapBaseUrl, sourcemapDebugIds, sourcemapExcludeSources, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, banner, footer, postBanner, postFooter, intro, outro, esModule, globals, paths, generatedCode, file, sanitizeFileName, preserveModules, virtualDirname, legalComments, comments, preserveModulesRoot, manualChunks, topLevelVar, cleanDir, strictExecutionOrder } = outputOptions;
  2912. if (legalComments != null) logger.warn("`legalComments` option is deprecated, please use `comments.legal` instead.");
  2913. const { inlineDynamicImports, advancedChunks } = bindingifyCodeSplitting(outputOptions.codeSplitting, outputOptions.inlineDynamicImports, outputOptions.advancedChunks, manualChunks);
  2914. return {
  2915. dir,
  2916. file: file == null ? void 0 : file,
  2917. format: bindingifyFormat(format),
  2918. exports,
  2919. hashCharacters,
  2920. sourcemap: bindingifySourcemap(sourcemap),
  2921. sourcemapBaseUrl,
  2922. sourcemapDebugIds,
  2923. sourcemapExcludeSources,
  2924. sourcemapIgnoreList: sourcemapIgnoreList ?? /node_modules/,
  2925. sourcemapPathTransform,
  2926. banner: bindingifyAddon(banner),
  2927. footer: bindingifyAddon(footer),
  2928. postBanner: bindingifyAddon(postBanner),
  2929. postFooter: bindingifyAddon(postFooter),
  2930. intro: bindingifyAddon(intro),
  2931. outro: bindingifyAddon(outro),
  2932. extend: outputOptions.extend,
  2933. globals,
  2934. paths,
  2935. generatedCode,
  2936. esModule,
  2937. name,
  2938. assetFileNames: bindingifyAssetFilenames(assetFileNames),
  2939. entryFileNames,
  2940. chunkFileNames,
  2941. plugins: [],
  2942. minify: outputOptions.minify,
  2943. externalLiveBindings: outputOptions.externalLiveBindings,
  2944. inlineDynamicImports,
  2945. dynamicImportInCjs: outputOptions.dynamicImportInCjs,
  2946. manualCodeSplitting: advancedChunks,
  2947. polyfillRequire: outputOptions.polyfillRequire,
  2948. sanitizeFileName,
  2949. preserveModules,
  2950. virtualDirname,
  2951. legalComments,
  2952. comments: bindingifyComments(comments),
  2953. preserveModulesRoot,
  2954. topLevelVar,
  2955. minifyInternalExports: outputOptions.minifyInternalExports,
  2956. cleanDir,
  2957. strictExecutionOrder,
  2958. strict: outputOptions.strict
  2959. };
  2960. }
  2961. function bindingifyAddon(configAddon) {
  2962. if (configAddon == null || configAddon === "") return;
  2963. if (typeof configAddon === "function") return async (chunk) => configAddon(transformRenderedChunk(chunk));
  2964. return configAddon;
  2965. }
  2966. function bindingifyFormat(format) {
  2967. switch (format) {
  2968. case void 0:
  2969. case "es":
  2970. case "esm":
  2971. case "module": return "es";
  2972. case "cjs":
  2973. case "commonjs": return "cjs";
  2974. case "iife": return "iife";
  2975. case "umd": return "umd";
  2976. default: unimplemented(`output.format: ${format}`);
  2977. }
  2978. }
  2979. function bindingifySourcemap(sourcemap) {
  2980. switch (sourcemap) {
  2981. case true: return "file";
  2982. case "inline": return "inline";
  2983. case false:
  2984. case void 0: return;
  2985. case "hidden": return "hidden";
  2986. default: throw new Error(`unknown sourcemap: ${sourcemap}`);
  2987. }
  2988. }
  2989. function bindingifyAssetFilenames(assetFileNames) {
  2990. if (typeof assetFileNames === "function") return (asset) => {
  2991. return assetFileNames({
  2992. name: asset.name,
  2993. names: asset.names,
  2994. originalFileName: asset.originalFileName,
  2995. originalFileNames: asset.originalFileNames,
  2996. source: transformAssetSource(asset.source),
  2997. type: "asset"
  2998. });
  2999. };
  3000. return assetFileNames;
  3001. }
  3002. function bindingifyComments(comments) {
  3003. if (comments == null) return;
  3004. if (typeof comments === "boolean") return comments;
  3005. return comments;
  3006. }
  3007. function bindingifyCodeSplitting(codeSplitting, inlineDynamicImportsOption, advancedChunks, manualChunks) {
  3008. let inlineDynamicImports;
  3009. let effectiveChunksOption;
  3010. if (codeSplitting === false) {
  3011. if (inlineDynamicImportsOption != null) logger.warn("`inlineDynamicImports` option is ignored because `codeSplitting: false` is set.");
  3012. if (manualChunks != null) throw new Error("Invalid configuration: \"output.manualChunks\" cannot be used when \"output.codeSplitting\" is set to false.");
  3013. if (advancedChunks != null) logger.warn("`advancedChunks` option is ignored because `codeSplitting` is set to `false`.");
  3014. return {
  3015. inlineDynamicImports: true,
  3016. advancedChunks: void 0
  3017. };
  3018. } else if (codeSplitting === true) {
  3019. if (inlineDynamicImportsOption != null) logger.warn("`inlineDynamicImports` option is ignored because `codeSplitting: true` is set.");
  3020. } else if (codeSplitting == null) {
  3021. if (inlineDynamicImportsOption != null) {
  3022. logger.warn("`inlineDynamicImports` option is deprecated, please use `codeSplitting: false` instead.");
  3023. inlineDynamicImports = inlineDynamicImportsOption;
  3024. }
  3025. } else {
  3026. effectiveChunksOption = codeSplitting;
  3027. if (inlineDynamicImportsOption != null) logger.warn("`inlineDynamicImports` option is ignored because the `codeSplitting` option is specified.");
  3028. }
  3029. if (inlineDynamicImports === true && manualChunks != null) throw new Error("Invalid value \"true\" for option \"output.inlineDynamicImports\" - this option is not supported for \"output.manualChunks\".");
  3030. if (effectiveChunksOption == null) {
  3031. if (advancedChunks != null) {
  3032. logger.warn("`advancedChunks` option is deprecated, please use `codeSplitting` instead.");
  3033. effectiveChunksOption = advancedChunks;
  3034. }
  3035. } else if (advancedChunks != null) logger.warn("`advancedChunks` option is ignored because the `codeSplitting` option is specified.");
  3036. if (manualChunks != null && effectiveChunksOption != null) logger.warn("`manualChunks` option is ignored because the `codeSplitting` option is specified.");
  3037. else if (manualChunks != null) effectiveChunksOption = { groups: [{ name(moduleId, ctx) {
  3038. return manualChunks(moduleId, { getModuleInfo: (id) => ctx.getModuleInfo(id) });
  3039. } }] };
  3040. let advancedChunksResult;
  3041. if (effectiveChunksOption != null) {
  3042. const { groups, ...restOptions } = effectiveChunksOption;
  3043. advancedChunksResult = {
  3044. ...restOptions,
  3045. groups: groups?.map((group) => {
  3046. const { name, ...restGroup } = group;
  3047. return {
  3048. ...restGroup,
  3049. name: typeof name === "function" ? (id, ctx) => name(id, new ChunkingContextImpl(ctx)) : name
  3050. };
  3051. })
  3052. };
  3053. }
  3054. return {
  3055. inlineDynamicImports,
  3056. advancedChunks: advancedChunksResult
  3057. };
  3058. }
  3059. //#endregion
  3060. //#region src/utils/initialize-parallel-plugins.ts
  3061. async function initializeParallelPlugins(plugins) {
  3062. const pluginInfos = [];
  3063. for (const [index, plugin] of plugins.entries()) if ("_parallel" in plugin) {
  3064. const { fileUrl, options } = plugin._parallel;
  3065. pluginInfos.push({
  3066. index,
  3067. fileUrl,
  3068. options
  3069. });
  3070. }
  3071. if (pluginInfos.length <= 0) return;
  3072. const count = availableParallelism();
  3073. const parallelJsPluginRegistry = new import_binding.ParallelJsPluginRegistry(count);
  3074. const registryId = parallelJsPluginRegistry.id;
  3075. const workers = await initializeWorkers(registryId, count, pluginInfos);
  3076. const stopWorkers = async () => {
  3077. await Promise.all(workers.map((worker) => worker.terminate()));
  3078. };
  3079. return {
  3080. registry: parallelJsPluginRegistry,
  3081. stopWorkers
  3082. };
  3083. }
  3084. function initializeWorkers(registryId, count, pluginInfos) {
  3085. return Promise.all(Array.from({ length: count }, (_, i) => initializeWorker(registryId, pluginInfos, i)));
  3086. }
  3087. async function initializeWorker(registryId, pluginInfos, threadNumber) {
  3088. const urlString = import.meta.resolve("#parallel-plugin-worker");
  3089. const workerData = {
  3090. registryId,
  3091. pluginInfos,
  3092. threadNumber
  3093. };
  3094. let worker;
  3095. try {
  3096. worker = new Worker(new URL(urlString), { workerData });
  3097. worker.unref();
  3098. await new Promise((resolve, reject) => {
  3099. worker.once("message", async (message) => {
  3100. if (message.type === "error") reject(message.error);
  3101. else resolve();
  3102. });
  3103. });
  3104. return worker;
  3105. } catch (e) {
  3106. worker?.terminate();
  3107. throw e;
  3108. }
  3109. }
  3110. const availableParallelism = () => {
  3111. let availableParallelism = 1;
  3112. try {
  3113. availableParallelism = os.availableParallelism();
  3114. } catch {
  3115. const cpus = os.cpus();
  3116. if (Array.isArray(cpus) && cpus.length > 0) availableParallelism = cpus.length;
  3117. }
  3118. return Math.min(availableParallelism, 8);
  3119. };
  3120. //#endregion
  3121. //#region src/utils/create-bundler-option.ts
  3122. async function createBundlerOptions(inputOptions, outputOptions, watchMode) {
  3123. const inputPlugins = await normalizePluginOption(inputOptions.plugins);
  3124. const outputPlugins = await normalizePluginOption(outputOptions.plugins);
  3125. const logLevel = inputOptions.logLevel || "info";
  3126. const onLog = getLogger(getObjectPlugins(inputPlugins), getOnLog(inputOptions, logLevel), logLevel, watchMode);
  3127. outputOptions = PluginDriver.callOutputOptionsHook([...inputPlugins, ...outputPlugins], outputOptions, onLog, logLevel, watchMode);
  3128. const hookOutputPlugins = await normalizePluginOption(outputOptions.plugins);
  3129. const normalizedInputPlugins = normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX);
  3130. const normalizedOutputPlugins = normalizePlugins(hookOutputPlugins, ANONYMOUS_OUTPUT_PLUGIN_PREFIX);
  3131. let plugins = [...normalizedInputPlugins, ...checkOutputPluginOption(normalizedOutputPlugins, onLog)];
  3132. const parallelPluginInitResult = await initializeParallelPlugins(plugins);
  3133. if (inputOptions.experimental?.strictExecutionOrder !== void 0) console.warn("`experimental.strictExecutionOrder` has been stabilized and moved to `output.strictExecutionOrder`. Please update your configuration.");
  3134. try {
  3135. return {
  3136. bundlerOptions: {
  3137. inputOptions: bindingifyInputOptions(plugins, inputOptions, outputOptions, normalizedInputPlugins, normalizedOutputPlugins, onLog, logLevel, watchMode),
  3138. outputOptions: bindingifyOutputOptions(outputOptions),
  3139. parallelPluginsRegistry: parallelPluginInitResult?.registry
  3140. },
  3141. inputOptions,
  3142. onLog,
  3143. stopWorkers: parallelPluginInitResult?.stopWorkers
  3144. };
  3145. } catch (e) {
  3146. await parallelPluginInitResult?.stopWorkers();
  3147. throw e;
  3148. }
  3149. }
  3150. //#endregion
  3151. //#region src/api/rolldown/rolldown-build.ts
  3152. Symbol.asyncDispose ??= Symbol("Symbol.asyncDispose");
  3153. /**
  3154. * The bundle object returned by {@linkcode rolldown} function.
  3155. *
  3156. * @category Programmatic APIs
  3157. */
  3158. var RolldownBuild = class RolldownBuild {
  3159. #inputOptions;
  3160. #bundler;
  3161. #stopWorkers;
  3162. /** @internal */
  3163. static asyncRuntimeShutdown = false;
  3164. /** @hidden should not be used directly */
  3165. constructor(inputOptions) {
  3166. this.#inputOptions = inputOptions;
  3167. this.#bundler = new import_binding.BindingBundler();
  3168. }
  3169. /**
  3170. * Whether the bundle has been closed.
  3171. *
  3172. * If the bundle is closed, calling other methods will throw an error.
  3173. */
  3174. get closed() {
  3175. return this.#bundler.closed;
  3176. }
  3177. /**
  3178. * Generate bundles in-memory.
  3179. *
  3180. * If you directly want to write bundles to disk, use the {@linkcode write} method instead.
  3181. *
  3182. * @param outputOptions The output options.
  3183. * @returns The generated bundle.
  3184. * @throws {@linkcode BundleError} When an error occurs during the build.
  3185. */
  3186. async generate(outputOptions = {}) {
  3187. return this.#build(false, outputOptions);
  3188. }
  3189. /**
  3190. * Generate and write bundles to disk.
  3191. *
  3192. * If you want to generate bundles in-memory, use the {@linkcode generate} method instead.
  3193. *
  3194. * @param outputOptions The output options.
  3195. * @returns The generated bundle.
  3196. * @throws {@linkcode BundleError} When an error occurs during the build.
  3197. */
  3198. async write(outputOptions = {}) {
  3199. return this.#build(true, outputOptions);
  3200. }
  3201. /**
  3202. * Close the bundle and free resources.
  3203. *
  3204. * This method is called automatically when using `using` syntax.
  3205. *
  3206. * @example
  3207. * ```js
  3208. * import { rolldown } from 'rolldown';
  3209. *
  3210. * {
  3211. * using bundle = await rolldown({ input: 'src/main.js' });
  3212. * const output = await bundle.generate({ format: 'esm' });
  3213. * console.log(output);
  3214. * // bundle.close() is called automatically here
  3215. * }
  3216. * ```
  3217. */
  3218. async close() {
  3219. await this.#stopWorkers?.();
  3220. await this.#bundler.close();
  3221. (0, import_binding.shutdownAsyncRuntime)();
  3222. RolldownBuild.asyncRuntimeShutdown = true;
  3223. this.#stopWorkers = void 0;
  3224. }
  3225. /** @hidden documented in close method */
  3226. async [Symbol.asyncDispose]() {
  3227. await this.close();
  3228. }
  3229. /**
  3230. * @experimental
  3231. * @hidden not ready for public usage yet
  3232. */
  3233. get watchFiles() {
  3234. return Promise.resolve(this.#bundler.getWatchFiles());
  3235. }
  3236. async #build(isWrite, outputOptions) {
  3237. validateOption("output", outputOptions);
  3238. await this.#stopWorkers?.();
  3239. const option = await createBundlerOptions(this.#inputOptions, outputOptions, false);
  3240. if (RolldownBuild.asyncRuntimeShutdown) (0, import_binding.startAsyncRuntime)();
  3241. try {
  3242. this.#stopWorkers = option.stopWorkers;
  3243. let output;
  3244. if (isWrite) output = await this.#bundler.write(option.bundlerOptions);
  3245. else output = await this.#bundler.generate(option.bundlerOptions);
  3246. return new RolldownOutputImpl(unwrapBindingResult(output));
  3247. } catch (e) {
  3248. await option.stopWorkers?.();
  3249. throw e;
  3250. }
  3251. }
  3252. };
  3253. //#endregion
  3254. export { getInputCliKeys as a, validateOption as c, getCliSchemaInfo as i, styleText$1 as l, createBundlerOptions as n, getOutputCliKeys as o, logger as r, validateCliOptions as s, RolldownBuild as t, PluginDriver as u };