conformtools 0.6.16 → 0.6.17

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 (100) hide show
  1. package/README.md +1 -1
  2. package/dist/{account-W7Z2MYZU.js → account-VXAKXGY6.js} +1 -1
  3. package/dist/{agent-hook-setup-JCIZG3Q3.js → agent-hook-setup-HBT2LTVR.js} +1 -1
  4. package/dist/{analysis-engine-DCHJHZ7W.js → analysis-engine-BZUEBW55.js} +1 -1
  5. package/dist/{arriraw-YIJ3BYNN.js → arriraw-GZ63YMLZ.js} +7 -7
  6. package/dist/bridge-DRC6BQFR.js +3 -0
  7. package/dist/browser/timeline_core_bg.wasm +0 -0
  8. package/dist/{chunk-HOACOBAY.js → chunk-2SDAOYP5.js} +3 -3
  9. package/dist/{chunk-XVZ7KJRI.js → chunk-2VH2Z6RD.js} +1 -1
  10. package/dist/chunk-3PVQ5QP4.js +3 -0
  11. package/dist/chunk-73RFYAVG.js +3 -0
  12. package/dist/{chunk-RGMTLNMF.js → chunk-BBCQMZQN.js} +1 -1
  13. package/dist/{chunk-JL454FFL.js → chunk-CRMGV32N.js} +2 -2
  14. package/dist/{chunk-JM5LHKTU.js → chunk-CZ6OZKR6.js} +222 -216
  15. package/dist/chunk-GRJLKGBG.js +3 -0
  16. package/dist/chunk-GTPTZRO6.js +3 -0
  17. package/dist/{chunk-4RA57LTJ.js → chunk-IG2X534U.js} +1 -1
  18. package/dist/{chunk-MGMDNGNX.js → chunk-JT3HI632.js} +2 -2
  19. package/dist/chunk-JTRM2JCE.js +7 -0
  20. package/dist/{chunk-UAURERD3.js → chunk-M5CEBOLK.js} +1 -1
  21. package/dist/{chunk-XDI6CPPV.js → chunk-MTAXVOHK.js} +1 -1
  22. package/dist/{chunk-WJ5EWXP2.js → chunk-MVQ5RGZB.js} +1 -1
  23. package/dist/{chunk-VETHR2O7.js → chunk-NN444GPH.js} +1 -1
  24. package/dist/chunk-OSUIS4JU.js +3 -0
  25. package/dist/chunk-P4PCSGEH.js +10 -0
  26. package/dist/{chunk-DPA26AOI.js → chunk-QNF4NMIW.js} +1 -1
  27. package/dist/{chunk-QRZO5GOI.js → chunk-R2WEXCVQ.js} +1 -1
  28. package/dist/chunk-RITYQNOO.js +3 -0
  29. package/dist/{chunk-RJD44NQU.js → chunk-S2WAFMRV.js} +2 -2
  30. package/dist/chunk-S5AOIOTT.js +3 -0
  31. package/dist/chunk-STGGRRYM.js +3 -0
  32. package/dist/{chunk-FLLB6UZJ.js → chunk-T7S2UBNN.js} +1 -1
  33. package/dist/chunk-TWHNQFKI.js +3 -0
  34. package/dist/chunk-UBWUED67.js +3 -0
  35. package/dist/{chunk-VWFEMXYZ.js → chunk-VCBLWNQR.js} +102 -101
  36. package/dist/{chunk-6V4OEOOX.js → chunk-VFXMP7IF.js} +1 -1
  37. package/dist/{chunk-5W57ITT2.js → chunk-WKNX742H.js} +2 -2
  38. package/dist/{chunk-UKXSKFL3.js → chunk-YGAAGTLE.js} +1 -1
  39. package/dist/{claude-setup-CM7G2YSG.js → claude-setup-W27DLJIO.js} +1 -1
  40. package/dist/cli.js +2 -2
  41. package/dist/{cr3-wasm-NYCB34ND.js → cr3-wasm-VUEEZYKQ.js} +1 -1
  42. package/dist/{demo-engine-CBFAAPPO.js → demo-engine-5TCNOTTH.js} +1 -1
  43. package/dist/dng-wasm-5RQBGYAK.js +3 -0
  44. package/dist/dpx-wasm-OQVTNGOB.js +3 -0
  45. package/dist/{engine-6YYXTF2Q.js → engine-4X6TDWWA.js} +2 -2
  46. package/dist/exr-wasm-72YZFOME.js +3 -0
  47. package/dist/framing-HGW5RCUA.js +3 -0
  48. package/dist/gfx-worker.js +1 -1
  49. package/dist/{h264-MAUVJTR4.js → h264-QCYEI6RF.js} +1 -1
  50. package/dist/{h264-mxf-2O4SAUTA.js → h264-mxf-2BYKXDGT.js} +1 -1
  51. package/dist/hook.js +2 -2
  52. package/dist/{host-relink-NVLUO73P.js → host-relink-37DCSN47.js} +1 -1
  53. package/dist/hosted-M2OZSONX.js +3 -0
  54. package/dist/hosts-IAJTORJD.js +3 -0
  55. package/dist/http.js +3 -3
  56. package/dist/{inspect-YIFLNOJW.js → inspect-R4RWCK3X.js} +2 -2
  57. package/dist/isobmff-RH4JKUUB.js +3 -0
  58. package/dist/{mc-video-HRZC7HGH.js → mc-video-MMKWEKFZ.js} +1 -1
  59. package/dist/mcp.js +8 -8
  60. package/dist/media-6MB7EKA7.js +3 -0
  61. package/dist/mxf-7HFFEBNW.js +3 -0
  62. package/dist/{ops-XIUVNJE2.js → ops-EM345H7F.js} +1 -1
  63. package/dist/{probe-GIAKRPFV.js → probe-YDOFGCGD.js} +1 -1
  64. package/dist/{r3d-I6EYEYX7.js → r3d-DDOTSYZH.js} +5 -5
  65. package/dist/r3d-G34YLXXA.js +3 -0
  66. package/dist/sequence-patch-2S7IPE52.js +3 -0
  67. package/dist/{source-QGWWLMME.js → source-L2JNTYS6.js} +1 -1
  68. package/dist/{still-4UR35GZH.js → still-AGBF3OOY.js} +1 -1
  69. package/dist/{still-wasm-RTPOMH7S.js → still-wasm-6YLI6NQQ.js} +1 -1
  70. package/dist/{store-MWNX47IK.js → store-LWUDJD76.js} +1 -1
  71. package/dist/tiff-wasm-6APT7FYP.js +3 -0
  72. package/dist/timeline-EZ6WUHCB.js +3 -0
  73. package/dist/{wav-HSCUCY4U.js → wav-CV43ZAJI.js} +1 -1
  74. package/package.json +5 -5
  75. package/dist/bridge-UPSJ7F3S.js +0 -3
  76. package/dist/chunk-DKGGJM6Z.js +0 -3
  77. package/dist/chunk-DLF5AKXT.js +0 -10
  78. package/dist/chunk-EEDLRRKU.js +0 -3
  79. package/dist/chunk-IDJIOKXA.js +0 -3
  80. package/dist/chunk-ISKNIQVO.js +0 -3
  81. package/dist/chunk-JKOB3U54.js +0 -3
  82. package/dist/chunk-OWWXUNJF.js +0 -7
  83. package/dist/chunk-PFZVET7S.js +0 -3
  84. package/dist/chunk-QH5DTYSE.js +0 -3
  85. package/dist/chunk-RVZQ3Y6N.js +0 -3
  86. package/dist/chunk-X527E5VI.js +0 -3
  87. package/dist/chunk-YUO3UWPH.js +0 -3
  88. package/dist/dng-wasm-XCPPBXPZ.js +0 -3
  89. package/dist/dpx-wasm-XACWNFPB.js +0 -3
  90. package/dist/exr-wasm-FQBUR6QT.js +0 -3
  91. package/dist/framing-QYRCUEB5.js +0 -3
  92. package/dist/hosted-2XACQY7J.js +0 -3
  93. package/dist/hosts-GEXAZFB3.js +0 -3
  94. package/dist/isobmff-MTMGQKLK.js +0 -3
  95. package/dist/media-WC4ZVKIL.js +0 -3
  96. package/dist/mxf-J5QHA3VY.js +0 -3
  97. package/dist/r3d-2PCOFR2Z.js +0 -3
  98. package/dist/sequence-patch-DFGEAJGB.js +0 -3
  99. package/dist/tiff-wasm-N2S267IA.js +0 -3
  100. package/dist/timeline-Z3KD2CJX.js +0 -3
