forge-terminal 0.5.9 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -16
- package/dist/chunks/{about-credits-32BUKO4K.js → about-credits-PWTKZG3Y.js} +1 -1
- package/dist/chunks/args-RHIBM3R3.js +3 -0
- package/dist/chunks/{available-TNMISSBA.js → available-FPBRQ3LS.js} +1 -1
- package/dist/chunks/boot-PHDTJAFT.js +3 -0
- package/dist/chunks/{catalog-FMHWWMUX.js → catalog-G44MXIAF.js} +1 -1
- package/dist/chunks/check-BFHBPCGW.js +3 -0
- package/dist/chunks/chunk-2YU4EI24.js +3 -0
- package/dist/chunks/chunk-3IAJTXYM.js +3 -0
- package/dist/chunks/chunk-3OCPO5V6.js +3 -0
- package/dist/chunks/chunk-42IEPG2K.js +3 -0
- package/dist/chunks/{chunk-WE6KP4FR.js → chunk-4AL5QJLM.js} +1 -1
- package/dist/chunks/chunk-56B3VZCM.js +3 -0
- package/dist/chunks/chunk-56QHX7QR.js +3 -0
- package/dist/chunks/chunk-6NCN7OJ5.js +7 -0
- package/dist/chunks/chunk-6PUV4HSU.js +3 -0
- package/dist/chunks/chunk-72UR37EG.js +3 -0
- package/dist/chunks/chunk-7NP76V4U.js +3 -0
- package/dist/chunks/{chunk-7XFLG32B.js → chunk-AETM2PCZ.js} +1 -1
- package/dist/chunks/chunk-BQV3DSUZ.js +23 -0
- package/dist/chunks/chunk-BSFBZBAI.js +16 -0
- package/dist/chunks/chunk-DC2DHMXO.js +3 -0
- package/dist/chunks/{chunk-WBW6G4N6.js → chunk-DKHBJ52G.js} +1 -1
- package/dist/chunks/chunk-E5VPEBUQ.js +3 -0
- package/dist/chunks/chunk-EYOO35US.js +3 -0
- package/dist/chunks/chunk-F4TUCI6D.js +3 -0
- package/dist/chunks/{chunk-MF3KKEFB.js → chunk-FEJSM3E4.js} +1 -1
- package/dist/chunks/chunk-FGR6QCG5.js +3 -0
- package/dist/chunks/{chunk-W53XNVNH.js → chunk-G2V33TMN.js} +1 -1
- package/dist/chunks/{chunk-ILQDMVJR.js → chunk-G4M2XYFJ.js} +1 -1
- package/dist/chunks/chunk-H332YFSO.js +4 -0
- package/dist/chunks/chunk-HAOKWLD3.js +4 -0
- package/dist/chunks/chunk-I2LPGKUU.js +3 -0
- package/dist/chunks/{chunk-YRXJDFP3.js → chunk-I3C3SRF2.js} +1 -1
- package/dist/chunks/{chunk-SM735FG7.js → chunk-ID4GJZJ6.js} +1 -1
- package/dist/chunks/chunk-ID75X37Z.js +3 -0
- package/dist/chunks/chunk-JPASVE56.js +3 -0
- package/dist/chunks/chunk-JZM37DG2.js +3 -0
- package/dist/chunks/chunk-KPUKMAYK.js +19 -0
- package/dist/chunks/{chunk-SZRSAL64.js → chunk-M7HB4L6L.js} +1 -1
- package/dist/chunks/chunk-NUCGWLOY.js +8 -0
- package/dist/chunks/{chunk-4KGC5ZBZ.js → chunk-OK56WDPA.js} +1 -1
- package/dist/chunks/{chunk-I25E2XDH.js → chunk-OLKPV4WO.js} +1 -1
- package/dist/chunks/chunk-OPDC577C.js +3 -0
- package/dist/chunks/chunk-OQ6DTE56.js +3 -0
- package/dist/chunks/chunk-PA7AG2NK.js +55 -0
- package/dist/chunks/chunk-PNPAHKJR.js +3 -0
- package/dist/chunks/chunk-PON65UTS.js +3 -0
- package/dist/chunks/{chunk-GVVQP3LF.js → chunk-PXCEMDOY.js} +2 -2
- package/dist/chunks/chunk-QMNERJL2.js +3 -0
- package/dist/chunks/{chunk-OXDRJO4V.js → chunk-R6QVLPGC.js} +1 -1
- package/dist/chunks/chunk-S44LAUHZ.js +3 -0
- package/dist/chunks/chunk-SCJ2QXZF.js +80 -0
- package/dist/chunks/{chunk-4MJEEEFA.js → chunk-SJIDFYPT.js} +1 -1
- package/dist/chunks/{chunk-3374PCO5.js → chunk-TQEGSODD.js} +1 -1
- package/dist/chunks/chunk-ULX4ZD2Y.js +3 -0
- package/dist/chunks/chunk-W6QOV4RP.js +6 -0
- package/dist/chunks/chunk-WWWWXOM4.js +3 -0
- package/dist/chunks/{chunk-6RCS3KBP.js → chunk-XIR3VWQY.js} +1 -1
- package/dist/chunks/chunk-XUJLUOGD.js +6 -0
- package/dist/chunks/chunk-Y3DMALHT.js +66 -0
- package/dist/chunks/chunk-YXV3PYVI.js +3 -0
- package/dist/chunks/chunk-Z3PQ5TMU.js +3 -0
- package/dist/chunks/chunk-ZL7E7PZN.js +4 -0
- package/dist/chunks/clip-command-6Q7BTXR5.js +3 -0
- package/dist/chunks/clipboard-QWNPA3GM.js +3 -0
- package/dist/chunks/colour-7HPH6KTY.js +3 -0
- package/dist/chunks/command-JTK4IOS7.js +3 -0
- package/dist/chunks/config-command-DIQTU7DM.js +3 -0
- package/dist/chunks/continue-editing-FTUY6UFG.js +3 -0
- package/dist/chunks/decoded-IXLPWTGZ.js +3 -0
- package/dist/chunks/{entry-BZYPZONY.js → entry-ZF7D32ZI.js} +2 -2
- package/dist/chunks/execute-RP7ZMWLZ.js +3 -0
- package/dist/chunks/extensions-YOZ4IF4E.js +3 -0
- package/dist/chunks/{extensions-command-JZSOQJEV.js → extensions-command-O7UHUJ3Y.js} +1 -1
- package/dist/chunks/ffmpeg-2ZP3GXJX.js +3 -0
- package/dist/chunks/image-6A7FXKIR.js +3 -0
- package/dist/chunks/{install-KGFOAQCU.js → install-4L7JGP3X.js} +1 -1
- package/dist/chunks/install-XJAPLIH2.js +3 -0
- package/dist/chunks/launch-2KSJ4GGN.js +18 -0
- package/dist/chunks/link-inputs-GTEW6ZH4.js +3 -0
- package/dist/chunks/lock-KNR7XS7Q.js +3 -0
- package/dist/chunks/manager-YH5XAMZA.js +4 -0
- package/dist/chunks/{needed-DYERJ72M.js → needed-TB3OC76N.js} +1 -1
- package/dist/chunks/notify-UD7FQAWX.js +3 -0
- package/dist/chunks/{own-2QGMHSKL.js → own-KUGTZ3BV.js} +1 -1
- package/dist/chunks/{paths-6OENILJ4.js → paths-BBUKTDDP.js} +1 -1
- package/dist/chunks/pdfium-MJ65YOXW.js +3 -0
- package/dist/chunks/preferences-7S7YZOFK.js +3 -0
- package/dist/chunks/preset-command-KMKR6KMG.js +3 -0
- package/dist/chunks/registry-657JRJR5.js +3 -0
- package/dist/chunks/run-VJDF5WRF.js +3 -0
- package/dist/chunks/server-6PH2DSFW.js +81 -0
- package/dist/chunks/signals-VY2XE3LV.js +3 -0
- package/dist/chunks/text-layer-PFIDCTEL.js +5 -0
- package/dist/chunks/theme-FVQOSLPB.js +3 -0
- package/dist/chunks/transcribe-FUN2SKRN.js +3 -0
- package/dist/chunks/transcribe-command-KNSUHROE.js +3 -0
- package/dist/chunks/update-command-X4OSYETA.js +3 -0
- package/dist/chunks/update-note-LV7G4CHE.js +3 -0
- package/dist/chunks/video-link-CF7GUA6V.js +3 -0
- package/dist/chunks/watch-command-3C4AWM7A.js +3 -0
- package/dist/helpers/forge-transcribe +0 -0
- package/dist/index.js +16 -15
- package/package.json +15 -3
- package/skills/forge/SKILL.md +7 -3
- package/dist/chunks/args-ZVZQR23M.js +0 -3
- package/dist/chunks/boot-2YFTQOMG.js +0 -3
- package/dist/chunks/check-B6NP7BEM.js +0 -3
- package/dist/chunks/chunk-4RNVZQRC.js +0 -3
- package/dist/chunks/chunk-6KUWZQGG.js +0 -3
- package/dist/chunks/chunk-6MWJO3GB.js +0 -4
- package/dist/chunks/chunk-6PEIZZNE.js +0 -3
- package/dist/chunks/chunk-7FW7JX74.js +0 -36
- package/dist/chunks/chunk-7XDMC7FL.js +0 -72
- package/dist/chunks/chunk-AR3M2PLK.js +0 -3
- package/dist/chunks/chunk-ASLKQXZ2.js +0 -3
- package/dist/chunks/chunk-BKLPRILS.js +0 -3
- package/dist/chunks/chunk-EEQSUBBL.js +0 -3
- package/dist/chunks/chunk-FAUL5L2W.js +0 -3
- package/dist/chunks/chunk-FBVRKMAF.js +0 -3
- package/dist/chunks/chunk-GHYODKA3.js +0 -3
- package/dist/chunks/chunk-H3DIRJFE.js +0 -3
- package/dist/chunks/chunk-HTA25PO2.js +0 -3
- package/dist/chunks/chunk-J7FLFHQJ.js +0 -3
- package/dist/chunks/chunk-K253E723.js +0 -3
- package/dist/chunks/chunk-KH5DHZ2U.js +0 -8
- package/dist/chunks/chunk-L44NRTP4.js +0 -3
- package/dist/chunks/chunk-N32JL4UI.js +0 -3
- package/dist/chunks/chunk-N6RCLJE6.js +0 -4
- package/dist/chunks/chunk-NDYMC3HY.js +0 -66
- package/dist/chunks/chunk-NMECUMJD.js +0 -7
- package/dist/chunks/chunk-OQBIYNGK.js +0 -6
- package/dist/chunks/chunk-Q6KQWJ4J.js +0 -3
- package/dist/chunks/chunk-QQV7CCAY.js +0 -3
- package/dist/chunks/chunk-RCWFUBTG.js +0 -3
- package/dist/chunks/chunk-TFGK7IRZ.js +0 -19
- package/dist/chunks/chunk-TGC24JEW.js +0 -4
- package/dist/chunks/chunk-TLHUFIXD.js +0 -3
- package/dist/chunks/chunk-V6GWPR2A.js +0 -3
- package/dist/chunks/chunk-VJMOZPHW.js +0 -3
- package/dist/chunks/chunk-YPAFAG4W.js +0 -6
- package/dist/chunks/chunk-ZBMJTIYR.js +0 -3
- package/dist/chunks/chunk-ZX5FDZZW.js +0 -55
- package/dist/chunks/clip-command-MDSM6KJP.js +0 -3
- package/dist/chunks/clipboard-IZJTBTSW.js +0 -3
- package/dist/chunks/colour-2MYODUDY.js +0 -3
- package/dist/chunks/command-GAGAD65W.js +0 -3
- package/dist/chunks/config-command-CKPJXJEE.js +0 -3
- package/dist/chunks/continue-editing-M6WESEVB.js +0 -3
- package/dist/chunks/decoded-XWKU23RG.js +0 -3
- package/dist/chunks/execute-7M6WA4W7.js +0 -3
- package/dist/chunks/extensions-E3OUBT36.js +0 -3
- package/dist/chunks/ffmpeg-KDZEPLNA.js +0 -3
- package/dist/chunks/image-R5C3AWHT.js +0 -3
- package/dist/chunks/install-MFYGS5TG.js +0 -3
- package/dist/chunks/launch-VNW4YQ4Z.js +0 -17
- package/dist/chunks/lock-BG3CLOHA.js +0 -3
- package/dist/chunks/manager-L753MI7U.js +0 -4
- package/dist/chunks/notify-NQNNOBFC.js +0 -3
- package/dist/chunks/pdfium-77L526HZ.js +0 -3
- package/dist/chunks/preferences-3P4V2EDX.js +0 -3
- package/dist/chunks/preset-command-UNMXHW5A.js +0 -3
- package/dist/chunks/registry-RS7LQ3UA.js +0 -3
- package/dist/chunks/run-GUFPETHF.js +0 -3
- package/dist/chunks/server-PIXRL5PA.js +0 -77
- package/dist/chunks/text-layer-LHZNDMPZ.js +0 -3
- package/dist/chunks/theme-P3ZE2ZYB.js +0 -3
- package/dist/chunks/transcribe-KXQXEVBJ.js +0 -3
- package/dist/chunks/transcribe-command-JHWN4RWU.js +0 -3
- package/dist/chunks/update-command-DWEBUFT5.js +0 -3
- package/dist/chunks/update-note-CY3LCBCJ.js +0 -3
- package/dist/chunks/watch-command-QGVXM23I.js +0 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d}from"./chunk-2YU4EI24.js";import"./chunk-S44LAUHZ.js";import"./chunk-PON65UTS.js";import"./chunk-JZM37DG2.js";import"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{a as SIGNAL_EXIT,b as dieBy,d as endLeftoverWork,c as stopOnSignals};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import"./chunk-TMUK2DD3.js";function H(e,t,n){if(Math.abs(e.length-t.length)>n)return n+1;let s=Array.from({length:t.length+1},(i,o)=>o);for(let i=1;i<=e.length;i++){let o=[i],h=i;for(let l=1;l<=t.length;l++){let f=Math.min(s[l]+1,o[l-1]+1,s[l-1]+(e[i-1]===t[l-1]?0:1));o.push(f),f<h&&(h=f)}if(h>n)return n+1;s=o}return s[t.length]}function T(e){let t=e.normalize("NFKC").match(/[\p{L}\p{N}][\p{L}\p{N}'’-]*/gu)??[];return new Set(t)}var P=e=>e>=8?2:e>=4?1:0;function $(e,t){if(t.size===0)return e;let n=e.split(/\s+/).filter(Boolean),s=[],i=0;for(;i<n.length;){let o=0,h="";for(let l=3;l>=1&&o===0;l--){if(i+l>n.length)continue;let f=n.slice(i,i+l),d=f.join(""),a=/^[^\p{L}\p{N}]*/u.exec(d)?.[0]??"",r=/[^\p{L}\p{N}]*$/u.exec(d.slice(a.length))?.[0]??"",c=d.slice(a.length,d.length-r.length);if(c.length<3)continue;if(l===1&&t.has(c))break;let g,B=1/0;for(let m of t){let L=H(c,m,P(m.length));L<=P(m.length)&&L<B&&(g=m,B=L)}g!==void 0&&(l===1||!f.every(m=>t.has(m)))&&(o=l,h=a+g+r)}o>0?(s.push(h),i+=o):(s.push(n[i]),i++)}return s.join(" ")}function O(e,t){let n=T(t);if(n.size===0)return e;let s=o=>$(o,n),i=e.blocks.map(o=>o.kind==="text"?{...o,text:s(o.text)}:o.kind==="list"?{...o,items:o.items.map(h=>({...h,text:s(h.text)}))}:{...o,rows:o.rows.map(h=>h.map(s))});return{...e,blocks:i}}var z=.5,M=e=>e.box!==void 0&&e.box[2]!==e.box[0],S=e=>/\S/u.test(e.char),v=e=>{let t=e.codePointAt(0)??0;return t<32&&e!==" "&&e!==`
|
|
4
|
+
`&&e!=="\r"||t===65533||t>=57344&&t<=63743||t>=983040},_=.1,I=e=>{let t=[...e].sort((n,s)=>n-s);return t[Math.floor(t.length/2)]??0};function N(e){let t=e.filter(M);if(t.some(S))return{text:e.map(n=>n.char).join("").replace(/\s+/gu," ").trim(),left:Math.min(...t.map(n=>n.box[0])),right:Math.max(...t.map(n=>n.box[2])),top:Math.max(...t.map(n=>n.box[1])),bottom:Math.min(...t.map(n=>n.box[3]))}}function D(e){let t=[[]],n;for(let i of e){if(i.char==="\r"||i.char===`
|
|
5
|
+
`){(t.at(-1)?.length??0)>0&&t.push([]),n=void 0;continue}if(M(i)&&n&&S(i)){let o=(i.box[1]+i.box[3])/2;(o>n.box[1]||o<n.box[3])&&t.push([])}t.at(-1)?.push(i),M(i)&&S(i)&&(n=i)}let s=[];for(let i of t){let o=I(i.filter(M).map(a=>a.box[1]-a.box[3])),h=[[]],l;for(let a of i)M(a)&&S(a)&&((l?Math.max(a.box[0]-l.box[2],l.box[0]-a.box[2]):Number.NEGATIVE_INFINITY)>o&&h.push([]),l=a),h.at(-1)?.push(a);let f=h.map(N).filter(a=>a!==void 0),d=N(i);d&&f.length>0&&s.push({...d,text:f.map(a=>a.text).join(" "),cells:f,height:o})}return s}var E=(e,t)=>e.left<t.right&&t.left<e.right,R=(e,t)=>e.cells.length>=2&&e.cells.length===t.cells.length&&e.cells.every((n,s)=>{let i=t.cells[s];return i!==void 0&&E(n,i)}),C=/^(?:([•◦▪‣●○■□\-–—*])|(\d{1,3}|[a-zA-Z])[.)])\s+(.*)$/u,j=(e,t)=>{let n=Math.max(e.height,t.height),s=e.bottom-t.top;return s>-n/2&&s<.8*n&&Math.abs(e.height-t.height)<=.15*n&&E(e,t)};function A(e,t){return/[\p{Ll}]-$/u.test(e)&&new RegExp("^\\p{Ll}","u").test(t)?e.slice(0,-1)+t:`${e} ${t}`}var F=(e,t,n)=>/^[•◦▪‣●○■□\-–—*]\s/u.test(e)||C.test(e)&&(/[.:;!?)]$/u.test(t.text)||t.right<n-2*t.height);function U(e){if((e.picture??0)>=z)return;let t=e.chars.filter(r=>M(r)&&S(r));if(t.length===0||t.filter(r=>r.hidden).length>t.length/2||t.filter(r=>v(r.char)).length>t.length*_)return;let n=D(e.chars),s=r=>[r.left/e.width,1-r.top/e.height,(r.right-r.left)/e.width,(r.top-r.bottom)/e.height],i=r=>({text:"",left:Math.min(...r.map(c=>c.left)),right:Math.max(...r.map(c=>c.right)),top:Math.max(...r.map(c=>c.top)),bottom:Math.min(...r.map(c=>c.bottom))}),o=[];for(let r=0;r<n.length;){let c=n[r],g=r+1;for(;g<n.length&&R(n[g],n[g-1]);)g++;if(g-r>=2&&c.cells.length>=2){let u=n.slice(r,g);o.push({kind:"table",rows:u.map(x=>x.cells.map(p=>p.text)),box:s(i(u))}),r=g;continue}if(C.exec(c.text)){let u=[],x=[],p=r;for(;p<n.length;p++){let k=n[p],b=C.exec(k.text);if(b){let w=b[1]?b[1]==="-"||b[1]==="\u2013"||b[1]==="\u2014"?"hyphen":"bullet":/\d/.test(b[2]??"")?"decimal":/[a-z]/.test(b[2]??"")?"lowercase":"uppercase";u.push({marker:w,text:b[3]??""})}else if(x.length>0&&k.left>c.left&&j(x.at(-1),k)){let w=u.at(-1);w&&(w.text=A(w.text,k.text))}else break;x.push(k)}o.push({kind:"list",items:u,box:s(i(x))}),r=p;continue}let m=[c],L=c.text,y=r+1;for(;y<n.length;){let u=n[y],x=m.at(-1),p=Math.max(...m.map(k=>k.right));if(!j(x,u)||F(u.text,x,p)||u.cells.length>1||R(n[y+1]??u,u)&&y+1<n.length)break;L=A(L,u.text),m.push(u),y++}o.push({kind:"text",text:L,title:!1,lines:m.length,lineHeight:I(m.map(u=>u.height))/e.height,box:s(i(m))}),r=y}let h=o.filter(r=>r.kind==="text"),l=Math.max(...h.map(r=>r.lineHeight)),f=h.filter(r=>r.lineHeight===l),d=h.filter(r=>r.lineHeight!==l),a=f[0];return f.length===1&&a&&a.lines===1&&d.every(r=>r.lineHeight*1.05<l)&&(a.title=!0),{blocks:o}}export{H as distance,U as layerPage,T as layerWords,$ as mendLine,O as mendPage};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w}from"./chunk-H332YFSO.js";import"./chunk-TMUK2DD3.js";export{u as BAR,c as DARK,f as FIRST_RUN,d as LIGHT,h as MODE_KEYS,k as MODE_MARKERS,g as MODE_ORDER,e as NEUTRAL,b as SYMBOLS,a as VERSION,w as applyColourPreference,v as colourEnabled,t as colourProp,o as dotGradient,p as menuPalette,l as modeColours,j as modeForKey,m as modeGradient,q as modePalette,n as modeWash,r as paintsCanvas,s as paletteFor,i as tabStep};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i,o as j,p as k,q as l,r as m,s as n}from"./chunk-BQV3DSUZ.js";import"./chunk-FEJSM3E4.js";import"./chunk-OLKPV4WO.js";import"./chunk-HZDYZ5RD.js";import"./chunk-BSFBZBAI.js";import"./chunk-W6QOV4RP.js";import"./chunk-PON65UTS.js";import"./chunk-KXKQDFHX.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{h as appleDoes,e as chooseHearing,c as helperPaths,d as helpers,b as notesNeed,i as probeSound,l as readRefusal,m as renderPages,n as renderTranscript,k as runRead,j as runTranscribe,a as transcribeNeeds,f as transcribeStatus,g as whisperUseful};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{a as U,b as at}from"./chunk-F4TUCI6D.js";import{a as S,b as st,c as L}from"./chunk-XUJLUOGD.js";import{c as ot}from"./chunk-6PUV4HSU.js";import"./chunk-3OCPO5V6.js";import{a as H,b as J,c as Q,d as V,f as X,g as Y,k as R,o as Z,p as tt,q as et,r as rt,s as nt}from"./chunk-BQV3DSUZ.js";import{b as z}from"./chunk-3IAJTXYM.js";import"./chunk-PXCEMDOY.js";import"./chunk-FEJSM3E4.js";import"./chunk-OLKPV4WO.js";import"./chunk-TQEGSODD.js";import"./chunk-O7DK3GJT.js";import"./chunk-S44LAUHZ.js";import"./chunk-ULX4ZD2Y.js";import"./chunk-HZDYZ5RD.js";import{c as N}from"./chunk-BSFBZBAI.js";import"./chunk-W6QOV4RP.js";import"./chunk-7NP76V4U.js";import{b as I,c as q}from"./chunk-DC2DHMXO.js";import"./chunk-PON65UTS.js";import"./chunk-JPASVE56.js";import"./chunk-SJIDFYPT.js";import{a as x,w as F}from"./chunk-JZM37DG2.js";import"./chunk-DKHBJ52G.js";import"./chunk-KXKQDFHX.js";import{a as W,d as _}from"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import{Ga as B,H as k,Ja as P,La as D,Na as G,Oa as K,Q as C,i as O,j}from"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import{c as E}from"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";import{existsSync as A}from"node:fs";import{stat as pt}from"node:fs/promises";import{basename as h,dirname as dt,extname as y,join as it,resolve as w}from"node:path";function lt(t){if(t.format)return t.format;let e=t.output;if(e===void 0||x(e))return"md";let r=y(e).toLowerCase();return W.find(s=>s.ext===r)?.id??"md"}function v(t,e,r,s){let a=`${t}${_(s)}`;return r===void 0?it(e,a):x(r)?it(w(r),a):w(r)}function At(t){return t.kind==="model"?`downloading speech model, ${Math.round(t.fraction*100)}%`:t.kind==="heard"?`heard ${S(t.seconds)} of ${S(t.of)}`:t.kind==="notes"?`writing notes, part ${t.part} of ${t.of}`:`page ${t.page} of ${t.of}`}var ct=t=>t.split(/\s+/).filter(Boolean).length,gt=t=>t.segments.reduce((e,r)=>e+ct(r.text),0);async function mt(t){let{probe:e}=await import("./registry-657JRJR5.js"),r=await e(t).catch(()=>{throw B(t)});return at(r)}async function ht(t,e,r,s){if(e.to!==void 0)throw C(h(t.path));if(!(await R())?.read)throw await et();let n=v(h(t.path,y(t.path)),dt(t.path),e.output,s);if(A(n)&&!e.force)throw k(n);r.onStart?.("read");let u=await tt(t.path,{language:e.language,signal:r.signal,onEvent:r.onProgress}),o=H(u);if(!J(o))throw D(t.path);let c=[];await F(n,await rt(o,s,h(t.path),{signal:r.signal,lang:e.language,onMissing:i=>{c=i}})),r.document?.({path:n,markdown:Q(o)});let p=t.what==="pdf"?`${t.pages} ${t.pages===1?"page":"pages"}`:y(t.path).slice(1).toUpperCase()||"picture";return r.out(`\u2713 ${E(n)} ${p} \u2192 ${ct(V(o)).toLocaleString("en-US")} words`),c.length>0&&r.err(`\u26A0 ${N(c).message}`),r.finished?.({made:[{from:[t.path],to:[n]}],failed:[]}),0}async function Mt(t,e){try{let r=I(t.input),s=q(r);if(s)throw s;let a=r?.kind==="video"?r:void 0,n,u,o,c,p=lt(t);if(a===void 0){if(n=w(t.input),!(await pt(n).catch(()=>{}))?.isFile())throw j(n);let f=await ot(n);if(f!=="video"&&f!=="audio"){let m=await mt(n);if(m)return await ht(m,t,e,p)}}let i=await R(t.language?{locale:t.language}:{});if(i===void 0||!i.speech)throw P(X(process.platform,i?.missing));let ft=U(i.locale),b=t.notes&&i.notes==="available"&&ft,g=!t.notes||b?void 0:i.notes!=="available"?i.notes:"language";if(t.notes&&!b&&g!=="language"){if(!t.transcript)throw P(Y(process.platform,i.notes));i.notes==="off"&&e.err("\u26A0 Apple Intelligence is off, so this is the transcript only.")}if(a===void 0){if(n=w(t.input),u={title:h(n,y(n)),from:h(n)},o=v(u.title,dt(n),t.output,p),A(o)&&!t.force)throw k(o)}else{let l=new AbortController;e.signal?.addEventListener("abort",()=>l.abort(e.signal?.reason),{once:!0});let f;c=await z(a.url,{signal:l.signal,onEvent:m=>{m.kind==="facts"&&(f=v(L(m.facts.title),process.cwd(),t.output,p),A(f)&&!t.force&&l.abort(k(f)))}}),n=c.path,u={title:c.facts.title,from:a.url},o=f??v(L(c.facts.title),process.cwd(),t.output,p)}let d;try{e.onStart?.("transcribe"),d=await Z(n,{notes:b,detail:t.detail,locale:t.language,signal:e.signal,onEvent:e.onProgress})}finally{await c?.dispose()}if(d.notes&&!U(d.locale)){let{notes:l,...f}=d;d=f,g="language"}b&&!d.notes&&g===void 0&&(g="too-short");let M=st(d,u,{transcript:t.transcript}),T=[];await F(o,await nt(M,p,{signal:e.signal,lang:d.locale,onMissing:l=>{T=l}})),e.document?.({path:o,markdown:M,...g?{notesSkipped:g}:{}});let $=d.notes?.parts.length,ut=$===void 0?"":` \xB7 ${$} ${$===1?"part":"parts"}`;return e.out(`\u2713 ${E(o)} ${S(d.seconds)} \u2192 ${gt(d).toLocaleString("en-US")} words${ut}`),T.length>0&&e.err(`\u26A0 ${N(T).message}`),e.finished?.({made:[{from:[a===void 0?n:u.title],to:[o]}],failed:[]}),0}catch(r){let s=O(r)?r:G(r);for(let n of K(s,{debug:t.debug}))e.err(n);let a=I(t.input)===void 0?w(t.input):"";return e.finished?.({made:[],failed:[{path:a,message:s.message}]}),1}}export{Mt as runTranscribeCommand,At as transcribeFact};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{ga as a}from"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";async function d(i,n={}){let e=n.check??(async()=>(await import("./check-BFHBPCGW.js")).checkNow()),s=n.install??(async r=>(await import("./install-XJAPLIH2.js")).installUpdate(r)),t=await e();if(t===void 0)throw a();let{isNewer:o}=await import("./check-BFHBPCGW.js");return o(t,i)?(n.onInstalling?.(t),await s(t),{stdout:[`\u2713 Forge ${t} is installed. It runs from your next forge.`],data:{current:i,latest:t,installed:!0}}):{stdout:[`\u2713 Forge ${i} is the latest.`],data:{current:i,latest:t,installed:!1}}}export{d as runUpdate};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{b as m,c as w,d as h,i as l,j as p,k as b}from"./chunk-M7HB4L6L.js";import{c as $,d as g}from"./chunk-H332YFSO.js";import{e as u}from"./chunk-ZL7E7PZN.js";import"./chunk-4AL5QJLM.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";import{spawn as x}from"node:child_process";var P=60;function v(t,n){let e=Number.parseInt(t.slice(1),16);return`\x1B[${n};2;${e>>16&255};${e>>8&255};${e&255}m`}function C(t,n,e){let i=[" \u2191 ",`Forge ${t} is available`,` \xB7 your version ${n}`],r=[" In terminal: ","forge update"];if(e===void 0)return[i.join(""),r.join("")];let s=v(e.newTagBg,48),o=f=>v(f,38),c="\x1B[1m",a="\x1B[0m",d=f=>" ".repeat(Math.max(0,P-f.join("").length));return[`${s}${o(e.newTag)}${c}${i[0]}${o(e.fg)}${i[1]}${a}${s}${o(e.dim)}${i[2]}${d(i)}${a}`,`${s}${o(e.dim)}${r[0]}${o(e.fg)}${c}${r[1]}${a}${s}${d(r)}${a}`]}async function I(t,n){let e=n.now??Date.now(),{prefs:i}=await u();if(!h(i,n.env??process.env))return[];let r=await l();b(r,e)&&n.refresh();let s=r?.latest;if(r===void 0||s===void 0||!w(s,t))return[];let o=r.notifiedAt;if(o!==void 0&&o<=e&&e-o<=m)return[];await p({...r,notifiedAt:e}).catch(()=>{});let c=n.colour?i.theme==="light"?g:$:void 0;return C(s,t,c)}function N(t,n=process.platform,e=x){if(t!==void 0)try{e(process.execPath,[...process.execArgv,t,"__update-check"],{detached:!0,stdio:"ignore",...n==="win32"?{windowsHide:!0}:{}}).unref()}catch{}}export{I as afterCommand,C as noteLines,N as spawnRefresh};
|
|
@@ -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-3IAJTXYM.js";import"./chunk-PXCEMDOY.js";import"./chunk-FEJSM3E4.js";import"./chunk-OLKPV4WO.js";import"./chunk-DC2DHMXO.js";import"./chunk-PON65UTS.js";import"./chunk-HON4OV7M.js";import"./chunk-PNPAHKJR.js";import"./chunk-FGR6QCG5.js";import"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";export{f as byteCounter,b as fetchSound,c as fetchVideo,d as linkArgs,e as readFacts,a as ytDlpMissing};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
+
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
+
import{c as R,d as k}from"./chunk-OPDC577C.js";import{a as W,d as N}from"./chunk-6PUV4HSU.js";import"./chunk-42IEPG2K.js";import"./chunk-YXV3PYVI.js";import"./chunk-56QHX7QR.js";import"./chunk-3OCPO5V6.js";import"./chunk-Z3PQ5TMU.js";import{d as w,e as h}from"./chunk-YJ6XLDRA.js";import"./chunk-63XCSYHM.js";import"./chunk-TQEGSODD.js";import"./chunk-O7DK3GJT.js";import"./chunk-S44LAUHZ.js";import"./chunk-ULX4ZD2Y.js";import"./chunk-BSFBZBAI.js";import"./chunk-W6QOV4RP.js";import{a as S}from"./chunk-H332YFSO.js";import"./chunk-7NP76V4U.js";import"./chunk-PON65UTS.js";import"./chunk-JPASVE56.js";import"./chunk-SJIDFYPT.js";import"./chunk-JZM37DG2.js";import"./chunk-DKHBJ52G.js";import"./chunk-KXKQDFHX.js";import"./chunk-ZL7E7PZN.js";import"./chunk-4AL5QJLM.js";import"./chunk-NUCGWLOY.js";import"./chunk-I2LPGKUU.js";import"./chunk-HON4OV7M.js";import{Oa as E,S as L,d as F,i as M,j as I}from"./chunk-PNPAHKJR.js";import{a as A}from"./chunk-FGR6QCG5.js";import{c as a}from"./chunk-VLVNA4T3.js";import"./chunk-TMUK2DD3.js";import{readdir as T,stat as B}from"node:fs/promises";import{join as C,resolve as y}from"node:path";function K(r,t,s,n){return[`\u2713 ${r} converted${n?` to ${n}`:""}`,...t?[`${t} failed`]:[],...s?[`${s} left alone`]:[]].join(" \xB7 ")}var P=r=>{let[t,...s]=r.job.outputs,n=`${a(t??"")}${s.length?` + ${s.length} more`:""}`;return`\u2713 ${a(r.job.sources[0].path)} \u2192 ${n} ${A(r.outputBytes)}`},O=(r,t)=>`\u2715 ${a(r)} ${t.title.toLowerCase()}`,D=r=>`\u2013 ${a(r.path)} ${r.reason}`;async function _(r,t){let s=y(r.folder),n=(e,o)=>t.out(JSON.stringify({forge:S,event:e,...o}));try{let e=await B(s).catch(()=>{});if(!e)throw I(s);if(!e.isDirectory())throw L(`${a(s)} is not a folder.`,`forge watch watches a folder. Try: forge watch ${a(y(s,".."))} --to ${r.target}`)}catch(e){if(!M(e))throw e;if(t.json)n("error",{ok:!1,failures:[h({error:e})]});else for(let o of E(e,{debug:r.debug}))(t.err??t.out)(o);return e.code==="invalid-arguments"?2:1}let m={target:r.target,...r.quality===void 0?{}:{quality:r.quality},dpi:r.dpi??150},$={images:m,pdfs:m,documents:m},c=r.output===void 0?void 0:y(r.output),q=F[r.target].label,p=0,i=[],u=[],b=new Set,g;if(r.newOnly)g=(await T(s,{withFileTypes:!0})).filter(o=>o.isFile()&&!W(o.name)).map(o=>C(s,o.name));else{let e=await N(s);g=e.paths;let o=await R(e,$,{destination:c});b=o.claimed;let f=[...e.failures,...o.outcome.refusals,...o.outcome.failures],j=e.kinds.flatMap(l=>l.why?[{count:l.count,why:l.why}]:[]),J=o.left.length+j.reduce((l,d)=>l+d.count,0);if(p+=o.outcome.results.length,i.push(...f),u.push(...o.left),t.json)n("converted-existing",{ok:f.length===0,results:o.outcome.results.map(w),failures:f.map(h),leftAlone:o.left});else if(e.paths.length>0){t.out(K(o.outcome.results.length,f.length,J,q));for(let l of f)t.out(O(l.path,l.error))}for(let l of j)for(let d=0;d<l.count;d++)u.push({path:"",reason:l.why})}t.json?n("watching",{folder:s,...c?{output:c}:{}}):t.out(`Watching ${a(s)} \xB7 any new files you add will be converted \xB7 ctrl-c to stop`);let x=k({dir:s,answers:$,known:g,claimed:b,destination:c,...t.settleMs===void 0?{}:{settleMs:t.settleMs},...t.pollMs===void 0?{}:{pollMs:t.pollMs},onEvent:e=>{e.type==="converted"?(p++,t.json?n("converted",{result:w(e.result)}):t.out(P(e.result))):e.type==="failed"?(i.push({path:e.path,error:e.error}),t.json?n("failed",{failure:h({path:e.path,error:e.error})}):t.out(O(e.path,e.error))):e.type==="left"&&(u.push({path:e.path,reason:e.reason}),t.json?n("left-alone",{path:e.path,reason:e.reason}):t.out(D({path:e.path,reason:e.reason})))}});return await new Promise(e=>{t.signal.aborted?e():t.signal.addEventListener("abort",()=>e(),{once:!0})}),await x.stop(),t.json?n("stopped",{converted:p,failed:i.length,leftAlone:u.length}):t.out(K(p,i.length,u.length)),i.length>0?1:0}export{_ as runWatch};
|
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
3
3
|
const require = __forgeCreateRequire(import.meta.url);
|
|
4
|
-
import{
|
|
5
|
-
`):process.stderr.write(` ${
|
|
6
|
-
`)}async function
|
|
4
|
+
import{b as f,d as S}from"./chunks/chunk-IBPGC4N2.js";import{e as N,f as v,g as E}from"./chunks/chunk-SCJ2QXZF.js";import"./chunks/chunk-EYOO35US.js";import"./chunks/chunk-72UR37EG.js";import"./chunks/chunk-Z3PQ5TMU.js";import{g as C}from"./chunks/chunk-YJ6XLDRA.js";import"./chunks/chunk-63XCSYHM.js";import"./chunks/chunk-TQEGSODD.js";import{b as P}from"./chunks/chunk-O7DK3GJT.js";import{c as F}from"./chunks/chunk-S44LAUHZ.js";import"./chunks/chunk-ULX4ZD2Y.js";import"./chunks/chunk-HZDYZ5RD.js";import"./chunks/chunk-BSFBZBAI.js";import"./chunks/chunk-W6QOV4RP.js";import{a as d}from"./chunks/chunk-H332YFSO.js";import"./chunks/chunk-7NP76V4U.js";import"./chunks/chunk-OQ6DTE56.js";import"./chunks/chunk-DC2DHMXO.js";import"./chunks/chunk-PON65UTS.js";import"./chunks/chunk-JPASVE56.js";import"./chunks/chunk-SJIDFYPT.js";import"./chunks/chunk-JZM37DG2.js";import"./chunks/chunk-DKHBJ52G.js";import"./chunks/chunk-KXKQDFHX.js";import"./chunks/chunk-ZL7E7PZN.js";import"./chunks/chunk-4AL5QJLM.js";import"./chunks/chunk-NUCGWLOY.js";import"./chunks/chunk-I2LPGKUU.js";import"./chunks/chunk-HON4OV7M.js";import{Na as $,Oa as h,T,i as g}from"./chunks/chunk-PNPAHKJR.js";import"./chunks/chunk-FGR6QCG5.js";import"./chunks/chunk-VLVNA4T3.js";import"./chunks/chunk-TMUK2DD3.js";import*as M from"node:module";function y(r){return g(r)?r:$(r)}function I(r,n){return h(y(r),{debug:n})}function j(r,n){process.once("beforeExit",()=>{r()||(n(new Error("Forge stopped before it finished: it was waiting for input that never came.")),process.exitCode=1)})}P();M.enableCompileCache?.();function R({completed:r,total:n}){r===0?process.stderr.write(`Converting ${n} files
|
|
5
|
+
`):process.stderr.write(` ${r}/${n}
|
|
6
|
+
`)}async function U(){let r=process.argv.slice(2),n=r.includes("--debug"),u=v(r);try{if(r[0]==="__update-check"){let{checkNow:e}=await import("./chunks/check-BFHBPCGW.js");await e();return}if(r[0]==="menu"||r[0]==="mcp"){let e=N(r);if(e!==void 0){process.stdout.write(e);return}}if(r[0]==="menu"){let{openedForClick:e,parseMenuArgs:o}=await import("./chunks/command-JTK4IOS7.js"),i=o(r.slice(1));if(i.kind==="open"){let{applyColourPreference:p}=await import("./chunks/theme-FVQOSLPB.js");p();let{bootShell:_}=await import("./chunks/boot-PHDTJAFT.js");await _(void 0,{opened:await e(i.action,i.paths)});return}let{runMenuCommand:a}=await import("./chunks/entry-ZF7D32ZI.js");process.exitCode=await a(i,d);return}if(r[0]==="mcp"){let{runMcpServer:e}=await import("./chunks/server-6PH2DSFW.js");await e(r.slice(1));return}let t=E(r);if(t.kind==="shell"){if(u)throw T("Pass a file, for example: forge photo.jpg --to webp --json");if(!process.stdout.isTTY||!process.stdin.isTTY){process.stderr.write(`Forge needs a file and a target format.
|
|
7
7
|
Try: forge photo.jpg --to webp
|
|
8
|
-
`),process.exitCode=2;return}let{applyColourPreference:
|
|
9
|
-
`),
|
|
10
|
-
`));return}let{
|
|
11
|
-
|
|
8
|
+
`),process.exitCode=2;return}if(process.env.TERM==="dumb"){E(["--help"]);return}let{applyColourPreference:e}=await import("./chunks/theme-FVQOSLPB.js");e();let{bootShell:o}=await import("./chunks/boot-PHDTJAFT.js");await o(void 0,{menuNote:async()=>(await import("./chunks/entry-ZF7D32ZI.js")).menuAtStart(d)});return}if(t.kind==="watch"){let{runWatch:e}=await import("./chunks/watch-command-3C4AWM7A.js"),{stopOnSignals:o}=await import("./chunks/signals-VY2XE3LV.js"),i=new AbortController,a=o(()=>i.abort(),{graceful:["SIGINT"]});process.exitCode=await e(t,{out:p=>process.stdout.write(`${p}
|
|
9
|
+
`),err:p=>process.stderr.write(`${p}
|
|
10
|
+
`),json:u,signal:i.signal}),a();return}if(t.kind==="uninstall"){let{runUninstall:e}=await import("./chunks/entry-ZF7D32ZI.js");process.exitCode=await e(d,o=>process.stdout.write(`${o}
|
|
11
|
+
`));return}let{execute:m}=await import("./chunks/execute-RP7ZMWLZ.js"),s,b,k=0,D=(e,o)=>{let i=Date.now();if(e<o&&i-k<100)return;k=i;let a=p=>(p/1e6).toFixed(1);process.stderr.write(`\r downloading ${a(e)} / ${a(o)} MB${e>=o?`
|
|
12
|
+
`:""}`)},l=!!process.stderr.isTTY&&!u,w=new AbortController,{stopOnSignals:O,SIGNAL_EXIT:L}=await import("./chunks/signals-VY2XE3LV.js"),x,Y=O(e=>{x=e,w.abort()},{graceMs:1e3}),G=Date.now(),c=await m(t,{json:u,...l?{onInstalling:e=>{s=f(process.stderr,`installing Forge ${e}`)}}:{},signal:w.signal,...l?{onDownload:D}:{},colour:!!process.stdout.isTTY&&!u&&S(),onProgress:l?e=>{e.completed>0&&s?.stop(),R(e)}:void 0,...l?{onSearch:e=>{s??=f(process.stderr,"finding the smallest that fits"),s.update(e)},onEncode:e=>{s??=f(process.stderr,"encoding"),s.update(e)},onLinkDownload:e=>{if(e===void 0){s?.stop(),s=void 0;return}s??=f(process.stderr,"downloading"),s.update(e)},onTranscribe:(e,o)=>{s??=f(process.stderr,e),s.update(o),b??=setInterval(()=>s?.tick(),1e3),b.unref()}}:{}});if(clearInterval(b),Y(),s?.stop(),c.stdout.length>0&&process.stdout.write(`${c.stdout.join(`
|
|
12
13
|
`)}
|
|
13
|
-
`),
|
|
14
|
+
`),c.stderr.length>0&&process.stderr.write(`${c.stderr.join(`
|
|
14
15
|
`)}
|
|
15
|
-
`),process.exitCode=
|
|
16
|
-
${
|
|
16
|
+
`),process.exitCode=x?L[x]:c.exitCode,l&&c.notice&&!w.signal.aborted){let{postFinishNotice:e}=await import("./chunks/notify-UD7FQAWX.js");await e(c.notice,Date.now()-G)}if(l&&process.stdout.isTTY&&t.kind!=="update"&&!w.signal.aborted)try{let{afterCommand:e,spawnRefresh:o}=await import("./chunks/update-note-LV7G4CHE.js"),{runningScript:i}=await import("./chunks/install-XJAPLIH2.js"),a=await e(d,{refresh:()=>o(i(process.argv[1])),colour:S()});a.length>0&&process.stderr.write(`
|
|
17
|
+
${a.join(`
|
|
17
18
|
`)}
|
|
18
|
-
`)}catch{}}catch(
|
|
19
|
-
`):process.stderr.write(`${
|
|
19
|
+
`)}catch{}}catch(t){if(g(t)){u?process.stdout.write(`${JSON.stringify(C(d,t))}
|
|
20
|
+
`):process.stderr.write(`${h(t,{debug:n}).join(`
|
|
20
21
|
`)}
|
|
21
|
-
`),process.exitCode=2;return}if(
|
|
22
|
-
`);return}process.stderr.write(`${
|
|
22
|
+
`),process.exitCode=2;return}if(t instanceof Error&&"code"in t&&"exitCode"in t){let m=t.code;process.exitCode=m==="commander.helpDisplayed"||m==="commander.version"?0:2;return}throw t}}function B(r){let n=process.argv.slice(2);if(v(n)){process.stdout.write(`${JSON.stringify(C(d,y(r)))}
|
|
23
|
+
`);return}process.stderr.write(`${I(r,n.includes("--debug")).join(`
|
|
23
24
|
`)}
|
|
24
|
-
`)}var
|
|
25
|
+
`)}process.on("exit",F);function A(r){r.on("error",n=>{if(n.code!=="EPIPE")throw n;process.exit()})}process.argv[2]!=="mcp"&&(A(process.stdout),A(process.stderr));var J=!1;j(()=>J,B);try{await U()}catch(r){B(r),process.exitCode=1}finally{J=!0}export{d as VERSION};
|
package/package.json
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "forge-terminal",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "A terminal-native file converter for macOS, Windows and Linux",
|
|
5
5
|
"whatsNew": [
|
|
6
6
|
{
|
|
7
|
-
"title": "
|
|
8
|
-
"text": "
|
|
7
|
+
"title": "Videos from links",
|
|
8
|
+
"text": "Paste a link from YouTube, Instagram, TikTok, X and more, and it works like a dropped video: convert it, shrink it, trim it or transcribe it."
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"title": "Download in Edit",
|
|
12
|
+
"text": "Edit → Download saves a link's video as the site sent it, named after its title. On the command line, forge <link> does the same."
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"title": "Signed-in sites",
|
|
16
|
+
"text": "Sites that want you signed in, like Instagram, can borrow your browser's sign-in. Forge asks once and remembers it for that site."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"title": "Smoother colours",
|
|
20
|
+
"text": "On a scale, type a new colour without #. ⇧→ starts a gradient, and the bar no longer fills up with every colour you tried."
|
|
9
21
|
}
|
|
10
22
|
],
|
|
11
23
|
"keywords": [
|
package/skills/forge/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: forge
|
|
3
|
-
description: Convert, compress and edit local files with the Forge CLI (`forge`) — images (HEIC, camera RAW, JPEG, PNG, WebP, AVIF, GIF, TIFF), PDFs, Word documents, video and sound — and hear or read what an agent cannot. Use when the user wants a file in another format, smaller or under a size limit, or cropped to a shape; a PDF merged, split, trimmed or rotated; what a recording, meeting or
|
|
3
|
+
description: Convert, compress and edit local files with the Forge CLI (`forge`) — images (HEIC, camera RAW, JPEG, PNG, WebP, AVIF, GIF, TIFF), PDFs, Word documents, video and sound — and hear or read what an agent cannot. Use when the user wants a file in another format, smaller or under a size limit, or cropped to a shape; a PDF merged, split, trimmed or rotated; what a recording, meeting or online video says; a video saved from a link (YouTube, Instagram, TikTok, X…); the text in a picture, scan or PDF; or a colour palette, tonal scale or named colours as a card to paste into Figma — and `forge` is installed (`npm i -g forge-terminal`).
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Forge
|
|
@@ -13,8 +13,12 @@ Forge converts files on this computer. Nothing is uploaded.
|
|
|
13
13
|
`--max-size 5mb`. A set width: `--width 1200`.
|
|
14
14
|
- **A format you cannot open** (HEIC, camera RAW, Word): convert it to PNG,
|
|
15
15
|
JPEG or PDF and read that.
|
|
16
|
-
- **What a recording, meeting or
|
|
16
|
+
- **What a recording, meeting or online video says:** `forge transcribe`,
|
|
17
17
|
then read the Markdown file it writes.
|
|
18
|
+
- **A video from a link** (YouTube, Instagram, TikTok, X…): `forge '<link>'`
|
|
19
|
+
saves it in the current folder; a link also goes anywhere a file goes
|
|
20
|
+
(`--to gif`, `compress --max-size 25mb`). A site that wants a sign-in:
|
|
21
|
+
`--cookies-from-browser chrome` (or safari, firefox, brave, edge).
|
|
18
22
|
- **The text in a picture, screenshot, scan or PDF:** `forge transcribe` on
|
|
19
23
|
it reads the text instead.
|
|
20
24
|
- **Colours for Figma:** `forge card`, `forge scale` or `forge palette` with
|
|
@@ -98,7 +102,7 @@ never edit the original.
|
|
|
98
102
|
```bash
|
|
99
103
|
forge transcribe meeting.m4a # summary, notes and transcript -> meeting.md
|
|
100
104
|
forge transcribe talk.mp4 --to transcript # no notes; --to notes: no transcript
|
|
101
|
-
forge transcribe 'https://youtu.be/…' # a
|
|
105
|
+
forge transcribe 'https://youtu.be/…' # a video link, into this folder
|
|
102
106
|
forge transcribe talk.mp4 --detail brief --format pdf -o ~/Notes/
|
|
103
107
|
forge transcribe whiteboard.jpg # the text in a picture -> whiteboard.md
|
|
104
108
|
```
|
|
@@ -1,3 +0,0 @@
|
|
|
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-7XDMC7FL.js";import"./chunk-FBVRKMAF.js";import"./chunk-3374PCO5.js";import"./chunk-HZDYZ5RD.js";import"./chunk-N32JL4UI.js";import"./chunk-TGC24JEW.js";import"./chunk-K253E723.js";import"./chunk-EEQSUBBL.js";import"./chunk-OQBIYNGK.js";import"./chunk-FAUL5L2W.js";import"./chunk-HTA25PO2.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-TLHUFIXD.js";import"./chunk-4MJEEEFA.js";import"./chunk-V6GWPR2A.js";import"./chunk-WBW6G4N6.js";import"./chunk-ZBMJTIYR.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 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{r as a}from"./chunk-TGC24JEW.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-VNW4YQ4Z.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};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"./chunk-SZRSAL64.js";import"./chunk-N6RCLJE6.js";import"./chunk-WE6KP4FR.js";import"./chunk-KH5DHZ2U.js";import"./chunk-HON4OV7M.js";import"./chunk-H3DIRJFE.js";import"./chunk-TMUK2DD3.js";export{b as CHECK_EVERY_MS,e as MAX_NOTES,g as NOTE_TEXT,f as NOTE_TITLE,a as REGISTRY_URL,o as availableUpdate,h as cachePath,m as checkNow,l as fetchLatest,c as isNewer,k as isStale,i as readCache,d as updateChecksEnabled,n as whatsNewFor,j as writeCache};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as m}from"./chunk-MF3KKEFB.js";import{V as l}from"./chunk-ZBMJTIYR.js";import{randomBytes as h}from"node:crypto";import{link as y,mkdir as p,readdir as x,readFile as P,rename as E,rm as c,stat as L,writeFile as S}from"node:fs/promises";import{join as u}from"node:path";var b=720*60*1e3,k=600*1e3,M=200,F=600*1e3;function a(){return u(m(),".locks")}function f(t){return u(a(),`${t}.lock`)}function v(t){if(!Number.isInteger(t)||t<=0)return!1;try{return process.kill(t,0),!0}catch(n){return n.code==="EPERM"}}async function s(t){try{let n=JSON.parse(await P(t,"utf8"));return typeof n.pid!="number"||typeof n.token!="string"?void 0:n}catch{return}}async function d(t,n){if(n===void 0||!v(n.pid))return!0;let e=await L(t).catch(()=>{});return e!==void 0&&Date.now()-e.mtimeMs>b}async function D(t){let n=`${t}.stale-${h(4).toString("hex")}`;try{await E(t,n)}catch{return}let e=await s(n);e!==void 0&&!await d(n,e)&&await y(n,t).catch(()=>{}),await c(n,{force:!0})}async function A(){let t=await x(a()).catch(()=>[]);for(let n of t){if(!/\.lock\.(stale-)?[0-9a-f]+$/.test(n))continue;let e=u(a(),n),i=await L(e).catch(()=>{});i&&Date.now()-i.mtimeMs>F&&await c(e,{force:!0})}}async function g(t,n){await p(a(),{recursive:!0});let e=f(t),i={pid:process.pid,token:h(8).toString("hex"),at:Date.now(),...n!==void 0?{what:n}:{}},r=`${e}.${i.token}`;await S(r,JSON.stringify(i),{flag:"wx"});try{for(let o=0;o<2;o++){try{return await y(r,e),i}catch(w){if(w.code!=="EEXIST")throw w}if(!await d(e,await s(e)))return;await D(e)}return}finally{await c(r,{force:!0})}}async function T(t,n){let e=f(t);(await s(e))?.token===n.token&&await c(e,{force:!0})}async function _(t){let n=f(t),e=await s(n);if(!(e===void 0||await d(n,e)))return{pid:e.pid,...e.what!==void 0?{what:e.what}:{}}}async function H(t,n,e={}){let i=Date.now()+(e.waitMs??k);await p(a(),{recursive:!0}),await A();let r=await g(t,e.what);for(r===void 0&&(e.waitMs??k)>0&&e.onWait?.();r===void 0;){if(e.signal?.aborted)throw e.signal.reason??new Error("aborted");if(Date.now()>=i)throw l(t,await _(t),e.action??"run");await new Promise(o=>setTimeout(o,M)),r=await g(t,e.what)}try{return await n()}finally{await T(t,r)}}export{k as a,_ as b,H as c};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{a as y,c as b}from"./chunk-AR3M2PLK.js";import{a as p}from"./chunk-3374PCO5.js";import{j as h}from"./chunk-K253E723.js";import{a as m}from"./chunk-ZBMJTIYR.js";import{a as c}from"./chunk-H3DIRJFE.js";import{open as g,readdir as w,stat as x}from"node:fs/promises";import{extname as S,join as k,resolve as v}from"node:path";function K(e){return e.startsWith(".")||/\.(crdownload|part|download|tmp)$/i.test(e)}function A(e){return e.kind==="image"?"images":e.format==="pdf"?"pdfs":"documents"}var R=new Set(Object.values(c).flatMap(e=>e.extensions));async function O(e){let i=await g(e,"r"),t=Buffer.alloc(4096),r=0;try{r=(await i.read(t,0,t.length,0)).bytesRead}finally{await i.close()}let n=t.subarray(0,r),o=(d,f)=>n.subarray(d,d+f).toString("latin1");return o(4,4)==="ftyp"?/^(M4A |M4B |M4P )$/.test(o(8,4))?"audio":"video":n[0]===26&&n[1]===69&&n[2]===223&&n[3]===163?"video":o(0,4)==="RIFF"?o(8,4)==="WAVE"?"audio":o(8,3)==="AVI"?"video":"other":n[0]===0&&n[1]===0&&n[2]===1&&(n[3]===186||n[3]===179)?"video":o(0,3)==="ID3"||o(0,4)==="fLaC"||o(0,4)==="OggS"||o(0,4)==="FORM"&&/^AIF[FC]$/.test(o(8,4))||n[0]===255&&n[1]!==void 0&&(n[1]&224)===224?"audio":r>0&&!n.includes(0)&&M(n)?"text":"other"}function M(e){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e,{stream:!0}),!0}catch{return!1}}var F=["images","pdfs","documents","videos","audio","other"];function j(e,i){if(e==="videos"||e==="audio")return"not yet supported";if(e==="other")return i.every(t=>t==="text")?i.length===1?"a text file":"text files":"not supported"}async function V(e){let i=v(e),t=await w(i,{withFileTypes:!0}),r=[],n=[],o=new Map,d=[],f=0;for(let s of t.sort((a,u)=>a.name.localeCompare(u.name)))!s.isFile()||K(s.name)||d.push(k(i,s.name));for(let s of await E(d))if(s.kind==="source")r.push(s.source),f+=s.source.bytes;else if(s.kind==="failed")n.push(s.failure),f+=s.bytes;else{let a=s.kind,u=o.get(a)??{bytes:0,sniffed:[]};u.bytes+=s.bytes,u.sniffed.push(s.sniffed),o.set(a,u),f+=s.bytes}let l=I(r);for(let s of F){let a=o.get(s);if(!a)continue;let u=j(s,a.sniffed);l.push({id:s,count:a.sniffed.length,bytes:a.bytes,sources:[],...u===void 0?{}:{why:u}})}return{dir:i,sources:r,failures:n,kinds:l,bytes:f,paths:d}}async function E(e){let i=[];return await b(e,y(),async(t,r)=>{try{i[r]={read:await C(t)}}catch(n){i[r]={error:n}}}),i.map(t=>{if("error"in t)throw t.error;return t.read})}function I(e){let i=[];for(let t of F){let r=e.filter(n=>A(n)===t);r.length>0&&i.push({id:t,count:r.length,bytes:r.reduce((n,o)=>n+o.bytes,0),sources:r})}return i.sort((t,r)=>r.count-t.count)}function W(e,i=[]){let t=e.filter(o=>o.kind==="media"),r=e.filter(o=>o.kind!=="media"),n=I(r);for(let o of["videos","audio"]){let d=t.filter(f=>c[f.format].media==="video"==(o==="videos"));if(d.length>0){let f=d.reduce((l,s)=>l+s.bytes,0);n.push({id:o,count:d.length,bytes:f,sources:[],why:"one at a time"})}}return{dir:"",sources:r,failures:i,kinds:n,bytes:e.reduce((o,d)=>o+d.bytes,0),paths:e.map(o=>o.path)}}async function C(e){let i=()=>x(e).then(t=>t.size,()=>0);try{let t=await h(e);if(t.kind==="media"){let r=c[t.format].media==="video";return{kind:r?"videos":"audio",sniffed:r?"video":"audio",bytes:t.bytes}}return{kind:"source",source:t}}catch(t){let r=await i(),n=await O(e).catch(()=>"other");if(n==="video"||n==="audio")return{kind:n==="video"?"videos":"audio",sniffed:n,bytes:r};if(R.has(S(e).toLowerCase())){let o=m(t)?t:void 0;if(o)return{kind:"failed",failure:{path:e,error:o},bytes:r}}return{kind:"other",sniffed:n,bytes:r}}}function D(e){let i=new Set(e.flatMap(t=>p(t).filter(r=>r!==t.format)));return Object.keys(c).filter(t=>i.has(t))}function _(e,i){let t=D(e),r=e[0],n=r?.kind==="image"?"webp":r?.format==="pdf"?"png":void 0,o=n&&t.includes(n)?n:t[0];if(o)return N(e,o,i)}function N(e,i,t){let r={target:i};return c[i].lossy&&(r.quality=t),e.some(n=>n.kind==="document"&&n.format==="pdf")&&(i==="png"||i==="jpeg")&&(r.dpi=150),r}export{K as a,A as b,O as c,V as d,W as e,C as f,D as g,_ as h,N as i};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as ie,d as ue,e as pe,g as ce,h as de}from"./chunk-ASLKQXZ2.js";import{a as te,b as oe,c as se,k as ne,m as M,n as O,s as ae}from"./chunk-BKLPRILS.js";import{b as X,c as T}from"./chunk-6RMRWBMB.js";import{a as y}from"./chunk-QQV7CCAY.js";import{b as I}from"./chunk-VJMOZPHW.js";import{e as be}from"./chunk-FBVRKMAF.js";import{a as C,c as _,d as ee,e as F,f as re}from"./chunk-3374PCO5.js";import{f as fe,g as le,h as me,i as ge,j as he,k as ye}from"./chunk-YJ6XLDRA.js";import{a as g}from"./chunk-TGC24JEW.js";import{d as $}from"./chunk-EEQSUBBL.js";import{a as Z}from"./chunk-FAUL5L2W.js";import{a as L,d as U}from"./chunk-TLHUFIXD.js";import{a as Y,c as K,d as E,e as Q}from"./chunk-V6GWPR2A.js";import{G as N,H as V,K as G,a as P,q as z,s as k,u as q,va as H,x as J}from"./chunk-ZBMJTIYR.js";import{a as h,b as W}from"./chunk-J7FLFHQJ.js";import{b as x,c as w}from"./chunk-VLVNA4T3.js";import{a as R}from"./chunk-H3DIRJFE.js";import{readFile as Te}from"node:fs/promises";import{dirname as Oe,resolve as Me}from"node:path";async function we(e){let t=[],r=[...e.resolved.failures];for(let o of e.resolved.sources){let s=C(o);if(!s.includes(e.target)){r.push({path:o.path,error:q(o,e.target,s)});continue}let a={sourcePath:o.path,target:e.target,output:e.output,sourceRoot:e.resolved.roots.get(o.path)},n=E(a);K(n,o.path)&&e.target!==o.format&&(n=Q({...a,suffix:e.target})),t.push({op:"convert",sources:[o],outputs:[n],target:e.target,options:e.options})}return{jobs:t,failures:r}}import{resolve as je}from"node:path";function Be(e,t=new Set){let r={path:je(e.path),kind:e.kind,format:e.format,bytes:e.bytes},o=e.kind==="document"&&e.encrypted===!0,s={targets:C(e).filter(a=>!o||F(a)),actions:ce([e],t).filter(a=>!o||a.id===O.id).map(a=>a.id)};if(e.kind==="image")return{...r,width:e.width,height:e.height,...s};if(e.kind==="media"){let a=e.facts;return{...r,...a?{duration:a.duration}:{},...a?.video?{width:a.video.width,height:a.video.height,fps:a.video.fps}:{},...s}}return{...r,pages:e.pages,encrypted:e.encrypted,...s}}async function Ie(e){let t=await y(e,{recursive:!1}),{installedExtensionIds:r}=await import("./available-TNMISSBA.js"),o=await r();return{probes:t.sources.map(s=>Be(s,o)),failures:t.failures}}import{dirname as Se}from"node:path";var j=e=>({cwd:e.cwd??process.cwd(),...e.home===void 0?{}:{home:e.home}});function ve(e,t){let r=x(Se(e),j(t));return r==="."?"":` in ${r.endsWith("/")?r:`${r}/`}`}function xe(e,t){let{pct:r,direction:o}=W(e,t);return o==="same"?"same size":`${r}% ${o}`}function Pe(e,t={}){let r=e.results[0];if(!r)return[];let o=r.job.sources[0],s=r.job.outputs;if(s.length>1){let n=[`\u2713 ${w(o.path)} \u2192 ${s.length} files${ve(s[0],t)}`,` ${s.map(i=>w(i)).join(", ")}`,` ${h(o.bytes)} \u2192 ${h(r.outputBytes)} total`];for(let i of r.warnings)n.push("",`\u26A0 ${i.message}`);return n}let a=[`\u2713 ${w(o.path)} \u2192 ${x(s[0],j(t))}`,` ${h(o.bytes)} \u2192 ${h(r.outputBytes)} \xB7 ${xe(o.bytes,r.outputBytes)}`];for(let n of r.warnings)a.push("",`\u26A0 ${n.message}`);return a}function ke(e,t={}){let r=[`\u2713 ${e.results.length} converted`,` ${h(e.inputBytes)} \u2192 ${h(e.outputBytes)} \xB7 ${xe(e.inputBytes,e.outputBytes)}`];for(let s of e.results)for(let a of s.job.outputs)r.push(` ${x(a,j(t))}`);let o=e.results.flatMap(s=>s.warnings);if(o.length>0){r.push("");for(let s of o)r.push(`\u26A0 ${s.message}`)}return r}function $e(e,t={}){let r=e.results.flatMap(u=>u.job.outputs),o=r.map(u=>w(u)).join(", "),s=r.length===1?"file":"files",a=r[0]===void 0?"":ve(r[0],t),n=[`\u2713 ${r.length} ${s} \xB7 ${o}${a}`],i=e.results.flatMap(u=>u.warnings);for(let u of i)n.push("",`\u26A0 ${u.message}`);return n}function B(e,t){if(e.length===0)return[];let r=[];for(let o of e)r.push(...H(o.error,{debug:t.debug}),"");return r}function Re(){let e=new Set(_()),t=new Set(ee()),r=["Formats",""];for(let s of e){let a=R[s],n=t.has(s)?"read and write":"read only";r.push(` ${a.label.padEnd(6)} ${a.extensions.join(" ").padEnd(12)} ${n}`)}let o=[...e].filter(s=>!t.has(s)).map(s=>R[s].label);if(o.length>0){let s=o.join(", "),[a,n]=o.length===1?["is","it"]:["are","them"];r.push("",`${s} ${a} read only because Forge cannot yet write ${n}.`)}return r}function Ee(e,t={}){let r=[R[e.format].label,h(e.bytes)];return e.duration!==void 0&&r.push($(e.duration)),e.width!==void 0&&e.height!==void 0&&r.push(`${e.width}\xD7${e.height}`),e.fps!==void 0&&r.push(`${e.fps} fps`),e.pages!==void 0&&r.push(`${e.pages} ${e.pages===1?"page":"pages"}`),e.encrypted&&r.push("password-protected"),[`${x(e.path,j(t))} \xB7 ${r.join(" \xB7 ")}`,` converts to ${e.targets.join(", ")}`,` actions ${e.actions.join(", ")}`]}import{createInterface as Ce}from"node:readline";import{PassThrough as Je}from"node:stream";function Ne(e){return new Promise(t=>{let r=Ce({input:e,terminal:!1}),o=!1,s=a=>{if(o)return;o=!0,r.close(),e.pause(),e.unref?.(),t(a.replace(/\r$/,""))};r.once("line",s),r.once("close",()=>s(""))})}async function Fe(e){if(e.stdin)return Ne(process.stdin);if(!process.stdin.isTTY)return;let t=new Je,r=Ce({input:process.stdin,output:t,terminal:!0});try{return process.stderr.write("Password: "),await new Promise(o=>r.question("",o))}finally{process.stderr.write(`
|
|
4
|
-
`),r.close()}}function Ae(e){return e.kind==="preset"?e.name:e.kind==="pageop"?"PDF":e.kind==="compress"?"Compress":e.kind==="convert"?"Convert":"Edit"}function A(e){return e.length===0?0:e.some(t=>t.error.code==="invalid-arguments")?2:1}function De(e,t){if(e.action==="merge")return{};if(e.action==="rotate")return{degrees:e.rotate};if(e.action==="extract")return{pages:e.pages,separate:e.separate?"many":"one"};if(e.action==="delete")return{pages:e.pages};let r=t.find(n=>n.kind==="document"),o=r?.pages??0,s=e.split;if(!s)throw N("--split needs a mode: every-page, every=N or at=N,N.");if(s.mode==="every-page")return{cuts:ie(o)};if(s.mode==="every-n")return{cuts:ue(o,s.n)};let a=Math.max(o-1,0);for(let n of s.after)if(!Number.isInteger(n)||n<1||n>a)throw V(String(n),`"${n}" is outside 1 and ${a} \u2014 ${r?w(r.path):"the document"} has ${o} pages.`,o);return{cuts:s.after.map(n=>n-1)}}function We(e,t){let r;return()=>t?(r??=Fe({stdin:e}).then(o=>e&&o===""?void 0:o),r):Promise.resolve(void 0)}async function ze(e,t,r,o){let s;if(e.encrypted){if(s=t.password??await r(),s===void 0)return{failure:{path:e.path,error:J(e.path)}};let i;try{i=await Z(await Te(e.path),s)}catch{return{failure:{path:e.path,error:J(e.path,{attempted:!0})}}}i.destroy()}let a;try{a=O.plan([e],{target:t.target,background:t.options.background,keepMetadata:t.options.keepMetadata,dpi:String(t.dpi??150),...t.options.quality===void 0?{}:{quality:t.options.quality},...t.pages===void 0?{}:{pages:t.pages},...t.output===void 0?{}:{destination:t.output},...o===void 0?{}:{sourceRoot:o}})}catch(i){if(!P(i))throw i;return{failure:{path:e.path,error:i}}}let n=a[0];if(n?.op!=="convert")throw new Error(`convertAction.plan() did not return a convert job for ${e.path}`);return s!==void 0&&(n.options.password=s),{job:n}}function S(e,t){return r=>{if(r.type==="search:attempt"){t||e.onSearch?.(r.rung.dpi===void 0?`attempt ${r.attempt} of ${r.of}`:`${r.rung.dpi} dpi \xB7 attempt ${r.attempt} of ${r.of}`);return}if(r.type==="search:settled"){t&&e.onSearch?.(`${r.completed} of ${r.total} searched`);return}if(!t&&r.type==="job:phase"&&r.progress.phase==="time"){let o=r.progress,s=`${$(o.done)} of ${$(o.total)}`;e.onEncode?.(o.pass?`pass ${o.pass.at} of ${o.pass.of} \xB7 ${s}`:s);return}t&&(r.type==="job:done"||r.type==="job:error")&&e.onProgress?.({completed:r.completed,total:r.total})}}var b=(e,t)=>({kind:e,results:[],failures:t,inputBytes:0,outputBytes:0});async function qe(e){let t=await y(e.inputs,{recursive:!1});if(t.sources.length===0)return b("pageop",t.failures);let r=pe.find(n=>n.id===e.action);if(!r)throw new Error(`no action registered for "${e.action}"`);let o=t.sources[0]?.path??"";if(!r.appliesTo(t.sources)){let n=de(r,t.sources)??"not available for these files";return b("pageop",[...t.failures,{path:o,error:k(e.action,n)}])}let s;try{s=r.plan(t.sources,De(e,t.sources))}catch(n){if(!P(n))throw n;return b("pageop",[...t.failures,{path:o,error:n}])}let a=await I(s,{force:e.force});return{kind:"pageop",results:a.results,failures:[...t.failures,...a.refusals,...a.failures],inputBytes:a.inputBytes,outputBytes:a.outputBytes}}async function Ve(e,t){let r=await y(e.inputs,{recursive:e.recursive}),o=[],s=[];for(let i of r.sources){if(!M.appliesTo([i])){s.push({path:i.path,error:z(i)});continue}let u=e.output!==void 0&&!Y(e.output)?Me(e.output):void 0,p=e.output===void 0||u!==void 0?Oe(i.path):Oe(E({sourcePath:i.path,target:i.format,output:e.output,sourceRoot:r.roots.get(i.path)})),[f]=M.plan([i],{mode:e.maxBytes===void 0?"quality":"size",...e.quality===void 0?{}:{quality:e.quality},...e.options.media??{},destination:p});f?.op==="convert"&&(u!==void 0&&(f.outputs=[u]),e.dpi!==void 0&&(f.options.dpi=e.dpi),o.push(f))}let a=o.length>1;a&&t.onProgress?.({completed:0,total:o.length});let n=await I(o,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(t,a)});return{kind:"compress",results:n.results,failures:[...r.failures,...s,...n.refusals,...n.unreachable.map(i=>({path:i.job.sources[0].path,error:i.error})),...n.failures],inputBytes:n.inputBytes,outputBytes:n.outputBytes}}async function Ge(e,t){let r=e.kind,o=e.op==="remove-background"?L(e.target):void 0;if(o)return b(r,[{path:"",error:o}]);let{installed:s}=await import("./paths-6OENILJ4.js"),a=await s(e.op);if(!a)return b(r,[{path:"",error:G(e.op)}]);if(e.op==="boost"&&e.scale!==void 0){let{assetFor:l,catalogEntry:c}=await import("./catalog-FMHWWMUX.js"),m=c("boost"),v=m&&l(m)?.version,D=U(e.scale,a.version,v);if(D)return b(r,[{path:"",error:D}])}let n=await y(e.inputs,{recursive:e.recursive}),i=e.op==="boost"?oe:se,u=[],p=[];for(let l of n.sources){if(!i.appliesTo([l])){p.push({path:l.path,error:k(e.op,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});continue}let c=te(l,e.target);if(c){p.push({path:l.path,error:c});continue}u.push(...i.plan([l],{target:e.target,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.scale===void 0?{}:{scale:e.scale},...e.options.quality===void 0?{}:{quality:e.options.quality},...e.output===void 0?{}:{output:e.output},roots:n.roots}))}let f=u.length>1;f&&t.onProgress?.({completed:0,total:u.length});let d=await I(u,{force:e.force,concurrency:1,...t.signal===void 0?{}:{signal:t.signal},onEvent:S(t,f)});return{kind:r,results:d.results,failures:[...n.failures,...p,...d.refusals,...d.failures],inputBytes:d.inputBytes,outputBytes:d.outputBytes}}async function He(e,t){let r=e.crop!==void 0?"crop":e.resize!==void 0?"resize":"trim",o=e.target===void 0?void 0:be(e.target,r);if(o)return b(e.kind,[{path:"",error:o}]);let s=await y(e.inputs,{recursive:e.recursive}),a=[],n=[],i=[];for(let c of s.sources)c.kind==="image"&&e.media===void 0?a.push(c):c.kind==="media"&&!e.trim?n.push(c):c.kind==="image"?i.push({path:c.path,error:k("cut","it works on video and sound, not images","Try a video or sound file, such as a MOV, MP4 or WAV.")}):i.push({path:c.path,error:k(r,"it works on images, not documents","Try an image such as a JPEG, PNG, WebP or HEIC file.")});let u=ne(n,{...e.media===void 0?{}:{media:e.media},...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots}),f=[...ae(a,{trim:e.trim,...e.crop===void 0?{}:{crop:e.crop},...e.resize===void 0?{}:{resize:e.resize},...e.target===void 0?{}:{target:e.target},...e.output===void 0?{}:{output:e.output},roots:s.roots,background:e.options.background,keepMetadata:e.options.keepMetadata,...e.options.quality===void 0?{}:{quality:e.options.quality}}),...u],d=f.length>1;d&&t.onProgress?.({completed:0,total:f.length});let l=await I(f,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},onEvent:S(t,d)});return{kind:e.kind,results:l.results,failures:[...s.failures,...i,...l.refusals,...l.failures],inputBytes:l.inputBytes,outputBytes:l.outputBytes}}async function Le(e,t){let r=await y(e.inputs,{recursive:e.recursive}),o=m=>m.kind==="document"&&m.format==="pdf",s=F(e.target),a=s?r.sources.filter(o):[],n=s?r.sources.filter(m=>!o(m)):r.sources,i=[],u=[],p=We(e.passwordStdin??!1,t.interactive??!0);for(let m of a){let v=await ze(m,e,p,r.roots.get(m.path));"failure"in v?u.push(v.failure):i.push(v.job)}let f=await we({resolved:{sources:n,failures:[],roots:r.roots},target:e.target,options:e.options,force:e.force,...e.output===void 0?{}:{output:e.output}}),d=[...f.jobs,...i],l=d.length>1;l&&t.onProgress?.({completed:0,total:d.length});let c=await I(d,{force:e.force,...e.concurrency===void 0?{}:{concurrency:e.concurrency},...e.maxBytes===void 0?{}:{targetBytes:e.maxBytes},onEvent:S(t,l)});return{kind:"convert",results:c.results,failures:[...r.failures,...u,...f.failures,...c.refusals,...c.unreachable.map(m=>({path:m.job.sources[0].path,error:m.error})),...c.failures],inputBytes:c.inputBytes,outputBytes:c.outputBytes}}async function Ue(e,t={}){try{if(e.kind==="pageop")return await qe(e);if(e.kind==="extension-op")return await Ge(e,t);if(e.kind==="edit")return await He(e,t);if(e.kind==="preset"){let{runPresetCommand:r}=await import("./preset-command-UNMXHW5A.js");return await r(e)}return e.kind==="compress"?await Ve(e,t):await Le(e,t)}catch(r){if(!P(r))throw r;return b(e.kind,[{path:"",error:r}])}}function Ye(e,t){let r=A(e.failures);if(t.json)return{exitCode:r,stdout:[JSON.stringify(fe(g,e))],stderr:[]};let o=e.results.length===0?[]:e.kind==="pageop"?$e(e):e.results.length===1?Pe(e):ke(e);return{exitCode:r,stdout:o,stderr:B(e.failures,{debug:t.debug})}}function Ke(e,t){let r=[{path:"",error:e}],o=A(r);return t.json?{exitCode:o,stdout:[JSON.stringify(le(g,e))],stderr:[]}:{exitCode:o,stdout:[],stderr:B(r,{debug:t.debug})}}async function Qe(e,t){let{runConfig:r}=await import("./config-command-CKPJXJEE.js"),o=await r(e);return t?{exitCode:0,stdout:[JSON.stringify(he(g,o.config,o.warnings))],stderr:[]}:{exitCode:0,stdout:o.stdout,stderr:[]}}async function zr(e,t={}){let r=t.json??!1,o="debug"in e?e.debug:!1;try{if(e.kind==="config")return await Qe(e,r);if(e.kind==="clip"){let{runClipCommand:n}=await import("./clip-command-MDSM6KJP.js");return await n(e,{...t,json:r,debug:o})}if(e.kind==="update"){let{runUpdate:n}=await import("./update-command-DWEBUFT5.js"),i=await n(g,{...t.onInstalling?{onInstalling:t.onInstalling}:{}});return{exitCode:0,stdout:r?[JSON.stringify({forge:g,ok:!0,...i.data})]:i.stdout,stderr:[]}}if(e.kind==="uninstall"){let{runUninstall:n}=await import("./entry-BZYPZONY.js"),i=[];return{exitCode:await n(g,p=>i.push(p)),stdout:i,stderr:[]}}if(e.kind==="extensions"){let{runExtensions:n}=await import("./extensions-command-JZSOQJEV.js"),i=await n(e,{onDownload:t.onDownload});return{exitCode:0,stdout:r?[JSON.stringify(ye(g,i.data))]:i.stdout,stderr:[]}}if(e.kind==="formats")return r?{exitCode:0,stdout:[JSON.stringify(me(g,re()))],stderr:[]}:{exitCode:0,stdout:Re(),stderr:[]};if(e.kind==="probe"){let{probes:n,failures:i}=await Ie(e.inputs),u=A(i);return r?{exitCode:u,stdout:[JSON.stringify(ge(g,{probes:n,failures:i}))],stderr:[]}:{exitCode:u,stdout:n.flatMap((p,f)=>[...f>0?[""]:[],...Ee(p)]),stderr:B(i,{debug:o})}}if(e.kind==="palette"||e.kind==="scale"||e.kind==="card"){let{runCard:n,runPalette:i,runScale:u}=await import("./colour-2MYODUDY.js"),p={json:r,colour:t.colour??!1};return e.kind==="card"?await n(e,p):e.kind==="palette"?await i(e,p):await u(e,p)}if(e.kind==="transcribe"){let{runTranscribeCommand:n}=await import("./transcribe-command-JHWN4RWU.js"),i=[],u=[],p;return{exitCode:await n(e,{out:d=>i.push(d),err:d=>u.push(d),finished:d=>{p=T("Transcribe",d)}}),stdout:i,stderr:u,...p?{notice:p}:{}}}if(e.kind==="shell")return{exitCode:0,stdout:[],stderr:[]};if(e.kind==="watch")throw N("forge watch runs in a terminal until ctrl-c.","Try: forge watch ./images --to webp");let s=await Ue(e,t),a=T(Ae(e),X(s.results,s.failures));return{...Ye(s,{json:r,debug:o}),...a?{notice:a}:{}}}catch(s){if(!P(s))throw s;return Ke(s,{json:r,debug:o})}}export{Ie as a,xe as b,A as c,Ue as d,Ye as e,zr as f};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
|
-
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{j as l}from"./chunk-K253E723.js";import{g as c}from"./chunk-WBW6G4N6.js";import{a as m,j as n,v as f}from"./chunk-ZBMJTIYR.js";import{a as s}from"./chunk-H3DIRJFE.js";import{b as p}from"./chunk-KXKQDFHX.js";async function b(r,i=192){let t=await l(r);if(t.kind!=="image")throw n(r,`a ${s[t.format].label}`);let u=await c(r,t.format);try{let e=await p(),{data:o,info:a}=await e(u,{animated:!1}).rotate().resize(i,i,{fit:"inside",withoutEnlargement:!0}).ensureAlpha().raw().toBuffer({resolveWithObject:!0});return{source:t,pixels:{width:a.width,height:a.height,rgba:new Uint8Array(o.buffer,o.byteOffset,o.length)}}}catch(e){throw m(e)?e:f(r,e)}}export{b as a};
|
|
@@ -1,36 +0,0 @@
|
|
|
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-OQBIYNGK.js";import{f as dt,g as ee,h as gt,i as ht,j as pt}from"./chunk-KH5DHZ2U.js";import{ma as ge,na as $e,oa as Te,pa as ct,ra as _e,sa as Re}from"./chunk-ZBMJTIYR.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"> </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-RS7LQ3UA.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-KDZEPLNA.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-RS7LQ3UA.js"),import("./decoded-XWKU23RG.js"),import("./libs-EK64ACG3.js"),import("./run-GUFPETHF.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-77L526HZ.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-77L526HZ.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,St as c,At as d,kt as e,zr as f,Zi as g,Gr as h,xe as i,Wr as j,Zr as k,Qi as l,eo as m,to as n,no as o,ro as p,io as q,oo as r,so as s};
|