/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@tapjs/processinfo@3.1.9/dist/commonjs/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,s,t,r){void 0===r&&(r=t);var i=Object.getOwnPropertyDescriptor(s,t);i&&!("get"in i?!s.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return s[t]}}),Object.defineProperty(e,r,i)}:function(e,s,t,r){void 0===r&&(r=t),e[r]=s[t]}),__exportStar=this&&this.__exportStar||function(e,s){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(s,t)||__createBinding(s,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProcessInfo=void 0;const child_process_js_1=require("./child_process.js");__exportStar(require("./child_process.js"),exports),__exportStar(require("./process-info-node.js"),exports);const fs_1=require("fs"),promises_1=require("fs/promises"),path_1=require("path"),get_exclude_js_1=require("./get-exclude.js"),json_file_js_1=require("./json-file.js"),process_info_node_js_1=require("./process-info-node.js"),p=process,tryStat=async(e,s)=>{s.set(e,await(0,promises_1.stat)(e).catch((()=>null)))};class ProcessInfo{dir;exclude;roots=new Set;uuids=new Map;files=new Map;pendingRoot=new Map;pendingParent=new Map;externalIDs=new Map;static async load({dir:e=(0,path_1.resolve)(p.cwd(),".tap/processinfo"),exclude:s=/(^|\\|\/)node_modules(\\|\/|$)/}){const t=new ProcessInfo({dir:e,exclude:s});return await t.load(),t}static loadSync({dir:e=(0,path_1.resolve)(p.cwd(),".tap/processinfo"),exclude:s=/(^|\\|\/)node_modules(\\|\/|$)/}){const t=new ProcessInfo({dir:e,exclude:s});return t.loadSync(),t}constructor({dir:e=(0,path_1.resolve)(p.cwd(),".tap/processinfo"),exclude:s=/(^|\\|\/)node_modules(\\|\/|$)/}={}){this.dir=e,this.exclude=s}clear(){this.roots.clear(),this.files.clear(),this.uuids.clear(),this.externalIDs.clear()}async save(){await(0,promises_1.mkdir)(this.dir,{recursive:!0});const e=[];for(const[s,t]of this.uuids.entries()){const r=`${this.dir}/${s}.json`;e.push((0,promises_1.writeFile)(r,JSON.stringify(t)+"\n","utf8"))}await Promise.all(e)}async saveSync(){(0,fs_1.mkdirSync)(this.dir,{recursive:!0});for(const[e,s]of this.uuids.entries()){const t=`${this.dir}/${e}.json`;(0,fs_1.writeFileSync)(t,JSON.stringify(s)+"\n","utf8")}}async erase(){this.clear(),await(0,promises_1.rm)(this.dir,{recursive:!0})}eraseSync(){this.clear(),(0,fs_1.rmSync)(this.dir,{recursive:!0})}async load(){const e=[];for(const s of await(0,promises_1.readdir)(this.dir).catch((()=>[]))){const t=(0,path_1.basename)(s,".json");if(this.uuids.has(t))continue;const r=(0,path_1.resolve)(this.dir,s);e.push((0,json_file_js_1.safeJSON)(r).then((e=>{e.uuid&&e.uuid===t&&new process_info_node_js_1.ProcessInfoNode(e).link(this)})))}return await Promise.all(e),this}loadSync(){let e;try{e=(0,fs_1.readdirSync)(this.dir)}catch(s){e=[]}for(const s of e){const e=(0,path_1.basename)(s,".json");if(this.uuids.has(e))continue;const t=(0,path_1.resolve)(this.dir,s),r=(0,json_file_js_1.safeJSONSync)(t);r.uuid&&r.uuid===e&&new process_info_node_js_1.ProcessInfoNode(r).link(this)}return this}#e(e,s,t){const r=[];for(const i of e.files){if(t.test(i))continue;if(s.has(i))continue;r.push(tryStat(i,s));const o=e.sources[i];if(o)for(const e of o)s.has(e)||r.push(tryStat(e,s))}for(const i of e.descendants??[])r.push(...this.#e(i,s,t));return r}#s(e,s,t){const r=Date.parse(e.date);for(const i of e.files){if(t.test(i))continue;const o=s.get(i);if(!o)return!0;if(!(Number(o.mtime)>r))continue;const n=e.sources[i];if(!n?.length)return!0;for(const e of n){const t=s.get(e);if(!t||Number(t.mtime)>r)return!0}}for(const r of e.descendants??[])if(this.#s(r,s,t))return!0;return!1}async externalIDsChanged(e=()=>!0){const s=(0,get_exclude_js_1.getExclude)("_TAPJS_PROCESSINFO_EXCLUDE_",!1),t=new Map,r=[],i=new Map;for(const[t,o]of this.externalIDs.entries())e(t,o)&&r.push(...this.#e(o,i,s));await Promise.all(r);for(const[r,o]of this.externalIDs.entries())e(r,o)&&this.#s(o,i,s)&&t.set(r,o);return t}static get Node(){return process_info_node_js_1.ProcessInfoNode}static get ProcessInfo(){return ProcessInfo}static get spawn(){return child_process_js_1.spawn}static get spawnSync(){return child_process_js_1.spawnSync}static get exec(){return child_process_js_1.exec}static get execSync(){return child_process_js_1.execSync}static get execFile(){return child_process_js_1.execFile}static get execFileSync(){return child_process_js_1.execFileSync}static get fork(){return child_process_js_1.fork}}exports.ProcessInfo=ProcessInfo;
//# sourceMappingURL=/sm/6cdcab851ce8bad47f40eef8c24788f45733f6c81a5d909acb02d6d8987abce2.map