/**
 * Minified by jsDelivr using Terser v5.37.0.
 * Original file: /npm/package-hash@4.0.0/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";const cp=require("child_process"),path=require("path"),{promisify:promisify}=require("util"),fs=require("graceful-fs"),flattenDeep=require("lodash.flattendeep"),hasha=require("hasha"),releaseZalgo=require("release-zalgo"),PACKAGE_FILE=require.resolve("./package.json"),TEN_MEBIBYTE=10485760,execFile=promisify(cp.execFile),readFile={async:promisify(fs.readFile),sync:fs.readFileSync},tryReadFile={async:e=>readFile.async(e).catch((()=>null)),sync(e){try{return fs.readFileSync(e)}catch(e){return null}}},tryExecFile={async:(e,r,t)=>execFile(e,r,t).then((({stdout:e})=>e)).catch((()=>null)),sync(e,r,t){try{return cp.execFileSync(e,r,t)}catch(e){return null}}},git={tryGetRef(e,r,t){const n=/^ref: (.+)$/.exec(t.toString("utf8").trim());return n?e.run(tryReadFile,path.join(r,".git",n[1])):null},tryGetDiff:(e,r)=>e.run(tryExecFile,"git",["--no-pager","diff","HEAD","--no-color","--no-ext-diff"],{cwd:r,maxBuffer:10485760,env:Object.assign({},process.env,{GIT_DIR:path.join(r,".git")}),stdio:["ignore","pipe","ignore"]})};function addPackageData(e,r){const t=path.dirname(r);return e.all([t,e.run(readFile,r),e.run(tryReadFile,path.join(t,".git","HEAD")).then((r=>r?e.all([e.run(tryReadFile,path.join(t,".git","packed-refs")),git.tryGetRef(e,t,r),git.tryGetDiff(e,t)]).then((e=>[r].concat(e.filter(Boolean)))):[]))])}function computeHash(e,r,t,n){const a=[];if(t&&a.push(t),void 0!==n)if(Buffer.isBuffer(n)||"string"==typeof n)a.push(n);else{if("object"!=typeof n||null===n)throw new TypeError("Salt must be an Array, Buffer, Object or string");a.push(JSON.stringify(n))}return e.all(r.map((r=>addPackageData(e,r)))).then((e=>hasha(flattenDeep([a,e]),{algorithm:"sha256"})))}let ownHash=null,ownHashPromise=null;function run(e,r,t){return ownHash?r===PACKAGE_FILE&&void 0===t?e.returns(ownHash.toString("hex")):(r=Array.isArray(r)?r:[r],computeHash(e,r,ownHash,t)):e.run({async:()=>(ownHashPromise||(ownHashPromise=computeHash(e,[PACKAGE_FILE])),ownHashPromise),sync:()=>computeHash(e,[PACKAGE_FILE])}).then((n=>(ownHash=Buffer.from(n,"hex"),ownHashPromise=null,run(e,r,t))))}module.exports=(e,r)=>{try{return run(releaseZalgo.async(),e,r)}catch(e){return Promise.reject(e)}},module.exports.sync=(e,r)=>{const t=run(releaseZalgo.sync(),e,r);return releaseZalgo.unwrapSync(t)};
//# sourceMappingURL=/sm/32e6d4cc6b83827e225d76a6ff55b1019675a2c17a929aef8b9bb797ec22bca6.map