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,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{f as a}from"./chunk-
|
|
3
|
+
import{f as a}from"./chunk-EPDF4NQI.js";import{c as i}from"./chunk-IE6NFN3N.js";import{a as e}from"./chunk-H3DIRJFE.js";function s(t){let o=Object.keys(e);return[...t].sort((r,n)=>o.indexOf(r)-o.indexOf(n))}function f(t){let o=new Set;for(let r of a)if(r.reads.has(t.format))for(let n of r.writesFor?.(t)??r.writes)e[n].keepsOnly&&n!==t.format||o.add(n);return s([...o])}function F(t){return f(t).map(o=>({id:o,label:e[o].label,hint:e[o].hint,lossy:e[o].lossy}))}function d(){let t=new Set;for(let o of a)for(let r of o.reads)t.add(r);return s([...t])}function l(){let t=new Set;for(let o of a)for(let r of o.writes)t.add(r);return s([...t])}function p(t){return i.writes.has(t)}function I(){let t=new Set(d()),o=new Set(l());return s([...new Set([...t,...o])]).map(r=>({id:r,label:e[r].label,extensions:[...e[r].extensions],read:t.has(r),write:o.has(r),lossy:e[r].lossy}))}export{f as a,F as b,d as c,l as d,p as e,I as f};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{l as P}from"./chunk-
|
|
3
|
+
import{l as P}from"./chunk-6LMVOQQA.js";import{c as k,e as I,f as $}from"./chunk-I25E2XDH.js";import{I as S,ma as E,oa as m,v as x}from"./chunk-CVNYUROW.js";var D=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com"]),M=/^[A-Za-z0-9_-]{11}$/,w=t=>t&&M.test(t)?{kind:"video",id:t,url:`https://www.youtube.com/watch?v=${t}`}:void 0;function Z(t){let r=t.trim();if(r==="")return;let e;try{e=new URL(/^[a-z]+:\/\//i.test(r)?r:`https://${r}`)}catch{return}let n=e.hostname.toLowerCase();if(n==="youtu.be")return w(e.pathname.slice(1).split("/")[0]);if(!D.has(n))return;let[s,o]=e.pathname.split("/").filter(Boolean);if(s==="watch")return w(e.searchParams.get("v"));if(s==="shorts"||s==="live")return w(o);if(s==="playlist"&&e.searchParams.get("list"))return{kind:"playlist"}}var R="Summary and notes by Apple Intelligence. They may contain mistakes.";function N(t){let r=Math.floor(t),e=o=>String(o).padStart(2,"0"),n=Math.floor(r/3600),s=Math.floor(r/60)%60;return n>0?`${n}:${e(s)}:${e(r%60)}`:`${s}:${e(r%60)}`}var L=t=>t.split(/\s+/).filter(Boolean).length,V=60,j=140,Y=1,W=10;function H(t){let r=[],e;for(let n of t){if(e){let s=n.start-e.end;if(!(s>W||s>Y&&e.words>=V||e.words>=j)){e.text+=` ${n.text}`,e.end=n.end,e.words+=L(n.text);continue}r.push({start:e.start,text:e.text})}e={start:n.start,end:n.end,text:n.text,words:L(n.text)}}return e&&r.push({start:e.start,text:e.text}),r}var T=t=>H(t).flatMap(r=>[`**${N(r.start)}** ${r.text}`,""]),B=t=>/^https?:\/\/\S+$/.test(t)?`<${t}>`:t;function Q(t,r,{transcript:e=!0}={}){let n=[`# ${r.title}`,"",B(r.from),""],s=t.notes;if(!s)return[...n,...T(t.segments)].join(`
|
|
4
4
|
`);let o=s.parts,p=a=>{let d=o[a];return d?`### ${d.refused?`Part ${a+1}`:d.heading} \xB7 ${N(d.start)}`:""};n.push(s.summary,"","## Notes",""),o.forEach((a,d)=>{n.push(p(d),""),a.points.length>0&&n.push(...a.points.map(l=>`- ${l}`),"")});let c=[`_${R}_`,""];return e?(n.push("## Transcript",""),o.forEach((a,d)=>{let l=o[d+1]?.start??Number.POSITIVE_INFINITY,b=t.segments.filter(h=>h.start>=a.start&&h.start<l);n.push(p(d),"",...T(b))}),[...n,...c].join(`
|
|
5
5
|
`)):[...n,...c].join(`
|
|
6
6
|
`)}function tt(t){let r=[...t].map(e=>(e.codePointAt(0)??0)<32?" ":e).join("").replace(/[/\\:*?"<>|]/g,"-").replace(/\s+/g," ").trim().slice(0,120).replace(/^\.+/,"");return r===""?"transcript":r}function nt(t){if(t.kind!=="media"){if(t.kind==="image"){let{path:r,format:e,bytes:n,width:s,height:o}=t;return{what:"image",path:r,format:e,bytes:n,width:s,height:o}}if(t.format!=="pdf")throw E(t.path);if(t.encrypted)throw x(t.path);return{what:"pdf",path:t.path,bytes:t.bytes,pages:t.pages}}}import{spawn as _}from"node:child_process";import{mkdtemp as C,rm as K}from"node:fs/promises";import{tmpdir as U}from"node:os";import{join as A}from"node:path";import{createInterface as G}from"node:readline";var z=[[/private video/i,"This video is private."],[/confirm your age/i,"This video is age-restricted."],[/members-only|join this channel/i,"This video is for channel members only."],[/live event will begin|premieres in/i,"This video has not started yet."],[/unavailable|has been removed|does not exist/i,"This video is unavailable."]],g=class extends Error{};function J(t=process.platform,r=process.arch){let e=I("yt-dlp");return e!==void 0&&$(e,t,r)!==void 0?S("yt-dlp"):m(`YouTube links on ${k(t)} need yt-dlp on your PATH.`,void 0,{hint:"Install yt-dlp (https://github.com/yt-dlp/yt-dlp) and put it on your PATH.",shellHint:"Install yt-dlp and put it on your PATH."})}async function ft(t,r={}){let e=await P();if(e===void 0)throw J();let n=await C(A(U(),"forge-yt-"));r.onDir?.(n);let s=()=>K(n,{recursive:!0,force:!0});try{let o;try{o=await F(e.entry,t,n,r)}catch(p){if(!(p instanceof g))throw p;if(e.own)throw m(`yt-dlp could not fetch this video: ${p.message}`,p);await X(e.entry,r.signal);try{o=await F(e.entry,t,n,r)}catch(c){throw c instanceof g?m(`yt-dlp could not fetch this video: ${c.message}`,c):c}}return{...o,dispose:s}}catch(o){throw await s(),o}}function F(t,r,e,n){let{signal:s}=n;if(s?.aborted)return Promise.reject(s.reason??new Error("aborted"));let o=["--js-runtimes",`node:${process.execPath}`,"--no-playlist","--no-warnings","--newline","--progress","-f","bestaudio[ext=m4a]/bestaudio","--print","before_dl:forge-facts %(.{title,uploader,duration,is_live})j","--progress-template","download:forge-bytes %(progress.downloaded_bytes)s %(progress.total_bytes,progress.total_bytes_estimate)s","--print","after_move:forge-file %(filepath)s","--no-simulate","-o",A(e,"sound.%(ext)s"),r];return new Promise((p,c)=>{let a=_(t,o,{stdio:["ignore","pipe","pipe"]}),d,l,b="",h=!1,y=i=>{h||(h=!0,s?.removeEventListener("abort",v),i())},v=()=>{a.kill("SIGKILL"),y(()=>c(s?.reason??new Error("aborted")))};s?.addEventListener("abort",v,{once:!0}),G({input:a.stdout}).on("line",i=>{if(i.startsWith("forge-facts ")){let u=JSON.parse(i.slice(12));if(u.is_live===!0){a.kill("SIGKILL"),y(()=>c(m("Live streams cannot be transcribed.")));return}d={title:String(u.title??""),uploader:String(u.uploader??""),seconds:Number(u.duration??0)},n.onEvent?.({kind:"facts",facts:d})}else if(i.startsWith("forge-bytes ")){let[u,f]=i.slice(12).split(" ").map(Number);Number.isFinite(u)&&Number.isFinite(f)&&(f??0)>0&&n.onEvent?.({kind:"bytes",done:u,total:f})}else i.startsWith("forge-file ")&&(l=i.slice(11))}),a.stderr.on("data",i=>{b+=i.toString()}),a.on("error",i=>y(()=>c(new g(i.message)))),a.on("close",i=>y(()=>{if(i===0&&d!==void 0&&l!==void 0)return p({path:l,facts:d});let u=b.match(/ERROR: (?:\[[^\]]*\] )?(?:[\w-]+: )?(.*)/)?.[1]?.trim()??"",f=z.find(([O])=>O.test(u));c(f?m(f[1]):new g(u||`yt-dlp exited ${i}`))}))})}function X(t,r){return new Promise((e,n)=>{let s=_(t,["--update"],{stdio:"ignore"}),o=()=>s.kill("SIGKILL");r?.addEventListener("abort",o,{once:!0}),s.on("error",()=>e()),s.on("close",()=>{r?.removeEventListener("abort",o),r?.aborted?n(r.reason??new Error("aborted")):e()})})}export{Z as a,N as b,Q as c,tt as d,nt as e,J as f,ft as g};
|
|
@@ -2,5 +2,5 @@ import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
3
|
import{a as l,c}from"./chunk-MF3KKEFB.js";import{e as p,f as u}from"./chunk-I25E2XDH.js";import{execFile as P}from"node:child_process";import{access as N,constants as A,mkdir as I,readFile as E,realpath as _,writeFile as F}from"node:fs/promises";import{homedir as B}from"node:os";import{dirname as C,join as f,posix as R,sep as m,win32 as S}from"node:path";import{promisify as T}from"node:util";var w=T(P),H=["yt-dlp","video"],X=e=>H.includes(e),a={"yt-dlp":{binary:"yt-dlp",name:"yt-dlp",formula:"yt-dlp",versionArgs:["--version"],version:e=>e.trim().split(`
|
|
4
4
|
`)[0]?.match(/^\d+(\.\d+)+$/)?.[0]},video:{binary:"ffmpeg",name:"ffmpeg",formula:"ffmpeg",versionArgs:["-hide_banner","-version"],version:e=>e.match(/ffmpeg version (\S+)/)?.[1],beside:["ffprobe"]}},Y=e=>a[e].name,q=e=>a[e].formula;function $(e,n){let r=e.split(".").map(Number),i=n.split(".").map(Number);for(let t=0;t<Math.max(r.length,i.length);t++){let o=r[t]??0,s=i[t]??0;if(Number.isNaN(o)||Number.isNaN(s))return e>n;if(o!==s)return o>s}return!1}function g(e){let n=p(e);return n&&(u(n)?.version??u(n,"darwin","universal")?.version)}function y({platform:e=process.platform,env:n=process.env,deep:r=!1}={}){let t=(n.PATH??n.Path??"").split(e==="win32"?";":":").filter(Boolean);if(e==="darwin"&&t.push("/opt/homebrew/bin","/usr/local/bin"),r){let o=n.HOME??B(),{join:s}=e==="win32"?S:R;t.push(s(o,".local","bin"),s(o,"bin"),"/opt/local/bin","/usr/bin")}return[...new Set(t)]}var O=(e,n=process.platform)=>n==="win32"?`${e}.exe`:e;async function d(e){try{return await N(e,A.X_OK),!0}catch{return!1}}async function b(e,n){let r=a[e];if(await d(n)){for(let i of r.beside??[])if(!await d(f(C(n),O(i))))return;try{let{stdout:i}=await w(n,r.versionArgs,{timeout:5e3}),t=r.version(i);if(t===void 0)return;let o=await _(n).catch(()=>n),s=g(e);return{id:e,path:n,version:t,homebrew:o.includes(`${m}Cellar${m}`),tooOld:e==="yt-dlp"&&s!==void 0&&$(s,t)}}catch{return}}}var h=()=>f(l(),"own.json");async function v(){try{let e=JSON.parse(await E(h(),"utf8"));return typeof e=="object"&&e!==null?e:{}}catch{return{}}}async function j(e){let n=(await v())[e];return typeof n=="string"&&n!==""?n:void 0}async function z(e,n){let r=await v();n===void 0?delete r[e]:r[e]=n,await I(l(),{recursive:!0}),await F(h(),`${JSON.stringify(r,null,2)}
|
|
5
|
-
`)}async function J(e,n={}){let r=await j(e);if(r!==void 0){let o=await b(e,r);if(o)return o}let t=process.env.FORGE_NO_OWN_TOOLS==="1"&&n.dirs===void 0?[]:n.dirs??y({deep:n.deep??!1});for(let o of t){let s=await b(e,f(o,O(a[e].binary)));if(s)return s}}async function k(e){if(await c(e)===void 0)return 0;try{let{removeExtension:n,extensionBytes:r}=await import("./manager-
|
|
5
|
+
`)}async function J(e,n={}){let r=await j(e);if(r!==void 0){let o=await b(e,r);if(o)return o}let t=process.env.FORGE_NO_OWN_TOOLS==="1"&&n.dirs===void 0?[]:n.dirs??y({deep:n.deep??!1});for(let o of t){let s=await b(e,f(o,O(a[e].binary)));if(s)return s}}async function k(e){if(await c(e)===void 0)return 0;try{let{removeExtension:n,extensionBytes:r}=await import("./manager-XPO4ZIRY.js"),i=await r(e);return await n(e)?i:0}catch{return 0}}async function Q(e={}){let n=await J("yt-dlp",e);if(n&&!n.tooOld)return await k("yt-dlp"),{entry:n.path,own:!0};let r=await c("yt-dlp");return r?{entry:r.entry,own:!1}:void 0}async function x(e){if(e.brew!==void 0)return await d(e.brew)?e.brew:void 0;for(let n of y({env:{PATH:process.env.PATH??""}})){let r=f(n,"brew");if(await d(r))return r}}async function V(e,n={}){if(e.tooOld)return g(e.id);if(!e.homebrew)return;let r=await x(n);if(r!==void 0)try{let{stdout:i}=await w(r,["outdated","--json=v2","--formula",a[e.id].formula],{timeout:15e3,env:{...process.env,HOMEBREW_NO_AUTO_UPDATE:"1"}}),t=JSON.parse(i);if(!Array.isArray(t.formulae))return;let o=t.formulae[0]?.current_version;return typeof o=="string"?o:null}catch{return}}var Z=e=>e.homebrew?"Homebrew":e.id==="yt-dlp"?"yt-dlp":void 0;async function ee(e,n={}){let r,i;if(e.homebrew){let t=await x(n);if(t===void 0)throw new Error("Homebrew was not found");r=t,i=["upgrade",a[e.id].formula]}else if(e.id==="yt-dlp")r=e.path,i=["--update"];else throw new Error(`${a[e.id].name} cannot update itself`);try{await w(r,i,{timeout:10*6e4,maxBuffer:8<<20,...n.signal?{signal:n.signal}:{}})}catch(t){if(n.signal?.aborted)throw n.signal.reason??t;let o=t,s=(o.stderr??"").trim().split(`
|
|
6
6
|
`).filter(Boolean).at(-1)?.replace(/^Error:\s*/,"");throw new Error(s||o.message||"the update failed")}}export{H as a,X as b,Y as c,q as d,$ as e,y as f,b as g,j as h,z as i,J as j,k,Q as l,V as m,Z as n,ee as o};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{c as d}from"./chunk-VLVNA4T3.js";import{posix as p,win32 as m}from"node:path";var c=2e4,y=o=>o>=c;function $(o,i){return{made:o.map(e=>({from:e.job.sources.map(a=>a.path),to:e.job.outputs})),failed:i.map(e=>({path:e.path,message:e.error.message}))}}function g(o,i){let e=i==="win32"?m:p,[a,...f]=o.map(r=>e.dirname(e.normalize(r)).split(e.sep)),n=a??[];for(let r of f){let s=0;for(;s<n.length&&n[s]===r[s];)s++;n=n.slice(0,s)}return n.join(e.sep)||e.sep}function x(o,i,e=process.platform){let a=t=>d(t,e),f=t=>t.length===1?a(t[0]):`${t.length} files`,n=i.made.length+i.failed.length;if(n===0)return;let[r]=i.failed,s=r&&(r.path?`${a(r.path)}: `:"")+r.message;if(n===1){let[t]=i.made;return t?{title:`${o} finished`,body:`${f(t.from)} \u2192 ${f(t.to)}`}:{title:`${o} failed`,body:s??""}}let l=`${o} finished ${i.made.length} of ${n} files`;return s!==void 0?{title:l,body:s}:{title:l,body:`Saved to ${a(g(i.made.flatMap(t=>t.to),e))}`}}export{y as a,$ as b,x as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{N as a,O as u,P as l}from"./chunk-CVNYUROW.js";import{spawn as x}from"node:child_process";import{existsSync as c,realpathSync as b}from"node:fs";import{dirname as h,join as E,win32 as d}from"node:path";function f(n,t=process.platform,e=c){if(n===void 0)return!1;if(t==="win32"){let r=/^(.*)[\\/]node_modules[\\/]forge-terminal[\\/]/.exec(n)?.[1];return r!==void 0&&e(d.join(r,"forge.cmd"))}return/\/lib\/node_modules\/forge-terminal\//.test(n)&&!n.includes("/_npx/")}function m(n){if(n!==void 0)try{return b(n)}catch{return n}}function P(n,t=c){let e=E(h(n),"npm");return t(e)?e:"npm"}function R(n,t=c){let e=d.join(d.dirname(n),"node_modules","npm","bin","npm-cli.js");return t(e)?e:void 0}var g=(n,t,e)=>new Promise(r=>{let o="",s=x(n,t,{stdio:["ignore","pipe","pipe"],...e?{signal:e}:{}});s.stdout.setEncoding("utf8").on("data",i=>{o+=i}),s.stderr.setEncoding("utf8").on("data",i=>{o+=i}),s.on("error",i=>r({code:null,output:`${o}
|
|
4
4
|
${i.message}`})),s.on("close",i=>r({code:i,output:o}))});function w(n){return n.split(`
|
|
5
5
|
`).map(e=>e.replace(/^npm (error|ERR!)\s*/,"").trim()).filter(e=>e!==""&&!/^(code|errno|syscall|path|dest|A complete log)/.test(e)).at(-1)??"npm exited without saying why"}async function _(n,t={}){let e=t.platform??process.platform;if(e==="win32")return S(n,t);let r=t.script??m(process.argv[1]);if(!f(r,e))throw a(n);let o=t.npm??P(process.execPath),s=t.run??g,{code:i,output:p}=await s(o,["install","--global",`forge-terminal@${n}`],t.signal);if(i!==0)throw/EACCES|EPERM|permission denied/i.test(p)?u(n,e):l(n,w(p))}async function S(n,t){let e=t.script??m(process.argv[1]);if(!f(e,"win32",t.exists))throw a(n);let r=R(process.execPath,t.exists);if(r===void 0)throw l(n,"npm was not found beside Node");let o=t.run??g,{code:s,output:i}=await o(process.execPath,[r,"install","--global",`forge-terminal@${n}`],t.signal);if(s!==0)throw/EACCES|EPERM|EBUSY|permission denied/i.test(i)?u(n,"win32"):l(n,w(i))}export{f as a,m as b,P as c,R as d,w as e,_ as f};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{l as S,m as U}from"./chunk-CVNYUROW.js";import{b as P}from"./chunk-KXKQDFHX.js";import{readFile as ve,stat as Ne}from"node:fs/promises";import{execFile as ie}from"node:child_process";import{randomBytes as oe}from"node:crypto";import{mkdtemp as ae,open as H,readFile as se,rm as D}from"node:fs/promises";import{tmpdir as J}from"node:os";import{join as B}from"node:path";import{promisify as ce}from"node:util";var v=ce(ie),z=async()=>({...await import("./paths-6OENILJ4.js"),...await import("./run-WSETTQXP.js")}),E,N=e=>e!=="darwin";async function _(e=process.platform){return N(e)?await(await z()).installed("heic")!==void 0:k()}async function k(){if(E!==void 0)return E;try{await v("/usr/bin/sips",["--help"],{timeout:5e3}),E=!0}catch{E=!1}return E}async function O(e,n=process.platform){if(N(n))return fe(e,n);let t=B(J(),`forge-heic-${oe(8).toString("hex")}.png`),i=async()=>{await D(t,{force:!0}).catch(()=>{})};try{return await v("/usr/bin/sips",["-s","format","png",e,"--out",t],{timeout:12e4}),{path:t,cleanup:i}}catch(r){throw await i(),r}}async function L(e,n){let{installed:t,runExtension:i}=await z(),r=await t("heic");if(r===void 0)throw S(e,n);return{ext:r,runExtension:i}}async function fe(e,n){let t=await ae(B(J(),"forge-heic-")),i=async()=>{await D(t,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:r,runExtension:o}=await L(e,n),a=B(t,"decoded.rgba"),f=B(t,"decoded.png"),{width:m,height:y}=await o(r,["--in",e,"--out",a],{subject:e});return await(await P())(await se(a),{raw:{width:m,height:y,channels:4}}).png().toFile(f),await D(a,{force:!0}),{path:f,cleanup:i}}catch(r){throw await i(),r}}var ue=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),de=new Set(["avif","avis"]);async function $e(e){let n;try{n=await H(e,"r")}catch{return!1}try{let t=Buffer.alloc(64),{bytesRead:i}=await n.read(t,0,64,0);if(i<12||t.toString("latin1",4,8)!=="ftyp")return!1;let r=Math.min(t.readUInt32BE(0),i),o=[];for(let a=8;a+4<=r;a+=4)o.push(t.toString("latin1",a,a+4));return o.some(a=>de.has(a))?!1:o.some(a=>ue.has(a))}catch{return!1}finally{await n.close().catch(()=>{})}}async function qe(e,n=process.platform){if(N(n)){let{ext:a,runExtension:f}=await L(e,n),m=await f(a,["--info","--in",e],{subject:e});return{width:m.width,height:m.height,hasAlpha:m.hasAlpha??!0}}let{stdout:t}=await v("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",e],{timeout:3e4}),i=Number(/pixelWidth:\s*(\d+)/.exec(t)?.[1]??0),r=Number(/pixelHeight:\s*(\d+)/.exec(t)?.[1]??0),o=await me(e);return{width:o?r:i,height:o?i:r,hasAlpha:/hasAlpha:\s*yes/i.test(t)}}function*x(e,n,t){let i=n;for(;i+8<=t;){let r=e.readUInt32BE(i),o=8;if(r===1&&i+16<=t?(r=Number(e.readBigUInt64BE(i+8)),o=16):r===0&&(r=t-i),r<o)return;yield{type:e.toString("latin1",i+4,i+8),start:i+o,end:Math.min(i+r,t)},i+=r}}async function me(e){let n=await H(e,"r");try{let t=Buffer.alloc(262144),{bytesRead:i}=await n.read(t,0,t.length,0),r=[...x(t,0,i)].find(l=>l.type==="meta");if(!r)return!1;let o=[...x(t,r.start+4,r.end)],a=o.find(l=>l.type==="pitm"),f=o.find(l=>l.type==="iprp");if(!a||!f)return!1;let m=t.readUInt8(a.start)===0?t.readUInt16BE(a.start+4):t.readUInt32BE(a.start+4),y=[...x(t,f.start,f.end)],s=y.find(l=>l.type==="ipco"),c=y.find(l=>l.type==="ipma");if(!s||!c)return!1;let u=new Map;if([...x(t,s.start,s.end)].forEach((l,b)=>{l.type==="irot"&&u.set(b+1,t.readUInt8(l.start)&3)}),u.size===0)return!1;let h=t.readUInt8(c.start),w=(t.readUInt8(c.start+3)&1)===1,d=c.start+4,p=t.readUInt32BE(d);d+=4;for(let l=0;l<p&&d<c.end;l++){let b=h<1?t.readUInt16BE(d):t.readUInt32BE(d);d+=h<1?2:4;let ne=t.readUInt8(d);d+=1;for(let C=0;C<ne;C++){let re=w?t.readUInt16BE(d)&32767:t.readUInt8(d)&127;if(d+=w?2:1,b===m&&(u.get(re)??0)%2===1)return!0}}return!1}catch{return!1}finally{await n.close().catch(()=>{})}}import{execFile as le}from"node:child_process";import{randomBytes as he}from"node:crypto";import{copyFile as we,mkdtemp as W,open as pe,readFile as ye,rm as R}from"node:fs/promises";import{tmpdir as A}from"node:os";import{extname as K,join as I}from"node:path";import{promisify as ge}from"node:util";var $=ge(le),q=async()=>({...await import("./paths-6OENILJ4.js"),...await import("./run-WSETTQXP.js")}),F=e=>e!=="darwin",xe={".nef":[".nef",".nrw"],".arw":[".arw",".srf",".sr2"],".rw2":[".rw2",".rwl"],".3fr":[".3fr",".fff"],".dcr":[".dcr",".kdc"]},be=[["nikon",".nef"],["sony",".arw"],["pentax",".pef"],["ricoh",".pef"],["samsung",".srw"],["hasselblad",".3fr"],["seiko epson",".erf"],["epson",".erf"],["kodak",".dcr"],["eastman kodak",".dcr"],["leaf",".mos"]],Ie=new Set([32803,34892]),Ee=new Set([32767,32769,32770,34316,34713,65e3,65535]),Se="85c0b687820f11e08111f4ce462b6a48";function j(e,n){let t=(s,c)=>n?s.readUInt16LE(c):s.readUInt16BE(c),i=(s,c)=>n?s.readUInt32LE(c):s.readUInt32BE(c),r={1:1,2:1,3:2,4:4,7:1,13:4};async function o(s){if(s<=0)return;let c=await e(s,2);if(c.length<2)return;let u=t(c,0);if(u===0||u>1e3)return;let h=await e(s+2,u*12+4);if(h.length<u*12+4)return;let w=new Map;for(let d=0;d<u;d++){let p=d*12;w.set(t(h,p),{type:t(h,p+2),count:i(h,p+4),inline:h.subarray(p+8,p+12),offset:i(h,p+8)})}return{entries:w,next:i(h,u*12)}}async function a(s,c=16){if(!s)return[];let u=r[s.type]===2?2:4,h=Math.min(s.count,c),w=h*u<=4?s.inline:await e(s.offset,h*u),d=[];for(let p=0;p<h&&(p+1)*u<=w.length;p++)d.push(u===2?t(w,p*u):i(w,p*u));return d}async function f(s){if(s?.type!==2)return"";let c=Math.min(s.count,64);return(c<=4?s.inline.subarray(0,c):await e(s.offset,c)).toString("latin1").replace(/\0.*$/s,"").trim()}async function m(s){let[c]=await a(s.entries.get(274),1);return c!==void 0&&c>=1&&c<=8?c:1}async function y(s){let c=[s],u=new Set;for(let h=0;c.length>0&&h<12;h++){let w=c.shift(),[d]=await a(w.entries.get(262),1),[p]=await a(w.entries.get(259),1);if(d!==void 0&&Ie.has(d)||p!==void 0&&Ee.has(p))return!0;for(let l of[...await a(w.entries.get(330),8),w.next]){if(l===0||u.has(l))continue;u.add(l);let b=await o(l);b&&c.push(b)}}return!1}return{directory:o,text:f,orientation:m,hasMosaic:y,u32:i}}function V(e){let n=e.toString("latin1",0,2);return n==="II"?!0:n==="MM"?!1:void 0}async function Y(e,n){let t=V(e.subarray(n,n+2));if(t===void 0)return 1;let r=j(async(a,f)=>e.subarray(n+a,n+a+f),t),o=await r.directory(r.u32(e,n+4));return o?r.orientation(o):1}async function Pe(e){if(e[0]!==255||e[1]!==216)return 1;let n=2;for(;n+4<=e.length&&e[n]===255;){let t=e[n+1],i=e.readUInt16BE(n+2);if(t===225&&e.toString("latin1",n+4,n+10)==="Exif\0\0")return Y(e,n+10);if(t===218)break;n+=2+i}return 1}async function Be(e,n){let t=await e(0,Math.min(n,1048576)),i=[...x(t,0,t.length)].find(r=>r.type==="moov");if(!i)return 1;for(let r of x(t,i.start,i.end)){if(r.type!=="uuid"||t.toString("hex",r.start,r.start+16)!==Se)continue;let o=[...x(t,r.start+16,r.end)].find(a=>a.type==="CMT1");return o?Y(t,o.start):1}return 1}async function Re(e,n){if(n.length<92)return 1;let t=n.readUInt32BE(84),i=n.readUInt32BE(88);return t===0||i===0?1:Pe(await e(t,Math.min(i,65536)))}async function Me(e){let n;try{n=await pe(e,"r")}catch{return}try{let{size:t}=await n.stat(),i=async(u,h)=>{let w=Math.max(0,Math.min(h,t-u)),d=Buffer.alloc(w);return w>0&&await n.read(d,0,w,u),d},r=await i(0,96);if(r.length<16)return;let o=r.toString("latin1",0,4);if(r.toString("latin1",0,15)==="FUJIFILMCCD-RAW")return{ext:".raf",orientation:await Re(i,r)};if(r.toString("latin1",4,12)==="ftypcrx ")return{ext:".cr3",orientation:await Be(i,t)};let a=V(r);if(a===void 0)return;let f=j(i,a),m=await f.directory(f.u32(r,4));if(!m)return;let y=await f.orientation(m);if(o==="IIRO"||o==="IIRS"||o==="MMOR")return{ext:".orf",orientation:y};if(o==="IIU\0")return{ext:".rw2",orientation:y};if(o!=="II*\0"&&o!=="MM\0*")return;if(m.entries.has(50706))return{ext:".dng",orientation:y};if(r.toString("latin1",8,11)==="CR")return{ext:".cr2",orientation:y};let s=(await f.text(m.entries.get(271))).toLowerCase(),c=be.find(([u])=>s.startsWith(u));return!c||!await f.hasMosaic(m)?void 0:{ext:c[1],orientation:y}}catch{return}finally{await n.close().catch(()=>{})}}async function Ue(e=process.platform){return F(e)?await(await q()).installed("raw")!==void 0:k()}async function Z(e,n){let{installed:t,runExtension:i}=await q(),r=await t("raw");if(r===void 0)throw U(e,n);return{ext:r,runExtension:i}}async function G(e,n,t){let i=K(e).toLowerCase();if((xe[n.ext]??[n.ext]).includes(i))return t(e);let r=await W(I(A(),"forge-raw-"));try{let o=I(r,`photo${n.ext}`);return await we(e,o),await t(o)}finally{await R(r,{recursive:!0,force:!0}).catch(()=>{})}}async function rt(e,n,t=process.platform){if(F(t)){let{ext:a,runExtension:f}=await Z(e,t),m=await f(a,["--info","--in",e],{subject:e,platform:t});if(!(m.width>0&&m.height>0))throw new Error("the raw extension reported no size");return{width:m.width,height:m.height}}let{stdout:i}=await G(e,n,a=>$("/usr/bin/sips",["-g","typeIdentifier","-g","pixelWidth","-g","pixelHeight",a],{timeout:3e4}));if(!/typeIdentifier:\s*\S*raw-image/.test(i))return;let r=Number(/pixelWidth:\s*(\d+)/.exec(i)?.[1]??0),o=Number(/pixelHeight:\s*(\d+)/.exec(i)?.[1]??0);if(!(r===0||o===0))return n.orientation>=5?{width:o,height:r}:{width:r,height:o}}async function Q(e,n=process.platform){if(F(n))return De(e,n);if(!await Ue(n))throw U(e,n);let t=await Me(e)??{ext:K(e).toLowerCase(),orientation:1},i=I(A(),`forge-raw-${he(8).toString("hex")}.png`),r=async()=>{await R(i,{force:!0}).catch(()=>{})};try{return await G(e,t,o=>$("/usr/bin/sips",["-s","format","png",o,"--out",i],{timeout:3e5})),{path:i,cleanup:r}}catch(o){throw await r(),o}}async function De(e,n){let t=await W(I(A(),"forge-raw-")),i=async()=>{await R(t,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:r,runExtension:o}=await Z(e,n),a=I(t,"decoded.rgb"),f=I(t,"decoded.png"),{width:m,height:y}=await o(r,["--in",e,"--out",a],{subject:e,platform:n});return await(await P())(await ye(a),{raw:{width:m,height:y,channels:3}}).png().toFile(f),await R(a,{force:!0}),{path:f,cleanup:i}}catch(r){throw await i(),r}}async function ft(e,n){return n!=="heic"&&n!=="raw"?e:Fe(e,n)}var ke=4,X=256*1024*1024,T=X,ee=6e4,te=ee,M;function Ae(){clearTimeout(M),M=setTimeout(()=>g.clear(),te),M.unref?.()}var g=new Map;async function Fe(e,n){let{size:t,mtimeMs:i}=await Ne(e);Ae();let r=`${n}\0${e}`,o=g.get(r);if(g.delete(r),o&&o.size===t&&o.mtimeMs===i)return g.set(r,o),o.png;let a={size:t,mtimeMs:i,png:Ce(e,n),bytes:0};return g.set(r,a),a.png.then(f=>{a.bytes=f.length,f.length>T&&g.get(r)===a&&g.delete(r),Te()},()=>{g.get(r)===a&&g.delete(r)}),a.png}function Te(){let e=0;for(let n of g.values())e+=n.bytes;for(let[n,t]of g){if(g.size<=ke&&e<=T)break;g.delete(n),e-=t.bytes}}async function Ce(e,n){if(n==="heic"&&!await _())throw S(e);let t=n==="heic"?await O(e):await Q(e);try{return await ve(t.path)}finally{await t.cleanup()}}function ut(){g.clear(),clearTimeout(M)}function dt(e){te=e??ee}function mt(e){T=e??X}export{_ as a,$e as b,qe as c,Me as d,Ue as e,rt as f,ft as g,ut as h,dt as i,mt as j};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as o}from"./chunk-
|
|
3
|
+
import{a as o}from"./chunk-5IZBFF6Y.js";import{f as n}from"./chunk-EPDF4NQI.js";import{E as i}from"./chunk-CVNYUROW.js";import{a as r}from"./chunk-H3DIRJFE.js";var I=5,h=200,x=5;function z(t){return t.format==="heic"||t.format==="raw"?"jpeg":o(t).includes(t.format)?t.format:"png"}function E(t,m){let e=n.find(f=>f.id==="image")?.writes;if(!e?.has(t))return i(`Cannot ${m} into ${r[t].label}; only an image format can take the edit.`,`Choose one of: ${[...e??[]].join(", ")}.`)}var c=t=>`${t.width}x${t.height}`,u=t=>"percent"in t?`${t.percent}pct`:"width"in t?`${t.width}w`:`${t.height}h`;export{I as a,h as b,x as c,z as d,E as e,c as f,u as g};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
var v="0.5.
|
|
3
|
+
var v="0.5.3",x={ok:"\u2713",fail:"\u2715",warn:"\u26A0",cursor:"\u276F",strip:"\u258C",star:"\u2605",arrow:"\u2192",tip:"\u2727",longArrow:"\u2500\u2500\u2192",longArrowDown:`\u2502
|
|
4
4
|
\u25BC`,dotFilled:"\u25CF",dotEmpty:"\u25CB"},f={name:"dark",fg:"#e7e7e7",dim:"#b0b0b0",accent:"#e5a23c",ok:"#6fcf7f",warn:"#e5c07b",fail:"#e8796d",failTint:"#2e2020",failTintDim:"#b0b0b0",larger:"#f2994a",shedHatch:"#47774f",grownFill:"#403225",tag:"#63c1d8",label:"#a68ce0",modeConvert:"#55c7d9",modeConvertBg:"#122c33",modeCompress:"#79c98b",modeCompressBg:"#182c1e",modePdf:"#ff6b4a",modePdfBg:"#361c16",modeColour:"#f27ba8",modeColourBg:"#3a1e2b",modeEdit:"#b39ae8",modeEditBg:"#2a2238",modeTranscribe:"#e63946",modeTranscribeBg:"#3a1a1d",border:"#808080",selectionBg:"#2c2c2c",band:"#2c2c2c",canvas:"#1e1e1e",textSelectionBg:"#3f5c86",brand:"#e5a23c",keycapBg:"#333333",violet:"#a68ce0",faint:"#4d4d4d",listBand:"#323232",shelf:"#242424",tabChip:"#262626",panelBand:"#404040",ink:"#0c1d22",track:"#2e2e2e",trackFill:"#515151",thumb:"#e7e7e7",folderChip:"#414141",pill:"#e7e7e7",fieldBand:"#3d3d3d",defaultTagBg:"#33261a",defaultTag:"#c98a4b",newTagBg:"#2a3448",newTag:"#4f77c5"},o={name:"light",fg:"#262626",dim:"#4f4f4f",accent:"#915a01",ok:"#0e702c",warn:"#8a6100",fail:"#a43c32",failTint:"#f9e3df",failTintDim:"#4a4a4a",larger:"#8b4d01",shedHatch:"#87b896",grownFill:"#ece3d6",tag:"#0a6b86",label:"#5e4b99",modeConvert:"#036b7b",modeConvertBg:"#e6f7fa",modeCompress:"#24733a",modeCompressBg:"#eaf5ec",modePdf:"#b82a06",modePdfBg:"#fceee9",modeColour:"#b0306a",modeColourBg:"#f7e3ec",modeEdit:"#64569f",modeEditBg:"#f0ebfa",modeTranscribe:"#c0102c",modeTranscribeBg:"#fef0ef",border:"#767676",selectionBg:"#e4e4e4",band:"#e4e4e4",canvas:"#ffffff",textSelectionBg:"#b9cfe8",brand:"#915a01",keycapBg:"#e1e1e1",violet:"#5e4b99",faint:"#b2b2b2",listBand:"#dcdcdc",shelf:"#f3f3f3",tabChip:"#f0f0f0",panelBand:"#d5d5d5",ink:"#ffffff",track:"#e4e4e4",trackFill:"#afafaf",thumb:"#262626",folderChip:"#d0d0d0",pill:"#262626",fieldBand:"#d7d7d7",defaultTagBg:"#f5e2cc",defaultTag:"#8f5000",newTagBg:"#e1e7f4",newTag:"#3358a3"},i={name:"neutral",fg:"",dim:"gray",accent:"yellow",ok:"green",warn:"yellow",fail:"red",failTint:"",failTintDim:"gray",larger:"yellow",shedHatch:"green",grownFill:"",tag:"cyan",label:"magenta",modeConvert:"cyan",modeConvertBg:"",modeCompress:"green",modeCompressBg:"",modePdf:"red",modePdfBg:"",modeColour:"magenta",modeColourBg:"",modeEdit:"magenta",modeEditBg:"",modeTranscribe:"redBright",modeTranscribeBg:"",border:"gray",selectionBg:"",band:"",canvas:"",textSelectionBg:"",brand:"yellow",keycapBg:"",violet:"magenta",faint:"gray",listBand:"",shelf:"",tabChip:"",panelBand:"",ink:"",track:"",trackFill:"",thumb:"",folderChip:"",pill:"",fieldBand:"",defaultTagBg:"",defaultTag:"",newTagBg:"",newTag:""},d=["convert","compress","pdf","edit","transcribe","colour"],k=`1\u2013${d.length}`;function E(e,t){let r=d,n=e==="menu"?r.length:r.indexOf(e),a=Math.max(0,Math.min(r.length-1,n+t));return r[a]}function P(e){return/^[1-9]$/.test(e)?d[Number(e)-1]:void 0}var S={convert:"\u2194",compress:"\u2193",pdf:"\u25A3",colour:"\u25D0",edit:"\u2726",transcribe:"\xB6"},c="#7d6ad0",l="#cc8ae2";function s(e,t){return t==="compress"?{fg:e.modeCompress,bg:e.modeCompressBg}:t==="pdf"?{fg:e.modePdf,bg:e.modePdfBg}:t==="colour"?{fg:e.modeColour,bg:e.modeColourBg}:t==="edit"?{fg:e.modeEdit,bg:e.modeEditBg}:t==="transcribe"?{fg:e.modeTranscribe,bg:e.modeTranscribeBg}:{fg:e.modeConvert,bg:e.modeConvertBg}}var g=["#f26e69","#e5a23c","#ace02c","#55c7d9","#6579fd","#ad95e9"],b=["#e5a23c","#f2cf6b"],m={convert:["#1e96a7","#1e94b3","#1e92c0","#1d8ed2","#1b86ef","#4a7df8","#6974f8","#816af8","#995cf8"],compress:["#24b459","#22ab6d","#21a479","#209f81","#1f9c89","#1f9a91","#1e9998","#1e97a0","#1e96a7"],pdf:["#eb4319","#e3541a","#de601b","#db6a1c","#d9731d","#d87c1e","#d8841f","#d98c20","#d99522"],edit:["#9b5af8","#985cf8","#965ef8","#945ff8","#9161f8","#8f62f8","#8d64f8","#8a65f8","#8867f8"],transcribe:["#f3233e","#f12259","#ee2270","#ea2186","#e6219b","#e121b0","#da22c6","#d122dc","#c723f2"],colour:["#f42335","#e05b1a","#d87d1e","#da9b23","#d2b427","#b4c027","#5bbf23","#20a27c","#1e989b","#1e94b6","#1c8cd9","#577af8","#7371f8","#8568f8","#965df8"]},u=["#d99522","#da9822","#da9b23","#da9f24","#d9a224","#d9a525","#d8a825","#d7ab26","#d6ad26"],B={convert:["#d6f7fd","#ddf5fe","#e1f4fe","#e4f2fe","#e7f1fe","#eaf0fe","#eceffe","#efeefe","#f1edfe"],compress:["#e0f7e4","#def8e7","#dcf8ea","#daf8ed","#d8f8f1","#d7f8f4","#d6f8f7","#d6f8fa","#d6f7fd"],pdf:["#feece7","#feece6","#feece5","#feece3","#feece2","#feede0","#feedde","#feeddc","#feeed9"],edit:["#f2edfe","#f1edfe","#f1edfe","#f1eefe","#f0eefe","#f0eefe","#f0eefe","#f0eefe","#efeefe"],transcribe:["#feebea","#feebec","#feebee","#feeaf0","#feeaf2","#feeaf5","#fee9f9","#fde9fd","#f9eafe"],colour:["#feebe9","#feece5","#feede0","#feeed7","#f7f1d6","#eff3d9","#e5f6df","#dbf8eb","#d6f8f8","#def5fe","#e5f2fe","#ebf0fe","#edeffe","#efeefe","#f1edfe"]},p=["#feeed9","#feeed8","#feeed7","#fdeed6","#fcefd6","#fbefd6","#fbefd6","#faefd6","#f9f0d6"],T={convert:["#138291","#8467bd"],compress:["#2b8748","#138291"],pdf:["#d54322","#a06c10"],edit:["#8567bc","#7b67cd"],transcribe:["#df3140","#9c5cb1"],colour:["#cb4b49","#a06c10","#618110","#138291","#5869ec","#8268bd"]};function C(e,t){return e.name==="light"?t==="menu"?u:m[t]:t==="menu"?e.name==="dark"?b:[e.brand]:t==="compress"?[e.modeCompress,e.modeConvert]:t==="pdf"?[e.modePdf,e.brand]:t==="colour"?e.name==="dark"?g:[e.modeColour,e.violet]:t==="edit"?[e.modeEdit,e.name==="dark"?c:e.violet]:t==="transcribe"?[e.modeTranscribe,e.name==="dark"?l:e.violet]:[e.modeConvert,e.violet]}function y(e,t){if(e.name==="light")return t==="menu"?p:B[t]}function w(e,t){return e.name==="light"?T[t]:C(e,t)}function M(e){return{...e,accent:e.brand,tag:e.brand,label:e.brand}}function R(e,t){let{fg:r,bg:n}=s(e,t);return{...e,accent:r,tag:r,label:r,band:n===""?e.band:n}}function H(e){return e.canvas!==""}function O(e){return e==="dark"?f:e==="light"?o:i}function D(e){return e===""?void 0:e}var _={filled:"\u2501",empty:"\u2501",knob:"\u25CF"};function h(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""?!1:process.stdout.isTTY===!0}function F(){h()||(process.env.FORCE_COLOR="0")}export{v as a,x as b,f as c,o as d,i as e,d as f,k as g,E as h,P as i,S as j,s as k,C as l,y as m,w as n,M as o,R as p,H as q,O as r,D as s,_ as t,h as u,F as v};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as M}from"./chunk-U5TEGDGH.js";import{
|
|
3
|
+
import{a as M}from"./chunk-U5TEGDGH.js";import{b as W}from"./chunk-7VR6LODN.js";import{a as X,b as Q}from"./chunk-HZDYZ5RD.js";import{a as K}from"./chunk-AFEYLHDD.js";import{b as J}from"./chunk-EEQSUBBL.js";import{a as D}from"./chunk-HWCXNKIN.js";import{a as Y}from"./chunk-KH5DHZ2U.js";import{a as U}from"./chunk-TFOEI5VF.js";import{m as R}from"./chunk-J6AZTW62.js";import{E as d,H}from"./chunk-CVNYUROW.js";import{d as L}from"./chunk-J7FLFHQJ.js";import{b as z}from"./chunk-H3DIRJFE.js";var x=class extends Error{constructor(e,t,n){super(n),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},v=class extends x{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};var E=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.endsWith("...")&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_collectValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:(t.push(e),t)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,n)=>{if(!this.argChoices.includes(t))throw new v(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._collectValue(t,n):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function N(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}import{EventEmitter as le}from"node:events";import G from"node:child_process";import C from"node:path";import F from"node:fs";import m from"node:process";import{stripVTControlCharacters as he}from"node:util";import{stripVTControlCharacters as se}from"node:util";var T=class{constructor(){this.helpWidth=void 0,this.minWidthToWrap=40,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}prepareContext(e){this.helpWidth=this.helpWidth??e.helpWidth??80}visibleCommands(e){let t=e.commands.filter(i=>!i._hidden),n=e._getHelpCommand();return n&&!n._hidden&&t.push(n),this.sortSubcommands&&t.sort((i,o)=>i.name().localeCompare(o.name())),t}compareOptions(e,t){let n=i=>i.short?i.short.replace(/^-/,""):i.long.replace(/^--/,"");return n(e).localeCompare(n(t))}visibleOptions(e){let t=e.options.filter(i=>!i.hidden),n=e._getHelpOption();if(n&&!n.hidden){let i=n.short&&e._findOption(n.short),o=n.long&&e._findOption(n.long);!i&&!o?t.push(n):n.long&&!o?t.push(e.createOption(n.long,n.description)):n.short&&!i&&t.push(e.createOption(n.short,n.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let n=e.parent;n;n=n.parent){let i=n.options.filter(o=>!o.hidden);t.push(...i)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(n=>N(n)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleSubcommandTerm(t.subcommandTerm(i)))),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleOptionTerm(t.optionTerm(i)))),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((n,i)=>Math.max(n,this.displayWidth(t.styleArgumentTerm(t.argumentTerm(i)))),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let n="";for(let i=e.parent;i;i=i.parent)n=i.name()+" "+n;return n+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(n=>JSON.stringify(n)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let n=`(${t.join(", ")})`;return e.description?`${e.description} ${n}`:n}return e.description}formatItemList(e,t,n){return t.length===0?[]:[n.styleTitle(e),...t,""]}groupItems(e,t,n){let i=new Map;return e.forEach(o=>{let r=n(o);i.has(r)||i.set(r,[])}),t.forEach(o=>{let r=n(o);i.has(r)||i.set(r,[]),i.get(r).push(o)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function o(c,p){return t.formatItem(c,n,p,t)}let r=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],u=t.commandDescription(e);u.length>0&&(r=r.concat([t.boxWrap(t.styleCommandDescription(u),i),""]));let l=t.visibleArguments(e).map(c=>o(t.styleArgumentTerm(t.argumentTerm(c)),t.styleArgumentDescription(t.argumentDescription(c))));if(r=r.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),c=>c.helpGroupHeading??"Options:").forEach((c,p)=>{let O=c.map(_=>o(t.styleOptionTerm(t.optionTerm(_)),t.styleOptionDescription(t.optionDescription(_))));r=r.concat(this.formatItemList(p,O,t))}),t.showGlobalOptions){let c=t.visibleGlobalOptions(e).map(p=>o(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));r=r.concat(this.formatItemList("Global Options:",c,t))}return this.groupItems(e.commands,t.visibleCommands(e),c=>c.helpGroup()||"Commands:").forEach((c,p)=>{let O=c.map(_=>o(t.styleSubcommandTerm(t.subcommandTerm(_)),t.styleSubcommandDescription(t.subcommandDescription(_))));r=r.concat(this.formatItemList(p,O,t))}),r.join(`
|
|
4
4
|
`)}displayWidth(e){return se(e).length}styleTitle(e){return e}styleUsage(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t==="[command]"?this.styleSubcommandText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleCommandText(t)).join(" ")}styleCommandDescription(e){return this.styleDescriptionText(e)}styleOptionDescription(e){return this.styleDescriptionText(e)}styleSubcommandDescription(e){return this.styleDescriptionText(e)}styleArgumentDescription(e){return this.styleDescriptionText(e)}styleDescriptionText(e){return e}styleOptionTerm(e){return this.styleOptionText(e)}styleSubcommandTerm(e){return e.split(" ").map(t=>t==="[options]"?this.styleOptionText(t):t[0]==="["||t[0]==="<"?this.styleArgumentText(t):this.styleSubcommandText(t)).join(" ")}styleArgumentTerm(e){return this.styleArgumentText(e)}styleOptionText(e){return e}styleArgumentText(e){return e}styleSubcommandText(e){return e}styleCommandText(e){return e}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}preformatted(e){return/\n[^\S\r\n]/.test(e)}formatItem(e,t,n,i){let r=" ".repeat(2);if(!n)return r+e;let u=e.padEnd(t+e.length-i.displayWidth(e)),l=2,a=(this.helpWidth??80)-t-l-2,c;return a<this.minWidthToWrap||i.preformatted(n)?c=n:c=i.boxWrap(n,a).replace(/\n/g,`
|
|
5
5
|
`+" ".repeat(t+l)),r+u+" ".repeat(l)+c.replace(/\n/g,`
|
|
6
6
|
${r}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,o=[];return n.forEach(r=>{let u=r.match(i);if(u===null){o.push("");return}let l=[u.shift()],h=this.displayWidth(l[0]);u.forEach(a=>{let c=this.displayWidth(a);if(h+c<=t){l.push(a),h+=c;return}o.push(l.join(""));let p=a.trimStart();l=[p],h=this.displayWidth(p)}),o.push(l.join(""))}),o.join(`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{A as E,B as l,C as S}from"./chunk-CVNYUROW.js";import{c as x}from"./chunk-H3DIRJFE.js";import{existsSync as h,statSync as w}from"node:fs";import{basename as f,dirname as T,extname as g,isAbsolute as _,join as c,relative as M,resolve as i,sep as D}from"node:path";function $(t){return t.endsWith("/")||t.endsWith(D)||h(t)&&w(t).isDirectory()?!0:g(t)===""}var O=255;function P(t,r){return r==="darwin"||r==="win32"?t.length:Buffer.byteLength(t)}function a(t,r,n=process.platform){if(P(t+r,n)<=O)return t+r;let e="";for(let s of t){if(P(e+s+r,n)>O)break;e+=s}return e+r}function nt(t,r){if(i(t)===i(r))return!0;try{let n=w(t),e=w(r);return n.dev===e.dev&&n.ino===e.ino}catch{return!1}}function L(t,r){let n=f(t),e=g(n),s=e?n.slice(0,-e.length):n;return a(s,x(r))}function b(t,r,n){if(!n)return t;let e=M(i(n),r);return!e||e.startsWith("..")?t:c(t,e)}function F(t){let r=i(t.sourcePath),n=L(r,t.target);if(!t.output)return c(i(r,".."),n);let e=_(t.output)?t.output:i(t.output);return $(t.output)?c(b(e,i(r,".."),t.sourceRoot),n):i(e)}function et(t){let r=F(t);if(t.output&&!$(t.output))return r;let n=g(r);return c(i(r,".."),a(f(r,n),`-${t.suffix}${n}`))}function it(t){if(!h(t))return t;let r=i(t,".."),n=f(t),e=g(n),s=e?n.slice(0,-e.length):n;for(let o=1;o<1e4;o++){let u=c(r,a(s,` (${o})${e}`));if(!h(u))return u}throw new Error(`no free name beside ${n}`)}function p(t){let r=i(t,".."),n=f(t),e=g(n);return{dir:r,stem:e?n.slice(0,-e.length):n,ext:e||".pdf"}}function A(t,r){let{dir:n,stem:e,ext:s}=p(i(t));return c(n,a(e,`-${r}${s}`))}function st(t,r){let{dir:n,stem:e,ext:s}=p(i(t)),o=String(r).length;return Array.from({length:r},(u,m)=>c(n,a(e,`-${String(m+1).padStart(o,"0")}${s}`)))}function ot(t,r,n,e,s){let{stem:o}=p(i(t)),u=e?b(i(e),i(t,".."),s):i(t,".."),m=x(n),I=String(Math.max(1,...r.map(d=>d+1))).length,W=r.map(d=>c(u,a(o,`-${String(d+1).padStart(I,"0")}${m}`))),[y,...R]=W;if(y===void 0)throw new Error("rasterOutputPaths requires at least one selected page");return[y,...R]}function ut(t,r,n){if(!n)return[A(t,"extract")];let{dir:e,stem:s,ext:o}=p(i(t));return r.map(u=>c(e,a(s,`-p${u+1}${o}`)))}function ct(t){let r=i(t[0]??"merged.pdf");if(new Set(t.map(e=>i(e,".."))).size===1){let e=i(r,"..");return c(e,a(f(e),"-merged.pdf"))}return A(r,"merged")}function k(t,r,n){let e=r?t.map(o=>c(r,f(o))):t,[s]=e;return!n||e.length!==1||s===void 0?e:[c(T(s),`${n}${g(s)}`)]}function at(t,r,n){return k([t],r,n)[0]??t}import{randomBytes as B}from"node:crypto";import{constants as J}from"node:fs";import{access as j,mkdir as C,rename as N,rm as U,writeFile as Y}from"node:fs/promises";import{basename as z,dirname as v,extname as G,join as K}from"node:path";function H(t,r=B(6).toString("hex")){let n=G(t);return K(v(t),a(`.forge-${r}-${z(t,n)}`,n))}async function Q(t){let r=v(t);try{await C(r,{recursive:!0})}catch(n){let e=l(t,n);throw e===n?S(t,n):e}try{await j(r,J.W_OK)}catch(n){throw E(t,n)}}var V=new Set(["EPERM","EBUSY","EACCES"]),X=5,ht=9;async function Z(t,r,n=process.platform,e=o=>new Promise(u=>setTimeout(u,o)),s=X){if(n!=="win32"){await N(t,r);return}for(let o=1;;o++)try{await N(t,r);return}catch(u){let m=u.code;if(o>=s||!m||!V.has(m))throw u;await e(Math.min(50*2**(o-1),1e3))}}async function wt(t,r){await Q(t);let n=H(t);try{return await Y(n,r),await Z(n,t),r.byteLength}catch(e){throw await U(n,{force:!0}).catch(()=>{}),l(t,e)}}export{$ as a,a as b,nt as c,F as d,et as e,it as f,A as g,st as h,ot as i,ut as j,ct as k,k as l,at as m,H as n,Q as o,ht as p,Z as q,wt as r};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{e as a}from"./chunk-
|
|
3
|
+
import{e as a}from"./chunk-J6AZTW62.js";import{a as t}from"./chunk-H3DIRJFE.js";var p=[{op:"compress",label:"Compress"},{op:"resize",label:"Resize"},{op:"crop",label:"Crop to shape"},{op:"trim",label:"Trim edges"},{op:"format",label:"Convert to another format"},{op:"sharpen",label:"Sharpen"},{op:"boost",label:"Boost resolution"},{op:"cutout",label:"Remove background"}],n=r=>t[r]?.label??r.toUpperCase(),i=r=>`under ${Math.round(r/1e3)} KB`,u=r=>"width"in r?`${r.width} wide`:"height"in r?`${r.height} high`:`${r.percent}%`;function l(r,e){let o={...r};switch(e.op){case"compress":return"quality"in e?(delete o.maxBytes,o.quality=e.quality,o.compress=r.compress??{dither:!1}):o.maxBytes=e.bytes,o;case"resize":return o.resize=e.spec,o;case"crop":return o.crop=e.aspect,o;case"trim":return o.trim=!0,o;case"format":return o.to=e.to,e.quality===void 0?delete o.quality:o.quality=e.quality,o;case"sharpen":return o.sharpen=!0,o;case"boost":return o.boost=e.scale,o;case"cutout":return o.removeBackground=!0,o}}function d(r){switch(r.op){case"compress":return"quality"in r?`quality ${r.quality}`:i(r.bytes);case"resize":return u(r.spec);case"crop":return`${r.aspect.w}:${r.aspect.h}`;case"trim":return"Trim";case"format":return`${n(r.to)}${r.quality===void 0?"":` ${r.quality}`}`;case"sharpen":return"Sharpen";case"boost":return`Boost ${r.scale}\xD7`;case"cutout":return"Remove background"}}function b(r,e){return[...!(e.to===void 0||e.to===r)&&e.to?[`${n(e.to)}${e.quality===void 0?"":` ${e.quality}`}`]:e.quality!==void 0?[`quality ${e.quality}`]:[],...e.resize?[u(e.resize)]:[],...e.trim?["Trim"]:[],...e.crop?[`${e.crop.w}:${e.crop.h}`]:[],...e.sharpen&&!e.boost?["Sharpen"]:[],...e.boost?[`Boost ${e.boost}\xD7`]:[],...e.removeBackground?["Remove background"]:[],...e.maxBytes?[i(e.maxBytes)]:[]]}function h(r,e){if(r.frames>1)return{trim:"animated",crop:"animated"};let o={};return e?.trimmed==="nothing"&&(o.trim="no empty edges"),a(r).length===0&&(o.crop="no shape to cut"),o}export{p as a,l as b,d as c,b as d,h as e};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as s}from"./chunk-J7FLFHQJ.js";import{c as r}from"./chunk-VLVNA4T3.js";import{a}from"./chunk-H3DIRJFE.js";import{dirname as f}from"node:path";var o=class extends Error{code;title;detail;short;hint;shellHint;constructor(t){super(`${t.title}: ${t.detail}`,t.cause===void 0?void 0:{cause:t.cause}),this.name="ForgeError",this.code=t.code,this.title=t.title,this.detail=t.detail,this.short=t.short,this.hint=t.hint,this.shellHint=t.shellHint}};function m(e){return e instanceof o}function v(e){return new o({code:"file-not-found",title:"File not found",detail:`${r(e)} could not be found.`,short:`${r(e)} could not be found.`,hint:"Check the filename and try again."})}function k(e){return new o({code:"not-a-file",title:"Not a file",detail:`${r(e)} is not a file.`,short:`${r(e)} is not a file.`,hint:"Point Forge at an image, or at a directory of images."})}function C(e){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(e)} could not be read.`,short:`${r(e)} could not be read.`,hint:"Check the file permissions and try again."})}function S(e){return new o({code:"not-a-directory",title:"Invalid path",detail:`${r(e)} could not be found: part of its path is not a directory.`,short:`part of ${r(e)}'s path is not a folder.`,hint:"Check the path and try again."})}function T(e){return new o({code:"symlink-loop",title:"Too many symbolic links",detail:`${r(e)} could not be resolved: its path contains a symbolic-link loop.`,short:`${r(e)}'s path loops back on itself.`,hint:"Check for a circular symlink somewhere in the path."})}function I(e){return new o({code:"path-too-long",title:"Path too long",detail:`${r(e)}'s path is too long for the filesystem to resolve.`,short:`${r(e)}'s path is too long.`,hint:"Use a shorter path and try again."})}function N(e,t){return new o({code:"unreadable-path",title:"Could not read path",detail:`${r(e)} could not be checked.`,short:`${r(e)} could not be checked.`,hint:"Check the path and try again.",cause:t})}function P(e,t){return new o({code:"unsupported-source",title:"Unsupported file type",detail:`${r(e)} is ${t}, which Forge cannot read.`,short:`${r(e)} is ${t}, which Forge cannot read.`,hint:"Forge 0.1 handles images only."})}function H(e,t){return new o({code:"unsupported-source",title:"Not an image",detail:`${r(e)} is ${t}, not an image.`,hint:"A palette is taken from a photo, a screenshot or artwork."})}function O(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${r(e)} has no visible pixels.`})}function R(e,t=process.platform){if(t!=="darwin"){let n=t==="win32"?"Windows":t==="linux"?"Linux":"this system";return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e,t)} is a HEIC photo, which needs Forge's free HEIC extension on ${n}.`,short:"HEIC needs the heic extension.",hint:"Install it with: forge extensions add heic",shellHint:"Open /extensions to install it."})}return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e)} is a HEIC photo, which Forge decodes with the macOS sips tool.`,short:"HEIC needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function A(e,t=process.platform){if(t!=="darwin"){let n=t==="win32"?"Windows":t==="linux"?"Linux":"this system";return new o({code:"raw-decoder-unavailable",title:"Cannot read RAW here",detail:`${r(e,t)} is a camera RAW photo, which needs Forge's free RAW extension on ${n}.`,short:"RAW needs the raw extension.",hint:"Install it with: forge extensions add raw",shellHint:"Open /extensions to install it."})}return new o({code:"raw-decoder-unavailable",title:"Cannot read RAW here",detail:`${r(e,t)} is a camera RAW photo, which Forge reads with macOS's own RAW support.`,short:"RAW needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function U(e){return new o({code:"raw-decoder-unavailable",title:"Cannot read this RAW",detail:`${r(e)} is a camera RAW photo that this Mac cannot read.`,short:"macOS cannot read RAW photos from this camera.",hint:"A newer camera usually needs a newer macOS."})}function W(e,t){let n=r(e.path);if(t!==void 0&&t!==e.format){let i=a[t].label;return a[t].lossy?new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`Forge cannot search ${n} \u2192 ${i} toward a size yet.`,hint:"Convert it first, then compress the result with --max-size.",shellHint:"Convert it first, then /compress the result to a size."}):new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`${i} is lossless \u2014 there is no quality to trade away, so ${n} cannot be made to fit as ${i}.`,hint:"Drop --max-size, or choose a lossy target. forge --formats lists them.",shellHint:"Choose a lossy target to aim for a size."})}if(e.kind==="document"&&e.format==="pdf"){let i=e.images?.skipped??0;return new o({code:"unsupported-compress",title:"Nothing to compress",detail:i>0?`${n}'s images are a kind Forge cannot re-encode, so there is nothing to make smaller.`:`${n} has no images \u2014 it is text and layout, which compression cannot shrink.`,hint:"Try a page operation such as --extract to keep fewer pages, or --to <format> to turn its pages into images.",shellHint:"Try /pdf to keep fewer pages, or /convert to turn its pages into images."})}return e.kind==="document"?new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${a[e.format].label}, which has no images Forge can re-encode.`,hint:`Use --to pdf to change it to PDF instead: forge ${n} --to pdf`,shellHint:"Use /convert to change it to PDF instead."}):new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${a[e.format].label}, which is lossless \u2014 there is no quality to trade away.`,hint:"Use --to to change it to a smaller format instead. forge --formats lists them.",shellHint:"Use /convert to change it to a smaller format instead."})}function D(e){let t=r(e.path);return new o({code:"unsupported-pdf",title:"/pdf needs a PDF",detail:`${t} is ${a[e.format].label}, not a PDF.`,hint:"Converting it instead."})}function M(e,t,n){return new o({code:"unsupported-operation",title:`Cannot ${e} these files`,detail:`Not available for these files: ${t}.`,hint:n??"Page operations work on PDFs: --merge takes two or more, the others take one.",shellHint:n??"Use /pdf with a PDF staged \u2014 two or more for merge."})}function J(e,t,n){let i=e.kind==="media"?`The smallest ${r(e.path)} can get is ${s(n)}, which is still over ${s(t)}.`:`${r(e.path)} is ${s(n)} even at the lowest quality, which is still over ${s(t)}.`;return new o({code:"target-unreachable",title:"Cannot get that small",detail:i,hint:"Try a larger --max-size, or --to a smaller format.",shellHint:"Try a larger target, or /convert to a smaller format."})}function j(e,t,n){return new o({code:"unsupported-target",title:`Can't convert ${r(e.path)} to ${t}`,detail:`${r(e.path)} is a ${a[e.format].label} ${e.kind==="image"?"image":"document"}.`,hint:`Available: ${n.join(", ")}`})}function z(e,t){return new o({code:"corrupt-source",title:"Damaged file",detail:`${r(e)} could not be read. It may be damaged, or not a format Forge recognises.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:t})}function L(e,t,n){return new o({code:"corrupt-source",title:`Damaged ${a[t].label}`,detail:`${r(e)} is a ${a[t].label} file, but its content could not be read.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:n})}function q(e,t={}){let n=r(e);return new o({code:"encrypted-source",title:"This PDF is password-protected",detail:`${n} is password-protected.`,short:`${n} is password-protected.`,hint:t.attempted?"That password didn't open it. Check it and try again.":`Convert it to images instead: forge ${n} --to jpeg --password-stdin`})}var c=e=>e==="convert"||e==="boost"||e==="remove-background";function Y(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${r(e)} is already there.`,hint:c(t)?"Pass --force to replace it, or choose a different --output.":"Pass --force to replace it, or move the existing file out of the way.",shellHint:"Run it again and Forge will ask before replacing it."})}function V(e,t){return new o({code:"output-collision",title:"Two files want the same output",detail:`${r(e[0])} and ${r(e[1])} would both become ${r(t)}.`,hint:"Convert them separately, or use --output to send them to different folders.",shellHint:"Convert them one at a time."})}function _(e,t){return new o({code:"output-collision",title:"One output, written twice",detail:`${r(e)} would write ${r(t)} twice, and only the second would survive.`,hint:"Every output has to be its own file. Check the selection for a repeated page."})}function X(e,t="convert"){return new o({code:"output-is-input",title:"Output would replace the original",detail:`${r(e)} is both the input and the output.`,hint:c(t)?"Choose a different --output, or pass --force to overwrite in place.":"Move or rename that file first, or pass --force to overwrite it in place.",shellHint:c(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function w(e,t){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(f(e))} is not a folder you can write to.`,hint:"Choose a different --output, or check the folder permissions.",shellHint:"Choose a different folder, or check its permissions.",cause:t})}var b=new Set(["EACCES","EPERM","EROFS"]);function B(e,t){if(m(t))return t;let n=t?.code;return n!==void 0&&b.has(n)?w(e,t):t}function G(e,t){return new o({code:"output-invalid",title:"Cannot write there",detail:`${e} could not be written to.`,hint:"Check that the path is valid and that you have permission to write to it.",cause:t})}function K(e){return new o({code:"empty-directory",title:"No images found",detail:`${r(e)} contains no images Forge can convert.`,hint:"Try --recursive to look inside subfolders.",shellHint:"Only files directly inside a folder are read \u2014 drop the files themselves, or the folder that holds them."})}function Q(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function Z(e,t,n){return new o({code:"invalid-page-range",title:"Page range not understood",detail:t,hint:`This document has ${n} pages. Use numbers and spans, like "3-7, 12, 20-".`})}function ee(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function te(e){return new o({code:"invalid-dpi",title:"Invalid resolution",detail:`${String(e)} is not a resolution Forge can use.`,hint:"Give a number between 36 and 600. The default is 150."})}function oe(e){return new o({code:"extension-missing",title:"Extension not installed",detail:`${e} is an optional extension and is not installed.`,hint:`Install it with: forge extensions add ${e}`,shellHint:"Open /extensions to install it."})}function ne(e,t,n,i){return new o({code:"extension-outdated",title:"Extension out of date",detail:`${e} ${n} cannot ${t}; that needs ${i} or later.`,hint:`Update it with: forge extensions add ${e}`,shellHint:"Open /extensions to update it."})}function re(e,t){return new o({code:"extension-corrupt",title:"Extension failed verification",detail:`${e}: ${t}`,hint:`Nothing was installed. Try again with: forge extensions add ${e}`,shellHint:"Nothing was installed. Try again from /extensions."})}function ie(e,t,n=process.platform){let i=n==="win32"?"PC":n==="darwin"?"Mac":"computer";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} cannot be installed on this ${i}: ${t}`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function ae(e,t=process.platform){let n=t==="win32"?"Windows":t==="darwin"?"macOS":t==="linux"?"Linux":"this system";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} is not available on ${n}.`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function se(e){return new o({code:"update-unavailable",title:"Cannot update this Forge",detail:`This copy of Forge was not installed with npm i -g, so ${e} cannot be installed over it.`,hint:"npm i -g forge-terminal"})}function le(e,t=process.platform){return t==="win32"?new o({code:"update-denied",title:"Forge is in use",detail:`npm could not replace Forge's files to update it to ${e}. Windows keeps them locked while Forge runs: close every Forge window, then run the command below. If Node is installed for every user, run it in a terminal opened as administrator.`,short:"Windows locks Forge while it runs: close it, then run this",hint:`npm i -g forge-terminal@${e}`}):new o({code:"update-denied",title:"npm needs permission",detail:`npm needs permission to update Forge to ${e}.`,short:"npm needs permission to update Forge",hint:`sudo npm i -g forge-terminal@${e}`})}function de(e,t){return new o({code:"update-failed",title:"Update failed",detail:`npm could not install Forge ${e}: ${t}`,short:"npm could not install the update",hint:`npm i -g forge-terminal@${e}`})}function ue(){return new o({code:"update-unreachable",title:"Could not check for updates",detail:"The npm registry could not be reached.",short:"could not reach npm",hint:"Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge update",shellHint:"Check your connection, then try again."})}function ce(e,t){return new o({code:"extension-download-failed",title:"Download failed",detail:`${e}: ${t}`,hint:`Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge extensions add ${e}`,shellHint:"Check your connection, then try again from /extensions."})}function pe(e,t){return new o({code:"extension-download-failed",title:"Not enough disk space",detail:`${e}: ${t}`,hint:`Free some disk space, then run: forge extensions add ${e}`,shellHint:"Free some disk space, then try again from /extensions."})}function he(e,t,n){let i=t?t.what?`${t.what} (forge, pid ${t.pid})`:`another forge (pid ${t.pid}) is using it`:"another forge is using it";return new o({code:"extension-in-use",title:"Extension in use",detail:`${e} is in use: ${i}.`,hint:n==="remove"?`Wait for that job to finish, then run: forge extensions remove ${e}`:"Wait for that job to finish, then try again.",shellHint:n==="remove"?"It can be removed when that job finishes.":"Try again when that job finishes."})}function ge(e){return new o({code:"no-subject",title:"No subject found",detail:`${r(e)} has no clear subject to cut out.`,hint:"Try a photo where the subject stands apart from the background."})}function fe(e,t,n){return n===1?new o({code:"boost-too-large",title:"Too large to sharpen",detail:`${r(e)} is too large to sharpen.`,hint:"Sharpen works on images up to 16,384 px a side and 100 megapixels."}):new o({code:"boost-too-large",title:"Too large to boost",detail:t>=2?`${r(e)} is too large to boost that far; ${t}x is the most it can take.`:`${r(e)} is already too large to boost.`,hint:t>=2?`Try --boost ${t}.`:"Boost works on images up to 100 megapixels.",shellHint:t>=2?`Choose ${t}x instead.`:void 0})}function me(e,t,n,i=process.platform){let l=n===1?"sharpen":"boost",d=i==="win32"?"PC":i==="darwin"?"Mac":"computer",u=Math.max(1,Math.round(t/60));return new o({code:"boost-too-slow",title:`Too slow to ${l}`,detail:`${r(e)} would take about ${u} ${u===1?"minute":"minutes"} to ${l} on this ${d}.`,hint:"Try a smaller photo."})}function we(e,t){return new o({code:"resize-too-large",title:"Too large to resize to",detail:`${r(e)} would be ${t.width} \xD7 ${t.height}.`,hint:"Resize works up to 16,384 px a side and 100 megapixels."})}var x={darwin:"\u2303\u21E7\u23184",win32:"Win+Shift+S"};function be(e,t=process.platform){let n=x[t];return new o({code:"no-clipboard-image",title:"No image",detail:e==="text"?"The clipboard holds text, not a picture.":"The clipboard is empty.",hint:n===void 0?"Copy a picture or a screenshot, then run forge clip again.":`Copy a picture, or take a screenshot with ${n}, then run forge clip again.`})}function xe(e=process.platform){return new o({code:"clipboard-unavailable",title:"No clipboard",detail:e==="linux"?"Forge reads the clipboard of a Wayland or X11 desktop, and not over SSH.":"Forge reads the clipboard on macOS, Windows and Linux, and not over SSH."})}function $e(e){return new o({code:"clipboard-tool-missing",title:`Clipboard needs ${e}`,detail:`Forge reaches the clipboard through ${e}, and it is not on this computer.`,short:`${e} is not on this computer`,hint:`Install it with sudo apt install ${e} (or your distribution's package manager), then try again.`})}function Fe(){return new o({code:"nothing-to-undo",title:"Nothing to undo",detail:"No copied image has been changed yet."})}function ye(e,t,n,i=!1){let l=r(e);if(i)return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} is no smaller even at the lowest quality, so nothing was written.`,short:"nothing written"});let d=n>t?`would grow from ${s(t)} to ${s(n)}`:`would stay at ${s(t)}`;return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} ${d}, so nothing was written.`,short:"nothing written",hint:"Try a lower --quality.",shellHint:"Try a lower quality."})}function Ee(e,t,n){return new o({code:"cannot-compress-more",title:"Already small enough",detail:`${r(e)} is ${s(t)}, already under ${s(n)}, so nothing was written.`,short:"already under that size"})}function ve(e){return new o({code:"nothing-to-trim",title:"Nothing to trim",detail:`${r(e)} has no empty edges.`,short:"no empty edges"})}function ke(e){return new o({code:"animated-trim",title:"Can't trim an animation",detail:`${r(e)} is animated; trimming works on still images.`})}function Ce(e,t){return new o({code:"nothing-to-crop",title:"Nothing to crop",detail:`${r(e)} is already ${t}.`,short:`already ${t}`})}function Se(e){return new o({code:"animated-crop",title:"Can't crop an animation",detail:`${r(e)} is animated; cropping works on still images.`})}function Te(e){return new o({code:"animated-rotate",title:"Can't rotate an animation",detail:`${r(e)} is animated; rotating works on still images.`})}function Ie(e,t=process.platform,n=!1){let i=p(t),l=n?`forge extensions add video (or ${i})`:t==="linux"?`${i} (or your distribution's package manager)`:i;return new o({code:"ffmpeg-missing",title:"Video and audio need ffmpeg",detail:`${r(e)} is a video or audio file, and ffmpeg is not on this computer.`,short:"ffmpeg is not on this computer",hint:`Install it with ${l}, then run Forge again.`})}function Ne(e,t,n=process.platform){let i=a[e].label,l=/^[AEFHILMNORSX]/.test(t.codec)?"an":"a",d=t.encoders,u=d.length>1?`${d.slice(0,-1).join(", ")} or ${d.at(-1)}`:d[0]??"",h=d.length>1?"any of them":"it",g=n==="linux"?"Install a full build of ffmpeg, then run Forge again. On Fedora, RPM Fusion's ffmpeg replaces ffmpeg-free.":n==="win32"?`Install a full build of ffmpeg, such as gyan.dev's (${p(n)}), then run Forge again.`:`Install a full build of ffmpeg (${p(n)}), then run Forge again.`;return new o({code:"encoder-missing",title:`Your ffmpeg can't write ${i}`,detail:`${i} needs ${l} ${t.codec} encoder${t.sound?" for its sound":""}: ${u}. Your ffmpeg was built without ${h}.`,short:`Your ffmpeg has no ${t.codec} encoder`,hint:g})}function p(e=process.platform){return e==="win32"?"winget install ffmpeg":e==="linux"?"sudo apt install ffmpeg":"brew install ffmpeg"}function Pe(e,t){return new o({code:"conversion-failed",title:"Conversion failed",detail:`${r(e)} could not be converted.`,hint:"Run again with --debug for the underlying error.",shellHint:"Run the same conversion with forge --debug from the command line to see why.",cause:t})}function He(e){return new o({code:"no-sound",title:"Nothing to transcribe",detail:`${r(e)} has no sound.`})}function Oe(e,t=process.platform,n=t==="darwin"?"apple":"whisper"){return n==="whisper"?new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e,t)} cannot be read by whisper.`,hint:"Video and sound files can be transcribed."}):new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e)} cannot be read by Apple's speech recogniser.`,hint:"MP4, MOV, M4A, MP3, WAV and AIFF can be transcribed; with ffmpeg (brew install ffmpeg), any video or sound file."})}function Re(e,t=process.platform,n=t==="darwin"?"apple":"whisper"){let i=n==="apple"?"Apple's speech recogniser":"The whisper extension";return new o({code:"language-unsupported",title:"Language not supported",detail:`${i} does not support ${e}.`,hint:"Pass another with --language, for example --language en-US."})}function Ae(e,t,n={}){return new o({code:"link-unavailable",title:"Cannot transcribe this link",detail:e,...n,...t===void 0?{}:{cause:t}})}function Ue(e){return new o({code:"transcribe-unavailable",title:"Transcribe is not available",detail:e})}function We(e=!1){return e?new o({code:"read-unavailable",title:"Reading text is not available",detail:"Reading text needs Forge's free read-text extension.",short:"Needs the read-text extension.",hint:"Install it with: forge extensions add read-text",shellHint:"Open /extensions to install it."}):new o({code:"read-unavailable",title:"Reading text is not available",detail:"Reading text needs macOS 26 or later.",short:"Reading text needs macOS 26 or later."})}function De(e){let t=r(e);return new o({code:"no-text",title:"No text found",detail:`No text found in ${t}`,short:`No text found in ${t}`})}function Me(e){return new o({code:"unexpected",title:"Something went wrong",detail:e instanceof Error?e.message:String(e),hint:"This was not expected. Try again \u2014 if it keeps happening, it may be worth reporting.",cause:e})}function Je(e,t={}){let n=[`\u2715 ${e.title}`,"",` ${e.detail}`];return e.hint&&n.push("",` ${e.hint}`),t.debug&&e.cause instanceof Error&&n.push("",` ${e.cause.stack??e.cause.message}`),n}export{m as a,v as b,k as c,C as d,S as e,T as f,I as g,N as h,P as i,H as j,O as k,R as l,A as m,U as n,W as o,D as p,M as q,J as r,j as s,z as t,L as u,q as v,Y as w,V as x,_ as y,X as z,w as A,B,G as C,K as D,Q as E,Z as F,ee as G,te as H,oe as I,ne as J,re as K,ie as L,ae as M,se as N,le as O,de as P,ue as Q,ce as R,pe as S,he as T,ge as U,fe as V,me as W,we as X,be as Y,xe as Z,$e as _,Fe as $,ye as aa,Ee as ba,ve as ca,ke as da,Ce as ea,Se as fa,Te as ga,Ie as ha,Ne as ia,p as ja,Pe as ka,He as la,Oe as ma,Re as na,Ae as oa,Ue as pa,We as qa,De as ra,Me as sa,Je as ta};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
3
|
import{execFile as I,spawn as R}from"node:child_process";import{access as T,constants as K}from"node:fs/promises";import{dirname as $,join as L}from"node:path";import{promisify as C}from"node:util";function S(e){let[t,r]=(e??"").split("/").map(Number);return!t||!r?0:Math.round(t/r*100)/100}function O(e){let t=e.side_data_list?.find(n=>typeof n.rotation=="number")?.rotation,r=t!==void 0?-t:Number(e.tags?.rotate??0);return(Math.round(r/90)*90%360+360)%360}function A(e){let t=e,r=t.streams??[],n=r.find(o=>o.codec_type==="video"&&o.disposition?.attached_pic!==1),i=r.find(o=>o.codec_type==="audio"),a={duration:Number(t.format?.duration)||Math.max(0,...r.map(o=>Number(o.duration)||0))};if(n){let o=O(n),f=o===90||o===270,s=n.width??0,c=n.height??0;a.video={codec:n.codec_name??"",width:f?c:s,height:f?s:c,fps:S(n.avg_frame_rate)||S(n.r_frame_rate),rotation:o,hdr:n.color_transfer==="arib-std-b67"||n.color_transfer==="smpte2084"}}return i&&(a.audio={codec:i.codec_name??"",channels:i.channels??0,sampleRate:Number(i.sample_rate)||0}),a}var v=C(I);function D(e,t){let r=t.PATH??t.Path??"",n=e==="win32"?";":":",i=r.split(n).filter(Boolean);return e==="darwin"&&i.push("/opt/homebrew/bin","/usr/local/bin"),[...new Set(i)]}var k=e=>process.platform==="win32"?`${e}.exe`:e;async function N(e){try{return await T(e,K.X_OK),!0}catch{return!1}}function G(e){let t=new Set;for(let r of e.split(`
|
|
4
|
-
`)){let n=r.match(/^\s*[A-Z.|]{3,6}\s+(\S+)\s/);n?.[1]&&n[1]!=="="&&t.add(n[1])}return t}async function J(){try{let{installed:e}=await import("./paths-6OENILJ4.js");return(await e("video"))?.dir}catch{return}}async function j(){try{let{chosenPath:e}=await import("./own-
|
|
4
|
+
`)){let n=r.match(/^\s*[A-Z.|]{3,6}\s+(\S+)\s/);n?.[1]&&n[1]!=="="&&t.add(n[1])}return t}async function J(){try{let{installed:e}=await import("./paths-6OENILJ4.js");return(await e("video"))?.dir}catch{return}}async function j(){try{let{chosenPath:e}=await import("./own-G4G4MRGM.js"),t=await e("video");return t===void 0?void 0:$(t)}catch{return}}async function q(){try{let{removeForgeCopy:e}=await import("./own-G4G4MRGM.js");await e("video")}catch{}}async function H(){let e=await J(),t=await j(),r=[...t?[t]:[],...D(process.platform,process.env),...e?[e]:[]];for(let n of r){let i=L(n,k("ffmpeg")),m=L(n,k("ffprobe"));if(!await N(i)||!await N(m))continue;try{await v(i,["-hide_banner","-version"],{timeout:5e3})}catch{continue}let[a,o]=await Promise.all(["-encoders","-filters"].map(s=>v(i,["-hide_banner",s],{timeout:5e3,maxBuffer:4<<20}).then(({stdout:c})=>G(c)).catch(()=>{}))),f=a&&o?new Set([...a,...o]):void 0;return e!==void 0&&n!==e&&await q(),{ffmpeg:i,ffprobe:m,...f?{has:f}:{}}}}var b,w=null,F;function y(){return w?Promise.resolve(w.value):(b=(b??H()).then(t=>(t||(b=void 0),F=t,t)),b)}function te(){return w?w.value:F}function ne(e){w=e===null?null:{value:e},b=void 0,F=void 0}async function re(e,t){let r=t??await y();if(!r)throw new Error("ffmpeg is not installed");let{stdout:n}=await v(r.ffprobe,["-v","error","-print_format","json","-show_format","-show_streams",e],{timeout:3e4,maxBuffer:16*1024*1024});return A(JSON.parse(n))}async function oe(e,t,r){let n=r??await y();if(!n)return;let i=Math.max(0,t-15),{stdout:m}=await v(n.ffprobe,["-v","error","-select_streams","v:0","-skip_frame","nokey","-show_entries","frame=pts_time","-of","csv=p=0","-read_intervals",`${i}%${t+.01}`,e],{timeout:3e4,maxBuffer:4*1024*1024}),a=m.split(`
|
|
5
5
|
`).map(o=>Number.parseFloat(o)).filter(o=>Number.isFinite(o)&&o<=t+.001);return a.length?Math.max(...a):void 0}var B=4e3;async function ie(e,t,r,n={}){let i=n.tools??await y();if(!i)return null;let m=Math.max(1,Math.round(t*B)),a=Math.max(1,Math.ceil(m/r)),o=new Array(r).fill(0),f=0,s=Buffer.alloc(0);if(!await new Promise((p,d)=>{let u=R(i.ffmpeg,["-hide_banner","-nostdin","-loglevel","error","-i",e,"-map","0:a:0","-ac","1","-ar",String(B),"-f","s16le","-"],{stdio:["ignore","pipe","pipe"]}),h=()=>u.kill("SIGKILL");n.signal?.addEventListener("abort",h,{once:!0}),u.stdout.on("data",l=>{let _=s.length?Buffer.concat([s,l]):l,P=_.length-_.length%2;for(let x=0;x<P;x+=2){let M=Math.abs(_.readInt16LE(x)),E=Math.min(r-1,Math.floor(f/a));M>(o[E]??0)&&(o[E]=M),f++}s=_.subarray(P)}),u.stderr.resume(),u.on("error",d),u.on("close",l=>{n.signal?.removeEventListener("abort",h),n.signal?.aborted?d(n.signal.reason??new Error("aborted")):p(l===0&&f>0)})}))return null;let g=Math.max(1,...o);return o.map(p=>Math.sqrt(p/g))}async function se(e,t,r,n){await Z(["-ss",String(Math.max(0,t)),"-i",e,"-frames:v","1","-y",r],{tools:n})}function V(e){let t;for(let r of e.matchAll(/out_time_us=(\d+)/g))t=Number(r[1])/1e6;return t}var X=4e3;async function Z(e,t={}){let{signal:r,onTime:n}=t;if(r?.aborted)throw r.reason??new Error("aborted");let i=t.tools??await y();if(!i)throw new Error("ffmpeg is not installed");let a=["-hide_banner","-nostdin","-loglevel",t.report?"info":"error","-progress","pipe:1","-nostats",...e];return new Promise((o,f)=>{let s=R(i.ffmpeg,a,{stdio:["ignore","pipe","pipe"]}),c="",g=()=>s.kill("SIGKILL");r?.addEventListener("abort",g,{once:!0}),s.stdout.setEncoding("utf8");let p="";s.stdout.on("data",d=>{let u=p+d,h=u.lastIndexOf(`
|
|
6
6
|
`);p=u.slice(h+1);let l=V(u.slice(0,h+1));l!==void 0&&n?.(l)}),s.stderr.setEncoding("utf8"),s.stderr.on("data",d=>{c=(c+d).slice(-X)}),s.on("error",d=>{r?.removeEventListener("abort",g),f(d)}),s.on("close",d=>{r?.removeEventListener("abort",g),r?.aborted?f(r.reason??new Error("aborted")):d===0?o(c):f(new Error(c.trim()||`ffmpeg exited with ${d}`))})})}export{D as a,G as b,y as c,te as d,ne as e,re as f,oe as g,ie as h,se as i,V as j,Z as k};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as f}from"./chunk-
|
|
3
|
+
import{b as f}from"./chunk-TYWGB767.js";import{execFile as s,execFileSync as i,spawn as d}from"node:child_process";var u=()=>({...process.env,LANG:process.env.LANG??"en_US.UTF-8"});function m(e,r=process.platform,n=process.env){if(e!==""){if(r==="linux"){c(Buffer.from(e,"utf8"),p(n,"copy"));return}if(r==="win32"){try{let t=s("clip.exe",()=>{});t.on("error",()=>{}),t.stdin?.end(Buffer.concat([Buffer.from([255,254]),Buffer.from(e,"utf16le")]))}catch{}return}try{let t=s("pbcopy",{env:u()},()=>{});t.on("error",()=>{}),t.stdin?.end(Buffer.from(e,"utf8"))}catch{}}}function y(e=process.platform,r=process.env){if(e==="linux")return l(p(r,"paste"));if(e==="win32")try{return i("powershell.exe",["-NoProfile","-NonInteractive","-Command","[Console]::OutputEncoding=[Text.Encoding]::UTF8; Get-Clipboard -Raw"],{encoding:"buffer",maxBuffer:67108864,timeout:5e3}).toString("utf8").replace(/\r\n$/,"")}catch{return""}try{return i("pbpaste",{encoding:"buffer",env:u(),maxBuffer:67108864,timeout:2e3}).toString("utf8")}catch{return""}}function p(e,r){return f(e).flatMap(n=>n.name==="wayland"?r==="copy"?[["wl-copy",["--type","text/plain;charset=utf-8"]]]:[["wl-paste",["--no-newline","--type","text"]]]:r==="copy"?[["xclip",["-selection","clipboard","-i"]],["xsel",["--clipboard","--input"]]]:[["xclip",["-selection","clipboard","-o"]],["xsel",["--clipboard","--output"]]])}function c(e,r){let[n,...t]=r;if(n)try{let o=d(n[0],n[1],{stdio:["pipe","ignore","ignore"],detached:!0});o.on("error",a=>{a.code==="ENOENT"&&c(e,t)}),o.stdin?.on("error",()=>{}),o.stdin?.end(e),o.unref()}catch{c(e,t)}}function l(e){for(let[r,n]of e)try{return i(r,n,{encoding:"buffer",maxBuffer:67108864,timeout:2e3,stdio:["ignore","pipe","ignore"]}).toString("utf8")}catch(t){if(t.code!=="ENOENT")return""}return""}export{m as a,y as b,p as c};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{c as ne,g as at,h as ct}from"./chunk-EEQSUBBL.js";import{c as le,d as ft,f as ge,g as dt,k as pt}from"./chunk-E2BYNETT.js";import{b as st,c as it}from"./chunk-IE6NFN3N.js";import{b as Ue,c as ze,d as qe,f as He,m as tt,n as ot,o as nt,t as rt}from"./chunk-TFOEI5VF.js";import{n as Ge,o as Ve,q as Ke,r as R}from"./chunk-BIBDLXCG.js";import{E as Te,F as V,G as me,I as Ne,M as Le,V as Je,a as B,aa as te,ha as We,ia as Ce,ka as J,r as Be,t as j,v as ee}from"./chunk-CVNYUROW.js";import{a as Ae}from"./chunk-J7FLFHQJ.js";import{c as A}from"./chunk-VLVNA4T3.js";import{a as S}from"./chunk-H3DIRJFE.js";import{a as Ye,b as oe,c as M,e as Ze,f as Qe,g as Xe,h as je,i as et}from"./chunk-KXKQDFHX.js";import{mkdtemp as Jt,rm as Wt}from"node:fs/promises";import{tmpdir as Ct}from"node:os";import{join as re}from"node:path";var mt=(e,t,o)=>He(e,t,o)===void 0;function ut(e,t,o=Number.POSITIVE_INFINITY,n=[2,4]){return[...n].reverse().find(s=>s<o&&mt(e,t,s))??0}async function Ut(e,t,o){if(e.op!=="boost"&&e.op!=="remove-background")throw new Error(`the extension engine cannot ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=e.op,{assetFor:i,catalogEntry:a,offeredHere:f}=await import("./catalog-FMHWWMUX.js");if(!f(r,process.platform,process.arch))throw Le(a(r)?.title??r);let{installed:d,extensionsRoot:u}=await import("./paths-6OENILJ4.js"),h=await d(r);if(!h)throw Ne(r);let l=ze(h.version);if(e.op==="boost"){let v=a(r),x=qe(e.scale,h.version,v&&i(v)?.version);if(x)throw x}if(e.op==="boost"&&!mt(n.width,n.height,e.scale))throw Je(n.path,ut(n.width,n.height,Number.POSITIVE_INFINITY,l),e.scale);let{runExtension:w}=await import("./run-WSETTQXP.js"),g=[];n.frames>1&&g.push({code:"animation-flattened",message:`${A(n.path)} has ${n.frames} frames. Only the first frame was used.`});let I=await Jt(re(Ct(),"forge-ext-"));try{t({phase:"decoding"});let v=re(I,"in.png"),x=re(I,"out.png");await nt(n,v);let $=e.op==="boost"?["--in",v,"--out",x,"--scale",String(e.scale),"--cache",re(u(),"boost","cache")]:[v,x],p=e.op==="boost"&&Ue(h.version);await w({...h,serve:p},$,{subject:n.path,what:`${zt(e)} is running on ${A(n.path)}`,onWait:()=>t({phase:"waiting"}),onStart:()=>t({phase:"encoding"}),onProgress:(O,P)=>t({phase:"tiles",done:O,total:P}),...e.op==="boost"?{maxScale:ut(n.width,n.height,e.scale,l)}:{},...o===void 0?{}:{signal:o}});let y=(await oe())(x);S[e.target].hasAlpha||(y=y.flatten({background:e.options.background}));let F=await tt(y,e.target,e.options.quality).toBuffer();t({phase:"writing"});let b=await ot(F,s);return{job:e,outputBytes:b,warnings:g}}catch(v){throw B(v)?v:J(n.path,v)}finally{await Wt(I,{recursive:!0,force:!0}).catch(()=>{})}}function zt(e){return e.op!=="boost"?"Remove background":e.scale===1?"Sharpen":`Boost resolution ${e.scale}\xD7`}var lt={id:"extension",reads:new Set,writes:new Set,ops:new Set(["boost","remove-background"]),probe:()=>Promise.reject(new Error("the extension engine reads no files")),run:Ut};import{randomBytes as mo}from"node:crypto";import{rm as lo,stat as se}from"node:fs/promises";import{dirname as go,join as ho}from"node:path";import{open as qt}from"node:fs/promises";async function W(e,t){let o=await qt(e,"r");try{let n=Buffer.alloc(t),{bytesRead:s}=await o.read(n,0,t,0);return n.subarray(0,s)}finally{await o.close()}}var he="%NOISE_FLOOR%",Ht=["highpass=f=80",`afftdn=nr=12:nf=${he}`],Gt="highpass=f=80,astats=measure_perchannel=none:measure_overall=RMS_trough";function vt(e){let t=/RMS trough dB:\s*(-?[\d.]+|-?inf)/i.exec(e)?.[1],o=t===void 0?Number.NaN:Number(t);return Number.isFinite(o)?Math.min(-30,Math.max(-70,Math.round(o+8))):-50}var we="%LOUDNORM_MEASURED%",Vt={mp4:"mp4",hevc:"mp4",mov:"mov",webm:"webm",mkv:"matroska",avi:"avi",gif:"gif",mp3:"mp3",m4a:"ipod",opus:"opus",flac:"flac",wav:"wav",aiff:"aiff",ogg:"ogg"},Kt={mp4:["h264","hevc","mpeg4","av1"],mov:["h264","hevc","mpeg4","prores","av1"],mkv:["h264","hevc","mpeg4","vp8","vp9","av1"],hevc:["hevc"],webm:["vp8","vp9","av1"],avi:["mpeg4","h264","mjpeg","msmpeg4v3"]},Yt={mp4:["aac","alac","mp3"],hevc:["aac","alac","mp3"],mov:["aac","alac","mp3","pcm_s16le","pcm_s16be","pcm_s24le"],m4a:["aac","alac"],mkv:["aac","mp3","opus","vorbis","flac","ac3","eac3"],webm:["opus","vorbis"],opus:["opus"],mp3:["mp3"],flac:["flac"],wav:["pcm_s16le"],aiff:["pcm_s16be"],ogg:["vorbis","opus","flac"],avi:["mp3","ac3","aac","pcm_s16le"]},gt=[48e3,24e3,16e3,12e3,8e3];function Zt(e,t,o){let n={encoder:"opus",kbps:96,args:["-strict","-2"],rates:[48e3]};switch(e){case"webm":return o("libopus")?{encoder:"libopus",kbps:96,rates:gt}:o("libvorbis")?{encoder:"libvorbis",kbps:128}:o("opus")?n:{codec:"Opus or Vorbis",encoders:["libopus","libvorbis","opus"],sound:!0};case"opus":return o("libopus")?{encoder:"libopus",kbps:96,rates:gt}:o("opus")?n:{codec:"Opus",encoders:["libopus","opus"]};case"mp3":return o("libmp3lame")?{encoder:"libmp3lame",kbps:128}:{codec:"MP3",encoders:["libmp3lame"]};case"flac":return{encoder:"flac"};case"wav":return{encoder:"pcm_s16le"};case"aiff":return{encoder:"pcm_s16be"};case"ogg":return o("libvorbis")?{encoder:"libvorbis",kbps:128}:{encoder:"vorbis",kbps:128,args:["-strict","-2","-ac","2"]};default:return{encoder:t==="darwin"&&o("aac_at")?"aac_at":"aac",kbps:128}}}var K=e=>Math.max(2,Math.floor(e/2)*2),Qt=e=>String(Math.round(e*1e3)/1e3),Xt=e=>String(Math.ceil(e*1e3)/1e3),jt=e=>Math.round(38-(e-1)*20/99),eo=e=>Math.round(50-(e-1)*30/99),to=e=>Math.round(40-(e-1)*18/99),ht=e=>Math.round(20+e*60/100),oo=e=>Math.round(31-(e-1)*29/99);function no(e,t){let o=.15*2**((18-e)/6);return Math.max(64,Math.round(t*o/1e3))}function ro(e,t,o,n,s){let r=e.width,i=e.height;if(o)r=o.width,i=o.height;else{t.crop?.box&&(r=t.crop.box.width,i=t.crop.box.height);let a=t.resize;if(a&&"width"in a){let f=Math.min(a.width,r)/r;r*=f,i*=f}else if(a&&"height"in a){let f=Math.min(a.height,i)/i;r*=f,i*=f}else a&&(r*=a.percent/100,i*=a.percent/100)}return r*i*(n??e.fps*s)}var so="zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p";function wt(e){let t=[],o=e;for(;o>2;)t.push("atempo=2"),o/=2;for(;o<.5;)t.push("atempo=0.5"),o/=.5;return t.push(`atempo=${Math.round(o*1e3)/1e3}`),t}var io=800,ao=15,bt=32;function be(e){let{facts:t,options:o,target:n,platform:s}=e,r=o.media??{},i=t.video,a=t.audio,f=S[n].media==="sound",d=n==="gif",u=o.compress!==void 0,h=s==="darwin",l=c=>e.has===void 0||e.has.has(c),w=c=>Ce(n,c,e.os??s),g=r.cut?.start??0,I=Math.min(r.cut?.end??t.duration,t.duration),v=Math.max(0,I-g),x=r.speed??1,$=v/x,p=i!==void 0&&!f,E=a!==void 0&&!r.mute&&!d,y,F,b,O;if(r.targetBytes!==void 0&&$>0){if(p&&i){let c=at({duration:$,width:i.width,height:i.height,fps:i.fps,hasAudio:E,targetBytes:r.targetBytes});"videoKbps"in c&&(y={width:c.width,height:c.height,fps:c.fps},b=c.videoKbps,F=c.audioKbps)}else if(E){let c=Math.floor(r.targetBytes*8/$/1e3*.98);O=Math.max(bt,Math.min(320,c))}}let P=[];if(p&&i){if(i.hdr&&n!=="hevc"&&l("zscale")&&P.push(so),o.crop?.box){let c=o.crop.box;P.push(`crop=${K(c.width)}:${K(c.height)}:${c.left}:${c.top}`)}if(y)P.push(`scale=${y.width}:${y.height}`);else if(o.resize){let c=o.resize;"width"in c?P.push(`scale=trunc(min(${K(c.width)}\\,iw)/2)*2:-2`):"height"in c?P.push(`scale=-2:trunc(min(${K(c.height)}\\,ih)/2)*2`):P.push(`scale=trunc(iw*${c.percent/100}/2)*2:-2`)}if(o.rotate&&P.push(o.rotate===90?"transpose=1":o.rotate===270?"transpose=2":"hflip,vflip"),x!==1&&P.push(`setpts=PTS/${x}`),d){let c=Math.min(io,K(i.width));P.push(`fps=${Math.min(ao,i.fps)},scale=${c}:-2:flags=lanczos,split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer:bayer_scale=4`)}}let Q=y?.fps??r.fps,Re=p&&i!==void 0&&P.length===0&&Q===void 0&&!u&&r.targetBytes===void 0&&(Kt[n]??[]).includes(i.codec),m=[],fe=!1;if(!p)m.push("-vn");else if(Re)m.push("-c:v","copy");else{if(P.length&&m.push("-vf",P.join(",")),d)m.push("-c:v","gif","-loop","0");else if(n==="webm"){if(!l("libvpx-vp9"))throw w({codec:"VP9",encoders:["libvpx-vp9"]});if(fe=b!==void 0,m.push("-c:v","libvpx-vp9","-row-mt","1","-deadline","good","-cpu-used","4"),i?.codec==="gif"&&m.push("-pix_fmt","yuva420p"),b!==void 0)m.push("-b:v",`${b}k`);else{let c=u?eo(o.quality??60):33;m.push("-crf",String(c),"-b:v","0")}}else if(n==="hevc"){let c=l("libx265"),k=h&&l("hevc_videotoolbox");if(!c&&!k)throw w({codec:"HEVC",encoders:["libx265",...h?["hevc_videotoolbox"]:[]]});if(b!==void 0)c?m.push("-c:v","libx265","-preset","fast","-b:v",`${b}k`):m.push("-c:v","hevc_videotoolbox","-b:v",`${b}k`);else if(k&&(!u||!c)){let D=u?ht(o.quality??60):60;m.push("-c:v","hevc_videotoolbox","-q:v",String(D))}else{let D=u?to(o.quality??60):26;m.push("-c:v","libx265","-crf",String(D),"-preset","fast")}m.push("-tag:v","hvc1","-pix_fmt",i?.hdr?"p010le":"yuv420p")}else{let c=u?jt(o.quality??60):21,k=()=>`${b??no(c,i?ro(i,o,y,Q,x):0)}k`;if(b===void 0&&!u&&h&&l("h264_videotoolbox"))m.push("-c:v","h264_videotoolbox","-q:v","65");else if(l("libx264"))fe=b!==void 0,b!==void 0?m.push("-c:v","libx264","-preset","medium","-b:v",`${b}k`):u?m.push("-c:v","libx264","-preset","medium","-crf",String(c)):m.push("-c:v","libx264","-preset","veryfast","-crf","21");else if(h&&l("h264_videotoolbox"))b!==void 0?m.push("-c:v","h264_videotoolbox","-b:v",k()):m.push("-c:v","h264_videotoolbox","-q:v",String(ht(o.quality??60)));else if(l("libopenh264"))m.push("-c:v","libopenh264","-b:v",k());else if(s==="win32"&&l("h264_mf"))m.push("-c:v","h264_mf","-b:v",k());else if(n==="avi")if(b!==void 0)m.push("-c:v","mpeg4","-b:v",`${b}k`);else{let D=u?oo(o.quality??60):3;m.push("-c:v","mpeg4","-q:v",String(D))}else throw w({codec:"H.264",encoders:["libx264",...h?["h264_videotoolbox"]:[],"libopenh264",...s==="win32"?["h264_mf"]:[]]});m.push("-pix_fmt","yuv420p")}Q!==void 0?m.push("-r",String(Q)):n==="avi"?m.push("-fps_mode","cfr"):d||m.push("-fps_mode","passthrough")}let $e=r.cleanup?[...Ht]:[],X=[...$e,...x!==1?wt(x):[]],N=r.loudness;N!==void 0&&X.push(`loudnorm=I=${N}:TP=-1.5:LRA=11:${we}:linear=true`);let _e=r.bitrate??F??O,ke=E&&a!==void 0&&X.length===0&&_e===void 0&&!(u&&f)&&(Yt[n]??[]).includes(a.codec),_=[];if(!E)_.push("-an");else if(ke)_.push("-c:a","copy");else{X.length&&_.push("-af",X.join(","));let c=Zt(n,s,l);if("codec"in c)throw w(c);_.push("-c:a",c.encoder);let k=_e??c.kbps;if(k!==void 0&&c.kbps!==void 0&&_.push("-b:a",`${k}k`),c.args&&_.push(...c.args),!c.args?.includes("-ac")&&F!==void 0&&F<=bt&&_.push("-ac","1"),N!==void 0&&a){let D=!c.rates||c.rates.includes(a.sampleRate);_.push("-ar",String(D?a.sampleRate:c.rates?.[0]))}}let de=[];g>0&&de.push("-ss",Xt(g)),r.cut&&de.push("-t",Qt(v));let H=[...de,"-i",e.input],G=[],pe=[...p?["-map","0:v:0"]:[],...E?["-map","0:a:0"]:[]],Me=o.keepMetadata?[]:["-map_metadata","-1"],Lt=Vt[n]??n,Oe=["mp4","hevc","mov","m4a"].includes(n)?["-movflags","+faststart"]:[],De=["-f",Lt,"-y",e.output],ue=s==="win32"?"NUL":"/dev/null",L=[];return r.cleanup&&L.push({args:[...H,...G,"-vn","-af",Gt,"-f","null",ue],measures:"noise"}),N!==void 0&&L.push({args:[...H,...G,"-vn","-af",`${[...$e,...x!==1?wt(x):[]].map(c=>`${c},`).join("")}loudnorm=I=${N}:TP=-1.5:LRA=11:print_format=json`,"-f","null",ue],measures:"loudness",pass:{at:1,of:2}}),fe?(L.push({args:[...H,...G,...pe.slice(0,2),...m,"-pass","1","-passlogfile",e.passlog,"-an","-f","null",ue],pass:{at:1,of:2}}),L.push({args:[...H,...G,...pe,...m,"-pass","2","-passlogfile",e.passlog,..._,...Me,...Oe,...De],pass:{at:2,of:2}})):L.push({args:[...H,...G,...pe,...m,..._,...Me,...Oe,...De],...N!==void 0?{pass:{at:2,of:2}}:{}}),{steps:L,duration:$,copies:{video:Re,audio:ke},...y?{fitted:y}:{}}}var C=(e,t,o)=>e.subarray(t,t+o).toString("latin1"),co=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1","avif","avis","crx "]),fo=new Set(["M4A ","M4B ","M4P ","F4A ","F4B "]);function po(e){let t=C(e,8,4);if(!co.has(t))return t==="qt "?"mov":fo.has(t)?"m4a":"mp4"}function yt(e){if(e.length<4)return;if(C(e,4,4)==="ftyp")return po(e);if(e[0]===26&&e[1]===69&&e[2]===223&&e[3]===163)return e.includes("webm",0,"latin1")?"webm":"mkv";let t=C(e,0,4);if(t==="RIFF"){let o=C(e,8,4);return o==="WAVE"?"wav":o==="AVI "?"avi":void 0}if(t==="FORM"){let o=C(e,8,4);return o==="AIFF"||o==="AIFC"?"aiff":void 0}if(t==="fLaC")return"flac";if(t==="OggS")return e.includes("OpusHead",0,"latin1")?"opus":"ogg";if(C(e,0,3)==="ID3"||e[0]===255&&((e[1]??0)&224)===224&&((e[1]??0)&6)===2)return"mp3"}var wo=["mp4","mov","webm","mkv","avi","gif"],Pt=["mp4","mov","hevc","webm","mkv","avi","gif","mp3","m4a","wav"],bo=["mp3","m4a","wav","aiff","flac","opus","ogg"],vo=["mp3","m4a","opus","flac","aiff","wav"];function yo(e){return W(e,64)}function xo(e,t){return t&&!t.video&&(e==="mp4"||e==="mov")?"m4a":e}async function Et(e,t){let o=yt(await yo(e));if(!o)throw new Error("not video or sound");if(o!=="mp4"&&o!=="mov"&&S[o].media!==t)throw new Error(`not ${t}`);let n=(await se(e)).size,s=await le(),r;if(s){try{r=await ge(e,s)}catch(a){throw j(e,a)}if(r.duration<=0||!r.video&&!r.audio)throw j(e,r)}let i=xo(o,r);if(S[i].media!==t)throw new Error(`not ${t}`);return{kind:"media",path:e,format:i,bytes:n,...r?{facts:r}:{}}}async function Po(){let{assetFor:e,catalogEntry:t}=await import("./catalog-FMHWWMUX.js"),o=t("video");return o!==void 0&&e(o)!==void 0}async function Eo(e,t){if(e.kind==="media"&&e.facts)return e.facts;try{return await ge(e.path,t)}catch(o){throw j(e.path,o)}}function Fo(e,t){let o=e.options.media??{},n=o.cut?.start??0,s=Math.min(o.cut?.end??t,t);return Math.max(0,s-n)/(o.speed??1)}function Ft(e,t){if(e.op!=="convert")return;let o=e.sources[0],n=o.kind==="media"?o.facts:void 0;if(!n)return;let s=e.options.media??{},r=ct({...n,duration:Fo(e,n.duration)},{soundOnly:S[e.target].media==="sound",mute:s.mute===!0||e.target==="gif"});return t<r?{floor:r}:void 0}function So(e){let t=e.slice(e.lastIndexOf("{"),e.lastIndexOf("}")+1),o=JSON.parse(t);return[`measured_I=${o.input_i}`,`measured_TP=${o.input_tp}`,`measured_LRA=${o.input_lra}`,`measured_thresh=${o.input_thresh}`,`offset=${o.target_offset}`].join(":")}async function xt(e){await Promise.all(e.map(t=>lo(t,{force:!0}).catch(()=>{})))}async function St(e,t,o){if(e.op!=="convert")throw new Error(`media engines only convert, not ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=await le();if(!r)throw We(n.path,process.platform,await Po());let i=await Eo(n,r),a=mo(6).toString("hex"),f=Ge(s,a),d=ho(go(s),`.forge-pass-${a}`),u=[f,`${d}-0.log`,`${d}-0.log.temp`,`${d}-0.log.mbtree`,`${d}-0.log.mbtree.temp`],h=[],l=(p,E=e.options)=>be({input:n.path,output:f,target:e.target,facts:i,options:E,platform:p,os:process.platform,passlog:d,...r.has?{has:r.has}:{}}),w=e.options,g=l(process.platform);if(g.duration<=0)throw Te(`The cut keeps nothing of ${A(n.path)}: it starts at or after its end.`,`It is ${ne(i.duration)} long.`);await Ve(s);let I=process.platform,v=w.media?.cut;if(g.copies.video&&v&&v.start>0){let p=await dt(n.path,v.start,r);p!==void 0&&v.start-p>.05&&(w={...w,media:{...w.media,cut:{...v,start:p}}},g=l(process.platform,w),h.push({code:"media-cut-keyframe",message:`It starts at ${ne(p)}, the keyframe just before ${ne(v.start)}.`}))}let x=async p=>{let E="",y="";for(let F of p.steps){let b=F.args.map(P=>P.replace(we,E).replace(he,y)),O=await pt(b,{tools:r,signal:o,report:F.measures!==void 0,onTime:P=>t({phase:"time",done:Math.min(P,p.duration),total:p.duration,...F.pass?{pass:F.pass}:{}})});F.measures==="loudness"&&(E=So(O)),F.measures==="noise"&&(y=String(vt(O)))}};try{try{await x(g)}catch(y){if(o?.aborted||!g.steps.some(F=>F.args.some(b=>b.endsWith("_videotoolbox"))))throw y;I="linux",g=l(I,w),await x(g)}let p=w.media?.targetBytes;for(let y of[.95,.9]){if(p===void 0||(await se(f)).size<=p)break;w={...w,media:{...w.media,targetBytes:Math.floor(p*y)}},g=l(I,w),await x(g)}let E=(await se(f)).size;if(p!==void 0&&E>p)throw Be(n,e.options.media?.targetBytes??p,E);if(e.options.compress!==void 0&&E>=n.bytes)throw te(n.path,n.bytes,E);await Ke(f,s)}catch(p){throw await xt(u),o?.aborted||B(p)?p:J(n.path,p)}await xt(u.slice(1));let $=i.video;if(g.fitted&&$&&(g.fitted.width<$.width-2||g.fitted.fps<$.fps)){let p=Ae(e.options.media?.targetBytes??0);h.push({code:"media-fitted",message:`To fit ${p} it is now ${g.fitted.width}\xD7${g.fitted.height} at ${g.fitted.fps} fps.`})}return{job:e,outputBytes:(await se(s)).size,warnings:h}}function Zn(e,t){if(e.kind!=="media"||!e.facts)return;let o=ft()?.has;if(o)try{be({input:e.path,output:e.path,target:t,facts:e.facts,options:{background:"#ffffff",keepMetadata:!1},platform:process.platform,passlog:"",has:o});return}catch(n){return B(n)&&n.code==="encoder-missing"?n:void 0}}var Y=e=>new Set(e);function Io(e){let t=e.kind==="media"?e.facts:void 0,o=e.kind==="image"||t!==void 0&&t.audio===void 0;return Y(Pt.filter(n=>!(o&&S[n].media==="sound"||n==="hevc"&&t?.video?.codec==="hevc")))}var It={id:"video",reads:Y(wo),writes:Y(Pt),ops:new Set(["convert"]),probe:e=>Et(e,"video"),alone:!0,run:St,sizeTo:Ft,writesFor:Io},Rt={id:"sound",reads:Y(bo),writes:Y(vo),ops:new Set(["convert"]),probe:e=>Et(e,"sound"),alone:!0,run:St,sizeTo:Ft};import{readFile as ie,rm as Mt,stat as Ro}from"node:fs/promises";function jn(e,t){let o=e.split(",").map(r=>r.trim()).filter(r=>r!=="");if(o.length===0)throw V(e,"That selects no pages.",t);let n=new Set,s=(r,i)=>{if(!Number.isInteger(r)||r<1||r>t)throw V(i,`"${i}" is outside 1 and ${t}.`,t);return r};for(let r of o){let i=r.match(/^(\d+)\s*-\s*(\d*)$/);if(i?.[1]!==void 0){let a=s(Number(i[1]),r),f=i[2]===""?t:s(Number(i[2]),r);if(f<a)throw V(r,`"${r}" ends before it starts.`,t);for(let d=a;d<=f;d++)n.add(d-1);continue}if(!/^\d+$/.test(r))throw V(r,`"${r}" is not a page number.`,t);n.add(s(Number(r),r)-1)}return[...n].sort((r,i)=>r-i)}function $t(e){return[...new Set(e)].sort((t,o)=>t-o)}function er(e){if(e.length===0)return"";let t=[...new Set(e)].sort((r,i)=>r-i),o=[],n=t[0],s=n;for(let r of t.slice(1)){if(r===s+1){s=r;continue}o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),n=r,s=r}return o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),o.join(", ")}function _t(e,t){let o=[...new Set(e)].sort((r,i)=>r-i).filter(r=>r>=0&&r<t-1),n=[],s=0;for(let r of o)n.push({from:s,to:r}),s=r+1;return n.push({from:s,to:t-1}),n}var ye=Ye(()=>import("./pdf-compress-U2E3CNXG.js")),$o=new Set(["pdf","jpeg","png","webp","avif","gif","tiff"]),_o=new Set(["pdf"]);async function U(e){return(await M()).PDFDocument.load(await ie(e),{ignoreEncryption:!0})}var ko=1024,kt=Buffer.from("%PDF-","latin1");async function Mo(e){return(await W(e,ko+kt.length)).indexOf(kt)!==-1}async function Oo(e){if(!await Mo(e))throw new Error(`${e} is not a PDF`);let{surveyDocument:t}=await ye(),o=await U(e),{size:n}=await Ro(e);return{kind:"document",path:e,format:"pdf",bytes:n,pages:o.getPageCount(),encrypted:o.isEncrypted,images:t(o)}}function z(e){for(let t of e)if(t.encrypted)throw ee(t.path)}async function Do(e,t,o){let n=await oe(),s=t.format==="jpeg"||t.format==="png",r=s?(await n(o).metadata()).orientation:void 0;if(s&&(r===void 0||r===1))return t.format==="jpeg"?e.embedJpg(o):e.embedPng(o);if(t.format==="jpeg"){let i=await n(o).rotate().jpeg({quality:S.jpeg.defaultQuality,mozjpeg:!0}).toBuffer();return e.embedJpg(i)}return e.embedPng(await n(o).rotate().png().toBuffer())}async function Ao(e,t){let o=e.sources[0];if(o.kind!=="image")throw new Error("the pdf engine cannot embed a document source");let n=[];o.frames>1&&n.push({code:"animation-flattened",message:`${A(o.path)} has ${o.frames} frames, and ${S.pdf.label} cannot animate. Only the first frame was converted.`}),t({phase:"reading"});let s=await ie(o.path);t({phase:"encoding"});let i=await(await M()).PDFDocument.create(),a=await Do(i,o,s);i.addPage([a.width,a.height]).drawImage(a,{x:0,y:0,width:a.width,height:a.height}),t({phase:"writing"});let d=await R(e.outputs[0],await i.save());return{job:e,outputBytes:d,warnings:n}}async function Bo(e,t){z(e.sources.filter(i=>i.kind==="document"));let n=await(await M()).PDFDocument.create();for(let i of e.sources){t({phase:"reading"});let a=await U(i.path),f=await n.copyPages(a,a.getPageIndices());for(let d of f)n.addPage(d)}t({phase:"writing"});let s=await n.save(),r=await R(e.outputs[0],s);return{job:e,outputBytes:r,warnings:[]}}async function To(e,t){let o=e.sources[0];z([o]);let n=await M();t({phase:"reading"});let s=await U(o.path),r=_t(e.cuts,s.getPageCount()),i=[],a=0;try{for(let[f,d]of r.entries()){let u=await n.PDFDocument.create(),h=Array.from({length:d.to-d.from+1},(g,I)=>d.from+I),l=await u.copyPages(s,h);for(let g of l)u.addPage(g);let w=e.outputs[f];if(w===void 0)throw new Error(`split produced ${r.length} parts but was given ${e.outputs.length} outputs`);a+=await R(w,await u.save()),i.push(w),t({phase:"page",done:f+1,total:r.length})}}catch(f){throw await Promise.all(i.map(d=>Mt(d,{force:!0}))),f}return{job:e,outputBytes:a,warnings:[]}}async function ve(e,t){let n=await(await M()).PDFDocument.create(),s=await n.copyPages(e,t);for(let r of s)n.addPage(r);return n.save()}async function No(e,t){let o=e.sources[0];if(z([o]),e.pages.length===0)throw me("That extract selects no pages.");t({phase:"reading"});let n=await U(o.path),s=$t(e.pages),r=[],i=0;try{if(e.separate)for(let[a,f]of s.entries()){let d=e.outputs[a];i+=await R(d,await ve(n,[f])),r.push(d),t({phase:"page",done:a+1,total:s.length})}else{t({phase:"writing"});let a=e.outputs[0];i=await R(a,await ve(n,s)),r.push(a)}}catch(a){throw await Promise.all(r.map(f=>Mt(f,{force:!0}))),a}return{job:e,outputBytes:i,warnings:[]}}async function Lo(e,t){let o=e.sources[0];z([o]),t({phase:"reading"});let n=await U(o.path),s=new Set(e.pages),r=n.getPageIndices().filter(a=>!s.has(a));if(r.length===0)throw me("That would delete every page.");t({phase:"writing"});let i=await R(e.outputs[0],await ve(n,r));return{job:e,outputBytes:i,warnings:[]}}async function Jo(e,t){let o=e.sources[0];z([o]);let n=await M();t({phase:"reading"});let s=await U(o.path);for(let i of s.getPages()){let f=((i.getRotation().angle+e.turns*90)%360+360)%360;i.setRotation(n.degrees(f))}t({phase:"writing"});let r=await R(e.outputs[0],await s.save());return{job:e,outputBytes:r,warnings:[]}}async function Wo(e,t){let o=e.sources[0];z([o]);let{compressPdf:n}=await ye();t({phase:"reading"});let s=await ie(o.path);t({phase:"encoding"});let{bytes:r,recompressed:i,skipped:a,fromDpi:f,toDpi:d}=await n(s,{quality:e.options.quality??60,dpi:e.options.dpi??150});if(e.options.compress&&r.length>=o.bytes)throw te(o.path,o.bytes,r.length);t({phase:"writing"});let u=await R(e.outputs[0],r),h=w=>w===1?"":"s",l=[];return i===0&&a===0?l.push({code:"pdf-no-images",message:"This PDF has no images to re-encode, so its size is almost unchanged."}):i===0?l.push({code:"pdf-no-images",message:`None of its ${a} image${h(a)} could be re-encoded \u2014 they are not JPEG data.`}):a>0&&l.push({code:"pdf-images-skipped",message:`${i} image${h(i)} recompressed, ${a} skipped (not JPEG).`}),f!==void 0&&d!==void 0&&l.push({code:"pdf-downsampled",message:`Images reduced from ${f} to ${d} dpi. Pass --dpi ${f} to keep them.`}),{job:e,outputBytes:u,warnings:l}}async function Co(e){if(e.op!=="convert")return;let t=e.sources[0];if(t.kind!=="document")return;let{compressPdf:o}=await ye(),n=await ie(t.path);return{ladder:[e.options.dpi??150,120,96,72].map(s=>({dpi:s})),measure:async s=>(await o(n,{quality:s.quality??60,...s.dpi===void 0?{}:{dpi:s.dpi}})).bytes.byteLength}}var Ot={id:"pdf",measurer:Co,reads:$o,writes:_o,ops:new Set(["convert","merge","split","extract","delete","rotate"]),probe:Oo,async run(e,t){switch(e.op){case"convert":if(e.target!=="pdf")throw new Error("the pdf engine only converts to pdf");return e.sources[0].kind==="document"?Wo(e,t):Ao(e,t);case"merge":return Bo(e,t);case"split":return To(e,t);case"extract":return No(e,t);case"delete":return Lo(e,t);case"rotate":return Jo(e,t);default:throw new Error(`the pdf engine cannot ${e.op}`)}}};import{execFile as Uo}from"node:child_process";import{mkdtemp as zo,readFile as Se,rm as qo}from"node:fs/promises";import{tmpdir as Ho}from"node:os";import{basename as Go,extname as Vo,join as Dt,win32 as Ee}from"node:path";import{pathToFileURL as Ko}from"node:url";import{promisify as Yo}from"node:util";var Fe=Yo(Uo),q=Buffer.from([208,207,17,224,161,177,26,225]);async function Zo(e){if(e.length<q.length||!e.subarray(0,q.length).equals(q))return!1;let t=await je();try{return t.find(t.parse(e),"WordDocument")!==null}catch{return!1}}async function Qo(e){let t=await Xe();try{let o=new t(e);if(!o.getEntry("word/document.xml"))return;let n=0,s=o.getEntry("docProps/app.xml");if(s){let r=/<Pages>(\d+)<\/Pages>/.exec(o.readAsText(s));r?.[1]&&(n=Number(r[1]))}return{pages:n}}catch{return}}var At=Buffer.from([80,75,3,4]);async function Xo(e){let t=await W(e,q.length);return t.subarray(0,At.length).equals(At)||t.subarray(0,q.length).equals(q)}async function jo(e){if(!await Xo(e))throw new Error(`${e} is not a Word document`);let t=await Se(e),o=await Qo(t);if(o)return{kind:"document",path:e,format:"docx",bytes:t.byteLength,pages:o.pages,encrypted:!1};if(await Zo(t))return{kind:"document",path:e,format:"doc",bytes:t.byteLength,pages:0,encrypted:!1};throw new Error(`${e} is not a Word document`)}function en(e,t){return e==="win32"?[Ee.join(t.ProgramFiles??"C:\\Program Files","LibreOffice","program","soffice.exe"),Ee.join(t["ProgramFiles(x86)"]??"C:\\Program Files (x86)","LibreOffice","program","soffice.exe")]:["/Applications/LibreOffice.app/Contents/MacOS/soffice"]}var tn=0;async function on(){tn++;try{return await Fe("soffice",["--version"],{timeout:5e3}),"soffice"}catch{}for(let e of en(process.platform,process.env))try{return await Fe(e,["--version"],{timeout:5e3}),e}catch{}}var Bt,nn=!1,rn;async function sn(){return nn?rn:(Bt??=on(),Bt)}var Ie="\f";function ae(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)}async function an(e){if(e.format==="docx"){let o=await Ze(),{value:n}=await o.extractRawText({path:e.path});return ae(n)}if(e.format==="doc"){let o=await Qe(),s=await new o().extract(e.path);return ae(s.getBody())}return(await st(await Se(e.path))).flatMap((o,n)=>n===0?ae(o):[Ie,...ae(o)])}var xe=612,ce=792,T=54,Pe=11,Tt=14;async function cn(e){let{PDFDocument:t,StandardFonts:o}=await M(),n=await t.create(),s=await n.embedFont(o.Helvetica),r=xe-T*2,i=n.addPage([xe,ce]),a=ce-T,f=()=>{i=n.addPage([xe,ce]),a=ce-T};for(let d of e){if(d===Ie){f();continue}let u="";for(let h of d.split(/\s+/).filter(Boolean)){let l=u?`${u} ${h}`:h;u&&s.widthOfTextAtSize(l,Pe)>r?(a<T&&f(),i.drawText(u,{x:T,y:a,size:Pe,font:s}),a-=Tt,u=h):u=l}u&&(a<T&&f(),i.drawText(u,{x:T,y:a,size:Pe,font:s}),a-=Tt)}return n.save()}async function fn(e){let{Document:t,Packer:o,PageBreak:n,Paragraph:s}=await et(),r=e.map(a=>a===Ie?new s({children:[new n]}):new s(a)),i=new t({sections:[{children:r}]});return o.toBuffer(i)}var dn=new Set(["docx","doc","pdf"]),pn=new Set(["docx","pdf"]),un=new Set(["convert"]),mn={code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: brew install --cask libreoffice"};function ln(e=process.platform){return e==="linux"?{code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: sudo apt install libreoffice"}:e!=="win32"?mn:{code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice from libreoffice.org for full-fidelity conversion."}}function gn(e,t,o,n=process.platform){return[`-env:UserInstallation=${n==="win32"?Ko(Ee.join(e,"profile"),{windows:!0}).href:`file://${e}/profile`}`,"--headless","--convert-to",o,"--outdir",e,t]}async function hn(e,t,o){let n=await zo(Dt(Ho(),"forge-word-"));try{await Fe(e,gn(n,t,o),{timeout:12e4});let s=Go(t,Vo(t));return await Se(Dt(n,`${s}.${o}`))}finally{await qo(n,{recursive:!0,force:!0})}}async function wn(e,t){if(e.op!=="convert")throw new Error(`the word engine cannot ${e.op}`);let o=e.sources[0];if(o.kind!=="document")throw new Error("the word engine can only convert a document source");if(o.encrypted)throw ee(o.path);t({phase:"reading"});let n=await sn();t({phase:"encoding"});let s=[],r;try{if(n!==void 0)r=await hn(n,o.path,e.target);else{let a=await an(o);r=e.target==="pdf"?await cn(a):await fn(a),s.push(ln())}}catch(a){throw J(o.path,a)}t({phase:"writing"});let i=await R(e.outputs[0],r);return{job:e,outputBytes:i,warnings:s}}var Nt={id:"word",reads:dn,writes:pn,ops:un,probe:jo,run:wn};var Z=[rt,It,Rt,Ot,Nt,lt,it];function kr(e){return Z.find(t=>t.reads.has(e))}function Mr(e){return Z.find(t=>t.writes.has(e))}function Or(e){if(e.op==="convert"){let t=e.sources[0].format;return Z.find(o=>o.reads.has(t)&&o.writes.has(e.target))}return Z.find(t=>t.ops.has(e.op))}async function Dr(e){let t;for(let o of Z)try{return await o.probe(e)}catch(n){B(t)||(t=n)}throw t}export{jn as a,$t as b,er as c,_t as d,Zn as e,Z as f,kr as g,Mr as h,Or as i,Dr as j};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{b as h,c as A,g as o,m as y,n as I,
|
|
3
|
+
import{b as h,c as A,g as o,m as y,n as I,t as v,u as O,v as P}from"./chunk-3GHHQNR6.js";import{a as x,b as u,d as S}from"./chunk-EPDF4NQI.js";import{g as s,h as f,j as g,k as b,l as c,m as a}from"./chunk-BIBDLXCG.js";import{E as d}from"./chunk-CVNYUROW.js";var l=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0,k={id:"split",label:"Split",verb:"Splitting",hint:"into several files",appliesTo:e=>(l(e)?.pages??0)>1,unavailable:e=>l(e)===void 0?"one PDF at a time":"only one page",options(e){let t=l(e);return t?[{kind:"select",id:"mode",label:"How",default:"every-page",choices:[{value:"every-page",label:"Every page",hint:`${t.pages} files`},{value:"every-n",label:"Every N pages",hint:"ask how many"},{value:"points",label:"At points I choose",hint:"grid"}]}]:[]},plan(e,t){let n=l(e);if(!n)return[];let r=Array.isArray(t.cuts)?t.cuts:[],i=S(r,n.pages).length,C=c(f(n.path,i),o(t.destination),o(t.name));return[{op:"split",sources:[n],outputs:C,cuts:r}]}};function $(e){return Array.from({length:Math.max(0,e-1)},(t,n)=>n)}function B(e,t){if(!Number.isInteger(t)||t<1)throw d("Splitting every N pages needs N to be a whole number, at least 1.");let n=[];for(let r=t;r<e;r+=t)n.push(r-1);return n}var p=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0;function D(e,t){return Array.isArray(t.pages)?u(t.pages):typeof t.pages=="string"?u(x(t.pages,e.pages)):[]}var w=e=>({kind:"text",id:"pages",label:"Pages",placeholder:`1-${e.pages}`}),T={id:"extract",label:"Extract",verb:"Extracting",hint:"keep only some pages",appliesTo:e=>p(e)!==void 0,unavailable:()=>"one PDF at a time",options:e=>{let t=p(e);return t?[w(t),{kind:"select",id:"separate",label:"Output",default:"one",choices:[{value:"one",label:"One file",hint:"all selected pages together"},{value:"many",label:"Separate files",hint:"one per page"}]}]:[]},plan(e,t){let n=p(e);if(!n)return[];let r=D(n,t),i=t.separate==="many";return[{op:"extract",sources:[n],outputs:c(g(n.path,r,i),o(t.destination),o(t.name)),pages:r,separate:i}]}},j={id:"delete",label:"Delete",verb:"Deleting",hint:"drop some pages",appliesTo:e=>p(e)!==void 0,unavailable:()=>"one PDF at a time",options:e=>{let t=p(e);return t?[w(t)]:[]},plan(e,t){let n=p(e);return n?[{op:"delete",sources:[n],outputs:[a(s(n.path,"trimmed"),o(t.destination),o(t.name))],pages:D(n,t)}]:[]}};var m=e=>e.filter(t=>t.kind==="document"&&t.format==="pdf"),J={id:"merge",label:"Merge",verb:"Merging",hint:"several files into one",appliesTo:e=>m(e).length>=2&&m(e).length===e.length,unavailable:e=>m(e).length!==e.length?"PDFs only":"needs 2+ files",options:()=>[],plan(e,t){let n=a(b(e.map(r=>r.path)),o(t.destination),o(t.name));return[{op:"merge",sources:e,outputs:[n]}]}};var N=e=>e.length===1&&e[0]?.kind==="document"&&e[0].format==="pdf"?e[0]:void 0,E={id:"rotate",label:"Rotate",verb:"Rotating",hint:"turn pages",appliesTo:e=>N(e)!==void 0,unavailable:()=>"one PDF at a time",options:()=>[{kind:"select",id:"degrees",label:"Turn",default:"90",choices:[{value:"90",label:"90\xB0 right",hint:"a quarter turn"},{value:"180",label:"180\xB0",hint:"upside down"},{value:"270",label:"90\xB0 left",hint:"a quarter turn back"}]}],plan(e,t){let n=N(e);if(!n)return[];let i=Number(t.degrees??90)/90%4||1;return[{op:"rotate",sources:[n],outputs:[a(s(n.path,"rotated"),o(t.destination),o(t.name))],turns:i}]}};var R=[I,y,J,k,T,j,E,v,O,P],se=R.filter(e=>!["convert","compress","trim","resize","crop"].includes(e.id)),F=[h,A];function ce(e,t=new Set){return[...R,...F.filter(n=>n.requires&&t.has(n.requires))].filter(n=>n.appliesTo(e))}function le(e,t){return e.appliesTo(t)?void 0:e.unavailable?.(t)}export{E as a,k as b,$ as c,B as d,R as e,se as f,ce as g,le as h};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as $,h as at,i as _}from"./chunk-
|
|
3
|
+
import{a as $,h as at,i as _}from"./chunk-VTA6Z45X.js";import{b as d,c as R,d as P,f as v,g as H,h as X}from"./chunk-QVACE4IE.js";import{j as st}from"./chunk-EPDF4NQI.js";import{g as ot}from"./chunk-7KYO62XK.js";import{a as tt,j as et,t as nt}from"./chunk-CVNYUROW.js";import{a as Z}from"./chunk-H3DIRJFE.js";import{b as rt}from"./chunk-KXKQDFHX.js";var xt=[[15,"rose"],[45,"red"],[70,"orange"],[95,"amber"],[120,"yellow"],[140,"lime"],[165,"green"],[185,"teal"],[215,"cyan"],[250,"sky"],[280,"blue"],[295,"indigo"],[315,"violet"],[340,"purple"],[355,"pink"],[360,"rose"]];function w(t){let{C:e,h:n}=v(R(t));return e<.03?"grey":D(n)}function D(t){let e=(t%360+360)%360;return(xt.find(([n])=>e<n)??[360,"rose"])[1]}var Ft=["full","mono","analogous","opposite","split","triad","pastel"],it={full:"Full set",mono:"Monochromatic",analogous:"Analogous",opposite:"Complementary",split:"Split complementary",triad:"Triadic",pastel:"Pastel"},B={brightness:0,saturation:0,hue:0,contrast:0},vt=t=>!!(t.brightness||t.saturation||t.hue||t.contrast),G=[{name:"red",hex:{r:251,g:44,b:54},role:"danger"},{name:"orange",hex:{r:255,g:105,b:0}},{name:"yellow",hex:{r:239,g:177,b:0},role:"warning"},{name:"green",hex:{r:0,g:201,b:80},role:"success"},{name:"teal",hex:{r:0,g:187,b:167}},{name:"blue",hex:{r:43,g:127,b:255},role:"info"},{name:"purple",hex:{r:173,g:70,b:255}},{name:"pink",hex:{r:246,g:51,b:154}}],bt={analogous:[-30,0,30],opposite:[0,180],split:[0,150,210],triad:[0,120,240]},dt=.553,$t=.024,b=t=>v(R(t)),C=(t,e,n)=>P(H({L:t,C:Math.max(0,e),h:(n+360)%360})),K=(t,e)=>(t-e+540)%360-180;function lt(t,e,n){let r=H({L:t,C:e,h:n}),o=R(P(r));return Math.hypot(o.L-r.L,o.a-r.a,o.b-r.b)<.003}function L(t,e){let n=0,r=.4;for(let o=0;o<30;o++){let a=(n+r)/2;lt(t,a,e)?n=a:r=a}return n}function W({L:t,C:e,h:n}){let r=L(t,n);return r>0?Math.min(1,e/r):0}var A=(t,e)=>e>=0?t+(.98-t)*(e/100):t+(t-.05)*(e/100),q=(t,e,n)=>n>=0?t+(Math.max(t,e)-t)*(n/100):t*(1+n/100);function T(t,e){if(!(e.brightness||e.saturation||e.hue))return t;let{L:n,C:r,h:o}=b(t),a=A(n,e.brightness),i=(o+e.hue+360)%360,l=q(r,L(a,i),e.saturation);for(let s=0;s<40&&l>0&&!lt(a,l,i);s++)l-=.005;return C(a,l,i)}function k(t,e,n,r){let o=A(t,r.brightness),a=(n+r.hue+360)%360,i=L(o,a);return C(o,Math.min(i,q(e,i,r.saturation)),a)}function Y(t,e,n){if(!e)return t;let r=b(t[n].rgb).L;return t.map((o,a)=>{if(a===n)return o;let i=b(o.rgb),l=Math.max(.02,Math.min(.995,r+(i.L-r)*(1+e/100))),s=C(l,Math.min(i.C,L(l,i.h)),i.h);return{...o,rgb:s,hex:d(s)}})}function Tt(t,e,n,r){return Y(t(T(e,n)),n.contrast,r)}function ct(t,e){let n=b(t),r=G.map(s=>b(s.hex)),o=0;r.forEach((s,c)=>{Math.abs(K(n.h,s.h))<Math.abs(K(n.h,r[o].h))&&(o=c)});let a=r[o],i=Math.max(-10,Math.min(10,K(n.h,a.h)/2)),l=W(n);return G.map((s,c)=>{if(c===o)return{name:s.name,role:s.role,rgb:T(t,e),yours:!0};let h=r[c],p=n.L>=a.L?h.L+(n.L-a.L)*(1-h.L)/(1-a.L):h.L*n.L/a.L,f=A(p,e.brightness),g=(h.h+i+e.hue+360)%360,x=L(f,g),u=Math.min(1,W(h)),S=Math.min(x,q(l*u*x,x,e.saturation));return{name:s.name,role:s.role,rgb:C(f,S,g),yours:!1}})}function wt(t,e,n){let r=b(t),o=w(t);if(e==="mono")return[{name:o,rgb:T(t,n),yours:!0},{name:`${o} soft`,rgb:k(r.L,r.C*.5,r.h,n),yours:!1},{name:`${o} dusty`,rgb:k(r.L,r.C*.22,r.h,n),yours:!1}];if(e==="pastel")return ct(t,B).map((l,s)=>{let c=b(l.rgb),h=c.C<.01?b(G[s].hex).h:c.h;return{...l,rgb:k(.86,Math.min(.1,L(.86,h))*.85,h,n)}});let a=W(r);return(bt[e]??[0]).map(l=>{if(l===0)return{name:o,rgb:T(t,n),yours:!0};let s=(r.h+l+360)%360,c=a*L(r.L,s);return{name:a>0?D(s):w(k(r.L,c,s,B)),rgb:k(r.L,c,s,n),yours:!1}}).sort((l,s)=>Number(s.yours)-Number(l.yours))}function yt(t,e,n){let r=b(t).h+e.hue,o=Math.max(0,$t*(1+e.saturation/100));return _(C(A(dt,e.brightness),o,r),n)}function At(t,e,n=B,r=$){let o=at(r);return{rows:(e==="full"?ct(t,n):wt(t,e,n)).map(({name:l,role:s,rgb:c,yours:h})=>({name:l,...s?{role:s}:{},steps:Y(_(c,r),n.contrast,o),yours:h})),neutral:Y(yt(t,n,r),n.contrast,o)}}var M=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),E=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"colour",y='font-family="Inter"',O=t=>`${t[0]?.toUpperCase()??""}${t.slice(1)}`;function ht(t){let e=t==="dark";return{ink:e?"#FAFAFA":"#111111",grey:e?"#A1A1AA":"#71717A",edge:e?"#FFFFFF":"#000000",paper:e?"#18181B":"#FFFFFF"}}var St=`<defs><pattern id="checker" width="16" height="16" patternUnits="userSpaceOnUse"><rect width="16" height="16" fill="#FFFFFF"/><rect width="8" height="8" fill="#E5E5E5"/><rect x="8" y="8" width="8" height="8" fill="#E5E5E5"/></pattern></defs>
|
|
4
4
|
`;function I(t,e,n,r="light"){let{ink:o,grey:a,edge:i,paper:l}=ht(r),s=n.length>8?64:104,c=10,h=48+n.length*s+Math.max(0,n.length-1)*c,p=84+s+56,f=s>80?12:10,g=`<text id="title" x="24" y="38" ${y} font-size="15" font-weight="600" fill="${o}">${M(t)}</text><text id="subtitle" x="24" y="58" ${y} font-size="12" fill="${a}">${M(e)}</text>`,x=n.map((u,S)=>`<g id="${E(u.id)}" transform="translate(${24+S*(s+c)} 80)">`+(u.alpha===void 0?"":`<rect id="checker" width="${s}" height="${s}" rx="${f}" fill="url(#checker)"/>`)+`<rect id="swatch" width="${s}" height="${s}" rx="${f}" fill="${u.hex}"`+(u.alpha===void 0?"":` fill-opacity="${u.alpha.toFixed(3)}"`)+` stroke="${i}" stroke-opacity="0.08"/><text id="name" x="1" y="${s+22}" ${y} font-size="13" font-weight="600" fill="${o}">${M(u.name)}</text><text id="value" x="1" y="${s+40}" ${y} font-size="11" fill="${a}">${M(u.value)}</text></g>`).join(`
|
|
5
5
|
`);return`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${p}" viewBox="0 0 ${h} ${p}">
|
|
6
6
|
`+(n.some(u=>u.alpha!==void 0)?St:"")+`<g id="${E(t)}">
|
|
@@ -16,4 +16,4 @@ ${mt}
|
|
|
16
16
|
<g id="steps">${gt}</g>
|
|
17
17
|
${pt}
|
|
18
18
|
</g>
|
|
19
|
-
</svg>`}function Ht(t,e,n,r="light",o=$){return I(`${O(w(t))} neutral`,`from ${d(t)} \xB7 ${n} tint \xB7 ${N(o)} in OKLCH`,e.map(a=>({id:`neutral-${a.step}`,name:String(a.step),value:a.hex,hex:a.hex})),r)}function _t(t,e,n,r="light",o=$){let a=w(t);return I(`${O(a)} alpha`,`from ${d(t)} \xB7 over ${n} \xB7 ${N(o)}`,e.map(i=>({id:`${a}-alpha-${i.step}`,name:String(i.step),value:i.hex8,hex:d(i.rgb),alpha:i.a})),r)}async function qt(t,e=192){let n=await st(t);if(n.kind!=="image")throw et(t,`a ${Z[n.format].label}`);let r=await ot(t,n.format);try{let o=await rt(),{data:a,info:i}=await o(r
|
|
19
|
+
</svg>`}function Ht(t,e,n,r="light",o=$){return I(`${O(w(t))} neutral`,`from ${d(t)} \xB7 ${n} tint \xB7 ${N(o)} in OKLCH`,e.map(a=>({id:`neutral-${a.step}`,name:String(a.step),value:a.hex,hex:a.hex})),r)}function _t(t,e,n,r="light",o=$){let a=w(t);return I(`${O(a)} alpha`,`from ${d(t)} \xB7 over ${n} \xB7 ${N(o)}`,e.map(i=>({id:`${a}-alpha-${i.step}`,name:String(i.step),value:i.hex8,hex:d(i.rgb),alpha:i.a})),r)}async function qt(t,e=192){let n=await st(t);if(n.kind!=="image")throw et(t,`a ${Z[n.format].label}`);let r=await ot(t,n.format);try{let o=await rt(),{data:a,info:i}=await o(r,{animated:!1}).rotate().resize(e,e,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:n,pixels:{width:i.width,height:i.height,rgba:new Uint8Array(a.buffer,a.byteOffset,a.length)}}}catch(o){throw tt(o)?o:nt(t,o)}}export{Ft as a,it as b,B as c,vt as d,Tt as e,At as f,I as g,Ut as h,jt as i,Pt as j,Ht as k,_t as l,qt as m};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as i,e as s,f as o}from"./chunk-N6RCLJE6.js";import{
|
|
3
|
+
import{c as i,e as s,f as o}from"./chunk-N6RCLJE6.js";import{E as n}from"./chunk-CVNYUROW.js";var g=["output","theme","quality","update-check"];async function p(a){if(a.action==="path")return{stdout:[i()],exitCode:0,config:{path:i()},warnings:[]};if(a.action==="list"){let{prefs:e,warning:u}=await s(),f=[`output ${e.defaultOutput}`,`theme ${e.theme??"not set"}`,`quality ${e.quality}`,`update-check ${e.updateCheck===!1?"off":"on"}`,"",i()];return u!==void 0&&f.unshift(`\u26A0 ${u}`,""),{stdout:f,exitCode:0,config:{output:e.defaultOutput,theme:e.theme??null,quality:e.quality,"update-check":e.updateCheck===!1?"off":"on",path:i()},warnings:u===void 0?[]:[{code:"config-unreadable",message:u}]}}let{key:r,value:t}=a;if(r==="theme"){if(t!=="dark"&&t!=="light")throw n(`Theme must be dark or light, not ${t}.`);return await o({theme:t}),{stdout:[`theme is now ${t}`],exitCode:0,config:{theme:t},warnings:[]}}if(r==="quality"){let e=Number(t);if(!Number.isInteger(e)||e<1||e>100)throw n(`Quality must be a whole number between 1 and 100, not ${t}.`);return await o({quality:e}),{stdout:[`quality is now ${e}`],exitCode:0,config:{quality:e},warnings:[]}}if(r==="update-check"){if(t!=="on"&&t!=="off")throw n(`update-check must be on or off, not ${t}.`);return await o({updateCheck:t==="on"}),{stdout:[`update-check is now ${t}`],exitCode:0,config:{"update-check":t},warnings:[]}}if(t.trim().length===0)throw n("Output must be a folder path.");return await o({defaultOutput:t}),{stdout:[`output is now ${t}`],exitCode:0,config:{output:t},warnings:[]}}export{g as a,p as b};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{
|
|
3
|
+
import{m as l}from"./chunk-TFOEI5VF.js";import{r as f}from"./chunk-BIBDLXCG.js";import{v as m}from"./chunk-CVNYUROW.js";import{b as g,d as w}from"./chunk-KXKQDFHX.js";import{readFile as D,rm as E}from"node:fs/promises";var b=new Set(["pdf"]),x=new Set(["jpeg","png"]),I=new Set(["convert"]),y;function R(){return y??=w().then(t=>t.PDFiumLibrary.init()),y}async function h(t,r){return await(await R()).loadDocument(t,r)}async function J(t){let r=await h(t);try{let e=[];for(let n=0;n<r.getPageCount();n++)e.push(r.getPage(n).getText());return e}finally{r.destroy()}}var T={id:"pdfium",reads:b,writes:x,ops:I,probe(){throw new Error("pdfium does not probe; engines/pdf.ts classifies PDFs")},async run(t,r){if(t.op!=="convert")throw new Error(`pdfium cannot ${t.op}`);let e=t.sources[0];if(e.kind!=="document")throw new Error("the pdfium engine can only rasterise a document source");if(e.encrypted&&t.options.password===void 0)throw m(e.path);let n=t.options.dpi??150,i=t.options.pages??Array.from({length:e.pages},(o,a)=>a);if(i.length!==t.outputs.length)throw new Error(`pdfium was given ${i.length} pages but ${t.outputs.length} outputs`);for(let o of i)if(o<0||o>=e.pages)throw new Error(`pdfium was asked for page ${o}, but ${e.path} has ${e.pages} pages`);let P=await g(),d=await h(await D(e.path),t.options.password);try{let o=[],a=0;try{for(let[s,p]of i.entries()){let u=await d.getPage(p).render({scale:n/72,render:"bitmap",transparent:!0}),F=P(u.data,{raw:{width:u.width,height:u.height,channels:4}}).flatten({background:t.options.background}),S=await l(F,t.target,t.options.quality).toBuffer(),c=t.outputs[s];a+=await f(c,S),o.push(c),r({phase:"page",done:s+1,total:i.length})}}catch(s){throw await Promise.all(o.map(p=>E(p,{force:!0}))),s}return{job:t,outputBytes:a,warnings:[]}}finally{d.destroy()}}};export{h as a,J as b,T as c};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as E}from"./chunk-O7DK3GJT.js";import{i as R}from"./chunk-EPDF4NQI.js";import{a as F,ka as y}from"./chunk-CVNYUROW.js";function P(n=process.env){let r=Number(n.UV_THREADPOOL_SIZE),o=E();return Number.isInteger(r)&&r>0?Math.min(o,r):o}function w(n){let r=n!==void 0&&Number.isFinite(n)?n:void 0;return Math.max(1,r??P())}async function x(n,r,o,f){let b=[],l=[];for(let[i,u]of n.entries())(f?.(u)?l:b).push(i);let p=0,m=0,t,g=async()=>{for(;;){let i=b[p],u=t?void 0:l[m];if(i!==void 0&&(u===void 0||i<u))p++,await o(n[i],i);else if(u!==void 0)m++,t=o(n[u],u).finally(()=>{t=void 0}),await t;else if(t)await t;else return}},d=Math.min(w(r),n.length);await Promise.all(Array.from({length:d},g))}async function T(n,r){let o=r.onEvent??(()=>{}),f=r.engineFor??R,b=w(r.concurrency),l=n.length,p=[],m=[],t=0;await x(n,b,async(e,a)=>{if(r.signal?.aborted)return;o({type:"job:start",job:e,index:a,total:l});let h=f(e);if(!h){t++;let s=e.sources[0].path,c={path:s,error:y(s,new Error(`no engine runs ${e.op}`))};m[a]=c,o({type:"job:error",job:e,failure:c,completed:t,total:l});return}try{let s=await h.run(e,c=>o({type:"job:phase",job:e,progress:c}),r.signal);p[a]=s,t++,o({type:"job:done",job:e,result:s,completed:t,total:l})}catch(s){t++;let c=e.sources[0].path,J=F(s)?s:y(c,s),v={path:c,error:J};m[a]=v,o({type:"job:error",job:e,failure:v,completed:t,total:l})}},e=>f(e)?.alone===!0);let d=p.filter(e=>e!==void 0),i=m.filter(e=>e!==void 0),u={results:d,failures:i,inputBytes:d.reduce((e,a)=>e+a.job.sources[0].bytes,0),outputBytes:d.reduce((e,a)=>e+a.outputBytes,0)};return o({type:"batch:done",summary:u}),u}export{P as a,w as b,x as c,T as d};
|