forge-terminal 0.5.5 → 0.5.7
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 +28 -10
- package/dist/chunks/{about-credits-VRRE6342.js → about-credits-4DHA4HMT.js} +1 -1
- package/dist/chunks/args-5CQKOHYO.js +3 -0
- package/dist/chunks/{boot-MX7UP2M2.js → boot-XX2TLD3Q.js} +1 -1
- package/dist/chunks/{chunk-7I2OSTBX.js → chunk-4KGC5ZBZ.js} +1 -1
- package/dist/chunks/{chunk-J6AZTW62.js → chunk-4MJEEEFA.js} +1 -1
- package/dist/chunks/{chunk-YK26E3OX.js → chunk-4RNVZQRC.js} +1 -1
- package/dist/chunks/{chunk-HYMPLIHW.js → chunk-4YK4XWYS.js} +1 -1
- package/dist/chunks/{chunk-UGATQHEE.js → chunk-6FXF6ALB.js} +1 -1
- package/dist/chunks/{chunk-D4R7UACU.js → chunk-6HQKTDGG.js} +1 -1
- package/dist/chunks/{chunk-TRJXZLR6.js → chunk-6RCS3KBP.js} +1 -1
- package/dist/chunks/{chunk-OUXPGAQL.js → chunk-7MC3LDNP.js} +1 -1
- package/dist/chunks/chunk-7XFLG32B.js +3 -0
- package/dist/chunks/{chunk-R7BEV6PR.js → chunk-AET63NOB.js} +1 -1
- package/dist/chunks/{chunk-HACM3MAD.js → chunk-FAUL5L2W.js} +1 -1
- package/dist/chunks/{chunk-7IWX5VSI.js → chunk-GBA5DFEO.js} +1 -1
- package/dist/chunks/chunk-GYERZAZU.js +4 -0
- package/dist/chunks/{chunk-HWCXNKIN.js → chunk-HTA25PO2.js} +1 -1
- package/dist/chunks/{chunk-BROTSQXG.js → chunk-ILQDMVJR.js} +1 -1
- package/dist/chunks/{chunk-MMLROWBQ.js → chunk-JMIKUWLY.js} +2 -2
- package/dist/chunks/{chunk-KDBKDURW.js → chunk-L57UZTYE.js} +2 -2
- package/dist/chunks/{chunk-BONMSCKD.js → chunk-MPSLPE4C.js} +1 -1
- package/dist/chunks/chunk-N32JL4UI.js +3 -0
- package/dist/chunks/{chunk-Q7ERPAG3.js → chunk-NMECUMJD.js} +1 -1
- package/dist/chunks/{chunk-ZBETH6BR.js → chunk-NRMLO5TP.js} +33 -24
- package/dist/chunks/{chunk-BU4YYGUJ.js → chunk-OXDRJO4V.js} +1 -1
- package/dist/chunks/{chunk-HVMQTKP6.js → chunk-P6JX5ZQT.js} +1 -1
- package/dist/chunks/chunk-POM7FXIV.js +3 -0
- package/dist/chunks/chunk-PUGNBNSV.js +3 -0
- package/dist/chunks/chunk-RM3XA72H.js +3 -0
- package/dist/chunks/{chunk-MES4FVLR.js → chunk-RRVD63NF.js} +1 -1
- package/dist/chunks/chunk-SM735FG7.js +81 -0
- package/dist/chunks/{chunk-JJV2YXZQ.js → chunk-SUB2JM7G.js} +1 -1
- package/dist/chunks/chunk-TFGK7IRZ.js +19 -0
- package/dist/chunks/{chunk-OGYSMKRM.js → chunk-TLHUFIXD.js} +1 -1
- package/dist/chunks/{chunk-SZCSV3PX.js → chunk-U3D3EU33.js} +1 -1
- package/dist/chunks/{chunk-L5JBHB4G.js → chunk-UGYBXR4V.js} +1 -1
- package/dist/chunks/{chunk-RLOJSZ6W.js → chunk-V6GWPR2A.js} +1 -1
- package/dist/chunks/{chunk-BI2E72HM.js → chunk-VDQMK2B2.js} +1 -1
- package/dist/chunks/{chunk-HGJXGAGJ.js → chunk-W53XNVNH.js} +1 -1
- package/dist/chunks/{chunk-7KYO62XK.js → chunk-WBW6G4N6.js} +1 -1
- package/dist/chunks/{chunk-2ZZXIDYX.js → chunk-WMK3IKW6.js} +1 -1
- package/dist/chunks/{chunk-WCOFUMZU.js → chunk-X6PZIFFX.js} +1 -1
- package/dist/chunks/chunk-YJ6XLDRA.js +3 -0
- package/dist/chunks/chunk-ZBMJTIYR.js +3 -0
- package/dist/chunks/clip-command-3CMQ6A5D.js +3 -0
- package/dist/chunks/{clipboard-3VFHDKYE.js → clipboard-IZJTBTSW.js} +1 -1
- package/dist/chunks/colour-VBHJAKAX.js +3 -0
- package/dist/chunks/{command-BKAPI4A5.js → command-GAGAD65W.js} +1 -1
- package/dist/chunks/{config-command-6GXRV627.js → config-command-CKPJXJEE.js} +1 -1
- package/dist/chunks/{continue-editing-4W3XWWCE.js → continue-editing-M6WESEVB.js} +1 -1
- package/dist/chunks/{decoded-SMEHAVCH.js → decoded-XWKU23RG.js} +1 -1
- package/dist/chunks/{entry-7GW4RIK2.js → entry-SOHEQPXT.js} +2 -2
- package/dist/chunks/execute-KTLXJTU2.js +3 -0
- package/dist/chunks/extensions-YF2KGD66.js +3 -0
- package/dist/chunks/{extensions-command-VXZL55KR.js → extensions-command-VT4M2JQW.js} +1 -1
- package/dist/chunks/{ffmpeg-Z7JQT53Y.js → ffmpeg-Q2WJH2OP.js} +1 -1
- package/dist/chunks/{image-FYCF2AVH.js → image-R5C3AWHT.js} +1 -1
- package/dist/chunks/{install-5YXQ6YV3.js → install-KGFOAQCU.js} +1 -1
- package/dist/chunks/{install-C6XNONFF.js → install-MFYGS5TG.js} +1 -1
- package/dist/chunks/{launch-U63VZQXC.js → launch-SOQTCV2D.js} +5 -5
- package/dist/chunks/{lock-AFVXUDOM.js → lock-BG3CLOHA.js} +1 -1
- package/dist/chunks/manager-HBAXHJL4.js +4 -0
- package/dist/chunks/{needed-X5D4E5X5.js → needed-GMZEKBH4.js} +1 -1
- package/dist/chunks/{own-5JN35AUV.js → own-IICGHC4K.js} +1 -1
- package/dist/chunks/{pdfium-GKF4ES7K.js → pdfium-77L526HZ.js} +1 -1
- package/dist/chunks/{preset-command-H6G22SZD.js → preset-command-4OVFEH7Y.js} +1 -1
- package/dist/chunks/{registry-LLAHKI4G.js → registry-TO6HJQJ4.js} +1 -1
- package/dist/chunks/{run-WSETTQXP.js → run-GUFPETHF.js} +1 -1
- package/dist/chunks/{server-CIGFNW7X.js → server-6275TY3O.js} +19 -19
- package/dist/chunks/{theme-HAB66OAL.js → theme-ISNQEBTS.js} +1 -1
- package/dist/chunks/{transcribe-FVCOCTGA.js → transcribe-QC2E7ETQ.js} +1 -1
- package/dist/chunks/{transcribe-command-XCBGAQMI.js → transcribe-command-GAKYFBWQ.js} +1 -1
- package/dist/chunks/{update-command-DJLYU6AB.js → update-command-DWEBUFT5.js} +1 -1
- package/dist/chunks/{update-note-47IPWQKY.js → update-note-T4LVCD25.js} +1 -1
- package/dist/chunks/{watch-command-VL6LOERU.js → watch-command-EYEZKROF.js} +1 -1
- package/dist/index.js +6 -6
- package/package.json +5 -5
- package/dist/chunks/args-5BPKCNTL.js +0 -3
- package/dist/chunks/chunk-2NSUAERD.js +0 -3
- package/dist/chunks/chunk-3YWAVKDZ.js +0 -19
- package/dist/chunks/chunk-45BFQHJB.js +0 -80
- package/dist/chunks/chunk-57M4J2BR.js +0 -3
- package/dist/chunks/chunk-CVNYUROW.js +0 -3
- package/dist/chunks/chunk-HFQOGB4T.js +0 -4
- package/dist/chunks/chunk-PBIS2ONZ.js +0 -3
- package/dist/chunks/chunk-QVACE4IE.js +0 -3
- package/dist/chunks/chunk-U5TEGDGH.js +0 -3
- package/dist/chunks/chunk-VTA6Z45X.js +0 -3
- package/dist/chunks/clip-command-WJ5P4DTN.js +0 -3
- package/dist/chunks/colour-5YBDFXXX.js +0 -3
- package/dist/chunks/execute-LBGFY5TG.js +0 -3
- package/dist/chunks/extensions-HTBACHMC.js +0 -3
- package/dist/chunks/manager-QUTR3RYR.js +0 -4
|
@@ -0,0 +1,4 @@
|
|
|
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-7MC3LDNP.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-VDQMK2B2.js";import{b as X,c as T}from"./chunk-6RMRWBMB.js";import{a as y}from"./chunk-4YK4XWYS.js";import{b as I}from"./chunk-X6PZIFFX.js";import{e as be}from"./chunk-6HQKTDGG.js";import{a as C,c as _,d as ee,e as F,f as re}from"./chunk-U3D3EU33.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-P6JX5ZQT.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-4OVFEH7Y.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-3CMQ6A5D.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-SOHEQPXT.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-VT4M2JQW.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-VBHJAKAX.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-GAKYFBWQ.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 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{c as i,e as s,f as o}from"./chunk-N6RCLJE6.js";import{
|
|
3
|
+
import{c as i,e as s,f as o}from"./chunk-N6RCLJE6.js";import{G as n}from"./chunk-ZBMJTIYR.js";var g=["output","theme","quality","update-check"];async function p(a){if(a.action==="path")return{stdout:[i()],exitCode:0,config:{path:i()},warnings:[]};if(a.action==="list"){let{prefs:e,warning:u}=await s(),f=[`output ${e.defaultOutput}`,`theme ${e.theme??"not set"}`,`quality ${e.quality}`,`update-check ${e.updateCheck===!1?"off":"on"}`,"",i()];return u!==void 0&&f.unshift(`\u26A0 ${u}`,""),{stdout:f,exitCode:0,config:{output:e.defaultOutput,theme:e.theme??null,quality:e.quality,"update-check":e.updateCheck===!1?"off":"on",path:i()},warnings:u===void 0?[]:[{code:"config-unreadable",message:u}]}}let{key:r,value:t}=a;if(r==="theme"){if(t!=="dark"&&t!=="light")throw n(`Theme must be dark or light, not ${t}.`);return await o({theme:t}),{stdout:[`theme is now ${t}`],exitCode:0,config:{theme:t},warnings:[]}}if(r==="quality"){let e=Number(t);if(!Number.isInteger(e)||e<1||e>100)throw n(`Quality must be a whole number between 1 and 100, not ${t}.`);return await o({quality:e}),{stdout:[`quality is now ${e}`],exitCode:0,config:{quality:e},warnings:[]}}if(r==="update-check"){if(t!=="on"&&t!=="off")throw n(`update-check must be on or off, not ${t}.`);return await o({updateCheck:t==="on"}),{stdout:[`update-check is now ${t}`],exitCode:0,config:{"update-check":t},warnings:[]}}if(t.trim().length===0)throw n("Output must be a folder path.");return await o({defaultOutput:t}),{stdout:[`output is now ${t}`],exitCode:0,config:{output:t},warnings:[]}}export{g as a,p as b};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
2
|
const require = __forgeCreateRequire(import.meta.url);
|
|
3
|
-
import{e as a}from"./chunk-
|
|
3
|
+
import{e as a}from"./chunk-4MJEEEFA.js";import{a as t}from"./chunk-H3DIRJFE.js";var p=[{op:"compress",label:"Compress"},{op:"resize",label:"Resize"},{op:"crop",label:"Crop to shape"},{op:"trim",label:"Trim edges"},{op:"format",label:"Convert to another format"},{op:"sharpen",label:"Sharpen"},{op:"boost",label:"Boost resolution"},{op:"cutout",label:"Remove background"}],n=r=>t[r]?.label??r.toUpperCase(),i=r=>`under ${Math.round(r/1e3)} KB`,u=r=>"width"in r?`${r.width} wide`:"height"in r?`${r.height} high`:`${r.percent}%`;function l(r,e){let o={...r};switch(e.op){case"compress":return"quality"in e?(delete o.maxBytes,o.quality=e.quality,o.compress=r.compress??{dither:!1}):o.maxBytes=e.bytes,o;case"resize":return o.resize=e.spec,o;case"crop":return o.crop=e.aspect,o;case"trim":return o.trim=!0,o;case"format":return o.to=e.to,e.quality===void 0?delete o.quality:o.quality=e.quality,o;case"sharpen":return o.sharpen=!0,o;case"boost":return o.boost=e.scale,o;case"cutout":return o.removeBackground=!0,o}}function d(r){switch(r.op){case"compress":return"quality"in r?`quality ${r.quality}`:i(r.bytes);case"resize":return u(r.spec);case"crop":return`${r.aspect.w}:${r.aspect.h}`;case"trim":return"Trim";case"format":return`${n(r.to)}${r.quality===void 0?"":` ${r.quality}`}`;case"sharpen":return"Sharpen";case"boost":return`Boost ${r.scale}\xD7`;case"cutout":return"Remove background"}}function b(r,e){return[...!(e.to===void 0||e.to===r)&&e.to?[`${n(e.to)}${e.quality===void 0?"":` ${e.quality}`}`]:e.quality!==void 0?[`quality ${e.quality}`]:[],...e.resize?[u(e.resize)]:[],...e.trim?["Trim"]:[],...e.crop?[`${e.crop.w}:${e.crop.h}`]:[],...e.sharpen&&!e.boost?["Sharpen"]:[],...e.boost?[`Boost ${e.boost}\xD7`]:[],...e.removeBackground?["Remove background"]:[],...e.maxBytes?[i(e.maxBytes)]:[]]}function h(r,e){if(r.frames>1)return{trim:"animated",crop:"animated"};let o={};return e?.trimmed==="nothing"&&(o.trim="no empty edges"),a(r).length===0&&(o.crop="no shape to cut"),o}export{p as a,l as b,d as c,b as d,h as e};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as __forgeCreateRequire } from 'node:module';
|
|
2
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-
|
|
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-MPSLPE4C.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
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
5
|
`)}var Ve=e=>e.filter(n=>n.length>0);function St(e){let n=Ve(e).map(t=>t.map(Fn).join(`
|
|
6
6
|
|
|
@@ -33,4 +33,4 @@ ${s.map(([f,c])=>`<${t(f)}> <${i(c.text)}>`).join(`
|
|
|
33
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
34
|
<0000> <FFFF>
|
|
35
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-LLAHKI4G.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-Z7JQT53Y.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-LLAHKI4G.js"),import("./decoded-SMEHAVCH.js"),import("./libs-EK64ACG3.js"),import("./run-WSETTQXP.js")]),f=await o(),c=await i(e),d=await st(O(ft(),"forge-read-")),h={width:tn,height:tn,fit:"inside",withoutEnlargement:!0};try{let p=[];if(c.kind==="document"&&c.format==="pdf"){let{openPdf:m}=await import("./pdfium-GKF4ES7K.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-GKF4ES7K.js"),import("./text-layer-LHZNDMPZ.js")]),g=await u(await ot(e)).catch(()=>[]);return a.map((m,S)=>l(m,g[S]??""))}finally{await at(d,{recursive:!0,force:!0})}}async function cn(){let{apple:e}=xe();if(!(e===void 0||await ye()===void 0))return{path:e,kind:"apple"}}async function ln(e,n,t,i){let r=await st(O(ft(),"forge-render-"));try{let o=O(r,"transcript.html"),s=O(r,`transcript.${t}`);return await _r(o,n,"utf8"),await oe(e,["render",o,s,"--as",t],s,{signal:i.signal}),await ot(s)}finally{await at(r,{recursive:!0,force:!0})}}var nn=9026;async function un(e,n){let t=await ut(),{Document:i,Packer:r,Paragraph:o,TextRun:s,Table:f,TableRow:c,TableCell:d,HeadingLevel:h}=t,p="forge-numbers",b=0,a=(A,w=!1)=>Tt(A,n).map(x=>new s({text:x.text,...w?{bold:!0}:{},...x.kind==="eastAsia"?{font:{hint:"eastAsia"},language:x.lang?{eastAsia:x.lang}:{}}:{},...x.kind==="complex"?{font:{hint:"cs"},...x.rtl?{rightToLeft:!0}:{},...w?{boldComplexScript:!0}:{},...x.lang?{language:{bidirectional:x.lang}}:{}}:{}})),u=A=>pe(A)?{bidirectional:!0}:{},l=A=>A.flatMap(w=>{if(w.kind==="heading")return[new o({children:a(w.text),heading:w.level===1?h.HEADING_1:h.HEADING_2,...u(w.text)})];if(w.kind==="paragraph")return[new o({children:a(w.text),spacing:{after:160},...u(w.text)})];if(w.kind==="list"){let E=++b;return w.items.map(T=>w.ordered?new o({children:a(T),numbering:{reference:p,level:0,instance:E},...u(T)}):new o({children:a(T),bullet:{level:0},...u(T)}))}let x=w.rows[0]?.length??1;return[new f({width:{size:100,type:t.WidthType.PERCENTAGE},columnWidths:Array(x).fill(Math.floor(nn/x)),margins:{top:40,bottom:40,left:100,right:100},rows:w.rows.map((E,T)=>new c({tableHeader:T===0,children:E.map(R=>new d({width:{size:Math.floor(nn/x),type:t.WidthType.DXA},children:[new o({children:a(R,T===0),...u(R)})]}))}))}),new o({text:""})]}),m=e.filter(A=>A.length>0).flatMap((A,w)=>[...w>0?[new o({children:[new t.PageBreak]})]:[],...l(A)]),S=new i({numbering:{config:[{reference:p,levels:[{level:0,format:t.LevelFormat.DECIMAL,text:"%1.",alignment:t.AlignmentType.START}]}]},sections:[{children:m}]});return r.toBuffer(S)}var dn=e=>({...e.lang!==void 0?{lang:e.lang}:{},...e.onMissing!==void 0?{onMissing:e.onMissing}:{}});async function oo(e,n,t,i={}){if(n==="md")return Buffer.from(St(e),"utf8");if(n==="txt")return Buffer.from(At(e),"utf8");if(n==="docx")return un(e,i.lang);let r=await cn();return r?ln(r,kt(e,t),"pdf",i):nt(e,{title:t,...dn(i)})}function oi(e){for(let n of e.flat())if(n.kind==="heading"&&n.level===1)return n.text;return"Transcript"}async function so(e,n,t={}){if(n==="md")return Buffer.from(e,"utf8");if(n==="txt")return Buffer.from(dt(e),"utf8");let i=await cn();if(i)return ln(i,pt(e),n,t);let r=ht(e);return n==="docx"?un(r,t.lang):nt(r,{title:oi(r),...dn(t)})}export{ci as a,li as b,At as c,kt as d,zr as e,Zi as f,Gr as g,xe as h,Wr as i,Zr as j,Qi as k,eo as l,to as m,no as n,ro as o,io as p,oo as q,so as r};
|
|
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-TO6HJQJ4.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-Q2WJH2OP.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-TO6HJQJ4.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,At as c,kt as d,zr as e,Zi as f,Gr as g,xe as h,Wr as i,Zr as j,Qi as k,eo as l,to as m,no as n,ro as o,io as p,oo as q,so as r};
|