forge-terminal 0.3.9 → 0.4.1

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 (104) hide show
  1. package/README.md +107 -11
  2. package/dist/chunks/{about-credits-NCKQZJMR.js → about-credits-GRSA5RLZ.js} +1 -1
  3. package/dist/chunks/args-VJZHLGIY.js +3 -0
  4. package/dist/chunks/{available-QN6QAGCU.js → available-GYIHVSRX.js} +1 -1
  5. package/dist/chunks/boot-HVIAAJMY.js +3 -0
  6. package/dist/chunks/{catalog-O3V24DK7.js → catalog-YSMT3PXT.js} +1 -1
  7. package/dist/chunks/check-KAR72Y4X.js +3 -0
  8. package/dist/chunks/chunk-3UEQ2OX6.js +3 -0
  9. package/dist/chunks/chunk-5B5XXH22.js +3 -0
  10. package/dist/chunks/chunk-5IS7O673.js +6 -0
  11. package/dist/chunks/chunk-6FUVEO3A.js +78 -0
  12. package/dist/chunks/chunk-6L6C3GJU.js +3 -0
  13. package/dist/chunks/chunk-AAXBN572.js +4 -0
  14. package/dist/chunks/chunk-CKUIRXDS.js +4 -0
  15. package/dist/chunks/chunk-DERIWZAT.js +3 -0
  16. package/dist/chunks/chunk-DOWMSJ6R.js +3 -0
  17. package/dist/chunks/chunk-EEQSUBBL.js +3 -0
  18. package/dist/chunks/chunk-EGIKV2GZ.js +4 -0
  19. package/dist/chunks/{chunk-3GVFOZ7M.js → chunk-EHARO6IS.js} +1 -1
  20. package/dist/chunks/{chunk-ZRP5CWIK.js → chunk-EX7KZBI6.js} +1 -1
  21. package/dist/chunks/chunk-EXLXSKRH.js +3 -0
  22. package/dist/chunks/chunk-FH3R2YYD.js +19 -0
  23. package/dist/chunks/chunk-FHORNIVW.js +3 -0
  24. package/dist/chunks/{chunk-TEO2EUS3.js → chunk-GJ2GZHRI.js} +1 -1
  25. package/dist/chunks/chunk-HZDYZ5RD.js +3 -0
  26. package/dist/chunks/chunk-I63TO22X.js +3 -0
  27. package/dist/chunks/chunk-IGF6ZFTM.js +4 -0
  28. package/dist/chunks/{chunk-MBTGANIR.js → chunk-IWFVEMDN.js} +1 -1
  29. package/dist/chunks/{chunk-SAWVMQAD.js → chunk-JFJ3ZJQL.js} +2 -2
  30. package/dist/chunks/chunk-JSMGNA55.js +3 -0
  31. package/dist/chunks/chunk-KAHWYWNT.js +3 -0
  32. package/dist/chunks/chunk-LDKF7KIZ.js +6 -0
  33. package/dist/chunks/chunk-LNB5D67B.js +3 -0
  34. package/dist/chunks/chunk-M66BUNYO.js +3 -0
  35. package/dist/chunks/chunk-MKVBI37R.js +63 -0
  36. package/dist/chunks/chunk-PSEIJXGT.js +3 -0
  37. package/dist/chunks/chunk-QR6QHTC3.js +3 -0
  38. package/dist/chunks/chunk-SMBK6BTC.js +3 -0
  39. package/dist/chunks/chunk-TDW6KQH6.js +3 -0
  40. package/dist/chunks/chunk-TMQDQLY7.js +21 -0
  41. package/dist/chunks/chunk-VGS5Z5RD.js +66 -0
  42. package/dist/chunks/chunk-YWKMG5WO.js +3 -0
  43. package/dist/chunks/{chunk-I6QBBRCE.js → chunk-YYB3TTGT.js} +1 -1
  44. package/dist/chunks/clip-command-264DPO6I.js +3 -0
  45. package/dist/chunks/colour-4NH6H4HA.js +3 -0
  46. package/dist/chunks/command-I5M275ZV.js +3 -0
  47. package/dist/chunks/config-command-TYNYVUMP.js +3 -0
  48. package/dist/chunks/entry-26YSXWT4.js +6 -0
  49. package/dist/chunks/execute-GSC2NMDW.js +3 -0
  50. package/dist/chunks/extensions-ADGECS5U.js +3 -0
  51. package/dist/chunks/{extensions-command-UGXZIFRI.js → extensions-command-TGOF36YW.js} +1 -1
  52. package/dist/chunks/ffmpeg-PF3VLTHK.js +3 -0
  53. package/dist/chunks/image-J4FT4ACZ.js +3 -0
  54. package/dist/chunks/install-2A5BGKQU.js +3 -0
  55. package/dist/chunks/install-V62EEK54.js +3 -0
  56. package/dist/chunks/launch-KBYCYAZR.js +5 -0
  57. package/dist/chunks/lock-KN7CF4YN.js +3 -0
  58. package/dist/chunks/manager-J7377NNA.js +4 -0
  59. package/dist/chunks/{paths-H2WS22BA.js → paths-5XI5L4KW.js} +1 -1
  60. package/dist/chunks/pdf-compress-U2E3CNXG.js +3 -0
  61. package/dist/chunks/preferences-4VETUGMN.js +3 -0
  62. package/dist/chunks/preset-command-HORY7KZQ.js +3 -0
  63. package/dist/chunks/run-6BK4REXK.js +4 -0
  64. package/dist/chunks/{server-XOMQGAIG.js → server-OAJFUZDM.js} +16 -15
  65. package/dist/chunks/{theme-ZSHECPGW.js → theme-WGCMV4T4.js} +1 -1
  66. package/dist/chunks/transcribe-command-YUSBCQEQ.js +3 -0
  67. package/dist/chunks/update-command-GMBG7BK6.js +3 -0
  68. package/dist/chunks/update-note-6YGNGYUB.js +3 -0
  69. package/dist/chunks/watch-command-HOG4TM3X.js +3 -0
  70. package/dist/helpers/forge-transcribe +0 -0
  71. package/dist/index.js +15 -63
  72. package/package.json +23 -1
  73. package/skills/forge/SKILL.md +7 -0
  74. package/dist/chunks/boot-ZJLZZHA7.js +0 -3
  75. package/dist/chunks/check-BRP6EKSA.js +0 -3
  76. package/dist/chunks/chunk-32VJ2RDH.js +0 -3
  77. package/dist/chunks/chunk-3V4DKIWP.js +0 -66
  78. package/dist/chunks/chunk-4QQEJ6YG.js +0 -3
  79. package/dist/chunks/chunk-C7YNQXXO.js +0 -3
  80. package/dist/chunks/chunk-DVJAGA5L.js +0 -19
  81. package/dist/chunks/chunk-F4ZPFXWD.js +0 -4
  82. package/dist/chunks/chunk-GGBNT4WI.js +0 -3
  83. package/dist/chunks/chunk-GNLE6JXL.js +0 -3
  84. package/dist/chunks/chunk-H2IUSPAK.js +0 -4
  85. package/dist/chunks/chunk-J3VS5AUZ.js +0 -4
  86. package/dist/chunks/chunk-LW2QEXDT.js +0 -3
  87. package/dist/chunks/chunk-MMRDELHW.js +0 -3
  88. package/dist/chunks/chunk-X54KIHCN.js +0 -4
  89. package/dist/chunks/chunk-YILLB45O.js +0 -3
  90. package/dist/chunks/colour-54Z3FBNN.js +0 -3
  91. package/dist/chunks/config-command-TXQUYFA6.js +0 -3
  92. package/dist/chunks/execute-4OBEIICQ.js +0 -3
  93. package/dist/chunks/extensions-7RTIGFIG.js +0 -3
  94. package/dist/chunks/image-F5D73JPQ.js +0 -3
  95. package/dist/chunks/install-YG43OJ7P.js +0 -3
  96. package/dist/chunks/launch-2I52TGLD.js +0 -4
  97. package/dist/chunks/lock-6KTGUFBY.js +0 -3
  98. package/dist/chunks/manager-XN7WNMEW.js +0 -4
  99. package/dist/chunks/pdf-compress-IMRFBLZF.js +0 -3
  100. package/dist/chunks/preferences-YL6SRNZR.js +0 -3
  101. package/dist/chunks/restart-RO6DM5N3.js +0 -3
  102. package/dist/chunks/run-XQYPVWFI.js +0 -4
  103. package/dist/chunks/update-command-6VNVMAYO.js +0 -3
  104. package/dist/chunks/update-note-MJPR4GHH.js +0 -3
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.9
46
+ # 0.4.1
47
47
 
48
48
  forge photo.jpg --to webp
49
49
  ```
@@ -90,12 +90,48 @@ legacy binary already claims that name and Homebrew still installs it.)
90
90
 
91
91
  ```bash
92
92
  npm update -g forge-terminal # update
93
- npm uninstall -g forge-terminal # remove
93
+ forge uninstall # remove
94
94
  ```
95
95
 
96
+ `forge uninstall` takes Forge's [right-click menu](#right-click-menu) out
97
+ first, then runs `npm uninstall -g forge-terminal` itself. npm runs nothing
98
+ when a package is removed, so `npm uninstall -g` on its own leaves the menu
99
+ items behind; the first click on one of those finds Forge gone, removes them
100
+ all, and says so.
101
+
96
102
  From source, `git pull && npm install && npm run build` updates and
97
103
  `npm unlink -g forge-terminal` removes.
98
104
 
105
+ ## Right-click menu
106
+
107
+ On a Mac and on Windows, Forge adds itself to the right-click menu the first
108
+ time you run `forge`, and says so once:
109
+
110
+ | Right-click | Items |
111
+ | --- | --- |
112
+ | an image | Open Forge · Convert in Forge · Compress in Forge · Sharpen in Forge |
113
+ | a folder | Open Forge · Convert in Forge · Compress in Forge |
114
+ | a PDF | Open in Forge |
115
+
116
+ - **Open Forge** opens Forge in a terminal window, nothing staged.
117
+ - **Convert in Forge** and **Compress in Forge** open it with the file staged
118
+ and that mode's first question already asked.
119
+ - **Open in Forge** opens a PDF staged in PDF mode.
120
+ - **Sharpen in Forge** runs with no window, says how it went in a
121
+ notification, and selects the new file. It is there once the Boost
122
+ extension is installed (`forge extensions add boost`).
123
+
124
+ Forge opens in the terminal you last ran it in: Terminal, iTerm or Ghostty on
125
+ a Mac; Windows Terminal, or a console window, on Windows. Each item's icon is
126
+ Forge's logo with the slashes in its mode's colour.
127
+
128
+ On a Mac the items are under **Quick Actions**, and Finder's own
129
+ **Customize…** at the bottom of that menu hides any you do not want. On
130
+ Windows 11 they are under **Show more options** (or shift + right-click): an
131
+ image's and a folder's in a **Forge** submenu, a PDF's one item on its own. They are set up only for a Forge installed with
132
+ `npm install -g`; from a source checkout, `forge menu install` sets them up
133
+ by hand and `forge menu remove` takes them out.
134
+
99
135
  ## Configuration
100
136
 
101
137
  Forge stores preferences at `~/.config/forge/config.json`, or
@@ -226,9 +262,16 @@ forge *.jpg --max-size 1mb # a whole folder
226
262
  has. `--quality` and `--max-size` are mutually exclusive — they ask the same
227
263
  question two ways, and Forge will not guess which wins.
228
264
 
229
- Compression only applies to formats with a quality dial. A PNG is lossless, so
230
- there is nothing to trade away; `/convert` it to WebP instead, and Forge says
231
- so if you try.
265
+ A PNG or GIF is compressed by cutting it to fewer colours, which is what
266
+ makes it lossy here: `/convert` keeps both lossless. The slider stops at three
267
+ points, 30 · 65 · 100, since a palette's size moves in steps; `--quality` takes
268
+ any number. Colours stay flat unless you press `d` for dithering, which looks
269
+ smoother and costs bytes. A GIF keeps every frame and its timing.
270
+
271
+ Compressing never writes a bigger file. A file another tool already squeezed,
272
+ or a JPEG asked for more quality than it was saved at, would grow, so Forge
273
+ says "Cannot compress more" and writes nothing. A TIFF is lossless with no
274
+ palette to cut; `/convert` it to WebP instead.
232
275
 
233
276
  After compressing, if another format would be meaningfully smaller, Forge says
234
277
  so — and it encodes a candidate to find out rather than guessing:
@@ -241,6 +284,59 @@ so — and it encodes a candidate to find out rather than guessing:
241
284
  ↵ convert another · c convert to WebP · o open · s show in finder · ctrl-c close app
242
285
  ```
243
286
 
