conformtools 0.6.17 → 0.6.19

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 (98) hide show
  1. package/README.md +3 -2
  2. package/dist/account-KSE6H6DJ.js +3 -0
  3. package/dist/{agent-hook-setup-HBT2LTVR.js → agent-hook-setup-SHZOVJYL.js} +1 -1
  4. package/dist/{analysis-engine-BZUEBW55.js → analysis-engine-KUGSWNQB.js} +1 -1
  5. package/dist/{bridge-DRC6BQFR.js → bridge-REYIYXUU.js} +1 -1
  6. package/dist/browser/timeline_core_bg.wasm +0 -0
  7. package/dist/{chunk-MTAXVOHK.js → chunk-2DEUYEQD.js} +1 -1
  8. package/dist/{chunk-STGGRRYM.js → chunk-2GRXBIJB.js} +1 -1
  9. package/dist/{chunk-GRJLKGBG.js → chunk-3DYCTUSQ.js} +1 -1
  10. package/dist/{chunk-M5CEBOLK.js → chunk-3J2FARFO.js} +1 -1
  11. package/dist/chunk-4KMSOMLG.js +524 -0
  12. package/dist/chunk-4PV2UTKG.js +10 -0
  13. package/dist/{chunk-RITYQNOO.js → chunk-567IWIX6.js} +1 -1
  14. package/dist/{chunk-73RFYAVG.js → chunk-ATEWMIY5.js} +1 -1
  15. package/dist/{chunk-TWHNQFKI.js → chunk-BD54PRSN.js} +1 -1
  16. package/dist/{chunk-NN444GPH.js → chunk-BZQAUU3D.js} +1 -1
  17. package/dist/chunk-COALWMI7.js +4 -0
  18. package/dist/{chunk-JT3HI632.js → chunk-CUZVK2JJ.js} +1 -1
  19. package/dist/{chunk-MVQ5RGZB.js → chunk-EWW5KWAO.js} +1 -1
  20. package/dist/{chunk-CRMGV32N.js → chunk-GTN62ZQV.js} +1 -1
  21. package/dist/{chunk-S5AOIOTT.js → chunk-HKHEL4MZ.js} +1 -1
  22. package/dist/chunk-HZG55H3B.js +3 -0
  23. package/dist/{chunk-QNF4NMIW.js → chunk-L2RTMZCN.js} +1 -1
  24. package/dist/{chunk-UBWUED67.js → chunk-LUKA7UUJ.js} +1 -1
  25. package/dist/chunk-MJKISVPS.js +7 -0
  26. package/dist/{chunk-IG2X534U.js → chunk-ND2YUUUH.js} +1 -1
  27. package/dist/{chunk-2VH2Z6RD.js → chunk-NHVH373D.js} +1 -1
  28. package/dist/chunk-NQD6H7SY.js +7 -0
  29. package/dist/chunk-PY6HS3EP.js +10 -0
  30. package/dist/{chunk-YGAAGTLE.js → chunk-TD3ZHREE.js} +1 -1
  31. package/dist/chunk-UWEM5YEM.js +161 -0
  32. package/dist/{chunk-R2WEXCVQ.js → chunk-WM7ESQLY.js} +1 -1
  33. package/dist/{chunk-2SDAOYP5.js → chunk-WNDA7QSY.js} +1 -1
  34. package/dist/{chunk-S2WAFMRV.js → chunk-XQON6ASI.js} +1 -1
  35. package/dist/chunk-Y7PFSVRX.js +3 -0
  36. package/dist/{claude-setup-W27DLJIO.js → claude-setup-ZOEQ5NXE.js} +1 -1
  37. package/dist/cli.js +2 -2
  38. package/dist/{cr3-wasm-VUEEZYKQ.js → cr3-wasm-DIWL7CPH.js} +1 -1
  39. package/dist/demo-engine-ZX24TAXA.js +3 -0
  40. package/dist/{dng-wasm-5RQBGYAK.js → dng-wasm-PE463PG2.js} +1 -1
  41. package/dist/{dpx-wasm-OQVTNGOB.js → dpx-wasm-DKE3LJ6Z.js} +1 -1
  42. package/dist/engine-K6QYU5KJ.js +5 -0
  43. package/dist/{exr-wasm-72YZFOME.js → exr-wasm-HAFH3YA5.js} +1 -1
  44. package/dist/framing-B6LP7MS2.js +3 -0
  45. package/dist/gfx-worker.js +1 -1
  46. package/dist/{h264-QCYEI6RF.js → h264-YX5KP63E.js} +1 -1
  47. package/dist/{h264-mxf-2BYKXDGT.js → h264-mxf-VAHIJCA7.js} +1 -1
  48. package/dist/hook.js +3 -2
  49. package/dist/host-relink-VYEOE3NE.js +10 -0
  50. package/dist/hosted-NLYSTYYN.js +3 -0
  51. package/dist/hosts-47EW33NY.js +3 -0
  52. package/dist/http.js +4 -3
  53. package/dist/{inspect-R4RWCK3X.js → inspect-QRHOFMC2.js} +18 -18
  54. package/dist/{isobmff-RH4JKUUB.js → isobmff-RHP3N5K2.js} +1 -1
  55. package/dist/{mc-video-MMKWEKFZ.js → mc-video-CHBOYPI5.js} +1 -1
  56. package/dist/mcp.js +8 -8
  57. package/dist/media-TPGEESEU.js +3 -0
  58. package/dist/{media_core_bg-FDL7GJZP.js → media_core_bg-ZMRCKALR.js} +1 -1
  59. package/dist/{mxf-7HFFEBNW.js → mxf-R2ONKSYU.js} +1 -1
  60. package/dist/{ops-EM345H7F.js → ops-MKDFWWPG.js} +1 -1
  61. package/dist/{probe-YDOFGCGD.js → probe-CHT266NN.js} +1 -1
  62. package/dist/{r3d-DDOTSYZH.js → r3d-EKISZSKU.js} +1 -1
  63. package/dist/{r3d-G34YLXXA.js → r3d-F4OWLQE2.js} +1 -1
  64. package/dist/resolve-bridge.py +173 -27
  65. package/dist/{sequence-patch-2S7IPE52.js → sequence-patch-6FSMBG7O.js} +1 -1
  66. package/dist/{still-AGBF3OOY.js → still-IDLCMQRD.js} +1 -1
  67. package/dist/{still-wasm-6YLI6NQQ.js → still-wasm-54HEDTRX.js} +1 -1
  68. package/dist/{store-LWUDJD76.js → store-CFQHKBGL.js} +1 -1
  69. package/dist/{tiff-wasm-6APT7FYP.js → tiff-wasm-O7XUGXIO.js} +1 -1
  70. package/dist/timeline-MZ6A3PQX.js +3 -0
  71. package/dist/timeline_core-6BRZG4LP.js +3 -0
  72. package/dist/{wav-CV43ZAJI.js → wav-OLA3QYFJ.js} +1 -1
  73. package/package.json +5 -5
  74. package/dist/account-VXAKXGY6.js +0 -3
  75. package/dist/chunk-CZ6OZKR6.js +0 -516
  76. package/dist/chunk-GTPTZRO6.js +0 -3
  77. package/dist/chunk-JTRM2JCE.js +0 -7
  78. package/dist/chunk-LVGGCRDW.js +0 -3
  79. package/dist/chunk-P4PCSGEH.js +0 -10
  80. package/dist/chunk-ROGMKTND.js +0 -4
  81. package/dist/chunk-T7S2UBNN.js +0 -7
  82. package/dist/chunk-VCBLWNQR.js +0 -160
  83. package/dist/chunk-WKNX742H.js +0 -10
  84. package/dist/demo-engine-5TCNOTTH.js +0 -3
  85. package/dist/engine-4X6TDWWA.js +0 -5
  86. package/dist/framing-HGW5RCUA.js +0 -3
  87. package/dist/host-relink-37DCSN47.js +0 -10
  88. package/dist/hosted-M2OZSONX.js +0 -3
  89. package/dist/hosts-IAJTORJD.js +0 -3
  90. package/dist/media-6MB7EKA7.js +0 -3
  91. package/dist/timeline-EZ6WUHCB.js +0 -3
  92. package/dist/timeline_core-ZKQQHUA2.js +0 -3
  93. /package/dist/{arriraw-GZ63YMLZ.js → arriraw-PS6V532Y.js} +0 -0
  94. /package/dist/{chunk-D6YDLKSA.js → chunk-LMRPCWHV.js} +0 -0
  95. /package/dist/{media_core_bg-XRBVKQZH.js → media_core_bg-57CDWER6.js} +0 -0
  96. /package/dist/{prores-RIG37OIH.js → prores-CFX64NME.js} +0 -0
  97. /package/dist/{timeline_core_bg-JW42YM3G.js → timeline_core_bg-5COJCLPG.js} +0 -0
  98. /package/dist/{udf_bg-B37GKRIH.js → udf_bg-HOHEKAVF.js} +0 -0