@@ -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{c as r,d as t}from"./chunk-VFXMP7IF.js";import{i}from"./chunk-IG2X534U.js";async function d(e){if(!r(e.name))return null;try{return await i(t(e),{verb:"inspect"})}catch(n){return console.warn(`[probeMedia] ${e.name} probe failed:`,n),null}}export{d as a};
@@ -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 H,appendFile as q,stat as W,readdir as G,mkdir as _,open as O,copyFile as Y,mkdtemp as K,rm as P,chmod as V,rename as B,cp as X,statfs as Z,realpath as Q}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,hostname as ie,tmpdir as ae,platform as ce,release as le,arch as ue,totalmem as de,availableParallelism as me}from"node:os";import{fileURLToPath as U}from"node:url";import fe from"node:http";import pe from"node:http2";import f from"node:process";import{Buffer as $}from"node:buffer";import{basename as ge,dirname as ye,join as h,resolve as C,sep as v}from"node:path";import{createRequire as we}from"node:module";import{basename as St,dirname as Ot,extname as Ut,join as Ft,relative as Dt,resolve as Tt}from"node:path";{let e=globalThis.fetch,t=typeof globalThis.Deno<"u";e&&!t&&(globalThis.fetch=(async(r,o)=>{let n=typeof r=="string"?r:r instanceof URL?r.href:r.url;if(n.startsWith("file:")){let s=await S(U(n)),i=n.endsWith(".wasm")?"application/wasm":"application/octet-stream";return new Response(s,{status:200,headers:{"content-type":i}})}return e(r,o)}))}var w=e=>f.env[e],Ce=()=>Number(w("CONFORM_MEMORY_GB")??0)*2**30||de(),Ne=()=>me(),Ie=()=>f.argv.slice(2),He=e=>f.exit(e),be=()=>f.platform,We=()=>ie(),_e=()=>w("CONFORM_PYTHON")??(be()==="win32"?"python":"python3"),Be=()=>f.arch,z=()=>`${f.platform}-${f.arch}`;function je(e){try{return h(ye(we(import.meta.url).resolve(`${he(z())}/package.json`)),e)}catch{return null}}var he=e=>`conformtools-${e==="win32-x64"?"windows-x64":e}`,ze=e=>`${e} is not in this package for ${z()} (conform.tools builds it for darwin-arm64, darwin-x64, linux-x64 and win32-x64)`;function Le(){let e=f.versions.deno,t=w("CONFORM_APP_VERSION"),r=e?`deno ${e}`:`node ${f.version}`;return{platform:`${ce()} ${le()} ${ue()}`,runtime:t&&/^[0-9A-Za-z.-]{1,32}$/.test(t)?`${r} app ${t}`:r}}var xe=()=>w("CONFORM_MCP_HOME")??h(A(),".conform-mcp"),A=()=>w("HOME")??se();function Je(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=U(t)}catch{}return t==="~"?t=A():(t.startsWith("~/")||t.startsWith("~\\"))&&(t=h(A(),t.slice(2))),t&&C(t)+(/[\\/]$/.test(t)&&!/[\\/]$/.test(C(t))?v:"")}async function qe(e,t){let r=await import("node:sqlite").catch(()=>null);if(r?.DatabaseSync){let n=new r.DatabaseSync(e,{readOnly:!0});try{let s=n.prepare(t);return s.setReadBigInts(!0),s.all().map(i=>Object.fromEntries(Object.entries(i).map(([c,l])=>[c,typeof l=="bigint"?Number(l):l])))}finally{n.close()}}let o=await F("sqlite3",["-readonly","-json",e,t]);if(!o.success)throw new Error(`sqlite3 ${ge(e)}: ${o.stderr.trim()||o.stdout.trim()}`);return o.stdout.trim()?JSON.parse(o.stdout):[]}var Ge=(e,t)=>e?`${e.replace(/[\\/]+$/,"")}${e.includes("\\")&&!e.includes("/")?"\\":"/"}${t}`:t;function Ye(e){let t=U(e),r=t.indexOf(`${v}deno-compile-`);if(r<0||!E(t))return t;let o=t.slice(r+1).split(v).slice(1).join(v),n=h(xe(),"bin",o);try{let s=M(t),i=E(n)?M(n):null;return(!i||s.isFile()&&(i.size!==s.size||i.mtimeMs<s.mtimeMs))&&(oe(t,n,{recursive:!0,force:!0}),s.isFile()&&ne(n,493)),n}catch{return t}}var N=null;var x=e=>N?.owns(e)?N:null;async function I(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,()=>I(e))??I(e)}async function Ke(e){try{return await R(e),!0}catch{return!1}}async function Ve(e){try{return(await R(e)).isFile}catch{return!1}}async function Xe(e){try{return(await R(e)).isDirectory}catch{return!1}}async function Ze(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"),et=(e,t)=>H(e,t),tt=(e,t,r)=>r?.append?q(e,t):H(e,t);async function rt(e){await _(e,{recursive:!0})}async function nt(e,t={}){let r=Date.now()+(t.timeoutMs??5e3),o=t.staleMs??15e3;for(;;)try{await _(e);break}catch(n){if(n.code!=="EEXIST")throw n;try{if(Date.now()-(await R(e)).mtimeMs>o){await P(e,{recursive:!0,force:!0});continue}}catch{}if(Date.now()>r)break;await new Promise(s=>setTimeout(s,25))}return()=>P(e,{recursive:!0,force:!0}).catch(()=>{})}var ot=e=>P(e,{force:!0}),st=(e,t)=>V(e,t).catch(()=>{}),it=(e,t)=>Y(e,t),at=(e,t)=>B(e,t),ct=e=>P(e,{recursive:!0,force:!0}),lt=(e,t)=>X(e,t,{recursive:!0,verbatimSymlinks:!0});async function ut(e){try{let t=await Z(e);return Number(t.bavail)*Number(t.bsize)}catch{return null}}async function dt(e){try{return await Q(e)}catch{return null}}var mt=(e="conform-")=>K(h(ae(),e));async function*ft(e){let t=async()=>(await G(e,{withFileTypes:!0})).map(r=>({name:r.name,isFile:r.isFile(),isDirectory:r.isDirectory()}));yield*await(x(e)?.readDir(e,t)??t())}async function pt(e){x(e)?.guard(e,"read bytes");let t=await O(e,"r"),r=(await t.stat()).size;return{path:e,size:r,async readAt(o,n){let s=new Uint8Array(n),i=0;for(;i<n;){let{bytesRead:c}=await t.read(s,i,n-i,o+i);if(!c)break;i+=c}return i===n?s:s.subarray(0,i)},close:()=>t.close()}}async function gt(e){let t=await O(e,"w");return{async writeAt(r,o){let n=0;for(;n<o.length;){let{bytesWritten:s}=await t.write(o,n,o.length-n,r+n);n+=s}},truncate:r=>t.truncate(r),close:()=>t.close()}}var L=(e,t)=>{for(let r of t)x(r)?.guard(r,`${e.split(/[\\/]/).pop()} ${t[0]}`)};function F(e,t,r={}){return L(e,t),new Promise(o=>{ee(e,t,{maxBuffer:1<<30,env:r.env?{...f.env,...r.env}:void 0,timeout:r.timeoutMs},(n,s,i)=>{let c=n?.code??0;o({success:!n,code:c,stdout:String(s),stderr:String(i)})})})}var ve="[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 yt(){let e=await F("powershell.exe",["-NoProfile","-NonInteractive","-Command",ve],{timeoutMs:3e4});return Pe(e.stdout)}function Pe(e){let t;try{t=JSON.parse(e.replace(/^/,"").trim()||"[]")}catch{return[]}return(Array.isArray(t)?t:[t]).flatMap(r=>{let o=r??{},n=Number(o.pid);return!Number.isInteger(n)||n<=0?[]:[{pid:n,args:String(o.cmd||o.exe||""),title:typeof o.title=="string"?o.title:""}]})}function wt(e,t,r,o={}){return L(e,t),new Promise((n,s)=>{let i=j(e,t,{env:o.env?{...f.env,...o.env}:void 0,stdio:["ignore","pipe","pipe"]}),c="";i.stdout.on("data",l=>r(l)),i.stderr.on("data",l=>{c+=new TextDecoder().decode(l)}),i.on("error",s),i.on("close",l=>n({code:l,stderr:c})),o.signal?.addEventListener("abort",()=>i.kill(),{once:!0})})}function bt(e,t,r,o,n={}){let s=j(e,t,{stdio:["pipe","pipe","pipe"],env:n.env?{...f.env,...n.env}:void 0});s.stdin.on("error",()=>{}),s.stdout.on("data",a=>r(a)),s.stderr.on("data",a=>o?.(new TextDecoder().decode(a)));let i=new Promise(a=>{s.on("close",u=>a(u)),s.on("error",()=>a(null))}),c=[s,s.stdout,s.stderr,s.stdin],l=a=>{for(let u of c)(a?u.ref:u.unref)?.call(u)};return l(!1),{write:a=>new Promise((u,p)=>{s.stdin.write(a,m=>m?p(m):u())}),hold:l,close:()=>{try{s.stdin.end(),s.kill()}catch{}},exited:i}}async function ht(e){if(w("CONFORM_NO_BROWSER"))return!1;let[t,r]=f.platform==="darwin"?["open",[e]]:f.platform==="win32"?["cmd",["/c","start","",e.replace(/&/g,"^&")]]:["xdg-open",[e]];return(await F(t,r)).success}function xt(e,t){let r=fe.createServer(async(o,n)=>{try{let s=[];if(o.method!=="GET"&&o.method!=="HEAD")for await(let p of o)s.push(p);let i=s.length>0,c=new Headers;for(let[p,m]of Object.entries(o.headers))m!=null&&c.set(p,Array.isArray(m)?m.join(", "):m);let l=`http://${o.headers.host??`${e.hostname}:${e.port}`}${o.url??"/"}`,a=new AbortController;n.on("close",()=>{n.writableEnded||a.abort()});let u=await t(new Request(l,{method:o.method,headers:c,body:i?$.concat(s):void 0,signal:a.signal}));if(n.statusCode=u.status,u.headers.forEach((p,m)=>n.setHeader(m,p)),u.body&&u.headers.get("content-type")?.startsWith("text/event-stream")){n.flushHeaders();let p=u.body.getReader();for(a.signal.addEventListener("abort",()=>void p.cancel(),{once:!0});;){let{value:m,done:g}=await p.read();if(g)break;n.write(m)}n.end();return}n.end($.from(await u.arrayBuffer()))}catch(s){n.statusCode=500,n.end(JSON.stringify({ok:!1,code:"internal",message:s instanceof Error?s.message:String(s)}))}});return r.listen(e.port,e.hostname,()=>{let o=r.address();e.onListen?.(typeof o=="object"&&o?o.port:e.port)}),{close:()=>r.close()}}var y=class extends Error{constructor(r,o,n){super(o);this.code=r;this.grpcStatus=n}};function vt(e,t,r,o,n){return new Promise((s,i)=>{let c=pe.connect(`http://${e}:${t}`),l=!1,a=(d,J)=>{l||(l=!0,clearTimeout(p),c.destroy(),d?i(d):s(J))},u=!1;c.on("connect",()=>{u=!0});let p=setTimeout(()=>a(u?new y("deadline",`no answer from ${e}:${t} in ${n} ms`):new y("unavailable",`${e}:${t}: no connection in ${n} ms`)),n);c.on("error",d=>a(new y("unavailable",`${e}:${t}: ${d.message}`)));let m=$.alloc(5+o.length);m.writeUInt32BE(o.length,1),m.set(o,5);let g=c.request({":method":"POST",":path":r,"content-type":"application/grpc",te:"trailers"}),D=[],b,k="",T=d=>{d["grpc-status"]!=null&&(b=String(d["grpc-status"]),k=decodeURIComponent(String(d["grpc-message"]??"")))};g.on("response",T),g.on("trailers",T),g.on("data",d=>D.push(d)),g.on("error",d=>a(new y("unavailable",`${e}:${t}: ${d.message}`))),g.on("end",()=>{if(b!=="0")return a(new y("grpc",`grpc-status ${b??"missing"}${k?`: ${k}`:""}`,b==null?void 0:Number(b)));let d=$.concat(D);if(d.length<5||d[0]!==0)return a(new y("grpc","reply is not one uncompressed gRPC message"));a(null,new Uint8Array(d.subarray(5,5+d.readUInt32BE(1))))}),g.end(m)})}async function Pt(e){let t=te("sha256");for await(let r of re(e))t.update(r);return t.digest("hex")}async function $t(e,t,r){let o=`${t}.part`;for(let n=0;;n++){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),l=await O(o,s?"a":"w");try{let a=s;for await(let u of i.body)await l.write(u),a+=u.length,r?.(a,c)}finally{await l.close()}break}catch(i){if(n>=4)throw i;await new Promise(c=>setTimeout(c,2e3*(n+1)))}}await B(o,t)}function Rt(e){let t="";for(let r=0;r<e.length;r+=32768)t+=String.fromCharCode(...e.subarray(r,r+32768));return btoa(t)}export{U as a,w as b,Ce as c,Ne as d,Ie as e,He as f,be as g,We as h,_e as i,Be as j,je as k,ze as l,Le as m,xe as n,A as o,Je as p,qe as q,Ge as r,Ye as s,R as t,Ke as u,Ve as v,Xe as w,Ze as x,Qe as y,et as z,tt as A,rt as B,nt as C,ot as D,st as E,it as F,at as G,ct as H,lt as I,ut as J,dt as K,mt as L,ft as M,pt as N,gt as O,F as P,yt as Q,wt as R,bt as S,ht as T,xt as U,y as V,vt as W,Pt as X,$t as Y,Rt as Z,St as _,Ot as $,Ut as aa,Ft as ba,Dt as ca,Tt as da};
@@ -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-MTMGQKLK.js").then(e=>e.isobmffFormat),crm:()=>import("./isobmff-MTMGQKLK.js").then(e=>e.isobmffFormat),braw:()=>import("./isobmff-MTMGQKLK.js").then(e=>e.isobmffFormat),wav:()=>import("./wav-HSCUCY4U.js").then(e=>e.wavFormat),mxf:()=>import("./mxf-J5QHA3VY.js").then(e=>e.mxfFormat),r3d:()=>import("./r3d-2PCOFR2Z.js").then(e=>e.r3dFormat),still:()=>import("./still-4UR35GZH.js").then(e=>e.stillFormat),avc1:()=>import("./h264-MAUVJTR4.js").then(e=>e.h264Format),avc3:()=>import("./h264-MAUVJTR4.js").then(e=>e.h264Format),h264:()=>import("./h264-MAUVJTR4.js").then(e=>e.h264Format),hvc1:()=>import("./h264-MAUVJTR4.js").then(e=>e.h264Format),hev1:()=>import("./h264-MAUVJTR4.js").then(e=>e.h264Format),hevc:()=>import("./h264-MAUVJTR4.js").then(e=>e.h264Format),h264_mxf:()=>import("./h264-mxf-2O4SAUTA.js").then(e=>e.h264MxfFormat),mcvideo:()=>import("./mc-video-HRZC7HGH.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-RH4JKUUB.js").then(e=>e.isobmffFormat),crm:()=>import("./isobmff-RH4JKUUB.js").then(e=>e.isobmffFormat),braw:()=>import("./isobmff-RH4JKUUB.js").then(e=>e.isobmffFormat),wav:()=>import("./wav-CV43ZAJI.js").then(e=>e.wavFormat),mxf:()=>import("./mxf-7HFFEBNW.js").then(e=>e.mxfFormat),r3d:()=>import("./r3d-G34YLXXA.js").then(e=>e.r3dFormat),still:()=>import("./still-AGBF3OOY.js").then(e=>e.stillFormat),avc1:()=>import("./h264-QCYEI6RF.js").then(e=>e.h264Format),avc3:()=>import("./h264-QCYEI6RF.js").then(e=>e.h264Format),h264:()=>import("./h264-QCYEI6RF.js").then(e=>e.h264Format),hvc1:()=>import("./h264-QCYEI6RF.js").then(e=>e.h264Format),hev1:()=>import("./h264-QCYEI6RF.js").then(e=>e.h264Format),hevc:()=>import("./h264-QCYEI6RF.js").then(e=>e.h264Format),h264_mxf:()=>import("./h264-mxf-2BYKXDGT.js").then(e=>e.h264MxfFormat),mcvideo:()=>import("./mc-video-MMKWEKFZ.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};
@@ -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{Qb as F,Rb as N,Ub as D}from"./chunk-VWFEMXYZ.js";import{i as j}from"./chunk-HOACOBAY.js";import{A as E,B as M,F as C,H as R,I as T,L as q,M as L,P as w,_ as b,aa as k,ba as _,da as I,g as y,n as O,s as A,t as S,u as x,v as P,y as H}from"./chunk-X527E5VI.js";var W=16e3,h=class extends Error{constructor(t,s){super(s);this.code=t}},$=class d{constructor(e,t=j,s=W){this.spec=e;this.bridge=t;this.waitMs=s;this.renders=new Map;this.host=e.host,e.items&&(this.items=n=>this.modelItems(n??{}))}async peer(){let e=await(await this.bridge()).waitFor(this.host,this.waitMs);if(!e)throw new h("not_connected",`${this.host}: the conform.tools plugin in ${this.spec.label} is not connected. ${this.spec.setup}`);return e}async needs(e){let t=await this.peer();if(!t.capabilities.includes(e))throw new h("panel_old",`${this.host}: the conform.tools plugin open in ${this.spec.label} ${t.version||""} has no ${e} (an older plugin); update it (${this.spec.setup})`);return t}async ask(e,t={},s){return await this.peer(),await(await this.bridge()).request(this.host,e,t,s)}static{this.announced=(e,t)=>e.optional_verbs.includes(t)}async support(){let e;try{e=await(await this.bridge()).waitFor(this.host,Math.min(3e3,this.waitMs))}catch(n){let o={ok:!1,reason:n instanceof Error?n.message:String(n)};return{export:o,open:o,render:o,markers:o}}if(!e){let n={ok:!1,reason:`the conform.tools plugin in ${this.spec.label} is not connected`,setup:this.spec.setup};return{export:n,open:n,render:n,markers:n}}let t=(n,o)=>n?{ok:!0}:{ok:!1,reason:`this plugin version has no ${o}`},s=e.capabilities;return{export:t(s.includes("timeline_read")||s.includes("timeline_write"),"timeline_read"),open:t(d.announced(e,"timeline_write.import_file"),"timeline_write.import_file"),render:t(s.includes("render"),"render"),markers:t(s.includes("markers"),"markers")}}async current(){let e=await this.ask("session.current_project");if(!e)return{project:"",timelines:[],timeline:""};let t=await this.ask("session.timeline_count",{project:e}),s=[];for(let o=1;o<=t;o++){let l=await this.ask("session.timeline_by_index",{project:e,index:o});l&&s.push(await this.ask("session.name",{handle:l}))}let n=await this.ask("session.current_timeline",{project:e});return{project:await this.ask("session.name",{handle:e}),timelines:s,timeline:n?await this.ask("session.name",{handle:n}):""}}async project(e={}){let t=await this.current();return{project:t.project,timeline:e.timeline??t.timeline,timelines:t.timelines,tracks:[],jobs:[],found:{},pool:{path:"",clips:0,folders:[]}}}async sequence(e){let t=await this.ask("session.current_project");if(!t)throw new h("no_project",`${this.host}: no project is open`);if(!e){let o=await this.ask("session.current_timeline",{project:t});if(!o)throw new h("no_timeline",`${this.host}: no timeline is active`);return{project:t,seq:o,name:await this.ask("session.name",{handle:o})}}let s=await this.ask("session.timeline_count",{project:t}),n=[];for(let o=1;o<=s;o++){let l=await this.ask("session.timeline_by_index",{project:t,index:o});if(!l)continue;let p=await this.ask("session.name",{handle:l});if(p===e)return{project:t,seq:l,name:p};n.push(p)}throw new h("not_found",`${this.host}: no timeline named "${e}" (have: ${n.join(", ")})`)}async model(e){let{project:t,seq:s}=await this.sequence(e);return await this.ask("timeline_read.model",{timeline:s,project:t},12e4)}async export(e){if(!e.out_path)throw new h("usage",`${this.host}: export needs out_path`);let t=await this.peer(),{project:s,seq:n,name:o}=await this.sequence(e.timeline),l=await this.ask("session.name",{handle:s}),p=r=>d.announced(t,r),m=e.out_path,c,a=[];if(p("timeline_write.export_otio")||p("timeline_write.export_xml")){let r=p("timeline_write.export_otio"),i=await this.ask(r?"timeline_write.export_otio":"timeline_write.export_xml",{project:s,timeline:n,path:e.out_path},12e4);if(c=i.format??(r?"otio":"xmeml"),i.ok===!1)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${e.out_path}${i.errors?.length?` (${i.errors.join("; ")})`:""}`);i.path&&i.path!==e.out_path&&(m=await this.adopt(i.path,e.out_path)),a=i.warnings??[]}else if(p("timeline_read.export_file")){let r=await this.ask("timeline_read.export_file",{timeline:n,fmt:"otio",path:e.out_path},12e4);if(!r)throw new h("export_failed",`${this.host}: ${this.spec.label} exported no OTIO`);c="otio",r!==e.out_path&&(m=await this.adopt(r,e.out_path))}else{await this.needs("timeline_read");let r=await this.ask("timeline_read.model",{timeline:n,project:s},12e4),i=J(r);await E(e.out_path,JSON.stringify(i.otio)),c="otio",a=i.notes}if(!F.includes(c))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${c}, which the engine does not read (${m})`);if(!await P(m)||(await S(m)).size===0)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${m}`);return{path:m,format:c,project:l,timeline:o,...a.length?{notes:a}:{}}}async adopt(e,t){let s=k(e)&&k(e)!==k(t)?t.slice(0,t.length-k(t).length)+k(e):t;if(await C(e,s),!N(s))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${b(e)}, which the engine does not read`);return s}async open(e){if(e.into==="scratch")throw new h("unsupported",`${this.host}: opening into a scratch project is not supported; the import lands in the open project`);let t=await this.peer();if(!d.announced(t,"timeline_write.import_file"))throw new h("unsupported",`${this.host}: this conform.tools plugin cannot import timelines (${this.spec.setup})`);let s=await this.ask("session.current_project");if(!s)throw new h("no_project",`${this.host}: no project is open`);let n=await this.ask("timeline_write.import_file",{project:s,path:e.path,sequences:null},3e5);if(!n.ok)throw new h("import_failed",`${this.host}: ${this.spec.label} did not import ${e.path}${n.issues?.length?` (${n.issues.join("; ")})`:""}`);let o=[...n.issues??[]];return n.imported.length>1&&o.push(`imported ${n.imported.length} timelines: ${n.imported.map(l=>l.name).join(", ")}`),e.name&&o.push(`${this.spec.label} names imported timelines after the file's own; name was not applied`),e.media_dirs?.length&&o.push(`${this.spec.label} links media from the paths in the file; media_dirs was not used (relink with timeline_relink before writing)`),{project:await this.ask("session.name",{handle:s}),timeline:n.imported[0]?.name??b(e.path),notes:o,restored:!e.stay,...n.bin?{folder:n.bin}:{}}}async modelItems(e){let t=await this.model(e.timeline),s=[...e.kind==="audio"?[]:t.items.map(n=>({kind:"video",track:n.track,start:n.start-t.start_frame,end:n.end-t.start_frame,id:n.handle?.$h??n.clip_id??"",name:n.name??"",color:n.color??"",flags:n.flags??[],enabled:n.enabled??!0,file:n.file_path})),...e.kind==="video"?[]:(t.audio_items??[]).map(n=>({kind:"audio",track:n.track,start:n.start-t.start_frame,end:n.end-t.start_frame,id:"",name:n.name??"",file:n.file_path??""}))].filter(n=>e.track===void 0||n.track===e.track);return{project:(await this.current()).project,timeline:t.timeline,start_frame:t.start_frame,fps:t.fps,items:s,color_groups:[],layers:1}}async apply(e){let t=e.ops.length>0&&e.ops.every(a=>a.op==="timeline_rename"&&(a.timeline||a.guid)),{project:s,seq:n,name:o}=await this.sequence(t?void 0:e.timeline),l=[],p=[],m=a=>a.op.startsWith("marker_")&&!a.item;for(let a=0;a<e.ops.length;){let r=a;for(;r<e.ops.length&&m(e.ops[r])===m(e.ops[a]);)r++;let i=e.ops.slice(a,r),u=m(i[0])?await this.markerOps(n,i):await this.clipOps(n,i,e.timeline);l.push(...u.results),p.unshift(...u.undo),a=r}let c=l.filter(a=>a.ok).length;return{project:await this.ask("session.name",{handle:s}),timeline:o,results:l,undo:p,applied:c,failed:l.length-c}}async clipOps(e,t,s){let n=await this.peer();if(n.capabilities.includes("edit"))return await this.ask("edit.apply",{timeline:e,ops:t},6e4+t.length*500);let o=(a,r)=>({op:a.op,ok:!1,detail:r});if(!n.capabilities.includes("item_meta"))return{results:t.map(a=>o(a,`${this.host}: clip edits are not reachable over this plugin`)),undo:[]};let l=await this.model(s),p=a=>a?"id"in a?{$h:a.id}:(a.kind??"video")!=="video"?null:l.items.find(r=>r.track===a.track&&r.start-l.start_frame===a.start)?.handle??null:null,m=[],c=[];for(let a of t){let r=p(a.item);try{if(!r)m.push(o(a,`no video item at ${JSON.stringify(a.item??null)}`));else if(a.op==="clip_color"){let i=await this.ask("item_meta.color",{handle:r}),u=a.color?await this.ask("item_meta.set_color",{handle:r,color:a.color}):await this.ask("item_meta.clear_color",{handle:r});m.push({op:a.op,ok:u}),u&&c.unshift({op:"clip_color",item:a.item,color:i})}else if(a.op==="enabled"&&d.announced(n,"item_meta.set_enabled")){let i=l.items.find(f=>f.handle?.$h===r.$h)?.enabled??!0,u=await this.ask("item_meta.set_enabled",{item:r,enabled:!!a.on});m.push({op:a.op,ok:u}),u&&c.unshift({op:"enabled",item:a.item,on:i})}else m.push(o(a,`${this.host}: '${a.op}' is not reachable over this plugin`))}catch(i){m.push(o(a,i instanceof Error?i.message:String(i)))}}return{results:m,undo:c}}async markerOps(e,t){let s=await this.peer(),n=r=>d.announced(s,r),o=new Map((await this.ask("markers.list",{target:e})).map(r=>[r.frame,r])),l=[],p=[],m=async r=>{let i=await this.ask("markers.add",{target:e,frame:r.frame,color:r.color??"",name:r.name??"",note:r.note??"",duration:r.duration??1,custom_data:r.custom_data??""});return i&&o.set(r.frame,{color:"",name:"",note:"",duration:1,...r}),i},c=async r=>{let i=await this.ask("markers.delete_at",{target:e,frame:r});return i&&o.delete(r),i},a=r=>({op:"marker_add",frame:r.frame,color:r.color,name:r.name,note:r.note,duration:r.duration,...r.custom_data?{data:r.custom_data}:{}});for(let r of t){let i=Number(r.frame);try{if(r.op==="marker_add"){let u=o.get(i);u&&await c(i);let f=await m({frame:i,color:r.color,name:r.name,note:r.note,duration:Number(r.duration??1),custom_data:r.data});l.push({op:r.op,ok:f}),f&&p.unshift(...u?[a(u)]:[],{op:"marker_delete",frame:i})}else if(r.op==="marker_update"){let u=o.get(i);if(!u){l.push({op:r.op,ok:!1,detail:`no marker at frame ${i}`});continue}let f=r.to_frame!==void 0?Number(r.to_frame):i,v={...u,frame:f,...r.color!==void 0?{color:String(r.color)}:{},...r.name!==void 0?{name:String(r.name)}:{},...r.note!==void 0?{note:String(r.note)}:{}},g=!0;n("markers.set_color")&&n("markers.set_text")&&n("markers.move")?(r.color!==void 0&&(g=await this.ask("markers.set_color",{target:e,frame:i,color:r.color})&&g),(r.name!==void 0||r.note!==void 0)&&(g=await this.ask("markers.set_text",{target:e,frame:i,name:r.name,note:r.note})&&g),f!==i&&(g=await this.ask("markers.move",{target:e,frame:i,to_frame:f})&&g),o.delete(i),o.set(f,v)):g=await c(i)&&await m(v),l.push({op:r.op,ok:g}),p.unshift({op:"marker_update",frame:f,color:u.color,name:u.name,note:u.note,...f!==i?{to_frame:i}:{}})}else if(r.op==="marker_delete"){let u=o.get(i),f=!!u&&await c(i);l.push({op:r.op,ok:f,...u?{}:{detail:`no marker at frame ${i}`}}),f&&u&&p.unshift(a(u))}else l.push({op:r.op,ok:!1,detail:`${this.host}: '${r.op}' is not reachable over this plugin`})}catch(u){l.push({op:r.op,ok:!1,detail:u instanceof Error?u.message:String(u)})}}return{results:l,undo:p}}async renderStart(e){if(await this.needs("render"),e.disable_tracks?.length||e.audio_tracks?.length)throw new h("unsupported",`${this.host}: disable_tracks / audio_tracks are DaVinci Resolve's; pick a preset that renders what you need`);if(!e.preset)throw new h("usage",`${this.host}: preset is required: one of ${this.spec.label}'s export presets by name`);let{seq:t,name:s}=await this.sequence(e.timeline),n=e.name??s,o={purpose:"deliver",format:"preset",preset:e.preset,target_dir:e.target_dir,name:n,...e.range?{range:[e.range.in,e.range.out]}:{}},l=await this.ask("render.submit",{timeline:t,job:o});if(!l?.id)throw new h("render_refused",`${this.host}: ${l?.error??`${this.spec.label} refused the render`}`);if(!await this.ask("render.start",{job_ids:[l.id]}))throw new h("render_refused",`${this.host}: ${this.spec.label} did not start job ${l.id}`);return this.renders.set(l.id,{dir:e.target_dir,name:n}),{job_id:l.id,state:"queued",percent:0}}async renderStatus(e){let t=await this.ask("render.status",{job_id:e});if(!t)return{job_id:e,state:"failed",percent:0,error:`${this.host}: no render job ${e}`};let s={done:"complete",rendering:"rendering",queued:"queued",failed:"failed",cancelled:"cancelled"}[t.state]??"rendering",n={job_id:e,state:s,percent:Math.round(t.progress??(s==="complete"?100:0)),...t.error?{error:t.error}:{}};if(s==="complete"||s==="failed"||s==="cancelled"){let o=this.renders.get(e);s==="complete"&&o&&(n.outputs=await V(o.dir,o.name)),await this.ask("render.remove",{job_id:e}).catch(()=>!1),this.renders.delete(e)}return n}async renderCancel(e){return await this.ask("render.cancel",{job_id:e})?{job_id:e,state:"cancelled",percent:0}:{...await this.renderStatus(e),error:`${this.spec.label}'s running export cannot be cancelled from here; stop it in ${this.spec.label}`}}};async function V(d,e){let t=[];try{for await(let s of L(d))s.isFile&&s.name.startsWith(`${e}.`)&&t.push(_(d,s.name))}catch{}return t.sort()}function J(d){let e=(c,a)=>({OTIO_SCHEMA:"RationalTime.1",value:c,rate:a}),t=(c,a,r,i=r)=>({OTIO_SCHEMA:"TimeRange.1",start_time:e(c,r),duration:e(a,i)}),s=d.fps,n=d.tracks?.length?d.tracks:[...new Set(d.items.map(c=>c.track))].sort((c,a)=>c-a).map(c=>({index:c,enabled:!0,name:"",items:d.items.filter(a=>a.track===c)})),o=c=>(c.reversed?-1:1)*(c.speed||1)/(c.fps_factor||1),l=new Map;for(let c of d.items)if(c.file_path&&c.start_tc!=null&&c.src_abs_in!=null){let a=c.src_abs_in-c.start_tc+Math.ceil((c.end-c.start)*Math.abs(o(c))*(c.fps_factor||1));l.set(c.file_path,Math.max(l.get(c.file_path)??0,a))}let p=n.map(c=>{let a=d.start_frame,r=[];for(let i of[...c.items].sort((u,f)=>u.start-f.start)){if(i.start<a)continue;i.start>a&&r.push({OTIO_SCHEMA:"Gap.1",name:"",source_range:t(0,i.start-a,s)});let u=i.src_fps||s,f=i.start_tc!=null&&l.has(i.file_path)?i.start_tc:null,v=f!=null?i.src_abs_in:i.src_in??i.src_abs_in??0,g=o(i);r.push({OTIO_SCHEMA:"Clip.2",name:i.name??b(i.file_path||""),enabled:i.enabled!==!1,source_range:t(v,i.end-i.start,u,s),media_references:{DEFAULT_MEDIA:{OTIO_SCHEMA:"ExternalReference.1",name:b(i.file_path||""),target_url:i.file_path?`file://${i.file_path}`:"",...f!=null?{available_range:t(f,l.get(i.file_path),u)}:{},metadata:{}}},active_media_reference_key:"DEFAULT_MEDIA",effects:Math.abs(g-1)>1e-6?[{OTIO_SCHEMA:"LinearTimeWarp.1",name:"",effect_name:"LinearTimeWarp",time_scalar:g}]:[],markers:[],metadata:i.reel?{cmx_3600:{reel:i.reel}}:{}}),a=i.end}return{OTIO_SCHEMA:"Track.1",name:c.name||`V${c.index}`,kind:"Video",enabled:c.enabled!==!1,children:r,effects:[],markers:[],metadata:{}}}),m=[];return d.audio_items?.length&&m.push(`${d.audio_items.length} audio clip(s) not carried: the host's plugin reports no audio source times`),d.transitions?.length&&m.push(`${d.transitions.length} transition(s) not carried (cuts in their place)`),{otio:{OTIO_SCHEMA:"Timeline.1",name:d.timeline,global_start_time:e(d.start_frame,s),metadata:{},tracks:{OTIO_SCHEMA:"Stack.1",name:"tracks",children:p,effects:[],markers:[],metadata:{}}},notes:m}}var X=16e3;var G="Install the conform.tools panel (host_setup host=premiere action=install_panel), then in Premiere open Window > UXP Plugins > conform.tools. It connects by itself from then on.";var U=class extends ${constructor(t=j,s=X){super({host:"premiere",label:"Premiere Pro",setup:G},t,s);this.items=async(t={})=>{await this.needs("edit");let{seq:s}=await this.sequence(t.timeline),n=await this.ask("edit.items",{timeline:s,kind:t.kind,track:t.track},12e4),o=n.project_path?await K(n.project_path,n.timeline).catch(p=>({error:p instanceof Error?p.message:String(p)})):{error:"the project has never been saved"},l=0;if(!("error"in o))for(let p of n.items){let m=o.get(`${p.kind}:${p.track}:${p.start}:${Number(p.end)-Number(p.start)}`);m?Object.assign(p,m,{saved:!0}):(p.saved=!1,l++)}return{...n,color_groups:[],layers:1,..."error"in o?{saved_note:`saved project not read: ${o.error}`}:{unsaved_items:l}}};this.premiereRenders=new Map}async current(){let t=await this.ask("session.describe");return{project:t.project,timelines:t.timelines,timeline:t.current}}async liveMarkers(t){if(!$.announced(await this.peer(),"edit.markers"))return null;let{seq:s}=await this.sequence(t);return await this.ask("edit.markers",{timeline:s},12e4)}async model(t){return await super.model(t)}async projectClips(){return await this.needs("edit"),await this.ask("edit.project_clips",{},12e4)}async relinkClips(t){return await this.needs("edit"),await this.ask("edit.relink_clips",{items:t},6e4+t.length*2e3)}async cutIn(t,s){await this.needs("edit");let{seq:n}=await this.sequence(t);return await this.ask("edit.cut_in",{timeline:n,cuts:s},12e4+s.length*3e3)}async renderStart(t){if(t.range)throw new h("unsupported","premiere: a frame range is not supported yet; set in/out on the sequence in Premiere");if(!t.preset||!/\.epr$/i.test(t.preset))throw new h("usage","premiere: preset must be the path of a Media Encoder preset (.epr)");let{seq:s,name:n}=await this.sequence(t.timeline);await M(t.target_dir);let o=_(t.target_dir,`${t.name??n}.mov`),l=await this.ask("render.export_sequence",{timeline:s,output_path:o,preset_path:t.preset,queue:!1},6e4);if(!l.ok)throw new h("render_refused","premiere: Premiere refused the export");let p=l.job||`ppro-${Date.now()}`;return this.premiereRenders.set(p,o),{job_id:p,state:"rendering",percent:0}}async renderStatus(t){let s=await this.ask("render.progress"),n=s[t]??s.last,o=this.premiereRenders.get(t);return n?.event==="error"||n?.event==="onEncodeError"?{job_id:t,state:"failed",percent:0,error:String(n.data??"encode error")}:n?.event==="complete"||n?.event==="onEncodeComplete"||o&&await x(o)&&!n?{job_id:t,state:"complete",percent:100,...o?{outputs:[o]}:{}}:{job_id:t,state:"rendering",percent:typeof n?.data=="number"?Math.round(Number(n.data)*100):0}}async renderCancel(t){return{job_id:t,state:"cancelled",percent:0,error:"Premiere's export cannot be cancelled from here; cancel it in Premiere / Media Encoder"}}};async function K(d,e){let{session:t}=await D(d,"prproj"),s=t.timelines.find(o=>o.name===e),n=new Map;if(!s)throw new Error(`the saved project has no sequence "${e}" (saved before it was made?)`);for(let o of s.tracks)if(!(o.kind!=="Video"&&o.kind!=="Audio"))for(let l of o.items){if(l.kind==="gap"||l.kind==="transition")continue;let p=l;n.set(`${o.kind==="Video"?"video":"audio"}:${o.track_index}:${l.timeline_range.start.value}:${l.timeline_range.duration.value}`,{saved_id:l.id,...p.speed_factor!=null&&p.speed_factor!==1?{retime:p.speed_factor}:{},...p.speed_ramped?{ramped:!0}:{},...p.speed_reverse?{reversed:!0}:{},...l.kind==="nested"?{nested:!0}:{},...p.is_multicam?{multicam:!0}:{},...p.effects?.some(m=>/stabiliz/i.test(m.kind??""))?{stabilized:!0}:{},...p.effects?.length?{saved_effects:p.effects.map(m=>m.name??m.kind??"")}:{}})}return n}function z(d=y()){return d==="darwin"?"/Library/Application Support/Adobe/Adobe Desktop Common/RemoteComponents/UPI/UnifiedPluginInstallerAgent/UnifiedPluginInstallerAgent.app/Contents/MacOS/UnifiedPluginInstallerAgent":d==="win32"?"C:\\Program Files\\Common Files\\Adobe\\Adobe Desktop Common\\RemoteComponents\\UPI\\UnifiedPluginInstallerAgent\\UnifiedPluginInstallerAgent.exe":null}async function B(){for(let d of["./uxp-plugin/","./premiere-uxp/"]){let e=A(new URL(d,import.meta.url));if(await P(_(e,"manifest.json")))return e}throw new Error("premiere: the conform.tools panel is missing from this install")}async function Q(){return JSON.parse(await H(_(await B(),"manifest.json"))).version}async function oe(d=y()){let e=z(d);if(!e||!await x(e))return{installed:!1,listing:"Creative Cloud's plugin installer is not on this machine"};let t=await w(e,d==="win32"?["/list","all"]:["--list","all"],{timeoutMs:6e4}),s=t.stdout.split(`
4
- `).find(n=>/CONFORM\.TOOLS|conformtools/i.test(n));return{installed:!!s&&/enabled|installed/i.test(s),version:s?.match(/(\d+\.\d+\.\d+)\s*$/)?.[1],listing:t.stdout.trim()}}async function ae(d=y()){let e=z(d);if(!e||!await x(e))throw new Error("premiere: Creative Cloud's plugin installer (UnifiedPluginInstallerAgent) is not on this machine; install Creative Cloud");let t=await B(),s=await Q(),n=await q("conform-ccx-");for(let a of["manifest.json","index.html","index.js","lib","icons"])await T(_(t,a),_(n,a));let o=_(O(),"premiere");await M(o);let l=I(_(o,`conformtools-premiere-${s}.ccx`));await R(l);let p=d==="darwin"?await w("sh",["-c",`cd '${n.replace(/'/g,"'\\''")}' && zip -r -q -X '${l.replace(/'/g,"'\\''")}' manifest.json index.html index.js lib icons`]):await w("powershell",["-NoProfile","-Command",`Compress-Archive -Path '${n}\\*' -DestinationPath '${l.replace(/\.ccx$/,".zip")}' -Force; Move-Item -Force '${l.replace(/\.ccx$/,".zip")}' '${l}'`]);if(await R(n),!p.success)throw new Error(`premiere: could not package the panel: ${p.stderr.trim()}`);await w(e,d==="win32"?["/remove","conform.tools"]:["--remove","conform.tools"],{timeoutMs:12e4});let m=await w(e,d==="win32"?["/install",l]:["--install",l],{timeoutMs:18e4}),c=`${m.stdout}
3
+ import{Qb as F,Rb as N,Ub as D}from"./chunk-VCBLWNQR.js";import{i as j}from"./chunk-2SDAOYP5.js";import{A as E,B as M,F as C,H as R,I as T,L as q,M as L,P as w,_ as b,aa as k,ba as _,da as I,g as y,n as O,s as S,t as A,u as x,v as P,y as H}from"./chunk-GTPTZRO6.js";var W=16e3,h=class extends Error{constructor(t,s){super(s);this.code=t}},$=class p{constructor(e,t=j,s=W){this.spec=e;this.bridge=t;this.waitMs=s;this.renders=new Map;this.host=e.host,e.items&&(this.items=n=>this.modelItems(n??{}))}async peer(){let e=await(await this.bridge()).waitFor(this.host,this.waitMs);if(!e)throw new h("not_connected",`${this.host}: the conform.tools plugin in ${this.spec.label} is not connected. ${this.spec.setup}`);return e}async needs(e){let t=await this.peer();if(!t.capabilities.includes(e))throw new h("panel_old",`${this.host}: the conform.tools plugin open in ${this.spec.label} ${t.version||""} has no ${e} (an older plugin); update it (${this.spec.setup})`);return t}async ask(e,t={},s){return await this.peer(),await(await this.bridge()).request(this.host,e,t,s)}static{this.announced=(e,t)=>e.optional_verbs.includes(t)}async support(){let e;try{e=await(await this.bridge()).waitFor(this.host,Math.min(3e3,this.waitMs))}catch(n){let o={ok:!1,reason:n instanceof Error?n.message:String(n)};return{export:o,open:o,render:o,markers:o}}if(!e){let n={ok:!1,reason:`the conform.tools plugin in ${this.spec.label} is not connected`,setup:this.spec.setup};return{export:n,open:n,render:n,markers:n}}let t=(n,o)=>n?{ok:!0}:{ok:!1,reason:`this plugin version has no ${o}`},s=e.capabilities;return{export:t(s.includes("timeline_read")||s.includes("timeline_write"),"timeline_read"),open:t(p.announced(e,"timeline_write.import_file"),"timeline_write.import_file"),render:t(s.includes("render"),"render"),markers:t(s.includes("markers"),"markers")}}async current(){let e=await this.ask("session.current_project");if(!e)return{project:"",timelines:[],timeline:""};let t=await this.ask("session.timeline_count",{project:e}),s=[];for(let o=1;o<=t;o++){let l=await this.ask("session.timeline_by_index",{project:e,index:o});l&&s.push(await this.ask("session.name",{handle:l}))}let n=await this.ask("session.current_timeline",{project:e});return{project:await this.ask("session.name",{handle:e}),timelines:s,timeline:n?await this.ask("session.name",{handle:n}):""}}async project(e={}){let t=await this.current();return{project:t.project,timeline:e.timeline??t.timeline,timelines:t.timelines,tracks:[],jobs:[],found:{},pool:{path:"",clips:0,folders:[]}}}async sequence(e){let t=await this.ask("session.current_project");if(!t)throw new h("no_project",`${this.host}: no project is open`);if(!e){let o=await this.ask("session.current_timeline",{project:t});if(!o)throw new h("no_timeline",`${this.host}: no timeline is active`);return{project:t,seq:o,name:await this.ask("session.name",{handle:o})}}let s=await this.ask("session.timeline_count",{project:t}),n=[];for(let o=1;o<=s;o++){let l=await this.ask("session.timeline_by_index",{project:t,index:o});if(!l)continue;let d=await this.ask("session.name",{handle:l});if(d===e)return{project:t,seq:l,name:d};n.push(d)}throw new h("not_found",`${this.host}: no timeline named "${e}" (have: ${n.join(", ")})`)}async model(e){let{project:t,seq:s}=await this.sequence(e);return await this.ask("timeline_read.model",{timeline:s,project:t},12e4)}async export(e){if(!e.out_path)throw new h("usage",`${this.host}: export needs out_path`);let t=await this.peer(),{project:s,seq:n,name:o}=await this.sequence(e.timeline),l=await this.ask("session.name",{handle:s}),d=r=>p.announced(t,r),m=e.out_path,c,a=[];if(d("timeline_write.export_otio")||d("timeline_write.export_xml")){let r=d("timeline_write.export_otio"),i=await this.ask(r?"timeline_write.export_otio":"timeline_write.export_xml",{project:s,timeline:n,path:e.out_path},12e4);if(c=i.format??(r?"otio":"xmeml"),i.ok===!1)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${e.out_path}${i.errors?.length?` (${i.errors.join("; ")})`:""}`);i.path&&i.path!==e.out_path&&(m=await this.adopt(i.path,e.out_path)),a=i.warnings??[]}else if(d("timeline_read.export_file")){let r=await this.ask("timeline_read.export_file",{timeline:n,fmt:"otio",path:e.out_path},12e4);if(!r)throw new h("export_failed",`${this.host}: ${this.spec.label} exported no OTIO`);c="otio",r!==e.out_path&&(m=await this.adopt(r,e.out_path))}else{await this.needs("timeline_read");let r=await this.ask("timeline_read.model",{timeline:n,project:s},12e4),i=J(r);await E(e.out_path,JSON.stringify(i.otio)),c="otio",a=i.notes}if(!F.includes(c))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${c}, which the engine does not read (${m})`);if(!await P(m)||(await A(m)).size===0)throw new h("export_failed",`${this.host}: ${this.spec.label} did not write ${m}`);return{path:m,format:c,project:l,timeline:o,...a.length?{notes:a}:{}}}async adopt(e,t){let s=k(e)&&k(e)!==k(t)?t.slice(0,t.length-k(t).length)+k(e):t;if(await C(e,s),!N(s))throw new h("export_failed",`${this.host}: ${this.spec.label} exported ${b(e)}, which the engine does not read`);return s}async open(e){if(e.into==="scratch")throw new h("unsupported",`${this.host}: opening into a scratch project is not supported; the import lands in the open project`);let t=await this.peer();if(!p.announced(t,"timeline_write.import_file"))throw new h("unsupported",`${this.host}: this conform.tools plugin cannot import timelines (${this.spec.setup})`);let s=await this.ask("session.current_project");if(!s)throw new h("no_project",`${this.host}: no project is open`);let n=await this.ask("timeline_write.import_file",{project:s,path:e.path,sequences:null},3e5);if(!n.ok)throw new h("import_failed",`${this.host}: ${this.spec.label} did not import ${e.path}${n.issues?.length?` (${n.issues.join("; ")})`:""}`);let o=[...n.issues??[]];return n.imported.length>1&&o.push(`imported ${n.imported.length} timelines: ${n.imported.map(l=>l.name).join(", ")}`),e.name&&o.push(`${this.spec.label} names imported timelines after the file's own; name was not applied`),e.media_dirs?.length&&o.push(`${this.spec.label} links media from the paths in the file; media_dirs was not used (relink with timeline_relink before writing)`),{project:await this.ask("session.name",{handle:s}),timeline:n.imported[0]?.name??b(e.path),notes:o,restored:!e.stay,...n.bin?{folder:n.bin}:{}}}async modelItems(e){let t=await this.model(e.timeline),s=[...e.kind==="audio"?[]:t.items.map(n=>({kind:"video",track:n.track,start:n.start-t.start_frame,end:n.end-t.start_frame,id:n.handle?.$h??n.clip_id??"",name:n.name??"",color:n.color??"",flags:n.flags??[],enabled:n.enabled??!0,file:n.file_path})),...e.kind==="video"?[]:(t.audio_items??[]).map(n=>({kind:"audio",track:n.track,start:n.start-t.start_frame,end:n.end-t.start_frame,id:"",name:n.name??"",file:n.file_path??""}))].filter(n=>e.track===void 0||n.track===e.track);return{project:(await this.current()).project,timeline:t.timeline,start_frame:t.start_frame,fps:t.fps,items:s,color_groups:[],layers:1}}async apply(e){let t=e.ops.length>0&&e.ops.every(a=>a.op==="timeline_rename"&&(a.timeline||a.guid)),{project:s,seq:n,name:o}=await this.sequence(t?void 0:e.timeline),l=[],d=[],m=a=>a.op.startsWith("marker_")&&!a.item;for(let a=0;a<e.ops.length;){let r=a;for(;r<e.ops.length&&m(e.ops[r])===m(e.ops[a]);)r++;let i=e.ops.slice(a,r),u=m(i[0])?await this.markerOps(n,i):await this.clipOps(n,i,e.timeline);l.push(...u.results),d.unshift(...u.undo),a=r}let c=l.filter(a=>a.ok).length;return{project:await this.ask("session.name",{handle:s}),timeline:o,results:l,undo:d,applied:c,failed:l.length-c}}async clipOps(e,t,s){let n=await this.peer();if(n.capabilities.includes("edit"))return await this.ask("edit.apply",{timeline:e,ops:t},6e4+t.length*500);let o=(a,r)=>({op:a.op,ok:!1,detail:r});if(!n.capabilities.includes("item_meta"))return{results:t.map(a=>o(a,`${this.host}: clip edits are not reachable over this plugin`)),undo:[]};let l=await this.model(s),d=a=>a?"id"in a?{$h:a.id}:(a.kind??"video")!=="video"?null:l.items.find(r=>r.track===a.track&&r.start-l.start_frame===a.start)?.handle??null:null,m=[],c=[];for(let a of t){let r=d(a.item);try{if(!r)m.push(o(a,`no video item at ${JSON.stringify(a.item??null)}`));else if(a.op==="clip_color"){let i=await this.ask("item_meta.color",{handle:r}),u=a.color?await this.ask("item_meta.set_color",{handle:r,color:a.color}):await this.ask("item_meta.clear_color",{handle:r});m.push({op:a.op,ok:u}),u&&c.unshift({op:"clip_color",item:a.item,color:i})}else if(a.op==="enabled"&&p.announced(n,"item_meta.set_enabled")){let i=l.items.find(f=>f.handle?.$h===r.$h)?.enabled??!0,u=await this.ask("item_meta.set_enabled",{item:r,enabled:!!a.on});m.push({op:a.op,ok:u}),u&&c.unshift({op:"enabled",item:a.item,on:i})}else m.push(o(a,`${this.host}: '${a.op}' is not reachable over this plugin`))}catch(i){m.push(o(a,i instanceof Error?i.message:String(i)))}}return{results:m,undo:c}}async markerOps(e,t){let s=await this.peer(),n=r=>p.announced(s,r),o=new Map((await this.ask("markers.list",{target:e})).map(r=>[r.frame,r])),l=[],d=[],m=async r=>{let i=await this.ask("markers.add",{target:e,frame:r.frame,color:r.color??"",name:r.name??"",note:r.note??"",duration:r.duration??1,custom_data:r.custom_data??""});return i&&o.set(r.frame,{color:"",name:"",note:"",duration:1,...r}),i},c=async r=>{let i=await this.ask("markers.delete_at",{target:e,frame:r});return i&&o.delete(r),i},a=r=>({op:"marker_add",frame:r.frame,color:r.color,name:r.name,note:r.note,duration:r.duration,...r.custom_data?{data:r.custom_data}:{}});for(let r of t){let i=Number(r.frame);try{if(r.op==="marker_add"){let u=o.get(i);u&&await c(i);let f=await m({frame:i,color:r.color,name:r.name,note:r.note,duration:Number(r.duration??1),custom_data:r.data});l.push({op:r.op,ok:f}),f&&d.unshift(...u?[a(u)]:[],{op:"marker_delete",frame:i})}else if(r.op==="marker_update"){let u=o.get(i);if(!u){l.push({op:r.op,ok:!1,detail:`no marker at frame ${i}`});continue}let f=r.to_frame!==void 0?Number(r.to_frame):i,v={...u,frame:f,...r.color!==void 0?{color:String(r.color)}:{},...r.name!==void 0?{name:String(r.name)}:{},...r.note!==void 0?{note:String(r.note)}:{}},g=!0;n("markers.set_color")&&n("markers.set_text")&&n("markers.move")?(r.color!==void 0&&(g=await this.ask("markers.set_color",{target:e,frame:i,color:r.color})&&g),(r.name!==void 0||r.note!==void 0)&&(g=await this.ask("markers.set_text",{target:e,frame:i,name:r.name,note:r.note})&&g),f!==i&&(g=await this.ask("markers.move",{target:e,frame:i,to_frame:f})&&g),o.delete(i),o.set(f,v)):g=await c(i)&&await m(v),l.push({op:r.op,ok:g}),d.unshift({op:"marker_update",frame:f,color:u.color,name:u.name,note:u.note,...f!==i?{to_frame:i}:{}})}else if(r.op==="marker_delete"){let u=o.get(i),f=!!u&&await c(i);l.push({op:r.op,ok:f,...u?{}:{detail:`no marker at frame ${i}`}}),f&&u&&d.unshift(a(u))}else l.push({op:r.op,ok:!1,detail:`${this.host}: '${r.op}' is not reachable over this plugin`})}catch(u){l.push({op:r.op,ok:!1,detail:u instanceof Error?u.message:String(u)})}}return{results:l,undo:d}}async renderStart(e){if(await this.needs("render"),e.disable_tracks?.length||e.audio_tracks?.length)throw new h("unsupported",`${this.host}: disable_tracks / audio_tracks are DaVinci Resolve's; pick a preset that renders what you need`);if(!e.preset)throw new h("usage",`${this.host}: preset is required: one of ${this.spec.label}'s export presets by name`);let{seq:t,name:s}=await this.sequence(e.timeline),n=e.name??s,o={purpose:"deliver",format:"preset",preset:e.preset,target_dir:e.target_dir,name:n,...e.range?{range:[e.range.in,e.range.out]}:{}},l=await this.ask("render.submit",{timeline:t,job:o});if(!l?.id)throw new h("render_refused",`${this.host}: ${l?.error??`${this.spec.label} refused the render`}`);if(!await this.ask("render.start",{job_ids:[l.id]}))throw new h("render_refused",`${this.host}: ${this.spec.label} did not start job ${l.id}`);return this.renders.set(l.id,{dir:e.target_dir,name:n}),{job_id:l.id,state:"queued",percent:0}}async renderStatus(e){let t=await this.ask("render.status",{job_id:e});if(!t)return{job_id:e,state:"failed",percent:0,error:`${this.host}: no render job ${e}`};let s={done:"complete",rendering:"rendering",queued:"queued",failed:"failed",cancelled:"cancelled"}[t.state]??"rendering",n={job_id:e,state:s,percent:Math.round(t.progress??(s==="complete"?100:0)),...t.error?{error:t.error}:{}};if(s==="complete"||s==="failed"||s==="cancelled"){let o=this.renders.get(e);s==="complete"&&o&&(n.outputs=await V(o.dir,o.name)),await this.ask("render.remove",{job_id:e}).catch(()=>!1),this.renders.delete(e)}return n}async renderCancel(e){return await this.ask("render.cancel",{job_id:e})?{job_id:e,state:"cancelled",percent:0}:{...await this.renderStatus(e),error:`${this.spec.label}'s running export cannot be cancelled from here; stop it in ${this.spec.label}`}}};async function V(p,e){let t=[];try{for await(let s of L(p))s.isFile&&s.name.startsWith(`${e}.`)&&t.push(_(p,s.name))}catch{}return t.sort()}function J(p){let e=(c,a)=>({OTIO_SCHEMA:"RationalTime.1",value:c,rate:a}),t=(c,a,r,i=r)=>({OTIO_SCHEMA:"TimeRange.1",start_time:e(c,r),duration:e(a,i)}),s=p.fps,n=p.tracks?.length?p.tracks:[...new Set(p.items.map(c=>c.track))].sort((c,a)=>c-a).map(c=>({index:c,enabled:!0,name:"",items:p.items.filter(a=>a.track===c)})),o=c=>(c.reversed?-1:1)*(c.speed||1)/(c.fps_factor||1),l=new Map;for(let c of p.items)if(c.file_path&&c.start_tc!=null&&c.src_abs_in!=null){let a=c.src_abs_in-c.start_tc+Math.ceil((c.end-c.start)*Math.abs(o(c))*(c.fps_factor||1));l.set(c.file_path,Math.max(l.get(c.file_path)??0,a))}let d=n.map(c=>{let a=p.start_frame,r=[];for(let i of[...c.items].sort((u,f)=>u.start-f.start)){if(i.start<a)continue;i.start>a&&r.push({OTIO_SCHEMA:"Gap.1",name:"",source_range:t(0,i.start-a,s)});let u=i.src_fps||s,f=i.start_tc!=null&&l.has(i.file_path)?i.start_tc:null,v=f!=null?i.src_abs_in:i.src_in??i.src_abs_in??0,g=o(i);r.push({OTIO_SCHEMA:"Clip.2",name:i.name??b(i.file_path||""),enabled:i.enabled!==!1,source_range:t(v,i.end-i.start,u,s),media_references:{DEFAULT_MEDIA:{OTIO_SCHEMA:"ExternalReference.1",name:b(i.file_path||""),target_url:i.file_path?`file://${i.file_path}`:"",...f!=null?{available_range:t(f,l.get(i.file_path),u)}:{},metadata:{}}},active_media_reference_key:"DEFAULT_MEDIA",effects:Math.abs(g-1)>1e-6?[{OTIO_SCHEMA:"LinearTimeWarp.1",name:"",effect_name:"LinearTimeWarp",time_scalar:g}]:[],markers:[],metadata:i.reel?{cmx_3600:{reel:i.reel}}:{}}),a=i.end}return{OTIO_SCHEMA:"Track.1",name:c.name||`V${c.index}`,kind:"Video",enabled:c.enabled!==!1,children:r,effects:[],markers:[],metadata:{}}}),m=[];return p.audio_items?.length&&m.push(`${p.audio_items.length} audio clip(s) not carried: the host's plugin reports no audio source times`),p.transitions?.length&&m.push(`${p.transitions.length} transition(s) not carried (cuts in their place)`),{otio:{OTIO_SCHEMA:"Timeline.1",name:p.timeline,global_start_time:e(p.start_frame,s),metadata:{},tracks:{OTIO_SCHEMA:"Stack.1",name:"tracks",children:d,effects:[],markers:[],metadata:{}}},notes:m}}var X=16e3,G="Install the conform.tools panel (host_setup host=premiere action=install_panel), then in Premiere open Window > UXP Plugins > conform.tools. It connects by itself from then on.";var U=class extends ${constructor(t=j,s=X){super({host:"premiere",label:"Premiere Pro",setup:G},t,s);this.items=async(t={})=>{await this.needs("edit");let{seq:s}=await this.sequence(t.timeline),n=await this.ask("edit.items",{timeline:s,kind:t.kind,track:t.track},12e4),o=n.project_path?await K(n.project_path,n.timeline).catch(d=>({error:d instanceof Error?d.message:String(d)})):{error:"the project has never been saved"},l=0;if(!("error"in o))for(let d of n.items){let m=o.get(`${d.kind}:${d.track}:${d.start}:${Number(d.end)-Number(d.start)}`);m?Object.assign(d,m,{saved:!0}):(d.saved=!1,l++)}return{...n,color_groups:[],layers:1,..."error"in o?{saved_note:`saved project not read: ${o.error}`}:{unsaved_items:l}}};this.premiereRenders=new Map}async current(){let t=await this.ask("session.describe");return{project:t.project,timelines:t.timelines,timeline:t.current}}async liveMarkers(t){if(!$.announced(await this.peer(),"edit.markers"))return null;let{seq:s}=await this.sequence(t);return await this.ask("edit.markers",{timeline:s},12e4)}async model(t){return await super.model(t)}async projectClips(){return await this.needs("edit"),await this.ask("edit.project_clips",{},12e4)}async relinkClips(t){return await this.needs("edit"),await this.ask("edit.relink_clips",{items:t},6e4+t.length*2e3)}async cutIn(t,s){await this.needs("edit");let{seq:n}=await this.sequence(t);return await this.ask("edit.cut_in",{timeline:n,cuts:s},12e4+s.length*3e3)}async renderStart(t){if(t.range)throw new h("unsupported","premiere: a frame range is not supported yet; set in/out on the sequence in Premiere");if(!t.preset||!/\.epr$/i.test(t.preset))throw new h("usage","premiere: preset must be the path of a Media Encoder preset (.epr)");let{seq:s,name:n}=await this.sequence(t.timeline);await M(t.target_dir);let o=_(t.target_dir,`${t.name??n}.mov`),l=await this.ask("render.export_sequence",{timeline:s,output_path:o,preset_path:t.preset,queue:!1},6e4);if(!l.ok)throw new h("render_refused","premiere: Premiere refused the export");let d=l.job||`ppro-${Date.now()}`;return this.premiereRenders.set(d,o),{job_id:d,state:"rendering",percent:0}}async renderStatus(t){let s=await this.ask("render.progress"),n=s[t]??s.last,o=this.premiereRenders.get(t);return n?.event==="error"||n?.event==="onEncodeError"?{job_id:t,state:"failed",percent:0,error:String(n.data??"encode error")}:n?.event==="complete"||n?.event==="onEncodeComplete"||o&&await x(o)&&!n?{job_id:t,state:"complete",percent:100,...o?{outputs:[o]}:{}}:{job_id:t,state:"rendering",percent:typeof n?.data=="number"?Math.round(Number(n.data)*100):0}}async renderCancel(t){return{job_id:t,state:"cancelled",percent:0,error:"Premiere's export cannot be cancelled from here; cancel it in Premiere / Media Encoder"}}};async function K(p,e){let{session:t}=await D(p,"prproj"),s=t.timelines.find(o=>o.name===e),n=new Map;if(!s)throw new Error(`the saved project has no sequence "${e}" (saved before it was made?)`);for(let o of s.tracks)if(!(o.kind!=="Video"&&o.kind!=="Audio"))for(let l of o.items){if(l.kind==="gap"||l.kind==="transition")continue;let d=l;n.set(`${o.kind==="Video"?"video":"audio"}:${o.track_index}:${l.timeline_range.start.value}:${l.timeline_range.duration.value}`,{saved_id:l.id,...d.speed_factor!=null&&d.speed_factor!==1?{retime:d.speed_factor}:{},...d.speed_ramped?{ramped:!0}:{},...d.speed_reverse?{reversed:!0}:{},...l.kind==="nested"?{nested:!0}:{},...d.is_multicam?{multicam:!0}:{},...d.effects?.some(m=>/stabiliz/i.test(m.kind??""))?{stabilized:!0}:{},...d.effects?.length?{saved_effects:d.effects.map(m=>m.name??m.kind??"")}:{}})}return n}function z(p=y()){return p==="darwin"?"/Library/Application Support/Adobe/Adobe Desktop Common/RemoteComponents/UPI/UnifiedPluginInstallerAgent/UnifiedPluginInstallerAgent.app/Contents/MacOS/UnifiedPluginInstallerAgent":p==="win32"?"C:\\Program Files\\Common Files\\Adobe\\Adobe Desktop Common\\RemoteComponents\\UPI\\UnifiedPluginInstallerAgent\\UnifiedPluginInstallerAgent.exe":null}async function B(){for(let p of["./uxp-plugin/","./premiere-uxp/"]){let e=S(new URL(p,import.meta.url));if(await P(_(e,"manifest.json")))return e}throw new Error("premiere: the conform.tools panel is missing from this install")}async function Q(){return JSON.parse(await H(_(await B(),"manifest.json"))).version}async function oe(p=y()){let e=z(p);if(!e||!await x(e))return{installed:!1,listing:"Creative Cloud's plugin installer is not on this machine"};let t=await w(e,p==="win32"?["/list","all"]:["--list","all"],{timeoutMs:6e4}),s=t.stdout.split(`
4
+ `).find(n=>/CONFORM\.TOOLS|conformtools/i.test(n));return{installed:!!s&&/enabled|installed/i.test(s),version:s?.match(/(\d+\.\d+\.\d+)\s*$/)?.[1],listing:t.stdout.trim()}}async function ae(p=y()){let e=z(p);if(!e||!await x(e))throw new Error("premiere: Creative Cloud's plugin installer (UnifiedPluginInstallerAgent) is not on this machine; install Creative Cloud");let t=await B(),s=await Q(),n=await q("conform-ccx-");for(let a of["manifest.json","index.html","index.js","lib","icons"])await T(_(t,a),_(n,a));let o=_(O(),"premiere");await M(o);let l=I(_(o,`conformtools-premiere-${s}.ccx`));await R(l);let d=p==="darwin"?await w("sh",["-c",`cd '${n.replace(/'/g,"'\\''")}' && zip -r -q -X '${l.replace(/'/g,"'\\''")}' manifest.json index.html index.js lib icons`]):await w("powershell",["-NoProfile","-Command",`Compress-Archive -Path '${n}\\*' -DestinationPath '${l.replace(/\.ccx$/,".zip")}' -Force; Move-Item -Force '${l.replace(/\.ccx$/,".zip")}' '${l}'`]);if(await R(n),!d.success)throw new Error(`premiere: could not package the panel: ${d.stderr.trim()}`);await w(e,p==="win32"?["/remove","conform.tools"]:["--remove","conform.tools"],{timeoutMs:12e4});let m=await w(e,p==="win32"?["/install",l]:["--install",l],{timeoutMs:18e4}),c=`${m.stdout}
5
5
  ${m.stderr}`.trim();if(!m.success||!/Installation Successful/i.test(c))throw new Error(`premiere: Adobe's installer refused the panel: ${c.split(`
6
6
  `).pop()}`);return{version:s,ccx:l,output:c}}export{$ as a,U as b,K as c,Q as d,oe as e,ae as f};
