forge-terminal 0.3.3 → 0.3.5

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 CHANGED
@@ -43,7 +43,7 @@ That puts `forge` on your `PATH`, so it works from any directory. Verify:
43
43
 
44
44
  ```bash
45
45
  forge --version
46
- # 0.3.3
46
+ # 0.3.5
47
47
 
48
48
  forge photo.jpg --to webp
49
49
  ```
@@ -933,7 +933,7 @@ photo.png · PNG · 122 KB · 2756×774
933
933
  With `--json`:
934
934
 
935
935
  ```json
936
- {"forge":"0.3.3","ok":true,"probes":[{"path":"/Users/me/photo.png","kind":"image","format":"png","bytes":122449,"width":2756,"height":774,"targets":["jpeg","png","webp","avif","gif","tiff","pdf"],"actions":["convert"]}],"failures":[]}
936
+ {"forge":"0.3.5","ok":true,"probes":[{"path":"/Users/me/photo.png","kind":"image","format":"png","bytes":122449,"width":2756,"height":774,"targets":["jpeg","png","webp","avif","gif","tiff","pdf"],"actions":["convert"]}],"failures":[]}
937
937
  ```
938
938
 
939
939
  `targets` and `actions` come from the engines' own capabilities, so they are
@@ -959,7 +959,7 @@ succeeded) and `failures`. A conversion, compression or page operation adds
959
959
 
960
960
  ```jsonc
961
961
  {
962
- "forge": "0.3.3",
962
+ "forge": "0.3.5",
963
963
  "ok": false,
964
964
  "results": [
965
965
  {
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
3
  import"./chunk-TMUK2DD3.js";import{readFile as x}from"node:fs/promises";import{dirname as m,join as u}from"node:path";import{fileURLToPath as C}from"node:url";var c=[{name:"sharp \xB7 libvips",licence:"Apache-2.0 \xB7 LGPL-3.0",does:"images",packages:["sharp"]},{name:"PDFium",licence:"BSD-3-Clause",does:"PDF pages",packages:[]},{name:"pdf-lib",licence:"MIT",does:"writing PDFs",packages:["pdf-lib"]},{name:"mammoth \xB7 docx",licence:"BSD-2-Clause \xB7 MIT",does:"Word documents",packages:["mammoth","docx"]},{name:"Ink \xB7 React",licence:"MIT",does:"this screen",packages:["ink","react"]}],g=[{name:"@hyzyla/pdfium",licence:"MIT"}],h=[{name:"xkcd colour survey",licence:"CC0-1.0"}];function l(n){let t=[];for(let e of n.split(`
