/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/npm-run-all2@8.0.4/lib/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
/**
 * @module index
 * @author Toru Nagashima
 * @copyright 2015 Toru Nagashima. All rights reserved.
 * See LICENSE file in root directory for full license.
 */
"use strict";const shellQuote=require("shell-quote"),matchTasks=require("./match-tasks"),readPackageJson=require("./read-package-json"),runTasks=require("./run-tasks"),ARGS_PATTERN=/\{(!)?([*@%]|\d+)([^}]+)?}/g,ARGS_UNPACK_PATTERN=/\{(!)?([%])([^}]+)?}/g;function toArray(e){return null==e?[]:Array.isArray(e)?e:[e]}function applyArguments(e,t){const r=Object.create(null);return e.flatMap((e=>{const r=ARGS_UNPACK_PATTERN.exec(e);if(r&&"%"===r[2]){const r=[];for(let n=0,o=t.length;n<o;n++){const t=n+1;r.push(e.replace(ARGS_UNPACK_PATTERN,((e,r,n,o)=>{if(null!=r||null!=o||"%"!==n)throw Error(`Invalid Placeholder: ${e}`);return`{${t}}`})))}return r}return e})).map((e=>e.replace(ARGS_PATTERN,((e,n,o,l)=>{if(null!=n)throw Error(`Invalid Placeholder: ${e}`);if("@"===o)return shellQuote.quote(t);if("*"===o)return shellQuote.quote([t.join(" ")]);const a=parseInt(o,10);if(a>=1&&a<=t.length)return shellQuote.quote([t[a-1]]);if(null!=l){const t=l.slice(0,2);if(":="===t)return r[o]=shellQuote.quote([l.slice(2)]),r[o];if(":-"===t)return shellQuote.quote([l.slice(2)]);throw Error(`Invalid Placeholder: ${e}`)}return null!=r[o]?r[o]:""}))))}function parsePatterns(e,t){const r=toArray(e);return r.some((e=>ARGS_PATTERN.test(e)))?applyArguments(r,t):r}function toOverwriteOptions(e){const t=[];for(const r of Object.keys(e)){const n=e[r];for(const e of Object.keys(n)){const o=n[e];t.push(`--${r}:${e}=${o}`)}}return t}function toConfigOptions(e){return Object.keys(e).map((t=>`--${t}=${e[t]}`))}function maxLength(e,t){return Math.max(t.length,e)}module.exports=function(e,t){const r=t&&t.stdin||null,n=t&&t.stdout||null,o=t&&t.stderr||null,l=t&&t.taskList||null,a=t&&t.config||null,s=t&&t.packageConfig||null,u=t&&t.arguments||[],i=Boolean(t&&t.parallel),c=Boolean(t&&t.silent),p=Boolean(t&&t.continueOnError),f=Boolean(t&&t.printLabel),h=Boolean(t&&t.printName),g=Boolean(t&&t.race),m=i?t&&t.maxParallel||0:1,P=Boolean(t&&t.aggregateOutput),d=t&&t.npmPath;try{const t=parsePatterns(e,u);if(0===t.length)return Promise.resolve(null);if(null!=l&&!1===Array.isArray(l))throw new Error("Invalid options.taskList");if("number"!=typeof m||!(m>=0))throw new Error("Invalid options.maxParallel");if(!i&&P)throw new Error("Invalid options.aggregateOutput; It requires options.parallel");if(!i&&g)throw new Error("Invalid options.race; It requires options.parallel");const A=[].concat(c?["--silent"]:[],s?toOverwriteOptions(s):[],a?toConfigOptions(a):[]);return Promise.resolve().then((()=>null!=l?{taskList:l,packageInfo:null}:readPackageJson())).then((e=>{const l=matchTasks(e.taskList,t),a=l.reduce(maxLength,0);return runTasks(l,{stdin:r,stdout:n,stderr:o,prefixOptions:A,continueOnError:p,labelState:{enabled:f,width:a,lastPrefix:null,lastIsLinebreak:!0},printName:h,packageInfo:e.packageInfo,race:g,maxParallel:m,npmPath:d,aggregateOutput:P})}))}catch(e){return Promise.reject(new Error(e.message))}};
//# sourceMappingURL=/sm/07a2369921aafaaeb7cab337a9f65763affde5c1a7ddea1c31b13dfcbbcded51.map