287
+ ## The clipboard
288
+
289
+ On a Mac, a copied image can be the file. Copy a screenshot (⌃⇧⌘4) or an
290
+ image in a browser, Figma or Preview, and home's field says `⌘V to paste from
291
+ clipboard`. ⌘V lands it as a card named **Copied image**; pick a mode as for
292
+ any file. There is no Save as: the result goes back on the clipboard, so the
293
+ next ⌘V — in Slack, GitHub, a chat — pastes it. On Done, `u` puts the original
294
+ back and `s` also saves the result to the default folder.
295
+
296
+ If your terminal sends nothing on ⌘V with only a picture copied, ctrl-v does
297
+ the same.
298
+
299
+ Forge never overwrites something you copied while it worked: the result is
300
+ saved to the default folder instead, and Done says so. A compression that
301
+ would come out larger is never put back.
302
+
303
+ From the command line:
304
+
305
+ ```bash
306
+ forge clip # compress the copied image, then ⌘V
307
+ forge clip --max-size 1mb # to fit
308
+ forge clip --to webp # convert it on the clipboard
309
+ forge clip --save ~/Desktop # and keep a file too
310
+ forge clip --undo # put the last original back
311
+ ```
312
+
313
+ Agents get the same as the MCP tool `forge_clip`.
314
+
315
+ ## Watch a folder
316
+
317
+ Drop a folder on home in convert mode: it is one card, **FOLDER – its name**.
318
+ ↵ asks what to convert to, as for a file, then converts every file in it and
319
+ keeps watching: any file you add afterwards is converted too, a row each,
320
+ until you press ↵. A folder holding several kinds of file (images, PDFs, …)
321
+ asks once per kind; ↵ on a kind opens a window to change its answer.
322
+
323
+ Files are read by their content once they stop changing, so a screenshot or a
324
+ download is never read half-written. Forge never picks up its own output, and
325
+ dropping the same folder again leaves what it already converted alone.
326
+
327
+ From the command line:
328
+
329
+ ```bash
330
+ forge watch ./images --to webp # convert what is there, then each new file
331
+ forge watch ./images --to webp -q 70 # at a quality
332
+ forge watch ./scans --to png --dpi 300 # PDFs, a page each
333
+ forge watch ./images --to webp -o ./dist # into another folder
334
+ forge watch ./images --to webp --new-only # only what lands from now on
335
+ forge watch ./images --to webp --json # one JSON document per line, per event
336
+ ```
337
+
338
+ ctrl-c stops it and prints the totals.
339
+
244
340
  ## Resize and trim edges
245
341
 
246
342
  Both need nothing extra, keep the file's own format unless `--to` says otherwise,
@@ -283,7 +379,7 @@ flags resize does, and is refused with the same ones — and with `--trim`: run
283
379
  one, then the other. Cropping an animated image is refused; so is cropping one
284
380
  that already has the shape, unless it is also resized, which then only warns.
285
381
  `forge_convert` takes `crop: "1:1"` (any `W:H`), and then `to` is optional.
286
- In the app, Crop to shape is an Enhance row with a preview you can move and
382
+ In the app, Crop to shape is an Edit row with a preview you can move and
287
383
  zoom.
288
384
 
289
385
  ## Boost resolution and remove background
@@ -327,7 +423,7 @@ while that extension is installed, and `--json` results report `op: "boost"` or
327
423
  `op: "remove-background"`. `forge_convert` accepts `sharpen: true`, `boost: 2 | 3 | 4` and
328
424
  `removeBackground: true`, with the same `extension-missing` tool error.
329
425
 
330
- The shell's enhance Done shows the real pictures in iTerm2, WezTerm, Kitty and Ghostty (a half-block close-up elsewhere); `FORGE_INLINE_IMAGES=0` turns them off, `=1` forces them on (e.g. tmux with passthrough).
426
+ The shell's edit Done shows the real pictures in iTerm2, WezTerm, Kitty and Ghostty (a half-block close-up elsewhere); `FORGE_INLINE_IMAGES=0` turns them off, `=1` forces them on (e.g. tmux with passthrough).
331
427
 
332
428
  ## PDF
333
429
 
@@ -933,7 +1029,7 @@ photo.png · PNG · 122 KB · 2756×774
933
1029
  With `--json`:
934
1030
 
935
1031
  ```json
