forge-terminal 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/chunks/{about-credits-FZ35HUFP.js → about-credits-DBQHH5HA.js} +1 -1
- package/dist/chunks/args-TZMA4ZR6.js +3 -0
- package/dist/chunks/{boot-PCZBPNFR.js → boot-E57BKWEC.js} +1 -1
- package/dist/chunks/chunk-3CLPUPJT.js +55 -0
- package/dist/chunks/chunk-3GHHQNR6.js +3 -0
- package/dist/chunks/chunk-4YFFT5CZ.js +66 -0
- package/dist/chunks/{chunk-BD3OLIVT.js → chunk-5IZBFF6Y.js} +1 -1
- package/dist/chunks/{chunk-S2M4XESA.js → chunk-5YUOG3A5.js} +1 -1
- package/dist/chunks/{chunk-X26WUHWB.js → chunk-6LMVOQQA.js} +1 -1
- package/dist/chunks/chunk-6RMRWBMB.js +3 -0
- package/dist/chunks/{chunk-63ZK5SRQ.js → chunk-7I2OSTBX.js} +1 -1
- package/dist/chunks/chunk-7KYO62XK.js +3 -0
- package/dist/chunks/{chunk-HCLEHCAR.js → chunk-7VR6LODN.js} +1 -1
- package/dist/chunks/{chunk-3KWAO2N2.js → chunk-AFEYLHDD.js} +1 -1
- package/dist/chunks/{chunk-YNZIN42P.js → chunk-AIINYKXW.js} +1 -1
- package/dist/chunks/{chunk-DZOBIUV6.js → chunk-BIBDLXCG.js} +1 -1
- package/dist/chunks/{chunk-G46QQBT3.js → chunk-BROTSQXG.js} +1 -1
- package/dist/chunks/chunk-CVNYUROW.js +3 -0
- package/dist/chunks/{chunk-QXNB5DQ2.js → chunk-E2BYNETT.js} +1 -1
- package/dist/chunks/{chunk-SK2UZ25Y.js → chunk-EITGK5OI.js} +1 -1
- package/dist/chunks/chunk-EPDF4NQI.js +3 -0
- package/dist/chunks/{chunk-JOIHR724.js → chunk-EURVTBPH.js} +1 -1
- package/dist/chunks/{chunk-MTDCDKPU.js → chunk-FLMQ5VFR.js} +2 -2
- package/dist/chunks/{chunk-JMBEZPYC.js → chunk-HWCXNKIN.js} +1 -1
- package/dist/chunks/{chunk-XURW53YK.js → chunk-IE6NFN3N.js} +1 -1
- package/dist/chunks/chunk-IJRLRAC5.js +3 -0
- package/dist/chunks/chunk-IKZTH2RL.js +3 -0
- package/dist/chunks/chunk-ITJZ7ODJ.js +4 -0
- package/dist/chunks/{chunk-THDAQBQ3.js → chunk-J6AZTW62.js} +1 -1
- package/dist/chunks/chunk-MNI6IKIU.js +3 -0
- package/dist/chunks/chunk-N3X3H4IZ.js +3 -0
- package/dist/chunks/chunk-NHMACTW3.js +82 -0
- package/dist/chunks/chunk-O7DK3GJT.js +3 -0
- package/dist/chunks/chunk-Q7ERPAG3.js +7 -0
- package/dist/chunks/{chunk-2CX33C6H.js → chunk-QPJ2LNXB.js} +1 -1
- package/dist/chunks/chunk-TDYKRRZH.js +3 -0
- package/dist/chunks/chunk-TFOEI5VF.js +3 -0
- package/dist/chunks/{chunk-EKTUUKDP.js → chunk-TYWGB767.js} +1 -1
- package/dist/chunks/chunk-VLVNA4T3.js +3 -0
- package/dist/chunks/{chunk-YINYF6C7.js → chunk-VTA6Z45X.js} +1 -1
- package/dist/chunks/{chunk-GLAD7GP2.js → chunk-YK26E3OX.js} +1 -1
- package/dist/chunks/chunk-Z2H2GT2X.js +36 -0
- package/dist/chunks/{chunk-C4UCCBCX.js → chunk-ZOQA3JAR.js} +1 -1
- package/dist/chunks/chunk-ZYIW4MAG.js +3 -0
- package/dist/chunks/clip-command-QPLYCGJ2.js +3 -0
- package/dist/chunks/clipboard-7KSZNWWT.js +3 -0
- package/dist/chunks/colour-PZOAKNTH.js +3 -0
- package/dist/chunks/command-DMGGGAPS.js +3 -0
- package/dist/chunks/config-command-6GXRV627.js +3 -0
- package/dist/chunks/continue-editing-4W3XWWCE.js +3 -0
- package/dist/chunks/decoded-SMEHAVCH.js +3 -0
- package/dist/chunks/{entry-2XJD7UCY.js → entry-REXB6JNP.js} +2 -2
- package/dist/chunks/execute-GKO4THUK.js +3 -0
- package/dist/chunks/extensions-UV4X2UUA.js +3 -0
- package/dist/chunks/{extensions-command-MGPRISPH.js → extensions-command-TLW53BUK.js} +1 -1
- package/dist/chunks/{ffmpeg-2UZXAB3C.js → ffmpeg-32EEMAZS.js} +1 -1
- package/dist/chunks/image-YMCS4PTS.js +3 -0
- package/dist/chunks/install-7ZRVQKCF.js +3 -0
- package/dist/chunks/install-C6XNONFF.js +3 -0
- package/dist/chunks/launch-IVBMNYNY.js +17 -0
- package/dist/chunks/lock-AFVXUDOM.js +3 -0
- package/dist/chunks/manager-XPO4ZIRY.js +4 -0
- package/dist/chunks/{needed-YEXRZMZX.js → needed-NOGBHTHE.js} +1 -1
- package/dist/chunks/notify-YEBP67MP.js +3 -0
- package/dist/chunks/{own-WOK6H277.js → own-G4G4MRGM.js} +1 -1
- package/dist/chunks/pdfium-BAMNBCNW.js +3 -0
- package/dist/chunks/preset-command-XXKLUJOS.js +3 -0
- package/dist/chunks/registry-PKOPEG3Z.js +3 -0
- package/dist/chunks/run-WSETTQXP.js +3 -0
- package/dist/chunks/{server-QNWPC2CC.js → server-AR73FWWG.js} +3 -3
- package/dist/chunks/{theme-EHFY7DT6.js → theme-D4AMWFFW.js} +1 -1
- package/dist/chunks/transcribe-EFVJPBPG.js +3 -0
- package/dist/chunks/transcribe-command-Q4J3WTOB.js +3 -0
- package/dist/chunks/update-command-DJLYU6AB.js +3 -0
- package/dist/chunks/{update-note-GYJWUDFS.js → update-note-2YR3TLPK.js} +1 -1
- package/dist/chunks/watch-command-2D7NLDAM.js +3 -0
- package/dist/index.js +13 -13
- package/package.json +7 -11
- package/dist/chunks/args-FSQFXDIX.js +0 -3
- package/dist/chunks/chunk-2J2PTA5O.js +0 -3
- package/dist/chunks/chunk-2MLASXG5.js +0 -3
- package/dist/chunks/chunk-5TEAR5XH.js +0 -3
- package/dist/chunks/chunk-63BBFKT2.js +0 -4
- package/dist/chunks/chunk-655UG277.js +0 -3
- package/dist/chunks/chunk-72TNSFL5.js +0 -36
- package/dist/chunks/chunk-AYB5AJ4E.js +0 -3
- package/dist/chunks/chunk-C32KGH4S.js +0 -3
- package/dist/chunks/chunk-LBDSFSYP.js +0 -3
- package/dist/chunks/chunk-OY4EGSPE.js +0 -3
- package/dist/chunks/chunk-UXRQ4UBQ.js +0 -66
- package/dist/chunks/chunk-WIPP5TWQ.js +0 -3
- package/dist/chunks/chunk-WZWK3PEZ.js +0 -3
- package/dist/chunks/chunk-ZRHYGR2L.js +0 -134
- package/dist/chunks/clip-command-NZNC46H2.js +0 -3
- package/dist/chunks/clipboard-GICOXMMN.js +0 -3
- package/dist/chunks/colour-GSDOHCFK.js +0 -3
- package/dist/chunks/command-GYCYLUHN.js +0 -3
- package/dist/chunks/config-command-6YUMMZF3.js +0 -3
- package/dist/chunks/continue-editing-QE5RRIMG.js +0 -3
- package/dist/chunks/decoded-NBZ335RZ.js +0 -3
- package/dist/chunks/execute-FYEXZ7EY.js +0 -3
- package/dist/chunks/extensions-V5O4NIHI.js +0 -3
- package/dist/chunks/image-3CMUB2P4.js +0 -3
- package/dist/chunks/install-IDUHZTTS.js +0 -3
- package/dist/chunks/install-L5C2UT6M.js +0 -3
- package/dist/chunks/launch-GUHDBMSJ.js +0 -17
- package/dist/chunks/lock-UQJ66TZ3.js +0 -3
- package/dist/chunks/manager-UKTMRXKE.js +0 -4
- package/dist/chunks/pdfium-LYHOU6WV.js +0 -3
- package/dist/chunks/preset-command-6A2C6VPQ.js +0 -3
- package/dist/chunks/registry-2YU7NW4P.js +0 -3
- package/dist/chunks/run-U2CU6VGE.js +0 -5
- package/dist/chunks/transcribe-SCL3LFZU.js +0 -3
- package/dist/chunks/transcribe-command-BX2VVUI3.js +0 -3
- package/dist/chunks/update-command-JCTCRPCS.js +0 -3
- package/dist/chunks/watch-command-ZLZAWTNJ.js +0 -3
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as ne,d as ae,e as ie,g as ue,h as pe}from"./chunk-JOIHR724.js";import{a as ee,b as te,c as re,k as oe,m as N,n as j,o as se}from"./chunk-655UG277.js";import{a as y}from"./chunk-OY4EGSPE.js";import{c as I}from"./chunk-C32KGH4S.js";import{e as he}from"./chunk-HCLEHCAR.js";import{e as ce,f as de,g as fe,h as le,i as me,j as ge}from"./chunk-57M4J2BR.js";import{a as F,c as X,d as Z,e as C,f as _}from"./chunk-BD3OLIVT.js";import{a as m}from"./chunk-3KWAO2N2.js";import{d as $}from"./chunk-EEQSUBBL.js";import{a as Q}from"./chunk-XURW53YK.js";import{a as H,c as L}from"./chunk-2J2PTA5O.js";import{a as U,c as Y,d as E,e as K}from"./chunk-DZOBIUV6.js";import{H as M,I as q,L as G,b as P,c as w,d as v,r as z,t as k,v as D,wa as V,y as J}from"./chunk-WIPP5TWQ.js";import{a as h,b as W}from"./chunk-J7FLFHQJ.js";import{a as R}from"./chunk-H3DIRJFE.js";import{readFile as Je}from"node:fs/promises";import{dirname as Fe,resolve as Me}from"node:path";async function ye(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=F(o);if(!s.includes(e.target)){t.push({path:o.path,error:D(o,e.target,s)});continue}let n={sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)},a=E(n);Y(a,o.path)&&e.target!==o.format&&(a=K({...n,suffix:e.target})),r.push({op:"convert",sources:[o],outputs:[a],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as Ce}from"node:path";function je(e,r=new Set){let t={path:Ce(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:F(e).filter(n=>!o||C(n)),actions:ue([e],r).filter(n=>!o||n.id===j.id).map(n=>n.id)};if(e.kind==="image")return{...t,width:e.width,height:e.height,...s};if(e.kind==="media"){let n=e.facts;return{...t,...n?{duration:n.duration}:{},...n?.video?{width:n.video.width,height:n.video.height,fps:n.video.fps}:{},...s}}return{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function be(e){let r=await y(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-TNMISSBA.js"),o=await t();return{probes:r.sources.map(s=>je(s,o)),failures:r.failures}}import{dirname as Be}from"node:path";var B=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function we(e,r){let t=P(Be(e),B(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function Ie(e,r){let{pct:t,direction:o}=W(e,r);return o==="same"?"same size":`${t}% ${o}`}function xe(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let a=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${we(s[0],r)}`,` ${s.map(i=>w(i)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} total`];for(let i of t.warnings)a.push("",`\u26A0 ${i.message}`);return a}let n=[`\u2713 ${w(o.path)} \u2192 ${P(s[0],B(r))}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} \xB7 ${Ie(o.bytes,t.outputBytes)}`];for(let a of t.warnings)n.push("",`\u26A0 ${a.message}`);return n}function Pe(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${Ie(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let n of s.job.outputs)t.push(` ${P(n,B(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function ve(e,r={}){let t=e.results.flatMap(u=>u.job.outputs),o=t.map(u=>w(u)).join(", "),s=t.length===1?"file":"files",n=t[0]===void 0?"":we(t[0],r),a=[`\u2713 ${t.length} ${s} \xB7 ${o}${n}`],i=e.results.flatMap(u=>u.warnings);for(let u of i)a.push("",`\u26A0 ${u.message}`);return a}function O(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...V(o.error,{debug:r.debug}),"");return t}function ke(){let e=new Set(X()),r=new Set(Z()),t=["Formats",""];for(let s of e){let n=R[s],a=r.has(s)?"read and write":"read only";t.push(` ${n.label.padEnd(6)} ${n.extensions.join(" ").padEnd(12)} ${a}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>R[s].label);if(o.length>0){let s=o.join(", "),[n,a]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${n} read only because Forge cannot yet write ${a}.`)}return t}function $e(e,r={}){let t=[R[e.format].label,h(e.bytes)];return e.duration!==void 0&&t.push($(e.duration)),e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.fps!==void 0&&t.push(`${e.fps} fps`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${P(e.path,B(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Re}from"node:readline";import{PassThrough as Oe}from"node:stream";function Se(e){return new Promise(r=>{let t=Re({input:e,terminal:!1}),o=!1,s=n=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(n.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function Ee(e){if(e.stdin)return Se(process.stdin);if(!process.stdin.isTTY)return;let r=new Oe,t=Re({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
|
|
4
|
-
`),t.close()}}function T(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function Ne(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(a=>a.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw M("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:ne(o)};if(s.mode==="every-n")return{cuts:ae(o,s.n)};let n=Math.max(o-1,0);for(let a of s.after)if(!Number.isInteger(a)||a<1||a>n)throw q(String(a),`"${a}" is outside 1 and ${n} \u2014 ${t?w(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(a=>a-1)}}function Te(e,r){let t;return()=>r?(t??=Ee({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function Ae(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:J(e.path)}};let i;try{i=await Q(await Je(e.path),s)}catch{return{failure:{path:e.path,error:J(e.path,{attempted:!0})}}}i.destroy()}let n;try{n=j.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(i){if(!v(i))throw i;return{failure:{path:e.path,error:i}}}let a=n[0];if(a?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(a.options.password=s),{job:a}}function S(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}if(!r&&t.type==="job:phase"&&t.progress.phase==="time"){let o=t.progress,s=`${$(o.done)} of ${$(o.total)}`;e.onEncode?.(o.pass?`pass ${o.pass.at} of 2 \xB7 ${s}`:s);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var b=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function We(e){let r=await y(e.inputs,{recursive:!1});if(r.sources.length===0)return b("pageop",r.failures);let t=ie.find(a=>a.id===e.action);if(!t)throw new Error(`no action registered for "${e.action}"`);let o=r.sources[0]?.path??"";if(!t.appliesTo(r.sources)){let a=pe(t,r.sources)??"not available for these files";return b("pageop",[...r.failures,{path:o,error:k(e.action,a)}])}let s;try{s=t.plan(r.sources,Ne(e,r.sources))}catch(a){if(!v(a))throw a;return b("pageop",[...r.failures,{path:o,error:a}])}let n=await I(s,{force:e.force});return{kind:"pageop",results:n.results,failures:[...r.failures,...n.refusals,...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function ze(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let i of t.sources){if(!N.appliesTo([i])){s.push({path:i.path,error:z(i)});continue}let u=e.output!==void 0&&!U(e.output)?Me(e.output):void 0,g=e.output===void 0||u!==void 0?Fe(i.path):Fe(E({sourcePath:i.path,target:i.format,output:e.output,sourceRoot:t.roots.get(i.path)})),[d]=N.plan([i],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},...e.options.media??{},destination:g});d?.op==="convert"&&(u!==void 0&&(d.outputs=[u]),e.dpi!==void 0&&(d.options.dpi=e.dpi),o.push(d))}let n=o.length>1;n&&r.onProgress?.({completed:0,total:o.length});let a=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,n)});return{kind:"compress",results:a.results,failures:[...t.failures,...s,...a.refusals,...a.unreachable.map(i=>({path:i.job.sources[0].path,error:i.error})),...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function De(e,r){let t=e.kind,o=e.op==="remove-background"?H(e.target):void 0;if(o)return b(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-6OENILJ4.js"),n=await s(e.op);if(!n)return b(t,[{path:"",error:G(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:c,catalogEntry:p}=await import("./catalog-FMHWWMUX.js"),f=p("boost"),x=f&&c(f)?.version,A=L(e.scale,n.version,x);if(A)return b(t,[{path:"",error:A}])}let a=await y(e.inputs,{recursive:e.recursive}),i=e.op==="boost"?te:re,u=[],g=[];for(let c of a.sources){if(!i.appliesTo([c])){g.push({path:c.path,error:k(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let p=ee(c,e.target);if(p){g.push({path:c.path,error:p});continue}u.push(...i.plan([c],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:a.roots}))}let d=u.length>1;d&&r.onProgress?.({completed:0,total:u.length});let l=await I(u,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:S(r,d)});return{kind:t,results:l.results,failures:[...a.failures,...g,...l.refusals,...l.failures],inputBytes:l.inputBytes,outputBytes:l.outputBytes}}async function qe(e,r){let t=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:he(e.target,t);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),n=[],a=[],i=[];for(let p of s.sources)p.kind==="image"&&e.media===void 0?n.push(p):p.kind==="media"&&!e.trim?a.push(p):p.kind==="image"?i.push({path:p.path,error:k("cut","it works on video and sound, not images","Try a video or sound file, such as a MOV, MP4 or WAV.")}):i.push({path:p.path,error:k(t,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=oe(a,{...e.media===void 0?{}:{media:e.media},...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots}),d=[...se(n,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),...u],l=d.length>1;l&&r.onProgress?.({completed:0,total:d.length});let c=await I(d,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:S(r,l)});return{kind:e.kind,results:c.results,failures:[...s.failures,...i,...c.refusals,...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function Ge(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=f=>f.kind==="document"&&f.format==="pdf",s=C(e.target),n=s?t.sources.filter(o):[],a=s?t.sources.filter(f=>!o(f)):t.sources,i=[],u=[],g=Te(e.passwordStdin??!1,r.interactive??!0);for(let f of n){let x=await Ae(f,e,g,t.roots.get(f.path));"failure"in x?u.push(x.failure):i.push(x.job)}let d=await ye({resolved:{sources:a,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),l=[...d.jobs,...i],c=l.length>1;c&&r.onProgress?.({completed:0,total:l.length});let p=await I(l,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,c)});return{kind:"convert",results:p.results,failures:[...t.failures,...u,...d.failures,...p.refusals,...p.unreachable.map(f=>({path:f.job.sources[0].path,error:f.error})),...p.failures],inputBytes:p.inputBytes,outputBytes:p.outputBytes}}async function Ve(e,r={}){try{if(e.kind==="pageop")return await We(e);if(e.kind==="extension-op")return await De(e,r);if(e.kind==="edit")return await qe(e,r);if(e.kind==="preset"){let{runPresetCommand:t}=await import("./preset-command-6A2C6VPQ.js");return await t(e)}return e.kind==="compress"?await ze(e,r):await Ge(e,r)}catch(t){if(!v(t))throw t;return b(e.kind,[{path:"",error:t}])}}function He(e,r){let t=T(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(ce(m,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?ve(e):e.results.length===1?xe(e):Pe(e);return{exitCode:t,stdout:o,stderr:O(e.failures,{debug:r.debug})}}function Le(e,r){let t=[{path:"",error:e}],o=T(t);return r.json?{exitCode:o,stdout:[JSON.stringify(de(m,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:O(t,{debug:r.debug})}}async function Ue(e,r){let{runConfig:t}=await import("./config-command-6YUMMZF3.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(me(m,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function Tt(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Ue(e,t);if(e.kind==="clip"){let{runClipCommand:s}=await import("./clip-command-NZNC46H2.js");return await s(e,{...r,json:t,debug:o})}if(e.kind==="update"){let{runUpdate:s}=await import("./update-command-JCTCRPCS.js"),n=await s(m,{...r.onInstalling?{onInstalling:r.onInstalling}:{}});return{exitCode:0,stdout:t?[JSON.stringify({forge:m,ok:!0,...n.data})]:n.stdout,stderr:[]}}if(e.kind==="uninstall"){let{runUninstall:s}=await import("./entry-2XJD7UCY.js"),n=[];return{exitCode:await s(m,i=>n.push(i)),stdout:n,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-MGPRISPH.js"),n=await s(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(ge(m,n.data))]:n.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(fe(m,_()))],stderr:[]}:{exitCode:0,stdout:ke(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:n}=await be(e.inputs),a=T(n);return t?{exitCode:a,stdout:[JSON.stringify(le(m,{probes:s,failures:n}))],stderr:[]}:{exitCode:a,stdout:s.flatMap((i,u)=>[...u>0?[""]:[],...$e(i)]),stderr:O(n,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:s,runScale:n}=await import("./colour-GSDOHCFK.js"),a={json:t,colour:r.colour??!1};return e.kind==="palette"?await s(e,a):await n(e,a)}if(e.kind==="transcribe"){let{runTranscribeCommand:s}=await import("./transcribe-command-BX2VVUI3.js"),n=[],a=[];return{exitCode:await s(e,{out:u=>n.push(u),err:u=>a.push(u)}),stdout:n,stderr:a}}if(e.kind==="shell")return{exitCode:0,stdout:[],stderr:[]};if(e.kind==="watch")throw M("forge watch runs in a terminal until ctrl-c.","Try: forge watch ./images --to webp");return He(await Ve(e,r),{json:t,debug:o})}catch(s){if(!v(s))throw s;return Le(s,{json:t,debug:o})}}export{be as a,Ie as b,T as c,Ve as d,He as e,Tt as f};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as h,c as Q}from"./chunk-Q6KQWJ4J.js";import{d as L,f as b,g as X}from"./chunk-HCLEHCAR.js";import{a as J,b as _,e as R}from"./chunk-BD3OLIVT.js";import{a as U,b as w}from"./chunk-WZWK3PEZ.js";import{a as g,d as A}from"./chunk-N6RCLJE6.js";import{f as l}from"./chunk-2J2PTA5O.js";import{d as x,l as I}from"./chunk-THDAQBQ3.js";import{b as $,c as N,d as D,e as d,i as B,m as z}from"./chunk-DZOBIUV6.js";import{H as k,v as C}from"./chunk-WIPP5TWQ.js";import{a as p,b as E,c as j}from"./chunk-H3DIRJFE.js";var O=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0;function Bt(t,e){let n=J(t);return n.includes(e)?void 0:C(t,e,n)}function G(t){return{target:t.target??"png",background:typeof t.background=="string"?t.background:"#ffffff",keepMetadata:t.keepMetadata===!0,...typeof t.output=="string"?{output:t.output}:{},...t.roots instanceof Map?{roots:t.roots}:{},...typeof t.quality=="number"?{quality:t.quality}:{}}}var W=()=>({kind:"select",id:"target",label:"Save as",default:"png",choices:[{value:"png",label:"PNG",hint:p.png.hint}]}),ot=t=>t===1?"sharp":`${t}x`,it=t=>t===1||t===3||t===4?t:2,Jt={id:"boost",label:"Boost resolution",verb:"Boosting",hint:"sharper, at its size or at 2\xD7, 3\xD7 or 4\xD7",requires:"boost",appliesTo:t=>O(t)!==void 0,unavailable:()=>"images only",options:()=>[{kind:"select",id:"scale",label:"Scale",default:"2",choices:[{value:"1",label:"Sharpen",hint:"the same size, sharper"},{value:"2",label:"2\xD7",hint:"twice the width and height"},{value:"3",label:"3\xD7",hint:"three times the width and height"},{value:"4",label:"4\xD7",hint:"four times the width and height"}]},W()],plan(t,e){let n=O(t);if(!n)return[];let o=G(e),i=it(Number(e.scale??2));return n.map(r=>({op:"boost",sources:[r],outputs:[d({sourcePath:r.path,target:o.target,suffix:ot(i),...o.output===void 0?{}:{output:o.output},...o.roots?.get(r.path)===void 0?{}:{sourceRoot:o.roots.get(r.path)}})],scale:i,target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}},_t={id:"remove-background",label:"Remove background",verb:"Removing",hint:"cut out the subject",requires:"remove-background",appliesTo:t=>O(t)!==void 0,unavailable:()=>"images only",options:()=>[W()],plan(t,e){let n=O(t);if(!n)return[];let o=G(e);return n.map(i=>({op:"remove-background",sources:[i],outputs:[d({sourcePath:i.path,target:o.target,suffix:"cutout",...o.output===void 0?{}:{output:o.output},...o.roots?.get(i.path)===void 0?{}:{sourceRoot:o.roots.get(i.path)}})],target:o.target,options:{background:o.background,keepMetadata:o.keepMetadata,...o.quality===void 0?{}:{quality:o.quality}}}))}};var rt=[{degrees:90,label:"90\xB0 right",suffix:"rotated-right"},{degrees:180,label:"180\xB0",suffix:"rotated-180"},{degrees:270,label:"90\xB0 left",suffix:"rotated-left"}],y=t=>t===90||t===180||t===270,Ut=(t,e)=>e===180?{...t}:{width:t.height,height:t.width},M=t=>rt.find(e=>e.degrees===t).suffix;import{dirname as at,join as H}from"node:path";var K="Same location",V="New subfolder";function st(t,e,n){return t===e?K:t===g("Desktop")?"Desktop":t===g("Downloads")?"Downloads":e!==void 0&&n!==void 0&&t===H(e,n)?V:h(t)||t}function T(t,e,n={}){return pt(at(t.path),e,n)}function pt(t,e,{subfolder:n}={}){let o=A(e.defaultOutput),i=e.lastOutput?A(e.lastOutput):void 0,r=f=>({label:st(f,t,n),path:f}),a=[r(o),...i?[r(i)]:[],r(g("Desktop")),...t===void 0?[]:[{label:K,path:t}],r(g("Downloads")),...n!==void 0&&t!==void 0?[{label:V,path:H(t,n)}]:[]],u=new Set,s=a.filter(f=>u.has(f.path)?!1:(u.add(f.path),!0));return{kind:"path",id:"destination",label:"Save to",default:o,presets:s,...i&&i!==o?{last:i}:{}}}var c=t=>typeof t=="string"&&t!==""?t:void 0;var ee=[2,1.5,1.25,.75,.5],ut=.25,dt=4,Y=-16;function q(t){return{wav:"m4a",aiff:"m4a",flac:"m4a",avi:"mp4",ogg:"opus"}[t]??t}var Z=t=>t.length===1&&t[0]?.kind==="media"?t[0]:void 0,ft=t=>t==="cut"||t==="mute"||t==="speed"||t==="resize"||t==="crop"||t==="rotate"||t==="loudness"||t==="extract"||t==="cleanup";function ct(t,e){let n=e.media??{},o=t.facts?.video,i=[];return e.extract&&i.push("audio"),n.cut&&i.push("trimmed"),n.mute&&i.push("muted"),n.cleanup?i.push("cleaned"):n.loudness!==void 0&&i.push("levelled"),n.speed!==void 0&&i.push(`${n.speed}x`),n.fps!==void 0&&i.push(`${n.fps}fps`),n.bitrate!==void 0&&i.push(`${n.bitrate}k`),e.crop&&i.push(I(e.crop.aspect)),e.resize&&i.push(o?b(l(o,e.resize)):"resized"),e.rotate&&i.push(M(e.rotate)),i.length===1?i[0]:"edited"}function mt(t,e){return t.map(n=>{let o=e.target??n.format,i={background:"#ffffff",keepMetadata:!1};e.media&&Object.keys(e.media).length&&(i.media=e.media),e.resize&&(i.resize=e.resize),e.rotate&&(i.rotate=e.rotate);let r=n.facts?.video;e.crop&&r&&(i.crop={aspect:e.crop.aspect,box:e.crop.box??x(r,e.crop.aspect)});let a=e.roots?.get(n.path),u=d({sourcePath:n.path,target:o,suffix:ct(n,e),...e.output===void 0?{}:{output:e.output},...a===void 0?{}:{sourceRoot:a}});return{op:"convert",sources:[n],outputs:[z(u,c(e.destination),c(e.name))],target:o,options:i}})}function S(t){let e={},n=t.cut;return n&&typeof n.start=="number"&&(e.cut={start:n.start,...typeof n.end=="number"?{end:n.end}:{}}),t.mute===!0&&(e.mute=!0),typeof t.speed=="number"&&(e.speed=t.speed),typeof t.fps=="number"&&(e.fps=t.fps),typeof t.bitrate=="number"&&(e.bitrate=t.bitrate),typeof t.loudness=="number"&&(e.loudness=t.loudness),t.cleanup===!0&&(e.cleanup=!0),Object.keys(e).length?e:void 0}var ne={id:"media-edit",label:"Edit",verb:"Editing",hint:"trim, mute, speed, resize, rotate, crop",appliesTo:t=>Z(t)!==void 0,unavailable:()=>"one video or audio file",options:()=>[],plan(t,e){let n=Z(t);if(!n||!ft(e.tool))return[];let o=e.tool,i={...typeof e.output=="string"?{output:e.output}:{},destination:e.destination,name:e.name};if(o==="cut"){let r=S(e)?.cut;if(!r)return[];i.media={cut:r}}if(o==="mute"&&(i.media={mute:!0}),o==="speed"){let r=e.speed;if(typeof r!="number"||r===1||r<ut||r>dt)return[];i.media={speed:r}}if(o==="loudness"&&(i.media={loudness:typeof e.loudness=="number"?e.loudness:Y}),o==="cleanup"){if(!n.facts?.audio)return[];i.media={cleanup:!0,loudness:Y}}if(o==="extract"){let r=n.facts?.audio;if(!r||!n.facts?.video)return[];i.extract=!0,i.target=Q(r.codec)}if(o==="resize"){if(typeof e.resize!="object"||e.resize===null)return[];i.resize=e.resize}if(o==="rotate"){if(!n.facts?.video||!y(e.turn))return[];i.rotate=e.turn}if(o==="crop"){let r=e.crop;if(!r?.aspect||!n.facts?.video)return[];i.crop=r}return mt([n],i)}};import{dirname as lt,join as gt}from"node:path";var ht=t=>p[t.format].media==="video",bt=t=>t.length===1&&t[0]?.kind==="image"?t[0]:void 0,yt=t=>t.length===1&&t[0]?.kind==="document"?t[0]:void 0,St="-small",m={min:30,max:100,step:35},kt=t=>{let e=Math.ceil((t-m.min)/m.step);return Math.min(m.max,m.min+Math.max(0,e)*m.step)},fe={id:"compress",label:"Compress",verb:"Compressing",hint:"make it smaller",appliesTo:t=>{if(t.length===1&&t[0]?.kind==="media")return!0;let e=bt(t);if(e!==void 0){let o=p[e.format];return o.lossy||o.quantisable===!0}return(yt(t)?.images?.compressible??0)>0},options(t,e,n){let o=t[0];if(!o)return[];let i=[{kind:"select",id:"mode",label:`Compress ${h(o.path)??"this file"}`,choices:[o.kind==="media"?{value:"quality",label:"By quality"}:{value:"quality",label:"By quality",hint:"pick a level, see the result"},{value:"size",label:"To a target size",hint:"smallest quality that fits"}],default:"quality"}];if(e.mode==="quality"&&o.kind==="media"&&!ht(o))i.push({kind:"slider",id:"bitrate",label:"Quality",min:32,max:320,step:32,default:96});else if(e.mode==="quality"){let r=o.kind==="image"&&p[o.format].quantisable===!0;i.push(r?{kind:"slider",id:"quality",label:"Quality",...m,default:kt(n.quality),points:!0}:{kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality})}else if(e.mode==="size")i.push({kind:"text",id:"size",label:"Target size",placeholder:"e.g. 500kb or 2mb"});else return i;return i.push(T(o,n)),i},plan(t,e){let n=e.mode;if(n!=="quality"&&n!=="size")throw k(`compressAction.plan() needs a mode of "quality" or "size", got ${JSON.stringify(n)}.`,"This is a caller bug, not a user-facing condition: walk options() before calling plan().");let o=t[0];if(!o)return[];let i=(h(o.path)??"file").replace(/\.[^.]+$/,""),r=typeof e.destination=="string"?e.destination:lt(o.path),a=o.kind==="media"?q(o.format):o.format,u=gt(r,$(i,`${St}${j(a)}`)),s=o.kind==="media"?S(e):void 0;return[{op:"convert",sources:[o],target:a,outputs:[u],options:{background:"#ffffff",keepMetadata:!1,...n==="quality"&&typeof e.quality=="number"?{quality:e.quality}:{},compress:{dither:e.dither===!0},...s?{media:s}:{}}}]}};function xt(t){return{kind:"select",id:"pages",label:"Pages",default:"all",choices:[{value:"all",label:"All pages",hint:`${t.pages} pages`},{value:"first",label:"First page only"},{value:"choose",label:"Choose pages",hint:"pick which ones"}]}}function It(){return{kind:"select",id:"dpi",label:"Resolution",default:"150",choices:[{value:"72",label:"72 dpi",hint:"screen"},{value:"150",label:"150 dpi",badge:"default"},{value:"300",label:"300 dpi",hint:"print"}]}}function zt(t,e){return Array.isArray(e)?w(e):e==="first"?[0]:typeof e=="string"&&e!=="all"&&e!==""?w(U(e,t.pages)):Array.from({length:t.pages},(n,o)=>o)}function Ot(t,e){let n=p[t.format].lossy,o=p[e].lossy;if(n&&!o)return{hint:"likely bigger",tone:"warn"};if(!n&&o)return{hint:"likely smaller",tone:"ok"}}function Mt(t){let e=_(t).filter(o=>o.id!==t.format),n=e[0];return{kind:"select",id:"target",label:`Convert ${p[t.format].label} to`,choices:e.map(o=>{let i=Ot(t,o.id);return{value:o.id,label:o.label,hint:i?.hint??o.hint,...i===void 0?{}:{tone:i.tone}}}),default:n?n.id:""}}function Tt(t){return{kind:"slider",id:"bitrate",label:"Quality",min:64,max:320,step:32,default:t==="opus"?96:128}}var Ft=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t);function At(t){let e=t.target,n=typeof e=="string"?E(e):void 0;if(!n)throw k(`convertAction.plan() requires a valid target format, got ${JSON.stringify(e)}.`,"This is a caller bug, not a user-facing condition: call options() and pass one of the target select choices before calling plan().");return n}var ke={id:"convert",label:"Convert",verb:"Converting",hint:"to another format",appliesTo:t=>t.length>=1,options(t,e,n){let o=t[0];if(!o)return[];let i=[Mt(o)],r=e.target;if(typeof r!="string")return i;o.kind==="document"&&R(r)&&i.push(xt(o),It());let a=p[r];return o.kind==="media"?a?.media==="sound"&&a.lossy&&i.push(Tt(r)):a?.lossy&&a.media===void 0&&i.push({kind:"slider",id:"quality",label:"Quality",min:1,max:100,step:5,default:n.quality}),i.push(T(o,n)),i},plan(t,e){let n=t[0];if(!n)return[];let o=At(e),i=o.id,r={background:typeof e.background=="string"?e.background:"#ffffff",keepMetadata:e.keepMetadata===!0};if(o.lossy&&typeof e.quality=="number"&&(r.quality=e.quality),n.kind==="media"){let s=S(e);s&&(r.media=s),Ft(e.resize)&&(r.resize=e.resize)}let a=typeof e.destination=="string"?e.destination:void 0;if(n.kind==="document"&&R(i)){let s=Number(e.dpi);r.dpi=Number.isFinite(s)&&s>0?s:150;let f=zt(n,e.pages);r.pages=f;let et=typeof e.sourceRoot=="string"?e.sourceRoot:void 0,nt=B(n.path,f,i,a,et);return[{op:"convert",sources:[n],outputs:nt,target:i,options:r}]}let u=D({sourcePath:n.path,target:i,...a===void 0?{}:{output:`${a}/`}});return N(u,n.path)&&(u=d({sourcePath:n.path,target:i,suffix:i,...a===void 0?{}:{output:`${a}/`}})),[{op:"convert",sources:[n],outputs:[u],target:i,options:r}]}};function Rt(t,e){if(!e.rotate)return v(t,e);let n=M(e.rotate);return e.trim||e.crop||e.resize?`${v(t,e)}-${n}`:n}function v(t,e){if(e.crop){let n=I(e.crop.aspect);if(!e.resize)return n;let o=e.crop.box??x(t,e.crop.aspect);return`${n}-${b(l(o,e.resize))}`}return e.trim&&e.resize?`trimmed-${X(e.resize)}`:e.resize?b(l(t,e.resize)):"trimmed"}function wt(t,e){if(e.trim&&e.crop)throw new Error("planEdit cannot trim and crop the same image");return t.map(n=>{let o=e.target??L(n),i={background:e.background,keepMetadata:e.keepMetadata,...e.quality===void 0?{}:{quality:e.quality},...e.trim?{trim:!0}:{},...e.resize?{resize:e.resize}:{},...e.crop?{crop:e.crop}:{},...e.rotate?{rotate:e.rotate}:{}},r=e.roots?.get(n.path),a=d({sourcePath:n.path,target:o,suffix:Rt(n,e),...e.output===void 0?{}:{output:e.output},...r===void 0?{}:{sourceRoot:r}});return{op:"convert",sources:[n],outputs:[z(a,c(e.destination),c(e.name))],target:o,options:i}})}var P=t=>t.length>0&&t.every(e=>e.kind==="image")?t:void 0,Pt=t=>typeof t=="object"&&t!==null&&("percent"in t||"width"in t||"height"in t),tt=t=>typeof t=="object"&&t!==null&&"aspect"in t&&typeof t.aspect=="object"&&t.aspect!==null&&"w"in t.aspect&&"h"in t.aspect;function F(t,e,n,o){return{id:t,label:e,verb:n,hint:o,appliesTo:i=>P(i)?.every(r=>t==="resize"||r.frames<=1)===!0,unavailable:i=>P(i)?"animated":"images only",options:()=>[],plan(i,r){let a=P(i);return a?t==="crop"&&!tt(r.crop)?[]:t==="turn"&&!y(r.turn)?[]:wt(a,{trim:t==="trim"||r.trim===!0,...y(r.turn)?{rotate:r.turn}:{},...Pt(r.resize)?{resize:r.resize}:{},...tt(r.crop)?{crop:r.crop}:{},...typeof r.target=="string"?{target:r.target}:{},...typeof r.output=="string"?{output:r.output}:{},...r.roots instanceof Map?{roots:r.roots}:{},destination:r.destination,name:r.name,background:typeof r.background=="string"?r.background:"#ffffff",keepMetadata:r.keepMetadata===!0,...typeof r.quality=="number"?{quality:r.quality}:{}}):[]}}}var Fe=F("trim","Trim edges","Trimming edges","cut empty borders"),Ae=F("resize","Resize","Resizing","smaller or larger"),Re=F("crop","Crop to shape","Cropping","change the shape"),we=F("turn","Rotate","Rotating","turn it");export{Bt as a,Jt as b,_t as c,V as d,T as e,pt as f,c as g,rt as h,Ut as i,ee as j,mt as k,ne as l,fe as m,ke as n,wt as o,Fe as p,Ae as q,Re as r,we as s};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as ht}from"./chunk-MF3KKEFB.js";import{b as jt}from"./chunk-I25E2XDH.js";import{b as me}from"./chunk-HZDYZ5RD.js";import{c as Ht}from"./chunk-QXNB5DQ2.js";import{f as de,g as tt,h as ge,i as he,j as pe}from"./chunk-KH5DHZ2U.js";import{na as gt,oa as $t,pa as Tt,qa as ce,sa as _t,ta as Rt}from"./chunk-WIPP5TWQ.js";import{c as le,i as ue}from"./chunk-KXKQDFHX.js";import{spawn as nn}from"node:child_process";import{existsSync as It}from"node:fs";import{mkdtemp as se,readFile as oe,rm as ae,writeFile as $r}from"node:fs/promises";import{tmpdir as fe}from"node:os";import{dirname as rn,join as O}from"node:path";import{createInterface as _r}from"node:readline";import{fileURLToPath as jr}from"node:url";var gn=new RegExp("\\p{M}","u"),Bt=new RegExp("\\p{L}","u"),hn=new RegExp("\\p{Nd}","u");function zt(t){let n=String.fromCodePoint(t);return gn.test(n)?"NSM":t>=1632&&t<=1641||t===1643||t===1644?"AN":hn.test(n)?"EN":t>=1424&&t<=1535||t>=64285&&t<=64335?Bt.test(n)?"R":"ON":t>=1536&&t<=1791||t>=1792&&t<=1983||t>=1872&&t<=1919||t>=2208&&t<=2303||t>=64336&&t<=65023||t>=65136&&t<=65279?Bt.test(n)?"AL":"ON":Bt.test(n)?"L":t===43||t===45?"ES":t===35||t===36||t===37||t===162||t===163||t===176?"ET":t===44||t===46||t===58||t===47||t===160?"CS":n===" "||n===" "||t===12288?"WS":"ON"}var pn={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","<":">",">":"<","\xAB":"\xBB","\xBB":"\xAB"};function pt(t){for(let n of t){let e=zt(n.codePointAt(0)??0);if(e==="R"||e==="AL")return!0;if(e==="L")return!1}return!1}function mn(t){for(let n of t){let e=zt(n.codePointAt(0)??0);if(e==="R"||e==="AL"||e==="AN")return!0}return!1}function be(t,n){let e=[...t];if(!n&&!mn(t))return t;let i=e.length,r=e.map(a=>zt(a.codePointAt(0)??0)),o=n?1:0,s=o?"R":"L";for(let a=0;a<i;a++){r[a]==="NSM"&&(r[a]=a>0?r[a-1]??"ON":o?"R":"L");let u=r[a];u==="L"||u==="R"||u==="AL"?s=u:u==="EN"&&s==="AL"&&(r[a]="AN")}for(let a=0;a<i;a++)r[a]==="AL"&&(r[a]="R");for(let a=1;a<i-1;a++){let u=r[a],l=r[a-1],g=r[a+1];(u==="ES"||u==="CS")&&l==="EN"&&g==="EN"?r[a]="EN":u==="CS"&&l==="AN"&&g==="AN"&&(r[a]="AN")}for(let a=0;a<i;a++){if(r[a]!=="ET")continue;let u=a;for(;u<i&&r[u]==="ET";)u++;if(r[a-1]==="EN"||r[u]==="EN")for(let l=a;l<u;l++)r[l]="EN";a=u-1}for(let a=0;a<i;a++)(r[a]==="ES"||r[a]==="ET"||r[a]==="CS")&&(r[a]="ON");let f=o?"R":"L";for(let a=0;a<i;a++)r[a]==="L"||r[a]==="R"?f=r[a]:r[a]==="EN"&&f==="L"&&(r[a]="L");let c=a=>a==="L"?"L":a==="R"||a==="EN"||a==="AN"?"R":void 0;for(let a=0;a<i;a++){if(r[a]!=="WS"&&r[a]!=="ON")continue;let u=a;for(;u<i&&(r[u]==="WS"||r[u]==="ON");)u++;let l=a>0?c(r[a-1]):o?"R":"L",g=u<i?c(r[u]):o?"R":"L",m=l!==void 0&&l===g?l:o?"R":"L";for(let S=a;S<u;S++)r[S]=m;a=u-1}let d=r.map(a=>o===0?a==="R"?1:a==="EN"||a==="AN"?2:0:a==="L"||a==="EN"||a==="AN"?2:1),h=e.map((a,u)=>u),p=Math.max(...d),b=Math.min(...d.filter(a=>a%2===1),Number.POSITIVE_INFINITY);for(let a=p;a>=b&&a>0;a--)for(let u=0;u<i;u++){if((d[h[u]]??0)<a)continue;let l=u;for(;l<i&&(d[h[l]]??0)>=a;)l++;let g=h.slice(u,l).reverse();h.splice(u,l-u,...g),u=l-1}return h.map(a=>{let u=e[a];return(d[a]??0)%2===1?pn[u]??u:u}).join("")}var bn=(t,n)=>{let e=t[0]+t[2]/2,i=t[1]+t[3]/2;return e>=n[0]&&e<=n[0]+n[2]&&i>=n[1]&&i<=n[1]+n[3]};function xn(t){let n=t.filter(e=>e.kind!=="text").map(e=>e.box);return t.filter(e=>e.kind!=="text"||!n.some(i=>bn(e.box,i)))}var yn=.002;function we(t,n){let e=f=>f.box[n],i=f=>f.box[n]+(n===0?f.box[2]:f.box[3]),r=[...t].sort((f,c)=>e(f)-e(c)),o=[],s=-1;for(let f of r){let c=o[o.length-1];c&&e(f)<=s+yn?(c.push(f),s=Math.max(s,i(f))):(o.push([f]),s=i(f))}return o}function wn(t){let n=we(t,1);if(n.length<2)return;let e=o=>Math.max(...o.map(s=>s.box[1]+s.box[3])),i=o=>Math.min(...o.map(s=>s.box[1])),r=1;for(let o=2;o<n.length;o++){let s=f=>i(n[f]??[])-e(n[f-1]??[]);s(o)>s(r)&&(r=o)}return[n.slice(0,r).flat(),n.slice(r).flat()]}function Wt(t){if(t.length<=1)return[...t];let n=we(t,0);if(n.length>1)return n.flatMap(Wt);let e=wn(t);return e?e.flatMap(Wt):[...t].sort((i,r)=>i.box[1]-r.box[1]||i.box[0]-r.box[0])}function Sn(t){let n=[];for(let e of t){let i=n[n.length-1],r=Math.max(e.lineHeight,i?.lineHeight??0);if(!(i!==void 0&&e.box[1]-(i.box[1]+i.box[3])<r&&Math.abs(e.box[0]-i.box[0])<2*r)){n.push({...e});continue}let s=Math.max(i.box[0]+i.box[2],e.box[0]+e.box[2]),f=e.box[1]+e.box[3];n[n.length-1]={...i,text:`${i.text} ${e.text}`,lines:i.lines+1,box:[i.box[0],i.box[1],s-i.box[0],f-i.box[1]]}}return n}function An(t){let n=t.flatMap(e=>Array(Math.max(1,e.lines)).fill(e.lineHeight));return n.sort((e,i)=>e-i),n[Math.floor(n.length/2)]??0}var kn=1.2,Pn=80,Gt=t=>t.replace(/\s*\n\s*/g," ").trim();function En(t,n,e){if(t.kind==="list")return{kind:"list",ordered:t.items.some(s=>s.marker==="decimal"||s.marker==="lowercase"||s.marker==="uppercase"),items:t.items.map(s=>Gt(s.text))};if(t.kind==="table"){let s=Math.max(...t.rows.map(f=>f.length));return{kind:"table",rows:t.rows.map(f=>Array.from({length:s},(c,d)=>Gt(f[d]??"")))}}let i=Gt(t.text);return!e&&t.lineHeight>=n*kn&&t.lines===1&&i.length<=Pn&&!/[.,;:!?]$/.test(i)?{kind:"heading",level:t.title?1:2,text:i}:{kind:"paragraph",text:i}}function fi(t){return t.map(n=>{let e=Wt(xn(n.blocks.filter(o=>o.kind!=="text"||o.text.trim()!=="")));n.lines&&(e=Sn(e.filter(o=>o.kind==="text")));let i=e.filter(o=>o.kind==="text"),r=An(i);return e.map(o=>En(o,r,e.length===1))})}var ci=t=>t.some(n=>n.length>0);function Kt(t){return t.replace(/[\\`*[\]<]/g,n=>`\\${n}`).replace(/(^|[^\p{L}\p{N}])_|_(?=[^\p{L}\p{N}]|$)/gu,n=>n.replace("_","\\_"))}function Tn(t){return t.replace(/^(#|>|[-+](?= )|(?<=^\d+)\.(?= ))/,"\\$1").replace(/^(\d+)\.(?= )/,"$1\\.")}var xe=t=>Tn(Kt(t));function Rn(t){if(t.kind==="heading")return`${"#".repeat(t.level)} ${Kt(t.text)}`;if(t.kind==="paragraph")return xe(t.text);if(t.kind==="list")return t.items.map((o,s)=>`${t.ordered?`${s+1}.`:"-"} ${xe(o)}`).join(`
|
|
4
|
-
`);let n=o=>Kt(o).replace(/\|/g,"\\|"),e=o=>`| ${o.map(n).join(" | ")} |`,[i=[],...r]=t.rows;return[e(i),`| ${i.map(()=>"---").join(" | ")} |`,...r.map(e)].join(`
|
|
5
|
-
`)}var Vt=t=>t.filter(n=>n.length>0);function Se(t){let n=Vt(t).map(e=>e.map(Rn).join(`
|
|
6
|
-
|
|
7
|
-
`));return n.length?`${n.join(`
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
`)}
|
|
12
|
-
`:""}function Fn(t){return t.kind==="heading"||t.kind==="paragraph"?t.text:t.kind==="list"?t.items.map((n,e)=>`${t.ordered?`${e+1}.`:"-"} ${n}`).join(`
|
|
13
|
-
`):t.rows.map(n=>n.join(" ")).join(`
|
|
14
|
-
`)}function Ae(t){let n=Vt(t).map(e=>e.map(Fn).join(`
|
|
15
|
-
|
|
16
|
-
`));return n.length?`${n.join(`
|
|
17
|
-
|
|
18
|
-
`)}
|
|
19
|
-
`:""}var Nn="table{border-collapse:collapse;width:100%;margin:0 0 8pt}th,td{border:1px solid #c7c7cc;padding:2pt 6pt;text-align:left;vertical-align:top}ol{margin:0 0 8pt}",ye='<p style="margin:0;font-size:5pt"> </p>';function vn(t){if(t.kind==="heading")return`<h${t.level}>${tt(t.text)}</h${t.level}>`;if(t.kind==="paragraph")return`<p>${tt(t.text)}</p>`;if(t.kind==="list"){let o=t.ordered?"ol":"ul";return`<${o}>${t.items.map(s=>`<li>${tt(s)}</li>`).join("")}</${o}>`}let[n=[],...e]=t.rows,i=(o,s)=>`<tr>${o.map(f=>`<${s}>${tt(f)}</${s}>`).join("")}</tr>`,r=`<table>${i(n,"th")}${e.map(o=>i(o,"td")).join("")}</table>`;return`${ye}${r}${ye}`}function ke(t,n){let e=Vt(t).map(i=>i.map(vn).join(`
|
|
20
|
-
`));return["<!doctype html>",`<html><head><meta charset="utf-8"><title>${tt(n)}</title><style>${ge}${Nn}</style></head><body>`,e.join(`
|
|
21
|
-
<hr>
|
|
22
|
-
`),"</body></html>"].join(`
|
|
23
|
-
`)}var Un=[[65,90,"latin"],[97,122,"latin"],[170,170,"latin"],[186,186,"latin"],[192,591,"latin"],[7680,7935,"latin"],[11360,11391,"latin"],[42784,43007,"latin"],[65313,65338,"latin"],[65345,65370,"latin"],[880,1023,"greek"],[7936,8191,"greek"],[1024,1327,"cyrillic"],[7296,7311,"cyrillic"],[11744,11775,"cyrillic"],[42560,42655,"cyrillic"],[1328,1423,"armenian"],[1424,1535,"hebrew"],[64285,64335,"hebrew"],[1536,1791,"arabic"],[1872,1919,"arabic"],[2208,2303,"arabic"],[64336,65023,"arabic"],[65136,65279,"arabic"],[1792,1871,"syriac"],[1920,1983,"thaana"],[2304,2431,"devanagari"],[2432,2559,"bengali"],[2560,2687,"gurmukhi"],[2688,2815,"gujarati"],[2816,2943,"oriya"],[2944,3071,"tamil"],[3072,3199,"telugu"],[3200,3327,"kannada"],[3328,3455,"malayalam"],[3456,3583,"sinhala"],[3584,3711,"thai"],[3712,3839,"lao"],[3840,4095,"tibetan"],[4096,4255,"myanmar"],[4256,4351,"georgian"],[4352,4607,"hangul"],[4608,5023,"ethiopic"],[6016,6143,"khmer"],[6144,6319,"mongolian"],[12352,12447,"kana"],[12448,12543,"kana"],[12784,12799,"kana"],[65382,65439,"kana"],[110592,110959,"kana"],[12592,12687,"hangul"],[43360,43391,"hangul"],[44032,55295,"hangul"],[65440,65500,"hangul"],[11904,12255,"han"],[12288,12351,"han"],[12544,12591,"han"],[12704,12735,"han"],[12800,13311,"han"],[13312,19903,"han"],[19968,40959,"han"],[63744,64255,"han"],[65072,65103,"han"],[65281,65312,"han"],[65371,65381,"han"],[65504,65510,"han"],[131072,205743,"han"],[127744,129791,"emoji"],[9728,10175,"symbols"]];function et(t){if(t<128)return t>=65&&t<=90||t>=97&&t<=122?"latin":void 0;for(let[n,e,i]of Un)if(t>=n&&t<=e)return i}var Ln=new Set(["latin","greek","cyrillic","han","kana","hangul","armenian","georgian","ethiopic","emoji","symbols"]),Pe=new Set([...Ln,"arabic","hebrew","thai","lao"]),Mn={latin:"Latin",greek:"Greek",cyrillic:"Cyrillic",han:"Chinese",kana:"Japanese",hangul:"Korean",arabic:"Arabic",hebrew:"Hebrew",thai:"Thai",lao:"Lao",armenian:"Armenian",georgian:"Georgian",devanagari:"Devanagari",bengali:"Bengali",gurmukhi:"Gurmukhi",gujarati:"Gujarati",oriya:"Odia",tamil:"Tamil",telugu:"Telugu",kannada:"Kannada",malayalam:"Malayalam",sinhala:"Sinhala",tibetan:"Tibetan",myanmar:"Burmese",khmer:"Khmer",ethiopic:"Ethiopic",mongolian:"Mongolian",syriac:"Syriac",thaana:"Thaana",emoji:"emoji",symbols:"symbols"};function Ee(t){return Mn[t]}function In(t){let n=new Set;for(let e of t){let i=et(e.codePointAt(0)??0);i!==void 0&&n.add(i)}return[...n]}function Jt(t,n){let e=n?.toLowerCase().replace("_","-");if(e?.startsWith("ja"))return"ja";if(e?.startsWith("ko"))return"ko";if(e==="zh-tw"||e==="zh-hant"||e==="zh-hk")return"zh-TW";if(e?.startsWith("zh"))return"zh";let i=In(t);return i.includes("kana")?"ja":i.includes("hangul")?"ko":"zh"}var Dn={ja:"ja-JP",ko:"ko-KR",zh:"zh-CN","zh-TW":"zh-TW"},Cn={arabic:"ar-SA",hebrew:"he-IL",thai:"th-TH",lao:"lo-LA",devanagari:"hi-IN",bengali:"bn-IN",gurmukhi:"pa-IN",gujarati:"gu-IN",oriya:"or-IN",tamil:"ta-IN",telugu:"te-IN",kannada:"kn-IN",malayalam:"ml-IN",sinhala:"si-LK",khmer:"km-KH",myanmar:"my-MM",tibetan:"bo-CN",armenian:"hy-AM",georgian:"ka-GE",ethiopic:"am-ET",syriac:"syr-SY",thaana:"dv-MV"},On=new Set(["latin","greek","cyrillic","armenian","georgian","ethiopic","mongolian","emoji","symbols"]);function $n(t){return t===void 0?"neutral":t==="han"||t==="kana"||t==="hangul"?"eastAsia":On.has(t)?"latin":"complex"}var _n=new Set(["arabic","hebrew","syriac","thaana"]);function Te(t,n){let e=Dn[Jt(t,n)],i=[],r="";for(let o of t){let s=et(o.codePointAt(0)??0),f=$n(s);if(f==="neutral"){let p=i.at(-1);p?p.text+=o:r+=o;continue}let c=s!==void 0&&_n.has(s),d=f==="eastAsia"?e:f==="complex"&&s?Cn[s]:void 0,h=i.at(-1);h&&h.kind===f&&h.rtl===c&&h.lang===d?h.text+=o:i.push({text:r+o,kind:f,rtl:c,...d?{lang:d}:{}}),r=""}return r&&i.push({text:r,kind:"latin",rtl:!1}),i}import{existsSync as ur,readFileSync as dr}from"node:fs";import{dirname as gr,join as bt}from"node:path";import{fileURLToPath as hr}from"node:url";import{gunzipSync as pr}from"node:zlib";var nt=new Map;function jn(){let t=new Map,n=[[64336,64511],[65152,65276]];for(let[e,i]of n)for(let r=e;r<=i;r++){let o=String.fromCodePoint(r).normalize("NFKD");if(o===String.fromCodePoint(r))continue;let s=t.get(o);s?s.push(r):t.set(o,[r])}for(let[e,i]of t)i.length===4?nt.set(e,{isolated:i[0]??0,final:i[1]??0,initial:i[2]??0,medial:i[3]??0}):i.length===2&&nt.set(e,{isolated:i[0]??0,final:i[1]??0,initial:0,medial:0})}jn();var Re=t=>t>=1611&&t<=1631||t===1648||t>=1750&&t<=1756||t>=1759&&t<=1764||t===1767||t===1768||t>=1770&&t<=1773,Fe=1604,Hn=new Set([1570,1571,1573,1575]),ve=t=>nt.has(String.fromCodePoint(t)),Ne=t=>(nt.get(String.fromCodePoint(t))?.initial??0)!==0;function Ue(t){for(let n of t)if(ve(n.codePointAt(0)??0))return!0;return!1}function Le(t,n=()=>!0){let e=[...t].map(o=>o.codePointAt(0)??0),i=[],r=!1;for(let o=0;o<e.length;o++){let s=e[o]??0;if(s===8204||s===8205){r=s===8205?r:!1,i.push(s);continue}if(Re(s)){i.push(s);continue}let f=nt.get(String.fromCodePoint(s));if(!f){r=!1,i.push(s);continue}let c=e[o+1]??0;if(s===Fe&&Hn.has(c)){let a=nt.get(String.fromCodePoint(Fe,c)),u=a?r?a.final:a.isolated:0;if(u!==0&&n(u)){i.push(u),r=!1,o++;continue}}let d=o+1;for(;d<e.length&&Re(e[d]??0);)d++;let h=e[d]??0,p=Ne(s)&&h!==8204&&(ve(h)||h===8205),b=r?p?f.medial:f.final:p?f.initial:f.isolated;i.push(b!==0&&n(b)?b:s),r=Ne(s)}return String.fromCodePoint(...i)}function Me(t){return String.fromCodePoint(t).normalize("NFKD")}import{execFile as Zn}from"node:child_process";import{existsSync as Qn,readdirSync as tr,readFileSync as er,statSync as nr}from"node:fs";import{homedir as rr}from"node:os";import{posix as Xt,win32 as Ke}from"node:path";var v={charset:15,encoding:16,charStrings:17,private:18,subrs:19,ros:1230,fdArray:1236,fdSelect:1237};function Y(t,n){let e=(t[n]??0)*256+(t[n+1]??0);if(e===0)return{items:[],end:n+2};let i=t[n+2]??1,r=[],o=n+3;for(let c=0;c<=e;c++){let d=0;for(let h=0;h<i;h++)d=d*256+(t[o+h]??0);r.push(d),o+=i}let s=o-1,f=[];for(let c=0;c<e;c++)f.push(t.subarray(s+(r[c]??0),s+(r[c+1]??0)));return{items:f,end:s+(r[e]??1)}}function X(t){if(t.length===0)return new Uint8Array([0,0]);let n=t.reduce((f,c)=>f+c.length,0)+1,e=n<256?1:n<65536?2:n<16777216?3:4,i=new Uint8Array(3+(t.length+1)*e+n-1);i[0]=t.length>>8,i[1]=t.length&255,i[2]=e;let r=1,o=3,s=f=>{for(let c=e-1;c>=0;c--)i[o++]=f>>8*c&255};s(r);for(let f of t)r+=f.length,s(r);for(let f of t)i.set(f,o),o+=f.length;return i}function Yt(t){let n=[],e=[],i=0,r=0;for(;r<t.length;){let o=t[r]??0;if(o<=21){let s=o;r++,o===12&&(s=1200+(t[r]??0),r++),n.push({op:s,operands:e,raw:t.subarray(i,r)}),e=[],i=r}else if(o===28)e.push(((t[r+1]??0)<<8|(t[r+2]??0))<<16>>16),r+=3;else if(o===29)e.push((t[r+1]??0)<<24|(t[r+2]??0)<<16|(t[r+3]??0)<<8|(t[r+4]??0)),r+=5;else if(o===30){for(r++;r<t.length&&((t[r]??0)&15)!==15&&(t[r]??0)>>4!==15;)r++;r++,e.push(0)}else o>=32&&o<=246?(e.push(o-139),r++):o>=247&&o<=250?(e.push((o-247)*256+(t[r+1]??0)+108),r+=2):o>=251&&o<=254?(e.push(-(o-251)*256-(t[r+1]??0)-108),r+=2):r++}return n}function Bn(t){return[29,t>>24&255,t>>16&255,t>>8&255,t&255]}function zn(t){return t>=1200?[12,t-1200]:[t]}function W(t,n){return Uint8Array.from([...n.flatMap(Bn),...zn(t)])}function Ft(t){let n=new Uint8Array(t.reduce((i,r)=>i+r.length,0)),e=0;for(let i of t)n.set(i,e),e+=i.length;return n}var q=(t,n)=>t.find(e=>e.op===n);function Ie(t){return t<1240?107:t<33900?1131:32768}function De(t){let n=t[2]??4,e=Y(t,n),i=Y(t,e.end),r=Y(t,i.end),o=Y(t,r.end),s=Yt(i.items[0]??new Uint8Array),f=q(s,v.ros)!==void 0,c=q(s,v.charStrings)?.operands[0]??0,d=Y(t,c),h=d.items.length,p=q(s,v.charset)?.operands[0]??0,b=new Array(h).fill(0);if(p<=2)for(let w=0;w<h;w++)b[w]=w;else{let w=t[p]??0,x=p+1,E=1;if(w===0)for(;E<h;E++,x+=2)b[E]=(t[x]??0)<<8|(t[x+1]??0);else for(;E<h;){let T=(t[x]??0)<<8|(t[x+1]??0),R=t[x+2]??0;x+=3,w===2&&(R=R<<8|(t[x]??0),x++);for(let I=0;I<=R&&E<h;I++,E++)b[E]=T+I}}let a=q(s,v.fdArray)?.operands[0],u=q(s,v.fdSelect)?.operands[0],l=a===void 0?[]:Y(t,a).items.map(Yt),g=new Array(h).fill(0);if(u!==void 0)if((t[u]??0)===0)for(let x=0;x<h;x++)g[x]=t[u+1+x]??0;else{let x=(t[u+1]??0)<<8|(t[u+2]??0),E=u+3;for(let T=0;T<x;T++,E+=3){let R=(t[E]??0)<<8|(t[E+1]??0),I=(t[E+3]??0)<<8|(t[E+4]??0);for(let D=R;D<I&&D<h;D++)g[D]=t[E+2]??0}}let m=w=>{let[x,E]=q(w,v.private)?.operands??[];if(x===void 0||E===void 0)return{dict:[],subrs:[]};let T=Yt(t.subarray(E,E+x)),R=q(T,v.subrs)?.operands[0];return{dict:T,subrs:R===void 0?[]:Y(t,E+R).items}},S=m(s),A=l.length>0?l.map(m):[S];return{cidKeyed:f,glyphCount:h,codeOf:w=>f?b[w]??0:w,subset(w){let x=new Set([0]);for(let y of w)y>=0&&y<h&&x.add(y);let E=Math.max(...x)+1,T=new Map;for(let y of x){let N=Kn(d.items[y]??new Uint8Array,(A[g[y]??0]??S).subrs,o.items);if(!N){T.clear();break}T.set(y,N)}let R=T.size===x.size,I=A.map(()=>new Set),D=new Set;if(!R)for(let y of x)Vn(d.items[y]??new Uint8Array,A[g[y]??0]??S,{local:I[g[y]??0]??new Set,global:D,gsubrs:o.items});let K=y=>R?T.get(y):d.items[y],Q=new Uint8Array([14]),k=new Uint8Array([11]),P=f?[...x].sort((y,N)=>y-N):Array.from({length:E},(y,N)=>N),z=(y,N)=>{if(N.size===0)return[];let B=y.length>=33900?33900:y.length>=1240?1240:0,J=Math.max(...N)+1;return y.slice(0,Math.max(J,B)).map((dt,Ct)=>N.has(Ct)?dt:k)},U=X(R?[]:z(o.items,D)),C=X(P.map(y=>x.has(y)?K(y)??Q:Q)),M=Gn(P.map(y=>b[y]??0)),j=l.length>0?Wn(P.map(y=>g[y]??0)):void 0,G=A.map((y,N)=>{let B=X(R?[]:z(y.subrs,I[N]??new Set)),J=y.dict.filter(Ot=>Ot.op!==v.subrs).map(Ot=>Ot.raw),dt=!R&&y.subrs.length>0,Ct=dt?W(v.subrs,[0]):new Uint8Array,dn=Ft([...J]).length+Ct.length;return{dict:Ft([...J,...dt?[W(v.subrs,[dn])]:[]]),subrs:dt?B:new Uint8Array}}),st=Uint8Array.from([1,0,4,4]),at=X(e.items),ft=X(r.items),wt=y=>{let N=[];for(let B of s)B.op===v.charset?N.push(W(v.charset,[y.charset])):B.op===v.charStrings?N.push(W(v.charStrings,[y.charStrings])):B.op===v.fdArray?N.push(W(v.fdArray,[y.fdArray])):B.op===v.fdSelect?N.push(W(v.fdSelect,[y.fdSelect])):B.op===v.private?N.push(W(v.private,[...y.priv])):B.op===v.encoding?N.push(W(v.encoding,[0])):N.push(B.raw);return X([Ft(N)])},St=wt({charset:0,charStrings:0,fdArray:0,fdSelect:0,priv:[0,0]}).length,H=st.length+at.length+St+ft.length+U.length,At=H;H+=M.length;let kt=H;H+=j?.length??0;let Pt=H;H+=C.length;let ct=y=>X(l.map((N,B)=>Ft(N.map(J=>J.op===v.private?W(v.private,[...y[B]??[0,0]]):J.raw)))),Et=H;H+=l.length>0?ct(l.map(()=>[0,0])).length:0;let F=[];for(let y of G)F.push([y.dict.length,H]),H+=y.dict.length+y.subrs.length;let $=wt({charset:At,charStrings:Pt,fdArray:Et,fdSelect:kt,priv:F[0]??[0,0]}),lt=[st,at,$,ft,U,M,...j?[j]:[],C,...l.length>0?[ct(F)]:[],...G.flatMap(y=>[y.dict,y.subrs])],ut=new Uint8Array(lt.reduce((y,N)=>y+N.length,0)),V=0;for(let y of lt)ut.set(y,V),V+=y.length;return ut}}}function Gn(t){let n=[2],e=1;for(;e<t.length;){let o=t[e]??0,s=0;for(;e+s+1<t.length&&(t[e+s+1]??0)===o+s+1;)s++;n.push(o>>8,o&255,s>>8,s&255),e+=s+1}let i=1+2*Math.max(0,t.length-1);if(n.length<=i)return Uint8Array.from(n);let r=[0];for(let o=1;o<t.length;o++)r.push((t[o]??0)>>8,(t[o]??0)&255);return Uint8Array.from(r)}function Wn(t){let n=[],e=-1,i=0;return t.forEach((r,o)=>{r!==e&&(n.push(o>>8,o&255,r),e=r,i++)}),Uint8Array.from([3,i>>8,i&255,...n,t.length>>8,t.length&255])}function Kn(t,n,e){let i=[],r=[],o=[],s=[],f=0,c=!1,d=()=>{r.length=0,o.length=0,s.length=0},h=(a,u)=>{r.push(i.length),o.push(u.length),s.push(a),i.push(...u)},p=(a,u)=>{if(u>10)return c=!0,!0;let l=0;for(;l<a.length&&!c;){let g=a[l]??0;if(l++,g===28){let m=[28,a[l]??0,a[l+1]??0];h(((a[l]??0)<<8|(a[l+1]??0))<<16>>16,m),l+=2}else if(g>=32&&g<=246)h(g-139,[g]);else if(g>=247&&g<=250)h((g-247)*256+(a[l]??0)+108,[g,a[l]??0]),l++;else if(g>=251&&g<=254)h(-(g-251)*256-(a[l]??0)-108,[g,a[l]??0]),l++;else if(g===255)h(0,[255,a[l]??0,a[l+1]??0,a[l+2]??0,a[l+3]??0]),l+=4;else if(g===10||g===29){let m=g===10?n:e,S=s.pop(),A=r.pop(),w=o.pop();if(S===void 0||A===void 0||w===void 0||A+w!==i.length)return c=!0,!0;let x=m[S+Ie(m.length)];if(x===void 0)return c=!0,!0;if(i.length=A,p(x,u+1))return!0}else{if(g===11)return!1;if(g===14)return i.push(14),!0;if(g===1||g===3||g===18||g===23)f+=s.length>>1,d(),i.push(g);else if(g===19||g===20){f+=s.length>>1,d();let m=f+7>>3;i.push(g,...Array.from(a.subarray(l,l+m))),l+=m}else if(g===12){let m=a[l++]??0;if(m>=34&&m<=37)d(),i.push(12,m);else return c=!0,!0}else d(),i.push(g)}}return!1},b=p(t,0);if(!c)return b||i.push(14),Uint8Array.from(i)}function Vn(t,n,e){let i=new Set,r=!1,o=0,s=[],f=(c,d)=>{if(d>10)return r=!0,!0;let h=0;for(;h<c.length;){let p=c[h]??0;if(h++,p>=32||p===28){p===28?(s.push(((c[h]??0)<<8|(c[h+1]??0))<<16>>16),h+=2):p<=246?s.push(p-139):p<=250?s.push((p-247)*256+(c[h++]??0)+108):p<=254?s.push(-(p-251)*256-(c[h++]??0)-108):(s.push(((c[h]??0)<<24|(c[h+1]??0)<<16|(c[h+2]??0)<<8|(c[h+3]??0))/65536),h+=4);continue}if(p===10||p===29){let b=p===10?n.subrs:e.gsubrs,a=s.pop();if(a===void 0)return r=!0,!0;let u=a+Ie(b.length),l=b[u];if(l===void 0)return r=!0,!0;let g=`${p}:${u}:${o}`;if(!i.has(g)&&(i.add(g),(p===10?e.local:e.global).add(u),f(l,d+1)))return!0;continue}if(p===11)return!1;if(p===14)return!0;if(p===1||p===3||p===18||p===23){o+=s.length>>1,s.length=0;continue}if(p===19||p===20){o+=s.length>>1,s.length=0,h+=o+7>>3;continue}if(p===12){let b=c[h++]??0;if(b>=34&&b<=37)s.length=0;else return r=!0,!0;continue}s.length=0}return!1};f(t,0),r&&(n.subrs.forEach((c,d)=>{e.local.add(d)}),e.gsubrs.forEach((c,d)=>{e.global.add(d)}))}var Oe=32,$e=1,_e=8,je=64,He=128;function Be(t){let n=new DataView(t.buffer,t.byteOffset,t.byteLength);return String.fromCharCode(...t.subarray(0,4))==="ttcf"?n.getUint32(8):1}function Nt(t,n=0){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=String.fromCharCode(...t.subarray(0,4))==="ttcf"?e.getUint32(12+n*4):0,r=new Map,o=e.getUint16(i+4);for(let k=0;k<o;k++){let P=i+12+k*16,z=String.fromCharCode(...t.subarray(P,P+4));r.set(z,{offset:e.getUint32(P+8),length:e.getUint32(P+12)})}let s=k=>{let P=r.get(k);if(!P)throw new Error(`font has no ${k} table`);return P},f=s("head").offset,c=e.getUint16(f+18),d=e.getInt16(f+50)===1,h=[e.getInt16(f+36),e.getInt16(f+38),e.getInt16(f+40),e.getInt16(f+42)],p=s("hhea").offset,b=e.getInt16(p+4),a=e.getInt16(p+6),u=e.getUint16(p+34),l=e.getUint16(s("maxp").offset+4),g=s("hmtx").offset,m=r.get("OS/2"),S=m&&e.getUint16(m.offset)>=2?e.getInt16(m.offset+88):Math.round(c*.714),A=Yn(e,s("cmap").offset),w=k=>e.getUint16(g+Math.min(k,u-1)*4),x=k=>k<u?e.getInt16(g+k*4+2):e.getInt16(g+u*4+(k-u)*2),E=k=>{let P=A(k);return P===void 0||P===0||P>=l?void 0:P},T=k=>{let P=s(k);return t.subarray(P.offset,P.offset+P.length)},R=r.get("CFF ");if(R){let k=De(t.subarray(R.offset,R.offset+R.length));return{unitsPerEm:c,ascent:b,descent:a,capHeight:S,bbox:h,outlines:"cff",variable:r.has("fvar"),cidKeyed:k.cidKeyed,glyphOf:E,codeOf:P=>k.codeOf(P),advance:w,subset:P=>({data:k.subset(P)})}}let I=s("loca").offset,D=s("glyf"),K=k=>d?[e.getUint32(I+k*4),e.getUint32(I+k*4+4)]:[e.getUint16(I+k*2)*2,e.getUint16(I+k*2+2)*2],Q=k=>{let[P,z]=K(k);if(z<=P)return[];let U=D.offset+P;if(e.getInt16(U)>=0)return[];let C=[],M=U+10;for(;;){let j=e.getUint16(M);if(C.push(e.getUint16(M+2)),M+=4+(j&$e?4:2),j&_e?M+=2:j&je?M+=4:j&He&&(M+=8),!(j&Oe))break}return C};return{unitsPerEm:c,ascent:b,descent:a,capHeight:S,bbox:h,outlines:"glyf",variable:r.has("fvar"),cidKeyed:!1,glyphOf:E,codeOf:k=>k,advance:w,subset(k){let P=new Set,z=[0,...k];for(let F=z.pop();F!==void 0;F=z.pop())P.has(F)||(P.add(F),z.push(...Q(F)));let U=[...P].sort((F,$)=>F-$),C=new Map(U.map((F,$)=>[F,$])),M=new Uint32Array(U.length+1),j=[],G=0;U.forEach((F,$)=>{M[$]=G;let[lt,ut]=K(F);if(ut>lt){let V=Uint8Array.from(t.subarray(D.offset+lt,D.offset+ut));new DataView(V.buffer).getInt16(0)<0&&Jn(V,C),j.push(V),G+=V.length;let y=(4-G%4)%4;y&&(j.push(new Uint8Array(y)),G+=y)}}),M[U.length]=G;let st=new Uint8Array(G),at=0;for(let F of j)st.set(F,at),at+=F.length;let ft=new Uint8Array((U.length+1)*4),wt=new DataView(ft.buffer);M.forEach((F,$)=>{wt.setUint32($*4,F)});let St=new Uint8Array(U.length*4),H=new DataView(St.buffer);U.forEach((F,$)=>{H.setUint16($*4,w(F)),H.setInt16($*4+2,x(F))});let At=Uint8Array.from(t.subarray(f,f+s("head").length)),kt=new DataView(At.buffer);kt.setUint32(8,0),kt.setInt16(50,1);let Pt=Uint8Array.from(T("hhea"));new DataView(Pt.buffer).setUint16(34,U.length);let ct=Uint8Array.from(T("maxp"));new DataView(ct.buffer).setUint16(4,U.length);let Et=new Uint16Array((U.at(-1)??0)+1);for(let[F,$]of C)Et[F]=$;return{data:qn([["glyf",st],["head",At],["hhea",Pt],["hmtx",St],["loca",ft],["maxp",ct]]),cidToGid:Et}}}}function Jn(t,n){let e=new DataView(t.buffer,t.byteOffset,t.byteLength),i=10;for(;;){let r=e.getUint16(i);if(e.setUint16(i+2,n.get(e.getUint16(i+2))??0),i+=4+(r&$e?4:2),r&_e?i+=2:r&je?i+=4:r&He&&(i+=8),!(r&Oe))break}}function Ce(t,n){let e=0,i=t.length-1,r=-1;for(;e<=i;){let o=e+i>>1;(t[o]??0)<=n?(r=o,e=o+1):i=o-1}return r}function Yn(t,n){let e=t.getUint16(n+2),i;for(let r=0;r<e;r++){let o=t.getUint16(n+4+r*8),s=t.getUint16(n+4+r*8+2),f=n+t.getUint32(n+4+r*8+4),c=t.getUint16(f);if(o===3&&(s===1||s===10)||o===0){if(c===12){let h=t.getUint32(f+12),p=new Uint32Array(h);for(let b=0;b<h;b++)p[b]=t.getUint32(f+16+b*12);return b=>{let a=Ce(p,b);if(a<0)return;let u=t.getUint32(f+16+a*12+4);if(!(b>u))return t.getUint32(f+16+a*12+8)+(b-(p[a]??0))}}if(c===4&&i===void 0){let h=t.getUint16(f+6)/2,p=f+14,b=p+h*2+2,a=b+h*2,u=a+h*2,l=new Uint32Array(h);for(let g=0;g<h;g++)l[g]=t.getUint16(b+g*2);i=g=>{if(g>65535)return;let m=Ce(l,g);if(m<0||g>t.getUint16(p+m*2))return;let S=t.getUint16(u+m*2);if(S===0)return g+t.getInt16(a+m*2)&65535;let A=t.getUint16(u+m*2+S+(g-(l[m]??0))*2);return A===0?void 0:A+t.getInt16(a+m*2)&65535}}}}if(i)return i;throw new Error("font has no Unicode cmap")}function Xn(t){let n=new Uint8Array(Math.ceil(t.length/4)*4);n.set(t);let e=new DataView(n.buffer),i=0;for(let r=0;r<n.length;r+=4)i=i+e.getUint32(r)>>>0;return i}function qn(t){let n=[...t].sort(([c],[d])=>c<d?-1:1),e=12+n.length*16,i=n.reduce((c,[,d])=>c+Math.ceil(d.length/4)*4,e),r=new Uint8Array(i),o=new DataView(r.buffer);o.setUint32(0,65536),o.setUint16(4,n.length);let s=Math.floor(Math.log2(n.length));o.setUint16(6,2**s*16),o.setUint16(8,s),o.setUint16(10,n.length*16-2**s*16);let f=e;return n.forEach(([c,d],h)=>{let p=12+h*16;r.set(new TextEncoder().encode(c),p),o.setUint32(p+4,Xn(d)),o.setUint32(p+8,f),o.setUint32(p+12,d.length),r.set(d,f),f+=Math.ceil(d.length/4)*4}),r}var vt={platform:process.platform,env:process.env,home:rr(),exists:t=>Qn(t),list:t=>{try{return tr(t)}catch{return[]}},run:(t,n)=>new Promise(e=>{Zn(t,n,{timeout:5e3,windowsHide:!0,maxBuffer:4e6},(i,r)=>e(i?void 0:r))}),read:t=>{try{return nr(t).size>1e8?void 0:er(t)}catch{return}}},ir={zh:[["msyh.ttc",0],["simsun.ttc",0],["simhei.ttf",0],["Deng.ttf",0],["arialuni.ttf",0]],"zh-TW":[["msjh.ttc",0],["mingliu.ttc",0],["msyh.ttc",0],["arialuni.ttf",0]],ja:[["YuGothR.ttc",0],["YuGothM.ttc",0],["meiryo.ttc",0],["msgothic.ttc",0],["msmincho.ttc",0],["arialuni.ttf",0]],ko:[["malgun.ttf",0],["gulim.ttc",0],["batang.ttc",0],["arialuni.ttf",0]],arabic:[["segoeui.ttf",0],["arial.ttf",0],["tahoma.ttf",0],["times.ttf",0],["arialuni.ttf",0]],hebrew:[["segoeui.ttf",0],["arial.ttf",0],["tahoma.ttf",0],["times.ttf",0],["arialuni.ttf",0]],thai:[["LeelawUI.ttf",0],["leelawad.ttf",0],["tahoma.ttf",0],["arialuni.ttf",0]],other:[["seguisym.ttf",0],["segoeui.ttf",0],["arial.ttf",0],["arialuni.ttf",0],["malgun.ttf",0],["msyh.ttc",0]]},or={zh:[["PingFang.ttc",0],["STHeiti Light.ttc",1],["Hiragino Sans GB.ttc",0],["Arial Unicode.ttf",0]],"zh-TW":[["PingFang.ttc",2],["STHeiti Light.ttc",0],["Hiragino Sans GB.ttc",0],["Arial Unicode.ttf",0]],ja:[["\u30D2\u30E9\u30AE\u30CE\u89D2\u30B4\u30B7\u30C3\u30AF W3.ttc",0],["Hiragino Sans GB.ttc",0],["AquaKana.ttc",0],["Arial Unicode.ttf",0]],ko:[["AppleSDGothicNeo.ttc",0],["Arial Unicode.ttf",0]],arabic:[["GeezaPro.ttc",0],["SFArabic.ttf",0],["Arial Unicode.ttf",0]],hebrew:[["ArialHB.ttc",0],["Arial Unicode.ttf",0]],thai:[["Thonburi.ttc",0],["Arial Unicode.ttf",0]],other:[["Arial Unicode.ttf",0],["Apple Symbols.ttf",0],["Arial.ttf",0]]},ze={zh:[["NotoSansCJK-Regular.ttc",2],["NotoSansCJKsc-Regular.otf",0],["wqy-zenhei.ttc",0],["wqy-microhei.ttc",0],["DroidSansFallbackFull.ttf",0],["DroidSansFallback.ttf",0]],"zh-TW":[["NotoSansCJK-Regular.ttc",3],["NotoSansCJKtc-Regular.otf",0],["wqy-zenhei.ttc",0],["DroidSansFallbackFull.ttf",0]],ja:[["NotoSansCJK-Regular.ttc",0],["NotoSansCJKjp-Regular.otf",0],["DroidSansFallbackFull.ttf",0],["TakaoGothic.ttf",0]],ko:[["NotoSansCJK-Regular.ttc",1],["NotoSansCJKkr-Regular.otf",0],["NanumGothic.ttf",0],["DroidSansFallbackFull.ttf",0]],arabic:[["NotoSansArabic-Regular.ttf",0],["NotoNaskhArabic-Regular.ttf",0],["DejaVuSans.ttf",0],["FreeSans.ttf",0]],hebrew:[["NotoSansHebrew-Regular.ttf",0],["DejaVuSans.ttf",0],["FreeSans.ttf",0]],thai:[["NotoSansThai-Regular.ttf",0],["Garuda.ttf",0],["Loma.ttf",0],["DejaVuSans.ttf",0]],other:[["DejaVuSans.ttf",0],["NotoSansSymbols-Regular.ttf",0],["NotoSansSymbols2-Regular.ttf",0],["FreeSans.ttf",0],["LiberationSans-Regular.ttf",0]]},sr={zh:"zh-cn","zh-TW":"zh-tw",ja:"ja",ko:"ko",arabic:"ar",hebrew:"he",thai:"th"};function ar(t){return t.script==="han"||t.script==="kana"||t.script==="hangul"?t.script==="kana"?"ja":t.script==="hangul"?"ko":t.lang??"zh":t.script==="arabic"||t.script==="hebrew"||t.script==="thai"?t.script:"other"}var qt=t=>t.platform==="win32"?Ke:Xt;function fr(t){let n=Ke.join,e=t.env.WINDIR??t.env.SystemRoot??"C:\\Windows";return[n(e,"Fonts"),...t.env.LOCALAPPDATA?[n(t.env.LOCALAPPDATA,"Microsoft","Windows","Fonts")]:[]]}function cr(t){let n=Xt.join;return["/System/Library/Fonts","/System/Library/Fonts/Supplemental","/Library/Fonts",n(t.home,"Library","Fonts")]}function lr(t){let n=Xt.join,e=t.env.XDG_DATA_HOME??n(t.home,".local","share");return["/usr/share/fonts","/usr/local/share/fonts","/usr/share/fonts/opentype/noto","/usr/share/fonts/truetype",n(e,"fonts"),n(t.home,".fonts")]}function Ve(t,n,e,i=3){let{join:r}=qt(e),o=e.list(t),s=n.toLowerCase(),f=o.find(c=>c.toLowerCase()===s);if(f)return r(t,f);if(i!==0)for(let c of o){if(c.includes("."))continue;let d=Ve(r(t,c),n,e,i-1);if(d)return d}}async function Ge(t,n){let e=await n.run("fc-match",["-s","-f",`%{file} %{index}
|
|
24
|
-
`,t]);return e===void 0?[]:e.split(`
|
|
25
|
-
`).map(i=>i.split(" ")).filter(([i])=>i!==void 0&&i!=="").slice(0,8).map(([i,r])=>({path:i,index:(Number(r)||0)&65535}))}async function Je(t,n=vt){let e=ar(t),{join:i}=qt(n),r=[],o=f=>{f&&!r.some(c=>c.path===f.path&&c.index===f.index)&&r.push(f)};if(n.platform==="win32"||n.platform==="darwin"){let f=n.platform==="win32"?ir:or,c=n.platform==="win32"?fr(n):cr(n);for(let[d,h]of f[e]??f.other??[])for(let p of c){let b=i(p,d);if(n.exists(b)){o({path:b,index:h});break}}return r}let s=sr[e];if(s)for(let f of await Ge(`:lang=${s}`,n))o(f);else if(t.codePoint!==void 0)for(let f of await Ge(`:charset=${t.codePoint.toString(16)}`,n))o(f);for(let[f,c]of ze[e]??ze.other??[])for(let d of lr(n)){let h=Ve(d,f,n);if(h){o({path:h,index:c});break}}return r}var We=new WeakMap;function Ye(t,n=vt){let e=We.get(n)??new Map;We.set(n,e);let i=`${t.path}#${t.index}`,r=qt(n).basename(t.path).replace(/\.[^.]+$/,""),o=e.get(i);if(o!==void 0)return o===null?void 0:{font:o,ref:t,name:r};try{let s=n.read(t.path);if(!s)throw new Error("unreadable");let f=Nt(s,Math.min(t.index,Math.max(0,Be(s)-1)));return e.set(i,f),{font:f,ref:t,name:r}}catch{e.set(i,null);return}}var Ze=595.28,Mt=841.89,rt=72,mt=Ze-2*rt,Zt=Mt-2*rt,Z={size:11,leading:16,after:8},mr={size:20,leading:26,before:0,after:6},br={size:15,leading:20,before:18,after:6},xr=4,yr=24,L={size:10,leading:14,padX:6,padY:3},wr=12,Ut=.114,Sr=.78,Ar=.95,Xe={regular:"NotoSans-Regular.ttf.gz",bold:"NotoSans-Bold.ttf.gz"};function kr(t){return[bt(t,"fonts"),bt(t,"..","fonts"),bt(t,"..","..","assets","fonts")]}var Lt;function Pr(){if(Lt)return Lt;let t=kr(gr(hr(import.meta.url))).find(e=>ur(bt(e,Xe.regular)));if(t===void 0)throw new Error("the PDF fonts are missing from this install");let n=e=>Nt(pr(dr(bt(t,Xe[e]))));return Lt={regular:n("regular"),bold:n("bold")},Lt}var it=class{constructor(n,e,i,r,o){this.font=n;this.resource=e;this.name=i;this.synthetic=r;this.isBold=o}font;resource;name;synthetic;isBold;used=new Map;widths=new Map;advance(n){let e=this.widths.get(n);return e===void 0&&(e=this.font.advance(n)/this.font.unitsPerEm,this.widths.set(n,e)),e}code(n,e){let i=this.font.codeOf(n);return this.used.has(i)||this.used.set(i,{gid:n,text:e}),i}},te=class{fonts=[];picks=new Map;count=0;missing=new Set;notdef;constructor(n){let e={regular:new it(n.regular,this.next(),"NotoSans-Regular",!1,!1),bold:new it(n.bold,this.next(),"NotoSans-Bold",!1,!0)};this.fonts.push(e),this.notdef=e}next(){return`F${++this.count}`}get primary(){return this.notdef.regular.font}all(){return this.fonts.flatMap(n=>[n.regular,n.bold])}add(n,e){this.fonts.push({regular:new it(e,this.next(),n,!1,!1),bold:new it(e,this.next(),n,!0,!0)}),this.picks.clear()}get fontCount(){return this.fonts.length}has(n){return this.fonts.some(e=>e.regular.font.glyphOf(n)!==void 0)}pick(n,e){let i=this.picks.get(n);if(i===void 0){i=null;for(let o=0;o<this.fonts.length;o++){let s=this.fonts[o]?.regular.font.glyphOf(n);if(s!==void 0){i=[o,s];break}}this.picks.set(n,i)}if(i===null)return this.missing.add(et(n)??"other"),{pf:e?this.notdef.bold:this.notdef.regular,gid:0};let r=this.fonts[i[0]];return{pf:(e?r?.bold:r?.regular)??this.notdef.regular,gid:i[1]}}width(n,e,i){let r=0;for(let o of n){let{pf:s,gid:f}=this.pick(o.codePointAt(0)??0,i);r+=s.advance(f)}return r*e}runs(n,e){let i=[];for(let r of n){let o=r.codePointAt(0)??0,{pf:s,gid:f}=this.pick(o,e),c=f===0?"\uFFFD":o>=64336&&o<=65279?Me(o):r,d=s.code(f,c).toString(16).padStart(4,"0"),h=i.at(-1);h&&h.pf===s?(h.hex+=d,h.width+=s.advance(f)):i.push({pf:s,hex:d,width:s.advance(f)})}return i}},Er=/[\u00AD\u200B\u200E\u200F\u2028\u2029\u202A-\u202E\u2060\u2066-\u2069\uFEFF]/g,Tr=/[\t\u00A0\u2000-\u200A\u202F\u205F\u3000]/g,Rr=/[^\P{Cc}\n]/gu;function Qe(t){return t.replace(Tr," ").replace(Er,"").replace(Rr,"").normalize("NFC")}function Fr(t,n){let e=Qe(t);Ue(e)&&(e=Le(e,n)),e=e.replace(/[\u200C\u200D]/g,"");let i=[];for(let r of e){let o=r.codePointAt(0)??0;if(r===`
|
|
26
|
-
`||n(o)){i.push(r);continue}let s=r.normalize("NFKD").replace(new RegExp("\\p{M}","gu"),"");i.push(s!==""&&[...s].every(f=>n(f.codePointAt(0)??0))?s:r)}return i.join("")}var Nr=new Set(["han","kana","hangul"]),vr=new Set([12289,12290,65292,65294,65306,65307,65281,65311,65289,65341,65373,12309,12297,12299,12301,12303,12305,12313,12311,12319,8217,8221,8252,12540,12293,12539,8230,8229,37,12445,12446,12541,12542].map(t=>String.fromCodePoint(t))),Ur=new Set([65288,65339,65371,12308,12296,12298,12300,12302,12304,12312,12310,12317,8216,8220].map(t=>String.fromCodePoint(t)));function Qt(t,n,e,i,r){let o=[],s=f=>n.width(f,i,e);for(let f of t.split(`
|
|
27
|
-
`)){let c="",d=0,h=s(" ");for(let p of f.split(" ").filter(Boolean)){let b=s(p),a=[...p].some(u=>Nr.has(et(u.codePointAt(0)??0)));if(b>r||a&&c!==""&&d+h+b>r){c!==""&&(d+h+s([...p][0]??"")<=r?(c+=" ",d+=h):(o.push(c),c="",d=0));for(let u of p){let l=s(u),g=[...c].at(-1),m=vr.has(u)&&d+l<=r*1.15;d+l>r&&c!==""&&!m&&(g!==void 0&&Ur.has(g)?(o.push([...c].slice(0,-1).join("")),c=g,d=s(g)):(o.push(c),c="",d=0)),c+=u,d+=l}}else c===""?(c=p,d=b):d+h+b<=r?(c+=` ${p}`,d+=h+b):(o.push(c),c=p,d=b)}o.push(c)}return o}var _=t=>(Math.round(t*100)/100).toString(),ee=class{constructor(n){this.chain=n}chain;pages=[];ops=[];y=0;owed=0;get remaining(){return Zt-this.y}get atTop(){return this.y===0}newPage(){this.ops=[`${_(Ut)} g ${_(Ut)} G`],this.pages.push(this.ops),this.y=0,this.owed=0}gap(n){this.y>0&&(this.y+=Math.max(this.owed,n)),this.owed=0}bottom(n){this.owed=n}advance(n){this.y+=n}text(n,e,i,r,o,s,f){if(s==="")return;let{primary:c}=this.chain,d=(c.ascent-c.descent)*e/c.unitsPerEm,h=o+(i-d)/2+c.ascent*e/c.unitsPerEm,p=this.chain.runs(be(s,f),n),b=p.reduce((l,g)=>l+g.width,0)*e,a=rt+(f?r.left+r.width-b:r.left),u=_(Mt-rt-h);for(let l of p){let g=l.pf.synthetic?`2 Tr ${_(e*.035)} w `:"",m=l.pf.synthetic?" 0 Tr":"";this.ops.push(`BT /${l.pf.resource} ${_(e)} Tf ${g}${_(a)} ${u} Td <${l.hex}> Tj${m} ET`),a+=l.width*e}}rect(n,e,i,r,o){let s=`${_(rt+n)} ${_(Mt-rt-e-r)} ${_(i)} ${_(r)} re`;o==="fill"?this.ops.push(`${_(Ar)} g ${s} f ${_(Ut)} g`):this.ops.push(`${_(Sr)} G 0.5 w ${s} S ${_(Ut)} G`)}lines(n,e,i,r,o,s){let f=pt(o),c=s?.indent??0,d={left:f?r.left:r.left+c,width:r.width-c};Qt(o,this.chain,n,e,d.width).forEach((h,p)=>{if(this.remaining<i&&this.newPage(),p===0&&s!==void 0){let b=this.chain.width(s.text,e,n),a=f?{left:r.left+r.width-b,width:b}:{left:d.left-b,width:b};this.text(n,e,i,a,this.y,s.text,!1)}this.text(n,e,i,d,this.y,h,f),this.advance(i)})}heading(n,e){let i=n===1?mr:br,r=Qt(e,this.chain,!0,i.size,mt);this.gap(i.before),this.remaining<r.length*i.leading+i.after+2*Z.leading&&this.newPage(),this.lines(!0,i.size,i.leading,{left:0,width:mt},e),this.bottom(i.after)}paragraph(n){this.gap(0),this.lines(!1,Z.size,Z.leading,{left:0,width:mt},n),this.bottom(Z.after)}list(n,e){this.gap(0),e.forEach((i,r)=>{r>0&&this.advance(xr);let o=n?`${r+1}. `:"\u2022 ";this.lines(!1,Z.size,Z.leading,{left:0,width:mt},i,{text:o,indent:yr})}),this.bottom(Z.after)}table(n){if(n.length===0)return;this.gap(0);let e=Math.max(...n.map(a=>a.length)),i=L.padX*2,r=Array(e).fill(0),o=Array(e).fill(0);for(let[a,u]of n.entries()){let l=a===0;for(let g=0;g<e;g++){let m=u[g]??"";r[g]=Math.max(r[g]??0,this.chain.width(m.replace(/\n/g," "),L.size,l)+i);let S=Math.max(0,...m.split(/\s+/).map(A=>Math.min(this.chain.width(A,L.size,l),L.size*3)));o[g]=Math.max(o[g]??0,S+i)}}let s=Lr(r,o,mt),f=s.map((a,u)=>s.slice(0,u).reduce((l,g)=>l+g,0)),c=a=>s.map((u,l)=>Qt(n[a]?.[l]??"",this.chain,a===0,L.size,u-i)),d=c(0),h=Math.max(...d.map(a=>a.length))*L.leading+2*L.padY,p=(a,u,l,g)=>{let m=g*L.leading+2*L.padY;for(let S=0;S<e;S++){let A=f[S]??0,w=s[S]??0;a===0&&this.rect(A,this.y,w,m,"fill"),this.rect(A,this.y,w,m,"stroke");let x=n[a]?.[S]??"",E=pt(x);(u[S]??[]).slice(l,l+g).forEach((T,R)=>{this.text(a===0,L.size,L.leading,{left:A+L.padX,width:w-i},this.y+L.padY+R*L.leading,T,E)})}this.advance(m)},b=a=>{this.newPage(),a>0&&h<Zt/2&&p(0,d,0,Math.max(...d.map(u=>u.length)))};for(let a=0;a<n.length;a++){let u=a===0?d:c(a),l=Math.max(...u.map(m=>m.length)),g=0;for(;g<l;){let m=Math.floor((this.remaining-2*L.padY)/L.leading),S=(l-g)*L.leading+2*L.padY;if(m<1||m<l-g&&!this.atTop&&S<=Zt-h){b(a);continue}let A=Math.min(l-g,m);p(a,u,g,A),g+=A,g<l&&b(a)}}this.bottom(wr)}};function Lr(t,n,e){let i=t.reduce((s,f)=>s+f,0);if(i<=e)return t.map(s=>s*e/i);let r=n.reduce((s,f)=>s+f,0);if(r>=e)return n.map(s=>s*e/r);let o=(e-r)/(i-r);return t.map((s,f)=>(n[f]??0)+(s-(n[f]??0))*o)}function Mr(t){return t.flatMap(n=>n.flatMap(e=>e.kind==="heading"||e.kind==="paragraph"?[e.text]:e.kind==="list"?e.items:e.rows.flat()))}var qe=8;async function Ir(t,n,e,i){let r=new Map;for(let f of new Set(n)){let c=f.codePointAt(0)??0;if(c<128||f===`
|
|
28
|
-
`||t.has(c)||c>=64336&&c<=65279)continue;let d=et(c)??"other";if(d!=="other"&&d!=="symbols"&&d!=="emoji"&&!Pe.has(d)){t.missing.add(d);continue}r.set(d,[...r.get(d)??[],c])}let o=Jt(n,e),s=0;for(let[f,c]of r){let d=c,h={script:f,lang:o,codePoint:c[0]??0},p=[],b=a=>{let u=d.filter(l=>a.font.glyphOf(l)!==void 0);u.length!==0&&(t.add(a.name,a.font),s++,d=d.filter(l=>!u.includes(l)))};for(let a of await Je(h,i)){if(d.length===0||s>=qe)break;let u=Ye(a,i);u&&(u.font.variable?p.push(u):b(u))}for(let a of p){if(d.length===0||s>=qe)break;b(a)}}}async function ne(t,n){let{PDFDocument:e,PDFName:i,PDFString:r}=await le(),o=new te(Pr()),s=Mr(t).map(Qe).join(`
|
|
29
|
-
`);await Ir(o,s,n.lang,n.fonts??vt);let f=new ee(o),c=l=>Fr(l,g=>o.has(g)),d=l=>{l.kind==="heading"?f.heading(l.level,c(l.text)):l.kind==="paragraph"?f.paragraph(c(l.text)):l.kind==="list"?f.list(l.ordered,l.items.map(c)):f.table(l.rows.map(g=>g.map(c)))};for(let l of t.filter(g=>g.length>0)){f.newPage();for(let g of l)d(g)}f.pages.length===0&&f.newPage();let h=await e.create({updateMetadata:!1});h.setTitle(n.title),h.setProducer("Forge"),h.setCreator("Forge");let{context:p}=h,b=new Map,a=new Map,u=0;for(let l of o.all()){if(l.used.size===0)continue;let g=p.nextRef();b.set(l,g);let{font:m}=l,S=[...l.used.keys()].sort((C,M)=>C-M),A=S.map(C=>l.used.get(C)?.gid??0),w=l.synthetic?a.get(m):void 0,x=1e3/m.unitsPerEm,E=`F${String.fromCharCode(65+(u>>8)%26,65+(u>>4)%26,65+(u>>2)%26,65+u%26,65+u*7%26)}`;u++;let T=`${E}+${l.name.replace(/[^A-Za-z0-9-]/g,"")}`,{data:R,cidToGid:I}=m.subset(A),D=m.outlines==="cff",K=p.register(D?p.flateStream(R,{Subtype:"CIDFontType0C"}):p.flateStream(R,{Length1:R.length})),Q=p.register(p.obj({Type:"FontDescriptor",FontName:T,Flags:4,FontBBox:m.bbox.map(C=>Math.round(C*x)),ItalicAngle:0,Ascent:Math.round(m.ascent*x),Descent:Math.round(m.descent*x),CapHeight:Math.round(m.capHeight*x),StemV:l.isBold?140:80,...D?{FontFile3:K}:{FontFile2:K}})),k=S.flatMap((C,M)=>[C,[Math.round(m.advance(A[M]??0)*x)]]),P=I?p.register(p.flateStream(new Uint8Array(new Uint16Array(Cr(I)).buffer))):void 0,z=p.register(p.obj({Type:"Font",Subtype:D?"CIDFontType0":"CIDFontType2",BaseFont:T,CIDSystemInfo:p.obj({Registry:r.of("Adobe"),Ordering:r.of("Identity"),Supplement:0}),FontDescriptor:Q,DW:0,W:k,...D?{}:{CIDToGIDMap:P??"Identity"}})),U=p.register(p.flateStream(Or(l.used)));p.assign(g,p.obj({Type:"Font",Subtype:"Type0",BaseFont:T,Encoding:"Identity-H",DescendantFonts:[z],ToUnicode:U})),l.synthetic||a.set(m,l)}for(let l of f.pages){let g=h.addPage([Ze,Mt]);for(let[m,S]of b)g.node.setFontDictionary(i.of(m.resource),S);g.node.set(i.of("Contents"),p.register(p.flateStream(l.join(`
|
|
30
|
-
`))))}return o.missing.size>0&&n.onMissing?.([...o.missing].map(Dr)),Buffer.from(await h.save())}var Dr=t=>t==="other"?"symbols":Ee(t);function Cr(t){let n=new Uint16Array(t.length);for(let e=0;e<t.length;e++)n[e]=((t[e]??0)&255)<<8|(t[e]??0)>>8;return n}function Or(t){let n=[...t].sort(([o],[s])=>o-s),e=o=>o.toString(16).padStart(4,"0"),i=o=>[...o].flatMap(s=>{let f=s.codePointAt(0)??65533;if(f<65536)return[e(f)];let c=f-65536;return[e(55296+(c>>10)),e(56320+(c&1023))]}).join(""),r=[];for(let o=0;o<n.length;o+=100){let s=n.slice(o,o+100);r.push(`${s.length} beginbfchar
|
|
31
|
-
${s.map(([f,c])=>`<${e(f)}> <${i(c.text)}>`).join(`
|
|
32
|
-
`)}
|
|
33
|
-
endbfchar`)}return["/CIDInit /ProcessSet findresource begin","12 dict begin","begincmap","/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def","/CMapName /Adobe-Identity-UCS def","/CMapType 2 def",`1 begincodespacerange
|
|
34
|
-
<0000> <FFFF>
|
|
35
|
-
endcodespacerange`,...r,"endcmap","CMapName currentdict /CMap defineresource pop","end","end"].join(`
|
|
36
|
-
`)}var Dt="forge-transcribe",re="forge-transcribe-whisper.mjs",Hr=["darwin","win32","linux"];function Br(t=process.platform,n=["whisper"]){let e=n.includes("whisper")||!n.includes("ffmpeg"),i=n.includes("ffmpeg"),r=[e&&"the whisper extension (forge extensions add whisper, or /extensions)",i&&(t==="darwin"?"ffmpeg (brew install ffmpeg)":t==="win32"?"ffmpeg (winget install ffmpeg)":"ffmpeg on your PATH")].filter(Boolean);return t==="darwin"?`Transcribe on this Mac needs ${r.join(" and ")}.`:t==="win32"?`Transcribe on Windows needs ${r.join(" and ")}.`:t==="linux"?`Transcribe on Linux needs ${r.join(" and ")}.`:"Transcribe needs macOS, Windows or Linux."}function qi(t=process.platform,n=t==="darwin"?"off":"unsupported"){return n==="off"?"Summary and notes need Apple Intelligence, and it is off.":`Summary and notes need Apple Intelligence, which this ${jt(t)} does not have.`}function zr(t){return{apple:[O(t,"helpers",Dt),O(t,"..","helpers",Dt),O(t,"..","..","dist","helpers",Dt)],whisper:[O(t,"helpers",re),O(t,"..","helpers",re),O(t,"..","..","helpers","transcribe",re)]}}function xt(t=process.platform,n=process.env){let e=n.FORGE_TRANSCRIBE_HELPER;if(e!==void 0)return It(e)?e.endsWith(".mjs")?{whisper:e}:{apple:e}:{};if(!Hr.includes(t))return{};let i=zr(rn(jr(import.meta.url))),r=t==="darwin"?i.apple.find(s=>It(s)):void 0,o=i.whisper.find(s=>It(s));return{...r?{apple:r}:{},...o?{whisper:o}:{}}}async function Gr(t){return t.apple!==void 0&&t.whisper===void 0?{path:t.apple,kind:"apple"}:t.apple!==void 0&&await t.appleHears(t.apple).catch(()=>!1)?{path:t.apple,kind:"apple"}:t.whisper===void 0?void 0:{path:t.whisper,kind:"whisper"}}async function yt(t){let{apple:n}=xt();if(n===void 0)return;let e=["status",...t?["--locale",t]:[]];return ot({path:n,kind:"apple"},e,"").catch(()=>{})}var ie;function Wr(){return process.env.FORGE_TRANSCRIBE_HELPER!==void 0&&(ie=void 0),ie??=Gr({...xt(),appleHears:async()=>(await yt())?.speech===!0}),ie}function Kr(t){let{apple:n}=xt();if(n===void 0)throw t();return{path:n,kind:"apple"}}async function Vr(){let t={...process.env,FORGE_HELPER_STOP_ON_EOF:"1"};if(!t.FORGE_FFMPEG){let n=await Ht().catch(()=>{});n&&(t.FORGE_FFMPEG=n.ffmpeg)}if(!t.FORGE_WHISPER_CLI){let n=await ht("whisper");n&&(t.FORGE_WHISPER_CLI=n.entry)}if(!t.FORGE_WHISPER_MODEL){let n=await ht("whisper"),e=n&&O(rn(n.entry),"model.bin");e&&It(e)&&(t.FORGE_WHISPER_MODEL=e)}return t}var Jr=5e3;async function ot(t,n,e,i={}){let{signal:r}=i;if(r?.aborted)throw r.reason??new Error("aborted");let o=t.kind==="whisper",s=o?await Vr():process.env;if(r?.aborted)throw r.reason??new Error("aborted");return new Promise((f,c)=>{let d=/\.[cm]?js$/.test(t.path),[h,p]=d?[process.execPath,[t.path,...n]]:[t.path,n],b=nn(h,p,{stdio:[o?"pipe":"ignore","pipe","ignore"],env:s,windowsHide:!0});b.stdin?.on("error",()=>{});let a,u=!1,l=m=>{u||(u=!0,r?.removeEventListener("abort",g),m())},g=()=>{o&&b.stdin?(b.stdin.end(),setTimeout(()=>b.kill("SIGKILL"),Jr).unref()):b.kill("SIGKILL"),l(()=>c(r?.reason??new Error("aborted")))};r?.addEventListener("abort",g,{once:!0}),_r({input:b.stdout}).on("line",m=>{let S;try{S=JSON.parse(m)}catch{return}"ok"in S?a=S:i.onLine?.(S)}),b.on("error",m=>l(()=>c(gt(e,m)))),b.on("close",()=>l(()=>{if(a===void 0)return c(gt(e,new Error(`${Dt} gave no result`)));if(a.ok===!0)return f(a);c(Yr(String(a.code??""),String(a.message??""),e,n,t.kind))}))})}function Yr(t,n,e,i,r){if(t==="no-sound")return $t(e);if(t==="unreadable")return Tt(e,process.platform,r);if(t==="locale"){let o=i.indexOf("--locale");return ce(o>=0?i[o+1]??"this language":`this ${jt()}'s language`,process.platform,r)}return t==="unsupported"||t==="runtime"?_t(n):gt(e,new Error(`${t}: ${n}`))}var Xr=["whisper","ffmpeg"];async function qr(t={}){let n=xt();if(n.apple===void 0&&n.whisper===void 0)return;let e=await yt(t.locale),r={read:e?.read===!0||await ht("read-text")!==void 0};if(e?.speech===!0)return{speech:!0,hears:"apple",locale:typeof e.locale=="string"?e.locale:null,notes:e.notes==="available"||e.notes==="off"?e.notes:"unsupported",...r};if(n.whisper===void 0)return e===void 0?void 0:{speech:!1,locale:null,notes:"unsupported",...r};let o=["status",...t.locale?["--locale",t.locale]:[]],s=await ot({path:n.whisper,kind:"whisper"},o,""),f=Array.isArray(s.missing)?Xr.filter(c=>s.missing.includes(c)):[];return{speech:s.speech===!0,...s.speech===!0?{hears:"whisper"}:{},locale:typeof s.locale=="string"?s.locale:null,notes:"unsupported",...r,...f.length>0?{missing:f}:{}}}async function Zi(t=process.platform){return t!=="darwin"?!0:(await qr().catch(()=>{}))?.hears!=="apple"}async function Qi(t=process.platform){if(t!=="darwin")return{hears:!1,reads:!1};let n=await yt().catch(()=>{});return{hears:n?.speech===!0,reads:n?.read===!0}}async function on(){let t=await Wr();if(t===void 0)throw _t(Br());return t}var Zr=new Set(["mp4","mov","m4a","mp3","wav","aiff"]);async function sn(t,n){if(t.kind!=="apple")return;let{probe:e}=await import("./registry-2YU7NW4P.js"),i=await e(n).catch(()=>{});if(i===void 0||i.kind!=="media"||Zr.has(i.format))return;let r=await Ht().catch(()=>{});return r?{tools:r}:void 0}async function Qr(t,n,e){let i=await se(O(fe(),"forge-sound-")),r=()=>ae(i,{recursive:!0,force:!0}),o=O(i,"sound.wav");try{return await new Promise((s,f)=>{let c=nn(n,["-nostdin","-v","error","-i",t,"-vn","-ac","1","-ar","16000","-c:a","pcm_s16le",o],{stdio:["ignore","ignore","pipe"],windowsHide:!0}),d="";c.stderr?.setEncoding("utf8").on("data",p=>{d+=p});let h=()=>c.kill("SIGKILL");e?.addEventListener("abort",h,{once:!0}),c.on("error",f),c.on("close",p=>{if(e?.removeEventListener("abort",h),e?.aborted)return f(e.reason??new Error("aborted"));p===0?s():f(gt(t,new Error(`ffmpeg: ${d.trim()}`)))})}),{path:o,cleanup:r}}catch(s){throw await r(),s}}async function to(t){let n=await on(),e=await sn(n,t);if(e){let{probeMedia:r}=await import("./ffmpeg-2UZXAB3C.js"),o=await r(t,e.tools).catch(()=>{});if(o===void 0)throw Tt(t);if(o.audio===void 0)throw $t(t);return{seconds:o.duration}}let i=await ot(n,["probe",t],t);return{seconds:Number(i.seconds)}}async function eo(t,n){let e=await on(),i=await sn(e,t),r=i?await Qr(t,i.tools.ffmpeg,n.signal):void 0;try{return await ti(e,r?.path??t,t,n)}finally{await r?.cleanup()}}async function ti(t,n,e,i){let r=["run",n,...i.locale?["--locale",i.locale]:[],...i.notes?["--notes"]:[],...i.notes&&i.detail&&i.detail!==me?["--detail",i.detail]:[]],o=await ot(t,r,e,{signal:i.signal,onLine:s=>{let f=ei(s);f&&i.onEvent?.(f)}});return{locale:String(o.locale),seconds:Number(o.seconds),segments:o.segments,...o.notes?{notes:o.notes}:{}}}function ei(t){if(t.event==="model")return{kind:"model",fraction:Number(t.fraction)};if(t.event==="heard")return{kind:"heard",seconds:Number(t.seconds),of:Number(t.of)};if(t.event==="notes")return{kind:"notes",part:Number(t.part),of:Number(t.of)}}async function no(t,n={}){if((await yt())?.read!==!0)return ri(t,n);let e=["read",t,...n.language?["--language",n.language]:[]];return(await ot(Kr(Rt),e,t,{signal:n.signal,onLine:r=>{r.event==="page"&&n.onEvent?.({kind:"page",page:Number(r.page),of:Number(r.of)})}})).pages??[]}var ni=200,tn=4e3;async function ro(){return Rt(await an())}async function an(){let{catalogEntry:t,assetFor:n}=await import("./catalog-FMHWWMUX.js"),e=t("read-text");return e!==void 0&&n(e)!==void 0}async function ri(t,n){let e=await ht("read-text");if(e===void 0)throw Rt(await an());let[{probe:i},{openable:r},{loadSharp:o},{runExtension:s}]=await Promise.all([import("./registry-2YU7NW4P.js"),import("./decoded-NBZ335RZ.js"),import("./libs-EK64ACG3.js"),import("./run-U2CU6VGE.js")]),f=await o(),c=await i(t),d=await se(O(fe(),"forge-read-")),h={width:tn,height:tn,fit:"inside",withoutEnlargement:!0};try{let p=[];if(c.kind==="document"&&c.format==="pdf"){let{openPdf:m}=await import("./pdfium-LYHOU6WV.js"),S=await m(await oe(t));try{for(let A=0;A<c.pages;A++){let w=await S.getPage(A).render({scale:ni/72,render:"bitmap"}),x=O(d,`page-${A+1}.png`);await f(Buffer.from(w.data),{raw:{width:w.width,height:w.height,channels:4}}).flatten({background:"#ffffff"}).resize(h).png().toFile(x),p.push(x)}}finally{S.destroy()}}else if(c.kind==="image"){let m=await r(t,c.format);try{let S=O(d,"page-1.png");await f(m.path).rotate().flatten({background:"#ffffff"}).resize(h).png().toFile(S),p.push(S)}finally{await m.cleanup()}}else throw Tt(t);let a=(await s({id:"read-text",entry:e.entry,kind:e.kind},p.flatMap(m=>["--in",m]),{subject:t,what:`Reading the text of ${t}`,...n.signal?{signal:n.signal}:{},onLine:m=>{m.event==="page"&&n.onEvent?.({kind:"page",page:Number(m.page),of:Number(m.of)})}})).pages??[];if(!(c.kind==="document"&&c.format==="pdf"))return a;let[{extractPdfText:u},{mendPage:l}]=await Promise.all([import("./pdfium-LYHOU6WV.js"),import("./text-layer-LHZNDMPZ.js")]),g=await u(await oe(t)).catch(()=>[]);return a.map((m,S)=>l(m,g[S]??""))}finally{await ae(d,{recursive:!0,force:!0})}}async function fn(){let{apple:t}=xt();if(!(t===void 0||await yt()===void 0))return{path:t,kind:"apple"}}async function cn(t,n,e,i){let r=await se(O(fe(),"forge-render-"));try{let o=O(r,"transcript.html"),s=O(r,`transcript.${e}`);return await $r(o,n,"utf8"),await ot(t,["render",o,s,"--as",e],s,{signal:i.signal}),await oe(s)}finally{await ae(r,{recursive:!0,force:!0})}}var en=9026;async function ln(t,n){let e=await ue(),{Document:i,Packer:r,Paragraph:o,TextRun:s,Table:f,TableRow:c,TableCell:d,HeadingLevel:h}=e,p="forge-numbers",b=0,a=(A,w=!1)=>Te(A,n).map(x=>new s({text:x.text,...w?{bold:!0}:{},...x.kind==="eastAsia"?{font:{hint:"eastAsia"},language:x.lang?{eastAsia:x.lang}:{}}:{},...x.kind==="complex"?{font:{hint:"cs"},...x.rtl?{rightToLeft:!0}:{},...w?{boldComplexScript:!0}:{},...x.lang?{language:{bidirectional:x.lang}}:{}}:{}})),u=A=>pt(A)?{bidirectional:!0}:{},l=A=>A.flatMap(w=>{if(w.kind==="heading")return[new o({children:a(w.text),heading:w.level===1?h.HEADING_1:h.HEADING_2,...u(w.text)})];if(w.kind==="paragraph")return[new o({children:a(w.text),spacing:{after:160},...u(w.text)})];if(w.kind==="list"){let E=++b;return w.items.map(T=>w.ordered?new o({children:a(T),numbering:{reference:p,level:0,instance:E},...u(T)}):new o({children:a(T),bullet:{level:0},...u(T)}))}let x=w.rows[0]?.length??1;return[new f({width:{size:100,type:e.WidthType.PERCENTAGE},columnWidths:Array(x).fill(Math.floor(en/x)),margins:{top:40,bottom:40,left:100,right:100},rows:w.rows.map((E,T)=>new c({tableHeader:T===0,children:E.map(R=>new d({width:{size:Math.floor(en/x),type:e.WidthType.DXA},children:[new o({children:a(R,T===0),...u(R)})]}))}))}),new o({text:""})]}),m=t.filter(A=>A.length>0).flatMap((A,w)=>[...w>0?[new o({children:[new e.PageBreak]})]:[],...l(A)]),S=new i({numbering:{config:[{reference:p,levels:[{level:0,format:e.LevelFormat.DECIMAL,text:"%1.",alignment:e.AlignmentType.START}]}]},sections:[{children:m}]});return r.toBuffer(S)}var un=t=>({...t.lang!==void 0?{lang:t.lang}:{},...t.onMissing!==void 0?{onMissing:t.onMissing}:{}});async function io(t,n,e,i={}){if(n==="md")return Buffer.from(Se(t),"utf8");if(n==="txt")return Buffer.from(Ae(t),"utf8");if(n==="docx")return ln(t,i.lang);let r=await fn();return r?cn(r,ke(t,e),"pdf",i):ne(t,{title:e,...un(i)})}function ii(t){for(let n of t.flat())if(n.kind==="heading"&&n.level===1)return n.text;return"Transcript"}async function oo(t,n,e={}){if(n==="md")return Buffer.from(t,"utf8");if(n==="txt")return Buffer.from(de(t),"utf8");let i=await fn();if(i)return cn(i,pe(t),n,e);let r=he(t);return n==="docx"?ln(r,e.lang):ne(r,{title:ii(r),...un(e)})}export{fi as a,ci as b,Ae as c,ke as d,Br as e,qi as f,zr as g,xt as h,Gr as i,qr as j,Zi as k,Qi as l,to as m,eo as n,no as o,ro as p,io as q,oo as r};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as L,b as O,f as T}from"./chunk-2MLASXG5.js";import{b as K,c as P,m as j,n as z,p as J,q as W,s as $}from"./chunk-655UG277.js";import{a as q,c as w}from"./chunk-C32KGH4S.js";import{d as R}from"./chunk-HCLEHCAR.js";import{a as M}from"./chunk-BD3OLIVT.js";import{e as B}from"./chunk-2J2PTA5O.js";import{b as I}from"./chunk-DZOBIUV6.js";import{a as k}from"./chunk-J7FLFHQJ.js";import{a as v}from"./chunk-H3DIRJFE.js";import{existsSync as E}from"node:fs";import{basename as G,dirname as H,extname as Q,join as U}from"node:path";var V={images:"an image",pdfs:"a PDF",documents:"a document",videos:"a video",audio:"audio",other:"a file Forge reads"};function X(e){let t=Object.keys(e).filter(s=>e[s]);if(t.length===0)return"not supported";let n=t.map(s=>V[s]);return`not ${n.length===1?n[0]:`${n.slice(0,-1).join(", ")} or ${n.at(-1)}`}`}function Y(e){return e.kind==="document"?e.format==="pdf"?"no images to shrink":"nothing to compress":`${v[e.format].label} is lossless`}function Z(e,t,n){if(e.kind!=="image")return{left:"images only"};let s=e,r=n===void 0?{}:{output:n};if(t.tool==="sharpen"||t.tool==="boost"){let c=t.tool==="sharpen"?1:t.scale??2;if(B(s.width,s.height,c))return{left:c===1?"too large":`too large for ${c}\xD7`};let[f]=K.plan([s],{scale:String(c),target:R(s),...r});return f?{job:f}:{left:"not supported"}}if(t.tool==="cutout"){let[c]=P.plan([s],{target:"png",...r});return c?{job:c}:{left:"not supported"}}if(t.tool==="rotate"){if(s.frames>1)return{left:"animated"};let[c]=$.plan([s],{turn:t.turn??90,...r});return c?{job:c}:{left:"not supported"}}if(t.tool==="trim"&&s.frames>1)return{left:"animated"};let o=t.tool==="trim"?J:W,[i]=o.plan([s],{target:R(s),...t.resize?{resize:t.resize}:{},...r});return i?{job:i}:{left:"not supported"}}function ee(e,t,n){if(t.op==="edit")return Z(e,t,n);if(e.kind==="media")return{left:"one at a time"};let s=n===void 0?{}:{destination:n};if(t.op==="compress"){if(!j.appliesTo([e]))return{left:Y(e)};if(t.targetBytes!==void 0&&e.bytes<=t.targetBytes)return{left:"already under that size"};let[i]=j.plan([e],{mode:t.targetBytes===void 0?"quality":"size",...t.quality===void 0?{}:{quality:t.quality},...s});return i?{job:i}:{left:"not supported"}}let r=t.answers[O(e)];if(!r)return{left:X(t.answers)};if(e.format===r.target)return{left:`already ${v[r.target].label}`};if(!M(e).includes(r.target))return{left:`can\u2019t become ${v[r.target].label}`};let[o]=z.plan([e],{target:r.target,...r.quality===void 0?{}:{quality:r.quality},...r.dpi===void 0?{}:{dpi:String(r.dpi)},pages:"all",...s});return o?.op==="convert"?{job:o}:{left:"not supported"}}function te(e,t){if(!t(e))return e;let n=Q(e),s=G(e,n);for(let r=1;;r++){let o=U(H(e),I(s,` (${r})${n}`));if(!t(o)&&!E(o))return o}}function ne(e,t,n,s={}){let r=s.existing??"leave",o=ee(e,t,s.destination);if(!("job"in o))return o;let{job:i}=o,c=i.outputs.some(a=>E(a)&&!n.has(a));if(c&&r==="leave")return{left:t.op==="compress"?"already compressed":t.op==="edit"?"already edited":"already converted"};let f=r==="number"?a=>n.has(a)||E(a):a=>n.has(a);i.outputs=i.outputs.map(a=>te(a,f));for(let a of i.outputs)n.add(a);return c&&r==="ask"?{job:i,taken:!0}:{job:i}}function S(e,t,n,s={}){let r=[],o=[],i=[];for(let c of e){let f=ne(c,t,n,s);"job"in f?(r.push(f.job),f.taken&&i.push(f.job)):o.push({path:c.path,reason:f.left})}return{jobs:r,left:o,taken:i}}async function D(e,t,n={}){let s=new Set,r=n.existing??"leave",{jobs:o,left:i}=S(e,t,s,{destination:n.destination,existing:r});return{outcome:await w(o,{force:r==="replace",...t.op==="compress"&&t.targetBytes!==void 0?{targetBytes:t.targetBytes}:{},...n.concurrency===void 0?{}:{concurrency:n.concurrency},...n.onEvent?{onEvent:n.onEvent}:{},...n.signal?{signal:n.signal}:{}}),left:i,claimed:s,jobs:o}}function C(e,t){let{outcome:n,left:s}=t,r=new Map;for(let o of n.results){let i=o.job.sources[0].path;r.set(i,{path:i,state:"done",result:o})}for(let o of[...n.refusals,...n.failures])if(o.error.code==="cannot-compress-more"){let i=o.error.short==="nothing written"?"can\u2019t get smaller":"already under that size";r.set(o.path,{path:o.path,state:"left",reason:i})}else o.error.code==="nothing-to-trim"?r.set(o.path,{path:o.path,state:"left",reason:"no empty edges"}):r.set(o.path,{path:o.path,state:"failed",reason:o.error.title.toLowerCase()});for(let o of n.unreachable){let i=o.job.sources[0].path;r.set(i,{path:i,state:"left",reason:`can\u2019t get below ${k(o.smallest)}`})}for(let o of s)r.set(o.path,{path:o.path,state:"left",reason:o.reason});return e.map(o=>r.get(o.path)??{path:o.path,state:"left",reason:n.cancelled?"stopped":"not run"})}import{watch as oe}from"node:fs";import{readdir as re,stat as se}from"node:fs/promises";import{join as ie,resolve as N}from"node:path";function _(e,t,n){let s=N(e),r=n.settleMs??1e3,o=n.pollMs??500,i=new Set([...t].map(m=>N(m))),c=new Map,f=!1,a=!1,d=!1,p=async()=>{if(!f){if(a){d=!0;return}a=!0;try{let m=await re(s,{withFileTypes:!0}).catch(()=>[]),g=new Set;for(let l of m){if(!l.isFile()||L(l.name))continue;let u=ie(s,l.name);if(g.add(u),i.has(u)||n.ignore?.(u))continue;let y=await se(u).catch(()=>{});if(!y||f)continue;let F=Date.now(),b=c.get(u);if(!b||b.size!==y.size||b.mtimeMs!==y.mtimeMs){c.set(u,{size:y.size,mtimeMs:y.mtimeMs,since:F});continue}F-b.since<r||(c.delete(u),i.add(u),n.onFile(u))}for(let l of[...i,...c.keys()])g.has(l)||(i.delete(l),c.delete(l))}finally{a=!1,d&&!f&&(d=!1,p())}}},x=setInterval(()=>{p()},o),h;try{h=oe(s,{persistent:!1},()=>{p()}),h.on("error",()=>{})}catch{}return p(),{close(){f=!0,clearInterval(x),h?.close()}}}var A=e=>"op"in e&&(e.op==="convert"||e.op==="compress"||e.op==="edit")?e:{op:"convert",answers:e};function ae(e,t,n,s){let{jobs:r,left:o}=S(e,A(t),n,{destination:s});return{jobs:r,left:o}}async function ze(e,t,n={}){return D(e.sources,A(t),n)}var ce=(e,t)=>e==="other"?t==="text"?"a text file":"not supported":"not yet supported";function Je(e){let t=q(e.concurrency),n=A(e.answers),s=[],r=new Set,o=!1,i=async a=>{e.onEvent({type:"arrived",path:a}),e.onEvent({type:"phase",path:a,phase:"reading"});let d=await T(a);if(d.kind==="failed"){e.onEvent({type:"failed",path:a,error:d.failure.error});return}if(d.kind!=="source"){e.onEvent({type:"left",path:a,reason:ce(d.kind,d.sniffed)});return}let{jobs:p,left:x}=ae([d.source],n,e.claimed,e.destination),[h]=x;if(h){e.onEvent({type:"left",path:a,reason:h.reason});return}let m=await w(p,{force:!1,concurrency:1,...n.op==="compress"&&n.targetBytes!==void 0?{targetBytes:n.targetBytes}:{},onEvent:l=>{l.type==="job:phase"&&"phase"in l.progress&&l.progress.phase!=="page"&&l.progress.phase!=="time"&&l.progress.phase!=="tiles"&&e.onEvent({type:"phase",path:a,phase:l.progress.phase,job:l.job})}}),[g]=C([d.source],{outcome:m,left:[],claimed:e.claimed,jobs:p});if(g?.result)e.onEvent({type:"converted",path:a,result:g.result});else if(g?.state==="left")e.onEvent({type:"left",path:a,reason:g.reason??""});else{let l=[...m.refusals,...m.failures][0];l&&e.onEvent({type:"failed",path:a,error:l.error})}},c=()=>{for(;!o&&r.size<t&&s.length>0;){let a=s.shift(),d=i(a).catch(()=>{}).finally(()=>{r.delete(d),c()});r.add(d)}},f=_(e.dir,e.known,{...e.settleMs===void 0?{}:{settleMs:e.settleMs},...e.pollMs===void 0?{}:{pollMs:e.pollMs},ignore:a=>e.claimed.has(a),onFile:a=>{s.push(a),c()}});return{async stop(){o=!0,f.close(),s.length=0,await Promise.all([...r])}}}export{S as a,C as b,ze as c,Je as d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{i as x}from"./chunk-WZWK3PEZ.js";import{c as U}from"./chunk-DZOBIUV6.js";import{A,B as T,C as B,d as k,da as S,ea as C,na as E,r as w,u as I,z as M}from"./chunk-WIPP5TWQ.js";function _(e=1,t=100){let o=Math.max(1,t-e+1);return 1+Math.max(0,Math.ceil(Math.log2(o)))}async function q(e){let t=e.min??1,o=e.max??100,l=_(t,o),a=0,s=async n=>(a+=1,e.onAttempt?.(a,l),e.encode(n)),u=()=>e.signal?.aborted===!0,i=await s(o);if(u())return{quality:o,bytes:i,missed:!1,cancelled:!0};if(i<=e.targetBytes)return{quality:o,bytes:i,missed:!1};let c=t,m=o,b;for(;c<=m;){let n=Math.floor((c+m)/2),p=await s(n);if(u())return{quality:n,bytes:p,missed:!1,cancelled:!0};p<=e.targetBytes?(b={quality:n,bytes:p,missed:!1},c=n+1):m=n-1}if(b)return b;let h=await e.encode(t);return{quality:t,bytes:h,missed:!0}}import{cpus as D}from"node:os";function L(){return Math.max(1,Math.min(D().length,4))}function J(e){let t=e!==void 0&&Number.isFinite(e)?e:void 0;return Math.max(1,t??L())}async function R(e,t,o){let l=0,a=async()=>{for(;l<e.length;){let u=l++;await o(e[u],u)}},s=Math.min(J(t),e.length);await Promise.all(Array.from({length:s},a))}async function O(e,t){let o=t.onEvent??(()=>{}),l=t.engineFor??x,a=J(t.concurrency),s=e.length,u=[],i=[],c=0;await R(e,a,async(n,p)=>{if(t.signal?.aborted)return;o({type:"job:start",job:n,index:p,total:s});let g=l(n);if(!g){c++;let f=n.sources[0].path,F={path:f,error:E(f,new Error(`no engine runs ${n.op}`))};i[p]=F,o({type:"job:error",job:n,failure:F,completed:c,total:s});return}try{let f=await g.run(n,F=>o({type:"job:phase",job:n,progress:F}),t.signal);u[p]=f,c++,o({type:"job:done",job:n,result:f,completed:c,total:s})}catch(f){c++;let F=n.sources[0].path,r=k(f)?f:E(F,f),d={path:F,error:r};i[p]=d,o({type:"job:error",job:n,failure:d,completed:c,total:s})}});let m=u.filter(n=>n!==void 0),b=i.filter(n=>n!==void 0),h={results:m,failures:b,inputBytes:m.reduce((n,p)=>n+p.job.sources[0].bytes,0),outputBytes:m.reduce((n,p)=>n+p.outputBytes,0)};return o({type:"batch:done",summary:h}),h}import{existsSync as W}from"node:fs";import{resolve as P}from"node:path";function z(e){let t=e.sources[0]?.path??e.outputs[0]??"",o=new Set;for(let l of e.outputs){let a=P(l);if(o.has(a))return{output:l,error:T(t,l)};o.add(a)}}function Q(e,t,o){let l=z(e);if(l)return l;let a=e.sources[0]?.path??e.outputs[0]??"";for(let s of e.outputs){let u=P(s);if(e.sources.some(c=>U(c.path,u))&&!o)return{output:s,error:B(s,e.op)};let i=t.get(u);if(i){let c=i.sources[0]?.path??i.outputs[0]??"";return{output:s,error:A([c,a],s)}}if(W(u)&&!o)return{output:s,error:M(s,e.op)}}}function N(e,t){let o=[],l=[],a=new Map;for(let s of e){let u=Q(s,a,t.force);if(u){let i=s.sources[0]?.path??u.output;l.push({path:i,error:u.error});continue}for(let i of s.outputs)a.set(P(i),s);o.push(s)}return{jobs:o,failures:l}}async function X(e,t,o,l,a,s){let u=e.sources[0].path,i=r=>({kind:"failed",failure:{path:u,error:k(r)?r:E(u,r)}}),c=o(e);if(c?.sizeTo){let r=e.sources[0],d=e.options.compress!==void 0;if(d&&r.bytes<=t)return{kind:"failed",failure:{path:u,error:C(u,r.bytes,t)}};let y=t,v=c.sizeTo(e,y);return v&&d&&v.floor>=r.bytes?{kind:"failed",failure:{path:u,error:S(u,r.bytes,v.floor,!0)}}:v?{kind:"unreachable",entry:{job:e,smallest:v.floor,settings:{quality:1,media:{...e.options.media,targetBytes:v.floor}},error:I(r,t,v.floor)}}:(e.options={...e.options,media:{...e.options.media,targetBytes:y}},{kind:"ready"})}let m;try{m=await o(e)?.measurer?.(e)}catch(r){return i(r)}if(!m||m.ladder.length===0)return{kind:"refused",failure:{path:u,error:w(e.sources[0],e.target)}};let b=m,h=e.sources[0],n=e.options.compress!==void 0&&h.bytes<=t,p=n?h.bytes-1:t;if(a?.aborted)return{kind:"cancelled"};let g=Number.POSITIVE_INFINITY,f;try{for(let r of b.ladder){let d=await q({encode:y=>b.measure({...e.options,...r,quality:y}),targetBytes:p,...s===void 0?{}:{max:s},onAttempt:(y,v)=>l({type:"search:attempt",job:e,attempt:y,of:v,rung:r}),...a===void 0?{}:{signal:a}});if(d.cancelled)return{kind:"cancelled"};if(d.bytes<g&&(g=d.bytes,f={...r,quality:d.quality}),!d.missed)return e.options={...e.options,...r,quality:d.quality},{kind:"ready"}}}catch(r){return i(r)}return n?{kind:"failed",failure:{path:u,error:S(u,h.bytes,g,!0)}}:{kind:"unreachable",entry:{job:e,smallest:g,settings:f??{quality:1},error:I(e.sources[0],t,g)}}}async function ie(e,t){let o=t.onEvent??(()=>{}),l=t.engineFor??x,a=t.targetBytes,s=N(e,{force:t.force}),u=a===void 0?0:s.jobs.filter(r=>r.op==="convert").length,i=[],c=0;await R(s.jobs,J(t.concurrency),async(r,d)=>{if(a===void 0||r.op!=="convert"){i[d]={kind:"ready"};return}if(t.signal?.aborted){i[d]={kind:"cancelled"};return}let y=await X(r,a,l,o,t.signal,t.maxQuality);i[d]=y,y.kind!=="cancelled"&&(c+=1,o({type:"search:settled",job:r,completed:c,total:u}))});let m=[...s.failures],b=[],h=[],n=[],p=!1;for(let[r,d]of s.jobs.entries()){let y=i[r]??{kind:"ready"};y.kind==="ready"?n.push(d):y.kind==="refused"?m.push(y.failure):y.kind==="failed"?h.push(y.failure):y.kind==="unreachable"?b.push(y.entry):p=!0}if(p)return{results:[],refusals:m,unreachable:[],failures:[],inputBytes:0,outputBytes:0,cancelled:!0};let g=new Set,f=await O(n,{...t.concurrency===void 0?{}:{concurrency:t.concurrency},...t.engineFor===void 0?{}:{engineFor:t.engineFor},...t.signal===void 0?{}:{signal:t.signal},onEvent:r=>{r.type==="job:error"&&!t.signal?.aborted&&g.add(r.failure),o(r)}}),F=n.length-f.results.length;if(t.signal?.aborted&&F>0){let r=f.failures.filter(d=>g.has(d));return{...f,refusals:m,unreachable:b,failures:[...h,...r],cancelled:!0}}return{results:f.results,refusals:m,unreachable:b,failures:[...h,...f.failures],inputBytes:f.inputBytes,outputBytes:f.outputBytes}}export{J as a,N as b,ie as c};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as w,b as I,d as k,e as m}from"./chunk-C4UCCBCX.js";import{a as $,c as O}from"./chunk-EKTUUKDP.js";import{b as h,d as P,e as R}from"./chunk-63BBFKT2.js";import{e as x}from"./chunk-57M4J2BR.js";import{a as l}from"./chunk-3KWAO2N2.js";import{j as B}from"./chunk-WZWK3PEZ.js";import{$ as g,aa as C,b as p,ca as v}from"./chunk-WIPP5TWQ.js";import{a as f}from"./chunk-J7FLFHQJ.js";import{a as c}from"./chunk-H3DIRJFE.js";import{dirname as S,join as q}from"node:path";async function T(t){if(t.fallback!==void 0)return t.fallback;let{loadPreferences:r,expandTilde:e}=await import("./preferences-3P4V2EDX.js");return e((await r()).prefs.defaultOutput)}function F(t){if(t.pasteboard)return t.pasteboard;if(!$())throw C();return O()}function E(t,r,e,o){let a=q(r.outDir,`Copied image${c[o].extensions[0]}`),s={inputs:[r.source],output:a,force:!1,recursive:!1,debug:t.debug},n={background:"#ffffff",keepMetadata:!1,...t.quality===void 0?{}:{quality:t.quality}};return o===e?{kind:"compress",...s,options:n,...t.quality===void 0?{}:{quality:t.quality},...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}:{kind:"convert",...s,target:o,options:n,...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}}async function J(t,r={}){let e=r.clip??{},o=F(e),a=await w(o,e.root);if(!a)throw g((await o.peek()).text?"text":"nothing");let s=await B(a.source),n=t.target??s.format,b=E(t,a,s.format,n),i=await P(b,r),y=i.results[0];if(!y||i.failures.length>0)return{report:i,status:"failed"};let u=y.job.outputs[0],d={report:i,output:u,source:{format:s.format,bytes:s.bytes},target:n};if(await I(o,a,u,n)==="changed")return{...d,status:"changed",saved:await m(u,await T(e))};if(t.save===void 0)return{...d,status:"placed"};let j=t.save===!0?await T(e):t.save,{expandTilde:D}=await import("./preferences-3P4V2EDX.js");return{...d,status:"placed",saved:await m(u,D(j))}}function N(t){let r=t.target===t.source.format?"":` as ${c[t.target].label}`,e=` ${f(t.source.bytes)} \u2192 ${f(t.report.outputBytes)} \xB7 ${h(t.source.bytes,t.report.outputBytes)}`;if(t.status==="changed"){let a=t.target===t.source.format?"compressed":"converted";return[`\u2713 Copied image \u2192 ${p(t.saved)}${r}`,e,"","\u26A0 Clipboard changed"," The file you uploaded is no longer in the clipboard.",` The ${a} image is saved to ${p(S(t.saved))}.`]}let o=t.saved===void 0?"":` + ${p(t.saved)}`;return[`\u2713 Copied image \u2192 clipboard${r}${o}`,e]}async function U(t){if(!await k(F(t),t.root))throw v()}async function Z(t,r){if(t.undo)return await U(r.clip??{}),{exitCode:0,stdout:r.json?[JSON.stringify({forge:l,ok:!0,clipboard:"restored"})]:["\u2713 The original is back on the clipboard"],stderr:[]};let e=await J(t,r);if(e.status==="failed")return R(e.report,r);if(r.json){let o={...x(l,e.report),clipboard:e.status,...e.saved===void 0?{}:{saved:e.saved}};return{exitCode:0,stdout:[JSON.stringify(o)],stderr:[]}}return{exitCode:0,stdout:N(e),stderr:[]}}export{J as a,N as b,U as c,Z as d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{j as Ht}from"./chunk-WZWK3PEZ.js";import{G as Ot,d as Tt,e as gt}from"./chunk-WIPP5TWQ.js";import{a as wt}from"./chunk-H3DIRJFE.js";import{c as et,e as xe}from"./chunk-TMUK2DD3.js";var it=et((zs,Qt)=>{"use strict";var Ut="[^\\\\/]",xr="(?=.)",Kt="[^/]",yt="(?:\\/|$)",Xt="(?:^|\\/)",Rt=`\\.{1,2}${yt}`,Cr="(?!\\.)",$r=`(?!${Xt}${Rt})`,Lr=`(?!\\.{0,1}${yt})`,vr=`(?!${Rt})`,wr="[^.\\/]",Tr=`${Kt}*?`,Or="/",jt={DOT_LITERAL:"\\.",PLUS_LITERAL:"\\+",QMARK_LITERAL:"\\?",SLASH_LITERAL:"\\/",ONE_CHAR:xr,QMARK:Kt,END_ANCHOR:yt,DOTS_SLASH:Rt,NO_DOT:Cr,NO_DOTS:$r,NO_DOT_SLASH:Lr,NO_DOTS_SLASH:vr,QMARK_NO_DOT:wr,STAR:Tr,START_ANCHOR:Xt,SEP:Or},Hr={...jt,SLASH_LITERAL:"[\\\\/]",QMARK:Ut,STAR:`${Ut}*?`,DOTS_SLASH:"\\.{1,2}(?:[\\\\/]|$)",NO_DOT:"(?!\\.)",NO_DOTS:"(?!(?:^|[\\\\/])\\.{1,2}(?:[\\\\/]|$))",NO_DOT_SLASH:"(?!\\.{0,1}(?:[\\\\/]|$))",NO_DOTS_SLASH:"(?!\\.{1,2}(?:[\\\\/]|$))",QMARK_NO_DOT:"[^.\\\\/]",START_ANCHOR:"(?:^|[\\\\/])",END_ANCHOR:"(?:[\\\\/]|$)",SEP:"\\"},Ir={__proto__:null,alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};Qt.exports={DEFAULT_MAX_EXTGLOB_RECURSION:0,MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:Ir,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{__proto__:null,"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,extglobChars(t){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===!0?Hr:jt}}});var ut=et(q=>{"use strict";var{REGEX_BACKSLASH:Pr,REGEX_REMOVE_BACKSLASH:kr,REGEX_SPECIAL_CHARS:Dr,REGEX_SPECIAL_CHARS_GLOBAL:Nr}=it();q.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);q.hasRegexChars=t=>Dr.test(t);q.isRegexChar=t=>t.length===1&&q.hasRegexChars(t);q.escapeRegex=t=>t.replace(Nr,"\\$1");q.toPosixSlashes=t=>t.replace(Pr,"/");q.isWindows=()=>{if(typeof navigator<"u"&&navigator.platform){let t=navigator.platform.toLowerCase();return t==="win32"||t==="windows"}return typeof process<"u"&&process.platform?process.platform==="win32":!1};q.removeBackslashes=t=>t.replace(kr,r=>r==="\\"?"":r);q.escapeLast=(t,r,e)=>{let s=t.lastIndexOf(r,e);return s===-1?t:t[s-1]==="\\"?q.escapeLast(t,r,s-1):`${t.slice(0,s)}\\${t.slice(s)}`};q.removePrefix=(t,r={})=>{let e=t;return e.startsWith("./")&&(e=e.slice(2),r.prefix="./"),e};q.wrapOutput=(t,r={},e={})=>{let s=e.contains?"":"^",n=e.contains?"":"$",o=`${s}(?:${t})${n}`;return r.negated===!0&&(o=`(?:^(?!${o}).*$)`),o};q.basename=(t,{windows:r}={})=>{let e=t.split(r?/[\\/]/:"/"),s=e[e.length-1];return s===""?e[e.length-2]:s}});var re=et((Zs,ee)=>{"use strict";var zt=ut(),{CHAR_ASTERISK:St,CHAR_AT:Fr,CHAR_BACKWARD_SLASH:rt,CHAR_COMMA:Br,CHAR_DOT:_t,CHAR_EXCLAMATION_MARK:Et,CHAR_FORWARD_SLASH:te,CHAR_LEFT_CURLY_BRACE:bt,CHAR_LEFT_PARENTHESES:ft,CHAR_LEFT_SQUARE_BRACKET:Mr,CHAR_PLUS:Gr,CHAR_QUESTION_MARK:Yt,CHAR_RIGHT_CURLY_BRACE:Wr,CHAR_RIGHT_PARENTHESES:Zt,CHAR_RIGHT_SQUARE_BRACKET:qr}=it(),Vt=t=>t===te||t===rt,Jt=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},Ur=(t,r)=>{let e=r||{},s=t.length-1,n=e.parts===!0||e.tokens===!0||e.scanToEnd===!0,o=[],i=[],l=[],h=t,d=-1,g=0,A=0,S=!1,x=!1,y=!1,C=!1,H=!1,G=!1,_=!1,B=!1,j=!1,I=!1,w=0,L,R,m={value:"",depth:0,isGlob:!1},u=()=>d>=s,M=()=>h.charCodeAt(d+1),D=()=>(L=R,h.charCodeAt(++d));for(;d<s;){R=D();let $;if(R===rt){_=m.backslashes=!0,R=D(),R===bt&&(G=!0);continue}if(G===!0||R===bt){for(w++;u()!==!0&&(R=D());){if(R===rt){_=m.backslashes=!0,D();continue}if(R===bt){w++;continue}if(G!==!0&&R===_t&&(R=D())===_t){if(S=m.isBrace=!0,y=m.isGlob=!0,I=!0,n===!0)continue;break}if(G!==!0&&R===Br){if(S=m.isBrace=!0,y=m.isGlob=!0,I=!0,n===!0)continue;break}if(R===Wr&&(w--,w===0)){G=!1,S=m.isBrace=!0,I=!0;break}}if(n===!0)continue;break}if(R===te){if(o.push(d),i.push(m),m={value:"",depth:0,isGlob:!1},I===!0)continue;if(L===_t&&d===g+1){g+=2;continue}A=d+1;continue}if(e.noext!==!0&&(R===Gr||R===Fr||R===St||R===Yt||R===Et)===!0&&M()===ft){if(y=m.isGlob=!0,C=m.isExtglob=!0,I=!0,R===Et&&d===g&&(j=!0),n===!0){let U=0;for(;u()!==!0&&(R=D());){if(R===rt){_=m.backslashes=!0,D();continue}if(R===ft){U++;continue}if(R===Zt&&--U===0){I=!0;break}}continue}break}if(R===St){if(L===St&&(H=m.isGlobstar=!0),y=m.isGlob=!0,I=!0,n===!0)continue;break}if(R===Yt){if(y=m.isGlob=!0,I=!0,n===!0)continue;break}if(R===Mr){for(;u()!==!0&&($=D());){if($===rt){_=m.backslashes=!0,D();continue}if($===qr){x=m.isBracket=!0,y=m.isGlob=!0,I=!0;break}}if(n===!0)continue;break}if(e.nonegate!==!0&&R===Et&&d===g){B=m.negated=!0,g++;continue}if(e.noparen!==!0&&R===ft){if(y=m.isGlob=!0,n===!0){let W=1;for(;u()!==!0&&(R=D());){if(R===rt){_=m.backslashes=!0,D();continue}if(R===ft){W++;continue}if(R===Zt&&--W===0){I=!0;break}}continue}break}if(y===!0){if(I=!0,n===!0)continue;break}}e.noext===!0&&(C=!1,y=!1);let P=h,c="",a="";g>0&&(c=h.slice(0,g),h=h.slice(g),A-=g),P&&y===!0&&A>0?(P=h.slice(0,A),a=h.slice(A)):y===!0?(P="",a=h):P=h,P&&P!==""&&P!=="/"&&P!==h&&Vt(P.charCodeAt(P.length-1))&&(P=P.slice(0,-1)),e.unescape===!0&&(a&&(a=zt.removeBackslashes(a)),P&&_===!0&&(P=zt.removeBackslashes(P)));let X={prefix:c,input:t,start:g,base:P,glob:a,isBrace:S,isBracket:x,isGlob:y,isExtglob:C,isGlobstar:H,negated:B,negatedExtglob:j};if(e.tokens===!0&&(X.maxDepth=0,Vt(R)||i.push(m),X.tokens=i),e.parts===!0||e.tokens===!0){let $;for(let N=0;N<o.length;N++){let J=$!==void 0?$+1:g,ot=o[N],Y=t.slice(J,ot);e.tokens&&(N===0&&g!==0?(i[N].isPrefix=!0,i[N].value=c):i[N].value=Y,Jt(i[N]),X.maxDepth+=i[N].depth),ot>=g&&(l.push(Y),$=ot)}let W=$!==void 0?$+1:g,U=t.slice(W);l.push(U),e.tokens&&$&&$+1<t.length&&(i[i.length-1].value=U,Jt(i[i.length-1]),X.maxDepth+=i[i.length-1].depth),X.slashes=o,X.parts=l}return X};ee.exports=Ur});var ie=et((Vs,oe)=>{"use strict";var at=it(),K=ut(),{MAX_LENGTH:ht,POSIX_REGEX_SOURCE:Kr,REGEX_NON_SPECIAL_CHARS:Xr,REGEX_SPECIAL_CHARS_BACKREF:jr,REPLACEMENTS:se}=at,Qr=(t,r)=>{if(typeof r.expandRange=="function")return r.expandRange(...t,r);t.sort();let e=`[${t.join("-")}]`;try{new RegExp(e)}catch{return t.map(n=>K.escapeRegex(n)).join("..")}return e},st=(t,r)=>`Missing ${t}: "${r}" - use "\\\\${r}" to match literal characters`,ne=t=>{let r=[],e=0,s=0,n=0,o="",i=!1;for(let l of t){if(i===!0){o+=l,i=!1;continue}if(l==="\\"){o+=l,i=!0;continue}if(l==='"'){n=n===1?0:1,o+=l;continue}if(n===0){if(l==="[")e++;else if(l==="]"&&e>0)e--;else if(e===0){if(l==="(")s++;else if(l===")"&&s>0)s--;else if(l==="|"&&s===0){r.push(o),o="";continue}}}o+=l}return r.push(o),r},zr=t=>{let r=!1;for(let e of t){if(r===!0){r=!1;continue}if(e==="\\"){r=!0;continue}if(/[?*+@!()[\]{}]/.test(e))return!1}return!0},xt=t=>{let r=t.trim(),e=!0;for(;e===!0;)e=!1,/^@\([^\\()[\]{}|]+\)$/.test(r)&&(r=r.slice(2,-1),e=!0);if(zr(r))return r.replace(/\\(.)/g,"$1")},Yr=t=>{let r=t.map(xt).filter(Boolean);for(let e=0;e<r.length;e++)for(let s=e+1;s<r.length;s++){let n=r[e],o=r[s],i=n[0];if(!(!i||n!==i.repeat(n.length)||o!==i.repeat(o.length))&&(n===o||n.startsWith(o)||o.startsWith(n)))return!0}return!1},mt=(t,r=!0)=>{if(t[0]!=="+"&&t[0]!=="*"||t[1]!=="(")return;let e=0,s=0,n=0,o=!1;for(let i=1;i<t.length;i++){let l=t[i];if(o===!0){o=!1;continue}if(l==="\\"){o=!0;continue}if(l==='"'){n=n===1?0:1;continue}if(n!==1){if(l==="["){e++;continue}if(l==="]"&&e>0){e--;continue}if(!(e>0)){if(l==="("){s++;continue}if(l===")"&&(s--,s===0))return r===!0&&i!==t.length-1?void 0:{type:t[0],body:t.slice(2,i),end:i}}}}},Zr=t=>`${t.length===1?K.escapeRegex(t[0]):`[${t.map(e=>K.escapeRegex(e)).join("")}]`}*`,Vr=t=>{let r=0,e=[];for(;r<t.length;){let s=mt(t.slice(r),!1);if(!s||s.type!=="*")return;let n=ne(s.body).map(i=>i.trim());if(n.length!==1)return;let o=xt(n[0]);if(!o||o.length!==1)return;e.push(o),r+=s.end+1}if(!(e.length<1))return e},Jr=t=>{let r=0,e=t.trim(),s=mt(e);for(;s;)r++,e=s.body.trim(),s=mt(e);return r},ts=(t,r)=>{if(r.maxExtglobRecursion===!1)return{risky:!1};let e=typeof r.maxExtglobRecursion=="number"?r.maxExtglobRecursion:at.DEFAULT_MAX_EXTGLOB_RECURSION,s=ne(t).map(l=>l.trim());if(s.length>1&&(s.some(l=>l==="")||s.some(l=>/^[*?]+$/.test(l))||Yr(s)))return{risky:!0};let n=[],o=!1,i=!0;for(let l of s){let h=Vr(l);if(h){o=!0,n.push(...h);continue}let d=xt(l);if(d&&d.length===1){n.push(d);continue}if(i=!1,Jr(l)>e)return{risky:!0}}return o?i?{risky:!0,safeOutput:Zr([...new Set(n)])}:{risky:!0}:{risky:!1}},Ct=(t,r)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=se[t]||t;let e={...r},s=typeof e.maxLength=="number"?Math.min(ht,e.maxLength):ht,n=t.length;if(n>s)throw new SyntaxError(`Input length: ${n}, exceeds maximum allowed length: ${s}`);let o={type:"bos",value:"",output:e.prepend||""},i=[o],l=e.capture?"":"?:",h=at.globChars(e.windows),d=at.extglobChars(h),{DOT_LITERAL:g,PLUS_LITERAL:A,SLASH_LITERAL:S,ONE_CHAR:x,DOTS_SLASH:y,NO_DOT:C,NO_DOT_SLASH:H,NO_DOTS_SLASH:G,QMARK:_,QMARK_NO_DOT:B,STAR:j,START_ANCHOR:I}=h,w=f=>`(${l}(?:(?!${I}${f.dot?y:g}).)*?)`,L=e.dot?"":C,R=e.dot?_:B,m=e.bash===!0?w(e):j;e.capture&&(m=`(${m})`),typeof e.noext=="boolean"&&(e.noextglob=e.noext);let u={input:t,index:-1,start:0,dot:e.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:i};t=K.removePrefix(t,u),n=t.length;let M=[],D=[],P=[],c=o,a,X=()=>u.index===n-1,$=u.peek=(f=1)=>t[u.index+f],W=u.advance=()=>t[++u.index]||"",U=()=>t.slice(u.index+1),N=(f="",O=0)=>{u.consumed+=f,u.index+=O},J=f=>{u.output+=f.output!=null?f.output:f.value,N(f.value)},ot=()=>{let f=1;for(;$()==="!"&&($(2)!=="("||$(3)==="?");)W(),u.start++,f++;return f%2===0?!1:(u.negated=!0,u.start++,!0)},Y=f=>{u[f]++,P.push(f)},z=f=>{u[f]--,P.pop()},E=f=>{if(c.type==="globstar"){let O=u.braces>0&&(f.type==="comma"||f.type==="brace"),p=f.extglob===!0||M.length&&(f.type==="pipe"||f.type==="paren");f.type!=="slash"&&f.type!=="paren"&&!O&&!p&&(u.output=u.output.slice(0,-c.output.length),c.type="star",c.value="*",c.output=m,u.output+=c.output)}if(M.length&&f.type!=="paren"&&(M[M.length-1].inner+=f.value),(f.value||f.output)&&J(f),c&&c.type==="text"&&f.type==="text"){c.output=(c.output||c.value)+f.value,c.value+=f.value;return}f.prev=c,i.push(f),c=f},lt=(f,O)=>{let p={...d[O],conditions:1,inner:""};p.prev=c,p.parens=u.parens,p.output=u.output,p.startIndex=u.index,p.tokensIndex=i.length;let b=(e.capture?"(":"")+p.open;Y("parens"),E({type:f,value:O,output:u.output?"":x}),E({type:"paren",extglob:!0,value:W(),output:b}),M.push(p)},me=f=>{let O=t.slice(f.startIndex,u.index+1),p=t.slice(f.startIndex+2,u.index),b=ts(p,e);if((f.type==="plus"||f.type==="star")&&b.risky){let v=b.safeOutput?(f.output?"":x)+(e.capture?`(${b.safeOutput})`:b.safeOutput):void 0,Q=i[f.tokensIndex];Q.type="text",Q.value=O,Q.output=v||K.escapeRegex(O);for(let Z=f.tokensIndex+1;Z<i.length;Z++)i[Z].value="",i[Z].output="",delete i[Z].suffix;u.output=f.output+Q.output,u.backtrack=!0,E({type:"paren",extglob:!0,value:a,output:""}),z("parens");return}let T=f.close+(e.capture?")":""),F;if(f.type==="negate"){let v=m;if(f.inner&&f.inner.length>1&&f.inner.includes("/")&&(v=w(e)),(v!==m||X()||/^\)+$/.test(U()))&&(T=f.close=`)$))${v}`),f.inner.includes("*")&&(F=U())&&/^\.[^\\/.]+$/.test(F)){let Q=Ct(F,{...r,fastpaths:!1}).output;T=f.close=`)${Q})${v})`}f.prev.type==="bos"&&(u.negatedExtglob=!0)}E({type:"paren",extglob:!0,value:a,output:T}),z("parens")};if(e.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(t)){let f=!1,O=t.replace(jr,(p,b,T,F,v,Q)=>F==="\\"?(f=!0,p):F==="?"?b?b+F+(v?_.repeat(v.length):""):Q===0?R+(v?_.repeat(v.length):""):_.repeat(T.length):F==="."?g.repeat(T.length):F==="*"?b?b+F+(v?m:""):m:b?p:`\\${p}`);return f===!0&&(e.unescape===!0?O=O.replace(/\\/g,""):O=O.replace(/\\+/g,p=>p.length%2===0?"\\\\":p?"\\":"")),O===t&&e.contains===!0?(u.output=t,u):(u.output=K.wrapOutput(O,u,r),u)}for(;!X();){if(a=W(),a==="\0")continue;if(a==="\\"){let p=$();if(p==="/"&&e.bash!==!0||p==="."||p===";")continue;if(!p){a+="\\",E({type:"text",value:a});continue}let b=/^\\+/.exec(U()),T=0;if(b&&b[0].length>2&&(T=b[0].length,u.index+=T,T%2!==0&&(a+="\\")),e.unescape===!0?a=W():a+=W(),u.brackets===0){E({type:"text",value:a});continue}}if(u.brackets>0&&(a!=="]"||c.value==="["||c.value==="[^")){if(e.posix!==!1&&a===":"){let p=c.value.slice(1);if(p.includes("[")&&(c.posix=!0,p.includes(":"))){let b=c.value.lastIndexOf("["),T=c.value.slice(0,b),F=c.value.slice(b+2),v=Kr[F];if(v){c.value=T+v,u.backtrack=!0,W(),!o.output&&i.indexOf(c)===1&&(o.output=x);continue}}}(a==="["&&$()!==":"||a==="-"&&$()==="]")&&(a=`\\${a}`),a==="]"&&(c.value==="["||c.value==="[^")&&(a=`\\${a}`),e.posix===!0&&a==="!"&&c.value==="["&&(a="^"),c.value+=a,J({value:a});continue}if(u.quotes===1&&a!=='"'){a=K.escapeRegex(a),c.value+=a,J({value:a});continue}if(a==='"'){u.quotes=u.quotes===1?0:1,e.keepQuotes===!0&&E({type:"text",value:a});continue}if(a==="("){Y("parens"),E({type:"paren",value:a});continue}if(a===")"){if(u.parens===0&&e.strictBrackets===!0)throw new SyntaxError(st("opening","("));let p=M[M.length-1];if(p&&u.parens===p.parens+1){me(M.pop());continue}E({type:"paren",value:a,output:u.parens?")":"\\)"}),z("parens");continue}if(a==="["){if(e.nobracket===!0||!U().includes("]")){if(e.nobracket!==!0&&e.strictBrackets===!0)throw new SyntaxError(st("closing","]"));a=`\\${a}`}else Y("brackets");E({type:"bracket",value:a});continue}if(a==="]"){if(e.nobracket===!0||c&&c.type==="bracket"&&c.value.length===1){E({type:"text",value:a,output:`\\${a}`});continue}if(u.brackets===0){if(e.strictBrackets===!0)throw new SyntaxError(st("opening","["));E({type:"text",value:a,output:`\\${a}`});continue}z("brackets");let p=c.value.slice(1);if(c.posix!==!0&&p[0]==="^"&&!p.includes("/")&&(a=`/${a}`),c.value+=a,J({value:a}),e.literalBrackets===!1||K.hasRegexChars(p))continue;let b=K.escapeRegex(c.value);if(u.output=u.output.slice(0,-c.value.length),e.literalBrackets===!0){u.output+=b,c.value=b;continue}c.value=`(${l}${b}|${c.value})`,u.output+=c.value;continue}if(a==="{"&&e.nobrace!==!0){Y("braces");let p={type:"brace",value:a,output:"(",outputIndex:u.output.length,tokensIndex:u.tokens.length};D.push(p),E(p);continue}if(a==="}"){let p=D[D.length-1];if(e.nobrace===!0||!p){E({type:"text",value:a,output:a});continue}let b=")";if(p.dots===!0){let T=i.slice(),F=[];for(let v=T.length-1;v>=0&&(i.pop(),T[v].type!=="brace");v--)T[v].type!=="dots"&&F.unshift(T[v].value);b=Qr(F,e),u.backtrack=!0}if(p.comma!==!0&&p.dots!==!0){let T=u.output.slice(0,p.outputIndex),F=u.tokens.slice(p.tokensIndex);p.value=p.output="\\{",a=b="\\}",u.output=T;for(let v of F)u.output+=v.output||v.value}E({type:"brace",value:a,output:b}),z("braces"),D.pop();continue}if(a==="|"){M.length>0&&M[M.length-1].conditions++,E({type:"text",value:a});continue}if(a===","){let p=a,b=D[D.length-1];b&&P[P.length-1]==="braces"&&(b.comma=!0,p="|"),E({type:"comma",value:a,output:p});continue}if(a==="/"){if(c.type==="dot"&&u.index===u.start+1){u.start=u.index+1,u.consumed="",u.output="",i.pop(),c=o;continue}E({type:"slash",value:a,output:S});continue}if(a==="."){if(u.braces>0&&c.type==="dot"){c.value==="."&&(c.output=g);let p=D[D.length-1];c.type="dots",c.output+=a,c.value+=a,p.dots=!0;continue}if(u.braces+u.parens===0&&c.type!=="bos"&&c.type!=="slash"){E({type:"text",value:a,output:g});continue}E({type:"dot",value:a,output:g});continue}if(a==="?"){if(!(c&&c.value==="(")&&e.noextglob!==!0&&$()==="("&&$(2)!=="?"){lt("qmark",a);continue}if(c&&c.type==="paren"){let b=$(),T=a;(c.value==="("&&!/[!=<:]/.test(b)||b==="<"&&!/<([!=]|\w+>)/.test(U()))&&(T=`\\${a}`),E({type:"text",value:a,output:T});continue}if(e.dot!==!0&&(c.type==="slash"||c.type==="bos")){E({type:"qmark",value:a,output:B});continue}E({type:"qmark",value:a,output:_});continue}if(a==="!"){if(e.noextglob!==!0&&$()==="("&&($(2)!=="?"||!/[!=<:]/.test($(3)))){lt("negate",a);continue}if(e.nonegate!==!0&&u.index===0){ot();continue}}if(a==="+"){if(e.noextglob!==!0&&$()==="("&&$(2)!=="?"){lt("plus",a);continue}if(c&&c.value==="("||e.regex===!1){E({type:"plus",value:a,output:A});continue}if(c&&(c.type==="bracket"||c.type==="paren"||c.type==="brace")||u.parens>0){E({type:"plus",value:a});continue}E({type:"plus",value:A});continue}if(a==="@"){if(e.noextglob!==!0&&$()==="("&&$(2)!=="?"){E({type:"at",extglob:!0,value:a,output:""});continue}E({type:"text",value:a});continue}if(a!=="*"){(a==="$"||a==="^")&&(a=`\\${a}`);let p=Xr.exec(U());p&&(a+=p[0],u.index+=p[0].length),E({type:"text",value:a});continue}if(c&&(c.type==="globstar"||c.star===!0)){c.type="star",c.star=!0,c.value+=a,c.output=m,u.backtrack=!0,u.globstar=!0,N(a);continue}let f=U();if(e.noextglob!==!0&&/^\([^?]/.test(f)){lt("star",a);continue}if(c.type==="star"){if(e.noglobstar===!0){N(a);continue}let p=c.prev,b=p.prev,T=p.type==="slash"||p.type==="bos",F=b&&(b.type==="star"||b.type==="globstar");if(e.bash===!0&&(!T||f[0]&&f[0]!=="/")){E({type:"star",value:a,output:""});continue}let v=u.braces>0&&(p.type==="comma"||p.type==="brace"),Q=M.length&&(p.type==="pipe"||p.type==="paren");if(!T&&p.type!=="paren"&&!v&&!Q){E({type:"star",value:a,output:""});continue}for(;f.slice(0,3)==="/**";){let tt=t[u.index+4];if(tt&&tt!=="/")break;f=f.slice(3),N("/**",3)}let Z=X()||u.parens>0&&f===")".repeat(u.parens)&&!M.some(tt=>tt.type==="negate");if(p.type==="bos"&&X()){c.type="globstar",c.value+=a,c.output=w(e),u.output=c.output,u.globstar=!0,N(a);continue}if(p.type==="slash"&&p.prev.type!=="bos"&&!F&&Z){u.output=u.output.slice(0,-(p.output+c.output).length),p.output=`(?:${p.output}`,c.type="globstar",c.output=w(e)+(e.strictSlashes?")":"|$)"),c.value+=a,u.globstar=!0,u.output+=p.output+c.output,N(a);continue}if(p.type==="slash"&&p.prev.type!=="bos"&&f[0]==="/"){let tt=f[1]!==void 0?"|$":"";u.output=u.output.slice(0,-(p.output+c.output).length),p.output=`(?:${p.output}`,c.type="globstar",c.output=`${w(e)}${S}|${S}${tt})`,c.value+=a,u.output+=p.output+c.output,u.globstar=!0,N(a+W()),E({type:"slash",value:"/",output:""});continue}if(p.type==="bos"&&f[0]==="/"){c.type="globstar",c.value+=a,c.output=`(?:^|${S}|${w(e)}${S})`,u.output=c.output,u.globstar=!0,N(a+W()),E({type:"slash",value:"/",output:""});continue}u.output=u.output.slice(0,-c.output.length),c.type="globstar",c.output=w(e),c.value+=a,u.output+=c.output,u.globstar=!0,N(a);continue}let O={type:"star",value:a,output:m};if(e.bash===!0){O.output=".*?",(c.type==="bos"||c.type==="slash")&&(O.output=L+O.output),E(O);continue}if(c&&(c.type==="bracket"||c.type==="paren")&&e.regex===!0){O.output=a,E(O);continue}(u.index===u.start||c.type==="slash"||c.type==="dot")&&(c.type==="dot"?(u.output+=H,c.output+=H):e.dot===!0?(u.output+=G,c.output+=G):(u.output+=L,c.output+=L),$()!=="*"&&(u.output+=x,c.output+=x)),E(O)}for(;u.brackets>0;){if(e.strictBrackets===!0)throw new SyntaxError(st("closing","]"));u.output=K.escapeLast(u.output,"["),z("brackets")}for(;u.parens>0;){if(e.strictBrackets===!0)throw new SyntaxError(st("closing",")"));u.output=K.escapeLast(u.output,"("),z("parens")}for(;u.braces>0;){if(e.strictBrackets===!0)throw new SyntaxError(st("closing","}"));u.output=K.escapeLast(u.output,"{"),z("braces")}if(e.strictSlashes!==!0&&(c.type==="star"||c.type==="bracket")&&E({type:"maybe_slash",value:"",output:`${S}?`}),u.backtrack===!0){u.output="";for(let f of u.tokens)u.output+=f.output!=null?f.output:f.value,f.suffix&&(u.output+=f.suffix)}return u};Ct.fastpaths=(t,r)=>{let e={...r},s=typeof e.maxLength=="number"?Math.min(ht,e.maxLength):ht,n=t.length;if(n>s)throw new SyntaxError(`Input length: ${n}, exceeds maximum allowed length: ${s}`);t=se[t]||t;let{DOT_LITERAL:o,SLASH_LITERAL:i,ONE_CHAR:l,DOTS_SLASH:h,NO_DOT:d,NO_DOTS:g,NO_DOTS_SLASH:A,STAR:S,START_ANCHOR:x}=at.globChars(e.windows),y=e.dot?g:d,C=e.dot?A:d,H=e.capture?"":"?:",G={negated:!1,prefix:""},_=e.bash===!0?".*?":S;e.capture&&(_=`(${_})`);let B=L=>L.noglobstar===!0?_:`(${H}(?:(?!${x}${L.dot?h:o}).)*?)`,j=L=>{switch(L){case"*":return`${y}${l}${_}`;case".*":return`${o}${l}${_}`;case"*.*":return`${y}${_}${o}${l}${_}`;case"*/*":return`${y}${_}${i}${l}${C}${_}`;case"**":return y+B(e);case"**/*":return`(?:${y}${B(e)}${i})?${C}${l}${_}`;case"**/*.*":return`(?:${y}${B(e)}${i})?${C}${_}${o}${l}${_}`;case"**/.*":return`(?:${y}${B(e)}${i})?${o}${l}${_}`;default:{let R=/^(.*?)\.(\w+)$/.exec(L);if(!R)return;let m=j(R[1]);return m?m+o+R[2]:void 0}}},I=K.removePrefix(t,G),w=j(I);return w&&e.strictSlashes!==!0&&(w+=`${i}?`),w};oe.exports=Ct});var ce=et((Js,ae)=>{"use strict";var es=re(),$t=ie(),ue=ut(),rs=it(),ss=t=>t&&typeof t=="object"&&!Array.isArray(t),k=(t,r,e=!1)=>{if(Array.isArray(t)){let g=t.map(S=>k(S,r,e));return S=>{for(let x of g){let y=x(S);if(y)return y}return!1}}let s=ss(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!s)throw new TypeError("Expected pattern to be a non-empty string");let n=r||{},o=n.windows,i=s?k.compileRe(t,r):k.makeRe(t,r,!1,!0),l=i.state;delete i.state;let h=()=>!1;if(n.ignore){let g={...r,ignore:null,onMatch:null,onResult:null};h=k(n.ignore,g,e)}let d=(g,A=!1)=>{let{isMatch:S,match:x,output:y}=k.test(g,i,r,{glob:t,posix:o}),C={glob:t,state:l,regex:i,posix:o,input:g,output:y,match:x,isMatch:S};return typeof n.onResult=="function"&&n.onResult(C),S===!1?(C.isMatch=!1,A?C:!1):h(g)?(typeof n.onIgnore=="function"&&n.onIgnore(C),C.isMatch=!1,A?C:!1):(typeof n.onMatch=="function"&&n.onMatch(C),A?C:!0)};return e&&(d.state=l),d};k.test=(t,r,e,{glob:s,posix:n}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return{isMatch:!1,output:""};let o=e||{},i=o.format||(n?ue.toPosixSlashes:null),l=t===s,h=l&&i?i(t):t;return l===!1&&(h=i?i(t):t,l=h===s),(l===!1||o.capture===!0)&&(o.matchBase===!0||o.basename===!0?l=k.matchBase(t,r,e,n):l=r.exec(h)),{isMatch:!!l,match:l,output:h}};k.matchBase=(t,r,e,s=e&&e.windows)=>(r instanceof RegExp?r:k.makeRe(r,e)).test(ue.basename(t,{windows:s}));k.isMatch=(t,r,e)=>k(r,e)(t);k.parse=(t,r)=>Array.isArray(t)?t.map(e=>k.parse(e,r)):$t(t,{...r,fastpaths:!1});k.scan=(t,r)=>es(t,r);k.compileRe=(t,r,e=!1,s=!1)=>{if(e===!0)return t.output;let n=r||{},o=n.contains?"":"^",i=n.contains?"":"$",l=`${o}(?:${t.output})${i}`;t&&t.negated===!0&&(l=`^(?!${l}).*$`);let h=k.toRegex(l,r);return s===!0&&(h.state=t),h};k.makeRe=(t,r={},e=!1,s=!1)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let n={negated:!1,fastpaths:!0};return r.fastpaths!==!1&&(t[0]==="."||t[0]==="*")&&(n.output=$t.fastpaths(t,r)),n.output||(n=$t(t,r)),k.compileRe(n,r,e,s)};k.toRegex=(t,r)=>{try{let e=r||{};return new RegExp(t,e.flags||(e.nocase?"i":""))}catch(e){if(r&&r.debug===!0)throw e;return/$^/}};k.constants=rs;ae.exports=k});var he=et((tn,fe)=>{"use strict";var le=ce(),ns=ut();function pe(t,r,e=!1){return r&&(r.windows===null||r.windows===void 0)&&(r={...r,windows:ns.isWindows()}),le(t,r,e)}Object.assign(pe,le);fe.exports=pe});import{existsSync as ks}from"node:fs";import{stat as Ds}from"node:fs/promises";import{resolve as Ee}from"node:path";import{readdir as os,readdirSync as is,realpath as us,realpathSync as as,stat as cs,statSync as ls}from"fs";import{isAbsolute as ps,posix as V,resolve as fs}from"path";import{fileURLToPath as hs}from"url";import{createRequire as Ce}from"module";import{basename as $e,dirname as dt,normalize as Le,relative as ve,resolve as we,sep as kt}from"path";import*as Te from"fs";var It=Ce(import.meta.url);function Oe(t){let r=Le(t);return r.length>1&&r[r.length-1]===kt&&(r=r.substring(0,r.length-1)),r}var He=/[\\/]/g;function Dt(t,r){return t.replace(He,r)}var Ie=/^[a-z]:[\\/]$/i;function Pe(t){return t==="/"||Ie.test(t)}function At(t,r){let{resolvePaths:e,normalizePath:s,pathSeparator:n}=r,o=process.platform==="win32"&&t.includes("/")||t.startsWith(".");if(e&&(t=we(t)),(s||o)&&(t=Oe(t)),t===".")return"";let i=t[t.length-1]!==n;return Dt(i?t+n:t,n)}function Nt(t,r){return r+t}function ke(t,r){return function(e,s){return s.startsWith(t)?s.slice(t.length)+e:Dt(ve(t,s),r.pathSeparator)+r.pathSeparator+e}}function De(t){return t}function Ne(t,r,e){return r+t+e}function Fe(t,r){let{relativePaths:e,includeBasePath:s}=r;return e&&t?ke(t,r):s?Nt:De}function Be(t){return function(r,e){e.push(r.substring(t.length)||".")}}function Me(t){return function(r,e,s){let n=r.substring(t.length)||".";s.every(o=>o(n,!0))&&e.push(n)}}var Ge=(t,r)=>{r.push(t||".")},We=(t,r,e)=>{let s=t||".";e.every(n=>n(s,!0))&&r.push(s)},qe=()=>{};function Ue(t,r){let{includeDirs:e,filters:s,relativePaths:n}=r;return e?n?s&&s.length?Me(t):Be(t):s&&s.length?We:Ge:qe}var Ke=(t,r,e,s)=>{s.every(n=>n(t,!1))&&e.files++},Xe=(t,r,e,s)=>{s.every(n=>n(t,!1))&&r.push(t)},je=(t,r,e,s)=>{e.files++},Qe=(t,r)=>{r.push(t)},ze=()=>{};function Ye(t){let{excludeFiles:r,filters:e,onlyCounts:s}=t;return r?ze:e&&e.length?s?Ke:Xe:s?je:Qe}var Ze=t=>t,Ve=()=>[""].slice(0,0);function Je(t){return t.group?Ve:Ze}var tr=(t,r,e)=>{t.push({directory:r,files:e,dir:r})},er=()=>{};function rr(t){return t.group?tr:er}var sr=function(t,r,e){let{queue:s,fs:n,options:{suppressErrors:o}}=r;s.enqueue(),n.realpath(t,(i,l)=>{if(i)return s.dequeue(o?null:i,r);n.stat(l,(h,d)=>{if(h)return s.dequeue(o?null:h,r);if(d.isDirectory()&&Ft(t,l,r))return s.dequeue(null,r);e(d,l),s.dequeue(null,r)})})},nr=function(t,r,e){let{queue:s,fs:n,options:{suppressErrors:o}}=r;s.enqueue();try{let i=n.realpathSync(t),l=n.statSync(i);if(l.isDirectory()&&Ft(t,i,r))return;e(l,i)}catch(i){if(!o)throw i}};function or(t,r){return!t.resolveSymlinks||t.excludeSymlinks?null:r?nr:sr}function Ft(t,r,e){if(e.options.useRealPaths)return ir(r,e);let s=dt(t),n=1;for(;s!==e.root&&n<2;){let o=e.symlinks.get(s);!!o&&(o===r||o.startsWith(r)||r.startsWith(o))?n++:s=dt(s)}return e.symlinks.set(t,r),n>1}function ir(t,r){return r.visited.includes(t+r.options.pathSeparator)}var ur=t=>t.counts,ar=t=>t.groups,cr=t=>t.paths,lr=t=>t.paths.slice(0,t.options.maxFiles),pr=(t,r,e)=>(pt(r,e,t.counts,t.options.suppressErrors),null),fr=(t,r,e)=>(pt(r,e,t.paths,t.options.suppressErrors),null),hr=(t,r,e)=>(pt(r,e,t.paths.slice(0,t.options.maxFiles),t.options.suppressErrors),null),gr=(t,r,e)=>(pt(r,e,t.groups,t.options.suppressErrors),null);function pt(t,r,e,s){r(t&&!s?t:null,e)}function Ar(t,r){let{onlyCounts:e,group:s,maxFiles:n}=t;return e?r?ur:pr:s?r?ar:gr:n?r?lr:hr:r?cr:fr}var Bt={withFileTypes:!0},dr=(t,r,e,s,n)=>{if(t.queue.enqueue(),s<0)return t.queue.dequeue(null,t);let{fs:o}=t;t.visited.push(r),t.counts.directories++,o.readdir(r||".",Bt,(i,l=[])=>{n(l,e,s),t.queue.dequeue(t.options.suppressErrors?null:i,t)})},yr=(t,r,e,s,n)=>{let{fs:o}=t;if(s<0)return;t.visited.push(r),t.counts.directories++;let i=[];try{i=o.readdirSync(r||".",Bt)}catch(l){if(!t.options.suppressErrors)throw l}n(i,e,s)};function Rr(t){return t?yr:dr}var Sr=class{count=0;constructor(t){this.onQueueEmpty=t}enqueue(){return this.count++,this.count}dequeue(t,r){this.onQueueEmpty&&(--this.count<=0||t)&&(this.onQueueEmpty(t,r),t&&(r.controller.abort(),this.onQueueEmpty=void 0))}},_r=class{_files=0;_directories=0;set files(t){this._files=t}get files(){return this._files}set directories(t){this._directories=t}get directories(){return this._directories}get dirs(){return this._directories}},Er=class{aborted=!1;abort(){this.aborted=!0}},Mt=class{root;isSynchronous;state;joinPath;pushDirectory;pushFile;getArray;groupFiles;resolveSymlink;walkDirectory;callbackInvoker;constructor(t,r,e){this.isSynchronous=!e,this.callbackInvoker=Ar(r,this.isSynchronous),this.root=At(t,r),this.state={root:Pe(this.root)?this.root:this.root.slice(0,-1),paths:[""].slice(0,0),groups:[],counts:new _r,options:r,queue:new Sr((s,n)=>this.callbackInvoker(n,s,e)),symlinks:new Map,visited:[""].slice(0,0),controller:new Er,fs:r.fs||Te},this.joinPath=Fe(this.root,r),this.pushDirectory=Ue(this.root,r),this.pushFile=Ye(r),this.getArray=Je(r),this.groupFiles=rr(r),this.resolveSymlink=or(r,this.isSynchronous),this.walkDirectory=Rr(this.isSynchronous)}start(){return this.pushDirectory(this.root,this.state.paths,this.state.options.filters),this.walkDirectory(this.state,this.root,this.root,this.state.options.maxDepth,this.walk),this.isSynchronous?this.callbackInvoker(this.state,null):null}walk=(t,r,e)=>{let{paths:s,options:{filters:n,resolveSymlinks:o,excludeSymlinks:i,exclude:l,maxFiles:h,signal:d,useRealPaths:g,pathSeparator:A},controller:S}=this.state;if(S.aborted||d&&d.aborted||h&&s.length>h)return;let x=this.getArray(this.state.paths);for(let y=0;y<t.length;++y){let C=t[y];if(C.isFile()||C.isSymbolicLink()&&!o&&!i){let H=this.joinPath(C.name,r);this.pushFile(H,x,this.state.counts,n)}else if(C.isDirectory()){let H=Ne(C.name,r,this.state.options.pathSeparator);if(l&&l(C.name,H))continue;this.pushDirectory(H,s,n),this.walkDirectory(this.state,H,H,e-1,this.walk)}else if(this.resolveSymlink&&C.isSymbolicLink()){let H=Nt(C.name,r);this.resolveSymlink(H,this.state,(G,_)=>{if(G.isDirectory()){if(_=At(_,this.state.options),l&&l(C.name,g?_:H+A))return;this.walkDirectory(this.state,_,g?_:H+A,e-1,this.walk)}else{_=g?_:H;let B=$e(_),j=At(dt(_),this.state.options);_=this.joinPath(B,j),this.pushFile(_,x,this.state.counts,n)}})}}this.groupFiles(this.state.groups,r,x)}};function br(t,r){return new Promise((e,s)=>{Gt(t,r,(n,o)=>{if(n)return s(n);e(o)})})}function Gt(t,r,e){new Mt(t,r,e).start()}function mr(t,r){return new Mt(t,r).start()}var Pt=class{constructor(t,r){this.root=t,this.options=r}withPromise(){return br(this.root,this.options)}withCallback(t){Gt(this.root,this.options,t)}sync(){return mr(this.root,this.options)}},Wt=null;try{It.resolve("picomatch"),Wt=It("picomatch")}catch{}var qt=class{globCache={};options={maxDepth:1/0,suppressErrors:!0,pathSeparator:kt,filters:[]};globFunction;constructor(t){this.options={...this.options,...t},this.globFunction=this.options.globFunction}group(){return this.options.group=!0,this}withPathSeparator(t){return this.options.pathSeparator=t,this}withBasePath(){return this.options.includeBasePath=!0,this}withRelativePaths(){return this.options.relativePaths=!0,this}withDirs(){return this.options.includeDirs=!0,this}withMaxDepth(t){return this.options.maxDepth=t,this}withMaxFiles(t){return this.options.maxFiles=t,this}withFullPaths(){return this.options.resolvePaths=!0,this.options.includeBasePath=!0,this}withErrors(){return this.options.suppressErrors=!1,this}withSymlinks({resolvePaths:t=!0}={}){return this.options.resolveSymlinks=!0,this.options.useRealPaths=t,this.withFullPaths()}withAbortSignal(t){return this.options.signal=t,this}normalize(){return this.options.normalizePath=!0,this}filter(t){return this.options.filters.push(t),this}onlyDirs(){return this.options.excludeFiles=!0,this.options.includeDirs=!0,this}exclude(t){return this.options.exclude=t,this}onlyCounts(){return this.options.onlyCounts=!0,this}crawl(t){return new Pt(t||".",this.options)}withGlobFunction(t){return this.globFunction=t,this}crawlWithOptions(t,r){return this.options={...this.options,...r},new Pt(t||".",this.options)}glob(...t){return this.globFunction?this.globWithOptions(t):this.globWithOptions(t,{dot:!0})}globWithOptions(t,...r){let e=this.globFunction||Wt;if(!e)throw new Error("Please specify a glob function to use glob matching.");var s=this.globCache[t.join("\0")];return s||(s=e(t,...r),this.globCache[t.join("\0")]=s),this.options.filters.push(n=>s(n)),this}};var nt=xe(he(),1),gs=Array.isArray,ye=/\\/g,As=/^[A-Za-z]:$/,Re=process.platform==="win32",ds=/^(\/?\.\.)+$/;function ys(t,r={}){let e=t.length,s=Array(e),n=Array(e),o,i;for(o=0;o<e;o++){let l=Se(t[o]);s[o]=l;let h=l.length,d=Array(h);for(i=0;i<h;i++)d[i]=(0,nt.default)(l[i],r);n[o]=d}return l=>{let h=l.split("/");if(h[0]===".."&&ds.test(l))return!0;for(o=0;o<e;o++){let d=s[o],g=n[o],A=h.length,S=Math.min(A,d.length);for(i=0;i<S;){let x=d[i];if(x.includes("/"))return!0;if(!g[i](h[i]))break;if(!r.noglobstar&&x==="**")return!0;i++}if(i===A)return!0}return!1}}var Rs=/^[A-Z]:\/$/i,Ss=Re?t=>Rs.test(t):t=>t==="/";function ge(t,r,e){if(t===r||r.startsWith(`${t}/`)){if(e){let n=t.length+ +!Ss(t);return(o,i)=>o.slice(n,i?-1:void 0)||"."}let s=r.slice(t.length+1);return s?(n,o)=>{if(n===".")return s;let i=`${s}/${n}`;return o?i.slice(0,-1):i}:(n,o)=>o&&n!=="."?n.slice(0,-1):n}return e?s=>V.relative(t,s)||".":s=>V.relative(t,`${r}/${s}`)||"."}function _s(t,r){if(r.startsWith(`${t}/`)){let e=r.slice(t.length+1);return s=>`${e}/${s}`}return e=>{let s=V.relative(t,`${r}/${e}`);return e[e.length-1]==="/"&&s!==""?`${s}/`:s||"."}}function Ae(t){return t.replace(As,r=>`${r}/`)}var Es={parts:!0};function Se(t){var r;let e=nt.default.scan(t,Es);return!((r=e.parts)===null||r===void 0)&&r.length?e.parts:[t]}var bs=/(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g,ms=/(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g,xs=t=>t.replace(bs,"\\$&"),Cs=t=>t.replace(ms,"\\$&"),$s=Re?Cs:xs;function Ls(t,r){if(r?.caseSensitiveMatch===!1)return!0;let e=nt.default.scan(t);return e.isGlob||e.negated}function ct(...t){console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`,...t)}function _e(t){return typeof t=="string"?[t]:t??[]}var vs=/^(\/?\.\.)+/,ws=/\\(?=[()[\]{}!*+?@|])/g;function Lt(t,r,e,s){var n;let o=r.cwd,i=t;t[t.length-1]==="/"&&(i=t.slice(0,-1)),i[i.length-1]!=="*"&&r.expandDirectories&&(i+="/**");let l=$s(o);i=ps(i.replace(ws,""))?V.relative(l,i):V.normalize(i);let h=(n=vs.exec(i))===null||n===void 0?void 0:n[0],d=Se(i);if(h){let A=(h.length+1)/3,S=0,x=l.split("/");for(;S<A&&d[S+A]===x[x.length+S-A];)i=i.slice(0,(A-S-1)*3)+i.slice((A-S)*3+d[S+A].length+1)||".",S++;let y=V.join(o,h.slice(S*3));y[0]!=="."&&e.root.length>y.length&&(e.root=Ae(y),e.depthOffset=-A+S)}if(!s&&e.depthOffset>=0){var g;(g=e.commonPath)!==null&&g!==void 0||(e.commonPath=d);let A=[],S=Math.min(e.commonPath.length,d.length);for(let x=0;x<S;x++){let y=d[x];if(y==="**"&&!d[x+1]){A.pop();break}if(x===d.length-1||y!==e.commonPath[x]||Ls(y))break;A.push(y)}e.depthOffset=A.length,e.commonPath=A,e.root=Ae(A.length>0?V.join(o,...A):o)}return i}function Ts(t,r,e){let s=[],n=[];for(let o of t.ignore)o&&(o[0]!=="!"||o[1]==="(")&&n.push(Lt(o,t,e,!0));for(let o of r)o&&(o[0]!=="!"||o[1]==="("?s.push(Lt(o,t,e,!1)):(o[1]!=="!"||o[2]==="(")&&n.push(Lt(o.slice(1),t,e,!0)));return{match:s,ignore:n}}function Os(t,r){let e=t.cwd,s={root:e,depthOffset:0},n=Ts(t,r,s);t.debug&&ct("internal processing patterns:",n);let{absolute:o,caseSensitiveMatch:i,debug:l,dot:h,followSymbolicLinks:d,onlyDirectories:g}=t,A=s.root.replace(ye,""),S={dot:h,nobrace:t.braceExpansion===!1,nocase:!i,noextglob:t.extglob===!1,noglobstar:t.globstar===!1,posix:!0},x=(0,nt.default)(n.match,S),y=(0,nt.default)(n.ignore,S),C=ys(n.match,S),H=ge(e,A,o),G=o?H:ge(e,A,!0),_=(I,w)=>{let L=G(w,!0);return L!=="."&&!C(L)||y(L)},B;t.deep!==void 0&&(B=Math.round(t.deep-s.depthOffset));let j=new qt({filters:[l?(I,w)=>{let L=H(I,w),R=x(L)&&!y(L);return R&&ct(`matched ${L}`),R}:(I,w)=>{let L=H(I,w);return x(L)&&!y(L)}],exclude:l?(I,w)=>{let L=_(I,w);return ct(`${L?"skipped":"crawling"} ${w}`),L}:_,fs:t.fs,pathSeparator:"/",relativePaths:!o,resolvePaths:o,includeBasePath:o,resolveSymlinks:d,excludeSymlinks:!d,excludeFiles:g,includeDirs:g||!t.onlyFiles,maxDepth:B,signal:t.signal}).crawl(A);return t.debug&&ct("internal properties:",{...s,root:A}),[j,e!==A&&!o&&_s(e,A)]}function Hs(t,r){if(r)for(let e=t.length-1;e>=0;e--)t[e]=r(t[e]);return t}var de={caseSensitiveMatch:!0,debug:!!process.env.TINYGLOBBY_DEBUG,expandDirectories:!0,followSymbolicLinks:!0,onlyFiles:!0};function Is(t){let r=Object.assign({},t);for(let e in de)r[e]===void 0&&Object.assign(r,{[e]:de[e]});return r.cwd=(r.cwd instanceof URL?hs(r.cwd):fs(r.cwd||process.cwd())).replace(ye,"/"),r.ignore=_e(r.ignore),r.fs&&(r.fs={readdir:r.fs.readdir||os,readdirSync:r.fs.readdirSync||is,realpath:r.fs.realpath||us,realpathSync:r.fs.realpathSync||as,stat:r.fs.stat||cs,statSync:r.fs.statSync||ls}),r.debug&&ct("globbing with options:",r),r}function Ps(t,r={}){var e;if(t&&r?.patterns)throw new Error("Cannot pass patterns as both an argument and an option");let s=gs(t)||typeof t=="string",n=_e((e=s?t:t.patterns)!==null&&e!==void 0?e:"**/*"),o=Is(s?r:t);return n.length>0?Os(o,n):[]}async function vt(t,r){let[e,s]=Ps(t,r);return e?Hs(await e.withPromise(),s):[]}var be=Object.values(wt).flatMap(t=>t.extensions).map(t=>t.slice(1));function Ns(t){return/[*?[\]{}]/.test(t)}async function Fs(t,r){let e=r?`**/*.{${be.join(",")}}`:`*.{${be.join(",")}}`;return(await vt([e],{cwd:t,absolute:!0,onlyFiles:!0,caseSensitiveMatch:!1})).sort()}async function Bs(t,r,e,s){let n=await Fs(t,r);if(n.length===0){e.push({path:t,error:Ot(t)});return}for(let o of n)await s(o,t,!1)}async function gn(t,r){let e=[],s=[],n=new Map,o=new Set,i=async(l,h,d)=>{let g=Ee(l);if(!o.has(g)){o.add(g);try{e.push(await Ht(g)),h&&n.set(g,h)}catch(A){if(Tt(A))s.push({path:g,error:A});else if(d)throw A}}};for(let l of t){let h=Ee(l);if(Ns(l)&&!ks(h)){let g=(r.platform??process.platform)==="win32"?l.replaceAll("\\","/"):l,A=await vt([g],{absolute:!0,onlyFiles:!0});A.length===0&&s.push({path:h,error:gt(h)});for(let S of A.sort())await i(S,void 0,!1);continue}let d;try{d=await Ds(h)}catch{s.push({path:h,error:gt(h)});continue}if(d.isDirectory()){await Bs(h,r.recursive,s,i);continue}await i(h,void 0,!0)}return{sources:e,failures:s,roots:n}}export{gn as a};
|