conformtools 0.6.28 → 0.6.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/dist/{account-RSL4PTDB.js → account-F4ODJBD2.js} +1 -1
  2. package/dist/{agent-hook-setup-IACTYSVL.js → agent-hook-setup-KBCGZNEE.js} +1 -1
  3. package/dist/{analysis-engine-BBOSGAB2.js → analysis-engine-LGB4OXG7.js} +1 -1
  4. package/dist/{bridge-I6VDW7YC.js → bridge-GLW34YZF.js} +1 -1
  5. package/dist/browser/timeline_core_bg.wasm +0 -0
  6. package/dist/{chunk-UE76WJ3Y.js → chunk-7DH6DFYL.js} +1 -1
  7. package/dist/{chunk-QY4QDBIN.js → chunk-BZE7IP6U.js} +91 -91
  8. package/dist/{chunk-TGLH2JDW.js → chunk-FHCRWOI7.js} +1 -1
  9. package/dist/{chunk-NRURUPLU.js → chunk-GDPYFRSV.js} +1 -1
  10. package/dist/chunk-H3FD5KA2.js +7 -0
  11. package/dist/{chunk-BIX5ETBY.js → chunk-HHOFGYZ7.js} +1 -1
  12. package/dist/{chunk-X76IIWBH.js → chunk-HZBGG7HI.js} +1 -1
  13. package/dist/{chunk-AR5BTVBM.js → chunk-KD7UGCLT.js} +1 -1
  14. package/dist/{chunk-CSH2RRI6.js → chunk-NTPDZOPF.js} +1 -1
  15. package/dist/chunk-QDL3XYOE.js +545 -0
  16. package/dist/chunk-QQBDHVUU.js +3 -0
  17. package/dist/chunk-RKJML7MH.js +10 -0
  18. package/dist/{chunk-WG75XXKG.js → chunk-RVKNGIE3.js} +2 -2
  19. package/dist/{chunk-3KS3547B.js → chunk-SSFG7FNI.js} +1 -1
  20. package/dist/{chunk-UXEL636C.js → chunk-UXVABU6B.js} +1 -1
  21. package/dist/{chunk-CV7OBWOX.js → chunk-WJS6NM7T.js} +1 -1
  22. package/dist/{chunk-RL5XRG6O.js → chunk-WWE2FXAQ.js} +1 -1
  23. package/dist/{chunk-HNEKQMQG.js → chunk-YJREJ2MH.js} +1 -1
  24. package/dist/{chunk-7CASAJU4.js → chunk-ZE7BP4AE.js} +1 -1
  25. package/dist/{claude-setup-6RMV3QZM.js → claude-setup-FYWGYBTH.js} +1 -1
  26. package/dist/cli.js +2 -2
  27. package/dist/demo-engine-5HWLXPDJ.js +3 -0
  28. package/dist/{engine-I2NXY2OK.js → engine-LFB243Q6.js} +2 -2
  29. package/dist/{framing-QC7Z2GRK.js → framing-KHUFARKE.js} +1 -1
  30. package/dist/gfx-worker.js +1 -1
  31. package/dist/h264-QGSP23K2.js +3 -0
  32. package/dist/{h264-mxf-PKSTGNGH.js → h264-mxf-I4YANT5F.js} +1 -1
  33. package/dist/{host-relink-B3M3B3VF.js → host-relink-L7I75SUH.js} +1 -1
  34. package/dist/{hosted-26GUD7IU.js → hosted-5Y5VX6X6.js} +1 -1
  35. package/dist/hosts-QMGBN2E6.js +3 -0
  36. package/dist/http.js +2 -2
  37. package/dist/{inspect-RT36GEVU.js → inspect-GP6B6UPD.js} +2 -2
  38. package/dist/{isobmff-65LRNCQH.js → isobmff-LAXAYC7P.js} +1 -1
  39. package/dist/{mc-video-2PCAX65A.js → mc-video-KQ7TP4DG.js} +1 -1
  40. package/dist/mcp.js +7 -7
  41. package/dist/{media-NCUTSVJ4.js → media-SUPBJX64.js} +1 -1
  42. package/dist/{mxf-WFJNAX7D.js → mxf-2TQO552L.js} +1 -1
  43. package/dist/{ops-SH3IUU2Z.js → ops-CVKPID5Z.js} +1 -1
  44. package/dist/{probe-VB6JH6ZJ.js → probe-HUPB4H4G.js} +1 -1
  45. package/dist/{r3d-X2O5LUAB.js → r3d-EPSGIBPT.js} +1 -1
  46. package/dist/resolve-bridge.py +4 -1
  47. package/dist/{sequence-patch-OHYBBKKZ.js → sequence-patch-GXM3QSJC.js} +1 -1
  48. package/dist/{store-F2CTSR6E.js → store-K4W2LVRN.js} +1 -1
  49. package/dist/{timeline-33MJ3HOK.js → timeline-HTG23FEH.js} +1 -1
  50. package/package.json +5 -5
  51. package/dist/chunk-7GEOQ4N6.js +0 -537
  52. package/dist/chunk-IDADYIY6.js +0 -7
  53. package/dist/chunk-TIZC6IEH.js +0 -10
  54. package/dist/chunk-ZPIY5DOU.js +0 -3
  55. package/dist/demo-engine-ITZ7VG6Q.js +0 -3
  56. package/dist/h264-TVMYQ7EB.js +0 -3
  57. package/dist/hosts-LVKUUVG7.js +0 -3
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{B as C,C as x,G as y,a as h,da as c,o as w,p as g,v as u,z as S}from"./chunk-ZPIY5DOU.js";var I=new Set(["ffmpeg","ffprobe","ffplay","sox","soxi","mediainfo","exiftool","mkvmerge","mkvextract","mp4box","bmxtranswrap","raw2rgb","redline","art-cmd","oiiotool","iconvert","idiff","asdcp-wrap","asdcp-unwrap","asdcp-info","opendcp","dcp_inspect","handbrakecli","gst-launch-1.0","mencoder","mplayer","sips","afconvert","avconvert","qtfaststart","mediaconch","bwfmetaedit","x264","x265","aomenc","svtav1encapp","otiotool","otioconvert","otioview","cineform","ale2csv"]),N=["mov","mp4","m4v","mxf","mkv","avi","webm","mts","m2ts","mpg","mpeg","r3d","braw","ari","arx","crm","dng","dpx","exr","wav","aif","aiff","bwf","flac","mp3","aac","m4a","caf"],J=["aaf","avb","edl","drt","otio","fcpxml","fcpxmld","prproj","ptx","ale","xml","csv"],L=new Set(["xml","csv","png","jpg","jpeg","tif","tiff"]),M=new Set([...N,...J,...L]);var m="conformtools-hook",d=o=>o&&typeof o=="object"&&!Array.isArray(o)?o:{},k=o=>!!o&&typeof o=="object"&&typeof o.command=="string"&&o.command.includes(m),A=[["PostToolUse","Bash"],["UserPromptSubmit",null],["Stop",null]];function U(o,e,t,n){let r=Array.isArray(o[e])?[...o[e]]:[],s=(i,a)=>({...i,...t?{matcher:t}:{},hooks:a});for(let i=0;i<r.length;i++){let a=d(r[i]),l=Array.isArray(a.hooks)?a.hooks:[],f=l.findIndex(k);if(f<0)continue;if(JSON.stringify(l[f])===JSON.stringify(n)&&(!t||a.matcher===t))return"kept";let H=[...l];return H[f]=n,r[i]=s(a,H),o[e]=r,"updated"}return o[e]=[...r,s({},[n])],"installed"}function $(o,e,t={}){let n={...d(o.hooks)},r=A.map(([s,i])=>U(n,s,i,{type:"command",command:e,timeout:10,...t.async&&i?{async:!0}:{}}));return r.every(s=>s==="kept")?{settings:o,result:"kept"}:{settings:{...o,hooks:n},result:r.every(s=>s==="installed")?"installed":"updated"}}function _(o){let e={...d(o.hooks)},t=!1;for(let[r]of A){if(!Array.isArray(e[r]))continue;let s=e[r].map(i=>{let a=d(i);if(!Array.isArray(a.hooks))return i;let l=a.hooks.filter(f=>!k(f));return l.length!==a.hooks.length&&(t=!0),l.length?{...a,hooks:l}:null}).filter(i=>i!==null);s.length?e[r]=s:delete e[r]}if(!t)return{settings:o,removed:!1};let n={...o};return Object.keys(e).length?n.hooks=e:delete n.hooks,{settings:n,removed:!0}}var X=30*6e4;function E(o,e,t){let n=d(o.hooks),r=Array.isArray(n.afterShellExecution)?[...n.afterShellExecution]:[],s={command:e,timeout:10,matcher:t},i=r.findIndex(k);return i>=0&&JSON.stringify(r[i])===JSON.stringify(s)?{settings:o,result:"kept"}:(i>=0?r[i]=s:r.push(s),{settings:{version:1,...o,hooks:{...n,afterShellExecution:r}},result:i>=0?"updated":"installed"})}function O(o){let e=d(o.hooks);if(!Array.isArray(e.afterShellExecution))return{settings:o,removed:!1};let t=e.afterShellExecution.filter(s=>!k(s));if(t.length===e.afterShellExecution.length)return{settings:o,removed:!1};let n={...e};t.length?n.afterShellExecution=t:delete n.afterShellExecution;let r={...o};return Object.keys(n).length?r.hooks=n:delete r.hooks,{settings:r,removed:!0}}function j(){return`\\b(${[...I].map(e=>e.replace(/[.+-]/g,"\\$&")).join("|")})\\b|\\.(${[...M].join("|")})\\b`}function q(o){let e=(o??"").toLowerCase();return e?e.includes("claude-code")||e.includes("claude code")?"claude":e.includes("codex")?"codex":e.includes("cursor")?"cursor":null:null}var D=["claude","codex","cursor"],p=()=>({claude:c(g(),".claude","settings.json"),codex:c(g(),".codex","hooks.json"),cursor:c(g(),".cursor","hooks.json")});async function F(){let o=new URL(import.meta.url),e=h(new URL("./hook.js",o));if(await u(e)){await x(w());let n=c(w(),`${m}.js`);return await y(e,n),`node "${n}"`}let t=h(new URL("../adapters/hook.ts",o));return await u(t)?`deno run --allow-read --allow-write --allow-env --no-check --unstable-sloppy-imports "${t}" ${m}`:null}async function v(o){if(!await u(o))return{};let e=await S(o);try{return e.trim()?JSON.parse(e):{}}catch{return"invalid"}}async function P(o,e){let t;return await u(o)?(t=`${o}.conformtools-backup`,await y(o,t)):await x(c(o,"..")),await C(o,JSON.stringify(e,null,2)+`
4
- `),t}async function z(o,e={}){let t=e.file??p()[o];try{let n=e.command??await F();if(!n)return{client:o,file:t,result:"skipped",detail:"no hook script beside this build"};let r=await v(t);if(r==="invalid")return{client:o,file:t,result:"failed",detail:`${t} is not valid JSON; nothing was changed`};let s=o==="cursor"?E(r,n,j()):$(r,n,{async:o==="codex"});if(s.result==="kept")return{client:o,file:t,result:"kept"};let i=await P(t,s.settings);return{client:o,file:t,result:s.result,backup:i}}catch(n){return{client:o,file:t,result:"failed",detail:n instanceof Error?n.message:String(n)}}}async function B(o,e={}){let t=e.file??p()[o],n=await v(t);if(n==="invalid")return{client:o,file:t,removed:!1};let r=o==="cursor"?O(n):_(n);if(!r.removed)return{client:o,file:t,removed:!1};let s=await P(t,r.settings);return{client:o,file:t,removed:!0,backup:s}}async function R(){let o=p(),e=[];for(let t of D)await u(c(o[t],".."))&&e.push(t);return e}var V=async()=>Promise.all((await R()).map(o=>z(o))),Q=async()=>Promise.all((await R()).map(o=>B(o)));async function K(o,e=p()[o]){let t=await v(e);return t!=="invalid"&&JSON.stringify(t).includes(m)}var b={claude:"Claude Code",codex:"Codex",cursor:"Cursor"},T="which other programs the agent ran on media or timeline files (program names and file extensions only; never a command, a path, a name, a prompt or an output), and on each message you send it reminds the agent to log your request with every name and path taken out (the hook itself sends nothing of the message)";function Y(o){return o.length?o.map(e=>{let t=b[e.client],n={installed:`${t}: agent hook installed in ${e.file}${e.backup?` (backup: ${e.backup})`:""}`,updated:`${t}: agent hook refreshed in ${e.file}`,kept:`${t}: agent hook already in ${e.file}`,skipped:`${t}: agent hook not installed (${e.detail})`,failed:`${t}: agent hook not installed: ${e.detail}`}[e.result];return e.client==="codex"&&(e.result==="installed"||e.result==="updated")?`${n}; Codex asks you to trust it once (/hooks)`:n}).concat(`It records ${T}. conformtools hooks off removes it; conformtools telemetry off removes it with the rest.`).join(`
5
- `):"Agent hook: no Claude Code, Codex or Cursor folder on this machine; nothing to install."}function oo(o){let e=o.filter(t=>t.removed);return e.length?e.map(t=>`${b[t.client]}: agent hook removed from ${t.file}`).join(`
6
- `):"Agent hook: not installed anywhere on this machine."}async function eo(){let o=await R();return o.length?[...await Promise.all(o.map(async t=>`${b[t]}: agent hook ${await K(t)?"on":"off"} (${p()[t]})`)),`It records ${T}. conformtools hooks on|off.`].join(`
7
- `):"Agent hook: no Claude Code, Codex or Cursor folder on this machine."}export{q as a,D as b,p as c,F as d,z as e,B as f,R as g,V as h,Q as i,K as j,T as k,Y as l,oo as m,eo as n};
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as F}from"./chunk-3PVQ5QP4.js";import{b as ge,c as we,f as _e}from"./chunk-VFXMP7IF.js";import{f as X,h as he}from"./chunk-ASFUV3PB.js";import{a as be}from"./chunk-NRURUPLU.js";import{i as N}from"./chunk-TGLH2JDW.js";import{b as P,d as T,f as E}from"./chunk-NU3X7P4N.js";import{Ja as pe,ea as ce,fa as le,ka as ue,pa as me,ya as de,za as fe}from"./chunk-7Z65WW4I.js";import{a as ae}from"./chunk-E75BCWXY.js";import{A as J,C as K,H as V,O as v,P as z,Q as se,T as ie,aa as b,b as D,ba as x,ca as k,d as ee,da as y,e as re,h as te,l as ne,m as B,t as W,u as L,w as oe,x as R}from"./chunk-ZPIY5DOU.js";var G=!1,O=8,De=0,ze=3,U=2;async function ke(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),n=i=>String.fromCharCode(t[i],t[i+1],t[i+2],t[i+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(n(4)==="RED1"||n(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],s=n(4);return/^[A-Za-z0-9 ]{4}$/.test(s)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function Ne(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Te(e){return async(t,n)=>new Uint8Array(await e.slice(t,Math.min(t+n,e.size)).arrayBuffer())}function ye(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function ir(e){return await pe(),xe?xe.clip(e,G?"rec709":"",()=>$e(e)):$e(e)}var xe=null;async function $e(e){let t=await ke(e),n=[];if(t==="r3d"){let r=e,s=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],o=r.bases??[0],i=async(u,f,m)=>{let p=o[u]+f;return new Uint8Array(await e.slice(p,Math.min(p+m,o[u]+s[u].size)).arrayBuffer())},a=JSON.stringify(s.map(u=>({name:u.name,size:u.size}))),c=JSON.parse(await fe(i,a)),l=JSON.parse(await ue(i,a));return s.length===1&&/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&n.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:l.map(u=>({offset:o[u.part??0]+u.essenceOffset,size:u.essenceLength})),w:c.width??0,h:c.height??0,fps:ye(c),startFrame:c.timecode?.start_frame??0,dropFrame:c.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:De},geometrySpec:{codec:"r3d",subbands:ze},index:null,warnings:n}}if(t==="mxf"){let r=Te(e),s=JSON.parse(await de(r,e.size));if(!s)throw new Error(`${e.name}: MXF index unreadable`);let o=JSON.parse(await me(r,e.size)),i=[];for(let p=0;p<o.frame_count;p++)i.push({offset:o.frames[p*2],size:o.frames[p*2+1]});let a=i.filter(p=>p.size===0).length;a&&n.push(`${a} frame(s) had no locatable picture KLV`);let c=s.width??0,l=s.height??0,u=(s.inner_codec??"").toLowerCase(),f=null,m="MXF";return u==="arriraw"?(f={codec:"arriraw",w:c,h:l,scale:O},m="ARRIRAW"):u==="xocn"?(f={codec:"xocn",scale:O,...G?{display:"rec709"}:{}},m="X-OCN"):await le(r,e.size)?(f={codec:"vc3",scale:O},m="DNxHR"):await ce(r,e.size)?(f={codec:"prores"},m="ProRes"):n.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:f?i:[],w:c,h:l,fps:ye(s),startFrame:s.timecode?.start_frame??0,dropFrame:s.timecode?.drop_frame??!1,label:m,spec:f,geometrySpec:f&&f.codec==="arriraw"?{...f,scale:U}:f&&f.codec==="xocn"?{codec:"xocn",scale:U,...G?{display:"rec709"}:{}}:f&&f.codec==="vc3"?{codec:"vc3",scale:U}:null,index:null,warnings:n}}if(t==="isobmff"){let r=await he(e),s=Ne(e.name);if(r.kind==="prores")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:X(r.kind),spec:{codec:"prores"},geometrySpec:null,index:r,warnings:n};if(r.kind==="h264"||r.kind==="hevc")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:X(r.kind),spec:null,geometrySpec:null,index:r,warnings:n};let o=s==="braw"?{codec:"braw",scale:O}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:O}:null;return o||n.push(`codec ${r.codec} not wired to the fingerprint pool`),{frames:o?r.offs:[],w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:o?s==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:o,geometrySpec:o?{...o,scale:U}:null,index:r,warnings:n}}throw new Error(`${e.name}: unrecognised container`)}var Y=null;var Ue=Number(D("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(re()/2),Math.floor(ee()/2**31))),Z=0,ve=[],Me=async(...e)=>{Z>=Ue?await new Promise(t=>ve.push(t)):Z++;try{return await ie(...e)}finally{let t=ve.shift();t?t():Z--}};async function Re(){let e=te()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[D("CONFORM_NATIVE_DECODE"),ne(e),W(new URL(`./${e}`,import.meta.url)),W(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of t)if(await oe(n))return n;return null}var S=class extends Error{constructor(n,r){super(r);this.why=n}};function Pr(e){let t=null;try{t=JSON.parse(e.trim().split(`
4
- `).pop())}catch{}if(t?.why==="not_entitled")throw new ae("not_entitled",t.detail??"this machine is not licensed");return t?.detail??e.trim()}function Fe(e,t){try{let n=JSON.parse(e.trim().split(`
5
- `).pop()??"");return new S(n.why,n.detail)}catch{return new S("decoder",`the native decoder exited ${t}: ${e.trim().slice(-300)}`)}}function Er(e){return Y?.owns(e)?Y.meta(`probe|${e}`,()=>Se(e)):Se(e)}async function Se(e){let t=await Re();if(!t)throw new S("missing",B("the native decoder (conformtools-decode)"));let n=[],r=await Me(t,["probe",e],s=>n.push(s));if(r.code!==0)throw Fe(r.stderr,r.code);return JSON.parse(new TextDecoder().decode(Pe(n)))}function Pe(e){let t=e.reduce((s,o)=>s+o.length,0),n=new Uint8Array(t),r=0;for(let s of e)n.set(s,r),r+=s.length;return n}async function Ie(e,t,n,r,s){let o=await Re();if(!o)throw new S("missing",B("the native decoder (conformtools-decode)"));let i=null,a=[],c=0,l=m=>{let p=new Uint8Array(m),d=0;for(;d<m;){let h=a[0],g=Math.min(h.length,m-d);p.set(h.subarray(0,g),d),d+=g,g===h.length?a.shift():a[0]=h.subarray(g)}return c-=m,p},u=[e,t,"--width",String(s.width??32768)];s.from!=null&&u.push("--from",String(s.from)),s.count!=null&&u.push("--count",String(s.count)),s.range&&u.push("--range",s.range);let f=await Me(o,u,m=>{if(a.push(m),c+=m.length,!i){let d=Pe(a.splice(0));a.push(d);let h=d.indexOf(10);if(h<0)return;i=JSON.parse(new TextDecoder().decode(d.subarray(0,h))),l(h+1),n(i)}let p=4+i.w*i.h*(i.bpp??(e==="rgb16"?6:4));for(;c>=p;){let d=l(p);r(new DataView(d.buffer).getUint32(0,!0),d.subarray(4))}},{signal:s.signal});if(f.code!==0||!i)throw Fe(f.stderr,f.code)}function Ee(e,t,n,r={}){return Ie("bgra",e,t,n,r)}var He=["none","rle","zips","zip","piz","pxr24","b44","b44a","dwaa","dwab","htj2k"],I=e=>(e>>4)*10+(e&15);function je(e){let t=I(e&63),n=I(e>>>8&127),r=I(e>>>16&127),s=I(e>>>24&63),o=i=>String(i).padStart(2,"0");return`${o(s)}:${o(r)}:${o(n)}${e&64?";":":"}${o(t)}`}function Be(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||t.getUint32(0,!0)!==20000630)return null;let n={fps:null,timecode:null,width:0,height:0,display:null,compression:null,attributes:[]},r=8,s=()=>{let i=r;for(;r<e.length&&e[r]!==0;)r++;let a=new TextDecoder().decode(e.subarray(i,r));return r++,a},o=i=>({width:t.getInt32(i+8,!0)-t.getInt32(i,!0)+1,height:t.getInt32(i+12,!0)-t.getInt32(i+4,!0)+1});for(;r<e.length;){let i=s();if(!i)break;let a=s();if(r+4>e.length)return null;let c=t.getInt32(r,!0);if(r+=4,c<0||r+c>e.length)return null;if(n.attributes.push(`${i}:${a}`),i==="framesPerSecond"&&a==="rational"&&c>=8){let l=t.getInt32(r,!0),u=t.getUint32(r+4,!0);n.fps=u?l/u:null}else i==="timeCode"&&a==="timecode"&&c>=8?n.timecode=je(t.getUint32(r,!0)):i==="dataWindow"&&a==="box2i"&&c>=16?{width:n.width,height:n.height}=o(r):i==="displayWindow"&&a==="box2i"&&c>=16?n.display=o(r):i==="compression"&&c>=1&&(n.compression=He[e[r]]??`type ${e[r]}`);r+=c}return n}async function We(e){let t=e,n=null,r=/^(.*?)\[(\d+)-(\d+)\](.*)$/.exec(b(e));if(await R(e))n=/^(.*?)(\d+)(\.exr)$/i;else{t=x(e);let o=r?[null,r[1],r[2],r[4]]:/^(.*?)(\d+)(\.exr)$/i.exec(b(e));if(!o)return{frames:[e],numbers:[]};let i=a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`^${i(o[1])}(\\d{${o[2].length}})${i(o[3])}$`,"i")}let s=[];for await(let o of v(t)){let i=o.isFile?n.exec(o.name):null;i&&s.push({n:Number(i[i.length===4?2:1]),f:y(t,o.name)})}return s.sort((o,i)=>o.n-i.n),{frames:s.map(o=>o.f),numbers:s.map(o=>o.n)}}async function Q(e){let t=await We(e),n=t.frames[0];if(!n)throw new Error(`no .exr frames for '${b(e)}'`);let r=await z(n),s;try{s=Be(await r.readAt(0,Math.min(r.size,1<<20)))}finally{await r.close()}if(!s)throw new Error(`'${b(n)}' is not an OpenEXR file`);let o=Math.max(1,t.frames.length),i=t.numbers.length>1?t.numbers[t.numbers.length-1]-t.numbers[0]+1-t.numbers.length:0,a=s.fps??0;return{id:b(n),kind:"external",target_url:n,local_path:n,content_kind:o>1?"video":"still",source_fps:s.fps??void 0,source_timecode:s.timecode??void 0,source_resolution_w:s.width,source_resolution_h:s.height,available_range:{start:{value:0,rate:a},duration:{value:o,rate:a}},streams:[{kind:"video",codec:"exr",width:s.width,height:s.height,rate:s.fps??void 0,codec_specific:{compression:s.compression}}],vendor_metadata:{exr:{frames:o,first_frame:t.numbers[0]??null,last_frame:t.numbers[t.numbers.length-1]??null,missing_frames:i,display_window:s.display,attributes:s.attributes,fps_source:s.fps!=null?"header framesPerSecond":"not in the header",timecode_source:s.timecode?"header timeCode (first frame)":"not in the header"}}}}var C=new Set([".mov",".mp4",".m4v",".mxf",".wav",".braw",".crm",".r3d",".aif",".aiff"]);async function Le(e){let t=await z(e);return{path:e,file:t,size:t.size}}function Je(e){return(t,n)=>e.file.readAt(t,n)}async function Ke(e){let t=F(b(e));if(!t)return[e];let n=x(e),r=[];for await(let s of v(n)){if(!s.isFile)continue;let o=F(s.name);o&&o.clipBase===t.clipBase&&r.push({n:o.partNumber,p:y(n,s.name)})}return r.sort((s,o)=>s.n-o.n).map(s=>s.p)}async function Ve(e){let t=[],n=[];for await(let r of v(e))!r.isFile||r.name.startsWith(".")||(F(r.name)?t.push(r.name):C.has(k(r.name).toLowerCase())&&n.push(r.name));if(t.length)return y(e,t.sort()[0]);if(n.length===1)return y(e,n[0]);throw n.length?(n.sort(),new Error(`'${b(e)}' is a folder of ${n.length} clips (${n.slice(0,3).join(", ")}${n.length>3?", \u2026":""}): probe one of them, or media_find to list them all`)):new Error(`'${b(e)}' is a folder with no media file in it (looked for ${[...C].join(" ")}, and RED parts)`)}async function q(e){await R(e)&&(e=await Ve(e));let t=we(b(e));if(!t)throw new Error(`unsupported media file '${b(e)}' (supported: ${[...C].join(" ")})`);let n=await Ke(e),r=await Promise.all(n.map(Le));return{source:_e(t,r.map(o=>ge(b(o.path),{fileSize:o.size,read:Je(o)}))),parts:r,format:t,anchor:n[0],close:()=>r.forEach(o=>o.file.close())}}async function jr(e,t,n,r){if(!/h264|avc|hevc|h265/.test(n)){let s=null,o=await q(e);try{return await N(o.source,{verb:"decode",index:t,intent:"park"})}catch(i){s=i}finally{o.close()}try{return await Oe(e,t,r)}catch(i){throw/no decoder/.test(String(s))?i:s instanceof Error?s:new Error(String(s))}}return Oe(e,t,r)}async function Oe(e,t,n){t=Math.round(t);let r=0,s=0,o=null;if(await Ee(e,a=>{r=a.w,s=a.h},(a,c)=>{a===t&&(o=c)},{from:t,count:1,width:n}),!o)throw new Error(`the OS decoder returned no frame ${t} of ${b(e)}`);let i=o;for(let a=0;a<i.length;a+=4){let c=i[a];i[a]=i[a+2],i[a+2]=c}return{rgba:i,width:r,height:s}}async function A(e){if(await R(e)){let n=[];for await(let r of v(e))r.isFile&&/\.exr$/i.test(r.name)&&!r.name.startsWith(".")&&n.push(r.name);if(n.length)return Q(y(e,n.sort()[0]))}if(/\.exr$/i.test(e))return Q(e);let t=await q(e);try{let n=await N(t.source,{verb:"inspect"});if(!n)throw new Error(`could not read '${b(e)}' as ${t.format}`);return n.target_url=t.anchor,n.local_path=t.anchor,n.id=n.id||b(t.anchor),t.parts.length>1&&((n.vendor_metadata??={}).spanned_parts=t.parts.map(r=>b(r.path))),n.size_bytes=t.parts.reduce((r,s)=>r+s.size,0),n}finally{t.close()}}function Ae(e,t,n,r){let s=Math.abs(r*1001-Math.round(r*1001/1e3)*1e3)<1?Math.round(r)*1e3/1001:r,o=Math.floor(e*s/t+1e-6);return{tc:P(o,r),frames:Math.round(n*s/t)}}var Xe=e=>String(Math.round(e*1e3)/1e3);function Br(e,t){let n=e.streams?.find(d=>d.kind==="video"),r=e.streams?.filter(d=>d.kind==="audio")??[],s=e.vendor_metadata?.bext;if(!n&&e.available_range&&r[0]?.rate){let d=r[0].rate,h=e.available_range.duration.value,w=(t?[t]:[24e3/1001,24]).map(_=>{let $=Ae(s?.time_reference??0,s?.sample_rate||d,h,_);return`${s?`start TC ${$.tc}, `:""}${$.frames} frames @ ${Xe(_)} fps`});return[e.target_url??"",`audio only; ${h} samples (${(h/d).toFixed(3)} s)${s?`; BWF time_reference ${s.time_reference}`:"; no BWF timecode"}`,...w,...t?[]:["(pass fps for the project's rate)"],...r.map((_,$)=>`audio ${r.length>1?`${$+1}: `:""}${_.codec??"pcm"} ${_.channels??"?"}ch ${_.rate} Hz ${_.bit_depth??"?"}-bit`)].join(`
6
- `)}let o=e.available_range?.duration?.value??e.declared_duration?.value??null,i=e.source_fps??n?.rate??null,a=e.size_bytes,c=e.vendor_metadata?.spanned_parts,l=n?.codec_specific??{},u=[l.profile?`${l.profile} (${l.fourcc})`:l.fourcc,l.pixel_format,n?.bit_depth?`${n.bit_depth}-bit`:null,l.colr?`color ${l.colr.primaries}/${l.colr.transfer}/${l.colr.matrix} (primaries/transfer/matrix)`:null].filter(Boolean).join(", "),f=e.source_pixel_aspect&&Math.abs(e.source_pixel_aspect-1)>.001?e.source_pixel_aspect:null,m=f&&n?.width&&n?.height?`pixel aspect ${Math.round(f*1e3)/1e3}: stored ${n.width}x${n.height}, shown ${(n.width*f/n.height).toFixed(2)}:1 (squeezed; a trim keeps it, a square-pixel copy is a new render)`:null,p=e.raw_extraction?.mov_probe?.every_sample_is_keyframe===!1&&n?"long-GOP (not every frame is a keyframe): media_trim starts on the keyframe at or before the frame asked for":null;return[e.target_url??"",n?`${n.codec??"?"} ${n.width??"?"}x${n.height??"?"}${i?` @ ${Math.round(i*1e3)/1e3} fps`:""}${u?`; ${u}`:""}`:"no video track",...[m,p].filter(d=>!!d),`start TC ${e.source_timecode??"none"}; ${o!=null?`${o} frames`:"length unknown"}${o!=null&&i?` (${(o/i).toFixed(2)} s)`:""}`,r.length?r.map((d,h)=>{let g=d.codec_specific?.channel_layout;return`audio ${r.length>1?`${h+1}: `:""}${d.codec??"pcm"} ${d.channels??"?"}ch${g?` (${g})`:""} ${d.rate??"?"} Hz ${d.bit_depth??"?"}-bit`}).join(`
7
- `):"no audio",`${e.reel_name?`reel ${e.reel_name}; `:""}${a!=null?`${(a/1e6).toFixed(1)} MB`:""}${c?`; spanned ${c.length} parts`:""}`].join(`
8
- `)}var Ge=8*1024*1024,H=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0));async function Ye(e,t,n){if(e.executable_locally===!1)throw new Error("this trim plan is server-side only");let r=new Map(t.parts.map(o=>[b(o.path),o]));await K(x(n));let s=await se(n);try{await s.truncate(e.total_size),await s.writeAt(0,H(e.dest_header_bytes_base64));for(let o of e.src_byte_ranges){let i=o.src_file_name?r.get(b(o.src_file_name)):t.parts[0];if(!i)throw new Error(`plan references unknown source part '${o.src_file_name}'`);let a=0;for(;a<o.length;){let c=Math.min(Ge,o.length-a),l=await i.file.readAt(o.offset+a,c);if(l.length<c)throw new Error(`short read in ${b(i.path)} at ${o.offset+a}`);await s.writeAt(o.write_to_dest_offset+a,l),a+=c}}e.dest_footer_bytes_base64&&e.dest_footer_offset!=null&&await s.writeAt(e.dest_footer_offset,H(e.dest_footer_bytes_base64));for(let o of e.dest_patches??[])await s.writeAt(o.offset,H(o.bytes_base64))}finally{await s.close()}for(let o of e.dest_sidecar_writes??[])await J(y(x(n),o.name),H(o.bytes_base64))}function Ze(e,t){let n=[];for(let r of e){if(r.kind!=="clip"||!r.source_range)continue;let s=r.source_range.start.value,o=r.source_range.duration.value,i=Math.max(0,Math.floor(s)-t),a=Math.floor(s+o-1)+t;a>=i&&n.push({first_frame:i,last_frame:a})}return be(n)}async function Qe(e,t,n,r,s){let o=await q(e);try{let i=Ze(t,n);if(!i.length)throw new Error("no usable frame ranges (items need kind=clip with source_range)");let a=await N(o.source,{verb:"trim",selection:{items:t,handles:n}}),c=k(o.anchor),l=o.format==="r3d",u=l?F(b(o.anchor))?.clipBase??b(o.anchor,c):b(o.anchor,c),f=[];for(let[m,p]of a.entries()){let d=p.output_clip_number??(i.length>1?m+1:void 0),h=i[(d??1)-1]??i[0],g=d&&(p.output_clip_count??i.length)>1?`_S${String(d).padStart(3,"0")}`:"",w;if(l){let _=p.output_part_number??m+1;w=y(r,`${u}${g}.RDC`,`${u}_${String(_).padStart(3,"0")}.R3D`),f.push({path:w,bytes:p.total_size,island:h,part:_,clip:d})}else{let _=s&&a.length===1?s:`${u}${g||`_trim_${h.first_frame}-${h.last_frame}`}${c}`;w=y(r,_),f.push({path:w,bytes:p.total_size,island:h,clip:d})}await Ye(p,o,w)}return l||await qe(e,f,!!s&&a.length===1),{outputs:f,islands:i,format:o.format}}finally{o.close()}}async function qe(e,t,n){let r=await A(e).catch(()=>null),s=r?.source_fps??r?.streams?.find(o=>o.kind==="video")?.rate??null;if(!(!r?.source_timecode||!s))for(let o of t){if(!o.island)continue;let i=await A(o.path).catch(()=>null),a=i?.available_range?.duration?.value??i?.declared_duration?.value;if(!i?.source_timecode||!a)continue;let c=E(i.source_timecode,s,r.source_timecode);if(c===o.island.first_frame&&c+a-1===o.island.last_frame||(o.island={first_frame:c,last_frame:c+a-1},n))continue;let l=o.path.replace(/_trim_\d+-\d+(\.[^./\\]+)$/,`_trim_${c}-${c+a-1}$1`);l!==o.path&&(await V(o.path,l),o.path=l)}}async function Wr(e){let t=await A(e.path),n=t.source_fps??t.streams?.find(w=>w.kind==="video")?.rate??null,r=t.available_range?.duration?.value??t.declared_duration?.value??null,s=t.streams?.find(w=>w.kind==="audio")?.rate;if(!n&&e.fps&&s&&r!=null){let w=t.vendor_metadata?.bext,_=Ae(w?.time_reference??0,w?.sample_rate||s,r,e.fps);n=Math.abs(e.fps*1001-Math.round(e.fps*1001/1e3)*1e3)<1?Math.round(e.fps)*1e3/1001:e.fps,r=_.frames,t.source_timecode=_.tc}if(!n)throw new Error(s?"cannot trim: audio-only file: pass fps (the project's video rate) to count in/out in frames":"cannot trim: no frame rate / timecode track on this file");let o=E(e.in,n,t.source_timecode??null),i=E(e.out,n,t.source_timecode??null);e.out_exclusive&&(i-=1);let a=t.source_timecode??"00:00:00:00",c=r!=null?P((T(a,n)??0)+r-1,n,!!t.vendor_metadata?.drop_frame):null;if(i<o)throw new Error(`out ${e.out} is before in ${e.in}`);if(o<0)throw new Error(`in ${e.in} is before the file starts (${a}, frame 0)`);if(r!=null&&i>r-1)throw new Error(`out ${e.out} is past the end of the file (last frame ${c}, frame ${r-1})`);let l={id:"trim",kind:"clip",source_range:{start:{value:o,rate:n},duration:{value:i-o+1,rate:n}}},u=x(e.path),f;if(e.out_path)try{(await L(e.out_path)).isDirectory?u=e.out_path:(u=x(e.out_path),f=b(e.out_path))}catch{u=x(e.out_path),f=b(e.out_path)}let m=await Qe(e.path,[l],Math.max(0,Math.floor(e.handles??0)),u,f),p=m.islands[0],d=m.outputs.length===1&&m.outputs[0].island?m.outputs[0].island:p,h=d.first_frame,g=d.last_frame;return{outputs:m.outputs,first_frame:h,last_frame:g,frames:g-h+1,fps:n,facts:t,...h!==p.first_frame||g!==p.last_frame?{asked:{first_frame:p.first_frame,last_frame:p.last_frame}}:{}}}function Ce(e){let t=[...C].map(n=>n.slice(1)).join("|");return e.toLowerCase().replace(new RegExp(`\\.(${t})(?=[._\\s-]|$)`,"g"),"").replace(/[^a-z0-9]/g,"")}function er(e,t){let n=Ce(e),r=Ce(t);if(r&&n.includes(r))return"name";let s=t.toLowerCase().split(/[^a-z0-9]+/).filter(o=>/\d/.test(o)&&o.length>=3);return s.length&&s.every(o=>n.includes(o))?"id":null}async function Lr(e,t,n){let r=[],s=0,o=null,i=Date.now()+n.time_limit_s*1e3,a=async(c,l)=>{try{for await(let u of v(c)){if(o&&!o.startsWith("folders"))return;if(++s>n.max_entries){o=`stopped after ${n.max_entries} entries (max_entries)`;return}if(Date.now()>i){o=`stopped after ${n.time_limit_s} s (time_limit_s)`;return}if(u.name.startsWith("."))continue;let f=y(c,u.name);if(u.isDirectory)l<n.max_depth?await a(f,l+1):o??=`folders deeper than max_depth=${n.max_depth} not searched (e.g. ${f})`;else if(u.isFile&&C.has(k(u.name).toLowerCase())){let m=er(u.name,t);m&&r.push({path:f,match:m,size:(await L(f).catch(()=>({size:0}))).size})}}}catch{}};if(await a(e,0),n.probe)for(let c=0;c<r.length;c+=8)await Promise.all(r.slice(c,c+8).map(async l=>{try{l.facts=await A(l.path)}catch(u){l.error=u.message}}));return r.sort((c,l)=>c.path.localeCompare(l.path)),{hits:r,scanned:s,truncated:o}}function rr(e){let t=e.streams?.find(a=>a.kind==="video"),n=e.source_fps??t?.rate??null,r=e.available_range?.duration?.value??e.declared_duration?.value??null,s=t?.codec_specific??{},o=e.source_timecode&&n?T(e.source_timecode,n):null,i=o!=null&&r!=null&&n?P((o+r)%(Math.round(n)*86400),n,e.source_timecode.includes(";")):null;return`${t?`${t.codec??"?"}${s.profile?` ${s.profile}`:""} ${t.width??"?"}x${t.height??"?"}`:"no video"}${n?` @ ${Math.round(n*1e3)/1e3} fps`:""}; TC ${e.source_timecode??"none"}${i?`\u2013${i}`:""}; ${r??"?"} fr${r!=null&&n?` (${(r/n).toFixed(2)} s)`:""}`}function Jr(e,t,n,r){let s=e.hits.slice(0,r),o=[];e.truncated&&o.push(`TRUNCATED: ${e.truncated} \u2014 the search did NOT cover all of ${t}; the matches below may be incomplete.`),e.hits.length>s.length&&o.push(`TRUNCATED: showing ${s.length} of ${e.hits.length} matches. Pass limit=${e.hits.length} or narrow the query.`),o.push(`${e.hits.length} file${e.hits.length===1?"":"s"} match "${n}" under ${t} (${e.scanned} entries scanned)`);let i=new Map;for(let c of e.hits)i.set(b(c.path).toLowerCase(),(i.get(b(c.path).toLowerCase())??0)+1);let a=[...i].filter(([,c])=>c>1);a.length&&o.push(`same name in several folders: ${a.map(([c,l])=>`${c} \xD7${l}`).join(", ")} \u2014 they can be DIFFERENT clips; match by TC + duration, never by name alone`);for(let c of s)o.push(`- ${c.path}${c.match==="id"?" (id match)":""}
9
- ${c.facts?rr(c.facts):c.error?`probe failed: ${c.error}`:`${(c.size/1e6).toFixed(1)} MB`}`);return o.join(`
10
- `)}async function Kr(e,t,n=0){let r=await A(e),s=r.source_fps??r.streams?.find(m=>m.kind==="video")?.rate??null,o=r.available_range?.duration?.value??r.declared_duration?.value??null;if(!s||o==null)throw new Error(`cannot check coverage: ${b(e)} has no frame rate or length`);let i=Math.round(s)*86400,a=r.source_timecode?T(r.source_timecode,s)??0:0,c=!!r.source_timecode?.includes(";"),l=m=>{let p=E(m,s,r.source_timecode??null);return typeof m=="number"||/^\d+$/.test(m.trim())?p:p<-i/2?p+i:p>i/2?p-i:p},u=m=>P(((a+m)%i+i)%i,s,c),f=t.map((m,p)=>{let d=l(m.in),h=l(m.out),g=d,w=o-h,_=g>=0&&w>=0&&h>d,$=Math.max(0,-g),j=Math.max(0,-w),M=[];return h<=d?M.push("out is not after in"):_?M.push(`covered; handles head ${g} / tail ${w} fr`):M.push(`NOT covered: short ${[$?`${$} fr at head`:"",j?`${j} fr at tail`:""].filter(Boolean).join(", ")}`),_&&n&&(g<n||w<n)&&M.push(`handles short of ${n}: ${[g<n?`head by ${n-g}`:"",w<n?`tail by ${n-w}`:""].filter(Boolean).join(", ")}`),{label:m.label??`range ${p+1}`,in_tc:u(d),out_tc:u(h),frames:h-d,covered:_,head:g,tail:w,short_head:$,short_tail:j,note:M.join("; ")}});return{facts:r,rows:f}}export{ir as a,Re as b,Pr as c,Er as d,Ee as e,We as f,C as g,Ke as h,Ve as i,q as j,jr as k,A as l,Ae as m,Br as n,Ze as o,Qe as p,Wr as q,Ce as r,er as s,Lr as t,rr as u,Jr as v,Kr as w};
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{readFile as U,writeFile as _,appendFile as V,stat as B,readdir as X,mkdir as j,open as T,copyFile as Z,mkdtemp as Q,rm as P,chmod as ee,rename as z,cp as te,statfs as re,realpath as ne}from"node:fs/promises";import{execFile as oe,spawn as L}from"node:child_process";import{createHash as se}from"node:crypto";import{createReadStream as ie,chmodSync as S,cpSync as ae,existsSync as A,mkdirSync as C,readdirSync as ce,statSync as N}from"node:fs";import{homedir as le,hostname as ue,tmpdir as de,platform as me,release as fe,arch as pe,totalmem as ge,availableParallelism as ye}from"node:os";import{fileURLToPath as D}from"node:url";import we from"node:http";import be from"node:http2";import f from"node:process";import{setTimeout as he}from"node:timers";import{Buffer as $}from"node:buffer";import{basename as xe,dirname as J,join as w,resolve as I,sep as v}from"node:path";import{createRequire as ve}from"node:module";import{basename as Mt,dirname as Ct,extname as Nt,join as It,relative as Ht,resolve as Wt}from"node:path";{let e=globalThis.fetch,t=typeof globalThis.Deno<"u";e&&!t&&(globalThis.fetch=(async(r,o)=>{let n=typeof r=="string"?r:r instanceof URL?r.href:r.url;if(n.startsWith("file:")){let s=await U(D(n)),i=n.endsWith(".wasm")?"application/wasm":"application/octet-stream";return new Response(s,{status:200,headers:{"content-type":i}})}return e(r,o)}))}var b=e=>f.env[e];function _e(e,t){he(e,t).unref()}var Be=()=>Number(b("CONFORM_MEMORY_GB")??0)*2**30||ge(),je=()=>ye(),ze=()=>f.argv.slice(2),Le=e=>f.exit(e),Pe=()=>f.platform,Je=()=>ue(),qe=()=>b("CONFORM_PYTHON")??(Pe()==="win32"?"python":"python3"),Ge=()=>f.arch,q=()=>`${f.platform}-${f.arch}`;function Ye(e){try{return w(J(ve(import.meta.url).resolve(`${$e(q())}/package.json`)),e)}catch{return null}}var $e=e=>`conformtools-${e==="win32-x64"?"windows-x64":e}`,Ke=e=>`${e} is not in this package for ${q()} (conform.tools builds it for darwin-arm64, darwin-x64, linux-x64 and win32-x64)`;function Ve(){let e=f.versions.deno,t=b("CONFORM_APP_VERSION"),r=e?`deno ${e}`:`node ${f.version}`;return{platform:`${me()} ${fe()} ${pe()}`,runtime:t&&/^[0-9A-Za-z.-]{1,32}$/.test(t)?`${r} app ${t}`:r}}var Re=()=>b("CONFORM_MCP_HOME")??w(O(),".conform-mcp"),O=()=>b("HOME")??le();function Xe(e){let t=e.trim();if(t.length>=2&&(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'"))&&(t=t.slice(1,-1)),/^file:\/\//i.test(t))try{t=D(t)}catch{}return t==="~"?t=O():(t.startsWith("~/")||t.startsWith("~\\"))&&(t=w(O(),t.slice(2))),t&&I(t)+(/[\\/]$/.test(t)&&!/[\\/]$/.test(I(t))?v:"")}async function Ze(e,t){let r=await import("node:sqlite").catch(()=>null);if(r?.DatabaseSync){let n=new r.DatabaseSync(e,{readOnly:!0});try{let s=n.prepare(t);return s.setReadBigInts(!0),s.all().map(i=>Object.fromEntries(Object.entries(i).map(([c,l])=>[c,typeof l=="bigint"?Number(l):l])))}finally{n.close()}}let o=await F("sqlite3",["-readonly","-json",e,t]);if(!o.success)throw new Error(`sqlite3 ${xe(e)}: ${o.stderr.trim()||o.stdout.trim()}`);return o.stdout.trim()?JSON.parse(o.stdout):[]}var Qe=(e,t)=>e?`${e.replace(/[\\/]+$/,"")}${e.includes("\\")&&!e.includes("/")?"\\":"/"}${t}`:t;function et(e){let t=D(e),r=t.indexOf(`${v}deno-compile-`);if(r<0||!A(t))return t;let o=t.slice(r+1).split(v).slice(1).join(v),n=w(Re(),"bin",o);try{return G(t,n,!0),n}catch{return t}}function G(e,t,r=!1){let o=N(e);if(o.isDirectory()){A(t)||C(t,{recursive:!0}),S(t,493);for(let s of ce(e))G(w(e,s),w(t,s));return}let n=A(t)?N(t):null;(!n||n.size!==o.size||n.mtimeMs<o.mtimeMs)&&(n?S(t,420):C(J(t),{recursive:!0}),ae(e,t,{force:!0,preserveTimestamps:!0})),S(t,r||o.mode&73?493:420)}var H=null;var x=e=>H?.owns(e)?H:null;async function W(e){let t=await B(e);return{isFile:t.isFile(),isDirectory:t.isDirectory(),size:t.size,mtimeMs:t.mtimeMs}}function R(e){return x(e)?.stat(e,()=>W(e))??W(e)}async function tt(e){try{return await R(e),!0}catch{return!1}}async function rt(e){try{return(await R(e)).isFile}catch{return!1}}async function nt(e){try{return(await R(e)).isDirectory}catch{return!1}}async function ot(e){x(e)?.guard(e,"read whole file");let t=await U(e);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}var st=e=>U(e,"utf8"),it=(e,t)=>_(e,t),at=(e,t,r)=>r?.append?V(e,t):_(e,t);async function ct(e){await j(e,{recursive:!0})}async function lt(e,t={}){let r=Date.now()+(t.timeoutMs??5e3),o=t.staleMs??15e3;for(;;)try{await j(e);break}catch(n){if(n.code!=="EEXIST")throw n;try{if(Date.now()-(await R(e)).mtimeMs>o){await P(e,{recursive:!0,force:!0});continue}}catch{}if(Date.now()>r)break;await new Promise(s=>setTimeout(s,25))}return()=>P(e,{recursive:!0,force:!0}).catch(()=>{})}var ut=e=>P(e,{force:!0}),dt=(e,t)=>ee(e,t).catch(()=>{}),mt=(e,t)=>Z(e,t),ft=(e,t)=>z(e,t),pt=e=>P(e,{recursive:!0,force:!0}),gt=(e,t)=>te(e,t,{recursive:!0,verbatimSymlinks:!0});async function yt(e){try{let t=await re(e);return Number(t.bavail)*Number(t.bsize)}catch{return null}}async function wt(e){try{return await ne(e)}catch{return null}}var bt=()=>f.ppid,ht=(e="conform-")=>Q(w(de(),e));async function*xt(e){let t=async()=>(await X(e,{withFileTypes:!0})).map(r=>({name:r.name,isFile:r.isFile(),isDirectory:r.isDirectory()}));yield*await(x(e)?.readDir(e,t)??t())}async function vt(e){x(e)?.guard(e,"read bytes");let t=await T(e,"r"),r=(await t.stat()).size;return{path:e,size:r,async readAt(o,n){let s=new Uint8Array(n),i=0;for(;i<n;){let{bytesRead:c}=await t.read(s,i,n-i,o+i);if(!c)break;i+=c}return i===n?s:s.subarray(0,i)},close:()=>t.close()}}async function Pt(e){let t=await T(e,"w");return{async writeAt(r,o){let n=0;for(;n<o.length;){let{bytesWritten:s}=await t.write(o,n,o.length-n,r+n);n+=s}},truncate:r=>t.truncate(r),close:()=>t.close()}}var Y=(e,t)=>{for(let r of t)x(r)?.guard(r,`${e.split(/[\\/]/).pop()} ${t[0]}`)};function F(e,t,r={}){return Y(e,t),new Promise(o=>{oe(e,t,{maxBuffer:1<<30,env:r.env?{...f.env,...r.env}:void 0,timeout:r.timeoutMs},(n,s,i)=>{let c=n?.code??0;o({success:!n,code:c,stdout:String(s),stderr:String(i)})})})}var ke="[Console]::OutputEncoding=[Text.Encoding]::UTF8;$t=@{};Get-Process|?{$_.MainWindowTitle}|%{$t[$_.Id]=$_.MainWindowTitle};ConvertTo-Json -Compress -InputObject @(Get-CimInstance Win32_Process|%{[pscustomobject]@{pid=[int]$_.ProcessId;exe=$_.ExecutablePath;cmd=$_.CommandLine;title=$t[[int]$_.ProcessId]}})";async function $t(){let e=await F("powershell.exe",["-NoProfile","-NonInteractive","-Command",ke],{timeoutMs:3e4});return Se(e.stdout)}function Se(e){let t;try{t=JSON.parse(e.replace(/^/,"").trim()||"[]")}catch{return[]}return(Array.isArray(t)?t:[t]).flatMap(r=>{let o=r??{},n=Number(o.pid);return!Number.isInteger(n)||n<=0?[]:[{pid:n,args:String(o.cmd||o.exe||""),title:typeof o.title=="string"?o.title:""}]})}function Rt(e,t,r,o={}){return Y(e,t),new Promise((n,s)=>{let i=L(e,t,{env:o.env?{...f.env,...o.env}:void 0,stdio:["ignore","pipe","pipe"]}),c="";i.stdout.on("data",l=>r(l)),i.stderr.on("data",l=>{c+=new TextDecoder().decode(l)}),i.on("error",s),i.on("close",l=>n({code:l,stderr:c})),o.signal?.addEventListener("abort",()=>i.kill(),{once:!0})})}function kt(e,t,r,o,n={}){let s=L(e,t,{stdio:["pipe","pipe","pipe"],env:n.env?{...f.env,...n.env}:void 0});s.stdin.on("error",()=>{}),s.stdout.on("data",a=>r(a)),s.stderr.on("data",a=>o?.(new TextDecoder().decode(a)));let i=new Promise(a=>{s.on("close",u=>a(u)),s.on("error",()=>a(null))}),c=[s,s.stdout,s.stderr,s.stdin],l=a=>{for(let u of c)(a?u.ref:u.unref)?.call(u)};return l(!1),{write:a=>new Promise((u,p)=>{s.stdin.write(a,m=>m?p(m):u())}),hold:l,close:()=>{try{s.stdin.end(),s.kill()}catch{}},exited:i}}async function St(e){if(b("CONFORM_NO_BROWSER"))return!1;let[t,r]=f.platform==="darwin"?["open",[e]]:f.platform==="win32"?["cmd",["/c","start","",e.replace(/&/g,"^&")]]:["xdg-open",[e]];return(await F(t,r)).success}function At(e,t){let r=we.createServer(async(o,n)=>{try{let s=[];if(o.method!=="GET"&&o.method!=="HEAD")for await(let p of o)s.push(p);let i=s.length>0,c=new Headers;for(let[p,m]of Object.entries(o.headers))m!=null&&c.set(p,Array.isArray(m)?m.join(", "):m);let l=`http://${o.headers.host??`${e.hostname}:${e.port}`}${o.url??"/"}`,a=new AbortController;n.on("close",()=>{n.writableEnded||a.abort()});let u=await t(new Request(l,{method:o.method,headers:c,body:i?$.concat(s):void 0,signal:a.signal}));if(n.statusCode=u.status,u.headers.forEach((p,m)=>n.setHeader(m,p)),u.body&&u.headers.get("content-type")?.startsWith("text/event-stream")){n.flushHeaders();let p=u.body.getReader();for(a.signal.addEventListener("abort",()=>void p.cancel(),{once:!0});;){let{value:m,done:g}=await p.read();if(g)break;n.write(m)}n.end();return}n.end($.from(await u.arrayBuffer()))}catch(s){n.statusCode=500,n.end(JSON.stringify({ok:!1,code:"internal",message:s instanceof Error?s.message:String(s)}))}});return r.listen(e.port,e.hostname,()=>{let o=r.address();e.onListen?.(typeof o=="object"&&o?o.port:e.port)}),{close:()=>r.close()}}var y=class extends Error{constructor(r,o,n){super(o);this.code=r;this.grpcStatus=n}};function Ot(e,t,r,o,n){return new Promise((s,i)=>{let c=be.connect(`http://${e}:${t}`),l=!1,a=(d,K)=>{l||(l=!0,clearTimeout(p),c.destroy(),d?i(d):s(K))},u=!1;c.on("connect",()=>{u=!0});let p=setTimeout(()=>a(u?new y("deadline",`no answer from ${e}:${t} in ${n} ms`):new y("unavailable",`${e}:${t}: no connection in ${n} ms`)),n);c.on("error",d=>a(new y("unavailable",`${e}:${t}: ${d.message}`)));let m=$.alloc(5+o.length);m.writeUInt32BE(o.length,1),m.set(o,5);let g=c.request({":method":"POST",":path":r,"content-type":"application/grpc",te:"trailers"}),E=[],h,k="",M=d=>{d["grpc-status"]!=null&&(h=String(d["grpc-status"]),k=decodeURIComponent(String(d["grpc-message"]??"")))};g.on("response",M),g.on("trailers",M),g.on("data",d=>E.push(d)),g.on("error",d=>a(new y("unavailable",`${e}:${t}: ${d.message}`))),g.on("end",()=>{if(h!=="0")return a(new y("grpc",`grpc-status ${h??"missing"}${k?`: ${k}`:""}`,h==null?void 0:Number(h)));let d=$.concat(E);if(d.length<5||d[0]!==0)return a(new y("grpc","reply is not one uncompressed gRPC message"));a(null,new Uint8Array(d.subarray(5,5+d.readUInt32BE(1))))}),g.end(m)})}async function Ut(e){let t=se("sha256");for await(let r of ie(e))t.update(r);return t.digest("hex")}async function Tt(e,t,r){let o=`${t}.part`;for(let n=0;;n++){let s=0;try{s=(await B(o)).size}catch{}try{let i=await fetch(e,{headers:s?{Range:`bytes=${s}-`}:{}});if(i.status===416)break;if(!i.ok||!i.body)throw new Error(`${e} answered ${i.status}`);s&&i.status!==206&&(s=0);let c=s+Number(i.headers.get("content-length")??0),l=await T(o,s?"a":"w");try{let a=s;for await(let u of i.body)await l.write(u),a+=u.length,r?.(a,c)}finally{await l.close()}break}catch(i){if(n>=4)throw i;await new Promise(c=>setTimeout(c,2e3*(n+1)))}}await z(o,t)}function Dt(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}export{D as a,b,_e as c,Be as d,je as e,ze as f,Le as g,Pe as h,Je as i,qe as j,Ge as k,Ye as l,Ke as m,Ve as n,Re as o,O as p,Xe as q,Ze as r,Qe as s,et as t,R as u,tt as v,rt as w,nt as x,ot as y,st as z,it as A,at as B,ct as C,lt as D,ut as E,dt as F,mt as G,ft as H,pt as I,gt as J,yt as K,wt as L,bt as M,ht as N,xt as O,vt as P,Pt as Q,F as R,$t as S,Rt as T,kt as U,St as V,At as W,y as X,Ot as Y,Ut as Z,Tt as _,Dt as $,Mt as aa,Ct as ba,Nt as ca,It as da,Ht as ea,Wt as fa};