936
- {"forge":"0.3.9","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.1","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
1033
  ```
938
1034
 
939
1035
  `targets` and `actions` come from the engines' own capabilities, so they are
@@ -941,8 +1037,8 @@ always true for that file. `format` is read from the file's content, not its
941
1037
  name. `actions` lists `convert` plus what else applies: `compress`,
942
1038
  `split`, `extract`, `delete`, `rotate`; `merge` appears only when several
943
1039
  PDFs are probed together. `compress` appears when quality or size can be
944
- reduced: lossy images, and PDFs that contain compressible images (a PNG has
945
- only `convert`). Run it as `--quality N` or `--max-size S` without `--to`;
1040
+ reduced: lossy images, PNG and GIF, and PDFs that contain compressible images
1041
+ (a TIFF has only `convert`). Run it as `--quality N` or `--max-size S` without `--to`;
946
1042
  its `--json` result reports `op: "convert"`. The encrypted PDF above omits
947
1043
  `compress` and `merge`; a plain PDF with images would also list `compress`.
948
1044
  A probe has `width`/`height` for an image,
@@ -959,7 +1055,7 @@ succeeded) and `failures`. A conversion, compression or page operation adds
959
1055
 
960
1056
  ```jsonc
961
1057
  {
962
- "forge": "0.3.9",
1058
+ "forge": "0.4.1",
963
1059
  "ok": false,
964
1060
  "results": [
965
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-XN7WNMEW.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-7RTIGFIG.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-J7377NNA.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-ADGECS5U.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};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a,b,c,d}from"./chunk-MKVBI37R.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-EGIKV2GZ.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{c as t}from"./chunk-ZRP5CWIK.js";import"./chunk-HON4OV7M.js";import{a as i}from"./chunk-YILLB45O.js";import"./chunk-TMUK2DD3.js";async function l(){let e=await Promise.all(i.map(async n=>await t(n.id)?n.id:null));return new Set(e.filter(n=>n!==null))}export{l as installedExtensionIds};
3
+ import{c as t}from"./chunk-EX7KZBI6.js";import"./chunk-HON4OV7M.js";import{a as i}from"./chunk-5B5XXH22.js";import"./chunk-TMUK2DD3.js";async function l(){let e=await Promise.all(i.map(async n=>await t(n.id)?n.id:null));return new Set(e.filter(n=>n!==null))}export{l as installedExtensionIds};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{r as l}from"./chunk-EGIKV2GZ.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-KBYCYAZR.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,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,e}from"./chunk-YILLB45O.js";import"./chunk-TMUK2DD3.js";export{a as CATALOG,c as assetFor,b as catalogEntry,e as offeredHere,d as offeredOn};
3
+ import{a,b,c,d,e}from"./chunk-5B5XXH22.js";import"./chunk-TMUK2DD3.js";export{a as CATALOG,c as assetFor,b as catalogEntry,e as offeredHere,d as offeredOn};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-IGF6ZFTM.js";import"./chunk-AAXBN572.js";import"./chunk-HON4OV7M.js";import"./chunk-M66BUNYO.js";import"./chunk-TMUK2DD3.js";export{b as CHECK_EVERY_MS,e as MAX_NOTES,g as NOTE_TEXT,f as NOTE_TITLE,a as REGISTRY_URL,o as availableUpdate,h as cachePath,m as checkNow,l as fetchLatest,c as isNewer,k as isStale,i as readCache,d as updateChecksEnabled,n as whatsNewFor,j as writeCache};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as s}from"./chunk-J7FLFHQJ.js";import{a}from"./chunk-M66BUNYO.js";import{homedir as m}from"node:os";import{posix as p,win32 as g}from"node:path";var f=/[\u0000-\u001f\u007f-\u009f‪-‮⁦-⁩]/g;function d(e){return e.replace(f,"?")}function c(e,t,n){let i=n.relative(t,e);if(i==="")return"";if(!(i===".."||i.startsWith(`..${n.sep}`)||n.isAbsolute(i)))return i}function C(e,t={}){return d(w(e,t))}function w(e,t){let n=(t.platform??process.platform)==="win32"?g:p;if(t.cwd!==void 0){let l=c(e,t.cwd,n);if(l!==void 0)return l===""?".":l}let i=c(e,t.home??m(),n);return i!==void 0?i===""?"~":`~${n.sep}${i}`:e}function r(e,t=process.platform){return d((t==="win32"?g:p).basename(e))}import{dirname as b}from"node:path";var o=class extends Error{code;title;detail;short;hint;shellHint;constructor(t){super(`${t.title}: ${t.detail}`,t.cause===void 0?void 0:{cause:t.cause}),this.name="ForgeError",this.code=t.code,this.title=t.title,this.detail=t.detail,this.short=t.short,this.hint=t.hint,this.shellHint=t.shellHint}};function $(e){return e instanceof o}function N(e){return new o({code:"file-not-found",title:"File not found",detail:`${r(e)} could not be found.`,short:`${r(e)} could not be found.`,hint:"Check the filename and try again."})}function U(e){return new o({code:"not-a-file",title:"Not a file",detail:`${r(e)} is not a file.`,short:`${r(e)} is not a file.`,hint:"Point Forge at an image, or at a directory of images."})}function D(e){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(e)} could not be read.`,short:`${r(e)} could not be read.`,hint:"Check the file permissions and try again."})}function O(e){return new o({code:"not-a-directory",title:"Invalid path",detail:`${r(e)} could not be found: part of its path is not a directory.`,short:`part of ${r(e)}'s path is not a folder.`,hint:"Check the path and try again."})}function z(e){return new o({code:"symlink-loop",title:"Too many symbolic links",detail:`${r(e)} could not be resolved: its path contains a symbolic-link loop.`,short:`${r(e)}'s path loops back on itself.`,hint:"Check for a circular symlink somewhere in the path."})}function A(e){return new o({code:"path-too-long",title:"Path too long",detail:`${r(e)}'s path is too long for the filesystem to resolve.`,short:`${r(e)}'s path is too long.`,hint:"Use a shorter path and try again."})}function j(e,t){return new o({code:"unreadable-path",title:"Could not read path",detail:`${r(e)} could not be checked.`,short:`${r(e)} could not be checked.`,hint:"Check the path and try again.",cause:t})}function M(e,t){return new o({code:"unsupported-source",title:"Unsupported file type",detail:`${r(e)} is ${t}, which Forge cannot read.`,short:`${r(e)} is ${t}, which Forge cannot read.`,hint:"Forge 0.1 handles images only."})}function J(e,t){return new o({code:"unsupported-source",title:"Not an image",detail:`${r(e)} is ${t}, not an image.`,hint:"A palette is taken from a photo, a screenshot or artwork."})}function R(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${r(e)} has no visible pixels.`})}function W(e,t=process.platform){return t==="win32"?new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e,t)} is a HEIC photo, which needs Forge's free HEIC extension on Windows.`,short:"HEIC needs the heic extension.",hint:"Install it with: forge extensions add heic",shellHint:"Open /extensions to install it."}):new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e)} is a HEIC photo, which Forge decodes with the macOS sips tool.`,short:"HEIC needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function q(e,t){let n=r(e.path);if(t!==void 0&&t!==e.format){let i=a[t].label;return a[t].lossy?new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`Forge cannot search ${n} \u2192 ${i} toward a size yet.`,hint:"Convert it first, then compress the result with --max-size.",shellHint:"Convert it first, then /compress the result to a size."}):new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`${i} is lossless \u2014 there is no quality to trade away, so ${n} cannot be made to fit as ${i}.`,hint:"Drop --max-size, or choose a lossy target. forge --formats lists them.",shellHint:"Choose a lossy target to aim for a size."})}if(e.kind==="document"&&e.format==="pdf"){let i=e.images?.skipped??0;return new o({code:"unsupported-compress",title:"Nothing to compress",detail:i>0?`${n}'s images are a kind Forge cannot re-encode, so there is nothing to make smaller.`:`${n} has no images \u2014 it is text and layout, which compression cannot shrink.`,hint:"Try a page operation such as --extract to keep fewer pages, or --to <format> to turn its pages into images.",shellHint:"Try /pdf to keep fewer pages, or /convert to turn its pages into images."})}return e.kind==="document"?new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${a[e.format].label}, which has no images Forge can re-encode.`,hint:`Use --to pdf to change it to PDF instead: forge ${n} --to pdf`,shellHint:"Use /convert to change it to PDF instead."}):new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${a[e.format].label}, which is lossless \u2014 there is no quality to trade away.`,hint:"Use --to to change it to a smaller format instead. forge --formats lists them.",shellHint:"Use /convert to change it to a smaller format instead."})}function L(e){let t=r(e.path);return new o({code:"unsupported-pdf",title:"/pdf needs a PDF",detail:`${t} is ${a[e.format].label}, not a PDF.`,hint:"Converting it instead."})}function V(e,t,n){return new o({code:"unsupported-operation",title:`Cannot ${e} these files`,detail:`Not available for these files: ${t}.`,hint:n??"Page operations work on PDFs: --merge takes two or more, the others take one.",shellHint:n??"Use /pdf with a PDF staged \u2014 two or more for merge."})}function _(e,t,n){let i=e.kind==="media"?`The smallest ${r(e.path)} can get is ${s(n)}, which is still over ${s(t)}.`:`${r(e.path)} is ${s(n)} even at the lowest quality, which is still over ${s(t)}.`;return new o({code:"target-unreachable",title:"Cannot get that small",detail:i,hint:"Try a larger --max-size, or --to a smaller format.",shellHint:"Try a larger target, or /convert to a smaller format."})}function B(e,t,n){return new o({code:"unsupported-target",title:`Can't convert ${r(e.path)} to ${t}`,detail:`${r(e.path)} is a ${a[e.format].label} ${e.kind==="image"?"image":"document"}.`,hint:`Available: ${n.join(", ")}`})}function X(e,t){return new o({code:"corrupt-source",title:"Damaged file",detail:`${r(e)} could not be read. It may be damaged, or not a format Forge recognises.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:t})}function Y(e,t,n){return new o({code:"corrupt-source",title:`Damaged ${a[t].label}`,detail:`${r(e)} is a ${a[t].label} file, but its content could not be read.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:n})}function G(e,t={}){let n=r(e);return new o({code:"encrypted-source",title:"This PDF is password-protected",detail:`${n} is password-protected.`,short:`${n} is password-protected.`,hint:t.attempted?"That password didn't open it. Check it and try again.":`Convert it to images instead: forge ${n} --to jpeg --password-stdin`})}var u=e=>e==="convert"||e==="boost"||e==="remove-background";function K(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${r(e)} is already there.`,hint:u(t)?"Pass --force to replace it, or choose a different --output.":"Pass --force to replace it, or move the existing file out of the way.",shellHint:"Run it again and Forge will ask before replacing it."})}function Q(e,t){return new o({code:"output-collision",title:"Two files want the same output",detail:`${r(e[0])} and ${r(e[1])} would both become ${r(t)}.`,hint:"Convert them separately, or use --output to send them to different folders.",shellHint:"Convert them one at a time."})}function Z(e,t){return new o({code:"output-collision",title:"One output, written twice",detail:`${r(e)} would write ${r(t)} twice, and only the second would survive.`,hint:"Every output has to be its own file. Check the selection for a repeated page."})}function ee(e,t="convert"){return new o({code:"output-is-input",title:"Output would replace the original",detail:`${r(e)} is both the input and the output.`,hint:u(t)?"Choose a different --output, or pass --force to overwrite in place.":"Move or rename that file first, or pass --force to overwrite it in place.",shellHint:u(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function x(e,t){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(b(e))} is not a folder you can write to.`,hint:"Choose a different --output, or check the folder permissions.",shellHint:"Choose a different folder, or check its permissions.",cause:t})}var y=new Set(["EACCES","EPERM","EROFS"]);function te(e,t){if($(t))return t;let n=t?.code;return n!==void 0&&y.has(n)?x(e,t):t}function oe(e,t){return new o({code:"output-invalid",title:"Cannot write there",detail:`${e} could not be written to.`,hint:"Check that the path is valid and that you have permission to write to it.",cause:t})}function ne(e){return new o({code:"empty-directory",title:"No images found",detail:`${r(e)} contains no images Forge can convert.`,hint:"Try --recursive to look inside subfolders.",shellHint:"Only files directly inside a folder are read \u2014 drop the files themselves, or the folder that holds them."})}function re(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function ie(e,t,n){return new o({code:"invalid-page-range",title:"Page range not understood",detail:t,hint:`This document has ${n} pages. Use numbers and spans, like "3-7, 12, 20-".`})}function se(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function ae(e){return new o({code:"invalid-dpi",title:"Invalid resolution",detail:`${String(e)} is not a resolution Forge can use.`,hint:"Give a number between 36 and 600. The default is 150."})}function le(e){return new o({code:"extension-missing",title:"Extension not installed",detail:`${e} is an optional extension and is not installed.`,hint:`Install it with: forge extensions add ${e}`,shellHint:"Open /extensions to install it."})}function de(e,t,n,i){return new o({code:"extension-outdated",title:"Extension out of date",detail:`${e} ${n} cannot ${t}; that needs ${i} or later.`,hint:`Update it with: forge extensions add ${e}`,shellHint:"Open /extensions to update it."})}function ue(e,t){return new o({code:"extension-corrupt",title:"Extension failed verification",detail:`${e}: ${t}`,hint:`Nothing was installed. Try again with: forge extensions add ${e}`,shellHint:"Nothing was installed. Try again from /extensions."})}function ce(e,t,n=process.platform){let i=n==="win32"?"PC":"Mac";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} cannot be installed on this ${i}: ${t}`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function pe(e,t=process.platform){let n=t==="win32"?"Windows":t==="darwin"?"macOS":"this system";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} is not available on ${n}.`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function ge(e){return new o({code:"update-unavailable",title:"Cannot update this Forge",detail:`This copy of Forge was not installed with npm i -g, so ${e} cannot be installed over it.`,hint:"npm i -g forge-terminal"})}function he(e,t=process.platform){return t==="win32"?new o({code:"update-denied",title:"Forge is in use",detail:`npm could not replace Forge's files to update it to ${e}. Windows keeps them locked while Forge runs: close every Forge window, then run the command below. If Node is installed for every user, run it in a terminal opened as administrator.`,short:"Windows locks Forge while it runs: close it, then run this",hint:`npm i -g forge-terminal@${e}`}):new o({code:"update-denied",title:"npm needs permission",detail:`npm needs permission to update Forge to ${e}.`,short:"npm needs permission to update Forge",hint:`sudo npm i -g forge-terminal@${e}`})}function fe(e,t){return new o({code:"update-failed",title:"Update failed",detail:`npm could not install Forge ${e}: ${t}`,short:"npm could not install the update",hint:`npm i -g forge-terminal@${e}`})}function me(){return new o({code:"update-unreachable",title:"Could not check for updates",detail:"The npm registry could not be reached.",short:"could not reach npm",hint:"Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge update",shellHint:"Check your connection, then try again."})}function we(e,t){return new o({code:"extension-download-failed",title:"Download failed",detail:`${e}: ${t}`,hint:`Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge extensions add ${e}`,shellHint:"Check your connection, then try again from /extensions."})}function be(e,t){return new o({code:"extension-download-failed",title:"Not enough disk space",detail:`${e}: ${t}`,hint:`Free some disk space, then run: forge extensions add ${e}`,shellHint:"Free some disk space, then try again from /extensions."})}function $e(e,t,n){let i=t?t.what?`${t.what} (forge, pid ${t.pid})`:`another forge (pid ${t.pid}) is using it`:"another forge is using it";return new o({code:"extension-in-use",title:"Extension in use",detail:`${e} is in use: ${i}.`,hint:n==="remove"?`Wait for that job to finish, then run: forge extensions remove ${e}`:"Wait for that job to finish, then try again.",shellHint:n==="remove"?"It can be removed when that job finishes.":"Try again when that job finishes."})}function xe(e){return new o({code:"no-subject",title:"No subject found",detail:`${r(e)} has no clear subject to cut out.`,hint:"Try a photo where the subject stands apart from the background."})}function ye(e,t,n){return n===1?new o({code:"boost-too-large",title:"Too large to sharpen",detail:`${r(e)} is too large to sharpen.`,hint:"Sharpen works on images up to 16,384 px a side and 100 megapixels."}):new o({code:"boost-too-large",title:"Too large to boost",detail:t>=2?`${r(e)} is too large to boost that far; ${t}x is the most it can take.`:`${r(e)} is already too large to boost.`,hint:t>=2?`Try --boost ${t}.`:"Boost works on images up to 100 megapixels.",shellHint:t>=2?`Choose ${t}x instead.`:void 0})}function Fe(e,t){return new o({code:"resize-too-large",title:"Too large to resize to",detail:`${r(e)} would be ${t.width} \xD7 ${t.height}.`,hint:"Resize works up to 16,384 px a side and 100 megapixels."})}function Ee(e){return new o({code:"no-clipboard-image",title:"No image",detail:e==="text"?"The clipboard holds text, not a picture.":"The clipboard is empty.",hint:"Copy a picture, or take a screenshot with \u2303\u21E7\u23184, then run forge clip again."})}function ve(){return new o({code:"clipboard-unavailable",title:"No clipboard",detail:"Forge reads the clipboard on a Mac, and not over SSH."})}function ke(){return new o({code:"nothing-to-undo",title:"Nothing to undo",detail:"No copied image has been changed yet."})}function Ce(e,t,n,i=!1){let l=r(e);if(i)return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} is no smaller even at the lowest quality, so nothing was written.`,short:"nothing written"});let h=n>t?`would grow from ${s(t)} to ${s(n)}`:`would stay at ${s(t)}`;return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} ${h}, so nothing was written.`,short:"nothing written",hint:"Try a lower --quality.",shellHint:"Try a lower quality."})}function Te(e,t,n){return new o({code:"cannot-compress-more",title:"Already small enough",detail:`${r(e)} is ${s(t)}, already under ${s(n)}, so nothing was written.`,short:"already under that size"})}function Se(e){return new o({code:"nothing-to-trim",title:"Nothing to trim",detail:`${r(e)} has no empty edges.`,short:"no empty edges"})}function He(e){return new o({code:"animated-trim",title:"Can't trim an animation",detail:`${r(e)} is animated; trimming works on still images.`})}function Pe(e,t){return new o({code:"nothing-to-crop",title:"Nothing to crop",detail:`${r(e)} is already ${t}.`,short:`already ${t}`})}function Ie(e){return new o({code:"animated-crop",title:"Can't crop an animation",detail:`${r(e)} is animated; cropping works on still images.`})}function Ne(e,t=process.platform,n=!1){let i=t==="win32"?"winget install ffmpeg":"brew install ffmpeg",l=n?`forge extensions add video (or ${i})`:i;return new o({code:"ffmpeg-missing",title:"Video and audio need ffmpeg",detail:`${r(e)} is a video or audio file, and ffmpeg is not on this computer.`,short:"ffmpeg is not on this computer",hint:`Install it with ${l}, then run Forge again.`})}function Ue(e,t){return new o({code:"conversion-failed",title:"Conversion failed",detail:`${r(e)} could not be converted.`,hint:"Run again with --debug for the underlying error.",shellHint:"Run the same conversion with forge --debug from the command line to see why.",cause:t})}function De(e){return new o({code:"no-sound",title:"Nothing to transcribe",detail:`${r(e)} has no sound.`})}function Oe(e){return new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e)} cannot be read by Apple's speech recogniser.`,hint:"MP4, MOV, M4A, MP3, WAV and AIFF files can be transcribed."})}function ze(e){return new o({code:"language-unsupported",title:"Language not supported",detail:`Apple's speech recogniser does not support ${e}.`,hint:"Pass another with --language, for example --language en-US."})}function Ae(e,t,n={}){return new o({code:"link-unavailable",title:"Cannot transcribe this link",detail:e,...n,...t===void 0?{}:{cause:t}})}function je(e){return new o({code:"transcribe-unavailable",title:"Transcribe is not available",detail:e})}function Me(e){return new o({code:"unexpected",title:"Something went wrong",detail:e instanceof Error?e.message:String(e),hint:"This was not expected. Try again \u2014 if it keeps happening, it may be worth reporting.",cause:e})}function Je(e,t={}){let n=[`\u2715 ${e.title}`,"",` ${e.detail}`];return e.hint&&n.push("",` ${e.hint}`),t.debug&&e.cause instanceof Error&&n.push("",` ${e.cause.stack??e.cause.message}`),n}export{d as a,C as b,r as c,$ as d,N as e,U as f,D as g,O as h,z as i,A as j,j as k,M as l,J as m,R as n,W as o,q as p,L as q,V as r,_ as s,B as t,X as u,Y as v,G as w,K as x,Q as y,Z as z,ee as A,x as B,te as C,oe as D,ne as E,re as F,ie as G,se as H,ae as I,le as J,de as K,ue as L,ce as M,pe as N,ge as O,he as P,fe as Q,me as R,we as S,be as T,$e as U,xe as V,ye as W,Fe as X,Ee as Y,ve as Z,ke as _,Ce as $,Te as aa,Se as ba,He as ca,Pe as da,Ie as ea,Ne as fa,Ue as ga,De as ha,Oe as ia,ze as ja,Ae as ka,je as la,Me as ma,Je as na};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ var s="https://github.com/AtharvaN16/forge-terminal/releases/download",r=[{id:"boost",title:"Boost resolution",summary:"Sharpen, or boost resolution 2x or 4x, with a local AI model",minMacos:14,assets:{"darwin-arm64":{version:"1.0.0",url:`${s}/ext-boost-v1.0.0/forge-ext-boost-1.0.0-arm64.tar.gz`,bytes:14866325,sha256:"7af24c92f95b1cd34618adde4a90926c91a8db4347d640be4921f1dc706a9a2e"},"win32-x64":{version:"1.1.0",url:`${s}/ext-boost-v1.1.0/forge-ext-boost-1.1.0-win32-x64.tar.gz`,bytes:22993151,sha256:"abac81a9efe616f33b3bce98db2c0ff0b5597b43a7e3d5ea98968761a2b7a0ce"},"win32-arm64":{version:"1.1.0",url:`${s}/ext-boost-v1.1.0/forge-ext-boost-1.1.0-win32-arm64.tar.gz`,bytes:22936985,sha256:"7d39d93cae52f298423db0b185b0ae3a3bac65464abeb23561d9bcb2ebb3f026"}},licence:"Real-ESRGAN general-x4v3 (BSD-3-Clause), ONNX Runtime (MIT)"},{id:"remove-background",title:"Remove background",summary:"Cut the subject out of a photo, on this Mac",minMacos:14,assets:{"darwin-universal":{version:"1.0.0",url:`${s}/ext-remove-background-v1.0.0/forge-ext-remove-background-1.0.0-universal.tar.gz`,bytes:32489,sha256:"9f6e055c0ce25f7504e10c7871e506a813bc75d6536396a675a8c075c4eb4686"}},licence:"Uses Apple Vision on-device; helper is MIT"},{id:"heic",title:"HEIC photos",summary:"Open iPhone photos (HEIC) on Windows",assets:{"win32-universal":{version:"1.0.0",url:`${s}/ext-heic-v1.0.0/forge-ext-heic-1.0.0-win32-universal.tar.gz`,bytes:532364,sha256:"6c5f86c1a896d84264fb19371117e6ca6ec9b8726afec03f8c30aa5125a3ad97"}},licence:"libheif and libde265 (LGPL-3.0), via libheif-js"},{id:"video",title:"Video and audio",summary:"Convert, compress and trim video and audio (ffmpeg)",minMacos:13,assets:{},licence:"FFmpeg (GPL-2.0-or-later) with x264 (GPL-2.0), LAME (LGPL-2.0), Opus and libvpx (BSD), zimg (WTFPL)"},{id:"yt-dlp",title:"YouTube links",summary:"Transcribe YouTube videos: yt-dlp fetches their sound",minMacos:26,assets:{"darwin-universal":{version:"2026.08.19",url:"https://github.com/yt-dlp/yt-dlp/releases/download/2026.08.19/yt-dlp_macos",bytes:37146048,sha256:"0f192b7ec147ab6288885d6351d9ab67367640029b4377576ef46dd79cf7b202",binary:"yt-dlp"}},licence:"yt-dlp (Unlicense); its bundled Python and libraries under their own licences"}];function n(t){return r.find(e=>e.id===t)}function d(t,e=process.platform,a=process.arch){let o=t.assets;return o[`${e}-${a}`]??o[`${e}-universal`]}function i(t,e=process.platform){return Object.keys(t.assets).some(a=>a.startsWith(`${e}-`))}function c(t,e=process.platform){let a=n(t);return a!==void 0&&i(a,e)}export{r as a,n as b,d as c,i as d,c as e};
@@ -0,0 +1,6 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{c as I}from"./chunk-EX7KZBI6.js";import{b as A}from"./chunk-HZDYZ5RD.js";import{J as T,ga as v,ha as N,ia as P,ja as $,ka as w,la as x}from"./chunk-3UEQ2OX6.js";var W=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com"]),B=/^[A-Za-z0-9_-]{11}$/,S=e=>e&&B.test(e)?{kind:"video",id:e,url:`https://www.youtube.com/watch?v=${e}`}:void 0;function de(e){let t=e.trim();if(t==="")return;let n;try{n=new URL(/^[a-z]+:\/\//i.test(t)?t:`https://${t}`)}catch{return}let r=n.hostname.toLowerCase();if(r==="youtu.be")return S(n.pathname.slice(1).split("/")[0]);if(!W.has(r))return;let[o,i]=n.pathname.split("/").filter(Boolean);if(o==="watch")return S(n.searchParams.get("v"));if(o==="shorts"||o==="live")return S(i);if(o==="playlist"&&n.searchParams.get("list"))return{kind:"playlist"}}import{spawn as O}from"node:child_process";import{mkdtemp as C,rm as G}from"node:fs/promises";import{tmpdir as K}from"node:os";import{join as R}from"node:path";import{createInterface as Y}from"node:readline";var H=[[/private video/i,"This video is private."],[/confirm your age/i,"This video is age-restricted."],[/members-only|join this channel/i,"This video is for channel members only."],[/live event will begin|premieres in/i,"This video has not started yet."],[/unavailable|has been removed|does not exist/i,"This video is unavailable."]],h=class extends Error{};async function he(e,t={}){let n=await I("yt-dlp");if(n===void 0)throw T("yt-dlp");let r=await C(R(K(),"forge-yt-"));t.onDir?.(r);let o=()=>G(r,{recursive:!0,force:!0});try{let i;try{i=await _(n.entry,e,r,t)}catch(u){if(!(u instanceof h))throw u;await z(n.entry,t.signal);try{i=await _(n.entry,e,r,t)}catch(a){throw a instanceof h?w(`yt-dlp could not fetch this video: ${a.message}`,a):a}}return{...i,dispose:o}}catch(i){throw await o(),i}}function _(e,t,n,r){let{signal:o}=r;if(o?.aborted)return Promise.reject(o.reason??new Error("aborted"));let i=["--js-runtimes",`node:${process.execPath}`,"--no-playlist","--no-warnings","--newline","--progress","-f","bestaudio[ext=m4a]/bestaudio","--print","before_dl:forge-facts %(.{title,uploader,duration,is_live})j","--progress-template","download:forge-bytes %(progress.downloaded_bytes)s %(progress.total_bytes,progress.total_bytes_estimate)s","--print","after_move:forge-file %(filepath)s","--no-simulate","-o",R(n,"sound.%(ext)s"),t];return new Promise((u,a)=>{let s=O(e,i,{stdio:["ignore","pipe","pipe"]}),d,l,g="",f=!1,p=c=>{f||(f=!0,o?.removeEventListener("abort",k),c())},k=()=>{s.kill("SIGKILL"),p(()=>a(o?.reason??new Error("aborted")))};o?.addEventListener("abort",k,{once:!0}),Y({input:s.stdout}).on("line",c=>{if(c.startsWith("forge-facts ")){let m=JSON.parse(c.slice(12));if(m.is_live===!0){s.kill("SIGKILL"),p(()=>a(w("Live streams cannot be transcribed.")));return}d={title:String(m.title??""),uploader:String(m.uploader??""),seconds:Number(m.duration??0)},r.onEvent?.({kind:"facts",facts:d})}else if(c.startsWith("forge-bytes ")){let[m,b]=c.slice(12).split(" ").map(Number);Number.isFinite(m)&&Number.isFinite(b)&&(b??0)>0&&r.onEvent?.({kind:"bytes",done:m,total:b})}else c.startsWith("forge-file ")&&(l=c.slice(11))}),s.stderr.on("data",c=>{g+=c.toString()}),s.on("error",c=>p(()=>a(new h(c.message)))),s.on("close",c=>p(()=>{if(c===0&&d!==void 0&&l!==void 0)return u({path:l,facts:d});let m=g.match(/ERROR: (?:\[[^\]]*\] )?(?:[\w-]+: )?(.*)/)?.[1]?.trim()??"",b=H.find(([j])=>j.test(m));a(b?w(b[1]):new h(m||`yt-dlp exited ${c}`))}))})}function z(e,t){return new Promise((n,r)=>{let o=O(e,["--update"],{stdio:"ignore"}),i=()=>o.kill("SIGKILL");t?.addEventListener("abort",i,{once:!0}),o.on("error",()=>n()),o.on("close",()=>{t?.removeEventListener("abort",i),t?.aborted?r(t.reason??new Error("aborted")):n()})})}var J="Summary and notes by Apple Intelligence. They may contain mistakes.";function M(e){let t=Math.floor(e),n=i=>String(i).padStart(2,"0"),r=Math.floor(t/3600),o=Math.floor(t/60)%60;return r>0?`${r}:${n(o)}:${n(t%60)}`:`${o}:${n(t%60)}`}var F=e=>e.split(/\s+/).filter(Boolean).length,X=60,Z=140,q=1,Q=10;function ee(e){let t=[],n;for(let r of e){if(n){let o=r.start-n.end;if(!(o>Q||o>q&&n.words>=X||n.words>=Z)){n.text+=` ${r.text}`,n.end=r.end,n.words+=F(r.text);continue}t.push({start:n.start,text:n.text})}n={start:r.start,end:r.end,text:r.text,words:F(r.text)}}return n&&t.push({start:n.start,text:n.text}),t}var D=e=>ee(e).flatMap(t=>[`**${M(t.start)}** ${t.text}`,""]),te=e=>/^https?:\/\/\S+$/.test(e)?`<${e}>`:e;function we(e,t,{transcript:n=!0}={}){let r=[`# ${t.title}`,"",te(t.from),""],o=e.notes;if(!o)return[...r,...D(e.segments)].join(`
4
+ `);let i=o.parts,u=s=>{let d=i[s];return d?`### ${d.refused?`Part ${s+1}`:d.heading} \xB7 ${M(d.start)}`:""};r.push(o.summary,"","## Notes",""),i.forEach((s,d)=>{r.push(u(d),""),s.points.length>0&&r.push(...s.points.map(l=>`- ${l}`),"")});let a=[`_${J}_`,""];return n?(r.push("## Transcript",""),i.forEach((s,d)=>{let l=i[d+1]?.start??Number.POSITIVE_INFINITY,g=e.segments.filter(f=>f.start>=s.start&&f.start<l);r.push(u(d),"",...D(g))}),[...r,...a].join(`
5
+ `)):[...r,...a].join(`
6
+ `)}function ye(e){let t=[...e].map(n=>(n.codePointAt(0)??0)<32?" ":n).join("").replace(/[/\\:*?"<>|]/g,"-").replace(/\s+/g," ").trim().slice(0,120).replace(/^\.+/,"");return t===""?"transcript":t}import{spawn as ne}from"node:child_process";import{existsSync as U}from"node:fs";import{dirname as re,join as E}from"node:path";import{createInterface as oe}from"node:readline";import{fileURLToPath as ie}from"node:url";var y="forge-transcribe";function V(){let e=process.env.FORGE_TRANSCRIBE_HELPER;if(e!==void 0)return U(e)?e:void 0;if(process.platform!=="darwin")return;let t=re(ie(import.meta.url));return[E(t,"helpers",y),E(t,"..","helpers",y),E(t,"..","..","dist","helpers",y)].find(n=>U(n))}function L(e,t,n={}){let r=V();if(r===void 0)return Promise.reject(x("Transcribe needs macOS 26 or later on Apple silicon."));let{signal:o}=n;return o?.aborted?Promise.reject(o.reason??new Error("aborted")):new Promise((i,u)=>{let a=ne(r,e,{stdio:["ignore","pipe","ignore"]}),s,d=!1,l=f=>{d||(d=!0,o?.removeEventListener("abort",g),f())},g=()=>{a.kill("SIGKILL"),l(()=>u(o?.reason??new Error("aborted")))};o?.addEventListener("abort",g,{once:!0}),oe({input:a.stdout}).on("line",f=>{let p;try{p=JSON.parse(f)}catch{return}"ok"in p?s=p:n.onLine?.(p)}),a.on("error",f=>l(()=>u(v(t,f)))),a.on("close",()=>l(()=>{if(s===void 0)return u(v(t,new Error(`${y} gave no result`)));if(s.ok===!0)return i(s);u(se(String(s.code??""),String(s.message??""),t,e))}))})}function se(e,t,n,r){if(e==="no-sound")return N(n);if(e==="unreadable")return P(n);if(e==="locale"){let o=r.indexOf("--locale");return $(o>=0?r[o+1]??"this language":"this Mac's language")}return e==="unsupported"?x(t):v(n,new Error(`${e}: ${t}`))}async function $e(e={}){if(V()===void 0)return;let t=["status",...e.locale?["--locale",e.locale]:[]],n=await L(t,"");return{speech:n.speech===!0,locale:typeof n.locale=="string"?n.locale:null,notes:n.notes==="available"||n.notes==="off"?n.notes:"unsupported"}}async function Ie(e){let t=await L(["probe",e],e);return{seconds:Number(t.seconds)}}async function Ae(e,t){let n=["run",e,...t.locale?["--locale",t.locale]:[],...t.notes?["--notes"]:[],...t.notes&&t.detail&&t.detail!==A?["--detail",t.detail]:[]],r=await L(n,e,{signal:t.signal,onLine:o=>{let i=ae(o);i&&t.onEvent?.(i)}});return{locale:String(r.locale),seconds:Number(r.seconds),segments:r.segments,...r.notes?{notes:r.notes}:{}}}function ae(e){if(e.event==="model")return{kind:"model",fraction:Number(e.fraction)};if(e.event==="heard")return{kind:"heard",seconds:Number(e.seconds),of:Number(e.of)};if(e.event==="notes")return{kind:"notes",part:Number(e.part),of:Number(e.of)}}export{de as a,he as b,M as c,we as d,ye as e,$e as f,Ie as g,Ae as h};
@@ -0,0 +1,78 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{execFile as de}from"node:child_process";import{chmodSync as ye,mkdirSync as Y,readFileSync as he,rmSync as w,writeFileSync as we}from"node:fs";import{dirname as Se,join as u}from"node:path";var ne={convert:"#55c7d9",compress:"#79c98b",edit:"#b39ae8",pdf:"#ff6b4a"},re="#55c7d9",oe="#a68ce0",ie=4/5,se=(e,t,n,o)=>`<path fill="${o}" d="M${e} ${t}h${4*n}v${n}h${-3*n}v${n}h${2*n}v${n}h${-2*n}v${2*n}h${-n}z"/>`;function ae(e,t){let n=t<=20,o=n?3:4,r=n?6:4.6,i=n?51:51.5,a=Array.from({length:o},(p,m)=>i-(o-1-m)*r).map(p=>`<line x1="${p}" y1="66" x2="${p+66*ie}" y2="0"/>`).join(""),c=e==="forge"?"url(#w)":ne[e];return`<svg width="${t}" height="${t}" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="w" gradientUnits="userSpaceOnUse" x1="34" y1="0" x2="62" y2="0"><stop offset="0" stop-color="${re}"/><stop offset="1" stop-color="${oe}"/></linearGradient><clipPath id="c"><rect width="64" height="64" rx="14"/></clipPath><clipPath id="i"><rect x="1.5" y="1.5" width="61" height="61" rx="12.5"/></clipPath></defs><g clip-path="url(#c)"><rect width="64" height="64" fill="#1e1e1e"/><g clip-path="url(#i)" stroke="${c}" stroke-width="${n?3.6:2.4}">${a}</g>${se(16,12,8,"#e7e7e7")}</g><rect x=".75" y=".75" width="62.5" height="62.5" rx="13.5" fill="none" stroke="#3a3a3a" stroke-width="1.5"/></svg>`}async function d(e,t){let{default:n}=await import("sharp");return n(Buffer.from(ae(e,t))).png().toBuffer()}function O(e){let t=Buffer.alloc(6);t.writeUInt16LE(0,0),t.writeUInt16LE(1,2),t.writeUInt16LE(e.length,4);let n=6+16*e.length,o=e.map(({size:r,png:i})=>{let s=Buffer.alloc(16);return s[0]=r>=256?0:r,s[1]=r>=256?0:r,s.writeUInt16LE(1,4),s.writeUInt16LE(32,6),s.writeUInt32LE(i.length,8),s.writeUInt32LE(n,12),n+=i.length,s});return Buffer.concat([t,...o,...e.map(r=>r.png)])}function y(e){let t=[{action:"open",label:"Open Forge",kinds:["image","folder"],window:!0,paint:"forge"},{action:"convert",label:"Convert in Forge",kinds:["image","folder"],window:!0,paint:"convert"},{action:"compress",label:"Compress in Forge",kinds:["image","folder"],window:!0,paint:"compress"},{action:"sharpen",label:"Sharpen in Forge",kinds:["image"],window:!1,paint:"edit"},{action:"open-pdf",label:"Open in Forge",kinds:["pdf"],window:!0,paint:"pdf"}];return e.sharpen?t:t.filter(n=>n.action!=="sharpen")}var k=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");function S(e,t){if(typeof e=="string")return`${t}<string>${k(e)}</string>`;if(typeof e=="number")return`${t}<integer>${e}</integer>`;if(typeof e=="boolean")return`${t}<${e}/>`;if(Array.isArray(e))return`${t}<array>
4
+ ${e.map(o=>S(o,`${t} `)).join(`
5
+ `)}
6
+ ${t}</array>`;let n=Object.entries(e).map(([o,r])=>`${t} <key>${k(o)}</key>
7
+ ${S(r,`${t} `)}`);return n.length===0?`${t}<dict/>`:`${t}<dict>
8
+ ${n.join(`
9
+ `)}
10
+ ${t}</dict>`}var B=e=>`<?xml version="1.0" encoding="UTF-8"?>
11
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
12
+ <plist version="1.0">
13
+ ${S(e,"")}
14
+ </plist>
15
+ `,ce={image:"public.image",folder:"public.folder",pdf:"com.adobe.pdf"};function le(e){return e.length===1&&e[0]==="image"?"com.apple.Automator.fileSystemObject.image":e.length===1&&e[0]==="pdf"?"com.apple.Automator.fileSystemObject.PDF":e.length===1&&e[0]==="folder"?"com.apple.Automator.fileSystemObject.folder":"com.apple.Automator.fileSystemObject"}var l=e=>`'${e.replace(/'/g,"'\\''")}'`,$="forge",R=e=>`com.forge-terminal.menu.${e.action}`,U="runWorkflowAsService",v=e=>`${R(e)} - ${e.label} - ${U}`,ue=`ObjC.import('Foundation')
16
+ function run(argv) {
17
+ const domain = argv[0]
18
+ const defaults = $.NSUserDefaults.standardUserDefaults
19
+ const or = (v) => (v.isNil() ? $.NSDictionary.dictionary : v)
20
+ const all = $.NSMutableDictionary.dictionaryWithDictionary(or(defaults.persistentDomainForName(domain)))
21
+ const status = $.NSMutableDictionary.dictionaryWithDictionary(or(all.objectForKey('NSServicesStatus')))
22
+ const on = { presentation_modes: { ContextMenu: true, FinderPreview: true, ServicesMenu: true, TouchBar: true } }
23
+ for (const arg of argv.slice(1)) {
24
+ const key = arg.slice(1)
25
+ if (arg[0] === '+') status.setObjectForKey($(on), key)
26
+ else status.removeObjectForKey(key)
27
+ }
28
+ all.setObjectForKey(status, 'NSServicesStatus')
29
+ defaults.setPersistentDomainForName(all, domain)
30
+ }`;function g(e){return[e.osascript??"/usr/bin/osascript",["-l","JavaScript","-e",ue,e.domain??"pbs",...e.on.map(t=>`+${t}`),...e.off.map(t=>`-${t}`)]]}function T(e,t){let n=B({CFBundleDevelopmentRegion:"English",CFBundleIdentifier:R(e),CFBundleInfoDictionaryVersion:"6.0",CFBundleName:e.label,CFBundlePackageType:"BNDL",CFBundleShortVersionString:"1.0",CFBundleVersion:"1",NSServices:[{NSIconName:$,NSMenuItem:{default:e.label},NSMessage:U,NSRequiredContext:{NSApplicationIdentifier:"com.apple.finder"},NSSendFileTypes:e.kinds.map(i=>ce[i])}]}),o=`${l(t)} ${e.action} "$@"`,r=B({AMApplicationBuild:"521",AMApplicationVersion:"2.10",AMDocumentVersion:"2",actions:[{action:{AMAccepts:{Container:"List",Optional:!0,Types:["com.apple.cocoa.path"]},AMActionVersion:"2.0.3",AMApplication:["Automator"],AMParameterProperties:{COMMAND_STRING:{},CheckedForUserDefaultShell:{},inputMethod:{},shell:{},source:{}},AMProvides:{Container:"List",Types:["com.apple.cocoa.string"]},ActionBundlePath:"/System/Library/Automator/Run Shell Script.action",ActionName:"Run Shell Script",ActionParameters:{COMMAND_STRING:o,CheckedForUserDefaultShell:!0,inputMethod:1,shell:"/bin/zsh",source:""},BundleIdentifier:"com.apple.RunShellScript",CFBundleVersion:"2.0.3",CanShowSelectedItemsWhenRun:!1,CanShowWhenRun:!0,Category:["AMCategoryUtilities"],"Class Name":"RunShellScriptAction",InputUUID:"7A1F3C2E-0F4B-4E8A-9C61-5B2D8E4F1A01",OutputUUID:"7A1F3C2E-0F4B-4E8A-9C61-5B2D8E4F1A02",UUID:"7A1F3C2E-0F4B-4E8A-9C61-5B2D8E4F1A03",UnlocalizedApplications:["Automator"]},isViewVisible:!0}],connectors:{},workflowMetaData:{serviceApplicationBundleID:"com.apple.finder",serviceApplicationPath:"/System/Library/CoreServices/Finder.app",serviceInputTypeIdentifier:le(e.kinds),serviceOutputTypeIdentifier:"com.apple.Automator.nothing",serviceProcessesInput:!1,workflowTypeIdentifier:"com.apple.Automator.servicesMenu"}});return{name:`${e.label}.workflow`,files:{"Contents/Info.plist":n,"Contents/document.wflow":r,"Contents/Resources/document.wflow":r}}}import{execFile as pe}from"node:child_process";var x="ForgeTerminal.Forge",L=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),M=e=>e.replace(/['‘’‚‛]/g,"$&$&"),j=M;function I(e,t){return["[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null","[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] > $null","$x = New-Object Windows.Data.Xml.Dom.XmlDocument",`$x.LoadXml('<toast><visual><binding template="ToastText02"><text id="1">${j(L(e))}</text><text id="2">${j(L(t))}</text></binding></visual></toast>')`,`[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier('${x}').Show([Windows.UI.Notifications.ToastNotification]::new($x))`].join("; ")}function me(e,t,n=process.platform){return n==="win32"?["powershell.exe",["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",I(e,t)]]:["/usr/bin/osascript",["-e","on run argv","-e","display notification (item 2 of argv) with title (item 1 of argv)","-e","end run",e,t]]}function Ae(e,t,n=process.platform){let[o,r]=me(e,t,n);return new Promise(i=>{pe(o,r,{timeout:1e4,windowsHide:!0},()=>i())})}var _="Forge was uninstalled",H="Its menu items are removed.",fe="Forge could not start",ge="Run forge in a terminal once to set its menu up again.";function K(e){let{osascript:t,pbs:n}=e.tools??{osascript:"/usr/bin/osascript",pbs:"/System/Library/CoreServices/pbs"},o=[e.node,...e.execArgv,e.forge].map(l).join(" "),[r,i]=g({on:[],off:e.services,osascript:t}),s=[r,...i].map(l).join(" "),a=(c,p)=>`${l(t)} -e 'display notification "${p}" with title "${c}"'`;return`#!/bin/sh
31
+ # Forge's right-click menu. Rewritten by Forge whenever it sets the menu up.
32
+ if [ ! -f ${l(e.forge)} ]; then
33
+ # Forge is gone: take its menu with it, and say so once.
34
+ ${e.bundles.map(c=>` rm -rf ${l(c)}`).join(`
35
+ `)}
36
+ rm -rf ${l(e.menuDir)}
37
+ ${s}
38
+ ${l(n)} -update
39
+ ${a(_,H)}
40
+ exit 0
41
+ fi
42
+ if [ ! -x ${l(e.node)} ]; then
43
+ ${a(fe,ge)}
44
+ exit 1
45
+ fi
46
+ ${e.xdgConfigHome===void 0?"":`export XDG_CONFIG_HOME=${l(e.xdgConfigHome)}
47
+ `}exec ${o} menu run "$@"
48
+ `}function V(e){let t=e.xdgConfigHome===void 0?{}:{XDG_CONFIG_HOME:e.xdgConfigHome};return`// Forge's right-click menu. Rewritten by Forge whenever it sets the menu up.
49
+ import { execFileSync, spawn } from 'node:child_process'
50
+ import { existsSync, rmSync } from 'node:fs'
51
+
52
+ const FORGE = ${JSON.stringify(e.forge)}
53
+ const ARGS = ${JSON.stringify(e.execArgv)}
54
+ const MENU = ${JSON.stringify(e.menuDir)}
55
+ const KEYS = ${JSON.stringify(e.keys)}
56
+ const ENV = ${JSON.stringify(t)}
57
+
58
+ if (existsSync(FORGE)) {
59
+ const child = spawn(process.execPath, [...ARGS, FORGE, 'menu', 'run', ...process.argv.slice(2)], {
60
+ stdio: 'inherit',
61
+ windowsHide: true,
62
+ env: { ...process.env, ...ENV },
63
+ })
64
+ child.on('exit', (code) => process.exit(code ?? 0))
65
+ } else {
66
+ // Forge is gone: say so while its app ID still exists, then take the menu with it.
67
+ try {
68
+ execFileSync('powershell.exe', ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', ${JSON.stringify(I(_,H))}], { windowsHide: true })
69
+ } catch {}
70
+ for (const key of KEYS) {
71
+ try {
72
+ execFileSync('reg.exe', ['delete', key, '/f'], { windowsHide: true, stdio: 'ignore' })
73
+ } catch {}
74
+ }
75
+ rmSync(MENU, { recursive: true, force: true })
76
+ }
77
+ `}var h="HKCU\\Software\\Classes",G=`${h}\\SystemFileAssociations\\image\\shell\\Forge`,W=`${h}\\Directory\\shell\\Forge`,N=`${h}\\SystemFileAssociations\\.pdf\\shell\\ForgeOpen`,J=`${h}\\AppUserModelId\\${x}`,D=()=>[G,W,N,J],F=e=>`${e.paint}.ico`;function X(e){let t=i=>`conhost.exe --headless "${e.node}" "${e.menuDir}\\run.mjs" ${i} "%1"`,n=i=>`${e.menuDir}\\${F(i)}`,o=(i,s)=>{let a=e.items.filter(c=>c.kinds.includes(s));return a.length===0?[]:[{key:i,values:{MUIVerb:"Forge",Icon:n({paint:"forge"}),SubCommands:""}},...a.flatMap((c,p)=>{let m=`${i}\\shell\\${p+1}${c.action}`;return[{key:m,values:{MUIVerb:c.label,Icon:n(c)}},{key:`${m}\\command`,values:{"":t(c.action)}}]})]},r=e.items.find(i=>i.kinds.includes("pdf"));return[...o(G,"image"),...o(W,"folder"),...r?[{key:N,values:{MUIVerb:r.label,Icon:n(r)}},{key:`${N}\\command`,values:{"":t(r.action)}}]:[],{key:J,values:{DisplayName:"Forge",IconUri:`${e.menuDir}\\forge.png`}}]}var b=e=>`'${M(e)}'`,A=e=>b(`Registry::${e.replace(/^HKCU\\/,"HKEY_CURRENT_USER\\")}`);function C(e){return["$ErrorActionPreference = 'Stop'",...D().map(n=>`Remove-Item -Path ${A(n)} -Recurse -Force -ErrorAction SilentlyContinue`),...e.flatMap(({key:n,values:o})=>[`New-Item -Path ${A(n)} -Force | Out-Null`,...Object.entries(o).map(([r,i])=>`Set-ItemProperty -LiteralPath ${A(n)} -Name ${b(r===""?"(default)":r)} -Value ${b(i)}`)])].join(`
78
+ `)}var je=(e,t)=>e.version===t.version&&e.forge===t.forge&&e.node===t.node&&e.execArgv.join("\0")===t.execArgv.join("\0")&&e.xdgConfigHome===t.xdgConfigHome,Q="/System/Library/CoreServices/pbs",q=e=>u(e.menuDir,"state.json"),Z=e=>u(e.home,"Library","Services"),E=e=>y({sharpen:!0}).map(t=>u(Z(e),`${t.label}.workflow`)),P=()=>y({sharpen:!0}).map(v);function $e(e){try{return JSON.parse(he(q(e),"utf8"))}catch{return}}var _e=e=>$e(e)!==void 0,f=(e,t)=>{Y(Se(e),{recursive:!0}),we(e,t)};async function He(e){if(e.platform!=="darwin"&&e.platform!=="win32")return;let t=y({sharpen:e.sharpen});if(Y(e.menuDir,{recursive:!0}),e.platform==="darwin"){let o=u(e.menuDir,"run");f(o,K({...e,bundles:E(e),services:P()})),ye(o,493);for(let a of E(e))w(a,{recursive:!0,force:!0});let r=new Map,{default:i}=await import("sharp");for(let a of t){r.has(a.paint)||r.set(a.paint,await i(await d(a.paint,64)).tiff().toBuffer());let{name:c,files:p}=T(a,o),m=u(Z(e),c);for(let[ee,te]of Object.entries(p))f(u(m,ee),te);f(u(m,"Contents","Resources",`${$}.tiff`),r.get(a.paint))}let s=t.map(v);await e.run(...g({on:s,off:P().filter(a=>!s.includes(a))})),await e.run(Q,["-update"])}else{f(u(e.menuDir,"run.mjs"),V({...e,keys:D()}));let o=["forge","convert","compress","edit","pdf"];for(let r of o){let i=await Promise.all([16,24,32,48,256].map(async s=>({size:s,png:await d(r,s)})));f(u(e.menuDir,F({paint:r})),O(i))}f(u(e.menuDir,"forge.png"),await d("forge",256)),await e.run("powershell.exe",z(C(X({...e,items:t}))))}let n={version:e.version,forge:e.forge,node:e.node,execArgv:e.execArgv,...e.xdgConfigHome===void 0?{}:{xdgConfigHome:e.xdgConfigHome}};f(q(e),JSON.stringify(n))}async function Ke(e){if(e.platform==="darwin"){for(let t of E(e))w(t,{recursive:!0,force:!0});w(e.menuDir,{recursive:!0,force:!0}),await e.run(...g({on:[],off:P()})),await e.run(Q,["-update"])}else e.platform==="win32"&&(w(e.menuDir,{recursive:!0,force:!0}),await e.run("powershell.exe",z(C([]))))}var z=e=>["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-Command",e],Ve=(e,t)=>new Promise((n,o)=>{de(e,t,{timeout:6e4,windowsHide:!0},r=>r?o(r):n())});export{l as a,Ae as b,je as c,$e as d,_e as e,He as f,Ke as g,Ve as h};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{c as Q,g as je,h as et}from"./chunk-EEQSUBBL.js";import{A as Ge,B as Ve,C as He,G as X,H as Ke,I as Ye,N as Ze,o as Te,p as Be,r as Le,u as ze,v as N,w as D,x as Ue,y as Ce,z as qe}from"./chunk-KAHWYWNT.js";import{a as Ne,b as Je,d as We,e as E}from"./chunk-SMBK6BTC.js";import{$ as Z,F as ke,G as C,H as ae,J as Ae,N as _e,W as Me,c as k,d as T,fa as Oe,ga as L,s as De,u as Y,w as B}from"./chunk-3UEQ2OX6.js";import{a as Re}from"./chunk-J7FLFHQJ.js";import{c as ce,e as pe,f as Xe,j as Qe}from"./chunk-LDKF7KIZ.js";import{a as I}from"./chunk-M66BUNYO.js";import{readFile as Rt,rm as Dt}from"node:fs/promises";var kt=new Set(["pdf"]),At=new Set(["jpeg","png"]),_t=new Set(["convert"]),tt;function Mt(){return tt??=Ue().then(e=>e.PDFiumLibrary.init()),tt}async function ot(e,t){return await(await Mt()).loadDocument(e,t)}async function nt(e){let t=await ot(e);try{let o=[];for(let n=0;n<t.getPageCount();n++)o.push(t.getPage(n).getText());return o}finally{t.destroy()}}var rt={id:"pdfium",reads:kt,writes:At,ops:_t,probe(){throw new Error("pdfium does not probe; engines/pdf.ts classifies PDFs")},async run(e,t){if(e.op!=="convert")throw new Error(`pdfium cannot ${e.op}`);let o=e.sources[0];if(o.kind!=="document")throw new Error("the pdfium engine can only rasterise a document source");if(o.encrypted&&e.options.password===void 0)throw B(o.path);let n=e.options.dpi??150,s=e.options.pages??Array.from({length:o.pages},(a,p)=>p);if(s.length!==e.outputs.length)throw new Error(`pdfium was given ${s.length} pages but ${e.outputs.length} outputs`);for(let a of s)if(a<0||a>=o.pages)throw new Error(`pdfium was asked for page ${a}, but ${o.path} has ${o.pages} pages`);let r=await N(),i=await ot(await Rt(o.path),e.options.password);try{let a=[],p=0;try{for(let[c,d]of s.entries()){let l=await i.getPage(d).render({scale:n/72,render:"bitmap",transparent:!0}),h=r(l.data,{raw:{width:l.width,height:l.height,channels:4}}).flatten({background:e.options.background}),g=await X(h,e.target,e.options.quality).toBuffer(),m=e.outputs[c];p+=await E(m,g),a.push(m),t({phase:"page",done:c+1,total:s.length})}}catch(c){throw await Promise.all(a.map(d=>Dt(d,{force:!0}))),c}return{job:e,outputBytes:p,warnings:[]}}finally{i.destroy()}}};import{mkdtemp as Ot,rm as Tt}from"node:fs/promises";import{tmpdir as Bt}from"node:os";import{join as j}from"node:path";var it=(e,t,o)=>Le(e,t,o)===void 0;function st(e,t,o=Number.POSITIVE_INFINITY,n=[2,4]){return[...n].reverse().find(s=>s<o&&it(e,t,s))??0}async function Lt(e,t,o){if(e.op!=="boost"&&e.op!=="remove-background")throw new Error(`the extension engine cannot ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=e.op,{assetFor:i,catalogEntry:a,offeredHere:p}=await import("./catalog-YSMT3PXT.js");if(!p(r))throw _e(a(r)?.title??r);let{installed:c,extensionsRoot:d}=await import("./paths-5XI5L4KW.js"),l=await c(r);if(!l)throw Ae(r);let h=Te(l.version);if(e.op==="boost"){let w=a(r),P=Be(e.scale,l.version,w&&i(w)?.version);if(P)throw P}if(e.op==="boost"&&!it(n.width,n.height,e.scale))throw Me(n.path,st(n.width,n.height,Number.POSITIVE_INFINITY,h),e.scale);let{runExtension:g}=await import("./run-6BK4REXK.js"),m=[];n.frames>1&&m.push({code:"animation-flattened",message:`${k(n.path)} has ${n.frames} frames. Only the first frame was used.`});let x=await Ot(j(Bt(),"forge-ext-"));try{t({phase:"decoding"});let w=j(x,"in.png"),P=j(x,"out.png");await Ye(n,w);let u=e.op==="boost"?["--in",w,"--out",P,"--scale",String(e.scale),"--cache",j(d(),"boost","cache")]:[w,P];await g(l,u,{subject:n.path,what:`${Nt(e)} is running on ${k(n.path)}`,onWait:()=>t({phase:"waiting"}),onStart:()=>t({phase:"encoding"}),...e.op==="boost"?{maxScale:st(n.width,n.height,e.scale,h)}:{},...o===void 0?{}:{signal:o}});let y=(await N())(P);I[e.target].hasAlpha||(y=y.flatten({background:e.options.background}));let S=await X(y,e.target,e.options.quality).toBuffer();t({phase:"writing"});let F=await Ke(S,s);return{job:e,outputBytes:F,warnings:m}}catch(w){throw T(w)?w:L(n.path,w)}finally{await Tt(x,{recursive:!0,force:!0}).catch(()=>{})}}function Nt(e){return e.op!=="boost"?"Remove background":e.scale===1?"Sharpen":`Boost resolution ${e.scale}\xD7`}var at={id:"extension",reads:new Set,writes:new Set,ops:new Set(["boost","remove-background"]),probe:()=>Promise.reject(new Error("the extension engine reads no files")),run:Lt};import{randomBytes as to}from"node:crypto";import{open as oo,rm as no,stat as ee}from"node:fs/promises";import{dirname as ro,join as so}from"node:path";var fe="%LOUDNORM_MEASURED%",Jt={mp4:"mp4",hevc:"mp4",mov:"mov",webm:"webm",mkv:"matroska",avi:"avi",gif:"gif",mp3:"mp3",m4a:"ipod",opus:"opus",flac:"flac",wav:"wav",aiff:"aiff",ogg:"ogg"},Wt={mp4:["h264","hevc","mpeg4","av1"],mov:["h264","hevc","mpeg4","prores","av1"],mkv:["h264","hevc","mpeg4","vp8","vp9","av1"],hevc:["hevc"],webm:["vp8","vp9","av1"],avi:["mpeg4","h264","mjpeg","msmpeg4v3"]},zt={mp4:["aac","alac","mp3"],hevc:["aac","alac","mp3"],mov:["aac","alac","mp3","pcm_s16le","pcm_s16be","pcm_s24le"],m4a:["aac","alac"],mkv:["aac","mp3","opus","vorbis","flac","ac3","eac3"],webm:["opus","vorbis"],opus:["opus"],mp3:["mp3"],flac:["flac"],wav:["pcm_s16le"],aiff:["pcm_s16be"],ogg:["vorbis","opus","flac"],avi:["mp3","ac3","aac","pcm_s16le"]};function Ut(e,t,o){switch(e){case"webm":case"opus":return{encoder:"libopus",kbps:96};case"mp3":return{encoder:"libmp3lame",kbps:128};case"flac":return{encoder:"flac"};case"wav":return{encoder:"pcm_s16le"};case"aiff":return{encoder:"pcm_s16be"};case"ogg":return{encoder:"libvorbis",kbps:128};default:return{encoder:t==="darwin"&&o("aac_at")?"aac_at":"aac",kbps:128}}}var q=e=>Math.max(2,Math.floor(e/2)*2),Ct=e=>String(Math.round(e*1e3)/1e3),qt=e=>String(Math.ceil(e*1e3)/1e3),Gt=e=>Math.round(38-(e-1)*20/99),Vt=e=>Math.round(50-(e-1)*30/99),Ht=e=>Math.round(40-(e-1)*18/99),Kt="zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p";function ct(e){let t=[],o=e;for(;o>2;)t.push("atempo=2"),o/=2;for(;o<.5;)t.push("atempo=0.5"),o/=.5;return t.push(`atempo=${Math.round(o*1e3)/1e3}`),t}var Yt=800,Zt=15,pt=32;function ft(e){let{facts:t,options:o,target:n,platform:s}=e,r=o.media??{},i=t.video,a=t.audio,p=I[n].media==="sound",c=n==="gif",d=o.compress!==void 0,l=s==="darwin",h=f=>e.has===void 0||e.has.has(f),g=r.cut?.start??0,m=Math.min(r.cut?.end??t.duration,t.duration),x=Math.max(0,m-g),w=r.speed??1,P=x/w,u=i!==void 0&&!p,b=a!==void 0&&!r.mute&&!c,y,S,F,_;if(r.targetBytes!==void 0&&P>0){if(u&&i){let f=je({duration:P,width:i.width,height:i.height,fps:i.fps,hasAudio:b,targetBytes:r.targetBytes});"videoKbps"in f&&(y={width:f.width,height:f.height,fps:f.fps},F=f.videoKbps,S=f.audioKbps)}else if(b){let f=Math.floor(r.targetBytes*8/P/1e3*.98);_=Math.max(pt,Math.min(320,f))}}let $=[];if(u&&i){if(i.hdr&&n!=="hevc"&&h("zscale")&&$.push(Kt),o.crop?.box){let f=o.crop.box;$.push(`crop=${q(f.width)}:${q(f.height)}:${f.left}:${f.top}`)}if(y)$.push(`scale=${y.width}:${y.height}`);else if(o.resize){let f=o.resize;"width"in f?$.push(`scale=trunc(min(${q(f.width)}\\,iw)/2)*2:-2`):"height"in f?$.push(`scale=-2:trunc(min(${q(f.height)}\\,ih)/2)*2`):$.push(`scale=trunc(iw*${f.percent/100}/2)*2:-2`)}if(w!==1&&$.push(`setpts=PTS/${w}`),c){let f=Math.min(Yt,q(i.width));$.push(`fps=${Math.min(Zt,i.fps)},scale=${f}:-2:flags=lanczos,split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer:bayer_scale=4`)}}let re=y?.fps??r.fps,xe=u&&i!==void 0&&$.length===0&&re===void 0&&!d&&r.targetBytes===void 0&&(Wt[n]??[]).includes(i.codec),v=[];if(!u)v.push("-vn");else if(xe)v.push("-c:v","copy");else{if($.length&&v.push("-vf",$.join(",")),c)v.push("-c:v","gif","-loop","0");else if(n==="webm")if(v.push("-c:v","libvpx-vp9","-row-mt","1","-deadline","good","-cpu-used","4"),F!==void 0)v.push("-b:v",`${F}k`);else{let f=d?Vt(o.quality??60):33;v.push("-crf",String(f),"-b:v","0")}else if(n==="hevc"){let f=h("libx265")||!l;if(F!==void 0)f?v.push("-c:v","libx265","-preset","fast","-b:v",`${F}k`):v.push("-c:v","hevc_videotoolbox","-b:v",`${F}k`);else if(l&&(!d||!f)){let O=d?Math.round(20+(o.quality??60)*60/100):60;v.push("-c:v","hevc_videotoolbox","-q:v",String(O))}else{let O=d?Ht(o.quality??60):26;v.push("-c:v","libx265","-crf",String(O),"-preset","fast")}v.push("-tag:v","hvc1","-pix_fmt",i?.hdr?"p010le":"yuv420p")}else F!==void 0?v.push("-c:v","libx264","-preset","medium","-b:v",`${F}k`):d?v.push("-c:v","libx264","-preset","medium","-crf",String(Gt(o.quality??60))):l?v.push("-c:v","h264_videotoolbox","-q:v","65"):v.push("-c:v","libx264","-preset","veryfast","-crf","21"),v.push("-pix_fmt","yuv420p");re!==void 0?v.push("-r",String(re)):c||v.push("-fps_mode","passthrough")}let V=w!==1?ct(w):[],M=r.loudness;M!==void 0&&V.push(`loudnorm=I=${M}:TP=-1.5:LRA=11:${fe}:linear=true`);let Pe=r.bitrate??S??_,Fe=b&&a!==void 0&&V.length===0&&Pe===void 0&&!(d&&p)&&(zt[n]??[]).includes(a.codec),R=[];if(!b)R.push("-an");else if(Fe)R.push("-c:a","copy");else{V.length&&R.push("-af",V.join(","));let f=Ut(n,s,h);R.push("-c:a",f.encoder);let O=Pe??f.kbps;O!==void 0&&f.kbps!==void 0&&R.push("-b:a",`${O}k`),S!==void 0&&S<=pt&&R.push("-ac","1"),M!==void 0&&a&&R.push("-ar",String(a.sampleRate))}let se=[];g>0&&se.push("-ss",qt(g)),r.cut&&se.push("-t",Ct(x));let H=[...se,"-i",e.input],K=[],ie=[...u?["-map","0:v:0"]:[],...b?["-map","0:a:0"]:[]],Ee=o.keepMetadata?[]:["-map_metadata","-1"],$t=Jt[n]??n,Se=["mp4","hevc","mov","m4a"].includes(n)?["-movflags","+faststart"]:[],Ie=["-f",$t,"-y",e.output],$e=s==="win32"?"NUL":"/dev/null",U=[];return M!==void 0&&U.push({args:[...H,...K,"-vn","-af",`${w!==1?`${ct(w).join(",")},`:""}loudnorm=I=${M}:TP=-1.5:LRA=11:print_format=json`,"-f","null",$e],measures:"loudness",pass:{at:1,of:2}}),F!==void 0&&n!=="hevc"&&!c?(U.push({args:[...H,...K,...ie.slice(0,2),...v,"-pass","1","-passlogfile",e.passlog,"-an","-f","null",$e],pass:{at:1,of:2}}),U.push({args:[...H,...K,...ie,...v,"-pass","2","-passlogfile",e.passlog,...R,...Ee,...Se,...Ie],pass:{at:2,of:2}})):U.push({args:[...H,...K,...ie,...v,...R,...Ee,...Se,...Ie],...M!==void 0?{pass:{at:2,of:2}}:{}}),{steps:U,duration:P,copies:{video:xe,audio:Fe},...y?{fitted:y}:{}}}var J=(e,t,o)=>e.subarray(t,t+o).toString("latin1"),Xt=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1","avif","avis","crx "]),Qt=new Set(["M4A ","M4B ","M4P ","F4A ","F4B "]);function jt(e){let t=J(e,8,4);if(!Xt.has(t))return t==="qt "?"mov":Qt.has(t)?"m4a":"mp4"}function dt(e){if(e.length<4)return;if(J(e,4,4)==="ftyp")return jt(e);if(e[0]===26&&e[1]===69&&e[2]===223&&e[3]===163)return e.includes("webm",0,"latin1")?"webm":"mkv";let t=J(e,0,4);if(t==="RIFF"){let o=J(e,8,4);return o==="WAVE"?"wav":o==="AVI "?"avi":void 0}if(t==="FORM"){let o=J(e,8,4);return o==="AIFF"||o==="AIFC"?"aiff":void 0}if(t==="fLaC")return"flac";if(t==="OggS")return e.includes("OpusHead",0,"latin1")?"opus":"ogg";if(J(e,0,3)==="ID3"||e[0]===255&&((e[1]??0)&224)===224&&((e[1]??0)&6)===2)return"mp3"}var io=["mp4","mov","webm","mkv","avi","gif"],mt=["mp4","mov","hevc","webm","mkv","avi","gif","mp3","m4a","wav"],ao=["mp3","m4a","wav","aiff","flac","opus","ogg"],co=["mp3","m4a","opus","flac","aiff","wav"];async function po(e){let t=await oo(e,"r");try{let o=Buffer.alloc(64),{bytesRead:n}=await t.read(o,0,o.length,0);return o.subarray(0,n)}finally{await t.close()}}function fo(e,t){return t&&!t.video&&(e==="mp4"||e==="mov")?"m4a":e}async function lt(e,t){let o=dt(await po(e));if(!o)throw new Error("not video or sound");if(o!=="mp4"&&o!=="mov"&&I[o].media!==t)throw new Error(`not ${t}`);let n=(await ee(e)).size,s=await ce(),r;if(s){try{r=await pe(e,s)}catch(a){throw Y(e,a)}if(r.duration<=0||!r.video&&!r.audio)throw Y(e,r)}let i=fo(o,r);if(I[i].media!==t)throw new Error(`not ${t}`);return{kind:"media",path:e,format:i,bytes:n,...r?{facts:r}:{}}}async function uo(){let{assetFor:e,catalogEntry:t}=await import("./catalog-YSMT3PXT.js"),o=t("video");return o!==void 0&&e(o)!==void 0}async function mo(e,t){if(e.kind==="media"&&e.facts)return e.facts;try{return await pe(e.path,t)}catch(o){throw Y(e.path,o)}}function lo(e,t){let o=e.options.media??{},n=o.cut?.start??0,s=Math.min(o.cut?.end??t,t);return Math.max(0,s-n)/(o.speed??1)}function gt(e,t){if(e.op!=="convert")return;let o=e.sources[0],n=o.kind==="media"?o.facts:void 0;if(!n)return;let s=e.options.media??{},r=et({...n,duration:lo(e,n.duration)},{soundOnly:I[e.target].media==="sound",mute:s.mute===!0||e.target==="gif"});return t<r?{floor:r}:void 0}function go(e){let t=e.slice(e.lastIndexOf("{"),e.lastIndexOf("}")+1),o=JSON.parse(t);return[`measured_I=${o.input_i}`,`measured_TP=${o.input_tp}`,`measured_LRA=${o.input_lra}`,`measured_thresh=${o.input_thresh}`,`offset=${o.target_offset}`].join(":")}async function ut(e){await Promise.all(e.map(t=>no(t,{force:!0}).catch(()=>{})))}async function ht(e,t,o){if(e.op!=="convert")throw new Error(`media engines only convert, not ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=await ce();if(!r)throw Oe(n.path,process.platform,await uo());let i=await mo(n,r);await Je(s);let a=to(6).toString("hex"),p=Ne(s,a),c=so(ro(s),`.forge-pass-${a}`),d=[p,`${c}-0.log`,`${c}-0.log.temp`,`${c}-0.log.mbtree`,`${c}-0.log.mbtree.temp`],l=[],h=(u,b=e.options)=>ft({input:n.path,output:p,target:e.target,facts:i,options:b,platform:u,passlog:c,...r.has?{has:r.has}:{}}),g=e.options,m=h(process.platform);if(m.duration<=0)throw ke(`The cut keeps nothing of ${k(n.path)}: it starts at or after its end.`,`It is ${Q(i.duration)} long.`);let x=g.media?.cut;if(m.copies.video&&x&&x.start>0){let u=await Xe(n.path,x.start,r);u!==void 0&&x.start-u>.05&&(g={...g,media:{...g.media,cut:{...x,start:u}}},m=h(process.platform,g),l.push({code:"media-cut-keyframe",message:`It starts at ${Q(u)}, the keyframe just before ${Q(x.start)}.`}))}let w=async u=>{let b="";for(let y of u.steps){let S=y.args.map(_=>_.replace(fe,b)),F=await Qe(S,{tools:r,signal:o,report:y.measures==="loudness",onTime:_=>t({phase:"time",done:Math.min(_,u.duration),total:u.duration,...y.pass?{pass:y.pass}:{}})});y.measures==="loudness"&&(b=go(F))}};try{try{await w(m)}catch(y){if(o?.aborted||!m.steps.some(S=>S.args.some(F=>F.endsWith("_videotoolbox"))))throw y;m=h("linux",g),await w(m)}let u=g.media?.targetBytes;for(let y of[.95,.9]){if(u===void 0||(await ee(p)).size<=u)break;g={...g,media:{...g.media,targetBytes:Math.floor(u*y)}},m=h(m.steps.some(S=>S.args.includes("libx264"))?"linux":process.platform,g),await w(m)}let b=(await ee(p)).size;if(u!==void 0&&b>u)throw De(n,e.options.media?.targetBytes??u,b);if(e.options.compress!==void 0&&b>=n.bytes)throw Z(n.path,n.bytes,b);await We(p,s)}catch(u){throw await ut(d),o?.aborted||T(u)?u:L(n.path,u)}await ut(d.slice(1));let P=i.video;if(m.fitted&&P&&(m.fitted.width<P.width-2||m.fitted.fps<P.fps)){let u=Re(e.options.media?.targetBytes??0);l.push({code:"media-fitted",message:`To fit ${u} it is now ${m.fitted.width}\xD7${m.fitted.height} at ${m.fitted.fps} fps.`})}return{job:e,outputBytes:(await ee(s)).size,warnings:l}}var G=e=>new Set(e);function ho(e){let t=e.kind==="media"?e.facts:void 0,o=e.kind==="image"||t!==void 0&&t.audio===void 0;return G(mt.filter(n=>!(o&&I[n].media==="sound"||n==="hevc"&&t?.video?.codec==="hevc")))}var wt={id:"video",reads:G(io),writes:G(mt),ops:new Set(["convert"]),probe:e=>lt(e,"video"),run:ht,sizeTo:gt,writesFor:ho},yt={id:"sound",reads:G(ao),writes:G(co),ops:new Set(["convert"]),probe:e=>lt(e,"sound"),run:ht,sizeTo:gt};import{readFile as te,rm as xt,stat as wo}from"node:fs/promises";function zn(e,t){let o=e.split(",").map(r=>r.trim()).filter(r=>r!=="");if(o.length===0)throw C(e,"That selects no pages.",t);let n=new Set,s=(r,i)=>{if(!Number.isInteger(r)||r<1||r>t)throw C(i,`"${i}" is outside 1 and ${t}.`,t);return r};for(let r of o){let i=r.match(/^(\d+)\s*-\s*(\d*)$/);if(i?.[1]!==void 0){let a=s(Number(i[1]),r),p=i[2]===""?t:s(Number(i[2]),r);if(p<a)throw C(r,`"${r}" ends before it starts.`,t);for(let c=a;c<=p;c++)n.add(c-1);continue}if(!/^\d+$/.test(r))throw C(r,`"${r}" is not a page number.`,t);n.add(s(Number(r),r)-1)}return[...n].sort((r,i)=>r-i)}function vt(e){return[...new Set(e)].sort((t,o)=>t-o)}function Un(e){if(e.length===0)return"";let t=[...new Set(e)].sort((r,i)=>r-i),o=[],n=t[0],s=n;for(let r of t.slice(1)){if(r===s+1){s=r;continue}o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),n=r,s=r}return o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),o.join(", ")}function bt(e,t){let o=[...new Set(e)].sort((r,i)=>r-i).filter(r=>r>=0&&r<t-1),n=[],s=0;for(let r of o)n.push({from:s,to:r}),s=r+1;return n.push({from:s,to:t-1}),n}var ue=ze(()=>import("./pdf-compress-U2E3CNXG.js")),yo=new Set(["pdf","jpeg","png","webp","avif","gif","tiff"]),vo=new Set(["pdf"]);async function W(e){return(await D()).PDFDocument.load(await te(e),{ignoreEncryption:!0})}async function bo(e){let{surveyDocument:t}=await ue(),o=await W(e),{size:n}=await wo(e);return{kind:"document",path:e,format:"pdf",bytes:n,pages:o.getPageCount(),encrypted:o.isEncrypted,images:t(o)}}function z(e){for(let t of e)if(t.encrypted)throw B(t.path)}async function xo(e,t,o){let n=await N(),s=t.format==="jpeg"||t.format==="png",r=s?(await n(o).metadata()).orientation:void 0;if(s&&(r===void 0||r===1))return t.format==="jpeg"?e.embedJpg(o):e.embedPng(o);if(t.format==="jpeg"){let i=await n(o).rotate().jpeg({quality:I.jpeg.defaultQuality,mozjpeg:!0}).toBuffer();return e.embedJpg(i)}return e.embedPng(await n(o).rotate().png().toBuffer())}async function Po(e,t){let o=e.sources[0];if(o.kind!=="image")throw new Error("the pdf engine cannot embed a document source");let n=[];o.frames>1&&n.push({code:"animation-flattened",message:`${k(o.path)} has ${o.frames} frames, and ${I.pdf.label} cannot animate. Only the first frame was converted.`}),t({phase:"reading"});let s=await te(o.path);t({phase:"encoding"});let i=await(await D()).PDFDocument.create(),a=await xo(i,o,s);i.addPage([a.width,a.height]).drawImage(a,{x:0,y:0,width:a.width,height:a.height}),t({phase:"writing"});let c=await E(e.outputs[0],await i.save());return{job:e,outputBytes:c,warnings:n}}async function Fo(e,t){z(e.sources.filter(i=>i.kind==="document"));let n=await(await D()).PDFDocument.create();for(let i of e.sources){t({phase:"reading"});let a=await W(i.path),p=await n.copyPages(a,a.getPageIndices());for(let c of p)n.addPage(c)}t({phase:"writing"});let s=await n.save(),r=await E(e.outputs[0],s);return{job:e,outputBytes:r,warnings:[]}}async function Eo(e,t){let o=e.sources[0];z([o]);let n=await D();t({phase:"reading"});let s=await W(o.path),r=bt(e.cuts,s.getPageCount()),i=[],a=0;try{for(let[p,c]of r.entries()){let d=await n.PDFDocument.create(),l=Array.from({length:c.to-c.from+1},(m,x)=>c.from+x),h=await d.copyPages(s,l);for(let m of h)d.addPage(m);let g=e.outputs[p];if(g===void 0)throw new Error(`split produced ${r.length} parts but was given ${e.outputs.length} outputs`);a+=await E(g,await d.save()),i.push(g),t({phase:"page",done:p+1,total:r.length})}}catch(p){throw await Promise.all(i.map(c=>xt(c,{force:!0}))),p}return{job:e,outputBytes:a,warnings:[]}}async function de(e,t){let n=await(await D()).PDFDocument.create(),s=await n.copyPages(e,t);for(let r of s)n.addPage(r);return n.save()}async function So(e,t){let o=e.sources[0];if(z([o]),e.pages.length===0)throw ae("That extract selects no pages.");t({phase:"reading"});let n=await W(o.path),s=vt(e.pages),r=[],i=0;try{if(e.separate)for(let[a,p]of s.entries()){let c=e.outputs[a];i+=await E(c,await de(n,[p])),r.push(c),t({phase:"page",done:a+1,total:s.length})}else{t({phase:"writing"});let a=e.outputs[0];i=await E(a,await de(n,s)),r.push(a)}}catch(a){throw await Promise.all(r.map(p=>xt(p,{force:!0}))),a}return{job:e,outputBytes:i,warnings:[]}}async function Io(e,t){let o=e.sources[0];z([o]),t({phase:"reading"});let n=await W(o.path),s=new Set(e.pages),r=n.getPageIndices().filter(a=>!s.has(a));if(r.length===0)throw ae("That would delete every page.");t({phase:"writing"});let i=await E(e.outputs[0],await de(n,r));return{job:e,outputBytes:i,warnings:[]}}async function $o(e,t){let o=e.sources[0];z([o]);let n=await D();t({phase:"reading"});let s=await W(o.path);for(let i of s.getPages()){let p=((i.getRotation().angle+e.turns*90)%360+360)%360;i.setRotation(n.degrees(p))}t({phase:"writing"});let r=await E(e.outputs[0],await s.save());return{job:e,outputBytes:r,warnings:[]}}async function Ro(e,t){let o=e.sources[0];z([o]);let{compressPdf:n}=await ue();t({phase:"reading"});let s=await te(o.path);t({phase:"encoding"});let{bytes:r,recompressed:i,skipped:a,fromDpi:p,toDpi:c}=await n(s,{quality:e.options.quality??60,dpi:e.options.dpi??150});if(e.options.compress&&r.length>=o.bytes)throw Z(o.path,o.bytes,r.length);t({phase:"writing"});let d=await E(e.outputs[0],r),l=g=>g===1?"":"s",h=[];return i===0&&a===0?h.push({code:"pdf-no-images",message:"This PDF has no images to re-encode, so its size is almost unchanged."}):i===0?h.push({code:"pdf-no-images",message:`None of its ${a} image${l(a)} could be re-encoded \u2014 they are not JPEG data.`}):a>0&&h.push({code:"pdf-images-skipped",message:`${i} image${l(i)} recompressed, ${a} skipped (not JPEG).`}),p!==void 0&&c!==void 0&&h.push({code:"pdf-downsampled",message:`Images reduced from ${p} to ${c} dpi. Pass --dpi ${p} to keep them.`}),{job:e,outputBytes:d,warnings:h}}async function Do(e){if(e.op!=="convert")return;let t=e.sources[0];if(t.kind!=="document")return;let{compressPdf:o}=await ue(),n=await te(t.path);return{ladder:[e.options.dpi??150,120,96,72].map(s=>({dpi:s})),measure:async s=>(await o(n,{quality:s.quality??60,...s.dpi===void 0?{}:{dpi:s.dpi}})).bytes.byteLength}}var Pt={id:"pdf",measurer:Do,reads:yo,writes:vo,ops:new Set(["convert","merge","split","extract","delete","rotate"]),probe:bo,async run(e,t){switch(e.op){case"convert":if(e.target!=="pdf")throw new Error("the pdf engine only converts to pdf");return e.sources[0].kind==="document"?Ro(e,t):Po(e,t);case"merge":return Fo(e,t);case"split":return Eo(e,t);case"extract":return So(e,t);case"delete":return Io(e,t);case"rotate":return $o(e,t);default:throw new Error(`the pdf engine cannot ${e.op}`)}}};import{execFile as ko}from"node:child_process";import{mkdtemp as Ao,readFile as ye,rm as _o}from"node:fs/promises";import{tmpdir as Mo}from"node:os";import{basename as Oo,extname as To,join as Ft,win32 as he}from"node:path";import{pathToFileURL as Bo}from"node:url";import{promisify as Lo}from"node:util";var we=Lo(ko),me=Buffer.from([208,207,17,224,161,177,26,225]);async function No(e){if(e.length<me.length||!e.subarray(0,me.length).equals(me))return!1;let t=await Ve();try{return t.find(t.parse(e),"WordDocument")!==null}catch{return!1}}async function Jo(e){let t=await Ge();try{let o=new t(e);if(!o.getEntry("word/document.xml"))return;let n=0,s=o.getEntry("docProps/app.xml");if(s){let r=/<Pages>(\d+)<\/Pages>/.exec(o.readAsText(s));r?.[1]&&(n=Number(r[1]))}return{pages:n}}catch{return}}async function Wo(e){let t=await ye(e),o=await Jo(t);if(o)return{kind:"document",path:e,format:"docx",bytes:t.byteLength,pages:o.pages,encrypted:!1};if(await No(t))return{kind:"document",path:e,format:"doc",bytes:t.byteLength,pages:0,encrypted:!1};throw new Error(`${e} is not a Word document`)}function zo(e,t){return e==="win32"?[he.join(t.ProgramFiles??"C:\\Program Files","LibreOffice","program","soffice.exe"),he.join(t["ProgramFiles(x86)"]??"C:\\Program Files (x86)","LibreOffice","program","soffice.exe")]:["/Applications/LibreOffice.app/Contents/MacOS/soffice"]}var Uo=0;async function Co(){Uo++;try{return await we("soffice",["--version"],{timeout:5e3}),"soffice"}catch{}for(let e of zo(process.platform,process.env))try{return await we(e,["--version"],{timeout:5e3}),e}catch{}}var Et,qo=!1,Go;async function Vo(){return qo?Go:(Et??=Co(),Et)}var ve="\f";function oe(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)}async function Ho(e){if(e.format==="docx"){let o=await Ce(),{value:n}=await o.extractRawText({path:e.path});return oe(n)}if(e.format==="doc"){let o=await qe(),s=await new o().extract(e.path);return oe(s.getBody())}return(await nt(await ye(e.path))).flatMap((o,n)=>n===0?oe(o):[ve,...oe(o)])}var le=612,ne=792,A=54,ge=11,St=14;async function Ko(e){let{PDFDocument:t,StandardFonts:o}=await D(),n=await t.create(),s=await n.embedFont(o.Helvetica),r=le-A*2,i=n.addPage([le,ne]),a=ne-A,p=()=>{i=n.addPage([le,ne]),a=ne-A};for(let c of e){if(c===ve){p();continue}let d="";for(let l of c.split(/\s+/).filter(Boolean)){let h=d?`${d} ${l}`:l;d&&s.widthOfTextAtSize(h,ge)>r?(a<A&&p(),i.drawText(d,{x:A,y:a,size:ge,font:s}),a-=St,d=l):d=h}d&&(a<A&&p(),i.drawText(d,{x:A,y:a,size:ge,font:s}),a-=St)}return n.save()}async function Yo(e){let{Document:t,Packer:o,PageBreak:n,Paragraph:s}=await He(),r=e.map(a=>a===ve?new s({children:[new n]}):new s(a)),i=new t({sections:[{children:r}]});return o.toBuffer(i)}var Zo=new Set(["docx","doc","pdf"]),Xo=new Set(["docx","pdf"]),Qo=new Set(["convert"]),jo={code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: brew install --cask libreoffice"};function en(e=process.platform){return e!=="win32"?jo:{code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice from libreoffice.org for full-fidelity conversion."}}function tn(e,t,o,n=process.platform){return[`-env:UserInstallation=${n==="win32"?Bo(he.join(e,"profile"),{windows:!0}).href:`file://${e}/profile`}`,"--headless","--convert-to",o,"--outdir",e,t]}async function on(e,t,o){let n=await Ao(Ft(Mo(),"forge-word-"));try{await we(e,tn(n,t,o),{timeout:12e4});let s=Oo(t,To(t));return await ye(Ft(n,`${s}.${o}`))}finally{await _o(n,{recursive:!0,force:!0})}}async function nn(e,t){if(e.op!=="convert")throw new Error(`the word engine cannot ${e.op}`);let o=e.sources[0];if(o.kind!=="document")throw new Error("the word engine can only convert a document source");if(o.encrypted)throw B(o.path);t({phase:"reading"});let n=await Vo();t({phase:"encoding"});let s=[],r;try{if(n!==void 0)r=await on(n,o.path,e.target);else{let a=await Ho(o);r=e.target==="pdf"?await Ko(a):await Yo(a),s.push(en())}}catch(a){throw L(o.path,a)}t({phase:"writing"});let i=await E(e.outputs[0],r);return{job:e,outputBytes:i,warnings:s}}var It={id:"word",reads:Zo,writes:Xo,ops:Qo,probe:Wo,run:nn};var be=[Ze,wt,yt,Pt,It,at,rt];function hr(e){if(e.op==="convert"){let t=e.sources[0].format;return be.find(o=>o.reads.has(t)&&o.writes.has(e.target))}return be.find(t=>t.ops.has(e.op))}async function wr(e){let t;for(let o of be)try{return await o.probe(e)}catch(n){T(t)||(t=n)}throw t}export{zn as a,vt as b,Un as c,bt as d,ot as e,rt as f,be as g,hr as h,wr as i};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as k}from"./chunk-HON4OV7M.js";import{b as p}from"./chunk-M66BUNYO.js";import{mkdir as A,readFile as O,rename as M,unlink as T,writeFile as D}from"node:fs/promises";import{homedir as F}from"node:os";import{dirname as I,join as S}from"node:path";var C=e=>/^[A-Za-z0-9][A-Za-z0-9-]*$/.test(e),a=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),u=e=>typeof e=="number"&&Number.isInteger(e)&&e>0;function B(e){if(!(!a(e)||Object.keys(e).length!==1)){if(u(e.width))return{width:e.width};if(u(e.height))return{height:e.height};if(u(e.percent))return{percent:e.percent}}}function R(e){if(!a(e))return;let t={};if(e.to!==void 0){if(typeof e.to!="string"||!p(e.to))return;t.to=e.to}if(e.quality!==void 0){if(!u(e.quality)||e.quality>100)return;t.quality=e.quality}if(e.maxBytes!==void 0){if(!u(e.maxBytes))return;t.maxBytes=e.maxBytes}if(e.resize!==void 0){let n=B(e.resize);if(!n)return;t.resize=n}for(let n of["trim","sharpen","removeBackground"])if(e[n]!==void 0){if(typeof e[n]!="boolean")return;t[n]=e[n]}if(e.crop!==void 0){if(!a(e.crop)||!u(e.crop.w)||!u(e.crop.h))return;t.crop={w:e.crop.w,h:e.crop.h}}if(e.boost!==void 0){if(e.boost!==2&&e.boost!==3&&e.boost!==4)return;t.boost=e.boost}if(e.behind!==void 0){if(e.behind!=="white"&&e.behind!=="black")return;t.behind=e.behind}return t}function b(e){if(!a(e)||typeof e.name!="string"||!C(e.name)||typeof e.saveTo!="string"||e.saveTo.trim()==="")return;let t=R(e.steps);if(t)return{name:e.name,steps:t,saveTo:e.saveTo}}var q={white:"#ffffff",black:"#000000"};function U(e,t){let n=[];e.removeBackground&&n.push({kind:"cutout"}),e.boost?n.push({kind:"boost",scale:e.boost}):e.sharpen&&n.push({kind:"boost",scale:1});let i=[];e.trim&&i.push({kind:"cut",trim:!0}),e.crop&&i.push({kind:"cut",crop:e.crop});let s=e.to??t,r={kind:"encode",target:s};if(e.quality!==void 0&&!e.maxBytes&&(r.quality=e.quality),e.maxBytes&&(r.maxBytes=e.maxBytes),e.resize&&(r.resize=e.resize),n.length===0){let o=i.pop();o?.kind==="cut"&&(o.trim&&(r.trim=!0),o.crop&&(r.crop=o.crop))}if(r.maxBytes&&(r.trim||r.crop||r.resize)){let{trim:o,crop:m,resize:y}=r;i.push({kind:"cut",...o?{trim:o}:{},...m?{crop:m}:{},...y?{resize:y}:{}}),delete r.trim,delete r.crop,delete r.resize}if(e.removeBackground&&!p(s)?.hasAlpha&&(r.background=q[e.behind??"white"]),i.length===0&&n.length===0&&Object.keys(r).length===2&&e.to===void 0)return[];let d=i.filter(o=>o.kind==="cut"&&o.resize);return[...i.filter(o=>!d.includes(o)),...n,...d,r]}import{execFileSync as E}from"node:child_process";import{homedir as x}from"node:os";import{join as P}from"node:path";var N={Desktop:"[Environment]::GetFolderPath('Desktop')",Downloads:"(Get-ItemProperty 'HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders').'{374DE290-123F-4565-9164-39C4925E467B}'"};function j(e){try{let n=E("powershell.exe",["-NoProfile","-NonInteractive","-Command",`[Console]::OutputEncoding=[Text.Encoding]::UTF8; ${N[e]}`],{encoding:"buffer",timeout:5e3,stdio:["ignore","pipe","ignore"]}).toString("utf8").trim();return n.length>0?n:void 0}catch{return}}var w=new Map;function l(e,t=process.platform,n=j){if(t!=="win32")return P(x(),e);let i=w.get(e);if(i!==void 0)return i;let r=n(e)?.replace(/%([^%]+)%/g,(g,o)=>process.env[o]??g),d=(r!==void 0&&!r.includes("%")?r:void 0)??P(x(),e);return w.set(e,d),d}var f={defaultOutput:"~/Desktop",quality:80};function h(){return S(k(),"forge","config.json")}function ee(e,t=process.platform){if(t==="win32"){if(e==="~/Desktop")return l("Desktop",t);if(e==="~/Downloads")return l("Downloads",t)}return e==="~"?F():e.startsWith("~/")?S(F(),e.slice(2)):e}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function $(e){let t={...f},n=[];if(e.theme!==void 0&&(e.theme==="dark"||e.theme==="light"?t.theme=e.theme:n.push("theme")),e.defaultOutput!==void 0&&(typeof e.defaultOutput=="string"&&e.defaultOutput.trim().length>0?t.defaultOutput=e.defaultOutput:n.push("defaultOutput")),e.quality!==void 0){let i=e.quality;typeof i=="number"&&Number.isInteger(i)&&i>=1&&i<=100?t.quality=i:n.push("quality")}if(e.updateCheck!==void 0&&(typeof e.updateCheck=="boolean"?t.updateCheck=e.updateCheck:n.push("updateCheck")),e.rightClickMenu!==void 0&&(typeof e.rightClickMenu=="boolean"?t.rightClickMenu=e.rightClickMenu:n.push("rightClickMenu")),e.searchMac!==void 0&&(typeof e.searchMac=="boolean"?t.searchMac=e.searchMac:n.push("searchMac")),e.lastOutput!==void 0&&(typeof e.lastOutput=="string"&&e.lastOutput.trim().length>0?t.lastOutput=e.lastOutput:n.push("lastOutput")),e.presets!==void 0)if(Array.isArray(e.presets)){let i=e.presets.map(b);t.presets=i.filter(s=>s!==void 0),t.presets.length<i.length&&n.push("presets")}else n.push("presets");return{prefs:t,rejected:n}}async function K(){let e;try{e=await O(h(),"utf8")}catch{return}try{let t=JSON.parse(e);return z(t)?t:void 0}catch{return}}async function te(){let e=h(),t;try{t=await O(e,"utf8")}catch(r){return r.code==="ENOENT"?{prefs:f}:{prefs:f,warning:`Could not read the config at ${e} \u2014 using defaults.`}}let n;try{n=JSON.parse(t)}catch{return{prefs:f,warning:`The config at ${e} is not valid JSON \u2014 using defaults.`}}if(!z(n))return{prefs:f,warning:`The config at ${e} is not an object \u2014 using defaults.`};let{prefs:i,rejected:s}=$(n);return s.length===0?{prefs:i}:{prefs:i,warning:`Ignored invalid config ${s.length===1?"setting":"settings"}: ${s.join(", ")}.`}}async function ne(e){let t=h();await A(I(t),{recursive:!0});let i={...await K()??{}};for(let[r,c]of Object.entries(e))c!==void 0&&(i[r]=c);let s=`${t}.${process.pid}.tmp`;try{await D(s,`${JSON.stringify(i,null,2)}
4
+ `,"utf8"),await M(s,t)}catch(r){throw await T(s).catch(()=>{}),r}}export{U as a,l as b,f as c,h as d,ee as e,te as f,ne as g};
@@ -0,0 +1,4 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
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-EGIKV2GZ.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-264DPO6I.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-26YSXWT4.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-TGOF36YW.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-4NH6H4HA.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};