@@ -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 ee}from"./chunk-NN444GPH.js";import{a as d}from"./chunk-ROGMKTND.js";import{A as I,B as M,C as q,D as x,E as V,M as X,P as Z,T as W,U as Q,b as c,ba as s,g,h as Y,n as p,o as _,u as H,y as f}from"./chunk-GTPTZRO6.js";var te=["align","reconform","conform-reference"],_e={transferGB:2e3},l={payg:{id:"payg",name:"Pay As You Go",includes:{web:!0,mcp:!1,app:!1,studio_tools:!1}},web:{id:"web",name:"Indie",unlisted:!0,includes:{web:!0,mcp:!1,app:!1,studio_tools:!1},allowance:{transferGB:50}},indie:{id:"indie",name:"Pro",popular:!0,includes:{web:!0,mcp:!0,app:!0,studio_tools:!1},allowance:{transferGB:250}},pro:{id:"pro",name:"Studio",includes:{web:!0,mcp:!0,app:!0,studio_tools:!0},allowance:{transferGB:1e3}},studio:{id:"studio",name:"Enterprise",includes:{web:!0,mcp:!0,app:!0,studio_tools:!0},allowance:_e}},ne={web:!0,mcp:!0,app:!0,studio_tools:!0};import{createPrivateKey as Ge,createPublicKey as he,sign as Fe,verify as we}from"node:crypto";import{Buffer as h}from"node:buffer";var ye="CONFORMTOOLS_LICENSE_V1",ae=/^[0-9A-F]{8}(-[0-9A-F]{8}){3}$/,ie=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 re(e){let t=e.split(/\r?\n/).map(a=>a.trim()).filter(a=>a&&!a.startsWith("#")&&!a.startsWith("-----")).join(""),n=JSON.parse(h.from(t,"base64").toString("utf8"));if(n?.magic!==ye||!n.payload?.data)throw new Error("not a conform.tools licence");return n.payload}function oe(e,t){let n=h.from(e.signature,"base64"),a=h.from(ie(e.data));return n.length!==64?!1:t.some(i=>we(null,a,he({key:h.concat([h.from("302a300506032b6570032100","hex"),h.from(i)]),format:"der",type:"spki"}),n))}var be=["cMwVBrEYKMzlG6pC7FF2lNKIoEqGz2xB5yph6clNnTg=","qnheqkkDU09l1oI6h2CFh4uQ97bY/hkTA5niGKH0+X8="],ve=be.map(e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0)));function E(){let e=c("CONFORM_RECORDS_DIR");if(e)return e;let t=_(),n=g()==="darwin"?s(t,"Library/Application Support"):g()==="win32"?c("LOCALAPPDATA")??s(t,"AppData/Local"):c("XDG_DATA_HOME")??s(t,".local/share");return s(n,"conform.tools")}var xe=()=>c("CONFORM_LICENSE_PATH")??s(E(),"license.lic"),N=()=>s(E(),"grant.lic"),Se=null;function $(){return Se??=(async()=>{let e=await ee();if(!e)return[];let t=await Z(e,["machine"],{timeoutMs:15e3}).catch(()=>null);try{return JSON.parse(t?.stdout??"").machines.filter(n=>ae.test(n))}catch{return[]}})()}function ke(e,t,n=Date.now()){if(!oe(e,ve))return{ok:!1,reason:"invalid licence signature"};let a=Date.parse(e.data.expires_at);return!Number.isFinite(a)||a<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 se(){let e;try{e=await f(xe())}catch{return null}try{return ke(re(e),await $())}catch(t){return{ok:!1,reason:t.message}}}var Oe={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 r(){let e=c("CONFORM_ENV")==="staging"?"staging":"production",t=Oe[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 Ae=600*1e3,ce=72*3600*1e3,Pe=300*1e3,y=()=>s(p(),r().env==="production"?"auth.json":`auth-${r().env}.json`);async function O(){for(let e of new Set([y(),s(p(),"auth.json")]))try{let t=JSON.parse(await f(e));if(t.env===r().env&&t.access_token)return t}catch{}return await Ie()}var Le=()=>{let e=g()==="win32"?c("APPDATA")??s(_(),"AppData","Roaming"):g()==="darwin"?s(_(),"Library","Application Support"):c("XDG_CONFIG_HOME")??s(_(),".config");return s(e,"conform-tools","kv-store.json")};async function Ie(){let e=Le();try{let t=JSON.parse(await f(e)),n=JSON.parse(t["ct-supabase-auth"]??"null");if(!n?.access_token||!n.refresh_token)return null;let a=n.access_token.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");if(JSON.parse(atob(a+"=".repeat(-a.length&3))).iss!==`${r().supabaseUrl}/auth/v1`)return null;let o={env:r().env,access_token:n.access_token,refresh_token:n.refresh_token,expires_at:n.expires_at??0};return await D(o),delete t["ct-supabase-auth"],await I(e,JSON.stringify(t)),o}catch{return null}}async function Ee(){try{for await(let e of X(p())){if(!/^auth(?:-(\w+))?\.json$/.exec(e.name))continue;let n=JSON.parse(await f(s(p(),e.name)));if(n.access_token&&n.env&&n.env!==r().env)return{other_env:n.env}}}catch{}return{}}async function D(e){await M(p()),await I(y(),JSON.stringify(e)),await V(y(),384)}var B=6e3,A=0,R=()=>Date.now()<A,ue=()=>{A=Date.now()+6e4};function et(){A=0}var pe=e=>e.expires_at-60>Date.now()/1e3;async function j(e){let t=await O();return t&&t.refresh_token!==e.refresh_token&&Object.assign(e,t),pe(e)}async function G(e){if(pe(e))return e.access_token;if(R())return null;if(await j(e))return e.access_token;let t=await q(`${y()}.lock`);try{if(await j(e))return e.access_token;let n=r(),a=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(B)}).catch(o=>{throw ue(),o});if(!a.ok)return a.status!==400&&a.status!==401?null:await j(e)?e.access_token:"";let i=await a.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 D(e),e.access_token}catch{return null}finally{await t()}}async function tt(){let e=await O();return e&&await G(e)||null}var w=null;function le(e,t){return{signed_in:!0,entitled:e.entitled,env:r().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 fe(e={}){let t=await se();if(t?.ok)return{signed_in:!!await O().catch(()=>null),entitled:!0,env:r().env,email:t.data.email,access:"licence",tier:t.data.tier,source:"licence"};let n=await Ne(e);return t&&!n.entitled?{...n,licence_error:t.reason}:n}async function Ne(e){if(!e.force&&w&&Date.now()-w.at<Ae)return{...w.status,source:"cache"};let t=r(),n=await O();if(!n)return{signed_in:!1,entitled:!1,env:t.env,reason:"not_signed_in",...await Ee()};let a=await G(n);if(a==="")return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(a&&!R())try{let i=(await $())[0],o=await fetch(`${t.supabaseUrl}/functions/v1/v1-billing/v1/billing/entitlement${i?`?machine=${i}`:""}`,{headers:{authorization:`Bearer ${a}`,apikey:t.anonKey},signal:AbortSignal.timeout(B)}).catch(u=>{throw ue(),u});if(o.status===401||o.status===403)return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(o.ok){let{grant:u,...P}=(await o.json()).data;i&&await $e(u),n.last_entitlement=P,n.last_entitlement_at=Date.now(),await D(n);let L=le(P,"live");return w={at:Date.now(),status:L},L}}catch{}if(n.last_entitlement&&n.last_entitlement_at&&Date.now()-n.last_entitlement_at<ce){let i=ce-(Date.now()-n.last_entitlement_at);return{...le(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 $e(e){try{if(!e)return await x(N());await M(E()),await I(N(),e)}catch{}}function De(e){return e.source==="licence"?`${e.email} \xB7 machine licence (${e.tier}) \u2014 runs offline, no account check`:Te(e)+(e.licence_error?`
4
+ (the machine licence was not used: ${e.licence_error})`:"")}function Te(e){let t=r();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 MCP is in the ${l.indie.name} plan and up. 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 a=e.access==="trial"?`trial, ${e.trial_days_remaining??"?"} day(s) left`:e.access==="allowlist"?"invited (early access)":`subscribed${e.tier?` (${F(e.tier)})`:""}`,i=T(e),o=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
+ ${a}${o}${e.source==="grace"?` \u2014 offline, using the last check (${e.grace_remaining_h} h of grace left)`:""}`}function F(e){return l[e.toLowerCase()]?.name??e}function T(e){if(e.access==="trial")return ne;let t=(e.tier??"").toLowerCase();return(t==="enterprise"?l.studio:l[t])?.includes??null}var de=()=>fe();function nt(e){de=e}async function me(){let e=await de();if(e.entitled)return e;let t=e.signed_in&&e.reason==="not_entitled"?"not_entitled":"not_signed_in";throw new d(t,De(e),{account:e})}async function at(){let e=await me();if(e.source==="licence"||T(e)?.mcp!==!1)return e;throw new d("not_entitled",`The conform.tools MCP is in the ${l.indie.name} plan and up. ${e.access==="trial"?"Your trial":`Your plan${e.tier?` (${F(e.tier)})`:""}`} includes Timeline Exchange and Conform Connect on ${r().appBase}, but not the engine on this machine. Upgrade at ${r().appBase}/pricing, then run account_status.`,{account:e,needs:"mcp"})}async function Ce(){let e=await me();if(e.source==="licence")return e;if(!T(e)?.app)throw new d("not_entitled",`The conform.tools app is in the ${l.indie.name} plan and up. ${e.access==="trial"?"Your trial":`Your plan${e.tier?` (${F(e.tier)})`:""}`} does not include the app. Upgrade at ${r().appBase}/pricing, then reopen the app.`,{account:e,needs:"app"});let t=await Me();if(t)throw new d("seat_in_use",`This seat is in use on ${t}. Each seat runs the app on one computer at a time: quit the app there (or sign out), or wait 15 minutes after it last ran, then reopen it here.`,{account:e,needs:"seat",in_use_by:t});return e}async function it(e){if(!te.includes(e))return;let t=await Ce();if(!(t.source==="licence"||T(t)?.studio_tools!==!1))throw new d("not_entitled",`This tool is in the ${l.pro.name} plan. Upgrade at ${r().appBase}/pricing.`,{account:t,needs:"studio_tools"})}var Ue=240*1e3,k=null;async function Me(){if(k&&Date.now()-k.at<Ue)return k.busy;let e=await ge("POST").catch(()=>null);return k={at:Date.now(),busy:e},e}async function ge(e){let t=r(),n=await O(),a=(await $())[0],i=n&&await G(n);if(!i||!a||R())return null;let o=await fetch(`${t.supabaseUrl}/functions/v1/v1-billing/v1/billing/seat`,{method:e,headers:{authorization:`Bearer ${i}`,apikey:t.anonKey,"content-type":"application/json"},body:JSON.stringify({machine:a,name:Y()}),signal:AbortSignal.timeout(B)});return o.status===409?(await o.json()).in_use_by??"another computer":null}var S=null;function rt(e={}){if(S)return S;let t=r(),n=crypto.randomUUID().replaceAll("-","");return S=new Promise((a,i)=>{let o=!1,u=b=>{o||(o=!0,clearTimeout(L),setTimeout(()=>P.close(),250),S=null,b())},P=Q({hostname:"127.0.0.1",port:0,onListen:async b=>{let v=`${t.appBase}/plugin-auth?client=engine&port=${b}&state=${n}`,m=await W(v);e.onUrl?.(v,m)}},async b=>{let v=new URL(b.url);if(v.pathname!=="/callback")return new Response("not found",{status:404});let m=v.searchParams,J=m.get("access_token")??"",K=m.get("refresh_token")??"",C=!!J&&!!K&&m.get("state")===n;if(C){let z=Number(m.get("expires_at"));await D({env:t.env,access_token:J,refresh_token:K,expires_at:z>0?z:Math.floor(Date.now()/1e3)+3600}),w=null,A=0,fe({force:!0}).then(U=>u(()=>a(U)),U=>u(()=>i(U)))}return new Response(je(C),{status:C?200:400,headers:{"content-type":"text/html; charset=utf-8"}})}),L=setTimeout(()=>u(()=>i(new d("not_signed_in","sign-in was not completed within 5 minutes"))),e.timeoutMs??Pe)}),S}async function ot(){await ge("DELETE").catch(()=>{}),k=null,w=null,A=0,await H(y())&&await x(y()),await x(N()).catch(()=>{});let e=s(p(),"auth.json");try{JSON.parse(await f(e)).env===r().env&&await x(e)}catch{}}function je(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{r as a,Le as b,B as c,et as d,tt as e,fe as f,De as g,T as h,nt as i,me as j,at as k,Ce as l,it as m,rt as n,ot as o};
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{c as u,d as y,f as w,g as h}from"./chunk-LVGGCRDW.js";import{a as f,e as p}from"./chunk-OWWXUNJF.js";import{a}from"./chunk-ROGMKTND.js";import{b as g}from"./chunk-X527E5VI.js";u(!0);var b={aaf:"aaf",avb:"avb",prproj:"prproj",drt:"resolve-drt",otio:"otio",capcut:"capcut",flame:"flame-archive",fcpxml:"resolve-fcpxml",xmeml:"fcp-xml",blscene:"baselight-blscene"},R=Object.keys(b),v=new Set([502,503,504,529,546]),d=(e,o)=>`${f().supabaseUrl}/functions/v1/${e}${o}`;async function m(){let e=await p();if(!e&&g("CONFORM_ANONYMOUS_READ")==="1")return f().anonKey;if(!e)throw new a("not_signed_in","reading and writing timelines runs on conform.tools \u2014 sign in first (account_login)");return e}async function S(e,o){let t;for(let n=0;n<3;n++){try{let i=await fetch(e,o);if(!v.has(i.status)||n===2)return i;t=new Error(`status ${i.status}`)}catch(i){if(t=i,n===2)break}await new Promise(i=>setTimeout(i,1500*(n+1)))}throw new a("offline",`conform.tools is unreachable (${t instanceof Error?t.message:String(t)}) \u2014 reading and writing timelines need the network`)}async function _(e,o){let n=(await e.json().catch(()=>({})))?.error?.message??`${o} failed (${e.status})`;throw e.status===401?new a("not_signed_in",`${n} \u2014 sign in again (account_login)`):e.status===402||e.status===403?new a("not_entitled",n):new a(e.status>=500?"engine":"refused",n)}async function P(e,o){let t=b[e];if(!t)throw new a("unsupported",`'${e}' timelines are not read by conform.tools yet`);let{fmt:n,extract:i}=await y(o,t),c=JSON.stringify({format:n,source_filename:o.name,persist:!1})+`
3
+ import{c as u,d as y,f as w,g as h}from"./chunk-LVGGCRDW.js";import{a as f,e as p}from"./chunk-JTRM2JCE.js";import{a}from"./chunk-ROGMKTND.js";import{b as g}from"./chunk-GTPTZRO6.js";u(!0);var b={aaf:"aaf",avb:"avb",prproj:"prproj",drt:"resolve-drt",otio:"otio",capcut:"capcut",flame:"flame-archive",fcpxml:"resolve-fcpxml",xmeml:"fcp-xml",blscene:"baselight-blscene"},R=Object.keys(b),v=new Set([502,503,504,529,546]),d=(e,o)=>`${f().supabaseUrl}/functions/v1/${e}${o}`;async function m(){let e=await p();if(!e&&g("CONFORM_ANONYMOUS_READ")==="1")return f().anonKey;if(!e)throw new a("not_signed_in","reading and writing timelines runs on conform.tools \u2014 sign in first (account_login)");return e}async function S(e,o){let t;for(let n=0;n<3;n++){try{let i=await fetch(e,o);if(!v.has(i.status)||n===2)return i;t=new Error(`status ${i.status}`)}catch(i){if(t=i,n===2)break}await new Promise(i=>setTimeout(i,1500*(n+1)))}throw new a("offline",`conform.tools is unreachable (${t instanceof Error?t.message:String(t)}) \u2014 reading and writing timelines need the network`)}async function _(e,o){let n=(await e.json().catch(()=>({})))?.error?.message??`${o} failed (${e.status})`;throw e.status===401?new a("not_signed_in",`${n} \u2014 sign in again (account_login)`):e.status===402||e.status===403?new a("not_entitled",n):new a(e.status>=500?"engine":"refused",n)}async function P(e,o){let t=b[e];if(!t)throw new a("unsupported",`'${e}' timelines are not read by conform.tools yet`);let{fmt:n,extract:i}=await y(o,t),c=JSON.stringify({format:n,source_filename:o.name,persist:!1})+`
4
4
  `+(typeof i=="string"?i:JSON.stringify(i)),s=await S(d("v1-timeline-canonicalize","/v1/timeline-canonicalize"),{method:"POST",headers:{"content-type":"application/x-ct-canonicalize-v1",authorization:`Bearer ${await m()}`,apikey:f().anonKey},body:c});s.ok||await _(s,"read");let l=await s.json();return JSON.stringify(l.session)}async function N(e,o){let t=await S(d("v1-write","/v1/write"),{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${await m()}`,apikey:f().anonKey,"x-engine-accept-delivery":"cdn"},body:JSON.stringify({target_format:e,session:o})});t.ok||await _(t,"write");let n=h(t.headers.get(w))??[];if(t.headers.get("x-engine-delivery")==="cdn"){let r=await t.json(),c=await fetch(r.download_url);if(!c.ok)throw new a("engine",`download failed (${c.status})`);let s=new Uint8Array(await c.arrayBuffer());if(s.byteLength!==r.size)throw new a("engine",`download incomplete: ${s.byteLength} of ${r.size} bytes`);return{body:s,contentType:r.content_type,filenameSuggestion:r.filename,issues:n,serverSession:r.session_id??void 0}}let i=t.headers.get("content-disposition")?.match(/filename="([^"]+)"/)?.[1];return{body:new Uint8Array(await t.arrayBuffer()),contentType:t.headers.get("content-type")??"application/octet-stream",filenameSuggestion:i??`timeline.${e}`,issues:n,serverSession:t.headers.get("x-session-id")??void 0}}async function j(e,o,t){try{let n={"content-type":"application/json",authorization:`Bearer ${await m()}`,apikey:f().anonKey},i=k=>d("v1-sessions",`/v1/sessions/${encodeURIComponent(e)}/original${k}`),r=await fetch(i(""),{method:"POST",headers:n,body:JSON.stringify({filename:o,content_type:"application/octet-stream"})});if(!r.ok)return!1;let{key:c,upload:s}=await r.json();return(await fetch(s.url,{method:s.method??"PUT",headers:s.headers??{"content-type":"application/octet-stream"},body:t})).ok?(await fetch(i("/complete"),{method:"POST",headers:n,body:JSON.stringify({key:c})})).ok:!1}catch{return!1}}export{R as a,P as b,N as c,j as d};
@@ -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{Da as d,Ia as l}from"./chunk-DPA26AOI.js";var u=[{codec:"prores",label:"Apple ProRes",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"preview tier is DC-only 1/8 COLOR (2026-08-05 \u2014 was gray luma; Y+Cb+Cr DC walks, no AC/IDCT) \u2014 the realtime tier for BOTH playback and scrub: full 4K XQ decode is ~170ms/frame + a 35MB RGBA hand-off, which can hold neither 24fps nor a smooth scrub; the parked frame upgrades to full via the standard 160ms park timer (scrubPreview flipped true 2026-08-05 with the color preview \u2014 the old 'full decode is scrub-fast' held for 2K 422, not 4K XQ). Both wrappers: .mov (sample table) and MXF OP1a (RDD 44, 2026-07-28 \u2014 is_prores_mxf routes the identical icpf bitstream through the walker via decode_prores_mxf; Suite ap4h fixture gated byte-exact vs ffmpeg 10-bit, rust tests/prores_mxf_gate.rs)"},{codec:"prores_raw",label:"Apple ProRes RAW",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"preview tier is a TRUE DC-only Bayer decode: the DC-DPCM segment is a strict prefix of each tile component's bitstream, so the preview reads just those prefixes (no AC walk, no IDCT), lands the exact closed-form value the full IDCT produces, and runs the SAME develop on the 1/8 grid (tier_parity gate). Decode = Apple's own reconstruction (RE'd from AppleProResRAWCodec.bundle 2026-10-22): bit-exact vs VideoToolbox's software decode on iPhone 17 Pro / Sony a7S III / Panasonic; the ffmpeg 8.0 byte-exact path remains as decode_bayer. Develop = the ProRes RAW SDK as DaVinci Resolve runs it (kernels transcribed from its Metal AIR, parameters RE'd from Resolve and captured live): noise-gated edge-directed demosaic, mired-interpolated per-CCT WB + forward matrix from the moov (iPhone; header color otherwise), Apple Log / Apple Wide Gamut output matching a Resolve 21 render to f32 rounding (97.9% of 10-bit codes identical end to end; the rest is Resolve's hardware-decode LSB noise). Viewer tiers render ACEScct log (2026-07-26 \u2014 no baked Rec.709/sRGB; the transcode-grade log form); decode_prores_raw_tier takes the clip's container color."},{codec:"h264",label:"H.264 / AVC",full:!0,preview:!0,luma:!1,scrubPreview:!0,backend:"webcodecs",notes:"scrub = nearest-keyframe snap (1 decode); exact frame on park; FALLBACK (2026-10-27): where WebCodecs is absent or refuses the config (Firefox + HEVC, Chrome without HEVC hardware, most 4:2:2 10-bit), and for containers the TS players cannot walk (MKV/WebM, raw Annex-B, fragmented MP4), the identify chain labels the clip 'h264_wasm' and media-core's own decoder answers through the mcvideo lane (wasm video_open/video_decode \u2014 rust video::lane, gated byte-exact vs ffmpeg in tests/h264_mov_gate.rs / hevc_gate.rs / annexb_gate.rs); WebCodecs stays first"},{codec:"hevc",label:"HEVC / H.265",full:!0,preview:!0,luma:!1,scrubPreview:!0,backend:"webcodecs",notes:"scrub = nearest-keyframe snap (1 decode); exact frame on park; FALLBACK (2026-10-27): where WebCodecs is absent or refuses the config (Firefox + HEVC, Chrome without HEVC hardware, most 4:2:2 10-bit), and for containers the TS players cannot walk (MKV/WebM, raw Annex-B, fragmented MP4), the identify chain labels the clip 'hevc_wasm' and media-core's own decoder answers through the mcvideo lane (wasm video_open/video_decode \u2014 rust video::lane, gated byte-exact vs ffmpeg in tests/h264_mov_gate.rs / hevc_gate.rs / annexb_gate.rs); WebCodecs stays first"},{codec:"xavc",label:"Sony XAVC-Intra",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"webcodecs",notes:"all-intra; already scrub-fast"},{codec:"h264_mxf",label:"H.264 long-GOP (MXF)",full:!0,preview:!0,luma:!1,scrubPreview:!0,backend:"webcodecs",notes:"Camera proxies (Sony CTAPA and kin): H.264 High long-GOP in MXF OP1a. SEPARATE from 'xavc' because XAVC-Intra is all-intra and this is not \u2014 measured on a 1224-frame CTAPA proxy: IBBP, I every 12, but a true RAP (index flag 0x80) only every 48; the intervening I-frames are open-GOP (flag 0x40) and are NOT legal entry points. Decoded by LongGopPlayer: walk the GOP from its RAP, first AU 'key' and the rest 'delta', outputs taken in EMISSION order (WebCodecs owns the B-frame reorder, so the index's temporal_offset is never interpreted). Whole GOP is cached, so any scrub inside those 2s is free. Until 2026-08-10 these files were misidentified as xavc and decoded one isolated AU at a time (submit + flush), so every P/B frame hit a decoder with no reference state, only the leading IDR ever decoded, and the viewer showed frame 0 forever. Gated by oracle/i2o/e2e/mxf-longgop-playback.spec.ts against ffmpeg"},{codec:"r3d",label:"RED R3D",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"Full + preview render NATIVE RWG/Log3G10 (2026-07-26 \u2014 IPP2 output LUT removed from decoders; display transforms are downstream)"},{codec:"arriraw",label:"ARRIRAW",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"EVERY STAGE BYTE-EXACT vs the ARRI SDK (2026-07-27): prep, the ADA-7 demosaic (0 of 15,690,240), the LuMaTaLu color kernel (0 of 31,457,280 \u2014 closed by transcribing the SDK's own f32 op order: the LUT index is fmul-then-fadd not a fused mul_add, the B-spline weights are evaluated expanded with the sixth applied last, and the bicubic accumulates columns before rows), the 1:1 resample (identity) and AfaScaler+BufferScaler (0 of 43,739,136). The shipped master still omits AfaScaler's Rec.709 YCbCr detail and its Jenkins-hash grain \u2014 added looks, not native signal \u2014 so the end-to-end floor gate vs the SDK's DEFAULT output reads 0.16/255; color is no part of that number. exact AWG4/LogC4 develop (2026-07-21, vs ARRI SDK); preview is color via the same per-clip develop plan (tier gate corr \u22650.997). Pre-A35 12-bit ALEV-III (Mini/Mini LF) fully wired 2026-07-26: Gen2 develop to native AWG3/LogC3, SDK-gated MAE<0.8/255, probe inner_codec 'arriraw-alev3' \u2192 decode_arriraw12_mxf; other ALEV3 bodies decode flagged calib:parametric-alev3-family-unvalidated"},{codec:"dnxhr",label:"Avid DNxHR / DNxHD",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"DC-only 1/8 preview tier is COLOR (2026-08-05 \u2014 was gray luma) \u2014 playback + scrub ride it (4K/UHD DNxHR full decodes aren't scrub-fast); park upgrades to full"},{codec:"crm",label:"Canon Cinema RAW Light",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"preview LL tier develops through the SAME tone-exact Canon Log 2 path as Full (2026-07-26 \u2014 replaced the placeholder tone map that drifted -46/255)"},{codec:"braw",label:"Blackmagic RAW",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"per-clip WB develop (bmdf wkel/wtin \u2192 wb_grid tables; Pocket-6K-family sweep-validated); preview is COLOUR-accurate native Gen5 log (gate corr \u22650.996 vs downsampled full). PER-FRAME HEADER LAW (2026-10-27, rust braw::frame_law): family, dequant tables, grain quantisers and edge-strength width are computed from each frame's own header exactly as BlackmagicRawAPI does \u2014 transcribed from the 5.1 binary (dequant builder 0xb98d4: luma M*(qi+4)/32, chroma M*max((qi+5)>>1,4)/32, transposed, DC capped by hdr +0x20/+0x22; M = the frame's in-header matrix (Pocket 6K v2 headers) or a built-in bank entry picked by +0x24; grain setup 0x50358: lo = trunc(hdr+0x1c*40/119), hi = 2*lo, chroma = trunc(hdr+0x1e*80/119); driver select 0x50490 from version/type/strength width). It reproduces all six previously captured quantiser pairs and both Pocket 6K grain captures bit for bit. The ladder only sets the deblock ramp, and ladder AND quant index change frame to frame inside a clip (SAN census: 10,959 frames, 8 ladders, qi 0..53 on one Pocket 6K), so the old ladder-keyed registry (now a witness list, braw::PROFILES) was refusing most Pocket 6K frames and mis-decoding others. A frame is refused with calib:unsupported-entropy-profile only when its header resolves to a decoder driver not yet transcribed. Byte-exact frame gates: (0,0,0,1) C013/C060 8\xD78 byte-exact; and the 12\xD712 family (SHIPPED 2026-07-26) \u2014 (1,2,3,4) URSA 12K, plus BOTH PYXIS encodes (0,1,2,4) and (0,0,1,2), which are the same camera at the same raster with quantisers half a step apart. That family is 12\xD712 luma / 12\xD76 chroma, 2 luma + Cb + Cr per unit off one threaded bit-reader; all four walks (full, multithreaded, DC preview, color preview) are parametric over it. GRAIN + EDGE FILTER MODELLED 2026-07-26 \u2014 the decode is now essentially the SDK's literal output: the synthesized high-frequency PRNG grain is reproduced (scatter map verified 0 mismatches over 76,896 observations across two clips), its per-frame seed turns out to be carried IN the bitstream (16 BE bytes before the first tile) and re-seeded per tile as s1 ^= broadcast16(region<<5|vtile), and the post-IDCT block-edge filter (A*b + B*(a+c) >> 4) is applied. The filter's per-block STRENGTH byte is solved too (2026-07-26): it is transmitted, not derived - each unit ends with a [ctx+0x68]-bit field on its own reader (the skip the walk used to call 'hf_bias' and discard), packing four 2-bit weight selectors per block (bits 7:6/5:4 = the horizontal cut's two 6-px column spans, 3:2/1:0 = the vertical cut's two 6-px row spans); and the four weights are master[ladder[k]] with master[i] = (16-2i, i), so the header ladder IS the deblock strength ramp and no future profile needs a capture for it. BRAW IS BYTE-EXACT (2026-07-26). Frame-gated vs the SDK's own decoded.bin, through BOTH the oracle bitstream and the real .braw container path: all four captures \u2014 C060 (8x8), URSA 12K, and both PYXIS encodes \u2014 now differ from the SDK in ZERO samples, luma and chroma alike, across 208,099,712 luma samples; the gates assert max == 0 rather than a mean bound, because a tolerance cannot tell 'clean' from 'one wrong block in 400,000'. The last drift (11,248 URSA pixels off by one, ~0.014%) was never a modelling gap: the SDK computes an Arai-Agui-Nakajima SCALED DCT \u2014 coefficients premultiplied by s[u]*s[v] = c(k)/(2*cos(k*pi/2N)), then a unit-scale radix-3 x radix-4 butterfly \u2014 so a dense basis multiply is the same function through a DIFFERENT operation graph and rounds differently in f32, which is why f32, f32+FMA and f64 all missed. Both transforms (luma 12x12 @0x6e9c8, chroma 12x6 @0x6fc68) are now the SDK's literal dataflow, machine-transcribed by oracle/media/braw/t12_transcribe.py \u2014 a symbolic byte-slot emulator of the unrolled NEON \u2014 into the generated rust/media-core/src/codecs/braw_t12_idct.rs. The 8x8 family gains the same seed fix (whole-frame grain, no captured constant) AND the same edge filter: it was never a different algorithm, only a different compiled copy (@0x6b6a4) whose ladder (0,0,0,1) resolves to three identities plus one weak tap - C060 Y 1.76 -> 0.003. Also solved by censusing where the residual sat: the SDK runs horizontal before vertical; a vertical cut is governed by the block to its LEFT; the frame's final vertical cut is not filtered (the SDK handles cuts in pairs and drops the pair whose second cut leaves the frame); and the 8x8 byte is a nibble per block (7:6 h / 5:4 v for block 0, 3:2 h / 1:0 v for block 1). Both PYXIS profiles now carry captured grain quantisers (the PARIS original's were read once its volume was remounted). Also gated: the multithreaded walk is byte-identical to single-threaded, and both preview tiers are exact block means of the full decode (corr 1.0000). Pocket 6K (driver sym1569, single-context scan-wrapping core, inline transforms) byte-exact at qi 7 and qi 27 (C040); the SAN Pocket 6K frames at every other ladder (incl. C030's (0,2,3,4) qi 11) decode through the same driver on law-derived tables \u2014 their SDK frame gates (tests/braw_san_law.rs) pass byte-exact (2026-10-27: all 10 SAN frames \u2014 nine Pocket 6K across eight ladders, qi 4..44, plus C104 f567 \u2014 differ from the 5.1 SDK in zero Y/Cb/Cr samples). URSA 12K 8:1-type header (v5, flags 0x0914: type 3) DECODED BYTE-EXACT (2026-10-27): the SDK decodes it at full resolution through its SCALE-1 driver 0x66fdc (the scale-0 row, 0x65248, only parses), which is sym1575 apart from its tables \u2014 6\xD712 coded blocks become 8\xD78 / 8\xD74 output blocks (12336\xD74032 coded \u2192 8224\xD75376), three sub-streams in a four-slot offset table, early-stopping entropy cores 0x735fc / 0x7392c, type-3 prescale rows into the shared 8\xD78 IDCT, inline chroma butterfly. Gated against the 5.1 SDK on both SAN clips (A003_09021503_C013 f0/f70, A005_09021941_C016 f0/f121): 0 differing Y/Cb/Cr samples; multithreaded walk identical. Two fixes landed with it for every 8\xD78 family: the shared IDCT's pass-1 c0 tap is unfused for coefficient columns 4..7, and the chroma grain pre-load (GRAIN_CHROMA8) + the inline chroma butterfly (Cb copy fused, Cr copy not) replace a never-gated matrix form. SAN census: 10,959 / 10,959 frames now resolve to a transcribed driver. See oracle/media/braw/ENTROPY_PROFILE_RE.md \xA714"},{codec:"xocn",label:"Sony X-OCN",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"Full + preview render NATIVE S-Gamut3/S-Log3 (2026-07-26 \u2014 replaced the adaptive display transform); preview = LL-band-only decode (~1/8 per axis, ~90x faster), colour-consistent with Full by construction. Fitted sensors: Burano LT/8K (SBRg), Venice ST (SBRe), VENICE 2 8.6K (SBRf, 2026-07-26 \u2014 decodes via the same parametric geometry, own C0_VENICE2 matrix R\xB2\u22650.9994). X-OCN IS BYTE-EXACT ACROSS MODES (2026-07-27): LT 6K, Venice ST and Burano 8K all decode to ZERO differing samples vs libSonyRawDev's own decoder output \u2014 86,293,760 samples over the three, gated in tests/xocn_variant_gate.rs against hashes of the SDK's planes. Venice ST and 8K previously lost their top and bottom rows (28 and 12 rows; the interiors were already exact) because the band row ranges were formulas in the LL strip count n, read off the LT capture (y0=10, y1=8n-2 and friends) \u2014 those hold only when 8n == h + 12, which is an LT coincidence. The real rule (xocn::phase_chain): the standalone band carries the frame's h rows CENTRED in its 8n coded rows, and every coarser level is the even subset of the level below, so lo = a[k] and y14 = a[k] + n[k] fall out per level and reproduce LT's captured constants exactly. Settled by MEASURING the bitstream \u2014 strips are byte-aligned, so the row count of a strip is the count whose decode consumes its byte size (harness xocnstrip) \u2014 not by sweeping constants. The write-side dy row shift that used to paper over the phase is gone. SBRf/VENICE 2 decodes through the same path but is not yet re-gated byte-exact (fixture on PARIS)"},{codec:"mpeg2",label:"MPEG-2 / MPEG-1",full:!0,preview:!0,luma:!0,scrubPreview:!1,backend:"wasm",notes:"media-core's own decoder (2026-10-27): XDCAM HD422/EX, HDV, IMX, DVD and broadcast streams in MXF / MOV / PS / TS / ES / AVI through the mcvideo lane (video_open/video_decode, rust video::lane \u2192 video::mpeg2_range): long-GOP from the I frame before the window, display order from the stream's own temporal references; a miss decodes a window of frames and keeps it. decode_mpeg2_{rgba,preview,luma} are the I-frame sample tiers (DC-only 1/8 color preview). Gated sample-identical to ffmpeg (tests/mpeg2_gate.rs)"},{codec:"dv",label:"DV / DVCPRO / DVCPRO HD",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"media-core's own decoder (2026-10-27), all-intra: DV25 / DVCPRO50 / DVCPRO HD in MXF / MOV / AVI / raw .dv through the mcvideo lane; scrub rides the DC-only 1/8 color preview, park upgrades to full. decode_dv_{rgba,preview,luma} are the frame tiers. Gated vs ffmpeg (tests/dv_gate.rs)"},{codec:"qtraw",label:"QuickTime raw / Animation / Motion-JPEG",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"wasm",notes:"media-core's codecs::qtraw through the mcvideo lane (2026-10-27): uncompressed raw/2vuy/v210, Animation (rle \u2014 a delta codec, painted forward from the sync sample before the window), Motion-JPEG (jpeg/mjpa/AVDJ/dmb1 on media-core's JPEG decoder, the JPEG's own raster); clean aperture applied. No browser decodes any of them. Gated vs ffmpeg (media-native mov_simple tests; RGB/Animation lossless-identical)"},{codec:"legacy",label:"Legacy & web video (MPEG-4 Part 2, H.263 / Sorenson, DivX 3, VC-1 / WMV, VP6, Cinepak, SVQ3, AV1)",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"wasm",notes:"media-core's legacy decoders through the mcvideo lane (2026-10-27): MOV / MP4 / 3GP, Matroska / WebM, AVI, ASF / WMV, FLV (H.264 in AVI / ASF / FLV too \u2014 only this reader indexes them). Sample-identical to ffmpeg 7.1.1 on 378 of 379 SAN files (the one is ffmpeg concealing a WMV9 picture it misreads); AV1 34,606 / 34,606 frames. Not covered: interlaced VC-1 / VP6, H.263 PB-frames, MS-MPEG4 v1/v2, WMV1/2, AV1 profiles 1/2 and 12-bit"},{codec:"uncompressed",label:"Uncompressed MXF",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"wasm",notes:"Avid 1:1 / alpha mattes / SMPTE 384 uncompressed pictures through the mcvideo lane (qtraw::decode_mxf_uncompressed by the descriptor's PictureLayout, 2026-10-27). Not yet gated against a browser-side fixture (no ffmpeg recipe writes one)"}],h=new Map(u.map(t=>[t.codec,t]));function a(t){let e=(t??"").toLowerCase().trim();return e?e==="aprn"||e==="aprh"?"prores_raw":e==="prores_mxf"||e.startsWith("ap")?"prores":e==="arriraw-alev3"?"arriraw":e==="avc1"||e==="avc3"||e==="h264"?"h264":e.startsWith("hvc")||e.startsWith("hev")||e==="h265"?"hevc":e.startsWith("avd")||e==="dnxh"||e==="dnxhd"?"dnxhr":e==="redcode"?"r3d":e==="h264_wasm"?"h264":e==="hevc_wasm"?"hevc":h.has(e)?e:null:null}function p(t){let e=(t??"").toLowerCase().trim();if(!e)return null;if(e==="aprn"||e==="aprh"||a(e)==="prores_raw"||e==="ap4h"||e==="ap4x")return 12;if(e.startsWith("ap"))return 10;let r=a(e);return r==="r3d"?16:r==="arriraw"||r==="braw"?12:r==="xocn"?16:r==="crm"?12:/dnxhr.?(hqx|444)/.test(e)?10:null}function b(t,e){if(typeof e!="number")return null;let r=a(t);return r==="h264"?[66,77,88,100].includes(e)?8:e===110?10:null:r==="hevc"?e===1?8:e===2?10:null:null}function w(t){let e=(t??"").toLowerCase().trim();if(!e)return null;if(e==="ap4h"||e==="ap4x")return"4:4:4";let r=a(e);return r==="prores_raw"||r==="r3d"||r==="arriraw"||r==="braw"||r==="xocn"||r==="crm"?"bayer":r==="prores"?"4:2:2":/dnxhr.?444/.test(e)?"4:4:4":/dnxhr.?(hqx|hq|sq|lb)/.test(e)?"4:2:2":null}function v(t){let e=t.toLowerCase().replace(/[^0-9a-z]/g,"");return e==="bayer"||e==="raw"?"bayer":e.length>=3&&/^\d+$/.test(e)?e.split("").join(":"):e}function c(t){let e=a(t);return e==="prores"||e==="h264"||e==="hevc"?e:"other"}var f={prores:"ProRes",h264:"H.264",hevc:"HEVC",r3d:"R3D",arriraw:"ARRIRAW",xocn:"X-OCN",vc3:"DNxHR",braw:"BRAW",proresraw:"ProRes RAW",other:"unsupported"};function x(t){return f[t]??"unsupported"}function m(t){let e=JSON.parse(t),r=e.frames??[],o=r.length>>1,n=new Array(o);for(let s=0,i=0;i<o;s+=2,i++)n[i]={offset:r[s],size:r[s+1]};return{offs:n,codec:e.codec,kind:c(e.codec),w:e.width,h:e.height,fps:e.fps??null,startFrame:e.start_frame??0,dropFrame:e.drop_frame??!1}}async function D(t){await l();let r=await d((o,n)=>t.slice(o,o+n).arrayBuffer().then(s=>new Uint8Array(s)),t.size,"mov");return m(r)}export{a,p as b,b as c,w as d,v as e,x as f,m as g,D as h};
3
+ import{Da as d,Ha as l}from"./chunk-QNF4NMIW.js";var u=[{codec:"prores",label:"Apple ProRes",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"preview tier is DC-only 1/8 COLOR (2026-08-05 \u2014 was gray luma; Y+Cb+Cr DC walks, no AC/IDCT) \u2014 the realtime tier for BOTH playback and scrub: full 4K XQ decode is ~170ms/frame + a 35MB RGBA hand-off, which can hold neither 24fps nor a smooth scrub; the parked frame upgrades to full via the standard 160ms park timer (scrubPreview flipped true 2026-08-05 with the color preview \u2014 the old 'full decode is scrub-fast' held for 2K 422, not 4K XQ). Both wrappers: .mov (sample table) and MXF OP1a (RDD 44, 2026-07-28 \u2014 is_prores_mxf routes the identical icpf bitstream through the walker via decode_prores_mxf; Suite ap4h fixture gated byte-exact vs ffmpeg 10-bit, rust tests/prores_mxf_gate.rs)"},{codec:"prores_raw",label:"Apple ProRes RAW",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"preview tier is a TRUE DC-only Bayer decode: the DC-DPCM segment is a strict prefix of each tile component's bitstream, so the preview reads just those prefixes (no AC walk, no IDCT), lands the exact closed-form value the full IDCT produces, and runs the SAME develop on the 1/8 grid (tier_parity gate). Decode = Apple's own reconstruction (RE'd from AppleProResRAWCodec.bundle 2026-10-22): bit-exact vs VideoToolbox's software decode on iPhone 17 Pro / Sony a7S III / Panasonic; the ffmpeg 8.0 byte-exact path remains as decode_bayer. Develop = the ProRes RAW SDK as DaVinci Resolve runs it (kernels transcribed from its Metal AIR, parameters RE'd from Resolve and captured live): noise-gated edge-directed demosaic, mired-interpolated per-CCT WB + forward matrix from the moov (iPhone; header color otherwise), Apple Log / Apple Wide Gamut output matching a Resolve 21 render to f32 rounding (97.9% of 10-bit codes identical end to end; the rest is Resolve's hardware-decode LSB noise). Viewer tiers render ACEScct log (2026-07-26 \u2014 no baked Rec.709/sRGB; the transcode-grade log form); decode_prores_raw_tier takes the clip's container color."},{codec:"h264",label:"H.264 / AVC",full:!0,preview:!0,luma:!1,scrubPreview:!0,backend:"webcodecs",notes:"scrub = nearest-keyframe snap (1 decode); exact frame on park; FALLBACK (2026-10-27): where WebCodecs is absent or refuses the config (Firefox + HEVC, Chrome without HEVC hardware, most 4:2:2 10-bit), and for containers the TS players cannot walk (MKV/WebM, raw Annex-B, fragmented MP4), the identify chain labels the clip 'h264_wasm' and media-core's own decoder answers through the mcvideo lane (wasm video_open/video_decode \u2014 rust video::lane, gated byte-exact vs ffmpeg in tests/h264_mov_gate.rs / hevc_gate.rs / annexb_gate.rs); WebCodecs stays first"},{codec:"hevc",label:"HEVC / H.265",full:!0,preview:!0,luma:!1,scrubPreview:!0,backend:"webcodecs",notes:"scrub = nearest-keyframe snap (1 decode); exact frame on park; FALLBACK (2026-10-27): where WebCodecs is absent or refuses the config (Firefox + HEVC, Chrome without HEVC hardware, most 4:2:2 10-bit), and for containers the TS players cannot walk (MKV/WebM, raw Annex-B, fragmented MP4), the identify chain labels the clip 'hevc_wasm' and media-core's own decoder answers through the mcvideo lane (wasm video_open/video_decode \u2014 rust video::lane, gated byte-exact vs ffmpeg in tests/h264_mov_gate.rs / hevc_gate.rs / annexb_gate.rs); WebCodecs stays first"},{codec:"xavc",label:"Sony XAVC-Intra",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"webcodecs",notes:"all-intra; already scrub-fast"},{codec:"h264_mxf",label:"H.264 long-GOP (MXF)",full:!0,preview:!0,luma:!1,scrubPreview:!0,backend:"webcodecs",notes:"Camera proxies (Sony CTAPA and kin): H.264 High long-GOP in MXF OP1a. SEPARATE from 'xavc' because XAVC-Intra is all-intra and this is not \u2014 measured on a 1224-frame CTAPA proxy: IBBP, I every 12, but a true RAP (index flag 0x80) only every 48; the intervening I-frames are open-GOP (flag 0x40) and are NOT legal entry points. Decoded by LongGopPlayer: walk the GOP from its RAP, first AU 'key' and the rest 'delta', outputs taken in EMISSION order (WebCodecs owns the B-frame reorder, so the index's temporal_offset is never interpreted). Whole GOP is cached, so any scrub inside those 2s is free. Until 2026-08-10 these files were misidentified as xavc and decoded one isolated AU at a time (submit + flush), so every P/B frame hit a decoder with no reference state, only the leading IDR ever decoded, and the viewer showed frame 0 forever. Gated by oracle/i2o/e2e/mxf-longgop-playback.spec.ts against ffmpeg"},{codec:"r3d",label:"RED R3D",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"Full + preview render NATIVE RWG/Log3G10 (2026-07-26 \u2014 IPP2 output LUT removed from decoders; display transforms are downstream)"},{codec:"arriraw",label:"ARRIRAW",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"EVERY STAGE BYTE-EXACT vs the ARRI SDK (2026-07-27): prep, the ADA-7 demosaic (0 of 15,690,240), the LuMaTaLu color kernel (0 of 31,457,280 \u2014 closed by transcribing the SDK's own f32 op order: the LUT index is fmul-then-fadd not a fused mul_add, the B-spline weights are evaluated expanded with the sixth applied last, and the bicubic accumulates columns before rows), the 1:1 resample (identity) and AfaScaler+BufferScaler (0 of 43,739,136). The shipped master still omits AfaScaler's Rec.709 YCbCr detail and its Jenkins-hash grain \u2014 added looks, not native signal \u2014 so the end-to-end floor gate vs the SDK's DEFAULT output reads 0.16/255; color is no part of that number. exact AWG4/LogC4 develop (2026-07-21, vs ARRI SDK); preview is color via the same per-clip develop plan (tier gate corr \u22650.997). Pre-A35 12-bit ALEV-III (Mini/Mini LF) fully wired 2026-07-26: Gen2 develop to native AWG3/LogC3, SDK-gated MAE<0.8/255, probe inner_codec 'arriraw-alev3' \u2192 decode_arriraw12_mxf; other ALEV3 bodies decode flagged calib:parametric-alev3-family-unvalidated"},{codec:"dnxhr",label:"Avid DNxHR / DNxHD",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"DC-only 1/8 preview tier is COLOR (2026-08-05 \u2014 was gray luma) \u2014 playback + scrub ride it (4K/UHD DNxHR full decodes aren't scrub-fast); park upgrades to full"},{codec:"crm",label:"Canon Cinema RAW Light",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"preview LL tier develops through the SAME tone-exact Canon Log 2 path as Full (2026-07-26 \u2014 replaced the placeholder tone map that drifted -46/255)"},{codec:"braw",label:"Blackmagic RAW",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"per-clip WB develop (bmdf wkel/wtin \u2192 wb_grid tables; Pocket-6K-family sweep-validated); preview is COLOUR-accurate native Gen5 log (gate corr \u22650.996 vs downsampled full). PER-FRAME HEADER LAW (2026-10-27, rust braw::frame_law): family, dequant tables, grain quantisers and edge-strength width are computed from each frame's own header exactly as BlackmagicRawAPI does \u2014 transcribed from the 5.1 binary (dequant builder 0xb98d4: luma M*(qi+4)/32, chroma M*max((qi+5)>>1,4)/32, transposed, DC capped by hdr +0x20/+0x22; M = the frame's in-header matrix (Pocket 6K v2 headers) or a built-in bank entry picked by +0x24; grain setup 0x50358: lo = trunc(hdr+0x1c*40/119), hi = 2*lo, chroma = trunc(hdr+0x1e*80/119); driver select 0x50490 from version/type/strength width). It reproduces all six previously captured quantiser pairs and both Pocket 6K grain captures bit for bit. The ladder only sets the deblock ramp, and ladder AND quant index change frame to frame inside a clip (SAN census: 10,959 frames, 8 ladders, qi 0..53 on one Pocket 6K), so the old ladder-keyed registry (now a witness list, braw::PROFILES) was refusing most Pocket 6K frames and mis-decoding others. A frame is refused with calib:unsupported-entropy-profile only when its header resolves to a decoder driver not yet transcribed. Byte-exact frame gates: (0,0,0,1) C013/C060 8\xD78 byte-exact; and the 12\xD712 family (SHIPPED 2026-07-26) \u2014 (1,2,3,4) URSA 12K, plus BOTH PYXIS encodes (0,1,2,4) and (0,0,1,2), which are the same camera at the same raster with quantisers half a step apart. That family is 12\xD712 luma / 12\xD76 chroma, 2 luma + Cb + Cr per unit off one threaded bit-reader; all four walks (full, multithreaded, DC preview, color preview) are parametric over it. GRAIN + EDGE FILTER MODELLED 2026-07-26 \u2014 the decode is now essentially the SDK's literal output: the synthesized high-frequency PRNG grain is reproduced (scatter map verified 0 mismatches over 76,896 observations across two clips), its per-frame seed turns out to be carried IN the bitstream (16 BE bytes before the first tile) and re-seeded per tile as s1 ^= broadcast16(region<<5|vtile), and the post-IDCT block-edge filter (A*b + B*(a+c) >> 4) is applied. The filter's per-block STRENGTH byte is solved too (2026-07-26): it is transmitted, not derived - each unit ends with a [ctx+0x68]-bit field on its own reader (the skip the walk used to call 'hf_bias' and discard), packing four 2-bit weight selectors per block (bits 7:6/5:4 = the horizontal cut's two 6-px column spans, 3:2/1:0 = the vertical cut's two 6-px row spans); and the four weights are master[ladder[k]] with master[i] = (16-2i, i), so the header ladder IS the deblock strength ramp and no future profile needs a capture for it. BRAW IS BYTE-EXACT (2026-07-26). Frame-gated vs the SDK's own decoded.bin, through BOTH the oracle bitstream and the real .braw container path: all four captures \u2014 C060 (8x8), URSA 12K, and both PYXIS encodes \u2014 now differ from the SDK in ZERO samples, luma and chroma alike, across 208,099,712 luma samples; the gates assert max == 0 rather than a mean bound, because a tolerance cannot tell 'clean' from 'one wrong block in 400,000'. The last drift (11,248 URSA pixels off by one, ~0.014%) was never a modelling gap: the SDK computes an Arai-Agui-Nakajima SCALED DCT \u2014 coefficients premultiplied by s[u]*s[v] = c(k)/(2*cos(k*pi/2N)), then a unit-scale radix-3 x radix-4 butterfly \u2014 so a dense basis multiply is the same function through a DIFFERENT operation graph and rounds differently in f32, which is why f32, f32+FMA and f64 all missed. Both transforms (luma 12x12 @0x6e9c8, chroma 12x6 @0x6fc68) are now the SDK's literal dataflow, machine-transcribed by oracle/media/braw/t12_transcribe.py \u2014 a symbolic byte-slot emulator of the unrolled NEON \u2014 into the generated rust/media-core/src/codecs/braw_t12_idct.rs. The 8x8 family gains the same seed fix (whole-frame grain, no captured constant) AND the same edge filter: it was never a different algorithm, only a different compiled copy (@0x6b6a4) whose ladder (0,0,0,1) resolves to three identities plus one weak tap - C060 Y 1.76 -> 0.003. Also solved by censusing where the residual sat: the SDK runs horizontal before vertical; a vertical cut is governed by the block to its LEFT; the frame's final vertical cut is not filtered (the SDK handles cuts in pairs and drops the pair whose second cut leaves the frame); and the 8x8 byte is a nibble per block (7:6 h / 5:4 v for block 0, 3:2 h / 1:0 v for block 1). Both PYXIS profiles now carry captured grain quantisers (the PARIS original's were read once its volume was remounted). Also gated: the multithreaded walk is byte-identical to single-threaded, and both preview tiers are exact block means of the full decode (corr 1.0000). Pocket 6K (driver sym1569, single-context scan-wrapping core, inline transforms) byte-exact at qi 7 and qi 27 (C040); the SAN Pocket 6K frames at every other ladder (incl. C030's (0,2,3,4) qi 11) decode through the same driver on law-derived tables \u2014 their SDK frame gates (tests/braw_san_law.rs) pass byte-exact (2026-10-27: all 10 SAN frames \u2014 nine Pocket 6K across eight ladders, qi 4..44, plus C104 f567 \u2014 differ from the 5.1 SDK in zero Y/Cb/Cr samples). URSA 12K 8:1-type header (v5, flags 0x0914: type 3) DECODED BYTE-EXACT (2026-10-27): the SDK decodes it at full resolution through its SCALE-1 driver 0x66fdc (the scale-0 row, 0x65248, only parses), which is sym1575 apart from its tables \u2014 6\xD712 coded blocks become 8\xD78 / 8\xD74 output blocks (12336\xD74032 coded \u2192 8224\xD75376), three sub-streams in a four-slot offset table, early-stopping entropy cores 0x735fc / 0x7392c, type-3 prescale rows into the shared 8\xD78 IDCT, inline chroma butterfly. Gated against the 5.1 SDK on both SAN clips (A003_09021503_C013 f0/f70, A005_09021941_C016 f0/f121): 0 differing Y/Cb/Cr samples; multithreaded walk identical. Two fixes landed with it for every 8\xD78 family: the shared IDCT's pass-1 c0 tap is unfused for coefficient columns 4..7, and the chroma grain pre-load (GRAIN_CHROMA8) + the inline chroma butterfly (Cb copy fused, Cr copy not) replace a never-gated matrix form. SAN census: 10,959 / 10,959 frames now resolve to a transcribed driver. See oracle/media/braw/ENTROPY_PROFILE_RE.md \xA714"},{codec:"xocn",label:"Sony X-OCN",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"Full + preview render NATIVE S-Gamut3/S-Log3 (2026-07-26 \u2014 replaced the adaptive display transform); preview = LL-band-only decode (~1/8 per axis, ~90x faster), colour-consistent with Full by construction. Fitted sensors: Burano LT/8K (SBRg), Venice ST (SBRe), VENICE 2 8.6K (SBRf, 2026-07-26 \u2014 decodes via the same parametric geometry, own C0_VENICE2 matrix R\xB2\u22650.9994). X-OCN IS BYTE-EXACT ACROSS MODES (2026-07-27): LT 6K, Venice ST and Burano 8K all decode to ZERO differing samples vs libSonyRawDev's own decoder output \u2014 86,293,760 samples over the three, gated in tests/xocn_variant_gate.rs against hashes of the SDK's planes. Venice ST and 8K previously lost their top and bottom rows (28 and 12 rows; the interiors were already exact) because the band row ranges were formulas in the LL strip count n, read off the LT capture (y0=10, y1=8n-2 and friends) \u2014 those hold only when 8n == h + 12, which is an LT coincidence. The real rule (xocn::phase_chain): the standalone band carries the frame's h rows CENTRED in its 8n coded rows, and every coarser level is the even subset of the level below, so lo = a[k] and y14 = a[k] + n[k] fall out per level and reproduce LT's captured constants exactly. Settled by MEASURING the bitstream \u2014 strips are byte-aligned, so the row count of a strip is the count whose decode consumes its byte size (harness xocnstrip) \u2014 not by sweeping constants. The write-side dy row shift that used to paper over the phase is gone. SBRf/VENICE 2 decodes through the same path but is not yet re-gated byte-exact (fixture on PARIS)"},{codec:"mpeg2",label:"MPEG-2 / MPEG-1",full:!0,preview:!0,luma:!0,scrubPreview:!1,backend:"wasm",notes:"media-core's own decoder (2026-10-27): XDCAM HD422/EX, HDV, IMX, DVD and broadcast streams in MXF / MOV / PS / TS / ES / AVI through the mcvideo lane (video_open/video_decode, rust video::lane \u2192 video::mpeg2_range): long-GOP from the I frame before the window, display order from the stream's own temporal references; a miss decodes a window of frames and keeps it. decode_mpeg2_{rgba,preview,luma} are the I-frame sample tiers (DC-only 1/8 color preview). Gated sample-identical to ffmpeg (tests/mpeg2_gate.rs)"},{codec:"dv",label:"DV / DVCPRO / DVCPRO HD",full:!0,preview:!0,luma:!0,scrubPreview:!0,backend:"wasm",notes:"media-core's own decoder (2026-10-27), all-intra: DV25 / DVCPRO50 / DVCPRO HD in MXF / MOV / AVI / raw .dv through the mcvideo lane; scrub rides the DC-only 1/8 color preview, park upgrades to full. decode_dv_{rgba,preview,luma} are the frame tiers. Gated vs ffmpeg (tests/dv_gate.rs)"},{codec:"qtraw",label:"QuickTime raw / Animation / Motion-JPEG",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"wasm",notes:"media-core's codecs::qtraw through the mcvideo lane (2026-10-27): uncompressed raw/2vuy/v210, Animation (rle \u2014 a delta codec, painted forward from the sync sample before the window), Motion-JPEG (jpeg/mjpa/AVDJ/dmb1 on media-core's JPEG decoder, the JPEG's own raster); clean aperture applied. No browser decodes any of them. Gated vs ffmpeg (media-native mov_simple tests; RGB/Animation lossless-identical)"},{codec:"legacy",label:"Legacy & web video (MPEG-4 Part 2, H.263 / Sorenson, DivX 3, VC-1 / WMV, VP6, Cinepak, SVQ3, AV1)",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"wasm",notes:"media-core's legacy decoders through the mcvideo lane (2026-10-27): MOV / MP4 / 3GP, Matroska / WebM, AVI, ASF / WMV, FLV (H.264 in AVI / ASF / FLV too \u2014 only this reader indexes them). Sample-identical to ffmpeg 7.1.1 on 378 of 379 SAN files (the one is ffmpeg concealing a WMV9 picture it misreads); AV1 34,606 / 34,606 frames. Not covered: interlaced VC-1 / VP6, H.263 PB-frames, MS-MPEG4 v1/v2, WMV1/2, AV1 profiles 1/2 and 12-bit"},{codec:"uncompressed",label:"Uncompressed MXF",full:!0,preview:!1,luma:!1,scrubPreview:!1,backend:"wasm",notes:"Avid 1:1 / alpha mattes / SMPTE 384 uncompressed pictures through the mcvideo lane (qtraw::decode_mxf_uncompressed by the descriptor's PictureLayout, 2026-10-27). Not yet gated against a browser-side fixture (no ffmpeg recipe writes one)"}],h=new Map(u.map(t=>[t.codec,t]));function a(t){let e=(t??"").toLowerCase().trim();return e?e==="aprn"||e==="aprh"?"prores_raw":e==="prores_mxf"||e.startsWith("ap")?"prores":e==="arriraw-alev3"?"arriraw":e==="avc1"||e==="avc3"||e==="h264"?"h264":e.startsWith("hvc")||e.startsWith("hev")||e==="h265"?"hevc":e.startsWith("avd")||e==="dnxh"||e==="dnxhd"?"dnxhr":e==="redcode"?"r3d":e==="h264_wasm"?"h264":e==="hevc_wasm"?"hevc":h.has(e)?e:null:null}function p(t){let e=(t??"").toLowerCase().trim();if(!e)return null;if(e==="aprn"||e==="aprh"||a(e)==="prores_raw"||e==="ap4h"||e==="ap4x")return 12;if(e.startsWith("ap"))return 10;let r=a(e);return r==="r3d"?16:r==="arriraw"||r==="braw"?12:r==="xocn"?16:r==="crm"?12:/dnxhr.?(hqx|444)/.test(e)?10:null}function b(t,e){if(typeof e!="number")return null;let r=a(t);return r==="h264"?[66,77,88,100].includes(e)?8:e===110?10:null:r==="hevc"?e===1?8:e===2?10:null:null}function w(t){let e=(t??"").toLowerCase().trim();if(!e)return null;if(e==="ap4h"||e==="ap4x")return"4:4:4";let r=a(e);return r==="prores_raw"||r==="r3d"||r==="arriraw"||r==="braw"||r==="xocn"||r==="crm"?"bayer":r==="prores"?"4:2:2":/dnxhr.?444/.test(e)?"4:4:4":/dnxhr.?(hqx|hq|sq|lb)/.test(e)?"4:2:2":null}function v(t){let e=t.toLowerCase().replace(/[^0-9a-z]/g,"");return e==="bayer"||e==="raw"?"bayer":e.length>=3&&/^\d+$/.test(e)?e.split("").join(":"):e}function c(t){let e=a(t);return e==="prores"||e==="h264"||e==="hevc"?e:"other"}var f={prores:"ProRes",h264:"H.264",hevc:"HEVC",r3d:"R3D",arriraw:"ARRIRAW",xocn:"X-OCN",vc3:"DNxHR",braw:"BRAW",proresraw:"ProRes RAW",other:"unsupported"};function x(t){return f[t]??"unsupported"}function m(t){let e=JSON.parse(t),r=e.frames??[],o=r.length>>1,n=new Array(o);for(let s=0,i=0;i<o;s+=2,i++)n[i]={offset:r[s],size:r[s+1]};return{offs:n,codec:e.codec,kind:c(e.codec),w:e.width,h:e.height,fps:e.fps??null,startFrame:e.start_frame??0,dropFrame:e.drop_frame??!1}}async function D(t){await l();let r=await d((o,n)=>t.slice(o,o+n).arrayBuffer().then(s=>new Uint8Array(s)),t.size,"mov");return m(r)}export{a,p as b,b as c,w as d,v as e,x as f,m as g,D as h};
@@ -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 r,X as s,o}from"./chunk-DPA26AOI.js";async function d(t){await r();let e=s(t);return e==="null"?null:JSON.parse(e)}async function l(t){await r();let e;try{e=o(t)}catch{return null}if(e.length<8)return null;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n.getUint32(0,!0),i=n.getUint32(4,!0),u=a*i*4;return e.length<8+u?null:{width:a,height:i,rgba:new Uint8ClampedArray(e.subarray(8,8+u))}}export{d as a,l as b};
3
+ import{Ha as r,X as s,o}from"./chunk-QNF4NMIW.js";async function d(t){await r();let e=s(t);return e==="null"?null:JSON.parse(e)}async function l(t){await r();let e;try{e=o(t)}catch{return null}if(e.length<8)return null;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),a=n.getUint32(0,!0),i=n.getUint32(4,!0),u=a*i*4;return e.length<8+u?null:{width:a,height:i,rgba:new Uint8ClampedArray(e.subarray(8,8+u))}}export{d as a,l as b};
@@ -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 E}from"./chunk-ROGMKTND.js";import{S as x,b as y,f as g,g as f,k as w,l as h,s as p,v as b}from"./chunk-X527E5VI.js";async function k(){let e=f()==="win32"?"conformtools-analyze.exe":"conformtools-analyze",r=[y("CONFORM_ANALYZE"),w(e),p(new URL(`./${e}`,import.meta.url)),p(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of r)if(await b(n))return n;return null}var R=e=>e.code==="not_entitled"?new E("not_entitled",String(e.why)):void 0;async function A(e){let r=await P(),n=await r.ask({op:"job",reference:e.reference,clips:e.clips,lite:e.lite??!0,display:!!e.display});if(!n.ok)throw r.close(),R(n)??new Error(`analysis engine: ${n.why}`);return r}async function N(e,r,n){let i=await P(),t=()=>i.close();n?.addEventListener("abort",t);let s;try{s=await i.ask(e,r)}finally{n?.removeEventListener("abort",t),i.close()}if(n?.aborted)throw new Error("cancelled");if(!s.ok)throw R(s)??new Error(s.why??`the analysis engine could not run ${e.op}`);return s}async function P(){let e=await k();if(!e)throw new Error(h("the analysis engine (conformtools-analyze)"));let r="",n=null,i=[],t=x(e,["serve"],o=>{r+=new TextDecoder().decode(o);let a;for(;(a=r.indexOf(`
3
+ import{a as E}from"./chunk-ROGMKTND.js";import{S as x,b as y,f as g,g as f,k as w,l as h,s as p,v as b}from"./chunk-GTPTZRO6.js";async function k(){let e=f()==="win32"?"conformtools-analyze.exe":"conformtools-analyze",r=[y("CONFORM_ANALYZE"),w(e),p(new URL(`./${e}`,import.meta.url)),p(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of r)if(await b(n))return n;return null}var R=e=>e.code==="not_entitled"?new E("not_entitled",String(e.why)):void 0;async function A(e){let r=await P(),n=await r.ask({op:"job",reference:e.reference,clips:e.clips,lite:e.lite??!0,display:!!e.display});if(!n.ok)throw r.close(),R(n)??new Error(`analysis engine: ${n.why}`);return r}async function N(e,r,n){let i=await P(),t=()=>i.close();n?.addEventListener("abort",t);let s;try{s=await i.ask(e,r)}finally{n?.removeEventListener("abort",t),i.close()}if(n?.aborted)throw new Error("cancelled");if(!s.ok)throw R(s)??new Error(s.why??`the analysis engine could not run ${e.op}`);return s}async function P(){let e=await k();if(!e)throw new Error(h("the analysis engine (conformtools-analyze)"));let r="",n=null,i=[],t=x(e,["serve"],o=>{r+=new TextDecoder().decode(o);let a;for(;(a=r.indexOf(`
4
4
  `))>=0;){let c=r.slice(0,a);r=r.slice(a+1);let l=JSON.parse(c);if(l.progress){n?.progress?.(l.progress[0],l.progress[1],l.phase??"");continue}let d=n;n=null,d?.done(l)}},o=>{console.error(o.trimEnd()),i=[...i,...o.split(`
5
5
  `).filter(a=>a.trim())].slice(-3)}),s=null;t.exited.then(o=>{s={ok:!1,why:`the analysis engine exited${o==null?"":` (code ${o})`}${i.length?`: ${i.join(" | ").slice(0,400)}`:""}`},n?.done(s)});let m=Promise.resolve();return{ask:(o,a)=>{let c=m.then(async()=>{t.hold(!0);try{if(s)return s;let l=new Promise(v=>{n={done:v,progress:a}}),u=await t.write(new TextEncoder().encode(JSON.stringify(o)+`
6
6
  `)).then(()=>!0,()=>!1)?await l:await Promise.race([l,t.exited.then(()=>s??{ok:!1,why:"the analysis engine exited"})]);return u.miss&&(console.error(`[mirror] MISS \u2014 ${u.miss} is not in the mirror. Replay never reads the source drive; record this case again with the drive mounted (CONFORM_MIRROR_MODE=record).`),g(75)),u}finally{t.hold(!1)}});return m=c.catch(()=>{}),c},close:()=>t.close()}}export{k as a,A as b,N as c,P as d};
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ function a(e){if(e.length<8)return null;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=n.getUint32(0,!0),r=n.getUint32(4,!0),u=t*r*4;return e.length<8+u?null:{width:t,height:r,rgba:new Uint8ClampedArray(e.subarray(8,8+u))}}export{a};
@@ -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 R}from"./chunk-3PVQ5QP4.js";import{b as be,c as ge,f as we}from"./chunk-VFXMP7IF.js";import{f as V,h as pe}from"./chunk-MTAXVOHK.js";import{a as he}from"./chunk-YGAAGTLE.js";import{i as D}from"./chunk-IG2X534U.js";import{b as M,d as z,f as F}from"./chunk-NU3X7P4N.js";import{Ha as fe,ea as ae,fa as ce,ja as le,oa as ue,wa as me,xa as de}from"./chunk-QNF4NMIW.js";import{a as ie}from"./chunk-ROGMKTND.js";import{$ as y,B as L,G as J,M as $,N as C,O as oe,R as se,_ as b,aa as K,b as E,ba as _,c as q,d as ee,g as re,k as te,l as H,s as B,t as j,v as ne,w as A,z as W}from"./chunk-GTPTZRO6.js";var X=!1,O=8,Ce=0,De=3,N=2;async function ze(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),o=i=>String.fromCharCode(t[i],t[i+1],t[i+2],t[i+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(o(4)==="RED1"||o(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],s=o(4);return/^[A-Za-z0-9 ]{4}$/.test(s)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function Ne(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Te(e){return async(t,o)=>new Uint8Array(await e.slice(t,Math.min(t+o,e.size)).arrayBuffer())}function _e(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function sr(e){return await fe(),ye?ye.clip(e,X?"rec709":"",()=>xe(e)):xe(e)}var ye=null;async function xe(e){let t=await ze(e),o=[];if(t==="r3d"){let r=e,s=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],n=r.bases??[0],i=async(m,l,d)=>{let f=n[m]+l;return new Uint8Array(await e.slice(f,Math.min(f+d,n[m]+s[m].size)).arrayBuffer())},c=JSON.stringify(s.map(m=>({name:m.name,size:m.size}))),a=JSON.parse(await de(i,c)),u=JSON.parse(await le(i,c));return s.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:u.map(m=>({offset:n[m.part??0]+m.essenceOffset,size:m.essenceLength})),w:a.width??0,h:a.height??0,fps:_e(a),startFrame:a.timecode?.start_frame??0,dropFrame:a.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:Ce},geometrySpec:{codec:"r3d",subbands:De},index:null,warnings:o}}if(t==="mxf"){let r=Te(e),s=JSON.parse(await me(r,e.size));if(!s)throw new Error(`${e.name}: MXF index unreadable`);let n=JSON.parse(await ue(r,e.size)),i=[];for(let f=0;f<n.frame_count;f++)i.push({offset:n.frames[f*2],size:n.frames[f*2+1]});let c=i.filter(f=>f.size===0).length;c&&o.push(`${c} frame(s) had no locatable picture KLV`);let a=s.width??0,u=s.height??0,m=(s.inner_codec??"").toLowerCase(),l=null,d="MXF";return m==="arriraw"?(l={codec:"arriraw",w:a,h:u,scale:O},d="ARRIRAW"):m==="xocn"?(l={codec:"xocn",scale:O,...X?{display:"rec709"}:{}},d="X-OCN"):await ce(r,e.size)?(l={codec:"vc3",scale:O},d="DNxHR"):await ae(r,e.size)?(l={codec:"prores"},d="ProRes"):o.push(`MXF inner codec ${m||"unknown"} not wired to the fingerprint pool`),{frames:l?i:[],w:a,h:u,fps:_e(s),startFrame:s.timecode?.start_frame??0,dropFrame:s.timecode?.drop_frame??!1,label:d,spec:l,geometrySpec:l&&l.codec==="arriraw"?{...l,scale:N}:l&&l.codec==="xocn"?{codec:"xocn",scale:N,...X?{display:"rec709"}:{}}:l&&l.codec==="vc3"?{codec:"vc3",scale:N}:null,index:null,warnings:o}}if(t==="isobmff"){let r=await pe(e),s=Ne(e.name);if(r.kind==="prores")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:V(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:V(r.kind),spec:null,geometrySpec:null,index:r,warnings:o};let n=s==="braw"?{codec:"braw",scale:O}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:O}: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?s==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:n,geometrySpec:n?{...n,scale:N}:null,index:r,warnings:o}}throw new Error(`${e.name}: unrecognised container`)}var G=null;var ke=Number(E("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(ee()/2),Math.floor(q()/2**31))),Y=0,$e=[],Se=async(...e)=>{Y>=ke?await new Promise(t=>$e.push(t)):Y++;try{return await se(...e)}finally{let t=$e.shift();t?t():Y--}};async function Re(){let e=re()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[E("CONFORM_NATIVE_DECODE"),te(e),B(new URL(`./${e}`,import.meta.url)),B(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let o of t)if(await ne(o))return o;return null}var v=class extends Error{constructor(o,r){super(r);this.why=o}};function Fr(e){let t=null;try{t=JSON.parse(e.trim().split(`
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 Me(e,t){try{let o=JSON.parse(e.trim().split(`
5
+ `).pop()??"");return new v(o.why,o.detail)}catch{return new v("decoder",`the native decoder exited ${t}: ${e.trim().slice(-300)}`)}}function Or(e){return G?.owns(e)?G.meta(`probe|${e}`,()=>ve(e)):ve(e)}async function ve(e){let t=await Re();if(!t)throw new v("missing",H("the native decoder (conformtools-decode)"));let o=[],r=await Se(t,["probe",e],s=>o.push(s));if(r.code!==0)throw Me(r.stderr,r.code);return JSON.parse(new TextDecoder().decode(Fe(o)))}function Fe(e){let t=e.reduce((s,n)=>s+n.length,0),o=new Uint8Array(t),r=0;for(let s of e)o.set(s,r),r+=s.length;return o}async function Ue(e,t,o,r,s){let n=await Re();if(!n)throw new v("missing",H("the native decoder (conformtools-decode)"));let i=null,c=[],a=0,u=d=>{let f=new Uint8Array(d),h=0;for(;h<d;){let p=c[0],g=Math.min(p.length,d-h);f.set(p.subarray(0,g),h),h+=g,g===p.length?c.shift():c[0]=p.subarray(g)}return a-=d,f},m=[e,t,"--width",String(s.width??32768)];s.from!=null&&m.push("--from",String(s.from)),s.count!=null&&m.push("--count",String(s.count)),s.range&&m.push("--range",s.range);let l=await Se(n,m,d=>{if(c.push(d),a+=d.length,!i){let h=Fe(c.splice(0));c.push(h);let p=h.indexOf(10);if(p<0)return;i=JSON.parse(new TextDecoder().decode(h.subarray(0,p))),u(p+1),o(i)}let f=4+i.w*i.h*(i.bpp??(e==="rgb16"?6:4));for(;a>=f;){let h=u(f);r(new DataView(h.buffer).getUint32(0,!0),h.subarray(4))}},{signal:s.signal});if(l.code!==0||!i)throw Me(l.stderr,l.code)}function Oe(e,t,o,r={}){return Ue("bgra",e,t,o,r)}var Ie=["none","rle","zips","zip","piz","pxr24","b44","b44a","dwaa","dwab","htj2k"],T=e=>(e>>4)*10+(e&15);function He(e){let t=T(e&63),o=T(e>>>8&127),r=T(e>>>16&127),s=T(e>>>24&63),n=i=>String(i).padStart(2,"0");return`${n(s)}:${n(r)}:${n(o)}${e&64?";":":"}${n(t)}`}function Be(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||t.getUint32(0,!0)!==20000630)return null;let o={fps:null,timecode:null,width:0,height:0,display:null,compression:null,attributes:[]},r=8,s=()=>{let i=r;for(;r<e.length&&e[r]!==0;)r++;let c=new TextDecoder().decode(e.subarray(i,r));return r++,c},n=i=>({width:t.getInt32(i+8,!0)-t.getInt32(i,!0)+1,height:t.getInt32(i+12,!0)-t.getInt32(i+4,!0)+1});for(;r<e.length;){let i=s();if(!i)break;let c=s();if(r+4>e.length)return null;let a=t.getInt32(r,!0);if(r+=4,a<0||r+a>e.length)return null;if(o.attributes.push(`${i}:${c}`),i==="framesPerSecond"&&c==="rational"&&a>=8){let u=t.getInt32(r,!0),m=t.getUint32(r+4,!0);o.fps=m?u/m:null}else i==="timeCode"&&c==="timecode"&&a>=8?o.timecode=He(t.getUint32(r,!0)):i==="dataWindow"&&c==="box2i"&&a>=16?{width:o.width,height:o.height}=n(r):i==="displayWindow"&&c==="box2i"&&a>=16?o.display=n(r):i==="compression"&&a>=1&&(o.compression=Ie[e[r]]??`type ${e[r]}`);r+=a}return o}async function je(e){let t=e,o=null,r=/^(.*?)\[(\d+)-(\d+)\](.*)$/.exec(b(e));if(await A(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 i=c=>c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");o=new RegExp(`^${i(n[1])}(\\d{${n[2].length}})${i(n[3])}$`,"i")}let s=[];for await(let n of $(t)){let i=n.isFile?o.exec(n.name):null;i&&s.push({n:Number(i[i.length===4?2:1]),f:_(t,n.name)})}return s.sort((n,i)=>n.n-i.n),{frames:s.map(n=>n.f),numbers:s.map(n=>n.n)}}async function Pe(e){let t=await je(e),o=t.frames[0];if(!o)throw new Error(`no .exr frames for '${b(e)}'`);let r=await C(o),s;try{s=Be(await r.readAt(0,Math.min(r.size,1<<20)))}finally{await r.close()}if(!s)throw new Error(`'${b(o)}' is not an OpenEXR file`);let n=Math.max(1,t.frames.length),i=t.numbers.length>1?t.numbers[t.numbers.length-1]-t.numbers[0]+1-t.numbers.length:0,c=s.fps??0;return{id:b(o),kind:"external",target_url:o,local_path:o,content_kind:n>1?"video":"still",source_fps:s.fps??void 0,source_timecode:s.timecode??void 0,source_resolution_w:s.width,source_resolution_h:s.height,available_range:{start:{value:0,rate:c},duration:{value:n,rate:c}},streams:[{kind:"video",codec:"exr",width:s.width,height:s.height,rate:s.fps??void 0,codec_specific:{compression:s.compression}}],vendor_metadata:{exr:{frames:n,first_frame:t.numbers[0]??null,last_frame:t.numbers[t.numbers.length-1]??null,missing_frames:i,display_window:s.display,attributes:s.attributes,fps_source:s.fps!=null?"header framesPerSecond":"not in the header",timecode_source:s.timecode?"header timeCode (first frame)":"not in the header"}}}}var Z=new Set([".mov",".mp4",".m4v",".mxf",".wav",".braw",".crm",".r3d",".aif",".aiff"]);async function We(e){let t=await C(e);return{path:e,file:t,size:t.size}}function Le(e){return(t,o)=>e.file.readAt(t,o)}async function Je(e){let t=R(b(e));if(!t)return[e];let o=y(e),r=[];for await(let s of $(o)){if(!s.isFile)continue;let n=R(s.name);n&&n.clipBase===t.clipBase&&r.push({n:n.partNumber,p:_(o,s.name)})}return r.sort((s,n)=>s.n-n.n).map(s=>s.p)}async function Q(e){if(await A(e)){let n=[];for await(let i of $(e))i.isFile&&R(i.name)&&n.push(_(e,i.name));if(!n.length)throw new Error(`'${b(e)}' is a folder with no .R3D parts`);e=n.sort()[0]}let t=ge(b(e));if(!t)throw new Error(`unsupported media file '${b(e)}' (supported: ${[...Z].join(" ")})`);let o=await Je(e),r=await Promise.all(o.map(We));return{source:we(t,r.map(n=>be(b(n.path),{fileSize:n.size,read:Le(n)}))),parts:r,format:t,anchor:o[0],close:()=>r.forEach(n=>n.file.close())}}async function Hr(e,t,o,r){if(!/h264|avc|hevc|h265/.test(o)){let s=null,n=await Q(e);try{return await D(n.source,{verb:"decode",index:t,intent:"park"})}catch(i){s=i}finally{n.close()}try{return await Ee(e,t,r)}catch(i){throw/no decoder/.test(String(s))?i:s instanceof Error?s:new Error(String(s))}}return Ee(e,t,r)}async function Ee(e,t,o){t=Math.round(t);let r=0,s=0,n=null;if(await Oe(e,c=>{r=c.w,s=c.h},(c,a)=>{c===t&&(n=a)},{from:t,count:1,width:o}),!n)throw new Error(`the OS decoder returned no frame ${t} of ${b(e)}`);let i=n;for(let c=0;c<i.length;c+=4){let a=i[c];i[c]=i[c+2],i[c+2]=a}return{rgba:i,width:r,height:s}}async function P(e){if(/\.exr$/i.test(e))return Pe(e);let t=await Q(e);try{let o=await D(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,s)=>r+s.size,0),o}finally{t.close()}}function Ke(e,t,o,r){let s=Math.abs(r*1001-Math.round(r*1001/1e3)*1e3)<1?Math.round(r)*1e3/1001:r,n=Math.floor(e*s/t+1e-6);return{tc:M(n,r),frames:Math.round(o*s/t)}}var Ve=e=>String(Math.round(e*1e3)/1e3);function Br(e,t){let o=e.streams?.find(l=>l.kind==="video"),r=e.streams?.filter(l=>l.kind==="audio")??[],s=e.vendor_metadata?.bext;if(!o&&e.available_range&&r[0]?.rate){let l=r[0].rate,d=e.available_range.duration.value,h=(t?[t]:[24e3/1001,24]).map(p=>{let g=Ke(s?.time_reference??0,s?.sample_rate||l,d,p);return`${s?`start TC ${g.tc}, `:""}${g.frames} frames @ ${Ve(p)} fps`});return[e.target_url??"",`audio only; ${d} samples (${(d/l).toFixed(3)} s)${s?`; BWF time_reference ${s.time_reference}`:"; no BWF timecode"}`,...h,...t?[]:["(pass fps for the project's rate)"],...r.map((p,g)=>`audio ${r.length>1?`${g+1}: `:""}${p.codec??"pcm"} ${p.channels??"?"}ch ${p.rate} Hz ${p.bit_depth??"?"}-bit`)].join(`
6
+ `)}let n=e.available_range?.duration?.value??e.declared_duration?.value??null,i=e.source_fps??o?.rate??null,c=e.size_bytes,a=e.vendor_metadata?.spanned_parts,u=o?.codec_specific??{},m=[u.profile?`${u.profile} (${u.fourcc})`:u.fourcc,u.pixel_format,o?.bit_depth?`${o.bit_depth}-bit`:null,u.colr?`color ${u.colr.primaries}/${u.colr.transfer}/${u.colr.matrix} (primaries/transfer/matrix)`:null].filter(Boolean).join(", ");return[e.target_url??"",o?`${o.codec??"?"} ${o.width??"?"}x${o.height??"?"}${i?` @ ${Math.round(i*1e3)/1e3} fps`:""}${m?`; ${m}`:""}`:"no video track",`start TC ${e.source_timecode??"none"}; ${n!=null?`${n} frames`:"length unknown"}${n!=null&&i?` (${(n/i).toFixed(2)} s)`:""}`,r.length?r.map((l,d)=>{let f=l.codec_specific?.channel_layout;return`audio ${r.length>1?`${d+1}: `:""}${l.codec??"pcm"} ${l.channels??"?"}ch${f?` (${f})`:""} ${l.rate??"?"} Hz ${l.bit_depth??"?"}-bit`}).join(`
7
+ `):"no audio",`${e.reel_name?`reel ${e.reel_name}; `:""}${c!=null?`${(c/1e6).toFixed(1)} MB`:""}${a?`; spanned ${a.length} parts`:""}`].join(`
8
+ `)}var Xe=8*1024*1024,k=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0));async function Ge(e,t,o){if(e.executable_locally===!1)throw new Error("this trim plan is server-side only");let r=new Map(t.parts.map(n=>[b(n.path),n]));await L(y(o));let s=await oe(o);try{await s.truncate(e.total_size),await s.writeAt(0,k(e.dest_header_bytes_base64));for(let n of e.src_byte_ranges){let i=n.src_file_name?r.get(b(n.src_file_name)):t.parts[0];if(!i)throw new Error(`plan references unknown source part '${n.src_file_name}'`);let c=0;for(;c<n.length;){let a=Math.min(Xe,n.length-c),u=await i.file.readAt(n.offset+c,a);if(u.length<a)throw new Error(`short read in ${b(i.path)} at ${n.offset+c}`);await s.writeAt(n.write_to_dest_offset+c,u),c+=a}}e.dest_footer_bytes_base64&&e.dest_footer_offset!=null&&await s.writeAt(e.dest_footer_offset,k(e.dest_footer_bytes_base64));for(let n of e.dest_patches??[])await s.writeAt(n.offset,k(n.bytes_base64))}finally{await s.close()}for(let n of e.dest_sidecar_writes??[])await W(_(y(o),n.name),k(n.bytes_base64))}function Ye(e,t){let o=[];for(let r of e){if(r.kind!=="clip"||!r.source_range)continue;let s=r.source_range.start.value,n=r.source_range.duration.value,i=Math.max(0,Math.floor(s)-t),c=Math.floor(s+n-1)+t;c>=i&&o.push({first_frame:i,last_frame:c})}return he(o)}async function Ze(e,t,o,r,s){let n=await Q(e);try{let i=Ye(t,o);if(!i.length)throw new Error("no usable frame ranges (items need kind=clip with source_range)");let c=await D(n.source,{verb:"trim",selection:{items:t,handles:o}}),a=K(n.anchor),u=n.format==="r3d",m=u?R(b(n.anchor))?.clipBase??b(n.anchor,a):b(n.anchor,a),l=[];for(let[d,f]of c.entries()){let h=f.output_clip_number??(i.length>1?d+1:void 0),p=i[(h??1)-1]??i[0],g=h&&(f.output_clip_count??i.length)>1?`_S${String(h).padStart(3,"0")}`:"",w;if(u){let x=f.output_part_number??d+1;w=_(r,`${m}${g}.RDC`,`${m}_${String(x).padStart(3,"0")}.R3D`),l.push({path:w,bytes:f.total_size,island:p,part:x,clip:h})}else{let x=s&&c.length===1?s:`${m}${g||`_trim_${p.first_frame}-${p.last_frame}`}${a}`;w=_(r,x),l.push({path:w,bytes:f.total_size,island:p,clip:h})}await Ge(f,n,w)}return u||await Qe(e,l,!!s&&c.length===1),{outputs:l,islands:i,format:n.format}}finally{n.close()}}async function Qe(e,t,o){let r=await P(e).catch(()=>null),s=r?.source_fps??r?.streams?.find(n=>n.kind==="video")?.rate??null;if(!(!r?.source_timecode||!s))for(let n of t){if(!n.island)continue;let i=await P(n.path).catch(()=>null),c=i?.available_range?.duration?.value??i?.declared_duration?.value;if(!i?.source_timecode||!c)continue;let a=F(i.source_timecode,s,r.source_timecode);if(a===n.island.first_frame&&a+c-1===n.island.last_frame||(n.island={first_frame:a,last_frame:a+c-1},o))continue;let u=n.path.replace(/_trim_\d+-\d+(\.[^./\\]+)$/,`_trim_${a}-${a+c-1}$1`);u!==n.path&&(await J(n.path,u),n.path=u)}}async function jr(e){let t=await P(e.path),o=t.source_fps??t.streams?.find(g=>g.kind==="video")?.rate??null,r=t.available_range?.duration?.value??t.declared_duration?.value??null;if(!o)throw new Error("cannot trim: no frame rate / timecode track on this file");let s=F(e.in,o,t.source_timecode??null),n=F(e.out,o,t.source_timecode??null);e.out_exclusive&&(n-=1);let i=t.source_timecode??"00:00:00:00",c=r!=null?M((z(i,o)??0)+r-1,o,!!t.vendor_metadata?.drop_frame):null;if(n<s)throw new Error(`out ${e.out} is before in ${e.in}`);if(s<0)throw new Error(`in ${e.in} is before the file starts (${i}, frame 0)`);if(r!=null&&n>r-1)throw new Error(`out ${e.out} is past the end of the file (last frame ${c}, frame ${r-1})`);let a={id:"trim",kind:"clip",source_range:{start:{value:s,rate:o},duration:{value:n-s+1,rate:o}}},u=y(e.path),m;if(e.out_path)try{(await j(e.out_path)).isDirectory?u=e.out_path:(u=y(e.out_path),m=b(e.out_path))}catch{u=y(e.out_path),m=b(e.out_path)}let l=await Ze(e.path,[a],Math.max(0,Math.floor(e.handles??0)),u,m),d=l.islands[0],f=l.outputs.length===1&&l.outputs[0].island?l.outputs[0].island:d,h=f.first_frame,p=f.last_frame;return{outputs:l.outputs,first_frame:h,last_frame:p,frames:p-h+1,fps:o,facts:t,...h!==d.first_frame||p!==d.last_frame?{asked:{first_frame:d.first_frame,last_frame:d.last_frame}}:{}}}function Ae(e){let t=[...Z].map(o=>o.slice(1)).join("|");return e.toLowerCase().replace(new RegExp(`\\.(${t})(?=[._\\s-]|$)`,"g"),"").replace(/[^a-z0-9]/g,"")}function qe(e,t){let o=Ae(e),r=Ae(t);if(r&&o.includes(r))return"name";let s=t.toLowerCase().split(/[^a-z0-9]+/).filter(n=>/\d/.test(n)&&n.length>=3);return s.length&&s.every(n=>o.includes(n))?"id":null}async function Wr(e,t,o){let r=[],s=0,n=null,i=Date.now()+o.time_limit_s*1e3,c=async(a,u)=>{try{for await(let m of $(a)){if(n&&!n.startsWith("folders"))return;if(++s>o.max_entries){n=`stopped after ${o.max_entries} entries (max_entries)`;return}if(Date.now()>i){n=`stopped after ${o.time_limit_s} s (time_limit_s)`;return}if(m.name.startsWith("."))continue;let l=_(a,m.name);if(m.isDirectory)u<o.max_depth?await c(l,u+1):n??=`folders deeper than max_depth=${o.max_depth} not searched (e.g. ${l})`;else if(m.isFile&&Z.has(K(m.name).toLowerCase())){let d=qe(m.name,t);d&&r.push({path:l,match:d,size:(await j(l).catch(()=>({size:0}))).size})}}}catch{}};if(await c(e,0),o.probe)for(let a=0;a<r.length;a+=8)await Promise.all(r.slice(a,a+8).map(async u=>{try{u.facts=await P(u.path)}catch(m){u.error=m.message}}));return r.sort((a,u)=>a.path.localeCompare(u.path)),{hits:r,scanned:s,truncated:n}}function er(e){let t=e.streams?.find(c=>c.kind==="video"),o=e.source_fps??t?.rate??null,r=e.available_range?.duration?.value??e.declared_duration?.value??null,s=t?.codec_specific??{},n=e.source_timecode&&o?z(e.source_timecode,o):null,i=n!=null&&r!=null&&o?M((n+r)%(Math.round(o)*86400),o,e.source_timecode.includes(";")):null;return`${t?`${t.codec??"?"}${s.profile?` ${s.profile}`:""} ${t.width??"?"}x${t.height??"?"}`:"no video"}${o?` @ ${Math.round(o*1e3)/1e3} fps`:""}; TC ${e.source_timecode??"none"}${i?`\u2013${i}`:""}; ${r??"?"} fr${r!=null&&o?` (${(r/o).toFixed(2)} s)`:""}`}function Lr(e,t,o,r){let s=e.hits.slice(0,r),n=[];e.truncated&&n.push(`TRUNCATED: ${e.truncated} \u2014 the search did NOT cover all of ${t}; the matches below may be incomplete.`),e.hits.length>s.length&&n.push(`TRUNCATED: showing ${s.length} of ${e.hits.length} matches. Pass limit=${e.hits.length} or narrow the query.`),n.push(`${e.hits.length} file${e.hits.length===1?"":"s"} match "${o}" under ${t} (${e.scanned} entries scanned)`);let i=new Map;for(let a of e.hits)i.set(b(a.path).toLowerCase(),(i.get(b(a.path).toLowerCase())??0)+1);let c=[...i].filter(([,a])=>a>1);c.length&&n.push(`same name in several folders: ${c.map(([a,u])=>`${a} \xD7${u}`).join(", ")} \u2014 they can be DIFFERENT clips; match by TC + duration, never by name alone`);for(let a of s)n.push(`- ${a.path}${a.match==="id"?" (id match)":""}
9
+ ${a.facts?er(a.facts):a.error?`probe failed: ${a.error}`:`${(a.size/1e6).toFixed(1)} MB`}`);return n.join(`
10
+ `)}async function Jr(e,t,o=0){let r=await P(e),s=r.source_fps??r.streams?.find(d=>d.kind==="video")?.rate??null,n=r.available_range?.duration?.value??r.declared_duration?.value??null;if(!s||n==null)throw new Error(`cannot check coverage: ${b(e)} has no frame rate or length`);let i=Math.round(s)*86400,c=r.source_timecode?z(r.source_timecode,s)??0:0,a=!!r.source_timecode?.includes(";"),u=d=>{let f=F(d,s,r.source_timecode??null);return typeof d=="number"||/^\d+$/.test(d.trim())?f:f<-i/2?f+i:f>i/2?f-i:f},m=d=>M(((c+d)%i+i)%i,s,a),l=t.map((d,f)=>{let h=u(d.in),p=u(d.out),g=h,w=n-p,x=g>=0&&w>=0&&p>h,U=Math.max(0,-g),I=Math.max(0,-w),S=[];return p<=h?S.push("out is not after in"):x?S.push(`covered; handles head ${g} / tail ${w} fr`):S.push(`NOT covered: short ${[U?`${U} fr at head`:"",I?`${I} fr at tail`:""].filter(Boolean).join(", ")}`),x&&o&&(g<o||w<o)&&S.push(`handles short of ${o}: ${[g<o?`head by ${o-g}`:"",w<o?`tail by ${o-w}`:""].filter(Boolean).join(", ")}`),{label:d.label??`range ${f+1}`,in_tc:m(h),out_tc:m(p),frames:p-h,covered:x,head:g,tail:w,short_head:U,short_tail:I,note:S.join("; ")}});return{facts:r,rows:l}}export{sr as a,Re as b,Fr as c,Or as d,Oe as e,je as f,Z as g,Je as h,Q as i,Hr as j,P as k,Ke as l,Br as m,Ye as n,Ze as o,jr as p,Ae as q,qe as r,Wr as s,er as t,Lr as u,Jr as v};