conformtools 0.6.0 → 0.6.2

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 (58) hide show
  1. package/README.md +22 -17
  2. package/dist/browser/timeline_core_bg.wasm +0 -0
  3. package/dist/{chunk-UUDNNFU7.js → chunk-BTXLTVNK.js} +1 -1
  4. package/dist/{chunk-AHNDJFQR.js → chunk-BUEIRRNY.js} +1 -1
  5. package/dist/{chunk-PZFWQJCF.js → chunk-BXFVYGFW.js} +1 -1
  6. package/dist/chunk-CX3USH6A.js +318 -0
  7. package/dist/chunk-D5DEQ467.js +3 -0
  8. package/dist/{chunk-N43NAG5E.js → chunk-FNGHTZ5F.js} +1 -1
  9. package/dist/{chunk-PSMXHDMX.js → chunk-JH3OLTR6.js} +1 -1
  10. package/dist/{chunk-7XTBFOUJ.js → chunk-KP4C2MFM.js} +1 -1
  11. package/dist/{chunk-R6WJ6JIQ.js → chunk-PIEH7J6J.js} +1 -1
  12. package/dist/{chunk-XDHIIZ6A.js → chunk-RUBNBRUK.js} +1 -1
  13. package/dist/{chunk-ZAHP3ES5.js → chunk-RULUDOB7.js} +1 -1
  14. package/dist/claude-setup-XSNTKEU7.js +5 -0
  15. package/dist/cli.js +10 -5
  16. package/dist/conformtools-decode +0 -0
  17. package/dist/{cr3-wasm-CWKEOCYH.js → cr3-wasm-YTMVBAFM.js} +1 -1
  18. package/dist/{dng-wasm-JNFS44V5.js → dng-wasm-WUUQB7M2.js} +1 -1
  19. package/dist/{dpx-wasm-VNJRFPYY.js → dpx-wasm-XBKO4V4W.js} +1 -1
  20. package/dist/{exr-wasm-5D66YR7A.js → exr-wasm-VE2W6MFW.js} +1 -1
  21. package/dist/{h264-ZB5DJSNV.js → h264-HD7BY5J5.js} +1 -1
  22. package/dist/{h264-mxf-NVBLGU3V.js → h264-mxf-6OOODSAK.js} +1 -1
  23. package/dist/http.js +1 -1
  24. package/dist/{inspect-MGSZRRAF.js → inspect-TDZCNXVW.js} +1 -1
  25. package/dist/isobmff-57HSD6O2.js +3 -0
  26. package/dist/mcp.js +8 -9
  27. package/dist/{media_core-AISE7FMT.js → media_core-R5PPN3AY.js} +2 -2
  28. package/dist/{media_core_bg-FGAR5KA5.js → media_core_bg-YBW45HJ2.js} +1 -1
  29. package/dist/{mxf-YH2A2XLW.js → mxf-FAXEK4WR.js} +1 -1
  30. package/dist/{ops-BQDPU4M6.js → ops-UPPAG2TI.js} +1 -1
  31. package/dist/{r3d-U4XTQJXQ.js → r3d-EY6FEFKM.js} +1 -1
  32. package/dist/{r3d-T6D3M2XJ.js → r3d-KJVC7T2C.js} +1 -1
  33. package/dist/resolve-bridge.py +458 -35
  34. package/dist/statusline-GMMCFMOA.js +4 -0
  35. package/dist/statusline.js +3 -0
  36. package/dist/{still-UFLOAEM4.js → still-WY7MUR7A.js} +1 -1
  37. package/dist/{tiff-wasm-2CEABW6L.js → tiff-wasm-T2V2ICZT.js} +1 -1
  38. package/dist/wasm/media_core_bg.wasm +0 -0
  39. package/dist/wasm-threads/media_core_bg.wasm +0 -0
  40. package/dist/{wav-KNJZMOGX.js → wav-LFS6OZHJ.js} +1 -1
  41. package/package.json +1 -1
  42. package/dist/chunk-E6YXZIJS.js +0 -230
  43. package/dist/isobmff-7G55HKDG.js +0 -3
  44. package/dist/skills/auto-conform/SKILL.md +0 -87
  45. package/dist/skills/conform-artist/SKILL.md +0 -68
  46. package/dist/skills/conform-artist/references/avid.md +0 -19
  47. package/dist/skills/conform-artist/references/other-hosts.md +0 -23
  48. package/dist/skills/conform-artist/references/premiere.md +0 -18
  49. package/dist/skills/conform-artist/references/resolve.md +0 -19
  50. package/dist/skills/conform-artist/references/troubleshooting.md +0 -33
  51. package/dist/skills/conform-artist/references/turnover-checklist.md +0 -37
  52. package/dist/skills/delivery-qc/SKILL.md +0 -48
  53. /package/dist/{arriraw-3GKCR6K2.js → arriraw-BEZILZY3.js} +0 -0
  54. /package/dist/{chunk-WHY3DVXS.js → chunk-NP53ITN6.js} +0 -0
  55. /package/dist/{media_core_bg-YK63OUDM.js → media_core_bg-5UIQAP7I.js} +0 -0
  56. /package/dist/{prores-L4JZZWGH.js → prores-BNALPJPS.js} +0 -0
  57. /package/dist/{timeline_core_bg-2TYWZ35G.js → timeline_core_bg-XYT26ZTU.js} +0 -0
  58. /package/dist/{udf_bg-A4WEMSAX.js → udf_bg-R3JEZJAT.js} +0 -0
@@ -0,0 +1,318 @@
1
+ #!/usr/bin/env node
2
+ import { createRequire as __conformRequire } from 'node:module'; const require = __conformRequire(import.meta.url);
3
+ import{A as Ti,B as $m,C as ep,D as ii,E as zn,F as Ec,G as tp,H as Mn,I as nf,J as I6,K as W6,L as D6,M as rf,N as np,O as ae,P as Yn,Q as Pr,R as _,S as q6,T as H6,b as Ut,c as xo,d as Po,g as xr,h as ef,i as Z6,j as wt,k as tf,l as zv,m as Fr,n as cn,o as Nn,p as Ar,q as Wi,r as pr,s as Tn,t as or,u as ln,v as vt,w as Er,x as So,y as Mv,z as Gr}from"./chunk-D5DEQ467.js";import{a as _m,d as j6,e as Tv}from"./chunk-GXEVALBL.js";import{a as F6,b as kv,c as V6}from"./chunk-Y2BEEOPB.js";import{a as ri,b as Va,c as R6,d as ip,g as E6,h as C6,i as U6,j as A6}from"./chunk-JH3OLTR6.js";import{S as rp}from"./chunk-C2ESM27Z.js";import{b as k6}from"./chunk-RULUDOB7.js";import{b as T6}from"./chunk-BXFVYGFW.js";import{b as z6}from"./chunk-BTXLTVNK.js";import{b as $u,c as Bm}from"./chunk-RXHNBSER.js";import{a as M6}from"./chunk-QDWB7QU7.js";import{b as Km,c as X6,e as N6,f as Qm}from"./chunk-P7OVDUA5.js";import{b as w6,c as x6}from"./chunk-UCMNH6Q6.js";import{b as P6}from"./chunk-KP4C2MFM.js";import{b as S6}from"./chunk-RUBNBRUK.js";import{a as Ym}from"./chunk-DKGGJM6Z.js";import{a as h6}from"./chunk-NP53ITN6.js";import{a as Ts,b as b6,d as g6,e as Jm}from"./chunk-BUEIRRNY.js";import{a as v6}from"./chunk-TK55FA56.js";import{a as y6}from"./chunk-JEMLKBH2.js";import{d as O6,e as L6,f as zs,i as Yo}from"./chunk-FNGHTZ5F.js";import{$ as i6,A as J4,B as B4,Ba as Hc,C as Y4,Ca as ni,D as K4,I as Q4,K as _4,M as $4,N as e6,P as t6,Q as n6,R as r6,aa as o6,b as Ra,d as D4,ea as a6,f as q4,g as Fa,i as H4,ia as s6,j as E4,q as C4,qa as c6,r as U4,ra as l6,s as Gm,ua as u6,va as f6,w as A4,x as G4,xa as d6,ya as m6,za as p6}from"./chunk-PIEH7J6J.js";import{a as Jo,c as rt,d as Bo,f as W4}from"./chunk-PSANHDZM.js";var Zd=rt((Gbe,FP)=>{"use strict";typeof process>"u"||!process.version||process.version.indexOf("v0.")===0||process.version.indexOf("v1.")===0&&process.version.indexOf("v1.8.")!==0?FP.exports={nextTick:hK}:FP.exports=process;function hK(e,t,n,i){if(typeof e!="function")throw new TypeError('"callback" argument must be a function');var r=arguments.length,o,a;switch(r){case 0:case 1:return process.nextTick(e);case 2:return process.nextTick(function(){e.call(null,t)});case 3:return process.nextTick(function(){e.call(null,t,n)});case 4:return process.nextTick(function(){e.call(null,t,n,i)});default:for(o=new Array(r-1),a=0;a<o.length;)o[a++]=arguments[a];return process.nextTick(function(){e.apply(null,o)})}}});var zX=rt((Jbe,TX)=>{var bK={}.toString;TX.exports=Array.isArray||function(e){return bK.call(e)=="[object Array]"}});var VP=rt((Bbe,MX)=>{MX.exports=Jo("stream")});var Id=rt((jP,LX)=>{var w0=Jo("buffer"),ma=w0.Buffer;function OX(e,t){for(var n in e)t[n]=e[n]}ma.from&&ma.alloc&&ma.allocUnsafe&&ma.allocUnsafeSlow?LX.exports=w0:(OX(w0,jP),jP.Buffer=Kl);function Kl(e,t,n){return ma(e,t,n)}OX(ma,Kl);Kl.from=function(e,t,n){if(typeof e=="number")throw new TypeError("Argument must not be a number");return ma(e,t,n)};Kl.alloc=function(e,t,n){if(typeof e!="number")throw new TypeError("Argument must be a number");var i=ma(e);return t!==void 0?typeof n=="string"?i.fill(t,n):i.fill(t):i.fill(0),i};Kl.allocUnsafe=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return ma(e)};Kl.allocUnsafeSlow=function(e){if(typeof e!="number")throw new TypeError("Argument must be a number");return w0.SlowBuffer(e)}});var Ql=rt(li=>{function gK(e){return Array.isArray?Array.isArray(e):x0(e)==="[object Array]"}li.isArray=gK;function vK(e){return typeof e=="boolean"}li.isBoolean=vK;function yK(e){return e===null}li.isNull=yK;function wK(e){return e==null}li.isNullOrUndefined=wK;function xK(e){return typeof e=="number"}li.isNumber=xK;function PK(e){return typeof e=="string"}li.isString=PK;function SK(e){return typeof e=="symbol"}li.isSymbol=SK;function kK(e){return e===void 0}li.isUndefined=kK;function TK(e){return x0(e)==="[object RegExp]"}li.isRegExp=TK;function zK(e){return typeof e=="object"&&e!==null}li.isObject=zK;function MK(e){return x0(e)==="[object Date]"}li.isDate=MK;function OK(e){return x0(e)==="[object Error]"||e instanceof Error}li.isError=OK;function LK(e){return typeof e=="function"}li.isFunction=LK;function XK(e){return e===null||typeof e=="boolean"||typeof e=="number"||typeof e=="string"||typeof e=="symbol"||typeof e>"u"}li.isPrimitive=XK;li.isBuffer=Jo("buffer").Buffer.isBuffer;function x0(e){return Object.prototype.toString.call(e)}});var XX=rt((Kbe,ZP)=>{typeof Object.create=="function"?ZP.exports=function(t,n){n&&(t.super_=n,t.prototype=Object.create(n.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:ZP.exports=function(t,n){if(n){t.super_=n;var i=function(){};i.prototype=n.prototype,t.prototype=new i,t.prototype.constructor=t}}});var _l=rt((Qbe,WP)=>{try{if(IP=Jo("util"),typeof IP.inherits!="function")throw"";WP.exports=IP.inherits}catch{WP.exports=XX()}var IP});var RX=rt((_be,DP)=>{"use strict";function NK(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var NX=Id().Buffer,Wd=Jo("util");function RK(e,t,n){e.copy(t,n)}DP.exports=(function(){function e(){NK(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(n){var i={data:n,next:null};this.length>0?this.tail.next=i:this.head=i,this.tail=i,++this.length},e.prototype.unshift=function(n){var i={data:n,next:this.head};this.length===0&&(this.tail=i),this.head=i,++this.length},e.prototype.shift=function(){if(this.length!==0){var n=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,n}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(n){if(this.length===0)return"";for(var i=this.head,r=""+i.data;i=i.next;)r+=n+i.data;return r},e.prototype.concat=function(n){if(this.length===0)return NX.alloc(0);for(var i=NX.allocUnsafe(n>>>0),r=this.head,o=0;r;)RK(r.data,i,o),o+=r.data.length,r=r.next;return i},e})();Wd&&Wd.inspect&&Wd.inspect.custom&&(DP.exports.prototype[Wd.inspect.custom]=function(){var e=Wd.inspect({length:this.length});return this.constructor.name+" "+e})});var qP=rt(($be,FX)=>{"use strict";var P0=Zd();function FK(e,t){var n=this,i=this._readableState&&this._readableState.destroyed,r=this._writableState&&this._writableState.destroyed;return i||r?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,P0.nextTick(S0,this,e)):P0.nextTick(S0,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(o){!t&&o?n._writableState?n._writableState.errorEmitted||(n._writableState.errorEmitted=!0,P0.nextTick(S0,n,o)):P0.nextTick(S0,n,o):t&&t(o)}),this)}function VK(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function S0(e,t){e.emit("error",t)}FX.exports={destroy:FK,undestroy:VK}});var jX=rt((e0e,VX)=>{VX.exports=Jo("util").deprecate});var EP=rt((t0e,CX)=>{"use strict";var uc=Zd();CX.exports=Mr;function IX(e){var t=this;this.next=null,this.entry=null,this.finish=function(){_K(t,e)}}var jK=!process.browser&&["v0.10","v0.9."].indexOf(process.version.slice(0,5))>-1?setImmediate:uc.nextTick,$l;Mr.WritableState=qd;var WX=Object.create(Ql());WX.inherits=_l();var ZK={deprecate:jX()},DX=VP(),T0=Id().Buffer,IK=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function WK(e){return T0.from(e)}function DK(e){return T0.isBuffer(e)||e instanceof IK}var qX=qP();WX.inherits(Mr,DX);function qK(){}function qd(e,t){$l=$l||fc(),e=e||{};var n=t instanceof $l;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,r=e.writableHighWaterMark,o=this.objectMode?16:16*1024;i||i===0?this.highWaterMark=i:n&&(r||r===0)?this.highWaterMark=r:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=e.decodeStrings===!1;this.decodeStrings=!a,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(s){JK(t,s)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new IX(this)}qd.prototype.getBuffer=function(){for(var t=this.bufferedRequest,n=[];t;)n.push(t),t=t.next;return n};(function(){try{Object.defineProperty(qd.prototype,"buffer",{get:ZK.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}})();var k0;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(k0=Function.prototype[Symbol.hasInstance],Object.defineProperty(Mr,Symbol.hasInstance,{value:function(e){return k0.call(this,e)?!0:this!==Mr?!1:e&&e._writableState instanceof qd}})):k0=function(e){return e instanceof this};function Mr(e){if($l=$l||fc(),!k0.call(Mr,this)&&!(this instanceof $l))return new Mr(e);this._writableState=new qd(e,this),this.writable=!0,e&&(typeof e.write=="function"&&(this._write=e.write),typeof e.writev=="function"&&(this._writev=e.writev),typeof e.destroy=="function"&&(this._destroy=e.destroy),typeof e.final=="function"&&(this._final=e.final)),DX.call(this)}Mr.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))};function HK(e,t){var n=new Error("write after end");e.emit("error",n),uc.nextTick(t,n)}function EK(e,t,n,i){var r=!0,o=!1;return n===null?o=new TypeError("May not write null values to stream"):typeof n!="string"&&n!==void 0&&!t.objectMode&&(o=new TypeError("Invalid non-string/buffer chunk")),o&&(e.emit("error",o),uc.nextTick(i,o),r=!1),r}Mr.prototype.write=function(e,t,n){var i=this._writableState,r=!1,o=!i.objectMode&&DK(e);return o&&!T0.isBuffer(e)&&(e=WK(e)),typeof t=="function"&&(n=t,t=null),o?t="buffer":t||(t=i.defaultEncoding),typeof n!="function"&&(n=qK),i.ended?HK(this,n):(o||EK(this,i,e,n))&&(i.pendingcb++,r=UK(this,i,o,e,t,n)),r};Mr.prototype.cork=function(){var e=this._writableState;e.corked++};Mr.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,!e.writing&&!e.corked&&!e.bufferProcessing&&e.bufferedRequest&&HX(this,e))};Mr.prototype.setDefaultEncoding=function(t){if(typeof t=="string"&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this};function CK(e,t,n){return!e.objectMode&&e.decodeStrings!==!1&&typeof t=="string"&&(t=T0.from(t,n)),t}Object.defineProperty(Mr.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function UK(e,t,n,i,r,o){if(!n){var a=CK(t,i,r);i!==a&&(n=!0,r="buffer",i=a)}var s=t.objectMode?1:i.length;t.length+=s;var c=t.length<t.highWaterMark;if(c||(t.needDrain=!0),t.writing||t.corked){var l=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:r,isBuf:n,callback:o,next:null},l?l.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else HP(e,t,!1,s,i,r,o);return c}function HP(e,t,n,i,r,o,a){t.writelen=i,t.writecb=a,t.writing=!0,t.sync=!0,n?e._writev(r,t.onwrite):e._write(r,o,t.onwrite),t.sync=!1}function AK(e,t,n,i,r){--t.pendingcb,n?(uc.nextTick(r,i),uc.nextTick(Dd,e,t),e._writableState.errorEmitted=!0,e.emit("error",i)):(r(i),e._writableState.errorEmitted=!0,e.emit("error",i),Dd(e,t))}function GK(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function JK(e,t){var n=e._writableState,i=n.sync,r=n.writecb;if(GK(n),t)AK(e,n,i,t,r);else{var o=EX(n);!o&&!n.corked&&!n.bufferProcessing&&n.bufferedRequest&&HX(e,n),i?jK(ZX,e,n,o,r):ZX(e,n,o,r)}}function ZX(e,t,n,i){n||BK(e,t),t.pendingcb--,i(),Dd(e,t)}function BK(e,t){t.length===0&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function HX(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var i=t.bufferedRequestCount,r=new Array(i),o=t.corkedRequestsFree;o.entry=n;for(var a=0,s=!0;n;)r[a]=n,n.isBuf||(s=!1),n=n.next,a+=1;r.allBuffers=s,HP(e,t,!0,t.length,r,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new IX(t),t.bufferedRequestCount=0}else{for(;n;){var c=n.chunk,l=n.encoding,u=n.callback,f=t.objectMode?1:c.length;if(HP(e,t,!1,f,c,l,u),n=n.next,t.bufferedRequestCount--,t.writing)break}n===null&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}Mr.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))};Mr.prototype._writev=null;Mr.prototype.end=function(e,t,n){var i=this._writableState;typeof e=="function"?(n=e,e=null,t=null):typeof t=="function"&&(n=t,t=null),e!=null&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||QK(this,i,n)};function EX(e){return e.ending&&e.length===0&&e.bufferedRequest===null&&!e.finished&&!e.writing}function YK(e,t){e._final(function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),Dd(e,t)})}function KK(e,t){!t.prefinished&&!t.finalCalled&&(typeof e._final=="function"?(t.pendingcb++,t.finalCalled=!0,uc.nextTick(YK,e,t)):(t.prefinished=!0,e.emit("prefinish")))}function Dd(e,t){var n=EX(t);return n&&(KK(e,t),t.pendingcb===0&&(t.finished=!0,e.emit("finish"))),n}function QK(e,t,n){t.ending=!0,Dd(e,t),n&&(t.finished?uc.nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}function _K(e,t,n){var i=e.entry;for(e.entry=null;i;){var r=i.callback;t.pendingcb--,r(n),i=i.next}t.corkedRequestsFree.next=e}Object.defineProperty(Mr.prototype,"destroyed",{get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}});Mr.prototype.destroy=qX.destroy;Mr.prototype._undestroy=qX.undestroy;Mr.prototype._destroy=function(e,t){this.end(),t(e)}});var fc=rt((n0e,JX)=>{"use strict";var UX=Zd(),$K=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};JX.exports=pa;var AX=Object.create(Ql());AX.inherits=_l();var GX=AP(),UP=EP();AX.inherits(pa,GX);for(CP=$K(UP.prototype),z0=0;z0<CP.length;z0++)M0=CP[z0],pa.prototype[M0]||(pa.prototype[M0]=UP.prototype[M0]);var CP,M0,z0;function pa(e){if(!(this instanceof pa))return new pa(e);GX.call(this,e),UP.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),this.once("end",eQ)}Object.defineProperty(pa.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function eQ(){this.allowHalfOpen||this._writableState.ended||UX.nextTick(tQ,this)}function tQ(e){e.end()}Object.defineProperty(pa.prototype,"destroyed",{get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(e){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=e,this._writableState.destroyed=e)}});pa.prototype._destroy=function(e,t){this.push(null),this.end(),UX.nextTick(t,e)}});var BP=rt(YX=>{"use strict";var JP=Id().Buffer,BX=JP.isEncoding||function(e){switch(e=""+e,e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function nQ(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function rQ(e){var t=nQ(e);if(typeof t!="string"&&(JP.isEncoding===BX||!BX(e)))throw new Error("Unknown encoding: "+e);return t||e}YX.StringDecoder=Hd;function Hd(e){this.encoding=rQ(e);var t;switch(this.encoding){case"utf16le":this.text=lQ,this.end=uQ,t=4;break;case"utf8":this.fillLast=aQ,t=4;break;case"base64":this.text=fQ,this.end=dQ,t=3;break;default:this.write=mQ,this.end=pQ;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=JP.allocUnsafe(t)}Hd.prototype.write=function(e){if(e.length===0)return"";var t,n;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n<e.length?t?t+this.text(e,n):this.text(e,n):t||""};Hd.prototype.end=cQ;Hd.prototype.text=sQ;Hd.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function GP(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function iQ(e,t,n){var i=t.length-1;if(i<n)return 0;var r=GP(t[i]);return r>=0?(r>0&&(e.lastNeed=r-1),r):--i<n||r===-2?0:(r=GP(t[i]),r>=0?(r>0&&(e.lastNeed=r-2),r):--i<n||r===-2?0:(r=GP(t[i]),r>=0?(r>0&&(r===2?r=0:e.lastNeed=r-3),r):0))}function oQ(e,t,n){if((t[0]&192)!==128)return e.lastNeed=0,"\uFFFD";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"\uFFFD";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"\uFFFD"}}function aQ(e){var t=this.lastTotal-this.lastNeed,n=oQ(this,e,t);if(n!==void 0)return n;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function sQ(e,t){var n=iQ(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var i=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)}function cQ(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"\uFFFD":t}function lQ(e,t){if((e.length-t)%2===0){var n=e.toString("utf16le",t);if(n){var i=n.charCodeAt(n.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function uQ(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function fQ(e,t){var n=(e.length-t)%3;return n===0?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,n===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function dQ(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function mQ(e){return e.toString(this.encoding)}function pQ(e){return e&&e.length?this.write(e):""}});var AP=rt((o0e,sN)=>{"use strict";var tu=Zd();sN.exports=ar;var hQ=zX(),Ed;ar.ReadableState=nN;var i0e=Jo("events").EventEmitter,$X=function(e,t){return e.listeners(t).length},$P=VP(),Cd=Id().Buffer,bQ=(typeof global<"u"?global:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function gQ(e){return Cd.from(e)}function vQ(e){return Cd.isBuffer(e)||e instanceof bQ}var eN=Object.create(Ql());eN.inherits=_l();var YP=Jo("util"),Fn=void 0;YP&&YP.debuglog?Fn=YP.debuglog("stream"):Fn=function(){};var yQ=RX(),tN=qP(),eu;eN.inherits(ar,$P);var KP=["error","close","destroy","pause","resume"];function wQ(e,t,n){if(typeof e.prependListener=="function")return e.prependListener(t,n);!e._events||!e._events[t]?e.on(t,n):hQ(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]}function nN(e,t){Ed=Ed||fc(),e=e||{};var n=t instanceof Ed;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,r=e.readableHighWaterMark,o=this.objectMode?16:16*1024;i||i===0?this.highWaterMark=i:n&&(r||r===0)?this.highWaterMark=r:this.highWaterMark=o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new yQ,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(eu||(eu=BP().StringDecoder),this.decoder=new eu(e.encoding),this.encoding=e.encoding)}function ar(e){if(Ed=Ed||fc(),!(this instanceof ar))return new ar(e);this._readableState=new nN(e,this),this.readable=!0,e&&(typeof e.read=="function"&&(this._read=e.read),typeof e.destroy=="function"&&(this._destroy=e.destroy)),$P.call(this)}Object.defineProperty(ar.prototype,"destroyed",{get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}});ar.prototype.destroy=tN.destroy;ar.prototype._undestroy=tN.undestroy;ar.prototype._destroy=function(e,t){this.push(null),t(e)};ar.prototype.push=function(e,t){var n=this._readableState,i;return n.objectMode?i=!0:typeof e=="string"&&(t=t||n.defaultEncoding,t!==n.encoding&&(e=Cd.from(e,t),t=""),i=!0),rN(this,e,t,!1,i)};ar.prototype.unshift=function(e){return rN(this,e,null,!0,!1)};function rN(e,t,n,i,r){var o=e._readableState;if(t===null)o.reading=!1,kQ(e,o);else{var a;r||(a=xQ(o,t)),a?e.emit("error",a):o.objectMode||t&&t.length>0?(typeof t!="string"&&!o.objectMode&&Object.getPrototypeOf(t)!==Cd.prototype&&(t=gQ(t)),i?o.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):QP(e,o,t,!0):o.ended?e.emit("error",new Error("stream.push() after EOF")):(o.reading=!1,o.decoder&&!n?(t=o.decoder.write(t),o.objectMode||t.length!==0?QP(e,o,t,!1):iN(e,o)):QP(e,o,t,!1))):i||(o.reading=!1)}return PQ(o)}function QP(e,t,n,i){t.flowing&&t.length===0&&!t.sync?(e.emit("data",n),e.read(0)):(t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&O0(e)),iN(e,t)}function xQ(e,t){var n;return!vQ(t)&&typeof t!="string"&&t!==void 0&&!e.objectMode&&(n=new TypeError("Invalid non-string/buffer chunk")),n}function PQ(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||e.length===0)}ar.prototype.isPaused=function(){return this._readableState.flowing===!1};ar.prototype.setEncoding=function(e){return eu||(eu=BP().StringDecoder),this._readableState.decoder=new eu(e),this._readableState.encoding=e,this};var KX=8388608;function SQ(e){return e>=KX?e=KX:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function QX(e,t){return e<=0||t.length===0&&t.ended?0:t.objectMode?1:e!==e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=SQ(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}ar.prototype.read=function(e){Fn("read",e),e=parseInt(e,10);var t=this._readableState,n=e;if(e!==0&&(t.emittedReadable=!1),e===0&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return Fn("read: emitReadable",t.length,t.ended),t.length===0&&t.ended?_P(this):O0(this),null;if(e=QX(e,t),e===0&&t.ended)return t.length===0&&_P(this),null;var i=t.needReadable;Fn("need readable",i),(t.length===0||t.length-e<t.highWaterMark)&&(i=!0,Fn("length less than watermark",i)),t.ended||t.reading?(i=!1,Fn("reading or ended",i)):i&&(Fn("do read"),t.reading=!0,t.sync=!0,t.length===0&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=QX(n,t)));var r;return e>0?r=oN(e,t):r=null,r===null?(t.needReadable=!0,e=0):t.length-=e,t.length===0&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&_P(this)),r!==null&&this.emit("data",r),r};function kQ(e,t){if(!t.ended){if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,O0(e)}}function O0(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(Fn("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?tu.nextTick(_X,e):_X(e))}function _X(e){Fn("emit readable"),e.emit("readable"),eS(e)}function iN(e,t){t.readingMore||(t.readingMore=!0,tu.nextTick(TQ,e,t))}function TQ(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(Fn("maybeReadMore read 0"),e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}ar.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))};ar.prototype.pipe=function(e,t){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e);break}i.pipesCount+=1,Fn("pipe count=%d opts=%j",i.pipesCount,t);var r=(!t||t.end!==!1)&&e!==process.stdout&&e!==process.stderr,o=r?s:h;i.endEmitted?tu.nextTick(o):n.once("end",o),e.on("unpipe",a);function a(v,g){Fn("onunpipe"),v===n&&g&&g.hasUnpiped===!1&&(g.hasUnpiped=!0,u())}function s(){Fn("onend"),e.end()}var c=zQ(n);e.on("drain",c);var l=!1;function u(){Fn("cleanup"),e.removeListener("close",p),e.removeListener("finish",b),e.removeListener("drain",c),e.removeListener("error",m),e.removeListener("unpipe",a),n.removeListener("end",s),n.removeListener("end",h),n.removeListener("data",d),l=!0,i.awaitDrain&&(!e._writableState||e._writableState.needDrain)&&c()}var f=!1;n.on("data",d);function d(v){Fn("ondata"),f=!1;var g=e.write(v);g===!1&&!f&&((i.pipesCount===1&&i.pipes===e||i.pipesCount>1&&aN(i.pipes,e)!==-1)&&!l&&(Fn("false write response, pause",i.awaitDrain),i.awaitDrain++,f=!0),n.pause())}function m(v){Fn("onerror",v),h(),e.removeListener("error",m),$X(e,"error")===0&&e.emit("error",v)}wQ(e,"error",m);function p(){e.removeListener("finish",b),h()}e.once("close",p);function b(){Fn("onfinish"),e.removeListener("close",p),h()}e.once("finish",b);function h(){Fn("unpipe"),n.unpipe(e)}return e.emit("pipe",n),i.flowing||(Fn("pipe resume"),n.resume()),e};function zQ(e){return function(){var t=e._readableState;Fn("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,t.awaitDrain===0&&$X(e,"data")&&(t.flowing=!0,eS(e))}}ar.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(t.pipesCount===0)return this;if(t.pipesCount===1)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n),this);if(!e){var i=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<r;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=aN(t.pipes,e);return a===-1?this:(t.pipes.splice(a,1),t.pipesCount-=1,t.pipesCount===1&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n),this)};ar.prototype.on=function(e,t){var n=$P.prototype.on.call(this,e,t);if(e==="data")this._readableState.flowing!==!1&&this.resume();else if(e==="readable"){var i=this._readableState;!i.endEmitted&&!i.readableListening&&(i.readableListening=i.needReadable=!0,i.emittedReadable=!1,i.reading?i.length&&O0(this):tu.nextTick(MQ,this))}return n};ar.prototype.addListener=ar.prototype.on;function MQ(e){Fn("readable nexttick read 0"),e.read(0)}ar.prototype.resume=function(){var e=this._readableState;return e.flowing||(Fn("resume"),e.flowing=!0,OQ(this,e)),this};function OQ(e,t){t.resumeScheduled||(t.resumeScheduled=!0,tu.nextTick(LQ,e,t))}function LQ(e,t){t.reading||(Fn("resume read 0"),e.read(0)),t.resumeScheduled=!1,t.awaitDrain=0,e.emit("resume"),eS(e),t.flowing&&!t.reading&&e.read(0)}ar.prototype.pause=function(){return Fn("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Fn("pause"),this._readableState.flowing=!1,this.emit("pause")),this};function eS(e){var t=e._readableState;for(Fn("flow",t.flowing);t.flowing&&e.read()!==null;);}ar.prototype.wrap=function(e){var t=this,n=this._readableState,i=!1;e.on("end",function(){if(Fn("wrapped end"),n.decoder&&!n.ended){var a=n.decoder.end();a&&a.length&&t.push(a)}t.push(null)}),e.on("data",function(a){if(Fn("wrapped data"),n.decoder&&(a=n.decoder.write(a)),!(n.objectMode&&a==null)&&!(!n.objectMode&&(!a||!a.length))){var s=t.push(a);s||(i=!0,e.pause())}});for(var r in e)this[r]===void 0&&typeof e[r]=="function"&&(this[r]=(function(a){return function(){return e[a].apply(e,arguments)}})(r));for(var o=0;o<KP.length;o++)e.on(KP[o],this.emit.bind(this,KP[o]));return this._read=function(a){Fn("wrapped _read",a),i&&(i=!1,e.resume())},this};Object.defineProperty(ar.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}});ar._fromList=oN;function oN(e,t){if(t.length===0)return null;var n;return t.objectMode?n=t.buffer.shift():!e||e>=t.length?(t.decoder?n=t.buffer.join(""):t.buffer.length===1?n=t.buffer.head.data:n=t.buffer.concat(t.length),t.buffer.clear()):n=XQ(e,t.buffer,t.decoder),n}function XQ(e,t,n){var i;return e<t.head.data.length?(i=t.head.data.slice(0,e),t.head.data=t.head.data.slice(e)):e===t.head.data.length?i=t.shift():i=n?NQ(e,t):RQ(e,t),i}function NQ(e,t){var n=t.head,i=1,r=n.data;for(e-=r.length;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(a===o.length?r+=o:r+=o.slice(0,e),e-=a,e===0){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}function RQ(e,t){var n=Cd.allocUnsafe(e),i=t.head,r=1;for(i.data.copy(n),e-=i.data.length;i=i.next;){var o=i.data,a=e>o.length?o.length:e;if(o.copy(n,n.length-e,0,a),e-=a,e===0){a===o.length?(++r,i.next?t.head=i.next:t.head=t.tail=null):(t.head=i,i.data=o.slice(a));break}++r}return t.length-=r,n}function _P(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,tu.nextTick(FQ,t,e))}function FQ(e,t){!e.endEmitted&&e.length===0&&(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function aN(e,t){for(var n=0,i=e.length;n<i;n++)if(e[n]===t)return n;return-1}});var tS=rt((a0e,uN)=>{"use strict";uN.exports=ha;var L0=fc(),lN=Object.create(Ql());lN.inherits=_l();lN.inherits(ha,L0);function VQ(e,t){var n=this._transformState;n.transforming=!1;var i=n.writecb;if(!i)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,t!=null&&this.push(t),i(e);var r=this._readableState;r.reading=!1,(r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}function ha(e){if(!(this instanceof ha))return new ha(e);L0.call(this,e),this._transformState={afterTransform:VQ.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",jQ)}function jQ(){var e=this;typeof this._flush=="function"?this._flush(function(t,n){cN(e,t,n)}):cN(this,null,null)}ha.prototype.push=function(e,t){return this._transformState.needTransform=!1,L0.prototype.push.call(this,e,t)};ha.prototype._transform=function(e,t,n){throw new Error("_transform() is not implemented")};ha.prototype._write=function(e,t,n){var i=this._transformState;if(i.writecb=n,i.writechunk=e,i.writeencoding=t,!i.transforming){var r=this._readableState;(i.needTransform||r.needReadable||r.length<r.highWaterMark)&&this._read(r.highWaterMark)}};ha.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&t.writecb&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};ha.prototype._destroy=function(e,t){var n=this;L0.prototype._destroy.call(this,e,function(i){t(i),n.emit("close")})};function cN(e,t,n){if(t)return e.emit("error",t);if(n!=null&&e.push(n),e._writableState.length)throw new Error("Calling transform done when ws.length != 0");if(e._transformState.transforming)throw new Error("Calling transform done when still transforming");return e.push(null)}});var pN=rt((s0e,mN)=>{"use strict";mN.exports=Ud;var fN=tS(),dN=Object.create(Ql());dN.inherits=_l();dN.inherits(Ud,fN);function Ud(e){if(!(this instanceof Ud))return new Ud(e);fN.call(this,e)}Ud.prototype._transform=function(e,t,n){n(null,e)}});var nS=rt((Qr,X0)=>{var Vo=Jo("stream");process.env.READABLE_STREAM==="disable"&&Vo?(X0.exports=Vo,Qr=X0.exports=Vo.Readable,Qr.Readable=Vo.Readable,Qr.Writable=Vo.Writable,Qr.Duplex=Vo.Duplex,Qr.Transform=Vo.Transform,Qr.PassThrough=Vo.PassThrough,Qr.Stream=Vo):(Qr=X0.exports=AP(),Qr.Stream=Vo||Qr,Qr.Readable=Qr,Qr.Writable=EP(),Qr.Duplex=fc(),Qr.Transform=tS(),Qr.PassThrough=pN())});var ba=rt(Ci=>{"use strict";Ci.base64=!0;Ci.array=!0;Ci.string=!0;Ci.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u";Ci.nodebuffer=typeof Buffer<"u";Ci.uint8array=typeof Uint8Array<"u";if(typeof ArrayBuffer>"u")Ci.blob=!1;else{rS=new ArrayBuffer(0);try{Ci.blob=new Blob([rS],{type:"application/zip"}).size===0}catch{try{hN=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,iS=new hN,iS.append(rS),Ci.blob=iS.getBlob("application/zip").size===0}catch{Ci.blob=!1}}}var rS,hN,iS;try{Ci.nodestream=!!nS().Readable}catch{Ci.nodestream=!1}});var aS=rt(oS=>{"use strict";var ZQ=br(),IQ=ba(),jo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";oS.encode=function(e){for(var t=[],n,i,r,o,a,s,c,l=0,u=e.length,f=u,d=ZQ.getTypeOf(e)!=="string";l<e.length;)f=u-l,d?(n=e[l++],i=l<u?e[l++]:0,r=l<u?e[l++]:0):(n=e.charCodeAt(l++),i=l<u?e.charCodeAt(l++):0,r=l<u?e.charCodeAt(l++):0),o=n>>2,a=(n&3)<<4|i>>4,s=f>1?(i&15)<<2|r>>6:64,c=f>2?r&63:64,t.push(jo.charAt(o)+jo.charAt(a)+jo.charAt(s)+jo.charAt(c));return t.join("")};oS.decode=function(e){var t,n,i,r,o,a,s,c=0,l=0,u="data:";if(e.substr(0,u.length)===u)throw new Error("Invalid base64 input, it looks like a data url.");e=e.replace(/[^A-Za-z0-9+/=]/g,"");var f=e.length*3/4;if(e.charAt(e.length-1)===jo.charAt(64)&&f--,e.charAt(e.length-2)===jo.charAt(64)&&f--,f%1!==0)throw new Error("Invalid base64 input, bad content length.");var d;for(IQ.uint8array?d=new Uint8Array(f|0):d=new Array(f|0);c<e.length;)r=jo.indexOf(e.charAt(c++)),o=jo.indexOf(e.charAt(c++)),a=jo.indexOf(e.charAt(c++)),s=jo.indexOf(e.charAt(c++)),t=r<<2|o>>4,n=(o&15)<<4|a>>2,i=(a&3)<<6|s,d[l++]=t,a!==64&&(d[l++]=n),s!==64&&(d[l++]=i);return d}});var Ad=rt((u0e,bN)=>{"use strict";bN.exports={isNode:typeof Buffer<"u",newBufferFrom:function(e,t){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(e,t);if(typeof e=="number")throw new Error('The "data" argument must not be a number');return new Buffer(e,t)},allocBuffer:function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t},isBuffer:function(e){return Buffer.isBuffer(e)},isStream:function(e){return e&&typeof e.on=="function"&&typeof e.pause=="function"&&typeof e.resume=="function"}}});var wN=rt((f0e,yN)=>{"use strict";var gN=global.MutationObserver||global.WebKitMutationObserver,nu;process.browser?gN?(sS=0,vN=new gN(Gd),cS=global.document.createTextNode(""),vN.observe(cS,{characterData:!0}),nu=function(){cS.data=sS=++sS%2}):!global.setImmediate&&typeof global.MessageChannel<"u"?(lS=new global.MessageChannel,lS.port1.onmessage=Gd,nu=function(){lS.port2.postMessage(0)}):"document"in global&&"onreadystatechange"in global.document.createElement("script")?nu=function(){var e=global.document.createElement("script");e.onreadystatechange=function(){Gd(),e.onreadystatechange=null,e.parentNode.removeChild(e),e=null},global.document.documentElement.appendChild(e)}:nu=function(){setTimeout(Gd,0)}:nu=function(){process.nextTick(Gd)};var sS,vN,cS,lS,uS,Jd=[];function Gd(){uS=!0;for(var e,t,n=Jd.length;n;){for(t=Jd,Jd=[],e=-1;++e<n;)t[e]();n=Jd.length}uS=!1}yN.exports=WQ;function WQ(e){Jd.push(e)===1&&!uS&&nu()}});var MN=rt((d0e,zN)=>{"use strict";var xN=wN();function ru(){}var ui={},PN=["REJECTED"],fS=["FULFILLED"],SN=["PENDING"];process.browser||(Bd=["UNHANDLED"]);var Bd;zN.exports=is;function is(e){if(typeof e!="function")throw new TypeError("resolver must be a function");this.state=SN,this.queue=[],this.outcome=void 0,process.browser||(this.handled=Bd),e!==ru&&kN(this,e)}is.prototype.finally=function(e){if(typeof e!="function")return this;var t=this.constructor;return this.then(n,i);function n(r){function o(){return r}return t.resolve(e()).then(o)}function i(r){function o(){throw r}return t.resolve(e()).then(o)}};is.prototype.catch=function(e){return this.then(null,e)};is.prototype.then=function(e,t){if(typeof e!="function"&&this.state===fS||typeof t!="function"&&this.state===PN)return this;var n=new this.constructor(ru);if(process.browser||this.handled===Bd&&(this.handled=null),this.state!==SN){var i=this.state===fS?e:t;dS(n,i,this.outcome)}else this.queue.push(new Yd(n,e,t));return n};function Yd(e,t,n){this.promise=e,typeof t=="function"&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),typeof n=="function"&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}Yd.prototype.callFulfilled=function(e){ui.resolve(this.promise,e)};Yd.prototype.otherCallFulfilled=function(e){dS(this.promise,this.onFulfilled,e)};Yd.prototype.callRejected=function(e){ui.reject(this.promise,e)};Yd.prototype.otherCallRejected=function(e){dS(this.promise,this.onRejected,e)};function dS(e,t,n){xN(function(){var i;try{i=t(n)}catch(r){return ui.reject(e,r)}i===e?ui.reject(e,new TypeError("Cannot resolve promise with itself")):ui.resolve(e,i)})}ui.resolve=function(e,t){var n=TN(DQ,t);if(n.status==="error")return ui.reject(e,n.value);var i=n.value;if(i)kN(e,i);else{e.state=fS,e.outcome=t;for(var r=-1,o=e.queue.length;++r<o;)e.queue[r].callFulfilled(t)}return e};ui.reject=function(e,t){e.state=PN,e.outcome=t,process.browser||e.handled===Bd&&xN(function(){e.handled===Bd&&process.emit("unhandledRejection",t,e)});for(var n=-1,i=e.queue.length;++n<i;)e.queue[n].callRejected(t);return e};function DQ(e){var t=e&&e.then;if(e&&(typeof e=="object"||typeof e=="function")&&typeof t=="function")return function(){t.apply(e,arguments)}}function kN(e,t){var n=!1;function i(s){n||(n=!0,ui.reject(e,s))}function r(s){n||(n=!0,ui.resolve(e,s))}function o(){t(r,i)}var a=TN(o);a.status==="error"&&i(a.value)}function TN(e,t){var n={};try{n.value=e(t),n.status="success"}catch(i){n.status="error",n.value=i}return n}is.resolve=qQ;function qQ(e){return e instanceof this?e:ui.resolve(new this(ru),e)}is.reject=HQ;function HQ(e){var t=new this(ru);return ui.reject(t,e)}is.all=EQ;function EQ(e){var t=this;if(Object.prototype.toString.call(e)!=="[object Array]")return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var r=new Array(n),o=0,a=-1,s=new this(ru);++a<n;)c(e[a],a);return s;function c(l,u){t.resolve(l).then(f,function(d){i||(i=!0,ui.reject(s,d))});function f(d){r[u]=d,++o===n&&!i&&(i=!0,ui.resolve(s,r))}}}is.race=CQ;function CQ(e){var t=this;if(Object.prototype.toString.call(e)!=="[object Array]")return this.reject(new TypeError("must be an array"));var n=e.length,i=!1;if(!n)return this.resolve([]);for(var r=-1,o=new this(ru);++r<n;)a(e[r]);return o;function a(s){t.resolve(s).then(function(c){i||(i=!0,ui.resolve(o,c))},function(c){i||(i=!0,ui.reject(o,c))})}}});var iu=rt((m0e,ON)=>{"use strict";var mS=null;typeof Promise<"u"?mS=Promise:mS=MN();ON.exports={Promise:mS}});var XN=rt(LN=>{(function(e,t){"use strict";if(e.setImmediate)return;var n=1,i={},r=!1,o=e.document,a;function s(g){typeof g!="function"&&(g=new Function(""+g));for(var y=new Array(arguments.length-1),w=0;w<y.length;w++)y[w]=arguments[w+1];var x={callback:g,args:y};return i[n]=x,a(n),n++}function c(g){delete i[g]}function l(g){var y=g.callback,w=g.args;switch(w.length){case 0:y();break;case 1:y(w[0]);break;case 2:y(w[0],w[1]);break;case 3:y(w[0],w[1],w[2]);break;default:y.apply(t,w);break}}function u(g){if(r)setTimeout(u,0,g);else{var y=i[g];if(y){r=!0;try{l(y)}finally{c(g),r=!1}}}}function f(){a=function(g){process.nextTick(function(){u(g)})}}function d(){if(e.postMessage&&!e.importScripts){var g=!0,y=e.onmessage;return e.onmessage=function(){g=!1},e.postMessage("","*"),e.onmessage=y,g}}function m(){var g="setImmediate$"+Math.random()+"$",y=function(w){w.source===e&&typeof w.data=="string"&&w.data.indexOf(g)===0&&u(+w.data.slice(g.length))};e.addEventListener?e.addEventListener("message",y,!1):e.attachEvent("onmessage",y),a=function(w){e.postMessage(g+w,"*")}}function p(){var g=new MessageChannel;g.port1.onmessage=function(y){var w=y.data;u(w)},a=function(y){g.port2.postMessage(y)}}function b(){var g=o.documentElement;a=function(y){var w=o.createElement("script");w.onreadystatechange=function(){u(y),w.onreadystatechange=null,g.removeChild(w),w=null},g.appendChild(w)}}function h(){a=function(g){setTimeout(u,0,g)}}var v=Object.getPrototypeOf&&Object.getPrototypeOf(e);v=v&&v.setTimeout?v:e,{}.toString.call(e.process)==="[object process]"?f():d()?m():e.MessageChannel?p():o&&"onreadystatechange"in o.createElement("script")?b():h(),v.setImmediate=s,v.clearImmediate=c})(typeof self>"u"?typeof global>"u"?LN:global:self)});var br=rt(Or=>{"use strict";var os=ba(),UQ=aS(),ou=Ad(),pS=iu();XN();function AQ(e){var t=null;return os.uint8array?t=new Uint8Array(e.length):t=new Array(e.length),R0(e,t)}Or.newBlob=function(e,t){Or.checkSupport("blob");try{return new Blob([e],{type:t})}catch{try{var n=self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder,i=new n;return i.append(e),i.getBlob(t)}catch{throw new Error("Bug : can't construct the Blob.")}}};function Kd(e){return e}function R0(e,t){for(var n=0;n<e.length;++n)t[n]=e.charCodeAt(n)&255;return t}var N0={stringifyByChunk:function(e,t,n){var i=[],r=0,o=e.length;if(o<=n)return String.fromCharCode.apply(null,e);for(;r<o;)t==="array"||t==="nodebuffer"?i.push(String.fromCharCode.apply(null,e.slice(r,Math.min(r+n,o)))):i.push(String.fromCharCode.apply(null,e.subarray(r,Math.min(r+n,o)))),r+=n;return i.join("")},stringifyByChar:function(e){for(var t="",n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},applyCanBeUsed:{uint8array:(function(){try{return os.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return os.nodebuffer&&String.fromCharCode.apply(null,ou.allocBuffer(1)).length===1}catch{return!1}})()}};function Qd(e){var t=65536,n=Or.getTypeOf(e),i=!0;if(n==="uint8array"?i=N0.applyCanBeUsed.uint8array:n==="nodebuffer"&&(i=N0.applyCanBeUsed.nodebuffer),i)for(;t>1;)try{return N0.stringifyByChunk(e,n,t)}catch{t=Math.floor(t/2)}return N0.stringifyByChar(e)}Or.applyFromCharCode=Qd;function F0(e,t){for(var n=0;n<e.length;n++)t[n]=e[n];return t}var as={};as.string={string:Kd,array:function(e){return R0(e,new Array(e.length))},arraybuffer:function(e){return as.string.uint8array(e).buffer},uint8array:function(e){return R0(e,new Uint8Array(e.length))},nodebuffer:function(e){return R0(e,ou.allocBuffer(e.length))}};as.array={string:Qd,array:Kd,arraybuffer:function(e){return new Uint8Array(e).buffer},uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return ou.newBufferFrom(e)}};as.arraybuffer={string:function(e){return Qd(new Uint8Array(e))},array:function(e){return F0(new Uint8Array(e),new Array(e.byteLength))},arraybuffer:Kd,uint8array:function(e){return new Uint8Array(e)},nodebuffer:function(e){return ou.newBufferFrom(new Uint8Array(e))}};as.uint8array={string:Qd,array:function(e){return F0(e,new Array(e.length))},arraybuffer:function(e){return e.buffer},uint8array:Kd,nodebuffer:function(e){return ou.newBufferFrom(e)}};as.nodebuffer={string:Qd,array:function(e){return F0(e,new Array(e.length))},arraybuffer:function(e){return as.nodebuffer.uint8array(e).buffer},uint8array:function(e){return F0(e,new Uint8Array(e.length))},nodebuffer:Kd};Or.transformTo=function(e,t){if(t||(t=""),!e)return t;Or.checkSupport(e);var n=Or.getTypeOf(t),i=as[n][e](t);return i};Or.resolve=function(e){for(var t=e.split("/"),n=[],i=0;i<t.length;i++){var r=t[i];r==="."||r===""&&i!==0&&i!==t.length-1||(r===".."?n.pop():n.push(r))}return n.join("/")};Or.getTypeOf=function(e){if(typeof e=="string")return"string";if(Object.prototype.toString.call(e)==="[object Array]")return"array";if(os.nodebuffer&&ou.isBuffer(e))return"nodebuffer";if(os.uint8array&&e instanceof Uint8Array)return"uint8array";if(os.arraybuffer&&e instanceof ArrayBuffer)return"arraybuffer"};Or.checkSupport=function(e){var t=os[e.toLowerCase()];if(!t)throw new Error(e+" is not supported by this platform")};Or.MAX_VALUE_16BITS=65535;Or.MAX_VALUE_32BITS=-1;Or.pretty=function(e){var t="",n,i;for(i=0;i<(e||"").length;i++)n=e.charCodeAt(i),t+="\\x"+(n<16?"0":"")+n.toString(16).toUpperCase();return t};Or.delay=function(e,t,n){setImmediate(function(){e.apply(n||null,t||[])})};Or.inherits=function(e,t){var n=function(){};n.prototype=t.prototype,e.prototype=new n};Or.extend=function(){var e={},t,n;for(t=0;t<arguments.length;t++)for(n in arguments[t])Object.prototype.hasOwnProperty.call(arguments[t],n)&&typeof e[n]>"u"&&(e[n]=arguments[t][n]);return e};Or.prepareContent=function(e,t,n,i,r){var o=pS.Promise.resolve(t).then(function(a){var s=os.blob&&(a instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(a))!==-1);return s&&typeof FileReader<"u"?new pS.Promise(function(c,l){var u=new FileReader;u.onload=function(f){c(f.target.result)},u.onerror=function(f){l(f.target.error)},u.readAsArrayBuffer(a)}):a});return o.then(function(a){var s=Or.getTypeOf(a);return s?(s==="arraybuffer"?a=Or.transformTo("uint8array",a):s==="string"&&(r?a=UQ.decode(a):n&&i!==!0&&(a=AQ(a))),a):pS.Promise.reject(new Error("Can't read the data of '"+e+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}});var Ui=rt((b0e,RN)=>{"use strict";function NN(e){this.name=e||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}NN.prototype={push:function(e){this.emit("data",e)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(e){this.emit("error",e)}return!0},error:function(e){return this.isFinished?!1:(this.isPaused?this.generatedError=e:(this.isFinished=!0,this.emit("error",e),this.previous&&this.previous.error(e),this.cleanUp()),!0)},on:function(e,t){return this._listeners[e].push(t),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(e,t){if(this._listeners[e])for(var n=0;n<this._listeners[e].length;n++)this._listeners[e][n].call(this,t)},pipe:function(e){return e.registerPrevious(this)},registerPrevious:function(e){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=e.streamInfo,this.mergeStreamInfo(),this.previous=e;var t=this;return e.on("data",function(n){t.processChunk(n)}),e.on("end",function(){t.end()}),e.on("error",function(n){t.error(n)}),this},pause:function(){return this.isPaused||this.isFinished?!1:(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;this.isPaused=!1;var e=!1;return this.generatedError&&(this.error(this.generatedError),e=!0),this.previous&&this.previous.resume(),!e},flush:function(){},processChunk:function(e){this.push(e)},withStreamInfo:function(e,t){return this.extraStreamInfo[e]=t,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var e in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,e)&&(this.streamInfo[e]=this.extraStreamInfo[e])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var e="Worker "+this.name;return this.previous?this.previous+" -> "+e:e}};RN.exports=NN});var su=rt(ss=>{"use strict";var au=br(),dc=ba(),GQ=Ad(),V0=Ui(),_d=new Array(256);for(ga=0;ga<256;ga++)_d[ga]=ga>=252?6:ga>=248?5:ga>=240?4:ga>=224?3:ga>=192?2:1;var ga;_d[254]=_d[254]=1;var JQ=function(e){var t,n,i,r,o,a=e.length,s=0;for(r=0;r<a;r++)n=e.charCodeAt(r),(n&64512)===55296&&r+1<a&&(i=e.charCodeAt(r+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),r++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(dc.uint8array?t=new Uint8Array(s):t=new Array(s),o=0,r=0;o<s;r++)n=e.charCodeAt(r),(n&64512)===55296&&r+1<a&&(i=e.charCodeAt(r+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),r++)),n<128?t[o++]=n:n<2048?(t[o++]=192|n>>>6,t[o++]=128|n&63):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|n&63):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|n&63);return t},BQ=function(e,t){var n;for(t=t||e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+_d[e[n]]>t?n:t},YQ=function(e){var t,n,i,r,o=e.length,a=new Array(o*2);for(n=0,t=0;t<o;){if(i=e[t++],i<128){a[n++]=i;continue}if(r=_d[i],r>4){a[n++]=65533,t+=r-1;continue}for(i&=r===2?31:r===3?15:7;r>1&&t<o;)i=i<<6|e[t++]&63,r--;if(r>1){a[n++]=65533;continue}i<65536?a[n++]=i:(i-=65536,a[n++]=55296|i>>10&1023,a[n++]=56320|i&1023)}return a.length!==n&&(a.subarray?a=a.subarray(0,n):a.length=n),au.applyFromCharCode(a)};ss.utf8encode=function(t){return dc.nodebuffer?GQ.newBufferFrom(t,"utf-8"):JQ(t)};ss.utf8decode=function(t){return dc.nodebuffer?au.transformTo("nodebuffer",t).toString("utf-8"):(t=au.transformTo(dc.uint8array?"uint8array":"array",t),YQ(t))};function j0(){V0.call(this,"utf-8 decode"),this.leftOver=null}au.inherits(j0,V0);j0.prototype.processChunk=function(e){var t=au.transformTo(dc.uint8array?"uint8array":"array",e.data);if(this.leftOver&&this.leftOver.length){if(dc.uint8array){var n=t;t=new Uint8Array(n.length+this.leftOver.length),t.set(this.leftOver,0),t.set(n,this.leftOver.length)}else t=this.leftOver.concat(t);this.leftOver=null}var i=BQ(t),r=t;i!==t.length&&(dc.uint8array?(r=t.subarray(0,i),this.leftOver=t.subarray(i,t.length)):(r=t.slice(0,i),this.leftOver=t.slice(i,t.length))),this.push({data:ss.utf8decode(r),meta:e.meta})};j0.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:ss.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)};ss.Utf8DecodeWorker=j0;function hS(){V0.call(this,"utf-8 encode")}au.inherits(hS,V0);hS.prototype.processChunk=function(e){this.push({data:ss.utf8encode(e.data),meta:e.meta})};ss.Utf8EncodeWorker=hS});var ZN=rt((v0e,jN)=>{"use strict";var FN=Ui(),VN=br();function bS(e){FN.call(this,"ConvertWorker to "+e),this.destType=e}VN.inherits(bS,FN);bS.prototype.processChunk=function(e){this.push({data:VN.transformTo(this.destType,e.data),meta:e.meta})};jN.exports=bS});var DN=rt((y0e,WN)=>{"use strict";var IN=nS().Readable,KQ=br();KQ.inherits(gS,IN);function gS(e,t,n){IN.call(this,t),this._helper=e;var i=this;e.on("data",function(r,o){i.push(r)||i._helper.pause(),n&&n(o)}).on("error",function(r){i.emit("error",r)}).on("end",function(){i.push(null)})}gS.prototype._read=function(){this._helper.resume()};WN.exports=gS});var vS=rt((w0e,EN)=>{"use strict";var mc=br(),QQ=ZN(),_Q=Ui(),$Q=aS(),e_=ba(),t_=iu(),qN=null;if(e_.nodestream)try{qN=DN()}catch{}function n_(e,t,n){switch(e){case"blob":return mc.newBlob(mc.transformTo("arraybuffer",t),n);case"base64":return $Q.encode(t);default:return mc.transformTo(e,t)}}function r_(e,t){var n,i=0,r=null,o=0;for(n=0;n<t.length;n++)o+=t[n].length;switch(e){case"string":return t.join("");case"array":return Array.prototype.concat.apply([],t);case"uint8array":for(r=new Uint8Array(o),n=0;n<t.length;n++)r.set(t[n],i),i+=t[n].length;return r;case"nodebuffer":return Buffer.concat(t);default:throw new Error("concat : unsupported type '"+e+"'")}}function i_(e,t){return new t_.Promise(function(n,i){var r=[],o=e._internalType,a=e._outputType,s=e._mimeType;e.on("data",function(c,l){r.push(c),t&&t(l)}).on("error",function(c){r=[],i(c)}).on("end",function(){try{var c=n_(a,r_(o,r),s);n(c)}catch(l){i(l)}r=[]}).resume()})}function HN(e,t,n){var i=t;switch(t){case"blob":case"arraybuffer":i="uint8array";break;case"base64":i="string";break}try{this._internalType=i,this._outputType=t,this._mimeType=n,mc.checkSupport(i),this._worker=e.pipe(new QQ(i)),e.lock()}catch(r){this._worker=new _Q("error"),this._worker.error(r)}}HN.prototype={accumulate:function(e){return i_(this,e)},on:function(e,t){var n=this;return e==="data"?this._worker.on(e,function(i){t.call(n,i.data,i.meta)}):this._worker.on(e,function(){mc.delay(t,arguments,n)}),this},resume:function(){return mc.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(e){if(mc.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new qN(this,{objectMode:this._outputType!=="nodebuffer"},e)}};EN.exports=HN});var yS=rt(fo=>{"use strict";fo.base64=!1;fo.binary=!1;fo.dir=!1;fo.createFolders=!0;fo.date=null;fo.compression=null;fo.compressionOptions=null;fo.comment=null;fo.unixPermissions=null;fo.dosPermissions=null});var wS=rt((P0e,CN)=>{"use strict";var Z0=br(),I0=Ui(),o_=16*1024;function cu(e){I0.call(this,"DataWorker");var t=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,e.then(function(n){t.dataIsReady=!0,t.data=n,t.max=n&&n.length||0,t.type=Z0.getTypeOf(n),t.isPaused||t._tickAndRepeat()},function(n){t.error(n)})}Z0.inherits(cu,I0);cu.prototype.cleanUp=function(){I0.prototype.cleanUp.call(this),this.data=null};cu.prototype.resume=function(){return I0.prototype.resume.call(this)?(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,Z0.delay(this._tickAndRepeat,[],this)),!0):!1};cu.prototype._tickAndRepeat=function(){this._tickScheduled=!1,!(this.isPaused||this.isFinished)&&(this._tick(),this.isFinished||(Z0.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))};cu.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var e=o_,t=null,n=Math.min(this.max,this.index+e);if(this.index>=this.max)return this.end();switch(this.type){case"string":t=this.data.substring(this.index,n);break;case"uint8array":t=this.data.subarray(this.index,n);break;case"array":case"nodebuffer":t=this.data.slice(this.index,n);break}return this.index=n,this.push({data:t,meta:{percent:this.max?this.index/this.max*100:0}})};CN.exports=cu});var W0=rt((S0e,AN)=>{"use strict";var a_=br();function s_(){for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var UN=s_();function c_(e,t,n,i){var r=UN,o=i+n;e=e^-1;for(var a=i;a<o;a++)e=e>>>8^r[(e^t[a])&255];return e^-1}function l_(e,t,n,i){var r=UN,o=i+n;e=e^-1;for(var a=i;a<o;a++)e=e>>>8^r[(e^t.charCodeAt(a))&255];return e^-1}AN.exports=function(t,n){if(typeof t>"u"||!t.length)return 0;var i=a_.getTypeOf(t)!=="string";return i?c_(n|0,t,t.length,0):l_(n|0,t,t.length,0)}});var PS=rt((k0e,JN)=>{"use strict";var GN=Ui(),u_=W0(),f_=br();function xS(){GN.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}f_.inherits(xS,GN);xS.prototype.processChunk=function(e){this.streamInfo.crc32=u_(e.data,this.streamInfo.crc32||0),this.push(e)};JN.exports=xS});var YN=rt((T0e,BN)=>{"use strict";var d_=br(),SS=Ui();function kS(e){SS.call(this,"DataLengthProbe for "+e),this.propName=e,this.withStreamInfo(e,0)}d_.inherits(kS,SS);kS.prototype.processChunk=function(e){if(e){var t=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=t+e.data.length}SS.prototype.processChunk.call(this,e)};BN.exports=kS});var D0=rt((z0e,_N)=>{"use strict";var KN=iu(),QN=wS(),m_=PS(),TS=YN();function zS(e,t,n,i,r){this.compressedSize=e,this.uncompressedSize=t,this.crc32=n,this.compression=i,this.compressedContent=r}zS.prototype={getContentWorker:function(){var e=new QN(KN.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new TS("data_length")),t=this;return e.on("end",function(){if(this.streamInfo.data_length!==t.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),e},getCompressedWorker:function(){return new QN(KN.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}};zS.createWorkerFrom=function(e,t,n){return e.pipe(new m_).pipe(new TS("uncompressedSize")).pipe(t.compressWorker(n)).pipe(new TS("compressedSize")).withStreamInfo("compression",t)};_N.exports=zS});var nR=rt((M0e,tR)=>{"use strict";var p_=vS(),h_=wS(),MS=su(),OS=D0(),$N=Ui(),LS=function(e,t,n){this.name=e,this.dir=n.dir,this.date=n.date,this.comment=n.comment,this.unixPermissions=n.unixPermissions,this.dosPermissions=n.dosPermissions,this._data=t,this._dataBinary=n.binary,this.options={compression:n.compression,compressionOptions:n.compressionOptions}};LS.prototype={internalStream:function(e){var t=null,n="string";try{if(!e)throw new Error("No output type specified.");n=e.toLowerCase();var i=n==="string"||n==="text";(n==="binarystring"||n==="text")&&(n="string"),t=this._decompressWorker();var r=!this._dataBinary;r&&!i&&(t=t.pipe(new MS.Utf8EncodeWorker)),!r&&i&&(t=t.pipe(new MS.Utf8DecodeWorker))}catch(o){t=new $N("error"),t.error(o)}return new p_(t,n,"")},async:function(e,t){return this.internalStream(e).accumulate(t)},nodeStream:function(e,t){return this.internalStream(e||"nodebuffer").toNodejsStream(t)},_compressWorker:function(e,t){if(this._data instanceof OS&&this._data.compression.magic===e.magic)return this._data.getCompressedWorker();var n=this._decompressWorker();return this._dataBinary||(n=n.pipe(new MS.Utf8EncodeWorker)),OS.createWorkerFrom(n,e,t)},_decompressWorker:function(){return this._data instanceof OS?this._data.getContentWorker():this._data instanceof $N?this._data:new h_(this._data)}};var eR=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],b_=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")};for(q0=0;q0<eR.length;q0++)LS.prototype[eR[q0]]=b_;var q0;tR.exports=LS});var va=rt(xi=>{"use strict";var g_=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";function v_(e,t){return Object.prototype.hasOwnProperty.call(e,t)}xi.assign=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var n=t.shift();if(n){if(typeof n!="object")throw new TypeError(n+"must be non-object");for(var i in n)v_(n,i)&&(e[i]=n[i])}}return e};xi.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var y_={arraySet:function(e,t,n,i,r){if(t.subarray&&e.subarray){e.set(t.subarray(n,n+i),r);return}for(var o=0;o<i;o++)e[r+o]=t[n+o]},flattenChunks:function(e){var t,n,i,r,o,a;for(i=0,t=0,n=e.length;t<n;t++)i+=e[t].length;for(a=new Uint8Array(i),r=0,t=0,n=e.length;t<n;t++)o=e[t],a.set(o,r),r+=o.length;return a}},w_={arraySet:function(e,t,n,i,r){for(var o=0;o<i;o++)e[r+o]=t[n+o]},flattenChunks:function(e){return[].concat.apply([],e)}};xi.setTyped=function(e){e?(xi.Buf8=Uint8Array,xi.Buf16=Uint16Array,xi.Buf32=Int32Array,xi.assign(xi,y_)):(xi.Buf8=Array,xi.Buf16=Array,xi.Buf32=Array,xi.assign(xi,w_))};xi.setTyped(g_)});var TR=rt(fu=>{"use strict";var x_=va(),P_=4,rR=0,iR=1,S_=2;function uu(e){for(var t=e.length;--t>=0;)e[t]=0}var k_=0,uR=1,T_=2,z_=3,M_=258,ZS=29,im=256,em=im+1+ZS,lu=30,IS=19,fR=2*em+1,pc=15,XS=16,O_=7,WS=256,dR=16,mR=17,pR=18,VS=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],H0=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],L_=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],hR=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],X_=512,ya=new Array((em+2)*2);uu(ya);var $d=new Array(lu*2);uu($d);var tm=new Array(X_);uu(tm);var nm=new Array(M_-z_+1);uu(nm);var DS=new Array(ZS);uu(DS);var E0=new Array(lu);uu(E0);function NS(e,t,n,i,r){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=e&&e.length}var bR,gR,vR;function RS(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}function yR(e){return e<256?tm[e]:tm[256+(e>>>7)]}function rm(e,t){e.pending_buf[e.pending++]=t&255,e.pending_buf[e.pending++]=t>>>8&255}function Vi(e,t,n){e.bi_valid>XS-n?(e.bi_buf|=t<<e.bi_valid&65535,rm(e,e.bi_buf),e.bi_buf=t>>XS-e.bi_valid,e.bi_valid+=n-XS):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)}function Zo(e,t,n){Vi(e,n[t*2],n[t*2+1])}function wR(e,t){var n=0;do n|=e&1,e>>>=1,n<<=1;while(--t>0);return n>>>1}function N_(e){e.bi_valid===16?(rm(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=e.bi_buf&255,e.bi_buf>>=8,e.bi_valid-=8)}function R_(e,t){var n=t.dyn_tree,i=t.max_code,r=t.stat_desc.static_tree,o=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,s=t.stat_desc.extra_base,c=t.stat_desc.max_length,l,u,f,d,m,p,b=0;for(d=0;d<=pc;d++)e.bl_count[d]=0;for(n[e.heap[e.heap_max]*2+1]=0,l=e.heap_max+1;l<fR;l++)u=e.heap[l],d=n[n[u*2+1]*2+1]+1,d>c&&(d=c,b++),n[u*2+1]=d,!(u>i)&&(e.bl_count[d]++,m=0,u>=s&&(m=a[u-s]),p=n[u*2],e.opt_len+=p*(d+m),o&&(e.static_len+=p*(r[u*2+1]+m)));if(b!==0){do{for(d=c-1;e.bl_count[d]===0;)d--;e.bl_count[d]--,e.bl_count[d+1]+=2,e.bl_count[c]--,b-=2}while(b>0);for(d=c;d!==0;d--)for(u=e.bl_count[d];u!==0;)f=e.heap[--l],!(f>i)&&(n[f*2+1]!==d&&(e.opt_len+=(d-n[f*2+1])*n[f*2],n[f*2+1]=d),u--)}}function xR(e,t,n){var i=new Array(pc+1),r=0,o,a;for(o=1;o<=pc;o++)i[o]=r=r+n[o-1]<<1;for(a=0;a<=t;a++){var s=e[a*2+1];s!==0&&(e[a*2]=wR(i[s]++,s))}}function F_(){var e,t,n,i,r,o=new Array(pc+1);for(n=0,i=0;i<ZS-1;i++)for(DS[i]=n,e=0;e<1<<VS[i];e++)nm[n++]=i;for(nm[n-1]=i,r=0,i=0;i<16;i++)for(E0[i]=r,e=0;e<1<<H0[i];e++)tm[r++]=i;for(r>>=7;i<lu;i++)for(E0[i]=r<<7,e=0;e<1<<H0[i]-7;e++)tm[256+r++]=i;for(t=0;t<=pc;t++)o[t]=0;for(e=0;e<=143;)ya[e*2+1]=8,e++,o[8]++;for(;e<=255;)ya[e*2+1]=9,e++,o[9]++;for(;e<=279;)ya[e*2+1]=7,e++,o[7]++;for(;e<=287;)ya[e*2+1]=8,e++,o[8]++;for(xR(ya,em+1,o),e=0;e<lu;e++)$d[e*2+1]=5,$d[e*2]=wR(e,5);bR=new NS(ya,VS,im+1,em,pc),gR=new NS($d,H0,0,lu,pc),vR=new NS(new Array(0),L_,0,IS,O_)}function PR(e){var t;for(t=0;t<em;t++)e.dyn_ltree[t*2]=0;for(t=0;t<lu;t++)e.dyn_dtree[t*2]=0;for(t=0;t<IS;t++)e.bl_tree[t*2]=0;e.dyn_ltree[WS*2]=1,e.opt_len=e.static_len=0,e.last_lit=e.matches=0}function SR(e){e.bi_valid>8?rm(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0}function V_(e,t,n,i){SR(e),i&&(rm(e,n),rm(e,~n)),x_.arraySet(e.pending_buf,e.window,t,n,e.pending),e.pending+=n}function oR(e,t,n,i){var r=t*2,o=n*2;return e[r]<e[o]||e[r]===e[o]&&i[t]<=i[n]}function FS(e,t,n){for(var i=e.heap[n],r=n<<1;r<=e.heap_len&&(r<e.heap_len&&oR(t,e.heap[r+1],e.heap[r],e.depth)&&r++,!oR(t,i,e.heap[r],e.depth));)e.heap[n]=e.heap[r],n=r,r<<=1;e.heap[n]=i}function aR(e,t,n){var i,r,o=0,a,s;if(e.last_lit!==0)do i=e.pending_buf[e.d_buf+o*2]<<8|e.pending_buf[e.d_buf+o*2+1],r=e.pending_buf[e.l_buf+o],o++,i===0?Zo(e,r,t):(a=nm[r],Zo(e,a+im+1,t),s=VS[a],s!==0&&(r-=DS[a],Vi(e,r,s)),i--,a=yR(i),Zo(e,a,n),s=H0[a],s!==0&&(i-=E0[a],Vi(e,i,s)));while(o<e.last_lit);Zo(e,WS,t)}function jS(e,t){var n=t.dyn_tree,i=t.stat_desc.static_tree,r=t.stat_desc.has_stree,o=t.stat_desc.elems,a,s,c=-1,l;for(e.heap_len=0,e.heap_max=fR,a=0;a<o;a++)n[a*2]!==0?(e.heap[++e.heap_len]=c=a,e.depth[a]=0):n[a*2+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=c<2?++c:0,n[l*2]=1,e.depth[l]=0,e.opt_len--,r&&(e.static_len-=i[l*2+1]);for(t.max_code=c,a=e.heap_len>>1;a>=1;a--)FS(e,n,a);l=o;do a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],FS(e,n,1),s=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=s,n[l*2]=n[a*2]+n[s*2],e.depth[l]=(e.depth[a]>=e.depth[s]?e.depth[a]:e.depth[s])+1,n[a*2+1]=n[s*2+1]=l,e.heap[1]=l++,FS(e,n,1);while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],R_(e,t),xR(n,c,e.bl_count)}function sR(e,t,n){var i,r=-1,o,a=t[1],s=0,c=7,l=4;for(a===0&&(c=138,l=3),t[(n+1)*2+1]=65535,i=0;i<=n;i++)o=a,a=t[(i+1)*2+1],!(++s<c&&o===a)&&(s<l?e.bl_tree[o*2]+=s:o!==0?(o!==r&&e.bl_tree[o*2]++,e.bl_tree[dR*2]++):s<=10?e.bl_tree[mR*2]++:e.bl_tree[pR*2]++,s=0,r=o,a===0?(c=138,l=3):o===a?(c=6,l=3):(c=7,l=4))}function cR(e,t,n){var i,r=-1,o,a=t[1],s=0,c=7,l=4;for(a===0&&(c=138,l=3),i=0;i<=n;i++)if(o=a,a=t[(i+1)*2+1],!(++s<c&&o===a)){if(s<l)do Zo(e,o,e.bl_tree);while(--s!==0);else o!==0?(o!==r&&(Zo(e,o,e.bl_tree),s--),Zo(e,dR,e.bl_tree),Vi(e,s-3,2)):s<=10?(Zo(e,mR,e.bl_tree),Vi(e,s-3,3)):(Zo(e,pR,e.bl_tree),Vi(e,s-11,7));s=0,r=o,a===0?(c=138,l=3):o===a?(c=6,l=3):(c=7,l=4)}}function j_(e){var t;for(sR(e,e.dyn_ltree,e.l_desc.max_code),sR(e,e.dyn_dtree,e.d_desc.max_code),jS(e,e.bl_desc),t=IS-1;t>=3&&e.bl_tree[hR[t]*2+1]===0;t--);return e.opt_len+=3*(t+1)+5+5+4,t}function Z_(e,t,n,i){var r;for(Vi(e,t-257,5),Vi(e,n-1,5),Vi(e,i-4,4),r=0;r<i;r++)Vi(e,e.bl_tree[hR[r]*2+1],3);cR(e,e.dyn_ltree,t-1),cR(e,e.dyn_dtree,n-1)}function I_(e){var t=4093624447,n;for(n=0;n<=31;n++,t>>>=1)if(t&1&&e.dyn_ltree[n*2]!==0)return rR;if(e.dyn_ltree[18]!==0||e.dyn_ltree[20]!==0||e.dyn_ltree[26]!==0)return iR;for(n=32;n<im;n++)if(e.dyn_ltree[n*2]!==0)return iR;return rR}var lR=!1;function W_(e){lR||(F_(),lR=!0),e.l_desc=new RS(e.dyn_ltree,bR),e.d_desc=new RS(e.dyn_dtree,gR),e.bl_desc=new RS(e.bl_tree,vR),e.bi_buf=0,e.bi_valid=0,PR(e)}function kR(e,t,n,i){Vi(e,(k_<<1)+(i?1:0),3),V_(e,t,n,!0)}function D_(e){Vi(e,uR<<1,3),Zo(e,WS,ya),N_(e)}function q_(e,t,n,i){var r,o,a=0;e.level>0?(e.strm.data_type===S_&&(e.strm.data_type=I_(e)),jS(e,e.l_desc),jS(e,e.d_desc),a=j_(e),r=e.opt_len+3+7>>>3,o=e.static_len+3+7>>>3,o<=r&&(r=o)):r=o=n+5,n+4<=r&&t!==-1?kR(e,t,n,i):e.strategy===P_||o===r?(Vi(e,(uR<<1)+(i?1:0),3),aR(e,ya,$d)):(Vi(e,(T_<<1)+(i?1:0),3),Z_(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),aR(e,e.dyn_ltree,e.dyn_dtree)),PR(e),i&&SR(e)}function H_(e,t,n){return e.pending_buf[e.d_buf+e.last_lit*2]=t>>>8&255,e.pending_buf[e.d_buf+e.last_lit*2+1]=t&255,e.pending_buf[e.l_buf+e.last_lit]=n&255,e.last_lit++,t===0?e.dyn_ltree[n*2]++:(e.matches++,t--,e.dyn_ltree[(nm[n]+im+1)*2]++,e.dyn_dtree[yR(t)*2]++),e.last_lit===e.lit_bufsize-1}fu._tr_init=W_;fu._tr_stored_block=kR;fu._tr_flush_block=q_;fu._tr_tally=H_;fu._tr_align=D_});var qS=rt((X0e,zR)=>{"use strict";function E_(e,t,n,i){for(var r=e&65535|0,o=e>>>16&65535|0,a=0;n!==0;){a=n>2e3?2e3:n,n-=a;do r=r+t[i++]|0,o=o+r|0;while(--a);r%=65521,o%=65521}return r|o<<16|0}zR.exports=E_});var HS=rt((N0e,MR)=>{"use strict";function C_(){for(var e,t=[],n=0;n<256;n++){e=n;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}var U_=C_();function A_(e,t,n,i){var r=U_,o=i+n;e^=-1;for(var a=i;a<o;a++)e=e>>>8^r[(e^t[a])&255];return e^-1}MR.exports=A_});var C0=rt((R0e,OR)=>{"use strict";OR.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}});var IR=rt(Do=>{"use strict";var Pi=va(),_i=TR(),RR=qS(),cs=HS(),G_=C0(),vc=0,J_=1,B_=3,ms=4,LR=5,Wo=0,XR=1,$i=-2,Y_=-3,ES=-5,K_=-1,Q_=1,U0=2,__=3,$_=4,e$=0,t$=2,B0=8,n$=9,r$=15,i$=8,o$=29,a$=256,US=a$+1+o$,s$=30,c$=19,l$=2*US+1,u$=15,vn=3,fs=258,mo=fs+vn+1,f$=32,Y0=42,AS=69,A0=73,G0=91,J0=103,hc=113,am=666,Ir=1,sm=2,bc=3,pu=4,d$=3;function ds(e,t){return e.msg=G_[t],t}function NR(e){return(e<<1)-(e>4?9:0)}function us(e){for(var t=e.length;--t>=0;)e[t]=0}function ls(e){var t=e.state,n=t.pending;n>e.avail_out&&(n=e.avail_out),n!==0&&(Pi.arraySet(e.output,t.pending_buf,t.pending_out,n,e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,t.pending===0&&(t.pending_out=0))}function _r(e,t){_i._tr_flush_block(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,ls(e.strm)}function On(e,t){e.pending_buf[e.pending++]=t}function om(e,t){e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=t&255}function m$(e,t,n,i){var r=e.avail_in;return r>i&&(r=i),r===0?0:(e.avail_in-=r,Pi.arraySet(t,e.input,e.next_in,r,n),e.state.wrap===1?e.adler=RR(e.adler,t,r,n):e.state.wrap===2&&(e.adler=cs(e.adler,t,r,n)),e.next_in+=r,e.total_in+=r,r)}function FR(e,t){var n=e.max_chain_length,i=e.strstart,r,o,a=e.prev_length,s=e.nice_match,c=e.strstart>e.w_size-mo?e.strstart-(e.w_size-mo):0,l=e.window,u=e.w_mask,f=e.prev,d=e.strstart+fs,m=l[i+a-1],p=l[i+a];e.prev_length>=e.good_match&&(n>>=2),s>e.lookahead&&(s=e.lookahead);do if(r=t,!(l[r+a]!==p||l[r+a-1]!==m||l[r]!==l[i]||l[++r]!==l[i+1])){i+=2,r++;do;while(l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&l[++i]===l[++r]&&i<d);if(o=fs-(d-i),i=d-fs,o>a){if(e.match_start=t,a=o,o>=s)break;m=l[i+a-1],p=l[i+a]}}while((t=f[t&u])>c&&--n!==0);return a<=e.lookahead?a:e.lookahead}function gc(e){var t=e.w_size,n,i,r,o,a;do{if(o=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-mo)){Pi.arraySet(e.window,e.window,t,t,0),e.match_start-=t,e.strstart-=t,e.block_start-=t,i=e.hash_size,n=i;do r=e.head[--n],e.head[n]=r>=t?r-t:0;while(--i);i=t,n=i;do r=e.prev[--n],e.prev[n]=r>=t?r-t:0;while(--i);o+=t}if(e.strm.avail_in===0)break;if(i=m$(e.strm,e.window,e.strstart+e.lookahead,o),e.lookahead+=i,e.lookahead+e.insert>=vn)for(a=e.strstart-e.insert,e.ins_h=e.window[a],e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+1])&e.hash_mask;e.insert&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[a+vn-1])&e.hash_mask,e.prev[a&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=a,a++,e.insert--,!(e.lookahead+e.insert<vn)););}while(e.lookahead<mo&&e.strm.avail_in!==0)}function p$(e,t){var n=65535;for(n>e.pending_buf_size-5&&(n=e.pending_buf_size-5);;){if(e.lookahead<=1){if(gc(e),e.lookahead===0&&t===vc)return Ir;if(e.lookahead===0)break}e.strstart+=e.lookahead,e.lookahead=0;var i=e.block_start+n;if((e.strstart===0||e.strstart>=i)&&(e.lookahead=e.strstart-i,e.strstart=i,_r(e,!1),e.strm.avail_out===0)||e.strstart-e.block_start>=e.w_size-mo&&(_r(e,!1),e.strm.avail_out===0))return Ir}return e.insert=0,t===ms?(_r(e,!0),e.strm.avail_out===0?bc:pu):(e.strstart>e.block_start&&(_r(e,!1),e.strm.avail_out===0),Ir)}function CS(e,t){for(var n,i;;){if(e.lookahead<mo){if(gc(e),e.lookahead<mo&&t===vc)return Ir;if(e.lookahead===0)break}if(n=0,e.lookahead>=vn&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+vn-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),n!==0&&e.strstart-n<=e.w_size-mo&&(e.match_length=FR(e,n)),e.match_length>=vn)if(i=_i._tr_tally(e,e.strstart-e.match_start,e.match_length-vn),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=vn){e.match_length--;do e.strstart++,e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+vn-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart;while(--e.match_length!==0);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+1])&e.hash_mask;else i=_i._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(i&&(_r(e,!1),e.strm.avail_out===0))return Ir}return e.insert=e.strstart<vn-1?e.strstart:vn-1,t===ms?(_r(e,!0),e.strm.avail_out===0?bc:pu):e.last_lit&&(_r(e,!1),e.strm.avail_out===0)?Ir:sm}function du(e,t){for(var n,i,r;;){if(e.lookahead<mo){if(gc(e),e.lookahead<mo&&t===vc)return Ir;if(e.lookahead===0)break}if(n=0,e.lookahead>=vn&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+vn-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=vn-1,n!==0&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-mo&&(e.match_length=FR(e,n),e.match_length<=5&&(e.strategy===Q_||e.match_length===vn&&e.strstart-e.match_start>4096)&&(e.match_length=vn-1)),e.prev_length>=vn&&e.match_length<=e.prev_length){r=e.strstart+e.lookahead-vn,i=_i._tr_tally(e,e.strstart-1-e.prev_match,e.prev_length-vn),e.lookahead-=e.prev_length-1,e.prev_length-=2;do++e.strstart<=r&&(e.ins_h=(e.ins_h<<e.hash_shift^e.window[e.strstart+vn-1])&e.hash_mask,n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart);while(--e.prev_length!==0);if(e.match_available=0,e.match_length=vn-1,e.strstart++,i&&(_r(e,!1),e.strm.avail_out===0))return Ir}else if(e.match_available){if(i=_i._tr_tally(e,0,e.window[e.strstart-1]),i&&_r(e,!1),e.strstart++,e.lookahead--,e.strm.avail_out===0)return Ir}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(i=_i._tr_tally(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<vn-1?e.strstart:vn-1,t===ms?(_r(e,!0),e.strm.avail_out===0?bc:pu):e.last_lit&&(_r(e,!1),e.strm.avail_out===0)?Ir:sm}function h$(e,t){for(var n,i,r,o,a=e.window;;){if(e.lookahead<=fs){if(gc(e),e.lookahead<=fs&&t===vc)return Ir;if(e.lookahead===0)break}if(e.match_length=0,e.lookahead>=vn&&e.strstart>0&&(r=e.strstart-1,i=a[r],i===a[++r]&&i===a[++r]&&i===a[++r])){o=e.strstart+fs;do;while(i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&i===a[++r]&&r<o);e.match_length=fs-(o-r),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=vn?(n=_i._tr_tally(e,1,e.match_length-vn),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=_i._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(_r(e,!1),e.strm.avail_out===0))return Ir}return e.insert=0,t===ms?(_r(e,!0),e.strm.avail_out===0?bc:pu):e.last_lit&&(_r(e,!1),e.strm.avail_out===0)?Ir:sm}function b$(e,t){for(var n;;){if(e.lookahead===0&&(gc(e),e.lookahead===0)){if(t===vc)return Ir;break}if(e.match_length=0,n=_i._tr_tally(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(_r(e,!1),e.strm.avail_out===0))return Ir}return e.insert=0,t===ms?(_r(e,!0),e.strm.avail_out===0?bc:pu):e.last_lit&&(_r(e,!1),e.strm.avail_out===0)?Ir:sm}function Io(e,t,n,i,r){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=i,this.func=r}var mu;mu=[new Io(0,0,0,0,p$),new Io(4,4,8,4,CS),new Io(4,5,16,8,CS),new Io(4,6,32,32,CS),new Io(4,4,16,16,du),new Io(8,16,32,32,du),new Io(8,16,128,128,du),new Io(8,32,128,256,du),new Io(32,128,258,1024,du),new Io(32,258,258,4096,du)];function g$(e){e.window_size=2*e.w_size,us(e.head),e.max_lazy_match=mu[e.level].max_lazy,e.good_match=mu[e.level].good_length,e.nice_match=mu[e.level].nice_length,e.max_chain_length=mu[e.level].max_chain,e.strstart=0,e.block_start=0,e.lookahead=0,e.insert=0,e.match_length=e.prev_length=vn-1,e.match_available=0,e.ins_h=0}function v$(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=B0,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Pi.Buf16(l$*2),this.dyn_dtree=new Pi.Buf16((2*s$+1)*2),this.bl_tree=new Pi.Buf16((2*c$+1)*2),us(this.dyn_ltree),us(this.dyn_dtree),us(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Pi.Buf16(u$+1),this.heap=new Pi.Buf16(2*US+1),us(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Pi.Buf16(2*US+1),us(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function VR(e){var t;return!e||!e.state?ds(e,$i):(e.total_in=e.total_out=0,e.data_type=t$,t=e.state,t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=t.wrap?Y0:hc,e.adler=t.wrap===2?0:1,t.last_flush=vc,_i._tr_init(t),Wo)}function jR(e){var t=VR(e);return t===Wo&&g$(e.state),t}function y$(e,t){return!e||!e.state||e.state.wrap!==2?$i:(e.state.gzhead=t,Wo)}function ZR(e,t,n,i,r,o){if(!e)return $i;var a=1;if(t===K_&&(t=6),i<0?(a=0,i=-i):i>15&&(a=2,i-=16),r<1||r>n$||n!==B0||i<8||i>15||t<0||t>9||o<0||o>$_)return ds(e,$i);i===8&&(i=9);var s=new v$;return e.state=s,s.strm=e,s.wrap=a,s.gzhead=null,s.w_bits=i,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=r+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+vn-1)/vn),s.window=new Pi.Buf8(s.w_size*2),s.head=new Pi.Buf16(s.hash_size),s.prev=new Pi.Buf16(s.w_size),s.lit_bufsize=1<<r+6,s.pending_buf_size=s.lit_bufsize*4,s.pending_buf=new Pi.Buf8(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=t,s.strategy=o,s.method=n,jR(e)}function w$(e,t){return ZR(e,t,B0,r$,i$,e$)}function x$(e,t){var n,i,r,o;if(!e||!e.state||t>LR||t<0)return e?ds(e,$i):$i;if(i=e.state,!e.output||!e.input&&e.avail_in!==0||i.status===am&&t!==ms)return ds(e,e.avail_out===0?ES:$i);if(i.strm=e,n=i.last_flush,i.last_flush=t,i.status===Y0)if(i.wrap===2)e.adler=0,On(i,31),On(i,139),On(i,8),i.gzhead?(On(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),On(i,i.gzhead.time&255),On(i,i.gzhead.time>>8&255),On(i,i.gzhead.time>>16&255),On(i,i.gzhead.time>>24&255),On(i,i.level===9?2:i.strategy>=U0||i.level<2?4:0),On(i,i.gzhead.os&255),i.gzhead.extra&&i.gzhead.extra.length&&(On(i,i.gzhead.extra.length&255),On(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=cs(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=AS):(On(i,0),On(i,0),On(i,0),On(i,0),On(i,0),On(i,i.level===9?2:i.strategy>=U0||i.level<2?4:0),On(i,d$),i.status=hc);else{var a=B0+(i.w_bits-8<<4)<<8,s=-1;i.strategy>=U0||i.level<2?s=0:i.level<6?s=1:i.level===6?s=2:s=3,a|=s<<6,i.strstart!==0&&(a|=f$),a+=31-a%31,i.status=hc,om(i,a),i.strstart!==0&&(om(i,e.adler>>>16),om(i,e.adler&65535)),e.adler=1}if(i.status===AS)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(i.gzhead.extra.length&65535)&&!(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=cs(e.adler,i.pending_buf,i.pending-r,r)),ls(e),r=i.pending,i.pending===i.pending_buf_size));)On(i,i.gzhead.extra[i.gzindex]&255),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(e.adler=cs(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=A0)}else i.status=A0;if(i.status===A0)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=cs(e.adler,i.pending_buf,i.pending-r,r)),ls(e),r=i.pending,i.pending===i.pending_buf_size)){o=1;break}i.gzindex<i.gzhead.name.length?o=i.gzhead.name.charCodeAt(i.gzindex++)&255:o=0,On(i,o)}while(o!==0);i.gzhead.hcrc&&i.pending>r&&(e.adler=cs(e.adler,i.pending_buf,i.pending-r,r)),o===0&&(i.gzindex=0,i.status=G0)}else i.status=G0;if(i.status===G0)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(e.adler=cs(e.adler,i.pending_buf,i.pending-r,r)),ls(e),r=i.pending,i.pending===i.pending_buf_size)){o=1;break}i.gzindex<i.gzhead.comment.length?o=i.gzhead.comment.charCodeAt(i.gzindex++)&255:o=0,On(i,o)}while(o!==0);i.gzhead.hcrc&&i.pending>r&&(e.adler=cs(e.adler,i.pending_buf,i.pending-r,r)),o===0&&(i.status=J0)}else i.status=J0;if(i.status===J0&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&ls(e),i.pending+2<=i.pending_buf_size&&(On(i,e.adler&255),On(i,e.adler>>8&255),e.adler=0,i.status=hc)):i.status=hc),i.pending!==0){if(ls(e),e.avail_out===0)return i.last_flush=-1,Wo}else if(e.avail_in===0&&NR(t)<=NR(n)&&t!==ms)return ds(e,ES);if(i.status===am&&e.avail_in!==0)return ds(e,ES);if(e.avail_in!==0||i.lookahead!==0||t!==vc&&i.status!==am){var c=i.strategy===U0?b$(i,t):i.strategy===__?h$(i,t):mu[i.level].func(i,t);if((c===bc||c===pu)&&(i.status=am),c===Ir||c===bc)return e.avail_out===0&&(i.last_flush=-1),Wo;if(c===sm&&(t===J_?_i._tr_align(i):t!==LR&&(_i._tr_stored_block(i,0,0,!1),t===B_&&(us(i.head),i.lookahead===0&&(i.strstart=0,i.block_start=0,i.insert=0))),ls(e),e.avail_out===0))return i.last_flush=-1,Wo}return t!==ms?Wo:i.wrap<=0?XR:(i.wrap===2?(On(i,e.adler&255),On(i,e.adler>>8&255),On(i,e.adler>>16&255),On(i,e.adler>>24&255),On(i,e.total_in&255),On(i,e.total_in>>8&255),On(i,e.total_in>>16&255),On(i,e.total_in>>24&255)):(om(i,e.adler>>>16),om(i,e.adler&65535)),ls(e),i.wrap>0&&(i.wrap=-i.wrap),i.pending!==0?Wo:XR)}function P$(e){var t;return!e||!e.state?$i:(t=e.state.status,t!==Y0&&t!==AS&&t!==A0&&t!==G0&&t!==J0&&t!==hc&&t!==am?ds(e,$i):(e.state=null,t===hc?ds(e,Y_):Wo))}function S$(e,t){var n=t.length,i,r,o,a,s,c,l,u;if(!e||!e.state||(i=e.state,a=i.wrap,a===2||a===1&&i.status!==Y0||i.lookahead))return $i;for(a===1&&(e.adler=RR(e.adler,t,n,0)),i.wrap=0,n>=i.w_size&&(a===0&&(us(i.head),i.strstart=0,i.block_start=0,i.insert=0),u=new Pi.Buf8(i.w_size),Pi.arraySet(u,t,n-i.w_size,i.w_size,0),t=u,n=i.w_size),s=e.avail_in,c=e.next_in,l=e.input,e.avail_in=n,e.next_in=0,e.input=t,gc(i);i.lookahead>=vn;){r=i.strstart,o=i.lookahead-(vn-1);do i.ins_h=(i.ins_h<<i.hash_shift^i.window[r+vn-1])&i.hash_mask,i.prev[r&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=r,r++;while(--o);i.strstart=r,i.lookahead=vn-1,gc(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=vn-1,i.match_available=0,e.next_in=c,e.input=l,e.avail_in=s,i.wrap=a,Wo}Do.deflateInit=w$;Do.deflateInit2=ZR;Do.deflateReset=jR;Do.deflateResetKeep=VR;Do.deflateSetHeader=y$;Do.deflate=x$;Do.deflateEnd=P$;Do.deflateSetDictionary=S$;Do.deflateInfo="pako deflate (from Nodeca project)"});var GS=rt(hu=>{"use strict";var K0=va(),WR=!0,DR=!0;try{String.fromCharCode.apply(null,[0])}catch{WR=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{DR=!1}var cm=new K0.Buf8(256);for(wa=0;wa<256;wa++)cm[wa]=wa>=252?6:wa>=248?5:wa>=240?4:wa>=224?3:wa>=192?2:1;var wa;cm[254]=cm[254]=1;hu.string2buf=function(e){var t,n,i,r,o,a=e.length,s=0;for(r=0;r<a;r++)n=e.charCodeAt(r),(n&64512)===55296&&r+1<a&&(i=e.charCodeAt(r+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),r++)),s+=n<128?1:n<2048?2:n<65536?3:4;for(t=new K0.Buf8(s),o=0,r=0;o<s;r++)n=e.charCodeAt(r),(n&64512)===55296&&r+1<a&&(i=e.charCodeAt(r+1),(i&64512)===56320&&(n=65536+(n-55296<<10)+(i-56320),r++)),n<128?t[o++]=n:n<2048?(t[o++]=192|n>>>6,t[o++]=128|n&63):n<65536?(t[o++]=224|n>>>12,t[o++]=128|n>>>6&63,t[o++]=128|n&63):(t[o++]=240|n>>>18,t[o++]=128|n>>>12&63,t[o++]=128|n>>>6&63,t[o++]=128|n&63);return t};function qR(e,t){if(t<65534&&(e.subarray&&DR||!e.subarray&&WR))return String.fromCharCode.apply(null,K0.shrinkBuf(e,t));for(var n="",i=0;i<t;i++)n+=String.fromCharCode(e[i]);return n}hu.buf2binstring=function(e){return qR(e,e.length)};hu.binstring2buf=function(e){for(var t=new K0.Buf8(e.length),n=0,i=t.length;n<i;n++)t[n]=e.charCodeAt(n);return t};hu.buf2string=function(e,t){var n,i,r,o,a=t||e.length,s=new Array(a*2);for(i=0,n=0;n<a;){if(r=e[n++],r<128){s[i++]=r;continue}if(o=cm[r],o>4){s[i++]=65533,n+=o-1;continue}for(r&=o===2?31:o===3?15:7;o>1&&n<a;)r=r<<6|e[n++]&63,o--;if(o>1){s[i++]=65533;continue}r<65536?s[i++]=r:(r-=65536,s[i++]=55296|r>>10&1023,s[i++]=56320|r&1023)}return qR(s,i)};hu.utf8border=function(e,t){var n;for(t=t||e.length,t>e.length&&(t=e.length),n=t-1;n>=0&&(e[n]&192)===128;)n--;return n<0||n===0?t:n+cm[e[n]]>t?n:t}});var JS=rt((j0e,HR)=>{"use strict";function k$(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}HR.exports=k$});var AR=rt(fm=>{"use strict";var lm=IR(),um=va(),YS=GS(),KS=C0(),T$=JS(),UR=Object.prototype.toString,z$=0,BS=4,bu=0,ER=1,CR=2,M$=-1,O$=0,L$=8;function yc(e){if(!(this instanceof yc))return new yc(e);this.options=um.assign({level:M$,method:L$,chunkSize:16384,windowBits:15,memLevel:8,strategy:O$,to:""},e||{});var t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new T$,this.strm.avail_out=0;var n=lm.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==bu)throw new Error(KS[n]);if(t.header&&lm.deflateSetHeader(this.strm,t.header),t.dictionary){var i;if(typeof t.dictionary=="string"?i=YS.string2buf(t.dictionary):UR.call(t.dictionary)==="[object ArrayBuffer]"?i=new Uint8Array(t.dictionary):i=t.dictionary,n=lm.deflateSetDictionary(this.strm,i),n!==bu)throw new Error(KS[n]);this._dict_set=!0}}yc.prototype.push=function(e,t){var n=this.strm,i=this.options.chunkSize,r,o;if(this.ended)return!1;o=t===~~t?t:t===!0?BS:z$,typeof e=="string"?n.input=YS.string2buf(e):UR.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new um.Buf8(i),n.next_out=0,n.avail_out=i),r=lm.deflate(n,o),r!==ER&&r!==bu)return this.onEnd(r),this.ended=!0,!1;(n.avail_out===0||n.avail_in===0&&(o===BS||o===CR))&&(this.options.to==="string"?this.onData(YS.buf2binstring(um.shrinkBuf(n.output,n.next_out))):this.onData(um.shrinkBuf(n.output,n.next_out)))}while((n.avail_in>0||n.avail_out===0)&&r!==ER);return o===BS?(r=lm.deflateEnd(this.strm),this.onEnd(r),this.ended=!0,r===bu):(o===CR&&(this.onEnd(bu),n.avail_out=0),!0)};yc.prototype.onData=function(e){this.chunks.push(e)};yc.prototype.onEnd=function(e){e===bu&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=um.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function QS(e,t){var n=new yc(t);if(n.push(e,!0),n.err)throw n.msg||KS[n.err];return n.result}function X$(e,t){return t=t||{},t.raw=!0,QS(e,t)}function N$(e,t){return t=t||{},t.gzip=!0,QS(e,t)}fm.Deflate=yc;fm.deflate=QS;fm.deflateRaw=X$;fm.gzip=N$});var JR=rt((I0e,GR)=>{"use strict";var Q0=30,R$=12;GR.exports=function(t,n){var i,r,o,a,s,c,l,u,f,d,m,p,b,h,v,g,y,w,x,T,z,k,S,M,L;i=t.state,r=t.next_in,M=t.input,o=r+(t.avail_in-5),a=t.next_out,L=t.output,s=a-(n-t.avail_out),c=a+(t.avail_out-257),l=i.dmax,u=i.wsize,f=i.whave,d=i.wnext,m=i.window,p=i.hold,b=i.bits,h=i.lencode,v=i.distcode,g=(1<<i.lenbits)-1,y=(1<<i.distbits)-1;e:do{b<15&&(p+=M[r++]<<b,b+=8,p+=M[r++]<<b,b+=8),w=h[p&g];t:for(;;){if(x=w>>>24,p>>>=x,b-=x,x=w>>>16&255,x===0)L[a++]=w&65535;else if(x&16){T=w&65535,x&=15,x&&(b<x&&(p+=M[r++]<<b,b+=8),T+=p&(1<<x)-1,p>>>=x,b-=x),b<15&&(p+=M[r++]<<b,b+=8,p+=M[r++]<<b,b+=8),w=v[p&y];n:for(;;){if(x=w>>>24,p>>>=x,b-=x,x=w>>>16&255,x&16){if(z=w&65535,x&=15,b<x&&(p+=M[r++]<<b,b+=8,b<x&&(p+=M[r++]<<b,b+=8)),z+=p&(1<<x)-1,z>l){t.msg="invalid distance too far back",i.mode=Q0;break e}if(p>>>=x,b-=x,x=a-s,z>x){if(x=z-x,x>f&&i.sane){t.msg="invalid distance too far back",i.mode=Q0;break e}if(k=0,S=m,d===0){if(k+=u-x,x<T){T-=x;do L[a++]=m[k++];while(--x);k=a-z,S=L}}else if(d<x){if(k+=u+d-x,x-=d,x<T){T-=x;do L[a++]=m[k++];while(--x);if(k=0,d<T){x=d,T-=x;do L[a++]=m[k++];while(--x);k=a-z,S=L}}}else if(k+=d-x,x<T){T-=x;do L[a++]=m[k++];while(--x);k=a-z,S=L}for(;T>2;)L[a++]=S[k++],L[a++]=S[k++],L[a++]=S[k++],T-=3;T&&(L[a++]=S[k++],T>1&&(L[a++]=S[k++]))}else{k=a-z;do L[a++]=L[k++],L[a++]=L[k++],L[a++]=L[k++],T-=3;while(T>2);T&&(L[a++]=L[k++],T>1&&(L[a++]=L[k++]))}}else if((x&64)===0){w=v[(w&65535)+(p&(1<<x)-1)];continue n}else{t.msg="invalid distance code",i.mode=Q0;break e}break}}else if((x&64)===0){w=h[(w&65535)+(p&(1<<x)-1)];continue t}else if(x&32){i.mode=R$;break e}else{t.msg="invalid literal/length code",i.mode=Q0;break e}break}}while(r<o&&a<c);T=b>>3,r-=T,b-=T<<3,p&=(1<<b)-1,t.next_in=r,t.next_out=a,t.avail_in=r<o?5+(o-r):5-(r-o),t.avail_out=a<c?257+(c-a):257-(a-c),i.hold=p,i.bits=b}});var eF=rt((W0e,$R)=>{"use strict";var BR=va(),gu=15,YR=852,KR=592,QR=0,_S=1,_R=2,F$=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],V$=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],j$=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],Z$=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];$R.exports=function(t,n,i,r,o,a,s,c){var l=c.bits,u=0,f=0,d=0,m=0,p=0,b=0,h=0,v=0,g=0,y=0,w,x,T,z,k,S=null,M=0,L,P=new BR.Buf16(gu+1),X=new BR.Buf16(gu+1),R=null,I=0,q,Y,D;for(u=0;u<=gu;u++)P[u]=0;for(f=0;f<r;f++)P[n[i+f]]++;for(p=l,m=gu;m>=1&&P[m]===0;m--);if(p>m&&(p=m),m===0)return o[a++]=1<<24|64<<16|0,o[a++]=1<<24|64<<16|0,c.bits=1,0;for(d=1;d<m&&P[d]===0;d++);for(p<d&&(p=d),v=1,u=1;u<=gu;u++)if(v<<=1,v-=P[u],v<0)return-1;if(v>0&&(t===QR||m!==1))return-1;for(X[1]=0,u=1;u<gu;u++)X[u+1]=X[u]+P[u];for(f=0;f<r;f++)n[i+f]!==0&&(s[X[n[i+f]]++]=f);if(t===QR?(S=R=s,L=19):t===_S?(S=F$,M-=257,R=V$,I-=257,L=256):(S=j$,R=Z$,L=-1),y=0,f=0,u=d,k=a,b=p,h=0,T=-1,g=1<<p,z=g-1,t===_S&&g>YR||t===_R&&g>KR)return 1;for(;;){q=u-h,s[f]<L?(Y=0,D=s[f]):s[f]>L?(Y=R[I+s[f]],D=S[M+s[f]]):(Y=96,D=0),w=1<<u-h,x=1<<b,d=x;do x-=w,o[k+(y>>h)+x]=q<<24|Y<<16|D|0;while(x!==0);for(w=1<<u-1;y&w;)w>>=1;if(w!==0?(y&=w-1,y+=w):y=0,f++,--P[u]===0){if(u===m)break;u=n[i+s[f]]}if(u>p&&(y&z)!==T){for(h===0&&(h=p),k+=d,b=u-h,v=1<<b;b+h<m&&(v-=P[b+h],!(v<=0));)b++,v<<=1;if(g+=1<<b,t===_S&&g>YR||t===_R&&g>KR)return 1;T=y&z,o[T]=p<<24|b<<16|k-a|0}}return y!==0&&(o[k+y]=u-h<<24|64<<16|0),c.bits=p,0}});var jF=rt(po=>{"use strict";var Ai=va(),i7=qS(),qo=HS(),I$=JR(),dm=eF(),W$=0,zF=1,MF=2,tF=4,D$=5,_0=6,wc=0,q$=1,H$=2,eo=-2,OF=-3,o7=-4,E$=-5,nF=8,LF=1,rF=2,iF=3,oF=4,aF=5,sF=6,cF=7,lF=8,uF=9,fF=10,tg=11,xa=12,$S=13,dF=14,e7=15,mF=16,pF=17,hF=18,bF=19,$0=20,eg=21,gF=22,vF=23,yF=24,wF=25,xF=26,t7=27,PF=28,SF=29,ur=30,a7=31,C$=32,U$=852,A$=592,G$=15,J$=G$;function kF(e){return(e>>>24&255)+(e>>>8&65280)+((e&65280)<<8)+((e&255)<<24)}function B$(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Ai.Buf16(320),this.work=new Ai.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function XF(e){var t;return!e||!e.state?eo:(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=t.wrap&1),t.mode=LF,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Ai.Buf32(U$),t.distcode=t.distdyn=new Ai.Buf32(A$),t.sane=1,t.back=-1,wc)}function NF(e){var t;return!e||!e.state?eo:(t=e.state,t.wsize=0,t.whave=0,t.wnext=0,XF(e))}function RF(e,t){var n,i;return!e||!e.state||(i=e.state,t<0?(n=0,t=-t):(n=(t>>4)+1,t<48&&(t&=15)),t&&(t<8||t>15))?eo:(i.window!==null&&i.wbits!==t&&(i.window=null),i.wrap=n,i.wbits=t,NF(e))}function FF(e,t){var n,i;return e?(i=new B$,e.state=i,i.window=null,n=RF(e,t),n!==wc&&(e.state=null),n):eo}function Y$(e){return FF(e,J$)}var TF=!0,n7,r7;function K$(e){if(TF){var t;for(n7=new Ai.Buf32(512),r7=new Ai.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(dm(zF,e.lens,0,288,n7,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;dm(MF,e.lens,0,32,r7,0,e.work,{bits:5}),TF=!1}e.lencode=n7,e.lenbits=9,e.distcode=r7,e.distbits=5}function VF(e,t,n,i){var r,o=e.state;return o.window===null&&(o.wsize=1<<o.wbits,o.wnext=0,o.whave=0,o.window=new Ai.Buf8(o.wsize)),i>=o.wsize?(Ai.arraySet(o.window,t,n-o.wsize,o.wsize,0),o.wnext=0,o.whave=o.wsize):(r=o.wsize-o.wnext,r>i&&(r=i),Ai.arraySet(o.window,t,n-i,r,o.wnext),i-=r,i?(Ai.arraySet(o.window,t,n-i,i,0),o.wnext=i,o.whave=o.wsize):(o.wnext+=r,o.wnext===o.wsize&&(o.wnext=0),o.whave<o.wsize&&(o.whave+=r))),0}function Q$(e,t){var n,i,r,o,a,s,c,l,u,f,d,m,p,b,h=0,v,g,y,w,x,T,z,k,S=new Ai.Buf8(4),M,L,P=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&e.avail_in!==0)return eo;n=e.state,n.mode===xa&&(n.mode=$S),a=e.next_out,r=e.output,c=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,l=n.hold,u=n.bits,f=s,d=c,k=wc;e:for(;;)switch(n.mode){case LF:if(n.wrap===0){n.mode=$S;break}for(;u<16;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(n.wrap&2&&l===35615){n.check=0,S[0]=l&255,S[1]=l>>>8&255,n.check=qo(n.check,S,2,0),l=0,u=0,n.mode=rF;break}if(n.flags=0,n.head&&(n.head.done=!1),!(n.wrap&1)||(((l&255)<<8)+(l>>8))%31){e.msg="incorrect header check",n.mode=ur;break}if((l&15)!==nF){e.msg="unknown compression method",n.mode=ur;break}if(l>>>=4,u-=4,z=(l&15)+8,n.wbits===0)n.wbits=z;else if(z>n.wbits){e.msg="invalid window size",n.mode=ur;break}n.dmax=1<<z,e.adler=n.check=1,n.mode=l&512?fF:xa,l=0,u=0;break;case rF:for(;u<16;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(n.flags=l,(n.flags&255)!==nF){e.msg="unknown compression method",n.mode=ur;break}if(n.flags&57344){e.msg="unknown header flags set",n.mode=ur;break}n.head&&(n.head.text=l>>8&1),n.flags&512&&(S[0]=l&255,S[1]=l>>>8&255,n.check=qo(n.check,S,2,0)),l=0,u=0,n.mode=iF;case iF:for(;u<32;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.head&&(n.head.time=l),n.flags&512&&(S[0]=l&255,S[1]=l>>>8&255,S[2]=l>>>16&255,S[3]=l>>>24&255,n.check=qo(n.check,S,4,0)),l=0,u=0,n.mode=oF;case oF:for(;u<16;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.head&&(n.head.xflags=l&255,n.head.os=l>>8),n.flags&512&&(S[0]=l&255,S[1]=l>>>8&255,n.check=qo(n.check,S,2,0)),l=0,u=0,n.mode=aF;case aF:if(n.flags&1024){for(;u<16;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.length=l,n.head&&(n.head.extra_len=l),n.flags&512&&(S[0]=l&255,S[1]=l>>>8&255,n.check=qo(n.check,S,2,0)),l=0,u=0}else n.head&&(n.head.extra=null);n.mode=sF;case sF:if(n.flags&1024&&(m=n.length,m>s&&(m=s),m&&(n.head&&(z=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Array(n.head.extra_len)),Ai.arraySet(n.head.extra,i,o,m,z)),n.flags&512&&(n.check=qo(n.check,i,m,o)),s-=m,o+=m,n.length-=m),n.length))break e;n.length=0,n.mode=cF;case cF:if(n.flags&2048){if(s===0)break e;m=0;do z=i[o+m++],n.head&&z&&n.length<65536&&(n.head.name+=String.fromCharCode(z));while(z&&m<s);if(n.flags&512&&(n.check=qo(n.check,i,m,o)),s-=m,o+=m,z)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=lF;case lF:if(n.flags&4096){if(s===0)break e;m=0;do z=i[o+m++],n.head&&z&&n.length<65536&&(n.head.comment+=String.fromCharCode(z));while(z&&m<s);if(n.flags&512&&(n.check=qo(n.check,i,m,o)),s-=m,o+=m,z)break e}else n.head&&(n.head.comment=null);n.mode=uF;case uF:if(n.flags&512){for(;u<16;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(l!==(n.check&65535)){e.msg="header crc mismatch",n.mode=ur;break}l=0,u=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=xa;break;case fF:for(;u<32;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}e.adler=n.check=kF(l),l=0,u=0,n.mode=tg;case tg:if(n.havedict===0)return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,n.hold=l,n.bits=u,H$;e.adler=n.check=1,n.mode=xa;case xa:if(t===D$||t===_0)break e;case $S:if(n.last){l>>>=u&7,u-=u&7,n.mode=t7;break}for(;u<3;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}switch(n.last=l&1,l>>>=1,u-=1,l&3){case 0:n.mode=dF;break;case 1:if(K$(n),n.mode=$0,t===_0){l>>>=2,u-=2;break e}break;case 2:n.mode=pF;break;case 3:e.msg="invalid block type",n.mode=ur}l>>>=2,u-=2;break;case dF:for(l>>>=u&7,u-=u&7;u<32;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if((l&65535)!==(l>>>16^65535)){e.msg="invalid stored block lengths",n.mode=ur;break}if(n.length=l&65535,l=0,u=0,n.mode=e7,t===_0)break e;case e7:n.mode=mF;case mF:if(m=n.length,m){if(m>s&&(m=s),m>c&&(m=c),m===0)break e;Ai.arraySet(r,i,o,m,a),s-=m,o+=m,c-=m,a+=m,n.length-=m;break}n.mode=xa;break;case pF:for(;u<14;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(n.nlen=(l&31)+257,l>>>=5,u-=5,n.ndist=(l&31)+1,l>>>=5,u-=5,n.ncode=(l&15)+4,l>>>=4,u-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=ur;break}n.have=0,n.mode=hF;case hF:for(;n.have<n.ncode;){for(;u<3;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.lens[P[n.have++]]=l&7,l>>>=3,u-=3}for(;n.have<19;)n.lens[P[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,M={bits:n.lenbits},k=dm(W$,n.lens,0,19,n.lencode,0,n.work,M),n.lenbits=M.bits,k){e.msg="invalid code lengths set",n.mode=ur;break}n.have=0,n.mode=bF;case bF:for(;n.have<n.nlen+n.ndist;){for(;h=n.lencode[l&(1<<n.lenbits)-1],v=h>>>24,g=h>>>16&255,y=h&65535,!(v<=u);){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(y<16)l>>>=v,u-=v,n.lens[n.have++]=y;else{if(y===16){for(L=v+2;u<L;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(l>>>=v,u-=v,n.have===0){e.msg="invalid bit length repeat",n.mode=ur;break}z=n.lens[n.have-1],m=3+(l&3),l>>>=2,u-=2}else if(y===17){for(L=v+3;u<L;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}l>>>=v,u-=v,z=0,m=3+(l&7),l>>>=3,u-=3}else{for(L=v+7;u<L;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}l>>>=v,u-=v,z=0,m=11+(l&127),l>>>=7,u-=7}if(n.have+m>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=ur;break}for(;m--;)n.lens[n.have++]=z}}if(n.mode===ur)break;if(n.lens[256]===0){e.msg="invalid code -- missing end-of-block",n.mode=ur;break}if(n.lenbits=9,M={bits:n.lenbits},k=dm(zF,n.lens,0,n.nlen,n.lencode,0,n.work,M),n.lenbits=M.bits,k){e.msg="invalid literal/lengths set",n.mode=ur;break}if(n.distbits=6,n.distcode=n.distdyn,M={bits:n.distbits},k=dm(MF,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,M),n.distbits=M.bits,k){e.msg="invalid distances set",n.mode=ur;break}if(n.mode=$0,t===_0)break e;case $0:n.mode=eg;case eg:if(s>=6&&c>=258){e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,n.hold=l,n.bits=u,I$(e,d),a=e.next_out,r=e.output,c=e.avail_out,o=e.next_in,i=e.input,s=e.avail_in,l=n.hold,u=n.bits,n.mode===xa&&(n.back=-1);break}for(n.back=0;h=n.lencode[l&(1<<n.lenbits)-1],v=h>>>24,g=h>>>16&255,y=h&65535,!(v<=u);){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(g&&(g&240)===0){for(w=v,x=g,T=y;h=n.lencode[T+((l&(1<<w+x)-1)>>w)],v=h>>>24,g=h>>>16&255,y=h&65535,!(w+v<=u);){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}l>>>=w,u-=w,n.back+=w}if(l>>>=v,u-=v,n.back+=v,n.length=y,g===0){n.mode=xF;break}if(g&32){n.back=-1,n.mode=xa;break}if(g&64){e.msg="invalid literal/length code",n.mode=ur;break}n.extra=g&15,n.mode=gF;case gF:if(n.extra){for(L=n.extra;u<L;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=vF;case vF:for(;h=n.distcode[l&(1<<n.distbits)-1],v=h>>>24,g=h>>>16&255,y=h&65535,!(v<=u);){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if((g&240)===0){for(w=v,x=g,T=y;h=n.distcode[T+((l&(1<<w+x)-1)>>w)],v=h>>>24,g=h>>>16&255,y=h&65535,!(w+v<=u);){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}l>>>=w,u-=w,n.back+=w}if(l>>>=v,u-=v,n.back+=v,g&64){e.msg="invalid distance code",n.mode=ur;break}n.offset=y,n.extra=g&15,n.mode=yF;case yF:if(n.extra){for(L=n.extra;u<L;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,u-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=ur;break}n.mode=wF;case wF:if(c===0)break e;if(m=d-c,n.offset>m){if(m=n.offset-m,m>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=ur;break}m>n.wnext?(m-=n.wnext,p=n.wsize-m):p=n.wnext-m,m>n.length&&(m=n.length),b=n.window}else b=r,p=a-n.offset,m=n.length;m>c&&(m=c),c-=m,n.length-=m;do r[a++]=b[p++];while(--m);n.length===0&&(n.mode=eg);break;case xF:if(c===0)break e;r[a++]=n.length,c--,n.mode=eg;break;case t7:if(n.wrap){for(;u<32;){if(s===0)break e;s--,l|=i[o++]<<u,u+=8}if(d-=c,e.total_out+=d,n.total+=d,d&&(e.adler=n.check=n.flags?qo(n.check,r,d,a-d):i7(n.check,r,d,a-d)),d=c,(n.flags?l:kF(l))!==n.check){e.msg="incorrect data check",n.mode=ur;break}l=0,u=0}n.mode=PF;case PF:if(n.wrap&&n.flags){for(;u<32;){if(s===0)break e;s--,l+=i[o++]<<u,u+=8}if(l!==(n.total&4294967295)){e.msg="incorrect length check",n.mode=ur;break}l=0,u=0}n.mode=SF;case SF:k=q$;break e;case ur:k=OF;break e;case a7:return o7;case C$:default:return eo}return e.next_out=a,e.avail_out=c,e.next_in=o,e.avail_in=s,n.hold=l,n.bits=u,(n.wsize||d!==e.avail_out&&n.mode<ur&&(n.mode<t7||t!==tF))&&VF(e,e.output,e.next_out,d-e.avail_out)?(n.mode=a7,o7):(f-=e.avail_in,d-=e.avail_out,e.total_in+=f,e.total_out+=d,n.total+=d,n.wrap&&d&&(e.adler=n.check=n.flags?qo(n.check,r,d,e.next_out-d):i7(n.check,r,d,e.next_out-d)),e.data_type=n.bits+(n.last?64:0)+(n.mode===xa?128:0)+(n.mode===$0||n.mode===e7?256:0),(f===0&&d===0||t===tF)&&k===wc&&(k=E$),k)}function _$(e){if(!e||!e.state)return eo;var t=e.state;return t.window&&(t.window=null),e.state=null,wc}function $$(e,t){var n;return!e||!e.state||(n=e.state,(n.wrap&2)===0)?eo:(n.head=t,t.done=!1,wc)}function eee(e,t){var n=t.length,i,r,o;return!e||!e.state||(i=e.state,i.wrap!==0&&i.mode!==tg)?eo:i.mode===tg&&(r=1,r=i7(r,t,n,0),r!==i.check)?OF:(o=VF(e,t,n,n),o?(i.mode=a7,o7):(i.havedict=1,wc))}po.inflateReset=NF;po.inflateReset2=RF;po.inflateResetKeep=XF;po.inflateInit=Y$;po.inflateInit2=FF;po.inflate=Q$;po.inflateEnd=_$;po.inflateGetHeader=$$;po.inflateSetDictionary=eee;po.inflateInfo="pako inflate (from Nodeca project)"});var s7=rt((q0e,ZF)=>{"use strict";ZF.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}});var WF=rt((H0e,IF)=>{"use strict";function tee(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}IF.exports=tee});var qF=rt(pm=>{"use strict";var vu=jF(),mm=va(),ng=GS(),Sr=s7(),c7=C0(),nee=JS(),ree=WF(),DF=Object.prototype.toString;function xc(e){if(!(this instanceof xc))return new xc(e);this.options=mm.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,t.windowBits===0&&(t.windowBits=-15)),t.windowBits>=0&&t.windowBits<16&&!(e&&e.windowBits)&&(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&(t.windowBits&15)===0&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new nee,this.strm.avail_out=0;var n=vu.inflateInit2(this.strm,t.windowBits);if(n!==Sr.Z_OK)throw new Error(c7[n]);if(this.header=new ree,vu.inflateGetHeader(this.strm,this.header),t.dictionary&&(typeof t.dictionary=="string"?t.dictionary=ng.string2buf(t.dictionary):DF.call(t.dictionary)==="[object ArrayBuffer]"&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=vu.inflateSetDictionary(this.strm,t.dictionary),n!==Sr.Z_OK)))throw new Error(c7[n])}xc.prototype.push=function(e,t){var n=this.strm,i=this.options.chunkSize,r=this.options.dictionary,o,a,s,c,l,u=!1;if(this.ended)return!1;a=t===~~t?t:t===!0?Sr.Z_FINISH:Sr.Z_NO_FLUSH,typeof e=="string"?n.input=ng.binstring2buf(e):DF.call(e)==="[object ArrayBuffer]"?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;do{if(n.avail_out===0&&(n.output=new mm.Buf8(i),n.next_out=0,n.avail_out=i),o=vu.inflate(n,Sr.Z_NO_FLUSH),o===Sr.Z_NEED_DICT&&r&&(o=vu.inflateSetDictionary(this.strm,r)),o===Sr.Z_BUF_ERROR&&u===!0&&(o=Sr.Z_OK,u=!1),o!==Sr.Z_STREAM_END&&o!==Sr.Z_OK)return this.onEnd(o),this.ended=!0,!1;n.next_out&&(n.avail_out===0||o===Sr.Z_STREAM_END||n.avail_in===0&&(a===Sr.Z_FINISH||a===Sr.Z_SYNC_FLUSH))&&(this.options.to==="string"?(s=ng.utf8border(n.output,n.next_out),c=n.next_out-s,l=ng.buf2string(n.output,s),n.next_out=c,n.avail_out=i-c,c&&mm.arraySet(n.output,n.output,s,c,0),this.onData(l)):this.onData(mm.shrinkBuf(n.output,n.next_out))),n.avail_in===0&&n.avail_out===0&&(u=!0)}while((n.avail_in>0||n.avail_out===0)&&o!==Sr.Z_STREAM_END);return o===Sr.Z_STREAM_END&&(a=Sr.Z_FINISH),a===Sr.Z_FINISH?(o=vu.inflateEnd(this.strm),this.onEnd(o),this.ended=!0,o===Sr.Z_OK):(a===Sr.Z_SYNC_FLUSH&&(this.onEnd(Sr.Z_OK),n.avail_out=0),!0)};xc.prototype.onData=function(e){this.chunks.push(e)};xc.prototype.onEnd=function(e){e===Sr.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=mm.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};function l7(e,t){var n=new xc(t);if(n.push(e,!0),n.err)throw n.msg||c7[n.err];return n.result}function iee(e,t){return t=t||{},t.raw=!0,l7(e,t)}pm.Inflate=xc;pm.inflate=l7;pm.inflateRaw=iee;pm.ungzip=l7});var CF=rt((C0e,EF)=>{"use strict";var oee=va().assign,aee=AR(),see=qF(),cee=s7(),HF={};oee(HF,aee,see,cee);EF.exports=HF});var AF=rt(ig=>{"use strict";var lee=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",uee=CF(),UF=br(),rg=Ui(),fee=lee?"uint8array":"array";ig.magic="\b\0";function Pc(e,t){rg.call(this,"FlateWorker/"+e),this._pako=null,this._pakoAction=e,this._pakoOptions=t,this.meta={}}UF.inherits(Pc,rg);Pc.prototype.processChunk=function(e){this.meta=e.meta,this._pako===null&&this._createPako(),this._pako.push(UF.transformTo(fee,e.data),!1)};Pc.prototype.flush=function(){rg.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)};Pc.prototype.cleanUp=function(){rg.prototype.cleanUp.call(this),this._pako=null};Pc.prototype._createPako=function(){this._pako=new uee[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var e=this;this._pako.onData=function(t){e.push({data:t,meta:e.meta})}};ig.compressWorker=function(e){return new Pc("Deflate",e)};ig.uncompressWorker=function(){return new Pc("Inflate",{})}});var f7=rt(u7=>{"use strict";var GF=Ui();u7.STORE={magic:"\0\0",compressWorker:function(){return new GF("STORE compression")},uncompressWorker:function(){return new GF("STORE decompression")}};u7.DEFLATE=AF()});var d7=rt(Sc=>{"use strict";Sc.LOCAL_FILE_HEADER="PK";Sc.CENTRAL_FILE_HEADER="PK";Sc.CENTRAL_DIRECTORY_END="PK";Sc.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07";Sc.ZIP64_CENTRAL_DIRECTORY_END="PK";Sc.DATA_DESCRIPTOR="PK\x07\b"});var KF=rt((J0e,YF)=>{"use strict";var yu=br(),wu=Ui(),m7=su(),JF=W0(),og=d7(),tr=function(e,t){var n="",i;for(i=0;i<t;i++)n+=String.fromCharCode(e&255),e=e>>>8;return n},dee=function(e,t){var n=e;return e||(n=t?16893:33204),(n&65535)<<16},mee=function(e){return(e||0)&63},BF=function(e,t,n,i,r,o){var a=e.file,s=e.compression,c=o!==m7.utf8encode,l=yu.transformTo("string",o(a.name)),u=yu.transformTo("string",m7.utf8encode(a.name)),f=a.comment,d=yu.transformTo("string",o(f)),m=yu.transformTo("string",m7.utf8encode(f)),p=u.length!==a.name.length,b=m.length!==f.length,h,v,g="",y="",w="",x=a.dir,T=a.date,z={crc32:0,compressedSize:0,uncompressedSize:0};(!t||n)&&(z.crc32=e.crc32,z.compressedSize=e.compressedSize,z.uncompressedSize=e.uncompressedSize);var k=0;t&&(k|=8),!c&&(p||b)&&(k|=2048);var S=0,M=0;x&&(S|=16),r==="UNIX"?(M=798,S|=dee(a.unixPermissions,x)):(M=20,S|=mee(a.dosPermissions,x)),h=T.getUTCHours(),h=h<<6,h=h|T.getUTCMinutes(),h=h<<5,h=h|T.getUTCSeconds()/2,v=T.getUTCFullYear()-1980,v=v<<4,v=v|T.getUTCMonth()+1,v=v<<5,v=v|T.getUTCDate(),p&&(y=tr(1,1)+tr(JF(l),4)+u,g+="up"+tr(y.length,2)+y),b&&(w=tr(1,1)+tr(JF(d),4)+m,g+="uc"+tr(w.length,2)+w);var L="";L+=`
4
+ \0`,L+=tr(k,2),L+=s.magic,L+=tr(h,2),L+=tr(v,2),L+=tr(z.crc32,4),L+=tr(z.compressedSize,4),L+=tr(z.uncompressedSize,4),L+=tr(l.length,2),L+=tr(g.length,2);var P=og.LOCAL_FILE_HEADER+L+l+g,X=og.CENTRAL_FILE_HEADER+tr(M,2)+L+tr(d.length,2)+"\0\0\0\0"+tr(S,4)+tr(i,4)+l+g+d;return{fileRecord:P,dirRecord:X}},pee=function(e,t,n,i,r){var o="",a=yu.transformTo("string",r(i));return o=og.CENTRAL_DIRECTORY_END+"\0\0\0\0"+tr(e,2)+tr(e,2)+tr(t,4)+tr(n,4)+tr(a.length,2)+a,o},hee=function(e){var t="";return t=og.DATA_DESCRIPTOR+tr(e.crc32,4)+tr(e.compressedSize,4)+tr(e.uncompressedSize,4),t};function ho(e,t,n,i){wu.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=t,this.zipPlatform=n,this.encodeFileName=i,this.streamFiles=e,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}yu.inherits(ho,wu);ho.prototype.push=function(e){var t=e.meta.percent||0,n=this.entriesCount,i=this._sources.length;this.accumulate?this.contentBuffer.push(e):(this.bytesWritten+=e.data.length,wu.prototype.push.call(this,{data:e.data,meta:{currentFile:this.currentFile,percent:n?(t+100*(n-i-1))/n:100}}))};ho.prototype.openedSource=function(e){this.currentSourceOffset=this.bytesWritten,this.currentFile=e.file.name;var t=this.streamFiles&&!e.file.dir;if(t){var n=BF(e,t,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:n.fileRecord,meta:{percent:0}})}else this.accumulate=!0};ho.prototype.closedSource=function(e){this.accumulate=!1;var t=this.streamFiles&&!e.file.dir,n=BF(e,t,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(n.dirRecord),t)this.push({data:hee(e),meta:{percent:100}});else for(this.push({data:n.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null};ho.prototype.flush=function(){for(var e=this.bytesWritten,t=0;t<this.dirRecords.length;t++)this.push({data:this.dirRecords[t],meta:{percent:100}});var n=this.bytesWritten-e,i=pee(this.dirRecords.length,n,e,this.zipComment,this.encodeFileName);this.push({data:i,meta:{percent:100}})};ho.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()};ho.prototype.registerPrevious=function(e){this._sources.push(e);var t=this;return e.on("data",function(n){t.processChunk(n)}),e.on("end",function(){t.closedSource(t.previous.streamInfo),t._sources.length?t.prepareNextSource():t.end()}),e.on("error",function(n){t.error(n)}),this};ho.prototype.resume=function(){if(!wu.prototype.resume.call(this))return!1;if(!this.previous&&this._sources.length)return this.prepareNextSource(),!0;if(!this.previous&&!this._sources.length&&!this.generatedError)return this.end(),!0};ho.prototype.error=function(e){var t=this._sources;if(!wu.prototype.error.call(this,e))return!1;for(var n=0;n<t.length;n++)try{t[n].error(e)}catch{}return!0};ho.prototype.lock=function(){wu.prototype.lock.call(this);for(var e=this._sources,t=0;t<e.length;t++)e[t].lock()};YF.exports=ho});var _F=rt(QF=>{"use strict";var bee=f7(),gee=KF(),vee=function(e,t){var n=e||t,i=bee[n];if(!i)throw new Error(n+" is not a valid compression method !");return i};QF.generateWorker=function(e,t,n){var i=new gee(t.streamFiles,n,t.platform,t.encodeFileName),r=0;try{e.forEach(function(o,a){r++;var s=vee(a.options.compression,t.compression),c=a.options.compressionOptions||t.compressionOptions||{},l=a.dir,u=a.date;a._compressWorker(s,c).withStreamInfo("file",{name:o,dir:l,date:u,comment:a.comment||"",unixPermissions:a.unixPermissions,dosPermissions:a.dosPermissions}).pipe(i)}),i.entriesCount=r}catch(o){i.error(o)}return i}});var eV=rt((Y0e,$F)=>{"use strict";var yee=br(),ag=Ui();function hm(e,t){ag.call(this,"Nodejs stream input adapter for "+e),this._upstreamEnded=!1,this._bindStream(t)}yee.inherits(hm,ag);hm.prototype._bindStream=function(e){var t=this;this._stream=e,e.pause(),e.on("data",function(n){t.push({data:n,meta:{percent:0}})}).on("error",function(n){t.isPaused?this.generatedError=n:t.error(n)}).on("end",function(){t.isPaused?t._upstreamEnded=!0:t.end()})};hm.prototype.pause=function(){return ag.prototype.pause.call(this)?(this._stream.pause(),!0):!1};hm.prototype.resume=function(){return ag.prototype.resume.call(this)?(this._upstreamEnded?this.end():this._stream.resume(),!0):!1};$F.exports=hm});var uV=rt((K0e,lV)=>{"use strict";var wee=su(),bm=br(),iV=Ui(),xee=vS(),oV=yS(),tV=D0(),Pee=nR(),See=_F(),nV=Ad(),kee=eV(),aV=function(e,t,n){var i=bm.getTypeOf(t),r,o=bm.extend(n||{},oV);o.date=o.date||new Date,o.compression!==null&&(o.compression=o.compression.toUpperCase()),typeof o.unixPermissions=="string"&&(o.unixPermissions=parseInt(o.unixPermissions,8)),o.unixPermissions&&o.unixPermissions&16384&&(o.dir=!0),o.dosPermissions&&o.dosPermissions&16&&(o.dir=!0),o.dir&&(e=sV(e)),o.createFolders&&(r=Tee(e))&&cV.call(this,r,!0);var a=i==="string"&&o.binary===!1&&o.base64===!1;(!n||typeof n.binary>"u")&&(o.binary=!a);var s=t instanceof tV&&t.uncompressedSize===0;(s||o.dir||!t||t.length===0)&&(o.base64=!1,o.binary=!0,t="",o.compression="STORE",i="string");var c=null;t instanceof tV||t instanceof iV?c=t:nV.isNode&&nV.isStream(t)?c=new kee(e,t):c=bm.prepareContent(e,t,o.binary,o.optimizedBinaryString,o.base64);var l=new Pee(e,c,o);this.files[e]=l},Tee=function(e){e.slice(-1)==="/"&&(e=e.substring(0,e.length-1));var t=e.lastIndexOf("/");return t>0?e.substring(0,t):""},sV=function(e){return e.slice(-1)!=="/"&&(e+="/"),e},cV=function(e,t){return t=typeof t<"u"?t:oV.createFolders,e=sV(e),this.files[e]||aV.call(this,e,null,{dir:!0,createFolders:t}),this.files[e]};function rV(e){return Object.prototype.toString.call(e)==="[object RegExp]"}var zee={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(e){var t,n,i;for(t in this.files)i=this.files[t],n=t.slice(this.root.length,t.length),n&&t.slice(0,this.root.length)===this.root&&e(n,i)},filter:function(e){var t=[];return this.forEach(function(n,i){e(n,i)&&t.push(i)}),t},file:function(e,t,n){if(arguments.length===1)if(rV(e)){var i=e;return this.filter(function(o,a){return!a.dir&&i.test(o)})}else{var r=this.files[this.root+e];return r&&!r.dir?r:null}else e=this.root+e,aV.call(this,e,t,n);return this},folder:function(e){if(!e)return this;if(rV(e))return this.filter(function(r,o){return o.dir&&e.test(r)});var t=this.root+e,n=cV.call(this,t),i=this.clone();return i.root=n.name,i},remove:function(e){e=this.root+e;var t=this.files[e];if(t||(e.slice(-1)!=="/"&&(e+="/"),t=this.files[e]),t&&!t.dir)delete this.files[e];else for(var n=this.filter(function(r,o){return o.name.slice(0,e.length)===e}),i=0;i<n.length;i++)delete this.files[n[i].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(e){var t,n={};try{if(n=bm.extend(e||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:wee.utf8encode}),n.type=n.type.toLowerCase(),n.compression=n.compression.toUpperCase(),n.type==="binarystring"&&(n.type="string"),!n.type)throw new Error("No output type specified.");bm.checkSupport(n.type),(n.platform==="darwin"||n.platform==="freebsd"||n.platform==="linux"||n.platform==="sunos")&&(n.platform="UNIX"),n.platform==="win32"&&(n.platform="DOS");var i=n.comment||this.comment||"";t=See.generateWorker(this,n,i)}catch(r){t=new iV("error"),t.error(r)}return new xee(t,n.type||"string",n.mimeType)},generateAsync:function(e,t){return this.generateInternalStream(e).accumulate(t)},generateNodeStream:function(e,t){return e=e||{},e.type||(e.type="nodebuffer"),this.generateInternalStream(e).toNodejsStream(t)}};lV.exports=zee});var p7=rt((Q0e,dV)=>{"use strict";var Mee=br();function fV(e){this.data=e,this.length=e.length,this.index=0,this.zero=0}fV.prototype={checkOffset:function(e){this.checkIndex(this.index+e)},checkIndex:function(e){if(this.length<this.zero+e||e<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+e+"). Corrupted zip ?")},setIndex:function(e){this.checkIndex(e),this.index=e},skip:function(e){this.setIndex(this.index+e)},byteAt:function(){},readInt:function(e){var t=0,n;for(this.checkOffset(e),n=this.index+e-1;n>=this.index;n--)t=(t<<8)+this.byteAt(n);return this.index+=e,t},readString:function(e){return Mee.transformTo("string",this.readData(e))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var e=this.readInt(4);return new Date(Date.UTC((e>>25&127)+1980,(e>>21&15)-1,e>>16&31,e>>11&31,e>>5&63,(e&31)<<1))}};dV.exports=fV});var h7=rt((_0e,pV)=>{"use strict";var mV=p7(),Oee=br();function xu(e){mV.call(this,e);for(var t=0;t<this.data.length;t++)e[t]=e[t]&255}Oee.inherits(xu,mV);xu.prototype.byteAt=function(e){return this.data[this.zero+e]};xu.prototype.lastIndexOfSignature=function(e){for(var t=e.charCodeAt(0),n=e.charCodeAt(1),i=e.charCodeAt(2),r=e.charCodeAt(3),o=this.length-4;o>=0;--o)if(this.data[o]===t&&this.data[o+1]===n&&this.data[o+2]===i&&this.data[o+3]===r)return o-this.zero;return-1};xu.prototype.readAndCheckSignature=function(e){var t=e.charCodeAt(0),n=e.charCodeAt(1),i=e.charCodeAt(2),r=e.charCodeAt(3),o=this.readData(4);return t===o[0]&&n===o[1]&&i===o[2]&&r===o[3]};xu.prototype.readData=function(e){if(this.checkOffset(e),e===0)return[];var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};pV.exports=xu});var gV=rt(($0e,bV)=>{"use strict";var hV=p7(),Lee=br();function Pu(e){hV.call(this,e)}Lee.inherits(Pu,hV);Pu.prototype.byteAt=function(e){return this.data.charCodeAt(this.zero+e)};Pu.prototype.lastIndexOfSignature=function(e){return this.data.lastIndexOf(e)-this.zero};Pu.prototype.readAndCheckSignature=function(e){var t=this.readData(4);return e===t};Pu.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};bV.exports=Pu});var g7=rt((ege,yV)=>{"use strict";var vV=h7(),Xee=br();function b7(e){vV.call(this,e)}Xee.inherits(b7,vV);b7.prototype.readData=function(e){if(this.checkOffset(e),e===0)return new Uint8Array(0);var t=this.data.subarray(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};yV.exports=b7});var PV=rt((tge,xV)=>{"use strict";var wV=g7(),Nee=br();function v7(e){wV.call(this,e)}Nee.inherits(v7,wV);v7.prototype.readData=function(e){this.checkOffset(e);var t=this.data.slice(this.zero+this.index,this.zero+this.index+e);return this.index+=e,t};xV.exports=v7});var y7=rt((nge,kV)=>{"use strict";var sg=br(),SV=ba(),Ree=h7(),Fee=gV(),Vee=PV(),jee=g7();kV.exports=function(e){var t=sg.getTypeOf(e);return sg.checkSupport(t),t==="string"&&!SV.uint8array?new Fee(e):t==="nodebuffer"?new Vee(e):SV.uint8array?new jee(sg.transformTo("uint8array",e)):new Ree(sg.transformTo("array",e))}});var OV=rt((rge,MV)=>{"use strict";var w7=y7(),ps=br(),Zee=D0(),TV=W0(),cg=su(),lg=f7(),Iee=ba(),Wee=0,Dee=3,qee=function(e){for(var t in lg)if(Object.prototype.hasOwnProperty.call(lg,t)&&lg[t].magic===e)return lg[t];return null};function zV(e,t){this.options=e,this.loadOptions=t}zV.prototype={isEncrypted:function(){return(this.bitFlag&1)===1},useUTF8:function(){return(this.bitFlag&2048)===2048},readLocalPart:function(e){var t,n;if(e.skip(22),this.fileNameLength=e.readInt(2),n=e.readInt(2),this.fileName=e.readData(this.fileNameLength),e.skip(n),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(t=qee(this.compressionMethod),t===null)throw new Error("Corrupted zip : compression "+ps.pretty(this.compressionMethod)+" unknown (inner file : "+ps.transformTo("string",this.fileName)+")");this.decompressed=new Zee(this.compressedSize,this.uncompressedSize,this.crc32,t,e.readData(this.compressedSize))},readCentralPart:function(e){this.versionMadeBy=e.readInt(2),e.skip(2),this.bitFlag=e.readInt(2),this.compressionMethod=e.readString(2),this.date=e.readDate(),this.crc32=e.readInt(4),this.compressedSize=e.readInt(4),this.uncompressedSize=e.readInt(4);var t=e.readInt(2);if(this.extraFieldsLength=e.readInt(2),this.fileCommentLength=e.readInt(2),this.diskNumberStart=e.readInt(2),this.internalFileAttributes=e.readInt(2),this.externalFileAttributes=e.readInt(4),this.localHeaderOffset=e.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");e.skip(t),this.readExtraFields(e),this.parseZIP64ExtraField(e),this.fileComment=e.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var e=this.versionMadeBy>>8;this.dir=!!(this.externalFileAttributes&16),e===Wee&&(this.dosPermissions=this.externalFileAttributes&63),e===Dee&&(this.unixPermissions=this.externalFileAttributes>>16&65535),!this.dir&&this.fileNameStr.slice(-1)==="/"&&(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var e=w7(this.extraFields[1].value);this.uncompressedSize===ps.MAX_VALUE_32BITS&&(this.uncompressedSize=e.readInt(8)),this.compressedSize===ps.MAX_VALUE_32BITS&&(this.compressedSize=e.readInt(8)),this.localHeaderOffset===ps.MAX_VALUE_32BITS&&(this.localHeaderOffset=e.readInt(8)),this.diskNumberStart===ps.MAX_VALUE_32BITS&&(this.diskNumberStart=e.readInt(4))}},readExtraFields:function(e){var t=e.index+this.extraFieldsLength,n,i,r;for(this.extraFields||(this.extraFields={});e.index+4<t;)n=e.readInt(2),i=e.readInt(2),r=e.readData(i),this.extraFields[n]={id:n,length:i,value:r};e.setIndex(t)},handleUTF8:function(){var e=Iee.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=cg.utf8decode(this.fileName),this.fileCommentStr=cg.utf8decode(this.fileComment);else{var t=this.findExtraFieldUnicodePath();if(t!==null)this.fileNameStr=t;else{var n=ps.transformTo(e,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(n)}var i=this.findExtraFieldUnicodeComment();if(i!==null)this.fileCommentStr=i;else{var r=ps.transformTo(e,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(r)}}},findExtraFieldUnicodePath:function(){var e=this.extraFields[28789];if(e){var t=w7(e.value);return t.readInt(1)!==1||TV(this.fileName)!==t.readInt(4)?null:cg.utf8decode(t.readData(e.length-5))}return null},findExtraFieldUnicodeComment:function(){var e=this.extraFields[25461];if(e){var t=w7(e.value);return t.readInt(1)!==1||TV(this.fileComment)!==t.readInt(4)?null:cg.utf8decode(t.readData(e.length-5))}return null}};MV.exports=zV});var NV=rt((ige,XV)=>{"use strict";var Hee=y7(),Pa=br(),bo=d7(),Eee=OV(),Cee=ba();function LV(e){this.files=[],this.loadOptions=e}LV.prototype={checkSignature:function(e){if(!this.reader.readAndCheckSignature(e)){this.reader.index-=4;var t=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+Pa.pretty(t)+", expected "+Pa.pretty(e)+")")}},isSignature:function(e,t){var n=this.reader.index;this.reader.setIndex(e);var i=this.reader.readString(4),r=i===t;return this.reader.setIndex(n),r},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var e=this.reader.readData(this.zipCommentLength),t=Cee.uint8array?"uint8array":"array",n=Pa.transformTo(t,e);this.zipComment=this.loadOptions.decodeFileName(n)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var e=this.zip64EndOfCentralSize-44,t=0,n,i,r;t<e;)n=this.reader.readInt(2),i=this.reader.readInt(4),r=this.reader.readData(i),this.zip64ExtensibleData[n]={id:n,length:i,value:r}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var e,t;for(e=0;e<this.files.length;e++)t=this.files[e],this.reader.setIndex(t.localHeaderOffset),this.checkSignature(bo.LOCAL_FILE_HEADER),t.readLocalPart(this.reader),t.handleUTF8(),t.processAttributes()},readCentralDir:function(){var e;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(bo.CENTRAL_FILE_HEADER);)e=new Eee({zip64:this.zip64},this.loadOptions),e.readCentralPart(this.reader),this.files.push(e);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var e=this.reader.lastIndexOfSignature(bo.CENTRAL_DIRECTORY_END);if(e<0){var t=!this.isSignature(0,bo.LOCAL_FILE_HEADER);throw t?new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html"):new Error("Corrupted zip: can't find end of central directory")}this.reader.setIndex(e);var n=e;if(this.checkSignature(bo.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===Pa.MAX_VALUE_16BITS||this.diskWithCentralDirStart===Pa.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===Pa.MAX_VALUE_16BITS||this.centralDirRecords===Pa.MAX_VALUE_16BITS||this.centralDirSize===Pa.MAX_VALUE_32BITS||this.centralDirOffset===Pa.MAX_VALUE_32BITS){if(this.zip64=!0,e=this.reader.lastIndexOfSignature(bo.ZIP64_CENTRAL_DIRECTORY_LOCATOR),e<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(e),this.checkSignature(bo.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,bo.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(bo.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(bo.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var i=this.centralDirOffset+this.centralDirSize;this.zip64&&(i+=20,i+=12+this.zip64EndOfCentralSize);var r=n-i;if(r>0)this.isSignature(n,bo.CENTRAL_FILE_HEADER)||(this.reader.zero=r);else if(r<0)throw new Error("Corrupted zip: missing "+Math.abs(r)+" bytes.")},prepareReader:function(e){this.reader=Hee(e)},load:function(e){this.prepareReader(e),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}};XV.exports=LV});var VV=rt((oge,FV)=>{"use strict";var x7=br(),ug=iu(),Uee=su(),Aee=NV(),Gee=PS(),RV=Ad();function Jee(e){return new ug.Promise(function(t,n){var i=e.decompressed.getContentWorker().pipe(new Gee);i.on("error",function(r){n(r)}).on("end",function(){i.streamInfo.crc32!==e.decompressed.crc32?n(new Error("Corrupted zip : CRC32 mismatch")):t()}).resume()})}FV.exports=function(e,t){var n=this;return t=x7.extend(t||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:Uee.utf8decode}),RV.isNode&&RV.isStream(e)?ug.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):x7.prepareContent("the loaded zip file",e,!0,t.optimizedBinaryString,t.base64).then(function(i){var r=new Aee(t);return r.load(i),r}).then(function(r){var o=[ug.Promise.resolve(r)],a=r.files;if(t.checkCRC32)for(var s=0;s<a.length;s++)o.push(Jee(a[s]));return ug.Promise.all(o)}).then(function(r){for(var o=r.shift(),a=o.files,s=0;s<a.length;s++){var c=a[s],l=c.fileNameStr,u=x7.resolve(c.fileNameStr);n.file(u,c.decompressed,{binary:!0,optimizedBinaryString:!0,date:c.date,dir:c.dir,comment:c.fileCommentStr.length?c.fileCommentStr:null,unixPermissions:c.unixPermissions,dosPermissions:c.dosPermissions,createFolders:t.createFolders}),c.dir||(n.file(u).unsafeOriginalName=l)}return o.zipComment.length&&(n.comment=o.zipComment),n})}});var P7=rt((age,jV)=>{"use strict";function to(){if(!(this instanceof to))return new to;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var e=new to;for(var t in this)typeof this[t]!="function"&&(e[t]=this[t]);return e}}to.prototype=uV();to.prototype.loadAsync=VV();to.support=ba();to.defaults=yS();to.version="3.10.1";to.loadAsync=function(e,t){return new to().loadAsync(e,t)};to.external=iu();jV.exports=to});var ze=class extends Error{constructor(n,i,r){super(i);this.code=n;this.data=r;this.name="ConformError"}};function Tt(e,t){return{content:[{type:"text",text:e}],...t?{structuredContent:{ok:!0,...t}}:{}}}var hr=e=>Tt(e);function ct(e){let t=e instanceof ze?e:nq(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 nq(e){let t=e instanceof Error?e.message:String(e);return/unknown session_id|not found on this machine|No such file|NotFound/i.test(t)?new ze("not_found",t):/unsupported|not supported|no local decoder|cannot detect/i.test(t)?new ze("unsupported",t):/before the file start|past the last frame|is before|required|unknown (operation|target|verb)/i.test(t)?new ze("invalid_args",t):/could not read|failed to parse|engine read failed/i.test(t)?new ze("unreadable",t):/refused|coverage|never shipped/i.test(t)?new ze("refused",t):/abort|cancel/i.test(t)?new ze("cancelled",t):new ze("engine",t)}function xse(e,t){let[n,...i]=t.content,r=`[conformtools ${e}]`;return{...t,content:n?[{...n,text:`${r} ${n.text}`},...i]:[{type:"text",text:r}]}}var rq={production:{supabaseUrl:"https://sttpwvjbpsetzbhrkohl.supabase.co",anonKey:"sb_publishable_cyuIPsrQa5Ye7lqFxjnknQ_ozDuwwzp",appBase:"https://conform.tools"},staging:{supabaseUrl:"https://slxggvbvgzkiwojcgykx.supabase.co",anonKey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InNseGdndmJ2Z3praXdvamNneWt4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzEyODUzMTksImV4cCI6MjA4Njg2MTMxOX0.b18iDsWftny0k9VmOCcbN6kLlyZsZ7GULn_jRH9CE9I",appBase:"https://beta.conform.tools"}};function yr(){let e=Ut("CONFORM_ENV")==="staging"?"staging":"production",t=rq[e];return{env:e,supabaseUrl:Ut("CONFORM_SUPABASE_URL")??t.supabaseUrl,anonKey:Ut("CONFORM_SUPABASE_ANON_KEY")??t.anonKey,appBase:Ut("CONFORM_APP_BASE")??t.appBase}}var iq=600*1e3,G6=72*3600*1e3,oq=300*1e3,af=()=>_(wt(),"auth.json");async function B6(){try{let e=JSON.parse(await Tn(af()));return e.env===yr().env&&e.access_token?e:null}catch{return null}}async function Ov(e){await vt(wt()),await ln(af(),JSON.stringify(e)),await So(af(),384)}async function Y6(e){if(e.expires_at-60>Date.now()/1e3)return e.access_token;let t=yr();try{let n=await fetch(`${t.supabaseUrl}/auth/v1/token?grant_type=refresh_token`,{method:"POST",headers:{apikey:t.anonKey,"content-type":"application/json"},body:JSON.stringify({refresh_token:e.refresh_token})});if(!n.ok)return n.status===400||n.status===401?"":null;let i=await n.json();return e.access_token=i.access_token,i.refresh_token&&(e.refresh_token=i.refresh_token),e.expires_at=i.expires_at??Math.floor(Date.now()/1e3)+(i.expires_in??3600),await Ov(e),e.access_token}catch{return null}}async function Ko(){let e=await B6();return e&&await Y6(e)||null}var Cc=null;function J6(e,t){return{signed_in:!0,entitled:e.entitled,env:yr().env,email:e.email,access:e.access,tier:e.tier,trial_days_remaining:e.trial_days_remaining,source:t,...e.entitled?{}:{reason:"not_entitled"}}}async function Uc(e={}){if(!e.force&&Cc&&Date.now()-Cc.at<iq)return{...Cc.status,source:"cache"};let t=yr(),n=await B6();if(!n)return{signed_in:!1,entitled:!1,env:t.env,reason:"not_signed_in"};let i=await Y6(n);if(i==="")return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(i)try{let r=await fetch(`${t.supabaseUrl}/functions/v1/v1-billing/v1/billing/entitlement`,{headers:{authorization:`Bearer ${i}`,apikey:t.anonKey}});if(r.status===401||r.status===403)return{signed_in:!0,entitled:!1,env:t.env,reason:"auth_rejected"};if(r.ok){let o=(await r.json()).data;n.last_entitlement=o,n.last_entitlement_at=Date.now(),await Ov(n);let a=J6(o,"live");return Cc={at:Date.now(),status:a},a}}catch{}if(n.last_entitlement&&n.last_entitlement_at&&Date.now()-n.last_entitlement_at<G6){let r=G6-(Date.now()-n.last_entitlement_at);return{...J6(n.last_entitlement,"grace"),grace_remaining_h:Math.round(r/36e4)/10}}return{signed_in:!0,entitled:!1,env:t.env,reason:"offline_grace_expired"}}function op(e){let t=yr();if(!e.signed_in)return`not signed in (${t.env}). Run the account_login tool, or \`npx -y conformtools@latest login\` in a terminal.`;if(e.reason==="auth_rejected")return"signed-in session was rejected (expired or revoked) \u2014 sign in again with account_login.";if(e.reason==="offline_grace_expired")return"offline for more than 72 h since the last account check \u2014 reconnect and run account_status.";let n=`${e.email??"(unknown email)"} \xB7 ${t.env}`;if(!e.entitled)return`${n}
5
+ no active plan: the trial has ended and there is no subscription. Choose a plan at ${t.appBase}/pricing, then run account_status.`;let i=e.access==="trial"?`trial, ${e.trial_days_remaining??"?"} day(s) left`:`subscribed${e.tier?` (${e.tier})`:""}`;return`${n}
6
+ ${i}${e.source==="grace"?` \u2014 offline, using the last check (${e.grace_remaining_h} h of grace left)`:""}`}var aq=()=>Uc();async function K6(){let e=await aq();if(e.entitled)return e;let t=e.signed_in&&e.reason==="not_entitled"?"not_entitled":"not_signed_in";throw new ze(t,op(e),{account:e})}var of=null;function Q6(e={}){if(of)return of;let t=yr(),n=crypto.randomUUID().replaceAll("-","");return of=new Promise((i,r)=>{let o=!1,a=l=>{o||(o=!0,clearTimeout(c),setTimeout(()=>s.close(),250),of=null,l())},s=D6({hostname:"127.0.0.1",port:0,onListen:async l=>{let u=`${t.appBase}/plugin-auth?client=engine&port=${l}&state=${n}`,f=await W6(u);e.onUrl?.(u,f)}},async l=>{let u=new URL(l.url);if(u.pathname!=="/callback")return new Response("not found",{status:404});let f=u.searchParams,d=f.get("access_token")??"",m=f.get("refresh_token")??"",p=!!d&&!!m&&f.get("state")===n;if(p){let b=Number(f.get("expires_at"));await Ov({env:t.env,access_token:d,refresh_token:m,expires_at:b>0?b:Math.floor(Date.now()/1e3)+3600}),Cc=null,Uc({force:!0}).then(h=>a(()=>i(h)),h=>a(()=>r(h)))}return new Response(sq(p),{status:p?200:400,headers:{"content-type":"text/html; charset=utf-8"}})}),c=setTimeout(()=>a(()=>r(new ze("not_signed_in","sign-in was not completed within 5 minutes"))),e.timeoutMs??oq)}),of}async function _6(){Cc=null,await Nn(af())&&await Er(af())}function sq(e){let[t,n]=e?["Connected","You're signed in \u2014 you can close this tab."]:["Sign-in failed","Please try again."];return`<!doctype html><meta charset=utf-8><title>conform.tools</title><body style='font:16px -apple-system,Helvetica,Arial,sans-serif;display:flex;align-items:center;justify-content:center;height:100vh;margin:0;background:#f5f5f7;color:#1d1d1f'><div style='text-align:center'><div style='font-size:22px;font-weight:700'>conform<span style='color:#ff3c00'>.tools</span></div><div style='margin-top:14px;font-size:20px;font-weight:600'>${t}</div><div style='margin-top:6px;color:#6e6e73'>${n}</div></div></body>`}function tn(e,t,n=!1){if(!t||t<=0||!Number.isFinite(e))return String(e);let i=Math.round(t),r=Math.round(e);if(n&&(i===30||i===60)){let u=i===30?2:4,f=i*600-u*9,d=Math.floor(r/f),m=r%f;r+=u*9*d,m>u&&(r+=u*Math.floor((m-u)/(i*60-u)))}let o=r%i,a=Math.floor(r/i)%60,s=Math.floor(r/(i*60))%60,c=Math.floor(r/(i*3600)),l=u=>String(u).padStart(2,"0");return`${l(c)}:${l(s)}:${l(a)}${n?";":":"}${l(o)}`}function Kn(e,t){let n=e.trim().match(/^(\d+)[:;.](\d+)[:;.](\d+)([:;.])(\d+)$/);if(!n||!t)return null;let i=+n[1],r=+n[2],o=+n[3],a=+n[5],s=Math.round(t),c=(i*3600+r*60+o)*s+a;if(n[4]===";"&&(s===30||s===60)){let l=s===30?2:4,u=i*60+r;c-=l*(u-Math.floor(u/10))}return c}function Jr(e,t,n){if(typeof e=="number")return e;if(/^\d+$/.test(e.trim()))return parseInt(e,10);let i=Kn(e,t);if(i==null)throw new Error(`cannot parse timecode '${e}' at ${t} fps`);let r=n?Kn(n,t)??0:0;return i-r}async function Ms(e,t,n,i={}){if(typeof VideoDecoder>"u")throw new Error("this browser has no VideoDecoder (WebCodecs) \u2014 H.264/HEVC needs Chrome/Edge/Safari 16+");let r={fileSize:e.size,read:async(m,p)=>new Uint8Array(await e.slice(m,m+p).arrayBuffer())},o=await v6(r),a=M6(o);if(!a)throw new Error("no H.264/HEVC decoder configuration found in this file");let s={codec:a.codec,description:a.description,hardwareAcceleration:"prefer-hardware"};if(!(await VideoDecoder.isConfigSupported(s).catch(()=>null))?.supported){if(!(await VideoDecoder.isConfigSupported({codec:a.codec,description:a.description}).catch(()=>null))?.supported)throw new Error(`this browser can't decode ${a.codec} \u2014 try a ProRes or H.264 export`);delete s.hardwareAcceleration}let l=a.decodeToPres.length||t.length,u=null,f=new VideoDecoder({output:m=>{try{n(m,Number(m.timestamp))}catch(p){u=u??(p instanceof Error?p:new Error(String(p)))}finally{m.close()}},error:m=>{u=m instanceof Error?m:new Error(String(m))}});f.configure(s);let d=[];for(let m=0;m<a.keyframes.length;m++){let p=a.keyframes[m],b=m+1<a.keyframes.length?a.keyframes[m+1]:t.length;b>p&&d.push([p,b])}try{for(let[m,p]of d){if(u||i.signal?.aborted)break;if(i.wantPres){let g=!1;for(let y=m;y<p&&!g;y++)g=i.wantPres.has(a.decodeToPres[y]);if(!g)continue}let b=1/0,h=0;for(let g=m;g<p;g++)b=Math.min(b,t[g].offset),h=Math.max(h,t[g].offset+t[g].size);let v=new Uint8Array(await e.slice(b,h).arrayBuffer());for(let g=m;g<p;g++){let y=t[g];f.decode(new EncodedVideoChunk({type:g===m?"key":"delta",timestamp:a.decodeToPres[g],data:v.subarray(y.offset-b,y.offset-b+y.size)}))}await f.flush()}}finally{try{f.close()}catch{}}if(u)throw u;if(i.signal?.aborted)throw new DOMException("aborted","AbortError");return l}var $6=new Set(["I420","I420A","I422","I444","NV12"]),cq=new Set(["I420P10","I420P12","I422P10","I422P12","I444P10","I444P12","I420AP10","I422AP10","I444AP10"]);async function lq(e){let t=e.visibleRect??{x:0,y:0,width:e.codedWidth,height:e.codedHeight},n=t.width,i=t.height,r=e.format??"";if($6.has(r)||cq.has(r)){let l=new Uint8Array(e.allocationSize({rect:t})),u=await e.copyTo(l,{rect:t}),{offset:f,stride:d}=u[0],m=new Uint8Array(n*i);if($6.has(r))for(let p=0;p<i;p++)m.set(l.subarray(f+p*d,f+p*d+n),p*n);else{let p=r.includes("P12")?4:2,b=new DataView(l.buffer,l.byteOffset,l.byteLength);for(let h=0;h<i;h++)for(let v=0;v<n;v++)m[h*n+v]=Math.min(255,b.getUint16(f+h*d+v*2,!0)>>p)}return{y:m,w:n,h:i}}let a=new OffscreenCanvas(n,i).getContext("2d",{willReadFrequently:!0});if(!a)return null;a.drawImage(e,0,0,n,i);let s=a.getImageData(0,0,n,i).data,c=new Uint8Array(n*i);for(let l=0,u=0;l<c.length;l++,u+=4)c[l]=s[u]*77+s[u+1]*150+s[u+2]*29>>8;return{y:c,w:n,h:i}}var ek=async(e,t,n)=>{let i=t.index;if(!i||i.kind!=="h264"&&i.kind!=="hevc")return null;let r=[];await Ms(e,i.offs,(o,a)=>{a===n&&r.push(o.clone())},{wantPres:new Set([n])});try{return r.length?await lq(r[0]):null}finally{for(let o of r)o.close()}},ap=ek;function tk(e){ap=e}function nk(){return ap===ek?null:ap}function rk(e,t,n){return ap(e,t,n)}function ik(e){let t=Ts(e);return t==="prores"||t==="h264"||t==="hevc"?t:"other"}var uq={prores:"ProRes",h264:"H.264",hevc:"HEVC",r3d:"R3D",arriraw:"ARRIRAW",xocn:"X-OCN",vc3:"DNxHR",braw:"BRAW",proresraw:"ProRes RAW",other:"unsupported"};function ko(e){return uq[e]??"unsupported"}function Lv(e,t,n=.1){return e==null||t==null?!1:Math.abs(e-t)>n}function sp(e){return e==null?"?":Number.isInteger(e)?String(e):String(Math.round(e*1e3)/1e3)}function fq(e){let t=JSON.parse(e),n=t.frames??[],i=n.length>>1,r=new Array(i);for(let o=0,a=0;a<i;o+=2,a++)r[a]={offset:n[o],size:n[o+1]};return{offs:r,codec:t.codec,kind:ik(t.codec),w:t.width,h:t.height,fps:t.fps??null,startFrame:t.start_frame??0,dropFrame:t.drop_frame??!1}}async function Xv(e){await ni();let n=await d6((i,r)=>e.slice(i,i+r).arrayBuffer().then(o=>new Uint8Array(o)),e.size,"mov");return fq(n)}var Nv=!1;function ak(e){Nv=e}var To=8,sk=0,dq=3,cp=2;async function mq(e){let t=new Uint8Array(await e.slice(0,16).arrayBuffer()),n=a=>String.fromCharCode(t[a],t[a+1],t[a+2],t[a+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 i=t[0]<<24|t[1]<<16|t[2]<<8|t[3],r=n(4);return/^[A-Za-z0-9 ]{4}$/.test(r)&&(i>=8||i===1)&&i<=e.size?"isobmff":null}function pq(e){let t=e.toLowerCase();return t.endsWith(".braw")?"braw":t.endsWith(".crm")?"crm":"mov"}function hq(e){return async(t,n)=>new Uint8Array(await e.slice(t,Math.min(t+n,e.size)).arrayBuffer())}function ok(e){let t=e.timecode;return!t||!t.fps_denominator?null:t.fps_numerator/t.fps_denominator}async function gn(e){await ni();let t=await mq(e),n=[];if(t==="r3d"){let i=async(s,c,l)=>new Uint8Array(await e.slice(c,Math.min(c+l,e.size)).arrayBuffer()),r=JSON.stringify([{name:e.name,size:e.size}]),o=JSON.parse(await l6(i,r)),a=JSON.parse(await a6(i,r));return/_\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:a.map(s=>({offset:s.essenceOffset,size:s.essenceLength})),w:o.width??0,h:o.height??0,fps:ok(o),startFrame:o.timecode?.start_frame??0,dropFrame:o.timecode?.drop_frame??!1,label:"R3D",spec:{codec:"r3d",subbands:sk},geometrySpec:{codec:"r3d",subbands:dq},index:null,warnings:n}}if(t==="mxf"){let i=hq(e),r=JSON.parse(await c6(i,e.size));if(!r)throw new Error(`${e.name}: MXF index unreadable`);let o=JSON.parse(await s6(i,e.size)),a=[];for(let m=0;m<o.frame_count;m++)a.push({offset:o.frames[m*2],size:o.frames[m*2+1]});let s=a.filter(m=>m.size===0).length;s&&n.push(`${s} frame(s) had no locatable picture KLV`);let c=r.width??0,l=r.height??0,u=(r.inner_codec??"").toLowerCase(),f=null,d="MXF";return u==="arriraw"?(f={codec:"arriraw",w:c,h:l,scale:To},d="ARRIRAW"):u==="xocn"?(f={codec:"xocn",scale:To,...Nv?{display:"rec709"}:{}},d="X-OCN"):await o6(i,e.size)?(f={codec:"vc3",scale:To},d="DNxHR"):await i6(i,e.size)?(f={codec:"prores"},d="ProRes"):n.push(`MXF inner codec ${u||"unknown"} not wired to the fingerprint pool`),{frames:f?a:[],w:c,h:l,fps:ok(r),startFrame:r.timecode?.start_frame??0,dropFrame:r.timecode?.drop_frame??!1,label:d,spec:f,geometrySpec:f&&f.codec==="arriraw"?{...f,scale:cp}:f&&f.codec==="xocn"?{codec:"xocn",scale:cp,...Nv?{display:"rec709"}:{}}:f&&f.codec==="vc3"?{codec:"vc3",scale:cp}:null,index:null,warnings:n}}if(t==="isobmff"){let i=await Xv(e),r=pq(e.name);if(i.kind==="prores")return{frames:i.offs,w:i.w,h:i.h,fps:i.fps,startFrame:i.startFrame,dropFrame:i.dropFrame,label:ko(i.kind),spec:{codec:"prores"},geometrySpec:null,index:i,warnings:n};if(i.kind==="h264"||i.kind==="hevc")return{frames:i.offs,w:i.w,h:i.h,fps:i.fps,startFrame:i.startFrame,dropFrame:i.dropFrame,label:ko(i.kind),spec:null,geometrySpec:null,index:i,warnings:n};let o=r==="braw"?{codec:"braw",scale:To}:i.codec==="aprh"||i.codec==="aprn"?{codec:"proresraw",scale:To}:null;return o||n.push(`codec ${i.codec} not wired to the fingerprint pool`),{frames:o?i.offs:[],w:i.w,h:i.h,fps:i.fps,startFrame:i.startFrame,dropFrame:i.dropFrame,label:o?r==="braw"?"BRAW":"ProRes RAW":`unsupported (${i.codec})`,spec:o,geometrySpec:o?{...o,scale:cp}:null,index:i,warnings:n}}throw new Error(`${e.name}: unrecognised container`)}function Rv(e,t,n){switch(e){case"prores":return{codec:"prores"};case"r3d":return{codec:"r3d",subbands:sk};case"arriraw":return{codec:"arriraw",w:t,h:n,scale:To};case"xocn":return{codec:"xocn",scale:To};case"vc3":return{codec:"vc3",scale:To};case"braw":return{codec:"braw",scale:To};case"proresraw":return{codec:"proresraw",scale:To};default:return null}}function sf(){return Hc({module_or_path:h6})}function Fv(e){let t=new DataView(e.buffer,e.byteOffset,8);return{w:t.getUint32(0,!0),h:t.getUint32(4,!0)}}function Vv(e){let t=B4(e),{w:n,h:i}=Fv(t),r=new Int32Array(n*i),o=new DataView(t.buffer,t.byteOffset+8,n*i*4);for(let a=0;a<n*i;a++)r[a]=o.getInt32(a*4,!0);return{y:r,w:n,h:i}}function ck(e){let t=Gm(e),{w:n,h:i}=Fv(t),r=new Uint16Array(n*i),o=new DataView(t.buffer,t.byteOffset+8,n*i*2);for(let a=0;a<n*i;a++)r[a]=o.getUint16(a*2,!0);return{y:r,width:n,height:i}}function lk(e){let t=J4(e),{w:n,h:i}=Fv(t);return{rgba:new Uint8ClampedArray(t.buffer,t.byteOffset+8,n*i*4).slice(),width:n,height:i}}function Ac(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0,!0),i=t.getUint32(4,!0),r=n*i;if(e.byteLength<8+r*4)throw new Error(`decoded frame short: ${e.byteLength} B for ${n}x${i}`);let o=new Uint8Array(r);for(let a=0,s=8;a<r;a++,s+=4)o[a]=54*e[s]+183*e[s+1]+19*e[s+2]+128>>8;return{y:o,w:n,h:i}}function Os(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),i=n.getUint32(0,!0),r=n.getUint32(4,!0),o=i*r;if(e.byteLength<8+o*2)throw new Error(`decoded luma short: ${e.byteLength} B for ${i}x${r}`);let a=new Uint16Array(o);for(let s=0,c=8;s<o;s++,c+=2)a[s]=n.getUint16(c,!0);return{y:a,w:i,h:r,peak:t}}function mk(e,t){switch(t.codec){case"prores":return Os(Gm(e),1023);case"r3d":return Os(Y4(e),255);case"arriraw":return Os(D4(e,t.w,t.h),255);case"xocn":return Os(e6(e),255);case"vc3":return Os(Q4(e),255);case"braw":return Os(H4(e),4095);case"proresraw":return Os(A4(e),255)}}var uk={gpu:0,wasm:0};var jv=null;function gq(){return jv||(jv=!!0||typeof navigator>"u"||!("gpu"in navigator)?Promise.resolve(null):import("./prores-BNALPJPS.js").catch(()=>null)),jv}function vq(e,t,n,i){if(i===t&&e.length===t*n)return e;let r=new Uint16Array(t*n);for(let o=0;o<n;o++)r.set(e.subarray(o*i,o*i+t),o*t);return r}async function yq(e){try{let t=await gq();if(!t||!await t.proresGpuAvailable())return null;let n=await t.decodeProResFrameGpu(e);return n?{y:vq(n.y,n.width,n.height,n.strideY),w:n.width,h:n.height,peak:1023}:null}catch{return null}}async function wq(e,t){if(t.codec==="prores"){let n=await yq(e);if(n)return uk.gpu++,n;uk.wasm++}return mk(e,t)}function pk(e){let t=e.y.length,n=new Uint8Array(t);if(e.peak===255){for(let r=0;r<t;r++)n[r]=e.y[r]>255?255:e.y[r];return n}let i=255/e.peak;for(let r=0;r<t;r++){let o=Math.round(e.y[r]*i);n[r]=o>255?255:o}return n}var Zv=null;function Iv(e){Zv=e}async function lp(e,t,n,i,r="coarse"){return Zv?Zv(e,t,n,i,r):Qo(await ja(e,t,n,i,r),i,r)}function Qo(e,t,n="coarse"){if(n==="exact"){let i=mk(e,t);return{y:pk(i),w:i.w,h:i.h}}if(n==="index"&&t.codec==="prores"){let i=Vv(e),r=e.length>20?e[18]<<8|e[19]:0,o=r>0?Math.min(i.h,Math.max(1,Math.round(r/8))):i.h,a=new Uint8Array(i.w*o);for(let s=0;s<a.length;s++)a[s]=Math.max(0,Math.min(255,Math.round(i.y[s]/128+128)));return{y:a,w:i.w,h:o}}if(n==="index"&&t.codec==="xocn"){let i=$4(e),r=new DataView(i.buffer,i.byteOffset,i.byteLength),o=r.getUint32(0,!0),a=r.getUint32(4,!0);return{y:i.subarray(8,8+o*a),w:o,h:a}}switch(t.codec){case"prores":{let i=Vv(e);return{y:i.y,w:i.w,h:i.h}}case"r3d":return Ac(K4(e,t.subbands));case"arriraw":return Ac(q4(e,t.w,t.h,t.scale));case"xocn":return Ac(t.display==="rec709"?n6(e):t6(e,t.scale));case"vc3":return Ac(_4(e,t.scale));case"braw":return Ac(E4(e,t.scale));case"proresraw":return Ac(G4(e,t.scale))}}var fk=512*1024,dk=160*1024;async function ja(e,t,n,i,r="coarse"){let o=async a=>new Uint8Array(await e.slice(t,t+a).arrayBuffer());if(r==="index"&&i?.codec==="xocn"&&n>dk){let a=await o(dk),s=m6(a.subarray(0,128));if(s>0&&s<=n)return s<=a.length?a.subarray(0,s):await o(s)}if(r!=="exact"&&i?.codec==="xocn"&&n>fk){let a=await o(fk),s=p6(a.subarray(0,128));if(s>0&&s<=n)return s<=a.length?a.subarray(0,s):await o(s)}return await o(n)}async function hk(e,t,n="coarse"){if(n!=="exact")return Qo(e,t,n);let i=await wq(e,t);return{y:pk(i),w:i.w,h:i.h}}var up=32,bk=8,Qse=(()=>{let e=new Float64Array(bk*up);for(let t=0;t<bk;t++)for(let n=0;n<up;n++)e[t*up+n]=Math.cos((2*n+1)*t*Math.PI/(2*up));return e})();function xq(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,Math.imul(e,16843009)>>>24}var Un=64,gk=(()=>{let e=new Float64Array(16*Un);for(let t=0;t<16;t++)for(let n=0;n<Un;n++)e[t*Un+n]=Math.cos(Math.PI*(t+1)*(2*n+1)/(2*Un));return e})();function fn(e,t){let n=0;for(let i=0;i<8;i++)n+=xq((e.bits[i]^t.bits[i])>>>0);return n}var An=72;function zr(e,t,n){let i=new Float64Array(Un*Un),r=t/Un,o=n/Un;for(let m=0;m<Un;m++)for(let p=0;p<Un;p++){let b=0,h=0,v=p*r|0,g=(p+1)*r|0,y=m*o|0,w=(m+1)*o|0;for(let x=y;x<w;x++){let T=x*t;for(let z=v;z<g;z++)b+=e[T+z],h++}i[m*Un+p]=h?b/h:0}let a=new Float64Array(16*Un);for(let m=0;m<16;m++)for(let p=0;p<Un;p++){let b=0;for(let h=0;h<Un;h++)b+=gk[m*Un+h]*i[h*Un+p];a[m*Un+p]=b}let s=new Float64Array(256);for(let m=0;m<16;m++)for(let p=0;p<16;p++){let b=0;for(let h=0;h<Un;h++)b+=a[m*Un+h]*gk[p*Un+h];s[m*16+p]=b}let c=Array.from(s).sort((m,p)=>m-p),l=(c[127]+c[128])/2,u=new Uint32Array(8);for(let m=0;m<256;m++)s[m]>l&&(u[m>>5]|=1<<(m&31));let f=0;for(let m=0;m<Un;m++)for(let p=0;p<Un-1;p++)f+=Math.abs(i[m*Un+p+1]-i[m*Un+p]);let d=0;for(let m=0;m<Un*Un;m++)d+=i[m];return{bits:u,quality:f,meanY:d/(Un*Un)}}var vk=3,Pq=2,yk=48,Sq=12,kq=28,Tq=16,wk=6,zq=2,Mq=32;function xk(e,t,n,i,r=0,o){let a=new Uint8Array(t),s=z=>{if(!i)return 0;let k=0;for(let S=0;S<z.count;S++)k+=i(z.aStart+S,z.bStart+S);return k},c=[],l=(z,k)=>z.count!==k.count?z.count>k.count:z.td!==k.td?z.td<k.td:z.bStart<k.bStart,u=z=>{let k={...z,td:s(z)};c.push(k);let S=c.length-1;for(;S>0;){let M=S-1>>1;if(l(c[S],c[M]))[c[S],c[M]]=[c[M],c[S]],S=M;else break}},f=()=>{if(c.length===0)return;let z=c[0],k=c.pop();if(c.length){c[0]=k;let S=0;for(;;){let M=2*S+1,L=M+1,P=S;if(M<c.length&&l(c[M],c[P])&&(P=M),L<c.length&&l(c[L],c[P])&&(P=L),P===S)break;[c[S],c[P]]=[c[P],c[S]],S=P}}return z};for(let z of n)u(z);let d=[];for(let z=f();z;z=f()){let k=-1,S=!0,M=[];for(let L=0;L<=z.count;L++)L<z.count&&!a[z.bStart+L]?k<0&&(k=L):(L<z.count&&(S=!1),k>=0&&(M.push({aStart:z.aStart+k,bStart:z.bStart+k,count:L-k}),k=-1));if(S){for(let L=0;L<z.count;L++)a[z.bStart+L]=1;d.push({aStart:z.aStart,bStart:z.bStart,count:z.count})}else for(let L of M)u(L)}d.sort((z,k)=>z.bStart-k.bStart),i&&Oq(e,t,d,i,r,o);let m=[],p=0,b=-1;for(let z of d)z.bStart>p&&m.push({op:"insert",bStart:p,count:z.bStart-p}),m.push({op:z.aStart<b?"move":"equal",aStart:z.aStart,bStart:z.bStart,count:z.count}),b=z.aStart+z.count,p=z.bStart+z.count;p<t&&m.push({op:"insert",bStart:p,count:t-p});let h=new Uint8Array(e);for(let z of d)for(let k=0;k<z.count;k++)h[z.aStart+k]=1;let v=-1,g=0;for(let z=0;z<e;z++)h[z]?g>0&&(m.push({op:"delete",aStart:v,count:g}),g=0):(g===0&&(v=z),g++);g>0&&m.push({op:"delete",aStart:v,count:g});let y=0,w=0,x=0,T=0;for(let z of m)z.op==="equal"?y+=z.count:z.op==="insert"?w+=z.count:z.op==="delete"?x+=z.count:T+=z.count;return{ops:m,equalFrames:y,insertedFrames:w,deletedFrames:x,movedFrames:T,identical:w===0&&x===0&&T===0}}function Oq(e,t,n,i,r,o){let a=(m,p)=>{let b=0;for(let h=0;h<m.count;h++)b+=i(m.bStart+h+p,m.bStart+h);return b},s=m=>m.aStart-m.bStart,c=Math.max(1,Pq*r),l=[];for(let m=0;m<n.length;m++){let p=n[m],b=s(p),h=new Set([b]);for(let P=1;P<=vk;P++)h.add(b-P),h.add(b+P);n[m-1]&&h.add(s(n[m-1])),n[m+1]&&h.add(s(n[m+1]));let v=[...h],g=v.length,y=p.count,w=2147483647,x=(P,X)=>{let R=p.bStart+P+v[X];return R>=0&&R<e?i(R,p.bStart+P):w},T=new Float64Array(g),z=new Float64Array(g),k=new Uint8Array(g*y);for(let P=0;P<g;P++)T[P]=x(0,P);for(let P=1;P<y;P++){let X=0;for(let R=1;R<g;R++)T[R]<T[X]&&(X=R);for(let R=0;R<g;R++){let I=T[R],q=T[X]+c;I<=q?(z[R]=I+x(P,R),k[R*y+P]=R):(z[R]=q+x(P,R),k[R*y+P]=X)}[T,z]=[z,T]}let S=0;for(let P=1;P<g;P++)T[P]<T[S]&&(S=P);let M=new Uint8Array(y);M[y-1]=S;for(let P=y-1;P>0;P--)M[P-1]=k[M[P]*y+P];let L=0;for(let P=1;P<=y;P++)(P===y||v[M[P]]!==v[M[L]])&&(l.push({aStart:p.bStart+L+v[M[L]],bStart:p.bStart+L,count:P-L}),L=P)}n.length=0,n.push(...l),n.sort((m,p)=>m.bStart-p.bStart);for(let m=0;m<n.length;m++){let p=n[m];if(p.count>yk)continue;let b=s(p),h=b,v=a(p,b);for(let g of[n[m-1],n[m+1]]){if(!g)continue;let y=s(g);if(y===b||p.bStart+y<0||p.bStart+p.count+y>e)continue;let w=a(p,y);w<v&&(v=w,h=y)}h!==b&&(p.aStart=p.bStart+h)}for(let m=n.length-1;m>=0;m--){let p=n[m];if(p.count>zq)continue;let b=s(p),h=y=>!!y&&Math.abs(s(y)-b)<=vk;if(h(n[m-1])||h(n[m+1]))continue;let v=0,g=0;for(let y=0;y<p.count;y++){let w=p.aStart+y,x=p.bStart+y;o&&(o.a[w]||o.b[x])||(v++,g+=i(w,x))}(v===0||g/v>Mq)&&n.splice(m,1)}let u=r+Tq,f=(m,p,b,h)=>{let v=m,g=p;if(b){let y=s(b),w=0;for(;w<wk&&v<g&&v+y>=0&&v+y<e&&i(v+y,v)<=u;)b.count++,v++,w++}if(h){let y=s(h),w=0;for(;w<wk&&g>v&&g-1+y>=0&&g-1+y<e&&i(g-1+y,g-1)<=u;)h.aStart--,h.bStart--,h.count++,g--,w++}};n.length&&f(0,n[0].bStart,void 0,n[0]);for(let m=0;m+1<n.length;m++)f(n[m].bStart+n[m].count,n[m+1].bStart,n[m],n[m+1]);if(n.length){let m=n[n.length-1];f(m.bStart+m.count,t,m,void 0)}let d=r+kq;for(let m=0;m+1<n.length;m++){let p=n[m],b=n[m+1],h=s(p);if(s(b)!==h||b.bStart-(p.bStart+p.count)>Sq)continue;let g=!0;for(let y=p.bStart+p.count;y<b.bStart;y++)if(y+h<0||y+h>=e||i(y+h,y)>d){g=!1;break}g&&(p.count=b.bStart+b.count-p.bStart,n.splice(m+1,1),m--)}for(let m=0;m+1<n.length;m++){let p=n[m],b=n[m+1];if(p.bStart+p.count!==b.bStart||Math.min(p.count,b.count)>yk)continue;let h=p.bStart,v=b.bStart+b.count,g=!1;for(let y of[s(p),s(b)]){if(h+y<0||v+y>e)continue;let w=!0;for(let x=h;x<v;x++)if(i(x+y,x)>r){w=!1;break}if(w){p.aStart=h+y,p.count=v-h,n.splice(m+1,1),g=!0;break}}g&&m--}}function Lq(e,t,n){let i=[];for(let r=-(e-1);r<=t-1;r++){let o=0,a=-1,s=Math.max(0,-r),c=Math.min(e,t-r);for(let l=s;l<c;l++)n(l,l+r)?(o===0&&(a=l),o++):(o>0&&i.push({aStart:a,bStart:a+r,count:o}),o=0);o>0&&i.push({aStart:a,bStart:a+r,count:o})}return i}var Xq=4e6,Pk=16,Nq=256,Sk=512;function kk(e,t){let n=e.bits[t>>1]>>>0;return t&1?n>>>16&65535:n&65535}function Rq(e,t,n,i,r,o){let a=e.length,s=t.length,c=new Map;for(let m=0;m<s;m++){if(r?.b[m])continue;let p=t[m];for(let b=0;b<Pk;b++){let h=b*65536+kk(p,b),v=c.get(h);v||(v=[],c.set(h,v)),v.push(m)}}let l=new Map,u=new Int32Array(s).fill(-1);for(let m=0;m<a;m++){if(r?.a[m])continue;let p=e[m],b=0;for(let h=0;h<Pk&&b<Sk;h++){let v=c.get(h*65536+kk(p,h));if(!(!v||v.length>Nq)){for(let g of v)if(u[g]!==m){if(u[g]=m,++b>Sk)break;if(o?o(m,g):fn(p,t[g])<=n){let y=g-m,w=l.get(y);w||(w=[],l.set(y,w)),w.push(m)}}}}}let f=i??((m,p)=>fn(e[m],t[p])),d=[];for(let[m,p]of l){p.sort((h,v)=>h-v);let b=-1;for(let h of p){if(h<=b)continue;let v=h,g=h;for(;v-1>b&&v-1+m>=0&&f(v-1,v-1+m)<=n;)v--;for(;g+1<a&&g+1+m<s&&f(g+1,g+1+m)<=n;)g++;d.push({aStart:v,bStart:v+m,count:g-v+1}),b=g}}return d}var Tk=.0015,zk=.03,Fq=32,Vq=.1;function Mk(e){if(e.length===0)return 0;let t=[...e].sort((n,i)=>n-i);return t[t.length>>1]}function Ok(e,t,n=An,i){let r=e.length,o=t.length,a,s,c,l=()=>!1;if(i?.flatGate&&r>0&&o>0){let b=Mk(e.map(w=>w.quality)),h=Mk(t.map(w=>w.quality));a={a:new Uint8Array(r),b:new Uint8Array(o)},s=new Uint8Array(r),c=new Uint8Array(o);for(let w=0;w<r;w++)a.a[w]=e[w].quality<Tk*b?1:0,s[w]=e[w].quality<zk*b?1:0;for(let w=0;w<o;w++)a.b[w]=t[w].quality<Tk*h?1:0,c[w]=t[w].quality<zk*h?1:0;let v=(w,x)=>{let T=[];for(let S=0;S<w.length;S++)x[S]||T.push(w[S].meanY??0);if(T.length===0)return{med:0,inv:0};T.sort((S,M)=>S-M);let z=T[T.length>>1],k=Math.max(1e-9,T[Math.floor(T.length*.9)]-T[Math.floor(T.length*.1)],.05*Math.max(1,Math.abs(z)));return{med:z,inv:1/k}},g=v(e,a.a),y=v(t,a.b);l=(w,x)=>{let T=((e[w].meanY??0)-g.med)*g.inv,z=((t[x].meanY??0)-y.med)*y.inv;return Math.abs(T-z)<=Vq},(a.a.every(w=>w)||a.b.every(w=>w))&&(a=void 0,s=c=void 0)}let u=a,f=s,d=c,m=u?(b,h)=>{let v=u.a[b],g=u.b[h];return v&&g?l(b,h)?0:256:v||g?256:fn(e[b],t[h])}:(b,h)=>fn(e[b],t[h]),p=(b,h)=>u&&(u.a[b]||u.b[h])?!1:fn(e[b],t[h])<=(f&&d&&(f[b]||d[h])?Fq:n);if(r===0||o===0||r*o<=Xq){let b=Lq(r,o,(h,v)=>m(h,v)<=n);return u&&(b=b.filter(h=>{for(let v=0;v<h.count;v++)if(p(h.aStart+v,h.bStart+v))return!0;return!1})),xk(r,o,b,m,n,a)}return xk(r,o,Rq(e,t,n,m,a,p),m,n,a)}function Lk(e){let t=e.ops.map(n=>n.op==="equal"?` = A[${n.aStart}..${n.aStart+n.count-1}] = B[${n.bStart}..${n.bStart+n.count-1}] (${n.count} unchanged)`:n.op==="delete"?` - A[${n.aStart}..${n.aStart+n.count-1}] removed (${n.count})`:n.op==="insert"?` + B[${n.bStart}..${n.bStart+n.count-1}] new/changed (${n.count})`:` ~ A[${n.aStart}..${n.aStart+n.count-1}] moved -> B[${n.bStart}..${n.bStart+n.count-1}] (${n.count})`);return[`${e.equalFrames} unchanged, ${e.insertedFrames} new, ${e.deletedFrames} removed, ${e.movedFrames} moved`+(e.identical?" (identical)":""),...t].join(`
7
+ `)}var cf=class{constructor(t,n,i=100){this.channels=t;this.sampleRate=n;this.hz=i;this.counted=0;this.binSamples=Math.max(1,Math.round(n/i)),this.sums=new Float64Array(t),this.bins=Array.from({length:t},()=>[])}push(t){let n=this.channels,i=Math.floor(t.length/n);for(let r=0;r<i;r++){let o=r*n;for(let a=0;a<n;a++){let s=t[o+a];this.sums[a]+=s*s}++this.counted===this.binSamples&&this.flush()}}flush(){for(let t=0;t<this.channels;t++)this.bins[t].push(Math.sqrt(this.sums[t]/this.counted)),this.sums[t]=0;this.counted=0}finish(){return this.counted>0&&this.flush(),this.bins.map(t=>Float32Array.from(t))}};var Xk=48e3*30;function Xs(e){return(t,n)=>e.slice(t,t+n).arrayBuffer().then(i=>new Uint8Array(i))}var jq=async e=>{let t=globalThis.OfflineAudioContext;if(!t)return null;let i=await new t(1,1,48e3).decodeAudioData(await e.arrayBuffer()),r=new Float32Array(i.length);for(let o=0;o<i.numberOfChannels;o++){let a=i.getChannelData(o);for(let s=0;s<a.length;s++)r[s]+=a[s]/i.numberOfChannels}return{sampleRate:i.sampleRate,channels:1,chunks:(async function*(){yield r})()}},Nk=jq;function Rk(e){Nk=e}async function Zq(e){let t=await Nk(e).catch(()=>null);if(!t)return null;let n=new cf(t.channels,t.sampleRate,100),i=0;for await(let r of t.chunks)n.push(r),i+=r.length/t.channels;return i?{sampleRate:t.sampleRate,channels:t.channels,sampleFrames:i,durationSec:i/t.sampleRate,envelopes:n.finish(),codec:"platform"}:null}async function fp(e){await ni();let t=Xs(e),n=await Ra(t,e.size),i=JSON.parse(n);if(!i||i.aac)return Zq(e);let r=i.sample_rate??0,o=i.channels??0,a=i.sample_frames??0;if(!r||!o||!a)return null;let s=new cf(o,r,100);for(let c=0;c<a;c+=Xk){let l=Math.min(Xk,a-c),u=await Fa(t,e.size,c,l);if(!u||u.length<12)break;let f=new DataView(u.buffer,u.byteOffset,u.byteLength),d=f.getUint32(8,!0),m=f.getUint32(4,!0);if(!d||!m)break;let p=u.byteOffset+12,b=p%4===0?new Float32Array(u.buffer,p,d*m):new Float32Array(u.slice(12).buffer,0,d*m);s.push(b)}return{sampleRate:r,channels:o,sampleFrames:a,durationSec:a/r,envelopes:s.finish(),codec:i.codec}}var Wv=10,Vk=.5,Wq=.5,Dq=.15;function qq(e){let t=e.envelopes;if(t.length===0)return new Float32Array(0);if(t.length===1)return t[0];let n=Math.max(...t.map(r=>r.length)),i=new Float32Array(n);for(let r of t)for(let o=0;o<r.length;o++)r[o]>i[o]&&(i[o]=r[o]);return i}function Dv(e,t){if(!e||!t)return null;let n=qq(e);return n.length?{curve:n,fps:t}:null}function Hq(e,t,n,i,r,o=Math.round(Vk*100)){let a=Math.max(0,-t,-i),s=t+a,c=i+a,l=Math.min(r-a,e.length-s,n.length-c);if(l<o)return null;let u=0,f=0;for(let g=0;g<l;g++)u+=e[s+g],f+=n[c+g];let d=u/l,m=f/l,p=0,b=0,h=0;for(let g=0;g<l;g++){let y=e[s+g]-d,w=n[c+g]-m;p+=y*w,b+=y*y,h+=w*w}if(b<=0||h<=0)return null;let v=p/Math.sqrt(b*h);return Number.isFinite(v)?v:null}function Eq(e,t,n){let i=0,r=Math.min(e.length,t+n);for(let o=Math.max(0,t);o<r;o++)e[o]>i&&(i=e[o]);return i}var Fk=(e,t)=>Math.round(e/t*100);function jk(e,t,n={}){let i=n.decides??Wq,r=n.margin??Dq,o=Math.round((n.minSpanSec??Vk)*100),a=y=>t.map(()=>({score:null,outcome:"abstained",reason:y}));if(!e)return a("the reference carries no audio we can read");if(t.length<2)return a("nothing to arbitrate");let s=Math.max(...t.map(y=>y.refStart)),l=Math.min(...t.map(y=>y.refEnd))-s+1,u=Fk(s,e.fps),f=Fk(l,e.fps);if(f<o)return a(`disputed span is ${(l/e.fps).toFixed(2)}s \u2014 too short to decide by sound`);if(Eq(e.curve,u,f)<1e-4)return a("the reference is silent across this span");let d=t.map(y=>{if(!y.track)return null;let w=y.srcStart/y.track.fps+(s-y.refStart)/e.fps;return Hq(e.curve,u,y.track.curve,Math.round(w*100),f,o)}),m=d.filter(y=>y!==null);if(m.length<2)return t.map((y,w)=>({score:d[w],outcome:"abstained",reason:m.length===0?"no contender's audio could be scored across this span":"only one contender has readable audio \u2014 nothing to compare it against"}));let p=[...m].sort((y,w)=>w-y),b=p[0],h=p[1];if(b<i)return t.map((y,w)=>({score:d[w],outcome:"abstained",reason:`best correlation ${b.toFixed(2)} is below ${i} \u2014 none of these sound like the reference here`}));if(b-h<r)return t.map((y,w)=>({score:d[w],outcome:"abstained",reason:`${b.toFixed(2)} vs ${h.toFixed(2)} \u2014 an audio tie as well as a picture tie`}));let v=d.findIndex(y=>y===b),g=t[v].label;return t.map((y,w)=>({score:d[w],outcome:w===v?"won":"rejected",preferredLabel:g}))}var Cq=.5;function Uq(e,t){let n=Math.max(e.refStart,t.refStart),r=Math.min(e.refEnd,t.refEnd)-n+1;if(r<=0)return!1;let o=Math.min(e.refEnd-e.refStart+1,t.refEnd-t.refStart+1);return r/o>=Cq}function Zk(e,t=Wv){let n=e.length,i=Array.from({length:n},(s,c)=>c),r=s=>{for(;i[s]!==s;)i[s]=i[i[s]],s=i[s];return s},o=!1;for(let s=0;s<n;s++)for(let c=s+1;c<n;c++){let l=e[s],u=e[c];l.clipLabel!==u.clipLabel&&(l.score==null||u.score==null||Math.abs(l.score-u.score)>t||Uq(l,u)&&(i[r(s)]=r(c),o=!0))}if(!o)return[];let a=new Map;for(let s=0;s<n;s++){let c=r(s),l=a.get(c);l?l.push(e[s]):a.set(c,[e[s]])}return[...a.values()].filter(s=>s.length>1)}var Ik=240;function Wk(e,t,n,i=Ik){let r=Math.max(1,Math.ceil(Math.max(t,n)/i));if(r===1)return{w:t,h:n,rgba:e};let o=Math.max(1,Math.floor(t/r)),a=Math.max(1,Math.floor(n/r)),s=new Uint8ClampedArray(o*a*4);for(let c=0,l=0;c<a;c++){let u=c*r*t;for(let f=0;f<o;f++,l+=4){let d=(u+f*r)*4;s[l]=e[d],s[l+1]=e[d+1],s[l+2]=e[d+2],s[l+3]=255}}return{w:o,h:a,rgba:s}}async function Aq(e,t,n,i){await sf();let r=new Map;for(let o of n){let a=t.offs[o];if(!a)continue;let s=new Uint8Array(await e.slice(a.offset,a.offset+a.size).arrayBuffer()),c=lk(s),l=Wk(c.rgba,c.width,c.height,i);r.set(o,{frame:o,...l})}return r}async function Gq(e,t,n,i){let r=new Set(n),o=new Map,a=null,s=null;return await Ms(e,t.offs,(c,l)=>{if(!r.has(l))return;let u=c.visibleRect,f=u?u.width:c.codedWidth,d=u?u.height:c.codedHeight,m=Math.min(1,i/Math.max(f,d)),p=Math.max(1,Math.round(f*m)),b=Math.max(1,Math.round(d*m));(!a||a.width!==p||a.height!==b)&&(a=new OffscreenCanvas(p,b),s=a.getContext("2d",{willReadFrequently:!0})),s&&(s.drawImage(c,0,0,p,b),o.set(l,{frame:l,w:p,h:b,rgba:s.getImageData(0,0,p,b).data}))},{wantPres:r}),o}async function Jq(e,t,n,i){let r=Rv(t.kind,t.w,t.h),o=new Map;if(!r)return o;await sf();for(let a of n){let s=t.offs[a];if(s)try{let c=new Uint8Array(await e.slice(s.offset,s.offset+s.size).arrayBuffer()),l=Qo(c,r),u=1/0,f=-1/0;for(let b=0;b<l.y.length;b++){let h=l.y[b];h<u&&(u=h),h>f&&(f=h)}let d=f>u?f-u:1,m=new Uint8ClampedArray(l.w*l.h*4);for(let b=0,h=0;b<l.y.length;b++,h+=4){let v=(l.y[b]-u)/d*255;m[h]=v,m[h+1]=v,m[h+2]=v,m[h+3]=255}let p=Wk(m,l.w,l.h,i);o.set(a,{frame:a,...p})}catch{}}return o}async function Dk(e,t,n,i=Ik){if(n.length===0)return new Map;if(t.kind==="prores")return Aq(e,t,n,i);if(t.kind==="h264"||t.kind==="hevc")return Gq(e,t,n,i);if(Rv(t.kind,t.w,t.h))return Jq(e,t,n,i);throw new Error(`unsupported codec "${t.codec}" for frame thumbnails`)}function dp(e,t,n,i=255){let r=e instanceof Int32Array?-13110.4:i*.1,o=Math.floor(n*.45),a=Math.floor(t*.45),s=m=>{let p=0,b=m*t;for(let h=0;h<t;h++)e[b+h]<=r&&p++;return p>=t*.95},c=m=>{let p=0;for(let b=0;b<n;b++)e[b*t+m]<=r&&p++;return p>=n*.95},l=0;for(;l<o&&s(l);)l++;let u=0;for(;u<o&&s(n-1-u);)u++;let f=0;for(;f<a&&c(f);)f++;let d=0;for(;d<a&&c(t-1-d);)d++;return{top:l,bottom:u,left:f,right:d}}function Gc(e,t=255){if(e.length===0)return null;let{w:n,h:i}=e[0];return qv(e.map(r=>dp(r.luma,r.w,r.h,t)),n,i)}function qv(e,t,n){if(e.length===0)return null;let i=(l,u)=>{let f=Math.floor(u*.02),d=e.filter(m=>m[l]>f);return d.length<e.length*.8?0:Math.min(...d.map(m=>m[l]))},r=i("top",n),o=i("bottom",n),a=i("left",t),s=i("right",t);if(r+o+a+s===0)return null;let c={x:a,y:r,w:t-a-s,h:n-r-o};return c.w<t*.3||c.h<n*.3?null:c}function Za(e,t,n,i=255){let r=dp(e,t,n,i),o=Math.floor(n*.02),a=Math.floor(t*.02),s=r.top>o?r.top:0,c=r.bottom>o?r.bottom:0,l=r.left>a?r.left:0,u=r.right>a?r.right:0;if(s+c+l+u===0)return null;let f={x:l,y:s,w:t-l-u,h:n-s-c};return f.w<t*.3||f.h<n*.3?null:f}function Ia(e,t,n,i){let r=i&&i.length>=n.w*n.h?i:new Float64Array(n.w*n.h);for(let o=0;o<n.h;o++){let a=(n.y+o)*t+n.x,s=o*n.w;for(let c=0;c<n.w;c++)r[s+c]=e[a+c]}return r}function Wa(e,t=16){if(e<=0)return[];let n=Math.min(t,e);if(n===1)return[e>>1];let i=[];for(let r=0;r<n;r++)i.push(Math.min(e-1,Math.floor((r+.5)*e/n)));return[...new Set(i)]}function mp(e,t,n){return{x0:e.x/t,y0:e.y/n,x1:(e.x+e.w)/t,y1:(e.y+e.h)/n}}function qk(e,t,n){let i=Math.max(0,Math.min(t-1,Math.round(e.x0*t))),r=Math.max(0,Math.min(n-1,Math.round(e.y0*n))),o=Math.max(i+1,Math.min(t,Math.round(e.x1*t))),a=Math.max(r+1,Math.min(n,Math.round(e.y1*n))),s={x:i,y:r,w:o-i,h:a-r};return s.w<8||s.h<8||s.w===t&&s.h===n?null:s}function Hk(e,t,n){if(!e)return null;let i=Math.round(e.y),r=Math.round(n-e.h-e.y),o=Math.round(e.x),a=Math.round(t-e.w-e.x),s=[];return(i||r)&&s.push(`letterboxed ${i===r?`${i} px top and bottom`:`${i} px top, ${r} px bottom`}`),(o||a)&&s.push(`pillarboxed ${o===a?`${o} px each side`:`${o} px left, ${a} px right`}`),s.length?s.join(", "):null}var Bq=256,Yq=120;async function Ek(e,t,n={}){let i=[],r=0,o=null,a=null,s=await Ms(e,t,(u,f)=>{let d=u.visibleRect,m=d?.width??u.codedWidth,p=d?.height??u.codedHeight,b=n.crop==="per-frame"?void 0:n.crop,h=(d?.x??0)+(b?b.x0*m:0),v=(d?.y??0)+(b?b.y0*p:0),g=b?Math.max(1,Math.round((b.x1-b.x0)*m)):m,y=b?Math.max(1,Math.round((b.y1-b.y0)*p)):p,w=Math.min(1,Bq/Math.max(g,y)),x=Math.max(1,Math.round(g*w)),T=Math.max(1,Math.round(y*w));if((!o||o.width!==x||o.height!==T)&&(o=new OffscreenCanvas(x,T),a=o.getContext("2d",{willReadFrequently:!0})),a){a.drawImage(u,h,v,g,y,0,0,x,T);let z=a.getImageData(0,0,x,T),k=z.data,S=new Float64Array(x*T);for(let L=0,P=0;L<S.length;L++,P+=4)S[L]=.2126*k[P]+.7152*k[P+1]+.0722*k[P+2];if(f>=0){let L=n.crop==="per-frame"?Za(S,x,T):null;i[f]=L?zr(Ia(S,x,L),L.w,L.h):zr(S,x,T)}let M=typeof performance<"u"?performance.now():Date.now();n.onThumb&&M-r>Yq&&(r=M,n.onThumb({idx:f,w:x,h:T,rgba:z.data}))}n.onTick?.()},{signal:n.signal}),c={bits:new Uint32Array(8),quality:0},l=new Array(s);for(let u=0;u<s;u++)l[u]=i[u]??c;return l}function Kq(e,t,n,i,r,o,a={codec:"prores"}){let s=Math.max(1,Math.min(navigator.hardwareConcurrency||4,16)),c=t.map((f,d)=>({idx:d,offset:f.offset,size:f.size})),l=new Array(t.length),u=Array.from({length:s},()=>[]);return c.forEach((f,d)=>u[d%s].push(f)),new Promise((f,d)=>{let m=s,p=[],b=()=>{for(let v of p)v.terminate();r?.removeEventListener("abort",h)};function h(){b(),d(new DOMException("aborted","AbortError"))}if(r?.aborted){h();return}r?.addEventListener("abort",h,{once:!0});for(let v=0;v<s;v++){if(u[v].length===0){m--;continue}let g=new Worker(new URL("./workers/qc-worker.ts",import.meta.url),{type:"module"});p.push(g),g.onmessage=y=>{let w=y.data;if(w.progress)for(let x=0;x<w.progress;x++)n();if(w.thumb&&i&&i(w.thumb),w.results){for(let x of w.results)l[x.idx]={bits:Uint32Array.from(x.bits),quality:x.q??0,meanY:x.my};--m===0&&(b(),f(l))}},g.onerror=y=>{b(),d(new Error(`worker error: ${y.message}`))},g.postMessage({file:e,jobs:u[v],crop:o,spec:a})}m===0&&(b(),f(l))})}async function Qq(e,t){try{let n=Wa(t.offs.length,12);if(n.length===0)return;let i=await Dk(e,t,n,320),r=[];for(let a of i.values()){let s=new Uint8Array(a.w*a.h);for(let c=0,l=0;c<s.length;c++,l+=4)s[c]=a.rgba[l]*77+a.rgba[l+1]*150+a.rgba[l+2]*29>>8;r.push({luma:s,w:a.w,h:a.h})}if(r.length===0)return;let o=Gc(r);return o?mp(o,r[0].w,r[0].h):void 0}catch{return}}function _q(e){return{codec:e.codec,kind:e.kind,label:ko(e.kind),w:e.w,h:e.h,fps:e.fps,frames:e.offs.length,startFrame:e.startFrame,dropFrame:e.dropFrame}}async function Uk(e,t={}){if(!(e instanceof File))throw new Error("fingerprintFile expects a File input");let n=await gn(e),i={offs:n.frames,codec:n.index?.codec??n.label,kind:n.spec?$q(n.spec):n.index?.kind??"other",w:n.w,h:n.h,fps:n.fps,startFrame:n.startFrame,dropFrame:n.dropFrame};if(!n.spec&&!n.index)throw new Error(`${e.name}: ${n.warnings[0]??"no decoder for this clip"} \u2014 QC handles ProRes / H.264 / HEVC in .mov/.mp4 and R3D / ARRIRAW / X-OCN / BRAW / ProRes RAW camera originals`);let r=Math.max(1,Math.floor(t.stride??1)),o=r===1?i.offs:i.offs.filter((f,d)=>d%r===0),a=o.length,s=0,c=()=>t.onProgress?.(++s,a),l=t.matte==="cut"?"per-frame":n.spec===null||n.spec.codec==="prores"?await Qq(e,i):void 0,u=n.spec?await Kq(e,o,c,Ck(t),t.signal,l,n.spec):await Ek(e,o,{onTick:c,onThumb:Ck(t),signal:t.signal,crop:l});return{meta:_q(i),index:i,pdq:u,matte:l==="per-frame"?void 0:l,stride:r}}function $q(e){return e?e.codec:"other"}function Ck(e){let t=e.side??"A",n=e.onThumb;return n?i=>n({side:t,...i}):void 0}function pp(e,t){if(e.stride!==t.stride)throw new Error(`fingerprint stride mismatch: reference ${e.stride}, candidate ${t.stride} \u2014 both sides of a comparison must be sampled on the same grid`);let n=eH(e.meta.fps,t.meta.fps),i=n===1?t.pdq:tH(t.pdq,n),r=Ok(e.pdq,i,An,{flatGate:!0}),o=[];return Lv(e.meta.fps,t.meta.fps)&&o.push(`${sp(t.meta.fps)} fps against a ${sp(e.meta.fps)} fps reference \u2014 resampled to the reference's timebase for matching, and its source in/out points are converted back to its own rate. Verify the in-points.`),{report:r,a:e.meta,b:t.meta,warnings:o,aPdq:e.pdq,bPdq:i,rateScale:n}}function eH(e,t){return!e||!t||e<=0||t<=0||Math.abs(e-t)<.001?1:t/e}function tH(e,t){if(!Number.isFinite(t)||t<=0||t===1)return e;let n=[],i=Math.ceil(e.length/t);for(let r=0;r<i;r++){let o=Math.min(e.length-1,Math.round(r*t));n.push(e[o])}return n}var lf=8;function Gk(e,t){return async n=>{let i=t.frames[n];if(!i||!t.spec)return null;try{let r=await ja(e,i.offset,i.size,t.spec),o=Qo(r,t.spec);return zr(o.y,o.w,o.h)}catch{return null}}}function Ak(e){let t=new Map;return n=>{let i=t.get(n);return i||(i=e(n),t.set(n,i)),i}}async function nH(e,t,n,i){let{stride:r,threshold:o,refFrames:a,srcFrames:s}=i,c=e.srcStart-e.refStart,l=async m=>{let p=m+c;if(m<0||m>=a||p<0||p>=s)return!1;let[b,h]=await Promise.all([t(m),n(p)]);return!!b&&!!h&&fn(b,h)<=o},u=e.refStart;for(let m=1;m<=r&&await l(e.refStart-m);m++)u=e.refStart-m;let f=e.refStart+e.count-1,d=f;for(let m=1;m<=r&&await l(f+m);m++)d=f+m;return{refStart:u,srcStart:u+c,count:d-u+1}}async function Jk(e,t,n,i){if(i.stride<=1||e.length===0)return e;let r=Ak(t),o=Ak(n),a=[];for(let s of e)a.push(await nH(s,r,o,i));return a}function Jc(e,t){let n=Math.round(e);return t&&(n===30||n===60)}var Bk=e=>e===60?4:2;function hp(e,t){let n=e.match(/^(\d+):(\d+):(\d+)([:;])(\d+)$/);if(!n)return null;let i=+n[1],r=+n[2],o=+n[3],a=+n[5],s=n[4]===";",c=Math.round(t)||24,l=(i*3600+r*60+o)*c+a;if(Jc(t,s)){let u=Bk(c),f=i*60+r;l-=u*(f-Math.floor(f/10))}return{frames:l,drop:s}}function zi(e,t,n=!1){let i=Math.round(t)||24,r=Math.max(0,Math.round(e)),o=Jc(t,n),a=o?";":":";if(o){let d=Bk(i),m=i*60-d,p=i*600-d*9,b=Math.floor(r/p),h=r%p;r+=h>d?d*9*b+d*Math.floor((h-d)/m):d*9*b}let s=r%i,c=Math.floor(r/i)%60,l=Math.floor(r/(i*60))%60,u=Math.floor(r/(i*3600))%24,f=d=>String(d).padStart(2,"0");return`${f(u)}:${f(l)}:${f(c)}${a}${f(s)}`}var rH=typeof process<"u"&&!!process.env?.CONFORM_PROFILE,Hv=new Map;async function Gn(e,t){if(!rH)return t();let n=performance.now();try{return await t()}finally{let i=Hv.get(e)??{n:0,ms:0};i.n++,i.ms+=performance.now()-n,Hv.set(e,i)}}function Yk(){return[...Hv].sort((e,t)=>t[1].ms-e[1].ms).map(([e,t])=>`[profile] ${e.padEnd(22)} ${String(t.n).padStart(7)} \xD7 ${(t.ms/t.n).toFixed(1).padStart(7)} ms = ${(t.ms/1e3).toFixed(1).padStart(7)} s`).join(`
8
+ `)}var iH=1/0;var oH=256;function aH(e){let[t,n,i,r,o,a,s,c,l]=e,u=t*(o*l-a*c)-n*(r*l-a*s)+i*(r*c-o*s);return u?[(o*l-a*c)/u,(i*c-n*l)/u,(n*a-i*o)/u,(a*s-r*l)/u,(t*l-i*s)/u,(i*r-t*a)/u,(r*c-o*s)/u,(n*s-t*c)/u,(t*o-n*r)/u]:[1,0,0,0,1,0,0,0,1]}function sH(e,t,n,i,r,o,a){let s=aH(a),c=Math.max(1,Math.round(Math.max(r,o)/oH)),l=[],u=[],f=0;for(let h=0;h<o;h+=c)for(let v=0;v<r;v+=c){f++;let g=s[6]*v+s[7]*h+s[8];if(!g)continue;let y=(s[0]*v+s[1]*h+s[2])/g,w=(s[3]*v+s[4]*h+s[5])/g;y<0||w<0||y>t-1||w>n-1||(l.push(e[Math.round(w)*t+Math.round(y)]),u.push(i[h*r+v]))}if(l.length<f*.2)return 1/0;let d=h=>{let v=0;for(let y of h)v+=y;v/=h.length;let g=0;for(let y of h)g+=(y-v)**2;return{m:v,s:Math.sqrt(g/h.length)||1}},m=d(l),p=d(u),b=0;for(let h=0;h<l.length;h++)b+=Math.abs((l[h]-m.m)/m.s-(u[h]-p.m)/p.s);return b/l.length*42}var Ev=null;function Kk(e){Ev=e}async function Br(e,t,n,i,r,o,a={}){let{maxResidual:s=iH,...c}=a,l;return Ev?l=await Gn("orb",()=>Ev(e,t,n,i,r,o,JSON.stringify(c))):(await Hc(),l=JSON.parse(u6(e,t,n,i,r,o,JSON.stringify(c)))),Object.assign(l,{srcW:t,srcH:n,refW:r,refH:o}),l.ok&&(l.residual=sH(e,t,n,i,r,o,l.transform),(!Number.isFinite(l.residual)||l.residual>s)&&(l.ok=!1,l.residualRejected=!0)),l}function Bc(e,t,n,i){if(!n||!i||!(e>0)||!(t>0))return{w:e,h:t};let r=Math.min(e/n,t/i);return{w:n*r,h:i*r}}function bp(e){let t=e.filter(a=>a.reframe!==null);if(e.length===0||t.length<2||t.length/e.length<.5)return{kind:"unresolved",keyframes:[],label:"unresolved \u2014 reframe not recoverable"};let n=a=>{let s=t.map(a);return Math.max(...s)-Math.min(...s)};if(!(n(a=>a.reframe.scale)>.05||n(a=>a.reframe.dxCenter)>12||n(a=>a.reframe.dyCenter)>12||n(a=>a.reframe.rotationDeg)>1)){let a=t[t.length>>1];return{kind:"static",keyframes:[a],label:a.reframe.label}}let r=t[0].reframe,o=t[t.length-1].reframe;return{kind:"animated",keyframes:t,label:`animated \xB7 ${r.label} \u2192 ${o.label}`}}var cH=.04,lH=.02;function Qk(e){let t=e.length;if(t<2)return{slope:1,percent:100,kind:"normal",samples:t,residual:0};let n=0,i=0;for(let d of e)n+=d.refStart,i+=d.srcStart;let r=n/t,o=i/t,a=0,s=0;for(let d of e){let m=d.refStart-r;a+=m*(d.srcStart-o),s+=m*m}if(s<=1e-9)return{slope:1,percent:100,kind:"normal",samples:t,residual:0};let c=a/s,l=o-c*r,u=0;for(let d of e)u+=Math.abs(d.srcStart-(c*d.refStart+l));let f=Math.abs(c)<lH?"freeze":Math.abs(c-1)>cH?"retime":"normal";return{slope:c,percent:c*100,kind:f,samples:t,residual:u/t}}function _k(e,t){let n=c=>c.score==null?1/0:c.score,i=t.flatMap(c=>c.shots.map(l=>({...l,clipLabel:c.label}))).filter(c=>c.audio?.outcome!=="rejected").filter(c=>!(c.track.kind==="unresolved"&&c.score!=null&&c.score>uH)).sort((c,l)=>n(c)-n(l)||l.refEnd-l.refStart-(c.refEnd-c.refStart)||c.refStart-l.refStart||(c.clipLabel<l.clipLabel?-1:c.clipLabel>l.clipLabel?1:0)),r=t.flatMap(c=>c.shots.map(l=>({...l,clipLabel:c.label}))),o=new Int32Array(Math.max(0,e)).fill(-1);i.forEach((c,l)=>{for(let u=Math.max(0,c.refStart);u<=Math.min(e-1,c.refEnd);u++)o[u]<0&&(o[u]=l)});let a=[],s=(c,l)=>{let u=a[a.length-1];u?.kind==="gap"&&u.refEnd===c-1?u.refEnd=l:a.push({refStart:c,refEnd:l,kind:"gap"})};for(let c=0;c<e;){let l=o[c],u=c;for(;u+1<e&&o[u+1]===l;)u++;if(l<0){s(c,u),c=u+1;continue}let f=i[l],d=c!==f.refStart||u!==f.refEnd;if(d&&u-c+1<fH){s(c,u),c=u+1;continue}let m=f.refEnd>f.refStart?(f.srcEnd-f.srcStart)/(f.refEnd-f.refStart):1;a.push({refStart:c,refEnd:u,kind:f.track.kind,clipLabel:f.clipLabel,srcStart:d?Math.round(f.srcStart+(c-f.refStart)*m):f.srcStart,srcEnd:d?Math.round(f.srcStart+(u-f.refStart)*m):f.srcEnd,track:f.track,inPointAmbiguity:f.vote?.ambiguity,contest:dH(f,r)}),c=u+1}return a}var uH=32,fH=3;function dH(e,t){if(e.score==null)return;let n=t.filter(r=>r.clipLabel!==e.clipLabel&&r.score!=null&&r.refStart<=e.refEnd&&r.refEnd>=e.refStart&&Math.abs(r.score-e.score)<=Wv).sort((r,o)=>(r.score??1/0)-(o.score??1/0));if(n.length===0)return;let i=e.audio?.outcome!=null||n.some(r=>r.audio?.outcome!=null)?"audio":n.every(r=>r.score>e.score)?"score":n.some(r=>r.score===e.score&&r.refEnd-r.refStart===e.refEnd-e.refStart)?"label":"length";return{rivals:n.map(r=>({clipLabel:r.clipLabel,score:r.score})),winnerScore:e.score,settledBy:i}}function gp(e,t){let n=[...new Set(t)].sort((r,o)=>r-o);if(n.length===0)return e;let i=[];for(let r of e){let o=n.filter(l=>l>r.refStart&&l<=r.refEnd);if(o.length===0){i.push(r);continue}let a=[r.refStart,...o,r.refEnd+1],s=r.refEnd-r.refStart,c=r.srcStart!=null&&r.srcEnd!=null&&s>0?(r.srcEnd-r.srcStart)/s:1;for(let l=0;l<a.length-1;l++){let u=a[l],f=a[l+1]-1;f<u||i.push({...r,refStart:u,refEnd:f,srcStart:r.srcStart==null?void 0:r.srcStart+Math.round((u-r.refStart)*c),srcEnd:r.srcStart==null?void 0:r.srcStart+Math.round((f-r.refStart)*c)})}}return i}var $k=180/Math.PI;function _o(e,t=2){let n=10**t;return Math.round(e*n)/n+0}function mH(e,t,n,i=t,r=n){let o=Math.min(t/i,n/r)||1,a=e[0]/o,s=e[1]/o,c=e[3]/o,l=e[4]/o,u=Math.hypot(a,c),f=a*l-s*c,d=u>1e-9?Math.abs(f/u):0,m=Math.sqrt(Math.abs(f)),p=Math.atan2(c,a)*$k,b=i/2,h=r/2,v=e[6]*b+e[7]*h+e[8],g=(e[0]*b+e[1]*h+e[2])/v,y=(e[3]*b+e[4]*h+e[5])/v,w=g-t/2,x=y-n/2,T=Math.abs(e[6])>1e-6||Math.abs(e[7])>1e-6;return{scale:_o(m,3),scaleX:_o(u,3),scaleY:_o(d,3),rotationDeg:_o(p,2),dxCenter:_o(w,1),dyCenter:_o(x,1),perspective:T,label:pH(m,p,w,x,T)}}function $o(e,t,n){return mH(e.transform,t,n,e.srcW??t,e.srcH??n)}function e8(e,t,n,i,r){let o=Math.min(i/t,r/n),a=e.rotationDeg/$k,s=Math.cos(a),c=Math.sin(a),l=e.scaleX*o,u=e.scaleY*o,f=l*s,d=-u*c,m=l*c,p=u*s,b=t/2,h=n/2,v=i/2+e.dxCenter-(f*b+d*h),g=r/2+e.dyCenter-(m*b+p*h);return[f,d,v,m,p,g,0,0,1]}function pH(e,t,n,i,r){let o=[];if(e>=1.01?o.push(`punch-in ${_o(e,2)}\xD7`):e<=.99&&o.push(`pull-out ${_o(e,2)}\xD7`),Math.abs(n)>=1||Math.abs(i)>=1){let a=n>=0?`+${Math.round(n)}`:`${Math.round(n)}`,s=i>=0?`+${Math.round(i)}`:`${Math.round(i)}`;o.push(`shift ${a},${s}px`)}return Math.abs(t)>=.1&&o.push(`rot ${_o(t,1)}\xB0`),r&&o.push("keystone"),o.length?o.join(" \xB7 "):"1:1 (no reframe)"}function Cv(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let i=e[n]>>2;t[n]=i>255?255:i}return t}function hH(e=typeof navigator<"u"?navigator.deviceMemory:void 0){let t=e&&e>0?e:8;return Math.max(64e6,Math.min(1e9,Math.floor(t*1024*1024*1024*.12)))}function Uv(e){return e==null?64:e.y.byteLength+64}function t8(e=hH()){let t=new Map,n=0,i=0,r=0,o=0,a=0,s=0,c=l=>{for(let u of t.keys()){if(n<=l)break;let f=t.get(u);t.delete(u),n-=Uv(f??null),a++}};return{get(l){if(!t.has(l)){o++;return}let u=t.get(l)??null;return t.delete(l),t.set(l,u),r++,u},set(l,u){if(t.has(l)){let d=t.get(l)??null;t.delete(l),n-=Uv(d)}let f=Uv(u);if(f>e){s++;return}t.set(l,u),n+=f,c(e),n>i&&(i=n)},stats:()=>({hits:r,misses:o,evictions:a,oversized:s,bytes:n,peakBytes:i,size:t.size,budgetBytes:e}),clear(){t.clear(),n=0}}}var Av=.6,bH=9,gH=4;function vH(e){let[t,n,i,r,o,a,s,c,l]=e,u=o*l-a*c,f=-(r*l-a*s),d=r*c-o*s,m=t*u+n*f+i*d;if(!Number.isFinite(m)||Math.abs(m)<1e-12)return null;let p=1/m;return[u*p,(i*c-n*l)*p,(n*a-i*o)*p,f*p,(t*l-i*s)*p,(i*r-t*a)*p,d*p,(n*s-t*c)*p,(t*o-n*r)*p]}function Gv(e,t,n,i){let r=vH(t);if(!r)return null;let o=new Float64Array(n*i),a=e.w-1,s=e.h-1,c=0;for(let l=0;l<i;l++)for(let u=0;u<n;u++){let f=r[6]*u+r[7]*l+r[8];if(Math.abs(f)<1e-12)continue;let d=(r[0]*u+r[1]*l+r[2])/f,m=(r[3]*u+r[4]*l+r[5])/f;d>=0&&d<=a&&m>=0&&m<=s&&c++;let p=d<0?0:d>a?a:d,b=m<0?0:m>s?s:m,h=Math.floor(p),v=Math.floor(b),g=h<a?h+1:h,y=v<s?v+1:v,w=p-h,x=b-v,T=e.y,z=v*e.w,k=y*e.w,S=T[z+h]+(T[z+g]-T[z+h])*w,M=T[k+h]+(T[k+g]-T[k+h])*w;o[l*n+u]=S+(M-S)*x}return{luma:o,coverage:c/(n*i)}}var yH=new WeakMap,wH=new WeakMap,xH=new WeakMap;function Jv(e,t,n){let i=e.get(t.y);return i===void 0&&(i=n(),e.set(t.y,i)),i}function i8(e,t,n,i){let r=Gv(e,t,n,i);return!r||r.coverage<Av?null:zr(r.luma,n,i)}function vp(e){return Jv(yH,e,()=>PH(e))}function PH(e){let t=new Float64Array(e.y.length);for(let n=0;n<t.length;n++)t[n]=e.y[n];return zr(t,e.w,e.h)}function n8(e){return Jv(wH,e,()=>SH(e))}function SH(e){let t=new Float64Array(e.y.length);for(let i=0;i<t.length;i++)t[i]=e.y[i];let n=Za(t,e.w,e.h);return n?zr(Ia(t,e.w,n),n.w,n.h):zr(t,e.w,e.h)}function uf(e,t,n){let i=Gv(t,n,e.w,e.h),r=!!i&&i.coverage>=Av,o=r?fn(vp(e),zr(i.luma,e.w,e.h)):1/0;return Math.min(o,fn(n8(e),n8(t)),r?o8(e,i.luma):1/0)}var r8=[[0,0,.5,1],[.5,0,.5,1],[0,0,1,.5],[0,.5,1,.5]],kH=32;function TH(e,t,n){let i=Gv(t,n,e.w,e.h);return!i||i.coverage<Av?1/0:o8(e,i.luma)}function o8(e,t){let n=(o,[a,s,c,l])=>{let u=Math.floor(a*e.w),f=Math.floor(s*e.h),d=Math.floor(c*e.w),m=Math.floor(l*e.h),p=new Float64Array(d*m);for(let b=0;b<m;b++)for(let h=0;h<d;h++)p[b*d+h]=o[(f+b)*e.w+u+h];return zr(p,d,m)},i=Jv(xH,e,()=>r8.map(o=>n(e.y,o))),r=1/0;return r8.forEach((o,a)=>{r=Math.min(r,fn(i[a],n(t,o)))}),r}async function ff(e,t,n,i,r,o){if(e.score<=o)return!0;let[a,s]=await Promise.all([n(r),i(e.srcFrame)]);return!!a&&!!s&&TH(a,s,t)<=kH}function zH(e,t,n,i,r){let o=c=>e-t+c>=0&&e+t+c<n,a=[];o(0)&&a.push(0);let s=Math.max(1,Math.round(i));for(let c=1;a.length<r&&c*s<n;c++)for(let l of[-c*s,c*s])a.length<r&&o(l)&&a.push(l);return a.length?a:[0]}var Yc=4;async function Kc(e){let t=e.probes??bH,n=zH(e.srcProbe,e.search,e.frameCount,e.runSpread??0,e.runSamples??1),i=new Map,r=new Map,o=0,a=async m=>(i.has(m)||i.set(m,await e.refLuma(m)),i.get(m)??null),s=async(m,p)=>{let b=m*1e3+p.length;if(r.has(b))return r.get(b)??null;let h=0,v=0;for(let y of p){let w=e.srcProbe+m+y;if(w<0||w>=e.frameCount)continue;let[x,T]=await Promise.all([a(e.refProbe+y),e.candLuma(w)]);if(!x||!T)continue;o++;let z=uf(x,T,e.transform);Number.isFinite(z)&&(h+=z,v++)}let g=v===p.length?h/v:null;return r.set(b,g),g},c=-e.search,l=e.search,u=null,f=1,d=!1;for(;;){let m=Math.max(1,Math.round((l-c)/(t-1))),p=m<=gH?n:[n[0]??0],b=null,h=[];for(let v=c;v<=l;v+=m){let g=await s(v,p);g!=null&&(h.push(g),(!b||g<b.score||g===b.score&&Math.abs(v)<Math.abs(b.d))&&(b={d:v,score:g}))}if(!b)return null;if(u=b,m===1){let v=h.filter(g=>g<=b.score+Yc).length;d=h.length>1&&v===h.length,f=Math.max(1,v);break}c=Math.max(-e.search,b.d-m),l=Math.min(e.search,b.d+m)}return u?{srcFrame:e.srcProbe+u.d,score:u.score,decodes:o,ambiguousFrames:f,flat:d}:null}var MH=3;async function a8(e){let t=await e.refLuma(e.refProbe);if(!t)return null;let n=vp(t),i=Math.max(1,Math.floor(e.stride)),r=0,o=[];for(let l=0;l<e.frameCount;l+=i){let u=await e.candLuma(l);if(!u)continue;r++;let f=uf(t,u,e.transform);Number.isFinite(f)&&o.push({s:l,d:f})}if(!o.length)return null;o.sort((l,u)=>l.d-u.d);let a=null;for(let l of o.slice(0,MH)){let u=await Kc({transform:e.transform,refLuma:e.refLuma,candLuma:e.candLuma,refProbe:e.refProbe,srcProbe:l.s,frameCount:e.frameCount,runSpread:e.runSpread,runSamples:e.runSamples,probes:e.probes,search:i});u&&(!a||u.score<a.score)&&(a=u)}if(!a)return null;let s=Math.min(...o.map(l=>l.d)),c=o.filter(l=>l.d<=s+Yc).length;return{...a,decodes:r+a.decodes,ambiguousFrames:Math.max(a.ambiguousFrames,c*i)}}function Bv(e,t){if(!t?.length)return e;let n=0,i=t.length-1;for(;n<i;){let a=n+i>>1;t[a]<e?n=a+1:i=a}let r=t[n],o=n>0?t[n-1]:r;return Math.abs(o-e)<=Math.abs(r-e)?o:r}var OH=3,Ns=12,LH=256,XH=(e,t,n)=>t<=1?n>>1:Math.round(e*(n-1)/(t-1));function c8(e,t,n,i,r){let o=Math.floor(t*e.w),a=Math.floor(n*e.h),s=Math.floor(i*e.w),c=Math.floor(r*e.h),l=new Uint8Array(s*c);for(let u=0;u<c;u++){let f=(a+u)*e.w+o,d=u*s;for(let m=0;m<s;m++)l[d+m]=e.y[f+m]}return{y:l,w:s,h:c}}var s8=8,NH=3,RH=[[0,0,.5,1],[.5,0,.5,1],[0,0,1,.5],[0,.5,1,.5]];function FH(e,t,n){return[e[0]+t*e[6],e[1]+t*e[7],e[2]+t*e[8],e[3]+n*e[6],e[4]+n*e[7],e[5]+n*e[8],e[6],e[7],e[8]]}function Qc(e,t,n){return e.ok||e.inliers>=t&&e.inlierRatio>=n}function VH(e){let t=e.filter(r=>r.dist!=null);if(!t.length)return e.sort((r,o)=>o.res.inliers-r.res.inliers);t.sort((r,o)=>r.dist-o.dist);let n=t[0].dist;return[...t.filter(r=>r.dist<=n+Yc/2).sort((r,o)=>o.res.inliers-r.res.inliers),...t.filter(r=>r.dist>n+Yc/2)]}async function jH(e,t,n,i,r,o,a,s){let c=e.map(f=>f?vp(f):null),l=e.map(()=>[]),u=e.map((f,d)=>f?d:-1).filter(f=>f>=0);if(!u.length)return l;for(let f=0;f<t.length;f++){let d=t[f];if(s?.aborted)throw new DOMException("Auto Conform cancelled","AbortError");a?.(f,t.length);let m=Math.min(n,Math.max(1,d.frameCount)),p=m>1?(d.frameCount-1)/(m-1):d.frameCount,b=-1;for(let h=0;h<m;h++){let v=Math.min(d.frameCount-1,Bv(XH(h,m,d.frameCount),d.keyframes));if(v===b)continue;b=v;let g=await d.luma(v);if(g)for(let y of u){let w=e[y],x=await Br(g.y,g.w,g.h,w.y,w.w,w.h,i);if(!Qc(x,r,o))continue;let T=i8(g,x.transform,w.w,w.h);l[y].push({cand:d,srcFrame:v,res:x,dist:T?fn(c[y],T):null,spacing:p})}}}return l.map(VH)}var Yv=[[{x:0,y:0,w:.5,h:1},{x:.5,y:0,w:.5,h:1}],[{x:0,y:0,w:1,h:.5},{x:0,y:.5,w:1,h:.5}]],ZH=Yv.reduce((e,t)=>e+t.length,0),IH=1+ZH;function WH(e,t,n){let i=null,r=0,o=0;for(let a of Yv){let s=[];for(let c of a){let l=n[o],u=e[t+1+o][0];o++,!(!l||!u)&&s.push({rect:c,clipLabel:u.cand.label,reframe:$o(u.res,l.w,l.h),inliers:u.res.inliers})}if(s.length===a.length&&new Set(s.map(c=>c.clipLabel)).size===s.length){let c=Math.min(...s.map(l=>l.inliers));c>r&&(r=c,i=s)}}return i}async function l8(e,t,n,i={}){let{signal:r,searchSamples:o=24,trackSamples:a=3,composite:s=!0,minRetrievalInliers:c=25,minRetrievalRatio:l=.03,refine:u=!0,escalationStride:f=lf,onProgress:d,onPhase:m,...p}=i,b=M=>(M.kind==="gap"||M.kind==="unresolved")&&M.nothingSimilar==null,h=e.filter(b),v=h.length,g=[],y=0,w=h.map(M=>M.refStart+M.refEnd>>1),x=[];for(let M of w)x.push(await t(M));let T=[],z=[];for(let M of x){T.push(M);let L=[];for(let P of Yv)for(let X of P){let R=M&&s?c8(M,X.x,X.y,X.w,X.h):null;L.push(R),T.push(R)}z.push(L)}m?.("retrieval");let k=await jH(T,n,o,p,c,l,(M,L)=>d?.(Math.floor(M/Math.max(1,L)*v),v),r),S=new Map(h.map((M,L)=>[M,L]));m?.("placing");for(let M of e){if(!b(M)){g.push(M);continue}d?.(y++,v);let L=M.refEnd-M.refStart+1,P=S.get(M),X=w[P],R=x[P];if(!R){g.push(M);continue}let I=P*IH,q=k[I],Y=s?WH(k,I,z[P]):null;if(Y){g.push({refStart:M.refStart,refEnd:M.refEnd,kind:"composite",regions:Y});continue}if(!q.length){g.push(M);continue}let D=u?q.slice(0,OH):q.slice(0,1),j=q[0],C=null;for(let we of D){if(!u)break;let De=await Kc({transform:we.res.transform,refLuma:t,candLuma:Je=>we.cand.luma(Je),refProbe:X,srcProbe:we.srcFrame,frameCount:we.cand.frameCount,runSpread:(we.cand.rate??1)===1?Math.max(1,Math.floor(L/3)):0,runSamples:(we.cand.rate??1)===1?3:1,search:Math.ceil(we.spacing)});De&&(!C||De.score<C.score)&&(C=De,j=we)}if(u){let we=await a8({transform:j.res.transform,refLuma:t,candLuma:De=>j.cand.luma(De),refProbe:X,frameCount:j.cand.frameCount,stride:Math.max(f,Math.ceil(j.cand.frameCount/LH)),runSpread:(j.cand.rate??1)===1?Math.max(1,Math.floor(L/3)):0,runSamples:(j.cand.rate??1)===1?3:1});we&&(!C||we.score<C.score)?C=we:we&&C&&(C={...C,ambiguousFrames:Math.max(C.ambiguousFrames,we.ambiguousFrames)})}let H=C?.srcFrame??j.srcFrame,ne=C?.score??j.dist,le=j.res.transform;if(C&&C.srcFrame!==j.srcFrame&&ne!=null&&ne>Ns){let[we,De]=await Promise.all([t(X),j.cand.luma(C.srcFrame)]),Je=we&&De?await Br(De.y,De.w,De.h,we.y,we.w,we.h,p):null;Je&&Qc(Je,c,l)&&(le=Je.transform)}if(ne!=null&&ne>Ns&&!(C&&await ff(C,le,t,we=>j.cand.luma(we),X,Ns))){g.push(M);continue}let Se=j.cand.rate??1,Le=[];for(let we=0;we<a;we++){let De=a<=1?X:M.refStart+Math.round(we*(L-1)/(a-1)),Je=H+Math.round((De-X)*Se),[be,Me]=await Promise.all([t(De),Je>=0&&Je<j.cand.frameCount?j.cand.luma(Je):Promise.resolve(null)]);if(be&&Me){let Oe=await Br(Me.y,Me.w,Me.h,be.y,be.w,be.h,p);Le.push({refFrame:De,reframe:Oe.ok?$o(Oe,be.w,be.h):null})}else Le.push({refFrame:De,reframe:null})}let ut=bp(Le);if(ut.kind==="unresolved"){let we=$o(j.res,R.w,R.h);ut={kind:"static",keyframes:[{refFrame:X,reframe:we}],label:we.label}}g.push({refStart:M.refStart,refEnd:M.refEnd,kind:ut.kind,clipLabel:j.cand.label,srcStart:H-Math.round((X-M.refStart)*Se),srcEnd:H+Math.round((M.refEnd-X)*Se),track:ut,score:C?.score??j.dist??void 0,inPointAmbiguity:C?.ambiguousFrames})}return d?.(v,v),g}async function df(e){let{minInliers:t=25,minRatio:n=.03}=e,i=await e.refLuma(e.refProbe);if(!i)return null;let r=null,o=0,a=[];for(let l=-e.radius;l<=e.radius;l++){let u=e.srcGuess+l;u>=0&&u<e.cand.frameCount&&a.push(u)}let s=await Promise.all(a.map(async l=>{let u=await e.cand.luma(l);return u?{sf:l,res:await Br(u.y,u.w,u.h,i.y,i.w,i.h,e.reframeOpts)}:null}));for(let l of s)l&&(o=Math.max(o,l.res.inliers),Qc(l.res,t,n)&&(!r||l.res.inliers>r.res.inliers)&&(r=l));if(!r&&o>=s8){let l=s.filter(d=>!!d&&d.res.inliers>=s8).sort((d,m)=>m.res.inliers-d.res.inliers).slice(0,NH),u=new Set;for(let d of l)for(let m of[-1,0,1])d.sf+m>=0&&d.sf+m<e.cand.frameCount&&u.add(d.sf+m);let f=[...u].sort((d,m)=>d-m);for(let[d,m,p,b]of RH){let h=c8(i,d,m,p,b),v=Math.floor(d*i.w),g=Math.floor(m*i.h),y=await Promise.all(f.map(async w=>{let x=await e.cand.luma(w);return x?{sf:w,res:await Br(x.y,x.w,x.h,h.y,h.w,h.h,e.reframeOpts)}:null}));for(let w of y)!w||!Qc(w.res,t,n)||(!r||w.res.inliers>r.res.inliers)&&(r={sf:w.sf,res:{...w.res,transform:FH(w.res.transform,v,g)}})}}if(!r)return null;let c=await Kc({transform:r.res.transform,refLuma:e.refLuma,candLuma:l=>e.cand.luma(l),refProbe:e.refProbe,srcProbe:r.sf,frameCount:e.cand.frameCount,search:4,runSpread:e.runSpread,runSamples:e.runSpread>0?3:1});if(!c)return null;if(c.srcFrame!==r.sf){let l=await e.cand.luma(c.srcFrame),u=l?await Br(l.y,l.w,l.h,i.y,i.w,i.h,e.reframeOpts):null;u&&Qc(u,t,n)&&(r={sf:c.srcFrame,res:u})}if(!await ff(c,r.res.transform,e.refLuma,l=>e.cand.luma(l),e.refProbe,Ns))return null;if(c.srcFrame!==e.srcGuess&&e.srcGuess>=0&&e.srcGuess<e.cand.frameCount){let l=await e.cand.luma(e.srcGuess),u=await e.cand.luma(c.srcFrame);if(l&&u){let f=d=>uf(i,d,r.res.transform);f(u)>f(l)-Yc&&(c.srcFrame=e.srcGuess)}}return{srcAtProbe:c.srcFrame,transform:r.res.transform,srcW:r.res.srcW,srcH:r.res.srcH,score:c.score,ambiguity:c.ambiguousFrames,refPlane:i}}async function u8(e){let t=e.refEnd-e.refStart+1;if(t<8)return null;let n=e.cand.rate??1,i=e.refStart+e.refEnd>>1,r=await e.refLuma(i);if(!r)return null;let o=null,a=0,s=await Promise.all(Array.from({length:9},async(q,Y)=>{let D=e.srcAt(i)+Y-4;if(D<0||D>=e.cand.frameCount)return null;let j=await e.cand.luma(D);return j?Br(j.y,j.w,j.h,r.y,r.w,r.h,e.reframeOpts):null}));for(let q of s)q&&Qc(q,25,.03)&&q.inliers>a&&(o=q.transform,a=q.inliers);if(!o)return null;let c=o,l=5,u=Math.min(3,Math.floor(t/8)),f=Array.from({length:l},(q,Y)=>Math.round(e.refStart+u+Y*(t-1-2*u)/(l-1))),d=new Map;for(let q of f)d.set(q,await e.refLuma(q));let m=new Map,p=(q,Y)=>{let D=`${q}:${Y}`,j=m.get(D);return j||(j=(async()=>{let C=d.get(q);if(!C||Y<0||Y>=e.cand.frameCount)return 1/0;let H=await e.cand.luma(Y);return H?uf(C,H,c):1/0})(),m.set(D,j)),j},b=async(q,Y,D)=>await Promise.all(q.flatMap(j=>Array.from({length:17},async(C,H)=>{let ne=H-8,le=await Promise.all(f.map(Se=>Y(Se,Math.round(g+ne+(Se-i)*j))));return{slope:j,delta:ne,mean:D*le.reduce((Se,Le)=>Se+Le,0)/l}}))),h=(e.srcAt(e.refEnd)-e.srcAt(e.refStart))/Math.max(1,t-1),v=[...new Set([1,n,h].map(q=>Math.round(q*1e3)/1e3))],g=e.srcAt(i),y=await b(v,p,1);y.sort((q,Y)=>q.mean-Y.mean);let w=y[0];if(!Number.isFinite(w.mean)||w.mean>Ns*3)return null;let x=2,T=y.find(q=>q.slope!==w.slope);if(T&&T.mean-w.mean<x){let q=new Map,D=await b(v,(H,ne)=>{let le=`${H}:${ne}`,Se=q.get(le);return Se||(Se=(async()=>{let Le=d.get(H);if(!Le||ne<0||ne>=e.cand.frameCount)return 0;let ut=await e.cand.luma(ne);return ut?(await Br(ut.y,ut.w,ut.h,Le.y,Le.w,Le.h,e.reframeOpts)).inliers:0})(),q.set(le,Se)),Se},-1);D.sort((H,ne)=>H.mean-ne.mean);let j=D[0],C=D.find(H=>H.slope!==j.slope);if(j.mean<-25&&(!C||C.mean-j.mean>=.05*-j.mean))return{srcAtStart:g+j.delta-(i-e.refStart)*j.slope,slope:j.slope,model:Math.abs(j.slope-n)<.001?"real-time":Math.abs(j.slope-1)<.001?"frame-for-frame":"retime",anchors:f.map(H=>({ref:H,src:Math.round(g+j.delta+(H-i)*j.slope),ambiguity:0}))};w=y[0]}let z=y.find(q=>q.slope!==w.slope),k=!z||z.mean-w.mean>=x,S=v.find(q=>Math.abs(q-h)<.001)??h,M=k?w.slope:S,L=y.filter(q=>q.slope===M),P=L[0],X=L.find(q=>Math.abs(q.delta-P.delta)>1),R=X&&X.mean-P.mean<x/2?0:P.delta;if(!k&&R===0)return null;let I=Math.abs(M-n)<.001?"real-time":Math.abs(M-1)<.001?"frame-for-frame":"retime";return{srcAtStart:g+R-(i-e.refStart)*M,slope:M,model:I,anchors:f.map(q=>({ref:q,src:Math.round(g+R+(q-i)*M),ambiguity:0}))}}function yp(e,t){let n=[...e].sort((i,r)=>i[0]-r[0]);if(t<=n[0][0])return n[0][1];for(let i=1;i<n.length;i++)if(t<=n[i][0])return n[i-1][1]+(n[i][1]-n[i-1][1])*(t-n[i-1][0])/Math.max(1e-9,n[i][0]-n[i-1][0]);return n[n.length-1][1]}function mf(e,t,n,i,r,o,a=0){let s=e.map(([h,v])=>[h,v*r/i]),c=[0,...s.map(h=>h[0]).filter(h=>h>1e-9&&h<t-1e-9),t].filter((h,v,g)=>g.indexOf(h)===v).sort((h,v)=>h-v),l=c.map(h=>yp(s,h)/100),u=n/r,f=c.map(h=>u+h/i),d=[u];for(let h=1;h<c.length;h++)d.push(d[h-1]+(l[h-1]+l[h])*.5*(c[h]-c[h-1])/r);let m=h=>l[h]*i/r,p=[],b=(h,v,g)=>p.push({id:`${o}-${p.length}`,parameter_path:"speed",time:{value:h,rate:i},value:v,interp:"bezier",tangent_in:null,tangent_out:null,order_index:p.length,raw_extraction:g});if(u>1e-9){let h=u/3;b(0,0,{drtNativeTangent:[0,0,h,h,0,0],speedPreRoll:!0})}for(let h=0;h<c.length;h++){let v=[0,0,0,0,0,0];if(h>0){let y=(f[h]-f[h-1])/3;v[0]=-y,v[1]=-m(h)*y}else if(u>1e-9){let y=u/3;v[0]=-y,v[1]=-y}if(h+1<c.length){let y=(f[h+1]-f[h])/3;v[2]=y,v[3]=m(h)*y}let g=s.find(y=>Math.abs(y[0]-c[h])<1e-9);b(f[h],d[h],g?{drtNativeTangent:v,speedGraphPoint:[c[h],g[1]]}:{drtNativeTangent:v,speedGraphPoint:[c[h],l[h]*100],speedGraphSynth:!0})}return{keyframes:p,sourceFrames:(d[d.length-1]-u)*r}}function Kv(e){if(!e||!Number.isFinite(e)||e<=0)return{num:24,den:1};for(let t of[24,30,60,120])if(Math.abs(e-t*1e3/1001)<.01)return{num:t*1e3,den:1001};return Math.abs(e-Math.round(e))<1e-6?{num:Math.round(e),den:1}:{num:Math.round(e*1e3),den:1e3}}function Qv(e,t,n=!1){let i=Math.max(1,Math.round(t)),r=Math.max(0,Math.round(e)),o=a=>String(a).padStart(2,"0");if(n&&(i===30||i===60)){let a=i===60?4:2,s=i*60-a,c=s*10+a,l=Math.floor(r/c),u=r%c;r=l*i*600+(u<=a?u:u+a*Math.floor((u-a)/s))}return`${o(Math.floor(r/(i*3600))%24)}:${o(Math.floor(r/(i*60))%60)}:${o(Math.floor(r/i)%60)}${n?";":":"}${o(r%i)}`}var pf=(e,t)=>`conform-${e}-${t}`,DH=4,qH="1",HH=.025,EH=.005,CH=.5,UH=.001,AH=.5,GH=.05;function JH(e,t,n){let i=e.measuredBy==="sizing";if(e.flipH||e.flipV)return!1;let r=i?UH:HH,o=i?GH:CH,a=(s,c)=>!c||(i?Math.abs(s)<AH:Math.abs(s/c)<EH);return Math.abs(e.scaleX-1)<r&&Math.abs(e.scaleY-1)<r&&Math.abs(e.rotationDeg)<o&&a(e.dxCenter,t)&&a(e.dyCenter,n)&&!e.perspective}function BH(e,t,n,i){e.scale=t.scale*100,Math.abs(t.scaleX-t.scaleY)>.001&&(e.scale_x=t.scaleX*100,e.scale_y=t.scaleY*100),n>0&&(e.position_x=t.dxCenter/n),i>0&&(e.position_y=t.dyCenter/i),Math.abs(t.rotationDeg)>.001&&(e.rotation=t.rotationDeg);let r=e;t.flipH&&(r.flip_horizontal=!0),t.flipV&&(r.flip_vertical=!0)}function f8(e,t,n,i,r){let o=Bc(t,n,i,r),a=(e.scale??100)/100,s={scaleX:(e.scale_x??e.scale??100)/100,scaleY:(e.scale_y??e.scale??100)/100,rotationDeg:e.rotation??0,dxCenter:(e.position_x??0)*o.w,dyCenter:(e.position_y??0)*o.h};return Math.abs(a-1)<1e-6&&Math.abs(s.scaleX-1)<1e-6&&Math.abs(s.scaleY-1)<1e-6&&Math.abs(s.rotationDeg)<1e-6&&Math.abs(s.dxCenter)<1e-6&&Math.abs(s.dyCenter)<1e-6?null:s}function YH(e,t,n,i,r,o,a){let s=[],c=n.srcStart??0,l=0;for(let u of t.keyframes){let f=u.refFrame-n.refStart,d=n.srcEnd!=null&&n.refEnd>n.refStart?(n.srcEnd-c)/(n.refEnd-n.refStart):i/(r||i),p={value:c+f*d,rate:i},b=(h,v)=>{s.push({id:`${e}-kf-${l++}`,parameter_path:h,time:p,value:v})};b("scale",u.reframe.scale*100),o>0&&b("position.x",u.reframe.dxCenter/o),a>0&&b("position.y",u.reframe.dyCenter/a),Math.abs(u.reframe.rotationDeg)>.001&&b("rotation",u.reframe.rotationDeg)}return s}function d8(e,t={}){let n=[],i=e.refFps??24,r=Kv(i),o=new Map(e.clips.map(y=>[y.label,y])),a=new Set(e.timeline.filter(y=>y.kind!=="gap"&&y.clipLabel).map(y=>y.clipLabel)),s=[],c=new Map;for(let y of e.clips){if(!a.has(y.label))continue;let w=pf("media",y.clipIndex);c.set(y.label,w);let x=y.srcFps??i;s.push({id:w,kind:"external",content_kind:"video",target_url:y.label,display_name:y.label.replace(/\.[^.]+$/,""),source_fps:x,source_timecode:Qv(y.srcStartFrame,x,y.srcDropFrame??!1),available_range:{start:{value:0,rate:x},duration:{value:y.srcFrames,rate:x}},source_resolution_w:y.srcW??null,source_resolution_h:y.srcH??null,reel_name:null,raw_extraction:{},metadata:{codec:y.codec}}),y.srcFps&&e.refFps&&Math.abs(y.srcFps-e.refFps)>.01&&n.push({kind:"rate",message:`${y.label} is ${y.srcFps.toFixed(3)} fps against a ${e.refFps.toFixed(3)} fps reference. The cut is written at the reference rate with source ranges in the clip's own rate, but the MATCH was made frame-index to frame-index \u2014 check this clip's in-points before trusting them.`});for(let T of y.warnings)n.push({kind:"rate",message:`${y.label}: ${T}`})}let l=[],u=0,f=0,d=0,m=0,p=0,b=[];for(let y of e.timeline){if(y.kind==="gap"||!y.clipLabel||y.srcStart==null||y.srcStart>=0){b.push(y);continue}let w=o.get(y.clipLabel),x=y.srcEnd!=null&&y.refEnd>y.refStart?(y.srcEnd-y.srcStart)/(y.refEnd-y.refStart):(w?.srcFps??i)/(i||1),T=x>0?Math.ceil(-y.srcStart/x-1e-9):y.refEnd-y.refStart+1;if(T>y.refEnd-y.refStart){b.push({...y,kind:"gap",clipLabel:void 0});continue}n.push({kind:"source-range",refStart:y.refStart,refEnd:y.refStart+T-1,message:`${y.clipLabel}: placed from source frame ${y.srcStart}, before the clip's first frame \u2014 the first ${T} frame(s) are left empty and the clip starts at frame 0. Usually a speed or frame-rate conform (e.g. 25 fps played frame-for-frame); check the shot's timing.`}),b.push({kind:"gap",refStart:y.refStart,refEnd:y.refStart+T-1}),b.push({...y,refStart:y.refStart+T,srcStart:y.srcStart+T*x})}for(let y of b){let w=y.refEnd-y.refStart+1;if(y.kind==="gap"||!y.clipLabel){f+=w,n.push({kind:"gap",refStart:y.refStart,refEnd:y.refEnd,message:`${w} frame(s) with no matching source \u2014 left empty on the timeline.`+(y.nothingSimilar!=null?` Nothing in the media you supplied resembles these frames (best similarity ${y.nothingSimilar.toFixed(2)}) \u2014 stock, graphics, or media that was not in the bucket.`:"")+(y.unconfirmed?` Best guess: ${y.unconfirmed.clipLabel} from source frame ${y.unconfirmed.srcFrame}, but the picture did not confirm it (${y.unconfirmed.why??"often graphics or stock that resembles a camera shot"}) \u2014 check it by eye if a shot is expected here.`:"")});continue}y.kind==="composite"&&n.push({kind:"composite",refStart:y.refStart,refEnd:y.refEnd,message:`split-screen / composite of ${y.regions?.length??0} sources \u2014 emitted as the first region only; rebuild the layout by hand.`});let x=o.get(y.clipLabel),T=c.get(y.clipLabel);if(!x||!T)continue;let z=x.srcFps??i,k=y.speed&&y.speed.kind==="retime"?y.speed.percent/100:1,S=(i>0?w*(z/i):w)*k,M=y.srcStart??0;y.takeRival&&n.push({kind:"contested",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel} or ${y.takeRival.clipLabel}? Two takes of one setup explain this shot almost equally (shot-sizing agreement ${y.takeRival.winnerAgreement.toFixed(2)} vs ${y.takeRival.agreement.toFixed(2)}). Conformed from ${y.clipLabel} \u2014 check the take against the offline.`}),y.contest?.settledBy==="label"&&n.push({kind:"contested",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel} and ${y.contest.rivals.map(R=>R.clipLabel).join(", ")} explain these frames equally well (tied at ${y.contest.winnerScore?.toFixed(1)??"\u2014"} bits). Conformed from ${y.clipLabel} because it sorts first by name \u2014 verify the source timecode.`});let L=pf("item",p),P={id:L,kind:"clip",item_index:p++,name:y.clipLabel,enabled:!0,timeline_range:{start:{value:y.refStart,rate:i},duration:{value:w,rate:i}},source_range:{start:{value:M,rate:z},duration:{value:S,rate:z}},media_reference_id:T,raw_extraction:{},metadata:{}},X=y.track;if(X&&X.kind!=="unresolved"&&X.keyframes.length>0&&!(X.kind==="static"&&JH(X.keyframes[X.keyframes.length>>1].reframe,e.refW,e.refH))){let R=X.keyframes[X.keyframes.length>>1],I=Bc(e.refW,e.refH,x.srcW,x.srcH);BH(P,R.reframe,I.w,I.h),d++,X.kind==="animated"&&(m++,P.keyframes=YH(L,{keyframes:X.keyframes},y,z,i,I.w,I.h),n.push({kind:"reframe",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel}: animated reframe (${X.keyframes.length} keys: ${X.label}) \u2014 measured, not declared; check the move against the reference.`}))}else X?.kind==="unresolved"&&n.push({kind:"unresolved",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel}: placed, but its reframe could not be recovered${X.label&&!X.label.startsWith("unresolved")?` (${X.label})`:""} \u2014 the clip is full-frame on the timeline and may need resizing.`});if(y.ramp&&y.ramp.length>=2){let R=mf(y.ramp,w,M,i,z,`${L}-spd`);P.source_range={start:P.source_range.start,duration:{value:Math.max(1,Math.ceil(R.sourceFrames)+1),rate:z}},P.speed_ramped=!0,P.speed=Math.round(100*R.sourceFrames/w*(i/z)*100)/100;let I=P.keyframes??[];P.keyframes=[...I,...R.keyframes.map((q,Y)=>({...q,order_index:I.length+Y}))],n.push({kind:"retime",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel}: SPEED RAMP read from the picture \u2014 ${y.ramp.map(([q,Y])=>`${Y.toFixed(0)}%@${Math.round(q)}`).join(" \u2192 ")}. Check the ramp against the reference.`})}y.speed&&y.speed.kind!=="normal"&&(P.speed=y.speed.percent,P.speed_ramped=!1,n.push({kind:"retime",refStart:y.refStart,refEnd:y.refEnd,message:y.speed.kind==="freeze"?`${y.clipLabel}: FREEZE FRAME \u2014 the source holds on one frame across ${w} reference frame(s). Emitted at 0% speed; a host may want an explicit freeze instead.`:y.speed.basis==="frame-for-frame"?`${y.clipLabel}: plays FRAME FOR FRAME \u2014 one source frame per record frame, ${y.speed.percent.toFixed(1)}% of real time \u2014 measured from the picture at ${y.speed.samples} points. Usually the edit's rate-conform setting, not a retime.`:y.speed.basis==="convention"?`${y.clipLabel}: emitted at ${y.speed.percent.toFixed(1)}% to match the cut's other shots at this frame rate \u2014 this shot's own picture could not tell real time from frame-for-frame. Check its motion against the reference.`:`${y.clipLabel}: retimed to ${y.speed.percent.toFixed(1)}% (fitted over ${y.speed.samples} runs, residual ${y.speed.residual.toFixed(1)} frames). A speed RAMP would not fit one slope \u2014 check it if the residual is high.`})),y.inPointAmbiguity!=null&&y.inPointAmbiguity>=DH?n.push({kind:"ambiguous",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel}: in-point uncertain \u2014 ${y.inPointAmbiguity} source frames match this shot equally well (the picture barely changes), so its source timecode may be out by up to \xB1${Math.ceil(y.inPointAmbiguity/2)} frames. Check it against the offline.`}):y.inPointUnconfirmed&&n.push({kind:"ambiguous",refStart:y.refStart,refEnd:y.refEnd,message:`${y.clipLabel}: in-point not confirmed \u2014 ${y.takeRival?"and the take itself is contested (see the red marker); ":"the take is right, but "}nothing in the shot (motion, difference mode) pinned the exact frame, so its source timecode may be off. Check it against the offline.`}),l.push(P),u++}let h={id:pf("track",1),kind:"Video",track_index:1,name:"V1",enabled:!0,items:l,source_element_id:null,raw_extraction:{},metadata:{}},v={id:pf("timeline",1),name:t.name??t.referenceName??"Auto-Conform",kind:"primary",timeline_index:0,fps_num:r.num,fps_den:r.den,resolution_w:e.refW||null,resolution_h:e.refH||null,start_frame:e.refStartFrame,is_drop_frame:e.refDropFrame,duration_frames:e.refFrames,tracks:[h],markers:[],source_element_id:null,raw_extraction:{},metadata:{}};return{session:{projects:[{id:pf("project",1),user_id:"",created_at:"",source_format:"auto-conform",source_filename:t.referenceName??null,source_file_sha256:null,source_file_bytes:null,parser_name:"conform-session",parser_version:qH,status:"ready",error_message:null,metadata:{}}],timelines:[v],media_references:s,source_format:"auto-conform",source_filename:t.referenceName??null},issues:n,stats:{placed:u,gapFrames:f,reframed:d,animated:m}}}var KH=16,QH=1.5,_H=10;function $H(e,t={}){let n=t.sigmas??QH,i=Math.max(1,t.minShotFrames??_H),r=t.minCutBits??KH,o=e.length;if(o<2*i)return[];let a=new Float64Array(o-1);for(let m=1;m<o;m++)a[m-1]=fn(e[m-1],e[m]);let s=0;for(let m of a)s+=m;let c=s/a.length,l=0;for(let m of a)l+=(m-c)**2;let u=Math.sqrt(l/a.length),f=Math.max(c+n*u,r),d=[];for(let m=0;m<a.length;m++){if(a[m]<=f)continue;let p=m+1;p<i||o-p<i||d.length&&p-d[d.length-1]<i||d.push(p)}return d}var eE=4;function p8(e,t,n,i=eE){let r=e[t];if(!r||n<=t)return!1;for(let o=t+1;o<=n;o++){let a=e[o];if(!a||fn(r,a)>i)return!1}return!0}function tE(e,t){if(e<=0)return[];let n=[0,...t.filter(r=>r>0&&r<e),e],i=[];for(let r=0;r<n.length-1;r++)n[r+1]-n[r]>0&&i.push({start:n[r],end:n[r+1]-1});return i}var nE=1e3,rE=8;function iE(e,t){if(!e||!t)return 1/0;let n=0,i=Math.min(e.length,t.length);for(let r=0;r<i;r++)n+=e[r]*t[r];return(1-n)*nE}function h8(e,t,n,i){let r=i.embedding;return r?{d:(o,a,s)=>iE(r.ref[o],a.embed?.[s]),len:o=>o.embed?.length??0,threshold:r.threshold??1/0,tau:r.tau??n}:{d:(o,a,s)=>{let c=e[o],l=a.pdq[s];return c&&l?fn(c,l):1/0},len:o=>o.pdq.length,threshold:t,tau:n}}var b8=42,g8=.42,v8=8,y8=.1,w8=.25,x8=3,P8=.9,oE=512;function aE(e,t,n,i,r,o,a){let s=[],c=new Map,l=0,u=0,f=!1;for(let d=n;d<=i;d++){if(d<0||d>=e)continue;let m=S8(d,t,r,o,a);if(m.length!==0){m.length>=o&&(f=!0),l++,s.push({f:d,picks:m});for(let p of m)c.set(p.clipIndex,(c.get(p.clipIndex)??0)+p.weight),u+=p.weight}}return{frames:s,votingFrames:l,truncated:f,massByClip:c,totalMass:u}}function sE(e,t,n,i,r,o,a,s,c){let{bins:l,base:u}=c;l.fill(0);let f=1/0,d=-1/0;for(let w of e.frames){let x=w.f-n;for(let T of w.picks){if(T.clipIndex!==t)continue;let z=Math.round(T.frame-i*x)-u;z<0||z>=l.length||(l[z]+=T.weight,z<f&&(f=z),z>d&&(d=z))}}if(f>d)return null;let m=-1,p=f,b=Math.max(0,f),h=Math.min(l.length-1,d);for(let w=b;w<=h;w++){if(l[w]<=0)continue;let x=0,T=Math.max(0,w-r),z=Math.min(l.length-1,w+r);for(let k=T;k<=z;k++)l[k]<=0||(x+=l[k]*(1-Math.abs(k-w)/(r+1)));x>m&&(m=x,p=w)}if(m<=0)return null;let v=0,g=0;for(let w=b;w<=h;w++){if(l[w]<=0)continue;Math.abs(w-p)<=o&&(v+=l[w]);let x=0,T=Math.max(0,w-r),z=Math.min(l.length-1,w+r);for(let k=T;k<=z;k++)l[k]>0&&(x+=l[k]*(1-Math.abs(k-w)/(r+1)));x>=a*m&&g++}let y=0;for(let w of e.frames){let x=w.f-n;for(let T of w.picks)if(T.clipIndex===t&&Math.abs(Math.round(T.frame-i*x)-u-p)<=r){y++;break}}return{intercept:p+u,peak:m,consensus:s>0?v/s:0,ambiguity:g,coverage:y}}function S8(e,t,n,i,r){let{threshold:o,tau:a}=n,s=f=>{let d=n.len(f);if(d<=0)return null;if(!r)return{from:0,to:d-1};if(r.clipIndex!==f.clipIndex)return null;let m=Math.max(0,r.lo),p=Math.min(d-1,r.hi);return m<=p?{from:m,to:p}:null},c=1/0;for(let f of t){let d=s(f);if(d)for(let m=d.from;m<=d.to;m++){let p=n.d(e,f,m);p<c&&(c=p)}}if(!(c<=o))return[];let l=[],u=0;for(let f of t){let d=s(f);if(d)for(let m=d.from;m<=d.to;m++){let p=n.d(e,f,m);if(!(p>o)){if(u+=Math.exp(-(p-c)/a),l.length<i)l.push({clipIndex:f.clipIndex,frame:m,dist:p}),l.length===i&&l.sort((b,h)=>b.dist-h.dist);else if(p<l[i-1].dist){l[i-1]={clipIndex:f.clipIndex,frame:m,dist:p};for(let b=i-1;b>0&&l[b].dist<l[b-1].dist;b--){let h=l[b];l[b]=l[b-1],l[b-1]=h}}}}}return u<=0?[]:l.map(f=>({clipIndex:f.clipIndex,frame:f.frame,weight:Math.exp(-(f.dist-c)/a)/u}))}function cE(e,t,n){let i=0,r=0,o=e.length;for(;r<o;){let a=r+o>>1;e[a].offset<t?r=a+1:o=a}for(let a=r;a<e.length;a++){let s=e[a].offset-t;if(s>n)break;i+=e[a].weight*(1-s/(n+1))}for(let a=r-1;a>=0;a--){let s=t-e[a].offset;if(s>n)break;i+=e[a].weight*(1-s/(n+1))}return i}function Fs(e,t,n,i,r={},o=!1){let a=r.threshold??An,s=r.kernelRadius??x8,c=r.consensusWindow??b8,l=r.minClipShare??g8,u=r.tau??v8,f=r.minConsensus??y8,d=r.minVotingFrames??w8,m=r.ambiguityFraction??P8,p=Math.max(1,r.maxCandidates??oE),b=h8(e,a,u,r),h=i-n+1,v=[],g=new Map,y=0,w=0,x=!1,T=r.embedding?r.embedding.ref.length:e.length;for(let j=n;j<=i;j++){if(j<0||j>=T)continue;let C=S8(j,t,b,p,r.searchWindow);if(C.length!==0){C.length>=p&&(x=!0),y++;for(let H of C)v.push({clipIndex:H.clipIndex,offset:H.frame-j,weight:H.weight}),g.set(H.clipIndex,(g.get(H.clipIndex)??0)+H.weight),w+=H.weight}}let z={refStart:n,refEnd:i,placement:null,ramp:null,hold:!1};if(v.length===0||w<=0)return{...z,declined:"no-votes"};if(y<d*h)return{...z,declined:"too-few-voting-frames"};let k=[...g.entries()].map(([j,C])=>({clipIndex:j,mass:C,share:C/w})).sort((j,C)=>C.mass-j.mass||j.clipIndex-C.clipIndex),S=k[0],M=t.find(j=>j.clipIndex===S.clipIndex)?.label??String(S.clipIndex);if(S.share<l)return{...z,declined:"no-dominant-clip"};if(k.length>1&&Math.abs(k[0].mass-k[1].mass)<=1e-9*w)return{...z,declined:"no-dominant-clip"};let L=v.filter(j=>j.clipIndex===S.clipIndex).sort((j,C)=>j.offset-C.offset),P=-1,X=L[0].offset,R=new Float64Array(L.length);for(let j=0;j<L.length;j++){let C=cE(L,L[j].offset,s);R[j]=C,C>P&&(P=C,X=L[j].offset)}let I=0;for(let j of L)Math.abs(j.offset-X)<=c&&(I+=j.weight);let q=I/S.mass;if(q<f)return{...z,declined:"no-consensus"};if(!o&&h>=2*8){let j=n+(h>>1),C=Fs(e,t,n,j-1,r,!0).placement,H=Fs(e,t,j,i,r,!0).placement,ne=r.halvesTolerance??s,le=Se=>!!Se&&Se.clipIndex===S.clipIndex&&Math.abs(Se.offset-X)<=ne;if(!le(C)||!le(H))return{...z,declined:"halves-disagree"}}let D=new Set;for(let j=0;j<L.length;j++)R[j]>=m*P&&D.add(L[j].offset);return{refStart:n,refEnd:i,declined:null,hold:!1,ramp:null,placement:{refStart:n,refEnd:i,clipIndex:S.clipIndex,clipLabel:M,offset:X,peak:P,share:S.share,consensus:q,votingFrames:y,ambiguity:D.size,truncated:x,rivals:k.slice(1).map(j=>({clipIndex:j.clipIndex,clipLabel:t.find(C=>C.clipIndex===j.clipIndex)?.label??String(j.clipIndex),share:j.share}))}}}var lE=8,uE=1,_v=1e-6,fE=.05,dE=3,mE=64;function m8(e,t,n){let i=e.frames.filter(a=>a.f>=t&&a.f<=n),r=new Map,o=0;for(let a of i)for(let s of a.picks)r.set(s.clipIndex,(r.get(s.clipIndex)??0)+s.weight),o+=s.weight;return{frames:i,votingFrames:i.length,truncated:e.truncated,massByClip:r,totalMass:o}}function $v(e,t,n,i,r={}){let o=r.threshold??An,a=r.kernelRadius??x8,s=r.consensusWindow??b8,c=r.minClipShare??g8,l=r.tau??v8,u=r.minConsensus??y8,f=r.minVotingFrames??w8,d=r.ambiguityFraction??P8,m=Math.max(1,r.maxCandidates??mE),p=i-n+1;if(p<2)return null;let b=h8(e,o,l,r),h=r.embedding?r.embedding.ref.length:e.length,v=aE(h,t,n,i,b,m,r.searchWindow);if(v.totalMass<=0||v.votingFrames<f*p)return null;let g=[...v.massByClip.entries()].map(([C,H])=>({clipIndex:C,mass:H,share:H/v.totalMass})).sort((C,H)=>H.mass-C.mass||C.clipIndex-H.clipIndex),y=g[0];if(y.share<c||g.length>1&&Math.abs(g[0].mass-g[1].mass)<=1e-9*v.totalMass)return null;let w=t.find(C=>C.clipIndex===y.clipIndex)?.label??String(y.clipIndex),x=1/0,T=-1/0;for(let C of v.frames)for(let H of C.picks)H.clipIndex===y.clipIndex&&(H.frame<x&&(x=H.frame),H.frame>T&&(T=H.frame));if(!Number.isFinite(x))return null;let z=Math.ceil(Rs*p)+a+2,k=Math.floor(x)-z,S=Math.ceil(T)+z-k+1;if(S<=0||S>4e6)return null;let M={bins:new Float64Array(S),base:k},L=(C,H,ne)=>sE(ne??v,y.clipIndex,n,C,H,s,d,(ne??v).massByClip.get(y.clipIndex)??0,M),P=Math.max(lE/p,1/64),X=Math.max(a,Math.ceil(P*p/2)),R=Math.max(uE/p,1/512),I=(C,H)=>{let ne=Math.abs(C)<_v;if(ne&&!p8(e,n,i)||!ne&&r.forceSlope==null&&Math.abs(C-1)<fE||!ne&&Math.abs(C)<wp||H.consensus<u)return null;if(p>=2*8){let be=n+(p>>1),Me=[m8(v,n,be-1),m8(v,be,i)];for(let Oe of Me){if(Oe.totalMass<=0)return null;let bt=Oe.massByClip.get(y.clipIndex)??0;if(bt<=0||bt/Oe.totalMass<c)return null;let tt=L(C,a,Oe);if(!tt||Math.abs(tt.intercept-H.intercept)>(r.halvesTolerance??a))return null}}let Se=(be,Me)=>{let Oe=[];for(let bt of v.frames){let tt=bt.f-n,zt=Me+be*tt;for(let Ht of bt.picks)Ht.clipIndex===y.clipIndex&&Math.abs(Ht.frame-zt)<=dE&&Oe.push({x:tt,y:Ht.frame,w:Ht.weight})}return Oe},Le=(be,Me,Oe)=>{let bt=0,tt=0;for(let zt of be)bt+=zt.w,tt+=zt.w*Math.abs(zt.y-(Oe+Me*zt.x));return bt>0?tt/bt:1/0},ut=C,we=H.intercept,De=Se(ut,we);if(De.length===0)return null;let Je=Le(De,ut,we);if(ne){let be=0,Me=0;for(let Oe of De)be+=Oe.w,Me+=Oe.w*Oe.y;if(be>0){let Oe=Me/be,bt=Se(0,Oe);bt.length>0&&Le(bt,0,Oe)<Je&&(we=Oe,De=bt,Je=Le(De,0,Oe))}}else{let be=0,Me=0,Oe=0;for(let Mt of De)be+=Mt.w,Me+=Mt.w*Mt.x,Oe+=Mt.w*Mt.y;let bt=Me/be,tt=Oe/be,zt=0,Ht=0;for(let Mt of De){let mt=Mt.x-bt;zt+=Mt.w*mt*(Mt.y-tt),Ht+=Mt.w*mt*mt}if(Ht>1e-9){let Mt=zt/Ht,mt=tt-Mt*bt,K=Se(Mt,mt);Math.abs(Mt-C)<=2*R&&Math.abs(Mt)>=wp&&Math.abs(Mt)<=Rs&&K.length>0&&Le(K,Mt,mt)<Je&&(ut=Mt,we=mt,De=K,Je=Le(De,ut,we))}}return{clipIndex:y.clipIndex,clipLabel:w,srcAtStart:Math.round(we),slope:ne?0:ut,pieces:v.votingFrames,residual:Je,ambiguity:H.ambiguity}};if(r.forceSlope!=null){let C=L(r.forceSlope,a);return C?I(r.forceSlope,C):null}let q=[];for(let C=-Rs;C<=Rs+1e-9;C+=P){let H=Math.abs(C)<_v?0:C,ne=L(H,X);ne&&q.push({slope:H,peak:ne.peak})}let Y=L(0,X);if(Y&&q.push({slope:0,peak:Y.peak}),q.length===0)return null;q.sort((C,H)=>H.peak-C.peak||C.slope-H.slope);let D=(C,H)=>C.coverage!==H.coverage?C.coverage>H.coverage:C.peak>H.peak,j=null;for(let C of q.slice(0,4)){for(let H=C.slope-P;H<=C.slope+P+1e-9;H+=R){let ne=Math.abs(H)<_v?0:H;if(Math.abs(ne)>Rs)continue;let le=L(ne,a);le&&(!j||D(le,j.p))&&(j={slope:ne,p:le})}if(C.slope===0){let H=L(0,a);H&&(!j||D(H,j.p))&&(j={slope:0,p:H})}}return j?I(j.slope,j.p):null}var Vs=3,k8=8,ey=.5,wp=.1,Rs=8;function pE(e,t,n,i,r={}){let o=i-n+1,a=[6,4,3].filter(l=>Math.floor(o/l)>=k8),s=null;for(let l of a){let u=Math.floor(o/l),f=bE(e,t,n,i,l,u,r);if(f.ramp){s=f.ramp;break}if(f.placed>=Vs)return null}return s?hE(e,t,n,i,s,r)??s:null}function hE(e,t,n,i,r,o){let a=i-n+1,s=Math.min(6,Math.floor(a/k8));if(s<Vs)return null;let c=Math.floor(a/s),l=d=>r.srcAtStart+r.slope*(d-n),u=[];for(let d=0;d<s;d++){let m=n+d*c,p=d===s-1?i:m+c-1,b=m+p>>1,h=l(b),v=Fs(e,t,m,p,{...o,searchWindow:{clipIndex:r.clipIndex,lo:Math.floor(h-c*2),hi:Math.ceil(h+c*2)}},!0).placement;v&&u.push({ref:b,src:b+v.offset})}if(u.length<Vs)return null;let f=T8(u,Math.max(2,ey*c));return!f||f.inliers<Vs||!(Math.abs(f.slope)>=wp&&Math.abs(f.slope)<=Rs)||f.inliers<r.pieces||f.inliers===r.pieces&&f.residual>=r.residual?null:{...r,srcAtStart:Math.round(f.slope*n+f.intercept),slope:f.slope,pieces:f.inliers,residual:f.residual}}function bE(e,t,n,i,r,o,a){let s=[];for(let f=0;f<r;f++){let d=n+f*o,m=f===r-1?i:d+o-1,p=Fs(e,t,d,m,a,!0).placement;if(!p)continue;let b=d+m>>1;s.push({ref:b,src:b+p.offset,clipIndex:p.clipIndex})}if(s.length<Vs)return{ramp:null,placed:s.length};let c=s[0].clipIndex,l=s.length;if(s.some(f=>f.clipIndex!==c))return{ramp:null,placed:l};let u=T8(s,Math.max(2,ey*o));return u?Math.abs(u.slope)>=wp&&Math.abs(u.slope)<=Rs?u.inliers<Vs?{ramp:null,placed:l}:u.residual>ey*o?{ramp:null,placed:l}:{ramp:{clipIndex:c,clipLabel:t.find(f=>f.clipIndex===c)?.label??String(c),srcAtStart:Math.round(u.slope*n+u.intercept),slope:u.slope,pieces:u.inliers,residual:u.residual},placed:l}:{ramp:null,placed:l}:{ramp:null,placed:l}}function T8(e,t){let n=a=>{let s=0,c=0;for(let p of a)s+=p.ref,c+=p.src;let l=s/a.length,u=c/a.length,f=0,d=0;for(let p of a){let b=p.ref-l;f+=b*(p.src-u),d+=b*b}if(d<=1e-9)return null;let m=f/d;return{slope:m,intercept:u-m*l}},i=null;for(let a=0;a<e.length;a++)for(let s=a+1;s<e.length;s++){let c=e[s].ref-e[a].ref;if(c===0)continue;let l=(e[s].src-e[a].src)/c,u=e[a].src-l*e[a].ref,f=e.filter(d=>Math.abs(d.src-(l*d.ref+u))<=t);(!i||f.length>i.length)&&(i=f)}if(!i||i.length<Vs)return null;let r=n(i);if(!r)return null;let o=0;for(let a of i)o+=Math.abs(a.src-(r.slope*a.ref+r.intercept));return{...r,residual:o/i.length,inliers:i.length}}function z8(e,t,n={}){let{embedding:i,...r}=n,o=i?{...r,embedding:i,halvesTolerance:n.halvesTolerance??rE}:null,a=$H(e,r);return tE(e.length,a).map(s=>{if(p8(e,s.start,s.end)){let u=Fs(e,t,s.start,s.end,r),f=u.placement?null:$v(e,t,s.start,s.end,{...r,forceSlope:0});return{...u,hold:!0,ramp:f}}let c=Fs(e,t,s.start,s.end,r);if(c.placement)return c;if(c.declined==="halves-disagree"){let u=$v(e,t,s.start,s.end,r)??pE(e,t,s.start,s.end,r);if(u)return{...c,ramp:u}}if(!o||c.declined!=="no-votes")return c;let l=Fs(e,t,s.start,s.end,o);if(l.placement)return{...l,tier:"embedding"};if(l.declined==="halves-disagree"){let u=$v(e,t,s.start,s.end,o);if(u)return{...l,ramp:u,tier:"embedding"}}return c})}var gE=24,M8=An+gE,ty=8,vE=4,O8="screened out before full match:";function L8(e){return Math.max(1,e)*ty}function yE(e,t){let n=1/0;for(let i of e)for(let r of t){let o=fn(i,r);if(o<n&&(n=o,n===0))return 0}return n}function X8(e,t){if(!e.length||!t.length)return{minDistance:1/0,skip:!1,reason:"coarse pass returned no frames \u2014 kept, absence of evidence is not evidence"};let n=yE(e,t),i=n>M8;return{minDistance:n,skip:i,reason:i?`best frame ${n} bits from the reference, past the ${M8}-bit cutoff`:`best frame ${n} bits \u2014 inside the cutoff, full pass`}}function N8(e){return e>=vE}var xp=12,wE=12,ny="not examined:";function F8(e){return e<=xp?1:Math.max(1,Math.floor(e/xp))}function V8(e,t,n,i,r){let o=0,a=1/0;for(let s of n){let c=1/0;for(let l of i){let u=fn(s,l);if(u<c&&(c=u,c===0))break}c<=An&&o++,c<a&&(a=c)}return{clipIndex:e,label:t,hits:o,minDistance:a,probes:n.length,spacing:r}}function R8(e){return e.probes>0?e.hits/e.probes:0}function j8(e){return e.map((t,n)=>({s:t,i:n})).sort((t,n)=>{let i=t.s.probes===0,r=n.s.probes===0;if(i!==r)return i?-1:1;let o=R8(t.s),a=R8(n.s);return o!==a?a-o:t.s.minDistance!==n.s.minDistance?t.s.minDistance-n.s.minDistance:t.i-n.i}).map(t=>t.s)}function Z8(e){return e>=wE}var Pp=3;function I8(e){let t=0,n=0;for(let i=0;i<e.length;i++)e[i]?n=0:++n>t&&(t=n);return t}function W8(e){return Number.isFinite(e.worstContributor)?e.coverageComplete&&e.dryStreak>=Pp&&e.nextScore>e.worstContributor:!1}var xE=3,Da=48,D8=An;function Sp(e){return(e.split(/[\\/]/).pop()??e).replace(/\.[^.]+$/,"").replace(/_\d{3}$/,"").toLowerCase()}function PE(e){return Sp(e).replace(/^v\d+-\d{4}_/,"")}function SE(e,t){let n=(c,l,u)=>{if(!c)return null;let f=l(c),d=t.reduce((m,p,b)=>u(p)===f?[...m,b]:m,[]);return d.length===1?d[0]:null},i=c=>n(c,Sp,l=>l),r=i(e.sourceFilename);if(r!=null)return r;let o=i(e.clipName);if(o!=null)return o;let a=c=>n(c,PE,l=>l.replace(/^v\d+-\d{4}_/,"")),s=a(e.sourceFilename)??a(e.clipName);if(s!=null)return s;if(e.reelName){let c=Sp(e.reelName),l=t.reduce((u,f,d)=>f.startsWith(c)?[...u,d]:u,[]);if(l.length===1)return l[0]}return null}function kE(e,t,n=xE){let i=t-e+1;if(i<=0)return[];if(i<=n)return Array.from({length:i},(s,c)=>e+c);let r=Math.max(1,Math.floor(i*.1)),o=e+r,a=t-r;return a<=o?[e+(i>>1)]:Array.from({length:n},(s,c)=>o+Math.round(c*(a-o)/(n-1)))}function TE(e,t,n){let i=e.declaredSpeed??1;return Math.round(n+(t-e.refStart)*i)}async function q8(e,t,n,i,r,o){let a=o.srcFrames(t),s=0;for(let c=0;c<i.length;c++){let l=r[c];if(!l)return null;let u=TE(e,i[c],n);if(u<0||a>0&&u>=a)return null;let f=await o.srcHash(t,u);if(!f)return null;let d=fn(l,f);d>s&&(s=d)}return s}async function zE(e,t,n){let i={hint:e,clipIndex:t,srcStart:null,correction:0,worstDistance:1/0};if(t==null)return{...i,outcome:"unbound",reason:`no file in the bucket answers to ${[e.sourceFilename,e.clipName,e.reelName].filter(Boolean).join(" / ")||"any name"} \u2014 this shot goes to the pixel search`};if(e.declaredReframe)return{...i,clipIndex:t,srcStart:e.srcStart,outcome:"reframe-declined",reason:"the timeline declares a resize on this shot, so a whole-frame hash cannot confirm its in-point \u2014 the clip and the cut are taken, the in-point is resolved from the picture"};let r=kE(e.refStart,e.refEnd);if(!r.length)return{...i,outcome:"unreadable",reason:"the hinted span has no frames"};let o=await Promise.all(r.map(c=>n.refHash(c)));if(o.some(c=>!c))return{...i,outcome:"unreadable",reason:"the reference frames for this span could not be read \u2014 the claim is untested, not disproved"};let a=await q8(e,t,e.srcStart,r,o,n);if(a!=null&&a<=D8)return{...i,clipIndex:t,srcStart:e.srcStart,correction:0,worstDistance:a,outcome:"confirmed",reason:`every sample within ${a} bits at the declared in-point`};let s=null;for(let c=1;c<=Da&&!s;c++)for(let l of[e.srcStart-c,e.srcStart+c]){if(l<0)continue;let u=await q8(e,t,l,r,o,n);if(u!=null&&u<=D8){s={srcStart:l,worst:u};break}}if(s){let c=s.srcStart-e.srcStart;return{...i,clipIndex:t,srcStart:s.srcStart,correction:c,worstDistance:s.worst,outcome:"corrected",reason:`the declared in-point is out by ${c>0?"+":""}${c} frame(s) \u2014 the picture matches at ${s.srcStart} within ${s.worst} bits`}}return{...i,clipIndex:t,outcome:"refuted",worstDistance:a??1/0,reason:a==null?"the claimed source frames could not be read from this clip \u2014 sent to the pixel search":`the picture does not match this clip at the declared in-point (${a} bits) or within ${Da} frames of it \u2014 sent to the pixel search`}}async function H8(e,t,n,i){let r=t.map(Sp),o=[];for(let a of e){let s=SE(a,r);o.push(await zE(s==null?a:await ME(a,s,n),s,n)),i?.(o.length,e.length)}return o}async function ME(e,t,n){if(e.srcTimecode==null||!n.srcTimecode)return e;let i=await n.srcTimecode(t).catch(()=>null);if(!i||!(i.fps>0))return e;let r=e.srcRate&&e.srcRate>0?e.srcRate:i.fps,o=Math.round(i.fps)===Math.round(r)&&!!e.srcDropFrame==!!i.dropFrame,a=o?null:zi(e.srcTimecode,r,!!e.srcDropFrame).split(/[:;]/).map(Number),s=o?e.srcTimecode:hp(`${a[0]}:${a[1]}:${a[2]}${i.dropFrame?";":":"}${Math.round(a[3]*Math.round(i.fps)/Math.round(r))}`,i.fps)?.frames;if(s==null)return e;let c=s-i.start,l=n.srcFrames(t);return c<0||l>0&&c>=l||c===e.srcStart?e:{...e,srcStart:c}}function E8(e){let t={confirmed:0,corrected:0,refuted:0,unbound:0,"reframe-declined":0,unreadable:0,total:e.length};for(let n of e)t[n.outcome]++;return t}var hf=24,kp=1440,OE=.55;function ea(e,t=0,n=e.length-1){let i=Math.max(1,t+1),r=Math.min(e.length-1,n),o=new Float64Array(Math.max(0,r-i+1));for(let a=i;a<=r;a++){let s=fn(e[a],e[a-1]);o[a-i]=Number.isFinite(s)?s:0}return o}function ry(e,t,n,i={}){let{perClip:r=2,apart:o=24,minR:a=OE}=i,s=e.length;if(s<hf)return[];let c=0;for(let m of e)c+=m;c/=s;let l=0;for(let m of e)l+=(m-c)**2;if(l<1e-9)return[];let u=Math.sqrt(l),f=e.map(m=>(m-c)/u),d=[];for(let m of n){let p=m.deltas;if(p.length<s)continue;let b=new Float64Array(p.length+1),h=new Float64Array(p.length+1);for(let y=0;y<p.length;y++)b[y+1]=b[y]+p[y],h[y+1]=h[y]+p[y]*p[y];let v=[];for(let y=0;y+s<=p.length;y++){let w=b[y+s]-b[y],x=h[y+s]-h[y]-w*w/s;if(x<1e-9)continue;let T=0;for(let k=0;k<s;k++)T+=f[k]*p[y+k];let z=T/Math.sqrt(x);z>=a&&v.push({at:y,r:z})}v.sort((y,w)=>w.r-y.r);let g=[];for(let y of v)if(g.every(w=>Math.abs(w.at-y.at)>=o)&&g.push(y),g.length>=r)break;for(let y of g)d.push({clipIndex:m.clipIndex,label:m.label,offset:y.at-t,r:y.r})}return d.sort((m,p)=>p.r-m.r)}var C8=new Map;function LE(e,t){let n=C8.get(e*4096+t);if(!n){n=new Int32Array(e);for(let i=0;i<e;i++)n[i]=Math.min(t-1,i*t/e|0);C8.set(e*4096+t,n)}return n}function jn(e,t=48,n=Math.max(1,Math.round(t*(e?.h??1)/(e?.w??1)))){if(!e||!e.w||!e.h)return null;let i=new Float32Array(t*n),r=new Float32Array(t*n),o=LE(e.w,t),a=e.y;for(let s=0;s<e.h;s++){let c=Math.min(n-1,s*n/e.h|0)*t,l=s*e.w;for(let u=0;u<e.w;u++){let f=c+o[u];i[f]+=a[l+u],r[f]++}}for(let s=0;s<i.length;s++)i[s]/=r[s]||1;return i}function hi(e,t,n,i,r=48,o=Math.max(1,Math.round(r*i/n))){if(!e||!e.w||!e.h||!n||!i)return null;let a=new Float32Array(r*o),s=4,[c,l,u,f,d,m,p,b,h]=t;for(let v=0;v<o;v++)for(let g=0;g<r;g++){let y=0,w=0;for(let x=0;x<s;x++)for(let T=0;T<s;T++){let z=(g+(T+.5)/s)*n/r-.5,k=(v+(x+.5)/s)*i/o-.5,S=p*z+b*k+h;if(Math.abs(S)<1e-12)continue;let M=Math.round((c*z+l*k+u)/S),L=Math.round((f*z+d*k+m)/S);M<0||L<0||M>=e.w||L>=e.h||(y+=e.y[L*e.w+M],w++)}a[v*r+g]=w?y/w:0}return a}function U8(e,t,n,i,r,o=3,a=6){let s=e.slice(1).map((f,d)=>Tp(e[d],f)),c=t.slice(1).map((f,d)=>Tp(t[d],f)),l=[];for(let f=i;f<=r;f++){let d=0,m=0;for(let p=0;p<s.length;p++){let b=c[f-n+p];!s[p]||!b||(d+=A8(s[p],b),m++)}m>=Math.max(4,s.length>>1)&&l.push([f,d/m])}l.sort((f,d)=>d[1]-f[1]);let u=[];for(let[f,d]of l)if(u.every(m=>Math.abs(m.src-f)>=a)&&u.push({src:f,score:d}),u.length>=o)break;return u}function ao(e){let[t,n,i,r,o,a,s,c,l]=e,u=o*l-a*c,f=-(r*l-a*s),d=r*c-o*s,m=t*u+n*f+i*d;return!Number.isFinite(m)||Math.abs(m)<1e-12?null:[u/m,-(n*l-i*c)/m,(n*a-i*o)/m,f/m,(t*l-i*s)/m,-(t*a-i*r)/m,d/m,-(t*c-n*s)/m,(t*o-n*r)/m]}function Tp(e,t){if(!e||!t||e.length!==t.length)return null;let n=new Float32Array(e.length);for(let i=0;i<e.length;i++)n[i]=t[i]-e[i];return n}function A8(e,t){let n=0,i=0;for(let s=0;s<e.length;s++)n+=e[s],i+=t[s];n/=e.length,i/=e.length;let r=0,o=0,a=0;for(let s=0;s<e.length;s++){let c=e[s]-n,l=t[s]-i;r+=c*l,o+=c*c,a+=l*l}return o>0&&a>0?r/Math.sqrt(o*a):0}function ta(e,t,n,i,r){let o=e.slice(1).map((d,m)=>Tp(e[m],d)),a=t.slice(1).map((d,m)=>Tp(t[m],d)),s=[];for(let d=i;d<=r;d++){let m=0,p=0;for(let b=0;b<o.length;b++){let h=a[d-n+b];!o[b]||!h||(m+=A8(o[b],h),p++)}p>=Math.max(4,o.length>>1)&&s.push([d,m/p])}if(!s.length)return null;s.sort((d,m)=>m[1]-d[1]);let[c,l]=s[0],u=s.find(([d])=>Math.abs(d-c)>2)?.[1]??0,f=l-u;return{src:c,score:l,margin:f,clear:l>=.3&&f>=.1}}function zo(e,t){if(!e)return null;let n=e.length/t,i=new Float32Array(2*e.length);for(let r=0;r<n;r++)for(let o=0;o<t;o++){let a=r*t+o;i[a]=e[r*t+Math.min(t-1,o+1)]-e[r*t+Math.max(0,o-1)],i[e.length+a]=e[Math.min(n-1,r+1)*t+o]-e[Math.max(0,r-1)*t+o]}return i}function zp(e,t){let n=0,i=0;for(let s=0;s<e.length;s++)n+=e[s],i+=t[s];n/=e.length,i/=t.length;let r=0,o=0,a=0;for(let s=0;s<e.length;s++){let c=e[s]-n,l=t[s]-i;r+=c*l,o+=c*c,a+=l*l}return o>0&&a>0?r/Math.sqrt(o*a):0}var bf=.4,Y8=12,Np=null;function K8(e){Np=e}function oy(){return Np!==null}function G8(e){let t=new Uint8Array(e.reduce((i,r)=>i+r.w*r.h,0)),n=0;for(let i of e)t.set(i.y.subarray(0,i.w*i.h),n),n+=i.w*i.h;return t}async function Mi(e,t={}){let n=e.filter(a=>a.src.w===e[0].src.w&&a.src.h===e[0].src.h&&a.ref.w===e[0].ref.w&&a.ref.h===e[0].ref.h);if(!n.length)return null;let i=n.map(a=>a.src),r=n.map(a=>a.ref),o;return Np?o=await Np(i,r,JSON.stringify(t)):(await Hc(),o=JSON.parse(r6(G8(i),i[0].w,i[0].h,G8(r),r[0].w,r[0].h,i.length,JSON.stringify(t)))),o.ok?o:null}function XE(e,t,n,i,r,o=i,a=r){let s=e.transform,c=(t-1)/2,l=(n-1)/2,u=s[0]*c+s[1]*l+s[2]+.5,f=s[3]*c+s[4]*l+s[5]+.5,d=(u-i/2)*(o/i),m=(f-r/2)*(a/r);return{scale:e.scale_fit,scaleX:e.scale_fit,scaleY:e.scale_fit,rotationDeg:e.rotation_deg,dxCenter:d,dyCenter:m,perspective:!1,label:Q8(e.scale_fit,d,m,e.rotation_deg,e.flip_h,e.flip_v),flipH:e.flip_h,flipV:e.flip_v,score:e.score,measuredBy:"sizing"}}function Q8(e,t,n,i,r,o){let a=[];return Math.abs(e-1)>.001&&a.push(e>1?`punch-in ${e.toFixed(3)}\xD7`:`pull-out ${e.toFixed(3)}\xD7`),(Math.abs(t)>=1||Math.abs(n)>=1)&&a.push(`shift ${Math.round(t)},${Math.round(n)}px`),Math.abs(i)>=.05&&a.push(`rot ${i.toFixed(2)}\xB0`),r&&a.push("flop"),o&&a.push("flip"),a.join(" \xB7 ")||"1:1"}function Oi(e,t,n=Y8){let i=Math.min(t,e+1),r=Math.max(i,t-1),o=Math.max(1,Math.min(n,r-i+1));return Array.from({length:o},(a,s)=>Math.round(i+(s+.5)*(r-i+1)/o-.5))}var iy={scale:.004,px:1.5,deg:.1},Mp=3,NE=.05,Op=[.04,.27,.5,.73,.96],Lp={scale:.003,px:1.5,deg:.1};function J8(e,t){return Math.abs(Math.log(e.scale/t.scale))>iy.scale||Math.hypot(e.dxCenter-t.dxCenter,e.dyCenter-t.dyCenter)>iy.px||Math.abs(e.rotationDeg-t.rotationDeg)>iy.deg||e.flipH!==t.flipH||e.flipV!==t.flipV}function B8(e,t,n,i,r){return{...e,scale:t,scaleX:t,scaleY:t,dxCenter:n,dyCenter:i,rotationDeg:r,label:Q8(t,n,i,r,e.flipH,e.flipV)}}function Xp(e,t){let n=e.length,i=e.reduce((l,u)=>l+u,0)/n,r=t.reduce((l,u)=>l+u,0)/n,o=0,a=0;for(let l=0;l<n;l++)o+=(e[l]-i)*(t[l]-r),a+=(e[l]-i)**2;let s=a>0?o/a:0,c=l=>r+s*(l-i);return{at:c,worst:Math.max(...e.map((l,u)=>Math.abs(c(l)-t[u])))}}async function _8(e,t,n={}){let i=0,r=0,o=0,a=e.timeline.filter(u=>u.clipLabel&&u.srcStart!=null&&u.srcEnd!=null&&(u.kind==="static"||u.kind==="unresolved")),s=0,c=async()=>{for(;s<a.length;)await l(a[s++])},l=async u=>{let f=Math.max(1,u.refEnd-u.refStart),d=n.hint?.(u.refStart),m=k=>d?{...n.params,min_scale:d/k,max_scale:d*k}:n.params,p=k=>Math.round(u.srcStart+(k-u.refStart)*(u.srcEnd-u.srcStart)/f),b=async k=>{let S=[];for(let M of k){let[L,P]=await Promise.all([t.ref(M),t.src(u.clipLabel,p(M))]);L&&P&&S.push({u:M,src:P,ref:L})}return S},h=(k,S)=>XE(k,S.src.w,S.src.h,S.ref.w,S.ref.h,e.refW||S.ref.w,e.refH||S.ref.h),v=async k=>{let S=Math.round(u.refStart+k*f),M=Math.max(u.refStart,Math.min(u.refEnd-Mp+1,S-(Mp>>1))),L=await b(Array.from({length:Math.min(Mp,f+1)},(X,R)=>M+R)),P=L.length?await Mi(L,m(1.35)):null;return P&&P.score>=bf?{u:L.reduce((X,R)=>X+R.u,0)/L.length,r:h(P,L[0]),score:P.score}:null},g=await b(Oi(u.refStart,u.refEnd,n.pairs??Y8)),y=g.length?await Mi(g,m(1.1)):null,w=u.refStart+u.refEnd>>1,x=f>=4*Mp?await Promise.all([v(Op[0]),v(Op[Op.length-1])]):[null,null],T=y!=null&&x[0]!=null&&x[1]!=null&&y.score>=Math.min(x[0].score,x[1].score)-NE;if(x[0]&&x[1]&&J8(x[0].r,x[1].r)&&n.log?.(`size ${u.refStart}-${u.refEnd} ${u.clipLabel}: ends differ (${x[0].r.label} \u2192 ${x[1].r.label}); static ${y?.score.toFixed(2)??"-"} vs ends ${x[0].score.toFixed(2)}/${x[1].score.toFixed(2)}`),x[0]&&x[1]&&J8(x[0].r,x[1].r)&&!T){let k=await Promise.all(Op.slice(1,-1).map(v)),S=[x[0],...k,x[1]].filter(j=>!!j),M=S.map(j=>j.u),L=Xp(M,S.map(j=>j.r.scale)),P=Xp(M,S.map(j=>j.r.dxCenter)),X=Xp(M,S.map(j=>j.r.dyCenter)),R=Xp(M,S.map(j=>j.r.rotationDeg)),I=L.worst/L.at(w)<Lp.scale&&P.worst<Lp.px&&X.worst<Lp.px&&R.worst<Lp.deg,q=(j,C,H)=>{let ne=(H-j.u)/Math.max(1e-9,C.u-j.u),le=Se=>j.r[Se]+(C.r[Se]-j.r[Se])*ne;return{refFrame:H,reframe:B8(j.r,le("scale"),le("dxCenter"),le("dyCenter"),le("rotationDeg"))}},Y=S.length,D=I?[u.refStart,u.refEnd].map(j=>({refFrame:j,reframe:B8(S[0].r,L.at(j),P.at(j),X.at(j),R.at(j))})):[q(S[0],S[1],u.refStart),...S.map(j=>({refFrame:Math.round(j.u),reframe:j.r})),q(S[Y-2],S[Y-1],u.refEnd)];u.kind="animated",u.track={kind:"animated",keyframes:D,label:`animated \xB7 ${D[0].reframe.label} \u2192 ${D[D.length-1].reframe.label}`},i++,r++,n.log?.(`size ${u.refStart}-${u.refEnd} ${u.clipLabel}: ${u.track.label} (${I?"linear":`${D.length} keys`})`);return}if(!y||y.score<bf){o++,u.kind="unresolved",u.track={kind:"unresolved",keyframes:[],label:`sizing not measured: agreement ${y?y.score.toFixed(2):"none"}, below ${bf}`},n.log?.(`size ${u.refStart}-${u.refEnd} ${u.clipLabel}: untrusted ${y?y.score.toFixed(2):"no fit"}`);return}let z=h(y,g[0]);u.kind="static",u.track={kind:"static",keyframes:[{refFrame:w,reframe:z}],label:z.label},i++,n.log?.(`size ${u.refStart}-${u.refEnd} ${u.clipLabel}: ${z.label} (agreement ${y.score.toFixed(2)})`)};return await Promise.all(Array.from({length:Math.max(1,n.concurrency??3)},c)),{sized:i,animated:r,untrusted:o}}var RE=(()=>{let e=new Float32Array(512);for(let t=0;t<512;t++)e[t]=.5-.5*Math.cos(2*Math.PI*t/512);return e})(),$8=(()=>{let e=new Float64Array(256),t=new Float64Array(512/2);for(let n=0;n<512/2;n++)e[n]=Math.cos(-2*Math.PI*n/512),t[n]=Math.sin(-2*Math.PI*n/512);return{c:e,s:t}})(),e5=(()=>{let e=new Uint16Array(512);for(let t=1,n=0;t<512;t++){let i=256;for(;n&i;i>>=1)n^=i;n^=i,e[t]=n}return e})();function FE(e){let t=[],n=new Float64Array(512),i=new Float64Array(512);for(let r=0;r+512<=e.length;r+=64){for(let a=0;a<512;a++)n[e5[a]]=e[r+a]*RE[a],i[e5[a]]=0;for(let a=2;a<=512;a<<=1){let s=a>>1,c=512/a;for(let l=0;l<512;l+=a)for(let u=0;u<s;u++){let f=$8.c[u*c],d=$8.s[u*c],m=l+u,p=m+s,b=n[p]*f-i[p]*d,h=n[p]*d+i[p]*f;n[p]=n[m]-b,i[p]=i[m]-h,n[m]+=b,i[m]+=h}}let o=new Float32Array(512/2);for(let a=0;a<512/2;a++)o[a]=Math.log1p(Math.hypot(n[a],i[a])*100);t.push(o)}return t}function VE(e){let t=new Map;for(let i=4;i<e.length-4;i++)for(let r=8;r<240;r++){let o=e[i][r];if(o<1)continue;let a=!0;for(let l=-4;l<=4&&a;l++)for(let u=-7;u<=7;u++)if((l||u)&&e[i+l][r+u]>=o){a=!1;break}if(!a)continue;let s=Math.floor(i/12),c=t.get(s);c||t.set(s,c=[]),c.push([i,r,o])}let n=[];for(let i of t.values())for(let r of i.sort((o,a)=>a[2]-o[2]).slice(0,5))n.push([r[0],r[1]]);return n.sort((i,r)=>i[0]-r[0])}function Rp(e){let t=VE(FE(e)),n=[],i=[];for(let r=0;r<t.length;r++){let o=0;for(let a=r+1;a<t.length&&o<6;a++){let s=t[a][0]-t[r][0];if(s<2)continue;if(s>63)break;let c=t[a][1]-t[r][1];Math.abs(c)>63||(n.push(t[r][1]<<14|c+64<<6|s),i.push(t[r][0]),o++)}}return{hash:Uint32Array.from(n),t:Uint32Array.from(i)}}var qa=class{constructor(){this.post=new Map;this.clips=new Set}add(t,n){this.addMarks(t,Rp(n))}addMarks(t,{hash:n,t:i}){for(let r=0;r<n.length;r++){let o=this.post.get(n[r]);o||this.post.set(n[r],o=[]),o.push(t,i[r])}this.clips.add(t)}get size(){return this.post.size}static reference(t){return Rp(t)}nominate(t,n,i,r=3){let o=Math.floor(n/.008),a=Math.ceil(i/.008),s=new Map;for(let u=0;u<t.hash.length;u++){let f=t.t[u];if(f<o||f>=a)continue;let d=this.post.get(t.hash[u]);if(d)for(let m=0;m<d.length;m+=2){let p=d[m]*16777216+(d[m+1]-f+8388608);s.set(p,(s.get(p)??0)+1)}}let c=[...s].sort((u,f)=>f[1]-u[1]),l=[];for(let[u,f]of c){let d=Math.floor(u/16777216),m=u%16777216-8388608;if(l.some(b=>b.clip===d))continue;let p=c.find(([b])=>Math.floor(b/16777216)!==d||Math.abs(b%16777216-8388608-m)>3)?.[1]??0;if(l.push({clip:d,shiftSec:m*.008,votes:f,rival:p}),l.length>=r)break}return l}},jE=12,ZE=3,t5=e=>e.votes>=jE&&e.votes>=ZE*Math.max(1,e.rival);function n5(e,t=6){let n=[],i=r=>r.length?(r.sort((o,a)=>o-a),r[r.length>>1]):0;for(let r=0;r<e.length;r++){let o=e[r];if(o<70)continue;let a=[],s=[];for(let p=Math.max(0,r-8);p<r;p++)a.push(e[p]);for(let p=r+1;p<=Math.min(e.length-1,r+8);p++)s.push(e[p]);let c=[a,s].filter(p=>p.length).map(p=>i([...p])),l=c.length?Math.min(...c):0,u=c.length?Math.max(...c):0,f=o>=2.5*Math.max(8,i([...a,...s])),d=o>=2.5*Math.max(8,l)&&o>=1.6*u;if(!f&&!d)continue;let m=r+1;if(n.length&&m-n[n.length-1]<t){o>e[n[n.length-1]-1]&&(n[n.length-1]=m);continue}n.push(m)}return n}function r5(e,t){let n=[],i=0;for(let r of[...t,e])r>i&&n.push({refStart:i,refEnd:r-1}),i=r;return n}function Fp(e,t=4){let i=e.refEnd-e.refStart+1>8?2:0,r=e.refStart+i,o=e.refEnd-i,a=Math.max(1,Math.min(t,Math.round((o-r+1)/24)));return a===1?[r+o>>1]:Array.from({length:a},(s,c)=>Math.round(r+c*(o-r)/(a-1)))}var IE=(e,t)=>{let n=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i];return n};function ay(e,t,n,i,r=4){let o=[];for(let a of t){let s=i(a.clipIndex),c=e.map(f=>a.vecs.map(d=>IE(f.vec,d))),l={score:-1/0,offset:0,sim:0};for(let f=0;f<e.length;f++){let d=0;for(let h=1;h<c[f].length;h++)c[f][h]>c[f][d]&&(d=h);let m=d*a.stride/s-e[f].frame,p=0;for(let h=0;h<e.length;h++){let v=Math.round((e[h].frame+m)*s/a.stride),g=0;for(let y=v-1;y<=v+1;y++)y>=0&&y<c[h].length&&(g=Math.max(g,c[h][y]));p+=g}let b=p/e.length;b>l.score&&(l={score:b,offset:m,sim:c[f][d]})}if(l.score===-1/0)continue;let u=Math.round((n+l.offset)*s);u<0||u>=a.frames||o.push({clipIndex:a.clipIndex,label:a.label,srcAtProbe:u,sim:l.score,why:`index ${l.score.toFixed(2)}`})}return o.sort((a,s)=>s.sim-a.sim).slice(0,r)}var Vp=.35,WE=6,sy=96,DE=6e3,js=(e,t)=>Math.floor(e*t+.001),qE=2.5;function HE(e){let n=jn(e,96);if(!n)return 0;let i=n.length/96,r=0,o=0;for(let a=1;a<i-1;a++)for(let s=1;s<95;s++){let c=a*96+s;r+=Math.abs(n[c+1]-n[c-1])+Math.abs(n[c+96]-n[c-96]),o++}return o?r/o:0}var EE=160;function CE(e,t){if(e.w<=t)return e;let n=t,i=Math.max(1,Math.round(e.h*n/e.w)),r=new Uint8Array(n*i),o=new Float32Array(n*i),a=new Float32Array(n*i);for(let s=0;s<e.h;s++){let c=Math.min(i-1,s*i/e.h|0)*n;for(let l=0;l<e.w;l++){let u=c+Math.min(n-1,l*n/e.w|0);o[u]+=e.y[s*e.w+l],a[u]++}}for(let s=0;s<r.length;s++)r[s]=o[s]/(a[s]||1);return{y:r,w:n,h:i}}var i5=6,cy=8,jp={turns:!1},yf=.5,oi=12e3,_c=48,UE=24,AE=.3,GE=.1,JE=.15,o5=.35,BE=.05,ly=3,YE=.05,a5=.1,s5=8,uy=4,fy=6,KE=.58,QE=.55,dy=8,c5=3;async function l5(e,t,n){if(t.kind!=="prores")return null;let i=t.offs[n];if(!i)return null;let r=new Uint8Array(await e.slice(i.offset,i.offset+i.size).arrayBuffer()),o=ck(r);return{y:o.y,w:o.width,h:o.height}}function _E(e,t,n){let i=Math.max(1,Math.ceil(n.count/64)),r=0,o=0;for(let a=0;a<n.count;a+=i){let s=e[n.refStart+a],c=t[n.srcStart+a];!s||!c||(r+=fn(s,c),o++)}return o?r/o:null}async function $E(e){let t=lf*8;try{for(let n of e){let i=await gn(n);if(!i.spec||i.frames.length<t)return 1}return lf}catch{return 1}}function eC(e){let t=[];for(let n of e)(n.op==="equal"||n.op==="move")&&t.push({refStart:n.aStart,srcStart:n.bStart,count:n.count});return t}async function my(e,t,n={}){let{onProgress:i,signal:r,gapFill:o=!0,candidateLuma:a,referenceLuma:s,fingerprint:c,stride:l,hashFrame:u,audio:f=!0,audioSummary:d,lumaCacheBytes:m,shotVote:p=!0,shotVoteOptions:b,embedSweep:h,shortlist:v=!0,triage:g,examineAll:y=!1,frameCount:w,hints:x,keyframesOf:T,findFirst:z,candidateThumb:k,audioPcm:S,...M}=n,L=()=>{if(r?.aborted)throw new DOMException("Auto Conform cancelled","AbortError")};L(),await sf();let P=l!==void 0?Math.max(1,Math.floor(l)):c||u?1:await $E([e,...t]),X=c??((Z,ee,ce,ve)=>Uk(Z,{side:ee,onProgress:ce,stride:ve,matte:"cut"})),R=u??(async Z=>Gk(Z,await gn(Z)));i?.(0,t.length,"fingerprinting reference");let I=await X(e,"A",(Z,ee)=>i?.(0,t.length,`fingerprinting reference \u2014 frame ${Z}/${ee}`),P),q=I.index,Y=P>1||x?.shots.length?await R(e,"A"):null,D=[],j=[],C=[],H=[],ne=t8(m),le=async Z=>{if(s)return s(Z);let ee=await l5(e,q,Z);return ee?{y:Cv(ee.y),w:ee.w,h:ee.h}:null},Se=async(Z,ee)=>{if(a)return a(Z,ee);let ce=await l5(t[Z],j[Z],ee);return ce?{y:Cv(ce.y),w:ce.w,h:ce.h}:null},Le=new Map,ut=async(Z,ee)=>{let ce=ne.get(Z);if(ce!==void 0)return ce;let ve=Le.get(Z);return ve||(ve=ee().then(B=>(ne.set(Z,B),B)).finally(()=>Le.delete(Z)),Le.set(Z,ve)),ve},we=Z=>ut(`r@${Z}`,()=>Gn("decode ref",()=>le(Z))),De=(Z,ee)=>ut(`c${Z}@${ee}`,()=>Gn("decode src",()=>Se(Z,ee))),Je=w??(async Z=>(await gn(Z)).frames.length),be=[],Me=new Map,Oe=new Set,bt=[];if(x?.shots.length&&!y&&Y){L(),i?.(0,t.length,`checking ${x.shots.length} claims from ${x.timelineName}`);let Z=new Map,ee=async B=>{let se=Z.get(B);return se||(se={hash:await R(t[B],"B"),frames:await Je(t[B]).catch(()=>0)},Z.set(B,se)),se},ce={refHash:B=>Y(B),srcHash:async(B,se)=>(await ee(B)).hash(se),srcFrames:B=>Z.get(B)?.frames??0,srcTimecode:async B=>{await ee(B);let se=await gn(t[B]).catch(()=>null);return se&&se.fps?{start:se.startFrame,fps:se.fps,dropFrame:se.dropFrame}:null}},ve=await H8(x.shots,t.map(B=>B.name),ce,(B,se)=>i?.(0,t.length,`checking claim ${B}/${se}`));if(a&&s)for(let B of ve){if(B.clipIndex==null||B.outcome!=="refuted"&&B.outcome!=="reframe-declined")continue;let se=B.hint,Fe=B.clipIndex,dt=se.refEnd-se.refStart+1;if(dt<3)continue;let Ie=se.refStart+se.refEnd>>1,yt=se.declaredSpeed??1,Ue=ce.srcFrames(Fe)||await Je(t[Fe]).catch(()=>0);if(!Ue)continue;let He=Math.round(se.srcStart+(Ie-se.refStart)*yt),St=await(async()=>{let Be=se.declaredTransform;if(!Be)return null;let Ee=await we(Ie),dn=await De(Fe,He),Vn=Ee&&dn?f8(Be,Ee.w,Ee.h,dn.w,dn.h):null;if(!Ee||!dn||!Vn)return null;let Ce=e8(Vn,dn.w,dn.h,Ee.w,Ee.h),yn=Nr=>De(Fe,Nr),Bn=await Kc({transform:Ce,refLuma:we,candLuma:yn,refProbe:Ie,srcProbe:He,frameCount:Ue,search:Da,runSpread:yt===1?Math.max(1,Math.floor(dt/3)):0,runSamples:yt===1?3:1}).catch(()=>null);return!Bn||!await ff(Bn,Ce,we,yn,Ie,Ns)?null:{srcAtProbe:Bn.srcFrame,score:Bn.score}})(),Qt=St??await df({refLuma:we,cand:{label:t[Fe].name,frameCount:Ue,luma:Be=>De(Fe,Be)},refProbe:Ie,srcGuess:He,radius:Da,runSpread:yt===1?Math.max(1,Math.floor(dt/3)):0,reframeOpts:M}).catch(()=>null);if(!Qt)continue;let Wt=Math.round(Qt.srcAtProbe-(Ie-se.refStart)*yt),me=Wt-se.srcStart;Oe.add(B),Object.assign(B,{srcStart:Wt,correction:me,worstDistance:Qt.score,outcome:me===0?"confirmed":"corrected",reason:`confirmed by ${St?"the declared transform":"geometry"} (the whole-frame hash could not rule: ${B.outcome==="reframe-declined"?"a declared resize":"a different grade or framing"}) \u2014 `+(me===0?"at the declared in-point":`the in-point is out by ${me>0?"+":""}${me} frame(s)`)})}be.push(...ve);for(let B of ve){if(B.clipIndex==null)continue;let se=Me.get(B.clipIndex)??{shots:[],clean:!0};if(Oe.has(B)&&B.srcStart!=null){bt.push({clipIndex:B.clipIndex,refStart:B.hint.refStart,refEnd:B.hint.refEnd,srcStart:B.srcStart,speed:B.hint.declaredSpeed??1}),se.clean=!1,Me.set(B.clipIndex,se);continue}(B.outcome==="confirmed"||B.outcome==="corrected")&&B.srcStart!=null?se.shots.push({refStart:B.hint.refStart,refEnd:B.hint.refEnd,srcStart:B.srcStart}):se.clean=!1,Me.set(B.clipIndex,se)}}let tt=v&&!y&&P>1&&N8(t.length),zt=P*ty,Ht=!z&&(g??Z8(t.length))&&t.length>1,Mt=[];if(Ht){L();for(let Z=0;Z<t.length;Z++){L();let ee=t[Z];i?.(Z/t.length,t.length,`triage ${Z+1}/${t.length} \u2014 ${ee.name}`);let ce=0;try{ce=await Je(ee)}catch{}if(ce<=0){Mt.push({clipIndex:Z,label:ee.name,hits:0,minDistance:1/0,probes:0,spacing:0});continue}let ve=F8(ce);try{let B=T?await T(ee).catch(()=>null):null,se;if(B?.length){let Fe=await R(ee,"B"),dt=[...new Set(Array.from({length:Math.ceil(ce/ve)},(Ie,yt)=>Math.min(ce-1,Bv(yt*ve,B))))];se=[];for(let Ie of dt){let yt=await Fe(Ie).catch(()=>null);yt&&se.push(yt)}}else se=(await X(ee,"B",void 0,ve)).pdq;Mt.push(V8(Z,ee.name,se,I.pdq,ve))}catch{Mt.push({clipIndex:Z,label:ee.name,hits:0,minDistance:1/0,probes:0,spacing:ve})}}Mt=j8(Mt)}let mt=z?t.map((Z,ee)=>ee).filter(Z=>Me.get(Z)?.clean&&Me.get(Z).shots.length):Ht?Mt.map(Z=>Z.clipIndex):t.map((Z,ee)=>ee),K=new Map(Mt.map(Z=>[Z.clipIndex,Z])),fe=new Uint8Array(q.offs.length),Xe=0,et=-1/0,ft=[],At=async(Z,ee,ce,ve)=>{let B=[];for(let se of ee){let Fe=Math.min(5,Math.max(1,se.count)),dt=[];for(let Ue=0;Ue<Fe;Ue++){let He=Fe===1?se.count>>1:Math.round(Ue*(se.count-1)/(Fe-1)),[St,Qt]=await Promise.all([we(se.refStart+He),De(Z,ce(se.srcStart+He))]);if(St&&Qt){let Wt=await Br(Qt.y,Qt.w,Qt.h,St.y,St.w,St.h,M),me=Wt.ok?$o(Wt,St.w,St.h):null;dt.push({refFrame:se.refStart+He,reframe:me,geometry:Wt})}else dt.push({refFrame:se.refStart+He,reframe:null,geometry:null})}let Ie=bp(dt.map(Ue=>({refFrame:Ue.refFrame,reframe:Ue.reframe}))),yt=dt[dt.length>>1];B.push({refStart:se.refStart,refEnd:se.refStart+se.count-1,srcStart:ce(se.srcStart),srcEnd:ce(se.srcStart+se.count-1),reframe:Ie.kind==="unresolved"?null:Ie.keyframes[Ie.keyframes.length>>1]?.reframe??null,geometry:yt.geometry,track:Ie,score:ve(se),contestedBy:null})}return B.sort((se,Fe)=>se.refStart-Fe.refStart),B},Nt=Z=>({offs:Z.frames,codec:Z.index?.codec??Z.label,kind:Z.spec?Z.spec.codec:Z.index?.kind??"other",w:Z.w,h:Z.h,fps:Z.fps,startFrame:Z.startFrame,dropFrame:Z.dropFrame}),Jt=2,nn=new Map,Ge=new Map,it=Z=>(Z.catch(()=>{}),Z),Rt=Z=>{let ee=mt[Z];ee==null||tt||Me.get(ee)?.clean&&Me.get(ee).shots.length||(nn.has(ee)||nn.set(ee,it(X(t[ee],"B",void 0,P))),h&&!Ge.has(ee)&&Ge.set(ee,it(h(t[ee]))))};for(let Z=0;Z<mt.length;Z++){let ee=mt[Z],ce=t[ee];L();for(let me=1;me<=Jt;me++)Rt(Z+me);let ve=Me.get(ee);if(ve?.clean&&ve.shots.length){i?.(Z,t.length,`${ce.name} \u2014 confirmed from the timeline`);let me=await gn(ce),Be=Nt(me);j[ee]=Be,H[ee]=1;let Ee=ve.shots.map(Ce=>({refStart:Ce.refStart,srcStart:Ce.srcStart,count:Ce.refEnd-Ce.refStart+1})).sort((Ce,yn)=>Ce.refStart-yn.refStart),dn=await At(ee,Ee,Ce=>Ce,()=>0),Vn=Ee.reduce((Ce,yn)=>Ce+yn.count,0);D.push({clipIndex:ee,label:ce.name,shots:dn,coverage:Be.offs.length?Vn/Be.offs.length:0,srcFps:Be.fps,srcStartFrame:Be.startFrame,srcDropFrame:Be.dropFrame,srcFrames:Be.offs.length,srcW:Be.w||null,srcH:Be.h||null,codec:ko(Be.kind),geometrySupported:Be.kind==="prores"||!!a&&!!s,warnings:[]});for(let Ce of Ee)for(let yn=Math.max(0,Ce.refStart);yn<Math.min(fe.length,Ce.refStart+Ce.count);yn++)fe[yn]||(fe[yn]=1);Xe=0,et===-1/0&&(et=0);continue}if(!y&&Ht&&Xe>=Pp&&Number.isFinite(et)){let me=K.get(ee);if(W8({coverageComplete:fe.length>0&&I8(fe)<=P,dryStreak:Xe,worstContributor:et,nextScore:me?.minDistance??1/0})){for(let Be=Z;Be<mt.length;Be++)ft.push(mt[Be]);break}}if(i?.(Z,t.length,`matching ${ce.name}`),tt){let me=await X(ce,"B",(Ee,dn)=>i?.(Z+(dn?Ee/dn:0),t.length,`screening ${ce.name} \u2014 frame ${Ee}/${dn}`),zt),Be=X8(me.pdq,I.pdq);if(Be.skip){let Ee=me.index;D.push({clipIndex:ee,label:ce.name,shots:[],coverage:0,srcFps:Ee.fps,srcStartFrame:Ee.startFrame,srcDropFrame:Ee.dropFrame,srcFrames:Ee.offs.length,srcW:Ee.w||null,srcH:Ee.h||null,codec:ko(Ee.kind),geometrySupported:!1,warnings:[`${O8} ${Be.reason}. A contribution shorter than ${L8(P)} source frames could be missed at this screening density \u2014 re-run with the screen disabled if a shot you expected is absent.`]}),j[ee]=Ee,H[ee]=1,Xe++;continue}}let B=await(nn.get(ee)??X(ce,"B",(me,Be)=>i?.(Z+(Be?me/Be:0),t.length,`fingerprinting ${ce.name} \u2014 frame ${me}/${Be}`),P));nn.delete(ee);let se=pp(I,B),Fe=B.index;j[ee]=Fe;let dt=eC(se.report.ops);if(P>1&&Y){let me=dt.map(Be=>({refStart:Be.refStart*P,srcStart:Be.srcStart*P,count:(Be.count-1)*P+1}));dt=await Jk(me,Y,await R(ce,"B"),{stride:P,threshold:An,refFrames:q.offs.length,srcFrames:Fe.offs.length})}let Ie=se.rateScale,yt=me=>Math.round(me*Ie),Ue=h?await(Ge.get(ee)??h(ce)):null;Ge.delete(ee),C.push({clipIndex:ee,label:ce.name,pdq:se.bPdq,embed:Ue?se.bPdq.map((me,Be)=>Ue[Math.min(Ue.length-1,yt(Be))]):void 0}),H[ee]=Ie;let He=await At(ee,dt,yt,me=>_E(I.pdq,se.bPdq,me)),St=dt.reduce((me,Be)=>me+Be.count,0),Qt=Fe.offs.length?St/Fe.offs.length:0;D.push({clipIndex:ee,label:ce.name,shots:He,coverage:Qt,srcFps:Fe.fps,srcStartFrame:Fe.startFrame,srcDropFrame:Fe.dropFrame,srcFrames:Fe.offs.length,srcW:Fe.w||null,srcH:Fe.h||null,codec:ko(Fe.kind),geometrySupported:Fe.kind==="prores"||!!a&&!!s,warnings:se.warnings});let Wt=0;for(let me of He)for(let Be=Math.max(0,me.refStart);Be<=Math.min(fe.length-1,me.refEnd);Be++)fe[Be]||(fe[Be]=1,Wt++);if(Wt>0){Xe=0;let me=K.get(ee);me&&me.minDistance>et&&(et=me.minDistance)}else Xe++}let rn=[],Ln=[],Sn=new Set,Et=new Set,Tr=new Map;if(z){L();let Z=q.offs.length,ee=t.map(()=>null),ce=0,ve=0;await Promise.all(Array.from({length:c5},async()=>{for(;ce<t.length;){let V=ce++;L(),!(Me.get(V)?.clean&&Me.get(V).shots.length)&&(ee[V]=await z.index(V).catch(()=>null),i?.(++ve,t.length,`indexing ${t[V].name}`))}}));let B=ee.filter(V=>!!V&&V.vecs.length>0),se=new Map(B.map(V=>[V.clipIndex,V.stride])),Fe=V=>se.get(V)??24,dt=new Map,Ie=async V=>{let F=dt.get(V);if(!F){if(F=Nt(await gn(t[V])),!F.offs.length){let W=await Je(t[V]).catch(()=>0);W>0&&(F={...F,offs:Array.from({length:W},()=>({offset:0,size:0}))})}dt.set(V,F)}return F},yt=q.fps||24;for(let V of B){let F=await Ie(V.clipIndex).catch(()=>null);H[V.clipIndex]=F?.fps?F.fps/yt:1}let Ue=V=>H[V]??1;if(x?.shots.length){let V=new Set;for(let F of x.shots)F.refStart>0&&V.add(F.refStart),F.refEnd+1<Z&&V.add(F.refEnd+1);rn=[...V].filter(F=>F>0&&F<Z).sort((F,W)=>F-W)}else rn=n5(ea(I.pdq)).map(V=>V*P);let He=r5(Z,rn).filter(V=>{let F=0;for(let W=V.refStart;W<=V.refEnd;W++)F+=fe[W]?1:0;return F<(V.refEnd-V.refStart+1)/2}),St=He.map(V=>Fp(V)),Qt=[...new Set(St.flat())];i?.(0,He.length,`describing ${He.length} shots`);let Wt=await z.embedRef(Qt,(V,F)=>i?.(V,F,`describing ${He.length} shots`)),me=new Map(Qt.map((V,F)=>[V,Wt[F]]));if(z.indexFine){let V=new Set;for(let oe of He){let U=Fp(oe).map(Pe=>({frame:Pe,vec:me.get(Pe)})).filter(Pe=>Pe.vec);if(U.length)for(let Pe of ay(U,B,oe.refStart+oe.refEnd>>1,Ue,4))Fe(Pe.clipIndex)>24&&V.add(Pe.clipIndex)}let F=[...V],W=0,de=0;await Promise.all(Array.from({length:c5},async()=>{for(;W<F.length;){let oe=F[W++];L();let U=await z.indexFine(oe).catch(()=>null);if(U?.vecs.length){let Pe=B.findIndex(re=>re.clipIndex===oe);Pe>=0&&(B[Pe]=U),se.set(oe,U.stride)}i?.(++de,F.length,`indexing nominated takes finely: ${t[oe].name}`)}})),typeof process<"u"&&process.env?.CONFORM_DEBUG_NOMINATIONS&&console.error(`[find-first] fine index for ${F.length} nominated long-GOP clip(s)`)}let Be=new Map,Ee=typeof process<"u"&&!!process.env?.CONFORM_DEBUG_NOMINATIONS,dn=S?(async()=>{let V=performance.now(),F=await S("ref").catch(()=>null);if(!F||F.length<8e3)return null;let W=new qa;return await Promise.all(t.map(async(de,oe)=>{let U=await S(oe).catch(()=>null);U&&U.length>=8e3&&W.add(oe,U)})),Ee&&console.error(`[find-first] audio index: ${W.clips.size}/${t.length} clips with sound, ${W.size} hashes, ${Math.round(performance.now()-V)} ms`),W.clips.size?{ix:W,ref:qa.reference(F)}:null})().catch(()=>null):Promise.resolve(null),Vn=async(V,F)=>{let W=await dn;if(!W)return[];let de=V.refStart/yt,oe=(V.refEnd+1)/yt;if(oe-de<1){let Pe=(de+oe)/2;de=Math.max(0,Pe-.5),oe=Pe+.5}let U=[];for(let Pe of W.ix.nominate(W.ref,de,oe)){if(!t5(Pe))continue;let re=await Ie(Pe.clip).catch(()=>null);re?.fps&&U.push({ci:Pe.clip,srcAtProbe:Math.round((F/yt+Pe.shiftSec)*re.fps),votes:Pe.votes,rival:Pe.rival})}return U},Ce=new Map,yn=V=>{let F=Ce.get(V);return F||(F=Gn("dense fingerprint",()=>X(t[V],"B",void 0,P)).then(W=>W.pdq).catch(()=>[]),Ce.set(V,F)),F},Bn=async(V,F,W,de,oe)=>{if(P!==1||Ue(V)!==1||!F.length)return null;let U=oe-de,Pe=xe=>{let E=[],ke=Math.max(1,Math.floor((W.refEnd-W.refStart+1)/120));for(let Te=W.refStart;Te<=W.refEnd;Te+=ke){let Ze=Te+xe;if(Ze<0||Ze>=F.length||!I.pdq[Te])continue;let at=fn(I.pdq[Te],F[Ze]);Number.isFinite(at)&&E.push(at)}return E.length<8?1/0:(E.sort((Te,Ze)=>Te-Ze),E[E.length>>1])},re=U,te=1/0;for(let xe=-6;xe<=6;xe++){let E=Pe(U+xe);E<te&&(te=E,re=U+xe)}let Q=1/0;for(let xe of[-48,-24,-12,12,24,48])Q=Math.min(Q,Pe(re+xe));if(Ee&&console.error(`[find-first] sequence: median ${te} bits at offset ${re} (guess ${U}) vs ${Q} around`),!(te<=An)||!(Q-te>=WE))return null;let pe=await we(de),Re=await De(V,de+re);if(!pe||!Re)return null;let $=await Br(Re.y,Re.w,Re.h,pe.y,pe.w,pe.h,M);return!$.ok||$.inliers<25?null:(Ee&&console.error(`[find-first] sequence: median ${te} bits at offset ${re} vs ${Q} around, ORB ${$.inliers}`),{srcAtProbe:de+re,score:te})},Nr=async(V,F,W,de)=>{let oe={srcAtProbe:de,r:NaN,ambiguous:!0};if(P!==1||Ue(V)!==1)return oe;let U=Math.max(F.refStart,W-240),Pe=Math.min(F.refEnd,W+240);if(Pe-U<hf)return oe;let re=ea(I.pdq,U,Pe),te=de-W,Q=sy,pe=await Ie(V).catch(()=>null);if(!pe)return oe;let Re=Math.max(0,U+te-Q),$=Math.min(pe.offs.length-1,Pe+te+Q+1),xe,E=Ce.has(V)||pe.offs.length<=DE?await yn(V):[];if(E.length===pe.offs.length)xe=E.slice(Re,$+1);else{let J=await $D(V);xe=await Promise.all(Array.from({length:$-Re+1},(ie,nt)=>Gn("motion hash",()=>J(Re+nt)).catch(()=>null)))}let ke=J=>{let ie=xe[J-Re],nt=xe[J+1-Re];return ie&&nt?fn(ie,nt):NaN},Te=J=>{let ie=0,nt=0,st=0,Ot=0,Zt=0,dr=0;for(let $n=0;$n<re.length;$n++){let bn=ke(U+$n+J);if(!Number.isFinite(bn))continue;let er=re[$n];ie++,nt+=er,st+=bn,Ot+=er*er,Zt+=bn*bn,dr+=er*bn}if(ie<hf)return NaN;let ki=(Ot-nt*nt/ie)*(Zt-st*st/ie);return ki>1e-9?(dr-nt*st/ie)/Math.sqrt(ki):NaN},Ze=new Map;for(let J=te-Q;J<=te+Q;J++){let ie=Te(J);Number.isFinite(ie)&&Ze.set(J,ie)}if(!Ze.size)return oe;let at=[...Ze].filter(([J,ie])=>ie>=(Ze.get(J-1)??-2)&&ie>=(Ze.get(J+1)??-2)).map(([J,ie])=>({off:J,r:ie})).sort((J,ie)=>ie.r-J.r),kt=at[0];if(!kt)return oe;let sn=at.find(J=>Math.abs(J.off-kt.off)>3)?.r??-1;if(kt.r<.6||kt.r-sn<.1)return{...oe,r:kt.r};if(kt.off===te)return{srcAtProbe:de,r:kt.r,ambiguous:!1};let Yt=await we(W),jt=await De(V,W+kt.off);if(!Yt||!jt)return{...oe,r:kt.r};let xn=await Br(jt.y,jt.w,jt.h,Yt.y,Yt.w,Yt.h,M);return!xn.ok||xn.inliers<25?{...oe,r:kt.r}:{srcAtProbe:W+kt.off,r:kt.r,ambiguous:!1}},Xn=new Map,N=(V,F)=>{let W=Xn.get(V);return W||(W=F().then(de=>jn(de)).catch(()=>null),Xn.set(V,W)),W},ue=(V,F,W)=>{let de=Xn.get(V);return de||(de=F().then(oe=>hi(oe,W.refToSrc,W.refW,W.refH)).catch(()=>null),Xn.set(V,de)),de},We=async(V,F,W,de)=>{if(!V.transform)return null;let[oe,U]=await Promise.all([we(de),De(F,W)]);if(!oe||!U)return null;let Pe=(V.srcW??U.w)/U.w,re=(V.srcH??U.h)/U.h,te=V.transform,Q=[te[0]*Pe,te[1]*re,te[2],te[3]*Pe,te[4]*re,te[5],te[6]*Pe,te[7]*re,te[8]];if(Math.abs(Q[0]*U.w/oe.w-1)<.005&&Math.abs(Q[4]*U.h/oe.h-1)<.005&&Math.abs(Q[1])<.001&&Math.abs(Q[3])<.001&&Math.abs(Q[2])<1&&Math.abs(Q[5])<1)return null;let Re=ao(Q);return Re?{refToSrc:Re,refW:oe.w,refH:oe.h,srcW:U.w,srcH:U.h}:null},Ae=async(V,F,W,de,oe,U)=>{let Pe=await Ie(V).catch(()=>null);if(!Pe)return null;let re=Math.max(0,F+de-oe),te=Math.min(Pe.offs.length-1,F+de+oe+W);if(te-re<W)return null;let Q=U?U.refToSrc.map(xe=>xe.toFixed(4)).join(","):"",[pe,Re]=await Promise.all([Promise.all(Array.from({length:W},(xe,E)=>N(`r@${F+E}`,()=>we(F+E)))),Promise.all(Array.from({length:te-re+1},(xe,E)=>U?ue(`w${V}@${re+E}|${Q}`,()=>De(V,re+E),U):N(`c${V}@${re+E}`,()=>De(V,re+E))))]),$=ta(pe,Re,re,F+de-oe,F+de+oe);return $?{...$,off:$.src-F}:null},pt=async(V,F,W,de)=>{let oe=F.refEnd-F.refStart+1;if(Ue(V)!==1||oe<8)return null;let U=Math.min(96,oe),Pe=F.refStart+(oe-U>>1),re=await Gn("map confirm",()=>Ae(V,Pe,U,de-W,i5));if(Ee&&console.error(`[find-first] map confirm ${t[V].name}@${de}: ${re?`${W+re.off} (score ${re.score.toFixed(2)}, margin ${re.margin.toFixed(2)})`:"\u2013"}`),!re||re.score<.4||re.margin<.2)return null;let te=await we(W),Q=await De(V,W+re.off),pe=te&&Q?await Br(Q.y,Q.w,Q.h,te.y,te.w,te.h,M).catch(()=>null):null;return{srcAtProbe:W+re.off,score:An,transform:pe?.ok?pe.transform:null,srcW:pe?.ok?pe.srcW:void 0,srcH:pe?.ok?pe.srcH:void 0,refPlane:te??{y:new Uint8Array(0),w:0,h:0}}},qe=async(V,F,W,de,oe=jp)=>{let U=await Ie(V).catch(()=>null);if(!U)return null;let Pe=U.offs.length,re=Oi(F.refStart,F.refEnd,cy).filter(ie=>ie+W>=0&&ie+W<Pe);if(re.length<3)return null;let te=(await Gn("sz: pair reads",()=>Promise.all(re.map(async ie=>{let[nt,st]=await Promise.all([we(ie),De(V,ie+W)]);return nt&&st?{ref:nt,src:st}:null})))).filter(ie=>!!ie);if(te.length<3)return null;let Q=await Gn("sz: fit",()=>Mi(te,oe));if(!Q)return null;let pe={srcW:te[0].src.w,srcH:te[0].src.h,refW:te[0].ref.w,refH:te[0].ref.h},Re={fit:Q,...pe},$=ao(Q.transform);if(!$)return{...Re,off:W,map:null,margin:0};let xe=F.refEnd-F.refStart+1,E=Math.min(96,xe),ke=F.refStart+(xe-E>>1),Te=Math.max(0,ke+W-de),Ze=Math.min(Pe-1,ke+W+de+E);if(Ze-Te<E)return{...Re,off:W,map:null,margin:0};let{refW:at,refH:kt}=Re,sn=$.map(ie=>ie.toFixed(4)).join(","),[Yt,jt]=await Gn("sz: map block",()=>Promise.all([Promise.all(Array.from({length:E},(ie,nt)=>N(`r@${ke+nt}`,()=>we(ke+nt)))),Promise.all(Array.from({length:Ze-Te+1},async(ie,nt)=>{let st=`w${V}@${Te+nt}|${sn}`,Ot=Xn.get(st);return Ot||(Ot=De(V,Te+nt).then(Zt=>hi(Zt,$,at,kt)).catch(()=>null),Xn.set(st,Ot)),Ot}))])),xn=ta(Yt,jt,Te,ke+W-de,ke+W+de);if(!xn)return{...Re,off:W,map:null,margin:0};let J=xn.src-ke;if(J!==W){let ie=(await Promise.all(re.filter(st=>st+J>=0&&st+J<Pe).map(async st=>{let[Ot,Zt]=await Promise.all([we(st),De(V,st+J)]);return Ot&&Zt?{ref:Ot,src:Zt}:null}))).filter(st=>!!st),nt=ie.length>=3?await Mi(ie,oe):null;if(!nt)return{...Re,off:J,map:null,margin:0};Re={fit:nt,...pe}}return{...Re,off:J,map:xn.score,margin:xn.margin}},ht=new Map,ot=(V,F)=>{let W=ht.get(V);W||(ht.size>=3&&ht.delete(ht.keys().next().value),W=new Map,ht.set(V,W));let de=W.get(F);return de||(de=Gn("take scan",()=>(k??Se)(V,F)).then(oe=>oe?CE(oe,EE):null).catch(()=>null),W.set(F,de)),de},Ye=async(V,F,W,de,oe)=>{let U=await Ie(V).catch(()=>null);if(!U)return null;let Pe=U.offs.length,re=(await Promise.all(Oi(F.refStart,F.refEnd,cy).map(async Q=>{let pe=Math.round(de+(Q-W)*oe);if(pe<0||pe>=Pe)return null;let[Re,$]=await Promise.all([we(Q),De(V,pe)]);return Re&&$?{ref:Re,src:$}:null}))).filter(Q=>!!Q);if(re.length<3)return null;let te=await Mi(re,jp);return te?{fit:te,srcW:re[0].src.w,srcH:re[0].src.h,refW:re[0].ref.w,refH:re[0].ref.h}:null},Qe=async(V,F,W,de,oe)=>{let U=[...new Set([Ue(V),1])],Pe=null,re=async(Q,pe)=>{let Re=await Gn("off-rate sizing",()=>Ye(V,F,W,Q,pe)).catch(()=>null);Re&&(!Pe||Re.fit.score>Pe.v.fit.score)&&(Pe={at:Q,rate:pe,v:Re})};for(let Q of U)for(let pe=-oe;pe<=oe;pe+=fy)await re(de+pe,Q);let te=Pe;if(te)for(let Q=-fy+1;Q<fy;Q++)Q&&await re(te.at+Q,te.rate);return Pe},gt=async(V,F,W,de=jp)=>{let oe=await Ie(V).catch(()=>null);if(!oe)return null;let U=oe.offs.length,Pe=(await Promise.all(Oi(F.refStart,F.refEnd,cy).filter(Q=>Q+W>=0&&Q+W<U).map(async Q=>{let[pe,Re]=await Promise.all([we(Q),De(V,Q+W)]);return pe&&Re?{ref:pe,src:Re}:null}))).filter(Q=>!!Q);if(Pe.length<3)return null;let re=await Mi(Pe,de),te=re?ao(re.transform):null;return re&&te?{fit:re,srcW:Pe[0].src.w,srcH:Pe[0].src.h,warp:{refToSrc:te,refW:Pe[0].ref.w,refH:Pe[0].ref.h,srcW:Pe[0].src.w,srcH:Pe[0].src.h}}:null},en=async(V,F,W,de)=>{let oe=await Ie(V).catch(()=>null);if(!oe)return null;let U=F.refEnd-F.refStart+1,Pe=Math.min(96,U),re=F.refStart+(U-Pe>>1),te=oe.offs.length,Q=te<=oi?0:Math.max(0,Math.min(te-oi,re+de-(oi>>1))),pe=Math.min(te,Q+oi);if(pe-Q<Pe+2)return null;let Re=await Promise.all(Array.from({length:Pe},(Te,Ze)=>N(`r@${re+Ze}`,()=>we(re+Ze)))),$=W?W.refToSrc.map(Te=>Te.toFixed(4)).join(","):"",xe=new Array(pe-Q).fill(null);for(let Te=Q;Te<pe;Te+=_c)L(),await Promise.all(Array.from({length:Math.min(_c,pe-Te)},async(Ze,at)=>{let kt=Te+at,sn=W?`w${V}@${kt}|${$}`:`c${V}@${kt}`,Yt=Xn.get(sn);Yt||(Yt=ot(V,kt).then(jt=>{if(!jt||!W)return jn(jt);let xn=jt.w/W.srcW,J=jt.h/W.srcH,ie=W.refToSrc;return hi(jt,[ie[0]*xn,ie[1]*xn,ie[2]*xn,ie[3]*J,ie[4]*J,ie[5]*J,ie[6],ie[7],ie[8]],W.refW,W.refH)}).catch(()=>null),Xn.set(sn,Yt)),xe[kt-Q]=await Yt}));let E=ta(Re,xe,Q,Q,pe-Pe),ke=U8(Re,xe,Q,Q,pe-Pe,ly).map(Te=>({off:Te.src-re,score:Te.score}));return E?{off:E.src-re,score:E.score,margin:E.margin,peaks:ke}:null},Pt=8,Bt=6,Vt=V=>{let F=new Uint8Array(V.y.length);for(let W=0;W<V.h;W++)for(let de=0;de<V.w;de++)F[W*V.w+de]=V.y[W*V.w+(V.w-1-de)];return{y:F,w:V.w,h:V.h}},kn=async(V,F,W,de=!1)=>{let oe=await Ie(V).catch(()=>null);if(!oe)return null;let U=F.refStart+F.refEnd>>1,Pe=await we(U);if(!Pe)return null;let re=de?Vt(Pe):Pe,te=oe.offs.length,Q=te<=oi?0:Math.max(0,Math.min(te-oi,U+W-(oi>>1))),pe=Math.min(te,Q+oi),Re=[],$=[];for(let ke=Q;ke<pe;ke+=Pt)$.push(ke);let xe=0;for(let ke=0;ke<$.length;ke+=Bt)L(),await Promise.all($.slice(ke,ke+Bt).map(async Te=>{let Ze=await De(V,Te).catch(()=>null);if(!Ze){xe++;return}let at=await Gn("orb scan",()=>Br(Ze.y,Ze.w,Ze.h,re.y,re.w,re.h,M)).catch(()=>null);if(!at){xe++;return}Re.push({g:Te,inl:at.ok?at.inliers:0})}));if(Ee&&console.error(`[find-first] orb scan ${t[V].name}: ${Re.length} frames (${xe} failed), best inliers ${Math.max(0,...Re.map(ke=>ke.inl))}`),!Re.length)return null;Re.sort((ke,Te)=>Te.inl-ke.inl);let E=[];for(let ke of Re)if(ke.inl<12||(E.every(Te=>Math.abs(Te.off-(ke.g-U))>3*Pt)&&E.push({off:ke.g-U,score:ke.inl/100}),E.length>=ly))break;return E.length?{off:E[0].off,score:E[0].score,margin:E[0].score-(E[1]?.score??0),peaks:E}:null},Dn=6,ir=4,Lt=V=>{let F=t[V].path??t[V].name;return F.slice(0,F.lastIndexOf("/")+1)},Qn=async(V,F,W)=>{let de=await we(V.refStart+V.refEnd>>1);if(!de||HE(de)<qE)return null;let oe=V.refStart+V.refEnd>>1,U=[],Pe=($,xe)=>{!U.some(E=>E.ci===$)&&U.length<Dn&&U.push({ci:$,near:xe})};for(let $ of W.slice(0,4))Pe($.clipIndex,$.srcAtProbe-F);for(let $ of W.slice(0,2))for(let xe=0;xe<t.length;xe++)Lt(xe)===Lt($.clipIndex)&&Pe(xe,0);let re=async $=>{let xe=[];return await Promise.all(U.map(async E=>{let ke=await kn(E.ci,V,E.near,$).catch(()=>null);if(Ee&&console.error(`[find-first] rescue scan${$?" (mirrored)":""} ${t[E.ci].name}: ${ke?ke.peaks.map(Te=>`${oe+Te.off}:${Math.round(Te.score*100)}`).join(" "):"\u2013"}`),ke)for(let Te of ke.peaks)xe.push({ci:E.ci,off:Te.off,inl:Te.score})})),xe.sort((E,ke)=>ke.inl-E.inl)},te=await re(!1);te.length||(te=await re(!0));let Q=[];for(let $ of te.slice(0,ir)){let xe=Ue($.ci);if(xe!==1){let ke=Math.round(oe+$.off+(F-oe)*xe),Te=await Gn("rescue sizing",()=>Qe($.ci,V,F,ke,Pt)).catch(()=>null);if(!Te)continue;let Ze=Te.at,at=ao(Te.v.fit.transform);if(at){let kt={refToSrc:at,refW:Te.v.refW,refH:Te.v.refH,srcW:Te.v.srcW,srcH:Te.v.srcH},sn=V.refEnd-V.refStart+1,Yt=Math.min(96,sn),jt=V.refStart+(sn-Yt>>1),xn=Ze/Te.rate-F,J=Te.rate===1?await Ae($.ci,jt,Yt,Math.round(Ze-F),48,kt).catch(()=>null):await qt($.ci,jt,Yt,xn,48,kt,Te.rate).catch(()=>null);Ee&&console.error(`[find-first] rescue polish ${t[$.ci].name}: ${Ze} \u2192 ${J?`${Math.round((F+J.off)*(Te.rate===1?1:Te.rate))} (score ${J.score.toFixed(2)}, margin ${J.margin.toFixed(2)})`:"\u2013"}`),J&&J.score>=.3&&J.margin>=.05&&(Ze=Te.rate===1?F+J.off:Math.round((F+J.off)*Te.rate))}Q.push({ci:$.ci,agree:Te.v.fit.score,ok:{clipIndex:$.ci,srcAtProbe:Ze,score:An,transform:Te.v.fit.transform,srcW:Te.v.srcW,srcH:Te.v.srcH,refW:Te.v.refW,refH:Te.v.refH}});continue}let E=null;for(let ke=-Pt/2;ke<=Pt/2;ke+=2){let Te=await Gn("rescue sizing",()=>gt($.ci,V,$.off+ke,{})).catch(()=>null);Te&&(!E||Te.fit.score>E.sw.fit.score)&&(E={off:$.off+ke,sw:Te})}if(E)for(let ke=-1;ke<=1;ke+=2){let Te=await gt($.ci,V,E.off+ke,{}).catch(()=>null);Te&&Te.fit.score>E.sw.fit.score&&(E={off:E.off+ke,sw:Te})}E&&Q.push({ci:$.ci,agree:E.sw.fit.score,ok:{clipIndex:$.ci,srcAtProbe:F+E.off,score:An,transform:E.sw.fit.transform,srcW:E.sw.srcW,srcH:E.sw.srcH,refW:E.sw.warp.refW,refH:E.sw.warp.refH}})}Q.sort(($,xe)=>xe.agree-$.agree);let pe=Q[0],Re=Q.find($=>$.ci!==pe?.ci)?.agree??0;return Ee&&console.error(`[find-first] rescue ${V.refStart}\u2013${V.refEnd}: ${U.length} takes, ${te.length} peaks; best ${pe?`${t[pe.ci].name}@${pe.ok.srcAtProbe} agreement ${pe.agree.toFixed(2)} (other takes ${Re.toFixed(2)})`:"\u2013"}`),!pe||pe.agree<yf||pe.agree<Re+.1?null:pe.ok},fr=96,En=V=>{if(!V)return null;let F=fr,W=V.length/F,de=new Float32Array(2*V.length);for(let oe=0;oe<W;oe++)for(let U=0;U<F;U++){let Pe=oe*F+U;de[Pe]=V[oe*F+Math.min(F-1,U+1)]-V[oe*F+Math.max(0,U-1)],de[V.length+Pe]=V[Math.min(W-1,oe+1)*F+U]-V[Math.max(0,oe-1)*F+U]}return de},mn=async(V,F,W,de)=>{let oe=await Ie(V).catch(()=>null);if(!oe)return null;let U=F.refEnd-F.refStart+1,Pe=U>=5?[F.refStart+1,F.refStart+F.refEnd>>1,F.refEnd-1]:[F.refStart+F.refEnd>>1],re=oe.offs.length,te=re<=oi?0:Math.max(0,Math.min(re-oi,Pe[0]+de-(oi>>1))),Q=Math.min(re,te+oi);if(Q-te<U+2)return null;let pe=await Promise.all(Pe.map(Ze=>we(Ze).then(at=>En(jn(at,fr))).catch(()=>null))),Re=W?W.refToSrc.map(Ze=>Ze.toFixed(4)).join(","):"",$=new Array(Q-te).fill(null);for(let Ze=te;Ze<Q;Ze+=_c)L(),await Promise.all(Array.from({length:Math.min(_c,Q-Ze)},async(at,kt)=>{let sn=Ze+kt,Yt=`a${fr}${V}@${sn}|${Re}`,jt=Xn.get(Yt);jt||(jt=ot(V,sn).then(xn=>{if(!xn)return null;if(!W)return En(jn(xn,fr));let J=xn.w/W.srcW,ie=xn.h/W.srcH,nt=W.refToSrc;return En(hi(xn,[nt[0]*J,nt[1]*J,nt[2]*J,nt[3]*ie,nt[4]*ie,nt[5]*ie,nt[6],nt[7],nt[8]],W.refW,W.refH,fr))}).catch(()=>null),Xn.set(Yt,jt)),$[sn-te]=await jt}));let xe=(Ze,at)=>{let kt=0,sn=0;for(let J=0;J<Ze.length;J++)kt+=Ze[J],sn+=at[J];kt/=Ze.length,sn/=at.length;let Yt=0,jt=0,xn=0;for(let J=0;J<Ze.length;J++){let ie=Ze[J]-kt,nt=at[J]-sn;Yt+=ie*nt,jt+=ie*ie,xn+=nt*nt}return jt>0&&xn>0?Yt/Math.sqrt(jt*xn):0},E=[];for(let Ze=te;Ze+(Pe[Pe.length-1]-Pe[0])<Q;Ze++){let at=Ze-Pe[0],kt=0,sn=0;for(let Yt=0;Yt<Pe.length;Yt++){let jt=$[Pe[Yt]+at-te],xn=pe[Yt];jt&&xn&&(kt+=xe(xn,jt),sn++)}sn&&E.push({off:at,score:kt/sn})}if(!E.length)return null;E.sort((Ze,at)=>at.score-Ze.score);let ke=[];for(let Ze of E)if(ke.every(at=>Math.abs(at.off-Ze.off)>12)&&ke.push(Ze),ke.length>=ly)break;let Te=E.find(Ze=>Math.abs(Ze.off-ke[0].off)>2)?.score??0;return{off:ke[0].off,score:ke[0].score,margin:ke[0].score-Te,peaks:ke}},_t=240,lt=async(V,F,W,de,oe)=>{let U=[{refStart:F,refEnd:W,off:de}];if(W-F+1<288)return U;let re=[];for(let $=F;$+96/2<=W;$+=96){let xe=Math.min(96,W-$+1),E=await Ae(V,$,xe,de,2,oe),ke=de,Te=!!E&&E.score>=.5;if(!E||E.score<.5){let Ze=await Ae(V,$,xe,de,_t,oe);Ze&&Ze.margin>=.1&&Math.abs(Ze.off-de)>2?ke=Ze.off:Ze&&Math.abs(Ze.off-de)<=2&&(Te=!0)}re.push({a:$,len:xe,off:ke,backed:Te})}let te=($,xe)=>Math.abs($-xe)<=1,Q=re.map(($,xe)=>$.off!==de&&[xe-1,xe+1].some(E=>E>=0&&E<re.length&&te(re[E].off,$.off)));for(let $=0;$<re.length;$++)re[$].off!==de&&!Q[$]&&(re[$].off=de);for(let $=1;$<re.length;$++)re[$].off!==de&&te(re[$].off,re[$-1].off)&&(re[$].off=re[$-1].off);if(re.some($=>$.off!==de))for(let $=0;$<re.length;$++){if(re[$].off!==de||re[$].backed)continue;let xe=[re[$-1],re[$+1]].find(E=>E&&E.off!==de);xe&&(re[$].off=xe.off)}if(re.every($=>$.off===de))return U;let pe=[];for(let $ of re){let xe=pe[pe.length-1];xe&&xe.off===$.off?xe.refEnd=$.a+$.len-1:pe.push({refStart:$.a,refEnd:$.a+$.len-1,off:$.off})}pe[pe.length-1].refEnd=W;let Re=async($,xe)=>{let[E,ke,Te,Ze]=await Promise.all([N(`r@${$}`,()=>we($)),N(`r@${$+1}`,()=>we($+1)),...[$+xe,$+xe+1].map(kt=>oe?ue(`w${V}@${kt}|${oe.refToSrc.map(sn=>sn.toFixed(4)).join(",")}`,()=>De(V,kt),oe):N(`c${V}@${kt}`,()=>De(V,kt)))]),at=ta([E,ke],[Te,Ze],$+xe,$+xe,$+xe);return at?at.score:0};for(let $=1;$<pe.length;$++){let xe=pe[$-1],E=pe[$],ke=Math.max(xe.refStart+1,E.refStart-96),Te=Math.min(E.refEnd-1,E.refStart+96),Ze=await Promise.all(Array.from({length:Te-ke+1},(Yt,jt)=>Re(ke+jt,xe.off))),at=await Promise.all(Array.from({length:Te-ke+1},(Yt,jt)=>Re(ke+jt,E.off))),kt=E.refStart,sn=-1/0;for(let Yt=ke;Yt<=Te;Yt++){let jt=0;for(let xn=0;xn<=Te-ke;xn++)jt+=ke+xn<Yt?Ze[xn]:at[xn];jt>sn&&(sn=jt,kt=Yt)}xe.refEnd=kt-1,E.refStart=kt}return Ee&&console.error(`[find-first] split ${F}\u2013${W}: ${pe.map($=>`${$.refStart}\u2013${$.refEnd}@${$.off}`).join(", ")}`),pe.filter($=>$.refEnd>=$.refStart)},Ne=18,$e=2.5,Ke=240,Ft=5,Ct=96,wn=.6,un=.03,pn=3,hn=async V=>{let[F,W]=await Promise.all([_n(V),_n(V+1)]);if(!F||!W)return 0;let de=0;for(let U=0;U<F.length;U++)de+=W[U]-F[U];de/=F.length;let oe=0;for(let U=0;U<F.length;U++){let Pe=W[U]-F[U]-de;oe+=Pe*Pe}return Math.sqrt(oe/F.length)},$t=1,Rr=async(V,F)=>{let W=Math.floor(V/P),de=Math.floor(F/P),oe=ea(I.pdq,W,de),U=await Promise.all(Array.from({length:Math.max(0,F-V)},(Q,pe)=>hn(V+pe))),Pe=(Q,pe,Re)=>{if(Q[pe]<Re)return 0;let $=[];for(let E=Math.max(0,pe-8);E<=Math.min(Q.length-1,pe+8);E++)E!==pe&&$.push(Q[E]);if($.length<4)return 0;$.sort((E,ke)=>E-ke);let xe=Q[pe]/Math.max(Re/$e,$[$.length>>1]);return xe>=$e?xe:0},re=[];for(let Q=0;Q<oe.length;Q++){let pe=Pe(oe,Q,Ne);pe&&re.push({at:(W+Q+1)*P,r:pe})}for(let Q=0;Q<U.length;Q++){let pe=Pe(U,Q,$t);pe&&re.push({at:V+Q+1,r:pe})}re.sort((Q,pe)=>Q.at-pe.at);let te=[];for(let Q of re){if(Q.at-V<Ft||F-Q.at+1<Ft)continue;let pe=te[te.length-1];if(pe&&Q.at-pe.at<Ft){Q.r>pe.r&&(pe.at=Q.at,pe.r=Q.r);continue}te.push({...Q})}return te.map(Q=>Q.at)},qt=async(V,F,W,de,oe,U,Pe)=>{if(Pe===1)return Ae(V,F,W,Math.round(de),oe,U);let re=await Ie(V).catch(()=>null);if(!re)return null;let te=Math.floor((re.offs.length-1)/Pe),Q=Math.round(F+de),pe=Math.max(0,Q-oe),Re=Math.min(te,Q+oe+W);if(Re-pe<W)return null;let $=U?U.refToSrc.map(Te=>Te.toFixed(4)).join(","):"",[xe,E]=await Promise.all([Promise.all(Array.from({length:W},(Te,Ze)=>N(`r@${F+Ze}`,()=>we(F+Ze)))),Promise.all(Array.from({length:Re-pe+1},(Te,Ze)=>{let at=Math.round((pe+Ze)*Pe);return U?ue(`w${V}@${at}|${$}`,()=>De(V,at),U):N(`c${V}@${at}`,()=>De(V,at))}))]),ke=ta(xe,E,pe,Q-oe,Q+oe);return ke?{...ke,off:ke.src-F}:null},on=160,vr=new Map,Cn=(V,F)=>{if(!V)return null;let W=V.length/F,de=new Float32Array(2*V.length);for(let oe=0;oe<W;oe++)for(let U=0;U<F;U++){let Pe=oe*F+U;de[Pe]=(V[oe*F+Math.min(F-1,U+1)]-V[oe*F+Math.max(0,U-1)])/2,de[V.length+Pe]=(V[Math.min(W-1,oe+1)*F+U]-V[Math.max(0,oe-1)*F+U])/2}return de},_n=V=>{let F=`R${V}`,W=vr.get(F);return W||(W=we(V).then(de=>Cn(jn(de,on),on)).catch(()=>null),vr.set(F,W)),W},Dr=(V,F,W)=>{let de=`C${V}@${F}|${W?W.refToSrc.map(U=>U.toFixed(4)).join(","):""}`,oe=vr.get(de);return oe||(oe=De(V,F).then(U=>Cn(W?hi(U,W.refToSrc,W.refW,W.refH,on):jn(U,on),on)).catch(()=>null),vr.set(de,oe)),oe},qr=(V,F)=>{let W=0,de=0;for(let re=0;re<V.length;re++)W+=V[re],de+=F[re];W/=V.length,de/=F.length;let oe=0,U=0,Pe=0;for(let re=0;re<V.length;re++){let te=V[re]-W,Q=F[re]-de;oe+=te*Q,U+=te*te,Pe+=Q*Q}return U>0&&Pe>0?oe/Math.sqrt(U*Pe):0},wo=async(V,F,W,de,oe,U,Pe)=>{let re=await Ie(V).catch(()=>null);if(!re)return null;let te=Math.floor((re.offs.length-1)/Pe),Q=Array.from({length:Math.min(8,W)},(at,kt)=>F+Math.round((kt+.5)*W/Math.min(8,W)-.5)),pe=U?U.refToSrc.map(at=>at.toFixed(4)).join(","):"",Re=at=>Dr(V,Math.round(at*Pe),U),$=await Promise.all(Q.map(at=>_n(at))),xe=[],E=Math.round(de);for(let at=E-oe;at<=E+oe;at++){if(F+at<0||F+W-1+at>te)continue;let kt=await Promise.all(Q.map(jt=>Re(jt+at))),sn=0,Yt=0;for(let jt=0;jt<Q.length;jt++)$[jt]&&kt[jt]&&(sn+=qr($[jt],kt[jt]),Yt++);Yt>=Math.max(1,Q.length>>1)&&xe.push([at,sn/Yt])}if(!xe.length)return null;let ke=at=>xe.find(([kt])=>kt===at)?.[1]??-1,Te=xe.reduce((at,kt)=>kt[1]>at[1]?kt:at),Ze=Math.max(-1,...xe.filter(([at])=>Math.abs(at-Te[0])>2).map(([,at])=>at));return{off:Te[0],score:Te[1],margin:Te[1]-Ze,here:ke(E)}},R4=async(V,F,W,de,oe,U)=>{if(U===1||W<5)return de;let Pe=await Ie(V).catch(()=>null);if(!Pe)return de;let re=Pe.offs.length,te=Math.round((F+de)*U),Q=await Promise.all(Array.from({length:W},($,xe)=>N(`r@${F+xe}`,()=>we(F+xe)))),pe=oe?oe.refToSrc.map($=>$.toFixed(4)).join(","):"",Re={s:te,score:-1/0};for(let $=te-2;$<=te+2;$++){let xe=Array.from({length:W},(Te,Ze)=>$+js(Ze,U));if(xe[0]<0||xe[W-1]>=re)continue;let E=await Promise.all(xe.map(Te=>oe?ue(`w${V}@${Te}|${pe}`,()=>De(V,Te),oe):N(`c${V}@${Te}`,()=>De(V,Te)))),ke=ta(Q,E,0,0,0);ke&&ke.score>Re.score&&(Re={s:$,score:ke.score})}return Re.s/U-F},_D=async(V,F,W,de)=>{let oe=await Rr(F.refStart,F.refEnd);if(Ee){let Q=[...ea(I.pdq,Math.floor(F.refStart/P),Math.floor(F.refEnd/P))].map((xe,E)=>[xe,(Math.floor(F.refStart/P)+E+1)*P]).sort((xe,E)=>E[0]-xe[0]).slice(0,5),pe=await Promise.all(Array.from({length:F.refEnd-F.refStart},(xe,E)=>hn(F.refStart+E))),Re=pe.map((xe,E)=>[xe,F.refStart+E+1]).sort((xe,E)=>E[0]-xe[0]).slice(0,5),$=[...pe].sort((xe,E)=>xe-E)[pe.length>>1]??0;console.error(`[find-first] soft cuts ${F.refStart}\u2013${F.refEnd}: [${oe.join(",")}] biggest deltas ${Q.map(([xe,E])=>`${E}:${xe}`).join(" ")} | grid ${Re.map(([xe,E])=>`${E}:${xe.toFixed(2)}`).join(" ")} (median ${$.toFixed(2)})`)}if(!oe.length)return W!==1&&F.refEnd-F.refStart+1>=Ft?[{...F,off:await R4(V,F.refStart,F.refEnd-F.refStart+1,F.off,de,W)}]:[F];let U=[F.refStart,...oe,F.refEnd+1],Pe=[];for(let te=0;te+1<U.length;te++){let Q=U[te],pe=U[te+1]-1,Re=pe-Q+1,$=F.off;if(Re>=Ft){let xe=await qt(V,Q,Re,F.off,1,de,W);if(xe&&xe.score>=.5)$=xe.off;else{let E=await qt(V,Q,Re,F.off,Ke,de,W);if(E&&E.margin>=.1&&E.score>=(xe?.score??0)+.1&&Math.abs(E.off-F.off)>1)$=E.off;else{let ke=await wo(V,Q,Re,F.off,Ct,de,W);if(Ee&&ke&&console.error(`[find-first] piece ${Q}\u2013${pe}: appearance ${ke.off} ${ke.score.toFixed(3)} m${ke.margin.toFixed(3)} (here ${ke.here.toFixed(3)})`),ke&&ke.score>=wn){let Te=ke.score-ke.here>=un?ke.off:F.off,Ze=await qt(V,Q,Re,Te,pn,de,W),at=Ze?Ze.off:Te;Ee&&console.error(`[find-first] piece ${Q}\u2013${pe}: basin ${Te}, polish ${Ze?`${Ze.off.toFixed(1)} ${Ze.score.toFixed(2)}`:"\u2013"}`),(Math.abs(at-F.off)>1||Te!==F.off)&&($=at)}}Ee&&console.error(`[find-first] piece ${Q}\u2013${pe}: here ${xe?`${xe.off.toFixed(1)} ${xe.score.toFixed(2)}`:"\u2013"}, wide ${E?`${E.off.toFixed(1)} ${E.score.toFixed(2)} m${E.margin.toFixed(2)}`:"\u2013"}`)}}Pe.push({refStart:Q,refEnd:pe,off:$})}let re=[];for(let te of Pe){let Q=re[re.length-1];Q&&Math.abs(Q.off-te.off)<=1?(te.refEnd-te.refStart>Q.refEnd-Q.refStart&&(Q.off=te.off),Q.refEnd=te.refEnd):re.push({...te})}if(W!==1)for(let te of re)te.off=await R4(V,te.refStart,te.refEnd-te.refStart+1,te.off,de,W);return Ee&&re.length>1&&console.error(`[find-first] jump cuts ${F.refStart}\u2013${F.refEnd} (soft cuts ${oe.join(",")}): ${re.map(te=>`${te.refStart}\u2013${te.refEnd}@${te.off}`).join(", ")}`),re},F4=new Map,$D=V=>{let F=F4.get(V);return F||(F=R(t[V],"B"),F4.set(V,F)),F},wv=async(V,F,W,de,oe,U,Pe,re=3)=>{let te=Ue(V),Q=de.refEnd-de.refStart+1,pe=[oe,...Fp(de,3).filter(Re=>Math.abs(Re-oe)>2)].slice(0,re);for(let Re of pe){let $=await Gn("confirm probe",()=>df({refLuma:we,cand:{label:F,frameCount:W,luma:xe=>De(V,xe)},refProbe:Re,srcGuess:Math.round(U+(Re-oe)*te),radius:Pe,runSpread:te===1?Math.max(1,Math.floor(Q/3)):0,reframeOpts:M})).catch(()=>null);if($)return{...$,srcAtProbe:Math.round($.srcAtProbe-(Re-oe)*te)}}return null},eq=12,tq=.6,Um=He.map(()=>null),V4=He.map(()=>null),xv=He.map(()=>!1),Qu=0,Pv=async(V,F)=>{L();let W=He[V],de=performance.now();F||i?.(Qu,He.length,`placing shots ${Qu}/${He.length}`);let oe=W.refEnd-W.refStart+1,U=W.refStart+W.refEnd>>1,Pe=St[V].map(J=>({frame:J,vec:me.get(J)})).filter(J=>J.vec),re=Pe.length?ay(Pe,B,U,Ue,1/0):[],te=re.slice(0,4),Q=te[0]?.sim??-1;if(Ee&&console.error(`[find-first] shot ${W.refStart}\u2013${W.refEnd} probe ${U}: ${te.map(J=>`${J.label}@${J.srcAtProbe} ${J.sim.toFixed(2)}`).join(", ")}`),Q<Vp){F||(Ln.push({...W,best:Q}),xv[V]=!0);return}let pe=[];for(let J of F?[]:bt)J.refStart>U||J.refEnd<U||pe.push({clipIndex:J.clipIndex,label:t[J.clipIndex].name,srcAtProbe:Math.round(J.srcStart+(U-J.refStart)*J.speed),sim:Q,why:"timeline claim",radius:12});let Re=F?[]:await Vn(W,U);Ee&&Re.length&&console.error(`[find-first] audio: ${Re.map(J=>`${t[J.ci].name}@${J.srcAtProbe} (${J.votes} vs ${J.rival})`).join(", ")}`);for(let J of Re)pe.push({clipIndex:J.ci,label:t[J.ci].name,srcAtProbe:J.srcAtProbe,sim:Q,why:"audio",radius:3});if(F&&(F.refEnd===W.refStart-1||F.refEnd===W.refEnd)){let J=re.find(ie=>ie.clipIndex===F.clipIndex);if(J&&J.sim>=Q-.05){let ie=Ue(F.clipIndex);pe.push({...J,srcAtProbe:Math.round(F.srcAtEnd+(U-F.refEnd)*ie),why:"continuity",radius:Da})}}for(let J of F?[]:te){if(J.sim<Q-.1)break;pe.push({...J,radius:Math.ceil(Fe(J.clipIndex)*Ue(J.clipIndex))})}let $=Q<QE,xe=async J=>{if(oe<12||!oy())return null;let ie=null,nt=J.map(st=>Gn("sizing confirm",()=>qe(st.ci,W,st.off,st.radius)).catch(()=>null));for(let[st,Ot]of J.entries()){if(ie&&ie.ci===Ot.ci&&Math.abs(ie.off-Ot.off)<=Ot.radius)continue;let Zt=await nt[st];if(Ee&&console.error(`[find-first] sizing ${Ot.label}@${U+Ot.off} \xB1${Ot.radius} (${Ot.why}) \u2192 ${Zt?`agreement ${Zt.fit.score.toFixed(2)}${Zt.map!=null?`, map ${Zt.map.toFixed(2)} margin ${Zt.margin.toFixed(2)} at ${U+Zt.off}`:""}`:"\u2013"}`),!(!Zt||Zt.fit.score<yf||Zt.map==null||Zt.map<.4||Zt.margin<.2)&&((!ie||Zt.map>ie.map)&&(ie={ci:Ot.ci,off:Zt.off,fit:Zt.fit,map:Zt.map,srcW:Zt.srcW,srcH:Zt.srcH,refW:Zt.refW,refH:Zt.refH}),Zt.fit.score>=KE))break}if(!ie&&J.length){let st=J[0],Ot=await Gn("sizing confirm",()=>qe(st.ci,W,st.off,st.radius,{})).catch(()=>null);Ee&&console.error(`[find-first] sizing ${st.label}@${U+st.off} turned \u2192 ${Ot?`agreement ${Ot.fit.score.toFixed(2)}${Ot.map!=null?`, map ${Ot.map.toFixed(2)} margin ${Ot.margin.toFixed(2)}`:""}`:"\u2013"}`),Ot&&Ot.fit.score>=yf&&Ot.map!=null&&Ot.map>=.4&&Ot.margin>=.2&&(ie={ci:st.ci,off:Ot.off,fit:Ot.fit,map:Ot.map,srcW:Ot.srcW,srcH:Ot.srcH,refW:Ot.refW,refH:Ot.refH})}return ie?{clipIndex:ie.ci,srcAtProbe:U+ie.off,score:An,transform:ie.fit.transform,srcW:ie.srcW,srcH:ie.srcH,refW:ie.refW,refH:ie.refH}:null},E=null;for(let J of pe.slice(0,$?1:4)){let ie=await Ie(J.clipIndex).catch(()=>null);if(!ie)continue;let nt=await wv(J.clipIndex,J.label,ie.offs.length,W,U,J.srcAtProbe,J.radius,$?1:3);if(Ee&&console.error(`[find-first] ${J.label}@${J.srcAtProbe} \xB1${J.radius} (${J.why}) \u2192 ${nt?`confirmed at ${nt.srcAtProbe}, ${nt.score} bits`:"refused"}`),nt){E={clipIndex:J.clipIndex,srcAtProbe:nt.srcAtProbe,score:nt.score,transform:"transform"in nt?nt.transform:null,srcW:"srcW"in nt?nt.srcW:void 0,srcH:"srcH"in nt?nt.srcH:void 0,refW:"refPlane"in nt?nt.refPlane.w:0,refH:"refPlane"in nt?nt.refPlane.h:0};break}}if(!E&&F){let J=pe.find(ie=>ie.why==="continuity");J&&(E=await xe([{ci:J.clipIndex,label:J.label,off:J.srcAtProbe-U,radius:Da,why:"continuity"}]))}if(!E&&F){let J=F.refEnd===W.refStart-1;if(J||F.refEnd===W.refEnd){let ie=F.clipIndex,nt=Ue(ie),st=await Ie(ie).catch(()=>null),Ot=J?W.refStart:W.refEnd+1,Zt=Math.max(0,Ot-1),dr=Math.min(Z-1,Ot+eq-1),ki=er=>F.srcAtEnd+Math.round((er-F.refEnd)*nt),$n=(Be.get(ie)??[]).find(er=>J?er.refStart+er.count-1===F.refEnd:er.refStart===F.refEnd+1),bn=$n?await We($n,ie,ki($n.probe),$n.probe).catch(()=>null):null;if(st&&ki(Zt)>=0&&ki(dr)<st.offs.length){let er=bn?bn.refToSrc.map($r=>$r.toFixed(4)).join(","):"",Na=Array.from({length:dr-Zt+1},($r,Go)=>Zt+Go),[Dt,Hr]=await Promise.all([Promise.all(Na.map($r=>N(`r@${$r}`,()=>we($r)))),Promise.all(Na.map($r=>{let Go=ki($r);return bn?ue(`w${ie}@${Go}|${er}`,()=>De(ie,Go),bn):N(`c${ie}@${Go}`,()=>De(ie,Go))}))]),cr=ta(Dt,Hr,0,0,0);Ee&&console.error(`[find-first] seam ${Ot} continuing ${t[ie].name}: maps ${cr?cr.score.toFixed(2):"\u2013"}`),cr&&cr.score>=tq&&(E={clipIndex:ie,srcAtProbe:ki(U),score:An,transform:$n?.transform??null,srcW:$n?.srcW,srcH:$n?.srcH,refW:$n?.refW??0,refH:$n?.refH??0})}}}!E&&Re.length&&(E=await xe(Re.filter(J=>Ue(J.ci)===1).map(J=>({ci:J.ci,label:t[J.ci].name,off:J.srcAtProbe-U,radius:4,why:"audio"})))),!E&&!F&&(E=await xe(te.filter(J=>J.sim>=Q-.06&&Ue(J.clipIndex)===1).slice(0,4).map(J=>({ci:J.clipIndex,label:J.label,off:J.srcAtProbe-U,radius:Fe(J.clipIndex)+6,why:`index ${J.sim.toFixed(2)}`}))));let ke=[],Te=new Set(te.filter(J=>J.sim>=Q-.06).map(J=>J.clipIndex)).size>=2;if(!E&&!F&&(!$||Te)&&Pe.length&&oe>=hf){let J=ea(I.pdq,Math.floor(W.refStart/P),Math.floor(W.refEnd/P));ke.length=0;for(let ie of te)ie.sim>=Q-.06&&Ue(ie.clipIndex)===1&&yn(ie.clipIndex);for(let ie of te){if(ie.sim<Q-.06||Ue(ie.clipIndex)!==1)continue;Ce.has(ie.clipIndex)||i?.(V,He.length,`placing shot ${V+1}/${He.length} \u2014 reading ${ie.label}`);let nt=yn(ie.clipIndex),st=ry(J,Math.floor(W.refStart/P),[{clipIndex:ie.clipIndex,label:ie.label,deltas:ea(await nt)}]);if(await Ie(ie.clipIndex).catch(()=>null)){Ee&&console.error(`[find-first] motion in ${ie.label}: ${st.map(Zt=>`@${Math.round((U/P+Zt.offset)*P)} r=${Zt.r.toFixed(2)}`).join(", ")||"none"}`);for(let Zt of st.slice(0,2))ke.push({c:ie,srcGuess:Math.round((U/P+Zt.offset)*P),r:Zt.r})}}ke.sort((ie,nt)=>nt.r-ie.r);for(let ie of ke.slice(0,3)){let nt=await Ie(ie.c.clipIndex).catch(()=>null);if(!nt)continue;let st=await wv(ie.c.clipIndex,ie.c.label,nt.offs.length,W,U,ie.srcGuess,Math.max(4,2*P+2))??await Bn(ie.c.clipIndex,await Ce.get(ie.c.clipIndex),W,U,ie.srcGuess)??await pt(ie.c.clipIndex,W,U,ie.srcGuess);if(Ee&&console.error(`[find-first] ${ie.c.label}@${ie.srcGuess} (motion r=${ie.r.toFixed(2)}) \u2192 ${st?`confirmed at ${st.srcAtProbe}, ${st.score} bits`:"refused"}`),st){E={clipIndex:ie.c.clipIndex,srcAtProbe:st.srcAtProbe,score:st.score,transform:st.transform??null,srcW:st.srcW,srcH:st.srcH,refW:st.refPlane?.w??0,refH:st.refPlane?.h??0};break}}}if(!E&&!F&&oe>=8){let J=Math.min(96,oe),ie=W.refStart+(oe-J>>1);for(let nt of te.filter(st=>st.sim>=Q-.06&&Ue(st.clipIndex)===1).slice(0,3)){let st=await Gn("map place",()=>Ae(nt.clipIndex,ie,J,nt.srcAtProbe-U,sy));if(Ee&&console.error(`[find-first] map place ${nt.label}: ${st?`${st.off} (score ${st.score.toFixed(2)}, margin ${st.margin.toFixed(2)})`:"\u2013"}`),!st||st.score<.4||st.margin<.2)continue;let Ot=await we(U),Zt=await De(nt.clipIndex,U+st.off),dr=Ot&&Zt?await Br(Zt.y,Zt.w,Zt.h,Ot.y,Ot.w,Ot.h,M).catch(()=>null):null;E={clipIndex:nt.clipIndex,srcAtProbe:U+st.off,score:An,transform:dr?.ok?dr.transform:null,srcW:dr?.ok?dr.srcW:void 0,srcH:dr?.ok?dr.srcH:void 0,refW:Ot?.w??0,refH:Ot?.h??0};break}}if(!E&&!F&&ke.length&&(E=await xe(ke.slice(0,3).map(J=>({ci:J.c.clipIndex,label:J.c.label,off:J.srcGuess-U,radius:i5,why:`motion r=${J.r.toFixed(2)}`})))),!E&&!F&&oe>=12&&oy())for(let J of te.filter(ie=>ie.sim>=Q-.06&&Ue(ie.clipIndex)!==1).slice(0,2)){let ie=await Qe(J.clipIndex,W,U,J.srcAtProbe,Math.ceil(Fe(J.clipIndex)*Ue(J.clipIndex)));if(Ee&&console.error(`[find-first] off-rate sizing ${J.label}@${J.srcAtProbe}: ${ie?`${ie.at} at ${ie.rate.toFixed(2)}\xD7, agreement ${ie.v.fit.score.toFixed(2)}`:"\u2013"}`),!(!ie||ie.v.fit.score<yf)){E={clipIndex:J.clipIndex,srcAtProbe:ie.at,score:An,transform:ie.v.fit.transform,srcW:ie.v.srcW,srcH:ie.v.srcH,refW:ie.v.refW,refH:ie.v.refH};break}}if(!E&&!F&&oe>=6&&(E=await Gn("orb rescue",()=>Qn(W,U,re))),!E){for(let J of te)J.sim>=Q-.1&&Sn.add(J.clipIndex);return}{let J=await Gn("refine by motion",()=>Nr(E.clipIndex,W,U,E.srcAtProbe));Ee&&console.error(`[find-first] motion: ${E.srcAtProbe} \u2192 ${J.srcAtProbe} (r=${Number.isFinite(J.r)?J.r.toFixed(2):"\u2013"}${J.ambiguous?", undecided":""})`);let ie=J.ambiguous;if(Re.find(st=>st.ci!==E.clipIndex&&Ue(st.ci)===1)&&(ie=!0),E={...E,srcAtProbe:J.srcAtProbe},Ue(E.clipIndex)===1){let st=Math.min(96,oe),Ot=W.refStart+(oe-st>>1),Zt=await We(E,E.clipIndex,E.srcAtProbe,U).catch(()=>null),dr=await Gn("motion map",()=>Ae(E.clipIndex,Ot,st,E.srcAtProbe-U,sy,Zt));if(Ee&&console.error(`[find-first] map: ${E.srcAtProbe-U} \u2192 ${dr?`${dr.off} (score ${dr.score.toFixed(2)}, margin ${dr.margin.toFixed(2)})`:"\u2013"}`),dr?.clear&&(E={...E,srcAtProbe:U+dr.off},ie=!1),ie&&!dr?.clear){let ki=dr?.score??0;for(let $n of te.filter(bn=>bn.clipIndex!==E.clipIndex&&bn.sim>=Q-.1&&Ue(bn.clipIndex)===1).slice(0,3)){let bn=await Gn("take check",()=>qe($n.clipIndex,W,$n.srcAtProbe-U,Fe($n.clipIndex)+6)).catch(()=>null),er=bn&&bn.map!=null?{off:bn.off,score:bn.map,margin:bn.margin,clear:bn.map>=.4&&bn.margin>=.2&&bn.fit.score>=yf}:null;if(Ee&&console.error(`[find-first] take ${$n.label}: ${er?`${er.off} (score ${er.score.toFixed(2)}, margin ${er.margin.toFixed(2)}, agreement ${bn.fit.score.toFixed(2)})`:"\u2013"} vs ${ki.toFixed(2)}`),!er?.clear||er.score<ki+.2)continue;let Na=await Ie($n.clipIndex).catch(()=>null),Dt=Na?await wv($n.clipIndex,$n.label,Na.offs.length,W,U,U+er.off,2,1):null;if(Dt){E={clipIndex:$n.clipIndex,srcAtProbe:U+er.off,score:Dt.score,transform:"transform"in Dt?Dt.transform:null,srcW:"srcW"in Dt?Dt.srcW:void 0,srcH:"srcH"in Dt?Dt.srcH:void 0,refW:"refPlane"in Dt?Dt.refPlane.w:0,refH:"refPlane"in Dt?Dt.refPlane.h:0},ie=!1;break}}}if(ie&&!dr?.clear){let ki=dr?.score??0,$n=[{ci:E.clipIndex,label:t[E.clipIndex].name,warp:Zt,fitScore:null,off0:E.srcAtProbe-U}];for(let Dt of te.filter(Hr=>Hr.clipIndex!==E.clipIndex&&Hr.sim>=Q-.06&&Ue(Hr.clipIndex)===1).slice(0,2)){let Hr=await gt(Dt.clipIndex,W,Dt.srcAtProbe-U).catch(()=>null);$n.push({ci:Dt.clipIndex,label:Dt.label,warp:Hr?.warp??null,fitScore:Hr?.fit.score??null,off0:Dt.srcAtProbe-U})}let bn=null,er=Re.filter(Dt=>Ue(Dt.ci)===1).map(Dt=>({ci:Dt.ci,off:Dt.srcAtProbe-U,score:1}));for(let Dt of $n){let Hr=oe<UE,cr=await Gn("take scan",()=>Hr?kn(Dt.ci,W,Dt.off0):en(Dt.ci,W,Dt.warp,Dt.off0)).catch(()=>null);if(Ee&&console.error(`[find-first] scan ${Dt.label}: ${cr?`${U+cr.off} (score ${cr.score.toFixed(2)}, margin ${cr.margin.toFixed(2)}; peaks ${cr.peaks.map($r=>`${U+$r.off}:${$r.score.toFixed(2)}`).join(" ")})`:"\u2013"} vs ${ki.toFixed(2)}`),cr)for(let $r of cr.peaks)$r.score>=YE&&er.push({ci:Dt.ci,...$r});!Hr&&cr&&cr.score>=AE&&cr.margin>=GE&&cr.score>=ki+JE&&(!bn||cr.score>bn.score)&&(bn={ci:Dt.ci,...cr})}let Na=!1;if(bn){let Dt=await gt(bn.ci,W,bn.off).catch(()=>null);Ee&&console.error(`[find-first] scan \u2192 ${t[bn.ci].name}@${U+bn.off}, agreement ${Dt?Dt.fit.score.toFixed(2):"\u2013"}`),Dt&&Dt.fit.score>=o5&&(E={clipIndex:bn.ci,srcAtProbe:U+bn.off,score:An,transform:Dt.fit.transform,srcW:Dt.srcW,srcH:Dt.srcH,refW:Dt.warp.refW,refH:Dt.warp.refH},ie=!1,Na=!0)}if(!Na&&er.length){let Hr=(await gt(E.clipIndex,W,E.srcAtProbe-U).catch(()=>null))?.fit.score??0,cr={best:null},$r=new Set,Go=async(ei,ti,Am)=>{let I4=`${ei}@${ti}`;if($r.has(I4)||ei===E.clipIndex&&ti===E.srcAtProbe-U)return;$r.add(I4);let _u=await Gn("moment sizing",()=>gt(ei,W,ti)).catch(()=>null);Ee&&Am&&console.error(`[find-first] moment ${t[ei].name}@${U+ti} (${Am}): agreement ${_u?_u.fit.score.toFixed(2):"\u2013"} vs ${Hr.toFixed(2)} here`),_u&&(!cr.best||_u.fit.score>cr.best.sw.fit.score)&&(cr.best={ci:ei,off:ti,sw:_u})},Z4=[];for(let ei of[...new Set(er.map(ti=>ti.ci))])Z4.push(...er.filter(ti=>ti.ci===ei).sort((ti,Am)=>Am.score-ti.score).slice(0,2));for(let ei of Z4)for(let ti=-s5;ti<=s5;ti+=uy)await Go(ei.ci,ei.off+ti,ti===0?`map ${ei.score.toFixed(2)}`:"");let Sv=cr.best;if(Sv)for(let ei=1-uy;ei<uy;ei++)ei&&await Go(Sv.ci,Sv.off+ei,"");let mr=cr.best;Ee&&mr&&console.error(`[find-first] moment sweep best ${t[mr.ci].name}@${U+mr.off}: agreement ${mr.sw.fit.score.toFixed(2)} vs ${Hr.toFixed(2)} here`),mr&&mr.ci!==E.clipIndex&&mr.sw.fit.score>=Hr-BE&&mr.sw.fit.score<Hr+a5&&Tr.set(W.refStart,{clipLabel:t[mr.ci].name,agreement:mr.sw.fit.score,winnerAgreement:Hr}),mr&&mr.sw.fit.score>=o5&&mr.sw.fit.score>=Hr+a5&&(Tr.delete(W.refStart),Ee&&console.error(`[find-first] moment \u2192 ${t[mr.ci].name}@${U+mr.off}, agreement ${mr.sw.fit.score.toFixed(2)}`),E={clipIndex:mr.ci,srcAtProbe:U+mr.off,score:An,transform:mr.sw.fit.transform,srcW:mr.sw.srcW,srcH:mr.sw.srcH,refW:mr.sw.warp.refW,refH:mr.sw.warp.refH},ie=!1)}}}ie&&Et.add(W.refStart)}let Ze=Ue(E.clipIndex),at=await We(E,E.clipIndex,E.srcAtProbe,U).catch(()=>null),kt=Ze===1?await Gn("split check",async()=>lt(E.clipIndex,W.refStart,W.refEnd,E.srcAtProbe-U,at)):[{refStart:W.refStart,refEnd:W.refEnd,off:E.srcAtProbe/Ze-U}],sn=(await Gn("jump cuts",()=>Promise.all(kt.map(J=>_D(E.clipIndex,J,Ze,at))))).flat(),Yt=Be.get(E.clipIndex)??[];if(sn.length>1)for(let J of sn)Yt.push({refStart:J.refStart,srcStart:Ze===1?Math.round(J.refStart+J.off):J.refStart+J.off,count:J.refEnd-J.refStart+1,score:E.score,transform:E.transform??null,srcW:E.srcW,srcH:E.srcH,refW:E.refW??0,refH:E.refH??0,probe:J.refStart+(J.refEnd-J.refStart>>1)});else Yt.push({refStart:W.refStart,srcStart:Ze===1?Math.round(E.srcAtProbe-(U-W.refStart)):E.srcAtProbe/Ze-(U-W.refStart),count:oe,score:E.score,transform:E.transform??null,srcW:E.srcW,srcH:E.srcH,refW:E.refW??0,refH:E.refH??0,probe:U});Be.set(E.clipIndex,Yt);for(let J=W.refStart;J<=W.refEnd;J++)fe[J]=1;let jt=sn[sn.length-1].off,xn=sn[0].off;Um[V]={clipIndex:E.clipIndex,refEnd:W.refEnd,srcAtEnd:sn.length>1?Math.round((W.refEnd+jt)*Ze):Math.round(E.srcAtProbe+(W.refEnd-U)*Ze)},V4[V]={clipIndex:E.clipIndex,refEnd:W.refStart,srcAtEnd:sn.length>1?Math.round((W.refStart+xn)*Ze):Math.round(E.srcAtProbe-(U-W.refStart)*Ze)},Ee&&console.error(`[find-first] shot ${W.refStart}\u2013${W.refEnd} took ${Math.round(performance.now()-de)} ms`)},Ao=Math.min(He.length,Number(typeof process<"u"&&process.env?.CONFORM_MAX_SHOTS||1/0)),j4=0;await Promise.all(Array.from({length:dy},async()=>{for(;j4<Ao;){let V=j4++;await Pv(V,null),Qu++,i?.(Qu,He.length,`placing shots ${Qu}/${He.length}`)}}));for(let V=1;V<Ao;V++){let F=Um[V-1];Um[V]||xv[V]||!F||F.refEnd!==He[V].refStart-1||(i?.(V,Ao,`continuity ${V}/${Ao}`),await Pv(V,F))}for(let V=Ao-2;V>=0;V--){let F=V4[V+1];Um[V]||xv[V]||!F||F.refEnd!==He[V].refEnd+1||(i?.(Ao-V,Ao,`continuity ${Ao-V}/${Ao}`),await Pv(V,{...F,refEnd:F.refEnd-1,srcAtEnd:F.srcAtEnd-Math.round(Ue(F.clipIndex))}))}typeof process<"u"&&process.env?.CONFORM_PROFILE&&console.error(Yk());for(let V of B){let F=await Ie(V.clipIndex).catch(()=>null);if(!F)continue;j[V.clipIndex]=F;let W=Ue(V.clipIndex),de=(Be.get(V.clipIndex)??[]).sort((re,te)=>re.refStart-te.refStart),oe=new Map(de.map(re=>[re.refStart,re.score])),U=de.length?await At(V.clipIndex,de,re=>Math.round(re*W),re=>oe.get(re.refStart)??null):[];for(let re of U){if(re.track.kind!=="unresolved")continue;let te=de.find(pe=>pe.refStart===re.refStart);if(te&&!te.transform){let pe=de.find(Re=>Re!==te&&Re.transform&&Re.refW&&(Re.refStart+Re.count===te.refStart&&Math.abs(Math.round((Re.srcStart+Re.count)*W)-Math.round(te.srcStart*W))<=2||te.refStart+te.count===Re.refStart&&Math.abs(Math.round((te.srcStart+te.count)*W)-Math.round(Re.srcStart*W))<=2));pe&&(te={...te,transform:pe.transform,srcW:pe.srcW,srcH:pe.srcH,refW:pe.refW,refH:pe.refH})}if(!te?.transform||!te.refW)continue;let Q=$o({transform:te.transform,srcW:te.srcW,srcH:te.srcH},te.refW,te.refH);re.track={kind:"static",keyframes:[{refFrame:te.probe,reframe:Q}],label:Q.label},re.reframe=Q}let Pe=de.reduce((re,te)=>re+te.count,0);D.push({clipIndex:V.clipIndex,label:t[V.clipIndex].name,shots:U,coverage:F.offs.length?Pe/F.offs.length:0,srcFps:F.fps,srcStartFrame:F.startFrame,srcDropFrame:F.dropFrame,srcFrames:F.offs.length,srcW:F.w||null,srcH:F.h||null,codec:ko(F.kind),geometrySupported:!!a&&!!s,warnings:[]})}for(let V=0;V<t.length;V++)D.some(F=>F.clipIndex===V)||(D.push({clipIndex:V,label:t[V].name,shots:[],coverage:0,srcFps:null,srcStartFrame:0,srcFrames:0,srcW:null,srcH:null,codec:"not indexed",geometrySupported:!1,warnings:[`${ny} this clip could not be read for the index.`]}),j[V]={offs:[],codec:"",kind:"other",w:0,h:0,fps:null,startFrame:0,dropFrame:!1},H[V]=1)}for(let Z of ft){let ee=K.get(Z),ce=t[Z];D.push({clipIndex:Z,label:ce.name,shots:[],coverage:0,srcFps:null,srcStartFrame:0,srcFrames:0,srcW:null,srcH:null,codec:"not examined",geometrySupported:!1,warnings:[`${ny} the reference was already fully accounted for and the last ${Pp} clips added nothing, so the run stopped here. On a ${xp}-frame probe this clip's closest frame was ${ee&&Number.isFinite(ee.minDistance)?`${ee.minDistance} bits`:"not measurable"} from the reference \u2014 worse than every clip that won a shot. Re-run with "examine every clip" if a shot you expected is missing.`]}),j[Z]={offs:[],codec:"",kind:"other",w:0,h:0,fps:null,startFrame:0,dropFrame:!1},H[Z]=1}D.sort((Z,ee)=>Z.clipIndex-ee.clipIndex);let rr,oo=null;if(p&&C.length){L(),i?.(t.length,t.length,"placing shots");let Z=h&&C.every(ve=>ve.embed)?await h(e):null;oo=Z;let ee=z8(I.pdq,C,{...b,...Z?{embedding:{ref:Z,...b?.embedding}}:{}});rr=ee;let ce=ve=>{let B=Math.floor(ve/P);return ee.find(se=>se.refStart<=B&&se.refEnd>=B)};for(let ve of D)for(let B of ve.shots){let Fe=ce(B.refStart+B.refEnd>>1)?.placement;if(!Fe||Fe.clipIndex!==ve.clipIndex)continue;let dt=H[ve.clipIndex]??1,Ie=Fe.refStart*P,yt=Fe.refEnd*P+P-1;if(B.refStart<Ie||B.refEnd>yt)continue;let Ue=Math.round((B.refStart+Fe.offset*P)*dt),He=Ue-B.srcStart;if(Math.abs(He)>P){let St=B.srcEnd-B.srcStart;B.srcStart=Ue,B.srcEnd=Ue+St}B.vote={offset:Fe.offset*P,ambiguity:Fe.ambiguity,share:Fe.share,consensus:Fe.consensus,movedBy:Math.abs(He)>P?He:0,truncated:Fe.truncated}}}if(f){let Z=D.flatMap(ce=>ce.shots.map(ve=>({shot:ve,clipLabel:ce.label,refStart:ve.refStart,refEnd:ve.refEnd,score:ve.score,srcFps:ce.srcFps,file:t[ce.clipIndex]}))),ee=Zk(Z);if(ee.length){L(),i?.(t.length,t.length,"audio arbitration");let ce=d??fp,ve=async dt=>{try{return await ce(dt)}catch{return null}},B=new Map,se=async(dt,Ie,yt)=>(B.has(dt)||B.set(dt,Dv(await ve(Ie),yt)),B.get(dt)??null),Fe=Dv(await ve(e),q.fps);for(let dt of ee){let Ie=[];for(let Ue of dt)Ie.push({label:Ue.clipLabel,refStart:Ue.refStart,refEnd:Ue.refEnd,srcStart:Ue.shot.srcStart,track:await se(Ue.clipLabel,Ue.file,Ue.srcFps)});let yt=jk(Fe,Ie);dt.forEach((Ue,He)=>{Ue.shot.audio=yt[He]})}}}let je=_k(q.offs.length,D);if(z&&rn.length&&(je=gp(je,rn),je=je.map(Z=>{if(Z.kind!=="gap")return Z;let ee=Ln.find(ce=>ce.refStart<=Z.refStart&&ce.refEnd>=Z.refEnd);return ee?{...Z,nothingSimilar:Math.max(0,ee.best)}:Z}),je=je.map(Z=>Z.kind!=="gap"&&Et.has(Z.refStart)&&Z.inPointAmbiguity==null?{...Z,inPointUnconfirmed:!0}:Z),je=je.map(Z=>{let ee=Z.kind!=="gap"?Tr.get(Z.refStart):void 0;return ee&&ee.clipLabel!==Z.clipLabel?{...Z,takeRival:ee}:Z})),rr?.length){let Z=[];for(let ee of je){if(ee.kind!=="gap"){Z.push(ee);continue}let ce=ee.refStart;for(let ve of rr){let B=ve.refStart*P,se=ve.refEnd*P+P-1,Fe=Math.max(ce,B),dt=Math.min(ee.refEnd,se);if(Fe>dt)continue;let Ie=ve.placement?.clipLabel??ve.ramp?.clipLabel;if(!Ie)continue;Fe>ce&&Z.push({...ee,refStart:ce,refEnd:Fe-1});let yt=D.find(Ee=>Ee.label===Ie),Ue=yt?H[yt.clipIndex]??1:1,He=Ee=>{let dn=Ee/P,Vn=ve.ramp?ve.ramp.srcAtStart+ve.ramp.slope*(dn-ve.refStart):dn+ve.placement.offset;return Math.round(Vn*P*Ue)},St=Fe+dt>>1,Qt=Ue===1&&!ve.ramp,Wt=yt?await df({refLuma:we,cand:{label:Ie,frameCount:yt.srcFrames,luma:Ee=>De(yt.clipIndex,Ee)},refProbe:St,srcGuess:He(St),radius:Math.max(4,Math.ceil(((ve.placement?.ambiguity??ve.ramp?.ambiguity??2)*P+2)*Ue)),runSpread:Qt?Math.max(1,Math.floor((dt-Fe+1)/3)):0,reframeOpts:M}):null;if(!Wt){Z.push({...ee,refStart:Fe,refEnd:dt,unconfirmed:{clipLabel:Ie,srcFrame:He(Fe)}}),ce=dt+1;continue}let me=Wt.srcAtProbe-He(St),Be=$o(Wt,Wt.refPlane.w,Wt.refPlane.h);Z.push({...ee,refStart:Fe,refEnd:dt,kind:"static",clipLabel:Ie,srcStart:He(Fe)+me,srcEnd:He(dt)+me,track:{kind:"static",keyframes:[{refFrame:St,reframe:Be}],label:Be.label},score:Wt.score,inPointAmbiguity:Wt.ambiguity,...ve.ramp?{speed:{slope:ve.ramp.slope,percent:ve.ramp.slope*100,kind:ve.ramp.slope===0?"freeze":"retime",samples:ve.ramp.pieces,residual:ve.ramp.residual}}:{}}),ce=dt+1}ce<=ee.refEnd&&Z.push({...ee,refStart:ce,refEnd:ee.refEnd})}je=Z}if(rr?.length){let Z=rr.map(ee=>ee.refStart*P).filter(ee=>ee>0);je=je.flatMap(ee=>ee.kind==="gap"?gp([ee],Z):[ee])}if(oo&&C.every(Z=>Z.embed)){let Z=[...new Set(C.flatMap(ce=>ce.embed))],ee=(ce,ve)=>{let B=0;for(let se=0;se<ce.length;se++)B+=ce[se]*ve[se];return B};je=je.map(ce=>{if(ce.kind!=="gap")return ce;let ve=-1;for(let B=ce.refStart;B<=ce.refEnd&&ve<Vp;B+=4){let se=oo[B];if(se)for(let Fe of Z){let dt=ee(se,Fe);if(dt>ve&&(ve=dt,ve>=Vp))break}}return ve>=0&&ve<Vp?{...ce,nothingSimilar:ve}:ce})}if(!z&&a&&s&&je.some(Z=>Z.kind==="gap")){L(),i?.(t.length,t.length,"continuity and motion");let Z=C.map(B=>({clipIndex:B.clipIndex,label:B.label,deltas:ea(B.pdq)})),ee=typeof process<"u"&&!!process.env?.CONFORM_DEBUG_NOMINATIONS,ce=new Map(D.map(B=>[B.clipIndex,B])),ve=[];for(let B=0;B<je.length;B++){let se=je[B],Fe=se.refEnd-se.refStart+1;if(se.kind!=="gap"||Fe<8||se.nothingSimilar!=null){ve.push(se);continue}let dt=[],Ie=(me,Be)=>{if(!me||!me.clipLabel||me.srcStart==null||me.srcEnd==null||me.kind!=="static"&&me.kind!=="animated"||(Be==="before"?me.refEnd!==se.refStart-1:me.refStart!==se.refEnd+1))return;let Ee=D.find(Ce=>Ce.label===me.clipLabel);if(!Ee)return;let dn=me.refEnd>me.refStart?(me.srcEnd-me.srcStart)/(me.refEnd-me.refStart):H[Ee.clipIndex]??1,Vn=Be==="before"?Ce=>Math.round(me.srcEnd+(Ce-me.refEnd)*dn):Ce=>Math.round(me.srcStart-(me.refStart-Ce)*dn);dt.push({clipIndex:Ee.clipIndex,label:Ee.label,at:Vn,radius:Da,why:"continuity"})};for(let me of bt){if(me.refEnd<se.refStart||me.refStart>se.refEnd)continue;let Be=ce.get(me.clipIndex);Be&&dt.push({clipIndex:me.clipIndex,label:Be.label,at:Ee=>Math.round(me.srcStart+(Ee-me.refStart)*me.speed),radius:12,why:"timeline claim"})}Ie(ve[ve.length-1],"before"),Ie(je[B+1],"after");let yt=se.refStart,Ue=se.refEnd;for(let me=B-1;me>=0&&je[me].kind==="gap"&&je[me].refEnd===yt-1&&je[me].nothingSimilar==null;me--)yt=je[me].refStart;for(let me=B+1;me<je.length&&je[me].kind==="gap"&&je[me].refStart===Ue+1&&je[me].nothingSimilar==null;me++)Ue=je[me].refEnd;let He=(me,Be)=>{let Ee=Math.ceil(me/P),dn=Math.floor(Be/P);return dn-Ee>kp&&(Ee=(Ee+dn>>1)-(kp>>1),dn=Ee+kp),ry(ea(I.pdq,Ee,dn),Ee,Z).slice(0,4)},St=He(se.refStart,se.refEnd);if(yt<se.refStart||Ue>se.refEnd){for(let me of He(yt,Ue))St.some(Be=>Be.clipIndex===me.clipIndex&&Math.abs(Be.offset-me.offset)<=2)||St.push(me);St.sort((me,Be)=>Be.r-me.r)}for(let me of St){let Be=H[me.clipIndex]??1;dt.push({clipIndex:me.clipIndex,label:me.label,at:Ee=>Math.round((Ee/P+me.offset)*P*Be),radius:Math.max(4,Math.ceil((2*P+2)*Be)),why:`motion r=${me.r.toFixed(2)}`})}let Qt=se.refStart+se.refEnd>>1,Wt=null;ee&&console.error(`[nominate] gap ${se.refStart}\u2013${se.refEnd}: ${dt.map(me=>`${me.label}@${me.at(Qt)} (${me.why})`).join(", ")||"none"}`);for(let me of dt){let Be=ce.get(me.clipIndex);if(!Be)continue;let Ee=H[me.clipIndex]??1,dn=me.at(Qt);if(dn<0||dn>=Be.srcFrames)continue;let Vn=await df({refLuma:we,cand:{label:me.label,frameCount:Be.srcFrames,luma:Bn=>De(me.clipIndex,Bn)},refProbe:Qt,srcGuess:dn,radius:me.radius,runSpread:Ee===1?Math.max(1,Math.floor(Fe/3)):0,reframeOpts:M}).catch(()=>null);if(ee&&console.error(`[nominate] ${me.label}@${dn} (${me.why}) \u2192 ${Vn?`confirmed at ${Vn.srcAtProbe}, ${Vn.score} bits`:"refused by the picture"}`),!Vn)continue;let Ce=Vn.srcAtProbe-dn,yn=$o(Vn,Vn.refPlane.w,Vn.refPlane.h);Wt={refStart:se.refStart,refEnd:se.refEnd,kind:"static",clipLabel:me.label,srcStart:me.at(se.refStart)+Ce,srcEnd:me.at(se.refEnd)+Ce,track:{kind:"static",keyframes:[{refFrame:Qt,reframe:yn}],label:yn.label},score:Vn.score,inPointAmbiguity:Vn.ambiguity};break}ve.push(Wt??se)}je=ve}if(o&&!z&&je.some(Z=>Z.kind==="gap"||Z.kind==="unresolved")){L(),i?.(t.length,t.length,"gap-fill");let Z=z?D.filter(B=>Sn.has(B.clipIndex)||B.shots.length):D,ee=await Promise.all(Z.map(async B=>({label:B.label,frameCount:B.srcFrames,luma:se=>De(B.clipIndex,se),rate:H[B.clipIndex]??1,keyframes:T?await T(t[B.clipIndex]).catch(()=>null):null}))),ce="retrieval";je=await l8(je,we,ee,{...M,signal:r,onProgress:(B,se)=>i?.(B,se,`gap-fill ${ce}`),onPhase:B=>{ce=B,i?.(0,1,`gap-fill ${B}`)}});let ve=new Map(D.map(B=>[B.label,B]));for(let B of je){if(!B.clipLabel||B.srcStart==null||B.kind==="gap")continue;let se=ve.get(B.clipLabel);se&&(se.shots.some(Fe=>Fe.refStart<=B.refEnd&&Fe.refEnd>=B.refStart)||se.shots.push({refStart:B.refStart,refEnd:B.refEnd,srcStart:B.srcStart,srcEnd:B.srcEnd??B.srcStart+(B.refEnd-B.refStart),reframe:B.track?.keyframes[B.track.keyframes.length>>1]?.reframe??null,geometry:null,track:B.track??{kind:"unresolved",keyframes:[],label:"unresolved"},score:B.score??null,contestedBy:null}))}for(let B of D)B.shots.sort((se,Fe)=>se.refStart-Fe.refStart)}for(let Z of D)if(Z.shots.length!==0)for(let ee of je){if(ee.clipLabel!==Z.label)continue;let ce=Z.shots.filter(Fe=>Fe.refStart>=ee.refStart&&Fe.refEnd<=ee.refEnd);if(ce.length===0)continue;let ve=H[Z.clipIndex]??1,B=Qk(ve===1?ce:ce.map(Fe=>({refStart:Fe.refStart,srcStart:Fe.srcStart/ve})));if(B.kind==="normal")continue;let se=ee.refEnd-ee.refStart+1;B.residual>Math.max(2,.25*se)||(ee.speed=B)}if(rr?.length&&(je=gp(je,rr.map(Z=>Z.refStart*P).filter(Z=>Z>0))),rr?.some(Z=>Z.ramp))for(let Z of je){if(!Z.clipLabel||Z.kind==="gap"||Z.srcStart==null)continue;let ee=rr.find(Fe=>Fe.ramp&&Fe.ramp.clipLabel===Z.clipLabel&&Z.refStart>=Fe.refStart*P&&Z.refEnd<=Fe.refEnd*P+P-1),ce=ee?.ramp;if(!ce||!ee)continue;let ve=D.find(Fe=>Fe.label===Z.clipLabel),B=ve?H[ve.clipIndex]??1:1,se=Fe=>Math.round((ce.srcAtStart*P+ce.slope*(Fe-ee.refStart*P))*B);Z.srcStart=se(Z.refStart),Z.srcEnd=se(Z.refEnd),Z.speed={slope:ce.slope,percent:ce.slope*100,kind:ce.slope===0?"freeze":"retime",samples:ce.pieces,residual:ce.residual}}i?.(t.length,t.length,"timing shots");let Hn=new Map,Ii=[],Uo=new Map,qc=Z=>{let ee=Z.track?.keyframes?.[0]?.reframe;return Z.track?.kind==="animated"||!!(ee&&(Math.abs(ee.scale-1)>.02||Math.abs(ee.rotationDeg)>.5||Math.hypot(ee.dxCenter,ee.dyCenter)>4))},Em=async(Z,ee,ce,ve)=>{if(qc(Z))return ce;let B=Z.refEnd-Z.refStart+1,se=Math.min(48,B);if(se<6||ve<=0)return ce;let Fe=Z.refStart+(B-se>>1),dt=(He,St)=>{let Qt=Uo.get(He);return Qt||(Qt=St().then(Wt=>jn(Wt)).catch(()=>null),Uo.set(He,Qt)),Qt},Ie=await Promise.all(Array.from({length:se},(He,St)=>dt(`r@${Fe+St}`,()=>we(Fe+St)))),yt=D.find(He=>He.clipIndex===ee),Ue={s:ce,score:-1/0};for(let He=-2;He<=2;He++){let St=Array.from({length:se},(me,Be)=>ce+He+js(Fe-Z.refStart+Be,ve));if(St[0]<0||yt?.srcFrames&&St[se-1]>=yt.srcFrames)continue;let Qt=await Promise.all(St.map(me=>dt(`c${ee}@${me}`,()=>De(ee,me)))),Wt=ta(Ie,Qt,0,0,0);Wt&&Wt.score>Ue.score+(He===0?-1e-9:.02)&&(Ue={s:ce+He,score:Wt.score})}return typeof process<"u"&&process.env?.CONFORM_DEBUG_NOMINATIONS&&Ue.s!==ce&&console.error(`[timing] ${Z.clipLabel} rec ${Z.refStart}: start ${ce} \u2192 ${Ue.s} (maps ${Ue.score.toFixed(2)})`),Ue.s},Cm=async Z=>{if(!Z.clipLabel||Z.kind==="gap"||Z.kind==="composite"||Z.srcStart==null)return;let ee=D.find(He=>He.label===Z.clipLabel);if(!ee)return;let ce=ee.srcFps&&q.fps?ee.srcFps/q.fps:1,ve=(H[ee.clipIndex]??1)!==1?H[ee.clipIndex]:Math.abs(ce-1)>.01?ce:1;if(ve===1&&Z.score==null)return;L();let B=Z.refEnd-Z.refStart,se=Z.srcStart,Fe=Z.srcEnd??Z.srcStart+B*ve,dt=Date.now(),Ie=await u8({refLuma:we,cand:{label:ee.label,frameCount:ee.srcFrames,luma:He=>De(ee.clipIndex,He),rate:ve},refStart:Z.refStart,refEnd:Z.refEnd,srcAt:He=>Math.round(se+(B?(He-Z.refStart)*(Fe-se)/B:0)),reframeOpts:M});if(typeof process<"u"&&process.env?.CONFORM_DEBUG_NOMINATIONS&&console.error(`[timing] ${Z.clipLabel} rec ${Z.refStart}\u2013${Z.refEnd}: ${Ie?`${Ie.model} slope ${Ie.slope.toFixed(3)} in ${se}\u2192${Math.round(Ie.srcAtStart)}`:"no answer"} (${Date.now()-dt} ms)`),!Ie){ve!==1&&Ii.push({seg:Z,rate:ve});return}if(Ie.model==="retime"){let He=[ve,1].find(St=>Math.abs(Ie.slope-St)/St<.025);if(He!=null){let St=Z.refStart+Z.refEnd>>1,Qt=qc(Z)?se+(B?(St-Z.refStart)*(Fe-se)/B:0):Ie.srcAtStart+(St-Z.refStart)*Ie.slope;Z.srcStart=await Em(Z,ee.clipIndex,Math.round(Qt-(St-Z.refStart)*He),He),Z.srcEnd=Math.round(Z.srcStart+B*He);let Wt=He/ve*100;Math.abs(Wt-100)<.5?delete Z.speed:Z.speed={slope:He/ve,percent:Wt,kind:"retime",samples:Ie.anchors.length,residual:0,basis:"frame-for-frame"},typeof process<"u"&&process.env?.CONFORM_DEBUG_NOMINATIONS&&console.error(`[timing] ${Z.clipLabel} rec ${Z.refStart}: retime ${Ie.slope.toFixed(3)} snapped to the natural ${He===1?"frame-for-frame":"real-time"} line, start ${Z.srcStart}`);return}}if(ve!==1&&Ie.model!=="retime"){let He=ve.toFixed(4),St=Hn.get(He)??[],Qt=St.find(Wt=>Math.abs(Wt.slopeOverRate-Ie.slope/ve)<.001);Qt?Qt.votes++:St.push({slopeOverRate:Ie.slope/ve,votes:1}),Hn.set(He,St)}let yt=Math.abs(Ie.slope-ve)<1e-6||Math.abs(Ie.slope-1)<1e-6;if(qc(Z)&&yt){let He=Z.refStart+Z.refEnd>>1,St=se+(B?(He-Z.refStart)*(Fe-se)/B:0);Z.srcStart=Math.round(St-(He-Z.refStart)*Ie.slope)}else Z.srcStart=await Em(Z,ee.clipIndex,Math.round(Ie.srcAtStart),Ie.slope);Z.srcEnd=Math.round(Z.srcStart+B*Ie.slope);let Ue=Ie.slope/ve*100;Math.abs(Ue-100)<.5?delete Z.speed:Z.speed={slope:Ie.slope/ve,percent:Ue,kind:"retime",samples:Ie.anchors.length,residual:0,basis:Ie.model==="retime"?"measured":"frame-for-frame"}};{let Z=0;await Promise.all(Array.from({length:dy},async()=>{for(;Z<je.length;)await Cm(je[Z++])}))}for(let{seg:Z,rate:ee}of Ii){let ce=(Hn.get(ee.toFixed(4))??[]).sort((Ue,He)=>He.votes-Ue.votes);if(!ce.length||ce[1]&&ce[1].votes===ce[0].votes)continue;let ve=ce[0].slopeOverRate*ee,B=Z.refEnd-Z.refStart,se=Z.srcStart,Fe=Z.srcEnd??se+B*ee,dt=Z.refStart+Z.refEnd>>1,Ie=se+(B?(dt-Z.refStart)*(Fe-se)/B:0);Z.srcStart=Math.round(Ie-(dt-Z.refStart)*ve),Z.srcEnd=Math.round(Ie+(Z.refEnd-dt)*ve);let yt=ce[0].slopeOverRate*100;Math.abs(yt-100)<.5?delete Z.speed:Z.speed={slope:ce[0].slopeOverRate,percent:yt,kind:"retime",samples:ce[0].votes,residual:0,basis:"convention"}}{let yt=zo,Ue=zp,He=new Map,St=(Ce,yn)=>{let Bn=He.get(Ce);return Bn||(Bn=yn().catch(()=>null),He.set(Ce,Bn)),Bn},Qt=Ce=>{let yn=Ce.srcFps&&q.fps?Ce.srcFps/q.fps:1;return(H[Ce.clipIndex]??1)!==1?H[Ce.clipIndex]:Math.abs(yn-1)>.01?yn:1},Wt=typeof process<"u"&&!!process.env?.CONFORM_DEBUG_NOMINATIONS,me=160,Be=new Map,Ee=async(Ce,yn,Bn,Nr,Xn,N)=>{let ue=D.find(Pt=>Pt.clipIndex===Ce),We=ue?.srcFrames??0;if(!We)return[];let Ae=js(Bn[Bn.length-1]-Nr,yn),pt=[0,Bn.length>>1,Bn.length-1].filter((Pt,Bt,Vt)=>Vt.indexOf(Pt)===Bt),qe=await Promise.all(pt.map(Pt=>we(Bn[Pt]).then(Bt=>yt(jn(Bt,me),me)).catch(()=>null))),ht=Xn?Xn.refToSrc.map(Pt=>Pt.toFixed(4)).join(","):"",ot=Pt=>{let Bt=`${Ce}@${Pt}|${ht}`,Vt=Be.get(Bt);return Vt||(Vt=(k??Se)(Ce,Pt).then(kn=>{if(!kn)return null;if(!Xn)return yt(jn(kn,me),me);let Dn=kn.w/Xn.srcW,ir=kn.h/Xn.srcH,Lt=Xn.refToSrc;return yt(hi(kn,[Lt[0]*Dn,Lt[1]*Dn,Lt[2]*Dn,Lt[3]*ir,Lt[4]*ir,Lt[5]*ir,Lt[6],Lt[7],Lt[8]],Xn.refW,Xn.refH,me),me)}).catch(()=>null),Be.set(Bt,Vt)),Vt},Ye=We<=oi?0:Math.max(0,Math.min(We-oi,N-(oi>>1))),Qe=Math.min(We,Ye+oi)-1-Ae,gt=[];for(let Pt=Ye;Pt<=Qe;Pt+=_c){L();let Bt=Array.from({length:Math.min(_c,Qe-Pt+1)},(kn,Dn)=>Pt+Dn),Vt=await Promise.all(Bt.map(async kn=>{let Dn=0,ir=0;for(let Lt=0;Lt<pt.length;Lt++){let Qn=await ot(kn+js(Bn[pt[Lt]]-Nr,yn));qe[Lt]&&Qn&&Qn.length===qe[Lt].length&&(Dn+=Ue(qe[Lt],Qn),ir++)}return ir?Dn/ir:-1}));Bt.forEach((kn,Dn)=>gt.push([kn,Vt[Dn]]))}gt.sort((Pt,Bt)=>Bt[1]-Pt[1]);let en=[];for(let[Pt]of gt)if(en.every(Bt=>Math.abs(Bt-Pt)>=4)&&en.push(Pt),en.length>=4)break;return Wt&&console.error(`[exact] swept ${gt.length} in-points of ${ue?.label}: ${en.map(Pt=>`${Pt}:${gt.find(Bt=>Bt[0]===Pt)[1].toFixed(3)}`).join(" ")}`),en},dn=async Ce=>{if(!Ce.clipLabel||Ce.kind==="gap"||Ce.kind==="composite"||Ce.srcStart==null)return;let yn=D.find(lt=>lt.label===Ce.clipLabel);if(!yn)return;let Bn=yn.clipIndex,Nr=Qt(yn),Xn=Ce.speed?Ce.speed.slope*Nr:Nr,N=Xn,ue=Ce.refEnd-Ce.refStart+1;if(ue<2||!(N>0))return;let We=Ce.srcStart,Ae=(lt,Ne)=>lt+js(Ne-Ce.refStart,N),pt=lt=>lt>=0&&!(yn.srcFrames&&lt>=yn.srcFrames),qe=Ce.track?.kind==="animated",ht=Math.min(qe?8:16,ue),ot=Array.from({length:ht},(lt,Ne)=>Ce.refStart+Math.round((Ne+.5)*ue/ht-.5)),Ye=async(lt,Ne,$e)=>{let Ke=(await Promise.all(lt.map(async hn=>{let $t=Ae(Ne,hn);if(!pt($t))return null;let[Rr,qt]=await Promise.all([we(hn),De(Bn,$t)]);return Rr&&qt?{ref:Rr,src:qt}:null}))).filter(hn=>!!hn),Ft=Ke.length>=3?await Mi(Ke,$e).catch(()=>null):null,Ct=Ft?ao(Ft.transform):null;if(!Ft||!Ct)return null;let wn=Ft.transform,pn=wn[0]*wn[4]-wn[1]*wn[3]<0||Math.abs(Math.atan2(wn[3],wn[0])*180/Math.PI)>.5;return{warp:{refToSrc:Ct,refW:Ke[0].ref.w,refH:Ke[0].ref.h,srcW:Ke[0].src.w,srcH:Ke[0].src.h},turned:pn}},Qe=qe||qc(Ce),gt=lt=>[lt-1,lt,lt+1].filter(Ne=>Ne>=Ce.refStart&&Ne<=Ce.refEnd).concat(lt===Ce.refStart?[lt+2]:lt===Ce.refEnd?[lt-2]:[]),en=Oi(Ce.refStart,Ce.refEnd,6),Pt={},Bt=async lt=>{if(qe){let $e=await Promise.all(ot.map(Ke=>Ye(gt(Ke),lt,Pt)));return $e.some(Ke=>!Ke)?null:$e.map(Ke=>Ke.warp)}let Ne=await Ye(en,lt,Pt);return Ne?ot.map(()=>Ne.warp):null};if(Qe){let lt=qe?await Ye(gt(ot[ht>>1]),We,{}):await Ye(en,We,{});lt&&!lt.turned&&(Pt=jp)}let Vt=await Promise.all(ot.map(lt=>St(`r@${lt}`,()=>we(lt).then(Ne=>yt(jn(Ne,640),640))))),kn=(lt,Ne)=>St(`c${Bn}@${lt}|${Ne?Ne.refToSrc.map($e=>$e.toFixed(4)).join(","):""}`,()=>De(Bn,lt).then($e=>yt(Ne?hi($e,Ne.refToSrc,Ne.refW,Ne.refH,640):jn($e,640),640))),Dn=async(lt,Ne)=>{let $e=await Promise.all(lt.map((Ct,wn)=>kn(Ct,Ne[wn]))),Ke=0,Ft=0;for(let Ct=0;Ct<ht;Ct++)Vt[Ct]&&$e[Ct]&&Vt[Ct].length===$e[Ct].length&&(Ke+=Ue(Vt[Ct],$e[Ct]),Ft++);return Ft>=Math.max(1,ht>>1)?Ke/Ft:null},ir=!1,Lt=async lt=>{let Ne=[];for(let $e=-2;$e<=2;$e++){let Ke=ot.map(pn=>Ae(lt+$e,pn));if(!pt(Ke[0])||!pt(Ke[ht-1]))continue;let Ft=await Dn(Ke,ot.map(()=>null)),Ct=Qe?await Bt(lt+$e):null,wn=Ct?await Dn(Ke,Ct):null,un=Math.max(Ft??-1/0,wn??-1/0);wn!=null&&(Ft==null||wn>Ft)&&(ir=!0),un>-1/0&&Ne.push([lt+$e,un])}return Ne},Qn=await Lt(We),fr=Qn.find(([lt])=>lt===We)?.[1];if(fr==null||Qn.length<2){Wt&&console.error(`[exact] ${Ce.clipLabel} rec ${Ce.refStart}\u2013${Ce.refEnd}: nothing to compare`);return}let En=Qn.reduce((lt,Ne)=>Ne[1]>lt[1]?Ne:lt);if(Wt&&console.error(`[exact] ${Ce.clipLabel} rec ${Ce.refStart}\u2013${Ce.refEnd}${ir?qe?" (animated sizing)":" (sized)":""}: ${Qn.map(([lt,Ne])=>`${lt-We>0?"+":""}${lt-We}:${Ne.toFixed(4)}`).join(" ")}`),En[1]<.9){let lt=await Ee(Bn,N,ot,Ce.refStart,Qe?(await Bt(En[0]))?.[ht>>1]??null:null,We);for(let Ne of lt.filter($e=>Math.abs($e-En[0])>2)){let $e=await Lt(Ne),Ke=$e.length?$e.reduce((Ft,Ct)=>Ct[1]>Ft[1]?Ct:Ft):null;Wt&&console.error(`[exact] sweep peak ${Ne}: ${Ke?`${Ke[0]} ${Ke[1].toFixed(4)}`:"\u2014"}`),Ke&&Ke[1]>En[1]+.02&&(En=Ke)}}let mn=Xn;if(Math.abs(Nr-1)>.01){let lt=ot[ht>>1],Ne=En[0]+js(lt-Ce.refStart,Xn);for(let $e of[Nr,1]){if(Math.abs($e-Xn)<1e-6)continue;N=$e;let Ke=await Lt(Ne-js(lt-Ce.refStart,$e)),Ft=Ke.length?Ke.reduce((Ct,wn)=>wn[1]>Ct[1]?wn:Ct):null;Wt&&console.error(`[exact] speed ${($e/Nr*100).toFixed(0)} %: ${Ft?`${Ft[0]} ${Ft[1].toFixed(4)}`:"\u2014"} vs ${(Xn/Nr*100).toFixed(0)} % ${En[1].toFixed(4)}`),Ft&&Ft[1]>En[1]+.01&&(En=Ft,mn=$e)}N=mn}if((En[0]!==We||mn!==Xn)&&En[1]>fr+.002&&(Wt&&console.error(`[exact] \u2192 start ${We} \u2192 ${En[0]}${mn!==Xn?`, speed ${(Xn/Nr*100).toFixed(0)} \u2192 ${(mn/Nr*100).toFixed(0)} %`:""} (${fr.toFixed(4)} \u2192 ${En[1].toFixed(4)})`),Ce.srcStart=En[0],Ce.srcEnd=Math.round(En[0]+(Ce.refEnd-Ce.refStart)*mn),mn!==Xn)){let lt=mn/Nr*100;Math.abs(lt-100)<.5?delete Ce.speed:Ce.speed={slope:mn/Nr,percent:lt,kind:"retime",samples:ht,residual:0,basis:"frame-for-frame"}}},Vn=0;await Promise.all(Array.from({length:dy},async()=>{for(;Vn<je.length;)L(),await dn(je[Vn++])}))}i?.(t.length,t.length,"attribution");{let Z=new Map,ee=new Array(q.offs.length);for(let ce of je)if(!(!ce.clipLabel||ce.kind==="gap")){Z.set(ce.clipLabel,(Z.get(ce.clipLabel)??0)+(ce.refEnd-ce.refStart+1));for(let ve=ce.refStart;ve<=ce.refEnd;ve++)ee[ve]=ce.clipLabel}for(let ce of D){for(let ve of ce.shots){let B=ve.refStart+ve.refEnd>>1,se=ee[B];ve.contestedBy=se&&se!==ce.label?se:null}ce.coverage=ce.srcFrames?Math.min(1,(Z.get(ce.label)??0)/ce.srcFrames):0}}return i?.(t.length,t.length,"done"),{refFps:q.fps,refStartFrame:q.startFrame,refFrames:q.offs.length,refDropFrame:q.dropFrame,refW:q.w,refH:q.h,clips:D,timeline:je,shotVotes:rr,lumaCache:ne.stats(),...be.length?{hints:{timelineName:x?.timelineName??"",verdicts:be,summary:E8(be),warnings:x?.warnings??[]}}:{},...Ht?{triage:{scores:Mt.map(({clipIndex:Z,label:ee,hits:ce,minDistance:ve,probes:B})=>({clipIndex:Z,label:ee,hits:ce,minDistance:ve,probes:B})),examined:t.length-ft.length,skipped:ft.length}}:{}}}var Zs=1280;function tC(e){if(e.w<=Zs)return e;let t=f6(e.y,e.w,e.h,Zs),n=new DataView(t.buffer,t.byteOffset,t.byteLength),i=n.getUint32(0,!0),r=n.getUint32(4,!0);return{y:t.subarray(8,8+i*r),w:i,h:r}}async function Zp(e,t="coarse"){let n=await gn(e),i=async(o,a,s)=>{let{offset:c,size:l}=n.frames[o]??{offset:0,size:0};return l>0?await lp(e,c,l,a,s):null},r=async o=>{let a=null;try{if(n.geometrySpec){let s=await i(o,n.geometrySpec,t);s&&(a={y:s.y instanceof Uint8Array?s.y:Uint8Array.from(s.y),w:s.w,h:s.h})}else if(n.spec?.codec==="prores"){let s=t==="index"?null:nk(),l=(s?await s(e,n,o).catch(()=>null):null)??await i(o,n.spec,t==="index"?"index":"exact");l&&(a={y:l.y,w:l.w,h:l.h})}else a=await rk(e,n,o)}catch{}return a?tC(a):null};return{src:n,frames:n.frames.length,luma:r}}var nC=Number(Ut("CONFORM_DECODERS")??0)||Math.max(2,Math.min(Math.floor(Po()/2),Math.floor(xo()/2**31))),py=0,u5=[],wf=async(...e)=>{py>=nC?await new Promise(t=>u5.push(t)):py++;try{return await nf(...e)}finally{let t=u5.shift();t?t():py--}},Wp=256;async function Vr(){let e=xr()==="win32"?"conformtools-decode.exe":"conformtools-decode",t=[Ut("CONFORM_NATIVE_DECODE"),Fr(new URL(`./${e}`,import.meta.url)),Fr(new URL(`../../rust/target/release/${e}`,import.meta.url))].filter(Boolean);for(let n of t)if(await Ar(n))return n;return null}var Ea=class extends Error{constructor(n,i){super(i);this.why=n}};function Dp(e,t){try{let n=JSON.parse(e.trim().split(`
9
+ `).pop()??"");return new Ea(n.why,n.detail)}catch{return new Ea("decoder",`the native decoder exited ${t}: ${e.trim().slice(-300)}`)}}async function Ws(e){let t=await Vr();if(!t)throw new Ea("missing","the native decoder (conformtools-decode) is not installed");let n=[],i=await wf(t,["probe",e],r=>n.push(r));if(i.code!==0)throw Dp(i.stderr,i.code);return JSON.parse(new TextDecoder().decode(xf(n)))}function xf(e){let t=e.reduce((r,o)=>r+o.length,0),n=new Uint8Array(t),i=0;for(let r of e)n.set(r,i),i+=r.length;return n}var $c=new Map;function el(e,t,n,i=Wp){let r=`${e}\0${i}`,o=$c.get(r);return o||(o=rC(e,t,n,i),$c.set(r,o),o.catch(()=>$c.delete(r))),o}async function m5(e){let t=new Set(e);for(let n of t)hy.delete(n);for(let[n,i]of[...$c.entries()])if(t.has(n.split("\0")[0])){$c.delete(n);try{await(await i).dispose()}catch{}}}async function rC(e,t,n,i=Wp){let r=await Vr();if(!r)throw new Ea("missing","the native decoder (conformtools-decode) is not installed");let o=_(wt(),"decode-cache");await vt(o);let a=_(o,`${Date.now()}-${Math.random().toString(36).slice(2)}.luma`),s=await tp(a),c=null,l=new Uint8Array(0),u=0,f=new Set,d=[],m=await wf(r,["luma",e,"--width",String(i)],b=>{if(l=l.length?xf([l,b]):b,!c){let g=l.indexOf(10);if(g<0)return;c=JSON.parse(new TextDecoder().decode(l.subarray(0,g))),u=c.w*c.h,l=l.subarray(g+1)}let h=4+u,v=0;for(;l.length-v>=h;){let g=new DataView(l.buffer,l.byteOffset+v,4).getUint32(0,!0);d.push(s.writeAt(g*u,l.slice(v+4,v+h))),f.add(g),v+=h,f.size%48===0&&t?.(f.size,c.emitted)}l=l.subarray(v)},{signal:n});if(await Promise.all(d),await s.close(),m.code!==0||!c)throw await Er(a),Dp(m.stderr,m.code);let p=c;return t?.(f.size,p.emitted),{w:p.w,h:p.h,fps:p.fps,frames:p.frames,codec:p.codec,has:b=>f.has(b),async read(b){if(!f.has(b))return null;let h=await Ec(a);try{return{y:await h.readAt(b*u,u),w:p.w,h:p.h}}finally{await h.close()}},async dispose(){$c.delete(`${e}\0${i}`),await cn(a).catch(()=>null)&&await Er(a)}}}async function Pf(e,t,n,i={}){let r=await Vr();if(!r)throw new Ea("missing","the native decoder (conformtools-decode) is not installed");let o=null,a=new Uint8Array(0),s=0,c=["bgra",e,"--width",String(i.width??32768)];i.from!=null&&c.push("--from",String(i.from)),i.count!=null&&c.push("--count",String(i.count));let l=await wf(r,c,u=>{if(a=a.length?xf([a,u]):u,!o){let m=a.indexOf(10);if(m<0)return;o=JSON.parse(new TextDecoder().decode(a.subarray(0,m))),s=o.w*o.h*4,t(o),a=a.subarray(m+1)}let f=4+s,d=0;for(;a.length-d>=f;){let m=new DataView(a.buffer,a.byteOffset+d,4).getUint32(0,!0);n(m,a.slice(d+4,d+f)),d+=f}a=a.subarray(d)},{signal:i.signal});if(l.code!==0||!o)throw Dp(l.stderr,l.code)}var iC=Number(Ut("CONFORM_DECODE_CACHE_MB")??0)*2**20||Math.max(1.5*2**30,Math.min(4*2**30,xo()/10)),Ha=[],Ip=0;function oC(e,t){let n={bytes:e,drop:t};for(Ha.push(n),Ip+=e;Ip>iC&&Ha.length>1;){let i=Ha.shift();Ip-=i.bytes,i.drop()}return n}function aC(e){let t=Ha.indexOf(e);t>=0&&Ha.push(...Ha.splice(t,1))}function sC(e){let t=Ha.indexOf(e);t>=0&&(Ha.splice(t,1),Ip-=e.bytes)}var Is={runs:0,frames:0,unique:0},f5=new Map,cC=!!globalThis.process?.env?.CONFORM_DEBUG_NOMINATIONS;function na(e,t=Zs,n=24){let i=[],r=null,o=-1,a=0,s=0,c=0,l;async function u(m,p,b){let h=await Vr();if(!h)throw new Ea("missing","the native decoder (conformtools-decode) is not installed");let v=new Map,g=null,y=new Uint8Array(0),w=0;Is.runs++,Is.frames+=p;let x=["luma",e,"--width",String(t),"--from",String(m),"--count",String(p)];b>1&&x.push("--stride",String(b));let T=await wf(h,x,z=>{if(y=y.length?xf([y,z]):z,!g){let S=y.indexOf(10);if(S<0)return;g=JSON.parse(new TextDecoder().decode(y.subarray(0,S))),w=g.w*g.h,y=y.subarray(S+1)}let k=0;for(;y.length-k>=4+w;){let S=new DataView(y.buffer,y.byteOffset+k,4).getUint32(0,!0);v.set(S,y.slice(k+4,k+4+w)),k+=4+w}y=y.subarray(k)});if(T.code!==0||!g)throw Dp(T.stderr,T.code);if(cC){let z=`${e}@${t}`,k=f5.get(z);k||f5.set(z,k=new Set);for(let S of v.keys())k.has(S)||(k.add(S),Is.unique++)}return r={w:g.w,h:g.h},v}let f=(m,p)=>p>=m.from&&p<m.from+m.count&&(p-m.from)%m.stride===0;function d(m,p,b){let h={from:m,count:p,stride:b,frames:u(m,p,b)};return h.h=oC(Math.ceil(p/b)*t*Math.ceil(t*9/16),()=>{i=i.filter(v=>v!==h)}),h.frames.catch(()=>{i=i.filter(v=>v!==h),sC(h.h)}),i.push(h),h}return{async read(m){let p=m-o;s=p>1&&p<=16&&p===a?s+1:0,c=Math.abs(p)>n?c+1:0,a=p,o=m;let b=i.find(v=>f(v,m));if(b)aC(b.h);else if(s>=2)b=d(m,a*n*4,a);else if(c>=2)b=d(m,1,1);else{let v=await(l??=qp(e).catch(()=>null)),g=v&&v.length>1?lC(v,m):null;b=i.find(y=>f(y,m))??(g&&g.count>1&&g.count<=4*n?d(g.from,g.count,1):d(m-m%n,n,1))}if(b.stride>1&&s>=2){let v=b.from+b.count;i.some(g=>g.from===v&&g.stride===b.stride)||d(v,b.count,b.stride)}let h=(await b.frames).get(m);return h&&r?{y:h,w:r.w,h:r.h}:null}}}function lC(e,t){let n=0,i=e.length-1;if(t<e[0])return null;for(;n<i;){let r=n+i+1>>1;e[r]<=t?n=r:i=r-1}return n+1<e.length?{from:e[n],count:e[n+1]-e[n]}:null}var hy=new Map;function p5(){return async(e,t,n)=>{let i=e.path;if(!i||!await Vr())return null;let r=hy.get(i);return r||hy.set(i,r=na(i)),r.read(n).catch(()=>null)}}var d5=new Map;function qp(e){let t=d5.get(e);return t||(t=(async()=>{let n=await Vr();if(!n)return null;let i=await Mn(n,["keyframes",e],{timeoutMs:6e4});if(!i.success)return null;try{let r=JSON.parse(i.stdout.trim().split(`
10
+ `).pop()??"{}");return Array.isArray(r.keyframes)?r.keyframes:null}catch{return null}})(),d5.set(e,t)),t}function h5(e=16e3){return async t=>{let n=t.path,i=n?await Vr():null;if(!i||!n)return null;let r=[],o=null,a=new Uint8Array(0);return(await wf(i,["audio",n,"--rate",String(e)],c=>{if(a=a.length?xf([a,c]):c,!o){let d=a.indexOf(10);if(d<0)return;o=JSON.parse(new TextDecoder().decode(a.subarray(0,d))),a=a.subarray(d+1)}let l=a.length>>1;if(!l)return;let u=new DataView(a.buffer,a.byteOffset,l*2),f=new Float32Array(l);for(let d=0;d<l;d++)f[d]=u.getInt16(d*2,!0)/32768;r.push(f),a=a.subarray(l*2)})).code!==0||!o||!r.length?null:{sampleRate:e,channels:1,chunks:(async function*(){yield*r})()}}}var ra=new Set([".mov",".mp4",".m4v",".mxf",".wav",".braw",".crm",".r3d",".aif",".aiff"]);async function uC(e){let t=await Ec(e);return{path:e,file:t,size:t.size}}function fC(e){return(t,n)=>e.file.readAt(t,n)}async function Ds(e){let t=ri(ae(e));if(!t)return[e];let n=Yn(e),i=[];for await(let r of zn(n)){if(!r.isFile)continue;let o=ri(r.name);o&&o.clipBase===t.clipBase&&i.push({n:o.partNumber,p:_(n,r.name)})}return i.sort((r,o)=>r.n-o.n).map(r=>r.p)}async function by(e){if(await Wi(e)){let o=[];for await(let a of zn(e))a.isFile&&ri(a.name)&&o.push(_(e,a.name));if(!o.length)throw new Error(`'${ae(e)}' is a folder with no .R3D parts`);e=o.sort()[0]}let t=X6(ae(e));if(!t)throw new Error(`unsupported media file '${ae(e)}' (supported: ${[...ra].join(" ")})`);let n=await Ds(e),i=await Promise.all(n.map(uC));return{source:Qm(t,i.map(o=>Km(ae(o.path),{fileSize:o.size,read:fC(o)}))),parts:i,format:t,anchor:n[0],close:()=>i.forEach(o=>o.file.close())}}async function tl(e,t,n){if(!/h264|avc|hevc|h265/.test(n)){let s=await by(e);try{return await Yo(s.source,{verb:"decode",index:t,intent:"park"})}catch(c){if(!/no decoder/.test(String(c)))throw c}finally{s.close()}}let i=0,r=0,o=null;if(await Pf(e,s=>{i=s.w,r=s.h},(s,c)=>{s===t&&(o=c)},{from:t,count:1}),!o)throw new Error(`the OS decoder returned no frame ${t} of ${ae(e)}`);let a=o;for(let s=0;s<a.length;s+=4){let c=a[s];a[s]=a[s+2],a[s+2]=c}return{rgba:a,width:i,height:r}}async function Rn(e){let t=await by(e);try{let n=await Yo(t.source,{verb:"inspect"});if(!n)throw new Error(`could not read '${ae(e)}' as ${t.format}`);return n.target_url=t.anchor,n.local_path=t.anchor,n.id=n.id||ae(t.anchor),t.parts.length>1&&((n.vendor_metadata??={}).spanned_parts=t.parts.map(i=>ae(i.path))),n.size_bytes=t.parts.reduce((i,r)=>i+r.size,0),n}finally{t.close()}}function gy(e,t,n,i){let r=Math.abs(i*1001-Math.round(i*1001/1e3)*1e3)<1?Math.round(i)*1e3/1001:i,o=Math.floor(e*r/t+1e-6);return{tc:tn(o,i),frames:Math.round(n*r/t)}}var dC=e=>String(Math.round(e*1e3)/1e3);function g5(e,t){let n=e.streams?.find(f=>f.kind==="video"),i=e.streams?.filter(f=>f.kind==="audio")??[],r=e.vendor_metadata?.bext;if(!n&&e.available_range&&i[0]?.rate){let f=i[0].rate,d=e.available_range.duration.value,p=(t?[t]:[24e3/1001,24]).map(b=>{let h=gy(r?.time_reference??0,r?.sample_rate||f,d,b);return`${r?`start TC ${h.tc}, `:""}${h.frames} frames @ ${dC(b)} fps`});return[e.target_url??"",`audio only; ${d} samples (${(d/f).toFixed(3)} s)${r?`; BWF time_reference ${r.time_reference}`:"; no BWF timecode"}`,...p,...t?[]:["(pass fps for the project's rate)"],...i.map((b,h)=>`audio ${i.length>1?`${h+1}: `:""}${b.codec??"pcm"} ${b.channels??"?"}ch ${b.rate} Hz ${b.bit_depth??"?"}-bit`)].join(`
11
+ `)}let o=e.available_range?.duration?.value??e.declared_duration?.value??null,a=e.source_fps??n?.rate??null,s=e.size_bytes,c=e.vendor_metadata?.spanned_parts,l=n?.codec_specific??{},u=[l.profile?`${l.profile} (${l.fourcc})`:l.fourcc,l.pixel_format,n?.bit_depth?`${n.bit_depth}-bit`:null,l.colr?`colour ${l.colr.primaries}/${l.colr.transfer}/${l.colr.matrix} (primaries/transfer/matrix)`:null].filter(Boolean).join(", ");return[e.target_url??"",n?`${n.codec??"?"} ${n.width??"?"}x${n.height??"?"}${a?` @ ${Math.round(a*1e3)/1e3} fps`:""}${u?`; ${u}`:""}`:"no video track",`start TC ${e.source_timecode??"none"}; ${o!=null?`${o} frames`:"length unknown"}${o!=null&&a?` (${(o/a).toFixed(2)} s)`:""}`,i.length?i.map((f,d)=>{let m=f.codec_specific?.channel_layout;return`audio ${i.length>1?`${d+1}: `:""}${f.codec??"pcm"} ${f.channels??"?"}ch${m?` (${m})`:""} ${f.rate??"?"} Hz ${f.bit_depth??"?"}-bit`}).join(`
12
+ `):"no audio",`${e.reel_name?`reel ${e.reel_name}; `:""}${s!=null?`${(s/1e6).toFixed(1)} MB`:""}${c?`; spanned ${c.length} parts`:""}`].join(`
13
+ `)}var mC=8*1024*1024,Hp=e=>Uint8Array.from(atob(e),t=>t.charCodeAt(0));async function pC(e,t,n){if(e.executable_locally===!1)throw new Error("this trim plan is server-side only");let i=new Map(t.parts.map(o=>[ae(o.path),o]));await vt(Yn(n));let r=await tp(n);try{await r.truncate(e.total_size),await r.writeAt(0,Hp(e.dest_header_bytes_base64));for(let o of e.src_byte_ranges){let a=o.src_file_name?i.get(ae(o.src_file_name)):t.parts[0];if(!a)throw new Error(`plan references unknown source part '${o.src_file_name}'`);let s=0;for(;s<o.length;){let c=Math.min(mC,o.length-s),l=await a.file.readAt(o.offset+s,c);if(l.length<c)throw new Error(`short read in ${ae(a.path)} at ${o.offset+s}`);await r.writeAt(o.write_to_dest_offset+s,l),s+=c}}e.dest_footer_bytes_base64&&e.dest_footer_offset!=null&&await r.writeAt(e.dest_footer_offset,Hp(e.dest_footer_bytes_base64));for(let o of e.dest_patches??[])await r.writeAt(o.offset,Hp(o.bytes_base64))}finally{await r.close()}for(let o of e.dest_sidecar_writes??[])await or(_(Yn(n),o.name),Hp(o.bytes_base64))}function hC(e,t){let n=[];for(let i of e){if(i.kind!=="clip"||!i.source_range)continue;let r=i.source_range.start.value,o=i.source_range.duration.value,a=Math.max(0,Math.floor(r)-t),s=Math.floor(r+o-1)+t;s>=a&&n.push({first_frame:a,last_frame:s})}return y6(n)}async function vy(e,t,n,i,r){let o=await by(e);try{let a=hC(t,n);if(!a.length)throw new Error("no usable frame ranges (items need kind=clip with source_range)");let s=await Yo(o.source,{verb:"trim",selection:{items:t,handles:n}}),c=Pr(o.anchor),l=o.format==="r3d",u=l?ri(ae(o.anchor))?.clipBase??ae(o.anchor,c):ae(o.anchor,c),f=[];for(let[d,m]of s.entries()){let p=m.output_clip_number??(a.length>1?d+1:void 0),b=a[(p??1)-1]??a[0],h=p&&(m.output_clip_count??a.length)>1?`_S${String(p).padStart(3,"0")}`:"",v;if(l){let g=m.output_part_number??d+1;v=_(i,`${u}${h}.RDC`,`${u}_${String(g).padStart(3,"0")}.R3D`),f.push({path:v,bytes:m.total_size,island:b,part:g,clip:p})}else{let g=r&&s.length===1?r:`${u}${h||`_trim_${b.first_frame}-${b.last_frame}`}${c}`;v=_(i,g),f.push({path:v,bytes:m.total_size,island:b,clip:p})}await pC(m,o,v)}return{outputs:f,islands:a,format:o.format}}finally{o.close()}}async function Ep(e){let t=await Rn(e.path),n=t.source_fps??t.streams?.find(f=>f.kind==="video")?.rate??null,i=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 r=Jr(e.in,n,t.source_timecode??null),o=Jr(e.out,n,t.source_timecode??null);if(e.out_exclusive&&(o-=1),o<r)throw new Error(`out (${o}) is before in (${r})`);if(r<0)throw new Error(`in (${r}) is before the file start (TC ${t.source_timecode})`);if(i!=null&&o>i-1)throw new Error(`out (${o}) is past the last frame (${i-1})`);let a={id:"trim",kind:"clip",source_range:{start:{value:r,rate:n},duration:{value:o-r+1,rate:n}}},s=Yn(e.path),c;if(e.out_path)try{(await cn(e.out_path)).isDirectory?s=e.out_path:(s=Yn(e.out_path),c=ae(e.out_path))}catch{s=Yn(e.out_path),c=ae(e.out_path)}let l=await vy(e.path,[a],Math.max(0,Math.floor(e.handles??0)),s,c),u=l.islands[0];return{outputs:l.outputs,first_frame:u.first_frame,last_frame:u.last_frame,frames:u.last_frame-u.first_frame+1,fps:n,facts:t}}function b5(e){let t=[...ra].map(n=>n.slice(1)).join("|");return e.toLowerCase().replace(new RegExp(`\\.(${t})(?=[._\\s-]|$)`,"g"),"").replace(/[^a-z0-9]/g,"")}function bC(e,t){let n=b5(e),i=b5(t);if(i&&n.includes(i))return"name";let r=t.toLowerCase().split(/[^a-z0-9]+/).filter(o=>/\d/.test(o)&&o.length>=3);return r.length&&r.every(o=>n.includes(o))?"id":null}async function v5(e,t,n){let i=[],r=0,o=null,a=Date.now()+n.time_limit_s*1e3,s=async(c,l)=>{try{for await(let u of zn(c)){if(o&&!o.startsWith("folders"))return;if(++r>n.max_entries){o=`stopped after ${n.max_entries} entries (max_entries)`;return}if(Date.now()>a){o=`stopped after ${n.time_limit_s} s (time_limit_s)`;return}if(u.name.startsWith("."))continue;let f=_(c,u.name);if(u.isDirectory)l<n.max_depth?await s(f,l+1):o??=`folders deeper than max_depth=${n.max_depth} not searched (e.g. ${f})`;else if(u.isFile&&ra.has(Pr(u.name).toLowerCase())){let d=bC(u.name,t);d&&i.push({path:f,match:d,size:(await cn(f).catch(()=>({size:0}))).size})}}}catch{}};if(await s(e,0),n.probe)for(let c=0;c<i.length;c+=8)await Promise.all(i.slice(c,c+8).map(async l=>{try{l.facts=await Rn(l.path)}catch(u){l.error=u.message}}));return i.sort((c,l)=>c.path.localeCompare(l.path)),{hits:i,scanned:r,truncated:o}}function Sf(e){let t=e.streams?.find(s=>s.kind==="video"),n=e.source_fps??t?.rate??null,i=e.available_range?.duration?.value??e.declared_duration?.value??null,r=t?.codec_specific??{},o=e.source_timecode&&n?Kn(e.source_timecode,n):null,a=o!=null&&i!=null&&n?tn((o+i)%(Math.round(n)*86400),n,e.source_timecode.includes(";")):null;return`${t?`${t.codec??"?"}${r.profile?` ${r.profile}`:""} ${t.width??"?"}x${t.height??"?"}`:"no video"}${n?` @ ${Math.round(n*1e3)/1e3} fps`:""}; TC ${e.source_timecode??"none"}${a?`\u2013${a}`:""}; ${i??"?"} fr${i!=null&&n?` (${(i/n).toFixed(2)} s)`:""}`}function y5(e,t,n,i){let r=e.hits.slice(0,i),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>r.length&&o.push(`TRUNCATED: showing ${r.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 a=new Map;for(let c of e.hits)a.set(ae(c.path).toLowerCase(),(a.get(ae(c.path).toLowerCase())??0)+1);let s=[...a].filter(([,c])=>c>1);s.length&&o.push(`same name in several folders: ${s.map(([c,l])=>`${c} \xD7${l}`).join(", ")} \u2014 they can be DIFFERENT clips; match by TC + duration, never by name alone`);for(let c of r)o.push(`- ${c.path}${c.match==="id"?" (id match)":""}
14
+ ${c.facts?Sf(c.facts):c.error?`probe failed: ${c.error}`:`${(c.size/1e6).toFixed(1)} MB`}`);return o.join(`
15
+ `)}async function w5(e,t,n=0){let i=await Rn(e),r=i.source_fps??i.streams?.find(d=>d.kind==="video")?.rate??null,o=i.available_range?.duration?.value??i.declared_duration?.value??null;if(!r||o==null)throw new Error(`cannot check coverage: ${ae(e)} has no frame rate or length`);let a=Math.round(r)*86400,s=i.source_timecode?Kn(i.source_timecode,r)??0:0,c=!!i.source_timecode?.includes(";"),l=d=>{let m=Jr(d,r,i.source_timecode??null);return typeof d=="number"||/^\d+$/.test(d.trim())?m:m<-a/2?m+a:m>a/2?m-a:m},u=d=>tn(((s+d)%a+a)%a,r,c),f=t.map((d,m)=>{let p=l(d.in),b=l(d.out),h=p,v=o-b,g=h>=0&&v>=0&&b>p,y=Math.max(0,-h),w=Math.max(0,-v),x=[];return b<=p?x.push("out is not after in"):g?x.push(`covered; handles head ${h} / tail ${v} fr`):x.push(`NOT covered: short ${[y?`${y} fr at head`:"",w?`${w} fr at tail`:""].filter(Boolean).join(", ")}`),g&&n&&(h<n||v<n)&&x.push(`handles short of ${n}: ${[h<n?`head by ${n-h}`:"",v<n?`tail by ${n-v}`:""].filter(Boolean).join(", ")}`),{label:d.label??`range ${m+1}`,in_tc:u(p),out_tc:u(b),frames:b-p,covered:g,head:h,tail:v,short_head:y,short_tail:w,note:x.join("; ")}});return{facts:i,rows:f}}var x5={facility:"",templates:{}},gC={TITLE:"[^_]+",NN:"\\d{2,3}",INITIALS:"[A-Z]{2,3}",COLORSPACE:"[A-Z0-9]+",GAMMA:"[A-Z0-9.]+",FORMAT:"\\d+x\\d+[pi]\\d+",YYYYMMDD:"\\d{8}",HHMM:"\\d{4}"},wy=()=>_(wt(),"profile.json");async function Di(e){let t=x5;for(let n of[wy(),_(wt(),"naming.json")])try{t={...x5,...JSON.parse(await Tn(n))};break}catch{}return e?xy(t,e):t}function xy(e,t){let n=e.projects?.[t]??e.projects?.[t.toUpperCase()];return n?{...e,...n,templates:{...e.templates,...n.templates},values:{...e.values,...n.values},patterns:{...e.patterns,...n.patterns},codec_folders:{...e.codec_folders,...n.codec_folders},deliverables:n.deliverables??e.deliverables,conventions:{...e.conventions,...n.conventions}}:e}function S5(e,t,n){let i=/p(\d+)$/.exec(t.FORMAT??"")?.[1];if(!t.FORMAT||!i)throw new ze("invalid_args","deliverables needs FORMAT at the program's OAR, e.g. 3840x2160p23976");let r=[];for(let o of e.deliverables??[]){if(o.optional&&!n.include_optional)continue;let a=o.raster==="OAR"?t.FORMAT.replace(/p\d+$/,""):o.raster;for(let s of o.texts.length?o.texts:[""]){if(vC.test(s)&&!n.textless)continue;let c=nl(e,"deliverable",{...Cp(),...t,TEXT:s,CODEC:o.CODEC,AUDIOCONFIG:o.AUDIOCONFIG,FORMAT:`${a}p${i}`,HHMM:t.HHMM??""})+`.${o.ext}`;r.push({label:o.label,text:s,name:c,codec:o.CODEC,audio:o.AUDIOCONFIG,raster:a,container:o.raster!=="OAR"&&a!==t.FORMAT.replace(/p\d+$/,"")})}}return r}var vC=/LESS|CLEAN|NOTEXT|NO-TEXT/i;async function Py(e,t={}){if(!e||typeof e.templates!="object")throw new ze("invalid_args","a profile needs templates: {kind: template}");for(let[n,i]of Object.entries(e.templates))if(!/\[[A-Z0-9]+\??\]/.test(i))throw new ze("invalid_args",`template ${n} has no [TOKEN] elements: ${i}`);return await vt(wt()),await ln(wy(),JSON.stringify(t.stamp===!1?e:{...e,updated_at:new Date().toISOString()},null,2)),wy()}function qs(e,t){let n=e.templates[t];if(!n&&!Object.keys(e.templates).length)throw new ze("invalid_args",`no artist profile yet, so no '${t}' naming: learn it from their delivered files (artist_profile action=learn path=<a delivery folder>) or ask the artist how they name a ${t}`);if(!n)throw new ze("invalid_args",`no '${t}' template in the ${e.facility||"artist"} profile (has: ${Object.keys(e.templates).join(", ")}): ask the artist, then artist_profile action=set`);return n}var k5=e=>e.split(/(\[[A-Z0-9]+\??\])/).filter(Boolean).map(t=>t.startsWith("[")?{tok:t.slice(1,-1).replace("?",""),opt:t.endsWith("?]")}:{lit:t}),yy=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function nl(e,t,n){let i=k5(qs(e,t)),r="";return i.forEach((o,a)=>{if("lit"in o){r+=o.lit;return}let s=n[o.tok];if(s==null||s===""){if(!o.opt)throw new ze("invalid_args",`${t} name needs ${o.tok} (template ${qs(e,t)})`);let c=i[a-1];c&&"lit"in c&&r.endsWith(c.lit.slice(-1))&&(r=r.slice(0,-1));return}r+=s}),r}function Tf(e,t,n){let i=k5(qs(e,t)),r=[],o="";i.forEach((c,l)=>{if("lit"in c){let d=i[l+1];o+=yy(d&&"tok"in d&&d.opt?c.lit.slice(0,-1):c.lit);return}let u=e.values?.[c.tok],f=e.patterns?.[c.tok]??(u?u.map(yy).join("|"):gC[c.tok]??".+?");r.push(c.tok),o+=c.opt?`(?:${yy(i[l-1]?.lit?.slice(-1)??"")}(${f}))?`:`(${f})`});let a=new RegExp(`^${o}(?:\\.([A-Za-z0-9]{2,5}))?$`).exec(ae(n));if(!a)return null;let s={};return r.forEach((c,l)=>{a[l+1]!=null&&(s[c]=a[l+1])}),{values:s,ext:a[r.length+1]??""}}var kf=e=>String(e).padStart(2,"0"),Cp=(e=new Date)=>({YYYYMMDD:`${e.getFullYear()}${kf(e.getMonth()+1)}${kf(e.getDate())}`,HHMM:`${kf(e.getHours())}${kf(e.getMinutes())}`});function yC(e){let t=Number(/^(\d+)x/.exec(e.FORMAT??"")?.[1]??0);return{JOBCODEC:/^PR/i.test(e.CODEC??"")?"pr":(e.CODEC??"").split("_")[0].toLowerCase(),JOBTEXT:e.TEXT==="TEXTLESS"?"txtls":"txtd",JOBRASTER:t>=3840?"uhd":t>=1920?"hd":"sd"}}function Sy(e,t,n){let i=e.conventions?.no_audio_tag;if(n.picture_only!==!1&&/\[AUDIOCONFIG/.test(qs(e,"patch"))&&!i)throw new ze("invalid_args","how does this artist mark a picture-only file in AUDIOCONFIG (NOAUDIO, MOS\u2026)? ask, then artist_profile action=remember conventions={no_audio_tag: '\u2026'}");let r=Tf(e,"deliverable",t);if(!r)throw new ze("invalid_args",`'${ae(t)}' does not follow the ${e.facility} deliverable template ${qs(e,"deliverable")}; name the patch from a real deliverable`);let o={...r.values,...Cp(n.when),NN:kf(n.nn),...n.text?{TEXT:n.text}:{},...n.picture_only!==!1&&i?{AUDIOCONFIG:i}:{},...Object.fromEntries((e.deprecated??[]).map(u=>[u,""]))},a=nl(e,"patch",o)+(r.ext?`.${r.ext}`:""),s=nl(e,"render_job",{...o,...yC(o)}),c=Object.entries(e.codec_folders??{}).find(([u])=>(o.CODEC??"").toUpperCase().startsWith(u))?.[1]??"",l=e.templates.deliverables_folder?nl(e,"deliverables_folder",{...o,CODECFOLDER:c}):"";return{file:a,job:s,folder:l,master_values:r.values}}var P5={ap4h:"PR4444",ap4x:"PR4444XQ",apch:"PRHQ",apcn:"PR422",apcs:"PRLT",apco:"PRPROXY"},wC={bt709:"REC709",bt2020:"REC2020",smpte432:"P3D65",smpte431:"P3DCI"},xC={smpte2084:"PQ","arib-std-b67":"HLG"},PC=e=>String(Math.round(e*1e3)/1e3).replace(".","");function ky(e){let t=e.streams?.find(o=>o.kind==="video"),n=t?.codec_specific??{},i=e.source_fps??t?.rate??0,r=e.streams?.filter(o=>o.kind==="audio")??[];return{CODEC:n.fourcc&&P5[n.fourcc]?P5[n.fourcc]:/h264|avc/i.test(t?.codec??"")?"H264":null,FORMAT:t?.width&&t.height&&i?`${t.width}x${t.height}p${PC(i)}`:null,COLORSPACE:n.colr?wC[n.colr.primaries]??null:null,GAMMA:n.colr?xC[n.colr.transfer]??null:null,AUDIOCH:r.length?String(r.reduce((o,a)=>o+(a.channels??0),0)):"0"}}function rl(e,t,n={}){let i=n.kind??(/[_-]PATCH\d/i.test(t)&&e.templates.patch?"patch":"deliverable"),r=Tf(e,i,t),o=[];if(!r){let s=/\]_\[/.test(qs(e,i))&&/[A-Z0-9]-[A-Z]/.test(t.replace(/\d-\d/g,""))?" ('-' used as a separator: this profile separates every element with '_')":"";return o.push({element:"template",level:"error",message:`does not follow the ${e.facility} ${i} template ${qs(e,i)}${s}`}),{kind:i,values:null,issues:o}}let a=r.values;for(let s of e.deprecated??[])a[s]&&o.push({element:s,level:"warn",message:`${s} ${a[s]}: in older names, left out of new ones (unless asked)`});if(n.probe){let s=ky(n.probe);for(let u of["CODEC","FORMAT","COLORSPACE","GAMMA"]){if(a[u]==null)continue;if(s[u]==null){u==="GAMMA"&&/^(PQ|HLG)$/.test(a[u])&&o.push({element:u,level:"error",message:`name says ${a[u]}, the file's transfer tag is not ${a[u]}`});continue}(u==="CODEC"?a[u]===s[u]||s[u]==="H264"&&a[u].startsWith("H264"):a[u]===s[u])||o.push({element:u,level:"error",message:`name says ${a[u]}, the file is ${s[u]}`})}let c=/^H26[45]_(\d+)mbps$/i.exec(a.CODEC??"")?.[1],l=n.probe.available_range?n.probe.available_range.duration.value/(n.probe.available_range.duration.rate||1):0;if(c&&n.probe.size_bytes&&l>1){let u=n.probe.size_bytes*8/l/1e6;(u<Number(c)*.6||u>Number(c)*1.3)&&o.push({element:"CODEC",level:"error",message:`name says ${c} Mbps, the file averages ${u.toFixed(1)} Mbps`})}if(a.AUDIOCONFIG){let u=/^(\d+)CH/.exec(a.AUDIOCONFIG)?.[1],f=e.conventions?.no_audio_tag??"NOAUDIO";a.AUDIOCONFIG===f&&s.AUDIOCH!=="0"&&o.push({element:"AUDIOCONFIG",level:"error",message:`name says ${f}, the file has ${s.AUDIOCH} audio channels`}),u&&u!==s.AUDIOCH&&o.push({element:"AUDIOCONFIG",level:"error",message:`name says ${u}CH, the file has ${s.AUDIOCH} audio channels`})}}if(n.master){let s=Tf(e,"deliverable",n.master)?.values;if(!s)o.push({element:"master",level:"error",message:`master '${ae(n.master)}' does not follow the deliverable template`});else for(let[c,l]of Object.entries(s))/^(YYYYMMDD|HHMM|TEXT)$/.test(c)||c==="AUDIOCONFIG"&&a[c]===(e.conventions?.no_audio_tag??"NOAUDIO")||a[c]!==l&&o.push({element:c,level:"error",message:`${a[c]??"(missing)"} \u2260 the master's ${l}`})}return{kind:i,values:a,issues:o}}var SC=/\.(mov|mp4|mxf|m4v|wav|aif|aiff)$/i,kC=/^(REC709|REC2020|REC2100|P3D65|P3DCI|P3D60|DCIP3|ACES|ACESCG|SRGB|XYZ)$/i,TC=/^(G\d(\.\d)?|G\d\d|PQ|HLG|ST2084|LOGC\d?|SLOG3|LINEAR|SRGB)$/i,zC=/^(TEXTED|TEXTLESS|TXTD|TXTLS|TXTLESS|CLEAN|TEXT|NOTEXT|NO-TEXT|SUBBED|SUBTITLED)$/i,MC=/^(\d+CH|NOAUDIO|MOS|STEREO|5-1|51|LTRT|LORO)$/i,OC=e=>/^(19|20)\d\d(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/.test(e);function LC(e){let t=n=>e.split(n).length-1;return["_","-"," ","."].reduce((n,i)=>t(i)>t(n)?i:n,"_")}function XC(e,t,n={}){let i=e.split(t),r=[],o=(s,c)=>OC(s)?"YYYYMMDD":/^([01]\d|2[0-3])[0-5]\d$/.test(s)&&c?.tok==="YYYYMMDD"?"HHMM":/^PATCH\d{1,3}$/i.test(s)?"PATCH":/^v\d{1,3}$/i.test(s)?"VERSION":n.FORMAT&&s===n.FORMAT||/^\d{3,5}x\d{3,5}[pi]\d{2,5}$/.test(s)?"FORMAT":n.CODEC&&(s===n.CODEC||n.CODEC==="H264"&&/^(H\.?264|AVC)/i.test(s))||/^(PR(4444(XQ)?|HQ|422|LT|PROXY)|H\.?26[45]|HEVC|DNX\w+|XAVC\w*|J2K|JPEG2000)$/i.test(s)?"CODEC":kC.test(s)||n.COLORSPACE&&s===n.COLORSPACE?"COLORSPACE":TC.test(s)||n.GAMMA&&s===n.GAMMA?"GAMMA":zC.test(s)?"TEXT":MC.test(s)?"AUDIOCONFIG":null;for(let s=0;s<i.length;s++){let c=i[s],l=o(c,r[r.length-1]);if(l==="CODEC"&&/^\d+mbps$/i.test(i[s+1]??"")){r.push({tok:l,raw:c+t+i[++s]});continue}if(l==="AUDIOCONFIG"){let u=c;for(;s+1<i.length&&!["YYYYMMDD","FORMAT","CODEC","COLORSPACE","GAMMA","TEXT","VERSION","PATCH"].includes(o(i[s+1])??"")&&!/^\d+$/.test(i[s+1]);)u+=t+i[++s];r.push({tok:l,raw:u});continue}r.push({tok:l??"?",raw:c})}let a=0;for(;a<r.length&&r[a].tok==="?";)a++;return a&&r.splice(0,a,{tok:"TITLE",raw:r.slice(0,a).map(s=>s.raw).join(t)}),r}function NC(e,t){let n=[],i=0;for(let r of e){for(;i<t.length&&t[i]!==r.tok;)i++;if(i===t.length)return null;n.push(i++)}return n}function RC(e,t){let n=Array.from({length:e.length+1},()=>new Array(t.length+1).fill(0));for(let a=e.length-1;a>=0;a--)for(let s=t.length-1;s>=0;s--)n[a][s]=e[a]===t[s]?n[a+1][s+1]+1:Math.max(n[a+1][s],n[a][s+1]);let i=[],r=0,o=0;for(;r<e.length&&o<t.length;)e[r]===t[o]?(i.push(e[r]),r++,o++):n[r+1][o]>=n[r][o+1]?i.push(e[r++]):i.push(t[o++]);return[n[0][0],[...i,...e.slice(r),...t.slice(o)]]}function FC(e,t){if(!e.length)throw new ze("invalid_args","no names to learn from");let n=new Map;for(let f of e)n.set(f.toks.map(d=>d.tok).join(" "),(n.get(f.toks.map(d=>d.tok).join(" "))??0)+1);let i=[];for(let[f]of[...n].sort((d,m)=>m[1]-d[1])){let d=f.split(" ");if(!i.length){i=d;continue}let[m,p]=RC(i,d);m*2>=d.length&&(i=p)}let r=i.map(()=>[]),o=[];for(let f of e){let d=NC(f.toks,i);if(!d){o.push(f.file);continue}d.forEach((m,p)=>r[m].push(f.toks[p].raw))}let a=e.length-o.length,s={},c={},l=0;return{template:i.map((f,d)=>{let m=[...new Set(r[d])],p=r[d].length<a?"?":"";if(f==="?"){if(m.length===1&&!p)return m[0];let b=`FIELD${++l}`;return c[b]=m,`[${b}${p}]`}return f==="PATCH"?"PATCH[NN]":(f==="TEXT"&&(c.TEXT=m),f==="TITLE"&&(t!=="_"||m.some(b=>b.includes(t)))&&(s.TITLE=".+?"),`[${f}${p}]`)}).join(t),patterns:s,values:c,fitted:a,misfits:o}}async function*T5(e,t=3){for await(let n of zn(e)){if(n.name.startsWith("."))continue;let i=_(e,n.name);n.isDirectory&&t>0?yield*T5(i,t-1):n.isFile&&SC.test(n.name)&&(yield i)}}async function z5(e,t={}){let n=e.replace(/\/+$/,""),i=[];if(await Wi(n))for await(let S of T5(n))i.push(S);else i.push(n);if(!i.length)throw new ze("not_found",`no media files under ${ae(n)}`);i.length>200&&(i.length=200);let r=await Promise.all(i.map(async S=>{let M=await Rn(S).catch(()=>null);return{file:S,m:M,e:M?ky(M):{}}})),o=S=>ae(S,Pr(S)),a=LC(o(i[0])),s=r.map(S=>({...S,toks:XC(o(S.file),a,S.e)})),c=S=>S.toks.some(M=>M.tok==="PATCH"),l={templates:{},patterns:{},values:{}},u=[];for(let[S,M]of[["deliverable",s.filter(L=>!c(L))],["patch",s.filter(c)]]){if(!M.length)continue;let L=FC(M.map(P=>({file:ae(P.file),toks:P.toks})),a);l.templates[S]=L.template,Object.assign(l.patterns,L.patterns);for(let[P,X]of Object.entries(L.values))l.values[P]=[...new Set([...l.values[P]??[],...X])];u.push(...L.misfits)}let f={facility:"",...l},d=s.filter(S=>!c(S)).map(S=>({x:S,v:Tf(f,"deliverable",S.file)?.values})).filter(S=>S.v),m=S=>(S.m?.size_bytes??0)/Math.max(1,S.m?.available_range?S.m.available_range.duration.value/(S.m.available_range.duration.rate||1):1),p=S=>/^(\d+x\d+)/.exec(S.FORMAT??"")?.[1]??"",b=[...d].sort((S,M)=>m(M.x)-m(S.x))[0],h=b?p(b.v):"",v=new Map;for(let{x:S,v:M}of d){let L=p(M),P=Pr(S.file).slice(1).toLowerCase(),X=[M.CODEC,M.AUDIOCONFIG,P,L===h?"OAR":L].join("|"),R=v.get(X)??{label:`${M.CODEC??P} ${L===h?"at the OAR":L}`,CODEC:M.CODEC??"",AUDIOCONFIG:M.AUDIOCONFIG??"",ext:P,raster:L===h||!L?"OAR":L,texts:[]};M.TEXT&&!R.texts.includes(M.TEXT)&&R.texts.push(M.TEXT),v.set(X,R)}if(v.size&&(l.deliverables=[...v.values()]),await Wi(n)){let S={};for(let{x:L,v:P}of d){let X=q6(n,Yn(L.file)),R=P.CODEC?.split(a)[0]??"",I=R.replace(/\d+$/,"");X&&R&&(S[I.length>=2?I:R]=X.split("/")[0])}Object.keys(S).length&&(l.codec_folders=S);let M=ae(n).replace(/(19|20)\d{6}/,"[YYYYMMDD]").replace(/(\[YYYYMMDD\]\D?)([01]\d|2[0-3])[0-5]\d/,"$1[HHMM]");M!==ae(n)&&(l.templates.deliverables_folder=`${ae(Yn(n))}/${M}${Object.keys(S).length?"/[CODECFOLDER]":""}`)}let g=t.today??new Date().toISOString().slice(0,10),y=`learned from ${i.length} file(s) in ${ae(n)} (${g})`;l.provenance=Object.fromEntries([...Object.keys(l.templates).map(S=>[`templates.${S}`,y]),...l.deliverables?[["deliverables",y]]:[],...l.codec_folders?[["codec_folders",y]]:[]]);let w=await Di(),x=VC(w,l,t.project,t.facility),T=t.project?xy(x,t.project):x,z=r.flatMap(S=>{let L=rl(T,ae(S.file),{probe:S.m??void 0}).issues.filter(P=>P.level==="error").map(P=>`${P.element}: ${P.message}`);return L.length?[{file:ae(S.file),issues:L}]:[]}),k={profile:x,learned:l,files:i.length,misfits:u,name_issues:z,source:y};return t.save!==!1&&(k.saved=await il(x)),k}function VC(e,t,n,i){let r=a=>({...a,templates:{...a.templates,...t.templates},patterns:{...a.patterns,...t.patterns},values:{...a.values,...t.values},codec_folders:{...a.codec_folders,...t.codec_folders},deliverables:t.deliverables??a.deliverables}),o={...e.provenance,...Object.fromEntries(Object.entries(t.provenance??{}).map(([a,s])=>[n?`projects.${n}.${a}`:a,s]))};return n?{...e,facility:i??e.facility,provenance:o,projects:{...e.projects,[n]:r(e.projects?.[n]??{})}}:{...r(e),facility:i??e.facility,provenance:o}}function M5(e,t){let n=t.at??new Date().toISOString().slice(0,10);return{...e,rules:[...(e.rules??[]).filter(i=>i.rule!==t.rule),{...t,at:n}]}}function O5(e,t){let n=e.rules??[],i=typeof t=="number"?t-1:n.findIndex(r=>r.rule.toLowerCase().includes(t.toLowerCase()));if(i<0||i>=n.length)throw new ze("not_found",`no rule matching ${t}`);return{...e,rules:n.filter((r,o)=>o!==i)}}function L5(e,t,n){let i=new Date().toISOString().slice(0,10);return{...e,conventions:{...e.conventions,...t},provenance:{...e.provenance,...Object.fromEntries(Object.keys(t).map(r=>[`conventions.${r}`,`${n} (${i})`]))}}}var zy=e=>!Object.keys(e.templates).length&&!e.rules?.length&&!Object.keys(e.conventions??{}).length;function zf(e){if(zy(e))return"No artist profile yet. Learn it: artist_profile action=learn path=<a folder of their delivered files>; ask what the files cannot show (usual deliverable set, program start TC, how they route audio).";let t=i=>e.provenance?.[i]??e.provenance?.["*"],n=[`Artist profile${e.facility?`: ${e.facility}`:""}`];for(let[i,r]of Object.entries(e.templates))n.push(` ${i}: ${r}${t(`templates.${i}`)?` [${t(`templates.${i}`)}]`:""}`);if(e.deliverables?.length){n.push(` usual deliverables${t("deliverables")?` [${t("deliverables")}]`:""}:`);for(let i of e.deliverables)n.push(` ${i.label}: ${i.CODEC} ${i.AUDIOCONFIG} .${i.ext} ${i.raster}${i.texts.length?` (${i.texts.join(", ")})`:""}${i.optional?" \u2014 on request":""}`)}for(let[i,r]of Object.entries(e.conventions??{}))n.push(` ${i}: ${r}${t(`conventions.${i}`)?` [${t(`conventions.${i}`)}]`:""}`);return(e.rules??[]).forEach((i,r)=>n.push(` rule ${r+1}${i.topic?` (${i.topic})`:""}: ${i.rule} [${i.source}, ${i.at}]`)),e.projects&&n.push(` projects: ${Object.keys(e.projects).join(", ")}`),n.join(`
16
+ `)}async function Rue(){await IC();let e=await Di().catch(()=>null);return!e||zy(e)?"Artist profile: none yet. Conventions that are the artist's choice (naming, usual deliverables, start TC, bins, routing) are not assumed: learn them (artist_profile action=learn) or ask, and save the answer (artist_profile action=remember).":`Artist profile: ${e.facility||"this artist"} (${Object.keys(e.templates).length} naming templates, ${e.deliverables?.length??0} deliverable kinds, ${e.rules?.length??0} workflow rules). Read it (artist_profile) before naming, rendering or delivering, and follow it. When the artist corrects you, ask whether it is their preference (artist_profile action=remember) or a rule for everyone (report_issue).`}var jC=()=>`${yr().supabaseUrl}/functions/v1/v1-me/v1/engine/artist-profile`;async function Ty(e,t){let n=await Ko().catch(()=>null);if(!n)return null;let i=await fetch(jC(),{method:e,signal:AbortSignal.timeout(5e3),headers:{authorization:`Bearer ${n}`,apikey:yr().anonKey,...t?{"content-type":"application/json"}:{}},...t?{body:JSON.stringify(t)}:{}});return i.ok?await i.json():null}async function il(e){let t=await Py(e);return await Ty("PATCH",{profile:await Di()}).catch(()=>null),t}function ZC(e,t){let n=e.updated_at??"",i=t?.updated_at??"";return t&&i>n?"pull":!zy(e)&&n>i?"push":"same"}async function IC(){try{let e=await Ty("GET");if(!e)return"offline";let t=await Di(),n=e.profile??null,i=ZC(t,n);return i==="pull"&&await Py(n,{stamp:!1}),i==="push"&&await Ty("PATCH",{profile:t}),i==="pull"?"pulled":i==="push"?"pushed":"same"}catch{return"offline"}}var so="0.6.2";function WC(e,t){let n=e.split("-")[0].split(".").map(Number),i=t.split("-")[0].split(".").map(Number);for(let r=0;r<Math.max(n.length,i.length);r++){let o=(n[r]||0)-(i[r]||0);if(o)return o>0}return!1}var DC=null;function My(){return Ut("CONFORM_UPDATE_CHECK")==="off"?Promise.resolve(null):DC??=fetch("https://registry.npmjs.org/conformtools/latest",{signal:AbortSignal.timeout(2e3)}).then(e=>e.ok?e.json():null).then(e=>typeof e?.version=="string"?e.version:null).catch(()=>null)}var qC="run npx -y conformtools@latest mcp (in the MCP client config too); if an old global install is shadowing it: npm rm -g conformtools";async function X5(){let e=await My();return`conformtools ${so}`+(e&&WC(e,so)?` \u2014 update available: ${e} \u2192 ${qC}`:"")}var O={};Bo(O,{$brand:()=>Hy,$input:()=>dx,$output:()=>fx,INVALID:()=>vi,NEVER:()=>qy,TimePrecision:()=>Sx,ZodAny:()=>u2,ZodArray:()=>p2,ZodBase64:()=>qb,ZodBase64URL:()=>Hb,ZodBigInt:()=>Hl,ZodBigIntFormat:()=>Ub,ZodBoolean:()=>ql,ZodCIDRv4:()=>Wb,ZodCIDRv6:()=>Db,ZodCUID:()=>Nb,ZodCUID2:()=>Rb,ZodCatch:()=>j2,ZodCodec:()=>wd,ZodCompileAsyncError:()=>lo,ZodCompileUnsupportedError:()=>an,ZodCreditCard:()=>n2,ZodCustom:()=>xd,ZodCustomStringFormat:()=>ic,ZodDate:()=>pd,ZodDefault:()=>L2,ZodDiscriminatedUnion:()=>b2,ZodE164:()=>Eb,ZodEmail:()=>Mb,ZodEmoji:()=>Lb,ZodEnum:()=>Il,ZodError:()=>nB,ZodExactOptional:()=>Bb,ZodFile:()=>T2,ZodFirstPartyTypeKind:()=>Y2,ZodFunction:()=>A2,ZodGUID:()=>Ob,ZodIBAN:()=>r2,ZodIPv4:()=>Zb,ZodIPv6:()=>Ib,ZodISODate:()=>_a,ZodISODateTime:()=>Qa,ZodISODuration:()=>es,ZodISOTime:()=>$a,ZodInstanceOf:()=>B2,ZodIntersection:()=>g2,ZodIssueCode:()=>oB,ZodJWT:()=>Cb,ZodKSUID:()=>jb,ZodLazy:()=>E2,ZodLiteral:()=>k2,ZodMAC:()=>t2,ZodMap:()=>P2,ZodNaN:()=>I2,ZodNanoID:()=>Xb,ZodNever:()=>d2,ZodNonOptional:()=>Yb,ZodNull:()=>c2,ZodNullable:()=>O2,ZodNumber:()=>Dl,ZodNumberFormat:()=>oc,ZodObject:()=>bd,ZodOptional:()=>vd,ZodPipe:()=>yd,ZodPrefault:()=>N2,ZodPreprocess:()=>W2,ZodPromise:()=>U2,ZodReadonly:()=>D2,ZodRealError:()=>Fi,ZodRecord:()=>Zl,ZodSet:()=>S2,ZodString:()=>Wl,ZodStringFormat:()=>qn,ZodSuccess:()=>V2,ZodSymbol:()=>a2,ZodTemplateLiteral:()=>H2,ZodTransform:()=>z2,ZodTuple:()=>y2,ZodType:()=>Gt,ZodULID:()=>Fb,ZodURL:()=>md,ZodUUID:()=>Xo,ZodUndefined:()=>s2,ZodUnion:()=>gd,ZodUnknown:()=>f2,ZodVoid:()=>m2,ZodXID:()=>Vb,ZodXor:()=>h2,_ZodString:()=>zb,_default:()=>X2,_function:()=>uO,any:()=>HM,array:()=>hd,base64:()=>xM,base64url:()=>PM,bigint:()=>ZM,boolean:()=>o2,catch:()=>Z2,check:()=>fO,cidrv4:()=>yM,cidrv6:()=>wM,clone:()=>Zn,codec:()=>aO,coerce:()=>Q2,compile:()=>bx,config:()=>wr,core:()=>ca,creditCard:()=>kM,cuid:()=>fM,cuid2:()=>dM,currencyCode:()=>XM,custom:()=>dO,date:()=>CM,decode:()=>B3,decodeAsync:()=>K3,deepPartial:()=>TO,describe:()=>mO,discriminatedUnion:()=>YM,e164:()=>SM,email:()=>tM,emoji:()=>lM,encode:()=>J3,encodeAsync:()=>Y3,endsWith:()=>Tl,enum:()=>Gb,exactOptional:()=>M2,file:()=>nO,flattenError:()=>Zf,float32:()=>RM,float64:()=>FM,formatError:()=>If,fromJSONSchema:()=>SO,function:()=>uO,getDiscriminatedOption:()=>Dw,getErrorMap:()=>sB,globalRegistry:()=>Kr,gt:()=>Oo,gte:()=>Hi,guid:()=>nM,hash:()=>NM,hex:()=>LM,hostname:()=>OM,httpUrl:()=>cM,iban:()=>TM,includes:()=>Sl,input:()=>MO,instanceof:()=>hO,int:()=>kb,int32:()=>VM,int64:()=>IM,intersection:()=>v2,invertCodec:()=>sO,ipv4:()=>bM,ipv6:()=>vM,iso:()=>Pd,json:()=>gO,jwt:()=>zM,keyof:()=>UM,ksuid:()=>hM,lazy:()=>C2,length:()=>$s,literal:()=>tO,locales:()=>rd,looseObject:()=>JM,looseRecord:()=>QM,lowercase:()=>xl,lt:()=>Mo,lte:()=>qi,mac:()=>gM,map:()=>_M,maxLength:()=>_s,maxSize:()=>Ja,memoizer:()=>td,meta:()=>pO,mime:()=>Ml,minLength:()=>sa,minSize:()=>Lo,multipleOf:()=>Ga,nan:()=>oO,nanoid:()=>uM,nativeEnum:()=>eO,negative:()=>mb,never:()=>Ab,nonnegative:()=>hb,nonoptional:()=>F2,nonpositive:()=>pb,normalize:()=>Ol,null:()=>l2,nullable:()=>dd,nullish:()=>rO,number:()=>i2,object:()=>AM,optional:()=>nc,output:()=>OO,overwrite:()=>uo,parse:()=>C3,parseAsync:()=>U3,partialRecord:()=>KM,pipe:()=>Tb,positive:()=>db,prefault:()=>R2,preprocess:()=>vO,prettifyError:()=>Gy,promise:()=>lO,properties:()=>zl,property:()=>bb,readonly:()=>q2,record:()=>x2,refine:()=>G2,regex:()=>wl,regexes:()=>Qi,registry:()=>Hh,safeDecode:()=>_3,safeDecodeAsync:()=>e2,safeEncode:()=>Q3,safeEncodeAsync:()=>$3,safeParse:()=>A3,safeParseAsync:()=>G3,set:()=>$M,setErrorMap:()=>aB,size:()=>Qs,slugify:()=>Rl,startsWith:()=>kl,strictObject:()=>GM,string:()=>fd,stringFormat:()=>MM,stringbool:()=>bO,success:()=>iO,superRefine:()=>J2,symbol:()=>DM,templateLiteral:()=>cO,toJSONSchema:()=>wb,toLowerCase:()=>Xl,toUpperCase:()=>Nl,toZod:()=>Mf,transform:()=>Jb,treeifyError:()=>Ay,trim:()=>Ll,tuple:()=>w2,uint32:()=>jM,uint64:()=>WM,ulid:()=>mM,undefined:()=>qM,union:()=>El,unknown:()=>tc,uppercase:()=>Pl,url:()=>sM,util:()=>he,uuid:()=>rM,uuidv4:()=>iM,uuidv6:()=>oM,uuidv7:()=>aM,validate:()=>Wf,validateAsync:()=>Df,void:()=>EM,withParser:()=>Eh,xid:()=>pM,xor:()=>BM});var ca={};Bo(ca,{$ZodAny:()=>Nw,$ZodArray:()=>Zw,$ZodAsyncError:()=>Ni,$ZodBase64:()=>yw,$ZodBase64URL:()=>ww,$ZodBigInt:()=>Mh,$ZodBigIntFormat:()=>Mw,$ZodBoolean:()=>Yf,$ZodCIDRv4:()=>gw,$ZodCIDRv6:()=>vw,$ZodCUID:()=>ow,$ZodCUID2:()=>aw,$ZodCatch:()=>tx,$ZodCheck:()=>Jn,$ZodCheckBigIntFormat:()=>R1,$ZodCheckEndsWith:()=>U1,$ZodCheckGreaterThan:()=>fh,$ZodCheckIncludes:()=>E1,$ZodCheckLengthEquals:()=>W1,$ZodCheckLessThan:()=>uh,$ZodCheckLowerCase:()=>q1,$ZodCheckMaxLength:()=>Z1,$ZodCheckMaxSize:()=>F1,$ZodCheckMimeType:()=>J1,$ZodCheckMinLength:()=>I1,$ZodCheckMinSize:()=>V1,$ZodCheckMultipleOf:()=>X1,$ZodCheckNumberFormat:()=>N1,$ZodCheckOverwrite:()=>B1,$ZodCheckProperties:()=>G1,$ZodCheckProperty:()=>A1,$ZodCheckRegex:()=>D1,$ZodCheckSizeEquals:()=>j1,$ZodCheckStartsWith:()=>C1,$ZodCheckStringFormat:()=>hl,$ZodCheckUpperCase:()=>H1,$ZodCodec:()=>Qf,$ZodCreditCard:()=>Pw,$ZodCustom:()=>cx,$ZodCustomStringFormat:()=>Tw,$ZodCyclicError:()=>Vh,$ZodDate:()=>jw,$ZodDefault:()=>Qw,$ZodDiscriminatedUnion:()=>qw,$ZodE164:()=>xw,$ZodEmail:()=>$1,$ZodEmoji:()=>rw,$ZodEncodeError:()=>Aa,$ZodEnum:()=>Aw,$ZodError:()=>Uy,$ZodExactOptional:()=>Yw,$ZodFile:()=>Jw,$ZodFunction:()=>ax,$ZodGUID:()=>Q1,$ZodIBAN:()=>Sw,$ZodIPv4:()=>pw,$ZodIPv6:()=>hw,$ZodISODate:()=>fw,$ZodISODateTime:()=>uw,$ZodISODuration:()=>mw,$ZodISOTime:()=>dw,$ZodIntersection:()=>Hw,$ZodJWT:()=>kw,$ZodKSUID:()=>lw,$ZodLazy:()=>_f,$ZodLiteral:()=>Gw,$ZodMAC:()=>bw,$ZodMap:()=>Cw,$ZodNaN:()=>nx,$ZodNanoID:()=>iw,$ZodNever:()=>Fw,$ZodNonOptional:()=>$w,$ZodNull:()=>Xw,$ZodNullable:()=>Kw,$ZodNumber:()=>zh,$ZodNumberFormat:()=>zw,$ZodObject:()=>fT,$ZodObjectJIT:()=>Iw,$ZodOptional:()=>Lh,$ZodPipe:()=>Xh,$ZodPrefault:()=>_w,$ZodPreprocess:()=>rx,$ZodPromise:()=>sx,$ZodReadonly:()=>ix,$ZodRealError:()=>Ri,$ZodRecord:()=>Ew,$ZodRegistry:()=>qh,$ZodSet:()=>Uw,$ZodString:()=>Gs,$ZodStringFormat:()=>In,$ZodSuccess:()=>ex,$ZodSymbol:()=>Ow,$ZodTemplateLiteral:()=>ox,$ZodTransform:()=>Bw,$ZodTuple:()=>Oh,$ZodType:()=>It,$ZodULID:()=>sw,$ZodURL:()=>nw,$ZodUUID:()=>_1,$ZodUndefined:()=>Lw,$ZodUnion:()=>Kf,$ZodUnknown:()=>Rw,$ZodVoid:()=>Vw,$ZodXID:()=>cw,$ZodXor:()=>Ww,$brand:()=>Hy,$constructor:()=>A,$input:()=>dx,$output:()=>fx,Doc:()=>As,INVALID:()=>vi,JSONSchema:()=>_z,JSONSchemaGenerator:()=>xb,NEVER:()=>qy,TimePrecision:()=>Sx,URL_BAD_FORMAT:()=>ew,URL_UNPARSEABLE:()=>Uf,ZodCompileAsyncError:()=>lo,ZodCompileUnsupportedError:()=>an,_any:()=>qx,_array:()=>Jx,_base64:()=>cb,_base64url:()=>lb,_bigint:()=>Fx,_boolean:()=>Nx,_catch:()=>UJ,_check:()=>Zz,_cidrv4:()=>ab,_cidrv6:()=>sb,_coercedBigint:()=>Vx,_coercedBoolean:()=>Rx,_coercedDate:()=>Ax,_coercedNumber:()=>Tx,_coercedString:()=>yx,_creditCard:()=>xx,_cuid:()=>$h,_cuid2:()=>eb,_custom:()=>Yx,_date:()=>Ux,_decode:()=>$p,_decodeAsync:()=>th,_default:()=>HJ,_discriminatedUnion:()=>LJ,_e164:()=>ub,_email:()=>Ah,_emoji:()=>Qh,_encode:()=>_p,_encodeAsync:()=>eh,_endsWith:()=>Tl,_enum:()=>jJ,_file:()=>Bx,_float32:()=>Mx,_float64:()=>Ox,_gt:()=>Oo,_gte:()=>Hi,_guid:()=>Gh,_iban:()=>Px,_includes:()=>Sl,_int:()=>zx,_int32:()=>Lx,_int64:()=>jx,_intersection:()=>XJ,_ipv4:()=>ib,_ipv6:()=>ob,_isoDate:()=>ad,_isoDateTime:()=>od,_isoDuration:()=>cd,_isoTime:()=>sd,_jwt:()=>fb,_ksuid:()=>rb,_lazy:()=>BJ,_length:()=>$s,_literal:()=>IJ,_lowercase:()=>xl,_lt:()=>Mo,_lte:()=>qi,_mac:()=>wx,_map:()=>FJ,_max:()=>qi,_maxLength:()=>_s,_maxSize:()=>Ja,_mime:()=>Ml,_min:()=>Hi,_minLength:()=>sa,_minSize:()=>Lo,_multipleOf:()=>Ga,_nan:()=>Gx,_nanoid:()=>_h,_nativeEnum:()=>ZJ,_negative:()=>mb,_never:()=>Ex,_nonnegative:()=>hb,_nonoptional:()=>EJ,_nonpositive:()=>pb,_normalize:()=>Ol,_null:()=>Dx,_nullable:()=>qJ,_number:()=>kx,_optional:()=>DJ,_overwrite:()=>uo,_parse:()=>fl,_parseAsync:()=>dl,_pipe:()=>AJ,_positive:()=>db,_promise:()=>YJ,_properties:()=>zl,_property:()=>bb,_readonly:()=>GJ,_record:()=>RJ,_refine:()=>Kx,_regex:()=>wl,_safeDecode:()=>rh,_safeDecodeAsync:()=>oh,_safeEncode:()=>nh,_safeEncodeAsync:()=>ih,_safeParse:()=>ml,_safeParseAsync:()=>pl,_set:()=>VJ,_size:()=>Qs,_slugify:()=>Rl,_startsWith:()=>kl,_string:()=>vx,_stringFormat:()=>ec,_stringbool:()=>e3,_success:()=>CJ,_superRefine:()=>Qx,_symbol:()=>Ix,_templateLiteral:()=>JJ,_toLowerCase:()=>Xl,_toUpperCase:()=>Nl,_transform:()=>WJ,_trim:()=>Ll,_tuple:()=>NJ,_uint32:()=>Xx,_uint64:()=>Zx,_ulid:()=>tb,_undefined:()=>Wx,_union:()=>MJ,_unknown:()=>Hx,_uppercase:()=>Pl,_url:()=>id,_uuid:()=>Jh,_uuidv4:()=>Bh,_uuidv6:()=>Yh,_uuidv7:()=>Kh,_void:()=>Cx,_xid:()=>nb,_xor:()=>OJ,base64Charset:()=>xh,base64urlCharset:()=>Bf,canParseURL:()=>tw,clone:()=>Zn,compile:()=>bx,compileFn:()=>Ch,config:()=>wr,createStandardJSONSchemaMethod:()=>Fl,createToJSONSchemaMethod:()=>n3,decode:()=>NU,decodeAsync:()=>FU,describe:()=>_x,encode:()=>XU,encodeAsync:()=>RU,extractDefs:()=>Ya,finalize:()=>Ka,flattenError:()=>Zf,formatError:()=>If,getDiscriminatedOption:()=>Dw,globalConfig:()=>Cr,globalRegistry:()=>Kr,handleUnrepresentable:()=>jr,initializeContext:()=>Ba,isBackEdge:()=>Zh,isRecursiveSchema:()=>jh,isValidBase64:()=>Jf,isValidBase64URL:()=>Ph,isValidCIDRv6:()=>wh,isValidCreditCard:()=>Sh,isValidIBAN:()=>kh,isValidIPv6:()=>Gf,isValidJWT:()=>Th,locales:()=>rd,memoizer:()=>td,mergeValues:()=>bl,meta:()=>$x,parse:()=>Kp,parseAsync:()=>Qp,parseURLObject:()=>cT,prettifyError:()=>Gy,process:()=>Wn,processSchema:()=>Wn,regexes:()=>Qi,registry:()=>Hh,safeDecode:()=>jU,safeDecodeAsync:()=>IU,safeEncode:()=>VU,safeEncodeAsync:()=>ZU,safeParse:()=>TU,safeParseAsync:()=>zU,standardProps:()=>bh,stripTabAndNewline:()=>Af,toDotPath:()=>H5,toJSONSchema:()=>wb,toZod:()=>Mf,treeifyError:()=>Ay,urlHostnameOk:()=>vh,urlProtocolOk:()=>yh,util:()=>he,validate:()=>Wf,validateAsync:()=>Df,validateURL:()=>gh,version:()=>Y1,withParser:()=>Eh});var he={};Bo(he,{BIGINT_FORMAT_RANGES:()=>Rf,CONSTANT_CATCH:()=>Bp,Class:()=>Xy,NUMBER_FORMAT_RANGES:()=>Nf,aborted:()=>gi,allowsEval:()=>Fy,assert:()=>AC,assertEqual:()=>HC,assertIs:()=>CC,assertNever:()=>UC,assertNotEqual:()=>EC,assignProp:()=>Yr,attachSchema:()=>Jp,base64ToUint8Array:()=>j5,base64urlToUint8Array:()=>uU,cached:()=>cl,captureStackTrace:()=>Ap,cleanEnum:()=>lU,cleanRegex:()=>oa,clone:()=>Zn,cloneDef:()=>BC,codePointLength:()=>Cs,constantCatch:()=>Wy,createTransparentProxy:()=>eU,defineLazy:()=>Ny,defineLazyInternal:()=>Kt,derived:()=>pU,esc:()=>bi,escapeRegex:()=>Ki,explicitlyAborted:()=>Zy,extend:()=>rU,finalizeIssue:()=>Xi,floatSafeRemainder:()=>Of,getElementAtPath:()=>YC,getEnumValues:()=>al,getLengthableOrigin:()=>Vf,getParsedType:()=>$C,getSizableOrigin:()=>Ff,hexToUint8Array:()=>dU,hide:()=>jf,installLazyProp:()=>vU,isObject:()=>Es,isPlainObject:()=>Yi,issue:()=>ul,joinValues:()=>G,jsonStringifyReplacer:()=>sl,members:()=>Iy,merge:()=>oU,mergeDefs:()=>co,normalizeParams:()=>Ve,nullish:()=>Up,numKeys:()=>_C,objectClone:()=>GC,omit:()=>nU,optionalKeys:()=>jy,own:()=>Ua,parsedType:()=>ye,partial:()=>aU,pick:()=>tU,prefixIssues:()=>Li,primitiveTypes:()=>Vy,promiseAllObject:()=>KC,propertyKeyTypes:()=>Xf,randomString:()=>QC,rawShape:()=>ll,required:()=>sU,safeExtend:()=>iU,shallowClone:()=>Lf,slugify:()=>Ry,stringifyPrimitive:()=>ge,toZod:()=>Mf,uint8ArrayToBase64:()=>Z5,uint8ArrayToBase64url:()=>fU,uint8ArrayToHex:()=>mU,unwrapMessage:()=>ol});function HC(e){return e}function EC(e){return e}function Mf(){return e=>e}function CC(e){}function UC(e){throw new Error("Unexpected value in exhaustive check")}function AC(e){}function al(e){let t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,r])=>t.indexOf(+i)===-1).map(([i,r])=>r)}function G(e,t="|"){return e.map(n=>ge(n)).join(t)}function sl(e,t){return typeof t=="bigint"?t.toString():t}var Ly=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function cl(e){return new Ly(e)}function Up(e){return e==null}function oa(e){let t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Of(e,t){let n=e/t,i=Math.round(n),r=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-i)<r?0:n-i}var N5=Symbol("evaluating");function Ny(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==N5)return i===void 0&&(i=N5,i=n()),i},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function GC(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Yr(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ll(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ia(e){return ll(e._zod.def)??e._zod.def.shape}function R5(e,t,n){Object.defineProperty(e,t,{get(){let i=n();return Yr(this,t,i),i},enumerable:!0,configurable:!0})}function F5(e,t,n){t in e?Yr(e,t,n):e[t]=n}function Hs(e,t,n,i){let r=ia(t);for(let o of n){let a=Object.getOwnPropertyDescriptor(r,o);a.enumerable&&(a.get?R5(e,o,()=>{let s=t._zod.def.shape[o];return i?i(s,o):s}):F5(e,o,i?i(a.value,o):a.value))}}function JC(e,t){for(let n of Reflect.ownKeys(t)){let i=Object.getOwnPropertyDescriptor(t,n);i.enumerable&&(i.get?R5(e,n,()=>t[n]):F5(e,n,i.value))}}function co(...e){let t={};for(let n of e){let i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function BC(e){return co(e._zod.def)}function YC(e,t){return t?t.reduce((n,i)=>n?.[i],e):e}function KC(e){let t=Object.keys(e),n=t.map(i=>e[i]);return Promise.all(n).then(i=>{let r={};for(let o=0;o<t.length;o++)r[t[o]]=i[o];return r})}function QC(e=10){let t="abcdefghijklmnopqrstuvwxyz",n="";for(let i=0;i<e;i++)n+=t[Math.floor(Math.random()*t.length)];return n}function bi(e){return JSON.stringify(e)}function Ry(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Ap="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Es(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Fy=cl(()=>{if(Cr.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Yi(e){if(Es(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let n=t.prototype;return!(Es(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Lf(e){return Yi(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function _C(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}var $C=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Xf=new Set(["string","number","symbol"]),Vy=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Ki(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zn(e,t,n){let i=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(i._zod.parent=e),i}function Ve(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function eU(e){let t;return new Proxy({},{get(n,i,r){return t??(t=e()),Reflect.get(t,i,r)},set(n,i,r,o){return t??(t=e()),Reflect.set(t,i,r,o)},has(n,i){return t??(t=e()),Reflect.has(t,i)},deleteProperty(n,i){return t??(t=e()),Reflect.deleteProperty(t,i)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,i){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,i)},defineProperty(n,i,r){return t??(t=e()),Reflect.defineProperty(t,i,r)}})}function ge(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function jy(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Nf={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Rf={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function tU(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let o={};return Hs(o,e,Gp(e,t)),Zn(e,co(n,{shape:o,checks:[]}))}function Gp(e,t){let n=ia(e),i=[];for(let r of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,r)?.enumerable)throw new Error(`Unrecognized key: "${String(r)}"`);t[r]&&i.push(r)}return i}function nU(e,t){let n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let o=new Set(Gp(e,t)),a={};return Hs(a,e,Reflect.ownKeys(ia(e)).filter(s=>!o.has(s))),Zn(e,co(n,{shape:a,checks:[]}))}function rU(e,t){if(!Yi(t))throw new Error("Invalid input to extend: expected a plain object");let n=e._zod.def.checks;if(n&&n.length>0){let r=ia(e);for(let o of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(r,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Zn(e,co(e._zod.def,{shape:V5(e,t)}))}function V5(e,t){let n={};return Hs(n,e,Reflect.ownKeys(ia(e))),JC(n,t),n}function iU(e,t){if(!Yi(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Zn(e,co(e._zod.def,{shape:V5(e,t)}))}function oU(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let n={};Hs(n,e,Reflect.ownKeys(ia(e))),Hs(n,t,Reflect.ownKeys(ia(t)));let i=co(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Zn(e,i)}function aU(e,t,n,i="partial"){let o=t._zod.def.checks;if(o&&o.length>0)throw new Error(`.${i}() cannot be used on object schemas containing refinements`);let s=n?new Set(Gp(t,n)):void 0,c={};return Hs(c,t,Reflect.ownKeys(ia(t)),e&&((l,u)=>s&&!s.has(u)?l:new e({type:"optional",innerType:l}))),Zn(t,co(t._zod.def,{shape:c,checks:[]}))}function sU(e,t,n){let i=n?new Set(Gp(t,n)):void 0,r={};return Hs(r,t,Reflect.ownKeys(ia(t)),(o,a)=>i&&!i.has(a)?o:new e({type:"nonoptional",innerType:o})),Zn(t,co(t._zod.def,{shape:r}))}function gi(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Zy(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Li(e,t){return t.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function ol(e){return typeof e=="string"?e:e?.message}function Jp(e,t,n){var i;for(let r=t;r<e.length;r++)(i=e[r]).schema??(i.schema=n)}function Xi(e,t,n){var i;let r=e.inst?._zod?.traits;r?.has("$ZodType")&&(r.has("$ZodCheck")?(i=e).schema??(i.schema=e.inst):e.schema=e.inst);let o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,a=e.message?e.message:ol(e.inst?._zod.def?.error?.(e))??ol(o?.(e))??ol(t?.error?.(e))??ol(n.customError?.(e))??ol(n.localeError?.(e))??"Invalid input",s={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(s[c]=e[c]);return s.path??(s.path=[]),s.message=a,t?.reportInput&&(s.input=e.input),s}function Ff(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var cU=/[\uD800-\uDBFF]/;function Cs(e){let t=e.length;if(!cU.test(e))return t;let n=t;for(let i=0;i<t-1;i++)(e.charCodeAt(i)&64512)===55296&&(e.charCodeAt(i+1)&64512)===56320&&(n--,i++);return n}function Vf(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ye(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function ul(...e){let[t,n,i]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:i}:{...t}}function lU(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function j5(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}function Z5(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function uU(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return j5(t+n)}function fU(e){return Z5(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function dU(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(t.length/2);for(let i=0;i<t.length;i+=2)n[i/2]=Number.parseInt(t.slice(i,i+2),16);return n}function mU(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Xy=class{constructor(...t){}};function Iy(e,t){for(let n in t){let i=Object.getOwnPropertyDescriptor(t,n);i.get?Object.defineProperty(e,n,{...i,enumerable:!1}):hU(e,n,i.value)}}function Ua(e,t,n,i=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:i,value:n}),n}function jf(e,t,n){return Ua(e,t,n,!1)}function pU(e,t){for(let n in e){let i=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Ua(this,n,i(this))},set(r){Ua(this,n,r)}})}return t}function hU(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Ua(this,t,n.bind(this))},set(i){Ua(this,t,i)}})}function bU(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Oy,Ca=!1,gU={configurable:!0,get(){Ca=!0}};function Kt(e,t,n){let i=Object.getPrototypeOf(e._zod);if(t in i&&Oy!==e._zod){Oy=void 0;return}Oy=e._zod,Object.defineProperty(i,t,{configurable:!0,get(){Object.defineProperty(this,t,gU);let r=Ca;Ca=!1;try{let o=n(this);return Ca?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),Ca=Ca||r,o}catch(o){throw delete this[t],Ca=Ca||r,o}},set(r){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r})}})}function vU(e,t,n,i){let r=bU(e,t);r&&Object.defineProperty(r,t,{configurable:!0,get(){let o={configurable:!0,writable:!0,enumerable:i,value:void 0};return Object.defineProperty(this,t,o),o.value=n(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:i,value:o})}})}var Bp="~constantCatch";function Wy(e){let t=()=>e;return t[Bp]=!0,t}var I5,qy=Object.freeze({status:"aborted"}),Dy={value:void 0,enumerable:!1},W5="captureStackTrace"in Error?Error:null;function yU(e){let t=W5;if(t){let n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return W5=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function A(e,t,n,i){let r={};function o(d){this.def=d,this.constr=f,this.traits=new Set}o.prototype=r;let a=n,s=a&&new WeakSet;function c(d,m){if(d._zod){if(d._zod.traits.has(e))return}else{Dy.value=new o(m);try{Object.defineProperty(d,"_zod",Dy)}finally{Dy.value=void 0}}if(d._zod.traits.add(e),t(d,m),s){let b=Object.getPrototypeOf(d),h=d._zod.constr.prototype,v=b;for(;v&&v!==h;)v=Object.getPrototypeOf(v);let g=v??b;s.has(g)||(s.add(g),Iy(g,a))}let p=f.prototype;for(let b in p)Object.prototype.hasOwnProperty.call(p,b)&&(b in d||(d[b]=p[b].bind(d)))}let l=i?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function f(d){let m=i?.Parent?yU(u):this;c(m,d);let p=m._zod.deferred;if(p){for(let h of p)h();m._zod.deferred=void 0}let b=globalThis.__zod_globalConfig?.postProcessor;return b&&b(m),m}return Object.defineProperty(f,"init",{value:c}),Object.defineProperty(f,Symbol.hasInstance,{value:d=>i?.Parent&&d instanceof i.Parent?!0:d?._zod?.traits?.has(e)}),Object.defineProperty(f,"name",{value:e}),f}var Hy=Symbol("zod_brand"),Ni=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Aa=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(I5=globalThis).__zod_globalConfig??(I5.__zod_globalConfig={});var Cr=globalThis.__zod_globalConfig;function wr(e){return e&&Object.assign(Cr,e),Cr}function wU(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,sl,2)),e.message}function xU(e){this._zod.message=e}var PU={get:wU,set:xU,enumerable:!0,configurable:!0},Cy={value:void 0,enumerable:!1},D5=new WeakSet([Object.prototype,Error.prototype]),q5=(e,t)=>{e.name="$ZodError",Cy.value=t,Object.defineProperty(e,"issues",Cy),Cy.value=void 0,Object.defineProperty(e,"message",PU);let n=Object.getPrototypeOf(e);D5.has(n)||(D5.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let i=()=>this.message;return Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,"toString",{value:i,configurable:!0,writable:!0})}}))},Uy=A("$ZodError",q5),Ri=A("$ZodError",q5,void 0,{Parent:Error});function SU(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Zf(e,t=n=>n.message){let n={},i=[];for(let r of e.issues)r.path.length>0?SU(n,r.path[0],()=>[]).push(t(r)):i.push(t(r));return{formErrors:i,fieldErrors:n}}function If(e,t=n=>n.message){let n={_errors:[]},i=(r,o=[])=>{for(let a of r.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(s=>i({issues:s},[...o,...a.path]));else if(a.code==="invalid_key")i({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")i({issues:a.issues},[...o,...a.path]);else{let s=[...o,...a.path];if(s.length===0)n._errors.push(t(a));else{let c=n,l=0;for(;l<s.length;){let u=s[l],f=l===s.length-1;if(u==="_errors"){f&&c._errors.push(t(a)),l++;continue}Object.prototype.hasOwnProperty.call(c,u)||Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let d=c[u];f&&d._errors.push(t(a)),c=d,l++}}}};return i(e),n}function Ay(e,t=n=>n.message){let n={errors:[]},i=(r,o=[])=>{var a;for(let s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(c=>i({issues:c},[...o,...s.path]));else if(s.code==="invalid_key")i({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")i({issues:s.issues},[...o,...s.path]);else{let c=[...o,...s.path];if(c.length===0){n.errors.push(t(s));continue}let l=n,u=0;for(;u<c.length;){let f=c[u],d=u===c.length-1;typeof f=="string"?(l.properties??(l.properties={}),Object.prototype.hasOwnProperty.call(l.properties,f)||Object.defineProperty(l.properties,f,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),l=l.properties[f]):(l.items??(l.items=[]),(a=l.items)[f]??(a[f]={errors:[]}),l=l.items[f]),d&&l.errors.push(t(s)),u++}}};return i(e),n}function H5(e){let t=[],n=e.map(i=>typeof i=="object"?i.key:i);for(let i of n)typeof i=="number"?t.push(`[${i}]`):typeof i=="symbol"?t.push(`[${JSON.stringify(String(i))}]`):/[^\w$]/.test(i)?t.push(`[${JSON.stringify(i)}]`):(t.length&&t.push("."),t.push(i));return t.join("")}function Gy(e){let t=[],n=[...e.issues].sort((i,r)=>(i.path??[]).length-(r.path??[]).length);for(let i of n)t.push(`\u2716 ${i.message}`),i.path?.length&&t.push(` \u2192 at ${H5(i.path)}`);return t.join(`
17
+ `)}function Yp(e,t){return{callee:t?.callee??e,Err:t?.Err}}var fl=e=>{let t=(n,i,r,o)=>{let a=r?{...r,async:!1}:{async:!1},s=n._zod.run({value:i,issues:[]},a);if(s instanceof Promise)throw new Ni;if(s.issues.length){let c=new(o?.Err??e)(s.issues.map(l=>Xi(l,a,wr())));throw Ap(c,o?.callee??t),c}return s.value};return t},Kp=fl(Ri),dl=e=>{let t=async(n,i,r,o)=>{let a=r?{...r,async:!0}:{async:!0},s=n._zod.run({value:i,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){let c=new(o?.Err??e)(s.issues.map(l=>Xi(l,a,wr())));throw Ap(c,o?.callee??t),c}return s.value};return t},Qp=dl(Ri),ml=e=>(t,n,i)=>{let r=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},r);if(o instanceof Promise)throw new Ni;return o.issues.length?E5(e,o.issues,r):{success:!0,data:o.value}},TU=ml(Ri);function E5(e,t,n){let i;return{success:!1,get error(){return i||(i=new e(t.map(r=>Xi(r,n,wr()))),t=void 0,n=void 0),i},set error(r){i=r,t=void 0,n=void 0}}}var pl=e=>async(t,n,i)=>{let r=i?{...i,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length?E5(e,o.issues,r):{success:!0,data:o.value}},zU=pl(Ri),MU=Symbol.for("zod.compile.invalid"),OU=Symbol.for("zod.compile.fallback"),Wf=((e,t,n)=>{let i=e._zod.bag.validator;if(i!==void 0){if(i(t)!==MU)return!0;if(i.definite===!0&&n===void 0)return!1}return LU(e,t,n)});function LU(e,t,n){let i=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},r=e._zod.bag.fallbackRun,o;if(r?(i[OU]=!0,o=r({value:t,issues:[]},i)):o=e._zod.run({value:t,issues:[]},i),o instanceof Promise)throw new Ni;return o.issues.length===0}var Df=async(e,t,n)=>{let i=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},r=e._zod.run({value:t,issues:[]},i);return r instanceof Promise&&(r=await r),r.issues.length===0},_p=e=>{let t=fl(e),n=(i,r,o,a)=>{let s=o?{...o,direction:"backward"}:{direction:"backward"};return t(i,r,s,Yp(n,a))};return n},XU=_p(Ri),$p=e=>{let t=fl(e),n=(i,r,o,a)=>t(i,r,o,Yp(n,a));return n},NU=$p(Ri),eh=e=>{let t=dl(e),n=async(i,r,o,a)=>{let s=o?{...o,direction:"backward"}:{direction:"backward"};return await t(i,r,s,Yp(n,a))};return n},RU=eh(Ri),th=e=>{let t=dl(e),n=async(i,r,o,a)=>await t(i,r,o,Yp(n,a));return n},FU=th(Ri),nh=e=>(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return ml(e)(t,n,r)},VU=nh(Ri),rh=e=>(t,n,i)=>ml(e)(t,n,i),jU=rh(Ri),ih=e=>async(t,n,i)=>{let r=i?{...i,direction:"backward"}:{direction:"backward"};return pl(e)(t,n,r)},ZU=ih(Ri),oh=e=>async(t,n,i)=>pl(e)(t,n,i),IU=oh(Ri);var Qi={};Bo(Qi,{anyString:()=>y1,base64:()=>u1,base64url:()=>f1,bigint:()=>x1,boolean:()=>P1,browserEmail:()=>AU,cidrv4:()=>c1,cidrv6:()=>l1,creditCard:()=>ah,cuid:()=>By,cuid2:()=>Yy,currencyCode:()=>h1,date:()=>b1,datetime:()=>v1,domain:()=>m1,duration:()=>t1,e164:()=>p1,email:()=>r1,emoji:()=>i1,extendedDuration:()=>WU,guid:()=>n1,hex:()=>M1,hostname:()=>d1,html5Email:()=>EU,httpProtocol:()=>qf,iban:()=>sh,idnEmail:()=>UU,integer:()=>Hf,ipv4:()=>o1,ipv6:()=>a1,ksuid:()=>_y,lowercase:()=>T1,mac:()=>s1,md5_base64:()=>YU,md5_base64url:()=>KU,md5_hex:()=>BU,nanoid:()=>$y,nanoidOfLength:()=>e1,null:()=>S1,number:()=>aa,rfc5322Email:()=>CU,sha1_base64:()=>_U,sha1_base64url:()=>$U,sha1_hex:()=>QU,sha256_base64:()=>tA,sha256_base64url:()=>nA,sha256_hex:()=>eA,sha384_base64:()=>iA,sha384_base64url:()=>oA,sha384_hex:()=>rA,sha512_base64:()=>sA,sha512_base64url:()=>cA,sha512_hex:()=>aA,string:()=>w1,time:()=>g1,ulid:()=>Ky,undefined:()=>k1,unicodeEmail:()=>C5,uppercase:()=>z1,uuid:()=>Us,uuid4:()=>DU,uuid6:()=>qU,uuid7:()=>HU,xid:()=>Qy});var By=/^[cC][0-9a-z]{6,}$/,Yy=/^[0-9a-z]+$/,Ky=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Qy=/^[0-9a-vA-V]{20}$/,_y=/^[A-Za-z0-9]{27}$/,$y=/^[a-zA-Z0-9_-]{21}$/;function e1(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var t1=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,WU=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,n1=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Us=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,DU=Us(4),qU=Us(6),HU=Us(7),r1=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,EU=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,CU=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,C5=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,UU=C5,AU=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,GU="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function i1(){return new RegExp(GU,"u")}var o1=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,a1=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,s1=e=>{let t=Ki(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},c1=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,l1=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,u1=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,f1=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,d1=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,m1=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,qf=/^https?$/,p1=/^\+[1-9]\d{6,14}$/,ah=/^\d(?:[ -]?\d){11,18}$/,h1=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,sh=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,U5="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function JU(e){return new RegExp(`^${e}$`)}var b1=JU(U5);function Jy(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function g1(e){return new RegExp(`^${Jy(e)}$`)}function v1(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${Jy({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,i=e.local?`${n}|${Jy({precision:e.precision})}`:n;return new RegExp(`^${U5}T(?:${i})$`)}var y1=/^[\s\S]{0,}$/,w1=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},x1=/^-?\d+n?$/,Hf=/^-?\d+$/,aa=/^-?\d+(?:\.\d+)?$/,P1=/^(?:true|false)$/i,S1=/^null$/i;var k1=/^undefined$/i;var T1=/^[^A-Z]*$/,z1=/^[^a-z]*$/,M1=/^[0-9a-fA-F]*$/;function Ef(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Cf(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}var BU=/^[0-9a-fA-F]{32}$/,YU=Ef(22,"=="),KU=Cf(22),QU=/^[0-9a-fA-F]{40}$/,_U=Ef(27,"="),$U=Cf(27),eA=/^[0-9a-fA-F]{64}$/,tA=Ef(43,"="),nA=Cf(43),rA=/^[0-9a-fA-F]{96}$/,iA=Ef(64,""),oA=Cf(64),aA=/^[0-9a-fA-F]{128}$/,sA=Ef(86,"=="),cA=Cf(86);var Jn=A("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),O1=e=>{let t=e.value;return!Up(t)&&t.size!==void 0},L1=e=>{let t=e.value;return!Up(t)&&t.length!==void 0},ch={number:"number",bigint:"bigint",object:"date"},uh=A("$ZodCheckLessThan",(e,t)=>{Jn.init(e,t);let n=ch[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:ch[typeof i.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),fh=A("$ZodCheckGreaterThan",(e,t)=>{Jn.init(e,t);let n=ch[typeof t.value];e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:ch[typeof i.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),X1=A("$ZodCheckMultipleOf",(e,t)=>{Jn.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Of(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),N1=A("$ZodCheckNumberFormat",(e,t)=>{Jn.init(e,t),t.format=t.format||"float64";let n=t.format?.includes("int"),i=n?"int":"number",[r,o]=Nf[t.format];e._zod.check=a=>{let s=a.value;if(n){if(!Number.isInteger(s)){a.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}s<r&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),s>o&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),R1=A("$ZodCheckBigIntFormat",(e,t)=>{Jn.init(e,t);let[n,i]=Rf[t.format];e._zod.check=r=>{let o=r.value;o<n&&r.issues.push({origin:"bigint",input:o,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),o>i&&r.issues.push({origin:"bigint",input:o,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),F1=A("$ZodCheckMaxSize",(e,t)=>{var n;Jn.init(e,t),(n=e._zod.def).when??(n.when=O1),e._zod.check=i=>{let r=i.value;r.size<=t.maximum||i.issues.push({origin:Ff(r),code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),V1=A("$ZodCheckMinSize",(e,t)=>{var n;Jn.init(e,t),(n=e._zod.def).when??(n.when=O1),e._zod.check=i=>{let r=i.value;r.size>=t.minimum||i.issues.push({origin:Ff(r),code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),j1=A("$ZodCheckSizeEquals",(e,t)=>{var n;Jn.init(e,t),(n=e._zod.def).when??(n.when=O1),e._zod.check=i=>{let r=i.value,o=r.size;if(o===t.size)return;let a=o>t.size;i.issues.push({origin:Ff(r),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Z1=A("$ZodCheckMaxLength",(e,t)=>{var n;Jn.init(e,t),(n=e._zod.def).when??(n.when=L1),e._zod.check=i=>{let r=i.value,o=r.length;if((typeof r=="string"&&o>t.maximum?Cs(r):o)<=t.maximum)return;let s=Vf(r);i.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),I1=A("$ZodCheckMinLength",(e,t)=>{var n;Jn.init(e,t),(n=e._zod.def).when??(n.when=L1),e._zod.check=i=>{let r=i.value,o=r.length;if((typeof r=="string"&&o>=t.minimum&&o<t.minimum*2?Cs(r):o)>=t.minimum)return;let s=Vf(r);i.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),W1=A("$ZodCheckLengthEquals",(e,t)=>{var n;Jn.init(e,t),(n=e._zod.def).when??(n.when=L1),e._zod.check=i=>{let r=i.value,o=r.length,a=typeof r=="string"&&o>=t.length&&o<=t.length*2?Cs(r):o;if(a===t.length)return;let s=Vf(r),c=a>t.length;i.issues.push({origin:s,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),hl=A("$ZodCheckStringFormat",(e,t)=>{var n,i;Jn.init(e,t),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),D1=A("$ZodCheckRegex",(e,t)=>{hl.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),q1=A("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=T1),hl.init(e,t)}),H1=A("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=z1),hl.init(e,t)}),E1=A("$ZodCheckIncludes",(e,t)=>{Jn.init(e,t);let n=Ki(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=i,e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),C1=A("$ZodCheckStartsWith",(e,t)=>{Jn.init(e,t);let n=new RegExp(`^${Ki(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),U1=A("$ZodCheckEndsWith",(e,t)=>{Jn.init(e,t);let n=new RegExp(`.*${Ki(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}});function lh(e,t,n){e.issues.length&&t.issues.push(...Li(n,e.issues))}var A1=A("$ZodCheckProperty",(e,t)=>{Jn.init(e,t),e._zod.check=n=>{let i=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(i instanceof Promise)return i.then(r=>lh(r,n,t.property));lh(i,n,t.property)}}),G1=A("$ZodCheckProperties",(e,t)=>{Jn.init(e,t),jf(e,Symbol.iterator,function*(){yield e});let n;e._zod.check=i=>{if(i.value==null){i.issues.push({expected:"object",code:"invalid_type",input:i.value,inst:e});return}n??(n=Reflect.ownKeys(t.shape).map(a=>[a,t.shape[a]]));let r=i.value,o;for(let[a,s]of n){let c=s._zod.run({value:r[a],issues:[]},{});c instanceof Promise?(o??(o=[]),o.push(c.then(l=>lh(l,i,a)))):lh(c,i,a)}if(o)return Promise.all(o).then(()=>{})}}),J1=A("$ZodCheckMimeType",(e,t)=>{Jn.init(e,t);let n=new Set(t.mime);e._zod.check=i=>{n.has(i.value.type)||i.issues.push({code:"invalid_value",values:t.mime,input:i.value.type,inst:e,continue:!t.abort})}}),B1=A("$ZodCheckOverwrite",(e,t)=>{Jn.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});var As=class{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let i=t.split(`
18
+ `).filter(a=>a),r=Math.min(...i.map(a=>a.length-a.trimStart().length)),o=i.map(a=>a.slice(r)).map(a=>" ".repeat(this.indent*2)+a);for(let a of o)this.content.push(a)}compile(){let t=Function,n=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
19
+ ${n.join(`
20
+ `)}
21
+ };`)(...Object.values(this.closed))}};var Y1={major:4,minor:6,patch:5};var It=A("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Y1;let i=e._zod.def.checks,r=e._zod.traits.has("$ZodCheck")?[e,...i??[]]:i?.length?[...i]:[];for(let o of r)for(let a of o._zod.onattach)a(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,c,l)=>{if(s.memo)return s;let u=gi(s),f;for(let d of c){if(d._zod.def.when){if(Zy(s)||!d._zod.def.when(s))continue}else if(u)continue;let m=s.issues.length,p=d._zod.check(s);if(p instanceof Promise&&l?.async===!1)throw new Ni;if(f||p instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await p,s.issues.length!==m&&(Jp(s.issues,m,e),u||(u=gi(s,m)))});else{if(s.issues.length===m)continue;Jp(s.issues,m,e),u||(u=gi(s,m))}}return f?f.then(()=>s):s},a=(s,c,l)=>{if(gi(s))return s.aborted=!0,s;let u=o(c,r,l);if(u instanceof Promise){if(l.async===!1)throw new Ni;return u.then(f=>e._zod.parse(f,l))}return e._zod.parse(u,l)};e._zod.run=(s,c)=>{if(c.skipChecks)return e._zod.parse(s,c);if(c.direction==="backward"){let u=e._zod.parse({value:s.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(f=>a(f,s,c)):a(u,s,c)}let l=e._zod.parse(s,c);if(l instanceof Promise){if(c.async===!1)throw new Ni;return l.then(u=>o(u,r,c))}return o(l,r,c)}}},{get"~standard"(){return jf(this,"~standard",bh(this))},set"~standard"(e){Ua(this,"~standard",e)}}),sT=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Xi(n,t,wr()))}:{value:e.value};async function lA(e,t){let n={async:!0};return sT(await e._zod.run({value:t,issues:[]},n),n)}function bh(e){return{validate:t=>{let n={async:!1};try{let i=e._zod.run({value:t,issues:[]},n);if(!(i instanceof Promise))return sT(i,n)}catch{}return lA(e,t)},vendor:"zod",version:1}}var Gs=A("$ZodString",(e,t)=>{It.init(e,t),e._zod.pattern=t.pattern??y1,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),In=A("$ZodStringFormat",(e,t)=>{hl.init(e,t),Gs.init(e,t)}),Q1=A("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=n1),In.init(e,t)}),_1=A("$ZodUUID",(e,t)=>{if(t.version){let i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Us(i))}else t.pattern??(t.pattern=Us());In.init(e,t)}),$1=A("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=r1),In.init(e,t)}),ew=1,Uf=2;function tw(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function gh(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?tw(e)||Uf:cT(e,t)}function cT(e,t){if(!t.normalize&&t.protocol?.source===qf.source&&!/^https?:\/\//i.test(e))return ew;try{if(typeof URL<"u"){let n=URL;if(typeof n.parse=="function")return n.parse(e)??Uf}return new URL(e)}catch{return Uf}}var uA=/[\t\n\r]/g;function Af(e){return e.replace(uA,"")}function vh(e,t){return t.lastIndex=0,t.test(e.hostname)}function yh(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var nw=A("$ZodURL",(e,t)=>{In.init(e,t),e._zod.check=n=>{try{let i=n.value.trim(),r=gh(i,t);if(r===ew){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(r===Uf){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(r===!0){n.value=Af(i);return}t.hostname&&!vh(r,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!yh(r,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?r.href:Af(i);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),rw=A("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=i1()),In.init(e,t)}),iw=A("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?$y:e1(t.length)),In.init(e,t)}),ow=A("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=By),In.init(e,t)}),aw=A("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Yy),In.init(e,t)}),sw=A("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ky),In.init(e,t)}),cw=A("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Qy),In.init(e,t)}),lw=A("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=_y),In.init(e,t)}),uw=A("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=v1(t)),In.init(e,t)}),fw=A("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=b1),In.init(e,t)}),dw=A("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=g1(t)),In.init(e,t)}),mw=A("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=t1),In.init(e,t)}),pw=A("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=o1),In.init(e,t)}),fA=/^[0-9a-fA-F:.]+$/;function Gf(e){return fA.test(e)?tw(`http://[${e}]`):!1}var hw=A("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=a1),In.init(e,t),e._zod.check=n=>{Gf(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),bw=A("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=s1(t.delimiter)),In.init(e,t)}),gw=A("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=c1),In.init(e,t)});function wh(e){let t=e.split("/");if(t.length!==2)return!1;let[n,i]=t;if(!i)return!1;let r=Number(i);return`${r}`!==i||r<0||r>128?!1:Gf(n)}var vw=A("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=l1),In.init(e,t),e._zod.check=n=>{wh(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Jf(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var xh=/^[0-9a-zA-Z+/]*={0,2}$/,yw=A("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=xh),In.init(e,t),e._zod.check=n=>{Jf(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Bf=/^[A-Za-z0-9_-]*$/;function Ph(e){if(!Bf.test(e))return!1;let t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Jf(n)}var ww=A("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Bf),In.init(e,t),e._zod.check=n=>{Ph(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),xw=A("$ZodE164",(e,t)=>{t.pattern??(t.pattern=p1),In.init(e,t)}),dA=/[- ]/g;function mA(e){let t=e.length,n=1,i=0;for(;t;){let r=e.charCodeAt(--t)-48;n^=1,i+=n?[0,2,4,6,8,1,3,5,7,9][r]:r}return i%10===0}function Sh(e){return ah.test(e)?mA(e.replace(dA,"")):!1}var Pw=A("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=ah),In.init(e,t),e._zod.check=n=>{Sh(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function pA(e){let t=0,n=e.length;for(let i=4;i<n;i++){let r=e.charCodeAt(i);t=(r>=65?t*100+(r-55):t*10+(r-48))%97}for(let i=0;i<4;i++){let r=e.charCodeAt(i);t=(r>=65?t*100+(r-55):t*10+(r-48))%97}return t===1}function kh(e){return sh.test(e)?pA(e):!1}var Sw=A("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=sh),In.init(e,t),e._zod.check=n=>{kh(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function Th(e,t=null){try{let n=e.split(".");if(n.length!==3)return!1;let[i]=n;if(!i)return!1;let r=JSON.parse(atob(i));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}var kw=A("$ZodJWT",(e,t)=>{In.init(e,t),e._zod.check=n=>{Th(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Tw=A("$ZodCustomStringFormat",(e,t)=>{In.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),zh=A("$ZodNumber",(e,t)=>{It.init(e,t),e._zod.pattern=aa,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let o=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:String(r):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...o?{received:o}:{}}),n}}),zw=A("$ZodNumberFormat",(e,t)=>{N1.init(e,t),zh.init(e,t)}),Yf=A("$ZodBoolean",(e,t)=>{It.init(e,t),e._zod.pattern=P1,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=!!n.value}catch{}let r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),Mh=A("$ZodBigInt",(e,t)=>{It.init(e,t),e._zod.pattern=x1,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),Mw=A("$ZodBigIntFormat",(e,t)=>{R1.init(e,t),Mh.init(e,t)}),Ow=A("$ZodSymbol",(e,t)=>{It.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:e}),n}}),Lw=A("$ZodUndefined",(e,t)=>{It.init(e,t),e._zod.pattern=k1,e._zod.values=new Set([void 0]),e._zod.parse=(n,i)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:e}),n}}),Xw=A("$ZodNull",(e,t)=>{It.init(e,t),e._zod.pattern=S1,e._zod.values=new Set([null]),e._zod.parse=(n,i)=>{let r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),Nw=A("$ZodAny",(e,t)=>{It.init(e,t),e._zod.parse=n=>n}),Rw=A("$ZodUnknown",(e,t)=>{It.init(e,t),e._zod.parse=n=>n}),Fw=A("$ZodNever",(e,t)=>{It.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),Vw=A("$ZodVoid",(e,t)=>{It.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:e}),n}}),jw=A("$ZodDate",(e,t)=>{It.init(e,t),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}let r=n.value,o=r instanceof Date;return o&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...o?{received:"Invalid Date"}:{},inst:e}),n}});function G5(e,t,n){e.issues.length&&t.issues.push(...Li(n,e.issues)),t.value[n]=e.value}var Zw=A("$ZodArray",(e,t)=>{It.init(e,t);let n=Cr.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),i;i.value=n?n.alloc(e,i,Array(o.length),r):Array(o.length);let a=[],s=r?.abortEarly;for(let c=0;c<o.length;c++){let l=o[c],u=t.element._zod.run({value:l,issues:[]},r);if(u instanceof Promise)a.push(u.then(f=>G5(f,i,c)));else if(G5(u,i,c),s&&u.issues.length!==0&&gi(u))break}return a.length?Promise.all(a).then(()=>i):i}});function hh(e,t,n,i,r,o){let a=n in i,s=o==="optional";if(!(!a&&s&&r==="optional")){if(e.issues.length){if(r!==void 0&&s&&!a)return;t.issues.push(...Li(n,e.issues))}if(!a&&r===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(a||r==="defaulted"&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var hA=[];function lT(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),i=n.length?n:hA,r=i.length?[...t,...i]:t;for(let a of r)if(!e.shape?.[a]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(a)}": expected a Zod schema`);let o=jy(e.shape);return{...e,allKeys:r,symbolKeys:i,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function uT(e,t,n,i,r,o,a){let s=[],c=r.keySet,l=r.catchall._zod,u=l.def.type,f=l.optin,d=l.optout,m=0;for(let p in t){if(a&&n.issues.length!==m){if(gi(n,m))break;m=n.issues.length}if(c.has(p))continue;if(p==="__proto__"){u==="never"&&s.push(p);continue}if(u==="never"){s.push(p);continue}let b=l.run({value:t[p],issues:[]},i);b instanceof Promise?e.push(b.then(h=>hh(h,n,p,t,f,d))):hh(b,n,p,t,f,d)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var fT=A("$ZodObject",(e,t)=>{It.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape"),i=n?.get?n.get.raw:t.shape??{};if(i){let l=()=>{let u={...i};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=i,Object.defineProperty(t,"shape",{get:l})}let r=cl(()=>lT(t));Kt(e,"propValues",l=>{let u=l.def.shape,f={};for(let d in u){let m=u[d]._zod;if(m.values){Object.prototype.hasOwnProperty.call(f,d)||Yr(f,d,new Set);for(let p of m.values)f[d].add(p);m.optin!==void 0&&f[d].add(void 0)}}return f});let o=Es,a=t.catchall,s,c=Cr.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{s??(s=r.value);let f=l.value;if(!o(f))return l.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let d=[],m=s.shape,p=u?.abortEarly,b=l.issues.length;for(let h of s.allKeys){if(p&&l.issues.length!==b){if(gi(l,b))break;b=l.issues.length}if(h==="__proto__")continue;let v=m[h],g=v._zod.optin,y=v._zod.optout,w=v._zod.run({value:f[h],issues:[]},u);w instanceof Promise?d.push(w.then(x=>hh(x,l,h,f,g,y))):hh(w,l,h,f,g,y)}return a?uT(d,f,l,u,r.value,e,p===!0):d.length?Promise.all(d).then(()=>l):l}}),Iw=A("$ZodObjectJIT",(e,t)=>{fT.init(e,t);let n=e._zod.parse,i=cl(()=>lT(t)),r=Cr.memoizer,o=m=>{let p=i.value,b=p.symbolKeys,h=new As(["payload","ctx"],{shape:m,inst:e,memo:r,syms:b}),v=x=>`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`,g=(x,T)=>`
22
+ let ${x}_ab = false;
23
+ for (let i = 0; i < ${x}.issues.length; i++) {
24
+ const iss = ${x}.issues[i];
25
+ iss.path = iss.path ? [${T}, ...iss.path] : [${T}];
26
+ payload.issues.push(iss);
27
+ if (iss.continue !== true) ${x}_ab = true;
28
+ }
29
+ if (${x}_ab && ctx && ctx.abortEarly) {
30
+ payload.value = newResult;
31
+ return payload;
32
+ }`;h.write("const input = payload.value;");let y=Object.create(null),w=0;for(let x of p.allKeys)y[x]=`key_${w++}`;h.write(r?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let x of p.allKeys){if(x==="__proto__")continue;let T=y[x],z=typeof x=="symbol"?`syms[${b.indexOf(x)}]`:bi(x),k=`${z} in input`,S=m[x],M=S?._zod?.optin,L=M!==void 0,P=S?._zod?.optout==="optional";if(h.write(`const ${T} = ${v(z)};`),L&&P){let X=M==="optional"?`${T}_present`:`${T}.value !== undefined || ${T}_present`;h.write(`
33
+ const ${T}_present = ${k};
34
+ if (!${T}.issues.length || ${T}_present) {
35
+ if (${T}.issues.length) {${g(T,z)}
36
+ }
37
+
38
+ if (${X}) {
39
+ newResult[${z}] = ${T}.value;
40
+ }
41
+ }
42
+
43
+ `)}else L?(h.write(`
44
+ if (${T}.issues.length) {${g(T,z)}
45
+ }
46
+ `),M==="defaulted"?h.write(`newResult[${z}] = ${T}.value;`):h.write(`
47
+ if (${T}.value !== undefined || ${k}) {
48
+ newResult[${z}] = ${T}.value;
49
+ }
50
+ `)):h.write(`
51
+ const ${T}_present = ${k};
52
+ if (${T}.issues.length) {${g(T,z)}
53
+ }
54
+ if (!${T}_present && !${T}.issues.length) {
55
+ payload.issues.push({
56
+ code: "invalid_type",
57
+ expected: "nonoptional",
58
+ input: undefined,
59
+ path: [${z}]
60
+ });
61
+ if (ctx && ctx.abortEarly) {
62
+ payload.value = newResult;
63
+ return payload;
64
+ }
65
+ }
66
+
67
+ if (${T}_present) {
68
+ newResult[${z}] = ${T}.value;
69
+ }
70
+
71
+ `)}return h.write("payload.value = newResult;"),h.write("return payload;"),h.compile()},a,s=Es,c=!Cr.jitless,u=c&&Fy.value,f=t.catchall,d;e._zod.parse=(m,p)=>{d??(d=i.value);let b=m.value;return s(b)?c&&u&&p?.async===!1&&p.jitless!==!0?(a||(a=o(t.shape)),m=a(m,p),f?uT([],b,m,p,d,e,p?.abortEarly===!0):m):n(m,p):(m.issues.push({expected:"object",code:"invalid_type",input:b,inst:e}),m)}});function J5(e,t,n,i){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;let r=e.filter(o=>!gi(o));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(a=>Xi(a,i,wr())))}),t)}var Kf=A("$ZodUnion",(e,t)=>{It.init(e,t),Kt(e,"optin",i=>i.def.options.some(r=>r._zod.optin==="defaulted")?"defaulted":i.def.options.some(r=>r._zod.optin!==void 0)?"optional":void 0),Kt(e,"optout",i=>i.def.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Kt(e,"values",i=>{if(i.def.options.every(r=>r._zod.values))return new Set(i.def.options.flatMap(r=>Array.from(r._zod.values)))}),Kt(e,"pattern",i=>{if(i.def.options.every(r=>r._zod.pattern)){let r=i.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>oa(o.source)).join("|")})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let o=!1,a=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},r);if(c instanceof Promise)a.push(c),o=!0;else{if(c.issues.length===0)return c;a.push(c)}}return o?Promise.all(a).then(s=>J5(s,i,e,r)):J5(a,i,e,r)}});function B5(e,t,n,i){let r=[];for(let o=0;o<e.length;o++)e[o].issues.length===0&&r.push(o);return r.length===1?(t.value=e[r[0]].value,t):(r.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(a=>Xi(a,i,wr())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:r}),t)}var Ww=A("$ZodXor",(e,t)=>{Kf.init(e,t),t.inclusive=!1;let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(i,r)=>{if(n)return n(i,r);let o=!1,a=[];for(let s of t.options){let c=s._zod.run({value:i.value,issues:[]},r);c instanceof Promise?(a.push(c),o=!0):a.push(c)}return o?Promise.all(a).then(s=>B5(s,i,e,r)):B5(a,i,e,r)}});function Dw(e,t){let n=e._zod,i=n.bag.optionsMap;i||(i=dT(n.def),n.bag.optionsMap=i);let r=i.get(t);if(r===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return r}function dT(e){let t=new Map;for(let n of e.options){let i=n._zod.propValues?.[e.discriminator];if(!i||i.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(let r of i)if(t.has(r)){if(r!==void 0)throw new Error(`Duplicate discriminator value "${String(r)}"`);t.set(r,null)}else t.set(r,n)}return t}var qw=A("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Kf.init(e,t);let n=e._zod.parse;Kt(e,"propValues",r=>{let o={},a=0;for(let s of r.def.options){let c=s._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${r.def.options.indexOf(s)}"`);c[r.def.discriminator]?.has(void 0)&&a++;for(let[l,u]of Object.entries(c)){Object.prototype.hasOwnProperty.call(o,l)||Yr(o,l,new Set);for(let f of u)o[l].add(f)}}return!r.def.unionFallback&&a>1&&o[r.def.discriminator]?.delete(void 0),o}),t.options.forEach((r,o)=>{let a=ll(r._zod.def);if(a&&!Object.prototype.hasOwnProperty.call(a,t.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});let i=cl(()=>dT(t));e._zod.parse=(r,o)=>{let a=r.value;if(!Es(a))return r.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),r;let s=a?.[t.discriminator],c=i.value.get(s);return c&&(s!==void 0||o.direction!=="backward")?c._zod.run(r,o):t.unionFallback||o.direction==="backward"?n(r,o):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(i.value.keys()).filter(l=>i.value.get(l)!==null),input:a,path:[t.discriminator],inst:e}),r)}}),Hw=A("$ZodIntersection",(e,t)=>{It.init(e,t),e._zod.parse=(n,i)=>{let r=n.value,o=t.left._zod.run({value:r,issues:[]},i),a=t.right._zod.run({value:r,issues:[]},i);return o instanceof Promise||a instanceof Promise?Promise.all([o,a]).then(([c,l])=>Y5(n,c,l)):Y5(n,o,a)}});function bl(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Yi(e)&&Yi(t)){let n=Object.keys(t),i=Object.keys(e).filter(o=>n.indexOf(o)!==-1),r={...e,...t};Object.prototype.hasOwnProperty.call(r,"__proto__")&&delete r.__proto__;for(let o of i){if(o==="__proto__")continue;let a=bl(e[o],t[o]);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};r[o]=a.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let i=0;i<e.length;i++){let r=e[i],o=t[i],a=bl(r,o);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};n.push(a.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Y5(e,t,n){let i=new Map,r,o=new Map,a=(l,u)=>{let f;if(l.code==="unrecognized_keys"&&!l.path?.length)r??(r=l),f=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let d=String(l.path[0]);o.has(d)||o.set(d,l),f=[d]}else return!1;for(let d of f)i.has(d)||i.set(d,{}),i.get(d)[u]=!0;return!0};for(let l of t.issues)a(l,"l")||e.issues.push(l);for(let l of n.issues)a(l,"r")||e.issues.push(l);let s=[...i].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(s.length){let l=r?s.filter(u=>r.keys.includes(u)):[];l.length&&e.issues.push({...r,keys:l});for(let u of s)!l.includes(u)&&o.has(u)&&e.issues.push(o.get(u))}let c=bl(t.value,n.value);if(!c.valid){if(gi(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Oh=A("$ZodTuple",(e,t)=>{It.init(e,t);let n=t.items,i=Cr.memoizer;i?.attach(e),e._zod.parse=(r,o)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({input:a,inst:e,expected:"tuple",code:"invalid_type"}),r;r.value=i?i.alloc(e,r,[],o):[];let s=[],c=K5(n,"optin"),l=K5(n,"optout");if(!t.rest){if(a.length<c)return r.issues.push({code:"too_small",minimum:c,inclusive:!0,input:a,inst:e,origin:"array"}),r;a.length>n.length&&r.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:a,inst:e,origin:"array"})}let u=new Array(n.length),f=t.rest?o?.abortEarly:void 0,d=!1;for(let m=0;m<n.length;m++){let p=n[m]._zod.run({value:a[m],issues:[]},o);p instanceof Promise?s.push(p.then(b=>{u[m]=b})):(u[m]=p,f&&!d&&p.issues.length&&(d=gi(p)))}if(t.rest&&!d){let m=n.length-1,p=a.slice(n.length),b=r.issues.length;for(let h of p){if(f&&r.issues.length!==b){if(gi(r,b))break;b=r.issues.length}m++;let v=t.rest._zod.run({value:h,issues:[]},o);v instanceof Promise?s.push(v.then(g=>Q5(g,r,m))):Q5(v,r,m)}}return s.length?Promise.all(s).then(()=>_5(u,r,n,a,l)):_5(u,r,n,a,l)}});function K5(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Q5(e,t,n){e.issues.length&&t.issues.push(...Li(n,e.issues)),t.value[n]=e.value}function _5(e,t,n,i,r){for(let o=0;o<n.length;o++){let a=e[o],s=o<i.length;if(!s&&o>=r&&n[o]._zod.optin==="optional"){t.value.length=o;break}if(a.issues.length){if(!s&&o>=r){t.value.length=o;break}t.issues.push(...Li(o,a.issues))}t.value[o]=a.value}for(let o=t.value.length-1;o>=i.length&&(n[o]._zod.optout==="optional"&&t.value[o]===void 0);o--)t.value.length=o;return t}var Ew=A("$ZodRecord",(e,t)=>{It.init(e,t);let n=Cr.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let o=i.value;if(!Yi(o))return i.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),i;let a=[],s=t.keyType._zod.values;if(s&&!t.partial){i.value=n?n.alloc(e,i,{},r):{};let c=new Set;for(let u of s)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){if(c.add(typeof u=="number"?u.toString():u),u==="__proto__")continue;let f=t.keyType._zod.run({value:u,issues:[]},r);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){i.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(p=>Xi(p,r,wr())),input:u,path:[u],inst:e});continue}let d=f.value;if(d==="__proto__")continue;let m=t.valueType._zod.run({value:o[u],issues:[]},r);m instanceof Promise?a.push(m.then(p=>{p.issues.length&&i.issues.push(...Li(u,p.issues)),i.value[d]=p.value})):(m.issues.length&&i.issues.push(...Li(u,m.issues)),i.value[d]=m.value)}let l;for(let u in o)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;i.value[u]=o[u]}else l=l??[],l.push(u);l&&l.length>0&&i.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:l,continue:!0})}else{i.value=n?n.alloc(e,i,{},r):{};let c;for(let l of Reflect.ownKeys(o)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&aa.test(l)&&u.issues.length){let p=t.keyType._zod.run({value:Number(l),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(u=p)}if(u.issues.length){t.mode==="loose"?i.value[l]=o[l]:s?(c=c??[],c.push(l)):i.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(p=>Xi(p,r,wr())),input:l,path:[l],inst:e});continue}let d=u.value;if(d==="__proto__")continue;let m=t.valueType._zod.run({value:o[l],issues:[]},r);m instanceof Promise?a.push(m.then(p=>{p.issues.length&&i.issues.push(...Li(l,p.issues)),i.value[d]=p.value})):(m.issues.length&&i.issues.push(...Li(l,m.issues)),i.value[d]=m.value)}c&&c.length>0&&i.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c,continue:!0})}return a.length?Promise.all(a).then(()=>i):i}}),Cw=A("$ZodMap",(e,t)=>{It.init(e,t);let n=Cr.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let o=i.value;if(!(o instanceof Map))return i.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),i;let a=[];i.value=n?n.alloc(e,i,new Map,r):new Map;let s=r?.abortEarly,c=i.issues.length;for(let[l,u]of o){if(s&&i.issues.length!==c){if(gi(i,c))break;c=i.issues.length}let f=t.keyType._zod.run({value:l,issues:[]},r),d=t.valueType._zod.run({value:u,issues:[]},r);f instanceof Promise||d instanceof Promise?a.push(Promise.all([f,d]).then(([m,p])=>{$5(m,p,i,l,o,e,r)})):$5(f,d,i,l,o,e,r)}return a.length?Promise.all(a).then(()=>i):i}});function $5(e,t,n,i,r,o,a){e.issues.length&&(Xf.has(typeof i)?n.issues.push(...Li(i,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:r,inst:o,issues:e.issues.map(s=>Xi(s,a,wr()))})),t.issues.length&&(Xf.has(typeof i)?n.issues.push(...Li(i,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:r,inst:o,key:i,issues:t.issues.map(s=>Xi(s,a,wr()))})),n.value.set(e.value,t.value)}var Uw=A("$ZodSet",(e,t)=>{It.init(e,t);let n=Cr.memoizer;n?.attach(e),e._zod.parse=(i,r)=>{let o=i.value;if(!(o instanceof Set))return i.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),i;let a=[];i.value=n?n.alloc(e,i,new Set,r):new Set;let s=r?.abortEarly,c=i.issues.length;for(let l of o){if(s&&i.issues.length!==c){if(gi(i,c))break;c=i.issues.length}let u=t.valueType._zod.run({value:l,issues:[]},r);u instanceof Promise?a.push(u.then(f=>eT(f,i))):eT(u,i)}return a.length?Promise.all(a).then(()=>i):i}});function eT(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}var Aw=A("$ZodEnum",(e,t)=>{It.init(e,t);let n=al(t.entries),i=new Set(n);e._zod.values=i,Kt(e,"pattern",r=>{let o=al(r.def.entries).filter(a=>Xf.has(typeof a));return new RegExp(o.length?`^(${o.map(a=>Ki(a.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{let a=r.value;return i.has(a)||r.issues.push({code:"invalid_value",values:n,input:a,inst:e}),r}}),Gw=A("$ZodLiteral",(e,t)=>{It.init(e,t);let n=new Set(t.values);e._zod.values=n,Kt(e,"pattern",i=>{let r=i.def.values;return new RegExp(r.length?`^(${r.map(o=>typeof o=="string"?Ki(o):o?Ki(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,r)=>{let o=i.value;return n.has(o)||i.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),i}}),Jw=A("$ZodFile",(e,t)=>{It.init(e,t),e._zod.parse=(n,i)=>{let r=n.value;return r instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:r,inst:e}),n}}),Bw=A("$ZodTransform",(e,t)=>{It.init(e,t),e._zod.optin="optional",Cr.memoizer?.guard(e),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Aa(e.constructor.name);let r=t.transform(n.value,n);if(i.async)return(r instanceof Promise?r:Promise.resolve(r)).then(a=>(n.value=a,n));if(r instanceof Promise)throw new Ni;return n.value=r,n}});function tT(e,t){return e.value=t.issues.length?void 0:t.value,e}var Lh=A("$ZodOptional",(e,t)=>{It.init(e,t),Kt(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Kt(e,"values",n=>{let i=n.def.innerType._zod.values;return i?new Set([...i,void 0]):void 0}),Kt(e,"pattern",n=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${oa(i.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;let r=t.innerType._zod.run({value:n.value,issues:[]},i);return r instanceof Promise?r.then(o=>tT(n,o)):tT(n,r)}return t.innerType._zod.run(n,i)}}),Yw=A("$ZodExactOptional",(e,t)=>{Lh.init(e,t),Kt(e,"values",n=>n.def.innerType._zod.values),Kt(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Kw=A("$ZodNullable",(e,t)=>{It.init(e,t),Kt(e,"optin",n=>n.def.innerType._zod.optin),Kt(e,"optout",n=>n.def.innerType._zod.optout),Kt(e,"pattern",n=>{let i=n.def.innerType._zod.pattern;return i?new RegExp(`^(${oa(i.source)}|null)$`):void 0}),Kt(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>n.value===null?n:t.innerType._zod.run(n,i)}),Qw=A("$ZodDefault",(e,t)=>{It.init(e,t),e._zod.optin="defaulted",Kt(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>nT(o,t)):nT(r,t)}});function nT(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var _w=A("$ZodPrefault",(e,t)=>{It.init(e,t),e._zod.optin="defaulted",Kt(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>(i.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,i))}),$w=A("$ZodNonOptional",(e,t)=>{It.init(e,t),Kt(e,"values",n=>{let i=n.def.innerType._zod.values;return i?new Set([...i].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,i)=>{let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>rT(o,e)):rT(r,e)}});function rT(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var ex=A("$ZodSuccess",(e,t)=>{It.init(e,t),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Aa("ZodSuccess");let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(o=>(n.value=o.issues.length===0,n)):(n.value=r.issues.length===0,n)}});function iT(e,t,n,i){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(r=>Xi(r,i,wr()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var tx=A("$ZodCatch",(e,t)=>{It.init(e,t),Kt(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Kt(e,"optout",n=>n.def.innerType._zod.optout),Kt(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run({value:n.value,issues:[]},i);return r instanceof Promise?r.then(o=>iT(n,o,t,i)):iT(n,r,t,i)}}),nx=A("$ZodNaN",(e,t)=>{It.init(e,t),e._zod.parse=(n,i)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),Xh=A("$ZodPipe",(e,t)=>{It.init(e,t),Kt(e,"values",n=>n.def.in._zod.values),Kt(e,"optin",n=>n.def.in._zod.optin),Kt(e,"optout",n=>n.def.out._zod.optout),Kt(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){let o=t.out._zod.run(n,i);return o instanceof Promise?o.then(a=>dh(a,t.in,i)):dh(o,t.in,i)}let r=t.in._zod.run(n,i);return r instanceof Promise?r.then(o=>dh(o,t.out,i)):dh(r,t.out,i)}});function dh(e,t,n){return e.issues.some(i=>i.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Qf=A("$ZodCodec",(e,t)=>{It.init(e,t),Kt(e,"values",n=>n.def.in._zod.values),Kt(e,"optin",n=>n.def.in._zod.optin),Kt(e,"optout",n=>n.def.out._zod.optout),Kt(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,i)=>{if((i.direction||"forward")==="forward"){let o=t.in._zod.run(n,i);return o instanceof Promise?o.then(a=>mh(a,t,i)):mh(o,t,i)}else{let o=t.out._zod.run(n,i);return o instanceof Promise?o.then(a=>mh(a,t,i)):mh(o,t,i)}}});function mh(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){let r=t.transform(e.value,e);return r instanceof Promise?r.then(o=>ph(e,o,t.out,n)):ph(e,r,t.out,n)}else{let r=t.reverseTransform(e.value,e);return r instanceof Promise?r.then(o=>ph(e,o,t.in,n)):ph(e,r,t.in,n)}}function ph(e,t,n,i){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},i)}var rx=A("$ZodPreprocess",(e,t)=>{Xh.init(e,t)}),ix=A("$ZodReadonly",(e,t)=>{It.init(e,t),Kt(e,"propValues",n=>n.def.innerType._zod.propValues),Kt(e,"values",n=>n.def.innerType._zod.values),Kt(e,"optin",n=>n.def.innerType?._zod?.optin),Kt(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);let r=t.innerType._zod.run(n,i);return r instanceof Promise?r.then(oT):oT(r)}});function oT(e){return e.memo||(e.value=Object.freeze(e.value)),e}function bA(e){let t=e._zod.def,n=t.pattern,i=!!t.format?.includes("int"),r,o;for(let s of t.checks??[]){let c=s._zod.def;c.pattern&&(n=c.pattern),i||(i=!!c.format?.includes("int"));let l=c.minimum??c.length,u=c.maximum??c.length;l!==void 0&&(r===void 0||l>r)&&(r=l),u!==void 0&&(o===void 0||u<o)&&(o=u)}if(n)return n.source;if(r!==void 0&&o!==void 0&&r>o)return"(?!)";if(r!==void 0||o!==void 0)return w1({minimum:r,maximum:o}).source;let a=e._zod.pattern;return(i&&a===aa?Hf:a)?.source}function K1(e){let t=e._zod.def,n=e._zod.pattern?.source,i=t.innerType??e._zod.innerType;if(i){let r=i._zod.pattern?.source,o=K1(i);return n&&r&&o&&o!==r?n.replace(oa(r),()=>oa(o)):n}if(t.options){let r=t.options.map(K1);if(r.every(Boolean))return`^(${r.map(o=>oa(o)).join("|")})$`}return bA(e)}var ox=A("$ZodTemplateLiteral",(e,t)=>{It.init(e,t);let n=[];for(let i of t.parts)if(typeof i=="object"&&i!==null){let r=K1(i);if(!r)throw new Error(`Invalid template literal part, no pattern found: ${[...i._zod.traits].shift()}`);n.push(oa(r))}else if(i===null||Vy.has(typeof i))n.push(Ki(`${i}`));else throw new Error(`Invalid template literal part: ${i}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(i,r)=>typeof i.value!="string"?(i.issues.push({input:i.value,inst:e,expected:"string",code:"invalid_type"}),i):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(i.value)||i.issues.push({input:i.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),i)}),ax=A("$ZodFunction",(e,t)=>(It.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return Object.defineProperty(function(...i){let r=e._def.input?Kp(e._def.input,i):i,o=Reflect.apply(n,this,r);return e._def.output?Kp(e._def.output,o):o},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...i){let r=e._def.input?await Qp(e._def.input,i):i,o=await Reflect.apply(n,this,r);return e._def.output?await Qp(e._def.output,o):o},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,i)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{let i=e.constructor;return Array.isArray(n[0])?new i({type:"function",input:new Oh({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new i({type:"function",input:n[0],output:e._def.output})},e.output=n=>{let i=e.constructor;return new i({type:"function",input:e._def.input,output:n})},e)),sx=A("$ZodPromise",(e,t)=>{It.init(e,t),e._zod.parse=(n,i)=>Promise.resolve(n.value).then(r=>t.innerType._zod.run({value:r,issues:[]},i))}),_f=A("$ZodLazy",(e,t)=>{It.init(e,t),Ny(e._zod,"innerType",()=>{let n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),Kt(e,"pattern",n=>n.innerType?._zod?.pattern),Kt(e,"propValues",n=>n.innerType?._zod?.propValues),Kt(e,"optin",n=>n.innerType?._zod?.optin??void 0),Kt(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,i)=>e._zod.innerType._zod.run(n,i)}),cx=A("$ZodCustom",(e,t)=>{Jn.init(e,t),It.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=n=>{let i=n.value,r=t.fn(i);if(r instanceof Promise)return r.then(o=>aT(o,n,i,e));aT(r,n,i,e)}});function aT(e,t,n,i){if(!e){let r={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(r.params=i._zod.def.params),t.issues.push(ul(r))}}var Vh=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},ux="~memo",pT=[];function hT(e){return e!==null&&typeof e=="object"}function lx(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var bT=new WeakMap,gl=0,Fh=1,$f=2;function ed(e,t,n){let i=bT.get(e);if(i!==void 0)return i?$f:gl;if(t.has(e))return $f;t.add(e);let r=gl,o=u=>{if(r!==$f&&u?._zod){let f=ed(u,t,n);f>r&&(r=f)}},a=(u,f)=>{let d=gl;for(let m of Reflect.ownKeys(u)){let p=Object.getOwnPropertyDescriptor(u,m);if(f&&!p.enumerable)continue;let b=p.get?Fh:p.value?._zod?ed(p.value,t,n):gl;b>d&&(d=b)}return d},s=u=>{u>r&&(r=u)},c=e._zod.def,l=c.type;switch(l){case"object":{let u=ll(c);s(u?a(u,!0):Fh),o(c.catchall);break}case"array":o(c.element);break;case"tuple":for(let u of c.items)o(u);o(c.rest);break;case"record":case"map":o(c.keyType),o(c.valueType);break;case"set":o(c.valueType);break;case"union":for(let u of c.options)o(u);break;case"intersection":o(c.left),o(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(c.innerType);break;case"pipe":o(c.in),o(c.out);break;case"function":o(c.input),o(c.output);break;case"lazy":{let u=c._cachedInner??(n?e._zod.innerType:void 0);s(u?ed(u,t,!1):Fh);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let f=Object.getOwnPropertyDescriptor(c,u);if(!f||f.get)continue;let d=f.value;if(!(!d||typeof d!="object")){if(d._zod)o(d);else if(Array.isArray(d))for(let m of d)o(m)}}}return t.delete(e),gA(e,r)}function gA(e,t){return t!==Fh&&bT.set(e,t===$f),t}function jh(e){return ed(e,new Set,!0)!==gl}function vA(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var Nh,Rh=[],yA={alloc(e,t,n){let i=Nh;if(!i)return n;Nh=void 0;let r={value:n,issues:null};return i.set(t.value,r),Rh.push(r),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let n=e._zod.parse,i=(r,o)=>{if(o.direction!=="backward"&&Zh(o,r.value))throw new Vh;return n(r,o)};e._zod.parse=i,e._zod.run===n&&(e._zod.run=i)})},attach(e){var t;let n,i=!1,r,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let a=e._zod.parse,s=(c,l)=>{if(n===void 0){let v=ed(e,new Set,!1);if(v===gl)return e._zod.parse=a,e._zod.run===s&&(e._zod.run=a),a(c,l);v===$f||i?n=!0:i=!0}let u=c.value;if(!hT(u))return a(c,l);let f=l[ux];f||(f={buckets:new WeakMap,backEdges:void 0},l[ux]=f);let d;r===l?d=o:(d=vA(f,e),r=l,o=d);let m=d.get(u);if(m)return c.value=m.value,m.issues?m.issues.length&&c.issues.push(...lx(m.issues)):(c.memo=!0,f.backEdges??(f.backEdges=new WeakSet),f.backEdges.add(m.value)),c;Nh=d;let p=Rh.length,b=a(c,l);Nh=void 0;let h=Rh.length>p?Rh.pop():void 0;return b instanceof Promise?b.then(v=>(h&&(h.issues=v.issues.length?lx(v.issues):pT),v)):(h&&(h.issues=b.issues.length?lx(b.issues):pT),b)};e._zod.parse=s,e._zod.run===a&&(e._zod.run=s)})}};function td(){return yA}function Zh(e,t){let n=e[ux]?.backEdges;return n!==void 0&&hT(t)&&n.has(t)}var rd={};Bo(rd,{ar:()=>gT,az:()=>vT,be:()=>wT,bg:()=>xT,bn:()=>PT,ca:()=>ST,ckb:()=>kT,cs:()=>TT,da:()=>zT,de:()=>MT,el:()=>OT,en:()=>Ih,eo:()=>LT,es:()=>XT,fa:()=>NT,fi:()=>RT,fr:()=>FT,frCA:()=>VT,gu:()=>jT,he:()=>ZT,hi:()=>IT,hr:()=>WT,hu:()=>DT,hy:()=>HT,id:()=>ET,is:()=>CT,it:()=>UT,ja:()=>AT,ka:()=>GT,kh:()=>JT,km:()=>Wh,kn:()=>BT,ko:()=>YT,lt:()=>QT,mk:()=>_T,ms:()=>$T,ne:()=>ez,nl:()=>tz,nn:()=>nz,no:()=>rz,ota:()=>iz,pl:()=>az,ps:()=>oz,pt:()=>sz,ptBR:()=>cz,ro:()=>lz,ru:()=>fz,sk:()=>dz,sl:()=>mz,sv:()=>pz,ta:()=>hz,tg:()=>bz,th:()=>gz,tk:()=>vz,tr:()=>yz,ua:()=>wz,uk:()=>Dh,ur:()=>xz,uz:()=>Pz,vi:()=>Sz,yo:()=>zz,zhCN:()=>kz,zhTW:()=>Tz});var wA=()=>{let e={string:{unit:"\u062D\u0631\u0641",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},file:{unit:"\u0628\u0627\u064A\u062A",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},array:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},set:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"},map:{unit:"\u0639\u0646\u0635\u0631",verb:"\u0623\u0646 \u064A\u062D\u0648\u064A"}};function t(r){return e[r]??null}let n={regex:"\u0645\u062F\u062E\u0644",email:"\u0628\u0631\u064A\u062F \u0625\u0644\u0643\u062A\u0631\u0648\u0646\u064A",url:"\u0631\u0627\u0628\u0637",emoji:"\u0625\u064A\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u064A\u062E \u0648\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",date:"\u062A\u0627\u0631\u064A\u062E \u0628\u0645\u0639\u064A\u0627\u0631 ISO",time:"\u0648\u0642\u062A \u0628\u0645\u0639\u064A\u0627\u0631 ISO",duration:"\u0645\u062F\u0629 \u0628\u0645\u0639\u064A\u0627\u0631 ISO",ipv4:"\u0639\u0646\u0648\u0627\u0646 IPv4",ipv6:"\u0639\u0646\u0648\u0627\u0646 IPv6",mac:"\u0639\u0646\u0648\u0627\u0646 MAC",cidrv4:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv4",cidrv6:"\u0645\u062F\u0649 \u0639\u0646\u0627\u0648\u064A\u0646 \u0628\u0635\u064A\u063A\u0629 IPv6",base64:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64-encoded",base64url:"\u0646\u064E\u0635 \u0628\u062A\u0631\u0645\u064A\u0632 base64url-encoded",json_string:"\u0646\u064E\u0635 \u0639\u0644\u0649 \u0647\u064A\u0626\u0629 JSON",e164:"\u0631\u0642\u0645 \u0647\u0627\u062A\u0641 \u0628\u0645\u0639\u064A\u0627\u0631 E.164",credit_card:"\u0631\u0642\u0645 \u0628\u0637\u0627\u0642\u0629 \u0627\u0644\u0627\u0626\u062A\u0645\u0627\u0646",currency_code:"\u0631\u0645\u0632 \u0627\u0644\u0639\u0645\u0644\u0629",iban:"IBAN",jwt:"JWT",template_literal:"\u0645\u062F\u062E\u0644"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 instanceof ${r.expected}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`:`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${o}\u060C \u0648\u0644\u0643\u0646 \u062A\u0645 \u0625\u062F\u062E\u0627\u0644 ${s}`}case"invalid_value":return r.values.length===1?`\u0645\u062F\u062E\u0644\u0627\u062A \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644\u0629: \u064A\u0641\u062A\u0631\u0636 \u0625\u062F\u062E\u0627\u0644 ${ge(r.values[0])}`:`\u0627\u062E\u062A\u064A\u0627\u0631 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062A\u0648\u0642\u0639 \u0627\u0646\u062A\u0642\u0627\u0621 \u0623\u062D\u062F \u0647\u0630\u0647 \u0627\u0644\u062E\u064A\u0627\u0631\u0627\u062A: ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?` \u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631"}`:`\u0623\u0643\u0628\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0623\u0646 \u062A\u0643\u0648\u0646 ${r.origin??"\u0627\u0644\u0642\u064A\u0645\u0629"} ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${r.minimum.toString()} ${a.unit}`:`\u0623\u0635\u063A\u0631 \u0645\u0646 \u0627\u0644\u0644\u0627\u0632\u0645: \u064A\u0641\u062A\u0631\u0636 \u0644\u0640 ${r.origin} \u0623\u0646 \u064A\u0643\u0648\u0646 ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0628\u062F\u0623 \u0628\u0640 "${r.prefix}"`:o.format==="ends_with"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0646\u062A\u0647\u064A \u0628\u0640 "${o.suffix}"`:o.format==="includes"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u062A\u0636\u0645\u0651\u064E\u0646 "${o.includes}"`:o.format==="regex"?`\u0646\u064E\u0635 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0637\u0627\u0628\u0642 \u0627\u0644\u0646\u0645\u0637 ${o.pattern}`:`${n[o.format]??r.format} \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644`}case"not_multiple_of":return`\u0631\u0642\u0645 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644: \u064A\u062C\u0628 \u0623\u0646 \u064A\u0643\u0648\u0646 \u0645\u0646 \u0645\u0636\u0627\u0639\u0641\u0627\u062A ${r.divisor}`;case"unrecognized_keys":return`\u0645\u0639\u0631\u0641${r.keys.length>1?"\u0627\u062A":""} \u063A\u0631\u064A\u0628${r.keys.length>1?"\u0629":""}: ${G(r.keys,"\u060C ")}`;case"invalid_key":return`\u0645\u0639\u0631\u0641 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;case"invalid_union":return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644";case"invalid_element":return`\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644 \u0641\u064A ${r.origin}`;default:return"\u0645\u062F\u062E\u0644 \u063A\u064A\u0631 \u0645\u0642\u0628\u0648\u0644"}}};function gT(){return{localeError:wA()}}var xA=()=>{let e={string:{unit:"simvol",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"element",verb:"olmal\u0131d\u0131r"},set:{unit:"element",verb:"olmal\u0131d\u0131r"},map:{unit:"element",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"kredit kart\u0131 n\xF6mr\u0259si",currency_code:"valyuta kodu",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n instanceof ${r.expected}, daxil olan ${s}`:`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${o}, daxil olan ${s}`}case"invalid_value":return r.values.length===1?`Yanl\u0131\u015F d\u0259y\u0259r: g\xF6zl\u0259nil\u0259n ${ge(r.values[0])}`:`Yanl\u0131\u015F se\xE7im: a\u015Fa\u011F\u0131dak\u0131lardan biri olmal\u0131d\u0131r: ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${o}${r.maximum.toString()} ${a.unit??"element"}`:`\xC7ox b\xF6y\xFCk: g\xF6zl\u0259nil\u0259n ${r.origin??"d\u0259y\u0259r"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${o}${r.minimum.toString()} ${a.unit}`:`\xC7ox ki\xE7ik: g\xF6zl\u0259nil\u0259n ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Yanl\u0131\u015F m\u0259tn: "${o.prefix}" il\u0259 ba\u015Flamal\u0131d\u0131r`:o.format==="ends_with"?`Yanl\u0131\u015F m\u0259tn: "${o.suffix}" il\u0259 bitm\u0259lidir`:o.format==="includes"?`Yanl\u0131\u015F m\u0259tn: "${o.includes}" daxil olmal\u0131d\u0131r`:o.format==="regex"?`Yanl\u0131\u015F m\u0259tn: ${o.pattern} \u015Fablonuna uy\u011Fun olmal\u0131d\u0131r`:`Yanl\u0131\u015F ${n[o.format]??r.format}`}case"not_multiple_of":return`Yanl\u0131\u015F \u0259d\u0259d: ${r.divisor} il\u0259 b\xF6l\xFCn\u0259 bil\u0259n olmal\u0131d\u0131r`;case"unrecognized_keys":return`Tan\u0131nmayan a\xE7ar${r.keys.length>1?"lar":""}: ${G(r.keys,", ")}`;case"invalid_key":return`${r.origin} daxilind\u0259 yanl\u0131\u015F a\xE7ar`;case"invalid_union":return"Yanl\u0131\u015F d\u0259y\u0259r";case"invalid_element":return`${r.origin} daxilind\u0259 yanl\u0131\u015F d\u0259y\u0259r`;default:return"Yanl\u0131\u015F d\u0259y\u0259r"}}};function vT(){return{localeError:xA()}}function yT(e,t,n,i){let r=Math.abs(e),o=r%10,a=r%100;return a>=11&&a<=19?i:o===1?t:o>=2&&o<=4?n:i}var PA=()=>{let e={string:{unit:{one:"\u0441\u0456\u043C\u0432\u0430\u043B",few:"\u0441\u0456\u043C\u0432\u0430\u043B\u044B",many:"\u0441\u0456\u043C\u0432\u0430\u043B\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},map:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u044B",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u044B",many:"\u0431\u0430\u0439\u0442\u0430\u045E"},verb:"\u043C\u0435\u0446\u044C"}};function t(r){return e[r]??null}let n={regex:"\u0443\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0430\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0456 \u0447\u0430\u0441",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0447\u0430\u0441",duration:"ISO \u043F\u0440\u0430\u0446\u044F\u0433\u043B\u0430\u0441\u0446\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0430\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0430\u0441",mac:"MAC \u0430\u0434\u0440\u0430\u0441",cidrv4:"IPv4 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u044B\u044F\u043F\u0430\u0437\u043E\u043D",base64:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64",base64url:"\u0440\u0430\u0434\u043E\u043A \u0443 \u0444\u0430\u0440\u043C\u0430\u0446\u0435 base64url",json_string:"JSON \u0440\u0430\u0434\u043E\u043A",e164:"\u043D\u0443\u043C\u0430\u0440 E.164",credit_card:"\u043D\u0443\u043C\u0430\u0440 \u043A\u0440\u044D\u0434\u044B\u0442\u043D\u0430\u0439 \u043A\u0430\u0440\u0442\u044B",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u044B",iban:"IBAN",jwt:"JWT",template_literal:"\u0443\u0432\u043E\u0434"},i={nan:"NaN",number:"\u043B\u0456\u043A",array:"\u043C\u0430\u0441\u0456\u045E"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F instanceof ${r.expected}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u045E\u0441\u044F ${o}, \u0430\u0442\u0440\u044B\u043C\u0430\u043D\u0430 ${s}`}case"invalid_value":return r.values.length===1?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F ${ge(r.values[0])}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0432\u0430\u0440\u044B\u044F\u043D\u0442: \u0447\u0430\u043A\u0430\u045E\u0441\u044F \u0430\u0434\u0437\u0456\u043D \u0437 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);if(a){let s=Number(r.maximum),c=yT(s,a.unit.one,a.unit.few,a.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${o}${r.maximum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u0432\u044F\u043B\u0456\u043A\u0456: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435"} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);if(a){let s=Number(r.minimum),c=yT(s,a.unit.one,a.unit.few,a.unit.many);return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 ${a.verb} ${o}${r.minimum.toString()} ${c}`}return`\u0417\u0430\u043D\u0430\u0434\u0442\u0430 \u043C\u0430\u043B\u044B: \u0447\u0430\u043A\u0430\u043B\u0430\u0441\u044F, \u0448\u0442\u043E ${r.origin} \u043F\u0430\u0432\u0456\u043D\u043D\u0430 \u0431\u044B\u0446\u044C ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u043F\u0430\u0447\u044B\u043D\u0430\u0446\u0446\u0430 \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u0430\u043A\u0430\u043D\u0447\u0432\u0430\u0446\u0446\u0430 \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0437\u043C\u044F\u0448\u0447\u0430\u0446\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u0440\u0430\u0434\u043E\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0430\u0434\u043F\u0430\u0432\u044F\u0434\u0430\u0446\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043B\u0456\u043A: \u043F\u0430\u0432\u0456\u043D\u0435\u043D \u0431\u044B\u0446\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u0430\u0437\u043D\u0430\u043D\u044B ${r.keys.length>1?"\u043A\u043B\u044E\u0447\u044B":"\u043A\u043B\u044E\u0447"}: ${G(r.keys,", ")}`;case"invalid_key":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434";case"invalid_element":return`\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u0430\u0435 \u0437\u043D\u0430\u0447\u044D\u043D\u043D\u0435 \u045E ${r.origin}`;default:return"\u041D\u044F\u043F\u0440\u0430\u0432\u0456\u043B\u044C\u043D\u044B \u045E\u0432\u043E\u0434"}}};function wT(){return{localeError:PA()}}var SA=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},file:{unit:"\u0431\u0430\u0439\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"},map:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430",verb:"\u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0445\u043E\u0434",email:"\u0438\u043C\u0435\u0439\u043B \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0436\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u043F\u0440\u043E\u0434\u044A\u043B\u0436\u0438\u0442\u0435\u043B\u043D\u043E\u0441\u0442",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",mac:"MAC \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"base64-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",base64url:"base64url-\u043A\u043E\u0434\u0438\u0440\u0430\u043D \u043D\u0438\u0437",json_string:"JSON \u043D\u0438\u0437",e164:"E.164 \u043D\u043E\u043C\u0435\u0440",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043D\u0430 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u0430 \u043A\u0430\u0440\u0442\u0430",currency_code:"\u043A\u043E\u0434 \u043D\u0430 \u0432\u0430\u043B\u0443\u0442\u0430",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0445\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D instanceof ${r.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D ${s}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434: \u043E\u0447\u0430\u043A\u0432\u0430\u043D ${ge(r.values[0])}`:`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u043E\u043F\u0446\u0438\u044F: \u043E\u0447\u0430\u043A\u0432\u0430\u043D\u043E \u0435\u0434\u043D\u043E \u043E\u0442 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${r.maximum.toString()} ${a.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0430"}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u0433\u043E\u043B\u044F\u043C\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin??"\u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442"} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin} \u0434\u0430 \u0441\u044A\u0434\u044A\u0440\u0436\u0430 ${o}${r.minimum.toString()} ${a.unit}`:`\u0422\u0432\u044A\u0440\u0434\u0435 \u043C\u0430\u043B\u043A\u043E: \u043E\u0447\u0430\u043A\u0432\u0430 \u0441\u0435 ${r.origin} \u0434\u0430 \u0431\u044A\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;if(o.format==="starts_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u0432\u0430 \u0441 "${o.prefix}"`;if(o.format==="ends_with")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0437\u0430\u0432\u044A\u0440\u0448\u0432\u0430 \u0441 "${o.suffix}"`;if(o.format==="includes")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0432\u043A\u043B\u044E\u0447\u0432\u0430 "${o.includes}"`;if(o.format==="regex")return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043D\u0438\u0437: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0441\u044A\u0432\u043F\u0430\u0434\u0430 \u0441 ${o.pattern}`;let a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D";return o.format==="emoji"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="datetime"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="date"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),o.format==="time"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E"),o.format==="duration"&&(a="\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430"),`${a} ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u043E \u0447\u0438\u0441\u043B\u043E: \u0442\u0440\u044F\u0431\u0432\u0430 \u0434\u0430 \u0431\u044A\u0434\u0435 \u043A\u0440\u0430\u0442\u043D\u043E \u043D\u0430 ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0437\u043F\u043E\u0437\u043D\u0430\u0442${r.keys.length>1?"\u0438":""} \u043A\u043B\u044E\u0447${r.keys.length>1?"\u043E\u0432\u0435":""}: ${G(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u043A\u043B\u044E\u0447 \u0432 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434";case"invalid_element":return`\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u043D\u0430 \u0441\u0442\u043E\u0439\u043D\u043E\u0441\u0442 \u0432 ${r.origin}`;default:return"\u041D\u0435\u0432\u0430\u043B\u0438\u0434\u0435\u043D \u0432\u0445\u043E\u0434"}}};function xT(){return{localeError:SA()}}var kA=()=>{let e={string:{unit:"\u0985\u0995\u09CD\u09B7\u09B0",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},file:{unit:"\u09AC\u09BE\u0987\u099F",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},array:{unit:"\u0986\u0987\u099F\u09C7\u09AE",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},set:{unit:"\u0986\u0987\u099F\u09C7\u09AE",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"},map:{unit:"\u098F\u09A8\u09CD\u099F\u09CD\u09B0\u09BF",verb:"\u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7"}};function t(r){return e[r]??null}let n={regex:"\u0987\u09A8\u09AA\u09C1\u099F",email:"\u0987\u09AE\u09C7\u0987\u09B2 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",url:"URL",emoji:"\u0987\u09AE\u09CB\u099C\u09BF",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u09A4\u09BE\u09B0\u09BF\u0996 \u0993 \u09B8\u09AE\u09AF\u09BC",date:"ISO \u09A4\u09BE\u09B0\u09BF\u0996",time:"ISO \u09B8\u09AE\u09AF\u09BC",duration:"ISO \u09B8\u09AE\u09AF\u09BC\u0995\u09BE\u09B2",ipv4:"IPv4 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",ipv6:"IPv6 \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",mac:"MAC \u09A0\u09BF\u0995\u09BE\u09A8\u09BE",cidrv4:"IPv4 \u09B0\u09C7\u099E\u09CD\u099C",cidrv6:"IPv6 \u09B0\u09C7\u099E\u09CD\u099C",base64:"base64-\u098F\u09A8\u0995\u09CB\u09A1\u09C7\u09A1 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",base64url:"base64url-\u098F\u09A8\u0995\u09CB\u09A1\u09C7\u09A1 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",json_string:"JSON \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982",e164:"E.164 \u09A8\u09AE\u09CD\u09AC\u09B0",credit_card:"\u0995\u09CD\u09B0\u09C7\u09A1\u09BF\u099F \u0995\u09BE\u09B0\u09CD\u09A1 \u09A8\u09AE\u09CD\u09AC\u09B0",currency_code:"\u09AE\u09C1\u09A6\u09CD\u09B0\u09BE \u0995\u09CB\u09A1",iban:"IBAN",jwt:"JWT",template_literal:"\u0987\u09A8\u09AA\u09C1\u099F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return`\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F: \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${o}, \u09AA\u09CD\u09B0\u09BE\u09AA\u09CD\u09A4 ${s}`}case"invalid_value":return r.values.length===1?`\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F: \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${ge(r.values[0])}`:`\u0985\u09AC\u09C8\u09A7 \u0985\u09AA\u09B6\u09A8: ${G(r.values," | ")} \u098F\u09B0 \u09AE\u09A7\u09CD\u09AF\u09C7 \u098F\u0995\u099F\u09BF \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0985\u09A8\u09C7\u0995 \u09AC\u09A1\u09BC: ${r.origin??"\u09AE\u09BE\u09A8"} ${o}${r.maximum.toString()} ${a.unit??"\u098F\u09B2\u09BF\u09AE\u09C7\u09A8\u09CD\u099F"} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09A8\u09C7\u0995 \u09AC\u09A1\u09BC: ${r.origin??"\u09AE\u09BE\u09A8"} ${o}${r.maximum.toString()} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0985\u09A8\u09C7\u0995 \u099B\u09CB\u099F: ${r.origin} ${o}${r.minimum.toString()} ${a.unit} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09A8\u09C7\u0995 \u099B\u09CB\u099F: ${r.origin} ${o}${r.minimum.toString()} \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${o.prefix}" \u09A6\u09BF\u09AF\u09BC\u09C7 \u09B6\u09C1\u09B0\u09C1 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:o.format==="ends_with"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${o.suffix}" \u09A6\u09BF\u09AF\u09BC\u09C7 \u09B6\u09C7\u09B7 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`:o.format==="includes"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: "${o.includes}" \u0985\u09A8\u09CD\u09A4\u09B0\u09CD\u09AD\u09C1\u0995\u09CD\u09A4 \u09A5\u09BE\u0995\u09A4\u09C7 \u09B9\u09AC\u09C7`:o.format==="regex"?`\u0985\u09AC\u09C8\u09A7 \u09B8\u09CD\u099F\u09CD\u09B0\u09BF\u0982: ${o.pattern} \u09AA\u09CD\u09AF\u09BE\u099F\u09BE\u09B0\u09CD\u09A8 \u09AE\u09BF\u09B2\u09A4\u09C7 \u09B9\u09AC\u09C7`:`\u0985\u09AC\u09C8\u09A7 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0985\u09AC\u09C8\u09A7 \u09A8\u09AE\u09CD\u09AC\u09B0: ${r.divisor} \u098F\u09B0 \u0997\u09C1\u09A3\u09BF\u09A4\u0995 \u09B9\u09A4\u09C7 \u09B9\u09AC\u09C7`;case"unrecognized_keys":return`\u0985\u099A\u09C7\u09A8\u09BE \u0995\u09C0${r.keys.length>1?"\u0997\u09C1\u09B2\u09CB":""}: ${G(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u098F \u0985\u09AC\u09C8\u09A7 \u0995\u09C0`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0985\u09AC\u09C8\u09A7 \u09A1\u09BF\u09B8\u0995\u09CD\u09B0\u09BF\u09AE\u09BF\u09A8\u09C7\u099F\u09B0 \u09AE\u09BE\u09A8\u0964 \u09AA\u09CD\u09B0\u09A4\u09CD\u09AF\u09BE\u09B6\u09BF\u09A4 ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F";case"invalid_element":return`${r.origin} \u098F \u0985\u09AC\u09C8\u09A7 \u09AE\u09BE\u09A8`;default:return"\u0985\u09AC\u09C8\u09A7 \u0987\u09A8\u09AA\u09C1\u099F"}}};function PT(){return{localeError:kA()}}var TA=()=>{let e={string:{unit:"car\xE0cters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"},map:{unit:"elements",verb:"contenir"}};function t(r){return e[r]??null}let n={regex:"entrada",email:"adre\xE7a electr\xF2nica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adre\xE7a IPv4",ipv6:"adre\xE7a IPv6",mac:"adre\xE7a MAC",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"n\xFAmero E.164",credit_card:"n\xFAmero de targeta de cr\xE8dit",currency_code:"codi de moneda",iban:"IBAN",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Tipus inv\xE0lid: s'esperava instanceof ${r.expected}, s'ha rebut ${s}`:`Tipus inv\xE0lid: s'esperava ${o}, s'ha rebut ${s}`}case"invalid_value":return r.values.length===1?`Valor inv\xE0lid: s'esperava ${ge(r.values[0])}`:`Opci\xF3 inv\xE0lida: s'esperava una de ${G(r.values," o ")}`;case"too_big":{let o=r.inclusive?"com a m\xE0xim":"menys de",a=t(r.origin);return a?`Massa gran: s'esperava que ${r.origin??"el valor"} contingu\xE9s ${o} ${r.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${r.origin??"el valor"} fos ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"com a m\xEDnim":"m\xE9s de",a=t(r.origin);return a?`Massa petit: s'esperava que ${r.origin} contingu\xE9s ${o} ${r.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${r.origin} fos ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Format inv\xE0lid: ha de comen\xE7ar amb "${o.prefix}"`:o.format==="ends_with"?`Format inv\xE0lid: ha d'acabar amb "${o.suffix}"`:o.format==="includes"?`Format inv\xE0lid: ha d'incloure "${o.includes}"`:o.format==="regex"?`Format inv\xE0lid: ha de coincidir amb el patr\xF3 ${o.pattern}`:`Format inv\xE0lid per a ${n[o.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE0lid: ha de ser m\xFAltiple de ${r.divisor}`;case"unrecognized_keys":return`Clau${r.keys.length>1?"s":""} no reconeguda${r.keys.length>1?"s":""}: ${G(r.keys,", ")}`;case"invalid_key":return`Clau inv\xE0lida a ${r.origin}`;case"invalid_union":return"Entrada inv\xE0lida";case"invalid_element":return`Element inv\xE0lid a ${r.origin}`;default:return"Entrada inv\xE0lida"}}};function ST(){return{localeError:TA()}}var zA=()=>{let e={string:{unit:"\u067E\u06CC\u062A",verb:"\u0628\u06CE\u062A"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u0628\u06CE\u062A"},array:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"},set:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"},map:{unit:"\u062F\u0627\u0646\u06D5",verb:"\u0628\u06CE\u062A"}};function t(r){return e[r]??null}let n={regex:"regex",email:"\u0626\u06CC\u0645\u06D5\u06CC\u06B5",url:"\u0628\u06D5\u0633\u062A\u06D5\u0631 (URL)",emoji:"\u0626\u06CC\u0645\u06C6\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0695\u06CE\u06A9\u06D5\u0648\u062A \u0648 \u06A9\u0627\u062A",date:"\u0695\u06CE\u06A9\u06D5\u0648\u062A",time:"\u06A9\u0627\u062A",duration:"\u0645\u0627\u0648\u06D5",ipv4:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC IPv4",ipv6:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC IPv6",mac:"\u0646\u0627\u0648\u0646\u06CC\u0634\u0627\u0646\u06CC MAC",cidrv4:"\u0645\u06D5\u0648\u062F\u0627\u06CC IPv4",cidrv6:"\u0645\u06D5\u0648\u062F\u0627\u06CC IPv6",base64:"\u062F\u06D5\u0642\u06CC base64",base64url:"\u062F\u06D5\u0642\u06CC base64url",json_string:"\u062F\u06D5\u0642\u06CC JSON",e164:"\u0698\u0645\u0627\u0631\u06D5\u06CC E.164",credit_card:"\u0698\u0645\u0627\u0631\u06D5\u06CC \u06A9\u0627\u0631\u062A\u06CC \u06A9\u0631\u06CE\u062F\u06CC\u062A",currency_code:"\u06A9\u06C6\u062F\u06CC \u062F\u0631\u0627\u0648",iban:"IBAN",jwt:"JWT",template_literal:"\u062A\u06CE\u06A9\u0631\u062F\u06D5"},i={nan:"NaN",string:"\u0646\u0648\u0648\u0633\u06CC\u0646",number:"\u0698\u0645\u0627\u0631\u06D5",boolean:"boolean",array:"array",object:"object",date:"\u0695\u06CE\u06A9\u06D5\u0648\u062A",integer:"\u0698\u0645\u0627\u0631\u06D5",float:"\u0698\u0645\u0627\u0631\u06D5",null:"null",undefined:"undefined",function:"function",symbol:"symbol",unknown:"unknown",promise:"promise",void:"void",never:"never",map:"map",set:"set"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a,c=["\u0627","\u0648","\u06C6","\u0648\u0648","\u06D5","\u06CC","\u06CE"].some(u=>s.endsWith(u))?"\u06CC\u06D5":"\u06D5",l=/^[a-zA-Z]+$/.test(s);return a==="null"||a==="undefined"?"\u062F\u0627\u0648\u0627\u06A9\u0631\u0627\u0648\u06D5":`\u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 ${o} \u0628\u06CE\u062A\u060C \u0628\u06D5\u06B5\u0627\u0645 ${s}${l?"":c}`}case"invalid_value":return r.values.length===1?`\u0628\u06D5\u0647\u0627\u06A9\u06D5 \u0646\u0627\u062F\u0631\u0648\u0648\u0633\u062A\u06D5: \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 ${ge(r.values[0])} \u0628\u06CE\u062A`:`\u0647\u06D5\u06B5\u0628\u0698\u0627\u0631\u062F\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648\u06D5 \u06CC\u06D5\u06A9\u06CE\u06A9 \u0628\u06CE\u062A \u0644\u06D5 ${G(r.values,"|")}`;case"too_big":{let o=t(r.origin);return o?`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u0632\u06C6\u0631\u06D5\u0648\u06D5 ${r.maximum.toString()} ${o.unit} ${o.verb}`:`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u0632\u06C6\u0631\u06D5\u0648\u06D5 ${r.maximum.toString()} \u0628\u06CE\u062A`}case"too_small":{let o=t(r.origin);return o?`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u06A9\u06D5\u0645\u06D5\u0648\u06D5 ${r.minimum.toString()} ${o.unit} ${o.verb}`:`\u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0628\u06D5 \u0644\u0627\u06CC\u06D5\u0646\u06CC \u06A9\u06D5\u0645\u06D5\u0648\u06D5 ${r.minimum.toString()} \u0628\u06CE\u062A`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u062F\u06D5\u0633\u062A\u067E\u06CE\u0628\u06A9\u0627\u062A \u0628\u06D5 "${o.prefix}"`:o.format==="ends_with"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u06A9\u06C6\u062A\u0627\u06CC\u06CC\u0628\u06CE\u062A \u0628\u06D5 "${o.suffix}"`:o.format==="includes"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 "${o.includes}" \u0644\u06D5\u062E\u06C6\u0628\u06AF\u0631\u06CE\u062A`:o.format==="regex"?`\u062F\u06D5\u0642\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u067E\u06CE\u0648\u06CC\u0633\u062A\u06D5 \u0644\u06D5\u06AF\u06D5\u06B5 \u067E\u0627\u062A\u06CE\u0631\u0646\u06CC ${o.pattern} \u0628\u06AF\u0648\u0646\u062C\u06CE\u062A`:`\u0628\u06D5\u0647\u0627\u06CC ${n[o.format]??r.format} \u0646\u0627\u062F\u0631\u0648\u0633\u062A\u06D5`}case"not_multiple_of":return`\u0698\u0645\u0627\u0631\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A: \u062F\u06D5\u0628\u06CE\u062A \u0686\u06D5\u0646\u062F \u0647\u06CE\u0646\u062F\u06D5 \u0628\u06CE\u062A \u0628\u06C6 ${r.divisor}`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u0644\u06CC \u0646\u06D5\u0646\u0627\u0633\u0631\u0627\u0648: ${G(r.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u0644\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A \u0644\u06D5 ${r.origin}`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0628\u06D5\u0647\u0627\u06CC \u0646\u06D5\u0646\u0627\u0633\u0631\u0627\u0648 \u0647\u06D5\u06CC\u06D5. \u0628\u06D5\u0647\u0627\u06CC \u0686\u0627\u0648\u06D5\u0695\u0648\u0627\u0646\u06A9\u0631\u0627\u0648: ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u06CC\u06D5\u06A9\u06AF\u0631\u062A\u0646\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A";case"invalid_element":return`${r.origin} \u0628\u06D5\u0647\u0627\u06A9\u06D5 \u0646\u0627\u062F\u0631\u0648\u0633\u062A\u06D5`;default:return"\u062A\u06CE\u06A9\u0631\u062F\u06D5\u06CC \u0646\u0627\u062F\u0631\u0648\u0633\u062A"}}};function kT(){return{localeError:zA()}}var MA=()=>{let e={string:{unit:"znak\u016F",verb:"m\xEDt"},file:{unit:"bajt\u016F",verb:"m\xEDt"},array:{unit:"prvk\u016F",verb:"m\xEDt"},set:{unit:"prvk\u016F",verb:"m\xEDt"},map:{unit:"prvk\u016F",verb:"m\xEDt"}};function t(r){return e[r]??null}let n={regex:"regul\xE1rn\xED v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a \u010Das ve form\xE1tu ISO",date:"datum ve form\xE1tu ISO",time:"\u010Das ve form\xE1tu ISO",duration:"doba trv\xE1n\xED ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64",base64url:"\u0159et\u011Bzec zak\xF3dovan\xFD ve form\xE1tu base64url",json_string:"\u0159et\u011Bzec ve form\xE1tu JSON",e164:"\u010D\xEDslo E.164",credit_card:"\u010D\xEDslo kreditn\xED karty",currency_code:"k\xF3d m\u011Bny",iban:"IBAN",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"\u0159et\u011Bzec",function:"funkce",array:"pole"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no instanceof ${r.expected}, obdr\u017Eeno ${s}`:`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${o}, obdr\u017Eeno ${s}`}case"invalid_value":return r.values.length===1?`Neplatn\xFD vstup: o\u010Dek\xE1v\xE1no ${ge(r.values[0])}`:`Neplatn\xE1 mo\u017Enost: o\u010Dek\xE1v\xE1na jedna z hodnot ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${o}${r.maximum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 velk\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED m\xEDt ${o}${r.minimum.toString()} ${a.unit??"prvk\u016F"}`:`Hodnota je p\u0159\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED b\xFDt ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED za\u010D\xEDnat na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED kon\u010Dit na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED obsahovat "${o.includes}"`:o.format==="regex"?`Neplatn\xFD \u0159et\u011Bzec: mus\xED odpov\xEDdat vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${n[o.format]??r.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED b\xFDt n\xE1sobkem ${r.divisor}`;case"unrecognized_keys":return`Nezn\xE1m\xE9 kl\xED\u010De: ${G(r.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xED\u010D v ${r.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${r.origin}`;default:return"Neplatn\xFD vstup"}}};function TT(){return{localeError:MA()}}var OA=()=>{let e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"},map:{unit:"elementer",verb:"indeholdt"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkesl\xE6t",date:"ISO-dato",time:"ISO-klokkesl\xE6t",duration:"ISO-varighed",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kreditkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"s\xE6t",file:"fil"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ugyldigt input: forventede instanceof ${r.expected}, fik ${s}`:`Ugyldigt input: forventede ${o}, fik ${s}`}case"invalid_value":return r.values.length===1?`Ugyldig v\xE6rdi: forventede ${ge(r.values[0])}`:`Ugyldigt valg: forventede en af f\xF8lgende ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin),s=i[r.origin]??r.origin;return a?`For stor: forventede ${s??"value"} ${a.verb} ${o} ${r.maximum.toString()} ${a.unit??"elementer"}`:`For stor: forventede ${s??"value"} havde ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin),s=i[r.origin]??r.origin;return a?`For lille: forventede ${s} ${a.verb} ${o} ${r.minimum.toString()} ${a.unit}`:`For lille: forventede ${s} havde ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ugyldig streng: skal starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: skal ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: skal indeholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: skal matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${n[o.format]??r.format}`}case"not_multiple_of":return`Ugyldigt tal: skal v\xE6re deleligt med ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukendte n\xF8gler":"Ukendt n\xF8gle"}: ${G(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8gle i ${r.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig v\xE6rdi i ${r.origin}`;default:return"Ugyldigt input"}}};function zT(){return{localeError:OA()}}var LA=()=>{let e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"},map:{unit:"Elemente",verb:"zu haben"}};function t(r){return e[r]??null}let n={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",mac:"MAC-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",credit_card:"Kreditkartennummer",currency_code:"W\xE4hrungscode",iban:"IBAN",jwt:"JWT",template_literal:"Eingabe"},i={nan:"NaN",number:"Zahl",array:"Array"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ung\xFCltige Eingabe: erwartet instanceof ${r.expected}, erhalten ${s}`:`Ung\xFCltige Eingabe: erwartet ${o}, erhalten ${s}`}case"invalid_value":return r.values.length===1?`Ung\xFCltige Eingabe: erwartet ${ge(r.values[0])}`:`Ung\xFCltige Option: erwartet eine von ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${o}${r.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu gro\xDF: erwartet, dass ${r.origin??"Wert"} ${o}${r.maximum.toString()} ist`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Zu klein: erwartet, dass ${r.origin} ${o}${r.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${r.origin} ${o}${r.minimum.toString()} ist`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ung\xFCltiger String: muss mit "${o.prefix}" beginnen`:o.format==="ends_with"?`Ung\xFCltiger String: muss mit "${o.suffix}" enden`:o.format==="includes"?`Ung\xFCltiger String: muss "${o.includes}" enthalten`:o.format==="regex"?`Ung\xFCltiger String: muss dem Muster ${o.pattern} entsprechen`:`Ung\xFCltig: ${n[o.format]??r.format}`}case"not_multiple_of":return`Ung\xFCltige Zahl: muss ein Vielfaches von ${r.divisor} sein`;case"unrecognized_keys":return`${r.keys.length>1?"Unbekannte Schl\xFCssel":"Unbekannter Schl\xFCssel"}: ${G(r.keys,", ")}`;case"invalid_key":return`Ung\xFCltiger Schl\xFCssel in ${r.origin}`;case"invalid_union":return"Ung\xFCltige Eingabe";case"invalid_element":return`Ung\xFCltiger Wert in ${r.origin}`;default:return"Ung\xFCltige Eingabe"}}};function MT(){return{localeError:LA()}}var XA=()=>{let e={string:{unit:"\u03C7\u03B1\u03C1\u03B1\u03BA\u03C4\u03AE\u03C1\u03B5\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},file:{unit:"bytes",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},array:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},set:{unit:"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"},map:{unit:"\u03BA\u03B1\u03C4\u03B1\u03C7\u03C9\u03C1\u03AE\u03C3\u03B5\u03B9\u03C2",verb:"\u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9"}};function t(r){return e[r]??null}let n={regex:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2",email:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1 \u03BA\u03B1\u03B9 \u03CE\u03C1\u03B1",date:"ISO \u03B7\u03BC\u03B5\u03C1\u03BF\u03BC\u03B7\u03BD\u03AF\u03B1",time:"ISO \u03CE\u03C1\u03B1",duration:"ISO \u03B4\u03B9\u03AC\u03C1\u03BA\u03B5\u03B9\u03B1",ipv4:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv4",ipv6:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 IPv6",mac:"\u03B4\u03B9\u03B5\u03CD\u03B8\u03C5\u03BD\u03C3\u03B7 MAC",cidrv4:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv4",cidrv6:"\u03B5\u03CD\u03C1\u03BF\u03C2 IPv6",base64:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64",base64url:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC \u03BA\u03C9\u03B4\u03B9\u03BA\u03BF\u03C0\u03BF\u03B9\u03B7\u03BC\u03AD\u03BD\u03B7 \u03C3\u03B5 base64url",json_string:"\u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC JSON",e164:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 E.164",credit_card:"\u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2 \u03C0\u03B9\u03C3\u03C4\u03C9\u03C4\u03B9\u03BA\u03AE\u03C2 \u03BA\u03AC\u03C1\u03C4\u03B1\u03C2",currency_code:"\u03BA\u03C9\u03B4\u03B9\u03BA\u03CC\u03C2 \u03BD\u03BF\u03BC\u03AF\u03C3\u03BC\u03B1\u03C4\u03BF\u03C2",iban:"IBAN",jwt:"JWT",template_literal:"\u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return typeof r.expected=="string"&&/^[A-Z]/.test(r.expected)?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD instanceof ${r.expected}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${o}, \u03BB\u03AE\u03C6\u03B8\u03B7\u03BA\u03B5 ${s}`}case"invalid_value":return r.values.length===1?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${ge(r.values[0])}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03C0\u03B9\u03BB\u03BF\u03B3\u03AE: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD \u03AD\u03BD\u03B1 \u03B1\u03C0\u03CC ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${r.maximum.toString()} ${a.unit??"\u03C3\u03C4\u03BF\u03B9\u03C7\u03B5\u03AF\u03B1"}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B5\u03B3\u03AC\u03BB\u03BF: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin??"\u03C4\u03B9\u03BC\u03AE"} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin} \u03BD\u03B1 \u03AD\u03C7\u03B5\u03B9 ${o}${r.minimum.toString()} ${a.unit}`:`\u03A0\u03BF\u03BB\u03CD \u03BC\u03B9\u03BA\u03C1\u03CC: \u03B1\u03BD\u03B1\u03BC\u03B5\u03BD\u03CC\u03C4\u03B1\u03BD ${r.origin} \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03BE\u03B5\u03BA\u03B9\u03BD\u03AC \u03BC\u03B5 "${o.prefix}"`:o.format==="ends_with"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B5\u03BB\u03B5\u03B9\u03CE\u03BD\u03B5\u03B9 \u03BC\u03B5 "${o.suffix}"`:o.format==="includes"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C0\u03B5\u03C1\u03B9\u03AD\u03C7\u03B5\u03B9 "${o.includes}"`:o.format==="regex"?`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C3\u03C5\u03BC\u03B2\u03BF\u03BB\u03BF\u03C3\u03B5\u03B9\u03C1\u03AC: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03C4\u03B1\u03B9\u03C1\u03B9\u03AC\u03B6\u03B5\u03B9 \u03BC\u03B5 \u03C4\u03BF \u03BC\u03BF\u03C4\u03AF\u03B2\u03BF ${o.pattern}`:`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF: ${n[o.format]??r.format}`}case"not_multiple_of":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF\u03C2 \u03B1\u03C1\u03B9\u03B8\u03BC\u03CC\u03C2: \u03C0\u03C1\u03AD\u03C0\u03B5\u03B9 \u03BD\u03B1 \u03B5\u03AF\u03BD\u03B1\u03B9 \u03C0\u03BF\u03BB\u03BB\u03B1\u03C0\u03BB\u03AC\u03C3\u03B9\u03BF \u03C4\u03BF\u03C5 ${r.divisor}`;case"unrecognized_keys":return`\u0386\u03B3\u03BD\u03C9\u03C3\u03C4${r.keys.length>1?"\u03B1":"\u03BF"} \u03BA\u03BB\u03B5\u03B9\u03B4${r.keys.length>1?"\u03B9\u03AC":"\u03AF"}: ${G(r.keys,", ")}`;case"invalid_key":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03BF \u03BA\u03BB\u03B5\u03B9\u03B4\u03AF \u03C3\u03C4\u03BF ${r.origin}`;case"invalid_union":return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2";case"invalid_element":return`\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03C4\u03B9\u03BC\u03AE \u03C3\u03C4\u03BF ${r.origin}`;default:return"\u039C\u03B7 \u03AD\u03B3\u03BA\u03C5\u03C1\u03B7 \u03B5\u03AF\u03C3\u03BF\u03B4\u03BF\u03C2"}}};function OT(){return{localeError:XA()}}var NA=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}let n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};function r(o,a){return o==="number"&&typeof a=="number"&&!Number.isFinite(a)?String(a):i[o]??o}return o=>{switch(o.code){case"invalid_type":{let a=r(o.expected),s=ye(o.input),c=r(s,o.input);return`Invalid input: expected ${a}, received ${c}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${ge(o.values[0])}`:`Invalid option: expected one of ${G(o.values,"|")}`;case"too_big":{let a=o.exact?"exactly ":o.inclusive?"<=":"<",s=t(o.origin);return s?`Too big: expected ${o.origin??"value"} to have ${a}${o.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${a}${o.maximum.toString()}`}case"too_small":{let a=o.exact?"exactly ":o.inclusive?">=":">",s=t(o.origin);return s?`Too small: expected ${o.origin} to have ${a}${o.minimum.toString()} ${s.unit}`:`Too small: expected ${o.origin} to be ${a}${o.minimum.toString()}`}case"invalid_format":{let a=o;return a.format==="starts_with"?`Invalid string: must start with "${a.prefix}"`:a.format==="ends_with"?`Invalid string: must end with "${a.suffix}"`:a.format==="includes"?`Invalid string: must include "${a.includes}"`:a.format==="regex"?`Invalid string: must match pattern ${a.pattern}`:`Invalid ${n[a.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${G(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(s=>`'${s}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function Ih(){return{localeError:NA()}}var RA=()=>{let e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"},map:{unit:"elementojn",verb:"havi"}};function t(r){return e[r]??null}let n={regex:"enigo",email:"retadreso",url:"URL",emoji:"emo\u011Dio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-da\u016Dro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",mac:"MAC-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",credit_card:"kreditkarta numero",currency_code:"valuta kodo",iban:"IBAN",jwt:"JWT",template_literal:"enigo"},i={nan:"NaN",number:"nombro",array:"tabelo",null:"senvalora"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Nevalida enigo: atendi\u011Dis instanceof ${r.expected}, ricevi\u011Dis ${s}`:`Nevalida enigo: atendi\u011Dis ${o}, ricevi\u011Dis ${s}`}case"invalid_value":return r.values.length===1?`Nevalida enigo: atendi\u011Dis ${ge(r.values[0])}`:`Nevalida opcio: atendi\u011Dis unu el ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Tro granda: atendi\u011Dis ke ${r.origin??"valoro"} havu ${o}${r.maximum.toString()} ${a.unit??"elementojn"}`:`Tro granda: atendi\u011Dis ke ${r.origin??"valoro"} havu ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Tro malgranda: atendi\u011Dis ke ${r.origin} havu ${o}${r.minimum.toString()} ${a.unit}`:`Tro malgranda: atendi\u011Dis ke ${r.origin} estu ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Nevalida karaktraro: devas komenci\u011Di per "${o.prefix}"`:o.format==="ends_with"?`Nevalida karaktraro: devas fini\u011Di per "${o.suffix}"`:o.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${o.includes}"`:o.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${o.pattern}`:`Nevalida ${n[o.format]??r.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${r.divisor}`;case"unrecognized_keys":return`Nekonata${r.keys.length>1?"j":""} \u015Dlosilo${r.keys.length>1?"j":""}: ${G(r.keys,", ")}`;case"invalid_key":return`Nevalida \u015Dlosilo en ${r.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${r.origin}`;default:return"Nevalida enigo"}}};function LT(){return{localeError:RA()}}var FA=()=>{let e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}};function t(r){return e[r]??null}let n={regex:"entrada",email:"direcci\xF3n de correo electr\xF3nico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duraci\xF3n ISO",ipv4:"direcci\xF3n IPv4",ipv6:"direcci\xF3n IPv6",mac:"direcci\xF3n MAC",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"n\xFAmero E.164",credit_card:"n\xFAmero de tarjeta de cr\xE9dito",currency_code:"c\xF3digo de moneda",iban:"IBAN",jwt:"JWT",template_literal:"entrada"},i={nan:"NaN",string:"texto",number:"n\xFAmero",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"n\xFAmero grande",symbol:"s\xEDmbolo",undefined:"indefinido",null:"nulo",function:"funci\xF3n",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeraci\xF3n",union:"uni\xF3n",literal:"literal",promise:"promesa",void:"vac\xEDo",never:"nunca",unknown:"desconocido",any:"cualquiera"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Entrada inv\xE1lida: se esperaba instanceof ${r.expected}, recibido ${s}`:`Entrada inv\xE1lida: se esperaba ${o}, recibido ${s}`}case"invalid_value":return r.values.length===1?`Entrada inv\xE1lida: se esperaba ${ge(r.values[0])}`:`Opci\xF3n inv\xE1lida: se esperaba una de ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin),s=i[r.origin]??r.origin;return a?`Demasiado grande: se esperaba que ${s??"valor"} tuviera ${o}${r.maximum.toString()} ${a.unit??"elementos"}`:`Demasiado grande: se esperaba que ${s??"valor"} fuera ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin),s=i[r.origin]??r.origin;return a?`Demasiado peque\xF1o: se esperaba que ${s} tuviera ${o}${r.minimum.toString()} ${a.unit}`:`Demasiado peque\xF1o: se esperaba que ${s} fuera ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cadena inv\xE1lida: debe comenzar con "${o.prefix}"`:o.format==="ends_with"?`Cadena inv\xE1lida: debe terminar en "${o.suffix}"`:o.format==="includes"?`Cadena inv\xE1lida: debe incluir "${o.includes}"`:o.format==="regex"?`Cadena inv\xE1lida: debe coincidir con el patr\xF3n ${o.pattern}`:`Inv\xE1lido ${n[o.format]??r.format}`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: debe ser m\xFAltiplo de ${r.divisor}`;case"unrecognized_keys":return`Llave${r.keys.length>1?"s":""} desconocida${r.keys.length>1?"s":""}: ${G(r.keys,", ")}`;case"invalid_key":return`Llave inv\xE1lida en ${i[r.origin]??r.origin}`;case"invalid_union":return"Entrada inv\xE1lida";case"invalid_element":return`Valor inv\xE1lido en ${i[r.origin]??r.origin}`;default:return"Entrada inv\xE1lida"}}};function XT(){return{localeError:FA()}}var VA=()=>{let e={string:{unit:"\u06A9\u0627\u0631\u0627\u06A9\u062A\u0631",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},file:{unit:"\u0628\u0627\u06CC\u062A",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},array:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},set:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"},map:{unit:"\u0622\u06CC\u062A\u0645",verb:"\u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F"}};function t(r){return e[r]??null}let n={regex:"\u0648\u0631\u0648\u062F\u06CC",email:"\u0622\u062F\u0631\u0633 \u0627\u06CC\u0645\u06CC\u0644",url:"URL",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u062A\u0627\u0631\u06CC\u062E \u0648 \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",date:"\u062A\u0627\u0631\u06CC\u062E \u0627\u06CC\u0632\u0648",time:"\u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",duration:"\u0645\u062F\u062A \u0632\u0645\u0627\u0646 \u0627\u06CC\u0632\u0648",ipv4:"IPv4 \u0622\u062F\u0631\u0633",ipv6:"IPv6 \u0622\u062F\u0631\u0633",mac:"MAC \u0622\u062F\u0631\u0633",cidrv4:"IPv4 \u062F\u0627\u0645\u0646\u0647",cidrv6:"IPv6 \u062F\u0627\u0645\u0646\u0647",base64:"base64-encoded \u0631\u0634\u062A\u0647",base64url:"base64url-encoded \u0631\u0634\u062A\u0647",json_string:"JSON \u0631\u0634\u062A\u0647",e164:"E.164 \u0639\u062F\u062F",credit_card:"\u0634\u0645\u0627\u0631\u0647 \u06A9\u0627\u0631\u062A \u0627\u0639\u062A\u0628\u0627\u0631\u06CC",currency_code:"\u06A9\u062F \u0627\u0631\u0632",iban:"IBAN",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u06CC"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0622\u0631\u0627\u06CC\u0647"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A instanceof ${r.expected} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`:`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${o} \u0645\u06CC\u200C\u0628\u0648\u062F\u060C ${s} \u062F\u0631\u06CC\u0627\u0641\u062A \u0634\u062F`}case"invalid_value":return r.values.length===1?`\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A ${ge(r.values[0])} \u0645\u06CC\u200C\u0628\u0648\u062F`:`\u06AF\u0632\u06CC\u0646\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0645\u06CC\u200C\u0628\u0627\u06CC\u0633\u062A \u06CC\u06A9\u06CC \u0627\u0632 ${G(r.values,"|")} \u0645\u06CC\u200C\u0628\u0648\u062F`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631"} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u0628\u0632\u0631\u06AF: ${r.origin??"\u0645\u0642\u062F\u0627\u0631"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} \u0628\u0627\u0634\u062F`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} ${a.unit} \u0628\u0627\u0634\u062F`:`\u062E\u06CC\u0644\u06CC \u06A9\u0648\u0686\u06A9: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} \u0628\u0627\u0634\u062F`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.prefix}" \u0634\u0631\u0648\u0639 \u0634\u0648\u062F`:o.format==="ends_with"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 "${o.suffix}" \u062A\u0645\u0627\u0645 \u0634\u0648\u062F`:o.format==="includes"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0634\u0627\u0645\u0644 "${o.includes}" \u0628\u0627\u0634\u062F`:o.format==="regex"?`\u0631\u0634\u062A\u0647 \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0628\u0627 \u0627\u0644\u06AF\u0648\u06CC ${o.pattern} \u0645\u0637\u0627\u0628\u0642\u062A \u062F\u0627\u0634\u062A\u0647 \u0628\u0627\u0634\u062F`:`${n[o.format]??r.format} \u0646\u0627\u0645\u0639\u062A\u0628\u0631`}case"not_multiple_of":return`\u0639\u062F\u062F \u0646\u0627\u0645\u0639\u062A\u0628\u0631: \u0628\u0627\u06CC\u062F \u0645\u0636\u0631\u0628 ${r.divisor} \u0628\u0627\u0634\u062F`;case"unrecognized_keys":return`\u06A9\u0644\u06CC\u062F${r.keys.length>1?"\u0647\u0627\u06CC":""} \u0646\u0627\u0634\u0646\u0627\u0633: ${G(r.keys,", ")}`;case"invalid_key":return`\u06A9\u0644\u06CC\u062F \u0646\u0627\u0634\u0646\u0627\u0633 \u062F\u0631 ${r.origin}`;case"invalid_union":return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631";case"invalid_element":return`\u0645\u0642\u062F\u0627\u0631 \u0646\u0627\u0645\u0639\u062A\u0628\u0631 \u062F\u0631 ${r.origin}`;default:return"\u0648\u0631\u0648\u062F\u06CC \u0646\u0627\u0645\u0639\u062A\u0628\u0631"}}};function NT(){return{localeError:VA()}}var jA=()=>{let e={string:{unit:"merkki\xE4",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},map:{unit:"alkiota",subject:"kuvauksen"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"p\xE4iv\xE4m\xE4\xE4r\xE4n"}};function t(r){return e[r]??null}let n={regex:"s\xE4\xE4nn\xF6llinen lauseke",email:"s\xE4hk\xF6postiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-p\xE4iv\xE4m\xE4\xE4r\xE4",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",mac:"MAC-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",credit_card:"luottokortin numero",currency_code:"valuuttakoodi",iban:"IBAN",jwt:"JWT",template_literal:"templaattimerkkijono"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Virheellinen tyyppi: odotettiin instanceof ${r.expected}, oli ${s}`:`Virheellinen tyyppi: odotettiin ${o}, oli ${s}`}case"invalid_value":return r.values.length===1?`Virheellinen sy\xF6te: t\xE4ytyy olla ${ge(r.values[0])}`:`Virheellinen valinta: t\xE4ytyy olla yksi seuraavista: ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Liian suuri: ${a.subject} t\xE4ytyy olla ${o}${r.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon t\xE4ytyy olla ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Liian pieni: ${a.subject} t\xE4ytyy olla ${o}${r.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon t\xE4ytyy olla ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Virheellinen sy\xF6te: t\xE4ytyy alkaa "${o.prefix}"`:o.format==="ends_with"?`Virheellinen sy\xF6te: t\xE4ytyy loppua "${o.suffix}"`:o.format==="includes"?`Virheellinen sy\xF6te: t\xE4ytyy sis\xE4lt\xE4\xE4 "${o.includes}"`:o.format==="regex"?`Virheellinen sy\xF6te: t\xE4ytyy vastata s\xE4\xE4nn\xF6llist\xE4 lauseketta ${o.pattern}`:`Virheellinen ${n[o.format]??r.format}`}case"not_multiple_of":return`Virheellinen luku: t\xE4ytyy olla luvun ${r.divisor} monikerta`;case"unrecognized_keys":return`${r.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${G(r.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen sy\xF6te"}}};function RT(){return{localeError:jA()}}var ZA=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n={regex:"expression r\xE9guli\xE8re",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",mac:"adresse MAC",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne de caract\xE8res encod\xE9e en base64",base64url:"cha\xEEne de caract\xE8res encod\xE9e en base64url",json_string:"cha\xEEne de caract\xE8res JSON",e164:"num\xE9ro au format E.164",credit_card:"num\xE9ro de carte de cr\xE9dit",currency_code:"code de devise",iban:"IBAN",jwt:"JWT",template_literal:"entr\xE9e"},i={string:"cha\xEEne de caract\xE8res",number:"nombre",int:"entier",boolean:"bool\xE9en",bigint:"grand entier",symbol:"symbole",undefined:"ind\xE9fini",null:"null",never:"jamais",void:"vide",date:"date",array:"tableau",object:"objet",tuple:"tuple",record:"record",map:"map",set:"ensemble",file:"fichier",nonoptional:"non optionnel",nan:"NaN",function:"fonction"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Entr\xE9e invalide : instance de ${r.expected} attendu, ${s} re\xE7u`:`Entr\xE9e invalide : ${o} attendu, ${s} re\xE7u`}case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : ${ge(r.values[0])} attendu`:`Option invalide : une valeur parmi ${G(r.values,"|")} attendue`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Trop grand : ${i[r.origin]??"valeur"} doit ${a.verb} ${o}${r.maximum.toString()} ${a.unit??"\xE9l\xE9ment(s)"}`:`Trop grand : ${i[r.origin]??"valeur"} doit \xEAtre ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Trop petit : ${i[r.origin]??"valeur"} doit ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`Trop petit : ${i[r.origin]??"valeur"} doit \xEAtre ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cha\xEEne de caract\xE8res invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne de caract\xE8res invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne de caract\xE8res invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne de caract\xE8res invalide : doit correspondre au motif ${o.pattern}`:`${n[o.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${G(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}};function FT(){return{localeError:ZA()}}var IA=()=>{let e={string:{unit:"caract\xE8res",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"\xE9l\xE9ments",verb:"avoir"},set:{unit:"\xE9l\xE9ments",verb:"avoir"},map:{unit:"\xE9l\xE9ments",verb:"avoir"}};function t(r){return e[r]??null}let n={regex:"entr\xE9e",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"dur\xE9e ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",mac:"adresse MAC",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"cha\xEEne encod\xE9e en base64",base64url:"cha\xEEne encod\xE9e en base64url",json_string:"cha\xEEne JSON",e164:"num\xE9ro E.164",credit_card:"num\xE9ro de carte de cr\xE9dit",currency_code:"code de devise",iban:"IBAN",jwt:"JWT",template_literal:"entr\xE9e"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Entr\xE9e invalide : attendu instanceof ${r.expected}, re\xE7u ${s}`:`Entr\xE9e invalide : attendu ${o}, re\xE7u ${s}`}case"invalid_value":return r.values.length===1?`Entr\xE9e invalide : attendu ${ge(r.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"\u2264":"<",a=t(r.origin);return a?`Trop grand : attendu que ${r.origin??"la valeur"} ait ${o}${r.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${r.origin??"la valeur"} soit ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"\u2265":">",a=t(r.origin);return a?`Trop petit : attendu que ${r.origin} ait ${o}${r.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${r.origin} soit ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Cha\xEEne invalide : doit commencer par "${o.prefix}"`:o.format==="ends_with"?`Cha\xEEne invalide : doit se terminer par "${o.suffix}"`:o.format==="includes"?`Cha\xEEne invalide : doit inclure "${o.includes}"`:o.format==="regex"?`Cha\xEEne invalide : doit correspondre au motif ${o.pattern}`:`${n[o.format]??r.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit \xEAtre un multiple de ${r.divisor}`;case"unrecognized_keys":return`Cl\xE9${r.keys.length>1?"s":""} non reconnue${r.keys.length>1?"s":""} : ${G(r.keys,", ")}`;case"invalid_key":return`Cl\xE9 invalide dans ${r.origin}`;case"invalid_union":return"Entr\xE9e invalide";case"invalid_element":return`Valeur invalide dans ${r.origin}`;default:return"Entr\xE9e invalide"}}};function VT(){return{localeError:IA()}}var WA=()=>{let e={string:{unit:"\u0A85\u0A95\u0ACD\u0AB7\u0AB0",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},file:{unit:"\u0AAC\u0ABE\u0AAF\u0A9F",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},array:{unit:"\u0A86\u0A87\u0A9F\u0AAE",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},set:{unit:"\u0A86\u0A87\u0A9F\u0AAE",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"},map:{unit:"\u0A8F\u0AA8\u0ACD\u0A9F\u0ACD\u0AB0\u0AC0",verb:"\u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F"}};function t(r){return e[r]??null}let n={regex:"\u0A87\u0AA8\u0AAA\u0AC1\u0A9F",email:"\u0A88\u0AAE\u0AC7\u0A87\u0AB2 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",url:"URL",emoji:"\u0A87\u0AAE\u0ACB\u0A9C\u0AC0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0AA4\u0ABE\u0AB0\u0AC0\u0A96 \u0A85\u0AA8\u0AC7 \u0AB8\u0AAE\u0AAF",date:"ISO \u0AA4\u0ABE\u0AB0\u0AC0\u0A96",time:"ISO \u0AB8\u0AAE\u0AAF",duration:"ISO \u0A85\u0AB5\u0AA7\u0ABF",ipv4:"IPv4 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",ipv6:"IPv6 \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",mac:"MAC \u0A8F\u0AA1\u0ACD\u0AB0\u0AC7\u0AB8",cidrv4:"IPv4 \u0AB6\u0ACD\u0AB0\u0AC7\u0AA3\u0AC0",cidrv6:"IPv6 \u0AB6\u0ACD\u0AB0\u0AC7\u0AA3\u0AC0",base64:"base64-\u0A8F\u0AA8\u0ACD\u0A95\u0ACB\u0AA1\u0AC7\u0AA1 \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",base64url:"base64url-\u0A8F\u0AA8\u0ACD\u0A95\u0ACB\u0AA1\u0AC7\u0AA1 \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",json_string:"JSON \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97",e164:"E.164 \u0AA8\u0A82\u0AAC\u0AB0",credit_card:"\u0A95\u0ACD\u0AB0\u0AC7\u0AA1\u0ABF\u0A9F \u0A95\u0ABE\u0AB0\u0ACD\u0AA1 \u0AA8\u0A82\u0AAC\u0AB0",currency_code:"\u0A9A\u0AB2\u0AA3 \u0A95\u0ACB\u0AA1",iban:"IBAN",jwt:"JWT",template_literal:"\u0A87\u0AA8\u0AAA\u0AC1\u0A9F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F: \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${o}, \u0AAA\u0ACD\u0AB0\u0ABE\u0AAA\u0ACD\u0AA4 ${s}`}case"invalid_value":return r.values.length===1?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F: \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${ge(r.values[0])}`:`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB5\u0ABF\u0A95\u0AB2\u0ACD\u0AAA: ${G(r.values," | ")} \u0AAE\u0ABE\u0AA7\u0ACD\u0AAF\u0AAE\u0AA5\u0AC0 \u0A8F\u0A95 \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0A96\u0AC2\u0AAC \u0AAE\u0ACB\u0A9F\u0AC1\u0A82: ${r.origin??"\u0AAE\u0AC2\u0AB2\u0ACD\u0AAF"} ${o}${r.maximum.toString()} ${a.unit??"\u0A8F\u0AB2\u0ABF\u0AAE\u0AC7\u0AA8\u0ACD\u0A9F"} \u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A96\u0AC2\u0AAC \u0AAE\u0ACB\u0A9F\u0AC1\u0A82: ${r.origin??"\u0AAE\u0AC2\u0AB2\u0ACD\u0AAF"} ${o}${r.maximum.toString()} \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0A96\u0AC2\u0AAC \u0AA8\u0ABE\u0AA8\u0AC1\u0A82: ${r.origin} ${o}${r.minimum.toString()} ${a.unit} \u0AB9\u0ACB\u0AB5\u0ABE \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A96\u0AC2\u0AAC \u0AA8\u0ABE\u0AA8\u0AC1\u0A82: ${r.origin} ${o}${r.minimum.toString()} \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${o.prefix}" \u0AA5\u0AC0 \u0AB6\u0AB0\u0AC2 \u0AA5\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:o.format==="ends_with"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${o.suffix}" \u0AAA\u0AB0 \u0AB8\u0AAE\u0ABE\u0AAA\u0ACD\u0AA4 \u0AA5\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:o.format==="includes"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: "${o.includes}" \u0AB6\u0ABE\u0AAE\u0AC7\u0AB2 \u0AB9\u0ACB\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:o.format==="regex"?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AB8\u0ACD\u0A9F\u0ACD\u0AB0\u0ABF\u0A82\u0A97: \u0AAA\u0AC7\u0A9F\u0AB0\u0ACD\u0AA8 ${o.pattern} \u0AB8\u0ABE\u0AA5\u0AC7 \u0AAE\u0AC7\u0AB3 \u0A96\u0ABE\u0AB5\u0AC1\u0A82 \u0A9C\u0ACB\u0A88\u0A8F`:`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AA8\u0A82\u0AAC\u0AB0: ${r.divisor} \u0AA8\u0ACB \u0A97\u0AC1\u0AA3\u0ABE\u0A82\u0A95 \u0AB9\u0ACB\u0AB5\u0ACB \u0A9C\u0ACB\u0A88\u0A8F`;case"unrecognized_keys":return`\u0A93\u0AB3\u0A96\u0AC0 \u0AB6\u0A95\u0ABE\u0AA4\u0ABE \u0AA8\u0AB9\u0AC0\u0A82 \u0AA4\u0AC7 \u0A95\u0AC0${r.keys.length>1?"\u0A93":""}: ${G(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u0AAE\u0ABE\u0A82 \u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A95\u0AC0`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AA1\u0ABF\u0AB8\u0ACD\u0A95\u0ACD\u0AB0\u0ABF\u0AAE\u0ABF\u0AA8\u0AC7\u0A9F\u0AB0 \u0AAE\u0AC2\u0AB2\u0ACD\u0AAF. \u0A85\u0AAA\u0AC7\u0A95\u0ACD\u0AB7\u0ABF\u0AA4 ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F";case"invalid_element":return`${r.origin} \u0AAE\u0ABE\u0A82 \u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0AAE\u0AC2\u0AB2\u0ACD\u0AAF`;default:return"\u0A85\u0AAE\u0ABE\u0AA8\u0ACD\u0AAF \u0A87\u0AA8\u0AAA\u0AC1\u0A9F"}}};function jT(){return{localeError:WA()}}var DA=()=>{let e={string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA",gender:"f"},number:{label:"\u05DE\u05E1\u05E4\u05E8",gender:"m"},boolean:{label:"\u05E2\u05E8\u05DA \u05D1\u05D5\u05DC\u05D9\u05D0\u05E0\u05D9",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA",gender:"m"},array:{label:"\u05DE\u05E2\u05E8\u05DA",gender:"m"},object:{label:"\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8",gender:"m"},null:{label:"\u05E2\u05E8\u05DA \u05E8\u05D9\u05E7 (null)",gender:"m"},undefined:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05DE\u05D5\u05D2\u05D3\u05E8 (undefined)",gender:"m"},symbol:{label:"\u05E1\u05D9\u05DE\u05D1\u05D5\u05DC (Symbol)",gender:"m"},function:{label:"\u05E4\u05D5\u05E0\u05E7\u05E6\u05D9\u05D4",gender:"f"},map:{label:"\u05DE\u05E4\u05D4 (Map)",gender:"f"},set:{label:"\u05E7\u05D1\u05D5\u05E6\u05D4 (Set)",gender:"f"},file:{label:"\u05E7\u05D5\u05D1\u05E5",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"\u05E2\u05E8\u05DA \u05DC\u05D0 \u05D9\u05D3\u05D5\u05E2",gender:"m"},value:{label:"\u05E2\u05E8\u05DA",gender:"m"}},t={string:{unit:"\u05EA\u05D5\u05D5\u05D9\u05DD",shortLabel:"\u05E7\u05E6\u05E8",longLabel:"\u05D0\u05E8\u05D5\u05DA"},file:{unit:"\u05D1\u05D9\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},array:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},set:{unit:"\u05E4\u05E8\u05D9\u05D8\u05D9\u05DD",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"},number:{unit:"",shortLabel:"\u05E7\u05D8\u05DF",longLabel:"\u05D2\u05D3\u05D5\u05DC"}},n=l=>l?e[l]:void 0,i=l=>{let u=n(l);return u?u.label:l??e.unknown.label},r=l=>`\u05D4${i(l)}`,o=l=>(n(l)?.gender??"m")==="f"?"\u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05D9\u05D5\u05EA":"\u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA",a=l=>l?t[l]??null:null,s={regex:{label:"\u05E7\u05DC\u05D8",gender:"m"},email:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05D0\u05D9\u05DE\u05D9\u05D9\u05DC",gender:"f"},url:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA \u05E8\u05E9\u05EA",gender:"f"},emoji:{label:"\u05D0\u05D9\u05DE\u05D5\u05D2'\u05D9",gender:"m"},uuid:{label:"UUID",gender:"m"},uuidv4:{label:"UUIDv4",gender:"m"},uuidv6:{label:"UUIDv6",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA \u05D5\u05D6\u05DE\u05DF ISO",gender:"m"},date:{label:"\u05EA\u05D0\u05E8\u05D9\u05DA ISO",gender:"m"},time:{label:"\u05D6\u05DE\u05DF ISO",gender:"m"},duration:{label:"\u05DE\u05E9\u05DA \u05D6\u05DE\u05DF ISO",gender:"m"},ipv4:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv4",gender:"f"},ipv6:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA IPv6",gender:"f"},mac:{label:"\u05DB\u05EA\u05D5\u05D1\u05EA MAC",gender:"f"},cidrv4:{label:"\u05D8\u05D5\u05D5\u05D7 IPv4",gender:"m"},cidrv6:{label:"\u05D8\u05D5\u05D5\u05D7 IPv6",gender:"m"},base64:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64",gender:"f"},base64url:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D1\u05D1\u05E1\u05D9\u05E1 64 \u05DC\u05DB\u05EA\u05D5\u05D1\u05D5\u05EA \u05E8\u05E9\u05EA",gender:"f"},json_string:{label:"\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA JSON",gender:"f"},e164:{label:"\u05DE\u05E1\u05E4\u05E8 E.164",gender:"m"},credit_card:{label:"\u05DE\u05E1\u05E4\u05E8 \u05DB\u05E8\u05D8\u05D9\u05E1 \u05D0\u05E9\u05E8\u05D0\u05D9",gender:"m"},currency_code:{label:"\u05E7\u05D5\u05D3 \u05DE\u05D8\u05D1\u05E2",gender:"m"},iban:{label:"IBAN",gender:"m"},jwt:{label:"JWT",gender:"m"},template_literal:{label:"\u05E7\u05DC\u05D8",gender:"m"},ends_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},includes:{label:"\u05E7\u05DC\u05D8",gender:"m"},lowercase:{label:"\u05E7\u05DC\u05D8",gender:"m"},starts_with:{label:"\u05E7\u05DC\u05D8",gender:"m"},uppercase:{label:"\u05E7\u05DC\u05D8",gender:"m"}},c={nan:"NaN"};return l=>{switch(l.code){case"invalid_type":{let u=l.expected,f=c[u??""]??i(u),d=ye(l.input),m=c[d]??e[d]?.label??d;return/^[A-Z]/.test(l.expected)?`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA instanceof ${l.expected}, \u05D4\u05EA\u05E7\u05D1\u05DC ${m}`:`\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${f}, \u05D4\u05EA\u05E7\u05D1\u05DC ${m}`}case"invalid_value":{if(l.values.length===1)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05E2\u05E8\u05DA \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA ${ge(l.values[0])}`;let u=l.values.map(m=>ge(m));if(l.values.length===2)return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u[0]} \u05D0\u05D5 ${u[1]}`;let f=u[u.length-1];return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D4\u05D0\u05E4\u05E9\u05E8\u05D5\u05D9\u05D5\u05EA \u05D4\u05DE\u05EA\u05D0\u05D9\u05DE\u05D5\u05EA \u05D4\u05DF ${u.slice(0,-1).join(", ")} \u05D0\u05D5 ${f}`}case"too_big":{let u=a(l.origin),f=r(l.origin??"value");if(l.origin==="string")return`${u?.longLabel??"\u05D0\u05E8\u05D5\u05DA"} \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.maximum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA":"\u05DC\u05DB\u05DC \u05D4\u05D9\u05D5\u05EA\u05E8"}`.trim();if(l.origin==="number"){let p=l.inclusive?`\u05E7\u05D8\u05DF \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.maximum}`:`\u05E7\u05D8\u05DF \u05DE-${l.maximum}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${p}`}if(l.origin==="array"||l.origin==="set"){let p=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA",b=l.inclusive?`${l.maximum} ${u?.unit??""} \u05D0\u05D5 \u05E4\u05D7\u05D5\u05EA`:`\u05E4\u05D7\u05D5\u05EA \u05DE-${l.maximum} ${u?.unit??""}`;return`\u05D2\u05D3\u05D5\u05DC \u05DE\u05D3\u05D9: ${f} ${p} \u05DC\u05D4\u05DB\u05D9\u05DC ${b}`.trim()}let d=l.inclusive?"<=":"<",m=o(l.origin??"value");return u?.unit?`${u.longLabel} \u05DE\u05D3\u05D9: ${f} ${m} ${d}${l.maximum.toString()} ${u.unit}`:`${u?.longLabel??"\u05D2\u05D3\u05D5\u05DC"} \u05DE\u05D3\u05D9: ${f} ${m} ${d}${l.maximum.toString()}`}case"too_small":{let u=a(l.origin),f=r(l.origin??"value");if(l.origin==="string")return`${u?.shortLabel??"\u05E7\u05E6\u05E8"} \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DB\u05D4 \u05DC\u05D4\u05DB\u05D9\u05DC ${l.minimum.toString()} ${u?.unit??""} ${l.inclusive?"\u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8":"\u05DC\u05E4\u05D7\u05D5\u05EA"}`.trim();if(l.origin==="number"){let p=l.inclusive?`\u05D2\u05D3\u05D5\u05DC \u05D0\u05D5 \u05E9\u05D5\u05D5\u05D4 \u05DC-${l.minimum}`:`\u05D2\u05D3\u05D5\u05DC \u05DE-${l.minimum}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} \u05E6\u05E8\u05D9\u05DA \u05DC\u05D4\u05D9\u05D5\u05EA ${p}`}if(l.origin==="array"||l.origin==="set"){let p=l.origin==="set"?"\u05E6\u05E8\u05D9\u05DB\u05D4":"\u05E6\u05E8\u05D9\u05DA";if(l.minimum===1&&l.inclusive){let h=(l.origin==="set","\u05DC\u05E4\u05D7\u05D5\u05EA \u05E4\u05E8\u05D9\u05D8 \u05D0\u05D7\u05D3");return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} ${p} \u05DC\u05D4\u05DB\u05D9\u05DC ${h}`}let b=l.inclusive?`${l.minimum} ${u?.unit??""} \u05D0\u05D5 \u05D9\u05D5\u05EA\u05E8`:`\u05D9\u05D5\u05EA\u05E8 \u05DE-${l.minimum} ${u?.unit??""}`;return`\u05E7\u05D8\u05DF \u05DE\u05D3\u05D9: ${f} ${p} \u05DC\u05D4\u05DB\u05D9\u05DC ${b}`.trim()}let d=l.inclusive?">=":">",m=o(l.origin??"value");return u?.unit?`${u.shortLabel} \u05DE\u05D3\u05D9: ${f} ${m} ${d}${l.minimum.toString()} ${u.unit}`:`${u?.shortLabel??"\u05E7\u05D8\u05DF"} \u05DE\u05D3\u05D9: ${f} ${m} ${d}${l.minimum.toString()}`}case"invalid_format":{let u=l;if(u.format==="starts_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D7\u05D9\u05DC \u05D1 "${u.prefix}"`;if(u.format==="ends_with")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05E1\u05EA\u05D9\u05D9\u05DD \u05D1 "${u.suffix}"`;if(u.format==="includes")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05DB\u05DC\u05D5\u05DC "${u.includes}"`;if(u.format==="regex")return`\u05D4\u05DE\u05D7\u05E8\u05D5\u05D6\u05EA \u05D7\u05D9\u05D9\u05D1\u05EA \u05DC\u05D4\u05EA\u05D0\u05D9\u05DD \u05DC\u05EA\u05D1\u05E0\u05D9\u05EA ${u.pattern}`;let f=s[u.format],d=f?.label??u.format,p=(f?.gender??"m")==="f"?"\u05EA\u05E7\u05D9\u05E0\u05D4":"\u05EA\u05E7\u05D9\u05DF";return`${d} \u05DC\u05D0 ${p}`}case"not_multiple_of":return`\u05DE\u05E1\u05E4\u05E8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF: \u05D7\u05D9\u05D9\u05D1 \u05DC\u05D4\u05D9\u05D5\u05EA \u05DE\u05DB\u05E4\u05DC\u05D4 \u05E9\u05DC ${l.divisor}`;case"unrecognized_keys":return`\u05DE\u05E4\u05EA\u05D7${l.keys.length>1?"\u05D5\u05EA":""} \u05DC\u05D0 \u05DE\u05D6\u05D5\u05D4${l.keys.length>1?"\u05D9\u05DD":"\u05D4"}: ${G(l.keys,", ")}`;case"invalid_key":return"\u05E9\u05D3\u05D4 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1\u05D0\u05D5\u05D1\u05D9\u05D9\u05E7\u05D8";case"invalid_union":return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF";case"invalid_element":return`\u05E2\u05E8\u05DA \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF \u05D1${r(l.origin??"array")}`;default:return"\u05E7\u05DC\u05D8 \u05DC\u05D0 \u05EA\u05E7\u05D9\u05DF"}}};function ZT(){return{localeError:DA()}}var qA=()=>{let e={string:{unit:"\u0905\u0915\u094D\u0937\u0930",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},file:{unit:"\u092C\u093E\u0907\u091F\u094D\u0938",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},array:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},set:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"},map:{unit:"\u092A\u094D\u0930\u0935\u093F\u0937\u094D\u091F\u093F\u092F\u093E\u0901",verb:"\u0930\u0916\u0928\u0947 \u0915\u0947 \u0932\u093F\u090F"}};function t(r){return e[r]??null}let n={regex:"\u0907\u0928\u092A\u0941\u091F",email:"\u0908\u092E\u0947\u0932 \u092A\u0924\u093E",url:"URL",emoji:"\u0907\u092E\u094B\u091C\u0940",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0924\u093F\u0925\u093F \u0914\u0930 \u0938\u092E\u092F",date:"ISO \u0924\u093F\u0925\u093F",time:"ISO \u0938\u092E\u092F",duration:"ISO \u0905\u0935\u0927\u093F",ipv4:"IPv4 \u092A\u0924\u093E",ipv6:"IPv6 \u092A\u0924\u093E",mac:"MAC \u092A\u0924\u093E",cidrv4:"IPv4 \u0936\u094D\u0930\u0947\u0923\u0940",cidrv6:"IPv6 \u0936\u094D\u0930\u0947\u0923\u0940",base64:"Base64-\u090F\u0928\u094D\u0915\u094B\u0921\u0947\u0921 \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",base64url:"Base64URL-\u090F\u0928\u094D\u0915\u094B\u0921\u0947\u0921 \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",json_string:"JSON \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917",e164:"E.164 \u0938\u0902\u0916\u094D\u092F\u093E",credit_card:"\u0915\u094D\u0930\u0947\u0921\u093F\u091F \u0915\u093E\u0930\u094D\u0921 \u0938\u0902\u0916\u094D\u092F\u093E",currency_code:"\u092E\u0941\u0926\u094D\u0930\u093E \u0915\u094B\u0921",iban:"IBAN",jwt:"JWT",template_literal:"\u0907\u0928\u092A\u0941\u091F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${o}, \u092A\u094D\u0930\u093E\u092A\u094D\u0924 ${s}`}case"invalid_value":return r.values.length===1?`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${ge(r.values[0])}`:`\u0905\u092E\u093E\u0928\u094D\u092F \u0935\u093F\u0915\u0932\u094D\u092A: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u092E\u093E\u0928\u094B\u0902 \u092E\u0947\u0902 \u0938\u0947 \u090F\u0915 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u092C\u0939\u0941\u0924 \u092C\u0921\u093C\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin??"\u092E\u093E\u0928"} \u092E\u0947\u0902 ${o}${r.maximum} ${a.unit} \u0939\u094B\u0902`:`\u092C\u0939\u0941\u0924 \u092C\u0921\u093C\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin??"\u092E\u093E\u0928"} ${o}${r.maximum} \u0939\u094B`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u092C\u0939\u0941\u0924 \u091B\u094B\u091F\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin} \u092E\u0947\u0902 ${o}${r.minimum} ${a.unit} \u0939\u094B\u0902`:`\u092C\u0939\u0941\u0924 \u091B\u094B\u091F\u093E: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u0925\u093E \u0915\u093F ${r.origin} ${o}${r.minimum} \u0939\u094B`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: "${o.prefix}" \u0938\u0947 \u0936\u0941\u0930\u0942 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:o.format==="ends_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: "${o.suffix}" \u092A\u0930 \u0938\u092E\u093E\u092A\u094D\u0924 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:o.format==="includes"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: \u0907\u0938\u092E\u0947\u0902 "${o.includes}" \u0936\u093E\u092E\u093F\u0932 \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:o.format==="regex"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0902\u0917: \u092A\u0948\u091F\u0930\u094D\u0928 ${o.pattern} \u0938\u0947 \u092E\u0947\u0932 \u0916\u093E\u0928\u093E \u091A\u093E\u0939\u093F\u090F`:`\u0905\u092E\u093E\u0928\u094D\u092F ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u0902\u0916\u094D\u092F\u093E: \u092F\u0939 ${r.divisor} \u0915\u093E \u0917\u0941\u0923\u091C \u0939\u094B\u0928\u093E \u091A\u093E\u0939\u093F\u090F`;case"unrecognized_keys":return`\u0905\u092A\u0930\u093F\u091A\u093F\u0924 \u0915\u0941\u0902\u091C\u0940${r.keys.length>1?"\u092F\u093E\u0901":""}: ${G(r.keys,", ")}`;case"invalid_key":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0915\u0941\u0902\u091C\u0940: ${r.origin} \u092E\u0947\u0902`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0905\u092E\u093E\u0928\u094D\u092F \u0921\u093F\u0938\u094D\u0915\u094D\u0930\u093F\u092E\u093F\u0928\u0947\u091F\u0930 \u092E\u093E\u0928: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F";case"invalid_element":return`\u0905\u092E\u093E\u0928\u094D\u092F \u092E\u093E\u0928: ${r.origin} \u092E\u0947\u0902`;default:return"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F"}}};function IT(){return{localeError:qA()}}var HA=()=>{let e={string:{unit:"znakova",verb:"imati"},file:{unit:"bajtova",verb:"imati"},array:{unit:"stavki",verb:"imati"},set:{unit:"stavki",verb:"imati"}};function t(r){return e[r]??null}let n={regex:"unos",email:"email adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum i vrijeme",date:"ISO datum",time:"ISO vrijeme",duration:"ISO trajanje",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"IPv4 raspon",cidrv6:"IPv6 raspon",base64:"base64 kodirani tekst",base64url:"base64url kodirani tekst",json_string:"JSON tekst",e164:"E.164 broj",credit_card:"broj kreditne kartice",currency_code:"kod valute",iban:"IBAN",jwt:"JWT",template_literal:"unos"},i={nan:"NaN",string:"tekst",number:"broj",boolean:"boolean",array:"niz",object:"objekt",set:"skup",file:"datoteka",date:"datum",bigint:"bigint",symbol:"simbol",undefined:"undefined",null:"null",function:"funkcija",map:"mapa"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Neispravan unos: o\u010Dekuje se instanceof ${r.expected}, a primljeno je ${s}`:`Neispravan unos: o\u010Dekuje se ${o}, a primljeno je ${s}`}case"invalid_value":return r.values.length===1?`Neispravna vrijednost: o\u010Dekivano ${ge(r.values[0])}`:`Neispravna opcija: o\u010Dekivano jedno od ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin),s=i[r.origin]??r.origin;return a?`Preveliko: o\u010Dekivano da ${s??"vrijednost"} ima ${o}${r.maximum.toString()} ${a.unit??"elemenata"}`:`Preveliko: o\u010Dekivano da ${s??"vrijednost"} bude ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin),s=i[r.origin]??r.origin;return a?`Premalo: o\u010Dekivano da ${s} ima ${o}${r.minimum.toString()} ${a.unit}`:`Premalo: o\u010Dekivano da ${s} bude ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neispravan tekst: mora zapo\u010Dinjati s "${o.prefix}"`:o.format==="ends_with"?`Neispravan tekst: mora zavr\u0161avati s "${o.suffix}"`:o.format==="includes"?`Neispravan tekst: mora sadr\u017Eavati "${o.includes}"`:o.format==="regex"?`Neispravan tekst: mora odgovarati uzorku ${o.pattern}`:`Neispravna ${n[o.format]??r.format}`}case"not_multiple_of":return`Neispravan broj: mora biti vi\u0161ekratnik od ${r.divisor}`;case"unrecognized_keys":return`Neprepoznat${r.keys.length>1?"i klju\u010Devi":" klju\u010D"}: ${G(r.keys,", ")}`;case"invalid_key":return`Neispravan klju\u010D u ${i[r.origin]??r.origin}`;case"invalid_union":return"Neispravan unos";case"invalid_element":return`Neispravna vrijednost u ${i[r.origin]??r.origin}`;default:return"Neispravan unos"}}};function WT(){return{localeError:HA()}}var EA=()=>{let e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"},map:{unit:"elem",verb:"legyen"}};function t(r){return e[r]??null}let n={regex:"bemenet",email:"email c\xEDm",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO id\u0151b\xE9lyeg",date:"ISO d\xE1tum",time:"ISO id\u0151",duration:"ISO id\u0151intervallum",ipv4:"IPv4 c\xEDm",ipv6:"IPv6 c\xEDm",mac:"MAC c\xEDm",cidrv4:"IPv4 tartom\xE1ny",cidrv6:"IPv6 tartom\xE1ny",base64:"base64-k\xF3dolt string",base64url:"base64url-k\xF3dolt string",json_string:"JSON string",e164:"E.164 sz\xE1m",credit_card:"hitelk\xE1rtyasz\xE1m",currency_code:"p\xE9nznemk\xF3d",iban:"IBAN",jwt:"JWT",template_literal:"bemenet"},i={nan:"NaN",number:"sz\xE1m",array:"t\xF6mb"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k instanceof ${r.expected}, a kapott \xE9rt\xE9k ${s}`:`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${o}, a kapott \xE9rt\xE9k ${s}`}case"invalid_value":return r.values.length===1?`\xC9rv\xE9nytelen bemenet: a v\xE1rt \xE9rt\xE9k ${ge(r.values[0])}`:`\xC9rv\xE9nytelen opci\xF3: valamelyik \xE9rt\xE9k v\xE1rt ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`T\xFAl nagy: ${r.origin??"\xE9rt\xE9k"} m\xE9rete t\xFAl nagy ${o}${r.maximum.toString()} ${a.unit??"elem"}`:`T\xFAl nagy: a bemeneti \xE9rt\xE9k ${r.origin??"\xE9rt\xE9k"} t\xFAl nagy: ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} m\xE9rete t\xFAl kicsi ${o}${r.minimum.toString()} ${a.unit}`:`T\xFAl kicsi: a bemeneti \xE9rt\xE9k ${r.origin} t\xFAl kicsi ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\xC9rv\xE9nytelen string: "${o.prefix}" \xE9rt\xE9kkel kell kezd\u0151dnie`:o.format==="ends_with"?`\xC9rv\xE9nytelen string: "${o.suffix}" \xE9rt\xE9kkel kell v\xE9gz\u0151dnie`:o.format==="includes"?`\xC9rv\xE9nytelen string: "${o.includes}" \xE9rt\xE9ket kell tartalmaznia`:o.format==="regex"?`\xC9rv\xE9nytelen string: ${o.pattern} mint\xE1nak kell megfelelnie`:`\xC9rv\xE9nytelen ${n[o.format]??r.format}`}case"not_multiple_of":return`\xC9rv\xE9nytelen sz\xE1m: ${r.divisor} t\xF6bbsz\xF6r\xF6s\xE9nek kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${r.keys.length>1?"s":""}: ${G(r.keys,", ")}`;case"invalid_key":return`\xC9rv\xE9nytelen kulcs ${r.origin}`;case"invalid_union":return"\xC9rv\xE9nytelen bemenet";case"invalid_element":return`\xC9rv\xE9nytelen \xE9rt\xE9k: ${r.origin}`;default:return"\xC9rv\xE9nytelen bemenet"}}};function DT(){return{localeError:EA()}}function qT(e,t,n){return Math.abs(e)===1?t:n}function vl(e){if(!e)return"";let t=["\u0561","\u0565","\u0568","\u056B","\u0578","\u0578\u0582","\u0585"],n=e[e.length-1];return e+(t.includes(n)?"\u0576":"\u0568")}var CA=()=>{let e={string:{unit:{one:"\u0576\u0577\u0561\u0576",many:"\u0576\u0577\u0561\u0576\u0576\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},file:{unit:{one:"\u0562\u0561\u0575\u0569",many:"\u0562\u0561\u0575\u0569\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},array:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},set:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"},map:{unit:{one:"\u057F\u0561\u0580\u0580",many:"\u057F\u0561\u0580\u0580\u0565\u0580"},verb:"\u0578\u0582\u0576\u0565\u0576\u0561\u056C"}};function t(r){return e[r]??null}let n={regex:"\u0574\u0578\u0582\u057F\u0584",email:"\u0567\u056C. \u0570\u0561\u057D\u0581\u0565",url:"URL",emoji:"\u0567\u0574\u0578\u057B\u056B",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E \u0587 \u056A\u0561\u0574",date:"ISO \u0561\u0574\u057D\u0561\u0569\u056B\u057E",time:"ISO \u056A\u0561\u0574",duration:"ISO \u057F\u0587\u0578\u0572\u0578\u0582\u0569\u0575\u0578\u0582\u0576",ipv4:"IPv4 \u0570\u0561\u057D\u0581\u0565",ipv6:"IPv6 \u0570\u0561\u057D\u0581\u0565",mac:"MAC \u0570\u0561\u057D\u0581\u0565",cidrv4:"IPv4 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",cidrv6:"IPv6 \u0574\u056B\u057B\u0561\u056F\u0561\u0575\u0584",base64:"base64 \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",base64url:"base64url \u0571\u0587\u0561\u0579\u0561\u0583\u0578\u057E \u057F\u0578\u0572",json_string:"JSON \u057F\u0578\u0572",e164:"E.164 \u0570\u0561\u0574\u0561\u0580",credit_card:"\u056F\u0580\u0565\u0564\u056B\u057F \u0584\u0561\u0580\u057F\u056B \u0570\u0561\u0574\u0561\u0580",currency_code:"\u0561\u0580\u056A\u0578\u0582\u0575\u0569\u056B \u056F\u0578\u0564",iban:"IBAN",jwt:"JWT",template_literal:"\u0574\u0578\u0582\u057F\u0584"},i={nan:"NaN",number:"\u0569\u056B\u057E",array:"\u0566\u0561\u0576\u0563\u057E\u0561\u056E"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 instanceof ${r.expected}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`:`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${o}, \u057D\u057F\u0561\u0581\u057E\u0565\u056C \u0567 ${s}`}case"invalid_value":return r.values.length===1?`\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 ${ge(r.values[1])}`:`\u054D\u056D\u0561\u056C \u057F\u0561\u0580\u0562\u0565\u0580\u0561\u056F\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567\u0580 \u0570\u0565\u057F\u0587\u0575\u0561\u056C\u0576\u0565\u0580\u056B\u0581 \u0574\u0565\u056F\u0568\u055D ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);if(a){let s=Number(r.maximum),c=qT(s,a.unit.one,a.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${vl(r.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${r.maximum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0574\u0565\u056E \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${vl(r.origin??"\u0561\u0580\u056A\u0565\u0584")} \u056C\u056B\u0576\u056B ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);if(a){let s=Number(r.minimum),c=qT(s,a.unit.one,a.unit.many);return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${vl(r.origin)} \u056F\u0578\u0582\u0576\u0565\u0576\u0561 ${o}${r.minimum.toString()} ${c}`}return`\u0549\u0561\u0583\u0561\u0566\u0561\u0576\u0581 \u0583\u0578\u0584\u0580 \u0561\u0580\u056A\u0565\u0584\u2024 \u057D\u057A\u0561\u057D\u057E\u0578\u0582\u0574 \u0567, \u0578\u0580 ${vl(r.origin)} \u056C\u056B\u0576\u056B ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057D\u056F\u057D\u057E\u056B "${o.prefix}"-\u0578\u057E`:o.format==="ends_with"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0561\u057E\u0561\u0580\u057F\u057E\u056B "${o.suffix}"-\u0578\u057E`:o.format==="includes"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u057A\u0561\u0580\u0578\u0582\u0576\u0561\u056F\u056B "${o.includes}"`:o.format==="regex"?`\u054D\u056D\u0561\u056C \u057F\u0578\u0572\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0570\u0561\u0574\u0561\u057A\u0561\u057F\u0561\u057D\u056D\u0561\u0576\u056B ${o.pattern} \u0571\u0587\u0561\u0579\u0561\u0583\u056B\u0576`:`\u054D\u056D\u0561\u056C ${n[o.format]??r.format}`}case"not_multiple_of":return`\u054D\u056D\u0561\u056C \u0569\u056B\u057E\u2024 \u057A\u0565\u057F\u0584 \u0567 \u0562\u0561\u0566\u0574\u0561\u057A\u0561\u057F\u056B\u056F \u056C\u056B\u0576\u056B ${r.divisor}-\u056B`;case"unrecognized_keys":return`\u0549\u0573\u0561\u0576\u0561\u0579\u057E\u0561\u056E \u0562\u0561\u0576\u0561\u056C\u056B${r.keys.length>1?"\u0576\u0565\u0580":""}. ${G(r.keys,", ")}`;case"invalid_key":return`\u054D\u056D\u0561\u056C \u0562\u0561\u0576\u0561\u056C\u056B ${vl(r.origin)}-\u0578\u0582\u0574`;case"invalid_union":return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574";case"invalid_element":return`\u054D\u056D\u0561\u056C \u0561\u0580\u056A\u0565\u0584 ${vl(r.origin)}-\u0578\u0582\u0574`;default:return"\u054D\u056D\u0561\u056C \u0574\u0578\u0582\u057F\u0584\u0561\u0563\u0580\u0578\u0582\u0574"}}};function HT(){return{localeError:CA()}}var UA=()=>{let e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"},map:{unit:"item",verb:"memiliki"}};function t(r){return e[r]??null}let n={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",mac:"alamat MAC",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",credit_card:"nomor kartu kredit",currency_code:"kode mata uang",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Input tidak valid: diharapkan instanceof ${r.expected}, diterima ${s}`:`Input tidak valid: diharapkan ${o}, diterima ${s}`}case"invalid_value":return r.values.length===1?`Input tidak valid: diharapkan ${ge(r.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Terlalu besar: diharapkan ${r.origin??"value"} memiliki ${o}${r.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${r.origin??"value"} menjadi ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Terlalu kecil: diharapkan ${r.origin} memiliki ${o}${r.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${r.origin} menjadi ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`String tidak valid: harus dimulai dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak valid: harus berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak valid: harus menyertakan "${o.includes}"`:o.format==="regex"?`String tidak valid: harus sesuai pola ${o.pattern}`:`${n[o.format]??r.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${r.keys.length>1?"s":""}: ${G(r.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${r.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${r.origin}`;default:return"Input tidak valid"}}};function ET(){return{localeError:UA()}}var AA=()=>{let e={string:{unit:"stafi",verb:"a\xF0 hafa"},file:{unit:"b\xE6ti",verb:"a\xF0 hafa"},array:{unit:"hluti",verb:"a\xF0 hafa"},set:{unit:"hluti",verb:"a\xF0 hafa"},map:{unit:"hluti",verb:"a\xF0 hafa"}};function t(r){return e[r]??null}let n={regex:"gildi",email:"netfang",url:"vefsl\xF3\xF0",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og t\xEDmi",date:"ISO dagsetning",time:"ISO t\xEDmi",duration:"ISO t\xEDmalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 t\xF6lugildi",credit_card:"kreditkortan\xFAmer",currency_code:"gjaldmi\xF0ilsk\xF3\xF0i",iban:"IBAN",jwt:"JWT",template_literal:"gildi"},i={nan:"NaN",number:"n\xFAmer",array:"fylki"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera instanceof ${r.expected}`:`Rangt gildi: \xDE\xFA sl\xF3st inn ${s} \xFEar sem \xE1 a\xF0 vera ${o}`}case"invalid_value":return r.values.length===1?`Rangt gildi: gert r\xE1\xF0 fyrir ${ge(r.values[0])}`:`\xD3gilt val: m\xE1 vera eitt af eftirfarandi ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin??"gildi"} hafi ${o}${r.maximum.toString()} ${a.unit??"hluti"}`:`Of st\xF3rt: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin??"gildi"} s\xE9 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin} hafi ${o}${r.minimum.toString()} ${a.unit}`:`Of l\xEDti\xF0: gert er r\xE1\xF0 fyrir a\xF0 ${r.origin} s\xE9 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 byrja \xE1 "${o.prefix}"`:o.format==="ends_with"?`\xD3gildur strengur: ver\xF0ur a\xF0 enda \xE1 "${o.suffix}"`:o.format==="includes"?`\xD3gildur strengur: ver\xF0ur a\xF0 innihalda "${o.includes}"`:o.format==="regex"?`\xD3gildur strengur: ver\xF0ur a\xF0 fylgja mynstri ${o.pattern}`:`Rangt ${n[o.format]??r.format}`}case"not_multiple_of":return`R\xF6ng tala: ver\xF0ur a\xF0 vera margfeldi af ${r.divisor}`;case"unrecognized_keys":return`\xD3\xFEekkt ${r.keys.length>1?"ir lyklar":"ur lykill"}: ${G(r.keys,", ")}`;case"invalid_key":return`Rangur lykill \xED ${r.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi \xED ${r.origin}`;default:return"Rangt gildi"}}};function CT(){return{localeError:AA()}}var GA=()=>{let e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"},map:{unit:"elementi",verb:"avere"}};function t(r){return e[r]??null}let n={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",mac:"indirizzo MAC",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",credit_card:"numero di carta di credito",currency_code:"codice valuta",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"numero",array:"vettore"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Input non valido: atteso instanceof ${r.expected}, ricevuto ${s}`:`Input non valido: atteso ${o}, ricevuto ${s}`}case"invalid_value":return r.values.length===1?`Input non valido: atteso ${ge(r.values[0])}`:`Opzione non valida: atteso uno tra ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Troppo grande: ${r.origin??"valore"} deve avere ${o}${r.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${r.origin??"valore"} deve essere ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Troppo piccolo: ${r.origin} deve avere ${o}${r.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${r.origin} deve essere ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Stringa non valida: deve iniziare con "${o.prefix}"`:o.format==="ends_with"?`Stringa non valida: deve terminare con "${o.suffix}"`:o.format==="includes"?`Stringa non valida: deve includere "${o.includes}"`:o.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${o.pattern}`:`Input non valido: ${n[o.format]??r.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${r.divisor}`;case"unrecognized_keys":return`Chiav${r.keys.length>1?"i":"e"} non riconosciut${r.keys.length>1?"e":"a"}: ${G(r.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${r.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${r.origin}`;default:return"Input non valido"}}};function UT(){return{localeError:GA()}}var JA=()=>{let e={string:{unit:"\u6587\u5B57",verb:"\u3067\u3042\u308B"},file:{unit:"\u30D0\u30A4\u30C8",verb:"\u3067\u3042\u308B"},array:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},set:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"},map:{unit:"\u8981\u7D20",verb:"\u3067\u3042\u308B"}};function t(r){return e[r]??null}let n={regex:"\u5165\u529B\u5024",email:"\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",url:"URL",emoji:"\u7D75\u6587\u5B57",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u6642",date:"ISO\u65E5\u4ED8",time:"ISO\u6642\u523B",duration:"ISO\u671F\u9593",ipv4:"IPv4\u30A2\u30C9\u30EC\u30B9",ipv6:"IPv6\u30A2\u30C9\u30EC\u30B9",mac:"MAC\u30A2\u30C9\u30EC\u30B9",cidrv4:"IPv4\u7BC4\u56F2",cidrv6:"IPv6\u7BC4\u56F2",base64:"base64\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",base64url:"base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u6587\u5B57\u5217",json_string:"JSON\u6587\u5B57\u5217",e164:"E.164\u756A\u53F7",credit_card:"\u30AF\u30EC\u30B8\u30C3\u30C8\u30AB\u30FC\u30C9\u756A\u53F7",currency_code:"\u901A\u8CA8\u30B3\u30FC\u30C9",iban:"IBAN",jwt:"JWT",template_literal:"\u5165\u529B\u5024"},i={nan:"NaN",number:"\u6570\u5024",array:"\u914D\u5217"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u7121\u52B9\u306A\u5165\u529B: instanceof ${r.expected}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u5165\u529B: ${o}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F\u304C\u3001${s}\u304C\u5165\u529B\u3055\u308C\u307E\u3057\u305F`}case"invalid_value":return r.values.length===1?`\u7121\u52B9\u306A\u5165\u529B: ${ge(r.values[0])}\u304C\u671F\u5F85\u3055\u308C\u307E\u3057\u305F`:`\u7121\u52B9\u306A\u9078\u629E: ${G(r.values,"\u3001")}\u306E\u3044\u305A\u308C\u304B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"too_big":{let o=r.inclusive?"\u4EE5\u4E0B\u3067\u3042\u308B":"\u3088\u308A\u5C0F\u3055\u3044",a=t(r.origin);return a?`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${a.unit??"\u8981\u7D20"}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5927\u304D\u3059\u304E\u308B\u5024: ${r.origin??"\u5024"}\u306F${r.maximum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"too_small":{let o=r.inclusive?"\u4EE5\u4E0A\u3067\u3042\u308B":"\u3088\u308A\u5927\u304D\u3044",a=t(r.origin);return a?`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${a.unit}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u5C0F\u3055\u3059\u304E\u308B\u5024: ${r.origin}\u306F${r.minimum.toString()}${o}\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.prefix}"\u3067\u59CB\u307E\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="ends_with"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.suffix}"\u3067\u7D42\u308F\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="includes"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: "${o.includes}"\u3092\u542B\u3080\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:o.format==="regex"?`\u7121\u52B9\u306A\u6587\u5B57\u5217: \u30D1\u30BF\u30FC\u30F3${o.pattern}\u306B\u4E00\u81F4\u3059\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`:`\u7121\u52B9\u306A${n[o.format]??r.format}`}case"not_multiple_of":return`\u7121\u52B9\u306A\u6570\u5024: ${r.divisor}\u306E\u500D\u6570\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059`;case"unrecognized_keys":return`\u8A8D\u8B58\u3055\u308C\u3066\u3044\u306A\u3044\u30AD\u30FC${r.keys.length>1?"\u7FA4":""}: ${G(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u30AD\u30FC`;case"invalid_union":return"\u7121\u52B9\u306A\u5165\u529B";case"invalid_element":return`${r.origin}\u5185\u306E\u7121\u52B9\u306A\u5024`;default:return"\u7121\u52B9\u306A\u5165\u529B"}}};function AT(){return{localeError:JA()}}var BA=()=>{let e={string:{unit:"\u10E1\u10D8\u10DB\u10D1\u10DD\u10DA\u10DD",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},file:{unit:"\u10D1\u10D0\u10D8\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},array:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},set:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"},map:{unit:"\u10D4\u10DA\u10D4\u10DB\u10D4\u10DC\u10E2\u10D8",verb:"\u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1"}};function t(r){return e[r]??null}let n={regex:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0",email:"\u10D4\u10DA-\u10E4\u10DD\u10E1\u10E2\u10D8\u10E1 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",url:"URL",emoji:"\u10D4\u10DB\u10DD\u10EF\u10D8",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8-\u10D3\u10E0\u10DD",date:"\u10D7\u10D0\u10E0\u10D8\u10E6\u10D8",time:"\u10D3\u10E0\u10DD",duration:"\u10EE\u10D0\u10DC\u10D2\u10E0\u10EB\u10DA\u10D8\u10D5\u10DD\u10D1\u10D0",ipv4:"IPv4 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",ipv6:"IPv6 \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",mac:"MAC \u10DB\u10D8\u10E1\u10D0\u10DB\u10D0\u10E0\u10D7\u10D8",cidrv4:"IPv4 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",cidrv6:"IPv6 \u10D3\u10D8\u10D0\u10DE\u10D0\u10D6\u10DD\u10DC\u10D8",base64:"base64-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",base64url:"base64url-\u10D9\u10DD\u10D3\u10D8\u10E0\u10D4\u10D1\u10E3\u10DA\u10D8 \u10D5\u10D4\u10DA\u10D8",json_string:"JSON \u10D5\u10D4\u10DA\u10D8",e164:"E.164 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",credit_card:"\u10E1\u10D0\u10D9\u10E0\u10D4\u10D3\u10D8\u10E2\u10DD \u10D1\u10D0\u10E0\u10D0\u10D7\u10D8\u10E1 \u10DC\u10DD\u10DB\u10D4\u10E0\u10D8",currency_code:"\u10D5\u10D0\u10DA\u10E3\u10E2\u10D8\u10E1 \u10D9\u10DD\u10D3\u10D8",iban:"IBAN",jwt:"JWT",template_literal:"\u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"},i={nan:"NaN",number:"\u10E0\u10D8\u10EA\u10EE\u10D5\u10D8",string:"\u10D5\u10D4\u10DA\u10D8",boolean:"\u10D1\u10E3\u10DA\u10D4\u10D0\u10DC\u10D8",function:"\u10E4\u10E3\u10DC\u10E5\u10EA\u10D8\u10D0",array:"\u10DB\u10D0\u10E1\u10D8\u10D5\u10D8"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 instanceof ${r.expected}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${o}, \u10DB\u10D8\u10E6\u10D4\u10D1\u10E3\u10DA\u10D8 ${s}`}case"invalid_value":return r.values.length===1?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${ge(r.values[0])}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D0\u10E0\u10D8\u10D0\u10DC\u10E2\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8\u10D0 \u10D4\u10E0\u10D7-\u10D4\u10E0\u10D7\u10D8 ${G(r.values,"|")}-\u10D3\u10D0\u10DC`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} ${a.verb} ${o}${r.maximum.toString()} ${a.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10D3\u10D8\u10D3\u10D8: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin??"\u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0"} \u10D8\u10E7\u10DD\u10E1 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin} ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`\u10D6\u10D4\u10D3\u10DB\u10D4\u10E2\u10D0\u10D3 \u10DE\u10D0\u10E2\u10D0\u10E0\u10D0: \u10DB\u10DD\u10E1\u10D0\u10DA\u10DD\u10D3\u10DC\u10D4\u10DA\u10D8 ${r.origin} \u10D8\u10E7\u10DD\u10E1 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10EC\u10E7\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.prefix}"-\u10D8\u10D7`:o.format==="ends_with"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10DB\u10D7\u10D0\u10D5\u10E0\u10D3\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 "${o.suffix}"-\u10D8\u10D7`:o.format==="includes"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D8\u10EA\u10D0\u10D5\u10D3\u10D4\u10E1 "${o.includes}"-\u10E1`:o.format==="regex"?`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D5\u10D4\u10DA\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10E8\u10D4\u10D4\u10E1\u10D0\u10D1\u10D0\u10DB\u10D4\u10D1\u10DD\u10D3\u10D4\u10E1 \u10E8\u10D0\u10D1\u10DA\u10DD\u10DC\u10E1 ${o.pattern}`:`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E0\u10D8\u10EA\u10EE\u10D5\u10D8: \u10E3\u10DC\u10D3\u10D0 \u10D8\u10E7\u10DD\u10E1 ${r.divisor}-\u10D8\u10E1 \u10EF\u10D4\u10E0\u10D0\u10D3\u10D8`;case"unrecognized_keys":return`\u10E3\u10EA\u10DC\u10DD\u10D1\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1${r.keys.length>1?"\u10D4\u10D1\u10D8":"\u10D8"}: ${G(r.keys,", ")}`;case"invalid_key":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10D2\u10D0\u10E1\u10D0\u10E6\u10D4\u10D1\u10D8 ${r.origin}-\u10E8\u10D8`;case"invalid_union":return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0";case"invalid_element":return`\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10DB\u10DC\u10D8\u10E8\u10D5\u10DC\u10D4\u10DA\u10DD\u10D1\u10D0 ${r.origin}-\u10E8\u10D8`;default:return"\u10D0\u10E0\u10D0\u10E1\u10EC\u10DD\u10E0\u10D8 \u10E8\u10D4\u10E7\u10D5\u10D0\u10DC\u10D0"}}};function GT(){return{localeError:BA()}}var YA=()=>{let e={string:{unit:"\u178F\u17BD\u17A2\u1780\u17D2\u179F\u179A",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},file:{unit:"\u1794\u17C3",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},array:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},set:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"},map:{unit:"\u1792\u17B6\u178F\u17BB",verb:"\u1782\u17BD\u179A\u1798\u17B6\u1793"}};function t(r){return e[r]??null}let n={regex:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B",email:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793\u17A2\u17CA\u17B8\u1798\u17C2\u179B",url:"URL",emoji:"\u179F\u1789\u17D2\u1789\u17B6\u17A2\u17B6\u179A\u1798\u17D2\u1798\u178E\u17CD",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 \u1793\u17B7\u1784\u1798\u17C9\u17C4\u1784 ISO",date:"\u1780\u17B6\u179B\u1794\u179A\u17B7\u1785\u17D2\u1786\u17C1\u1791 ISO",time:"\u1798\u17C9\u17C4\u1784 ISO",duration:"\u179A\u1799\u17C8\u1796\u17C1\u179B ISO",ipv4:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",ipv6:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",mac:"\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 MAC",cidrv4:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv4",cidrv6:"\u178A\u17C2\u1793\u17A2\u17B6\u179F\u1799\u178A\u17D2\u178B\u17B6\u1793 IPv6",base64:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64",base64url:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u17A2\u17CA\u17B7\u1780\u17BC\u178A base64url",json_string:"\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A JSON",e164:"\u179B\u17C1\u1781 E.164",credit_card:"\u179B\u17C1\u1781\u1794\u17D0\u178E\u17D2\u178E\u17A5\u178E\u1791\u17B6\u1793",currency_code:"\u1780\u17BC\u178A\u179A\u17BC\u1794\u17B7\u1799\u1794\u17D0\u178E\u17D2\u178E",iban:"IBAN",jwt:"JWT",template_literal:"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B"},i={nan:"NaN",number:"\u179B\u17C1\u1781",array:"\u17A2\u17B6\u179A\u17C1 (Array)",null:"\u1782\u17D2\u1798\u17B6\u1793\u178F\u1798\u17D2\u179B\u17C3 (null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A instanceof ${r.expected} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`:`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${o} \u1794\u17C9\u17BB\u1793\u17D2\u178F\u17C2\u1791\u1791\u17BD\u179B\u1794\u17B6\u1793 ${s}`}case"invalid_value":return r.values.length===1?`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1794\u1789\u17D2\u1785\u17BC\u179B\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${ge(r.values[0])}`:`\u1787\u1798\u17D2\u179A\u17BE\u179F\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1787\u17B6\u1798\u17BD\u1799\u1780\u17D2\u1793\u17BB\u1784\u1785\u17C6\u178E\u17C4\u1798 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${r.maximum.toString()} ${a.unit??"\u1792\u17B6\u178F\u17BB"}`:`\u1792\u17C6\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin??"\u178F\u1798\u17D2\u179B\u17C3"} ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${o} ${r.minimum.toString()} ${a.unit}`:`\u178F\u17BC\u1785\u1796\u17C1\u1780\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1780\u17B6\u179A ${r.origin} ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1785\u17B6\u1794\u17CB\u1795\u17D2\u178F\u17BE\u1798\u178A\u17C4\u1799 "${o.prefix}"`:o.format==="ends_with"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1794\u1789\u17D2\u1785\u1794\u17CB\u178A\u17C4\u1799 "${o.suffix}"`:o.format==="includes"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u1798\u17B6\u1793 "${o.includes}"`:o.format==="regex"?`\u1781\u17D2\u179F\u17C2\u17A2\u1780\u17D2\u179F\u179A\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1795\u17D2\u1782\u17BC\u1795\u17D2\u1782\u1784\u1793\u17B9\u1784\u1791\u1798\u17D2\u179A\u1784\u17CB\u178A\u17C2\u179B\u1794\u17B6\u1793\u1780\u17C6\u178E\u178F\u17CB ${o.pattern}`:`\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u179B\u17C1\u1781\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u17D6 \u178F\u17D2\u179A\u17BC\u179C\u178F\u17C2\u1787\u17B6\u1796\u17A0\u17BB\u1782\u17BB\u178E\u1793\u17C3 ${r.divisor}`;case"unrecognized_keys":return`\u179A\u1780\u1783\u17BE\u1789\u179F\u17C4\u1798\u17B7\u1793\u179F\u17D2\u1782\u17B6\u179B\u17CB\u17D6 ${G(r.keys,", ")}`;case"invalid_key":return`\u179F\u17C4\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;case"invalid_union":return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C";case"invalid_element":return`\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C\u1793\u17C5\u1780\u17D2\u1793\u17BB\u1784 ${r.origin}`;default:return"\u1791\u17B7\u1793\u17D2\u1793\u1793\u17D0\u1799\u1798\u17B7\u1793\u178F\u17D2\u179A\u17B9\u1798\u178F\u17D2\u179A\u17BC\u179C"}}};function Wh(){return{localeError:YA()}}function JT(){return Wh()}var KA=()=>{let e={string:{unit:"\u0C85\u0C95\u0CCD\u0CB7\u0CB0\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},file:{unit:"\u0CAC\u0CC8\u0C9F\u0CCD\u200C\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},array:{unit:"\u0CB5\u0CB8\u0CCD\u0CA4\u0CC1\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},set:{unit:"\u0CB5\u0CB8\u0CCD\u0CA4\u0CC1\u0C97\u0CB3\u0CC1",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"},map:{unit:"entries",verb:"\u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1"}};function t(r){return e[r]??null}let n={regex:"\u0C87\u0CA8\u0CCD\u0CAA\u0CC1\u0C9F\u0CCD",email:"email \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0CA6\u0CBF\u0CA8\u0CBE\u0C82\u0C95\u0CA6 \u0CB8\u0CAE\u0CAF",date:"ISO \u0CA6\u0CBF\u0CA8\u0CBE\u0C82\u0C95",time:"ISO \u0CB8\u0CAE\u0CAF",duration:"ISO \u0C85\u0CB5\u0CA7\u0CBF",ipv4:"IPv4 \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",ipv6:"IPv6 \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",mac:"MAC \u0CB5\u0CBF\u0CB3\u0CBE\u0CB8",cidrv4:"IPv4 \u0CB5\u0CCD\u0CAF\u0CBE\u0CAA\u0CCD\u0CA4\u0CBF\u0CAF",cidrv6:"IPv6 \u0CB5\u0CCD\u0CAF\u0CBE\u0CAA\u0CCD\u0CA4\u0CBF\u0CAF",base64:"base64-encoded\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",base64url:"base64url-encoded\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",json_string:"JSON\u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD",e164:"E.164 \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6",credit_card:"\u0C95\u0CCD\u0CB0\u0CC6\u0CA1\u0CBF\u0C9F\u0CCD \u0C95\u0CBE\u0CB0\u0CCD\u0CA1\u0CCD \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6",currency_code:"\u0C95\u0CB0\u0CC6\u0CA8\u0CCD\u0CB8\u0CBF \u0C95\u0CCB\u0CA1\u0CCD",iban:"IBAN",jwt:"JWT",template_literal:"\u0C87\u0CA8\u0CCD\u0CAA\u0CC1\u0C9F\u0CCD"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${o}, \u0CB8\u0CCD\u0CB5\u0CC0\u0C95\u0CB0\u0CBF\u0CB8\u0CBF\u0CA6\u0CA8\u0CC1 ${s}`}case"invalid_value":return r.values.length===1?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${ge(r.values[0])}`:`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C86\u0CAF\u0CCD\u0C95\u0CC6: \u0C87\u0CB5\u0CC1\u0C97\u0CB3\u0CB2\u0CCD\u0CB2\u0CBF \u0C92\u0C82\u0CA6\u0CA8\u0CCD\u0CA8\u0CC1 \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0CA6\u0CCA\u0CA1\u0CCD\u0CA1\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin??"value"} \u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1 ${o}${r.maximum.toString()} ${a.unit??"\u0C85\u0C82\u0CB6\u0C97\u0CB3\u0CC1"}`:`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0CA6\u0CCA\u0CA1\u0CCD\u0CA1\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin??"value"} \u0C8E\u0C82\u0CA6\u0CC1 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0C9A\u0CBF\u0C95\u0CCD\u0C95\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin} \u0CB9\u0CCA\u0C82\u0CA6\u0CB2\u0CC1 ${o}${r.minimum.toString()} ${a.unit}`:`\u0CA4\u0CC1\u0C82\u0CAC\u0CBE \u0C9A\u0CBF\u0C95\u0CCD\u0C95\u0CA6\u0CC1: \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.origin} \u0C8E\u0C82\u0CA6\u0CC1 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C87\u0CA6\u0CB0\u0CCA\u0C82\u0CA6\u0CBF\u0C97\u0CC6 \u0CAA\u0CCD\u0CB0\u0CBE\u0CB0\u0C82\u0CAD\u0CBF\u0CB8\u0CAC\u0CC7\u0C95\u0CC1 "${o.prefix}"`:o.format==="ends_with"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C87\u0CA6\u0CB0\u0CCA\u0C82\u0CA6\u0CBF\u0C97\u0CC6 \u0C95\u0CCA\u0CA8\u0CC6\u0C97\u0CCA\u0CB3\u0CCD\u0CB3\u0CAC\u0CC7\u0C95\u0CC1 "${o.suffix}"`:o.format==="includes"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0C92\u0CB3\u0C97\u0CCA\u0C82\u0CA1\u0CBF\u0CB0\u0CAC\u0CC7\u0C95\u0CC1 "${o.includes}"`:o.format==="regex"?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0CB8\u0CCD\u0C9F\u0CCD\u0CB0\u0CBF\u0C82\u0C97\u0CCD: \u0CAE\u0CBE\u0CA6\u0CB0\u0CBF\u0C97\u0CC6 \u0CB9\u0CCA\u0C82\u0CA6\u0CBF\u0C95\u0CC6\u0CAF\u0CBE\u0C97\u0CAC\u0CC7\u0C95\u0CC1 ${o.pattern}`:`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6: \u0CAC\u0CB9\u0CC1\u0CB8\u0C82\u0C96\u0CCD\u0CAF\u0CC6\u0CAF\u0CBE\u0C97\u0CBF\u0CB0\u0CAC\u0CC7\u0C95\u0CC1 ${r.divisor}`;case"unrecognized_keys":return`\u0C97\u0CC1\u0CB0\u0CC1\u0CA4\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CA6 \u0C95\u0CC0 ${r.keys.length>1?"s":""}: ${G(r.keys,", ")}`;case"invalid_key":return`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF\u0CB5\u0CBE\u0CA6 \u0C95\u0CC0 \u0C87\u0CA8\u0CCD ${r.origin}`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CA4\u0CBE\u0CB0\u0CA4\u0CAE\u0CCD\u0CAF \u0CAE\u0CCC\u0CB2\u0CCD\u0CAF. \u0CA8\u0CBF\u0CB0\u0CC0\u0C95\u0CCD\u0CB7\u0CBF\u0CB8\u0CB2\u0CBE\u0C97\u0CBF\u0CA6\u0CC6 ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD";case"invalid_element":return`\u0CB0\u0CB2\u0CCD\u0CB2\u0CBF \u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0CAE\u0CCC\u0CB2\u0CCD\u0CAF ${r.origin}`;default:return"\u0C85\u0CAE\u0CBE\u0CA8\u0CCD\u0CAF \u0C87\u0CA8\u0CCD\u200C\u0CAA\u0CC1\u0C9F\u0CCD"}}};function BT(){return{localeError:KA()}}var QA=()=>{let e={string:{unit:"\uBB38\uC790",verb:"to have"},file:{unit:"\uBC14\uC774\uD2B8",verb:"to have"},array:{unit:"\uAC1C",verb:"to have"},set:{unit:"\uAC1C",verb:"to have"},map:{unit:"\uAC1C",verb:"to have"}};function t(r){return e[r]??null}let n={regex:"\uC785\uB825",email:"\uC774\uBA54\uC77C \uC8FC\uC18C",url:"URL",emoji:"\uC774\uBAA8\uC9C0",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \uB0A0\uC9DC\uC2DC\uAC04",date:"ISO \uB0A0\uC9DC",time:"ISO \uC2DC\uAC04",duration:"ISO \uAE30\uAC04",ipv4:"IPv4 \uC8FC\uC18C",ipv6:"IPv6 \uC8FC\uC18C",mac:"MAC \uC8FC\uC18C",cidrv4:"IPv4 \uBC94\uC704",cidrv6:"IPv6 \uBC94\uC704",base64:"base64 \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",base64url:"base64url \uC778\uCF54\uB529 \uBB38\uC790\uC5F4",json_string:"JSON \uBB38\uC790\uC5F4",e164:"E.164 \uBC88\uD638",credit_card:"\uC2E0\uC6A9\uCE74\uB4DC \uBC88\uD638",currency_code:"\uD1B5\uD654 \uCF54\uB4DC",iban:"IBAN",jwt:"JWT",template_literal:"\uC785\uB825"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 instanceof ${r.expected}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC785\uB825: \uC608\uC0C1 \uD0C0\uC785\uC740 ${o}, \uBC1B\uC740 \uD0C0\uC785\uC740 ${s}\uC785\uB2C8\uB2E4`}case"invalid_value":return r.values.length===1?`\uC798\uBABB\uB41C \uC785\uB825: \uAC12\uC740 ${ge(r.values[0])} \uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C \uC635\uC158: ${G(r.values,"\uB610\uB294 ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"too_big":{let o=r.inclusive?"\uC774\uD558":"\uBBF8\uB9CC",a=o==="\uBBF8\uB9CC"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(r.origin),c=s?.unit??"\uC694\uC18C";return s?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()}${c} ${o}${a}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uD07D\uB2C8\uB2E4: ${r.maximum.toString()} ${o}${a}`}case"too_small":{let o=r.inclusive?"\uC774\uC0C1":"\uCD08\uACFC",a=o==="\uC774\uC0C1"?"\uC774\uC5B4\uC57C \uD569\uB2C8\uB2E4":"\uC5EC\uC57C \uD569\uB2C8\uB2E4",s=t(r.origin),c=s?.unit??"\uC694\uC18C";return s?`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()}${c} ${o}${a}`:`${r.origin??"\uAC12"}\uC774 \uB108\uBB34 \uC791\uC2B5\uB2C8\uB2E4: ${r.minimum.toString()} ${o}${a}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.prefix}"(\uC73C)\uB85C \uC2DC\uC791\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="ends_with"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.suffix}"(\uC73C)\uB85C \uB05D\uB098\uC57C \uD569\uB2C8\uB2E4`:o.format==="includes"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: "${o.includes}"\uC744(\uB97C) \uD3EC\uD568\uD574\uC57C \uD569\uB2C8\uB2E4`:o.format==="regex"?`\uC798\uBABB\uB41C \uBB38\uC790\uC5F4: \uC815\uADDC\uC2DD ${o.pattern} \uD328\uD134\uACFC \uC77C\uCE58\uD574\uC57C \uD569\uB2C8\uB2E4`:`\uC798\uBABB\uB41C ${n[o.format]??r.format}`}case"not_multiple_of":return`\uC798\uBABB\uB41C \uC22B\uC790: ${r.divisor}\uC758 \uBC30\uC218\uC5EC\uC57C \uD569\uB2C8\uB2E4`;case"unrecognized_keys":return`\uC778\uC2DD\uD560 \uC218 \uC5C6\uB294 \uD0A4: ${G(r.keys,", ")}`;case"invalid_key":return`\uC798\uBABB\uB41C \uD0A4: ${r.origin}`;case"invalid_union":return"\uC798\uBABB\uB41C \uC785\uB825";case"invalid_element":return`\uC798\uBABB\uB41C \uAC12: ${r.origin}`;default:return"\uC798\uBABB\uB41C \uC785\uB825"}}};function YT(){return{localeError:QA()}}var nd=e=>e.charAt(0).toUpperCase()+e.slice(1);function KT(e){let t=Math.abs(e),n=t%10,i=t%100;return i>=11&&i<=19||n===0?"many":n===1?"one":"few"}var _A=()=>{let e={string:{unit:{one:"simbolis",few:"simboliai",many:"simboli\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne ilgesn\u0117 kaip",notInclusive:"turi b\u016Bti trumpesn\u0117 kaip"},bigger:{inclusive:"turi b\u016Bti ne trumpesn\u0117 kaip",notInclusive:"turi b\u016Bti ilgesn\u0117 kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"bait\u0173"},verb:{smaller:{inclusive:"turi b\u016Bti ne didesnis kaip",notInclusive:"turi b\u016Bti ma\u017Eesnis kaip"},bigger:{inclusive:"turi b\u016Bti ne ma\u017Eesnis kaip",notInclusive:"turi b\u016Bti didesnis kaip"}}},array:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}},set:{unit:{one:"element\u0105",few:"elementus",many:"element\u0173"},verb:{smaller:{inclusive:"turi tur\u0117ti ne daugiau kaip",notInclusive:"turi tur\u0117ti ma\u017Eiau kaip"},bigger:{inclusive:"turi tur\u0117ti ne ma\u017Eiau kaip",notInclusive:"turi tur\u0117ti daugiau kaip"}}}};function t(r,o,a,s){let c=e[r]??null;return c===null?c:{unit:c.unit[o],verb:c.verb[s][a?"inclusive":"notInclusive"]}}let n={regex:"\u012Fvestis",email:"el. pa\u0161to adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukm\u0117",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",mac:"MAC adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 u\u017Ekoduota eilut\u0117",base64url:"base64url u\u017Ekoduota eilut\u0117",json_string:"JSON eilut\u0117",e164:"E.164 numeris",credit_card:"kredito kortel\u0117s numeris",currency_code:"valiutos kodas",iban:"IBAN",jwt:"JWT",template_literal:"\u012Fvestis"},i={nan:"NaN",number:"skai\u010Dius",bigint:"sveikasis skai\u010Dius",string:"eilut\u0117",boolean:"login\u0117 reik\u0161m\u0117",undefined:"neapibr\u0117\u017Eta reik\u0161m\u0117",function:"funkcija",symbol:"simbolis",array:"masyvas",object:"objektas",null:"nulin\u0117 reik\u0161m\u0117"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Gautas tipas ${s}, o tik\u0117tasi - instanceof ${r.expected}`:`Gautas tipas ${s}, o tik\u0117tasi - ${o}`}case"invalid_value":return r.values.length===1?`Privalo b\u016Bti ${ge(r.values[0])}`:`Privalo b\u016Bti vienas i\u0161 ${G(r.values,"|")} pasirinkim\u0173`;case"too_big":{let o=i[r.origin]??r.origin,a=t(r.origin,KT(Number(r.maximum)),r.inclusive??!1,"smaller");if(a?.verb)return`${nd(o??r.origin??"reik\u0161m\u0117")} ${a.verb} ${r.maximum.toString()} ${a.unit??"element\u0173"}`;let s=r.inclusive?"ne didesnis kaip":"ma\u017Eesnis kaip";return`${nd(o??r.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${r.maximum.toString()} ${a?.unit}`}case"too_small":{let o=i[r.origin]??r.origin,a=t(r.origin,KT(Number(r.minimum)),r.inclusive??!1,"bigger");if(a?.verb)return`${nd(o??r.origin??"reik\u0161m\u0117")} ${a.verb} ${r.minimum.toString()} ${a.unit??"element\u0173"}`;let s=r.inclusive?"ne ma\u017Eesnis kaip":"didesnis kaip";return`${nd(o??r.origin??"reik\u0161m\u0117")} turi b\u016Bti ${s} ${r.minimum.toString()} ${a?.unit}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Eilut\u0117 privalo prasid\u0117ti "${o.prefix}"`:o.format==="ends_with"?`Eilut\u0117 privalo pasibaigti "${o.suffix}"`:o.format==="includes"?`Eilut\u0117 privalo \u012Ftraukti "${o.includes}"`:o.format==="regex"?`Eilut\u0117 privalo atitikti ${o.pattern}`:`Neteisingas ${n[o.format]??r.format}`}case"not_multiple_of":return`Skai\u010Dius privalo b\u016Bti ${r.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpa\u017Eint${r.keys.length>1?"i":"as"} rakt${r.keys.length>1?"ai":"as"}: ${G(r.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga \u012Fvestis";case"invalid_element":{let o=i[r.origin]??r.origin;return`${nd(o??r.origin??"reik\u0161m\u0117")} turi klaiding\u0105 \u012Fvest\u012F`}default:return"Klaidinga \u012Fvestis"}}};function QT(){return{localeError:_A()}}var $A=()=>{let e={string:{unit:"\u0437\u043D\u0430\u0446\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},file:{unit:"\u0431\u0430\u0458\u0442\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},array:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},set:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"},map:{unit:"\u0441\u0442\u0430\u0432\u043A\u0438",verb:"\u0434\u0430 \u0438\u043C\u0430\u0430\u0442"}};function t(r){return e[r]??null}let n={regex:"\u0432\u043D\u0435\u0441",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u043D\u0430 \u0435-\u043F\u043E\u0448\u0442\u0430",url:"URL",emoji:"\u0435\u043C\u043E\u045F\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0443\u043C \u0438 \u0432\u0440\u0435\u043C\u0435",date:"ISO \u0434\u0430\u0442\u0443\u043C",time:"ISO \u0432\u0440\u0435\u043C\u0435",duration:"ISO \u0432\u0440\u0435\u043C\u0435\u0442\u0440\u0430\u0435\u045A\u0435",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441\u0430",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441\u0430",mac:"MAC \u0430\u0434\u0440\u0435\u0441\u0430",cidrv4:"IPv4 \u043E\u043F\u0441\u0435\u0433",cidrv6:"IPv6 \u043E\u043F\u0441\u0435\u0433",base64:"base64-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",base64url:"base64url-\u0435\u043D\u043A\u043E\u0434\u0438\u0440\u0430\u043D\u0430 \u043D\u0438\u0437\u0430",json_string:"JSON \u043D\u0438\u0437\u0430",e164:"E.164 \u0431\u0440\u043E\u0458",credit_card:"\u0431\u0440\u043E\u0458 \u043D\u0430 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u0430 \u043A\u0430\u0440\u0442\u0438\u0447\u043A\u0430",currency_code:"\u043A\u043E\u0434 \u043D\u0430 \u0432\u0430\u043B\u0443\u0442\u0430",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u043D\u0435\u0441"},i={nan:"NaN",number:"\u0431\u0440\u043E\u0458",array:"\u043D\u0438\u0437\u0430"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 instanceof ${r.expected}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`:`\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${o}, \u043F\u0440\u0438\u043C\u0435\u043D\u043E ${s}`}case"invalid_value":return r.values.length===1?`Invalid input: expected ${ge(r.values[0])}`:`\u0413\u0440\u0435\u0448\u0430\u043D\u0430 \u043E\u043F\u0446\u0438\u0458\u0430: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 \u0435\u0434\u043D\u0430 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0438\u043C\u0430 ${o}${r.maximum.toString()} ${a.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0438"}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u0433\u043E\u043B\u0435\u043C: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin??"\u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442\u0430"} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0438\u043C\u0430 ${o}${r.minimum.toString()} ${a.unit}`:`\u041F\u0440\u0435\u043C\u043D\u043E\u0433\u0443 \u043C\u0430\u043B: \u0441\u0435 \u043E\u0447\u0435\u043A\u0443\u0432\u0430 ${r.origin} \u0434\u0430 \u0431\u0438\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u043F\u043E\u0447\u043D\u0443\u0432\u0430 \u0441\u043E "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0437\u0430\u0432\u0440\u0448\u0443\u0432\u0430 \u0441\u043E "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0432\u043A\u043B\u0443\u0447\u0443\u0432\u0430 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0430\u0436\u0435\u0447\u043A\u0430 \u043D\u0438\u0437\u0430: \u043C\u043E\u0440\u0430 \u0434\u0430 \u043E\u0434\u0433\u043E\u0430\u0440\u0430 \u043D\u0430 \u043F\u0430\u0442\u0435\u0440\u043D\u043E\u0442 ${o.pattern}`:`Invalid ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0413\u0440\u0435\u0448\u0435\u043D \u0431\u0440\u043E\u0458: \u043C\u043E\u0440\u0430 \u0434\u0430 \u0431\u0438\u0434\u0435 \u0434\u0435\u043B\u0438\u0432 \u0441\u043E ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D\u0438 \u043A\u043B\u0443\u0447\u0435\u0432\u0438":"\u041D\u0435\u043F\u0440\u0435\u043F\u043E\u0437\u043D\u0430\u0435\u043D \u043A\u043B\u0443\u0447"}: ${G(r.keys,", ")}`;case"invalid_key":return`\u0413\u0440\u0435\u0448\u0435\u043D \u043A\u043B\u0443\u0447 \u0432\u043E ${r.origin}`;case"invalid_union":return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441";case"invalid_element":return`\u0413\u0440\u0435\u0448\u043D\u0430 \u0432\u0440\u0435\u0434\u043D\u043E\u0441\u0442 \u0432\u043E ${r.origin}`;default:return"\u0413\u0440\u0435\u0448\u0435\u043D \u0432\u043D\u0435\u0441"}}};function _T(){return{localeError:$A()}}var eG=()=>{let e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"},map:{unit:"elemen",verb:"mempunyai"}};function t(r){return e[r]??null}let n={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",mac:"alamat MAC",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",credit_card:"nombor kad kredit",currency_code:"kod mata wang",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"nombor"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Input tidak sah: dijangka instanceof ${r.expected}, diterima ${s}`:`Input tidak sah: dijangka ${o}, diterima ${s}`}case"invalid_value":return r.values.length===1?`Input tidak sah: dijangka ${ge(r.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Terlalu besar: dijangka ${r.origin??"nilai"} ${a.verb} ${o}${r.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${r.origin??"nilai"} adalah ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Terlalu kecil: dijangka ${r.origin} ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${r.origin} adalah ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`String tidak sah: mesti bermula dengan "${o.prefix}"`:o.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${o.suffix}"`:o.format==="includes"?`String tidak sah: mesti mengandungi "${o.includes}"`:o.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${o.pattern}`:`${n[o.format]??r.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${r.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${G(r.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${r.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${r.origin}`;default:return"Input tidak sah"}}};function $T(){return{localeError:eG()}}var tG=()=>{let e={string:{unit:"\u0905\u0915\u094D\u0937\u0930",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},file:{unit:"\u092C\u093E\u0907\u091F",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},array:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},set:{unit:"\u0924\u0924\u094D\u0935",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"},map:{unit:"\u092A\u094D\u0930\u0935\u093F\u0937\u094D\u091F\u093F",verb:"\u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B"}};function t(r){return e[r]??null}let n={regex:"\u0907\u0928\u092A\u0941\u091F",email:"\u0907\u092E\u0947\u0932 \u0920\u0947\u0917\u093E\u0928\u093E",url:"URL",emoji:"\u0907\u092E\u094B\u091C\u0940",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u092E\u093F\u0924\u093F \u0930 \u0938\u092E\u092F",date:"ISO \u092E\u093F\u0924\u093F",time:"ISO \u0938\u092E\u092F",duration:"ISO \u0905\u0935\u0927\u093F",ipv4:"IPv4 \u0920\u0947\u0917\u093E\u0928\u093E",ipv6:"IPv6 \u0920\u0947\u0917\u093E\u0928\u093E",mac:"MAC \u0920\u0947\u0917\u093E\u0928\u093E",cidrv4:"IPv4 \u0926\u093E\u092F\u0930\u093E",cidrv6:"IPv6 \u0926\u093E\u092F\u0930\u093E",base64:"base64-\u0907\u0928\u094D\u0915\u094B\u0921 \u0917\u0930\u093F\u090F\u0915\u094B \u0938\u094D\u091F\u094D\u0930\u093F\u0919",base64url:"base64url-\u0907\u0928\u094D\u0915\u094B\u0921 \u0917\u0930\u093F\u090F\u0915\u094B \u0938\u094D\u091F\u094D\u0930\u093F\u0919",json_string:"JSON \u0938\u094D\u091F\u094D\u0930\u093F\u0919",e164:"E.164 \u0928\u092E\u094D\u092C\u0930",credit_card:"\u0915\u094D\u0930\u0947\u0921\u093F\u091F \u0915\u093E\u0930\u094D\u0921 \u0928\u092E\u094D\u092C\u0930",currency_code:"\u092E\u0941\u0926\u094D\u0930\u093E \u0915\u094B\u0921",iban:"IBAN",jwt:"JWT",template_literal:"\u0907\u0928\u092A\u0941\u091F"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${o}, \u092A\u094D\u0930\u093E\u092A\u094D\u0924 ${s}`}case"invalid_value":return r.values.length===1?`\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${ge(r.values[0])}`:`\u0905\u092E\u093E\u0928\u094D\u092F \u0935\u093F\u0915\u0932\u094D\u092A: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 \u092E\u093E\u0928\u0939\u0930\u0942 \u092E\u0927\u094D\u092F\u0947 \u090F\u0915 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0927\u0947\u0930\u0948 \u0920\u0942\u0932\u094B: ${r.origin??"\u092E\u093E\u0928"} \u092E\u093E ${o}${r.maximum.toString()} ${a.unit} ${a.verb}`:`\u0927\u0947\u0930\u0948 \u0920\u0942\u0932\u094B: ${r.origin??"\u092E\u093E\u0928"} ${o}${r.maximum.toString()} \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0927\u0947\u0930\u0948 \u0938\u093E\u0928\u094B: ${r.origin} \u092E\u093E ${o}${r.minimum.toString()} ${a.unit} ${a.verb}`:`\u0927\u0947\u0930\u0948 \u0938\u093E\u0928\u094B: ${r.origin} ${o}${r.minimum.toString()} \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${o.prefix}" \u092C\u093E\u091F \u0938\u0941\u0930\u0941 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:o.format==="ends_with"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${o.suffix}" \u092E\u093E \u0938\u092E\u093E\u092A\u094D\u0924 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:o.format==="includes"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: "${o.includes}" \u0938\u092E\u093E\u0935\u0947\u0936 \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`:o.format==="regex"?`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u094D\u091F\u094D\u0930\u093F\u0919: \u0922\u093E\u0901\u091A\u093E ${o.pattern} \u0938\u0901\u0917 \u092E\u0947\u0932 \u0916\u093E\u0928\u0941\u092A\u0930\u094D\u091B`:`\u0905\u092E\u093E\u0928\u094D\u092F ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0938\u0902\u0916\u094D\u092F\u093E: ${r.divisor} \u0915\u094B \u0917\u0941\u0923\u091C \u0939\u0941\u0928\u0941\u092A\u0930\u094D\u091B`;case"unrecognized_keys":return`\u0905\u092A\u0930\u093F\u091A\u093F\u0924 \u0915\u0941\u091E\u094D\u091C\u0940${r.keys.length>1?"\u0939\u0930\u0942":""}: ${G(r.keys,", ")}`;case"invalid_key":return`\u0905\u092E\u093E\u0928\u094D\u092F \u0915\u0941\u091E\u094D\u091C\u0940: ${r.origin} \u092E\u093E`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u0905\u092E\u093E\u0928\u094D\u092F \u0921\u093F\u0938\u094D\u0915\u094D\u0930\u093F\u092E\u093F\u0928\u0947\u091F\u0930 \u092E\u093E\u0928: \u0905\u092A\u0947\u0915\u094D\u0937\u093F\u0924 ${r.options.map(a=>`'${a}'`).join(" | ")}`:"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F";case"invalid_element":return`\u0905\u092E\u093E\u0928\u094D\u092F \u092E\u093E\u0928: ${r.origin} \u092E\u093E`;default:return"\u0905\u092E\u093E\u0928\u094D\u092F \u0907\u0928\u092A\u0941\u091F"}}};function ez(){return{localeError:tG()}}var nG=()=>{let e={string:{unit:"tekens",verb:"heeft"},file:{unit:"bytes",verb:"heeft"},array:{unit:"elementen",verb:"heeft"},set:{unit:"elementen",verb:"heeft"},map:{unit:"elementen",verb:"heeft"}};function t(r){return e[r]??null}let n={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",mac:"MAC-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",credit_card:"creditcardnummer",currency_code:"valutacode",iban:"IBAN",jwt:"JWT",template_literal:"invoer"},i={nan:"NaN",number:"getal"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ongeldige invoer: verwacht instanceof ${r.expected}, ontving ${s}`:`Ongeldige invoer: verwacht ${o}, ontving ${s}`}case"invalid_value":return r.values.length===1?`Ongeldige invoer: verwacht ${ge(r.values[0])}`:`Ongeldige optie: verwacht \xE9\xE9n van ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin),s=r.origin==="date"?"laat":r.origin==="string"?"lang":"groot";return a?`Te ${s}: verwacht dat ${r.origin??"waarde"} ${o}${r.maximum.toString()} ${a.unit??"elementen"} ${a.verb}`:`Te ${s}: verwacht dat ${r.origin??"waarde"} ${o}${r.maximum.toString()} is`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin),s=r.origin==="date"?"vroeg":r.origin==="string"?"kort":"klein";return a?`Te ${s}: verwacht dat ${r.origin} ${o}${r.minimum.toString()} ${a.unit} ${a.verb}`:`Te ${s}: verwacht dat ${r.origin} ${o}${r.minimum.toString()} is`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ongeldige tekst: moet met "${o.prefix}" beginnen`:o.format==="ends_with"?`Ongeldige tekst: moet op "${o.suffix}" eindigen`:o.format==="includes"?`Ongeldige tekst: moet "${o.includes}" bevatten`:o.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${o.pattern}`:`Ongeldig: ${n[o.format]??r.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${r.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${r.keys.length>1?"s":""}: ${G(r.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${r.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${r.origin}`;default:return"Ongeldige invoer"}}};function tz(){return{localeError:nG()}}var rG=()=>{let e={string:{unit:"teikn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"element",verb:"\xE5 innehalde"},set:{unit:"element",verb:"\xE5 innehalde"},map:{unit:"element",verb:"\xE5 innehalde"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varigheit",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkoda streng",base64url:"base64url-enkoda streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kredittkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tal",array:"liste"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ugyldig input: forventa instanceof ${r.expected}, fekk ${s}`:`Ugyldig input: forventa ${o}, fekk ${s}`}case"invalid_value":return r.values.length===1?`Ugyldig verdi: forventa ${ge(r.values[0])}`:`Ugyldig val: forventa eitt av ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`For stor(t): forventa ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()} ${a.unit??"element"}`:`For stor(t): forventa ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`For lite(n): forventa ${r.origin} til \xE5 ha ${o}${r.minimum.toString()} ${a.unit}`:`For lite(n): forventa ${r.origin} til \xE5 ha ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 slutte med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 innehalde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${n[o.format]??r.format}`}case"not_multiple_of":return`Ugyldig tal: m\xE5 vere eit multiplum av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukjende n\xF8klar":"Ukjend n\xF8kkel"}: ${G(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${r.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${r.origin}`;default:return"Ugyldig input"}}};function nz(){return{localeError:rG()}}var iG=()=>{let e={string:{unit:"tegn",verb:"\xE5 ha"},file:{unit:"bytes",verb:"\xE5 ha"},array:{unit:"elementer",verb:"\xE5 inneholde"},set:{unit:"elementer",verb:"\xE5 inneholde"},map:{unit:"elementer",verb:"\xE5 inneholde"}};function t(r){return e[r]??null}let n={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-adresse",ipv6:"IPv6-adresse",mac:"MAC-adresse",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",credit_card:"kredittkortnummer",currency_code:"valutakode",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"tall",array:"liste"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ugyldig input: forventet instanceof ${r.expected}, fikk ${s}`:`Ugyldig input: forventet ${o}, fikk ${s}`}case"invalid_value":return r.values.length===1?`Ugyldig verdi: forventet ${ge(r.values[0])}`:`Ugyldig valg: forventet en av ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${r.origin??"value"} til \xE5 ha ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`For lite(n): forventet ${r.origin} til \xE5 ha ${o}${r.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${r.origin} til \xE5 ha ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ugyldig streng: m\xE5 starte med "${o.prefix}"`:o.format==="ends_with"?`Ugyldig streng: m\xE5 ende med "${o.suffix}"`:o.format==="includes"?`Ugyldig streng: m\xE5 inneholde "${o.includes}"`:o.format==="regex"?`Ugyldig streng: m\xE5 matche m\xF8nsteret ${o.pattern}`:`Ugyldig ${n[o.format]??r.format}`}case"not_multiple_of":return`Ugyldig tall: m\xE5 v\xE6re et multiplum av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ukjente n\xF8kler":"Ukjent n\xF8kkel"}: ${G(r.keys,", ")}`;case"invalid_key":return`Ugyldig n\xF8kkel i ${r.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${r.origin}`;default:return"Ugyldig input"}}};function rz(){return{localeError:iG()}}var oG=()=>{let e={string:{unit:"harf",verb:"olmal\u0131d\u0131r"},file:{unit:"bayt",verb:"olmal\u0131d\u0131r"},array:{unit:"unsur",verb:"olmal\u0131d\u0131r"},set:{unit:"unsur",verb:"olmal\u0131d\u0131r"},map:{unit:"unsur",verb:"olmal\u0131d\u0131r"}};function t(r){return e[r]??null}let n={regex:"giren",email:"epostag\xE2h",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO heng\xE2m\u0131",date:"ISO tarihi",time:"ISO zaman\u0131",duration:"ISO m\xFCddeti",ipv4:"IPv4 ni\u015F\xE2n\u0131",ipv6:"IPv6 ni\u015F\xE2n\u0131",mac:"MAC ni\u015F\xE2n\u0131",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-\u015Fifreli metin",base64url:"base64url-\u015Fifreli metin",json_string:"JSON metin",e164:"E.164 say\u0131s\u0131",credit_card:"i'tib\xE2r kart\u0131 numaras\u0131",currency_code:"para birimi kodu",iban:"IBAN",jwt:"JWT",template_literal:"giren"},i={nan:"NaN",number:"numara",array:"saf",null:"gayb"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`F\xE2sit giren: umulan instanceof ${r.expected}, al\u0131nan ${s}`:`F\xE2sit giren: umulan ${o}, al\u0131nan ${s}`}case"invalid_value":return r.values.length===1?`F\xE2sit giren: umulan ${ge(r.values[0])}`:`F\xE2sit tercih: m\xFBteberler ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${o}${r.maximum.toString()} ${a.unit??"elements"} sahip olmal\u0131yd\u0131.`:`Fazla b\xFCy\xFCk: ${r.origin??"value"}, ${o}${r.maximum.toString()} olmal\u0131yd\u0131.`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${o}${r.minimum.toString()} ${a.unit} sahip olmal\u0131yd\u0131.`:`Fazla k\xFC\xE7\xFCk: ${r.origin}, ${o}${r.minimum.toString()} olmal\u0131yd\u0131.`}case"invalid_format":{let o=r;return o.format==="starts_with"?`F\xE2sit metin: "${o.prefix}" ile ba\u015Flamal\u0131.`:o.format==="ends_with"?`F\xE2sit metin: "${o.suffix}" ile bitmeli.`:o.format==="includes"?`F\xE2sit metin: "${o.includes}" ihtiv\xE2 etmeli.`:o.format==="regex"?`F\xE2sit metin: ${o.pattern} nak\u015F\u0131na uymal\u0131.`:`F\xE2sit ${n[o.format]??r.format}`}case"not_multiple_of":return`F\xE2sit say\u0131: ${r.divisor} kat\u0131 olmal\u0131yd\u0131.`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar ${r.keys.length>1?"s":""}: ${G(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7in tan\u0131nmayan anahtar var.`;case"invalid_union":return"Giren tan\u0131namad\u0131.";case"invalid_element":return`${r.origin} i\xE7in tan\u0131nmayan k\u0131ymet var.`;default:return"K\u0131ymet tan\u0131namad\u0131."}}};function iz(){return{localeError:oG()}}var aG=()=>{let e={string:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},file:{unit:"\u0628\u0627\u06CC\u067C\u0633",verb:"\u0648\u0644\u0631\u064A"},array:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},set:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"},map:{unit:"\u062A\u0648\u06A9\u064A",verb:"\u0648\u0644\u0631\u064A"}};function t(r){return e[r]??null}let n={regex:"\u0648\u0631\u0648\u062F\u064A",email:"\u0628\u0631\u06CC\u069A\u0646\u0627\u0644\u06CC\u06A9",url:"\u06CC\u0648 \u0622\u0631 \u0627\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u064A",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0646\u06CC\u067C\u0647 \u0627\u0648 \u0648\u062E\u062A",date:"\u0646\u06D0\u067C\u0647",time:"\u0648\u062E\u062A",duration:"\u0645\u0648\u062F\u0647",ipv4:"\u062F IPv4 \u067E\u062A\u0647",ipv6:"\u062F IPv6 \u067E\u062A\u0647",mac:"\u062F MAC \u067E\u062A\u0647",cidrv4:"\u062F IPv4 \u0633\u0627\u062D\u0647",cidrv6:"\u062F IPv6 \u0633\u0627\u062D\u0647",base64:"base64-encoded \u0645\u062A\u0646",base64url:"base64url-encoded \u0645\u062A\u0646",json_string:"JSON \u0645\u062A\u0646",e164:"\u062F E.164 \u0634\u0645\u06D0\u0631\u0647",credit_card:"\u062F \u06A9\u0631\u06CC\u0689\u06CC\u067C \u06A9\u0627\u0631\u062A \u0634\u0645\u06CC\u0631\u0647",currency_code:"\u062F \u0627\u0633\u0639\u0627\u0631\u0648 \u06A9\u0648\u0689",iban:"IBAN",jwt:"JWT",template_literal:"\u0648\u0631\u0648\u062F\u064A"},i={nan:"NaN",number:"\u0639\u062F\u062F",array:"\u0627\u0631\u06D0"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F instanceof ${r.expected} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`:`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${o} \u0648\u0627\u06CC, \u0645\u06AB\u0631 ${s} \u062A\u0631\u0644\u0627\u0633\u0647 \u0634\u0648`}case"invalid_value":return r.values.length===1?`\u0646\u0627\u0633\u0645 \u0648\u0631\u0648\u062F\u064A: \u0628\u0627\u06CC\u062F ${ge(r.values[0])} \u0648\u0627\u06CC`:`\u0646\u0627\u0633\u0645 \u0627\u0646\u062A\u062E\u0627\u0628: \u0628\u0627\u06CC\u062F \u06CC\u0648 \u0644\u0647 ${G(r.values,"|")} \u0685\u062E\u0647 \u0648\u0627\u06CC`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0635\u0631\u0648\u0646\u0647"} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u0644\u0648\u06CC: ${r.origin??"\u0627\u0631\u0632\u069A\u062A"} \u0628\u0627\u06CC\u062F ${o}${r.maximum.toString()} \u0648\u064A`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} ${a.unit} \u0648\u0644\u0631\u064A`:`\u0689\u06CC\u0631 \u06A9\u0648\u0686\u0646\u06CC: ${r.origin} \u0628\u0627\u06CC\u062F ${o}${r.minimum.toString()} \u0648\u064A`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.prefix}" \u0633\u0631\u0647 \u067E\u06CC\u0644 \u0634\u064A`:o.format==="ends_with"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F "${o.suffix}" \u0633\u0631\u0647 \u067E\u0627\u06CC \u062A\u0647 \u0648\u0631\u0633\u064A\u0696\u064A`:o.format==="includes"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F "${o.includes}" \u0648\u0644\u0631\u064A`:o.format==="regex"?`\u0646\u0627\u0633\u0645 \u0645\u062A\u0646: \u0628\u0627\u06CC\u062F \u062F ${o.pattern} \u0633\u0631\u0647 \u0645\u0637\u0627\u0628\u0642\u062A \u0648\u0644\u0631\u064A`:`${n[o.format]??r.format} \u0646\u0627\u0633\u0645 \u062F\u06CC`}case"not_multiple_of":return`\u0646\u0627\u0633\u0645 \u0639\u062F\u062F: \u0628\u0627\u06CC\u062F \u062F ${r.divisor} \u0645\u0636\u0631\u0628 \u0648\u064A`;case"unrecognized_keys":return`\u0646\u0627\u0633\u0645 ${r.keys.length>1?"\u06A9\u0644\u06CC\u0689\u0648\u0646\u0647":"\u06A9\u0644\u06CC\u0689"}: ${G(r.keys,", ")}`;case"invalid_key":return`\u0646\u0627\u0633\u0645 \u06A9\u0644\u06CC\u0689 \u067E\u0647 ${r.origin} \u06A9\u06D0`;case"invalid_union":return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A";case"invalid_element":return`\u0646\u0627\u0633\u0645 \u0639\u0646\u0635\u0631 \u067E\u0647 ${r.origin} \u06A9\u06D0`;default:return"\u0646\u0627\u0633\u0645\u0647 \u0648\u0631\u0648\u062F\u064A"}}};function oz(){return{localeError:aG()}}var sG=()=>{let e={string:{unit:"znak\xF3w",verb:"mie\u0107"},file:{unit:"bajt\xF3w",verb:"mie\u0107"},array:{unit:"element\xF3w",verb:"mie\u0107"},set:{unit:"element\xF3w",verb:"mie\u0107"},map:{unit:"element\xF3w",verb:"mie\u0107"}};function t(r){return e[r]??null}let n={regex:"wyra\u017Cenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",mac:"adres MAC",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ci\u0105g znak\xF3w zakodowany w formacie base64",base64url:"ci\u0105g znak\xF3w zakodowany w formacie base64url",json_string:"ci\u0105g znak\xF3w w formacie JSON",e164:"liczba E.164",credit_card:"numer karty kredytowej",currency_code:"kod waluty",iban:"IBAN",jwt:"JWT",template_literal:"wej\u015Bcie"},i={nan:"NaN",number:"liczba",array:"tablica"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano instanceof ${r.expected}, otrzymano ${s}`:`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${o}, otrzymano ${s}`}case"invalid_value":return r.values.length===1?`Nieprawid\u0142owe dane wej\u015Bciowe: oczekiwano ${ge(r.values[0])}`:`Nieprawid\u0142owa opcja: oczekiwano jednej z warto\u015Bci ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Za du\u017Ca warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${r.maximum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt du\u017C(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Za ma\u0142a warto\u015B\u0107: oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie mie\u0107 ${o}${r.minimum.toString()} ${a.unit??"element\xF3w"}`:`Zbyt ma\u0142(y/a/e): oczekiwano, \u017Ce ${r.origin??"warto\u015B\u0107"} b\u0119dzie wynosi\u0107 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zaczyna\u0107 si\u0119 od "${o.prefix}"`:o.format==="ends_with"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi ko\u0144czy\u0107 si\u0119 na "${o.suffix}"`:o.format==="includes"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi zawiera\u0107 "${o.includes}"`:o.format==="regex"?`Nieprawid\u0142owy ci\u0105g znak\xF3w: musi odpowiada\u0107 wzorcowi ${o.pattern}`:`Nieprawid\u0142ow(y/a/e) ${n[o.format]??r.format}`}case"not_multiple_of":return`Nieprawid\u0142owa liczba: musi by\u0107 wielokrotno\u015Bci\u0105 ${r.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${r.keys.length>1?"s":""}: ${G(r.keys,", ")}`;case"invalid_key":return`Nieprawid\u0142owy klucz w ${r.origin}`;case"invalid_union":return"Nieprawid\u0142owe dane wej\u015Bciowe";case"invalid_element":return`Nieprawid\u0142owa warto\u015B\u0107 w ${r.origin}`;default:return"Nieprawid\u0142owe dane wej\u015Bciowe"}}};function az(){return{localeError:sG()}}var cG=()=>{let e={string:{unit:"caracteres"},file:{unit:"bytes"},array:{unit:"elementos"},set:{unit:"elementos"},map:{unit:"entradas"}};function t(a){return e[a]??null}let n={regex:"a entrada",email:"o endere\xE7o de e-mail",url:"o URL",emoji:"o emoji",uuid:"o UUID",uuidv4:"o UUIDv4",uuidv6:"o UUIDv6",nanoid:"o nanoid",guid:"o GUID",cuid:"o cuid",cuid2:"o cuid2",ulid:"o ULID",xid:"o XID",ksuid:"o KSUID",datetime:"a data e hora ISO",date:"a data ISO",time:"a hora ISO",duration:"a dura\xE7\xE3o ISO",ipv4:"o endere\xE7o IPv4",ipv6:"o endere\xE7o IPv6",mac:"o endere\xE7o MAC",cidrv4:"o intervalo de endere\xE7os IPv4",cidrv6:"o intervalo de endere\xE7os IPv6",base64:"o texto codificado em base64",base64url:"o texto codificado em base64url",json_string:"o texto JSON",e164:"o n\xFAmero E.164",credit_card:"o n\xFAmero de cart\xE3o de cr\xE9dito",currency_code:"o c\xF3digo de moeda",iban:"o IBAN",jwt:"o JWT",template_literal:"a entrada"},i={masculine:{definite:"o",indefinite:"um"},feminine:{definite:"a",indefinite:"uma"}},r={string:{name:"texto",articles:i.masculine},number:{name:"n\xFAmero",articles:i.masculine},int:{name:"n\xFAmero inteiro",articles:i.masculine},boolean:{name:"valor booleano",articles:i.masculine},bigint:{name:"n\xFAmero bigint",articles:i.masculine},symbol:{name:"s\xEDmbolo",articles:i.masculine},undefined:{name:'valor "undefined"',articles:i.masculine},null:{name:'valor "nulo"',articles:i.masculine},never:{name:'valor "never"',articles:i.masculine},void:{name:'valor "void"',articles:i.masculine},date:{name:"data",articles:i.feminine},array:{name:"vetor",articles:i.masculine},object:{name:"objeto",articles:i.masculine},tuple:{name:"tuplo",articles:i.masculine},record:{name:"registo",articles:i.masculine},map:{name:"mapa",articles:i.masculine},set:{name:"conjunto",articles:i.masculine},file:{name:"ficheiro",articles:i.masculine},nonoptional:{name:"valor n\xE3o opcional",articles:i.masculine},nan:{name:'valor "NaN"',articles:i.masculine},function:{name:"fun\xE7\xE3o",articles:i.feminine}};function o(a,s){let c=r[a]??{name:`valor "${a}"`,articles:i.masculine};return`${c.articles[s]} ${c.name}`}return a=>{switch(a.code){case"invalid_type":{let s=o(a.expected,"indefinite"),c=ye(a.input),l=o(c,"indefinite");return`Entrada inv\xE1lida: esperava ${s}, recebeu ${l}`}case"invalid_value":return a.values.length===1?`Entrada inv\xE1lida: esperava ${ge(a.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperava uma das seguintes op\xE7\xF5es: ${G(a.values,"|")}`;case"too_big":{let s=a.inclusive?"<=":"<",c=t(a.origin);return c?`Demasiado grande: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.maximum.toString()} ${c.unit??"elementos"}`:`Demasiado grande: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.maximum.toString()}`}case"too_small":{let s=a.inclusive?">=":">",c=t(a.origin);return c?`Demasiado pequeno: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.minimum.toString()} ${c.unit??"elementos"}`:`Demasiado pequeno: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.minimum.toString()}`}case"invalid_format":{let s=a;return s.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar por "${s.prefix}"`:s.format==="ends_with"?`Texto inv\xE1lido: deve terminar em "${s.suffix}"`:s.format==="includes"?`Texto inv\xE1lido: deve incluir "${s.includes}"`:s.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${s.pattern}`:`Formato d${n[s.format]??a.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${a.divisor}`;case"unrecognized_keys":{let s=a.keys.length>1?"s":"";return`Chave${s} inv\xE1lida${s}: ${G(a.keys,", ")}`}case"invalid_key":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;case"invalid_union":return a.options&&Array.isArray(a.options)&&a.options.length>0?`Valor de discrimina\xE7\xE3o inv\xE1lido. Esperava ${a.options.map(c=>`'${c}'`).join(" | ")}`:"Entrada inv\xE1lida";case"invalid_element":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;default:return"Entrada inv\xE1lida"}}};function sz(){return{localeError:cG()}}var lG=()=>{let e={string:{unit:"caracteres"},file:{unit:"bytes"},array:{unit:"elementos"},set:{unit:"elementos"},map:{unit:"entradas"}};function t(a){return e[a]??null}let n={regex:"a entrada",email:"o endere\xE7o de e-mail",url:"o URL",emoji:"o emoji",uuid:"o UUID",uuidv4:"o UUIDv4",uuidv6:"o UUIDv6",nanoid:"o nanoid",guid:"o GUID",cuid:"o cuid",cuid2:"o cuid2",ulid:"o ULID",xid:"o XID",ksuid:"o KSUID",datetime:"a data e hora ISO",date:"a data ISO",time:"a hora ISO",duration:"a dura\xE7\xE3o ISO",ipv4:"o endere\xE7o IPv4",ipv6:"o endere\xE7o IPv6",mac:"o endere\xE7o MAC",cidrv4:"a faixa de endere\xE7os IPv4",cidrv6:"a faixa de endere\xE7os IPv6",base64:"o texto codificado em base64",base64url:"o texto codificado em base64url",json_string:"o texto JSON",e164:"o n\xFAmero E.164",credit_card:"o n\xFAmero de cart\xE3o de cr\xE9dito",currency_code:"o c\xF3digo de moeda",iban:"o IBAN",jwt:"o JWT",template_literal:"a entrada"},i={masculine:{definite:"o",indefinite:"um"},feminine:{definite:"a",indefinite:"uma"}},r={string:{name:"texto",articles:i.masculine},number:{name:"n\xFAmero",articles:i.masculine},int:{name:"n\xFAmero inteiro",articles:i.masculine},boolean:{name:"valor booleano",articles:i.masculine},bigint:{name:"n\xFAmero bigint",articles:i.masculine},symbol:{name:"s\xEDmbolo",articles:i.masculine},undefined:{name:'valor "undefined"',articles:i.masculine},null:{name:'valor "nulo"',articles:i.masculine},never:{name:'valor "never"',articles:i.masculine},void:{name:'valor "void"',articles:i.masculine},date:{name:"data",articles:i.feminine},array:{name:"vetor",articles:i.masculine},object:{name:"objeto",articles:i.masculine},tuple:{name:"tupla",articles:i.feminine},record:{name:"registro",articles:i.masculine},map:{name:"mapa",articles:i.masculine},set:{name:"conjunto",articles:i.masculine},file:{name:"arquivo",articles:i.masculine},nonoptional:{name:"valor n\xE3o opcional",articles:i.masculine},nan:{name:'valor "NaN"',articles:i.masculine},function:{name:"fun\xE7\xE3o",articles:i.feminine}};function o(a,s){let c=r[a]??{name:`valor "${a}"`,articles:i.masculine};return`${c.articles[s]} ${c.name}`}return a=>{switch(a.code){case"invalid_type":{let s=o(a.expected,"indefinite"),c=ye(a.input),l=o(c,"indefinite");return`Entrada inv\xE1lida: esperava ${s}, recebeu ${l}`}case"invalid_value":return a.values.length===1?`Entrada inv\xE1lida: esperava ${ge(a.values[0])}`:`Op\xE7\xE3o inv\xE1lida: esperava uma das seguintes op\xE7\xF5es: ${G(a.values,"|")}`;case"too_big":{let s=a.inclusive?"<=":"<",c=t(a.origin);return c?`Grande demais: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.maximum.toString()} ${c.unit??"elementos"}`:`Grande demais: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.maximum.toString()}`}case"too_small":{let s=a.inclusive?">=":">",c=t(a.origin);return c?`Pequeno demais: esperava que ${o(a.origin,"definite")} tivesse ${s} ${a.minimum.toString()} ${c.unit??"elementos"}`:`Pequeno demais: esperava que ${o(a.origin,"definite")} fosse ${s} ${a.minimum.toString()}`}case"invalid_format":{let s=a;return s.format==="starts_with"?`Texto inv\xE1lido: deve come\xE7ar com "${s.prefix}"`:s.format==="ends_with"?`Texto inv\xE1lido: deve terminar com "${s.suffix}"`:s.format==="includes"?`Texto inv\xE1lido: deve incluir "${s.includes}"`:s.format==="regex"?`Texto inv\xE1lido: deve corresponder ao padr\xE3o ${s.pattern}`:`Formato d${n[s.format]??a.format} inv\xE1lido`}case"not_multiple_of":return`N\xFAmero inv\xE1lido: deve ser m\xFAltiplo de ${a.divisor}`;case"unrecognized_keys":{let s=a.keys.length>1?"s":"";return`Chave${s} inv\xE1lida${s}: ${G(a.keys,", ")}`}case"invalid_key":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;case"invalid_union":return a.options&&Array.isArray(a.options)&&a.options.length>0?`Valor de discrimina\xE7\xE3o inv\xE1lido. Esperava ${a.options.map(c=>`'${c}'`).join(" | ")}`:"Entrada inv\xE1lida";case"invalid_element":return`Entrada inv\xE1lida n${o(a.origin,"definite")}`;default:return"Entrada inv\xE1lida"}}};function cz(){return{localeError:lG()}}var uG=()=>{let e={string:{unit:"caractere",verb:"s\u0103 aib\u0103"},file:{unit:"octe\u021Bi",verb:"s\u0103 aib\u0103"},array:{unit:"elemente",verb:"s\u0103 aib\u0103"},set:{unit:"elemente",verb:"s\u0103 aib\u0103"},map:{unit:"intr\u0103ri",verb:"s\u0103 aib\u0103"}};function t(r){return e[r]??null}let n={regex:"intrare",email:"adres\u0103 de email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"dat\u0103 \u0219i or\u0103 ISO",date:"dat\u0103 ISO",time:"or\u0103 ISO",duration:"durat\u0103 ISO",ipv4:"adres\u0103 IPv4",ipv6:"adres\u0103 IPv6",mac:"adres\u0103 MAC",cidrv4:"interval IPv4",cidrv6:"interval IPv6",base64:"\u0219ir codat base64",base64url:"\u0219ir codat base64url",json_string:"\u0219ir JSON",e164:"num\u0103r E.164",credit_card:"num\u0103r de card de credit",currency_code:"cod valutar",iban:"IBAN",jwt:"JWT",template_literal:"intrare"},i={nan:"NaN",string:"\u0219ir",number:"num\u0103r",boolean:"boolean",function:"func\u021Bie",array:"matrice",object:"obiect",undefined:"nedefinit",symbol:"simbol",bigint:"num\u0103r mare",void:"void",never:"never",map:"hart\u0103",set:"set"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return`Intrare invalid\u0103: a\u0219teptat ${o}, primit ${s}`}case"invalid_value":return r.values.length===1?`Intrare invalid\u0103: a\u0219teptat ${ge(r.values[0])}`:`Op\u021Biune invalid\u0103: a\u0219teptat una dintre ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Prea mare: a\u0219teptat ca ${r.origin??"valoarea"} ${a.verb} ${o}${r.maximum.toString()} ${a.unit??"elemente"}`:`Prea mare: a\u0219teptat ca ${r.origin??"valoarea"} s\u0103 fie ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Prea mic: a\u0219teptat ca ${r.origin} ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`Prea mic: a\u0219teptat ca ${r.origin} s\u0103 fie ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0218ir invalid: trebuie s\u0103 \xEEnceap\u0103 cu "${o.prefix}"`:o.format==="ends_with"?`\u0218ir invalid: trebuie s\u0103 se termine cu "${o.suffix}"`:o.format==="includes"?`\u0218ir invalid: trebuie s\u0103 includ\u0103 "${o.includes}"`:o.format==="regex"?`\u0218ir invalid: trebuie s\u0103 se potriveasc\u0103 cu modelul ${o.pattern}`:`Format invalid: ${n[o.format]??r.format}`}case"not_multiple_of":return`Num\u0103r invalid: trebuie s\u0103 fie multiplu de ${r.divisor}`;case"unrecognized_keys":return`Chei nerecunoscute: ${G(r.keys,", ")}`;case"invalid_key":return`Cheie invalid\u0103 \xEEn ${r.origin}`;case"invalid_union":return"Intrare invalid\u0103";case"invalid_element":return`Valoare invalid\u0103 \xEEn ${r.origin}`;default:return"Intrare invalid\u0103"}}};function lz(){return{localeError:uG()}}function uz(e,t,n,i){let r=Math.abs(e),o=r%10,a=r%100;return a>=11&&a<=19?i:o===1?t:o>=2&&o<=4?n:i}var fG=()=>{let e={string:{unit:{one:"\u0441\u0438\u043C\u0432\u043E\u043B",few:"\u0441\u0438\u043C\u0432\u043E\u043B\u0430",many:"\u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},file:{unit:{one:"\u0431\u0430\u0439\u0442",few:"\u0431\u0430\u0439\u0442\u0430",many:"\u0431\u0430\u0439\u0442"},verb:"\u0438\u043C\u0435\u0442\u044C"},array:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},set:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"},map:{unit:{one:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442",few:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u0430",many:"\u044D\u043B\u0435\u043C\u0435\u043D\u0442\u043E\u0432"},verb:"\u0438\u043C\u0435\u0442\u044C"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0432\u043E\u0434",email:"email \u0430\u0434\u0440\u0435\u0441",url:"URL",emoji:"\u044D\u043C\u043E\u0434\u0437\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",date:"ISO \u0434\u0430\u0442\u0430",time:"ISO \u0432\u0440\u0435\u043C\u044F",duration:"ISO \u0434\u043B\u0438\u0442\u0435\u043B\u044C\u043D\u043E\u0441\u0442\u044C",ipv4:"IPv4 \u0430\u0434\u0440\u0435\u0441",ipv6:"IPv6 \u0430\u0434\u0440\u0435\u0441",mac:"MAC \u0430\u0434\u0440\u0435\u0441",cidrv4:"IPv4 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",cidrv6:"IPv6 \u0434\u0438\u0430\u043F\u0430\u0437\u043E\u043D",base64:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64",base64url:"\u0441\u0442\u0440\u043E\u043A\u0430 \u0432 \u0444\u043E\u0440\u043C\u0430\u0442\u0435 base64url",json_string:"JSON \u0441\u0442\u0440\u043E\u043A\u0430",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u043E\u0439 \u043A\u0430\u0440\u0442\u044B",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u044B",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0432\u043E\u0434"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C instanceof ${r.expected}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${o}, \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u043E ${s}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0432\u043E\u0434: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C ${ge(r.values[0])}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u0432\u0430\u0440\u0438\u0430\u043D\u0442: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C \u043E\u0434\u043D\u043E \u0438\u0437 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);if(a){let s=Number(r.maximum),c=uz(s,a.unit.one,a.unit.few,a.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${r.maximum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0431\u043E\u043B\u044C\u0448\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"} \u0431\u0443\u0434\u0435\u0442 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);if(a){let s=Number(r.minimum),c=uz(s,a.unit.one,a.unit.few,a.unit.many);return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 \u0438\u043C\u0435\u0442\u044C ${o}${r.minimum.toString()} ${c}`}return`\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435: \u043E\u0436\u0438\u0434\u0430\u043B\u043E\u0441\u044C, \u0447\u0442\u043E ${r.origin} \u0431\u0443\u0434\u0435\u0442 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u043D\u0430\u0447\u0438\u043D\u0430\u0442\u044C\u0441\u044F \u0441 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0437\u0430\u043A\u0430\u043D\u0447\u0438\u0432\u0430\u0442\u044C\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u0434\u0435\u0440\u0436\u0430\u0442\u044C "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u0432\u0435\u0440\u043D\u0430\u044F \u0441\u0442\u0440\u043E\u043A\u0430: \u0434\u043E\u043B\u0436\u043D\u0430 \u0441\u043E\u043E\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043E\u0432\u0430\u0442\u044C \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0447\u0438\u0441\u043B\u043E: \u0434\u043E\u043B\u0436\u043D\u043E \u0431\u044B\u0442\u044C \u043A\u0440\u0430\u0442\u043D\u044B\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u0430\u0441\u043F\u043E\u0437\u043D\u0430\u043D\u043D${r.keys.length>1?"\u044B\u0435":"\u044B\u0439"} \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0438":""}: ${G(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0439 \u043A\u043B\u044E\u0447 \u0432 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435";case"invalid_element":return`\u041D\u0435\u0432\u0435\u0440\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 \u0432 ${r.origin}`;default:return"\u041D\u0435\u0432\u0435\u0440\u043D\u044B\u0435 \u0432\u0445\u043E\u0434\u043D\u044B\u0435 \u0434\u0430\u043D\u043D\u044B\u0435"}}};function fz(){return{localeError:fG()}}var dG=()=>{let e={string:{unit:"znakov",verb:"ma\u0165"},file:{unit:"bajtov",verb:"ma\u0165"},array:{unit:"prvkov",verb:"ma\u0165"},set:{unit:"prvkov",verb:"ma\u0165"},map:{unit:"polo\u017Eiek",verb:"ma\u0165"}};function t(r){return e[r]??null}let n={regex:"regul\xE1rny v\xFDraz",email:"e-mailov\xE1 adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"d\xE1tum a \u010Das vo form\xE1te ISO",date:"d\xE1tum vo form\xE1te ISO",time:"\u010Das vo form\xE1te ISO",duration:"doba trvania ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",mac:"MAC adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"re\u0165azec zak\xF3dovan\xFD vo form\xE1te base64",base64url:"re\u0165azec zak\xF3dovan\xFD vo form\xE1te base64url",json_string:"re\u0165azec vo form\xE1te JSON",e164:"\u010D\xEDslo E.164",credit_card:"\u010D\xEDslo kreditnej karty",currency_code:"k\xF3d meny",iban:"IBAN",jwt:"JWT",template_literal:"vstup"},i={nan:"NaN",number:"\u010D\xEDslo",string:"re\u0165azec",function:"funkcia",array:"pole"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 instanceof ${r.expected}, obdr\u017Ean\xE9 ${s}`:`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 ${o}, obdr\u017Ean\xE9 ${s}`}case"invalid_value":return r.values.length===1?`Neplatn\xFD vstup: o\u010Dak\xE1van\xE9 ${ge(r.values[0])}`:`Neplatn\xFD vstup: o\u010Dak\xE1van\xE1 jedna z hodn\xF4t ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Hodnota je pr\xEDli\u0161 ve\u013Ek\xE1: ${r.origin??"hodnota"} mus\xED ma\u0165 ${o}${r.maximum.toString()} ${a.unit??"prvkov"}`:`Hodnota je pr\xEDli\u0161 ve\u013Ek\xE1: ${r.origin??"hodnota"} mus\xED by\u0165 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Hodnota je pr\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED ma\u0165 ${o}${r.minimum.toString()} ${a.unit??"prvkov"}`:`Hodnota je pr\xEDli\u0161 mal\xE1: ${r.origin??"hodnota"} mus\xED by\u0165 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neplatn\xFD re\u0165azec: mus\xED za\u010D\xEDna\u0165 na "${o.prefix}"`:o.format==="ends_with"?`Neplatn\xFD re\u0165azec: mus\xED kon\u010Di\u0165 na "${o.suffix}"`:o.format==="includes"?`Neplatn\xFD re\u0165azec: mus\xED obsahova\u0165 "${o.includes}"`:o.format==="regex"?`Neplatn\xFD re\u0165azec: mus\xED zodpoveda\u0165 vzoru ${o.pattern}`:`Neplatn\xFD form\xE1t ${n[o.format]??r.format}`}case"not_multiple_of":return`Neplatn\xE9 \u010D\xEDslo: mus\xED by\u0165 n\xE1sobkom ${r.divisor}`;case"unrecognized_keys":return`Nezn\xE1me kl\xFA\u010De: ${G(r.keys,", ")}`;case"invalid_key":return`Neplatn\xFD kl\xFA\u010D v ${r.origin}`;case"invalid_union":return"Neplatn\xFD vstup";case"invalid_element":return`Neplatn\xE1 hodnota v ${r.origin}`;default:return"Neplatn\xFD vstup"}}};function dz(){return{localeError:dG()}}var mG=()=>{let e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"},map:{unit:"elementov",verb:"imeti"}};function t(r){return e[r]??null}let n={regex:"vnos",email:"e-po\u0161tni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in \u010Das",date:"ISO datum",time:"ISO \u010Das",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",mac:"MAC naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 \u0161tevilka",credit_card:"\u0161tevilka kreditne kartice",currency_code:"koda valute",iban:"IBAN",jwt:"JWT",template_literal:"vnos"},i={nan:"NaN",number:"\u0161tevilo",array:"tabela"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Neveljaven vnos: pri\u010Dakovano instanceof ${r.expected}, prejeto ${s}`:`Neveljaven vnos: pri\u010Dakovano ${o}, prejeto ${s}`}case"invalid_value":return r.values.length===1?`Neveljaven vnos: pri\u010Dakovano ${ge(r.values[0])}`:`Neveljavna mo\u017Enost: pri\u010Dakovano eno izmed ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} imelo ${o}${r.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pri\u010Dakovano, da bo ${r.origin??"vrednost"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Premajhno: pri\u010Dakovano, da bo ${r.origin} imelo ${o}${r.minimum.toString()} ${a.unit}`:`Premajhno: pri\u010Dakovano, da bo ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Neveljaven niz: mora se za\u010Deti z "${o.prefix}"`:o.format==="ends_with"?`Neveljaven niz: mora se kon\u010Dati z "${o.suffix}"`:o.format==="includes"?`Neveljaven niz: mora vsebovati "${o.includes}"`:o.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${o.pattern}`:`Neveljaven ${n[o.format]??r.format}`}case"not_multiple_of":return`Neveljavno \u0161tevilo: mora biti ve\u010Dkratnik ${r.divisor}`;case"unrecognized_keys":return`Neprepoznan${r.keys.length>1?"i klju\u010Di":" klju\u010D"}: ${G(r.keys,", ")}`;case"invalid_key":return`Neveljaven klju\u010D v ${r.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${r.origin}`;default:return"Neveljaven vnos"}}};function mz(){return{localeError:mG()}}var pG=()=>{let e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att inneh\xE5lla"},set:{unit:"objekt",verb:"att inneh\xE5lla"},map:{unit:"objekt",verb:"att inneh\xE5lla"}};function t(r){return e[r]??null}let n={regex:"regulj\xE4rt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-adress",ipv6:"IPv6-adress",mac:"MAC-adress",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad str\xE4ng",base64url:"base64url-kodad str\xE4ng",json_string:"JSON-str\xE4ng",e164:"E.164-nummer",credit_card:"kreditkortsnummer",currency_code:"valutakod",iban:"IBAN",jwt:"JWT",template_literal:"mall-literal"},i={nan:"NaN",number:"antal",array:"lista"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ogiltig inmatning: f\xF6rv\xE4ntat instanceof ${r.expected}, fick ${s}`:`Ogiltig inmatning: f\xF6rv\xE4ntat ${o}, fick ${s}`}case"invalid_value":return r.values.length===1?`Ogiltig inmatning: f\xF6rv\xE4ntat ${ge(r.values[0])}`:`Ogiltigt val: f\xF6rv\xE4ntade en av ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`F\xF6r stor(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.maximum.toString()} ${a.unit??"element"}`:`F\xF6r stor(t): f\xF6rv\xE4ntat ${r.origin??"v\xE4rdet"} att ha ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.minimum.toString()} ${a.unit}`:`F\xF6r lite(t): f\xF6rv\xE4ntade ${r.origin??"v\xE4rdet"} att ha ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ogiltig str\xE4ng: m\xE5ste b\xF6rja med "${o.prefix}"`:o.format==="ends_with"?`Ogiltig str\xE4ng: m\xE5ste sluta med "${o.suffix}"`:o.format==="includes"?`Ogiltig str\xE4ng: m\xE5ste inneh\xE5lla "${o.includes}"`:o.format==="regex"?`Ogiltig str\xE4ng: m\xE5ste matcha m\xF6nstret "${o.pattern}"`:`Ogiltig(t) ${n[o.format]??r.format}`}case"not_multiple_of":return`Ogiltigt tal: m\xE5ste vara en multipel av ${r.divisor}`;case"unrecognized_keys":return`${r.keys.length>1?"Ok\xE4nda nycklar":"Ok\xE4nd nyckel"}: ${G(r.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${r.origin??"v\xE4rdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt v\xE4rde i ${r.origin??"v\xE4rdet"}`;default:return"Ogiltig input"}}};function pz(){return{localeError:pG()}}var hG=()=>{let e={string:{unit:"\u0B8E\u0BB4\u0BC1\u0BA4\u0BCD\u0BA4\u0BC1\u0B95\u0BCD\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},file:{unit:"\u0BAA\u0BC8\u0B9F\u0BCD\u0B9F\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},array:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},set:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"},map:{unit:"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD",verb:"\u0B95\u0BCA\u0BA3\u0BCD\u0B9F\u0BBF\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD"}};function t(r){return e[r]??null}let n={regex:"\u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1",email:"\u0BAE\u0BBF\u0BA9\u0BCD\u0BA9\u0B9E\u0BCD\u0B9A\u0BB2\u0BCD \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u0BA4\u0BC7\u0BA4\u0BBF \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",date:"ISO \u0BA4\u0BC7\u0BA4\u0BBF",time:"ISO \u0BA8\u0BC7\u0BB0\u0BAE\u0BCD",duration:"ISO \u0B95\u0BBE\u0BB2 \u0B85\u0BB3\u0BB5\u0BC1",ipv4:"IPv4 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",ipv6:"IPv6 \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",mac:"MAC \u0BAE\u0BC1\u0B95\u0BB5\u0BB0\u0BBF",cidrv4:"IPv4 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",cidrv6:"IPv6 \u0BB5\u0BB0\u0BAE\u0BCD\u0BAA\u0BC1",base64:"base64-encoded \u0B9A\u0BB0\u0BAE\u0BCD",base64url:"base64url-encoded \u0B9A\u0BB0\u0BAE\u0BCD",json_string:"JSON \u0B9A\u0BB0\u0BAE\u0BCD",e164:"E.164 \u0B8E\u0BA3\u0BCD",credit_card:"\u0B95\u0B9F\u0BA9\u0BCD \u0B85\u0B9F\u0BCD\u0B9F\u0BC8 \u0B8E\u0BA3\u0BCD",currency_code:"\u0BA8\u0BBE\u0BA3\u0BAF\u0B95\u0BCD \u0B95\u0BC1\u0BB1\u0BBF\u0BAF\u0BC0\u0B9F\u0BC1",iban:"IBAN",jwt:"JWT",template_literal:"input"},i={nan:"NaN",number:"\u0B8E\u0BA3\u0BCD",array:"\u0B85\u0BA3\u0BBF",null:"\u0BB5\u0BC6\u0BB1\u0BC1\u0BAE\u0BC8"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 instanceof ${r.expected}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${o}, \u0BAA\u0BC6\u0BB1\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${s}`}case"invalid_value":return r.values.length===1?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${ge(r.values[0])}`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0BB0\u0BC1\u0BAA\u0BCD\u0BAA\u0BAE\u0BCD: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${G(r.values,"|")} \u0B87\u0BB2\u0BCD \u0B92\u0BA9\u0BCD\u0BB1\u0BC1`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${r.maximum.toString()} ${a.unit??"\u0B89\u0BB1\u0BC1\u0BAA\u0BCD\u0BAA\u0BC1\u0B95\u0BB3\u0BCD"} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95 \u0BAA\u0BC6\u0BB0\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin??"\u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1"} ${o}${r.maximum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${o}${r.minimum.toString()} ${a.unit} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BAE\u0BBF\u0B95\u0B9A\u0BCD \u0B9A\u0BBF\u0BB1\u0BBF\u0BAF\u0BA4\u0BC1: \u0B8E\u0BA4\u0BBF\u0BB0\u0BCD\u0BAA\u0BBE\u0BB0\u0BCD\u0B95\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0B9F\u0BCD\u0B9F\u0BA4\u0BC1 ${r.origin} ${o}${r.minimum.toString()} \u0B86\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.prefix}" \u0B87\u0BB2\u0BCD \u0BA4\u0BCA\u0B9F\u0B99\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="ends_with"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.suffix}" \u0B87\u0BB2\u0BCD \u0BAE\u0BC1\u0B9F\u0BBF\u0BB5\u0B9F\u0BC8\u0BAF \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="includes"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: "${o.includes}" \u0B90 \u0B89\u0BB3\u0BCD\u0BB3\u0B9F\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:o.format==="regex"?`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B9A\u0BB0\u0BAE\u0BCD: ${o.pattern} \u0BAE\u0BC1\u0BB1\u0BC8\u0BAA\u0BBE\u0B9F\u0BCD\u0B9F\u0BC1\u0B9F\u0BA9\u0BCD \u0BAA\u0BCA\u0BB0\u0BC1\u0BA8\u0BCD\u0BA4 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`:`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B8E\u0BA3\u0BCD: ${r.divisor} \u0B87\u0BA9\u0BCD \u0BAA\u0BB2\u0BAE\u0BBE\u0B95 \u0B87\u0BB0\u0BC1\u0B95\u0BCD\u0B95 \u0BB5\u0BC7\u0BA3\u0BCD\u0B9F\u0BC1\u0BAE\u0BCD`;case"unrecognized_keys":return`\u0B85\u0B9F\u0BC8\u0BAF\u0BBE\u0BB3\u0BAE\u0BCD \u0BA4\u0BC6\u0BB0\u0BBF\u0BAF\u0BBE\u0BA4 \u0BB5\u0BBF\u0B9A\u0BC8${r.keys.length>1?"\u0B95\u0BB3\u0BCD":""}: ${G(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BB5\u0BBF\u0B9A\u0BC8`;case"invalid_union":return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1";case"invalid_element":return`${r.origin} \u0B87\u0BB2\u0BCD \u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0BAE\u0BA4\u0BBF\u0BAA\u0BCD\u0BAA\u0BC1`;default:return"\u0BA4\u0BB5\u0BB1\u0BBE\u0BA9 \u0B89\u0BB3\u0BCD\u0BB3\u0BC0\u0B9F\u0BC1"}}};function hz(){return{localeError:hG()}}var bG=()=>{let e={string:{unit:"\u0430\u043B\u043E\u043C\u0430\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},file:{unit:"\u0431\u0430\u0439\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},array:{unit:"\u0443\u043D\u0441\u0443\u0440",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},set:{unit:"\u0443\u043D\u0441\u0443\u0440",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"},map:{unit:"\u0441\u0430\u0431\u0442",verb:"\u0434\u043E\u0448\u0442\u0430 \u0431\u043E\u0448\u0430\u0434"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0443\u0440\u0443\u0434",email:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 email",url:"URL",emoji:"\u044D\u043C\u043E\u04B7\u0438",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0441\u0430\u043D\u0430\u0432\u0443 \u0432\u0430\u049B\u0442\u0438 ISO",date:"\u0441\u0430\u043D\u0430\u0438 ISO",time:"\u0432\u0430\u049B\u0442\u0438 ISO",duration:"\u0434\u0430\u0432\u043E\u043C\u043D\u043E\u043A\u0438\u0438 ISO",ipv4:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv4",ipv6:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 IPv6",mac:"\u0441\u0443\u0440\u043E\u0493\u0430\u0438 MAC",cidrv4:"\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv4",cidrv6:"\u043C\u0430\u04B3\u0434\u0443\u0434\u0430\u0438 IPv6",base64:"\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64",base64url:"\u0441\u0430\u0442\u0440\u0438 \u0434\u0430\u0440 \u0444\u043E\u0440\u043C\u0430\u0442\u0438 base64url",json_string:"\u0441\u0430\u0442\u0440\u0438 JSON",e164:"\u0440\u0430\u049B\u0430\u043C\u0438 E.164",credit_card:"\u0440\u0430\u049B\u0430\u043C\u0438 \u043A\u043E\u0440\u0442\u0438 \u043A\u0440\u0435\u0434\u0438\u0442\u04E3",currency_code:"\u0440\u0430\u043C\u0437\u0438 \u0430\u0441\u044A\u043E\u0440",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0443\u0440\u0443\u0434"},i={nan:"NaN",number:"\u0440\u0430\u049B\u0430\u043C",string:"\u0441\u0430\u0442\u0440",array:"\u043C\u0430\u0441\u0441\u0438\u0432",object:"\u043E\u0431\u044A\u0435\u043A\u0442",date:"\u0441\u0430\u043D\u0430"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return`\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${o} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442, ${s} \u0433\u0438\u0440\u0438\u0444\u0442\u0430 \u0448\u0443\u0434`}case"invalid_value":return r.values.length===1?`\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: ${ge(r.values[0])} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`:`\u0418\u043D\u0442\u0438\u0445\u043E\u0431\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u044F\u043A\u0435 \u0430\u0437 ${G(r.values,"|")} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${r.origin??"\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${o}${r.maximum.toString()} ${a.unit} ${a.verb}`:`\u0425\u0435\u043B\u0435 \u043A\u0430\u043B\u043E\u043D: ${r.origin??"\u049B\u0438\u043C\u0430\u0442"} \u0431\u043E\u044F\u0434 ${o}${r.maximum.toString()} \u0431\u043E\u0448\u0430\u0434`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${r.origin} \u0431\u043E\u044F\u0434 ${o}${r.minimum.toString()} ${a.unit} ${a.verb}`:`\u0425\u0435\u043B\u0435 \u0445\u0443\u0440\u0434: ${r.origin} \u0431\u043E\u044F\u0434 ${o}${r.minimum.toString()} \u0431\u043E\u0448\u0430\u0434`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${o.prefix}" \u043E\u0493\u043E\u0437 \u0448\u0430\u0432\u0430\u0434`:o.format==="ends_with"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u043E "${o.suffix}" \u0430\u043D\u04B7\u043E\u043C \u0451\u0431\u0430\u0434`:o.format==="includes"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 "${o.includes}"-\u0440\u043E \u0434\u0430\u0440 \u0431\u0430\u0440 \u0433\u0438\u0440\u0430\u0434`:o.format==="regex"?`\u0421\u0430\u0442\u0440\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 \u043D\u0430\u043C\u0443\u043D\u0430\u0438 ${o.pattern} \u043C\u0443\u0432\u043E\u0444\u0438\u049B\u0430\u0442 \u043A\u0443\u043D\u0430\u0434`:`${n[o.format]??r.format}-\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442`}case"not_multiple_of":return`\u0420\u0430\u049B\u0430\u043C\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442: \u0431\u043E\u044F\u0434 \u0431\u0430 ${r.divisor} \u0431\u0435 \u0431\u0430\u049B\u0438\u044F \u0442\u0430\u049B\u0441\u0438\u043C \u0448\u0430\u0432\u0430\u0434`;case"unrecognized_keys":return`\u041A\u0430\u043B\u0438\u0434${r.keys.length>1?"\u04B3\u043E\u0438":"\u0438"} \u043D\u043E\u043C\u0430\u044A\u043B\u0443\u043C: ${G(r.keys,", ")}`;case"invalid_key":return`\u041A\u0430\u043B\u0438\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${r.origin}`;case"invalid_union":return r.options&&Array.isArray(r.options)&&r.options.length>0?`\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442\u0438 \u0434\u0438\u0441\u043A\u0440\u0438\u043C\u0438\u043D\u0430\u0442\u043E\u0440: ${r.options.map(a=>`'${a}'`).join(" | ")} \u0438\u043D\u0442\u0438\u0437\u043E\u0440 \u043C\u0435\u0440\u0430\u0444\u0442`:"\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442";case"invalid_element":return`\u049A\u0438\u043C\u0430\u0442\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442 \u0434\u0430\u0440 ${r.origin}`;default:return"\u0412\u0443\u0440\u0443\u0434\u0438 \u043D\u043E\u0434\u0443\u0440\u0443\u0441\u0442"}}};function bz(){return{localeError:bG()}}var gG=()=>{let e={string:{unit:"\u0E15\u0E31\u0E27\u0E2D\u0E31\u0E01\u0E29\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},file:{unit:"\u0E44\u0E1A\u0E15\u0E4C",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},array:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},set:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"},map:{unit:"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23",verb:"\u0E04\u0E27\u0E23\u0E21\u0E35"}};function t(r){return e[r]??null}let n={regex:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19",email:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48\u0E2D\u0E35\u0E40\u0E21\u0E25",url:"URL",emoji:"\u0E2D\u0E34\u0E42\u0E21\u0E08\u0E34",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",date:"\u0E27\u0E31\u0E19\u0E17\u0E35\u0E48\u0E41\u0E1A\u0E1A ISO",time:"\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",duration:"\u0E0A\u0E48\u0E27\u0E07\u0E40\u0E27\u0E25\u0E32\u0E41\u0E1A\u0E1A ISO",ipv4:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv4",ipv6:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 IPv6",mac:"\u0E17\u0E35\u0E48\u0E2D\u0E22\u0E39\u0E48 MAC",cidrv4:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv4",cidrv6:"\u0E0A\u0E48\u0E27\u0E07 IP \u0E41\u0E1A\u0E1A IPv6",base64:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64",base64url:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A Base64 \u0E2A\u0E33\u0E2B\u0E23\u0E31\u0E1A URL",json_string:"\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E41\u0E1A\u0E1A JSON",e164:"\u0E40\u0E1A\u0E2D\u0E23\u0E4C\u0E42\u0E17\u0E23\u0E28\u0E31\u0E1E\u0E17\u0E4C\u0E23\u0E30\u0E2B\u0E27\u0E48\u0E32\u0E07\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28 (E.164)",credit_card:"\u0E2B\u0E21\u0E32\u0E22\u0E40\u0E25\u0E02\u0E1A\u0E31\u0E15\u0E23\u0E40\u0E04\u0E23\u0E14\u0E34\u0E15",currency_code:"\u0E23\u0E2B\u0E31\u0E2A\u0E2A\u0E01\u0E38\u0E25\u0E40\u0E07\u0E34\u0E19",iban:"IBAN",jwt:"\u0E42\u0E17\u0E40\u0E04\u0E19 JWT",template_literal:"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E17\u0E35\u0E48\u0E1B\u0E49\u0E2D\u0E19"},i={nan:"NaN",number:"\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02",array:"\u0E2D\u0E32\u0E23\u0E4C\u0E40\u0E23\u0E22\u0E4C (Array)",null:"\u0E44\u0E21\u0E48\u0E21\u0E35\u0E04\u0E48\u0E32 (null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 instanceof ${r.expected} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`:`\u0E1B\u0E23\u0E30\u0E40\u0E20\u0E17\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${o} \u0E41\u0E15\u0E48\u0E44\u0E14\u0E49\u0E23\u0E31\u0E1A ${s}`}case"invalid_value":return r.values.length===1?`\u0E04\u0E48\u0E32\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19 ${ge(r.values[0])}`:`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E04\u0E27\u0E23\u0E40\u0E1B\u0E47\u0E19\u0E2B\u0E19\u0E36\u0E48\u0E07\u0E43\u0E19 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"\u0E44\u0E21\u0E48\u0E40\u0E01\u0E34\u0E19":"\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32",a=t(r.origin);return a?`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.maximum.toString()} ${a.unit??"\u0E23\u0E32\u0E22\u0E01\u0E32\u0E23"}`:`\u0E40\u0E01\u0E34\u0E19\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin??"\u0E04\u0E48\u0E32"} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?"\u0E2D\u0E22\u0E48\u0E32\u0E07\u0E19\u0E49\u0E2D\u0E22":"\u0E21\u0E32\u0E01\u0E01\u0E27\u0E48\u0E32",a=t(r.origin);return a?`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.minimum.toString()} ${a.unit}`:`\u0E19\u0E49\u0E2D\u0E22\u0E01\u0E27\u0E48\u0E32\u0E01\u0E33\u0E2B\u0E19\u0E14: ${r.origin} \u0E04\u0E27\u0E23\u0E21\u0E35${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E02\u0E36\u0E49\u0E19\u0E15\u0E49\u0E19\u0E14\u0E49\u0E27\u0E22 "${o.prefix}"`:o.format==="ends_with"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E25\u0E07\u0E17\u0E49\u0E32\u0E22\u0E14\u0E49\u0E27\u0E22 "${o.suffix}"`:o.format==="includes"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21\u0E15\u0E49\u0E2D\u0E07\u0E21\u0E35 "${o.includes}" \u0E2D\u0E22\u0E39\u0E48\u0E43\u0E19\u0E02\u0E49\u0E2D\u0E04\u0E27\u0E32\u0E21`:o.format==="regex"?`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14 ${o.pattern}`:`\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: ${n[o.format]??r.format}`}case"not_multiple_of":return`\u0E15\u0E31\u0E27\u0E40\u0E25\u0E02\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E15\u0E49\u0E2D\u0E07\u0E40\u0E1B\u0E47\u0E19\u0E08\u0E33\u0E19\u0E27\u0E19\u0E17\u0E35\u0E48\u0E2B\u0E32\u0E23\u0E14\u0E49\u0E27\u0E22 ${r.divisor} \u0E44\u0E14\u0E49\u0E25\u0E07\u0E15\u0E31\u0E27`;case"unrecognized_keys":return`\u0E1E\u0E1A\u0E04\u0E35\u0E22\u0E4C\u0E17\u0E35\u0E48\u0E44\u0E21\u0E48\u0E23\u0E39\u0E49\u0E08\u0E31\u0E01: ${G(r.keys,", ")}`;case"invalid_key":return`\u0E04\u0E35\u0E22\u0E4C\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;case"invalid_union":return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07: \u0E44\u0E21\u0E48\u0E15\u0E23\u0E07\u0E01\u0E31\u0E1A\u0E23\u0E39\u0E1B\u0E41\u0E1A\u0E1A\u0E22\u0E39\u0E40\u0E19\u0E35\u0E22\u0E19\u0E17\u0E35\u0E48\u0E01\u0E33\u0E2B\u0E19\u0E14\u0E44\u0E27\u0E49";case"invalid_element":return`\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07\u0E43\u0E19 ${r.origin}`;default:return"\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E44\u0E21\u0E48\u0E16\u0E39\u0E01\u0E15\u0E49\u0E2D\u0E07"}}};function gz(){return{localeError:gG()}}var vG=()=>{let e={string:{unit:"simwol",verb:"bolmaly"},file:{unit:"ba\xFDt",verb:"bolmaly"},array:{unit:"elementler",verb:"bolmaly"},set:{unit:"elementler",verb:"bolmaly"},map:{unit:"elementler",verb:"bolmaly"}};function t(r){return e[r]??null}let n={regex:"giri\u015F",email:"e-po\xE7ta salgysy",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sene we wagt",date:"ISO sene",time:"ISO wagt",duration:"ISO wagt aralygy",ipv4:"IPv4 salgysy",ipv6:"IPv6 salgysy",mac:"MAC salgysy",cidrv4:"IPv4 aralygy",cidrv6:"IPv6 aralygy",base64:"base64 bilen \u015Fifrlenen setir",base64url:"base64url bilen \u015Fifrlenen setir",json_string:"JSON setiri",e164:"E.164 nomeri",credit_card:"kredit kartyny\u0148 nomeri",currency_code:"wal\xFDuta kody",iban:"IBAN",jwt:"JWT",template_literal:"\u015Fablon"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return`N\xE4dogry baha: gara\u015Fylan ${o} \xFDerine ${s} alyndy`}case"invalid_value":return r.values.length===1?`N\xE4dogry baha: ${ge(r.values[0])} bolmaly`:`N\xE4dogry sa\xFDlaw: a\u015Fakdakylardan biri bolmaly: ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Has uly: gara\u015Fyl\xFDan ${r.origin??"baha"} ${o} ${r.maximum.toString()} ${a.unit??"element"}`:`Has uly: gara\u015Fyl\xFDan ${r.origin??"baha"} ${o} ${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Has ki\xE7i: gara\u015Fyl\xFDan ${r.origin} ${o} ${r.minimum.toString()} ${a.unit}`:`Has ki\xE7i: gara\u015Fyl\xFDan ${r.origin} ${o} ${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`N\xE4dogry setir: "${o.prefix}" bilen ba\u015Flamaly`:o.format==="ends_with"?`N\xE4dogry setir: "${o.suffix}" bilen gutarmaly`:o.format==="includes"?`N\xE4dogry setir: "${o.includes}" saklamaly`:o.format==="regex"?`N\xE4dogry setir: ${o.pattern} nusga la\xFDyk bolmaly`:`N\xE4dogry ${n[o.format]??r.format}`}case"not_multiple_of":return`N\xE4dogry san: ${r.divisor} bilen galyndysyz b\xF6l\xFCnmeli`;case"unrecognized_keys":return`Tanalma\xFDan a\xE7ar${r.keys.length>1?"lar":""}: ${G(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7inde n\xE4dogry a\xE7ar`;case"invalid_union":return"N\xE4dogry baha";case"invalid_element":return`${r.origin} i\xE7inde n\xE4dogry baha`;default:return"N\xE4dogry baha"}}};function vz(){return{localeError:vG()}}var yG=()=>{let e={string:{unit:"karakter",verb:"olmal\u0131"},file:{unit:"bayt",verb:"olmal\u0131"},array:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},set:{unit:"\xF6\u011Fe",verb:"olmal\u0131"},map:{unit:"\xF6\u011Fe",verb:"olmal\u0131"}};function t(r){return e[r]??null}let n={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO s\xFCre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",mac:"MAC adresi",cidrv4:"IPv4 aral\u0131\u011F\u0131",cidrv6:"IPv6 aral\u0131\u011F\u0131",base64:"base64 ile \u015Fifrelenmi\u015F metin",base64url:"base64url ile \u015Fifrelenmi\u015F metin",json_string:"JSON dizesi",e164:"E.164 say\u0131s\u0131",credit_card:"kredi kart\u0131 numaras\u0131",currency_code:"para birimi kodu",iban:"IBAN",jwt:"JWT",template_literal:"\u015Eablon dizesi"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Ge\xE7ersiz de\u011Fer: beklenen instanceof ${r.expected}, al\u0131nan ${s}`:`Ge\xE7ersiz de\u011Fer: beklenen ${o}, al\u0131nan ${s}`}case"invalid_value":return r.values.length===1?`Ge\xE7ersiz de\u011Fer: beklenen ${ge(r.values[0])}`:`Ge\xE7ersiz se\xE7enek: a\u015Fa\u011F\u0131dakilerden biri olmal\u0131: ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\xC7ok b\xFCy\xFCk: beklenen ${r.origin??"de\u011Fer"} ${o}${r.maximum.toString()} ${a.unit??"\xF6\u011Fe"}`:`\xC7ok b\xFCy\xFCk: beklenen ${r.origin??"de\u011Fer"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\xC7ok k\xFC\xE7\xFCk: beklenen ${r.origin} ${o}${r.minimum.toString()} ${a.unit}`:`\xC7ok k\xFC\xE7\xFCk: beklenen ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Ge\xE7ersiz metin: "${o.prefix}" ile ba\u015Flamal\u0131`:o.format==="ends_with"?`Ge\xE7ersiz metin: "${o.suffix}" ile bitmeli`:o.format==="includes"?`Ge\xE7ersiz metin: "${o.includes}" i\xE7ermeli`:o.format==="regex"?`Ge\xE7ersiz metin: ${o.pattern} desenine uymal\u0131`:`Ge\xE7ersiz ${n[o.format]??r.format}`}case"not_multiple_of":return`Ge\xE7ersiz say\u0131: ${r.divisor} ile tam b\xF6l\xFCnebilmeli`;case"unrecognized_keys":return`Tan\u0131nmayan anahtar${r.keys.length>1?"lar":""}: ${G(r.keys,", ")}`;case"invalid_key":return`${r.origin} i\xE7inde ge\xE7ersiz anahtar`;case"invalid_union":return"Ge\xE7ersiz de\u011Fer";case"invalid_element":return`${r.origin} i\xE7inde ge\xE7ersiz de\u011Fer`;default:return"Ge\xE7ersiz de\u011Fer"}}};function yz(){return{localeError:yG()}}var wG=()=>{let e={string:{unit:"\u0441\u0438\u043C\u0432\u043E\u043B\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},file:{unit:"\u0431\u0430\u0439\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},array:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},set:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"},map:{unit:"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432",verb:"\u043C\u0430\u0442\u0438\u043C\u0435"}};function t(r){return e[r]??null}let n={regex:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456",email:"\u0430\u0434\u0440\u0435\u0441\u0430 \u0435\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0457 \u043F\u043E\u0448\u0442\u0438",url:"URL",emoji:"\u0435\u043C\u043E\u0434\u0437\u0456",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\u0434\u0430\u0442\u0430 \u0442\u0430 \u0447\u0430\u0441 ISO",date:"\u0434\u0430\u0442\u0430 ISO",time:"\u0447\u0430\u0441 ISO",duration:"\u0442\u0440\u0438\u0432\u0430\u043B\u0456\u0441\u0442\u044C ISO",ipv4:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv4",ipv6:"\u0430\u0434\u0440\u0435\u0441\u0430 IPv6",mac:"\u0430\u0434\u0440\u0435\u0441\u0430 MAC",cidrv4:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv4",cidrv6:"\u0434\u0456\u0430\u043F\u0430\u0437\u043E\u043D IPv6",base64:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64",base64url:"\u0440\u044F\u0434\u043E\u043A \u0443 \u043A\u043E\u0434\u0443\u0432\u0430\u043D\u043D\u0456 base64url",json_string:"\u0440\u044F\u0434\u043E\u043A JSON",e164:"\u043D\u043E\u043C\u0435\u0440 E.164",credit_card:"\u043D\u043E\u043C\u0435\u0440 \u043A\u0440\u0435\u0434\u0438\u0442\u043D\u043E\u0457 \u043A\u0430\u0440\u0442\u043A\u0438",currency_code:"\u043A\u043E\u0434 \u0432\u0430\u043B\u044E\u0442\u0438",iban:"IBAN",jwt:"JWT",template_literal:"\u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"},i={nan:"NaN",number:"\u0447\u0438\u0441\u043B\u043E",array:"\u043C\u0430\u0441\u0438\u0432"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F instanceof ${r.expected}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${o}, \u043E\u0442\u0440\u0438\u043C\u0430\u043D\u043E ${s}`}case"invalid_value":return r.values.length===1?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F ${ge(r.values[0])}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0430 \u043E\u043F\u0446\u0456\u044F: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F \u043E\u0434\u043D\u0435 \u0437 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} ${a.verb} ${o}${r.maximum.toString()} ${a.unit??"\u0435\u043B\u0435\u043C\u0435\u043D\u0442\u0456\u0432"}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u0432\u0435\u043B\u0438\u043A\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin??"\u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F"} \u0431\u0443\u0434\u0435 ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`\u0417\u0430\u043D\u0430\u0434\u0442\u043E \u043C\u0430\u043B\u0435: \u043E\u0447\u0456\u043A\u0443\u0454\u0442\u044C\u0441\u044F, \u0449\u043E ${r.origin} \u0431\u0443\u0434\u0435 ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043F\u043E\u0447\u0438\u043D\u0430\u0442\u0438\u0441\u044F \u0437 "${o.prefix}"`:o.format==="ends_with"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0437\u0430\u043A\u0456\u043D\u0447\u0443\u0432\u0430\u0442\u0438\u0441\u044F \u043D\u0430 "${o.suffix}"`:o.format==="includes"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u043C\u0456\u0441\u0442\u0438\u0442\u0438 "${o.includes}"`:o.format==="regex"?`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u0440\u044F\u0434\u043E\u043A: \u043F\u043E\u0432\u0438\u043D\u0435\u043D \u0432\u0456\u0434\u043F\u043E\u0432\u0456\u0434\u0430\u0442\u0438 \u0448\u0430\u0431\u043B\u043E\u043D\u0443 ${o.pattern}`:`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0447\u0438\u0441\u043B\u043E: \u043F\u043E\u0432\u0438\u043D\u043D\u043E \u0431\u0443\u0442\u0438 \u043A\u0440\u0430\u0442\u043D\u0438\u043C ${r.divisor}`;case"unrecognized_keys":return`\u041D\u0435\u0440\u043E\u0437\u043F\u0456\u0437\u043D\u0430\u043D\u0438\u0439 \u043A\u043B\u044E\u0447${r.keys.length>1?"\u0456":""}: ${G(r.keys,", ")}`;case"invalid_key":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0438\u0439 \u043A\u043B\u044E\u0447 \u0443 ${r.origin}`;case"invalid_union":return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456";case"invalid_element":return`\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u043D\u044F \u0443 ${r.origin}`;default:return"\u041D\u0435\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u0456 \u0432\u0445\u0456\u0434\u043D\u0456 \u0434\u0430\u043D\u0456"}}};function Dh(){return{localeError:wG()}}function wz(){return Dh()}var xG=()=>{let e={string:{unit:"\u062D\u0631\u0648\u0641",verb:"\u06C1\u0648\u0646\u0627"},file:{unit:"\u0628\u0627\u0626\u0679\u0633",verb:"\u06C1\u0648\u0646\u0627"},array:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},set:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"},map:{unit:"\u0622\u0626\u0679\u0645\u0632",verb:"\u06C1\u0648\u0646\u0627"}};function t(r){return e[r]??null}let n={regex:"\u0627\u0646 \u067E\u0679",email:"\u0627\u06CC \u0645\u06CC\u0644 \u0627\u06CC\u0688\u0631\u06CC\u0633",url:"\u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644",emoji:"\u0627\u06CC\u0645\u0648\u062C\u06CC",uuid:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",uuidv4:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 4",uuidv6:"\u06CC\u0648 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC \u0648\u06CC 6",nanoid:"\u0646\u06CC\u0646\u0648 \u0622\u0626\u06CC \u0688\u06CC",guid:"\u062C\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",cuid2:"\u0633\u06CC \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC 2",ulid:"\u06CC\u0648 \u0627\u06CC\u0644 \u0622\u0626\u06CC \u0688\u06CC",xid:"\u0627\u06CC\u06A9\u0633 \u0622\u0626\u06CC \u0688\u06CC",ksuid:"\u06A9\u06D2 \u0627\u06CC\u0633 \u06CC\u0648 \u0622\u0626\u06CC \u0688\u06CC",datetime:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0688\u06CC\u0679 \u0679\u0627\u0626\u0645",date:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u062A\u0627\u0631\u06CC\u062E",time:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0648\u0642\u062A",duration:"\u0622\u0626\u06CC \u0627\u06CC\u0633 \u0627\u0648 \u0645\u062F\u062A",ipv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0627\u06CC\u0688\u0631\u06CC\u0633",ipv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0627\u06CC\u0688\u0631\u06CC\u0633",mac:"\u0627\u06CC\u0645 \u0627\u06D2 \u0633\u06CC \u0627\u06CC\u0688\u0631\u06CC\u0633",cidrv4:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 4 \u0631\u06CC\u0646\u062C",cidrv6:"\u0622\u0626\u06CC \u067E\u06CC \u0648\u06CC 6 \u0631\u06CC\u0646\u062C",base64:"\u0628\u06CC\u0633 64 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",base64url:"\u0628\u06CC\u0633 64 \u06CC\u0648 \u0622\u0631 \u0627\u06CC\u0644 \u0627\u0646 \u06A9\u0648\u0688\u0688 \u0633\u0679\u0631\u0646\u06AF",json_string:"\u062C\u06D2 \u0627\u06CC\u0633 \u0627\u0648 \u0627\u06CC\u0646 \u0633\u0679\u0631\u0646\u06AF",e164:"\u0627\u06CC 164 \u0646\u0645\u0628\u0631",credit_card:"\u06A9\u0631\u06CC\u0688\u0679 \u06A9\u0627\u0631\u0688 \u0646\u0645\u0628\u0631",currency_code:"\u06A9\u0631\u0646\u0633\u06CC \u06A9\u0648\u0688",iban:"IBAN",jwt:"\u062C\u06D2 \u0688\u0628\u0644\u06CC\u0648 \u0679\u06CC",template_literal:"\u0627\u0646 \u067E\u0679"},i={nan:"NaN",number:"\u0646\u0645\u0628\u0631",array:"\u0622\u0631\u06D2",null:"\u0646\u0644"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: instanceof ${r.expected} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`:`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${o} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627\u060C ${s} \u0645\u0648\u0635\u0648\u0644 \u06C1\u0648\u0627`}case"invalid_value":return r.values.length===1?`\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679: ${ge(r.values[0])} \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`:`\u063A\u0644\u0637 \u0622\u067E\u0634\u0646: ${G(r.values,"|")} \u0645\u06CC\u06BA \u0633\u06D2 \u0627\u06CC\u06A9 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u06D2 ${o}${r.maximum.toString()} ${a.unit??"\u0639\u0646\u0627\u0635\u0631"} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0628\u0691\u0627: ${r.origin??"\u0648\u06CC\u0644\u06CC\u0648"} \u06A9\u0627 ${o}${r.maximum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u06D2 ${o}${r.minimum.toString()} ${a.unit} \u06C1\u0648\u0646\u06D2 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u06D2`:`\u0628\u06C1\u062A \u0686\u06BE\u0648\u0679\u0627: ${r.origin} \u06A9\u0627 ${o}${r.minimum.toString()} \u06C1\u0648\u0646\u0627 \u0645\u062A\u0648\u0642\u0639 \u062A\u06BE\u0627`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.prefix}" \u0633\u06D2 \u0634\u0631\u0648\u0639 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="ends_with"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.suffix}" \u067E\u0631 \u062E\u062A\u0645 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="includes"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: "${o.includes}" \u0634\u0627\u0645\u0644 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:o.format==="regex"?`\u063A\u0644\u0637 \u0633\u0679\u0631\u0646\u06AF: \u067E\u06CC\u0679\u0631\u0646 ${o.pattern} \u0633\u06D2 \u0645\u06CC\u0686 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`:`\u063A\u0644\u0637 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u063A\u0644\u0637 \u0646\u0645\u0628\u0631: ${r.divisor} \u06A9\u0627 \u0645\u0636\u0627\u0639\u0641 \u06C1\u0648\u0646\u0627 \u0686\u0627\u06C1\u06CC\u06D2`;case"unrecognized_keys":return`\u063A\u06CC\u0631 \u062A\u0633\u0644\u06CC\u0645 \u0634\u062F\u06C1 \u06A9\u06CC${r.keys.length>1?"\u0632":""}: ${G(r.keys,"\u060C ")}`;case"invalid_key":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u06A9\u06CC`;case"invalid_union":return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679";case"invalid_element":return`${r.origin} \u0645\u06CC\u06BA \u063A\u0644\u0637 \u0648\u06CC\u0644\u06CC\u0648`;default:return"\u063A\u0644\u0637 \u0627\u0646 \u067E\u0679"}}};function xz(){return{localeError:xG()}}var PG=()=>{let e={string:{unit:"belgi",verb:"bo\u2018lishi kerak"},file:{unit:"bayt",verb:"bo\u2018lishi kerak"},array:{unit:"element",verb:"bo\u2018lishi kerak"},set:{unit:"element",verb:"bo\u2018lishi kerak"},map:{unit:"yozuv",verb:"bo\u2018lishi kerak"}};function t(r){return e[r]??null}let n={regex:"kirish",email:"elektron pochta manzili",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO sana va vaqti",date:"ISO sana",time:"ISO vaqt",duration:"ISO davomiylik",ipv4:"IPv4 manzil",ipv6:"IPv6 manzil",mac:"MAC manzil",cidrv4:"IPv4 diapazon",cidrv6:"IPv6 diapazon",base64:"base64 kodlangan satr",base64url:"base64url kodlangan satr",json_string:"JSON satr",e164:"E.164 raqam",credit_card:"kredit karta raqami",currency_code:"valyuta kodi",iban:"IBAN",jwt:"JWT",template_literal:"kirish"},i={nan:"NaN",number:"raqam",array:"massiv"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`Noto\u2018g\u2018ri kirish: kutilgan instanceof ${r.expected}, qabul qilingan ${s}`:`Noto\u2018g\u2018ri kirish: kutilgan ${o}, qabul qilingan ${s}`}case"invalid_value":return r.values.length===1?`Noto\u2018g\u2018ri kirish: kutilgan ${ge(r.values[0])}`:`Noto\u2018g\u2018ri variant: quyidagilardan biri kutilgan ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Juda katta: kutilgan ${r.origin??"qiymat"} ${o}${r.maximum.toString()} ${a.unit} ${a.verb}`:`Juda katta: kutilgan ${r.origin??"qiymat"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Juda kichik: kutilgan ${r.origin} ${o}${r.minimum.toString()} ${a.unit} ${a.verb}`:`Juda kichik: kutilgan ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Noto\u2018g\u2018ri satr: "${o.prefix}" bilan boshlanishi kerak`:o.format==="ends_with"?`Noto\u2018g\u2018ri satr: "${o.suffix}" bilan tugashi kerak`:o.format==="includes"?`Noto\u2018g\u2018ri satr: "${o.includes}" ni o\u2018z ichiga olishi kerak`:o.format==="regex"?`Noto\u2018g\u2018ri satr: ${o.pattern} shabloniga mos kelishi kerak`:`Noto\u2018g\u2018ri ${n[o.format]??r.format}`}case"not_multiple_of":return`Noto\u2018g\u2018ri raqam: ${r.divisor} ning karralisi bo\u2018lishi kerak`;case"unrecognized_keys":return`Noma\u2019lum kalit${r.keys.length>1?"lar":""}: ${G(r.keys,", ")}`;case"invalid_key":return`${r.origin} dagi kalit noto\u2018g\u2018ri`;case"invalid_union":return"Noto\u2018g\u2018ri kirish";case"invalid_element":return`${r.origin} da noto\u2018g\u2018ri qiymat`;default:return"Noto\u2018g\u2018ri kirish"}}};function Pz(){return{localeError:PG()}}var SG=()=>{let e={string:{unit:"k\xFD t\u1EF1",verb:"c\xF3"},file:{unit:"byte",verb:"c\xF3"},array:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},set:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"},map:{unit:"ph\u1EA7n t\u1EED",verb:"c\xF3"}};function t(r){return e[r]??null}let n={regex:"\u0111\u1EA7u v\xE0o",email:"\u0111\u1ECBa ch\u1EC9 email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ng\xE0y gi\u1EDD ISO",date:"ng\xE0y ISO",time:"gi\u1EDD ISO",duration:"kho\u1EA3ng th\u1EDDi gian ISO",ipv4:"\u0111\u1ECBa ch\u1EC9 IPv4",ipv6:"\u0111\u1ECBa ch\u1EC9 IPv6",mac:"\u0111\u1ECBa ch\u1EC9 MAC",cidrv4:"d\u1EA3i IPv4",cidrv6:"d\u1EA3i IPv6",base64:"chu\u1ED7i m\xE3 h\xF3a base64",base64url:"chu\u1ED7i m\xE3 h\xF3a base64url",json_string:"chu\u1ED7i JSON",e164:"s\u1ED1 E.164",credit_card:"s\u1ED1 th\u1EBB t\xEDn d\u1EE5ng",currency_code:"m\xE3 ti\u1EC1n t\u1EC7",iban:"IBAN",jwt:"JWT",template_literal:"\u0111\u1EA7u v\xE0o"},i={nan:"NaN",number:"s\u1ED1",array:"m\u1EA3ng"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i instanceof ${r.expected}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`:`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${o}, nh\u1EADn \u0111\u01B0\u1EE3c ${s}`}case"invalid_value":return r.values.length===1?`\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i ${ge(r.values[0])}`:`T\xF9y ch\u1ECDn kh\xF4ng h\u1EE3p l\u1EC7: mong \u0111\u1EE3i m\u1ED9t trong c\xE1c gi\xE1 tr\u1ECB ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${a.verb} ${o}${r.maximum.toString()} ${a.unit??"ph\u1EA7n t\u1EED"}`:`Qu\xE1 l\u1EDBn: mong \u0111\u1EE3i ${r.origin??"gi\xE1 tr\u1ECB"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${a.verb} ${o}${r.minimum.toString()} ${a.unit}`:`Qu\xE1 nh\u1ECF: mong \u0111\u1EE3i ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i b\u1EAFt \u0111\u1EA7u b\u1EB1ng "${o.prefix}"`:o.format==="ends_with"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i k\u1EBFt th\xFAc b\u1EB1ng "${o.suffix}"`:o.format==="includes"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i bao g\u1ED3m "${o.includes}"`:o.format==="regex"?`Chu\u1ED7i kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i kh\u1EDBp v\u1EDBi m\u1EABu ${o.pattern}`:`${n[o.format]??r.format} kh\xF4ng h\u1EE3p l\u1EC7`}case"not_multiple_of":return`S\u1ED1 kh\xF4ng h\u1EE3p l\u1EC7: ph\u1EA3i l\xE0 b\u1ED9i s\u1ED1 c\u1EE7a ${r.divisor}`;case"unrecognized_keys":return`Kh\xF3a kh\xF4ng \u0111\u01B0\u1EE3c nh\u1EADn d\u1EA1ng: ${G(r.keys,", ")}`;case"invalid_key":return`Kh\xF3a kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;case"invalid_union":return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7";case"invalid_element":return`Gi\xE1 tr\u1ECB kh\xF4ng h\u1EE3p l\u1EC7 trong ${r.origin}`;default:return"\u0110\u1EA7u v\xE0o kh\xF4ng h\u1EE3p l\u1EC7"}}};function Sz(){return{localeError:SG()}}var kG=()=>{let e={string:{unit:"\u5B57\u7B26",verb:"\u5305\u542B"},file:{unit:"\u5B57\u8282",verb:"\u5305\u542B"},array:{unit:"\u9879",verb:"\u5305\u542B"},set:{unit:"\u9879",verb:"\u5305\u542B"},map:{unit:"\u9879",verb:"\u5305\u542B"}};function t(r){return e[r]??null}let n={regex:"\u8F93\u5165",email:"\u7535\u5B50\u90AE\u4EF6",url:"URL",emoji:"\u8868\u60C5\u7B26\u53F7",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO\u65E5\u671F\u65F6\u95F4",date:"ISO\u65E5\u671F",time:"ISO\u65F6\u95F4",duration:"ISO\u65F6\u957F",ipv4:"IPv4\u5730\u5740",ipv6:"IPv6\u5730\u5740",mac:"MAC\u5730\u5740",cidrv4:"IPv4\u7F51\u6BB5",cidrv6:"IPv6\u7F51\u6BB5",base64:"base64\u7F16\u7801\u5B57\u7B26\u4E32",base64url:"base64url\u7F16\u7801\u5B57\u7B26\u4E32",json_string:"JSON\u5B57\u7B26\u4E32",e164:"E.164\u53F7\u7801",credit_card:"\u4FE1\u7528\u5361\u53F7",currency_code:"\u8D27\u5E01\u4EE3\u7801",iban:"IBAN",jwt:"JWT",template_literal:"\u8F93\u5165"},i={nan:"NaN",number:"\u6570\u5B57",array:"\u6570\u7EC4",null:"\u7A7A\u503C(null)"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B instanceof ${r.expected}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`:`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${o}\uFF0C\u5B9E\u9645\u63A5\u6536 ${s}`}case"invalid_value":return r.values.length===1?`\u65E0\u6548\u8F93\u5165\uFF1A\u671F\u671B ${ge(r.values[0])}`:`\u65E0\u6548\u9009\u9879\uFF1A\u671F\u671B\u4EE5\u4E0B\u4E4B\u4E00 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${o}${r.maximum.toString()} ${a.unit??"\u4E2A\u5143\u7D20"}`:`\u6570\u503C\u8FC7\u5927\uFF1A\u671F\u671B ${r.origin??"\u503C"} ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${o}${r.minimum.toString()} ${a.unit}`:`\u6570\u503C\u8FC7\u5C0F\uFF1A\u671F\u671B ${r.origin} ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.prefix}" \u5F00\u5934`:o.format==="ends_with"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u4EE5 "${o.suffix}" \u7ED3\u5C3E`:o.format==="includes"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u65E0\u6548\u5B57\u7B26\u4E32\uFF1A\u5FC5\u987B\u6EE1\u8DB3\u6B63\u5219\u8868\u8FBE\u5F0F ${o.pattern}`:`\u65E0\u6548${n[o.format]??r.format}`}case"not_multiple_of":return`\u65E0\u6548\u6570\u5B57\uFF1A\u5FC5\u987B\u662F ${r.divisor} \u7684\u500D\u6570`;case"unrecognized_keys":return`\u51FA\u73B0\u672A\u77E5\u7684\u952E(key): ${G(r.keys,", ")}`;case"invalid_key":return`${r.origin} \u4E2D\u7684\u952E(key)\u65E0\u6548`;case"invalid_union":return"\u65E0\u6548\u8F93\u5165";case"invalid_element":return`${r.origin} \u4E2D\u5305\u542B\u65E0\u6548\u503C(value)`;default:return"\u65E0\u6548\u8F93\u5165"}}};function kz(){return{localeError:kG()}}var TG=()=>{let e={string:{unit:"\u5B57\u5143",verb:"\u64C1\u6709"},file:{unit:"\u4F4D\u5143\u7D44",verb:"\u64C1\u6709"},array:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},set:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"},map:{unit:"\u9805\u76EE",verb:"\u64C1\u6709"}};function t(r){return e[r]??null}let n={regex:"\u8F38\u5165",email:"\u90F5\u4EF6\u5730\u5740",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO \u65E5\u671F\u6642\u9593",date:"ISO \u65E5\u671F",time:"ISO \u6642\u9593",duration:"ISO \u671F\u9593",ipv4:"IPv4 \u4F4D\u5740",ipv6:"IPv6 \u4F4D\u5740",mac:"MAC \u4F4D\u5740",cidrv4:"IPv4 \u7BC4\u570D",cidrv6:"IPv6 \u7BC4\u570D",base64:"base64 \u7DE8\u78BC\u5B57\u4E32",base64url:"base64url \u7DE8\u78BC\u5B57\u4E32",json_string:"JSON \u5B57\u4E32",e164:"E.164 \u6578\u503C",credit_card:"\u4FE1\u7528\u5361\u865F",currency_code:"\u8CA8\u5E63\u4EE3\u78BC",iban:"IBAN",jwt:"JWT",template_literal:"\u8F38\u5165"},i={nan:"NaN"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA instanceof ${r.expected}\uFF0C\u4F46\u6536\u5230 ${s}`:`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${o}\uFF0C\u4F46\u6536\u5230 ${s}`}case"invalid_value":return r.values.length===1?`\u7121\u6548\u7684\u8F38\u5165\u503C\uFF1A\u9810\u671F\u70BA ${ge(r.values[0])}`:`\u7121\u6548\u7684\u9078\u9805\uFF1A\u9810\u671F\u70BA\u4EE5\u4E0B\u5176\u4E2D\u4E4B\u4E00 ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${o}${r.maximum.toString()} ${a.unit??"\u500B\u5143\u7D20"}`:`\u6578\u503C\u904E\u5927\uFF1A\u9810\u671F ${r.origin??"\u503C"} \u61C9\u70BA ${o}${r.maximum.toString()}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${o}${r.minimum.toString()} ${a.unit}`:`\u6578\u503C\u904E\u5C0F\uFF1A\u9810\u671F ${r.origin} \u61C9\u70BA ${o}${r.minimum.toString()}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.prefix}" \u958B\u982D`:o.format==="ends_with"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u4EE5 "${o.suffix}" \u7D50\u5C3E`:o.format==="includes"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u5305\u542B "${o.includes}"`:o.format==="regex"?`\u7121\u6548\u7684\u5B57\u4E32\uFF1A\u5FC5\u9808\u7B26\u5408\u683C\u5F0F ${o.pattern}`:`\u7121\u6548\u7684 ${n[o.format]??r.format}`}case"not_multiple_of":return`\u7121\u6548\u7684\u6578\u5B57\uFF1A\u5FC5\u9808\u70BA ${r.divisor} \u7684\u500D\u6578`;case"unrecognized_keys":return`\u7121\u6CD5\u8B58\u5225\u7684\u9375\u503C${r.keys.length>1?"\u5011":""}\uFF1A${G(r.keys,"\u3001")}`;case"invalid_key":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u9375\u503C`;case"invalid_union":return"\u7121\u6548\u7684\u8F38\u5165\u503C";case"invalid_element":return`${r.origin} \u4E2D\u6709\u7121\u6548\u7684\u503C`;default:return"\u7121\u6548\u7684\u8F38\u5165\u503C"}}};function Tz(){return{localeError:TG()}}var zG=()=>{let e={string:{unit:"\xE0mi",verb:"n\xED"},file:{unit:"bytes",verb:"n\xED"},array:{unit:"nkan",verb:"n\xED"},set:{unit:"nkan",verb:"n\xED"},map:{unit:"nkan",verb:"n\xED"}};function t(r){return e[r]??null}let n={regex:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9",email:"\xE0d\xEDr\u1EB9\u0301s\xEC \xECm\u1EB9\u0301l\xEC",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"\xE0k\xF3k\xF2 ISO",date:"\u1ECDj\u1ECD\u0301 ISO",time:"\xE0k\xF3k\xF2 ISO",duration:"\xE0k\xF3k\xF2 t\xF3 p\xE9 ISO",ipv4:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv4",ipv6:"\xE0d\xEDr\u1EB9\u0301s\xEC IPv6",mac:"\xE0d\xEDr\u1EB9\u0301s\xEC MAC",cidrv4:"\xE0gb\xE8gb\xE8 IPv4",cidrv6:"\xE0gb\xE8gb\xE8 IPv6",base64:"\u1ECD\u0300r\u1ECD\u0300 t\xED a k\u1ECD\u0301 n\xED base64",base64url:"\u1ECD\u0300r\u1ECD\u0300 base64url",json_string:"\u1ECD\u0300r\u1ECD\u0300 JSON",e164:"n\u1ECD\u0301mb\xE0 E.164",credit_card:"n\u1ECDmba kaadi gbese",currency_code:"koodu ow\xF3",iban:"IBAN",jwt:"JWT",template_literal:"\u1EB9\u0300r\u1ECD \xECb\xE1w\u1ECDl\xE9"},i={nan:"NaN",number:"n\u1ECD\u0301mb\xE0",array:"akop\u1ECD"};return r=>{switch(r.code){case"invalid_type":{let o=i[r.expected]??r.expected,a=ye(r.input),s=i[a]??a;return/^[A-Z]/.test(r.expected)?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi instanceof ${r.expected}, \xE0m\u1ECD\u0300 a r\xED ${s}`:`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${o}, \xE0m\u1ECD\u0300 a r\xED ${s}`}case"invalid_value":return r.values.length===1?`\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e: a n\xED l\xE1ti fi ${ge(r.values[0])}`:`\xC0\u1E63\xE0y\xE0n a\u1E63\xEC\u1E63e: yan \u1ECD\u0300kan l\xE1ra ${G(r.values,"|")}`;case"too_big":{let o=r.inclusive?"<=":"<",a=t(r.origin);return a?`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${r.origin??"iye"} ${a.verb} ${o}${r.maximum} ${a.unit}`:`T\xF3 p\u1ECD\u0300 j\xF9: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${r.maximum}`}case"too_small":{let o=r.inclusive?">=":">",a=t(r.origin);return a?`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 p\xE9 ${r.origin} ${a.verb} ${o}${r.minimum} ${a.unit}`:`K\xE9r\xE9 ju: a n\xED l\xE1ti j\u1EB9\u0301 ${o}${r.minimum}`}case"invalid_format":{let o=r;return o.format==="starts_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\u1EB9\u0300r\u1EB9\u0300 p\u1EB9\u0300l\xFA "${o.prefix}"`:o.format==="ends_with"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 par\xED p\u1EB9\u0300l\xFA "${o.suffix}"`:o.format==="includes"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 n\xED "${o.includes}"`:o.format==="regex"?`\u1ECC\u0300r\u1ECD\u0300 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 b\xE1 \xE0p\u1EB9\u1EB9r\u1EB9 mu ${o.pattern}`:`A\u1E63\xEC\u1E63e: ${n[o.format]??r.format}`}case"not_multiple_of":return`N\u1ECD\u0301mb\xE0 a\u1E63\xEC\u1E63e: gb\u1ECD\u0301d\u1ECD\u0300 j\u1EB9\u0301 \xE8y\xE0 p\xEDp\xEDn ti ${r.divisor}`;case"unrecognized_keys":return`B\u1ECDt\xECn\xEC \xE0\xECm\u1ECD\u0300: ${G(r.keys,", ")}`;case"invalid_key":return`B\u1ECDt\xECn\xEC a\u1E63\xEC\u1E63e n\xEDn\xFA ${r.origin}`;case"invalid_union":return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e";case"invalid_element":return`Iye a\u1E63\xEC\u1E63e n\xEDn\xFA ${r.origin}`;default:return"\xCCb\xE1w\u1ECDl\xE9 a\u1E63\xEC\u1E63e"}}};function zz(){return{localeError:zG()}}var Mz,fx=Symbol("ZodOutput"),dx=Symbol("ZodInput"),qh=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){let i=n[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){let n=t._zod.parent;if(n){let i={...this.get(n)??{}};delete i.id;let r={...i,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Hh(){return new qh}(Mz=globalThis).__zod_globalRegistry??(Mz.__zod_globalRegistry=Hh());var Kr=globalThis.__zod_globalRegistry;var vi=Symbol.for("zod.compile.invalid"),Oz=Symbol.for("zod.compile.fallback"),lo=class extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}},an=class extends Error{constructor(t,n=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=n}};function OG(e,t){try{return Ch(e,{assertOnly:!0})}catch{return t}}function bx(e,t){try{let n=Ch(e),i=Eh(e,n);return i._zod.bag.validator=OG(e,n),i}catch(n){if(t?.strict)throw n;return e}}function Eh(e,t){if(jh(e))throw new an("a schema whose subtree contains a reference cycle");let n=Zn(e),i=e._zod.run,r=i.__originalRun??i,o=(a,s)=>{if(s?.async||s?.direction==="backward"||s?.skipChecks||s?.[Oz]||s&&Zh(s,a.value))return r(a,s);let c=t(a.value);return c!==vi?(a.value=c,a):(s&&(s[Oz]=!0),r(a,s))};return o.__originalRun=r,n._zod.bag.fallbackRun=r,n._zod.bag.validator=t,n._zod.run=o,i.__originalRun||LG(n,e,t),n}function LG(e,t,n){let i=e,r=t;if(typeof r.safeParse=="function"){let o=r.safeParse;i.safeParse=(a,s)=>{let c=n(a);return c!==vi?{success:!0,data:c}:o(a,s)}}if(typeof r.parse=="function"){let o=r.parse;i.parse=(a,s)=>{let c=n(a);return c!==vi?c:o(a,s)}}}function Ch(e,t){let n=!0;try{n=jh(e)}catch{}if(n)throw new an("a schema whose subtree contains a reference cycle");let i={constants:new Map,constantCounter:0,varCounter:0,definite:!0},r=new As(["input"]),o=lr(r,i,e,"input",!t?.assertOnly);r.write(o===null?"return true;":`return ${o};`);let a=["INVALID",...i.constants.keys()],s=[vi,...i.constants.values()],c=r.content.join(`
72
+ `),l=t?.debug?a.length>0?`// Constants: ${a.join(", ")}
73
+ ${c}`:c:"",u=Function,f=`return (input) => {
74
+ ${c}
75
+ }`,d;try{d=new u(...a,f)(...s)}catch(m){throw new an(`this schema (generated code failed to evaluate: ${m.message})`)}return t?.debug&&(d.code=l),d.definite=i.definite,d}function Xt(e,t){for(let[i,r]of e.constants)if(r===t)return i;let n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}function Ys(e,t){return e.definite=!1,Xt(e,t)}function xt(e){return`v${e.varCounter++}`}function XG(e,t){let n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return vi;let i=n;return i.issues.length===0?i.value:vi}function ai(e,t,n,i,r=!0){let o=e.content.length,a=t.constants.size,s=t.constantCounter,c=t.varCounter;try{return lr(e,t,n,i,r)}catch(l){if(!(l instanceof an)||!l.islandable)throw l;if(e.content.length=o,t.constants.size>a){let u=Array.from(t.constants.keys()).slice(a);for(let f of u)t.constants.delete(f)}return t.constantCounter=s,t.varCounter=c,NG(e,t,n,i)}}function NG(e,t,n,i){t.definite=!1;let r=Xt(t,n),o=Xt(t,XG),a=xt(t);return e.write(`const ${a} = ${o}(${r}, ${i});`),e.write(`if (${a} === INVALID) return INVALID;`),a}var RG=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function FG(e,t,n,i){let r=n._zod.def.checks;if(!r||r.length===0)return i;let o=i;for(let a of r){let s=a._zod.def;if(s.when&&!RG.has(s.check))throw new an('check with a custom "when" condition');switch(s.check){case"greater_than":VG(e,t,s,o);break;case"less_than":jG(e,t,s,o);break;case"multiple_of":ZG(e,t,s,o);break;case"number_format":Vz(e,s,o);break;case"min_length":{let c=Js(s.minimum,"min_length"),l=mx(e,t,o,`${o}.length >= ${c} && ${o}.length < ${s.minimum*2}`);e.write(`if (${l} < ${c}) return INVALID;`);break}case"max_length":{let c=Js(s.maximum,"max_length"),l=mx(e,t,o,`${o}.length > ${c}`);e.write(`if (${l} > ${c}) return INVALID;`);break}case"length_equals":{let c=Js(s.length,"length_equals"),l=mx(e,t,o,`${o}.length >= ${c} && ${o}.length <= ${s.length*2}`);e.write(`if (${l} !== ${c}) return INVALID;`);break}case"min_size":e.write(`if (${o}.size < ${Js(s.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${Js(s.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${Js(s.size,"size_equals")}) return INVALID;`);break;case"string_format":o=jz(e,t,s,o);break;case"custom":o=EG(e,t,a,o);break;case"bigint_format":IG(e,s,o);break;case"mime_type":WG(e,t,s,o);break;case"property":qG(e,t,s,o);break;case"properties":DG(e,t,s,o);break;case"overwrite":{let c=xt(t);HG(e,t,a,o,c),o=c;break}default:throw new an(`check type ${s.check}`)}}return o}function mx(e,t,n,i){let r=Xt(t,Cs),o=xt(t);return e.write(`const ${o} = typeof ${n} === "string" && ${i} ? ${r}(${n}) : ${n}.length;`),o}function Js(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new an(`${t} bound of type ${typeof e}`);return`${e}`}function Fz(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new an("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new an("comparison check with Invalid Date bound");return Xt(e,t)}throw new an(`comparison check bound of type ${typeof t}`)}function VG(e,t,n,i){let r=n.inclusive?"<":"<=";e.write(`if (${i} ${r} ${Fz(t,n.value)}) return INVALID;`)}function jG(e,t,n,i){let r=n.inclusive?">":">=";e.write(`if (${i} ${r} ${Fz(t,n.value)}) return INVALID;`)}function ZG(e,t,n,i){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new an("multiple_of check with a zero divisor");e.write(`if (${i} % ${n.value}n !== 0n) return INVALID;`)}else{let r=Xt(t,Of);e.write(`if (${r}(${i}, ${Js(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function Vz(e,t,n){let i=t.format;switch(i){case"safeint":e.write(`if (!Number.isSafeInteger(${n})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${n}) || ${n} < -2147483648 || ${n} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${n}) || ${n} < 0 || ${n} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${n}) || ${n} < -3.4028234663852886e38 || ${n} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${n})) return INVALID;`);break;default:throw new an(`number format ${i}`)}}function IG(e,t,n){let i=t.format;if(i)switch(i){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break;default:throw new an(`bigint format ${i}`)}}function WG(e,t,n,i){let r=n.mime;if(r&&r.length>0){let o=Xt(t,new Set(r));e.write(`if (!${o}.has(${i}.type)) return INVALID;`)}}function DG(e,t,n,i){if(n.when)throw new an('check with a custom "when" condition');e.write(`if (${i} == null) return INVALID;`);let r=n.shape;for(let o of Reflect.ownKeys(r)){let a=typeof o=="symbol"?Xt(t,o):bi(o),s=xt(t);e.write(`const ${s} = ${i}[${a}];`),ai(e,t,r[o],s,!1)}}function qG(e,t,n,i){let r=`${i}[${JSON.stringify(n.property)}]`;lr(e,t,n.schema,r)}function HG(e,t,n,i,r){let o=n._zod.def.tx;if(!o)throw new an("overwrite check without a transform function");if(Ks(o))throw new lo("z.compile: async overwrite transforms are not supported");let a=Xt(t,o);e.write(`const ${r} = ${a}(${i});`)}function px(){throw new Ni}function gx(e){this.issues.push(e)}function EG(e,t,n,i){let r=n._zod.def;if(r.fn){if(Ks(r.fn))throw new lo("z.compile: async .refine() predicates are not supported");let o=Ys(t,r.fn),a=Xt(t,px),s=xt(t);return e.write(`const ${s} = ${o}(${i});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`),i}if(n._zod.check){if(Ks(n._zod.check))throw new lo("z.compile: async .superRefine() / check functions are not supported");let o=n._zod.check,s=Ys(t,l=>{let u={value:l,issues:[],addIssue:gx};return o(u)instanceof Promise&&px(),u.issues.length===0?u.value:vi}),c=xt(t);return e.write(`const ${c} = ${s}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),c}throw new an("custom check without a predicate or check function")}var CG=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function jz(e,t,n,i,r=!0){let o=n.format;if(o==="base64"){let l=Xt(t,Jf);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(o==="base64url"){let l=Xt(t,Ph);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(o==="jwt"){let l=Xt(t,Th),u=Xt(t,n.alg??null);return e.write(`if (!${l}(${i}, ${u})) return INVALID;`),i}if(o==="ipv6"){let l=Xt(t,Gf);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(o==="cidrv6"){let l=Xt(t,wh);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(o==="credit_card"){let l=Xt(t,Sh);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(o==="iban"){let l=Xt(t,kh);return e.write(`if (!${l}(${i})) return INVALID;`),i}let a=n;if(o==="url"||o==="httpurl"||a.normalize||a.hostname!==void 0||a.protocol!==void 0){let l=Xt(t,gh),u=Xt(t,n),f=xt(t),d=xt(t);if(e.write(`const ${f} = ${i}.trim();`),e.write(`const ${d} = ${l}(${f}, ${u});`),e.write(`if (typeof ${d} === "number") return INVALID;`),a.hostname!==void 0){let b=Xt(t,vh);e.write(`if (!${b}(${d}, ${u}.hostname)) return INVALID;`)}if(a.protocol!==void 0){let b=Xt(t,yh);e.write(`if (!${b}(${d}, ${u}.protocol)) return INVALID;`)}if(!r)return null;let m=xt(t),p=a.normalize?`${d}.href`:`${Xt(t,Af)}(${f})`;return e.write(`const ${m} = ${p};`),m}let s=n.fn;if(s){if(Ks(s))throw new an(`async string format ${o}`);let l=Xt(t,s);return e.write(`if (!${l}(${i})) return INVALID;`),i}if(CG.has(o)&&n.pattern){let l=Xt(t,n.pattern);return e.write(`${l}.lastIndex = 0;`),e.write(`if (!${l}.test(${i})) return INVALID;`),i}let c=n.format;switch(c){case"regex":throw new an("regex format without a pattern");case"lowercase":e.write(`if (${i} !== ${i}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${i} !== ${i}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${i}.includes(${bi(n.includes)})) return INVALID;`);break;case"starts_with":{let l=n.prefix;e.write(`if (${i}.slice(0, ${l.length}) !== ${bi(l)}) return INVALID;`);break}case"ends_with":{let l=n.suffix;e.write(`if (${i}.slice(-${l.length}) !== ${bi(l)}) return INVALID;`);break}default:throw new an(`string format ${c}`)}return i}function lr(e,t,n,i,r=!0){let o=n._zod.def,a=o.type;if(o.coerce)throw new an(`coercion (z.coerce.${a}())`);let s=r||!!o.checks?.length,c;switch(a){case"string":c=UG(e,t,n,i,s);break;case"number":c=AG(e,n,i);break;case"boolean":c=GG(e,i);break;case"bigint":c=JG(e,n,i);break;case"symbol":c=BG(e,i);break;case"undefined":c=YG(e,i);break;case"null":c=KG(e,i);break;case"any":case"unknown":c=i;break;case"never":e.write("return INVALID;"),c=i;break;case"void":c=QG(e,i);break;case"nan":c=_G(e,i);break;case"date":c=$G(e,i);break;case"object":c=eJ(e,t,n,i,s);break;case"optional":c=tJ(e,t,n,i,s);break;case"nullable":c=iJ(e,t,n,i,s);break;case"array":c=oJ(e,t,n,i,s);break;case"literal":c=aJ(e,t,n,i);break;case"enum":c=sJ(e,t,n,i);break;case"readonly":{let l=Xz(e,t,n,i),u=xt(t);e.write(`const ${u} = Object.freeze(${l});`),c=u;break}case"success":Xz(e,t,n,i),c="true";break;case"default":case"prefault":c=cJ(e,t,n,i);break;case"nonoptional":c=lJ(e,t,n,i);break;case"tuple":c=uJ(e,t,n,i);break;case"union":c=fJ(e,t,n,i);break;case"intersection":c=pJ(e,t,n,i);break;case"record":c=hJ(e,t,n,i);break;case"map":c=gJ(e,t,n,i);break;case"set":c=vJ(e,t,n,i);break;case"file":c=yJ(e,i);break;case"template_literal":c=wJ(e,t,n,i);break;case"lazy":c=xJ(e,t,n,i);break;case"pipe":c=PJ(e,t,n,i);break;case"custom":c=SJ(e,t,n,i);break;case"transform":c=zJ(e,t,n,i);break;case"catch":c=TJ(e,t,n,i);break;default:throw new an(`schema type ${a}`)}return c===null?null:FG(e,t,n,c)}function UG(e,t,n,i,r=!0){e.write(`if (typeof ${i} !== "string") return INVALID;`);let o=n._zod.def;return o.format===void 0?i:jz(e,t,o,i,r)}function AG(e,t,n){e.write(`if (typeof ${n} !== "number" || !Number.isFinite(${n})) return INVALID;`);let i=t._zod.def;return i.check==="number_format"&&i.format&&Vz(e,{format:i.format},n),n}function GG(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function JG(e,t,n){e.write(`if (typeof ${n} !== "bigint") return INVALID;`);let i=t._zod.def;if(i.format)switch(i.format){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break}return n}function BG(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function YG(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function KG(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function QG(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function _G(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function $G(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function eJ(e,t,n,i,r=!0){let o=n._zod.def;e.write(`if (typeof ${i} !== "object" || ${i} === null || Array.isArray(${i})) return INVALID;`);let a=o.shape,s=Object.keys(a),c=Object.getOwnPropertySymbols(a),l=c.length?[...s,...c]:s,u=g=>typeof g=="symbol"?Xt(t,g):bi(g),f=g=>typeof g=="symbol"?`[${u(g)}]`:bi(g),d=a;if(s.includes("__proto__"))throw new an('object shape key "__proto__"');let m=new Map;for(let g of l){let y=d[g],w=u(g),x=xt(t);if(e.write(`const ${x} = ${i}[${w}];`),y._zod.optin!==void 0){let T=xt(t);e.write(`let ${T} = (() => {`),e.indented(z=>{let k=ai(z,t,y,x);z.write(`return ${k};`)}),e.write("})();"),y._zod.optout==="optional"?(e.write(`if (${T} === INVALID) {`),e.indented(z=>{z.write(`if (${w} in ${i}) return INVALID;`),z.write(`${T} = undefined;`)}),e.write("}")):e.write(`if (${T} === INVALID) return INVALID;`),m.set(g,T)}else{rJ(y)&&e.write(`if (!(${w} in ${i})) return INVALID;`);let T=ai(e,t,y,x,r);T!==null&&m.set(g,T)}}let p=o.catchall,b="none";if(p){let g=p._zod.def.type;if(g==="never"){let y=s.map(w=>`k !== ${bi(w)}`).join(" && ")||"true";e.write(`for (const k in ${i}) {`),e.indented(w=>{w.write(`if (${y}) return INVALID;`)}),e.write("}")}else(g==="unknown"||g==="any")&&!p._zod.def.checks?.length?b="passthrough":b="schema"}let h=xt(t),v=l.some(g=>Lz(d[g])||hx(d[g]));if(!r){if(b==="schema"){let g=s.length>0?Xt(t,new Set(s)):null;e.write(`for (const k in ${i}) {`),e.indented(y=>{y.write('if (k === "__proto__") continue;'),g&&y.write(`if (${g}.has(k)) continue;`);let w=xt(t);y.write(`const ${w} = ${i}[k];`),ai(y,t,p,w,!1)}),e.write("}")}return null}if(v){e.write(`const ${h} = {};`);for(let g of l){let y=u(g),w=m.get(g);hx(d[g])?e.write(`if (${y} in ${i}) ${h}[${y}] = ${w};`):Lz(d[g])?e.write(`if (${w} !== undefined || ${y} in ${i}) ${h}[${y}] = ${w};`):e.write(`${h}[${y}] = ${w};`)}}else{let g=l.map(y=>`${f(y)}: ${m.get(y)}`).join(", ");e.write(`const ${h} = { ${g} };`)}if(b!=="none"){let g=s.length>0?Xt(t,new Set(s)):null;e.write(`for (const k in ${i}) {`),e.indented(y=>{if(y.write('if (k === "__proto__") continue;'),g&&y.write(`if (${g}.has(k)) continue;`),b==="passthrough")y.write(`${h}[k] = ${i}[k];`);else{let w=xt(t);y.write(`const ${w} = ${i}[k];`);let x=ai(y,t,p,w);y.write(`${h}[k] = ${x};`)}}),e.write("}")}return h}function tJ(e,t,n,i,r=!0){let o=n._zod.def;if(nJ(n))return lr(e,t,o.innerType,i,r);if(o.innerType._zod.optin==="defaulted"){let s=xt(t),c=xt(t);return e.write(`let ${s};`),e.write(`if (${i} === undefined) {`),e.indented(l=>{l.write(`const ${c} = (() => {`),l.indented(u=>{let f=lr(u,t,o.innerType,i);u.write(`return ${f};`)}),l.write("})();"),l.write(`if (${c} !== INVALID) ${s} = ${c};`)}),e.write("} else {"),e.indented(l=>{let u=lr(l,t,o.innerType,i);l.write(`${s} = ${u};`)}),e.write("}"),s}let a=r?xt(t):null;return a&&e.write(`let ${a};`),e.write(`if (${i} !== undefined) {`),e.indented(s=>{let c=lr(s,t,o.innerType,i,r);a&&c!==null&&s.write(`${a} = ${c};`)}),e.write("}"),a}function nJ(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function rJ(e){return e._zod.optin===void 0&&Bs(e)}function Bs(e){if(e._zod.def.coerce)return!0;let t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?Bs(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?Bs(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Bs):!0;case"intersection":return!t.left||!t.right?!0:Bs(t.left)&&Bs(t.right);case"pipe":return t.in?Bs(t.in):!0;default:return!0}}function hx(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function Lz(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&yl(e)}function yl(e){let t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?yl(t.innerType):!0;case"union":return t.options?t.options.some(yl):!0;case"intersection":return!t.left||!t.right||yl(t.left)||yl(t.right);case"pipe":return t.out?yl(t.out):!0;default:return!0}}function iJ(e,t,n,i,r=!0){let o=n._zod.def,a=r?xt(t):null;return a&&e.write(`let ${a} = null;`),e.write(`if (${i} !== null) {`),e.indented(s=>{let c=lr(s,t,o.innerType,i,r);a&&c!==null&&s.write(`${a} = ${c};`)}),e.write("}"),a}function oJ(e,t,n,i,r=!0){let o=n._zod.def;e.write(`if (!Array.isArray(${i})) return INVALID;`);let a=r?xt(t):null,s=xt(t),c=xt(t);return a&&e.write(`const ${a} = new Array(${i}.length);`),e.write(`for (let ${s} = 0; ${s} < ${i}.length; ${s}++) {`),e.indented(l=>{l.write(`const ${c} = ${i}[${s}];`);let u=ai(l,t,o.element,c,r);a&&u!==null&&l.write(`${a}[${s}] = ${u};`)}),e.write("}"),a}function aJ(e,t,n,i){let o=n._zod.def.values;if(o.length!==1){let s=Xt(t,new Set(o));return e.write(`if (!${s}.has(${i})) return INVALID;`),i}let a=o[0];if(typeof a=="number"&&Number.isNaN(a)){let s=Xt(t,new Set(o));return e.write(`if (!${s}.has(${i})) return INVALID;`),i}if(typeof a=="string")e.write(`if (${i} !== ${bi(a)}) return INVALID;`);else if(typeof a=="number"||typeof a=="boolean")e.write(`if (${i} !== ${a}) return INVALID;`);else if(a===null)e.write(`if (${i} !== null) return INVALID;`);else if(a===void 0)e.write(`if (${i} !== undefined) return INVALID;`);else if(typeof a=="bigint")e.write(`if (${i} !== ${a}n) return INVALID;`);else throw new an(`literal type ${typeof a}`);return i}function sJ(e,t,n,i){let r=n._zod.values;if(!r)throw new an("enum schema without enumerated values");let o=Xt(t,r);return e.write(`if (!${o}.has(${i})) return INVALID;`),i}function Xz(e,t,n,i){let r=n._zod.def;return lr(e,t,r.innerType,i)}function cJ(e,t,n,i){let r=n._zod.def,a=Object.getOwnPropertyDescriptor(n._zod.def,"defaultValue")?()=>n._zod.def.defaultValue:void 0;if(n._zod.def.type==="prefault"){if(!a)return lr(e,t,r.innerType,i);let c=Xt(t,a),l=xt(t);return e.write(`let ${l} = ${i};`),e.write(`if (${i} === undefined) ${l} = ${c}();`),lr(e,t,r.innerType,l)}let s=xt(t);if(a){let c=Xt(t,a),l=Xt(t,Lf);e.write(`let ${s};`),e.write(`if (${i} === undefined) {`),e.indented(u=>{u.write(`${s} = ${l}(${c}());`)}),e.write("} else {"),e.indented(u=>{let f=lr(u,t,r.innerType,i);u.write(`${s} = ${f} === undefined ? ${l}(${c}()) : ${f};`)}),e.write("}")}else e.write(`let ${s};`),e.write(`if (${i} !== undefined) {`),e.indented(c=>{let l=lr(c,t,r.innerType,i);c.write(`${s} = ${l};`)}),e.write("}");return s}function lJ(e,t,n,i){let r=n._zod.def,o=lr(e,t,r.innerType,i),a=xt(t);return e.write(`const ${a} = ${o};`),e.write(`if (${a} === undefined) return INVALID;`),a}function uJ(e,t,n,i){let r=n._zod.def,o=r.items,a=r.rest;e.write(`if (!Array.isArray(${i})) return INVALID;`);let s=Nz(o,"optin"),c=Nz(o,"optout");a?e.write(`if (${i}.length < ${s}) return INVALID;`):e.write(`if (${i}.length < ${s} || ${i}.length > ${o.length}) return INVALID;`);let l=xt(t);e.write(`const ${l} = [];`);for(let u=0;u<o.length;u++){let f=o[u];if(u>=c)e.write(`if (${l}.length === ${u}) {`),e.indented(d=>{d.write(`if (${u} < ${i}.length) {`),d.indented(m=>{let p=xt(t);m.write(`const ${p} = ${i}[${u}];`);let b=ai(m,t,f,p);m.write(`${l}[${u}] = ${b};`)}),d.write("} else {"),d.indented(m=>{if(hx(f)){m.write(`${l}.length = ${u};`);return}let p=xt(t),b=xt(t);m.write(`const ${p} = undefined;`),m.write(`const ${b} = (() => {`),m.indented(h=>{let v=ai(h,t,f,p);h.write(`return ${v};`)}),m.write("})();"),m.write(`if (${b} === INVALID || ${b} === undefined) ${l}.length = ${u};`),m.write(`else ${l}[${u}] = ${b};`)}),d.write("}")}),e.write("}");else{let d=xt(t);e.write(`const ${d} = ${i}[${u}];`);let m=ai(e,t,f,d);e.write(`${l}[${u}] = ${m};`)}}if(a){let u=xt(t),f=xt(t);e.write(`for (let ${u} = ${o.length}; ${u} < ${i}.length; ${u}++) {`),e.indented(d=>{d.write(`const ${f} = ${i}[${u}];`);let m=ai(d,t,a,f);d.write(`${l}[${u}] = ${m};`)}),e.write("}")}return l}function Nz(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function fJ(e,t,n,i){let r=n._zod.def,o=r.options;if(r.discriminator)return dJ(e,t,r,i);if(r.inclusive===!1)throw new an("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),i;if(o.length===1)return lr(e,t,o[0],i);if(o.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){let c=new Set(o.flatMap(u=>u._zod.def.values)),l=Xt(t,c);return e.write(`if (!${l}.has(${i})) return INVALID;`),i}let s=xt(t);e.write(`let ${s};`);for(let c=0;c<o.length;c++){let l=o[c];c===0?e.write(`${s} = (() => {`):e.write(`if (${s} === INVALID) ${s} = (() => {`),e.indented(u=>{let f=lr(u,t,l,i);u.write(`return ${f};`)}),e.write("})();")}return e.write(`if (${s} === INVALID) return INVALID;`),s}function dJ(e,t,n,i){if(n.unionFallback)throw new an("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),i;let r=xt(t),o=xt(t);e.write(`const ${r} = ${i}?.[${bi(n.discriminator)}];`),e.write(`let ${o};`);let a=!0,s=new Set;for(let c of n.options){let l=c._zod.propValues?.[n.discriminator];if(!l||l.size===0)throw new an("discriminated union option without static discriminator values");for(let d of l){if(s.has(d))throw new an(`duplicate discriminator value ${String(d)}`);s.add(d)}let u=Array.from(l,d=>mJ(t,r,d)),f=a?"if":"else if";e.write(`${f} (${u.join(" || ")}) {`),e.indented(d=>{let m=lr(d,t,c,i);d.write(`${o} = ${m};`)}),e.write("}"),a=!1}return e.write("else { return INVALID; }"),o}function mJ(e,t,n){if(typeof n=="string")return`${t} === ${bi(n)}`;if(typeof n=="number")return Number.isNaN(n)?`Number.isNaN(${t})`:`${t} === ${n}`;if(typeof n=="boolean")return`${t} === ${n}`;if(n===null)return`${t} === null`;if(n===void 0)return`${t} === undefined`;if(typeof n=="bigint")return`${t} === ${n}n`;if(typeof n=="symbol"){let i=Xt(e,n);return`${t} === ${i}`}throw new an(`literal discriminator value ${String(n)}`)}function pJ(e,t,n,i){let r=n._zod.def;t.definite=!1;let o=ai(e,t,r.left,i),a=ai(e,t,r.right,i),s=Xt(t,bl),c=xt(t);return e.write(`const ${c} = ${s}(${o}, ${a});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function hJ(e,t,n,i){let r=n._zod.def,o=Xt(t,Yi);e.write(`if (!${o}(${i})) return INVALID;`);let a=xt(t),s=xt(t),c=xt(t);e.write(`const ${a} = {};`);let l=r,u=l.partial?void 0:r.keyType._zod.values;if(u){let m=[];for(let b of u){if(!(typeof b=="string"||typeof b=="number"||typeof b=="symbol"))throw new an(`record key value ${String(b)}`);let h=typeof b=="number"?b.toString():b;if(h==="__proto__")throw new an('record key "__proto__"');m.push(h);let v=Xt(t,b),g=lr(e,t,r.keyType,v),y=xt(t);e.write(`const ${y} = ${i}[${bJ(t,h)}];`);let w=ai(e,t,r.valueType,y);e.write(`${a}[${g}] = ${w};`)}let p=Xt(t,new Set(m));return e.write(`for (const ${s} in ${i}) {`),e.indented(b=>{b.write(`if (${p}.has(${s})) continue;`),l.mode==="loose"?b.write(`if (${s} !== "__proto__") ${a}[${s}] = ${i}[${s}];`):b.write("return INVALID;")}),e.write("}"),a}let f=r.keyType._zod.def;if(!(f.type==="string"&&f.format===void 0&&!f.coerce&&(f.checks?.length??0)===0)){let m=r.mode==="loose",p=Ch(r.keyType);p.definite===!1&&(t.definite=!1);let b=Xt(t,p),h=Xt(t,aa),v=xt(t);return Rz(e,t,i,s,g=>{g.write(`let ${v} = ${b}(${s});`),g.write(`if (${v} === INVALID && typeof ${s} === "string" && ${h}.test(${s})) ${v} = ${b}(Number(${s}));`),m?g.write(`if (${v} === INVALID) { ${a}[${s}] = ${i}[${s}]; continue; }`):g.write(`if (${v} === INVALID) return INVALID;`),g.write(`if (${v} === "__proto__") continue;`);let y=xt(t);g.write(`const ${y} = ${i}[${s}];`);let w=ai(g,t,r.valueType,y);g.write(`${a}[${v}] = ${w};`)}),a}return Rz(e,t,i,s,m=>{m.write(`const ${c} = ${i}[${s}];`);let p=ai(m,t,r.valueType,c);m.write(`${a}[${s}] = ${p};`)},"return INVALID;"),a}function Rz(e,t,n,i,r,o){let a=Xt(t,Object.prototype.propertyIsEnumerable),s=xt(t),c=xt(t),l=xt(t);e.write(`const ${s} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${c} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${l} = 0; ${l} < ${c}.length; ${l}++) {`),e.indented(u=>{u.write(`const ${i} = ${c}[${l}];`),u.write(`if (${i} === "__proto__" || !${a}.call(${n}, ${i})) continue;`),r(u)}),e.write("}"),e.write(`for (let ${l} = 0; ${l} < ${s}.length; ${l}++) {`),e.indented(u=>{u.write(`const ${i} = ${s}[${l}];`),u.write(`if (!${a}.call(${n}, ${i})) continue;`),o?u.write(o):r(u)}),e.write("}")}function bJ(e,t){return typeof t=="string"?bi(t):Xt(e,t)}function gJ(e,t,n,i){let r=n._zod.def;e.write(`if (!(${i} instanceof Map)) return INVALID;`);let o=xt(t),a=xt(t),s=xt(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${a}, ${s}] of ${i}) {`),e.indented(c=>{let l=lr(c,t,r.keyType,a),u=lr(c,t,r.valueType,s);c.write(`${o}.set(${l}, ${u});`)}),e.write("}"),o}function vJ(e,t,n,i){let r=n._zod.def;e.write(`if (!(${i} instanceof Set)) return INVALID;`);let o=xt(t),a=xt(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${a} of ${i}) {`),e.indented(s=>{let c=lr(s,t,r.valueType,a);s.write(`${o}.add(${c});`)}),e.write("}"),o}function yJ(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function wJ(e,t,n,i){e.write(`if (typeof ${i} !== "string") return INVALID;`);let r=n._zod.pattern;if(r){let o=Xt(t,r);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${i})) return INVALID;`)}return i}function xJ(e,t,n,i){let r=n._zod.def,o=Ys(t,r.getter),a=Xt(t,{parser:null});e.write(`if (!${a}.parser) {`),e.indented(c=>{c.write(`const inner = ${o}();`),c.write(`${a}.parser = function(input) {`),c.indented(l=>{l.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),l.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),e.write("}");let s=xt(t);return e.write(`const ${s} = ${a}.parser(${i});`),e.write(`if (${s} === INVALID) return INVALID;`),s}function PJ(e,t,n,i){let r=n._zod.def,o=lr(e,t,r.in,i);if(r.transform){if(Ks(r.transform))throw new lo("z.compile: async transforms in pipes are not supported");let a=r.transform,c=Ys(t,u=>{let f={value:u,issues:[],addIssue:gx},d=a(u,f);return d instanceof Promise?vi:f.issues.length===0?d:vi}),l=xt(t);return e.write(`const ${l} = ${c}(${o});`),e.write(`if (${l} === INVALID) return INVALID;`),lr(e,t,r.out,l)}else return lr(e,t,r.out,o)}function Ks(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function SJ(e,t,n,i){let r=n._zod.def;if(r.fn){if(Ks(r.fn))throw new lo("z.compile: async custom predicates are not supported");let o=Ys(t,r.fn),a=Xt(t,px),s=xt(t);e.write(`const ${s} = ${o}(${i});`),e.write(`if (${s} instanceof Promise) ${a}();`),e.write(`if (!${s}) return INVALID;`)}else throw new an("custom schema without a predicate function");return i}function kJ(e,t,n){let i=e._zod.run({value:n,issues:[]},{});if(i&&typeof i.then=="function")return vi;let r=i;return r.issues.length===0?r.value:t()}function TJ(e,t,n,i){let r=n._zod.def;if(!r.catchValue[Bp])throw new an("catch with a callback (only a constant catch value compiles)",!1);let o=xt(t);e.write(`let ${o} = (() => {`),e.indented(l=>{let u=ai(l,t,r.innerType,i);l.write(`return ${u};`)}),e.write("})();");let a=Xt(t,r.innerType),s=Ys(t,r.catchValue),c=Xt(t,kJ);return e.write(`if (${o} === INVALID) {`),e.indented(l=>{l.write(`${o} = ${c}(${a}, ${s}, ${i});`),l.write(`if (${o} === INVALID) return INVALID;`)}),e.write("}"),o}function zJ(e,t,n,i){let r=n._zod.def;if(r.transform){if(Ks(r.transform))throw new lo("z.compile: async transforms are not supported");let o=r.transform,s=Ys(t,l=>{let u={value:l,issues:[],addIssue:gx},f=o(l,u);return f instanceof Promise?vi:u.issues.length===0?f:vi}),c=xt(t);return e.write(`const ${c} = ${s}(${i});`),e.write(`if (${c} === INVALID) return INVALID;`),c}return i}function Uh(e){return e.checks&&(e.checks=[...e.checks]),e}function vx(e,t){return new e(Uh({type:"string",...Ve(t)}))}function yx(e,t){return new e(Uh({type:"string",coerce:!0,...Ve(t)}))}function Ah(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...Ve(t)})}function Gh(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...Ve(t)})}function Jh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...Ve(t)})}function Bh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Ve(t)})}function Yh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Ve(t)})}function Kh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Ve(t)})}function id(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Ve(t)})}function Qh(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...Ve(t)})}function _h(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...Ve(t)})}function $h(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...Ve(t)})}function eb(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...Ve(t)})}function tb(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...Ve(t)})}function nb(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...Ve(t)})}function rb(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...Ve(t)})}function ib(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...Ve(t)})}function ob(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...Ve(t)})}function wx(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...Ve(t)})}function ab(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Ve(t)})}function sb(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Ve(t)})}function cb(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...Ve(t)})}function lb(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...Ve(t)})}function ub(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...Ve(t)})}function xx(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...Ve(t)})}function Px(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...Ve(t)})}function fb(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...Ve(t)})}var Sx={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function od(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Ve(t)})}function ad(e,t){return new e({type:"string",format:"date",check:"string_format",...Ve(t)})}function sd(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...Ve(t)})}function cd(e,t){return new e({type:"string",format:"duration",check:"string_format",...Ve(t)})}function kx(e,t){return new e(Uh({type:"number",checks:[],...Ve(t)}))}function Tx(e,t){return new e(Uh({type:"number",coerce:!0,checks:[],...Ve(t)}))}function zx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Ve(t)})}function Mx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...Ve(t)})}function Ox(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...Ve(t)})}function Lx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...Ve(t)})}function Xx(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...Ve(t)})}function Nx(e,t){return new e({type:"boolean",...Ve(t)})}function Rx(e,t){return new e({type:"boolean",coerce:!0,...Ve(t)})}function Fx(e,t){return new e({type:"bigint",...Ve(t)})}function Vx(e,t){return new e({type:"bigint",coerce:!0,...Ve(t)})}function jx(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...Ve(t)})}function Zx(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...Ve(t)})}function Ix(e,t){return new e({type:"symbol",...Ve(t)})}function Wx(e,t){return new e({type:"undefined",...Ve(t)})}function Dx(e,t){return new e({type:"null",...Ve(t)})}function qx(e){return new e({type:"any"})}function Hx(e){return new e({type:"unknown"})}function Ex(e,t){return new e({type:"never",...Ve(t)})}function Cx(e,t){return new e({type:"void",...Ve(t)})}function Ux(e,t){return new e({type:"date",...Ve(t)})}function Ax(e,t){return new e({type:"date",coerce:!0,...Ve(t)})}function Gx(e,t){return new e({type:"nan",...Ve(t)})}function Mo(e,t){return new uh({check:"less_than",...Ve(t),value:e,inclusive:!1})}function qi(e,t){return new uh({check:"less_than",...Ve(t),value:e,inclusive:!0})}function Oo(e,t){return new fh({check:"greater_than",...Ve(t),value:e,inclusive:!1})}function Hi(e,t){return new fh({check:"greater_than",...Ve(t),value:e,inclusive:!0})}function db(e){return Oo(0,e)}function mb(e){return Mo(0,e)}function pb(e){return qi(0,e)}function hb(e){return Hi(0,e)}function Ga(e,t){return new X1({check:"multiple_of",...Ve(t),value:e})}function Ja(e,t){return new F1({check:"max_size",...Ve(t),maximum:e})}function Lo(e,t){return new V1({check:"min_size",...Ve(t),minimum:e})}function Qs(e,t){return new j1({check:"size_equals",...Ve(t),size:e})}function _s(e,t){return new Z1({check:"max_length",...Ve(t),maximum:e})}function sa(e,t){return new I1({check:"min_length",...Ve(t),minimum:e})}function $s(e,t){return new W1({check:"length_equals",...Ve(t),length:e})}function wl(e,t){return new D1({check:"string_format",format:"regex",...Ve(t),pattern:e})}function xl(e){return new q1({check:"string_format",format:"lowercase",...Ve(e)})}function Pl(e){return new H1({check:"string_format",format:"uppercase",...Ve(e)})}function Sl(e,t){return new E1({check:"string_format",format:"includes",...Ve(t),includes:e})}function kl(e,t){return new C1({check:"string_format",format:"starts_with",...Ve(t),prefix:e})}function Tl(e,t){return new U1({check:"string_format",format:"ends_with",...Ve(t),suffix:e})}function bb(e,t,n){return new A1({check:"property",property:e,schema:t,...Ve(n)})}function zl(e,t){return new G1({check:"properties",shape:e,...Ve(t)})}function Ml(e,t){return new J1({check:"mime_type",mime:e,...Ve(t)})}function uo(e){return new B1({check:"overwrite",tx:e})}function Ol(e){return uo(t=>t.normalize(e))}function Ll(){return uo(e=>e.trim())}function Xl(){return uo(e=>e.toLowerCase())}function Nl(){return uo(e=>e.toUpperCase())}function Rl(){return uo(e=>Ry(e))}function Jx(e,t,n){return new e({type:"array",element:t,...Ve(n)})}function MJ(e,t,n){return new e({type:"union",options:t,...Ve(n)})}function OJ(e,t,n){return new e({type:"union",options:t,inclusive:!1,...Ve(n)})}function LJ(e,t,n,i){return new e({type:"union",options:n,discriminator:t,...Ve(i)})}function XJ(e,t,n){return new e({type:"intersection",left:t,right:n})}function NJ(e,t,n,i){let r=n instanceof It,o=r?i:n,a=r?n:null;return new e({type:"tuple",items:t,rest:a,...Ve(o)})}function RJ(e,t,n,i){return new e({type:"record",keyType:t,valueType:n,...Ve(i)})}function FJ(e,t,n,i){return new e({type:"map",keyType:t,valueType:n,...Ve(i)})}function VJ(e,t,n){return new e({type:"set",valueType:t,...Ve(n)})}function jJ(e,t,n){let i=Array.isArray(t)?Object.fromEntries(t.map(r=>[r,r])):t;return new e({type:"enum",entries:i,...Ve(n)})}function ZJ(e,t,n){return new e({type:"enum",entries:t,...Ve(n)})}function IJ(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...Ve(n)})}function Bx(e,t){return new e({type:"file",...Ve(t)})}function WJ(e,t){return new e({type:"transform",transform:t})}function DJ(e,t){return new e({type:"optional",innerType:t})}function qJ(e,t){return new e({type:"nullable",innerType:t})}function HJ(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():Lf(n)}})}function EJ(e,t,n){return new e({type:"nonoptional",innerType:t,...Ve(n)})}function CJ(e,t){return new e({type:"success",innerType:t})}function UJ(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:Wy(n)})}function AJ(e,t,n){return new e({type:"pipe",in:t,out:n})}function GJ(e,t){return new e({type:"readonly",innerType:t})}function JJ(e,t,n){return new e({type:"template_literal",parts:t,...Ve(n)})}function BJ(e,t){return new e({type:"lazy",getter:t})}function YJ(e,t){return new e({type:"promise",innerType:t})}function Yx(e,t,n){let i=Ve(n);return i.abort??(i.abort=!0),new e({type:"custom",check:"custom",fn:t,...i})}function Kx(e,t,n){return new e({type:"custom",check:"custom",fn:t,...Ve(n)})}function Qx(e,t){let n=Zz(i=>(i.addIssue=r=>{if(typeof r=="string")i.issues.push(ul(r,i.value,n._zod.def));else{let o=r;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=i.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),i.issues.push(ul(o))}},e(i.value,i)),t);return n}function Zz(e,t){let n=new Jn({check:"custom",...Ve(t)});return n._zod.check=e,n}function _x(e){let t=new Jn({check:"describe"});return t._zod.onattach=[n=>{let i=Kr.get(n)??{};Kr.add(n,{...i,description:e})}],t._zod.check=()=>{},t}function $x(e){let t=new Jn({check:"meta"});return t._zod.onattach=[n=>{let i=Kr.get(n)??{};Kr.add(n,{...i,...e})}],t._zod.check=()=>{},t}function e3(e,t){let n=Ve(t),i=n.truthy??["true","1","yes","on","y","enabled"],r=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(i=i.map(m=>typeof m=="string"?m.toLowerCase():m),r=r.map(m=>typeof m=="string"?m.toLowerCase():m));let o=new Set(i),a=new Set(r),s=e.Codec??Qf,c=e.Boolean??Yf,l=e.String??Gs,u=new l({type:"string",error:n.error}),f=new c({type:"boolean",error:n.error}),d=new s({type:"pipe",in:u,out:f,transform:((m,p)=>{let b=m;return n.case!=="sensitive"&&(b=b.toLowerCase()),o.has(b)?!0:a.has(b)?!1:(p.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...a],input:p.value,inst:d,continue:!1}),{})}),reverseTransform:((m,p)=>m===!0?i[0]||"true":r[0]||"false"),error:n.error});return d._zod.bag.truthy=i,d._zod.bag.falsy=r,d._zod.bag.case=n.case??"insensitive",d}function ec(e,t,n,i={}){let r=Ve(i),o={check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:s=>n.test(s),...r};return n instanceof RegExp&&(o.pattern=n),new e(o)}function ld(e,...t){for(let n of t)for(let i of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,i)&&Yr(e,i,n[i]);return e}function Ba(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Kr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function jr(e,t,n,i,r){let o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:i.path,message:r}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(r);return Object.assign(n,o),!0}function Wn(e,t,n={path:[],schemaPath:[]}){var i;let r=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;let a={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,a),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{let u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,u);else{let d=a.schema,m=t.processors[r.type];if(!m)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);m(e,t,d,u)}let f=e._zod.parent;f&&(a.ref||(a.ref=f),Wn(f,t,u),t.seen.get(f).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&ld(a.schema,c),t.io==="input"&&yi(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&"_prefault"in a.schema&&((i=a.schema).default??(i.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Iz(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Ya(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let i=new Map;for(let a of e.seen.entries()){let s=e.metadataRegistry.get(a[0])?.id;if(s){let c=i.get(s);if(c&&c!==a[0])throw new Error(`Duplicate schema id "${s}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(s,a[0])}}let r=a=>{let s=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let f=e.external.registry.get(a[0])?.id,d=e.external.uri??(p=>p);if(f)return{ref:d(f)};let m=a[1].defId??a[1].schema.id??`schema${e.counter++}`;return a[1].defId=m,{defId:m,ref:`${d("__shared")}#/${s}/${Iz(m)}`}}let c="#",l=`${c}/${s}/`;if(a[1]===n&&!a[1].schema.id)return{ref:c};let u=a[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+Iz(u)}},o=a=>{if(a[1].schema.$ref)return;let s=a[1],{ref:c,defId:l}=r(a);s.def={...s.schema},l&&(s.defId=l);let u=s.schema;for(let f in u)delete u[f];u.$ref=c};if(e.cycles==="throw")for(let a of e.seen.entries()){let s=a[1];if(s.cycle)throw new Error(`Cycle detected: #/${s.cycle?.join("/")}/<root>
76
+
77
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let a of e.seen.entries()){let s=a[1];if(t===a[0]){o(a);continue}if(e.external){let l=e.external.registry.get(a[0])?.id;if(t!==a[0]&&l){o(a);continue}}if(e.metadataRegistry.get(a[0])?.id){o(a);continue}if(s.cycle){o(a);continue}s.count>1&&e.reused==="ref"&&o(a)}e.external&&(e.sharedDefsExtractedFor=e.external)}function qz(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let i of t){if(!i||typeof i!="object")return;qz(i);let r=Object.keys(i);if(r.length!==1||r[0]!=="type")return;let o=i.type;for(let a of Array.isArray(o)?o:[o]){if(typeof a!="string")return;n.includes(a)||n.push(a)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Hz=new Set(["type","properties","required","additionalProperties"]),Wz=["oneOf","anyOf"];function Dz(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function t3(e){let t=[];for(let o of e){if(typeof o!="object"||o.type!=="object")return null;for(let a in o)if(!Hz.has(a))return null;t.push(o)}let n={},i=new Set;for(let o of t){for(let a in o.properties){if(Object.prototype.hasOwnProperty.call(n,a))continue;let s=[];for(let l of t){let u=l.properties?.[a]??Dz(l);u!=null&&(s.some(f=>JSON.stringify(f)===JSON.stringify(u))||s.push(u))}let c=s.length===1?s[0]:t3(s)??{allOf:s};Yr(n,a,c)}for(let a of o.required??[])i.add(a)}let r={type:"object",properties:n};if(i.size&&(r.required=[...i]),t.every(o=>o.additionalProperties===!1))r.additionalProperties=!1;else{let o=[];for(let a of t){let s=Dz(a);s&&!o.some(c=>JSON.stringify(c)===JSON.stringify(s))&&o.push(s)}o.length===1?r.additionalProperties=o[0]:o.length>1&&(r.additionalProperties={allOf:o})}return r}function KJ(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let r of Hz)if(r in e)return;let n=t.filter(r=>Wz.some(o=>Array.isArray(r[o]))),i=null;if(!n.length)i=t3(t);else{let r=n[0],o=Wz.find(c=>Array.isArray(r[c]));if(Object.keys(r).length!==1)return;let a=t.filter(c=>c!==r),s=r[o].map(c=>t3([...a,c]));if(s.some(c=>!c))return;i={[o]:s}}i&&(delete e.allOf,ld(e,i))}function Ka(e,t){let n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");let i=s=>{let c=e.seen.get(s);if(c.ref===null)return;let l=c.def??c.schema,u={...l},f=c.ref;if(c.ref=null,f){i(f);let m=e.seen.get(f),p=m.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(p)):ld(l,p),ld(l,u),s._zod.parent===f)for(let h in l)h==="$ref"||h==="allOf"||h in u||delete l[h];if(p.$ref&&m.def)for(let h in l)h==="$ref"||h==="allOf"||h in m.def&&JSON.stringify(l[h])===JSON.stringify(m.def[h])&&delete l[h]}let d=s._zod.parent;if(d&&d!==f){i(d);let m=e.seen.get(d);if(m?.schema.$ref&&(l.$ref=m.schema.$ref,m.def))for(let p in l)p==="$ref"||p==="allOf"||p in m.def&&JSON.stringify(l[p])===JSON.stringify(m.def[p])&&delete l[p]}e.override({zodSchema:s,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let s of[...e.seen.entries()].reverse())i(s[0]);if(e.target!=="openapi-3.0")for(let s of e.seen.entries())qz(s[1].def??s[1].schema);for(let s of e.deferred)s();if(e.intersections.length){let s=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let f=s.get(u);f?f.push(l):s.set(u,[l])}for(let c of e.intersections)for(let l of s.get(c)??[])KJ(l)}}let r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(s)}ld(r,n.defId?n.schema:n.def??n.schema);let o=e.metadataRegistry.get(t)?.id;o!==void 0&&r.id===o&&delete r.id;let a=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let s of e.seen.entries()){let c=s[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Yr(a,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(a).length>0&&(e.target==="draft-2020-12"?r.$defs=a:r.definitions=a);try{let s=JSON.parse(JSON.stringify(r));return Object.defineProperty(s,"~standard",{value:{...t["~standard"],jsonSchema:{input:Fl(t,"input",e.processors),output:Fl(t,"output",e.processors)}},enumerable:!1,writable:!1}),s}catch{throw new Error("Error converting schema to JSON.")}}function yi(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return yi(i.element,n);if(i.type==="set")return yi(i.valueType,n);if(i.type==="lazy")return yi(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault"||i.type==="catch")return yi(i.innerType,n);if(i.type==="intersection")return yi(i.left,n)||yi(i.right,n);if(i.type==="record"||i.type==="map")return yi(i.keyType,n)||yi(i.valueType,n);if(i.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:yi(i.in,n)||yi(i.out,n);if(i.type==="object"){for(let r in i.shape)if(yi(i.shape[r],n))return!0;return!1}if(i.type==="union"){for(let r of i.options)if(yi(r,n))return!0;return!1}if(i.type==="tuple"){for(let r of i.items)if(yi(r,n))return!0;return!!(i.rest&&yi(i.rest,n))}return!1}var n3=(e,t={})=>n=>{let i=Ba({...n,processors:t});return Wn(e,i),Ya(i,e),Ka(i,e)},Fl=(e,t,n={})=>i=>{let{libraryOptions:r,target:o}=i??{},a=Ba({...r??{},target:o,io:t,processors:n});return Wn(e,a),Ya(a,e),Ka(a,e)};var Vl=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},jl=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Ez=(e,t)=>{Vl(e,"minimum",t),jl(e,"maximum",t)},Gz=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Jz=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Bz=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},Yz=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Cz=(e,t)=>Vl(e,"minimum",t.minimum),Uz=(e,t)=>jl(e,"maximum",t.maximum),Az=e=>(t,n)=>{Yz(t,n.format);let[i,r]=e[n.format];Vl(t,"minimum",i),jl(t,"maximum",r)},QJ={greater_than:(e,t)=>Vl(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>jl(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Gz(e,t.value),number_format:Az(Nf),bigint_format:Az(Rf),min_length:Cz,max_length:Uz,length_equals:(e,t)=>Ez(e,t.length),min_size:Cz,max_size:Uz,size_equals:(e,t)=>Ez(e,t.size),string_format:(e,t)=>{Yz(e,t.format),t.pattern&&Jz(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Bz(e,t.mime)};function Zr(e){let t={},n=e._zod.def,i=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(let o of i)QJ[o._zod.def.check]?.(t,o._zod.def);let r=e._zod.bag;r.minimum!==void 0&&Vl(t,"minimum",r.minimum),r.exclusiveMinimum!==void 0&&Vl(t,"exclusiveMinimum",r.exclusiveMinimum),r.maximum!==void 0&&jl(t,"maximum",r.maximum),r.exclusiveMaximum!==void 0&&jl(t,"exclusiveMaximum",r.exclusiveMaximum),r.multipleOf!==void 0&&Gz(t,r.multipleOf),r.format!==void 0&&(t.format??(t.format=r.format),r.format.includes("int")&&(t.isInt=!0)),r.mime&&Bz(t,r.mime);for(let o of r.patterns??[])Jz(t,o);return t}var _J={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},$J=new Map([[xh,u1],[Bf,f1]]),Kz=e=>$J.get(e)??e,o3=(e,t,n,i)=>{let r=n;r.type="string";let{minimum:o,maximum:a,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Zr(e);if(typeof o=="number"&&(r.minLength=o),typeof a=="number"&&(r.maxLength=a),s&&(r.format=_J[s]??s,r.format===""&&delete r.format,(s==="time"||u)&&delete r.format),l&&(r.contentEncoding=l),c&&c.size>0){let f=[...c].map(Kz);f.length===1?r.pattern=f[0].source:f.length>1&&(r.allOf=[...f.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},a3=(e,t,n,i)=>{let r=n,{minimum:o,maximum:a,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Zr(e);r.type=u?"integer":"number";let f=typeof l=="number"&&l>=(o??Number.NEGATIVE_INFINITY),d=typeof c=="number"&&c<=(a??Number.POSITIVE_INFINITY),m=t.target==="draft-04"||t.target==="openapi-3.0";if(f?m?(r.minimum=l,r.exclusiveMinimum=!0):r.exclusiveMinimum=l:typeof o=="number"&&(r.minimum=o),d?m?(r.maximum=c,r.exclusiveMaximum=!0):r.exclusiveMaximum=c:typeof a=="number"&&(r.maximum=a),s){let p=new Set;for(let v of s)Number.isFinite(v)&&v!==0?p.add(Math.abs(v)):jr(e,t,r,i,`A multipleOf divisor of ${v} cannot be represented in JSON Schema`);let[b,...h]=p;b!==void 0&&(r.multipleOf=b),h.length&&(r.allOf=[...r.allOf??[],...h.map(v=>({multipleOf:v}))])}},s3=(e,t,n,i)=>{n.type="boolean"},c3=(e,t,n,i)=>{jr(e,t,n,i,"BigInt cannot be represented in JSON Schema")},l3=(e,t,n,i)=>{jr(e,t,n,i,"Symbols cannot be represented in JSON Schema")},u3=(e,t,n,i)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},f3=(e,t,n,i)=>{jr(e,t,n,i,"Undefined cannot be represented in JSON Schema")},d3=(e,t,n,i)=>{jr(e,t,n,i,"Void cannot be represented in JSON Schema")},m3=(e,t,n,i)=>{n.not={}},p3=(e,t,n,i)=>{},h3=(e,t,n,i)=>{},b3=(e,t,n,i)=>{jr(e,t,n,i,"Date cannot be represented in JSON Schema")},g3=(e,t,n,i)=>{let r=e._zod.def,o=al(r.entries);if(o.length===0){n.not={};return}o.every(a=>typeof a=="number")&&(n.type="number"),o.every(a=>typeof a=="string")&&(n.type="string"),n.enum=o},v3=(e,t,n,i)=>{let r=e._zod.def;if(r.values.length===0){n.not={};return}let o=[];for(let a of r.values)if(a===void 0){if(jr(e,t,n,i,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof a=="bigint"){if(jr(e,t,n,i,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(a))}else o.push(a);if(o.length!==0)if(o.length===1){let a=o[0];n.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[a]:n.const=a}else o.every(a=>typeof a=="number")&&(n.type="number"),o.every(a=>typeof a=="string")&&(n.type="string"),o.every(a=>typeof a=="boolean")&&(n.type="boolean"),o.every(a=>a===null)&&(n.type="null"),n.enum=o},y3=(e,t,n,i)=>{jr(e,t,n,i,"NaN cannot be represented in JSON Schema")},w3=(e,t,n,i)=>{let r=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");r.type="string",r.pattern=o.source},x3=(e,t,n,i)=>{let r=n;r.type="string",r.format="binary",r.contentEncoding="binary";let{minimum:o,maximum:a,mime:s}=Zr(e);o!==void 0&&(r.minLength=o),a!==void 0&&(r.maxLength=a),s&&(s.length===0?r.not={}:s.length===1?r.contentMediaType=s[0]:r.anyOf=s.map(c=>({contentMediaType:c})))},P3=(e,t,n,i)=>{n.type="boolean"},S3=(e,t,n,i)=>{jr(e,t,n,i,"Custom types cannot be represented in JSON Schema")},k3=(e,t,n,i)=>{jr(e,t,n,i,"Function types cannot be represented in JSON Schema")},T3=(e,t,n,i)=>{jr(e,t,n,i,"Transforms cannot be represented in JSON Schema")},z3=(e,t,n,i)=>{jr(e,t,n,i,"Map cannot be represented in JSON Schema")},M3=(e,t,n,i)=>{jr(e,t,n,i,"Set cannot be represented in JSON Schema")},O3=(e,t,n,i)=>{let r=n,o=e._zod.def,{minimum:a,maximum:s}=Zr(e);typeof a=="number"&&(r.minItems=a),typeof s=="number"&&(r.maxItems=s),r.type="array",r.items=Wn(o.element,t,{...i,path:[...i.path,"items"]})};function ud(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?ud(t.out):t.type==="catch"?ud(t.innerType):e._zod.optin}var L3=(e,t,n,i)=>{let r=n,o=e._zod.def,a=o.shape;if(Object.getOwnPropertySymbols(a).length&&jr(e,t,r,i,"Symbol keys cannot be represented in JSON Schema"))return;r.type="object",r.properties={};for(let l in a)Yr(r.properties,l,Wn(a[l],t,{...i,path:[...i.path,"properties",l]}));let c=[];for(let l of Object.keys(a)){let u=o.shape[l];(t.io==="input"?ud(u)===void 0:u._zod.optout===void 0)&&c.push(l)}c.length>0&&(r.required=c),o.catchall?._zod.def.type==="never"?r.additionalProperties=!1:o.catchall?o.catchall&&(r.additionalProperties=Wn(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},vb=(e,t,n,i)=>{let r=e._zod.def,o=r.inclusive===!1,a=r.options.map((s,c)=>Wn(s,t,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=a:n.anyOf=a},X3=(e,t,n,i)=>{let r=e._zod.def,o=Wn(r.left,t,{...i,path:[...i.path,"allOf",0]}),a=Wn(r.right,t,{...i,path:[...i.path,"allOf",1]}),s=l=>"allOf"in l&&Object.keys(l).length===1,c=[...s(o)?o.allOf:[o],...s(a)?a.allOf:[a]];n.allOf=c,t.intersections.push(c)},N3=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="array";let a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=o.items.map((b,h)=>Wn(b,t,{...i,path:[...i.path,a,h]})),l=o.rest?Wn(o.rest,t,{...i,path:[...i.path,s,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null,u=o.items.length;for(;u>0;){let b=o.items[u-1];if(!(t.io==="input"?ud(b)!==void 0:b._zod.optout==="optional"))break;u--}let f=o.items.length,d=!o.rest;t.target==="draft-2020-12"?(r.prefixItems=c,d?r.items=!1:l&&(r.items=l),u>0&&(r.minItems=u),d&&(r.maxItems=f)):t.target==="openapi-3.0"?(r.items={anyOf:c},l&&r.items.anyOf.push(l),u>0&&(r.minItems=u),d&&(r.maxItems=f)):(r.items=c,d?r.additionalItems=!1:l&&(r.additionalItems=l),u>0&&(r.minItems=u),d&&(r.maxItems=f));let{minimum:m,maximum:p}=Zr(e);typeof m=="number"&&(r.minItems=m),typeof p=="number"&&(r.maxItems=p)};function r3(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let p=e.get(t)?.def;if(!p)return t;let b=r3(e,p,n);return b===p?t:b}for(let p of["anyOf","oneOf"]){let b=t[p];if(!Array.isArray(b))continue;let h=b.map(v=>r3(e,v,n));h.some((v,g)=>v!==b[g])&&(t={...t,[p]:h})}let i=Array.isArray(t.type)?t.type:[t.type],r=!i.includes("string")&&i.some(p=>p==="number"||p==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!r&&!o?.some(p=>typeof p=="number"))return t;let{minimum:a,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:f,id:d,...m}=t;return m.enum?m.enum=m.enum.map(p=>typeof p=="number"?String(p):p):typeof m.const=="number"&&(m.const=String(m.const)),r&&(m.type="string",o||(m.pattern=(i.includes("number")?aa:Hf).source)),m}var i3=new WeakMap;function eB(e){let t=new Map;for(let i of e.seen.values())i.def&&!t.has(i.schema)&&t.set(i.schema,i);let n=new Map;for(let i of i3.get(e)??[]){let r=e.seen.get(i),o=(r?.def??r?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;let a=r3(t,o,new Set);a!==o&&n.set(o,a)}if(n.size)for(let i of e.seen.values())for(let r of[i.schema,i.def]){let o=r&&n.get(r.propertyNames);o&&(r.propertyNames=o)}}var R3=(e,t,n,i)=>{let r=n,o=e._zod.def;r.type="object";let a=o.keyType,s=Zr(a).patterns;if(o.mode==="loose"&&s&&s.size>0){let u=Wn(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});r.patternProperties={};for(let f of s)Yr(r.patternProperties,Kz(f).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){r.propertyNames=Wn(o.keyType,t,{...i,path:[...i.path,"propertyNames"]});let u=i3.get(t);u||(u=[],i3.set(t,u),t.deferred.push(()=>eB(t))),u.push(e)}r.additionalProperties=Wn(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]})}let c=a._zod.values,l=t.io==="input"&&ud(o.valueType)!==void 0;if(c&&!o.partial&&!l){let u=[...c].filter(f=>typeof f=="string"||typeof f=="number");u.length>0&&(r.required=u.map(String))}},F3=(e,t,n,i)=>{let r=e._zod.def,o=Wn(r.innerType,t,i),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=r.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},V3=(e,t,n,i)=>{let r=e._zod.def;Wn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},j3=Symbol();function Qz(e,t,n,i,r){let o=!1,a=JSON.stringify(e,(s,c)=>typeof c!="bigint"?c:(o=!0,null));return o?(jr(t,n,i,r,"BigInt defaults cannot be represented in JSON Schema"),j3):JSON.parse(a)}var Z3=(e,t,n,i)=>{let r=e._zod.def;Wn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType;let a=Qz(r.defaultValue,e,t,n,i);a!==j3&&(n.default=a)},I3=(e,t,n,i)=>{let r=e._zod.def;Wn(r.innerType,t,i);let o=t.seen.get(e);if(o.ref=r.innerType,t.io!=="input")return;let a=Qz(r.defaultValue,e,t,n,i);a!==j3&&(n._prefault=a)},W3=(e,t,n,i)=>{let r=e._zod.def;Wn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType;let a;try{a=r.catchValue(void 0)}catch{jr(e,t,n,i,"Dynamic catch values are not supported in JSON Schema");return}n.default=a},D3=(e,t,n,i)=>{let r=e._zod.def,o=r.in._zod.traits.has("$ZodTransform"),a=t.io==="input"?o?r.out:r.in:r.out;Wn(a,t,i);let s=t.seen.get(e);s.ref=a},q3=(e,t,n,i)=>{let r=e._zod.def;Wn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType,n.readOnly=!0},H3=(e,t,n,i)=>{let r=e._zod.def;Wn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},yb=(e,t,n,i)=>{let r=e._zod.def;Wn(r.innerType,t,i);let o=t.seen.get(e);o.ref=r.innerType},E3=(e,t,n,i)=>{let r=e._zod.innerType;Wn(r,t,i);let o=t.seen.get(e);o.ref=r},gb={string:o3,number:a3,boolean:s3,bigint:c3,symbol:l3,null:u3,undefined:f3,void:d3,never:m3,any:p3,unknown:h3,date:b3,enum:g3,literal:v3,nan:y3,template_literal:w3,file:x3,success:P3,custom:S3,function:k3,transform:T3,map:z3,set:M3,array:O3,object:L3,union:vb,intersection:X3,tuple:N3,record:R3,nullable:F3,nonoptional:V3,default:Z3,prefault:I3,catch:W3,pipe:D3,readonly:q3,promise:H3,optional:yb,lazy:E3};function wb(e,t){if("_idmap"in e){let i=e,r=Ba({...t,processors:gb}),o={};for(let c of i._idmap.entries()){let[l,u]=c;Wn(u,r)}let a={},s={registry:i,uri:t?.uri,defs:o};r.external=s;for(let c of i._idmap.entries()){let[l,u]=c;Ya(r,u),Yr(a,l,Ka(r,u))}if(Object.keys(o).length>0){let c=r.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[c]:o}}return{schemas:a}}let n=Ba({...t,processors:gb});return Wn(e,n),Ya(n,e),Ka(n,e)}var xb=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=Ba({processors:gb,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return Wn(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,Ya(this.ctx,t);let i=Ka(this.ctx,t),{"~standard":r,...o}=i;return o}};var _z={};var Cl={};Bo(Cl,{ZodAny:()=>u2,ZodArray:()=>p2,ZodBase64:()=>qb,ZodBase64URL:()=>Hb,ZodBigInt:()=>Hl,ZodBigIntFormat:()=>Ub,ZodBoolean:()=>ql,ZodCIDRv4:()=>Wb,ZodCIDRv6:()=>Db,ZodCUID:()=>Nb,ZodCUID2:()=>Rb,ZodCatch:()=>j2,ZodCodec:()=>wd,ZodCreditCard:()=>n2,ZodCustom:()=>xd,ZodCustomStringFormat:()=>ic,ZodDate:()=>pd,ZodDefault:()=>L2,ZodDiscriminatedUnion:()=>b2,ZodE164:()=>Eb,ZodEmail:()=>Mb,ZodEmoji:()=>Lb,ZodEnum:()=>Il,ZodExactOptional:()=>Bb,ZodFile:()=>T2,ZodFunction:()=>A2,ZodGUID:()=>Ob,ZodIBAN:()=>r2,ZodIPv4:()=>Zb,ZodIPv6:()=>Ib,ZodISODate:()=>_a,ZodISODateTime:()=>Qa,ZodISODuration:()=>es,ZodISOTime:()=>$a,ZodInstanceOf:()=>B2,ZodIntersection:()=>g2,ZodJWT:()=>Cb,ZodKSUID:()=>jb,ZodLazy:()=>E2,ZodLiteral:()=>k2,ZodMAC:()=>t2,ZodMap:()=>P2,ZodNaN:()=>I2,ZodNanoID:()=>Xb,ZodNever:()=>d2,ZodNonOptional:()=>Yb,ZodNull:()=>c2,ZodNullable:()=>O2,ZodNumber:()=>Dl,ZodNumberFormat:()=>oc,ZodObject:()=>bd,ZodOptional:()=>vd,ZodPipe:()=>yd,ZodPrefault:()=>N2,ZodPreprocess:()=>W2,ZodPromise:()=>U2,ZodReadonly:()=>D2,ZodRecord:()=>Zl,ZodSet:()=>S2,ZodString:()=>Wl,ZodStringFormat:()=>qn,ZodSuccess:()=>V2,ZodSymbol:()=>a2,ZodTemplateLiteral:()=>H2,ZodTransform:()=>z2,ZodTuple:()=>y2,ZodType:()=>Gt,ZodULID:()=>Fb,ZodURL:()=>md,ZodUUID:()=>Xo,ZodUndefined:()=>s2,ZodUnion:()=>gd,ZodUnknown:()=>f2,ZodVoid:()=>m2,ZodXID:()=>Vb,ZodXor:()=>h2,_ZodString:()=>zb,_default:()=>X2,_function:()=>uO,any:()=>HM,array:()=>hd,base64:()=>xM,base64url:()=>PM,bigint:()=>ZM,boolean:()=>o2,catch:()=>Z2,check:()=>fO,cidrv4:()=>yM,cidrv6:()=>wM,codec:()=>aO,creditCard:()=>kM,cuid:()=>fM,cuid2:()=>dM,currencyCode:()=>XM,custom:()=>dO,date:()=>CM,describe:()=>mO,discriminatedUnion:()=>YM,e164:()=>SM,email:()=>tM,emoji:()=>lM,enum:()=>Gb,exactOptional:()=>M2,file:()=>nO,float32:()=>RM,float64:()=>FM,function:()=>uO,guid:()=>nM,hash:()=>NM,hex:()=>LM,hostname:()=>OM,httpUrl:()=>cM,iban:()=>TM,instanceof:()=>hO,int:()=>kb,int32:()=>VM,int64:()=>IM,intersection:()=>v2,invertCodec:()=>sO,ipv4:()=>bM,ipv6:()=>vM,json:()=>gO,jwt:()=>zM,keyof:()=>UM,ksuid:()=>hM,lazy:()=>C2,literal:()=>tO,looseObject:()=>JM,looseRecord:()=>QM,mac:()=>gM,map:()=>_M,meta:()=>pO,nan:()=>oO,nanoid:()=>uM,nativeEnum:()=>eO,never:()=>Ab,nonoptional:()=>F2,null:()=>l2,nullable:()=>dd,nullish:()=>rO,number:()=>i2,object:()=>AM,optional:()=>nc,partialRecord:()=>KM,pipe:()=>Tb,prefault:()=>R2,preprocess:()=>vO,promise:()=>lO,readonly:()=>q2,record:()=>x2,refine:()=>G2,set:()=>$M,strictObject:()=>GM,string:()=>fd,stringFormat:()=>MM,stringbool:()=>bO,success:()=>iO,superRefine:()=>J2,symbol:()=>DM,templateLiteral:()=>cO,transform:()=>Jb,tuple:()=>w2,uint32:()=>jM,uint64:()=>WM,ulid:()=>mM,undefined:()=>qM,union:()=>El,unknown:()=>tc,url:()=>sM,uuid:()=>rM,uuidv4:()=>iM,uuidv6:()=>oM,uuidv7:()=>aM,void:()=>EM,xid:()=>pM,xor:()=>BM});var Pb={};Bo(Pb,{endsWith:()=>Tl,gt:()=>Oo,gte:()=>Hi,includes:()=>Sl,length:()=>$s,lowercase:()=>xl,lt:()=>Mo,lte:()=>qi,maxLength:()=>_s,maxSize:()=>Ja,mime:()=>Ml,minLength:()=>sa,minSize:()=>Lo,multipleOf:()=>Ga,negative:()=>mb,nonnegative:()=>hb,nonpositive:()=>pb,normalize:()=>Ol,overwrite:()=>uo,positive:()=>db,properties:()=>zl,property:()=>bb,regex:()=>wl,size:()=>Qs,slugify:()=>Rl,startsWith:()=>kl,toLowerCase:()=>Xl,toUpperCase:()=>Nl,trim:()=>Ll,uppercase:()=>Pl});var $z=new WeakSet([Object.prototype,Error.prototype]);function Sb(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let i=n(this);return Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0}),i},set(i){Object.defineProperty(this,t,{value:i,configurable:!0,writable:!0})}})}var eM=(e,t)=>{Uy.init(e,t),e.name="ZodError";let n=Object.getPrototypeOf(e);$z.has(n)||($z.add(n),Sb(n,"format",i=>r=>If(i,r)),Sb(n,"flatten",i=>r=>Zf(i,r)),Sb(n,"addIssue",i=>r=>{i.issues.push(r),i.message=JSON.stringify(i.issues,sl,2)}),Sb(n,"addIssues",i=>r=>{i.issues.push(...r),i.message=JSON.stringify(i.issues,sl,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},nB=A("ZodError",eM),Fi=A("ZodError",eM,void 0,{Parent:Error});var C3=fl(Fi),U3=dl(Fi),A3=ml(Fi),G3=pl(Fi),J3=_p(Fi),B3=$p(Fi),Y3=eh(Fi),K3=th(Fi),Q3=nh(Fi),_3=rh(Fi),$3=ih(Fi),e2=oh(Fi);function iB(){Cr.localeError||wr(Ih())}function rc(){Cr.memoizer||wr({memoizer:td()})}var Gt=A("ZodType",(e,t)=>(iB(),It.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(he.mergeDefs(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Zn(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(G2(e,t))},superRefine(e,t){return this.check(J2(e,t))},overwrite(e){return this.check(uo(e))},optional(){return nc(this)},exactOptional(){return M2(this)},nullable(){return dd(this)},nullish(){return nc(dd(this))},nonoptional(e){return F2(this,e)},array(){return hd(this)},or(e){return El([this,e])},and(e){return v2(this,e)},transform(e){return Tb(this,Jb(e))},default(e){return X2(this,e)},prefault(e){return R2(this,e)},catch(e){return Z2(this,e)},pipe(e){return Tb(this,e)},readonly(){return q2(this)},describe(e){let t=this.clone();return Kr.add(t,{description:e}),t},meta(...e){if(e.length===0)return Kr.get(this);let t=this.clone();return Kr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return he.hide(this,"~standard",{...bh(this),jsonSchema:{input:Fl(this,"input"),output:Fl(this,"output")}})},set"~standard"(e){he.own(this,"~standard",e)},parse:function e(t,n){return C3(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await U3(this,t,n,{callee:e})},safeParse(e,t){return A3(this,e,t)},async safeParseAsync(e,t){return G3(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){he.own(this,"spa",e)},validate(e,t){return Wf(this,e,t)},validateAsync(e,t){return Df(this,e,t)},encode:function e(t,n){return J3(this,t,n,{callee:e})},decode:function e(t,n){return B3(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Y3(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await K3(this,t,n,{callee:e})},safeEncode(e,t){return Q3(this,e,t)},safeDecode(e,t){return _3(this,e,t)},async safeEncodeAsync(e,t){return $3(this,e,t)},async safeDecodeAsync(e,t){return e2(this,e,t)},toJSONSchema(e){return n3(this,{})(e)},get description(){return Kr.get(this)?.description},get _def(){return this._zod.def}}),zb=A("_ZodString",(e,t)=>{Gs.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>o3(e,n,i,r)},he.derived({format:e=>Zr(e).format??null,minLength:e=>Zr(e).minimum??null,maxLength:e=>Zr(e).maximum??null},{regex(...e){return this.check(wl(...e))},includes(...e){return this.check(Sl(...e))},startsWith(...e){return this.check(kl(...e))},endsWith(...e){return this.check(Tl(...e))},min(...e){return this.check(sa(...e))},max(...e){return this.check(_s(...e))},length(...e){return this.check($s(...e))},nonempty(...e){return this.check(sa(1,...e))},lowercase(e){return this.check(xl(e))},uppercase(e){return this.check(Pl(e))},trim(){return this.check(Ll())},normalize(...e){return this.check(Ol(...e))},toLowerCase(){return this.check(Xl())},toUpperCase(){return this.check(Nl())},slugify(){return this.check(Rl())}})),Wl=A("ZodString",(e,t)=>{Gs.init(e,t),zb.init(e,t)},{email(e){return this.check(Ah(Mb,e))},url(e){return this.check(id(md,e))},jwt(e){return this.check(fb(Cb,e))},emoji(e){return this.check(Qh(Lb,e))},guid(e){return this.check(Gh(Ob,e))},uuid(e){return this.check(Jh(Xo,e))},uuidv4(e){return this.check(Bh(Xo,e))},uuidv6(e){return this.check(Yh(Xo,e))},uuidv7(e){return this.check(Kh(Xo,e))},nanoid(e){return this.check(_h(Xb,e))},cuid(e){return this.check($h(Nb,e))},cuid2(e){return this.check(eb(Rb,e))},ulid(e){return this.check(tb(Fb,e))},base64(e){return this.check(cb(qb,e))},base64url(e){return this.check(lb(Hb,e))},xid(e){return this.check(nb(Vb,e))},ksuid(e){return this.check(rb(jb,e))},ipv4(e){return this.check(ib(Zb,e))},ipv6(e){return this.check(ob(Ib,e))},cidrv4(e){return this.check(ab(Wb,e))},cidrv6(e){return this.check(sb(Db,e))},e164(e){return this.check(ub(Eb,e))},datetime(e){return this.check(od(Qa,e))},date(e){return this.check(ad(_a,e))},time(e){return this.check(sd($a,e))},duration(e){return this.check(cd(es,e))}});function fd(e){return vx(Wl,e)}var qn=A("ZodStringFormat",(e,t)=>{In.init(e,t),zb.init(e,t)}),Qa=A("ZodISODateTime",(e,t)=>{uw.init(e,t),qn.init(e,t)}),_a=A("ZodISODate",(e,t)=>{fw.init(e,t),qn.init(e,t)}),$a=A("ZodISOTime",(e,t)=>{dw.init(e,t),qn.init(e,t)}),es=A("ZodISODuration",(e,t)=>{mw.init(e,t),qn.init(e,t)}),Mb=A("ZodEmail",(e,t)=>{$1.init(e,t),qn.init(e,t)});function tM(e){return Ah(Mb,e)}var Ob=A("ZodGUID",(e,t)=>{Q1.init(e,t),qn.init(e,t)});function nM(e){return Gh(Ob,e)}var Xo=A("ZodUUID",(e,t)=>{_1.init(e,t),qn.init(e,t)});function rM(e){return Jh(Xo,e)}function iM(e){return Bh(Xo,e)}function oM(e){return Yh(Xo,e)}function aM(e){return Kh(Xo,e)}var md=A("ZodURL",(e,t)=>{nw.init(e,t),qn.init(e,t)});function sM(e){return id(md,e)}function cM(e){return id(md,{protocol:qf,hostname:m1,...he.normalizeParams(e)})}var Lb=A("ZodEmoji",(e,t)=>{rw.init(e,t),qn.init(e,t)});function lM(e){return Qh(Lb,e)}var Xb=A("ZodNanoID",(e,t)=>{iw.init(e,t),qn.init(e,t)});function uM(e){return _h(Xb,e)}var Nb=A("ZodCUID",(e,t)=>{ow.init(e,t),qn.init(e,t)});function fM(e){return $h(Nb,e)}var Rb=A("ZodCUID2",(e,t)=>{aw.init(e,t),qn.init(e,t)});function dM(e){return eb(Rb,e)}var Fb=A("ZodULID",(e,t)=>{sw.init(e,t),qn.init(e,t)});function mM(e){return tb(Fb,e)}var Vb=A("ZodXID",(e,t)=>{cw.init(e,t),qn.init(e,t)});function pM(e){return nb(Vb,e)}var jb=A("ZodKSUID",(e,t)=>{lw.init(e,t),qn.init(e,t)});function hM(e){return rb(jb,e)}var Zb=A("ZodIPv4",(e,t)=>{pw.init(e,t),qn.init(e,t)});function bM(e){return ib(Zb,e)}var t2=A("ZodMAC",(e,t)=>{bw.init(e,t),qn.init(e,t)});function gM(e){return wx(t2,e)}var Ib=A("ZodIPv6",(e,t)=>{hw.init(e,t),qn.init(e,t)});function vM(e){return ob(Ib,e)}var Wb=A("ZodCIDRv4",(e,t)=>{gw.init(e,t),qn.init(e,t)});function yM(e){return ab(Wb,e)}var Db=A("ZodCIDRv6",(e,t)=>{vw.init(e,t),qn.init(e,t)});function wM(e){return sb(Db,e)}var qb=A("ZodBase64",(e,t)=>{yw.init(e,t),qn.init(e,t)});function xM(e){return cb(qb,e)}var Hb=A("ZodBase64URL",(e,t)=>{ww.init(e,t),qn.init(e,t)});function PM(e){return lb(Hb,e)}var Eb=A("ZodE164",(e,t)=>{xw.init(e,t),qn.init(e,t)});function SM(e){return ub(Eb,e)}var n2=A("ZodCreditCard",(e,t)=>{Pw.init(e,t),qn.init(e,t)});function kM(e){return xx(n2,e)}var r2=A("ZodIBAN",(e,t)=>{Sw.init(e,t),qn.init(e,t)});function TM(e){return Px(r2,e)}var Cb=A("ZodJWT",(e,t)=>{kw.init(e,t),qn.init(e,t)});function zM(e){return fb(Cb,e)}var ic=A("ZodCustomStringFormat",(e,t)=>{Tw.init(e,t),qn.init(e,t)});function MM(e,t,n={}){return ec(ic,e,t,n)}function OM(e){return ec(ic,"hostname",d1,e)}function LM(e){return ec(ic,"hex",M1,e)}function XM(e){return ec(ic,"currency_code",h1,e)}function NM(e,t){let n=t?.enc??"hex",i=`${e}_${n}`,r=Qi[i];if(!r)throw new Error(`Unrecognized hash format: ${i}`);return ec(ic,i,r,t)}var Dl=A("ZodNumber",(e,t)=>{zh.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>a3(e,n,i,r),e.isFinite=!0},he.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Zr(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Zr(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:n}=Zr(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Zr(e).format??null},{gt(e,t){return this.check(Oo(e,t))},gte(e,t){return this.check(Hi(e,t))},min(e,t){return this.check(Hi(e,t))},lt(e,t){return this.check(Mo(e,t))},lte(e,t){return this.check(qi(e,t))},max(e,t){return this.check(qi(e,t))},int(e){return this.check(kb(e))},safe(e){return this.check(kb(e))},positive(e){return this.check(Oo(0,e))},nonnegative(e){return this.check(Hi(0,e))},negative(e){return this.check(Mo(0,e))},nonpositive(e){return this.check(qi(0,e))},multipleOf(e,t){return this.check(Ga(e,t))},step(e,t){return this.check(Ga(e,t))},finite(){return this}}));function i2(e){return kx(Dl,e)}var oc=A("ZodNumberFormat",(e,t)=>{zw.init(e,t),Dl.init(e,t)});function kb(e){return zx(oc,e)}function RM(e){return Mx(oc,e)}function FM(e){return Ox(oc,e)}function VM(e){return Lx(oc,e)}function jM(e){return Xx(oc,e)}var ql=A("ZodBoolean",(e,t)=>{Yf.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>s3(e,n,i,r)});function o2(e){return Nx(ql,e)}var Hl=A("ZodBigInt",(e,t)=>{Mh.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>c3(e,n,i,r)},he.derived({minValue:e=>Zr(e).minimum??null,maxValue:e=>Zr(e).maximum??null,format:e=>Zr(e).format??null},{gte(e,t){return this.check(Hi(e,t))},min(e,t){return this.check(Hi(e,t))},gt(e,t){return this.check(Oo(e,t))},lt(e,t){return this.check(Mo(e,t))},lte(e,t){return this.check(qi(e,t))},max(e,t){return this.check(qi(e,t))},positive(e){return this.check(Oo(BigInt(0),e))},negative(e){return this.check(Mo(BigInt(0),e))},nonpositive(e){return this.check(qi(BigInt(0),e))},nonnegative(e){return this.check(Hi(BigInt(0),e))},multipleOf(e,t){return this.check(Ga(e,t))}}));function ZM(e){return Fx(Hl,e)}var Ub=A("ZodBigIntFormat",(e,t)=>{Mw.init(e,t),Hl.init(e,t)});function IM(e){return jx(Ub,e)}function WM(e){return Zx(Ub,e)}var a2=A("ZodSymbol",(e,t)=>{Ow.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>l3(e,n,i,r)});function DM(e){return Ix(a2,e)}var s2=A("ZodUndefined",(e,t)=>{Lw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>f3(e,n,i,r)});function qM(e){return Wx(s2,e)}var c2=A("ZodNull",(e,t)=>{Xw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>u3(e,n,i,r)});function l2(e){return Dx(c2,e)}var u2=A("ZodAny",(e,t)=>{Nw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>p3(e,n,i,r)});function HM(){return qx(u2)}var f2=A("ZodUnknown",(e,t)=>{Rw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>h3(e,n,i,r)});function tc(){return Hx(f2)}var d2=A("ZodNever",(e,t)=>{Fw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>m3(e,n,i,r)});function Ab(e){return Ex(d2,e)}var m2=A("ZodVoid",(e,t)=>{Vw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>d3(e,n,i,r)});function EM(e){return Cx(m2,e)}var pd=A("ZodDate",(e,t)=>{jw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>b3(e,n,i,r),e.min=(n,i)=>e.check(Hi(n,i)),e.max=(n,i)=>e.check(qi(n,i))},he.derived({minDate:e=>{let{minimum:t}=Zr(e);return t?new Date(t):null},maxDate:e=>{let{maximum:t}=Zr(e);return t?new Date(t):null}},{}));function CM(e){return Ux(pd,e)}var p2=A("ZodArray",(e,t)=>{rc(),Zw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>O3(e,n,i,r),e.element=t.element},{min(e,t){return this.check(sa(e,t))},nonempty(e){return this.check(sa(1,e))},max(e,t){return this.check(_s(e,t))},length(e,t){return this.check($s(e,t))},unwrap(){return this.element}});function hd(e,t){return Jx(p2,e,t)}function UM(e){let t=e._zod.def.shape;return Gb(Object.keys(t))}var bd=A("ZodObject",(e,t)=>{rc(),Iw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>L3(e,n,i,r),he.installLazyProp(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return Gb(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(he.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(he.mergeDefs(this._zod.def,{catchall:tc()}))},loose(){return this.clone(he.mergeDefs(this._zod.def,{catchall:tc()}))},strict(){return this.clone(he.mergeDefs(this._zod.def,{catchall:Ab()}))},strip(){return this.clone(he.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return he.extend(this,e)},safeExtend(e){return he.safeExtend(this,e)},merge(e){return he.merge(this,e)},pick(e){return he.pick(this,e)},omit(e){return he.omit(this,e)},partial(...e){return he.partial(vd,this,e[0])},exactPartial(...e){return he.partial(Bb,this,e[0],"exactPartial")},required(...e){return he.required(Yb,this,e[0])}});function AM(e,t){let n={type:"object",shape:e??{},...he.normalizeParams(t)};return new bd(n)}function GM(e,t){return new bd({type:"object",shape:e,catchall:Ab(),...he.normalizeParams(t)})}function JM(e,t){return new bd({type:"object",shape:e,catchall:tc(),...he.normalizeParams(t)})}var gd=A("ZodUnion",(e,t)=>{Kf.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vb(e,n,i,r),e.options=t.options});function El(e,t){return new gd({type:"union",options:e,...he.normalizeParams(t)})}var h2=A("ZodXor",(e,t)=>{gd.init(e,t),Ww.init(e,t),e._zod.processJSONSchema=(n,i,r)=>vb(e,n,i,r),e.options=t.options});function BM(e,t){return new h2({type:"union",options:e,inclusive:!1,...he.normalizeParams(t)})}var b2=A("ZodDiscriminatedUnion",(e,t)=>{gd.init(e,t),qw.init(e,t)});function YM(e,t,n){return new b2({type:"union",options:t,discriminator:e,...he.normalizeParams(n)})}var g2=A("ZodIntersection",(e,t)=>{Hw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>X3(e,n,i,r)});function v2(e,t){return new g2({type:"intersection",left:e,right:t})}var y2=A("ZodTuple",(e,t)=>{rc(),Oh.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>N3(e,n,i,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new vd({type:"optional",innerType:t}))})}});function w2(e,t,n){let i=t instanceof It,r=i?n:t,o=i?t:null;return new y2({type:"tuple",items:e,rest:o,...he.normalizeParams(r)})}var Zl=A("ZodRecord",(e,t)=>{rc(),Ew.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>R3(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType});function x2(e,t,n){return!t||!t._zod?new Zl({type:"record",keyType:fd(),valueType:e,...he.normalizeParams(t)}):new Zl({type:"record",keyType:e,valueType:t,...he.normalizeParams(n)})}function KM(e,t,n){return new Zl({type:"record",keyType:e,valueType:t,...he.normalizeParams(n),partial:!0})}function QM(e,t,n){return new Zl({type:"record",keyType:e,valueType:t,mode:"loose",...he.normalizeParams(n)})}var P2=A("ZodMap",(e,t)=>{rc(),Cw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>z3(e,n,i,r),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(Lo(...n)),e.nonempty=n=>e.check(Lo(1,n)),e.max=(...n)=>e.check(Ja(...n)),e.size=(...n)=>e.check(Qs(...n))});function _M(e,t,n){return new P2({type:"map",keyType:e,valueType:t,...he.normalizeParams(n)})}var S2=A("ZodSet",(e,t)=>{rc(),Uw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>M3(e,n,i,r),e.min=(...n)=>e.check(Lo(...n)),e.nonempty=n=>e.check(Lo(1,n)),e.max=(...n)=>e.check(Ja(...n)),e.size=(...n)=>e.check(Qs(...n))});function $M(e,t){return new S2({type:"set",valueType:e,...he.normalizeParams(t)})}var Il=A("ZodEnum",(e,t)=>{Aw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(i,r,o)=>g3(e,i,r,o),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(i,r)=>{let o={};for(let a of i)if(n.has(a))o[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new Il({...t,checks:[],...he.normalizeParams(r),entries:o})},e.exclude=(i,r)=>{let o={...t.entries};for(let a of i)if(n.has(a))delete o[a];else throw new Error(`Key ${a} not found in enum`);return new Il({...t,checks:[],...he.normalizeParams(r),entries:o})}});function Gb(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new Il({type:"enum",entries:n,...he.normalizeParams(t)})}function eO(e,t){return new Il({type:"enum",entries:e,...he.normalizeParams(t)})}var k2=A("ZodLiteral",(e,t)=>{Gw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>v3(e,n,i,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function tO(e,t){return new k2({type:"literal",values:Array.isArray(e)?e:[e],...he.normalizeParams(t)})}var T2=A("ZodFile",(e,t)=>{Jw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>x3(e,n,i,r),e.min=(n,i)=>e.check(Lo(n,i)),e.max=(n,i)=>e.check(Ja(n,i)),e.mime=(n,i)=>e.check(Ml(Array.isArray(n)?n:[n],i))});function nO(e){return Bx(T2,e)}var z2=A("ZodTransform",(e,t)=>{rc(),Bw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>T3(e,n,i,r),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new Aa(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(he.issue(o,n.value,t));else{let a=o;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),"input"in a||(a.input=n.value),a.inst??(a.inst=e),n.issues.push(he.issue(a))}};let r=t.transform(n.value,n);return r instanceof Promise?r.then(o=>(n.value=o,n)):(n.value=r,n)}});function Jb(e){return new z2({type:"transform",transform:e})}var vd=A("ZodOptional",(e,t)=>{Lh.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yb(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function nc(e){return new vd({type:"optional",innerType:e})}var Bb=A("ZodExactOptional",(e,t)=>{Yw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>yb(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function M2(e){return new Bb({type:"optional",innerType:e})}var O2=A("ZodNullable",(e,t)=>{Kw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>F3(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function dd(e){return new O2({type:"nullable",innerType:e})}function rO(e){return nc(dd(e))}var L2=A("ZodDefault",(e,t)=>{Qw.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>Z3(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function X2(e,t){return new L2({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():he.shallowClone(t)}})}var N2=A("ZodPrefault",(e,t)=>{_w.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>I3(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function R2(e,t){return new N2({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():he.shallowClone(t)}})}var Yb=A("ZodNonOptional",(e,t)=>{$w.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>V3(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function F2(e,t){return new Yb({type:"nonoptional",innerType:e,...he.normalizeParams(t)})}var V2=A("ZodSuccess",(e,t)=>{ex.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>P3(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function iO(e){return new V2({type:"success",innerType:e})}var j2=A("ZodCatch",(e,t)=>{tx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>W3(e,n,i,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Z2(e,t){return new j2({type:"catch",innerType:e,catchValue:typeof t=="function"?t:he.constantCatch(t)})}var I2=A("ZodNaN",(e,t)=>{nx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>y3(e,n,i,r)});function oO(e){return Gx(I2,e)}var yd=A("ZodPipe",(e,t)=>{Xh.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>D3(e,n,i,r),e.in=t.in,e.out=t.out});function Tb(e,t){return new yd({type:"pipe",in:e,out:t})}var wd=A("ZodCodec",(e,t)=>{yd.init(e,t),Qf.init(e,t)});function aO(e,t,n){return new wd({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function sO(e){let t=e._zod.def;return new wd({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}var W2=A("ZodPreprocess",(e,t)=>{yd.init(e,t),rx.init(e,t)}),D2=A("ZodReadonly",(e,t)=>{ix.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>q3(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function q2(e){return new D2({type:"readonly",innerType:e})}var H2=A("ZodTemplateLiteral",(e,t)=>{ox.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>w3(e,n,i,r)});function cO(e,t){return new H2({type:"template_literal",parts:e,...he.normalizeParams(t)})}var E2=A("ZodLazy",(e,t)=>{_f.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>E3(e,n,i,r),e.unwrap=()=>e._zod.def.getter()});function C2(e){return new E2({type:"lazy",getter:e})}var U2=A("ZodPromise",(e,t)=>{sx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>H3(e,n,i,r),e.unwrap=()=>e._zod.def.innerType});function lO(e){return new U2({type:"promise",innerType:e})}var A2=A("ZodFunction",(e,t)=>{ax.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>k3(e,n,i,r)});function uO(e){return new A2({type:"function",input:Array.isArray(e?.input)?w2(e?.input):e?.input??hd(tc()),output:e?.output??tc()})}var xd=A("ZodCustom",(e,t)=>{cx.init(e,t),Gt.init(e,t),e._zod.processJSONSchema=(n,i,r)=>S3(e,n,i,r)});function fO(e){let t=new Jn({check:"custom"});return t._zod.check=e,t}function dO(e,t){return Yx(xd,e??(()=>!0),t)}function G2(e,t={}){return Kx(xd,e,t)}function J2(e,t){return Qx(e,t)}var mO=_x,pO=$x,B2=A("ZodInstanceOf",(e,t)=>{xd.init(e,t)},{properties(e,t){return this.check(zl(e,t))}});function hO(e,t={}){let n=new B2({type:"custom",check:"custom",fn:i=>i instanceof e,abort:!0,...he.normalizeParams(t)});return n._zod.bag.Class=e,n._zod.check=i=>{i.value instanceof e||i.issues.push({code:"invalid_type",expected:e.name,input:i.value,inst:n,path:[...n._zod.def.path??[]]})},n}var bO=(...e)=>e3({Codec:wd,Boolean:ql,String:Wl},...e);function gO(e){let t=C2(()=>El([fd(e),i2(),o2(),l2(),hd(t),x2(fd(),t)]));return t}function vO(e,t){return new W2({type:"pipe",in:Jb(e),out:t})}var oB={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function aB(e){wr({customError:e})}function sB(){return wr().customError}var Y2;Y2||(Y2={});var Pd={};Bo(Pd,{ZodISODate:()=>_a,ZodISODateTime:()=>Qa,ZodISODuration:()=>es,ZodISOTime:()=>$a,date:()=>lB,datetime:()=>cB,duration:()=>fB,time:()=>uB});function cB(e){return od(Qa,e)}function lB(e){return ad(_a,e)}function uB(e){return sd($a,e)}function fB(e){return cd(es,e)}var _e={...Cl,...Pb,iso:Pd},dB=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function mB(e,t){let n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function yO(e,t){return e.map((n,i)=>i<t?n:n.optional())}function pB(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function hB(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;let i=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===i){let r=n[1]===void 0?void 0:pB(n[1]);if(!r||!t.defs[r])throw new Error(`Reference not found: ${e}`);return t.defs[r]}throw new Error(`Reference not found: ${e}`)}function bB(e,t){return _e.transform(i=>i).check(i=>{let r=i.value;if(typeof r!="object"||r===null||Array.isArray(r))return;let o=Object.getOwnPropertyNames(r);if(t.minProperties!==void 0&&o.length<t.minProperties&&i.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:r,inst:e,continue:!0}),t.maxProperties!==void 0&&o.length>t.maxProperties&&i.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:r,inst:e,continue:!0}),t.keySchema)for(let a of o){let s=t.keySchema.safeParse(a);s.success||i.issues.push({code:"invalid_key",origin:"record",issues:s.error.issues,input:a,path:[a],continue:!0})}}).pipe(e)}function K2(e,t){if(e===null)return"z";let n=typeof e;if(n!=="object"){if(n==="number"&&Number.isNaN(e))return null;let i=String(e);return`${n[0]}${i.length}:${i}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){let o=[];for(let a of e){let s=K2(a,t);if(s===null)return null;o.push(s)}return`a${o.length}:[${o.join(",")}]`}let i=Object.keys(e).sort(),r=[];for(let o of i){let a=K2(e[o],t);if(a===null)return null;r.push(`${o.length}:${o}=${a}`)}return`o${r.length}:{${r.join(",")}}`}finally{t.delete(e)}}var gB=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),vB=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Sd(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Sd):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>gB.has(t)?Sd(n):!vB.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(Sd))}function wO(e){return e===1?"element":"elements"}function yB(e,t){return _e.transform(i=>i).check(i=>{let r=i.value;if(Array.isArray(r)){if(t.uniqueItems===!0){let o=new Map;for(let a=0;a<r.length;a++){let s=K2(r[a],new Set);if(s===null)continue;let c=o.get(s);if(c===void 0){o.set(s,a);continue}i.issues.push({code:"custom",message:`Array items must be unique: element at index ${a} duplicates the one at index ${c}`,input:r,path:[a],continue:!0})}}if(t.containsSchema){let o=t.minContains??1,a=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY,s=0;for(let c of r)if(t.containsSchema.safeParse(c).success&&++s>=a)break;s<o&&i.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${wO(o)}; found ${s}`,input:r,continue:!0}),t.maxContains!==void 0&&s>t.maxContains&&i.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${wO(t.maxContains)}`,input:r,continue:!0})}}}).pipe(e)}function xO(e,t){if(e!==!1)return e===void 0||e===!0?_e.any():wi(e,t)}var wB=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function PO(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return _e.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){let r=e.$ref;if(t.refs.has(r))return t.refs.get(r);if(t.processing.has(r))return _e.lazy(()=>{if(!t.refs.has(r))throw new Error(`Circular reference not resolved: ${r}`);return t.refs.get(r)});t.processing.add(r);let o=hB(r,t),a=wi(o,t);return t.refs.set(r,a),t.processing.delete(r),a}if(e.enum!==void 0){let r=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&r.length===1&&r[0]===null)return _e.null();if(r.length===0)return _e.never();if(r.length===1)return _e.literal(r[0]);if(r.every(a=>typeof a=="string"))return _e.enum(r);let o=r.map(a=>_e.literal(a));return o.length<2?o[0]:_e.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return _e.literal(e.const);let n=e.type;if(Array.isArray(n)){let r=n.map(o=>{let a={...e,type:o};return PO(a,t)});return r.length===0?_e.never():r.length===1?r[0]:_e.union(r)}if(!n)return _e.any();let i;switch(n){case"string":{let r=_e.string();if(e.format){let o=e.format;o==="email"?r=r.check(_e.email()):o==="uri"||o==="uri-reference"?r=r.check(_e.url()):o==="uuid"||o==="guid"?r=r.check(_e.uuid()):o==="date-time"?r=r.check(_e.iso.datetime({offset:!0})):o==="date"?r=r.check(_e.iso.date()):o==="time"?r=r.check(_e.regex(wB)):o==="duration"?r=r.check(_e.iso.duration()):o==="hostname"?r=r.check(_e.hostname()):o==="ipv4"?r=r.check(_e.ipv4()):o==="ipv6"?r=r.check(_e.ipv6()):o==="mac"?r=r.check(_e.mac()):o==="cidr"?r=r.check(_e.cidrv4()):o==="cidr-v6"?r=r.check(_e.cidrv6()):o==="base64"?r=r.check(_e.base64()):o==="base64url"?r=r.check(_e.base64url()):o==="e164"?r=r.check(_e.e164()):o==="credit_card"?r=r.check(_e.creditCard()):o==="iban"?r=r.check(_e.iban()):o==="jwt"?r=r.check(_e.jwt()):o==="emoji"?r=r.check(_e.emoji()):o==="nanoid"?r=r.check(_e.nanoid()):o==="cuid"?r=r.check(_e.cuid()):o==="cuid2"?r=r.check(_e.cuid2()):o==="ulid"?r=r.check(_e.ulid()):o==="xid"?r=r.check(_e.xid()):o==="ksuid"&&(r=r.check(_e.ksuid()))}typeof e.minLength=="number"&&(r=r.min(e.minLength)),typeof e.maxLength=="number"&&(r=r.max(e.maxLength)),e.pattern&&(r=r.regex(new RegExp(e.pattern))),i=r;break}case"number":case"integer":{let r=n==="integer"?_e.number().int():_e.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(r=r.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(r=r.max(e.maximum)),typeof e.exclusiveMinimum=="number"?r=r.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(r=r.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?r=r.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(r=r.lt(e.maximum)),typeof e.multipleOf=="number"&&(r=r.multipleOf(e.multipleOf)),i=r;break}case"boolean":{i=_e.boolean();break}case"null":{i=_e.null();break}case"object":{let r={},o=e.properties||{},a=new Set(e.required||[]),s=typeof e.additionalProperties=="object"?wi(e.additionalProperties,t):void 0;for(let[f,d]of Object.entries(o)){let m=wi(d,t);Yr(r,f,a.has(f)?m:m.optional())}if(e.patternProperties){let f=e.patternProperties,d=Object.keys(f),m=[];for(let b of d){let h=wi(f[b],t),v=_e.string().regex(new RegExp(b));m.push(_e.looseRecord(v,h))}let p=[];if(Object.keys(r).length>0&&p.push(_e.object(r).passthrough()),p.push(...m),p.length===0)i=_e.object({}).passthrough();else if(p.length===1)i=p[0];else{let b=_e.intersection(p[0],p[1]);for(let h=2;h<p.length;h++)b=_e.intersection(b,p[h]);i=b}if(e.additionalProperties===!1){let b=Object.keys(r),h=d.map(g=>new RegExp(g)),v=i;i=i.check(g=>{if(!Yi(g.value))return;let y=[];for(let w of Object.keys(g.value))b.includes(w)||h.some(x=>x.test(w))||y.push(w);y.length&&g.issues.push({code:"unrecognized_keys",keys:y,input:g.value,inst:v})})}}else{let f=_e.object(r);e.additionalProperties===!1?i=f.strict():s?i=f.catchall(s):i=f.passthrough()}let c=e.propertyNames!==void 0&&e.propertyNames!==!0,l=typeof e.minProperties=="number"?e.minProperties:void 0,u=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(c||l!==void 0||u!==void 0){let f;if(c){let d=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;f=wi(d,t)}i=bB(i,{keySchema:f,minProperties:l,maxProperties:u})}break}case"array":{let r=e.prefixItems,o=e.items;if(r&&Array.isArray(r)){let a=typeof e.minItems=="number"?e.minItems:0,s=r.map(f=>wi(f,t)),c=yO(s,a),l=Array.isArray(o)?void 0:xO(o,t),u=_e.tuple(c);i=l?u.rest(l):u,typeof e.minItems=="number"&&(i=i.check(_e.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(_e.maxLength(e.maxItems)))}else if(Array.isArray(o)){let a=typeof e.minItems=="number"?e.minItems:0,s=o.map(f=>wi(f,t)),c=yO(s,a),l=xO(e.additionalItems,t),u=_e.tuple(c);i=l?u.rest(l):u,typeof e.minItems=="number"&&(i=i.check(_e.minLength(e.minItems))),typeof e.maxItems=="number"&&(i=i.check(_e.maxLength(e.maxItems)))}else if(o!==void 0){let a=wi(o,t),s=_e.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),i=s}else i=_e.array(_e.any());(e.uniqueItems===!0||e.contains!==void 0)&&(i=yB(i,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?wi(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${n}`)}return i}function wi(e,t){if(typeof e=="boolean")return e?_e.any():_e.never();let n=PO(e,t),i=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){let s=e.anyOf.map(l=>wi(l,t)),c=_e.union(s);n=i?_e.intersection(n,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){let s=e.oneOf.map(l=>wi(l,t)),c=_e.xor(s);n=i?_e.intersection(n,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=i?n:_e.any();else{let s=i?n:wi(e.allOf[0],t),c=i?0:1;for(let l=c;l<e.allOf.length;l++)s=_e.intersection(s,wi(e.allOf[l],t));n=s}e.nullable===!0&&t.version==="openapi-3.0"&&(n=_e.nullable(n)),e.readOnly===!0&&(n=_e.readonly(n)),e.default!==void 0&&(n=n.default(e.default));let r={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let s of o)s in e&&(r[s]=e[s]);let a=["contentEncoding","contentMediaType","contentSchema"];for(let s of a)s in e&&(r[s]=e[s]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!Sd(e.propertyNames)&&(r.propertyNames=e.propertyNames);for(let s of["minProperties","maxProperties"])e[s]!==void 0&&(r[s]=e[s])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!Sd(e.contains)&&(r.contains=e.contains);for(let s of["uniqueItems","minContains","maxContains"])e[s]!==void 0&&(r[s]=e[s])}for(let s of Object.keys(e))dB.has(s)||Yr(r,s,e[s]);return Object.keys(r).length>0&&t.registry.add(n,r),e.description&&(n=n.describe(e.description)),n}function SO(e,t){if(typeof e=="boolean")return e?_e.any():_e.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}let i=mB(n,t?.defaultTarget),r=n.$defs||n.definitions||{},o={version:i,defs:r,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??Kr};return wi(n,o)}var kO=Symbol("z.visit/resolving");function kd(e,t){let n=typeof t=="function"?t:(a,s)=>{let c=t[a._zod.def.type];return c?c(a,s):a},i=new Map;function r(a){let s=i.get(a);if(s===kO)return new _f({type:"lazy",getter:()=>i.get(a)});if(s!==void 0)return s;i.set(a,kO);let c=o(a),l=n(c,c!==a);return i.set(a,l),l}function o(a){let s=a._zod.def,c=s.type;switch(c){case"object":{let l=s.shape,u=Object.keys(l),f=!1,d={};for(let p of u){let b=r(l[p]);b!==l[p]&&(f=!0),d[p]=b}let m=s.catchall;return s.catchall&&(m=r(s.catchall),m!==s.catchall&&(f=!0)),f?Zn(a,{...s,shape:d,catchall:m}):a}case"array":{let l=r(s.element);return l===s.element?a:Zn(a,{...s,element:l})}case"tuple":{let l=s.items,u=!1,f=[];for(let m of l){let p=r(m);p!==m&&(u=!0),f.push(p)}let d=s.rest;return s.rest&&(d=r(s.rest),d!==s.rest&&(u=!0)),u?Zn(a,{...s,items:f,rest:d}):a}case"record":case"map":{let l=r(s.keyType),u=r(s.valueType);return l===s.keyType&&u===s.valueType?a:Zn(a,{...s,keyType:l,valueType:u})}case"set":{let l=r(s.valueType);return l===s.valueType?a:Zn(a,{...s,valueType:l})}case"union":{let l=s.options,u=!1,f=[];for(let d of l){let m=r(d);m!==d&&(u=!0),f.push(m)}return u?Zn(a,{...s,options:f}):a}case"intersection":{let l=r(s.left),u=r(s.right);return l===s.left&&u===s.right?a:Zn(a,{...s,left:l,right:u})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{let l=r(s.innerType);return l===s.innerType?a:Zn(a,{...s,innerType:l})}case"pipe":{let l=r(s.in),u=r(s.out);return l===s.in&&u===s.out?a:Zn(a,{...s,in:l,out:u})}case"function":{let l=r(s.input),u=r(s.output);return l===s.input&&u===s.output?a:Zn(a,{...s,input:l,output:u})}case"lazy":{let l=s.getter,{_cachedInner:u,...f}=s;return Zn(a,{...f,getter:()=>r(l())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return a;default:return a}}return r(e)}function TO(e){return kd(e,{object:t=>t.partial(),union:t=>{let n=t._zod.def;return n.discriminator===void 0?t:El(n.options)}})}function xB(e,t){if(!t?.length)return e;let n=e._zod.def;return Zn(e,co(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function zO(e){return xB(e.out,e.checks)}function PB(e){return e.in._zod.traits.has("$ZodTransform")?zO(e):e.in}function MO(e){return kd(e,{pipe:t=>PB(t._zod.def),default:(t,n)=>n?nc(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function OO(e){return kd(e,{pipe:t=>zO(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}var Q2={};Bo(Q2,{bigint:()=>zB,boolean:()=>TB,date:()=>MB,number:()=>kB,string:()=>SB});function SB(e){return yx(Wl,e)}function kB(e){return Tx(Dl,e)}function TB(e){return Rx(ql,e)}function zB(e){return Vx(Hl,e)}function MB(e){return Ax(pd,e)}import{AsyncLocalStorage as NB}from"node:async_hooks";var _2=()=>{throw new Error("this build has no local engine \u2014 timelines are read and written on conform.tools")};function LO(e,t){return _2()}function XO(e,t){return _2()}function NO(e){return _2()}E6(!0);var RO={aaf:"aaf",avb:"avb",prproj:"prproj",drt:"resolve-drt",otio:"otio",flame:"flame-archive",fcpxml:"resolve-fcpxml",xmeml:"fcp-xml"},LB=Object.keys(RO),XB=new Set([502,503,504,529,546]),FO=(e,t)=>`${yr().supabaseUrl}/functions/v1/${e}${t}`;async function VO(){let e=await Ko();if(!e)throw new ze("not_signed_in","reading and writing timelines runs on conform.tools \u2014 sign in first (account_login)");return e}async function jO(e,t){let n;for(let i=0;i<3;i++){try{let r=await fetch(e,t);if(!XB.has(r.status)||i===2)return r;n=new Error(`status ${r.status}`)}catch(r){if(n=r,i===2)break}await new Promise(r=>setTimeout(r,1500*(i+1)))}throw new ze("offline",`conform.tools is unreachable (${n instanceof Error?n.message:String(n)}) \u2014 reading and writing timelines need the network`)}async function ZO(e,t){let i=(await e.json().catch(()=>({})))?.error?.message??`${t} failed (${e.status})`;throw e.status===401?new ze("not_signed_in",`${i} \u2014 sign in again (account_login)`):e.status===402||e.status===403?new ze("not_entitled",i):new ze(e.status>=500?"engine":"refused",i)}async function IO(e,t){let n=RO[e];if(!n)throw new ze("unsupported",`'${e}' timelines are not read by conform.tools yet`);let{fmt:i,extract:r}=await C6(t,n),a=JSON.stringify({format:i,source_filename:t.name,persist:!1})+`
78
+ `+(typeof r=="string"?r:JSON.stringify(r)),s=await jO(FO("v1-timeline-canonicalize","/v1/timeline-canonicalize"),{method:"POST",headers:{"content-type":"application/x-ct-canonicalize-v1",authorization:`Bearer ${await VO()}`,apikey:yr().anonKey},body:a});s.ok||await ZO(s,"read");let c=await s.json();return JSON.stringify(c.session)}async function WO(e,t){let n=await jO(FO("v1-write","/v1/write"),{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${await VO()}`,apikey:yr().anonKey,"x-engine-accept-delivery":"cdn"},body:JSON.stringify({target_format:e,session:t})});n.ok||await ZO(n,"write");let i=A6(n.headers.get(U6))??[];if(n.headers.get("x-engine-delivery")==="cdn"){let o=await n.json(),a=await fetch(o.download_url);if(!a.ok)throw new ze("engine",`download failed (${a.status})`);let s=new Uint8Array(await a.arrayBuffer());if(s.byteLength!==o.size)throw new ze("engine",`download incomplete: ${s.byteLength} of ${o.size} bytes`);return{body:s,contentType:o.content_type,filenameSuggestion:o.filename,issues:i}}let r=n.headers.get("content-disposition")?.match(/filename="([^"]+)"/)?.[1];return{body:new Uint8Array(await n.arrayBuffer()),contentType:n.headers.get("content-type")??"application/octet-stream",filenameSuggestion:r??`timeline.${e}`,issues:i}}var $2=new NB;function eP(e){let t=$2.getStore();if(!t||t.declared.includes(e))return;let n=`verb '${t.verb}' reached the protected stage '${e}' without declaring it in protectedStages (core/verbs.ts)`;if(Ut("CONFORM_STRICT_STAGES")==="1")throw new ze("internal",n);console.error(`[conform] warning: ${n}`)}var qO=!1;function ac(){return Ut("CONFORM_ENGINE")==="hosted"||!!1?"hosted":"local"}async function HO(e){return eP("canonicalize"),ac()==="local"?await LO(e.fmt,e.data):await IO(e.fmt,e.file)}async function Kb(e,t){return eP("write"),ac()==="local"?await XO(e,t):await WO(e,t)}async function EO(e){if(ac()!=="local")return null;eP("canonicalize");let t=JSON.parse(await NO(JSON.stringify(e)));return{session:t.session,issues:t.issues??[]}}var Zpe="io.modelcontextprotocol/skills",AO=3e5,RB=512,FB=16*1024*1024;async function VB(){let e=Ut("CONFORM_PLAYBOOKS_DIR");if(e)return await Wi(e)?e:null;let t=Fr(new URL("../../api/playbooks/",import.meta.url));return await Wi(t)?t:null}var jB={md:"text/markdown",txt:"text/plain",json:"application/json",yaml:"application/yaml",yml:"application/yaml",py:"text/x-python",ts:"text/typescript",js:"text/javascript",sh:"text/x-shellscript",csv:"text/csv",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",svg:"image/svg+xml",pdf:"application/pdf"},ZB=e=>jB[e.split(".").pop()?.toLowerCase()??""]??"application/octet-stream";async function IB(e){let t=new Uint8Array(await crypto.subtle.digest("SHA-256",e));return"sha256:"+Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}function WB(e){let t=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(e);if(!t)return null;let n={};for(let i of t[1].split(/\r?\n/)){let r=/^([A-Za-z0-9_-]+):\s*(.*)$/.exec(i);if(!r)continue;let o=r[2].trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),n[r[1]]=o}return n}async function GO(e,t,n,i){let r=[];for await(let o of zn(e))r.push(o);r.sort((o,a)=>o.name.localeCompare(a.name));for(let o of r){if(o.name.startsWith("."))continue;let a=t?`${t}/${o.name}`:o.name;o.isDirectory?(i.push(a),await GO(_(e,o.name),a,n,i)):o.isFile&&n.push({rel:a,abs:_(e,o.name)})}}async function DB(e){let t=[];for await(let i of zn(e))i.isDirectory&&!i.name.startsWith(".")&&t.push(i.name);let n=[];for(let i of t.sort()){let r=[];await GO(_(e,i),"",r,[]),n.push({name:i,files:await Promise.all(r.filter(o=>o.rel.endsWith(".md")).map(async o=>({path:o.rel,bytes:await pr(o.abs)})))})}return n}var qB=()=>`${yr().supabaseUrl}/functions/v1/v1-me/v1/engine/playbooks`;async function HB(){let e=await Ko().catch(()=>null);if(!e)throw new Error("not signed in: call account_login, then try again");let t=await fetch(qB(),{headers:{authorization:`Bearer ${e}`,apikey:yr().anonKey},signal:AbortSignal.timeout(8e3)}),n=await t.json().catch(()=>null);if(!t.ok||!Array.isArray(n?.playbooks))throw new Error(n?.error?.message??`conform.tools answered ${t.status}`);let i=new TextEncoder;return{version:String(n.version??"unknown"),skills:n.playbooks.map(r=>({name:r.name,files:r.files.map(o=>({path:o.path,bytes:i.encode(o.text)}))}))}}async function CO(e){let t=[];for(let n of e){if(!n.files.some(s=>s.path==="SKILL.md"))continue;let i=`skill://${n.name}`,r=[],o=new Set([""]);for(let s of[...n.files].sort((c,l)=>c.path.localeCompare(l.path))){let c=s.path.split("/");for(let l=1;l<c.length;l++)o.add(c.slice(0,l).join("/"));r.push({uri:`${i}/${s.path}`,path:s.path,name:c[c.length-1],bytes:s.bytes,digest:await IB(s.bytes),mimeType:ZB(s.path)})}let a=WB(new TextDecoder().decode(r.find(s=>s.path==="SKILL.md").bytes));!a||a.name!==n.name||typeof a.description!="string"||r.length>RB||r.reduce((s,c)=>s+c.bytes.length,0)>FB||t.push({name:n.name,uri:`${i}/SKILL.md`,root:i,frontmatter:a,files:r,dirs:o})}return t}var Qb=null;function tP(){Qb??=(async()=>{let t=await VB();if(t)return{skills:await CO(await DB(t)),source:"local",version:"local"};let n=await HB();return{skills:await CO(n.skills),source:"conform.tools",version:n.version}})();let e=Qb;return e.catch(()=>{Qb===e&&(Qb=null)}),e}async function $b(){try{return(await tP()).skills}catch{return[]}}function JO(e){return{uri:e.uri,frontmatter:e.frontmatter,resources:e.files.map(t=>({uri:t.uri,digest:t.digest,size:t.bytes.length}))}}var _b=class extends Error{constructor(n,i){super(i);this.code=n}},BO=-32602;async function Ipe(){return{resultType:"complete",skills:(await $b()).map(JO),ttlMs:AO,cacheScope:"public"}}async function Wpe(e){let t=(await $b()).find(n=>n.uri===e);if(!t)throw new _b(BO,`No skill is served at ${String(e)}`);return{resultType:"complete",skill:JO(t),ttlMs:AO,cacheScope:"public"}}async function Dpe(e){let t=String(e??"").replace(/\/$/,"");for(let n of await $b()){if(t!==n.root&&!t.startsWith(n.root+"/"))continue;let i=t===n.root?"":t.slice(n.root.length+1);if(!n.dirs.has(i))break;let r=i?i+"/":"",o=[];for(let a of[...n.dirs].sort())a&&a.startsWith(r)&&!a.slice(r.length).includes("/")&&o.push({uri:`${n.root}/${a}`,name:a.slice(r.length),mimeType:"inode/directory"});for(let a of n.files)a.path.startsWith(r)&&!a.path.slice(r.length).includes("/")&&o.push({uri:a.uri,name:a.name,mimeType:a.mimeType});return{resultType:"complete",resources:o}}throw new _b(BO,`No skill directory at ${t}`)}async function qpe(){let e=await $b();return e.length?["Skills: this server ships Agent Skills that say how a conform artist uses these tools. Load the one that fits the task:",...e.map(t=>`- ${t.uri} \u2014 ${t.frontmatter.description}`)].join(`
79
+ `):""}var YO=["conform","autoconform","deliver","deliverables","troubleshoot","patch"],nP=["avid","premiere","resolve","finalcut","flame","baselight","protools"],EB={conform:["conform-artist",["SKILL.md","references/turnover-checklist.md"]],autoconform:["auto-conform",["SKILL.md"]],deliver:["delivery-qc",["SKILL.md"]],deliverables:["deliverables",["SKILL.md"]],troubleshoot:["conform-artist",["references/troubleshooting.md"]],patch:["finishing-fixes",["SKILL.md"]]},UO={avid:"references/avid.md",premiere:"references/premiere.md",resolve:"references/resolve.md",finalcut:"references/other-hosts.md",flame:"references/other-hosts.md",baselight:"references/other-hosts.md",protools:"references/other-hosts.md"},CB=e=>e.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/,"").trimStart(),KO=new Set,QO=()=>KO.size>0;async function _O(e,t=[]){let{skills:n,version:i}=await tP(),[r,o]=EB[e],a=n.find(d=>d.name===r);if(!a)throw new Error(`the ${r} playbook is not available (version ${i})`);let s=n.find(d=>d.name==="conform-artist"),c=o.map(d=>[a,d]);for(let d of t)c.some(([,m])=>m===UO[d])||c.push([s,UO[d]]);let l=[],u=[];for(let[d,m]of c){let p=d?.files.find(b=>b.path===m);p&&(u.push(p.uri),l.push(`<!-- ${p.uri} -->
80
+ ${CB(new TextDecoder().decode(p.bytes)).trimEnd()}`))}KO.add(e);let f=`conform.tools playbook \u2014 ${e} (version ${i}). Follow it for this task; it says how a conform artist uses these tools and what to tell the user.`;return{task:e,version:i,files:u,text:[f,...l].join(`
81
+
82
+ ---
83
+
84
+ `)}}async function e0(e,t){let n;try{n=(await tP()).skills.find(a=>a.name===e)}catch{return""}let i=n?.files.find(a=>a.path==="SKILL.md");if(!i)return"";let r=new Set(["always",...t]),o=[];for(let a of new TextDecoder().decode(i.bytes).split(/^(?=#{1,3} )/m)){let s=a.match(/^### (.+?) \(when: ([a-z_, ]+)\)\s*\n/);s&&s[2].split(",").some(c=>r.has(c.trim()))&&o.push(`**${s[1]}.** ${a.slice(s[0].length).trim().replace(/\s*\n\s*/g," ")}`)}return o.join(`
85
+ `)}var UB=wt(),sc=_(UB,"jobs"),Td=new Map;function AB(){let e=new Uint8Array(4);return crypto.getRandomValues(e),"job-"+Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}async function t0(e){try{await vt(sc),await ln(_(sc,`${e.id}.json`),JSON.stringify(e));let{result:t,...n}=e;await ln(_(sc,".current"),JSON.stringify(n))}catch{}}function $O(e,t){let n=new AbortController,i=new Date().toISOString(),r={id:AB(),verb:e,status:"running",started_at:i,updated_at:i,phase:"starting",done:0,total:0},o=0,s=t((c,l,u)=>{r.done=c,r.total=l,r.phase=u,r.updated_at=new Date().toISOString();let f=Date.now();f-o>2e3&&(o=f,t0(r))},n.signal).then(c=>(r.status=c.isError?"failed":"done",r.result=c,r.error=c.isError?c.content[0]?.text:void 0,r.finished_at=new Date().toISOString(),t0(r),c),c=>{r.status=n.signal.aborted?"cancelled":"failed",r.error=c instanceof Error?c.message:String(c),r.finished_at=new Date().toISOString(),t0(r);let l={content:[{type:"text",text:`error: ${r.error}`}],isError:!0,structuredContent:{ok:!1,code:r.status==="cancelled"?"cancelled":"engine",message:r.error}};return r.result=l,l});return Td.set(r.id,{rec:r,ctrl:n,promise:s}),t0(r),r}function rP(e){return Td.get(e)?.promise??null}async function eL(e){let t=Td.get(e);if(t)return t.rec;try{return JSON.parse(await Tn(_(sc,`${e}.json`)))}catch{return null}}function tL(e){let t=Td.get(e);return!t||t.rec.status!=="running"?!1:(t.ctrl.abort(),!0)}async function nL(){let e=new Map;try{await vt(sc);for await(let t of zn(sc))if(t.name.endsWith(".json"))try{let n=JSON.parse(await Tn(_(sc,t.name)));e.set(n.id,n)}catch{}}catch{}for(let t of Td.values())e.set(t.rec.id,t.rec);return[...e.values()].sort((t,n)=>n.started_at.localeCompare(t.started_at)).slice(0,50)}function iP(e){let t=e.total?` ${Math.round(100*e.done/e.total)}%`:"";return`${e.id} ${e.verb} ${e.status} \u2014 ${e.phase}${t} (started ${e.started_at}${e.finished_at?`, finished ${e.finished_at}`:""})${e.error?`
86
+ ${e.error}`:""}`}var iL=()=>_(wt(),"logs","engine.jsonl"),rL=new Set;function oL(e){if(!e||typeof e!="object")return{};let t={};for(let[n,i]of Object.entries(e))typeof i=="string"?t[n]=i.length>200?`${i.slice(0,200)}\u2026`:i:Array.isArray(i)?t[n]=i.length>20?`[${i.length} items]`:i:i&&typeof i=="object"?t[n]=JSON.stringify(i).length>400?"{\u2026}":i:t[n]=i;return t}async function aL(e){let t=JSON.stringify(e);console.error(`[conform] ${e.verb} ${e.ok?"ok":`FAIL ${e.code??""}`} ${e.ms} ms${e.job?` job ${e.job}`:""}`);try{let n=iL(),i=_(wt(),"logs");rL.has(i)||(await vt(i),rL.add(i)),await ln(n,t+`
87
+ `,{append:!0})}catch{}}async function sL(e,t={}){let n="";try{n=await Tn(iL())}catch{return[]}let i=n.split(`
88
+ `).slice(-5e3),r=[];for(let o=i.length-1;o>=0&&r.length<e;o--){if(!i[o])continue;let a;try{a=JSON.parse(i[o])}catch{continue}let s=t.session_id,c=t.job_id;(s||c)&&!(s&&(a.session===s||a.args?.session_id===s||a.args?.hints_session_id===s)||c&&(a.job===c||a.args?.job_id===c))||r.push(a)}return r.reverse()}var cL=["issue","gap","note"],sP=["low","medium","high","blocker"],cP=["missing_tool","missing_option","tool_failed","did_not_know","other"];var oP=String.raw`[^\s"'${"`"}<>|,;()[\]{}\\/]+(?: [^\s"'${"`"}<>|,;()[\]{}\\/:]+(?=$|[\s"'${"`"}<>|,;()[\]{}\\/]))*`,lL=String.raw`[^\s"'${"`"}<>|,;()[\]{}\\/]+`,GB=new RegExp(String.raw`(?<![A-Za-z0-9_.~:\\/-])(?:file://)?(?:~|[A-Za-z]:)?(?:[\\/]${oP}){2,}[\\/]?|\\\\${oP}(?:\\${oP})+`+String.raw`|(?<![A-Za-z0-9_.~:\\/-])${lL}(?:[\\/]${lL}){2,}`,"g");function JB(e){let t=e.replace(/[\\/]+$/,""),n=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return n>=0?t.slice(n+1):t}function uL(e){return e.replace(GB,t=>JB(t.replace(/^file:\/\//,"")))}function aP(e,t=300,n=0){if(typeof e=="string")return n0(uL(e),t);if(typeof e=="number"||typeof e=="boolean"||e===null)return e;if(n>4)return null;if(Array.isArray(e))return e.slice(0,20).map(i=>aP(i,t,n+1));if(e&&typeof e=="object"){let i={};for(let[r,o]of Object.entries(e).slice(0,40))i[n0(r,64)]=aP(o,t,n+1);return i}return null}var n0=(e,t)=>e.length>t?`${e.slice(0,t)}\u2026`:e;function ts(e,t){if(typeof e!="string")return null;let n=e.trim();return n?n0(uL(n),t):null}var BB=/^[A-Za-z0-9_.:-]{1,64}$/;function No(e){return typeof e=="string"&&BB.test(e)?e:null}var cc=(e,t)=>typeof e=="string"&&t.includes(e)?e:null;function lP(e){if(!e||typeof e!="object")return null;let t=e,n={};typeof t.ts=="string"&&(n.ts=n0(t.ts,40));let i=No(t.verb);i&&(n.verb=i),typeof t.ms=="number"&&Number.isFinite(t.ms)&&(n.ms=Math.round(t.ms)),typeof t.ok=="boolean"&&(n.ok=t.ok);for(let o of["code","job","session"]){let a=No(t[o]);a&&(n[o]=a)}let r=ts(t.msg,500);return r&&(n.msg=r),t.args&&typeof t.args=="object"&&(n.args=aP(t.args,160)),n.verb?n:null}var si={summary:300,task:500,used_instead:300,what_happened:4e3,expected:4e3};function fL(e){if(!e||typeof e!="object")return"body must be a JSON object";let t=e,n=cc(t.kind??"issue",cL);if(!n)return`kind must be one of ${cL.join(", ")}`;let i=ts(t.task,si.task),r=ts(t.summary,si.summary)??(n==="gap"?i:null);if(!r)return n==="gap"?"task is required":"summary is required";let o=Array.isArray(t.log_lines)?t.log_lines.slice(-20).map(lP).filter(a=>!!a):[];return{kind:n,summary:r,what_happened:ts(t.what_happened,si.what_happened),expected:ts(t.expected,si.expected),severity:n==="issue"?cc(t.severity,sP)??"medium":null,session_id:No(t.session_id),verb:No(t.verb),job_id:No(t.job_id),task:n==="gap"?i:null,used_instead:n==="gap"?ts(t.used_instead,si.used_instead):null,why_not_conformtools:n==="gap"?cc(t.why_not_conformtools,cP)??(t.why_not_conformtools?"other":null):null,conformtools_verb_tried:No(t.conformtools_verb_tried),version:No(t.version),engine:cc(t.engine,["local","hosted"]),platform:ts(t.platform,80),runtime:ts(t.runtime,80),account_env:cc(t.account_env,["production","staging"]),log_lines:o}}var YB=/^[a-z_]{1,32}$/,KB=/^[A-Za-z0-9_.]{1,64}$/;function QB(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t={};for(let[n,i]of Object.entries(e).slice(0,16))YB.test(n)&&typeof i=="number"&&Number.isFinite(i)&&i>=0&&(t[n]=Math.round(i));return Object.keys(t).length?t:null}function dL(e){if(!e||typeof e!="object")return null;let t=e,n=cc(t.kind,["outcome","invalid_args"]),i=No(t.verb);if(!n||!i)return null;let r=n==="invalid_args"&&Array.isArray(t.fields)?t.fields.filter(o=>typeof o=="string"&&KB.test(o)).slice(0,16):null;return{kind:n,verb:i,ok:n==="outcome"&&typeof t.ok=="boolean"?t.ok:null,code:No(t.code),duration_ms:typeof t.duration_ms=="number"&&Number.isFinite(t.duration_ms)&&t.duration_ms>=0?Math.round(t.duration_ms):null,version:No(t.version),engine:cc(t.engine,["local","hosted"]),counts:n==="outcome"?QB(t.counts):null,fields:r,run_at:typeof t.run_at=="string"&&!Number.isNaN(Date.parse(t.run_at))?new Date(t.run_at).toISOString():null}}var eY="support@conform.tools",hL=15,mL=2e3,ehe=[`conformtools ${so} is the conform.tools engine on this machine: timeline exchange between editing hosts (Avid, Premiere, Resolve, Final Cut, Flame), relinking, media probe/trim/consolidate, delivery packages and auto conform. account_status shows the running version and whether a newer one is on npm.`,"0. Before any conform, timeline conversion, relink, verification or delivery task, call conform_learn with the task (and the hosts involved) and follow the playbook it returns. It needs a signed-in account; if it cannot load, carry on with the tools.",'1. When you call one of these tools, say so in one short line first: "using conformtools: <tool>" (for example "using conformtools: timeline_read").','2. Whenever you do a post-production task (anything about timelines, edits, media files, codecs, timecode, relinking, conforming, delivery) with ANYTHING other than conformtools, such as ffmpeg, ffprobe, mediainfo, exiftool, a python or shell script, another MCP server, or manual steps you ask the user to do in a host app, or when conformtools cannot do the task at all, call report_gap once for that task, before or right after the workaround. Say what the user wanted (task), what you used instead (used_instead, e.g. "ffprobe -show_streams"), why not conformtools (missing_tool, missing_option, tool_failed, did_not_know), and what you needed from it (needed: the information or operation, and which of its output fields you used) so the team can build it into conformtools. Tell the user you sent it. Never put full file paths in it; file names at most.',"3. When the user says a conformtools result is wrong, complains about it, corrects an output, or a tool failed unexpectedly, call report_issue with a short summary, what happened and what they expected, plus the session_id / verb / job_id involved. Tell the user it was sent and give them the report id.",'4. A lesson, workflow rule or suggestion (nothing broke: "the patch range runs whole clip before to whole clip after", "this facility files renders in 200 - FINISH") goes to report_note, not report_issue.',"report_issue, report_gap and report_note never send media, file contents or timeline files. Outcome telemetry is off unless the user turned it on (account_telemetry)."].join(`
89
+ `),bL=()=>_(wt(),"config.json");async function gL(){try{return JSON.parse(await Tn(bL()))}catch{return{}}}async function tY(e){await vt(wt()),await ln(bL(),JSON.stringify(e,null,1))}async function Ul(){return Ut("CONFORM_TELEMETRY")==="off"||Ut("CONFORM_TELEMETRY")==="0"?!1:(await gL()).telemetry===!0}async function vL(e){let t=await gL();t.telemetry=e,t.telemetry_changed_at=new Date().toISOString(),await tY(t),e||await Er(Od()).catch(()=>{})}var pL="per tool run: the tool name, ok or the error code, duration, package version, engine mode (local/hosted) and counts (clips, files, matched/unmatched\u2026, numbers only); per rejected call: the tool name and the names of the arguments that failed validation. Never paths, file or clip names, timeline contents or media.";async function yL(){let e=await Ul(),t=(await dP()).length;return e?`outcome telemetry: ON \u2014 records ${pL}
90
+ sent in batches at most every ${hL} min${t?`; ${t} event(s) waiting`:""}. Turn off: conformtools telemetry off`:`outcome telemetry: OFF (the default). Nothing is recorded. If turned on it records ${pL} Turn on: conformtools telemetry on`}var nY=e=>`${yr().supabaseUrl}/functions/v1/v1-me/v1/engine/${e}`;async function pP(e,t,n){return await fetch(nY(e),{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${n}`,apikey:yr().anonKey},body:JSON.stringify(t),signal:AbortSignal.timeout(1e4)})}async function r0(e,t){let{platform:n,runtime:i}=Z6(),r=t,o=e==="issue"?(await sL(20,{session_id:r.session_id,job_id:r.job_id})).map(lP).filter(s=>!!s):[],a=fL({...t,kind:e,version:so,engine:ac(),platform:n,runtime:i,account_env:yr().env,log_lines:o});if(typeof a=="string")throw new Error(a);return a}async function i0(e){let t=_(wt(),"reports");await vt(t);let n=_(t,`${new Date().toISOString().replace(/[:.]/g,"-")}-${e.kind}.json`);await ln(n,JSON.stringify(e,null,1));let i=await Ko().catch(()=>null);if(!i)return{sent:!1,saved:n,reason:"not signed in (account_login)"};let r=(await Uc().catch(()=>null))?.email??null;try{let o=await pP("report",e,i),a=await o.json().catch(()=>({}));return!o.ok||!a.id?{sent:!1,saved:n,email:r,status:o.status,reason:`conform.tools answered ${o.status}${a.error?.message?`: ${a.error.message}`:""}`}:(await ln(n,JSON.stringify({id:a.id,...e},null,1)),{sent:!0,id:a.id,saved:n,email:r,resent:await iY(i)})}catch(o){return{sent:!1,saved:n,email:r,reason:`conform.tools is unreachable (${o instanceof Error?o.message:String(o)})`}}}var rY=20,uP=!1;async function iY(e){if(uP)return 0;uP=!0;let t=0,n=0;try{let i=_(wt(),"reports"),r=[];for await(let o of zn(i))o.isFile&&o.name.endsWith(".json")&&r.push(o.name);for(let o of r.sort()){if(n>=rY)break;let a=_(i,o),s;try{s=JSON.parse(await Tn(a))}catch{continue}if(s.id||s.rejected)continue;n++;let c=await pP("report",s,e).catch(()=>null),l=await c?.json().catch(()=>({}));if(c?.status===400){await ln(a,JSON.stringify({rejected:l?.error?.message??"400",...s},null,1));continue}if(!c?.ok||!l?.id)break;await ln(a,JSON.stringify({id:l.id,...s},null,1)),t++}}catch{}finally{uP=!1}return t}function oY(e){let t=e;return Object.entries(si).filter(([n,i])=>typeof t[n]=="string"&&t[n].trim().length>i).map(([n])=>n)}function o0(e,t,n,i){let r=oY(i),o=Tt(aY(e,t,n,r),{sent:t.sent,report_id:t.id??null,saved:t.saved,reason:t.reason??null,status:t.status??null,resent:t.resent??0,clipped:r,...e==="issue"?{log_lines:n.log_lines.length}:{}});return t.sent||(o.structuredContent.ok=!1),o}function aY(e,t,n,i=[]){let r=e==="issue"?`issue report${n.log_lines.length?` with the last ${n.log_lines.length} log line(s)${n.session_id||n.job_id?" for that session/job":""}`:""}`:e==="gap"?"tool-gap report":"note",o=i.length?`
91
+ Cut to fit: ${i.map(a=>`${a} (max ${si[a]} chars)`).join(", ")}.`:"";return t.sent?`sent ${r} to conform.tools \u2014 report id ${t.id.slice(0,8)}${t.email?` (account ${t.email})`:""}.
92
+ No media, file contents or timeline files were sent; paths were cut to file names. Copy of what was sent: ${t.saved}`+(t.resent?`
93
+ Also sent ${t.resent} earlier report(s) that had been saved unsent.`:"")+o:`NOT SENT \u2014 ${t.reason}. The ${r} is saved to ${t.saved}; it is resent automatically after the next report that gets through, or send that file to ${eY}.`+o}var Md=()=>_(wt(),"telemetry"),Od=()=>_(Md(),"queue.jsonl"),fP=()=>_(Md(),"state.json");async function dP(){try{return(await Tn(Od())).split(`
94
+ `).filter(Boolean).flatMap(e=>{try{return[JSON.parse(e)]}catch{return[]}})}catch{return[]}}var sY=new Set(["account_login","account_status","account_logout","account_telemetry","report_issue","report_gap","report_note","job_status","job_cancel","job_list","timeline_routes","timeline_sessions"]),cY=[["clips",/\b(\d+) clips?\b/i],["files",/\b(\d+) (?:output )?files?(?:\(s\))?\b/i],["sources",/\b(\d+) sources?(?:\(s\))?\b/i],["skipped",/\bskipped (\d+)\b/i],["matched",/\b(?:(\d+) matched|matched[: =]+(\d+))\b/i],["unmatched",/\b(?:(\d+) unmatched|unmatched[: =]+(\d+))\b/i],["ambiguous",/\b(?:(\d+) ambiguous|ambiguous[: =]+(\d+))\b/i],["unresolved",/\b(?:(\d+) unresolved|unresolved[: =]+(\d+))\b/i],["linked",/\b(?:(\d+) linked|linked[: =]+(\d+))\b/i],["issues",/\bissues \((\d+)\)/i],["frames",/\((\d+) frames\)/i]];function lY(e){let t={},n=e.content.map(i=>i.text).join(`
95
+ `);for(let[i,r]of cY){let o=n.match(r),a=o?Number(o[1]??o[2]):NaN;Number.isFinite(a)&&(t[i]=a)}for(let[i,r]of Object.entries(e.structuredContent??{}))typeof r=="number"&&/^[a-z_]{1,32}$/.test(i)&&!(i in t)&&(t[i]=r);return t}async function wL(e){let t=dL(e);t&&(await vt(Md()),await ln(Od(),JSON.stringify(t)+`
96
+ `,{append:!0}))}var mP=new Set;function xL(e){return mP.add(e),e.finally(()=>mP.delete(e)),e}async function the(){await Promise.allSettled([...mP])}function hP(e,t,n){return xL(uY(e,t,n))}async function uY(e,t,n){try{if(sY.has(e)||!await Ul())return;await wL({kind:"outcome",verb:e,ok:!t.isError,code:t.isError?String(t.structuredContent?.code??"engine"):void 0,duration_ms:n,version:so,engine:ac(),counts:lY(t),run_at:new Date().toISOString()}),PL()}catch{}}function bP(e,t){return xL(fY(e,t))}async function fY(e,t){try{if(!await Ul())return;await wL({kind:"invalid_args",verb:e,fields:t,version:so,engine:ac(),run_at:new Date().toISOString()}),PL()}catch{}}function a0(e){return[...new Set(e.map(t=>t.path.map(String).join(".")||"(root)"))]}var zd=null;function PL(e={}){return zd||(zd=(async()=>{try{if(!await Ul())return;let t={};try{t=JSON.parse(await Tn(fP()))}catch{}if(!e.force&&!t.last_flush){await vt(Md()),await ln(fP(),JSON.stringify({last_flush:Date.now()}));return}if(!e.force&&Date.now()-t.last_flush<hL*6e4)return;let n=await dP();if(!n.length)return;let i=await Ko().catch(()=>null);if(!i)return;await vt(Md()),await ln(fP(),JSON.stringify({last_flush:Date.now()}));let r=n.slice(0,500),o=await pP("telemetry",{events:r},i).catch(()=>null);if(o?.ok||o?.status===400){let a=await dP();await ln(Od(),a.slice(r.length).map(s=>JSON.stringify(s)+`
97
+ `).join(""))}else n.length>mL&&await ln(Od(),n.slice(-mL).map(a=>JSON.stringify(a)+`
98
+ `).join(""));await o?.body?.cancel().catch(()=>{})}catch{}finally{zd=null}})(),zd)}var dY=wt(),Al=_(dY,"sessions"),s0=new Map;function mY(){let e=new Uint8Array(4);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}async function la(e,t,n){let i=new Date().toISOString(),r={id:mY(),source_path:t,source_format:n,created_at:i,updated_at:i,history:[],session:e};return s0.set(r.id,r),await kL(r),r}async function ci(e){let t=s0.get(e);if(t)return t;try{let n=await Tn(_(Al,`${e}.json`)),i=JSON.parse(n);return s0.set(e,i),i}catch{throw new Error(`unknown session_id '${e}' \u2014 call timeline_read first, or timeline_sessions to list`)}}async function ns(e,t){e.updated_at=new Date().toISOString(),e.history.push(t),s0.set(e.id,e),await kL(e)}async function SL(){await vt(Al);let e=[];for await(let t of zn(Al))if(t.name.endsWith(".json"))try{let n=JSON.parse(await Tn(_(Al,t.name))),{session:i,...r}=n;e.push(r)}catch{}return e.sort((t,n)=>n.updated_at.localeCompare(t.updated_at))}async function kL(e){await vt(Al),await ln(_(Al,`${e.id}.json`),JSON.stringify(e))}function TL(e,t){if(!t||t<=0)return null;let n=e.match(/^(\d+):(\d+):(\d+)([:;])(\d+)$/);if(!n)return null;let i=+n[1],r=+n[2],o=+n[3],a=+n[5],s=Math.round(t),c=(i*3600+r*60+o)*s+a;if(n[4]===";"&&(s===30||s===60)){let l=s===60?4:2,u=i*60+r;c-=l*(u-Math.floor(u/10))}return c}function pY(e){return{path:e.path,resolution_w:e.resolution_w??null,resolution_h:e.resolution_h??null,codec:e.codec??null,container:e.container??null,fps:e.fps??null,bit_depth:e.bit_depth??null,reel:e.reel_name??null,timecode:e.timecode??null}}function gP(e,t,n,i,r){if(!(e>0&&t>0&&i>0&&r>0))return{baseW:i,baseH:r,kx:1,ky:1};let o=e/t,a=i/r,[s,c]=o>a?[1,o/a]:o<a?[a/o,1]:[1,1],l=Math.max(e/i,t/r)||1;return{baseW:e*n/l,baseH:t/l,kx:s,ky:c}}var c0=(e,{matches:t})=>{let n=e.media_references??[],i=[];for(let o of t){let a=n.find(R=>R.id===o.ref_id);if(!a)continue;let s=a.source_facts_origin??null,c={path:a.target_url??null,resolution_w:a.source_resolution_w??null,resolution_h:a.source_resolution_h??null,codec:a.codec??null,container:a.container??null,fps:a.source_fps??null,bit_depth:a.streams?.[0]?.bit_depth??null,reel:a.reel_name??null,timecode:a.source_timecode??null},l=a.metadata??={};l.pre_relink||(l.pre_relink={...c,pixel_aspect:a.source_pixel_aspect??null,facts_origin:a.source_facts_origin??null,available_range:a.available_range?JSON.parse(JSON.stringify(a.available_range)):null});let u=o.to;a.target_url=u.path,u.size_bytes!=null&&(a.size_bytes=u.size_bytes),u.resolution_w!=null&&(a.source_resolution_w=u.resolution_w),u.resolution_h!=null&&(a.source_resolution_h=u.resolution_h),u.codec!=null&&(a.codec=u.codec),u.container!=null&&(a.container=u.container),u.fps!=null&&(a.source_fps=u.fps),u.pixel_aspect!=null&&(a.source_pixel_aspect=u.pixel_aspect),u.bitrate_bps!=null&&(a.bitrate_bps=u.bitrate_bps),u.reel_name!=null&&(a.reel_name=u.reel_name),u.timecode!=null&&(a.source_timecode=u.timecode),u.local_path!=null&&(a.local_path=u.local_path),u.streams&&u.streams.length>0&&(a.streams=u.streams),(u.resolution_w!=null||u.timecode!=null||u.fps!=null||u.pixel_aspect!=null)&&(a.source_facts_origin="probed"),u.vendor_metadata&&Object.keys(u.vendor_metadata).length>0&&(a.vendor_metadata={...a.vendor_metadata??{},...u.vendor_metadata}),u.reel_sources&&(a.reel_sources={...a.reel_sources??{},...u.reel_sources}),u.recipe!==void 0&&(a.recipe=u.recipe);let f=u.fps??null,d=u.recipe&&"frame_count"in u.recipe?u.recipe.frame_count:u.frame_count??null,m=d??null,p=f??a.source_fps??null;m!=null&&p?a.available_range={start:{value:0,rate:p},duration:{value:m,rate:p}}:u.keep_range_if_unknown||(a.available_range=null);let b=a.raw_extraction;b&&"proxyResolution"in b&&delete b.proxyResolution;let h=c.resolution_w,v=c.resolution_h,g=u.resolution_w??null,y=u.resolution_h??null,w=u.pixel_aspect??a.source_pixel_aspect??1,x=h!=null&&v!=null&&g!=null&&y!=null&&h*y!==g*v,T=g!=null&&y!=null,z=[];for(let R of e.timelines??[]){let I=R.resolution_w??0,q=R.resolution_h??0;for(let Y of R.tracks??[])for(let D of Y.items??[])if(D.media_reference_id===o.ref_id&&D.source_range){if(z.push({it:D}),x){let j=gP(h,v,1,I,q),C=gP(g,y,w,I,q),H=j.kx!==0?C.kx/j.kx:1,ne=j.ky!==0?C.ky/j.ky:1;typeof D.position_x=="number"&&(D.position_x*=H),typeof D.position_y=="number"&&(D.position_y*=ne);for(let le of D.keyframes??[])if(le.parameter_path==="position"&&Array.isArray(le.value)){let Se=le.value;typeof Se[0]=="number"&&(Se[0]*=H),typeof Se[1]=="number"&&(Se[1]*=ne)}}if(T){let j=gP(g,y,w,I,q);D.render_base_w=j.baseW,D.render_base_h=j.baseH,D.render_pos_div_x=j.kx,D.render_pos_div_y=j.ky}}}let k="linked",S,M=!1,L=u.path.split(/[/\\]/).pop()??u.path,P=()=>{let R=z.find(({it:I})=>(I.source_range.duration?.value??0)>m);if(R){k="unbound",M=!0,S=`cut duration ${R.it.source_range.duration?.value??0}f exceeds linked media ${L} extent ${m}f`;return}for(let{it:I}of z){let q=I.source_range.duration?.value??0,Y=I.source_range.start.value;if(Y<0||Y+q>m){let D=Math.max(0,Math.floor((m-q)/2));I.source_range={...I.source_range,start:{...I.source_range.start,value:D}};let j=I.raw_extraction??(I.raw_extraction={});j.sourceConformedToMedia=!0}}};if(Bm(a))a.content_kind==null&&(a.content_kind="still");else if(m==null)k="unbound",S=`matched ${L} by name but not probed \u2014 coverage unverified`;else if(c.timecode&&u.timecode!=null){let R=u.fps??c.fps??null,I=TL(c.timecode,R),q=TL(u.timecode,R);if(I==null||q==null)k="unbound",S=`could not verify ${L} timecode placement \u2014 coverage unverified`;else{let Y=I-q,D=z.find(({it:j})=>{let C=j.source_range.start.value+Y,H=j.source_range.duration?.value??0;return C<0||C+H>m});if(D)if(s!=="probed"&&I===0)P();else{k="unbound",M=!0;let C=D.it.source_range.start.value+Y,H=D.it.source_range.duration?.value??0;S=`cut [${C}..${C+H}] not within linked media ${L} [0..${m}] (source TC ${c.timecode} \u2192 ${u.timecode})`}else if(Y!==0)for(let{it:j}of z){let C=j.source_range.start.rate||1;j.source_range={...j.source_range,start:{...j.source_range.start,value:j.source_range.start.value+Y}};for(let ne of j.keyframes??[])if(!(!ne.time||typeof ne.time.value!="number"))if(ne.parameter_path==="speed"){let le=Y/C;if(ne.time.value===0&&ne.value===0)continue;ne.time={...ne.time,value:Math.max(0,ne.time.value+le)},typeof ne.value=="number"&&(ne.value=Math.max(0,ne.value+le))}else{let le=ne.time.rate||C;ne.time={...ne.time,value:Math.max(0,ne.time.value+Y*(le/C))}}let H=j.raw_extraction??(j.raw_extraction={});typeof H.alternateFrame=="number"&&(H.alternateFrame=q),H.sourceConformedToMedia=!0}}}else P();a.binding_state=k;let X;S?(a.coverage_reason=S,M&&(X=S)):delete a.coverage_reason,i.push({ref_id:o.ref_id,confidence:o.confidence,reasons:o.reasons??[],before:c,after:pY(u),...X?{warning:X}:{}})}let r=i.filter(o=>o.warning).length;return{summary:`Relinked ${i.length} reference${i.length===1?"":"s"}`+(r?` \xB7 ${r} unresolved (cut not covered)`:""),meta:{applied:i}}};function ua(e,t){return e.timelines?.find(n=>n.id===t)}function Gl(e,t,n){let i=ua(e,t);if(i)for(let r of i.tracks??[]){let o=(r.items??[]).findIndex(a=>a.id===n);if(o!==-1)return{timeline:i,track:r,item:r.items[o],index:o}}}function fa(e){(e.items??[]).forEach((t,n)=>{t.item_index=n})}function Ro(e){let t=0;for(let n of e.tracks??[])for(let i of n.items??[])t=Math.max(t,i.timeline_range.start.value+i.timeline_range.duration.value);e.duration_frames=t}function Ld(e,t){let n=new Set;for(let r of e.timelines??[])for(let o of r.tracks??[]){n.add(o.id);for(let a of o.items??[])n.add(a.id)}for(let r of e.media_references??[])n.add(r.id);let i=1;for(;n.has(`${t}-${i}`);)i++;return`${t}-${i}`}function zL(e){let t=e.timeline_range.start.value;return[t,t+e.timeline_range.duration.value]}function hY(e,t,n,i){return n>t?(e.items??[]).filter(r=>{if(i&&r.id===i)return!1;let[o,a]=zL(r);return o<n&&t<a}):[]}function rs(e,t,n,i,r){let o={removed:0,trimmed:0,split:0},a=hY(t,n,i,r);if(a.length===0)return o;let s=new Set,c=[];for(let l of a){let[u,f]=zL(l);if(l.kind==="transition"||u>=n&&f<=i){s.add(l),o.removed++;continue}if(u<n&&f>i){let d=structuredClone(l);d.id=Ld(e,"ov-it"),d.timeline_range.start.value=i,d.timeline_range.duration.value=f-i,d.source_range&&(d.source_range.start.value+=i-u,d.source_range.duration.value=f-i),c.push(d),l.timeline_range.duration.value=n-u,l.source_range&&(l.source_range.duration.value=n-u),o.split++;continue}if(u<n)l.timeline_range.duration.value=n-u,l.source_range&&(l.source_range.duration.value=n-u);else{let d=i-u;l.timeline_range.start.value=i,l.timeline_range.duration.value=f-i,l.source_range&&(l.source_range.start.value+=d,l.source_range.duration.value=f-i)}o.trimmed++}return(s.size||c.length)&&(t.items=[...(t.items??[]).filter(l=>!s.has(l)),...c]),(t.items??=[]).sort((l,u)=>l.timeline_range.start.value-u.timeline_range.start.value),fa(t),o}function Jl(e){let t=[];return e.removed&&t.push(`${e.removed} overwritten`),e.trimmed&&t.push(`${e.trimmed} trimmed`),e.split&&t.push(`${e.split} split`),t.length?` \xB7 ${t.join(", ")}`:""}var l0={head:null,tail:null};function bY(e,t){if(!t?.start||!t.duration||!e||e.content_kind==="still")return l0;let n=e.available_range,i=n?.duration?.value;if(!n||typeof i!="number"||!(i>1))return l0;let r=n.start?.value??0,o=r+i,a=t.start.value,s=a+t.duration.value;return{head:Math.max(0,Math.round(a-r)),tail:Math.max(0,Math.round(o-s))}}function vP(e,t){if(!t.media_reference_id)return l0;let n=(e.media_references??[]).find(i=>i.id===t.media_reference_id);return bY(n,t.source_range)}function gY(e,t,n,i,r={}){let o=Math.round(t),a=Math.max(0,n-1);if(e==="in"){let c=[i.head,r.startFrame,r.sourceStart].filter(u=>typeof u=="number").map(u=>-Math.max(0,u)),l=c.length?Math.max(...c):-1/0;return Math.min(a,Math.max(l,o))}let s=i.tail==null?1/0:i.tail;return Math.max(-a,Math.min(s,o))}function vY(e,t,n,i,r){return(e==="in"?t<0:t>0)?e==="out"?"there is no media after its out point":r<=0?"it already starts at the head of the timeline":"there is no media before its in point":n<=1?"it is already one frame long":"it cannot get any shorter"}var ML=(e,{timeline_id:t,item_id:n,edge:i,delta_frames:r,ripple:o})=>{let a=ua(e,t);if(!a)return{summary:"Trim: timeline not found"};for(let s of a.tracks??[]){let c=(s.items??[]).find(w=>w.id===n);if(!c)continue;let l=c.timeline_range,u=c.source_range,f=c.name??"clip",d=l.start.value,m=d+l.duration.value,p=vP(e,c),b=Math.round(Number(r)||0),h=gY(i,b,l.duration.value,p,{startFrame:d,sourceStart:u?.start.value});if(h===0)return{summary:b===0?`Trim: "${f}" \u2014 no change`:`Trim: "${f}" won't move \u2014 ${vY(i,b,l.duration.value,p,d)}`,meta:{timeline_id:t,item_id:n,edge:i,delta_frames:0,asked:b,clamped:b!==0}};let v=0;if(i==="out"?(l.duration.value+=h,u&&(u.duration.value+=h),v=h):(l.start.value+=h,l.duration.value-=h,u&&(u.start.value+=h,u.duration.value-=h),v=-h),o&&v!==0)for(let w of s.items)w.id!==c.id&&w.timeline_range.start.value>=m&&(w.timeline_range.start.value+=v);let g={removed:0,trimmed:0,split:0};i==="in"&&h<0?g=rs(e,s,l.start.value,d,c.id):i==="out"&&h>0&&!o&&(g=rs(e,s,m,l.start.value+l.duration.value,c.id)),Ro(a);let y=h>0?"+":"";return{summary:`Trimmed ${i} of "${f}" by ${y}${h}f`+(o?" (rippled)":"")+(h!==b?" (limited by the media)":"")+Jl(g),meta:{timeline_id:t,item_id:n,edge:i,delta_frames:h,asked:b,clamped:h!==b,ripple:!!o,cleared:g}}}return{summary:"Trim: item not found"}};var OL=(e,{timeline_id:t,item_id:n,delta_frames:i})=>{let r=Gl(e,t,n);if(!r)return{summary:"Slip: item not found"};let{item:o}=r;if(!o.source_range)return{summary:"Slip: clip has no source range"};let{head:a,tail:s}=vP(e,o),c=Math.round(Number(i)||0),l=s??1/0,u=a==null?-o.source_range.start.value:-a,f=Math.max(u,Math.min(l,c)),d=Math.max(0,o.source_range.start.value+f),m=d-o.source_range.start.value;if(o.source_range.start.value=d,m===0)return{summary:c===0?`Slip: "${o.name??"clip"}" \u2014 no change`:`Slip: "${o.name??"clip"}" is already at the ${c>0?"end":"start"} of its media`,meta:{timeline_id:t,item_id:n,delta_frames:0,asked:c,clamped:c!==0}};let p=m>0?"+":"";return{summary:`Slipped "${o.name??"clip"}" ${p}${m}f`+(m!==c?" (limited by the media)":""),meta:{timeline_id:t,item_id:n,delta_frames:m,asked:c,clamped:m!==c}}};var LL=(e,{timeline_id:t,item_id:n,ripple:i})=>{let r=ua(e,t);if(!r)return{summary:"Delete: timeline not found"};for(let o of r.tracks??[]){let a=(o.items??[]).findIndex(u=>u.id===n);if(a===-1)continue;let s=o.items[a],c=s.timeline_range.start.value,l=s.timeline_range.duration.value;if(o.items.splice(a,1),i)for(let u of o.items)u.timeline_range.start.value>=c&&(u.timeline_range.start.value-=l);return fa(o),Ro(r),{summary:`Deleted "${s.name??"clip"}"${i?" (rippled)":""}`,meta:{timeline_id:t,item_id:n,ripple:!!i}}}return{summary:"Delete: item not found"}};function u0(e){return e==="fit"||e==="fill"||e==="stretch"||e==="none"}var yY=.005;function wY(e,t,n,i){if(e<=0||t<=0||n<=0||i<=0)return!1;let r=e/t,o=n/i;return Math.abs(r-o)/Math.max(r,o)<=yY}function wP(e,t,n,i,r){let o=i,a=r;if(!e||!t||e<=0||t<=0||o<=0||a<=0)return[o,a,1,1];let s=e,c=t,l=s/c,u=o/a,f=1,d=1;l>u?d=l/u:l<u&&(f=u/l);let m=Math.max(s/o,c/a);return m>0||(m=1),[s*n/m,c/m,f,d]}function xP(e,t,n,i){let r=Math.max(e/n,t/i);return r>0?r:1}function XL(e,t,n,i){let r=e/n,o=t/i,a=Math.max(r,o),s=Math.min(r,o);return s>0?a/s:1}function Xd(e,t){return`${e}\xD7${t}`}function xY(e,t){for(let n of e.tracks??[])if(n.kind==="Video"){for(let i of n.items??[])if(NL(i)&&(i.reframe_fit??"fit")!==t)return!0}return!1}function NL(e){let t=e.kind??"clip";return t==="clip"||t==="nested"}function RL(e,t,n,i){return e/n<t/i?"x":"y"}function PY(e,t,n,i,r){let o=e.reframe_fit;if(!o||o==="fit")return;let a=o==="none"?xP(t,n,i,r):XL(t,n,i,r);a!==1&&(o==="fill"||o==="none"?(e.scale!=null&&(e.scale=e.scale/a),e.raw_scale!=null&&(e.raw_scale=e.raw_scale/a)):o==="stretch"&&(RL(t,n,i,r)==="x"?e.scale_x!=null&&(e.scale_x=e.scale_x/a):e.scale_y!=null&&(e.scale_y=e.scale_y/a)))}function FL(e,t,n,i,r,o){if(!n||!i||n<=0||i<=0){e.reframe_fit=t;return}VL(e,t,n,i,r,o)}function VL(e,t,n,i,r,o){if(e.reframe_fit=t,t==="fit")return;if(t==="none"){let s=xP(n,i,r,o);if(s===1)return;e.scale=(e.scale??100)*s,e.raw_scale!=null&&(e.raw_scale=e.raw_scale*s);return}let a=XL(n,i,r,o);if(a!==1)if(t==="fill")e.scale=(e.scale??100)*a,e.raw_scale!=null&&(e.raw_scale=e.raw_scale*a);else{let s=e.scale??100;RL(n,i,r,o)==="x"?e.scale_x=(e.scale_x??s)*a:e.scale_y=(e.scale_y??s)*a}}function yP(e,t,n,i,r,o,a){let s=0;for(let c of e.tracks??[])if(c.kind==="Video")for(let l of c.items??[]){if(!NL(l))continue;let{w:u,h:f,par:d}=t(l),m=!!u&&!!f&&u>0&&f>0;m&&a!=null&&PY(l,u,f,r,o);let[p,b,h,v]=wP(u,f,d,n,i);l.render_base_w=p,l.render_base_h=b,l.render_pos_div_x=h,l.render_pos_div_y=v,l.raw_scale!=null&&m&&(l.raw_scale=(l.scale??100)/xP(u,f,n,i)),m&&a!=null&&VL(l,a,u,f,n,i),s++}return a!=null&&(e.mismatch_policy=a),s}var jL=(e,t)=>{let n=Math.round(Number(t?.resolution_w)),i=Math.round(Number(t?.resolution_h));if(!Number.isFinite(n)||!Number.isFinite(i)||n<=0||i<=0)return{summary:"Reformat: resolution must be two positive numbers"};if(n%2!==0||i%2!==0)return{summary:`Reformat: ${Xd(n,i)} \u2014 dimensions must be even`};let r=t?.fit??null;if(r!=null&&!u0(r))return{summary:`Reformat: unknown fit policy "${r}"`};let o=new Map;for(let g of e.media_references??[])g.id&&o.set(g.id,g);let a=g=>{let y=g.media_reference_id?o.get(g.media_reference_id):void 0,w=g.pixel_aspect_ratio??y?.source_pixel_aspect??1;return{w:y?.source_resolution_w??null,h:y?.source_resolution_h??null,par:w>0?w:1}},s=e.timelines??[],c;if(t.timeline_id&&t.timeline_id!=="*"){let g=ua(e,t.timeline_id);if(!g)return{summary:"Reformat: timeline not found"};c=[g]}else c=s;if(c.length===0)return{summary:"Reformat: no timelines in this session"};let l=[],u=[],f=0,d=!1,m=!1;for(let g of c){let y=g.resolution_w,w=g.resolution_h;if(y==null||w==null||y<=0||w<=0){g.resolution_w=n,g.resolution_h=i,f+=yP(g,a,n,i,n,i,r),l.push(g.id);continue}if(y===n&&w===i){let T=r!=null&&xY(g,r),z=r!=null&&(g.mismatch_policy??"fit")!==r;if(T||z){T?f+=yP(g,a,n,i,y,w,r):r!=null&&(g.mismatch_policy=r),l.push(g.id),m=!0;continue}u.push({timeline_id:g.id,name:g.name??null,reason:`already ${Xd(n,i)}`});continue}let x=!wY(y,w,n,i);if(x&&r==null){u.push({timeline_id:g.id,name:g.name??null,reason:`${Xd(y,w)} \u2192 ${Xd(n,i)} changes the aspect ratio \u2014 choose fit (bars), fill (crop), stretch (distort) or none (native pixels)`});continue}g.resolution_w=n,g.resolution_h=i,f+=yP(g,a,n,i,y,w,r),l.push(g.id),x&&(d=!0)}let p=l.length,b=f>0?` \xB7 ${f} clip${f===1?"":"s"}`:"",h=u.length>0?` \xB7 ${u.length} skipped`:"";return{summary:p===0?`Reformat: nothing changed \u2014 ${u[0]?.reason??"no eligible timeline"}`:m&&!d?`Reframed ${p} timeline${p===1?"":"s"} to ${r}${b}${h}`:`Reformatted ${p} timeline${p===1?"":"s"} to ${Xd(n,i)}`+(d&&r?` (${r})`:"")+(b?`${b} re-based`:"")+h,meta:{resolution_w:n,resolution_h:i,fit:r??void 0,changed:l,skipped:u,clips_rebased:f,reframe_only:m}}};var WL="conform.stringout",ZL=(e,t)=>({value:e,rate:t}),IL=(e,t,n)=>({start:ZL(e,n),duration:ZL(t,n)});function DL(e){return e.generated_by===WL}function SY(e){let t=e?.available_range;if(!t)return null;let n=t.start?.value,i=t.duration?.value;return typeof n!="number"||typeof i!="number"||i<=0?null:{start:n,duration:i}}function kY(e,t,n,i){let r=e.source_range,o=SY(t);if(n==="full")return o||(r?{start:r.start.value,duration:r.duration.value}:null);if(!r||!(r.duration.value>0))return null;let a=r.start.value,s=r.duration.value;if(n==="handles"&&i>0){let c=a-i,l=a+s+i;o?(c=Math.max(o.start,c),l=Math.min(o.start+o.duration,l)):c=Math.max(0,c),a=c,s=Math.max(1,l-c)}return{start:a,duration:s}}function TY(e,t,n){let i=new Map;for(let u of e.media_references??[])u.id&&i.set(u.id,u);let r=(e.timelines??[]).filter(u=>!DL(u)),o=r[0],a=o&&o.fps_den?o.fps_num/o.fps_den:24,s=[],c=0,l=0;for(let u of r)for(let f of u.tracks??[])if(f.kind==="Video")for(let d of f.items??[]){if(d.kind!=="clip"||d.enabled===!1)continue;let m=d.media_reference_id?i.get(d.media_reference_id):void 0,p=m?.source_resolution_w,b=m?.source_resolution_h;if(!p||!b||p<=0||b<=0){l++;continue}let h=kY(d,m,t,n);if(!h){c++;continue}let v=d.source_range,g=v?.duration?.rate||v?.start?.rate||m?.available_range?.duration?.rate||a,y=d.pixel_aspect_ratio??m?.source_pixel_aspect??1;s.push({item:d,mrefId:d.media_reference_id??null,w:p,h:b,par:y>0?y:1,start:h.start,duration:h.duration,rate:g,name:d.name,reel:d.reel_name??null})}return{shots:s,fallbackRate:a,noRange:c,noRaster:l}}function zY(e,t){let n=new Set,i=[];for(let r of e){let o=t==="full"?`m:${r.mrefId??r.item.id}`:`m:${r.mrefId??r.item.id}|${r.start}|${r.duration}`;n.has(o)||(n.add(o),i.push(r))}return i}var qL=(e,t)=>{let n=t?.extent??"cut";if(n!=="cut"&&n!=="handles"&&n!=="full")return{summary:`Stringout: unknown extent "${n}"`};let i=n==="handles"?Math.max(0,Math.round(t?.handles??24)):0,r=(t?.name_prefix??"STRINGOUT").trim()||"STRINGOUT",{shots:o,fallbackRate:a,noRange:s,noRaster:c}=TY(e,n,i),l=zY(o,n);if(l.length===0)return{summary:c>0?`Stringout: no clip has a probed resolution to group by (${c} unprobed)`:"Stringout: no clips with a usable range in this session"};let u=new Map;for(let z of l){let k=`${z.w}x${z.h}`,S=u.get(k);S?S.push(z):u.set(k,[z])}let f=[...u.entries()].sort((z,k)=>{let[S,M]=z[0].split("x").map(Number),[L,P]=k[0].split("x").map(Number);return L*P-S*M||L-S||P-M}),d=(e.timelines??[]).filter(z=>!DL(z)),m=d[0]?.fps_num??Math.round(a*1e3),p=d[0]?.fps_den??1e3,b=p?m/p:a,h=0,v=z=>`so-${z}-${++h}`,g=[],y=(e.timelines??[]).length;for(let[,z]of f){let{w:k,h:S,par:M}=z[0],L=v("tl"),P=`${r} ${k}\xD7${S}${M!==1?` PAR ${MY(M)}`:""}`,X=[],R=0;z.forEach((q,Y)=>{X.push({id:v("it"),kind:"clip",item_index:Y,name:q.name,enabled:!0,timeline_range:IL(R,q.duration,b),source_range:IL(q.start,q.duration,q.rate||b),media_reference_id:q.mrefId,reel_name:q.reel,pixel_aspect_ratio:q.par,scale:100,position_x:0,position_y:0,rotation:0,crop_left:0,crop_right:0,crop_top:0,crop_bottom:0,render_base_w:k*q.par,render_base_h:S,render_pos_div_x:1,render_pos_div_y:1,keyframes:[],effects:[]}),R+=q.duration});let I={id:v("tr"),kind:"Video",track_index:0,name:"V1",enabled:!0,items:X};(e.timelines??=[]).push({id:L,name:P,kind:"primary",timeline_index:y++,fps_num:m,fps_den:p,resolution_w:k,resolution_h:S,pixel_aspect_ratio:M,start_frame:0,is_drop_frame:d[0]?.is_drop_frame??!1,duration_frames:R,tracks:[I],markers:[],generated_by:WL}),g.push({id:L,name:P,w:k,h:S,clips:z.length})}let w=o.length-l.length,x=n==="handles"?`handles \xB1${i}f`:n;return{summary:`Strung out ${l.length} clip${l.length===1?"":"s"} into ${g.length} reel${g.length===1?"":"s"} by resolution (${g.map(z=>`${z.w}\xD7${z.h}\xD7${z.clips}`).join(", ")}) \xB7 ${x}`+(w>0?` \xB7 ${w} duplicate${w===1?"":"s"} collapsed`:"")+(c>0?` \xB7 ${c} unprobed skipped`:"")+(s>0?` \xB7 ${s} skipped (no range)`:""),meta:{timelines:g,clips:l.length,extent:n,handles:i,duplicates_collapsed:w,skipped_no_raster:c,skipped_no_range:s}}};function MY(e){return Math.round(e*1e4)/1e4}var OY=["position","scale","rotation"];function f0(e,t){return t.length===0?[e,e]:[Math.min(...t),Math.max(...t)]}var LY={"anchor-or-flip":"flipped or off-centre anchor",nested:"compound clip",retimed:"retimed",cropped:"cropped","mixed-format":"mixed-format conform sizing",revealing:"zooms out or repositions past the frame"};function XY(e,t){let n=new Map;for(let le of e.keyframes??[]){let Se=le.parameter_path??"";if(!OY.some(ut=>Se===ut||Se.startsWith(ut+".")))continue;let Le=n.get(Se)??[];Le.push(le.value),n.set(Se,Le)}let i=le=>{let Se=n.get(le);if(!Se||Se.length===0)return!1;let Le=JSON.stringify(Se[0]);return Se.some(ut=>JSON.stringify(ut)!==Le)},r=[...n.keys()].some(i),o=le=>typeof le=="number"?le:null,a=(le,Se)=>(n.get(le)??[]).map(Le=>Se?Se(Le):o(Le)).filter(Le=>Le!=null),s=[...a("position",le=>Array.isArray(le)?o(le[0]):null),...a("position.x")],c=[...a("position",le=>Array.isArray(le)?o(le[1]):null),...a("position.y")],l=a("scale"),u=a("rotation"),f=e.position_x??0,d=e.position_y??0,m=e.scale??100,p=e.scale_x??null,b=e.scale_y??null,h=e.rotation??0;if(!(r||Math.abs(f)>1e-9||Math.abs(d)>1e-9||Math.abs(m-100)>1e-9||p!=null&&Math.abs(p-m)>1e-9||b!=null&&Math.abs(b-m)>1e-9||Math.abs(h)>1e-9||s.some(le=>Math.abs(le)>1e-9)||c.some(le=>Math.abs(le)>1e-9)||l.some(le=>Math.abs(le-100)>1e-9)||u.some(le=>Math.abs(le)>1e-9)))return{verdict:"none"};let g=Math.abs(e.anchor_x??0)>1e-9||Math.abs(e.anchor_y??0)>1e-9,y=e,w=y.flip_horizontal===!0||y.flip_vertical===!0;if(g||w)return{verdict:"kept",reason:"anchor-or-flip"};if(e.kind==="nested")return{verdict:"kept",reason:"nested"};if(y.speed!=null&&Math.abs(y.speed-100)>1e-9||y.speed_reverse===!0||y.speed_ramped===!0)return{verdict:"kept",reason:"retimed"};if([e.crop_left,e.crop_right,e.crop_top,e.crop_bottom].some(le=>Math.abs(le??0)>1e-9)||(e.keyframes??[]).some(le=>(le.parameter_path??"").startsWith("crop")&&Math.abs(o(le.value)??0)>1e-9))return{verdict:"kept",reason:"cropped"};if(t){let le=t.sourcePar??1;if(Math.abs(le-1)>1e-4)return{verdict:"kept",reason:"mixed-format"};let Se=t.sourceW??0,Le=t.sourceH??0;if(Se>0&&Le>0&&Math.abs(Se/Le-t.frameAr)/t.frameAr>.005)return{verdict:"kept",reason:"mixed-format"}}let z=t?.frameAr??16/9,[k]=f0(m,l),[S,M]=f0(f,s),[L,P]=f0(d,c),[X,R]=f0(h,u),I=Math.max(Math.abs(S),Math.abs(M)),q=Math.max(Math.abs(L),Math.abs(P)),D=Math.max(Math.abs(X),Math.abs(R))*Math.PI/180,j=Math.cos(D)+z*Math.sin(D),C=(p!=null&&l.length===0?p:k)/100,H=(b!=null&&l.length===0?b:k)/100;return C>=j+2*I-1e-6&&H>=j+2*q-1e-6?{verdict:"moves"}:{verdict:"kept",reason:"revealing"}}function NY(e,t){let n=e.timeline_range;if(!n)return!1;let i=n.start.value,r=n.start.value+n.duration.value;return(t.items??[]).some(o=>{if(o.kind!=="transition"||!o.timeline_range)return!1;let a=o.timeline_range.start.value,s=o.timeline_range.start.value+o.timeline_range.duration.value;return a<r&&s>i})}function RY(e,t){let n=new Map((t?.media_references??[]).map(s=>[s.id,s])),i=(e.resolution_w||1920)/(e.resolution_h||1080),r=0,o=0,a={};for(let s of e.tracks??[])if(s.kind==="Video")for(let c of s.items??[]){if(c.kind!=="clip"&&c.kind!=="nested")continue;let l=c.media_reference_id?n.get(c.media_reference_id):void 0,u=XY(c,{frameAr:i,sourceW:l?.source_resolution_w,sourceH:l?.source_resolution_h,sourcePar:l?.source_pixel_aspect,transitionOverlap:NY(c,s)});u.verdict==="moves"?r++:u.verdict==="kept"&&(o++,u.reason&&(a[u.reason]=(a[u.reason]??0)+1))}return{moves:r,kept:o,reasons:a}}var HL=(e,t)=>{let n=t?.surface==="edit"?"edit":"node",i=t?.timeline_id,r=(e.timelines??[]).filter(u=>!i||i==="*"||u.id===i);if(r.length===0)return{summary:"No matching timeline"};let o=0,a=0,s={};for(let u of r){u.sizing_surface=n;let f=RY(u,e);o+=f.moves,a+=f.kept;for(let[d,m]of Object.entries(f.reasons)){let p=d;s[p]=(s[p]??0)+(m??0)}}let c=Object.entries(s).sort((u,f)=>(f[1]??0)-(u[1]??0)).map(([u,f])=>`${f} ${LY[u]}`).join(" \xB7 ");if(n==="edit")return{summary:"Sizing back on the edit page \u2014 the next Resolve export keeps clip transforms in the inspector",meta:{surface:n,moves:o,kept:a,reasons:s,timelines:r.length}};let l=[`${o} clip${o===1?"":"s"} move to the color page in the next Resolve export`];return a>0&&l.push(`${a} stay on the edit page (${c})`),o===0&&a===0&&(l[0]="No clip transforms to move \u2014 the flag is set for anything added later"),{summary:l.join(" \xB7 "),meta:{surface:n,moves:o,kept:a,reasons:s,timelines:r.length}}};var EL=(e,t)=>({value:e,rate:t}),d0=(e,t,n)=>({start:EL(e,n),duration:EL(t,n)});function FY(e){let t=e.streams??[];return t.length?t.some(n=>n.kind==="video"):e.content_kind!=="audio"}function SP(e){let t=e.streams??[];return t.length?t.some(n=>n.kind==="audio"):e.content_kind==="audio"||e.content_kind==="video_audio"}function VY(e){return(e.streams??[]).find(t=>t.kind==="audio")?.channels??null}function CL(e,t,n){let i=[...t.tracks??[]].reverse().find(a=>a.kind===n);if(i)return i;let r=(t.tracks??[]).filter(a=>a.kind===n).length,o={id:Ld(e,"ac-tr"),kind:n,track_index:r,name:`${n==="Video"?"V":"A"}${r+1}`,enabled:!0,items:[]};return(t.tracks??=[]).push(o),o}function PP(e){return e.display_name?e.display_name:(e.target_url??"").split("/").pop()||e.id}var UL=(e,t)=>{let n=(e.timelines??[]).find(S=>S.id===t.timeline_id);if(!n)return{summary:"Add clip: timeline not found"};let i=(e.media_references??[]).find(S=>S.id===t.media_reference_id);if(!i){if(!t.media_reference||t.media_reference.id!==t.media_reference_id)return{summary:"Add clip: media reference not in session and none supplied"};(e.media_references??=[]).push(t.media_reference),i=t.media_reference}let r=n.fps_den?n.fps_num/n.fps_den:24,o=i.available_range,a=o?.duration?.rate||o?.start?.rate||r,s=t.source_start??o?.start?.value??0,c=Math.max(1,Math.round(t.source_duration??o?.duration?.value??r)),l=FY(i),u=!t.without_audio&&SP(i),f=l?"Video":"Audio",d=t.track_id?(n.tracks??[]).find(S=>S.id===t.track_id):null;if(t.track_id&&!d)return{summary:"Add clip: track not found"};if(d&&d.kind!==f)return{summary:`Add clip: ${d.name??d.id} is a ${d.kind} track`};let m=d??CL(e,n,f),p=0;for(let S of m.items??[]){let M=S.timeline_range.start.value+S.timeline_range.duration.value;M>p&&(p=M)}typeof t.at_frame=="number"&&Number.isFinite(t.at_frame)&&(p=Math.max(0,Math.round(t.at_frame)));let b=rs(e,m,p,p+c),h=i.source_pixel_aspect??1,[v,g,y,w]=wP(i.source_resolution_w,i.source_resolution_h,h,n.resolution_w??0,n.resolution_h??0),x=u0(t.fit)?t.fit:u0(n.mismatch_policy)?n.mismatch_policy:"fit",T={id:Ld(e,"ac-it"),kind:"clip",item_index:(m.items??[]).length,name:PP(i),enabled:!0,timeline_range:d0(p,c,r),source_range:d0(s,c,a),media_reference_id:i.id,reel_name:i.reel_name??null,pixel_aspect_ratio:h,scale:100,position_x:0,position_y:0,rotation:0,crop_left:0,crop_right:0,crop_top:0,crop_bottom:0,render_base_w:v,render_base_h:g,render_pos_div_x:y,render_pos_div_y:w,keyframes:[],effects:[]};FL(T,x,i.source_resolution_w,i.source_resolution_h,n.resolution_w??0,n.resolution_h??0),(m.items??=[]).push(T),m.items.sort((S,M)=>S.timeline_range.start.value-M.timeline_range.start.value),fa(m);let z=null;if(u&&l){let S=CL(e,n,"Audio");S.audio_channel_count==null&&(S.audio_channel_count=VY(i)),rs(e,S,p,p+c);let M={id:Ld(e,"ac-it"),kind:"clip",item_index:(S.items??[]).length,name:PP(i),enabled:!0,timeline_range:d0(p,c,r),source_range:d0(s,c,a),media_reference_id:i.id,reel_name:i.reel_name??null,keyframes:[],effects:[]};(S.items??=[]).push(M),S.items.sort((L,P)=>L.timeline_range.start.value-P.timeline_range.start.value),fa(S),z={track:S,item:M}}Ro(n);let k=z?"picture + sound":l?"picture":"sound";return{summary:`Added "${PP(i)}" (${k}) to ${n.name??"timeline"} at ${p}f (${c}f)`+Jl(b),meta:{timeline_id:n.id,track_id:m.id,item_id:T.id,media_reference_id:i.id,at_frame:p,duration_frames:c,ref_added:i===t.media_reference,fit:x,cleared:b,audio_track_id:z?.track.id??null,audio_item_id:z?.item.id??null}}};function jY(e,t){let n=new Set((e.timelines??[]).map(r=>r.id)),i=1;for(;n.has(`${t}-${i}`);)i++;return`${t}-${i}`}function ZY(e){let t=new Set((e.timelines??[]).map(i=>i.name)),n=(e.timelines??[]).length+1;for(;t.has(`Timeline ${n}`);)n++;return`Timeline ${n}`}var AL=(e,t)=>{let n=e.timelines??[];if(t.timeline_id&&n.some(d=>d.id===t.timeline_id))return{summary:`New timeline: id "${t.timeline_id}" is already in the session`};let i=t.timeline_id||jY(e,"nt-tl"),r=t.name||ZY(e),o=n.find(d=>d.kind==="primary")??n[0],a=typeof t.fps_num=="number"&&t.fps_num>0&&typeof t.fps_den=="number"&&t.fps_den>0,s=a?t.fps_num:o?.fps_num??24,c=a?t.fps_den:o?.fps_den??1,l={id:`${i}-v1`,kind:"Video",track_index:0,name:"V1",enabled:!0,items:[]},u={id:i,name:r,kind:"primary",timeline_index:n.length,fps_num:s,fps_den:c,resolution_w:t.resolution_w||o?.resolution_w||1920,resolution_h:t.resolution_h||o?.resolution_h||1080,pixel_aspect_ratio:t.pixel_aspect_ratio??1,start_frame:t.start_frame??0,is_drop_frame:t.is_drop_frame??!1,duration_frames:0,tracks:[l],markers:[],source_element_id:null,raw_extraction:{},metadata:{}};(e.timelines??=[]).push(u);let f=c?s/c:0;return{summary:`New timeline "${r}" \u2014 ${u.resolution_w}\xD7${u.resolution_h} @ ${Number.isInteger(f)?f:f.toFixed(3)}`,meta:{timeline_id:i,track_id:l.id,name:r,fps_num:s,fps_den:c,resolution_w:u.resolution_w,resolution_h:u.resolution_h}}};function IY(e,t){let n=new Set;for(let r of e.timelines??[])for(let o of r.tracks??[])n.add(o.id);let i=1;for(;n.has(`${t}-${i}`);)i++;return`${t}-${i}`}var GL=(e,t)=>{let n=(e.timelines??[]).find(s=>s.id===t.timeline_id);if(!n)return{summary:"Add track: timeline not found"};let i=t.kind??"Video",r=(n.tracks??[]).filter(s=>s.kind===i).length,o=`${i==="Video"?"V":"A"}${r+1}`,a={id:IY(e,"at-tr"),kind:i,track_index:r,name:o,enabled:!0,items:[]};return(n.tracks??=[]).push(a),{summary:`Added ${o} to ${n.name??"timeline"}`,meta:{timeline_id:n.id,track_id:a.id,kind:i,name:o}}};function WY(e){let t=e;return t.finish_ops??=[]}var JL=(e,t)=>{let n,i,r;if(t.timeline_level){let s=(e.timelines??[]).find(c=>c.id===t.timeline_id);if(!s)return{summary:"Finish: timeline not found"};n=s,i=s.name??"timeline",r=s.id}else{if(!t.item_id)return{summary:"Finish: item_id required for a clip-level stack"};let s=Gl(e,t.timeline_id,t.item_id);if(!s)return{summary:"Finish: item not found"};n=s.item,i=s.item.name??"clip",r=s.item.id}let o={id:r},a=WY(n);if(t.entry){let s=a.findIndex(l=>l.id===t.entry.id),c=s>=0;return c?a[s]=t.entry:a.push(t.entry),{summary:`${c?"Updated":"Added"} ${t.entry.label??t.entry.kind} on "${i}"`,meta:{item_id:o.id,entry_id:t.entry.id,upserted:!0}}}if(t.toggle_id){let s=a.find(c=>c.id===t.toggle_id);return s?(s.enabled=!s.enabled,{summary:`${s.enabled?"Enabled":"Bypassed"} ${s.label??s.kind} on "${i}"`,meta:{item_id:o.id,entry_id:s.id,enabled:s.enabled}}):{summary:`Finish: operator not found on "${i}"`}}if(t.remove_id){let s=a.findIndex(l=>l.id===t.remove_id);if(s<0)return{summary:`Finish: operator not found on "${i}"`};let[c]=a.splice(s,1);return{summary:`Removed ${c.label??c.kind} from "${i}"`,meta:{item_id:o.id,entry_id:c.id,removed:!0}}}return{summary:"Finish: nothing to do (no entry / toggle_id / remove_id)"}};var BL=(e,t)=>{let n=(e.timelines??[]).find(s=>s.id===t.timeline_id);if(!n)return{summary:"Delete track: timeline not found"};let i=(n.tracks??[]).findIndex(s=>s.id===t.track_id);if(i<0)return{summary:"Delete track: track not found"};let[r]=n.tracks.splice(i,1),o=0;for(let s of n.tracks)s.kind===r.kind&&(s.track_index=o++);Ro(n);let a=(r.items??[]).filter(s=>s.kind!=="gap").length;return{summary:`Deleted ${r.name??r.kind} (${a} clip${a===1?"":"s"}) from ${n.name??"timeline"}`,meta:{timeline_id:n.id,track_id:r.id,kind:r.kind,clips:a}}};var YL=(e,t)=>{let n=(e.timelines??[]).find(m=>m.id===t.timeline_id);if(!n)return{summary:"Move: timeline not found"};let i,r,o=-1;for(let m of n.tracks??[]){let p=(m.items??[]).findIndex(b=>b.id===t.item_id);if(p>=0){i=m,r=m.items[p],o=p;break}}if(!i||!r)return{summary:"Move: clip not found"};let a=t.to_track_id?(n.tracks??[]).find(m=>m.id===t.to_track_id):i;if(!a)return{summary:"Move: destination track not found"};if(a.kind!==i.kind)return{summary:`Move: can't put a ${i.kind} clip on a ${a.kind} track`};let s=r.timeline_range.start.value,c=r.timeline_range.duration.value,l=typeof t.to_frame=="number"&&Number.isFinite(t.to_frame)?Math.max(0,Math.round(t.to_frame)):s;if(a===i&&l===s)return{summary:"Move: already there"};let u=rs(e,a,l,l+c,r.id);if(a!==i){let m=i.items.findIndex(p=>p.id===r.id);i.items.splice(m>=0?m:o,1),(a.items??=[]).push(r)}r.timeline_range.start.value=l,a.items.sort((m,p)=>m.timeline_range.start.value-p.timeline_range.start.value),fa(i),a!==i&&fa(a),Ro(n);let f=a!==i?` to ${a.name??"track"}`:"",d=l!==s?` to ${l}f`:"";return{summary:`Moved "${r.name??"clip"}"${f}${d}${Jl(u)}`,meta:{timeline_id:n.id,item_id:r.id,from_track_id:i.id,to_track_id:a.id,from_frame:s,to_frame:l,cleared:u}}};var DY=[{label:"23.976",num:24e3,den:1001},{label:"24",num:24,den:1},{label:"25",num:25,den:1},{label:"29.97",num:3e4,den:1001},{label:"30",num:30,den:1},{label:"48",num:48,den:1},{label:"50",num:50,den:1},{label:"59.94",num:6e4,den:1001},{label:"60",num:60,den:1}];function qY(e){let t=0;for(let n of e.tracks??[])t+=(n.items??[]).length;return t}function KL(e,t){if(!(t>0))return"\u2014";let n=DY.find(r=>r.num===e&&r.den===t);if(n)return n.label;let i=e/t;return Number.isInteger(i)?String(i):i.toFixed(3).replace(/0+$/,"").replace(/\.$/,"")}var QL=(e,t)=>{let n=Math.round(Number(t?.fps_num)),i=Math.round(Number(t?.fps_den));if(!Number.isFinite(n)||!Number.isFinite(i)||n<=0||i<=0)return{summary:"Frame rate: must be a positive rational (fps_num / fps_den)"};let r=ua(e,t?.timeline_id);if(!r)return{summary:"Frame rate: timeline not found"};let o=KL(r.fps_num??0,r.fps_den??0),a=KL(n,i);if(r.fps_num===n&&r.fps_den===i)return{summary:`Frame rate: already ${a} fps`};let s=qY(r);return s>0?{summary:`Frame rate: ${r.name??"this timeline"} has ${s} item${s===1?"":"s"} in it \u2014 changing ${o} \u2192 ${a} would move every cut. Set the rate on an empty timeline, or export and re-conform at the new rate.`,meta:{timeline_id:r.id,refused:"populated",items:s}}:(r.fps_num=n,r.fps_den=i,{summary:`Frame rate: ${o} \u2192 ${a} fps`,meta:{timeline_id:r.id,fps_num:n,fps_den:i,was:o}})};var HY=["crop_left","crop_right","crop_top","crop_bottom"],EY={scale:"scale",opacity:"opacity",position_x:"position X",position_y:"position Y",rotation:"rotation",crop_left:"crop L",crop_right:"crop R",crop_top:"crop T",crop_bottom:"crop B"},kP=(e,t,n)=>Math.min(n,Math.max(t,e));function Bl(e){return typeof e=="number"&&Number.isFinite(e)?e:null}var _L=(e,t)=>{let n=Gl(e,t.timeline_id,t.item_id);if(!n)return{summary:"Transform: clip not found"};let i=n.item,r=[],o=(m,p)=>{i[m]!==p&&(i[m]=p,r.push(m))},a=Bl(t.scale);a!=null&&o("scale",kP(a,.01,1e5));let s=Bl(t.opacity);s!=null&&o("opacity",kP(s,0,100));let c=Bl(t.position_x);c!=null&&o("position_x",c);let l=Bl(t.position_y);l!=null&&o("position_y",l);let u=Bl(t.rotation);u!=null&&o("rotation",u);for(let m of HY){let p=Bl(t[m]);p!=null&&o(m,kP(p,0,100))}if(r.length===0)return{summary:"Transform: nothing changed"};let f=i.name??t.item_id;return{summary:`Set ${r.map(m=>EY[m]??m).join(", ")} on "${f}"`,meta:{timeline_id:t.timeline_id,item_id:t.item_id,changed:r}}};var CY=e=>!!e&&typeof e=="object"&&Number.isFinite(e.value)&&Number.isFinite(e.rate)&&e.rate>0,$L=(e,t)=>{let n=e.timelines??[],i=t.timeline_id?n.find(f=>f.id===t.timeline_id):n.length===1?n[0]:n.find(f=>f.kind==="primary");if(!i)return{summary:`Add markers: timeline not found (${t.timeline_id??"no timeline_id"}); timelines: ${n.map(f=>f.id).join(", ")||"none"}`};let r=(i.fps_num??24)/(i.fps_den??1),o=(f,d)=>typeof f=="number"&&Number.isFinite(f)?{value:f,rate:r}:CY(f)?f:f==null&&d?d:null,a=new Set((i.tracks??[]).flatMap(f=>(f.items??[]).map(d=>d.id))),s=new Set((i.markers??[]).map(f=>f.id)),c=[],l=[];(t.markers??[]).forEach((f,d)=>{let m=f??{},p=`marker ${d}${typeof m.name=="string"?` "${m.name}"`:""}`;if(typeof f!="object"||f===null)return void l.push(`${p}: not an object`);let b=o(m.time??m.frame);if(!b)return void l.push(`${p}: time must be timeline frames or {value, rate}, got ${JSON.stringify(m.time??m.frame)}`);if(b.value<0)return void l.push(`${p}: time ${b.value} is before the timeline start`);let h=o(m.duration,{value:1,rate:b.rate});if(!h||h.value<0)return void l.push(`${p}: duration must be frames or {value, rate}, got ${JSON.stringify(m.duration)}`);let v=typeof m.item_id=="string"?m.item_id:null;if(v&&!a.has(v))return void l.push(`${p}: no item ${v} on this timeline`);let g=typeof m.id=="string"&&m.id?m.id:"";if(g&&s.has(g))return void l.push(`${p}: id ${g} already present`);for(let y=(i.markers??[]).length+c.length;!g||s.has(g);y++)g=`marker-${y}`;s.add(g),c.push({kind:null,raw_extraction:{},source_element_id:null,metadata:{},...m,id:g,time:b,duration:h,item_id:v,name:typeof m.name=="string"?m.name:null,note:typeof m.note=="string"?m.note:null,color:typeof m.color=="string"?m.color:null})});let u=l.length?`; dropped ${l.length}: ${l.join("; ")}`:"";return c.length===0?{summary:`Add markers: nothing added${u||" (no markers given)"}`,meta:{added:0,dropped:l}}:(i.markers=[...i.markers??[],...c],{summary:`Added ${c.length} marker(s) to "${i.name}"${u}`,meta:{timeline_id:i.id,added:c.length,dropped:l}})};var Nd={relink:c0,slip:OL,delete:LL,trim:ML,reformat:jL,stringout:qL,node_sizing:HL,add_clip:UL,new_timeline:AL,add_track:GL,finish_op:JL,delete_track:BL,move_clip:YL,timeline_rate:QL,transform:_L,add_markers:$L};function m0(e){return Nd[e]}var UY=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});UY.decode();var TP=new TextEncoder;"encodeInto"in TP||(TP.encodeInto=function(e,t){let n=TP.encode(e);return t.set(n),{read:e.length,written:n.length}});var dbe=new TextEncoder,mbe=new TextDecoder;var pbe=256*1024;var hbe=new Uint8Array(0);var zbe=2*1024*1024,zP=["resolve-otio","resolve-xmeml","flame-fcpxml","flame-archive","resolve-drt","avid-aaf","resolve-aaf","avid-avb","premiere-prproj","premiere-otio","baselight-blscene","finalcut-fcpxmld","protools-aaf","protools-ptx","session_json"],eX=["premiere-prproj","resolve-drt","flame-archive","avid-avb","resolve-xmeml"],tX=["resolve-otio","flame-fcpxml","avid-aaf","resolve-aaf","premiere-otio","session_json"],nX=["baselight-blscene","finalcut-fcpxmld","protools-ptx","protools-aaf"],rX=[];var p0={prproj:"premiere-prproj",otio:"resolve-otio","resolve-xml":"resolve-xmeml",xmeml:"resolve-xmeml",drt:"resolve-drt",fcpxml:"flame-fcpxml",aaf:"avid-aaf",avb:"avid-avb"};function iX(e){return e==="Video"?"V":e==="Audio"?"A":e?.[0]??"T"}function Ei(e,t){let n=e.name?.trim();if(n)return n;let i=GY(e.kind,t),r=i.indexOf(e);return r<0&&e.id&&(r=i.findIndex(o=>o?.id===e.id)),r<0?`${iX(e.kind)}${Math.max(1,Math.abs(e.track_index??0))}`:`${iX(e.kind)}${r+1}`}function GY(e,t){let n=t.filter(o=>o?.kind===e),i=n.length>0&&n.every(o=>(o.track_index??0)<=0),r=o=>i?-(o.track_index??0):o.track_index??0;return[...n].sort((o,a)=>r(o)-r(a))}var JY=["proxy","prx","low","offline","rough","preview","comp","temp","draft","h264","dnxhr","prores"];function Rd(e,t,n,i={}){let r=_Y(i),o=[],a=[],s=[],c=new Map,l=iK(t),u=nK(n.fileExtensions),f=u?l.filter(m=>u.has(tK(m.filename))):l;for(let m of e){let p=[];for(let w of f){let x=$Y(m,w,n,r);if(x.confidence>0){let T=h0(m,w,r);p.push({candidate:w,contains:T.known&&T.contains,confidence:x.confidence,reasons:x.reasons})}else x.refusal&&!c.has(m.id)&&c.set(m.id,{candidate_id:w.id,reason:x.refusal})}if(p.sort((w,x)=>x.confidence-w.confidence),p.length===0){a.push(m.id);continue}let b=p[0].confidence,h=p.filter(w=>b-w.confidence<.05),v=h.filter(w=>w.contains);if(v.length===1&&!h[0].contains){let w=p.indexOf(v[0]);p.splice(w,1),p.unshift(v[0])}let g=p[0],y=p.slice(1).filter(w=>g.confidence-w.confidence<.05&&w.contains===g.contains);y.length>0&&s.push({proxy_id:m.id,candidate_ids:[g,...y].map(w=>w.candidate.id)}),o.push({proxy_id:m.id,candidate_id:g.candidate.id,matched_path:g.candidate.path??g.candidate.filename,confidence:g.confidence,reasons:g.reasons})}if(a.length>0&&o.length>0){let m=new Map(e.map(y=>[y.id,y])),p=new Map(f.map(y=>[y.id,y])),b=new Map;for(let y of f){let w=lc(y.filename).toLowerCase(),x=b.get(w);x?x.push(y):b.set(w,[y])}let h=o.filter(y=>y.confidence>=.5),v=new Set,g=[];for(let y of h){let w=m.get(y.proxy_id),x=p.get(y.candidate_id);if(!w||!x)continue;let T=YY(lc(w.filename),lc(x.filename));T&&v.add(T);let z=w.original_path??w.id,k=KY(z,x.path);k&&g.push(k)}if(v.size>0||g.length>0){let y=[];for(let w of a){let x=m.get(w);if(!x){y.push(w);continue}let T=null,z=null;for(let k of v){let S=(lc(x.filename)+k).toLowerCase(),M=b.get(S);if(M&&M.length>0){T=BY(x,M,r),z=`filename pattern inferred (${k} suffix)`;break}}if(!T&&x.original_path)for(let k of g){let S=QY(x.original_path,k);if(!S)continue;let M=S.toLowerCase();for(let L of f){let P=(L.path??"").replace(/\\/g,"/").toLowerCase();if(P&&P.endsWith(M)){T=L,z="directory proximity";break}}if(T)break}T?o.push({proxy_id:x.id,candidate_id:T.id,matched_path:T.path??T.filename,confidence:.5,reasons:z?[z]:[]}):y.push(w)}a.length=0,a.push(...y)}}let d=a.filter(m=>c.has(m)).map(m=>({proxy_id:m,...c.get(m)}));return{matches:o,unmatched:a,ambiguous:s,refusals:d}}function BY(e,t,n){return t.length===1?t[0]:t.find(r=>h0(e,r,n).contains)??t[0]}function oX(e,t,n,i,r){if(n==null||i==null||t==null)return{known:!1,contains:!1};let o=Yl(n,r);if(o==null)return{known:!1,contains:!1};let a=Yl(e??"00:00:00:00",r)??0;return{known:!0,contains:a<=o&&o+i<=a+t}}function h0(e,t,n){if(e.cut_timecode_start==null||e.cut_duration_frames==null)return{known:!1,contains:!1};let i=e.fps??t.fps??n.timecode_rate,r=t.duration_frames??(t.duration_seconds!=null?Math.round(t.duration_seconds*i):null);return oX(t.timecode_start,r,e.cut_timecode_start,e.cut_duration_frames,i)}function YY(e,t){let n=e.toLowerCase(),i=t.toLowerCase();if(i.length<=n.length||!i.startsWith(n))return null;let r=i.slice(n.length);return!r.startsWith("_")&&!r.startsWith("-")?null:t.slice(e.length)}function KY(e,t){if(!e||!t)return null;let n=e.replace(/\\/g,"/").split("/").filter(Boolean),i=t.replace(/\\/g,"/").split("/").filter(Boolean),r=0;for(;r<n.length&&r<i.length&&n[n.length-1-r].toLowerCase()===i[i.length-1-r].toLowerCase();)r++;return r===0?null:{proxyPrefix:n.slice(0,n.length-r).join("/")}}function QY(e,t){let n=e.replace(/\\/g,"/").replace(/^\/+/,""),i=t.proxyPrefix.replace(/^\/+/,"");return i?n.toLowerCase().startsWith(i.toLowerCase())?n.slice(i.length).replace(/^\/+/,""):null:n}function _Y(e){return{timecode_tolerance_frames:e.timecode_tolerance_frames??1,timecode_rate:e.timecode_rate??24,duration_tolerance_seconds:e.duration_tolerance_seconds??.1,min_name_similarity:e.min_name_similarity??.6,aspect_tolerance:e.aspect_tolerance??.01,fps_tolerance:e.fps_tolerance??.005}}function $Y(e,t,n,i){let r=[],o=0;if(n.fileName)if(n.fileNameMode==="tight"){if(lc(e.filename)!==lc(t.filename))return{confidence:0,reasons:[]};o+=.6,r.push("exact filename")}else{let s=Fd(Fo(e.filename),Fo(t.filename));if(s<i.min_name_similarity)return{confidence:0,reasons:[]};let c=e.cut_timecode_start??e.timecode_start,l=c==null||/^00:00:00[:;]00$/.test(c),u=Fo(e.filename).toLowerCase(),f=Fo(t.filename).toLowerCase(),d=u===f||f.startsWith(u)||u.startsWith(f);if(l&&!d)return{confidence:0,reasons:[],refusal:`filename similarity ${s.toFixed(2)} but no source timecode to confirm a non-exact name \u2014 exact name required`};o+=s*.6,r.push(`filename similarity ${s.toFixed(2)}`)}else o+=.1;let a=$u(e.filename)||$u(t.filename);if(!a)if(e.tc_unrecorded){let s=h0(e,t,i);s.known&&s.contains&&(o+=.2,r.push("cut within source timecode range"))}else{let s=h0(e,t,i);if(s.known)if(s.contains)o+=.2,r.push("cut within source timecode range");else{let c=e.fps??t.fps??i.timecode_rate,l=Yl(e.cut_timecode_start??"00:00:00:00",c)??0,u=Yl(t.timecode_start??"00:00:00:00",c)??0,f=t.duration_frames??(t.duration_seconds!=null?Math.round(t.duration_seconds*c):0);return{confidence:0,reasons:[],refusal:`cut [${l}..${l+(e.cut_duration_frames??0)}] not within linked media ${t.filename} [${u}..${u+f}]`}}else{let c=e.fps??t.fps??i.timecode_rate,l=Yl(e.cut_timecode_start??e.timecode_start??"00:00:00:00",c),u=Yl(t.timecode_start??"00:00:00:00",c),f=e.duration_seconds!=null?Math.round(e.duration_seconds*c):null,d=t.duration_seconds!=null?Math.round(t.duration_seconds*c):null;if(l!=null&&u!=null)if(f!=null&&d!=null)if(Math.max(l,u)<Math.min(l+f,u+d))o+=.2,r.push("source timecode overlaps");else return{confidence:0,reasons:[],refusal:`source timecode [${l}..${l+f}] does not overlap ${t.filename} [${u}..${u+d}]`};else Math.abs(l-u)<=i.timecode_tolerance_frames&&(o+=.2,r.push("source timecode aligned"))}}if(n.reelName){let s=e.reel_name&&t.reel_name&&e.reel_name===t.reel_name,c=s?null:eK(e.reel_sources,t.reel_sources);if(s)o+=.15,r.push("reel name matched");else if(c)o+=.075,r.push(`reel matched (proxy.${c.proxySource} = candidate.${c.candidateSource})`);else if(e.reel_name&&t.reel_name)return{confidence:0,reasons:[]}}if(n.totalDuration&&!a&&e.duration_seconds!=null&&t.duration_seconds!=null){let s=u=>u==null?null:u>=1e3?"sample":"frame",c=s(e.duration_rate),l=s(t.duration_rate);if(c!=null&&l!=null&&c!==l)r.push("duration units differ (frames vs samples) \u2014 not compared");else if(Math.abs(e.duration_seconds-t.duration_seconds)<=i.duration_tolerance_seconds)o+=.1,r.push("duration matches");else return{confidence:0,reasons:[]}}if(n.resolution&&e.resolution_w!=null&&e.resolution_h!=null&&t.resolution_w!=null&&t.resolution_h!=null)if(e.resolution_w===t.resolution_w&&e.resolution_h===t.resolution_h)o+=.05,r.push(`resolution ${t.resolution_w}\xD7${t.resolution_h}`);else return{confidence:0,reasons:[]};if(n.bitDepth&&e.bit_depth!=null&&t.bit_depth!=null)if(e.bit_depth===t.bit_depth)o+=.05,r.push(`${t.bit_depth}-bit`);else return{confidence:0,reasons:[]};if(e.fps!=null&&t.fps!=null&&!$u(e.filename)&&!$u(t.filename)){let s=e.fps;if(Math.abs(t.fps-s)/s<i.fps_tolerance)o+=.05,r.push(`${s} fps`);else return{confidence:0,reasons:[],refusal:`frame rate ${t.fps} does not match the edit's ${s} \u2014 different-rate media is never the same clip`}}if(n.fileFormat&&e.container&&t.container)if(rK(t.container,e.container))o+=.05,r.push(`container ${t.container}`);else return{confidence:0,reasons:[]};if(n.codec&&e.codec&&t.codec)if(aX(t.codec,e.codec))o+=.05,r.push(`codec ${t.codec}`);else return{confidence:0,reasons:[]};return n.mediaUmid&&e.media_umid&&t.media_umid&&e.media_umid===t.media_umid&&(o=Math.max(o,.95),r.push("UMID match")),{confidence:Math.min(o,1),reasons:r}}function lc(e){return e.replace(/\.[^.]+$/,"").toLowerCase()}function Fo(e){let t=lc(e);t=t.replace(/[-_]s\d{3}$/i,""),t=t.replace(/[-_]+v\d+$/i,"");let n=new Set(JY);return t.split(/[-_\s]+/).filter(i=>i&&!n.has(i)).join("_")}function eK(e,t){if(!e||!t)return null;let n=["embedded","project_metadata","parent_folder","filename_pattern"];for(let i of n){let r=e[i];if(r)for(let o of n){let a=t[o];if(a&&r===a)return{proxySource:i,candidateSource:o}}}return null}function Fd(e,t){if(!e||!t)return 0;if(e===t)return 1;if(Math.min(e.length,t.length)>=6&&(e.includes(t)||t.includes(e)))return .8;let i=e.split(/[_\-\s]+/),r=new Set(t.split(/[_\-\s]+/)),o=i.filter(a=>r.has(a));return o.length===0?0:o.length/Math.max(i.length,r.size)}function Yl(e,t){let n=e.match(/^(\d{1,2}):(\d{2}):(\d{2})[:;](\d{2})$/);return n?parseInt(n[1],10)*3600*t+parseInt(n[2],10)*60*t+parseInt(n[3],10)*t+parseInt(n[4],10):null}function tK(e){let t=e.match(/\.([^.]+)$/);return t?t[1].toLowerCase():""}function nK(e){if(!e||!e.trim())return null;let t=e.split(/[,\s]+/).map(n=>n.replace(/^\./,"").toLowerCase()).filter(Boolean);return t.length===0?null:new Set(t)}function rK(e,t){let n=e.toLowerCase(),i=t.toLowerCase();return!!(n===i||i.includes("quicktime")&&(n==="mov"||n==="quicktime")||i.includes("mxf")&&n==="mxf"||i.includes("mp4")&&(n==="mp4"||n==="mpeg-4"))}function aX(e,t){let n=Ts(e),i=Ts(t);if(n&&i)return n===i;let r=e.toLowerCase(),o=t.toLowerCase();return r.includes(o)||o.includes(r)}function iK(e){let t=e.filter(r=>/\.r3d$/i.test(r.filename)),n=e.filter(r=>!/\.r3d$/i.test(r.filename));if(t.length===0)return e;let i=new Map;for(let r of t){let a=`${r.filename.toLowerCase().replace(/_\d{3}\.r3d$/i,"")}|${r.timecode_start??r.id??""}`,s=i.get(a);(!s||r.filename<s.filename)&&i.set(a,r)}return[...n,...i.values()]}function oK(e){return e?e.split(/[/\\]/).pop()??"":""}var aK={fileName:"a file name",timecode:"source timecode",reelName:"a reel name",totalDuration:"duration data",resolution:"resolution data",bitDepth:"bit-depth data",frameRate:"frame-rate data",fileFormat:"container/format data",codec:"codec data",mediaUmid:"a UMID/clip-ID"};function da(e,t){let n=e.length,i=0;for(let r of e)r!=null&&r!==""&&i++;return sX(i,n,t)}function sX(e,t,n){return t===0?{populated:0,total:0,available:!0,unavailable_reason:null}:e===0?{populated:e,total:t,available:!1,unavailable_reason:`No clips in this timeline carry ${aK[n]}.`}:{populated:e,total:t,available:!0,unavailable_reason:null}}function sK(e){let t=e.vendor_metadata??{},n=["umid","media_umid","clip_id","mxf_umid","package_uid","material_package_uid","source_package_uid","mob_id","MobID","avid_mob_id","MasterMobID","SourceMobID","SourceID","media_pool_item_id"];for(let i of n){let r=t[i];if(typeof r=="string"&&r.length>0)return r}return null}function b0(e){for(let t of e.streams??[]){if(t.kind!=="video")continue;if(typeof t.bit_depth=="number")return t.bit_depth;let n=t.codec_specific;if(!n)continue;let i=n.BitDepth??n.bit_depth??n.bits_per_sample;if(typeof i=="number")return i;if(typeof i=="string"&&/^\d+$/.test(i))return parseInt(i,10)}return null}function cX(e){let t=e.length,i=e.map(r=>oK(r.target_url)).filter(r=>r.length>0).length;return{fileName:sX(i,t,"fileName"),timecode:da(e.map(r=>r.source_timecode),"timecode"),reelName:da(e.map(r=>r.reel_name),"reelName"),totalDuration:da(e.map(r=>{let o=r.available_range?.duration;if(o&&o.value!=null&&o.rate)return o.value;let a=r.declared_duration;return a&&a.value!=null&&a.rate?a.value:null}),"totalDuration"),resolution:da(e.map(r=>r.source_resolution_w&&r.source_resolution_h?`${r.source_resolution_w}\xD7${r.source_resolution_h}`:null),"resolution"),bitDepth:da(e.map(r=>b0(r)),"bitDepth"),frameRate:da(e.map(r=>r.source_fps??null),"frameRate"),fileFormat:da(e.map(r=>r.container??null),"fileFormat"),codec:da(e.map(r=>r.codec??null),"codec"),mediaUmid:da(e.map(r=>sK(r)),"mediaUmid")}}function MP(e){let t=g0(e.target_url);return{id:e.id,filename:t,original_path:e.target_url??null,container:e.container??null,codec:e.codec??null,size_bytes:e.size_bytes??null,duration_seconds:e.available_range?.duration?.value?e.available_range.duration.value/(e.available_range.duration.rate??1):e.declared_duration?.value&&e.declared_duration.rate?e.declared_duration.value/e.declared_duration.rate:null,duration_rate:e.available_range?.duration?.rate??e.declared_duration?.rate??null,duration_frames:e.available_range?.duration?.value??(typeof e.vendor_metadata?.frame_count=="number"?e.vendor_metadata.frame_count:null),timecode_start:e.source_timecode??null,reel_name:e.reel_name??null,reel_sources:e.reel_sources,resolution_w:e.source_resolution_w??null,resolution_h:e.source_resolution_h??null,fps:e.source_fps??null,bit_depth:b0(e),media_umid:e.vendor_metadata?.umid??null,facts_origin:e.source_facts_origin??null}}function OP(e){return{...MP(e),path:e.local_path??e.target_url??null}}function LP(e,t){let n=MP(t),i=fX(e,t);i&&(n.cut_timecode_start=i.tcStart,n.cut_duration_frames=i.durFrames);let r=uX(t.source_timecode,t.source_fps??24);return(t.source_facts_origin??"declared")!=="probed"&&(r==null||r===0)&&(n.tc_unrecorded=!0),n}function uX(e,t){if(!e)return null;let n=e.match(/^(\d+):(\d+):(\d+)[:;](\d+)$/);if(!n)return null;let i=Math.round(t)||24;return(+n[1]*3600+ +n[2]*60+ +n[3])*i+ +n[4]}function cK(e,t){let n=Math.round(t)||24,i=Math.max(0,Math.round(e)),r=i%n,o=Math.floor(i/n)%60,a=Math.floor(i/(n*60))%60,s=Math.floor(i/(n*3600))%24,c=l=>String(l).padStart(2,"0");return`${c(s)}:${c(a)}:${c(o)}:${c(r)}`}function fX(e,t){let n=t.source_fps??24,i=uX(t.source_timecode,n);if(i==null)return null;let r=1/0,o=-1/0;for(let a of e.timelines??[])for(let s of a.tracks??[])for(let c of s.items??[])if(c.media_reference_id===t.id&&c.source_range){let l=i+c.source_range.start.value,u=l+(c.source_range.duration?.value??0);l<r&&(r=l),u>o&&(o=u)}return r===1/0?null:{tcStart:cK(r,n),durFrames:Math.max(0,o-r)}}function XP(e,t,n,i=!1){let r=new Map;for(let f of t)r.set(f.id,f);let o=[],a=new Set;for(let f of n){let d=r.get(f.candidate_id);d&&(o.push({ref_id:f.proxy_id,to:{path:d.local_path??d.target_url??"",size_bytes:d.size_bytes??null,resolution_w:d.source_resolution_w??null,resolution_h:d.source_resolution_h??null,codec:d.codec??null,container:d.container??null,fps:d.source_fps??null,bit_depth:b0(d),reel_name:d.reel_name??null,timecode:d.source_timecode??null,recipe:d.recipe??null,frame_count:d.available_range?.duration?.value??null,pixel_aspect:d.source_pixel_aspect??null,bitrate_bps:d.bitrate_bps??null,local_path:d.local_path??null,vendor_metadata:d.vendor_metadata??null,reel_sources:d.reel_sources??null},confidence:f.confidence,reasons:f.reasons}),a.add(d.id))}let s=lK(e)?structuredClone(e):e,l=c0(s,{matches:o}).meta?.applied??[],u=i?(s.media_references??[]).filter(f=>!a.has(f.id)):s.media_references??[];return{session:{...s,media_references:u},applied:l}}function lK(e){return Object.isFrozen(e)||Object.isFrozen(e.media_references??{})||(e.media_references??[]).some(t=>Object.isFrozen(t)||Object.isFrozen(t.metadata??{}))}function g0(e){return e?e.split(/[/\\]/).pop()??"":""}var lX=(e,t)=>`${g0(e)}|${t}`,uK=2;function NP(e,t){let n=new Map,i=new Map;for(let c of t){n.set(lX(c.source_path,c.source_in),c);let l=g0(c.source_path);(i.get(l)??(i.set(l,[]),i.get(l))).push(c)}let r=e.media_references??(e.media_references=[]),o=new Map(r.map(c=>[c.id,c])),a=0,s=0;for(let c of e.timelines??[])for(let l of c.tracks??[])for(let u of l.items??[]){if(!u.media_reference_id)continue;let f=o.get(u.media_reference_id);if(!f){s++;continue}let d=u.source_range?.start?.value??0,m=f.target_url??"",p=n.get(lX(m,d));if(!p&&m&&(p=fK(i.get(g0(m)),d)),!p){s++;continue}let b={...f,id:crypto.randomUUID(),kind:"external",content_kind:f.content_kind??"video",target_url:p.render_path,source_timecode:p.render_start_tc??f.source_timecode,available_range:{start:{value:0,rate:p.rate},duration:{value:p.render_frames,rate:p.rate}}};r.push(b),o.set(b.id,b),u.media_reference_id=b.id;let h=u.source_range?.duration??{value:p.render_frames,rate:p.rate};if(u.source_range={start:{value:p.lead_handle,rate:p.rate},duration:h},p.render_start_frame!=null){let v=u.raw_extraction??(u.raw_extraction={});v.alternateFrame=p.render_start_frame}a++}return{matched:a,unmatched:s}}function fK(e,t){if(!e||e.length===0)return;let n,i=1/0,r=!1;for(let o of e){let a=Math.abs(o.source_in-t);a<i?(i=a,n=o,r=!1):a===i&&(r=!0)}if(!(!n||i>uK||r))return n}var dK=new Set(["mov","mp4","m4v","mxf","avi","mkv","mts","m2ts","webm","r3d","braw","ari","arx","arri","crm","dng","dpx","exr","png","jpg","jpeg","tif","tiff","wav","aif","aiff","psd","tga","bmp","gif","webp","avif"]),mK={...ip,fileName:!0,fileNameMode:"tight"};function dX(e){return{...mK,...e?.file_name!=null?{fileName:e.file_name}:{},...e?.file_name_mode?{fileNameMode:e.file_name_mode}:{},...e?.reel_name!=null?{reelName:e.reel_name}:{},...e?.total_duration!=null?{totalDuration:e.total_duration}:{},...e?.resolution!=null?{resolution:e.resolution}:{},...e?.bit_depth!=null?{bitDepth:e.bit_depth}:{},...e?.file_format!=null?{fileFormat:e.file_format}:{},...e?.codec!=null?{codec:e.codec}:{},...e?.media_umid!=null?{mediaUmid:e.media_umid}:{},...e?.extensions?.length?{fileExtensions:e.extensions.join(",")}:{}}}function mX(e,t){let n=new Map;for(let r of e.timelines)for(let o of r.tracks)for(let a of o.items)a.media_reference_id&&(n.get(a.media_reference_id)??n.set(a.media_reference_id,new Set).get(a.media_reference_id)).add(o.kind);let i=t.ref_ids?new Set(t.ref_ids):null;return(e.media_references??[]).filter(r=>{if(!n.has(r.id)||i&&!i.has(r.id)||!t.reset&&r.binding_state==="linked")return!1;if(t.lane&&t.lane!=="both"){let o=n.get(r.id),a=o.has("Video"),s=o.has("Audio");if(t.lane==="video"&&!a||t.lane==="audio"&&!s)return!1}return!0})}var Vd=e=>e.replace(/\.[^.]+$/,"");async function pX(e,t,n=2e3){let i=t.map(l=>Fo(Vd(ae(l.target_url??l.reel_name??"")).toLowerCase())).filter(Boolean),r=new Set(t.map(l=>ri(ae(l.target_url??""))?.clipBase.toLowerCase()).filter(Boolean)),o=l=>{if(!i.length)return!0;let u=ri(l)?.clipBase.toLowerCase();if(u&&r.has(u))return!0;let f=Fo(Vd(l.toLowerCase()));return!!f&&i.some(d=>Fd(d,f)>=.5)},a=[],s=!1;async function c(l,u){if(u>12||s)return;let f=[];try{for await(let d of zn(l))f.push(d)}catch{return}for(let d of f){if(d.name.startsWith("."))continue;let m=_(l,d.name);if(d.isDirectory){await c(m,u+1);continue}if(!d.isFile)continue;let p=Pr(d.name).slice(1).toLowerCase();if(!(!dK.has(p)||!o(d.name))&&(a.push(m),a.length>=n)){s=!0;return}}}return await c(e,0),{paths:a,capped:s}}async function hX(e,t){let n=t.split(/[/\\]/).filter(Boolean),i=ae(e).toLowerCase(),r=[];for(let o=n.length-2;o>=0;o--)n[o].toLowerCase()===i&&r.push(n.slice(o+1));r.push([n[n.length-1]]);for(let o of r){let a=_(e,...o);try{if((await cn(a)).isFile)return a}catch{}}return null}async function bX(e){let t=[],n=[],i=new Set,r=0;for(let o of e){let a=await Ds(o).catch(()=>[o]);if(!i.has(a[0])){a.forEach(s=>i.add(s));try{let s=await Rn(a[0]);s.id=`cand-${++r}`,s.binding_state="unbound",t.push(s)}catch(s){n.push(`${ae(o)}: ${s.message.slice(0,80)}`),t.push({id:`cand-${++r}`,kind:"external",target_url:a[0],local_path:a[0],reel_name:Vd(ae(a[0])),binding_state:"unbound",streams:[],raw_extraction:{},metadata:{}})}}}return{refs:t,failed:n}}function gX(e,t,n,i,r){let o=t.map(f=>LP(e,f)),a=n.map(OP),s=Rd(o,a,i,r),c=Rd(o,a,{...i,reelName:!1,totalDuration:!1,resolution:!1,bitDepth:!1,fileFormat:!1,codec:!1,mediaUmid:!1,fileNameMode:"loose"},r),l=new Map(n.map(f=>[f.id,f]));return{rows:t.map(f=>{let d=s.matches.find(h=>h.proxy_id===f.id),m=s.ambiguous.find(h=>h.proxy_id===f.id),p=s.refusals?.filter(h=>h.proxy_id===f.id).map(h=>`${ae(l.get(h.candidate_id)?.target_url??h.candidate_id)}: ${h.reason}`).join("; "),b=new Set;for(let h of c.matches)h.proxy_id===f.id&&h.candidate_id!==d?.candidate_id&&b.add(h.candidate_id);for(let h of c.ambiguous)h.proxy_id===f.id&&h.candidate_ids.forEach(v=>v!==d?.candidate_id&&b.add(v));if(m&&m.candidate_ids.forEach(h=>b.add(h)),!d&&!m&&!b.size){let h=Fo(Vd(ae(f.target_url??"")).toLowerCase()),v=n.map(g=>({c:g,s:Fd(h,Fo(Vd(ae(g.target_url??"")).toLowerCase()))})).filter(g=>g.s>=.4).sort((g,y)=>y.s-g.s)[0];v&&b.add(v.c.id)}return{ref_id:f.id,name:ae(f.target_url??f.reel_name??f.id),status:d?"matched":m?"ambiguous":"unmatched",candidate:d?l.get(d.candidate_id):void 0,confidence:d?.confidence??0,reasons:d?.reasons??[],alternatives:[...b].map(h=>l.get(h)).filter(Boolean),refusal:p||void 0}}),result:s,candidates:n,config:i}}function pK(e,t,n,i){let r=a=>a.streams?.find(s=>s.kind==="video");return[["file name",i.fileName,ae(t.target_url??""),ae(n.target_url??"")],["reel",i.reelName,t.reel_name??"\u2014",n.reel_name??"\u2014"],["timecode (cut must be inside)",!0,`${t.source_timecode??"\u2014"}`,`${n.source_timecode??"\u2014"} \xD7 ${n.available_range?.duration?.value??n.declared_duration?.value??"?"} fr`],["fps (must agree)",!0,`${t.source_fps??"\u2014"}`,`${n.source_fps??r(n)?.rate??"\u2014"}`],["duration",i.totalDuration,`${t.declared_duration?.value??"\u2014"} fr`,`${n.available_range?.duration?.value??n.declared_duration?.value??"\u2014"} fr`],["resolution",i.resolution,`${t.source_resolution_w??"\u2014"}x${t.source_resolution_h??"\u2014"}`,`${n.source_resolution_w??r(n)?.width??"\u2014"}x${n.source_resolution_h??r(n)?.height??"\u2014"}`],["bit depth",i.bitDepth,`${r(t)?.bit_depth??"\u2014"}`,`${r(n)?.bit_depth??"\u2014"}`],["format",i.fileFormat,Pr(t.target_url??"").slice(1)||"\u2014",Pr(n.target_url??"").slice(1)||"\u2014"],["codec",i.codec,r(t)?.codec??"\u2014",r(n)?.codec??"\u2014"]].map(([a,s,c,l])=>` ${s?"\u2022":"\xB7"} ${a}: ${c} \u2192 ${l}`)}function vX(e,t,n){let i=n.map(r=>({proxy_id:r.ref_id,candidate_id:r.candidate_id,matched_path:t.candidates.find(o=>o.id===r.candidate_id)?.target_url??"",confidence:1,reasons:["accepted"]}));return XP(e,t.candidates,i,!0)}var yX=wt(),wX=_(yX,"locations.json");async function jd(){try{return JSON.parse(await Tn(wX))}catch{return[]}}async function xX(e){await vt(yX);let t=(await jd()).filter(n=>n!==e);await ln(wX,JSON.stringify([e,...t].slice(0,12)))}function PX(e){let t=e.media_references??[],n=cX(t);return Object.entries(n).map(([i,r])=>`- ${i}: ${r.available?"usable":"not usable"} (${r.populated}/${r.total} populated${r.unavailable_reason?`; ${r.unavailable_reason}`:""})`).join(`
99
+ `)}function SX(e,t,n){let i=[],r=o=>t.rows.filter(a=>a.status===o).length;i.push(`proposal: ${r("matched")} matched, ${r("ambiguous")} ambiguous, ${r("unmatched")} unmatched of ${t.rows.length} in scope; ${t.candidates.length} candidates`);for(let o of t.rows){let a=e.media_references.find(c=>c.id===o.ref_id),s=`- ${o.ref_id} ${o.name}: ${o.status}`;o.candidate&&(s+=` \u2192 ${o.candidate.target_url} (${Math.round(o.confidence*100)}%${o.reasons.length?`; ${o.reasons.join("; ")}`:""})`),o.refusal&&(s+=`
100
+ refused: ${o.refusal}`),o.alternatives.length&&(s+=`
101
+ alternatives: ${o.alternatives.slice(0,4).map(c=>`${c.id} ${ae(c.target_url??"")}`).join(", ")}`),i.push(s),n.compare&&o.candidate&&i.push(...pK(e,a,o.candidate,t.config))}return i.join(`
102
+ `)}var v0=[{id:"resolve",label:"Blackmagic DaVinci Resolve",folder:"DaVinci Resolve",primary:{target:"resolve-drt",label:"Resolve timeline (.drt)",extension:"drt",status:"ready",open:"In Resolve: File > Import > Timeline, choose the .drt."},fallback:{target:"resolve-xmeml",label:"XML for Resolve (.xml)",extension:"xml",status:"ready",open:"In Resolve: File > Import > Timeline, choose the .xml."}},{id:"premiere",label:"Adobe Premiere Pro",folder:"Premiere Pro",primary:{target:"premiere-prproj",label:"Premiere project (.prproj)",extension:"prproj",status:"ready",open:"In Premiere Pro: File > Open Project, choose the .prproj."},fallback:{target:"premiere-xmeml",label:"XML for Premiere (.xml)",extension:"xml",status:"pending",open:"In Premiere Pro: File > Import, choose the .xml."}},{id:"avid",label:"Avid Media Composer",folder:"Media Composer",primary:{target:"avid-avb",label:"Media Composer bin (.avb)",extension:"avb",status:"ready",open:"Copy the .avb into your project folder, then open it from the Project window."},fallback:{target:"avid-aaf",label:"AAF for Media Composer (.aaf)",extension:"aaf",status:"ready",open:"In Media Composer: File > Input > Import, choose the .aaf."}},{id:"flame",label:"Autodesk Flame",folder:"Flame",quality:"Beta",primary:{target:"flame-archive",label:"Flame archive (.hdr + .seg)",extension:"flame-archive.zip",status:"ready",open:"Unzip, then open the .hdr in Project Manager > Archive Browser and restore."},fallback:{target:"flame-xmeml",label:"XML for Flame (.xml)",extension:"xml",status:"pending",open:"In Flame: import the .xml from the MediaHub."}},{id:"finalcut",label:"Apple Final Cut Pro",folder:"Final Cut Pro",quality:"Beta",primary:{target:"finalcut-fcpxmld",label:"Final Cut Pro bundle (.fcpxmld)",extension:"fcpxmld.zip",status:"ready",open:"Unzip, then in Final Cut Pro: File > Import > XML, choose the .fcpxmld."},fallback:null},{id:"baselight",label:"FilmLight Baselight",folder:"Baselight",quality:"Beta",primary:{target:"baselight-blscene",label:"Baselight scene (.blscene)",extension:"blscene",status:"ready",open:"Open the .blscene in Baselight."},fallback:{target:"baselight-xmeml",label:"XML for Baselight (.xml)",extension:"xml",status:"pending",open:"In Baselight: import the .xml as an edit."}},{id:"protools",label:"Avid Pro Tools",folder:"Pro Tools",quality:"Beta",primary:{target:"protools-ptx",label:"Pro Tools session (.ptx)",extension:"ptx",status:"ready",open:"Open the .ptx in Pro Tools."},fallback:{target:"protools-aaf",label:"AAF for Pro Tools (.aaf)",extension:"aaf",status:"ready",open:"In Pro Tools: File > Open Session, choose the .aaf."}}];function y0(e){let t=e.trim().toLowerCase();return v0.find(n=>n.id===t)}function RP(e){return[e.primary,...e.fallback&&e.fallback.status==="ready"?[e.fallback]:[]]}function kX(e,t,n){let i=[];i.push(`${e.label}${n?` \u2014 ${n}`:""}`,"");let r=t.find(a=>a.file.target===e.primary.target),o=e.fallback?t.find(a=>a.file.target===e.fallback.target):void 0;r&&i.push(`1. Open ${r.filename} first.`,` ${e.primary.open}`),e.fallback&&o?i.push("",`2. If ${e.label.replace(/^\S+ /,"")} refuses it, use ${o.filename} instead.`,` ${e.fallback.open}`):e.fallback&&e.fallback.status==="pending"&&i.push("",`${e.fallback.label} is not included yet: its writer is still being built to ${e.label.replace(/^\S+ /,"")}'s own import rules.`);for(let a of t){if(i.push("",`${a.filename} \u2014 ${a.file.label}`),!a.issues.length){i.push(" Everything in the source timeline carried.");continue}i.push(" Not carried / check:");for(let s of a.issues)i.push(` - ${s.message}`)}return i.join(`
103
+ `)+`
104
+ `}var ZV=W4(P7(),1);var dg=["aaf","avb","prproj","drt","fcpxml","xmeml","otio","flame","ptx"];function Bee(e){switch(Pr(e).toLowerCase()){case".aaf":return"aaf";case".avb":return"avb";case".ptx":return"ptx";case".prproj":return"prproj";case".drt":return"drt";case".fcpxml":case".fcpxmld":return"fcpxml";case".xml":return"xmeml";case".otio":return"otio";default:return null}}async function Su(e,t){let n=t??Bee(e);if(!n)throw new Error(`cannot detect timeline format from '${e}' \u2014 pass format explicitly (${dg.join("|")})`);let i,r=null;if(n==="drt"){r=await pr(e);let c=await ZV.default.loadAsync(r),l={};for(let[u,f]of Object.entries(c.files))f.dir||(l[u]=await f.async("string"));i=new TextEncoder().encode(JSON.stringify(l))}else n==="fcpxml"&&e.toLowerCase().endsWith(".fcpxmld")?i=await pr(_(e,"Info.fcpxml")):i=await pr(e);let o=n==="fcpxml"&&e.toLowerCase().endsWith(".fcpxmld")?"Info.fcpxml":ae(e),a=new File([r??i],o),s=JSON.parse(await HO({fmt:n,data:i,file:a}));return s.source_format=n,s.source_filename=ae(e),{session:s,format:n}}function mg(e){return e.fps_den?e.fps_num/e.fps_den:e.fps_num}var IV=e=>e==null?"?":String(Math.round(e*1e3)/1e3);function fg(e,t){return tn(e,mg(t),!!t.is_drop_frame)}async function hs(e){let t=[],n=e.media_references??[];for(let c of e.timelines){let l=mg(c),u=c.start_frame??0;t.push(`timeline ${c.id} "${c.name}" \u2014 ${IV(l)} fps${c.is_drop_frame?" DF":""}, ${c.resolution_w}x${c.resolution_h}, start ${fg(u,c)}, duration ${c.duration_frames} fr (${fg(c.duration_frames??0,c)})${c.kind&&c.kind!=="primary"?` [${c.kind}]`:""}`);let f={},d=0,m=0,p=0,b=[];for(let h of c.tracks){let v=h.items.length,g=h.items.filter(y=>y.kind==="clip").length;b.push(`${Ei(h,c.tracks)}${h.enabled===!1?"(off)":""}:${g}`);for(let y of h.items)f[y.kind]=(f[y.kind]??0)+1,d+=y.effects?.length??0,m+=y.metadata?.conform_flags?.length??0,(y.speed_ramped||y.speed_reverse||y.speed_factor!=null&&y.speed_factor!==1)&&p++}m+=qV(c).length,t.push(` tracks: ${b.join(" ")}`),t.push(` items: ${Object.entries(f).map(([h,v])=>`${v} ${h}`).join(", ")}; ${d} effects, ${p} retimes, ${c.markers?.length??0} markers, ${m} conform flags`)}let i=n.filter(c=>c.binding_state==="linked").length,r=n.filter(c=>c.kind==="missing").length,o=n.filter(c=>c.binding_state!=="linked"&&c.kind!=="generator"),a=o.map(c=>c.local_path||c.target_url).filter(c=>!!c).map(c=>c.startsWith("file://")?decodeURIComponent(new URL(c).pathname):c),s="paths not checked";return a.length&&a.length<=5e3&&(s=`${(await Promise.all(a.map(l=>Nn(l)))).filter(Boolean).length} of ${o.length} on disk at their recorded paths`),t.push(`media: ${n.length} references (${i} linked, ${o.length} not linked yet \u2014 ${o.length?`${s}; timeline_relink probes and links them`:"nothing to link"}${r?`, ${r} missing`:""})`),t.join(`
105
+ `)}function WV(e,t){let n=new Map((e.media_references??[]).map(r=>[r.id,r])),i=[];for(let r of e.timelines)if(!(t&&r.id!==t)){i.push(`# ${r.id} "${r.name}"`);for(let o of r.tracks){i.push(`## track ${o.id} ${o.kind} ${Ei(o,r.tracks)}${o.enabled===!1?" (disabled)":""}`);for(let a of o.items){let s=a.timeline_range.start.value+(r.start_frame??0),c=s+a.timeline_range.duration.value,l=`- ${a.id} [${a.kind}] "${a.name??""}" rec ${fg(s,r)}\u2013${fg(c,r)} (${a.timeline_range.duration.value} fr)`;if(a.source_range){let f=a.media_reference_id?n.get(a.media_reference_id):void 0,d=a.source_range.start.rate||mg(r),m=a.source_range.start.value,p=m+a.source_range.duration.value,b=f?.source_timecode??null,h=f?.source_fps||d,v=b?Kn(b,h):null,g=!!b?.includes(";"),y=w=>v==null?tn(w,d):tn(v+w*h/d,h,g);l+=` src ${y(m)}\u2013${y(p)}${b?` (file TC ${b})`:""}`,f&&(l+=` media ${f.id}${f.reel_name?` reel "${f.reel_name}"`:""}${f.binding_state==="linked"?"":" UNBOUND"}`)}a.speed_factor!=null&&a.speed_factor!==1&&(l+=` speed ${a.speed_factor}${a.speed_reverse?" reverse":""}`),a.speed_ramped&&(l+=" ramped"),a.enabled===!1&&(l+=" DISABLED"),a.effects?.length&&(l+=` effects[${a.effects.map(f=>f.name??f.kind).join(", ")}]`);let u=a.metadata?.conform_flags;u?.length&&(l+=`
106
+ \u2691 ${u.join(`
107
+ \u2691 `)}`),i.push(l)}}}return i.join(`
108
+ `)}function DV(e){let t=new Set;for(let n of e.timelines)for(let i of n.tracks)for(let r of i.items)r.media_reference_id&&t.add(r.media_reference_id);return(e.media_references??[]).map(n=>{let i=n.streams?.find(r=>r.kind==="video");return`- ${n.id} [${n.kind}${n.binding_state==="linked"?", linked":", unbound"}${t.has(n.id)?"":", unused"}] ${n.target_url??"(no path)"}${n.reel_name?` reel "${n.reel_name}"`:""}${n.source_timecode?` TC ${n.source_timecode}`:""}${n.source_resolution_w?` ${n.source_resolution_w}x${n.source_resolution_h}`:""}${n.source_fps?` ${IV(n.source_fps)} fps`:""}${i?.codec?` ${i.codec}`:""}${n.declared_duration?` dur ${n.declared_duration.value} fr`:""}${n.binding_state!=="linked"&&n.coverage_reason?`
109
+ \u26A0 ${n.coverage_reason}`:""}`}).join(`
110
+ `)}function qV(e){return(e.markers??[]).filter(t=>t.kind==="conform_issue").map(t=>({note:t.note??"",frame:Number(t.time?.value??0)}))}function HV(e){let t=[];for(let n of e.timelines){for(let i of n.tracks)for(let r of i.items){let o=r.metadata?.conform_flags;for(let a of o??[])t.push(`- ${n.id}/${r.id} "${r.name??""}": ${a}`)}for(let i of qV(n))t.push(`- ${n.id} @ ${tn(i.frame,mg(n))}: ${i.note}`)}return t.length?t.join(`
111
+ `):"(no conform flags)"}var pg=Object.keys(Nd);function S7(e,t,n){let i=m0(t);if(!i)throw new Error(`unknown operation '${t}'; known: ${pg.join(", ")}`);return i(e,n)}function k7(e){let t=e.trim().toLowerCase(),n=p0[t]??t;if(!zP.includes(n))throw new Error(`unknown target '${e}'; valid: ${zP.filter(i=>!rX.includes(i)).join(", ")} (aliases: ${Object.keys(p0).join(", ")})`);return n}async function T7(e,t,n,i){let r=k7(t),o=await Kb(r,e),a=typeof o.body=="string"?new TextEncoder().encode(o.body):o.body,s=(e.timelines.find(f=>f.kind==="primary")??e.timelines[0])?.name?.trim(),c=s?s.replace(/[\\/:*?"<>|\x00-\x1f]+/g,"_").slice(0,120):"",l=c?o.filenameSuggestion.replace(/^[^.]+/,c):o.filenameSuggestion,u=n;if(!u)u=_(Yn(i),l);else try{(await cn(u)).isDirectory&&(u=_(u,l))}catch{}if(r==="finalcut-fcpxmld"){let f=rp(a),d=u.toLowerCase().endsWith(".fcpxmld.zip")?Yn(u):u.toLowerCase().endsWith(".fcpxmld")?Yn(u):u,m="",p=0;for(let[b,h]of Object.entries(f)){if(b.endsWith("/"))continue;let v=u.toLowerCase().endsWith(".fcpxmld")?_(ae(u),...b.split("/").slice(1)):b,g=_(d,v);await vt(Yn(g)),await or(g,h),m=_(d,v.split("/")[0]),p+=h.byteLength}return{path:m,bytes:p,issues:o.issues??[]}}return await or(u,a),{path:u,bytes:a.byteLength,issues:o.issues??[]}}async function EV(e,t,n,i){let r=y0(t);if(!r)throw new Error(`unknown destination ${t} (one of ${v0.map(l=>l.id).join(", ")})`);let o=_(n??Yn(i),r.folder);await vt(o);let a=[];for(let l of RP(r)){let u=await T7(e,l.target,o,i);a.push({...u,target:l.target})}let s=(e.timelines.find(l=>l.kind==="primary")??e.timelines[0])?.name?.trim(),c=kX(r,a.map(l=>({file:[r.primary,r.fallback].find(u=>u?.target===l.target),filename:ae(l.path),issues:l.issues})),s);return await or(_(o,"README.txt"),new TextEncoder().encode(c)),{folder:o,files:a,pending:r.fallback?.status==="pending"?r.fallback.label:null}}function CV(){return[`read (any of): ${dg.join(", ")} \u2014 .aaf .avb .prproj .drt .fcpxml/.fcpxmld .xml(FCP7/xmeml) .otio, flame archive (pass format=flame)`,`destinations (pick the host; each delivers its native file + fallback): ${v0.map(e=>`${e.id} = ${RP(e).map(t=>t.target).join(" + ")}${e.fallback?.status==="pending"?` (${e.fallback.label} pending)`:""}`).join("; ")}`,`write first-class: ${eX.join(", ")}`,`write beta: ${nX.join(", ")}`,`write deprecated (still available): ${tX.join(", ")}`,`aliases: ${Object.entries(p0).map(([e,t])=>`${e}\u2192${t}`).join(", ")}`,`edit operations: ${pg.join(", ")}`,"Loss report: timeline_write returns per-target capability issues (what the target host cannot carry)."].join(`
112
+ `)}async function UV(e){let t=e.media_references??[],n=t.filter(r=>r.binding_state!=="linked").map(r=>`- ${r.id} ${ae(r.target_url??r.reel_name??"")}: ${r.coverage_reason??"no file matched yet"}`),i=await jd();return["match criteria usable on this timeline:",PX(e),`unresolved (${n.length} of ${t.length}):`,...n.length?n:[" (none)"],`remembered locations: ${i.length?i.join(", "):"(none)"}`].join(`
113
+ `)}async function AV(e,t,n,i){let r=new Map((e.media_references??[]).map(d=>[d.id,d])),o=new Map;for(let d of e.timelines)for(let m of d.tracks)for(let p of m.items)p.kind!=="clip"||!p.media_reference_id||!p.source_range||(o.get(p.media_reference_id)??o.set(p.media_reference_id,[]).get(p.media_reference_id)).push(p);let a=[],s=[],c=[],l=[];for(let[d,m]of o){let p=r.get(d),b=p?.local_path??p?.target_url??null;if(!p||!b){s.push(`${d}: no path`);continue}if(i.only_linked&&p.binding_state!=="linked"){s.push(`${d} ${ae(b)}: not linked (run timeline_relink first, or only_linked=false)`);continue}if(!await Nn(b)){s.push(`${d} ${b}: file not found on this machine`);continue}if(!ra.has(Pr(b).toLowerCase())){s.push(`${d} ${ae(b)}: unsupported container`);continue}try{let h=await vy(b,m,n,t),v=m[0].source_range.start.rate||p.source_fps||24,g=p.source_timecode?Kn(p.source_timecode,v)??0:0;for(let y of h.outputs)if(a.push(y),!(!y.island||(y.part??1)!==1))for(let w of m){let x=w.source_range.start.value;x<y.island.first_frame||x>y.island.last_frame||c.push({source_path:b,source_in:x,render_path:y.path,render_frames:y.island.last_frame-y.island.first_frame+1,lead_handle:x-y.island.first_frame,rate:v,render_start_tc:p.source_timecode?tn(g+y.island.first_frame,v):void 0})}l.push(`- ${ae(b)} \u2192 ${h.outputs.map(y=>`${ae(Yn(y.path))===ae(t)?ae(y.path):`${ae(Yn(y.path))}/${ae(y.path)}`} (${y.island?`${y.island.last_frame-y.island.first_frame+1} fr`:""}${y.part?` part ${y.part}`:""})`).join(", ")}`)}catch(h){s.push(`${d} ${ae(b)}: ${h.message}`)}}let u="";if(i.relink&&c.length){let d=NP(e,c);u=`
114
+ relinked ${d.matched} references to the trims (${d.unmatched} unmatched)`}return{text:[`consolidated ${a.length} output file(s) from ${c.length} source(s) into ${t} with ${n}-frame handles`,...l,...s.length?[`skipped ${s.length}:`,...s.map(d=>` - ${d}`)]:[]].join(`
115
+ `)+u,outputs:a,skipped:s}}async function GV(e,t){let n=Ut("CONFORM_PYTHON")??"python3",i=Fr(new URL("./judge_local.py",import.meta.url)),r=await Mn(n,[i,e,t]),o=r.stderr.trim();if(!r.success)throw new Error(`judge failed: ${o.split(`
116
+ `).slice(-4).join(" | ")}`);let a=JSON.parse(r.stdout.trim().split(`
117
+ `).pop()),s=a.tiers??{},c=[`verdict: ${a.verdict} (${a.source_format} \u2192 ${a.target_format})`,...(a.reasons??[]).map(d=>`- ${d}`),...Object.entries(s).map(([d,m])=>`${d}: ${m?.tally?Object.entries(m.tally).map(([p,b])=>`${p} ${b}`).join(", "):"not run"}${m?.notes?.length?`
118
+ notes: ${m.notes.join("; ")}`:""}`)],l=a.clips_with_issues??[];l.length&&c.push(`clips with issues (${l.length}):`,...l.slice(0,20).map(d=>`- ${d.track??"?"} @${d.rec??"?"} ${d.name??""}: ${d.issues.map(m=>`${m.check}: ${m.reason}`).join("; ").slice(0,300)}`));let u=a.clips?.not_checked??{},f=Object.entries(u).flatMap(([d,m])=>Object.entries(m).map(([p,b])=>`- ${d}: ${b}\xD7 ${p}`));return f.length&&c.push("not checked:",...f),c.join(`
119
+ `)}async function JV(e,t){let n=t.media_root?[t.media_root]:await jd();if(!n.length)throw new Error("no media_root given and no remembered locations \u2014 pass the folder to link from");for(let w of n)try{if(!(await cn(w)).isDirectory)throw 0}catch{throw new Error(`media_root is not a folder on this machine: ${w}`)}let i=mX(e,{ref_ids:t.ref_ids,lane:t.lane,reset:t.reset});if(!i.length)return{session:e,changed:!1,note:"",text:"nothing in scope: every reference in scope is already linked (use reset=true to re-point) or the ids/lane matched nothing"};if(t.reset)for(let w of i)w.binding_state="unbound",delete w.coverage_reason;let r=[],o=!1,a=[];for(let w of n)if(t.gather==="path")for(let x of i){let T=x.local_path??x.target_url??"",z=T?await hX(w,T):null;z?r.push(z):a.push(`${x.id} ${ae(T)}: not at its recorded path under ${w}`)}else{let x=await pX(w,i,t.cap);r.push(...x.paths),o||=x.capped}let{refs:s,failed:c}=await bX([...new Set(r)]);t.remember&&t.media_root&&await xX(t.media_root);let l=dX(t.criteria),u=gX(e,i,s,l,t.tolerances),f=[`scope: ${i.length} reference(s)${t.lane!=="both"?` (${t.lane} lane)`:""}${t.ref_ids?` (zone of ${t.ref_ids.length})`:""}; gather=${t.gather} under ${n.join(", ")}: ${s.length} candidate clip(s)${o?` (CAPPED at ${t.cap} \u2014 narrow the folder)`:""}`,`criteria: ${Object.entries(l).filter(([,w])=>w===!0).map(([w])=>w).join(", ")}${l.fileName?` (${l.fileNameMode})`:""}${l.fileExtensions?`; ext ${l.fileExtensions}`:""}; timecode containment + fps always on`,...c.length?[`could not probe ${c.length}: ${c.slice(0,5).join("; ")}`]:[],...a.slice(0,20)];if(t.dry_run)return{session:e,changed:!1,note:"",text:[...f,SX(e,u,{compare:t.compare}),"(dry run \u2014 nothing changed; pass accept=[{ref_id,candidate_id}] to commit chosen rows, or run again without dry_run to apply every matched row)"].join(`
120
+ `)};let d,m=[];if(t.accept?.length){d=[];for(let w of t.accept){let x=u.rows.find(z=>z.ref_id===w.ref_id);x&&(x.candidate?.id===w.candidate_id||x.alternatives.some(z=>z.id===w.candidate_id))?d.push(w):m.push(`${w.ref_id} \u2192 ${w.candidate_id}: not a proposed match or alternative for that reference`)}}else d=u.rows.filter(w=>w.status==="matched"&&w.candidate).map(w=>({ref_id:w.ref_id,candidate_id:w.candidate.id}));let p=vX(e,u,d),b=p.session.media_references??[],h=b.filter(w=>i.some(x=>x.id===w.id)&&w.binding_state==="linked").length,v=p.applied,g=b.filter(w=>i.some(x=>x.id===w.id)&&w.binding_state!=="linked").map(w=>` - ${w.id} ${ae(w.target_url??"")}: ${w.coverage_reason??(u.rows.find(x=>x.ref_id===w.id)?.status==="ambiguous"?"ambiguous \u2014 pick one with accept":"no file matched")}`),y=[...f,`Linked ${h} of ${i.length}${m.length?`; ${m.length} pick(s) vetoed`:""}`,...v.map(w=>`- ${w.ref_id}: ${ae(w.before.path??"?")} \u2192 ${w.after.path}${w.warning?` \u26A0 ${w.warning}`:""}`),...m.map(w=>` \u2717 ${w}`),...g.length?["unresolved:",...g]:[]].join(`
121
+ `);return{session:p.session,changed:!0,note:`relink ${t.gather} ${n[0]} (${h}/${i.length})`,text:y}}function BV(e,t){let n=e.time??e.timeline_range?.start;if(!n||!Number.isFinite(n.value))return null;let i=n.rate&&n.rate>0?n.rate:t;return Math.round(n.value*(t/i))}function YV(e,t){let n=e.duration??e.timeline_range?.duration;if(!n||!Number.isFinite(n.value))return 1;let i=n.rate&&n.rate>0?n.rate:t;return Math.max(1,Math.round(n.value*(t/i)))}function gm(e){let t=(e.timelines??[]).filter(n=>n.kind==="primary");return t.length?t:e.timelines??[]}function KV(e,t){if(t.media_reference_id)return(e.media_references??[]).find(n=>n.id===t.media_reference_id)}function QV(e){if(e.fps_num&&e.fps_den)return e.fps_num/e.fps_den;for(let t of e.tracks??[])for(let n of t.items??[]){let i=n.timeline_range?.start?.rate;if(i&&i>0)return i}return 24}function Yee(e){let t=e?.duration?.value,n=e?.duration?.rate;if(!t||!n)return"n/a";let i=a=>String(a).padStart(2,"0");if(n>=1e3){let a=t/n,s=Math.round((a-Math.floor(a))*1e3);return`${i(Math.floor(a/3600))}:${i(Math.floor(a/60)%60)}:${i(Math.floor(a)%60)}.${String(s).padStart(3,"0")}`}let r=Math.round(n)||24,o=Math.max(0,Math.round(t));return`${i(Math.floor(o/r/3600))}:${i(Math.floor(o/r/60)%60)}:${i(Math.floor(o/r)%60)}:${i(o%r)}`}function Kee(e){return String(Math.round(e*1e3)/1e3).replace(/\.0+$/,"")}function _V(e){for(let t of e?.streams??[])if(t.kind==="video"&&t.bit_depth!=null)return t.bit_depth;return null}var z7=[{label:"Start TC",criterion:"timecode",standing:!0,get:e=>e?.source_timecode||"00:00:00:00",has:e=>!!e?.source_timecode},{label:"Reel",criterion:"reelName",get:e=>e?.reel_name||"n/a",has:e=>!!e?.reel_name},{label:"Duration",criterion:"totalDuration",get:e=>Yee(e?.available_range?.duration?.value?e.available_range:e?.declared_duration?{duration:e.declared_duration}:null),has:e=>(e?.available_range?.duration?.value??0)>0||(e?.declared_duration?.value??0)>0},{label:"Resolution",criterion:"resolution",get:e=>e?.source_resolution_w&&e?.source_resolution_h?`${e.source_resolution_w}\xD7${e.source_resolution_h}`:"n/a",has:e=>!!(e?.source_resolution_w&&e?.source_resolution_h)},{label:"Bit depth",criterion:"bitDepth",get:e=>{let t=_V(e);return t!=null?`${t}-bit`:"n/a"},has:e=>_V(e)!=null},{label:"Frame rate",criterion:"frameRate",standing:!0,get:e=>e?.source_fps!=null?Kee(e.source_fps):"n/a",has:e=>e?.source_fps!=null},{label:"Format",criterion:"fileFormat",get:e=>e?.container||"n/a",has:e=>!!e?.container},{label:"Codec",criterion:"codec",get:e=>e?.codec||"n/a",has:e=>!!e?.codec}],$V=z7.map(e=>e.label);var ej=["#","name","track","timeline","kind","item_index","enabled","timeline_range.start","timeline_range.dur","source_range.start","source_range.dur","media_reference_id","source_element_id","reel_name","source_timecode","nested_timeline_id","is_nested","is_multicam","is_reinterpreted","speed","speed_ramped","speed_reverse","scale","scale_x","scale_y","position_x","position_y","rotation","anchor_x","anchor_y","crop_left","crop_right","crop_top","crop_bottom","opacity","blend_mode","keyframes","effects",...$V];function Qee(e){if(!e||typeof e!="object")return!1;let t=e,n=t.start,i=t.duration;return!!n&&!!i&&typeof n.value=="number"&&typeof i.value=="number"}function nj(e,t,n){for(let[i,r]of Object.entries(t)){let o=e?`${e}.${i}`:i;if(r==null)n[o]=null;else if(typeof r=="string"||typeof r=="number"||typeof r=="boolean")n[o]=r;else if(Qee(r))n[`${o}.start`]=Math.round(r.start.value),n[`${o}.dur`]=Math.round(r.duration.value);else if(Array.isArray(r))n[o]=r.length?`[${r.length}]`:null;else if(typeof r=="object"){let a=JSON.stringify(r);n[o]=a==="{}"?null:a}}}function rj(e){let t=[],n=new Set,i=[],r=s=>{n.has(s)||(n.add(s),i.push(s))},o=0;for(let s of gm(e))for(let c of s.tracks??[])for(let l of c.items??[]){if(l.kind==="gap")continue;let u={};u["#"]=++o,u.timeline=s.name,u.track=Ei(c,s.tracks??[]),nj("",l,u);let f=KV(e,l);for(let d of z7){let m=f?d.get(f):null;u[d.label]=m==="n/a"?null:m}u.binding_state=f?f.binding_state??"unbound":null;for(let d of Object.keys(u))r(d);t.push({id:l.id,item:l,cells:u})}return{columns:[...ej,...i.filter(s=>!ej.includes(s))],rows:t}}var tj=["name","binding_state","usage","origin","content_kind","kind","target_url","local_path","reel_name","reel_sources","source_timecode","available_range.start","available_range.dur","source_resolution_w","source_resolution_h","source_pixel_aspect","source_fps","container","codec","size_bytes","bitrate_bps","streams","display_name","file_modified_at","keykode","vendor_metadata","bundle","recipe","raw_extraction","metadata"];function ij(e){let t=[],n=new Set,i=[],r=a=>{n.has(a)||(n.add(a),i.push(a))};for(let a of e){let s={};s.name=a.name,s.origin=a.origin,a.ref&&nj("",a.ref,s),a.extra&&Object.assign(s,a.extra);for(let c of Object.keys(s))r(c);t.push({id:a.id,name:a.name,ref:a.ref,origin:a.origin,cells:s})}return{columns:[...tj,...i.filter(a=>!tj.includes(a))],rows:t}}var _ee={name:"Name",origin:"Origin",usage:"Usage",id:"ID",binding_state:"State",content_kind:"Kind",target_url:"Path",reel_name:"Reel",source_timecode:"Start TC",source_resolution_w:"Source W",source_resolution_h:"Source H",source_pixel_aspect:"PAR",source_fps:"FPS",size_bytes:"Size",codec:"Codec",container:"Format",declared_duration:"Declared",available_range:"Range",source_facts_origin:"Facts",coverage_reason:"Coverage",display_name:"Display name"};function hg(e){let t=_ee[e];return t||e.split(".").map(n=>n.replace(/_/g," ").replace(/^./,i=>i.toUpperCase())).join(" \xB7 ")}var $ee=/^[-+]?(\d+\.?\d*|\.\d+)([eE][-+]?\d+)?$/,kc="[-+]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][-+]?\\d+)?";function Tc(e){let t=e.trim();if(!$ee.test(t))return null;let n=Number(t);return Number.isFinite(n)?n:null}function ete(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e!="string")return null;let t=Tc(e);if(t!==null)return t;let n=e.trim().match(new RegExp(`^(${kc})\\s*[a-zA-Z%\xB0\xD7]*$`));if(!n)return null;let i=Number(n[1]);return Number.isFinite(i)?i:null}function oj(e){let t=e.trim(),n=t.indexOf(".");if(n===-1||/[eE]/.test(t))return 1e-4;let i=t.length-n-1;return Math.max(1e-4,.5*Math.pow(10,-(i+1)))}function ku(e){let t=e.trim();if(!t||t.includes("...."))return null;let i=t.match(new RegExp(`^between\\s+(${kc})\\s+and\\s+(${kc})$`,"i"))??t.match(new RegExp(`^(${kc})\\s*(?:\\.\\.\\.?|,,|\\s+to\\s+|-)\\s*(${kc})$`,"i"));if(i){let s=Tc(i[1]),c=Tc(i[2]);return s===null||c===null?null:{op:"range",value:Math.min(s,c),high:Math.max(s,c)}}let r=t.match(new RegExp(`^(?:in\\s+)?(${kc}(?:\\s*[,|]\\s*${kc})+)$`,"i"));if(r){let s=r[1].split(/\s*[,|]\s*/).map(Tc);if(s.some(l=>l===null))return null;let c=s;return{op:"in",value:c[0],values:c,tolerance:1e-4}}let o=t.match(/^(>=|<=|!=|==|=|>|<)\s*(.+)$/);if(o){let s=Tc(o[2]);return s===null?null:{op:o[1]==="=="?"=":o[1],value:s,tolerance:oj(o[2])}}let a=Tc(t);return a!==null?{op:"=",value:a,tolerance:oj(t)}:null}function tte(e){let t=e.trim();if(!t)return null;let n=ku(t);if(n)return[n];let i=t.split(/(?:\s*(?:,|&|\band\b)\s*|\s+)(?=(?:>=|<=|!=|==|=|>|<))/i).map(o=>o.trim().replace(/(?:\s*(?:,|&|\band))+$/i,"").trim()).filter(Boolean);if(i.length<2)return null;let r=i.map(ku);return r.some(o=>o===null)?null:r}function nte(e,t,n){if(!Number.isFinite(e))return!1;let i=n??t.tolerance??1e-6;switch(t.op){case"=":return Math.abs(e-t.value)<=i;case"!=":return Math.abs(e-t.value)>i;case">":return e>t.value;case"<":return e<t.value;case">=":return e>=t.value-i;case"<=":return e<=t.value+i;case"range":return e>=t.value-i&&e<=(t.high??t.value)+i;case"in":return(t.values??[t.value]).some(r=>Math.abs(e-r)<=i);default:return!1}}function M7(e,t=0){if(t>4||e===null||e===void 0)return[];let n=ete(e);return n!==null?[n]:Array.isArray(e)?e.flatMap(i=>M7(i,t+1)):typeof e=="object"?Object.values(e).flatMap(i=>M7(i,t+1)):[]}function Tu(e,t,n="="){let i=tte(t);if(!i)return!1;let r=M7(e);if(r.length===0)return!1;let o=Tc(t)!==null,a=i.map(s=>o&&n!=="="?{...s,op:n}:s);return r.some(s=>a.every(c=>nte(s,c)))}var aj="Key > value \xB7 Key = value \xB7 Key ~ text \xB7 Key (exists)",sj=">1.2 \xB7 <0.5 \xB7 =62.5 \xB7 !=0 \xB7 1..2 \xB7 61-64 \xB7 >61 <64 \xB7 in 5,6,8";var rte=/^is:(.*)$/,ite=/^([A-Za-z_][\w. -]*?)\s*(>=|<=|!=|=|>|<|:)\s*(.*)$/s,cj=/^\/(.*)\/([a-z]*)$/s,O7=e=>e.toLowerCase().replace(/[^a-z0-9]/g,"");function N7(e){return e.match(/[^\s"]*(?::|=)in\s+[^\s"]+|(?:[^\s"]+|"[^"]*")+/gi)??[]}function uj(e){return/^".*"$/s.test(e)?e.slice(1,-1):null}function ote(e,t){let n=O7(t);if(!n)return[];let i=Object.keys(e.cells),r=i.filter(a=>O7(a)===n);return(r.length?r:i.filter(a=>O7(a).includes(n))).map(a=>e.cells[a])}var ate=e=>e==null?null:String(e);function L7(e,t,n){let i=ate(e),r=uj(n.trim());if(r!=null)return i==null?!1:t==="="?i.toLowerCase()===r.toLowerCase():t==="!="?i.toLowerCase()!==r.toLowerCase():i.toLowerCase().includes(r.toLowerCase());let o=n.trim(),a=/^in\s+(.+)$/is.exec(o);if(a&&(t===":"||t==="="))return a[1].split(/\s*[,|]\s*/).some(c=>c!==""&&L7(e,"=",c));if(!o)return i!=null&&i!==""&&i!=="n/a";if(o.includes("|")&&!cj.test(o))return o.split("|").some(c=>c.trim()&&L7(e,t,c));let s=cj.exec(o);if(s){if(i==null)return!1;try{return new RegExp(s[1],s[2]||"i").test(i)}catch{return!1}}if(t===":"){let c=ku(o);return c&&!/^[-+]?[\d.]+$/.test(o)?Tu(e,o):c!=null&&Tu(e,o)||i!=null&&i.toLowerCase().includes(o.toLowerCase())}if(ku(o)&&t!=="="&&t!=="!=")return Tu(e,t+o);if(t==="="||t==="!="){let c=ku(o)?Tu(e,o):i!=null&&i.toLowerCase()===o.toLowerCase();return t==="="?c:!c}return Tu(e,t+o)}function X7(e,t,n){let i=uj(t);if(i!=null)return lj(e,i);let r=rte.exec(t);if(r){let a=n[r[1].toLowerCase()];return a?a(e):!1}let o=ite.exec(t);if(o){let a=ote(e,o[1]);return a.length?a.some(s=>L7(s,o[2],o[3])):!1}return t.includes("|")?t.split("|").some(a=>a.trim()&&X7(e,a.trim(),n)):lj(e,t)}function lj(e,t){let n=t.toLowerCase();return Object.values(e.cells).some(i=>i!=null&&String(i).toLowerCase().includes(n))}function fj(e,t,n={}){let i=t.trim();if(!i)return!0;let r=Object.fromEntries(Object.entries(n).map(([o,a])=>[o.toLowerCase(),a]));return N7(i).every(o=>{let a=o.startsWith("-")||o.startsWith("!"),s=a?o.slice(1):o;if(!s)return X7(e,o,r);let c=X7(e,s,r);return a?!c:c})}function dj(e){return Object.keys(e).sort()}var mj={offline:e=>e.cells.binding_state!=null&&e.cells.binding_state!=="linked"},pj={unused:e=>Number(e.cells.usage??0)===0,offline:e=>e.cells.binding_state!=="linked",linked:e=>e.cells.binding_state==="linked"};function hj(e){let t=new Map;for(let n of e?.timelines??[])for(let i of n?.tracks??[])for(let r of i?.items??[]){let o=r?.media_reference_id;!o||r.kind==="gap"||t.set(o,(t.get(o)??0)+1)}return t}function ste(e){return(typeof e.display_name=="string"?e.display_name:"")||e.target_url&&e.target_url.split(/[\\/]/).pop()||e.id}function bj(e,t={}){let n=hj(e),i=t.idPrefix??"mr:";return(e?.media_references??[]).flatMap(r=>{let o=ste(r);return t.skip?.(o)?[]:[{id:`${i}${r.id}`,name:o,ref:r,origin:"from timeline",extra:{usage:n.get(r.id)??0}}]})}function gj(e){return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function cte(e){return e==null?"":String(e)}function bg(e,t){let n=e.map(r=>gj(r.header)).join(","),i=t.map(r=>e.map(o=>gj(cte(o.value(r)))).join(","));return[n,...i].join(`
122
+ `)}var lte=["Blue","Cyan","Green","Yellow","Red","Pink","Purple","Fuchsia","Rose","Lavender","Sky","Mint","Lemon","Sand","Cocoa","Cream"];function vj(e,t){let n=QV(e),i=Jc(n,!!e.is_drop_frame),r=e.start_frame??0,o=new Map,a=(e.tracks??[]).filter(l=>l.kind==="Video")[0];for(let l of e.tracks??[])for(let u of l.items??[])o.set(u.id,{name:u.name??u.id});let s=l=>{for(let u of a?.items??[]){let f=u.timeline_range?.start?.value??0,d=u.timeline_range?.duration?.value??0;if(l>=f&&l<f+d)return u.name??u.id}return""},c=[];return(e.markers??[]).forEach((l,u)=>{let f=BV(l,n);if(f==null)return;let d=YV(l,n),m=l.id??`marker-${u}`,p=l.item_id&&o.get(l.item_id)?.name||s(f),b={id:m,marker:l,frame:f,tc:zi(r+f,n,i),duration:d,durationTc:d>1?zi(d,n,!1).replace(/^00:/,""):"",color:l.color??"",name:l.name??"",note:l.note??l.comment??"",clip:p,cells:{}};b.cells={tc:b.tc,frame:f,color:b.color,name:b.name,note:b.note,duration:b.durationTc,clip:p},c.push(b)}),c.sort((l,u)=>l.frame-u.frame)}var yj={...Object.fromEntries(lte.map(e=>[e.toLowerCase(),t=>t.color.toLowerCase()===e.toLowerCase()])),duration:e=>e.duration>1};function wj(e){return bg([{header:"Record TC",value:n=>n.tc},{header:"Source TC",value:()=>""},{header:"Frame",value:n=>n.frame},{header:"Color",value:n=>n.color},{header:"Source",value:n=>n.marker.item_id?"clip":"timeline"},{header:"Clip Name",value:n=>n.clip},{header:"Name",value:n=>n.name},{header:"Note",value:n=>n.note},{header:"Duration",value:n=>n.duration},{header:"Keywords",value:()=>""},{header:"Custom Data",value:n=>n.marker.metadata?JSON.stringify(n.marker.metadata):""}],e)}function xj(e,t){let n=e.map(i=>({header:hg(i),value:r=>{let o=r.cells[i];return o==null?"":typeof o=="boolean"?o?"true":"false":o}}));return bg(n,[...t])}function Pj(e,t,n=new Date){let i=n.toISOString().slice(0,16).replace(/[-:T]/g,""),r=o=>o.replace(/[^a-zA-Z0-9_-]/g,"_");return`${i}_${r(e)}_${r(t)}.csv`}var Sj=["clips","media","markers"],ute={clips:["#","timeline","track","name","timeline_range.start","timeline_range.dur","rec_in_tc","rec_out_tc","source_range.start","reel_name","speed","binding_state"],media:["name","binding_state","usage","codec","source_resolution_w","source_resolution_h","source_fps","source_timecode","target_url"],markers:["timeline","tc","color","name","note","duration","clip"]},R7=`Terms are separated by spaces and ALL must match; a leading - negates a term. text = in any column; field:text = in that column (field:/regex/, field:"two words", field:a|b); numbers: ${sj} (e.g. speed!=100, crop:1..2, track:in V5,V6 \u2014 whole-cell membership); field: alone = has a value; clips: overlaps:A..B = clips whose RECORD range touches A..B inclusive (record TC like 01:00:10:00, or timeline frames; overlaps:A alone = clips under that frame) \u2014 unlike timeline_range.start:A..B, which only asks where a clip starts. is:<lens> = a named question (clips: is:offline; media: is:unused, is:offline, is:linked; markers: is:<colour>, is:duration). An unknown field or lens matches nothing.`,fte=/^([-!]?)overlaps?:(.+)$/i;function dte(e){let t=[];return{rest:N7(e).filter(i=>{let r=fte.exec(i);if(!r)return!0;let[o,a=o]=r[2].split(/\.\.\.?|-(?=\d)/);return t.push(s=>{if(!s.item||!s.tl)return!1;let c=s.tl.fps_den?s.tl.fps_num/s.tl.fps_den:s.tl.fps_num,l=tn(s.tl.start_frame??0,c,!!s.tl.is_drop_frame),u,f;try{u=Jr(o,c,l),f=Jr(a,c,l)}catch{return!1}u>f&&([u,f]=[f,u]);let d=s.item.timeline_range.start.value,m=d+s.item.timeline_range.duration.value,p=d<=f&&m>u;return r[1]?!p:p}),!1}).join(" "),tests:t}}function mte(e,t,n){let i=e,r=gm(i).filter(a=>!n||a.id===n);if(n&&!r.length){let a=gm(i).map(s=>`${s.id} "${s.name}"`).join(", ");throw new ze("not_found",`no timeline ${n} in this session (timelines: ${a||"none"})`)}if(t==="clips"){let a=new Set(r.map(f=>f.id)),s=new Map;for(let f of e.timelines){if(!a.has(f.id))continue;let d=f.fps_den?f.fps_num/f.fps_den:f.fps_num,m=p=>tn(p+(f.start_frame??0),d,!!f.is_drop_frame);for(let p of f.tracks??[])for(let b of p.items??[]){let h=b.timeline_range.start.value,v=h+b.timeline_range.duration.value;s.set(b.id,{tl:f,cells:{track_name:p.name??null,track_enabled:p.enabled!==!1,rec_in_tc:m(h),rec_out_tc:m(v)}})}}let c=rj(i),l=c.rows.filter(f=>s.has(f.id)).map(f=>({...f,tl:s.get(f.id).tl,cells:{...f.cells,...s.get(f.id).cells}})),u=[...c.columns];return u.splice(u.indexOf("track")+1,0,"track_name","track_enabled"),u.splice(u.indexOf("timeline_range.dur")+1,0,"rec_in_tc","rec_out_tc"),{rows:l,columns:u,lenses:mj}}if(t==="media"){let a=ij(bj(i));return{rows:a.rows,columns:a.columns,lenses:pj}}return{rows:r.flatMap(a=>vj(a,i).map(s=>({...s,id:`${a.id}:${s.id}`,cells:{timeline:a.name,...s.cells}}))),columns:["timeline","tc","frame","color","name","note","duration","clip"],lenses:yj}}function pte(e,t,n){if(!e?.length)return ute[t].filter(a=>n.includes(a));let i=a=>a.toLowerCase().replace(/[^a-z0-9]/g,""),r=[],o=[];for(let a of e){let s=n.find(c=>c===a)??n.find(c=>i(c)===i(a)||i(hg(c))===i(a));s?r.push(s):o.push(a)}if(o.length)throw new ze("invalid_args",`unknown column${o.length>1?"s":""} ${o.join(", ")} for ${t} (columns: ${n.slice(0,60).join(", ")}${n.length>60?", \u2026":""})`,{available:n});return r}function kj(e,t){let{rows:n,columns:i,lenses:r}=mte(e,t.table,t.timeline_id),o=pte(t.columns,t.table,i),{rest:a,tests:s}=dte(t.query?.trim()??""),c=n.filter(u=>s.every(f=>f(u))&&(!a||fj(u,a,r))),l={table:t.table,columns:o,available:i,lenses:dj(r),total:n.length,matched:c.length,rows:c.map(u=>({id:u.id,cells:Object.fromEntries(o.map(f=>[f,u.cells[f]??null]))}))};return t.csv&&(l.csv=t.table==="markers"&&!t.columns?.length?wj(c):xj(o,c)),l}async function Tj(e,t,n){let i=e.table==="clips"?"Edit_Index":e.table==="media"?"Media":"Markers",r=await Wi(t)?_(t,Pj(n,i)):t;return await ln(r,e.csv??""),r}function zj(e,t,n){let i=`${e.table}: ${e.matched} of ${e.total} row${e.total===1?"":"s"}${t?` match "${t}"`:""}`;if(!e.matched)return`${i}
123
+ lenses: ${e.lenses.map(f=>`is:${f}`).join(" ")||"(none)"}
124
+ columns: ${e.available.slice(0,40).join(", ")}${e.available.length>40?", \u2026":""}
125
+ grammar: ${R7}
126
+ field queries: ${aj}`;let r=e.rows.slice(0,n),o=f=>(f==null?"":String(f)).replace(/\s+/g," ").slice(0,60),a=e.columns.map(f=>Math.min(60,Math.max(f.length,...r.map(d=>o(d.cells[f]).length)))),s=f=>f.map((d,m)=>d.padEnd(a[m])).join(" ").trimEnd(),c=[s(e.columns),...r.map(f=>s(e.columns.map(d=>o(f.cells[d]))))],l=e.matched>r.length?`TRUNCATED: showing ${r.length} of ${e.matched} matching rows \u2014 NOT the full list. Pass limit=${Math.min(e.matched,5e3)}, narrow the query, or out_path for the full CSV.
127
+ `:"",u=l?`
128
+ \u2026 ${e.matched-r.length} more not shown (see TRUNCATED above)`:"";return`${l}${i}
129
+ ${c.join(`
130
+ `)}${u}`}var hte=/^0[1-4]_[A-Z_]+\//;function V7(e,t){let n=F7(e.target_url);if(!n)return"";let i=e.role==="reference"?"03_REFERENCES":"02_MEDIA";if(t&&e.target_url){let r=gte(e.target_url),o=r?r.replace(hte,""):n;return`${i}/${o}`}return`${i}/${n}`}function j7(e,t,n){return{entries:bte(e,t,n).entries.map(o=>{if(o.inlineBytes)return{path:o.path,bytes:o.inlineBytes};if(o.sourceBasename)return{path:o.path,sourceBasename:o.sourceBasename};throw new Error(`folder-layout entry missing both inlineBytes and sourceBasename: ${o.path}`)})}}function bte(e,t,n){let i=[],r=new Map,o=new Set;for(let c of n.sourceFiles??[]){let l=zu(`01_PROJECT_FILES/source/${c.name}`,o);i.push({path:l,section:"project-source",inlineBytes:c.data})}let a=new Set,s=(e.media_references??[]).filter(c=>{if(!c.target_url)return!1;let l=F7(c.target_url);if(!(l.length>0&&t.has(l)))return!1;let u=`${l.toLowerCase()}\0${c.role??""}`;return a.has(u)?!1:(a.add(u),!0)});for(let c of s){let l=F7(c.target_url);if(c.bundle&&c.bundle.files.length>0){for(let f of c.bundle.files){if(!t.has(f.basename))continue;let d=zu(`02_MEDIA/${f.rel_path}`,o);i.push({path:d,section:"media",sourceBasename:f.basename}),r.set(f.basename,d)}continue}let u=zu(V7(c,n.preserveStructure===!0),o);i.push({path:u,section:c.role==="reference"?"reference":"media",sourceBasename:l}),c.role!=="reference"&&r.set(l,u)}for(let c of n.exchangeFiles??[]){let l=c.text?Mj(c.bytes,r,n.volumeName):c.bytes,u=zu(`01_PROJECT_FILES/converted/${c.filename}`,o);i.push({path:u,section:"project-converted",inlineBytes:l})}if(n.timelineFile){let c=n.timelineFile,l=Mj(c.bytes,r,n.volumeName);if(c.isConversion){let u=zu(`01_PROJECT_FILES/converted/${c.filename}`,o);i.push({path:u,section:"project-converted",inlineBytes:l})}else{let u=c.filename.includes(".")?c.filename.slice(c.filename.lastIndexOf(".")):"",d=`${c.filename.includes(".")?c.filename.slice(0,c.filename.lastIndexOf(".")):c.filename}_relinked${u}`,m=zu(`01_PROJECT_FILES/source/${d}`,o);i.push({path:m,section:"project-source",inlineBytes:l})}}return{entries:i,basenameToIsoPath:r}}function Mj(e,t,n){let i;try{i=new TextDecoder("utf-8",{fatal:!1}).decode(e)}catch{return e}for(let[r,o]of t){let a=`/Volumes/${n}/${o}`,s=vte(r);i=i.replace(new RegExp(`(<pathurl>)[^<]*${s}(</pathurl>)`,"g"),`$1file://localhost${a}$2`).replace(new RegExp(`("target_url"\\s*:\\s*")[^"]*${s}"`,"g"),`$1${a}"`).replace(new RegExp(`(src="file://)[^"]*${s}"`,"g"),`$1localhost${a}"`)}return new TextEncoder().encode(i)}function F7(e){return e?e.split(/[/\\]/).pop()??"":""}function gte(e){if(e)try{return decodeURIComponent(e.replace(/^file:\/\//,"").replace(/^\//,"").replace(/^Volumes\//,""))||void 0}catch{return}}function zu(e,t){if(!t.has(e))return t.add(e),e;let n=e.lastIndexOf("."),i=n>0?e.slice(0,n):e,r=n>0?e.slice(n):"",o=2,a=`${i}_${o}${r}`;for(;t.has(a);)o++,a=`${i}_${o}${r}`;return t.add(a),a}function vte(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Oj(e){return x6(e)}function Lj(e,t){let n=Math.max(0,Math.floor(e.handles??0)),i=e.frame_in-n,r=e.frame_out+n,o=Math.max(0,i),a=t!==void 0?Math.min(t,r):r;return{frame_in:o,frame_out:a,handles_applied_in:e.frame_in-o,handles_applied_out:a-e.frame_out,handles_requested:n}}function vm(e,t){if(t.format==="iso")return wte(e,t);if(t.format==="folder")return yte(e,t);throw new Error(`deriveLayout: unsupported format "${t.format}"`)}function yte(e,t){let n=Xj(e),i=[],r=new Set,o=new Set,a=0;for(let s of n){let c=Z7(s);if(!c)continue;o.add(c);let l=xte(s,c,t);r.add(l);let u=Nj(s.id??c,t),f=Rj(e,s,u,t.handles??0);i.push({dest_file:l,dest_offset:0,length:f,source:{kind:"file",basename:c,offset:0}}),a+=f}return{regions:i,total_bytes:a,dest_files:Array.from(r),source_basenames:Array.from(o)}}function wte(e,t){if(!t.volume_name)throw new Error("deriveLayout(iso): intent.volume_name is required");let n=Xj(e),i=`${t.volume_name}.iso`,r=[],o=new Set,a=0;for(let s of n){let c=Z7(s);if(!c)continue;o.add(c);let l=Nj(s.id??c,t),u=Rj(e,s,l,t.handles??0);r.push({dest_file:i,dest_offset:a,length:u,source:{kind:"file",basename:c,offset:0}}),a+=u}return{regions:r,total_bytes:a,dest_files:[i],source_basenames:Array.from(o)}}function Xj(e){let t=e.media_references;return Array.isArray(t)?t.filter(n=>n.carry_whole===!0||!(n.binding_state&&n.binding_state!=="linked")):[]}function Z7(e){if(!e.target_url)return null;let t=e.target_url.split(/[\\/]/).pop();return t&&t.length>0?t:null}function xte(e,t,n){let i=n.per_file_overrides?.[e.id]?.rel_path;if(i)return i;switch(n.folder_layout??"flat"){case"flat":return t;case"by-camera":{let r=e.reel_name;return r?`${r}/${t}`:t}case"media-organized":{let r=Pte(e);return r?`${r}/${t}`:t}case"canonical-i2o":return V7(e,!1)}}function Pte(e){if(Bm(e))return"Stills";switch(e.content_kind){case"still":return"Stills";case"audio":return"Audio";case"video":case"video_audio":return"Footage";case"compound":return"Compounds";default:return null}}function Nj(e,t){return t.per_file_overrides?.[e]?.mode??t.per_file_mode}function Rj(e,t,n,i){let r=t.size_bytes??0;if(r===0)return 0;let o=Z7(t);if(!o||!Oj(o)||n.mode==="sparse"&&n.populate.full===!0)return r;let a=t.available_range?.duration?.value??0;if(a<=0)return r;let s=Ste(e,t.id);if(s.length===0)return r;let c=s.map(d=>{let m=Lj({frame_in:d.start,frame_out:d.end,handles:i},a);return{start:m.frame_in,end:m.frame_out}});c.sort((d,m)=>d.start-m.start);let l=[{...c[0]}];for(let d=1;d<c.length;d++){let m=c[d],p=l[l.length-1];m.start<=p.end?p.end=Math.max(p.end,m.end):l.push({...m})}let u=0;for(let d of l){let m=Math.max(0,d.start),p=Math.min(a,d.end);p>m&&(u+=p-m)}let f=Math.min(1,u/a);return Math.round(f*r)}function Ste(e,t){let n=[],i=e?.timelines??[];for(let r of i)for(let o of r.tracks??[])for(let a of o.items??[]){if(a.media_reference_id!==t||!a.source_range)continue;let s=a.source_range.start.value,c=a.source_range.duration.value;c>0&&n.push({start:s,end:s+c})}return n}function Fj(e,t){let n=kte(e),i=n>=0?e.slice(0,n+1):"",r=n>=0?e.slice(n+1):e,o=r.lastIndexOf(".");return o<=0?i+r+t:i+r.slice(0,o)+t+r.slice(o)}function kte(e){let t=e.lastIndexOf("/"),n=e.lastIndexOf("\\");return t>n?t:n}async function Vj(e){try{return await e()}catch(t){let n=O6(t);throw n?new L6(n):t}}async function gg(e){let t=w6(e);if(!t||!t.trimSupported)return null;let n=t.flavor,i=r=>Qm(n,[Km(e,r)]);return{byteSourceFromFile:Tte,async prepareWrite(r,o,a){let c=(await Vj(()=>Yo(i(r),{verb:"sparsify",selection:{items:o,handles:a}})))[0];return{fileSize:c.fileSize,structuralRanges:c.structuralRanges,essenceRanges:c.essenceRanges,trimInputs:c.trimInputs??[],wholeFileFallback:c.wholeFileFallback}},async planTrim(r,o,a){let s=await Vj(()=>Yo(i(r),{verb:"trim",selection:{items:o,handles:a}}));if(n==="r3d")throw new Error(`planTrim(${e}): R3D must route through the R3D compact pass (r3d-trim-pass.ts), not the per-file path`);return s}}}async function Tte(e){return{fileSize:e.size,async read(t,n){let i=Math.min(t+n,e.size),r=e.slice(t,i);return new Uint8Array(await r.arrayBuffer())}}}var zte=new Uint16Array(256);for(let e=0;e<256;e++){let t=0,n=e<<8;for(let i=0;i<8;i++)(t^n)&32768?t=t<<1^4129:t=t<<1,n=n<<1;zte[e]=t&65535}var ym=Date.UTC(2020,0,1,0,0,0);function Ij(e,t,n,i){let r,o;try{let d=Pn.__wbindgen_add_to_stack_pointer(-16),m=W7(e,Pn.__wbindgen_export3,Pn.__wbindgen_export4),p=Oc,b=W7(t,Pn.__wbindgen_export3,Pn.__wbindgen_export4),h=Oc,v=W7(n,Pn.__wbindgen_export3,Pn.__wbindgen_export4),g=Oc;Pn.udf_build_layout(d,m,p,b,h,v,g,i);var a=no().getInt32(d+0,!0),s=no().getInt32(d+4,!0),c=no().getInt32(d+8,!0),l=no().getInt32(d+12,!0),u=a,f=s;if(l)throw u=0,f=0,q7(c);return r=u,o=f,Mc(u,f)}finally{Pn.__wbindgen_add_to_stack_pointer(16),Pn.__wbindgen_export5(r,o,1)}}function Wj(){let e,t;try{let r=Pn.__wbindgen_add_to_stack_pointer(-16);Pn.udf_last_panic(r);var n=no().getInt32(r+0,!0),i=no().getInt32(r+4,!0);return e=n,t=i,Mc(n,i)}finally{Pn.__wbindgen_add_to_stack_pointer(16),Pn.__wbindgen_export5(e,t,1)}}function Dj(e){let t,n;try{let o=Pn.__wbindgen_add_to_stack_pointer(-16),a=Rte(e,Pn.__wbindgen_export3),s=Oc;Pn.udf_read_conform_iuvd(o,a,s);var i=no().getInt32(o+0,!0),r=no().getInt32(o+4,!0);return t=i,n=r,Mc(i,r)}finally{Pn.__wbindgen_add_to_stack_pointer(16),Pn.__wbindgen_export5(t,n,1)}}function Mte(){return{__proto__:null,"./udf_bg.js":{__proto__:null,__wbg___wbindgen_is_function_acc5528be2b923f2:function(t){return typeof nr(t)=="function"},__wbg___wbindgen_is_undefined_721f8decd50c87a3:function(t){return nr(t)===void 0},__wbg___wbindgen_number_get_1cc01dd708740256:function(t,n){let i=nr(n),r=typeof i=="number"?i:void 0;no().setFloat64(t+8,Mu(r)?0:r,!0),no().setInt32(t+0,!Mu(r),!0)},__wbg___wbindgen_throw_ea4887a5f8f9a9db:function(t,n){throw new Error(Mc(t,n))},__wbg__wbg_cb_unref_33c39e13d73b25f6:function(t){nr(t)._wbg_cb_unref()},__wbg_call_0e855b388e315e17:function(){return I7(function(t,n,i,r){let o=nr(t).call(nr(n),nr(i),nr(r));return gr(o)},arguments)},__wbg_call_5575218572ead796:function(){return I7(function(t,n,i){let r=nr(t).call(nr(n),nr(i));return gr(r)},arguments)},__wbg_call_8e98ed2f3c86c4b5:function(){return I7(function(t,n){let i=nr(t).call(nr(n));return gr(i)},arguments)},__wbg_error_2b5d73c4c4804cfd:function(t,n){console.error(Mc(t,n))},__wbg_length_589238bdcf171f0e:function(t){return nr(t).length},__wbg_new_81880fb5002cb255:function(t){let n=new Uint8Array(nr(t));return gr(n)},__wbg_new_from_slice_543b875b27789a8f:function(t,n){let i=new Uint8Array(Zj(t,n));return gr(i)},__wbg_new_no_args_2d7333de60de5ac7:function(t,n){let i=new Function(Mc(t,n));return gr(i)},__wbg_new_typed_00a409eb4ec4f2d9:function(t,n){try{var i={a:t,b:n},r=(a,s)=>{let c=i.a;i.a=0;try{return Lte(c,i.b,a,s)}finally{i.a=c}};let o=new Promise(r);return gr(o)}finally{i.a=0}},__wbg_prototypesetcall_d721637c7ca66eb8:function(t,n,i){Uint8Array.prototype.set.call(Zj(t,n),nr(i))},__wbg_queueMicrotask_1c9b3800e321a967:function(t){let n=nr(t).queueMicrotask;return gr(n)},__wbg_queueMicrotask_311744e534a929a3:function(t){queueMicrotask(nr(t))},__wbg_resolve_d82363d90af6928a:function(t){let n=Promise.resolve(nr(t));return gr(n)},__wbg_static_accessor_GLOBAL_THIS_2fee5048bcca5938:function(){let t=typeof globalThis>"u"?null:globalThis;return Mu(t)?0:gr(t)},__wbg_static_accessor_GLOBAL_ce44e66a4935da8c:function(){let t=typeof global>"u"?null:global;return Mu(t)?0:gr(t)},__wbg_static_accessor_SELF_44f6e0cb5e67cdad:function(){let t=typeof self>"u"?null:self;return Mu(t)?0:gr(t)},__wbg_static_accessor_WINDOW_168f178805d978fe:function(){let t=typeof window>"u"?null:window;return Mu(t)?0:gr(t)},__wbg_then_05edfc8a4fea5106:function(t,n,i){let r=nr(t).then(nr(n),nr(i));return gr(r)},__wbg_then_591b6b3a75ee817a:function(t,n){let i=nr(t).then(nr(n));return gr(i)},__wbindgen_cast_0000000000000001:function(t,n){let i=Nte(t,n,Ote);return gr(i)},__wbindgen_cast_0000000000000002:function(t){return gr(t)},__wbindgen_cast_0000000000000003:function(t,n){let i=Mc(t,n);return gr(i)},__wbindgen_object_clone_ref:function(t){let n=nr(t);return gr(n)},__wbindgen_object_drop_ref:function(t){q7(t)}}}}function Ote(e,t,n){try{let o=Pn.__wbindgen_add_to_stack_pointer(-16);Pn.__wasm_bindgen_func_elem_253(o,e,t,gr(n));var i=no().getInt32(o+0,!0),r=no().getInt32(o+4,!0);if(r)throw q7(i)}finally{Pn.__wbindgen_add_to_stack_pointer(16)}}function Lte(e,t,n,i){Pn.__wasm_bindgen_func_elem_267(e,t,gr(n),gr(i))}function gr(e){xm===Sa.length&&Sa.push(Sa.length+1);let t=xm;return xm=Sa[t],Sa[t]=e,t}var jj=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Pn.__wbindgen_export2(e.a,e.b));function Xte(e){e<1028||(Sa[e]=xm,xm=e)}function Zj(e,t){return e=e>>>0,Ou().subarray(e/1,e/1+t)}var zc=null;function no(){return(zc===null||zc.buffer.detached===!0||zc.buffer.detached===void 0&&zc.buffer!==Pn.memory.buffer)&&(zc=new DataView(Pn.memory.buffer)),zc}function Mc(e,t){return Vte(e>>>0,t)}var wm=null;function Ou(){return(wm===null||wm.byteLength===0)&&(wm=new Uint8Array(Pn.memory.buffer)),wm}function nr(e){return Sa[e]}function I7(e,t){try{return e.apply(this,t)}catch(n){Pn.__wbindgen_export(gr(n))}}var Sa=new Array(1024).fill(void 0);Sa.push(void 0,null,!0,!1);var xm=Sa.length;function Mu(e){return e==null}function Nte(e,t,n){let i={a:e,b:t,cnt:1},r=(...o)=>{i.cnt++;let a=i.a;i.a=0;try{return n(a,i.b,...o)}finally{i.a=a,r._wbg_cb_unref()}};return r._wbg_cb_unref=()=>{--i.cnt===0&&(Pn.__wbindgen_export2(i.a,i.b),i.a=0,jj.unregister(i))},jj.register(r,i,i),r}function Rte(e,t){let n=t(e.length*1,1)>>>0;return Ou().set(e,n/1),Oc=e.length,n}function W7(e,t,n){if(n===void 0){let s=Pm.encode(e),c=t(s.length,1)>>>0;return Ou().subarray(c,c+s.length).set(s),Oc=s.length,c}let i=e.length,r=t(i,1)>>>0,o=Ou(),a=0;for(;a<i;a++){let s=e.charCodeAt(a);if(s>127)break;o[r+a]=s}if(a!==i){a!==0&&(e=e.slice(a)),r=n(r,i,i=a+e.length*3,1)>>>0;let s=Ou().subarray(r+a,r+i),c=Pm.encodeInto(e,s);a+=c.written,r=n(r,i,a,1)>>>0}return Oc=a,r}function q7(e){let t=nr(e);return Xte(e),t}var vg=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});vg.decode();var Fte=2146435072,D7=0;function Vte(e,t){return D7+=t,D7>=Fte&&(vg=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),vg.decode(),D7=t),vg.decode(Ou().subarray(e,e+t))}var Pm=new TextEncoder;"encodeInto"in Pm||(Pm.encodeInto=function(e,t){let n=Pm.encode(e);return t.set(n),{read:e.length,written:n.length}});var Oc=0,jte,Zte,Pn;function Ite(e,t){return Zte=e,Pn=e.exports,jte=t,zc=null,wm=null,Pn.__wbindgen_start(),Pn}async function Wte(e,t){if(typeof Response=="function"&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(r){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",r);else throw r}let i=await e.arrayBuffer();return await WebAssembly.instantiate(i,t)}else{let i=await WebAssembly.instantiate(e,t);return i instanceof WebAssembly.Instance?{instance:i,module:e}:i}function n(i){switch(i){case"basic":case"cors":case"default":return!0}return!1}}async function yg(e){if(Pn!==void 0)return Pn;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=Mte();(typeof e=="string"||typeof Request=="function"&&e instanceof Request||typeof URL=="function"&&e instanceof URL)&&(e=fetch(e));let{instance:n,module:i}=await Wte(await e,t);return Ite(n,i)}var H7=null;function Dte(e){return H7||(H7=(async()=>{if(e!==void 0)return yg(e);if(typeof process<"u"&&process.versions?.node){let n="node:fs/promises",{readFile:i}=await import(n),r=await i(new URL("./wasm/udf_bg.wasm",import.meta.url));return yg({module_or_path:r})}let{default:t}=await import("./udf_bg-R3JEZJAT.js");return yg({module_or_path:t})})()),H7}function E7(){return Dte()}function qte(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}async function Hj(e,t="i2o",n,i,r=ym){await E7();let o;try{o=Ij(JSON.stringify(e),t,i?JSON.stringify(i):"",r)}catch(s){let c="";try{c=Wj()}catch{}throw c?new Error(`udf_build_layout failed: ${c} (raw: ${s instanceof Error?s.message:String(s)})`):s instanceof Error?s:new Error(`udf_build_layout failed: ${String(s)}`)}let a=JSON.parse(o);return{totalBytes:a.totalBytes,totalSectors:a.totalSectors,structuralRegions:a.structuralRegions.map(s=>({sectorStart:s.sectorStart,sectorCount:s.sectorCount,data:qte(s.dataB64)})),fileDataRegions:a.fileDataRegions}}async function Ej(e){await E7();let t=32*2048,n=16*2048,i;if(e instanceof Uint8Array){if(e.length<t+n)return null;i=e.subarray(t,t+n)}else{if(e.size<t+n)return null;i=new Uint8Array(await e.slice(t,t+n).arrayBuffer())}let r=Dj(i);if(!r)return null;try{return JSON.parse(r)}catch{return null}}function Hte(e){return e.speed!=null&&e.speed!==100||e.speed_reverse||e.speed_ramped?!0:(e.keyframes??[]).some(t=>t.parameter_path==="speed")}function Ete(e,t){let n=e.timelines??[];if(t)return n.filter(o=>o.name===t);let i=new Set;for(let o of n)for(let a of o.tracks??[])for(let s of a.items??[])s.nested_timeline_id&&i.add(s.nested_timeline_id);let r=n.filter(o=>!i.has(o.id));return r.length?r:n}function Cte(e,t,n){let i=new Map((e.timelines??[]).map(o=>[o.id,o])),r=(o,a,s,c)=>{if(!(!o||s>8))for(let l of o.tracks??[])for(let u of l.items??[]){let f=s===0?u:c??u,d=Math.round(u.timeline_range?.start?.value??0),m=d+Math.round(u.timeline_range?.duration?.value??0),p=a?a.map(([h,v])=>[Math.max(d,h),Math.min(m,v)]).filter(([h,v])=>v>h):[[d,m]];if(p.length===0)continue;let b=Hte(u);if(u.nested_timeline_id){let h=i.get(u.nested_timeline_id),v=Math.round(u.source_range?.start?.value??0),g=(o.fps_num??0)/Math.max(o.fps_den??1,1),y=h?(h.fps_num??0)/Math.max(h.fps_den??1,1):g,w=g>0&&y>0?y/g:1,x=p.map(([T,z])=>[Math.floor((v+(T-d))*w),Math.floor((v+(z-d))*w)]);r(h,x,s+1,f)}else if(u.media_reference_id){let h=Math.round(u.source_range?.start?.value??0),v=Math.round(u.source_range?.duration?.value??0);if(b){n({item:u,root:f,tl_id:o.id,depth:s,has_speed:!0,tl_in:d,src_in:h,a:d,b:d+v,reached_in:h,reached_out:h+v});continue}for(let[g,y]of p)n({item:u,root:f,tl_id:o.id,depth:s,has_speed:!1,tl_in:d,src_in:h,a:g,b:y,reached_in:h+(g-d),reached_out:h+(y-d)})}}};for(let o of Ete(e,t.rootTimelineName))r(o,null,0,null)}function Cj(e,t={}){let n=new Map;return Cte(e,t,i=>{let r=i.item.media_reference_id,o={clip_src_in:i.src_in,reached_in:i.reached_in,reached_out:i.reached_out,has_speed:i.has_speed},a=n.get(r);a?a.push(o):n.set(r,[o])}),n}var ka=2048;function wg(e,t,n){console.error(`[planIsoRegions] DROPPING "${t}" \u2014 ${n}. NOT shipping it whole: that would deliver the entire file to carry a few seconds of it.`),e.push({basename:t,reason:n})}async function Uj(e){if(e.perFile.mode==="trim")throw new Error("planIsoRegions: ISO + trim is not supported. Use folder collection for compact trim output, or ISO sparse-segments for the canonical cloud / P2P shape (recipient can derive folder-of-trims at download time per project_upload_once_choose_at_download).");let t=e.perFile.populate,{ranges:n,dropped:i}=await Ute(e),r=[],o=[];for(let v of e.entries){if("bytes"in v){r.push({path:v.path,totalSize:v.bytes.length,keptRanges:[{offset:0,length:v.bytes.length}],inlineBytes:v.bytes});continue}let g=e.files.get(v.sourceBasename);if(!g)continue;let y=()=>({path:v.path,sourceBasename:v.sourceBasename,totalSize:g.size,keptRanges:[{offset:0,length:g.size}],file:g}),w=await gg(v.sourceBasename);if(!w||t.full){r.push(y());continue}if(Va(v.sourceBasename)){if(i.has(v.sourceBasename)){wg(o,v.sourceBasename,"delivery coverage miss (cut outside the clip's real frames)");continue}let S=n.get(v.sourceBasename);if(S&&(S.structuralRanges.length>0||S.essenceRanges.length>0)){let M=[...S.structuralRanges];t.segments&&M.push(...S.essenceRanges),r.push({path:v.path,sourceBasename:v.sourceBasename,totalSize:g.size,keptRanges:M,prep:{fileSize:g.size,structuralRanges:S.structuralRanges,essenceRanges:S.essenceRanges,trimInputs:[]},file:g})}else wg(o,v.sourceBasename,"R3D part has no planned sparse ranges");continue}let x=Gj(e.session,v.sourceBasename),T=await w.byteSourceFromFile(g),z;try{z=await w.prepareWrite(T,x,e.handles)}catch(S){let M=zs(S);if(M){console.warn(`[planIsoRegions] coverage miss detail for "${v.sourceBasename}":`,M),wg(o,v.sourceBasename,"delivery coverage miss (cut outside the clip's real frames)");continue}wg(o,v.sourceBasename,S instanceof Error?S.message:String(S));continue}let k=[...z.structuralRanges];t.segments&&k.push(...z.essenceRanges),r.push({path:v.path,sourceBasename:v.sourceBasename,totalSize:g.size,keptRanges:k,prep:z,source:T,file:g})}let a=r.map(v=>{let g=v.prep?Ate(v.keptRanges,v.totalSize):void 0,y=e.pinSectorByPath?.get(v.path);return{name:v.path,totalSize:v.totalSize,...g?{dataExtents:g}:{},...y!==void 0?{fixedPartSector:y}:{}}}),s=await Hj(a,e.volumeName,{},e.iuvd,e.buildTimestamp),c=new Map;for(let v of s.fileDataRegions)c.has(v.name)||c.set(v.name,{byteOffset:v.sectorStart*ka,partSector:v.sectorStart-257});let l=`${e.volumeName}.iso`,u=[],f=new Set;for(let v of s.structuralRegions)v.data.length!==0&&u.push({dest_file:l,dest_offset:v.sectorStart*ka,length:v.data.length,source:{kind:"inline",bytes:v.data}});let d=new Map;for(let v of r)d.set(v.path,v);let m=new Map,p=new Map;for(let v of s.fileDataRegions){let g=d.get(v.name);if(!g)continue;let y=!!g.file&&!g.inlineBytes&&(!g.prep||g.prep.wholeFileFallback===!0);if(p.has(g.path)||p.set(g.path,y),g.inlineBytes){let z=g.inlineBytes.subarray(v.sourceOffset,v.sourceOffset+v.sourceLength);u.push({dest_file:l,dest_offset:v.sectorStart*ka,length:z.length,source:{kind:"inline",bytes:z}}),m.set(g.path,(m.get(g.path)??0)+z.length);continue}if(!g.file){p.set(g.path,!0);continue}if(!g.prep){f.add(g.sourceBasename??g.file.name),u.push({dest_file:l,dest_offset:v.sectorStart*ka,length:v.sourceLength,source:{kind:"file",basename:g.sourceBasename??g.file.name,offset:v.sourceOffset}}),m.set(g.path,(m.get(g.path)??0)+v.sourceLength);continue}let w=g.sourceBasename??g.file.name;f.add(w);let x=v.sourceOffset,T=v.sourceOffset+v.sourceLength;for(let z of g.keptRanges){let k=Math.max(z.offset,x),S=Math.min(z.offset+z.length,T);if(S<=k)continue;let M=S-k;u.push({dest_file:l,dest_offset:v.sectorStart*ka+(k-x),length:M,source:{kind:"file",basename:w,offset:k}}),m.set(g.path,(m.get(g.path)??0)+M)}}u.sort((v,g)=>v.dest_offset-g.dest_offset);let b=r.map(v=>({path:v.path,bytesWritten:m.get(v.path)??0,fellBack:p.get(v.path)??!1})),h=0;for(let v of u)h+=v.length;return{layout:{regions:u,total_bytes:h,dest_files:[l],source_basenames:Array.from(f),image_total_bytes:s.totalBytes},isoPositions:c,totalBytes:s.totalBytes,perFileSummary:b,untrimmable:o}}async function Aj(e,t,n,i={}){let{layout:r,totalBytes:o}=e;if(r.dest_files.length!==1)throw new Error(`executeIsoPlan: expected single dest_file, got ${r.dest_files.length}`);let a=0;for(let c of r.regions)c.source.kind!=="zero"&&(a+=c.length);await n.reserveSize(o);let s=0;try{for(let c of r.regions){if(i.signal?.aborted)throw new DOMException("Aborted","AbortError");if(c.length!==0){switch(c.source.kind){case"inline":{await n.writeAt(c.dest_offset,c.source.bytes),s+=c.source.bytes.length;break}case"file":{let l=t.get(c.source.basename);if(!l)throw new Error(`executeIsoPlan: file not in files map: "${c.source.basename}"`);let u=16*1024*1024,f=0;for(;f<c.length;){let d=Math.min(u,c.length-f),m=l.slice(c.source.offset+f,c.source.offset+f+d),p=new Uint8Array(await m.arrayBuffer());await n.writeAt(c.dest_offset+f,p),f+=d,s+=d,i.onProgress?.({bytesWritten:s,totalBytes:a,currentFile:c.source.basename})}continue}case"zero":break;case"pack":throw new Error("executeIsoPlan: `pack` regions require the CAS executor, not a local-file build")}i.onProgress?.({bytesWritten:s,totalBytes:a})}}await n.close()}catch(c){throw await n.abort?.(c),c}return{bytesWritten:s}}async function Ute(e){let t=new Map,n=new Set,i=e.session.media_references??[],r=[],o=new Set;for(let c of i){if(c.bundle?.kind!=="rdc")continue;let l=c.bundle,u=l.files.filter(d=>d.role==="anchor"||d.role==="part").slice().sort((d,m)=>(d.part_number??0)-(m.part_number??0)).map(d=>({filename:d.basename,file:e.files.get(d.basename)})).filter(d=>!!d.file);if(u.length===0)continue;let f=(c.target_url??"").split(/[/\\]/).pop()||u[0].filename;r.push({label:l.folder,anchorBasename:f,parts:u});for(let d of u)o.add(d.filename)}for(let c of i){if(c.bundle?.kind==="rdc")continue;let l=(c.target_url??"").split(/[/\\]/).pop()??"";if(!Va(l)||o.has(l))continue;let u=R6(l,e.files.keys()).map(f=>({filename:f,file:e.files.get(f)})).filter(f=>!!f.file);if(u.length!==0){r.push({label:l,anchorBasename:l,parts:u});for(let f of u)o.add(f.filename)}}if(r.length===0)return{ranges:t,dropped:n};let{mediaOp:a}=await import("./ops-UPPAG2TI.js"),{sourceFromFiles:s}=await import("./source-BDJAUQVR.js");for(let c of r){let{label:l,anchorBasename:u,parts:f}=c,d=Gj(e.session,u);try{let m=s(f.map(b=>b.file)),p=await a(m,{verb:"sparsify",selection:{items:d,handles:e.handles}});for(let b of p)t.set(b.filename,{structuralRanges:b.structuralRanges,essenceRanges:b.essenceRanges})}catch(m){let p=zs(m);if(p){for(let b of f)n.add(b.filename);console.warn(`[planIsoRegions] DROPPING R3D clip "${l}" fail-closed \u2014 delivery coverage miss; NOT whole-filing:`,p);continue}console.warn(`[planIsoRegions] R3D spanned prep failed for "${l}":`,m)}}return{ranges:t,dropped:n}}function Gj(e,t){let n=new Set,i=t.toLowerCase();for(let u of e.media_references??[]){if(!u.target_url)continue;(u.target_url.split(/[/\\]/).pop()??"").toLowerCase()===i&&n.add(u.id)}let r=[],o=!1;for(let u of e.timelines??[])for(let f of u.tracks??[])for(let d of f.items??[])d.media_reference_id&&n.has(d.media_reference_id)&&r.push(d),d.nested_timeline_id&&(o=!0);if(!o||r.length===0)return r;let a=Cj(e),s=[...n].flatMap(u=>a.get(u)??[]);if(s.length===0)return r;let c=r[0],l=c.source_range?.start?.rate??c.source_range?.duration?.rate??1;return s.map(u=>({...c,kind:"clip",source_range:{start:{value:u.reached_in,rate:l},duration:{value:u.reached_out-u.reached_in,rate:l}}}))}function Ate(e,t){if(e.length===0)return e;let n=e.map(r=>{let o=Math.floor(r.offset/ka)*ka,a=Math.min(Math.ceil((r.offset+r.length)/ka)*ka,t);return{offset:o,length:Math.max(0,a-o)}}).filter(r=>r.length>0);n.sort((r,o)=>r.offset-o.offset);let i=[];for(let r of n){let o=i[i.length-1];o&&r.offset<=o.offset+o.length?o.length=Math.max(o.length,r.offset+r.length-o.offset):i.push({...r})}return i}async function xg(e,t,n,i,r){if(i.format==="iso"){if(!r)throw new Error("refineLayoutForTrim(iso): isoOptions is required (entries, pinSectorByPath, iuvd come from buildI2oFolderLayout in the wizard).");if(!i.volume_name)throw new Error("refineLayoutForTrim(iso): intent.volume_name is required");let l=Yte(i,n),u=await Uj({session:n,files:t,handles:i.handles??0,perFile:l,volumeName:i.volume_name,entries:r.entries,pinSectorByPath:r.pinSectorByPath,iuvd:r.iuvd,buildTimestamp:r.buildTimestamp});return u.untrimmable.length>0?{...u.layout,untrimmable:u.untrimmable}:u.layout}if(i.per_file_mode.mode!=="trim")return e;let o=U7(n),a=A7(n),s=new Map;for(let l of e.regions){let u=s.get(l.dest_file);u?u.push(l):s.set(l.dest_file,[l])}let c=[];for(let[l,u]of s){let f=u.length===1?u[0]:null;if(!f||f.source.kind!=="file"){c.push(...u);continue}let d=f.source.basename,m=t.get(d);if(!m){c.push(f);continue}let p=a.get(d),b=p?o.get(p.id)??[]:[],h=await Gte({destFile:l,basename:d,file:m,ref:p,items:b,handles:i.handles??0});h!=="coverage-miss"&&(h?c.push(...h):c.push({dest_file:l,dest_offset:0,length:m.size,source:{kind:"file",basename:d,offset:0}}))}return Bte(c)}async function Gte(e){if(e.items.length===0)return null;let t=await gg(e.basename);if(!t||!t.planTrim)return null;let n;try{let r=await t.byteSourceFromFile(e.file);n=await t.planTrim(r,e.items,e.handles)}catch(r){let o=zs(r);return o?(console.warn(`[refineLayoutForTrim] DROPPING "${e.basename}" fail-closed \u2014 delivery coverage miss; NOT whole-filing:`,o),"coverage-miss"):null}if(n.length===0)return null;if(n.length===1)return Sm(n[0],e.destFile,e.basename);let i=Math.max(3,String(n.length).length);return n.flatMap((r,o)=>Sm(r,Fj(e.destFile,`_S${String(o+1).padStart(i,"0")}`),e.basename))}function Sm(e,t,n){let i=[],r=e.dest_header_bytes_base64?C7(e.dest_header_bytes_base64):null;r&&r.length>0&&i.push({dest_file:t,dest_offset:0,length:r.length,source:{kind:"inline",bytes:r}});for(let o of e.src_byte_ranges)o.length<=0||i.push({dest_file:t,dest_offset:o.write_to_dest_offset,length:o.length,source:{kind:"file",basename:o.src_file_name??n,offset:o.offset}});if(e.dest_footer_bytes_base64&&e.dest_footer_offset!=null){let o=C7(e.dest_footer_bytes_base64);o.length>0&&i.push({dest_file:t,dest_offset:e.dest_footer_offset,length:o.length,source:{kind:"inline",bytes:o}})}if(e.dest_patches)for(let o of e.dest_patches){let a=C7(o.bytes_base64);a.length!==0&&i.push({dest_file:t,dest_offset:o.offset,length:a.length,source:{kind:"inline",bytes:a}})}return i.sort((o,a)=>o.dest_offset-a.dest_offset),i}function U7(e){let t=new Map,n=e?.timelines??[];for(let i of n)for(let r of i.tracks??[])for(let o of r.items??[]){if(!o?.media_reference_id)continue;let a=t.get(o.media_reference_id);a?a.push(o):t.set(o.media_reference_id,[o])}return t}function Jte(e,t){let n=e.match(/^(\d+):(\d+):(\d+)[:;](\d+)$/);if(!n)return null;let i=Math.round(t);return(+n[1]*3600+ +n[2]*60+ +n[3])*i+ +n[4]}function Jj(e,t,n){let i=t?.source_timecode?Jte(t.source_timecode,n):null;return i==null?e:e.map(r=>{let o=r?.raw_extraction;if(o?.sourceConformedToMedia)return r;let a=o?.alternateFrame;if(a==null||!r.source_range)return r;let s=a-i;return s===0?r:{...r,source_range:{...r.source_range,start:{...r.source_range.start,value:r.source_range.start.value+s}}}})}function A7(e){let t=new Map,n=e?.media_references??[];for(let i of n){if(!i.target_url)continue;let r=i.target_url.split(/[\\/]/).pop();r&&r.length>0&&t.set(r,i)}return t}function Bte(e){let t=new Set,n=new Set,i=0;for(let r of e)t.add(r.dest_file),r.source.kind==="file"&&n.add(r.source.basename),i+=r.length;return{regions:e,total_bytes:i,dest_files:Array.from(t),source_basenames:Array.from(n)}}function C7(e){let t=atob(e),n=new Uint8Array(t.length);for(let i=0;i<t.length;i++)n[i]=t.charCodeAt(i);return n}function Yte(e,t){return e.per_file_mode.mode==="trim"?{mode:"trim"}:{mode:"sparse",populate:{structural:!0,segments:e.per_file_mode.populate.segments,full:e.per_file_mode.populate.full}}}var Pg=class{constructor(t){this.opts=t}async execute(){let{layout:t,sink:n}=this.opts,i=t.total_bytes,r=Kte(t.regions),o=Math.max(1,this.opts.concurrency??1),a=0,s=0,c=[],l,u=async(f,d)=>{this.opts.signal?.throwIfAborted(),d.sort((h,v)=>h.dest_offset-v.dest_offset);let m=Qte(d),p=await n.openFile(f,m),b=0;try{for(let h of d){this.opts.signal?.throwIfAborted(),l=f,this.opts.onProgress?.({bytesWritten:a,totalBytes:i,currentFile:l});let v=0,g=await this.writeRegion(h,p,y=>{s+=y-v,v=y,this.opts.onProgress?.({bytesWritten:s,totalBytes:i,currentFile:l})});b+=g,a+=g}await p.close()}catch(h){throw await p.abort?.(h),h}return{path:f,bytesWritten:b}};if(o===1)for(let[f,d]of r)c.push(await u(f,d));else{let f=Array.from(r.entries()),d=0,m=[];for(let p=0;p<Math.min(o,f.length);p++)m.push((async()=>{for(;d<f.length;){let b=d++;if(b>=f.length)break;let[h,v]=f[b],g=await u(h,v);c.push(g)}})());await Promise.all(m)}return await n.closeCollection(),this.opts.onProgress?.({bytesWritten:a,totalBytes:i}),{bytesWritten:a,perFile:c}}async writeRegion(t,n,i){if(t.length===0)return 0;switch(t.source.kind){case"inline":return await n.writeAt(t.dest_offset,t.source.bytes),i?.(t.source.bytes.length),t.source.bytes.length;case"file":{let r=this.opts.files.get(t.source.basename);if(!r)throw new Error(`LocalDirectoryExecutor: file not found in files map: "${t.source.basename}"`);let o=16*1024*1024,a=t.source.offset,s=0;for(;s<t.length;){let c=Math.min(o,t.length-s),l=r.slice(a+s,a+s+c),u=new Uint8Array(await l.arrayBuffer());await n.writeAt(t.dest_offset+s,u),s+=c,i?.(s)}return t.length}case"zero":return 0;case"pack":throw new Error("LocalDirectoryExecutor: `pack` regions require the CAS executor, not a local-file executor")}}};function Kte(e){let t=new Map;for(let n of e){let i=t.get(n.dest_file);i?i.push(n):t.set(n.dest_file,[n])}return t}function Qte(e){let t=0;for(let n of e){let i=n.dest_offset+n.length;i>t&&(t=i)}return t}var Sg=class{constructor(t){this.opts=t}async execute(){return Aj({layout:this.opts.layout,totalBytes:this.opts.totalBytes},this.opts.files,this.opts.sink,{onProgress:this.opts.onProgress,signal:this.opts.signal})}};import{mkdir as _te,open as Bj}from"node:fs/promises";import{dirname as $te,join as ene}from"node:path";function Yj(e){let t=!1;return{async reserveSize(n){await e.truncate(n)},async writeAt(n,i){if(t)throw new Error("nodeFileStream: closed");let r=Buffer.from(i.buffer,i.byteOffset,i.byteLength);await e.write(r,0,i.byteLength,n)},async close(){t||(t=!0,await e.close())},async abort(n){if(!t){t=!0;try{await e.close()}catch{}}}}}async function Kj(e){let t=await Bj(e,"w");return Yj(t)}function Qj(e){return{async openFile(t,n){let i=ene(e,t);await _te($te(i),{recursive:!0});let r=await Bj(i,"w"),o=Yj(r);return await o.reserveSize(n),o},async closeCollection(){}}}async function J7(e){let t=G7(e),n=new TextEncoder().encode(t),i=await crypto.subtle.digest("SHA-256",n);return Array.from(new Uint8Array(i)).map(r=>r.toString(16).padStart(2,"0")).join("")}function G7(e){if(e===null||typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(G7).join(",")}]`;let t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${G7(t[r])}`).join(",")}}`}var nne="i2o-2026-05-08",rne=1;function _j(e){let t=e?.created_at?Date.parse(e.created_at):NaN;return Number.isFinite(t)?t:ym}async function $j(e){let[t,n]=await Promise.all([J7(e.session),J7(e.layoutIntent)]);return{payload:{v:1,conform_tools_version:nne,session_sha256:t,delivery_intent_sha256:n,layout_fn_version:rne,written_at:e.writtenAt??new Date(ym).toISOString(),...e.sessionIdHint?{session_id_hint:e.sessionIdHint}:{}},session_sha256:t,delivery_intent_sha256:n}}function eZ(e){return e.map((t,n)=>({partNumber:t.output_part_number??n+1,clipNumber:t.output_clip_number,clipCount:t.output_clip_count,plan:t}))}function ine(e,t,n,i=""){let r=ri(t),o=r?r.clipBase:t.replace(/\.R3D$/i,""),a=`${o}_${String(n).padStart(3,"0")}.R3D`,s=e.split("/");return s.pop(),s.length&&/\.rdc$/i.test(s[s.length-1])&&s.pop(),[...s,`${o}${i}.RDC`,a].join("/")}function one(e){let t=e.clipCount??1;if(t<=1)return"";let n=Math.max(3,String(t).length);return`_S${String(e.clipNumber??1).padStart(n,"0")}`}function ane(e){let t=new Map;for(let n of e){let i=ri(n.basename),r=i?i.clipBase:n.basename,o=t.get(r);o?o.push(n):t.set(r,[n])}for(let n of t.values())n.sort((i,r)=>(ri(i.basename)?.partNumber??0)-(ri(r.basename)?.partNumber??0));return[...t.values()]}async function tZ(e){let t=[],n=new Map,i=[],r=0;for(let o of ane(e.parts)){let a=o[0];if(new Set(o.map(c=>c.basename)).size!==o.length){let c=ri(a.basename),l=c?c.clipBase:a.basename.replace(/\.R3D$/i,""),u={reason:"duplicate .R3D part filenames in one send (same clip name in two .RDC folders \u2014 e.g. re-sending two _S### islands of one source); byte-identical routing would be ambiguous"};console.warn(`[r3d-trim-pass] DROPPING R3D clip "${l}" fail-closed:`,u.reason),i.push({clipBase:l,parts:o.map(f=>f.basename),reason:u});continue}let s;try{s=await e.planClip(o)}catch(c){let l=zs(c);if(!l)throw c;let u=ri(a.basename),f=u?u.clipBase:a.basename.replace(/\.R3D$/i,"");console.warn(`[r3d-trim-pass] DROPPING R3D clip "${f}" fail-closed \u2014 delivery coverage miss (cut not within the file's real frames); NOT whole-filing:`,l),i.push({clipBase:f,parts:o.map(d=>d.basename),reason:l});continue}for(let c of o)n.set(c.basename,c.file);for(let c of s){let l=ine(a.destPathHint,a.basename,c.partNumber,one(c));t.push(...Sm(c.plan,l,a.basename)),r+=c.plan.src_byte_ranges.reduce((u,f)=>u+f.length,0)}}return{regions:t,filesByBasename:n,bytes:r,dropped:i}}function nZ(e){switch(e){case"trim":return{mode:"trim"};case"skeleton":return{mode:"sparse",populate:{structural:!0}};case"sparse":return{mode:"sparse",populate:{structural:!0,segments:!0}};case"full":return{mode:"sparse",populate:{structural:!0,full:!0}}}}var sr=class e extends File{#e;constructor(t,n,i){super([],n),this.path=t,this.#e=i}get size(){return this.#e}static async open(t,n=ae(t)){return new e(t,n,(await cn(t)).size)}slice(t=0,n=this.size){let i=Math.max(0,t),r=Math.min(this.size,n),o=this.path;return{size:r-i,async arrayBuffer(){let a=await Ec(o);try{let s=await a.readAt(i,r-i);return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}finally{await a.close()}}}}arrayBuffer(){return this.slice().arrayBuffer()}stream(){let t=this;return new ReadableStream({async start(n){n.enqueue(new Uint8Array(await t.arrayBuffer())),n.close()}})}text(){return this.arrayBuffer().then(t=>new TextDecoder().decode(t))}};async function rZ(e,t){let n=new Map,i=[],r=new Set;for(let o of e.timelines)for(let a of o.tracks)for(let s of a.items)s.media_reference_id&&r.add(s.media_reference_id);for(let o of e.media_references??[]){if(!r.has(o.id))continue;let a=o.local_path??o.target_url;if(!a){i.push(`${o.id}: no path`);continue}if(t.only_linked&&o.binding_state!=="linked"){i.push(`${o.id} ${ae(a)}: not linked (run timeline_relink, or only_linked=false)`);continue}if(!await Nn(a)){i.push(`${o.id} ${a}: not on this machine`);continue}if(!ra.has(Pr(a).toLowerCase())){i.push(`${o.id} ${ae(a)}: unsupported container`);continue}for(let s of await Ds(a))n.set(ae(s),await sr.open(s))}return{files:n,skipped:i}}var sne=new Set(["resolve-xmeml","flame-fcpxml","resolve-otio","premiere-otio"]);async function iZ(e,t,n){let i=await Nn(t)?[{name:ae(t),data:await pr(t)}]:[],r=[],o=[];for(let s of n){let c=k7(s),l=await Kb(c,e),u=typeof l.body=="string"?new TextEncoder().encode(l.body):l.body;if(c==="finalcut-fcpxmld"){for(let[f,d]of Object.entries(rp(u)))f.endsWith("/")||r.push({filename:f,bytes:d,text:!0});for(let f of l.issues??[])o.push(`${c}: ${f.message}`);continue}r.push({filename:l.filenameSuggestion,bytes:u,text:sne.has(c)});for(let f of l.issues??[])o.push(`${c}: ${f.message}`)}return{timelineFile:r.length?{bytes:r[0].bytes,filename:r[0].filename,isConversion:!0}:void 0,sourceFiles:i,exchangeFiles:r.slice(1),issues:o}}function cne(e,t){let n=t.filter(i=>i.bytes).map(i=>({dest_file:i.path,dest_offset:0,length:i.bytes.length,source:{kind:"inline",bytes:i.bytes}}));return n.length?{...e,regions:[...e.regions,...n],dest_files:[...new Set([...e.dest_files,...n.map(i=>i.dest_file)])],total_bytes:e.total_bytes+n.reduce((i,r)=>i+r.length,0)}:e}var oZ=(e,t,n,i)=>["deliver",...t.length?["untrimmable"]:[],...n.length?["skipped"]:[],...e.length?["capability"]:[],...i?[]:["iso_unverified"]];async function aZ(e,t,n){let{files:i,skipped:r}=await rZ(e,{only_linked:n.only_linked});if(!i.size)throw new Error(`nothing to deliver \u2014 no linked media on this machine${r.length?`:
131
+ - ${r.join(`
132
+ - `)}`:""}`);let o=n.volume_name??ae(n.out_path),a=await iZ(e,t,n.timeline_formats),{entries:s}=j7(e,i,{volumeName:o,preserveStructure:n.preserve_structure,timelineFile:a.timelineFile,sourceFiles:a.sourceFiles,exchangeFiles:a.exchangeFiles,handles:n.handles}),c={format:"folder",volume_name:o,folder_layout:"canonical-i2o",per_file_mode:{mode:"trim"},handles:n.handles},l=vm(e,c),u=[...i.keys()].filter(Va),f=u.length?{...e,media_references:(e.media_references??[]).filter(g=>!Va(ae(g.target_url??"")))}:e,d=await xg(l,i,f,c),m=[];if(u.length){let g=new Map;for(let k of l.regions){let S=ae(k.dest_file);Va(S)&&g.set(S,k.dest_file)}let y=U7(e),w=A7(e),x=await tZ({parts:u.map(k=>({basename:k,destPathHint:g.get(k)??`02_MEDIA/${k}`,file:i.get(k)})),planClip:async k=>{let S=w.get(k[0].basename),M=Jj(S?y.get(S.id)??[]:[],S,S?.source_fps??24),L=await Yo(N6(k.map(P=>P.file)),{verb:"trim",selection:{items:M,handles:n.handles}});return eZ(L)}});m=x.dropped??[];let z=[...d.regions.filter(k=>!Va(ae(k.dest_file))),...x.regions];d={...d,regions:z,total_bytes:z.reduce((k,S)=>k+S.length,0),dest_files:[...new Set(z.map(k=>k.dest_file))],source_basenames:[...new Set(z.map(k=>k.source.kind==="file"?k.source.basename:"").filter(Boolean))]}}d=cne(d,s);let p=d.regions.filter(g=>g.source.kind!=="file"||i.has(g.source.basename));d={...d,regions:p,dest_files:[...new Set(p.map(g=>g.dest_file))],total_bytes:p.reduce((g,y)=>g+y.length,0)},await vt(n.out_path);let b=await new Pg({layout:d,files:i,sink:Qj(n.out_path)}).execute(),h=[...d.untrimmable??[],...m],v=[...i.values()].reduce((g,y)=>g+y.size,0);return{text:[`delivered ${d.dest_files.length} file(s), ${(b.bytesWritten/1e6).toFixed(1)} MB (sources ${(v/1e6).toFixed(1)} MB) \u2192 ${n.out_path}`,...d.dest_files.map(g=>`- ${g}`),...a.issues.length?["timeline capability issues:",...a.issues.map(g=>` - ${g}`)]:[],...h.length?["not shipped (could not be trimmed \u2014 never shipped whole):",...h.map(g=>` - ${g.basename}: ${g.reason}`)]:[],...r.length?["skipped:",...r.map(g=>` - ${g}`)]:[]].join(`
133
+ `),files:d.dest_files.length,bytes:b.bytesWritten,keys:oZ(a.issues,h,r,!0)}}async function sZ(e,t,n){let{files:i,skipped:r}=await rZ(e,{only_linked:n.only_linked});if(!i.size)throw new Error(`nothing to deliver \u2014 no linked media on this machine${r.length?`:
134
+ - ${r.join(`
135
+ - `)}`:""}`);let o=n.out_path.toLowerCase().endsWith(".iso")?n.out_path:_(n.out_path,`${n.volume_name??ae(t,Pr(t))}.iso`),a=n.volume_name??ae(o,".iso"),s=await iZ(e,t,n.timeline_formats),{entries:c,pinSectorByPath:l}=j7(e,i,{volumeName:a,preserveStructure:n.preserve_structure,timelineFile:s.timelineFile,sourceFiles:s.sourceFiles,exchangeFiles:s.exchangeFiles,handles:n.handles}),u={format:"iso",volume_name:a,per_file_mode:nZ("sparse"),handles:n.handles},f=_j(e),{payload:d}=await $j({session:e,layoutIntent:u,writtenAt:new Date(f).toISOString()}),m=await xg(vm(e,u),i,e,u,{entries:c,pinSectorByPath:l,iuvd:d,buildTimestamp:f}),p=m.image_total_bytes??m.total_bytes;await vt(Yn(o));let b=await new Sg({layout:m,files:i,totalBytes:p,sink:await Kj(o)}).execute(),h=await Ej(await sr.open(o)).catch(()=>null),v=m.untrimmable??[],g=[...i.values()].reduce((y,w)=>y+w.size,0);return{text:[`wrote ${o}: ${(p/1e6).toFixed(1)} MB image, ${(b.bytesWritten/1e6).toFixed(1)} MB real data (sources ${(g/1e6).toFixed(1)} MB), volume "${a}"${h?", IUVD verified":", IUVD readback FAILED"}`,...[...new Set(m.dest_files)].map(y=>`- ${y}`),...s.issues.length?["timeline capability issues:",...s.issues.map(y=>` - ${y}`)]:[],...v.length?["not shipped (could not be planned \u2014 never shipped whole):",...v.map(y=>` - ${y.basename}: ${y.reason}`)]:[],...r.length?["skipped:",...r.map(y=>` - ${y}`)]:[]].join(`
136
+ `),path:o,bytes:p,keys:oZ(s.issues,v,r,!!h)}}var B7=16;function cZ(e,t,n,i=An){for(let l of e){if(delete l.unreproducible,l.kind!=="a-source"||l.aIn==null)continue;let u=Math.min(32,l.count),f=0,d=0;for(let p=0;p<u;p++){let b=u===1?l.count>>1:Math.round(p*(l.count-1)/(u-1)),h=t[l.aIn+b],v=n[l.recordIn+b];!h||!v||(f++,fn(h,v)>i&&d++)}let m=0;for(let p=1;p<l.count;p++){let b=n[l.recordIn+p-1],h=n[l.recordIn+p],v=t[l.aIn+p-1],g=t[l.aIn+p];!b||!h||!v||!g||fn(h,b)<=B7&&fn(g,v)>B7&&m++}if(f>0&&(d>0||m>0)){let p=[];d>0&&p.push(d===f?"none of the sampled frames match the source frames this event names":`${d} of ${f} sampled frames do not match the source frames this event names`),m>0&&p.push(`${m} record frame(s) repeat where the named source frames advance \u2014 a hold this event cannot source`),l.unreproducible={checked:f,failed:d+m,note:p.join("; ")}}}let o=2,a=e.filter(l=>l.kind==="a-source"&&l.aIn!=null),s=[],c=()=>{if(s.length>o)for(let l of s){let u="source frames run backwards across this span \u2014 a reverse no a-source event can express";l.unreproducible=l.unreproducible?{...l.unreproducible,note:`${l.unreproducible.note}; ${u}`}:{checked:s.length,failed:s.length,note:u}}s=[]};for(let l=1;l<a.length;l++){let u=a[l-1],f=a[l];f.recordIn===u.recordOut&&f.aIn<u.aIn?(s.length===0&&s.push(u),s.push(f)):c()}return c(),e}var Y7=3;function lZ(e,t,n,i=Y7){let r=[];for(let c of e.ops)c.op==="equal"||c.op==="move"?r.push({kind:"a-source",recordIn:c.bStart,count:c.count,aIn:c.aStart}):c.op==="insert"&&r.push({kind:"hole",recordIn:c.bStart,count:c.count});r.sort((c,l)=>c.recordIn-l.recordIn);for(let c=0;c<r.length;c++){let l=r[c];if(l.kind!=="a-source"||l.count>=i)continue;let u=c===0||r[c-1].kind==="hole",f=c===r.length-1||r[c+1].kind==="hole";u&&f&&(l.kind="hole",l.aIn=void 0)}let o=[];for(let c of r){let l=o[o.length-1];l&&l.kind==="hole"&&c.kind==="hole"?l.count+=c.count:o.push({...c})}let a=c=>t.fps?zi(t.startFrame+c,t.fps,t.dropFrame):"",s=c=>n.fps?zi(n.startFrame+c,n.fps,n.dropFrame):"";return o.map((c,l)=>{let u=c.recordIn+c.count,f={index:l+1,kind:c.kind,count:c.count,recordIn:c.recordIn,recordOut:u,recordInTc:s(c.recordIn),recordOutTc:s(u)};return c.kind==="a-source"&&c.aIn!=null&&(f.aIn=c.aIn,f.aOut=c.aIn+c.count,f.aInTc=a(c.aIn),f.aOutTc=a(c.aIn+c.count)),f})}function uZ(e){let t={aSource:0,hole:0};for(let n of e)n.kind==="hole"?t.hole+=n.count:t.aSource+=n.count;return t}function K7(e,t="AX"){return e.replace(/\.[^.]+$/,"").replace(/[^A-Za-z0-9]/g,"").toUpperCase().slice(0,8)||t}function fZ(e,t,n){let i=n?.title??"QC RECONFORM",r=K7(n?.aReel??"AX"),o=(n?.aReel??"").replace(/[\r\n]+/g," ").trim(),a=t.fps??24,s=Jc(a,t.dropFrame)?"DROP FRAME":"NON-DROP FRAME",c=zi(0,a,t.dropFrame),l=[`TITLE: ${i}`,`FCM: ${s}`],u=0;for(let f of e){u++;let d=String(u).padStart(3,"0");if(f.kind==="hole"){let m=zi(f.count,a,t.dropFrame);l.push(`${d} ${"BL".padEnd(8)} V C ${c} ${m} ${f.recordInTc} ${f.recordOutTc}`),l.push(`* NEW MATERIAL (${f.count} frames)`)}else l.push(`${d} ${r.padEnd(8)} V C ${f.aInTc} ${f.aOutTc} ${f.recordInTc} ${f.recordOutTc}`),o&&l.push(`* FROM CLIP NAME: ${o}`),f.unreproducible&&(l.push(`* CHECK BY EYE \u2014 ${f.unreproducible.note.toUpperCase()}`),l.push("* THIS EVENT MAY NOT REBUILD THE CUT (HOLD / REVERSE / RETIME NOT EXPRESSIBLE)"))}return l.join(`\r
137
+ `)+`\r
138
+ `}function lne(e){return/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function dZ(e){let t=[["#","kind","rec_in","rec_out","A_in","A_out","frames"]];for(let n of e)t.push([String(n.index),n.kind==="hole"?"HOLE":"A-SOURCE",n.recordInTc,n.recordOutTc,n.aInTc??"",n.aOutTc??"",String(n.count)]);return t.map(n=>n.map(lne).join(",")).join(`\r
139
+ `)+`\r
140
+ `}var Q7=["only_in_a","only_in_b","different_file","same_name_different_clip","source_tc"],Lc=e=>e.fps_den?e.fps_num/e.fps_den:e.fps_num,une=e=>e.replace(/^file:\/\//,"").split(/[\\/]/).pop()??e;function kg(e,t){let n=e.timelines??[],i=t?n.find(r=>r.id===t):n.find(r=>r.kind==="primary"&&r.tracks?.some(o=>o.items?.length))??n[0];if(!i)throw new ze("not_found",t?`no timeline ${t} (timelines: ${n.map(r=>`${r.id} "${r.name}"`).join(", ")})`:"the session has no timeline");return i}function Tg(e,t){let n=e.start_frame??0,i=[];for(let a of t)if(a.enabled!==!1)for(let s of a.items){if(s.kind!=="clip"||s.enabled===!1||!s.timeline_range.duration.value)continue;let c=n+s.timeline_range.start.value;i.push({s:c,e:c+s.timeline_range.duration.value,it:s,track:Ei(a,e.tracks),z:a.track_index??0})}let r=[...new Set(i.flatMap(a=>[a.s,a.e]))].sort((a,s)=>a-s),o=[];for(let a=0;a+1<r.length;a++){let[s,c]=[r[a],r[a+1]],l;for(let u of i)u.s<=s&&u.e>=c&&(!l||u.z>=l.z)&&(l=u);l&&o.push({s,e:c,it:l.it,track:l.track})}return o}function mZ(e,t,n,i){let r=e.it,o=r.media_reference_id?i.get(r.media_reference_id):void 0,a=o?.local_path??o?.target_url??null,s=r.source_range?.start.rate||Lc(n),c=o?.source_fps||s,l=o?.source_timecode?Kn(o.source_timecode,c)??0:0,u=(n.start_frame??0)+r.timeline_range.start.value,f=(r.speed??100)/100*(r.speed_reverse?-1:1),d=(r.source_range?.start.value??0)+(t-u)*f*s/Lc(n),m=Math.round(l+d*c/s);return{item_id:r.id,track:e.track,file:a?une(a):r.name??"(unnamed)",path:a,reel:o?.reel_name??r.reel_name??null,file_tc:o?.source_timecode??null,file_frames:o?.available_range?.duration?.value??o?.declared_duration?.value??null,src_tc:tn(m,c,!!o?.source_timecode?.includes(";")),src_frame:m,rate:c}}function fne(e,t){if(!e&&!t)return null;if(!t)return{kind:"only_in_a",note:"A has picture here, B has none"};if(!e)return{kind:"only_in_b",note:"B has picture here, A has none (missing from A)"};let n=e.file.toLowerCase(),i=t.file.toLowerCase();if(n!==i)return{kind:"different_file",note:`${e.reel&&t.reel&&e.reel===t.reel?"same reel, ":""}different file; source TC ${e.src_tc} vs ${t.src_tc}${Math.abs(e.src_frame-t.src_frame)>1440?" (different TC base: temp vs master?)":""}`};if(e.file_tc&&t.file_tc&&e.file_tc!==t.file_tc||e.file_frames!=null&&t.file_frames!=null&&e.file_frames!==t.file_frames)return{kind:"same_name_different_clip",note:`same name, different clip: file TC ${e.file_tc??"?"} vs ${t.file_tc??"?"}, ${e.file_frames??"?"} vs ${t.file_frames??"?"} fr${e.path!==t.path?" (different folders)":""}`};let r=t.src_frame-e.src_frame;return r?{kind:"source_tc",note:`same file, source ${r>0?"+":""}${r} fr (A ${e.src_tc}, B ${t.src_tc})`}:null}function hZ(e,t,n={}){let i=kg(e,n.a_timeline_id),r=kg(t,n.b_timeline_id),o=Lc(i),a=Lc(r);if(Math.abs(o-a)>.001)throw new ze("invalid_args",`the timelines run at different rates (${o} vs ${a} fps); record TC cannot be aligned frame for frame`);let s=new Map((e.media_references??[]).map(m=>[m.id,m])),c=new Map((t.media_references??[]).map(m=>[m.id,m])),l=m=>m.tracks.filter(p=>p.kind==="Video"),u=[];if(n.by_track){let m=new Set([...l(i).map(p=>Ei(p,i.tracks)),...l(r).map(p=>Ei(p,r.tracks))]);for(let p of m)u.push({name:p,a:l(i).filter(b=>Ei(b,i.tracks)===p),b:l(r).filter(b=>Ei(b,r.tracks)===p)})}else u.push({name:"top",a:l(i),b:l(r)});let f=m=>tn(m,o,!!i.is_drop_frame),d=[];for(let m of u){let p=Tg(i,m.a),b=Tg(r,m.b),h=[...new Set([...p,...b].flatMap(g=>[g.s,g.e]))].sort((g,y)=>g-y),v=(g,y)=>g.find(w=>w.s<=y&&w.e>y);for(let g=0;g+1<h.length;g++){let[y,w]=[h[g],h[g+1]],x=v(p,y),T=v(b,y),z=x?mZ(x,y,i,s):null,k=T?mZ(T,y,r,c):null,S=fne(z,k);if(!S)continue;let M=d[d.length-1];if(M&&M.lane===m.name&&M.rec_out===y&&M.kind===S.kind&&M.a?.item_id===z?.item_id&&M.b?.item_id===k?.item_id){M.rec_out=w,M.rec_out_tc=f(w),M.frames=w-M.rec_in;continue}d.push({lane:m.name,kind:S.kind,rec_in:y,rec_out:w,rec_in_tc:f(y),rec_out_tc:f(w),frames:w-y,a:z,b:k,note:S.note})}}return{ranges:d,ta:i,tb:r,lanes:u.map(m=>m.name)}}var pZ=e=>e?`${e.file} @ ${e.src_tc} [${e.track} ${e.item_id}]`:"(nothing)";function bZ(e,t,n,i){let r=Q7.map(l=>[l,e.ranges.filter(u=>u.kind===l).length]).filter(([,l])=>l),o=e.ranges.length?`${e.ranges.length} record range${e.ranges.length===1?"":"s"} differ in source between A and B (${r.map(([l,u])=>`${u} ${l}`).join(", ")})`:`no source differences: A and B show the same source on every record frame (${e.lanes.join(", ")})`,a=e.ranges.slice(0,i),s=e.ranges.length>a.length?`TRUNCATED: showing ${a.length} of ${e.ranges.length} ranges \u2014 NOT the full list. Pass limit=${e.ranges.length}, or csv_path for all.
141
+ `:"",c=a.map(l=>`- ${l.lane==="top"?"":`${l.lane} `}${l.rec_in_tc}\u2013${l.rec_out_tc} (${l.frames} fr) ${l.kind}: A ${pZ(l.a)} | B ${pZ(l.b)} \u2014 ${l.note}`);return`${s}${o}
142
+ A: ${t} "${e.ta.name}"
143
+ B: ${n} "${e.tb.name}"
144
+ compared: ${e.lanes[0]==="top"?"topmost enabled video clip per record frame":`per video track (${e.lanes.join(", ")})`}; record TC from each timeline's start TC; out exclusive${c.length?`
145
+ ${c.join(`
146
+ `)}`:""}`}var dne=e=>{let t=e==null?"":String(e);return/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t};function gZ(e){let t=["lane","kind","rec_in_tc","rec_out_tc","frames","a_file","a_src_tc","a_file_tc","a_track","a_item","a_path","b_file","b_src_tc","b_file_tc","b_track","b_item","b_path","note"],n=e.map(i=>[i.lane,i.kind,i.rec_in_tc,i.rec_out_tc,i.frames,i.a?.file,i.a?.src_tc,i.a?.file_tc,i.a?.track,i.a?.item_id,i.a?.path,i.b?.file,i.b?.src_tc,i.b?.file_tc,i.b?.track,i.b?.item_id,i.b?.path,i.note]);return[t,...n].map(i=>i.map(dne).join(",")).join(`
147
+ `)+`
148
+ `}function vZ(e,t){let n=Lc(e.tb),i=!!e.tb.is_drop_frame,r=a=>tn(a,n,i),o=[`TITLE: ${t}`,`FCM: ${i?"DROP FRAME":"NON-DROP FRAME"}`];return e.ranges.forEach((a,s)=>{let c=String(s+1).padStart(3,"0");if(!a.b){o.push(`${c} ${"BL".padEnd(8)} V C ${r(0)} ${r(a.frames)} ${a.rec_in_tc} ${a.rec_out_tc}`,`* ${a.kind.toUpperCase()}: B HAS NO PICTURE HERE`);return}o.push(`${c} ${K7(a.b.reel??a.b.file).padEnd(8)} V C ${a.b.src_tc} ${tn(a.b.src_frame+Math.round(a.frames*a.b.rate/n),a.b.rate,a.b.src_tc.includes(";"))} ${a.rec_in_tc} ${a.rec_out_tc}`,`* FROM CLIP NAME: ${a.b.file}`,`* ${a.kind.toUpperCase()}: ${a.note.toUpperCase()}`)}),o.join(`\r
149
+ `)+`\r
150
+ `}function yZ(e,t){let n=structuredClone(e),i=n.timelines.find(o=>o.id===t.tb.id);n.timelines=[i];let r=new Set(t.ranges.map(o=>o.b?.item_id).filter(Boolean));for(let o of i.tracks)o.items=o.kind==="Video"?o.items.filter(a=>r.has(a.id)):[];return i.name=`${i.name} \u2014 source diff`,n}async function wZ(e){let t=Ut("CONFORM_PYTHON")??"python3",i=[Fr(new URL("./cadence_repair.py",import.meta.url)),"--plate",e.plate,"--render",e.render];e.out_path&&i.push("--out",e.out_path),e.plate_start&&i.push("--plate-start",String(e.plate_start)),e.plate_frames&&i.push("--plate-frames",String(e.plate_frames)),e.mask&&i.push("--mask",e.mask.join(",")),e.plan_only&&i.push("--plan-only"),e.force&&i.push("--force");let r=await Mn(t,i,{env:{OMP_NUM_THREADS:"1"}}),o=r.stdout.trim().split(`
151
+ `).pop()??"";if(!r.success||!o.startsWith("{"))throw new Error(`cadence repair failed: ${r.stderr.trim().split(`
152
+ `).slice(-4).join(" | ")}`);return JSON.parse(o)}function xZ(e){let t=e.gaps.reduce((i,r)=>i+r.missing,0),n=[`${e.status}: render ${e.render.frames} frames \u2192 ${e.output_frames} (plate ${e.plate.frames} from frame ${e.plate.start})`,`held frames cut (${e.held_frames.length}): ${e.held_frames.join(", ")||"none"}`];if(e.real_pauses_kept.length&&n.push(`kept as real pauses (the plate pauses too): ${e.real_pauses_kept.join(", ")}`),n.push(`skipped source frames (${t}): ${e.gaps.map(i=>`after render ${i.after_render_frame} \u2192 plate ${i.plate_frames.join("/")}`).join("; ")||"none"}`),e.repace.detected&&n.push(`RE-PACE: render frames ${e.repace.runs.fast.map(([i,r])=>`${i}\u2013${r}`).join(", ")} race ahead of the plate. ${e.repace.note}`),e.repace.runs.slow.length&&n.push(`slower than the plate (reported only): ${e.repace.runs.slow.map(([i,r])=>`${i}\u2013${r}`).join(", ")}`),e.wrote){n.push(`wrote ${e.wrote} (${e.frames_written} frames); RIFE frames at output ${e.rife_output_frames?.join(", ")||"none"}`);let i=e.motion_flags??[];n.push(i.length?`motion vs plate flagged (${i.length}): ${i.map(r=>`${r.output_frame} ${r.kind} ${r.vs_plate}\xD7`).join(", ")}`:"motion vs plate: no dips or jumps")}return n.join(`
153
+ `)}async function Xc(e){let t=await Vr();if(!t)throw new ze("unsupported","media_patch needs the native engine (conformtools-decode), which is not installed here. From a source checkout build it once: cd rust && cargo build --release -p media-native --bin conformtools-decode (or set CONFORM_NATIVE_DECODE to the binary); the npm package ships it.");let n=await Mn(t,["patch",JSON.stringify(e)]);if(n.code!==0){let i=n.stderr.trim();try{i=JSON.parse(i.split(`
154
+ `).pop()).detail}catch{}let r=/not supported|does not match|refus|outside|disagrees|no timecode|timecode mismatch|exists/.test(i);throw new ze(r?"refused":"engine",i)}return JSON.parse(n.stdout.trim().split(`
155
+ `).pop())}var e9=()=>_(wt(),"patches.jsonl"),zg=e=>`${(e/1e9).toFixed(e<1e10?2:1)} GB`;function mne(e,t){return[`layout: ${e.top_level.map(n=>n.type).join(" ")} (index at the ${e.moov_at}), ${zg(e.master_bytes)}`,` in_place grows the file by ${zg(e.in_place_grows_by)}; new needs ${zg(e.new_needs_free)} free${t!=null?` (${zg(t)} free here${t<e.new_needs_free?": NOT enough for new, in_place only if the user asks to modify the master":""})`:""}`,` chunk offsets after the write: ${e.chunk_offsets_after}; bitrate box (btrt): ${e.btrt?"present, refreshed":"none"}`,` changes: ${e.changes}`].join(`
156
+ `)}async function pne(e){if(e.in==null||e.out==null)throw new ze("invalid_args","plan needs in and out (the fixed range on the master, frames or TC)");let t=await Rn(e.path),n=t.source_fps??t.streams?.find(l=>l.kind==="video")?.rate??0,i=t.source_timecode??null,r=Jr(e.in,n,i),o=Jr(e.out,n,i);if(r<0||o<r)throw new ze("invalid_args","in/out must be inside the master, in before out");let a=await Xc({mode:"plan",master:e.path,master_in:r,frames:o-r+1}),s=l=>tn((a.master_tc_start_frame??0)+l,n),c=a.frames-(o-r+1);return{text:[`${a.codec}: render master frames ${a.span[0]}\u2013${a.span[1]} (${a.frames} frames, ${s(a.span[0])}\u2013${s(a.span[1])}) for the fix at ${r}\u2013${o}${c?` (+${c} to whole GOPs)`:""}`,`GOP ${a.gop??"?"}${a.fixed_gop?" (fixed)":" (varies)"}, ${a.b_frames?"B-frames":"no B-frames"}${a.open_gop_after?"; the GOP after the fix is open, so it is included":""}`,a.swappable?`then: ${a.render}`:`the master's GOP at ${s(a.span[0])} is open: a swap there needs a re-encode across the seam; ask before rendering`].join(`
157
+ `),data:{...a,fixed:[r,o],tc_in:s(a.span[0]),tc_out:s(a.span[1])}}}async function hne(){try{return(await Tn(e9())).split(`
158
+ `).filter(Boolean).map(e=>JSON.parse(e))}catch{return[]}}var _7=e=>`${((Number(e)||0)/1e6).toFixed(1)} MB`;async function t9(e,t){let n=e.mode??"new";if(n==="undo")return bne(e.path);if(e.patches?.length){if(n!=="in_place"&&n!=="check")throw new ze("invalid_args","patches (several at once) is for mode in_place or check; one patch per new/section file");if(e.patch||e.in!=null||e.out!=null||e.patch_in!=null)throw new ze("invalid_args","with patches, each is placed by its own TC: leave patch/in/out/patch_in out");let p=[];for(let[v,g]of e.patches.entries())t?.(v,e.patches.length,`check ${ae(g)}`),p.push(await Xc({mode:"check",master:e.path,patch:g}));let b=p.map(v=>[v.master_in,v.master_in+v.frames-1]).sort((v,g)=>v[0]-g[0]);for(let v=1;v<b.length;v++)if(b[v][0]<=b[v-1][1])throw new ze("refused",`patches overlap at master frames ${b[v][0]}\u2013${b[v-1][1]}; nothing written`);if(n==="check")return{text:`all ${p.length} patches fit: ${p.map(v=>`${v.frames} frames at ${v.master_in}`).join(", ")}
159
+ nothing written (mode=check)`,data:{plans:p}};let h=[];for(let[v,g]of e.patches.entries())t?.(v,e.patches.length,`patch ${v+1}/${e.patches.length}: ${ae(g)}`),h.push(await t9({path:e.path,patch:g,mode:n,verify:e.verify}));return t?.(e.patches.length,e.patches.length,"done"),{text:h.map(v=>v.text).join(`
160
+
161
+ `),data:{mode:n,path:e.path,patches:h.map(v=>v.data)}}}if(n==="plan")return pne(e);if(!e.patch)throw new ze("invalid_args","patch (the render of the fixed range, with record TC) is required");let i,r;if(e.in!=null||e.out!=null){let p=await Rn(e.path),b=p.source_fps??p.streams?.find(v=>v.kind==="video")?.rate??0,h=p.source_timecode??null;if(e.in!=null&&(i=Jr(e.in,b,h)),e.out!=null){if(i==null)throw new ze("invalid_args","out needs in");if(r=Jr(e.out,b,h)-i+1,r<1)throw new ze("invalid_args","out is before in")}if(i!=null&&i<0)throw new ze("invalid_args",`in is before the master's start TC (${h})`)}let o=await Xc({mode:"check",master:e.path,patch:e.patch,master_in:i,frames:r,patch_in:e.patch_in}),a=`${o.master_in}\u2013${o.master_in+o.frames-1}`,s=Pr(e.path),c=ae(e.path,s),l=async p=>{let b=e.out_path??_(Yn(e.path),p);try{(await cn(b)).isDirectory&&(b=_(b,p))}catch{}if(await Nn(b))throw new ze("refused",`${b} already exists; not overwriting (pass another out_path)`);return b},u=`${o.frames} frame${o.frames===1?"":"s"} of ${o.codec} cut in by timecode at master frames ${a} (patch frames ${o.patch_in}\u2013${o.patch_in+o.frames-1})`;if(n==="check"){let p=o.layout,b=await ep(Yn(e.path)).catch(()=>null);return{text:`patch fits: ${u}, no re-encode
162
+ ${p?mne(p,b)+`
163
+ `:""}nothing written (mode=check)`,data:{...o,free_bytes:b}}}let f={patch_in:o.patch_in,frames:o.frames};if(n==="section"){let p=await l(`${c}_patch_${a.replace("\u2013","-")}${s}`),b=await ii("conform-patch-");try{let h=_(b,`range${s}`);await Ep({path:e.path,in:o.master_in,out:o.master_in+o.frames-1,out_path:h});let v=await Xc({mode:"new",master:h,patch:e.patch,out_path:p,...f}),g=await Rn(p);return{text:`wrote section ${p}: ${u}, with the master's TC and audio, no re-encode
164
+ verified: ${$7(v)}; start TC ${g.source_timecode??"none"}`,data:{...f,master_in:o.master_in,mode:n,path:p,start_tc:g.source_timecode??null,verify:v.verify,cost:v.cost}}}finally{await Ti(b)}}if(n==="in_place"){t?.(0,1,`write + verify ${ae(e.patch)}`);let p=await Xc({mode:"in_place",master:e.path,patch:e.patch,...f,verify:e.verify??"index"}),b={...p.undo,patch:e.patch,at:new Date().toISOString()};await vt(wt()),await ln(e9(),JSON.stringify(b)+`
165
+ `,{append:!0});let h=p.cost??{};return{text:`patched ${ae(e.path)} in place: ${u}, no re-encode
166
+ verified: ${$7(p)}
167
+ cost: the file grew ${_7(h.grew_bytes)}; ${_7(h.dead_bytes)} stay as dead bytes (the replaced frames + old index, kept so undo works); the patched span now sits at the end of the file, away from its audio (mode=new rewrites the file contiguously)${h.btrt_refreshed?"; bitrate box refreshed":""}
168
+ undo: media_patch mode=undo path=${e.path} restores the original byte for byte`,data:{...f,master_in:o.master_in,mode:n,path:e.path,verify:p.verify,cost:p.cost,undo:b}}}let d=await l(`${c}_patched${s}`),m=await Xc({mode:"new",master:e.path,patch:e.patch,out_path:d,...f});return{text:`wrote ${d}: ${ae(e.path)} with ${u}, no re-encode
169
+ verified: ${$7(m)}
170
+ rewritten contiguously in the master's interleave order (${_7(m.cost?.bytes)}); the master was not touched`,data:{...f,master_in:o.master_in,mode:n,path:d,verify:m.verify,cost:m.cost}}}function $7(e){let t=e.verify??{},n=t.other_tracks_check==="index"?`${t.other_tracks} other tracks (audio/TC) untouched: every sample at its original offset and size, and the write never reached them (verify=full re-reads and hashes them)`:`${t.other_tracks} other tracks (audio/TC) hash-identical`;return`${t.frames} frames, the master's TC track unchanged, ${t.patched_frames_identical} frames at the patch's TC byte-identical to the patch (ends decode to the patch's pixels), frames either side are the master's (${(t.splice??[]).filter(i=>!i.is.startsWith("patch")).map(i=>i.frame).join(", ")||"none: the span is the whole file"}), ${n}`}async function bne(e){let t=await hne(),n=(await cn(e)).size,i=t.findLastIndex(o=>o.path===e&&o.size_after===n);if(i<0){let o=t.some(a=>a.path===e);throw new ze(o?"refused":"not_found",o?`${ae(e)} changed since its last in-place patch (size ${n}); nothing undone`:`no in-place patch of ${ae(e)} on record`)}let r=t[i];return await Xc({mode:"undo",record:r}),t.splice(i,1),await ln(e9(),t.map(o=>JSON.stringify(o)+`
171
+ `).join("")),{text:`undid the in-place patch of ${ae(e)} (master frames ${r.master_in}\u2013${r.master_in+r.frames-1}): the file is byte-identical to before it`,data:{mode:"undo",path:e,undone:r}}}function PZ(e,t,n){let i=new Float64Array(t*n),r=new Float64Array(t*n);for(let a=0;a<e.h;a++){let s=Math.min(n-1,a*n/e.h|0)*t;for(let c=0;c<e.w;c++){let l=s+Math.min(t-1,c*t/e.w|0);i[l]+=e.y[a*e.w+c],r[l]++}}let o=new Uint16Array(t*n);for(let a=0;a<o.length;a++)o[a]=Math.round(16*i[a]/(r[a]||1));return o}var gne=Math.max(2,Math.min(12,Po()-4)),SZ=typeof Worker<"u",Lu=null,Mg=new Map,kZ=1;function TZ(){return Lu||(Lu=Array.from({length:gne},()=>{let e=new Worker(new URL("./decode-worker.ts",import.meta.url).href,{type:"module"}),t={w:e,busy:0};return e.onmessage=n=>{let i=Mg.get(n.data.id);i&&(Mg.delete(n.data.id),i.slot.busy--,n.data.ok?i.res(n.data.g??{y:n.data.y,w:n.data.w,h:n.data.h}):i.rej(new Error(n.data.why)))},t}),Lu)}var vne=(e,t,n,i,r)=>{let o=e.path;if(!o)return ja(e,t,n,i,r).then(c=>Qo(c,i,r));let a=TZ().reduce((c,l)=>l.busy<c.busy?l:c),s=kZ++;return a.busy++,new Promise((c,l)=>{Mg.set(s,{res:c,rej:l,slot:a}),a.w.postMessage({id:s,path:o,offset:t,size:n,spec:i,tier:r})})};function zZ(e,t,n,i,r,o,a){if(!SZ)return sr.open(e).then(async l=>PZ(Qo(await ja(l,t,n,i,r),i,r),o,a));let s=TZ().reduce((l,u)=>u.busy<l.busy?u:l),c=kZ++;return s.busy++,new Promise((l,u)=>{Mg.set(c,{res:l,rej:u,slot:s}),s.w.postMessage({id:c,path:e,offset:t,size:n,spec:i,tier:r,grid:[o,a]})})}function MZ(){SZ&&Iv(vne)}function OZ(){Iv(null);for(let e of Lu??[])e.w.terminate();Lu=null}var Lg=640,XZ=100,NZ=.03,n9=67,yne=7,LZ=3;function Og(e,t,n,i){let r=new Float32Array(e.length),o=new Float32Array(e.length),a=2*i+1;for(let s=0;s<n;s++){let c=0;for(let l=-i;l<=i;l++)c+=e[s*t+Math.min(t-1,Math.max(0,l))];for(let l=0;l<t;l++)r[s*t+l]=c/a,c+=e[s*t+Math.min(t-1,l+i+1)]-e[s*t+Math.max(0,l-i)]}for(let s=0;s<t;s++){let c=0;for(let l=-i;l<=i;l++)c+=r[Math.min(n-1,Math.max(0,l))*t+s];for(let l=0;l<n;l++)o[l*t+s]=c/a,c+=r[Math.min(n-1,l+i+1)*t+s]-r[Math.max(0,l-i)*t+s]}return o}function Ng(e,t,n=Lg){let i=e?Math.round(n*e.h/e.w):0,r=jn(e,n,i);if(!r)return[];let o=Og(r,n,i,1),a=new Float32Array(n*i),s=new Float32Array(n*i),c=new Float32Array(n*i);for(let h=1;h<i-1;h++)for(let v=1;v<n-1;v++){let g=h*n+v,y=o[g+1]-o[g-1],w=o[g+n]-o[g-n];a[g]=y*y,s[g]=w*w,c[g]=y*w}let l=Og(a,n,i,2),u=Og(s,n,i,2),f=Og(c,n,i,2),d=new Float32Array(n*i);for(let h=0;h<n*i;h++)d[h]=l[h]*u[h]-f[h]*f[h]-.05*(l[h]+u[h])**2;let m=[],p=6,b=Math.max(p,Math.round(n/64));for(let h=b;h<i-b;h++)for(let v=b;v<n-b;v++){let g=d[h*n+v];if(g<=0)continue;let y=!0;for(let w=-p;w<=p&&y;w++)for(let x=-p;x<=p;x++)if(d[(h+w)*n+v+x]>g){y=!1;break}y&&m.push([g,v,h])}return m.sort((h,v)=>v[0]-h[0]).slice(0,t).map(([,h,v])=>[h*Lg/n,v*Lg/n])}function r9(e){let t=e.length,n=[],i=new Set,r=Math.min(yne+1,t),o=new Float64Array(t),a=Array.from({length:t},(u,f)=>f),s=new Array(r),c=new Array(4),l=[0,0,0,0];for(let u=0;u<t;u++){for(let f=0;f<t;f++)o[f]=(e[f][0]-e[u][0])**2+(e[f][1]-e[u][1])**2;for(let f=0;f<t;f++)a[f]=f;for(let f=0;f<r;f++){let d=f;for(let p=f+1;p<t;p++){let b=a[p],h=a[d];(o[b]<o[h]||o[b]===o[h]&&b<h)&&(d=p)}let m=a[f];a[f]=a[d],a[d]=m,s[f]=a[f]}for(let f=0;f<r;f++)for(let d=f+1;d<r;d++)for(let m=d+1;m<r;m++)for(let p=m+1;p<r;p++){l[0]=s[f],l[1]=s[d],l[2]=s[m],l[3]=s[p],l.sort((k,S)=>k-S);let b=((l[0]*128+l[1])*128+l[2])*128+l[3];if(i.has(b))continue;i.add(b);for(let k=0;k<4;k++)c[k]=e[l[k]];let h=-1,v=0,g=1;for(let k=0;k<4;k++)for(let S=k+1;S<4;S++){let M=(c[k][0]-c[S][0])**2+(c[k][1]-c[S][1])**2;M>h&&(h=M,v=k,g=S)}if(h<400)continue;let y=[0,1,2,3].filter(k=>k!==v&&k!==g),w=(k,S)=>{let M=S[0]-k[0],L=S[1]-k[1],P=M*M+L*L;return y.map(X=>{let R=c[X][0]-k[0],I=c[X][1]-k[1],q=(R*M+I*L)/P,Y=(-R*L+I*M)/P;return[q-Y,q+Y]})},x=c[v],T=c[g],z=w(x,T);z[0][0]+z[1][0]>1&&([x,T]=[T,x],z=w(x,T)),z.sort((k,S)=>k[0]-S[0]),n.push({code:[z[0][0],z[0][1],z[1][0],z[1][1]],a:x,b:T})}}return n}var RZ=e=>{let t=[e[1],e[0],e[3],e[2]];return t[0]>t[2]?[t[2],t[3],t[0],t[1]]:t},Xg=e=>{let t=0;for(let n of e)t=t*n9+Math.max(0,Math.min(n9-1,Math.round(n/NZ)+17));return t};function wne(e,t,n,i,r){let o=new Map;for(let f of i){let d=Xg(f.code);(o.get(d)??o.set(d,[]).get(d)).push(f)}let a=new Map;for(let f of n){let d=Math.round(f[0]/4)*4096+Math.round(f[1]/4);(a.get(d)??a.set(d,[]).get(d)).push(f)}let s=(f,d)=>{let m=Math.round(f/4),p=Math.round(d/4);for(let b=-1;b<=1;b++)for(let h=-1;h<=1;h++)for(let v of a.get((m+b)*4096+p+h)??[])if((v[0]-f)**2+(v[1]-d)**2<LZ*LZ)return!0;return!1},c=f=>r?[-f[0],f[1]]:f,l={inl:0,scale:0,rot:0,flip:r},u=0;for(let f of t){let d=r?RZ(f.code):f.code;for(let m of o.get(Xg(d))??[]){if(d.some((L,P)=>Math.abs(L-m.code[P])>NZ)||++u>4e3)continue;let p=c(f.a),b=c(f.b),h=b[0]-p[0],v=b[1]-p[1],g=m.b[0]-m.a[0],y=m.b[1]-m.a[1],w=h*h+v*v,x=(g*h+y*v)/w,T=(y*h-g*v)/w,z=Math.hypot(x,T);if(z<.3||z>1.2)continue;let k=m.a[0]-(x*p[0]-T*p[1]),S=m.a[1]-(T*p[0]+x*p[1]),M=0;for(let L of e){let P=c(L);s(x*P[0]-T*P[1]+k,T*P[0]+x*P[1]+S)&&M++}M/e.length>l.inl&&(l={inl:M/e.length,scale:1/z,rot:Math.atan2(T,x)*180/Math.PI,flip:r})}}return l}var i9=e=>Int32Array.from(new Set(r9(e).map(t=>Xg(t.code)))),xne=[1,1.25,1.5,1.8],km=class{constructor(){this.ents=[];this.pk=new Int32Array(65536);this.pid=new Int32Array(65536);this.n=0;this.off=null;this.post=new Int32Array(0)}add(t,n,i,r=i9(i)){let o=this.ents.length;if(this.n+r.length>this.pk.length){let a=s=>{let c=new Int32Array(Math.max(s.length*2,this.n+r.length));return c.set(s.subarray(0,this.n)),c};this.pk=a(this.pk),this.pid=a(this.pid)}for(let a of r)this.pk[this.n]=a,this.pid[this.n++]=o;this.ents.push({clip:t,frame:n,st:Float32Array.from(i.flat()),nk:r.length}),this.off=null}postings(){if(this.off)return this.off;let t=new Int32Array(n9**4+1),n=new Int32Array(this.n);for(let r=0;r<this.n;r++)t[this.pk[r]+1]++;for(let r=1;r<t.length;r++)t[r]+=t[r-1];let i=t.slice(0,-1);for(let r=0;r<this.n;r++)n[i[this.pk[r]]++]=this.pid[r];return this.post=n,this.off=t}get size(){return this.ents.length}find(t,n=40){let i=xne.map(s=>{let c=Ng(t,60,Math.round(Lg/s)).map(([l,u])=>[l/s,u/s]);return{rs:s,st:c,q:r9(c)}}),r=new Map,o=this.postings();for(let{q:s}of i)for(let c of[!1,!0]){let l=new Set(s.map(f=>Xg(c?RZ(f.code):f.code))),u=new Map;for(let f of l){let d=o[f],m=o[f+1];if(d===m)continue;let p=Math.log(this.ents.length/(m-d));for(let b=d;b<m;b++){let h=this.post[b];u.set(h,(u.get(h)??0)+p)}}for(let[f,d]of u)r.set(f,Math.max(r.get(f)??0,d/Math.sqrt(this.ents[f].nk*l.size)))}let a=null;for(let[s]of[...r].sort((c,l)=>l[1]-c[1]).slice(0,n)){let c=this.ents[s],l=Array.from({length:c.st.length/2},(f,d)=>[c.st[2*d],c.st[2*d+1]]),u=r9(l);for(let{rs:f,st:d,q:m}of i)for(let p of[!1,!0]){let b=wne(d,m,l,u,p);(!a||b.inl>a.inl)&&(a={...b,scale:b.scale*f,clip:c.clip,frame:c.frame})}}return a}};if(import.meta.main){let e=7,t=()=>(e=e*16807%2147483647)/2147483647,n=()=>{let u=new Uint8Array(518400).fill(60);for(let f=0;f<120;f++){let d=t()*960,m=t()*540,p=6+t()*30,b=120+t()*135;for(let h=Math.max(0,m|0);h<Math.min(540,m+p);h++)for(let v=Math.max(0,d|0);v<Math.min(960,d+p);v++)u[h*960+v]=b}return{y:u,w:960,h:540}},i=(c,l,u,f)=>{let{w:d,h:m}=c,p=new Uint8Array(d*m),b=Math.cos(u*Math.PI/180),h=Math.sin(u*Math.PI/180);for(let v=0;v<m;v++)for(let g=0;g<d;g++){let y=(g-d/2)/l,w=(v-m/2)/l;f&&(y=-y);let x=b*y-h*w+d/2,T=h*y+b*w+m/2;p[v*d+g]=x>=0&&T>=0&&x<d&&T<m?c.y[(T|0)*d+(x|0)]:0}return{y:p,w:d,h:m}},r=new km,o=Array.from({length:6},n);o.forEach((c,l)=>r.add(0,l,Ng(c,100)));let a=r.find(o[3]),s=r.find(i(o[4],1.5,4,!0));if(a.frame!==3||a.inl<.8)throw new Error(`plain ${JSON.stringify(a)}`);if(s.frame!==4||!s.flip||Math.abs(s.scale-1.5)>.1||s.inl<.5)throw new Error(`turned ${JSON.stringify(s)}`);console.log("plate-solve self-check ok",a.inl.toFixed(2),s.inl.toFixed(2),s.scale.toFixed(2),s.rot.toFixed(1))}var FZ=Math.max(2,Math.min(8,Po()-4)),Rg=null,Pne=0,Sne=1,o9=new Map;function VZ(e){if(typeof Worker>"u")return Promise.resolve(e.map(i9));Rg??=Array.from({length:FZ},()=>{let n=new Worker(new URL("./plate-worker.ts",import.meta.url).href,{type:"module"});return n.onmessage=i=>{o9.get(i.data.id)?.(i.data.keys),o9.delete(i.data.id)},n});let t=Sne++;return new Promise(n=>{o9.set(t,n),Rg[Pne++%FZ].postMessage({id:t,stars:e})})}function jZ(){for(let e of Rg??[])e.terminate();Rg=null}var kne=1;async function ZZ(e,t){try{let n=await cn(e);if(!n.isFile)return null;let i=JSON.stringify([kne,e,n.size,Math.round(n.mtimeMs),ae(t.model),t.stride,t.geometryWidth,...t.display?[t.display]:[]]),r=new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(i)));return Array.from(r.slice(0,16),o=>o.toString(16).padStart(2,"0")).join("")}catch{return null}}var Fg=()=>_(wt(),"cache","sscd");async function Tm(e,t){let n=await ZZ(e,t);if(!n)return null;let i;try{i=await pr(_(Fg(),`${n}.sscd`))}catch{return null}try{let r=new DataView(i.buffer,i.byteOffset,i.byteLength),[o,a,s]=[r.getUint32(0,!0),r.getUint32(4,!0),r.getUint32(8,!0)],c=new Uint32Array(i.slice(12,12+o*4).buffer),l=new Float32Array(i.slice(12+o*4,12+o*4+a*s*4).buffer);if(l.length!==a*s)return null;let u=Array.from({length:a},(f,d)=>l.subarray(d*s,(d+1)*s));return Array.from(c,f=>u[f])}catch{return null}}async function a9(e,t,n){let i=await ZZ(e,t);if(!i||!n.length)return;let r=new Map,o=new Uint32Array(n.length);n.forEach((f,d)=>{let m=r.get(f);m===void 0&&r.set(f,m=r.size),o[d]=m});let a=n[0].length,s=new Uint8Array(12+o.byteLength+r.size*a*4),c=new DataView(s.buffer);c.setUint32(0,n.length,!0),c.setUint32(4,r.size,!0),c.setUint32(8,a,!0),s.set(new Uint8Array(o.buffer),12);let l=12+o.byteLength;for(let f of r.keys())s.set(new Uint8Array(f.buffer,f.byteOffset,a*4),l),l+=a*4;await vt(Fg()),await So(_(wt(),"cache"),448);let u=_(Fg(),`${i}.${crypto.randomUUID()}.tmp`);await or(u,s),await So(u,384);try{await Gr(u,_(Fg(),`${i}.sscd`))}catch{await Er(u)}}function DZ(e){let t=()=>(e=e*1103515245+12345>>>0)/4294967296;return{rnd:t,gauss:()=>Math.sqrt(-2*Math.log(t()+1e-12))*Math.cos(2*Math.PI*t())}}var IZ=e=>(e-=e>>>1&1431655765,e=(e&858993459)+(e>>>2&858993459),(e+(e>>>4)&252645135)*16843009>>>24),zm=(e,t,n,i)=>1-(IZ(e[2*t]^n[2*i])+IZ((e[2*t+1]^n[2*i+1])&(1<<20)-1))/52;function s9(e,t,n,i){if(t<1||i<1||e.still[t]||n.still[i])return null;let r=0,o=0,a=t*1152,s=i*1152;for(let f=0;f<1152;f++)r+=e.g[a+f]-e.g[a-1152+f],o+=n.g[s+f]-n.g[s-1152+f];r/=1152,o/=1152;let c=0,l=0,u=0;for(let f=0;f<1152;f++){let d=e.g[a+f]-e.g[a-1152+f]-r,m=n.g[s+f]-n.g[s-1152+f]-o;c+=d*m,l+=d*d,u+=m*m}return l&&u?c/Math.sqrt(l*u):null}function Tne(e){let t=new Uint16Array(e.g.length);for(let n=0;n<e.n;n++){let i=n*1152;for(let r=0;r<1152;r++)t[i+r]=e.g[i+1152-1-r]}return{n:e.n,ok:e.ok,g:t}}function u9(e,t,n={}){let i=n.L??24,r=n.STRIDE??12,o=n.CANDS??8,a=n.ALTS??4,s=n.REFINE??16,c=n.PEN??4,l=n.PENHI??40,u=n.CONT??.95,f=n.SPW??4,d=n.SP0??.75,m=n.SPMIN??.8,p=n.EXT??.85,b=n.EXTALTS??2,h=n.SEGSURE??.3,v=n.ROT??!0,g=v?2:1,{rnd:y,gauss:w}=DZ(99),x=new Float32Array(32*1152);for(let K=0;K<32;K++)for(let fe=0;fe<1152/2;fe++){let Xe=w();x[K*1152+fe]=Xe,x[K*1152+1152-1-fe]=K&1?-Xe:Xe}let T=48/8,z=24/4,k=(K,fe)=>{let{n:Xe,ok:et,g:ft}=K;if(!fe&&K.feat?.mp.length===Xe*32)return{n:Xe,ok:et,g:ft,...K.feat};let At=new Uint32Array(Xe*2),Nt=new Float32Array(Xe*32),Jt=new Uint8Array(Xe),nn=new Float32Array(32),Ge=new Float32Array(1152);for(let it=0;it<Xe;it++){if(!et[it]){Jt[it]=1;continue}let Rt=it*1152;nn.fill(0);for(let je=0;je<24;je++)for(let Hn=0;Hn<48;Hn++)nn[(je/z|0)*8+(Hn/T|0)]+=ft[Rt+je*48+Hn];let rn=0,Ln=0,Sn=0,Et=je=>{rn<32?Ln|=(je>0?1:0)<<rn:Sn|=(je>0?1:0)<<rn-32,rn++};for(let je=0;je<4;je++)for(let Hn=0;Hn<7;Hn++)Et(nn[je*8+Hn]-nn[je*8+Hn+1]);for(let je=0;je<3;je++)for(let Hn=0;Hn<8;Hn++)Et(nn[je*8+Hn]-nn[(je+1)*8+Hn]);if(At[2*it]=Ln>>>0,At[2*it+1]=Sn>>>0,fe){Jt[it]=fe.still[it];for(let je=0;je<32;je++)Nt[it*32+je]=je&1?-fe.mp[it*32+je]:fe.mp[it*32+je];continue}if(it===0||!et[it-1]){Jt[it]=1;continue}let Tr=0;for(let je=0;je<1152;je++)Ge[je]=ft[Rt+je]-ft[Rt-1152+je],Tr+=Ge[je];Tr/=1152;let rr=0;for(let je=0;je<1152;je++)Ge[je]-=Tr,rr+=Ge[je]*Ge[je];if(!rr){Jt[it]=1;continue}let oo=1/Math.sqrt(rr);for(let je=0;je<32;je++){let Hn=0,Ii=je*1152;for(let Uo=0;Uo<1152;Uo++)Hn+=x[Ii+Uo]*Ge[Uo];Nt[it*32+je]=Hn*oo/Math.sqrt(32)}}return fe||(K.feat={sp:At,mp:Nt,still:Jt}),{n:Xe,ok:et,g:ft,sp:At,mp:Nt,still:Jt}},S=[],M=[];t.forEach((K,fe)=>{let Xe=k(K);S.push(Xe),M.push(n.rates?.[fe]??1),v&&(S.push(k(Tne(K),Xe)),M.push(n.rates?.[fe]??1))});let L=(K,fe)=>M[K]===1?fe:Math.floor(fe*M[K]+.001),P=k(e),X=Array.from({length:12},()=>{let K=[...Array(52).keys()];for(let fe=K.length-1;fe>0;fe--){let Xe=y()*(fe+1)|0;[K[fe],K[Xe]]=[K[Xe],K[fe]]}return K.slice(0,18)}),R=(K,fe,Xe)=>Xe<32?K[2*fe]>>>Xe&1:K[2*fe+1]>>>Xe-32&1,I=(K,fe,Xe)=>{let et=0;for(let ft of Xe)et=et*2+R(K,fe,ft);return et},q=X.map(()=>new Map);S.forEach((K,fe)=>{for(let Xe=0;Xe<K.n;Xe++)if(K.ok[Xe])for(let et=0;et<12;et++){let ft=I(K.sp,Xe,X[et]),At=q[et].get(ft);At||q[et].set(ft,At=new Map),At.set(fe,(At.get(fe)??0)+1)}});let Y=new Float32Array(P.n);for(let K=1;K<P.n;K++){if(!P.ok[K]||!P.ok[K-1])continue;let fe=0,Xe=0,et=(K-1)*1152,ft=K*1152;for(let nn=0;nn<1152;nn++)fe+=P.g[et+nn],Xe+=P.g[ft+nn];fe/=1152,Xe/=1152;let At=0,Nt=0,Jt=0;for(let nn=0;nn<1152;nn++){let Ge=P.g[et+nn]-fe,it=P.g[ft+nn]-Xe;At+=Ge*it,Nt+=Ge*Ge,Jt+=it*it}Y[K]=Nt&&Jt?At/Math.sqrt(Nt*Jt):0}let D=K=>1-Y[K],j=new Uint8Array(P.n);for(let K=2;K<P.n-1;K++){let fe=[];for(let et=-6;et<=6;et++)et&&K+et>=1&&K+et<P.n&&fe.push(D(K+et));fe.sort((et,ft)=>et-ft);let Xe=fe[fe.length>>1];D(K)>.004&&D(K)>4*Xe+.002&&D(K)>=Math.max(D(K-1),D(K+1))&&(j[K]=1)}for(let K=1;K<P.n;K++)j[K]&&(Y[K]=Math.min(Y[K],u-.001));let C=K=>K<=0||K>=P.n||Y[K]<u,H=zne(P),ne=[];for(let K=0;K+i<=P.n;K+=r)ne.push([K,i]);for(let K=0;K<P.n;){let fe=K+1;for(;fe<P.n&&!C(fe);)fe++;fe-K>=4&&fe-K<i&&ne.push([K,fe-K]),K=fe}let le=[],Se=ne.length;for(let[K,[fe,Xe]]of ne.entries()){K%25===0&&n.onProgress?.(K,Se,"align: windows");let et=new Map;for(let Ge=fe;Ge<fe+Xe;Ge++)if(P.ok[Ge])for(let it=0;it<12;it++){let Rt=q[it].get(I(P.sp,Ge,X[it]));if(!Rt)continue;let rn=1/Math.sqrt(Rt.size);for(let[Ln]of Rt)et.set(Ln,(et.get(Ln)??0)+rn)}let ft=[...et].sort((Ge,it)=>it[1]-Ge[1]).slice(0,o).map(([Ge])=>Ge);ft=[...new Set(ft.flatMap(Ge=>{let it=Ge-Ge%g;return[it-g,it,it+g].flatMap(Rt=>v?[Rt,Rt+1]:[Rt])}).filter(Ge=>Ge>=0&&Ge<S.length))];let At=fe+(Xe>>1),Nt=[];for(let Ge=fe;Ge<fe+Xe;Ge++)P.still[Ge]||Nt.push(Ge);let Jt=[];for(let Ge of ft){let it=S[Ge];for(let Rt=-L(Ge,fe);Rt+L(Ge,fe+Xe)<=it.n;Rt++){let rn=At;if(!it.ok[L(Ge,At)+Rt]){rn=-1;for(let Et=fe;Et<fe+Xe;Et++)if(it.ok[L(Ge,Et)+Rt]&&P.ok[Et]){rn=Et;break}if(rn<0)continue}if(zm(P.sp,rn,it.sp,L(Ge,rn)+Rt)<m)continue;let Ln=0,Sn=0;if(Nt.length>=4){for(let Et=0;Et<Nt.length;Et+=2){let Tr=Nt[Et],rr=L(Ge,Tr)+Rt;if(it.still[rr]){if(!it.ok[rr])continue;Sn++;continue}let oo=0,je=Tr*32,Hn=rr*32;for(let Ii=0;Ii<32;Ii++)oo+=P.mp[je+Ii]*it.mp[Hn+Ii];Ln+=oo,Sn++}if(!Sn)continue;Ln/=Sn}else{for(let Et=fe;Et<fe+Xe;Et+=4)Ln+=zm(P.sp,Et,it.sp,L(Ge,Et)+Rt),Sn++;Ln=Ln/Sn-1}Jt.push({ci:Ge,s:Rt,sc:Ln})}}Jt.sort((Ge,it)=>it.sc-Ge.sc);let nn=Jt.slice(0,s).map(Ge=>{if(Nt.length<4)return Ge;let it=0,Rt=0;for(let rn of Nt){let Ln=L(Ge.ci,rn)+Ge.s;!S[Ge.ci].ok[Ln]||!S[Ge.ci].ok[Ln-1]||(it+=s9(P,rn,S[Ge.ci],Ln)??0,Rt++)}return{...Ge,sc:Rt?it/Rt:-1}}).sort((Ge,it)=>it.sc-Ge.sc);le.push({a:fe,len:Xe,alts:[...nn,...Jt.slice(s,40)].filter((Ge,it,Rt)=>Rt.findIndex(rn=>rn.ci===Ge.ci&&Math.abs(rn.s-Ge.s)<=2)===it).slice(0,a)})}n.onProgress?.(Se,Se,"align: path");let Le=(K,fe)=>K*1e6+fe+5e5,ut=K=>({ci:Math.floor(K/1e6),d:K%1e6-5e5}),we=(K,fe,Xe)=>{let et=0,ft=0;for(let At=-1;At<=1;At++){let Nt=Xe+At,Jt=L(K,Nt)+fe;Nt<0||Nt>=P.n||Jt<0||Jt>=S[K].n||!P.ok[Nt]||!S[K].ok[Jt]||(et+=zm(P.sp,Nt,S[K].sp,Jt),ft++)}return ft?et/ft:0},De=Array.from({length:P.n},()=>new Set);for(let K of le){let fe=K.a;for(;!C(fe);)fe--;let Xe=K.a+K.len;for(;Xe<P.n&&!C(Xe);)Xe++;fe=Math.max(0,Math.min(fe,K.a-i)),Xe=Math.min(P.n,Math.max(Xe,K.a+2*i));for(let et of K.alts)for(let ft=fe;ft<Xe;ft++)De[ft].add(Le(et.ci,et.s))}let Je=new Set;for(let K of le)for(let fe of K.alts.slice(0,b)){let Xe=Le(fe.ci,fe.s);if(!Je.has(Xe)){Je.add(Xe);for(let et of[-1,1])for(let ft=et<0?K.a-i-1:K.a+2*i;ft>=0&&ft<P.n&&!(we(fe.ci,fe.s,ft)<p);ft+=et)De[ft].add(Xe)}}let be=(K,fe)=>{let{ci:Xe,d:et}=ut(fe),ft=L(Xe,K)+et,At=S[Xe];return ft<0||ft>=At.n||!At.ok[ft]||!P.ok[K]||H[K]?-1/0:f*(zm(P.sp,K,At.sp,ft)-d)+(s9(P,K,At,ft)??0)},Me=(K,fe)=>{let{ci:Xe,d:et}=ut(K),ft=S[Xe],At=L(Xe,fe)+et,Nt=L(Xe,fe-1)+et;if(Nt<0||At>=ft.n||!ft.ok[At]||!ft.ok[Nt])return 0;let Jt=0,nn=0,Ge=Nt*1152,it=At*1152;for(let Sn=0;Sn<1152;Sn++)Jt+=ft.g[Ge+Sn],nn+=ft.g[it+Sn];Jt/=1152,nn/=1152;let Rt=0,rn=0,Ln=0;for(let Sn=0;Sn<1152;Sn++){let Et=ft.g[Ge+Sn]-Jt,Tr=ft.g[it+Sn]-nn;Rt+=Et*Tr,rn+=Et*Et,Ln+=Tr*Tr}return rn&&Ln?Rt/Math.sqrt(rn*Ln):0},Oe=new Map([[-1,0]]),bt=[],tt=[];for(let K=0;K<P.n;K++){let fe=-1,Xe=-1/0;for(let[Nt,Jt]of Oe)Jt>Xe&&(Xe=Jt,fe=Nt);let et=new Map,ft=new Map,At=new Map;for(let Nt of[-1,...De[K]]){let Jt=Nt===-1?0:be(K,Nt);if(Jt===-1/0)continue;At.set(Nt,Jt);let nn=Y[K]<u&&Nt!==-1&&Me(Nt,K)>=u?l:0,Ge=(Oe.get(Nt)??-1/0)-nn,it=Xe-(Y[K]>=u?l:c);Ge>=it?(et.set(Nt,Ge+Jt),ft.set(Nt,Nt)):(et.set(Nt,it+Jt),ft.set(Nt,fe))}bt.push(ft),tt.push(At),Oe=et}let zt=-1,Ht=-1/0;for(let[K,fe]of Oe)fe>Ht&&(Ht=fe,zt=K);let Mt=new Array(P.n);for(let K=P.n-1;K>=0;K--)Mt[K]=zt,zt=bt[K].get(zt)??-1;let mt=[];for(let K=0;K<P.n;){let fe=K;for(;fe<P.n&&Mt[fe]===Mt[K];)fe++;let Xe=Mt[K];if(Xe===-1)mt.push({refStart:K,refEnd:fe-1,clip:-1,srcStart:0,srcEnd:0,rot180:!1,conf:0,sure:!1});else{let{ci:et,d:ft}=ut(Xe),At=new Map,Nt=0;for(let Ge=K;Ge<fe;Ge++){Nt+=tt[Ge].get(Xe)??0;for(let[it,Rt]of tt[Ge]){if(it===-1)continue;let rn=ut(it);rn.ci===et&&Math.abs(rn.d-ft)<=2||At.set(it,(At.get(it)??0)+Rt)}}let Jt=(Nt-Math.max(0,...At.values()))/(fe-K),nn=L(et,K)+ft;{let Ge=-1/0,it=Math.ceil(2*M[et]);for(let Rt=nn-it;Rt<=nn+it;Rt++){let rn=0;for(let Ln=K;Ln<fe;Ln++){let Sn=Rt+Math.floor((Ln-K)*M[et]+.001),Et=S[et];Sn>=1&&Sn<Et.n&&Et.ok[Sn]&&(rn+=f*zm(P.sp,Ln,Et.sp,Sn)+(s9(P,Ln,Et,Sn)??0))}rn>Ge&&(Ge=rn,nn=Rt)}}mt.push({refStart:K,refEnd:fe-1,clip:Math.floor(et/g),srcStart:nn,srcEnd:nn+Math.floor((fe-1-K)*M[et]+.001),rot180:v&&et%2===1,conf:Jt,sure:Jt>=h})}K=fe}return Lne(mt,P,t,M,H,n),mt}function zne(e){let t=new Uint8Array(e.n);for(let n=0;n<e.n;n++){if(!e.ok[n])continue;let i=0,r=0,o=n*1152;for(let a=0;a<1152;a++)i+=e.g[o+a];i/=1152;for(let a=0;a<1152;a++)r+=(e.g[o+a]-i)**2;Math.sqrt(r/1152)<32&&(t[n]=1)}return t}var Mne=[1.15,1.3,1.5,1.75,2];function c9(e,t,n,i,r=48,o=24){let a=new Float32Array(n*i),s=new Float32Array(n*i);for(let f=0;f<o;f++){let d=Math.min(i-1,f*i/o|0);for(let m=0;m<r;m++){let p=d*n+Math.min(n-1,m*n/r|0);a[p]+=e[t+f*r+m],s[p]++}}let c=0;for(let f=0;f<a.length;f++)a[f]/=s[f]||1,c+=a[f];c/=a.length;let l=0;for(let f=0;f<a.length;f++)a[f]-=c,l+=a[f]*a[f];let u=Math.sqrt(l)||1;for(let f=0;f<a.length;f++)a[f]/=u;return a}function One(e,t,n){let i=new Float64Array((t+1)*(n+1)),r=new Float64Array((t+1)*(n+1));for(let o=0;o<n;o++){let a=0,s=0;for(let c=0;c<t;c++){let l=e[o*t+c];a+=l,s+=l*l,i[(o+1)*(t+1)+c+1]=i[o*(t+1)+c+1]+a,r[(o+1)*(t+1)+c+1]=r[o*(t+1)+c+1]+s}}return{I:i,I2:r}}function l9(e,t,n,i,r,o=48,a=24,s){let c=-2,l=0,u=0,f=t*n,d=o+1;for(let m=0;m+n<=a;m++)for(let p=0;p+t<=o;p++){let b=0,h=0,v=0;if(s){let w=m*d+p,x=w+t,T=(m+n)*d+p,z=T+t;b=s.I[z]-s.I[x]-s.I[T]+s.I[w],h=s.I2[z]-s.I2[x]-s.I2[T]+s.I2[w];for(let k=0;k<n;k++){let S=r+(m+k)*o+p,M=k*t;for(let L=0;L<t;L++)v+=e[M+L]*i[S+L]}}else for(let w=0;w<n;w++){let x=r+(m+w)*o+p,T=w*t;for(let z=0;z<t;z++){let k=i[x+z];b+=k,h+=k*k,v+=e[T+z]*k}}let g=h-b*b/f;if(g<=0)continue;let y=v/Math.sqrt(g);y>c&&(c=y,l=p,u=m)}return{ncc:c,px:l,py:u}}function WZ(e,t,n,i,r,o,a,s,c){let l=new Float32Array(n*i),u=new Float32Array(n*i),f=new Float32Array(n*i);for(let v=0;v<24;v++){let g=Math.min(i-1,v*i/24|0);for(let y=0;y<48;y++){let w=g*n+Math.min(n-1,y*n/48|0);l[w]+=e[t*1152+v*48+y]-e[(t-1)*1152+v*48+y],f[w]++}}for(let v=0;v<i;v++)for(let g=0;g<n;g++){let y=(c+v)*48+s+g;u[v*n+g]=r[o*1152+y]-r[a*1152+y]}let d=0,m=0;for(let v=0;v<l.length;v++)l[v]/=f[v]||1,d+=l[v],m+=u[v];d/=l.length,m/=l.length;let p=0,b=0,h=0;for(let v=0;v<l.length;v++){let g=l[v]-d,y=u[v]-m;p+=g*y,b+=g*g,h+=y*y}return b>1e-6&&h>1e-6?p/Math.sqrt(b*h):null}function Lne(e,t,n,i,r,o){let a=o.ROT??!0?2:1,s=h=>i[h*a]??1,c=e.filter(h=>h.refEnd-h.refStart>=3&&(h.clip<0||!h.sure));if(!c.length)return;let l=[...new Set(e.filter(h=>h.clip>=0&&h.sure).flatMap(h=>[h.clip-1,h.clip,h.clip+1]))].filter(h=>h>=0&&h<n.length),u=n.length<=16||!l.length?n.map((h,v)=>v):l,f=(h,v,g,y)=>v+Math.floor((y-g)*s(h)+.001),d=24,m=12,p=new Map,b=(h,v)=>{let g=h*1e7+v,y=p.get(g);if(!y){let w=n[h].g,x=v*1152,T=new Float32Array(d*m);for(let z=0;z<m;z++)for(let k=0;k<d;k++){let S=x+2*z*48+2*k;T[z*d+k]=(w[S]+w[S+1]+w[S+48]+w[S+48+1])/4}p.set(g,y={h:T,sat:One(T,d,m)})}return y};for(let[h,v]of c.entries()){o.onProgress?.(h,c.length,"align: reframed shots");let g=[v.refStart+1,v.refStart+v.refEnd>>1,v.refEnd-1].filter(M=>t.ok[M]&&!r[M]);if(g.length<2)continue;let y=[];for(let M of Mne){let L=Math.round(d/M),P=Math.round(m/M),X=g.map(R=>c9(t.g,R*1152,L,P));for(let R of u){let I=n[R],q=f(R,0,g[0],g[g.length-1]);for(let Y=0;Y+q<I.n;Y+=6){let D=0,j=0;for(let C=0;C<g.length;C++){let H=f(R,Y,g[0],g[C]);if(!I.ok[H])continue;let ne=b(R,H);D+=l9(X[C],L,P,ne.h,0,d,m,ne.sat).ncc,j++}j>=2&&y.push({ci:R,S:Y-f(R,0,v.refStart,g[0]),sc:D/j,scale:M})}}}y.sort((M,L)=>L.sc-M.sc);let w=[];for(let M=v.refStart;M<=v.refEnd;M+=Math.max(1,(v.refEnd-v.refStart)/8|0))t.ok[M]&&!r[M]&&w.push(M);let x=[],T=new Map;for(let M of y){let L=T.get(M.ci)??0;if(!(L>=3||x.some(P=>P.ci===M.ci&&Math.abs(P.S-M.S)<12))&&(T.set(M.ci,L+1),x.push(M),x.length>=12))break}let z=null,k=new Map;for(let M of x)for(let L of[M.scale/1.07,M.scale,M.scale*1.07]){let P=Math.round(48/L),X=Math.round(24/L);if(P>=48)continue;let R=w.map(q=>c9(t.g,q*1152,P,X)),I=n[M.ci];for(let q=M.S-6;q<=M.S+6;q++){let Y=0,D=0,j=0,C=0;for(let le=0;le<w.length;le++){let Se=w[le],Le=f(M.ci,q,v.refStart,Se),ut=f(M.ci,q,v.refStart,Se-1);if(Le<1||Le>=I.n||!I.ok[Le])continue;let we=l9(R[le],P,X,I.g,Le*1152);if(Y+=we.ncc,D++,Se>v.refStart&&ut>=0&&ut!==Le&&I.ok[ut]&&t.ok[Se-1]){let De=WZ(t.g,Se,P,X,I.g,Le,ut,we.px,we.py);De!==null&&(j+=De,C++)}}let H=D?Y/D+(C>=2?j/C:0):-9;if(D<Math.max(2,w.length>>1))continue;(!z||H>z.sc)&&(z={ci:M.ci,S:q,sc:H,scale:L});let ne=k.get(M);(!ne||H>ne.sc)&&k.set(M,{ci:M.ci,S:q,sc:H,scale:L})}}if(globalThis.ALIGN_DEBUG&&console.error(`rescue ${v.refStart}-${v.refEnd}: short ${x.map(M=>`${M.ci}@${M.S}x${M.scale}:${M.sc.toFixed(2)}`).join(" ")} \u2192 best ${z?`${z.ci}@${z.S}x${z.scale.toFixed(2)}:${z.sc.toFixed(2)}`:"-"}`),!z)continue;let S=0;if(v.clip>=0){let M=n[v.clip],L=w.map(I=>c9(t.g,I*1152,48,24)),P=0,X=0,R=0;for(let I=0;I<w.length;I++){let q=w[I],Y=f(v.clip,v.srcStart,v.refStart,q),D=f(v.clip,v.srcStart,v.refStart,q-1);if(!(Y<1||Y>=M.n||!M.ok[Y])&&(S+=l9(L[I],48,24,M.g,Y*1152).ncc,P++,q>v.refStart&&D>=0&&D!==Y&&M.ok[D]&&t.ok[q-1])){let j=WZ(t.g,q,48,24,M.g,Y,D,0,0);j!==null&&(X+=j,R++)}}S=P?S/P+(R>=2?X/R:0):0}v.candidates=[...k.values()].sort((M,L)=>L.sc-M.sc).slice(0,6).map(M=>({clip:M.ci,srcStart:M.S,scale:M.scale,score:M.sc})),v.clip>=0&&v.candidates.push({clip:v.clip,srcStart:v.srcStart,scale:1,score:S}),!(z.sc<.6||z.sc<S+.1)&&(v.clip=z.ci,v.srcStart=z.S,v.srcEnd=z.S+Math.floor((v.refEnd-v.refStart)*s(z.ci)+.001),v.rot180=!1,v.conf=z.sc-Math.max(S,0),v.sure=!1,v.reframed=z.scale)}}function Xne(){let{gauss:e}=DZ(7),t=s=>{let c=new Uint16Array(s*1152),l=0,u=0,f=Float32Array.from({length:5632},()=>2e3+800*e());for(let d=0;d<s;d++){l+=.7,u+=.3;for(let m=0;m<24;m++)for(let p=0;p<48;p++)c[d*1152+m*48+p]=f[(m+(u|0))%64*88+(p+(l|0))%88]}return{n:s,ok:new Uint8Array(s).fill(1),g:c}},n=t(60),i=t(60),r={n:60,ok:new Uint8Array(60).fill(1),g:new Uint16Array(60*1152)};r.g.set(n.g.subarray(10*1152,40*1152),0),r.g.set(i.g.subarray(5*1152,35*1152),30*1152);let o=u9(r,[n,i]).filter(s=>s.clip>=0),a=s=>o.find(c=>s>=c.refStart&&s<=c.refEnd);for(let[s,c,l]of[[15,0,10],[45,1,-25]]){let u=a(s);if(!u||u.clip!==c||u.srcStart-u.refStart!==l)throw new Error(`alignSelfCheck: frame ${s} \u2192 ${JSON.stringify(u)}`)}}import.meta.main&&(Xne(),console.log("align self-check ok"));var Nne=[1,...Array.from({length:97},(e,t)=>.25*16**(t/96))],Rne=1.25,Fne=.3,qZ=[.25,.5,.75,1,1.25,1.5,2,3,4];function Vg(e){let t=0;for(let o of e)t+=o;t/=e.length;let n=0;for(let o of e)n+=(o-t)**2;let i=1/(Math.sqrt(n)||1),r=new Float32Array(e.length);for(let o=0;o<e.length;o++)r[o]=(e[o]-t)*i;return r}function f9(e,t,n,i=1){let r=e.length,o=n.length,a=new Float32Array(r*o).fill(NaN);for(let h=0;h<r;h++){let v=e[h];if(v)for(let g=0;g<o;g++){let y=n[g];if(!y)continue;let w=0;for(let x=0;x<v.length;x++)w+=v[x]*y[x];a[h*o+g]=w}}let s=(h,v)=>{let g=0,y=0;for(let w=0;w<r;w++){let x=Math.floor(h*t[w]+v+.001);if(x<0||x>=o)return-1/0;let T=a[w*o+x];T===T&&(g+=T,y++)}return y>=Math.max(3,r>>1)?g/y:-1/0},c=t[r-1]-t[0],l=Nne.map(h=>{let v={score:-1/0,off:0};for(let g=0;g+h*c<o;g+=.5){let y=s(h,g);y>v.score&&(v={score:y,off:g})}return{sp:h,...v}}),u=l.reduce((h,v)=>v.score>h.score?v:h);if(!isFinite(u.score))return null;let f=Math.max(-1,...l.filter(h=>Math.abs(Math.log(h.sp/u.sp))>Math.log(Rne)).map(h=>h.score)),d=[...qZ,...qZ.map(h=>h*i)].reduce((h,v)=>Math.abs(Math.log(v/u.sp))<Math.abs(Math.log(h/u.sp))?v:h),m=u.sp,p=u.off;if(Math.abs(Math.log(d/u.sp))<.07){let h=u.sp*c/2+u.off,v=-1/0;for(let g=Math.round(h-d*c/2)-2;g<=h-d*c/2+2;g+=.5){let y=s(d,g);y>v&&(v=y,p=g)}isFinite(v)?m=d:p=u.off}let b=(u.score-f)/Math.max(1e-6,1-f);return{score:s(m,p),margin:b,speed:m,start:Math.floor(p+.001),observable:b>=Fne,scoreOf:s}}var jg=160,Zg=2,Vne=12;async function HZ(e,t,n,i=16,r=9){let o=Math.max(1,e.refEnd-e.refStart);if(o<Zg+2)return null;let a=Math.round(jg*r/i),s=h=>Math.round(e.srcStart+(h-e.refStart)*(e.srcEnd-e.srcStart)/o),c=h=>h.catch(()=>null),l=(await Promise.all(Oi(e.refStart,e.refEnd-Zg,Vne).map(h=>Promise.all([c(t(h)),c(t(h+Zg)),c(n(s(h))),c(n(s(h+Zg)))])))).filter(h=>h.every(Boolean));if(l.length<3)return null;let u=await Mi(l.map(h=>({ref:h[0],src:h[2]})),{turns:!1}).catch(()=>null),f=u?ao(u.transform):null,d=l[0][0].w,m=l[0][0].h,p=(h,v)=>zo(v&&f?hi(h,f,d,m,jg,a):jn(h,jg,a),jg),b=h=>{let v=0,g=0,y=0;for(let w of l){let x=p(w[0],!1),T=p(w[1],!1),z=p(w[2],h),k=p(w[3],h);if(!(!x||!T||!z||!k))for(let S=0;S<x.length;S++){let M=T[S]-x[S],L=k[S]-z[S];v+=M*L,g+=M*M,y+=L*L}}return g&&y?v/Math.sqrt(g*y):0};return Math.max(b(!1),f?b(!0):-1)}var d9=Array.from({length:30},(e,t)=>(t+1)/10),Ig=[-1,0,1],jne=.004;function m9(e,t,n){if(t<2||n<2)return null;let i=n*10,r=d9.length,o=d9.map((h,v)=>v+1),a=(h,v)=>{let g=e[h*n+Math.floor(v/10)];return g===g?g:0},s=new Float32Array(i*r);for(let h=0;h<i;h++){let v=a(0,h);for(let g=0;g<r;g++)s[h*r+g]=v}let c=new Int8Array(t*i*r);for(let h=1;h<t;h++){let v=new Float32Array(i*r).fill(-1/0);for(let g=0;g<i;g++){let y=a(h,g);for(let w=0;w<r;w++){let x=g-o[w];if(x<0)continue;let T=-1/0,z=0;for(let k=0;k<Ig.length;k++){let S=w-Ig[k];if(S<0||S>=r)continue;let M=s[x*r+S]-jne*Math.abs(Ig[k]);M>T&&(T=M,z=k)}v[g*r+w]=T+y,c[(h*i+g)*r+w]=z}}s=v}let l=0;for(let h=1;h<i*r;h++)s[h]>s[l]&&(l=h);if(!isFinite(s[l]))return null;let u=s[l]/t,f=Math.floor(l/r),d=l%r,m=new Int32Array(t),p=new Float32Array(t),b=new Float64Array(t);for(let h=t-1;h>=0&&(m[h]=Math.floor(f/10),p[h]=d9[d],b[h]=(f+.5)/10,h!==0);h--){let v=c[(h*i+f)*r+d];f-=o[d],d-=Ig[v]}return{frames:m,speeds:p,score:u,pos:b}}function EZ(e,t,n){let i=o=>{if(o<=e[0][0])return e[0][1];for(let a=1;a<e.length;a++)if(o<=e[a][0])return e[a-1][1]+(e[a][1]-e[a-1][1])*(o-e[a-1][0])/Math.max(1e-9,e[a][0]-e[a-1][0]);return e[e.length-1][1]},r=new Float64Array(n);r[0]=t;for(let o=1;o<n;o++){let a=[o-1,...e.map(c=>c[0]).filter(c=>c>o-1&&c<o),o],s=0;for(let c=1;c<a.length;c++)s+=(i(a[c-1])+i(a[c]))/2*(a[c]-a[c-1]);r[o]=r[o-1]+s}return r}var Zne=e=>Math.floor(e+.002);function p9(e){let{frames:t,pos:n}=e,i=t.length,r=t[0],o=Array.from({length:i},(l,u)=>u===0?0:n[u]-(u===1?r:n[u-1])),a=o.map((l,u)=>u===0?o[1]:u===i-1?o[u]:(o[u]+o[u+1])/2),s=[[0,a[0]]];for(let l=1;l<i;l++)s.push([l-.5,(4*o[l]-a[l-1]-a[l])/2],[l,a[l]]);let c=l=>{let u=EZ(l,r,i);for(let f=0;f<i;f++)if(Zne(u[f])!==t[f])return!1;return!0};if(!c(s))return s;for(let l=s.length-2;l>=1;l--){let u=[...s.slice(0,l),...s.slice(l+1)];c(u)&&(s=u)}return s.map(([l,u])=>[l,Math.round(u*1e4)/1e4])}if(import.meta.main){let n=[],i=20;for(let u=0;u<90;u++)n.push(Math.floor(i)),i+=u<30?1:u<60?.4:1;let r=new Float32Array(18e3);for(let u=0;u<90;u++)for(let f=0;f<200;f++)r[u*200+f]=Math.exp(-((f-n[u])**2)/2)+.05*Math.sin(u*7+f*3);let o=m9(r,90,200),a=n.filter((u,f)=>o.frames[f]===u).length,s=p9(o),c=EZ(s,o.frames[0],90),l=n.filter((u,f)=>Math.floor(c[f]+.002)===u).length;if(console.log(`decoded exact ${a}/90; graph ${JSON.stringify(s)} plays back exact ${l}/90`),a<90*.95||l<90*.9)throw new Error("time path self-check failed")}var Ine=16,bs=1152,Wg=()=>_(wt(),"cache","grids");async function Dg(e){let t=await cn(e);return _(Wg(),`${ae(e)}.${t.size}.${Math.floor(t.mtimeMs)}.g${48}x${24}`)}function Wne(e,t,n){let i=new Float32Array(bs),r=new Float32Array(bs);for(let o=0;o<e.h;o++){let a=Math.min(23,o*24/e.h|0)*48;for(let s=0;s<e.w;s++){let c=a+Math.min(47,s*48/e.w|0);i[c]+=e.y[o*e.w+s],r[c]++}}for(let o=0;o<bs;o++)t[n+o]=Math.round(Ine*i[o]/(r[o]||1))}async function h9(e,t={}){let n=await Dg(e);try{let u=await pr(n),f=new DataView(u.buffer,u.byteOffset).getUint32(0,!0),d=4+f+1&-2;return{n:f,ok:u.slice(4,4+f),g:new Uint16Array(u.slice(d,d+f*bs*2).buffer)}}catch{}let i=await gn(await sr.open(e)),r=i.geometrySpec??(i.spec?.codec==="prores"?i.spec:null),o,a,s;if(r){o=i.frames.length,a=new Uint16Array(o*bs),s=new Uint8Array(o);let u=0;await Promise.all(Array.from({length:64},async()=>{for(;u<o;){t.signal?.throwIfAborted();let f=u++,{offset:d,size:m}=i.frames[f];if(!(m<=0)){try{a.set(await zZ(e,d,m,r,"index",48,24),f*bs),s[f]=1}catch{}f%500===0&&t.onFrames?.(f)}}}))}else{let u=await el(e,void 0,t.signal,96);o=u.frames,a=new Uint16Array(o*bs),s=new Uint8Array(o);for(let f=0;f<o;f++){let d=u.has(f)?await u.read(f):null;d&&(Wne(d,a,f*bs),s[f]=1)}}let c=4+o+1&-2,l=new Uint8Array(c+a.byteLength);return new DataView(l.buffer).setUint32(0,o,!0),l.set(s,4),l.set(new Uint8Array(a.buffer),c),await vt(Wg()),await or(`${n}.tmp`,l),await Gr(`${n}.tmp`,n),{n:o,ok:s,g:a}}async function UZ(e,t){try{let n=await pr(`${await Dg(e)}.f${1}`),i=new DataView(n.buffer,n.byteOffset).getUint32(0,!0);if(i!==t.n)return;let r=n.slice(4).buffer;t.feat={sp:new Uint32Array(r,0,2*i),mp:new Float32Array(r,8*i,32*i),still:new Uint8Array(r,136*i,i)}}catch{}}async function AZ(e,t){let n=t.feat;if(!n||n.mp.length!==32*t.n)return;let i=t.n,r=new Uint8Array(4+137*i),o=`${await Dg(e)}.f${1}`;new DataView(r.buffer).setUint32(0,i,!0),r.set(new Uint8Array(n.sp.buffer,n.sp.byteOffset,8*i),4),r.set(new Uint8Array(n.mp.buffer,n.mp.byteOffset,128*i),4+8*i),r.set(n.still,4+136*i),await vt(Wg()),await or(`${o}.tmp`,r),await Gr(`${o}.tmp`,o)}async function GZ(e,t,n,i,r){let o=(await Dg(e)).replace(`${Wg()}`,_(wt(),"cache","stars"))+`.s${i}.json`;try{return JSON.parse(new TextDecoder().decode(await pr(o)))}catch{}let a=[];for(let s=0;s<t;s+=i){r?.throwIfAborted();let c=await n(s).catch(()=>null);c&&a.push({frame:s,st:Ng(c,XZ).map(([l,u])=>[Math.round(l*4)/4,Math.round(u*4)/4])})}return await vt(_(wt(),"cache","stars")),await or(`${o}.tmp`,new TextEncoder().encode(JSON.stringify(a))),await Gr(`${o}.tmp`,o),a}var Dne={gap:"Green",unresolved:"Red",contested:"Red",composite:"Yellow",rate:"Yellow",reframe:"Yellow",retime:"Yellow",ambiguous:"Yellow","source-range":"Yellow"},qne={gap:"NO SOURCE",unresolved:"REFRAME UNRESOLVED",contested:"CONTESTED SOURCE",composite:"COMPOSITE",rate:"RATE",reframe:"REFRAME",retime:"RETIME",ambiguous:"IN-POINT UNCERTAIN","source-range":"SOURCE RANGE"};function Hne(e,t){return e.map((n,i)=>{let r=n.refStart??0,o=n.refEnd!=null&&n.refStart!=null?n.refEnd-n.refStart+1:1;return{id:`conform-marker-${i}`,name:qne[n.kind]??n.kind.toUpperCase(),color:Dne[n.kind]??"Yellow",kind:null,note:n.message,time:{value:r,rate:t},duration:{value:Math.max(1,o),rate:t},item_id:null,raw_extraction:{},source_element_id:null,metadata:{}}})}function JZ(e,t){let n=(e.timelines??[])[0];if(!n||t.length===0)return e;let i=n.fps_den?n.fps_num/n.fps_den:24;return{...e,timelines:[{...n,markers:[...n.markers??[],...Hne(t,i)]},...(e.timelines??[]).slice(1)]}}var Ene=.02,b9=100,Cne="the lowest enabled video track is read as the picture spine; anything on the tracks above it (titles, graphics, split-screens) is not hinted and falls to the pixel search";function BZ(e){return e&&e.split(/[\\/]/).pop()||null}function Ta(e,t){if(!e||!Number.isFinite(e.value))return 0;let n=e.rate&&Number.isFinite(e.rate)&&e.rate>0?e.rate:t;return Math.round(e.value*(t/n))}function YZ(e){let t=e,n=(i,r)=>i!=null&&Number.isFinite(i)&&Math.abs(i-r)>1e-6;return n(t.scale,b9)||n(t.scale_x,b9)||n(t.scale_y,b9)||n(t.position_x,0)||n(t.position_y,0)||n(t.rotation,0)}var Une=3;function Ane(e){let t=e;return(t.scale??100)>=100&&Math.abs(t.position_x??0)<1&&Math.abs(t.position_y??0)<1&&(t.opacity??100)>=100&&!(t.crop_left||t.crop_right||t.crop_top||t.crop_bottom)}function Gne(e){let n=(e.tracks??[]).filter(i=>i.kind==="Video"&&i.enabled!==!1).sort((i,r)=>i.track_index-r.track_index).filter(i=>(i.items??[]).some(r=>r.kind==="clip"));return{track:n[0]??null,extraVideo:Math.max(0,n.length-1)}}function Jne(e,t,n){return!n||n<=0||!e.length?0:Math.min(...e.map(r=>Ta(r.timeline_range?.start,t)))>=n-1?n:0}function KZ(e,t,n={}){let i=[],r=(e.timelines??[]).filter(x=>x.kind!=="compound"),o=(t?r.find(x=>x.name===t):null)??r[0]??(e.timelines??[])[0];if(!o)return{timelineName:"",timelineId:null,startOffset:0,fps:0,frames:0,shots:[],cuts:[],warnings:["no timeline in this file"]};r.length>1&&i.push(`this file holds ${r.length} sequences \u2014 hinting from "${o.name}". If that is not the cut you rendered, the claims below will disagree with the picture everywhere.`);let a=o.fps_den?o.fps_num/o.fps_den:o.fps_num||24,{track:s,extraVideo:c}=Gne(o);if(!s)return{timelineName:o.name,timelineId:o.id??null,startOffset:0,fps:a,frames:o.duration_frames??0,shots:[],cuts:[],warnings:[...i,"no video track with clips \u2014 nothing to hint from"]};let l=n.allTracks?(o.tracks??[]).filter(x=>x.kind==="Video"&&x.enabled!==!1):[s];c>0&&i.push(n.allTracks?`${c} video track(s) above the spine \u2014 their clips are hinted too, each checked against the picture like any other claim.`:`${c} video track(s) above the spine \u2014 ${Cne}.`);let u=l.flatMap(x=>x.items??[]).sort((x,T)=>Ta(x.timeline_range?.start,a)-Ta(T.timeline_range?.start,a)),f=Jne(u,a,o.start_frame??0);f>0&&i.push(`item times carry the timeline's start timecode (${f} frames); removed so they line up with a render that begins at its first frame.`);let d=new Map((e.media_references??[]).map(x=>[x.id,x])),m=new Map;for(let x of l)for(let T of x.items??[])m.set(T,x.track_index);let p=[];for(let x of l)for(let T of x.items??[]){if(T.enabled===!1||T.kind!=="clip"||!Ane(T))continue;let z=T.media_reference_id?d.get(T.media_reference_id):void 0;if(z?.content_kind==="still"||/\.(png|webp|tiff?|psd|exr|dpx|gif|jpe?g)$/i.test(z?.target_url??z?.display_name??""))continue;let k=Ta(T.timeline_range?.start,a)-f,S=Ta(T.timeline_range?.duration,a);S>0&&p.push({track:x.track_index,lo:k,hi:k+S-1})}let b=(x,T,z)=>{let k=[[x,T]];for(let S of p)S.track<=z||(k=k.flatMap(([M,L])=>{if(S.hi<M||S.lo>L)return[[M,L]];let P=[];return S.lo>M&&P.push([M,S.lo-1]),S.hi<L&&P.push([S.hi+1,L]),P}));return k.filter(([S,M])=>M-S+1>=Une)},h=[],v=0,g=0,y=0,w=0;for(let x of u){if(x.enabled===!1){g++;continue}if(x.kind==="nested"||x.nested_timeline_id){v++;continue}if(x.kind!=="clip"){y++;continue}let T=Ta(x.timeline_range?.start,a)-f,z=Ta(x.timeline_range?.duration,a);if(z<=0){y++;continue}let k=x.media_reference_id?d.get(x.media_reference_id):void 0,S=BZ(k?.local_path)??BZ(k?.target_url)??k?.display_name??null,M=x.name??null,L=x.reel_name??k?.reel_name??null;if(!S&&!M&&!L){w++;continue}let P=x.source_range?.start?.rate||a,X=Ta(x.source_range?.start,P),R=Ta(x.source_range?.duration,P),I=z>0&&R>0?R/z:1,q=Math.abs(I-1)>Ene?I:null,Y=m.get(x)??0,D=k?.source_timecode?hp(k.source_timecode,P):null;for(let[j,C]of b(T,T+z-1,Y)){let H=Math.round((j-T)*I);h.push({index:h.length,itemId:x.id??null,refStart:j,refEnd:C,clipName:M,reelName:L,sourceFilename:S,srcStart:X+H,srcTimecode:D?D.frames+X+H:null,srcRate:P,srcDropFrame:D?.drop??!1,declaredReframe:YZ(x),declaredTransform:YZ(x)?{scale:x.scale,scale_x:x.scale_x,scale_y:x.scale_y,position_x:x.position_x,position_y:x.position_y,rotation:x.rotation}:null,declaredSpeed:q})}}return v&&i.push(`${v} nested/compound clip(s) not expanded \u2014 their shots fall to the pixel search rather than being hinted from the wrapper's own range, which would be wrong.`),g&&i.push(`${g} disabled clip(s) ignored.`),y&&i.push(`${y} non-clip item(s) (transitions, gaps) ignored.`),w&&i.push(`${w} clip(s) name no source at all \u2014 no file, no reel, no clip name. Nothing to bind them to, so they go to the pixel search.`),{timelineName:o.name,timelineId:o.id??null,startOffset:f,fps:a,frames:o.duration_frames??(h.length?h[h.length-1].refEnd+1:0),shots:h,cuts:[...new Set(h.slice(1).map(x=>x.refStart))].sort((x,T)=>x-T),warnings:i}}import{resolve as Bne,dirname as Yne}from"node:path";import{fileURLToPath as Kne}from"node:url";var _Z=Bne(Yne(Kne(import.meta.url)),"../../../../public/sscd/sscd_disc_mixup.288.fp16.onnx"),QZ=new Map;function Qne(e=_Z){let t=QZ.get(e);return t||(t=import("onnxruntime-node").then(n=>n.InferenceSession.create(e,{executionProviders:["cpu"]})),QZ.set(e,t)),t}async function qg(e,t=_Z,n=288){if(e.length===0)return[];let i=await import("onnxruntime-node"),r=await Qne(t),o=[];for(let a=0;a<e.length;a+=8){let s=e.slice(a,a+8),l=(await r.run({rgb:new i.Tensor("float32",V6(s,n),[s.length,3,n,n])})).embedding,u=l.dims[1],f=l.data;for(let d=0;d<s.length;d++)o.push(f.slice(d*u,(d+1)*u))}return o}var Z1e=8*1024*1024;var ire=new Set(["mov","mp4","m4v","r3d","mxf","braw","ari","arx","arri","crm"]),g9=e=>e.split(".").pop()?.toLowerCase()??"",v9=e=>ire.has(g9(e)),$Z=new Set(["mov","mp4","m4v"]),Hg=e=>(e.split(/[\\/]/).pop()??e).replace(/\.[^.]+$/,"").toUpperCase();function eI(e,t){let n=new Set(e.map(t).filter(a=>!$Z.has(g9(a))).map(Hg)),i=new Set(e.map(t).map(Hg)),r=[],o=[];for(let a of e){let s=t(a),c=/^(.*)_TRIM_\d+-\d+$/.exec(Hg(s))?.[1];($Z.has(g9(s))&&n.has(Hg(s))||c!=null&&i.has(c)?o:r).push(a)}return{kept:r,proxies:o}}var ore=1;async function tI(e,t){try{let n=await cn(e);if(!n.isFile)return null;let i=JSON.stringify([ore,e,n.size,Math.round(n.mtimeMs),t.matte,t.stride,t.motion,t.lane]),r=new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(i)));return Array.from(r.slice(0,16),o=>o.toString(16).padStart(2,"0")).join("")}catch{return null}}var Eg=()=>_(wt(),"cache","pdq"),y9=48;async function nI(e,t){let n=await tI(e,t);if(!n)return null;let i;try{i=await pr(_(Eg(),`${n}.pdq`))}catch{return null}try{let r=new DataView(i.buffer,i.byteOffset,i.byteLength),o=r.getUint32(0,!0),a=JSON.parse(new TextDecoder().decode(i.subarray(4,4+o))),s=4+o,c=[];for(let m=0;m<a.frames;m++,s+=y9){let p=r.getFloat64(s+40,!0);c.push({bits:new Uint32Array(i.slice(s,s+32).buffer),quality:r.getFloat64(s+32,!0),...Number.isNaN(p)?{}:{meanY:p}})}let l=a.motion?new Float32Array(i.slice(s,s+a.motion*4).buffer):void 0,{frames:u,motion:f,...d}=a;return{...d,pdq:c,...l?{motion:l}:{}}}catch{return null}}async function rI(e,t,n){let i=await tI(e,t);if(!i)return;let{pdq:r,motion:o,...a}=n,s=new TextEncoder().encode(JSON.stringify({...a,frames:r.length,motion:o?.length??0})),c=new Uint8Array(4+s.length+r.length*y9+(o?.byteLength??0)),l=new DataView(c.buffer);l.setUint32(0,s.length,!0),c.set(s,4);let u=4+s.length;for(let d of r)c.set(new Uint8Array(d.bits.buffer,d.bits.byteOffset,32),u),l.setFloat64(u+32,d.quality??0,!0),l.setFloat64(u+40,d.meanY??NaN,!0),u+=y9;o&&c.set(new Uint8Array(o.buffer,o.byteOffset,o.byteLength),u),await vt(Eg()),await So(_(wt(),"cache"),448);let f=_(Eg(),`${i}.${crypto.randomUUID()}.tmp`);await or(f,c),await So(f,384);try{await Gr(f,_(Eg(),`${i}.pdq`))}catch{await Er(f)}}async function Xu(e){let t=e.path;if(!t||!await Vr())return!1;try{return await Ws(t),!0}catch{return!1}}async function Ho(e,t,n={}){let i=await gn(e);if(i.spec&&t!=="os-decoder"){let a=i.spec;return{src:i,frames:i.frames.length,lane:"media-core",luma:async s=>{let c=i.frames[s];if(!c||c.size<=0)return null;try{return await lp(e,c.offset,c.size,a)}catch{return null}}}}let r=e.path;if(!r||!await Vr())throw new Error(`${e.name}: ${i.warnings[0]??"no decoder for this clip"} (H.264/HEVC need the native decoder, conformtools-decode, which is not installed)`);if(n.sparse){let a=na(r,Wp);return{src:i,frames:i.frames.length||(await Ws(r)).frames,luma:s=>a.read(s).catch(()=>null),lane:"os-decoder"}}let o=await el(r);return{src:i,frames:i.frames.length||o.frames,luma:a=>o.read(a),lane:"os-decoder"}}async function Om(e,t){let n=e.path,i=Math.max(1,Math.floor(t.stride??1)),r=t.lane??await gn(e).then(s=>s.spec?`media-core${"display"in s.spec&&s.spec.display?`+${s.spec.display}`:""}`:"os-decoder").catch(()=>"?"),o={matte:t.matte,stride:i,motion:!!t.motion,lane:r};if(n){let s=await nI(n,o);if(s)return t.onProgress?.(s.pdq.length,s.pdq.length),s}let a=await are(e,t);return n&&await rI(n,o,a).catch(()=>{}),a}async function are(e,t){let{src:n,frames:i,luma:r,lane:o}=await Ho(e,t.lane,{sparse:(t.stride??1)>1}),a={offs:n.frames.length?n.frames:Array.from({length:i},()=>({offset:0,size:0})),codec:n.index?.codec??n.label,kind:n.spec?n.spec.codec:n.index?.kind??"other",w:n.w,h:n.h,fps:n.fps,startFrame:n.startFrame,dropFrame:n.dropFrame},s=Math.max(1,Math.floor(t.stride??1)),c;if(t.matte==="clip"){let b=[];for(let v of Wa(i,12)){let g=await r(v);g&&b.push({luma:Uint8Array.from(g.y),w:g.w,h:g.h})}let h=b.length?Gc(b):null;c=h?mp(h,b[0].w,b[0].h):void 0}let l=[],u=t.motion&&s===1?new Float32Array(Math.ceil(i/s)):void 0,f=null,d=0,m=Math.ceil(i/s);for(let b=0;b<i;b+=s){if(t.signal?.aborted)throw new Error("cancelled");let h=await r(b);if(!h)l.push({bits:new Uint32Array(8),quality:0,meanY:0}),f=null;else{let v=t.matte==="cut"?Za(h.y,h.w,h.h):c?qk(c,h.w,h.h):null;if(l.push(v?zr(Ia(h.y,h.w,v),v.w,v.h):zr(h.y,h.w,h.h)),u&&f&&f.w===h.w&&f.h===h.h){let g=0;for(let y=0;y<h.y.length;y++)g+=Math.abs(h.y[y]-f.y[y]);u[l.length-1]=g/h.y.length}f=h}t.onProgress?.(++d,m)}return{meta:{codec:a.codec,kind:a.kind,label:n.label,w:a.w,h:a.h,fps:a.fps,frames:i,startFrame:a.startFrame,dropFrame:a.dropFrame},index:a,pdq:l,...u?{motion:u}:{},...c?{matte:c}:{},stride:s,lane:o}}var Lm=Number(Ut("CONFORM_REFRAMERS")??0)||Math.max(1,Math.min(12,Po()-4,Math.floor(xo()/2**33))),w9=Array(Lm).fill(null),Eo=Array(Lm).fill(0);function oI(e){return(async()=>{let t=await Vr();if(!t)return null;let n=[],i="",r=I6(t,["reframe-server"],c=>{i+=new TextDecoder().decode(c);let l;for(;(l=i.indexOf(`
172
+ `))>=0;){let u=i.slice(0,l);i=i.slice(l+1),n.shift()?.(u)}},Ut("SIZING_DEBUG")?c=>console.error(c.trimEnd()):void 0);r.exited.then(()=>{w9[e]=null;for(let c of n.splice(0))c(JSON.stringify({ok:!1,why:"exited"}))});let o=Promise.resolve(),a=0;return{io:r,ask:(c,l)=>{a++===0&&r.hold(!0);let u=o.then(async()=>{let f=new Promise(d=>n.push(d));return await r.write(new TextEncoder().encode(JSON.stringify(c)+`
173
+ `)),l&&await r.write(l),JSON.parse(await f)}).finally(()=>{--a===0&&r.hold(!1)});return o=u.catch(()=>{}),u}}})()}var Xm=new WeakMap,sre=1;async function iI(e,t,n,i,r,o){let a=Xm.get(n);a||(a=new Map,Xm.set(n,a));let s=`${t}|${o}`,c=a.get(s);if(c)return c;let l=sre++,u=await e.ask({op:"extract",id:l,w:i,h:r,opts:o},n);if(!u.ok)throw new Error(`reframe-server extract failed: ${JSON.stringify(u)}`);return a.set(s,l),l}function cre(e,t){let n=Xm.get(e),i=0;for(let r=1;r<Lm;r++)Eo[r]<Eo[i]&&(i=r);for(let r=0;r<Lm;r++)if(Eo[r]<=Eo[i]&&n?.has(`${r}|${t}`))return r;return i}var lre=async(e,t,n,i,r,o,a)=>{let s=cre(i,a);Eo[s]++;try{let c=await(w9[s]??=oI(s));if(!c)throw new Error("the native reframe engine is not available");for(let l=0;l<2;l++){let u=await iI(c,s,e,t,n,a),f=await iI(c,s,i,r,o,a),d=await c.ask({op:"match",a:u,b:f,opts:a});if(d.why==="unknown_id"){Xm.delete(e),Xm.delete(i);continue}if(d.ok===!1&&d.why)throw new Error(`reframe-server: ${JSON.stringify(d)}`);return d}throw new Error("reframe-server kept evicting the frames it was asked to match")}finally{Eo[s]--}},ure=async(e,t,n)=>{let i=0;for(let r=1;r<Lm;r++)Eo[r]<Eo[i]&&(i=r);Eo[i]++;try{let r=await(w9[i]??=oI(i));if(!r)throw new Error("the native reframe engine is not available");let[o,a,s,c]=[e[0].w,e[0].h,t[0].w,t[0].h],l=new Uint8Array(e.length*(o*a+s*c)),u=0;for(let f of e)l.set(f.y.subarray(0,o*a),u),u+=o*a;for(let f of t)l.set(f.y.subarray(0,s*c),u),u+=s*c;return await r.ask({op:"sizing",n:e.length,sw:o,sh:a,rw:s,rh:c,opts:n},l)}finally{Eo[i]--}};async function aI(){return await Vr()?(Kk(lre),K8(ure),!0):!1}var sI=new Map;async function fre(e){let t=await Vr();if(!t)return null;let n=await new Deno.Command(t,{args:["audio",e,"--rate",String(8e3)],stdout:"piped",stderr:"null"}).output();if(!n.success)return null;let i=n.stdout,r=i.indexOf(10);if(r<0||!JSON.parse(new TextDecoder().decode(i.subarray(0,r))).ok)return null;let a=i.subarray(r+1),s=a.length>>1,c=new DataView(a.buffer,a.byteOffset,s*2),l=new Float32Array(s);for(let u=0;u<s;u++)l[u]=c.getInt16(u*2,!0)/32768;return l}async function dre(e){await ni();let t=await sr.open(e),n=Xs(t),i=JSON.parse(await Ra(n,t.size)||"null");if(!i||i.aac||!i.sample_rate||!i.sample_frames)return null;let r=i.sample_rate,o=i.sample_frames,a=Math.max(1,Math.round(r/8e3)),s=new Float32Array(Math.floor(o/a)),c=0,l=0,u=0,f=r*10;for(let d=0;d<o;d+=f){let m=await Fa(n,t.size,d,Math.min(f,o-d));if(!m||m.length<12)break;let p=new DataView(m.buffer,m.byteOffset,m.byteLength),b=p.getUint32(8,!0),h=p.getUint32(4,!0);if(!b||!h)break;let v=new Float32Array(m.slice(12).buffer,0,b*h);for(let g=0;g<b;g++){let y=0;for(let w=0;w<h;w++)y+=v[g*h+w];l+=y/h,++u===a&&(c<s.length&&(s[c++]=l/a),l=0,u=0)}}return c?s.subarray(0,c):null}var cI=e=>fre(e).then(t=>t??dre(e)).catch(()=>null),lI=async(e,t)=>{let n=await cn(e);return _(wt(),"cache","pcm",`${ae(e)}.${n.size}.${Math.floor(n.mtimeMs)}.${t}`)};async function Nu(e){let t=null;try{t=await lI(e,`r${8e3}`)}catch{return cI(e)}try{let i=await pr(t),r=new Int16Array(i.buffer,i.byteOffset,i.length>>1),o=new Float32Array(r.length);for(let a=0;a<r.length;a++)o[a]=r[a]/32767;return o}catch{}let n=await cI(e);if(!n)return null;try{let i=new Int16Array(n.length);for(let r=0;r<i.length;r++)i[r]=Math.max(-32767,Math.min(32767,Math.round(n[r]*32767)));await vt(_(wt(),"cache","pcm")),await or(`${t}.tmp`,new Uint8Array(i.buffer)),await Gr(`${t}.tmp`,t)}catch{}return n}function uI(e){let t=sI.get(e);return t||(t=Nu(e),sI.set(e,t)),t}async function fI(e){let t=null;try{t=await lI(e,`r${8e3}.lm1`);let r=await pr(t),o=new DataView(r.buffer,r.byteOffset).getUint32(0,!0),a=r.slice(4);return{hash:new Uint32Array(a.buffer,0,o),t:new Uint32Array(a.buffer,o*4,o)}}catch{}let n=await Nu(e);if(!n||n.length<8e3)return null;let i=Rp(n);if(t)try{let r=new Uint8Array(4+i.hash.length*8);new DataView(r.buffer).setUint32(0,i.hash.length,!0),r.set(new Uint8Array(i.hash.buffer,i.hash.byteOffset,i.hash.byteLength),4),r.set(new Uint8Array(i.t.buffer,i.t.byteOffset,i.t.byteLength),4+i.hash.byteLength),await vt(_(wt(),"cache","pcm")),await or(`${t}.tmp`,r),await Gr(`${t}.tmp`,t)}catch{}return i}function dI(e,t,n,i,r,o=.05){let a=8e3,s=Math.round(n*a),c=Math.min(Math.round((i-n)*a),4*a);if(c<a/20||s+c>e.length)return null;let l=e.subarray(s,s+c),u=0;for(let h=0;h<c;h++)u+=l[h];u/=c;let f=0;for(let h=0;h<c;h++)f+=(l[h]-u)**2;if(f<1e-9)return null;let d=Math.round(r*a),m=Math.round(o*a),p=-2,b=-1;for(let h=Math.max(0,d-m);h<=Math.min(t.length-c,d+m);h++){let v=0,g=0,y=0;for(let T=0;T<c;T++){let z=t[h+T];v+=(l[T]-u)*z,g+=z,y+=z*z}let w=y-g*g/c,x=v/Math.sqrt(Math.max(w,1e-12)*f);x>p&&(p=x,b=h)}return b<0?null:{clipSec:b/a,ncc:p}}function x9(e,t,n){let i=t*n,r=new Float32Array(i*3);for(let o=0;o<i;o++)r[o*3]=e[o*4]/255,r[o*3+1]=e[o*4+1]/255,r[o*3+2]=e[o*4+2]/255;return{data:r,w:t,h:n}}function ro(e){return e<0?0:e>1?1:e}var P9="srgb";function mI(e){P9=e}function za(e){return P9==="g24"?Math.pow(Math.max(e,0),2.4):e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function S9(e){return P9==="g24"?Math.pow(Math.max(e,0),1/2.4):e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055}function gs(e,t){let n=Math.min(1,t/Math.max(e.w,e.h));if(n>=1)return e;let i=Math.max(1,Math.round(e.w*n)),r=Math.max(1,Math.round(e.h*n)),o=new Float32Array(i*r*3),a=e.w/i,s=e.h/r;for(let c=0;c<r;c++){let l=Math.floor(c*s),u=Math.min(e.h,Math.max(l+1,Math.floor((c+1)*s)));for(let f=0;f<i;f++){let d=Math.floor(f*a),m=Math.min(e.w,Math.max(d+1,Math.floor((f+1)*a))),p=0,b=0,h=0,v=0;for(let y=l;y<u;y++)for(let w=d;w<m;w++){let x=(y*e.w+w)*3;p+=e.data[x],b+=e.data[x+1],h+=e.data[x+2],v++}let g=(c*i+f)*3;o[g]=p/v,o[g+1]=b/v,o[g+2]=h/v}}return{data:o,w:i,h:r}}function k9(e,t,n){if(e.w===t&&e.h===n)return e;let i=new Float32Array(t*n*3);for(let r=0;r<n;r++){let o=Math.min(e.h-1,Math.floor(r*e.h/n));for(let a=0;a<t;a++){let s=Math.min(e.w-1,Math.floor(a*e.w/t)),c=(o*e.w+s)*3,l=(r*t+a)*3;i[l]=e.data[c],i[l+1]=e.data[c+1],i[l+2]=e.data[c+2]}}return{data:i,w:t,h:n}}var bxe=Promise.resolve();var mre=.7,pre=.35;function hre(e,t){let n=Math.max(e.x0,t.x0),i=Math.max(e.y0,t.y0),r=Math.min(e.x1,t.x1),o=Math.min(e.y1,t.y1),a=Math.max(0,r-n)*Math.max(0,o-i),s=(e.x1-e.x0)*(e.y1-e.y0)+(t.x1-t.x0)*(t.y1-t.y0);return a/Math.max(s-a,1e-9)}function pI(e,t,n,i=mre){let r=s=>s<0?0:s>1?1:s,o=[];for(let s=0;s<n;s++){let c=e[s*2+1];if(!(c>i))continue;let l=r(t[s*4]),u=r(t[s*4+1]),f=r(t[s*4+2]),d=r(t[s*4+3]);f<=l||d<=u||o.push({x0:l,y0:u,x1:f,y1:d,score:c})}o.sort((s,c)=>c.score-s.score);let a=[];for(let s of o)a.every(c=>hre(s,c)<pre)&&a.push(s);return a}var bre="klein4b-q8",Cg="https://pub-ed884bfa772244d89e9b6178f3b8ec9a.r2.dev/klein4b-q8/v1/manifest.json",gre=["media-gen","mlx.metallib","transformer.safetensors","vae.safetensors","balance.safetensors"],vre=16e9,Ru=()=>_(wt(),"models",bre);function z9(){return xr()!=="darwin"||ef()!=="arm64"?`the local AI colour model runs on Apple Silicon Macs for now (this is ${xr()}/${ef()})`:xo()<vre?`the local AI colour model needs 16 GB of memory (this machine has ${Math.round(xo()/1e9)} GB)`:null}async function M9(){let e=Ut("CONFORM_AI_MODEL")??Ru(),t=Ut("CONFORM_MEDIA_GEN")??_(Ru(),"media-gen"),n={runner:t,model:e,preset:_(e,"balance.safetensors")};for(let i of[t,n.preset,_(e,"transformer.safetensors"),_(e,"vae.safetensors")])if(!await Ar(i))return null;return n}async function hI(e={}){let t=z9();if(t)throw new Error(t);let n=e.manifestUrl??Ut("CONFORM_AI_PACK_URL")??Cg;if(!n)throw new Error("the AI colour model has not been published yet (no pack manifest URL)");let i=await fetch(n);if(!i.ok)throw new Error(`could not read the AI pack manifest (${i.status})`);let r=await i.json(),o=Ru();await vt(o);for(let s of r.files){if(!gre.includes(s.name))throw new Error(`unexpected file in the AI pack: ${s.name}`);let c=_(o,s.name);if(await Ar(c)&&await rf(c)===s.sha256)continue;let l=0;await np(new URL(s.url,n).href,c,(f,d)=>{let m=Math.floor(100*f/(d||s.bytes));m>=l+5&&(l=m,e.onProgress?.(`${s.name} ${m}% of ${(s.bytes/1e9).toFixed(2)} GB`))});let u=await rf(c);if(u!==s.sha256)throw await Er(c),new Error(`${s.name} failed its checksum (got ${u}); deleted, run again to re-download`);s.name==="media-gen"&&await nf("chmod",["+x",c],()=>{})}let a=await M9();if(!a)throw new Error("the AI pack downloaded but is incomplete");return a}async function bI(e,t,n={}){let i=new Uint8Array(t.w*t.h*3);for(let c=0;c<i.length;c++)i[c]=Math.max(0,Math.min(255,Math.round(t.data[c]*255)));let r=await ii("conform-ai-"),o=_(r,"in.rgb");await or(o,i);let a=[],s=Date.now();try{let c=await nf(e.runner,["balance","--input-rgb",`${o}:${t.w}x${t.h}`,"--raw","u8","--model",e.model,"--preset",e.preset,"--edge",String(n.edge??512),"--seed",String(n.seed??376436993),"--steps",String(n.steps??3),"--sampler","sdcpp"],b=>a.push(b));if(c.code!==0)throw new Error(`the AI colour model failed (exit ${c.code}): ${c.stderr.trim().slice(-400)}`);let l=c.stderr.match(/ (\d+)x(\d+) [\d.]+s/);if(!l)throw new Error(`the AI colour model gave no output size: ${c.stderr.trim().slice(-200)}`);let[u,f]=[Number(l[1]),Number(l[2])],d=new Uint8Array(a.reduce((b,h)=>b+h.length,0)),m=0;for(let b of a)d.set(b,m),m+=b.length;if(d.length!==u*f*3)throw new Error(`the AI colour model returned ${d.length} bytes for ${u}x${f}`);let p=new Float32Array(d.length);for(let b=0;b<d.length;b++)p[b]=d[b]/255;return{data:p,w:u,h:f,ms:Date.now()-s}}finally{await Er(r).catch(()=>{})}}var T9=[.2126,.7152,.0722];function gI(e,t,n=2){let i=(u,f)=>T9[0]*Math.max(0,Math.min(1,u[f]))**2.4+T9[1]*Math.max(0,Math.min(1,u[f+1]))**2.4+T9[2]*Math.max(0,Math.min(1,u[f+2]))**2.4,r=[];for(let u=0;u<e.data.length;u+=3){let f=i(e.data,u);f>1e-5&&Math.max(e.data[u],e.data[u+1],e.data[u+2])<.99&&r.push(Math.log2(Math.max(i(t.data,u),1e-9)/Math.max(f,1e-9)))}if(r.length<64)return{image:t,askedStops:0,appliedStops:0};r.sort((u,f)=>u-f);let o=r.length,a=o%2?r[o-1>>1]:(r[o/2-1]+r[o/2])/2;if(Math.abs(a)<.01)return{image:t,askedStops:a,appliedStops:a};let s=a*Math.exp(-Math.abs(a)/n),c=2**(s-a),l=new Float32Array(t.data.length);for(let u=0;u<l.length;u++)l[u]=Math.min(1,(Math.max(0,Math.min(1,t.data[u]))**2.4*c)**(1/2.4));return{image:{data:l,w:t.w,h:t.h},askedStops:a,appliedStops:s}}var O9="ultraface_rfb640.onnx",yre="a9e7cb5308de493844547e3ffdc4458f68fc81da9672f33f1074ed149db36578";async function wre(){let e=_(Ru(),O9);if(await Ar(e))return e;let t=decodeURIComponent(new URL("../../color-balance-lab/balance-pass/models/"+O9,import.meta.url).pathname);if(await Ar(t))return t;if(!Cg)return null;try{return await vt(Ru()),await np(new URL(O9,Cg).href,e,()=>{}),await rf(e)!==yre?(await Er(e),null):e}catch{return null}}var vI=null,xre=null;function L9(){return xre??=import("onnxruntime-node").catch(e=>(console.error(`conformtools: onnxruntime-node unavailable (${e instanceof Error?e.message:e}); face protection and the reframe tier are off`),null))}async function yI(e){let t=await wre();if(!t)return[];let n=await L9();if(!n)return[];vI??=n.InferenceSession.create(t,{executionProviders:["cpu"]});let i=await vI,r=640,o=480,a=k9(gs(e,r),r,o),s=r*o,c=new Float32Array(s*3);for(let d=0;d<s;d++)c[d]=(a.data[d*3]*255-127)/128,c[s+d]=(a.data[d*3+1]*255-127)/128,c[2*s+d]=(a.data[d*3+2]*255-127)/128;let l=await i.run({input:new n.Tensor("float32",c,[1,3,o,r])}),u=l.scores.data,f=l.boxes.data;return pI(u,f,u.length/2)}var Pre=6e3;async function Sre(){let e=[Ut("CONFORM_SSCD_MODEL"),Fr(new URL("../../public/sscd/sscd_disc_mixup.288.fp16.onnx",import.meta.url)),Fr(new URL("../../.qc-scratch/sscd/sscd_disc_mixup.288.fp16.onnx",import.meta.url)),Fr(new URL("../../../tbd_conformtools/.qc-scratch/sscd/sscd_disc_mixup.288.fp16.onnx",import.meta.url))].filter(Boolean);for(let t of e)try{if((await cn(t)).isFile)return t}catch{}return null}var kre=async(e,t,n,i=1)=>{let{lane:r,...o}=await Om(e,{matte:t==="A"?"cut":"none",stride:i,onProgress:n});return o},Tre=async(e,t)=>{let{luma:n}=await Ho(e,void 0,{sparse:!0});return async i=>{let r=await n(i);if(!r)return null;let o=t==="A"?Za(r.y,r.w,r.h):null;return o?zr(Ia(r.y,r.w,o),o.w,o.h):zr(r.y,r.w,r.h)}};async function zre(e,t=4e3){let n=[],i=new Set;async function r(a){let s=await Ds(a).catch(()=>[a]);i.has(s[0])||(s.forEach(c=>i.add(c)),n.push(s[0]))}async function o(a,s){if(!(s>10||n.length>=t))for await(let c of zn(a)){if(c.name.startsWith("."))continue;let l=_(a,c.name);if(c.isDirectory?await o(l,s+1):c.isFile&&v9(c.name)&&await r(l),n.length>=t)return}}for(let a of e)if((await cn(a)).isDirectory)await o(a,0);else if(v9(ae(a)))await r(a);else throw new Error(`not a conformable media file: ${a}`);return eI(n,a=>a).kept}async function wI(e){await aI(),MZ(),tk(p5()),Rk(h5()),ak(!!e.display_transform);let t=e.display_transform?"rec709":void 0,n=await zre(e.pool);if(!n.length)throw new Error("pool is empty \u2014 no mov/mp4/r3d/mxf/braw/ari/crm files found");let i=await sr.open(e.reference),r=await Promise.all(n.map(async P=>{try{let X=await sr.open(P);return{p:P,file:X,luma:await Zp(X)}}catch(X){return{p:P,error:X instanceof Error?X.message:String(X)}}})),o=r.filter(P=>"error"in P),a=r.filter(P=>!("error"in P));if(!a.length)throw new Error(`no pool file could be read (${o.length} tried; first: ${o[0]?.error})`);let s=a.map(P=>P.p),c=a.map(P=>P.file),l=e.reframe_tier===!1?null:await Sre(),u=l&&await L9()?l:null;if(e.reframe_tier===!0&&!u)throw new Error("reframe_tier needs the SSCD model: set CONFORM_SSCD_MODEL to sscd_disc_mixup.288.fp16.onnx (exported by .qc-scratch/sscd_export_onnx.py, halved by scripts/sscd/weights_fp16.py)");let f=e.hints?(await EO(e.hints))?.session??e.hints:void 0,d=a.map(P=>P.luma),m=new Map,p=await Zp(i),b=new Map;c.forEach((P,X)=>b.set(P,d[X])),b.set(i,p);let h=async(P,X)=>{if(P.frames)return P.frames;let R=X.path;return R?(await Ws(R)).frames:0},v=async(P,X)=>{if(!u)return null;let R=c[P],I=d[P],q=R.path,Y=await h(I,R);if(!Y)return null;let D=q&&!I.src.geometrySpec&&I.src.index?.kind!=="prores"?await qp(q).catch(()=>null):null,j=D&&D.length>3?D.slice(1).map((ut,we)=>ut-D[we]):[],C=j.length&&Math.max(...j)-Math.min(...j)<=1?j[0]:0,H=C>24&&C<=96&&(!X||Y>Pre),ne=H?C:24,le=ne===24?0:D[0],Se={model:u,stride:ne,geometryWidth:Zs,display:t};if(H&&!X&&q){let ut=await Tm(q,{...Se,stride:24});if(ut?.length)return{clipIndex:P,label:R.name,stride:24,frames:Y,vecs:ut}}let Le=q?await Tm(q,Se):null;if(!Le&&q&&ne===24){let ut=await Tm(q,{...Se,stride:_m});ut?.length===Y&&(Le=Array.from({length:Math.ceil(Y/24)},(we,De)=>ut[De*24]))}if(!Le){let ut=Array.from({length:Math.ceil((Y-le)/ne)},(we,De)=>le+De*ne);Le=await Tv(I.luma,ut,{embed:we=>qg(we,u),signal:e.signal}),q&&Le.length&&await a9(q,Se,Le).catch(()=>{})}return{clipIndex:P,label:R.name,stride:ne,frames:Y,vecs:Le}},g=e.engine??(f?"legacy":"align"),y=new Set,w=new Set,x=[],T=async()=>{let P=()=>{let N=globalThis.Deno?.memoryUsage();return N?` \u2014 rss ${Math.round(N.rss/1048576)} MB, heap ${Math.round(N.heapUsed/1048576)}, external ${Math.round(N.external/1048576)}`:""},X=performance.now(),R=N=>{globalThis.process?.env?.CONFORM_DEBUG_NOMINATIONS&&console.error(`[time] ${N} ${((performance.now()-X)/1e3).toFixed(1)} s \u2014 ${Is.runs} decodes, ${Is.frames} frames (${Is.unique} distinct)${P()}`)},I=c.map((N,ue)=>ue).sort((N,ue)=>c[N].name.localeCompare(c[ue].name)),q=0,Y=Promise.all([0,1].map(async()=>{for(;q<I.length;)await Nu(s[I[q++]])})).catch(()=>{}),D=0,j=I.length+1,C=new Array(I.length),H=0,ne=h9(e.reference,{signal:e.signal});await Promise.all(Array.from({length:4},async()=>{for(;H<I.length;){let N=H++;C[N]=await h9(s[I[N]],{signal:e.signal}).catch(()=>({n:0,ok:new Uint8Array(0),g:new Uint16Array(0)})),await UZ(s[I[N]],C[N]),e.onProgress?.(++D,j,"index")}}));let le=await ne;e.onProgress?.(j,j,"index");let Se=async N=>{let ue=await gn(N);return{fps:ue.fps,start:ue.startFrame,drop:ue.dropFrame,n:ue.frames.length,w:ue.w,h:ue.h,codec:ue.label}},Le=await Se(i),ut=await Promise.all(I.map(N=>Se(c[N]).then(ue=>ue.fps).catch(()=>Le.fps))),we=ut.map(N=>N&&Le.fps?N/Le.fps:1);R("grids");let De=C.map(N=>!!N.feat),Je=u9(le,C,{onProgress:e.onProgress,rates:we});await Promise.all(C.map((N,ue)=>De[ue]?null:AZ(s[I[ue]],N).catch(()=>{}))),R("align"),await(async N=>{let ue=0,We=0;await Promise.all(Array.from({length:8},async()=>{for(;ue<N.length;){let Ae=N[ue++];e.signal?.throwIfAborted(),e.onProgress?.(We++,N.length,"align: confirming");let pt=Oi(Ae.refStart,Ae.refEnd,4),qe=await Promise.all(pt.map(ot=>p.luma(ot))),ht=null;for(let ot of Ae.candidates){let Ye=d[I[ot.clip]],Qe=we[ot.clip],gt=(await Promise.all(pt.map(async(Bt,Vt)=>{let kn=await Ye.luma(ot.srcStart+Math.floor((Bt-Ae.refStart)*Qe+.001));return kn&&qe[Vt]?{src:kn,ref:qe[Vt]}:null}))).filter(Bt=>!!Bt),en=ot.scale>0&&ot.scale!==1?{min_scale:ot.scale/1.2,max_scale:ot.scale*1.2}:{},Pt=gt.length>=2?await Mi(gt,{turns:!1,...en}).catch(()=>null):null;Pt&&(!ht||Pt.score>ht.score)&&(ht={c:ot,score:Pt.score})}ht&&ht.score>=.4&&(Ae.clip=ht.c.clip,Ae.srcStart=ht.c.srcStart,Ae.srcEnd=ht.c.srcStart+Math.floor((Ae.refEnd-Ae.refStart)*we[ht.c.clip]+.001),Ae.rot180=Ae.rot180&&ht.c.scale===1,Ae.sure=ht.score>=.55)}}))})(Je.filter(N=>(N.candidates?.length??0)>1)),R("confirm");let Me=640,Oe=Math.round(Me*(Le.h||9)/(Le.w||16)),bt=8,tt=.002,zt=.5,Ht=12,Mt=.01,mt=.6,K=.006,fe=12,Xe=.5,et=160,ft=Math.round(et*(Le.h||9)/(Le.w||16)),At=.6,Nt=72,Jt=12,nn=N=>{if(!N)return null;let ue=0,We=0;for(let pt of N)ue+=pt;ue/=N.length;for(let pt of N)We+=(pt-ue)**2;let Ae=Math.sqrt(We/N.length)||1;return N.map(pt=>(pt-ue)/Ae)},Ge=N=>N.slice(1).map((ue,We)=>{let Ae=N[We];if(!ue||!Ae||ue.length!==Ae.length)return NaN;let pt=0;for(let qe=0;qe<ue.length;qe++)pt+=Math.abs(ue[qe]-Ae[qe]);return pt/ue.length}),it=(N,ue)=>{let We=N.map((Ye,Qe)=>Qe).filter(Ye=>isFinite(N[Ye])&&isFinite(ue[Ye]));if(We.length<4)return-2;let Ae=0,pt=0;for(let Ye of We)Ae+=N[Ye],pt+=ue[Ye];Ae/=We.length,pt/=We.length;let qe=0,ht=0,ot=0;for(let Ye of We)qe+=(N[Ye]-Ae)*(ue[Ye]-pt),ht+=(N[Ye]-Ae)**2,ot+=(ue[Ye]-pt)**2;return qe/Math.sqrt(ht*ot||1)},Rt=!!globalThis.process?.env?.CONFORM_DEBUG_NOMINATIONS,rn=new Map,Ln=N=>{let ue=rn.get(N);return ue||(ue=p.luma(N).then(We=>zo(jn(We,Me,Oe),Me)).catch(()=>null),rn.set(N,ue)),ue},Sn={n:0,ms:0},Et=new Map,Tr=new Set,rr=new Set,oo=async(N,ue=!1,We=Ht,Ae=!1)=>{let pt=N.refEnd-N.refStart+1;if(N.clip<0||pt<2)return;let qe=d[I[N.clip]],ht=we[N.clip],ot=C[N.clip].n,Ye=ht,Qe,gt=(Ne,$e)=>Ne+Math.floor(($e-N.refStart)*Ye+.001),en=Ne=>qe.luma(Ne).then($e=>$e&&N.rot180?{...$e,y:$e.y.slice().reverse()}:$e).catch(()=>null),Pt=Math.min(bt,pt),Bt=Array.from({length:Pt},(Ne,$e)=>N.refStart+Math.round(($e+.5)*pt/Pt-.5)),Vt=await Promise.all(Bt.map(Ln)),kn=async(Ne,$e)=>{let Ke=(await Promise.all($e.map(async pn=>{let[hn,$t]=await Promise.all([p.luma(pn),en(gt(Ne,pn))]);return hn&&$t?{ref:hn,src:$t}:null}))).filter(pn=>!!pn),Ft=performance.now(),Ct=Qe?{min_scale:Qe/1.08,max_scale:Qe*1.08}:{},wn=Ke.length>=3?await Mi(Ke,{...ue?{}:{turns:!1},...Ct}).catch(()=>null):null;wn&&!Qe&&(Qe=wn.scale_fit),Sn.n++,Sn.ms+=performance.now()-Ft;let un=wn?ao(wn.transform):null;return un?{inv:un,w:Ke[0].ref.w,h:Ke[0].ref.h,sw:Ke[0].src.w,sh:Ke[0].src.h}:null},Dn=Ne=>[Ne-1,Ne,Ne+1].filter($e=>$e>=N.refStart&&$e<=N.refEnd).concat(Ne===N.refStart?[Ne+2]:Ne===N.refEnd?[Ne-2]:[]),ir=async(Ne,$e,Ke)=>{let Ft=Bt.map($t=>gt(Ne,$t));if(Ft[0]<0||Ft[Pt-1]>=ot)return null;let Ct=await Promise.all(Ft.map(en)),wn=Ke!==void 0?Ke:$e?await kn(Ne,Oi(N.refStart,N.refEnd,6)):null,un=$e&&Ke===void 0?await Promise.all(Bt.map($t=>kn(Ne,Dn($t)))):null,pn=[()=>null];wn&&pn.push(()=>wn),un?.every(Boolean)&&pn.push($t=>un[$t]);let hn=[];for(let $t of pn){let Rr=0,qt=0;for(let on=0;on<Pt;on++){let vr=$t(on),Cn=zo(vr?hi(Ct[on],vr.inv,vr.w,vr.h,Me,Oe):jn(Ct[on],Me,Oe),Me);Vt[on]&&Cn&&(Rr+=zp(Vt[on],Cn),qt++)}hn.push(qt>=Math.max(1,Pt>>1)?Rr/qt:-1/0)}return hn};{if(pt>=Jt){let Ft=Math.max(0,gt(N.srcStart,N.refStart)-We),Ct=Math.min(ot-1,gt(N.srcStart,N.refEnd)+We);await Promise.all(Array.from({length:Ct-Ft+1},(wn,un)=>en(Ft+un)))}let Ne=(await ir(N.srcStart,!1))?.[0]??-1/0,$e=!!N.reframed||Ne<zt,Ke=$e?await kn(N.srcStart,Oi(N.refStart,N.refEnd,6)):null;if((!$e||Ke)&&pt>=Jt){let Ft=Array.from({length:pt},(qt,on)=>N.refStart+on),Ct=Ge(await Promise.all(Ft.map(qt=>p.luma(qt).then(on=>nn(jn(on,et,ft))).catch(()=>null)))),wn=new Map,un=qt=>wn.get(qt)??wn.set(qt,qt<0||qt>=ot?Promise.resolve(null):en(qt).then(on=>nn(Ke?hi(on,Ke.inv,Ke.w,Ke.h,et,ft):jn(on,et,ft)))).get(qt),pn=async(qt,on)=>{let vr={s:on,r:-2};for(let Cn=-We;Cn<=We;Cn++){let _n=it(Ct,Ge(await Promise.all(Ft.map(Dr=>un(on+Cn+Math.floor((Dr-N.refStart)*qt+.001))))));_n>vr.r&&(vr={s:on+Cn,r:_n})}return vr},hn={s:N.srcStart,e:N.srcEnd,slope:N.slope},$t=await pn(ht,N.srcStart),Rr=!1;if(Math.abs(ht-1)>.01){let qt=Bt[Pt>>1],on=await pn(1,gt(N.srcStart,qt)-(qt-N.refStart));on.r>$t.r+Mt&&($t=on,Rr=!0)}Rt&&console.error(`[motion] ${N.refStart}-${N.refEnd} @${N.srcStart} \u2192 ${$t.s}${Rr?" frame for frame":""} r=${$t.r.toFixed(3)}${Ke?" sized":""}`),$t.r>=At&&(Rr&&(Ye=1,N.slope=1),N.srcStart=$t.s,N.srcEnd=Rr?$t.s+(pt-1):$t.s+Math.floor((pt-1)*ht+.001));{let qt=Ge(await Promise.all(Ft.map(Cn=>un(gt(N.srcStart,Cn))))),on=(Cn,_n)=>{let Dr=Cn.slice(Math.max(0,_n-6),_n+7).filter((qr,wo)=>isFinite(qr)&&wo!==Math.min(_n,6)).sort((qr,wo)=>qr-wo);return Cn[_n]/(Dr[Dr.length>>1]||1e-6)},vr=Ct.flatMap((Cn,_n)=>{let Dr=on(Ct,_n);return Dr>=2.5&&Cn-Cn/Dr>.01&&!(on(qt,_n)>Dr/2)?[N.refStart+_n+1]:[]}).filter(Cn=>Cn-N.refStart>=3&&N.refEnd-Cn>=2);if(vr.length&&We===Ht){let Cn=[...vr,N.refEnd+1],_n=[],Dr=N.refStart;for(let qr of Cn){if(Dr===N.refStart)N.refEnd=qr-1,N.srcEnd=gt(N.srcStart,qr-1),_n.push(N);else{let wo={...N,refStart:Dr,refEnd:qr-1,srcStart:gt(N.srcStart,Dr),candidates:void 0};wo.srcEnd=wo.srcStart+Math.floor((qr-1-Dr)*Ye+.001),Je.push(wo),_n.push(wo)}Dr=qr}Rt&&console.error(`[motion] jump cuts at ${vr.join(" ")}`);for(let qr of _n)await oo(qr,ue,qr.refEnd-qr.refStart+1>=Jt?Nt:3);return}}if($t.r>=At){Ke?Qe&&m.set(N.refStart,Qe):m.set(N.refStart,1);let qt=async _n=>{let Dr=Ke?await kn(N.srcStart+_n,Oi(N.refStart,N.refEnd,6))??Ke:null,qr=await ir(N.srcStart+_n,!1,Dr);return qr?Math.max(...qr):-1/0},[on,vr,Cn]=await Promise.all([qt(-1),qt(0),qt(1)]);if(!Ke||Math.max(on,vr,Cn)>=mt){let _n=on>vr+tt&&on>=Cn?-1:Cn>vr+tt?1:0;_n&&(N.srcStart+=_n,N.srcEnd+=_n),Et.set(N,Math.max(on,vr,Cn));return}N.srcStart=hn.s,N.srcEnd=hn.e,N.slope=hn.slope,Ye=ht}if(Ke&&!Ae){let qt=await ir(N.srcStart,!1,Ke),on=qt?Math.max(...qt):0;if(on<mt){Et.set(N,on),Tr.add(N);return}}}}let Lt=[-2,-1,0,1,2],Qn=Ne=>Promise.all(Lt.map($e=>ir(N.srcStart+$e,Ne))),fr=await Qn(!!N.reframed);!N.reframed&&(fr[2]?.[0]??0)<zt&&(fr=await Qn(!0));let En=Lt.map((Ne,$e)=>[Ne,fr[$e]?Math.max(...fr[$e]):null]).filter(Ne=>Ne[1]!=null&&Ne[1]>-1/0),mn=En.find(([Ne])=>Ne===0)?.[1];if(En.length>=3&&Math.max(...En.map(Ne=>Ne[1]))-Math.min(...En.map(Ne=>Ne[1]))<K?rr.add(N):rr.delete(N),Rt&&console.error(`[exact] ${N.refStart}-${N.refEnd} @${N.srcStart}: ${Lt.map((Ne,$e)=>`${Ne}:${fr[$e]?.map(Ke=>Ke.toFixed(3)).join("/")}`).join(" ")}`),mn==null)return;let _t=En.reduce((Ne,$e)=>$e[1]>Ne[1]?$e:Ne),lt=!!N.reframed||fr.some(Ne=>(Ne?.length??0)>1);for(let Ne=_t[0]+Math.sign(_t[0]);Math.abs(_t[0])===Math.abs(Ne)-1&&Math.abs(Ne)<=Ht&&Math.abs(_t[0])>=2;Ne+=Math.sign(Ne)){let $e=await ir(N.srcStart+Ne,lt),Ke=$e?Math.max(...$e):-1/0;if(Ke>_t[1])_t=[Ne,Ke];else break}if(Math.abs(ht-1)>.01){let Ne=Bt[Pt>>1],$e=gt(N.srcStart+_t[0],Ne);Ye=1;let Ke=$e-(Ne-N.refStart),Ft=!1;for(let Ct=-2;Ct<=2;Ct++){let wn=await ir(Ke+Ct,lt),un=wn?Math.max(...wn):-1/0;un>_t[1]+Mt&&(_t=[Ke+Ct-N.srcStart,un],Ft=!0)}Rt&&console.error(`[exact] frame for frame: ${Ft?`wins at ${N.srcStart+_t[0]} ${_t[1].toFixed(3)}`:"no"}`),Ft?(N.slope=1,N.srcEnd=N.srcStart+_t[0]+(pt-1)):Ye=ht}_t[0]!==0&&_t[1]>mn+tt&&(N.srcStart+=_t[0],N.slope==null&&(N.srcEnd+=_t[0])),Et.set(N,Math.max(_t[1],mn))},je=async(N,ue=!1,We=!1)=>{let Ae=0,pt=0;await Promise.all(Array.from({length:8},async()=>{for(;Ae<N.length;)e.signal?.throwIfAborted(),await oo(N[Ae++],ue,Ht,We),e.onProgress?.(++pt,N.length,"align: exact frame")}))};await je(Je.filter(N=>N.clip>=0)),Je.sort((N,ue)=>N.refStart-ue.refStart),R(`exact (${Sn.n} fits, ${(Sn.ms/1e3).toFixed(1)} s summed)`);let Hn=Je.filter(N=>N.clip>=0&&N.refEnd-N.refStart>=3&&(Et.get(N)??1)<mt);if(Hn.length){let N=new km,ue=0;await Promise.all([0,1].map(async()=>{for(;ue<I.length;){let qe=ue++,ht=I[qe],ot=await GZ(s[ht],C[qe].n,Qe=>d[ht].luma(Qe),fe,e.signal).catch(()=>[]),Ye=(await Promise.all(Array.from({length:Math.ceil(ot.length/64)},(Qe,gt)=>VZ(ot.slice(gt*64,gt*64+64).map(en=>en.st))))).flat();ot.forEach((Qe,gt)=>N.add(qe,Qe.frame,Qe.st,Ye[gt]))}})),jZ(),R(`star catalogue (${N.size} frames)`);let We=new Set,Ae=[],pt=[];for(let qe of Hn){let ht=qe.refStart+qe.refEnd>>1,ot=N.find(await p.luma(ht).catch(()=>null));if(pt.push(`${qe.refStart}-${qe.refEnd}:${Et.get(qe).toFixed(2)}${ot?` ${ot.clip}@${ot.frame} ${(ot.inl*100).toFixed(0)}% \xD7${ot.scale.toFixed(2)} ${ot.rot.toFixed(1)}\xB0${ot.flip?" flop":""}`:""}`),!ot||ot.inl<Xe)continue;let Ye=Math.abs(ot.rot)>90;(Math.abs(Ye?180-Math.abs(ot.rot):ot.rot)>1||ot.flip)&&We.add(qe);let gt=en=>Math.floor((ht-qe.refStart)*we[en]+.001);ot.clip===qe.clip&&Math.abs(qe.srcStart+gt(qe.clip)-ot.frame)<=fe||(qe.clip=ot.clip,qe.srcStart=Math.max(0,ot.frame-gt(ot.clip)),qe.srcEnd=qe.srcStart+Math.floor((qe.refEnd-qe.refStart)*we[ot.clip]+.001),qe.slope=void 0,qe.rot180=Ye,qe.reframed=ot.scale>1.03||We.has(qe)?ot.scale:void 0,qe.sure=!0,Ae.push(qe))}Rt&&console.error(`[weak] ${Hn.length} weak shots, plate solved: ${pt.join(" | ")}; moved ${Ae.map(qe=>qe.refStart).join(" ")}; turned ${[...We].map(qe=>qe.refStart).join(" ")}`),await je(Ae.filter(qe=>!We.has(qe))),await je([...We],!0),await je(Hn.filter(qe=>Tr.has(qe)&&!Ae.includes(qe)&&!We.has(qe)),!1,!0)}R("weak shots");let Ii=8,Uo=3,qc=12,Em=2,Cm=.9,Z=.95,ee=.9,ce=[];for(let N=0;N<Je.length;N++){let ue=Je[N];if(ue.clip<0||ue.refEnd-ue.refStart+1>Ii)continue;let We=N;for(;We+1<Je.length;){let qe=Je[We],ht=Je[We+1];if(ht.clip!==ue.clip||ht.refStart!==qe.refEnd+1||ht.refEnd-ht.refStart+1>Ii||ht.srcStart<qe.srcStart-Em)break;We++}let Ae=Je[We];if(We-N+1<Uo||Ae.refEnd-ue.refStart+1<qc||Ae.srcStart<=ue.srcStart)continue;let pt=(Ae.srcStart-ue.srcStart)/Math.max(1,Ae.refStart-ue.refStart);if(!(pt>Cm*we[ue.clip])){ce.push(`${ue.refStart}-${Ae.refEnd} ${We-N+1} pieces @${ue.srcStart}\u2192${Ae.srcStart} (${(pt/we[ue.clip]*100).toFixed(0)} %)`),Object.assign(ue,{refEnd:Ae.refEnd,srcEnd:ue.srcStart+Math.floor((Ae.refEnd-ue.refStart)*pt+.001),slope:pt,sure:!1});for(let qe of Je.slice(N+1,We+1))Et.delete(qe),Tr.delete(qe),rr.delete(qe);Je.splice(N+1,We-N),Et.set(ue,0)}}Rt&&ce.length&&console.error(`[merge] ${ce.join(" | ")}`);let ve=128,B=Math.round(ve*(Le.h||9)/(Le.w||16)),se=48,Fe=.02,dt=.9,Ie=256,yt=Math.round(Ie*(Le.h||9)/(Le.w||16)),Ue=24,He=.02,St=.2,Qt=N=>N?Vg(zo(N,ve)):null,Wt=[],me=new Set;for(let N of Je.filter(ue=>ue.clip>=0&&ue.refEnd-ue.refStart>=7&&(Et.get(ue)??1)<dt)){e.signal?.throwIfAborted();let ue=N.refEnd-N.refStart+1,We=we[N.clip],Ae=N.slope??We,pt=d[I[N.clip]],qe=C[N.clip].n,ht=mn=>pt.luma(mn).then(_t=>_t&&N.rot180?{..._t,y:_t.y.slice().reverse()}:_t).catch(()=>null),ot=Oi(N.refStart,N.refEnd,6),Ye=(await Promise.all(ot.map(async mn=>{let[_t,lt]=await Promise.all([p.luma(mn).catch(()=>null),ht(N.srcStart+Math.floor((mn-N.refStart)*Ae+.001))]);return _t&&lt?{ref:_t,src:lt}:null}))).filter(mn=>!!mn),Qe=Ye.length>=3?await Mi(Ye,N.reframed?{min_scale:N.reframed/1.2,max_scale:N.reframed*1.2}:{}).catch(()=>null):null,gt=Qe?ao(Qe.transform):null,en=Math.max(0,N.srcStart-Math.ceil(2*ue*We)-24),Pt=Math.min(qe-1,N.srcStart+Math.ceil(5*ue*We)+24),Bt=Math.ceil(ue/se),Vt=Array.from({length:Math.ceil(ue/Bt)},(mn,_t)=>_t*Bt),kn=await Promise.all(Vt.map(mn=>p.luma(N.refStart+mn).then(_t=>Qt(jn(_t,ve,B))).catch(()=>null))),Dn=await Promise.all(Array.from({length:Pt-en+1},(mn,_t)=>ht(en+_t).then(lt=>[Qt(jn(lt,ve,B)),gt&&Ye.length?Qt(hi(lt,gt,Ye[0].ref.w,Ye[0].ref.h,ve,B)):null]))),Lt=[f9(kn,Vt,Dn.map(mn=>mn[0]),We),gt?f9(kn,Vt,Dn.map(mn=>mn[1]),We):null].reduce((mn,_t)=>_t&&(!mn||_t.score>mn.score)?_t:mn,null);if(!Lt)continue;let Qn=Lt.scoreOf(Ae,N.srcStart-en),fr=c[I[N.clip]].name;Wt.push(`${N.refStart}-${N.refEnd}@${N.srcStart}: ${Lt.speed.toFixed(3)}\xD7@${en+Lt.start} ${Lt.score.toFixed(3)} (now ${Qn.toFixed(3)}) margin ${Lt.margin.toFixed(2)}`),Lt.observable&&Lt.score>Qn+Fe&&(N.srcStart=en+Lt.start,N.slope=Lt.speed,N.srcEnd=N.srcStart+Math.floor((ue-1)*Lt.speed+.001)),Lt.observable&&Lt.score>=Z&&(N.slope??We)<Cm*We&&me.add(N);let En=!1;if(ue>=Ue&&Qe&&Qe.score>=bf){let mn=un=>{let pn=gt&&Ye.length?hi(un,gt,Ye[0].ref.w,Ye[0].ref.h,Ie,yt):jn(un,Ie,yt);return pn?Vg(zo(pn,Ie)):null},_t=await Promise.all(Array.from({length:ue},(un,pn)=>p.luma(N.refStart+pn).then(hn=>{let $t=jn(hn,Ie,yt);return $t?Vg(zo($t,Ie)):null}).catch(()=>null))),lt=await Promise.all(Array.from({length:Pt-en+1},(un,pn)=>ht(en+pn).then(hn=>hn?mn(hn):null))),Ne=lt.length,$e=new Float32Array(ue*Ne).fill(NaN);for(let un=0;un<ue;un++){let pn=_t[un];if(pn)for(let hn=0;hn<Ne;hn++){let $t=lt[hn];if(!$t)continue;let Rr=0;for(let qt=0;qt<pn.length;qt++)Rr+=pn[qt]*$t[qt];$e[un*Ne+hn]=Rr}}let Ke=m9($e,ue,Ne),Ft=(()=>{let un=N.slope??We,pn=0,hn=0;for(let $t=0;$t<ue;$t++){let Rr=N.srcStart-en+Math.floor($t*un+.001),qt=Rr>=0&&Rr<Ne?$e[$t*Ne+Rr]:NaN;qt===qt&&(pn+=qt,hn++)}return hn?pn/hn:-1})(),Ct=Ke?Ke.frames.reduce((un,pn,hn)=>{let $t=$e[hn*Ne+pn];return $t===$t?un+$t:un},0)/ue:-1,wn=Ke?Math.max(...Ke.speeds)-Math.min(...Ke.speeds):0;if(Wt.push(` ramp? path ${Ct.toFixed(3)} vs line ${Ft.toFixed(3)}, speeds ${Ke?`${Math.min(...Ke.speeds)}\u2013${Math.max(...Ke.speeds)}`:"-"}`),Ke&&Ct>Ft+He&&wn>=St){let un=p9(Ke);Object.assign(N,{srcStart:en+Ke.frames[0],srcEnd:en+Ke.frames[ue-1],slope:void 0,ramp:un.map(([pn,hn])=>[pn,hn/We*100])}),En=!0}}!Lt.observable&&!En&&x.push({kind:"speed_unobservable",refStart:N.refStart,refEnd:N.refEnd,message:`${fr}: too little motion to confirm this shot's moment and speed from the picture \u2014 check it against the reference.`})}Rt&&Wt.length&&console.error(`[line] ${Wt.join(" | ")}`);let Be=[],Ee=(N,ue)=>{let We=0;for(let Ae=0;Ae<N.length;Ae++)We+=N[Ae]*ue[Ae];return We};for(let N of me){let ue=we[N.clip],We=N.slope??ue,Ae=d[I[N.clip]],pt=C[N.clip].n,qe=[N.refStart,N.refEnd],ht=ot=>N.srcStart+Math.floor((ot-N.refStart)*We+.001);for(let ot of[-1,1])for(;;){e.signal?.throwIfAborted();let Ye=Je.indexOf(N),Qe=Je[Ye+ot];if(!Qe||(ot<0?Qe.refEnd!==N.refStart-1:Qe.refStart!==N.refEnd+1)||Qe.clip>=0&&(Qe.refEnd-Qe.refStart+1>Ii||Qe.ramp||Qe.sure&&(Et.get(Qe)??1)>=dt))break;let gt=0,en=0,Pt=!1;for(let kn=Qe.refStart;kn<=Qe.refEnd;kn++){let Dn=ht(kn);if(Dn<0||Dn>=pt){Pt=!0;break}let[ir,Lt]=await Promise.all([p.luma(kn).then(Qn=>Qt(jn(Qn,ve,B))).catch(()=>null),Ae.luma(Dn).then(Qn=>Qt(jn(Qn&&N.rot180?{...Qn,y:Qn.y.slice().reverse()}:Qn,ve,B))).catch(()=>null)]);ir&&Lt&&(gt+=Ee(ir,Lt),en++)}if(Pt||!en||gt/en<ee)break;if(ot>0){N.refEnd=Qe.refEnd,N.srcEnd=N.srcStart+Math.floor((N.refEnd-N.refStart)*We+.001),Et.delete(Qe),Tr.delete(Qe),rr.delete(Qe),Je.splice(Je.indexOf(Qe),1);continue}let Bt=N.refStart-Qe.refStart,Vt=Bt;for(;Vt>0&&Math.abs(Vt*We-Math.round(Vt*We))>1e-6;)Vt--;if(Vt===0&&(Vt=Bt),N.srcStart-=Math.round(Vt*We),N.refStart-=Vt,N.srcEnd=N.srcStart+Math.floor((N.refEnd-N.refStart)*We+.001),Vt===Bt)Et.delete(Qe),Tr.delete(Qe),rr.delete(Qe),Je.splice(Je.indexOf(Qe),1);else{Qe.refEnd=N.refStart-1;break}}(N.refStart!==qe[0]||N.refEnd!==qe[1])&&Be.push(`${qe[0]}-${qe[1]} \u2192 ${N.refStart}-${N.refEnd} @${N.srcStart} ${(We/ue*100).toFixed(0)} %`)}Rt&&Be.length&&console.error(`[grow] ${Be.join(" | ")}`),R("speed line");let dn=.9,Vn=await Nu(e.reference_audio??e.reference),Ce=Je.filter(N=>N.refEnd-N.refStart>=2&&(N.clip<0||(Et.get(N)??1)<dt||rr.has(N)));if(Vn&&Vn.length>=8e3&&Ce.length){await Y;let N=new qa,ue=qa.reference(Vn),We=Ye=>Nu(s[I[Ye]]),Ae=Math.max(1,Math.min(6,Po()>>1)),pt=[];for(let Ye=0;Ye<I.length;Ye++){for(let gt=pt.length;gt<Math.min(I.length,Ye+Ae);gt++)pt[gt]=fI(s[I[gt]]);let Qe=await pt[Ye];delete pt[Ye],Qe&&N.addMarks(Ye,Qe)}let qe=new Map,ht=Ye=>{let Qe=qe.get(Ye);return Qe?(qe.delete(Ye),qe.set(Ye,Qe),Qe):(Qe=We(Ye),qe.set(Ye,Qe),qe.size>8&&qe.delete(qe.keys().next().value),Qe)},ot=[];for(let Ye of Ce){e.signal?.throwIfAborted();let Qe=Ye.refStart/Le.fps,gt=(Ye.refEnd+1)/Le.fps,en=(Qe+gt)/2,[Pt,Bt]=gt-Qe<1?[Math.max(0,en-.5),en+.5]:[Qe,gt],Vt=null,kn=gt-Qe<1?[...N.nominate(ue,Qe,gt,5),...N.nominate(ue,Pt,Bt,5)]:N.nominate(ue,Pt,Bt,5);for(let Lt of kn){let Qn=await ht(Lt.clip),fr=Qn?dI(Vn,Qn,Qe,gt,Qe+Lt.shiftSec):null;fr&&fr.ncc>=dn&&(!Vt||fr.ncc>Vt.ncc)&&(Vt={k:Lt.clip,...fr})}if(!Vt)continue;let Dn=Math.round(Vt.clipSec*ut[Vt.k]);if(Ye.clip>=0&&(Et.get(Ye)??1)>=dt&&(Vt.k!==Ye.clip||Math.abs(Dn-Ye.srcStart)>Nt))continue;let ir=Ye.clip<0?"gap":`${c[I[Ye.clip]].name}@${Ye.srcStart}`;ot.push(`${Ye.refStart}-${Ye.refEnd} ${ir} \u2192 ${c[I[Vt.k]].name}@${Dn} ncc ${Vt.ncc.toFixed(3)}`),Object.assign(Ye,{clip:Vt.k,srcStart:Dn,srcEnd:Dn+Math.floor((Ye.refEnd-Ye.refStart)*we[Vt.k]+.001),slope:void 0,ramp:void 0,sure:!0,rot180:!1}),w.add(Ye.refStart)}Rt&&ot.length&&console.error(`[sound] ${ot.join(" | ")}`)}R("sound");let yn=6;Je.sort((N,ue)=>N.refStart-ue.refStart);for(let N=0;N<Je.length;N++){let ue=Je[N];if(ue.clip<0)continue;let We=N+1;for(;We<Je.length&&Je[We].clip<0;)We++;let Ae=Je[We];if(!Ae||Ae.clip!==ue.clip||!!Ae.rot180!=!!ue.rot180||(ue.slope??we[ue.clip])!==(Ae.slope??we[Ae.clip]))continue;let pt=Ae.refStart-ue.refEnd-1,qe=ue.slope??we[ue.clip];pt<1||pt>yn||Ae.srcStart!==ue.srcStart+Math.floor((Ae.refStart-ue.refStart)*qe+.001)||(ue.refEnd=Ae.refEnd,ue.srcEnd=Ae.srcEnd,Je.splice(N+1,We-N),N--)}let Bn=[...new Set(Je.filter(N=>N.clip>=0).map(N=>I[N.clip]))],Nr=await Promise.all(Bn.map(async N=>{let ue=await Se(c[N]);return{clipIndex:N,label:c[N].name,shots:[],coverage:0,srcFps:ue.fps,srcStartFrame:ue.start,srcFrames:ue.n||C[I.indexOf(N)].n,srcW:ue.w,srcH:ue.h,codec:ue.codec,warnings:[]}})),Xn=Je.map(N=>{if(N.clip<0)return{refStart:N.refStart,refEnd:N.refEnd,kind:"gap"};let ue=c[I[N.clip]].name;N.rot180&&y.add(N.refStart),N.sure||x.push({kind:"ambiguous",refStart:N.refStart,refEnd:N.refEnd,message:`${ue}: in-point uncertain \u2014 aligner confidence ${N.conf.toFixed(2)}; check this shot against the reference.`});let We=we[N.clip],Ae=N.slope!=null&&Math.abs(N.slope/We-1)>.005?{slope:N.slope/We,percent:N.slope/We*100,kind:"retime",samples:bt,residual:0,basis:"frame-for-frame"}:void 0,pt=N.ramp;return{refStart:N.refStart,refEnd:N.refEnd,kind:"static",clipLabel:ue,srcStart:N.srcStart,srcEnd:N.srcEnd,...pt?{ramp:pt}:Ae?{speed:Ae}:{}}});return{refFps:Le.fps,refStartFrame:Le.start,refFrames:le.n,refDropFrame:Le.drop,refW:Le.w,refH:Le.h,clips:Nr,timeline:Xn}},z=new Map,k;try{if(k=g==="align"?await T():await my(i,c,{lumaCacheBytes:Math.min(6*2**30,Math.max(2**30,Math.floor(xo()/20))),fingerprint:kre,hashFrame:Tre,onProgress:e.onProgress,signal:e.signal,candidateLuma:(P,X)=>d[P].luma(X),candidateThumb:(P,X)=>{let R=d[P],I=c[P].path;if(I&&!t&&R.src.index?.kind!=="prores"&&!R.src.geometrySpec)return el(I).then(Y=>Y.read(X)).catch(()=>R.luma(X));let q=z.get(P);return q||(q=Zp(c[P],"index").catch(()=>d[P]),z.set(P,q)),q.then(Y=>Y.luma(X))},referenceLuma:P=>p.luma(P),audioPcm:P=>{let X=P==="ref"?e.reference_audio??e.reference:c[P].path;return X?uI(X):Promise.resolve(null)},examineAll:e.examine_all,keyframesOf:async P=>{let X=P.path;return X?qp(X):null},frameCount:async P=>{let X=b.get(P);return X?h(X,P):0},...e.find_first&&u?{findFirst:{index:P=>v(P,!1),indexFine:P=>v(P,!0),embedRef:(P,X)=>Tv(p.luma,P,{embed:R=>qg(R,u),signal:e.signal,onProgress:X})}}:{},...f?{hints:KZ(f,void 0,{allTracks:!0})}:{},...u?{embedSweep:async P=>{let X=b.get(P),R=P.path,I={model:u,stride:_m,geometryWidth:Zs,display:t},q=R?await Tm(R,I):null;if(q)return q;let Y=await j6(X.luma,await h(X,P),{stride:_m,embed:D=>qg(D,u),signal:e.signal,onProgress:(D,j)=>e.onProgress?.(D,j,`reframe tier: ${P.name}`)});return R&&await a9(R,I,Y).catch(()=>{}),Y}}:{}}),e.sizing!==!1){let P=new Map(c.map((H,ne)=>[H.name,ne])),X=k.timeline.filter(H=>H.clipLabel&&(H.kind==="static"||H.kind==="unresolved")).length,R=0,I=performance.now(),q=await _8(k,{ref:H=>p.luma(H),src:async(H,ne)=>{let le=P.get(H);return le==null?null:await d[le].luma(ne)}},{log:()=>e.onProgress?.(++R,X,"sizing"),hint:H=>m.get(H)}),Y=!!globalThis.process?.env?.CONFORM_DEBUG_NOMINATIONS;Y&&console.error(`[time] sizing ${((performance.now()-I)/1e3).toFixed(1)} s`),e.onProgress?.(X,X,`sizing: ${q.sized} measured (${q.animated} moving), ${q.untrusted} left unresized`);let D=Number(globalThis.process?.env?.CONFORM_DYN_KEEP??.05),j=k.timeline.filter(H=>H.kind==="unresolved"&&!w.has(H.refStart)&&H.clipLabel&&H.srcStart!=null&&H.srcEnd!=null),C=[];for(let H of j){e.signal?.throwIfAborted();let ne=P.get(H.clipLabel),le=ne==null?null:await HZ(H,Le=>p.luma(Le),Le=>d[ne].luma(Le),k.refW||16,k.refH||9);if(C.push(`${H.refStart}-${H.refEnd} ${H.clipLabel}@${H.srcStart}: ${le==null?"n/a":le.toFixed(3)}`),le!=null&&le>=D)continue;let Se=`${H.track?.label??"sizing not measured"}; motion agreement ${le==null?"not measurable":le.toFixed(2)}, below ${D}`;Object.assign(H,{kind:"gap",unconfirmed:{clipLabel:H.clipLabel,srcFrame:H.srcStart,why:Se}});for(let Le of["clipLabel","srcStart","srcEnd","track","speed"])delete H[Le]}Y&&C.length&&console.error(`[dyn] keep \u2265 ${D}: ${C.join(" | ")}`)}}finally{OZ(),await m5([e.reference,...s])}let S=d8(k,{name:e.name??`${ae(e.reference)} auto conform`,referenceName:ae(e.reference)});for(let P of S.session.timelines[0]?.tracks[0]?.items??[]){let X=Math.round(P.timeline_range?.start.value??-1);y.has(X)&&!k.timeline.find(R=>R.refStart===X)?.track&&(P.rotation=180)}S.issues.push(...x);let M=JZ(S.session,S.issues),L=new Map(s.map(P=>[ae(P),P]));for(let P of M.media_references??[]){let X=L.get(ae(P.target_url??""))??L.get(P.reel_name??"");X&&(P.target_url=X,P.local_path=X)}return{session:M,report:k,issues:S.issues,stats:S.stats,pool:s,unreadable:o.map(P=>({path:P.p,error:P.error}))}}function xI(e){let t=new Set(e.issues.map(n=>n.kind));return(e.report.timeline??[]).some(n=>n.kind==="gap")&&t.add("gap"),e.unreadable?.length&&t.add("unreadable"),t}function PI(e){let t=e.report,n=t.timeline??[],i={};for(let a of n)i[a.kind??"?"]=(i[a.kind??"?"]??0)+1;let r=e.issues,o={};for(let a of r)o[a.kind]=(o[a.kind]??0)+1;return[`reference ${t.refFrames??"?"} frames @ ${t.refFps??"?"} fps; pool ${e.pool.length} clip(s)${t.triage?` (examined ${t.triage.examined??"?"}, skipped ${t.triage.skipped??0})`:""}`,...e.unreadable?.length?[`unreadable pool files (left out): ${e.unreadable.length} \u2014 ${e.unreadable.slice(0,5).map(a=>`${ae(a.path)}: ${a.error.slice(0,80)}`).join("; ")}${e.unreadable.length>5?"; \u2026":""}`]:[],`timeline segments: ${Object.entries(i).map(([a,s])=>`${s} ${a}`).join(", ")}`,`stats: ${JSON.stringify(e.stats)}`,`issues: ${r.length?Object.entries(o).map(([a,s])=>`${s} ${a}`).join(", "):"none"}`,...r.slice(0,25).map(a=>`- [${a.kind}] ${a.message??a.note??""}${a.refStart!=null?` @ ${a.refStart}${a.refEnd!=null?`\u2013${a.refEnd}`:""}`:""}`)].join(`
174
+ `)}var Rm=["plain","short","jump","lookalike","punch_in","turned","animated","offrate","retime","ramp","pip","gap","lower_third","locator","title","frankenbite"],Fu={plain:{plain:1},hard:{plain:2,short:3,jump:2,lookalike:3,punch_in:2,turned:1,animated:1,offrate:1,gap:1},all:{plain:2,short:3,jump:2,lookalike:3,punch_in:2,turned:1,animated:1,offrate:1,retime:1,ramp:1,pip:1,gap:1,lower_third:1,locator:1,title:1},speed:{plain:1,offrate:3,retime:3,ramp:3},sound:{plain:2,short:1,jump:2,lookalike:3,punch_in:1,frankenbite:2},graphics:{plain:1,lower_third:3,locator:3,title:2}},X9=new Set(["lower_third","locator","title"]),SI=["MARIA ALVAREZ","DR. JAMES OKAFOR","SARAH CHEN","TOM WHITFIELD","ANA LUCIA REYES","MARCUS BELL"],kI=["Small Business Owner","Emergency Physician","City Council Member","Rancher, 4th Generation","Teacher","Veteran, U.S. Army"],TI=["AUSTIN, TEXAS","LOCKHART, TX","SAN MARCOS","CALDWELL COUNTY","HOUSTON, TEXAS","WEST TEXAS"],zI=["STRONGER TOGETHER","THE ROAD AHEAD","PLANNING AHEAD","RIGHT HERE AT HOME","VOTE NOVEMBER 5"];var Mre=(e,t)=>e.path<t.path?-1:e.path>t.path?1:0;function Ore(e){let t=[],n=[],i=new Map;for(let{path:r,ref:o}of[...e].sort(Mre)){let a=o.available_range?.duration?.value??0,s=o.available_range?.duration?.rate||o.source_fps||0;if(!s||a<s*5||!o.source_resolution_w){n.push({path:r,reason:"too short or no picture"});continue}let c=r.slice(0,r.lastIndexOf("/")),l=i.get(c)??0;i.set(c,l+1);let u=SP(o);t.push({path:r,dir:c,idx:l,frames:a,rate:s,w:o.source_resolution_w,h:o.source_resolution_h??0,sound:u})}return{clips:t,skipped:n}}function Lre(e){let t=e>>>0,n=()=>{t=t+1831565813>>>0;let i=t;return i=Math.imul(i^i>>>15,i|1),i^=i+Math.imul(i^i>>>7,i|61),((i^i>>>14)>>>0)/4294967296};return{next:n,int:(i,r)=>i+Math.floor(n()*(r-i+1)),pick:i=>i[Math.floor(n()*i.length)],range:(i,r)=>i+n()*(r-i)}}function MI(e){let t=typeof e=="object"&&e!==null?e:Fu[e??"hard"];if(!t)throw new Error(`unknown mix '${e}' (presets: ${Object.keys(Fu).join(", ")})`);return t}function Ug(e){let t=MI(e),n=Rm.filter(i=>(t[i]??0)>0);if(!n.length)throw new Error("the mix weights no class");return n}function Xre(e,t){let n=Lre(e.seed),i=e.fps_num??24e3,r=e.fps_den??1001,o=e.width??1920,a=e.height??1080,s=i/r,c=MI(e.mix),l=Ug(e.mix),u=l.reduce((k,S)=>k+c[S],0),f=()=>{let k=n.next()*u;for(let S of l)if((k-=c[S])<0)return S;return l[l.length-1]};if(!t.length)throw new Error("no usable clips");let d=t.filter(k=>Math.abs(k.rate-s)>.01),m=[],p=e.shots??24,b=0,h=null,v=0,g=(k,S,M)=>Math.max(1,Math.round(S*(k.rate/s)*(M/100))),y=k=>Math.ceil(k.rate*Math.min(12,Math.max(2,.15*k.frames/k.rate))),w=(k,S,M)=>(e.avoid??[]).some(L=>L.path===k&&S<L.to&&S+M>L.from),x=(k,S)=>{let M=y(k),L=k.frames-Math.ceil(k.rate)-S;if(L<=M)return-1;for(let P=0;P<24;P++){let X=n.int(M,L);if(!w(k.path,X,S))return X}return-1},T=(k,S,M)=>{let L=0;for(let P=0;P<S;P++)L+=yp(M,P+.5)/100;return Math.max(1,Math.ceil(L*(k.rate/s))+1)},z=[];for(let k=0;k<p;k++){let S=f(),M=[S];S==="gap"&&(b+=n.int(6,48));let L=S==="short"||S!=="plain"&&S!=="ramp"&&!X9.has(S)&&n.next()<.2;L&&S!=="short"&&M.push("short");let P=S==="ramp"?n.int(60,144):X9.has(S)?n.int(48,120):L?n.int(4,23):S==="plain"?n.int(24,120):24+Math.floor(n.next()**2*96),X,R=n.pick(t),I=100,q=-1,Y={};if(S==="jump"&&h){R=h.clip;let ne=h.srcOut+n.int(6,120);ne+g(R,P,100)<R.frames-R.rate&&!w(R.path,ne,g(R,P,100))&&(q=ne)}else if(S==="lookalike"&&h){let ne=t.filter(le=>le.dir===h.clip.dir&&le!==h.clip).sort((le,Se)=>Math.abs(le.idx-h.clip.idx)-Math.abs(Se.idx-h.clip.idx));ne.length&&(R=ne[Math.min(ne.length-1,n.int(0,2))])}else if(S==="offrate"&&d.length)R=n.pick(d),I=n.next()<.6?Math.round(s/R.rate*1e4)/100:100;else if(S==="retime")I=n.pick([25,50,150,200]);else if(S==="ramp"){let ne=Math.round(P*n.range(.2,.4)),le=Math.round(P*n.range(.6,.8));X=n.pick([[[ne,100],[le,40]],[[ne,40],[le,100]],[[ne,100],[le,200]],[[ne,200],[le,100]],[[0,100],[ne,100],[Math.round((ne+le)/2),30],[le,100]]])}S==="jump"&&q<0&&(M[0]="plain"),S==="lookalike"&&(!h||R.dir!==h.clip.dir)&&(M[0]="plain"),S==="offrate"&&I===100&&Math.abs(R.rate-s)<.01&&(M[0]="plain");let D=X?T(R,P,X):g(R,P,I);if(q<0&&(q=x(R,D)),q<0){if(++v>p*50)throw new Error("the clips are too short for this mix");k--;continue}let j=ne=>(ne/100-1)/2*.8;if(S==="punch_in"){let ne=Math.round(n.range(110,200));Object.assign(Y,{scale:ne,position_x:Math.round(n.range(-1,1)*j(ne)*o),position_y:Math.round(n.range(-1,1)*j(ne)*a)})}else if(S==="turned")if(n.next()<.35)Object.assign(Y,n.next()<.7?{flip_h:!0}:{flip_v:!0});else{let ne=Math.round(n.range(1,6)*10)/10*(n.next()<.5?-1:1);Object.assign(Y,{rotation:ne,scale:Math.round(100+Math.abs(ne)*4)})}else if(S==="animated")if(n.next()<.5)Object.assign(Y,{scale:100,scale_end:Math.round(n.range(115,150))});else{let ne=Math.round(n.range(125,150)),le=j(ne)*o;Object.assign(Y,{scale:ne,position_x:Math.round(-le),position_x_end:Math.round(le)})}let C=e.audio&&R.sound&&I===100&&!X&&Math.abs(R.rate-s)<.01,H;if(S==="frankenbite")if(!C)M[0]="plain";else{let ne=t.filter(Le=>Le.dir===R.dir&&Le!==R&&Le.sound&&Math.abs(Le.rate-s)<.01),le=ne.length&&n.next()<.6?n.pick(ne):R,Se=x(le,D);Se>=0&&(le!==R||Math.abs(Se-q)>48)?H={path:le.path,source_in:Se}:M[0]="plain"}if(m.push({path:R.path,source_in:q,duration:P,at:b,track:1,...I!==100?{speed:I}:{},...X?{ramp:X}:{},...C?{audio:!0}:{},...H?{audio_from:H}:{},...Y,classes:M,record_in:b,record_out:b+P}),X9.has(S)){let ne=b+Math.floor(P*n.range(0,.2)),le=b+P-Math.floor(P*n.range(0,.15)),Se=n.int(0,SI.length-1),Le=S==="lower_third"?`${SI[Se]}
175
+ ${kI[n.int(0,kI.length-1)]}`:S==="locator"?TI[n.int(0,TI.length-1)]:zI[n.int(0,zI.length-1)];z.push({kind:S,text:Le,at:ne,duration:Math.max(12,le-ne),track:3})}if(S==="pip"&&P>=12){let ne=n.pick(t),le=Math.max(8,Math.floor(P*n.range(.5,1))),Se=x(ne,g(ne,le,100));if(Se>=0){let Le=Math.round(n.range(25,45)),ut=(1-Le/100)/2*.85,we=b+Math.floor((P-le)*n.next());m.push({path:ne.path,source_in:Se,duration:le,at:we,track:2,scale:Le,position_x:Math.round((n.next()<.5?-1:1)*ut*o),position_y:Math.round((n.next()<.5?-1:1)*ut*a),classes:["pip"],record_in:we,record_out:we+le})}}h={clip:R,srcOut:q+D},b+=P}return{shots:m,titles:z}}function Nm(e,t,n){let i=m0(t);if(!i)throw new Error(`unknown operation '${t}'; known: ${Object.keys(Nd).join(", ")}`);return i(e,n)}function N9(e,t){let n={projects:[],timelines:[],media_references:[]},i="author-tl";Nm(n,"new_timeline",{timeline_id:i,name:e.name,fps_num:e.fps_num,fps_den:e.fps_den,resolution_w:e.width,resolution_h:e.height,start_frame:e.start_frame,is_drop_frame:e.drop_frame});let r=n.timelines.find(l=>l.id===i),o=e.fps_num/e.fps_den,a=()=>r.tracks.filter(l=>l.kind==="Video"),s=new Map,c=[];for(let[l,u]of e.shots.entries()){let f=Math.max(1,u.track??1);for(;a().length<f;)Nm(n,"add_track",{timeline_id:i,kind:"Video"});let d=a()[f-1],m=s.get(u.path);m||s.set(u.path,m=t(u.path));let p=m.available_range,b=p?.duration?.rate||m.source_fps||o,h=p?.duration?.value??1/0,v=u.speed??100,g=u.ramp?mf(u.ramp,u.duration,u.source_in,o,b,"spd"):null,y=g?Math.max(1,Math.ceil(g.sourceFrames)+1):Math.max(1,Math.round(u.duration*(b/o)*(v/100)));if(u.source_in<0||u.source_in+y>h)throw new Error(`shot ${l+1} (${m.id}): source ${u.source_in}+${y} is outside the clip (0\u2013${h-1})`);let w=Nm(n,"add_clip",{timeline_id:i,media_reference_id:m.id,media_reference:m,source_start:(p?.start?.value??0)+u.source_in,source_duration:u.duration,at_frame:u.at,track_id:d.id,without_audio:!u.audio}),x=w.meta?.item_id,T=d.items.find(P=>P.id===x);if(!T)throw new Error(`shot ${l+1}: ${w.summary}`);T.source_range={start:T.source_range.start,duration:{value:y,rate:b}};let z=w.meta?.audio_item_id;if(z&&u.audio_from){let P=r.tracks.flatMap(R=>R.items).find(R=>R.id===z),X=s.get(u.audio_from.path);if(X||s.set(u.audio_from.path,X=t(u.audio_from.path)),P){n.media_references.some(I=>I.id===X.id)||n.media_references.push(X),P.media_reference_id=X.id,P.name=X.id;let R=X.available_range?.duration?.rate||X.source_fps||o;P.source_range={start:{value:(X.available_range?.start?.value??0)+u.audio_from.source_in,rate:R},duration:{value:u.duration*(R/o),rate:R}}}}g?(T.speed_ramped=!0,T.speed=Math.round(100*g.sourceFrames/u.duration*(o/b)*100)/100):v!==100&&(T.speed=v);let k=Bc(e.width,e.height,m.source_resolution_w,m.source_resolution_h);(u.scale!=null||u.position_x!=null||u.position_y!=null||u.rotation!=null)&&Nm(n,"transform",{timeline_id:i,item_id:T.id,...u.scale!=null?{scale:u.scale}:{},...u.position_x!=null?{position_x:u.position_x/k.w}:{},...u.position_y!=null?{position_y:u.position_y/k.h}:{},...u.rotation!=null?{rotation:u.rotation}:{}});let S=[["scale",u.scale??100,u.scale_end,P=>P],["position.x",u.position_x??0,u.position_x_end,P=>P/k.w],["position.y",u.position_y??0,u.position_y_end,P=>P/k.h],["rotation",u.rotation??0,u.rotation_end,P=>P]],M=[];for(let[P,X,R,I]of S)if(R!=null)for(let[q,Y]of[[0,X],[y-1,R]])M.push({id:`${T.id}-kf-${M.length}`,parameter_path:P,time:{value:T.source_range.start.value+q,rate:b},value:I(Y),interp:"linear",order_index:M.length,raw_extraction:{}});if(g)for(let P of g.keyframes)M.push({...P,id:`${T.id}-${P.id}`,order_index:M.length});M.length&&(T.keyframes=M);let L=T;u.flip_h&&(L.flip_horizontal=!0),u.flip_v&&(L.flip_vertical=!0),c.push(`${l+1}. V${f} @${T.timeline_range.start.value} ${u.duration}f ${m.id} src+${u.source_in}${v!==100?` ${v}%`:""}${u.scale!=null?` scale ${u.scale}`:""}${u.rotation?` rot ${u.rotation}`:""}${u.flip_h?" flipH":""}${u.flip_v?" flipV":""}${u.audio?u.audio_from?` sound from ${u.audio_from.path.split("/").pop()}+${u.audio_from.source_in}`:" +sound":""}${g?` ramp ${u.ramp.map(([P,X])=>`${X}%@${P}`).join("\u2192")}`:""}${M.length&&!g?` animated (${M.length/2} params)`:""}`)}for(let[l,u]of(e.titles??[]).entries()){for(;a().length<u.track;)Nm(n,"add_track",{timeline_id:i,kind:"Video"});let f=a()[u.track-1],d=e.height/1080,m={font:"Arial",raster_w:e.width,raster_h:e.height,color:"#FFFFFF",opacity:1,shadow_color:"#000000",shadow_opacity:.6,shadow_dx:2*d,shadow_dy:2*d,shadow_blur:4*d,source_tool:"Resolve Text+"},p=u.kind==="lower_third"?{font_style:"Bold",size:52*d,align:"left",anchor_x:.08,anchor_y:.8,anchor_ref:"baseline"}:u.kind==="locator"?{font_style:"Regular",size:40*d,align:"left",anchor_x:.06,anchor_y:.1,anchor_ref:"baseline",tracking:.08}:{font_style:"Bold",size:110*d,align:"center",anchor_x:.5,anchor_y:.5,anchor_ref:"center"};f.items.push({id:`${i}-title-${l}`,kind:"clip",item_index:f.items.length,name:u.text.split(`
176
+ `)[0],enabled:!0,timeline_range:{start:{value:u.at,rate:o},duration:{value:u.duration,rate:o}},title:{text:u.text,...m,...p}}),c.push(`T${l+1}. V${u.track} @${u.at} ${u.duration}f ${u.kind} "${u.text.replace(`
177
+ `," / ")}"`)}return{session:n,summary:c}}function OI(e,t){Ug(e.mix);let{clips:n,skipped:i}=Ore(t);if(!n.length)throw new Error(`no usable clips (${i.length} skipped)`);let{shots:r,titles:o}=Xre(e,n),a=e.fps_num??24e3,s=e.fps_den??1001,c=e.width??1920,l=e.height??1080,u=new Map(t.map(p=>[p.path,p.ref])),f=e.name??`generated ${e.seed}`,{session:d,summary:m}=N9({name:f,fps_num:a,fps_den:s,width:c,height:l,shots:r.map(({classes:p,record_in:b,record_out:h,...v})=>v),titles:o},p=>u.get(p));return{session:d,summary:m,shots:r,titles:o,pool:{used:n.length,skipped:i}}}async function LI(e){if(e.start_tc){let i=Kn(e.start_tc,e.fps_num/e.fps_den);if(i==null)throw new Error(`start_tc: cannot parse '${e.start_tc}' (HH:MM:SS:FF, ';' before FF for drop frame)`);e={...e,start_frame:i,drop_frame:e.drop_frame??e.start_tc.includes(";")}}let t=new Map;for(let i of e.shots)if(!t.has(i.path))try{t.set(i.path,await Rn(i.path))}catch(r){t.set(i.path,r instanceof Error?r:new Error(String(r)))}let n=new Set;for(let i of t.values()){if(i instanceof Error)continue;let r=i.id,o=2;for(;n.has(r);)r=`${i.id} (${o++})`;n.add(i.id=r)}return N9(e,i=>{let r=t.get(i);if(r instanceof Error)throw r;return r})}var Nre=2.5;function Rre(e){let n=jn(e,96),i=n.length/96,r=0,o=0;for(let a=1;a<i-1;a++)for(let s=1;s<95;s++){let c=a*96+s;r+=Math.abs(n[c+1]-n[c-1])+Math.abs(n[c+96]-n[c-96]),o++}return o?r/o:0}var XI=new Map;async function Fre(e){let t=[];return await Promise.all(e.map(async n=>{let i=XI.get(n.path);i||XI.set(n.path,i=na(n.path));let r=Math.max(1,Math.round(n.duration*((n.speed??100)/100))),o=[n.source_in,n.source_in+(r>>1),n.source_in+r-1],a=0;for(let s of o){let c=await i.read(s).catch(()=>null);c&&Rre(c)<Nre&&a++}a>=2&&t.push({path:n.path,from:n.source_in-24,to:n.source_in+r+24})})),t}var Vre=/\.(mov|mxf|mp4|m4v|mts|braw|r3d|ari)$/i,jre=/prox(y|ies)|^cache$/i;async function NI(e,t,n=!0){if((await Deno.stat(e)).isFile){Vre.test(e)&&!e.split("/").pop().startsWith("._")&&t.push(e);return}if(!(!n&&jre.test(e.split("/").pop())))for await(let r of Deno.readDir(e))r.name.startsWith(".")||await NI(`${e}/${r.name}`,t,!1)}async function RI(e){Ug(e.mix);let t=[];for(let c of e.media)await NI(c,t);if(t.sort(),!t.length)throw new Error("no video files under the media given");let n=[],i=new Map;for(let c of t)try{n.push({path:c,ref:await Rn(c)})}catch(l){i.set(c,l instanceof Error?l.message:String(l))}let r=[...e.avoid??[]],o;for(let c=0;c<(e.look===!1?1:5);c++){try{o=OI({...e,avoid:r},n)}catch(u){throw u instanceof Error&&u.message.startsWith("no usable clips")?new Error(`no usable clips (${t.length} skipped)`):u}if(e.look===!1)break;let l=await Fre(o.shots);if(!l.length)break;r.push(...l)}if(!o)throw new Error("no cut");let a=new Map([...i,...o.pool.skipped.map(c=>[c.path,c.reason])]),s=t.filter(c=>a.has(c)).map(c=>`${c} (${a.get(c)})`);return{session:o.session,summary:o.summary,shots:o.shots,titles:o.titles,pool:{used:o.pool.used,skipped:s}}}var Zre="1",Vu=(e,t)=>`reconform-${e}-${t}`,FI=e=>e.replace(/\.[^.]+$/,"");function VI(e,t,n,i){let r=FI(i.aName),o=FI(i.bName),a=t.fps??n.fps??24,s=t.fps??a,c=Kv(a),l=[],u=0,f=(k,S,M,L,P)=>{l.push({id:Vu("marker",u++),name:k,color:S,kind:null,note:M,time:{value:L,rate:a},duration:{value:Math.max(1,P),rate:a},item_id:null,raw_extraction:{},source_element_id:null,metadata:{}})},d=Vu("media","a"),m=[{id:d,kind:"external",content_kind:"video",target_url:i.aName,display_name:r,source_fps:s,source_timecode:Qv(t.startFrame,s,t.dropFrame),available_range:{start:{value:0,rate:s},duration:{value:t.frames,rate:s}},source_resolution_w:t.w||null,source_resolution_h:t.h||null,reel_name:null,raw_extraction:{},metadata:{codec:t.codec}}],p=[],b=0,h=0,v=0,g=0,y=0;for(let k of e){if(k.kind==="hole"){v+=k.count,f("NEW MATERIAL","Green",`${k.count} frame(s) not in ${r} \u2014 cut the new material in here.`,k.recordIn,k.count);continue}if(k.aIn==null)continue;let S=Vu("item",y);p.push({id:S,kind:"clip",item_index:y++,name:r,enabled:!0,timeline_range:{start:{value:k.recordIn,rate:a},duration:{value:k.count,rate:a}},source_range:{start:{value:k.aIn,rate:s},duration:{value:k.count,rate:s}},media_reference_id:d,raw_extraction:{},metadata:{}}),b++,h+=k.count,k.unreproducible&&(g++,f("CHECK BY EYE","Red",`${k.unreproducible.note}. This clip is the closest straight source frames can get \u2014 a hold, reverse or retime here must be rebuilt by hand from ${r} (${k.aInTc??"?"}\u2013${k.aOutTc??"?"}).`,k.recordIn,k.count))}t.fps&&n.fps&&Math.abs(t.fps-n.fps)>.01&&f("RATE MISMATCH","Yellow",`Old cut is ${t.fps.toFixed(3)} fps, new cut ${n.fps.toFixed(3)} fps. This timeline is emitted at ${a.toFixed(3)} fps (the matcher's timebase) \u2014 frame counts near edits need checking by eye.`,0,1);for(let k of i.warnings??[])f("COMPARE WARNING","Yellow",k,0,1);let w={id:Vu("track",1),kind:"Video",track_index:1,name:"V1",enabled:!0,items:p,source_element_id:null,raw_extraction:{},metadata:{}},x=e.length?e[e.length-1].recordOut:0,T={id:Vu("timeline",1),name:i.name??`${o} \u2014 reconform from ${r}`,kind:"primary",timeline_index:0,fps_num:c.num,fps_den:c.den,resolution_w:n.w||null,resolution_h:n.h||null,start_frame:n.startFrame,is_drop_frame:n.dropFrame,duration_frames:x,tracks:[w],markers:l,source_element_id:null,raw_extraction:{},metadata:{}};return{session:{projects:[{id:Vu("project",1),user_id:"",created_at:"",source_format:"ref-compare",source_filename:i.bName,source_file_sha256:null,source_file_bytes:null,parser_name:"reconform-session",parser_version:Zre,status:"ready",error_message:null,metadata:{}}],timelines:[T],media_references:m,source_format:"ref-compare",source_filename:i.bName},stats:{placed:b,aSourceFrames:h,holeFrames:v,flagged:g}}}async function jI(e){let t=await sr.open(e.a),n=await sr.open(e.b),[i,r]=[!(await gn(t)).spec,!(await gn(n)).spec],o=(i||r)&&await Xu(t)&&await Xu(n)?"os-decoder":void 0,a=await Om(t,{matte:"clip",motion:!0,lane:o,onProgress:(f,d)=>e.onProgress?.(f,d,`fingerprinting ${ae(e.a)}`),signal:e.signal}),s=await Om(n,{matte:"clip",motion:!0,lane:o,onProgress:(f,d)=>e.onProgress?.(f,d,`fingerprinting ${ae(e.b)}`),signal:e.signal}),c=pp(a,s),l=cZ(lZ(c.report,c.a,c.b,e.min_run??Y7),c.aPdq,c.bPdq),u=VI(l,c.a,c.b,{aName:ae(e.a),bName:ae(e.b),name:`${ae(e.b)} rebuilt from ${ae(e.a)}`,warnings:c.warnings});for(let f of u.session.media_references??[])f.target_url=e.a,f.local_path=e.a;return{result:c,events:l,summary:uZ(l),unreproducible:l.filter(f=>f.unreproducible),edl:fZ(l,c.b,{title:`${ae(e.b)} FROM ${ae(e.a)}`.toUpperCase().slice(0,70),aReel:ae(e.a).replace(/\.[^.]+$/,"").slice(0,8)}),csv:dZ(l),session:u.session,stats:u.stats,lanes:{a:a.lane,b:s.lane}}}function ZI(e,t){let{a:n,b:i}=e.result,r=e.summary.hole===0&&e.events.length===1&&!e.unreproducible.length;return[`A (old) ${ae(t.a)}: ${n.label} ${n.w}x${n.h} @ ${n.fps??"?"} fps, ${n.frames} frames (${e.lanes.a})`,`B (new) ${ae(t.b)}: ${i.label} ${i.w}x${i.h} @ ${i.fps??"?"} fps, ${i.frames} frames (${e.lanes.b})`,r?"B is A, picture for picture (one event covers the whole cut).":`B rebuilt from A in ${e.events.length} event(s): ${e.events.filter(a=>a.kind!=="hole").length} from A (${e.summary.aSource} frames), ${e.events.filter(a=>a.kind==="hole").length} hole(s) of new material (${e.summary.hole} frames)`,...e.result.warnings.map(a=>`warning: ${a}`),...e.unreproducible.map(a=>`CHECK BY EYE event ${a.index} ${a.recordInTc}\u2013${a.recordOutTc}: ${a.unreproducible.note}`),"",Lk(e.result.report)].join(`
178
+ `)}import{basename as Fc}from"node:path";var Rc=32,Zu=18;function DI(e,t,n,i=1,r=0){let o=new Float64Array(Rc*Zu),a=new Uint32Array(Rc*Zu);for(let u=0;u<n;u++){let f=Math.min(Zu-1,Math.floor(u*Zu/n))*Rc;for(let d=0;d<t;d++){let m=f+Math.min(Rc-1,Math.floor(d*Rc/t));o[m]+=e[(u*t+d)*i+r],a[m]++}}let s=new Float32Array(Rc*Zu);for(let u=0;u<s.length;u++)s[u]=a[u]?o[u]/a[u]:0;let c=Iu(Float32Array.from(s)),l=Math.max(Iu(s.map(u=>Math.abs(u-c))),2);for(let u=0;u<s.length;u++)s[u]=(s[u]-c)/l;return s}function Iu(e){return e.sort(),e.length?e[e.length>>1]:0}var ju=new Float32Array(Rc*Zu);function R9(e,t){return Math.max(II(e,t),II(t,e))}function II(e,t){let n=e.length;for(let a=0;a<n;a++)ju[a]=e[a]-t[a];let i=null,r=1,o=Iu(Float32Array.from(ju));for(let a=0;a<5;a++){if(i){let l=0,u=0,f=0,d=0,m=0;for(let b=0;b<n;b++)i(b)&&(l+=e[b],u+=t[b],f+=t[b]*t[b],d+=e[b]*t[b],m++);let p=f-u*u/m;r=p>1e-6?Math.max(0,(d-l*u/m)/p):0,o=(l-r*u)/m}for(let l=0;l<n;l++)ju[l]=Math.abs(e[l]-r*t[l]-o);let s=Iu(Float32Array.from(ju)),c=Float32Array.from(ju);i=l=>c[l]<=s}return Iu(ju)}function WI(e){let t=e.slice(0,-1).map((i,r)=>i&&e[r+1]?R9(i,e[r+1]):0),n=Iu(Float32Array.from(t));return t.flatMap((i,r)=>i>Math.max(Ire,4*n)?[r]:[])}var Ire=.6,F9=.35,Wre=e=>e*1.25+.005;async function Ag(e){let t=await Rn(e),n=t.streams?.find(o=>o.kind==="video");if(!n)throw new Error(`${ae(e)} has no video`);let i=t.source_fps??n.rate??24,r=t.source_timecode??null;return{path:e,name:ae(e),fps:i,start:r?Kn(r,i)??0:0,df:!!r?.includes(";"),frames:t.available_range?.duration?.value??0,codec:(n.codec??"").toLowerCase()}}var Wr=(e,t)=>tn(e.start+t,e.fps,e.df);function Wu(e,t){let n=t==null?Math.floor(e.frames/2):Jr(t,e.fps,e.start?Wr(e,0):null);if(e.frames&&(n<0||n>=e.frames))throw new Error(`frame ${n} is outside ${e.name} (0\u2013${e.frames-1}, ${Wr(e,0)}\u2013${Wr(e,e.frames-1)})`);return n}async function V9(e){if(e.out_path&&!/\.png$/i.test(e.out_path))throw new ze("invalid_args",`out_path must be a .png file (${ae(e.out_path)})`);let t=await Ag(e.path),n=Wu(t,e.frame),i=e.b?await Ag(e.b):null,r=i?e.b_frame!=null?Wu(i,e.b_frame):Wu(i,Wr(t,n)):0,o=Math.max(0,Math.floor(e.around??0)),a=Math.max(1,Math.floor(e.step??1)),s=Array.from({length:2*Math.floor(o/a)+1},(z,k)=>(k-Math.floor(o/a))*a),c=s.length>1||!!i,l=[{clip:t,frames:s.map(z=>n+z)}];i&&l.push({clip:i,frames:s.map(z=>r+z)});let u=[];for(let z of l){let k=[];for(let S of z.frames){if(S<0||z.clip.frames&&S>=z.clip.frames){k.push(null);continue}let M=await tl(z.clip.path,S,z.clip.codec),L=e.width??(c?Math.min(M.width,480):M.width),P=L===M.width?{rgba:M.rgba,w:M.width,h:M.height}:Dre(M.rgba,M.width,M.height,L);k.push({...P,label:`${i?z.clip===t?"A ":"B ":""}${Wr(z.clip,S)} f${S}`,feat:DI(M.rgba,M.width,M.height,4,1)})}u.push(k)}let f=u.flat().filter(Boolean);if(!f.length)throw new Error("no frame in range");let d=Math.max(...f.map(z=>z.w)),m=Math.max(...f.map(z=>z.h)),p=Math.max(1,Math.round(d/240)),b=c?7*p+6:0,h=c?4:0,v=s.length*d+(s.length-1)*h,g=l.length*(m+b)+(l.length-1)*h,y=new Uint8Array(v*g*4);for(let z=3;z<y.length;z+=4)y[z]=255;u.forEach((z,k)=>z.forEach((S,M)=>{if(!S)return;let L=M*(d+h),P=k*(m+b+h);for(let X=0;X<S.h;X++)y.set(S.rgba.subarray(X*S.w*4,(X+1)*S.w*4),((P+X)*v+L)*4);c&&Hre(y,v,L+3,P+m+3,S.label,p)}));let w=e.out_path??_(await ii("conform-frame-"),`${t.name.replace(/\.[^.]+$/,"")}_${Wr(t,n).replace(/[:;]/g,"")}${i?"_AB":o?`_pm${o}`:""}.png`);await or(w,await Ure(y,v,g));let x=l.flatMap(z=>z.frames.filter(k=>k>=0&&(!z.clip.frames||k<z.clip.frames)).map(k=>({file:z.clip.name,frame:k,tc:Wr(z.clip,k)}))),T=i?s.flatMap((z,k)=>{let S=u[0][k],M=u[1][k];if(!S||!M)return[];let L=+R9(S.feat,M.feat).toFixed(3);return[{a_frame:n+z,b_frame:r+z,tc:Wr(t,n+z),distance:L,same:L<=F9}]}):void 0;return{out_path:w,w:v,h:g,frames:x,...T?{diff:T}:{}}}function j9(e){let t=`wrote ${e.out_path} (${e.w}x${e.h} PNG, ${e.frames.length} frame${e.frames.length>1?"s":""})`;if(!e.diff)return[t,...e.frames.map(i=>`${i.file} f${i.frame} ${i.tc}`)].join(`
179
+ `);let n=e.diff[e.diff.length>>1];return[`${n?.same?"A and B show the same picture":"A and B DIFFER"} at A ${n?.tc??"?"} (distance ${n?.distance??"?"}; 0 = identical, \u2264${F9} = same picture through a grade/burn-in/rescale; a neighbouring frame also scores low, so prove the frame offset with media_align)`,t,...e.diff.map(i=>`A f${i.a_frame} vs B f${i.b_frame} (A ${i.tc}): ${i.distance}${i.same?"":" DIFFERENT"}`)].join(`
180
+ `)}function Dre(e,t,n,i){i=Math.max(1,Math.round(i));let r=Math.max(1,Math.round(n*i/t)),o=new Uint8Array(i*r*4);for(let a=0;a<r;a++){let s=Math.floor(a*n/r),c=Math.max(s+1,Math.floor((a+1)*n/r));for(let l=0;l<i;l++){let u=Math.floor(l*t/i),f=Math.max(u+1,Math.floor((l+1)*t/i)),d=0,m=0,p=0,b=0;for(let v=s;v<c;v++)for(let g=u;g<f;g++){let y=(v*t+g)*4;d+=e[y],m+=e[y+1],p+=e[y+2],b++}let h=(a*i+l)*4;o[h]=d/b,o[h+1]=m/b,o[h+2]=p/b,o[h+3]=255}}return{rgba:o,w:i,h:r}}var qre={0:[14,17,19,21,25,17,14],1:[4,12,4,4,4,4,14],2:[14,17,1,2,4,8,31],3:[31,2,4,2,1,17,14],4:[2,6,10,18,31,2,2],5:[31,16,30,1,1,17,14],6:[6,8,16,30,17,17,14],7:[31,1,2,4,8,8,8],8:[14,17,17,14,17,17,14],9:[14,17,17,15,1,2,12],":":[0,12,12,0,12,12,0],";":[0,12,12,0,12,4,8],"+":[0,4,4,31,4,4,0],"-":[0,0,0,31,0,0,0],A:[14,17,17,31,17,17,17],B:[30,17,17,30,17,17,30],f:[6,9,8,28,8,8,8]};function Hre(e,t,n,i,r,o){for(let a of r){let s=qre[a];if(s){for(let c=0;c<7;c++)for(let l=0;l<5;l++)if(s[c]>>4-l&1)for(let u=0;u<o;u++)for(let f=0;f<o;f++){let d=((i+c*o+u)*t+n+l*o+f)*4;e[d]=e[d+1]=e[d+2]=255}}n+=6*o}}var Ere=Array.from({length:256},(e,t)=>{let n=t;for(let i=0;i<8;i++)n=n&1?3988292384^n>>>1:n>>>1;return n>>>0});function Cre(e){let t=4294967295;for(let n of e)t=Ere[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}async function Ure(e,t,n){let i=new Uint8Array(n*(t*3+1));for(let f=0,d=0;f<n;f++){i[d++]=0;for(let m=0;m<t;m++){let p=(f*t+m)*4;i[d++]=e[p],i[d++]=e[p+1],i[d++]=e[p+2]}}let r=new Uint8Array(await new Response(new Blob([i]).stream().pipeThrough(new CompressionStream("deflate"))).arrayBuffer()),o=(f,d)=>{let m=new Uint8Array(12+d.length),p=new DataView(m.buffer);return p.setUint32(0,d.length),m.set(new TextEncoder().encode(f),4),m.set(d,8),p.setUint32(8+d.length,Cre(m.subarray(4,8+d.length))),m},a=new Uint8Array(13),s=new DataView(a.buffer);s.setUint32(0,t),s.setUint32(4,n),a[8]=8,a[9]=2;let c=[new Uint8Array([137,80,78,71,13,10,26,10]),o("IHDR",a),o("IDAT",r),o("IEND",new Uint8Array(0))],l=new Uint8Array(c.reduce((f,d)=>f+d.length,0)),u=0;for(let f of c)l.set(f,u),u+=f.length;return l}async function Gg(e){let t=await Ag(e.a),n=await Ag(e.b),i=await sr.open(e.a),r=await sr.open(e.b),[o,a]=[!(await gn(i)).spec,!(await gn(r)).spec],s=(o||a)&&await Xu(i)&&await Xu(r)?"os-decoder":void 0,c=await Ho(i,s,{sparse:!0}),l=await Ho(r,s,{sparse:!0}),u=t.frames||c.frames,f=n.frames||l.frames;t.frames=u,n.frames=f;let d=e.a_in!=null?Wu(t,e.a_in):0,m=e.a_out!=null?Wu(t,e.a_out):u-1;if(m<d)throw new Error(`a_out (${m}) is before a_in (${d})`);let p=m-d+1,b=Math.max(1,Math.floor(e.search??12)),h=async(D,j)=>{if(e.signal?.aborted)throw new Error("cancelled");let C=await D.luma(j);return C?DI(C.y,C.w,C.h):null},v=[];for(let D=d;D<=m;D++)v.push(await h(c,D));let g=new Map,y=async D=>D<0||D>=f?null:(g.has(D)||g.set(D,await h(l,D)),g.get(D)),w=async(D,j)=>{let C=0,H=0;for(let ne of j){let le=v[ne],Se=await y(D+ne);le&&Se&&(C+=R9(le,Se),H++)}return H>=Math.max(1,j.length*.8)?C/H:1/0},x=e.b_in!=null?Wu(n,e.b_in):null,T=x??0;if(x==null){let D=Array.from(new Set(Array.from({length:Math.min(16,p)},(C,H)=>Math.round(H*(p-1)/Math.max(1,Math.min(16,p)-1))))),j=1/0;for(let C=-p+1;C<f;C++){let H=await w(C,D);H<j&&(j=H,T=C)}}let z=v.map((D,j)=>j),k=async D=>{let j=[];for(let Je=-b;Je<=b;Je++)j.push({k:Je,c:await w(T+Je,D)});let C=[...j].sort((Je,be)=>Je.c-be.c),H=C[0],ne=C[1]??{c:1/0},le=H.k+T-(x??T),Se=j.filter(Je=>Je.c<=Wre(H.c)).map(Je=>Je.k+T-(x??T)),Le=Number.isFinite(ne.c)?+Math.min(1,(ne.c-H.c)/Math.max(ne.c,1e-6)).toFixed(2):0,ut=d+D[0],we=d+D[D.length-1],De={a_in:ut,a_out:we,a_tc:Wr(t,ut),cost:+H.c.toFixed(3),confidence:Le};return!Number.isFinite(H.c)||H.c>F9?{...De,verdict:"no_match",offset:null,confidence:0}:Se.length>1?{...De,verdict:"unverifiable",offset:null,ambiguous:[Math.min(...Se),Math.max(...Se)]}:{...De,verdict:le===0?"exact":"offset",offset:le}},S=await k(z),M=WI(v),L=[-1,...M,p-1],P=[];for(let D=0;D+1<L.length;D++)P.push(await k(z.slice(L[D]+1,L[D+1]+1)));let X=(x??T)+(S.offset??0),R=[];for(let D=X-3;D<=X+p+2;D++)R.push(await y(D));let I=WI(R).map(D=>D-3),q=M.map(D=>({a_cut:d+D,tc:Wr(t,d+D+1),in_b:I.includes(D)})),Y=[];for(let D of I)M.includes(D)||(D>=0&&D<p-1?Y.push(`B has a shot change inside the range that A does not, at B ${Wr(n,X+D+1)} (A ${Wr(t,d+D+1)}): a flash frame / wrong shot`):D<0&&D>=-3?Y.push(`B cuts ${-D} frame(s) before the head (B ${Wr(n,X+D+1)}): a ${-D}-frame slip early shows the previous shot`):D>=p-1&&D<=p+1&&Y.push(`B cuts ${D-p+2} frame(s) after the tail (B ${Wr(n,X+D+1)}): a slip late shows the next shot`));return x!=null&&S.offset&&Y.unshift(`the client's in-point ${Wr(n,x)} is ${S.offset>0?"early":"late"} by ${Math.abs(S.offset)} frame(s): the measured in-point is ${Wr(n,X)}`),{a:t.name,b:n.name,a_range:[d,m],a_tc:[Wr(t,d),Wr(t,m)],proposed_b_in:x,b_in:X,b_tc:Wr(n,X),searched:x==null,overall:S,shots:P,anchors:q,flash:Y,lane:c.lane}}function qI(e){let t=e.overall,n=t.verdict==="exact"?`EXACT: ${e.a} ${e.a_tc[0]} = ${e.b} ${e.b_tc} (confidence ${t.confidence})`:t.verdict==="offset"?`OFFSET ${t.offset>0?"+":""}${t.offset} frame(s): ${e.a} ${e.a_tc[0]} = ${e.b} ${e.b_tc}${e.proposed_b_in!=null?" (not the client's in-point)":""} (confidence ${t.confidence})`:t.verdict==="unverifiable"?`UNVERIFIABLE: offsets ${t.ambiguous[0]}\u2026${t.ambiguous[1]} fit equally (static picture, no shot change to anchor on)`:`NO MATCH: ${e.a} ${e.a_tc[0]}\u2013${e.a_tc[1]} is not in ${e.b} within the searched frames (cost ${t.cost})`,i=r=>` shot A ${r.a_tc} (f${r.a_in}\u2013${r.a_out}): ${r.verdict}${r.offset?` ${r.offset>0?"+":""}${r.offset}`:""}${r.ambiguous?` (${r.ambiguous[0]}\u2026${r.ambiguous[1]})`:""}, confidence ${r.confidence}`;return[n,`A ${e.a} ${e.a_tc[0]}\u2013${e.a_tc[1]} (${e.a_range[1]-e.a_range[0]+1} frames) vs B ${e.b}${e.searched?" (searched all of B)":` from ${e.b_tc}`}; offset = measured \u2212 client in-point (+ = later in B)`,`anchors: ${e.anchors.length?`${e.anchors.filter(r=>r.in_b).length} of ${e.anchors.length} shot change(s) in A are in B at the same frame`:"no shot change inside the range: the offset rests on motion alone"}`,`shots (${e.shots.length}):`,...e.shots.map(i),...e.flash.length?["flash-frame risk:",...e.flash.map(r=>` ${r}`)]:["flash-frame risk: none found (no B shot change within 3 frames of the range ends)"]].join(`
181
+ `)}function HI(e,t){let n=e.timelines.filter(v=>!t.timeline||v.id===t.timeline||v.name===t.timeline),i=t.item_id?n.find(v=>v.tracks.some(g=>g.items.some(y=>y.id===t.item_id))):n.find(v=>v.kind==="primary")??n[0];if(!i)throw new Error(t.item_id?`no item ${t.item_id} in this session`:`no timeline ${t.timeline??""} in this session`);let r=i.fps_den?i.fps_num/i.fps_den:i.fps_num,o=i.start_frame??0,a=!!i.is_drop_frame,s=t.record!=null?Jr(t.record,r,tn(o,r,a)):null,c=i.tracks.filter(v=>v.kind==="Video"),l;if(t.item_id){for(let v of c)for(let g of v.items)g.id===t.item_id&&(l={it:g,tr:v});if(!l)throw new Error(`${t.item_id} is not a video clip`)}else{if(s==null)throw new Error("give item_id or record (a record TC or frame)");for(let v of[...c].sort((g,y)=>y.track_index-g.track_index)){if(v.enabled===!1)continue;let g=v.items.find(y=>y.kind==="clip"&&y.enabled!==!1&&y.timeline_range.start.value<=s&&s<y.timeline_range.start.value+y.timeline_range.duration.value);if(g){l={it:g,tr:v};break}}if(!l)throw new Error(`no enabled video clip at record ${tn(o+s,r,a)}`)}let{it:u,tr:f}=l,d=e.media_references.find(v=>v.id===u.media_reference_id),m=d?.local_path??d?.target_url?.replace(/^file:\/\//,"");if(!m||!u.source_range)throw new Error(`${u.name??u.id} has no linked media (relink it first)`);let p=u.timeline_range.start.value,b=s!=null?s-p:0;if(b<0||b>=u.timeline_range.duration.value)throw new Error(`record ${s} is outside ${u.name??u.id}`);let h=u.source_range.start.value+Math.floor(b*u.source_range.duration.value/Math.max(1,u.timeline_range.duration.value));return{path:m,frame:h,item:u.id,track:f.name??`V${f.track_index}`,record_tc:tn(o+p+b,r,a)}}function Are(e){let t=1681.974450955533,n=3.999843853973347,i=.7071752369554196,r=Math.tan(Math.PI*t/e),o=Math.pow(10,n/20),a=Math.pow(o,.4996667741545416),s=1+r/i+r*r,c={b0:(o+a*r/i+r*r)/s,b1:2*(r*r-o)/s,b2:(o-a*r/i+r*r)/s,a1:2*(r*r-1)/s,a2:(1-r/i+r*r)/s},l=38.13547087602444,u=.5003270373238773,f=Math.tan(Math.PI*l/e),d=1+f/u+f*f,m={b0:1,b1:-2,b2:1,a1:2*(f*f-1)/d,a2:(1-f/u+f*f)/d};return{shelf:c,highpass:m}}function Gre(e){switch(e){case 1:return[1];case 2:return[1,1];case 6:return[1,1,1,0,1.41,1.41];case 8:return[1,1,1,0,1.41,1.41,1.41,1.41];default:return new Array(e).fill(1)}}var Jre=-.691,Bre=-70,Yre=10,Kre=.4,Qre=.75;var Du=class{constructor(t,n){this.channels=t;this.sampleRate=n;this.blockFilled=0;this.historyAt=0;this.sinceLastBlock=0;this.totalSamples=0;this.blockPower=[];let i=Are(n);this.shelf=i.shelf,this.highpass=i.highpass,this.weights=Gre(t),this.state=Array.from({length:t},()=>({s1:[0,0,0,0],s2:[0,0,0,0]})),this.blockSize=Math.round(Kre*n),this.hop=Math.max(1,Math.round(this.blockSize*(1-Qre))),this.blockSums=new Array(t).fill(0),this.history=Array.from({length:t},()=>new Float32Array(this.blockSize))}step(t,n,i){let r=t.b0*i+t.b1*n[0]+t.b2*n[1]-t.a1*n[2]-t.a2*n[3];return n[1]=n[0],n[0]=i,n[3]=n[2],n[2]=r,r}push(t){let n=Math.floor(t.length/this.channels);for(let i=0;i<n;i++){for(let r=0;r<this.channels;r++){let o=this.state[r],a=this.step(this.highpass,o.s2,this.step(this.shelf,o.s1,t[i*this.channels+r])),s=a*a;this.blockSums[r]+=s-this.history[r][this.historyAt],this.history[r][this.historyAt]=s}if(this.historyAt=(this.historyAt+1)%this.blockSize,this.totalSamples++,this.blockFilled<this.blockSize&&this.blockFilled++,this.blockFilled>=this.blockSize&&(this.sinceLastBlock++,this.sinceLastBlock>=this.hop||this.blockPower.length===0)){this.sinceLastBlock=0;let r=0;for(let o=0;o<this.channels;o++){let a=this.weights[o]??1;a!==0&&(r+=a*(this.blockSums[o]/this.blockSize))}this.blockPower.push(r)}}}finish(){return _re(this.blockPower)}get samplesSeen(){return this.totalSamples}};function _re(e){let t=s=>s>0?Jre+10*Math.log10(s):-1/0,n=e.filter(s=>t(s)>Bre);if(n.length===0)return{integratedLufs:null,gatedBlocks:0,totalBlocks:e.length};let i=n.reduce((s,c)=>s+c,0)/n.length,r=t(i)-Yre,o=n.filter(s=>t(s)>r);if(o.length===0)return{integratedLufs:null,gatedBlocks:0,totalBlocks:e.length};let a=o.reduce((s,c)=>s+c,0)/o.length;return{integratedLufs:t(a),gatedBlocks:o.length,totalBlocks:e.length}}var $re=4,Jg=32;function eie(e=$re,t=Jg){let n=[],i=t/2;for(let r=0;r<e;r++){let o=new Float32Array(t),a=0;for(let s=0;s<t;s++){let c=s-i+1-r/e,l=c===0?1:Math.sin(Math.PI*c)/(Math.PI*c),u=.42-.5*Math.cos(2*Math.PI*s/(t-1))+.08*Math.cos(4*Math.PI*s/(t-1));o[s]=l*u,a+=o[s]}if(a!==0)for(let s=0;s<t;s++)o[s]/=a;n.push(o)}return n}var EI=1024;var qu=class{constructor(t){this.channelCount=t;this.base=0;this.next=0;this.peak=0;this.phases=eie(),this.half=Jg/2;let n=1;for(let i=1;i<this.phases.length;i++){let r=0;for(let o=0;o<Jg;o++)r+=Math.abs(this.phases[i][o]);r>n&&(n=r)}this.l1=n,this.buffers=Array.from({length:t},()=>new Float32Array(0))}push(t){let n=Math.floor(t.length/this.channelCount);if(n<=0)return;for(let r=0;r<this.channelCount;r++){let o=this.buffers[r],a=new Float32Array(o.length+n);a.set(o,0);for(let s=0;s<n;s++){let c=t[s*this.channelCount+r];a[o.length+s]=c;let l=c<0?-c:c;l>this.peak&&(this.peak=l)}this.buffers[r]=a}let i=this.base+this.buffers[0].length;this.evaluate(i-this.half,!1),this.trim()}finish(){let t=this.base+this.buffers[0].length;return this.evaluate(t,!0),this.peak>0?20*Math.log10(this.peak):-1/0}evaluate(t,n){if(!(t<=this.next)){for(let i=0;i<this.channelCount;i++){let r=this.buffers[i],o=this.base,a=this.base+r.length;for(let s=this.next;s<t;s+=EI){let c=Math.min(s+EI,t),l=Math.max(o,s-this.half),u=Math.min(a,c+this.half),f=0;for(let d=l;d<u;d++){let m=r[d-o]<0?-r[d-o]:r[d-o];m>f&&(f=m)}if(!(f*this.l1<=this.peak))for(let d=s;d<c;d++)for(let m=1;m<this.phases.length;m++){let p=this.phases[m],b=0;for(let v=0;v<Jg;v++){let g=d+v-this.half+1;g>=o&&g<a&&(b+=r[g-o]*p[v])}let h=b<0?-b:b;h>this.peak&&(this.peak=h)}}}this.next=t,n&&(this.next=Math.max(this.next,this.base+this.buffers[0].length))}}trim(){let t=Math.max(this.base,this.next-this.half+1),n=t-this.base;if(!(n<=0)){for(let i=0;i<this.channelCount;i++)this.buffers[i]=this.buffers[i].slice(n);this.base=t}}};var tie={fps:24,minTonality:.7,minIsolationDb:20,maxFrameMultiple:3};function nie(e,t,n,i,r){let o=Math.round(n*i/r),a=2*Math.PI*o/n,s=2*Math.cos(a),c=0,l=0;for(let u=0;u<n;u++){let f=e[t+u]+s*c-l;l=c,c=f}return Math.sqrt(c*c+l*l-s*c*l)/(n/2)}function rie(e,t,n){let i=0;for(let r=0;r<n;r++){let o=e[t+r];i+=o*o}return Math.sqrt(i/n)}var Bg=e=>e>0?20*Math.log10(e):-1/0;function Yg(e,t,n={}){let i={...tie,...n};if(t<=0||e.length===0)return null;let r=1e3/i.fps,o=Math.max(64,Math.round(20/1e3*t)),a=Math.max(1,Math.round(o/2)),s=Math.min(e.length,Math.round(12*t));if(s<o*4)return null;let c=[],l=[];for(let b=0;b+o<=s;b+=a){let h=rie(e,b,o);c.push(h),l.push(h>1e-6?Math.min(1,nie(e,b,o,1e3,t)/(h*Math.SQRT2)):0)}if(c.length<4)return null;let u=[...c].sort((b,h)=>b-h),f=u[Math.floor(u.length/2)],d=b=>l[b]>=i.minTonality&&Bg(c[b])-Bg(Math.max(f,1e-9))>=i.minIsolationDb,m=null,p=0;for(;p<c.length;){if(!d(p)){p++;continue}let b=p;for(;b+1<c.length&&d(b+1);)b++;let h=b-p+1,v=((h-1)*a+o)*1e3/t;if(v<=r*i.maxFrameMultiple){let g=(p*a+(b*a+o))/2,y=Math.max(...c.slice(p,b+1)),w=l.slice(p,b+1).reduce((T,z)=>T+z,0)/h,x={atSeconds:g/t,durationMs:v,tonality:w,isolationDb:Bg(y)-Bg(Math.max(f,1e-9))};(!m||x.isolationDb>m.isolationDb)&&(m=x)}p=b+1}return m}function CI(e,t){if(t<=1)return e;let n=Math.floor(e.length/t),i=new Float32Array(n);for(let r=0;r<n;r++){let o=0;for(let a=0;a<t;a++)o+=e[r*t+a];i[r]=o/t}return i}var UI=1<<18;async function Kg(e,t={}){await ni();let n=Xs(e),i=await Ra(n,e.size),r=JSON.parse(i);if(!r||r.aac)return{loudness:null,twoPop:null,truePeakDb:null};let o=r.sample_rate??0,a=r.channels??0,s=r.sample_frames??0;if(!o||!a||!s)return{loudness:null,twoPop:null,truePeakDb:null};let c=new Du(a,o),l=new qu(a),u=Math.min(s,Math.round(12*o)),f=new Float32Array(u*a),d=0;for(let h=0;h<s;h+=UI){if(t.signal?.aborted)return{loudness:null,twoPop:null,truePeakDb:null};let v=Math.min(UI,s-h),g=await Fa(n,e.size,h,v);if(!g||g.length<12)break;let y=new DataView(g.buffer,g.byteOffset,g.byteLength),w=y.getUint32(8,!0),x=y.getUint32(4,!0);if(!w||!x)break;let T=g.byteOffset+12,z=T%4===0?new Float32Array(g.buffer,T,w*x):new Float32Array(g.slice(12).buffer,0,w*x);if(c.push(z),l.push(z),d<f.length){let k=Math.min(z.length,f.length-d);f.set(z.subarray(0,k),d),d+=k}t.onProgress?.(Math.min(h+v,s),s)}let m=c.finish(),p=d>0?Yg(CI(f.subarray(0,d),a),o,{fps:t.fps&&t.fps>0?t.fps:void 0}):null,b=l.finish();return{loudness:m.integratedLufs===null?null:m,twoPop:p,truePeakDb:Number.isFinite(b)?b:null}}var oie={apco:"ProRes 422 Proxy",apcs:"ProRes 422 LT",apcn:"ProRes 422",apch:"ProRes 422 HQ",ap4h:"ProRes 4444",ap4x:"ProRes 4444 XQ",aprn:"ProRes RAW",aprh:"ProRes RAW HQ"};function AI(e){let t=(e??"").toLowerCase().trim(),n=Ts(t);return{family:n,label:oie[t]??n??t,bitDepth:b6(t),chroma:g6(t)}}function Z9(e){return e.toLowerCase().replace(/\b(apple|avid|sony|panasonic)\b/g,"").replace(/[\s_-]+/g,"")}function GI(e,t){let n=Z9(e),i=Z9(t.label);return!n||!i?!1:i===n||i.startsWith(n)?!0:t.family!=null&&Z9(t.family)===n}var t2e={"23.98":24e3/1001,"23.976":24e3/1001,"29.97":3e4/1001,"59.94":6e4/1001,"47.95":48e3/1001,"119.88":12e4/1001};async function aie(e,t,n,i,r,o){let a=await hk(e,t,n),s={idx:r,ok:!0,w:a.w,h:a.h,black:Qg(a.y)};if(i.diff&&o&&(s.diff=YI(o.y,a.y)),i.hash){let c=zr(a.y,a.w,a.h);s.bits=Array.from(c.bits),s.q=c.quality,s.my=c.meanY??0}return i.bars&&(s.bars=dp(a.y,a.w,a.h)),{result:s,plane:a}}var JI=e=>({idx:e,ok:!1,w:0,h:0,black:!1});async function sie(e,t,n,i,r,o,a){let s=[],c=null;for(let l=0;l<t.length;l++){let u=t[l],f=l<n,d;try{let m=await ja(e,u.offset,u.size,i,r),p=await aie(m,i,r,o,u.idx,c);c=p.plane,d=p.result}catch{d=JI(u.idx)}f||s.push(d),a?.(f?null:d)}return s}function cie(e,t){let n=[],i=Math.min(t,e.length);if(i===0)return n;let r=Math.ceil(e.length/i);for(let o=0;o<e.length;o+=r){let a=e.slice(o,o+r);o===0?n.push({jobs:a,primers:0}):n.push({jobs:[e[o-1],...a],primers:1})}return n}async function BI(e,t,n,i,r,o={}){let{signal:a,onProgress:s}=o;if(t.length===0)return[];let c=t.length,l=0,u=()=>s?.(++l,c);if(typeof Worker>"u")return await sie(e,t,0,n,i,r,b=>{if(a?.aborted)throw new DOMException("aborted","AbortError");b&&u()});let f=Math.max(1,Math.min(navigator.hardwareConcurrency||4,16,t.length)),d=r.diff?cie(t,f):Array.from({length:f},(p,b)=>({jobs:t.filter((h,v)=>v%f===b),primers:0})),m=new Map;return await new Promise((p,b)=>{let h=d.filter(w=>w.jobs.length>0).length;if(h===0){p();return}let v=[],g=()=>{for(let w of v)w.terminate();a?.removeEventListener("abort",y)};function y(){g(),b(new DOMException("aborted","AbortError"))}if(a?.aborted){y();return}a?.addEventListener("abort",y,{once:!0});for(let w of d){if(w.jobs.length===0)continue;let x=new Worker(new URL("./workers/picture-worker.ts",import.meta.url),{type:"module"});v.push(x),x.onmessage=z=>{let k=z.data;if(k.progress)for(let S=0;S<k.progress;S++)u();if(k.results){for(let S of k.results)m.set(S.idx,S);--h===0&&(g(),p())}},x.onerror=z=>{g(),b(new Error(`picture worker error: ${z.message}`))};let T={file:e,jobs:w.jobs,primers:w.primers,spec:n,tier:i,want:r};x.postMessage(T)}}),t.map(p=>m.get(p.idx)??JI(p.idx))}var lie=16,uie=.075,fie=.12;function Qg(e){let t=0,n=0;for(let i=0;i<e.length;i++){let r=e[i];t+=r,r>n&&(n=r)}return t/e.length<=255*uie&&n<=255*fie}function YI(e,t){let n=Math.min(e.length,t.length);if(n===0)return 0;let i=0;for(let r=0;r<n;r++)i+=Math.abs(e[r]-t[r]);return i/n}var die=1.5,mie=1,pie=30;function hie(e,t){let n=[];for(let i of t){let r=e.frames[i];r&&n.push({idx:i,offset:r.offset,size:r.size})}return n}async function _g(e,t,n,i,r,o){if(!t.spec)return null;try{return await BI(e,hie(t,n),t.spec,i,r,{signal:o.signal,onProgress:o.onProgress})}catch(a){if(a instanceof DOMException&&a.name==="AbortError")return null;throw a}}async function KI(e,t,n={}){let i;try{i=t??await gn(e)}catch{return null}if(!i.spec||i.frames.length===0)return null;let r=Wa(i.frames.length,lie),o=await _g(e,i,r,"exact",{bars:!0},n);if(!o)return null;let a=o.filter(g=>g.ok&&g.bars);if(a.length===0)return null;let{w:s,h:c}=a[0],l=qv(a.map(g=>g.bars),s,c),u=i.h>0&&c>0?i.h/c:1,f=i.w>0&&s>0?i.w/s:1,d=l?{x:Math.round(l.x*f),y:Math.round(l.y*u),w:Math.round(l.w*f),h:Math.round(l.h*u)}:null,m=d?Hk(d,Math.round(s*f),Math.round(c*u)):null,p=Math.max(1,Math.round(u)),b=p>1?` (\xB1${p} px, measured at 1/${p} scale)`:"",h=`across ${a.length} sampled frame${a.length===1?"":"s"}`;return l==null||l.x===0&&l.y===0&&l.w===s&&l.h===c?{hasBlanking:!1,note:`none found ${h}`}:{hasBlanking:!0,note:`${m??"bars detected"}${b} ${h}`}}async function QI(e,t,n,i={}){let r;try{r=n??await gn(e)}catch{return null}if(!r.spec||r.frames.length===0)return null;let o=r.frames.length,a=Math.min(t,o),s=Math.max(a,o-t);if(s<=a)return null;let c=[];for(let p=a;p<s;p++)c.push(p);let l=await _g(e,r,c,"exact",{},i);if(!l)return null;let u=[],f=0;for(let p of l)p.ok&&(f++,p.black&&u.push(p.idx));if(f===0)return null;let d=`${f} of ${s-a} interior frames`;if(u.length===0)return{hasBlackFrames:!1,note:`none found in ${d}`};let m=u.slice(0,5).join(", ");return{hasBlackFrames:!0,note:`${u.length} black frame${u.length===1?"":"s"} at ${m}${u.length>5?", \u2026":""} (${d})`}}function I9(e,t){let n=e/t,i=Math.floor(n/60);return`${i}:${(n-i*60).toFixed(2).padStart(5,"0")}`}async function _I(e,t,n={}){let i;try{i=t??await gn(e)}catch{return null}if(!i.spec||i.frames.length===0)return null;let r=i.fps&&i.fps>0?i.fps:24,o=Math.min(i.frames.length,Math.round(r*pie)),a=[];for(let f=0;f<o;f++)a.push(f);let s=await _g(e,i,a,"exact",{diff:!0},n);if(!s)return null;let c=[],l=[],u=0;for(let f=0;f<s.length;f++){let d=s[f];if(!d.ok){c.push(c[f-1]??!1),l.push(!1);continue}u++,c.push(d.black),l.push(d.diff==null?!1:d.diff>die)}return u===0?null:bie(c,l,r)}function bie(e,t,n){let i=e.length,r=Math.max(2,Math.round(n*mie)),o=0;for(;o<i&&e[o];)o++;let a=o,s=-1,c=-1;for(;o<i;){if(e[o]){o++;continue}let f=o,d=o+1;for(;d<i&&!e[d]&&!t[d];)d++;if(d-f>=r){s=f,c=d;break}o=Math.max(d,o+1)}let l=null;for(let f=c>=0?c:a;f<i;f++)if(!e[f]){l=f;break}let u=[];return a>0&&u.push(`${(a/n).toFixed(2)} s black at head`),s>=0?u.push(`a static card ${I9(s,n)}\u2013${I9(c,n)} (${((c-s)/n).toFixed(2)} s)`):u.push(`no static card in the first ${(i/n).toFixed(0)} s`),l!=null&&u.push(`picture from ${I9(l,n)}`),{hasSlate:s>=0,programmeStart:l,note:u.join(", ")}}var gie=1200,vie=.5,yie=.6,wie=.7,xie=3;function Pie(e,t,n){let i=e.length;for(let r=n;r<i;r++){if(!e[r]||t[r])continue;let o=0,a=0;for(let s=r;s<i;s++)t[s]||(o++,e[s]&&a++);if(o>=3&&a>=o*wie)return r}return-1}async function $I(e,t,n={}){let i;try{i=t??await gn(e)}catch{return null}if(!i.spec||i.frames.length===0)return null;let r=i.fps&&i.fps>0?i.fps:24,o=i.frames.length,a=Math.max(1,Math.round(r*vie),Math.ceil(o/gie)),s=[];for(let g=0;g<o;g+=a)s.push(g);let c=await _g(e,i,s,"coarse",{hash:!0},n);if(!c)return null;let l=[],u=[],f=[];for(let g of c)!g.ok||!g.bits||(l.push(g.idx),u.push({bits:Uint32Array.from(g.bits),quality:g.q??0,meanY:g.my}),f.push(g.black));let d=u.length,m=`sampled every ${(a/r).toFixed(2)} s`;if(d<8)return null;let p=Math.floor(d*yie);if(p<2)return null;let b=new Array(d).fill(!1);for(let g=p;g<d;g++)if(!f[g]){for(let y=0;y<p;y++)if(fn(u[g],u[y])<=An){b[g]=!0;break}}let h=Pie(b,f,p);if(h<0)return{hasTextlessTail:!1,note:`no repeated material at the tail (${m})`};let v=(l[d-1]-l[h])/r;return v<xie?{hasTextlessTail:!1,note:`only ${v.toFixed(1)} s of repeated material at the tail, too short to be textless (${m})`}:{hasTextlessTail:!0,note:`${v.toFixed(1)} s from ${(l[h]/r/60).toFixed(0)}:${(l[h]/r%60).toFixed(2).padStart(5,"0")} repeats earlier picture (${m})`}}function Sie(e){let t=e.toLowerCase().match(/\.([a-z0-9]{2,4})$/);return t?t[1]:void 0}function kie(e){if(e===1)return"mono";if(e===2)return"stereo";if(e===6)return"5.1"}async function eW(e,t={}){let n={name:e.name,sizeBytes:e.size,wrapper:Sie(e.name)},i;try{let r=await gn(e);i=r,n.width=r.w||void 0,n.height=r.h||void 0,n.fps=r.fps??void 0,n.durationFrames=r.frames.length||void 0;let o=r.index?.codec,a=AI(o??r.label);n.codec=o?a.label:r.label,n.bitDepth=a.bitDepth??void 0,n.chroma=a.chroma??void 0,r.fps&&Number.isFinite(r.startFrame)&&(n.startTimecode=zi(r.startFrame,r.fps,r.dropFrame))}catch{}if(t.audio!==!1){try{let r=await fp(e);r&&(n.audioChannels=r.channels,n.audioSampleRate=r.sampleRate,n.audioLayout=kie(r.channels))}catch{}if(t.loudness!==!1)try{let r=await Kg(e,{signal:t.signal,fps:n.fps});r.loudness?.integratedLufs!=null&&(n.loudnessLufs=r.loudness.integratedLufs),r.truePeakDb!=null&&(n.truePeakDb=r.truePeakDb),n.hasTwoPop=r.twoPop!==null}catch{}}if(t.picture?.blanking){let r=await KI(e,i,{signal:t.signal});r&&(n.hasBlanking=r.hasBlanking,n.blankingNote=r.note)}if(t.picture?.headStructure){let r=await _I(e,i,{signal:t.signal});r&&(n.hasSlate=r.hasSlate,n.slateNote=r.note)}if(t.picture?.textlessTail){let r=await $I(e,i,{signal:t.signal});r&&(n.hasTextlessTail=r.hasTextlessTail,n.textlessNote=r.note)}if(t.picture?.blackFrames){let r=n.fps&&n.fps>0?Math.round(n.fps):24,o=await QI(e,r,i,{signal:t.signal});o&&(n.hasBlackFrames=o.hasBlackFrames,n.blackFramesNote=o.note)}return n}function Hu(e,t,n,i,r,o){let a=fi(e,t,n,i,(s,c)=>s===c,r);return o&&a.outcome!=="unstated"?{...a,note:o}:a}function W9(e,t){let n=t.plusMinus??0;return Math.abs(e-t.target)<=n+1e-9}function Tie(e){return e.plusMinus?`${e.target} \xB1${e.plusMinus}`:String(e.target)}function fi(e,t,n,i,r,o){if(n==null)return{field:e,label:t,outcome:"unstated"};let a=o.required(n.value);return i==null||typeof i=="number"&&!Number.isFinite(i)?{field:e,label:t,outcome:"unmeasurable",required:a,note:"not reported by the probe"}:{field:e,label:t,outcome:r(n.value,i)?"pass":"fail",required:a,measured:o.measured(i)}}var Fm={required:e=>e,measured:e=>e},Eu={required:e=>String(e),measured:e=>String(e)},D9={required:Tie,measured:e=>String(e)};function tW(e,t){let n=e.video??{},i=e.audio??{},r=e.content??{};return[fi("video.codec","Codec",n.codec,t.codec,(o,a)=>GI(o,{family:null,label:a}),Fm),fi("video.wrapper","Wrapper",n.wrapper,t.wrapper,(o,a)=>o.toLowerCase()===a.toLowerCase(),Fm),fi("video.width","Width",n.width,t.width,(o,a)=>o===a,Eu),fi("video.height","Height",n.height,t.height,(o,a)=>o===a,Eu),fi("video.fps","Frame rate",n.fps,t.fps,(o,a)=>W9(a,o),D9),fi("video.durationFrames","Duration (frames)",n.durationFrames,t.durationFrames,(o,a)=>W9(a,o),D9),fi("video.startTimecode","Start timecode",n.startTimecode,t.startTimecode,(o,a)=>o===a,Fm),fi("video.par","Pixel aspect ratio",n.par,t.par,(o,a)=>Math.abs(o-a)<=.005,Eu),fi("video.bitDepth","Bit depth",n.bitDepth,t.bitDepth,(o,a)=>o===a,Eu),fi("video.chroma","Chroma",n.chroma,t.chroma,(o,a)=>Jm(o)===Jm(a),Fm),fi("audio.channels","Audio channels",i.channels,t.audioChannels,(o,a)=>o===a,Eu),fi("audio.layout","Audio layout",i.layout,t.audioLayout,(o,a)=>o.toLowerCase()===a.toLowerCase(),Fm),fi("audio.sampleRate","Sample rate",i.sampleRate,t.audioSampleRate,(o,a)=>o===a,Eu),fi("audio.loudnessLufs","Loudness (LUFS)",i.loudnessLufs,t.loudnessLufs,(o,a)=>W9(a,o),D9),fi("audio.truePeakDb","True peak (dBTP)",i.truePeakDb,t.truePeakDb,(o,a)=>a<=o+1e-9,{required:o=>`\u2264 ${o}`,measured:o=>o.toFixed(2)}),Hu("content.twoPop","2-pop",r.twoPop,t.hasTwoPop,{required:o=>o?"present":"absent",measured:o=>o?"present":"absent"}),Hu("content.slate","Slate",r.slate,t.hasSlate,{required:o=>o?"present":"absent",measured:o=>o?"present":"absent"},t.slateNote),Hu("content.textlessAtTail","Textless at tail",r.textlessAtTail,t.hasTextlessTail,{required:o=>o?"present":"absent",measured:o=>o?"present":"absent"},t.textlessNote),Hu("content.noBlanking","Free of blanking",r.noBlanking,t.hasBlanking==null?void 0:!t.hasBlanking,{required:o=>o?"no blanking":"blanking allowed",measured:o=>o?"none found":"blanking found"},t.blankingNote),Hu("content.noBlackFrames","Free of black frames",r.noBlackFrames,t.hasBlackFrames==null?void 0:!t.hasBlackFrames,{required:o=>o?"no black frames":"black frames allowed",measured:o=>o?"none found":"black frames found"},t.blackFramesNote),Hu("content.matchesMaster","Matches approved master",r.matchesMaster,t.matchesMaster,{required:o=>o?"must match":"need not match",measured:o=>o?"matches":"differs"})]}async function zie(e,t){try{await ni();let n=await sr.open(e),i=Xs(n),r=JSON.parse(await Ra(i,n.size)||"null");if(!r||r.aac||!r.sample_rate||!r.sample_frames)return null;let o=r.sample_rate,a=r.sample_frames,s=0;for(let c=0;c<a;c+=o*10){let l=await Fa(i,n.size,c,Math.min(o*10,a-c));if(!l||l.length<12)break;let u=new DataView(l.buffer,l.byteOffset,l.byteLength),f=u.getUint32(4,!0),d=u.getUint32(8,!0);if(!d||!f)break;s=f,t(new Float32Array(l.slice(12,12+d*f*4).buffer),f,o)}return s?{tracks:1,channels:s,rate:o}:null}catch{return null}}async function q9(e,t,n){let i=await Vr();if(!i)return t===0?zie(e,n):null;let r=new Deno.Command(i,{args:["audio",e,"--track",String(t)],stdout:"piped",stderr:"null"}).spawn(),o=r.stdout.getReader(),a=null,s=new Uint8Array(0);for(;;){let{value:c,done:l}=await o.read();if(l)break;let u=s.length?new Uint8Array([...s,...c]):c;if(!a){let m=u.indexOf(10);if(m<0){s=u;continue}if(a=JSON.parse(new TextDecoder().decode(u.subarray(0,m))),!a?.ok||!a.rate||!a.channels){await o.cancel();break}u=u.subarray(m+1)}let f=4*a.channels,d=u.length-u.length%f;d&&n(new Float32Array(u.slice(0,d).buffer),a.channels,a.rate),s=u.slice(d)}return await r.status,a?.ok&&a.rate&&a.channels?{tracks:a.tracks??1,channels:a.channels,rate:a.rate}:null}async function nW(e,t){let n=null,i=null,r=await q9(e,t,(a,s,c)=>{n??=new Du(s,c),i??=new qu(s),n.push(a),i.push(a)});if(!r||!n||!i)return null;let o=i.finish();return{track:t+1,tracks:r.tracks,channels:r.channels,rate:r.rate,lufs:n.finish().integratedLufs,peak_db:Number.isFinite(o)?o:null}}async function rW(e){let t=await nW(e,0);if(t){let o=[t];for(let a=1;a<t.tracks;a++){let s=await nW(e,a);s&&o.push(s)}return o.map(({track:a,channels:s,rate:c,lufs:l,peak_db:u})=>({track:a,channels:s,rate:c,lufs:l,peak_db:u}))}let i=(await Rn(e).catch(()=>null))?.streams?.filter(o=>o.kind==="audio").reduce((o,a)=>o+(a.channels??0),0)??0;if(!i)return[];let r=await Kg(await sr.open(e)).catch(()=>null);return[{track:1,channels:i,rate:0,lufs:r?.loudness?.integratedLufs??null,peak_db:r?.truePeakDb??null}]}var ys=e=>e==null?"\u2014":`${e.toFixed(1)}`;function Mie(e,t){if(!t.length)return[];let n=[],i=new Set;for(let r of e){if(r.lufs==null)continue;let o=t.map((c,l)=>({x:c,i:l,d:c.lufs==null?1/0:r.lufs-c.lufs})).sort((c,l)=>Math.abs(c.d)-Math.abs(l.d)),a=o.find(c=>Math.abs(c.d)<=.5&&c.x.channels===r.channels)??o.find(c=>Math.abs(c.d)<=.5),s=o.find(c=>c.d>=5&&c.d<=7);a&&i.add(a.i),n.push(a?{check:`Track ${r.track} vs mix`,outcome:a.x.channels===r.channels?"pass":"warn",measured:`= ${a.x.file} (${a.x.channels}ch, ${ys(a.x.lufs)} LUFS, \u0394 ${a.d.toFixed(1)} LU)`,note:a.x.channels!==r.channels?"loudness matches but the channel count differs (downmix or wrong bus)":void 0}:{check:`Track ${r.track} vs mix`,outcome:"fail",measured:`${ys(r.lufs)} LUFS`,note:s?`\u2248 +6 LU over ${s.x.file}: summed twice (two buses into one output, or a doubled track)`:`no mix file within 0.5 LU (nearest ${o[0]?.x.file??"\u2014"}: ${ys(o[0]?.x.lufs??null)} LUFS)`})}return t.forEach((r,o)=>{i.has(o)||n.push({check:`Mix ${r.file}`,outcome:"warn",measured:`${r.channels}ch, ${ys(r.lufs)} LUFS`,note:"no output track carries this mix (missing bus?)"})}),n}var vs=e=>({value:e,source:"operator"});async function iW(e){let t=await sr.open(e.path),n=await eW(t,{loudness:!1}),i=e.fps??n.fps??24,r=g=>g==null?null:typeof g=="number"?g:Kn(g,i),o=r(e.mark_in),a=r(e.mark_out),s=await Di(),c=o!=null?tn(o,i):e.start_tc??s.conventions?.program_start,l=e.end_on_picture??s.conventions?.end_on_picture,u=e.frames??(o!=null&&a!=null?a-o+1:void 0),f={label:Fc(e.path),video:{...e.codec?{codec:vs(e.codec)}:{},...e.width?{width:vs(e.width)}:{},...e.height?{height:vs(e.height)}:{},...e.fps?{fps:vs({target:e.fps,plusMinus:.001})}:{},...e.bit_depth?{bitDepth:vs(e.bit_depth)}:{},...e.chroma?{chroma:vs(e.chroma)}:{},...c?{startTimecode:vs(c)}:{},...u?{durationFrames:vs({target:u})}:{}}},d=tW(f,n).filter(g=>g.outcome!=="unstated").map(g=>({check:g.label,outcome:g.outcome==="pass"||g.outcome==="fail"?g.outcome:"unchecked",expected:g.required,measured:g.measured,note:g.note}));if(c||d.push({check:"Start timecode",outcome:"unchecked",measured:n.startTimecode,note:"no start TC stated and none in the artist's profile: confirm it (artist_profile action=remember convention program_start)"}),d.push({check:"Picture",outcome:"pass",measured:[n.codec,n.width&&`${n.width}x${n.height}`,n.fps&&`${+n.fps.toFixed(3)} fps`,n.bitDepth&&`${n.bitDepth}-bit`,n.chroma].filter(Boolean).join(", ")}),e.name!==!1)try{let g=rl(s,Fc(e.path),{probe:await Rn(e.path)}),y=g.issues.filter(x=>x.level==="error"),w=g.issues.filter(x=>x.level==="warn");d.push({check:"Name",outcome:y.length?"fail":w.length?"warn":"pass",measured:Fc(e.path),note:g.issues.map(x=>`${x.element}: ${x.message}`).join("; ")||void 0})}catch(g){d.push({check:"Name",outcome:"unchecked",note:String(g.message??g)})}try{let g=await gn(t),y=n.durationFrames??g.frames.length,w=g.spec?null:na(e.path,256),x=g.spec?await Ho(t):null,T=async X=>{let R=w?await w.read(X):await x.luma(X);return R?Qg(R.y):null},z=async(X,R)=>{let I=Math.round(5*i),q=0;for(;q<I&&X+R*q>=0&&X+R*q<y&&await T(X+R*q);)q++;return q},[k,S]=[await T(0),await T(y-1)],M=k?await z(0,1):0,L=S?await z(y-1,-1):0,P=X=>X>=Math.round(5*i)?"5 s or more":`${X} frame(s)`;d.push({check:"First frame",outcome:k==null?"unchecked":k?"warn":"pass",measured:k==null?void 0:k?`black (${P(M)})`:"picture"}),d.push({check:"Last frame",outcome:S==null?"unchecked":S?l?"fail":"warn":"pass",measured:S==null?void 0:S?`black (last ${P(L)})`:"picture",note:S?l?"the job ends on picture: Mark Out past the end card, or a gap at the tail":"black tail: confirm the delivery spec pads with black":void 0})}catch{d.push({check:"First/last frame",outcome:"unchecked"})}let m=await rW(e.path),p=m.reduce((g,y)=>g+y.channels,0);e.channels!=null&&d.push({check:"Audio channels",outcome:p===e.channels?"pass":"fail",expected:String(e.channels),measured:`${p} (${m.map(g=>`track ${g.track}: ${g.channels}ch`).join(", ")||"no audio"})`});for(let g of m){let y=e.loudness_lufs==null||g.lufs==null?null:Math.abs(g.lufs-e.loudness_lufs)<=(e.loudness_tolerance??1),w=e.true_peak==null||g.peak_db==null?null:g.peak_db<=e.true_peak;d.push({check:`Audio track ${g.track}`,outcome:y===!1||w===!1?"fail":g.lufs==null?"unchecked":"pass",expected:[e.loudness_lufs!=null&&`${e.loudness_lufs} LUFS \xB1${e.loudness_tolerance??1}`,e.true_peak!=null&&`\u2264 ${e.true_peak} dBTP`].filter(Boolean).join(", ")||void 0,measured:`${g.channels}ch${g.rate?` ${g.rate/1e3} kHz`:""}, ${ys(g.lufs)} LUFS, ${ys(g.peak_db)} dBTP`})}let b=m.find(g=>g.channels===2)??m[0],h=s.conventions?.theatrical_tag;if(h&&b?.lufs!=null&&e.name!==!1){let g=new RegExp(`[_\\-. ]${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}([_\\-. ]|$)`,"i").test(Fc(e.path));g&&b.lufs>-20&&d.push({check:`${h} tag`,outcome:"warn",measured:`${ys(b.lufs)} LUFS on track ${b.track}`,note:`tagged ${h} (theatrical) but measures at a web/nearfield level`}),!g&&b.lufs<-27&&d.push({check:`${h} tag`,outcome:"warn",measured:`${ys(b.lufs)} LUFS on track ${b.track}`,note:`measures at a theatrical level: add _${h} to the audio config? ask`})}m.length||d.push({check:"Audio",outcome:e.channels===0?"pass":e.channels||e.mix?.length?"fail":"warn",measured:"no audio tracks"});let v=[];for(let g of e.mix??[]){let y=await rW(g);y.length||d.push({check:`Mix ${Fc(g)}`,outcome:"unchecked",measured:"no audio read from this file"});for(let w of y)v.push({...w,file:Fc(g)})}if(d.push(...Mie(m,v)),e.ref)try{let g=await Gg({a:e.path,b:e.ref,b_in:e.ref_in??n.startTimecode??c}),y=g.overall;d.push({check:"Picture vs REF",outcome:y.verdict==="exact"?"pass":y.verdict==="unverifiable"?"warn":"fail",measured:y.verdict==="offset"?`offset ${y.offset>0?"+":""}${y.offset} frame(s)`:y.verdict,expected:`exact at ${g.b_tc}`,note:[...g.shots.filter(w=>w.verdict!=="exact").slice(0,5).map(w=>`shot ${w.a_tc}: ${w.verdict}${w.offset?` ${w.offset>0?"+":""}${w.offset}`:""}`),...g.flash].join("; ")||void 0})}catch(g){d.push({check:"Picture vs REF",outcome:"unchecked",note:String(g.message??g)})}return{file:Fc(e.path),verdict:d.some(g=>g.outcome==="fail")?"FAIL":"PASS",rows:d,tracks:m,mix:v}}function oW(e){let t={pass:"PASS",fail:"FAIL",warn:"WARN",unchecked:"----"};return[`${e.verdict}: ${e.file}`,...e.rows.map(n=>` ${t[n.outcome]} ${n.check}: ${n.measured??"could not measure"}${n.expected?` (expected ${n.expected})`:""}${n.note?` \u2014 ${n.note}`:""}`)].join(`
182
+ `)}import{basename as aW}from"node:path";var Oie=10**(-60/20);async function Lie(e,t){let i=(await Rn(e).catch(()=>null))?.vendor_metadata?.bext,r=0,o=-1,a=0,s=0,c=[];if(!await q9(e,0,(p,b,h)=>{a=h,s=b;for(let v=0;v<p.length;v+=b){let g=0,y=0;for(let w=0;w<b;w++){let x=Math.abs(p[v+w]);x>g&&(g=x),y+=p[v+w]}g>Oie&&(o=r),r<h*15&&c.push(y/b),r++}}))return null;let u=gy(i?.time_reference??0,i?.sample_rate||a,r,t),f=Kn(u.tc,t)??0,d=p=>f+Math.floor(p*u.frames/Math.max(r,1)),m=Yg(Float32Array.from(c),a,{fps:t});return{file:aW(e),channels:s,start:f,end:f+u.frames,last_sound:o<0?f:d(o)+1,pop:m?d(m.atSeconds*a):null}}function Xie(e){let t=e.toUpperCase().split(/[_.]/),n=[];for(let r of t)r==="5-1"?n.push({label:"5.1",channels:6}):r==="7-1"?n.push({label:"7.1",channels:8}):r==="STEREO"||r==="LORO"?n.push({label:r==="LORO"?"LoRo":"stereo",channels:2}):r==="MONO"&&n.push({label:"mono",channels:1});let i=t.map(r=>/^(\d+)CH$/.exec(r)).find(Boolean);return{total:i?Number(i[1]):null,parts:n}}async function sW(e,t){let n=kg(e,t.timeline_id),i=Lc(n),r=!!n.is_drop_frame,o=x=>tn(x,i,r),a=n.tracks.filter(x=>x.kind==="Video"),s=Tg(n,a),c=[];if(!s.length)throw new Error("the timeline has no enabled video");let l=s[0].s,u=s[s.length-1].e,f=[];for(let x of t.mix??[]){let T=await Lie(x,i);T?f.push(T):c.push({check:`Mix ${aW(x)}`,outcome:"unchecked",measured:"no audio read from this file"})}let d=f[0],m=t.program_start??(await Di()).conventions?.program_start,p=m?Kn(m,i):null,b=d?.pop!=null?d.pop+Math.round(2*i):null,h=b??(p!=null&&p>=l-Math.round(10*i)?p:l);d&&c.push(d.pop!=null?{check:"2-pop",outcome:p==null||b===p?"pass":"warn",measured:`${o(d.pop)} in ${d.file} \u2192 program starts ${o(b)}`,note:p!=null&&b!==p?`the stated start is ${o(p)}`:void 0}:{check:"2-pop",outcome:"warn",measured:`none found in the first 15 s of ${d.file}`,note:`program start taken as ${o(h)}`});let v=d?d.last_sound:u;if(d){let x=u-d.last_sound;c.push({check:"Picture end vs mix end",outcome:x===0?"pass":"fail",measured:`picture ends ${o(u-1)} (last frame), sound ends ${o(d.last_sound-1)}`,note:x===0?void 0:x<0?`picture stops ${-x} frame(s) before the mix: ${-x} frame(s) of black under sound. EDIT ERROR: extend the last shot/card, or ask`:`picture runs ${x} frame(s) past the mix: picture with no sound at the end. EDIT ERROR: ask before trimming`});for(let T of f.slice(1))T.last_sound!==d.last_sound&&c.push({check:`Mix ${T.file} end`,outcome:"warn",measured:`sound ends ${o(T.last_sound-1)}`,note:`${d.file} ends ${o(d.last_sound-1)}`});d.start>h&&c.push({check:"Mix start",outcome:"fail",measured:`${d.file} starts ${o(d.start)}`,note:`after the program start ${o(h)}: no sound under the first frames`})}l>h&&c.push({check:"Picture start",outcome:"fail",measured:`first picture ${o(l)}`,note:`${l-h} frame(s) of black after the program start ${o(h)}`});let g=s.find(x=>x.s<=v-1&&x.e>=v);c.push({check:"Last program frame",outcome:g?"pass":"fail",measured:g?`${o(v-1)}: ${g.it.name??"clip"} (${g.track})`:`${o(v-1)}: no picture`,note:g?"confirm it is the end card, not black inside the clip":"the program ends on a gap"});let y=[],w=h;for(let x of s)if(!(x.e<=h)){if(x.s>=v)break;x.s>w&&y.push([w,Math.min(x.s,v)]),w=Math.max(w,x.e)}w<Math.min(v,u)&&y.push([w,Math.min(v,u)]),c.push(y.length?{check:"Gaps in the program",outcome:"warn",measured:y.map(([x,T])=>`${o(x)}\u2013${o(T-1)} (${T-x} fr)`).join(", "),note:"black in the render: check each against the REF (intentional or an edit error)"}:{check:"Gaps in the program",outcome:"pass",measured:"none"});for(let x of a){if(x.enabled===!1)continue;let T=x.items.filter(k=>k.kind==="clip"&&k.enabled!==!1).map(k=>(n.start_frame??0)+k.timeline_range.start.value+k.timeline_range.duration.value),z=Math.max(...T,-1/0);z>Math.min(v,u)-Math.round(i)&&z<Math.min(v,u)&&c.push({check:`Track ${Ei(x,n.tracks)}`,outcome:"warn",measured:`ends ${Math.min(v,u)-z} frame(s) before the picture ends`,note:"an effect/adjustment layer should cover the whole program"})}if(t.name){let x=Xie(t.name),T=x.parts.reduce((z,k)=>z+k.channels,0);if(x.total!=null&&x.parts.length&&T!==x.total)c.push({check:"Name audio",outcome:"fail",measured:t.name,note:`${x.total}CH but ${x.parts.map(z=>z.label).join(" + ")} = ${T} channels`});else if(x.parts.length&&f.length){let z=[...f],k=x.parts.filter(S=>{let M=z.findIndex(L=>L.channels===S.channels);return M<0?!0:(z.splice(M,1),!1)});c.push({check:"Name audio vs mix",outcome:k.length?"fail":"pass",measured:`${x.parts.map(S=>`${S.label} (${S.channels}ch)`).join(" + ")} = ${T}ch`,note:k.length?`no ${k.map(S=>`${S.channels}ch mix for ${S.label}`).join(", ")} among ${f.map(S=>`${S.file} (${S.channels}ch)`).join(", ")}`:"route each to an output track in this order (host_render audio_tracks), then qc_deliverable the render"})}}return{verdict:c.some(x=>x.outcome==="fail"||x.outcome==="unchecked"&&x.check.startsWith("Mix "))?"STOP":"READY",rows:c,mark_in:o(h),mark_out:o(v-1),program:[h,v],mix:f}}function cW(e){let t={pass:"PASS",fail:"FAIL",warn:"WARN",unchecked:"----"};return[`${e.verdict==="READY"?"READY to render":"STOP: fix before rendering"} \u2014 Mark In ${e.mark_in}, Mark Out ${e.mark_out} (inclusive, ${e.program[1]-e.program[0]} frames)`,...e.rows.map(n=>` ${t[n.outcome]} ${n.check}: ${n.measured??"could not measure"}${n.note?` \u2014 ${n.note}`:""}`)].join(`
183
+ `)}import{basename as H9}from"node:path";var Nie=[[4/3,"1.33 (4:3)"],[1.66,"1.66"],[16/9,"1.78 (16:9)"],[1.85,"1.85"],[1.9,"1.90 (DCI)"],[2,"2.00"],[2.2,"2.20"],[2.35,"2.35"],[2.39,"2.39"],[2.4,"2.40"],[2.76,"2.76"]];function Rie(e){let t=Nie.reduce((n,i)=>Math.abs(i[0]-e)<Math.abs(n[0]-e)?i:n);return Math.abs(t[0]-e)/e<=.015?t[1]:e.toFixed(2)}async function lW(e,t=16){let n=await sr.open(e),i=await gn(n).catch(()=>null),r=i?null:await Ws(e),o=i?.w??r.w,a=i?.h??r.h,s=i?.frames.length??r.frames;if(!o||!a||!s)throw new Error(`${H9(e)}: no raster or frames in the probe`);let c=i?.spec?null:na(e,640),l=i?.spec?await Ho(n):null,u=[];for(let z of Wa(s,t)){let k=c?await c.read(z):await l.luma(z);k&&u.push({luma:k.y,w:k.w,h:k.h})}if(!u.length)throw new Error(`${H9(e)}: no frame decoded`);let f=u[0].w,d=u[0].h,m=Gc(u)??{x:0,y:0,w:f,h:d},p=o/f,b=a/d,h={x:Math.round(m.x*p),y:Math.round(m.y*b),w:Math.round(m.w*p),h:Math.round(m.h*b)},v=h.h<a-2,g=h.w<o-2,y=v&&g?"windowbox":v?"letterbox":g?"pillarbox":"none",w=h.w/h.h,x=z=>2*Math.round(z/2),T=y==="pillarbox"?`${x(a*w)}x${a}`:`${o}x${x(o/w)}`;return{file:H9(e),width:o,height:a,frames_sampled:u.length,active:h,boxing:y,aspect:+w.toFixed(4),aspect_name:Rie(w),oar_raster:y==="none"?`${o}x${a}`:T}}function uW(e){return`${e.boxing==="none"?`${e.file}: full ${e.width}x${e.height} raster is picture \u2192 OAR ${e.aspect_name}, no boxing`:`${e.file}: ${e.boxing}: active picture ${e.active.w}x${e.active.h} at (${e.active.x},${e.active.y}) inside ${e.width}x${e.height} \u2192 OAR ${e.aspect_name}; OAR raster ${e.oar_raster}`}
184
+ (${e.frames_sampled} frames sampled across the clip; a bar counts only when \u226580% of them carry it)`}var bW=/lower ?thirds?|\bLTs?\b|titles?|subtitles?|\bsubs\b|captions?|graphics?|\bgfx\b|\btext\b|supers?/i,Fie=e=>e.fps_den?e.fps_num/e.fps_den:e.fps_num,Ma=e=>[e.timeline_range.start.value,e.timeline_range.start.value+e.timeline_range.duration.value],fW=e=>bW.test(e.name??"")||e.items.some(t=>t.kind!=="gap")&&e.items.every(t=>t.kind==="gap"||!!t.title),Cu=e=>e.enabled!==!1&&(e.kind==="clip"||e.kind==="nested"),dW=e=>`V${e.track_index}${e.name?` "${e.name}"`:""}`;function gW(e,t,n={}){let i=e.timelines.filter(P=>P.kind!=="compound"),r=n.timeline_id?i.find(P=>P.id===n.timeline_id):i.find(P=>P.tracks.some(X=>X.kind==="Video"&&X.items.length));if(!r)throw new ze("not_found",n.timeline_id?`no timeline ${n.timeline_id} in this session`:"the session has no timeline with video");if(!t.length)throw new ze("invalid_args","changes is empty: give clip ids or record ranges");let o=Fie(r),a=r.start_frame??0,s=!!r.is_drop_frame,c=P=>tn(P+a,o,s),l=[],u=r.tracks.filter(P=>P.kind==="Video"&&P.enabled!==!1).sort((P,X)=>X.track_index-P.track_index),f=u.filter(fW),d=u.filter(P=>!fW(P));for(let P of r.tracks)P.kind==="Video"&&P.enabled===!1&&bW.test(P.name??"")&&P.items.some(Cu)&&l.push(`${dW(P)} is a graphics track but disabled: left out of TEXTED too; enable it if the master carries it`);let m=Math.max(0,...u.flatMap(P=>P.items.filter(Cu).map(X=>Ma(X)[1]))),p=new Set([0,m]);for(let P of d)for(let X of P.items)Cu(X)&&Ma(X).forEach(R=>p.add(R));let b=[...p].filter(P=>P>=0&&P<=m).sort((P,X)=>P-X),h=[];for(let P=0;P+1<b.length;P++){let[X,R]=[b[P],b[P+1]],I={start:X,end:R,item:null,track:null};for(let Y of d){let D=Y.items.find(j=>Cu(j)&&Ma(j)[0]<=X&&Ma(j)[1]>=R);if(D){I={start:X,end:R,item:D,track:Y};break}}let q=h[h.length-1];q&&q.item===I.item?q.end=R:h.push(I)}let v=[...f.flatMap(P=>P.items.filter(Cu).map(Ma)),...u.flatMap(P=>P.items.filter(X=>X.kind==="transition").map(Ma))],g=new Set([0,m,...h.map(P=>P.start)].filter(P=>!v.some(([X,R])=>X<P&&P<R))),y=P=>Math.max(...[...g].filter(X=>X<=P)),w=P=>Math.min(...[...g].filter(X=>X>=P)),x=P=>h.find(X=>X.start<=P&&P<X.end),T=new Map(r.tracks.flatMap(P=>P.items.map(X=>[X.id,X]))),z=P=>{if(typeof P=="number")return P-a;let X=Kn(P,o);if(X==null){if(/^\d+$/.test(P))return Number(P)-a;throw new ze("invalid_args",`cannot read '${P}' as a record timecode`)}return X-a},k=t.map(P=>{if(typeof P=="string"){let I=T.get(P);if(!I)throw new ze("not_found",`no clip ${P} on ${r.name} (item ids come from timeline_query)`);return[...Ma(I)]}let[X,R]=[z(P.in),z(P.out)+1];if(R<=X)throw new ze("invalid_args",`range ${P.in}..${P.out} is empty or backwards`);return[X,R]}).sort((P,X)=>P[0]-X[0]);for(let[P,X]of k)if(P<0||X>m)throw new ze("invalid_args",`change ${c(P)}\u2013${c(X-1)} is outside the timeline (${c(0)}\u2013${c(m-1)})`);let S=[];for(let[P,X]of k){let R=P>0?x(P-1):void 0,I=X<m?x(X):void 0,q=y(R?.item?R.start:P),Y=w(I?.item?I.end:X),D=S[S.length-1];D&&q<=D.tail?(D.tail=Math.max(D.tail,Y),D.changes.push([P,X])):S.push({head:q,tail:Y,changes:[[P,X]]})}let M=P=>P.item?P.item.name??P.item.reel_name??P.item.id:"(black)",L=S.map((P,X)=>{let R=h.filter(H=>H.end>P.head&&H.start<P.tail),I=H=>P.changes.some(([ne,le])=>H.end>ne&&H.start<le),q=R.findIndex(I),Y=R.length-1-[...R].reverse().findIndex(I),D=R.map((H,ne)=>({role:I(H)?"changed":ne===q-1?"before":ne===Y+1?"after":"inside",name:M(H),track:H.track?dW(H.track):"-",rec_in_tc:c(H.start),frames:H.end-H.start})),j=f.filter(H=>H.items.some(ne=>Cu(ne)&&Ma(ne)[1]>P.head&&Ma(ne)[0]<P.tail)),C=[];return D.some(H=>H.role==="before")||C.push("no clip before the change (timeline head or black): starts on the change"),D.some(H=>H.role==="after")||C.push("no clip after the change (timeline tail or black): ends on the change"),j.length||C.push("no graphics in range: one render serves TEXTED and TEXTLESS"),{nn:(n.first_patch??1)+X,range:{in:P.head+a,out:P.tail-1+a},frames:P.tail-P.head,rec_in_tc:c(P.head),rec_out_tc:c(P.tail-1),start_tc:c(P.head),versions:j.length?["TEXTED","TEXTLESS"]:["TEXTED"],textless_exclude_tracks:j.map(H=>({index:H.track_index,name:H.name??null})),audio:!1,neighbours:D,notes:C}});return{timeline:r.name,fps:o,start_tc:c(0),patches:L,warnings:l}}function vW(e){let t=`${e.patches.length} patch${e.patches.length===1?"":"es"} on ${e.timeline}: `+e.patches.map(i=>`PATCH${String(i.nn).padStart(2,"0")} ${i.rec_in_tc}\u2013${i.rec_out_tc} (${i.frames} fr, ${i.versions.join("+")})`).join("; "),n=e.patches.flatMap(i=>[`PATCH${String(i.nn).padStart(2,"0")}: record ${i.rec_in_tc}\u2013${i.rec_out_tc} inclusive, ${i.frames} frames; host_render range {in:${i.range.in}, out:${i.range.out}}; file TC ${i.start_tc}; picture only`,...i.neighbours.map(r=>` ${r.role.padEnd(7)} ${r.rec_in_tc} ${String(r.frames).padStart(5)} fr ${r.track} ${r.name}`),i.textless_exclude_tracks.length?` TEXTLESS: leave out ${i.textless_exclude_tracks.map(r=>`V${r.index}${r.name?` "${r.name}"`:""}`).join(", ")}`:"",...i.notes.map(r=>` note: ${r}`)].filter(Boolean));return[t,...n,...e.warnings.map(i=>`warning: ${i}`)].join(`
185
+ `)}var Uu=64;function mW(e,t,n){let i=Math.max(1,Math.round(Uu*n/t)),r=new Float32Array(Uu*i),o=new Uint32Array(Uu*i);for(let a=0;a<n;a++){let s=Math.min(i-1,Math.floor(a*i/n))*Uu;for(let c=0;c<t;c++){let l=(a*t+c)*4,u=s+Math.min(Uu-1,Math.floor(c*Uu/t));r[u]+=(e[l]+2*e[l+1]+e[l+2])/4,o[u]++}}for(let a=0;a<r.length;a++)r[a]/=o[a]||1;return r}var pW=async(e,t,n,i)=>{try{let r=0,o=0;await Pf(e,a=>{r=a.w,o=a.h},(a,s)=>i(a-t,mW(s,r,o)),{width:256,from:t,count:n})}catch(r){if(!/not installed|missing/.test(String(r)))throw r;let o=(await Rn(e)).streams?.find(a=>a.kind==="video");for(let a=0;a<n;a++){let s=await tl(e,t+a,o?.codec??"");i(a,mW(s.rgba,s.width,s.height))}}};function hW(e){let t=e.streams?.find(i=>i.kind==="video"),n=t?.codec_specific??{};return{codec:t?.codec,fourcc:n.fourcc,profile:n.profile,pixel_format:n.pixel_format,bit_depth:t?.bit_depth,raster:t?.width?`${t.width}x${t.height}`:void 0,fps:Math.round((e.source_fps??t?.rate??0)*1e3)/1e3,colour:n.colr?`${n.colr.primaries}/${n.colr.transfer}/${n.colr.matrix}`:void 0}}var Vie=async e=>Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",e)).slice(0,8),t=>t.toString(16).padStart(2,"0")).join("");async function E9(e,t,n){let i=[];return await Pf(e,()=>{},(r,o)=>{r>=t&&r<t+n&&(i[r-t]=Vie(o))},{from:t,count:n}),Promise.all(Array.from({length:n},(r,o)=>i[o]??Promise.resolve(void 0)))}async function jie(e){let t=Math.max(2,Math.round(e.fps*2)),n=[];for(let[i,r]of[["head",e.offset],["tail",e.offset+e.frames]]){let o=Math.max(0,r-t),a=Math.min(e.mframes,r+t),s=a-o;if(s<=0)continue;let c=await E9(e.master,o,s),l=Math.max(o,e.offset),u=Math.min(a,e.offset+e.frames),f=u>l?await E9(e.patch,l-e.offset,u-l):[],d=e.original?await E9(e.original,o,s):null,m=0,p=0,b=0,h=0;c.forEach((g,y)=>{let w=o+y;w>=l&&w<u?(p++,(!g||g!==f[w-l])&&m++):d&&(h++,(!g||g!==d[y])&&b++)});let v=c.filter(g=>!g).length;n.push({seam:i,tc:tn(e.master_tc+r,e.fps),frames:[o,a-1],inside:p?m?`${m}/${p} frames differ from the patch`:`${p} frames = the patch`:"\u2014",outside:d?b?`${b}/${h} frames differ from the original`:`${h} frames = the original`:"no original given (pass original= a backup to prove the neighbours)",undecoded:v,ok:!m&&!b&&!v})}return n}async function yW(e,t=pW,n){let[i,r]=await Promise.all([Rn(e.patch),Rn(e.master)]),o=hW(i),a=hW(r),s=Object.keys(o).map(x=>({field:x,patch:o[x],master:a[x],ok:o[x]===a[x]})),c=i.available_range?.duration.value??i.declared_duration?.value??0,l=r.available_range?.duration.value??r.declared_duration?.value??0,u=o.fps||a.fps,f=[];e.expected_frames!=null&&f.push({what:"frames",ok:c===e.expected_frames,detail:`${c} frames, expected ${e.expected_frames}`});let d=i.source_timecode??null,m=r.source_timecode??null;e.expected_tc&&f.push({what:"start TC",ok:d!=null&&Kn(d,u)===Kn(e.expected_tc,u),detail:`starts ${d??"with no TC"}, expected ${e.expected_tc}`});let p=i.streams?.filter(x=>x.kind==="audio").length??0;f.push({what:"picture only",ok:p===0,detail:p?`${p} audio track(s)`:"no audio"});let b=null,h=[],v=[],g=d?Kn(d,u):null,y=m?Kn(m,u):null;if(g==null||y==null)f.push({what:"position in master",ok:!1,detail:"no start TC on the patch or the master: cannot place it"});else if(g-y<0||g-y+c>l)f.push({what:"position in master",ok:!1,detail:`${d} + ${c} fr is outside the master (${m}, ${l} fr)`});else{b=g-y,f.push({what:"position in master",ok:!0,detail:`master frames ${b}\u2013${b+c-1}`});let x=[];await t(e.patch,0,c,(S,M)=>{x[S]=M,n?.(S+1,c*2,"decoding the patch")});let T=null,z=[];await t(e.master,b,c,(S,M)=>{let L=x[S];if(n?.(c+S+1,c*2,"comparing with the master"),!L){z.push(S);return}let P=0,X=0;for(let R=0;R<L.length;R++){let I=Math.abs(L[R]-M[R]);P+=I,I>X&&(X=I)}if(X>(e.tolerance??10)&&h.push({frame:S,tc:tn((g??0)+S,u),mean:Math.round(P/L.length*10)/10,max:Math.round(X)}),T){let R=0;for(let I=0;I<L.length;I++)R+=Math.abs(L[I]-T[I]);R/L.length>12&&v.push(tn((g??0)+S,u))}T=L});let k=c-x.filter(Boolean).length;k&&f.push({what:"decode",ok:!1,detail:`${k} patch frame(s) did not decode`}),f.push({what:"picture vs master",ok:!h.length,detail:h.length?`${h.length}/${c} frames differ (first ${h[0].tc})`:`all ${c} frames match at the same TC`})}let w;if(b!=null&&t===pW)try{w=await jie({master:e.master,patch:e.patch,original:e.original,offset:b,frames:c,mframes:l,fps:u,master_tc:y??0});let x=w.filter(T=>!T.ok);f.push({what:"seam decode",ok:!x.length,detail:x.length?x.map(T=>`${T.seam} ${T.tc}: ${[T.inside,T.outside,T.undecoded?`${T.undecoded} undecoded`:""].filter(Boolean).join("; ")}`).join(" | "):`${w.length} seam(s): every frame decodes and matches${e.original?"":" the patch (neighbours unchecked: no original)"}`})}catch(x){if(!/not installed|missing/.test(String(x)))throw x}return{ok:s.every(x=>x.ok)&&f.every(x=>x.ok),spec:s,frames:c,start_tc:d,master_offset:b,checks:f,mismatches:h,shot_changes:v,seams:w}}function wW(e,t){let n=[...e.spec.filter(i=>!i.ok).map(i=>i.field),...e.checks.filter(i=>!i.ok).map(i=>i.what)];return[`${e.ok?"PASS":"FAIL"}: ${ae(t.patch)} vs ${ae(t.master)}${n.length?` (${n.join(", ")})`:""}`,...e.spec.map(i=>` ${i.ok?"ok ":"DIFF"} ${i.field}: ${i.patch??"-"}${i.ok?"":` (master ${i.master??"-"})`}`),...e.checks.map(i=>` ${i.ok?"ok ":"FAIL"} ${i.what}: ${i.detail}`),...e.mismatches.slice(0,40).map(i=>` frame ${i.frame} @ ${i.tc}: mean diff ${i.mean}, max ${i.max}`),e.mismatches.length>40?` \u2026 ${e.mismatches.length-40} more`:"",e.shot_changes.length?` shot changes in the patch at ${e.shot_changes.join(", ")}`:"",...(e.seams??[]).map(i=>` seam ${i.seam} ${i.tc} (master frames ${i.frames[0]}\u2013${i.frames[1]}): ${i.ok?"ok":"FAIL"} \u2014 inside: ${i.inside}; outside: ${i.outside}${i.undecoded?`; ${i.undecoded} undecoded`:""}`)].filter(Boolean).join(`
186
+ `)}var zW=W4(P7(),1);function C9(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var Zie=ArrayBuffer,kr=Uint8Array,$g=Uint16Array,Iie=Int16Array;var ev=Int32Array,U9=function(e,t,n){if(kr.prototype.slice)return kr.prototype.slice.call(e,t,n);(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length);var i=new kr(n-t);return i.set(e.subarray(t,n)),i},jm=function(e,t,n,i){if(kr.prototype.fill)return kr.prototype.fill.call(e,t,n,i);for((n==null||n<0)&&(n=0),(i==null||i>e.length)&&(i=e.length);n<i;++n)e[n]=t;return e},Wie=function(e,t,n,i){if(kr.prototype.copyWithin)return kr.prototype.copyWithin.call(e,t,n,i);for((n==null||n<0)&&(n=0),(i==null||i>e.length)&&(i=e.length);n<i;)e[t++]=e[n++]};var Die=["invalid zstd data","window size too large (>2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],Lr=function(e,t,n){var i=new Error(t||Die[e]);if(i.code=e,Error.captureStackTrace&&Error.captureStackTrace(i,Lr),!n)throw i;return i},xW=function(e,t,n){for(var i=0,r=0;i<n;++i)r|=e[t++]<<(i<<3);return r},qie=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Hie=function(e,t){var n=e[0]|e[1]<<8|e[2]<<16;if(n==3126568&&e[3]==253){var i=e[4],r=i>>5&1,o=i>>2&1,a=i&3,s=i>>6;i&8&&Lr(0);var c=6-r,l=a==3?4:a,u=xW(e,c,l);c+=l;var f=s?1<<s:r,d=xW(e,c,f)+(s==1&&256),m=d;if(!r){var p=1<<10+(e[5]>>3);m=p+(p>>3)*(e[5]&7)}m>2145386496&&Lr(1);var b=new kr((t==1?d||m:t?0:m)+12);return b[0]=1,b[4]=4,b[8]=8,{b:c+f,y:0,l:0,d:u,w:t&&t!=1?t:b.subarray(12),e:m,o:new ev(b.buffer,0,3),u:d,c:o,m:Math.min(131072,m)}}else if((n>>4|e[3]<<20)==25481893)return qie(e,4)+8;Lr(0)},Vc=function(e){for(var t=0;1<<t<=e;++t);return t-1},Zm=function(e,t,n){var i=(t<<3)+4,r=(e[t]&15)+5;r>n&&Lr(3);for(var o=1<<r,a=o,s=-1,c=-1,l=-1,u=o,f=new Zie(512+(o<<2)),d=new Iie(f,0,256),m=new $g(f,0,256),p=new $g(f,512,o),b=512+(o<<1),h=new kr(f,b,o),v=new kr(f,b+o);s<255&&a>0;){var g=Vc(a+1),y=i>>3,w=(1<<g+1)-1,x=(e[y]|e[y+1]<<8|e[y+2]<<16)>>(i&7)&w,T=(1<<g)-1,z=w-a-1,k=x&T;if(k<z?(i+=g,x=k):(i+=g+1,x>T&&(x-=z)),d[++s]=--x,x==-1?(a+=x,h[--u]=s):a-=x,!x)do{var S=i>>3;c=(e[S]|e[S+1]<<8)>>(i&7)&3,i+=2,s+=c}while(c==3)}(s>255||a)&&Lr(0);for(var M=0,L=(o>>1)+(o>>3)+3,P=o-1,X=0;X<=s;++X){var R=d[X];if(R<1){m[X]=-R;continue}for(l=0;l<R;++l){h[M]=X;do M=M+L&P;while(M>=u)}}for(M&&Lr(0),l=0;l<o;++l){var I=m[h[l]]++,q=v[l]=r-Vc(I);p[l]=(I<<q)-o}return[i+7>>3,{b:r,s:h,n:v,t:p}]},Eie=function(e,t){var n=0,i=-1,r=new kr(292),o=e[t],a=r.subarray(0,256),s=r.subarray(256,268),c=new $g(r.buffer,268);if(o<128){var l=Zm(e,t+1,6),u=l[0],f=l[1];t+=o;var d=u<<3,m=e[t];m||Lr(0);for(var p=0,b=0,h=f.b,v=h,g=(++t<<3)-8+Vc(m);g-=h,!(g<d);){var y=g>>3;if(p+=(e[y]|e[y+1]<<8)>>(g&7)&(1<<h)-1,a[++i]=f.s[p],g-=v,g<d)break;y=g>>3,b+=(e[y]|e[y+1]<<8)>>(g&7)&(1<<v)-1,a[++i]=f.s[b],h=f.n[p],p=f.t[p],v=f.n[b],b=f.t[b]}++i>255&&Lr(0)}else{for(i=o-127;n<i;n+=2){var w=e[++t];a[n]=w>>4,a[n+1]=w&15}++t}var x=0;for(n=0;n<i;++n){var T=a[n];T>11&&Lr(0),x+=T&&1<<T-1}var z=Vc(x)+1,k=1<<z,S=k-x;for(S&S-1&&Lr(0),a[i++]=Vc(S)+1,n=0;n<i;++n){var T=a[n];++s[a[n]=T&&z+1-T]}var M=new kr(k<<1),L=M.subarray(0,k),P=M.subarray(k);for(c[z]=0,n=z;n>0;--n){var X=c[n];jm(P,n,X,c[n-1]=X+s[n]*(1<<z-n))}for(c[0]!=k&&Lr(0),n=0;n<i;++n){var R=a[n];if(R){var I=c[R];jm(L,n,I,c[R]=I+(1<<z-R))}}return[t,{n:P,b:z,s:L}]},Cie=Zm(new kr([81,16,99,140,49,198,24,99,12,33,196,24,99,102,102,134,70,146,4]),0,6)[1],Uie=Zm(new kr([33,20,196,24,99,140,33,132,16,66,8,33,132,16,66,8,33,68,68,68,68,68,68,68,68,36,9]),0,6)[1],Aie=Zm(new kr([32,132,16,66,102,70,68,68,68,68,36,73,2]),0,5)[1],PW=function(e,t){for(var n=e.length,i=new ev(n),r=0;r<n;++r)i[r]=t,t+=1<<e[r];return i},A9=new kr(new ev([0,0,0,0,16843009,50528770,134678020,202050057,269422093]).buffer,0,36),Gie=PW(A9,0),G9=new kr(new ev([0,0,0,0,0,0,0,0,16843009,50528770,117769220,185207048,252579084,16]).buffer,0,53),Jie=PW(G9,3),Vm=function(e,t,n){var i=e.length,r=t.length,o=e[i-1],a=(1<<n.b)-1,s=-n.b;o||Lr(0);for(var c=0,l=n.b,u=(i<<3)-8+Vc(o)-l,f=-1;u>s&&f<r;){var d=u>>3,m=(e[d]|e[d+1]<<8|e[d+2]<<16)>>(u&7);c=(c<<l|m)&a,t[++f]=n.s[c],u-=l=n.n[c]}(u!=s||f+1!=r)&&Lr(0)},Bie=function(e,t,n){var i=6,r=t.length,o=r+3>>2,a=o<<1,s=o+a;Vm(e.subarray(i,i+=e[0]|e[1]<<8),t.subarray(0,o),n),Vm(e.subarray(i,i+=e[2]|e[3]<<8),t.subarray(o,a),n),Vm(e.subarray(i,i+=e[4]|e[5]<<8),t.subarray(a,s),n),Vm(e.subarray(i),t.subarray(s),n)},Yie=function(e,t,n){var i,r=t.b,o=e[r],a=o>>1&3;t.l=o&1;var s=o>>3|e[r+1]<<5|e[r+2]<<13,c=(r+=3)+s;if(a==1)return r>=e.length?void 0:(t.b=r+1,n?(jm(n,e[r],t.y,t.y+=s),n):jm(new kr(s),e[r]));if(!(c>e.length)){if(a==0)return t.b=c,n?(n.set(e.subarray(r,c),t.y),t.y+=s,n):U9(e,r,c);if(a==2){var l=e[r],u=l&3,f=l>>2&3,d=l>>4,m=0,p=0;u<2?f&1?d|=e[++r]<<4|(f&2&&e[++r]<<12):d=l>>3:(p=f,f<2?(d|=(e[++r]&63)<<4,m=e[r]>>6|e[++r]<<2):f==2?(d|=e[++r]<<4|(e[++r]&3)<<12,m=e[r]>>2|e[++r]<<6):(d|=e[++r]<<4|(e[++r]&63)<<12,m=e[r]>>6|e[++r]<<2|e[++r]<<10)),++r;var b=n?n.subarray(t.y,t.y+t.m):new kr(t.m),h=b.length-d;if(u==0)b.set(e.subarray(r,r+=d),h);else if(u==1)jm(b,e[r++],h);else{var v=t.h;if(u==2){var g=Eie(e,r);m+=r-(r=g[0]),t.h=v=g[1]}else v||Lr(0);(p?Bie:Vm)(e.subarray(r,r+=m),b.subarray(h),v)}var y=e[r++];if(y){y==255?y=(e[r++]|e[r++]<<8)+32512:y>127&&(y=y-128<<8|e[r++]);var w=e[r++];w&3&&Lr(0);for(var x=[Uie,Aie,Cie],T=2;T>-1;--T){var z=w>>(T<<1)+2&3;if(z==1){var k=new kr([0,0,e[r++]]);x[T]={s:k.subarray(2,3),n:k.subarray(0,1),t:new $g(k.buffer,0,1),b:0}}else z==2?(i=Zm(e,r,9-(T&1)),r=i[0],x[T]=i[1]):z==3&&(t.t||Lr(0),x[T]=t.t[T])}var S=t.t=x,M=S[0],L=S[1],P=S[2],X=e[c-1];X||Lr(0);var R=(c<<3)-8+Vc(X)-P.b,I=R>>3,q=0,Y=(e[I]|e[I+1]<<8)>>(R&7)&(1<<P.b)-1;I=(R-=L.b)>>3;var D=(e[I]|e[I+1]<<8)>>(R&7)&(1<<L.b)-1;I=(R-=M.b)>>3;var j=(e[I]|e[I+1]<<8)>>(R&7)&(1<<M.b)-1;for(++y;--y;){var C=P.s[Y],H=P.n[Y],ne=M.s[j],le=M.n[j],Se=L.s[D],Le=L.n[D];I=(R-=Se)>>3;var ut=1<<Se,we=ut+((e[I]|e[I+1]<<8|e[I+2]<<16|e[I+3]<<24)>>>(R&7)&ut-1);I=(R-=G9[ne])>>3;var De=Jie[ne]+((e[I]|e[I+1]<<8|e[I+2]<<16)>>(R&7)&(1<<G9[ne])-1);I=(R-=A9[C])>>3;var Je=Gie[C]+((e[I]|e[I+1]<<8|e[I+2]<<16)>>(R&7)&(1<<A9[C])-1);if(I=(R-=H)>>3,Y=P.t[Y]+((e[I]|e[I+1]<<8)>>(R&7)&(1<<H)-1),I=(R-=le)>>3,j=M.t[j]+((e[I]|e[I+1]<<8)>>(R&7)&(1<<le)-1),I=(R-=Le)>>3,D=L.t[D]+((e[I]|e[I+1]<<8)>>(R&7)&(1<<Le)-1),we>3)t.o[2]=t.o[1],t.o[1]=t.o[0],t.o[0]=we-=3;else{var be=we-(Je!=0);be?(we=be==3?t.o[0]-1:t.o[be],be>1&&(t.o[2]=t.o[1]),t.o[1]=t.o[0],t.o[0]=we):we=t.o[0]}for(var T=0;T<Je;++T)b[q+T]=b[h+T];q+=Je,h+=Je;var Me=q-we;if(Me<0){var Oe=-Me,bt=t.e+Me;Oe>De&&(Oe=De);for(var T=0;T<Oe;++T)b[q+T]=t.w[bt+T];q+=Oe,De-=Oe,Me=0}for(var T=0;T<De;++T)b[q+T]=b[Me+T];q+=De}if(q!=h)for(;h<b.length;)b[q++]=b[h++];else q=b.length;n?t.y+=q:b=U9(b,0,q)}else if(n){if(t.y+=d,h)for(var T=0;T<d;++T)b[T]=b[h+T]}else h&&(b=U9(b,h));return t.b=c,b}Lr(2)}},Kie=function(e,t){if(e.length==1)return e[0];for(var n=new kr(t),i=0,r=0;i<e.length;++i){var o=e[i];n.set(o,r),r+=o.length}return n};function SW(e,t){for(var n=[],i=+!t,r=0,o=0;e.length;){var a=Hie(e,i||t);if(typeof a=="object"){for(i?(t=null,a.w.length==a.u&&(n.push(t=a.w),o+=a.u)):(n.push(t),a.e=0);!a.l;){var s=Yie(e,a,t);s||Lr(5),t?a.e=a.y:(n.push(s),o+=s.length,Wie(a.w,0,s.length),a.w.set(s,a.w.length-s.length))}r=a.b+a.c*4}else r=a;e=e.subarray(r)}return Kie(n,o)}var kW={classes:{SM_Project:{order:["FieldsBlob","LockId","User","Folder","UserId","SysId","ProjectId","UpToDate","OrigProjUpToDate","RevivalTaskSetID","PlayHeadsSplitDisplay","LastModTimeInSecs","UpgradeLockSysId","ProjectAgeInMs","ProjectName","FolderMap","TimelineVec","TimelineHandleVec","CurrentTimelineIndex","StreamCursorVector","StreamIdVector","StreamPlayHeadVector","StreamAdvanceVector","GangPlayHeadVector","NumTotalStreams","NumPlayStreams","CurrentStreamId","PlayingStreamId","PlayHeadMode","CommonConfig","DeletedSsnList","IsADeliverableProject","DeliverableProjectEDLStr","DeliverableSessionName","NumReader","ClipInfoSeed","ReelSeed","EDLSeed","RenderTextEnabled","RenderTextGanged","RenderTextPrefixed","activeStereoLeftSession","activeStereoRightSession","IsAutoSave","ProjRef","Thumbnails","MediaPool","ProjectVersion","GroupList","GroupListObj","IsLiveCollaborationEnabled","LockableBlobMap","PowerNodeList","Notes","FaceTaggingClipVec","FaceTaggingPeopleVec"],props:{FieldsBlob:{kind:"scalar"},LockId:{kind:"empty",values:{"":1}},User:{kind:"ref"},Folder:{kind:"empty",values:{"":1}},UserId:{kind:"scalar",values:{"-1":1}},SysId:{kind:"scalar",values:{F4D48876E6E2:1}},ProjectId:{kind:"scalar",values:{"0":1}},UpToDate:{kind:"scalar",values:{true:1}},OrigProjUpToDate:{kind:"scalar",values:{true:1}},RevivalTaskSetID:{kind:"scalar",values:{"-1":1}},PlayHeadsSplitDisplay:{kind:"scalar",values:{false:1}},LastModTimeInSecs:{kind:"scalar",values:{"0":1}},UpgradeLockSysId:{kind:"empty",values:{"":1}},ProjectAgeInMs:{kind:"scalar"},ProjectName:{kind:"scalar"},FolderMap:{kind:"empty",values:{"":1}},TimelineVec:{kind:"empty",values:{"":1}},TimelineHandleVec:{kind:"refvec"},CurrentTimelineIndex:{kind:"scalar",values:{"0":1}},StreamCursorVector:{kind:"scalarvec"},StreamIdVector:{kind:"scalarvec"},StreamPlayHeadVector:{kind:"scalarvec"},StreamAdvanceVector:{kind:"scalarvec"},GangPlayHeadVector:{kind:"scalarvec"},NumTotalStreams:{kind:"scalar",values:{"1":1}},NumPlayStreams:{kind:"scalar",values:{"1":1}},CurrentStreamId:{kind:"scalar",values:{"0":1}},PlayingStreamId:{kind:"scalar",values:{"0":1}},PlayHeadMode:{kind:"scalar"},CommonConfig:{kind:"inline"},DeletedSsnList:{kind:"empty",values:{"":1}},IsADeliverableProject:{kind:"scalar",values:{false:1}},DeliverableProjectEDLStr:{kind:"empty",values:{"":1}},DeliverableSessionName:{kind:"empty",values:{"":1}},NumReader:{kind:"scalar",values:{"0":1}},ClipInfoSeed:{kind:"scalar",values:{"0":1}},ReelSeed:{kind:"scalar",values:{"0":1}},EDLSeed:{kind:"scalar",values:{"0":1}},RenderTextEnabled:{kind:"scalar",values:{true:1}},RenderTextGanged:{kind:"scalar",values:{true:1}},RenderTextPrefixed:{kind:"scalar",values:{true:1}},activeStereoLeftSession:{kind:"empty",values:{"":1}},activeStereoRightSession:{kind:"empty",values:{"":1}},IsAutoSave:{kind:"scalar",values:{false:1}},ProjRef:{kind:"empty",values:{"":1}},Thumbnails:{kind:"empty",values:{"":1}},MediaPool:{kind:"inline"},ProjectVersion:{kind:"scalar",values:{"17":1}},GroupList:{kind:"empty",values:{"":1}},GroupListObj:{kind:"inline"},IsLiveCollaborationEnabled:{kind:"scalar",values:{false:1}},LockableBlobMap:{kind:"inline"},PowerNodeList:{kind:"inline"},Notes:{kind:"empty",values:{"":1}},FaceTaggingClipVec:{kind:"empty",values:{"":1}},FaceTaggingPeopleVec:{kind:"empty",values:{"":1}}}},SM_Config:{order:["FieldsBlob","User","ConfigId","UserId","ProjId","SsnId","Name","LockSysId","DbSavedTime","MultiSysData"],props:{FieldsBlob:{kind:"scalar"},User:{kind:"empty",values:{"":1}},ConfigId:{kind:"scalar",values:{"0":1}},UserId:{kind:"scalar",values:{"0":1}},ProjId:{kind:"scalar",values:{"0":1}},SsnId:{kind:"scalar",values:{"0":1}},Name:{kind:"scalar",values:{"260903_CONNIE_SCOTT.Cfg":1}},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}},MultiSysData:{kind:"inline"}}},Sm2MultiSysData:{order:["FieldsBlob","LockSysId","DbSavedTime"],props:{FieldsBlob:{kind:"scalar",values:{"00000001000000010000000c0044006100740061004200410000000c0000000037000000010000002f8012280000000100000001000000180046003400440034003800380037003600450036004500320000000020013000":1}},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2MediaPool:{order:["FieldsBlob","SmartFolderVec","StereoSource"],props:{FieldsBlob:{kind:"scalar"},SmartFolderVec:{kind:"empty",values:{"":1}},StereoSource:{kind:"scalar",values:{"2":1}}}},Sm2GroupList:{order:["FieldsBlob","GroupList","LockSysId","DbSavedTime"],props:{FieldsBlob:{kind:"empty",values:{"":1}},GroupList:{kind:"vec"},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2LockableBlobMap:{order:["FieldsBlob","LocableBlobSet"],props:{FieldsBlob:{kind:"empty",values:{"":1}},LocableBlobSet:{kind:"vec"}}},Sm2MediaPoolLockableBlob:{order:["FieldsBlob","BlobOwner","DbSavedTime"],props:{FieldsBlob:{kind:"empty",values:{"":1}},BlobOwner:{kind:"ref"},DbSavedTime:{kind:"scalar",values:{"0":1}}}},"ListMgt::LmPowerNodeList":{order:["FieldsBlob","PowerNodes","LockSysId","DbSavedTime"],props:{FieldsBlob:{kind:"empty",values:{"":1}},PowerNodes:{kind:"empty",values:{"":1}},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2MpFolder:{order:["FieldsBlob","Name","UniqueMediaPoolItemId","MediaVec","MediaPool","Folded","ColorTag","LockSysId","DbSavedTime"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Name:{kind:"scalar",values:{Master:1}},UniqueMediaPoolItemId:{kind:"ref"},MediaVec:{kind:"vec"},MediaPool:{kind:"ref"},Folded:{kind:"scalar",values:{true:1}},ColorTag:{kind:"scalar",values:{FOLDER_COLOR_NONE:1}},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2MpTimelineClip:{order:["FieldsBlob","Name","MpFolder","UniqueMediaPoolItemId","MarkIn","MarkInVideo","MarkInAudio","MarkOut","MarkOutVideo","MarkOutAudio","CurPlayheadPosition","PinsBA","VirtualAudioTracksBA","MatteVec","AudioSource","PTZRPreset","PTZRPresetType","SlateTC","TimelineSharedHandle","VideoMetadata","MediaMetadata"],props:{FieldsBlob:{kind:"scalar"},Name:{kind:"scalar"},MpFolder:{kind:"ref"},UniqueMediaPoolItemId:{kind:"ref"},MarkIn:{kind:"empty",values:{"":1}},MarkInVideo:{kind:"empty",values:{"":1}},MarkInAudio:{kind:"empty",values:{"":1}},MarkOut:{kind:"empty",values:{"":1}},MarkOutVideo:{kind:"empty",values:{"":1}},MarkOutAudio:{kind:"empty",values:{"":1}},CurPlayheadPosition:{kind:"scalar"},PinsBA:{kind:"empty",values:{"":1}},VirtualAudioTracksBA:{kind:"empty",values:{"":1}},MatteVec:{kind:"empty",values:{"":1}},AudioSource:{kind:"scalar",values:{AUDIO_SOURCE_EMBEDDED:1}},PTZRPreset:{kind:"inline"},PTZRPresetType:{kind:"scalar",values:{"0":1}},SlateTC:{kind:"scalar"},TimelineSharedHandle:{kind:"inline"},VideoMetadata:{kind:"scalar"},MediaMetadata:{kind:"empty",values:{"":1}}}},SmPTZRPreset:{order:["FieldsBlob","Name","ID","IsCustom","Producer","Presets"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Name:{kind:"empty",values:{"":1}},ID:{kind:"scalar",values:{"100":1}},IsCustom:{kind:"scalar",values:{true:1}},Producer:{kind:"scalar",values:{"Producer@Resolve":1}},Presets:{kind:"scalar",values:{"7b7d":1}}}},Sm2Timeline:{order:["FieldsBlob","Name","MpTimelineClip","Sequence","OfflineFrameOffset","PTZRPresetType","VideoStereoSource","Type","ImportExportMetadataBA","EnableLTC","LTCSyncDelay","EnableAudio","AudioSyncDelay","ModTimeInSecs","CreateTimeInSecs"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Name:{kind:"scalar"},MpTimelineClip:{kind:"ref"},Sequence:{kind:"inline"},OfflineFrameOffset:{kind:"scalar",values:{"0":1}},PTZRPresetType:{kind:"scalar",values:{"0":1}},VideoStereoSource:{kind:"scalar",values:{"0":1}},Type:{kind:"scalar",values:{"0":1}},ImportExportMetadataBA:{kind:"scalar"},EnableLTC:{kind:"scalar",values:{false:1}},LTCSyncDelay:{kind:"scalar",values:{"0":1}},EnableAudio:{kind:"scalar",values:{false:1}},AudioSyncDelay:{kind:"scalar",values:{"0":1}},ModTimeInSecs:{kind:"scalar",values:{"1790712446":1}},CreateTimeInSecs:{kind:"scalar",values:{"1790712446":1}}}},Sm2Sequence:{order:["FieldsBlob","UniqueSequenceId","MediaExtents","FrameRate","Resolution","VideoTrackVec","AudioTrackVec","Parent","pLmVerTable","LastChangedTime","RenderCacheBA","AuxRenderCacheBA","UIElementsState","NumOutputAudioChannels","OutputAudioGain","PinsBA","ImportExportMetadataBA","LockSysId","DbSavedTime"],props:{FieldsBlob:{kind:"scalar"},UniqueSequenceId:{kind:"ref"},MediaExtents:{kind:"scalar"},FrameRate:{kind:"scalar",values:{"872211b5dcf937400000000000000000":1}},Resolution:{kind:"scalar"},VideoTrackVec:{kind:"empty",values:{"":1}},AudioTrackVec:{kind:"empty",values:{"":1}},Parent:{kind:"ref"},pLmVerTable:{kind:"inline"},LastChangedTime:{kind:"scalar",values:{"0":1}},RenderCacheBA:{kind:"scalar"},AuxRenderCacheBA:{kind:"scalar"},UIElementsState:{kind:"scalar"},NumOutputAudioChannels:{kind:"scalar",values:{"2":1}},OutputAudioGain:{kind:"scalar",values:{"0":1}},PinsBA:{kind:"empty",values:{"":1}},ImportExportMetadataBA:{kind:"scalar"},LockSysId:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar"}}},"ListMgt::LmVersionTable":{order:["FieldsBlob","VerType","pActive","Locals","DbSavedTime","pRemoteTable","LinkedGroup"],props:{FieldsBlob:{kind:"scalar"},VerType:{kind:"scalar"},pActive:{kind:"ref"},Locals:{kind:"vec"},DbSavedTime:{kind:"scalar"},pRemoteTable:{kind:"ref"},LinkedGroup:{kind:"ref"}}},"ListMgt::LmVersion":{order:["FieldsBlob","Name","HasCorrection","VerType","ImplVersion","IncludedInRecording","FlatPassEnabled","RGBAOutputEnabled","Body","UseVersionClipProcParams"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Name:{kind:"scalar"},HasCorrection:{kind:"scalar"},VerType:{kind:"scalar"},ImplVersion:{kind:"scalar",values:{"1":1}},IncludedInRecording:{kind:"scalar",values:{true:1}},FlatPassEnabled:{kind:"scalar",values:{false:1}},RGBAOutputEnabled:{kind:"scalar",values:{false:1}},Body:{kind:"scalar"},UseVersionClipProcParams:{kind:"scalar"}}},Sm2MpVideoClip:{order:["FieldsBlob","Name","MpFolder","UniqueMediaPoolItemId","MarkIn","MarkInVideo","MarkInAudio","MarkOut","MarkOutVideo","MarkOutAudio","CurPlayheadPosition","pLmVerTable","PinsBA","VirtualAudioTracksBA","MatteVec","AudioSource","PTZRPreset","PTZRPresetType","SlateTC","Video","EmbeddedAudioVec"],props:{FieldsBlob:{kind:"scalar"},Name:{kind:"scalar"},MpFolder:{kind:"ref"},UniqueMediaPoolItemId:{kind:"ref"},MarkIn:{kind:"empty",values:{"":1}},MarkInVideo:{kind:"empty",values:{"":1}},MarkInAudio:{kind:"empty",values:{"":1}},MarkOut:{kind:"empty",values:{"":1}},MarkOutVideo:{kind:"empty",values:{"":1}},MarkOutAudio:{kind:"empty",values:{"":1}},CurPlayheadPosition:{kind:"scalar"},pLmVerTable:{kind:"inline"},PinsBA:{kind:"empty",values:{"":1}},VirtualAudioTracksBA:{kind:"empty",values:{"":1}},MatteVec:{kind:"empty",values:{"":1}},AudioSource:{kind:"scalar",values:{AUDIO_SOURCE_EMBEDDED:1}},PTZRPreset:{kind:"inline"},PTZRPresetType:{kind:"scalar",values:{"0":1}},SlateTC:{kind:"scalar"},Video:{kind:"inline"},EmbeddedAudioVec:{kind:"vec"}}},BtVideoInfo:{order:["FieldsBlob","Clip","Time","Geometry","Radiometry","Proxy","VideoMetadata","MediaMetadata","Type","Eye"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Clip:{kind:"scalar"},Time:{kind:"scalar"},Geometry:{kind:"scalar"},Radiometry:{kind:"scalar"},Proxy:{kind:"scalar"},VideoMetadata:{kind:"scalar"},MediaMetadata:{kind:"empty",values:{"":1}},Type:{kind:"scalar",values:{STANDARD_CLIP:1}},Eye:{kind:"scalar",values:{SUB_TRACK_MONO:1}}}},BtAudioInfo:{order:["FieldsBlob","Clip","TracksBA","MediaMetadata"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Clip:{kind:"scalar"},TracksBA:{kind:"scalar"},MediaMetadata:{kind:"empty",values:{"":1}}}},Sm2SequenceContainer:{order:["FieldsBlob","VideoTrackVec","AudioTrackVec","SubtitleTrackVec","GeometryTrackVec","DbSavedTime"],props:{FieldsBlob:{kind:"empty",values:{"":1}},VideoTrackVec:{kind:"vec"},AudioTrackVec:{kind:"vec"},SubtitleTrackVec:{kind:"empty",values:{"":1}},GeometryTrackVec:{kind:"empty",values:{"":1}},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2TiTrack:{order:["FieldsBlob","Type","SubType","Flags","Sequence","Items","FusionCompHolderItems","UserDefinedName","LayersVec"],props:{FieldsBlob:{kind:"scalar"},Type:{kind:"scalar"},SubType:{kind:"scalar"},Flags:{kind:"scalar"},Sequence:{kind:"ref"},Items:{kind:"vec"},FusionCompHolderItems:{kind:"empty",values:{"":1}},UserDefinedName:{kind:"empty",values:{"":1}},LayersVec:{kind:"empty",values:{"":1}}}},Sm2TiVideoClip:{order:["FieldsBlob","PrettyType","Name","Start","Duration","LinkedItemSync","WasDisbanded","MarkersBA","UiMemento","Flags","PriorityIndex","EffectFiltersBA","ImportExportMetadataBA","RenderTextEnabled","RenderTextGanged","RenderTextPrefixed","In","MixedFrameRateAlignment","MediaRef","MediaStartTime","MediaFilePath","MediaReelNumber","MediaFrameRate","MediaTimemapBA","LastChangedTime","LastRenderedTime","IsMarkedForCaching","IsForceConformed","MatchConflictState","UseOppositeSrcForLeftEye","UseOppositeSrcForRightEye","RenderCacheBA","CurrentSelectorIdx","IsPreConformed","PreConformMediaExtents","MediaMetadata","Thumbnail","ThumbnailDirtyFlag","CompositionTable","pLmVerTable"],props:{FieldsBlob:{kind:"scalar"},PrettyType:{kind:"scalar"},Name:{kind:"scalar"},Start:{kind:"scalar"},Duration:{kind:"scalar"},LinkedItemSync:{kind:"scalar"},WasDisbanded:{kind:"scalar",values:{false:1}},MarkersBA:{kind:"empty",values:{"":1}},UiMemento:{kind:"scalar",values:{"0":1}},Flags:{kind:"scalar"},PriorityIndex:{kind:"scalar",values:{"0":1}},EffectFiltersBA:{kind:"scalar"},ImportExportMetadataBA:{kind:"empty",values:{"":1}},RenderTextEnabled:{kind:"scalar"},RenderTextGanged:{kind:"scalar"},RenderTextPrefixed:{kind:"scalar"},In:{kind:"scalar"},MixedFrameRateAlignment:{kind:"scalar",values:{"0":1}},MediaRef:{kind:"ref"},MediaStartTime:{kind:"scalar"},MediaFilePath:{kind:"scalar"},MediaReelNumber:{kind:"scalar"},MediaFrameRate:{kind:"scalar"},MediaTimemapBA:{kind:"scalar"},LastChangedTime:{kind:"scalar",values:{"0":1}},LastRenderedTime:{kind:"scalar",values:{"0":1}},IsMarkedForCaching:{kind:"scalar",values:{false:1}},IsForceConformed:{kind:"scalar",values:{true:1}},MatchConflictState:{kind:"scalar",values:{"0":1}},UseOppositeSrcForLeftEye:{kind:"scalar",values:{false:1}},UseOppositeSrcForRightEye:{kind:"scalar",values:{false:1}},RenderCacheBA:{kind:"empty",values:{"":1}},CurrentSelectorIdx:{kind:"scalar"},IsPreConformed:{kind:"scalar",values:{false:1}},PreConformMediaExtents:{kind:"scalar"},MediaMetadata:{kind:"empty",values:{"":1}},Thumbnail:{kind:"inline"},ThumbnailDirtyFlag:{kind:"scalar",values:{true:1}},CompositionTable:{kind:"inline"},pLmVerTable:{kind:"inline"}}},BtThumnail:{order:["FieldsBlob","ImgWidth","ImgHeight","Buffer"],props:{FieldsBlob:{kind:"empty",values:{"":1}},ImgWidth:{kind:"scalar",values:{"-1":1}},ImgHeight:{kind:"scalar",values:{"-1":1}},Buffer:{kind:"empty",values:{"":1}}}},Sm2TiGenerator:{order:["FieldsBlob","PrettyType","Name","Start","Duration","LinkedItemSync","WasDisbanded","MarkersBA","UiMemento","Flags","PriorityIndex","EffectFiltersBA","ImportExportMetadataBA","RenderTextEnabled","RenderTextGanged","RenderTextPrefixed","In"],props:{FieldsBlob:{kind:"scalar"},PrettyType:{kind:"scalar"},Name:{kind:"scalar"},Start:{kind:"scalar"},Duration:{kind:"scalar"},LinkedItemSync:{kind:"empty",values:{"":1}},WasDisbanded:{kind:"scalar",values:{false:1}},MarkersBA:{kind:"empty",values:{"":1}},UiMemento:{kind:"scalar",values:{"0":1}},Flags:{kind:"scalar",values:{"0":1}},PriorityIndex:{kind:"scalar",values:{"0":1}},EffectFiltersBA:{kind:"scalar"},ImportExportMetadataBA:{kind:"empty",values:{"":1}},RenderTextEnabled:{kind:"scalar",values:{true:1}},RenderTextGanged:{kind:"scalar",values:{true:1}},RenderTextPrefixed:{kind:"scalar",values:{true:1}},In:{kind:"empty",values:{"":1}}}},BtMetadataLockableBlob:{order:["FieldsBlob","BlobOwner","DbSavedTime"],props:{FieldsBlob:{kind:"scalar",values:{"0000000100000001000000100042006c006f006200440061007400610000000c000000003e0000271100000036801233000f42410000002b121c08d7011217535452454e4754485f544f5f574f524b5f76342e776176120508a6031200120408101200":1}},BlobOwner:{kind:"ref"},DbSavedTime:{kind:"scalar",values:{"0":1}}}},Sm2MpAudioClip:{order:["FieldsBlob","Name","MpFolder","UniqueMediaPoolItemId","MarkIn","MarkInVideo","MarkInAudio","MarkOut","MarkOutVideo","MarkOutAudio","CurPlayheadPosition","PinsBA","VirtualAudioTracksBA","EmbeddedAudioVec"],props:{FieldsBlob:{kind:"scalar",values:{"00000002000001358128b52ffd602d0155090006923937404dd51c0fe966933d866178c09f07f3c95a791d455b2452e697a8d636adb733f7a55c19cc047efbcf7cf7c3d82ac7ba1af1ce8f90bd53320024002600a0938cbf153dd40a388013d507bcd2aace48a1a051b1d83a2cb82c481246a20b249146fa6810429e9156a140c4c0a321e211a9a7134afef117751b5afa7235ec8c7cd320c008c907139f4372d84d7dbb173db7a7dc37d952ca2df6927bbdc4bc7e307c4790102dad5b082a0739166648dd9a764e0eda49e1811b6edf1b0d8a1224082400e170442cd36ec5f7c1ee2927a442bdc88d90b5e466b098252e338ba5cc32f85e2935b10119009d975800b2042b4b5cc818b6241a56e06297b24c06a289619853d0585b42e341decb18010cd6c9a6f519af9103086d949f6294de56113286cbd666a63f7364":1}},Name:{kind:"scalar",values:{"STRENGTH_TO_WORK_v4.wav":1}},MpFolder:{kind:"ref"},UniqueMediaPoolItemId:{kind:"ref"},MarkIn:{kind:"empty",values:{"":1}},MarkInVideo:{kind:"empty",values:{"":1}},MarkInAudio:{kind:"empty",values:{"":1}},MarkOut:{kind:"empty",values:{"":1}},MarkOutVideo:{kind:"empty",values:{"":1}},MarkOutAudio:{kind:"empty",values:{"":1}},CurPlayheadPosition:{kind:"scalar",values:{"0":1}},PinsBA:{kind:"empty",values:{"":1}},VirtualAudioTracksBA:{kind:"empty",values:{"":1}},EmbeddedAudioVec:{kind:"vec"}}},Sm2TiAudioClip:{order:["FieldsBlob","PrettyType","Name","Start","Duration","LinkedItemSync","WasDisbanded","MarkersBA","UiMemento","Flags","PriorityIndex","EffectFiltersBA","ImportExportMetadataBA","RenderTextEnabled","RenderTextGanged","RenderTextPrefixed","In","MixedFrameRateAlignment","MediaRef","MediaStartTime","MediaFilePath","MediaReelNumber","MediaFrameRate","MediaTimemapBA","LastChangedTime","LastRenderedTime","IsMarkedForCaching","IsForceConformed","MatchConflictState","UseOppositeSrcForLeftEye","UseOppositeSrcForRightEye","RenderCacheBA","VirtualAudioTrackBA","MediaTrackIdx"],props:{FieldsBlob:{kind:"scalar"},PrettyType:{kind:"empty",values:{"":1}},Name:{kind:"scalar"},Start:{kind:"scalar"},Duration:{kind:"scalar"},LinkedItemSync:{kind:"scalar"},WasDisbanded:{kind:"scalar",values:{false:1}},MarkersBA:{kind:"empty",values:{"":1}},UiMemento:{kind:"scalar",values:{"0":1}},Flags:{kind:"scalar",values:{"0":1}},PriorityIndex:{kind:"scalar",values:{"0":1}},EffectFiltersBA:{kind:"empty",values:{"":1}},ImportExportMetadataBA:{kind:"empty",values:{"":1}},RenderTextEnabled:{kind:"scalar",values:{false:1}},RenderTextGanged:{kind:"scalar",values:{false:1}},RenderTextPrefixed:{kind:"scalar",values:{false:1}},In:{kind:"empty",values:{"":1}},MixedFrameRateAlignment:{kind:"scalar",values:{"0":1}},MediaRef:{kind:"ref"},MediaStartTime:{kind:"scalar"},MediaFilePath:{kind:"scalar"},MediaReelNumber:{kind:"scalar"},MediaFrameRate:{kind:"scalar",values:{"872211b5dcf937400000000000000000":1}},MediaTimemapBA:{kind:"scalar"},LastChangedTime:{kind:"scalar",values:{"0":1}},LastRenderedTime:{kind:"scalar",values:{"0":1}},IsMarkedForCaching:{kind:"scalar",values:{false:1}},IsForceConformed:{kind:"scalar",values:{true:1}},MatchConflictState:{kind:"scalar",values:{"0":1}},UseOppositeSrcForLeftEye:{kind:"scalar",values:{false:1}},UseOppositeSrcForRightEye:{kind:"scalar",values:{false:1}},RenderCacheBA:{kind:"empty",values:{"":1}},VirtualAudioTrackBA:{kind:"scalar",values:{"000000010000000200000014004300680061006e006e0065006c0073004200410000000c000000001000000002000000020000400100004002000000120041007500640069006f0054007900700065000000020000000000":1}},MediaTrackIdx:{kind:"scalar",values:{"0":1}}}},Sm2TiCompositionTable:{order:["FieldsBlob","DbSavedTime","CompositionBA","ActiveCompositionIdx"],props:{FieldsBlob:{kind:"scalar"},DbSavedTime:{kind:"scalar",values:{"0":1}},CompositionBA:{kind:"scalar"},ActiveCompositionIdx:{kind:"scalar",values:{"0":1}}}},Sm2TiTransition:{order:["FieldsBlob","PrettyType","Name","Start","Duration","LinkedItemSync","WasDisbanded","MarkersBA","UiMemento","Flags","PriorityIndex","EffectFiltersBA","ImportExportMetadataBA","RenderTextEnabled","RenderTextGanged","RenderTextPrefixed","AlignmentType","Position"],props:{FieldsBlob:{kind:"scalar",values:{"000000020000001b800a04a801940312120000002c789c636660642016000000da0005":1}},PrettyType:{kind:"scalar",values:{"Cross Dissolve":1}},Name:{kind:"scalar",values:{Transition:1}},Start:{kind:"scalar",values:{"404":1}},Duration:{kind:"scalar",values:{"8":1}},LinkedItemSync:{kind:"empty",values:{"":1}},WasDisbanded:{kind:"scalar",values:{false:1}},MarkersBA:{kind:"empty",values:{"":1}},UiMemento:{kind:"scalar",values:{"0":1}},Flags:{kind:"scalar",values:{"0":1}},PriorityIndex:{kind:"scalar",values:{"0":1}},EffectFiltersBA:{kind:"scalar",values:{"000000020000003a800a37081238024a004a004a004a004a29088b015224ffffffe00000000000000c0000000000000000000800000000000c00000000000000f03f":1}},ImportExportMetadataBA:{kind:"empty",values:{"":1}},RenderTextEnabled:{kind:"scalar",values:{true:1}},RenderTextGanged:{kind:"scalar",values:{true:1}},RenderTextPrefixed:{kind:"scalar",values:{true:1}},AlignmentType:{kind:"scalar",values:{"2":1}},Position:{kind:"scalar",values:{"2":1}}}},Sm2Group:{order:["FieldsBlob","Name","pLmVerTable"],props:{FieldsBlob:{kind:"empty",values:{"":1}},Name:{kind:"scalar",values:{"GROUP - 01":1}},pLmVerTable:{kind:"inline"}}},Sm2MpCompoundClip:{order:["FieldsBlob","Name","MpFolder","UniqueMediaPoolItemId","MarkIn","MarkInVideo","MarkInAudio","MarkOut","MarkOutVideo","MarkOutAudio","CurPlayheadPosition","PinsBA","VirtualAudioTracksBA","MatteVec","AudioSource","PTZRPreset","PTZRPresetType","SlateTC","Sequence","VideoMetadata","MediaMetadata"],props:{FieldsBlob:{kind:"scalar"},Name:{kind:"scalar"},MpFolder:{kind:"ref"},UniqueMediaPoolItemId:{kind:"ref"},MarkIn:{kind:"empty",values:{"":1}},MarkInVideo:{kind:"empty",values:{"":1}},MarkInAudio:{kind:"empty",values:{"":1}},MarkOut:{kind:"empty",values:{"":1}},MarkOutVideo:{kind:"empty",values:{"":1}},MarkOutAudio:{kind:"empty",values:{"":1}},CurPlayheadPosition:{kind:"scalar",values:{"0":1}},PinsBA:{kind:"empty",values:{"":1}},VirtualAudioTracksBA:{kind:"empty",values:{"":1}},MatteVec:{kind:"empty",values:{"":1}},AudioSource:{kind:"scalar",values:{AUDIO_SOURCE_EMBEDDED:1}},PTZRPreset:{kind:"inline"},PTZRPresetType:{kind:"scalar",values:{"0":1}},SlateTC:{kind:"scalar"},Sequence:{kind:"inline"},VideoMetadata:{kind:"scalar"},MediaMetadata:{kind:"empty",values:{"":1}}}}}};var _ie="000000000000000300000000000000000000000000000000000000000000006400000000000000060000000000000f000000000000000870000000000000000000000000000000000000803f00000000000000170000000000000000ffffffffffffffff0000000000000001fffffffffffffffe0000000000000001000000000000000000000000000000c40000000000000005000000000000002c00000000000000040000000000000001000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000f000000000000000870000000000000000000000000000000000000803fffffffffffffffff00000000000000000000000000000221000000000000000000000000000000000000000000000000000000000000000000000000000000000000003f0000003f000000000000003b1800200e280140a001486872134e6f204f7574707574205472616e73666f726d880102e80101a00200b00208c80200e00228e80202800304a00301",J9=e=>Uint8Array.from(e.match(/../g)??[],t=>parseInt(t,16)),$ie=e=>[...e].map(t=>t.toString(16).padStart(2,"0")).join(""),MW=e=>[...e].map(t=>t.charCodeAt(0).toString(16).padStart(4,"0")).join("");function eoe(e,t,n,i){let r=J9(_ie),o=new DataView(r.buffer);return o.setInt32(40,0),o.setInt32(44,e),o.setInt32(48,0),o.setInt32(52,t),o.setInt32(80,Math.floor(n)),o.setInt32(88,i?1:0),o.setInt32(232,e),o.setInt32(240,t),r}function toe(e,t,n){let i=e&&e.length>=16?e:"0000000100000000",r=parseInt(i.slice(8,16),16)+1,o=s=>s.toString(16).padStart(8,"0"),a=MW(t);return i.slice(0,8)+o(r)+o(a.length/2)+a+"0000000c00"+o(n.length)+$ie(n)+i.slice(16)}function noe(e){let t=J9(e),n=-1;for(let u=0;u+4<=t.length;u++)if(t[u]===40&&t[u+1]===181&&t[u+2]===47&&t[u+3]===253){n=u;break}if(n<0)return null;let i;try{i=SW(t.subarray(n))}catch{return null}let r={},o="",a=0,s=()=>{let u=0,f=0;for(;;){let d=i[a++];if(u+=(d&127)*2**f,f+=7,!(d&128))return u}};for(;a<i.length;){let u=s(),f=Math.floor(u/8),d=u%8;if(d===0)r[f]=s();else if(d===1)a+=8;else if(d===5)a+=4;else if(d===2){let m=s();f===1&&(o=new TextDecoder().decode(i.subarray(a,a+m))),a+=m}else break}let c=u=>u%2?-(u+1)/2:u/2;if(r[2]&&r[3])return{w:c(r[2]),h:c(r[3])};let l=/(\d+)\s*x\s*(\d+)/.exec(o);return l?{w:+l[1],h:+l[2]}:null}function roe(e){let t=J9(e);return t.length<8?{fps:24,df:!1}:{fps:new DataView(t.buffer).getFloat64(0,!0),df:t.length>=16&&t[15]===1}}var ioe=kW.classes,TW=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,tv=class e{constructor(t,n){this.path=t;this.copy=n;this.cols=new Map;this.rows=new Map;this.idTable=null;this.links=null;this.tables=null;this.mediaRefs=new Set;this.sequences=new Set;this.visited=new Set}static async open(t){let n=await ii("conform-resolve-db-"),i=_(n,"Project.db");await Mv(t,i);for(let r of["-wal","-shm"])await Nn(t+r)&&await Mv(t+r,i+r);return new e(t,i)}async q(t){let n=await Mn("sqlite3",["-readonly","-json",this.copy,t]);if(!n.success)throw new Error(`sqlite3: ${n.stderr.trim()||n.stdout.trim()}`);return n.stdout.trim()?JSON.parse(n.stdout):[]}async tableNames(){return this.tables??=(await this.q("select name from sqlite_master where type='table' order by name")).map(t=>t.name)}async columns(t){let n=this.cols.get(t);return n||(n=(await this.q(`pragma table_info("${t}")`)).map(i=>({name:i.name,type:i.type})),this.cols.set(t,n)),n}async table(t){let n=this.rows.get(t);if(n)return n;let r=(await this.columns(t)).map(o=>`case when typeof("${o.name}")='blob' then lower(hex("${o.name}")) else "${o.name}" end as "${o.name}"`).join(", ");n=new Map;for(let o of await this.q(`select ${r} from "${t}"`))n.set(String(o[`${t}_id`]),o);return this.rows.set(t,n),n}async objectTables(){let t=[];for(let n of await this.tableNames())(await this.columns(n))[0]?.name===`${n}_id`&&t.push(n);return t}async tableOf(t){if(!this.idTable){let i=(await this.objectTables()).map(r=>`select '${r}' as t, "${r}_id" as id from "${r}"`).join(" union all ");this.idTable=new Map;for(let r of await this.q(i))this.idTable.set(r.id,r.t)}return this.idTable.get(t)}async linkRows(t,n){if(!this.links){this.links=new Map;let i=[];for(let o of await this.tableNames()){let a=await this.columns(o);["DbOwner","DbAssociate","DbPropertyName","DbIndex"].every(s=>a.some(c=>c.name===s))&&i.push(o)}let r=i.map(o=>`select DbOwner o, DbAssociate a, DbPropertyName p, DbIndex i from "${o}"`).join(" union all ");for(let o of await this.q(r)){let a=`${o.o}|${o.p}`,s=this.links.get(a)??[];s.push({idx:o.i,assoc:o.a}),this.links.set(a,s)}for(let o of this.links.values())o.sort((a,s)=>a.idx-s.idx)}return this.links.get(`${t}|${n}`)??[]}async object(t){let n=await this.tableOf(t);if(!n)return null;let i=(await this.table(n)).get(t);return i?{table:n,row:i}:null}async facts(){let t=(await this.q("select CurrentTimelineIndex from SM_Project limit 1"))[0],n=Number(t?.CurrentTimelineIndex??-1),r=(await this.q(`select t.Sm2Timeline_id id, t.Name name, t.ModTimeInSecs mod, l.DbIndex idx from Sm2Timeline t
187
+ left join SM_Project_Sm2Timeline l on l.DbAssociate = t.Sm2Timeline_id order by l.DbIndex`)).map(o=>({id:o.id,name:o.name,modified_at:o.mod?new Date(o.mod*1e3).toISOString():null,is_current:o.idx===n}));return{project:ae(Yn(this.path)),db_path:this.path,timelines:r,current:r.find(o=>o.is_current)??null}}scalar(t,n){return t==null?"":/bool/i.test(n)?t?"true":"false":typeof t=="number"?(Number.isInteger(t),String(t)):C9(String(t))}async serialize(t,n,i={}){let r=await this.object(t);if(!r)return"";let o=String(r.row.DbType??r.table),a=await this.columns(r.table),s=new Map(a.map(f=>[f.name,f.type])),c=ioe[o]??this.fallbackSchema(r.table,a,r.row);this.visited.add(t),o==="Sm2Sequence"&&this.sequences.add(t);let l=[`${n}<${o} DbId="${t}">`],u=n+" ";for(let f of c.order){let d=c.props[f];if(f in i){let b=i[f];l.push(b===null?`${u}<${f}/>`:b);continue}let m=s.has(f),p=r.row[f];switch(d.kind){case"scalar":case"empty":{let b=m?this.scalar(p,s.get(f)):Object.keys(d.values??{})[0]??"";l.push(b===""?`${u}<${f}/>`:`${u}<${f}>${b}</${f}>`);break}case"ref":{let b=m&&p?String(p):"";b&&/^Sm2Ti/.test(o)&&/^Sm2Mp/.test(await this.tableOf(b)??"")&&this.mediaRefs.add(b),l.push(b?`${u}<${f}>${b}</${f}>`:`${u}<${f}/>`);break}case"inline":{let b=m&&p&&TW.test(String(p))?String(p):"";b||(b=(await this.linkRows(t,f))[0]?.assoc??""),b||(b=await this.inlineByBackRef(o,f,t));let h=b&&!this.visited.has(b)?await this.serialize(b,u+" "):"";l.push(h?`${u}<${f}>
188
+ ${h}
189
+ ${u}</${f}>`:`${u}<${f}/>`);break}case"vec":case"refvec":{let b=await this.linkRows(t,f);if(!b.length){l.push(`${u}<${f}/>`);break}l.push(`${u}<${f}>`);for(let{assoc:h}of b){if(d.kind==="refvec"){l.push(`${u} <Element>${h}</Element>`);continue}if(this.visited.has(h))continue;let v=await this.serialize(h,u+" ");v&&l.push(`${u} <Element>
190
+ ${v}
191
+ ${u} </Element>`)}l.push(`${u}</${f}>`);break}default:l.push(`${u}<${f}/>`)}}return l.push(`${n}</${o}>`),l.join(`
192
+ `)}async inlineByBackRef(t,n,i){let o={"SM_Project.CommonConfig":["SM_Config","SM_Project_id"],"SM_Project.MediaPool":["Sm2MediaPool","SM_Project_id"],"Sm2Timeline.Sequence":["Sm2Sequence","Parent"]}[`${t}.${n}`];if(!o)return"";let[a,s]=o;if(!(await this.tableNames()).includes(a))return"";if(!(await this.columns(a)).some(l=>l.name===s)){let l=(await this.table(a)).keys().next();return l.done?"":l.value}for(let[l,u]of await this.table(a))if(String(u[s])===i)return l;return""}fallbackSchema(t,n,i){let r=["FieldsBlob",...n.map(a=>a.name).filter(a=>a!==`${t}_id`&&a!=="DbType"&&a!=="FieldsBlob")],o={};for(let a of r)o[a]={kind:TW.test(String(i[a]??""))?"ref":"scalar"};return{order:r,props:o}}async ensureSequenceSetup(t){let n=(await this.table("Sm2Sequence")).get(t);if(!n)return;let i=String(n.FieldsBlob??"");if(i.includes(MW("SequenceSetup")))return;let r=[...(await this.table("SM_Config")).values()][0],o=r?noe(String(r.FieldsBlob??"")):null;if(!o)return;let{fps:a,df:s}=roe(String(n.FrameRate??""));n.FieldsBlob=toe(i,"SequenceSetup",eoe(o.w,o.h,a,s))}async exportDrt(t,n,i="21.0.0"){let r=await this.object(t);if(!r||r.table!=="Sm2Timeline")throw new Error(`no timeline ${t} in ${this.path}`);let o=`<?xml version="1.0" encoding="UTF-8"?>
193
+ <!--DbAppVer="${i}" DbPrjVer="${(await this.q("select ProjectVersion v from SM_Project limit 1"))[0]?.v??17}"-->
194
+ `;this.visited.clear(),this.mediaRefs.clear(),this.sequences.clear();let a=async g=>(await this.q(`select Sm2SequenceContainer_id id from Sm2SequenceContainer where Sm2Sequence_id='${g}'`))[0]?.id,s=String(r.row.Sequence??await this.inlineByBackRef("Sm2Timeline","Sequence",t));await this.ensureSequenceSetup(s),this.sequences.add(s);let c=new Map,l=[],u=new Set,f=String(r.row.MpTimelineClip??"");for(f&&(l.push(await this.serialize(f," ")),u.add(f));;){let g=!1;for(let y of[...this.sequences]){let w=await a(y);if(!w){if(y===s)throw new Error(`timeline ${t}: no sequence container for sequence ${y}`);continue}c.has(w)||(c.set(w,o+await this.serialize(w,"")),g=!0)}for(let y of[...this.mediaRefs]){if(u.has(y)||this.visited.has(y))continue;u.add(y);let w=await this.serialize(y," ");w&&l.push(w),g=!0}if(!g)break}let d=[...(await this.table("Sm2MpFolder")).entries()].find(([,g])=>g.Name==="Master")??[...(await this.table("Sm2MpFolder")).entries()][0],m=l.length?` <MediaVec>
195
+ ${l.map(g=>` <Element>
196
+ ${g.replace(/^/gm," ")}
197
+ </Element>`).join(`
198
+ `)}
199
+ </MediaVec>`:" <MediaVec/>",p=o+(d?await this.serialize(d[0],"",{MediaVec:m}):""),b=(await this.q("select SM_Project_id id from SM_Project limit 1"))[0]?.id,h=o+(b?await this.serialize(b,"",{TimelineHandleVec:` <TimelineHandleVec>
200
+ <Element>${t}</Element>
201
+ </TimelineHandleVec>`,CurrentTimelineIndex:" <CurrentTimelineIndex>0</CurrentTimelineIndex>",ProjectName:` <ProjectName>${C9(String(r.row.Name??""))}</ProjectName>`}):""),v=new zW.default;v.file("project.xml",h);for(let[g,y]of c)v.file(`SeqContainer/${g}.xml`,y);return v.file("MediaPool/Master/MpFolder.xml",p),await or(n,await v.generateAsync({type:"uint8array",compression:"DEFLATE"})),n}};var ooe="7145B29C33684D8AA1C7E5126F9B405D",Oa="conform.tools.dvcp.bundle",aoe="https://raw.githubusercontent.com/tbdpost/conformtools-public/main/plugin/manifest.json";function LW(e=xr()){return e==="win32"?{system:`${Ut("PROGRAMDATA")??"C:\\ProgramData"}\\Blackmagic Design\\DaVinci Resolve\\Support\\IOPlugins`,user:`${Ut("APPDATA")??""}\\Blackmagic Design\\DaVinci Resolve\\Support\\IOPlugins`}:e==="linux"?{system:"/opt/resolve/IOPlugins",user:_(tf(),".local/share/DaVinciResolve/IOPlugins")}:{system:"/Library/Application Support/Blackmagic Design/DaVinci Resolve/IOPlugins",user:_(tf(),"Library/Application Support/Blackmagic Design/DaVinci Resolve/IOPlugins")}}function soe(e=xr()){return e==="win32"?`${Ut("APPDATA")??""}\\Blackmagic Design\\DaVinci Resolve\\Support\\logs\\ResolveDebug.txt`:e==="linux"?_(tf(),".local/share/DaVinciResolve/logs/ResolveDebug.txt"):_(tf(),"Library/Application Support/Blackmagic Design/DaVinci Resolve/logs/ResolveDebug.txt")}function XW(e=xr(),t=ef()){return e==="darwin"?{key:"darwin-universal",binary:"Contents/MacOS/conform.tools.dvcp"}:e==="linux"&&/x86_64|x64/.test(t)?{key:"linux-x86_64",binary:"Contents/Linux-x86-64/conform.tools.dvcp"}:e==="win32"?{key:"windows-x86_64",binary:"Contents/Win64/conform.tools.dvcp"}:null}async function OW(e){let t=_(e,"Contents/Resources/VERSION");if(await Ar(t))return(await Tn(t)).trim()||null;let n=_(e,"Contents/Info.plist");return await Ar(n)?/<key>CFBundleShortVersionString<\/key>\s*<string>([^<]+)</.exec(await Tn(n))?.[1]??null:null}function coe(e,t){let n=e.split(`
202
+ `),i=n.find(s=>s.includes("Running DaVinci Resolve"));if(!i)return null;let r=/(\d{4}-\d{2}-\d{2}) (\d{2}:\d{2}:\d{2}),(\d{3})/.exec(i);if(!r)return null;let o=new Date(`${r[1]}T${r[2]}.${r[3]}`),a=n.some(s=>/plugin repository/i.test(s)&&s.toUpperCase().includes(`LOADED PLUGIN [${ooe}]`));return{launched_at:o.toISOString(),loaded:a,installed_after_launch:t!==void 0&&t>o.getTime()}}async function Au(e=xr()){let t=XW(e),n=LW(e),i=_(n.system,Oa),r=t?await Wi(i)&&await Nn(_(i,t.binary)):!1,o=r?await OW(i):null,a=_(n.user,Oa),s=await Wi(a)?{path:a,version:await OW(a)}:void 0,c=null;try{let f=r&&t?(await cn(_(i,t.binary))).mtimeMs:void 0;c=coe(await Tn(soe(e)),f)}catch{}let l=t?r?c?c.loaded&&!c.installed_after_launch?"ready":"needs-restart":"unknown":"plugin-missing":"unsupported-platform",u={ready:"The plugin is installed and loaded.","plugin-missing":s?`Only a per-user copy exists (${a}); Resolve loads I/O plugins only from ${n.system}. Install it with host_setup action=install_renderplugin.`:"Install it with host_setup action=install_renderplugin, then restart Resolve.","needs-restart":"Restart Resolve: it loads I/O plugins only at launch.","unsupported-platform":"There is no build of the plugin for this platform.",unknown:"Start Resolve once so its log says whether it loaded the plugin."}[l];return{platform:t?.key??null,installed:r,path:i,version:o,...s?{shadowed:s}:{},resolve:c,readiness:l,next:u}}async function NW(){for(let e of["./presets/conform.tools.xml","./resolve-presets/conform.tools.xml"]){let t=Fr(new URL(e,import.meta.url));if(await Ar(t))return t}throw new Error("resolve: the conform.tools render preset is missing from this install")}async function loe(e){let t=new Uint8Array(await crypto.subtle.digest("SHA-256",e));return Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}async function RW(e,t=3){for await(let n of zn(e)){if(!n.isDirectory)continue;let i=_(e,n.name);if(n.name===Oa)return i;if(t>0&&!n.name.startsWith("__MACOSX")){let r=await RW(i,t-1);if(r)return r}}return null}var uoe=async e=>{let t=await fetch(e,{signal:AbortSignal.timeout(12e4)});if(!t.ok)throw new Error(`download failed: ${e} answered ${t.status}`);return new Uint8Array(await t.arrayBuffer())};async function FW(e={}){let t=e.os??xr(),n=XW(t);if(!n)throw new Error("there is no build of the plugin for this platform");let i=e.fetcher??uoe,r=JSON.parse(new TextDecoder().decode(await i(e.manifest_url??aoe))),o=r.platforms?.[n.key]??(t==="darwin"&&r.bundle_url?{bundle_url:r.bundle_url,sha256:r.sha256??""}:void 0);if(!o)throw new Error(`plugin ${r.version} has no ${n.key} build`);let a=await i(o.bundle_url),s=await loe(a);if(s!==o.sha256.toLowerCase())throw new Error(`the downloaded plugin failed its checksum (got ${s}, the manifest says ${o.sha256}); nothing was installed`);let c=await ii("conform-plugin-"),l=_(c,"plugin.zip");await or(l,a);let u=_(c,"x");await vt(u);let f=t==="darwin"?await Mn("ditto",["-x","-k",l,u]):t==="win32"?await Mn("powershell",["-NoProfile","-Command",`Expand-Archive -LiteralPath '${l}' -DestinationPath '${u}' -Force`]):await Mn("unzip",["-q",l,"-d",u]);if(!f.success)throw new Error(`could not unpack the plugin: ${f.stderr.trim()}`);let d=await RW(u);if(!d||!await Nn(_(d,n.binary)))throw new Error(`the ${n.key} download does not contain ${n.binary}`);let m=e.targetDir??LW(t).system,p=_(m,Oa),b=_(m,`.${Oa}.staging`),h=_(m,`.${Oa}.previous`),v=[],g=!1;try{await vt(m),await Ti(b),await $m(d,b),await Ti(h),await Nn(p)&&await Gr(p,h);try{await Gr(b,p)}catch(y){throw await Nn(h)&&await Gr(h,p),y}await Ti(h)}catch(y){let w=y.code;if(w!=="EACCES"&&w!=="EPERM")throw y;g=!0,await foe(t,d,m)}return t==="darwin"&&((await Mn(g?"osascript":"xattr",g?["-e",`do shell script "xattr -dr com.apple.quarantine ${Si(p)}" with administrator privileges`]:["-dr","com.apple.quarantine",p])).success||v.push("could not clear the quarantine flag; if Resolve refuses the plugin, run: xattr -dr com.apple.quarantine "+p)),await Ti(c),{version:r.version,path:p,elevated:g,restart_required:!0,notes:v}}var Si=e=>`'${e.replace(/'/g,"'\\''")}'`;async function foe(e,t,n){let i=_(n,Oa),r=_(n,`.${Oa}.staging`),o=_(n,`.${Oa}.previous`),a=[`mkdir -p ${Si(n)}`,`rm -rf ${Si(r)} ${Si(o)}`,`cp -R ${Si(t)} ${Si(r)}`,`if [ -e ${Si(i)} ]; then mv ${Si(i)} ${Si(o)}; fi`,`mv ${Si(r)} ${Si(i)} || { [ -e ${Si(o)} ] && mv ${Si(o)} ${Si(i)}; exit 1; }`,`rm -rf ${Si(o)}`].join(" && "),s=e==="darwin"?await Mn("osascript",["-e",`do shell script ${JSON.stringify(a)} with administrator privileges`]):e==="linux"?await Mn("pkexec",["sh","-c",a]):{success:!1,stderr:"run this from an administrator prompt",stdout:"",code:1};if(!s.success)throw new Error(`installing into ${n} needs an administrator, and that was refused or failed: ${s.stderr.trim()}`)}function B9(e=xr()){if(e==="win32"){let t=Ut("PROGRAMDATA")??"C:\\ProgramData",n=Ut("PROGRAMFILES")??"C:\\Program Files";return{api:`${t}\\Blackmagic Design\\DaVinci Resolve\\Support\\Developer\\Scripting`,lib:`${n}\\Blackmagic Design\\DaVinci Resolve\\fusionscript.dll`}}return e==="linux"?{api:"/opt/resolve/Developer/Scripting",lib:"/opt/resolve/libs/Fusion/fusionscript.so"}:{api:"/Library/Application Support/Blackmagic Design/DaVinci Resolve/Developer/Scripting",lib:"/Applications/DaVinci Resolve/DaVinci Resolve.app/Contents/Libraries/Fusion/fusionscript.so"}}async function doe(e){let t=Ut("RESOLVE_SCRIPT_LIB");if(t)return t;if(e==="darwin"){let i=(await Mn("ps",["-axo","comm="])).stdout.split(`
203
+ `).map(r=>r.trim()).find(r=>/\/Contents\/MacOS\/Resolve$/.test(r));if(i){let r=i.replace(/\/MacOS\/Resolve$/,"/Libraries/Fusion/fusionscript.so");if(await Nn(r))return r}}return B9(e).lib}async function moe(){for(let e of["./bridge.py","./resolve-bridge.py"]){let t=Fr(new URL(e,import.meta.url));if(await Ar(t))return t}throw new Error("resolve: bridge.py is missing from this install")}var jc=async(e,t,n)=>{let i=xr(),{api:r}=B9(i),o=Ut("CONFORM_PYTHON")??(i==="win32"?"python":"python3"),a=await Mn(o,[await moe(),e,JSON.stringify(t)],{env:{RESOLVE_SCRIPT_API:Ut("RESOLVE_SCRIPT_API")??r,RESOLVE_SCRIPT_LIB:await doe(i),PYTHONPATH:_(Ut("RESOLVE_SCRIPT_API")??r,"Modules")},timeoutMs:n}),s=a.stdout.trim().split(`
204
+ `).pop()??"";try{return JSON.parse(s)}catch{return{ok:!1,why:"bridge",detail:a.code==="ENOENT"?`${o} is not installed (Resolve's scripting needs Python 3)`:a.stderr.trim().split(`
205
+ `).pop()||`no answer from Resolve within ${Math.round(n/1e3)} s`}}},Im=class extends Error{constructor(n,i){super(i);this.why=n}},poe={module:"Install DaVinci Resolve (its scripting module ships with it).",no_connection:"Start Resolve and set Preferences > System > General > External scripting using: Local (Resolve Studio).",no_project:"Open a project in Resolve."},nv=class{constructor(t=jc){this.runner=t;this.host="resolve";this.restore=new Map;this.startNotes=new Map}async call(t,n={},i=6e4){let r=await this.runner(t,n,i);if(r.ok)return r;throw r.why==="resolve_error"&&/NoneType' object is not callable/.test(String(r.detail))&&!(await this.runner("version",{},1e4)).ok?new Im("host_quit",`resolve: Resolve stopped responding during ${t} (it may have quit; see its log, ResolveDebug.txt). Restart Resolve and try again.`):new Im(r.why??"unknown",`resolve: ${r.detail||r.why}`)}async support(){let t=await this.runner("version",{},15e3),n=t.ok?t.product==="DaVinci Resolve Studio"?{ok:!0}:{ok:!1,reason:`${t.product} has no external scripting (Resolve Studio has)`}:{ok:!1,reason:t.detail??String(t.why),setup:poe[t.why??""]},i=n;if(n.ok){let r=await Au();i=r.readiness==="ready"||r.readiness==="unknown"?{ok:!0}:{ok:!1,reason:`renderplugin: ${r.readiness}`,setup:r.next}}return{export:n,open:n,render:n,markers:n,renderplugin:i}}async current(){return await this.call("current")}async project(t){return await this.call("project",t,12e4)}async presets(t){return await this.call("presets",t,12e4)}async presetAuthor(t){return await this.call("preset_author",t,6e4)}async export(t){if(!t.out_path)throw new Im("usage","resolve: export needs out_path");let n=await this.call("export",{timeline:t.timeline,out_path:t.out_path});return{path:String(n.path),format:"drt",project:String(n.project),timeline:String(n.timeline)}}async open(t){let n=await this.call("open",{path:t.path,into:t.into??"current",name:t.name,media_dir:t.media_dirs?.[0],stay:t.stay??!1,folder:t.folder,create_folder:t.create_folder??!1,link_existing:t.link_existing??!1},3e5),i=[...n.notes??[]];return(t.media_dirs?.length??0)>1&&i.push(`Resolve searches one media folder per import; used ${t.media_dirs[0]}`),{project:String(n.project),timeline:String(n.timeline),notes:i,restored:!!n.restored,...n.folder?{folder:String(n.folder)}:{}}}async renderStart(t){let n=await this.call("render_start",{...t}),i=String(n.job_id);this.restore.set(i,n.restore);let r=n.rejected_settings??[];return r.length&&this.startNotes.set(i,[`Resolve refused render setting(s) ${r.join(", ")} for this format; the rest were applied`]),{job_id:i,state:"queued",percent:0}}async renderStatus(t){let n=await this.call("render_status",{job_id:t},15e3),i={job_id:t,state:n.state,percent:Number(n.percent??0)};if(n.error&&(i.error=String(n.error)),i.state==="complete"||i.state==="failed"){let r=await this.call("render_finish",{job_id:t,restore:this.restore.get(t)});this.restore.delete(t),r.output&&(i.outputs=[String(r.output)]);let o=[...this.startNotes.get(t)??[],...r.tracks?[VW(r)]:[]];this.startNotes.delete(t),o.length&&(i.notes=o)}return i}async renderCancel(t){let n=await this.call("render_cancel",{job_id:t,restore:this.restore.get(t)});return this.restore.delete(t),{job_id:t,state:"cancelled",percent:0,...n.output?{outputs:[String(n.output)]}:{},...n.tracks?{notes:[VW(n)]}:{}}}},VW=e=>{let t=e.tracks.map(n=>`V${n}`).join(", ");return e.tracks_restored?`video track(s) ${t} switched back on`:`could NOT switch video track(s) ${t} back on: re-enable them on the Edit page`};async function jW(e,t){let n=[];for await(let i of zn(e))i.isFile&&i.name.startsWith(t)&&n.push(_(e,i.name));return n.sort()}import{gunzipSync as hoe}from"node:zlib";var La=["resolve","premiere","avid","flame","fcp"];function ZW(e,t){if(!t.tracks?.length)return;let n=e.timelines.find(i=>i.name===t.timeline)??e.timelines[0];if(n)for(let i of["video","audio"]){let r=n.tracks.filter(o=>(o.kind??"").toLowerCase()===i).sort((o,a)=>(o.track_index??0)-(a.track_index??0));for(let o of t.tracks.filter(a=>a.kind===i)){let a=r[o.index-1];a&&(a.enabled=o.enabled,o.name&&!/^(Video|Audio) \d+$/.test(o.name)&&(a.name=o.name))}}}async function boe(){return(await Mn("ps",["-axo","pid=,args="])).stdout.split(`
206
+ `).map(t=>t.trim()).filter(Boolean).map(t=>{let n=t.indexOf(" ");return{pid:Number(t.slice(0,n)),args:t.slice(n+1)}})}async function goe(){let e=`ObjC.import("CoreGraphics");
207
+ const a = $.CGWindowListCopyWindowInfo($.kCGWindowListOptionAll, 0);
208
+ const arr = ObjC.deepUnwrap(ObjC.castRefToObject(a)) || [];
209
+ JSON.stringify(arr.filter(w => w.kCGWindowName).map(w => ({ pid: w.kCGWindowOwnerPID, owner: w.kCGWindowOwnerName, title: w.kCGWindowName })));`;if(xr()!=="darwin")return[];let t=await Mn("osascript",["-l","JavaScript","-e",e]);try{return JSON.parse(t.stdout.trim())}catch{return[]}}async function K9(e){return(await Mn("lsof",["-p",String(e),"-Fn"])).stdout.split(`
210
+ `).filter(n=>n.startsWith("n/")).map(n=>n.slice(1))}var Y9=e=>new Date(e).toISOString();async function voe(e,t){let n=e.find(l=>/DaVinci Resolve\.app\/Contents\/MacOS\/Resolve(\s|$)/.test(l.args)),i={host:"resolve",running:!!n,pid:n?.pid,notes:[]};if(!n)return i;let r=(await K9(n.pid)).find(l=>/\/Project\.db$/.test(l));if(!r)return woe(n.pid,i,t);i.project_path=r;let o=await tv.open(r),a=await o.facts();if(i.project=a.project,i.timelines=a.timelines.map(l=>l.name),!a.current)return i.notes.push("no timeline is open in the viewer"),i;i.timeline=a.current.name;let s=_(t,`${rv(a.project)}__${rv(a.current.name)}.drt`);await o.exportDrt(a.current.id,s),i.read={path:s,format:"drt"},i.notes.push("built from the project database Resolve autosaves (the live state, minus edits of the last few seconds)");let c=await jc("current",{},15e3);return c.ok&&c.timeline===i.timeline&&(i.tracks=c.tracks),i}async function yoe(e){let n=(await Mn("lsof",["-a","-p",String(e),"-i","TCP","-P","-n","-Fn"])).stdout.split(`
211
+ `).filter(i=>i.startsWith("n")&&i.includes("->")).map(i=>i.slice(i.indexOf("->")+2));return[...new Set(n.filter(i=>/:5432$/.test(i)))]}async function woe(e,t,n){let i=await yoe(e),r=_(n,`resolve_current_${Date.now()}.drt`),o=await jc("current",{},6e4),a;o.why!=="bridge"&&(a=o,o.ok&&o.timeline&&(a.exported=(await jc("export",{out_path:r},6e4)).ok));let s=i.length?`a PostgreSQL project library (${i.join(", ")})`:"no Project.db on disk";if(!a)return t.notes.push(`Resolve holds ${s}, and its scripting door could not be reached (${o.detail??"no answer"}). Export the timeline as a .drt from Resolve (File > Export > Timeline) and read that file.`),t;if(a.db?.DbType?t.project_path=`${a.db.DbType.toLowerCase()}://${a.db.IpAddress??i[0]??""}/${a.db.DbName??""}`:i.length&&(t.project_path=`postgresql://${i[0]}`),!a.ok){let l=a.why==="no_project"?"no project is open (only the Project Manager)":a.why==="no_connection"?"Resolve refused the local scripting connection (Preferences > System > General > External scripting using: Local)":`the Resolve scripting module is not installed (${a.detail??""})`;return t.notes.push(`Resolve holds ${s}; ${l}.`),t}if(t.project=a.project,t.timelines=a.timelines,!a.timeline)return t.notes.push("no timeline is open in the viewer"),t;if(t.timeline=a.timeline,o.ok&&(t.tracks=o.tracks),!a.exported||!await Nn(r))return t.notes.push(`Resolve holds ${s}; it named the open timeline but its .drt export failed. Export it from Resolve (File > Export > Timeline) and read that file.`),t;let c=_(n,`${rv(a.project??"resolve")}__${rv(a.timeline)}.drt`);return await Gr(r,c),t.read={path:c,format:"drt"},t.notes.push(`project in ${s}: the timeline was exported by Resolve itself (its own .drt of the current state, including unsaved edits)`),t}async function xoe(e,t){let n=e.find(u=>/Adobe Premiere Pro( \d{4})?\.app\/Contents\/MacOS\/Adobe Premiere Pro/.test(u.args)),i={host:"premiere",running:!!n,pid:n?.pid,notes:[]};if(!n)return i;let r=t.find(u=>u.pid===n.pid&&/\.prproj/i.test(u.title))?.title;if(!r)return i.notes.push("Premiere is running with no project window (home screen), or the window title carries no project path."),i;let o=r.replace(/\s*\*\s*$/,"").replace(/^.*?(\/.*\.prproj).*$/i,"$1");if(!await Nn(o))return i.notes.push(`window title names ${o} but it is not on disk`),i;i.project_path=o,i.project=ae(o).replace(/\.prproj$/i,""),i.read={path:o,format:"prproj"},await Nn(o.replace(/\.prproj$/i,".prlock"))&&i.notes.push("lock file present beside the project (project locking is on)");let a=await pr(o),s=new TextDecoder().decode(a[0]===31&&a[1]===139?hoe(a):a),c=[...s.matchAll(/<MZ\.PrefixKey\.OpenSequenceGuidList\.(\d+)>([0-9a-f-]{36})</g)].map(u=>({idx:Number(u[1]),uid:u[2]})).sort((u,f)=>u.idx-f.idx),l=u=>{let f=s.indexOf(`<Sequence ObjectUID="${u}"`);if(f<0)return null;let d=/<Name>([^<]*)<\/Name>/.exec(s.slice(f,f+2e4));return d?d[1]:null};return i.timelines=c.map(u=>l(u.uid)).filter(u=>!!u),i.timelines.length&&(i.timeline=i.timelines[0]),i.notes.push("last saved state of the project file (Premiere has no outside door to unsaved edits; the panel has)"),i.notes.push(i.timelines.length?"sequences open in the Timeline panel at the last save, in panel order; the first is taken as the active one":"the project file records no open sequences"),i}async function Poe(e,t,n){let i=e.find(d=>/AvidMediaComposer\.app\/Contents\/MacOS\/AvidMediaComposer(\s|$)/.test(d.args)),r={host:"avid",running:!!i,pid:i?.pid,notes:[]};if(!i)return r;let o=(await K9(i.pid)).find(d=>/\.avp$/i.test(d)),a=t.find(d=>d.pid===i.pid&&/Media Composer/.test(d.title))?.title??"",s=/Media Composer[^-]*-\s*([^-]+?)\s*(?:-|$)/.exec(a)?.[1]?.trim();if(!o)return r.notes.push(s?`project "${s}" per the window title, but no .avp is held open`:"no project open"),r.project=s,r;r.project_path=o,r.project=ae(o).replace(/\.avp$/i,"");let c=Yn(o),l=[];for await(let d of zn(c))if(d.isFile&&/\.avb$/i.test(d.name)&&!d.name.startsWith("_")){let m=await cn(_(c,d.name));l.push({path:_(c,d.name),modified_at:Y9(m.mtimeMs)})}l.sort((d,m)=>m.modified_at.localeCompare(d.modified_at)),r.bins=l;let u=l[0];if(n){for(let d of l.slice(0,12))if(await n(d.path,"avb")){u=d;break}}u&&(r.read={path:u.path,format:"avb"}),r.notes.push("Media Composer keeps the sequence loaded in the Timeline only in memory; bins are the saved state. The newest-modified bin holding a sequence is offered; pass another bin path to timeline_read to choose.");let f=_("/Users/Shared/AvidMediaComposer/Avid Attic",r.project,"Bins");if(await Nn(f)){let d=null;for await(let m of zn(f)){if(!m.isDirectory)continue;let p=await cn(_(f,m.name));(!d||p.mtimeMs>d.m)&&(d={name:m.name,m:p.mtimeMs})}d&&r.notes.push(`Attic: last bin autosaved while open was "${d.name.replace(/\.[^.]*$/,"")}" at ${Y9(d.m)}`)}return r}async function Soe(e){let t=e.find(c=>/\/flame\.app\/Contents\/MacOS\/flame(\s|$)/.test(c.args)||/\/flame_\d{4}\/bin\/flame(\s|$)/.test(c.args)),n={host:"flame",running:!!t,pid:t?.pid,notes:[]};if(!t)return n;let i=/\s-J\s+(\S+)/.exec(t.args)?.[1],r=/\s-W\s+(\S+)/.exec(t.args)?.[1]??"Workspace";if(!i)return n.notes.push("Flame is running but its command line names no project (-J)"),n;n.project=i;let o=["/opt/Autodesk/project","/private/var/opt/Autodesk/flame/projects","/var/opt/Autodesk/flame/projects"],a=null;for(let c of o){let l=_(c,i,"catalog",`${r}.wksp`);if(await Nn(l)){a=l;break}}if(!a)return n.notes.push(`no catalog folder for project ${i} / workspace ${r} under ${o.join(", ")}`),n;n.project_path=a;let s=null;for await(let c of zn(a))if(c.isFile&&/^\.#workspace\.\d+\.wks$/.test(c.name)){let l=await cn(_(a,c.name));(!s||l.mtimeMs>s.m)&&(s={path:_(a,c.name),m:l.mtimeMs})}return s?(n.read={path:s.path,format:"flame"},n.notes.push(`live workspace file, written by Flame at ${Y9(s.m)}; holds the desktop's reels and sequences. Which sequence sits in the Timeline is not yet decoded \u2014 every sequence on the desktop is returned.`),n):(n.notes.push("no workspace file in the catalog"),n)}async function koe(e){let t=e.find(c=>/Final Cut Pro\.app\/Contents\/MacOS\/Final Cut Pro(\s|$)/.test(c.args)),n={host:"fcp",running:!!t,pid:t?.pid,notes:[]};if(!t)return n;let i=[...new Set((await K9(t.pid)).map(c=>/^(.*?\.fcpbundle)(\/|$)/.exec(c)?.[1]).filter(c=>!!c))];if(!i.length)return n.notes.push("Final Cut is running with no library open"),n;n.timelines=[];let r=new Map;for(let c of i)for await(let l of zn(c))if(!(!l.isDirectory||/\.(localized)$/.test(l.name)||l.name.startsWith("_")))for await(let u of zn(_(c,l.name)))u.isDirectory&&!/^(Original Media|Render Files|Analysis Files|Transcoded Media|Shared Items)$/.test(u.name)&&r.set(u.name,{library:c,event:l.name});let o=await Mn("osascript",["-e",'tell application "System Events" to tell process "Final Cut Pro" to get value of every static text of group 1 of group 4 of splitter group 1 of group 1 of splitter group 1 of group 1 of splitter group 1 of window 2']),a=o.success?o.stdout.trim().split(", ").find(c=>r.has(c)):void 0;if(!a){let c=await Mn("osascript",["-e",'tell application "System Events" to tell process "Final Cut Pro" to get entire contents of window 2']);for(let l of c.stdout.matchAll(/static text ([^,]+?) of group/g))if(r.has(l[1])){a=l[1];break}}let s=a?r.get(a):void 0;return n.project=s?ae(s.library).replace(/\.fcpbundle$/,""):i.length===1?ae(i[0]).replace(/\.fcpbundle$/,""):void 0,n.project_path=s?.library??(i.length===1?i[0]:void 0),n.timeline=a,n.timelines=[...r.keys()],n.notes.push(`${i.length} librar${i.length===1?"y":"ies"} open: ${i.map(c=>ae(c)).join(" | ")}`),a&&s?n.notes.push(`project "${a}" is in event "${s.event}" of ${ae(s.library)}`):n.notes.push("could not read the Timeline title (no project loaded, or the accessibility layout differs)"),n.notes.push("no readable file: a Final Cut library is a Core Data store with a private object graph, not fcpxml. Reading the open project needs either a decode of that store or a UI-driven File > Export XML."),n}var rv=e=>e.replace(/[^\w.-]+/g,"_").slice(0,80);function Toe(e=xr()){return e==="darwin"||e==="linux"?null:`host_current is not available on ${e} yet: it reads the process table and open files (ps, lsof), which this OS does not have. Export the timeline from the host and use timeline_read.`}async function IW(e,t,n){let i=Toe();if(i)throw new ze("unsupported",i);let r=e?.length?e:[...La],o=t??await ii("conform-host-"),a=await boe(),s=r.some(l=>l==="premiere"||l==="avid")?await goe():[],c=[];for(let l of r)try{l==="resolve"?c.push(await voe(a,o)):l==="premiere"?c.push(await xoe(a,s)):l==="avid"?c.push(await Poe(a,s,n)):l==="flame"?c.push(await Soe(a)):c.push(await koe(a))}catch(u){c.push({host:l,running:!0,notes:[`failed: ${u instanceof Error?u.message:String(u)}`]})}return c}function Q9(e){return e.map(t=>`${t.kind[0].toUpperCase()}${t.index}${t.name&&!/^(Video|Audio|Subtitle) \d+$/.test(t.name)?` ${t.name}`:""}${t.enabled?"":" (off)"}${t.locked?" (locked)":""}`).join(" | ")}function WW(e){let t=[`${e.host}: ${e.running?`running (pid ${e.pid})`:"not running"}`];e.project&&t.push(` project: ${e.project}${e.project_path?` [${e.project_path}]`:""}`),e.timeline&&t.push(` open timeline: ${e.timeline}`),e.timelines?.length&&t.push(` timelines: ${e.timelines.join(" | ")}`),e.tracks?.length&&t.push(` tracks: ${Q9(e.tracks)}`),e.bins?.length&&t.push(` bins (newest first): ${e.bins.slice(0,8).map(n=>ae(n.path)).join(" | ")}${e.bins.length>8?` \u2026 +${e.bins.length-8}`:""}`),e.read&&t.push(` read as: ${e.read.format} ${e.read.path}`);for(let n of e.notes)t.push(` note: ${n}`);return t.join(`
212
+ `)}function iv(e,t){let n=async()=>{throw new Error(`${e}: ${t}`)},i={ok:!1,reason:t};return{host:e,support:async()=>({export:i,open:i,render:i,markers:i,renderplugin:i}),export:n,open:n,renderStart:n,renderStatus:n,renderCancel:n}}import zoe from"node:http";import{createHash as Moe}from"node:crypto";import{Buffer as io}from"node:buffer";var Ooe="258EAFA5-E914-47DA-95CA-C5AB0DC85B11";function _9(e,t){let n=t.length,i=n<126?io.from([128|e,n]):n<65536?io.from([128|e,126,n>>8,n&255]):(()=>{let r=io.alloc(10);return r[0]=128|e,r[1]=127,r.writeBigUInt64BE(BigInt(n),2),r})();return io.concat([i,io.from(t)])}function Loe(e,t,n){let i=io.alloc(0),r=[],o=0,a=!1,s=[],c=[],l=()=>{a||(a=!0,c.forEach(f=>f()))},u=(f=1e3,d="")=>{if(a)return;let m=io.from(d),p=io.alloc(2+m.length);p.writeUInt16BE(f,0),m.copy(p,2);try{e.write(_9(8,p))}catch{}e.end(),l()};return e.on("data",f=>{for(i=io.concat([i,f]);i.length>=2;){let d=(i[0]&128)!==0,m=i[0]&15,p=(i[1]&128)!==0,b=i[1]&127,h=2;if(b===126){if(i.length<4)return;b=i.readUInt16BE(2),h=4}else if(b===127){if(i.length<10)return;let y=i.readBigUInt64BE(2);if(y>BigInt(n))return u(1009,"too big");b=Number(y),h=10}if(!p)return u(1002,"client frames must be masked");if(b>n||o+b>n)return u(1009,"message too big");if(i.length<h+4+b)return;let v=i.subarray(h,h+4),g=io.from(i.subarray(h+4,h+4+b));for(let y=0;y<g.length;y++)g[y]^=v[y&3];if(i=i.subarray(h+4+b),m===8)return u(1e3);if(m===9){e.write(_9(10,g));continue}if(m!==10){if(m===1||m===0){if(r.push(g),o+=g.length,d){let y=io.concat(r).toString("utf8");r=[],o=0,s.forEach(w=>w(y))}continue}return u(1003,"text frames only")}}}),e.on("close",l),e.on("error",l),{origin:t,send:f=>{a||e.write(_9(1,io.from(f,"utf8")))},close:u,onMessage:f=>{s.push(f)},onClose:f=>{c.push(f)}}}function DW(e,t){let n=new Set,i=zoe.createServer((r,o)=>{o.writeHead(426,{"content-type":"text/plain"}),o.end("websocket only")});return i.on("upgrade",(r,o)=>{let a=r.headers["sec-websocket-key"];if(r.url?.split("?")[0]!==e.path||typeof a!="string"||String(r.headers.upgrade).toLowerCase()!=="websocket"){o.end(`HTTP/1.1 400 Bad Request\r
213
+ \r
214
+ `);return}let s=Moe("sha1").update(a+Ooe).digest("base64");o.write(`HTTP/1.1 101 Switching Protocols\r
215
+ Upgrade: websocket\r
216
+ Connection: Upgrade\r
217
+ Sec-WebSocket-Accept: ${s}\r
218
+ \r
219
+ `),n.add(o),o.on("close",()=>n.delete(o));let c=typeof r.headers.origin=="string"?r.headers.origin:null;t(Loe(o,c,e.maxBytes))}),new Promise((r,o)=>{i.once("error",o),i.listen(e.port,e.hostname,()=>{let a=i.address();r({port:typeof a=="object"&&a?a.port:e.port,close:()=>new Promise(s=>{for(let c of n)c.destroy();i.close(()=>s())})})})})}var ov=1,Xoe=[48127,48128,48129,48130,48131,48132,48133,48134],Noe=5e3,qW=4,Roe=8*1024*1024,Zc=class extends Error{constructor(n,i){super(i);this.code=n}},av=()=>_(wt(),"host-bridge","pairing.json");function Foe(){let e=new Uint8Array(32);return crypto.getRandomValues(e),Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}var $9=class{constructor(){this.token=Foe();this.port=0;this.live=new Map;this.waiters=[];this.seq=0;this.events=[]}async start(t=Xoe){let n;for(let i of t)try{this.server=await DW({hostname:"127.0.0.1",port:i,path:"/host-bridge",maxBytes:Roe},r=>this.accept(r)),this.port=this.server.port;break}catch(r){n=r}if(!this.server)throw new Zc("no_port",`every host-bridge port (${t.join(", ")}) is taken: ${n}`);await vt(_(wt(),"host-bridge")),await ln(av(),JSON.stringify({protocol:ov,url:`ws://127.0.0.1:${this.port}/host-bridge`,port:this.port,token:this.token})),await So(av(),384)}async stop(){for(let t of this.live.values())t.conn.close(1001,"engine stopping");this.live.clear(),await this.server?.close();try{JSON.parse(await Tn(av())).token===this.token&&await Er(av())}catch{}}peers(){return[...this.live.values()].map(t=>t.peer)}peer(t){return this.live.get(t)?.peer}async waitFor(t,n){return this.live.has(t)?this.peer(t):(await Promise.race([new Promise(i=>this.waiters.push({host:t,resolve:i})),new Promise(i=>setTimeout(i,n))]),this.peer(t))}request(t,n,i={},r=3e4){let o=this.live.get(t);if(!o)return Promise.reject(new Zc("not_connected",`${t}: its panel is not connected`));let a=`r${++this.seq}`;return new Promise((s,c)=>{let l=setTimeout(()=>{o.pending.delete(a),c(new Zc("timeout",`${t}: no answer to ${n} within ${Math.round(r/1e3)} s`))},r);o.pending.set(a,{resolve:s,reject:c,timer:l}),o.conn.send(JSON.stringify({type:"request",id:a,method:n,params:i}))})}accept(t){if(t.origin&&/^https?:/i.test(t.origin)){t.send(JSON.stringify({type:"error",code:"origin_refused",message:"web pages may not use the host bridge"})),t.close(1008,"origin");return}let n=null,i=setTimeout(()=>{n||(t.send(JSON.stringify({type:"error",code:"hello_timeout",message:"no hello"})),t.close(1008,"hello"))},Noe);t.onMessage(r=>{let o;try{o=JSON.parse(r)}catch{return}if(!n){let s=(f,d)=>{clearTimeout(i),t.send(JSON.stringify({type:"error",code:f,message:d})),t.close(1008,f)};if(o.type!=="hello")return s("hello_expected","the first frame must be hello");if(o.protocol!==ov)return s("protocol_mismatch",`this engine speaks protocol ${ov}`);if(o.token!==this.token)return s("bad_token","the pairing token does not match: re-read the pairing file");let c=o.host??{},l=String(c.id??"");if(!/^[a-z][a-z0-9_-]{1,31}$/.test(l))return s("bad_host","host.id is missing or malformed");if(!this.live.has(l)&&this.live.size>=qW)return s("too_many_peers",`at most ${qW} panels`);clearTimeout(i),this.live.get(l)?.conn.close(1e3,"replaced by a newer connection"),n=l;let u={id:l,name:String(c.name??l),version:String(c.version??""),platform:String(c.platform??""),capabilities:Array.isArray(o.capabilities)?o.capabilities.map(String):[],optional_verbs:Array.isArray(o.optional_verbs)?o.optional_verbs.map(String):[]};this.live.set(l,{peer:u,conn:t,pending:new Map}),t.send(JSON.stringify({type:"welcome",protocol:ov,app:{name:"conformtools",version:so}})),this.waiters=this.waiters.filter(f=>f.host===l?(f.resolve(),!1):!0);return}let a=this.live.get(n);if(!(!a||a.conn!==t))if(o.type==="response"){let s=a.pending.get(String(o.id));if(!s)return;if(a.pending.delete(String(o.id)),clearTimeout(s.timer),o.ok)s.resolve(o.result??null);else{let c=o.error??{};s.reject(new Zc(c.code??"peer_error",`${n}: ${c.message??c.code??"error"}`))}}else o.type==="event"&&(this.events.push({host:n,name:String(o.name),data:o.data}),this.events.length>200&&this.events.shift())}),t.onClose(()=>{if(clearTimeout(i),!n)return;let r=this.live.get(n);if(r?.conn===t){for(let o of r.pending.values())clearTimeout(o.timer),o.reject(new Zc("disconnected",`${n}: the panel disconnected`));this.live.delete(n)}})}},sv=null;function HW(){return sv??=(async()=>{let e=new $9;return await e.start(),e})(),sv.catch(()=>{sv=null}),sv}var Voe=16e3;var EW="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.",ji=class extends Error{constructor(n,i){super(i);this.code=n}},cv=class{constructor(t=HW,n=Voe){this.bridge=t;this.waitMs=n;this.host="premiere";this.renders=new Map}async connected(){let t=await this.bridge();if(!await t.waitFor("premiere",this.waitMs))throw new ji("not_connected",`premiere: the conform.tools panel is not connected. ${EW}`);return t}async ask(t,n={},i){return await(await this.connected()).request("premiere",t,n,i)}async support(){let t;try{let i=await(await this.bridge()).waitFor("premiere",3e3);if(t=i?{ok:!0}:{ok:!1,reason:"the conform.tools panel is not connected",setup:EW},i){let r=o=>i.capabilities.includes(o)?{ok:!0}:{ok:!1,reason:`this panel version has no ${o}`};return{export:r("timeline_write"),open:r("timeline_write"),render:r("render"),markers:r("markers"),renderplugin:{ok:!1,reason:"the renderplugin is a DaVinci Resolve plugin"}}}}catch(n){t={ok:!1,reason:n instanceof Error?n.message:String(n)}}return{export:t,open:t,render:t,markers:t,renderplugin:{ok:!1,reason:"the renderplugin is a DaVinci Resolve plugin"}}}async current(){let t=await this.ask("session.describe");return{project:t.project,timelines:t.timelines,timeline:t.current}}async sequence(t){let n=await this.ask("session.current_project");if(!n)throw new ji("no_project","premiere: no project is open");if(!t){let o=await this.ask("session.current_timeline",{project:n});if(!o)throw new ji("no_timeline","premiere: no sequence is active");return{project:n,seq:o,name:await this.ask("session.name",{handle:o})}}let i=await this.ask("session.timeline_count",{project:n}),r=[];for(let o=1;o<=i;o++){let a=await this.ask("session.timeline_by_index",{project:n,index:o});if(!a)continue;let s=await this.ask("session.name",{handle:a});if(s===t)return{project:n,seq:a,name:s};r.push(s)}throw new ji("not_found",`premiere: no sequence named "${t}" (have: ${r.join(", ")})`)}async export(t){if(!t.out_path)throw new ji("usage","premiere: export needs out_path");let{project:n,seq:i,name:r}=await this.sequence(t.timeline),o=await this.ask("timeline_write.export_xml",{project:n,timeline:i,path:t.out_path},12e4);if(!o.ok||!await Ar(t.out_path)||(await cn(t.out_path)).size===0)throw new ji("export_failed",`premiere: Premiere did not write ${t.out_path}${o.errors?.length?` (${o.errors.join("; ")})`:""}`);let a=await this.ask("session.describe");return{path:t.out_path,format:"xmeml",project:a.project,timeline:r}}async open(t){if(t.into==="scratch")throw new ji("unsupported","premiere: opening into a scratch project is not supported; the import lands in the open project as a new bin");let n=await this.ask("session.current_project");if(!n)throw new ji("no_project","premiere: no project is open");let i=await this.ask("timeline_write.import_file",{project:n,path:t.path},3e5);if(!i.ok||!i.imported.length)throw new ji("import_failed",`premiere: Premiere did not import ${t.path}`);let r=await this.ask("session.describe"),o=i.imported.length>1?[`imported ${i.imported.length} sequences: ${i.imported.map(a=>a.name).join(", ")}`]:[];return t.name&&o.push("Premiere names imported sequences after the file's own; name was not applied"),t.media_dirs?.length&&o.push("Premiere links media from the paths in the file; media_dirs was not used (relink with timeline_relink before writing)"),{project:r.project,timeline:i.imported[0].name,notes:o,restored:!t.stay}}async renderStart(t){if(t.range)throw new ji("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 ji("usage","premiere: preset must be the path of a Media Encoder preset (.epr)");let{seq:n,name:i}=await this.sequence(t.timeline);await vt(t.target_dir);let r=_(t.target_dir,`${t.name??i}.mov`),o=await this.ask("render.export_sequence",{timeline:n,output_path:r,preset_path:t.preset,queue:!1},6e4);if(!o.ok)throw new ji("render_refused","premiere: Premiere refused the export");let a=o.job||`ppro-${Date.now()}`;return this.renders.set(a,r),{job_id:a,state:"rendering",percent:0}}async renderStatus(t){let n=await this.ask("render.progress"),i=n[t]??n.last,r=this.renders.get(t);return i?.event==="onEncodeError"?{job_id:t,state:"failed",percent:0,error:String(i.data??"encode error")}:i?.event==="onEncodeComplete"||r&&await Nn(r)&&!i?{job_id:t,state:"complete",percent:100,...r?{outputs:[r]}:{}}:{job_id:t,state:"rendering",percent:typeof i?.data=="number"?Math.round(Number(i.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"}}};function CW(e=xr()){return e==="darwin"?"/Library/Application Support/Adobe/Adobe Desktop Common/RemoteComponents/UPI/UnifiedPluginInstallerAgent/UnifiedPluginInstallerAgent.app/Contents/MacOS/UnifiedPluginInstallerAgent":e==="win32"?"C:\\Program Files\\Common Files\\Adobe\\Adobe Desktop Common\\RemoteComponents\\UPI\\UnifiedPluginInstallerAgent\\UnifiedPluginInstallerAgent.exe":null}async function UW(){for(let e of["./uxp-plugin/","./premiere-uxp/"]){let t=Fr(new URL(e,import.meta.url));if(await Ar(_(t,"manifest.json")))return t}throw new Error("premiere: the conform.tools panel is missing from this install")}async function e4(){return JSON.parse(await Tn(_(await UW(),"manifest.json"))).version}async function AW(e=xr()){let t=CW(e);if(!t||!await Nn(t))return{installed:!1,listing:"Creative Cloud's plugin installer is not on this machine"};let n=await Mn(t,e==="win32"?["/list","all"]:["--list","all"],{timeoutMs:6e4}),i=n.stdout.split(`
220
+ `).find(r=>/CONFORM\.TOOLS|conformtools/i.test(r));return{installed:!!i&&/enabled|installed/i.test(i),version:i?.match(/(\d+\.\d+\.\d+)\s*$/)?.[1],listing:n.stdout.trim()}}async function GW(e=xr()){let t=CW(e);if(!t||!await Nn(t))throw new Error("premiere: Creative Cloud's plugin installer (UnifiedPluginInstallerAgent) is not on this machine; install Creative Cloud");let n=await UW(),i=await e4(),r=await ii("conform-ccx-");for(let u of["manifest.json","index.html","index.js","lib","icons"])await $m(_(n,u),_(r,u));let o=_(wt(),"premiere");await vt(o);let a=H6(_(o,`conformtools-premiere-${i}.ccx`));await Ti(a);let s=e==="darwin"?await Mn("sh",["-c",`cd '${r.replace(/'/g,"'\\''")}' && zip -r -q -X '${a.replace(/'/g,"'\\''")}' manifest.json index.html index.js lib icons`]):await Mn("powershell",["-NoProfile","-Command",`Compress-Archive -Path '${r}\\*' -DestinationPath '${a.replace(/\.ccx$/,".zip")}' -Force; Move-Item -Force '${a.replace(/\.ccx$/,".zip")}' '${a}'`]);if(await Ti(r),!s.success)throw new Error(`premiere: could not package the panel: ${s.stderr.trim()}`);let c=await Mn(t,e==="win32"?["/install",a]:["--install",a],{timeoutMs:18e4}),l=`${c.stdout}
221
+ ${c.stderr}`.trim();if(!c.success||!/Installation Successful/i.test(l))throw new Error(`premiere: Adobe's installer refused the panel: ${l.split(`
222
+ `).pop()}`);return{version:i,ccx:a,output:l}}var joe=new nv,Zoe=new cv;function Ic(e){switch(e){case"resolve":return joe;case"premiere":return Zoe;case"avid":return iv(e,"not wired yet: waiting on Avid's Panel SDK access (bins and AAFs on disk work without it)");case"flame":return iv(e,"not wired yet");case"fcp":return iv(e,"not wired yet")}}var Dm={strict:{tolerance_px:1,min_frames:1,gap_frames:0,black_threshold:16},standard:{tolerance_px:2,min_frames:2,gap_frames:1,black_threshold:10},relaxed:{tolerance_px:6,min_frames:4,gap_frames:3,black_threshold:6}},t4="strict",JW={tolerance_px:[0,512],min_frames:[1,600],gap_frames:[0,600],black_threshold:[0,255]};function BW(e,t={}){let n=(e??t4).trim().toLowerCase(),i=Dm[n]??Dm[t4],r=Dm[n]?n:n==="custom"?"custom":t4,o={...i};for(let a of Object.keys(JW)){let s=t[a];if(s===void 0||!Number.isFinite(Number(s)))continue;let[c,l]=JW[a],u=Math.max(c,Math.min(l,Math.round(Number(s))));u!==o[a]&&(r="custom"),o[a]=u}return{...o,preset:r}}function Wm(e,t){let n=Number(e),i=Number(t);return!Number.isFinite(n)||!Number.isFinite(i)?!1:n>0&&n>=i}function Ioe(e,t,n){return!(e>0)||!(t>0)||!(n>0)?!1:Math.abs(t/n-e)/e>=.02}function Woe(e,t,n,i,r){let o=Math.max(2,Number(r)||0);return Math.abs(e-t)<=o&&Math.abs(n-i)<=o}function Doe(e,t,n,i,r,o){return!r||!(r.top>0||r.bottom>0||r.left>0||r.right>0)?!1:Math.abs(e-r.top)<=o&&Math.abs(t-r.bottom)<=o&&Math.abs(n-r.left)<=o&&Math.abs(i-r.right)<=o}var YW=[["bt","ct"],["bb","cb"],["bl","cl"],["br","cr"]],lv=e=>Math.max(0,Math.trunc(Number(e)||0)),uv=e=>Math.max(0,Math.min(1,Number(e)||0));function qoe(e,t,n,i,r,o={}){let a=o.tolerance_px??4;i=Math.max(1,Math.trunc(i)),r=Math.max(1,Math.trunc(r));let s=[];for(let c of e??[]){let l=Math.trunc(Number(c.pts)||0),u=lv(c.bt),f=lv(c.bb),d=lv(c.bl),m=lv(c.br);if(!Wm(Math.max(u,f,d,m),a)||Doe(u,f,d,m,o.declared_blanking,a))continue;let p=Number(o.expected_aspect_ratio)||0;if(p>0){let v=Math.max(1,i-d-m),g=Math.max(1,r-u-f),y=d<=a&&m<=a,w=u<=a&&f<=a;if((y||w)&&Ioe(p,i,r)&&Woe(u,f,d,m,a)&&Math.abs(v/g-p)/p<.02)continue}let b=n+l,h;for(let v of t??[])v.start<=b&&b<v.end&&(!h||v.track>h.track)&&(h=v);h&&s.push({frame_abs:b,bt:u,bb:f,bl:d,br:m,ct:uv(c.ct),cb:uv(c.cb),cl:uv(c.cl),cr:uv(c.cr),source:c.source??"pixels",clip:h})}return s.sort((c,l)=>c.frame_abs-l.frame_abs)}function Hoe(e,t){let n=[];return Wm(e.bt,t)&&n.push("Top"),Wm(e.bb,t)&&n.push("Bottom"),Wm(e.bl,t)&&n.push("Left"),Wm(e.br,t)&&n.push("Right"),n}function KW(e,t,n,i,r,o={}){let a=Math.max(1,Math.trunc(o.min_frames??1)),s=Math.max(0,Math.trunc(o.gap_frames??0)),c=o.tolerance_px??4,l=[],u;for(let f of qoe(e,t,n,i,r,o)){(!u||u.clip!==f.clip||f.frame_abs-u.end_frame-1>s)&&(u={clip:f.clip,start_frame:f.frame_abs,end_frame:f.frame_abs,frame_count:0,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},sources:new Set},l.push(u)),u.end_frame=f.frame_abs,u.frame_count++,u.sources.add(f.source);for(let[d,m]of YW)f[d]>=u.measured[d]&&(u.measured[d]=f[d],u.coverage[m]=f[m])}return l.filter(f=>f.frame_count>=a).map(f=>({...f,duration_frames:f.end_frame-f.start_frame+1,sources:[...f.sources].sort(),zones:Hoe(f.measured,c)}))}function QW(e){let t=new Map;for(let i of e){let r=t.get(i.clip.id);r||(r={clip:i.clip,measured:{bt:0,bb:0,bl:0,br:0},coverage:{ct:0,cb:0,cl:0,cr:0},frames:0,first_frame_abs:i.start_frame,zones:[],sources:[],ranges:[]},t.set(i.clip.id,r)),r.frames+=i.frame_count,r.first_frame_abs=Math.min(r.first_frame_abs,i.start_frame);for(let[o,a]of YW)i.measured[o]>=r.measured[o]&&(r.measured[o]=i.measured[o],r.coverage[a]=i.coverage[a]);r.sources=[...new Set([...r.sources,...i.sources])].sort(),r.ranges.push(i)}let n=["Top","Bottom","Left","Right"];return[...t.values()].map(i=>{let r=new Set(i.ranges.flatMap(o=>o.zones));return{...i,zones:n.filter(o=>r.has(o)),ranges:i.ranges.sort((o,a)=>o.start_frame-a.start_frame)}}).sort((i,r)=>i.clip.start-r.clip.start)}function _W(e,t=1){let n=Math.max(0,Math.trunc(t)),i=[];for(let r of[...e].sort((o,a)=>o.frame-a.frame)){let o=i.at(-1);if(o&&r.frame-o.end_frame<=n+1){o.end_frame=Math.max(o.end_frame,r.frame),o.frames++,o.darkest=Math.min(o.darkest,r.avg);continue}i.push({start_frame:r.frame,end_frame:r.frame,duration_frames:1,frames:1,darkest:r.avg})}for(let r of i)r.duration_frames=r.end_frame-r.start_frame+1;return i}var Eoe="ConformTools:blanking:error",Coe="ConformTools:blanking:black";function Uoe(e,t,n){return e*175e4*(t*n/(1920*1080))}async function $W(e,t){let n=-1;for(let i=Date.now()+t;Date.now()<i;){if(await Nn(e)){let r=(await cn(e)).size;if(r>0&&r===n)return!0;n=r}await new Promise(r=>setTimeout(r,500))}return n>0}async function n4(e,t,n,i){let r=new Promise(o=>i?.addEventListener("abort",()=>o(),{once:!0}));for(;t.state==="queued"||t.state==="rendering";){if(n?.(t.percent,100,"rendering"),await Promise.race([r.then(()=>!0),new Promise(a=>setTimeout(()=>a(!1),1e3))]))return await e.renderCancel(t.job_id);t=await e.renderStatus(t.job_id)}return t}async function eD(e,t,n,i,r,o={}){let a=[],s=await(o.status??Au)();if(s.readiness!=="ready")if(s.readiness==="unknown")a.push("Resolve's log does not say whether it loaded the renderplugin; trying anyway");else throw new Error(`renderplugin ${s.readiness}: ${s.next}`);let c=async(Y,D)=>{let j=await t(Y,D,6e4);if(!j.ok)throw new Error(`resolve: ${j.detail||j.why}`);return j};i?.(0,100,"preparing");let l=await c("renderplugin_preset",{preset_path:await NW()});l.imported&&a.push(`imported the conform.tools render preset into this Resolve database${l.replaced?" (replaced a stale one)":""}`);let u=await c("clips",{timeline:n.timeline}),f=n.range?.in??u.start_frame,d=n.range?n.range.out-n.range.in+1:u.end_frame-u.start_frame,m=_(wt(),"renderplugin",`${u.timeline.replace(/[^\w.-]+/g,"_")}_${Date.now()}`);await vt(m);let p=Uoe(d,u.width,u.height)*1.15+5e9,b=await ep(m);if(!n.ignore_space&&b!==null&&b<p)throw await Ti(m),new Error(`not enough space for the throwaway render: about ${(p/1e9).toFixed(1)} GB needed, ${(b/1e9).toFixed(1)} GB free on the volume holding ${wt()}. Free space, set CONFORM_MCP_HOME to a bigger volume, or pass ignore_space.`);let h=await e.renderStart({timeline:u.timeline,target_dir:m,name:"conform.tools",range:n.range,audio:n.audio??!0,renderplugin:n.checks??{}});if(h=await n4(e,h,i,r),h.state!=="complete")throw await Ti(m),new Error(`the renderplugin render ${h.state}${h.error?`: ${h.error}`:""}`);i?.(100,100,"reading the report");let v=_(m,"qc_report.json");if(!await $W(v,3e4))throw new Error("the render finished but wrote no qc_report.json: the preset is not selecting the renderplugin codec, or Resolve has not loaded the renderplugin (restart Resolve)");let g=JSON.parse(await Tn(v)),y=g.width||u.width,w=g.height||u.height,x=g.fps_num&&g.fps_den?g.fps_num/g.fps_den:Number(u.fps)||24,T=BW(n.strictness,n.overrides),z=g.frame_stats??[],k=KW(z,u.clips,f,y,w,{...T,expected_aspect_ratio:n.expected_aspect}),S=z.some(Y=>(Y.avg_luma??0)>1.5)?1:255,M=_W(z.filter(Y=>(Y.avg_luma??255)*S<T.black_threshold).map(Y=>({frame:f+Y.pts,avg:(Y.avg_luma??0)*S})),T.gap_frames),L=(g.checks??[]).filter(Y=>Y.status==="fail"||Y.status==="warn").map(Y=>({id:Y.id,label:Y.label??Y.id,status:Y.status,ranges:Y.ranges?.length??0})),P,X=_(m,"qc_audio.json");if((n.audio??!0)&&await $W(X,8e3)){let Y=JSON.parse(await Tn(X));P={integrated_lufs:Y.integrated_lufs,true_peak_dbtp:Y.true_peak_dbtp,issues:Y.issues?.length??0}}let R;if(n.markers??!0){let Y=C=>tn(C,x),D=[...k.map(C=>({frame:C.start_frame-u.start_frame,duration:C.duration_frames,color:"Red",tag:Eoe,name:"conform.tools blanking",note:`Zone: ${C.zones.join(", ")} | max ${Math.max(C.measured.bt,C.measured.bb,C.measured.bl,C.measured.br)}px | ${C.frame_count} frame(s) | frames ${C.start_frame}-${C.end_frame} @ ${Y(C.start_frame)}`})),...M.map(C=>({frame:C.start_frame-u.start_frame,duration:C.duration_frames,color:"Yellow",tag:Coe,name:"conform.tools black frames",note:`${C.frames} black frame(s) @ ${Y(C.start_frame)}`}))];await c("markers",{timeline:u.timeline,tag:"ConformTools:blanking",clear:!0,place:[]});let j=await c("markers",{timeline:u.timeline,tag:"ConformTools:blanking",place:D});R={placed:Number(j.placed),skipped:j.skipped}}let I;for await(let Y of zn(m))!Y.isFile||Y.name.startsWith("qc_")||(n.keep_render?(I??=[]).push(_(m,Y.name)):await Ti(_(m,Y.name)));let q=QW(k).length;return k.length&&a.push(`${k.length} blanking finding(s) on ${q} clip(s)`),{timeline:u.timeline,frames:d,raster:{width:y,height:w},fps:x,strictness:T,blanking:k,black:M,checks:L,audio:P,markers:R,report_dir:m,...I?{render_kept:I}:{},notes:a}}function tD(e){let t=r=>tn(r,e.fps),n=e.blanking.length+e.black.length+e.checks.filter(r=>r.status==="fail").length,i=[`renderplugin scan of ${e.timeline}: ${n?`${n} finding(s)`:"clean"} over ${e.frames} frames (${e.raster.width}x${e.raster.height}, ${e.strictness.preset} strictness)`];for(let r of e.blanking){let o=Math.max(r.measured.bt,r.measured.bb,r.measured.bl,r.measured.br);i.push(` blanking ${t(r.start_frame)}\u2013${t(r.end_frame)} ${r.clip.name} (V${r.clip.track}) ${r.zones.join("/")} ${o}px, ${r.frame_count} frame(s)`)}for(let r of e.black)i.push(` black ${t(r.start_frame)}\u2013${t(r.end_frame)} ${r.frames} frame(s)`);for(let r of e.checks)i.push(` ${r.status.padEnd(9)} ${r.label}${r.ranges?` (${r.ranges} range(s))`:""}`);return e.audio&&i.push(` audio ${e.audio.integrated_lufs??"?"} LUFS integrated, ${e.audio.true_peak_dbtp??"?"} dBTP true peak, ${e.audio.issues} issue(s)`),e.markers&&i.push(`markers: ${e.markers.placed} placed on the timeline${e.markers.skipped.length?`, ${e.markers.skipped.length} skipped (a frame already had someone else's marker)`:""}`),i.push(...e.notes.map(r=>`note: ${r}`),`report: ${e.report_dir}`),e.render_kept&&i.push(`render kept: ${e.render_kept.join(", ")}`),i.join(`
223
+ `)}function di(e,t){let n=new Float64Array(9);for(let i=0;i<3;i++)for(let r=0;r<3;r++){let o=0;for(let a=0;a<3;a++)o+=e[i*3+a]*t[a*3+r];n[i*3+r]=o}return n}function o4(e){let t=new Float64Array(9);for(let n=0;n<3;n++)for(let i=0;i<3;i++)t[n*3+i]=e[i*3+n];return t}function fv(e){let t=new Float64Array(9);return t[0]=e[0],t[4]=e[1],t[8]=e[2],t}function a4(e){let t=Float64Array.from(e),n=new Float64Array([1,0,0,0,1,0,0,0,1]);for(let a=0;a<24;a++){let s=0;for(let[c,l]of[[0,1],[0,2],[1,2]])s+=t[c*3+l]**2;if(s<1e-30)break;for(let[c,l]of[[0,1],[0,2],[1,2]]){let u=t[c*3+l];if(Math.abs(u)<1e-300)continue;let f=(t[l*3+l]-t[c*3+c])/(2*u),d=Math.sign(f||1)/(Math.abs(f)+Math.sqrt(f*f+1)),m=1/Math.sqrt(d*d+1),p=d*m;for(let b=0;b<3;b++){let h=t[b*3+c],v=t[b*3+l];t[b*3+c]=m*h-p*v,t[b*3+l]=p*h+m*v}for(let b=0;b<3;b++){let h=t[c*3+b],v=t[l*3+b];t[c*3+b]=m*h-p*v,t[l*3+b]=p*h+m*v}for(let b=0;b<3;b++){let h=n[b*3+c],v=n[b*3+l];n[b*3+c]=m*h-p*v,n[b*3+l]=p*h+m*v}}}let i=[0,1,2].sort((a,s)=>t[a*3+a]-t[s*3+s]),r=new Float64Array(3),o=new Float64Array(9);return i.forEach((a,s)=>{r[s]=t[a*3+a];for(let c=0;c<3;c++)o[c*3+s]=n[c*3+a]}),{values:r,vectors:o}}function nD(e){let t=new Float64Array(9);for(let n=0;n<3;n++)for(let i=0;i<=n;i++){let r=e[n*3+i];for(let o=0;o<i;o++)r-=t[n*3+o]*t[i*3+o];if(n===i){if(r<=0)return null;t[n*3+i]=Math.sqrt(r)}else t[n*3+i]=r/t[i*3+i]}return t}function Aoe(e){let t=new Float64Array(9);for(let n=0;n<3;n++){t[n*3+n]=1/e[n*3+n];for(let i=0;i<n;i++){let r=0;for(let o=i;o<n;o++)r+=e[n*3+o]*t[o*3+i];t[n*3+i]=-r/e[n*3+n]}}return t}function r4(e){let{values:t,vectors:n}=a4(e),i=1e-12*Math.max(...Array.from(t).map(Math.abs),1e-30),r=new Float64Array(3);for(let o=0;o<3;o++)r[o]=Math.abs(t[o])>i?1/t[o]:0;return di(di(n,fv(r)),o4(n))}function Goe(e){let{values:t,vectors:n}=a4(e),i=new Float64Array(3);for(let r=0;r<3;r++)i[r]=Math.sqrt(Math.max(t[r],0));return di(di(n,fv(i)),o4(n))}function rD(e){let t=e.w*e.h,n=new Float64Array(3);for(let o=0;o<t;o++)for(let a=0;a<3;a++)n[a]+=e.data[o*3+a];for(let o=0;o<3;o++)n[o]/=t;let i=new Float64Array(9);for(let o=0;o<t;o++){let a=e.data[o*3]-n[0],s=e.data[o*3+1]-n[1],c=e.data[o*3+2]-n[2];i[0]+=a*a,i[1]+=a*s,i[2]+=a*c,i[4]+=s*s,i[5]+=s*c,i[8]+=c*c}let r=Math.max(1,t-1);for(let o of[0,1,2,4,5,8])i[o]/=r;return i[3]=i[1],i[6]=i[2],i[7]=i[5],{mean:n,cov:i}}function Joe(e,t,n,i){let r=e.w*e.h,o=new Float32Array(r*3);for(let a=0;a<r;a++){let s=e.data[a*3]-n[0],c=e.data[a*3+1]-n[1],l=e.data[a*3+2]-n[2];o[a*3]=t[0]*s+t[1]*c+t[2]*l+i[0],o[a*3+1]=t[3]*s+t[4]*c+t[5]*l+i[1],o[a*3+2]=t[6]*s+t[7]*c+t[8]*l+i[2]}return{data:o,w:e.w,h:e.h}}function Boe(e,t){let{values:n,vectors:i}=a4(e),r=new Float64Array(3),o=new Float64Array(3);for(let f=0;f<3;f++){let d=Math.max(n[f],0);r[f]=Math.sqrt(d),o[f]=r[f]>1e-12?1/r[f]:0}let a=fv(r),s=fv(o),c=o4(i),l=di(di(di(di(a,c),t),i),a),u=Goe(l);return di(di(di(di(i,s),u),s),c)}function Yoe(e,t){let i=Float64Array.from(e),r=Float64Array.from(t);for(let s of[0,4,8])i[s]+=1e-5,r[s]+=1e-5;let o=nD(i),a=nD(r);if(!o||!a){let s=new Float64Array(9);for(let c=0;c<3;c++){let l=Math.sqrt(Math.max(e[c*3+c],0)),u=Math.sqrt(Math.max(t[c*3+c],0));s[c*3+c]=l>1e-12?u/l:1}return s}return di(a,Aoe(o))}function Koe(e,t,n,i){let r=r4(n.cov),o=r4(i.cov),a=e.w*e.h,s=new Float64Array(9);for(let l=0;l<a;l++){let u=t.data[l*3]-i.mean[0],f=t.data[l*3+1]-i.mean[1],d=t.data[l*3+2]-i.mean[2],m=e.data[l*3]-n.mean[0],p=e.data[l*3+1]-n.mean[1],b=e.data[l*3+2]-n.mean[2];s[0]+=u*m,s[1]+=u*p,s[2]+=u*b,s[3]+=f*m,s[4]+=f*p,s[5]+=f*b,s[6]+=d*m,s[7]+=d*p,s[8]+=d*b}let c=Math.max(1,a-1);for(let l=0;l<9;l++)s[l]/=c;return di(di(r4(o),o),di(s,r))}var go=4096;function i4(e,t){let n=e.w*e.h,i=t.w*t.h,r=a=>Math.min(go-1,Math.max(0,Math.round(ro(a)*(go-1)))),o=[];for(let a=0;a<3;a++){let s=new Float64Array(go),c=new Float64Array(go);for(let p=0;p<n;p++)s[r(e.data[p*3+a])]++;for(let p=0;p<i;p++)c[r(t.data[p*3+a])]++;let l=0;for(let p=0;p<go;p++)l+=s[p],s[p]=l/n;let u=[],f=[];l=0;for(let p=0;p<go;p++)c[p]!==0&&(l+=c[p],u.push(p/(go-1)),f.push(l/i));let d=new Float32Array(go),m=0;for(let p=0;p<go;p++){let b=s[p];for(;m<f.length-1&&f[m]<b;)m++;if(m===0||f[m]<=b)d[p]=u[m]??0;else{let h=f[m-1],v=f[m],g=v>h?(b-h)/(v-h):0;d[p]=u[m-1]+(u[m]-u[m-1])*g}}o.push(d)}return o}var Gu=1/Math.sqrt(3),Ju=1/Math.sqrt(6),dv=1/Math.sqrt(2),$Pe=[Gu,Gu,Gu,Ju,Ju,-2*Ju,dv,-dv,0],eSe=[Gu,Ju,dv,Gu,Ju,-dv,Gu,-2*Ju,0];function mv(e,t,n="mvgd"){let i=e.w*e.h,r=h=>Math.min(go-1,Math.max(0,Math.round(ro(h)*(go-1)))),o=(h,v)=>{let g=new Float32Array(i*3);for(let y=0;y<3;y++){let w=v[y];for(let x=0;x<i;x++)g[x*3+y]=w[r(h.data[x*3+y])]}return{data:g,w:h.w,h:h.h}},a=i4(e,t),s=o(e,a),c=rD(s),l=rD(t),u;if(n==="mkl")u=Boe(c.cov,l.cov);else if(n==="coral")u=Yoe(c.cov,l.cov);else if(n==="adain"){let h=new Float64Array(9);for(let v=0;v<3;v++){let g=Math.sqrt(Math.max(c.cov[v*3+v],0)),y=Math.sqrt(Math.max(l.cov[v*3+v],0));h[v*3+v]=g>1e-12?y/g:1}u=h}else u=Koe(s,t,c,l);let f=Joe(s,u,c.mean,l.mean),d={data:Float32Array.from(f.data,ro),w:e.w,h:e.h},m=i4(d,t),p=o(d,m),b=[l.mean[0]-(u[0]*c.mean[0]+u[1]*c.mean[1]+u[2]*c.mean[2]),l.mean[1]-(u[3]*c.mean[0]+u[4]*c.mean[1]+u[5]*c.mean[2]),l.mean[2]-(u[6]*c.mean[0]+u[7]*c.mean[1]+u[8]*c.mean[2])];return{hm1:a,matrix:Array.from(u),offset:b,mid:d,hm2:m,image:p}}function oD(e,t,n=1){let i=e.w*e.h,r=new Float32Array(i*3),o=[Math.pow(t[0],n),Math.pow(t[1],n),Math.pow(t[2],n)];for(let a=0;a<i;a++)for(let s=0;s<3;s++){let c=za(Math.min(1,Math.max(0,e.data[a*3+s])))*o[s];r[a*3+s]=S9(c<0?0:c>1?1:c)}return{data:r,w:e.w,h:e.h}}function iD(e){let t=Math.hypot(e[0],e[1],e[2]);return t>0?[e[0]/t,e[1]/t,e[2]/t]:[1/Math.sqrt(3),1/Math.sqrt(3),1/Math.sqrt(3)]}function s4(e,t){let n=iD(e),i=iD(t),r=n[0]*i[0]+n[1]*i[1]+n[2]*i[2],o=[n[1]*i[2]-n[2]*i[1],n[2]*i[0]-n[0]*i[2],n[0]*i[1]-n[1]*i[0]],a=Math.hypot(o[0],o[1],o[2]);return Math.atan2(a,r)*180/Math.PI}function aD(e,t,n){return .2126*e+.7152*t+.0722*n}function Qoe(e,t){let n=e.length;if(n===0)return 0;if(n===1)return e[0];let i=Math.min(n-1,Math.max(0,t*(n-1))),r=Math.floor(i),o=Math.min(n-1,r+1),a=i-r;return e[r]+a*(e[o]-e[r])}function c4(e,t,n=4,i=6e4){let r=e.w*e.h,o=Math.max(1,Math.floor(r/i)),a=new Float32Array(Math.ceil(r/o)),s=0;for(let l=0;l<r;l+=o){let u=za(Math.max(0,Math.min(1,e.data[l*3]))),f=za(Math.max(0,Math.min(1,e.data[l*3+1]))),d=za(Math.max(0,Math.min(1,e.data[l*3+2]))),m=aD(u,f,d);if(m<=1e-5||Math.max(u,f,d)>=.99)continue;let p=za(Math.max(0,Math.min(1,t.data[l*3]))),b=za(Math.max(0,Math.min(1,t.data[l*3+1]))),h=za(Math.max(0,Math.min(1,t.data[l*3+2]))),v=aD(p,b,h)/m;!Number.isFinite(v)||v<=0||(a[s++]=Math.max(-n,Math.min(n,Math.log2(v))))}if(s===0)return 0;let c=a.subarray(0,s);return c.sort(),Qoe(c,.5)}var pv={note:"Measured from DaVinci Resolve Studio 21 EXR renders of a 16-bit ramp chart (drt-color-re/render_grade.py batch 5, 2026-08-11). Absolute per-amplitude deltas vs the neutral render; regenerate with gen_wheel_basis.py.",x:[0,.033351,.066701,.100052,.133403,.166754,.200104,.233455,.266806,.300156,.333507,.366858,.400208,.433559,.46691,.500261,.533611,.566962,.600313,.633663,.667014,.700365,.733715,.767066,.800417,.833768,.867118,.900469,.93382,.96717,1],controls:{shadow:{amps:[-.4,-.2,-.1,.05,.1,.2,.3,.4],curves:{"-0.40":[-.4,-.361005,-.320961,-.28089,-.240827,-.200775,-.160651,-.119559,-.084823,-.054151,-.028079,-.007759,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"-0.20":[-.2,-.180746,-.160725,-.140689,-.120659,-.100632,-.08057,-.060049,-.042665,-.027551,-.014705,-.004394,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"-0.10":[-.1,-.090617,-.080607,-.070588,-.060574,-.05056,-.040529,-.030279,-.021573,-.014076,-.007709,-.002511,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.05":[.01665,.014519,.01285,.011184,.009514,.007848,.006178,.004433,.003088,.001785,631e-6,-218e-6,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.10":[.0333,.029526,.02619,.022856,.019518,.016185,.012843,.009357,.006657,.004041,.00172,24e-6,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.20":[.0666,.059539,.052869,.046199,.039526,.032859,.026174,.019208,.013791,.008561,.003926,527e-6,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.30":[.0999,.089552,.079548,.069542,.059534,.049533,.039505,.029067,.020915,.013093,.006169,.001059,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.40":[.1332,.119565,.106227,.092886,.079542,.066207,.052837,.038936,.028026,.017634,.008453,.001622,-487e-6,-487e-6,-493e-6,-492e-6,-49e-5,-49e-5,-488e-6,-49e-5,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6]}},midtone:{amps:[-.4,-.2,-.1,.1,.2,.4],curves:{"-0.40":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-451e-6,263e-6,-.003632,-.010819,-.020501,-.032238,-.047185,-.059943,-.066296,-.060685,-.040876,-.017385,-303e-6,-447e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"-0.20":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-466e-6,-57e-6,-.002523,-.007541,-.014006,-.020949,-.027712,-.032192,-.033342,-.029182,-.019455,-.008585,-391e-6,-467e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"-0.10":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-476e-6,-266e-6,-.001602,-.004451,-.00808,-.011811,-.014895,-.016618,-.016765,-.014464,-.00969,-.004462,-438e-6,-478e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.10":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-509e-6,-938e-6,.001249,.004662,.008518,.012261,.014922,.015752,.01505,.012601,.007936,.002742,-514e-6,-496e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.20":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-53e-5,-.001381,.00303,.010093,.018105,.0258,.030902,.031857,.029403,.023831,.014993,.005523,-542e-6,-502e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6],"+0.40":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-571e-6,-.002236,.006718,.021856,.039117,.055211,.063967,.062345,.052975,.039586,.02427,.009349,-592e-6,-514e-6,-488e-6,-487e-6,-489e-6,-488e-6,-49e-5,-488e-6,-491e-6,-489e-6,-488e-6,-49e-5,-489e-6]}},highlight:{amps:[-.4,-.2,-.1,.1,.2,.4],curves:{"-0.40":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-49e-6,-.001378,-.005676,-.012124,-.02034,-.033741,-.0471,-.060436,-.073779,-.087121,-.100459,-.1138,-.127144,-.14048,-.153821,-.167165,-.180293],"-0.20":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-285e-6,-921e-6,-.003101,-.006371,-.010411,-.017115,-.023794,-.030461,-.037134,-.043804,-.050474,-.057144,-.063817,-.070484,-.077154,-.083827,-.090391],"-0.10":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-392e-6,-703e-6,-.001797,-.003442,-.005449,-.008802,-.012141,-.015474,-.018812,-.022146,-.025482,-.028816,-.032154,-.035487,-.038821,-.042159,-.04544],"+0.10":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-913e-6,207e-6,.002501,.005682,.010558,.017987,.025407,.032818,.040228,.047642,.055048,.062463,.069872,.077283,.084698,.092108,.099403],"+0.20":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-.001308,875e-6,.005478,.011902,.021601,.036463,.051302,.066123,.080944,.095772,.110587,.125414,.140236,.155056,.169883,.184705,.199294],"+0.40":[0,-487e-6,-489e-6,-488e-6,-49e-5,-489e-6,-487e-6,-49e-5,-484e-6,-475e-6,-464e-6,-461e-6,-487e-6,-487e-6,-.002028,.002127,.011361,.024415,.043682,.073414,.103093,.132732,.162378,.192031,.221663,.251316,.280962,.310601,.340254,.3699,.399077]}}},contrast:{cs:[.5,.8,1.25,1.5,1.8],curves:{"0.50":[.2175,.200578,.183907,.167229,.15055,.13388,.117203,.100531,.083854,.067175,.050505,.033828,.017148,479e-6,-.016201,-.032878,-.049548,-.066227,-.082897,-.099576,-.116253,-.132923,-.149602,-.16628,-.182951,-.199629,-.216308,-.232978,-.249655,-.266334,-.282745],"0.80":[.087,.079939,.073269,.066599,.059926,.053259,.046589,.039919,.033249,.026576,.019909,.013239,.006566,-101e-6,-.006775,-.013445,-.020112,-.026785,-.033452,-.040125,-.046795,-.053462,-.060135,-.066805,-.073475,-.080145,-.086818,-.093485,-.100155,-.106828,-.113392],"1.25":[0,-.010727,-.021735,-.032532,-.042279,-.050126,-.055135,-.056541,-.054061,-.047509,-.037623,-.025716,-.013116,-.001136,.010563,.023076,.035617,.047411,.057676,.06563,.070555,.072344,.071151,.067141,.060599,.052178,.042386,.031729,.020695,.009783,-345e-6],"1.50":[0,-.021136,-.043244,-.065419,-.086537,-.105469,-.121116,-.131949,-.135345,-.128698,-.109132,-.077071,-.039172,-.002436,.033276,.07165,.108539,.139821,.161382,.172335,.174591,.16969,.159165,.144656,.12727,.107658,.086487,.064431,.042132,.020262,-196e-6],"1.80":[0,-.030247,-.061752,-.093815,-.125632,-.1564,-.185357,-.21169,-.23463,-.254734,-.26386,-.247374,-.163569,-.008383,.14496,.280152,.328288,.341546,.334832,.316817,.295588,.272004,.245823,.217525,.18759,.15646,.124616,.09254,.060672,.029492,-59e-6]}},pivot_probes:{pivot02_c15:[0,.011586,.023617,.041223,.072432,.128713,.199237,.267856,.339119,.410913,.481153,.547825,.60882,.662121,.707868,.747147,.780708,.809347,.833813,.8549,.873465,.889957,.904721,.918081,.93036,.941903,.953031,.964073,.975367,.987238,.999804],pivot08_c15:[0,.012599,.024474,.035774,.04682,.057941,.069476,.081743,.095087,.109829,.126295,.144829,.165876,.190289,.218866,.252371,.29155,.337202,.39039,.451293,.517901,.588105,.659892,.731177,.799843,.87034,.927,.958466,.976191,.988267,.999805],pivot02_c07:[.06,.083008,.106345,.129696,.153044,.176383,.199734,.223071,.246421,.269769,.293109,.316459,.339807,.363147,.386494,.409845,.433184,.456532,.479872,.50322,.52657,.54991,.573258,.596608,.619945,.643295,.666643,.689983,.713333,.736681,.759657],pivot08_c07:[.24,.263008,.286345,.309696,.333044,.356383,.379734,.403071,.426421,.449769,.473109,.496459,.519807,.543146,.566494,.589845,.613184,.636532,.659872,.68322,.70657,.72991,.753258,.776608,.799945,.823295,.846643,.869983,.893333,.916681,.939657]}};var vo=.435;var fD={shadow:[0,0,0],midtone:[0,0,0],highlight:[0,0,0],contrast:1,pivot:vo};function Bu(e){if(!e)return!0;let t=n=>n.every(i=>Math.abs(i)<1e-9);return t(e.shadow)&&t(e.midtone)&&t(e.highlight)&&Math.abs(e.contrast-1)<1e-9}var mi=pv.x,ws=mi.length;function u4(e){let t=pv.controls[e],n=[],i=[];for(let o of t.amps)n.push(o),i.push(t.curves[`${o>=0?"+":""}${o.toFixed(2)}`]);let r=n.findIndex(o=>o>0);return r<0&&(r=n.length),n.splice(r,0,0),i.splice(r,0,new Array(ws).fill(0)),{amps:n,curves:i}}var $oe=u4("shadow"),eae=u4("midtone"),tae=u4("highlight");function Wc(e,t){if(t<=mi[0])return e[0];let n=ws-1;if(t>=mi[n])return e[n];let i=0,r=n;for(;r-i>1;){let a=i+r>>1;mi[a]<=t?i=a:r=a}let o=(t-mi[i])/(mi[r]-mi[i]);return e[i]+(e[r]-e[i])*o}function l4(e,t,n){if(t===0)return 0;let{amps:i,curves:r}=e,o=i.length-1;if(t<=i[0])return Wc(r[0],n)*(t/i[0]);if(t>=i[o])return Wc(r[o],n)*(t/i[o]);let a=0,s=o;for(;s-a>1;){let l=a+s>>1;i[l]<=t?a=l:s=l}let c=(t-i[a])/(i[s]-i[a]);return Wc(r[a],n)+(Wc(r[s],n)-Wc(r[a],n))*c}var hv=(()=>{let e=pv.contrast,t=e.cs.filter(n=>n>1).map(n=>({c:n,y:e.curves[n.toFixed(2)].map((i,r)=>mi[r]+i)}));return t.unshift({c:1,y:[...mi]}),t})();function sD(e,t){if(t<=e[0])return mi[0];let n=ws-1;if(t>=e[n])return mi[n];let i=0,r=n;for(;r-i>1;){let a=i+r>>1;e[a]<=t?i=a:r=a}let o=(t-e[i])/(e[r]-e[i]);return mi[i]+(mi[r]-mi[i])*o}function nae(e,t){let n=0;for(;n<hv.length-2&&hv[n+1].c<=e;)n++;let i=hv[n],r=hv[n+1],o=(e-i.c)/(r.c-i.c),a=vo,s=new Array(ws);for(let u=0;u<ws;u++){let f=mi[u],d=0,m=1;for(let p=0;p<30;p++){let b=(d+m)/2;sD(i.y,b)*(1-o)+sD(r.y,b)*o<f?d=b:m=b}s[u]=(d+m)/2}let c=s;if(Math.abs(t-a)>1e-6){c=new Array(ws);for(let u=0;u<ws;u++){let f=mi[u],d=f<t?a*(f/t):a+(1-a)*((f-t)/(1-t)),m=Wc(s,d);c[u]=m<a?t*(m/a):t+(1-t)*((m-a)/(1-a))}}let l=0;for(let u=0;u<ws;u++){let f=c[u]<l?l:c[u];c[u]=f<0?0:f>1?1:f,l=c[u]}return c}var cD=NaN,lD=NaN,uD=null;function rae(e,t,n){return t<1?n+t*(e-n):((t!==cD||n!==lD)&&(uD=nae(t,n),cD=t,lD=n),Wc(uD,e))}function xs(e,t,n){let i=e+l4($oe,t.shadow[n],e)+l4(eae,t.midtone[n],e)+l4(tae,t.highlight[n],e);return t.contrast!==1&&(i=rae(i,t.contrast,t.pivot)),i}var dD=[.2126,.7152,.0722];function mD(e,t){let n=t.wheels??fD,i=f4({...t,wheels:void 0,saturation:void 0,mixer:void 0}),r=!Bu(t.wheels),o=e.w*e.h,a=new Float32Array(o*3),s=(l,u)=>{let f=l*i.slope[u]+i.offset[u],d=i.power[u];return d!==1&&(f=f<0?-Math.pow(-f,d):Math.pow(f,d)),r?xs(f,n,u):f};if(o*3>=32768){let u=new Float32Array(12288);for(let f=0;f<3;f++)for(let d=0;d<4096;d++)u[f*4096+d]=s(d/4095,f);for(let f=0;f<o;f++)for(let d=0;d<3;d++){let m=e.data[f*3+d];if(m>=0&&m<=1){let p=m*4095,b=p|0,h=p-b,v=u[d*4096+b];a[f*3+d]=h>0?v+(u[d*4096+b+1]-v)*h:v}else a[f*3+d]=s(m,d)}}else for(let l=0;l<o;l++)for(let u=0;u<3;u++)a[l*3+u]=s(e.data[l*3+u],u);let c=t.saturation??1;if(c!==1)for(let l=0;l<o;l++){let u=.21*a[l*3]+.7*a[l*3+1]+.09*a[l*3+2];for(let f=0;f<3;f++)a[l*3+f]=u+(a[l*3+f]-u)*c}if(!Yu(t.mixer)){let l=bv(t.mixer);for(let u=0;u<o;u++){let f=a[u*3],d=a[u*3+1],m=a[u*3+2];a[u*3]=l[0]*f+l[1]*d+l[2]*m,a[u*3+1]=l[3]*f+l[4]*d+l[5]*m,a[u*3+2]=l[6]*f+l[7]*d+l[8]*m}}return{data:a,w:e.w,h:e.h}}function Yu(e){if(!e)return!0;let t=[1,0,0,0,1,0,0,0,1];return e.every((n,i)=>Math.abs(n-t[i])<1e-9)}function bv(e){let t=e.slice();for(let n=0;n<3;n++){let i=-dD[n];for(let r=0;r<3;r++)i+=dD[r]*e[r*3+n];for(let r=0;r<3;r++)t[r*3+n]-=i}return t}function pD(e,t){if(!Bu(t.wheels)||t.saturation!==void 0&&t.saturation!==1||!Yu(t.mixer)){let l=mD(e,t);for(let u=0;u<l.data.length;u++)l.data[u]=ro(l.data[u]);return l}let n=t.blackPointOffset,i=Math.pow(2,t.exposureStops),r=[t.wbGain[0]*i,t.wbGain[1]*i,t.wbGain[2]*i],o=e.w*e.h,a=new Float32Array(o*3);for(let l=0;l<o;l++)a[l*3]=ro(e.data[l*3]+n[0]),a[l*3+1]=ro(e.data[l*3+1]+n[1]),a[l*3+2]=ro(e.data[l*3+2]+n[2]);let s=oD({data:a,w:e.w,h:e.h},r,1),c=t.power;if(!c||c[0]===1&&c[1]===1&&c[2]===1)return s;for(let l=0;l<o;l++)for(let u=0;u<3;u++){let f=s.data[l*3+u];s.data[l*3+u]=f<=0?0:Math.pow(f,c[u])}return s}function f4(e){let t=Math.pow(2,e.exposureStops),n=e.wbGain.map(a=>Math.pow(a*t,1/2.4)),i=e.blackPointOffset.map((a,s)=>a*n[s]),r=e.power??[1,1,1],o={slope:n,offset:i,power:r};return Bu(e.wheels)||(o.wheels=e.wheels),e.saturation!==void 0&&Math.abs(e.saturation-1)>1e-6&&(o.saturation=e.saturation),Yu(e.mixer)||(o.mixer=e.mixer),o}function iae(e,t,n,i,r,o,a){let c=new Float64Array(1024),l=new Float64Array(1024),u=new Float64Array(1024),f=0;for(let M=0;M<n;M+=i){let L=e[M*3+r],P=t[M*3+r];if(!(L>.004&&L<.996)||!(P>5e-4&&P<.9995))continue;let X=L*1023+.5|0,R=o?o[M]:1;c[X]+=L*R,l[X]+=P*R,u[X]+=R,f++}let d=[],m=[],p=[];for(let M=0;M<1024;M++)u[M]!==0&&(d.push(c[M]/u[M]),m.push(l[M]/u[M]),p.push(u[M]));let b=d.length;if(f<32||b<8)return{slope:1,offset:0,power:1,residual:0,samples:f};let h=0;for(let M=0;M<b;M++)h+=p[M];let v=(M,L,P)=>{let X=0;for(let R=0;R<b;R++){let I=d[R]*M+L,q=I<=0?0:Math.pow(I,P);X+=p[R]*Math.abs((q>1?1:q)-m[R])}return X/h},g=M=>{let L=0,P=0,X=0,R=0,I=0;for(let j=0;j<b;j++){let C=M===1?m[j]:Math.pow(Math.max(m[j],1e-9),1/M),H=p[j];L+=H,P+=H*d[j],X+=H*d[j]*d[j],R+=H*C,I+=H*d[j]*C}let q=L*X-P*P;if(Math.abs(q)<1e-12)return null;let Y=(L*I-P*R)/q,D=(X*R-P*I)/q;for(let j=0;j<3;j++){let C=0,H=0,ne=0,le=0,Se=0;for(let ut=0;ut<b;ut++){let we=d[ut]*Y+D;if(we<=1e-9)continue;let De=Math.pow(we,M),Je=(De>1?1:De)-m[ut],be=M*Math.pow(we,M-1),Me=be*d[ut],Oe=p[ut];C+=Oe*Me*Me,H+=Oe*Me*be,ne+=Oe*be*be,le+=Oe*Me*Je,Se+=Oe*be*Je}let Le=C*ne-H*H;if(!(Math.abs(Le)>1e-12))break;if(Y-=(ne*le-H*Se)/Le,D-=(C*Se-H*le)/Le,D>0&&(D=0),!(Y>.02&&Y<200)||!Number.isFinite(D))return null}return!(Y>.02&&Y<200)||!Number.isFinite(D)||D>0?null:{s:Y,o:D}},y=a?Math.min(Math.max(1,a[0]),a[1]):1,w=g(y),x=w?{slope:w.s,offset:w.o,power:y,residual:v(w.s,w.o,y),samples:f}:{slope:1,offset:0,power:1,residual:v(1,0,1),samples:f},T=.02,z=160,k=Math.log(a?a[0]:.1),S=Math.log(a?a[1]:5);for(let M=0;M<z;M++){let L=Math.exp(k+(S-k)*M/(z-1)),P=g(L);if(!P)continue;let X=v(P.s,P.o,L);X<x.residual*(1-T)&&(x={slope:P.s,offset:P.o,power:L,residual:X,samples:f})}return x}function gv(e,t,n=4e4,i,r){if(e.w!==t.w||e.h!==t.h)throw new Error(`fitShotAnalysis: size mismatch \u2014 ${e.w}x${e.h} vs ${t.w}x${t.h}`);let o=e.w*e.h;if(i&&i.length!==o)throw new Error(`fitShotAnalysis: weights length ${i.length} != ${o} pixels`);let a=Math.max(1,Math.floor(o/n)),s=[1,1,1],c=[0,0,0],l=[1,1,1],u=[0,0,0],f=0;for(let h=0;h<3;h++){let v=iae(e.data,t.data,o,a,h,i,r?.[h]);s[h]=v.slope,c[h]=v.offset,l[h]=v.power,u[h]=v.residual,f=Math.max(f,v.samples)}let d=s.map(h=>Math.pow(h,2.4)),m=[d[0]/d[1],1,d[2]/d[1]],p=Math.log2(d[1]);return{analysis:{blackPointOffset:[c[0]/s[0],c[1]/s[1],c[2]/s[2]],wbGain:m,exposureStops:p,power:l,castDeg:s4(m,[1,1,1])},lumaStops:c4(e,t),slope:s,offset:c,power:l,residual:u,maxResidual:Math.max(u[0],u[1],u[2]),samples:f}}function hD(e,t,n,i=2e4,r,o){let a=e.w*e.h;if(r&&r.length!==a)throw new Error(`fitLogWheels: weights length ${r.length} != ${a} pixels`);let s=Math.max(1,Math.floor(a/i)),c=1024,l=[[],[],[]],u=[[],[],[]],f=[[],[],[]];for(let k=0;k<3;k++){let S=new Float64Array(c),M=new Float64Array(c),L=new Float64Array(c);for(let P=0;P<a;P+=s){let X=e.data[P*3+k];if(!(X>.002&&X<.998))continue;let R=X*(c-1)+.5|0,I=r?r[P]:1;S[R]+=X*I,M[R]+=t.data[P*3+k]*I,L[R]+=I}for(let P=0;P<c;P++)L[P]!==0&&(l[k].push(S[P]/L[P]),u[k].push(M[P]/L[P]),f[k].push(L[P]))}let d=(k,S)=>S?Math.min(S[1],Math.max(S[0],k)):k,m={shadow:[0,0,0],midtone:[0,0,0],highlight:[0,0,0],contrast:d(1,o?.contrast),pivot:d(vo,o?.pivot)},p=n.wbGain,b=Math.pow(2,n.exposureStops),h=[0,1,2].map(k=>Math.pow(p[k]*b,1/2.4)),v=n.blackPointOffset,g=n.power??[1,1,1],y=[[],[],[]];for(let k=0;k<3;k++)for(let S=0;S<l[k].length;S++){let M=(l[k][S]+v[k])*h[k];g[k]!==1&&(M=M<0?-Math.pow(-M,g[k]):Math.pow(M,g[k])),y[k].push(M)}let w=0;for(let k=0;k<3;k++)for(let S of f[k])w+=S;let x=()=>{let k=0;for(let S=0;S<3;S++)for(let M=0;M<y[S].length;M++){let L=xs(y[S][M],m,S);k+=f[S][M]*Math.abs((L<0?0:L>1?1:L)-u[S][M])}return w?k/w:0},T=(k,S,M)=>{let L=.6180339887,P=S,X=M,R=X-L*(X-P),I=P+L*(X-P);k(R);let q=x();k(I);let Y=x(),D=q,j=Y;for(let H=0;H<18&&X-P>1e-4;H++)D<j?(X=I,I=R,j=D,R=X-L*(X-P),k(R),D=x()):(P=R,R=I,D=j,I=P+L*(X-P),k(I),j=x());let C=D<j?R:I;k(C)},z=x();for(let k=0;k<3;k++){T(M=>{m.contrast=M},Math.max(.4,o?.contrast[0]??.4),Math.min(2.2,o?.contrast[1]??2.2)),T(M=>{m.pivot=M},Math.max(.15,o?.pivot[0]??.15),Math.min(.85,o?.pivot[1]??.85));for(let M=0;M<3;M++)T(L=>{m.shadow[M]=L},-.4,.4),T(L=>{m.midtone[M]=L},-.4,.4),T(L=>{m.highlight[M]=L},-.4,.4);let S=x();if(z-S<1e-5)break;z=S}return Math.abs(m.contrast-1)<1e-4&&(m.contrast=1,m.pivot=vo),{wheels:m,residual:x()}}var Zi=e=>e<0?0:e>1?1:e;function gD(e){let t=e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]);return[(e[4]*e[8]-e[5]*e[7])/t,(e[2]*e[7]-e[1]*e[8])/t,(e[1]*e[5]-e[2]*e[4])/t,(e[5]*e[6]-e[3]*e[8])/t,(e[0]*e[8]-e[2]*e[6])/t,(e[2]*e[3]-e[0]*e[5])/t,(e[3]*e[7]-e[4]*e[6])/t,(e[1]*e[6]-e[0]*e[7])/t,(e[0]*e[4]-e[1]*e[3])/t]}function oae(e,t){let n=e.w*e.h,i=new Float32Array(n*3);for(let r=0;r<3;r++){let o=t[r],a=o.length-1;for(let s=0;s<n;s++){let c=Math.min(a,Math.max(0,Math.round(Zi(e.data[s*3+r])*a)));i[s*3+r]=o[c]}}return{data:i,w:e.w,h:e.h}}function bD(e,t,n=1){let i=0,r=0;for(let o=0;o<e.w*e.h;o+=n){for(let a=0;a<3;a++)i+=Math.abs(Zi(e.data[o*3+a])-Zi(t.data[o*3+a]));r+=3}return i/r}var ESe=.8/255;function vD(e,t,n,i){let r=n??mv(e,t,i?.inner??"mvgd"),o=i?.tone1Contrast??null,a=i?.enableTone2??!0,s=i?.trimContrast??null,c=r.matrix,l=M=>({data:Float32Array.from(M.data,Zi),w:M.w,h:M.h}),u=oae(e,r.hm1),f=m4(e,u),d=r.offset,m=gD(c),p=[m[0]*d[0]+m[1]*d[1]+m[2]*d[2],m[3]*d[0]+m[4]*d[1]+m[5]*d[2],m[6]*d[0]+m[7]*d[1]+m[8]*d[2]],b=e.w*e.h,h=new Float32Array(b*3);for(let M=0;M<b;M++){let L=f.out.data[M*3],P=f.out.data[M*3+1],X=f.out.data[M*3+2];h[M*3]=Zi(c[0]*L+c[1]*P+c[2]*X+d[0]),h[M*3+1]=Zi(c[3]*L+c[4]*P+c[5]*X+d[1]),h[M*3+2]=Zi(c[6]*L+c[7]*P+c[8]*X+d[2])}let v={data:h,w:e.w,h:e.h},g=m4(v,r.image);if(o==null&&a&&s==null){let M=bD(l(g.out),r.image);return{tone1:f.tone,offset:p,matrix:c,tone2:g.tone,tone2Enabled:!0,trim:null,residual:M}}let y=o==null?f.tone:{...f.tone,contrast:o,pivot:f.tone.pivot??.435},w=s==null?null:{slope:[1,1,1],offset:[0,0,0],power:[1,1,1],contrast:s,pivot:.435},x=d4(e,y),T=new Float32Array(b*3);for(let M=0;M<b;M++){let L=x.data[M*3],P=x.data[M*3+1],X=x.data[M*3+2];T[M*3]=Zi(c[0]*L+c[1]*P+c[2]*X+d[0]),T[M*3+1]=Zi(c[3]*L+c[4]*P+c[5]*X+d[1]),T[M*3+2]=Zi(c[6]*L+c[7]*P+c[8]*X+d[2])}let z={data:T,w:e.w,h:e.h},k=a?d4(z,g.tone):z;w&&(k=d4(k,w));let S=bD(k,r.image);return{tone1:y,offset:p,matrix:c,tone2:g.tone,tone2Enabled:a,trim:w,residual:S}}function d4(e,t){let i=t.shadow||t.midtone||t.highlight||t.contrast!==void 0&&Math.abs(t.contrast-1)>1e-9?{shadow:t.shadow??[0,0,0],midtone:t.midtone??[0,0,0],highlight:t.highlight??[0,0,0],contrast:t.contrast??1,pivot:t.pivot??.435}:null,r=new Float32Array(3*4096);for(let a=0;a<3;a++){let s=t.power?.[a]??1;for(let c=0;c<4096;c++){let l=c/4095*t.slope[a]+t.offset[a];s!==1&&(l=l<0?-Math.pow(-l,s):Math.pow(l,s)),i&&(l=xs(l,i,a)),r[a*4096+c]=Zi(l)}}let o=new Float32Array(e.data.length);for(let a=0;a<e.w*e.h;a++)for(let s=0;s<3;s++)o[a*3+s]=r[s*4096+Math.min(4095,Math.max(0,Math.round(Zi(e.data[a*3+s])*4095)))];return{data:o,w:e.w,h:e.h}}function m4(e,t,n){let i=gv(e,t,void 0,n),r=i.analysis,o=hD(e,t,r,void 0,n);o.residual<i.maxResidual&&(r={...r,wheels:o.wheels});let a=pD(e,r),s={data:Float32Array.from(a.data,Zi),w:e.w,h:e.h},c=f4(r);return{tone:{slope:c.slope,offset:c.offset,power:c.power,...c.wheels?{shadow:c.wheels.shadow,midtone:c.wheels.midtone,highlight:c.wheels.highlight,contrast:c.wheels.contrast,pivot:c.wheels.pivot}:{}},out:s}}function p4(e,t,n=16){let{w:i,h:r}=e,o=(s,c)=>.2126*s[c*3]+.7152*s[c*3+1]+.0722*s[c*3+2],a=new Float32Array(i*r);for(let s=0;s<r;s+=n)for(let c=0;c<i;c+=n){let l=0,u=0,f=0,d=0,m=0,p=0,b=Math.min(r,s+n),h=Math.min(i,c+n);for(let x=s;x<b;x++)for(let T=c;T<h;T++){let z=x*i+T,k=o(e.data,z),S=o(t.data,z);l++,u+=k,f+=S,d+=k*k,m+=S*S,p+=k*S}let v=d/l-(u/l)**2,g=m/l-(f/l)**2,y=2e-5,w=v<y&&g<y?1:v<y||g<y?.1:Math.min(1,Math.max(0,((p/l-u/l*(f/l))/Math.sqrt(v*g)-.2)/.6));for(let x=s;x<b;x++)for(let T=c;T<h;T++){let z=x*i+T,k=Math.max(e.data[z*3],e.data[z*3+1],e.data[z*3+2])>.99||Math.max(t.data[z*3],t.data[z*3+1],t.data[z*3+2])>.99;a[z]=k?0:w}}return a}function aae(e,t){let n=[0,1,2,3].map(i=>[e[i*4],e[i*4+1],e[i*4+2],e[i*4+3],t[i]]);for(let i=0;i<4;i++){let r=i;for(let o=i+1;o<4;o++)Math.abs(n[o][i])>Math.abs(n[r][i])&&(r=o);if([n[i],n[r]]=[n[r],n[i]],Math.abs(n[i][i])<1e-12)return i<3?[i===0?1:0,i===1?1:0,i===2?1:0,0]:[0,0,0,0];for(let o=0;o<4;o++)if(o!==i){let a=n[o][i]/n[i][i];for(let s=i;s<5;s++)n[o][s]-=a*n[i][s]}}return n.map((i,r)=>i[4]/i[r])}var sae=0;function yD(e,t,n){if(e.w!==t.w||e.h!==t.h)throw new Error(`pixelFitStages: size mismatch ${e.w}x${e.h} vs ${t.w}x${t.h}`);let i=e.w*e.h,r=n?.weights??p4(e,t),o=new Float64Array(16),a=new Float64Array(12),s=0;for(let T=0;T<i;T++){let z=r[T];if(!z)continue;s+=z;let k=[e.data[T*3],e.data[T*3+1],e.data[T*3+2],1];for(let S=0;S<4;S++){for(let M=0;M<4;M++)o[S*4+M]+=z*k[S]*k[M];for(let M=0;M<3;M++)a[S*3+M]+=z*k[S]*t.data[T*3+M]}}let c=(n?.ridge??sae)*s;for(let T=0;T<3;T++)o[T*4+T]+=c,a[T*3+T]+=c;let l=[0,1,2].map(T=>aae(o,[0,1,2,3].map(z=>a[z*3+T]))),u=l.flatMap(T=>T.slice(0,3)),f=l.map(T=>T[3]),d=gD(u),m=[d[0]*f[0]+d[1]*f[1]+d[2]*f[2],d[3]*f[0]+d[4]*f[1]+d[5]*f[2],d[6]*f[0]+d[7]*f[1]+d[8]*f[2]],p=new Float32Array(i*3);for(let T=0;T<i;T++){let z=e.data[T*3],k=e.data[T*3+1],S=e.data[T*3+2];for(let M=0;M<3;M++)p[T*3+M]=Zi(u[M*3]*z+u[M*3+1]*k+u[M*3+2]*S+f[M])}let b={data:p,w:e.w,h:e.h},h=T=>{let z=0,k=0;for(let S=0;S<i;S++){let M=r[S];M&&(z+=M*(Math.abs(T.data[S*3]-t.data[S*3])+Math.abs(T.data[S*3+1]-t.data[S*3+1])+Math.abs(T.data[S*3+2]-t.data[S*3+2])),k+=3*M)}return k?z/k:0},v=m4(b,t,r),g=h(b),y=h(v.out),w=y<g-.5/255;return{tone1:{slope:[1,1,1],offset:[0,0,0],power:[1,1,1]},offset:m,matrix:u,tone2:v.tone,tone2Enabled:w,trim:null,residual:w?y:g,trustedShare:s/i}}function wD(e){let{wheels:t,...n}=e;return{...n,...t?{shadow:t.shadow,midtone:t.midtone,highlight:t.highlight,contrast:t.contrast,pivot:t.pivot}:{}}}function xD(e){if(e.mixerLumaLock!==!1||Yu(e.mixer))return!1;let t=(o,a)=>Math.abs(o-a)<1e-9,n=e.power??[1,1,1],i=e.curves,r=!!i&&[i.r,i.g,i.b].some(o=>o&&o.length>=2);return[0,1,2].every(o=>t(n[o],1))&&PD(e)===null&&!r}function cae(e,t){if(t<=e[0][0])return e[0][1];let n=e[e.length-1];if(t>=n[0])return n[1];let i=0,r=e.length-1;for(;r-i>1;){let l=i+r>>1;e[l][0]<=t?i=l:r=l}let[o,a]=e[i],[s,c]=e[r];return s>o?a+(c-a)*(t-o)/(s-o):a}var Xa=[.21,.7,.09];function PD(e){if(!e.shadow&&!e.midtone&&!e.highlight&&e.contrast===void 0)return null;let t=i=>[i?.[0]??0,i?.[1]??0,i?.[2]??0],n={shadow:t(e.shadow),midtone:t(e.midtone),highlight:t(e.highlight),contrast:e.contrast??1,pivot:e.pivot??vo};return Bu(n)?null:n}function SD(e,t){if(xD(e))return a=>a;let n=PD(e),i=e.power??[1,1,1],r=[e.curves?.r,e.curves?.g,e.curves?.b].map(a=>a&&a.length>=2?a:null),o=a=>a<0?0:a>1?1:a;return(a,s)=>{let c=a*e.slope[s]+e.offset[s],l=i[s];l!==1&&(c=c<0?-Math.pow(-c,l):Math.pow(c,l)),n&&(c=xs(c,n,s));let u=r[s];return u&&(c=cae(u,o(c))),t?o(c):c}}function kD(e){let t=e.saturation??1,n=Math.abs(t-1)>1e-9,i=!Yu(e.mixer),r=xD(e);if(!n&&!i&&!r)return null;let o=[t+(1-t)*Xa[0],(1-t)*Xa[1],(1-t)*Xa[2],(1-t)*Xa[0],t+(1-t)*Xa[1],(1-t)*Xa[2],(1-t)*Xa[0],(1-t)*Xa[1],t+(1-t)*Xa[2]];if(i){let s=e.mixerLumaLock===!1?e.mixer:bv(e.mixer),c=new Array(9);for(let l=0;l<3;l++)for(let u=0;u<3;u++)c[l*3+u]=s[l*3]*o[u]+s[l*3+1]*o[3+u]+s[l*3+2]*o[6+u];o=c}let a=[0,0,0];if(r){let s=e.slope,c=e.offset;for(let l=0;l<3;l++){a[l]=o[l*3]*c[0]+o[l*3+1]*c[1]+o[l*3+2]*c[2];for(let u=0;u<3;u++)o[l*3+u]*=s[u]}}return{m:o,add:a}}var qm=-1,Ps=-1,zD=!1,b4=.35,lae=[.25,-.5,Math.log(.25)],uae=[4,.5,Math.log(4)],Co=-1;function h4(e){let t={slope:[e[0],e[1],e[2]],offset:[e[3],e[4],e[5]],power:[Math.exp(e[6]),Math.exp(e[7]),Math.exp(e[8])],contrast:e[9],pivot:qm>=0?e[qm]:vo,saturation:e[10]};if(Co>=0&&(t.master={slope:e[Co],offset:e[Co+1],power:Math.exp(e[Co+2])}),Ps>=0){let n=e.slice(Ps,Ps+6);t.mixer=[1,n[0],n[1],n[2],1,n[3],n[4],n[5],1],zD&&(t.mixerLumaLock=!1)}return e.length-(qm>=0?1:0)-(Ps>=0?6:0)-(Co>=0?3:0)>11&&(t.shadow=[e[11],e[12],e[13]],t.midtone=[e[14],e[15],e[16]],t.highlight=[e[17],e[18],e[19]]),t}var fae=[.25,.25,.25,-.5,-.5,-.5,Math.log(.25),Math.log(.25),Math.log(.25),.5,0,...Array(9).fill(-.3)],dae=[4,4,4,.5,.5,.5,Math.log(4),Math.log(4),Math.log(4),2,2,...Array(9).fill(.3)],mae=e=>e.map((t,n)=>n===qm?Math.min(.9,Math.max(.1,t)):Co>=0&&n>=Co?Math.min(uae[n-Co],Math.max(lae[n-Co],t)):Ps>=0&&n>=Ps&&n<Ps+6?Math.min(b4,Math.max(-b4,t)):Math.min(dae[n],Math.max(fae[n],t))),vv=(e,t)=>t===1?e:e<0?-Math.pow(-e,t):Math.pow(e,t);function TD(e,t,n,i){let r=e.master,o=r?{...e,slope:[1,1,1],offset:[0,0,0],power:[1,1,1]}:{...e},a=SD(o,!1),s=kD(o);for(let c=0;c<t.length;c+=3){let l,u,f;if(r){let d=t[c],m=t[c+1],p=t[c+2],b=vv(d*e.slope[0]+e.offset[0],e.power[0]),h=vv(m*e.slope[1]+e.offset[1],e.power[1]),v=vv(p*e.slope[2]+e.offset[2],e.power[2]),g=.2126*b+.7152*h+.0722*v,y=.2126*d+.7152*m+.0722*p,w=vv(y*r.slope+r.offset,r.power);l=a(b-g+w,0),u=a(h-g+w,1),f=a(v-g+w,2)}else l=a(t[c],0),u=a(t[c+1],1),f=a(t[c+2],2);if(s){let d=s.m,m=s.add,p=d[0]*l+d[1]*u+d[2]*f+m[0],b=d[3]*l+d[4]*u+d[5]*f+m[1],h=d[6]*l+d[7]*u+d[8]*f+m[2];l=p,u=b,f=h}n[c]=l,n[c+1]=u,n[c+2]=f}i?.(n);for(let c=0;c<n.length;c++)n[c]=n[c]<0?0:n[c]>1?1:n[c]}function pae(e,t,n){let i=e.slice(),r=t.slice();for(let a=0;a<n;a++){let s=a;for(let l=a+1;l<n;l++)Math.abs(i[l*n+a])>Math.abs(i[s*n+a])&&(s=l);if(s!==a){for(let l=0;l<n;l++)[i[a*n+l],i[s*n+l]]=[i[s*n+l],i[a*n+l]];[r[a],r[s]]=[r[s],r[a]]}let c=i[a*n+a]||1e-12;for(let l=a+1;l<n;l++){let u=i[l*n+a]/c;if(u){for(let f=a;f<n;f++)i[l*n+f]-=u*i[a*n+f];r[l]-=u*r[a]}}}let o=new Array(n).fill(0);for(let a=n-1;a>=0;a--){let s=r[a];for(let c=a+1;c<n;c++)s-=i[a*n+c]*o[c];o[a]=s/(i[a*n+a]||1e-12)}return o}function g4(e,t,n={}){if(n.matchChroma&&n.matchStats===void 0&&(n={...n,matchStats:1}),e.w!==t.w||e.h!==t.h)throw new Error(`fitPrimaries: size mismatch ${e.w}x${e.h} vs ${t.w}x${t.h}`);let i=e.w*e.h,r=n.samples??6e3;if(n.skinBoost&&n.skinBoost>1){let be=n.weights??new Float32Array(i).fill(1),Me=new Float32Array(i);for(let Oe=0;Oe<i;Oe++){if(Me[Oe]=be[Oe],!be[Oe])continue;let bt=t.data[Oe*3]*255,tt=t.data[Oe*3+1]*255,zt=t.data[Oe*3+2]*255,Ht=.299*bt+.587*tt+.114*zt,Mt=128-.168736*bt-.331264*tt+.5*zt,mt=128+.5*bt-.418688*tt-.081312*zt;(n.skinRegion===void 0||n.skinRegion!==null&&n.skinRegion[Oe]>1)&&Mt>=77&&Mt<=127&&mt>=133&&mt<=173&&Ht>40&&Ht<235&&(Me[Oe]=be[Oe]*n.skinBoost)}n={...n,weights:Me}}let o=[];for(let be=0;be<i;be++)(!n.weights||n.weights[be]>0)&&o.push(be);let a=[],s=Math.max(1,o.length/r);for(let be=0;be<o.length&&a.length<r;be+=s)a.push(o[Math.floor(be)]);let c=a.length,l=new Float64Array(c*3),u=new Float64Array(c*3),f=new Float64Array(c);a.forEach((be,Me)=>{for(let Oe=0;Oe<3;Oe++)l[Me*3+Oe]=e.data[be*3+Oe],u[Me*3+Oe]=t.data[be*3+Oe];f[Me]=Math.sqrt(n.weights?n.weights[be]:1)});let d=(n.wheels?20:11)+(n.freePivot?1:0)+(n.mixer||n.mixerRaw?6:0)+(n.lumMix100?3:0),m=[1,1,1,0,0,0,0,0,0,1,1,...n.wheels?Array(9).fill(0):[],...n.freePivot?[vo]:[],...n.mixer||n.mixerRaw?Array(6).fill(0):[]];Co=n.lumMix100?d-3:-1,n.lumMix100&&(m=[...m,1,0,0]),Ps=n.mixer||n.mixerRaw?d-6-(n.lumMix100?3:0):-1,zD=!!n.mixerRaw,b4=n.mixerRaw?1.5:.35,qm=n.freePivot?d-1-(n.mixer||n.mixerRaw?6:0)-(n.lumMix100?3:0):-1;let p=[.2126,.7152,.0722],b=n.keepTone;b&&(m=[...b.slope,...b.offset,...b.power.map(Math.log),b.contrast,b.saturation,...m.slice(11)]);let h=be=>{if(n.balanceOnly&&(be[7]=be[6],be[8]=be[6]),b){let Me=p[0]*be[0]+p[1]*be[1]+p[2]*be[2],Oe=p[0]*b.slope[0]+p[1]*b.slope[1]+p[2]*b.slope[2];for(let zt=0;zt<3;zt++)be[zt]*=Oe/Me;let bt=p[0]*be[3]+p[1]*be[4]+p[2]*be[5],tt=p[0]*b.offset[0]+p[1]*b.offset[1]+p[2]*b.offset[2];for(let zt=3;zt<6;zt++)be[zt]+=tt-bt}return be};if(n.lumMix100){let be=h;h=Me=>{be(Me);let Oe=p[0]*Me[0]+p[1]*Me[1]+p[2]*Me[2];for(let tt=0;tt<3;tt++)Me[tt]/=Oe;let bt=p[0]*Me[3]+p[1]*Me[4]+p[2]*Me[5];for(let tt=3;tt<6;tt++)Me[tt]-=bt;return Me[6]=Me[7]=Me[8]=0,Me}}let v=new Set([...n.balanceOnly?[7,8]:[],...b?[6,7,8,9]:[],...n.lumMix100?[6,7,8]:[],...n.noContrastSat?[9,10]:[]]),g=[1,1,1,0,0,0,0,0,0,1,1,...n.wheels?Array(9).fill(0):[],...n.freePivot?[vo]:[],...n.mixer||n.mixerRaw?Array(6).fill(0):[],...n.lumMix100?[1,0,0]:[]],y=[6,7,8,9],w=0;for(let be=0;be<c;be++)w+=f[be]*f[be];let x=Math.sqrt((n.prior??0)*w),T=[.02,.1,.25,.5,.75,.9,.98],z=be=>{let Me=new Float64Array(c),Oe=0,bt=0;for(let mt=0;mt<c;mt++){let K=be[mt*3],fe=be[mt*3+1],Xe=be[mt*3+2],et=f[mt]*f[mt];bt+=et,Oe+=et*(Math.max(K,fe,Xe)-Math.min(K,fe,Xe)),Me[mt]=.2126*K+.7152*fe+.0722*Xe}let tt=new Float64Array(9),zt=[0,0,0];L.forEach((mt,K)=>{for(let fe of mt){for(let Xe=0;Xe<3;Xe++)tt[K*3+Xe]+=be[fe*3+Xe];zt[K]++}});let Ht=new Float64Array(6),Mt=[0,0];return R.forEach((mt,K)=>{for(let fe of mt){for(let Xe=0;Xe<3;Xe++)Ht[K*3+Xe]+=be[fe*3+Xe];Mt[K]++}}),Me.sort(),[...T.map(mt=>Me[Math.floor(mt*(c-1))]),Oe/bt,...Array.from(tt,(mt,K)=>zt[K/3|0]?mt/zt[K/3|0]:0),...[0,1].flatMap(()=>Array.from(Ht,(mt,K)=>Mt[K/3|0]?mt/Mt[K/3|0]:0))]},k=[];for(let be=0;be<c;be++){let Me=u[be*3],Oe=u[be*3+1],bt=u[be*3+2],tt=.2126*Me+.7152*Oe+.0722*bt;Math.max(Me,Oe,bt)-Math.min(Me,Oe,bt)<.06&&tt>.04&&tt<.96&&k.push(be)}let S=be=>.2126*u[be*3]+.7152*u[be*3+1]+.0722*u[be*3+2];k.sort((be,Me)=>S(be)-S(Me));let M=Math.floor(k.length/3),L=M>=20?[k.slice(0,M),k.slice(M,2*M),k.slice(2*M)]:[[],[],[]],P=[];for(let be=0;be<c;be++){let Me=u[be*3]*255,Oe=u[be*3+1]*255,bt=u[be*3+2]*255,tt=.299*Me+.587*Oe+.114*bt,zt=128-.168736*Me-.331264*Oe+.5*bt,Ht=128+.5*Me-.418688*Oe-.081312*bt;zt>=77&&zt<=127&&Ht>=133&&Ht<=173&&tt>40&&tt<235&&P.push(be)}P.sort((be,Me)=>S(be)-S(Me));let X=Math.floor(P.length/2),R=X>=15?[P.slice(0,X),P.slice(X)]:[[],[]],I=z(u),q=n.matchStats?I.length:0,Y=Math.sqrt((n.matchStats??0)*w*3/Math.max(1,q)),D=c*3+q+y.length,j=new Float64Array(c*3),C=be=>{TD(h4(be),l,j,n.post);let Me=new Float64Array(D);for(let Oe=0;Oe<c*3;Oe++)Me[Oe]=(j[Oe]-u[Oe])*f[Oe/3|0];if(q){let Oe=z(j);for(let bt=0;bt<q;bt++)Me[c*3+bt]=Y*(Oe[bt]-I[bt])}return y.forEach((Oe,bt)=>{Me[c*3+q+bt]=x*(be[Oe]-g[Oe])}),Me},H=be=>{let Me=0;for(let Oe of be)Me+=Oe*Oe;return Me},ne=C(m),le=H(ne),Se=.001,Le=0,ut=n.iterations??80,we=new Float64Array(D*d);for(;Le<ut;Le++){for(let tt=0;tt<d;tt++){if(v.has(tt)){for(let mt=0;mt<D;mt++)we[mt*d+tt]=0;continue}let zt=1e-4,Ht=m.slice();Ht[tt]+=zt,h(Ht);let Mt=C(Ht);for(let mt=0;mt<D;mt++)we[mt*d+tt]=(Mt[mt]-ne[mt])/zt}let be=new Array(d*d).fill(0),Me=new Array(d).fill(0);for(let tt=0;tt<D;tt++){let zt=ne[tt];for(let Ht=0;Ht<d;Ht++){let Mt=we[tt*d+Ht];if(Mt){Me[Ht]+=Mt*zt;for(let mt=Ht;mt<d;mt++)be[Ht*d+mt]+=Mt*we[tt*d+mt]}}}for(let tt of v)be[tt*d+tt]+=1;for(let tt=0;tt<d;tt++)for(let zt=0;zt<tt;zt++)be[tt*d+zt]=be[zt*d+tt];let Oe=!1,bt=!1;for(let tt=0;tt<8;tt++){let zt=be.slice();for(let fe=0;fe<d;fe++)zt[fe*d+fe]*=1+Se;let Ht=pae(zt,Me.map(fe=>-fe),d),Mt=h(mae(m.map((fe,Xe)=>v.has(Xe)?fe:fe+Ht[Xe]))),mt=C(Mt),K=H(mt);if(K<le){bt=(le-K)/Math.max(le,1e-12)<1e-7,m=Mt,le=K,ne=mt,Se=Math.max(Se/3,1e-7),Oe=!0;break}Se*=4}if(!Oe||bt)break}TD(h4(m),l,j,n.post);let De=0,Je=0;for(let be=0;be<c*3;be++){let Me=f[be/3|0]**2;De+=Me*Math.abs(j[be]-u[be]),Je+=Me}return{cdl:h4(m),residual:Je?De/Je:0,iterations:Le}}function MD(e,t,n=8){let i=t.filter(a=>a.x1>a.x0&&a.y1>a.y0&&a.score>0);if(i.length===0)return null;let r=e.w*e.h,o=new Float32Array(r).fill(1);for(let a of i){let s=(a.x0+a.x1)/2*e.w,c=(a.y0+a.y1)/2*e.h,l=Math.max(1,(a.x1-a.x0)/2*e.w),u=Math.max(1,(a.y1-a.y0)/2*e.h),f=Math.max(0,Math.floor(s-2.5*l)),d=Math.min(e.w,Math.ceil(s+2.5*l)),m=Math.max(0,Math.floor(c-2.5*u)),p=Math.min(e.h,Math.ceil(c+2.5*u));for(let b=m;b<p;b++){let h=(b-c)/u;for(let v=f;v<d;v++){let g=(v-s)/l,y=g*g+h*h,w=1+(n-1)*a.score*Math.exp(-y/(2*.45)),x=b*e.w+v;w>o[x]&&(o[x]=w)}}}return o}var OD=()=>({slope:[1,1,1],offset:[0,0,0],power:[1,1,1]});function v4(e,t){let n=yv(t),i="engine"in e&&e.engine==="ai"?e:null,r=i?i.transferred?"AI Color Transfer":"AI Auto Balance":"Auto Balance",o={source:i?i.transferred?"ai_color_transfer_v1":"ai_balance_v1":"auto_balance_v1",castDeg:e.analysis.castDeg,exposureStops:e.analysis.exposureStops,wbGain:e.analysis.wbGain,blackPointOffset:e.analysis.blackPointOffset,framesUsed:e.framesUsed,transfer:e.transfer,...i?{seed:i.seed,prompt:i.prompt,fitResidual:i.fitResidual,inferenceMs:i.inferenceMs,matchMethod:i.matchMethod,gradeStyle:i.gradeStyle,usesLogWheels:e.cdl.wheels!==void 0,usesSaturation:e.cdl.saturation!==void 0,facesDetected:i.facesDetected,skinWeighted:i.skinWeighted}:{}};if(i?.fold){let s=i.fold;return[{id:n[0],kind:"cdl",label:`${r} \xB7 tone 1`,enabled:!0,cdl:{...s.tone1},meta:o},{id:n[1],kind:"cdl",label:`${r} \xB7 match matrix`,enabled:!0,cdl:{...OD(),offset:s.offset,mixer:s.matrix,mixerLumaLock:!1},meta:{source:o.source,part:"2/4"}},{id:n[2],kind:"cdl",label:`${r} \xB7 tone 2`,enabled:s.tone2Enabled??!0,cdl:{...s.tone2},meta:{source:o.source,part:"3/4"}},...s.trim?[{id:n[3],kind:"cdl",label:`${r} \xB7 trim`,enabled:!0,cdl:{...OD(),contrast:s.trim.contrast,pivot:s.trim.pivot},meta:{source:o.source,part:"4/4"}}]:[]]}let a=wD(e.cdl);return[{id:n[0],kind:"cdl",label:r,enabled:!0,cdl:a,meta:o}]}function yv(e){let t=e?`@${e}`:"";return[`auto-balance${t}`,`auto-balance${t}-2`,`auto-balance${t}-3`,`auto-balance${t}-4`]}function LD(e,t,n,i){let r=v4(e,i),o=new Set(r.map(s=>s.id)),a=i?[...yv(i),...yv()]:yv();return[...r.map(s=>({timeline_id:t,item_id:n,entry:s})),...a.filter(s=>!o.has(s)).map(s=>({timeline_id:t,item_id:n,remove_id:s}))]}async function XD(e){await ni();try{return Ym(U4(e))}catch{return null}}async function ND(e){await ni();try{return Ym(C4(e))}catch{return null}}var yo=Math.pow,y4=Math.abs,RD=Math.sqrt,w4=Math.exp,x4=Math.log,Ku=Math.log2,pi=Math.log10,Xr=Math.max,hae=Math.min,Hm=e=>2**e,Ur=e=>10**e,P4=(e,t)=>t<0||Object.is(t,-0)?-Math.abs(e):Math.abs(e),S4=(e,t,n)=>Math.min(Math.max(e,t),n),FD=[[1.00000368,-515198584e-15,-515198585e-15,-515198616e-15,1.00000368,-515198585e-15,-515198572e-15,-515198591e-15,1.00000368],[1.3283766,-.213535123,-.114806713,-.0131647719,.912903039,.100298097,.0983208714,.0796202945,.822095761],[.91485402,.00284464831,.082300271,.0311847086,.783316716,.185499076,.0674001183,.0855864176,.847013637],[.885059491,.103594767,.011348535,.0692279832,.919431107,.0113425625,.075369767,.0527967473,.871835841],[.99739712,-.0231662641,.0257692126,-.00918353172,.917632516,.0915523025,.0734886088,.093706093,.83280779],[.999999513,594083242e-14,594083241e-14,59408323e-13,.999999513,594083241e-14,594083244e-14,594083241e-14,.999999513],[.915392376,.111481322,-.0268837717,.0315093793,.912062715,.0564183595,.0539772892,.0767111453,.869301769],[1.01388821,-.0133451286,-.000553929226,-.00764941028,.986632885,.0210044931,.0675794637,-.0767402369,1.0091491],[.562769234,.32351647,.113716987,.0777569207,.74957615,.172669093,.0646713865,.191999033,.743331835],[.562763384,.323512938,.113712941,.077751854,.74957252,.172664934,.0646663168,.191995547,.743327331],[.562768974,.323517012,.113717437,.0777571756,.749576184,.172669465,.0646714537,.191999725,.743331502],[.906045424,.0776579414,.0162703378,.0496278728,.912843186,.0375012464,.0590268875,.038018816,.902928655],[1.11683939,-.178448648,.061597207,-.0102851182,.91916553,.0911099443,.0822863513,.082273997,.835430904],[.687688759,.189241013,.123086555,.0623075684,.749049224,.188658016,.0581538012,.129275981,.812584092],[.673521912,.201597163,.124897287,.0603385952,.750033918,.189642207,.0565531092,.12707993,.816380997],[.630231651,.247575576,.122209243,.0547055408,.757814867,.187494097,.0531260313,.13892445,.807963474],[.958788747,.0134176677,.0277953094,.00862222369,.898149502,.0932308985,.0654375657,.090931855,.843633568],[1.04618357,-.0821764172,.0359915517,.00299958567,.962281479,.034719491,.018300977,-.168021609,1.14971961],[.618130671,.264160079,.11770036,.0511006943,.762272078,.186618224,.0358150706,.110415519,.853760447],[.892108973,.0243698849,.0835184974,.0326174513,.786134934,.181245441,.0699777221,.104750152,.825269679],[.562767908,.323515292,.113716491,.077756134,.749574616,.172668145,.0646708499,.191997876,.743330321],[.996644264,-.0267422383,.0300872533,.0089598248,.925295128,.0657350315,.0680179717,.0977025194,.834269802],[.99664269,-.02674189,.0300880855,.00896030872,.925294707,.0657357244,.0680184217,.0977029445,.834269456],[.852787691,.132476445,.0147381578,-.014981672,.987029187,.0279531835,.0379094789,.0916796162,.870413593],[.562763627,.323513615,.113714016,.0777527842,.74957256,.172665736,.0646674598,.191996382,.74332738],[.562763627,.323513615,.113714016,.0777527842,.74957256,.172665736,.0646674598,.191996382,.74332738],[.562768967,.323515949,.113717627,.0777575702,.749574602,.17266932,.0646722317,.191998733,.743330807]],VD=[[.999996315,515195053e-15,515195053e-15,515195085e-15,.999996315,515195053e-15,515195041e-15,515195059e-15,.999996315],[.748240597,.167690132,.084034057,.0208437942,1.11185917,-.132739222,-.0915066835,-.12773937,1.21920886],[1.10080925,.00787752201,-.108685585,-.0236465478,1.3077504,-.284104486,-.0852062433,-.132768368,1.21797438],[1.1409871,-.127800699,-.0131893461,-.0847563762,1.09793569,-.0131808569,-.0935050696,-.0554406252,1.14894334],[1.00540174,.0288831372,-.0342848965,.0191281138,1.10268288,-.121812109,-.090870903,-.126620677,1.21748872],[1.00000049,-59408029e-13,-59408029e-13,-594080279e-14,1.00000049,-59408029e-13,-594080293e-14,-59408029e-13,1.00000049],[1.09463511,-.137394341,.0427693641,-.0337968467,1.10667566,-.0728693005,-.0649864561,-.089126913,1.15412317],[.986385289,.01336226,.000263311082,.00903910733,1.01203247,-.021059546,-.06536767,.0760646734,.989314748],[1.89861262,-.792175792,-.106439986,-.168953481,1.48898092,-.320029486,-.121543302,-.315675691,1.43721676],[1.89862401,-.792177065,-.106436176,-.168945232,1.48898123,-.320025345,-.121535003,-.315675991,1.43722184],[1.89861419,-.79217754,-.106440622,-.168954217,1.48898181,-.320030365,-.121543317,-.315677224,1.437218],[1.10988175,-.0937497351,-.016105834,-.0574587847,1.10223009,-.0447434335,-.0701366045,-.0402819509,1.11044407],[.903449996,.183147864,-.0865859615,.0191163799,1.10254344,-.121650021,-.0908685379,-.12661876,1.21749563],[1.49843277,-.353560479,-.144889507,-.101709172,1.41475121,-.313056983,-.0910564321,-.199773126,1.29081609],[1.53154193,-.387193916,-.144365343,-.100332731,1.41326403,-.31294607,-.0904763604,-.193170193,1.28363286],[1.64213411,-.512759105,-.129392805,-.0959087304,1.4081623,-.31226806,-.0914843341,-.208409566,1.29988029],[1.04535104,-.0122670343,-.0330856785,-.00163687728,1.12601787,-.124383577,-.0809076189,-.12041741,1.20132189],[.956200995,.0760296483,-.0322294826,-.00241871347,1.03355388,-.0311357753,-.0155740655,.149834766,.86574008],[1.67056585,-.563401409,-.107155622,-.0979342425,1.3877905,-.289847234,-.0574142007,-.15584623,1.21326939],[1.13030634,-.0203939197,-.109909748,-.0255482353,1.31085413,-.28530381,-.0926001325,-.164655328,1.25725793],[1.89861596,-.792175918,-.106440427,-.1689524,1.48898259,-.320028905,-.121543011,-.315675008,1.437219],[1.00572255,.0331725183,-.0388843341,-.0039462376,1.08967311,-.0857168323,-.0815343557,-.130317716,1.21186166],[1.00572422,.0331723362,-.0388854268,-.00394667363,1.08967374,-.0857178026,-.0815350148,-.130318402,1.21186243],[1.17054769,-.155731372,-.0148188505,.0192685123,1.01360896,-.0328781397,-.0530108709,-.0999795801,1.15298754],[1.89862513,-.79217867,-.10643786,-.168947023,1.48898279,-.320026777,-.121537359,-.31567669,1.43722279],[1.89862513,-.79217867,-.10643786,-.168947023,1.48898279,-.320026777,-.121537359,-.31567669,1.43722279],[1.89861492,-.792176711,-.106441665,-.168955179,1.48898484,-.320030887,-.121545458,-.315675558,1.43721925]],k4=[0,27,14,1,2,28,13,23,7,8,9,6,11,24,12,16,17,18,22,25,10,5,15,26,4,3,19],bae=[100.000012,65504,65504,55.0795767,469.8,1,12.0000021,222.860944,8.29590938,65.8161133,16.2981127,13.5216946,41.9993927,7.28132488,58.250874,1,1,1,1,14.7808634,46.085528,184.322348,1,9.73759126,13.7582741,38.4209343,1];function gae(e){return e<=.02740668?e/10.44426855:Hm(e/.07329248-7)-.0075}function vae(e){return e<=.00262409?e*10.44426855:(Ku(e+.0075)+7)*.07329248}function yae(e){return e>5.367655*.010591+.092809?(Ur((e-.385537)/.24719)-.052272)/5.555556:(e-.092809)/5.367655}function wae(e){return e>.010591?.24719*pi(Xr(5.555556*e+.052272,1e-10))+.385537:5.367655*e+.092809}function xae(e){return e<0?e*.113597209+-.0180569961:(Hm(14*(e-.0928641251)/.907135875+6)-64)/2231.82631}function Pae(e){return e<-.0180569961?(e- -.0180569961)/.113597209:(Ku(Xr(2231.82631*e+64,1e-10))-6)/14*.907135875+.0928641251}function Sae(e){return e>=171.2102946929/1023?Ur((e*1023-420)/261.5)*.19-.01:(e*1023-95)*.01125/(171.2102946929-95)}function kae(e){return e>=.01125?(420+pi((Xr(e,-.0099)+.01)/.19)*261.5)/1023:(e*(171.2102946929-95)/.01125+95)/1023}function Tae(e){let t=(e*1023-64)/876;return t>=.030001222851889303?219*(Ur((t-.646596)/.432699)-.037584)/155*.9:(t-.030001222851889303)/3.53881278538813*.9}function zae(e){let t=e/.9;return((t>=0?.432699*pi(155*t/219+.037584)+.646596:t*3.53881278538813+.030001222851889303)*876+64)/1023}function Mae(e){return e<0?e/15.1927-.01:(Ur(e/.224282)-1)/155.975327-.01}function Oae(e){let t=e+.01;return t<0?t*15.1927:.224282*pi(t*155.975327+1)}function Lae(e){let t=Ur(-1.9666666666666666);return(Ur((e*1023-685)/300)-t)/(1-t)}function Xae(e){let t=Ur(-1.9666666666666666);return(685+300*pi(Xr(e*(1-t)+t,1e-10)))/1023}function Nae(e){return e<.12512248?-(Ur((.12512248-e)/.45310179)-1)/10.1596:(Ur((e-.12512248)/.45310179)-1)/10.1596}function Rae(e){return e<0?-.45310179*pi(1-10.1596*e)+.12512248:.45310179*pi(10.1596*e+1)+.12512248}function Fae(e){return e<.092864125?-(Ur((.092864125-e)/.24136077)-1)/87.099375:(Ur((e-.092864125)/.24136077)-1)/87.099375}function Vae(e){return e<0?-.24136077*pi(1-87.099375*e)+.092864125:.24136077*pi(87.099375*e+1)+.092864125}function jae(e){return e<.097465473?-(Ur((.12783901-e)/.36726845)-1)/14.98325:e<=.15277891?(e-.12512219)/1.9754798:(Ur((e-.12240537)/.36726845)-1)/14.98325}function Zae(e){return e<-.014?-.36726845*pi(1-14.98325*e)+.12783901:e<=.014?1.9754798*e+.12512219:.36726845*pi(14.98325*e+1)+.12240537}function Iae(e){return e<.181?(e-.125)/5.6:Ur((e-.598206)/.241514)-.00873}function Wae(e){return e<.01?5.6*e+.125:.241514*pi(Xr(e+.00873,1e-10))+.598206}function Dae(e){return e<=.14?(e-.0929)*.165972075:(Ur(3.89616*e-2.27752)-.0108)/.9892}function qae(e){return e<=.00781728475?e/.165972075+.0929:(pi(Xr(e*.9892+.0108,1e-10))+2.27752)/3.89616}function Hae(e){return e<.100686685370811?(e-.092864)/8.799461:(Ur((e-.384316)/.245281)-.064829)/5.555556}function Eae(e){return e<889e-6?8.799461*e+.092864:.245281*pi(Xr(5.555556*e+.064829,1e-10))+.384316}function Cae(e){return e>=.208555316?Hm((e-.69336945)/.08550479)-.00964052:e>0?RD(e/47.2871124)+-.05641088:-.05641088}function Uae(e){return e>=.01?.08550479*Ku(e+.00964052)+.69336945:e>-.05641088?47.2871124*(e- -.05641088)*(e- -.05641088):0}function Aae(e){return e<=.155251141552511?(e-.0729055341958355)/10.5402377416545:Hm(e*17.52-9.72)}function Gae(e){return e<=.0078125?10.5402377416545*e+.0729055341958355:(Ku(Xr(e,1e-10))+9.72)/17.52}function T4(e){return e<.081?e/4.5:yo((e+.099)/1.099,1/.45)}function z4(e){return e<.018?4.5*e:1.099*yo(Xr(e,0),.45)-.099}function Ss(e,t){return P4(yo(y4(e),t),e)}function Jae(e){let t=y4(e),n=t<=.04045?t/12.92:yo((t+.055)/1.055,2.4);return P4(n,e)}function Bae(e){let t=y4(e),n=t<=.0031308?t*12.92:1.055*yo(t,1/2.4)-.055;return P4(n,e)}function Yae(e){let t=yo(Xr(e,0),.012683313515655966);return yo(Xr(t-.8359375,0)/(18.8515625-18.6875*t),1/.1593017578125)*100}function Kae(e){let t=yo(Xr(e/100,0),.1593017578125);return yo((.8359375+18.8515625*t)/(1+18.6875*t),78.84375)}function Qae(e){return(e<=.5?e*e/3:(w4((e-.55991073)/.17883277)+.28466892)/12)*10}function _ae(e){let t=Xr(e/10,0);return t<=1/12?RD(3*t):.17883277*x4(Xr(12*t-.28466892,1e-10))+.55991073}function $ae(e){return e<.133883783?(e-.0924657534)/8.28360593:w4((e-.530013339)/.0869287607)-.00549407243}function ese(e){return e<.005?8.28360593*e+.0924657534:.0869287607*x4(Xr(e+.00549407243,1e-10))+.530013339}function tse(e){return e<.100537775223865?(e-.092864)/8.735631:(Ur((e-.790453)/.344676)-.009468)/.555556}function nse(e){return e<89e-5?8.735631*e+.092864:.344676*pi(Xr(.555556*e+.009468,1e-10))+.790453}function rse(e){let t=e*1023;return t<452?yo(t/650,3)-.0075:w4((t-619)/150)}function ise(e){return(e<.328?650*yo(Xr(e+.0075,0),.3333333333333333):150*x4(Xr(e,1e-10))+619)/1023}function ose(e){let t=(e*1023-64)/876;return t>=.030001222851889303?(Ur((t-.646596)/.432699)-.037584)*.9:(t-.030001222851889303)/5*.9}function ase(e){let t=e/.9;return((t>=0?.432699*pi(t+.037584)+.646596:t*5+.030001222851889303)*876+64)/1023}function sse(e){let t=Hm(e*17.52-9.72);return e<-.30136893?(t-152587890625e-16)*2:t}function cse(e){return e<=0?(Ku(Xr(152587890625e-16+e*.5,1e-38))+9.72)/17.52:(Ku(Xr(e,221336e-10))+9.72)/17.52}function jD(e,t){switch(e){case 0:return gae(t);case 1:return yae(t);case 2:return xae(t);case 3:return Sae(t);case 4:return Tae(t);case 5:return Mae(t);case 6:return Lae(t);case 7:return Nae(t);case 8:return Fae(t);case 9:return jae(t);case 10:return Iae(t);case 11:return Dae(t);case 12:return Hae(t);case 13:return Cae(t);case 14:return Aae(t);case 15:return T4(t);case 16:return Ss(t,2.2);case 17:return Ss(t,2.4);case 18:return Ss(t,2.6);case 19:return Jae(t);case 20:return Yae(t);case 21:return Qae(t);case 22:return t;case 23:return $ae(t);case 24:return tse(t);case 25:return rse(t);case 26:return ose(t);case 27:return sse(t);default:return Ss(t,2.19921875)}}function ZD(e,t){switch(e){case 0:return vae(t);case 1:return wae(t);case 2:return Pae(t);case 3:return kae(t);case 4:return zae(t);case 5:return Oae(t);case 6:return Xae(t);case 7:return Rae(t);case 8:return Vae(t);case 9:return Zae(t);case 10:return Wae(t);case 11:return qae(t);case 12:return Eae(t);case 13:return Uae(t);case 14:return Gae(t);case 15:return z4(t);case 16:return Ss(t,1/2.2);case 17:return Ss(t,1/2.4);case 18:return Ss(t,1/2.6);case 19:return Bae(t);case 20:return Kae(t);case 21:return _ae(t);case 22:return t;case 23:return ese(t);case 24:return nse(t);case 25:return ise(t);case 26:return ase(t);case 27:return cse(t);default:return Ss(t,1/2.19921875)}}function M4(e,t){return e==18&&(t==1||t==2)?100:bae[e]}function O4(e,t,n,i,r){if(e<0)return e;let o=hae(e,i);return S4(t*o/(o+n),0,r)}var ID=["DWG_COLORSPACE","ACES_AP0_COLORSPACE","ACES_AP1_COLORSPACE","ALEXA3_COLORSPACE","ARRI_LOGC4_COLORSPACE","ADOBE_RGB_COLORSPACE","APPLE_WG_COLORSPACE","CANONLOG2_COLORSPACE","CANONLOG3_COLORSPACE","CANONLOG_COLORSPACE","CINEON_COLORSPACE","DGAMUT_COLORSPACE","FGAMUT_C_COLORSPACE","P3D60_COLORSPACE","P3D65_COLORSPACE","P3DCI_COLORSPACE","VLOG_COLORSPACE","RWG_COLORSPACE","REDCOLOR4_COLORSPACE","REC2020_COLORSPACE","REC709_COLORSPACE","SGAMUT_COLORSPACE","SGAMUT3_COLORSPACE","SGAMUT3CINE_COLORSPACE","VENICE_SGAMUT3_COLORSPACE","VENICE_SGAMUT3CINE_COLORSPACE","SRGB_COLORSPACE"],WD=["DAV_INTER_OETF_GAMMA","ACESCC_GAMMA","ACESCCT_GAMMA","LOGC_EI800_GAMMA","LOGC4_EI800_GAMMA","ADOBE_RGB_GAMMA","APPLE_LOG_GAMMA","BMDFILMV5_GAMMA","CANONLOG_GAMMA","CANONLOG2_GAMMA","CANONLOG3_GAMMA","CINEON_GAMMA","DJI_DLOG_GAMMA","FLOG_OETF_GAMMA","FLOG2_OETF_GAMMA","TWOPOINTTWO_GAMMA","TWOPOINTFOUR_GAMMA","TWOPOINTSIX_GAMMA","LINEAR_GAMMA","NLOG_OETF_GAMMA","PANASONIC_VLOG_GAMMA","RED_LOG3G10_GAMMA","REC709_GAMMA","SONY_SLOG_GAMMA","SONY_SLOG2_GAMMA","SONY_SLOG3_GAMMA","SRGB_GAMMA"],L4={inputColorSpace:"REC709_COLORSPACE",inputGamma:"TWOPOINTFOUR_GAMMA",outputColorSpace:"REC709_COLORSPACE",outputGamma:"TWOPOINTFOUR_GAMMA"};function DD(e){let t=String(e.outputGamma??L4.outputGamma);return t==="TWOPOINTFOUR_GAMMA"||t==="REC709_GAMMA"?"g24":t==="SRGB_GAMMA"?"srgb":null}function X4(e){let t=n=>String(e[n]??L4[n]).replace(/_(COLORSPACE|GAMMA)$/,"");return`${t("inputColorSpace")}/${t("inputGamma")} \u2192 ${t("outputColorSpace")}/${t("outputGamma")}`}function qD(e,t){let n=(x,T)=>{let z=String(t[T]??L4[T]),k=x.indexOf(z);if(k<0)throw new Error(`the clip's Color Space Transform uses ${T} ${z}, which our CST does not model yet`);return k},i=n(ID,"inputColorSpace"),r=n(WD,"inputGamma"),o=n(ID,"outputColorSpace"),a=n(WD,"outputGamma"),s=k4[r],c=k4[a],l=M4(r,i),u=M4(a,o),f=Math.abs(l-u)>1e-9,d=f?(l-.09*(l/u))/(l/u-1):0,m=f?u*(l+d)/l:0,p=Number(t.doFwdOOTF??0)===1,b=Number(t.doInvOOTF??0)===1,h=FD[i],v=VD[o],g=new Float32Array(e.data.length),y=[0,0,0],w=[0,0,0];for(let x=0;x<g.length;x+=3){for(let T=0;T<3;T++)y[T]=jD(s,e.data[x+T]),b&&(y[T]=T4(Math.sign(y[T])*Math.abs(y[T])**(1/2.4))),f&&l>u&&(y[T]=O4(y[T],m,d,l,u));for(let T=0;T<3;T++)w[T]=h[T*3]*y[0]+h[T*3+1]*y[1]+h[T*3+2]*y[2];for(let T=0;T<3;T++){let z=v[T*3]*w[0]+v[T*3+1]*w[1]+v[T*3+2]*w[2];f&&l<u&&(z=O4(z,m,d,l,u)),p&&(z=Math.max(z4(z),0)**2.4),g[x+T]=S4(ZD(c,z),0,1)}}return{data:g,w:e.w,h:e.h}}var UD=["primaries","pixel","hm-mkl-hm","hm-coral-hm","hm-adain-hm","hm-mvgd-hm"],lse=new Set([".png",".jpg",".jpeg",".jpe",".jfif",".tif",".tiff",".exr",".dpx",".dng",".cr3"]),AD=new Set([".webp",".avif",".heic",".heif",".gif",".bmp"]),HD=1024;async function use(e){let t=Pr(e).toLowerCase();if(AD.has(t))throw new Error(`${ae(e)}: ${t.slice(1)} stills are not decoded by the engine yet \u2014 save the reference as PNG or JPEG`);let n=await pr(e),i=t===".png"?XD:t===".jpg"||t===".jpeg"||t===".jpe"||t===".jfif"?ND:t===".dpx"?P6:t===".exr"?S6:t===".tif"||t===".tiff"?z6:t===".dng"?k6:t===".cr3"?T6:null;if(!i)throw new Error(`unsupported still: ${ae(e)}`);let r=await i(n);if(!r)throw new Error(`could not decode ${ae(e)}`);return x9(r.rgba,r.width,r.height)}async function fse(e,t){let n=await Rn(e),i=n.streams?.find(u=>u.kind==="video"),r=(i?.codec??"").toLowerCase(),o=n.source_fps??i?.rate??24,a=n.available_range?.duration?.value??0;if(["r3d","braw","crm","canon","arriraw","ari","xocn","prores_raw","prores raw","aprn","aprh"].some(u=>r.includes(u)))throw new Error(`${ae(e)} is camera-native raw (${r}): the engine decodes it as log, so a display-referred match would be wrong \u2014 match on a proxy or a rendered frame`);let c=t==null?Math.floor(a/2):Jr(t,o,n.source_timecode??null);if(a&&(c<0||c>=a))throw new Error(`frame ${c} is outside ${ae(e)} (0\u2013${a-1})`);let l=await tl(e,c,r);return{image:x9(l.rgba,l.width,l.height),frame:c,codec:r,transfer:"g24",fps:o}}async function ED(e,t){let n=Pr(e).toLowerCase();if(lse.has(n)||AD.has(n))return{image:await use(e),frame:0,codec:"still",transfer:"srgb",fps:0};if(ra.has(n))return fse(e,t);throw new Error(`unsupported file for color match: ${ae(e)}`)}async function GD(e){let t=Date.now(),n=e.reference==="ai",i=e.method??(n?"primaries":"hm-mkl-hm"),r=i.split("-")[1],o=await ED(e.source,e.frame);if(e.cst){let w=DD(e.cst);if(!w)throw new Error(`the clip's Color Space Transform (${X4(e.cst)}) does not end on a display; balance needs Rec.709/sRGB out`);o.image=qD(o.image,e.cst),o.transfer=w}let a,s=n?await(async()=>{let w=z9();if(w)throw new Error(w);let x=await M9();if(!x&&!e.download)throw new Error("the local AI colour model is not installed yet: run again with download: true to fetch it once (~4.3 GB, stays on this machine)");x??=await hI({onProgress:e.onProgress});let T=await bI(x,gs(o.image,1024)),z=gI(CD(o.image,T.w,T.h),T);return a={ms:T.ms,askedStops:z.askedStops,appliedStops:z.appliedStops},{image:z.image,frame:0,codec:"ai",transfer:o.transfer,fps:0}})():await ED(e.reference,e.reference_frame),c=e.transfer??o.transfer;mI(c);let l=gs(o.image,HD),u=gs(s.image,HD);(r==="mvgd"||i==="pixel"||i==="primaries")&&(u.w!==l.w||u.h!==l.h)&&(u=CD(u,l.w,l.h));let f,d,m,p,b=0,h=0;if(i==="primaries"){let w=p4(l,u),x=0;for(let M of w)x+=M;let T,z=e.skinBoost??3;if(z>1){let M=await yI(u);b=M.length,T=MD(u,M);let L=M.reduce((P,X)=>P+Math.max(0,X.x1-X.x0)*Math.max(0,X.y1-X.y0)*X.score,0);h=Math.min(1,L/.05)}let k={weights:w,balanceOnly:!0,mixerRaw:e.mixer===!0};p=g4(l,u,k);let S=1+(z-1)*h;T&&S>1.05&&(p=g4(l,u,{...k,skinBoost:S,skinRegion:T,keepTone:p.cdl})),d=u,m=x/w.length}else if(i==="pixel"){let w=yD(l,u);f=w,d=u,m=w.trustedShare}else{let w=mv(l,u,r);f=vD(l,u,w,{tone1Contrast:null,enableTone2:!1,trimContrast:null}),d=w.image}let v=gv(l,d),g={itemId:e.item_id??"color-match",averaged:l,balanced:d,report:{},analysis:v.analysis,cdl:{slope:[1,1,1],offset:[0,0,0],power:[1,1,1]},framesUsed:[o.frame],issues:[],transfer:c,sourceW:o.image.w,sourceH:o.image.h,totalMs:Date.now()-t,engine:"ai",transferred:!0,reference:u,seed:n?376436993:0,prompt:n?"balance (FLUX.2 klein, local)":"",matchMethod:i,fitResidual:p?.residual??f.residual,lumaStops:v.lumaStops,inferenceMs:a?.ms??0,facesDetected:b,skinWeighted:b>0,gradeStyle:p?"primaries":"fold",fold:f};if(p){let w=p.cdl;g.cdl={slope:w.slope,offset:w.offset,power:w.power,saturation:w.saturation,...w.mixer?{mixer:w.mixer,mixerLumaLock:w.mixerLumaLock}:{},wheels:{shadow:[0,0,0],midtone:[0,0,0],highlight:[0,0,0],contrast:w.contrast,pivot:w.pivot}}}let y=v4(g);return{run:g,entries:y,method:i,transfer:c,source:{path:e.source,frame:o.frame,codec:o.codec,w:o.image.w,h:o.image.h},reference:{path:n?"FLUX.2 klein (local)":e.reference,w:s.image.w,h:s.image.h},residual:p?.residual??f.residual,lumaStops:v.lumaStops,ai:a,trustedShare:m,cst:e.cst?X4(e.cst):void 0}}function JD(e,t,n){return LD(e.run,t,n)}function BD(e,t){for(let n of e.timelines)for(let i of n.tracks)for(let r of i.items){if(r.id!==t)continue;return(r.effects??[]).find(a=>a.kind==="color_space_transform")?.parameters}}function YD(e,t){let n=[];for(let i of e.timelines)for(let r of i.tracks)for(let o of r.items)(o.id===t||o.name===t)&&n.push({timelineId:i.id??"",itemId:o.id,name:o.name??""});return n.length===1?n[0]:n.length>1?n.find(r=>r.itemId===t)??n[0]:null}var ks=e=>(Math.round(e*1e3)/1e3).toString(),Dc=e=>e?`[${e.map(ks).join(", ")}]`:"\u2014";function KD(e){let t=[`source ${ae(e.source.path)} frame ${e.source.frame} (${e.source.codec}, ${e.source.w}x${e.source.h}, ${e.cst?`after the clip's CST ${e.cst}, `:""}${e.transfer}) \u2192 reference ${ae(e.reference.path)} (${e.reference.w}x${e.reference.h})`,`method ${e.method}; fit residual ${ks(e.residual)} (mean |chain \u2212 match|, 0\u20131 codes); luma ${e.lumaStops>=0?"+":""}${ks(e.lumaStops)} stops`,...e.ai?[`AI balance: FLUX.2 klein on this machine in ${(e.ai.ms/1e3).toFixed(1)} s; exposure held (model asked ${e.ai.askedStops>=0?"+":""}${ks(e.ai.askedStops)} stops, applied ${e.ai.appliedStops>=0?"+":""}${ks(e.ai.appliedStops)})`]:[],...e.method==="primaries"?[(n=>n.facesDetected?`skin: ${n.facesDetected} face${n.facesDetected>1?"s":""} found \u2014 skin protected (colour only, contrast kept)`:"skin: no faces in the frame \u2014 plain balance")(e.run)]:[],"grade (Resolve node order \u2014 timeline_write resolve-drt emits them as corrector nodes):"];for(let n of e.entries){let i=n.cdl??{},r=n.enabled===!1?" (bypassed)":"",o=[i.slope?`slope ${Dc(i.slope)}`:"",i.offset?`offset ${Dc(i.offset)}`:"",i.power?`power ${Dc(i.power)}`:"",i.mixer?`mixer ${Dc(i.mixer)}`:"",i.saturation!=null?`sat ${ks(i.saturation)}`:"",i.contrast!=null?`contrast ${ks(i.contrast)} @ pivot ${ks(i.pivot??.435)}`:"",i.shadow?`wheels lift ${Dc(i.shadow)} gamma ${Dc(i.midtone)} gain ${Dc(i.highlight)}`:""].filter(Boolean);t.push(`- ${n.label??n.id}${r}: ${o.join("; ")}`)}return t.join(`
224
+ `)}function CD(e,t,n){let i=new Float32Array(t*n*3);for(let r=0;r<n;r++){let o=Math.min(e.h-1,Math.floor((r+.5)*e.h/n));for(let a=0;a<t;a++){let s=Math.min(e.w-1,Math.floor((a+.5)*e.w/t)),c=(o*e.w+s)*3,l=(r*t+a)*3;i[l]=e.data[c],i[l+1]=e.data[c+1],i[l+2]=e.data[c+2]}}return{data:i,w:t,h:n}}var dse=[{name:"account_login",title:"Sign in to conform.tools",description:"Sign in with the Google account you use on conform.tools. Opens the browser to the sign-in page and waits (up to 5 minutes) until it completes, then reports the plan. Needed once per machine; every other verb except timeline_routes and the account verbs requires a signed-in account with an active trial or subscription.",inputSchema:{},run:async()=>{let e="",t=await Q6({onUrl:(n,i)=>{e=i?"":n,i||console.error(`open this URL to sign in: ${n}`)}});return Tt(`signed in
225
+ ${op(t)}${e?`
226
+ (sign-in URL: ${e})`:""}`,{account:t})}},{name:"account_status",title:"Account and plan",description:"The running conformtools version (and whether a newer one is on npm), who is signed in on this machine, and whether the account's trial or subscription is active (checked live against conform.tools, with a 72-hour offline grace).",inputSchema:{},run:async()=>{let[e,t]=await Promise.all([Uc({force:!0}),My()]);return Tt(`${await X5()}
227
+ ${op(e)}`,{account:e,version:so,latest_version:t})}},{name:"account_logout",title:"Sign out",description:"Forget this machine's conform.tools sign-in.",inputSchema:{},run:async()=>(await _6(),Tt(`signed out (${yr().env})`,{signed_in:!1}))},{name:"account_telemetry",title:"Outcome telemetry on / off",description:"Turn the optional outcome telemetry on or off, or show its state (action=status, the default). It is OFF unless the user turns it on. When on it records, per tool run, the tool name, ok or the error code, duration, package version, engine mode and counts (numbers only), and per rejected call the tool name and the names of the failing arguments; never paths, file or clip names, timeline contents or media. Only change it when the user asks. Same as `conformtools telemetry on|off|status`.",inputSchema:{action:O.enum(["on","off","status"]).default("status")},run:async({action:e})=>((e==="on"||e==="off")&&await vL(e==="on"),Tt(await yL(),{telemetry:await Ul()}))},{name:"conform_learn",title:"Load the conform.tools playbook for a task",description:`Call this FIRST, before any conform, timeline conversion, relink, verification or delivery task, and follow what it returns: the conform.tools playbook for the task (the order a conform artist works in, what to check, how to tell the user). task = conform (a turnover, timeline conversion, relink, online/offline conform, "is this conform right?") | autoconform (rebuild an edit from a reference render + source media) | deliver (consolidate, media manage, package or QC a turnover for the next facility) | deliverables (render and QC a finished program's deliverables: the usual set, naming, pre-render gate, audio routing, sign-off) | troubleshoot (a conformtools result looks wrong) | patch (fix a show already delivered: temps left in, replace with masters, insert timelines, patch renders and their QC). hosts = the editing systems involved, which adds their notes. Once per task per conversation is enough. Needs a signed-in account (account_login).`,inputSchema:{task:O.enum(YO).describe("conform | autoconform | deliver | troubleshoot | patch"),hosts:O.array(O.enum(nP)).max(nP.length).optional().describe("The editing systems involved, source and target")},run:async({task:e,hosts:t})=>{try{let n=await _O(e,t??[]);return Tt(n.text,{task:n.task,version:n.version,files:n.files})}catch(n){return ct(new ze("refused",`the playbook could not be loaded: ${n instanceof Error?n.message:String(n)}. Carry on with the tools; their descriptions still apply.`))}}},{name:"report_issue",title:"Report a problem with a conformtools result",description:'Send the conform.tools team a problem report. Call it when the user says a conformtools result is wrong, complains about it, corrects an output ("that clip should be at 01:00:10:00", "the relink picked the proxy"), or when a tool failed unexpectedly. Give a short summary, what happened, what they expected, and the session_id / verb / job_id involved. It attaches the package version, engine mode, OS and runtime, the signed-in account, and the last 20 engine log lines for that session/job with paths cut to file names. It never sends media, file contents or timeline files. Tell the user it was sent and give the report id.',inputSchema:{summary:O.string().min(3).describe(`One line: what is wrong (max ${si.summary} chars; longer is cut)`),what_happened:O.string().optional().describe(`What the tool did or returned (max ${si.what_happened} chars; longer is cut)`),expected:O.string().optional().describe(`What the user expected instead (max ${si.expected} chars; longer is cut)`),session_id:O.string().optional().describe("The session involved, if any"),verb:O.string().optional().describe("The tool that produced the wrong result, e.g. timeline_write"),job_id:O.string().optional().describe("The background job involved, if any"),severity:O.enum(sP).default("medium").describe("blocker = the user cannot continue")},run:async e=>{try{let t=await r0("issue",e),n=await i0(t);return o0("issue",n,t,e)}catch(t){return ct(t)}}},{name:"report_gap",title:"Report a task done without conformtools",description:`Tell the conform.tools team which post-production task needed something other than conformtools, so the missing tool gets built. Call it once per task whenever you use ffmpeg, ffprobe, mediainfo, exiftool, a python or shell script, another MCP server, or manual steps in a host app for a timeline / media / conform / delivery task, or when conformtools cannot do the task at all; before or right after the workaround. task = what the user wanted; used_instead = the tool or command (e.g. "ffprobe -show_streams"); why_not_conformtools = missing_tool | missing_option | tool_failed | did_not_know; needed = what you needed from it and which output fields you used, so the team can build it in. File names at most, never full paths; never file contents or values from the user's media. Tell the user you sent it.`,inputSchema:{task:O.string().min(3).describe(`What the user wanted done (max ${si.task} chars; longer is cut)`),used_instead:O.string().optional().describe(`The tool, command or manual step used instead (max ${si.used_instead} chars; longer is cut)`),why_not_conformtools:O.enum(cP).optional().describe("missing_tool: no tool for it; missing_option: a tool exists but lacks the option; tool_failed; did_not_know: a conformtools tool exists but was not used"),conformtools_verb_tried:O.string().optional().describe("The conformtools tool tried first, if any"),needed:O.string().max(2e3).optional().describe(`What you needed from the other tool, so it can be built into conformtools: the information or operation, and which of its output fields you actually used (e.g. "per-stream start timecode and audio channel layout of a MOV: ffprobe streams[].tags.timecode, channel_layout"). Field names and the kind of value, never values from the user's media`),session_id:O.string().optional()},run:async({needed:e,...t})=>{try{let n=await r0("gap",{...t,...e?{expected:e}:{}}),i=await i0(n);return o0("gap",i,n,t)}catch(n){return ct(n)}}},{name:"report_note",title:"Send a playbook note or suggestion",description:`Send the conform.tools team a lesson, workflow rule or suggestion when nothing broke: something the playbooks should teach ("a patch runs from the whole clip before to the whole clip after", "this facility files patch renders in 200 - FINISH/<date>", "never match archival by file name alone") or an idea for the tools. Use report_issue for a wrong result and report_gap for a task done with another tool. File names at most, never full paths or values from the user's media. Tell the user you sent it.`,inputSchema:{note:O.string().min(3).describe(`One line: the lesson or suggestion (max ${si.summary} chars; longer is cut)`),detail:O.string().optional().describe(`Why, when it applies, what went wrong without it (max ${si.what_happened} chars; longer is cut)`),topic:O.enum(["playbook","suggestion"]).default("playbook").describe("playbook = how the work should be done; suggestion = an idea for conformtools"),session_id:O.string().optional(),verb:O.string().optional().describe("The tool it is about, if any")},run:async({note:e,detail:t,topic:n,...i})=>{try{let r={...i,summary:`[${n??"playbook"}] ${e}`,...t?{what_happened:t}:{}},o=await r0("note",r),a=await i0(o);return o0("note",a,o,r)}catch(r){return ct(r)}}},{name:"timeline_read",protectedStages:["canonicalize"],title:"Read a timeline file",description:"Read an editorial timeline file (Avid AAF/AVB bin, Premiere .prproj, Resolve .drt, Final Cut .fcpxml/.fcpxmld, FCP7 XML, OTIO, Flame archive) into a session on this machine. Nothing is uploaded. Returns a session_id to pass to the other timeline_* tools, plus a summary (rates, raster, tracks, clip counts, media link state, conform flags). Call this first for any request that mentions a cut, sequence, bin, timeline or conform.",inputSchema:{path:O.string().describe("Absolute path to the timeline file (or .fcpxmld bundle directory)"),format:O.enum(dg).optional().describe("Override format detection (needed for Flame archives, which have no fixed extension)")},run:async({path:e,format:t})=>{try{let{session:n,format:i}=await Su(e,t),r=await la(n,e,i);return hr(`session_id: ${r.id}
228
+ source: ${e} (${i})
229
+ ${await hs(n)}`)}catch(n){return ct(n)}}},{name:"host_current",protectedStages:["canonicalize"],title:"What is open in Resolve / Premiere / Media Composer / Flame / Final Cut",description:"Find the project and timeline each editing host on this machine has open right now \u2014 no host API, no export dialog \u2014 and read it into a session as if its file had been given to timeline_read. Resolve: the open project database \u2192 the timeline in the viewer, built into a .drt (identical to Resolve's own export). Premiere: the project window's .prproj and the sequences open in its Timeline panel (last save). Media Composer: the open project's bins (newest first; the loaded sequence is not on disk). Flame: the running project/workspace's live workspace file (every sequence on the desktop). Final Cut: the open libraries and the project in the Timeline (no readable file on disk). Use when asked 'what do I have open', 'grab my current timeline', 'the sequence I'm working on', or to act on the open cut without exporting.",inputSchema:{host:O.enum(La).optional().describe("One host; omit for all five"),read:O.boolean().default(!0).describe("Also read the open timeline into a session (session_id in the reply)")},run:async({host:e,read:t})=>{try{let i=await IW(e?[e]:void 0,void 0,t?async(o,a)=>{try{let{session:s}=await Su(o,a);return s.timelines.some(c=>c.tracks?.some(l=>l.items?.length))}catch{return!1}}:void 0),r=[];for(let o of i){let a=WW(o);if(t&&o.read)try{let{session:s,format:c}=await Su(o.read.path,o.read.format);ZW(s,o);let l=await la(s,o.read.path,c);a+=`
230
+ session_id: ${l.id}
231
+ ${(await hs(s)).replace(/^/gm," ")}`}catch(s){a+=`
232
+ read failed: ${s instanceof Error?s.message:String(s)}`}r.push(a)}return hr(r.join(`
233
+
234
+ `))}catch(n){return ct(n)}}},{name:"host_export",protectedStages:["canonicalize"],title:"Export a timeline from the running host",description:"Ask the running host to export a timeline in its own format, through its scripting door (read-only on the project), and read it into a session. Resolve: any timeline of the open project by name (default: the one in the viewer) as Resolve's own .drt. Use when host_current cannot read the open timeline from disk (a PostgreSQL project library, a timeline never saved), or to pick a timeline by name.",inputSchema:{host:O.enum(La).describe("The host to export from"),timeline:O.string().optional().describe("Timeline name; the open one when omitted"),out_path:O.string().optional().describe("Where to write the file; a temp file when omitted"),read:O.boolean().default(!0).describe("Also read it into a session (session_id in the reply)")},run:async({host:e,timeline:t,out_path:n,read:i})=>{try{let r=n??_(await ii("conform-export-"),`${(t??"current").replace(/[^\w.-]+/g,"_")}.drt`),o=await Ic(e).export({timeline:t,out_path:r}),a=`exported ${o.project} / ${o.timeline} \u2192 ${o.path} (${o.format})`,s={...o};if(i!==!1){let{session:c,format:l}=await Su(o.path,o.format),u=await la(c,o.path,l);a+=`
235
+ session_id: ${u.id}
236
+ ${await hs(c)}`,s.session_id=u.id}return Tt(a,s)}catch(r){return ct(new ze("refused",r instanceof Error?r.message:String(r)))}}},{name:"host_open",title:"Open a timeline file in the running host",description:`Import a timeline file into the running host as a NEW timeline (never overwrites one; a taken name gets a number). Resolve: into the open project's conform.tools media pool folder (into=current, the default), or into our scratch project (into=scratch: the user's project is saved first, then reopened). folder (Resolve): the media pool folder to land it in, by path under Master, e.g. "000 - TIMELINES/20261006" (learn the project's layout with host_project first); a missing folder is refused unless create_folder=true. link_existing=true links the timeline to clips already in the media pool (no duplicate clips; Resolve importSourceClips off): the way to bring an insert/update timeline into a project that has the media. The user's timeline, folder and page are put back afterwards unless stay=true. Use after timeline_write to land a conversion in the host, or to bring a turnover in for checking.`,inputSchema:{host:O.enum(La).describe("The host to open it in"),path:O.string().describe("The timeline file (Resolve: .drt, .xml, .fcpxml, .aaf, .edl, .otio)"),name:O.string().optional().describe("Timeline name; the file name when omitted"),into:O.enum(["current","scratch"]).default("current").describe("current: the open project; scratch: our own project"),media_dirs:O.array(O.string()).optional().describe("Folders to link media from while importing"),stay:O.boolean().default(!1).describe("Leave the host showing the imported timeline"),folder:O.string().optional().describe('Resolve: media pool folder path to import into, e.g. "000 - TIMELINES/20261006" (default: conform.tools)'),create_folder:O.boolean().default(!1).describe("Create the folder (and its parents) when missing"),link_existing:O.boolean().default(!1).describe("Link to clips already in the media pool instead of importing new ones")},run:async({host:e,path:t,name:n,into:i,media_dirs:r,stay:o,folder:a,create_folder:s,link_existing:c})=>{try{let l=await Ic(e).open({path:t,name:n,into:i,media_dirs:r,stay:o,folder:a,create_folder:s,link_existing:c}),u=[`opened in ${e}: ${l.project} / ${l.timeline}${l.folder?` (media pool: ${l.folder})`:""}`,l.restored?"the user's timeline, folder and page were put back":"left showing the imported timeline",...c?["linked to clips already in the media pool (no new clips imported)"]:[],...l.notes];return Tt(u.join(`
237
+ `),{...l})}catch(l){return ct(new ze("refused",l instanceof Error?l.message:String(l)))}}},{name:"host_render",long:!0,title:"Render a timeline in the running host (optionally through the renderplugin)",description:`Render a timeline (or a frame range of it) with the host's own renderer and wait for the files. Only OUR job is queued and started; the user's render queue is never run, their Deliver settings are restored as soon as our job is queued, and their timeline and page come back when it finishes. Refuses while the host is already rendering. Resolve: preset = a render preset saved in Resolve (default: the project's current render settings); range = absolute timeline frames, inclusive; name = the output file name. Picture only unless audio=true. audio_tracks (Resolve) = the Deliver page's audio output routing by timeline track, which its API cannot set: [1, 2] = A1 (5.1) on ch1-6 + A2 (stereo) on ch7-8 (an 8CH_5-1_STEREO deliverable), [2] = stereo only; set it whenever a name promises a channel layout. disable_tracks = video tracks to leave out of this render, by name (every track so named, e.g. ["Lower Thirds"] for a TEXTLESS version) or "V7": Resolve's API has no per-job track selection, so they are switched off on the Edit page (read back) for our job and switched back on when it ends. Resolve names the queued job itself ("Job N"); its API cannot. renderplugin=true (Resolve): render through the conform.tools renderplugin instead, which measures EVERY frame after grading and compositing, and return findings: black edges (blanking) per range with the clip and edge, black frames, failed/warned checks (clipping, freeze/flash, dead pixels, leader/slate), audio loudness and peak; markers go on the timeline (ours, tagged; a re-run replaces them, nobody else's are touched). The throwaway render is deleted unless keep_render. strictness: strict (1 px, 1 frame; default) | standard | relaxed. expected_aspect: the delivered ratio when bars are part of the deliverable (2.39 in UHD, 1.85 in DCI). Use for finishing QC ('check this timeline for black edges', 'QC the master before it goes'). Long: pass background=true for a job id, then job_status.`,inputSchema:{host:O.enum(La).describe("The host to render in"),timeline:O.string().optional().describe("Timeline name; the open one when omitted"),target_dir:O.string().optional().describe("Folder for the render (required unless renderplugin=true); created if missing"),name:O.string().optional().describe("Output name without extension; the timeline name when omitted"),preset:O.string().optional().describe("A render preset saved in the host"),range:O.object({in:O.number().int(),out:O.number().int()}).optional().describe("Frame range, absolute timeline frames, inclusive"),audio:O.boolean().optional().describe("Render audio with the picture (default: off = picture only; on for renderplugin)"),disable_tracks:O.array(O.string()).optional().describe('Video tracks to leave out of this render, by name or "V7" (e.g. ["Lower Thirds"] for TEXTLESS)'),audio_tracks:O.array(O.number().int().positive()).optional().describe("Resolve: audio output n = timeline track audio_tracks[n], e.g. [1, 2] = 5.1 (A1) on ch1-6 + stereo (A2) on ch7-8; [2] = stereo only. Implies audio"),renderplugin:O.boolean().default(!1).describe("Resolve: render through the conform.tools renderplugin and return QC findings"),strictness:O.enum(Object.keys(Dm)).optional().describe("renderplugin: strict (default) | standard | relaxed"),expected_aspect:O.number().positive().optional().describe("renderplugin: delivered aspect ratio when bars are expected, e.g. 2.39"),markers:O.boolean().default(!0).describe("renderplugin: place markers on the findings"),keep_render:O.boolean().default(!1).describe("renderplugin: keep the throwaway ProRes render"),ignore_space:O.boolean().default(!1).describe("renderplugin: skip the free-space check")},run:async({host:e,timeline:t,target_dir:n,name:i,preset:r,range:o,audio:a,disable_tracks:s,audio_tracks:c,renderplugin:l,strictness:u,expected_aspect:f,markers:d,keep_render:m,ignore_space:p,__progress:b,__signal:h})=>{let v=Ic(e);try{if(l){if(e!=="resolve")return ct(new ze("unsupported","the renderplugin is a DaVinci Resolve plugin"));let w=await eD(v,jc,{timeline:t,range:o,strictness:u,expected_aspect:f,markers:d,keep_render:m,ignore_space:p,audio:a},b,h);return Tt(tD(w),{...w})}if(!n)return ct(new ze("invalid_args","target_dir is required (unless renderplugin=true)"));if(c?.length&&e!=="resolve")return ct(new ze("unsupported","audio_tracks (output routing) is for DaVinci Resolve"));let g=await v.renderStart({timeline:t,target_dir:n,name:i,preset:r,range:o,audio:(a??!1)||!!c?.length,...s?.length?{disable_tracks:s}:{},...c?.length?{audio_tracks:c}:{}});if(g=await n4(v,g,b,h),g.state!=="complete")return ct(new ze(g.state==="cancelled"?"cancelled":"engine",`render ${g.state}${g.error?`: ${g.error}`:""}${g.notes?.length?`; ${g.notes.join("; ")}`:""}`));let y=g.outputs?.length?g.outputs:await jW(n,i??t??"");return Tt([`rendered in ${e} \u2192 ${y.join(", ")||n}${a||c?.length?"":" (picture only)"}`,...s?.length?[`without video tracks: ${s.join(", ")}`]:[],...c?.length?[`audio outputs: ${c.map((w,x)=>`${x+1} = timeline track ${w}`).join(", ")} \u2014 probe the file to confirm the channel layout`]:[],"the user's render settings, timeline and page were put back",...g.notes??[]].join(`
238
+ `),{job_id:g.job_id,outputs:y,...g.notes?{notes:g.notes}:{}})}catch(g){return ct(new ze("refused",g instanceof Error?g.message:String(g)))}}},{name:"host_preset",title:"Read or author host render presets (incl. audio output routing)",description:"Resolve render presets. action=list: every preset (or names) with its container, codec, raster, audio codec and the Deliver page's audio OUTPUT routing (Timeline Track n / Bus n per output) \u2014 the routing the scripting API cannot read. action=author: save a NEW preset = base (a preset, or the Deliver page's current settings) with audio output n fed by timeline track audio_tracks[n] ([1, 2] = 5.1 on A1 \u2192 ch1-6 + stereo on A2 \u2192 ch7-8; [2] = stereo only). Never replaces a preset; names without dots. The user's Deliver settings and page are put back. Prove a new preset with a short test render (host_render range of ~11 frames) and media_probe the channels before the full render.",inputSchema:{host:O.enum(La).default("resolve").describe("The host"),action:O.enum(["list","author"]).default("list"),names:O.array(O.string()).optional().describe("list: only these presets"),name:O.string().optional().describe("author: the new preset's name (no dots), e.g. PR4444_8CH_5-1_STEREO"),base:O.string().optional().describe("author: the preset to start from; the Deliver page's current settings when omitted"),audio_tracks:O.array(O.number().int().positive()).optional().describe("author: timeline track per audio output, e.g. [1, 2]")},run:async({host:e,action:t,names:n,name:i,base:r,audio_tracks:o})=>{try{let a=Ic(e??"resolve");if(!a.presets||!a.presetAuthor)return ct(new ze("unsupported",`${a.host}: host_preset is for DaVinci Resolve`));let s=l=>l.error?`${l.name}: ${l.error}`:`${l.name}: ${l.format??"?"} ${l.codec??"?"} ${l.width??"?"}x${l.height??"?"}; audio ${l.audio==="true"?`${l.audio_codec??"on"} \u2192 ${l.audio_outputs?.length?l.audio_outputs.map((u,f)=>`out ${f+1} = ${u}`).join(", "):"default routing"}`:"off"}`;if(t==="author"){if(!i||!o?.length)return ct(new ze("invalid_args","author needs name and audio_tracks"));let l=await a.presetAuthor({name:i,...r?{base:r}:{},audio_tracks:o});return Tt(`saved render preset "${l.preset}"${l.summary?`
239
+ ${s({...l.summary,name:l.preset})}`:""}
240
+ prove it: host_render a ~11-frame range with this preset, then media_probe the channels`,l)}let c=await a.presets({...n?.length?{names:n}:{}});return Tt([`${c.presets.length} render preset(s) in "${c.project}":`,...c.presets.map(s)].join(`
241
+ `),c)}catch(a){return ct(new ze("refused",a instanceof Error?a.message:String(a)))}}},{name:"host_project",title:"Learn the open host project: media pool, render queue, tracks",description:"Read-only look at the project open in the running host, to learn its conventions before acting. Resolve: the media pool folder tree with clip counts (clips=true lists every clip with its file, start TC and usage); find = file paths or name fragments to look up project-wide ('is this file already in the project? where?'); the render queue with each job's name, timeline, output folder/file, status, mark in/out and the settings Resolve reports; and every track of a timeline (default: the open one) with its name and enabled/locked state. Use before host_open (which folder) and host_render (which tracks are Lower Thirds, which job made the deliverable).",inputSchema:{host:O.enum(La).default("resolve").describe("The host"),timeline:O.string().optional().describe("Timeline whose tracks to list; the open one when omitted"),clips:O.boolean().default(!1).describe("List every clip in every folder (large projects: long)"),find:O.array(O.string()).optional().describe("File paths or name fragments to look up in the media pool")},run:async({host:e,timeline:t,clips:n,find:i})=>{try{let r=Ic(e??"resolve");if(!r.project)return ct(new ze("unsupported",`${r.host}: host_project is not available for this host yet`));let o=await r.project({timeline:t,clips:n,find:i}),a=0,s=0,c=[],l=(f,d)=>{d&&(a++,c.push(`${" ".repeat(d)}${f.path.split("/").pop()} (${f.clips} clip${f.clips===1?"":"s"})`)),s+=f.clips;for(let m of f.clip_list??[])c.push(`${" ".repeat(d+1)}- ${m.name} ${m.file}${m.start_tc?` TC ${m.start_tc}`:""}${m.usage?` used ${m.usage}x`:""}`);for(let m of f.folders)l(m,d+1)};l(o.pool,0);let u=[`${e??"resolve"} project "${o.project}": ${a} media pool folders, ${s} clips; ${o.jobs.length} render job(s)${o.timeline?`; timeline "${o.timeline}" has ${o.tracks.length} tracks`:""}`];u.push("media pool:",...c.length?c:[" (no folders)"]);for(let[f,d]of Object.entries(o.found??{}))u.push(d.length?`find "${f}": ${d.map(m=>`${m.folder||"Master"}/${m.name} (${m.file||"no file"}${m.usage?`, used ${m.usage}x`:""})`).join("; ")}`:`find "${f}": not in the project`);o.jobs.length&&u.push("render queue:");for(let f of o.jobs){let d=f.MarkIn!=null?` frames ${f.MarkIn}-${f.MarkOut}`:"";u.push(` ${f.RenderJobName??f.JobId} [${f.JobStatus||"?"}] "${f.TimelineName??""}" \u2192 ${_(String(f.TargetDir??""),String(f.OutputFilename??""))}${d}${f.VideoCodec?` ${f.VideoFormat??""} ${f.VideoCodec}`:""}${f.PresetName?` preset ${f.PresetName}`:""}`)}return o.tracks?.length&&u.push(`tracks: ${Q9(o.tracks)}`),Tt(u.join(`
242
+ `),o)}catch(r){return ct(new ze("refused",r instanceof Error?r.message:String(r)))}}},{name:"host_setup",title:"Host readiness, and installing the renderplugin",description:"What works with each editing host on this machine and what to do about what doesn't (Resolve: Studio, external scripting, an open project; the conform.tools renderplugin installed and loaded). action=install_renderplugin downloads the published renderplugin for this platform, verifies its checksum before writing anything, and installs it into Resolve's system I/O plugin folder (the OS asks for an administrator password). Resolve must be restarted afterwards. action=install_panel (Premiere) installs the conform.tools UXP panel with Adobe's own installer; the user then opens Window > UXP Plugins > conform.tools once. Only install when the user asks.",inputSchema:{host:O.enum(La).default("resolve").describe("The host"),action:O.enum(["status","install_renderplugin","install_panel"]).default("status")},run:async({host:e,action:t})=>{try{let n=e??"resolve";if((t??"status")==="install_panel"){if(n!=="premiere")return ct(new ze("unsupported","install_panel installs the conform.tools panel for Premiere Pro (host=premiere)"));let a=await GW();return Tt([`conform.tools panel ${a.version} installed for Premiere Pro (Adobe's installer: ${a.output.split(`
243
+ `).pop()})`,"In Premiere: Window > UXP Plugins > conform.tools (restart Premiere first if it was running). It connects by itself from then on."].join(`
244
+ `),{...a})}if((t??"status")==="install_renderplugin"){if(n!=="resolve")return ct(new ze("unsupported","the renderplugin is a DaVinci Resolve plugin"));let a=await FW();return Tt([`renderplugin ${a.version} installed at ${a.path}${a.elevated?" (with administrator approval)":""}`,"Restart Resolve: it loads I/O plugins only at launch.",...a.notes].join(`
245
+ `),{...a})}let i=await Ic(n).support(),r=[`${n}:`,...Object.entries(i).map(([a,s])=>` ${a}: ${s.ok?"ready":`no: ${s.reason}${s.setup?` (${s.setup})`:""}`}`)],o={host:n,support:i};if(n==="premiere"){let a=await AW();r.push(` panel: ${a.installed?`installed${a.version?` (${a.version})`:""}`:`not installed (this release ships ${await e4()}; host_setup host=premiere action=install_panel)`}`),o.panel={installed:a.installed,version:a.version}}if(n==="resolve"){let a=await Au();r.push(` renderplugin: ${a.readiness}${a.version?` (${a.version})`:""}: ${a.next}`),o.renderplugin=a}return Tt(r.join(`
246
+ `),o)}catch(n){return ct(new ze("refused",n instanceof Error?n.message:String(n)))}}},{name:"timeline_inspect",title:"Inspect a session",description:"Look inside a read timeline. detail=summary (default) gives rates/tracks/counts; clips lists every item per track with record and source timecodes, media link state, speed, effects and conform flags; media lists every media reference with path, reel, timecode, raster, fps and whether it is linked; flags lists only the conform flags (things the reader could not carry 1:1); link is the Conform Connect view: which match criteria are usable for this timeline (populated on the references), what is unresolved and why, and the remembered media locations. Use clips to find item_id values for timeline_edit.",inputSchema:{session_id:O.string(),detail:O.enum(["summary","clips","media","flags","link"]).default("summary"),timeline_id:O.string().optional().describe("Limit clips listing to one timeline")},run:async({session_id:e,detail:t,timeline_id:n})=>{try{let i=await ci(e);switch(t){case"clips":return hr(WV(i.session,n));case"media":return hr(DV(i.session));case"flags":return hr(HV(i.session));case"link":return hr(await UV(i.session));default:return hr(`${await hs(i.session)}
247
+ history: ${i.history.length?i.history.join(" \u2192 "):"(unedited)"}`)}}catch(i){return ct(i)}}},{name:"timeline_query",title:"Query clips, media or markers (Edit Index)",description:`Search a read timeline the way the app's tables do \u2014 the Edit Index +, Unused Media and Marker Utility tools without a host app. table=clips: one row per clip with every IR field (record/source frames, reel, speed, transform, crop, opacity, media columns, link state), plus rec_in_tc / rec_out_tc (record timecode from the timeline's start TC and rate; out is exclusive), track_name (the lane's own name, if any) and track_enabled. table=media: one row per media reference with its usage count (how many clips use it) and link state \u2014 query "is:unused" lists media no cut uses. table=markers: every marker with record TC, colour, name, note, duration and the clip under it \u2014 "is:red" lists red markers. query grammar: ${R7} The reply shows at most limit rows (default 50); when more match it starts with TRUNCATED and truncated=true \u2014 never treat that list as complete. columns picks what to show (keys or the app's labels; the reply lists every available column). out_path writes the matched rows as CSV (a file, or a folder for a stamped name; markers use the Resolve suite's marker CSV). Read-only: to change what it finds use timeline_edit with the item_ids in the rows.`,inputSchema:{session_id:O.string(),table:O.enum(Sj).default("clips"),query:O.string().optional().describe("Filter, e.g. 'is:offline', 'speed!=100 track:V1', 'track:in V5,V6', 'overlaps:01:00:10:00..01:00:12:00', 'is:unused', 'is:red note:vfx'. Omit for every row."),timeline_id:O.string().optional().describe("Only this timeline (clips, markers); default every primary timeline"),columns:O.array(O.string()).optional().describe("Columns to return, by key or label; default the table's working set"),limit:O.number().int().min(1).max(5e3).default(50).describe("Rows in the reply (the CSV always has every match)"),out_path:O.string().optional().describe("Write the matched rows as CSV to this file or folder")},run:async({session_id:e,table:t,query:n,timeline_id:i,columns:r,limit:o,out_path:a})=>{try{let s=await ci(e),c=kj(s.session,{table:t,query:n,timeline_id:i,columns:r,csv:!!a}),l=s.session.timelines.find(m=>m.id===i)?.name??s.source_path.split(/[\\/]/).pop()??"session",u=a?await Tj(c,a,l):null,{csv:f,...d}=c;return Tt(`${zj(c,n??"",o)}${u?`
248
+ wrote ${u} (${c.matched} rows)`:""}`,{...d,rows:d.rows.slice(0,o),truncated:c.matched>o,csv_path:u})}catch(s){return ct(s)}}},{name:"timeline_edit",title:"Edit a session",description:`Apply one editing operation to the session in place (frame-accurate, on the IR, no host app needed). Operations and their args:
249
+ - slip {timeline_id,item_id,delta_frames}: move the source window, keep the record position
250
+ - trim {timeline_id,item_id,edge:'in'|'out',delta_frames,ripple?}: move one edge (+ lengthens the clip at out / shortens at in)
251
+ - delete {timeline_id,item_id,ripple?}
252
+ - move_clip {timeline_id,item_id,to_track_id?,to_frame?}
253
+ - transform {timeline_id,item_id,scale?,opacity?,position_x?,position_y?,rotation?,crop_*?}
254
+ - reformat {timeline_id?,resolution_w,resolution_h,fit?}: change the sequence raster
255
+ - timeline_rate {timeline_id,fps_num,fps_den}
256
+ - add_markers {timeline_id?,markers:[{name?,note?,color?,time,duration?,item_id?}]}: time/duration in timeline frames (from the timeline start) or {value,rate}; duration defaults to 1 frame; the reply says why any marker was dropped
257
+ - stringout {extent?,handles?,name_prefix?}: build a string-out (every used source range, in order) with handles
258
+ - relink, add_clip, new_timeline, add_track, delete_track, node_sizing, finish_op (advanced)
259
+ Get item_id / timeline_id from timeline_inspect detail=clips. Frame deltas are in timeline frames.`,inputSchema:{session_id:O.string(),kind:O.enum(pg),args:O.object({}).passthrough().describe("Arguments for the operation, see description")},run:async({session_id:e,kind:t,args:n})=>{try{let i=await ci(e),r=S7(i.session,t,n);return await ns(i,`${t} ${JSON.stringify(n)}`),hr(`${r.summary}${r.meta?`
260
+ ${JSON.stringify(r.meta,null,1).slice(0,4e3)}`:""}`)}catch(i){return ct(i)}}},{name:"timeline_author",title:"Author a timeline from media",description:"Build a NEW timeline from media files and a shot list, on this machine, with the app's own editing operations (no host app). Each shot: path, source_in (first source frame, 0 = the file's first frame), duration (timeline frames), and optionally at (timeline frame; default append), track (1-based video track; created as needed), scale (percent), position_x/position_y (frame pixels from centre), rotation (degrees clockwise), flip_h/flip_v (mirror), scale_end/position_x_end/position_y_end/rotation_end (animate linearly to these by the shot's last frame), speed (percent of real time; a 29.97 clip played frame for frame in a 23.976 timeline is 80). Returns a session_id for timeline_write / timeline_inspect. Use to make a test cut whose answer is known exactly (write it, render it in the host, then auto conform the render against the media).",inputSchema:{name:O.string().describe("Timeline name"),fps_num:O.number().int().positive().describe("Timeline rate numerator, e.g. 24000"),fps_den:O.number().int().positive().describe("Timeline rate denominator, e.g. 1001"),width:O.number().int().positive(),height:O.number().int().positive(),start_tc:O.string().optional().describe("Timeline start timecode, e.g. \"00:59:52:00\" (';' before the frames = drop frame); default 00:00:00:00. Shot `at` stays frames from the timeline start"),shots:O.array(O.object({path:O.string(),source_in:O.number().int().nonnegative(),duration:O.number().int().positive(),at:O.number().int().nonnegative().optional(),track:O.number().int().positive().optional(),scale:O.number().positive().optional(),position_x:O.number().optional(),position_y:O.number().optional(),rotation:O.number().optional(),flip_h:O.boolean().optional(),flip_v:O.boolean().optional(),scale_end:O.number().positive().optional(),position_x_end:O.number().optional(),position_y_end:O.number().optional(),rotation_end:O.number().optional(),speed:O.number().positive().optional()})).min(1)},run:async e=>{try{let{session:t,summary:n}=await LI(e),i=await la(t,_(wt(),"authored",`${e.name}.authored`),"authored");return hr(`session_id: ${i.id}
261
+ ${n.join(`
262
+ `)}
263
+ ${await hs(t)}`)}catch(t){return ct(t)}}},{name:"timeline_generate",title:"Generate a test cut from a bucket",description:"Make a NEW timeline from a bucket of media: a seeded random edit with a chosen mix of hard cases, laid in by timeline_author, so its answer is known exactly. Same media + seed + mix = the same cut. Every shot is tagged with the classes it tests: "+Rm.join(", ")+". mix: a preset ("+Object.keys(Fu).join(", ")+"; default hard) or weights per class. Returns a session_id for timeline_write and the shot list with record ranges and classes. Use to test auto conform, compare or any matcher: generate, write, render in the host (optionally grade it), auto conform the render, score per class.",inputSchema:{media:O.array(O.string()).min(1).describe("Media files or folders (walked; folders named *proxy*/*proxies* or cache skipped)"),seed:O.number().int().describe("Random seed"),shots:O.number().int().positive().max(500).optional().describe("V1 shots (default 24)"),audio:O.boolean().optional().describe("Lay sync sound in under normal-speed shots whose clips have it (needed for frankenbite)"),look:O.boolean().optional().describe("Look at each planned shot and re-plan around flat picture \u2014 empty backdrops, grey cards (default true)"),mix:O.union([O.enum(Object.keys(Fu)),O.record(O.enum(Rm),O.number().nonnegative())]).optional(),name:O.string().optional(),fps_num:O.number().int().positive().optional().describe("Default 24000"),fps_den:O.number().int().positive().optional().describe("Default 1001"),width:O.number().int().positive().optional().describe("Default 1920"),height:O.number().int().positive().optional().describe("Default 1080")},run:async e=>{try{let t=await RI(e),n=e.name??`generated ${e.seed}`,i=await la(t.session,_(wt(),"authored",`${n}.authored`),"authored"),r=new Map;for(let a of t.shots)for(let s of a.classes)r.set(s,(r.get(s)??0)+1);let o=[`session_id: ${i.id}`,`${t.shots.length} shots from ${t.pool.used} clips: ${[...r].map(([a,s])=>`${s} ${a}`).join(", ")}`,...t.pool.skipped.length?[`skipped ${t.pool.skipped.length}: ${t.pool.skipped.slice(0,5).join("; ")}`]:[],await hs(t.session)];return Tt(o.join(`
264
+ `),{session_id:i.id,shots:t.shots,titles:t.titles,skipped:t.pool.skipped})}catch(t){return ct(t)}}},{name:"timeline_relink",title:"Link / relink media (Conform Connect)",description:`The app's Conform Connect link wizard, as one call, on the same matcher and coverage law. Finds the media for the session's unbound references under a folder on this machine and repoints them.
265
+ gather: 'walk' (default) scans the folder recursively (name-first pre-filter, cap 2000) and matches by the criteria; 'path' is strict link \u2014 each reference must exist at its recorded relative path under the folder, no scan.
266
+ criteria (all optional; default = file_name on, tight): file_name + file_name_mode tight|loose (loose strips _Sxxx, _vN and proxy words like proxy/prx/offline/h264/prores and accepts \u22650.6 similarity), reel_name, total_duration, resolution, bit_depth, file_format, codec, media_umid, extensions. Enabled criteria are strict AND. Timecode containment (the file must hold the cut) and fps are ALWAYS enforced. For renamed media use reel_name=true, file_name=false. For proxy\u2192OCF use file_name_mode loose and leave resolution/codec off.
267
+ tolerances: timecode_tolerance_frames (1), duration_tolerance_seconds (0.1), min_name_similarity (0.6), fps_tolerance (0.005).
268
+ scope: ref_ids limits to a zone; lane video|audio|both limits by track usage; reset=true re-points already-linked refs in scope (they are unbound first).
269
+ dry_run=true proposes without changing anything: per reference matched/ambiguous/unmatched, the chosen file, confidence, reasons, refusals with the coverage reason, and alternatives; compare=true adds the per-criterion project-vs-media table. accept=[{ref_id,candidate_id}] commits only those rows (ids from a dry run) \u2014 the manual pick. Without accept, every matched row is applied. media_root omitted \u2192 the remembered locations are tried; remember=true saves this folder. Ends with the link summary and what is still unresolved, with the reason.`,inputSchema:{session_id:O.string(),media_root:O.string().optional().describe("Folder to link from; omit to use remembered locations"),gather:O.enum(["walk","path"]).default("walk"),criteria:O.object({file_name:O.boolean().optional(),file_name_mode:O.enum(["tight","loose"]).optional(),reel_name:O.boolean().optional(),total_duration:O.boolean().optional(),resolution:O.boolean().optional(),bit_depth:O.boolean().optional(),file_format:O.boolean().optional(),codec:O.boolean().optional(),media_umid:O.boolean().optional(),extensions:O.array(O.string()).optional().describe("Only consider these extensions, e.g. ['mxf','mov']")}).optional(),tolerances:O.object({timecode_tolerance_frames:O.number().optional(),duration_tolerance_seconds:O.number().optional(),min_name_similarity:O.number().optional(),fps_tolerance:O.number().optional(),aspect_tolerance:O.number().optional()}).optional(),ref_ids:O.array(O.string()).optional().describe("Only these references (a zone)"),lane:O.enum(["video","audio","both"]).default("both"),reset:O.boolean().default(!1).describe("Re-point refs in scope even if already linked"),dry_run:O.boolean().default(!1).describe("Propose only; change nothing"),compare:O.boolean().default(!1).describe("With dry_run: show the per-criterion comparison for each matched row"),accept:O.array(O.object({ref_id:O.string(),candidate_id:O.string()})).optional().describe("Commit only these rows (from a dry run)"),cap:O.number().int().min(1).max(2e4).default(2e3),remember:O.boolean().default(!1)},run:async e=>{try{let t=await ci(e.session_id),n=await JV(t.session,e);return n.changed&&(t.session=n.session,await ns(t,n.note)),hr(n.text)}catch(t){return ct(t)}}},{name:"timeline_write",protectedStages:["write"],title:"Write a timeline for a host",description:"Write the session for a host, on this machine. Prefer a DESTINATION (the host the user is going to): resolve, premiere, avid, flame, finalcut, baselight, protools \u2014 it writes the host's native file AND its fallback (e.g. resolve = .drt + XML for Resolve; avid = .avb + AAF) into one folder named for the host, with a README saying which to open first. Single formats still work as targets: resolve-drt (DaVinci Resolve timeline, preferred for Resolve), premiere-prproj, avid-avb (Media Composer bin), avid-aaf, flame-archive, baselight-blscene, finalcut-fcpxmld, resolve-xmeml, flame-fcpxml, resolve-otio. Short aliases drt/prproj/avb/aaf/xmeml/fcpxml/otio work. Returns the written path and the capability issues: what this target host cannot carry from the source (nests flattened, effects dropped, etc.) \u2014 always relay those to the user.",inputSchema:{session_id:O.string(),target:O.string().describe("A destination (resolve, premiere, avid, flame, finalcut, baselight, protools) or a single target format, e.g. resolve-drt, or an alias like drt"),out_path:O.string().optional().describe("Output file path, or a directory (file name is derived; a destination writes a host-named folder inside it). Defaults next to the source file.")},run:async({session_id:e,target:t,out_path:n})=>{try{let i=await ci(e);if(y0(t)){let s=await EV(i.session,t,n,i.source_path);await ns(i,`write ${t} \u2192 ${s.folder}`);let c=s.files.map(l=>`${l.path} (${l.bytes} bytes, ${l.target})`+(l.issues.length?`
270
+ issues (${l.issues.length}):
271
+ ${l.issues.map(u=>` - [${u.severity??"info"}] ${u.code?`${u.code}: `:""}${u.message}`).join(`
272
+ `)}`:`
273
+ no capability issues`));return hr(`wrote ${s.folder}/ \u2014 README.txt says which to open first
274
+ ${c.join(`
275
+ `)}${s.pending?`
276
+ ${s.pending} is not included yet (writer pending its host's import law)`:""}`)}let r=await T7(i.session,t,n,i.source_path);await ns(i,`write ${t} \u2192 ${r.path}`);let o=r.issues.length?`
277
+ issues (${r.issues.length}):
278
+ ${r.issues.map(s=>`- [${s.severity??"info"}] ${s.code?`${s.code}: `:""}${s.message}`).join(`
279
+ `)}`:`
280
+ no capability issues`,a=await e0("conform-artist",["write"]);return hr(`wrote ${r.path} (${r.bytes} bytes)${o}${a?`
281
+
282
+ Reading this write (conform.tools playbook):
283
+ ${a}`:""}`)}catch(i){return ct(i)}}},{name:"timeline_routes",title:"Supported formats and operations",description:"List what can be read, what can be written (first-class vs beta), aliases, and the editing operations. Use when asked 'can you convert X to Y' or what the tool supports.",inputSchema:{},run:()=>hr(CV())},{name:"timeline_sessions",title:"List sessions",description:"List sessions read earlier (id, source file, format, when, edit history). Sessions persist across restarts.",inputSchema:{},run:async()=>{let e=await SL();return hr(e.length?e.map(t=>`${t.id} ${t.source_path} (${t.source_format}) updated ${t.updated_at}${t.history.length?` \u2014 ${t.history.length} edits`:""}`).join(`
284
+ `):"(no sessions)")}},{name:"session_export",title:"Export Session IR",description:"Write the session's IR JSON (the engine's canonical timeline representation) to a file, for tooling, diffing or archiving.",inputSchema:{session_id:O.string(),out_path:O.string()},run:async({session_id:e,out_path:t})=>{try{let n=await ci(e);return await ln(t,JSON.stringify(n.session,null,1)),hr(`wrote ${t}`)}catch(n){return ct(n)}}},{name:"media_probe",title:"Probe a media file",description:"Read a media file's facts on this machine (never uploads): container, codec, raster, frame rate, start timecode, frame count, duration, audio, reel. Supports mov/mp4/m4v (ProRes, DNx, H.264/HEVC\u2026), braw, crm, mxf (ARRI/Sony/DNx), wav, RED .R3D (spanned clips: any part or the .RDC folder). Use before media_trim to know the file's start timecode and length. A WAV has no frame rate: pass fps (the project's) for its BWF start TC and length in frames; without it both 23.976 and 24 are shown.",inputSchema:{path:O.string(),fps:O.number().positive().optional().describe("audio-only files: the video rate to count the BWF timecode and length at (23.976, 24, 25, 29.97\u2026)")},run:async({path:e,fps:t})=>{try{return hr(g5(await Rn(e),t))}catch(n){return ct(n)}}},{name:"timeline_diff",protectedStages:["canonicalize"],title:"Source diff of two cuts (online vs editorial)",description:"Compare WHERE THE PICTURE COMES FROM in two cuts aligned by record TC: A = the online/colour timeline, B = the newest editorial turnover (each a session_id or a timeline file). Per record frame it takes the topmost enabled video clip (by_track=true: each video track by name, V1 vs V1\u2026) and reports the record ranges whose source differs: only_in_a / only_in_b (missing or extra clips), different_file (another file or reel \u2014 temp vs master; a different TC base is called out), same_name_different_clip (same file name but a different start TC or length: dated batch folders reuse names, never trust the name alone), source_tc (same file, slipped N frames). Starts with the count per kind; every range lists both sides' file, source TC, track and item id. csv_path / edl_path write every range (the EDL carries B's sources: what to drop into A); session=true makes a new session of B's clips under those ranges only (an insert timeline for timeline_write). Read-only on both cuts.",inputSchema:{a_session_id:O.string().optional().describe("A (online/colour) as a session"),a:O.string().optional().describe("A as a timeline file, instead of a_session_id"),b_session_id:O.string().optional().describe("B (editorial turnover) as a session"),b:O.string().optional().describe("B as a timeline file, instead of b_session_id"),a_timeline_id:O.string().optional(),b_timeline_id:O.string().optional(),by_track:O.boolean().default(!1).describe("Compare each video track by name instead of the topmost picture"),limit:O.number().int().min(1).max(5e3).default(100).describe("Ranges in the reply (files always have all)"),csv_path:O.string().optional(),edl_path:O.string().optional(),session:O.boolean().default(!1).describe("Also create a session of B's differing clips (insert timeline)")},run:async({a_session_id:e,a:t,b_session_id:n,b:i,a_timeline_id:r,b_timeline_id:o,by_track:a,limit:s=100,csv_path:c,edl_path:l,session:u})=>{try{let f=async(g,y,w)=>{if(g){let x=await ci(g);return{session:x.session,name:`session ${g} (${ae(x.source_path)})`}}if(y)return{session:(await Su(y)).session,name:ae(y)};throw new ze("invalid_args",`give ${w}_session_id or ${w} (a timeline file)`)},d=await f(e,t,"a"),m=await f(n,i,"b"),p=hZ(d.session,m.session,{a_timeline_id:r,b_timeline_id:o,by_track:a}),b=[];c&&(await ln(c,gZ(p.ranges)),b.push(`CSV: ${c} (${p.ranges.length} ranges)`)),l&&(await ln(l,vZ(p,`${p.tb.name} SOURCE DIFF`)),b.push(`EDL: ${l} (B sources)`));let h;if(u&&p.ranges.length){let g=await la(yZ(m.session,p),_(wt(),"authored",`${p.tb.name} source diff.authored`),"diff");h=g.id,b.push(`session_id: ${g.id} (B's clips under the differing ranges; timeline_write it)`)}let v=Object.fromEntries(Q7.map(g=>[g,p.ranges.filter(y=>y.kind===g).length]));return Tt([bZ(p,d.name,m.name,s),...b].join(`
285
+ `),{counts:v,total:p.ranges.length,ranges:p.ranges.slice(0,s),truncated:p.ranges.length>s,session_id:h,csv_path:c,edl_path:l})}catch(f){return ct(f)}}},{name:"media_aspect",title:"Active picture and OAR of a movie",description:"Find a movie's active picture (letterbox / pillarbox / windowbox) and the original aspect ratio it implies, snapped to the standard ratios (1.33, 1.78, 1.85, 1.90, 2.00, 2.39 \u2026), with the OAR raster (full width, even height). 16 frames across the clip; a bar counts only when \u226580% of them carry it, so fades and black leaders don't invent one. Use on the screener / editorial REF to decide OAR deliverables vs a 16x9 container, and on a render to confirm it.",inputSchema:{path:O.string(),samples:O.number().int().min(4).max(64).optional().describe("Frames sampled (default 16)")},run:async({path:e,samples:t})=>{try{let n=await lW(e,t);return Tt(uW(n),{...n})}catch(n){return ct(n)}}},{name:"media_find",title:"Find media by name or ID on a volume",description:"Search a folder or volume (read-only walk) for media whose name holds a name or ID fragment, and probe each match so temp and master can be told apart: codec, raster, rate, start\u2013end TC, frames, duration. Matching ignores case, spaces/underscores/dots and doubled extensions (`X.mov.mov`, `X.mov_001.mov`); when the whole fragment is not found, a file that holds every digit-bearing token of it matches as an id match (a misspelt word around the ID). Files with the same name in different folders are called out: dated batch folders reuse names for DIFFERENT clips, so match by TC + duration, never by name alone. Bounded by max_depth, max_entries and time_limit_s; when a bound stops it the reply starts with TRUNCATED.",inputSchema:{path:O.string().describe("Folder or volume to search"),query:O.string().min(2).describe("Name or ID fragment, e.g. 'XD32995' or 'XD32995_0158_0221_MultiClip.mov'"),max_depth:O.number().int().min(0).max(30).default(10),max_entries:O.number().int().min(1).max(2e6).default(2e5).describe("Directory entries to visit before stopping"),time_limit_s:O.number().min(1).max(600).default(60),probe:O.boolean().default(!0).describe("Probe each match (codec, raster, rate, TC, length)"),limit:O.number().int().min(1).max(5e3).default(100)},run:async({path:e,query:t,max_depth:n,max_entries:i,time_limit_s:r,probe:o,limit:a})=>{try{let s=await v5(e,t,{max_depth:n??10,max_entries:i??2e5,time_limit_s:r??60,probe:o??!0});return a??=100,Tt(y5(s,e,t,a),{scanned:s.scanned,truncated:s.truncated,total:s.hits.length,hits:s.hits.slice(0,a).map(c=>({path:c.path,match:c.match,size:c.size,facts:c.facts?Sf(c.facts):null,source_timecode:c.facts?.source_timecode??null,frames:c.facts?.available_range?.duration?.value??c.facts?.declared_duration?.value??null,error:c.error}))})}catch(s){return ct(s)}}},{name:"media_coverage",title:"Does a file cover these TC ranges (and how much handle)?",description:"Check that a media file holds the source ranges a cut needs, and how much handle it has: per range covered, or NOT covered and short by N frames at head/tail, plus the head/tail handle in frames. ranges: [{in, out, label?}] as absolute source timecode (the file's own TC, e.g. 23:59:12:10; out exclusive, as an EDL reads; TC wraps at midnight) or file-local frame numbers. Or session_id + item_ids: the clips' used source ranges (from their own media's TC), checked against path, or against each clip's own file when path is omitted. A master with a different TC base than the temp the cut was made on will show NOT covered: that is the answer (the client's clip-TC list is then the mapping). handles: also flag ranges with less than this many frames each side.",inputSchema:{path:O.string().optional().describe("The media file to check (required with ranges)"),ranges:O.array(O.object({in:O.union([O.string(),O.number().int()]),out:O.union([O.string(),O.number().int()]),label:O.string().optional()})).optional(),session_id:O.string().optional(),item_ids:O.array(O.string()).optional().describe("Clip item ids (timeline_inspect detail=clips / timeline_query)"),handles:O.number().int().min(0).default(0).describe("Required handle per side, frames")},run:async({path:e,ranges:t,session_id:n,item_ids:i,handles:r})=>{try{let o=new Map,a=[];if(t?.length){if(!e)throw new ze("invalid_args","path is required with ranges");o.set(e,[...t])}if(n){if(!i?.length)throw new ze("invalid_args","item_ids is required with session_id");let d=(await ci(n)).session,m=new Map((d.media_references??[]).map(b=>[b.id,b])),p=new Map(d.timelines.flatMap(b=>b.tracks.flatMap(h=>h.items)).map(b=>[b.id,b]));for(let b of i){let h=p.get(b);if(!h?.source_range){a.push(`${b}: no such clip with a source range`);continue}let v=h.media_reference_id?m.get(h.media_reference_id):void 0,g=(v?.local_path??v?.target_url??"").replace(/^file:\/\//,""),y=e??g;if(!y){a.push(`${b}: the clip has no media path; pass path`);continue}let w=h.source_range.start.rate||v?.source_fps||24,x=v?.source_fps||w,T=h.source_range.start.value*x/w,z=h.source_range.duration.value*x/w,k=v?.source_timecode?Kn(v.source_timecode,x):null,S=Math.round(x)*86400,M=!!v?.source_timecode?.includes(";"),L=P=>k==null?Math.round(P):tn(Math.round(k+P)%S,x,M);(o.get(y)??o.set(y,[]).get(y)).push({label:`${b} ${h.name??""}`.trim(),in:L(T),out:L(T+z)})}}if(!o.size)throw new ze("invalid_args",a.length?a.join("; "):"give path + ranges, or session_id + item_ids");let s=[],c=[],l=0,u=0;for(let[d,m]of o){let p=await w5(d,m,r);c.push({path:d,facts:Sf(p.facts),rows:p.rows}),s.push(`${d}
286
+ ${Sf(p.facts)}`,...p.rows.map(b=>` - ${b.label}: ${b.in_tc}\u2013${b.out_tc} (${b.frames} fr) ${b.note}`)),l+=p.rows.filter(b=>!b.covered).length,u+=p.rows.length}let f=l?`${l} of ${u} range${u===1?"":"s"} NOT covered`:`all ${u} range${u===1?"":"s"} covered`;return Tt([f,...s,...a.map(d=>`skipped ${d}`)].join(`
287
+ `),{covered:u-l,not_covered:l,files:c,skipped:a})}catch(o){return ct(o)}}},{name:"media_trim",title:"Trim a media file",description:"Cut a shorter file out of a source WITHOUT re-encoding (byte-exact essence copy, index rebuilt; source timecode is preserved so the trim relinks in any host). in/out are frame indexes (0 = first frame) or timecodes relative to the file's start TC; out is the LAST frame included unless out_exclusive=true. handles adds frames on both sides (clamped to the file). Supports mov/mp4/m4v (ProRes, DNx, H.264/HEVC \u2014 long-GOP snaps to keyframes), braw, crm, mxf, wav, and RED .R3D (spanned .RDC clips: pass any part or the folder; output is a new .RDC). Returns the new path(s) and the frames written.",inputSchema:{path:O.string(),in:O.union([O.string(),O.number().int()]).describe("First frame: frame index or timecode like 01:00:10:00"),out:O.union([O.string(),O.number().int()]).describe("Last frame (inclusive) or timecode; set out_exclusive for an edit-style out point"),out_exclusive:O.boolean().optional(),handles:O.number().int().min(0).optional().describe("Extra frames on each side"),out_path:O.string().optional().describe("Output file or directory; default is next to the source as <name>_trim_<in>-<out>.<ext>")},run:async e=>{try{let t=await Ep(e),n=t.facts.streams?.find(i=>i.kind==="video");return hr(`${t.outputs.map(i=>`wrote ${i.path} (${(i.bytes/1e6).toFixed(1)} MB${i.part?`, part ${i.part}`:""})`).join(`
288
+ `)}
289
+ frames ${t.first_frame}\u2013${t.last_frame} (${t.frames} frames)
290
+ source: ${n?.codec??"?"} ${n?.width??"?"}x${n?.height??"?"} @ ${t.fps} fps, start TC ${t.facts.source_timecode??"none"}`)}catch(t){return ct(t)}}},{name:"media_patch",long:!0,title:"Patch frames into a master",description:"Cut a fixed range of frames into a finished master BY TIMECODE, WITHOUT re-encoding (the Resolve 'bypass re-encode' fix, for ProRes and DNxHD/HR .mov). patch = a render of the fixed range in the master's exact spec with record TC: codec/profile, raster, rate, alpha/depth and colour tags are checked first, the patch lands at (patch start TC \u2212 master start TC) and needs a TC track at the master's TC rate and DF/NDF; a mismatch, a patch without TC or a range outside the master is refused and nothing is written. in/out on the master (frames or timecodes, like media_trim; out inclusive) only cross-check that placement or pick part of the patch: an in= that disagrees with the TC is refused. Patch frames may be bigger or smaller than the ones they replace. mode new (default): a new file beside the master (<name>_patched), rewritten contiguously in the master's interleave order; the master untouched. mode section: a new file of just the patched range with the master's TC and audio. mode in_place: ONLY when the user asks to modify the master itself \u2014 the patch frames are appended and the index rewritten (the file grows by the patch, the replaced frames stay as dead bytes, the patched span loses interleave locality), the old index kept so mode=undo restores the file byte for byte. mode check: the spec + TC check, nothing written. mode plan (H.264/HEVC, BEFORE rendering a patch; needs in/out, no patch): the whole-GOP span of the master to render (keyframe at/before in \u2192 frame before the next keyframe after out; an open GOP after it included), its TCs, the GOP length and B-frames. Every write is verified (frame count, the master's TC track unchanged, frames at the patch's TC byte-identical to the patch and decoding to its pixels, the frames either side the master's, audio and untouched frames identical) and rolled back if it fails. in_place proves audio/TC untouched from the index by default (every sample at its original offset and size, the write append-only), so a feature master patches in about a minute; verify=full re-reads and hashes them (minutes a pass over a share). patches=[\u2026] puts several into one master in one call (all checked first; overlap refused). Long: background=true for a job id with progress. H.264/HEVC (long-GOP): a patch that replaces whole closed GOPs encoded like the master's (span from a master keyframe to the frame before the next, identical avcC/hvcC, keyframes and B-frame offsets) cuts in with no re-encode; anything else is refused, naming the GOP span to render.",inputSchema:{path:O.string().describe("The master .mov"),patch:O.string().optional().describe("The render of the fixed range (not needed for mode=undo)"),mode:O.enum(["new","section","in_place","check","undo","plan"]).optional().describe("Default new; in_place only when asked to modify the master itself; plan before rendering a long-GOP patch"),in:O.union([O.string(),O.number().int()]).optional().describe("Cross-check: the master frame (index or timecode) to start at; must agree with the patch's TC"),out:O.union([O.string(),O.number().int()]).optional().describe("Last master frame to replace (inclusive); default: to the end of the patch"),patch_in:O.number().int().min(0).optional().describe("First patch frame to use (default: the one at in= by TC, else 0)"),out_path:O.string().optional().describe("Output file or folder for mode new/section; never overwritten"),patches:O.array(O.string()).optional().describe("in_place/check: several patch renders into this master in one call, each placed by its own TC (instead of patch)"),verify:O.enum(["index","full"]).optional().describe("in_place: index (default) proves audio/TC untouched from the index; full re-reads and hashes them")},run:async({__progress:e,__signal:t,...n})=>{try{let i=await t9(n,e);return Tt(i.text,i.data)}catch(i){return ct(i)}}},{name:"media_repair_cadence",long:!0,repoOnly:!0,title:"Repair an AI render's cadence",description:"Put back the frames an AI video edit (e.g. Seedance video_edit) held or skipped, against the plate it was made from. Held frames (a near-copy of the previous frame while the plate moves) are cut; skipped source frames are found by aligning the render to the plate and filled with ONE RIFE v4.22.lite in-between each; every unique render frame passes through untouched and the output has the plate's frame count, at the plate's rate (ProRes 422 HQ). A render the AI RE-PACED (it races ahead of the performance, then pays it back) is reported and NOT repaired unless force=true \u2014 filling it would cut real frames, a creative decision. plan_only reports without writing. Report: held frames, gaps (which plate frames), RIFE output frames, motion dips/jumps against the plate. Needs CONFORM_PYTHON with torch + torchvision + numpy, and ffmpeg.",inputSchema:{plate:O.string().describe("The source plate the AI was given"),render:O.string().describe("The raw AI render"),out_path:O.string().optional().describe("Output .mov; default <render>_cadence.mov beside the render"),plate_start:O.number().int().min(0).optional().describe("First plate frame the AI was given (default 0)"),plate_frames:O.number().int().min(2).optional().describe("Plate frames the AI was given (default: to the end)"),mask:O.tuple([O.number(),O.number(),O.number(),O.number()]).optional().describe("x0,y0,x1,y1 fractions: an area the AI changed on purpose, left out of the alignment"),plan_only:O.boolean().optional(),force:O.boolean().optional().describe("Repair even when a re-pace is detected")},run:async e=>{try{return hr(xZ(await wZ(e)))}catch(t){return ct(t)}}},{name:"media_consolidate",long:!0,title:"Consolidate media for a timeline",description:"Timeline-driven trim: for every source file the cut uses, write a byte-exact trim of just the used frames plus handles into out_dir (no re-encode; ProRes/DNx/H.264 mov, mxf, wav, RED .R3D). This is the conform 'consolidate' / 'media manage' step. By default only linked references are trimmed (run timeline_relink first so paths are verified); set only_linked=false to trim whatever paths exist on disk. With relink=true (default) the session is repointed at the trims, so a following timeline_write links to the consolidated media. Reports each output and everything skipped, with the reason.",inputSchema:{session_id:O.string(),out_dir:O.string().describe("Folder for the trimmed media"),handles:O.number().int().min(0).default(24).describe("Frames of handle on each side of every used range"),relink:O.boolean().default(!0).describe("Repoint the session at the trims"),only_linked:O.boolean().default(!0)},run:async({session_id:e,out_dir:t,handles:n,relink:i,only_linked:r})=>{try{let o=await ci(e),a=await AV(o.session,t,n,{relink:i,only_linked:r});return await ns(o,`consolidate \u2192 ${t} (${a.outputs.length} files, ${n} handles)`),hr(a.text)}catch(o){return ct(o)}}},{name:"color_match",title:"Match a shot's color to a reference image",description:`Conform Connect's auto color, headless: solve the grade that moves a SOURCE frame onto a REFERENCE image (an AI-generated still, a client frame grab, a graded still \u2014 png/jpg/tiff/exr/dpx decoded by our own engine, or a frame of another clip). The same histogram + covariance match and fold fit the Lab runs; the result is Resolve corrector nodes (tone 1, match matrix, tone 2 bypassed) as finish entries. Default method hm-mkl-hm works against ANY reference; hm-mvgd-hm is the Lab's default and needs a pixel-aligned pair (the same frame recolored, e.g. an AI color transfer output). With session_id + item the grade is installed on that clip, so timeline_write resolve-drt then carries it as live nodes on Resolve's color page. reference "ai" balances the frame with the local model (colour from the model, exposure mostly held, as on conform.tools) and fits it from the pixel pairs (method pixel); the first use needs download: true. With session_id + item, a Color Space Transform on the clip's colour page (read from the .drt) runs first \u2014 our own CST, exact to Resolve's \u2014 so the balance and the fit happen after it, and the written .drt keeps that CST node in front of the new nodes. Camera-native raw sources are refused (they decode as log); match on a proxy or a rendered frame.`,inputSchema:{source:O.string().describe("Media file (ProRes/DNx/MXF) or a still to grade"),frame:O.union([O.number().int(),O.string()]).optional().describe("Frame index or timecode of the source frame (default: the middle of the file)"),reference:O.string().describe('The look to match: a still image, a media file (+reference_frame), or "ai" \u2014 a first-pass balance by FLUX.2 klein running on THIS machine (Apple Silicon, 16 GB+; nothing is uploaded)'),reference_frame:O.union([O.number().int(),O.string()]).optional(),method:O.enum(UD).optional().describe('default hm-mkl-hm; for reference "ai" the default is primaries: ONE corrector node of gain/lift per channel, one gamma, contrast and saturation, skin protected on faces'),mixer:O.boolean().optional().describe("method primaries: also use the RGB Mixer (default false: a plain balance of gain/lift/gamma/contrast/saturation)"),skin_protect:O.number().min(1).max(20).optional().describe("method primaries: skin protection strength, default 3 (1 = off). Only inside detected faces, scaled by how much of the frame they fill; it moves colour only and keeps the balance's contrast"),transfer:O.enum(["srgb","g24"]).optional().describe("Override the source's encoding (default: g24 for video, srgb for stills)"),session_id:O.string().optional().describe("Install the grade on a clip of this session"),item:O.string().optional().describe("The clip to grade: item id or unique clip name (with session_id)"),download:O.boolean().optional().describe('reference "ai" only: allow the one-time model download (~4.3 GB into ~/.conform-mcp/models). Ask the user first.')},run:async({source:e,frame:t,reference:n,reference_frame:i,method:r,transfer:o,session_id:a,item:s,download:c,mixer:l,skin_protect:u})=>{try{let f=a?await ci(a):null;if(f&&!s)throw new ze("invalid_args","item is required with session_id");let d=f&&s?YD(f.session,s):null;if(f&&!d)throw new ze("not_found",`no clip '${s}' in session ${a} (timeline_inspect detail=clips lists ids and names)`);let m=d?BD(f.session,d.itemId):void 0,p=await GD({source:e,frame:t,reference:n,reference_frame:i,method:r,transfer:o,item_id:s,download:c,cst:m,mixer:l,skinBoost:u}),b={method:p.method,transfer:p.transfer,residual:p.residual,luma_stops:p.lumaStops,source:p.source,reference:p.reference,entries:p.entries,...p.cst?{cst:p.cst}:{}},h="";if(f&&d){let v=JD(p,d.timelineId,d.itemId);for(let g of v)S7(f.session,"finish_op",g);await ns(f,`color_match ${ae(n)} \u2192 ${d.name||d.itemId} (${p.method})`),b.session_id=a,b.item_id=d.itemId,h=`
291
+ installed on ${d.name||d.itemId} in session ${a}: timeline_write target=resolve-drt writes it as corrector nodes`}return Tt(KD(p)+h,b)}catch(f){return ct(f)}}},{name:"media_deliver",protectedStages:["write"],long:!0,title:"Deliver a package (folder or ISO)",description:`The app's i2o delivery, on this machine: the conform package a colourist or VFX house receives. Layout: 01_PROJECT_FILES/source (the original timeline), 01_PROJECT_FILES/converted (the requested host timelines, media paths rewritten to the package), 02_MEDIA (every used source trimmed byte-exact to the used frames + handles; RED clips as .RDC bundles), 03_REFERENCES.
292
+ destination=folder writes that tree into out_path. destination=iso writes ONE sparse UDF image (mountable on macOS/Windows/Linux; only the cut's frames are real bytes, the rest are holes) at out_path (.iso file or a folder), with the session and intent hashes stamped in the volume (IUVD) and verified after writing.
293
+ Only linked references ship (run timeline_relink first). A clip that cannot be trimmed is reported and NEVER shipped whole. timeline_formats picks which host timelines ride along, e.g. ['resolve-drt','avid-avb'] (default resolve-drt).`,inputSchema:{session_id:O.string(),destination:O.enum(["folder","iso"]),out_path:O.string().describe("Folder to write the package into, or the .iso path"),volume_name:O.string().optional().describe("Package / volume name; default from the source file"),handles:O.number().int().min(0).default(24),preserve_structure:O.boolean().default(!1).describe("Mirror the sources' parent folders under 02_MEDIA"),timeline_formats:O.array(O.string()).default(["resolve-drt"]),only_linked:O.boolean().default(!0)},run:async({session_id:e,destination:t,out_path:n,volume_name:i,handles:r,preserve_structure:o,timeline_formats:a,only_linked:s})=>{try{let c=await ci(e),l={out_path:n,volume_name:i,handles:r,preserve_structure:o,timeline_formats:a,only_linked:s},u=t==="iso"?await sZ(c.session,c.source_path,l):await aZ(c.session,c.source_path,l);await ns(c,`deliver ${t} \u2192 ${n}`);let f=await e0("delivery-qc",u.keys);return hr(`${u.text}${f?`
294
+
295
+ Reading this delivery (conform.tools playbook):
296
+ ${f}`:""}`)}catch(c){return ct(c)}}},{name:"timeline_judge",repoOnly:!0,title:"Judge a written timeline against its source",description:"Law-backed check of a written timeline file against the source it came from: the same timing, sizing, link and content judges that run on every production conversion, using each host's decoded rules. Pass the source file and the written file (e.g. the AAF you read and the .drt you wrote). Returns a verdict (clean / issues), the reasons, per-tier tallies and the clips with issues. Judged formats: prproj, drt, xmeml, aaf, avb, flame. Use after timeline_write when the user asks whether the conversion is right, or before delivering.",inputSchema:{source_path:O.string().describe("The original timeline file"),output_path:O.string().describe("The written timeline file to judge")},run:async({source_path:e,output_path:t})=>{try{return hr(await GV(e,t))}catch(n){return ct(n)}}},{name:"timeline_autoconform",long:!0,protectedStages:["canonicalize"],title:"Auto conform a reference to source media",description:"Rebuild a cut from a reference render: reads every frame of the reference and the pool as a tiny luma grid at each codec's cheapest tier, aligns the whole reference against the pool in one pass (grade-proof take codes name the clip, difference-mode motion names the frame, one path over the film finds the cuts), measures each shot's sizing, and builds a new timeline session at the reference's raster and rate with markers on every issue (gap, unresolved, contested, reframe, retime). reference: a ProRes .mov (or camera original) of the cut. pool: folders and/or files of source media (mov/mp4/r3d/mxf/braw/ari/crm; spanned RED = one clip). hints_session_id: an editor's timeline of the same cut to verify and correct instead of searching blind (much faster). reframe_tier: the SSCD embedding pass that places punched-in/reframed shots under graphics \u2014 on automatically when its model is installed; false skips it (faster), true requires it. examine_all=true disables early stopping. Returns a session_id for timeline_write plus the coverage stats and the issue list. H.264/HEVC (references or pool) decode with the OS's own decoder (macOS today).",inputSchema:{reference:O.string().describe("Path to the reference render of the cut (ProRes, H.264, HEVC, or a camera original)"),pool:O.array(O.string()).min(1).describe("Folders and/or media files to search"),hints_session_id:O.string().optional().describe("Session id of the editor's timeline for this cut, if you have one"),reframe_tier:O.boolean().optional().describe("SSCD reframe tier: omit = on when the model is installed"),examine_all:O.boolean().default(!1),display_transform:O.boolean().optional().describe("Decode camera originals display-referred (Log \u2192 Rec.709/2.4 through the Color Space Transform) to match a GRADED reference. Experimental; X-OCN today"),engine:O.enum(["align","legacy"]).optional().describe("align (default): the whole-film aligner. legacy: the older per-shot matcher (used automatically with hints_session_id)"),find_first:O.boolean().optional().describe("legacy engine only: look each reference shot up in a sparse index of the pool and confirm it with pixels, instead of decoding every clip densely \u2014 far faster on big camera-original pools (needs the SSCD model)"),sizing:O.boolean().optional().describe("Measure each placed shot's scale/position/rotation/mirror from a dozen frame pairs (default on; shots it cannot measure are left at 100 % and flagged). false keeps the per-frame ORB estimate"),name:O.string().optional().describe("Timeline name"),background:O.boolean().default(!1).describe("Return a job id immediately; poll with job_status, cancel with job_cancel")},run:async({reference:e,pool:t,hints_session_id:n,reframe_tier:i,examine_all:r,engine:o,find_first:a,display_transform:s,sizing:c,name:l,__progress:u,__signal:f})=>{try{let d=n?(await ci(n)).session:void 0,m=await wI({reference:e,pool:t,hints:d,reframe_tier:i,examine_all:r,engine:o,find_first:a,display_transform:s,sizing:c,name:l,onProgress:u,signal:f}),p=await la(m.session,e,"autoconform"),b=await e0("auto-conform",xI(m));return hr(`session_id: ${p.id}
297
+ ${PI(m)}
298
+ ${await hs(m.session)}${b?`
299
+
300
+ Reading this result (conform.tools playbook):
301
+ ${b}`:""}`)}catch(d){return ct(d)}}},{name:"qc_compare",long:!0,title:"Compare two versions of a cut and rebuild the new one from the old",description:"Reference Compare: diff two renders of a cut (A = the old version, B = the new one) frame by frame and say what changed: frames inserted, removed, moved, replaced. Perceptual, so it survives a regrade or a re-render; A and B may differ in codec (ProRes, H.264, HEVC, camera originals) and resolution, and a frame-rate difference is normalised and reported. Builds the reconform: events that rebuild B from A (A-source events + holes of new material), each verified against the pictures (an event that does not reproduce B, a hold, a reverse or a retime, is flagged CHECK BY EYE, never shown as exact). Writes a CMX3600 EDL and/or CSV when given paths, and returns a session of B rebuilt from A's media (session_id, for timeline_write). Use for a re-cut after colour ('what changed in v3?'), checking a deliverable against the approved version, or reconforming changes into a graded timeline. Long: background=true for a job id.",inputSchema:{a:O.string().describe("Path to the OLD version (whose media and grade exist)"),b:O.string().describe("Path to the NEW version, to rebuild from A"),min_run:O.number().int().min(1).optional().describe("Shortest run in frames that counts as an event (default 3; shorter = noise)"),edl_path:O.string().optional().describe("Write the reconform as a CMX3600 EDL here"),csv_path:O.string().optional().describe("Write the reconform events as CSV here")},run:async({a:e,b:t,min_run:n,edl_path:i,csv_path:r,__progress:o,__signal:a})=>{try{let s=await jI({a:e,b:t,min_run:n,onProgress:o,signal:a});i&&await ln(i,s.edl),r&&await ln(r,s.csv);let c=await la(s.session,t,"reconform"),l=[`session_id: ${c.id} (B rebuilt from A; timeline_write it to any host)`,...i?[`EDL: ${i}`]:[],...r?[`CSV: ${r}`]:[],ZI(s,{a:e,b:t})].join(`
302
+ `);return Tt(l,{session_id:c.id,summary:s.summary,stats:s.stats,warnings:s.result.warnings,unreproducible:s.unreproducible.map(u=>({index:u.index,record:[u.recordInTc,u.recordOutTc],note:u.unreproducible.note})),lanes:s.lanes})}catch(s){return ct(s)}}},{name:"render_gate",title:"Check a timeline before a deliverable render",description:"Run BEFORE every deliverable render. From the read timeline and the mix WAVs (placed by their BWF timecode): the program start (the mix's 2-pop + 2 s, else program_start, else the artist profile's, else the picture's first frame), picture end vs the mix's last sound (any difference, even 1 frame, is an EDIT ERROR: fix or ask, never cut at picture), picture/mix starting late, the last program frame (picture, not a gap), gaps inside the program, video layers ending just short of the end, and the deliverable name's audio promise (8CH_5-1_STEREO = 6ch + 2ch) vs the mix files. Returns READY/STOP and the Mark In/Out to render with (Out inclusive). Then render (host_render, audio_tracks for the output routing) and qc_deliverable the file.",inputSchema:{session_id:O.string().describe("The timeline (timeline_read / host_current)"),mix:O.array(O.string()).optional().describe("The mix WAV(s); the first sets the program length"),program_start:O.string().optional().describe("Program start TC when the mix has no 2-pop (default: the artist profile's program_start)"),name:O.string().optional().describe("The deliverable file name about to be rendered"),timeline_id:O.string().optional()},run:async({session_id:e,...t})=>{try{let n=await sW((await ci(e)).session,t);return Tt(cW(n),{...n})}catch(n){return ct(n)}}},{name:"qc_deliverable",long:!0,title:"Sign off a deliverable render",description:"QC a rendered deliverable before it goes out, PASS/FAIL per check: codec/raster/rate/bit depth/chroma (when given), start TC (mark_in, start_tc or the artist profile's program_start; else reported only) and frame count (mark_in..mark_out inclusive, or frames), the file name against the facility naming profile and against the file itself (codec, raster, colour tags, audio channels), black at the head/tail with its length (WARN; end_on_picture=true makes tail black FAIL), audio per output track (channels, integrated loudness, true peak; AAC included) and against the mix WAVs (each track must match one mix within 0.5 LU: +6 LU = summed twice, an unmatched mix = missing bus), and picture vs the approved REF (frame-exact at the render's start TC; burn-ins and a regrade do not count as differences). Use after every deliverable render. Long: background=true for a job id.",inputSchema:{path:O.string().describe("The rendered deliverable"),mark_in:O.union([O.string(),O.number().int()]).optional().describe("Timeline Mark In (TC or frame): the expected start TC"),mark_out:O.union([O.string(),O.number().int()]).optional().describe("Timeline Mark Out, INCLUSIVE: with mark_in, the expected frame count"),start_tc:O.string().optional().describe("Expected start TC when there is no mark_in (default: the artist profile's program_start)"),frames:O.number().int().positive().optional().describe("Expected frame count"),codec:O.string().optional().describe("e.g. 'ProRes 4444', 'ProRes 422 HQ', 'H.264'"),width:O.number().int().positive().optional(),height:O.number().int().positive().optional(),fps:O.number().positive().optional(),bit_depth:O.number().int().optional(),chroma:O.string().optional().describe("e.g. 4:4:4"),channels:O.number().int().min(0).optional().describe("Total audio channels expected"),loudness_lufs:O.number().optional().describe("Target integrated loudness per track (e.g. -24)"),loudness_tolerance:O.number().positive().optional().describe("\xB1 LU (default 1)"),true_peak:O.number().optional().describe("True-peak ceiling, dBTP (e.g. -2)"),mix:O.array(O.string()).optional().describe("The mix WAVs / stems the audio outputs must carry"),ref:O.string().optional().describe("The approved reference movie"),ref_in:O.union([O.string(),O.number().int()]).optional().describe("The REF's TC/frame for the render's first frame (default the render's start TC)"),name:O.boolean().optional().describe("Check the name against the naming profile (default true)"),end_on_picture:O.boolean().optional().describe("The program ends on its end card: any black at the tail FAILS (default: WARN with its length)")},run:async({__progress:e,__signal:t,...n})=>{try{let i=await iW(n);return Tt(oW(i),{...i})}catch(i){return ct(i)}}},{name:"patch_plan",title:"Plan patch renders for changed shots",description:"Work out the patches to re-render for changed shots on a read timeline (a session from host_current / host_export / timeline_read), before anything is queued. Each patch runs from the head of the WHOLE clip before the change to the tail of the WHOLE clip after it, cut on existing edits of the picture as it plays (the topmost enabled video layer), never inside a lower third/title (graphics tracks, by name) or a transition; contiguous changes share one patch. Says the neighbouring clips, whether TEXTLESS is needed (a graphics track has content in range \u2192 TEXTED + TEXTLESS, with the tracks to leave out of TEXTLESS), picture only, file TC = record TC of the head. Returns host_render-ready ranges (absolute frames, inclusive) plus record TC. Give master (a delivered file's name) to get each patch's file name, render job name and folder from the naming profile. Read-only.",inputSchema:{session_id:O.string(),changes:O.array(O.union([O.string(),O.object({in:O.union([O.string(),O.number()]),out:O.union([O.string(),O.number()])})])).min(1).describe("The changed shots: clip item_ids (timeline_query), or record ranges {in, out} as record TC or absolute timeline frames, out inclusive"),timeline_id:O.string().optional().describe("The timeline (default the session's first with video)"),master:O.string().optional().describe("A delivered master's file name (or path) to name the patches from (naming profile)"),first_patch:O.number().int().min(1).default(1).describe("Number of the first patch (PATCH01)")},run:async({session_id:e,changes:t,timeline_id:n,master:i,first_patch:r})=>{try{let o=await ci(e),a=gW(o.session,t,{timeline_id:n,first_patch:r}),s=vW(a);if(i){let c=await Di(),l=new Date,u=a.patches.map(f=>f.versions.map(d=>({text:d,...Sy(c,i,{nn:f.nn,text:d,when:l})})));return s+=`
303
+ `+u.flat().map(f=>`name ${f.file} job ${f.job} \u2192 ${f.folder}`).join(`
304
+ `),Tt(s,{...a,names:u})}return Tt(s,{...a})}catch(o){return ct(o)}}},{name:"media_frame",title:"Grab frames from a media file",description:"Decode a frame of a media file to a PNG on this machine (our own decoders: ProRes, DNx, H.264/HEVC, MXF, camera originals; never uploads). frame is a frame index (0 = first) or an ABSOLUTE source timecode (the file's start TC is honoured); default the middle frame. around=N makes a contact sheet of the frames \xB1N (every step-th), each labelled with its TC \u2014 check a shot change, not one middle frame. b = a second file: A/B rows of the same frames (b_frame defaults to the same absolute TC; give it when the TC bases differ) with a perceptual difference score per column (survives a regrade, burn-in/watermark, rescale). Prove a frame offset with media_align. Writes out_path (.png) or a temp file; returns the path \u2014 open it to look.",inputSchema:{path:O.string(),frame:O.union([O.string(),O.number().int()]).optional().describe("Frame index or absolute source TC like 01:00:10:00; default the middle frame"),around:O.number().int().min(0).max(48).optional().describe("Contact sheet: \xB1N frames around frame"),step:O.number().int().min(1).optional().describe("Contact sheet: every Nth frame (default 1)"),b:O.string().optional().describe("A second file for A/B (e.g. the master against the temp)"),b_frame:O.union([O.string(),O.number().int()]).optional().describe("B's frame or TC for A's frame; default the same absolute TC"),width:O.number().int().min(16).max(8192).optional().describe("Output width per frame (default full size; 480 per tile on a sheet)"),out_path:O.string().optional().describe("PNG to write; default a temp file")},run:async e=>{try{let t=await V9(e);return Tt(j9(t),{...t})}catch(t){return ct(t)}}},{name:"timeline_frame",title:"Grab the source frame under a timeline position",description:"media_frame through a session: the source file and frame under an item (item_id; record moves inside it) or under a record TC (the topmost enabled video clip there), decoded to a PNG; around=N for a contact sheet. Returns the file, source frame and TC it resolved to. The clip must be linked (timeline_relink first).",inputSchema:{session_id:O.string(),item_id:O.string().optional(),record:O.union([O.string(),O.number().int()]).optional().describe("Record TC like 01:00:10:00, or frames from the timeline head"),timeline:O.string().optional().describe("Timeline id or name (default the primary)"),around:O.number().int().min(0).max(48).optional(),step:O.number().int().min(1).optional(),width:O.number().int().min(16).max(8192).optional(),out_path:O.string().optional()},run:async({session_id:e,item_id:t,record:n,timeline:i,...r})=>{try{let o=await ci(e),a=HI(o.session,{item_id:t,record:n,timeline:i}),s=await V9({...r,path:a.path,frame:a.frame});return Tt(`record ${a.record_tc} (${a.track}, item ${a.item}) = ${ae(a.path)} frame ${a.frame} (${s.frames[s.frames.length>>1]?.tc??"?"})
305
+ ${j9(s)}`,{...s,source:a})}catch(o){return ct(o)}}},{name:"patch_verify",long:!0,title:"Verify a rendered patch against the delivered master",description:"Check a rendered patch against the master it patches: spec (codec, ProRes profile, pixel format, bit depth, raster, frame rate, colour tags), frame count, start TC = the record TC, picture only, then the picture frame by frame against the master at the same TC (every frame; per-frame mismatches with their TC and difference, plus the patch's shot changes). After a splice (media_patch), the seam decode proof: full-raster decoded frames \xB12 s around each seam, exact: inside the span = the patch, outside = original (a backup or the unpatched master) when given, and every frame decodes. Use after every patch render, before it goes to the client. Read-only. Long: background=true for a job id.",inputSchema:{patch:O.string().describe("The rendered patch file"),master:O.string().describe("The delivered master file it patches"),expected_tc:O.string().optional().describe("The record TC the patch must start at (patch_plan start_tc)"),expected_frames:O.number().int().min(1).optional().describe("The frame count it must have (patch_plan frames)"),tolerance:O.number().min(0).max(255).default(10).describe("Largest luma difference (0-255, on a 64-wide thumbnail) still counted as the same picture"),original:O.string().optional().describe("After a splice: the backup / unpatched master, so the seam proof checks the neighbouring frames are untouched")},run:async({patch:e,master:t,expected_tc:n,expected_frames:i,tolerance:r,original:o,__progress:a})=>{try{let s=await yW({patch:e,master:t,expected_tc:n,expected_frames:i,tolerance:r,original:o},void 0,a);return Tt(wW(s,{patch:e,master:t}),{...s})}catch(s){return ct(s)}}},{name:"artist_profile",title:"How this artist works: learn, read and remember",description:"conform.tools works the way THIS artist/facility works, never one built-in way. Their profile holds naming templates, the usual deliverable set, folders/bins, conventions (program_start TC, end_on_picture, theatrical_tag) and workflow rules in their words, each with where it came from. action=get (default) shows it; read it before naming, rendering or delivering. learn reads a folder of their DELIVERED files (read only): matches each name element to what the file really is (codec, raster+rate, colour, audio, dates) and saves the naming template, the usual deliverable set and the codec folders (project= keeps them as that project's spellings; save=false previews). remember saves a preference: rule='\u2026' (topic e.g. deliverables/naming/render/patch) and/or conventions={program_start:'01:00:00:00', \u2026}. Save only what is THIS artist's choice; when they correct you, ask: 'your preference, or should every artist work this way?'; the second is a product issue (report_issue), not a profile rule. forget removes a rule (number or text). set replaces the whole profile JSON.",inputSchema:{action:O.enum(["get","learn","remember","forget","set"]).default("get"),path:O.string().optional().describe("learn: a folder of delivered files (or one file)"),project:O.string().optional().describe("learn: save as this project's spellings over the artist's"),facility:O.string().optional().describe("learn: the artist's or facility's name"),save:O.boolean().default(!0).describe("learn: false = preview only"),rule:O.string().optional().describe("remember: the preference in the artist's words; forget: text or number"),topic:O.string().optional().describe("remember: naming, deliverables, render, patch, conform\u2026"),source:O.string().optional().describe("remember: where it came from (default 'told')"),conventions:O.object({program_start:O.string().optional(),end_on_picture:O.boolean().optional(),theatrical_tag:O.string().optional(),no_audio_tag:O.string().optional()}).optional(),profile:O.record(O.string(),O.unknown()).optional().describe("set: the whole profile JSON")},run:async({action:e,path:t,project:n,facility:i,save:r,rule:o,topic:a,source:s,conventions:c,profile:l})=>{try{let u=await Di();switch(e??"get"){case"learn":{if(!t)return ct(new ze("invalid_args","learn needs path (a folder of delivered files)"));let f=await z5(t,{project:n,facility:i,save:r}),d=[`${f.source}${f.saved?` \u2192 saved ${f.saved}`:" (preview, not saved)"}`,...Object.entries(f.learned.templates??{}).map(([m,p])=>` ${m}: ${p}`),...(f.learned.deliverables??[]).map(m=>` usual: ${m.label} (${m.CODEC} ${m.AUDIOCONFIG} .${m.ext}${m.texts.length?`, ${m.texts.join("/")}`:""})`),...Object.entries(f.learned.codec_folders??{}).map(([m,p])=>` folder: ${m}\u2026 \u2192 ${p}`),...f.misfits.length?[` ${f.misfits.length} name(s) follow another pattern: ${f.misfits.slice(0,5).join(", ")}`]:[],...f.name_issues.map(m=>` check ${m.file}: ${m.issues.join("; ")}`),"Ask the artist what files cannot show: is this the usual set, the program start TC, any optional kinds (artist_profile action=remember)."];return Tt(d.join(`
306
+ `),{...f})}case"remember":{if(!o&&!c)return ct(new ze("invalid_args","remember needs rule or conventions"));o&&(u=M5(u,{rule:o,topic:a,source:s??"told"})),c&&(u=L5(u,c,s??"told"));let f=await il(u);return Tt(`remembered \u2192 ${f}
307
+ ${zf(u)}`,{profile:u,path:f})}case"forget":{if(!o)return ct(new ze("invalid_args","forget needs rule (its number or text)"));u=O5(u,/^\d+$/.test(o)?Number(o):o);let f=await il(u);return Tt(`forgotten \u2192 ${f}
308
+ ${zf(u)}`,{profile:u,path:f})}case"set":{let f=await il(l);return Tt(`saved \u2192 ${f}`,{path:f})}default:return Tt(zf(u),{profile:u})}}catch(u){return ct(u)}}},{name:"naming",title:"The artist's naming: build and check names",description:"The artist's own naming convention (from their artist_profile) for everything conform.tools names: deliverables, patches, timelines, documents, render jobs, folders. There is no built-in convention: with no profile, learn it first (artist_profile action=learn) or ask. Names are copied EXACTLY from the convention (separators, order, spellings). action=get shows the profile; set saves one ({facility, templates: {kind: '[TITLE]_[TEXT]_\u2026'}, values?, codec_folders?}); build makes a name of a kind from values; patch derives a patch's file name, render job name and folder FROM a delivered master's file name (the artist's patch template, their no-audio tag when picture-only, today's date/time, every other element the master's); check validates a name against the template (separators, order), against the file's probe facts (path: codec, raster, rate, colour tags, audio channels, the H264_25mbps bitrate) and against the master it patches; legacy operator initials after the date are noted, not required. deliverables expands the artist's usual deliverable set for a program (values: TITLE, COLORSPACE, GAMMA, FORMAT at the OAR) into file names: TEXTLESS only with textless=true (text over picture), optional kinds (UHD H.264) with include_optional. project applies that project's own spellings (profile.projects[PROJECT]: templates/values/deliverables) over the facility's structure.",inputSchema:{action:O.enum(["get","set","build","patch","check","deliverables"]).default("get"),project:O.string().optional().describe("Use this project's spellings (profile.projects[project]) over the facility's"),textless:O.boolean().optional().describe("deliverables: the program has text over picture, so a TEXTLESS version is made"),include_optional:O.boolean().optional().describe("deliverables: include the optional kinds (e.g. UHD H.264)"),profile:O.record(O.string(),O.unknown()).optional().describe("set: the profile JSON"),kind:O.string().optional().describe("build/check: the template kind (deliverable, patch, timeline, replace_list, tracklayout, qc, render_job, deliverables_folder)"),values:O.record(O.string(),O.string()).optional().describe("build: the elements, e.g. {TITLE: 'TRIMBLE', SOURCE: 'TRIMBLE_LP COLOR', PURPOSE: 'ARCHIVAL', SCOPE: 'REPLACE_XD32995'}; YYYYMMDD/HHMM default to now"),name:O.string().optional().describe("check: the name to check"),path:O.string().optional().describe("check: the file the name is for (probed)"),master:O.string().optional().describe("patch/check: the delivered master's file name"),nn:O.number().int().min(1).default(1).describe("patch: the patch number"),text:O.enum(["TEXTED","TEXTLESS"]).optional().describe("patch: the version (default the master's)"),picture_only:O.boolean().default(!0).describe("patch: AUDIOCONFIG = the artist's no-audio tag")},run:async({action:e,profile:t,kind:n,values:i,name:r,path:o,master:a,nn:s,text:c,picture_only:l,project:u,textless:f,include_optional:d})=>{try{let m=await Di(u);switch(e??"get"){case"set":{let p=await il(t);return Tt(`saved the ${t?.facility??""} naming profile \u2192 ${p}`,{path:p})}case"build":{if(!n)return ct(new ze("invalid_args","build needs kind"));let p=nl(m,n,{...Cp(),...i});return Tt(p,{name:p,kind:n})}case"patch":{if(!a)return ct(new ze("invalid_args","patch needs master (a delivered file's name)"));let p=Sy(m,a,{nn:s??1,text:c,picture_only:l});return Tt(`${p.file}
309
+ render job: ${p.job}
310
+ folder: ${p.folder}`,{...p})}case"check":{if(!r)return ct(new ze("invalid_args","check needs name"));let p=rl(m,r,{kind:n,master:a,probe:o?await Rn(o):void 0}),b=p.issues.filter(h=>h.level==="error");return Tt([`${b.length?"WRONG":"ok"}: ${r} (${m.facility} ${p.kind})`,...p.issues.map(h=>` ${h.level}: ${h.element}: ${h.message}`)].join(`
311
+ `),{...p,ok_name:!b.length})}case"deliverables":{let p=S5(m,i??{},{textless:!!f,include_optional:d});return Tt([`${m.facility}${u?` / ${u}`:""} usual deliverables:`,...p.map(b=>` ${b.name} (${b.label}, ${b.text}, ${b.raster}${b.container?" 16x9 container":""}, ${b.audio})`),...f?[]:[" (no TEXTLESS: pass textless=true when the program has text over picture)"]].join(`
312
+ `),{deliverables:p})}default:return Tt(Object.keys(m.templates).length?`${m.facility} naming profile
313
+ ${JSON.stringify(m,null,2)}`:zf(m),{profile:m})}}catch(m){return ct(m)}}},{name:"media_align",long:!0,title:"Frame offset between a temp and its master",description:"Prove (or find) where a range of file A (the temp / graded reference) sits in file B (the master), frame-exact. Give a_in/a_out (frame or absolute TC in A; default all of A) and b_in, the frame/TC in B the client maps a_in to; without b_in all of B is searched. Checks \xB1search frames (default 12), anchored on shot changes present in both; perceptual (a regrade, a burned-in TC/watermark, a rescale do not move it). Reports overall and per shot: exact / offset N frames (+ = later in B) with a confidence / unverifiable (static picture: the offsets that fit equally) / no match, plus flash-frame risk (a B shot change inside or within 3 frames of the range). Use before replacing a temp with a master on another TC base, and when the client's mapping disagrees with the graded temp.",inputSchema:{a:O.string().describe("The temp / graded reference"),a_in:O.union([O.string(),O.number().int()]).optional(),a_out:O.union([O.string(),O.number().int()]).optional().describe("Last frame included"),b:O.string().describe("The master"),b_in:O.union([O.string(),O.number().int()]).optional().describe("The client's in-point in B for a_in; omit to search"),search:O.number().int().min(1).max(250).optional().describe("\xB1frames checked (default 12)")},run:async({__progress:e,__signal:t,...n})=>{try{let i=await Gg({...n,signal:t});return Tt(qI(i),{...i})}catch(i){return ct(i)}}},{name:"job_status",title:"Status of a background job",description:"Status, phase and progress of a job started with background=true (auto conform, deliver, consolidate), and its result once finished.",inputSchema:{job_id:O.string()},run:async({job_id:e})=>{let t=await eL(e);if(!t)return ct(new ze("not_found",`no job ${e}`));let n=iP(t);return t.status==="done"&&t.result?Tt(`${n}
314
+
315
+ ${t.result.content.map(i=>i.text).join(`
316
+ `)}`,{job:t,result:t.result.structuredContent??null}):Tt(n,{job:t})}},{name:"job_cancel",title:"Cancel a background job",description:"Cancel a running background job. Partial outputs already written stay on disk and are named in the job's result.",inputSchema:{job_id:O.string()},run:async({job_id:e})=>tL(e)?Tt(`cancelling ${e}`,{job_id:e}):ct(new ze("not_found",`no running job ${e}`))},{name:"job_list",title:"List jobs",description:"Recent background jobs (running and finished) with status and progress.",inputSchema:{},run:async()=>{let e=await nL();return Tt(e.length?e.map(iP).join(`
317
+ `):"(no jobs)",{jobs:e})}}],mse=new Set(["account_login","account_status","account_logout","account_telemetry","timeline_routes","report_issue","report_gap","report_note"]),QD=new Set(["account_status","conform_learn","timeline_read","host_current","host_project","timeline_inspect","timeline_routes","timeline_sessions","media_probe","media_find","media_coverage","timeline_judge","timeline_autoconform","job_status","job_list","patch_plan","patch_verify","media_align"]),pse=new Set(["account_login","account_logout","account_telemetry","report_issue","report_gap","report_note","host_open","host_setup","timeline_edit","timeline_author","timeline_generate","timeline_relink","color_match","job_cancel","naming","artist_profile","media_frame","timeline_frame"]);function y9e(e){return{readOnlyHint:QD.has(e),destructiveHint:!QD.has(e)&&!pse.has(e)}}async function w9e(e,t){let n=N4(e);if(!n)return ct(new ze("not_found",`unknown verb '${e}'`));if(!mse.has(e))try{await K6()}catch(o){return ct(o)}let i=bse(t),r=await $2.run({verb:e,declared:n.protectedStages??[]},()=>yse(n,e,i));return vse(e,r)}var hse=new Set(["path","paths","out_path","out_dir","media_root","reference","pool","source_path","output_path","plate","render","target_dir","media_dirs","a","b","edl_path","csv_path","patch","master"]);function bse(e){let t={...e};for(let n of hse){let i=t[n];n==="reference"&&i==="ai"||(typeof i=="string"&&i?t[n]=zv(i):Array.isArray(i)&&(t[n]=i.map(r=>typeof r=="string"&&r?zv(r):r)))}return t}var gse={timeline_read:"conform",host_current:"conform",timeline_relink:"conform",timeline_write:"conform",timeline_autoconform:"autoconform",media_consolidate:"deliver",media_deliver:"deliver"};function vse(e,t){let n=gse[e];return!n||t.isError||QO()?t:{...t,content:[...t.content,{type:"text",text:`Next: call conform_learn task=${n} (with the hosts involved) before going further, and follow the playbook it returns.`}]}}async function yse(e,t,n){let i=performance.now(),r=async(a,s)=>{let c=Math.round(performance.now()-i),l=a.content.map(f=>f.text).join(`
318
+ `),u=typeof n.session_id=="string"?n.session_id:l.match(/session_id: (\w+)/)?.[1];return await aL({ts:new Date().toISOString(),verb:t,ms:c,ok:!a.isError,code:a.isError?String(a.structuredContent?.code??"engine"):void 0,msg:a.isError?l.slice(0,500):void 0,...s.withArgs?{args:oL(n)}:{},job:s.job,session:u,note:s.note}),c},o=async(a,s)=>{let c=await r(a,{job:s,withArgs:!0});return e.long&&n.background||hP(t,a,c),a};if(e.long){let{background:a,...s}=n,c=$O(t,async(l,u)=>await e.run({...s,__progress:l,__signal:u}));return a?(rP(c.id)?.then(async l=>hP(t,l,await r(l,{job:c.id,note:"job finished"}))),o(Tt(`started ${c.id} (${t}) \u2014 poll job_status`,{job_id:c.id}),c.id)):o(await rP(c.id),c.id)}try{return await o(await e.run(n))}catch(a){return o(ct(a))}}function x9e(e,t){let n=N4(e);if(!n)return{ok:!1,result:ct(new ze("not_found",`unknown verb '${e}'`))};let i=O.object(n.inputSchema).safeParse(t??{});if(i.success)return{ok:!0,data:i.data};bP(e,a0(i.error.issues));let r=i.error.issues.map(o=>`${o.path.join(".")||"(args)"}: ${o.message}`).join("; ");return{ok:!1,result:ct(new ze("invalid_args",r,{fields:a0(i.error.issues)}))}}function P9e(e,t){let n=N4(e);if(!n)return;let i=O.object(n.inputSchema).safeParse(t??{});i.success||bP(e,a0(i.error.issues))}var wse=dse.filter(e=>!e.repoOnly||qO);function N4(e){return wse.find(t=>t.name===e)}export{xse as a,Uc as b,op as c,Rue as d,so as e,WC as f,My as g,qC as h,Zn as i,Ve as j,Ua as k,vU as l,A as m,Kp as n,Qp as o,TU as p,zU as q,It as r,fT as s,wb as t,fd as u,i2 as v,o2 as w,l2 as x,tc as y,hd as z,AM as A,JM as B,El as C,YM as D,v2 as E,x2 as F,Gb as G,tO as H,vd as I,nc as J,dO as K,vO as L,Pd as M,O as N,ac as O,Zpe as P,$b as Q,_b as R,Ipe as S,Wpe as T,Dpe as U,qpe as V,eL as W,tL as X,nL as Y,ehe as Z,the as _,y9e as $,w9e as aa,x9e as ba,P9e as ca,wse as da,N4 as ea};