`.charCodeAt(),a=typeof e=="string"?"\r":"\r".charCodeAt();return e[e.length-1]===t&&(e=e.slice(0,e.length-1)),e[e.length-1]===a&&(e=e.slice(0,e.length-1)),e}});var gh=O((FD,ki)=>{"use strict";var Ti=require("path"),vh=zc(),bh=e=>{e={cwd:process.cwd(),path:process.env[vh()],execPath:process.execPath,...e};let t,a=Ti.resolve(e.cwd),n=[];for(;t!==a;)n.push(Ti.join(a,"node_modules/.bin")),t=a,a=Ti.resolve(a,"..");let i=Ti.resolve(e.cwd,e.execPath,"..");return n.push(i),n.concat(e.path).join(Ti.delimiter)};ki.exports=bh;ki.exports.default=bh;ki.exports.env=e=>{e={env:process.env,...e};let t={...e.env},a=vh({env:t});return e.path=t[a],t[a]=ki.exports(e),t}});var yh=O((PD,Xc)=>{"use strict";var xh=(e,t)=>{for(let a of Reflect.ownKeys(t))Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(t,a));return e};Xc.exports=xh;Xc.exports.default=xh});var Eh=O((OD,eo)=>{"use strict";var NT=yh(),Qr=new WeakMap,wh=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let a,n=0,i=e.displayName||e.name||"<anonymous>",r=function(...o){if(Qr.set(r,++n),n===1)a=e.apply(this,o),e=null;else if(t.throw===!0)throw new Error(`Function\`${i}\` can only be called once`);returna};returnNT(r,e),Qr.set(r,n),r};eo.exports=wh;eo.exports.default=wh;eo.exports.callCount=e=>{if(!Qr.has(e))thrownewError(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);returnQr.get(e)}});varSh=O(to=>{"use strict";Object.defineProperty(to,"__esModule",{value:!0});to.SIGNALS=void0;varjT=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Background process cannot read terminal input",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"User interruption with CTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:
${n.message}`:m,x=[v,t,e].filter(Boolean).join(`
`);return h?(n.originalMessage=n.message,n.message=x):n=new Error(x),n.shortMessage=v,n.command=o,n.escapedCommand=s,n.exitCode=r,n.signal=i,n.signalDescription=p,n.stdout=e,n.stderr=t,a!==void 0&&(n.all=a),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!l,n.isCanceled=u,n.killed=c&&!l,n};kh.exports=t4});var Oh=O((MD,Yc)=>{"use strict";var no=["stdin","stdout","stderr"],a4=e=>no.some(t=>e[t]!==void 0),Ph=e=>{if(!e)return;let{stdio:t}=e;if(t===void 0)return no.map(n=>e[n]);if(a4(e))throw new Error(`It'snotpossibletoprovide\`stdio\` in combination with one of ${no.map(n=>`\`${n}\``).join(", ")}`);if(typeoft=="string")returnt;if(!Array.isArray(t))thrownewTypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeoft}\``);leta=Math.max(t.length,no.length);returnArray.from({length:a},(n,i)=>t[i])};Yc.exports=Ph;Yc.exports.node=e=>{lett=Ph(e);returnt==="ipc"?"ipc":t===void0||typeoft=="string"?[t,t,t,"ipc"]:t.includes("ipc")?t:[...t,"ipc"]}});varRh=O((DD,io)=>{io.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&io.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&io.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});vareu=O((zD,Fn)=>{varGe=global.process,qa=function(e){returne&&typeofe=="object"&&typeofe.removeListener=="function"&&typeofe.emit=="function"&&typeofe.reallyExit=="function"&&typeofe.listeners=="function"&&typeofe.kill=="function"&&typeofe.pid=="number"&&typeofe.on=="function"};qa(Ge)?(Bh=require("assert"),Tn=Rh(),Nh=/^win/i.test(Ge.platform),Fi=require("events"),typeofFi!="function"&&(Fi=Fi.EventEmitter),Ge.__signal_exit_emitter__?at=Ge.__signal_exit_emitter__:(at=Ge.__signal_exit_emitter__=newFi,at.count=0,at.emitted={}),at.infinite||(at.setMaxListeners(1/0),at.infinite=!0),Fn.exports=function(e,t){if(!qa(global.process))returnfunction(){};Bh.equal(typeofe,"function","a callback must be provided for exit handler"),kn===!1&&Kc();vara="exit";t&&t.alwaysLast&&(a="afterexit");varn=function(){at.removeListener(a,e),at.listeners("exit").length===0&&at.listeners("afterexit").length===0&&ro()};returnat.on(a,e),n},ro=function(){!kn||!qa(global.process)||(kn=!1,Tn.forEach(function(t){try{Ge.removeListener(t,oo[t])}catch(a){}}),Ge.emit=so,Ge.reallyExit=Qc,at.count-=1)},Fn.exports.unload=ro,Xa=function(t,a,n){at.emitted[t]||(at.emitted[t]=!0,at.emit(t,a,n))},oo={},Tn.forEach(function(e){oo[e]=function(){if(qa(global.process)){vara=Ge.listeners(e);a.length===at.count&&(ro(),Xa("exit",null,e),Xa("afterexit",null,e),Nh&&e==="SIGHUP"&&(e="SIGINT"),Ge.kill(Ge.pid,e))}}}),Fn.exports.signals=function(){returnTn},kn=!1,Kc=function(){kn||!qa(global.process)||(kn=!0,at.count+=1,Tn=Tn.filter(function(t){try{returnGe.on(t,oo[t]),!0}catch(a){return!1}}),Ge.emit=Lh,Ge.reallyExit=jh)},Fn.exports.load=Kc,Qc=Ge.reallyExit,jh=function(t){qa(global.process)&&(Ge.exitCode=t||0,Xa("exit",Ge.exitCode,null),Xa("afterexit",Ge.exitCode,null),Qc.call(Ge,Ge.exitCode))},so=Ge.emit,Lh=function(t,a){if(t==="exit"&&qa(global.process)){a!==void0&&(Ge.exitCode=a);varn=so.apply(this,arguments);returnXa("exit",Ge.exitCode,null),Xa("afterexit",Ge.exitCode,null),n}elsereturnso.apply(this,arguments)}):Fn.exports=function(){returnfunction(){}};varBh,Tn,Nh,Fi,at,ro,Xa,oo,kn,Kc,Qc,jh,so,Lh});varDh=O((GD,Mh)=>{"use strict";varn4=require("os"),i4=eu(),r4=1e3*5,o4=(e,t="SIGTERM",a={})=>{letn=e(t);returns4(e,t,a,n),n},s4=(e,t,a,n)=>{if(!l4(t,a,n))return;leti=u4(a),r=setTimeout(()=>{e("SIGKILL")},i);r.unref&&r.unref()},l4=(e,{forceKillAfterTimeout:t},a)=>c4(e)&&t!==!1&&a,c4=e=>e===n4.constants.signals.SIGTERM||typeofe=="string"&&e.toUpperCase()==="SIGTERM",u4=({forceKillAfterTimeout:e=!0})=>{if(e===!0)returnr4;if(!Number.isFinite(e)||e<0)thrownewTypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeofe})`);returne},p4=(e,t)=>{e.kill()&&(t.isCanceled=!0)},d4=(e,t,a)=>{e.kill(t),a(Object.assign(newEr
`?this.forward():this.back())),Z(v,$,U,X);if(($=this._extractString(this.tags.VARIABLE_END))||($=this._extractString("-"+this.tags.VARIABLE_END)))return this.in_code=!1,Z(E,$,U,X);if(he==="r"&&this.str.charAt(this.index+1)==="/"){this.forwardN(2);for(var qe="";!this.isFinished();)if(this.current()==="/"&&this.previous()!=="\\"){this.forward();break}else qe+=this.current(),this.forward();for(var ze=["g","i","m","y"],ht="";!this.isFinished();){var R=ze.indexOf(this.current())!==-1;if(R)ht+=this.current(),this.forward();else break}return Z(q,{body:qe,flags:ht},U,X)}else if(r.indexOf(he)!==-1){this.forward();var z=["==","===","!=","!==","<=",">=","//","**"],J=he+this.current(),H;switch(n.indexOf(z,J)!==-1&&(this.forward(),he=J,n.indexOf(z,J+this.current())!==-1&&(he=J+this.current(),this.forward())),he){case"(":H=w;break;case")":H=C;break;case"[":H=y;break;case"]":H=S;break;case"{":H=A;break;case"}":H=_;break;case",":H=F;break;case":":H=B;break;case"~":H=j;break;case"|":H=L;break;default:H=P}return Z(H,he,U,X)}else if($=this._extractUntil(i+r),$.match(/^[-+]?[0-9]+$/))if(this.current()==="."){this.forward();var ne=this._extract(o);return Z(T,$+"."+ne,U,X)}else return Z(k,$,U,X);else{if($.match(/^(true|false)$/))return Z(N,$,U,X);if($==="none")return Z(M,$,U,X);if($==="null")return Z(M,$,U,X);if($)return Z(D,$,U,X);throw new Error("Unexpected value while parsing: "+$)}}else{var K=this.tags.BLOCK_START.charAt(0)+this.tags.VARIABLE_START.charAt(0)+this.tags.COMMENT_START.charAt(0)+this.tags.COMMENT_END.charAt(0);if(this.isFinished())return null;if(($=this._extractString(this.tags.BLOCK_START+"-"))||($=this._extractString(this.tags.BLOCK_START)))return this.in_code=!0,Z(h,$,U,X);if(($=this._extractString(this.tags.VARIABLE_START+"-"))||($=this._extractString(this.tags.VARIABLE_START)))return this.in_code=!0,Z(x,$,U,X);$="";var Ae,ue=!1;for(this._matches(this.tags.COMMENT_START)&&(ue=!0,$=this._extractString(this.tags.COMMENT_START));(Ae=this._extractUntil(K))!==null;)if($+=Ae,(this._matches(this.tags.BLOCK_START)||this._matches(this.tags.VARIABLE_START)||this._matches(this.tags.COMMENT_START))&&!ue){if(this.lstripBlocks&&this._matches(this.tags.BLOCK_START)&&this.colno>0&&this.colno<=$.length){var Ne=$.slice(-this.colno);if(/^\s+$/.test(Ne)&&($=$.slice(0,-this.colno),!$.length))return this.nextToken()}break}else if(this._matches(this.tags.COMMENT_END)){if(!ue)throw new Error("unexpected end of comment");$+=this._extractString(this.tags.COMMENT_END);break}else $+=this.current(),this.forward();if(Ae===null&&ue)throw new Error("expected end of comment, got end of file");return Z(ue?g:m,$,U,X)}},ee._parseString=function(U){this.forward();for(var X="";!this.isFinished()&&this.current()!==U;){var $=this.current();if($==="\\"){switch(this.forward(),this.current()){case"n":X+=`
`);return k6(t)};ei.decodePax=function(e){for(var t={};e.length;){for(var a=0;a<e.length&&e[a]!==32;)a++;var n=parseInt(e.slice(0,a).toString(),10);if(!n)return t;var i=e.slice(a+1,n-1).toString(),r=i.indexOf("=");if(r===-1)return t;t[i.slice(0,r)]=i.slice(r+1),e=e.slice(n)}return t};ei.encode=function(e){var t=F6(512),a=e.name,n="";if(e.typeflag===5&&a[a.length-1]!=="/"&&(a+="/"),Buffer.byteLength(a)!==a.length)return null;for(;Buffer.byteLength(a)>100;){var i=a.indexOf("/");if(i===-1)return null;n+=n?"/"+a.slice(0,i):a.slice(0,i),a=a.slice(i+1)}return Buffer.byteLength(a)>100||Buffer.byteLength(n)>155||e.linkname&&Buffer.byteLength(e.linkname)>100?null:(t.write(a),t.write(La(e.mode&B6,6),100),t.write(La(e.uid,6),108),t.write(La(e.gid,6),116),t.write(La(e.size,11),124),t.write(La(e.mtime.getTime()/1e3|0,11),136),t[156]=xw+L6(e.type),e.linkname&&t.write(e.linkname,157),t.write(R6,257),e.uname&&t.write(e.uname,265),e.gname&&t.write(e.gname,297),t.write(La(e.devmajor||0,6),329),t.write(La(e.devminor||0,6),337),n&&t.write(n,345),t.write(La(ww(t),6),148),t)};ei.decode=function(e,t){var a=e[156]===0?0:e[156]-xw,n=Qn(e,0,100,t),i=Ma(e,100,8),r=Ma(e,108,8),o=Ma(e,116,8),s=Ma(e,124,12),l=Ma(e,136,12),u=j6(a),c=e[157]===0?null:Qn(e,157,100,t),f=Qn(e,265,32),p=Qn(e,297,32),b=Ma(e,329,8),d=Ma(e,337,8);e[345]&&(n=Qn(e,345,155,t)+"/"+n),a===0&&n&&n[n.length-1]==="/"&&(a=5);var m=ww(e);if(m===8*32)return null;if(m!==Ma(e,148,8))throw new Error("Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?");return{name:n,mode:i,uid:r,gid:o,size:s,mtime:new Date(1e3*l),type:u,linkname:c,uname:f,gname:p,devmajor:b,devminor:d}}});var Kp=O((wH,Cw)=>{"use strict";Cw.exports=xa;var Ys=ja(),Sw=Object.create(Zn());Sw.inherits=fn();Sw.inherits(xa,Ys);function D6(e,t){var a=this._transformState;a.transforming=!1;var n=a.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));a.writechunk=null,a.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function xa(e){if(!(this instanceof xa))return new xa(e);Ys.call(this,e),this._transformState={afterTransform:D6.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",z6)}function z6(){var e=this;typeof this._flush=="function"?this._flush(function(t,a){Ew(e,t,a)}):Ew(this,null,null)}xa.prototype.push=function(e,t){return this._transformState.needTransform=!1,Ys.prototype.push.call(this,e,t)};xa.prototype._transform=function(e,t,a){throw new Error("_transform() is not implemented")};xa.prototype._write=function(e,t,a){var n=this._transformState;if(n.writecb=a,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};xa.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};xa.prototype._destroy=function(e,t){var a=this;Ys.prototype._destroy.call(this,e,function(n){t(n),a.emit("close")})};function Ew(e,t,a){if(t)return e.emit("error",t);if(a!=null&&e.push(a),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var Tw=O((EH,_w)=>{"use strict";_w.exports=ur;var Aw=Kp(),Iw=Object.create(Zn());Iw.inherits=fn();Iw.inherits(ur,Aw);function ur(e){if(!(this instanceof ur))return new ur(e);Aw.call(this,e)}ur.prototype._transform=function(e,t,a){a(null,e)}});var ti=O((ta,kw)=>{ta=kw.exports=Gp();ta.Stream=ta;ta.Readable=ta;ta.Writable=Vp();ta.Duplex=ja();ta.Transform=Kp();ta.PassThrough=Tw()});var jw=O((SH,Nw)=>{var Pw=require
${t}`,gP=Object.getOwnPropertyDescriptor(Function.prototype,"toString"),xP=Object.getOwnPropertyDescriptor(Function.prototype.toString,"name"),yP=(e,t,a)=>{let n=a===""?"":`with${a.trim()}()`,i=bP.bind(null,n,t.toString());Object.defineProperty(i,"name",xP),Object.defineProperty(e,"toString",{...gP,value:i})};function Zu(e,t,{ignoreNonConfigurable:a=!1}={}){let{name:n}=e;for(let i of Reflect.ownKeys(t))mP(e,t,i,a);return vP(e,t),yP(e,t,n),e}var fs=new WeakMap,Ig=(e,t={})=>{if(typeof e!="function")throw new TypeError("Expected a function");let a,n=0,i=e.displayName||e.name||"<anonymous>",r=function(...o){if(fs.set(r,++n),n===1)a=e.apply(this,o),e=null;else if(t.throw===!0)throw new Error(`Function\`${i}\` can only be called once`);returna};returnZu(r,e),fs.set(r,n),r};Ig.callCount=e=>{if(!fs.has(e))thrownewError(`The given function \`${e.name}\` is not wrapped by the \`onetime\` package`);returnfs.get(e)};var_g=Ig;varRg=require("node:os");varTg=()=>{lete=Fg-kg+1;returnArray.from({length:e},wP)},wP=(e,t)=>({name:`SIGRT${t+1}`,number:kg+t,action:"terminate",description:"Application-specific signal (realtime)",standard:"posix"}),kg=34,Fg=64;varOg=require("node:os");varPg=[{name:"SIGHUP",number:1,action:"terminate",description:"Terminal closed",standard:"posix"},{name:"SIGINT",number:2,action:"terminate",description:"User interruption with CTRL-C",standard:"ansi"},{name:"SIGQUIT",number:3,action:"core",description:"User interruption with CTRL-\\",standard:"posix"},{name:"SIGILL",number:4,action:"core",description:"Invalid machine instruction",standard:"ansi"},{name:"SIGTRAP",number:5,action:"core",description:"Debugger breakpoint",standard:"posix"},{name:"SIGABRT",number:6,action:"core",description:"Aborted",standard:"ansi"},{name:"SIGIOT",number:6,action:"core",description:"Aborted",standard:"bsd"},{name:"SIGBUS",number:7,action:"core",description:"Bus error due to misaligned, non-existing address or paging error",standard:"bsd"},{name:"SIGEMT",number:7,action:"terminate",description:"Command should be emulated but is not implemented",standard:"other"},{name:"SIGFPE",number:8,action:"core",description:"Floating point arithmetic error",standard:"ansi"},{name:"SIGKILL",number:9,action:"terminate",description:"Forced termination",standard:"posix",forced:!0},{name:"SIGUSR1",number:10,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGSEGV",number:11,action:"core",description:"Segmentation fault",standard:"ansi"},{name:"SIGUSR2",number:12,action:"terminate",description:"Application-specific signal",standard:"posix"},{name:"SIGPIPE",number:13,action:"terminate",description:"Broken pipe or socket",standard:"posix"},{name:"SIGALRM",number:14,action:"terminate",description:"Timeout or timer",standard:"posix"},{name:"SIGTERM",number:15,action:"terminate",description:"Termination",standard:"ansi"},{name:"SIGSTKFLT",number:16,action:"terminate",description:"Stack is empty or overflowed",standard:"other"},{name:"SIGCHLD",number:17,action:"ignore",description:"Child process terminated, paused or unpaused",standard:"posix"},{name:"SIGCLD",number:17,action:"ignore",description:"Childprocessterminated,pausedorunpaused",standard:"other"},{name:"SIGCONT",number:18,action:"unpause",description:"Unpaused",standard:"posix",forced:!0},{name:"SIGSTOP",number:19,action:"pause",description:"Paused",standard:"posix",forced:!0},{name:"SIGTSTP",number:20,action:"pause",description:'Paused using CTRL-Z or "suspend"',standard:"posix"},{name:"SIGTTIN",number:21,action:"pause",description:"Backgroundprocesscannotreadterminalinput",standard:"posix"},{name:"SIGBREAK",number:21,action:"terminate",description:"UserinterruptionwithCTRL-BREAK",standard:"other"},{name:"SIGTTOU",number:22,action:"pause",description:"Backgroundprocesscannotwritetoterminaloutput",standard:"posix"},{name:"SIGURG",number:23,action:"ignore",description:"Socketreceivedout-of-banddata",standard:"bsd"},{name:"SIGXCPU",number:24,action:"core",description:"Processtimedout",standard:"bsd"},{name:"SIGXFSZ",number:25,
${n.message}`:m,x=[v,t,e].filter(Boolean).join(`
`);return h?(n.originalMessage=n.message,n.message=x):n=new Error(x),n.shortMessage=v,n.command=o,n.escapedCommand=s,n.exitCode=r,n.signal=i,n.signalDescription=p,n.stdout=e,n.stderr=t,a!==void 0&&(n.all=a),"bufferedData"in n&&delete n.bufferedData,n.failed=!0,n.timedOut=!!l,n.isCanceled=u,n.killed=c&&!l,n};var ms=["stdin","stdout","stderr"],kP=e=>ms.some(t=>e[t]!==void 0),Ng=e=>{if(!e)return;let{stdio:t}=e;if(t===void 0)return ms.map(n=>e[n]);if(kP(e))throw new Error(`It's not possible to provide \`stdio\` in combination with one of ${ms.map(n=>`\`${n}\``).join(", ")}`);if(typeof t=="string")return t;if(!Array.isArray(t))throw new TypeError(`Expected \`stdio\` to be of type \`string\` or \`Array\`, got \`${typeof t}\``);let a=Math.max(t.length,ms.length);return Array.from({length:a},(n,i)=>t[i])};var jg=_e(require("node:os"),1),Lg=_e(eu(),1),FP=1e3*5,Mg=(e,t="SIGTERM",a={})=>{let n=e(t);return PP(e,t,a,n),n},PP=(e,t,a,n)=>{if(!OP(t,a,n))return;let i=BP(a),r=setTimeout(()=>{e("SIGKILL")},i);r.unref&&r.unref()},OP=(e,{forceKillAfterTimeout:t},a)=>RP(e)&&t!==!1&&a,RP=e=>e===jg.default.constants.signals.SIGTERM||typeof e=="string"&&e.toUpperCase()==="SIGTERM",BP=({forceKillAfterTimeout:e=!0})=>{if(e===!0)return FP;if(!Number.isFinite(e)||e<0)throw new TypeError(`Expected the \`forceKillAfterTimeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`);return e},Dg=(e,t)=>{e.kill()&&(t.isCanceled=!0)},NP=(e,t,a)=>{e.kill(t),a(Object.assign(new Error("Timed out"),{timedOut:!0,signal:t}))},zg=(e,{timeout:t,killSignal:a="SIGTERM"},n)=>{if(t===0||t===void 0)return n;let i,r=new Promise((s,l)=>{i=setTimeout(()=>{NP(e,a,l)},t)}),o=n.finally(()=>{clearTimeout(i)});return Promise.race([r,o])},Gg=({timeout:e})=>{if(e!==void 0&&(!Number.isFinite(e)||e<0))throw new TypeError(`Expected the \`timeout\` option to be a non-negative integer, got \`${e}\` (${typeof e})`)},Hg=async(e,{cleanup:t,detached:a},n)=>{if(!t||a)return n;let i=(0,Lg.default)(()=>{e.kill()});return n.finally(()=>{i()})};var Wg=require("node:fs"),Vg=require("node:child_process");function hs(e){return e!==null&&typeof e=="object"&&typeof e.pipe=="function"}function Xu(e){return hs(e)&&e.writable!==!1&&typeof e._write=="function"&&typeof e._writableState=="object"}var jP=e=>e instanceof Vg.ChildProcess&&typeof e.then=="function",$u=(e,t,a)=>{if(typeof a=="string")return e[t].pipe((0,Wg.createWriteStream)(a)),e;if(Xu(a))return e[t].pipe(a),e;if(!jP(a))throw new TypeError("The second argument must be a string, a stream or an Execa child process.");if(!Xu(a.stdin))throw new TypeError("The target child process'sstdinmustbeavailable.");return e[t].pipe(a.stdin),a},Ug=e=>{e.stdout!==null&&(e.pipeStdout=$u.bind(void 0,e,"stdout")),e.stderr!==null&&(e.pipeStderr=$u.bind(void 0,e,"stderr")),e.all!==void 0&&(e.pipeAll=$u.bind(void 0,e,"all"))};var bs=require("node:fs");var ep=_e(qg(),1),Xg=_e(au(),1),$g=e=>{if(e!==void 0)throw new TypeError("The`input`and`inputFile`optionscannotbebothset.")},WP=({input:e,inputFile:t})=>typeof t!="string"?e:($g(e),(0,bs.readFileSync)(t)),Yg=e=>{let t=WP(e);if(hs(t))throw new TypeError("The`input`optioncannotbeastreaminsyncmode");return t},VP=({input:e,inputFile:t})=>typeof t!="string"?e:($g(e),(0,bs.createReadStream)(t)),Kg=(e,t)=>{leta=VP(t);a!==void0&&(hs(a)?a.pipe(e.stdin):e.stdin.end(a))},Qg=(e,{all:t})=>{if(!t||!e.stdout&&!e.stderr)return;leta=(0,Xg.default)();returne.stdout&&a.add(e.stdout),e.stderr&&a.add(e.stderr),a},Ku=async(e,t)=>{if(!(!e||t===void0)){e.destroy();try{returnawaitt}catch(a){returna.bufferedData}}},Qu=(e,{encoding:t,buffer:a,maxBuffer:n})=>{if(!(!e||!a))returnt?(0,ep.default)(e,{encoding:t,maxBuffer:n}):ep.default.buffer(e,{maxBuffer:n})},ex=async({stdout:e,stderr:t,all:a},{encoding:n,buffer:i,maxBuffer:r},o)=>{lets=Qu(e,{encoding:n,buffer:i,maxBuffer:r}),l=Qu(t,{encoding:n,buffer:i,maxBuffer:r}),u=Qu(a,{encoding:n,buffer:i,maxBuffer:r*2});try{returnawaitPromise.all([o,s,l,u])}catch(c){returnPromise.all([{error:c,signal:c.signal,timedOut:c.timedOut},Ku(e,s),Ku(t,l),Ku(a,u)])}};
`}function ln(e){return e.startsWith("/")?e.replace(/^\/+/,""):e}function bp(e){return e.endsWith(".md")||(e+=".md"),e.startsWith("/")&&(e=ln(e)),e}async function gp(e,t,a,n){let i=new DOMParser().parseFromString(t,"text/html"),r=i.querySelectorAll("[data-annotation]"),o=i.querySelectorAll("[data-citation]");for(let s of Array.from(r))try{let l=s.dataset.annotation,u=l?JSON.parse(decodeURIComponent(l)):null;if(!u)return;let c=u.annotationKey,f=s instanceof HTMLImageElement;if(f){let p=a[c];if(p){let b=cn.default.parse(p),d=await bO(c,b.ext.slice(1),n),h=cn.default.parse(cn.default.join(an(),d)).dir;(0,Oa.existsSync)(h)||(0,Oa.mkdirSync)(h,{recursive:!0});let v=cn.default.join(b.dir,`${c}${b.ext}`);try{if(!(0,Oa.existsSync)(v)){let x=v;if(v=p,!(0,Oa.existsSync)(v))throw new Error("Cannot find annotation image: "+x)}(0,Oa.copyFileSync)(v,cn.default.join(an(),d))}catch(x){new zt.Notice("Error: unable to copy annotation image from Zotero into your vault",7e3),console.error(x)}s.src=d}}s.insertAdjacentElement(f?"afterend":"beforebegin",createEl("a",{text:"Go to annotation",href:Qt("open-pdf",u.attachmentURI,{page:u.pageLabel,annotation:u.annotationKey})})),f?s.insertAdjacentElement("afterend",createEl("br")):s.insertAdjacentElement("beforebegin",createSpan({text:" "}))}catch(l){console.error(l)}return o.forEach(s=>{var l;try{let u=s.dataset.citation,c=u?JSON.parse(decodeURIComponent(u)):null;if(!c||!c.citationItems.length||!((l=c.citationItems[0].uris)!=null&&l.length))return;let f=s.querySelector("span");if(!f)return;let p=f.innerText;f.empty(),f.createEl("a",{text:p,href:Qt("select",c.citationItems[0].uris[0])})}catch(u){console.error(u)}}),i.body.innerHTML}async function xp(e,t){let a=await on(e);if(!a.length)return;let n=await Ox(a,e);if(!n){new zt.Notice("No notes found for selected items",7e3);return}let i=Object.keys(n);if(!i.length){new zt.Notice("No notes found for selected items",7e3);return}let r={};for(let s of a){let l=await Cs(s,e);if(l){let u={};l.forEach(c=>{var f;(f=c.annotations)==null||f.forEach(p=>{p.annotationType==="image"&&(u[p.key]=p.annotationImagePath)})}),r[s.key]=u}}let o={};for(let s of i){let l=[];for(let u of n[s])l.push((0,zt.htmlToMarkdown)(await gp(s,u,r[s],t)));o[s]=l.join(`
`))}async function Vx(e,t){let a=Object.keys(t),n=[];for(let i of a){let r=await gO(e,i,t[i]);if(!r)break;n.push(r)}return n.map(i=>i.path)}async function gO(e,t,a){let n=(0,zt.normalizePath)(Vn(ln(`${e}/${t}.md`))),i=app.vault.getAbstractFileByPath(n);try{i?await app.vault.modify(i,a):(await Ss(n),i=await app.vault.create(n,a))}catch(r){return console.error(r),new zt.Notice(`Errorcreatingfile"${n}":${r.message}`,1e4),null}return i}var un=require("obsidian"),_s=_e(require("path"));var xO={noWrite:"-w",imageOutputPath:"-o",imageBaseName:"-n",imageFormat:"-f",imageDPI:"-d",imageQuality:"-q",ignoreBefore:"-b",attemptOCR:"-e",ocrLang:"-l",tesseractPath:"--tesseract-path",tessDataDir:"--tess-data-dir"};async function yp(e,t,a){let n=new nt(app,"Extracting annotations...");n.open();let i=[e];Object.keys(t).forEach(r=>{let o=t[r];if(o===""||o===void 0)return"";let s=xO[r];typeof o=="boolean"?o&&i.push(s):(i.push(s),typeof o=="string"&&o.startsWith("-")?i.push(`"${o}"`):i.push(o.toString()))});try{if(!Cx(a))return new un.Notice("Error: PDF utility is not executable",1e4),"[]";let o=await er(a||_s.default.join(_t(),nn()),i);if(n.close(),o.stderr.toLowerCase().includes("password"))return new un.Notice(`Erroropening${_s.default.basename(e)}:PDFispasswordprotected`,1e4),"[]";if(o.stderr&&!o.stderr.includes("warning"))throw new un.Notice(`ErrorprocessingPDF:${o.stderr}`,1e4),new Error(o.stderr);return o.stdout}catch(r){if(n.close(),r.message.toLowerCase().includes("password"))return new un.Notice(`Erroropening${_s.default.basename(e)}:PDFispasswordprotected`,1e4),"[]";if(r.message.toLowerCase().includes("type3"))return new un.Notice(`Errorprocessingannotations:${r.message}`,1e4),"[]";throw console.error(r),new un.Notice(`ErrorprocessingPDF:${r.message}`,1e4),r}}async function yO(e,t,a,n,i){t.note&&(t.note=(0,Be.htmlToMarkdown)(await gp(e.key,t.note,{}))),t.dateAdded&&(t.dateAdded=(0,Be.moment)(t.dateAdded)),t.dateModified&&(t.dateModified=(0,Be.moment)(t.dateModified)),t.desktopURI=Qt("select",t.uri),t.relations=await Zx(t,e.library,a,n,i)}function wO(e){var t;e.dateAdded&&(e.dateAdded=(0,Be.moment)(e.dateAdded)),e.dateModified&&(e.dateModified=(0,Be.moment)(e.dateModified)),e.uri&&(e.itemKey=e.uri.split("/").pop(),e.desktopURI=e.select||Qt("select",e.uri),(t=e.path)!=null&&t.endsWith(".pdf")&&(e.pdfURI=Qt("open-pdf",e.uri)))}function Ux(e,t,a){e.date=(0,Be.moment)(e.date),e.attachment=t,e.source="pdf",e.imagePath&&(e.imageBaseName=Jt.default.basename(e.imagePath),e.imageExtension=Jt.default.extname(e.imagePath).slice(1),e.imageRelativePath=(0,Be.normalizePath)(Jt.default.join(a,e.imageBaseName))),e.desktopURI=Qt("open-pdf",t.uri,{page:e.pageLabel})}function Jx(e,t,a,n,i,r=!1){var l;let o=e.annotationPosition.rects[0],s={date:(0,Be.moment)(e.dateModified),attachment:t,page:e.annotationPosition.pageIndex+1,pageLabel:e.annotationPageLabel,id:e.key,type:e.annotationType,x:o[0],y:o[1],color:e.annotationColor,colorCategory:Px(e.annotationColor),desktopURI:Qt("open-pdf",t.uri,{page:e.annotationPageLabel,annotation:e.key}),source:"zotero"};if(e.annotationText&&(s.annotatedText=e.annotationText),e.annotationComment&&(s.comment=e.annotationComment),e.annotationImagePath){let u=Jt.default.parse(e.annotationImagePath);s.imageBaseName=`${i}-${s.page}-x${Math.round(s.x)}-y${Math.round(s.y)}${u.ext}`,s.imageRelativePath=(0,Be.normalizePath)(Jt.default.join(n,s.imageBaseName)),s.imageExtension=u.ext.slice(1);let c=Jt.default.join(a,s.imageBaseName);if(r){(0,Ra.existsSync)(a)||(0,Ra.mkdirSync)(a,{recursive:!0});let f=Jt.default.join(u.dir,`${e.key}${u.ext}`);try{if(!(0,Ra.existsSync)(f)){let p=f;if(f=e.annotationImagePath,!(0,Ra.existsSync)(f))throw new Error("Cannot find annotation image: "+p)}(0,Ra.copyFileSync)(f,c)}catch(p){new Be.Notice("Error: unable to copy annotation image from Zotero into your vault",7e3),console.error(p)}}s.imagePath=c}return(l=e.tags)!=null&&l.length&&(s.tags=e.tags,s.allTags=e.tags.map(u=>u.tag).join(", "),s.hashTags=e.tags.map(u=>`#${u.tag.replace(/\s+/g,"-")}`).join(", ")),s}function Fs(e){let
{%endfor%}`)})),o.preventDefault(),s.showAtMouseEvent(o)}},a?"Template Data":e[0])},kO=e=>e.map(PO).reverse().join(""),FO=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,PO=(e,t,a)=>typeof e=="number"?`[${e}]`:FO.test(e)?t===a.length-1?`${e}`:`.${e}`:`[${JSON.stringify(e)}]`,OO=/^#(?:[\dA-F]{3}){1,2}$|^#(?:[\dA-F]{4}){1,2}$/i,RO=(e,t)=>t instanceof Ba.moment?I.createElement(I.Fragment,null,"\u{1F4C5} ",t.format("l LTS")):typeof t=="string"&&OO.test(t)?I.createElement(I.Fragment,null,I.createElement("span",{style:{backgroundColor:t},className:"zt-color-chip"}),t):typeof t=="string"&&t.length>800?t.slice(0,800)+"...":e;var ZA=_e(UA()),Zl=require("obsidian"),Sf=_e(require("os"));var JA=require("obsidian");function ca({name:e,className:t}){return I.createElement("span",{"data-icon":e,className:t,ref:a=>{a&&(0,JA.setIcon)(a,e)}})}function s9({name:e,description:t}){return I.createElement("div",{className:"setting-item-info"},I.createElement("div",{className:"setting-item-name"},e),I.createElement("div",{className:"setting-item-description"},t))}function He({name:e,description:t,children:a,isHeading:n}){return I.createElement("div",{className:`zt-setting-itemsetting-item${n?" setting-item-heading":""}`},I.createElement(s9,{name:e,description:t}),I.createElement("div",{className:"setting-item-control"},a))}var Va="1.0.15",Cf=1,l9={darwin:{x64:`https://github.com/mgmeyers/pdfannots2json/releases/download/${Va}/pdfannots2json.Mac.Intel.tar.gz`,arm64:`https://github.com/mgmeyers/pdfannots2json/releases/download/${Va}/pdfannots2json.Mac.M1.tar.gz`},linux:{x64:`https://github.com/mgmeyers/pdfannots2json/releases/download/${Va}/pdfannots2json.Linux.x64.tar.gz`},win32:{x64:`https://github.com/mgmeyers/pdfannots2json/releases/download/${Va}/pdfannots2json.Windows.x64.zip`}};function c9(){let e=l9[Sf.default.platform()];if(!e)return null;let t=e[Sf.default.arch()];return t||null}async function Af(){let e=c9();if(console.log("Obsidian Zotero Integration: Downloading "+e),!e)return!1;try{xx()&&Ex(),gx()&&wx(),Hn()&&yx(),await(0,ZA.default)(e,_t(),{extract:!0}),vx()}catch(t){console.error(t),new Zl.Notice("Error downloading PDF utility. Check the console for more details.",1e4)}return!0}function qA(e){let[t,a]=I.useState(null),[n,i]=I.useState(!1),[r,o]=I.useState(!1),[s,l]=I.useState(e.settings.exeOverridePath),u=I.useMemo(()=>(0,Zl.debounce)(m=>{l(m),e.updateSetting("exeOverridePath",m)},150,!0),[]);I.useEffect(()=>{let m=Hn(s);o(m),m&&Sx(s).then(h=>{a(`v${Va}`===h)}).catch(()=>{})},[s]);let c=I.useCallback(()=>{i(!0),Af().then(m=>{i(!1),m&&(a(!0),o(!0))})},[]),f=["Extracting data from PDFs requires an external tool.","This plugin will still work without it, but annotations will not be included in exports."],b=I.createElement(He,{name:"PDF Utility Path Override",description:I.createElement(I.Fragment,null,"Override the path to the PDF utility. Specify an absolute path to the pdfannots2json executable."," ",I.createElement("a",{href:"https://github.com/mgmeyers/pdfannots2json/releases",target:"_blank",rel:"noreferrer"},"Download the executable here.")," ","You may need to provide Obsidian the appropriate OS permissions to access the executable.")},I.createElement("input",{onChange:m=>u(m.target.value),type:"text",spellCheck:!1,value:s}),I.createElement("div",{className:"clickable-icon setting-editor-extra-setting-button","aria-label":"Select the pdfannots2json executable",onClick:()=>{let m=require("electron").remote.dialog.showOpenDialogSync({properties:["openFile"]});m&&m.length&&u(m[0])}},I.createElement(ca,{name:"lucide-folder-open"})));if(r&&t)return I.createElement(I.Fragment,null,I.createElement(He,{name:"PDF Utility",description:f.join(" ")},I.createElement("div",{className:"zt-asset-success"},I.createElement("div",{className:"zt-asset-success__icon"},I.createElement(ca,{name:"check-small"})),I.createElement("div",{className:"zt-asset-success__message"},"PDF utility is up to date."))),b);let d=I.createElement(I.Fragment,null,f.join(" ")," ",r&&I.createElement("strong",{className:"mod-warning"},"The PDF extraction tool req