4
- `)){let i=/^((?:@[^/\s]+\/)?[^@\s]+)@\S+ — (.+)$/.exec(e);i&&t.push({name:i[1],licence:i[2].replace(/^\((.*)\)$/,"$1")})}return t}var d=n=>n.name.replace(/^@/,"");function p({bundled:n,extensions:t}){let e=new Set(c.flatMap(s=>s.packages)),i=[...n.filter(s=>!e.has(s.name)),...g,...h].sort((s,r)=>d(s).localeCompare(d(r)));return[{title:"App",credits:c.map(({packages:s,...r})=>r)},...t.length>0?[{title:"Extensions",credits:t}]:[],{title:"Others",credits:i}]}var f="third-party-licenses.txt";function y(n){let t=[],e=m(n);for(let i=0;i<4;i++)t.push(u(e,f),u(e,"dist",f)),e=m(e);return t}async function k(n){for(let t of y(C(n))){let e=await x(t,"utf8").catch(()=>{});if(e!==void 0)return{path:t,text:e}}}async function I({from:n=import.meta.url,list:t=async()=>(await import("./manager-XN7WNMEW.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-4OWNFLEI.js"),r=i.filter(o=>o.installed!==void 0).flatMap(o=>s(o.entry)),a=p({bundled:l(e?.text??""),extensions:r});return e?{sections:a,file:e.path}:{sections:a}}export{I as loadCredits};
4
+ `)){let i=/^((?:@[^/\s]+\/)?[^@\s]+)@\S+ — (.+)$/.exec(e);i&&t.push({name:i[1],licence:i[2].replace(/^\((.*)\)$/,"$1")})}return t}var d=n=>n.name.replace(/^@/,"");function p({bundled:n,extensions:t}){let e=new Set(c.flatMap(s=>s.packages)),i=[...n.filter(s=>!e.has(s.name)),...g,...h].sort((s,r)=>d(s).localeCompare(d(r)));return[{title:"App",credits:c.map(({packages:s,...r})=>r)},...t.length>0?[{title:"Extensions",credits:t}]:[],{title:"Others",credits:i}]}var f="third-party-licenses.txt";function y(n){let t=[],e=m(n);for(let i=0;i<4;i++)t.push(u(e,f),u(e,"dist",f)),e=m(e);return t}async function k(n){for(let t of y(C(n))){let e=await x(t,"utf8").catch(()=>{});if(e!==void 0)return{path:t,text:e}}}async function I({from:n=import.meta.url,list:t=async()=>(await import("./manager-XN7WNMEW.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-GNO4XS7P.js"),r=i.filter(o=>o.installed!==void 0).flatMap(o=>s(o.entry)),a=p({bundled:l(e?.text??""),extensions:r});return e?{sections:a,file:e.path}:{sections:a}}export{I as loadCredits};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{r as l}from"./chunk-G4DU5ADF.js";import{e as a}from"./chunk-H2IUSPAK.js";import"./chunk-HON4OV7M.js";import"./chunk-TMUK2DD3.js";var i={loadPreferences:a,loadShell:()=>import("./launch-OVBNYIQE.js")};async function p(e=i){let o=e.loadShell();o.catch(()=>{});let{prefs:t,warning:r}=await e.loadPreferences(),n=l(t.theme),{launchShell:s}=await o;await s({prefs:t,palette:n,...r===void 0?{}:{warning:r}})}export{p as bootShell};
3
+ import{r as l}from"./chunk-2BCNTUEO.js";import{e as a}from"./chunk-H2IUSPAK.js";import"./chunk-HON4OV7M.js";import"./chunk-TMUK2DD3.js";var i={loadPreferences:a,loadShell:()=>import("./launch-UW5W34IU.js")};async function p(e=i){let o=e.loadShell();o.catch(()=>{});let{prefs:t,warning:r}=await e.loadPreferences(),n=l(t.theme),{launchShell:s}=await o;await s({prefs:t,palette:n,...r===void 0?{}:{warning:r}})}export{p as bootShell};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ var C="0.3.5",T={ok:"\u2713",fail:"\u2715",warn:"\u26A0",cursor:"\u276F",strip:"\u258C",star:"\u2605",arrow:"\u2192",tip:"\u2727",longArrow:"\u2500\u2500\u2192",longArrowDown:`\u2502
4
+ \u25BC`,dotFilled:"\u25CF",dotEmpty:"\u25CB"},o={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",modeEnhance:"#b39ae8",modeEnhanceBg:"#2a2238",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"},r={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",modeEnhance:"#64569f",modeEnhanceBg:"#f0ebfa",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"},f={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:"",modeEnhance:"magenta",modeEnhanceBg:"",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","enhance","colour"],v=`1\u2013${d.length}`;function x(e,n){let t=[...d,"commands"],a=Math.max(0,Math.min(t.length-1,t.indexOf(e)+n));return t[a]}function S(e){return/^[1-9]$/.test(e)?d[Number(e)-1]:void 0}var P={convert:"\u2194",compress:"\u2193",pdf:"\u25A3",colour:"\u25D0",enhance:"\u2726"},c="#7d6ad0";function l(e,n){return n==="compress"?{fg:e.modeCompress,bg:e.modeCompressBg}:n==="pdf"?{fg:e.modePdf,bg:e.modePdfBg}:n==="colour"?{fg:e.modeColour,bg:e.modeColourBg}:n==="enhance"?{fg:e.modeEnhance,bg:e.modeEnhanceBg}:{fg:e.modeConvert,bg:e.modeConvertBg}}var i=["#f26e69","#e5a23c","#ace02c","#55c7d9","#6579fd","#ad95e9"],g=["#e5a23c","#f2cf6b"],s={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"],enhance:["#9b5af8","#985cf8","#965ef8","#945ff8","#9161f8","#8f62f8","#8d64f8","#8a65f8","#8867f8"],colour:["#f42335","#e05b1a","#d87d1e","#da9b23","#d2b427","#b4c027","#5bbf23","#20a27c","#1e989b","#1e94b6","#1c8cd9","#577af8","#7371f8","#8568f8","#965df8"]},m=["#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"],enhance:["#f2edfe","#f1edfe","#f1edfe","#f1eefe","#f0eefe","#f0eefe","#f0eefe","#f0eefe","#efeefe"],colour:["#feebe9","#feece5","#feede0","#feeed7","#f7f1d6","#eff3d9","#e5f6df","#dbf8eb","#d6f8f8","#def5fe","#e5f2fe","#ebf0fe","#edeffe","#efeefe","#f1edfe"]},u=["#feeed9","#feeed8","#feeed7","#fdeed6","#fcefd6","#fbefd6","#fbefd6","#faefd6","#f9f0d6"],h={convert:["#138291","#8467bd"],compress:["#2b8748","#138291"],pdf:["#d54322","#a06c10"],enhance:["#8567bc","#7b67cd"],colour:["#cb4b49","#a06c10","#618110","#138291","#5869ec","#8268bd"]};function p(e,n){return e.name==="light"?n==="commands"?m:s[n]:n==="commands"?e.name==="dark"?g:[e.brand]:n==="compress"?[e.modeCompress,e.modeConvert]:n==="pdf"?[e.modePdf,e.brand]:n==="colour"?e.name==="dark"?i:[e.modeColour,e.violet]:n==="enhance"?[e.modeEnhance,e.name==="dark"?c:e.violet]:[e.modeConvert,e.violet]}function k(e,n){if(e.name==="light")return n==="commands"?u:b[n]}function y(e,n){return e.name==="light"?h[n]:p(e,n)}function E(e){return{...e,accent:e.brand,tag:e.brand,label:e.brand}}function M(e,n){let{fg:t,bg:a}=l(e,n);return{...e,accent:t,tag:t,label:t,band:a===""?e.band:a}}function w(e){return e.canvas!==""}function O(e){return e==="dark"?o:e==="light"?r:f}function H(e){return e===""?void 0:e}var R={filled:"\u2501",empty:"\u2501",knob:"\u25CF"};function B(){return process.env.NO_COLOR!==void 0&&process.env.NO_COLOR!==""?!1:process.stdout.isTTY===!0}function D(){B()||(process.env.FORCE_COLOR="0")}export{C as a,T as b,o as c,r as d,f as e,d as f,v as g,x as h,S as i,P as j,l as k,p as l,k as m,y as n,E as o,M as p,w as q,O as r,H as s,R as t,B as u,D as v};
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{c as J,d as oe,e as E,g as B,h as se,i as ne,j as ae,k as ue,q as ie,r as pe,s as ce,u as de,v as fe,x as I,z as y}from"./chunk-WFD6OWQY.js";import{a as $,c as U,d as Y,e as F,f as K,k as Q}from"./chunk-LW2QEXDT.js";import{c as X,d as Z,e as _,f as ee,g as te,h as re}from"./chunk-3GVFOZ7M.js";import{e as V}from"./chunk-GGBNT4WI.js";import{m as H,o as L}from"./chunk-GNLE6JXL.js";import{a as g}from"./chunk-G4DU5ADF.js";import{I as D,J as q,M as z,b as P,c as w,d as R,fa as G,g as x,s as A,u as k,w as W,z as C}from"./chunk-MMRDELHW.js";import{a as h,b as M}from"./chunk-J7FLFHQJ.js";import{readFile as Se}from"node:fs/promises";import{dirname as Re,resolve as je}from"node:path";async function le(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=$(o);if(!s.includes(e.target)){t.push({path:o.path,error:W(o,e.target,s)});continue}let n=E({sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)});r.push({op:"convert",sources:[o],outputs:[n],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as ke}from"node:path";function $e(e,r=new Set){let t={path:ke(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:$(e).filter(n=>!o||F(n)),actions:de([e],r).filter(n=>!o||n.id===B.id).map(n=>n.id)};return e.kind==="image"?{...t,width:e.width,height:e.height,...s}:{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function me(e){let r=await y(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-QN6QAGCU.js"),o=await t();return{probes:r.sources.map(s=>$e(s,o)),failures:r.failures}}import{dirname as Fe}from"node:path";var S=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function ge(e,r){let t=P(Fe(e),S(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function he(e,r){let{pct:t,direction:o}=M(e,r);return o==="same"?"same size":`${t}% ${o}`}function ye(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let a=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${ge(s[0],r)}`,` ${s.map(u=>w(u)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} total`];for(let u of t.warnings)a.push("",`\u26A0 ${u.message}`);return a}let n=[`\u2713 ${w(o.path)} \u2192 ${P(s[0],S(r))}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} \xB7 ${he(o.bytes,t.outputBytes)}`];for(let a of t.warnings)n.push("",`\u26A0 ${a.message}`);return n}function be(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${he(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let n of s.job.outputs)t.push(` ${P(n,S(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function we(e,r={}){let t=e.results.flatMap(i=>i.job.outputs),o=t.map(i=>w(i)).join(", "),s=t.length===1?"file":"files",n=t[0]===void 0?"":ge(t[0],r),a=[`\u2713 ${t.length} ${s} \xB7 ${o}${n}`],u=e.results.flatMap(i=>i.warnings);for(let i of u)a.push("",`\u26A0 ${i.message}`);return a}function j(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...G(o.error,{debug:r.debug}),"");return t}function Ie(){let e=new Set(U()),r=new Set(Y()),t=["Formats",""];for(let s of e){let n=R[s],a=r.has(s)?"read and write":"read only";t.push(` ${n.label.padEnd(6)} ${n.extensions.join(" ").padEnd(12)} ${a}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>R[s].label);if(o.length>0){let s=o.join(", "),[n,a]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${n} read only because Forge cannot yet write ${a}.`)}return t}function ve(e,r={}){let t=[R[e.format].label,h(e.bytes)];return e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${P(e.path,S(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Pe}from"node:readline";import{PassThrough as Ee}from"node:stream";function Be(e){return new Promise(r=>{let t=Pe({input:e,terminal:!1}),o=!1,s=n=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(n.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function xe(e){if(e.stdin)return Be(process.stdin);if(!process.stdin.isTTY)return;let r=new Ee,t=Pe({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
4
- `),t.close()}}function N(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function Oe(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(a=>a.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw D("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:ie(o)};if(s.mode==="every-n")return{cuts:pe(o,s.n)};let n=Math.max(o-1,0);for(let a of s.after)if(!Number.isInteger(a)||a<1||a>n)throw q(String(a),`"${a}" is outside 1 and ${n} \u2014 ${t?w(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(a=>a-1)}}function Ce(e,r){let t;return()=>r?(t??=xe({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function Je(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:C(e.path)}};let u;try{u=await V(await Se(e.path),s)}catch{return{failure:{path:e.path,error:C(e.path,{attempted:!0})}}}u.destroy()}let n;try{n=B.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(u){if(!x(u))throw u;return{failure:{path:e.path,error:u}}}let a=n[0];if(a?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(a.options.password=s),{job:a}}function O(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var b=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function Ne(e){let r=await y(e.inputs,{recursive:!1});if(r.sources.length===0)return b("pageop",r.failures);let t=ce.find(a=>a.id===e.action);if(!t)throw new Error(`no action registered for "${e.action}"`);let o=r.sources[0]?.path??"";if(!t.appliesTo(r.sources)){let a=fe(t,r.sources)??"not available for these files";return b("pageop",[...r.failures,{path:o,error:k(e.action,a)}])}let s;try{s=t.plan(r.sources,Oe(e,r.sources))}catch(a){if(!x(a))throw a;return b("pageop",[...r.failures,{path:o,error:a}])}let n=await I(s,{force:e.force});return{kind:"pageop",results:n.results,failures:[...r.failures,...n.refusals,...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function Te(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let u of t.sources){if(!J.appliesTo([u])){s.push({path:u.path,error:A(u)});continue}let i=e.output!==void 0&&!oe(e.output)?je(e.output):void 0,c=e.output===void 0||i!==void 0?Re(u.path):Re(E({sourcePath:u.path,target:u.format,output:e.output,sourceRoot:t.roots.get(u.path)})),[p]=J.plan([u],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},destination:c});p?.op==="convert"&&(i!==void 0&&(p.outputs=[i]),e.dpi!==void 0&&(p.options.dpi=e.dpi),o.push(p))}let n=o.length>1;n&&r.onProgress?.({completed:0,total:o.length});let a=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:O(r,n)});return{kind:"compress",results:a.results,failures:[...t.failures,...s,...a.refusals,...a.unreachable.map(u=>({path:u.job.sources[0].path,error:u.error})),...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function Me(e,r){let t=e.kind,o=e.op==="remove-background"?H(e.target):void 0;if(o)return b(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-H2WS22BA.js"),n=await s(e.op);if(!n)return b(t,[{path:"",error:z(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:l,catalogEntry:f}=await import("./catalog-O3V24DK7.js"),d=f("boost"),v=d&&l(d)?.version,T=L(e.scale,n.version,v);if(T)return b(t,[{path:"",error:T}])}let a=await y(e.inputs,{recursive:e.recursive}),u=e.op==="boost"?ne:ae,i=[],c=[];for(let l of a.sources){if(!u.appliesTo([l])){c.push({path:l.path,error:k(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let f=se(l,e.target);if(f){c.push({path:l.path,error:f});continue}i.push(...u.plan([l],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:a.roots}))}let p=i.length>1;p&&r.onProgress?.({completed:0,total:i.length});let m=await I(i,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:O(r,p)});return{kind:t,results:m.results,failures:[...a.failures,...c,...m.refusals,...m.failures],inputBytes:m.inputBytes,outputBytes:m.outputBytes}}async function Ae(e,r){let t=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:Q(e.target,t);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),n=[],a=[];for(let p of s.sources)p.kind==="image"?n.push(p):a.push({path:p.path,error:k(t,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=ue(n,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),i=u.length>1;i&&r.onProgress?.({completed:0,total:u.length});let c=await I(u,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:O(r,i)});return{kind:e.kind,results:c.results,failures:[...s.failures,...a,...c.refusals,...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function We(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=d=>d.kind==="document"&&d.format==="pdf",s=F(e.target),n=s?t.sources.filter(o):[],a=s?t.sources.filter(d=>!o(d)):t.sources,u=[],i=[],c=Ce(e.passwordStdin??!1,r.interactive??!0);for(let d of n){let v=await Je(d,e,c,t.roots.get(d.path));"failure"in v?i.push(v.failure):u.push(v.job)}let p=await le({resolved:{sources:a,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),m=[...p.jobs,...u],l=m.length>1;l&&r.onProgress?.({completed:0,total:m.length});let f=await I(m,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:O(r,l)});return{kind:"convert",results:f.results,failures:[...t.failures,...i,...p.failures,...f.refusals,...f.unreachable.map(d=>({path:d.job.sources[0].path,error:d.error})),...f.failures],inputBytes:f.inputBytes,outputBytes:f.outputBytes}}async function De(e,r={}){try{return e.kind==="pageop"?await Ne(e):e.kind==="extension-op"?await Me(e,r):e.kind==="edit"?await Ae(e,r):e.kind==="compress"?await Te(e,r):await We(e,r)}catch(t){if(!x(t))throw t;return b(e.kind,[{path:"",error:t}])}}function qe(e,r){let t=N(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(X(g,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?we(e):e.results.length===1?ye(e):be(e);return{exitCode:t,stdout:o,stderr:j(e.failures,{debug:r.debug})}}function ze(e,r){let t=[{path:"",error:e}],o=N(t);return r.json?{exitCode:o,stdout:[JSON.stringify(Z(g,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:j(t,{debug:r.debug})}}async function Ge(e,r){let{runConfig:t}=await import("./config-command-TXQUYFA6.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(te(g,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function St(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Ge(e,t);if(e.kind==="update"){let{runUpdate:s}=await import("./update-command-6VNVMAYO.js"),n=await s(g,{...r.onInstalling?{onInstalling:r.onInstalling}:{}});return{exitCode:0,stdout:t?[JSON.stringify({forge:g,ok:!0,...n.data})]:n.stdout,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-UGXZIFRI.js"),n=await s(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(re(g,n.data))]:n.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(_(g,K()))],stderr:[]}:{exitCode:0,stdout:Ie(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:n}=await me(e.inputs),a=N(n);return t?{exitCode:a,stdout:[JSON.stringify(ee(g,{probes:s,failures:n}))],stderr:[]}:{exitCode:a,stdout:s.flatMap((u,i)=>[...i>0?[""]:[],...ve(u)]),stderr:j(n,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:s,runScale:n}=await import("./colour-D7L5VGQC.js"),a={json:t,colour:r.colour??!1};return e.kind==="palette"?await s(e,a):await n(e,a)}return e.kind==="shell"?{exitCode:0,stdout:[],stderr:[]}:qe(await De(e,r),{json:t,debug:o})}catch(s){if(!x(s))throw s;return ze(s,{json:t,debug:o})}}export{me as a,N as b,De as c,qe as d,St as e};
3
+ import{c as J,d as oe,e as E,g as B,h as se,i as ne,j as ae,k as ue,q as ie,r as pe,s as ce,u as de,v as fe,x as I,z as y}from"./chunk-WFD6OWQY.js";import{a as $,c as U,d as Y,e as F,f as K,k as Q}from"./chunk-LW2QEXDT.js";import{c as X,d as Z,e as _,f as ee,g as te,h as re}from"./chunk-3GVFOZ7M.js";import{e as V}from"./chunk-GGBNT4WI.js";import{m as H,o as L}from"./chunk-GNLE6JXL.js";import{a as g}from"./chunk-2BCNTUEO.js";import{I as D,J as q,M as z,b as P,c as w,d as R,fa as G,g as x,s as A,u as k,w as W,z as C}from"./chunk-MMRDELHW.js";import{a as h,b as M}from"./chunk-J7FLFHQJ.js";import{readFile as Se}from"node:fs/promises";import{dirname as Re,resolve as je}from"node:path";async function le(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=$(o);if(!s.includes(e.target)){t.push({path:o.path,error:W(o,e.target,s)});continue}let n=E({sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)});r.push({op:"convert",sources:[o],outputs:[n],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as ke}from"node:path";function $e(e,r=new Set){let t={path:ke(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:$(e).filter(n=>!o||F(n)),actions:de([e],r).filter(n=>!o||n.id===B.id).map(n=>n.id)};return e.kind==="image"?{...t,width:e.width,height:e.height,...s}:{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function me(e){let r=await y(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-QN6QAGCU.js"),o=await t();return{probes:r.sources.map(s=>$e(s,o)),failures:r.failures}}import{dirname as Fe}from"node:path";var S=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function ge(e,r){let t=P(Fe(e),S(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function he(e,r){let{pct:t,direction:o}=M(e,r);return o==="same"?"same size":`${t}% ${o}`}function ye(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let a=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${ge(s[0],r)}`,` ${s.map(u=>w(u)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} total`];for(let u of t.warnings)a.push("",`\u26A0 ${u.message}`);return a}let n=[`\u2713 ${w(o.path)} \u2192 ${P(s[0],S(r))}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} \xB7 ${he(o.bytes,t.outputBytes)}`];for(let a of t.warnings)n.push("",`\u26A0 ${a.message}`);return n}function be(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${he(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let n of s.job.outputs)t.push(` ${P(n,S(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function we(e,r={}){let t=e.results.flatMap(i=>i.job.outputs),o=t.map(i=>w(i)).join(", "),s=t.length===1?"file":"files",n=t[0]===void 0?"":ge(t[0],r),a=[`\u2713 ${t.length} ${s} \xB7 ${o}${n}`],u=e.results.flatMap(i=>i.warnings);for(let i of u)a.push("",`\u26A0 ${i.message}`);return a}function j(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...G(o.error,{debug:r.debug}),"");return t}function Ie(){let e=new Set(U()),r=new Set(Y()),t=["Formats",""];for(let s of e){let n=R[s],a=r.has(s)?"read and write":"read only";t.push(` ${n.label.padEnd(6)} ${n.extensions.join(" ").padEnd(12)} ${a}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>R[s].label);if(o.length>0){let s=o.join(", "),[n,a]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${n} read only because Forge cannot yet write ${a}.`)}return t}function ve(e,r={}){let t=[R[e.format].label,h(e.bytes)];return e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${P(e.path,S(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Pe}from"node:readline";import{PassThrough as Ee}from"node:stream";function Be(e){return new Promise(r=>{let t=Pe({input:e,terminal:!1}),o=!1,s=n=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(n.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function xe(e){if(e.stdin)return Be(process.stdin);if(!process.stdin.isTTY)return;let r=new Ee,t=Pe({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
4
+ `),t.close()}}function N(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function Oe(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(a=>a.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw D("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:ie(o)};if(s.mode==="every-n")return{cuts:pe(o,s.n)};let n=Math.max(o-1,0);for(let a of s.after)if(!Number.isInteger(a)||a<1||a>n)throw q(String(a),`"${a}" is outside 1 and ${n} \u2014 ${t?w(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(a=>a-1)}}function Ce(e,r){let t;return()=>r?(t??=xe({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function Je(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:C(e.path)}};let u;try{u=await V(await Se(e.path),s)}catch{return{failure:{path:e.path,error:C(e.path,{attempted:!0})}}}u.destroy()}let n;try{n=B.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(u){if(!x(u))throw u;return{failure:{path:e.path,error:u}}}let a=n[0];if(a?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(a.options.password=s),{job:a}}function O(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var b=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function Ne(e){let r=await y(e.inputs,{recursive:!1});if(r.sources.length===0)return b("pageop",r.failures);let t=ce.find(a=>a.id===e.action);if(!t)throw new Error(`no action registered for "${e.action}"`);let o=r.sources[0]?.path??"";if(!t.appliesTo(r.sources)){let a=fe(t,r.sources)??"not available for these files";return b("pageop",[...r.failures,{path:o,error:k(e.action,a)}])}let s;try{s=t.plan(r.sources,Oe(e,r.sources))}catch(a){if(!x(a))throw a;return b("pageop",[...r.failures,{path:o,error:a}])}let n=await I(s,{force:e.force});return{kind:"pageop",results:n.results,failures:[...r.failures,...n.refusals,...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function Te(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let u of t.sources){if(!J.appliesTo([u])){s.push({path:u.path,error:A(u)});continue}let i=e.output!==void 0&&!oe(e.output)?je(e.output):void 0,c=e.output===void 0||i!==void 0?Re(u.path):Re(E({sourcePath:u.path,target:u.format,output:e.output,sourceRoot:t.roots.get(u.path)})),[p]=J.plan([u],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},destination:c});p?.op==="convert"&&(i!==void 0&&(p.outputs=[i]),e.dpi!==void 0&&(p.options.dpi=e.dpi),o.push(p))}let n=o.length>1;n&&r.onProgress?.({completed:0,total:o.length});let a=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:O(r,n)});return{kind:"compress",results:a.results,failures:[...t.failures,...s,...a.refusals,...a.unreachable.map(u=>({path:u.job.sources[0].path,error:u.error})),...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function Me(e,r){let t=e.kind,o=e.op==="remove-background"?H(e.target):void 0;if(o)return b(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-H2WS22BA.js"),n=await s(e.op);if(!n)return b(t,[{path:"",error:z(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:l,catalogEntry:f}=await import("./catalog-O3V24DK7.js"),d=f("boost"),v=d&&l(d)?.version,T=L(e.scale,n.version,v);if(T)return b(t,[{path:"",error:T}])}let a=await y(e.inputs,{recursive:e.recursive}),u=e.op==="boost"?ne:ae,i=[],c=[];for(let l of a.sources){if(!u.appliesTo([l])){c.push({path:l.path,error:k(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let f=se(l,e.target);if(f){c.push({path:l.path,error:f});continue}i.push(...u.plan([l],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:a.roots}))}let p=i.length>1;p&&r.onProgress?.({completed:0,total:i.length});let m=await I(i,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:O(r,p)});return{kind:t,results:m.results,failures:[...a.failures,...c,...m.refusals,...m.failures],inputBytes:m.inputBytes,outputBytes:m.outputBytes}}async function Ae(e,r){let t=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:Q(e.target,t);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),n=[],a=[];for(let p of s.sources)p.kind==="image"?n.push(p):a.push({path:p.path,error:k(t,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=ue(n,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),i=u.length>1;i&&r.onProgress?.({completed:0,total:u.length});let c=await I(u,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:O(r,i)});return{kind:e.kind,results:c.results,failures:[...s.failures,...a,...c.refusals,...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function We(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=d=>d.kind==="document"&&d.format==="pdf",s=F(e.target),n=s?t.sources.filter(o):[],a=s?t.sources.filter(d=>!o(d)):t.sources,u=[],i=[],c=Ce(e.passwordStdin??!1,r.interactive??!0);for(let d of n){let v=await Je(d,e,c,t.roots.get(d.path));"failure"in v?i.push(v.failure):u.push(v.job)}let p=await le({resolved:{sources:a,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),m=[...p.jobs,...u],l=m.length>1;l&&r.onProgress?.({completed:0,total:m.length});let f=await I(m,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:O(r,l)});return{kind:"convert",results:f.results,failures:[...t.failures,...i,...p.failures,...f.refusals,...f.unreachable.map(d=>({path:d.job.sources[0].path,error:d.error})),...f.failures],inputBytes:f.inputBytes,outputBytes:f.outputBytes}}async function De(e,r={}){try{return e.kind==="pageop"?await Ne(e):e.kind==="extension-op"?await Me(e,r):e.kind==="edit"?await Ae(e,r):e.kind==="compress"?await Te(e,r):await We(e,r)}catch(t){if(!x(t))throw t;return b(e.kind,[{path:"",error:t}])}}function qe(e,r){let t=N(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(X(g,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?we(e):e.results.length===1?ye(e):be(e);return{exitCode:t,stdout:o,stderr:j(e.failures,{debug:r.debug})}}function ze(e,r){let t=[{path:"",error:e}],o=N(t);return r.json?{exitCode:o,stdout:[JSON.stringify(Z(g,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:j(t,{debug:r.debug})}}async function Ge(e,r){let{runConfig:t}=await import("./config-command-TXQUYFA6.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(te(g,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function St(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Ge(e,t);if(e.kind==="update"){let{runUpdate:s}=await import("./update-command-6VNVMAYO.js"),n=await s(g,{...r.onInstalling?{onInstalling:r.onInstalling}:{}});return{exitCode:0,stdout:t?[JSON.stringify({forge:g,ok:!0,...n.data})]:n.stdout,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-UGXZIFRI.js"),n=await s(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(re(g,n.data))]:n.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(_(g,K()))],stderr:[]}:{exitCode:0,stdout:Ie(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:n}=await me(e.inputs),a=N(n);return t?{exitCode:a,stdout:[JSON.stringify(ee(g,{probes:s,failures:n}))],stderr:[]}:{exitCode:a,stdout:s.flatMap((u,i)=>[...i>0?[""]:[],...ve(u)]),stderr:j(n,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:s,runScale:n}=await import("./colour-VIZLKX46.js"),a={json:t,colour:r.colour??!1};return e.kind==="palette"?await s(e,a):await n(e,a)}return e.kind==="shell"?{exitCode:0,stdout:[],stderr:[]}:qe(await De(e,r),{json:t,debug:o})}catch(s){if(!x(s))throw s;return ze(s,{json:t,debug:o})}}export{me as a,N as b,De as c,qe as d,St as e};
@@ -0,0 +1,19 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as $,h as lt,i as D}from"./chunk-MBTGANIR.js";import{b as x,c as R,d as H,f as v,g as P,h as X}from"./chunk-QVACE4IE.js";import{i as it}from"./chunk-GGBNT4WI.js";import{C as at,D as st,u as ot}from"./chunk-GNLE6JXL.js";import{d as Z,g as tt,p as et,r as nt,x as rt}from"./chunk-MMRDELHW.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":_(n)}function _(t){let e=(t%360+360)%360;return(xt.find(([n])=>e<n)??[360,"rose"])[1]}var Tt=["full","mono","analogous","opposite","split","triad","pastel"],ct={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},At=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}}],$t={analogous:[-30,0,30],opposite:[0,180],split:[0,150,210],triad:[0,120,240]},wt=.553,yt=.024,b=t=>v(R(t)),C=(t,e,n)=>H(P({L:t,C:Math.max(0,e),h:(n+360)%360})),K=(t,e)=>(t-e+540)%360-180;function ht(t,e,n){let r=P({L:t,C:e,h:n}),a=R(H(r));return Math.hypot(a.L-r.L,a.a-r.a,a.b-r.b)<.003}function L(t,e){let n=0,r=.4;for(let a=0;a<30;a++){let o=(n+r)/2;ht(t,o,e)?n=o:r=o}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:a}=b(t),o=A(n,e.brightness),i=(a+e.hue+360)%360,l=q(r,L(o,i),e.saturation);for(let s=0;s<40&&l>0&&!ht(o,l,i);s++)l-=.005;return C(o,l,i)}function k(t,e,n,r){let a=A(t,r.brightness),o=(n+r.hue+360)%360,i=L(a,o);return C(a,Math.min(i,q(e,i,r.saturation)),o)}function Y(t,e,n){if(!e)return t;let r=b(t[n].rgb).L;return t.map((a,o)=>{if(o===n)return a;let i=b(a.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{...a,rgb:s,hex:x(s)}})}function Et(t,e,n,r){return Y(t(T(e,n)),n.contrast,r)}function ut(t,e){let n=b(t),r=G.map(s=>b(s.hex)),a=0;r.forEach((s,c)=>{Math.abs(K(n.h,s.h))<Math.abs(K(n.h,r[a].h))&&(a=c)});let o=r[a],i=Math.max(-10,Math.min(10,K(n.h,o.h)/2)),l=W(n);return G.map((s,c)=>{if(c===a)return{name:s.name,role:s.role,rgb:T(t,e),yours:!0};let h=r[c],p=n.L>=o.L?h.L+(n.L-o.L)*(1-h.L)/(1-o.L):h.L*n.L/o.L,f=A(p,e.brightness),g=(h.h+i+e.hue+360)%360,d=L(f,g),u=Math.min(1,W(h)),S=Math.min(d,q(l*u*d,d,e.saturation));return{name:s.name,role:s.role,rgb:C(f,S,g),yours:!1}})}function St(t,e,n){let r=b(t),a=w(t);if(e==="mono")return[{name:a,rgb:T(t,n),yours:!0},{name:`${a} soft`,rgb:k(r.L,r.C*.5,r.h,n),yours:!1},{name:`${a} dusty`,rgb:k(r.L,r.C*.22,r.h,n),yours:!1}];if(e==="pastel")return ut(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 o=W(r);return($t[e]??[0]).map(l=>{if(l===0)return{name:a,rgb:T(t,n),yours:!0};let s=(r.h+l+360)%360,c=o*L(r.L,s);return{name:o>0?_(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 Lt(t,e,n){let r=b(t).h+e.hue,a=Math.max(0,yt*(1+e.saturation/100));return D(C(A(wt,e.brightness),a,r),n)}function Ot(t,e,n=B,r=$){let a=lt(r);return{rows:(e==="full"?ut(t,n):St(t,e,n)).map(({name:l,role:s,rgb:c,yours:h})=>({name:l,...s?{role:s}:{},steps:Y(D(c,r),n.contrast,a),yours:h})),neutral:Y(Lt(t,n,r),n.contrast,a)}}var M=t=>t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),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 mt(t){let e=t==="dark";return{ink:e?"#FAFAFA":"#111111",grey:e?"#A1A1AA":"#71717A",edge:e?"#FFFFFF":"#000000",paper:e?"#18181B":"#FFFFFF"}}var Mt=`<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
+ `;function I(t,e,n,r="light"){let{ink:a,grey:o,edge:i,paper:l}=mt(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="${a}">${M(t)}</text><text id="subtitle" x="24" y="58" ${y} font-size="12" fill="${o}">${M(e)}</text>`,d=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="${a}">${M(u.name)}</text><text id="value" x="1" y="${s+40}" ${y} font-size="11" fill="${o}">${M(u.value)}</text></g>`).join(`
5
+ `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${p}" viewBox="0 0 ${h} ${p}">
6
+ `+(n.some(u=>u.alpha!==void 0)?Mt:"")+`<g id="${E(t)}">
7
+ <rect id="card" width="${h}" height="${p}" rx="0" fill="${l}"/>
8
+ ${g}
9
+ ${d}
10
+ </g>
11
+ </svg>`}function Ht(t,e,n="light",r){let a=t.replace(/\.[^.]+$/,""),o=e.length;return I(t,r?`${o} shade${o===1?"":"s"} of ${r}`:`${o} colour${o===1?"":"s"}, most of the image first`,e.map((i,l)=>({id:`${a}-${l+1}`,name:i.hex,value:X(i.rgb),hex:i.hex})),n)}function N(t){if(t.set==="radix")return"Radix 1\u201312";if(t.set==="even")return`${t.start}\u2013${t.end}, ${t.count} even steps`;let e=$;return t.start===e.start&&t.end===e.end?"50\u2013950":`Tailwind ${t.start}\u2013${t.end}`}function Pt(t,e,n="light",r=$){let a=w(t);return I(O(a),`from ${x(t)} \xB7 ${N(r)} in OKLCH`,e.map(o=>({id:`${a}-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),n)}function Dt(t,e,n,r=$,a="light"){let{ink:o,grey:i,edge:l,paper:s}=mt(a),c=`${O(w(t))} palette`,h=`from ${x(t)} \xB7 ${ct[n]} \xB7 ${N(r)} in OKLCH`,p=[...e.rows.map(m=>({name:m.name,steps:m.steps})),{name:"neutral",steps:e.neutral}],f=p[0]?.steps.map(m=>m.step)??[],g=44,d=6,u=g+10,S=92,z=24+Math.max(92,...p.map(m=>m.name.length*8+12)),gt=z+f.length*g+Math.max(0,f.length-1)*d+24,U=Math.max(gt,48+Math.ceil(h.length*6.5)),j=S+p.length*u+24+10,pt=`<text id="title" x="24" y="38" ${y} font-size="15" font-weight="600" fill="${o}">${M(c)}</text><text id="subtitle" x="24" y="58" ${y} font-size="12" fill="${i}">${M(h)}</text>`,ft=f.map((m,F)=>`<text id="step-${m}" x="${z+F*(g+d)+1}" y="${S-10}" ${y} font-size="11" font-weight="600" fill="${i}">${m}</text>`).join(""),dt=p.map((m,F)=>{let J=S+F*u+(F===p.length-1?10:0),Q=E(m.name);return`<g id="${Q}"><text id="name" x="24" y="${J+g/2+4}" ${y} font-size="13" font-weight="600" fill="${o}">${M(m.name)}</text>`+m.steps.map((V,bt)=>`<g id="${Q}-${V.step}"><rect id="swatch" x="${z+bt*(g+d)}" y="${J}" width="${g}" height="${g}" rx="8" fill="${V.hex}" stroke="${l}" stroke-opacity="0.08"/></g>`).join("")+"</g>"}).join(`
12
+ `);return`<svg xmlns="http://www.w3.org/2000/svg" width="${U}" height="${j}" viewBox="0 0 ${U} ${j}">
13
+ <g id="${E(c)}">
14
+ <rect id="card" width="${U}" height="${j}" rx="0" fill="${s}"/>
15
+ ${pt}
16
+ <g id="steps">${ft}</g>
17
+ ${dt}
18
+ </g>
19
+ </svg>`}function _t(t,e,n,r="light",a=$){return I(`${O(w(t))} neutral`,`from ${x(t)} \xB7 ${n} tint \xB7 ${N(a)} in OKLCH`,e.map(o=>({id:`neutral-${o.step}`,name:String(o.step),value:o.hex,hex:o.hex})),r)}function Kt(t,e,n,r="light",a=$){let o=w(t);return I(`${O(o)} alpha`,`from ${x(t)} \xB7 over ${n} \xB7 ${N(a)}`,e.map(i=>({id:`${o}-alpha-${i.step}`,name:String(i.step),value:i.hex8,hex:x(i.rgb),alpha:i.a})),r)}async function Qt(t,e=192){let n=await it(t);if(n.kind!=="image")throw et(t,`a ${Z[n.format].label}`);let r=n.format==="heic";if(r&&!await at())throw nt(t);let a=r?await st(t):void 0;try{let i=(await ot())(a?.path??t,{animated:!1}),{data:l,info:s}=await(r?i:i.rotate()).resize(e,e,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:n,pixels:{width:s.width,height:s.height,rgba:new Uint8Array(l.buffer,l.byteOffset,l.length)}}}catch(o){throw tt(o)?o:rt(t,o)}finally{await a?.cleanup()}}export{Tt as a,ct as b,B as c,At as d,Et as e,Ot as f,I as g,Ht as h,Pt as i,Dt as j,_t as k,Kt as l,Qt as m};