conformtools 0.6.12 → 0.6.13

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 (66) hide show
  1. package/README.md +13 -0
  2. package/dist/{account-IUWNSDG5.js → account-F54SG45Q.js} +1 -1
  3. package/dist/agent-hook-setup-RTQT5JEN.js +3 -0
  4. package/dist/{analysis-engine-M7W32RRC.js → analysis-engine-UWIK7AYB.js} +1 -1
  5. package/dist/{bridge-6NCHJWE6.js → bridge-PWYOJ7E7.js} +1 -1
  6. package/dist/{chunk-UUXHJNQA.js → chunk-4BTTR6U3.js} +1 -1
  7. package/dist/{chunk-NXJZXXC2.js → chunk-4VFDGL4E.js} +1 -1
  8. package/dist/{chunk-THVX57I3.js → chunk-6WLSIH2N.js} +1 -1
  9. package/dist/{chunk-P3XI63Q2.js → chunk-7W5AFZYX.js} +1 -1
  10. package/dist/chunk-B54TEGMG.js +5 -0
  11. package/dist/chunk-BTS3DFPD.js +7 -0
  12. package/dist/chunk-BYMCZJBQ.js +3 -0
  13. package/dist/{chunk-64X5DLH5.js → chunk-EP4L2BWV.js} +1 -1
  14. package/dist/chunk-ERUN634Q.js +6 -0
  15. package/dist/{chunk-OMPYIH6F.js → chunk-G3HBKJ5L.js} +1 -1
  16. package/dist/{chunk-B77ADB26.js → chunk-H4BU5WA6.js} +1 -1
  17. package/dist/{chunk-SJ56EEFP.js → chunk-I2Y2P5NH.js} +2 -2
  18. package/dist/{chunk-2CY2OOOJ.js → chunk-J43UCJ6G.js} +1 -1
  19. package/dist/chunk-L3HRAIDR.js +8 -0
  20. package/dist/{chunk-LYM757KG.js → chunk-LKQTE6T5.js} +66 -66
  21. package/dist/{chunk-QTA36RVO.js → chunk-LRGA6QJQ.js} +232 -220
  22. package/dist/{chunk-F4PHKOAS.js → chunk-LZRCXSUJ.js} +1 -1
  23. package/dist/chunk-NZLL44HU.js +3 -0
  24. package/dist/chunk-OD445COC.js +7 -0
  25. package/dist/chunk-XI6XF7FQ.js +3 -0
  26. package/dist/{chunk-DFQWQ3EA.js → chunk-Y455Y6V4.js} +1 -1
  27. package/dist/{claude-setup-REU4AOKX.js → claude-setup-NGZ5NDYH.js} +1 -1
  28. package/dist/cli.js +9 -9
  29. package/dist/framing-P5RGN5V3.js +3 -0
  30. package/dist/gfx-worker.js +1 -1
  31. package/dist/{h264-5OGRVYUF.js → h264-JI62TU4W.js} +1 -1
  32. package/dist/{h264-mxf-FTHNCK4B.js → h264-mxf-J2QPZO4U.js} +1 -1
  33. package/dist/hook.js +3 -0
  34. package/dist/host-relink-76CFY32O.js +10 -0
  35. package/dist/hosted-L26AGRIY.js +3 -0
  36. package/dist/hosts-TBHEPV6A.js +3 -0
  37. package/dist/http.js +2 -2
  38. package/dist/{inspect-BJYIDVDN.js → inspect-U656APGR.js} +1 -1
  39. package/dist/{isobmff-DN6MCHEK.js → isobmff-UISATYUR.js} +1 -1
  40. package/dist/{mc-video-TF3MD7LN.js → mc-video-LSTKUKNL.js} +1 -1
  41. package/dist/mcp.js +8 -8
  42. package/dist/{media-MJKEKCPN.js → media-XBNKYKB7.js} +1 -1
  43. package/dist/mxf-ZL57VJ3C.js +3 -0
  44. package/dist/{ops-B2OA7VXN.js → ops-ZQEQXW2N.js} +1 -1
  45. package/dist/probe-ZDX6XNRF.js +3 -0
  46. package/dist/{r3d-7OOZMPWH.js → r3d-R4TLYJVE.js} +1 -1
  47. package/dist/resolve-bridge.py +31 -2
  48. package/dist/{sequence-patch-CN4VC5W3.js → sequence-patch-C2QRIT5V.js} +1 -1
  49. package/dist/{store-4WZQF6YD.js → store-JNWELX35.js} +1 -1
  50. package/dist/timeline-JONFBIA3.js +3 -0
  51. package/package.json +5 -5
  52. package/dist/chunk-3XQI5SIV.js +0 -3
  53. package/dist/chunk-6NLB5TZ2.js +0 -7
  54. package/dist/chunk-G3SZDPDS.js +0 -3
  55. package/dist/chunk-NMH62JSC.js +0 -5
  56. package/dist/chunk-VJN4UXFJ.js +0 -8
  57. package/dist/chunk-XF3YMBI7.js +0 -3
  58. package/dist/chunk-XVRTAKDK.js +0 -6
  59. package/dist/framing-CVJM5TT3.js +0 -3
  60. package/dist/host-relink-ZP33BK53.js +0 -10
  61. package/dist/hosted-BWAYLJXR.js +0 -3
  62. package/dist/hosts-H3IKRZF2.js +0 -3
  63. package/dist/mxf-Q5723GPD.js +0 -3
  64. package/dist/probe-72QZKMCC.js +0 -3
  65. package/dist/timeline-ZP5H4YDQ.js +0 -3
  66. /package/dist/{still-SX6RJ7O6.js → still-4UR35GZH.js} +0 -0
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- var s={scrub:{output:"rgba8",detail:"coarse"},thumbnail:{output:"rgba8",detail:"coarse"},park:{output:"rgba8",detail:"exact"},render:{output:"rgba8",detail:"exact"},transcode:{output:"rgb16",detail:"exact"}};function p(e){let t=new DataView(e.buffer,e.byteOffset,8),r=t.getUint32(0,!0),n=t.getUint32(4,!0),o=e.slice(8);return{width:r,height:n,rgb16:new Uint16Array(o.buffer,o.byteOffset,r*n*3)}}var a=class extends Error{constructor(r,n){super(`COVERAGE_MISS: frame ${r} not in linked media (${n} frames)`);this.index=r;this.frameCount=n;this.name="CoverageMissError"}},m=/(?:[A-Z0-9]+_)?COVERAGE_MISS\s+(\{[\s\S]*\})/;function d(e){let r=(e instanceof Error?e.message:String(e??"")).match(m);if(!r)return null;try{return JSON.parse(r[1])}catch{return{reason:"coverage_miss"}}}var i=class extends Error{constructor(r){super(`DELIVERY_COVERAGE_MISS: ${r.reason}`+(r.cut_in!=null?` cut [${r.cut_in}..${r.cut_out}] file_frames ${r.file_frames}`:""));this.detail=r;this.name="DeliveryCoverageMissError"}};function l(e){return e instanceof i?e.detail:d(e)}var u={mov:()=>import("./isobmff-DN6MCHEK.js").then(e=>e.isobmffFormat),crm:()=>import("./isobmff-DN6MCHEK.js").then(e=>e.isobmffFormat),braw:()=>import("./isobmff-DN6MCHEK.js").then(e=>e.isobmffFormat),wav:()=>import("./wav-HSCUCY4U.js").then(e=>e.wavFormat),mxf:()=>import("./mxf-Q5723GPD.js").then(e=>e.mxfFormat),r3d:()=>import("./r3d-7OOZMPWH.js").then(e=>e.r3dFormat),still:()=>import("./still-SX6RJ7O6.js").then(e=>e.stillFormat),avc1:()=>import("./h264-5OGRVYUF.js").then(e=>e.h264Format),avc3:()=>import("./h264-5OGRVYUF.js").then(e=>e.h264Format),h264:()=>import("./h264-5OGRVYUF.js").then(e=>e.h264Format),hvc1:()=>import("./h264-5OGRVYUF.js").then(e=>e.h264Format),hev1:()=>import("./h264-5OGRVYUF.js").then(e=>e.h264Format),hevc:()=>import("./h264-5OGRVYUF.js").then(e=>e.h264Format),h264_mxf:()=>import("./h264-mxf-FTHNCK4B.js").then(e=>e.h264MxfFormat),mcvideo:()=>import("./mc-video-TF3MD7LN.js").then(e=>e.mcVideoFormat)};async function c(e){let t=u[e];return t?await t():null}async function f(e){let t=await c(e.format);if(!t)throw new Error(`extract: no handler for format '${e.format}'`);return t.extract(e)}async function b(e,t){let r=await c(e.format);if(!r){if(t.verb==="inspect")return null;throw new Error(`mediaOp: no handler for format '${e.format}' (verb ${t.verb})`)}switch(t.verb){case"inspect":{let n=await r.inspect(e);return n&&(n.source_facts_origin="probed"),n}case"sparsify":return r.sparsify(e,t.selection);case"trim":return r.trim(e,t.selection);case"decode":{let{output:n,detail:o}=s[t.intent];if(n==="rgb16"){if(!r.decode16)throw new Error(`mediaOp: format '${e.format}' has no 16-bit decoder (intent '${t.intent}')`);return r.decode16(e,t.index)}if(!r.decode)throw new Error(`mediaOp: format '${e.format}' has no decoder (no viewer)`);return r.decode(e,t.index,{detail:o})}}}export{s as a,p as b,a as c,d,i as e,l as f,c as g,f as h,b as i};
3
+ var s={scrub:{output:"rgba8",detail:"coarse"},thumbnail:{output:"rgba8",detail:"coarse"},park:{output:"rgba8",detail:"exact"},render:{output:"rgba8",detail:"exact"},transcode:{output:"rgb16",detail:"exact"}};function p(e){let t=new DataView(e.buffer,e.byteOffset,8),r=t.getUint32(0,!0),n=t.getUint32(4,!0),o=e.slice(8);return{width:r,height:n,rgb16:new Uint16Array(o.buffer,o.byteOffset,r*n*3)}}var a=class extends Error{constructor(r,n){super(`COVERAGE_MISS: frame ${r} not in linked media (${n} frames)`);this.index=r;this.frameCount=n;this.name="CoverageMissError"}},m=/(?:[A-Z0-9]+_)?COVERAGE_MISS\s+(\{[\s\S]*\})/;function d(e){let r=(e instanceof Error?e.message:String(e??"")).match(m);if(!r)return null;try{return JSON.parse(r[1])}catch{return{reason:"coverage_miss"}}}var i=class extends Error{constructor(r){super(`DELIVERY_COVERAGE_MISS: ${r.reason}`+(r.cut_in!=null?` cut [${r.cut_in}..${r.cut_out}] file_frames ${r.file_frames}`:""));this.detail=r;this.name="DeliveryCoverageMissError"}};function l(e){return e instanceof i?e.detail:d(e)}var u={mov:()=>import("./isobmff-UISATYUR.js").then(e=>e.isobmffFormat),crm:()=>import("./isobmff-UISATYUR.js").then(e=>e.isobmffFormat),braw:()=>import("./isobmff-UISATYUR.js").then(e=>e.isobmffFormat),wav:()=>import("./wav-HSCUCY4U.js").then(e=>e.wavFormat),mxf:()=>import("./mxf-ZL57VJ3C.js").then(e=>e.mxfFormat),r3d:()=>import("./r3d-R4TLYJVE.js").then(e=>e.r3dFormat),still:()=>import("./still-4UR35GZH.js").then(e=>e.stillFormat),avc1:()=>import("./h264-JI62TU4W.js").then(e=>e.h264Format),avc3:()=>import("./h264-JI62TU4W.js").then(e=>e.h264Format),h264:()=>import("./h264-JI62TU4W.js").then(e=>e.h264Format),hvc1:()=>import("./h264-JI62TU4W.js").then(e=>e.h264Format),hev1:()=>import("./h264-JI62TU4W.js").then(e=>e.h264Format),hevc:()=>import("./h264-JI62TU4W.js").then(e=>e.h264Format),h264_mxf:()=>import("./h264-mxf-J2QPZO4U.js").then(e=>e.h264MxfFormat),mcvideo:()=>import("./mc-video-LSTKUKNL.js").then(e=>e.mcVideoFormat)};async function c(e){let t=u[e];return t?await t():null}async function f(e){let t=await c(e.format);if(!t)throw new Error(`extract: no handler for format '${e.format}'`);return t.extract(e)}async function b(e,t){let r=await c(e.format);if(!r){if(t.verb==="inspect")return null;throw new Error(`mediaOp: no handler for format '${e.format}' (verb ${t.verb})`)}switch(t.verb){case"inspect":{let n=await r.inspect(e);return n&&(n.source_facts_origin="probed"),n}case"sparsify":return r.sparsify(e,t.selection);case"trim":return r.trim(e,t.selection);case"decode":{let{output:n,detail:o}=s[t.intent];if(n==="rgb16"){if(!r.decode16)throw new Error(`mediaOp: format '${e.format}' has no 16-bit decoder (intent '${t.intent}')`);return r.decode16(e,t.index)}if(!r.decode)throw new Error(`mediaOp: format '${e.format}' has no decoder (no viewer)`);return r.decode(e,t.index,{detail:o})}}}export{s as a,p as b,a as c,d,i as e,l as f,c as g,f as h,b as i};
@@ -0,0 +1,3 @@
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-PHAMF4JF.js";import{A as m,C as v,E as R,F as g,G as D,L as $,Z as k,aa as i,m as b,s as x,t as p,x as S,z as _}from"./chunk-XI6XF7FQ.js";var A="_originalframes",y="zAPPLIED_PATCHES",u=t=>t.replace(/[\\/][^\\/]+[\\/]?$/,""),T=()=>i(b(),"move-undo");async function P(t){let n=[];for await(let a of $(t))a.isFile&&!a.name.startsWith(".")&&n.push(a.name);return n.sort()}async function O(t){let n=[];for await(let a of $(u(t)))a.isDirectory&&/patch/i.test(a.name)&&a.name!==y&&n.push(a.name);return n.sort()}async function C(t,n){let a=new Set(await P(t)),e=[];for(let r of n){let s=i(u(t),r);if(await p(s))for(let w of await P(s))e.push({file:w,folder:r,replaces:a.has(w)})}return e}async function j(t,n,a){if(!await p(t)||!(await x(t)).isDirectory)throw new F("invalid_args",`not a folder: ${t}`);let e=u(t),r=[],s=[];for(let o of await C(t,n)){if(a&&!a.has(`${o.folder}/${o.file}`))continue;if(!o.replaces){r.push(`${o.file}: not in the sequence`);continue}let f=i(t,o.file),c=i(e,o.folder,o.file),l=`${t}${A}`,d=i(l,o.file);for(let h=1;await p(d);h++)d=i(`${t}${A}${String(h).padStart(2,"0")}`,o.file);await m(u(d));try{await g(f,d)}catch(h){r.push(`${o.file}: ${h.message}`);continue}try{await R(c,f)}catch(h){await g(d,f).catch(()=>{}),r.push(`${o.file}: ${h.message}`);continue}s.push({file:o.file,backup:d,patch_src:c,applied:c,folder:o.folder}),l=""}let w=[];if(s.length){let o=i(e,y);await m(o);for(let f of new Set(s.map(c=>c.folder))){let c=i(o,f);for(let l=1;await p(c);l++)c=i(o,`${f}_${l}`);try{await g(i(e,f),c),w.push({from:i(e,f),to:c});for(let l of s)l.folder===f&&(l.applied=i(c,l.file))}catch(l){r.push(`${f}: not filed under ${y} (${l.message})`)}}}if(!s.length)return{patched:0,errors:r};let E=`files-${Date.now().toString(36)}`;return await m(T()),await _(i(T(),`${E}.json`),JSON.stringify({patch:!0,sequence:t,entries:s.map(({folder:o,...f})=>f),folders:w})),{patched:s.length,errors:r,undo_id:E}}async function J(t){let n=[];for(let e of t.folders)await p(e.to)&&!await p(e.from)&&await g(e.to,e.from).catch(r=>n.push({path:e.to,error:r.message}));let a=0;for(let e of t.entries){let r=i(t.sequence,e.file);if(await p(e.backup))try{await p(r)&&await v(r),await g(e.backup,r),a++}catch(s){n.push({path:r,error:s.message})}}for(let e of new Set([...t.entries.map(r=>u(r.backup)),...t.folders.map(r=>u(r.to))]))if(await p(e)&&!(await P(e)).length){let r=!0;for await(let s of $(e)){r=!1;break}r&&await D(e).catch(()=>{})}return{restored:a,failed:n}}var L=t=>k(t),U=async t=>JSON.parse(await S(t));export{A as a,y as b,O as c,C as d,j as e,J as f,L as g,U as h};
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{a as H}from"./chunk-EP4L2BWV.js";import{a as b}from"./chunk-PHAMF4JF.js";import{A as C,B as F,C as w,D as J,L as K,O as X,S as z,T as Y,aa as o,b as c,g as N,m as u,n as B,t as G,x as d,z as $}from"./chunk-XI6XF7FQ.js";var q={transferGB:2e3},f={payg:{id:"payg",name:"Pay As You Go",monthly:0,yearly:0,stripe:{},includes:{web:!0,mcp:!1,app:!1}},web:{id:"web",name:"Web",monthly:10,yearly:100,stripe:{},includes:{web:!0,mcp:!1,app:!1},allowance:{transferGB:50}},indie:{id:"indie",name:"MCP",monthly:49,yearly:490,stripe:{monthly:"price_1T5XDXJ5lnla0aaLasKq49tm",yearly:"price_1T5XDXJ5lnla0aaL2MdMSuI9"},includes:{web:!0,mcp:!0,app:!1},allowance:{transferGB:250}},pro:{id:"pro",name:"App",monthly:199,yearly:1990,stripe:{monthly:"price_1T5X8oJ5lnla0aaLyNJa93H0",yearly:"price_1T5X8oJ5lnla0aaL3dh7b1el"},includes:{web:!0,mcp:!0,app:!0},allowance:q},studio:{id:"studio",name:"Studio",monthly:"custom",yearly:"custom",stripe:{monthly:"price_1T5X7xJ5lnla0aaLoeE1aBlL",yearly:"price_1T5X7xJ5lnla0aaLeBiYo3Di"},includes:{web:!0,mcp:!0,app:!0},allowance:q}};var V={web:!0,mcp:!1,app:!1};var Oe=Object.fromEntries(Object.values(f).flatMap(e=>Object.values(e.stripe).map(t=>[t,e.id])));import{createPrivateKey as $e,createPublicKey as de,sign as Ce,verify as fe}from"node:crypto";import{Buffer as m}from"node:buffer";var me="CONFORMTOOLS_LICENSE_V1",Z=/^[0-9A-F]{8}(-[0-9A-F]{8}){3}$/,W=e=>JSON.stringify({dev_mode:e.dev_mode??!1,email:e.email,expires_at:e.expires_at,features:e.features,issued_at:e.issued_at,machine_fingerprint:e.machine_fingerprint,tier:e.tier});function Q(e){let t=e.split(/\r?\n/).map(r=>r.trim()).filter(r=>r&&!r.startsWith("#")&&!r.startsWith("-----")).join(""),n=JSON.parse(m.from(t,"base64").toString("utf8"));if(n?.magic!==me||!n.payload?.data)throw new Error("not a conform.tools licence");return n.payload}function ee(e,t){let n=m.from(e.signature,"base64"),r=m.from(W(e.data));return n.length!==64?!1:t.some(i=>fe(null,r,de({key:m.concat([m.from("302a300506032b6570032100","hex"),m.from(i)]),format:"der",type:"spki"}),n))}var ge=["cMwVBrEYKMzlG6pC7FF2lNKIoEqGz2xB5yph6clNnTg=","qnheqkkDU09l1oI6h2CFh4uQ97bY/hkTA5niGKH0+X8="],he=ge.map(e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)));function A(){let e=c("CONFORM_RECORDS_DIR");if(e)return e;let t=B(),n=N()==="darwin"?o(t,"Library/Application Support"):N()==="win32"?c("LOCALAPPDATA")??o(t,"AppData/Local"):c("XDG_DATA_HOME")??o(t,".local/share");return o(n,"conform.tools")}var _e=()=>c("CONFORM_LICENSE_PATH")??o(A(),"license.lic"),L=()=>o(A(),"grant.lic"),ye=null;function T(){return ye??=(async()=>{let e=await H();if(!e)return[];let t=await X(e,["machine"],{timeoutMs:15e3}).catch(()=>null);try{return JSON.parse(t?.stdout??"").machines.filter(n=>Z.test(n))}catch{return[]}})()}function we(e,t,n=Date.now()){if(!ee(e,he))return{ok:!1,reason:"invalid licence signature"};let r=Date.parse(e.data.expires_at);return!Number.isFinite(r)||r<n?{ok:!1,reason:`licence expired ${e.data.expires_at}`}:[t??[]].flat().includes(e.data.machine_fingerprint)?{ok:!0,data:e.data}:{ok:!1,reason:"licence is for another machine"}}async function te(){let e;try{e=await d(_e())}catch{return null}try{return we(Q(e),await T())}catch(t){return{ok:!1,reason:t.message}}}var be={production:{supabaseUrl:"https://sttpwvjbpsetzbhrkohl.supabase.co",anonKey:"sb_publishable_cyuIPsrQa5Ye7lqFxjnknQ_ozDuwwzp",appBase:"https://conform.tools"},staging:{supabaseUrl:"https://slxggvbvgzkiwojcgykx.supabase.co",anonKey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNseGdndmJ2Z3praXdvamNneWt4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzEyODUzMTksImV4cCI6MjA4Njg2MTMxOX0.b18iDsWftny0k9VmOCcbN6kLlyZsZ7GULn_jRH9CE9I",appBase:"https://beta.conform.tools"}};function a(){let e=c("CONFORM_ENV")==="staging"?"staging":"production",t=be[e];return{env:e,supabaseUrl:c("CONFORM_SUPABASE_URL")??t.supabaseUrl,anonKey:c("CONFORM_SUPABASE_ANON_KEY")??t.anonKey,appBase:c("CONFORM_APP_BASE")??t.appBase}}var xe=600*1e3,ne=72*3600*1e3,ve=300*1e3,h=()=>o(u(),a().env==="production"?"auth.json":`auth-${a().env}.json`);async function I(){for(let e of new Set([h(),o(u(),"auth.json")]))try{let t=JSON.parse(await d(e));if(t.env===a().env&&t.access_token)return t}catch{}return null}async function Se(){try{for await(let e of K(u())){if(!/^auth(?:-(\w+))?\.json$/.exec(e.name))continue;let n=JSON.parse(await d(o(u(),e.name)));if(n.access_token&&n.env&&n.env!==a().env)return{other_env:n.env}}}catch{}return{}}async function M(e){await C(u()),await $(h(),JSON.stringify(e)),await J(h(),384)}var ie=6e3,v=0,ae=()=>Date.now()<v,oe=()=>{v=Date.now()+6e4};function Xe(){v=0}var se=e=>e.expires_at-60>Date.now()/1e3;async function D(e){let t=await I();return t&&t.refresh_token!==e.refresh_token&&Object.assign(e,t),se(e)}async function ce(e){if(se(e))return e.access_token;if(ae())return null;if(await D(e))return e.access_token;let t=await F(`${h()}.lock`);try{if(await D(e))return e.access_token;let n=a(),r=await fetch(`${n.supabaseUrl}/auth/v1/token?grant_type=refresh_token`,{method:"POST",headers:{apikey:n.anonKey,"content-type":"application/json"},body:JSON.stringify({refresh_token:e.refresh_token}),signal:AbortSignal.timeout(ie)}).catch(s=>{throw oe(),s});if(!r.ok)return r.status!==400&&r.status!==401?null:await D(e)?e.access_token:"";let i=await r.json();return e.access_token=i.access_token,i.refresh_token&&(e.refresh_token=i.refresh_token),e.expires_at=i.expires_at??Math.floor(Date.now()/1e3)+(i.expires_in??3600),await M(e),e.access_token}catch{return null}finally{await t()}}async function ze(){let e=await I();return e&&await ce(e)||null}var g=null;function re(e,t){return{signed_in:!0,entitled:e.entitled,env:a().env,email:e.email,access:e.access,tier:e.tier,trial_days_remaining:e.trial_days_remaining,source:t,...e.entitled?{}:{reason:"not_entitled"},...e.invite_only?{invite_only:!0}:{}}}async function le(e={}){let t=await te();if(t?.ok)return{signed_in:!!await I().catch(()=>null),entitled:!0,env:a().env,email:t.data.email,access:"licence",tier:t.data.tier,source:"licence"};let n=await ke(e);return t&&!n.entitled?{...n,licence_error:t.reason}:n}async function ke(e){if(!e.force&&g&&Date.now()-g.at<xe)return{...g.status,source:"cache"};let t=a(),n=await I();if(!n)return{signed_in:!1,entitled:!1,env:t.env,reason:"not_signed_in",...await Se()};let r=await ce(n);if(r==="")return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(r&&!ae())try{let i=(await T())[0],s=await fetch(`${t.supabaseUrl}/functions/v1/v1-billing/v1/billing/entitlement${i?`?machine=${i}`:""}`,{headers:{authorization:`Bearer ${r}`,apikey:t.anonKey},signal:AbortSignal.timeout(ie)}).catch(l=>{throw oe(),l});if(s.status===401||s.status===403)return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(s.ok){let{grant:l,...S}=(await s.json()).data;i&&await Ae(l),n.last_entitlement=S,n.last_entitlement_at=Date.now(),await M(n);let k=re(S,"live");return g={at:Date.now(),status:k},k}}catch{}if(n.last_entitlement&&n.last_entitlement_at&&Date.now()-n.last_entitlement_at<ne){let i=ne-(Date.now()-n.last_entitlement_at);return{...re(n.last_entitlement,"grace"),grace_remaining_h:Math.round(i/36e4)/10}}return{signed_in:!0,entitled:!1,env:t.env,reason:"offline_grace_expired"}}async function Ae(e){try{if(!e)return await w(L());await C(A()),await $(L(),e)}catch{}}function Le(e){return e.source==="licence"?`${e.email} \xB7 machine licence (${e.tier}) \u2014 runs offline, no account check`:Pe(e)+(e.licence_error?`
4
+ (the machine licence was not used: ${e.licence_error})`:"")}function Pe(e){let t=a();if(!e.signed_in)return`not signed in (${t.env})${e.other_env?`; you are signed in to ${e.other_env} only (each server keeps its own sign-in)`:""}. Run the account_login tool, or \`npx -y conformtools@latest login\` in a terminal.`;if(e.reason==="auth_rejected")return"signed-in session was rejected (expired or revoked) \u2014 sign in again with account_login.";if(e.reason==="offline_grace_expired")return"offline for more than 72 h since the last account check \u2014 reconnect and run account_status.";let n=`${e.email??"(unknown email)"} \xB7 ${t.env}`;if(!e.entitled&&e.invite_only)return`${n}
5
+ the conform.tools engine (the MCP and the app) is invite-only for now, and ${e.email??"this account"} is not on the list. If that is the wrong Google account, run account_logout, then account_login with the invited one.`;if(!e.entitled)return`${n}
6
+ no active plan on ${e.email??"this account"}: the trial has ended and there is no subscription. If that is the wrong Google account, run account_logout, then account_login and pick the account with the plan; otherwise choose a plan at ${t.appBase}/pricing, then run account_status.`;let r=e.access==="trial"?`trial, ${e.trial_days_remaining??"?"} day(s) left`:e.access==="allowlist"?"invited (early access)":`subscribed${e.tier?` (${e.tier})`:""}`,i=P(e),s=i?` \xB7 includes ${[i.web&&"the web tools",i.mcp&&"the MCP",i.app&&"the app"].filter(Boolean).join(", ")||"the web tools"}`:"";return`${n}
7
+ ${r}${s}${e.source==="grace"?` \u2014 offline, using the last check (${e.grace_remaining_h} h of grace left)`:""}`}function P(e){if(e.access==="trial")return V;let t=(e.tier??"").toLowerCase();return(t==="enterprise"?f.studio:f[t])?.includes??null}var ue=()=>le();function Ye(e){ue=e}async function pe(){let e=await ue();if(e.entitled)return e;let t=e.signed_in&&e.reason==="not_entitled"?"not_entitled":"not_signed_in";throw new b(t,Le(e),{account:e})}async function He(){let e=await pe();if(e.source==="licence"||P(e)?.mcp!==!1)return e;throw new b("not_entitled",`The conform.tools MCP is in the MCP plan ($${f.indie.monthly}/mo) and up. ${e.access==="trial"?"Your trial":`Your plan${e.tier?` (${e.tier})`:""}`} includes Timeline Exchange and Conform Connect on ${a().appBase}, but not the engine on this machine. Upgrade at ${a().appBase}/pricing, then run account_status.`,{account:e,needs:"mcp"})}async function qe(){let e=await pe();if(e.source==="licence"||P(e)?.app)return e;throw new b("not_entitled",`The conform.tools app is in the App plan ($${f.pro.monthly}/mo). ${e.access==="trial"?"Your trial":`Your plan${e.tier?` (${e.tier})`:""}`} does not include the app${P(e)?.mcp?" \u2014 it includes the conform.tools MCP: use it from Claude, Claude Code or any MCP client":""}. Upgrade at ${a().appBase}/pricing, then reopen the app.`,{account:e,needs:"app"})}var x=null;function Ve(e={}){if(x)return x;let t=a(),n=crypto.randomUUID().replaceAll("-","");return x=new Promise((r,i)=>{let s=!1,l=_=>{s||(s=!0,clearTimeout(k),setTimeout(()=>S.close(),250),x=null,_())},S=Y({hostname:"127.0.0.1",port:0,onListen:async _=>{let y=`${t.appBase}/plugin-auth?client=engine&port=${_}&state=${n}`,p=await z(y);e.onUrl?.(y,p)}},async _=>{let y=new URL(_.url);if(y.pathname!=="/callback")return new Response("not found",{status:404});let p=y.searchParams,U=p.get("access_token")??"",R=p.get("refresh_token")??"",O=!!U&&!!R&&p.get("state")===n;if(O){let j=Number(p.get("expires_at"));await M({env:t.env,access_token:U,refresh_token:R,expires_at:j>0?j:Math.floor(Date.now()/1e3)+3600}),g=null,v=0,le({force:!0}).then(E=>l(()=>r(E)),E=>l(()=>i(E)))}return new Response(Ie(O),{status:O?200:400,headers:{"content-type":"text/html; charset=utf-8"}})}),k=setTimeout(()=>l(()=>i(new b("not_signed_in","sign-in was not completed within 5 minutes"))),e.timeoutMs??ve)}),x}async function Ze(){g=null,v=0,await G(h())&&await w(h()),await w(L()).catch(()=>{});let e=o(u(),"auth.json");try{JSON.parse(await d(e)).env===a().env&&await w(e)}catch{}}function Ie(e){let[t,n]=e?["Connected","You're signed in \u2014 you can close this tab."]:["Sign-in failed","Please try again."];return`<!doctype html><meta charset=utf-8><title>conform.tools</title><body style='font:16px -apple-system,Helvetica,Arial,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7;color:#1d1d1f'><div style='text-align:center'><div style='font-size:22px;font-weight:700'>conform<span style='color:#ff3c00'>.tools</span></div><div style='margin-top:14px;font-size:20px;font-weight:600'>${t}</div><div style='margin-top:6px;color:#6e6e73'>${n}</div></div></body>`}export{a,ie as b,Xe as c,ze as d,le as e,Le as f,P as g,Ye as h,pe as i,He as j,qe as k,Ve as l,Ze as m};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{readFile as S,writeFile as N,appendFile as q,stat as W,readdir as G,mkdir as _,open as U,copyFile as Y,mkdtemp as K,rm as P,chmod as X,rename as B,cp as Q,statfs as V,realpath as Z}from"node:fs/promises";import{execFile as ee,spawn as j}from"node:child_process";import{createHash as te}from"node:crypto";import{createReadStream as re,chmodSync as ne,cpSync as oe,existsSync as E,statSync as M}from"node:fs";import{homedir as se,tmpdir as ie,platform as ae,release as ce,arch as le,totalmem as ue,availableParallelism as de}from"node:os";import{fileURLToPath as F}from"node:url";import me from"node:http";import fe from"node:http2";import f from"node:process";import{Buffer as $}from"node:buffer";import{basename as pe,dirname as ge,join as b,resolve as C,sep as v}from"node:path";import{createRequire as ye}from"node:module";import{basename as kt,dirname as At,extname as St,join as Ut,relative as Ft,resolve as Dt}from"node:path";{let e=globalThis.fetch,t=typeof globalThis.Deno<"u";e&&!t&&(globalThis.fetch=(async(n,o)=>{let r=typeof n=="string"?n:n instanceof URL?n.href:n.url;if(r.startsWith("file:")){let s=await S(F(r)),i=r.endsWith(".wasm")?"application/wasm":"application/octet-stream";return new Response(s,{status:200,headers:{"content-type":i}})}return e(n,o)}))}var h=e=>f.env[e],Me=()=>Number(h("CONFORM_MEMORY_GB")??0)*2**30||ue(),Ce=()=>de(),Ie=()=>f.argv.slice(2),He=e=>f.exit(e),we=()=>f.platform,Ne=()=>h("CONFORM_PYTHON")??(we()==="win32"?"python":"python3"),We=()=>f.arch,z=()=>`${f.platform}-${f.arch}`;function _e(e){try{return b(ge(ye(import.meta.url).resolve(`${be(z())}/package.json`)),e)}catch{return null}}var be=e=>`conformtools-${e==="win32-x64"?"windows-x64":e}`,Be=e=>`${e} is not in this package for ${z()} (conform.tools builds it for darwin-arm64, darwin-x64, linux-x64 and win32-x64)`;function je(){let e=f.versions.deno;return{platform:`${ae()} ${ce()} ${le()}`,runtime:e?`deno ${e}`:`node ${f.version}`}}var he=()=>h("CONFORM_MCP_HOME")??b(A(),".conform-mcp"),A=()=>h("HOME")??se();function ze(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=F(t)}catch{}return t==="~"?t=A():(t.startsWith("~/")||t.startsWith("~\\"))&&(t=b(A(),t.slice(2))),t&&C(t)+(/[\\/]$/.test(t)&&!/[\\/]$/.test(C(t))?v:"")}async function Le(e,t){let n=await import("node:sqlite").catch(()=>null);if(n?.DatabaseSync){let r=new n.DatabaseSync(e,{readOnly:!0});try{let s=r.prepare(t);return s.setReadBigInts(!0),s.all().map(i=>Object.fromEntries(Object.entries(i).map(([c,a])=>[c,typeof a=="bigint"?Number(a):a])))}finally{r.close()}}let o=await D("sqlite3",["-readonly","-json",e,t]);if(!o.success)throw new Error(`sqlite3 ${pe(e)}: ${o.stderr.trim()||o.stdout.trim()}`);return o.stdout.trim()?JSON.parse(o.stdout):[]}var Je=(e,t)=>e?`${e.replace(/[\\/]+$/,"")}${e.includes("\\")&&!e.includes("/")?"\\":"/"}${t}`:t;function qe(e){let t=F(e),n=t.indexOf(`${v}deno-compile-`);if(n<0||!E(t))return t;let o=t.slice(n+1).split(v).slice(1).join(v),r=b(he(),"bin",o);try{let s=M(t),i=E(r)?M(r):null;return(!i||s.isFile()&&(i.size!==s.size||i.mtimeMs<s.mtimeMs))&&(oe(t,r,{recursive:!0,force:!0}),s.isFile()&&ne(r,493)),r}catch{return t}}var I=null;var x=e=>I?.owns(e)?I:null;async function H(e){let t=await W(e);return{isFile:t.isFile(),isDirectory:t.isDirectory(),size:t.size,mtimeMs:t.mtimeMs}}function R(e){return x(e)?.stat(e,()=>H(e))??H(e)}async function Ge(e){try{return await R(e),!0}catch{return!1}}async function Ye(e){try{return(await R(e)).isFile}catch{return!1}}async function Ke(e){try{return(await R(e)).isDirectory}catch{return!1}}async function Xe(e){x(e)?.guard(e,"read whole file");let t=await S(e);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}var Qe=e=>S(e,"utf8"),Ve=(e,t)=>N(e,t),Ze=(e,t,n)=>n?.append?q(e,t):N(e,t);async function et(e){await _(e,{recursive:!0})}async function tt(e,t={}){let n=Date.now()+(t.timeoutMs??5e3),o=t.staleMs??15e3;for(;;)try{await _(e);break}catch(r){if(r.code!=="EEXIST")throw r;try{if(Date.now()-(await R(e)).mtimeMs>o){await P(e,{recursive:!0,force:!0});continue}}catch{}if(Date.now()>n)break;await new Promise(s=>setTimeout(s,25))}return()=>P(e,{recursive:!0,force:!0}).catch(()=>{})}var rt=e=>P(e,{force:!0}),nt=(e,t)=>X(e,t).catch(()=>{}),ot=(e,t)=>Y(e,t),st=(e,t)=>B(e,t),it=e=>P(e,{recursive:!0,force:!0}),at=(e,t)=>Q(e,t,{recursive:!0,verbatimSymlinks:!0});async function ct(e){try{let t=await V(e);return Number(t.bavail)*Number(t.bsize)}catch{return null}}async function lt(e){try{return await Z(e)}catch{return null}}var ut=(e="conform-")=>K(b(ie(),e));async function*dt(e){let t=async()=>(await G(e,{withFileTypes:!0})).map(n=>({name:n.name,isFile:n.isFile(),isDirectory:n.isDirectory()}));yield*await(x(e)?.readDir(e,t)??t())}async function mt(e){x(e)?.guard(e,"read bytes");let t=await U(e,"r"),n=(await t.stat()).size;return{path:e,size:n,async readAt(o,r){let s=new Uint8Array(r),i=0;for(;i<r;){let{bytesRead:c}=await t.read(s,i,r-i,o+i);if(!c)break;i+=c}return i===r?s:s.subarray(0,i)},close:()=>t.close()}}async function ft(e){let t=await U(e,"w");return{async writeAt(n,o){let r=0;for(;r<o.length;){let{bytesWritten:s}=await t.write(o,r,o.length-r,n+r);r+=s}},truncate:n=>t.truncate(n),close:()=>t.close()}}var L=(e,t)=>{for(let n of t)x(n)?.guard(n,`${e.split(/[\\/]/).pop()} ${t[0]}`)};function D(e,t,n={}){return L(e,t),new Promise(o=>{ee(e,t,{maxBuffer:1<<30,env:n.env?{...f.env,...n.env}:void 0,timeout:n.timeoutMs},(r,s,i)=>{let c=r?.code??0;o({success:!r,code:c,stdout:String(s),stderr:String(i)})})})}var xe="[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 pt(){let e=await D("powershell.exe",["-NoProfile","-NonInteractive","-Command",xe],{timeoutMs:3e4});return ve(e.stdout)}function ve(e){let t;try{t=JSON.parse(e.replace(/^/,"").trim()||"[]")}catch{return[]}return(Array.isArray(t)?t:[t]).flatMap(n=>{let o=n??{},r=Number(o.pid);return!Number.isInteger(r)||r<=0?[]:[{pid:r,args:String(o.cmd||o.exe||""),title:typeof o.title=="string"?o.title:""}]})}function gt(e,t,n,o={}){return L(e,t),new Promise((r,s)=>{let i=j(e,t,{env:o.env?{...f.env,...o.env}:void 0,stdio:["ignore","pipe","pipe"]}),c="";i.stdout.on("data",a=>n(a)),i.stderr.on("data",a=>{c+=new TextDecoder().decode(a)}),i.on("error",s),i.on("close",a=>r({code:a,stderr:c})),o.signal?.addEventListener("abort",()=>i.kill(),{once:!0})})}function yt(e,t,n,o){let r=j(e,t,{stdio:["pipe","pipe","pipe"]});r.stdin.on("error",()=>{}),r.stdout.on("data",a=>n(a)),r.stderr.on("data",a=>o?.(new TextDecoder().decode(a)));let s=new Promise(a=>{r.on("close",l=>a(l)),r.on("error",()=>a(null))}),i=[r,r.stdout,r.stderr,r.stdin],c=a=>{for(let l of i)(a?l.ref:l.unref)?.call(l)};return c(!1),{write:a=>new Promise((l,d)=>{r.stdin.write(a,m=>m?d(m):l())}),hold:c,close:()=>{try{r.stdin.end(),r.kill()}catch{}},exited:s}}async function wt(e){if(h("CONFORM_NO_BROWSER"))return!1;let[t,n]=f.platform==="darwin"?["open",[e]]:f.platform==="win32"?["cmd",["/c","start","",e.replace(/&/g,"^&")]]:["xdg-open",[e]];return(await D(t,n)).success}function bt(e,t){let n=me.createServer(async(o,r)=>{try{let s=[];if(o.method!=="GET"&&o.method!=="HEAD")for await(let m of o)s.push(m);let i=s.length>0,c=new Headers;for(let[m,p]of Object.entries(o.headers))p!=null&&c.set(m,Array.isArray(p)?p.join(", "):p);let a=`http://${o.headers.host??`${e.hostname}:${e.port}`}${o.url??"/"}`,l=new AbortController;r.on("close",()=>{r.writableEnded||l.abort()});let d=await t(new Request(a,{method:o.method,headers:c,body:i?$.concat(s):void 0,signal:l.signal}));if(r.statusCode=d.status,d.headers.forEach((m,p)=>r.setHeader(p,m)),d.body&&d.headers.get("content-type")?.startsWith("text/event-stream")){r.flushHeaders();let m=d.body.getReader();for(l.signal.addEventListener("abort",()=>void m.cancel(),{once:!0});;){let{value:p,done:g}=await m.read();if(g)break;r.write(p)}r.end();return}r.end($.from(await d.arrayBuffer()))}catch(s){r.statusCode=500,r.end(JSON.stringify({ok:!1,code:"internal",message:s instanceof Error?s.message:String(s)}))}});return n.listen(e.port,e.hostname,()=>{let o=n.address();e.onListen?.(typeof o=="object"&&o?o.port:e.port)}),{close:()=>n.close()}}var y=class extends Error{constructor(n,o,r){super(o);this.code=n;this.grpcStatus=r}};function ht(e,t,n,o,r){return new Promise((s,i)=>{let c=fe.connect(`http://${e}:${t}`),a=!1,l=(u,J)=>{a||(a=!0,clearTimeout(m),c.destroy(),u?i(u):s(J))},d=!1;c.on("connect",()=>{d=!0});let m=setTimeout(()=>l(d?new y("deadline",`no answer from ${e}:${t} in ${r} ms`):new y("unavailable",`${e}:${t}: no connection in ${r} ms`)),r);c.on("error",u=>l(new y("unavailable",`${e}:${t}: ${u.message}`)));let p=$.alloc(5+o.length);p.writeUInt32BE(o.length,1),p.set(o,5);let g=c.request({":method":"POST",":path":n,"content-type":"application/grpc",te:"trailers"}),O=[],w,k="",T=u=>{u["grpc-status"]!=null&&(w=String(u["grpc-status"]),k=decodeURIComponent(String(u["grpc-message"]??"")))};g.on("response",T),g.on("trailers",T),g.on("data",u=>O.push(u)),g.on("error",u=>l(new y("unavailable",`${e}:${t}: ${u.message}`))),g.on("end",()=>{if(w!=="0")return l(new y("grpc",`grpc-status ${w??"missing"}${k?`: ${k}`:""}`,w==null?void 0:Number(w)));let u=$.concat(O);if(u.length<5||u[0]!==0)return l(new y("grpc","reply is not one uncompressed gRPC message"));l(null,new Uint8Array(u.subarray(5,5+u.readUInt32BE(1))))}),g.end(p)})}async function xt(e){let t=te("sha256");for await(let n of re(e))t.update(n);return t.digest("hex")}async function vt(e,t,n){let o=`${t}.part`;for(let r=0;;r++){let s=0;try{s=(await W(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),a=await U(o,s?"a":"w");try{let l=s;for await(let d of i.body)await a.write(d),l+=d.length,n?.(l,c)}finally{await a.close()}break}catch(i){if(r>=4)throw i;await new Promise(c=>setTimeout(c,2e3*(r+1)))}}await B(o,t)}function Pt(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}export{F as a,h as b,Me as c,Ce as d,Ie as e,He as f,we as g,Ne as h,We as i,_e as j,Be as k,je as l,he as m,A as n,ze as o,Le as p,Je as q,qe as r,R as s,Ge as t,Ye as u,Ke as v,Xe as w,Qe as x,Ve as y,Ze as z,et as A,tt as B,rt as C,nt as D,ot as E,st as F,it as G,at as H,ct as I,lt as J,ut as K,dt as L,mt as M,ft as N,D as O,pt as P,gt as Q,yt as R,wt as S,bt as T,y as U,ht as V,xt as W,vt as X,Pt as Y,kt as Z,At as _,St as $,Ut as aa,Ft as ba,Dt as ca};
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as R}from"./chunk-PFZVET7S.js";import{b as he,c as be,f as ge}from"./chunk-6V4OEOOX.js";import{f as J,h as fe}from"./chunk-XDI6CPPV.js";import{a as pe}from"./chunk-P3XI63Q2.js";import{i as C}from"./chunk-F4PHKOAS.js";import{b as D,d as K,f as M}from"./chunk-NU3X7P4N.js";import{Ia as de,ea as se,fa as ae,ja as ce,oa as le,wa as ue,xa as me}from"./chunk-DPA26AOI.js";import{a as ie}from"./chunk-PHAMF4JF.js";import{$ as _,A as j,E as W,K as v,L as A,M as ne,P as oe,Y as b,Z as y,_ as L,b as E,c as Z,d as Q,g as q,j as ee,k as re,r as I,s as H,u as te,v as O,y as B}from"./chunk-G3SZDPDS.js";var V=!1;var F=8,Pe=0,Ee=3,z=2;async function Oe(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),o=s=>String.fromCharCode(t[s],t[s+1],t[s+2],t[s+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(o(4)==="RED1"||o(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],i=o(4);return/^[A-Za-z0-9 ]{4}$/.test(i)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function Ae(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Ce(e){return async(t,o)=>new Uint8Array(await e.slice(t,Math.min(t+o,e.size)).arrayBuffer())}function we(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function ir(e){return await de(),_e?_e.clip(e,V?"rec709":"",()=>ye(e)):ye(e)}var _e=null;async function ye(e){let t=await Oe(e),o=[];if(t==="r3d"){let r=e,i=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],n=r.bases??[0],s=async(u,m,d)=>{let f=n[u]+m;return new Uint8Array(await e.slice(f,Math.min(f+d,n[u]+i[u].size)).arrayBuffer())},a=JSON.stringify(i.map(u=>({name:u.name,size:u.size}))),c=JSON.parse(await me(s,a)),l=JSON.parse(await ce(s,a));return i.length===1&&/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&o.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:l.map(u=>({offset:n[u.part??0]+u.essenceOffset,size:u.essenceLength})),w:c.width??0,h:c.height??0,fps:we(c),startFrame:c.timecode?.start_frame??0,dropFrame:c.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:Pe},geometrySpec:{codec:"r3d",subbands:Ee},index:null,warnings:o}}if(t==="mxf"){let r=Ce(e),i=JSON.parse(await ue(r,e.size));if(!i)throw new Error(`${e.name}: MXF index unreadable`);let n=JSON.parse(await le(r,e.size)),s=[];for(let f=0;f<n.frame_count;f++)s.push({offset:n.frames[f*2],size:n.frames[f*2+1]});let a=s.filter(f=>f.size===0).length;a&&o.push(`${a} frame(s) had no locatable picture KLV`);let c=i.width??0,l=i.height??0,u=(i.inner_codec??"").toLowerCase(),m=null,d="MXF";return u==="arriraw"?(m={codec:"arriraw",w:c,h:l,scale:F},d="ARRIRAW"):u==="xocn"?(m={codec:"xocn",scale:F,...V?{display:"rec709"}:{}},d="X-OCN"):await ae(r,e.size)?(m={codec:"vc3",scale:F},d="DNxHR"):await se(r,e.size)?(m={codec:"prores"},d="ProRes"):o.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:m?s:[],w:c,h:l,fps:we(i),startFrame:i.timecode?.start_frame??0,dropFrame:i.timecode?.drop_frame??!1,label:d,spec:m,geometrySpec:m&&m.codec==="arriraw"?{...m,scale:z}:m&&m.codec==="xocn"?{codec:"xocn",scale:z,...V?{display:"rec709"}:{}}:m&&m.codec==="vc3"?{codec:"vc3",scale:z}:null,index:null,warnings:o}}if(t==="isobmff"){let r=await fe(e),i=Ae(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:J(r.kind),spec:{codec:"prores"},geometrySpec:null,index:r,warnings:o};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:J(r.kind),spec:null,geometrySpec:null,index:r,warnings:o};let n=i==="braw"?{codec:"braw",scale:F}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:F}:null;return n||o.push(`codec ${r.codec} not wired to the fingerprint pool`),{frames:n?r.offs:[],w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:n?i==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:n,geometrySpec:n?{...n,scale:z}:null,index:r,warnings:o}}throw new Error(`${e.name}: unrecognised container`)}var De=Number(E("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(Q()/2),Math.floor(Z()/2**31))),X=0,xe=[],ze=async(...e)=>{X>=De?await new Promise(t=>xe.push(t)):X++;try{return await oe(...e)}finally{let t=xe.shift();t?t():X--}};async function Ne(){let e=q()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[E("CONFORM_NATIVE_DECODE"),ee(e),I(new URL(`./${e}`,import.meta.url)),I(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let o of t)if(await te(o))return o;return null}var $=class extends Error{constructor(o,r){super(r);this.why=o}};function Pr(e){let t=null;try{t=JSON.parse(e.trim().split(`
3
+ import{a as R}from"./chunk-PFZVET7S.js";import{b as he,c as be,f as ge}from"./chunk-6V4OEOOX.js";import{f as J,h as fe}from"./chunk-XDI6CPPV.js";import{a as pe}from"./chunk-7W5AFZYX.js";import{i as C}from"./chunk-LZRCXSUJ.js";import{b as D,d as K,f as M}from"./chunk-NU3X7P4N.js";import{Ia as de,ea as se,fa as ae,ja as ce,oa as le,wa as ue,xa as me}from"./chunk-DPA26AOI.js";import{a as ie}from"./chunk-PHAMF4JF.js";import{$ as L,A as j,F as W,L as v,M as A,N as ne,Q as oe,Z as b,_ as y,aa as _,b as E,c as Z,d as Q,g as q,j as ee,k as re,r as I,s as H,u as te,v as O,y as B}from"./chunk-XI6XF7FQ.js";var V=!1;var F=8,Pe=0,Ee=3,z=2;async function Oe(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),o=s=>String.fromCharCode(t[s],t[s+1],t[s+2],t[s+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(o(4)==="RED1"||o(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],i=o(4);return/^[A-Za-z0-9 ]{4}$/.test(i)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function Ae(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Ce(e){return async(t,o)=>new Uint8Array(await e.slice(t,Math.min(t+o,e.size)).arrayBuffer())}function we(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function ir(e){return await de(),_e?_e.clip(e,V?"rec709":"",()=>ye(e)):ye(e)}var _e=null;async function ye(e){let t=await Oe(e),o=[];if(t==="r3d"){let r=e,i=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],n=r.bases??[0],s=async(u,m,d)=>{let f=n[u]+m;return new Uint8Array(await e.slice(f,Math.min(f+d,n[u]+i[u].size)).arrayBuffer())},a=JSON.stringify(i.map(u=>({name:u.name,size:u.size}))),c=JSON.parse(await me(s,a)),l=JSON.parse(await ce(s,a));return i.length===1&&/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&o.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:l.map(u=>({offset:n[u.part??0]+u.essenceOffset,size:u.essenceLength})),w:c.width??0,h:c.height??0,fps:we(c),startFrame:c.timecode?.start_frame??0,dropFrame:c.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:Pe},geometrySpec:{codec:"r3d",subbands:Ee},index:null,warnings:o}}if(t==="mxf"){let r=Ce(e),i=JSON.parse(await ue(r,e.size));if(!i)throw new Error(`${e.name}: MXF index unreadable`);let n=JSON.parse(await le(r,e.size)),s=[];for(let f=0;f<n.frame_count;f++)s.push({offset:n.frames[f*2],size:n.frames[f*2+1]});let a=s.filter(f=>f.size===0).length;a&&o.push(`${a} frame(s) had no locatable picture KLV`);let c=i.width??0,l=i.height??0,u=(i.inner_codec??"").toLowerCase(),m=null,d="MXF";return u==="arriraw"?(m={codec:"arriraw",w:c,h:l,scale:F},d="ARRIRAW"):u==="xocn"?(m={codec:"xocn",scale:F,...V?{display:"rec709"}:{}},d="X-OCN"):await ae(r,e.size)?(m={codec:"vc3",scale:F},d="DNxHR"):await se(r,e.size)?(m={codec:"prores"},d="ProRes"):o.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:m?s:[],w:c,h:l,fps:we(i),startFrame:i.timecode?.start_frame??0,dropFrame:i.timecode?.drop_frame??!1,label:d,spec:m,geometrySpec:m&&m.codec==="arriraw"?{...m,scale:z}:m&&m.codec==="xocn"?{codec:"xocn",scale:z,...V?{display:"rec709"}:{}}:m&&m.codec==="vc3"?{codec:"vc3",scale:z}:null,index:null,warnings:o}}if(t==="isobmff"){let r=await fe(e),i=Ae(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:J(r.kind),spec:{codec:"prores"},geometrySpec:null,index:r,warnings:o};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:J(r.kind),spec:null,geometrySpec:null,index:r,warnings:o};let n=i==="braw"?{codec:"braw",scale:F}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:F}:null;return n||o.push(`codec ${r.codec} not wired to the fingerprint pool`),{frames:n?r.offs:[],w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:n?i==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:n,geometrySpec:n?{...n,scale:z}:null,index:r,warnings:o}}throw new Error(`${e.name}: unrecognised container`)}var De=Number(E("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(Q()/2),Math.floor(Z()/2**31))),X=0,xe=[],ze=async(...e)=>{X>=De?await new Promise(t=>xe.push(t)):X++;try{return await oe(...e)}finally{let t=xe.shift();t?t():X--}};async function Ne(){let e=q()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[E("CONFORM_NATIVE_DECODE"),ee(e),I(new URL(`./${e}`,import.meta.url)),I(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let o of t)if(await te(o))return o;return null}var $=class extends Error{constructor(o,r){super(r);this.why=o}};function Pr(e){let t=null;try{t=JSON.parse(e.trim().split(`
4
4
  `).pop())}catch{}if(t?.why==="not_entitled")throw new ie("not_entitled",t.detail??"this machine is not licensed");return t?.detail??e.trim()}function Te(e,t){try{let o=JSON.parse(e.trim().split(`
5
5
  `).pop()??"");return new $(o.why,o.detail)}catch{return new $("decoder",`the native decoder exited ${t}: ${e.trim().slice(-300)}`)}}function Ue(e){let t=e.reduce((i,n)=>i+n.length,0),o=new Uint8Array(t),r=0;for(let i of e)o.set(i,r),r+=i.length;return o}async function $e(e,t,o,r,i){let n=await Ne();if(!n)throw new $("missing",re("the native decoder (conformtools-decode)"));let s=null,a=[],c=0,l=d=>{let f=new Uint8Array(d),p=0;for(;p<d;){let h=a[0],g=Math.min(h.length,d-p);f.set(h.subarray(0,g),p),p+=g,g===h.length?a.shift():a[0]=h.subarray(g)}return c-=d,f},u=[e,t,"--width",String(i.width??32768)];i.from!=null&&u.push("--from",String(i.from)),i.count!=null&&u.push("--count",String(i.count)),i.range&&u.push("--range",i.range);let m=await ze(n,u,d=>{if(a.push(d),c+=d.length,!s){let p=Ue(a.splice(0));a.push(p);let h=p.indexOf(10);if(h<0)return;s=JSON.parse(new TextDecoder().decode(p.subarray(0,h))),l(h+1),o(s)}let f=4+s.w*s.h*(s.bpp??(e==="rgb16"?6:4));for(;c>=f;){let p=l(f);r(new DataView(p.buffer).getUint32(0,!0),p.subarray(4))}},{signal:i.signal});if(m.code!==0||!s)throw Te(m.stderr,m.code)}function ve(e,t,o,r={}){return $e("bgra",e,t,o,r)}function Se(e,t,o,r={}){return $e("rgb16",e,t,(i,n)=>o(i,new Uint16Array(n.buffer,n.byteOffset,n.length>>1)),r)}var ke=["none","rle","zips","zip","piz","pxr24","b44","b44a","dwaa","dwab","htj2k"],N=e=>(e>>4)*10+(e&15);function Ie(e){let t=N(e&63),o=N(e>>>8&127),r=N(e>>>16&127),i=N(e>>>24&63),n=s=>String(s).padStart(2,"0");return`${n(i)}:${n(r)}:${n(o)}${e&64?";":":"}${n(t)}`}function He(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||t.getUint32(0,!0)!==20000630)return null;let o={fps:null,timecode:null,width:0,height:0,display:null,compression:null,attributes:[]},r=8,i=()=>{let s=r;for(;r<e.length&&e[r]!==0;)r++;let a=new TextDecoder().decode(e.subarray(s,r));return r++,a},n=s=>({width:t.getInt32(s+8,!0)-t.getInt32(s,!0)+1,height:t.getInt32(s+12,!0)-t.getInt32(s+4,!0)+1});for(;r<e.length;){let s=i();if(!s)break;let a=i();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(o.attributes.push(`${s}:${a}`),s==="framesPerSecond"&&a==="rational"&&c>=8){let l=t.getInt32(r,!0),u=t.getUint32(r+4,!0);o.fps=u?l/u:null}else s==="timeCode"&&a==="timecode"&&c>=8?o.timecode=Ie(t.getUint32(r,!0)):s==="dataWindow"&&a==="box2i"&&c>=16?{width:o.width,height:o.height}=n(r):s==="displayWindow"&&a==="box2i"&&c>=16?o.display=n(r):s==="compression"&&c>=1&&(o.compression=ke[e[r]]??`type ${e[r]}`);r+=c}return o}async function Be(e){let t=e,o=null,r=/^(.*?)\[(\d+)-(\d+)\](.*)$/.exec(b(e));if(await O(e))o=/^(.*?)(\d+)(\.exr)$/i;else{t=y(e);let n=r?[null,r[1],r[2],r[4]]:/^(.*?)(\d+)(\.exr)$/i.exec(b(e));if(!n)return{frames:[e],numbers:[]};let s=a=>a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");o=new RegExp(`^${s(n[1])}(\\d{${n[2].length}})${s(n[3])}$`,"i")}let i=[];for await(let n of v(t)){let s=n.isFile?o.exec(n.name):null;s&&i.push({n:Number(s[s.length===4?2:1]),f:_(t,n.name)})}return i.sort((n,s)=>n.n-s.n),{frames:i.map(n=>n.f),numbers:i.map(n=>n.n)}}async function Re(e){let t=await Be(e),o=t.frames[0];if(!o)throw new Error(`no .exr frames for '${b(e)}'`);let r=await A(o),i;try{i=He(await r.readAt(0,Math.min(r.size,1<<20)))}finally{await r.close()}if(!i)throw new Error(`'${b(o)}' is not an OpenEXR file`);let n=Math.max(1,t.frames.length),s=t.numbers.length>1?t.numbers[t.numbers.length-1]-t.numbers[0]+1-t.numbers.length:0,a=i.fps??0;return{id:b(o),kind:"external",target_url:o,local_path:o,content_kind:n>1?"video":"still",source_fps:i.fps??void 0,source_timecode:i.timecode??void 0,source_resolution_w:i.width,source_resolution_h:i.height,available_range:{start:{value:0,rate:a},duration:{value:n,rate:a}},streams:[{kind:"video",codec:"exr",width:i.width,height:i.height,rate:i.fps??void 0,codec_specific:{compression:i.compression}}],vendor_metadata:{exr:{frames:n,first_frame:t.numbers[0]??null,last_frame:t.numbers[t.numbers.length-1]??null,missing_frames:s,display_window:i.display,attributes:i.attributes,fps_source:i.fps!=null?"header framesPerSecond":"not in the header",timecode_source:i.timecode?"header timeCode (first frame)":"not in the header"}}}}var G=new Set([".mov",".mp4",".m4v",".mxf",".wav",".braw",".crm",".r3d",".aif",".aiff"]);async function je(e){let t=await A(e);return{path:e,file:t,size:t.size}}function We(e){return(t,o)=>e.file.readAt(t,o)}async function Le(e){let t=R(b(e));if(!t)return[e];let o=y(e),r=[];for await(let i of v(o)){if(!i.isFile)continue;let n=R(i.name);n&&n.clipBase===t.clipBase&&r.push({n:n.partNumber,p:_(o,i.name)})}return r.sort((i,n)=>i.n-n.n).map(i=>i.p)}async function Y(e){if(await O(e)){let n=[];for await(let s of v(e))s.isFile&&R(s.name)&&n.push(_(e,s.name));if(!n.length)throw new Error(`'${b(e)}' is a folder with no .R3D parts`);e=n.sort()[0]}let t=be(b(e));if(!t)throw new Error(`unsupported media file '${b(e)}' (supported: ${[...G].join(" ")})`);let o=await Le(e),r=await Promise.all(o.map(je));return{source:ge(t,r.map(n=>he(b(n.path),{fileSize:n.size,read:We(n)}))),parts:r,format:t,anchor:o[0],close:()=>r.forEach(n=>n.file.close())}}async function Je(e,t,o,r){if(!/h264|avc|hevc|h265/.test(o)){let i=null,n=await Y(e);try{return await C(n.source,{verb:"decode",index:t,intent:"park"})}catch(s){i=s}finally{n.close()}try{return await Me(e,t,r)}catch(s){throw/no decoder/.test(String(i))?s:i instanceof Error?i:new Error(String(i))}}return Me(e,t,r)}async function Hr(e,t,o,r={}){if(/\.mxf$/i.test(e)&&(!o||/h264|avc|mxf/.test(o))){let a=null,c=null;try{await Se(e,l=>{a=l},(l,u)=>{l===t&&(c=u.slice())},{from:t,count:1,range:r.range})}catch(l){if(!(l instanceof $)||!/unsupported|missing/.test(l.why))throw l}if(c&&a){let l=a;return{rgb:c,width:l.w,height:l.h,bits:l.bit_depth??16,decoder:"media-core",full_range:l.full_range??null}}}let i=await Je(e,t,o),n=i.width*i.height,s=new Uint16Array(n*3);for(let a=0;a<n;a++)s[a*3]=i.rgba[a*4]*257,s[a*3+1]=i.rgba[a*4+1]*257,s[a*3+2]=i.rgba[a*4+2]*257;return{rgb:s,width:i.width,height:i.height,bits:8,decoder:"8-bit",full_range:null}}async function Me(e,t,o){t=Math.round(t);let r=0,i=0,n=null;if(await ve(e,a=>{r=a.w,i=a.h},(a,c)=>{a===t&&(n=c)},{from:t,count:1,width:o}),!n)throw new Error(`the OS decoder returned no frame ${t} of ${b(e)}`);let s=n;for(let a=0;a<s.length;a+=4){let c=s[a];s[a]=s[a+2],s[a+2]=c}return{rgba:s,width:r,height:i}}async function P(e){if(/\.exr$/i.test(e))return Re(e);let t=await Y(e);try{let o=await C(t.source,{verb:"inspect"});if(!o)throw new Error(`could not read '${b(e)}' as ${t.format}`);return o.target_url=t.anchor,o.local_path=t.anchor,o.id=o.id||b(t.anchor),t.parts.length>1&&((o.vendor_metadata??={}).spanned_parts=t.parts.map(r=>b(r.path))),o.size_bytes=t.parts.reduce((r,i)=>r+i.size,0),o}finally{t.close()}}function Ke(e,t,o,r){let i=Math.abs(r*1001-Math.round(r*1001/1e3)*1e3)<1?Math.round(r)*1e3/1001:r,n=Math.floor(e*i/t+1e-6);return{tc:D(n,r),frames:Math.round(o*i/t)}}var Ve=e=>String(Math.round(e*1e3)/1e3);function Br(e,t){let o=e.streams?.find(m=>m.kind==="video"),r=e.streams?.filter(m=>m.kind==="audio")??[],i=e.vendor_metadata?.bext;if(!o&&e.available_range&&r[0]?.rate){let m=r[0].rate,d=e.available_range.duration.value,p=(t?[t]:[24e3/1001,24]).map(h=>{let g=Ke(i?.time_reference??0,i?.sample_rate||m,d,h);return`${i?`start TC ${g.tc}, `:""}${g.frames} frames @ ${Ve(h)} fps`});return[e.target_url??"",`audio only; ${d} samples (${(d/m).toFixed(3)} s)${i?`; BWF time_reference ${i.time_reference}`:"; no BWF timecode"}`,...p,...t?[]:["(pass fps for the project's rate)"],...r.map((h,g)=>`audio ${r.length>1?`${g+1}: `:""}${h.codec??"pcm"} ${h.channels??"?"}ch ${h.rate} Hz ${h.bit_depth??"?"}-bit`)].join(`
6
6
  `)}let n=e.available_range?.duration?.value??e.declared_duration?.value??null,s=e.source_fps??o?.rate??null,a=e.size_bytes,c=e.vendor_metadata?.spanned_parts,l=o?.codec_specific??{},u=[l.profile?`${l.profile} (${l.fourcc})`:l.fourcc,l.pixel_format,o?.bit_depth?`${o.bit_depth}-bit`:null,l.colr?`color ${l.colr.primaries}/${l.colr.transfer}/${l.colr.matrix} (primaries/transfer/matrix)`:null].filter(Boolean).join(", ");return[e.target_url??"",o?`${o.codec??"?"} ${o.width??"?"}x${o.height??"?"}${s?` @ ${Math.round(s*1e3)/1e3} fps`:""}${u?`; ${u}`:""}`:"no video track",`start TC ${e.source_timecode??"none"}; ${n!=null?`${n} frames`:"length unknown"}${n!=null&&s?` (${(n/s).toFixed(2)} s)`:""}`,r.length?r.map((m,d)=>{let f=m.codec_specific?.channel_layout;return`audio ${r.length>1?`${d+1}: `:""}${m.codec??"pcm"} ${m.channels??"?"}ch${f?` (${f})`:""} ${m.rate??"?"} Hz ${m.bit_depth??"?"}-bit`}).join(`
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{$ as c,A as P,D as p,N as w,a as h,m as C,n as v,t as u,x as y,z as m}from"./chunk-G3SZDPDS.js";import"./chunk-PSANHDZM.js";var b="conformtools-statusline";function O(e,n){let t=e.statusLine;return t&&!String(t.command??"").includes(b)?{settings:e,result:"kept"}:t?.command===n?{settings:e,result:"updated"}:{settings:{...e,statusLine:{type:"command",command:n,padding:0}},result:t?"updated":"installed"}}async function _(){let e=new URL(import.meta.url),n=h(new URL("./statusline.js",e));if(await u(n)){await P(C());let s=c(C(),`${b}.js`);return await p(n,s),`node "${s}"`}let t=h(new URL("../adapters/statusline.ts",e));return await u(t)?`deno run --allow-read --allow-env --no-check "${t}" ${b}`:null}function A(e,n){let t=e.permissions&&typeof e.permissions=="object"?e.permissions:{},s=Array.isArray(t.allow)?t.allow.filter(o=>typeof o=="string"):[];return s.includes(n)?{settings:e,added:!1}:{settings:{...e,permissions:{...t,allow:[...s,n]}},added:!0}}async function T(e={}){let n=e.server??"conformtools",t=`mcp__${n}`,s=e.settingsPath??c(v(),".claude","settings.json"),o={};if(await u(s)){let r=await y(s);try{o=r.trim()?JSON.parse(r):{}}catch(d){throw new Error(`${s} is not valid JSON (${d instanceof Error?d.message:d}); fix it first, nothing was changed`)}}let a=A(o,t),i=a.settings,l="skipped",f=a.added,R=e.statusline===!1?null:await _();if(R){let r=O(i,R);i=r.settings,l=r.result}let k;(f||l==="installed"||l==="updated"&&i!==a.settings)&&(await u(s)?(k=`${s}.conformtools-backup`,await p(s,k)):await Deno.mkdir(c(s,".."),{recursive:!0}),await m(s,JSON.stringify(i,null,2)+`
3
+ import{A as P,E as p,O as w,a as h,aa as c,m as C,n as v,t as u,x as y,z as m}from"./chunk-XI6XF7FQ.js";import"./chunk-PSANHDZM.js";var b="conformtools-statusline";function O(e,n){let t=e.statusLine;return t&&!String(t.command??"").includes(b)?{settings:e,result:"kept"}:t?.command===n?{settings:e,result:"updated"}:{settings:{...e,statusLine:{type:"command",command:n,padding:0}},result:t?"updated":"installed"}}async function _(){let e=new URL(import.meta.url),n=h(new URL("./statusline.js",e));if(await u(n)){await P(C());let s=c(C(),`${b}.js`);return await p(n,s),`node "${s}"`}let t=h(new URL("../adapters/statusline.ts",e));return await u(t)?`deno run --allow-read --allow-env --no-check "${t}" ${b}`:null}function A(e,n){let t=e.permissions&&typeof e.permissions=="object"?e.permissions:{},s=Array.isArray(t.allow)?t.allow.filter(o=>typeof o=="string"):[];return s.includes(n)?{settings:e,added:!1}:{settings:{...e,permissions:{...t,allow:[...s,n]}},added:!0}}async function T(e={}){let n=e.server??"conformtools",t=`mcp__${n}`,s=e.settingsPath??c(v(),".claude","settings.json"),o={};if(await u(s)){let r=await y(s);try{o=r.trim()?JSON.parse(r):{}}catch(d){throw new Error(`${s} is not valid JSON (${d instanceof Error?d.message:d}); fix it first, nothing was changed`)}}let a=A(o,t),i=a.settings,l="skipped",f=a.added,R=e.statusline===!1?null:await _();if(R){let r=O(i,R);i=r.settings,l=r.result}let k;(f||l==="installed"||l==="updated"&&i!==a.settings)&&(await u(s)?(k=`${s}.conformtools-backup`,await p(s,k)):await Deno.mkdir(c(s,".."),{recursive:!0}),await m(s,JSON.stringify(i,null,2)+`
4
4
  `));let g="skipped",x;if(e.register!==!1)try{let r=await w("claude",["mcp","get",n]),d=r.code===0&&r.stdout.includes("conformtools@latest")&&!r.stdout.includes("--prefer-online");if(r.code===0&&!d)g="already";else{d&&await w("claude",["mcp","remove","-s","user",n]);let $=await w("claude",["mcp","add","-s","user",n,"--","npx",...S]);g=$.code===0?d?"updated":"added":"failed",$.code!==0&&(x=$.stderr.trim().slice(-300))}}catch(r){g="failed",x=`claude CLI not found (${r instanceof Error?r.message:r}); add the server with: claude mcp add -s user ${n} -- npx ${S.join(" ")}`}return{settings:s,rule:t,added:f,backup:k,registered:g,detail:x,statusline:l}}function U(e){return[e.added?`Claude Code: allowed every conform.tools tool (${e.rule}) in ${e.settings}${e.backup?` (backup: ${e.backup})`:""}`:`Claude Code: ${e.rule} was already allowed in ${e.settings}`,{already:"MCP server: already registered",added:"MCP server: registered (claude mcp add -s user); every new session runs the newest version",updated:"MCP server: registered again so every new session runs the newest version (it was set up to keep a cached copy)",skipped:"MCP server: not checked",failed:`MCP server: not registered: ${e.detail??"claude mcp add failed"}`}[e.registered],{installed:"Status line: conform.tools (the running job and its progress) at the bottom of Claude Code",updated:"Status line: conform.tools, refreshed",kept:"Status line: you already have one, so it was left as it is (conformtools statusline prints ours)",skipped:"Status line: not installed"}[e.statusline],"Restart Claude Code (or /mcp) to load it. Remove the rule from permissions.allow to be asked again."].join(`
5
5
  `)}var S=["-y","--prefer-online","conformtools@latest","mcp"],L='args = ["-y", "conformtools@latest", "mcp"]',j=e=>`[mcp_servers.${e}]
6
6
  command = "npx"
package/dist/cli.js CHANGED
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{h as F,i as G,l as V,m as Y}from"./chunk-QTA36RVO.js";import"./chunk-XF3YMBI7.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import"./chunk-OMPYIH6F.js";import"./chunk-NMH62JSC.js";import"./chunk-SJ56EEFP.js";import"./chunk-2CY2OOOJ.js";import"./chunk-XVRTAKDK.js";import{P as W,Tc as J,Uc as H}from"./chunk-LYM757KG.js";import"./chunk-IN6XVTUS.js";import"./chunk-DFQWQ3EA.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-NXJZXXC2.js";import{a as A}from"./chunk-B77ADB26.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-WJ5EWXP2.js";import"./chunk-YUO3UWPH.js";import"./chunk-JV7TZDKJ.js";import"./chunk-RGMTLNMF.js";import"./chunk-XDI6CPPV.js";import"./chunk-P3XI63Q2.js";import"./chunk-F4PHKOAS.js";import"./chunk-ISKNIQVO.js";import"./chunk-DKGGJM6Z.js";import"./chunk-THVX57I3.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-UUXHJNQA.js";import"./chunk-N34DQ6MH.js";import{b as L}from"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import"./chunk-VJN4UXFJ.js";import{e as D,f as I}from"./chunk-6NLB5TZ2.js";import"./chunk-64X5DLH5.js";import"./chunk-PHAMF4JF.js";import{b as T,e as l,f as i}from"./chunk-G3SZDPDS.js";import"./chunk-PSANHDZM.js";var c=process.stdout,R=22,E=20,C=E/2,B=(t,n)=>Math.abs(n)<=Math.min(1-.417*Math.abs(t),2.393*(1-Math.abs(t))),et=(t,n)=>t*t+n*n<=1;function rt(t){let n=.62**-t,m=[];for(let r=0;r<E;r++){let a=[];for(let s=0;s<R;s++){let w=(s+.5)/R*2-1,f=(r+.5)/E*2-1,h=!1;if(B(w,f))for(let x=0;x<6;x++)for(let $ of[!1,!0]){let p=.62**x*($?.77:1)*n,y=.5*Math.max(0,1-p)**2;($?et:B)(w/p,(f-y)/p)&&(h=!$)}a.push(h)}m.push(a)}return m}var M={C:["\u25E2\u2588\u25E3","\u2588 ","\u2588 ","\u25E5\u2588\u25E4"],O:["\u25E2\u2588\u25E3","\u2588 \u2588","\u2588 \u2588","\u25E5\u2588\u25E4"],N:["\u2588\u25E3 \u2588","\u2588\u2588\u25E3\u2588","\u2588\u25E5\u2588\u2588","\u2588 \u25E5\u2588"],F:["\u2588\u2588\u2588","\u2588\u2584\u2584","\u2588 ","\u2588 "],R:["\u2588\u2588\u25E3","\u2588 \u2588","\u2588\u2588\u25E4","\u2588 \u2588"],M:["\u2588\u25E3\u25E2\u2588","\u2588\u25E5\u25E4\u2588","\u2588 \u2588","\u2588 \u2588"],T:["\u2588\u2588\u2588"," \u2588 "," \u2588 "," \u2588 "],L:["\u2588 ","\u2588 ","\u2588 ","\u2588\u2588\u2588"],S:["\u25E2\u2588\u25E3","\u25E5\u25E3 "," \u25E5\u25E3","\u25E5\u2588\u25E4"],".":[" "," "," ","\u25CF"]},K="CONFORM.TOOLS",st=[...K].reduce((t,n)=>t+M[n][0].length+1,-1);async function q(t){if(!c.isTTY)return!1;let n=!!T("NO_COLOR"),m=/truecolor|24bit/i.test(T("COLORTERM")??""),r=o=>e=>n?e:`\x1B[${o}m${e}\x1B[0m`,a=r(m?"38;2;255;60;0":"38;5;202"),s=r(m?"38;2;255;222;0":"38;5;220"),w=r("1"),f=r("2"),h=(c.columns??80)>=R+4+st,x=o=>[...K].map(e=>e==="."?a(M[e][o]):w(M[e][o])).join(" "),$=(o,e)=>h&&o>=2&&o<=5?x(o-2):!h&&o===3?`${w("conform")}${a(".")}${w("tools")}`:o===7?e:"",p=(o,e,O=[])=>{let S=rt(o),_=[];for(let g=0;g<C;g++){let tt=S[2*g].map((N,nt)=>{let k=S[2*g+1][nt];return N&&k?"\u2588":N?"\u2580":k?"\u2584":" "}).join(""),ot=g>=8?O[g-8]??"":"";_.push(` ${a(tt)} ${ot||$(g,e)}\x1B[K`)}return _.join(`
3
+ import{h as G,i as V,l as Y,m as B}from"./chunk-LRGA6QJQ.js";import"./chunk-B54TEGMG.js";import"./chunk-I2Y2P5NH.js";import"./chunk-ERUN634Q.js";import"./chunk-J43UCJ6G.js";import"./chunk-NZLL44HU.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import"./chunk-G3HBKJ5L.js";import{Nc as S,P as W,Uc as J,Vc as F}from"./chunk-LKQTE6T5.js";import"./chunk-IN6XVTUS.js";import"./chunk-Y455Y6V4.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-4VFDGL4E.js";import{a as D}from"./chunk-H4BU5WA6.js";import"./chunk-ISKNIQVO.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-WJ5EWXP2.js";import"./chunk-YUO3UWPH.js";import"./chunk-DKGGJM6Z.js";import"./chunk-JV7TZDKJ.js";import"./chunk-RGMTLNMF.js";import"./chunk-XDI6CPPV.js";import"./chunk-7W5AFZYX.js";import"./chunk-LZRCXSUJ.js";import"./chunk-BTS3DFPD.js";import"./chunk-6WLSIH2N.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-4BTTR6U3.js";import"./chunk-N34DQ6MH.js";import{b as L}from"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import"./chunk-L3HRAIDR.js";import{e as H,f as I}from"./chunk-OD445COC.js";import"./chunk-EP4L2BWV.js";import"./chunk-PHAMF4JF.js";import{b as O,e as l,f as c}from"./chunk-XI6XF7FQ.js";import"./chunk-PSANHDZM.js";var m=process.stdout,C=22,E=20,R=E/2,K=(o,n)=>Math.abs(n)<=Math.min(1-.417*Math.abs(o),2.393*(1-Math.abs(o))),so=(o,n)=>o*o+n*n<=1;function ro(o){let n=.62**-o,u=[];for(let s=0;s<E;s++){let a=[];for(let r=0;r<C;r++){let f=(r+.5)/C*2-1,i=(s+.5)/E*2-1,d=!1;if(K(f,i))for(let x=0;x<6;x++)for(let y of[!1,!0]){let p=.62**x*(y?.77:1)*n,$=.5*Math.max(0,1-p)**2;(y?so:K)(f/p,(i-$)/p)&&(d=!y)}a.push(d)}u.push(a)}return u}var A={C:["\u25E2\u2588\u25E3","\u2588 ","\u2588 ","\u25E5\u2588\u25E4"],O:["\u25E2\u2588\u25E3","\u2588 \u2588","\u2588 \u2588","\u25E5\u2588\u25E4"],N:["\u2588\u25E3 \u2588","\u2588\u2588\u25E3\u2588","\u2588\u25E5\u2588\u2588","\u2588 \u25E5\u2588"],F:["\u2588\u2588\u2588","\u2588\u2584\u2584","\u2588 ","\u2588 "],R:["\u2588\u2588\u25E3","\u2588 \u2588","\u2588\u2588\u25E4","\u2588 \u2588"],M:["\u2588\u25E3\u25E2\u2588","\u2588\u25E5\u25E4\u2588","\u2588 \u2588","\u2588 \u2588"],T:["\u2588\u2588\u2588"," \u2588 "," \u2588 "," \u2588 "],L:["\u2588 ","\u2588 ","\u2588 ","\u2588\u2588\u2588"],S:["\u25E2\u2588\u25E3","\u25E5\u25E3 "," \u25E5\u25E3","\u25E5\u2588\u25E4"],".":[" "," "," ","\u25CF"]},q="CONFORM.TOOLS",io=[...q].reduce((o,n)=>o+A[n][0].length+1,-1);async function z(o){if(!m.isTTY)return!1;let n=!!O("NO_COLOR"),u=/truecolor|24bit/i.test(O("COLORTERM")??""),s=t=>e=>n?e:`\x1B[${t}m${e}\x1B[0m`,a=s(u?"38;2;255;60;0":"38;5;202"),r=s(u?"38;2;255;222;0":"38;5;220"),f=s("1"),i=s("2"),d=(m.columns??80)>=C+4+io,x=t=>[...q].map(e=>e==="."?a(A[e][t]):f(A[e][t])).join(" "),y=(t,e)=>d&&t>=2&&t<=5?x(t-2):!d&&t===3?`${f("conform")}${a(".")}${f("tools")}`:t===7?e:"",p=(t,e,T=[])=>{let k=ro(t),P=[];for(let w=0;w<R;w++){let to=k[2*w].map((_,eo)=>{let N=k[2*w+1][eo];return _&&N?"\u2588":_?"\u2580":N?"\u2584":" "}).join(""),no=w>=8?T[w-8]??"":"";P.push(` ${a(to)} ${no||y(w,e)}\x1B[K`)}return P.join(`
4
4
  `)+`
5
- `},y=null;t.account.then(o=>{y=o});let P=o=>L(o,24),X=!T("CI")&&T("TERM")!=="dumb";if(c.write(`
6
- `),X){let o=()=>c.write("\x1B[?25h");process.once("SIGINT",()=>{o(),process.exit(130)}),c.write("\x1B[?25l"+p(0,s(`\u25B6 ${P(0)}`)));let e=Date.now(),O=0;for(;y===null||Date.now()-e<900;)await new Promise(S=>setTimeout(S,1e3/24)),O=Math.round((Date.now()-e)*24/1e3),c.write(`\x1B[${C}A\r`+p(O/22%1,`${s(`\u25B6 ${P(O)}`)} ${f("checking your account\u2026")}`));c.write(`\x1B[${C}A\r`),o()}let Z=(y??await t.account).split(`
7
- `);return c.write(p(0,`${f("v")}${t.version} ${f("\xB7 built by post pros")}`,Z.map(o=>f(o)))),c.write(`
8
- `),!0}var Q=()=>q({version:A,account:Promise.race([D().catch(()=>null),new Promise(t=>setTimeout(t,1500,null))]).then(t=>t?I(t):"account: no answer (offline?)")}),it={login:"account_login",logout:"account_logout",whoami:"account_status",status:"account_status",telemetry:"account_telemetry"};l()[0]==="mcp"&&(await import("./mcp.js"),await new Promise(()=>{}));l()[0]==="http"&&(await import("./http.js"),await new Promise(()=>{}));l()[0]==="statusline"&&((await import("./statusline-GMMCFMOA.js")).main(),i(0));if(l()[0]==="setup"){let t=l()[1];t!=="claude"&&t!=="codex"&&(console.error(`conformtools setup <client>: supported: claude, codex${t?` (not ${t} yet)`:""}`),i(2));let{setupClaude:n,setupText:m,setupCodex:r,codexText:a}=await import("./claude-setup-REU4AOKX.js");try{console.log(t==="codex"?a(await r()):m(await n())),i(0)}catch(s){console.error(s instanceof Error?s.message:String(s)),i(1)}}H("cli");var z=l().includes("--json"),[u,v]=l().filter(t=>t!=="--json");if(!u||u==="--list"||u==="help"||u==="--help"){await Q(),console.log(`conformtools <verb> '<json args>' [--json]
5
+ `},$=null;o.account.then(t=>{$=t});let j=t=>L(t,24),Z=!O("CI")&&O("TERM")!=="dumb";if(m.write(`
6
+ `),Z){let t=()=>m.write("\x1B[?25h");process.once("SIGINT",()=>{t(),process.exit(130)}),m.write("\x1B[?25l"+p(0,r(`\u25B6 ${j(0)}`)));let e=Date.now(),T=0;for(;$===null||Date.now()-e<900;)await new Promise(k=>setTimeout(k,1e3/24)),T=Math.round((Date.now()-e)*24/1e3),m.write(`\x1B[${R}A\r`+p(T/22%1,`${r(`\u25B6 ${j(T)}`)} ${i("checking your account\u2026")}`));m.write(`\x1B[${R}A\r`),t()}let oo=($??await o.account).split(`
7
+ `);return m.write(p(0,`${i("v")}${o.version} ${i("\xB7 built by post pros")}`,oo.map(t=>i(t)))),m.write(`
8
+ `),!0}var U=()=>z({version:D,account:Promise.race([H().catch(()=>null),new Promise(o=>setTimeout(o,1500,null))]).then(o=>o?I(o):"account: no answer (offline?)")}),co={login:"account_login",logout:"account_logout",whoami:"account_status",status:"account_status",telemetry:"account_telemetry"};l()[0]==="mcp"&&(await import("./mcp.js"),await new Promise(()=>{}));l()[0]==="http"&&(await import("./http.js"),await new Promise(()=>{}));l()[0]==="statusline"&&((await import("./statusline-GMMCFMOA.js")).main(),c(0));if(l()[0]==="setup"){let o=l()[1];o!=="claude"&&o!=="codex"&&(console.error(`conformtools setup <client>: supported: claude, codex${o?` (not ${o} yet)`:""}`),c(2));let{setupClaude:n,setupText:u,setupCodex:s,codexText:a}=await import("./claude-setup-NGZ5NDYH.js"),{installAgentHook:r,hooksText:f}=await import("./agent-hook-setup-RTQT5JEN.js");try{console.log(o==="codex"?a(await s()):u(await n())),await S()&&console.log(f([await r(o)])),c(0)}catch(i){console.error(i instanceof Error?i.message:String(i)),c(1)}}if(l()[0]==="hooks"){let{installAllAgentHooks:o,removeAllAgentHooks:n,hooksText:u,hooksRemovedText:s,hooksStatusText:a}=await import("./agent-hook-setup-RTQT5JEN.js"),r=l()[1]??"status";r==="on"?console.log(await S()?u(await o()):"outcome telemetry is off, so the agent hook stays off: conformtools telemetry on first"):r==="off"?console.log(s(await n())):r==="status"?console.log(await a()):(console.error("conformtools hooks on|off|status"),c(2)),c(0)}F("cli");var Q=l().includes("--json"),[g,v]=l().filter(o=>o!=="--json");if(!g||g==="--list"||g==="help"||g==="--help"){await U(),console.log(`conformtools <verb> '<json args>' [--json]
9
9
 
10
10
  login / whoami / logout sign in with your conform.tools Google account
11
11
  telemetry on|off|status outcome telemetry (on by default, content-free; see the README, Feedback and privacy)
12
12
  mcp run as an MCP server (stdio) for Claude Code, Cursor, Codex\u2026
13
13
  http run the local HTTP API on 127.0.0.1:7791
14
- `);let t=W()==="hosted";for(let n of V)console.log(` ${n.name.padEnd(22)} ${n.title}${t&&n.protectedStages?.length?" (on conform.tools)":""}`);t&&console.log(`
15
- (on conform.tools) = the timeline is read or written by conform.tools; the file and its media stay here`),i(0)}var d=it[u]??u,ct=Y(d);ct||(console.error(`unknown verb '${u}' \u2014 conformtools --list`),i(2));d==="account_login"&&console.error("opening the browser to sign in to conform.tools\u2026");var at=d==="account_telemetry"&&v&&!v.trim().startsWith("{")?JSON.stringify({action:v.trim()}):v,U;try{U=JSON.parse(at??"{}")}catch{console.error(`arguments must be JSON, e.g. conformtools ${u} '{"path":"\u2026"}'`),i(2)}var j=G(d,U),b=j.ok?await F(d,j.data):j.result;d==="account_login"&&!b.isError&&!z&&await Q()||console.log(z?JSON.stringify(b.structuredContent??{ok:!b.isError,text:b.content.map(t=>t.text).join(`
16
- `)},null,1):b.content.map(t=>t.text).join(`
17
- `));await J();i(b.isError?1:0);
14
+ `);let o=W()==="hosted";for(let n of Y)console.log(` ${n.name.padEnd(22)} ${n.title}${o&&n.protectedStages?.length?" (on conform.tools)":""}`);o&&console.log(`
15
+ (on conform.tools) = the timeline is read or written by conform.tools; the file and its media stay here`),c(0)}var b=co[g]??g,ao=B(b);ao||(console.error(`unknown verb '${g}' \u2014 conformtools --list`),c(2));b==="account_login"&&console.error("opening the browser to sign in to conform.tools\u2026");var lo=b==="account_telemetry"&&v&&!v.trim().startsWith("{")?JSON.stringify({action:v.trim()}):v,X;try{X=JSON.parse(lo??"{}")}catch{console.error(`arguments must be JSON, e.g. conformtools ${g} '{"path":"\u2026"}'`),c(2)}var M=V(b,X),h=M.ok?await G(b,M.data):M.result;b==="account_login"&&!h.isError&&!Q&&await U()||console.log(Q?JSON.stringify(h.structuredContent??{ok:!h.isError,text:h.content.map(o=>o.text).join(`
16
+ `)},null,1):h.content.map(o=>o.text).join(`
17
+ `));await J();c(h.isError?1:0);
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{lc as a,mc as b,nc as c,oc as d,pc as e,qc as f,rc as g,sc as h,tc as i,uc as j,vc as k,wc as l,xc as m,yc as n}from"./chunk-LKQTE6T5.js";import"./chunk-IN6XVTUS.js";import"./chunk-Y455Y6V4.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-H4BU5WA6.js";import"./chunk-ISKNIQVO.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-WJ5EWXP2.js";import"./chunk-YUO3UWPH.js";import"./chunk-DKGGJM6Z.js";import"./chunk-JV7TZDKJ.js";import"./chunk-RGMTLNMF.js";import"./chunk-XDI6CPPV.js";import"./chunk-7W5AFZYX.js";import"./chunk-LZRCXSUJ.js";import"./chunk-BTS3DFPD.js";import"./chunk-6WLSIH2N.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import"./chunk-L3HRAIDR.js";import"./chunk-OD445COC.js";import"./chunk-EP4L2BWV.js";import"./chunk-PHAMF4JF.js";import"./chunk-XI6XF7FQ.js";import"./chunk-PSANHDZM.js";export{j as ASPECTS,a as INPUT_SCALING,f as SIZING_TARGETS,i as alignText,h as alignTimeline,k as aspectOf,l as blankingForAspect,m as blankingQc,n as blankingText,c as inputFitRatio,g as offlineLane,d as resolveProps,b as scalingOf,e as underRef};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as h,b as d,j as w,l as _}from"./chunk-UUXHJNQA.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import{Ia as u,U as l,W as g}from"./chunk-DPA26AOI.js";import"./chunk-PHAMF4JF.js";import{w as y}from"./chunk-G3SZDPDS.js";import"./chunk-PSANHDZM.js";import{parentPort as p,workerData as C}from"node:worker_threads";import{createCanvas as M,loadImage as A}from"@napi-rs/canvas";var S=(async()=>{await w(C),await u()})(),o=new Map,c=new Map;p.on("message",async t=>{try{await S;let s={};for(let[e,a]of Object.entries(t.images))c.has(a)||c.set(a,await A(await y(a))),s[e]=c.get(a);let m=`${t.fmt.w}x${t.fmt.h}`;o.has(m)||o.set(m,M(t.fmt.w,t.fmt.h));let i=o.get(m).getContext("2d"),v=h(i),r=[],f=null;for(let e=t.from;e<t.to;e++){d(i,t.scene,e/t.fps,t.fmt,v,s);let a=i.getImageData(0,0,t.fmt.w,t.fmt.h).data,n=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);if(f&&_(f,n)){r.push(null);continue}r.push(t.alpha?l(n,t.fmt.w,t.fmt.h,4):g(n,t.fmt.w,t.fmt.h,4)),f=n.slice()}p.postMessage({id:t.id,samples:r},r.filter(e=>!!e).map(e=>e.buffer))}catch(s){p.postMessage({id:t.id,error:s.message??String(s)})}});
3
+ import{a as h,b as d,j as w,l as _}from"./chunk-4BTTR6U3.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import{Ia as u,U as l,W as g}from"./chunk-DPA26AOI.js";import"./chunk-PHAMF4JF.js";import{w as y}from"./chunk-XI6XF7FQ.js";import"./chunk-PSANHDZM.js";import{parentPort as p,workerData as C}from"node:worker_threads";import{createCanvas as M,loadImage as A}from"@napi-rs/canvas";var S=(async()=>{await w(C),await u()})(),o=new Map,c=new Map;p.on("message",async t=>{try{await S;let s={};for(let[e,a]of Object.entries(t.images))c.has(a)||c.set(a,await A(await y(a))),s[e]=c.get(a);let m=`${t.fmt.w}x${t.fmt.h}`;o.has(m)||o.set(m,M(t.fmt.w,t.fmt.h));let i=o.get(m).getContext("2d"),v=h(i),r=[],f=null;for(let e=t.from;e<t.to;e++){d(i,t.scene,e/t.fps,t.fmt,v,s);let a=i.getImageData(0,0,t.fmt.w,t.fmt.h).data,n=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);if(f&&_(f,n)){r.push(null);continue}r.push(t.alpha?l(n,t.fmt.w,t.fmt.h,4):g(n,t.fmt.w,t.fmt.h,4)),f=n.slice()}p.postMessage({id:t.id,samples:r},r.filter(e=>!!e).map(e=>e.buffer))}catch(s){p.postMessage({id:t.id,error:s.message??String(s)})}});
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as O}from"./chunk-TK55FA56.js";import"./chunk-PSANHDZM.js";function v(e,n,t,f){let s=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n;for(;r+8<=t;){let o=s.getUint32(r),a=String.fromCharCode(e[r+4],e[r+5],e[r+6],e[r+7]),c=8;if(o===1){let l=s.getUint32(r+8),g=s.getUint32(r+12);o=l*2**32+g,c=16}else o===0&&(o=t-r);if(o<c||r+o>t)break;f(a,r+c,r+o),r+=o}}var E=new Set(["moov","trak","mdia","minf","stbl"]);function D(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=null,f=(r,o)=>{let a={},c=!1,l=(g,y)=>{v(e,g,y,(w,i,p)=>{if(E.has(w)){l(i,p);return}if(!(!c&&w!=="hdlr"&&w!=="stsd"))switch(w){case"hdlr":{String.fromCharCode(e[i+8],e[i+9],e[i+10],e[i+11])==="vide"&&(c=!0);break}case"stsd":{let u=i+8;a.codec=String.fromCharCode(e[u+4],e[u+5],e[u+6],e[u+7]),a.width=n.getUint16(u+32),a.height=n.getUint16(u+34);break}case"stsz":{let u=n.getUint32(i+4),d=n.getUint32(i+8),m=[];if(u===0)for(let h=0;h<d;h++)m.push(n.getUint32(i+12+h*4));else for(let h=0;h<d;h++)m.push(u);a.sampleSizes=m;break}case"stco":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push(n.getUint32(i+8+m*4));a.chunkOffsets=d;break}case"co64":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++){let h=n.getUint32(i+8+m*8),k=n.getUint32(i+12+m*8);d.push(h*2**32+k)}a.chunkOffsets=d;break}case"stsc":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push({firstChunk:n.getUint32(i+8+m*12),samplesPerChunk:n.getUint32(i+8+m*12+4),descIdx:n.getUint32(i+8+m*12+8)});a.sampleToChunk=d;break}}})};l(r,o),c&&a.chunkOffsets&&a.sampleSizes&&a.sampleToChunk&&(t=a)};if(((r,o)=>{v(e,r,o,(a,c,l)=>{a==="moov"&&v(e,c,l,(g,y,w)=>{g==="trak"&&f(y,w)})})})(0,e.length),!t)throw new Error("could not find a video sample table");return t}function V(e){let n=[],t=0;for(let f=0;f<e.chunkOffsets.length;f++){let s=1;for(let o=0;o<e.sampleToChunk.length;o++)f+1>=e.sampleToChunk[o].firstChunk&&(s=e.sampleToChunk[o].samplesPerChunk);let r=e.chunkOffsets[f];for(let o=0;o<s&&t<e.sampleSizes.length;o++){let a=e.sampleSizes[t];n.push({offset:r,size:a}),r+=a,t++}}return n}var P=(e,n)=>String.fromCharCode(e[n],e[n+1],e[n+2],e[n+3]),z=e=>e.toString(16).padStart(2,"0");function S(e,n,t,f){let s=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n;for(;r+8<=t;){let o=s.getUint32(r),a=8;if(o===1?(o=Number(s.getBigUint64(r+8)),a=16):o===0&&(o=t-r),P(e,r+4)===f)return[r+a,r+o];if(o<a)break;r+=o}return null}function H(e,n,t,f){let s=[n,t];for(let r of f){if(!s)return null;s=S(e,s[0],s[1],r)}return s}function M(e,n,t){let f=S(e,n[0],n[1],"stts");if(!f)return new Int32Array(0);let s=t.getUint32(f[0]+4),r=[],o=0,a=f[0]+8;for(let i=0;i<s;i++){let p=t.getUint32(a),u=t.getInt32(a+4);for(let d=0;d<p;d++)r.push(o),o+=u;a+=8}let c=r.length,l=S(e,n[0],n[1],"ctts"),g=new Float64Array(c);for(let i=0;i<c;i++)g[i]=r[i];if(l){let i=t.getUint32(l[0]+4),p=l[0]+8,u=0;for(let d=0;d<i&&u<c;d++){let m=t.getUint32(p),h=t.getInt32(p+4);for(let k=0;k<m&&u<c;k++)g[u++]+=h;p+=8}}let y=Array.from({length:c},(i,p)=>p).sort((i,p)=>g[i]-g[p]||i-p),w=new Int32Array(c);for(let i=0;i<c;i++)w[y[i]]=i;return w}function F(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=S(e,0,e.length,"moov"),[f,s]=t??[0,e.length],r=f;for(;r+8<=s;){let o=n.getUint32(r),a=8;if(o===1?(o=Number(n.getBigUint64(r+8)),a=16):o===0&&(o=s-r),P(e,r+4)==="trak"){let c=H(e,r+a,r+o,["mdia","minf","stbl"]);if(c){let l=S(e,c[0],c[1],"stsd");if(l){let g=l[0]+8,y=P(e,g+4);if(y==="avc1"||y==="avc3"||y==="hvc1"||y==="hev1"){let w=n.getUint32(g),i=g+8+78,p=y.startsWith("hv")||y.startsWith("he"),u=S(e,i,g+w,p?"hvcC":"avcC");if(!u)return null;let d=e.subarray(u[0],u[1]),m=p?"hvc1.1.6.L93.B0":`avc1.${z(d[1])}${z(d[2])}${z(d[3])}`,h=M(e,c,n),k=h.length,U=S(e,c[0],c[1],"stss"),b=[];if(U){let T=n.getUint32(U[0]+4);for(let C=0;C<T;C++)b.push(n.getUint32(U[0]+8+C*4)-1)}else for(let T=0;T<k;T++)b.push(T);return(b.length===0||b[0]!==0)&&b.unshift(0),b.sort((T,C)=>T-C),{codec:m,description:d,keyframes:b,decodeToPres:h}}}}}if(o<a)break;r+=o}return null}var x=8,R=1500,I=new WeakMap;async function $(e){let n=I.get(e);return n||(n=L(e),I.set(e,n)),n}async function L(e){if(typeof VideoDecoder>"u")throw new Error("h264: WebCodecs (VideoDecoder) not available in this context");let n=e.parts[0],t=await O({fileSize:n.fileSize,read:n.read}),f=V(D(t)),s=F(t);if(!s)throw new Error("h264: no H.264/HEVC config in container");let r=s.decodeToPres.length||f.length,o=new Int32Array(r);for(let l=0;l<s.decodeToPres.length;l++)o[s.decodeToPres[l]]=l;let a=[];for(let l=0;l<s.keyframes.length;l++){let g=s.keyframes[l],y=l+1<s.keyframes.length?s.keyframes[l+1]:f.length;a.push([g,y])}let c={offs:f,cfg:s,gops:a,presToDecode:o,count:r,dec:null,wanted:-1,got:null,gotResolve:null,fedThrough:-1,queue:Promise.resolve()};return c.dec=new VideoDecoder({output:l=>{Number(l.timestamp)===c.wanted&&!c.got?(c.got=l,c.gotResolve?.()):l.close()},error:()=>{c.fedThrough=-1}}),c.dec.configure({codec:s.codec,description:s.description,optimizeForLatency:!0,hardwareAcceleration:"prefer-hardware"}),c}function q(e,n){let t=0,f=e.length-1,s=0;for(;t<=f;){let r=t+f>>1;e[r][0]<=n?(s=r,t=r+1):f=r-1}return s}async function B(e){let n=e.codedWidth,t=e.codedHeight;try{let f=n*t*4,s=new Uint8Array(f);return await e.copyTo(s,{format:"RGBA",colorSpace:"srgb"}),{width:n,height:t,rgba:s}}catch{let s=new OffscreenCanvas(n,t).getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("h264: no 2d context for frame readback");s.drawImage(e,0,0);let r=s.getImageData(0,0,n,t);return{width:n,height:t,rgba:new Uint8Array(r.data.buffer)}}}async function N(e,n){let t=await $(e);if(t.count===0)throw new Error("h264: empty clip");if(n<0||n>=t.count)throw new Error(`COVERAGE_MISS: frame ${n} outside 0..${t.count-1}`);let f,s=new Promise(o=>{f=o}),r=t.queue;t.queue=t.queue.then(()=>s),await r;try{let o=e.parts[0],a=t.presToDecode[n],c=q(t.gops,a),[l,g]=t.gops[c];for(let y=0;y<2;y++){let w=y===0&&t.fedThrough>l&&t.fedThrough<=g&&a>=t.fedThrough,i=w?t.fedThrough:l;if(!w&&t.fedThrough!==-1){try{await t.dec.flush()}catch{}t.fedThrough=-1}let p=Math.min(g,a+1+x);t.wanted=n,t.got=null;let u=new Promise(h=>{t.gotResolve=h});if(p>i){let h=1/0,k=0;for(let b=i;b<p;b++)h=Math.min(h,t.offs[b].offset),k=Math.max(k,t.offs[b].offset+t.offs[b].size);let U=await o.read(h,k-h);for(let b=i;b<p;b++){let T=t.offs[b];t.dec.decode(new EncodedVideoChunk({type:b===l?"key":"delta",timestamp:t.cfg.decodeToPres[b],data:U.subarray(T.offset-h,T.offset-h+T.size)}))}t.fedThrough=p}let d=new Promise(h=>setTimeout(h,R));if(await Promise.race([u,d]),!t.got){try{await t.dec.flush()}catch{}t.fedThrough=-1}let m=t.got;if(t.wanted=-1,t.gotResolve=null,t.got=null,!!m)try{return await B(m)}finally{m.close()}}throw new Error(`h264: frame ${n} did not decode`)}finally{f()}}async function A(){return(await import("./isobmff-DN6MCHEK.js")).isobmffFormat}var J={async inspect(e){return(await A()).inspect(e)},async extract(e){return(await A()).extract(e)},async sparsify(e,n){return(await A()).sparsify(e,n)},async trim(e,n){return(await A()).trim(e,n)},async decode(e,n){return N(e,n)}};export{J as h264Format};
3
+ import{a as O}from"./chunk-TK55FA56.js";import"./chunk-PSANHDZM.js";function v(e,n,t,f){let s=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n;for(;r+8<=t;){let o=s.getUint32(r),a=String.fromCharCode(e[r+4],e[r+5],e[r+6],e[r+7]),c=8;if(o===1){let l=s.getUint32(r+8),g=s.getUint32(r+12);o=l*2**32+g,c=16}else o===0&&(o=t-r);if(o<c||r+o>t)break;f(a,r+c,r+o),r+=o}}var E=new Set(["moov","trak","mdia","minf","stbl"]);function D(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=null,f=(r,o)=>{let a={},c=!1,l=(g,y)=>{v(e,g,y,(w,i,p)=>{if(E.has(w)){l(i,p);return}if(!(!c&&w!=="hdlr"&&w!=="stsd"))switch(w){case"hdlr":{String.fromCharCode(e[i+8],e[i+9],e[i+10],e[i+11])==="vide"&&(c=!0);break}case"stsd":{let u=i+8;a.codec=String.fromCharCode(e[u+4],e[u+5],e[u+6],e[u+7]),a.width=n.getUint16(u+32),a.height=n.getUint16(u+34);break}case"stsz":{let u=n.getUint32(i+4),d=n.getUint32(i+8),m=[];if(u===0)for(let h=0;h<d;h++)m.push(n.getUint32(i+12+h*4));else for(let h=0;h<d;h++)m.push(u);a.sampleSizes=m;break}case"stco":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push(n.getUint32(i+8+m*4));a.chunkOffsets=d;break}case"co64":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++){let h=n.getUint32(i+8+m*8),k=n.getUint32(i+12+m*8);d.push(h*2**32+k)}a.chunkOffsets=d;break}case"stsc":{let u=n.getUint32(i+4),d=[];for(let m=0;m<u;m++)d.push({firstChunk:n.getUint32(i+8+m*12),samplesPerChunk:n.getUint32(i+8+m*12+4),descIdx:n.getUint32(i+8+m*12+8)});a.sampleToChunk=d;break}}})};l(r,o),c&&a.chunkOffsets&&a.sampleSizes&&a.sampleToChunk&&(t=a)};if(((r,o)=>{v(e,r,o,(a,c,l)=>{a==="moov"&&v(e,c,l,(g,y,w)=>{g==="trak"&&f(y,w)})})})(0,e.length),!t)throw new Error("could not find a video sample table");return t}function V(e){let n=[],t=0;for(let f=0;f<e.chunkOffsets.length;f++){let s=1;for(let o=0;o<e.sampleToChunk.length;o++)f+1>=e.sampleToChunk[o].firstChunk&&(s=e.sampleToChunk[o].samplesPerChunk);let r=e.chunkOffsets[f];for(let o=0;o<s&&t<e.sampleSizes.length;o++){let a=e.sampleSizes[t];n.push({offset:r,size:a}),r+=a,t++}}return n}var P=(e,n)=>String.fromCharCode(e[n],e[n+1],e[n+2],e[n+3]),z=e=>e.toString(16).padStart(2,"0");function S(e,n,t,f){let s=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n;for(;r+8<=t;){let o=s.getUint32(r),a=8;if(o===1?(o=Number(s.getBigUint64(r+8)),a=16):o===0&&(o=t-r),P(e,r+4)===f)return[r+a,r+o];if(o<a)break;r+=o}return null}function H(e,n,t,f){let s=[n,t];for(let r of f){if(!s)return null;s=S(e,s[0],s[1],r)}return s}function M(e,n,t){let f=S(e,n[0],n[1],"stts");if(!f)return new Int32Array(0);let s=t.getUint32(f[0]+4),r=[],o=0,a=f[0]+8;for(let i=0;i<s;i++){let p=t.getUint32(a),u=t.getInt32(a+4);for(let d=0;d<p;d++)r.push(o),o+=u;a+=8}let c=r.length,l=S(e,n[0],n[1],"ctts"),g=new Float64Array(c);for(let i=0;i<c;i++)g[i]=r[i];if(l){let i=t.getUint32(l[0]+4),p=l[0]+8,u=0;for(let d=0;d<i&&u<c;d++){let m=t.getUint32(p),h=t.getInt32(p+4);for(let k=0;k<m&&u<c;k++)g[u++]+=h;p+=8}}let y=Array.from({length:c},(i,p)=>p).sort((i,p)=>g[i]-g[p]||i-p),w=new Int32Array(c);for(let i=0;i<c;i++)w[y[i]]=i;return w}function F(e){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=S(e,0,e.length,"moov"),[f,s]=t??[0,e.length],r=f;for(;r+8<=s;){let o=n.getUint32(r),a=8;if(o===1?(o=Number(n.getBigUint64(r+8)),a=16):o===0&&(o=s-r),P(e,r+4)==="trak"){let c=H(e,r+a,r+o,["mdia","minf","stbl"]);if(c){let l=S(e,c[0],c[1],"stsd");if(l){let g=l[0]+8,y=P(e,g+4);if(y==="avc1"||y==="avc3"||y==="hvc1"||y==="hev1"){let w=n.getUint32(g),i=g+8+78,p=y.startsWith("hv")||y.startsWith("he"),u=S(e,i,g+w,p?"hvcC":"avcC");if(!u)return null;let d=e.subarray(u[0],u[1]),m=p?"hvc1.1.6.L93.B0":`avc1.${z(d[1])}${z(d[2])}${z(d[3])}`,h=M(e,c,n),k=h.length,U=S(e,c[0],c[1],"stss"),b=[];if(U){let T=n.getUint32(U[0]+4);for(let C=0;C<T;C++)b.push(n.getUint32(U[0]+8+C*4)-1)}else for(let T=0;T<k;T++)b.push(T);return(b.length===0||b[0]!==0)&&b.unshift(0),b.sort((T,C)=>T-C),{codec:m,description:d,keyframes:b,decodeToPres:h}}}}}if(o<a)break;r+=o}return null}var x=8,R=1500,I=new WeakMap;async function $(e){let n=I.get(e);return n||(n=L(e),I.set(e,n)),n}async function L(e){if(typeof VideoDecoder>"u")throw new Error("h264: WebCodecs (VideoDecoder) not available in this context");let n=e.parts[0],t=await O({fileSize:n.fileSize,read:n.read}),f=V(D(t)),s=F(t);if(!s)throw new Error("h264: no H.264/HEVC config in container");let r=s.decodeToPres.length||f.length,o=new Int32Array(r);for(let l=0;l<s.decodeToPres.length;l++)o[s.decodeToPres[l]]=l;let a=[];for(let l=0;l<s.keyframes.length;l++){let g=s.keyframes[l],y=l+1<s.keyframes.length?s.keyframes[l+1]:f.length;a.push([g,y])}let c={offs:f,cfg:s,gops:a,presToDecode:o,count:r,dec:null,wanted:-1,got:null,gotResolve:null,fedThrough:-1,queue:Promise.resolve()};return c.dec=new VideoDecoder({output:l=>{Number(l.timestamp)===c.wanted&&!c.got?(c.got=l,c.gotResolve?.()):l.close()},error:()=>{c.fedThrough=-1}}),c.dec.configure({codec:s.codec,description:s.description,optimizeForLatency:!0,hardwareAcceleration:"prefer-hardware"}),c}function q(e,n){let t=0,f=e.length-1,s=0;for(;t<=f;){let r=t+f>>1;e[r][0]<=n?(s=r,t=r+1):f=r-1}return s}async function B(e){let n=e.codedWidth,t=e.codedHeight;try{let f=n*t*4,s=new Uint8Array(f);return await e.copyTo(s,{format:"RGBA",colorSpace:"srgb"}),{width:n,height:t,rgba:s}}catch{let s=new OffscreenCanvas(n,t).getContext("2d",{willReadFrequently:!0});if(!s)throw new Error("h264: no 2d context for frame readback");s.drawImage(e,0,0);let r=s.getImageData(0,0,n,t);return{width:n,height:t,rgba:new Uint8Array(r.data.buffer)}}}async function N(e,n){let t=await $(e);if(t.count===0)throw new Error("h264: empty clip");if(n<0||n>=t.count)throw new Error(`COVERAGE_MISS: frame ${n} outside 0..${t.count-1}`);let f,s=new Promise(o=>{f=o}),r=t.queue;t.queue=t.queue.then(()=>s),await r;try{let o=e.parts[0],a=t.presToDecode[n],c=q(t.gops,a),[l,g]=t.gops[c];for(let y=0;y<2;y++){let w=y===0&&t.fedThrough>l&&t.fedThrough<=g&&a>=t.fedThrough,i=w?t.fedThrough:l;if(!w&&t.fedThrough!==-1){try{await t.dec.flush()}catch{}t.fedThrough=-1}let p=Math.min(g,a+1+x);t.wanted=n,t.got=null;let u=new Promise(h=>{t.gotResolve=h});if(p>i){let h=1/0,k=0;for(let b=i;b<p;b++)h=Math.min(h,t.offs[b].offset),k=Math.max(k,t.offs[b].offset+t.offs[b].size);let U=await o.read(h,k-h);for(let b=i;b<p;b++){let T=t.offs[b];t.dec.decode(new EncodedVideoChunk({type:b===l?"key":"delta",timestamp:t.cfg.decodeToPres[b],data:U.subarray(T.offset-h,T.offset-h+T.size)}))}t.fedThrough=p}let d=new Promise(h=>setTimeout(h,R));if(await Promise.race([u,d]),!t.got){try{await t.dec.flush()}catch{}t.fedThrough=-1}let m=t.got;if(t.wanted=-1,t.gotResolve=null,t.got=null,!!m)try{return await B(m)}finally{m.close()}}throw new Error(`h264: frame ${n} did not decode`)}finally{f()}}async function A(){return(await import("./isobmff-UISATYUR.js")).isobmffFormat}var J={async inspect(e){return(await A()).inspect(e)},async extract(e){return(await A()).extract(e)},async sparsify(e,n){return(await A()).sparsify(e,n)},async trim(e,n){return(await A()).trim(e,n)},async decode(e,n){return N(e,n)}};export{J as h264Format};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{Ia as v,na as g,pa as b}from"./chunk-DPA26AOI.js";import"./chunk-PSANHDZM.js";var G=8,P=1500,M=new WeakMap,S=o=>(t,e)=>o.read(t,e);function F(o){let t=new DataView(o.buffer,o.byteOffset,o.byteLength),e=t.getUint32(0,!0),n=[];for(let a=0;a<e;a++)n.push(t.getUint32(4+a*4,!0));let i=[],r=4+e*4;for(let a of n)i.push(o.subarray(r,r+a)),r+=a;return i}function V(o){for(let t=0;t+5<o.length;t++){let e=o[t]===0&&o[t+1]===0&&o[t+2]===0&&o[t+3]===1,n=o[t]===0&&o[t+1]===0&&o[t+2]===1;if(e||n){let i=t+(e?4:3);if((o[i]&31)===7){let r=a=>a.toString(16).padStart(2,"0");return`avc1.${r(o[i+1])}${r(o[i+2])}${r(o[i+3])}`}t=i-1}}return"avc1.640028"}async function A(o){if(typeof VideoDecoder>"u")throw new Error("h264-mxf: WebCodecs (VideoDecoder) not available in this context");await v();let t=o.parts[0],e=S(t),n=JSON.parse(await b(e,t.fileSize));if(!n.raps.length)throw new Error("h264-mxf: no random-access points in MXF index");let i=V(F(await g(e,t.fileSize,0,0))[0]),r={map:n,codec:i,dec:null,wanted:-1,emitted:0,got:null,gotResolve:null,fedGop:-1,fedThrough:-1,queue:Promise.resolve()};return r.dec=new VideoDecoder({output:a=>{r.emitted++===r.wanted&&!r.got?(r.got=a,r.gotResolve?.()):a.close()},error:()=>{r.fedGop=-1,r.fedThrough=-1}}),r.dec.configure({codec:i,codedWidth:n.coded_width||1920,codedHeight:n.coded_height||1088,optimizeForLatency:!0}),r}async function E(o){let t=M.get(o);return t||(t=A(o),M.set(o,t)),t}function D(o,t){let e=o.raps,n=0,i=e.length-1,r=0;for(;n<=i;){let a=n+i>>1;e[a]<=t?(r=a,n=a+1):i=a-1}return{start:e[r],end:r+1<e.length?e[r+1]:o.total_frames}}async function R(o){let t=o.visibleRect,e=t?t.width:o.codedWidth,n=t?t.height:o.codedHeight;try{let i=new Uint8Array(e*n*4);return await o.copyTo(i,{format:"RGBA",colorSpace:"srgb",rect:t??void 0}),{width:e,height:n,rgba:i}}catch{let r=new OffscreenCanvas(e,n).getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("h264-mxf: no 2d context for frame readback");r.drawImage(o,t?t.x:0,t?t.y:0,e,n,0,0,e,n);let a=r.getImageData(0,0,e,n);return{width:e,height:n,rgba:new Uint8Array(a.data.buffer)}}}async function U(o,t){let e=await E(o);if(e.map.total_frames===0)throw new Error("h264-mxf: empty clip");if(t<0||t>=e.map.total_frames)throw new Error(`COVERAGE_MISS: frame ${t} outside 0..${e.map.total_frames-1}`);let n,i=new Promise(a=>{n=a}),r=e.queue;e.queue=e.queue.then(()=>i),await r;try{let a=o.parts[0],w=S(a),{start:c,end:_}=D(e.map,t);for(let u=0;u<2;u++){let f=u===0&&e.fedGop===c&&e.fedThrough>c&&t>=e.fedThrough;if(!f&&e.fedGop!==-1){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let l=f?e.fedThrough:c,h=Math.min(_,t+1+G);f||(e.emitted=0),e.wanted=t-c,e.got=null;let T=new Promise(s=>{e.gotResolve=s});if(h>l){let s=F(await g(w,a.fileSize,l,h-1));for(let d=0;d<s.length;d++){let y=l+d;e.dec.decode(new EncodedVideoChunk({type:y===c?"key":"delta",timestamp:y*1e3,data:s[d]}))}e.fedGop=c,e.fedThrough=h}let x=new Promise(s=>setTimeout(s,P));if(await Promise.race([T,x]),!e.got){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let p=e.got;if(e.wanted=-1,e.gotResolve=null,e.got=null,!!p)try{return await R(p)}finally{p.close()}}throw new Error(`h264-mxf: frame ${t} did not decode`)}finally{n()}}async function m(){return(await import("./mxf-Q5723GPD.js")).mxfFormat}var O={async inspect(o){return(await m()).inspect(o)},async extract(o){return(await m()).extract(o)},async sparsify(o,t){return(await m()).sparsify(o,t)},async trim(o,t){return(await m()).trim(o,t)},async decode(o,t){return U(o,t)}};export{O as h264MxfFormat};
3
+ import{Ia as v,na as g,pa as b}from"./chunk-DPA26AOI.js";import"./chunk-PSANHDZM.js";var G=8,P=1500,M=new WeakMap,S=o=>(t,e)=>o.read(t,e);function F(o){let t=new DataView(o.buffer,o.byteOffset,o.byteLength),e=t.getUint32(0,!0),n=[];for(let a=0;a<e;a++)n.push(t.getUint32(4+a*4,!0));let i=[],r=4+e*4;for(let a of n)i.push(o.subarray(r,r+a)),r+=a;return i}function V(o){for(let t=0;t+5<o.length;t++){let e=o[t]===0&&o[t+1]===0&&o[t+2]===0&&o[t+3]===1,n=o[t]===0&&o[t+1]===0&&o[t+2]===1;if(e||n){let i=t+(e?4:3);if((o[i]&31)===7){let r=a=>a.toString(16).padStart(2,"0");return`avc1.${r(o[i+1])}${r(o[i+2])}${r(o[i+3])}`}t=i-1}}return"avc1.640028"}async function A(o){if(typeof VideoDecoder>"u")throw new Error("h264-mxf: WebCodecs (VideoDecoder) not available in this context");await v();let t=o.parts[0],e=S(t),n=JSON.parse(await b(e,t.fileSize));if(!n.raps.length)throw new Error("h264-mxf: no random-access points in MXF index");let i=V(F(await g(e,t.fileSize,0,0))[0]),r={map:n,codec:i,dec:null,wanted:-1,emitted:0,got:null,gotResolve:null,fedGop:-1,fedThrough:-1,queue:Promise.resolve()};return r.dec=new VideoDecoder({output:a=>{r.emitted++===r.wanted&&!r.got?(r.got=a,r.gotResolve?.()):a.close()},error:()=>{r.fedGop=-1,r.fedThrough=-1}}),r.dec.configure({codec:i,codedWidth:n.coded_width||1920,codedHeight:n.coded_height||1088,optimizeForLatency:!0}),r}async function E(o){let t=M.get(o);return t||(t=A(o),M.set(o,t)),t}function D(o,t){let e=o.raps,n=0,i=e.length-1,r=0;for(;n<=i;){let a=n+i>>1;e[a]<=t?(r=a,n=a+1):i=a-1}return{start:e[r],end:r+1<e.length?e[r+1]:o.total_frames}}async function R(o){let t=o.visibleRect,e=t?t.width:o.codedWidth,n=t?t.height:o.codedHeight;try{let i=new Uint8Array(e*n*4);return await o.copyTo(i,{format:"RGBA",colorSpace:"srgb",rect:t??void 0}),{width:e,height:n,rgba:i}}catch{let r=new OffscreenCanvas(e,n).getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("h264-mxf: no 2d context for frame readback");r.drawImage(o,t?t.x:0,t?t.y:0,e,n,0,0,e,n);let a=r.getImageData(0,0,e,n);return{width:e,height:n,rgba:new Uint8Array(a.data.buffer)}}}async function U(o,t){let e=await E(o);if(e.map.total_frames===0)throw new Error("h264-mxf: empty clip");if(t<0||t>=e.map.total_frames)throw new Error(`COVERAGE_MISS: frame ${t} outside 0..${e.map.total_frames-1}`);let n,i=new Promise(a=>{n=a}),r=e.queue;e.queue=e.queue.then(()=>i),await r;try{let a=o.parts[0],w=S(a),{start:c,end:_}=D(e.map,t);for(let u=0;u<2;u++){let f=u===0&&e.fedGop===c&&e.fedThrough>c&&t>=e.fedThrough;if(!f&&e.fedGop!==-1){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let l=f?e.fedThrough:c,h=Math.min(_,t+1+G);f||(e.emitted=0),e.wanted=t-c,e.got=null;let T=new Promise(s=>{e.gotResolve=s});if(h>l){let s=F(await g(w,a.fileSize,l,h-1));for(let d=0;d<s.length;d++){let y=l+d;e.dec.decode(new EncodedVideoChunk({type:y===c?"key":"delta",timestamp:y*1e3,data:s[d]}))}e.fedGop=c,e.fedThrough=h}let x=new Promise(s=>setTimeout(s,P));if(await Promise.race([T,x]),!e.got){try{await e.dec.flush()}catch{}e.fedGop=-1,e.fedThrough=-1}let p=e.got;if(e.wanted=-1,e.gotResolve=null,e.got=null,!!p)try{return await R(p)}finally{p.close()}}throw new Error(`h264-mxf: frame ${t} did not decode`)}finally{n()}}async function m(){return(await import("./mxf-ZL57VJ3C.js")).mxfFormat}var O={async inspect(o){return(await m()).inspect(o)},async extract(o){return(await m()).extract(o)},async sparsify(o,t){return(await m()).sparsify(o,t)},async trim(o,t){return(await m()).trim(o,t)},async decode(o,t){return U(o,t)}};export{O as h264MxfFormat};
package/dist/hook.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{appendFileSync as Y,mkdirSync as J,readFileSync as d}from"node:fs";import{join as l}from"node:path";import{homedir as K}from"node:os";import{randomUUID as W}from"node:crypto";var w=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"]),x=["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"],E=["aaf","avb","edl","drt","otio","fcpxml","fcpxmld","prproj","ptx","ale","xml","csv"],m=new Set(["xml","csv","png","jpg","jpeg","tif","tiff"]),A=new Set([...x,...E,...m]),S=new Set(["sudo","env","time","nice","nohup","command","exec","xargs","caffeinate","stdbuf","timeout","doas"]),g=e=>(e.replace(/^["']+|["']+$/g,"").split(/[\\/]/).pop()??e).toLowerCase();function T(e){let n=[];for(let o of e.split(/\|\||&&|;|\||\n|\$\(|`/)){let t=o.trim().split(/\s+/).filter(Boolean),r=0;for(;r<t.length&&(/^[A-Za-z_][A-Za-z0-9_]*=/.test(t[r])||S.has(g(t[r]))||t[r].startsWith("-")||/^\d+$/.test(t[r]));)r++;let s=t[r];if(!s)continue;let i=g(s);/^[a-z0-9_.+-]{1,32}$/.test(i)&&!n.includes(i)&&n.push(i)}return n}function v(e){let n=new Set;for(let o of e.matchAll(/\.([A-Za-z0-9]{2,7})(?=["'\s)\]|;,>]|$)/g)){let t=o[1].toLowerCase();A.has(t)&&n.add(t)}return[...n].sort()}function O(e){if(!e||typeof e!="object")return null;let n=e;if(n.hook_event_name==="afterShellExecution"&&typeof n.command=="string")return{command:n.command,client:"cursor"};let o=n.tool_input;if(n.tool_name==="Bash"&&o&&typeof o=="object"&&typeof o.command=="string"){let t=typeof n.transcript_path=="string"?n.transcript_path:"";return{command:o.command,client:/[\\/]\.codex[\\/]/.test(t)?"codex":/[\\/]\.claude[\\/]/.test(t)?"claude-code":null}}return null}function b(e){let n=O(e);if(!n)return null;let o=T(n.command),t=v(n.command),r=o.filter(i=>w.has(i)),s=t.filter(i=>!m.has(i));return!r.length&&!s.length?null:{verb:`shell:${r[0]??o[0]??"sh"}`,fields:t.slice(0,16),counts:{programs:o.length,media_programs:r.length,extensions:t.length},client:n.client}}var c=String.raw`[^\s"'${"`"}<>|,;()[\]{}\\/]+(?: [^\s"'${"`"}<>|,;()[\]{}\\/:]+(?=$|[\s"'${"`"}<>|,;()[\]{}\\/]))*`,_=String.raw`[^\s"'${"`"}<>|,;()[\]{}\\/]+`,C=new RegExp(String.raw`(?<![A-Za-z0-9_.~:\\/-])(?:file://)?(?:~|[A-Za-z]:)?(?:[\\/]${c}){2,}[\\/]?|\\\\${c}(?:\\${c})+`+String.raw`|(?<![A-Za-z0-9_.~:\\/-])${_}(?:[\\/]${_}){2,}`,"g");function N(e){let n=e.replace(/[\\/]+$/,""),o=Math.max(n.lastIndexOf("/"),n.lastIndexOf("\\"));return o>=0?n.slice(o+1):n}var D=(e,n)=>e.length>n?`${e.slice(0,n)}\u2026`:e;var I=/^[A-Za-z0-9_.:-]{1,64}$/;function u(e){return typeof e=="string"&&I.test(e)?e:null}var a=(e,n)=>typeof e=="string"&&n.includes(e)?e:null,M=300,P=["solved","partly","failed"],L=new Set("AAF EDL XML DCP KDM IMF VFX QC OCF MOV MP4 MXF LUT CDL ACES HDR SDR VFR CFR ISO AVB DRT DRP FCP FCPXML OTIO RGB YUV ARRI RED BRAW DNX DNXHD DNXHR HEVC AVC PRORES EXR DPX TIFF TIF PNG JPG JPEG WAV AIFF OMF LTFS UHD NLE API CLI MCP PDF CSV JSON SRT SCC STL TTML PAL NTSC SMPTE LTC VITC CST IDT ODT RRT ALE ASC TC GPU CPU SSD NAS USB HDD MAM DIT VND RAW CC SFX ADR MNE ME LFE HFR DCI DCDM AUDIO NOTE TODO ALL ANY EVERY EACH ONLY NOT NEW OLD AND THE FOR WITH NEVER ALWAYS MUST".split(" ")),F=/\b(?:https?|ftp|s3|gs|file):\/\/\S+/gi,$=/\b[\w.+-]+@[\w-]+(?:\.[\w-]+)+\b/g,j=/\b\d{1,2}[:;]\d{2}[:;]\d{2}[:;.]\d{2,3}\b/g,H=/"[^"]{1,200}"|“[^”]{1,200}”|‘[^’]{1,200}’|(?<![A-Za-z])'[^']{1,200}'(?![A-Za-z])/g,U=/(?<![{\w])[\w][\w.+-]+\.[A-Za-z][A-Za-z0-9]{1,4}\b/g,z=/(?<![{\w])(?=[\w-]*[A-Za-z])(?=[\w-]*\d)(?:[\w]+[_-][\w-]+|[A-Za-z]+\d+[A-Za-z]+\d+\w*)(?![\w}])/g,q=/(?<![{\w])[A-Z][A-Z0-9&]{2,}(?:\s+[A-Z][A-Z0-9&]{2,})*(?![\w}])/g;function p(e,n=M){if(typeof e!="string")return null;let o=e.replace(/\s+/g," ").trim();return o?(o=o.replace(F,"{url}").replace($,"{email}").replace(C,t=>{let r=N(t),s=r.indexOf(" ");return`{path}${s>=0?r.slice(s):""}`}).replace(H,"{text}").replace(j,"{tc}").replace(U,t=>t.toLowerCase()==="conform.tools"?t:"{file}").replace(z,t=>/^\d+-[a-z]+$/.test(t)?t:"{id}").replace(q,t=>t.split(/\s+/).every(r=>L.has(r))?t:"{title}").replace(/\{([^{}]*)\}/g,(t,r)=>/^[a-z_]{1,24}$/.test(r)?`{${r}}`:"{text}"),D(o,n)):null}var X=["outcome","invalid_args","dropped"],Z=300,y=/^[A-Za-z0-9 ._()-]{1,80}$/,h=(e,n)=>typeof e=="number"&&Number.isInteger(e)&&e>0&&e<=n?e:null,V=/^[a-z_]{1,32}$/,k=/^[A-Za-z0-9_.]{1,64}$/,f=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function G(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let n={};for(let[o,t]of Object.entries(e).slice(0,16))V.test(o)&&typeof t=="number"&&Number.isFinite(t)&&t>=0&&(n[o]=Math.round(t));return Object.keys(n).length?n:null}function R(e){if(!e||typeof e!="object")return null;let n=e,o=a(n.kind,X),t=u(n.verb);if(!o||!t)return null;let r=Array.isArray(n.fields)?n.fields.filter(s=>typeof s=="string"&&k.test(s)).slice(0,32):null;return{kind:o,verb:t,ok:o==="outcome"&&typeof n.ok=="boolean"?n.ok:null,code:u(n.code),duration_ms:typeof n.duration_ms=="number"&&Number.isFinite(n.duration_ms)&&n.duration_ms>=0?Math.round(n.duration_ms):null,version:u(n.version),engine:a(n.engine,["local","hosted"]),counts:o!=="invalid_args"?G(n.counts):null,fields:r?.length?r:null,run_id:typeof n.run_id=="string"&&f.test(n.run_id)?n.run_id:null,seq:typeof n.seq=="number"&&Number.isInteger(n.seq)&&n.seq>0&&n.seq<1e6?n.seq:null,run_at:typeof n.run_at=="string"&&!Number.isNaN(Date.parse(n.run_at))?new Date(n.run_at).toISOString():null,event_id:typeof n.event_id=="string"&&f.test(n.event_id)?n.event_id:null,req:typeof n.req=="number"&&Number.isInteger(n.req)&&n.req>0&&n.req<1e6?n.req:null,asked:o==="outcome"?p(n.asked):null,previous:o==="outcome"?a(n.previous,P):null,previous_why:o==="outcome"?p(n.previous_why,200):null,client:typeof n.client=="string"?u(n.client.toLowerCase().replace(/[^a-z0-9_.:-]+/g,"-").slice(0,64)):null,hits:Array.isArray(n.hits)?n.hits.filter(s=>typeof s=="string"&&k.test(s)).slice(0,8):null,error:o==="outcome"&&n.ok===!1?p(n.error,Z):null,platform:typeof n.platform=="string"&&y.test(n.platform)?n.platform:null,runtime:typeof n.runtime=="string"&&y.test(n.runtime)?n.runtime:null,memory_gb:h(n.memory_gb,4096),cpus:h(n.cpus,1024),install:typeof n.install=="string"&&f.test(n.install)?n.install:null}}var B=12*36e5;function Q(e,n=process.env.CONFORM_MCP_HOME??l(K(),".conform-mcp")){try{if(process.env.CONFORM_TELEMETRY==="off"||process.env.CONFORM_TELEMETRY==="0")return"off";let o={};try{o=JSON.parse(d(l(n,"config.json"),"utf8"))}catch{}if(o.telemetry===!1)return"off";let t=b(JSON.parse(e));if(!t)return"not media";let r={};try{r=JSON.parse(d(l(n,"telemetry","run.json"),"utf8"))}catch{}let s=typeof r.at=="string"&&Date.now()-Date.parse(r.at)<B,i=R({kind:"outcome",verb:t.verb,ok:!0,counts:t.counts,fields:t.fields,client:t.client??(s?r.client:null),run_id:s?r.run_id:null,req:s?r.req:null,event_id:W(),run_at:new Date().toISOString(),install:o.install});return i?(J(l(n,"telemetry"),{recursive:!0}),Y(l(n,"telemetry","queue.jsonl"),JSON.stringify(i)+`
3
+ `),"queued"):"nothing"}catch{return"nothing"}}if(import.meta.main??/hook\.(js|ts)$/.test(process.argv[1]??"")){let e="";try{e=d(0,"utf8")}catch{}e.trim()&&Q(e),process.exit(0)}export{Q as main};
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{a as T}from"./chunk-B54TEGMG.js";import{c as D}from"./chunk-ERUN634Q.js";import{R as M,Wb as P,bc as N,fc as q}from"./chunk-LKQTE6T5.js";import"./chunk-IN6XVTUS.js";import{k as A}from"./chunk-Y455Y6V4.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-4VFDGL4E.js";import"./chunk-H4BU5WA6.js";import"./chunk-ISKNIQVO.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-WJ5EWXP2.js";import"./chunk-YUO3UWPH.js";import"./chunk-DKGGJM6Z.js";import"./chunk-JV7TZDKJ.js";import"./chunk-RGMTLNMF.js";import"./chunk-XDI6CPPV.js";import"./chunk-7W5AFZYX.js";import"./chunk-LZRCXSUJ.js";import"./chunk-BTS3DFPD.js";import"./chunk-6WLSIH2N.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import{b as F}from"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import"./chunk-L3HRAIDR.js";import"./chunk-OD445COC.js";import"./chunk-EP4L2BWV.js";import"./chunk-PHAMF4JF.js";import{K as x,L as E,Z as U,_ as R,aa as k,o as O,s as S}from"./chunk-XI6XF7FQ.js";import"./chunk-PSANHDZM.js";var y=s=>{let i=s?.target_url??s?.local_path??"";return i.startsWith("file://")?O(i):i};async function H(s,i){let o=await V(s,i);return await I(s,o.session,i),o}async function I(s,i,o){let r=await s.liveMarkers(o).catch(()=>null);if(!r)return;let l=i.timelines,e=l.find(m=>m.kind!=="compound")??l[0];if(!e)return;let t=(m,f,a,p)=>({id:`live-${p??"tl"}-${m}`,time:{value:m},duration:{value:Math.max(1,f)},color:a.color,name:a.name,note:a.note,...p?{item_id:p}:{}}),n=r.timeline.map(m=>t(m.frame,m.duration,m)),c=e.tracks.filter(m=>m.kind==="Video");for(let m of r.clips){let f=c[m.track-1]?.items.find(a=>a.timeline_range?.start?.value===m.start);if(f)for(let a of m.markers)n.push(t(a.frame,a.duration,a,f.id))}e.markers=n}async function V(s,i){let o=await s.items({timeline:i,kind:"video"}),r=o.items.map(f=>`${f.kind}:${f.track}:${f.start}:${f.end-f.start}`),l=async f=>{let a=await D(f,o.timeline).catch(()=>null);if(!a||!r.every(d=>a.has(d)))return null;let{session:p}=await P(f,"prproj"),u=p.timelines.find(d=>d.name===o.timeline);return u?z(p,u):null};if(o.project_path){let f=await l(o.project_path);if(f)return await C(f),{session:f,from:"the saved project (matches the live sequence)",path:o.project_path};let a=k(R(o.project_path),"Adobe Premiere Pro Auto-Save"),p=U(o.project_path).replace(/\.prproj$/i,""),u=[];try{for await(let d of E(a))d.isFile&&d.name.startsWith(`${p}--`)&&d.name.endsWith(".prproj")&&u.push({path:k(a,d.name),mtime:(await S(k(a,d.name))).mtime?.getTime()??0})}catch{}for(let d of u.sort((g,_)=>_.mtime-g.mtime).slice(0,3)){let g=await l(d.path);if(g&&await C(g),g)return{session:g,from:`Premiere's auto-save of ${new Date(d.mtime).toLocaleTimeString()} (matches the live sequence; the project itself is not saved)`,path:d.path}}}let e=k(await x("conform-ppro-"),"live.otio"),t=await s.export({timeline:i,out_path:e}),{session:n}=await P(t.path,t.format);if(await W(s,n),await Z(n),typeof o.drop_frame=="boolean")for(let f of n.timelines)f.is_drop_frame=o.drop_frame;await C(n);for(let f of n.timelines)for(let a of f.tracks)for(let p of a.items){let u=p;u.scale=null,u.position_x=null,u.position_y=null,u.rotation=null}let c=await s.model(i).then(f=>f.items.filter(a=>Object.keys(a.sizing??{}).length).map(a=>`${a.name??a.file_path.split("/").pop()} (V${a.track} @${a.start-f.start_frame})`)).catch(()=>[]),m=`Premiere's OTIO export carries the cut, not the clips' Motion / Opacity / effects / retimes${c.length?` \u2014 ${c.length} clip(s) here have Motion that will not carry: ${c.slice(0,6).join(", ")}${c.length>6?"\u2026":""}`:""}; save the project (or wait for its auto-save) and run it again for every one of them`;return{session:n,from:"Premiere's OTIO export of the live sequence (no saved or auto-saved copy matches it yet)",path:t.path,lossy:m}}async function C(s){let i=new Set;for(let r of s.media_references??[]){if(r.binding_state==="linked")continue;let l=y(r);l&&await S(l).then(e=>e.isFile,()=>!1)&&i.add(R(l))}let o=s;for(let r of i){let l=await T(o,{media_root:r,gather:"path",criteria:{file_name:!0,file_name_mode:"tight"},lane:"both",reset:!1,dry_run:!1,compare:!1,cap:2e3,remember:!1}).catch(()=>null);l?.changed&&(o=l.session)}return o!==s&&Object.assign(s,o),(s.media_references??[]).filter(r=>r.binding_state==="linked").length}async function Z(s){let i=0;for(let o of s.media_references??[]){if(o.source_resolution_w)continue;let r=y(o),l=r?await A(r).catch(()=>null):null;if(!l)continue;let e=l;for(let t of["source_resolution_w","source_resolution_h","source_pixel_aspect","codec","container","streams"])e[t]!=null&&o[t]==null&&(o[t]=e[t]);o.source_fps??=e.source_fps??null,o.source_timecode??=e.source_timecode??null,!o.available_range&&e.available_range&&(o.available_range=e.available_range),i++}return i}async function re(s,i){let o=i.timelines.filter(t=>t.offline_reference?.clip_id);if(!o.length)return 0;let r=t=>[...t?.clip_list??[],...(t?.folders??[]).flatMap(r)],l=new Map(r((await s.project({clips:!0})).pool).map(t=>[t.id,t])),e=0;for(let t of o){let n=l.get(t.offline_reference.clip_id);if(n?.file){let c=i.media_references.find(m=>y(m)===n.file);c||(c={id:`offline-ref-${t.id??e}`,kind:"external",name:n.name,target_url:`file://${n.file}`,local_path:n.file},i.media_references.push(c)),t.offline_reference.media_reference_id=c.id,e++}else if(n&&n.name!==t.name&&(n.type==="Timeline"||/compound/i.test(n.type??""))){let{createSession:c}=await import("./store-JNWELX35.js"),m=k(await x("conform-offline-ref-"),`${n.name.replace(/[^\w.-]+/g,"_")}.drt`),f=await s.export(n.type==="Timeline"?{timeline:n.name,out_path:m}:{clip_id:n.id,out_path:m}),{session:a}=await P(f.path,"drt");a=(await M(a))?.session??a,t.offline_reference.session_id=(await c(a,f.path,"drt")).id,e++}else t.offline_reference=null}return e}async function W(s,i){let o=(await s.projectClips()).clips,r=new Map(o.filter(e=>e.start_frame!=null&&e.fps).map(e=>[e.file,e])),l=0;for(let e of i.media_references??[]){if(e.source_timecode)continue;let t=r.get(y(e));if(t){e.source_timecode=F(t.start_frame,t.fps),e.source_fps??=t.fps,l++;continue}let n=y(e),c=n?await A(n).catch(()=>null):null;c?.source_timecode&&(e.source_timecode=c.source_timecode,e.source_fps??=c.source_fps??null,l++)}return l}function z(s,i){let o=new Map(s.timelines.map(l=>[l.id,l])),r=[i];for(let l=0;l<r.length;l++)for(let e of r[l].tracks)for(let t of e.items){let n=t.nested_timeline_id,c=n?o.get(n):void 0;c&&!r.includes(c)&&r.push(c)}return{...s,timelines:r}}function X(s,i){let o=new Map((s.media_references??[]).map(n=>[n.id,y(n)])),r=[];for(let n of i.media_references??[]){let c=o.get(n.id),m=y(n);c!==void 0&&m&&m!==c&&r.push({ref_id:n.id,old:c,new:m})}let l=new Map(r.map(n=>[n.ref_id,n])),e=[],t=i.timelines.find(n=>n.kind==="primary")??i.timelines[0];for(let n of t?.tracks??[])if(n.kind==="Video")for(let c of n.items){let m=c.media_reference_id?l.get(c.media_reference_id):void 0;!m||c.kind!=="clip"||!c.source_range||e.push({track:n.track_index,start:c.timeline_range.start.value,duration:c.timeline_range.duration.value,src_in:c.source_range.start.value,path:m.new,name:c.name??""})}return{media:r,cuts:e}}async function oe(s,i){let{session:o,from:r,lossy:l}=await H(s,i.timeline),e=await T(structuredClone(o),{media_root:i.media_root,gather:"walk",reset:!0,lane:"video",dry_run:!1,cap:2e3,criteria:i.criteria??(i.mode==="cut_in"?{file_name:!1,reel_name:!0}:{file_name:!0,file_name_mode:"loose"}),tolerances:i.tolerances}),{media:t,cuts:n}=X(o,e.session),c=[`read from ${r}`,...l&&i.mode==="new_version"?[`\u26A0 ${l}`]:[],`matched ${t.length} medi${t.length===1?"um":"a"} under ${i.media_root} (${n.length} clip use${n.length===1?"":"s"} in the sequence)`],m=t.map(u=>` ${u.old.split("/").pop()} \u2192 ${u.new}`);if(i.dry_run||!t.length)return{text:[...c,...m,i.dry_run?"(dry run \u2014 nothing changed in Premiere)":"",e.text.split(`
4
+ `).slice(-6).join(`
5
+ `)].filter(Boolean).join(`
6
+ `),data:{media:t,cuts:n,from:r}};if(i.mode==="replace"||i.mode==="hires"||i.mode==="proxy"){let d=(await s.projectClips()).clips.flatMap(w=>t.filter(j=>j.old===w.file).map(j=>({clip:w.id,path:j.new,mode:i.mode}))),g=i.mode==="replace"?L(o,e.session,t):new Map,_=g.size?await Y(s,new Set(g.keys())):[],b=await s.relinkClips(d),h=b.results.filter(w=>w.ok).length,$=[...c,`${i.mode==="hires"?"attached full-res behind":i.mode==="proxy"?"attached as proxies to":"repointed"} ${h}/${d.length} project clip(s)${i.mode==="proxy"?" (Toggle Proxies in Premiere switches)":""}`,...m,...b.results.filter(w=>!w.ok).map(w=>` refused: ${w.detail??"Premiere refused"}`)],v=_.length?await B(s,_,g):null;return v&&$.push(...v.lines),{text:$.join(`
7
+ `),data:{media:t,results:b.results,undo_relink:b.undo,...v?{refit:v.data}:{},from:r}}}if(i.mode==="cut_in"){let u=await s.items({timeline:i.timeline,kind:"video"}),d=Math.max(0,...u.items.map(h=>h.track)),g=i.track??d+1,_=await s.cutIn(i.timeline,n.map(h=>({path:h.path,track:g,start:h.start,src_in:h.src_in,duration:h.duration,copy_from:{track:h.track,start:h.start}}))),b=_.results.filter(h=>h.ok).length;return{text:[...c,`cut in ${b}/${n.length} on V${g} (video only, the originals untouched underneath; Edit > Undo ${_.undo_steps}\xD7 in Premiere takes the cuts${_.undo_steps>1?" and the carried sizing":""} back; each return clip keeps its in/out marks)`,...n.map((h,$)=>` V${h.track} @${h.start} ${h.name} \u2192 ${h.path.split("/").pop()} src ${h.src_in}${_.results[$]?.ok?"":` REFUSED: ${_.results[$]?.detail??""}`}`)].join(`
8
+ `),data:{media:t,cuts:n,results:_.results,track:g,from:r}}}let f=e.session.timelines.find(u=>u.kind==="primary")??e.session.timelines[0];f&&(f.name=i.name??`${f.name}_CONFORMED`);let a=await q(e.session,"premiere-prproj",k(await x("conform-ppro-"),"/"),""),p=await s.open({path:a.path});return{text:[...c,`new sequence "${p.timeline}" in ${p.project} (the open sequence is untouched)`,...m,...p.notes,...a.issues.slice(0,10).map(u=>` note: ${u.message}`)].join(`
9
+ `),data:{media:t,path:a.path,sequence:p.timeline,issues:a.issues,from:r}}}function L(s,i,o){let r=new Map,l=(e,t)=>(e.media_references??[]).find(n=>n.id===t);for(let e of o){let t=l(s,e.ref_id),n=l(i,e.ref_id),c=t?.source_resolution_w,m=t?.source_resolution_h,f=n?.source_resolution_w,a=n?.source_resolution_h;!c||!m||!f||!a||c===f||Math.abs(c/m-f/a)>.01||r.set(e.old,c/f)}return r}async function Y(s,i){let o=[];for(let r of(await s.current()).timelines){let l=await s.model(r).catch(()=>null);for(let e of l?.items??[])i.has(e.file_path)&&o.push({sequence:r,track:e.track,start:e.start-l.start_frame,file:e.file_path,zx:e.sizing.ZoomX??1,zy:e.sizing.ZoomY??e.sizing.ZoomX??1,keyframed:!!e.sizing_keyframed})}return o}async function B(s,i,o){let r=[],l={},e=new Map;for(let t of i)(e.get(t.sequence)??e.set(t.sequence,[]).get(t.sequence)).push(t);for(let[t,n]of e){let c=n.filter(a=>a.keyframed),m=n.filter(a=>!a.keyframed).map(a=>{let p=o.get(a.file);return{op:"properties",item:{kind:"video",track:a.track,start:a.start},set:{ZoomX:+(a.zx*p).toFixed(6),ZoomY:+(a.zy*p).toFixed(6)}}}),f=m.length?await s.apply({timeline:t,ops:m}):null;l[t]={rescaled:f?.applied??0,keyframed:c.length,undo:f?.undo??[]},r.push(` "${t}": ${f?.applied??0}/${m.length} use(s) rescaled to keep their framing on the new raster (one Edit > Undo)${c.length?`; ${c.length} with keyframed scale left as they are \u2014 check them`:""}`)}return{lines:["framing kept through the raster change (Premiere's Scale is a percent of the media's pixels):",...r],data:l}}async function G(s){let i=new Set;for(let e of s.timelines)for(let t of e.tracks)for(let n of t.items)n.is_adjustment&&(i.add(n.id),n.is_adjustment=!1);let o=s.timelines.flatMap(e=>e.tracks.flatMap(t=>t.items)).filter(e=>e.kind==="nested").length,r=await M(s);if(!r)throw new Error("un-nesting needs the conform.tools engine on this machine");for(let e of r.session.timelines)for(let t of e.tracks)for(let n of t.items)i.has(n.id)&&(n.is_adjustment=!0);let l=s.timelines[0]?.id;return Object.assign(s,r.session),s.timelines=s.timelines.filter(e=>e.id===l),{summary:`un-nested ${o} nest${o===1?"":"s"}`,issues:r.issues}}async function ae(s,i){let{session:o,from:r,lossy:l}=await H(s,i.timeline),e=await J(o,i.ops,i.name),t=await q(e.session,"premiere-prproj",k(await x("conform-ppro-"),"/"),""),n=await s.open({path:t.path}),c=[...e.issues,...t.issues.map(m=>m.message)];return{text:[`read from ${r}`,...l?[`\u26A0 ${l}`]:[],...e.lines,`new sequence "${n.timeline}" in ${n.project} (the open sequence is untouched)`,...c.slice(0,12).map(m=>` note: ${m}`),...c.length>12?[` \u2026and ${c.length-12} more notes`]:[]].join(`
10
+ `),data:{sequence:n.timeline,path:t.path,notes:c,from:r}}}async function J(s,i,o){let r=[],l=[],e=()=>s.timelines[0];for(let n of i){if(n.kind==="unnest"){let a=await G(s);r.push(a.summary),l.push(...a.issues);continue}let c=new Set(s.timelines.map(a=>a.id)),m=N(s,n.kind,{timeline_id:e()?.id,...n.args??{}});r.push(m.summary);let f=s.timelines.find(a=>!c.has(a.id)&&a.kind!=="compound");f&&(s.timelines=z(s,f).timelines)}let t=e();if(!t)throw new Error("nothing to write: the operations left no timeline");return t.name=o??(i.length===1?`${t.name}_${i[0].kind.toUpperCase()}`:`${t.name}_EDIT`),{session:z(s,t),lines:r,issues:l}}export{C as bindAtRecordedPaths,X as changes,J as editSession,ae as hostEdit,oe as hostRelink,H as premiereSession,Z as probeRefs,L as rasterRatios,I as withLiveMarkers,z as withNests,re as withOfflineReference,W as withPremiereTimecodes};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{a,b,c,d}from"./chunk-6WLSIH2N.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-OD445COC.js";import"./chunk-EP4L2BWV.js";import"./chunk-PHAMF4JF.js";import"./chunk-XI6XF7FQ.js";import"./chunk-PSANHDZM.js";export{a as HOSTED_READ_KEYS,b as readHosted,d as shareOriginal,c as writeHosted};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{f as a,g as b,h as c,i as d,j as e}from"./chunk-I2Y2P5NH.js";import"./chunk-ERUN634Q.js";import"./chunk-J43UCJ6G.js";import"./chunk-LKQTE6T5.js";import"./chunk-IN6XVTUS.js";import"./chunk-Y455Y6V4.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-4VFDGL4E.js";import"./chunk-H4BU5WA6.js";import"./chunk-ISKNIQVO.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-WJ5EWXP2.js";import"./chunk-YUO3UWPH.js";import"./chunk-DKGGJM6Z.js";import"./chunk-JV7TZDKJ.js";import"./chunk-RGMTLNMF.js";import"./chunk-XDI6CPPV.js";import"./chunk-7W5AFZYX.js";import"./chunk-LZRCXSUJ.js";import"./chunk-BTS3DFPD.js";import"./chunk-6WLSIH2N.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import"./chunk-L3HRAIDR.js";import"./chunk-OD445COC.js";import"./chunk-EP4L2BWV.js";import"./chunk-PHAMF4JF.js";import"./chunk-XI6XF7FQ.js";import"./chunk-PSANHDZM.js";export{a as AVID_SETUP,b as FLAME_SETUP,c as NUKE_SETUP,e as adapter,d as setAdapter};
package/dist/http.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as Tt}from"./chunk-3XQI5SIV.js";import{a as wt,b as _t,c as kt,d as yt,e as xt,h as S,i as bt,l as U,m as St}from"./chunk-QTA36RVO.js";import"./chunk-XF3YMBI7.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import"./chunk-OMPYIH6F.js";import"./chunk-NMH62JSC.js";import"./chunk-SJ56EEFP.js";import"./chunk-2CY2OOOJ.js";import"./chunk-XVRTAKDK.js";import{G as ot,Gb as mt,H as rt,Hb as ft,J as dt,P as I,bd as pt,dd as gt,fd as ht}from"./chunk-LYM757KG.js";import"./chunk-IN6XVTUS.js";import"./chunk-DFQWQ3EA.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-NXJZXXC2.js";import{a as nt}from"./chunk-B77ADB26.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-WJ5EWXP2.js";import"./chunk-YUO3UWPH.js";import"./chunk-JV7TZDKJ.js";import"./chunk-RGMTLNMF.js";import"./chunk-XDI6CPPV.js";import"./chunk-P3XI63Q2.js";import"./chunk-F4PHKOAS.js";import"./chunk-ISKNIQVO.js";import"./chunk-DKGGJM6Z.js";import"./chunk-THVX57I3.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-UUXHJNQA.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import{C as v,E as lt,t as H,u as st,v as at,x as it,y as ct,z as ut}from"./chunk-VJN4UXFJ.js";import{k as F}from"./chunk-6NLB5TZ2.js";import"./chunk-64X5DLH5.js";import{a as B}from"./chunk-PHAMF4JF.js";import{$ as b,A as $,B as Z,F as L,J as D,K as q,L as tt,S as et,Y as M,Z as J,b as E,m as P,s as W,t as K,w as X,x as Y,y as A,z as Q}from"./chunk-G3SZDPDS.js";import"./chunk-PSANHDZM.js";import C from"node:process";var Ot=new Map;function Rt(t,s,o,T){let a=`${t}:${o}:${T}`,i=Ot.get(a);return i||(i=(async()=>{let n=b(P(),"cache","grade-luts",t);await $(n);let l=b(n,`V${o}_${T}.cube`);if(!await K(l)){let{adapter:k}=await import("./hosts-H3IKRZF2.js");if((await k("resolve").clipLut({timeline:s,track:o,start:T,out_path:l})).ok===!1)return null}return l})().catch(()=>null),Ot.set(a,i)),i}var Lt=new Set(["/app/convert","/app/canonicalize"]);function Et(t,s){let o=(s??"").split(";")[0].trim().toLowerCase();return o==="application/json"||o==="application/octet-stream"&&Lt.has(t)}function Mt(t){let s=t.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").replace(/[. ]+$/,"")||"timeline";return/^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i.test(s)?`_${s}`:s}var G={id:"local",name:"Local",client_name:null,handles:24,local:!0};async function vt(){try{return JSON.parse(await Y(b(P(),"projects","projects.json")))}catch{return[]}}async function Pt(){let t=await S("project",{action:"list"});if(!t.isError){let s=t.structuredContent?.projects??[];return await $(b(P(),"projects")),await Q(b(P(),"projects","projects.json"),JSON.stringify(s)),{projects:[G,...s],offline:!1}}return{projects:[G,...await vt()],offline:!0,code:String(t.structuredContent?.code??"offline"),reason:String(t.structuredContent?.message??t.content[0]?.text??"")}}async function Ut(t){return t==="local"?G:(await vt()).find(s=>s.id===t)??{id:t,name:t}}async function Ct(t,s,o,T,a=(i,n)=>new Response(i,{headers:{"content-type":n}})){if(s[0]!=="app")return null;let[,i,n,l]=s,k=async()=>t.headers.get("content-type")?.includes("json")?await t.json():{};try{if(i==="policy"&&t.method==="GET"){let{config:e}=await import("./account-IUWNSDG5.js"),r=await fetch(`${e().supabaseUrl}/functions/v1/v1-billing/v1/billing/app-policy`,{signal:AbortSignal.timeout(3e3)}).catch(()=>null);return o(r?.ok?await r.json():{offline:!0})}if(i==="account"&&t.method==="GET"){let e=await S("account_status",{}),r=await F().then(()=>({app:!0}),u=>({app:!1,app_reason:u.message,code:u.code}));return o({...e.structuredContent,...e.structuredContent?.account??{},...r,text:e.content[0]?.text})}{let e=await F().then(()=>null,r=>r);if(e)return o({ok:!1,code:e.code,message:e.message,needs:"app"},e.code==="not_signed_in"?401:402)}if(i==="events"&&t.method==="GET")return T(_t());if(i==="front"&&t.method==="POST"){let e=await t.json();return wt({project:String(e.project??""),view:String(e.view??""),...e.tool?{tool:String(e.tool)}:{}}),o({ok:!0})}if(i==="convert"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=M(e.get("name")||"timeline"),u=e.get("out")||"",h=JSON.parse(e.get("targets")||"[]"),c=JSON.parse(e.get("sequences")||"[]");if(!u||!h.length)return o({ok:!1,error:"a folder and at least one format are needed"},400);let m=await D("conform-te-"),w=b(m,r);await A(w,new Uint8Array(await t.arrayBuffer()));let p=await S("timeline_read",{path:w}),y=p.structuredContent?.session_id??p.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(p.isError||!y)return o({ok:!1,error:p.content[0]?.text??"could not read the timeline"});let g=(await v(y)).session.timelines.filter(x=>x.kind!=="compound"),_=c.length?g.filter(x=>c.includes(x.name??"")):g,d=[],O=0;for(let x of _)for(let R of h){let N=b(u,`${Mt(x.name??"timeline")}.${R.ext}`),V=await S("timeline_write",{session_id:y,target:R.target,out_path:N,..._.length>1||g.length>1?{timeline_id:x.id}:{}});V.isError?d.push(`${x.name} \u2192 ${R.target}: ${V.content[0]?.text}`):O++}return await L(m).catch(()=>{}),o({ok:O>0,savedCount:O,...d.length?{error:d.join(`
3
+ import{a as Tt}from"./chunk-BYMCZJBQ.js";import{a as wt,b as _t,c as kt,d as yt,e as xt,h as S,i as bt,l as U,m as St}from"./chunk-LRGA6QJQ.js";import"./chunk-B54TEGMG.js";import"./chunk-I2Y2P5NH.js";import"./chunk-ERUN634Q.js";import"./chunk-J43UCJ6G.js";import"./chunk-NZLL44HU.js";import"./chunk-YU3SUSK3.js";import"./chunk-QTFFVLVJ.js";import"./chunk-5YULBQJX.js";import"./chunk-G3HBKJ5L.js";import{G as ot,H as rt,Hb as mt,Ib as ft,J as dt,P as I,cd as pt,ed as gt,gd as ht}from"./chunk-LKQTE6T5.js";import"./chunk-IN6XVTUS.js";import"./chunk-Y455Y6V4.js";import"./chunk-PFZVET7S.js";import"./chunk-6V4OEOOX.js";import"./chunk-4VFDGL4E.js";import{a as nt}from"./chunk-H4BU5WA6.js";import"./chunk-ISKNIQVO.js";import"./chunk-JKOB3U54.js";import"./chunk-EEDLRRKU.js";import"./chunk-WJ5EWXP2.js";import"./chunk-YUO3UWPH.js";import"./chunk-DKGGJM6Z.js";import"./chunk-JV7TZDKJ.js";import"./chunk-RGMTLNMF.js";import"./chunk-XDI6CPPV.js";import"./chunk-7W5AFZYX.js";import"./chunk-LZRCXSUJ.js";import"./chunk-BTS3DFPD.js";import"./chunk-6WLSIH2N.js";import"./chunk-LVGGCRDW.js";import"./chunk-C2ESM27Z.js";import"./chunk-D6YDLKSA.js";import"./chunk-4BTTR6U3.js";import"./chunk-N34DQ6MH.js";import"./chunk-NU3X7P4N.js";import"./chunk-DPA26AOI.js";import{C as v,E as lt,t as H,u as st,v as at,x as it,y as ct,z as ut}from"./chunk-L3HRAIDR.js";import{k as F}from"./chunk-OD445COC.js";import"./chunk-EP4L2BWV.js";import{a as B}from"./chunk-PHAMF4JF.js";import{A as $,C as Z,G as L,K as D,L as q,M as tt,T as et,Z as M,_ as J,aa as b,b as E,m as P,s as W,t as K,w as X,x as Y,y as A,z as Q}from"./chunk-XI6XF7FQ.js";import"./chunk-PSANHDZM.js";import C from"node:process";var Ot=new Map;function Rt(t,s,o,T){let a=`${t}:${o}:${T}`,i=Ot.get(a);return i||(i=(async()=>{let n=b(P(),"cache","grade-luts",t);await $(n);let l=b(n,`V${o}_${T}.cube`);if(!await K(l)){let{adapter:k}=await import("./hosts-TBHEPV6A.js");if((await k("resolve").clipLut({timeline:s,track:o,start:T,out_path:l})).ok===!1)return null}return l})().catch(()=>null),Ot.set(a,i)),i}var Lt=new Set(["/app/convert","/app/canonicalize"]);function Et(t,s){let o=(s??"").split(";")[0].trim().toLowerCase();return o==="application/json"||o==="application/octet-stream"&&Lt.has(t)}function Mt(t){let s=t.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").replace(/[. ]+$/,"")||"timeline";return/^(con|prn|aux|nul|com\d|lpt\d)(\..*)?$/i.test(s)?`_${s}`:s}var G={id:"local",name:"Local",client_name:null,handles:24,local:!0};async function vt(){try{return JSON.parse(await Y(b(P(),"projects","projects.json")))}catch{return[]}}async function Pt(){let t=await S("project",{action:"list"});if(!t.isError){let s=t.structuredContent?.projects??[];return await $(b(P(),"projects")),await Q(b(P(),"projects","projects.json"),JSON.stringify(s)),{projects:[G,...s],offline:!1}}return{projects:[G,...await vt()],offline:!0,code:String(t.structuredContent?.code??"offline"),reason:String(t.structuredContent?.message??t.content[0]?.text??"")}}async function Ut(t){return t==="local"?G:(await vt()).find(s=>s.id===t)??{id:t,name:t}}async function Ct(t,s,o,T,a=(i,n)=>new Response(i,{headers:{"content-type":n}})){if(s[0]!=="app")return null;let[,i,n,l]=s,k=async()=>t.headers.get("content-type")?.includes("json")?await t.json():{};try{if(i==="policy"&&t.method==="GET"){let{config:e}=await import("./account-F54SG45Q.js"),r=await fetch(`${e().supabaseUrl}/functions/v1/v1-billing/v1/billing/app-policy`,{signal:AbortSignal.timeout(3e3)}).catch(()=>null);return o(r?.ok?await r.json():{offline:!0})}if(i==="account"&&t.method==="GET"){let e=await S("account_status",{}),r=await F().then(()=>({app:!0}),u=>({app:!1,app_reason:u.message,code:u.code}));return o({...e.structuredContent,...e.structuredContent?.account??{},...r,text:e.content[0]?.text})}{let e=await F().then(()=>null,r=>r);if(e)return o({ok:!1,code:e.code,message:e.message,needs:"app"},e.code==="not_signed_in"?401:402)}if(i==="events"&&t.method==="GET")return T(_t());if(i==="front"&&t.method==="POST"){let e=await t.json();return wt({project:String(e.project??""),view:String(e.view??""),...e.tool?{tool:String(e.tool)}:{}}),o({ok:!0})}if(i==="convert"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=M(e.get("name")||"timeline"),u=e.get("out")||"",h=JSON.parse(e.get("targets")||"[]"),c=JSON.parse(e.get("sequences")||"[]");if(!u||!h.length)return o({ok:!1,error:"a folder and at least one format are needed"},400);let m=await D("conform-te-"),w=b(m,r);await A(w,new Uint8Array(await t.arrayBuffer()));let p=await S("timeline_read",{path:w}),y=p.structuredContent?.session_id??p.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(p.isError||!y)return o({ok:!1,error:p.content[0]?.text??"could not read the timeline"});let g=(await v(y)).session.timelines.filter(x=>x.kind!=="compound"),_=c.length?g.filter(x=>c.includes(x.name??"")):g,d=[],O=0;for(let x of _)for(let R of h){let N=b(u,`${Mt(x.name??"timeline")}.${R.ext}`),V=await S("timeline_write",{session_id:y,target:R.target,out_path:N,..._.length>1||g.length>1?{timeline_id:x.id}:{}});V.isError?d.push(`${x.name} \u2192 ${R.target}: ${V.content[0]?.text}`):O++}return await L(m).catch(()=>{}),o({ok:O>0,savedCount:O,...d.length?{error:d.join(`
4
4
  `)}:{}})}if(i==="fs"&&t.method==="POST"){let{op:e,path:r,offset:u=0,length:h=0}=await k();if(e==="statPath"){let c=await W(r).catch(()=>null);return o({ok:!0,result:c?{kind:c.isDirectory?"directory":"file",size:c.size,lastModified:Math.round(c.mtimeMs)}:null})}if(e==="readDir"){let c=[];for await(let m of q(r))(m.isFile||m.isDirectory)&&c.push({name:m.name,kind:m.isDirectory?"directory":"file"});return o({ok:!0,result:c})}if(e==="readFile"){let c=await tt(r);try{return a(await c.readAt(Math.max(0,u),Math.min(Math.max(0,h),16<<20)),"application/octet-stream")}finally{await c.close()}}return o({ok:!1,code:"bad_request",message:`no fs op ${e}`},400)}if(i==="canonicalize"&&t.method==="POST"){let e=new URL(t.url).searchParams,r=JSON.parse(e.get("sequences")||"[]"),u=JSON.parse(e.get("previous")||"[]"),h=await D("conform-te-");try{let c=b(h,M(e.get("name")||"timeline"));await A(c,new Uint8Array(await t.arrayBuffer()));let m=await S("timeline_read",{path:c}),w=m.structuredContent?.session_id??m.content[0]?.text.match(/session_id: (\w+)/)?.[1];if(m.isError||!w)return o({ok:!1,error:m.content[0]?.text??"could not read the timeline"},422);let p=(await v(w)).session,y=p.timelines;if(r.length){let g=new Map;for(let d of u)g.set(d,(g.get(d)??0)+1);let _=new Set;for(let d of r){let O=p.timelines.filter(N=>N.kind!=="compound"&&(N.name??"")===d),x=g.get(d)??0;g.set(d,x+1);let R=O[Math.min(x,O.length-1)];R&&_.add(R)}y=p.timelines.filter(d=>d.kind==="compound"||_.has(d))}return o({ok:!0,session_id:w,session:{...p,timelines:y}})}finally{await L(h).catch(()=>{})}}if(i==="sessions"&&n&&l==="frame"){let e=new URL(t.url).searchParams,r=Math.max(0,Math.round(Number(e.get("f")??0))),u=Math.min(3840,Math.max(64,Number(e.get("w")??1280)|0));try{let w=(await v(n)).session,p=e.get("track")==="offline"?"offline":Number(e.get("track"))||void 0,y;if(e.get("grade")==="resolve"&&p!=="offline"){let _=(()=>{try{return mt(w,{record:r,timeline:e.get("timeline")??void 0,track:p})}catch{return null}})();_&&(y=await Rt(n,e.get("host_timeline")??void 0,_.video_track,_.record_start)??void 0)}let g=await ft(w,r,u,e.get("timeline")??void 0,p,y);if(g){let _=new Uint8Array(12+g.px.length),d=new DataView(_.buffer);return d.setUint32(0,g.w,!0),d.setUint32(4,g.h,!0),d.setUint32(8,g.order==="bgra"?1:0,!0),_.set(g.px,12),a(_,"application/x-conform-pixels")}}catch(w){return o({ok:!1,code:"no_frame",message:w.message},404)}let h=await S("timeline_frame",{session_id:n,record:r,width:u,...e.get("timeline")?{timeline:e.get("timeline")}:{}}),c=h.structuredContent?.out_path;if(h.isError||!c)return o({ok:!1,code:String(h.structuredContent?.code??"no_frame"),message:h.content[0]?.text??"no picture here"},404);let m=await X(c);return await(M(J(c)).startsWith("conform-frame-")?L(J(c)):Z(c)).catch(()=>{}),a(m,"image/png")}if(i==="sessions"&&n&&t.method==="GET"){let e=await v(n).catch(()=>null);return e?o(e):o({ok:!1,code:"not_found"},404)}if(i==="sessions"&&!n)return o(await lt());if(i!=="projects")return o({ok:!1,code:"not_found"},404);if(!n){if(t.method==="POST"){let e=await k(),r=await S("project",{action:"create",name:e.name,client_name:e.client_name,handles:e.handles});return r.isError?o({...r.structuredContent,text:r.content[0]?.text},422):(await Pt(),o(r.structuredContent))}return o(await Pt())}if(!l){let[e,r,u,h,c,m]=await Promise.all([Ut(n),st(n).catch(()=>null),ut(n),dt(n),pt(n).then(y=>y.facts).catch(()=>[]),n===H?null:gt().catch(()=>null)]);await it(n===H?null:{id:n,name:e.name??n});let{text:w="",...p}=r??{};return o({project:e,context:w,context_meta:p,sessions:u,activity:h.slice(-100).reverse(),known:ht(c),facility:m?.text??""})}if(l==="sessions"&&t.method==="PUT")return await ct(n,String((await k()).session_id??"")),o({ok:!0});if(l==="context"&&t.method==="PUT"){let e=await k();try{let{text:r,...u}=await at(n,String(e.text??""),e.base===void 0?void 0:e.base);return o({ok:!0,context:r,context_meta:u})}catch(r){if(r instanceof B&&r.code==="context_conflict"){let u=r.data?.current;return o({ok:!1,code:r.code,message:r.message,context:u.context,context_meta:{updated_at:u.context_updated_at,updated_by:u.context_updated_by_name??null}},409)}throw r}}return o({ok:!1,code:"not_found"},404)}catch(e){let r=e instanceof B?e:null;return o({ok:!1,code:r?.code??"internal",message:e.message},r?.code==="not_found"?404:r?.code==="invalid_args"?400:500)}}var jt=Number(E("CONFORM_HTTP_PORT")??7791);E("CONFORM_EXIT_WITH_PARENT")==="1"&&(C.stdin.on("end",()=>C.exit(0)),C.stdin.on("close",()=>C.exit(0)),C.stdin.resume());var z=E("CONFORM_HTTP_TOKEN")??"",$t=(E("CONFORM_HTTP_ORIGINS")??"https://conform.tools,https://app.conform.tools,http://localhost:5173,http://localhost:3000").split(","),j=(t,s=new Headers)=>{let o=t.headers.get("origin")??"";return $t.includes(o)&&s.set("access-control-allow-origin",o),s.set("access-control-allow-headers","authorization, content-type"),s.set("access-control-allow-methods","GET, POST, PUT, DELETE, OPTIONS"),s.set("access-control-allow-private-network","true"),s.set("vary","origin"),s},Nt=new Set,f=(t,s,o=200)=>new Response(JSON.stringify(s),{status:o,headers:j(t,new Headers({"content-type":"application/json"}))});et({hostname:"127.0.0.1",port:jt,onListen:t=>{Nt=new Set([`127.0.0.1:${t}`,`localhost:${t}`,`[::1]:${t}`]),console.error(`conformtools HTTP API on http://127.0.0.1:${t} (${U.length} verbs)`),Tt(t,z)}},async t=>{let s=new URL(t.url),o=(t.headers.get("host")??"").toLowerCase();if(!Nt.has(o))return new Response("forbidden host",{status:403});let T=t.headers.get("origin");if(T&&!$t.includes(T))return new Response("forbidden origin",{status:403});if(t.method==="OPTIONS")return new Response(null,{status:204,headers:j(t)});if((t.method==="POST"||t.method==="PUT")&&t.headers.get("content-length")!=="0"&&!Et(s.pathname,t.headers.get("content-type")))return f(t,{ok:!1,code:"unsupported_media_type",message:"send the body as application/json"},415);if(z&&t.headers.get("authorization")!==`Bearer ${z}`&&s.pathname!=="/health")return f(t,{ok:!1,code:"unauthorized"},401);let a=s.pathname.split("/").filter(Boolean);try{if(s.pathname==="/health")return f(t,{ok:!0,verbs:U.length,version:nt,engine:I()});if(a[0]==="verbs"&&a.length===1&&t.method==="GET")return f(t,U.map(n=>({name:n.name,title:n.title,description:n.description,long:!!n.long,input_schema:rt(ot.object(n.inputSchema)),protected_stages:n.protectedStages??[],engine:I()})));if(a[0]==="verbs"&&a.length===2&&t.method==="POST"){let n=St(a[1]);if(!n)return f(t,{ok:!1,code:"not_found",message:`unknown verb ${a[1]}`},404);let l=t.headers.get("content-type")?.includes("json")?await t.json():{},k=bt(n.name,l);if(!k.ok)return f(t,{...k.result.structuredContent,text:k.result.content[0].text},400);let e=await S(n.name,k.data,{client:t.headers.get("x-conform-client")??"http",poll:t.headers.get("x-conform-poll")==="1"});return f(t,{...e.structuredContent??{ok:!e.isError},text:e.content.map(r=>r.text).join(`
5
- `)},e.isError?422:200)}if(a[0]==="debug"&&a.length===3&&t.method==="POST"&&Deno.env.get("CONFORM_DEBUG_BRIDGE")==="1"){let{hostBridge:n}=await import("./bridge-6NCHJWE6.js"),l=await n();return await l.waitFor(a[1],5e3)?f(t,{ok:!0,result:await l.request(a[1],a[2],t.headers.get("content-type")?.includes("json")?await t.json():{},12e4)}):f(t,{ok:!1,code:"not_connected"},409)}let i=await Ct(t,a,(n,l)=>f(t,n,l),n=>new Response(n,{headers:j(t,new Headers({"content-type":"text/event-stream","cache-control":"no-cache"}))}),(n,l)=>new Response(n,{headers:j(t,new Headers({"content-type":l,"cache-control":"no-store"}))}));if(i)return i;if(a[0]==="jobs"&&a.length===1)return f(t,await xt());if(a[0]==="jobs"&&a.length===2){if(t.method==="DELETE")return f(t,{ok:yt(a[1])});let n=await kt(a[1]);return n?f(t,n):f(t,{ok:!1,code:"not_found"},404)}return f(t,{ok:!1,code:"not_found"},404)}catch(i){return f(t,{ok:!1,code:"internal",message:i instanceof Error?i.message:String(i)},500)}});
5
+ `)},e.isError?422:200)}if(a[0]==="debug"&&a.length===3&&t.method==="POST"&&Deno.env.get("CONFORM_DEBUG_BRIDGE")==="1"){let{hostBridge:n}=await import("./bridge-PWYOJ7E7.js"),l=await n();return await l.waitFor(a[1],5e3)?f(t,{ok:!0,result:await l.request(a[1],a[2],t.headers.get("content-type")?.includes("json")?await t.json():{},12e4)}):f(t,{ok:!1,code:"not_connected"},409)}let i=await Ct(t,a,(n,l)=>f(t,n,l),n=>new Response(n,{headers:j(t,new Headers({"content-type":"text/event-stream","cache-control":"no-cache"}))}),(n,l)=>new Response(n,{headers:j(t,new Headers({"content-type":l,"cache-control":"no-store"}))}));if(i)return i;if(a[0]==="jobs"&&a.length===1)return f(t,await xt());if(a[0]==="jobs"&&a.length===2){if(t.method==="DELETE")return f(t,{ok:yt(a[1])});let n=await kt(a[1]);return n?f(t,n):f(t,{ok:!1,code:"not_found"},404)}return f(t,{ok:!1,code:"not_found"},404)}catch(i){return f(t,{ok:!1,code:"internal",message:i instanceof Error?i.message:String(i)},500)}});