forge-terminal 0.5.1 → 0.5.2

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 (116) hide show
  1. package/README.md +7 -6
  2. package/dist/chunks/{about-credits-FZ35HUFP.js → about-credits-VZQJAWG3.js} +1 -1
  3. package/dist/chunks/args-FZXEZBPA.js +3 -0
  4. package/dist/chunks/{boot-PCZBPNFR.js → boot-NYKO3NLR.js} +1 -1
  5. package/dist/chunks/chunk-2AFHW44W.js +36 -0
  6. package/dist/chunks/{chunk-S2M4XESA.js → chunk-63ZZRDSV.js} +1 -1
  7. package/dist/chunks/{chunk-63ZK5SRQ.js → chunk-7I2OSTBX.js} +1 -1
  8. package/dist/chunks/chunk-7KYO62XK.js +3 -0
  9. package/dist/chunks/{chunk-DZOBIUV6.js → chunk-BIBDLXCG.js} +1 -1
  10. package/dist/chunks/{chunk-G46QQBT3.js → chunk-BROTSQXG.js} +1 -1
  11. package/dist/chunks/chunk-CVNYUROW.js +3 -0
  12. package/dist/chunks/chunk-CW2Y2KDQ.js +3 -0
  13. package/dist/chunks/chunk-DYIATUFE.js +3 -0
  14. package/dist/chunks/{chunk-SK2UZ25Y.js → chunk-EITGK5OI.js} +1 -1
  15. package/dist/chunks/chunk-GRWOJKQB.js +3 -0
  16. package/dist/chunks/{chunk-X26WUHWB.js → chunk-GT6U6HV3.js} +1 -1
  17. package/dist/chunks/{chunk-JMBEZPYC.js → chunk-HWCXNKIN.js} +1 -1
  18. package/dist/chunks/chunk-IED6VBE6.js +3 -0
  19. package/dist/chunks/{chunk-2CX33C6H.js → chunk-ITW5FG4K.js} +1 -1
  20. package/dist/chunks/{chunk-MTDCDKPU.js → chunk-IVBSXPNS.js} +2 -2
  21. package/dist/chunks/chunk-J2UQI544.js +4 -0
  22. package/dist/chunks/{chunk-THDAQBQ3.js → chunk-J6AZTW62.js} +1 -1
  23. package/dist/chunks/chunk-JGJU3AW5.js +3 -0
  24. package/dist/chunks/{chunk-XURW53YK.js → chunk-K6ERQTUQ.js} +1 -1
  25. package/dist/chunks/chunk-KMLT45OJ.js +66 -0
  26. package/dist/chunks/{chunk-QXNB5DQ2.js → chunk-LA5JVBFP.js} +1 -1
  27. package/dist/chunks/chunk-M6LYLTFH.js +3 -0
  28. package/dist/chunks/chunk-O7DK3GJT.js +3 -0
  29. package/dist/chunks/chunk-Q7ERPAG3.js +7 -0
  30. package/dist/chunks/{chunk-HCLEHCAR.js → chunk-R24JCIZ5.js} +1 -1
  31. package/dist/chunks/{chunk-3KWAO2N2.js → chunk-RK3WGALB.js} +1 -1
  32. package/dist/chunks/chunk-RXI6QLNY.js +82 -0
  33. package/dist/chunks/chunk-SNFUGJ3M.js +3 -0
  34. package/dist/chunks/chunk-T37DEXUI.js +3 -0
  35. package/dist/chunks/chunk-TARDT6LZ.js +55 -0
  36. package/dist/chunks/{chunk-EKTUUKDP.js → chunk-TYWGB767.js} +1 -1
  37. package/dist/chunks/chunk-VLVNA4T3.js +3 -0
  38. package/dist/chunks/{chunk-YINYF6C7.js → chunk-VTA6Z45X.js} +1 -1
  39. package/dist/chunks/{chunk-JOIHR724.js → chunk-W2QJA73Q.js} +1 -1
  40. package/dist/chunks/{chunk-BD3OLIVT.js → chunk-XPATZLEH.js} +1 -1
  41. package/dist/chunks/chunk-XUKYIVJC.js +3 -0
  42. package/dist/chunks/{chunk-GLAD7GP2.js → chunk-YK26E3OX.js} +1 -1
  43. package/dist/chunks/{chunk-YNZIN42P.js → chunk-ZFLFBNIK.js} +1 -1
  44. package/dist/chunks/{chunk-655UG277.js → chunk-ZHNPBRCX.js} +1 -1
  45. package/dist/chunks/{chunk-C4UCCBCX.js → chunk-ZOQA3JAR.js} +1 -1
  46. package/dist/chunks/clip-command-SLSAWJF4.js +3 -0
  47. package/dist/chunks/clipboard-7KSZNWWT.js +3 -0
  48. package/dist/chunks/colour-LMZO2EE6.js +3 -0
  49. package/dist/chunks/command-DMGGGAPS.js +3 -0
  50. package/dist/chunks/config-command-6GXRV627.js +3 -0
  51. package/dist/chunks/continue-editing-4W3XWWCE.js +3 -0
  52. package/dist/chunks/decoded-SMEHAVCH.js +3 -0
  53. package/dist/chunks/{entry-2XJD7UCY.js → entry-TV4FJQDR.js} +2 -2
  54. package/dist/chunks/execute-NEDE4JM6.js +3 -0
  55. package/dist/chunks/extensions-4UJRQ32J.js +3 -0
  56. package/dist/chunks/{extensions-command-MGPRISPH.js → extensions-command-VROVGVD4.js} +1 -1
  57. package/dist/chunks/{ffmpeg-2UZXAB3C.js → ffmpeg-OIVMTPY7.js} +1 -1
  58. package/dist/chunks/image-J5WDYORX.js +3 -0
  59. package/dist/chunks/install-5XLVERRR.js +3 -0
  60. package/dist/chunks/install-C6XNONFF.js +3 -0
  61. package/dist/chunks/launch-5JMWS5CI.js +17 -0
  62. package/dist/chunks/lock-AFVXUDOM.js +3 -0
  63. package/dist/chunks/manager-T3WDLUKR.js +4 -0
  64. package/dist/chunks/{needed-YEXRZMZX.js → needed-YU5BPYD6.js} +1 -1
  65. package/dist/chunks/notify-LTV7F634.js +3 -0
  66. package/dist/chunks/{own-WOK6H277.js → own-OJAQ5FRQ.js} +1 -1
  67. package/dist/chunks/pdfium-7HNCQ3K3.js +3 -0
  68. package/dist/chunks/preset-command-VP5RAXBG.js +3 -0
  69. package/dist/chunks/registry-E5PNQWOZ.js +3 -0
  70. package/dist/chunks/run-WSETTQXP.js +3 -0
  71. package/dist/chunks/{server-QNWPC2CC.js → server-EFNTD7ZW.js} +3 -3
  72. package/dist/chunks/{theme-EHFY7DT6.js → theme-NF3LQHPV.js} +1 -1
  73. package/dist/chunks/transcribe-CQFHXBTV.js +3 -0
  74. package/dist/chunks/transcribe-command-ZXB3JJFZ.js +3 -0
  75. package/dist/chunks/update-command-DJLYU6AB.js +3 -0
  76. package/dist/chunks/{update-note-GYJWUDFS.js → update-note-CJ5XYKYH.js} +1 -1
  77. package/dist/chunks/watch-command-ZNMO4SF7.js +3 -0
  78. package/dist/index.js +13 -13
  79. package/package.json +9 -9
  80. package/dist/chunks/args-FSQFXDIX.js +0 -3
  81. package/dist/chunks/chunk-2J2PTA5O.js +0 -3
  82. package/dist/chunks/chunk-2MLASXG5.js +0 -3
  83. package/dist/chunks/chunk-5TEAR5XH.js +0 -3
  84. package/dist/chunks/chunk-63BBFKT2.js +0 -4
  85. package/dist/chunks/chunk-72TNSFL5.js +0 -36
  86. package/dist/chunks/chunk-AYB5AJ4E.js +0 -3
  87. package/dist/chunks/chunk-C32KGH4S.js +0 -3
  88. package/dist/chunks/chunk-LBDSFSYP.js +0 -3
  89. package/dist/chunks/chunk-OY4EGSPE.js +0 -3
  90. package/dist/chunks/chunk-UXRQ4UBQ.js +0 -66
  91. package/dist/chunks/chunk-WIPP5TWQ.js +0 -3
  92. package/dist/chunks/chunk-WZWK3PEZ.js +0 -3
  93. package/dist/chunks/chunk-ZRHYGR2L.js +0 -134
  94. package/dist/chunks/clip-command-NZNC46H2.js +0 -3
  95. package/dist/chunks/clipboard-GICOXMMN.js +0 -3
  96. package/dist/chunks/colour-GSDOHCFK.js +0 -3
  97. package/dist/chunks/command-GYCYLUHN.js +0 -3
  98. package/dist/chunks/config-command-6YUMMZF3.js +0 -3
  99. package/dist/chunks/continue-editing-QE5RRIMG.js +0 -3
  100. package/dist/chunks/decoded-NBZ335RZ.js +0 -3
  101. package/dist/chunks/execute-FYEXZ7EY.js +0 -3
  102. package/dist/chunks/extensions-V5O4NIHI.js +0 -3
  103. package/dist/chunks/image-3CMUB2P4.js +0 -3
  104. package/dist/chunks/install-IDUHZTTS.js +0 -3
  105. package/dist/chunks/install-L5C2UT6M.js +0 -3
  106. package/dist/chunks/launch-GUHDBMSJ.js +0 -17
  107. package/dist/chunks/lock-UQJ66TZ3.js +0 -3
  108. package/dist/chunks/manager-UKTMRXKE.js +0 -4
  109. package/dist/chunks/pdfium-LYHOU6WV.js +0 -3
  110. package/dist/chunks/preset-command-6A2C6VPQ.js +0 -3
  111. package/dist/chunks/registry-2YU7NW4P.js +0 -3
  112. package/dist/chunks/run-U2CU6VGE.js +0 -5
  113. package/dist/chunks/transcribe-SCL3LFZU.js +0 -3
  114. package/dist/chunks/transcribe-command-BX2VVUI3.js +0 -3
  115. package/dist/chunks/update-command-JCTCRPCS.js +0 -3
  116. package/dist/chunks/watch-command-ZLZAWTNJ.js +0 -3
package/README.md CHANGED
@@ -50,7 +50,7 @@ That puts `forge` on your `PATH`, so it works from any directory. Verify:
50
50
 
51
51
  ```bash
52
52
  forge --version
53
- # 0.5.1
53
+ # 0.5.2
54
54
 
55
55
  forge photo.jpg --to webp
56
56
  ```
@@ -888,7 +888,7 @@ forge <inputs...> --to <format> [options]
888
888
  | `--keep-metadata` | preserve EXIF/GPS instead of stripping it |
889
889
  | `--recursive` | descend into subdirectories |
890
890
  | `--force` | allow overwriting an existing output file |
891
- | `--concurrency <n>` | batch parallelism (default `min(cpus, 4)`) |
891
+ | `--concurrency <n>` | batch parallelism (default: one per core, at most 8) |
892
892
  | `--debug` | include stack traces in error output |
893
893
  | `--formats` | print the capability matrix |
894
894
  | `-V, --version` / `-h, --help` | the usual |
@@ -1117,7 +1117,7 @@ photo.png · PNG · 122 KB · 2756×774
1117
1117
  With `--json`:
1118
1118
 
1119
1119
  ```json
1120
- {"forge":"0.5.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":[]}
1120
+ {"forge":"0.5.2","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":[]}
1121
1121
  ```
1122
1122
 
1123
1123
  `targets` and `actions` come from the engines' own capabilities, so they are
@@ -1143,7 +1143,7 @@ succeeded) and `failures`. A conversion, compression or page operation adds
1143
1143
 