@@ -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 M}from"./chunk-3PVQ5QP4.js";import{b as ge,c as we,f as _e}from"./chunk-VFXMP7IF.js";import{f as X,h as he}from"./chunk-2DEUYEQD.js";import{a as be}from"./chunk-TD3ZHREE.js";import{i as N}from"./chunk-ND2YUUUH.js";import{b as F,d as T,f as E}from"./chunk-NU3X7P4N.js";import{Ha as pe,ea as ce,fa as le,ja as ue,oa as me,wa as de,xa as fe}from"./chunk-L2RTMZCN.js";import{a as ae}from"./chunk-COALWMI7.js";import{$ as b,B as K,G as V,N as $,O as D,P as ie,S as se,aa as y,b as A,ba as z,c as ee,ca as _,d as re,g as te,k as ne,l as j,s as W,t as L,v as oe,w as R,z as J}from"./chunk-HZG55H3B.js";var G=!1,P=8,Ae=0,De=3,k=2;async function ze(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),n=s=>String.fromCharCode(t[s],t[s+1],t[s+2],t[s+3]);if(t[0]===6&&t[1]===14&&t[2]===43&&t[3]===52)return"mxf";if(n(4)==="RED1"||n(4)==="RED2")return"r3d";let r=t[0]<<24|t[1]<<16|t[2]<<8|t[3],i=n(4);return/^[A-Za-z0-9 ]{4}$/.test(i)&&(r>=8||r===1)&&r<=e.size?"isobmff":null}function Ne(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function Te(e){return async(t,n)=>new Uint8Array(await e.slice(t,Math.min(t+n,e.size)).arrayBuffer())}function ye(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function sr(e){return await pe(),xe?xe.clip(e,G?"rec709":"",()=>$e(e)):$e(e)}var xe=null;async function $e(e){let t=await ze(e),n=[];if(t==="r3d"){let r=e,i=r.parts&&r.bases?r.parts:[{name:e.name,size:e.size}],o=r.bases??[0],s=async(m,l,d)=>{let f=o[m]+l;return new Uint8Array(await e.slice(f,Math.min(f+d,o[m]+i[m].size)).arrayBuffer())},c=JSON.stringify(i.map(m=>({name:m.name,size:m.size}))),a=JSON.parse(await fe(s,c)),u=JSON.parse(await ue(s,c));return i.length===1&&/_\d{3}\.r3d$/i.test(e.name)&&!/_001\.r3d$/i.test(e.name)&&n.push("spanned R3D part \u2014 only this part's frames are indexed"),{frames:u.map(m=>({offset:o[m.part??0]+m.essenceOffset,size:m.essenceLength})),w:a.width??0,h:a.height??0,fps:ye(a),startFrame:a.timecode?.start_frame??0,dropFrame:a.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:Ae},geometrySpec:{codec:"r3d",subbands:De},index:null,warnings:n}}if(t==="mxf"){let r=Te(e),i=JSON.parse(await de(r,e.size));if(!i)throw new Error(`${e.name}: MXF index unreadable`);let o=JSON.parse(await me(r,e.size)),s=[];for(let f=0;f<o.frame_count;f++)s.push({offset:o.frames[f*2],size:o.frames[f*2+1]});let c=s.filter(f=>f.size===0).length;c&&n.push(`${c} frame(s) had no locatable picture KLV`);let a=i.width??0,u=i.height??0,m=(i.inner_codec??"").toLowerCase(),l=null,d="MXF";return m==="arriraw"?(l={codec:"arriraw",w:a,h:u,scale:P},d="ARRIRAW"):m==="xocn"?(l={codec:"xocn",scale:P,...G?{display:"rec709"}:{}},d="X-OCN"):await le(r,e.size)?(l={codec:"vc3",scale:P},d="DNxHR"):await ce(r,e.size)?(l={codec:"prores"},d="ProRes"):n.push(`MXF inner codec ${m||"unknown"} not wired to the fingerprint pool`),{frames:l?s:[],w:a,h:u,fps:ye(i),startFrame:i.timecode?.start_frame??0,dropFrame:i.timecode?.drop_frame??!1,label:d,spec:l,geometrySpec:l&&l.codec==="arriraw"?{...l,scale:k}:l&&l.codec==="xocn"?{codec:"xocn",scale:k,...G?{display:"rec709"}:{}}:l&&l.codec==="vc3"?{codec:"vc3",scale:k}:null,index:null,warnings:n}}if(t==="isobmff"){let r=await he(e),i=Ne(e.name);if(r.kind==="prores")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:X(r.kind),spec:{codec:"prores"},geometrySpec:null,index:r,warnings:n};if(r.kind==="h264"||r.kind==="hevc")return{frames:r.offs,w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:X(r.kind),spec:null,geometrySpec:null,index:r,warnings:n};let o=i==="braw"?{codec:"braw",scale:P}:r.codec==="aprh"||r.codec==="aprn"?{codec:"proresraw",scale:P}:null;return o||n.push(`codec ${r.codec} not wired to the fingerprint pool`),{frames:o?r.offs:[],w:r.w,h:r.h,fps:r.fps,startFrame:r.startFrame,dropFrame:r.dropFrame,label:o?i==="braw"?"BRAW":"ProRes RAW":`unsupported (${r.codec})`,spec:o,geometrySpec:o?{...o,scale:k}:null,index:r,warnings:n}}throw new Error(`${e.name}: unrecognised container`)}var Y=null;var ke=Number(A("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(re()/2),Math.floor(ee()/2**31))),Z=0,ve=[],Re=async(...e)=>{Z>=ke?await new Promise(t=>ve.push(t)):Z++;try{return await se(...e)}finally{let t=ve.shift();t?t():Z--}};async function Me(){let e=te()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[A("CONFORM_NATIVE_DECODE"),ne(e),W(new URL(`./${e}`,import.meta.url)),W(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of t)if(await oe(n))return n;return null}var v=class extends Error{constructor(n,r){super(r);this.why=n}};function Er(e){let t=null;try{t=JSON.parse(e.trim().split(`
4
+ `).pop())}catch{}if(t?.why==="not_entitled")throw new ae("not_entitled",t.detail??"this machine is not licensed");return t?.detail??e.trim()}function Fe(e,t){try{let n=JSON.parse(e.trim().split(`
5
+ `).pop()??"");return new v(n.why,n.detail)}catch{return new v("decoder",`the native decoder exited ${t}: ${e.trim().slice(-300)}`)}}function Pr(e){return Y?.owns(e)?Y.meta(`probe|${e}`,()=>Se(e)):Se(e)}async function Se(e){let t=await Me();if(!t)throw new v("missing",j("the native decoder (conformtools-decode)"));let n=[],r=await Re(t,["probe",e],i=>n.push(i));if(r.code!==0)throw Fe(r.stderr,r.code);return JSON.parse(new TextDecoder().decode(Ee(n)))}function Ee(e){let t=e.reduce((i,o)=>i+o.length,0),n=new Uint8Array(t),r=0;for(let i of e)n.set(i,r),r+=i.length;return n}async function Ue(e,t,n,r,i){let o=await Me();if(!o)throw new v("missing",j("the native decoder (conformtools-decode)"));let s=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(i.width??32768)];i.from!=null&&m.push("--from",String(i.from)),i.count!=null&&m.push("--count",String(i.count)),i.range&&m.push("--range",i.range);let l=await Re(o,m,d=>{if(c.push(d),a+=d.length,!s){let h=Ee(c.splice(0));c.push(h);let p=h.indexOf(10);if(p<0)return;s=JSON.parse(new TextDecoder().decode(h.subarray(0,p))),u(p+1),n(s)}let f=4+s.w*s.h*(s.bpp??(e==="rgb16"?6:4));for(;a>=f;){let h=u(f);r(new DataView(h.buffer).getUint32(0,!0),h.subarray(4))}},{signal:i.signal});if(l.code!==0||!s)throw Fe(l.stderr,l.code)}function Pe(e,t,n,r={}){return Ue("bgra",e,t,n,r)}var Ie=["none","rle","zips","zip","piz","pxr24","b44","b44a","dwaa","dwab","htj2k"],U=e=>(e>>4)*10+(e&15);function He(e){let t=U(e&63),n=U(e>>>8&127),r=U(e>>>16&127),i=U(e>>>24&63),o=s=>String(s).padStart(2,"0");return`${o(i)}:${o(r)}:${o(n)}${e&64?";":":"}${o(t)}`}function Be(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<8||t.getUint32(0,!0)!==20000630)return null;let n={fps:null,timecode:null,width:0,height:0,display:null,compression:null,attributes:[]},r=8,i=()=>{let s=r;for(;r<e.length&&e[r]!==0;)r++;let c=new TextDecoder().decode(e.subarray(s,r));return r++,c},o=s=>({width:t.getInt32(s+8,!0)-t.getInt32(s,!0)+1,height:t.getInt32(s+12,!0)-t.getInt32(s+4,!0)+1});for(;r<e.length;){let s=i();if(!s)break;let c=i();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(n.attributes.push(`${s}:${c}`),s==="framesPerSecond"&&c==="rational"&&a>=8){let u=t.getInt32(r,!0),m=t.getUint32(r+4,!0);n.fps=m?u/m:null}else s==="timeCode"&&c==="timecode"&&a>=8?n.timecode=He(t.getUint32(r,!0)):s==="dataWindow"&&c==="box2i"&&a>=16?{width:n.width,height:n.height}=o(r):s==="displayWindow"&&c==="box2i"&&a>=16?n.display=o(r):s==="compression"&&a>=1&&(n.compression=Ie[e[r]]??`type ${e[r]}`);r+=a}return n}async function je(e){let t=e,n=null,r=/^(.*?)\[(\d+)-(\d+)\](.*)$/.exec(b(e));if(await R(e))n=/^(.*?)(\d+)(\.exr)$/i;else{t=y(e);let o=r?[null,r[1],r[2],r[4]]:/^(.*?)(\d+)(\.exr)$/i.exec(b(e));if(!o)return{frames:[e],numbers:[]};let s=c=>c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");n=new RegExp(`^${s(o[1])}(\\d{${o[2].length}})${s(o[3])}$`,"i")}let i=[];for await(let o of $(t)){let s=o.isFile?n.exec(o.name):null;s&&i.push({n:Number(s[s.length===4?2:1]),f:_(t,o.name)})}return i.sort((o,s)=>o.n-s.n),{frames:i.map(o=>o.f),numbers:i.map(o=>o.n)}}async function Q(e){let t=await je(e),n=t.frames[0];if(!n)throw new Error(`no .exr frames for '${b(e)}'`);let r=await D(n),i;try{i=Be(await r.readAt(0,Math.min(r.size,1<<20)))}finally{await r.close()}if(!i)throw new Error(`'${b(n)}' is not an OpenEXR file`);let o=Math.max(1,t.frames.length),s=t.numbers.length>1?t.numbers[t.numbers.length-1]-t.numbers[0]+1-t.numbers.length:0,c=i.fps??0;return{id:b(n),kind:"external",target_url:n,local_path:n,content_kind:o>1?"video":"still",source_fps:i.fps??void 0,source_timecode:i.timecode??void 0,source_resolution_w:i.width,source_resolution_h:i.height,available_range:{start:{value:0,rate:c},duration:{value:o,rate:c}},streams:[{kind:"video",codec:"exr",width:i.width,height:i.height,rate:i.fps??void 0,codec_specific:{compression:i.compression}}],vendor_metadata:{exr:{frames:o,first_frame:t.numbers[0]??null,last_frame:t.numbers[t.numbers.length-1]??null,missing_frames:s,display_window:i.display,attributes:i.attributes,fps_source:i.fps!=null?"header framesPerSecond":"not in the header",timecode_source:i.timecode?"header timeCode (first frame)":"not in the header"}}}}var O=new Set([".mov",".mp4",".m4v",".mxf",".wav",".braw",".crm",".r3d",".aif",".aiff"]);async function We(e){let t=await D(e);return{path:e,file:t,size:t.size}}function Le(e){return(t,n)=>e.file.readAt(t,n)}async function Je(e){let t=M(b(e));if(!t)return[e];let n=y(e),r=[];for await(let i of $(n)){if(!i.isFile)continue;let o=M(i.name);o&&o.clipBase===t.clipBase&&r.push({n:o.partNumber,p:_(n,i.name)})}return r.sort((i,o)=>i.n-o.n).map(i=>i.p)}async function Ke(e){let t=[],n=[];for await(let r of $(e))!r.isFile||r.name.startsWith(".")||(M(r.name)?t.push(r.name):O.has(z(r.name).toLowerCase())&&n.push(r.name));if(t.length)return _(e,t.sort()[0]);if(n.length===1)return _(e,n[0]);throw n.length?(n.sort(),new Error(`'${b(e)}' is a folder of ${n.length} clips (${n.slice(0,3).join(", ")}${n.length>3?", \u2026":""}): probe one of them, or media_find to list them all`)):new Error(`'${b(e)}' is a folder with no media file in it (looked for ${[...O].join(" ")}, and RED parts)`)}async function q(e){await R(e)&&(e=await Ke(e));let t=we(b(e));if(!t)throw new Error(`unsupported media file '${b(e)}' (supported: ${[...O].join(" ")})`);let n=await Je(e),r=await Promise.all(n.map(We));return{source:_e(t,r.map(o=>ge(b(o.path),{fileSize:o.size,read:Le(o)}))),parts:r,format:t,anchor:n[0],close:()=>r.forEach(o=>o.file.close())}}async function Br(e,t,n,r){if(!/h264|avc|hevc|h265/.test(n)){let i=null,o=await q(e);try{return await N(o.source,{verb:"decode",index:t,intent:"park"})}catch(s){i=s}finally{o.close()}try{return await Oe(e,t,r)}catch(s){throw/no decoder/.test(String(i))?s:i instanceof Error?i:new Error(String(i))}}return Oe(e,t,r)}async function Oe(e,t,n){t=Math.round(t);let r=0,i=0,o=null;if(await Pe(e,c=>{r=c.w,i=c.h},(c,a)=>{c===t&&(o=a)},{from:t,count:1,width:n}),!o)throw new Error(`the OS decoder returned no frame ${t} of ${b(e)}`);let s=o;for(let c=0;c<s.length;c+=4){let a=s[c];s[c]=s[c+2],s[c+2]=a}return{rgba:s,width:r,height:i}}async function C(e){if(await R(e)){let n=[];for await(let r of $(e))r.isFile&&/\.exr$/i.test(r.name)&&!r.name.startsWith(".")&&n.push(r.name);if(n.length)return Q(_(e,n.sort()[0]))}if(/\.exr$/i.test(e))return Q(e);let t=await q(e);try{let n=await N(t.source,{verb:"inspect"});if(!n)throw new Error(`could not read '${b(e)}' as ${t.format}`);return n.target_url=t.anchor,n.local_path=t.anchor,n.id=n.id||b(t.anchor),t.parts.length>1&&((n.vendor_metadata??={}).spanned_parts=t.parts.map(r=>b(r.path))),n.size_bytes=t.parts.reduce((r,i)=>r+i.size,0),n}finally{t.close()}}function Ve(e,t,n,r){let i=Math.abs(r*1001-Math.round(r*1001/1e3)*1e3)<1?Math.round(r)*1e3/1001:r,o=Math.floor(e*i/t+1e-6);return{tc:F(o,r),frames:Math.round(n*i/t)}}var Xe=e=>String(Math.round(e*1e3)/1e3);function jr(e,t){let n=e.streams?.find(l=>l.kind==="video"),r=e.streams?.filter(l=>l.kind==="audio")??[],i=e.vendor_metadata?.bext;if(!n&&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=Ve(i?.time_reference??0,i?.sample_rate||l,d,p);return`${i?`start TC ${g.tc}, `:""}${g.frames} frames @ ${Xe(p)} fps`});return[e.target_url??"",`audio only; ${d} samples (${(d/l).toFixed(3)} s)${i?`; BWF time_reference ${i.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 o=e.available_range?.duration?.value??e.declared_duration?.value??null,s=e.source_fps??n?.rate??null,c=e.size_bytes,a=e.vendor_metadata?.spanned_parts,u=n?.codec_specific??{},m=[u.profile?`${u.profile} (${u.fourcc})`:u.fourcc,u.pixel_format,n?.bit_depth?`${n.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??"",n?`${n.codec??"?"} ${n.width??"?"}x${n.height??"?"}${s?` @ ${Math.round(s*1e3)/1e3} fps`:""}${m?`; ${m}`:""}`:"no video track",`start TC ${e.source_timecode??"none"}; ${o!=null?`${o} frames`:"length unknown"}${o!=null&&s?` (${(o/s).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 Ge=8*1024*1024,I=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0));async function Ye(e,t,n){if(e.executable_locally===!1)throw new Error("this trim plan is server-side only");let r=new Map(t.parts.map(o=>[b(o.path),o]));await K(y(n));let i=await ie(n);try{await i.truncate(e.total_size),await i.writeAt(0,I(e.dest_header_bytes_base64));for(let o of e.src_byte_ranges){let s=o.src_file_name?r.get(b(o.src_file_name)):t.parts[0];if(!s)throw new Error(`plan references unknown source part '${o.src_file_name}'`);let c=0;for(;c<o.length;){let a=Math.min(Ge,o.length-c),u=await s.file.readAt(o.offset+c,a);if(u.length<a)throw new Error(`short read in ${b(s.path)} at ${o.offset+c}`);await i.writeAt(o.write_to_dest_offset+c,u),c+=a}}e.dest_footer_bytes_base64&&e.dest_footer_offset!=null&&await i.writeAt(e.dest_footer_offset,I(e.dest_footer_bytes_base64));for(let o of e.dest_patches??[])await i.writeAt(o.offset,I(o.bytes_base64))}finally{await i.close()}for(let o of e.dest_sidecar_writes??[])await J(_(y(n),o.name),I(o.bytes_base64))}function Ze(e,t){let n=[];for(let r of e){if(r.kind!=="clip"||!r.source_range)continue;let i=r.source_range.start.value,o=r.source_range.duration.value,s=Math.max(0,Math.floor(i)-t),c=Math.floor(i+o-1)+t;c>=s&&n.push({first_frame:s,last_frame:c})}return be(n)}async function Qe(e,t,n,r,i){let o=await q(e);try{let s=Ze(t,n);if(!s.length)throw new Error("no usable frame ranges (items need kind=clip with source_range)");let c=await N(o.source,{verb:"trim",selection:{items:t,handles:n}}),a=z(o.anchor),u=o.format==="r3d",m=u?M(b(o.anchor))?.clipBase??b(o.anchor,a):b(o.anchor,a),l=[];for(let[d,f]of c.entries()){let h=f.output_clip_number??(s.length>1?d+1:void 0),p=s[(h??1)-1]??s[0],g=h&&(f.output_clip_count??s.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=i&&c.length===1?i:`${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 Ye(f,o,w)}return u||await qe(e,l,!!i&&c.length===1),{outputs:l,islands:s,format:o.format}}finally{o.close()}}async function qe(e,t,n){let r=await C(e).catch(()=>null),i=r?.source_fps??r?.streams?.find(o=>o.kind==="video")?.rate??null;if(!(!r?.source_timecode||!i))for(let o of t){if(!o.island)continue;let s=await C(o.path).catch(()=>null),c=s?.available_range?.duration?.value??s?.declared_duration?.value;if(!s?.source_timecode||!c)continue;let a=E(s.source_timecode,i,r.source_timecode);if(a===o.island.first_frame&&a+c-1===o.island.last_frame||(o.island={first_frame:a,last_frame:a+c-1},n))continue;let u=o.path.replace(/_trim_\d+-\d+(\.[^./\\]+)$/,`_trim_${a}-${a+c-1}$1`);u!==o.path&&(await V(o.path,u),o.path=u)}}async function Wr(e){let t=await C(e.path),n=t.source_fps??t.streams?.find(g=>g.kind==="video")?.rate??null,r=t.available_range?.duration?.value??t.declared_duration?.value??null;if(!n)throw new Error("cannot trim: no frame rate / timecode track on this file");let i=E(e.in,n,t.source_timecode??null),o=E(e.out,n,t.source_timecode??null);e.out_exclusive&&(o-=1);let s=t.source_timecode??"00:00:00:00",c=r!=null?F((T(s,n)??0)+r-1,n,!!t.vendor_metadata?.drop_frame):null;if(o<i)throw new Error(`out ${e.out} is before in ${e.in}`);if(i<0)throw new Error(`in ${e.in} is before the file starts (${s}, frame 0)`);if(r!=null&&o>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:i,rate:n},duration:{value:o-i+1,rate:n}}},u=y(e.path),m;if(e.out_path)try{(await L(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 Qe(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:n,facts:t,...h!==d.first_frame||p!==d.last_frame?{asked:{first_frame:d.first_frame,last_frame:d.last_frame}}:{}}}function Ce(e){let t=[...O].map(n=>n.slice(1)).join("|");return e.toLowerCase().replace(new RegExp(`\\.(${t})(?=[._\\s-]|$)`,"g"),"").replace(/[^a-z0-9]/g,"")}function er(e,t){let n=Ce(e),r=Ce(t);if(r&&n.includes(r))return"name";let i=t.toLowerCase().split(/[^a-z0-9]+/).filter(o=>/\d/.test(o)&&o.length>=3);return i.length&&i.every(o=>n.includes(o))?"id":null}async function Lr(e,t,n){let r=[],i=0,o=null,s=Date.now()+n.time_limit_s*1e3,c=async(a,u)=>{try{for await(let m of $(a)){if(o&&!o.startsWith("folders"))return;if(++i>n.max_entries){o=`stopped after ${n.max_entries} entries (max_entries)`;return}if(Date.now()>s){o=`stopped after ${n.time_limit_s} s (time_limit_s)`;return}if(m.name.startsWith("."))continue;let l=_(a,m.name);if(m.isDirectory)u<n.max_depth?await c(l,u+1):o??=`folders deeper than max_depth=${n.max_depth} not searched (e.g. ${l})`;else if(m.isFile&&O.has(z(m.name).toLowerCase())){let d=er(m.name,t);d&&r.push({path:l,match:d,size:(await L(l).catch(()=>({size:0}))).size})}}}catch{}};if(await c(e,0),n.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 C(u.path)}catch(m){u.error=m.message}}));return r.sort((a,u)=>a.path.localeCompare(u.path)),{hits:r,scanned:i,truncated:o}}function rr(e){let t=e.streams?.find(c=>c.kind==="video"),n=e.source_fps??t?.rate??null,r=e.available_range?.duration?.value??e.declared_duration?.value??null,i=t?.codec_specific??{},o=e.source_timecode&&n?T(e.source_timecode,n):null,s=o!=null&&r!=null&&n?F((o+r)%(Math.round(n)*86400),n,e.source_timecode.includes(";")):null;return`${t?`${t.codec??"?"}${i.profile?` ${i.profile}`:""} ${t.width??"?"}x${t.height??"?"}`:"no video"}${n?` @ ${Math.round(n*1e3)/1e3} fps`:""}; TC ${e.source_timecode??"none"}${s?`\u2013${s}`:""}; ${r??"?"} fr${r!=null&&n?` (${(r/n).toFixed(2)} s)`:""}`}function Jr(e,t,n,r){let i=e.hits.slice(0,r),o=[];e.truncated&&o.push(`TRUNCATED: ${e.truncated} \u2014 the search did NOT cover all of ${t}; the matches below may be incomplete.`),e.hits.length>i.length&&o.push(`TRUNCATED: showing ${i.length} of ${e.hits.length} matches. Pass limit=${e.hits.length} or narrow the query.`),o.push(`${e.hits.length} file${e.hits.length===1?"":"s"} match "${n}" under ${t} (${e.scanned} entries scanned)`);let s=new Map;for(let a of e.hits)s.set(b(a.path).toLowerCase(),(s.get(b(a.path).toLowerCase())??0)+1);let c=[...s].filter(([,a])=>a>1);c.length&&o.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 i)o.push(`- ${a.path}${a.match==="id"?" (id match)":""}
9
+ ${a.facts?rr(a.facts):a.error?`probe failed: ${a.error}`:`${(a.size/1e6).toFixed(1)} MB`}`);return o.join(`
10
+ `)}async function Kr(e,t,n=0){let r=await C(e),i=r.source_fps??r.streams?.find(d=>d.kind==="video")?.rate??null,o=r.available_range?.duration?.value??r.declared_duration?.value??null;if(!i||o==null)throw new Error(`cannot check coverage: ${b(e)} has no frame rate or length`);let s=Math.round(i)*86400,c=r.source_timecode?T(r.source_timecode,i)??0:0,a=!!r.source_timecode?.includes(";"),u=d=>{let f=E(d,i,r.source_timecode??null);return typeof d=="number"||/^\d+$/.test(d.trim())?f:f<-s/2?f+s:f>s/2?f-s:f},m=d=>F(((c+d)%s+s)%s,i,a),l=t.map((d,f)=>{let h=u(d.in),p=u(d.out),g=h,w=o-p,x=g>=0&&w>=0&&p>h,H=Math.max(0,-g),B=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 ${[H?`${H} fr at head`:"",B?`${B} fr at tail`:""].filter(Boolean).join(", ")}`),x&&n&&(g<n||w<n)&&S.push(`handles short of ${n}: ${[g<n?`head by ${n-g}`:"",w<n?`tail by ${n-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:H,short_tail:B,note:S.join("; ")}});return{facts:r,rows:l}}export{sr as a,Me as b,Er as c,Pr as d,Pe as e,je as f,O as g,Je as h,Ke as i,q as j,Br as k,C as l,Ve as m,jr as n,Ze as o,Qe as p,Wr as q,Ce as r,er as s,Lr as t,rr as u,Jr as v,Kr as w};
@@ -1,3 +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{Ha as n,K as f,aa as s}from"./chunk-QNF4NMIW.js";async function c(t){await n();let e=s(t);return e==="null"?null:JSON.parse(e)}async function l(t){await n();let e;try{e=f(t)}catch{return null}if(e.length<8)return null;let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=r.getUint32(0,!0),a=r.getUint32(4,!0),o=i*a*4;return e.length<8+o?null:{width:i,height:a,rgba:new Uint8ClampedArray(e.subarray(8,8+o))}}export{c as a,l as b};
3
+ import{Ha as n,K as f,aa as s}from"./chunk-L2RTMZCN.js";async function c(t){await n();let e=s(t);return e==="null"?null:JSON.parse(e)}async function l(t){await n();let e;try{e=f(t)}catch{return null}if(e.length<8)return null;let r=new DataView(e.buffer,e.byteOffset,e.byteLength),i=r.getUint32(0,!0),a=r.getUint32(4,!0),o=i*a*4;return e.length<8+o?null:{width:i,height:a,rgba:new Uint8ClampedArray(e.subarray(8,8+o))}}export{c as a,l as b};
@@ -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{Ha as t,_ as u,s as o}from"./chunk-QNF4NMIW.js";async function m(r){await t();let e=u(r);return e==="null"?null:JSON.parse(e)}async function d(r){await t();let e;try{e=o(r)}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),s=a*i*4;return e.length<8+s?null:{width:a,height:i,rgba:new Uint8ClampedArray(e.subarray(8,8+s))}}export{m as a,d as b};
3
+ import{Ha as t,_ as u,s as o}from"./chunk-L2RTMZCN.js";async function m(r){await t();let e=u(r);return e==="null"?null:JSON.parse(e)}async function d(r){await t();let e;try{e=o(r)}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),s=a*i*4;return e.length<8+s?null:{width:a,height:i,rgba:new Uint8ClampedArray(e.subarray(8,8+s))}}export{m as a,d as b};
@@ -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{b as o}from"./chunk-GTPTZRO6.js";var i="0.6.17";function a(t,n){let r=t.split("-")[0].split(".").map(Number),s=n.split("-")[0].split(".").map(Number);for(let e=0;e<Math.max(r.length,s.length);e++){let l=(r[e]||0)-(s[e]||0);if(l)return l>0}return!1}var p=null;function u(){return o("CONFORM_UPDATE_CHECK")==="off"?Promise.resolve(null):p??=fetch("https://registry.npmjs.org/conformtools/latest",{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?t.json():null).then(t=>typeof t?.version=="string"?t.version:null).catch(()=>null)}var c="run npx -y conformtools@latest setup claude (or setup codex) once: it registers the server so every new session runs the newest version (npx --prefer-online), then restart the MCP client; if an old global install is shadowing it: npm rm -g conformtools";async function m(){let t=o("CONFORM_APP_VERSION");if(t)return`conform.tools app ${t}`;let n=await u();return`conformtools ${i}`+(n&&a(n,i)?` \u2014 update available: ${n} \u2192 ${c}`:"")}export{i as a,a as b,u as c,c as d,m as e};
3
+ import{b as o}from"./chunk-HZG55H3B.js";var i="0.6.19";function a(t,n){let r=t.split("-")[0].split(".").map(Number),s=n.split("-")[0].split(".").map(Number);for(let e=0;e<Math.max(r.length,s.length);e++){let l=(r[e]||0)-(s[e]||0);if(l)return l>0}return!1}var p=null;function u(){return o("CONFORM_UPDATE_CHECK")==="off"?Promise.resolve(null):p??=fetch("https://registry.npmjs.org/conformtools/latest",{signal:AbortSignal.timeout(2e3)}).then(t=>t.ok?t.json():null).then(t=>typeof t?.version=="string"?t.version:null).catch(()=>null)}var c="run npx -y conformtools@latest setup claude (or setup codex) once: it registers the server so every new session runs the newest version (npx --prefer-online), then restart the MCP client; if an old global install is shadowing it: npm rm -g conformtools";async function m(){let t=o("CONFORM_APP_VERSION");if(t)return`conform.tools app ${t}`;let n=await u();return`conformtools ${i}`+(n&&a(n,i)?` \u2014 update available: ${n} \u2192 ${c}`:"")}export{i as a,a as b,u as c,c as d,m as e};
@@ -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-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(`
3
+ import{a as E}from"./chunk-COALWMI7.js";import{T 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-HZG55H3B.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,4 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ var n=class extends Error{constructor(o,r,s){super(r);this.code=o;this.data=s;this.name="ConformError"}};function u(e,t){return{content:[{type:"text",text:e}],...t?{structuredContent:{ok:!0,...t}}:{}}}var l=e=>u(e);function f(e){let t=e instanceof n?e:d(e);return{content:[{type:"text",text:`error [${t.code}]: ${t.message}`}],structuredContent:{ok:!1,code:t.code,message:t.message,...t.data?{data:t.data}:{}},isError:!0}}function d(e){let t=e instanceof Error?e.message:String(e);return/Cannot find module ['"]?[^'"\s]*\/(dist|conformtools)\/[^'"\s]+\.js['"]? imported from/.test(t)||/Cannot find module ['"]?\.\//.test(t)&&/imported from/.test(t)?new n("internal","conformtools was updated on this machine while this session was running, and the running copy can't load its own files any more. Reconnect it (Claude Code: /mcp \u2192 conformtools \u2192 Reconnect; or restart the agent app), then try again."):/unknown session_id|not found on this machine|No such file|NotFound/i.test(t)?new n("not_found",t):/unsupported|not supported|no local decoder|cannot detect/i.test(t)?new n("unsupported",t):/before the file start|past the last frame|is before|required|unknown (operation|target|verb)/i.test(t)?new n("invalid_args",t):/could not read|failed to parse|engine read failed/i.test(t)?new n("unreadable",t):/refused|coverage|never shipped/i.test(t)?new n("refused",t):/abort|cancel/i.test(t)?new n("cancelled",t):new n("engine",t)}function g(e,t){let[o,...r]=t.content,s=`[conformtools ${e}]`,a=o?[{...o,text:`${s} ${o.text}`},...r]:[{type:"text",text:s}],i=t.structuredContent;return{...t,content:a,...i&&!("text"in i)?{structuredContent:{...i,text:a.map(c=>c.text).join(`
4
+ `)}}:{}}}function p(e){let{images:t,...o}=e;return t?.length?{...o,content:[...e.content,...t.map(r=>({type:"image",...r}))]}:o}export{n as a,u as b,l as c,f as d,g as e,p as f};
@@ -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-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(`
3
+ import{Rb as F,Sb as N,Vb as D}from"./chunk-UWEM5YEM.js";import{i as j}from"./chunk-WNDA7QSY.js";import{$ as b,A as E,B as M,F as C,H as R,I as T,M as q,N as L,Q as w,ba as k,ca as _,ea 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-HZG55H3B.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
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};
@@ -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{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};
3
+ import{Ha as r,X as s,o}from"./chunk-L2RTMZCN.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 Q,e as mt}from"./chunk-JTRM2JCE.js";import{a as j}from"./chunk-ROGMKTND.js";import{A as P,B as T,M as pt,ba as y,n as R,y as S}from"./chunk-GTPTZRO6.js";import{createHash as qt}from"node:crypto";import{open as Zt}from"node:fs/promises";var Mt=new Uint16Array(256);for(let e=0;e<256;e++){let t=0,n=e<<8;for(let r=0;r<8;r++)(t^n)&32768?t=t<<1^4129:t=t<<1,n=n<<1;Mt[e]=t&65535}var tt=0,wt=2;var ne=Date.UTC(2020,0,1,0,0,0);function ht(e,t,n,r,o,s,a,i,g,c,u,_,p,w,d,b){let F=z(o,l.__wbindgen_export3,l.__wbindgen_export4),A=x,v=rt(a,l.__wbindgen_export3),W=x,Dt=l.udf_add_file_stream(f(e),f(t),f(n),f(r),F,A,s,v,W,i,g,c,u,_,p,w,d,b);return M(Dt)}function oe(e,t,n,r){let o,s;try{let p=l.__wbindgen_add_to_stack_pointer(-16),w=z(e,l.__wbindgen_export3,l.__wbindgen_export4),d=x,b=z(t,l.__wbindgen_export3,l.__wbindgen_export4),F=x,A=z(n,l.__wbindgen_export3,l.__wbindgen_export4),v=x;l.udf_build_layout(p,w,d,b,F,A,v,r);var a=h().getInt32(p+0,!0),i=h().getInt32(p+4,!0),g=h().getInt32(p+8,!0),c=h().getInt32(p+12,!0),u=a,_=i;if(c)throw u=0,_=0,M(g);return o=u,s=_,C(u,_)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export5(o,s,1)}}function xt(e,t,n,r,o,s,a){let i=z(o,l.__wbindgen_export3,l.__wbindgen_export4),g=x,c=rt(a,l.__wbindgen_export3),u=x,_=l.udf_fill_sparse_stream(f(e),f(t),f(n),f(r),i,g,s,c,u);return M(_)}function ae(){let e,t;try{let o=l.__wbindgen_add_to_stack_pointer(-16);l.udf_last_panic(o);var n=h().getInt32(o+0,!0),r=h().getInt32(o+4,!0);return e=n,t=r,C(n,r)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export5(e,t,1)}}function St(e,t){let n=l.udf_parse_stream(f(e),f(t));return M(n)}function se(e){let t,n;try{let s=l.__wbindgen_add_to_stack_pointer(-16),a=rt(e,l.__wbindgen_export3),i=x;l.udf_read_conform_iuvd(s,a,i);var r=h().getInt32(s+0,!0),o=h().getInt32(s+4,!0);return t=r,n=o,C(r,o)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export5(t,n,1)}}function Lt(){return{__proto__:null,"./udf_bg.js":{__proto__:null,__wbg___wbindgen_is_function_acc5528be2b923f2:function(t){return typeof m(t)=="function"},__wbg___wbindgen_is_undefined_721f8decd50c87a3:function(t){return m(t)===void 0},__wbg___wbindgen_number_get_1cc01dd708740256:function(t,n){let r=m(n),o=typeof r=="number"?r:void 0;h().setFloat64(t+8,O(o)?0:o,!0),h().setInt32(t+0,!O(o),!0)},__wbg___wbindgen_throw_ea4887a5f8f9a9db:function(t,n){throw new Error(C(t,n))},__wbg__wbg_cb_unref_33c39e13d73b25f6:function(t){m(t)._wbg_cb_unref()},__wbg_call_0e855b388e315e17:function(){return et(function(t,n,r,o){let s=m(t).call(m(n),m(r),m(o));return f(s)},arguments)},__wbg_call_5575218572ead796:function(){return et(function(t,n,r){let o=m(t).call(m(n),m(r));return f(o)},arguments)},__wbg_call_8e98ed2f3c86c4b5:function(){return et(function(t,n){let r=m(t).call(m(n));return f(r)},arguments)},__wbg_error_2b5d73c4c4804cfd:function(t,n){console.error(C(t,n))},__wbg_length_589238bdcf171f0e:function(t){return m(t).length},__wbg_new_81880fb5002cb255:function(t){let n=new Uint8Array(m(t));return f(n)},__wbg_new_from_slice_543b875b27789a8f:function(t,n){let r=new Uint8Array(yt(t,n));return f(r)},__wbg_new_no_args_2d7333de60de5ac7:function(t,n){let r=new Function(C(t,n));return f(r)},__wbg_new_typed_00a409eb4ec4f2d9:function(t,n){try{var r={a:t,b:n},o=(a,i)=>{let g=r.a;r.a=0;try{return $t(g,r.b,a,i)}finally{r.a=g}};let s=new Promise(o);return f(s)}finally{r.a=0}},__wbg_prototypesetcall_d721637c7ca66eb8:function(t,n,r){Uint8Array.prototype.set.call(yt(t,n),m(r))},__wbg_queueMicrotask_1c9b3800e321a967:function(t){let n=m(t).queueMicrotask;return f(n)},__wbg_queueMicrotask_311744e534a929a3:function(t){queueMicrotask(m(t))},__wbg_resolve_d82363d90af6928a:function(t){let n=Promise.resolve(m(t));return f(n)},__wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938:function(){let t=typeof globalThis>"u"?null:globalThis;return O(t)?0:f(t)},__wbg_static_accessor_GLOBAL_ce44e66a4935da8c:function(){let t=typeof global>"u"?null:global;return O(t)?0:f(t)},__wbg_static_accessor_SELF_44f6e0cb5e67cdad:function(){let t=typeof self>"u"?null:self;return O(t)?0:f(t)},__wbg_static_accessor_WINDOW_168f178805d978fe:function(){let t=typeof window>"u"?null:window;return O(t)?0:f(t)},__wbg_then_05edfc8a4fea5106:function(t,n,r){let o=m(t).then(m(n),m(r));return f(o)},__wbg_then_591b6b3a75ee817a:function(t,n){let r=m(t).then(m(n));return f(r)},__wbindgen_cast_0000000000000001:function(t,n){let r=zt(t,n,jt);return f(r)},__wbindgen_cast_0000000000000002:function(t){return f(t)},__wbindgen_cast_0000000000000003:function(t,n){let r=C(t,n);return f(r)},__wbindgen_object_clone_ref:function(t){let n=m(t);return f(n)},__wbindgen_object_drop_ref:function(t){M(t)}}}}function jt(e,t,n){try{let s=l.__wbindgen_add_to_stack_pointer(-16);l.__wasm_bindgen_func_elem_268(s,e,t,f(n));var r=h().getInt32(s+0,!0),o=h().getInt32(s+4,!0);if(o)throw M(r)}finally{l.__wbindgen_add_to_stack_pointer(16)}}function $t(e,t,n,r){l.__wasm_bindgen_func_elem_282(e,t,f(n),f(r))}function f(e){N===E.length&&E.push(E.length+1);let t=N;return N=E[t],E[t]=e,t}var bt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>l.__wbindgen_export2(e.a,e.b));function Nt(e){e<1028||(E[e]=N,N=e)}function yt(e,t){return e=e>>>0,D().subarray(e/1,e/1+t)}var U=null;function h(){return(U===null||U.buffer.detached===!0||U.buffer.detached===void 0&&U.buffer!==l.memory.buffer)&&(U=new DataView(l.memory.buffer)),U}function C(e,t){return Wt(e>>>0,t)}var $=null;function D(){return($===null||$.byteLength===0)&&($=new Uint8Array(l.memory.buffer)),$}function m(e){return E[e]}function et(e,t){try{return e.apply(this,t)}catch(n){l.__wbindgen_export(f(n))}}var E=new Array(1024).fill(void 0);E.push(void 0,null,!0,!1);var N=E.length;function O(e){return e==null}function zt(e,t,n){let r={a:e,b:t,cnt:1},o=(...s)=>{r.cnt++;let a=r.a;r.a=0;try{return n(a,r.b,...s)}finally{r.a=a,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{--r.cnt===0&&(l.__wbindgen_export2(r.a,r.b),r.a=0,bt.unregister(r))},bt.register(o,r,r),o}function rt(e,t){let n=t(e.length*1,1)>>>0;return D().set(e,n/1),x=e.length,n}function z(e,t,n){if(n===void 0){let i=B.encode(e),g=t(i.length,1)>>>0;return D().subarray(g,g+i.length).set(i),x=i.length,g}let r=e.length,o=t(r,1)>>>0,s=D(),a=0;for(;a<r;a++){let i=e.charCodeAt(a);if(i>127)break;s[o+a]=i}if(a!==r){a!==0&&(e=e.slice(a)),o=n(o,r,r=a+e.length*3,1)>>>0;let i=D().subarray(o+a,o+r),g=B.encodeInto(e,i);a+=g.written,o=n(o,r,a,1)>>>0}return x=a,o}function M(e){let t=m(e);return Nt(e),t}var H=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});H.decode();var Bt=2146435072,nt=0;function Wt(e,t){return nt+=t,nt>=Bt&&(H=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),H.decode(),nt=t),H.decode(D().subarray(e,e+t))}var B=new TextEncoder;"encodeInto"in B||(B.encodeInto=function(e,t){let n=B.encode(e);return t.set(n),{read:e.length,written:n.length}});var x=0,Ht,Gt,l;function Jt(e,t){return Gt=e,l=e.exports,Ht=t,U=null,$=null,l.__wbindgen_start(),l}async function Vt(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(e.ok&&n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function G(e){if(l!==void 0)return l;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0&&(e=new URL("udf_bg.wasm",import.meta.url));let t=Lt();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await Vt(await e,t);return Jt(n,r)}var ot=null;function Xt(e){return ot||(ot=(async()=>{if(e!==void 0)return G(e);if(typeof process<"u"&&process.versions?.node){let n="node:fs/promises",{readFile:r}=await import(n),o=await r(new URL("./wasm/udf_bg.wasm",import.meta.url));return G({module_or_path:o})}let{default:t}=await import("./udf_bg-B37GKRIH.js");return G({module_or_path:t})})()),ot}function J(){return Xt()}function V(e){return(t,n)=>e.read(t,n)}function at(e){return(t,n)=>e.write(t,n)}function X(e){return()=>e.getSize()}function st(e){return t=>e.setSize?e.setSize(t):Promise.resolve()}async function It(e){await J();let t=JSON.parse(await St(V(e),X(e)));if(t.error)throw new Error(t.error);let n=null;if(t.iuvdPayload)try{n=JSON.parse(t.iuvdPayload)}catch{}let r=null,o=t.files.find(s=>s.name===".i2o-manifest.json");if(o&&o.extents.length>0&&o.extents[0].type===tt){let s=o.extents[0].position,a=await e.read((t.partitionStartSector+s)*2048,o.totalSize);try{r=JSON.parse(new TextDecoder().decode(a))}catch{}}return{totalSectors:t.totalSectors,partitionStartSector:t.partitionStartSector,partitionLength:t.partitionLength,volumeName:t.volumeName,files:t.files,manifest:r,iuvdPayload:n,rootIcbSector:t.rootIcbSector,rootDataSector:t.rootDataSector,rootDataLength:t.rootDataLength,rootDataSectors:t.rootDataSectors,vdsStartSector:t.vdsStartSector,partitionDescVdsSector:t.partitionDescVdsSector}}function me(e){let t=[],n=0;for(let r of e.extents)r.type===wt&&t.push({offset:n,length:r.length}),n+=r.length;return t}function At(e){let t=[],n=0;for(let r of e.extents)r.type===tt&&t.push({offset:n,length:r.length,imageSector:r.position}),n+=r.length;return t}async function we(e,t,n,r,o){return await J(),await xt(V(e),at(e),X(e),st(e),n,r,o),It(e)}async function be(e,t,n,r,o,s=0){await J();let a=new Date,i=!!(o&&o.length>0);return await ht(V(e),at(e),X(e),st(e),n,r,i?o:new Uint8Array(0),i,s,a.getFullYear(),a.getMonth()+1,a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),-a.getTimezoneOffset()),It(e)}var Y=1<<20,k=5*Y,Et=5*1024*Y,it=1e4,ct=8*Y,Kt=2048;function Ae(e,t,n=Math.max(16*Y,Math.ceil(e/(it-500)))){let r=[...t].filter(c=>c.len>0).sort((c,u)=>c.at-u.at),o=[];for(let c of r){let u=o[o.length-1];u&&c.at<u.at+u.len||(u&&u.at+u.len===c.at&&u.key===c.key&&u.offset+u.len===c.offset?u.len+=c.len:o.push({...c}))}let s=[],a=0;for(let c of o.filter(u=>u.len>=k))c.at>a&&s.push({at:a,len:c.at-a}),s.push({at:c.at,len:c.len,copy:c}),a=c.at+c.len;a<e&&s.push({at:a,len:e-a});let i=c=>c.reduce((u,_)=>{let p=u[u.length-1];return p&&!p.copy&&!_.copy?p.len+=_.len:u.push({..._}),u},[]);for(let c=!0;c;){c=!1,s=i(s);for(let u=0;u<s.length-1;u++){let _=s[u];if(_.len>=k)continue;let p=k-_.len,w=s[u+1],d=s[u-1];if(_.copy){delete _.copy,c=!0;break}w?.copy&&w.len-p>=k?(_.len+=p,w.at+=p,w.len-=p,w.copy={...w.copy,at:w.at,len:w.len,offset:w.copy.offset+p}):d?.copy&&d.len-p>=k?(d.len-=p,d.copy={...d.copy,len:d.len},_.at-=p,_.len+=p):w?.copy?delete w.copy:d?.copy&&delete d.copy,c=!0;break}}let g=[];for(let c of s){let u=c.copy?Math.min(Et,Math.max(n,k)):n;for(let _=c.at,p=c.at+c.len;_<p;){let w=Math.min(u,p-_);p-(_+w)>0&&p-(_+w)<k&&(w=p-_<=Et?p-_:w-k),g.push(c.copy?{kind:"copy",at:_,len:w,key:c.copy.key,offset:c.copy.offset+(_-c.at)}:{kind:"upload",at:_,len:w}),_+=w}}if(g.length>it)throw new Error(`the image needs ${g.length} pieces (S3 allows ${it})`);return g}function Ee(e,t,n,r){let o=[...r].sort((i,g)=>i.offset-g.offset),s=[],a=0;for(let i of o){let g=Math.min(i.offset,t);g>a&&s.push({at:a,len:g-a,key:e,offset:a}),a=Math.max(a,i.offset+i.length)}return a<Math.min(t,n)&&s.push({at:a,len:Math.min(t,n)-a,key:e,offset:a}),s}async function ve(e,t,n,r,o){let s=[];for(let a of t.files)for(let i of At(a)){let g=(t.partitionStartSector+i.imageSector)*Kt;for(let c=i.offset;c<i.offset+i.length;){let u=Math.min(i.offset+i.length,(Math.floor(c/ct)+1)*ct),_=g+(c-i.offset);s.push(o?.(_,u-c)??[qt("sha256").update(await e.read(_,u-c)).digest("hex"),_,u-c]),r?.(u-c),c=u}}return{v:1,block:ct,size:n,blocks:s}}function Pe(e,t){let n=new Map;for(let o of t)for(let[s,a,i]of o.index.blocks)n.set(`${s}:${i}`,{key:o.key,offset:a});let r=[];for(let[o,s,a]of e.blocks){let i=n.get(`${o}:${a}`);i&&r.push({at:s,len:a,key:i.key,offset:i.offset})}return r}var vt=(e,t)=>`${Q().supabaseUrl}/functions/v1/${e}${t}`;async function lt(e,t,n={}){let r=await mt();if(!r)throw new Error("not signed in to conform.tools \u2014 run account_login");let o=await fetch(vt(e,t),{method:n.method??(n.body?"POST":"GET"),headers:{authorization:`Bearer ${r}`,apikey:Q().anonKey,...n.body?{"content-type":"application/json"}:{}},...n.body?{body:JSON.stringify(n.body)}:{},signal:AbortSignal.timeout(2e4)}),s=await o.text();if(!o.ok){let a=s;try{let i=JSON.parse(s);a=i.error?.message??i.message??i.error??s}catch{}throw o.status===404&&/Requested function was not found/i.test(String(a))?new Error(`${e} isn't deployed on ${new URL(vt(e,t)).host}: this server doesn't have that feature yet (an older server, or a staging/production mismatch)`):new Error(`${n.method??"GET"} ${t}: ${o.status} ${a}`)}return s?JSON.parse(s):{}}function Te(e,t="org"){let n=`/v1/sessions/${e}/storage/multipart`,r=(o,s,a)=>lt("v1-sessions",o,{body:s,method:a});return{start:async o=>String((await r(`${n}/start`,{key:o,content_type:"application/x-iso9660-image"})).upload_id),partUrls:async(o,s,a,i)=>(await r(`${n}/${s}/part-urls`,{key:o,first_part:a,count:i})).parts,copyPart:async(o,s,a,i)=>String((await r(`${n}/${s}/copy-part`,{key:o,part_number:a,source_ref:{scheme:t,bucket:"i2o",key:i.key},byte_range:{offset:i.offset,length:i.length}})).etag),complete:async(o,s,a)=>{await r(`${n}/${s}/complete`,{key:o,parts:a})},abort:async(o,s)=>{await r(`${n}/${encodeURIComponent(s)}?key=${encodeURIComponent(o)}`,void 0,"DELETE")},readUrl:async o=>String((await r(`/v1/sessions/${e}/download-url`,{storage_path:o})).download_url)}}async function ut(e,t,n=4){for(let r=1;;r++)try{return await t()}catch(o){if(r>=n)throw new Error(`${e} failed after ${n} tries: ${o instanceof Error?o.message:o}`);await new Promise(s=>setTimeout(s,500*2**r))}}async function ke(e,t,n,r,o={}){let s=o.fetchFn??fetch,a=await e.start(t),i=n.reduce((d,b)=>d+b.len,0),g=new Array(n.length),c=0,u=0,_=new Map,p=async d=>(_.has(d)||(await e.partUrls(t,a,d+1,Math.min(100,n.length-d))).forEach((F,A)=>_.set(d+A,F)),_.get(d)),w=async d=>{let b=n[d];if(b.kind==="copy")g[d]=await ut(`copy piece ${d+1}`,()=>e.copyPart(t,a,d+1,{key:b.key,offset:b.offset,length:b.len}));else{let F=await r(b.at,b.len);g[d]=await ut(`upload piece ${d+1}`,async()=>{let A=await p(d),v=await s(A.upload_url,{method:A.method,headers:A.headers,body:F,signal:o.signal});if(!v.ok)throw _.delete(d),new Error(`${v.status} ${(await v.text()).slice(0,200)}`);let W=v.headers.get("etag");if(!W)throw new Error("the bucket returned no ETag (expose it in the bucket's CORS / response headers)");return W})}c+=b.len,o.onProgress?.(c,i)};try{await Promise.all(Array.from({length:Math.min(6,n.length)},async()=>{for(;u<n.length;)o.signal?.throwIfAborted(),await w(u++)})),await ut("complete",()=>e.complete(t,a,g.map((d,b)=>({part_number:b+1,etag:d}))))}catch(d){throw await e.abort(t,a).catch(()=>{}),d}return{uploaded:n.filter(d=>d.kind==="upload").reduce((d,b)=>d+b.len,0),copied:n.filter(d=>d.kind==="copy").reduce((d,b)=>d+b.len,0),pieces:n.length}}function Fe(e){let t=Zt(e,"r");return{read:async(n,r)=>{let o=new Uint8Array(r);return await(await t).read(o,0,r,n),o},close:async()=>{await(await t).close()}}}var gt="local",Tt=/^[A-Za-z0-9_-]{1,64}$/,I=e=>{if(!Tt.test(e))throw new j("invalid_args",`bad project_id '${e}'`);return y(R(),"projects",e)},dt=(e,t={})=>lt("v1-projects",e,t),kt=e=>Number(/: (\d{3}) /.exec(String(e?.message))?.[1]??0);async function Ft(e){let t="",n={base:null,by:null};try{t=await S(y(I(e),"CONTEXT.md"))}catch{}try{n=JSON.parse(await S(y(I(e),"context.json")))}catch{}return{text:t,meta:n}}async function _t(e,t,n){await T(I(e)),await P(y(I(e),"CONTEXT.md"),t),await P(y(I(e),"context.json"),JSON.stringify(n))}var ft=async(e,t)=>(await _t(e,t.context,{base:t.context_updated_at,by:t.context_updated_by_name??null}),{text:t.context,updated_at:t.context_updated_at,updated_by:t.context_updated_by_name??null});async function Me(e){I(e);let t=await Ft(e);if(e===gt)return{text:t.text,updated_at:null,updated_by:null};if(t.meta.pending)try{return await Pt(e,t.text,t.meta.base)}catch(n){if(!(n instanceof j&&n.code==="context_conflict"))return{text:t.text,updated_at:t.meta.base,updated_by:t.meta.by,offline:!0,pending:!0};let r=n.data?.current??{context:"",context_updated_at:null},o=`${r.context.trimEnd()}
3
+ import{d as Q,i as mt}from"./chunk-MJKISVPS.js";import{a as j}from"./chunk-COALWMI7.js";import{A as P,B as T,N as pt,ca as y,n as R,y as S}from"./chunk-HZG55H3B.js";import{createHash as qt}from"node:crypto";import{open as Zt}from"node:fs/promises";var Mt=new Uint16Array(256);for(let e=0;e<256;e++){let t=0,n=e<<8;for(let r=0;r<8;r++)(t^n)&32768?t=t<<1^4129:t=t<<1,n=n<<1;Mt[e]=t&65535}var tt=0,wt=2;var ne=Date.UTC(2020,0,1,0,0,0);function ht(e,t,n,r,o,s,a,i,g,c,u,_,p,w,d,b){let F=z(o,l.__wbindgen_export3,l.__wbindgen_export4),A=x,v=rt(a,l.__wbindgen_export3),W=x,Dt=l.udf_add_file_stream(f(e),f(t),f(n),f(r),F,A,s,v,W,i,g,c,u,_,p,w,d,b);return M(Dt)}function oe(e,t,n,r){let o,s;try{let p=l.__wbindgen_add_to_stack_pointer(-16),w=z(e,l.__wbindgen_export3,l.__wbindgen_export4),d=x,b=z(t,l.__wbindgen_export3,l.__wbindgen_export4),F=x,A=z(n,l.__wbindgen_export3,l.__wbindgen_export4),v=x;l.udf_build_layout(p,w,d,b,F,A,v,r);var a=h().getInt32(p+0,!0),i=h().getInt32(p+4,!0),g=h().getInt32(p+8,!0),c=h().getInt32(p+12,!0),u=a,_=i;if(c)throw u=0,_=0,M(g);return o=u,s=_,C(u,_)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export5(o,s,1)}}function xt(e,t,n,r,o,s,a){let i=z(o,l.__wbindgen_export3,l.__wbindgen_export4),g=x,c=rt(a,l.__wbindgen_export3),u=x,_=l.udf_fill_sparse_stream(f(e),f(t),f(n),f(r),i,g,s,c,u);return M(_)}function ae(){let e,t;try{let o=l.__wbindgen_add_to_stack_pointer(-16);l.udf_last_panic(o);var n=h().getInt32(o+0,!0),r=h().getInt32(o+4,!0);return e=n,t=r,C(n,r)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export5(e,t,1)}}function St(e,t){let n=l.udf_parse_stream(f(e),f(t));return M(n)}function se(e){let t,n;try{let s=l.__wbindgen_add_to_stack_pointer(-16),a=rt(e,l.__wbindgen_export3),i=x;l.udf_read_conform_iuvd(s,a,i);var r=h().getInt32(s+0,!0),o=h().getInt32(s+4,!0);return t=r,n=o,C(r,o)}finally{l.__wbindgen_add_to_stack_pointer(16),l.__wbindgen_export5(t,n,1)}}function Lt(){return{__proto__:null,"./udf_bg.js":{__proto__:null,__wbg___wbindgen_is_function_acc5528be2b923f2:function(t){return typeof m(t)=="function"},__wbg___wbindgen_is_undefined_721f8decd50c87a3:function(t){return m(t)===void 0},__wbg___wbindgen_number_get_1cc01dd708740256:function(t,n){let r=m(n),o=typeof r=="number"?r:void 0;h().setFloat64(t+8,O(o)?0:o,!0),h().setInt32(t+0,!O(o),!0)},__wbg___wbindgen_throw_ea4887a5f8f9a9db:function(t,n){throw new Error(C(t,n))},__wbg__wbg_cb_unref_33c39e13d73b25f6:function(t){m(t)._wbg_cb_unref()},__wbg_call_0e855b388e315e17:function(){return et(function(t,n,r,o){let s=m(t).call(m(n),m(r),m(o));return f(s)},arguments)},__wbg_call_5575218572ead796:function(){return et(function(t,n,r){let o=m(t).call(m(n),m(r));return f(o)},arguments)},__wbg_call_8e98ed2f3c86c4b5:function(){return et(function(t,n){let r=m(t).call(m(n));return f(r)},arguments)},__wbg_error_2b5d73c4c4804cfd:function(t,n){console.error(C(t,n))},__wbg_length_589238bdcf171f0e:function(t){return m(t).length},__wbg_new_81880fb5002cb255:function(t){let n=new Uint8Array(m(t));return f(n)},__wbg_new_from_slice_543b875b27789a8f:function(t,n){let r=new Uint8Array(yt(t,n));return f(r)},__wbg_new_no_args_2d7333de60de5ac7:function(t,n){let r=new Function(C(t,n));return f(r)},__wbg_new_typed_00a409eb4ec4f2d9:function(t,n){try{var r={a:t,b:n},o=(a,i)=>{let g=r.a;r.a=0;try{return $t(g,r.b,a,i)}finally{r.a=g}};let s=new Promise(o);return f(s)}finally{r.a=0}},__wbg_prototypesetcall_d721637c7ca66eb8:function(t,n,r){Uint8Array.prototype.set.call(yt(t,n),m(r))},__wbg_queueMicrotask_1c9b3800e321a967:function(t){let n=m(t).queueMicrotask;return f(n)},__wbg_queueMicrotask_311744e534a929a3:function(t){queueMicrotask(m(t))},__wbg_resolve_d82363d90af6928a:function(t){let n=Promise.resolve(m(t));return f(n)},__wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938:function(){let t=typeof globalThis>"u"?null:globalThis;return O(t)?0:f(t)},__wbg_static_accessor_GLOBAL_ce44e66a4935da8c:function(){let t=typeof global>"u"?null:global;return O(t)?0:f(t)},__wbg_static_accessor_SELF_44f6e0cb5e67cdad:function(){let t=typeof self>"u"?null:self;return O(t)?0:f(t)},__wbg_static_accessor_WINDOW_168f178805d978fe:function(){let t=typeof window>"u"?null:window;return O(t)?0:f(t)},__wbg_then_05edfc8a4fea5106:function(t,n,r){let o=m(t).then(m(n),m(r));return f(o)},__wbg_then_591b6b3a75ee817a:function(t,n){let r=m(t).then(m(n));return f(r)},__wbindgen_cast_0000000000000001:function(t,n){let r=zt(t,n,jt);return f(r)},__wbindgen_cast_0000000000000002:function(t){return f(t)},__wbindgen_cast_0000000000000003:function(t,n){let r=C(t,n);return f(r)},__wbindgen_object_clone_ref:function(t){let n=m(t);return f(n)},__wbindgen_object_drop_ref:function(t){M(t)}}}}function jt(e,t,n){try{let s=l.__wbindgen_add_to_stack_pointer(-16);l.__wasm_bindgen_func_elem_268(s,e,t,f(n));var r=h().getInt32(s+0,!0),o=h().getInt32(s+4,!0);if(o)throw M(r)}finally{l.__wbindgen_add_to_stack_pointer(16)}}function $t(e,t,n,r){l.__wasm_bindgen_func_elem_282(e,t,f(n),f(r))}function f(e){N===E.length&&E.push(E.length+1);let t=N;return N=E[t],E[t]=e,t}var bt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>l.__wbindgen_export2(e.a,e.b));function Nt(e){e<1028||(E[e]=N,N=e)}function yt(e,t){return e=e>>>0,D().subarray(e/1,e/1+t)}var U=null;function h(){return(U===null||U.buffer.detached===!0||U.buffer.detached===void 0&&U.buffer!==l.memory.buffer)&&(U=new DataView(l.memory.buffer)),U}function C(e,t){return Wt(e>>>0,t)}var $=null;function D(){return($===null||$.byteLength===0)&&($=new Uint8Array(l.memory.buffer)),$}function m(e){return E[e]}function et(e,t){try{return e.apply(this,t)}catch(n){l.__wbindgen_export(f(n))}}var E=new Array(1024).fill(void 0);E.push(void 0,null,!0,!1);var N=E.length;function O(e){return e==null}function zt(e,t,n){let r={a:e,b:t,cnt:1},o=(...s)=>{r.cnt++;let a=r.a;r.a=0;try{return n(a,r.b,...s)}finally{r.a=a,o._wbg_cb_unref()}};return o._wbg_cb_unref=()=>{--r.cnt===0&&(l.__wbindgen_export2(r.a,r.b),r.a=0,bt.unregister(r))},bt.register(o,r,r),o}function rt(e,t){let n=t(e.length*1,1)>>>0;return D().set(e,n/1),x=e.length,n}function z(e,t,n){if(n===void 0){let i=B.encode(e),g=t(i.length,1)>>>0;return D().subarray(g,g+i.length).set(i),x=i.length,g}let r=e.length,o=t(r,1)>>>0,s=D(),a=0;for(;a<r;a++){let i=e.charCodeAt(a);if(i>127)break;s[o+a]=i}if(a!==r){a!==0&&(e=e.slice(a)),o=n(o,r,r=a+e.length*3,1)>>>0;let i=D().subarray(o+a,o+r),g=B.encodeInto(e,i);a+=g.written,o=n(o,r,a,1)>>>0}return x=a,o}function M(e){let t=m(e);return Nt(e),t}var H=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});H.decode();var Bt=2146435072,nt=0;function Wt(e,t){return nt+=t,nt>=Bt&&(H=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),H.decode(),nt=t),H.decode(D().subarray(e,e+t))}var B=new TextEncoder;"encodeInto"in B||(B.encodeInto=function(e,t){let n=B.encode(e);return t.set(n),{read:e.length,written:n.length}});var x=0,Ht,Gt,l;function Jt(e,t){return Gt=e,l=e.exports,Ht=t,U=null,$=null,l.__wbindgen_start(),l}async function Vt(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(e.ok&&n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);return r instanceof WebAssembly.Instance?{instance:r,module:e}:r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function G(e){if(l!==void 0)return l;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),e===void 0&&(e=new URL("udf_bg.wasm",import.meta.url));let t=Lt();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:r}=await Vt(await e,t);return Jt(n,r)}var ot=null;function Xt(e){return ot||(ot=(async()=>{if(e!==void 0)return G(e);if(typeof process<"u"&&process.versions?.node){let n="node:fs/promises",{readFile:r}=await import(n),o=await r(new URL("./wasm/udf_bg.wasm",import.meta.url));return G({module_or_path:o})}let{default:t}=await import("./udf_bg-HOHEKAVF.js");return G({module_or_path:t})})()),ot}function J(){return Xt()}function V(e){return(t,n)=>e.read(t,n)}function at(e){return(t,n)=>e.write(t,n)}function X(e){return()=>e.getSize()}function st(e){return t=>e.setSize?e.setSize(t):Promise.resolve()}async function It(e){await J();let t=JSON.parse(await St(V(e),X(e)));if(t.error)throw new Error(t.error);let n=null;if(t.iuvdPayload)try{n=JSON.parse(t.iuvdPayload)}catch{}let r=null,o=t.files.find(s=>s.name===".i2o-manifest.json");if(o&&o.extents.length>0&&o.extents[0].type===tt){let s=o.extents[0].position,a=await e.read((t.partitionStartSector+s)*2048,o.totalSize);try{r=JSON.parse(new TextDecoder().decode(a))}catch{}}return{totalSectors:t.totalSectors,partitionStartSector:t.partitionStartSector,partitionLength:t.partitionLength,volumeName:t.volumeName,files:t.files,manifest:r,iuvdPayload:n,rootIcbSector:t.rootIcbSector,rootDataSector:t.rootDataSector,rootDataLength:t.rootDataLength,rootDataSectors:t.rootDataSectors,vdsStartSector:t.vdsStartSector,partitionDescVdsSector:t.partitionDescVdsSector}}function me(e){let t=[],n=0;for(let r of e.extents)r.type===wt&&t.push({offset:n,length:r.length}),n+=r.length;return t}function At(e){let t=[],n=0;for(let r of e.extents)r.type===tt&&t.push({offset:n,length:r.length,imageSector:r.position}),n+=r.length;return t}async function we(e,t,n,r,o){return await J(),await xt(V(e),at(e),X(e),st(e),n,r,o),It(e)}async function be(e,t,n,r,o,s=0){await J();let a=new Date,i=!!(o&&o.length>0);return await ht(V(e),at(e),X(e),st(e),n,r,i?o:new Uint8Array(0),i,s,a.getFullYear(),a.getMonth()+1,a.getDate(),a.getHours(),a.getMinutes(),a.getSeconds(),-a.getTimezoneOffset()),It(e)}var Y=1<<20,k=5*Y,Et=5*1024*Y,it=1e4,ct=8*Y,Kt=2048;function Ae(e,t,n=Math.max(16*Y,Math.ceil(e/(it-500)))){let r=[...t].filter(c=>c.len>0).sort((c,u)=>c.at-u.at),o=[];for(let c of r){let u=o[o.length-1];u&&c.at<u.at+u.len||(u&&u.at+u.len===c.at&&u.key===c.key&&u.offset+u.len===c.offset?u.len+=c.len:o.push({...c}))}let s=[],a=0;for(let c of o.filter(u=>u.len>=k))c.at>a&&s.push({at:a,len:c.at-a}),s.push({at:c.at,len:c.len,copy:c}),a=c.at+c.len;a<e&&s.push({at:a,len:e-a});let i=c=>c.reduce((u,_)=>{let p=u[u.length-1];return p&&!p.copy&&!_.copy?p.len+=_.len:u.push({..._}),u},[]);for(let c=!0;c;){c=!1,s=i(s);for(let u=0;u<s.length-1;u++){let _=s[u];if(_.len>=k)continue;let p=k-_.len,w=s[u+1],d=s[u-1];if(_.copy){delete _.copy,c=!0;break}w?.copy&&w.len-p>=k?(_.len+=p,w.at+=p,w.len-=p,w.copy={...w.copy,at:w.at,len:w.len,offset:w.copy.offset+p}):d?.copy&&d.len-p>=k?(d.len-=p,d.copy={...d.copy,len:d.len},_.at-=p,_.len+=p):w?.copy?delete w.copy:d?.copy&&delete d.copy,c=!0;break}}let g=[];for(let c of s){let u=c.copy?Math.min(Et,Math.max(n,k)):n;for(let _=c.at,p=c.at+c.len;_<p;){let w=Math.min(u,p-_);p-(_+w)>0&&p-(_+w)<k&&(w=p-_<=Et?p-_:w-k),g.push(c.copy?{kind:"copy",at:_,len:w,key:c.copy.key,offset:c.copy.offset+(_-c.at)}:{kind:"upload",at:_,len:w}),_+=w}}if(g.length>it)throw new Error(`the image needs ${g.length} pieces (S3 allows ${it})`);return g}function Ee(e,t,n,r){let o=[...r].sort((i,g)=>i.offset-g.offset),s=[],a=0;for(let i of o){let g=Math.min(i.offset,t);g>a&&s.push({at:a,len:g-a,key:e,offset:a}),a=Math.max(a,i.offset+i.length)}return a<Math.min(t,n)&&s.push({at:a,len:Math.min(t,n)-a,key:e,offset:a}),s}async function ve(e,t,n,r,o){let s=[];for(let a of t.files)for(let i of At(a)){let g=(t.partitionStartSector+i.imageSector)*Kt;for(let c=i.offset;c<i.offset+i.length;){let u=Math.min(i.offset+i.length,(Math.floor(c/ct)+1)*ct),_=g+(c-i.offset);s.push(o?.(_,u-c)??[qt("sha256").update(await e.read(_,u-c)).digest("hex"),_,u-c]),r?.(u-c),c=u}}return{v:1,block:ct,size:n,blocks:s}}function Pe(e,t){let n=new Map;for(let o of t)for(let[s,a,i]of o.index.blocks)n.set(`${s}:${i}`,{key:o.key,offset:a});let r=[];for(let[o,s,a]of e.blocks){let i=n.get(`${o}:${a}`);i&&r.push({at:s,len:a,key:i.key,offset:i.offset})}return r}var vt=(e,t)=>`${Q().supabaseUrl}/functions/v1/${e}${t}`;async function lt(e,t,n={}){let r=await mt();if(!r)throw new Error("not signed in to conform.tools \u2014 run account_login");let o=await fetch(vt(e,t),{method:n.method??(n.body?"POST":"GET"),headers:{authorization:`Bearer ${r}`,apikey:Q().anonKey,...n.body?{"content-type":"application/json"}:{}},...n.body?{body:JSON.stringify(n.body)}:{},signal:AbortSignal.timeout(2e4)}),s=await o.text();if(!o.ok){let a=s;try{let i=JSON.parse(s);a=i.error?.message??i.message??i.error??s}catch{}throw o.status===404&&/Requested function was not found/i.test(String(a))?new Error(`${e} isn't deployed on ${new URL(vt(e,t)).host}: this server doesn't have that feature yet (an older server, or a staging/production mismatch)`):new Error(`${n.method??"GET"} ${t}: ${o.status} ${a}`)}return s?JSON.parse(s):{}}function Te(e,t="org"){let n=`/v1/sessions/${e}/storage/multipart`,r=(o,s,a)=>lt("v1-sessions",o,{body:s,method:a});return{start:async o=>String((await r(`${n}/start`,{key:o,content_type:"application/x-iso9660-image"})).upload_id),partUrls:async(o,s,a,i)=>(await r(`${n}/${s}/part-urls`,{key:o,first_part:a,count:i})).parts,copyPart:async(o,s,a,i)=>String((await r(`${n}/${s}/copy-part`,{key:o,part_number:a,source_ref:{scheme:t,bucket:"i2o",key:i.key},byte_range:{offset:i.offset,length:i.length}})).etag),complete:async(o,s,a)=>{await r(`${n}/${s}/complete`,{key:o,parts:a})},abort:async(o,s)=>{await r(`${n}/${encodeURIComponent(s)}?key=${encodeURIComponent(o)}`,void 0,"DELETE")},readUrl:async o=>String((await r(`/v1/sessions/${e}/download-url`,{storage_path:o})).download_url)}}async function ut(e,t,n=4){for(let r=1;;r++)try{return await t()}catch(o){if(r>=n)throw new Error(`${e} failed after ${n} tries: ${o instanceof Error?o.message:o}`);await new Promise(s=>setTimeout(s,500*2**r))}}async function ke(e,t,n,r,o={}){let s=o.fetchFn??fetch,a=await e.start(t),i=n.reduce((d,b)=>d+b.len,0),g=new Array(n.length),c=0,u=0,_=new Map,p=async d=>(_.has(d)||(await e.partUrls(t,a,d+1,Math.min(100,n.length-d))).forEach((F,A)=>_.set(d+A,F)),_.get(d)),w=async d=>{let b=n[d];if(b.kind==="copy")g[d]=await ut(`copy piece ${d+1}`,()=>e.copyPart(t,a,d+1,{key:b.key,offset:b.offset,length:b.len}));else{let F=await r(b.at,b.len);g[d]=await ut(`upload piece ${d+1}`,async()=>{let A=await p(d),v=await s(A.upload_url,{method:A.method,headers:A.headers,body:F,signal:o.signal});if(!v.ok)throw _.delete(d),new Error(`${v.status} ${(await v.text()).slice(0,200)}`);let W=v.headers.get("etag");if(!W)throw new Error("the bucket returned no ETag (expose it in the bucket's CORS / response headers)");return W})}c+=b.len,o.onProgress?.(c,i)};try{await Promise.all(Array.from({length:Math.min(6,n.length)},async()=>{for(;u<n.length;)o.signal?.throwIfAborted(),await w(u++)})),await ut("complete",()=>e.complete(t,a,g.map((d,b)=>({part_number:b+1,etag:d}))))}catch(d){throw await e.abort(t,a).catch(()=>{}),d}return{uploaded:n.filter(d=>d.kind==="upload").reduce((d,b)=>d+b.len,0),copied:n.filter(d=>d.kind==="copy").reduce((d,b)=>d+b.len,0),pieces:n.length}}function Fe(e){let t=Zt(e,"r");return{read:async(n,r)=>{let o=new Uint8Array(r);return await(await t).read(o,0,r,n),o},close:async()=>{await(await t).close()}}}var gt="local",Tt=/^[A-Za-z0-9_-]{1,64}$/,I=e=>{if(!Tt.test(e))throw new j("invalid_args",`bad project_id '${e}'`);return y(R(),"projects",e)},dt=(e,t={})=>lt("v1-projects",e,t),kt=e=>Number(/: (\d{3}) /.exec(String(e?.message))?.[1]??0);async function Ft(e){let t="",n={base:null,by:null};try{t=await S(y(I(e),"CONTEXT.md"))}catch{}try{n=JSON.parse(await S(y(I(e),"context.json")))}catch{}return{text:t,meta:n}}async function _t(e,t,n){await T(I(e)),await P(y(I(e),"CONTEXT.md"),t),await P(y(I(e),"context.json"),JSON.stringify(n))}var ft=async(e,t)=>(await _t(e,t.context,{base:t.context_updated_at,by:t.context_updated_by_name??null}),{text:t.context,updated_at:t.context_updated_at,updated_by:t.context_updated_by_name??null});async function Me(e){I(e);let t=await Ft(e);if(e===gt)return{text:t.text,updated_at:null,updated_by:null};if(t.meta.pending)try{return await Pt(e,t.text,t.meta.base)}catch(n){if(!(n instanceof j&&n.code==="context_conflict"))return{text:t.text,updated_at:t.meta.base,updated_by:t.meta.by,offline:!0,pending:!0};let r=n.data?.current??{context:"",context_updated_at:null},o=`${r.context.trimEnd()}
4
4
 
5
5
  ## Saved offline on this machine (merge into the notes above)
6
6
 
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
- import{a as F}from"./chunk-ROGMKTND.js";import{A as S,B as m,D as v,F as x,G as g,H as D,M as $,ba as a,n as _,t as b,u as p}from"./chunk-GTPTZRO6.js";var R="_originalframes",y="zAPPLIED_PATCHES",u=t=>t.replace(/[\\/][^\\/]+[\\/]?$/,""),k=()=>a(_(),"move-undo");async function P(t){let n=[];for await(let o of $(t))o.isFile&&!o.name.startsWith(".")&&n.push(o.name);return n.sort()}async function T(t){let n=[];for await(let o of $(u(t)))o.isDirectory&&/patch/i.test(o.name)&&o.name!==y&&n.push(o.name);return n.sort()}async function A(t,n){let o=new Set(await P(t)),e=[];for(let r of n){let s=a(u(t),r);if(await p(s))for(let w of await P(s))e.push({file:w,folder:r,replaces:o.has(w)})}return e}async function j(t,n,o){if(!await p(t)||!(await b(t)).isDirectory)throw new F("invalid_args",`not a folder: ${t}`);let e=u(t),r=[],s=[];for(let i of await A(t,n)){if(o&&!o.has(`${i.folder}/${i.file}`))continue;if(!i.replaces){r.push(`${i.file}: not in the sequence`);continue}let f=a(t,i.file),c=a(e,i.folder,i.file),l=`${t}${R}`,h=a(l,i.file);for(let d=1;await p(h);d++)h=a(`${t}${R}${String(d).padStart(2,"0")}`,i.file);await m(u(h));try{await g(f,h)}catch(d){r.push(`${i.file}: ${d.message}`);continue}try{await x(c,f)}catch(d){await g(h,f).catch(()=>{}),r.push(`${i.file}: ${d.message}`);continue}s.push({file:i.file,backup:h,patch_src:c,applied:c,folder:i.folder}),l=""}let w=[];if(s.length){let i=a(e,y);await m(i);for(let f of new Set(s.map(c=>c.folder))){let c=a(i,f);for(let l=1;await p(c);l++)c=a(i,`${f}_${l}`);try{await g(a(e,f),c),w.push({from:a(e,f),to:c});for(let l of s)l.folder===f&&(l.applied=a(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(k()),await S(a(k(),`${E}.json`),JSON.stringify({patch:!0,sequence:t,entries:s.map(({folder:i,...f})=>f),folders:w})),{patched:s.length,errors:r,undo_id:E}}async function L(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 o=0;for(let e of t.entries){let r=a(t.sequence,e.file);if(await p(e.backup))try{await p(r)&&await v(r),await g(e.backup,r),o++}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:o,failed:n}}export{R as a,y as b,T as c,A as d,j as e,L as f};
3
+ import{a as F}from"./chunk-COALWMI7.js";import{A as S,B as m,D as v,F as x,G as g,H as D,N as $,ca as a,n as _,t as b,u as p}from"./chunk-HZG55H3B.js";var R="_originalframes",y="zAPPLIED_PATCHES",u=t=>t.replace(/[\\/][^\\/]+[\\/]?$/,""),k=()=>a(_(),"move-undo");async function P(t){let n=[];for await(let o of $(t))o.isFile&&!o.name.startsWith(".")&&n.push(o.name);return n.sort()}async function T(t){let n=[];for await(let o of $(u(t)))o.isDirectory&&/patch/i.test(o.name)&&o.name!==y&&n.push(o.name);return n.sort()}async function A(t,n){let o=new Set(await P(t)),e=[];for(let r of n){let s=a(u(t),r);if(await p(s))for(let w of await P(s))e.push({file:w,folder:r,replaces:o.has(w)})}return e}async function j(t,n,o){if(!await p(t)||!(await b(t)).isDirectory)throw new F("invalid_args",`not a folder: ${t}`);let e=u(t),r=[],s=[];for(let i of await A(t,n)){if(o&&!o.has(`${i.folder}/${i.file}`))continue;if(!i.replaces){r.push(`${i.file}: not in the sequence`);continue}let f=a(t,i.file),c=a(e,i.folder,i.file),l=`${t}${R}`,h=a(l,i.file);for(let d=1;await p(h);d++)h=a(`${t}${R}${String(d).padStart(2,"0")}`,i.file);await m(u(h));try{await g(f,h)}catch(d){r.push(`${i.file}: ${d.message}`);continue}try{await x(c,f)}catch(d){await g(h,f).catch(()=>{}),r.push(`${i.file}: ${d.message}`);continue}s.push({file:i.file,backup:h,patch_src:c,applied:c,folder:i.folder}),l=""}let w=[];if(s.length){let i=a(e,y);await m(i);for(let f of new Set(s.map(c=>c.folder))){let c=a(i,f);for(let l=1;await p(c);l++)c=a(i,`${f}_${l}`);try{await g(a(e,f),c),w.push({from:a(e,f),to:c});for(let l of s)l.folder===f&&(l.applied=a(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(k()),await S(a(k(),`${E}.json`),JSON.stringify({patch:!0,sequence:t,entries:s.map(({folder:i,...f})=>f),folders:w})),{patched:s.length,errors:r,undo_id:E}}async function L(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 o=0;for(let e of t.entries){let r=a(t.sequence,e.file);if(await p(e.backup))try{await p(r)&&await v(r),await g(e.backup,r),o++}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:o,failed:n}}export{R as a,y as b,T as c,A as d,j as e,L as f};
@@ -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 Ot,dirname as Ut,extname as Ft,join as Dt,relative as Tt,resolve as Et}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=()=>f.ppid,ft=(e="conform-")=>K(h(ae(),e));async function*pt(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 gt(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 yt(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 wt(){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 bt(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 ht(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 xt(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 vt(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 Pt(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 $t(e){let t=te("sha256");for await(let r of re(e))t.update(r);return t.digest("hex")}async function Rt(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 kt(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,yt as P,F as Q,wt as R,bt as S,ht as T,xt as U,vt as V,y as W,Pt as X,$t as Y,Rt as Z,kt as _,Ot as $,Ut as aa,Ft as ba,Dt as ca,Tt as da,Et as ea};