forge-terminal 0.4.3 → 0.4.4

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.
Files changed (25) hide show
  1. package/README.md +3 -3
  2. package/dist/chunks/{about-credits-BIOQB4LZ.js → about-credits-QMC5GQU2.js} +1 -1
  3. package/dist/chunks/{args-5XWINYYE.js → args-VPUOIDWE.js} +1 -1
  4. package/dist/chunks/{boot-66CWEF4E.js → boot-FOKV7OHT.js} +1 -1
  5. package/dist/chunks/{chunk-KCCI3WEN.js → chunk-5SMYDPVX.js} +1 -1
  6. package/dist/chunks/{chunk-5BE5XZY5.js → chunk-I2IATJNL.js} +1 -1
  7. package/dist/chunks/{chunk-WMPQ5T2K.js → chunk-M7A55JKD.js} +2 -2
  8. package/dist/chunks/chunk-NWREILRP.js +66 -0
  9. package/dist/chunks/{chunk-KAQ5LMYO.js → chunk-XEQVXPPY.js} +1 -1
  10. package/dist/chunks/{clip-command-ANGANJ3B.js → clip-command-SGB3B4OJ.js} +1 -1
  11. package/dist/chunks/{colour-RMOFEV4G.js → colour-QMGYV6WQ.js} +1 -1
  12. package/dist/chunks/{entry-NFR27M33.js → entry-3PEVSH2X.js} +1 -1
  13. package/dist/chunks/{execute-JY372YAC.js → execute-WQJ37VKD.js} +1 -1
  14. package/dist/chunks/{extensions-K27LB6ZO.js → extensions-ZKOWPSLD.js} +1 -1
  15. package/dist/chunks/{extensions-command-TBOTOP4R.js → extensions-command-L2AT6OVR.js} +1 -1
  16. package/dist/chunks/launch-L5DKAUA3.js +15 -0
  17. package/dist/chunks/{manager-DLXGO25L.js → manager-TEZ3V4L4.js} +1 -1
  18. package/dist/chunks/{server-PQEGX3HK.js → server-7PMVIYWQ.js} +3 -3
  19. package/dist/chunks/{theme-BJRL3INU.js → theme-Z6X54JY4.js} +1 -1
  20. package/dist/chunks/{update-note-NSHFIIX6.js → update-note-RQG2RZNR.js} +1 -1
  21. package/dist/chunks/{watch-command-B5R6NDWW.js → watch-command-DUHMTXQL.js} +1 -1
  22. package/dist/index.js +6 -6
  23. package/package.json +7 -11
  24. package/dist/chunks/chunk-E55PYOCI.js +0 -66
  25. package/dist/chunks/launch-QNZWUCVQ.js +0 -5
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.4.3
46
+ # 0.4.4
47
47
 
48
48
  forge photo.jpg --to webp
49
49
  ```
@@ -1029,7 +1029,7 @@ photo.png · PNG · 122 KB · 2756×774
1029
1029
  With `--json`:
1030
1030
 
1031
1031
  ```json
1032
- {"forge":"0.4.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":[]}
1032
+ {"forge":"0.4.4","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":[]}
1033
1033
  ```
1034
1034
 
1035
1035
  `targets` and `actions` come from the engines' own capabilities, so they are
@@ -1055,7 +1055,7 @@ succeeded) and `failures`. A conversion, compression or page operation adds
1055
1055
 
1056
1056
  ```jsonc