1144
1144
  ```jsonc
1145
1145
  {
1146
- "forge": "0.5.1",
1146
+ "forge": "0.5.2",
1147
1147
  "ok": false,
1148
1148
  "results": [
1149
1149
  {
@@ -1441,8 +1441,9 @@ These apply automatically, unconditionally, unless a flag opts out:
1441
1441
  4. **Never drop animation silently.** An animated source converting to a
1442
1442
  format that can't animate keeps only the first frame — and attaches a
1443
1443
  warning to the result, rather than converting quietly and losing frames.
1444
- 5. **Bounded concurrency.** Batches run `min(cpus, 4)` conversions at a
1445
- time, so Sharp's threadpool isn't overwhelmed.
1444
+ 5. **Bounded concurrency.** Batches run one conversion per core, at most
1445
+ 8 at a time, and Forge gives Sharp's threadpool a thread for each, so
1446
+ neither waits on the other. Video and sound encode one at a time.
1446
1447
 
1447
1448
  Writes are atomic: output goes to a temp file in the destination directory
1448
1449
  and is renamed into place only on success, so a crash mid-encode never
@@ -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:"Noto Sans",licence:"OFL-1.1"},{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 F({from:n=import.meta.url,list:t=async()=>(await import("./manager-UKTMRXKE.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-V5O4NIHI.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{F 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 F({from:n=import.meta.url,list:t=async()=>(await import("./manager-T3WDLUKR.js")).listExtensions()}={}){let[e,i]=await Promise.all([k(n),t().catch(()=>[])]),{extensionCredits:s}=await import("./extensions-4UJRQ32J.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{F 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,e,f}from"./chunk-ZFLFBNIK.js";import"./chunk-U5TEGDGH.js";import"./chunk-R24JCIZ5.js";import"./chunk-XPATZLEH.js";import"./chunk-HZDYZ5RD.js";import"./chunk-QVACE4IE.js";import"./chunk-RK3WGALB.js";import"./chunk-DYIATUFE.js";import"./chunk-EEQSUBBL.js";import"./chunk-LA5JVBFP.js";import"./chunk-K6ERQTUQ.js";import"./chunk-HWCXNKIN.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-T37DEXUI.js";import"./chunk-J6AZTW62.js";import"./chunk-BIBDLXCG.js";import"./chunk-7KYO62XK.js";import"./chunk-CVNYUROW.js";import"./chunk-J7FLFHQJ.js";import"./chunk-VLVNA4T3.js";import"./chunk-H3DIRJFE.js";import"./chunk-KXKQDFHX.js";import"./chunk-TMUK2DD3.js";export{b as COMMANDS_HELP,a as EXIT_CODES_HELP,d as colourUsage,c as commandsHelp,f as parseArgs,e as wantsJson};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{r as a}from"./chunk-3KWAO2N2.js";import{e as l}from"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";var c={loadPreferences:l,loadShell:()=>import("./launch-GUHDBMSJ.js")};async function f(e=c,n={}){let t=e.loadShell();t.catch(()=>{});let{prefs:o,warning:r}=await e.loadPreferences(),s=a(o.theme),{launchShell:i}=await t;await i({prefs:o,palette:s,...r===void 0?{}:{warning:r},...n})}export{f as bootShell};
3
+ import{r as a}from"./chunk-RK3WGALB.js";import{e as l}from"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";var c={loadPreferences:l,loadShell:()=>import("./launch-5JMWS5CI.js")};async function f(e=c,n={}){let t=e.loadShell();t.catch(()=>{});let{prefs:o,warning:r}=await e.loadPreferences(),s=a(o.theme),{launchShell:i}=await t;await i({prefs:o,palette:s,...r===void 0?{}:{warning:r},...n})}export{f as bootShell};
@@ -0,0 +1,36 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{c as he}from"./chunk-MF3KKEFB.js";import{b as je}from"./chunk-I25E2XDH.js";import{b as mt}from"./chunk-HZDYZ5RD.js";import{c as He}from"./chunk-LA5JVBFP.js";import{f as dt,g as ee,h as gt,i as ht,j as pt}from"./chunk-KH5DHZ2U.js";import{ka as ge,la as $e,ma as Te,na as ct,pa as _e,qa as Re}from"./chunk-CVNYUROW.js";import{c as lt,i as ut}from"./chunk-KXKQDFHX.js";import{spawn as rn}from"node:child_process";import{existsSync as Ie}from"node:fs";import{mkdtemp as st,readFile as ot,rm as at,writeFile as _r}from"node:fs/promises";import{tmpdir as ft}from"node:os";import{dirname as on,join as O}from"node:path";import{createInterface as jr}from"node:readline";import{fileURLToPath as Hr}from"node:url";var hn=new RegExp("\\p{M}","u"),Be=new RegExp("\\p{L}","u"),pn=new RegExp("\\p{Nd}","u");function ze(e){let n=String.fromCodePoint(e);return hn.test(n)?"NSM":e>=1632&&e<=1641||e===1643||e===1644?"AN":pn.test(n)?"EN":e>=1424&&e<=1535||e>=64285&&e<=64335?Be.test(n)?"R":"ON":e>=1536&&e<=1791||e>=1792&&e<=1983||e>=1872&&e<=1919||e>=2208&&e<=2303||e>=64336&&e<=65023||e>=65136&&e<=65279?Be.test(n)?"AL":"ON":Be.test(n)?"L":e===43||e===45?"ES":e===35||e===36||e===37||e===162||e===163||e===176?"ET":e===44||e===46||e===58||e===47||e===160?"CS":n===" "||n===" "||e===12288?"WS":"ON"}var mn={"(":")",")":"(","[":"]","]":"[","{":"}","}":"{","<":">",">":"<","\xAB":"\xBB","\xBB":"\xAB"};function pe(e){for(let n of e){let t=ze(n.codePointAt(0)??0);if(t==="R"||t==="AL")return!0;if(t==="L")return!1}return!1}function bn(e){for(let n of e){let t=ze(n.codePointAt(0)??0);if(t==="R"||t==="AL"||t==="AN")return!0}return!1}function bt(e,n){let t=[...e];if(!n&&!bn(e))return e;let i=t.length,r=t.map(a=>ze(a.codePointAt(0)??0)),o=n?1:0,s=o?"R":"L";for(let a=0;a<i;a++){r[a]==="NSM"&&(r[a]=a>0?r[a-1]??"ON":o?"R":"L");let u=r[a];u==="L"||u==="R"||u==="AL"?s=u:u==="EN"&&s==="AL"&&(r[a]="AN")}for(let a=0;a<i;a++)r[a]==="AL"&&(r[a]="R");for(let a=1;a<i-1;a++){let u=r[a],l=r[a-1],g=r[a+1];(u==="ES"||u==="CS")&&l==="EN"&&g==="EN"?r[a]="EN":u==="CS"&&l==="AN"&&g==="AN"&&(r[a]="AN")}for(let a=0;a<i;a++){if(r[a]!=="ET")continue;let u=a;for(;u<i&&r[u]==="ET";)u++;if(r[a-1]==="EN"||r[u]==="EN")for(let l=a;l<u;l++)r[l]="EN";a=u-1}for(let a=0;a<i;a++)(r[a]==="ES"||r[a]==="ET"||r[a]==="CS")&&(r[a]="ON");let f=o?"R":"L";for(let a=0;a<i;a++)r[a]==="L"||r[a]==="R"?f=r[a]:r[a]==="EN"&&f==="L"&&(r[a]="L");let c=a=>a==="L"?"L":a==="R"||a==="EN"||a==="AN"?"R":void 0;for(let a=0;a<i;a++){if(r[a]!=="WS"&&r[a]!=="ON")continue;let u=a;for(;u<i&&(r[u]==="WS"||r[u]==="ON");)u++;let l=a>0?c(r[a-1]):o?"R":"L",g=u<i?c(r[u]):o?"R":"L",m=l!==void 0&&l===g?l:o?"R":"L";for(let S=a;S<u;S++)r[S]=m;a=u-1}let d=r.map(a=>o===0?a==="R"?1:a==="EN"||a==="AN"?2:0:a==="L"||a==="EN"||a==="AN"?2:1),h=t.map((a,u)=>u),p=Math.max(...d),b=Math.min(...d.filter(a=>a%2===1),Number.POSITIVE_INFINITY);for(let a=p;a>=b&&a>0;a--)for(let u=0;u<i;u++){if((d[h[u]]??0)<a)continue;let l=u;for(;l<i&&(d[h[l]]??0)>=a;)l++;let g=h.slice(u,l).reverse();h.splice(u,l-u,...g),u=l-1}return h.map(a=>{let u=t[a];return(d[a]??0)%2===1?mn[u]??u:u}).join("")}var xn=(e,n)=>{let t=e[0]+e[2]/2,i=e[1]+e[3]/2;return t>=n[0]&&t<=n[0]+n[2]&&i>=n[1]&&i<=n[1]+n[3]};function yn(e){let n=e.filter(t=>t.kind!=="text").map(t=>t.box);return e.filter(t=>t.kind!=="text"||!n.some(i=>xn(t.box,i)))}var wn=.002;function wt(e,n){let t=f=>f.box[n],i=f=>f.box[n]+(n===0?f.box[2]:f.box[3]),r=[...e].sort((f,c)=>t(f)-t(c)),o=[],s=-1;for(let f of r){let c=o[o.length-1];c&&t(f)<=s+wn?(c.push(f),s=Math.max(s,i(f))):(o.push([f]),s=i(f))}return o}function Sn(e){let n=wt(e,1);if(n.length<2)return;let t=o=>Math.max(...o.map(s=>s.box[1]+s.box[3])),i=o=>Math.min(...o.map(s=>s.box[1])),r=1;for(let o=2;o<n.length;o++){let s=f=>i(n[f]??[])-t(n[f-1]??[]);s(o)>s(r)&&(r=o)}return[n.slice(0,r).flat(),n.slice(r).flat()]}function We(e){if(e.length<=1)return[...e];let n=wt(e,0);if(n.length>1)return n.flatMap(We);let t=Sn(e);return t?t.flatMap(We):[...e].sort((i,r)=>i.box[1]-r.box[1]||i.box[0]-r.box[0])}function An(e){let n=[];for(let t of e){let i=n[n.length-1],r=Math.max(t.lineHeight,i?.lineHeight??0);if(!(i!==void 0&&t.box[1]-(i.box[1]+i.box[3])<r&&Math.abs(t.box[0]-i.box[0])<2*r)){n.push({...t});continue}let s=Math.max(i.box[0]+i.box[2],t.box[0]+t.box[2]),f=t.box[1]+t.box[3];n[n.length-1]={...i,text:`${i.text} ${t.text}`,lines:i.lines+1,box:[i.box[0],i.box[1],s-i.box[0],f-i.box[1]]}}return n}function kn(e){let n=e.flatMap(t=>Array(Math.max(1,t.lines)).fill(t.lineHeight));return n.sort((t,i)=>t-i),n[Math.floor(n.length/2)]??0}var Pn=1.2,En=80,Ge=e=>e.replace(/\s*\n\s*/g," ").trim();function Tn(e,n,t){if(e.kind==="list")return{kind:"list",ordered:e.items.some(s=>s.marker==="decimal"||s.marker==="lowercase"||s.marker==="uppercase"),items:e.items.map(s=>Ge(s.text))};if(e.kind==="table"){let s=Math.max(...e.rows.map(f=>f.length));return{kind:"table",rows:e.rows.map(f=>Array.from({length:s},(c,d)=>Ge(f[d]??"")))}}let i=Ge(e.text);return!t&&e.lineHeight>=n*Pn&&e.lines===1&&i.length<=En&&!/[.,;:!?]$/.test(i)?{kind:"heading",level:e.title?1:2,text:i}:{kind:"paragraph",text:i}}function ci(e){return e.map(n=>{let t=We(yn(n.blocks.filter(o=>o.kind!=="text"||o.text.trim()!=="")));n.lines&&(t=An(t.filter(o=>o.kind==="text")));let i=t.filter(o=>o.kind==="text"),r=kn(i);return t.map(o=>Tn(o,r,t.length===1))})}var li=e=>e.some(n=>n.length>0);function Ke(e){return e.replace(/[\\`*[\]<]/g,n=>`\\${n}`).replace(/(^|[^\p{L}\p{N}])_|_(?=[^\p{L}\p{N}]|$)/gu,n=>n.replace("_","\\_"))}function Rn(e){return e.replace(/^(#|>|[-+](?= )|(?<=^\d+)\.(?= ))/,"\\$1").replace(/^(\d+)\.(?= )/,"$1\\.")}var xt=e=>Rn(Ke(e));function Fn(e){if(e.kind==="heading")return`${"#".repeat(e.level)} ${Ke(e.text)}`;if(e.kind==="paragraph")return xt(e.text);if(e.kind==="list")return e.items.map((o,s)=>`${e.ordered?`${s+1}.`:"-"} ${xt(o)}`).join(`
4
+ `);let n=o=>Ke(o).replace(/\|/g,"\\|"),t=o=>`| ${o.map(n).join(" | ")} |`,[i=[],...r]=e.rows;return[t(i),`| ${i.map(()=>"---").join(" | ")} |`,...r.map(t)].join(`
5
+ `)}var Ve=e=>e.filter(n=>n.length>0);function St(e){let n=Ve(e).map(t=>t.map(Fn).join(`
6
+
7
+ `));return n.length?`${n.join(`
8
+
9
+ ---
10
+
11
+ `)}
12
+ `:""}function Nn(e){return e.kind==="heading"||e.kind==="paragraph"?e.text:e.kind==="list"?e.items.map((n,t)=>`${e.ordered?`${t+1}.`:"-"} ${n}`).join(`
13
+ `):e.rows.map(n=>n.join(" ")).join(`
14
+ `)}function At(e){let n=Ve(e).map(t=>t.map(Nn).join(`
15
+
16
+ `));return n.length?`${n.join(`
17
+
18
+ `)}
19
+ `:""}var vn="table{border-collapse:collapse;width:100%;margin:0 0 8pt}th,td{border:1px solid #c7c7cc;padding:2pt 6pt;text-align:left;vertical-align:top}ol{margin:0 0 8pt}",yt='<p style="margin:0;font-size:5pt">&nbsp;</p>';function Un(e){if(e.kind==="heading")return`<h${e.level}>${ee(e.text)}</h${e.level}>`;if(e.kind==="paragraph")return`<p>${ee(e.text)}</p>`;if(e.kind==="list"){let o=e.ordered?"ol":"ul";return`<${o}>${e.items.map(s=>`<li>${ee(s)}</li>`).join("")}</${o}>`}let[n=[],...t]=e.rows,i=(o,s)=>`<tr>${o.map(f=>`<${s}>${ee(f)}</${s}>`).join("")}</tr>`,r=`<table>${i(n,"th")}${t.map(o=>i(o,"td")).join("")}</table>`;return`${yt}${r}${yt}`}function kt(e,n){let t=Ve(e).map(i=>i.map(Un).join(`
20
+ `));return["<!doctype html>",`<html><head><meta charset="utf-8"><title>${ee(n)}</title><style>${gt}${vn}</style></head><body>`,t.join(`
21
+ <hr>
22
+ `),"</body></html>"].join(`
23
+ `)}var Ln=[[65,90,"latin"],[97,122,"latin"],[170,170,"latin"],[186,186,"latin"],[192,591,"latin"],[7680,7935,"latin"],[11360,11391,"latin"],[42784,43007,"latin"],[65313,65338,"latin"],[65345,65370,"latin"],[880,1023,"greek"],[7936,8191,"greek"],[1024,1327,"cyrillic"],[7296,7311,"cyrillic"],[11744,11775,"cyrillic"],[42560,42655,"cyrillic"],[1328,1423,"armenian"],[1424,1535,"hebrew"],[64285,64335,"hebrew"],[1536,1791,"arabic"],[1872,1919,"arabic"],[2208,2303,"arabic"],[64336,65023,"arabic"],[65136,65279,"arabic"],[1792,1871,"syriac"],[1920,1983,"thaana"],[2304,2431,"devanagari"],[2432,2559,"bengali"],[2560,2687,"gurmukhi"],[2688,2815,"gujarati"],[2816,2943,"oriya"],[2944,3071,"tamil"],[3072,3199,"telugu"],[3200,3327,"kannada"],[3328,3455,"malayalam"],[3456,3583,"sinhala"],[3584,3711,"thai"],[3712,3839,"lao"],[3840,4095,"tibetan"],[4096,4255,"myanmar"],[4256,4351,"georgian"],[4352,4607,"hangul"],[4608,5023,"ethiopic"],[6016,6143,"khmer"],[6144,6319,"mongolian"],[12352,12447,"kana"],[12448,12543,"kana"],[12784,12799,"kana"],[65382,65439,"kana"],[110592,110959,"kana"],[12592,12687,"hangul"],[43360,43391,"hangul"],[44032,55295,"hangul"],[65440,65500,"hangul"],[11904,12255,"han"],[12288,12351,"han"],[12544,12591,"han"],[12704,12735,"han"],[12800,13311,"han"],[13312,19903,"han"],[19968,40959,"han"],[63744,64255,"han"],[65072,65103,"han"],[65281,65312,"han"],[65371,65381,"han"],[65504,65510,"han"],[131072,205743,"han"],[127744,129791,"emoji"],[9728,10175,"symbols"]];function te(e){if(e<128)return e>=65&&e<=90||e>=97&&e<=122?"latin":void 0;for(let[n,t,i]of Ln)if(e>=n&&e<=t)return i}var Mn=new Set(["latin","greek","cyrillic","han","kana","hangul","armenian","georgian","ethiopic","emoji","symbols"]),Pt=new Set([...Mn,"arabic","hebrew","thai","lao"]),In={latin:"Latin",greek:"Greek",cyrillic:"Cyrillic",han:"Chinese",kana:"Japanese",hangul:"Korean",arabic:"Arabic",hebrew:"Hebrew",thai:"Thai",lao:"Lao",armenian:"Armenian",georgian:"Georgian",devanagari:"Devanagari",bengali:"Bengali",gurmukhi:"Gurmukhi",gujarati:"Gujarati",oriya:"Odia",tamil:"Tamil",telugu:"Telugu",kannada:"Kannada",malayalam:"Malayalam",sinhala:"Sinhala",tibetan:"Tibetan",myanmar:"Burmese",khmer:"Khmer",ethiopic:"Ethiopic",mongolian:"Mongolian",syriac:"Syriac",thaana:"Thaana",emoji:"emoji",symbols:"symbols"};function Et(e){return In[e]}function Dn(e){let n=new Set;for(let t of e){let i=te(t.codePointAt(0)??0);i!==void 0&&n.add(i)}return[...n]}function Je(e,n){let t=n?.toLowerCase().replace("_","-");if(t?.startsWith("ja"))return"ja";if(t?.startsWith("ko"))return"ko";if(t==="zh-tw"||t==="zh-hant"||t==="zh-hk")return"zh-TW";if(t?.startsWith("zh"))return"zh";let i=Dn(e);return i.includes("kana")?"ja":i.includes("hangul")?"ko":"zh"}var Cn={ja:"ja-JP",ko:"ko-KR",zh:"zh-CN","zh-TW":"zh-TW"},On={arabic:"ar-SA",hebrew:"he-IL",thai:"th-TH",lao:"lo-LA",devanagari:"hi-IN",bengali:"bn-IN",gurmukhi:"pa-IN",gujarati:"gu-IN",oriya:"or-IN",tamil:"ta-IN",telugu:"te-IN",kannada:"kn-IN",malayalam:"ml-IN",sinhala:"si-LK",khmer:"km-KH",myanmar:"my-MM",tibetan:"bo-CN",armenian:"hy-AM",georgian:"ka-GE",ethiopic:"am-ET",syriac:"syr-SY",thaana:"dv-MV"},$n=new Set(["latin","greek","cyrillic","armenian","georgian","ethiopic","mongolian","emoji","symbols"]);function _n(e){return e===void 0?"neutral":e==="han"||e==="kana"||e==="hangul"?"eastAsia":$n.has(e)?"latin":"complex"}var jn=new Set(["arabic","hebrew","syriac","thaana"]);function Tt(e,n){let t=Cn[Je(e,n)],i=[],r="";for(let o of e){let s=te(o.codePointAt(0)??0),f=_n(s);if(f==="neutral"){let p=i.at(-1);p?p.text+=o:r+=o;continue}let c=s!==void 0&&jn.has(s),d=f==="eastAsia"?t:f==="complex"&&s?On[s]:void 0,h=i.at(-1);h&&h.kind===f&&h.rtl===c&&h.lang===d?h.text+=o:i.push({text:r+o,kind:f,rtl:c,...d?{lang:d}:{}}),r=""}return r&&i.push({text:r,kind:"latin",rtl:!1}),i}import{existsSync as dr,readFileSync as gr}from"node:fs";import{dirname as hr,join as be}from"node:path";import{fileURLToPath as pr}from"node:url";import{gunzipSync as mr}from"node:zlib";var ne=new Map;function Hn(){let e=new Map,n=[[64336,64511],[65152,65276]];for(let[t,i]of n)for(let r=t;r<=i;r++){let o=String.fromCodePoint(r).normalize("NFKD");if(o===String.fromCodePoint(r))continue;let s=e.get(o);s?s.push(r):e.set(o,[r])}for(let[t,i]of e)i.length===4?ne.set(t,{isolated:i[0]??0,final:i[1]??0,initial:i[2]??0,medial:i[3]??0}):i.length===2&&ne.set(t,{isolated:i[0]??0,final:i[1]??0,initial:0,medial:0})}Hn();var Rt=e=>e>=1611&&e<=1631||e===1648||e>=1750&&e<=1756||e>=1759&&e<=1764||e===1767||e===1768||e>=1770&&e<=1773,Ft=1604,Bn=new Set([1570,1571,1573,1575]),vt=e=>ne.has(String.fromCodePoint(e)),Nt=e=>(ne.get(String.fromCodePoint(e))?.initial??0)!==0;function Ut(e){for(let n of e)if(vt(n.codePointAt(0)??0))return!0;return!1}function Lt(e,n=()=>!0){let t=[...e].map(o=>o.codePointAt(0)??0),i=[],r=!1;for(let o=0;o<t.length;o++){let s=t[o]??0;if(s===8204||s===8205){r=s===8205?r:!1,i.push(s);continue}if(Rt(s)){i.push(s);continue}let f=ne.get(String.fromCodePoint(s));if(!f){r=!1,i.push(s);continue}let c=t[o+1]??0;if(s===Ft&&Bn.has(c)){let a=ne.get(String.fromCodePoint(Ft,c)),u=a?r?a.final:a.isolated:0;if(u!==0&&n(u)){i.push(u),r=!1,o++;continue}}let d=o+1;for(;d<t.length&&Rt(t[d]??0);)d++;let h=t[d]??0,p=Nt(s)&&h!==8204&&(vt(h)||h===8205),b=r?p?f.medial:f.final:p?f.initial:f.isolated;i.push(b!==0&&n(b)?b:s),r=Nt(s)}return String.fromCodePoint(...i)}function Mt(e){return String.fromCodePoint(e).normalize("NFKD")}import{execFile as Qn}from"node:child_process";import{existsSync as er,readdirSync as tr,readFileSync as nr,statSync as rr}from"node:fs";import{homedir as ir}from"node:os";import{posix as Xe,win32 as Kt}from"node:path";var v={charset:15,encoding:16,charStrings:17,private:18,subrs:19,ros:1230,fdArray:1236,fdSelect:1237};function Y(e,n){let t=(e[n]??0)*256+(e[n+1]??0);if(t===0)return{items:[],end:n+2};let i=e[n+2]??1,r=[],o=n+3;for(let c=0;c<=t;c++){let d=0;for(let h=0;h<i;h++)d=d*256+(e[o+h]??0);r.push(d),o+=i}let s=o-1,f=[];for(let c=0;c<t;c++)f.push(e.subarray(s+(r[c]??0),s+(r[c+1]??0)));return{items:f,end:s+(r[t]??1)}}function X(e){if(e.length===0)return new Uint8Array([0,0]);let n=e.reduce((f,c)=>f+c.length,0)+1,t=n<256?1:n<65536?2:n<16777216?3:4,i=new Uint8Array(3+(e.length+1)*t+n-1);i[0]=e.length>>8,i[1]=e.length&255,i[2]=t;let r=1,o=3,s=f=>{for(let c=t-1;c>=0;c--)i[o++]=f>>8*c&255};s(r);for(let f of e)r+=f.length,s(r);for(let f of e)i.set(f,o),o+=f.length;return i}function Ye(e){let n=[],t=[],i=0,r=0;for(;r<e.length;){let o=e[r]??0;if(o<=21){let s=o;r++,o===12&&(s=1200+(e[r]??0),r++),n.push({op:s,operands:t,raw:e.subarray(i,r)}),t=[],i=r}else if(o===28)t.push(((e[r+1]??0)<<8|(e[r+2]??0))<<16>>16),r+=3;else if(o===29)t.push((e[r+1]??0)<<24|(e[r+2]??0)<<16|(e[r+3]??0)<<8|(e[r+4]??0)),r+=5;else if(o===30){for(r++;r<e.length&&((e[r]??0)&15)!==15&&(e[r]??0)>>4!==15;)r++;r++,t.push(0)}else o>=32&&o<=246?(t.push(o-139),r++):o>=247&&o<=250?(t.push((o-247)*256+(e[r+1]??0)+108),r+=2):o>=251&&o<=254?(t.push(-(o-251)*256-(e[r+1]??0)-108),r+=2):r++}return n}function zn(e){return[29,e>>24&255,e>>16&255,e>>8&255,e&255]}function Gn(e){return e>=1200?[12,e-1200]:[e]}function W(e,n){return Uint8Array.from([...n.flatMap(zn),...Gn(e)])}function Fe(e){let n=new Uint8Array(e.reduce((i,r)=>i+r.length,0)),t=0;for(let i of e)n.set(i,t),t+=i.length;return n}var q=(e,n)=>e.find(t=>t.op===n);function It(e){return e<1240?107:e<33900?1131:32768}function Dt(e){let n=e[2]??4,t=Y(e,n),i=Y(e,t.end),r=Y(e,i.end),o=Y(e,r.end),s=Ye(i.items[0]??new Uint8Array),f=q(s,v.ros)!==void 0,c=q(s,v.charStrings)?.operands[0]??0,d=Y(e,c),h=d.items.length,p=q(s,v.charset)?.operands[0]??0,b=new Array(h).fill(0);if(p<=2)for(let w=0;w<h;w++)b[w]=w;else{let w=e[p]??0,x=p+1,E=1;if(w===0)for(;E<h;E++,x+=2)b[E]=(e[x]??0)<<8|(e[x+1]??0);else for(;E<h;){let T=(e[x]??0)<<8|(e[x+1]??0),R=e[x+2]??0;x+=3,w===2&&(R=R<<8|(e[x]??0),x++);for(let I=0;I<=R&&E<h;I++,E++)b[E]=T+I}}let a=q(s,v.fdArray)?.operands[0],u=q(s,v.fdSelect)?.operands[0],l=a===void 0?[]:Y(e,a).items.map(Ye),g=new Array(h).fill(0);if(u!==void 0)if((e[u]??0)===0)for(let x=0;x<h;x++)g[x]=e[u+1+x]??0;else{let x=(e[u+1]??0)<<8|(e[u+2]??0),E=u+3;for(let T=0;T<x;T++,E+=3){let R=(e[E]??0)<<8|(e[E+1]??0),I=(e[E+3]??0)<<8|(e[E+4]??0);for(let D=R;D<I&&D<h;D++)g[D]=e[E+2]??0}}let m=w=>{let[x,E]=q(w,v.private)?.operands??[];if(x===void 0||E===void 0)return{dict:[],subrs:[]};let T=Ye(e.subarray(E,E+x)),R=q(T,v.subrs)?.operands[0];return{dict:T,subrs:R===void 0?[]:Y(e,E+R).items}},S=m(s),A=l.length>0?l.map(m):[S];return{cidKeyed:f,glyphCount:h,codeOf:w=>f?b[w]??0:w,subset(w){let x=new Set([0]);for(let y of w)y>=0&&y<h&&x.add(y);let E=Math.max(...x)+1,T=new Map;for(let y of x){let N=Vn(d.items[y]??new Uint8Array,(A[g[y]??0]??S).subrs,o.items);if(!N){T.clear();break}T.set(y,N)}let R=T.size===x.size,I=A.map(()=>new Set),D=new Set;if(!R)for(let y of x)Jn(d.items[y]??new Uint8Array,A[g[y]??0]??S,{local:I[g[y]??0]??new Set,global:D,gsubrs:o.items});let K=y=>R?T.get(y):d.items[y],Q=new Uint8Array([14]),k=new Uint8Array([11]),P=f?[...x].sort((y,N)=>y-N):Array.from({length:E},(y,N)=>N),z=(y,N)=>{if(N.size===0)return[];let B=y.length>=33900?33900:y.length>=1240?1240:0,J=Math.max(...N)+1;return y.slice(0,Math.max(J,B)).map((de,Ce)=>N.has(Ce)?de:k)},U=X(R?[]:z(o.items,D)),C=X(P.map(y=>x.has(y)?K(y)??Q:Q)),M=Wn(P.map(y=>b[y]??0)),j=l.length>0?Kn(P.map(y=>g[y]??0)):void 0,G=A.map((y,N)=>{let B=X(R?[]:z(y.subrs,I[N]??new Set)),J=y.dict.filter(Oe=>Oe.op!==v.subrs).map(Oe=>Oe.raw),de=!R&&y.subrs.length>0,Ce=de?W(v.subrs,[0]):new Uint8Array,gn=Fe([...J]).length+Ce.length;return{dict:Fe([...J,...de?[W(v.subrs,[gn])]:[]]),subrs:de?B:new Uint8Array}}),se=Uint8Array.from([1,0,4,4]),ae=X(t.items),fe=X(r.items),we=y=>{let N=[];for(let B of s)B.op===v.charset?N.push(W(v.charset,[y.charset])):B.op===v.charStrings?N.push(W(v.charStrings,[y.charStrings])):B.op===v.fdArray?N.push(W(v.fdArray,[y.fdArray])):B.op===v.fdSelect?N.push(W(v.fdSelect,[y.fdSelect])):B.op===v.private?N.push(W(v.private,[...y.priv])):B.op===v.encoding?N.push(W(v.encoding,[0])):N.push(B.raw);return X([Fe(N)])},Se=we({charset:0,charStrings:0,fdArray:0,fdSelect:0,priv:[0,0]}).length,H=se.length+ae.length+Se+fe.length+U.length,Ae=H;H+=M.length;let ke=H;H+=j?.length??0;let Pe=H;H+=C.length;let ce=y=>X(l.map((N,B)=>Fe(N.map(J=>J.op===v.private?W(v.private,[...y[B]??[0,0]]):J.raw)))),Ee=H;H+=l.length>0?ce(l.map(()=>[0,0])).length:0;let F=[];for(let y of G)F.push([y.dict.length,H]),H+=y.dict.length+y.subrs.length;let $=we({charset:Ae,charStrings:Pe,fdArray:Ee,fdSelect:ke,priv:F[0]??[0,0]}),le=[se,ae,$,fe,U,M,...j?[j]:[],C,...l.length>0?[ce(F)]:[],...G.flatMap(y=>[y.dict,y.subrs])],ue=new Uint8Array(le.reduce((y,N)=>y+N.length,0)),V=0;for(let y of le)ue.set(y,V),V+=y.length;return ue}}}function Wn(e){let n=[2],t=1;for(;t<e.length;){let o=e[t]??0,s=0;for(;t+s+1<e.length&&(e[t+s+1]??0)===o+s+1;)s++;n.push(o>>8,o&255,s>>8,s&255),t+=s+1}let i=1+2*Math.max(0,e.length-1);if(n.length<=i)return Uint8Array.from(n);let r=[0];for(let o=1;o<e.length;o++)r.push((e[o]??0)>>8,(e[o]??0)&255);return Uint8Array.from(r)}function Kn(e){let n=[],t=-1,i=0;return e.forEach((r,o)=>{r!==t&&(n.push(o>>8,o&255,r),t=r,i++)}),Uint8Array.from([3,i>>8,i&255,...n,e.length>>8,e.length&255])}function Vn(e,n,t){let i=[],r=[],o=[],s=[],f=0,c=!1,d=()=>{r.length=0,o.length=0,s.length=0},h=(a,u)=>{r.push(i.length),o.push(u.length),s.push(a),i.push(...u)},p=(a,u)=>{if(u>10)return c=!0,!0;let l=0;for(;l<a.length&&!c;){let g=a[l]??0;if(l++,g===28){let m=[28,a[l]??0,a[l+1]??0];h(((a[l]??0)<<8|(a[l+1]??0))<<16>>16,m),l+=2}else if(g>=32&&g<=246)h(g-139,[g]);else if(g>=247&&g<=250)h((g-247)*256+(a[l]??0)+108,[g,a[l]??0]),l++;else if(g>=251&&g<=254)h(-(g-251)*256-(a[l]??0)-108,[g,a[l]??0]),l++;else if(g===255)h(0,[255,a[l]??0,a[l+1]??0,a[l+2]??0,a[l+3]??0]),l+=4;else if(g===10||g===29){let m=g===10?n:t,S=s.pop(),A=r.pop(),w=o.pop();if(S===void 0||A===void 0||w===void 0||A+w!==i.length)return c=!0,!0;let x=m[S+It(m.length)];if(x===void 0)return c=!0,!0;if(i.length=A,p(x,u+1))return!0}else{if(g===11)return!1;if(g===14)return i.push(14),!0;if(g===1||g===3||g===18||g===23)f+=s.length>>1,d(),i.push(g);else if(g===19||g===20){f+=s.length>>1,d();let m=f+7>>3;i.push(g,...Array.from(a.subarray(l,l+m))),l+=m}else if(g===12){let m=a[l++]??0;if(m>=34&&m<=37)d(),i.push(12,m);else return c=!0,!0}else d(),i.push(g)}}return!1},b=p(e,0);if(!c)return b||i.push(14),Uint8Array.from(i)}function Jn(e,n,t){let i=new Set,r=!1,o=0,s=[],f=(c,d)=>{if(d>10)return r=!0,!0;let h=0;for(;h<c.length;){let p=c[h]??0;if(h++,p>=32||p===28){p===28?(s.push(((c[h]??0)<<8|(c[h+1]??0))<<16>>16),h+=2):p<=246?s.push(p-139):p<=250?s.push((p-247)*256+(c[h++]??0)+108):p<=254?s.push(-(p-251)*256-(c[h++]??0)-108):(s.push(((c[h]??0)<<24|(c[h+1]??0)<<16|(c[h+2]??0)<<8|(c[h+3]??0))/65536),h+=4);continue}if(p===10||p===29){let b=p===10?n.subrs:t.gsubrs,a=s.pop();if(a===void 0)return r=!0,!0;let u=a+It(b.length),l=b[u];if(l===void 0)return r=!0,!0;let g=`${p}:${u}:${o}`;if(!i.has(g)&&(i.add(g),(p===10?t.local:t.global).add(u),f(l,d+1)))return!0;continue}if(p===11)return!1;if(p===14)return!0;if(p===1||p===3||p===18||p===23){o+=s.length>>1,s.length=0;continue}if(p===19||p===20){o+=s.length>>1,s.length=0,h+=o+7>>3;continue}if(p===12){let b=c[h++]??0;if(b>=34&&b<=37)s.length=0;else return r=!0,!0;continue}s.length=0}return!1};f(e,0),r&&(n.subrs.forEach((c,d)=>{t.local.add(d)}),t.gsubrs.forEach((c,d)=>{t.global.add(d)}))}var Ot=32,$t=1,_t=8,jt=64,Ht=128;function Bt(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength);return String.fromCharCode(...e.subarray(0,4))==="ttcf"?n.getUint32(8):1}function Ne(e,n=0){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),i=String.fromCharCode(...e.subarray(0,4))==="ttcf"?t.getUint32(12+n*4):0,r=new Map,o=t.getUint16(i+4);for(let k=0;k<o;k++){let P=i+12+k*16,z=String.fromCharCode(...e.subarray(P,P+4));r.set(z,{offset:t.getUint32(P+8),length:t.getUint32(P+12)})}let s=k=>{let P=r.get(k);if(!P)throw new Error(`font has no ${k} table`);return P},f=s("head").offset,c=t.getUint16(f+18),d=t.getInt16(f+50)===1,h=[t.getInt16(f+36),t.getInt16(f+38),t.getInt16(f+40),t.getInt16(f+42)],p=s("hhea").offset,b=t.getInt16(p+4),a=t.getInt16(p+6),u=t.getUint16(p+34),l=t.getUint16(s("maxp").offset+4),g=s("hmtx").offset,m=r.get("OS/2"),S=m&&t.getUint16(m.offset)>=2?t.getInt16(m.offset+88):Math.round(c*.714),A=Xn(t,s("cmap").offset),w=k=>t.getUint16(g+Math.min(k,u-1)*4),x=k=>k<u?t.getInt16(g+k*4+2):t.getInt16(g+u*4+(k-u)*2),E=k=>{let P=A(k);return P===void 0||P===0||P>=l?void 0:P},T=k=>{let P=s(k);return e.subarray(P.offset,P.offset+P.length)},R=r.get("CFF ");if(R){let k=Dt(e.subarray(R.offset,R.offset+R.length));return{unitsPerEm:c,ascent:b,descent:a,capHeight:S,bbox:h,outlines:"cff",variable:r.has("fvar"),cidKeyed:k.cidKeyed,glyphOf:E,codeOf:P=>k.codeOf(P),advance:w,subset:P=>({data:k.subset(P)})}}let I=s("loca").offset,D=s("glyf"),K=k=>d?[t.getUint32(I+k*4),t.getUint32(I+k*4+4)]:[t.getUint16(I+k*2)*2,t.getUint16(I+k*2+2)*2],Q=k=>{let[P,z]=K(k);if(z<=P)return[];let U=D.offset+P;if(t.getInt16(U)>=0)return[];let C=[],M=U+10;for(;;){let j=t.getUint16(M);if(C.push(t.getUint16(M+2)),M+=4+(j&$t?4:2),j&_t?M+=2:j&jt?M+=4:j&Ht&&(M+=8),!(j&Ot))break}return C};return{unitsPerEm:c,ascent:b,descent:a,capHeight:S,bbox:h,outlines:"glyf",variable:r.has("fvar"),cidKeyed:!1,glyphOf:E,codeOf:k=>k,advance:w,subset(k){let P=new Set,z=[0,...k];for(let F=z.pop();F!==void 0;F=z.pop())P.has(F)||(P.add(F),z.push(...Q(F)));let U=[...P].sort((F,$)=>F-$),C=new Map(U.map((F,$)=>[F,$])),M=new Uint32Array(U.length+1),j=[],G=0;U.forEach((F,$)=>{M[$]=G;let[le,ue]=K(F);if(ue>le){let V=Uint8Array.from(e.subarray(D.offset+le,D.offset+ue));new DataView(V.buffer).getInt16(0)<0&&Yn(V,C),j.push(V),G+=V.length;let y=(4-G%4)%4;y&&(j.push(new Uint8Array(y)),G+=y)}}),M[U.length]=G;let se=new Uint8Array(G),ae=0;for(let F of j)se.set(F,ae),ae+=F.length;let fe=new Uint8Array((U.length+1)*4),we=new DataView(fe.buffer);M.forEach((F,$)=>{we.setUint32($*4,F)});let Se=new Uint8Array(U.length*4),H=new DataView(Se.buffer);U.forEach((F,$)=>{H.setUint16($*4,w(F)),H.setInt16($*4+2,x(F))});let Ae=Uint8Array.from(e.subarray(f,f+s("head").length)),ke=new DataView(Ae.buffer);ke.setUint32(8,0),ke.setInt16(50,1);let Pe=Uint8Array.from(T("hhea"));new DataView(Pe.buffer).setUint16(34,U.length);let ce=Uint8Array.from(T("maxp"));new DataView(ce.buffer).setUint16(4,U.length);let Ee=new Uint16Array((U.at(-1)??0)+1);for(let[F,$]of C)Ee[F]=$;return{data:Zn([["glyf",se],["head",Ae],["hhea",Pe],["hmtx",Se],["loca",fe],["maxp",ce]]),cidToGid:Ee}}}}function Yn(e,n){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),i=10;for(;;){let r=t.getUint16(i);if(t.setUint16(i+2,n.get(t.getUint16(i+2))??0),i+=4+(r&$t?4:2),r&_t?i+=2:r&jt?i+=4:r&Ht&&(i+=8),!(r&Ot))break}}function Ct(e,n){let t=0,i=e.length-1,r=-1;for(;t<=i;){let o=t+i>>1;(e[o]??0)<=n?(r=o,t=o+1):i=o-1}return r}function Xn(e,n){let t=e.getUint16(n+2),i;for(let r=0;r<t;r++){let o=e.getUint16(n+4+r*8),s=e.getUint16(n+4+r*8+2),f=n+e.getUint32(n+4+r*8+4),c=e.getUint16(f);if(o===3&&(s===1||s===10)||o===0){if(c===12){let h=e.getUint32(f+12),p=new Uint32Array(h);for(let b=0;b<h;b++)p[b]=e.getUint32(f+16+b*12);return b=>{let a=Ct(p,b);if(a<0)return;let u=e.getUint32(f+16+a*12+4);if(!(b>u))return e.getUint32(f+16+a*12+8)+(b-(p[a]??0))}}if(c===4&&i===void 0){let h=e.getUint16(f+6)/2,p=f+14,b=p+h*2+2,a=b+h*2,u=a+h*2,l=new Uint32Array(h);for(let g=0;g<h;g++)l[g]=e.getUint16(b+g*2);i=g=>{if(g>65535)return;let m=Ct(l,g);if(m<0||g>e.getUint16(p+m*2))return;let S=e.getUint16(u+m*2);if(S===0)return g+e.getInt16(a+m*2)&65535;let A=e.getUint16(u+m*2+S+(g-(l[m]??0))*2);return A===0?void 0:A+e.getInt16(a+m*2)&65535}}}}if(i)return i;throw new Error("font has no Unicode cmap")}function qn(e){let n=new Uint8Array(Math.ceil(e.length/4)*4);n.set(e);let t=new DataView(n.buffer),i=0;for(let r=0;r<n.length;r+=4)i=i+t.getUint32(r)>>>0;return i}function Zn(e){let n=[...e].sort(([c],[d])=>c<d?-1:1),t=12+n.length*16,i=n.reduce((c,[,d])=>c+Math.ceil(d.length/4)*4,t),r=new Uint8Array(i),o=new DataView(r.buffer);o.setUint32(0,65536),o.setUint16(4,n.length);let s=Math.floor(Math.log2(n.length));o.setUint16(6,2**s*16),o.setUint16(8,s),o.setUint16(10,n.length*16-2**s*16);let f=t;return n.forEach(([c,d],h)=>{let p=12+h*16;r.set(new TextEncoder().encode(c),p),o.setUint32(p+4,qn(d)),o.setUint32(p+8,f),o.setUint32(p+12,d.length),r.set(d,f),f+=Math.ceil(d.length/4)*4}),r}var ve={platform:process.platform,env:process.env,home:ir(),exists:e=>er(e),list:e=>{try{return tr(e)}catch{return[]}},run:(e,n)=>new Promise(t=>{Qn(e,n,{timeout:5e3,windowsHide:!0,maxBuffer:4e6},(i,r)=>t(i?void 0:r))}),read:e=>{try{return rr(e).size>1e8?void 0:nr(e)}catch{return}}},or={zh:[["msyh.ttc",0],["simsun.ttc",0],["simhei.ttf",0],["Deng.ttf",0],["arialuni.ttf",0]],"zh-TW":[["msjh.ttc",0],["mingliu.ttc",0],["msyh.ttc",0],["arialuni.ttf",0]],ja:[["YuGothR.ttc",0],["YuGothM.ttc",0],["meiryo.ttc",0],["msgothic.ttc",0],["msmincho.ttc",0],["arialuni.ttf",0]],ko:[["malgun.ttf",0],["gulim.ttc",0],["batang.ttc",0],["arialuni.ttf",0]],arabic:[["segoeui.ttf",0],["arial.ttf",0],["tahoma.ttf",0],["times.ttf",0],["arialuni.ttf",0]],hebrew:[["segoeui.ttf",0],["arial.ttf",0],["tahoma.ttf",0],["times.ttf",0],["arialuni.ttf",0]],thai:[["LeelawUI.ttf",0],["leelawad.ttf",0],["tahoma.ttf",0],["arialuni.ttf",0]],other:[["seguisym.ttf",0],["segoeui.ttf",0],["arial.ttf",0],["arialuni.ttf",0],["malgun.ttf",0],["msyh.ttc",0]]},sr={zh:[["PingFang.ttc",0],["STHeiti Light.ttc",1],["Hiragino Sans GB.ttc",0],["Arial Unicode.ttf",0]],"zh-TW":[["PingFang.ttc",2],["STHeiti Light.ttc",0],["Hiragino Sans GB.ttc",0],["Arial Unicode.ttf",0]],ja:[["\u30D2\u30E9\u30AE\u30CE\u89D2\u30B4\u30B7\u30C3\u30AF W3.ttc",0],["Hiragino Sans GB.ttc",0],["AquaKana.ttc",0],["Arial Unicode.ttf",0]],ko:[["AppleSDGothicNeo.ttc",0],["Arial Unicode.ttf",0]],arabic:[["GeezaPro.ttc",0],["SFArabic.ttf",0],["Arial Unicode.ttf",0]],hebrew:[["ArialHB.ttc",0],["Arial Unicode.ttf",0]],thai:[["Thonburi.ttc",0],["Arial Unicode.ttf",0]],other:[["Arial Unicode.ttf",0],["Apple Symbols.ttf",0],["Arial.ttf",0]]},zt={zh:[["NotoSansCJK-Regular.ttc",2],["NotoSansCJKsc-Regular.otf",0],["wqy-zenhei.ttc",0],["wqy-microhei.ttc",0],["DroidSansFallbackFull.ttf",0],["DroidSansFallback.ttf",0]],"zh-TW":[["NotoSansCJK-Regular.ttc",3],["NotoSansCJKtc-Regular.otf",0],["wqy-zenhei.ttc",0],["DroidSansFallbackFull.ttf",0]],ja:[["NotoSansCJK-Regular.ttc",0],["NotoSansCJKjp-Regular.otf",0],["DroidSansFallbackFull.ttf",0],["TakaoGothic.ttf",0]],ko:[["NotoSansCJK-Regular.ttc",1],["NotoSansCJKkr-Regular.otf",0],["NanumGothic.ttf",0],["DroidSansFallbackFull.ttf",0]],arabic:[["NotoSansArabic-Regular.ttf",0],["NotoNaskhArabic-Regular.ttf",0],["DejaVuSans.ttf",0],["FreeSans.ttf",0]],hebrew:[["NotoSansHebrew-Regular.ttf",0],["DejaVuSans.ttf",0],["FreeSans.ttf",0]],thai:[["NotoSansThai-Regular.ttf",0],["Garuda.ttf",0],["Loma.ttf",0],["DejaVuSans.ttf",0]],other:[["DejaVuSans.ttf",0],["NotoSansSymbols-Regular.ttf",0],["NotoSansSymbols2-Regular.ttf",0],["FreeSans.ttf",0],["LiberationSans-Regular.ttf",0]]},ar={zh:"zh-cn","zh-TW":"zh-tw",ja:"ja",ko:"ko",arabic:"ar",hebrew:"he",thai:"th"};function fr(e){return e.script==="han"||e.script==="kana"||e.script==="hangul"?e.script==="kana"?"ja":e.script==="hangul"?"ko":e.lang??"zh":e.script==="arabic"||e.script==="hebrew"||e.script==="thai"?e.script:"other"}var qe=e=>e.platform==="win32"?Kt:Xe;function cr(e){let n=Kt.join,t=e.env.WINDIR??e.env.SystemRoot??"C:\\Windows";return[n(t,"Fonts"),...e.env.LOCALAPPDATA?[n(e.env.LOCALAPPDATA,"Microsoft","Windows","Fonts")]:[]]}function lr(e){let n=Xe.join;return["/System/Library/Fonts","/System/Library/Fonts/Supplemental","/Library/Fonts",n(e.home,"Library","Fonts")]}function ur(e){let n=Xe.join,t=e.env.XDG_DATA_HOME??n(e.home,".local","share");return["/usr/share/fonts","/usr/local/share/fonts","/usr/share/fonts/opentype/noto","/usr/share/fonts/truetype",n(t,"fonts"),n(e.home,".fonts")]}function Vt(e,n,t,i=3){let{join:r}=qe(t),o=t.list(e),s=n.toLowerCase(),f=o.find(c=>c.toLowerCase()===s);if(f)return r(e,f);if(i!==0)for(let c of o){if(c.includes("."))continue;let d=Vt(r(e,c),n,t,i-1);if(d)return d}}async function Gt(e,n){let t=await n.run("fc-match",["-s","-f",`%{file} %{index}
24
+ `,e]);return t===void 0?[]:t.split(`
25
+ `).map(i=>i.split(" ")).filter(([i])=>i!==void 0&&i!=="").slice(0,8).map(([i,r])=>({path:i,index:(Number(r)||0)&65535}))}async function Jt(e,n=ve){let t=fr(e),{join:i}=qe(n),r=[],o=f=>{f&&!r.some(c=>c.path===f.path&&c.index===f.index)&&r.push(f)};if(n.platform==="win32"||n.platform==="darwin"){let f=n.platform==="win32"?or:sr,c=n.platform==="win32"?cr(n):lr(n);for(let[d,h]of f[t]??f.other??[])for(let p of c){let b=i(p,d);if(n.exists(b)){o({path:b,index:h});break}}return r}let s=ar[t];if(s)for(let f of await Gt(`:lang=${s}`,n))o(f);else if(e.codePoint!==void 0)for(let f of await Gt(`:charset=${e.codePoint.toString(16)}`,n))o(f);for(let[f,c]of zt[t]??zt.other??[])for(let d of ur(n)){let h=Vt(d,f,n);if(h){o({path:h,index:c});break}}return r}var Wt=new WeakMap;function Yt(e,n=ve){let t=Wt.get(n)??new Map;Wt.set(n,t);let i=`${e.path}#${e.index}`,r=qe(n).basename(e.path).replace(/\.[^.]+$/,""),o=t.get(i);if(o!==void 0)return o===null?void 0:{font:o,ref:e,name:r};try{let s=n.read(e.path);if(!s)throw new Error("unreadable");let f=Ne(s,Math.min(e.index,Math.max(0,Bt(s)-1)));return t.set(i,f),{font:f,ref:e,name:r}}catch{t.set(i,null);return}}var Zt=595.28,Me=841.89,re=72,me=Zt-2*re,Ze=Me-2*re,Z={size:11,leading:16,after:8},br={size:20,leading:26,before:0,after:6},xr={size:15,leading:20,before:18,after:6},yr=4,wr=24,L={size:10,leading:14,padX:6,padY:3},Sr=12,Ue=.114,Ar=.78,kr=.95,Xt={regular:"NotoSans-Regular.ttf.gz",bold:"NotoSans-Bold.ttf.gz"};function Pr(e){return[be(e,"fonts"),be(e,"..","fonts"),be(e,"..","..","assets","fonts")]}var Le;function Er(){if(Le)return Le;let e=Pr(hr(pr(import.meta.url))).find(t=>dr(be(t,Xt.regular)));if(e===void 0)throw new Error("the PDF fonts are missing from this install");let n=t=>Ne(mr(gr(be(e,Xt[t]))));return Le={regular:n("regular"),bold:n("bold")},Le}var ie=class{constructor(n,t,i,r,o){this.font=n;this.resource=t;this.name=i;this.synthetic=r;this.isBold=o}font;resource;name;synthetic;isBold;used=new Map;widths=new Map;advance(n){let t=this.widths.get(n);return t===void 0&&(t=this.font.advance(n)/this.font.unitsPerEm,this.widths.set(n,t)),t}code(n,t){let i=this.font.codeOf(n);return this.used.has(i)||this.used.set(i,{gid:n,text:t}),i}},et=class{fonts=[];picks=new Map;count=0;missing=new Set;notdef;constructor(n){let t={regular:new ie(n.regular,this.next(),"NotoSans-Regular",!1,!1),bold:new ie(n.bold,this.next(),"NotoSans-Bold",!1,!0)};this.fonts.push(t),this.notdef=t}next(){return`F${++this.count}`}get primary(){return this.notdef.regular.font}all(){return this.fonts.flatMap(n=>[n.regular,n.bold])}add(n,t){this.fonts.push({regular:new ie(t,this.next(),n,!1,!1),bold:new ie(t,this.next(),n,!0,!0)}),this.picks.clear()}get fontCount(){return this.fonts.length}has(n){return this.fonts.some(t=>t.regular.font.glyphOf(n)!==void 0)}pick(n,t){let i=this.picks.get(n);if(i===void 0){i=null;for(let o=0;o<this.fonts.length;o++){let s=this.fonts[o]?.regular.font.glyphOf(n);if(s!==void 0){i=[o,s];break}}this.picks.set(n,i)}if(i===null)return this.missing.add(te(n)??"other"),{pf:t?this.notdef.bold:this.notdef.regular,gid:0};let r=this.fonts[i[0]];return{pf:(t?r?.bold:r?.regular)??this.notdef.regular,gid:i[1]}}width(n,t,i){let r=0;for(let o of n){let{pf:s,gid:f}=this.pick(o.codePointAt(0)??0,i);r+=s.advance(f)}return r*t}runs(n,t){let i=[];for(let r of n){let o=r.codePointAt(0)??0,{pf:s,gid:f}=this.pick(o,t),c=f===0?"\uFFFD":o>=64336&&o<=65279?Mt(o):r,d=s.code(f,c).toString(16).padStart(4,"0"),h=i.at(-1);h&&h.pf===s?(h.hex+=d,h.width+=s.advance(f)):i.push({pf:s,hex:d,width:s.advance(f)})}return i}},Tr=/[\u00AD\u200B\u200E\u200F\u2028\u2029\u202A-\u202E\u2060\u2066-\u2069\uFEFF]/g,Rr=/[\t\u00A0\u2000-\u200A\u202F\u205F\u3000]/g,Fr=/[^\P{Cc}\n]/gu;function Qt(e){return e.replace(Rr," ").replace(Tr,"").replace(Fr,"").normalize("NFC")}function Nr(e,n){let t=Qt(e);Ut(t)&&(t=Lt(t,n)),t=t.replace(/[\u200C\u200D]/g,"");let i=[];for(let r of t){let o=r.codePointAt(0)??0;if(r===`
26
+ `||n(o)){i.push(r);continue}let s=r.normalize("NFKD").replace(new RegExp("\\p{M}","gu"),"");i.push(s!==""&&[...s].every(f=>n(f.codePointAt(0)??0))?s:r)}return i.join("")}var vr=new Set(["han","kana","hangul"]),Ur=new Set([12289,12290,65292,65294,65306,65307,65281,65311,65289,65341,65373,12309,12297,12299,12301,12303,12305,12313,12311,12319,8217,8221,8252,12540,12293,12539,8230,8229,37,12445,12446,12541,12542].map(e=>String.fromCodePoint(e))),Lr=new Set([65288,65339,65371,12308,12296,12298,12300,12302,12304,12312,12310,12317,8216,8220].map(e=>String.fromCodePoint(e)));function Qe(e,n,t,i,r){let o=[],s=f=>n.width(f,i,t);for(let f of e.split(`
27
+ `)){let c="",d=0,h=s(" ");for(let p of f.split(" ").filter(Boolean)){let b=s(p),a=[...p].some(u=>vr.has(te(u.codePointAt(0)??0)));if(b>r||a&&c!==""&&d+h+b>r){c!==""&&(d+h+s([...p][0]??"")<=r?(c+=" ",d+=h):(o.push(c),c="",d=0));for(let u of p){let l=s(u),g=[...c].at(-1),m=Ur.has(u)&&d+l<=r*1.15;d+l>r&&c!==""&&!m&&(g!==void 0&&Lr.has(g)?(o.push([...c].slice(0,-1).join("")),c=g,d=s(g)):(o.push(c),c="",d=0)),c+=u,d+=l}}else c===""?(c=p,d=b):d+h+b<=r?(c+=` ${p}`,d+=h+b):(o.push(c),c=p,d=b)}o.push(c)}return o}var _=e=>(Math.round(e*100)/100).toString(),tt=class{constructor(n){this.chain=n}chain;pages=[];ops=[];y=0;owed=0;get remaining(){return Ze-this.y}get atTop(){return this.y===0}newPage(){this.ops=[`${_(Ue)} g ${_(Ue)} G`],this.pages.push(this.ops),this.y=0,this.owed=0}gap(n){this.y>0&&(this.y+=Math.max(this.owed,n)),this.owed=0}bottom(n){this.owed=n}advance(n){this.y+=n}text(n,t,i,r,o,s,f){if(s==="")return;let{primary:c}=this.chain,d=(c.ascent-c.descent)*t/c.unitsPerEm,h=o+(i-d)/2+c.ascent*t/c.unitsPerEm,p=this.chain.runs(bt(s,f),n),b=p.reduce((l,g)=>l+g.width,0)*t,a=re+(f?r.left+r.width-b:r.left),u=_(Me-re-h);for(let l of p){let g=l.pf.synthetic?`2 Tr ${_(t*.035)} w `:"",m=l.pf.synthetic?" 0 Tr":"";this.ops.push(`BT /${l.pf.resource} ${_(t)} Tf ${g}${_(a)} ${u} Td <${l.hex}> Tj${m} ET`),a+=l.width*t}}rect(n,t,i,r,o){let s=`${_(re+n)} ${_(Me-re-t-r)} ${_(i)} ${_(r)} re`;o==="fill"?this.ops.push(`${_(kr)} g ${s} f ${_(Ue)} g`):this.ops.push(`${_(Ar)} G 0.5 w ${s} S ${_(Ue)} G`)}lines(n,t,i,r,o,s){let f=pe(o),c=s?.indent??0,d={left:f?r.left:r.left+c,width:r.width-c};Qe(o,this.chain,n,t,d.width).forEach((h,p)=>{if(this.remaining<i&&this.newPage(),p===0&&s!==void 0){let b=this.chain.width(s.text,t,n),a=f?{left:r.left+r.width-b,width:b}:{left:d.left-b,width:b};this.text(n,t,i,a,this.y,s.text,!1)}this.text(n,t,i,d,this.y,h,f),this.advance(i)})}heading(n,t){let i=n===1?br:xr,r=Qe(t,this.chain,!0,i.size,me);this.gap(i.before),this.remaining<r.length*i.leading+i.after+2*Z.leading&&this.newPage(),this.lines(!0,i.size,i.leading,{left:0,width:me},t),this.bottom(i.after)}paragraph(n){this.gap(0),this.lines(!1,Z.size,Z.leading,{left:0,width:me},n),this.bottom(Z.after)}list(n,t){this.gap(0),t.forEach((i,r)=>{r>0&&this.advance(yr);let o=n?`${r+1}. `:"\u2022 ";this.lines(!1,Z.size,Z.leading,{left:0,width:me},i,{text:o,indent:wr})}),this.bottom(Z.after)}table(n){if(n.length===0)return;this.gap(0);let t=Math.max(...n.map(a=>a.length)),i=L.padX*2,r=Array(t).fill(0),o=Array(t).fill(0);for(let[a,u]of n.entries()){let l=a===0;for(let g=0;g<t;g++){let m=u[g]??"";r[g]=Math.max(r[g]??0,this.chain.width(m.replace(/\n/g," "),L.size,l)+i);let S=Math.max(0,...m.split(/\s+/).map(A=>Math.min(this.chain.width(A,L.size,l),L.size*3)));o[g]=Math.max(o[g]??0,S+i)}}let s=Mr(r,o,me),f=s.map((a,u)=>s.slice(0,u).reduce((l,g)=>l+g,0)),c=a=>s.map((u,l)=>Qe(n[a]?.[l]??"",this.chain,a===0,L.size,u-i)),d=c(0),h=Math.max(...d.map(a=>a.length))*L.leading+2*L.padY,p=(a,u,l,g)=>{let m=g*L.leading+2*L.padY;for(let S=0;S<t;S++){let A=f[S]??0,w=s[S]??0;a===0&&this.rect(A,this.y,w,m,"fill"),this.rect(A,this.y,w,m,"stroke");let x=n[a]?.[S]??"",E=pe(x);(u[S]??[]).slice(l,l+g).forEach((T,R)=>{this.text(a===0,L.size,L.leading,{left:A+L.padX,width:w-i},this.y+L.padY+R*L.leading,T,E)})}this.advance(m)},b=a=>{this.newPage(),a>0&&h<Ze/2&&p(0,d,0,Math.max(...d.map(u=>u.length)))};for(let a=0;a<n.length;a++){let u=a===0?d:c(a),l=Math.max(...u.map(m=>m.length)),g=0;for(;g<l;){let m=Math.floor((this.remaining-2*L.padY)/L.leading),S=(l-g)*L.leading+2*L.padY;if(m<1||m<l-g&&!this.atTop&&S<=Ze-h){b(a);continue}let A=Math.min(l-g,m);p(a,u,g,A),g+=A,g<l&&b(a)}}this.bottom(Sr)}};function Mr(e,n,t){let i=e.reduce((s,f)=>s+f,0);if(i<=t)return e.map(s=>s*t/i);let r=n.reduce((s,f)=>s+f,0);if(r>=t)return n.map(s=>s*t/r);let o=(t-r)/(i-r);return e.map((s,f)=>(n[f]??0)+(s-(n[f]??0))*o)}function Ir(e){return e.flatMap(n=>n.flatMap(t=>t.kind==="heading"||t.kind==="paragraph"?[t.text]:t.kind==="list"?t.items:t.rows.flat()))}var qt=8;async function Dr(e,n,t,i){let r=new Map;for(let f of new Set(n)){let c=f.codePointAt(0)??0;if(c<128||f===`
28
+ `||e.has(c)||c>=64336&&c<=65279)continue;let d=te(c)??"other";if(d!=="other"&&d!=="symbols"&&d!=="emoji"&&!Pt.has(d)){e.missing.add(d);continue}r.set(d,[...r.get(d)??[],c])}let o=Je(n,t),s=0;for(let[f,c]of r){let d=c,h={script:f,lang:o,codePoint:c[0]??0},p=[],b=a=>{let u=d.filter(l=>a.font.glyphOf(l)!==void 0);u.length!==0&&(e.add(a.name,a.font),s++,d=d.filter(l=>!u.includes(l)))};for(let a of await Jt(h,i)){if(d.length===0||s>=qt)break;let u=Yt(a,i);u&&(u.font.variable?p.push(u):b(u))}for(let a of p){if(d.length===0||s>=qt)break;b(a)}}}async function nt(e,n){let{PDFDocument:t,PDFName:i,PDFString:r}=await lt(),o=new et(Er()),s=Ir(e).map(Qt).join(`
29
+ `);await Dr(o,s,n.lang,n.fonts??ve);let f=new tt(o),c=l=>Nr(l,g=>o.has(g)),d=l=>{l.kind==="heading"?f.heading(l.level,c(l.text)):l.kind==="paragraph"?f.paragraph(c(l.text)):l.kind==="list"?f.list(l.ordered,l.items.map(c)):f.table(l.rows.map(g=>g.map(c)))};for(let l of e.filter(g=>g.length>0)){f.newPage();for(let g of l)d(g)}f.pages.length===0&&f.newPage();let h=await t.create({updateMetadata:!1});h.setTitle(n.title),h.setProducer("Forge"),h.setCreator("Forge");let{context:p}=h,b=new Map,a=new Map,u=0;for(let l of o.all()){if(l.used.size===0)continue;let g=p.nextRef();b.set(l,g);let{font:m}=l,S=[...l.used.keys()].sort((C,M)=>C-M),A=S.map(C=>l.used.get(C)?.gid??0),w=l.synthetic?a.get(m):void 0,x=1e3/m.unitsPerEm,E=`F${String.fromCharCode(65+(u>>8)%26,65+(u>>4)%26,65+(u>>2)%26,65+u%26,65+u*7%26)}`;u++;let T=`${E}+${l.name.replace(/[^A-Za-z0-9-]/g,"")}`,{data:R,cidToGid:I}=m.subset(A),D=m.outlines==="cff",K=p.register(D?p.flateStream(R,{Subtype:"CIDFontType0C"}):p.flateStream(R,{Length1:R.length})),Q=p.register(p.obj({Type:"FontDescriptor",FontName:T,Flags:4,FontBBox:m.bbox.map(C=>Math.round(C*x)),ItalicAngle:0,Ascent:Math.round(m.ascent*x),Descent:Math.round(m.descent*x),CapHeight:Math.round(m.capHeight*x),StemV:l.isBold?140:80,...D?{FontFile3:K}:{FontFile2:K}})),k=S.flatMap((C,M)=>[C,[Math.round(m.advance(A[M]??0)*x)]]),P=I?p.register(p.flateStream(new Uint8Array(new Uint16Array(Or(I)).buffer))):void 0,z=p.register(p.obj({Type:"Font",Subtype:D?"CIDFontType0":"CIDFontType2",BaseFont:T,CIDSystemInfo:p.obj({Registry:r.of("Adobe"),Ordering:r.of("Identity"),Supplement:0}),FontDescriptor:Q,DW:0,W:k,...D?{}:{CIDToGIDMap:P??"Identity"}})),U=p.register(p.flateStream($r(l.used)));p.assign(g,p.obj({Type:"Font",Subtype:"Type0",BaseFont:T,Encoding:"Identity-H",DescendantFonts:[z],ToUnicode:U})),l.synthetic||a.set(m,l)}for(let l of f.pages){let g=h.addPage([Zt,Me]);for(let[m,S]of b)g.node.setFontDictionary(i.of(m.resource),S);g.node.set(i.of("Contents"),p.register(p.flateStream(l.join(`
30
+ `))))}return o.missing.size>0&&n.onMissing?.([...o.missing].map(Cr)),Buffer.from(await h.save())}var Cr=e=>e==="other"?"symbols":Et(e);function Or(e){let n=new Uint16Array(e.length);for(let t=0;t<e.length;t++)n[t]=((e[t]??0)&255)<<8|(e[t]??0)>>8;return n}function $r(e){let n=[...e].sort(([o],[s])=>o-s),t=o=>o.toString(16).padStart(4,"0"),i=o=>[...o].flatMap(s=>{let f=s.codePointAt(0)??65533;if(f<65536)return[t(f)];let c=f-65536;return[t(55296+(c>>10)),t(56320+(c&1023))]}).join(""),r=[];for(let o=0;o<n.length;o+=100){let s=n.slice(o,o+100);r.push(`${s.length} beginbfchar
31
+ ${s.map(([f,c])=>`<${t(f)}> <${i(c.text)}>`).join(`
32
+ `)}
33
+ endbfchar`)}return["/CIDInit /ProcessSet findresource begin","12 dict begin","begincmap","/CIDSystemInfo << /Registry (Adobe) /Ordering (UCS) /Supplement 0 >> def","/CMapName /Adobe-Identity-UCS def","/CMapType 2 def",`1 begincodespacerange
34
+ <0000> <FFFF>
35
+ endcodespacerange`,...r,"endcmap","CMapName currentdict /CMap defineresource pop","end","end"].join(`
36
+ `)}var De="forge-transcribe",rt="forge-transcribe-whisper.mjs",Br=["darwin","win32","linux"];function zr(e=process.platform,n=["whisper"]){let t=n.includes("whisper")||!n.includes("ffmpeg"),i=n.includes("ffmpeg"),r=[t&&"the whisper extension (forge extensions add whisper, or /extensions)",i&&(e==="darwin"?"ffmpeg (brew install ffmpeg)":e==="win32"?"ffmpeg (winget install ffmpeg)":"ffmpeg on your PATH")].filter(Boolean);return e==="darwin"?`Transcribe on this Mac needs ${r.join(" and ")}.`:e==="win32"?`Transcribe on Windows needs ${r.join(" and ")}.`:e==="linux"?`Transcribe on Linux needs ${r.join(" and ")}.`:"Transcribe needs macOS, Windows or Linux."}function Zi(e=process.platform,n=e==="darwin"?"off":"unsupported"){return n==="off"?"Summary and notes need Apple Intelligence, and it is off.":`Summary and notes need Apple Intelligence, which this ${je(e)} does not have.`}function Gr(e){return{apple:[O(e,"helpers",De),O(e,"..","helpers",De),O(e,"..","..","dist","helpers",De)],whisper:[O(e,"helpers",rt),O(e,"..","helpers",rt),O(e,"..","..","helpers","transcribe",rt)]}}function xe(e=process.platform,n=process.env){let t=n.FORGE_TRANSCRIBE_HELPER;if(t!==void 0)return Ie(t)?t.endsWith(".mjs")?{whisper:t}:{apple:t}:{};if(!Br.includes(e))return{};let i=Gr(on(Hr(import.meta.url))),r=e==="darwin"?i.apple.find(s=>Ie(s)):void 0,o=i.whisper.find(s=>Ie(s));return{...r?{apple:r}:{},...o?{whisper:o}:{}}}async function Wr(e){return e.apple!==void 0&&e.whisper===void 0?{path:e.apple,kind:"apple"}:e.apple!==void 0&&await e.appleHears(e.apple).catch(()=>!1)?{path:e.apple,kind:"apple"}:e.whisper===void 0?void 0:{path:e.whisper,kind:"whisper"}}var en=new Map;function ye(e,n={}){let{apple:t}=xe();if(t===void 0)return Promise.resolve(void 0);let i=`${t}\0${e??""}`,r=n.fresh?void 0:en.get(i);if(r)return r;let o=["status",...e?["--locale",e]:[]],s=oe({path:t,kind:"apple"},o,"").catch(()=>{});return en.set(i,s),s}var it;function Kr(){return process.env.FORGE_TRANSCRIBE_HELPER!==void 0&&(it=void 0),it??=Wr({...xe(),appleHears:async()=>(await ye())?.speech===!0}),it}function Vr(e){let{apple:n}=xe();if(n===void 0)throw e();return{path:n,kind:"apple"}}async function Jr(){let e={...process.env,FORGE_HELPER_STOP_ON_EOF:"1"};if(!e.FORGE_FFMPEG){let n=await He().catch(()=>{});n&&(e.FORGE_FFMPEG=n.ffmpeg)}if(!e.FORGE_WHISPER_CLI){let n=await he("whisper");n&&(e.FORGE_WHISPER_CLI=n.entry)}if(!e.FORGE_WHISPER_MODEL){let n=await he("whisper"),t=n&&O(on(n.entry),"model.bin");t&&Ie(t)&&(e.FORGE_WHISPER_MODEL=t)}return e}var Yr=5e3;async function oe(e,n,t,i={}){let{signal:r}=i;if(r?.aborted)throw r.reason??new Error("aborted");let o=e.kind==="whisper",s=o?await Jr():process.env;if(r?.aborted)throw r.reason??new Error("aborted");return new Promise((f,c)=>{let d=/\.[cm]?js$/.test(e.path),[h,p]=d?[process.execPath,[e.path,...n]]:[e.path,n],b=rn(h,p,{stdio:[o?"pipe":"ignore","pipe","ignore"],env:s,windowsHide:!0});b.stdin?.on("error",()=>{});let a,u=!1,l=m=>{u||(u=!0,r?.removeEventListener("abort",g),m())},g=()=>{o&&b.stdin?(b.stdin.end(),setTimeout(()=>b.kill("SIGKILL"),Yr).unref()):b.kill("SIGKILL"),l(()=>c(r?.reason??new Error("aborted")))};r?.addEventListener("abort",g,{once:!0}),jr({input:b.stdout}).on("line",m=>{let S;try{S=JSON.parse(m)}catch{return}"ok"in S?a=S:i.onLine?.(S)}),b.on("error",m=>l(()=>c(ge(t,m)))),b.on("close",()=>l(()=>{if(a===void 0)return c(ge(t,new Error(`${De} gave no result`)));if(a.ok===!0)return f(a);c(Xr(String(a.code??""),String(a.message??""),t,n,e.kind))}))})}function Xr(e,n,t,i,r){if(e==="no-sound")return $e(t);if(e==="unreadable")return Te(t,process.platform,r);if(e==="locale"){let o=i.indexOf("--locale");return ct(o>=0?i[o+1]??"this language":`this ${je()}'s language`,process.platform,r)}return e==="unsupported"||e==="runtime"?_e(n):ge(t,new Error(`${e}: ${n}`))}var qr=["whisper","ffmpeg"];async function Zr(e={}){let n=xe();if(n.apple===void 0&&n.whisper===void 0)return;let t=await ye(e.locale,{fresh:!0}),r={read:t?.read===!0||await he("read-text")!==void 0};if(t?.speech===!0)return{speech:!0,hears:"apple",locale:typeof t.locale=="string"?t.locale:null,notes:t.notes==="available"||t.notes==="off"?t.notes:"unsupported",...r};if(n.whisper===void 0)return t===void 0?void 0:{speech:!1,locale:null,notes:"unsupported",...r};let o=["status",...e.locale?["--locale",e.locale]:[]],s=await oe({path:n.whisper,kind:"whisper"},o,""),f=Array.isArray(s.missing)?qr.filter(c=>s.missing.includes(c)):[];return{speech:s.speech===!0,...s.speech===!0?{hears:"whisper"}:{},locale:typeof s.locale=="string"?s.locale:null,notes:"unsupported",...r,...f.length>0?{missing:f}:{}}}async function Qi(e=process.platform){return e!=="darwin"?!0:(await Zr().catch(()=>{}))?.hears!=="apple"}async function eo(e=process.platform){if(e!=="darwin")return{hears:!1,reads:!1};let n=await ye().catch(()=>{});return{hears:n?.speech===!0,reads:n?.read===!0}}async function sn(){let e=await Kr();if(e===void 0)throw _e(zr());return e}var Qr=new Set(["mp4","mov","m4a","mp3","wav","aiff"]);async function an(e,n){if(e.kind!=="apple")return;let{probe:t}=await import("./registry-E5PNQWOZ.js"),i=await t(n).catch(()=>{});if(i===void 0||i.kind!=="media"||Qr.has(i.format))return;let r=await He().catch(()=>{});return r?{tools:r}:void 0}async function ei(e,n,t){let i=await st(O(ft(),"forge-sound-")),r=()=>at(i,{recursive:!0,force:!0}),o=O(i,"sound.wav");try{return await new Promise((s,f)=>{let c=rn(n,["-nostdin","-v","error","-i",e,"-vn","-ac","1","-ar","16000","-c:a","pcm_s16le",o],{stdio:["ignore","ignore","pipe"],windowsHide:!0}),d="";c.stderr?.setEncoding("utf8").on("data",p=>{d+=p});let h=()=>c.kill("SIGKILL");t?.addEventListener("abort",h,{once:!0}),c.on("error",f),c.on("close",p=>{if(t?.removeEventListener("abort",h),t?.aborted)return f(t.reason??new Error("aborted"));p===0?s():f(ge(e,new Error(`ffmpeg: ${d.trim()}`)))})}),{path:o,cleanup:r}}catch(s){throw await r(),s}}async function to(e){let n=await sn(),t=await an(n,e);if(t){let{probeMedia:r}=await import("./ffmpeg-OIVMTPY7.js"),o=await r(e,t.tools).catch(()=>{});if(o===void 0)throw Te(e);if(o.audio===void 0)throw $e(e);return{seconds:o.duration}}let i=await oe(n,["probe",e],e);return{seconds:Number(i.seconds)}}async function no(e,n){let t=await sn(),i=await an(t,e),r=i?await ei(e,i.tools.ffmpeg,n.signal):void 0;try{return await ti(t,r?.path??e,e,n)}finally{await r?.cleanup()}}async function ti(e,n,t,i){let r=["run",n,...i.locale?["--locale",i.locale]:[],...i.notes?["--notes"]:[],...i.notes&&i.detail&&i.detail!==mt?["--detail",i.detail]:[]],o=await oe(e,r,t,{signal:i.signal,onLine:s=>{let f=ni(s);f&&i.onEvent?.(f)}});return{locale:String(o.locale),seconds:Number(o.seconds),segments:o.segments,...o.notes?{notes:o.notes}:{}}}function ni(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)}}async function ro(e,n={}){if((await ye())?.read!==!0)return ii(e,n);let t=["read",e,...n.language?["--language",n.language]:[]];return(await oe(Vr(Re),t,e,{signal:n.signal,onLine:r=>{r.event==="page"&&n.onEvent?.({kind:"page",page:Number(r.page),of:Number(r.of)})}})).pages??[]}var ri=200,tn=4e3;async function io(){return Re(await fn())}async function fn(){let{catalogEntry:e,assetFor:n}=await import("./catalog-FMHWWMUX.js"),t=e("read-text");return t!==void 0&&n(t)!==void 0}async function ii(e,n){let t=await he("read-text");if(t===void 0)throw Re(await fn());let[{probe:i},{decodedInput:r},{loadSharp:o},{runExtension:s}]=await Promise.all([import("./registry-E5PNQWOZ.js"),import("./decoded-SMEHAVCH.js"),import("./libs-EK64ACG3.js"),import("./run-WSETTQXP.js")]),f=await o(),c=await i(e),d=await st(O(ft(),"forge-read-")),h={width:tn,height:tn,fit:"inside",withoutEnlargement:!0};try{let p=[];if(c.kind==="document"&&c.format==="pdf"){let{openPdf:m}=await import("./pdfium-7HNCQ3K3.js"),S=await m(await ot(e));try{for(let A=0;A<c.pages;A++){let w=await S.getPage(A).render({scale:ri/72,render:"bitmap"}),x=O(d,`page-${A+1}.png`);await f(Buffer.from(w.data),{raw:{width:w.width,height:w.height,channels:4}}).flatten({background:"#ffffff"}).resize(h).png().toFile(x),p.push(x)}}finally{S.destroy()}}else if(c.kind==="image"){let m=O(d,"page-1.png");await f(await r(e,c.format)).rotate().flatten({background:"#ffffff"}).resize(h).png().toFile(m),p.push(m)}else throw Te(e);let a=(await s({id:"read-text",entry:t.entry,kind:t.kind},p.flatMap(m=>["--in",m]),{subject:e,what:`Reading the text of ${e}`,...n.signal?{signal:n.signal}:{},onLine:m=>{m.event==="page"&&n.onEvent?.({kind:"page",page:Number(m.page),of:Number(m.of)})}})).pages??[];if(!(c.kind==="document"&&c.format==="pdf"))return a;let[{extractPdfText:u},{mendPage:l}]=await Promise.all([import("./pdfium-7HNCQ3K3.js"),import("./text-layer-LHZNDMPZ.js")]),g=await u(await ot(e)).catch(()=>[]);return a.map((m,S)=>l(m,g[S]??""))}finally{await at(d,{recursive:!0,force:!0})}}async function cn(){let{apple:e}=xe();if(!(e===void 0||await ye()===void 0))return{path:e,kind:"apple"}}async function ln(e,n,t,i){let r=await st(O(ft(),"forge-render-"));try{let o=O(r,"transcript.html"),s=O(r,`transcript.${t}`);return await _r(o,n,"utf8"),await oe(e,["render",o,s,"--as",t],s,{signal:i.signal}),await ot(s)}finally{await at(r,{recursive:!0,force:!0})}}var nn=9026;async function un(e,n){let t=await ut(),{Document:i,Packer:r,Paragraph:o,TextRun:s,Table:f,TableRow:c,TableCell:d,HeadingLevel:h}=t,p="forge-numbers",b=0,a=(A,w=!1)=>Tt(A,n).map(x=>new s({text:x.text,...w?{bold:!0}:{},...x.kind==="eastAsia"?{font:{hint:"eastAsia"},language:x.lang?{eastAsia:x.lang}:{}}:{},...x.kind==="complex"?{font:{hint:"cs"},...x.rtl?{rightToLeft:!0}:{},...w?{boldComplexScript:!0}:{},...x.lang?{language:{bidirectional:x.lang}}:{}}:{}})),u=A=>pe(A)?{bidirectional:!0}:{},l=A=>A.flatMap(w=>{if(w.kind==="heading")return[new o({children:a(w.text),heading:w.level===1?h.HEADING_1:h.HEADING_2,...u(w.text)})];if(w.kind==="paragraph")return[new o({children:a(w.text),spacing:{after:160},...u(w.text)})];if(w.kind==="list"){let E=++b;return w.items.map(T=>w.ordered?new o({children:a(T),numbering:{reference:p,level:0,instance:E},...u(T)}):new o({children:a(T),bullet:{level:0},...u(T)}))}let x=w.rows[0]?.length??1;return[new f({width:{size:100,type:t.WidthType.PERCENTAGE},columnWidths:Array(x).fill(Math.floor(nn/x)),margins:{top:40,bottom:40,left:100,right:100},rows:w.rows.map((E,T)=>new c({tableHeader:T===0,children:E.map(R=>new d({width:{size:Math.floor(nn/x),type:t.WidthType.DXA},children:[new o({children:a(R,T===0),...u(R)})]}))}))}),new o({text:""})]}),m=e.filter(A=>A.length>0).flatMap((A,w)=>[...w>0?[new o({children:[new t.PageBreak]})]:[],...l(A)]),S=new i({numbering:{config:[{reference:p,levels:[{level:0,format:t.LevelFormat.DECIMAL,text:"%1.",alignment:t.AlignmentType.START}]}]},sections:[{children:m}]});return r.toBuffer(S)}var dn=e=>({...e.lang!==void 0?{lang:e.lang}:{},...e.onMissing!==void 0?{onMissing:e.onMissing}:{}});async function oo(e,n,t,i={}){if(n==="md")return Buffer.from(St(e),"utf8");if(n==="txt")return Buffer.from(At(e),"utf8");if(n==="docx")return un(e,i.lang);let r=await cn();return r?ln(r,kt(e,t),"pdf",i):nt(e,{title:t,...dn(i)})}function oi(e){for(let n of e.flat())if(n.kind==="heading"&&n.level===1)return n.text;return"Transcript"}async function so(e,n,t={}){if(n==="md")return Buffer.from(e,"utf8");if(n==="txt")return Buffer.from(dt(e),"utf8");let i=await cn();if(i)return ln(i,pt(e),n,t);let r=ht(e);return n==="docx"?un(r,t.lang):nt(r,{title:oi(r),...dn(t)})}export{ci as a,li as b,At as c,kt as d,zr as e,Zi as f,Gr as g,xe as h,Wr as i,Zr as j,Qi as k,eo as l,to as m,no as n,ro as o,io as p,oo as q,so as r};
@@ -1,6 +1,6 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{l as P}from"./chunk-X26WUHWB.js";import{c as k,e as I,f as $}from"./chunk-I25E2XDH.js";import{L as S,pa as E,ra as m,y as x}from"./chunk-WIPP5TWQ.js";var D=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com"]),M=/^[A-Za-z0-9_-]{11}$/,w=t=>t&&M.test(t)?{kind:"video",id:t,url:`https://www.youtube.com/watch?v=${t}`}:void 0;function Z(t){let r=t.trim();if(r==="")return;let e;try{e=new URL(/^[a-z]+:\/\//i.test(r)?r:`https://${r}`)}catch{return}let n=e.hostname.toLowerCase();if(n==="youtu.be")return w(e.pathname.slice(1).split("/")[0]);if(!D.has(n))return;let[s,o]=e.pathname.split("/").filter(Boolean);if(s==="watch")return w(e.searchParams.get("v"));if(s==="shorts"||s==="live")return w(o);if(s==="playlist"&&e.searchParams.get("list"))return{kind:"playlist"}}var R="Summary and notes by Apple Intelligence. They may contain mistakes.";function N(t){let r=Math.floor(t),e=o=>String(o).padStart(2,"0"),n=Math.floor(r/3600),s=Math.floor(r/60)%60;return n>0?`${n}:${e(s)}:${e(r%60)}`:`${s}:${e(r%60)}`}var L=t=>t.split(/\s+/).filter(Boolean).length,V=60,j=140,Y=1,W=10;function H(t){let r=[],e;for(let n of t){if(e){let s=n.start-e.end;if(!(s>W||s>Y&&e.words>=V||e.words>=j)){e.text+=` ${n.text}`,e.end=n.end,e.words+=L(n.text);continue}r.push({start:e.start,text:e.text})}e={start:n.start,end:n.end,text:n.text,words:L(n.text)}}return e&&r.push({start:e.start,text:e.text}),r}var T=t=>H(t).flatMap(r=>[`**${N(r.start)}** ${r.text}`,""]),B=t=>/^https?:\/\/\S+$/.test(t)?`<${t}>`:t;function Q(t,r,{transcript:e=!0}={}){let n=[`# ${r.title}`,"",B(r.from),""],s=t.notes;if(!s)return[...n,...T(t.segments)].join(`
3
+ import{l as P}from"./chunk-GT6U6HV3.js";import{c as k,e as I,f as $}from"./chunk-I25E2XDH.js";import{I as S,ma as E,oa as m,v as x}from"./chunk-CVNYUROW.js";var D=new Set(["youtube.com","www.youtube.com","m.youtube.com","music.youtube.com"]),M=/^[A-Za-z0-9_-]{11}$/,w=t=>t&&M.test(t)?{kind:"video",id:t,url:`https://www.youtube.com/watch?v=${t}`}:void 0;function Z(t){let r=t.trim();if(r==="")return;let e;try{e=new URL(/^[a-z]+:\/\//i.test(r)?r:`https://${r}`)}catch{return}let n=e.hostname.toLowerCase();if(n==="youtu.be")return w(e.pathname.slice(1).split("/")[0]);if(!D.has(n))return;let[s,o]=e.pathname.split("/").filter(Boolean);if(s==="watch")return w(e.searchParams.get("v"));if(s==="shorts"||s==="live")return w(o);if(s==="playlist"&&e.searchParams.get("list"))return{kind:"playlist"}}var R="Summary and notes by Apple Intelligence. They may contain mistakes.";function N(t){let r=Math.floor(t),e=o=>String(o).padStart(2,"0"),n=Math.floor(r/3600),s=Math.floor(r/60)%60;return n>0?`${n}:${e(s)}:${e(r%60)}`:`${s}:${e(r%60)}`}var L=t=>t.split(/\s+/).filter(Boolean).length,V=60,j=140,Y=1,W=10;function H(t){let r=[],e;for(let n of t){if(e){let s=n.start-e.end;if(!(s>W||s>Y&&e.words>=V||e.words>=j)){e.text+=` ${n.text}`,e.end=n.end,e.words+=L(n.text);continue}r.push({start:e.start,text:e.text})}e={start:n.start,end:n.end,text:n.text,words:L(n.text)}}return e&&r.push({start:e.start,text:e.text}),r}var T=t=>H(t).flatMap(r=>[`**${N(r.start)}** ${r.text}`,""]),B=t=>/^https?:\/\/\S+$/.test(t)?`<${t}>`:t;function Q(t,r,{transcript:e=!0}={}){let n=[`# ${r.title}`,"",B(r.from),""],s=t.notes;if(!s)return[...n,...T(t.segments)].join(`
4
4
  `);let o=s.parts,p=a=>{let d=o[a];return d?`### ${d.refused?`Part ${a+1}`:d.heading} \xB7 ${N(d.start)}`:""};n.push(s.summary,"","## Notes",""),o.forEach((a,d)=>{n.push(p(d),""),a.points.length>0&&n.push(...a.points.map(l=>`- ${l}`),"")});let c=[`_${R}_`,""];return e?(n.push("## Transcript",""),o.forEach((a,d)=>{let l=o[d+1]?.start??Number.POSITIVE_INFINITY,b=t.segments.filter(h=>h.start>=a.start&&h.start<l);n.push(p(d),"",...T(b))}),[...n,...c].join(`
5
5
  `)):[...n,...c].join(`
6
6
  `)}function tt(t){let r=[...t].map(e=>(e.codePointAt(0)??0)<32?" ":e).join("").replace(/[/\\:*?"<>|]/g,"-").replace(/\s+/g," ").trim().slice(0,120).replace(/^\.+/,"");return r===""?"transcript":r}function nt(t){if(t.kind!=="media"){if(t.kind==="image"){let{path:r,format:e,bytes:n,width:s,height:o}=t;return{what:"image",path:r,format:e,bytes:n,width:s,height:o}}if(t.format!=="pdf")throw E(t.path);if(t.encrypted)throw x(t.path);return{what:"pdf",path:t.path,bytes:t.bytes,pages:t.pages}}}import{spawn as _}from"node:child_process";import{mkdtemp as C,rm as K}from"node:fs/promises";import{tmpdir as U}from"node:os";import{join as A}from"node:path";import{createInterface as G}from"node:readline";var z=[[/private video/i,"This video is private."],[/confirm your age/i,"This video is age-restricted."],[/members-only|join this channel/i,"This video is for channel members only."],[/live event will begin|premieres in/i,"This video has not started yet."],[/unavailable|has been removed|does not exist/i,"This video is unavailable."]],g=class extends Error{};function J(t=process.platform,r=process.arch){let e=I("yt-dlp");return e!==void 0&&$(e,t,r)!==void 0?S("yt-dlp"):m(`YouTube links on ${k(t)} need yt-dlp on your PATH.`,void 0,{hint:"Install yt-dlp (https://github.com/yt-dlp/yt-dlp) and put it on your PATH.",shellHint:"Install yt-dlp and put it on your PATH."})}async function ft(t,r={}){let e=await P();if(e===void 0)throw J();let n=await C(A(U(),"forge-yt-"));r.onDir?.(n);let s=()=>K(n,{recursive:!0,force:!0});try{let o;try{o=await F(e.entry,t,n,r)}catch(p){if(!(p instanceof g))throw p;if(e.own)throw m(`yt-dlp could not fetch this video: ${p.message}`,p);await X(e.entry,r.signal);try{o=await F(e.entry,t,n,r)}catch(c){throw c instanceof g?m(`yt-dlp could not fetch this video: ${c.message}`,c):c}}return{...o,dispose:s}}catch(o){throw await s(),o}}function F(t,r,e,n){let{signal:s}=n;if(s?.aborted)return Promise.reject(s.reason??new Error("aborted"));let o=["--js-runtimes",`node:${process.execPath}`,"--no-playlist","--no-warnings","--newline","--progress","-f","bestaudio[ext=m4a]/bestaudio","--print","before_dl:forge-facts %(.{title,uploader,duration,is_live})j","--progress-template","download:forge-bytes %(progress.downloaded_bytes)s %(progress.total_bytes,progress.total_bytes_estimate)s","--print","after_move:forge-file %(filepath)s","--no-simulate","-o",A(e,"sound.%(ext)s"),r];return new Promise((p,c)=>{let a=_(t,o,{stdio:["ignore","pipe","pipe"]}),d,l,b="",h=!1,y=i=>{h||(h=!0,s?.removeEventListener("abort",v),i())},v=()=>{a.kill("SIGKILL"),y(()=>c(s?.reason??new Error("aborted")))};s?.addEventListener("abort",v,{once:!0}),G({input:a.stdout}).on("line",i=>{if(i.startsWith("forge-facts ")){let u=JSON.parse(i.slice(12));if(u.is_live===!0){a.kill("SIGKILL"),y(()=>c(m("Live streams cannot be transcribed.")));return}d={title:String(u.title??""),uploader:String(u.uploader??""),seconds:Number(u.duration??0)},n.onEvent?.({kind:"facts",facts:d})}else if(i.startsWith("forge-bytes ")){let[u,f]=i.slice(12).split(" ").map(Number);Number.isFinite(u)&&Number.isFinite(f)&&(f??0)>0&&n.onEvent?.({kind:"bytes",done:u,total:f})}else i.startsWith("forge-file ")&&(l=i.slice(11))}),a.stderr.on("data",i=>{b+=i.toString()}),a.on("error",i=>y(()=>c(new g(i.message)))),a.on("close",i=>y(()=>{if(i===0&&d!==void 0&&l!==void 0)return p({path:l,facts:d});let u=b.match(/ERROR: (?:\[[^\]]*\] )?(?:[\w-]+: )?(.*)/)?.[1]?.trim()??"",f=z.find(([O])=>O.test(u));c(f?m(f[1]):new g(u||`yt-dlp exited ${i}`))}))})}function X(t,r){return new Promise((e,n)=>{let s=_(t,["--update"],{stdio:"ignore"}),o=()=>s.kill("SIGKILL");r?.addEventListener("abort",o,{once:!0}),s.on("error",()=>e()),s.on("close",()=>{r?.removeEventListener("abort",o),r?.aborted?n(r.reason??new Error("aborted")):e()})})}export{Z as a,N as b,Q as c,tt as d,nt as e,J as f,ft as g};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{Q as a,R as u,S as l}from"./chunk-WIPP5TWQ.js";import{spawn as x}from"node:child_process";import{existsSync as c,realpathSync as b}from"node:fs";import{dirname as h,join as E,win32 as d}from"node:path";function f(n,t=process.platform,e=c){if(n===void 0)return!1;if(t==="win32"){let r=/^(.*)[\\/]node_modules[\\/]forge-terminal[\\/]/.exec(n)?.[1];return r!==void 0&&e(d.join(r,"forge.cmd"))}return/\/lib\/node_modules\/forge-terminal\//.test(n)&&!n.includes("/_npx/")}function m(n){if(n!==void 0)try{return b(n)}catch{return n}}function P(n,t=c){let e=E(h(n),"npm");return t(e)?e:"npm"}function R(n,t=c){let e=d.join(d.dirname(n),"node_modules","npm","bin","npm-cli.js");return t(e)?e:void 0}var g=(n,t,e)=>new Promise(r=>{let o="",s=x(n,t,{stdio:["ignore","pipe","pipe"],...e?{signal:e}:{}});s.stdout.setEncoding("utf8").on("data",i=>{o+=i}),s.stderr.setEncoding("utf8").on("data",i=>{o+=i}),s.on("error",i=>r({code:null,output:`${o}
3
+ import{N as a,O as u,P as l}from"./chunk-CVNYUROW.js";import{spawn as x}from"node:child_process";import{existsSync as c,realpathSync as b}from"node:fs";import{dirname as h,join as E,win32 as d}from"node:path";function f(n,t=process.platform,e=c){if(n===void 0)return!1;if(t==="win32"){let r=/^(.*)[\\/]node_modules[\\/]forge-terminal[\\/]/.exec(n)?.[1];return r!==void 0&&e(d.join(r,"forge.cmd"))}return/\/lib\/node_modules\/forge-terminal\//.test(n)&&!n.includes("/_npx/")}function m(n){if(n!==void 0)try{return b(n)}catch{return n}}function P(n,t=c){let e=E(h(n),"npm");return t(e)?e:"npm"}function R(n,t=c){let e=d.join(d.dirname(n),"node_modules","npm","bin","npm-cli.js");return t(e)?e:void 0}var g=(n,t,e)=>new Promise(r=>{let o="",s=x(n,t,{stdio:["ignore","pipe","pipe"],...e?{signal:e}:{}});s.stdout.setEncoding("utf8").on("data",i=>{o+=i}),s.stderr.setEncoding("utf8").on("data",i=>{o+=i}),s.on("error",i=>r({code:null,output:`${o}
4
4
  ${i.message}`})),s.on("close",i=>r({code:i,output:o}))});function w(n){return n.split(`
5
5
  `).map(e=>e.replace(/^npm (error|ERR!)\s*/,"").trim()).filter(e=>e!==""&&!/^(code|errno|syscall|path|dest|A complete log)/.test(e)).at(-1)??"npm exited without saying why"}async function _(n,t={}){let e=t.platform??process.platform;if(e==="win32")return S(n,t);let r=t.script??m(process.argv[1]);if(!f(r,e))throw a(n);let o=t.npm??P(process.execPath),s=t.run??g,{code:i,output:p}=await s(o,["install","--global",`forge-terminal@${n}`],t.signal);if(i!==0)throw/EACCES|EPERM|permission denied/i.test(p)?u(n,e):l(n,w(p))}async function S(n,t){let e=t.script??m(process.argv[1]);if(!f(e,"win32",t.exists))throw a(n);let r=R(process.execPath,t.exists);if(r===void 0)throw l(n,"npm was not found beside Node");let o=t.run??g,{code:s,output:i}=await o(process.execPath,[r,"install","--global",`forge-terminal@${n}`],t.signal);if(s!==0)throw/EACCES|EPERM|EBUSY|permission denied/i.test(i)?u(n,"win32"):l(n,w(i))}export{f as a,m as b,P as c,R as d,w as e,_ as f};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{l as S,m as U}from"./chunk-CVNYUROW.js";import{b as P}from"./chunk-KXKQDFHX.js";import{readFile as ve,stat as Ne}from"node:fs/promises";import{execFile as ie}from"node:child_process";import{randomBytes as oe}from"node:crypto";import{mkdtemp as ae,open as H,readFile as se,rm as D}from"node:fs/promises";import{tmpdir as J}from"node:os";import{join as B}from"node:path";import{promisify as ce}from"node:util";var v=ce(ie),z=async()=>({...await import("./paths-6OENILJ4.js"),...await import("./run-WSETTQXP.js")}),E,N=e=>e!=="darwin";async function _(e=process.platform){return N(e)?await(await z()).installed("heic")!==void 0:k()}async function k(){if(E!==void 0)return E;try{await v("/usr/bin/sips",["--help"],{timeout:5e3}),E=!0}catch{E=!1}return E}async function O(e,n=process.platform){if(N(n))return fe(e,n);let t=B(J(),`forge-heic-${oe(8).toString("hex")}.png`),i=async()=>{await D(t,{force:!0}).catch(()=>{})};try{return await v("/usr/bin/sips",["-s","format","png",e,"--out",t],{timeout:12e4}),{path:t,cleanup:i}}catch(r){throw await i(),r}}async function L(e,n){let{installed:t,runExtension:i}=await z(),r=await t("heic");if(r===void 0)throw S(e,n);return{ext:r,runExtension:i}}async function fe(e,n){let t=await ae(B(J(),"forge-heic-")),i=async()=>{await D(t,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:r,runExtension:o}=await L(e,n),a=B(t,"decoded.rgba"),f=B(t,"decoded.png"),{width:m,height:y}=await o(r,["--in",e,"--out",a],{subject:e});return await(await P())(await se(a),{raw:{width:m,height:y,channels:4}}).png().toFile(f),await D(a,{force:!0}),{path:f,cleanup:i}}catch(r){throw await i(),r}}var ue=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1"]),de=new Set(["avif","avis"]);async function $e(e){let n;try{n=await H(e,"r")}catch{return!1}try{let t=Buffer.alloc(64),{bytesRead:i}=await n.read(t,0,64,0);if(i<12||t.toString("latin1",4,8)!=="ftyp")return!1;let r=Math.min(t.readUInt32BE(0),i),o=[];for(let a=8;a+4<=r;a+=4)o.push(t.toString("latin1",a,a+4));return o.some(a=>de.has(a))?!1:o.some(a=>ue.has(a))}catch{return!1}finally{await n.close().catch(()=>{})}}async function qe(e,n=process.platform){if(N(n)){let{ext:a,runExtension:f}=await L(e,n),m=await f(a,["--info","--in",e],{subject:e});return{width:m.width,height:m.height,hasAlpha:m.hasAlpha??!0}}let{stdout:t}=await v("/usr/bin/sips",["-g","pixelWidth","-g","pixelHeight","-g","hasAlpha",e],{timeout:3e4}),i=Number(/pixelWidth:\s*(\d+)/.exec(t)?.[1]??0),r=Number(/pixelHeight:\s*(\d+)/.exec(t)?.[1]??0),o=await me(e);return{width:o?r:i,height:o?i:r,hasAlpha:/hasAlpha:\s*yes/i.test(t)}}function*x(e,n,t){let i=n;for(;i+8<=t;){let r=e.readUInt32BE(i),o=8;if(r===1&&i+16<=t?(r=Number(e.readBigUInt64BE(i+8)),o=16):r===0&&(r=t-i),r<o)return;yield{type:e.toString("latin1",i+4,i+8),start:i+o,end:Math.min(i+r,t)},i+=r}}async function me(e){let n=await H(e,"r");try{let t=Buffer.alloc(262144),{bytesRead:i}=await n.read(t,0,t.length,0),r=[...x(t,0,i)].find(l=>l.type==="meta");if(!r)return!1;let o=[...x(t,r.start+4,r.end)],a=o.find(l=>l.type==="pitm"),f=o.find(l=>l.type==="iprp");if(!a||!f)return!1;let m=t.readUInt8(a.start)===0?t.readUInt16BE(a.start+4):t.readUInt32BE(a.start+4),y=[...x(t,f.start,f.end)],s=y.find(l=>l.type==="ipco"),c=y.find(l=>l.type==="ipma");if(!s||!c)return!1;let u=new Map;if([...x(t,s.start,s.end)].forEach((l,b)=>{l.type==="irot"&&u.set(b+1,t.readUInt8(l.start)&3)}),u.size===0)return!1;let h=t.readUInt8(c.start),w=(t.readUInt8(c.start+3)&1)===1,d=c.start+4,p=t.readUInt32BE(d);d+=4;for(let l=0;l<p&&d<c.end;l++){let b=h<1?t.readUInt16BE(d):t.readUInt32BE(d);d+=h<1?2:4;let ne=t.readUInt8(d);d+=1;for(let C=0;C<ne;C++){let re=w?t.readUInt16BE(d)&32767:t.readUInt8(d)&127;if(d+=w?2:1,b===m&&(u.get(re)??0)%2===1)return!0}}return!1}catch{return!1}finally{await n.close().catch(()=>{})}}import{execFile as le}from"node:child_process";import{randomBytes as he}from"node:crypto";import{copyFile as we,mkdtemp as W,open as pe,readFile as ye,rm as R}from"node:fs/promises";import{tmpdir as A}from"node:os";import{extname as K,join as I}from"node:path";import{promisify as ge}from"node:util";var $=ge(le),q=async()=>({...await import("./paths-6OENILJ4.js"),...await import("./run-WSETTQXP.js")}),F=e=>e!=="darwin",xe={".nef":[".nef",".nrw"],".arw":[".arw",".srf",".sr2"],".rw2":[".rw2",".rwl"],".3fr":[".3fr",".fff"],".dcr":[".dcr",".kdc"]},be=[["nikon",".nef"],["sony",".arw"],["pentax",".pef"],["ricoh",".pef"],["samsung",".srw"],["hasselblad",".3fr"],["seiko epson",".erf"],["epson",".erf"],["kodak",".dcr"],["eastman kodak",".dcr"],["leaf",".mos"]],Ie=new Set([32803,34892]),Ee=new Set([32767,32769,32770,34316,34713,65e3,65535]),Se="85c0b687820f11e08111f4ce462b6a48";function j(e,n){let t=(s,c)=>n?s.readUInt16LE(c):s.readUInt16BE(c),i=(s,c)=>n?s.readUInt32LE(c):s.readUInt32BE(c),r={1:1,2:1,3:2,4:4,7:1,13:4};async function o(s){if(s<=0)return;let c=await e(s,2);if(c.length<2)return;let u=t(c,0);if(u===0||u>1e3)return;let h=await e(s+2,u*12+4);if(h.length<u*12+4)return;let w=new Map;for(let d=0;d<u;d++){let p=d*12;w.set(t(h,p),{type:t(h,p+2),count:i(h,p+4),inline:h.subarray(p+8,p+12),offset:i(h,p+8)})}return{entries:w,next:i(h,u*12)}}async function a(s,c=16){if(!s)return[];let u=r[s.type]===2?2:4,h=Math.min(s.count,c),w=h*u<=4?s.inline:await e(s.offset,h*u),d=[];for(let p=0;p<h&&(p+1)*u<=w.length;p++)d.push(u===2?t(w,p*u):i(w,p*u));return d}async function f(s){if(s?.type!==2)return"";let c=Math.min(s.count,64);return(c<=4?s.inline.subarray(0,c):await e(s.offset,c)).toString("latin1").replace(/\0.*$/s,"").trim()}async function m(s){let[c]=await a(s.entries.get(274),1);return c!==void 0&&c>=1&&c<=8?c:1}async function y(s){let c=[s],u=new Set;for(let h=0;c.length>0&&h<12;h++){let w=c.shift(),[d]=await a(w.entries.get(262),1),[p]=await a(w.entries.get(259),1);if(d!==void 0&&Ie.has(d)||p!==void 0&&Ee.has(p))return!0;for(let l of[...await a(w.entries.get(330),8),w.next]){if(l===0||u.has(l))continue;u.add(l);let b=await o(l);b&&c.push(b)}}return!1}return{directory:o,text:f,orientation:m,hasMosaic:y,u32:i}}function V(e){let n=e.toString("latin1",0,2);return n==="II"?!0:n==="MM"?!1:void 0}async function Y(e,n){let t=V(e.subarray(n,n+2));if(t===void 0)return 1;let r=j(async(a,f)=>e.subarray(n+a,n+a+f),t),o=await r.directory(r.u32(e,n+4));return o?r.orientation(o):1}async function Pe(e){if(e[0]!==255||e[1]!==216)return 1;let n=2;for(;n+4<=e.length&&e[n]===255;){let t=e[n+1],i=e.readUInt16BE(n+2);if(t===225&&e.toString("latin1",n+4,n+10)==="Exif\0\0")return Y(e,n+10);if(t===218)break;n+=2+i}return 1}async function Be(e,n){let t=await e(0,Math.min(n,1048576)),i=[...x(t,0,t.length)].find(r=>r.type==="moov");if(!i)return 1;for(let r of x(t,i.start,i.end)){if(r.type!=="uuid"||t.toString("hex",r.start,r.start+16)!==Se)continue;let o=[...x(t,r.start+16,r.end)].find(a=>a.type==="CMT1");return o?Y(t,o.start):1}return 1}async function Re(e,n){if(n.length<92)return 1;let t=n.readUInt32BE(84),i=n.readUInt32BE(88);return t===0||i===0?1:Pe(await e(t,Math.min(i,65536)))}async function Me(e){let n;try{n=await pe(e,"r")}catch{return}try{let{size:t}=await n.stat(),i=async(u,h)=>{let w=Math.max(0,Math.min(h,t-u)),d=Buffer.alloc(w);return w>0&&await n.read(d,0,w,u),d},r=await i(0,96);if(r.length<16)return;let o=r.toString("latin1",0,4);if(r.toString("latin1",0,15)==="FUJIFILMCCD-RAW")return{ext:".raf",orientation:await Re(i,r)};if(r.toString("latin1",4,12)==="ftypcrx ")return{ext:".cr3",orientation:await Be(i,t)};let a=V(r);if(a===void 0)return;let f=j(i,a),m=await f.directory(f.u32(r,4));if(!m)return;let y=await f.orientation(m);if(o==="IIRO"||o==="IIRS"||o==="MMOR")return{ext:".orf",orientation:y};if(o==="IIU\0")return{ext:".rw2",orientation:y};if(o!=="II*\0"&&o!=="MM\0*")return;if(m.entries.has(50706))return{ext:".dng",orientation:y};if(r.toString("latin1",8,11)==="CR")return{ext:".cr2",orientation:y};let s=(await f.text(m.entries.get(271))).toLowerCase(),c=be.find(([u])=>s.startsWith(u));return!c||!await f.hasMosaic(m)?void 0:{ext:c[1],orientation:y}}catch{return}finally{await n.close().catch(()=>{})}}async function Ue(e=process.platform){return F(e)?await(await q()).installed("raw")!==void 0:k()}async function Z(e,n){let{installed:t,runExtension:i}=await q(),r=await t("raw");if(r===void 0)throw U(e,n);return{ext:r,runExtension:i}}async function G(e,n,t){let i=K(e).toLowerCase();if((xe[n.ext]??[n.ext]).includes(i))return t(e);let r=await W(I(A(),"forge-raw-"));try{let o=I(r,`photo${n.ext}`);return await we(e,o),await t(o)}finally{await R(r,{recursive:!0,force:!0}).catch(()=>{})}}async function rt(e,n,t=process.platform){if(F(t)){let{ext:a,runExtension:f}=await Z(e,t),m=await f(a,["--info","--in",e],{subject:e,platform:t});if(!(m.width>0&&m.height>0))throw new Error("the raw extension reported no size");return{width:m.width,height:m.height}}let{stdout:i}=await G(e,n,a=>$("/usr/bin/sips",["-g","typeIdentifier","-g","pixelWidth","-g","pixelHeight",a],{timeout:3e4}));if(!/typeIdentifier:\s*\S*raw-image/.test(i))return;let r=Number(/pixelWidth:\s*(\d+)/.exec(i)?.[1]??0),o=Number(/pixelHeight:\s*(\d+)/.exec(i)?.[1]??0);if(!(r===0||o===0))return n.orientation>=5?{width:o,height:r}:{width:r,height:o}}async function Q(e,n=process.platform){if(F(n))return De(e,n);if(!await Ue(n))throw U(e,n);let t=await Me(e)??{ext:K(e).toLowerCase(),orientation:1},i=I(A(),`forge-raw-${he(8).toString("hex")}.png`),r=async()=>{await R(i,{force:!0}).catch(()=>{})};try{return await G(e,t,o=>$("/usr/bin/sips",["-s","format","png",o,"--out",i],{timeout:3e5})),{path:i,cleanup:r}}catch(o){throw await r(),o}}async function De(e,n){let t=await W(I(A(),"forge-raw-")),i=async()=>{await R(t,{recursive:!0,force:!0}).catch(()=>{})};try{let{ext:r,runExtension:o}=await Z(e,n),a=I(t,"decoded.rgb"),f=I(t,"decoded.png"),{width:m,height:y}=await o(r,["--in",e,"--out",a],{subject:e,platform:n});return await(await P())(await ye(a),{raw:{width:m,height:y,channels:3}}).png().toFile(f),await R(a,{force:!0}),{path:f,cleanup:i}}catch(r){throw await i(),r}}async function ft(e,n){return n!=="heic"&&n!=="raw"?e:Fe(e,n)}var ke=4,X=256*1024*1024,T=X,ee=6e4,te=ee,M;function Ae(){clearTimeout(M),M=setTimeout(()=>g.clear(),te),M.unref?.()}var g=new Map;async function Fe(e,n){let{size:t,mtimeMs:i}=await Ne(e);Ae();let r=`${n}\0${e}`,o=g.get(r);if(g.delete(r),o&&o.size===t&&o.mtimeMs===i)return g.set(r,o),o.png;let a={size:t,mtimeMs:i,png:Ce(e,n),bytes:0};return g.set(r,a),a.png.then(f=>{a.bytes=f.length,f.length>T&&g.get(r)===a&&g.delete(r),Te()},()=>{g.get(r)===a&&g.delete(r)}),a.png}function Te(){let e=0;for(let n of g.values())e+=n.bytes;for(let[n,t]of g){if(g.size<=ke&&e<=T)break;g.delete(n),e-=t.bytes}}async function Ce(e,n){if(n==="heic"&&!await _())throw S(e);let t=n==="heic"?await O(e):await Q(e);try{return await ve(t.path)}finally{await t.cleanup()}}function ut(){g.clear(),clearTimeout(M)}function dt(e){te=e??ee}function mt(e){T=e??X}export{_ as a,$e as b,qe as c,Me as d,Ue as e,rt as f,ft as g,ut as h,dt as i,mt as j};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{D as E,E as l,F as S}from"./chunk-WIPP5TWQ.js";import{c as x}from"./chunk-H3DIRJFE.js";import{existsSync as h,statSync as w}from"node:fs";import{basename as f,dirname as T,extname as g,isAbsolute as _,join as c,relative as M,resolve as i,sep as D}from"node:path";function $(t){return t.endsWith("/")||t.endsWith(D)||h(t)&&w(t).isDirectory()?!0:g(t)===""}var O=255;function P(t,r){return r==="darwin"||r==="win32"?t.length:Buffer.byteLength(t)}function a(t,r,n=process.platform){if(P(t+r,n)<=O)return t+r;let e="";for(let s of t){if(P(e+s+r,n)>O)break;e+=s}return e+r}function nt(t,r){if(i(t)===i(r))return!0;try{let n=w(t),e=w(r);return n.dev===e.dev&&n.ino===e.ino}catch{return!1}}function L(t,r){let n=f(t),e=g(n),s=e?n.slice(0,-e.length):n;return a(s,x(r))}function b(t,r,n){if(!n)return t;let e=M(i(n),r);return!e||e.startsWith("..")?t:c(t,e)}function F(t){let r=i(t.sourcePath),n=L(r,t.target);if(!t.output)return c(i(r,".."),n);let e=_(t.output)?t.output:i(t.output);return $(t.output)?c(b(e,i(r,".."),t.sourceRoot),n):i(e)}function et(t){let r=F(t);if(t.output&&!$(t.output))return r;let n=g(r);return c(i(r,".."),a(f(r,n),`-${t.suffix}${n}`))}function it(t){if(!h(t))return t;let r=i(t,".."),n=f(t),e=g(n),s=e?n.slice(0,-e.length):n;for(let o=1;o<1e4;o++){let u=c(r,a(s,` (${o})${e}`));if(!h(u))return u}throw new Error(`no free name beside ${n}`)}function p(t){let r=i(t,".."),n=f(t),e=g(n);return{dir:r,stem:e?n.slice(0,-e.length):n,ext:e||".pdf"}}function A(t,r){let{dir:n,stem:e,ext:s}=p(i(t));return c(n,a(e,`-${r}${s}`))}function st(t,r){let{dir:n,stem:e,ext:s}=p(i(t)),o=String(r).length;return Array.from({length:r},(u,m)=>c(n,a(e,`-${String(m+1).padStart(o,"0")}${s}`)))}function ot(t,r,n,e,s){let{stem:o}=p(i(t)),u=e?b(i(e),i(t,".."),s):i(t,".."),m=x(n),I=String(Math.max(1,...r.map(d=>d+1))).length,W=r.map(d=>c(u,a(o,`-${String(d+1).padStart(I,"0")}${m}`))),[y,...R]=W;if(y===void 0)throw new Error("rasterOutputPaths requires at least one selected page");return[y,...R]}function ut(t,r,n){if(!n)return[A(t,"extract")];let{dir:e,stem:s,ext:o}=p(i(t));return r.map(u=>c(e,a(s,`-p${u+1}${o}`)))}function ct(t){let r=i(t[0]??"merged.pdf");if(new Set(t.map(e=>i(e,".."))).size===1){let e=i(r,"..");return c(e,a(f(e),"-merged.pdf"))}return A(r,"merged")}function k(t,r,n){let e=r?t.map(o=>c(r,f(o))):t,[s]=e;return!n||e.length!==1||s===void 0?e:[c(T(s),`${n}${g(s)}`)]}function at(t,r,n){return k([t],r,n)[0]??t}import{randomBytes as B}from"node:crypto";import{constants as J}from"node:fs";import{access as j,mkdir as C,rename as N,rm as U,writeFile as Y}from"node:fs/promises";import{basename as z,dirname as v,extname as G,join as K}from"node:path";function H(t,r=B(6).toString("hex")){let n=G(t);return K(v(t),a(`.forge-${r}-${z(t,n)}`,n))}async function Q(t){let r=v(t);try{await C(r,{recursive:!0})}catch(n){let e=l(t,n);throw e===n?S(t,n):e}try{await j(r,J.W_OK)}catch(n){throw E(t,n)}}var V=new Set(["EPERM","EBUSY","EACCES"]),X=5,ht=9;async function Z(t,r,n=process.platform,e=o=>new Promise(u=>setTimeout(u,o)),s=X){if(n!=="win32"){await N(t,r);return}for(let o=1;;o++)try{await N(t,r);return}catch(u){let m=u.code;if(o>=s||!m||!V.has(m))throw u;await e(Math.min(50*2**(o-1),1e3))}}async function wt(t,r){await Q(t);let n=H(t);try{return await Y(n,r),await Z(n,t),r.byteLength}catch(e){throw await U(n,{force:!0}).catch(()=>{}),l(t,e)}}export{$ as a,a as b,nt as c,F as d,et as e,it as f,A as g,st as h,ot as i,ut as j,ct as k,k as l,at as m,H as n,Q as o,ht as p,Z as q,wt as r};
3
+ import{A as E,B as l,C as S}from"./chunk-CVNYUROW.js";import{c as x}from"./chunk-H3DIRJFE.js";import{existsSync as h,statSync as w}from"node:fs";import{basename as f,dirname as T,extname as g,isAbsolute as _,join as c,relative as M,resolve as i,sep as D}from"node:path";function $(t){return t.endsWith("/")||t.endsWith(D)||h(t)&&w(t).isDirectory()?!0:g(t)===""}var O=255;function P(t,r){return r==="darwin"||r==="win32"?t.length:Buffer.byteLength(t)}function a(t,r,n=process.platform){if(P(t+r,n)<=O)return t+r;let e="";for(let s of t){if(P(e+s+r,n)>O)break;e+=s}return e+r}function nt(t,r){if(i(t)===i(r))return!0;try{let n=w(t),e=w(r);return n.dev===e.dev&&n.ino===e.ino}catch{return!1}}function L(t,r){let n=f(t),e=g(n),s=e?n.slice(0,-e.length):n;return a(s,x(r))}function b(t,r,n){if(!n)return t;let e=M(i(n),r);return!e||e.startsWith("..")?t:c(t,e)}function F(t){let r=i(t.sourcePath),n=L(r,t.target);if(!t.output)return c(i(r,".."),n);let e=_(t.output)?t.output:i(t.output);return $(t.output)?c(b(e,i(r,".."),t.sourceRoot),n):i(e)}function et(t){let r=F(t);if(t.output&&!$(t.output))return r;let n=g(r);return c(i(r,".."),a(f(r,n),`-${t.suffix}${n}`))}function it(t){if(!h(t))return t;let r=i(t,".."),n=f(t),e=g(n),s=e?n.slice(0,-e.length):n;for(let o=1;o<1e4;o++){let u=c(r,a(s,` (${o})${e}`));if(!h(u))return u}throw new Error(`no free name beside ${n}`)}function p(t){let r=i(t,".."),n=f(t),e=g(n);return{dir:r,stem:e?n.slice(0,-e.length):n,ext:e||".pdf"}}function A(t,r){let{dir:n,stem:e,ext:s}=p(i(t));return c(n,a(e,`-${r}${s}`))}function st(t,r){let{dir:n,stem:e,ext:s}=p(i(t)),o=String(r).length;return Array.from({length:r},(u,m)=>c(n,a(e,`-${String(m+1).padStart(o,"0")}${s}`)))}function ot(t,r,n,e,s){let{stem:o}=p(i(t)),u=e?b(i(e),i(t,".."),s):i(t,".."),m=x(n),I=String(Math.max(1,...r.map(d=>d+1))).length,W=r.map(d=>c(u,a(o,`-${String(d+1).padStart(I,"0")}${m}`))),[y,...R]=W;if(y===void 0)throw new Error("rasterOutputPaths requires at least one selected page");return[y,...R]}function ut(t,r,n){if(!n)return[A(t,"extract")];let{dir:e,stem:s,ext:o}=p(i(t));return r.map(u=>c(e,a(s,`-p${u+1}${o}`)))}function ct(t){let r=i(t[0]??"merged.pdf");if(new Set(t.map(e=>i(e,".."))).size===1){let e=i(r,"..");return c(e,a(f(e),"-merged.pdf"))}return A(r,"merged")}function k(t,r,n){let e=r?t.map(o=>c(r,f(o))):t,[s]=e;return!n||e.length!==1||s===void 0?e:[c(T(s),`${n}${g(s)}`)]}function at(t,r,n){return k([t],r,n)[0]??t}import{randomBytes as B}from"node:crypto";import{constants as J}from"node:fs";import{access as j,mkdir as C,rename as N,rm as U,writeFile as Y}from"node:fs/promises";import{basename as z,dirname as v,extname as G,join as K}from"node:path";function H(t,r=B(6).toString("hex")){let n=G(t);return K(v(t),a(`.forge-${r}-${z(t,n)}`,n))}async function Q(t){let r=v(t);try{await C(r,{recursive:!0})}catch(n){let e=l(t,n);throw e===n?S(t,n):e}try{await j(r,J.W_OK)}catch(n){throw E(t,n)}}var V=new Set(["EPERM","EBUSY","EACCES"]),X=5,ht=9;async function Z(t,r,n=process.platform,e=o=>new Promise(u=>setTimeout(u,o)),s=X){if(n!=="win32"){await N(t,r);return}for(let o=1;;o++)try{await N(t,r);return}catch(u){let m=u.code;if(o>=s||!m||!V.has(m))throw u;await e(Math.min(50*2**(o-1),1e3))}}async function wt(t,r){await Q(t);let n=H(t);try{return await Y(n,r),await Z(n,t),r.byteLength}catch(e){throw await U(n,{force:!0}).catch(()=>{}),l(t,e)}}export{$ as a,a as b,nt as c,F as d,et as e,it as f,A as g,st as h,ot as i,ut as j,ct as k,k as l,at as m,H as n,Q as o,ht as p,Z as q,wt as r};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{e as a}from"./chunk-THDAQBQ3.js";import{a as t}from"./chunk-H3DIRJFE.js";var p=[{op:"compress",label:"Compress"},{op:"resize",label:"Resize"},{op:"crop",label:"Crop to shape"},{op:"trim",label:"Trim edges"},{op:"format",label:"Convert to another format"},{op:"sharpen",label:"Sharpen"},{op:"boost",label:"Boost resolution"},{op:"cutout",label:"Remove background"}],n=r=>t[r]?.label??r.toUpperCase(),i=r=>`under ${Math.round(r/1e3)} KB`,u=r=>"width"in r?`${r.width} wide`:"height"in r?`${r.height} high`:`${r.percent}%`;function l(r,e){let o={...r};switch(e.op){case"compress":return"quality"in e?(delete o.maxBytes,o.quality=e.quality,o.compress=r.compress??{dither:!1}):o.maxBytes=e.bytes,o;case"resize":return o.resize=e.spec,o;case"crop":return o.crop=e.aspect,o;case"trim":return o.trim=!0,o;case"format":return o.to=e.to,e.quality===void 0?delete o.quality:o.quality=e.quality,o;case"sharpen":return o.sharpen=!0,o;case"boost":return o.boost=e.scale,o;case"cutout":return o.removeBackground=!0,o}}function d(r){switch(r.op){case"compress":return"quality"in r?`quality ${r.quality}`:i(r.bytes);case"resize":return u(r.spec);case"crop":return`${r.aspect.w}:${r.aspect.h}`;case"trim":return"Trim";case"format":return`${n(r.to)}${r.quality===void 0?"":` ${r.quality}`}`;case"sharpen":return"Sharpen";case"boost":return`Boost ${r.scale}\xD7`;case"cutout":return"Remove background"}}function b(r,e){return[...!(e.to===void 0||e.to===r)&&e.to?[`${n(e.to)}${e.quality===void 0?"":` ${e.quality}`}`]:e.quality!==void 0?[`quality ${e.quality}`]:[],...e.resize?[u(e.resize)]:[],...e.trim?["Trim"]:[],...e.crop?[`${e.crop.w}:${e.crop.h}`]:[],...e.sharpen&&!e.boost?["Sharpen"]:[],...e.boost?[`Boost ${e.boost}\xD7`]:[],...e.removeBackground?["Remove background"]:[],...e.maxBytes?[i(e.maxBytes)]:[]]}function h(r,e){if(r.frames>1)return{trim:"animated",crop:"animated"};let o={};return e?.trimmed==="nothing"&&(o.trim="no empty edges"),a(r).length===0&&(o.crop="no shape to cut"),o}export{p as a,l as b,d as c,b as d,h as e};
3
+ import{e as a}from"./chunk-J6AZTW62.js";import{a as t}from"./chunk-H3DIRJFE.js";var p=[{op:"compress",label:"Compress"},{op:"resize",label:"Resize"},{op:"crop",label:"Crop to shape"},{op:"trim",label:"Trim edges"},{op:"format",label:"Convert to another format"},{op:"sharpen",label:"Sharpen"},{op:"boost",label:"Boost resolution"},{op:"cutout",label:"Remove background"}],n=r=>t[r]?.label??r.toUpperCase(),i=r=>`under ${Math.round(r/1e3)} KB`,u=r=>"width"in r?`${r.width} wide`:"height"in r?`${r.height} high`:`${r.percent}%`;function l(r,e){let o={...r};switch(e.op){case"compress":return"quality"in e?(delete o.maxBytes,o.quality=e.quality,o.compress=r.compress??{dither:!1}):o.maxBytes=e.bytes,o;case"resize":return o.resize=e.spec,o;case"crop":return o.crop=e.aspect,o;case"trim":return o.trim=!0,o;case"format":return o.to=e.to,e.quality===void 0?delete o.quality:o.quality=e.quality,o;case"sharpen":return o.sharpen=!0,o;case"boost":return o.boost=e.scale,o;case"cutout":return o.removeBackground=!0,o}}function d(r){switch(r.op){case"compress":return"quality"in r?`quality ${r.quality}`:i(r.bytes);case"resize":return u(r.spec);case"crop":return`${r.aspect.w}:${r.aspect.h}`;case"trim":return"Trim";case"format":return`${n(r.to)}${r.quality===void 0?"":` ${r.quality}`}`;case"sharpen":return"Sharpen";case"boost":return`Boost ${r.scale}\xD7`;case"cutout":return"Remove background"}}function b(r,e){return[...!(e.to===void 0||e.to===r)&&e.to?[`${n(e.to)}${e.quality===void 0?"":` ${e.quality}`}`]:e.quality!==void 0?[`quality ${e.quality}`]:[],...e.resize?[u(e.resize)]:[],...e.trim?["Trim"]:[],...e.crop?[`${e.crop.w}:${e.crop.h}`]:[],...e.sharpen&&!e.boost?["Sharpen"]:[],...e.boost?[`Boost ${e.boost}\xD7`]:[],...e.removeBackground?["Remove background"]:[],...e.maxBytes?[i(e.maxBytes)]:[]]}function h(r,e){if(r.frames>1)return{trim:"animated",crop:"animated"};let o={};return e?.trimmed==="nothing"&&(o.trim="no empty edges"),a(r).length===0&&(o.crop="no shape to cut"),o}export{p as a,l as b,d as c,b as d,h as e};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as s}from"./chunk-J7FLFHQJ.js";import{c as r}from"./chunk-VLVNA4T3.js";import{a}from"./chunk-H3DIRJFE.js";import{dirname as f}from"node:path";var o=class extends Error{code;title;detail;short;hint;shellHint;constructor(t){super(`${t.title}: ${t.detail}`,t.cause===void 0?void 0:{cause:t.cause}),this.name="ForgeError",this.code=t.code,this.title=t.title,this.detail=t.detail,this.short=t.short,this.hint=t.hint,this.shellHint=t.shellHint}};function m(e){return e instanceof o}function v(e){return new o({code:"file-not-found",title:"File not found",detail:`${r(e)} could not be found.`,short:`${r(e)} could not be found.`,hint:"Check the filename and try again."})}function k(e){return new o({code:"not-a-file",title:"Not a file",detail:`${r(e)} is not a file.`,short:`${r(e)} is not a file.`,hint:"Point Forge at an image, or at a directory of images."})}function C(e){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(e)} could not be read.`,short:`${r(e)} could not be read.`,hint:"Check the file permissions and try again."})}function S(e){return new o({code:"not-a-directory",title:"Invalid path",detail:`${r(e)} could not be found: part of its path is not a directory.`,short:`part of ${r(e)}'s path is not a folder.`,hint:"Check the path and try again."})}function T(e){return new o({code:"symlink-loop",title:"Too many symbolic links",detail:`${r(e)} could not be resolved: its path contains a symbolic-link loop.`,short:`${r(e)}'s path loops back on itself.`,hint:"Check for a circular symlink somewhere in the path."})}function I(e){return new o({code:"path-too-long",title:"Path too long",detail:`${r(e)}'s path is too long for the filesystem to resolve.`,short:`${r(e)}'s path is too long.`,hint:"Use a shorter path and try again."})}function N(e,t){return new o({code:"unreadable-path",title:"Could not read path",detail:`${r(e)} could not be checked.`,short:`${r(e)} could not be checked.`,hint:"Check the path and try again.",cause:t})}function P(e,t){return new o({code:"unsupported-source",title:"Unsupported file type",detail:`${r(e)} is ${t}, which Forge cannot read.`,short:`${r(e)} is ${t}, which Forge cannot read.`,hint:"Forge 0.1 handles images only."})}function H(e,t){return new o({code:"unsupported-source",title:"Not an image",detail:`${r(e)} is ${t}, not an image.`,hint:"A palette is taken from a photo, a screenshot or artwork."})}function O(e){return new o({code:"unsupported-source",title:"Nothing to take colours from",detail:`${r(e)} has no visible pixels.`})}function R(e,t=process.platform){if(t!=="darwin"){let n=t==="win32"?"Windows":t==="linux"?"Linux":"this system";return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e,t)} is a HEIC photo, which needs Forge's free HEIC extension on ${n}.`,short:"HEIC needs the heic extension.",hint:"Install it with: forge extensions add heic",shellHint:"Open /extensions to install it."})}return new o({code:"heic-decoder-unavailable",title:"Cannot read HEIC here",detail:`${r(e)} is a HEIC photo, which Forge decodes with the macOS sips tool.`,short:"HEIC needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function A(e,t=process.platform){if(t!=="darwin"){let n=t==="win32"?"Windows":t==="linux"?"Linux":"this system";return new o({code:"raw-decoder-unavailable",title:"Cannot read RAW here",detail:`${r(e,t)} is a camera RAW photo, which needs Forge's free RAW extension on ${n}.`,short:"RAW needs the raw extension.",hint:"Install it with: forge extensions add raw",shellHint:"Open /extensions to install it."})}return new o({code:"raw-decoder-unavailable",title:"Cannot read RAW here",detail:`${r(e,t)} is a camera RAW photo, which Forge reads with macOS's own RAW support.`,short:"RAW needs sips, which could not be run.",hint:"sips could not be run. It ships with macOS at /usr/bin/sips."})}function U(e){return new o({code:"raw-decoder-unavailable",title:"Cannot read this RAW",detail:`${r(e)} is a camera RAW photo that this Mac cannot read.`,short:"macOS cannot read RAW photos from this camera.",hint:"A newer camera usually needs a newer macOS."})}function W(e,t){let n=r(e.path);if(t!==void 0&&t!==e.format){let i=a[t].label;return a[t].lossy?new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`Forge cannot search ${n} \u2192 ${i} toward a size yet.`,hint:"Convert it first, then compress the result with --max-size.",shellHint:"Convert it first, then /compress the result to a size."}):new o({code:"unsupported-compress",title:"Cannot fit that to a size",detail:`${i} is lossless \u2014 there is no quality to trade away, so ${n} cannot be made to fit as ${i}.`,hint:"Drop --max-size, or choose a lossy target. forge --formats lists them.",shellHint:"Choose a lossy target to aim for a size."})}if(e.kind==="document"&&e.format==="pdf"){let i=e.images?.skipped??0;return new o({code:"unsupported-compress",title:"Nothing to compress",detail:i>0?`${n}'s images are a kind Forge cannot re-encode, so there is nothing to make smaller.`:`${n} has no images \u2014 it is text and layout, which compression cannot shrink.`,hint:"Try a page operation such as --extract to keep fewer pages, or --to <format> to turn its pages into images.",shellHint:"Try /pdf to keep fewer pages, or /convert to turn its pages into images."})}return e.kind==="document"?new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${a[e.format].label}, which has no images Forge can re-encode.`,hint:`Use --to pdf to change it to PDF instead: forge ${n} --to pdf`,shellHint:"Use /convert to change it to PDF instead."}):new o({code:"unsupported-compress",title:"Nothing to compress",detail:`${n} is ${a[e.format].label}, which is lossless \u2014 there is no quality to trade away.`,hint:"Use --to to change it to a smaller format instead. forge --formats lists them.",shellHint:"Use /convert to change it to a smaller format instead."})}function D(e){let t=r(e.path);return new o({code:"unsupported-pdf",title:"/pdf needs a PDF",detail:`${t} is ${a[e.format].label}, not a PDF.`,hint:"Converting it instead."})}function M(e,t,n){return new o({code:"unsupported-operation",title:`Cannot ${e} these files`,detail:`Not available for these files: ${t}.`,hint:n??"Page operations work on PDFs: --merge takes two or more, the others take one.",shellHint:n??"Use /pdf with a PDF staged \u2014 two or more for merge."})}function J(e,t,n){let i=e.kind==="media"?`The smallest ${r(e.path)} can get is ${s(n)}, which is still over ${s(t)}.`:`${r(e.path)} is ${s(n)} even at the lowest quality, which is still over ${s(t)}.`;return new o({code:"target-unreachable",title:"Cannot get that small",detail:i,hint:"Try a larger --max-size, or --to a smaller format.",shellHint:"Try a larger target, or /convert to a smaller format."})}function j(e,t,n){return new o({code:"unsupported-target",title:`Can't convert ${r(e.path)} to ${t}`,detail:`${r(e.path)} is a ${a[e.format].label} ${e.kind==="image"?"image":"document"}.`,hint:`Available: ${n.join(", ")}`})}function z(e,t){return new o({code:"corrupt-source",title:"Damaged file",detail:`${r(e)} could not be read. It may be damaged, or not a format Forge recognises.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:t})}function L(e,t,n){return new o({code:"corrupt-source",title:`Damaged ${a[t].label}`,detail:`${r(e)} is a ${a[t].label} file, but its content could not be read.`,short:`${r(e)} could not be read.`,hint:"The file may be incomplete or corrupted.",cause:n})}function q(e,t={}){let n=r(e);return new o({code:"encrypted-source",title:"This PDF is password-protected",detail:`${n} is password-protected.`,short:`${n} is password-protected.`,hint:t.attempted?"That password didn't open it. Check it and try again.":`Convert it to images instead: forge ${n} --to jpeg --password-stdin`})}var c=e=>e==="convert"||e==="boost"||e==="remove-background";function Y(e,t="convert"){return new o({code:"output-exists",title:"File already exists",detail:`${r(e)} is already there.`,hint:c(t)?"Pass --force to replace it, or choose a different --output.":"Pass --force to replace it, or move the existing file out of the way.",shellHint:"Run it again and Forge will ask before replacing it."})}function V(e,t){return new o({code:"output-collision",title:"Two files want the same output",detail:`${r(e[0])} and ${r(e[1])} would both become ${r(t)}.`,hint:"Convert them separately, or use --output to send them to different folders.",shellHint:"Convert them one at a time."})}function _(e,t){return new o({code:"output-collision",title:"One output, written twice",detail:`${r(e)} would write ${r(t)} twice, and only the second would survive.`,hint:"Every output has to be its own file. Check the selection for a repeated page."})}function X(e,t="convert"){return new o({code:"output-is-input",title:"Output would replace the original",detail:`${r(e)} is both the input and the output.`,hint:c(t)?"Choose a different --output, or pass --force to overwrite in place.":"Move or rename that file first, or pass --force to overwrite it in place.",shellHint:c(t)?"Choose a different folder to save it in.":"Move or rename that file first."})}function w(e,t){return new o({code:"permission-denied",title:"Permission denied",detail:`${r(f(e))} is not a folder you can write to.`,hint:"Choose a different --output, or check the folder permissions.",shellHint:"Choose a different folder, or check its permissions.",cause:t})}var b=new Set(["EACCES","EPERM","EROFS"]);function B(e,t){if(m(t))return t;let n=t?.code;return n!==void 0&&b.has(n)?w(e,t):t}function G(e,t){return new o({code:"output-invalid",title:"Cannot write there",detail:`${e} could not be written to.`,hint:"Check that the path is valid and that you have permission to write to it.",cause:t})}function K(e){return new o({code:"empty-directory",title:"No images found",detail:`${r(e)} contains no images Forge can convert.`,hint:"Try --recursive to look inside subfolders.",shellHint:"Only files directly inside a folder are read \u2014 drop the files themselves, or the folder that holds them."})}function Q(e,t){return new o({code:"invalid-arguments",title:"Invalid arguments",detail:e,hint:t})}function Z(e,t,n){return new o({code:"invalid-page-range",title:"Page range not understood",detail:t,hint:`This document has ${n} pages. Use numbers and spans, like "3-7, 12, 20-".`})}function ee(e){return new o({code:"empty-selection",title:"Nothing to write",detail:e,hint:"Select at least one page to keep."})}function te(e){return new o({code:"invalid-dpi",title:"Invalid resolution",detail:`${String(e)} is not a resolution Forge can use.`,hint:"Give a number between 36 and 600. The default is 150."})}function oe(e){return new o({code:"extension-missing",title:"Extension not installed",detail:`${e} is an optional extension and is not installed.`,hint:`Install it with: forge extensions add ${e}`,shellHint:"Open /extensions to install it."})}function ne(e,t,n,i){return new o({code:"extension-outdated",title:"Extension out of date",detail:`${e} ${n} cannot ${t}; that needs ${i} or later.`,hint:`Update it with: forge extensions add ${e}`,shellHint:"Open /extensions to update it."})}function re(e,t){return new o({code:"extension-corrupt",title:"Extension failed verification",detail:`${e}: ${t}`,hint:`Nothing was installed. Try again with: forge extensions add ${e}`,shellHint:"Nothing was installed. Try again from /extensions."})}function ie(e,t,n=process.platform){let i=n==="win32"?"PC":n==="darwin"?"Mac":"computer";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} cannot be installed on this ${i}: ${t}`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function ae(e,t=process.platform){let n=t==="win32"?"Windows":t==="darwin"?"macOS":t==="linux"?"Linux":"this system";return new o({code:"extension-unsupported",title:"Extension not available here",detail:`${e} is not available on ${n}.`,hint:"See what is available with: forge extensions",shellHint:"See what is available in /extensions."})}function se(e){return new o({code:"update-unavailable",title:"Cannot update this Forge",detail:`This copy of Forge was not installed with npm i -g, so ${e} cannot be installed over it.`,hint:"npm i -g forge-terminal"})}function le(e,t=process.platform){return t==="win32"?new o({code:"update-denied",title:"Forge is in use",detail:`npm could not replace Forge's files to update it to ${e}. Windows keeps them locked while Forge runs: close every Forge window, then run the command below. If Node is installed for every user, run it in a terminal opened as administrator.`,short:"Windows locks Forge while it runs: close it, then run this",hint:`npm i -g forge-terminal@${e}`}):new o({code:"update-denied",title:"npm needs permission",detail:`npm needs permission to update Forge to ${e}.`,short:"npm needs permission to update Forge",hint:`sudo npm i -g forge-terminal@${e}`})}function de(e,t){return new o({code:"update-failed",title:"Update failed",detail:`npm could not install Forge ${e}: ${t}`,short:"npm could not install the update",hint:`npm i -g forge-terminal@${e}`})}function ue(){return new o({code:"update-unreachable",title:"Could not check for updates",detail:"The npm registry could not be reached.",short:"could not reach npm",hint:"Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge update",shellHint:"Check your connection, then try again."})}function ce(e,t){return new o({code:"extension-download-failed",title:"Download failed",detail:`${e}: ${t}`,hint:`Check your connection (and HTTPS_PROXY if you use a proxy), then run: forge extensions add ${e}`,shellHint:"Check your connection, then try again from /extensions."})}function pe(e,t){return new o({code:"extension-download-failed",title:"Not enough disk space",detail:`${e}: ${t}`,hint:`Free some disk space, then run: forge extensions add ${e}`,shellHint:"Free some disk space, then try again from /extensions."})}function he(e,t,n){let i=t?t.what?`${t.what} (forge, pid ${t.pid})`:`another forge (pid ${t.pid}) is using it`:"another forge is using it";return new o({code:"extension-in-use",title:"Extension in use",detail:`${e} is in use: ${i}.`,hint:n==="remove"?`Wait for that job to finish, then run: forge extensions remove ${e}`:"Wait for that job to finish, then try again.",shellHint:n==="remove"?"It can be removed when that job finishes.":"Try again when that job finishes."})}function ge(e){return new o({code:"no-subject",title:"No subject found",detail:`${r(e)} has no clear subject to cut out.`,hint:"Try a photo where the subject stands apart from the background."})}function fe(e,t,n){return n===1?new o({code:"boost-too-large",title:"Too large to sharpen",detail:`${r(e)} is too large to sharpen.`,hint:"Sharpen works on images up to 16,384 px a side and 100 megapixels."}):new o({code:"boost-too-large",title:"Too large to boost",detail:t>=2?`${r(e)} is too large to boost that far; ${t}x is the most it can take.`:`${r(e)} is already too large to boost.`,hint:t>=2?`Try --boost ${t}.`:"Boost works on images up to 100 megapixels.",shellHint:t>=2?`Choose ${t}x instead.`:void 0})}function me(e,t,n,i=process.platform){let l=n===1?"sharpen":"boost",d=i==="win32"?"PC":i==="darwin"?"Mac":"computer",u=Math.max(1,Math.round(t/60));return new o({code:"boost-too-slow",title:`Too slow to ${l}`,detail:`${r(e)} would take about ${u} ${u===1?"minute":"minutes"} to ${l} on this ${d}.`,hint:"Try a smaller photo."})}function we(e,t){return new o({code:"resize-too-large",title:"Too large to resize to",detail:`${r(e)} would be ${t.width} \xD7 ${t.height}.`,hint:"Resize works up to 16,384 px a side and 100 megapixels."})}var x={darwin:"\u2303\u21E7\u23184",win32:"Win+Shift+S"};function be(e,t=process.platform){let n=x[t];return new o({code:"no-clipboard-image",title:"No image",detail:e==="text"?"The clipboard holds text, not a picture.":"The clipboard is empty.",hint:n===void 0?"Copy a picture or a screenshot, then run forge clip again.":`Copy a picture, or take a screenshot with ${n}, then run forge clip again.`})}function xe(e=process.platform){return new o({code:"clipboard-unavailable",title:"No clipboard",detail:e==="linux"?"Forge reads the clipboard of a Wayland or X11 desktop, and not over SSH.":"Forge reads the clipboard on macOS, Windows and Linux, and not over SSH."})}function $e(e){return new o({code:"clipboard-tool-missing",title:`Clipboard needs ${e}`,detail:`Forge reaches the clipboard through ${e}, and it is not on this computer.`,short:`${e} is not on this computer`,hint:`Install it with sudo apt install ${e} (or your distribution's package manager), then try again.`})}function Fe(){return new o({code:"nothing-to-undo",title:"Nothing to undo",detail:"No copied image has been changed yet."})}function ye(e,t,n,i=!1){let l=r(e);if(i)return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} is no smaller even at the lowest quality, so nothing was written.`,short:"nothing written"});let d=n>t?`would grow from ${s(t)} to ${s(n)}`:`would stay at ${s(t)}`;return new o({code:"cannot-compress-more",title:"Cannot compress more",detail:`${l} ${d}, so nothing was written.`,short:"nothing written",hint:"Try a lower --quality.",shellHint:"Try a lower quality."})}function Ee(e,t,n){return new o({code:"cannot-compress-more",title:"Already small enough",detail:`${r(e)} is ${s(t)}, already under ${s(n)}, so nothing was written.`,short:"already under that size"})}function ve(e){return new o({code:"nothing-to-trim",title:"Nothing to trim",detail:`${r(e)} has no empty edges.`,short:"no empty edges"})}function ke(e){return new o({code:"animated-trim",title:"Can't trim an animation",detail:`${r(e)} is animated; trimming works on still images.`})}function Ce(e,t){return new o({code:"nothing-to-crop",title:"Nothing to crop",detail:`${r(e)} is already ${t}.`,short:`already ${t}`})}function Se(e){return new o({code:"animated-crop",title:"Can't crop an animation",detail:`${r(e)} is animated; cropping works on still images.`})}function Te(e){return new o({code:"animated-rotate",title:"Can't rotate an animation",detail:`${r(e)} is animated; rotating works on still images.`})}function Ie(e,t=process.platform,n=!1){let i=p(t),l=n?`forge extensions add video (or ${i})`:t==="linux"?`${i} (or your distribution's package manager)`:i;return new o({code:"ffmpeg-missing",title:"Video and audio need ffmpeg",detail:`${r(e)} is a video or audio file, and ffmpeg is not on this computer.`,short:"ffmpeg is not on this computer",hint:`Install it with ${l}, then run Forge again.`})}function Ne(e,t,n=process.platform){let i=a[e].label,l=/^[AEFHILMNORSX]/.test(t.codec)?"an":"a",d=t.encoders,u=d.length>1?`${d.slice(0,-1).join(", ")} or ${d.at(-1)}`:d[0]??"",h=d.length>1?"any of them":"it",g=n==="linux"?"Install a full build of ffmpeg, then run Forge again. On Fedora, RPM Fusion's ffmpeg replaces ffmpeg-free.":n==="win32"?`Install a full build of ffmpeg, such as gyan.dev's (${p(n)}), then run Forge again.`:`Install a full build of ffmpeg (${p(n)}), then run Forge again.`;return new o({code:"encoder-missing",title:`Your ffmpeg can't write ${i}`,detail:`${i} needs ${l} ${t.codec} encoder${t.sound?" for its sound":""}: ${u}. Your ffmpeg was built without ${h}.`,short:`Your ffmpeg has no ${t.codec} encoder`,hint:g})}function p(e=process.platform){return e==="win32"?"winget install ffmpeg":e==="linux"?"sudo apt install ffmpeg":"brew install ffmpeg"}function Pe(e,t){return new o({code:"conversion-failed",title:"Conversion failed",detail:`${r(e)} could not be converted.`,hint:"Run again with --debug for the underlying error.",shellHint:"Run the same conversion with forge --debug from the command line to see why.",cause:t})}function He(e){return new o({code:"no-sound",title:"Nothing to transcribe",detail:`${r(e)} has no sound.`})}function Oe(e,t=process.platform,n=t==="darwin"?"apple":"whisper"){return n==="whisper"?new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e,t)} cannot be read by whisper.`,hint:"Video and sound files can be transcribed."}):new o({code:"unsupported-source",title:"Cannot transcribe this file",detail:`${r(e)} cannot be read by Apple's speech recogniser.`,hint:"MP4, MOV, M4A, MP3, WAV and AIFF can be transcribed; with ffmpeg (brew install ffmpeg), any video or sound file."})}function Re(e,t=process.platform,n=t==="darwin"?"apple":"whisper"){let i=n==="apple"?"Apple's speech recogniser":"The whisper extension";return new o({code:"language-unsupported",title:"Language not supported",detail:`${i} does not support ${e}.`,hint:"Pass another with --language, for example --language en-US."})}function Ae(e,t,n={}){return new o({code:"link-unavailable",title:"Cannot transcribe this link",detail:e,...n,...t===void 0?{}:{cause:t}})}function Ue(e){return new o({code:"transcribe-unavailable",title:"Transcribe is not available",detail:e})}function We(e=!1){return e?new o({code:"read-unavailable",title:"Reading text is not available",detail:"Reading text needs Forge's free read-text extension.",short:"Needs the read-text extension.",hint:"Install it with: forge extensions add read-text",shellHint:"Open /extensions to install it."}):new o({code:"read-unavailable",title:"Reading text is not available",detail:"Reading text needs macOS 26 or later.",short:"Reading text needs macOS 26 or later."})}function De(e){let t=r(e);return new o({code:"no-text",title:"No text found",detail:`No text found in ${t}`,short:`No text found in ${t}`})}function Me(e){return new o({code:"unexpected",title:"Something went wrong",detail:e instanceof Error?e.message:String(e),hint:"This was not expected. Try again \u2014 if it keeps happening, it may be worth reporting.",cause:e})}function Je(e,t={}){let n=[`\u2715 ${e.title}`,"",` ${e.detail}`];return e.hint&&n.push("",` ${e.hint}`),t.debug&&e.cause instanceof Error&&n.push("",` ${e.cause.stack??e.cause.message}`),n}export{m as a,v as b,k as c,C as d,S as e,T as f,I as g,N as h,P as i,H as j,O as k,R as l,A as m,U as n,W as o,D as p,M as q,J as r,j as s,z as t,L as u,q as v,Y as w,V as x,_ as y,X as z,w as A,B,G as C,K as D,Q as E,Z as F,ee as G,te as H,oe as I,ne as J,re as K,ie as L,ae as M,se as N,le as O,de as P,ue as Q,ce as R,pe as S,he as T,ge as U,fe as V,me as W,we as X,be as Y,xe as Z,$e as _,Fe as $,ye as aa,Ee as ba,ve as ca,ke as da,Ce as ea,Se as fa,Te as ga,Ie as ha,Ne as ia,p as ja,Pe as ka,He as la,Oe as ma,Re as na,Ae as oa,Ue as pa,We as qa,De as ra,Me as sa,Je as ta};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{a as w,b as I,d as k,e as m}from"./chunk-ZOQA3JAR.js";import{a as $,c as O}from"./chunk-TYWGB767.js";import{b as h,d as P,e as R}from"./chunk-J2UQI544.js";import{e as x}from"./chunk-57M4J2BR.js";import{a as l}from"./chunk-RK3WGALB.js";import{j as B}from"./chunk-DYIATUFE.js";import{$ as v,Y as g,Z as C}from"./chunk-CVNYUROW.js";import{a as f}from"./chunk-J7FLFHQJ.js";import{b as p}from"./chunk-VLVNA4T3.js";import{a as c}from"./chunk-H3DIRJFE.js";import{dirname as S,join as q}from"node:path";async function T(t){if(t.fallback!==void 0)return t.fallback;let{loadPreferences:r,expandTilde:e}=await import("./preferences-3P4V2EDX.js");return e((await r()).prefs.defaultOutput)}function F(t){if(t.pasteboard)return t.pasteboard;if(!$())throw C();return O()}function E(t,r,e,o){let a=q(r.outDir,`Copied image${c[o].extensions[0]}`),s={inputs:[r.source],output:a,force:!1,recursive:!1,debug:t.debug},n={background:"#ffffff",keepMetadata:!1,...t.quality===void 0?{}:{quality:t.quality}};return o===e?{kind:"compress",...s,options:n,...t.quality===void 0?{}:{quality:t.quality},...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}:{kind:"convert",...s,target:o,options:n,...t.maxBytes===void 0?{}:{maxBytes:t.maxBytes}}}async function J(t,r={}){let e=r.clip??{},o=F(e),a=await w(o,e.root);if(!a)throw g((await o.peek()).text?"text":"nothing");let s=await B(a.source),n=t.target??s.format,b=E(t,a,s.format,n),i=await P(b,r),y=i.results[0];if(!y||i.failures.length>0)return{report:i,status:"failed"};let u=y.job.outputs[0],d={report:i,output:u,source:{format:s.format,bytes:s.bytes},target:n};if(await I(o,a,u,n)==="changed")return{...d,status:"changed",saved:await m(u,await T(e))};if(t.save===void 0)return{...d,status:"placed"};let j=t.save===!0?await T(e):t.save,{expandTilde:D}=await import("./preferences-3P4V2EDX.js");return{...d,status:"placed",saved:await m(u,D(j))}}function N(t){let r=t.target===t.source.format?"":` as ${c[t.target].label}`,e=` ${f(t.source.bytes)} \u2192 ${f(t.report.outputBytes)} \xB7 ${h(t.source.bytes,t.report.outputBytes)}`;if(t.status==="changed"){let a=t.target===t.source.format?"compressed":"converted";return[`\u2713 Copied image \u2192 ${p(t.saved)}${r}`,e,"","\u26A0 Clipboard changed"," The file you uploaded is no longer in the clipboard.",` The ${a} image is saved to ${p(S(t.saved))}.`]}let o=t.saved===void 0?"":` + ${p(t.saved)}`;return[`\u2713 Copied image \u2192 clipboard${r}${o}`,e]}async function U(t){if(!await k(F(t),t.root))throw v()}async function Z(t,r){if(t.undo)return await U(r.clip??{}),{exitCode:0,stdout:r.json?[JSON.stringify({forge:l,ok:!0,clipboard:"restored"})]:["\u2713 The original is back on the clipboard"],stderr:[]};let e=await J(t,r);if(e.status==="failed")return R(e.report,r);if(r.json){let o={...x(l,e.report),clipboard:e.status,...e.saved===void 0?{}:{saved:e.saved}};return{exitCode:0,stdout:[JSON.stringify(o)],stderr:[]}}return{exitCode:0,stdout:N(e),stderr:[]}}export{J as a,N as b,U as c,Z as d};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{c as ne,g as at,h as ct}from"./chunk-EEQSUBBL.js";import{c as le,d as ft,f as ge,g as dt,k as pt}from"./chunk-LA5JVBFP.js";import{b as st,c as it}from"./chunk-K6ERQTUQ.js";import{b as Ue,c as ze,d as qe,f as He,i as tt,j as ot,k as nt,p as rt}from"./chunk-T37DEXUI.js";import{n as Ge,o as Ve,q as Ke,r as R}from"./chunk-BIBDLXCG.js";import{E as Te,F as V,G as me,I as Ne,M as Le,V as Je,a as B,aa as te,ha as We,ia as Ce,ka as J,r as Be,t as j,v as ee}from"./chunk-CVNYUROW.js";import{a as Ae}from"./chunk-J7FLFHQJ.js";import{c as A}from"./chunk-VLVNA4T3.js";import{a as S}from"./chunk-H3DIRJFE.js";import{a as Ye,b as oe,c as M,e as Ze,f as Qe,g as Xe,h as je,i as et}from"./chunk-KXKQDFHX.js";import{mkdtemp as Jt,rm as Wt}from"node:fs/promises";import{tmpdir as Ct}from"node:os";import{join as re}from"node:path";var mt=(e,t,o)=>He(e,t,o)===void 0;function ut(e,t,o=Number.POSITIVE_INFINITY,n=[2,4]){return[...n].reverse().find(s=>s<o&&mt(e,t,s))??0}async function Ut(e,t,o){if(e.op!=="boost"&&e.op!=="remove-background")throw new Error(`the extension engine cannot ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=e.op,{assetFor:i,catalogEntry:a,offeredHere:f}=await import("./catalog-FMHWWMUX.js");if(!f(r,process.platform,process.arch))throw Le(a(r)?.title??r);let{installed:d,extensionsRoot:u}=await import("./paths-6OENILJ4.js"),h=await d(r);if(!h)throw Ne(r);let l=ze(h.version);if(e.op==="boost"){let v=a(r),x=qe(e.scale,h.version,v&&i(v)?.version);if(x)throw x}if(e.op==="boost"&&!mt(n.width,n.height,e.scale))throw Je(n.path,ut(n.width,n.height,Number.POSITIVE_INFINITY,l),e.scale);let{runExtension:w}=await import("./run-WSETTQXP.js"),g=[];n.frames>1&&g.push({code:"animation-flattened",message:`${A(n.path)} has ${n.frames} frames. Only the first frame was used.`});let I=await Jt(re(Ct(),"forge-ext-"));try{t({phase:"decoding"});let v=re(I,"in.png"),x=re(I,"out.png");await nt(n,v);let $=e.op==="boost"?["--in",v,"--out",x,"--scale",String(e.scale),"--cache",re(u(),"boost","cache")]:[v,x],p=e.op==="boost"&&Ue(h.version);await w({...h,serve:p},$,{subject:n.path,what:`${zt(e)} is running on ${A(n.path)}`,onWait:()=>t({phase:"waiting"}),onStart:()=>t({phase:"encoding"}),onProgress:(O,P)=>t({phase:"tiles",done:O,total:P}),...e.op==="boost"?{maxScale:ut(n.width,n.height,e.scale,l)}:{},...o===void 0?{}:{signal:o}});let y=(await oe())(x);S[e.target].hasAlpha||(y=y.flatten({background:e.options.background}));let F=await tt(y,e.target,e.options.quality).toBuffer();t({phase:"writing"});let b=await ot(F,s);return{job:e,outputBytes:b,warnings:g}}catch(v){throw B(v)?v:J(n.path,v)}finally{await Wt(I,{recursive:!0,force:!0}).catch(()=>{})}}function zt(e){return e.op!=="boost"?"Remove background":e.scale===1?"Sharpen":`Boost resolution ${e.scale}\xD7`}var lt={id:"extension",reads:new Set,writes:new Set,ops:new Set(["boost","remove-background"]),probe:()=>Promise.reject(new Error("the extension engine reads no files")),run:Ut};import{randomBytes as mo}from"node:crypto";import{rm as lo,stat as se}from"node:fs/promises";import{dirname as go,join as ho}from"node:path";import{open as qt}from"node:fs/promises";async function W(e,t){let o=await qt(e,"r");try{let n=Buffer.alloc(t),{bytesRead:s}=await o.read(n,0,t,0);return n.subarray(0,s)}finally{await o.close()}}var he="%NOISE_FLOOR%",Ht=["highpass=f=80",`afftdn=nr=12:nf=${he}`],Gt="highpass=f=80,astats=measure_perchannel=none:measure_overall=RMS_trough";function vt(e){let t=/RMS trough dB:\s*(-?[\d.]+|-?inf)/i.exec(e)?.[1],o=t===void 0?Number.NaN:Number(t);return Number.isFinite(o)?Math.min(-30,Math.max(-70,Math.round(o+8))):-50}var we="%LOUDNORM_MEASURED%",Vt={mp4:"mp4",hevc:"mp4",mov:"mov",webm:"webm",mkv:"matroska",avi:"avi",gif:"gif",mp3:"mp3",m4a:"ipod",opus:"opus",flac:"flac",wav:"wav",aiff:"aiff",ogg:"ogg"},Kt={mp4:["h264","hevc","mpeg4","av1"],mov:["h264","hevc","mpeg4","prores","av1"],mkv:["h264","hevc","mpeg4","vp8","vp9","av1"],hevc:["hevc"],webm:["vp8","vp9","av1"],avi:["mpeg4","h264","mjpeg","msmpeg4v3"]},Yt={mp4:["aac","alac","mp3"],hevc:["aac","alac","mp3"],mov:["aac","alac","mp3","pcm_s16le","pcm_s16be","pcm_s24le"],m4a:["aac","alac"],mkv:["aac","mp3","opus","vorbis","flac","ac3","eac3"],webm:["opus","vorbis"],opus:["opus"],mp3:["mp3"],flac:["flac"],wav:["pcm_s16le"],aiff:["pcm_s16be"],ogg:["vorbis","opus","flac"],avi:["mp3","ac3","aac","pcm_s16le"]},gt=[48e3,24e3,16e3,12e3,8e3];function Zt(e,t,o){let n={encoder:"opus",kbps:96,args:["-strict","-2"],rates:[48e3]};switch(e){case"webm":return o("libopus")?{encoder:"libopus",kbps:96,rates:gt}:o("libvorbis")?{encoder:"libvorbis",kbps:128}:o("opus")?n:{codec:"Opus or Vorbis",encoders:["libopus","libvorbis","opus"],sound:!0};case"opus":return o("libopus")?{encoder:"libopus",kbps:96,rates:gt}:o("opus")?n:{codec:"Opus",encoders:["libopus","opus"]};case"mp3":return o("libmp3lame")?{encoder:"libmp3lame",kbps:128}:{codec:"MP3",encoders:["libmp3lame"]};case"flac":return{encoder:"flac"};case"wav":return{encoder:"pcm_s16le"};case"aiff":return{encoder:"pcm_s16be"};case"ogg":return o("libvorbis")?{encoder:"libvorbis",kbps:128}:{encoder:"vorbis",kbps:128,args:["-strict","-2","-ac","2"]};default:return{encoder:t==="darwin"&&o("aac_at")?"aac_at":"aac",kbps:128}}}var K=e=>Math.max(2,Math.floor(e/2)*2),Qt=e=>String(Math.round(e*1e3)/1e3),Xt=e=>String(Math.ceil(e*1e3)/1e3),jt=e=>Math.round(38-(e-1)*20/99),eo=e=>Math.round(50-(e-1)*30/99),to=e=>Math.round(40-(e-1)*18/99),ht=e=>Math.round(20+e*60/100),oo=e=>Math.round(31-(e-1)*29/99);function no(e,t){let o=.15*2**((18-e)/6);return Math.max(64,Math.round(t*o/1e3))}function ro(e,t,o,n,s){let r=e.width,i=e.height;if(o)r=o.width,i=o.height;else{t.crop?.box&&(r=t.crop.box.width,i=t.crop.box.height);let a=t.resize;if(a&&"width"in a){let f=Math.min(a.width,r)/r;r*=f,i*=f}else if(a&&"height"in a){let f=Math.min(a.height,i)/i;r*=f,i*=f}else a&&(r*=a.percent/100,i*=a.percent/100)}return r*i*(n??e.fps*s)}var so="zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p";function wt(e){let t=[],o=e;for(;o>2;)t.push("atempo=2"),o/=2;for(;o<.5;)t.push("atempo=0.5"),o/=.5;return t.push(`atempo=${Math.round(o*1e3)/1e3}`),t}var io=800,ao=15,bt=32;function be(e){let{facts:t,options:o,target:n,platform:s}=e,r=o.media??{},i=t.video,a=t.audio,f=S[n].media==="sound",d=n==="gif",u=o.compress!==void 0,h=s==="darwin",l=c=>e.has===void 0||e.has.has(c),w=c=>Ce(n,c,e.os??s),g=r.cut?.start??0,I=Math.min(r.cut?.end??t.duration,t.duration),v=Math.max(0,I-g),x=r.speed??1,$=v/x,p=i!==void 0&&!f,E=a!==void 0&&!r.mute&&!d,y,F,b,O;if(r.targetBytes!==void 0&&$>0){if(p&&i){let c=at({duration:$,width:i.width,height:i.height,fps:i.fps,hasAudio:E,targetBytes:r.targetBytes});"videoKbps"in c&&(y={width:c.width,height:c.height,fps:c.fps},b=c.videoKbps,F=c.audioKbps)}else if(E){let c=Math.floor(r.targetBytes*8/$/1e3*.98);O=Math.max(bt,Math.min(320,c))}}let P=[];if(p&&i){if(i.hdr&&n!=="hevc"&&l("zscale")&&P.push(so),o.crop?.box){let c=o.crop.box;P.push(`crop=${K(c.width)}:${K(c.height)}:${c.left}:${c.top}`)}if(y)P.push(`scale=${y.width}:${y.height}`);else if(o.resize){let c=o.resize;"width"in c?P.push(`scale=trunc(min(${K(c.width)}\\,iw)/2)*2:-2`):"height"in c?P.push(`scale=-2:trunc(min(${K(c.height)}\\,ih)/2)*2`):P.push(`scale=trunc(iw*${c.percent/100}/2)*2:-2`)}if(o.rotate&&P.push(o.rotate===90?"transpose=1":o.rotate===270?"transpose=2":"hflip,vflip"),x!==1&&P.push(`setpts=PTS/${x}`),d){let c=Math.min(io,K(i.width));P.push(`fps=${Math.min(ao,i.fps)},scale=${c}:-2:flags=lanczos,split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer:bayer_scale=4`)}}let Q=y?.fps??r.fps,Re=p&&i!==void 0&&P.length===0&&Q===void 0&&!u&&r.targetBytes===void 0&&(Kt[n]??[]).includes(i.codec),m=[],fe=!1;if(!p)m.push("-vn");else if(Re)m.push("-c:v","copy");else{if(P.length&&m.push("-vf",P.join(",")),d)m.push("-c:v","gif","-loop","0");else if(n==="webm"){if(!l("libvpx-vp9"))throw w({codec:"VP9",encoders:["libvpx-vp9"]});if(fe=b!==void 0,m.push("-c:v","libvpx-vp9","-row-mt","1","-deadline","good","-cpu-used","4"),i?.codec==="gif"&&m.push("-pix_fmt","yuva420p"),b!==void 0)m.push("-b:v",`${b}k`);else{let c=u?eo(o.quality??60):33;m.push("-crf",String(c),"-b:v","0")}}else if(n==="hevc"){let c=l("libx265"),k=h&&l("hevc_videotoolbox");if(!c&&!k)throw w({codec:"HEVC",encoders:["libx265",...h?["hevc_videotoolbox"]:[]]});if(b!==void 0)c?m.push("-c:v","libx265","-preset","fast","-b:v",`${b}k`):m.push("-c:v","hevc_videotoolbox","-b:v",`${b}k`);else if(k&&(!u||!c)){let D=u?ht(o.quality??60):60;m.push("-c:v","hevc_videotoolbox","-q:v",String(D))}else{let D=u?to(o.quality??60):26;m.push("-c:v","libx265","-crf",String(D),"-preset","fast")}m.push("-tag:v","hvc1","-pix_fmt",i?.hdr?"p010le":"yuv420p")}else{let c=u?jt(o.quality??60):21,k=()=>`${b??no(c,i?ro(i,o,y,Q,x):0)}k`;if(b===void 0&&!u&&h&&l("h264_videotoolbox"))m.push("-c:v","h264_videotoolbox","-q:v","65");else if(l("libx264"))fe=b!==void 0,b!==void 0?m.push("-c:v","libx264","-preset","medium","-b:v",`${b}k`):u?m.push("-c:v","libx264","-preset","medium","-crf",String(c)):m.push("-c:v","libx264","-preset","veryfast","-crf","21");else if(h&&l("h264_videotoolbox"))b!==void 0?m.push("-c:v","h264_videotoolbox","-b:v",k()):m.push("-c:v","h264_videotoolbox","-q:v",String(ht(o.quality??60)));else if(l("libopenh264"))m.push("-c:v","libopenh264","-b:v",k());else if(s==="win32"&&l("h264_mf"))m.push("-c:v","h264_mf","-b:v",k());else if(n==="avi")if(b!==void 0)m.push("-c:v","mpeg4","-b:v",`${b}k`);else{let D=u?oo(o.quality??60):3;m.push("-c:v","mpeg4","-q:v",String(D))}else throw w({codec:"H.264",encoders:["libx264",...h?["h264_videotoolbox"]:[],"libopenh264",...s==="win32"?["h264_mf"]:[]]});m.push("-pix_fmt","yuv420p")}Q!==void 0?m.push("-r",String(Q)):n==="avi"?m.push("-fps_mode","cfr"):d||m.push("-fps_mode","passthrough")}let $e=r.cleanup?[...Ht]:[],X=[...$e,...x!==1?wt(x):[]],N=r.loudness;N!==void 0&&X.push(`loudnorm=I=${N}:TP=-1.5:LRA=11:${we}:linear=true`);let _e=r.bitrate??F??O,ke=E&&a!==void 0&&X.length===0&&_e===void 0&&!(u&&f)&&(Yt[n]??[]).includes(a.codec),_=[];if(!E)_.push("-an");else if(ke)_.push("-c:a","copy");else{X.length&&_.push("-af",X.join(","));let c=Zt(n,s,l);if("codec"in c)throw w(c);_.push("-c:a",c.encoder);let k=_e??c.kbps;if(k!==void 0&&c.kbps!==void 0&&_.push("-b:a",`${k}k`),c.args&&_.push(...c.args),!c.args?.includes("-ac")&&F!==void 0&&F<=bt&&_.push("-ac","1"),N!==void 0&&a){let D=!c.rates||c.rates.includes(a.sampleRate);_.push("-ar",String(D?a.sampleRate:c.rates?.[0]))}}let de=[];g>0&&de.push("-ss",Xt(g)),r.cut&&de.push("-t",Qt(v));let H=[...de,"-i",e.input],G=[],pe=[...p?["-map","0:v:0"]:[],...E?["-map","0:a:0"]:[]],Me=o.keepMetadata?[]:["-map_metadata","-1"],Lt=Vt[n]??n,Oe=["mp4","hevc","mov","m4a"].includes(n)?["-movflags","+faststart"]:[],De=["-f",Lt,"-y",e.output],ue=s==="win32"?"NUL":"/dev/null",L=[];return r.cleanup&&L.push({args:[...H,...G,"-vn","-af",Gt,"-f","null",ue],measures:"noise"}),N!==void 0&&L.push({args:[...H,...G,"-vn","-af",`${[...$e,...x!==1?wt(x):[]].map(c=>`${c},`).join("")}loudnorm=I=${N}:TP=-1.5:LRA=11:print_format=json`,"-f","null",ue],measures:"loudness",pass:{at:1,of:2}}),fe?(L.push({args:[...H,...G,...pe.slice(0,2),...m,"-pass","1","-passlogfile",e.passlog,"-an","-f","null",ue],pass:{at:1,of:2}}),L.push({args:[...H,...G,...pe,...m,"-pass","2","-passlogfile",e.passlog,..._,...Me,...Oe,...De],pass:{at:2,of:2}})):L.push({args:[...H,...G,...pe,...m,..._,...Me,...Oe,...De],...N!==void 0?{pass:{at:2,of:2}}:{}}),{steps:L,duration:$,copies:{video:Re,audio:ke},...y?{fitted:y}:{}}}var C=(e,t,o)=>e.subarray(t,t+o).toString("latin1"),co=new Set(["heic","heix","hevc","hevx","heim","heis","mif1","msf1","avif","avis","crx "]),fo=new Set(["M4A ","M4B ","M4P ","F4A ","F4B "]);function po(e){let t=C(e,8,4);if(!co.has(t))return t==="qt "?"mov":fo.has(t)?"m4a":"mp4"}function yt(e){if(e.length<4)return;if(C(e,4,4)==="ftyp")return po(e);if(e[0]===26&&e[1]===69&&e[2]===223&&e[3]===163)return e.includes("webm",0,"latin1")?"webm":"mkv";let t=C(e,0,4);if(t==="RIFF"){let o=C(e,8,4);return o==="WAVE"?"wav":o==="AVI "?"avi":void 0}if(t==="FORM"){let o=C(e,8,4);return o==="AIFF"||o==="AIFC"?"aiff":void 0}if(t==="fLaC")return"flac";if(t==="OggS")return e.includes("OpusHead",0,"latin1")?"opus":"ogg";if(C(e,0,3)==="ID3"||e[0]===255&&((e[1]??0)&224)===224&&((e[1]??0)&6)===2)return"mp3"}var wo=["mp4","mov","webm","mkv","avi","gif"],Pt=["mp4","mov","hevc","webm","mkv","avi","gif","mp3","m4a","wav"],bo=["mp3","m4a","wav","aiff","flac","opus","ogg"],vo=["mp3","m4a","opus","flac","aiff","wav"];function yo(e){return W(e,64)}function xo(e,t){return t&&!t.video&&(e==="mp4"||e==="mov")?"m4a":e}async function Et(e,t){let o=yt(await yo(e));if(!o)throw new Error("not video or sound");if(o!=="mp4"&&o!=="mov"&&S[o].media!==t)throw new Error(`not ${t}`);let n=(await se(e)).size,s=await le(),r;if(s){try{r=await ge(e,s)}catch(a){throw j(e,a)}if(r.duration<=0||!r.video&&!r.audio)throw j(e,r)}let i=xo(o,r);if(S[i].media!==t)throw new Error(`not ${t}`);return{kind:"media",path:e,format:i,bytes:n,...r?{facts:r}:{}}}async function Po(){let{assetFor:e,catalogEntry:t}=await import("./catalog-FMHWWMUX.js"),o=t("video");return o!==void 0&&e(o)!==void 0}async function Eo(e,t){if(e.kind==="media"&&e.facts)return e.facts;try{return await ge(e.path,t)}catch(o){throw j(e.path,o)}}function Fo(e,t){let o=e.options.media??{},n=o.cut?.start??0,s=Math.min(o.cut?.end??t,t);return Math.max(0,s-n)/(o.speed??1)}function Ft(e,t){if(e.op!=="convert")return;let o=e.sources[0],n=o.kind==="media"?o.facts:void 0;if(!n)return;let s=e.options.media??{},r=ct({...n,duration:Fo(e,n.duration)},{soundOnly:S[e.target].media==="sound",mute:s.mute===!0||e.target==="gif"});return t<r?{floor:r}:void 0}function So(e){let t=e.slice(e.lastIndexOf("{"),e.lastIndexOf("}")+1),o=JSON.parse(t);return[`measured_I=${o.input_i}`,`measured_TP=${o.input_tp}`,`measured_LRA=${o.input_lra}`,`measured_thresh=${o.input_thresh}`,`offset=${o.target_offset}`].join(":")}async function xt(e){await Promise.all(e.map(t=>lo(t,{force:!0}).catch(()=>{})))}async function St(e,t,o){if(e.op!=="convert")throw new Error(`media engines only convert, not ${e.op}`);if(o?.aborted)throw o.reason??new Error("aborted");let n=e.sources[0],s=e.outputs[0],r=await le();if(!r)throw We(n.path,process.platform,await Po());let i=await Eo(n,r),a=mo(6).toString("hex"),f=Ge(s,a),d=ho(go(s),`.forge-pass-${a}`),u=[f,`${d}-0.log`,`${d}-0.log.temp`,`${d}-0.log.mbtree`,`${d}-0.log.mbtree.temp`],h=[],l=(p,E=e.options)=>be({input:n.path,output:f,target:e.target,facts:i,options:E,platform:p,os:process.platform,passlog:d,...r.has?{has:r.has}:{}}),w=e.options,g=l(process.platform);if(g.duration<=0)throw Te(`The cut keeps nothing of ${A(n.path)}: it starts at or after its end.`,`It is ${ne(i.duration)} long.`);await Ve(s);let I=process.platform,v=w.media?.cut;if(g.copies.video&&v&&v.start>0){let p=await dt(n.path,v.start,r);p!==void 0&&v.start-p>.05&&(w={...w,media:{...w.media,cut:{...v,start:p}}},g=l(process.platform,w),h.push({code:"media-cut-keyframe",message:`It starts at ${ne(p)}, the keyframe just before ${ne(v.start)}.`}))}let x=async p=>{let E="",y="";for(let F of p.steps){let b=F.args.map(P=>P.replace(we,E).replace(he,y)),O=await pt(b,{tools:r,signal:o,report:F.measures!==void 0,onTime:P=>t({phase:"time",done:Math.min(P,p.duration),total:p.duration,...F.pass?{pass:F.pass}:{}})});F.measures==="loudness"&&(E=So(O)),F.measures==="noise"&&(y=String(vt(O)))}};try{try{await x(g)}catch(y){if(o?.aborted||!g.steps.some(F=>F.args.some(b=>b.endsWith("_videotoolbox"))))throw y;I="linux",g=l(I,w),await x(g)}let p=w.media?.targetBytes;for(let y of[.95,.9]){if(p===void 0||(await se(f)).size<=p)break;w={...w,media:{...w.media,targetBytes:Math.floor(p*y)}},g=l(I,w),await x(g)}let E=(await se(f)).size;if(p!==void 0&&E>p)throw Be(n,e.options.media?.targetBytes??p,E);if(e.options.compress!==void 0&&E>=n.bytes)throw te(n.path,n.bytes,E);await Ke(f,s)}catch(p){throw await xt(u),o?.aborted||B(p)?p:J(n.path,p)}await xt(u.slice(1));let $=i.video;if(g.fitted&&$&&(g.fitted.width<$.width-2||g.fitted.fps<$.fps)){let p=Ae(e.options.media?.targetBytes??0);h.push({code:"media-fitted",message:`To fit ${p} it is now ${g.fitted.width}\xD7${g.fitted.height} at ${g.fitted.fps} fps.`})}return{job:e,outputBytes:(await se(s)).size,warnings:h}}function Zn(e,t){if(e.kind!=="media"||!e.facts)return;let o=ft()?.has;if(o)try{be({input:e.path,output:e.path,target:t,facts:e.facts,options:{background:"#ffffff",keepMetadata:!1},platform:process.platform,passlog:"",has:o});return}catch(n){return B(n)&&n.code==="encoder-missing"?n:void 0}}var Y=e=>new Set(e);function Io(e){let t=e.kind==="media"?e.facts:void 0,o=e.kind==="image"||t!==void 0&&t.audio===void 0;return Y(Pt.filter(n=>!(o&&S[n].media==="sound"||n==="hevc"&&t?.video?.codec==="hevc")))}var It={id:"video",reads:Y(wo),writes:Y(Pt),ops:new Set(["convert"]),probe:e=>Et(e,"video"),alone:!0,run:St,sizeTo:Ft,writesFor:Io},Rt={id:"sound",reads:Y(bo),writes:Y(vo),ops:new Set(["convert"]),probe:e=>Et(e,"sound"),alone:!0,run:St,sizeTo:Ft};import{readFile as ie,rm as Mt,stat as Ro}from"node:fs/promises";function jn(e,t){let o=e.split(",").map(r=>r.trim()).filter(r=>r!=="");if(o.length===0)throw V(e,"That selects no pages.",t);let n=new Set,s=(r,i)=>{if(!Number.isInteger(r)||r<1||r>t)throw V(i,`"${i}" is outside 1 and ${t}.`,t);return r};for(let r of o){let i=r.match(/^(\d+)\s*-\s*(\d*)$/);if(i?.[1]!==void 0){let a=s(Number(i[1]),r),f=i[2]===""?t:s(Number(i[2]),r);if(f<a)throw V(r,`"${r}" ends before it starts.`,t);for(let d=a;d<=f;d++)n.add(d-1);continue}if(!/^\d+$/.test(r))throw V(r,`"${r}" is not a page number.`,t);n.add(s(Number(r),r)-1)}return[...n].sort((r,i)=>r-i)}function $t(e){return[...new Set(e)].sort((t,o)=>t-o)}function er(e){if(e.length===0)return"";let t=[...new Set(e)].sort((r,i)=>r-i),o=[],n=t[0],s=n;for(let r of t.slice(1)){if(r===s+1){s=r;continue}o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),n=r,s=r}return o.push(n===s?`${n+1}`:`${n+1}-${s+1}`),o.join(", ")}function _t(e,t){let o=[...new Set(e)].sort((r,i)=>r-i).filter(r=>r>=0&&r<t-1),n=[],s=0;for(let r of o)n.push({from:s,to:r}),s=r+1;return n.push({from:s,to:t-1}),n}var ye=Ye(()=>import("./pdf-compress-U2E3CNXG.js")),$o=new Set(["pdf","jpeg","png","webp","avif","gif","tiff"]),_o=new Set(["pdf"]);async function U(e){return(await M()).PDFDocument.load(await ie(e),{ignoreEncryption:!0})}var ko=1024,kt=Buffer.from("%PDF-","latin1");async function Mo(e){return(await W(e,ko+kt.length)).indexOf(kt)!==-1}async function Oo(e){if(!await Mo(e))throw new Error(`${e} is not a PDF`);let{surveyDocument:t}=await ye(),o=await U(e),{size:n}=await Ro(e);return{kind:"document",path:e,format:"pdf",bytes:n,pages:o.getPageCount(),encrypted:o.isEncrypted,images:t(o)}}function z(e){for(let t of e)if(t.encrypted)throw ee(t.path)}async function Do(e,t,o){let n=await oe(),s=t.format==="jpeg"||t.format==="png",r=s?(await n(o).metadata()).orientation:void 0;if(s&&(r===void 0||r===1))return t.format==="jpeg"?e.embedJpg(o):e.embedPng(o);if(t.format==="jpeg"){let i=await n(o).rotate().jpeg({quality:S.jpeg.defaultQuality,mozjpeg:!0}).toBuffer();return e.embedJpg(i)}return e.embedPng(await n(o).rotate().png().toBuffer())}async function Ao(e,t){let o=e.sources[0];if(o.kind!=="image")throw new Error("the pdf engine cannot embed a document source");let n=[];o.frames>1&&n.push({code:"animation-flattened",message:`${A(o.path)} has ${o.frames} frames, and ${S.pdf.label} cannot animate. Only the first frame was converted.`}),t({phase:"reading"});let s=await ie(o.path);t({phase:"encoding"});let i=await(await M()).PDFDocument.create(),a=await Do(i,o,s);i.addPage([a.width,a.height]).drawImage(a,{x:0,y:0,width:a.width,height:a.height}),t({phase:"writing"});let d=await R(e.outputs[0],await i.save());return{job:e,outputBytes:d,warnings:n}}async function Bo(e,t){z(e.sources.filter(i=>i.kind==="document"));let n=await(await M()).PDFDocument.create();for(let i of e.sources){t({phase:"reading"});let a=await U(i.path),f=await n.copyPages(a,a.getPageIndices());for(let d of f)n.addPage(d)}t({phase:"writing"});let s=await n.save(),r=await R(e.outputs[0],s);return{job:e,outputBytes:r,warnings:[]}}async function To(e,t){let o=e.sources[0];z([o]);let n=await M();t({phase:"reading"});let s=await U(o.path),r=_t(e.cuts,s.getPageCount()),i=[],a=0;try{for(let[f,d]of r.entries()){let u=await n.PDFDocument.create(),h=Array.from({length:d.to-d.from+1},(g,I)=>d.from+I),l=await u.copyPages(s,h);for(let g of l)u.addPage(g);let w=e.outputs[f];if(w===void 0)throw new Error(`split produced ${r.length} parts but was given ${e.outputs.length} outputs`);a+=await R(w,await u.save()),i.push(w),t({phase:"page",done:f+1,total:r.length})}}catch(f){throw await Promise.all(i.map(d=>Mt(d,{force:!0}))),f}return{job:e,outputBytes:a,warnings:[]}}async function ve(e,t){let n=await(await M()).PDFDocument.create(),s=await n.copyPages(e,t);for(let r of s)n.addPage(r);return n.save()}async function No(e,t){let o=e.sources[0];if(z([o]),e.pages.length===0)throw me("That extract selects no pages.");t({phase:"reading"});let n=await U(o.path),s=$t(e.pages),r=[],i=0;try{if(e.separate)for(let[a,f]of s.entries()){let d=e.outputs[a];i+=await R(d,await ve(n,[f])),r.push(d),t({phase:"page",done:a+1,total:s.length})}else{t({phase:"writing"});let a=e.outputs[0];i=await R(a,await ve(n,s)),r.push(a)}}catch(a){throw await Promise.all(r.map(f=>Mt(f,{force:!0}))),a}return{job:e,outputBytes:i,warnings:[]}}async function Lo(e,t){let o=e.sources[0];z([o]),t({phase:"reading"});let n=await U(o.path),s=new Set(e.pages),r=n.getPageIndices().filter(a=>!s.has(a));if(r.length===0)throw me("That would delete every page.");t({phase:"writing"});let i=await R(e.outputs[0],await ve(n,r));return{job:e,outputBytes:i,warnings:[]}}async function Jo(e,t){let o=e.sources[0];z([o]);let n=await M();t({phase:"reading"});let s=await U(o.path);for(let i of s.getPages()){let f=((i.getRotation().angle+e.turns*90)%360+360)%360;i.setRotation(n.degrees(f))}t({phase:"writing"});let r=await R(e.outputs[0],await s.save());return{job:e,outputBytes:r,warnings:[]}}async function Wo(e,t){let o=e.sources[0];z([o]);let{compressPdf:n}=await ye();t({phase:"reading"});let s=await ie(o.path);t({phase:"encoding"});let{bytes:r,recompressed:i,skipped:a,fromDpi:f,toDpi:d}=await n(s,{quality:e.options.quality??60,dpi:e.options.dpi??150});if(e.options.compress&&r.length>=o.bytes)throw te(o.path,o.bytes,r.length);t({phase:"writing"});let u=await R(e.outputs[0],r),h=w=>w===1?"":"s",l=[];return i===0&&a===0?l.push({code:"pdf-no-images",message:"This PDF has no images to re-encode, so its size is almost unchanged."}):i===0?l.push({code:"pdf-no-images",message:`None of its ${a} image${h(a)} could be re-encoded \u2014 they are not JPEG data.`}):a>0&&l.push({code:"pdf-images-skipped",message:`${i} image${h(i)} recompressed, ${a} skipped (not JPEG).`}),f!==void 0&&d!==void 0&&l.push({code:"pdf-downsampled",message:`Images reduced from ${f} to ${d} dpi. Pass --dpi ${f} to keep them.`}),{job:e,outputBytes:u,warnings:l}}async function Co(e){if(e.op!=="convert")return;let t=e.sources[0];if(t.kind!=="document")return;let{compressPdf:o}=await ye(),n=await ie(t.path);return{ladder:[e.options.dpi??150,120,96,72].map(s=>({dpi:s})),measure:async s=>(await o(n,{quality:s.quality??60,...s.dpi===void 0?{}:{dpi:s.dpi}})).bytes.byteLength}}var Ot={id:"pdf",measurer:Co,reads:$o,writes:_o,ops:new Set(["convert","merge","split","extract","delete","rotate"]),probe:Oo,async run(e,t){switch(e.op){case"convert":if(e.target!=="pdf")throw new Error("the pdf engine only converts to pdf");return e.sources[0].kind==="document"?Wo(e,t):Ao(e,t);case"merge":return Bo(e,t);case"split":return To(e,t);case"extract":return No(e,t);case"delete":return Lo(e,t);case"rotate":return Jo(e,t);default:throw new Error(`the pdf engine cannot ${e.op}`)}}};import{execFile as Uo}from"node:child_process";import{mkdtemp as zo,readFile as Se,rm as qo}from"node:fs/promises";import{tmpdir as Ho}from"node:os";import{basename as Go,extname as Vo,join as Dt,win32 as Ee}from"node:path";import{pathToFileURL as Ko}from"node:url";import{promisify as Yo}from"node:util";var Fe=Yo(Uo),q=Buffer.from([208,207,17,224,161,177,26,225]);async function Zo(e){if(e.length<q.length||!e.subarray(0,q.length).equals(q))return!1;let t=await je();try{return t.find(t.parse(e),"WordDocument")!==null}catch{return!1}}async function Qo(e){let t=await Xe();try{let o=new t(e);if(!o.getEntry("word/document.xml"))return;let n=0,s=o.getEntry("docProps/app.xml");if(s){let r=/<Pages>(\d+)<\/Pages>/.exec(o.readAsText(s));r?.[1]&&(n=Number(r[1]))}return{pages:n}}catch{return}}var At=Buffer.from([80,75,3,4]);async function Xo(e){let t=await W(e,q.length);return t.subarray(0,At.length).equals(At)||t.subarray(0,q.length).equals(q)}async function jo(e){if(!await Xo(e))throw new Error(`${e} is not a Word document`);let t=await Se(e),o=await Qo(t);if(o)return{kind:"document",path:e,format:"docx",bytes:t.byteLength,pages:o.pages,encrypted:!1};if(await Zo(t))return{kind:"document",path:e,format:"doc",bytes:t.byteLength,pages:0,encrypted:!1};throw new Error(`${e} is not a Word document`)}function en(e,t){return e==="win32"?[Ee.join(t.ProgramFiles??"C:\\Program Files","LibreOffice","program","soffice.exe"),Ee.join(t["ProgramFiles(x86)"]??"C:\\Program Files (x86)","LibreOffice","program","soffice.exe")]:["/Applications/LibreOffice.app/Contents/MacOS/soffice"]}var tn=0;async function on(){tn++;try{return await Fe("soffice",["--version"],{timeout:5e3}),"soffice"}catch{}for(let e of en(process.platform,process.env))try{return await Fe(e,["--version"],{timeout:5e3}),e}catch{}}var Bt,nn=!1,rn;async function sn(){return nn?rn:(Bt??=on(),Bt)}var Ie="\f";function ae(e){return e.split(/\r?\n/).map(t=>t.trim()).filter(t=>t.length>0)}async function an(e){if(e.format==="docx"){let o=await Ze(),{value:n}=await o.extractRawText({path:e.path});return ae(n)}if(e.format==="doc"){let o=await Qe(),s=await new o().extract(e.path);return ae(s.getBody())}return(await st(await Se(e.path))).flatMap((o,n)=>n===0?ae(o):[Ie,...ae(o)])}var xe=612,ce=792,T=54,Pe=11,Tt=14;async function cn(e){let{PDFDocument:t,StandardFonts:o}=await M(),n=await t.create(),s=await n.embedFont(o.Helvetica),r=xe-T*2,i=n.addPage([xe,ce]),a=ce-T,f=()=>{i=n.addPage([xe,ce]),a=ce-T};for(let d of e){if(d===Ie){f();continue}let u="";for(let h of d.split(/\s+/).filter(Boolean)){let l=u?`${u} ${h}`:h;u&&s.widthOfTextAtSize(l,Pe)>r?(a<T&&f(),i.drawText(u,{x:T,y:a,size:Pe,font:s}),a-=Tt,u=h):u=l}u&&(a<T&&f(),i.drawText(u,{x:T,y:a,size:Pe,font:s}),a-=Tt)}return n.save()}async function fn(e){let{Document:t,Packer:o,PageBreak:n,Paragraph:s}=await et(),r=e.map(a=>a===Ie?new s({children:[new n]}):new s(a)),i=new t({sections:[{children:r}]});return o.toBuffer(i)}var dn=new Set(["docx","doc","pdf"]),pn=new Set(["docx","pdf"]),un=new Set(["convert"]),mn={code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: brew install --cask libreoffice"};function ln(e=process.platform){return e==="linux"?{code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice for full-fidelity conversion: sudo apt install libreoffice"}:e!=="win32"?mn:{code:"word-basic-fidelity",message:"Converted with basic formatting only \u2014 tables, images, and complex layouts weren't preserved. Install LibreOffice from libreoffice.org for full-fidelity conversion."}}function gn(e,t,o,n=process.platform){return[`-env:UserInstallation=${n==="win32"?Ko(Ee.join(e,"profile"),{windows:!0}).href:`file://${e}/profile`}`,"--headless","--convert-to",o,"--outdir",e,t]}async function hn(e,t,o){let n=await zo(Dt(Ho(),"forge-word-"));try{await Fe(e,gn(n,t,o),{timeout:12e4});let s=Go(t,Vo(t));return await Se(Dt(n,`${s}.${o}`))}finally{await qo(n,{recursive:!0,force:!0})}}async function wn(e,t){if(e.op!=="convert")throw new Error(`the word engine cannot ${e.op}`);let o=e.sources[0];if(o.kind!=="document")throw new Error("the word engine can only convert a document source");if(o.encrypted)throw ee(o.path);t({phase:"reading"});let n=await sn();t({phase:"encoding"});let s=[],r;try{if(n!==void 0)r=await hn(n,o.path,e.target);else{let a=await an(o);r=e.target==="pdf"?await cn(a):await fn(a),s.push(ln())}}catch(a){throw J(o.path,a)}t({phase:"writing"});let i=await R(e.outputs[0],r);return{job:e,outputBytes:i,warnings:s}}var Nt={id:"word",reads:dn,writes:pn,ops:un,probe:jo,run:wn};var Z=[rt,It,Rt,Ot,Nt,lt,it];function kr(e){return Z.find(t=>t.reads.has(e))}function Mr(e){return Z.find(t=>t.writes.has(e))}function Or(e){if(e.op==="convert"){let t=e.sources[0].format;return Z.find(o=>o.reads.has(t)&&o.writes.has(e.target))}return Z.find(t=>t.ops.has(e.op))}async function Dr(e){let t;for(let o of Z)try{return await o.probe(e)}catch(n){B(t)||(t=n)}throw t}export{jn as a,$t as b,er as c,_t as d,Zn as e,Z as f,kr as g,Mr as h,Or as i,Dr as j};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __forgeCreateRequire } from 'node:module';
2
2
  const require = __forgeCreateRequire(import.meta.url);
3
- import{b as f}from"./chunk-EKTUUKDP.js";import{execFile as s,execFileSync as i,spawn as d}from"node:child_process";var u=()=>({...process.env,LANG:process.env.LANG??"en_US.UTF-8"});function m(e,r=process.platform,n=process.env){if(e!==""){if(r==="linux"){c(Buffer.from(e,"utf8"),p(n,"copy"));return}if(r==="win32"){try{let t=s("clip.exe",()=>{});t.on("error",()=>{}),t.stdin?.end(Buffer.concat([Buffer.from([255,254]),Buffer.from(e,"utf16le")]))}catch{}return}try{let t=s("pbcopy",{env:u()},()=>{});t.on("error",()=>{}),t.stdin?.end(Buffer.from(e,"utf8"))}catch{}}}function y(e=process.platform,r=process.env){if(e==="linux")return l(p(r,"paste"));if(e==="win32")try{return i("powershell.exe",["-NoProfile","-NonInteractive","-Command","[Console]::OutputEncoding=[Text.Encoding]::UTF8; Get-Clipboard -Raw"],{encoding:"buffer",maxBuffer:67108864,timeout:5e3}).toString("utf8").replace(/\r\n$/,"")}catch{return""}try{return i("pbpaste",{encoding:"buffer",env:u(),maxBuffer:67108864,timeout:2e3}).toString("utf8")}catch{return""}}function p(e,r){return f(e).flatMap(n=>n.name==="wayland"?r==="copy"?[["wl-copy",["--type","text/plain;charset=utf-8"]]]:[["wl-paste",["--no-newline","--type","text"]]]:r==="copy"?[["xclip",["-selection","clipboard","-i"]],["xsel",["--clipboard","--input"]]]:[["xclip",["-selection","clipboard","-o"]],["xsel",["--clipboard","--output"]]])}function c(e,r){let[n,...t]=r;if(n)try{let o=d(n[0],n[1],{stdio:["pipe","ignore","ignore"],detached:!0});o.on("error",a=>{a.code==="ENOENT"&&c(e,t)}),o.stdin?.on("error",()=>{}),o.stdin?.end(e),o.unref()}catch{c(e,t)}}function l(e){for(let[r,n]of e)try{return i(r,n,{encoding:"buffer",maxBuffer:67108864,timeout:2e3,stdio:["ignore","pipe","ignore"]}).toString("utf8")}catch(t){if(t.code!=="ENOENT")return""}return""}export{m as a,y as b,p as c};
3
+ import{b as f}from"./chunk-TYWGB767.js";import{execFile as s,execFileSync as i,spawn as d}from"node:child_process";var u=()=>({...process.env,LANG:process.env.LANG??"en_US.UTF-8"});function m(e,r=process.platform,n=process.env){if(e!==""){if(r==="linux"){c(Buffer.from(e,"utf8"),p(n,"copy"));return}if(r==="win32"){try{let t=s("clip.exe",()=>{});t.on("error",()=>{}),t.stdin?.end(Buffer.concat([Buffer.from([255,254]),Buffer.from(e,"utf16le")]))}catch{}return}try{let t=s("pbcopy",{env:u()},()=>{});t.on("error",()=>{}),t.stdin?.end(Buffer.from(e,"utf8"))}catch{}}}function y(e=process.platform,r=process.env){if(e==="linux")return l(p(r,"paste"));if(e==="win32")try{return i("powershell.exe",["-NoProfile","-NonInteractive","-Command","[Console]::OutputEncoding=[Text.Encoding]::UTF8; Get-Clipboard -Raw"],{encoding:"buffer",maxBuffer:67108864,timeout:5e3}).toString("utf8").replace(/\r\n$/,"")}catch{return""}try{return i("pbpaste",{encoding:"buffer",env:u(),maxBuffer:67108864,timeout:2e3}).toString("utf8")}catch{return""}}function p(e,r){return f(e).flatMap(n=>n.name==="wayland"?r==="copy"?[["wl-copy",["--type","text/plain;charset=utf-8"]]]:[["wl-paste",["--no-newline","--type","text"]]]:r==="copy"?[["xclip",["-selection","clipboard","-i"]],["xsel",["--clipboard","--input"]]]:[["xclip",["-selection","clipboard","-o"]],["xsel",["--clipboard","--output"]]])}function c(e,r){let[n,...t]=r;if(n)try{let o=d(n[0],n[1],{stdio:["pipe","ignore","ignore"],detached:!0});o.on("error",a=>{a.code==="ENOENT"&&c(e,t)}),o.stdin?.on("error",()=>{}),o.stdin?.end(e),o.unref()}catch{c(e,t)}}function l(e){for(let[r,n]of e)try{return i(r,n,{encoding:"buffer",maxBuffer:67108864,timeout:2e3,stdio:["ignore","pipe","ignore"]}).toString("utf8")}catch(t){if(t.code!=="ENOENT")return""}return""}export{m as a,y as b,p as c};
@@ -0,0 +1,3 @@
1
+ import { createRequire as __forgeCreateRequire } from 'node:module';
2
+ const require = __forgeCreateRequire(import.meta.url);
3
+ import{b as B,c as C,d as U}from"./chunk-IED6VBE6.js";import{i as q}from"./chunk-DYIATUFE.js";import{c as T}from"./chunk-BIBDLXCG.js";import{a as x,aa as E,ba as A,ka as R,o as I,r as k,w as J,x as P,y as M,z as w}from"./chunk-CVNYUROW.js";function D(e=1,t=100){let o=Math.max(1,t-e+1);return 1+Math.max(0,Math.ceil(Math.log2(o)))}async function O(e){let t=e.min??1,o=e.max??100,c=D(t,o),a=0,n=async f=>(a+=1,e.onAttempt?.(a,c),e.encode(f)),s=()=>e.signal?.aborted===!0,u=await n(o);if(s())return{quality:o,bytes:u,missed:!1,cancelled:!0};if(u<=e.targetBytes)return{quality:o,bytes:u,missed:!1};let d=t,p=o,m;for(;d<=p;){let f=Math.floor((d+p)/2),g=await n(f);if(s())return{quality:f,bytes:g,missed:!1,cancelled:!0};g<=e.targetBytes?(m={quality:f,bytes:g,missed:!1},d=f+1):p=f-1}if(m)return m;let b=await e.encode(t);return{quality:t,bytes:b,missed:!0}}import{existsSync as L}from"node:fs";import{resolve as v}from"node:path";function N(e){let t=e.sources[0]?.path??e.outputs[0]??"",o=new Set;for(let c of e.outputs){let a=v(c);if(o.has(a))return{output:c,error:M(t,c)};o.add(a)}}function W(e,t,o){let c=N(e);if(c)return c;let a=e.sources[0]?.path??e.outputs[0]??"";for(let n of e.outputs){let s=v(n);if(e.sources.some(d=>T(d.path,s))&&!o)return{output:n,error:w(n,e.op)};let u=t.get(s);if(u){let d=u.sources[0]?.path??u.outputs[0]??"";return{output:n,error:P([d,a],n)}}if(L(s)&&!o)return{output:n,error:J(n,e.op)}}}function _(e,t){let o=[],c=[],a=new Map;for(let n of e){let s=W(n,a,t.force);if(s){let u=n.sources[0]?.path??s.output;c.push({path:u,error:s.error});continue}for(let u of n.outputs)a.set(v(u),n);o.push(n)}return{jobs:o,failures:c}}async function z(e,t,o,c,a,n){let s=e.sources[0].path,u=r=>({kind:"failed",failure:{path:s,error:x(r)?r:R(s,r)}}),d=o(e);if(d?.sizeTo){let r=e.sources[0],i=e.options.compress!==void 0;if(i&&r.bytes<=t)return{kind:"failed",failure:{path:s,error:A(s,r.bytes,t)}};let l=t,h=d.sizeTo(e,l);return h&&i&&h.floor>=r.bytes?{kind:"failed",failure:{path:s,error:E(s,r.bytes,h.floor,!0)}}:h?{kind:"unreachable",entry:{job:e,smallest:h.floor,settings:{quality:1,media:{...e.options.media,targetBytes:h.floor}},error:k(r,t,h.floor)}}:(e.options={...e.options,media:{...e.options.media,targetBytes:l}},{kind:"ready"})}let p;try{p=await o(e)?.measurer?.(e)}catch(r){return u(r)}if(!p||p.ladder.length===0)return{kind:"refused",failure:{path:s,error:I(e.sources[0],e.target)}};let m=p,b=e.sources[0],f=e.options.compress!==void 0&&b.bytes<=t,g=f?b.bytes-1:t;if(a?.aborted)return{kind:"cancelled"};let F=Number.POSITIVE_INFINITY,y;try{for(let r of m.ladder){let i=await O({encode:l=>m.measure({...e.options,...r,quality:l}),targetBytes:g,...n===void 0?{}:{max:n},onAttempt:(l,h)=>c({type:"search:attempt",job:e,attempt:l,of:h,rung:r}),...a===void 0?{}:{signal:a}});if(i.cancelled)return{kind:"cancelled"};if(i.bytes<F&&(F=i.bytes,y={...r,quality:i.quality}),!i.missed)return e.options={...e.options,...r,quality:i.quality},{kind:"ready"}}}catch(r){return u(r)}return f?{kind:"failed",failure:{path:s,error:E(s,b.bytes,F,!0)}}:{kind:"unreachable",entry:{job:e,smallest:F,settings:y??{quality:1},error:k(e.sources[0],t,F)}}}async function te(e,t){let o=t.onEvent??(()=>{}),c=t.engineFor??q,a=t.targetBytes,n=_(e,{force:t.force}),s=a===void 0?0:n.jobs.filter(r=>r.op==="convert").length,u=[],d=0;await C(n.jobs,B(t.concurrency),async(r,i)=>{if(a===void 0||r.op!=="convert"){u[i]={kind:"ready"};return}if(t.signal?.aborted){u[i]={kind:"cancelled"};return}let l=await z(r,a,c,o,t.signal,t.maxQuality);u[i]=l,l.kind!=="cancelled"&&(d+=1,o({type:"search:settled",job:r,completed:d,total:s}))});let p=[...n.failures],m=[],b=[],f=[],g=!1;for(let[r,i]of n.jobs.entries()){let l=u[r]??{kind:"ready"};l.kind==="ready"?f.push(i):l.kind==="refused"?p.push(l.failure):l.kind==="failed"?b.push(l.failure):l.kind==="unreachable"?m.push(l.entry):g=!0}if(g)return{results:[],refusals:p,unreachable:[],failures:[],inputBytes:0,outputBytes:0,cancelled:!0};let F=new Set,y=await U(f,{...t.concurrency===void 0?{}:{concurrency:t.concurrency},...t.engineFor===void 0?{}:{engineFor:t.engineFor},...t.signal===void 0?{}:{signal:t.signal},onEvent:r=>{r.type==="job:error"&&!t.signal?.aborted&&F.add(r.failure),o(r)}}),S=f.length-y.results.length;if(t.signal?.aborted&&S>0){let r=y.failures.filter(i=>F.has(i));return{...y,refusals:p,unreachable:m,failures:[...b,...r],cancelled:!0}}return{results:y.results,refusals:p,unreachable:m,failures:[...b,...y.failures],inputBytes:y.inputBytes,outputBytes:y.outputBytes}}export{_ as a,te as b};