conformtools 0.6.10 → 0.6.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +54 -22
- package/dist/{account-GFIQC77T.js → account-IUWNSDG5.js} +1 -1
- package/dist/{analysis-engine-4K5K6L53.js → analysis-engine-M7W32RRC.js} +1 -1
- package/dist/bridge-6NCHJWE6.js +3 -0
- package/dist/browser/timeline_core_bg.wasm +0 -0
- package/dist/{chunk-56EEBHP2.js → chunk-2CY2OOOJ.js} +1 -1
- package/dist/chunk-3XQI5SIV.js +3 -0
- package/dist/chunk-5YULBQJX.js +3 -0
- package/dist/chunk-64X5DLH5.js +6 -0
- package/dist/{chunk-XJNWAQON.js → chunk-6NLB5TZ2.js} +1 -1
- package/dist/chunk-B77ADB26.js +3 -0
- package/dist/chunk-DFQWQ3EA.js +10 -0
- package/dist/{chunk-JXTRQ3UG.js → chunk-F4PHKOAS.js} +1 -1
- package/dist/chunk-G3SZDPDS.js +3 -0
- package/dist/chunk-IN6XVTUS.js +3 -0
- package/dist/{chunk-NQNS4Y2B.js → chunk-LVGGCRDW.js} +1 -1
- package/dist/chunk-LYM757KG.js +158 -0
- package/dist/chunk-N34DQ6MH.js +14 -0
- package/dist/chunk-NMH62JSC.js +5 -0
- package/dist/chunk-NXJZXXC2.js +20 -0
- package/dist/{chunk-6HZP2OJA.js → chunk-OMPYIH6F.js} +1 -1
- package/dist/{chunk-DGXZB7MO.js → chunk-P3XI63Q2.js} +1 -1
- package/dist/chunk-QTA36RVO.js +502 -0
- package/dist/chunk-QTFFVLVJ.js +8 -0
- package/dist/{chunk-E5ENIKNR.js → chunk-SJ56EEFP.js} +2 -2
- package/dist/chunk-THVX57I3.js +4 -0
- package/dist/chunk-UUXHJNQA.js +8 -0
- package/dist/chunk-VJN4UXFJ.js +8 -0
- package/dist/chunk-XF3YMBI7.js +3 -0
- package/dist/chunk-XVRTAKDK.js +6 -0
- package/dist/chunk-YU3SUSK3.js +3 -0
- package/dist/claude-setup-REU4AOKX.js +13 -0
- package/dist/cli.js +8 -8
- package/dist/emscripten-module-Q67P5WYC-HW3D2R5O.js +2161 -0
- package/dist/engine-6ACEWA4S.js +5 -0
- package/dist/ffi-7KTOX2T4.js +3 -0
- package/dist/framing-CVJM5TT3.js +3 -0
- package/dist/gfx-worker.js +1 -1
- package/dist/{h264-B2TLLEMI.js → h264-5OGRVYUF.js} +1 -1
- package/dist/{h264-mxf-3GED5PBT.js → h264-mxf-FTHNCK4B.js} +1 -1
- package/dist/host-relink-ZP33BK53.js +10 -0
- package/dist/hosted-BWAYLJXR.js +3 -0
- package/dist/hosts-H3IKRZF2.js +3 -0
- package/dist/http.js +3 -3
- package/dist/{inspect-D3WEYL2W.js → inspect-BJYIDVDN.js} +2 -2
- package/dist/{isobmff-C5A2EFKH.js → isobmff-DN6MCHEK.js} +1 -1
- package/dist/{mc-video-ARKIHPA7.js → mc-video-TF3MD7LN.js} +1 -1
- package/dist/mcp.js +8 -7
- package/dist/{media-3YMIZSSF.js → media-MJKEKCPN.js} +1 -1
- package/dist/module-ES6BEMUI-L6VQ7K3J.js +3 -0
- package/dist/module-asyncify-2EFITU5U-Z4EEM6X7.js +3 -0
- package/dist/{mxf-CQSI6H5T.js → mxf-Q5723GPD.js} +1 -1
- package/dist/{ops-BCTGDBXT.js → ops-B2OA7VXN.js} +1 -1
- package/dist/{probe-COWUTQGN.js → probe-72QZKMCC.js} +1 -1
- package/dist/{r3d-FX7V4BIE.js → r3d-7OOZMPWH.js} +1 -1
- package/dist/{sequence-patch-JVEZW24V.js → sequence-patch-CN4VC5W3.js} +1 -1
- package/dist/store-4WZQF6YD.js +3 -0
- package/dist/timeline-ZP5H4YDQ.js +3 -0
- package/package.json +10 -1
- package/dist/bridge-73XMEZLH.js +0 -3
- package/dist/chunk-2MJAQROY.js +0 -5
- package/dist/chunk-7QUSVHO2.js +0 -10
- package/dist/chunk-CJYLQ3UM.js +0 -5
- package/dist/chunk-DFDXSIMI.js +0 -39
- package/dist/chunk-DNS4ZYIO.js +0 -3
- package/dist/chunk-GM262EDM.js +0 -8
- package/dist/chunk-JHTMYXJM.js +0 -20
- package/dist/chunk-QHXX5GDD.js +0 -440
- package/dist/chunk-TDIY4NRQ.js +0 -3
- package/dist/chunk-UGVGRL5M.js +0 -3
- package/dist/chunk-Y2QHZUGL.js +0 -5
- package/dist/chunk-YC7QDS5U.js +0 -19
- package/dist/chunk-ZVUKOFUX.js +0 -6
- package/dist/claude-setup-OKOPPDMB.js +0 -5
- package/dist/conformtools-analyze +0 -0
- package/dist/conformtools-decode +0 -0
- package/dist/engine-274GQLUB.js +0 -5
- package/dist/framing-BKTUEUZO.js +0 -3
- package/dist/host-relink-PTV44KXF.js +0 -10
- package/dist/hosts-D3TR2QEV.js +0 -3
- package/dist/i2o-transfer +0 -0
- package/dist/store-SZKXADGI.js +0 -3
- package/dist/timeline-PEUC3G7K.js +0 -3
- /package/dist/{still-WUCFH2WX.js → still-SX6RJ7O6.js} +0 -0
package/dist/chunk-TDIY4NRQ.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
-
import{A as d,Z as f,k as u,v as c,x as l,y as p}from"./chunk-DNS4ZYIO.js";import o from"node:process";import{readFileSync as y,rmSync as g}from"node:fs";import{createConnection as h}from"node:net";var w=new Set(["tool_run","app","tool"]),s=()=>f(u(),"engine.json");async function k(e,r){await p(u()),await l(s(),JSON.stringify({port:e,token:r||void 0,pid:o.pid})),await d(s(),384);for(let t of["SIGINT","SIGTERM"])o.on(t,()=>o.exit(0));o.on("exit",()=>{try{JSON.parse(y(s(),"utf8")).pid===o.pid&&g(s())}catch{}})}function S(e,r=1500){return new Promise(t=>{let n=h({host:"127.0.0.1",port:e}),i=m=>{clearTimeout(a),n.destroy(),t(m)},a=setTimeout(()=>i(!1),r);n.once("connect",()=>i(!0)).once("error",()=>i(!1))})}async function I(e,r){if(!w.has(e))return null;let t;try{t=JSON.parse(await c(s()))}catch{return null}if(t.pid===o.pid||!await S(t.port))return null;let n;try{n=await fetch(`http://127.0.0.1:${t.port}/verbs/${e}`,{method:"POST",body:JSON.stringify(r),headers:{"content-type":"application/json",...t.token?{authorization:`Bearer ${t.token}`}:{}}})}catch{return null}if(n.status===401||n.status===404)return null;let{text:i,...a}=await n.json();return{content:[{type:"text",text:i??""}],structuredContent:a,isError:!n.ok}}export{k as a,I as b};
|
package/dist/chunk-UGVGRL5M.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
-
import{a as F}from"./chunk-PHAMF4JF.js";import{B as R,C as g,D,I as $,W as k,Z as i,k as b,q as x,r as p,v as S,x as _,y as m,z as v}from"./chunk-DNS4ZYIO.js";var A="_originalframes",y="zAPPLIED_PATCHES",u=t=>t.replace(/[\\/][^\\/]+[\\/]?$/,""),T=()=>i(b(),"move-undo");async function P(t){let n=[];for await(let a of $(t))a.isFile&&!a.name.startsWith(".")&&n.push(a.name);return n.sort()}async function O(t){let n=[];for await(let a of $(u(t)))a.isDirectory&&/patch/i.test(a.name)&&a.name!==y&&n.push(a.name);return n.sort()}async function C(t,n){let a=new Set(await P(t)),e=[];for(let r of n){let s=i(u(t),r);if(await p(s))for(let w of await P(s))e.push({file:w,folder:r,replaces:a.has(w)})}return e}async function j(t,n,a){if(!await p(t)||!(await x(t)).isDirectory)throw new F("invalid_args",`not a folder: ${t}`);let e=u(t),r=[],s=[];for(let o of await C(t,n)){if(a&&!a.has(`${o.folder}/${o.file}`))continue;if(!o.replaces){r.push(`${o.file}: not in the sequence`);continue}let f=i(t,o.file),c=i(e,o.folder,o.file),l=`${t}${A}`,d=i(l,o.file);for(let h=1;await p(d);h++)d=i(`${t}${A}${String(h).padStart(2,"0")}`,o.file);await m(u(d));try{await g(f,d)}catch(h){r.push(`${o.file}: ${h.message}`);continue}try{await R(c,f)}catch(h){await g(d,f).catch(()=>{}),r.push(`${o.file}: ${h.message}`);continue}s.push({file:o.file,backup:d,patch_src:c,applied:c,folder:o.folder}),l=""}let w=[];if(s.length){let o=i(e,y);await m(o);for(let f of new Set(s.map(c=>c.folder))){let c=i(o,f);for(let l=1;await p(c);l++)c=i(o,`${f}_${l}`);try{await g(i(e,f),c),w.push({from:i(e,f),to:c});for(let l of s)l.folder===f&&(l.applied=i(c,l.file))}catch(l){r.push(`${f}: not filed under ${y} (${l.message})`)}}}if(!s.length)return{patched:0,errors:r};let E=`files-${Date.now().toString(36)}`;return await m(T()),await _(i(T(),`${E}.json`),JSON.stringify({patch:!0,sequence:t,entries:s.map(({folder:o,...f})=>f),folders:w})),{patched:s.length,errors:r,undo_id:E}}async function J(t){let n=[];for(let e of t.folders)await p(e.to)&&!await p(e.from)&&await g(e.to,e.from).catch(r=>n.push({path:e.to,error:r.message}));let a=0;for(let e of t.entries){let r=i(t.sequence,e.file);if(await p(e.backup))try{await p(r)&&await v(r),await g(e.backup,r),a++}catch(s){n.push({path:r,error:s.message})}}for(let e of new Set([...t.entries.map(r=>u(r.backup)),...t.folders.map(r=>u(r.to))]))if(await p(e)&&!(await P(e)).length){let r=!0;for await(let s of $(e)){r=!1;break}r&&await D(e).catch(()=>{})}return{restored:a,failed:n}}var L=t=>k(t),U=async t=>JSON.parse(await S(t));export{A as a,y as b,O as c,C as d,j as e,J as f,L as g,U as h};
|
package/dist/chunk-Y2QHZUGL.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
|
|
3
|
-
import{W as $e,c as de}from"./chunk-DFDXSIMI.js";import{b as ve,f as we}from"./chunk-NU3X7P4N.js";import{c as me}from"./chunk-CJYLQ3UM.js";import{a as ce}from"./chunk-PHAMF4JF.js";function te(e,n,t,o,s){let r=1-s;return r*r*r*e+3*r*r*s*n+3*r*s*s*t+s*s*s*o}function Ue(e,n,t){let o=0,s=1;for(let a=0;a<48;a++){let u=(o+s)/2;te(n[0],n[1],n[2],n[3],u)<e?o=u:s=u}let r=(o+s)/2;return te(t[0],t[1],t[2],t[3],r)}var be=e=>!!(e.sOutX||e.sOutY||e.sInX||e.sInY);function Se(e){return e.some(n=>be(n)||n.interp==="bezier")}var Me=new WeakMap;function Qe(e,n){let t=Me.get(e);if(t&&t.to===n)return t;let o=e.x,s=e.y,r=n.x,a=n.y,u,m,c,l;be(e)||be(n)?(u=o+(e.sOutX??0),m=s+(e.sOutY??0),c=r+(n.sInX??0),l=a+(n.sInY??0)):(u=o+(r-o)/3,m=s+(a-s)/3,c=r-(r-o)/3,l=a-(a-s)/3);let f=[0],h=o,x=s;for(let k=1;k<=256;k++){let w=k/256,$=te(o,u,c,r,w),A=te(s,m,l,a,w);f.push(f[f.length-1]+Math.hypot($-h,A-x)),h=$,x=A}let M={to:n,arc:f,ctrl:[o,u,c,r,s,m,l,a]};return Me.set(e,M),M}function Te(e,n,t){if(!e.length)return[0,0];let o=e[0],s=e[e.length-1];if(n<=o.time)return[o.x,o.y];if(n>=s.time)return[s.x,s.y];for(let r=0;r<e.length-1;r++){let a=e[r],u=e[r+1];if(!(n>=a.time&&n<u.time))continue;if(a.interp==="hold")return[a.x,a.y];let m=u.time-a.time;if(m<=0)return[u.x,u.y];let c=m/(t||24),{arc:l,ctrl:f}=Qe(a,u),h=l[l.length-1];if(!(h>1e-12))return[a.x,a.y];let x=c>0?h/c:0,M=a.interp==="bezier"&&a.outSpeed!=null?a.outSpeed:x,k=a.interp==="bezier"&&a.outInfluence!=null?a.outInfluence:1/3,w=u.interp==="bezier"&&u.inSpeed!=null?u.inSpeed:x,$=u.interp==="bezier"&&u.inInfluence!=null?u.inInfluence:1/3,A=1/6,C=(T,p)=>Math.abs(T-p)<1e-9,N=M===0&&C(k,1/3),Z=w===0&&C($,1/3);C(k,A)&&(M=x,k=Z?.5:1/3),C($,A)&&(w=x,$=N?.5:1/3);let Q=(n-a.time)/(t||24),z=Math.min(Math.max(Ue(Q,[0,k*c,c-$*c,c],[0,M*k*c,h-w*$*c,h]),0),h),E=1,G=256;for(;E<G;){let T=E+G>>1;l[T]<z?E=T+1:G=T}let K=l[E-1],i=l[E],b=i>K?(z-K)/(i-K):0,_=(E-1+b)/256;return[te(f[0],f[1],f[2],f[3],_),te(f[4],f[5],f[6],f[7],_)]}return[s.x,s.y]}function Ae(e,n){if((n==="flip_horizontal"?e.flip_horizontal:e.flip_vertical)===!0)return!0;let o=e.effects;return Array.isArray(o)?o.some(s=>{let r=s;return r?.kind===n&&r.enabled!==!1}):!1}function j(e,n){return typeof e=="number"&&Number.isFinite(e)?e:Array.isArray(e)&&typeof e[n]=="number"?e[n]:null}function Je(e,n,t,o,s){let r;Array.isArray(e.value)&&Array.isArray(n.value)?r=Math.hypot((j(n.value,0)??0)-(j(e.value,0)??0),(j(n.value,1)??0)-(j(e.value,1)??0)):r=(j(n.value,0)??0)-(j(e.value,0)??0);let a=o/t;if(r===0||!(s>0))return a;let u=w=>{let $=typeof w?.x=="number"?w.x:null,A=typeof w?.y=="number"?w.y:null;if($===null||A===null)return null;let C=Math.min(Math.max(A,0),1)*t;return{dx:C,dy:$/s/r*C}},m=u(e.tout)??{dx:t/3,dy:t/3/t},c=u(n.tin)??{dx:t/3,dy:t/3/t},l=Math.min(Math.max(m.dx,0),t),f=m.dy,h=t-Math.min(Math.max(c.dx,0),t),x=1-c.dy,M=(w,$,A,C)=>{let N=1-C;return 3*w*C*N*N+3*$*C*C*N+A*C*C*C},k=a;for(let w=0;w<8;w++){let $=M(l,h,t,k)-o,A=1-k,C=3*(l*(A*A-2*k*A)+h*(2*k*A-k*k)+t*k*k);if(Math.abs(C)<1e-9)break;let N=k-$/C;if(!(N>=0&&N<=1))break;if(Math.abs(N-k)<1e-7){k=N;break}k=N}if(Math.abs(M(l,h,t,k)-o)>t*1e-4){let w=0,$=1;for(let A=0;A<40;A++)k=(w+$)/2,M(l,h,t,k)<o?w=k:$=k}return M(f,x,1,k)}function We(e,n,t,o=0,s=0){let a=(e.keyframes??[]).filter(c=>c.parameter_path===n&&typeof c.time?.value=="number").map(c=>({time:c.time.value,value:c.value,interp:c.interp??"linear",tin:c.tangent_in,tout:c.tangent_out,drt:!!c.raw_extraction?.drt_tangent})).sort((c,l)=>c.time-l.time);if(!a.length)return;let u=j(a[0].value,o)??0,m=j(a[a.length-1].value,o)??0;if(t<=a[0].time)return u;if(t>=a[a.length-1].time)return m;for(let c=0;c<a.length-1;c++){let l=a[c],f=a[c+1];if(t>=l.time&&t<=f.time){let h=j(l.value,o)??0,x=j(f.value,o)??0;if(l.interp==="hold")return h;let M=f.time-l.time||1,k=(l.tout||f.tin)&&!l.drt&&!f.drt?Je(l,f,M,t-l.time,s):(t-l.time)/M;return h+(x-h)*k}}return m}function qe(e){let n=e.keyframes??[];for(let t of n){if(t.parameter_path==="speed")continue;let o=t.time?.rate;if(typeof o=="number"&&o>0)return o}}function ze(e){let n=e.speed;return typeof n=="number"&&Number.isFinite(n)?Math.abs(n)/100:1}function en(e){let n=e,t=n.raw_extraction??void 0,o=m=>{let c=t?.[m];return typeof c=="number"&&Number.isFinite(c)?c:void 0};if(!(n.is_reinterpreted===!0||t?.isReinterpreted===!0))return 1;let r=n.original_fps??o("originalFps"),a=n.interpreted_fps??o("reinterpretedFps");if(r!=null&&a!=null&&r>0&&a>0)return a/r;let u=o("reinterpretationSpeedAdjustment");return u!=null&&u>0?u/100:1}function Ie(e,n){let o=(e.keyframes??[]).filter(a=>a.parameter_path==="speed"&&typeof a.time?.value=="number"&&typeof a.value=="number").map(a=>({x:a.time.value,y:a.value,tan:Array.isArray(a.raw_extraction?.drtNativeTangent)?a.raw_extraction.drtNativeTangent:null})).sort((a,u)=>a.x-u.x);if(o.length<2)return null;let s=(a,u)=>{let m=o[a].tan;if(m&&m.length>=4){if(u==="in"&&m[0])return m[1]/m[0];if(u==="out"&&m[2])return m[3]/m[2]}let c=u==="out"?Math.min(a+1,o.length-1):Math.max(a-1,0),l=Math.min(a,c),f=Math.max(a,c),h=o[f].x-o[l].x;return h>0?(o[f].y-o[l].y)/h:0},r=o.length-1;if(n<=o[0].x)return o[0].y+(n-o[0].x)*s(0,"out");if(n>=o[r].x)return o[r].y+(n-o[r].x)*s(r,"in");for(let a=0;a<r;a++){let u=o[a],m=o[a+1];if(n>m.x)continue;let c=m.x-u.x;if(c<=0)return m.y;let l=(n-u.x)/c,f=l*l,h=f*l,x=s(a,"out"),M=s(a+1,"in");return(2*h-3*f+1)*u.y+(h-2*f+l)*c*x+(-2*h+3*f)*m.y+(h-f)*c*M}return o[r].y}function nn(e,n,t){let o=e.timeline_range?.start?.value??0,s=e.timeline_range?.start?.rate||t,r=(n-o)/s,a=e.source_range?.start,u=a&&typeof a.value=="number"&&a.rate?a.value/a.rate:0,m=Ie(e,r);if(m!=null)return(u+m)*t;let c=ze(e);if(e.speed_reverse){let l=e.source_range?.duration,f=l&&typeof l.value=="number"&&l.rate?Math.max(0,l.value-1)/l.rate:0;return(u+f-r*c)*t}return(u+r*c)*t}function rn(e,n){let t=e.timeline_range?.start,o=t?.value??0,s=t?.rate||24,r=e.source_range?.start,a=r?.value??0,u=r?.rate||s,m=Ie(e,(n-o)/s);if(m!=null)return a+m*u;let c=ze(e)*en(e),l=(n-o)*(u/s)*c;if(e.speed_reverse){let f=e.source_range?.duration?.value??0;return a+Math.max(0,f-1)-l}return a+l}function tn(e){let n=e.keyframes??[],t=[];for(let o of n){if(o.parameter_path!=="position"||typeof o.time?.value!="number")continue;let s=o.value,r=j(s,0),a=j(s,1);if(r==null||a==null)return null;let u=o.raw_extraction?.tangentPs??void 0,m=(c,l)=>{let f=c?.[l];return typeof f=="number"&&Number.isFinite(f)?f:void 0};t.push({time:o.time.value,x:r,y:a,interp:o.interp??"linear",outSpeed:o.tangent_out?.x??void 0,outInfluence:o.tangent_out?.y??void 0,inSpeed:o.tangent_in?.x??void 0,inInfluence:o.tangent_in?.y??void 0,sOutX:m(u,"spatialOutX"),sOutY:m(u,"spatialOutY"),sInX:m(u,"spatialInX"),sInY:m(u,"spatialInY")})}return t.length<2?null:(t.sort((o,s)=>o.time-s.time),Se(t)?t:null)}function Re(e,n){let t=qe(e)??e.timeline_range?.start?.rate??24,o=nn(e,n,t),s=!1,r=(c,l=0)=>{let f=We(e,c,o,l,t);return f!==void 0&&(s=!0),f},a=c=>typeof c=="number"?c:null,u=tn(e);u&&(s=!0);let m=u?Te(u,o,t):null;return{scale:r("scale")??a(e.scale),scaleX:r("scale.x")??a(e.scale_x),scaleY:r("scale.y")??a(e.scale_y),posX:m?m[0]:r("position",0)??r("position.x")??a(e.position_x)??0,posY:m?m[1]:r("position",1)??r("position.y")??a(e.position_y)??0,rotation:r("rotation")??a(e.rotation)??0,anchorX:r("anchor",0)??r("anchor.x")??a(e.anchor_x)??0,anchorY:r("anchor",1)??r("anchor.y")??a(e.anchor_y)??0,opacity:r("opacity")??a(e.opacity),cropL:r("crop.left")??a(e.crop_left)??0,cropR:r("crop.right")??a(e.crop_right)??0,cropT:r("crop.top")??a(e.crop_top)??0,cropB:r("crop.bottom")??a(e.crop_bottom)??0,flipH:Ae(e,"flip_horizontal"),flipV:Ae(e,"flip_vertical"),animated:s}}function Oe(e,n){return Math.floor(rn(e,n)+1e-9)}var _e={strict:{tolerance_px:1,min_frames:1,gap_frames:0,black_threshold:16},standard:{tolerance_px:2,min_frames:2,gap_frames:1,black_threshold:10},relaxed:{tolerance_px:6,min_frames:4,gap_frames:3,black_threshold:6}},ge="strict",Ce={tolerance_px:[0,512],min_frames:[1,600],gap_frames:[0,600],black_threshold:[0,255]};function Fe(e,n={}){let t=(e??ge).trim().toLowerCase(),o=_e[t]??_e[ge],s=_e[t]?t:t==="custom"?"custom":ge,r={...o};for(let a of Object.keys(Ce)){let u=n[a];if(u===void 0||!Number.isFinite(Number(u)))continue;let[m,c]=Ce[a],l=Math.max(m,Math.min(c,Math.round(Number(u))));l!==r[a]&&(s="custom"),r[a]=l}return{...r,preset:s}}function ie(e,n){let t=Number(e),o=Number(n);return!Number.isFinite(t)||!Number.isFinite(o)?!1:t>0&&t>=o}function an(e,n,t){return!(e>0)||!(n>0)||!(t>0)?!1:Math.abs(n/t-e)/e>=.02}function sn(e,n,t,o,s){let r=Math.max(2,Number(s)||0);return Math.abs(e-n)<=r&&Math.abs(t-o)<=r}function on(e,n,t,o,s,r){return!s||!(s.top>0||s.bottom>0||s.left>0||s.right>0)?!1:Math.abs(e-s.top)<=r&&Math.abs(n-s.bottom)<=r&&Math.abs(t-s.left)<=r&&Math.abs(o-s.right)<=r}var Ne=[["bt","ct"],["bb","cb"],["bl","cl"],["br","cr"]],le=e=>Math.max(0,Math.trunc(Number(e)||0)),fe=e=>Math.max(0,Math.min(1,Number(e)||0));function un(e,n,t,o,s,r={}){let a=r.tolerance_px??4;o=Math.max(1,Math.trunc(o)),s=Math.max(1,Math.trunc(s));let u=[];for(let m of e??[]){let c=Math.trunc(Number(m.pts)||0),l=le(m.bt),f=le(m.bb),h=le(m.bl),x=le(m.br);if(!ie(Math.max(l,f,h,x),a)||on(l,f,h,x,r.declared_blanking,a))continue;let M=Number(r.expected_aspect_ratio)||0;if(M>0){let $=Math.max(1,o-h-x),A=Math.max(1,s-l-f),C=h<=a&&x<=a,N=l<=a&&f<=a;if((C||N)&&an(M,o,s)&&sn(l,f,h,x,a)&&Math.abs($/A-M)/M<.02)continue}let k=t+c,w;for(let $ of n??[])$.start<=k&&k<$.end&&(!w||$.track>w.track)&&(w=$);w&&u.push({frame_abs:k,bt:l,bb:f,bl:h,br:x,ct:fe(m.ct),cb:fe(m.cb),cl:fe(m.cl),cr:fe(m.cr),source:m.source??"pixels",clip:w})}return u.sort((m,c)=>m.frame_abs-c.frame_abs)}function cn(e,n){let t=[];return ie(e.bt,n)&&t.push("Top"),ie(e.bb,n)&&t.push("Bottom"),ie(e.bl,n)&&t.push("Left"),ie(e.br,n)&&t.push("Right"),t}function Ee(e,n,t,o,s,r={}){let a=Math.max(1,Math.trunc(r.min_frames??1)),u=Math.max(0,Math.trunc(r.gap_frames??0)),m=r.tolerance_px??4,c=[],l;for(let f of un(e,n,t,o,s,r)){(!l||l.clip!==f.clip||f.frame_abs-l.end_frame-1>u)&&(l={clip:f.clip,start_frame:f.frame_abs,end_frame:f.frame_abs,frame_count:0,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},sources:new Set},c.push(l)),l.end_frame=f.frame_abs,l.frame_count++,l.sources.add(f.source);for(let[h,x]of Ne)f[h]>=l.measured[h]&&(l.measured[h]=f[h],l.coverage[x]=f[x])}return c.filter(f=>f.frame_count>=a).map(f=>({...f,duration_frames:f.end_frame-f.start_frame+1,sources:[...f.sources].sort(),zones:cn(f.measured,m)}))}function yn(e){let n=new Map;for(let o of e){let s=n.get(o.clip.id);s||(s={clip:o.clip,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},frames:0,first_frame_abs:o.start_frame,zones:[],sources:[],ranges:[]},n.set(o.clip.id,s)),s.frames+=o.frame_count,s.first_frame_abs=Math.min(s.first_frame_abs,o.start_frame);for(let[r,a]of Ne)o.measured[r]>=s.measured[r]&&(s.measured[r]=o.measured[r],s.coverage[a]=o.coverage[a]);s.sources=[...new Set([...s.sources,...o.sources])].sort(),s.ranges.push(o)}let t=["Top","Bottom","Left","Right"];return[...n.values()].map(o=>{let s=new Set(o.ranges.flatMap(r=>r.zones));return{...o,zones:t.filter(r=>s.has(r)),ranges:o.ranges.sort((r,a)=>r.start_frame-a.start_frame)}}).sort((o,s)=>o.clip.start-s.clip.start)}function kn(e,n=1){let t=Math.max(0,Math.trunc(n)),o=[];for(let s of[...e].sort((r,a)=>r.frame-a.frame)){let r=o.at(-1);if(r&&s.frame-r.end_frame<=t+1){r.end_frame=Math.max(r.end_frame,s.frame),r.frames++,r.darkest=Math.min(r.darkest,s.avg);continue}o.push({start_frame:s.frame,end_frame:s.frame,duration_frames:1,frames:1,darkest:s.avg})}for(let s of o)s.duration_frames=s.end_frame-s.start_frame+1;return o}function xe(e,n){let t=n?e.timelines.find(o=>o.id===n||o.name===n):e.timelines.find(o=>o.kind==="primary")??e.timelines[0];if(!t)throw new Error(n?`no timeline ${n} in this session`:"this session has no timeline");if(!t.resolution_w||!t.resolution_h)throw new Error(`${t.name}: the timeline has no raster (resolution) in the session`);return t}var mn=e=>e.fps_den?e.fps_num/e.fps_den:e.fps_num,ae=(e,n)=>ve((e.start_frame??0)+n,mn(e),!!e.is_drop_frame),ln=e=>e.split(/[\\/]/).pop()??e,ue=e=>e.tracks.filter(n=>n.kind==="Video").sort((n,t)=>n.track_index-t.track_index),D=e=>{let n=e.timeline_range.start.value;return[n,n+e.timeline_range.duration.value]},pe=e=>e.items.filter(n=>n.kind==="clip");function se(e,n){let t=e.media_references.find(u=>u.id===n.media_reference_id),o=t?.local_path??t?.target_url?.replace(/^file:\/\//,"")??null,s=t?.source_resolution_w??0,r=t?.source_resolution_h??0,a=t?.source_pixel_aspect||1;return{path:o,w:s*a,h:r}}var re=(e,n)=>Re(e,n),ye=(e,n)=>Oe(e,n),Be=(e,n,t)=>({box:[n,t],scale:[(e.scaleX??e.scale??100)/100,(e.scaleY??e.scale??100)/100],pos:[e.posX*n,e.posY*t],rot:e.rotation,anchor:[e.anchorX,e.anchorY],crop:[e.cropL/100,e.cropR/100,e.cropT/100,e.cropB/100],flip:[e.flipH,e.flipV]});function Xe(e,n,t,o){if(!(t>0&&o>0))return[e,n];let s=Math.min(e/t,n/o);return[t*s,o*s]}function je(e,n,t){let o=n-e,s=Math.max(1,Math.min(t,o));return[...new Set(Array.from({length:s},(r,a)=>e+Math.min(o-1,Math.floor((a+.5)*o/s))))]}var fn=["fit","fill","crop","stretch"];function Ge(e,n,t){if(t)return t;let o=e.reframe_fit??n.mismatch_policy??"fit";return o==="none"?"crop":fn.includes(o)?o:"fit"}function He(e,n,t,o,s){if(!(e>0&&n>0)||s==="fit")return[1,1];let r=t/e,a=o/n,u=[r,r],m=[a,a],c=r<=a?u:m,l=s==="crop"?[1,1]:s==="fill"?r>a?u:m:[r,a];return[l[0]/c[0],l[1]/c[1]]}var ne=(e,n)=>Math.round(e*10**n)/10**n||0;function ke(e,n,t,o=[1,1]){return{Pan:ne(e.position_x*n/o[0],3),Tilt:ne(-e.position_y*t/o[1],3),ZoomX:ne(e.scale_x/100/o[0],5),ZoomY:ne(e.scale_y/100/o[1],5),RotationAngle:ne(-e.rotation,3),FlipX:e.flip_h,FlipY:e.flip_v}}function Ye(e,n,t,o){let s=(n.scaleX??n.scale??100)/100,r=n.rotation*Math.PI/180,a=Math.cos(r),u=Math.sin(r),m=e.position_x*t,c=e.position_y*o;return{...e,scale_x:e.scale_x*s,scale_y:e.scale_y*s,rotation:e.rotation+n.rotation,position_x:(n.posX*t+s*(a*m-u*c))/t,position_y:(n.posY*o+s*(u*m+a*c))/o}}var De=e=>({scale_x:e.scaleX??e.scale??100,scale_y:e.scaleY??e.scale??100,position_x:e.posX,position_y:e.posY,rotation:e.rotation,flip_h:e.flipH,flip_v:e.flipV}),Pe=e=>(e.scale??100)===100&&(e.scaleX??100)===100&&(e.scaleY??100)===100&&!e.posX&&!e.posY&&!e.rotation&&!e.cropL&&!e.cropR&&!e.cropT&&!e.cropB&&!e.flipH&&!e.flipV,zn=["edit","input","node"];function Le(e){let n=e.node,t=typeof n=="object"&&n?n:{layer:e.layer??1,node:n};return{...t.node!==void 0&&t.node!==""?{node:t.node}:{},...t.layer&&t.layer!==1?{layer:t.layer}:{}}}var pn={aligned:"Green",animated:"Yellow",no_match:"Red",refused:"Red"};async function dn(e,n){let t=n.offline_reference,o=de(n),s=o,r=Math.max(...n.tracks.flatMap(k=>k.items.map(w=>w.timeline_range.start.value+w.timeline_range.duration.value)),0),a=k=>({kind:"Video",track_index:Math.max(0,...ue(n).map(w=>w.track_index))+1,name:"OFFLINE REFERENCE",enabled:!0,items:k});if(t?.session_id){let{getSession:k}=await import("./store-SZKXADGI.js"),w=(await k(t.session_id)).session,$=w.timelines.find(z=>z.kind==="primary")??w.timelines[0],A=(n.start_frame??0)+(t.frame_offset??0)-($.start_frame??0),C=ue($).filter(z=>z.enabled!==!1).flatMap(z=>z.items.filter(E=>E.kind==="clip"&&E.enabled!==!1&&E.media_reference_id).map(E=>({i:E,top:z.track_index}))),N=[...new Set(C.flatMap(({i:z})=>[z.timeline_range.start.value,z.timeline_range.start.value+z.timeline_range.duration.value]))].sort((z,E)=>z-E),Z=[];for(let z=0;z+1<N.length;z++){let[E,G]=[N[z],N[z+1]],K=C.filter(({i:Y})=>Y.timeline_range.start.value<=E&&E<Y.timeline_range.start.value+Y.timeline_range.duration.value).sort((Y,v)=>v.top-Y.top)[0],[i,b]=[Math.max(0,E-A),Math.min(r,G-A)];if(!K||b<=i)continue;let _=K.i,T=Z.at(-1);if(T&&T.from===_.id&&T.timeline_range.start.value+T.timeline_range.duration.value===i){T.timeline_range.duration.value+=b-i,T.source_range.duration.value+=b-i;continue}let{id:p,timeline_range:y,source_range:g,media_reference_id:I,keyframes:d,...S}=_;Z.push({...S,id:`offline-ref-${Z.length}`,from:_.id,kind:"clip",enabled:!0,media_reference_id:`offref:${I}`,timeline_range:{start:{value:i,rate:s},duration:{value:b-i,rate:s}},source_range:{start:{value:g.start.value+(i+A-_.timeline_range.start.value),rate:g.start.rate},duration:{value:b-i,rate:g.start.rate}}})}if(!Z.length)throw new ce("not_found",`the offline reference timeline "${$.name}" has no picture over this timeline`);let Q=new Set(Z.map(z=>String(z.media_reference_id).slice(7)));return{lane:a(Z),media:w.media_references.filter(z=>Q.has(z.id)).map(z=>({...z,id:`offref:${z.id}`})),name:`timeline ${$.name}`}}let u=t?.media_reference_id?e.media_references.find(k=>k.id===t.media_reference_id):void 0,m=u?.local_path??u?.target_url?.replace(/^file:\/\//,"");if(!u||!m)throw new ce("not_found","this timeline has no offline reference linked in Resolve (Timeline \u203A Link Offline Reference Clip): a movie or another timeline");let{probeMedia:c}=await import("./media-3YMIZSSF.js"),l=await c(m),f=l.source_timecode?we(l.source_timecode,o,null):0,h=l.available_range?.duration?.value??l.declared_duration?.value??null,x=(n.start_frame??0)+(t.frame_offset??0)-f;h!=null&&(x>=h||x+r<=0)&&(x=t.frame_offset??0);let M=h!=null?Math.max(1,Math.min(r,h-x)):r;return{lane:a([{id:"offline-reference",kind:"clip",name:u.name??"offline reference",enabled:!0,media_reference_id:u.id,timeline_range:{start:{value:0,rate:s},duration:{value:M,rate:s}},source_range:{start:{value:x,rate:s},duration:{value:M,rate:s}}}]),media:[],name:u.name??ln(m)}}async function In(e,n,t,o){if(n.reference_track!=="offline")return await Ze(e,n,t,o);let s=xe(e,n.timeline_id),{lane:r,media:a,name:u}=await dn(e,s);s.tracks.push(r),e.media_references.push(...a);try{return{...await Ze(e,{...n,reference_track:ue(s).length,reference_label:"the offline reference"},t,o),reference:`the offline reference (${u})`}}finally{s.tracks.splice(s.tracks.indexOf(r),1),e.media_references=e.media_references.filter(m=>!a.includes(m))}}async function Ze(e,n,t,o){let s=xe(e,n.timeline_id),r=s.resolution_w,a=s.resolution_h,u=ue(s),m=u.findIndex(i=>/\b(ref|reference|offline)\b/i.test(String(i.name??""))),c=n.reference_track||(m>=0?m+1:u.length),l=u[c-1];if(!l)throw new Error(`no video track V${c} (the timeline has ${u.length})`);if(n.tracks?.includes(c))throw new ce("invalid_args",`the track to align cannot be the reference track (V${c})`);let f=(n.tracks?.length?n.tracks:u.map((i,b)=>b+1).filter(i=>u[i-1].enabled!==!1)).filter(i=>i!==c);for(let i of f)if(!u[i-1])throw new Error(`no video track V${i} (the timeline has ${u.length})`);let h=n.input_scaling??"fit",x=n.sizing_target??"edit",M=600,k=(i,b)=>{let _=Math.max(1,b-i);if(n.samples==="ends")return[...new Set([0,.25,.5,.75,1].map(y=>i+Math.round(y*(Math.max(i,b-1)-i))))];let T=(n.samples??"half")==="half"&&!n.step?Math.max(1,Math.round(de(s)/2)):n.step,p=n.samples==="all"?Math.max(1,Math.ceil(_/M)):T?Math.max(1,Math.floor(T),Math.ceil(_/M)):0;if(p){let y=[];for(let g=i;g<b;g+=p)y.push(g);return y.at(-1)!==b-1&&y.push(b-1),y}return je(i,b,Math.max(1,Math.min(M,Math.floor(Number(n.samples))||1)))},w=Number(s.start_frame??0),$=[],A=[],C=pe(l),N=n.scope??"all",Z=new Set(n.picks??[]);if(N==="selected"&&!Z.size)throw new Error("no clips selected: select clips in the timeline, or align the whole timeline");for(let i of f)for(let b of pe(u[i-1])){let[_,T]=D(b);if(N==="playhead"&&!(_<=(n.at??-1)&&(n.at??-1)<T)||N==="selected"&&!Z.has(`${i}:${_}`))continue;let p={item_id:b.id,name:b.name??b.id,track:i,start:_,end:T,record_tc:ae(s,_),verdict:"refused",confidence:null,samples:[]};$.push(p);let y=R=>{p.reason=R};if(b.enabled===!1){y("disabled");continue}let g,I=0,d=0;for(let R of C){let[O,H]=D(R),P=Math.max(_,O),U=Math.min(T,H);U-P>d-I&&(g=R,I=P,d=U)}if(!g){if(n.reference_label){y(`${n.reference_label} does not cover it (${ae(s,_)}\u2013${ae(s,T)}): it ends before this clip`);continue}let R=l.items.find(O=>{let[H,P]=D(O);return O.kind!=="clip"&&O.kind!=="gap"&&Math.min(T,P)>Math.max(_,H)});y(R?`V${c} has ${/compound|stack|timeline/i.test(String(R.kind))?"a compound clip or nested timeline":`a ${R.kind}`} over it, not a movie clip: Align reads a media file there (decompose it, or use Offline ref)`:C.length?`nothing on V${c} over it (${ae(s,_)}\u2013${ae(s,T)}): the reference does not cover this clip`:`V${c} has no movie clips: pick the track the reference is on, or Offline ref`);continue}let S=se(e,g),Y=se(e,b);if(!S.path){y(`the reference clip ${g.name??g.id} is not linked (timeline_relink first)`);continue}if(!Y.path){y("not linked (timeline_relink first)");continue}let v=k(I,d),B=re(g,I),F=Pe(B)?void 0:B;if(F){let R=F.scaleX??F.scale??100,O=F.scaleY??F.scale??100,H=F.animated||v.some(P=>JSON.stringify(re(g,P))!==JSON.stringify(B))?"keyframed":Math.abs(R-O)>1e-6?"scaled unevenly":F.cropL||F.cropR||F.cropT||F.cropB?"cropped":F.flipH||F.flipV?"flipped":F.anchorX||F.anchorY?"anchored off centre":x!=="edit"?"resized (Colour-page sizing is solved against an unresized reference only)":"";if(H){y(`the reference clip ${g.name??g.id} is ${H}; the fit is against its raw picture`);continue}}if(S.w>0&&S.h>0&&Math.abs(S.w/S.h-r/a)>.01*(r/a)){y(`the reference ${S.w}x${S.h} does not fill the ${r}x${a} frame`);continue}let ee=R=>R.map(O=>({ref:S.path,refFrame:ye(g,O),src:Y.path,srcFrame:ye(b,O)})),X=Array.from({length:d-I},(R,O)=>I+O),L=re(b,_);A.push({row:p,item:b,recs:v,every:X,refT:F,ask:{pairs:ee(v),every:ee(X),every_t:X.map(R=>R-_),edit:De(L),edit_identity:Pe(L),edit_animated:!!L.animated,anchor_off:!!(L.anchorX||L.anchorY),...n.inputs?.get(`${i}:${_+w}`)?.length?{input:n.inputs.get(`${i}:${_+w}`)}:{}}})}let Q=A.length?await me({op:"reframe",items:A.map(i=>i.ask),out:[r,a],target:x},t,o):{items:[],offsets:[]},z=Q.offsets;Q.items.forEach((i,b)=>{let{row:_,item:T,recs:p,every:y,ask:g,refT:I}=A[b];if(I&&(i.verdict==="animated"&&Object.assign(i,{verdict:"refused",reason:"a move under a resized reference is not solved yet",keys:void 0,edit_keys:void 0,grade_keys:void 0}),i.transform&&(i.transform=Ye(i.transform,I,r,a)),i.edit_transform&&(i.edit_transform=Ye(i.edit_transform,I,r,a)),i.transform)){let v=g.edit,B=i.transform,F=.5/r;i.unchanged=Math.abs(B.scale_x-v.scale_x)<.05&&Math.abs(B.scale_y-v.scale_y)<.05&&Math.abs(B.position_x-v.position_x)<F&&Math.abs(B.position_y-v.position_y)<.5/a&&Math.abs(B.rotation-v.rotation)<.02}let d=i.measured==="every"?y:p,S=i.measured==="every"?g.every:g.pairs,Y=(({w:v,h:B})=>He(v,B,r,a,Ge(T,s,n.input_scaling)))(se(e,T));_.samples=i.scores.map((v,B)=>({record:d[i.at[B]],ref_frame:S[i.at[B]].refFrame,src_frame:S[i.at[B]].srcFrame,score:v})),Object.assign(_,{verdict:i.verdict,confidence:i.confidence,...i.reason?{reason:i.reason}:{},...i.label?{label:i.label}:{},...i.unchanged?{unchanged:!0}:{},...i.grade_sizing?{grade_sizing:i.grade_sizing}:{}}),i.transform&&(_.transform=i.transform,_.properties=ke(i.edit_transform??i.transform,r,a,Y)),i.keys?.length&&(_.keys=i.keys.map(v=>({record:d[i.at[v.j]],transform:v.transform,properties:ke(v.transform,r,a,Y),confidence:v.confidence}))),i.grade_keys?.length&&(_.grade_keys=i.grade_keys.map(({shape:v,...B})=>v?.kind==="resolve_dissolve"?{...B,ease_in:v.start,ease_out:v.end}:B),_.grade_keys[0].t>0&&_.grade_keys.unshift({..._.grade_keys[0],t:0,ease_in:void 0,ease_out:void 0})),i.edit_keys?.length&&(_.edit_keys=i.edit_keys[0].t>0?[{...i.edit_keys[0],t:0,shape:void 0},...i.edit_keys]:i.edit_keys)});let E=[];for(let i of $){let b={track:i.track,start:i.start};if(i.verdict==="aligned"&&x==="edit"&&!i.unchanged){let _=i.properties;E.push({op:"properties",item:b,set:{..._.ZoomX!==_.ZoomY?{ZoomGang:!1}:{},..._}})}if(i.verdict==="animated"&&i.edit_keys&&E.push({op:"edit_keys",item:b,keys:i.edit_keys}),i.verdict==="animated"&&i.grade_keys&&E.push({op:"grade_sizing",item:b,target:x==="node"?"node":"input",keys:i.grade_keys,...x==="node"?Le(n):{}}),i.verdict==="aligned"&&i.grade_sizing&&!i.unchanged&&E.push({op:"grade_sizing",item:b,target:x,...i.grade_sizing,...x==="node"?Le(n):{}}),n.markers??!0){let _={aligned:"Aligned",animated:"Animated",no_match:"No match",refused:"Not aligned"}[i.verdict],T=[i.label,i.confidence!=null?`confidence ${i.confidence}`:"",i.reason].filter(Boolean).join(" \xB7 ");E.push({op:"marker_add",frame:i.start,color:pn[i.verdict],name:`${_}: ${i.name}`,note:T,data:"ConformTools:align"})}}let G;if(n.apply_session){G=0;for(let i of $.filter(b=>b.verdict==="aligned")){let b=i.transform;$e(e,"transform",{timeline_id:s.id,item_id:i.item_id,scale:b.scale_x,position_x:b.position_x,position_y:b.position_y,rotation:b.rotation});let _=s.tracks.flatMap(T=>T.items).find(T=>T.id===i.item_id);Math.abs(b.scale_x-b.scale_y)>.001&&(_.scale_x=b.scale_x,_.scale_y=b.scale_y),b.flip_h?_.flip_horizontal=!0:delete _.flip_horizontal,b.flip_v?_.flip_vertical=!0:delete _.flip_vertical,G++}}let K={aligned:0,animated:0,no_match:0,refused:0};for(let i of $)K[i.verdict]++;return{timeline:s.name??s.id,raster:[r,a],reference_track:c,rows:$,counts:K,ops:E,...G!=null?{applied:G}:{},input_scaling:h,sizing_target:x,...z.length?{offsets:z}:{}}}function Rn(e){let n=e.counts,t=`${e.timeline} (${e.raster.join("x")}): ${n.aligned} aligned, ${n.animated} animated, ${n.no_match} no match, ${n.refused} not aligned \u2014 against ${e.reference??`V${e.reference_track}`}${e.input_scaling!=="fit"?` (Resolve units for input scaling "${e.input_scaling}")`:""}${e.sizing_target!=="edit"?`; written as Color-page ${e.sizing_target==="input"?"Input Sizing":"node Sizing"} on top of each clip's own edit transform`:""}${e.sizing_target==="edit"&&n.animated?`; the ${n.animated} moving clip(s) get Edit-page keyframes on a copy of the timeline, "${e.timeline} ALIGNED" (Resolve cannot keyframe the Edit page from a script; the copy carries every grade and setting)`:""}${e.applied!=null?`; ${e.applied} transform(s) written into the session`:""}`,o=r=>{let a=r.properties,u=r.grade_sizing,m=u?` \u2192 ${e.sizing_target} sizing Zoom ${u.zoom}${u.height!==1?` Height ${u.height}`:""} Pan ${u.pan} Tilt ${u.tilt} Rotate ${u.rotation}${u.flip_x?" FlipH":""}${u.flip_y?" FlipV":""}`:a?` \u2192 Pan ${a.Pan} Tilt ${a.Tilt} Zoom ${a.ZoomX}${a.ZoomY!==a.ZoomX?`/${a.ZoomY}`:""} Rot ${a.RotationAngle}${a.FlipX?" FlipX":""}${a.FlipY?" FlipY":""}`:"",c=r.grade_keys?.length?` \u2192 ${r.grade_keys.length} keyframes (${e.sizing_target==="node"?"node":"Input"} Sizing)`:r.edit_keys?.length?` \u2192 ${r.edit_keys.length} Edit-page keyframes`:"";return` V${r.track} ${r.record_tc} ${r.name}: ${r.verdict.toUpperCase()}${r.label?` (${r.label})`:""}${m}${c}${r.confidence!=null?`, confidence ${r.confidence}`:""}${r.reason?` \u2014 ${r.reason}`:""}`},s=(e.offsets??[]).map(r=>` the reference differs from the ${r.raster} online by ${r.label} on ${r.clips} of ${r.of} clips: a render / decode difference, not sizing \u2014 taken out of every clip, never written`);return[t,...s,...e.rows.map(o),`host_apply ops ready: ${e.ops.filter(r=>r.op==="properties"||r.op==="grade_sizing").length} ${e.sizing_target==="edit"?"properties":"grade_sizing"}, ${e.ops.filter(r=>r.op==="marker_add").length} markers (data "ConformTools:align")`].join(`
|
|
4
|
-
`)}var he={"16:9":16/9,"1.85":1.85,"2.00":2,"2.20":2.2,"2.35":2.35,"2.39":2.39,"2.76":2.76,"4:3":4/3,"1:1":1,"9:16":9/16,none:null};function bn(e){if(e==null)return null;if(typeof e=="number")return e>0?e:null;if(e in he)return he[e];let n=/^(\d+(?:\.\d+)?)(?:[:/](\d+(?:\.\d+)?))?$/.exec(e.trim());if(!n)throw new Error(`aspect '${e}': one of ${Object.keys(he).join(", ")}, or a ratio like 1.66 or 3:2`);let t=n[2]?Number(n[1])/Number(n[2]):Number(n[1]);return t>0?t:null}function On(e,n,t){let o=n/t,s=a=>{let u=Math.round(a);return u-u%2};if(!(e>0)||Math.abs(o-e)/e<.002)return{top:0,bottom:0,left:0,right:0};if(e>o){let a=s((t-n/e)/2);return{top:a,bottom:a,left:0,right:0}}let r=s((n-t*e)/2);return{top:0,bottom:0,left:r,right:r}}function Ve(e,n,t){let o=[],s=e;for(let[r,a]of t)if(!(a<=s)&&(r>=n||(r>s&&o.push([s,Math.min(r,n)]),s=Math.max(s,a),s>=n)))break;return s<n&&o.push([s,n]),o}function Ke(e,n,t){let o=[...e,[n,t]].sort((r,a)=>r[0]-a[0]),s=[];for(let r of o){let a=s.at(-1);a&&r[0]<=a[1]?a[1]=Math.max(a[1],r[1]):s.push([r[0],r[1]])}return s}async function Cn(e,n,t,o){let s=xe(e,n.timeline_id),r=s.resolution_w,a=s.resolution_h,u=bn(n.aspect),m=Fe(n.strictness,{tolerance_px:n.tolerance_px,min_frames:n.min_frames,gap_frames:n.gap_frames,black_threshold:n.black_threshold}),c=!!n.pixels,l=Math.max(1,Math.min(12,Math.floor(n.samples??3))),f=ue(s),h=f.filter(p=>p.enabled!==!1),x=[],M=[],k=p=>{let y=se(e,p);if(!(y.w>0&&y.h>0))return!1;let[g,I]=Xe(r,a,y.w,y.h),d=re(p,D(p)[0]);return!d.animated&&Math.abs(g-r)<.5&&Math.abs(I-a)<.5&&(d.scaleX??d.scale??100)===100&&(d.scaleY??d.scale??100)===100&&!d.posX&&!d.posY&&!d.rotation&&!d.cropL&&!d.cropR&&!d.cropT&&!d.cropB},w=new Map,$=[];for(let p of h)w.set(p,$),$=pe(p).filter(y=>y.enabled!==!1&&k(y)).reduce((y,g)=>Ke(y,...D(g)),$);let A=[];for(let p of[...h].reverse()){let y=pe(p).filter(d=>d.enabled!==!1),g=y.reduce((d,S)=>Ke(d,...D(S)),A),I=f.indexOf(p)+1;for(let d of y){let[S,Y]=D(d),v=w.get(p)??[],B=Ve(S,Y,A).flatMap(([P,U])=>Ve(P,U,v));if(!B.length)continue;let F=se(e,d);if(!(F.w>0&&F.h>0)){x.push({item_id:d.id,name:d.name??d.id,track:I,reason:"the source raster is unknown (timeline_relink the clip first)"});continue}c&&!F.path&&x.push({item_id:d.id,name:d.name??d.id,track:I,reason:"not linked: its source frames were not measured (timeline_relink first); its transform was checked"});let[ee,X]=Xe(r,a,F.w,F.h),L=re(d,S).animated,R=P=>Be(re(d,P),ee,X),O=[],H=new Map;for(let[P,U]of B){let J=new Set(c&&F.path?je(P,U,l):[]),W=new Set(L?Array.from({length:U-P},(V,q)=>P+q):J.size?[]:[P]);for(let V of J)W.add(V);let oe=[...W].sort((V,q)=>V-q);oe.forEach((V,q)=>{H.set(V,[q?V:P,oe[q+1]??U]),O.push({rec:V,place:R(V),...J.has(V)?{src:ye(d,V)}:{}})})}M.push({item:d,track:I,path:F.path,frames:O,hold:H,animated:L,box:[ee,X]})}A=g}let C=M.length?await me({op:"blanking",items:M.map(p=>({path:p.path,frames:p.frames})),out:[r,a],aspect:u},t,o):{items:[],target:[0,0,r,a]},N=C.target,Z=[],Q=new Map,z=0;C.items.forEach((p,y)=>{let g=M[y],I=new Map;Q.set(g.item.id,I);for(let d of p){if(d.bars&&z++,d.black||!d.edges.some(v=>v>0))continue;let[S,Y]=g.hold.get(d.rec);for(let v=S;v<Y;v++)Z.push({pts:v,bt:d.edges[0],bb:d.edges[1],bl:d.edges[2],br:d.edges[3],source:d.bars?"pixels":"geometry"}),I.set(v,d.zoom)}});let E=M.map(p=>({id:p.item.id,name:p.item.name??p.item.id,start:D(p.item)[0],end:D(p.item)[1],track:p.track})),K=Ee(Z,E,0,Math.round(N[2]-N[0]),Math.round(N[3]-N[1]),{tolerance_px:m.tolerance_px,min_frames:m.min_frames,gap_frames:m.gap_frames}).map(p=>{let y=1,g=Q.get(p.clip.id);for(let I=p.start_frame;I<=p.end_frame;I++){if(!g.has(I))continue;let d=g.get(I);y=d==null||y==null?null:Math.max(y,d)}return{item_id:p.clip.id,name:p.clip.name,track:p.clip.track,record_start:p.start_frame,record_end:p.end_frame,record_tc:ae(s,p.start_frame),frames:p.duration_frames,edges:{top:p.measured.bt,bottom:p.measured.bb,left:p.measured.bl,right:p.measured.br},zones:p.zones,sources:p.sources,zoom_fix:y}}),i=[],b=new Map;for(let p of K)b.set(p.item_id,[...b.get(p.item_id)??[],p]);let _=new Map,T=async(p,y)=>{let I=(await me({op:"blanking",items:[{path:null,frames:p.frames.map(S=>({rec:S.rec,place:Be(y,p.box[0],p.box[1])}))}],out:[r,a],aspect:u},void 0,o)).items[0]??[],d=[0,1,2,3].map(S=>Math.max(0,...I.map(Y=>Y.edges[S])));return{ok:d.every(S=>S<=m.tolerance_px),edges:d}};for(let[p,y]of b){let g=M.find(X=>X.item.id===p);if(g.animated)continue;let I=se(e,g.item),d={track:g.track,start:D(g.item)[0]},S=re(g.item,D(g.item)[0]),Y=X=>ke(De(X),r,a,He(I.w,I.h,r,a,Ge(g.item,s,n.input_scaling))),v;if(y.every(X=>X.sources.every(L=>L==="geometry"))){let X=["top","bottom","left","right"].map(R=>Math.max(...y.map(O=>O.edges[R]))),L=[];if(S.rotation&&Math.abs(S.rotation)<1){let R={...S,rotation:0},O=await T(g,R);O.ok?v={t:R,what:`rotation ${ne(S.rotation,2)}\xB0 removed`}:L.push({t:R,what:`rotation ${ne(S.rotation,2)}\xB0 removed, `,edges:O.edges})}L.push({t:S,what:"",edges:X});for(let R of v?[]:L){let[O,H,P,U]=R.edges,J=P-U,W=O-H;if(!(!J&&!W)){for(let[oe,V]of[[1,1],[-1,1],[1,-1],[-1,-1]]){let q={...R.t,posX:R.t.posX+oe*J/g.box[0],posY:R.t.posY+V*W/g.box[1]};if((await T(g,q)).ok){v={t:q,what:`${R.what}pan / tilt ${[J&&`${J>0?"+":""}${J} px across`,W&&`${W>0?"+":""}${W} px up/down`].filter(Boolean).join(", ")}`};break}if(!W&&V===1&&oe===-1)break}if(v)break}}}if(v){let X=Y(S),L=Y(v.t),R=Object.fromEntries(["Pan","Tilt","RotationAngle"].filter(O=>L[O]!==X[O]).map(O=>[O,L[O]]));i.push({op:"properties",item:d,set:R}),_.set(p,`${v.what} fills it`);for(let O of y)O.fix=v.what;continue}if(y.some(X=>X.zoom_fix==null))continue;let B=Math.max(...y.map(X=>X.zoom_fix)),F=Y(S),ee=X=>Math.ceil(X*B*1e5)/1e5;i.push({op:"properties",item:d,set:{ZoomX:ee(F.ZoomX),ZoomY:ee(F.ZoomY)}})}if(n.markers??!0)for(let p of K){let y=M.find(d=>d.item.id===p.item_id),g=p.zones.map(d=>`${d} ${p.edges[d.toLowerCase()]} px`).join(" \xB7 "),I=y.animated?"keyframed sizing: fix the keys":_.get(p.item_id)??(p.zoom_fix==null?"no zoom about its anchor fills it":`zoom \xD7${p.zoom_fix} fills it`);i.push({op:"marker_add",frame:p.record_start,duration:p.frames,color:"Red",name:`Blanking: ${p.name}`,note:`${g} (${p.sources.join("+")}) \u2014 ${I}`,data:"ConformTools:blanking"})}return{timeline:s.name??s.id,raster:[r,a],aspect:u,target:N,strictness:m,pixels:c,clips_checked:M.length,frames_measured:z,findings:K,refused:x,ops:i}}function Fn(e){return[`${e.findings.length?`BLANKING: ${e.findings.length} range(s) on ${new Set(e.findings.map(t=>t.item_id)).size} clip(s)`:"CLEAN: no clip shows black"} \u2014 ${e.timeline} ${e.raster.join("x")}${e.aspect?`, delivered ${ne(e.aspect,3)}:1 (black counted inside it only)`:""}; ${e.strictness.preset} (${e.strictness.tolerance_px} px, ${e.strictness.min_frames} frame(s)); ${e.clips_checked} clip(s) by their transform${e.pixels?`, ${e.frames_measured} source frame(s) measured for their own black edges`:" (pixels:false: a black edge baked into a source is not seen)"}`,...e.findings.map(t=>` V${t.track} ${t.record_tc} ${t.name} (${t.frames} frame${t.frames>1?"s":""}): ${t.zones.map(o=>`${o} ${t.edges[o.toLowerCase()]} px`).join(", ")} [${t.sources.join("+")}]${t.zoom_fix?` \u2014 zoom \xD7${t.zoom_fix} fills it`:" \u2014 no zoom about its anchor fills it"}`),...e.refused.map(t=>` V${t.track} ${t.name}: ${t.reason}`),`host_apply ops ready: ${e.ops.filter(t=>t.op==="properties").length} ZoomX/ZoomY fixes, ${e.ops.filter(t=>t.op==="marker_add").length} markers (data "ConformTools:blanking")`].join(`
|
|
5
|
-
`)}export{_e as a,Fe as b,Ee as c,yn as d,kn as e,fn as f,Ge as g,He as h,ke as i,Ye as j,zn as k,dn as l,In as m,Rn as n,he as o,bn as p,On as q,Cn as r,Fn as s};
|