1057
1057
  {
1058
- "forge": "0.4.3",
1058
+ "forge": "0.4.4",
1059
1059
  "ok": false,
1060
1060
  "results": [
1061
1061
  {
@@ -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-DLXGO25L.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-K27LB6ZO.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-TEZ3V4L4.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-ZKOWPSLD.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{a,b,c,d}from"./chunk-KCCI3WEN.js";import"./chunk-U5TEGDGH.js";import"./chunk-QVACE4IE.js";import"./chunk-HZDYZ5RD.js";import"./chunk-QR6QHTC3.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-YYB3TTGT.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import"./chunk-5BE5XZY5.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{b as COMMANDS_HELP,a as EXIT_CODES_HELP,d as parseArgs,c as wantsJson};
3
+ import{a,b,c,d}from"./chunk-5SMYDPVX.js";import"./chunk-U5TEGDGH.js";import"./chunk-QVACE4IE.js";import"./chunk-HZDYZ5RD.js";import"./chunk-QR6QHTC3.js";import"./chunk-6L6C3GJU.js";import"./chunk-EEQSUBBL.js";import"./chunk-YYB3TTGT.js";import"./chunk-KAHWYWNT.js";import"./chunk-SMBK6BTC.js";import"./chunk-EXLXSKRH.js";import"./chunk-3UEQ2OX6.js";import"./chunk-J7FLFHQJ.js";import"./chunk-LDKF7KIZ.js";import"./chunk-I2IATJNL.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{b as COMMANDS_HELP,a as EXIT_CODES_HELP,d as parseArgs,c as wantsJson};
@@ -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-5BE5XZY5.js";import{f as a}from"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";var c={loadPreferences:a,loadShell:()=>import("./launch-QNZWUCVQ.js")};async function f(e=c,n={}){let t=e.loadShell();t.catch(()=>{});let{prefs:o,warning:r}=await e.loadPreferences(),s=l(o.theme),{launchShell:i}=await t;await i({prefs:o,palette:s,...r===void 0?{}:{warning:r},...n})}export{f as bootShell};
3
+ import{r as l}from"./chunk-I2IATJNL.js";import{f as a}from"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";var c={loadPreferences:a,loadShell:()=>import("./launch-L5DKAUA3.js")};async function f(e=c,n={}){let t=e.loadShell();t.catch(()=>{});let{prefs:o,warning:r}=await e.loadPreferences(),s=l(o.theme),{launchShell:i}=await t;await i({prefs:o,palette:s,...r===void 0?{}:{warning:r},...n})}export{f as bootShell};
@@ -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 B}from"./chunk-U5TEGDGH.js";import{a as K,b as Y}from"./chunk-HZDYZ5RD.js";import{h as W}from"./chunk-QR6QHTC3.js";import{b as J}from"./chunk-EEQSUBBL.js";import{a as D}from"./chunk-YYB3TTGT.js";import{l as L,n as U}from"./chunk-KAHWYWNT.js";import{F as d,I as H}from"./chunk-3UEQ2OX6.js";import{d as R}from"./chunk-J7FLFHQJ.js";import{a as X}from"./chunk-5BE5XZY5.js";import{b as z}from"./chunk-M66BUNYO.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 V(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}import{EventEmitter as ae}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 ue}from"node:util";import{stripVTControlCharacters as re}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,r)=>i.name().localeCompare(r.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),r=n.long&&e._findOption(n.long);!i&&!r?t.push(n):n.long&&!r?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(r=>!r.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=>V(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(r=>{let o=n(r);i.has(o)||i.set(o,[])}),t.forEach(r=>{let o=n(r);i.has(o)||i.set(o,[]),i.get(o).push(r)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function r(c,p){return t.formatItem(c,n,p,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],u=t.commandDescription(e);u.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(u),i),""]));let l=t.visibleArguments(e).map(c=>r(t.styleArgumentTerm(t.argumentTerm(c)),t.styleArgumentDescription(t.argumentDescription(c))));if(o=o.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),c=>c.helpGroupHeading??"Options:").forEach((c,p)=>{let O=c.map(_=>r(t.styleOptionTerm(t.optionTerm(_)),t.styleOptionDescription(t.optionDescription(_))));o=o.concat(this.formatItemList(p,O,t))}),t.showGlobalOptions){let c=t.visibleGlobalOptions(e).map(p=>r(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));o=o.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(_=>r(t.styleSubcommandTerm(t.subcommandTerm(_)),t.styleSubcommandDescription(t.subcommandDescription(_))));o=o.concat(this.formatItemList(p,O,t))}),o.join(`
3
+ import{a as B}from"./chunk-U5TEGDGH.js";import{a as K,b as Y}from"./chunk-HZDYZ5RD.js";import{h as W}from"./chunk-QR6QHTC3.js";import{b as J}from"./chunk-EEQSUBBL.js";import{a as D}from"./chunk-YYB3TTGT.js";import{l as L,n as U}from"./chunk-KAHWYWNT.js";import{F as d,I as H}from"./chunk-3UEQ2OX6.js";import{d as R}from"./chunk-J7FLFHQJ.js";import{a as X}from"./chunk-I2IATJNL.js";import{b as z}from"./chunk-M66BUNYO.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 V(s){let e=s.name()+(s.variadic===!0?"...":"");return s.required?"<"+e+">":"["+e+"]"}import{EventEmitter as ae}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 ue}from"node:util";import{stripVTControlCharacters as re}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,r)=>i.name().localeCompare(r.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),r=n.long&&e._findOption(n.long);!i&&!r?t.push(n):n.long&&!r?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(r=>!r.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=>V(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(r=>{let o=n(r);i.has(o)||i.set(o,[])}),t.forEach(r=>{let o=n(r);i.has(o)||i.set(o,[]),i.get(o).push(r)}),i}formatHelp(e,t){let n=t.padWidth(e,t),i=t.helpWidth??80;function r(c,p){return t.formatItem(c,n,p,t)}let o=[`${t.styleTitle("Usage:")} ${t.styleUsage(t.commandUsage(e))}`,""],u=t.commandDescription(e);u.length>0&&(o=o.concat([t.boxWrap(t.styleCommandDescription(u),i),""]));let l=t.visibleArguments(e).map(c=>r(t.styleArgumentTerm(t.argumentTerm(c)),t.styleArgumentDescription(t.argumentDescription(c))));if(o=o.concat(this.formatItemList("Arguments:",l,t)),this.groupItems(e.options,t.visibleOptions(e),c=>c.helpGroupHeading??"Options:").forEach((c,p)=>{let O=c.map(_=>r(t.styleOptionTerm(t.optionTerm(_)),t.styleOptionDescription(t.optionDescription(_))));o=o.concat(this.formatItemList(p,O,t))}),t.showGlobalOptions){let c=t.visibleGlobalOptions(e).map(p=>r(t.styleOptionTerm(t.optionTerm(p)),t.styleOptionDescription(t.optionDescription(p))));o=o.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(_=>r(t.styleSubcommandTerm(t.subcommandTerm(_)),t.styleSubcommandDescription(t.subcommandDescription(_))));o=o.concat(this.formatItemList(p,O,t))}),o.join(`
4
4
  `)}displayWidth(e){return re(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 o=" ".repeat(2);if(!n)return o+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)),o+u+" ".repeat(l)+c.replace(/\n/g,`
6
6
  ${o}`)}boxWrap(e,t){if(t<this.minWidthToWrap)return e;let n=e.split(/\r\n|\n/),i=/[\s]*[^\s]+/g,r=[];return n.forEach(o=>{let u=o.match(i);if(u===null){r.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}r.push(l.join(""));let p=a.trimStart();l=[p],h=this.displayWidth(p)}),r.push(l.join(""))}),r.join(`
@@ -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.4.3",x={ok:"\u2713",fail:"\u2715",warn:"\u26A0",cursor:"\u276F",strip:"\u258C",star:"\u2605",arrow:"\u2192",tip:"\u2727",longArrow:"\u2500\u2500\u2192",longArrowDown:`\u2502
3
+ var v="0.4.4",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,4 +1,4 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{a as ie,b as ue,c as pe,d as N,e as de,k as fe,l as le,m as me,o as ge,p as he}from"./chunk-I63TO22X.js";import{a as y}from"./chunk-DERIWZAT.js";import{c as I}from"./chunk-YWKMG5WO.js";import{f as ce,i as j}from"./chunk-LNB5D67B.js";import{e as te,f as re,g as oe,h as se,i as ne,j as ae}from"./chunk-EHARO6IS.js";import{a as F,c as X,d as Z,e as C,f as _,k as ee}from"./chunk-QR6QHTC3.js";import{e as Q}from"./chunk-6L6C3GJU.js";import{d as $}from"./chunk-EEQSUBBL.js";import{n as H,p as L}from"./chunk-KAHWYWNT.js";import{a as U,c as Y,d as E,e as K}from"./chunk-EXLXSKRH.js";import{F as M,G as q,J as G,b as P,c as w,d as v,na as V,p as z,r as k,t as D,w as J}from"./chunk-3UEQ2OX6.js";import{a as h,b as W}from"./chunk-J7FLFHQJ.js";import{a as m}from"./chunk-5BE5XZY5.js";import{a as R}from"./chunk-M66BUNYO.js";import{readFile as Je}from"node:fs/promises";import{dirname as Fe,resolve as Me}from"node:path";async function ye(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=F(o);if(!s.includes(e.target)){t.push({path:o.path,error:D(o,e.target,s)});continue}let n={sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)},a=E(n);Y(a,o.path)&&e.target!==o.format&&(a=K({...n,suffix:e.target})),r.push({op:"convert",sources:[o],outputs:[a],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as Ce}from"node:path";function je(e,r=new Set){let t={path:Ce(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:F(e).filter(n=>!o||C(n)),actions:ge([e],r).filter(n=>!o||n.id===j.id).map(n=>n.id)};if(e.kind==="image")return{...t,width:e.width,height:e.height,...s};if(e.kind==="media"){let n=e.facts;return{...t,...n?{duration:n.duration}:{},...n?.video?{width:n.video.width,height:n.video.height,fps:n.video.fps}:{},...s}}return{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function be(e){let r=await y(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-GYIHVSRX.js"),o=await t();return{probes:r.sources.map(s=>je(s,o)),failures:r.failures}}import{dirname as Be}from"node:path";var B=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function we(e,r){let t=P(Be(e),B(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function Ie(e,r){let{pct:t,direction:o}=W(e,r);return o==="same"?"same size":`${t}% ${o}`}function xe(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let a=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${we(s[0],r)}`,` ${s.map(i=>w(i)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} total`];for(let i of t.warnings)a.push("",`\u26A0 ${i.message}`);return a}let n=[`\u2713 ${w(o.path)} \u2192 ${P(s[0],B(r))}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} \xB7 ${Ie(o.bytes,t.outputBytes)}`];for(let a of t.warnings)n.push("",`\u26A0 ${a.message}`);return n}function Pe(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${Ie(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let n of s.job.outputs)t.push(` ${P(n,B(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function ve(e,r={}){let t=e.results.flatMap(u=>u.job.outputs),o=t.map(u=>w(u)).join(", "),s=t.length===1?"file":"files",n=t[0]===void 0?"":we(t[0],r),a=[`\u2713 ${t.length} ${s} \xB7 ${o}${n}`],i=e.results.flatMap(u=>u.warnings);for(let u of i)a.push("",`\u26A0 ${u.message}`);return a}function O(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...V(o.error,{debug:r.debug}),"");return t}function ke(){let e=new Set(X()),r=new Set(Z()),t=["Formats",""];for(let s of e){let n=R[s],a=r.has(s)?"read and write":"read only";t.push(` ${n.label.padEnd(6)} ${n.extensions.join(" ").padEnd(12)} ${a}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>R[s].label);if(o.length>0){let s=o.join(", "),[n,a]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${n} read only because Forge cannot yet write ${a}.`)}return t}function $e(e,r={}){let t=[R[e.format].label,h(e.bytes)];return e.duration!==void 0&&t.push($(e.duration)),e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.fps!==void 0&&t.push(`${e.fps} fps`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${P(e.path,B(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Re}from"node:readline";import{PassThrough as Oe}from"node:stream";function Se(e){return new Promise(r=>{let t=Re({input:e,terminal:!1}),o=!1,s=n=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(n.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function Ee(e){if(e.stdin)return Se(process.stdin);if(!process.stdin.isTTY)return;let r=new Oe,t=Re({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
4
- `),t.close()}}function T(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function Ne(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(a=>a.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw M("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:fe(o)};if(s.mode==="every-n")return{cuts:le(o,s.n)};let n=Math.max(o-1,0);for(let a of s.after)if(!Number.isInteger(a)||a<1||a>n)throw q(String(a),`"${a}" is outside 1 and ${n} \u2014 ${t?w(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(a=>a-1)}}function Te(e,r){let t;return()=>r?(t??=Ee({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function Ae(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:J(e.path)}};let i;try{i=await Q(await Je(e.path),s)}catch{return{failure:{path:e.path,error:J(e.path,{attempted:!0})}}}i.destroy()}let n;try{n=j.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(i){if(!v(i))throw i;return{failure:{path:e.path,error:i}}}let a=n[0];if(a?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(a.options.password=s),{job:a}}function S(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}if(!r&&t.type==="job:phase"&&t.progress.phase==="time"){let o=t.progress,s=`${$(o.done)} of ${$(o.total)}`;e.onEncode?.(o.pass?`pass ${o.pass.at} of 2 \xB7 ${s}`:s);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var b=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function We(e){let r=await y(e.inputs,{recursive:!1});if(r.sources.length===0)return b("pageop",r.failures);let t=me.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=he(t,r.sources)??"not available for these files";return b("pageop",[...r.failures,{path:o,error:k(e.action,a)}])}let s;try{s=t.plan(r.sources,Ne(e,r.sources))}catch(a){if(!v(a))throw a;return b("pageop",[...r.failures,{path:o,error:a}])}let n=await I(s,{force:e.force});return{kind:"pageop",results:n.results,failures:[...r.failures,...n.refusals,...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function ze(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let i of t.sources){if(!N.appliesTo([i])){s.push({path:i.path,error:z(i)});continue}let u=e.output!==void 0&&!U(e.output)?Me(e.output):void 0,g=e.output===void 0||u!==void 0?Fe(i.path):Fe(E({sourcePath:i.path,target:i.format,output:e.output,sourceRoot:t.roots.get(i.path)})),[d]=N.plan([i],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},...e.options.media??{},destination:g});d?.op==="convert"&&(u!==void 0&&(d.outputs=[u]),e.dpi!==void 0&&(d.options.dpi=e.dpi),o.push(d))}let n=o.length>1;n&&r.onProgress?.({completed:0,total:o.length});let a=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,n)});return{kind:"compress",results:a.results,failures:[...t.failures,...s,...a.refusals,...a.unreachable.map(i=>({path:i.job.sources[0].path,error:i.error})),...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function De(e,r){let t=e.kind,o=e.op==="remove-background"?H(e.target):void 0;if(o)return b(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-5XI5L4KW.js"),n=await s(e.op);if(!n)return b(t,[{path:"",error:G(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:c,catalogEntry:p}=await import("./catalog-YSMT3PXT.js"),f=p("boost"),x=f&&c(f)?.version,A=L(e.scale,n.version,x);if(A)return b(t,[{path:"",error:A}])}let a=await y(e.inputs,{recursive:e.recursive}),i=e.op==="boost"?ue:pe,u=[],g=[];for(let c of a.sources){if(!i.appliesTo([c])){g.push({path:c.path,error:k(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let p=ie(c,e.target);if(p){g.push({path:c.path,error:p});continue}u.push(...i.plan([c],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:a.roots}))}let d=u.length>1;d&&r.onProgress?.({completed:0,total:u.length});let l=await I(u,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:S(r,d)});return{kind:t,results:l.results,failures:[...a.failures,...g,...l.refusals,...l.failures],inputBytes:l.inputBytes,outputBytes:l.outputBytes}}async function qe(e,r){let t=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:ee(e.target,t);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),n=[],a=[],i=[];for(let p of s.sources)p.kind==="image"&&e.media===void 0?n.push(p):p.kind==="media"&&!e.trim?a.push(p):p.kind==="image"?i.push({path:p.path,error:k("cut","it works on video and sound, not images","Try a video or sound file, such as a MOV, MP4 or WAV.")}):i.push({path:p.path,error:k(t,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=ce(a,{...e.media===void 0?{}:{media:e.media},...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots}),d=[...de(n,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),...u],l=d.length>1;l&&r.onProgress?.({completed:0,total:d.length});let c=await I(d,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:S(r,l)});return{kind:e.kind,results:c.results,failures:[...s.failures,...i,...c.refusals,...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function Ge(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=f=>f.kind==="document"&&f.format==="pdf",s=C(e.target),n=s?t.sources.filter(o):[],a=s?t.sources.filter(f=>!o(f)):t.sources,i=[],u=[],g=Te(e.passwordStdin??!1,r.interactive??!0);for(let f of n){let x=await Ae(f,e,g,t.roots.get(f.path));"failure"in x?u.push(x.failure):i.push(x.job)}let d=await ye({resolved:{sources:a,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),l=[...d.jobs,...i],c=l.length>1;c&&r.onProgress?.({completed:0,total:l.length});let p=await I(l,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,c)});return{kind:"convert",results:p.results,failures:[...t.failures,...u,...d.failures,...p.refusals,...p.unreachable.map(f=>({path:f.job.sources[0].path,error:f.error})),...p.failures],inputBytes:p.inputBytes,outputBytes:p.outputBytes}}async function Ve(e,r={}){try{if(e.kind==="pageop")return await We(e);if(e.kind==="extension-op")return await De(e,r);if(e.kind==="edit")return await qe(e,r);if(e.kind==="preset"){let{runPresetCommand:t}=await import("./preset-command-HORY7KZQ.js");return await t(e)}return e.kind==="compress"?await ze(e,r):await Ge(e,r)}catch(t){if(!v(t))throw t;return b(e.kind,[{path:"",error:t}])}}function He(e,r){let t=T(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(te(m,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?ve(e):e.results.length===1?xe(e):Pe(e);return{exitCode:t,stdout:o,stderr:O(e.failures,{debug:r.debug})}}function Le(e,r){let t=[{path:"",error:e}],o=T(t);return r.json?{exitCode:o,stdout:[JSON.stringify(re(m,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:O(t,{debug:r.debug})}}async function Ue(e,r){let{runConfig:t}=await import("./config-command-TYNYVUMP.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(ne(m,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function Tt(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Ue(e,t);if(e.kind==="clip"){let{runClipCommand:s}=await import("./clip-command-ANGANJ3B.js");return await s(e,{...r,json:t,debug:o})}if(e.kind==="update"){let{runUpdate:s}=await import("./update-command-GMBG7BK6.js"),n=await s(m,{...r.onInstalling?{onInstalling:r.onInstalling}:{}});return{exitCode:0,stdout:t?[JSON.stringify({forge:m,ok:!0,...n.data})]:n.stdout,stderr:[]}}if(e.kind==="uninstall"){let{runUninstall:s}=await import("./entry-NFR27M33.js"),n=[];return{exitCode:await s(m,i=>n.push(i)),stdout:n,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-TBOTOP4R.js"),n=await s(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(ae(m,n.data))]:n.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(oe(m,_()))],stderr:[]}:{exitCode:0,stdout:ke(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:n}=await be(e.inputs),a=T(n);return t?{exitCode:a,stdout:[JSON.stringify(se(m,{probes:s,failures:n}))],stderr:[]}:{exitCode:a,stdout:s.flatMap((i,u)=>[...u>0?[""]:[],...$e(i)]),stderr:O(n,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:s,runScale:n}=await import("./colour-RMOFEV4G.js"),a={json:t,colour:r.colour??!1};return e.kind==="palette"?await s(e,a):await n(e,a)}if(e.kind==="transcribe"){let{runTranscribeCommand:s}=await import("./transcribe-command-YUSBCQEQ.js"),n=[],a=[];return{exitCode:await s(e,{out:u=>n.push(u),err:u=>a.push(u)}),stdout:n,stderr:a}}if(e.kind==="shell")return{exitCode:0,stdout:[],stderr:[]};if(e.kind==="watch")throw M("forge watch runs in a terminal until ctrl-c.","Try: forge watch ./images --to webp");return He(await Ve(e,r),{json:t,debug:o})}catch(s){if(!v(s))throw s;return Le(s,{json:t,debug:o})}}export{be as a,Ie as b,T as c,Ve as d,He as e,Tt as f};
3
+ import{a as ie,b as ue,c as pe,d as N,e as de,k as fe,l as le,m as me,o as ge,p as he}from"./chunk-I63TO22X.js";import{a as y}from"./chunk-DERIWZAT.js";import{c as I}from"./chunk-YWKMG5WO.js";import{f as ce,i as j}from"./chunk-LNB5D67B.js";import{e as te,f as re,g as oe,h as se,i as ne,j as ae}from"./chunk-EHARO6IS.js";import{a as F,c as X,d as Z,e as C,f as _,k as ee}from"./chunk-QR6QHTC3.js";import{e as Q}from"./chunk-6L6C3GJU.js";import{d as $}from"./chunk-EEQSUBBL.js";import{n as H,p as L}from"./chunk-KAHWYWNT.js";import{a as U,c as Y,d as E,e as K}from"./chunk-EXLXSKRH.js";import{F as M,G as q,J as G,b as P,c as w,d as v,na as V,p as z,r as k,t as D,w as J}from"./chunk-3UEQ2OX6.js";import{a as h,b as W}from"./chunk-J7FLFHQJ.js";import{a as m}from"./chunk-I2IATJNL.js";import{a as R}from"./chunk-M66BUNYO.js";import{readFile as Je}from"node:fs/promises";import{dirname as Fe,resolve as Me}from"node:path";async function ye(e){let r=[],t=[...e.resolved.failures];for(let o of e.resolved.sources){let s=F(o);if(!s.includes(e.target)){t.push({path:o.path,error:D(o,e.target,s)});continue}let n={sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)},a=E(n);Y(a,o.path)&&e.target!==o.format&&(a=K({...n,suffix:e.target})),r.push({op:"convert",sources:[o],outputs:[a],target:e.target,options:e.options})}return{jobs:r,failures:t}}import{resolve as Ce}from"node:path";function je(e,r=new Set){let t={path:Ce(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:F(e).filter(n=>!o||C(n)),actions:ge([e],r).filter(n=>!o||n.id===j.id).map(n=>n.id)};if(e.kind==="image")return{...t,width:e.width,height:e.height,...s};if(e.kind==="media"){let n=e.facts;return{...t,...n?{duration:n.duration}:{},...n?.video?{width:n.video.width,height:n.video.height,fps:n.video.fps}:{},...s}}return{...t,pages:e.pages,encrypted:e.encrypted,...s}}async function be(e){let r=await y(e,{recursive:!1}),{installedExtensionIds:t}=await import("./available-GYIHVSRX.js"),o=await t();return{probes:r.sources.map(s=>je(s,o)),failures:r.failures}}import{dirname as Be}from"node:path";var B=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function we(e,r){let t=P(Be(e),B(r));return t==="."?"":` in ${t.endsWith("/")?t:`${t}/`}`}function Ie(e,r){let{pct:t,direction:o}=W(e,r);return o==="same"?"same size":`${t}% ${o}`}function xe(e,r={}){let t=e.results[0];if(!t)return[];let o=t.job.sources[0],s=t.job.outputs;if(s.length>1){let a=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${we(s[0],r)}`,` ${s.map(i=>w(i)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} total`];for(let i of t.warnings)a.push("",`\u26A0 ${i.message}`);return a}let n=[`\u2713 ${w(o.path)} \u2192 ${P(s[0],B(r))}`,` ${h(o.bytes)} \u2192 ${h(t.outputBytes)} \xB7 ${Ie(o.bytes,t.outputBytes)}`];for(let a of t.warnings)n.push("",`\u26A0 ${a.message}`);return n}function Pe(e,r={}){let t=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${Ie(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let n of s.job.outputs)t.push(` ${P(n,B(r))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){t.push("");for(let s of o)t.push(`\u26A0 ${s.message}`)}return t}function ve(e,r={}){let t=e.results.flatMap(u=>u.job.outputs),o=t.map(u=>w(u)).join(", "),s=t.length===1?"file":"files",n=t[0]===void 0?"":we(t[0],r),a=[`\u2713 ${t.length} ${s} \xB7 ${o}${n}`],i=e.results.flatMap(u=>u.warnings);for(let u of i)a.push("",`\u26A0 ${u.message}`);return a}function O(e,r){if(e.length===0)return[];let t=[];for(let o of e)t.push(...V(o.error,{debug:r.debug}),"");return t}function ke(){let e=new Set(X()),r=new Set(Z()),t=["Formats",""];for(let s of e){let n=R[s],a=r.has(s)?"read and write":"read only";t.push(` ${n.label.padEnd(6)} ${n.extensions.join(" ").padEnd(12)} ${a}`)}let o=[...e].filter(s=>!r.has(s)).map(s=>R[s].label);if(o.length>0){let s=o.join(", "),[n,a]=o.length===1?["is","it"]:["are","them"];t.push("",`${s} ${n} read only because Forge cannot yet write ${a}.`)}return t}function $e(e,r={}){let t=[R[e.format].label,h(e.bytes)];return e.duration!==void 0&&t.push($(e.duration)),e.width!==void 0&&e.height!==void 0&&t.push(`${e.width}\xD7${e.height}`),e.fps!==void 0&&t.push(`${e.fps} fps`),e.pages!==void 0&&t.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&t.push("password-protected"),[`${P(e.path,B(r))} \xB7 ${t.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Re}from"node:readline";import{PassThrough as Oe}from"node:stream";function Se(e){return new Promise(r=>{let t=Re({input:e,terminal:!1}),o=!1,s=n=>{if(o)return;o=!0,t.close(),e.pause(),e.unref?.(),r(n.replace(/\r$/,""))};t.once("line",s),t.once("close",()=>s(""))})}async function Ee(e){if(e.stdin)return Se(process.stdin);if(!process.stdin.isTTY)return;let r=new Oe,t=Re({input:process.stdin,output:r,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>t.question("",o))}finally{process.stderr.write(`
4
+ `),t.close()}}function T(e){return e.length===0?0:e.some(r=>r.error.code==="invalid-arguments")?2:1}function Ne(e,r){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let t=r.find(a=>a.kind==="document"),o=t?.pages??0,s=e.split;if(!s)throw M("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:fe(o)};if(s.mode==="every-n")return{cuts:le(o,s.n)};let n=Math.max(o-1,0);for(let a of s.after)if(!Number.isInteger(a)||a<1||a>n)throw q(String(a),`"${a}" is outside 1 and ${n} \u2014 ${t?w(t.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(a=>a-1)}}function Te(e,r){let t;return()=>r?(t??=Ee({stdin:e}).then(o=>e&&o===""?void 0:o),t):Promise.resolve(void 0)}async function Ae(e,r,t,o){let s;if(e.encrypted){if(s=r.password??await t(),s===void 0)return{failure:{path:e.path,error:J(e.path)}};let i;try{i=await Q(await Je(e.path),s)}catch{return{failure:{path:e.path,error:J(e.path,{attempted:!0})}}}i.destroy()}let n;try{n=j.plan([e],{target:r.target,background:r.options.background,keepMetadata:r.options.keepMetadata,dpi:String(r.dpi??150),...r.options.quality===void 0?{}:{quality:r.options.quality},...r.pages===void 0?{}:{pages:r.pages},...r.output===void 0?{}:{destination:r.output},...o===void 0?{}:{sourceRoot:o}})}catch(i){if(!v(i))throw i;return{failure:{path:e.path,error:i}}}let a=n[0];if(a?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(a.options.password=s),{job:a}}function S(e,r){return t=>{if(t.type==="search:attempt"){r||e.onSearch?.(t.rung.dpi===void 0?`attempt ${t.attempt} of ${t.of}`:`${t.rung.dpi} dpi \xB7 attempt ${t.attempt} of ${t.of}`);return}if(t.type==="search:settled"){r&&e.onSearch?.(`${t.completed} of ${t.total} searched`);return}if(!r&&t.type==="job:phase"&&t.progress.phase==="time"){let o=t.progress,s=`${$(o.done)} of ${$(o.total)}`;e.onEncode?.(o.pass?`pass ${o.pass.at} of 2 \xB7 ${s}`:s);return}r&&(t.type==="job:done"||t.type==="job:error")&&e.onProgress?.({completed:t.completed,total:t.total})}}var b=(e,r)=>({kind:e,results:[],failures:r,inputBytes:0,outputBytes:0});async function We(e){let r=await y(e.inputs,{recursive:!1});if(r.sources.length===0)return b("pageop",r.failures);let t=me.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=he(t,r.sources)??"not available for these files";return b("pageop",[...r.failures,{path:o,error:k(e.action,a)}])}let s;try{s=t.plan(r.sources,Ne(e,r.sources))}catch(a){if(!v(a))throw a;return b("pageop",[...r.failures,{path:o,error:a}])}let n=await I(s,{force:e.force});return{kind:"pageop",results:n.results,failures:[...r.failures,...n.refusals,...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function ze(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let i of t.sources){if(!N.appliesTo([i])){s.push({path:i.path,error:z(i)});continue}let u=e.output!==void 0&&!U(e.output)?Me(e.output):void 0,g=e.output===void 0||u!==void 0?Fe(i.path):Fe(E({sourcePath:i.path,target:i.format,output:e.output,sourceRoot:t.roots.get(i.path)})),[d]=N.plan([i],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},...e.options.media??{},destination:g});d?.op==="convert"&&(u!==void 0&&(d.outputs=[u]),e.dpi!==void 0&&(d.options.dpi=e.dpi),o.push(d))}let n=o.length>1;n&&r.onProgress?.({completed:0,total:o.length});let a=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,n)});return{kind:"compress",results:a.results,failures:[...t.failures,...s,...a.refusals,...a.unreachable.map(i=>({path:i.job.sources[0].path,error:i.error})),...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function De(e,r){let t=e.kind,o=e.op==="remove-background"?H(e.target):void 0;if(o)return b(t,[{path:"",error:o}]);let{installed:s}=await import("./paths-5XI5L4KW.js"),n=await s(e.op);if(!n)return b(t,[{path:"",error:G(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:c,catalogEntry:p}=await import("./catalog-YSMT3PXT.js"),f=p("boost"),x=f&&c(f)?.version,A=L(e.scale,n.version,x);if(A)return b(t,[{path:"",error:A}])}let a=await y(e.inputs,{recursive:e.recursive}),i=e.op==="boost"?ue:pe,u=[],g=[];for(let c of a.sources){if(!i.appliesTo([c])){g.push({path:c.path,error:k(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let p=ie(c,e.target);if(p){g.push({path:c.path,error:p});continue}u.push(...i.plan([c],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:a.roots}))}let d=u.length>1;d&&r.onProgress?.({completed:0,total:u.length});let l=await I(u,{force:e.force,concurrency:1,...r.signal===void 0?{}:{signal:r.signal},onEvent:S(r,d)});return{kind:t,results:l.results,failures:[...a.failures,...g,...l.refusals,...l.failures],inputBytes:l.inputBytes,outputBytes:l.outputBytes}}async function qe(e,r){let t=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:ee(e.target,t);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),n=[],a=[],i=[];for(let p of s.sources)p.kind==="image"&&e.media===void 0?n.push(p):p.kind==="media"&&!e.trim?a.push(p):p.kind==="image"?i.push({path:p.path,error:k("cut","it works on video and sound, not images","Try a video or sound file, such as a MOV, MP4 or WAV.")}):i.push({path:p.path,error:k(t,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=ce(a,{...e.media===void 0?{}:{media:e.media},...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots}),d=[...de(n,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),...u],l=d.length>1;l&&r.onProgress?.({completed:0,total:d.length});let c=await I(d,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:S(r,l)});return{kind:e.kind,results:c.results,failures:[...s.failures,...i,...c.refusals,...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function Ge(e,r){let t=await y(e.inputs,{recursive:e.recursive}),o=f=>f.kind==="document"&&f.format==="pdf",s=C(e.target),n=s?t.sources.filter(o):[],a=s?t.sources.filter(f=>!o(f)):t.sources,i=[],u=[],g=Te(e.passwordStdin??!1,r.interactive??!0);for(let f of n){let x=await Ae(f,e,g,t.roots.get(f.path));"failure"in x?u.push(x.failure):i.push(x.job)}let d=await ye({resolved:{sources:a,failures:[],roots:t.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),l=[...d.jobs,...i],c=l.length>1;c&&r.onProgress?.({completed:0,total:l.length});let p=await I(l,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(r,c)});return{kind:"convert",results:p.results,failures:[...t.failures,...u,...d.failures,...p.refusals,...p.unreachable.map(f=>({path:f.job.sources[0].path,error:f.error})),...p.failures],inputBytes:p.inputBytes,outputBytes:p.outputBytes}}async function Ve(e,r={}){try{if(e.kind==="pageop")return await We(e);if(e.kind==="extension-op")return await De(e,r);if(e.kind==="edit")return await qe(e,r);if(e.kind==="preset"){let{runPresetCommand:t}=await import("./preset-command-HORY7KZQ.js");return await t(e)}return e.kind==="compress"?await ze(e,r):await Ge(e,r)}catch(t){if(!v(t))throw t;return b(e.kind,[{path:"",error:t}])}}function He(e,r){let t=T(e.failures);if(r.json)return{exitCode:t,stdout:[JSON.stringify(te(m,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?ve(e):e.results.length===1?xe(e):Pe(e);return{exitCode:t,stdout:o,stderr:O(e.failures,{debug:r.debug})}}function Le(e,r){let t=[{path:"",error:e}],o=T(t);return r.json?{exitCode:o,stdout:[JSON.stringify(re(m,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:O(t,{debug:r.debug})}}async function Ue(e,r){let{runConfig:t}=await import("./config-command-TYNYVUMP.js"),o=await t(e);return r?{exitCode:0,stdout:[JSON.stringify(ne(m,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function Tt(e,r={}){let t=r.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Ue(e,t);if(e.kind==="clip"){let{runClipCommand:s}=await import("./clip-command-SGB3B4OJ.js");return await s(e,{...r,json:t,debug:o})}if(e.kind==="update"){let{runUpdate:s}=await import("./update-command-GMBG7BK6.js"),n=await s(m,{...r.onInstalling?{onInstalling:r.onInstalling}:{}});return{exitCode:0,stdout:t?[JSON.stringify({forge:m,ok:!0,...n.data})]:n.stdout,stderr:[]}}if(e.kind==="uninstall"){let{runUninstall:s}=await import("./entry-3PEVSH2X.js"),n=[];return{exitCode:await s(m,i=>n.push(i)),stdout:n,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:s}=await import("./extensions-command-L2AT6OVR.js"),n=await s(e,{onDownload:r.onDownload});return{exitCode:0,stdout:t?[JSON.stringify(ae(m,n.data))]:n.stdout,stderr:[]}}if(e.kind==="formats")return t?{exitCode:0,stdout:[JSON.stringify(oe(m,_()))],stderr:[]}:{exitCode:0,stdout:ke(),stderr:[]};if(e.kind==="probe"){let{probes:s,failures:n}=await be(e.inputs),a=T(n);return t?{exitCode:a,stdout:[JSON.stringify(se(m,{probes:s,failures:n}))],stderr:[]}:{exitCode:a,stdout:s.flatMap((i,u)=>[...u>0?[""]:[],...$e(i)]),stderr:O(n,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"){let{runPalette:s,runScale:n}=await import("./colour-QMGYV6WQ.js"),a={json:t,colour:r.colour??!1};return e.kind==="palette"?await s(e,a):await n(e,a)}if(e.kind==="transcribe"){let{runTranscribeCommand:s}=await import("./transcribe-command-YUSBCQEQ.js"),n=[],a=[];return{exitCode:await s(e,{out:u=>n.push(u),err:u=>a.push(u)}),stdout:n,stderr:a}}if(e.kind==="shell")return{exitCode:0,stdout:[],stderr:[]};if(e.kind==="watch")throw M("forge watch runs in a terminal until ctrl-c.","Try: forge watch ./images --to webp");return He(await Ve(e,r),{json:t,debug:o})}catch(s){if(!v(s))throw s;return Le(s,{json:t,debug:o})}}export{be as a,Ie as b,T as c,Ve as d,He as e,Tt as f};