@shopify/cli
Version:
A CLI tool to build for the Shopify platform
2 lines (1 loc) • 31.4 kB
JavaScript
import{a as vt}from"./chunk-NKQBEFPS.js";import{a as Ee,b as pe,c as ge,e as Ft}from"./chunk-PRVQAHWI.js";import{a as w,c as S,g}from"./chunk-VPRTJUIN.js";var xt=S((ai,Lt)=>{"use strict";g();var A=w("fs"),{Readable:ye}=w("stream"),v=w("path"),{promisify:V}=w("util"),$=Ft(),be=V(A.readdir),Se=V(A.stat),At=V(A.lstat),Re=V(A.realpath),Te="!",kt="READDIRP_RECURSIVE_ERROR",De=new Set(["ENOENT","EPERM","EACCES","ELOOP",kt]),X="files",Wt="directories",C="files_directories",x="all",It=[X,Wt,C,x],Pe=c=>De.has(c.code),[Nt,Fe]=process.versions.node.split(".").slice(0,2).map(c=>Number.parseInt(c,10)),ve=process.platform==="win32"&&(Nt>10||Nt===10&&Fe>=5),Ot=c=>{if(c!==void 0){if(typeof c=="function")return c;if(typeof c=="string"){let t=$(c.trim());return e=>t(e.basename)}if(Array.isArray(c)){let t=[],e=[];for(let s of c){let i=s.trim();i.charAt(0)===Te?e.push($(i.slice(1))):t.push($(i))}return e.length>0?t.length>0?s=>t.some(i=>i(s.basename))&&!e.some(i=>i(s.basename)):s=>!e.some(i=>i(s.basename)):s=>t.some(i=>i(s.basename))}}},M=class c extends ye{static get defaultOptions(){return{root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:X,lstat:!1,depth:2147483648,alwaysStat:!1}}constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark||4096});let e={...c.defaultOptions,...t},{root:s,type:i}=e;this._fileFilter=Ot(e.fileFilter),this._directoryFilter=Ot(e.directoryFilter);let o=e.lstat?At:Se;ve?this._stat=n=>o(n,{bigint:!0}):this._stat=o,this._maxDepth=e.depth,this._wantsDir=[Wt,C,x].includes(i),this._wantsFile=[X,C,x].includes(i),this._wantsEverything=i===x,this._root=v.resolve(s),this._isDirent="Dirent"in A&&!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(s,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let{path:e,depth:s,files:i=[]}=this.parent||{};if(i.length>0){let o=i.splice(0,t).map(n=>this._formatEntry(n,e));for(let n of await Promise.all(o)){if(this.destroyed)return;let r=await this._getEntryType(n);r==="directory"&&this._directoryFilter(n)?(s<=this._maxDepth&&this.parents.push(this._exploreDir(n.fullPath,s+1)),this._wantsDir&&(this.push(n),t--)):(r==="file"||this._includeAsFile(n))&&this._fileFilter(n)&&this._wantsFile&&(this.push(n),t--)}}else{let o=this.parents.pop();if(!o){this.push(null);break}if(this.parent=await o,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let s;try{s=await be(t,this._rdOptions)}catch(i){this._onError(i)}return{files:s,depth:e,path:t}}async _formatEntry(t,e){let s;try{let i=this._isDirent?t.name:t,o=v.resolve(v.join(e,i));s={path:v.relative(this._root,o),fullPath:o,basename:i},s[this._statsProp]=this._isDirent?t:await this._stat(o)}catch(i){this._onError(i)}return s}_onError(t){Pe(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){let e=t&&t[this._statsProp];if(e){if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let s=t.fullPath;try{let i=await Re(s),o=await At(i);if(o.isFile())return"file";if(o.isDirectory()){let n=i.length;if(s.startsWith(i)&&s.substr(n,1)===v.sep){let r=new Error(`Circular symlink detected: "${s}" points to "${i}"`);return r.code=kt,this._onError(r)}return"directory"}}catch(i){this._onError(i)}}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}},D=(c,t={})=>{let e=t.entryType||t.type;if(e==="both"&&(e=C),e&&(t.type=e),c){if(typeof c!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!It.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${It.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=c,new M(t)},Ae=(c,t={})=>new Promise((e,s)=>{let i=[];D(c,t).on("data",o=>i.push(o)).on("end",()=>e(i)).on("error",o=>s(o))});D.promise=Ae;D.ReaddirpStream=M;D.default=D;Lt.exports=D});var Yt=S((Ht,Gt)=>{"use strict";g();Object.defineProperty(Ht,"__esModule",{value:!0});var Vt=Ft(),Ie=vt(),Ct="!",Ne={returnIndex:!1},Oe=c=>Array.isArray(c)?c:[c],ke=(c,t)=>{if(typeof c=="function")return c;if(typeof c=="string"){let e=Vt(c,t);return s=>c===s||e(s)}return c instanceof RegExp?e=>c.test(e):e=>!1},Mt=(c,t,e,s)=>{let i=Array.isArray(e),o=i?e[0]:e;if(!i&&typeof o!="string")throw new TypeError("anymatch: second argument must be a string: got "+Object.prototype.toString.call(o));let n=Ie(o,!1);for(let a=0;a<t.length;a++){let l=t[a];if(l(n))return s?-1:!1}let r=i&&[n].concat(e.slice(1));for(let a=0;a<c.length;a++){let l=c[a];if(i?l(...r):l(n))return s?a:!0}return s?-1:!1},Q=(c,t,e=Ne)=>{if(c==null)throw new TypeError("anymatch: specify first argument");let s=typeof e=="boolean"?{returnIndex:e}:e,i=s.returnIndex||!1,o=Oe(c),n=o.filter(a=>typeof a=="string"&&a.charAt(0)===Ct).map(a=>a.slice(1)).map(a=>Vt(a,s)),r=o.filter(a=>typeof a!="string"||typeof a=="string"&&a.charAt(0)!==Ct).map(a=>ke(a,s));return t==null?(a,l=!1)=>Mt(r,n,a,typeof l=="boolean"?l:!1):Mt(r,n,t,i)};Q.default=Q;Gt.exports=Q});var zt=S((li,We)=>{We.exports=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]});var Ut=S((di,jt)=>{g();jt.exports=zt()});var Bt=S((ui,qt)=>{"use strict";g();var Le=w("path"),xe=Ut(),Ce=new Set(xe);qt.exports=c=>Ce.has(Le.extname(c).slice(1).toLowerCase())});var H=S(u=>{"use strict";g();var{sep:Me}=w("path"),{platform:J}=process,Ve=w("os");u.EV_ALL="all";u.EV_READY="ready";u.EV_ADD="add";u.EV_CHANGE="change";u.EV_ADD_DIR="addDir";u.EV_UNLINK="unlink";u.EV_UNLINK_DIR="unlinkDir";u.EV_RAW="raw";u.EV_ERROR="error";u.STR_DATA="data";u.STR_END="end";u.STR_CLOSE="close";u.FSEVENT_CREATED="created";u.FSEVENT_MODIFIED="modified";u.FSEVENT_DELETED="deleted";u.FSEVENT_MOVED="moved";u.FSEVENT_CLONED="cloned";u.FSEVENT_UNKNOWN="unknown";u.FSEVENT_FLAG_MUST_SCAN_SUBDIRS=1;u.FSEVENT_TYPE_FILE="file";u.FSEVENT_TYPE_DIRECTORY="directory";u.FSEVENT_TYPE_SYMLINK="symlink";u.KEY_LISTENERS="listeners";u.KEY_ERR="errHandlers";u.KEY_RAW="rawEmitters";u.HANDLER_KEYS=[u.KEY_LISTENERS,u.KEY_ERR,u.KEY_RAW];u.DOT_SLASH=`.${Me}`;u.BACK_SLASH_RE=/\\/g;u.DOUBLE_SLASH_RE=/\/\//;u.SLASH_OR_BACK_SLASH_RE=/[/\\]/;u.DOT_RE=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/;u.REPLACER_RE=/^\.[/\\]/;u.SLASH="/";u.SLASH_SLASH="//";u.BRACE_START="{";u.BANG="!";u.ONE_DOT=".";u.TWO_DOTS="..";u.STAR="*";u.GLOBSTAR="**";u.ROOT_GLOBSTAR="/**/*";u.SLASH_GLOBSTAR="/**";u.DIR_SUFFIX="Dir";u.ANYMATCH_OPTS={dot:!0};u.STRING_TYPE="string";u.FUNCTION_TYPE="function";u.EMPTY_STR="";u.EMPTY_FN=()=>{};u.IDENTITY_FN=c=>c;u.isWindows=J==="win32";u.isMacos=J==="darwin";u.isLinux=J==="linux";u.isIBMi=Ve.type()==="OS400"});var Zt=S((Ei,Jt)=>{"use strict";g();var R=w("fs"),E=w("path"),{promisify:k}=w("util"),He=Bt(),{isWindows:Ge,isLinux:Ye,EMPTY_FN:ze,EMPTY_STR:je,KEY_LISTENERS:P,KEY_ERR:Z,KEY_RAW:I,HANDLER_KEYS:Ue,EV_CHANGE:Y,EV_ADD:G,EV_ADD_DIR:qe,EV_ERROR:$t,STR_DATA:Be,STR_END:Ke,BRACE_START:$e,STAR:Xe}=H(),Qe="watch",Je=k(R.open),Xt=k(R.stat),Ze=k(R.lstat),ts=k(R.close),tt=k(R.realpath),es={lstat:Ze,stat:Xt},st=(c,t)=>{c instanceof Set?c.forEach(t):t(c)},N=(c,t,e)=>{let s=c[t];s instanceof Set||(c[t]=s=new Set([s])),s.add(e)},ss=c=>t=>{let e=c[t];e instanceof Set?e.clear():delete c[t]},O=(c,t,e)=>{let s=c[t];s instanceof Set?s.delete(e):s===e&&delete c[t]},Qt=c=>c instanceof Set?c.size===0:!c,z=new Map;function Kt(c,t,e,s,i){let o=(n,r)=>{e(c),i(n,r,{watchedPath:c}),r&&c!==r&&j(E.resolve(c,r),P,E.join(c,r))};try{return R.watch(c,t,o)}catch(n){s(n)}}var j=(c,t,e,s,i)=>{let o=z.get(c);o&&st(o[t],n=>{n(e,s,i)})},is=(c,t,e,s)=>{let{listener:i,errHandler:o,rawEmitter:n}=s,r=z.get(t),a;if(!e.persistent)return a=Kt(c,e,i,o,n),a.close.bind(a);if(r)N(r,P,i),N(r,Z,o),N(r,I,n);else{if(a=Kt(c,e,j.bind(null,t,P),o,j.bind(null,t,I)),!a)return;a.on($t,async l=>{let d=j.bind(null,t,Z);if(r.watcherUnusable=!0,Ge&&l.code==="EPERM")try{let h=await Je(c,"r");await ts(h),d(l)}catch{}else d(l)}),r={listeners:i,errHandlers:o,rawEmitters:n,watcher:a},z.set(t,r)}return()=>{O(r,P,i),O(r,Z,o),O(r,I,n),Qt(r.listeners)&&(r.watcher.close(),z.delete(t),Ue.forEach(ss(r)),r.watcher=void 0,Object.freeze(r))}},et=new Map,rs=(c,t,e,s)=>{let{listener:i,rawEmitter:o}=s,n=et.get(t),r=new Set,a=new Set,l=n&&n.options;return l&&(l.persistent<e.persistent||l.interval>e.interval)&&(r=n.listeners,a=n.rawEmitters,R.unwatchFile(t),n=void 0),n?(N(n,P,i),N(n,I,o)):(n={listeners:i,rawEmitters:o,options:e,watcher:R.watchFile(t,e,(d,h)=>{st(n.rawEmitters,_=>{_(Y,t,{curr:d,prev:h})});let f=d.mtimeMs;(d.size!==h.size||f>h.mtimeMs||f===0)&&st(n.listeners,_=>_(c,d))})},et.set(t,n)),()=>{O(n,P,i),O(n,I,o),Qt(n.listeners)&&(et.delete(t),R.unwatchFile(t),n.options=n.watcher=void 0,Object.freeze(n))}},it=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let s=this.fsw.options,i=E.dirname(t),o=E.basename(t);this.fsw._getWatchedDir(i).add(o);let r=E.resolve(t),a={persistent:s.persistent};e||(e=ze);let l;return s.usePolling?(a.interval=s.enableBinaryInterval&&He(o)?s.binaryInterval:s.interval,l=rs(t,r,a,{listener:e,rawEmitter:this.fsw._emitRaw})):l=is(t,r,a,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw}),l}_handleFile(t,e,s){if(this.fsw.closed)return;let i=E.dirname(t),o=E.basename(t),n=this.fsw._getWatchedDir(i),r=e;if(n.has(o))return;let a=async(d,h)=>{if(this.fsw._throttle(Qe,t,5)){if(!h||h.mtimeMs===0)try{let f=await Xt(t);if(this.fsw.closed)return;let _=f.atimeMs,y=f.mtimeMs;(!_||_<=y||y!==r.mtimeMs)&&this.fsw._emit(Y,t,f),Ye&&r.ino!==f.ino?(this.fsw._closeFile(d),r=f,this.fsw._addPathCloser(d,this._watchWithNodeFs(t,a))):r=f}catch{this.fsw._remove(i,o)}else if(n.has(o)){let f=h.atimeMs,_=h.mtimeMs;(!f||f<=_||_!==r.mtimeMs)&&this.fsw._emit(Y,t,h),r=h}}},l=this._watchWithNodeFs(t,a);if(!(s&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(G,t,0))return;this.fsw._emit(G,t,e)}return l}async _handleSymlink(t,e,s,i){if(this.fsw.closed)return;let o=t.fullPath,n=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let r;try{r=await tt(s)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(n.has(i)?this.fsw._symlinkPaths.get(o)!==r&&(this.fsw._symlinkPaths.set(o,r),this.fsw._emit(Y,s,t.stats)):(n.add(i),this.fsw._symlinkPaths.set(o,r),this.fsw._emit(G,s,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(o))return!0;this.fsw._symlinkPaths.set(o,!0)}_handleRead(t,e,s,i,o,n,r){if(t=E.join(t,je),!s.hasGlob&&(r=this.fsw._throttle("readdir",t,1e3),!r))return;let a=this.fsw._getWatchedDir(s.path),l=new Set,d=this.fsw._readdirp(t,{fileFilter:h=>s.filterPath(h),directoryFilter:h=>s.filterDir(h),depth:0}).on(Be,async h=>{if(this.fsw.closed){d=void 0;return}let f=h.path,_=E.join(t,f);if(l.add(f),!(h.stats.isSymbolicLink()&&await this._handleSymlink(h,t,_,f))){if(this.fsw.closed){d=void 0;return}(f===i||!i&&!a.has(f))&&(this.fsw._incrReadyCount(),_=E.join(o,E.relative(o,_)),this._addToNodeFs(_,e,s,n+1))}}).on($t,this._boundHandleError);return new Promise(h=>d.once(Ke,()=>{if(this.fsw.closed){d=void 0;return}let f=r?r.clear():!1;h(),a.getChildren().filter(_=>_!==t&&!l.has(_)&&(!s.hasGlob||s.filterPath({fullPath:E.resolve(t,_)}))).forEach(_=>{this.fsw._remove(t,_)}),d=void 0,f&&this._handleRead(t,!1,s,i,o,n,r)}))}async _handleDir(t,e,s,i,o,n,r){let a=this.fsw._getWatchedDir(E.dirname(t)),l=a.has(E.basename(t));!(s&&this.fsw.options.ignoreInitial)&&!o&&!l&&(!n.hasGlob||n.globFilter(t))&&this.fsw._emit(qe,t,e),a.add(E.basename(t)),this.fsw._getWatchedDir(t);let d,h,f=this.fsw.options.depth;if((f==null||i<=f)&&!this.fsw._symlinkPaths.has(r)){if(!o&&(await this._handleRead(t,s,n,o,t,i,d),this.fsw.closed))return;h=this._watchWithNodeFs(t,(_,y)=>{y&&y.mtimeMs===0||this._handleRead(_,!1,n,o,t,i,d)})}return h}async _addToNodeFs(t,e,s,i,o){let n=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return n(),!1;let r=this.fsw._getWatchHelpers(t,i);!r.hasGlob&&s&&(r.hasGlob=s.hasGlob,r.globFilter=s.globFilter,r.filterPath=a=>s.filterPath(a),r.filterDir=a=>s.filterDir(a));try{let a=await es[r.statMethod](r.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(r.watchPath,a))return n(),!1;let l=this.fsw.options.followSymlinks&&!t.includes(Xe)&&!t.includes($e),d;if(a.isDirectory()){let h=E.resolve(t),f=l?await tt(t):t;if(this.fsw.closed||(d=await this._handleDir(r.watchPath,a,e,i,o,r,f),this.fsw.closed))return;h!==f&&f!==void 0&&this.fsw._symlinkPaths.set(h,f)}else if(a.isSymbolicLink()){let h=l?await tt(t):t;if(this.fsw.closed)return;let f=E.dirname(r.watchPath);if(this.fsw._getWatchedDir(f).add(r.watchPath),this.fsw._emit(G,r.watchPath,a),d=await this._handleDir(f,a,e,i,t,r,h),this.fsw.closed)return;h!==void 0&&this.fsw._symlinkPaths.set(E.resolve(t),h)}else d=this._handleFile(r.watchPath,a,e);return n(),this.fsw._addPathCloser(t,d),!1}catch(a){if(this.fsw._handleError(a))return n(),t}}};Jt.exports=it});var oe=S((gi,dt)=>{"use strict";g();var ht=w("fs"),p=w("path"),{promisify:lt}=w("util"),F;try{F=w("fsevents")}catch(c){process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR&&console.error(c)}if(F){let c=process.version.match(/v(\d+)\.(\d+)/);if(c&&c[1]&&c[2]){let t=Number.parseInt(c[1],10),e=Number.parseInt(c[2],10);t===8&&e<16&&(F=void 0)}}var{EV_ADD:rt,EV_CHANGE:ns,EV_ADD_DIR:te,EV_UNLINK:U,EV_ERROR:os,STR_DATA:as,STR_END:cs,FSEVENT_CREATED:hs,FSEVENT_MODIFIED:ls,FSEVENT_DELETED:ds,FSEVENT_MOVED:fs,FSEVENT_UNKNOWN:us,FSEVENT_FLAG_MUST_SCAN_SUBDIRS:_s,FSEVENT_TYPE_FILE:ms,FSEVENT_TYPE_DIRECTORY:W,FSEVENT_TYPE_SYMLINK:ne,ROOT_GLOBSTAR:ee,DIR_SUFFIX:ws,DOT_SLASH:se,FUNCTION_TYPE:nt,EMPTY_FN:Es,IDENTITY_FN:ps}=H(),gs=c=>isNaN(c)?{}:{depth:c},at=lt(ht.stat),ys=lt(ht.lstat),ie=lt(ht.realpath),bs={stat:at,lstat:ys},T=new Map,Ss=10,Rs=new Set([69888,70400,71424,72704,73472,131328,131840,262912]),Ts=(c,t)=>({stop:F.watch(c,t)});function Ds(c,t,e,s){let i=p.extname(t)?p.dirname(t):t,o=p.dirname(i),n=T.get(i);Ps(o)&&(i=o);let r=p.resolve(c),a=r!==t,l=(h,f,_)=>{a&&(h=h.replace(t,r)),(h===r||!h.indexOf(r+p.sep))&&e(h,f,_)},d=!1;for(let h of T.keys())if(t.indexOf(p.resolve(h)+p.sep)===0){i=h,n=T.get(i),d=!0;break}return n||d?n.listeners.add(l):(n={listeners:new Set([l]),rawEmitter:s,watcher:Ts(i,(h,f)=>{if(!n.listeners.size||f&_s)return;let _=F.getInfo(h,f);n.listeners.forEach(y=>{y(h,f,_)}),n.rawEmitter(_.event,h,_)})},T.set(i,n)),()=>{let h=n.listeners;if(h.delete(l),!h.size&&(T.delete(i),n.watcher))return n.watcher.stop().then(()=>{n.rawEmitter=n.watcher=void 0,Object.freeze(n)})}}var Ps=c=>{let t=0;for(let e of T.keys())if(e.indexOf(c)===0&&(t++,t>=Ss))return!0;return!1},Fs=()=>F&&T.size<128,ot=(c,t)=>{let e=0;for(;!c.indexOf(t)&&(c=p.dirname(c))!==t;)e++;return e},re=(c,t)=>c.type===W&&t.isDirectory()||c.type===ne&&t.isSymbolicLink()||c.type===ms&&t.isFile(),ct=class{constructor(t){this.fsw=t}checkIgnored(t,e){let s=this.fsw._ignoredPaths;if(this.fsw._isIgnored(t,e))return s.add(t),e&&e.isDirectory()&&s.add(t+ee),!0;s.delete(t),s.delete(t+ee)}addOrChange(t,e,s,i,o,n,r,a){let l=o.has(n)?ns:rt;this.handleEvent(l,t,e,s,i,o,n,r,a)}async checkExists(t,e,s,i,o,n,r,a){try{let l=await at(t);if(this.fsw.closed)return;re(r,l)?this.addOrChange(t,e,s,i,o,n,r,a):this.handleEvent(U,t,e,s,i,o,n,r,a)}catch(l){l.code==="EACCES"?this.addOrChange(t,e,s,i,o,n,r,a):this.handleEvent(U,t,e,s,i,o,n,r,a)}}handleEvent(t,e,s,i,o,n,r,a,l){if(!(this.fsw.closed||this.checkIgnored(e)))if(t===U){let d=a.type===W;(d||n.has(r))&&this.fsw._remove(o,r,d)}else{if(t===rt){if(a.type===W&&this.fsw._getWatchedDir(e),a.type===ne&&l.followSymlinks){let h=l.depth===void 0?void 0:ot(s,i)+1;return this._addToFsEvents(e,!1,!0,h)}this.fsw._getWatchedDir(o).add(r)}let d=a.type===W?t+ws:t;this.fsw._emit(d,e),d===te&&this._addToFsEvents(e,!1,!0)}}_watchWithFsEvents(t,e,s,i){if(this.fsw.closed||this.fsw._isIgnored(t))return;let o=this.fsw.options,r=Ds(t,e,async(a,l,d)=>{if(this.fsw.closed||o.depth!==void 0&&ot(a,e)>o.depth)return;let h=s(p.join(t,p.relative(t,a)));if(i&&!i(h))return;let f=p.dirname(h),_=p.basename(h),y=this.fsw._getWatchedDir(d.type===W?h:f);if(Rs.has(l)||d.event===us)if(typeof o.ignored===nt){let K;try{K=await at(h)}catch{}if(this.fsw.closed||this.checkIgnored(h,K))return;re(d,K)?this.addOrChange(h,a,e,f,y,_,d,o):this.handleEvent(U,h,a,e,f,y,_,d,o)}else this.checkExists(h,a,e,f,y,_,d,o);else switch(d.event){case hs:case ls:return this.addOrChange(h,a,e,f,y,_,d,o);case ds:case fs:return this.checkExists(h,a,e,f,y,_,d,o)}},this.fsw._emitRaw);return this.fsw._emitReady(),r}async _handleFsEventsSymlink(t,e,s,i){if(!(this.fsw.closed||this.fsw._symlinkPaths.has(e))){this.fsw._symlinkPaths.set(e,!0),this.fsw._incrReadyCount();try{let o=await ie(t);if(this.fsw.closed)return;if(this.fsw._isIgnored(o))return this.fsw._emitReady();this.fsw._incrReadyCount(),this._addToFsEvents(o||t,n=>{let r=t;return o&&o!==se?r=n.replace(o,t):n!==se&&(r=p.join(t,n)),s(r)},!1,i)}catch(o){if(this.fsw._handleError(o))return this.fsw._emitReady()}}}emitAdd(t,e,s,i,o){let n=s(t),r=e.isDirectory(),a=this.fsw._getWatchedDir(p.dirname(n)),l=p.basename(n);r&&this.fsw._getWatchedDir(n),!a.has(l)&&(a.add(l),(!i.ignoreInitial||o===!0)&&this.fsw._emit(r?te:rt,n,e))}initWatch(t,e,s,i){if(this.fsw.closed)return;let o=this._watchWithFsEvents(s.watchPath,p.resolve(t||s.watchPath),i,s.globFilter);this.fsw._addPathCloser(e,o)}async _addToFsEvents(t,e,s,i){if(this.fsw.closed)return;let o=this.fsw.options,n=typeof e===nt?e:ps,r=this.fsw._getWatchHelpers(t);try{let a=await bs[r.statMethod](r.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(r.watchPath,a))throw null;if(a.isDirectory()){if(r.globFilter||this.emitAdd(n(t),a,n,o,s),i&&i>o.depth)return;this.fsw._readdirp(r.watchPath,{fileFilter:l=>r.filterPath(l),directoryFilter:l=>r.filterDir(l),...gs(o.depth-(i||0))}).on(as,l=>{if(this.fsw.closed||l.stats.isDirectory()&&!r.filterPath(l))return;let d=p.join(r.watchPath,l.path),{fullPath:h}=l;if(r.followSymlinks&&l.stats.isSymbolicLink()){let f=o.depth===void 0?void 0:ot(d,p.resolve(r.watchPath))+1;this._handleFsEventsSymlink(d,h,n,f)}else this.emitAdd(d,l.stats,n,o,s)}).on(os,Es).on(cs,()=>{this.fsw._emitReady()})}else this.emitAdd(r.watchPath,a,n,o,s),this.fsw._emitReady()}catch(a){(!a||this.fsw._handleError(a))&&(this.fsw._emitReady(),this.fsw._emitReady())}if(o.persistent&&s!==!0)if(typeof e===nt)this.initWatch(void 0,t,r,n);else{let a;try{a=await ie(r.watchPath)}catch{}this.initWatch(a,t,r,n)}}};dt.exports=ct;dt.exports.canUse=Fs});var ni=S(Pt=>{g();var{EventEmitter:vs}=w("events"),Tt=w("fs"),m=w("path"),{promisify:ue}=w("util"),As=xt(),Et=Yt().default,Is=pe(),ft=Ee(),Ns=ge(),Os=vt(),ks=Zt(),ae=oe(),{EV_ALL:ut,EV_READY:Ws,EV_ADD:q,EV_CHANGE:L,EV_UNLINK:ce,EV_ADD_DIR:Ls,EV_UNLINK_DIR:xs,EV_RAW:Cs,EV_ERROR:_t,STR_CLOSE:Ms,STR_END:Vs,BACK_SLASH_RE:Hs,DOUBLE_SLASH_RE:he,SLASH_OR_BACK_SLASH_RE:Gs,DOT_RE:Ys,REPLACER_RE:zs,SLASH:mt,SLASH_SLASH:js,BRACE_START:Us,BANG:pt,ONE_DOT:_e,TWO_DOTS:qs,GLOBSTAR:Bs,SLASH_GLOBSTAR:wt,ANYMATCH_OPTS:gt,STRING_TYPE:Dt,FUNCTION_TYPE:Ks,EMPTY_STR:yt,EMPTY_FN:$s,isWindows:Xs,isMacos:Qs,isIBMi:Js}=H(),Zs=ue(Tt.stat),ti=ue(Tt.readdir),bt=(c=[])=>Array.isArray(c)?c:[c],me=(c,t=[])=>(c.forEach(e=>{Array.isArray(e)?me(e,t):t.push(e)}),t),le=c=>{let t=me(bt(c));if(!t.every(e=>typeof e===Dt))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(we)},de=c=>{let t=c.replace(Hs,mt),e=!1;for(t.startsWith(js)&&(e=!0);t.match(he);)t=t.replace(he,mt);return e&&(t=mt+t),t},we=c=>de(m.normalize(de(c))),fe=(c=yt)=>t=>typeof t!==Dt?t:we(m.isAbsolute(t)?t:m.join(c,t)),ei=(c,t)=>m.isAbsolute(c)?c:c.startsWith(pt)?pt+m.join(t,c.slice(1)):m.join(t,c),b=(c,t)=>c[t]===void 0,St=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==_e&&t!==qs&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let s=this.path;try{await ti(s)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(s),m.basename(s))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;if(t)return[...t.values()]}dispose(){this.items.clear(),delete this.path,delete this._removeWatcher,delete this.items,Object.freeze(this)}},si="stat",ii="lstat",Rt=class{constructor(t,e,s,i){this.fsw=i,this.path=t=t.replace(zs,yt),this.watchPath=e,this.fullWatchPath=m.resolve(e),this.hasGlob=e!==t,t===yt&&(this.hasGlob=!1),this.globSymlink=this.hasGlob&&s?void 0:!1,this.globFilter=this.hasGlob?Et(t,void 0,gt):!1,this.dirParts=this.getDirParts(t),this.dirParts.forEach(o=>{o.length>1&&o.pop()}),this.followSymlinks=s,this.statMethod=s?si:ii}checkGlobSymlink(t){return this.globSymlink===void 0&&(this.globSymlink=t.fullParentDir===this.fullWatchPath?!1:{realPath:t.fullParentDir,linkPath:this.fullWatchPath}),this.globSymlink?t.fullPath.replace(this.globSymlink.realPath,this.globSymlink.linkPath):t.fullPath}entryPath(t){return m.join(this.watchPath,m.relative(this.watchPath,this.checkGlobSymlink(t)))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let s=this.entryPath(t);return(this.hasGlob&&typeof this.globFilter===Ks?this.globFilter(s):!0)&&this.fsw._isntIgnored(s,e)&&this.fsw._hasReadPermissions(e)}getDirParts(t){if(!this.hasGlob)return[];let e=[];return(t.includes(Us)?Ns.expand(t):[t]).forEach(i=>{e.push(m.relative(this.watchPath,i).split(Gs))}),e}filterDir(t){if(this.hasGlob){let e=this.getDirParts(this.checkGlobSymlink(t)),s=!1;this.unmatchedGlob=!this.dirParts.some(i=>i.every((o,n)=>(o===Bs&&(s=!0),s||!e[0][n]||Et(o,e[0][n],gt))))}return!this.unmatchedGlob&&this.fsw._isntIgnored(this.entryPath(t),t.stats)}},B=class extends vs{constructor(t){super();let e={};t&&Object.assign(e,t),this._watched=new Map,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._symlinkPaths=new Map,this._streams=new Set,this.closed=!1,b(e,"persistent")&&(e.persistent=!0),b(e,"ignoreInitial")&&(e.ignoreInitial=!1),b(e,"ignorePermissionErrors")&&(e.ignorePermissionErrors=!1),b(e,"interval")&&(e.interval=100),b(e,"binaryInterval")&&(e.binaryInterval=300),b(e,"disableGlobbing")&&(e.disableGlobbing=!1),e.enableBinaryInterval=e.binaryInterval!==e.interval,b(e,"useFsEvents")&&(e.useFsEvents=!e.usePolling),ae.canUse()||(e.useFsEvents=!1),b(e,"usePolling")&&!e.useFsEvents&&(e.usePolling=Qs),Js&&(e.usePolling=!0);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let a=i.toLowerCase();a==="false"||a==="0"?e.usePolling=!1:a==="true"||a==="1"?e.usePolling=!0:e.usePolling=!!a}let o=process.env.CHOKIDAR_INTERVAL;o&&(e.interval=Number.parseInt(o,10)),b(e,"atomic")&&(e.atomic=!e.usePolling&&!e.useFsEvents),e.atomic&&(this._pendingUnlinks=new Map),b(e,"followSymlinks")&&(e.followSymlinks=!0),b(e,"awaitWriteFinish")&&(e.awaitWriteFinish=!1),e.awaitWriteFinish===!0&&(e.awaitWriteFinish={});let n=e.awaitWriteFinish;n&&(n.stabilityThreshold||(n.stabilityThreshold=2e3),n.pollInterval||(n.pollInterval=100),this._pendingWrites=new Map),e.ignored&&(e.ignored=bt(e.ignored));let r=0;this._emitReady=()=>{r++,r>=this._readyCount&&(this._emitReady=$s,this._readyEmitted=!0,process.nextTick(()=>this.emit(Ws)))},this._emitRaw=(...a)=>this.emit(Cs,...a),this._readyEmitted=!1,this.options=e,e.useFsEvents?this._fsEventsHandler=new ae(this):this._nodeFsHandler=new ks(this),Object.freeze(e)}add(t,e,s){let{cwd:i,disableGlobbing:o}=this.options;this.closed=!1;let n=le(t);return i&&(n=n.map(r=>{let a=ei(r,i);return o||!ft(r)?a:Os(a)})),n=n.filter(r=>r.startsWith(pt)?(this._ignoredPaths.add(r.slice(1)),!1):(this._ignoredPaths.delete(r),this._ignoredPaths.delete(r+wt),this._userIgnored=void 0,!0)),this.options.useFsEvents&&this._fsEventsHandler?(this._readyCount||(this._readyCount=n.length),this.options.persistent&&(this._readyCount+=n.length),n.forEach(r=>this._fsEventsHandler._addToFsEvents(r))):(this._readyCount||(this._readyCount=0),this._readyCount+=n.length,Promise.all(n.map(async r=>{let a=await this._nodeFsHandler._addToNodeFs(r,!s,0,0,e);return a&&this._emitReady(),a})).then(r=>{this.closed||r.filter(a=>a).forEach(a=>{this.add(m.dirname(a),m.basename(e||a))})})),this}unwatch(t){if(this.closed)return this;let e=le(t),{cwd:s}=this.options;return e.forEach(i=>{!m.isAbsolute(i)&&!this._closers.has(i)&&(s&&(i=m.join(s,i)),i=m.resolve(i)),this._closePath(i),this._ignoredPaths.add(i),this._watched.has(i)&&this._ignoredPaths.add(i+wt),this._userIgnored=void 0}),this}close(){if(this.closed)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(s=>{let i=s();i instanceof Promise&&t.push(i)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),["closers","watched","streams","symlinkPaths","throttled"].forEach(e=>{this[`_${e}`].clear()}),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,s)=>{let i=this.options.cwd?m.relative(this.options.cwd,s):s;t[i||_e]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(...e),t!==_t&&this.emit(ut,...e)}async _emit(t,e,s,i,o){if(this.closed)return;let n=this.options;Xs&&(e=m.normalize(e)),n.cwd&&(e=m.relative(n.cwd,e));let r=[t,e];o!==void 0?r.push(s,i,o):i!==void 0?r.push(s,i):s!==void 0&&r.push(s);let a=n.awaitWriteFinish,l;if(a&&(l=this._pendingWrites.get(e)))return l.lastChange=new Date,this;if(n.atomic){if(t===ce)return this._pendingUnlinks.set(e,r),setTimeout(()=>{this._pendingUnlinks.forEach((d,h)=>{this.emit(...d),this.emit(ut,...d),this._pendingUnlinks.delete(h)})},typeof n.atomic=="number"?n.atomic:100),this;t===q&&this._pendingUnlinks.has(e)&&(t=r[0]=L,this._pendingUnlinks.delete(e))}if(a&&(t===q||t===L)&&this._readyEmitted){let d=(h,f)=>{h?(t=r[0]=_t,r[1]=h,this.emitWithAll(t,r)):f&&(r.length>2?r[2]=f:r.push(f),this.emitWithAll(t,r))};return this._awaitWriteFinish(e,a.stabilityThreshold,t,d),this}if(t===L&&!this._throttle(L,e,50))return this;if(n.alwaysStat&&s===void 0&&(t===q||t===Ls||t===L)){let d=n.cwd?m.join(n.cwd,e):e,h;try{h=await Zs(d)}catch{}if(!h||this.closed)return;r.push(h)}return this.emitWithAll(t,r),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(_t,t),t||this.closed}_throttle(t,e,s){this._throttled.has(t)||this._throttled.set(t,new Map);let i=this._throttled.get(t),o=i.get(e);if(o)return o.count++,!1;let n,r=()=>{let l=i.get(e),d=l?l.count:0;return i.delete(e),clearTimeout(n),l&&clearTimeout(l.timeoutObject),d};n=setTimeout(r,s);let a={timeoutObject:n,clear:r,count:0};return i.set(e,a),a}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,s,i){let o,n=t;this.options.cwd&&!m.isAbsolute(t)&&(n=m.join(this.options.cwd,t));let r=new Date,a=l=>{Tt.stat(n,(d,h)=>{if(d||!this._pendingWrites.has(t)){d&&d.code!=="ENOENT"&&i(d);return}let f=Number(new Date);l&&h.size!==l.size&&(this._pendingWrites.get(t).lastChange=f);let _=this._pendingWrites.get(t);f-_.lastChange>=e?(this._pendingWrites.delete(t),i(void 0,h)):o=setTimeout(a,this.options.awaitWriteFinish.pollInterval,h)})};this._pendingWrites.has(t)||(this._pendingWrites.set(t,{lastChange:r,cancelWait:()=>(this._pendingWrites.delete(t),clearTimeout(o),s)}),o=setTimeout(a,this.options.awaitWriteFinish.pollInterval))}_getGlobIgnored(){return[...this._ignoredPaths.values()]}_isIgnored(t,e){if(this.options.atomic&&Ys.test(t))return!0;if(!this._userIgnored){let{cwd:s}=this.options,i=this.options.ignored,o=i&&i.map(fe(s)),n=bt(o).filter(a=>typeof a===Dt&&!ft(a)).map(a=>a+wt),r=this._getGlobIgnored().map(fe(s)).concat(o,n);this._userIgnored=Et(r,void 0,gt)}return this._userIgnored([t,e])}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t,e){let s=e||this.options.disableGlobbing||!ft(t)?t:Is(t),i=this.options.followSymlinks;return new Rt(t,s,i,this)}_getWatchedDir(t){this._boundRemove||(this._boundRemove=this._remove.bind(this));let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new St(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){if(this.options.ignorePermissionErrors)return!0;let s=(t&&Number.parseInt(t.mode,10))&511;return!!(4&Number.parseInt(s.toString(8)[0],10))}_remove(t,e,s){let i=m.join(t,e),o=m.resolve(i);if(s=s??(this._watched.has(i)||this._watched.has(o)),!this._throttle("remove",i,100))return;!s&&!this.options.useFsEvents&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(i).getChildren().forEach(f=>this._remove(i,f));let a=this._getWatchedDir(t),l=a.has(e);a.remove(e),this._symlinkPaths.has(o)&&this._symlinkPaths.delete(o);let d=i;if(this.options.cwd&&(d=m.relative(this.options.cwd,i)),this.options.awaitWriteFinish&&this._pendingWrites.has(d)&&this._pendingWrites.get(d).cancelWait()===q)return;this._watched.delete(i),this._watched.delete(o);let h=s?xs:ce;l&&!this._isIgnored(i)&&this._emit(h,i),this.options.useFsEvents||this._closePath(i)}_closePath(t){this._closeFile(t);let e=m.dirname(t);this._getWatchedDir(e).remove(m.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(s=>s()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let s=this._closers.get(t);s||(s=[],this._closers.set(t,s)),s.push(e)}_readdirp(t,e){if(this.closed)return;let s={type:ut,alwaysStat:!0,lstat:!0,...e},i=As(t,s);return this._streams.add(i),i.once(Ms,()=>{i=void 0}),i.once(Vs,()=>{i&&(this._streams.delete(i),i=void 0)}),i}};Pt.FSWatcher=B;var ri=(c,t)=>{let e=new B(t);return e.add(c),e};Pt.watch=ri});export default ni();