framefields 2.2.0-beta.0 → 2.2.0-beta.1

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 (31) hide show
  1. package/dist/effects/index.d.mts +1 -1
  2. package/dist/effects/index.mjs +1 -1
  3. package/dist/{index-Bg8HIYAO.d.mts → index-DLbtJPrc.d.mts} +20 -9
  4. package/dist/index-DLbtJPrc.d.mts.map +1 -0
  5. package/dist/index-DgJIBC_N.d.mts.map +1 -1
  6. package/dist/index.d.mts +2 -2
  7. package/dist/index.d.mts.map +1 -1
  8. package/dist/index.mjs +3 -3
  9. package/dist/preview/index.mjs +1 -1
  10. package/dist/{preview-RdaP0Rfv.mjs → preview-BQ3BhcVX.mjs} +2 -2
  11. package/dist/{preview-RdaP0Rfv.mjs.map → preview-BQ3BhcVX.mjs.map} +1 -1
  12. package/dist/preview-engine/chunk-7OMK352W.mjs +1 -0
  13. package/dist/preview-engine/{chunk-UKBUEM3G.mjs → chunk-HFUA47QH.mjs} +1 -1
  14. package/dist/preview-engine/chunk-K7M5EIFC.mjs +98 -0
  15. package/dist/preview-engine/{chunk-FFQ3K5FW.mjs → chunk-Z457JJCO.mjs} +1 -1
  16. package/dist/preview-engine/effects.mjs +1 -1
  17. package/dist/preview-engine/framefields.mjs +1 -1
  18. package/dist/preview-engine/player.mjs +1 -1
  19. package/dist/preview-engine/{renderers-57WDL6XN.mjs → renderers-HVTQ2B3H.mjs} +1 -1
  20. package/dist/renderer/index.mjs +1 -1
  21. package/dist/renderer-CZKFEf_6.mjs +3 -0
  22. package/dist/{renderer-CfR0GeQL.mjs → renderer-DzDZlez7.mjs} +2 -2
  23. package/dist/{renderer-CfR0GeQL.mjs.map → renderer-DzDZlez7.mjs.map} +1 -1
  24. package/dist/{renderer-mp1NN5zk.mjs → renderer-dc39dBVA.mjs} +283 -79
  25. package/dist/renderer-dc39dBVA.mjs.map +1 -0
  26. package/package.json +58 -55
  27. package/dist/index-Bg8HIYAO.d.mts.map +0 -1
  28. package/dist/preview-engine/chunk-3GNP7TJH.mjs +0 -98
  29. package/dist/preview-engine/chunk-VRGREB3V.mjs +0 -1
  30. package/dist/renderer-GSFP7v2z.mjs +0 -3
  31. package/dist/renderer-mp1NN5zk.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ import{a as _,c as G}from"./chunk-IQKIHFNZ.mjs";import{d as p,e as f}from"./chunk-BVF64D6H.mjs";f();var w=8,W=/^\s*(linear|radial|conic)-gradient\(\s*([\s\S]*)\)\s*$/i;function A(t){return typeof t=="string"&&W.test(t)}function U(t){let e=[],n=0,o="";for(let r of t)r==="("&&n++,r===")"&&n--,r===","&&n===0?(e.push(o.trim()),o=""):o+=r;return o.trim()&&e.push(o.trim()),e}function x(t){let e=/^(-?[\d.]+)(deg|turn|rad|grad)?$/i.exec(t.trim());if(!e)return null;let n=parseFloat(e[1]);switch((e[2]??"deg").toLowerCase()){case"turn":return n*360;case"rad":return n*180/Math.PI;case"grad":return n*.9;default:return n}}var I={top:0,right:90,bottom:180,left:270,"top right":45,"right top":45,"bottom right":135,"right bottom":135,"bottom left":225,"left bottom":225,"top left":315,"left top":315},T={left:0,top:0,center:.5,right:1,bottom:1};function F(t){let e=t.map(r=>r in T?{v:T[r],axis:r==="top"||r==="bottom"?"y":r==="left"||r==="right"?"x":"any"}:{v:r.endsWith("%")?parseFloat(r)/100:.5,axis:"any"}),n=.5,o=.5;return e.length===1?e[0].axis==="y"?o=e[0].v:n=e[0].v:e.length>=2&&(e[0].axis==="y"||e[1].axis==="x"?(o=e[0].v,n=e[1].v):(n=e[0].v,o=e[1].v)),[n,o]}function R(t){let e=/^((?:[a-z]+\([^)]*\))|#[0-9a-f]+|[a-z]+)\s*(.*)$/i.exec(t.trim());if(!e)return null;let n=G(e[1]);if(!n)return null;let o=[];for(let r of e[2].split(/\s+/).filter(Boolean))if(r.endsWith("%"))o.push(parseFloat(r)/100);else if(r==="0")o.push(0);else if(/(deg|turn|rad|grad)$/i.test(r)){let i=x(r);i!==null&&o.push(i/360)}return{color:n,positions:o.filter(r=>Number.isFinite(r))}}function V(t){let e=t.length;if(e===0)return[];let n=t.map(r=>r.position);n[0]===void 0&&(n[0]=0),n[e-1]===void 0&&(n[e-1]=1);let o=-1/0;for(let r=0;r<e;r++){let i=n[r];i!==void 0&&(n[r]=Math.max(i,o),o=n[r])}for(let r=1;r<e;r++){if(n[r]!==void 0)continue;let i=r;for(;n[i]===void 0;)i++;let a=n[r-1],s=n[i];for(let u=r;u<i;u++)n[u]=a+(s-a)*(u-r+1)/(i-r+1)}return t.map((r,i)=>({offset:n[i],color:r.color}))}var v=new Map;function E(t){let e=v.get(t);if(e!==void 0)return e;let n=L(t);return v.size>512&&v.clear(),v.set(t,n),n}function L(t){let e=W.exec(t);if(!e)return null;let n=e[1].toLowerCase(),o=U(e[2]),r={type:n,angle:180,center:[.5,.5],shape:"ellipse",from:0,stops:[]},i=o[0]?.toLowerCase().trim()??"",a=!1;if(n==="linear")if(i.startsWith("to ")){let u=i.slice(3).trim().replace(/\s+/g," ");u in I&&(r.angle=I[u],a=!0)}else{let u=x(i);u!==null&&(r.angle=u,a=!0)}else{let u=i.split(/\s+/).filter(Boolean),l=u.indexOf("at"),c=l>=0?u.slice(0,l):u;if(l>=0||c.some(d=>d==="circle"||d==="ellipse"||d==="from"||/^closest|^farthest/.test(d)||n==="radial"&&/px$/.test(d)))if(a=!0,l>=0&&(r.center=F(u.slice(l+1))),n==="radial"){c.includes("circle")&&(r.shape="circle");let d=c.filter(h=>/px$/.test(h)).map(h=>parseFloat(h));d.length===1?(r.shape="circle",r.radius=[d[0],d[0]]):d.length>=2&&(r.radius=[d[0],d[1]])}else{let d=c.indexOf("from");d>=0&&c[d+1]&&(r.from=x(c[d+1])??0)}}let s=[];for(let u of a?o.slice(1):o){let l=R(u);if(!l)return null;l.positions.length===0&&s.push({color:l.color});for(let c of l.positions)s.push({color:l.color,position:c})}return s.length===0?null:(s.length===1&&s.push({...s[0]}),r.stops=V(s),r)}function Y(t){if(t.length<=w)return t;let e=[],n=t[0].offset,o=t[t.length-1].offset;for(let r=0;r<w;r++){let i=n+(o-n)*r/(w-1),a=1;for(;a<t.length-1&&t[a].offset<i;)a++;let s=t[a-1],u=t[a],l=u.offset-s.offset,c=l>0?Math.min(1,Math.max(0,(i-s.offset)/l)):1;e.push({offset:i,color:s.color.map((m,d)=>m+(u.color[d]-m)*c)})}return e}function J(t){let e=t.map(n=>_(n.color[0],n.color[1],n.color[2]));return t.map((n,o)=>{let r=e[o];if(n.color[3]<1e-4){let i=t.slice(0,o).reverse().findIndex(l=>l.color[3]>1e-4),a=t.slice(o+1).findIndex(l=>l.color[3]>1e-4),s=i>=0?o-1-i:-1,u=a>=0?o+1+a:-1;if(s>=0&&u>=0){let l=e[s],c=e[u];r=[(l[0]+c[0])/2,(l[1]+c[1])/2,(l[2]+c[2])/2]}else s>=0?r=e[s]:u>=0&&(r=e[u])}return[r[0],r[1],r[2],n.color[3]]})}function S(t){return t.map(e=>typeof e=="string"?e:`${e.color} ${Math.round(e.offset*1e4)/100}%`).join(", ")}var Z={linear(t,e=180){return`linear-gradient(${e}deg, ${S(t)})`},radial(t,e={}){let n=e.at??[.5,.5];return`radial-gradient(${e.radius!==void 0?`${e.radius}px`:e.circle?"circle":"ellipse"} at ${n[0]*100}% ${n[1]*100}%, ${S(t)})`},conic(t,e={}){let n=e.at??[.5,.5];return`conic-gradient(from ${e.from??0}deg at ${n[0]*100}% ${n[1]*100}%, ${S(t)})`},parse:E,is:A};f();var M="onnxruntime-web",$=()=>import(M),P=class{kind="webgpu";_loader;_providers;_wasmFallback;_ortPromise;constructor(e={}){this._loader=e.loader??$,this._providers=e.executionProviders??["webgpu","wasm"],this._wasmFallback=e.wasmFallback!==!1}ort(){return this._ortPromise||(this._ortPromise=this._loader().catch(e=>{throw this._ortPromise=void 0,new Error(`onnxruntime-web failed to load (${String(e)}). Install it in the browser bundle or pass a custom loader.`)})),this._ortPromise}async createSession(e){let n=await this.ort(),o;try{o=await n.InferenceSession.create(e,{executionProviders:[...this._providers],graphOptimizationLevel:"all",logSeverityLevel:3})}catch(r){if(!this._wasmFallback||!this._providers.includes("webgpu"))throw r;o=await n.InferenceSession.create(e,{executionProviders:["wasm"],graphOptimizationLevel:"all",logSeverityLevel:3})}return{run:async r=>{let i=o.inputNames.includes(r.name)?r.name:o.inputNames[0]??r.name,a=await o.run({[i]:new n.Tensor("float32",r.data,[...r.dims])}),s={};for(let[u,l]of Object.entries(a))s[u]={data:l.data,dims:[...l.dims]};return s},release:()=>{o.release()}}}};f();f();var C="onnxruntime-web/webgpu",j="webgpu",b,D=/llvmpipe|lavapipe|swiftshader|software/i;function B(){return b||(b=(async()=>{let t=globalThis;if(!t.navigator?.gpu){let{create:i,globals:a}=await import(j);Object.assign(globalThis,a),t.navigator??={},Object.defineProperty(t.navigator,"gpu",{value:i([]),configurable:!0,writable:!0})}let n=await(t.navigator?.gpu).requestAdapter({powerPreference:"high-performance"});if(!n)throw new Error("No WebGPU adapter.");let o=n.info??{},r=[o.vendor,o.architecture,o.device,o.description].filter(Boolean).join(" ");if(n.isFallbackAdapter===!0||o.isFallbackAdapter===!0||D.test(r))throw new Error(`WebGPU adapter is a software rasterizer (${r}).`);z(n.features)})(),b.catch(()=>{b=void 0})),b}function z(t){let e=Object.getPrototypeOf(t);!e||typeof e.keys!="function"||(typeof e.forEach!="function"&&Object.defineProperty(e,"forEach",{value(n,o){for(let r of this.keys())n.call(o,r,r,this)},configurable:!0,writable:!0}),typeof e.values!="function"&&Object.defineProperty(e,"values",{value(){return this.keys()},configurable:!0,writable:!0}),typeof e.entries!="function"&&Object.defineProperty(e,"entries",{*value(){for(let n of this.keys())yield[n,n]},configurable:!0,writable:!0}))}var y=class{kind="webgpu";_inner;constructor(e={}){let n=e.loader??(async()=>{await B();let o=await import(C);return o.env?.wasm&&(o.env.wasm.numThreads=1),o.env?.webgpu&&(o.env.webgpu.powerPreference="high-performance"),o});this._inner=new P({wasmFallback:!1,...e,loader:n})}createSession(e){return this._inner.createSession(e)}};var O;function ue(t){O=t}function q(){let t=typeof p<"u"?p.env.FRAMEFIELDS_VISION_PROVIDER?.trim().toLowerCase():void 0;return t==="webgpu"||t==="cuda"||t==="cpu"?t:"auto"}var k=class{_resolved;_resolving;get kind(){return this._resolved?.kind??"webgpu"}async createSession(e){if(this._resolved)return this._resolved.createSession(e);if(!this._resolving){this._resolving=this.resolve(e),this._resolving.catch(()=>{this._resolving=void 0});let{provider:o,first:r}=await this._resolving;return this._resolved=o,r||o.createSession(e)}let{provider:n}=await this._resolving;return n.createSession(e)}async resolve(e){let n=q();if(n==="cpu")return{provider:new g};if(n==="cuda")return{provider:new g({executionProviders:["cuda","cpu"]})};let o=new y({wasmFallback:!1});try{return{provider:o,first:await o.createSession(e)}}catch(r){if(n==="webgpu")throw r;return{provider:new g}}}},N;function le(){return O?O():(N??=new k,N)}async function Q(){let t=await import("./shims/os.mjs"),e=typeof t.availableParallelism=="function"?t.availableParallelism():t.cpus().length,n=await H();return Math.max(1,n!==void 0?Math.min(e,n):e)}async function H(){if(typeof p>"u"||p.platform!=="linux")return;let{readFile:t}=await import("./shims/fs-promises.mjs"),e=a=>t(a,"utf8").then(s=>s.trim(),()=>{}),n=(a,s)=>a>0&&s>0?Math.ceil(a/s):void 0,o=await e("/sys/fs/cgroup/cpu.max");if(o!==void 0){let[a,s]=o.split(/\s+/);return a==="max"?void 0:n(Number(a),Number(s))}let r=await e("/sys/fs/cgroup/cpu/cpu.cfs_quota_us"),i=await e("/sys/fs/cgroup/cpu/cpu.cfs_period_us");if(!(r===void 0||i===void 0))return n(Number(r),Number(i))}async function K(){let t=typeof p<"u"?Number.parseInt(p.env.FRAMEFIELDS_VISION_THREADS??"",10):Number.NaN;if(Number.isFinite(t)&&t>0)return t;if(!(typeof p>"u"||p.platform!=="linux"))return Q()}var g=class{kind="node";_executionProviders;constructor(e={}){this._executionProviders=e.executionProviders??["cpu"]}ortPromise;async ort(){return this.ortPromise||(this.ortPromise=import("./onnxruntime-node-56GSZEH3.mjs").catch(e=>{throw this.ortPromise=void 0,new Error(`onnxruntime-node failed to load (${String(e)}). Install it in the environment or provide a custom SessionProvider.`)})),this.ortPromise}async createSession(e){let n=await this.ort(),o=await K(),r=await n.InferenceSession.create(e,{executionProviders:[...this._executionProviders],graphOptimizationLevel:"all",...o!==void 0?{intraOpNumThreads:o,interOpNumThreads:1}:{}});return{run:async i=>{let s={[r.inputNames.includes(i.name)?i.name:r.inputNames[0]??i.name]:new n.Tensor("float32",i.data,[...i.dims])},u=await r.run(s),l={};for(let[c,m]of Object.entries(u))l[c]={data:m.data,dims:[...m.dims]};return l},release:()=>{r.release()}}}};export{w as a,A as b,E as c,Y as d,J as e,Z as f,P as g,ue as h,le as i};
@@ -1 +1 @@
1
- import{a as t}from"./chunk-3GNP7TJH.mjs";import{a as $}from"./chunk-FJH5A2PV.mjs";import{h as j}from"./chunk-63SFBHEH.mjs";import{d,e as c}from"./chunk-BVF64D6H.mjs";c();c();c();c();c();c();function _(r){return typeof d<"u"?d.env?.[r]:void 0}function J(){let r=_("FRAMEFIELDS_STRICT_PROPS");return r==="1"||r==="true"}function Ee(){return J()||_("NODE_ENV")!=="production"}var Z=new Set;function K(r){if(J())throw new Error(r);Z.has(r)||(Z.add(r),console.warn(`[framefields] ${r}`))}function U(r){if(typeof r!="object"||r===null||Array.isArray(r)||j(r))return!1;let e=Object.getPrototypeOf(r);return e===Object.prototype||e===null}function we(r,e){let n=Array.from({length:e.length+1},(l,i)=>i);for(let l=1;l<=r.length;l++){let i=n[0];n[0]=l;for(let s=1;s<=e.length;s++){let u=n[s];n[s]=Math.min(n[s]+1,n[s-1]+1,i+(r[l-1]===e[s-1]?0:1)),i=u}}return n[e.length]}function ve(r,e){let n,l=Number.POSITIVE_INFINITY,i=r.toLowerCase();for(let u of e){let p=u.toLowerCase(),m=p.includes(i)||i.includes(p)?1:we(i,p);m<l&&(l=m,n=u)}return n&&l<=Math.max(2,Math.ceil(r.length/2))?` Did you mean "${n}"?`:` Known props: ${e.join(", ")}.`}function Me(r,e,n){if(typeof e=="number"){let{min:l,max:i}=n,s=l!==void 0&&e<l,u=i!==void 0&&e>i;if(s||u||Number.isNaN(e)){let p=l!==void 0&&i!==void 0?`${l} to ${i}`:l!==void 0?`\u2265 ${l}`:`\u2264 ${i}`;K(Number.isNaN(e)?`${r} is NaN`:`${r} = ${e} is outside ${p}`)}return}n.enum&&(typeof e=="string"||typeof e=="boolean")&&!n.enum.includes(e)&&K(`${r} = ${JSON.stringify(e)} is not one of ${n.enum.map(l=>JSON.stringify(l)).join(", ")}`)}function Q(r,e,n){let l=Object.keys(n);for(let[i,s]of Object.entries(e)){if(s===void 0)continue;let u=n[i];if(!u){K(`${r}: unknown prop "${i}".${ve(i,l)}`);continue}j(s)||typeof s=="function"||(u.props&&U(s)?Q(`${r}.${i}`,s,u.props):Me(`${r}.${i}`,s,u))}}function Re(r){return typeof r=="object"&&r!==null?structuredClone(r):r}function o(r,e,n,l){let i=n;Ee()&&Q(r,i,l);let s={};for(let[u,p]of Object.entries(e))s[u]=Re(p);for(let[u,p]of Object.entries(i)){if(p===void 0)continue;let m=s[u];s[u]=U(m)&&U(p)?{...m,...Object.fromEntries(Object.entries(p).filter(([,Ce])=>Ce!==void 0))}:p}return s}c();var a={AudioCompressor:{threshold:{min:-60,max:0},ratio:{min:1,max:100},attack:{min:1e-4,max:1},release:{min:.01,max:5},knee:{min:0,max:24},makeupGain:{min:0,max:24}},AudioDelay:{delayTime:{min:.001,max:5},feedback:{min:0,max:.95},wet:{min:0,max:1},dry:{min:0,max:1},pingPong:{}},AudioFade:{fadeInDuration:{min:0,max:60},fadeOutDuration:{min:0,max:60},fadeInCurve:{enum:["linear","exponential","scurve"]},fadeOutCurve:{enum:["linear","exponential","scurve"]}},AudioNoiseGate:{threshold:{min:-120,max:0},attack:{min:1e-4,max:1},hold:{min:.001,max:5},release:{min:.01,max:5},range:{min:-120,max:0}},AudioParametricEq:{type:{enum:["lowShelf","highShelf","peak","lowPass","highPass","notch"]},frequency:{min:20,max:2e4},gain:{min:-24,max:24},q:{min:.01,max:10}},AudioReverb:{roomSize:{min:0,max:.98},damping:{min:0,max:1},wet:{min:0,max:1},dry:{min:0,max:1},width:{min:0,max:1}},Blur:{blurType:{enum:["Gaussian","Box","Median","Motion","Bilateral","Edge-preserving","Radial","Zoom"]},strength:{min:0,max:100},angle:{min:0,max:360},sigmaColor:{min:.01,max:1},centerX:{min:0,max:1},centerY:{min:0,max:1},partialBlur:{},radius:{min:.01,max:1},radiusY:{min:0,max:1},shape:{enum:["ellipse","circle","rect"]}},CameraParallax3D:{motionPreset:{enum:["Custom","DollyZoom","Orbit","FlyThrough","HandheldShake","RackFocus"]},panX:{min:-1,max:1},panY:{min:-1,max:1},dollyZ:{min:-1,max:1},fov:{min:15,max:120},parallaxAmount:{min:0,max:2},dofAperture:{min:0,max:1},focusPlane:{min:0,max:1},edgeDilation:{min:0,max:1},depthInvert:{}},ChannelMerger:{colorSpace:{enum:["RGBA","HSLA","CMYK","LAB"]},defaultChannel4:{min:0,max:1}},ChannelSplitter:{colorSpace:{enum:["RGBA","HSLA","CMYK","LAB"]}},ColorBalance:{shadows:{props:{cyanRed:{min:-100,max:100},magentaGreen:{min:-100,max:100},yellowBlue:{min:-100,max:100}}},midtones:{props:{cyanRed:{min:-100,max:100},magentaGreen:{min:-100,max:100},yellowBlue:{min:-100,max:100}}},highlights:{props:{cyanRed:{min:-100,max:100},magentaGreen:{min:-100,max:100},yellowBlue:{min:-100,max:100}}},preserveLuminosity:{}},ColorKey:{keyColor:{},similarity:{min:0,max:1},smoothness:{min:0,max:1},spillSuppression:{min:0,max:1},colorSpace:{enum:["YUV","RGB"]},spillSuppressionType:{enum:["Desaturate","Neutralize","None"]}},CornerPin:{points:{}},DisplacementMap:{strengthX:{min:0,max:500},strengthY:{min:0,max:500},xChannel:{enum:["Red","Green","Blue","Alpha","Luminance"]},yChannel:{enum:["Red","Green","Blue","Alpha","Luminance"]},wrapMode:{enum:["Clamp","Repeat","Mirror"]}},ExtractLUT:{strategy:{enum:["deterministic","statistical"]},samplePoints:{min:10,max:500}},Flip:{horizontal:{},vertical:{},diagonal:{},mode:{enum:["horizontal","vertical","both","diagonal","antiDiagonal","custom"]},symmetry:{enum:["none","leftToRight","rightToLeft","topToBottom","bottomToTop","quadrant"]}},KenBurns:{keyframes:{},motionBlurSize:{min:0,max:10},movementStyle:{enum:["spline","direct"]},aspectRatio:{enum:["input","16:9","9:16","21:9","9:21","1:1","4:3","3:2","2:3","4:5","5:4"]}},LayerStyle:{dropShadow:{props:{enabled:{},color:{},opacity:{min:0,max:1},angle:{min:0,max:360},distance:{min:0,max:500},spread:{min:0,max:100},size:{min:0,max:250},blendMode:{}}},innerShadow:{props:{enabled:{},color:{},opacity:{min:0,max:1},angle:{min:0,max:360},distance:{min:0,max:500},choke:{min:0,max:100},size:{min:0,max:250},blendMode:{}}},outerGlow:{props:{enabled:{},color:{},opacity:{min:0,max:1},size:{min:0,max:250},spread:{min:0,max:100},blendMode:{}}},innerGlow:{props:{enabled:{},color:{},opacity:{min:0,max:1},size:{min:0,max:250},spread:{min:0,max:100},blendMode:{}}},stroke:{props:{enabled:{},size:{min:0,max:100},position:{enum:["inside","center","outside"]},color:{},opacity:{min:0,max:1},blendMode:{}}},bevelEmboss:{props:{enabled:{},style:{enum:["InnerBevel","OuterBevel","Emboss","PillowEmboss"]},technique:{enum:["Smooth","ChiselHard","ChiselSoft"]},depth:{min:1,max:1e3},direction:{enum:["Up","Down"]},size:{min:0,max:250},soften:{min:0,max:50},angle:{min:0,max:360},altitude:{min:0,max:90},highlightColor:{},highlightOpacity:{min:0,max:1},shadowColor:{},shadowOpacity:{min:0,max:1}}},colorOverlay:{props:{enabled:{},color:{},opacity:{min:0,max:1},blendMode:{}}},dropShadowAngleHandleId:{},dropShadowDistanceHandleId:{},dropShadowSpreadHandleId:{},dropShadowSizeHandleId:{},dropShadowOpacityHandleId:{},innerShadowAngleHandleId:{},innerShadowDistanceHandleId:{},innerShadowChokeHandleId:{},innerShadowSizeHandleId:{},innerShadowOpacityHandleId:{},outerGlowSizeHandleId:{},outerGlowSpreadHandleId:{},outerGlowOpacityHandleId:{},innerGlowSizeHandleId:{},innerGlowSpreadHandleId:{},innerGlowOpacityHandleId:{},strokeSizeHandleId:{},strokeOpacityHandleId:{},bevelEmbossDepthHandleId:{},bevelEmbossSizeHandleId:{},bevelEmbossSoftenHandleId:{},bevelEmbossAngleHandleId:{},bevelEmbossAltitudeHandleId:{},bevelEmbossHighlightOpacityHandleId:{},bevelEmbossShadowOpacityHandleId:{},colorOverlayOpacityHandleId:{}},Liquify:{operations:{}},MaskMath:{operation:{enum:["Union","Intersect","Subtract","Difference","Invert","Dilate","Erode","Choke","Feather"]},radius:{min:0,max:200},threshold:{min:0,max:1},clampMin:{min:0,max:1},clampMax:{min:0,max:1},channelA:{enum:["Alpha","Luminance","Red","Green","Blue"]},channelB:{enum:["Alpha","Luminance","Red","Green","Blue"]},binarize:{},invertResult:{},outputFormat:{enum:["WhiteWithAlpha","GrayscaleRGB","AlphaOnly","PassthroughRGB"]}},MeshWarp:{cols:{min:2,max:12},rows:{min:2,max:12},points:{}},NoiseGenerator:{noiseType:{enum:["Perlin","Simplex","Voronoi"]},outputType:{enum:["Image","Video"]},width:{min:16,max:4096},height:{min:16,max:4096},scale:{min:.1,max:100},octaves:{min:1,max:8},persistence:{min:0,max:1},lacunarity:{min:1,max:4},speed:{min:0,max:10},colorStart:{},colorEnd:{},durationMs:{min:1,max:6e4},fps:{min:1,max:120}},Paint:{width:{min:1,max:16384},height:{min:1,max:16384},maintainAspect:{},aspectRatio:{},backgroundColor:{},strokes:{}},PatchHeal:{patches:{},centerX:{min:0,max:1},centerY:{min:0,max:1},offsetX:{min:-4096,max:4096},offsetY:{min:-4096,max:4096},radius:{min:1,max:500},sourceRadius:{min:1,max:500},feather:{min:0,max:100},opacity:{min:0,max:1},mode:{enum:["Clone","SeamlessHeal","TextureTransfer"]}},ProceduralVFX:{effectType:{enum:["Smoke","Fire","Rain","Sparks","Snow","Dust","Lightning","Magic","LensFlare","Embers","EnergyBeam"]},outputType:{enum:["Image","Video"]},width:{min:16,max:4096},height:{min:16,max:4096},density:{min:0,max:1},scale:{min:.001,max:10},speed:{min:0,max:10},intensity:{min:0,max:1},seed:{min:0,max:1e6},colorStart:{},colorEnd:{},durationMs:{min:100,max:1e5},fps:{min:1,max:120}},RefineEdge:{decontaminateAmount:{min:0,max:1},radius:{min:.5,max:50},smooth:{min:0,max:100},feather:{min:0,max:50},shiftEdge:{min:-100,max:100},matteChannel:{enum:["Alpha","Luminance","Red","Green","Blue"]},outputMode:{enum:["Composite","MatteOnly","DecontaminatedRGB"]}},RefractionCaustics3D:{ior:{min:1,max:2.5},dispersion:{min:0,max:.2},refractionScale:{min:0,max:2},causticBrightness:{min:0,max:2},causticScale:{min:.1,max:5},fluidRipples:{min:0,max:1},rippleSpeed:{min:0,max:5},roughness:{min:0,max:1},specularIntensity:{min:0,max:2},lightPosX:{min:0,max:1},lightPosY:{min:0,max:1},tintColor:{},tintStrength:{min:0,max:1},depthInvert:{},depthScale:{min:.1,max:5}},ResizerScaler:{aspectRatioPreset:{enum:["9:16","16:9","1:1","4:5","21:9","custom"]},resolutionPreset:{enum:["4k","1080p","720p","480p","custom"]},targetWidth:{min:1,max:8192},targetHeight:{min:1,max:8192},fitMode:{enum:["cover","contain","stretch","manual"]},zoom:{min:1,max:1e3},offsetX:{min:-8192,max:8192},offsetY:{min:-8192,max:8192},backgroundMode:{enum:["solid","blurred","gradient","transparent"]},backgroundColor:{},backgroundColor2:{},blurRadius:{min:0,max:100},backgroundBrightness:{min:0,max:1},anchorX:{enum:["left","center","right"]},anchorY:{enum:["top","center","bottom"]}},Rotate:{angle:{},fit:{enum:["cover","contain","fill"]},scale:{min:.01,max:20}},StereoPanning:{pan:{min:-1,max:1}},Vignette:{strength:{min:0,max:100},radius:{min:.1,max:2},softness:{min:0,max:1},roundness:{min:0,max:1},centerX:{min:0,max:1},centerY:{min:0,max:1}}};var Ae={threshold:-24,ratio:4,attack:.003,release:.25,knee:6,makeupGain:0},b=class extends t{op="AudioCompressor";constructor(e={}){super(o("AudioCompressor",Ae,e,a.AudioCompressor))}},ke={delayTime:.25,feedback:.4,wet:.3,dry:1,pingPong:!1},f=class extends t{op="AudioDelay";constructor(e={}){super(o("AudioDelay",ke,e,a.AudioDelay))}},De={fadeInDuration:0,fadeOutDuration:0,fadeInCurve:"linear",fadeOutCurve:"linear"},h=class extends t{op="AudioFade";constructor(e={}){super(o("AudioFade",De,e,a.AudioFade))}},Be={threshold:-40,attack:.005,hold:.05,release:.1,range:-80},P=class extends t{op="AudioNoiseGate";constructor(e={}){super(o("AudioNoiseGate",Be,e,a.AudioNoiseGate))}},Ie={type:"peak",frequency:1e3,gain:0,q:1},y=class extends t{op="AudioParametricEq";constructor(e={}){super(o("AudioParametricEq",Ie,e,a.AudioParametricEq))}},Te={roomSize:.5,damping:.5,wet:.3,dry:1,width:1},g=class extends t{op="AudioReverb";constructor(e={}){super(o("AudioReverb",Te,e,a.AudioReverb))}},He={blurType:"Gaussian",strength:5,angle:0,sigmaColor:.1,centerX:.5,centerY:.5,partialBlur:!1,radius:.3,radiusY:0,shape:"circle"},N=class extends t{op="Blur";constructor(e={}){super(o("Blur",He,e,a.Blur))}},Le={motionPreset:"DollyZoom",panX:0,panY:0,dollyZ:0,fov:50,parallaxAmount:.6,dofAperture:.3,focusPlane:.4,edgeDilation:.5,depthInvert:!1},x=class extends t{op="CameraParallax3D";constructor(e={}){super(o("CameraParallax3D",Le,e,a.CameraParallax3D))}},Ge={colorSpace:"RGBA",defaultChannel4:1},S=class extends t{op="ChannelMerger";constructor(e={}){super(o("ChannelMerger",Ge,e,a.ChannelMerger))}},Oe={colorSpace:"RGBA"},C=class extends t{op="ChannelSplitter";constructor(e={}){super(o("ChannelSplitter",Oe,e,a.ChannelSplitter))}},ze={shadows:{cyanRed:0,magentaGreen:0,yellowBlue:0},midtones:{cyanRed:0,magentaGreen:0,yellowBlue:0},highlights:{cyanRed:0,magentaGreen:0,yellowBlue:0},preserveLuminosity:!0},E=class extends t{op="ColorBalance";constructor(e={}){super(o("ColorBalance",ze,e,a.ColorBalance))}},Fe={keyColor:"#00ff00",similarity:.4,smoothness:.1,spillSuppression:.2,colorSpace:"YUV",spillSuppressionType:"Desaturate"},w=class extends t{op="ColorKey";constructor(e={}){super(o("ColorKey",Fe,e,a.ColorKey))}},Ve={},v=class extends t{op="CornerPin";constructor(e={}){super(o("CornerPin",Ve,e,a.CornerPin))}},Ye={strengthX:50,strengthY:50,xChannel:"Red",yChannel:"Green",wrapMode:"Clamp"},M=class extends t{op="DisplacementMap";constructor(e={}){super(o("DisplacementMap",Ye,e,a.DisplacementMap))}},Xe={strategy:"deterministic",samplePoints:150},R=class extends t{op="ExtractLUT";constructor(e={}){super(o("ExtractLUT",Xe,e,a.ExtractLUT))}},qe={horizontal:!0,vertical:!1,diagonal:!1,mode:"horizontal",symmetry:"none"},A=class extends t{op="Flip";constructor(e={}){super(o("Flip",qe,e,a.Flip))}},We={keyframes:[],motionBlurSize:1.5,movementStyle:"spline",aspectRatio:"input"},k=class extends t{op="KenBurns";constructor(e={}){super(o("KenBurns",We,e,a.KenBurns))}},Ne={dropShadow:{enabled:!1,color:"#000000",opacity:.75,angle:120,distance:10,spread:0,size:10,blendMode:"multiply"},innerShadow:{enabled:!1,color:"#000000",opacity:.75,angle:120,distance:5,choke:0,size:5,blendMode:"multiply"},outerGlow:{enabled:!1,color:"#ffffff",opacity:.75,size:15,spread:0,blendMode:"screen"},innerGlow:{enabled:!1,color:"#ffffff",opacity:.75,size:15,spread:0,blendMode:"screen"},stroke:{enabled:!1,size:2,position:"outside",color:"#ffffff",opacity:1,blendMode:"normal"},bevelEmboss:{enabled:!1,style:"InnerBevel",technique:"Smooth",depth:100,direction:"Up",size:5,soften:0,angle:120,altitude:30,highlightColor:"#ffffff",highlightOpacity:.75,shadowColor:"#000000",shadowOpacity:.75},colorOverlay:{enabled:!1,color:"#ff0000",opacity:1,blendMode:"normal"}},D=class extends t{op="LayerStyle";constructor(e={}){super(o("LayerStyle",Ne,e,a.LayerStyle))}},je={operations:[]},B=class extends t{op="Liquify";constructor(e={}){super(o("Liquify",je,e,a.Liquify))}},Ke={operation:"Union",radius:0,threshold:.5,clampMin:0,clampMax:1,channelA:"Alpha",channelB:"Alpha",binarize:!1,invertResult:!1,outputFormat:"WhiteWithAlpha"},I=class extends t{op="MaskMath";constructor(e={}){super(o("MaskMath",Ke,e,a.MaskMath))}},Ue={cols:3,rows:3},T=class extends t{op="MeshWarp";constructor(e={}){super(o("MeshWarp",Ue,e,a.MeshWarp))}},$e={noiseType:"Perlin",outputType:"Image",width:512,height:512,scale:10,octaves:4,persistence:.5,lacunarity:2,speed:1,colorStart:"#000000",colorEnd:"#ffffff",durationMs:5e3,fps:30},H=class extends t{op="NoiseGenerator";constructor(e={}){super(o("NoiseGenerator",$e,e,a.NoiseGenerator))}},Ze={width:1080,height:1080,maintainAspect:!0,backgroundColor:"#ffffff"},L=class extends t{op="Paint";constructor(e={}){super(o("Paint",Ze,e,a.Paint))}},_e={centerX:.5,centerY:.5,offsetX:50,offsetY:0,radius:25,sourceRadius:25,feather:50,opacity:1,mode:"SeamlessHeal"},G=class extends t{op="PatchHeal";constructor(e={}){super(o("PatchHeal",_e,e,a.PatchHeal))}},Je={effectType:"Smoke",outputType:"Video",width:1080,height:1080,density:.6,scale:.01,speed:1,intensity:.8,seed:1234,colorStart:"#ffffff",colorEnd:"#ff5500",durationMs:5e3,fps:30},O=class extends t{op="ProceduralVFX";constructor(e={}){super(o("ProceduralVFX",Je,e,a.ProceduralVFX))}},Qe={decontaminateAmount:.7,radius:2,smooth:5,feather:.5,shiftEdge:0,matteChannel:"Alpha",outputMode:"Composite"},z=class extends t{op="RefineEdge";constructor(e={}){super(o("RefineEdge",Qe,e,a.RefineEdge))}},er={ior:1.52,dispersion:.04,refractionScale:.5,causticBrightness:.6,causticScale:1,fluidRipples:0,rippleSpeed:1,roughness:0,specularIntensity:.8,lightPosX:.5,lightPosY:.2,tintColor:"#ffffff",tintStrength:0,depthInvert:!1,depthScale:1},F=class extends t{op="RefractionCaustics3D";constructor(e={}){super(o("RefractionCaustics3D",er,e,a.RefractionCaustics3D))}},rr={aspectRatioPreset:"16:9",resolutionPreset:"1080p",targetWidth:1920,targetHeight:1080,fitMode:"contain",zoom:100,offsetX:0,offsetY:0,backgroundMode:"solid",backgroundColor:"#000000FF",backgroundColor2:"#000000FF",blurRadius:40,backgroundBrightness:.6,anchorX:"center",anchorY:"center"},V=class extends t{op="ResizerScaler";constructor(e={}){super(o("ResizerScaler",rr,e,a.ResizerScaler))}},tr={angle:90,fit:"cover",scale:1},Y=class extends t{op="Rotate";constructor(e={}){super(o("Rotate",tr,e,a.Rotate))}},nr={pan:0},X=class extends t{op="StereoPanning";constructor(e={}){super(o("StereoPanning",nr,e,a.StereoPanning))}},ar={strength:50,radius:1,softness:.5,roundness:.5,centerX:.5,centerY:.5},q=class extends t{op="Vignette";constructor(e={}){super(o("Vignette",ar,e,a.Vignette))}};function or(r){return{partialBlur:!0,centerX:r.center.x,centerY:r.center.y,radius:r.bounds.width.multiply(.55),radiusY:r.bounds.height.multiply(.55),shape:"ellipse",strength:r.active.multiply(25)}}var W=class extends N{constructor(e={}){let{track:n,...l}=e;super(n?{...or(n),...lr(l)}:l)}};function lr(r){return Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0))}c();var ir={audioCompressor:r=>new b(r),audioDelay:r=>new f(r),audioFade:r=>new h(r),audioNoiseGate:r=>new P(r),audioParametricEq:r=>new y(r),audioReverb:r=>new g(r),blur:r=>new W(r),cameraParallax3D:r=>new x(r),channelMerger:r=>new S(r),channelSplitter:r=>new C(r),colorBalance:r=>new E(r),colorKey:r=>new w(r),cornerPin:r=>new v(r),displacementMap:r=>new M(r),extractLUT:r=>new R(r),flip:r=>new A(r),kenBurns:r=>new k(r),layerStyle:r=>new D(r),liquify:r=>new B(r),maskMath:r=>new I(r),meshWarp:r=>new T(r),noiseGenerator:r=>new H(r),paint:r=>new L(r),patchHeal:r=>new G(r),proceduralVFX:r=>new O(r),refineEdge:r=>new z(r),refractionCaustics3D:r=>new F(r),resizerScaler:r=>new V(r),rotate:r=>new Y(r),stereoPanning:r=>new X(r),vignette:r=>new q(r)};var ee=class extends t{op="Levels";constructor(e={}){let n={inBlack:0,inWhite:1,outBlack:0,outWhite:1};super({master:e.master??{...n},red:e.red??{...n},green:e.green??{...n},blue:e.blue??{...n},...e})}},re=class extends t{op="FilmGrain";constructor(e={}){super({strength:e.strength??15,size:e.size??1.5,monochrome:e.monochrome??!0,animated:e.animated??!0,speed:e.speed??50,shadows:e.shadows??.2,midtones:e.midtones??1,highlights:e.highlights??.2,...e})}},te=class extends t{op;constructor(e,n={}){super(n),this.op=e}},ne=class extends t{op="AudioSignalExtractor";constructor(e={}){super({extractionMode:e.extractionMode??"rms_envelope",attackMs:e.attackMs??10,releaseMs:e.releaseMs??120,sensitivity:e.sensitivity??1,noiseFloorDb:e.noiseFloorDb??-48,dynamicRangeDb:e.dynamicRangeDb??48,autoRange:e.autoRange??!0,smoothing:e.smoothing??.15,curve:e.curve??"linear",beatThreshold:e.beatThreshold??.08,beatDecayMs:e.beatDecayMs??80,previewMode:e.previewMode??"envelope",nodeId:e.nodeId??"audio_extractor",...e})}async extract(e,n={}){return $.extract(e,{extractionMode:this.extractionMode,attackMs:this.attackMs,releaseMs:this.releaseMs,sensitivity:this.sensitivity,noiseFloorDb:this.noiseFloorDb,dynamicRangeDb:this.dynamicRangeDb,smoothing:this.smoothing,curve:this.curve,beatThreshold:this.beatThreshold,beatDecayMs:this.beatDecayMs,previewMode:this.previewMode,...n})}},ae=class extends t{op="Curves";constructor(e={}){super({...e,curveType:e.curveType??"rgb",master:e.master??[{x:0,y:0},{x:1,y:1}],red:e.red??[{x:0,y:0},{x:1,y:1}],green:e.green??[{x:0,y:0},{x:1,y:1}],blue:e.blue??[{x:0,y:0},{x:1,y:1}],hueVsHue:e.hueVsHue??[{x:0,y:.5},{x:1,y:.5}],hueVsSat:e.hueVsSat??[{x:0,y:1},{x:1,y:1}],lumVsSat:e.lumVsSat??[{x:0,y:1},{x:1,y:1}],satVsSat:e.satVsSat??[{x:0,y:1},{x:1,y:1}]})}},oe=class extends t{op="SelectiveColor";constructor(e={}){let n={cyan:0,magenta:0,yellow:0,black:0};super({...e,method:e.method??"Relative",reds:{...n,...e.reds},yellows:{...n,...e.yellows},greens:{...n,...e.greens},cyans:{...n,...e.cyans},blues:{...n,...e.blues},magentas:{...n,...e.magentas},whites:{...n,...e.whites},neutrals:{...n,...e.neutrals},blacks:{...n,...e.blacks}})}},le=class extends t{op="GradientMap";constructor(e={}){let n=[{position:0,color:"#000000"},{position:1,color:"#ffffff"}];super({...e,stops:e.stops??n,smooth:e.smooth??!0,dither:e.dither??!0,opacity:e.opacity??1})}},ie=class extends t{op="ShadowsHighlights";constructor(e={}){super({...e,shadowAmount:e.shadowAmount??0,shadowTonalWidth:e.shadowTonalWidth??50,shadowRadius:e.shadowRadius??30,highlightAmount:e.highlightAmount??0,highlightTonalWidth:e.highlightTonalWidth??50,highlightRadius:e.highlightRadius??30,colorCorrection:e.colorCorrection??0,midtoneContrast:e.midtoneContrast??0})}},se=class extends t{op="ApplyLUT";constructor(e={}){super({...e,lutUrl:e.lutUrl??"",intensity:e.intensity??1})}},ue=class extends t{op="UnsharpMask";constructor(e={}){super({...e,amount:e.amount??100,radius:e.radius??1.5,threshold:e.threshold??3})}},ce=class extends t{op="HighPass";constructor(e={}){super({...e,radius:e.radius??3,contrastBoost:e.contrastBoost??1,monochrome:e.monochrome??!0})}},pe=class extends t{op="HalftoneScreen";constructor(e={}){super({...e,mode:e.mode??"Monochrome",dotShape:e.dotShape??"Circle",frequency:e.frequency??30,angle:e.angle??45,contrast:e.contrast??1,dotColor:e.dotColor??"#000000",paperColor:e.paperColor??"#ffffff",smooth:e.smooth??!0,invert:e.invert??!1,cyanAngle:e.cyanAngle??15,magentaAngle:e.magentaAngle??75,yellowAngle:e.yellowAngle??0,blackAngle:e.blackAngle??45,opacity:e.opacity??1})}},de=class extends t{op="TileOffset";constructor(e={}){super({...e,offsetX:e.offsetX??0,offsetY:e.offsetY??0,wrap:e.wrap??!0,edgeMode:e.edgeMode??"wrap"})}},me=class extends t{op="MotionBlur";constructor(e={}){super({...e,shutterAngle:e.shutterAngle??180,samples:e.samples??16,maxVelocity:e.maxVelocity??64,shutterCurve:e.shutterCurve??"gaussian",depthAware:e.depthAware??!0})}},be=class extends t{op="SSAO";constructor(e={}){super({...e,radius:e.radius??45,bias:e.bias??.025,intensity:e.intensity??1.5,kernelSamples:e.kernelSamples??16,blurRadius:e.blurRadius??4})}},fe=class extends t{op="PBRGlass";constructor(e={}){super({...e,ior:e.ior??1.49,roughness:e.roughness??.15,transmission:e.transmission??.92,dispersion:e.dispersion??.015,fresnelPower:e.fresnelPower??5,tintColor:e.tintColor??"#ffffff"})}},he=class extends t{op="DepthOfField";constructor(e={}){super({...e,focusDistance:e.focusDistance??500,focalLength:e.focalLength??50,aperture:e.aperture??2.8,maxBlur:e.maxBlur??16,quality:e.quality??"high"})}},Pe=class extends t{op="Crop";constructor(e={}){super({cropType:e.cropType??"rect",leftPercentage:e.leftPercentage??0,topPercentage:e.topPercentage??0,widthPercentage:e.widthPercentage??100,heightPercentage:e.heightPercentage??100,roundness:e.roundness??0,...e})}},ye=class extends t{op="Vision";constructor(e={}){super({enableDetection:e.enableDetection!==!1,enableSegmentation:e.enableSegmentation===!0,enablePose:e.enablePose===!0,enableMatte:e.enableMatte===!0,confidence:e.confidence??.3,variant:e.variant??"s",mode:e.mode??"passthrough",matteSource:e.matteSource??"instance",...e})}},ge=class extends t{op="Relight3D";constructor(e={}){super({lightType:e.lightType??"Point",intensity:e.intensity??1,lightPosX:e.lightPosX??.5,lightPosY:e.lightPosY??.5,lightPosZ:e.lightPosZ??.3,lightRadius:e.lightRadius??.8,spotConeAngle:e.spotConeAngle??45,specularRoughness:e.specularRoughness??.35,specularStrength:e.specularStrength??.7,metallic:e.metallic??0,ambientIntensity:e.ambientIntensity??.4,volumetricDensity:e.volumetricDensity??.2,depthScale:e.depthScale??1,depthInvert:e.depthInvert??!1,lightColor:e.lightColor??"#ffffff",ambientColor:e.ambientColor??"#ffffff",normalMap:e.normalMap,...e})}},xe=class extends t{op="TemporalDeflicker";constructor(e={}){super({blendWeight:e.blendWeight??.35,disocclusionThreshold:e.disocclusionThreshold??.15,maxMotionPixels:e.maxMotionPixels??64,scale:e.scale??.5,windowSize:e.windowSize??2,...e})}},Se=class extends t{op="Modulate";constructor(e={}){super({hue:e.hue??0,brightness:e.brightness??1,contrast:e.contrast??1,exposure:e.exposure??0,saturation:e.saturation??1,sepia:e.sepia??0,...e})}};export{a,b,f as c,h as d,P as e,y as f,g,x as h,S as i,C as j,E as k,w as l,v as m,M as n,R as o,A as p,k as q,D as r,B as s,I as t,T as u,H as v,L as w,G as x,O as y,z,F as A,V as B,Y as C,X as D,q as E,W as F,ir as G,ee as H,re as I,te as J,ne as K,ae as L,oe as M,le as N,ie as O,se as P,ue as Q,ce as R,pe as S,de as T,me as U,be as V,fe as W,he as X,Pe as Y,ye as Z,ge as _,xe as $,Se as aa};
1
+ import{a as t}from"./chunk-K7M5EIFC.mjs";import{a as $}from"./chunk-FJH5A2PV.mjs";import{h as j}from"./chunk-63SFBHEH.mjs";import{d,e as c}from"./chunk-BVF64D6H.mjs";c();c();c();c();c();c();function _(r){return typeof d<"u"?d.env?.[r]:void 0}function J(){let r=_("FRAMEFIELDS_STRICT_PROPS");return r==="1"||r==="true"}function Ee(){return J()||_("NODE_ENV")!=="production"}var Z=new Set;function K(r){if(J())throw new Error(r);Z.has(r)||(Z.add(r),console.warn(`[framefields] ${r}`))}function U(r){if(typeof r!="object"||r===null||Array.isArray(r)||j(r))return!1;let e=Object.getPrototypeOf(r);return e===Object.prototype||e===null}function we(r,e){let n=Array.from({length:e.length+1},(l,i)=>i);for(let l=1;l<=r.length;l++){let i=n[0];n[0]=l;for(let s=1;s<=e.length;s++){let u=n[s];n[s]=Math.min(n[s]+1,n[s-1]+1,i+(r[l-1]===e[s-1]?0:1)),i=u}}return n[e.length]}function ve(r,e){let n,l=Number.POSITIVE_INFINITY,i=r.toLowerCase();for(let u of e){let p=u.toLowerCase(),m=p.includes(i)||i.includes(p)?1:we(i,p);m<l&&(l=m,n=u)}return n&&l<=Math.max(2,Math.ceil(r.length/2))?` Did you mean "${n}"?`:` Known props: ${e.join(", ")}.`}function Me(r,e,n){if(typeof e=="number"){let{min:l,max:i}=n,s=l!==void 0&&e<l,u=i!==void 0&&e>i;if(s||u||Number.isNaN(e)){let p=l!==void 0&&i!==void 0?`${l} to ${i}`:l!==void 0?`\u2265 ${l}`:`\u2264 ${i}`;K(Number.isNaN(e)?`${r} is NaN`:`${r} = ${e} is outside ${p}`)}return}n.enum&&(typeof e=="string"||typeof e=="boolean")&&!n.enum.includes(e)&&K(`${r} = ${JSON.stringify(e)} is not one of ${n.enum.map(l=>JSON.stringify(l)).join(", ")}`)}function Q(r,e,n){let l=Object.keys(n);for(let[i,s]of Object.entries(e)){if(s===void 0)continue;let u=n[i];if(!u){K(`${r}: unknown prop "${i}".${ve(i,l)}`);continue}j(s)||typeof s=="function"||(u.props&&U(s)?Q(`${r}.${i}`,s,u.props):Me(`${r}.${i}`,s,u))}}function Re(r){return typeof r=="object"&&r!==null?structuredClone(r):r}function o(r,e,n,l){let i=n;Ee()&&Q(r,i,l);let s={};for(let[u,p]of Object.entries(e))s[u]=Re(p);for(let[u,p]of Object.entries(i)){if(p===void 0)continue;let m=s[u];s[u]=U(m)&&U(p)?{...m,...Object.fromEntries(Object.entries(p).filter(([,Ce])=>Ce!==void 0))}:p}return s}c();var a={AudioCompressor:{threshold:{min:-60,max:0},ratio:{min:1,max:100},attack:{min:1e-4,max:1},release:{min:.01,max:5},knee:{min:0,max:24},makeupGain:{min:0,max:24}},AudioDelay:{delayTime:{min:.001,max:5},feedback:{min:0,max:.95},wet:{min:0,max:1},dry:{min:0,max:1},pingPong:{}},AudioFade:{fadeInDuration:{min:0,max:60},fadeOutDuration:{min:0,max:60},fadeInCurve:{enum:["linear","exponential","scurve"]},fadeOutCurve:{enum:["linear","exponential","scurve"]}},AudioNoiseGate:{threshold:{min:-120,max:0},attack:{min:1e-4,max:1},hold:{min:.001,max:5},release:{min:.01,max:5},range:{min:-120,max:0}},AudioParametricEq:{type:{enum:["lowShelf","highShelf","peak","lowPass","highPass","notch"]},frequency:{min:20,max:2e4},gain:{min:-24,max:24},q:{min:.01,max:10}},AudioReverb:{roomSize:{min:0,max:.98},damping:{min:0,max:1},wet:{min:0,max:1},dry:{min:0,max:1},width:{min:0,max:1}},Blur:{blurType:{enum:["Gaussian","Box","Median","Motion","Bilateral","Edge-preserving","Radial","Zoom"]},strength:{min:0,max:100},angle:{min:0,max:360},sigmaColor:{min:.01,max:1},centerX:{min:0,max:1},centerY:{min:0,max:1},partialBlur:{},radius:{min:.01,max:1},radiusY:{min:0,max:1},shape:{enum:["ellipse","circle","rect"]}},CameraParallax3D:{motionPreset:{enum:["Custom","DollyZoom","Orbit","FlyThrough","HandheldShake","RackFocus"]},panX:{min:-1,max:1},panY:{min:-1,max:1},dollyZ:{min:-1,max:1},fov:{min:15,max:120},parallaxAmount:{min:0,max:2},dofAperture:{min:0,max:1},focusPlane:{min:0,max:1},edgeDilation:{min:0,max:1},depthInvert:{}},ChannelMerger:{colorSpace:{enum:["RGBA","HSLA","CMYK","LAB"]},defaultChannel4:{min:0,max:1}},ChannelSplitter:{colorSpace:{enum:["RGBA","HSLA","CMYK","LAB"]}},ColorBalance:{shadows:{props:{cyanRed:{min:-100,max:100},magentaGreen:{min:-100,max:100},yellowBlue:{min:-100,max:100}}},midtones:{props:{cyanRed:{min:-100,max:100},magentaGreen:{min:-100,max:100},yellowBlue:{min:-100,max:100}}},highlights:{props:{cyanRed:{min:-100,max:100},magentaGreen:{min:-100,max:100},yellowBlue:{min:-100,max:100}}},preserveLuminosity:{}},ColorKey:{keyColor:{},similarity:{min:0,max:1},smoothness:{min:0,max:1},spillSuppression:{min:0,max:1},colorSpace:{enum:["YUV","RGB"]},spillSuppressionType:{enum:["Desaturate","Neutralize","None"]}},CornerPin:{points:{}},DisplacementMap:{strengthX:{min:0,max:500},strengthY:{min:0,max:500},xChannel:{enum:["Red","Green","Blue","Alpha","Luminance"]},yChannel:{enum:["Red","Green","Blue","Alpha","Luminance"]},wrapMode:{enum:["Clamp","Repeat","Mirror"]}},ExtractLUT:{strategy:{enum:["deterministic","statistical"]},samplePoints:{min:10,max:500}},Flip:{horizontal:{},vertical:{},diagonal:{},mode:{enum:["horizontal","vertical","both","diagonal","antiDiagonal","custom"]},symmetry:{enum:["none","leftToRight","rightToLeft","topToBottom","bottomToTop","quadrant"]}},KenBurns:{keyframes:{},motionBlurSize:{min:0,max:10},movementStyle:{enum:["spline","direct"]},aspectRatio:{enum:["input","16:9","9:16","21:9","9:21","1:1","4:3","3:2","2:3","4:5","5:4"]}},LayerStyle:{dropShadow:{props:{enabled:{},color:{},opacity:{min:0,max:1},angle:{min:0,max:360},distance:{min:0,max:500},spread:{min:0,max:100},size:{min:0,max:250},blendMode:{}}},innerShadow:{props:{enabled:{},color:{},opacity:{min:0,max:1},angle:{min:0,max:360},distance:{min:0,max:500},choke:{min:0,max:100},size:{min:0,max:250},blendMode:{}}},outerGlow:{props:{enabled:{},color:{},opacity:{min:0,max:1},size:{min:0,max:250},spread:{min:0,max:100},blendMode:{}}},innerGlow:{props:{enabled:{},color:{},opacity:{min:0,max:1},size:{min:0,max:250},spread:{min:0,max:100},blendMode:{}}},stroke:{props:{enabled:{},size:{min:0,max:100},position:{enum:["inside","center","outside"]},color:{},opacity:{min:0,max:1},blendMode:{}}},bevelEmboss:{props:{enabled:{},style:{enum:["InnerBevel","OuterBevel","Emboss","PillowEmboss"]},technique:{enum:["Smooth","ChiselHard","ChiselSoft"]},depth:{min:1,max:1e3},direction:{enum:["Up","Down"]},size:{min:0,max:250},soften:{min:0,max:50},angle:{min:0,max:360},altitude:{min:0,max:90},highlightColor:{},highlightOpacity:{min:0,max:1},shadowColor:{},shadowOpacity:{min:0,max:1}}},colorOverlay:{props:{enabled:{},color:{},opacity:{min:0,max:1},blendMode:{}}},dropShadowAngleHandleId:{},dropShadowDistanceHandleId:{},dropShadowSpreadHandleId:{},dropShadowSizeHandleId:{},dropShadowOpacityHandleId:{},innerShadowAngleHandleId:{},innerShadowDistanceHandleId:{},innerShadowChokeHandleId:{},innerShadowSizeHandleId:{},innerShadowOpacityHandleId:{},outerGlowSizeHandleId:{},outerGlowSpreadHandleId:{},outerGlowOpacityHandleId:{},innerGlowSizeHandleId:{},innerGlowSpreadHandleId:{},innerGlowOpacityHandleId:{},strokeSizeHandleId:{},strokeOpacityHandleId:{},bevelEmbossDepthHandleId:{},bevelEmbossSizeHandleId:{},bevelEmbossSoftenHandleId:{},bevelEmbossAngleHandleId:{},bevelEmbossAltitudeHandleId:{},bevelEmbossHighlightOpacityHandleId:{},bevelEmbossShadowOpacityHandleId:{},colorOverlayOpacityHandleId:{}},Liquify:{operations:{}},MaskMath:{operation:{enum:["Union","Intersect","Subtract","Difference","Invert","Dilate","Erode","Choke","Feather"]},radius:{min:0,max:200},threshold:{min:0,max:1},clampMin:{min:0,max:1},clampMax:{min:0,max:1},channelA:{enum:["Alpha","Luminance","Red","Green","Blue"]},channelB:{enum:["Alpha","Luminance","Red","Green","Blue"]},binarize:{},invertResult:{},outputFormat:{enum:["WhiteWithAlpha","GrayscaleRGB","AlphaOnly","PassthroughRGB"]}},MeshWarp:{cols:{min:2,max:12},rows:{min:2,max:12},points:{}},NoiseGenerator:{noiseType:{enum:["Perlin","Simplex","Voronoi"]},outputType:{enum:["Image","Video"]},width:{min:16,max:4096},height:{min:16,max:4096},scale:{min:.1,max:100},octaves:{min:1,max:8},persistence:{min:0,max:1},lacunarity:{min:1,max:4},speed:{min:0,max:10},colorStart:{},colorEnd:{},durationMs:{min:1,max:6e4},fps:{min:1,max:120}},Paint:{width:{min:1,max:16384},height:{min:1,max:16384},maintainAspect:{},aspectRatio:{},backgroundColor:{},strokes:{}},PatchHeal:{patches:{},centerX:{min:0,max:1},centerY:{min:0,max:1},offsetX:{min:-4096,max:4096},offsetY:{min:-4096,max:4096},radius:{min:1,max:500},sourceRadius:{min:1,max:500},feather:{min:0,max:100},opacity:{min:0,max:1},mode:{enum:["Clone","SeamlessHeal","TextureTransfer"]}},ProceduralVFX:{effectType:{enum:["Smoke","Fire","Rain","Sparks","Snow","Dust","Lightning","Magic","LensFlare","Embers","EnergyBeam"]},outputType:{enum:["Image","Video"]},width:{min:16,max:4096},height:{min:16,max:4096},density:{min:0,max:1},scale:{min:.001,max:10},speed:{min:0,max:10},intensity:{min:0,max:1},seed:{min:0,max:1e6},colorStart:{},colorEnd:{},durationMs:{min:100,max:1e5},fps:{min:1,max:120}},RefineEdge:{decontaminateAmount:{min:0,max:1},radius:{min:.5,max:50},smooth:{min:0,max:100},feather:{min:0,max:50},shiftEdge:{min:-100,max:100},matteChannel:{enum:["Alpha","Luminance","Red","Green","Blue"]},outputMode:{enum:["Composite","MatteOnly","DecontaminatedRGB"]}},RefractionCaustics3D:{ior:{min:1,max:2.5},dispersion:{min:0,max:.2},refractionScale:{min:0,max:2},causticBrightness:{min:0,max:2},causticScale:{min:.1,max:5},fluidRipples:{min:0,max:1},rippleSpeed:{min:0,max:5},roughness:{min:0,max:1},specularIntensity:{min:0,max:2},lightPosX:{min:0,max:1},lightPosY:{min:0,max:1},tintColor:{},tintStrength:{min:0,max:1},depthInvert:{},depthScale:{min:.1,max:5}},ResizerScaler:{aspectRatioPreset:{enum:["9:16","16:9","1:1","4:5","21:9","custom"]},resolutionPreset:{enum:["4k","1080p","720p","480p","custom"]},targetWidth:{min:1,max:8192},targetHeight:{min:1,max:8192},fitMode:{enum:["cover","contain","stretch","manual"]},zoom:{min:1,max:1e3},offsetX:{min:-8192,max:8192},offsetY:{min:-8192,max:8192},backgroundMode:{enum:["solid","blurred","gradient","transparent"]},backgroundColor:{},backgroundColor2:{},blurRadius:{min:0,max:100},backgroundBrightness:{min:0,max:1},anchorX:{enum:["left","center","right"]},anchorY:{enum:["top","center","bottom"]}},Rotate:{angle:{},fit:{enum:["cover","contain","fill"]},scale:{min:.01,max:20}},StereoPanning:{pan:{min:-1,max:1}},Vignette:{strength:{min:0,max:100},radius:{min:.1,max:2},softness:{min:0,max:1},roundness:{min:0,max:1},centerX:{min:0,max:1},centerY:{min:0,max:1}}};var Ae={threshold:-24,ratio:4,attack:.003,release:.25,knee:6,makeupGain:0},b=class extends t{op="AudioCompressor";constructor(e={}){super(o("AudioCompressor",Ae,e,a.AudioCompressor))}},ke={delayTime:.25,feedback:.4,wet:.3,dry:1,pingPong:!1},f=class extends t{op="AudioDelay";constructor(e={}){super(o("AudioDelay",ke,e,a.AudioDelay))}},De={fadeInDuration:0,fadeOutDuration:0,fadeInCurve:"linear",fadeOutCurve:"linear"},h=class extends t{op="AudioFade";constructor(e={}){super(o("AudioFade",De,e,a.AudioFade))}},Be={threshold:-40,attack:.005,hold:.05,release:.1,range:-80},P=class extends t{op="AudioNoiseGate";constructor(e={}){super(o("AudioNoiseGate",Be,e,a.AudioNoiseGate))}},Ie={type:"peak",frequency:1e3,gain:0,q:1},y=class extends t{op="AudioParametricEq";constructor(e={}){super(o("AudioParametricEq",Ie,e,a.AudioParametricEq))}},Te={roomSize:.5,damping:.5,wet:.3,dry:1,width:1},g=class extends t{op="AudioReverb";constructor(e={}){super(o("AudioReverb",Te,e,a.AudioReverb))}},He={blurType:"Gaussian",strength:5,angle:0,sigmaColor:.1,centerX:.5,centerY:.5,partialBlur:!1,radius:.3,radiusY:0,shape:"circle"},N=class extends t{op="Blur";constructor(e={}){super(o("Blur",He,e,a.Blur))}},Le={motionPreset:"DollyZoom",panX:0,panY:0,dollyZ:0,fov:50,parallaxAmount:.6,dofAperture:.3,focusPlane:.4,edgeDilation:.5,depthInvert:!1},x=class extends t{op="CameraParallax3D";constructor(e={}){super(o("CameraParallax3D",Le,e,a.CameraParallax3D))}},Ge={colorSpace:"RGBA",defaultChannel4:1},S=class extends t{op="ChannelMerger";constructor(e={}){super(o("ChannelMerger",Ge,e,a.ChannelMerger))}},Oe={colorSpace:"RGBA"},C=class extends t{op="ChannelSplitter";constructor(e={}){super(o("ChannelSplitter",Oe,e,a.ChannelSplitter))}},ze={shadows:{cyanRed:0,magentaGreen:0,yellowBlue:0},midtones:{cyanRed:0,magentaGreen:0,yellowBlue:0},highlights:{cyanRed:0,magentaGreen:0,yellowBlue:0},preserveLuminosity:!0},E=class extends t{op="ColorBalance";constructor(e={}){super(o("ColorBalance",ze,e,a.ColorBalance))}},Fe={keyColor:"#00ff00",similarity:.4,smoothness:.1,spillSuppression:.2,colorSpace:"YUV",spillSuppressionType:"Desaturate"},w=class extends t{op="ColorKey";constructor(e={}){super(o("ColorKey",Fe,e,a.ColorKey))}},Ve={},v=class extends t{op="CornerPin";constructor(e={}){super(o("CornerPin",Ve,e,a.CornerPin))}},Ye={strengthX:50,strengthY:50,xChannel:"Red",yChannel:"Green",wrapMode:"Clamp"},M=class extends t{op="DisplacementMap";constructor(e={}){super(o("DisplacementMap",Ye,e,a.DisplacementMap))}},Xe={strategy:"deterministic",samplePoints:150},R=class extends t{op="ExtractLUT";constructor(e={}){super(o("ExtractLUT",Xe,e,a.ExtractLUT))}},qe={horizontal:!0,vertical:!1,diagonal:!1,mode:"horizontal",symmetry:"none"},A=class extends t{op="Flip";constructor(e={}){super(o("Flip",qe,e,a.Flip))}},We={keyframes:[],motionBlurSize:1.5,movementStyle:"spline",aspectRatio:"input"},k=class extends t{op="KenBurns";constructor(e={}){super(o("KenBurns",We,e,a.KenBurns))}},Ne={dropShadow:{enabled:!1,color:"#000000",opacity:.75,angle:120,distance:10,spread:0,size:10,blendMode:"multiply"},innerShadow:{enabled:!1,color:"#000000",opacity:.75,angle:120,distance:5,choke:0,size:5,blendMode:"multiply"},outerGlow:{enabled:!1,color:"#ffffff",opacity:.75,size:15,spread:0,blendMode:"screen"},innerGlow:{enabled:!1,color:"#ffffff",opacity:.75,size:15,spread:0,blendMode:"screen"},stroke:{enabled:!1,size:2,position:"outside",color:"#ffffff",opacity:1,blendMode:"normal"},bevelEmboss:{enabled:!1,style:"InnerBevel",technique:"Smooth",depth:100,direction:"Up",size:5,soften:0,angle:120,altitude:30,highlightColor:"#ffffff",highlightOpacity:.75,shadowColor:"#000000",shadowOpacity:.75},colorOverlay:{enabled:!1,color:"#ff0000",opacity:1,blendMode:"normal"}},D=class extends t{op="LayerStyle";constructor(e={}){super(o("LayerStyle",Ne,e,a.LayerStyle))}},je={operations:[]},B=class extends t{op="Liquify";constructor(e={}){super(o("Liquify",je,e,a.Liquify))}},Ke={operation:"Union",radius:0,threshold:.5,clampMin:0,clampMax:1,channelA:"Alpha",channelB:"Alpha",binarize:!1,invertResult:!1,outputFormat:"WhiteWithAlpha"},I=class extends t{op="MaskMath";constructor(e={}){super(o("MaskMath",Ke,e,a.MaskMath))}},Ue={cols:3,rows:3},T=class extends t{op="MeshWarp";constructor(e={}){super(o("MeshWarp",Ue,e,a.MeshWarp))}},$e={noiseType:"Perlin",outputType:"Image",width:512,height:512,scale:10,octaves:4,persistence:.5,lacunarity:2,speed:1,colorStart:"#000000",colorEnd:"#ffffff",durationMs:5e3,fps:30},H=class extends t{op="NoiseGenerator";constructor(e={}){super(o("NoiseGenerator",$e,e,a.NoiseGenerator))}},Ze={width:1080,height:1080,maintainAspect:!0,backgroundColor:"#ffffff"},L=class extends t{op="Paint";constructor(e={}){super(o("Paint",Ze,e,a.Paint))}},_e={centerX:.5,centerY:.5,offsetX:50,offsetY:0,radius:25,sourceRadius:25,feather:50,opacity:1,mode:"SeamlessHeal"},G=class extends t{op="PatchHeal";constructor(e={}){super(o("PatchHeal",_e,e,a.PatchHeal))}},Je={effectType:"Smoke",outputType:"Video",width:1080,height:1080,density:.6,scale:.01,speed:1,intensity:.8,seed:1234,colorStart:"#ffffff",colorEnd:"#ff5500",durationMs:5e3,fps:30},O=class extends t{op="ProceduralVFX";constructor(e={}){super(o("ProceduralVFX",Je,e,a.ProceduralVFX))}},Qe={decontaminateAmount:.7,radius:2,smooth:5,feather:.5,shiftEdge:0,matteChannel:"Alpha",outputMode:"Composite"},z=class extends t{op="RefineEdge";constructor(e={}){super(o("RefineEdge",Qe,e,a.RefineEdge))}},er={ior:1.52,dispersion:.04,refractionScale:.5,causticBrightness:.6,causticScale:1,fluidRipples:0,rippleSpeed:1,roughness:0,specularIntensity:.8,lightPosX:.5,lightPosY:.2,tintColor:"#ffffff",tintStrength:0,depthInvert:!1,depthScale:1},F=class extends t{op="RefractionCaustics3D";constructor(e={}){super(o("RefractionCaustics3D",er,e,a.RefractionCaustics3D))}},rr={aspectRatioPreset:"16:9",resolutionPreset:"1080p",targetWidth:1920,targetHeight:1080,fitMode:"contain",zoom:100,offsetX:0,offsetY:0,backgroundMode:"solid",backgroundColor:"#000000FF",backgroundColor2:"#000000FF",blurRadius:40,backgroundBrightness:.6,anchorX:"center",anchorY:"center"},V=class extends t{op="ResizerScaler";constructor(e={}){super(o("ResizerScaler",rr,e,a.ResizerScaler))}},tr={angle:90,fit:"cover",scale:1},Y=class extends t{op="Rotate";constructor(e={}){super(o("Rotate",tr,e,a.Rotate))}},nr={pan:0},X=class extends t{op="StereoPanning";constructor(e={}){super(o("StereoPanning",nr,e,a.StereoPanning))}},ar={strength:50,radius:1,softness:.5,roundness:.5,centerX:.5,centerY:.5},q=class extends t{op="Vignette";constructor(e={}){super(o("Vignette",ar,e,a.Vignette))}};function or(r){return{partialBlur:!0,centerX:r.center.x,centerY:r.center.y,radius:r.bounds.width.multiply(.55),radiusY:r.bounds.height.multiply(.55),shape:"ellipse",strength:r.active.multiply(25)}}var W=class extends N{constructor(e={}){let{track:n,...l}=e;super(n?{...or(n),...lr(l)}:l)}};function lr(r){return Object.fromEntries(Object.entries(r).filter(([,e])=>e!==void 0))}c();var ir={audioCompressor:r=>new b(r),audioDelay:r=>new f(r),audioFade:r=>new h(r),audioNoiseGate:r=>new P(r),audioParametricEq:r=>new y(r),audioReverb:r=>new g(r),blur:r=>new W(r),cameraParallax3D:r=>new x(r),channelMerger:r=>new S(r),channelSplitter:r=>new C(r),colorBalance:r=>new E(r),colorKey:r=>new w(r),cornerPin:r=>new v(r),displacementMap:r=>new M(r),extractLUT:r=>new R(r),flip:r=>new A(r),kenBurns:r=>new k(r),layerStyle:r=>new D(r),liquify:r=>new B(r),maskMath:r=>new I(r),meshWarp:r=>new T(r),noiseGenerator:r=>new H(r),paint:r=>new L(r),patchHeal:r=>new G(r),proceduralVFX:r=>new O(r),refineEdge:r=>new z(r),refractionCaustics3D:r=>new F(r),resizerScaler:r=>new V(r),rotate:r=>new Y(r),stereoPanning:r=>new X(r),vignette:r=>new q(r)};var ee=class extends t{op="Levels";constructor(e={}){let n={inBlack:0,inWhite:1,outBlack:0,outWhite:1};super({master:e.master??{...n},red:e.red??{...n},green:e.green??{...n},blue:e.blue??{...n},...e})}},re=class extends t{op="FilmGrain";constructor(e={}){super({strength:e.strength??15,size:e.size??1.5,monochrome:e.monochrome??!0,animated:e.animated??!0,speed:e.speed??50,shadows:e.shadows??.2,midtones:e.midtones??1,highlights:e.highlights??.2,...e})}},te=class extends t{op;constructor(e,n={}){super(n),this.op=e}},ne=class extends t{op="AudioSignalExtractor";constructor(e={}){super({extractionMode:e.extractionMode??"rms_envelope",attackMs:e.attackMs??10,releaseMs:e.releaseMs??120,sensitivity:e.sensitivity??1,noiseFloorDb:e.noiseFloorDb??-48,dynamicRangeDb:e.dynamicRangeDb??48,autoRange:e.autoRange??!0,smoothing:e.smoothing??.15,curve:e.curve??"linear",beatThreshold:e.beatThreshold??.08,beatDecayMs:e.beatDecayMs??80,previewMode:e.previewMode??"envelope",nodeId:e.nodeId??"audio_extractor",...e})}async extract(e,n={}){return $.extract(e,{extractionMode:this.extractionMode,attackMs:this.attackMs,releaseMs:this.releaseMs,sensitivity:this.sensitivity,noiseFloorDb:this.noiseFloorDb,dynamicRangeDb:this.dynamicRangeDb,smoothing:this.smoothing,curve:this.curve,beatThreshold:this.beatThreshold,beatDecayMs:this.beatDecayMs,previewMode:this.previewMode,...n})}},ae=class extends t{op="Curves";constructor(e={}){super({...e,curveType:e.curveType??"rgb",master:e.master??[{x:0,y:0},{x:1,y:1}],red:e.red??[{x:0,y:0},{x:1,y:1}],green:e.green??[{x:0,y:0},{x:1,y:1}],blue:e.blue??[{x:0,y:0},{x:1,y:1}],hueVsHue:e.hueVsHue??[{x:0,y:.5},{x:1,y:.5}],hueVsSat:e.hueVsSat??[{x:0,y:1},{x:1,y:1}],lumVsSat:e.lumVsSat??[{x:0,y:1},{x:1,y:1}],satVsSat:e.satVsSat??[{x:0,y:1},{x:1,y:1}]})}},oe=class extends t{op="SelectiveColor";constructor(e={}){let n={cyan:0,magenta:0,yellow:0,black:0};super({...e,method:e.method??"Relative",reds:{...n,...e.reds},yellows:{...n,...e.yellows},greens:{...n,...e.greens},cyans:{...n,...e.cyans},blues:{...n,...e.blues},magentas:{...n,...e.magentas},whites:{...n,...e.whites},neutrals:{...n,...e.neutrals},blacks:{...n,...e.blacks}})}},le=class extends t{op="GradientMap";constructor(e={}){let n=[{position:0,color:"#000000"},{position:1,color:"#ffffff"}];super({...e,stops:e.stops??n,smooth:e.smooth??!0,dither:e.dither??!0,opacity:e.opacity??1})}},ie=class extends t{op="ShadowsHighlights";constructor(e={}){super({...e,shadowAmount:e.shadowAmount??0,shadowTonalWidth:e.shadowTonalWidth??50,shadowRadius:e.shadowRadius??30,highlightAmount:e.highlightAmount??0,highlightTonalWidth:e.highlightTonalWidth??50,highlightRadius:e.highlightRadius??30,colorCorrection:e.colorCorrection??0,midtoneContrast:e.midtoneContrast??0})}},se=class extends t{op="ApplyLUT";constructor(e={}){super({...e,lutUrl:e.lutUrl??"",intensity:e.intensity??1})}},ue=class extends t{op="UnsharpMask";constructor(e={}){super({...e,amount:e.amount??100,radius:e.radius??1.5,threshold:e.threshold??3})}},ce=class extends t{op="HighPass";constructor(e={}){super({...e,radius:e.radius??3,contrastBoost:e.contrastBoost??1,monochrome:e.monochrome??!0})}},pe=class extends t{op="HalftoneScreen";constructor(e={}){super({...e,mode:e.mode??"Monochrome",dotShape:e.dotShape??"Circle",frequency:e.frequency??30,angle:e.angle??45,contrast:e.contrast??1,dotColor:e.dotColor??"#000000",paperColor:e.paperColor??"#ffffff",smooth:e.smooth??!0,invert:e.invert??!1,cyanAngle:e.cyanAngle??15,magentaAngle:e.magentaAngle??75,yellowAngle:e.yellowAngle??0,blackAngle:e.blackAngle??45,opacity:e.opacity??1})}},de=class extends t{op="TileOffset";constructor(e={}){super({...e,offsetX:e.offsetX??0,offsetY:e.offsetY??0,wrap:e.wrap??!0,edgeMode:e.edgeMode??"wrap"})}},me=class extends t{op="MotionBlur";constructor(e={}){super({...e,shutterAngle:e.shutterAngle??180,samples:e.samples??16,maxVelocity:e.maxVelocity??64,shutterCurve:e.shutterCurve??"gaussian",depthAware:e.depthAware??!0})}},be=class extends t{op="SSAO";constructor(e={}){super({...e,radius:e.radius??45,bias:e.bias??.025,intensity:e.intensity??1.5,kernelSamples:e.kernelSamples??16,blurRadius:e.blurRadius??4})}},fe=class extends t{op="PBRGlass";constructor(e={}){super({...e,ior:e.ior??1.49,roughness:e.roughness??.15,transmission:e.transmission??.92,dispersion:e.dispersion??.015,fresnelPower:e.fresnelPower??5,tintColor:e.tintColor??"#ffffff"})}},he=class extends t{op="DepthOfField";constructor(e={}){super({...e,focusDistance:e.focusDistance??500,focalLength:e.focalLength??50,aperture:e.aperture??2.8,maxBlur:e.maxBlur??16,quality:e.quality??"high"})}},Pe=class extends t{op="Crop";constructor(e={}){super({cropType:e.cropType??"rect",leftPercentage:e.leftPercentage??0,topPercentage:e.topPercentage??0,widthPercentage:e.widthPercentage??100,heightPercentage:e.heightPercentage??100,roundness:e.roundness??0,...e})}},ye=class extends t{op="Vision";constructor(e={}){super({enableDetection:e.enableDetection!==!1,enableSegmentation:e.enableSegmentation===!0,enablePose:e.enablePose===!0,enableMatte:e.enableMatte===!0,confidence:e.confidence??.3,variant:e.variant??"s",mode:e.mode??"passthrough",matteSource:e.matteSource??"instance",...e})}},ge=class extends t{op="Relight3D";constructor(e={}){super({lightType:e.lightType??"Point",intensity:e.intensity??1,lightPosX:e.lightPosX??.5,lightPosY:e.lightPosY??.5,lightPosZ:e.lightPosZ??.3,lightRadius:e.lightRadius??.8,spotConeAngle:e.spotConeAngle??45,specularRoughness:e.specularRoughness??.35,specularStrength:e.specularStrength??.7,metallic:e.metallic??0,ambientIntensity:e.ambientIntensity??.4,volumetricDensity:e.volumetricDensity??.2,depthScale:e.depthScale??1,depthInvert:e.depthInvert??!1,lightColor:e.lightColor??"#ffffff",ambientColor:e.ambientColor??"#ffffff",normalMap:e.normalMap,...e})}},xe=class extends t{op="TemporalDeflicker";constructor(e={}){super({blendWeight:e.blendWeight??.35,disocclusionThreshold:e.disocclusionThreshold??.15,maxMotionPixels:e.maxMotionPixels??64,scale:e.scale??.5,windowSize:e.windowSize??2,...e})}},Se=class extends t{op="Modulate";constructor(e={}){super({hue:e.hue??0,brightness:e.brightness??1,contrast:e.contrast??1,exposure:e.exposure??0,saturation:e.saturation??1,sepia:e.sepia??0,...e})}};export{a,b,f as c,h as d,P as e,y as f,g,x as h,S as i,C as j,E as k,w as l,v as m,M as n,R as o,A as p,k as q,D as r,B as s,I as t,T as u,H as v,L as w,G as x,O as y,z,F as A,V as B,Y as C,X as D,q as E,W as F,ir as G,ee as H,re as I,te as J,ne as K,ae as L,oe as M,le as N,ie as O,se as P,ue as Q,ce as R,pe as S,de as T,me as U,be as V,fe as W,he as X,Pe as Y,ye as Z,ge as _,xe as $,Se as aa};
@@ -0,0 +1,98 @@
1
+ import{a as je}from"./chunk-VXUJWPIK.mjs";import{a as mt}from"./chunk-XKO4RYKN.mjs";import{i as ft}from"./chunk-7OMK352W.mjs";import{I as ot,a as S,b as L}from"./chunk-NQZKBFC6.mjs";import{b as rt,h as be,i as Ee,l as te,z as st}from"./chunk-63SFBHEH.mjs";import{a as ct,e as lt,i as Ve,j as dt}from"./chunk-4GEWSUX5.mjs";import{b as ye,c as it,e as at}from"./chunk-MTJHQATU.mjs";import{d as ut,e as xe,g as Ae}from"./chunk-YAQFFQPG.mjs";import{a as Jt,c as en,d as A,e as y}from"./chunk-BVF64D6H.mjs";var At=Jt((wo,Vt)=>{y();var we=()=>new Proxy(function(){},{get:(r,e)=>e==="__esModule"?!0:e===Symbol.toPrimitive?()=>"":we(),apply:()=>we(),construct:()=>we()});Vt.exports=we()});y();y();var ht=class{signals;config;_frameHooks=[];constructor(e){this.config={...e},this.signals={};for(let[t,n]of Object.entries(e))be(n)?this.signals[t]=n:this.signals[t]=Ee(n);return new Proxy(this,{get(t,n,s){if(typeof n=="string"&&n in t.signals){let o=t.signals[n];return o?o.value:void 0}return Reflect.get(t,n,s)},set(t,n,s,o){if(typeof n=="string"&&n in t.signals){let i=t.signals[n];return be(s)?(t.signals[n]=s,t.config[n]=s):i&&typeof i.set=="function"?(i.set(s),t.config[n]=s):(t.signals[n]=Ee(s),t.config[n]=s),!0}return Reflect.set(t,n,s,o)}})}onRequestFrame(e){return this._frameHooks.push(e),this}notifyFrame(e){for(let t of this._frameHooks)t(e)}resolveUniforms(e){let t={};for(let[n,s]of Object.entries(this.signals))t[n]=s.get(e);return t}resolveTextures(){let e={};for(let[t,n]of Object.entries(this.signals)){let s=n.gpuBinding;s?.textureView&&(e[`${t}TextureView`]=s.textureView),s?.texture&&(e[`${t}Texture`]=s.texture)}return e}toOperation(){let e={op:this.op,effect:this,onRequestFrame:t=>this.notifyFrame(t),signals:this.signals,...this.config};for(let[t,n]of Object.entries(this.signals)){let s=this.config[t];!be(s)&&(typeof s=="string"||typeof s=="boolean")?e[t]=n.value:e[t]=n}return e}};y();var gt=class extends Error{constructor(e){super(e),this.name="ModerationError"}},pt=class extends Error{constructor(e){super(e),this.name="ModerationUnrefundableError"}};y();y();y();var bt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var yt=(r=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(r|=0));for(;r--;)e+=bt[t[r]&63];return e};var tr=r=>yt(r);y();var xt=L.object({dataTypes:L.custom(),label:L.string(),required:L.boolean().optional(),order:L.number(),description:L.string().optional()}),tn=L.object({configKey:L.string(),dataTypes:L.custom(),label:L.string(),description:L.string().optional()}),sr=L.object({type:L.string().min(1),version:L.number().int().positive().optional(),baseType:L.string().optional(),displayName:L.string().min(1),description:L.string().optional(),showInQuickAccess:L.boolean().optional(),showInSidebar:L.boolean().optional(),advanced:L.boolean().optional(),category:L.string().min(1),subcategory:L.string().optional(),defaultDimensions:L.object({width:L.number().positive().optional(),height:L.number().positive().optional()}).optional(),handles:L.object({inputs:L.array(xt),outputs:L.array(xt)}),variableInputs:L.discriminatedUnion("enabled",[L.object({enabled:L.literal(!0),dataTypes:L.custom()}),L.object({enabled:L.literal(!1),dataTypes:L.custom().optional()})]).optional(),variableOutputs:L.discriminatedUnion("enabled",[L.object({enabled:L.literal(!0),dataTypes:L.custom()}),L.object({enabled:L.literal(!1),dataTypes:L.custom().optional()})]).optional(),isTerminal:L.boolean().optional(),isTransient:L.boolean().optional(),configSchema:L.custom().optional(),defaultConfig:L.record(L.string(),L.unknown()).optional(),validation:L.any().optional(),resultSchema:L.custom().optional(),configHandles:L.array(tn).optional()});y();var cr={Text:{bg:"bg-blue-500",stroke:"stroke-blue-500",hex:"#3b82f6",text:"text-blue-500",border:"border-blue-500"},Image:{bg:"bg-purple-500",stroke:"stroke-purple-500",hex:"#a855f7",text:"text-purple-500",border:"border-purple-500"},Video:{bg:"bg-teal-500",stroke:"stroke-teal-500",hex:"oklch(60% 0.118 184.704)",text:"text-teal-500",border:"border-teal-500"},Audio:{bg:"bg-orange-500",stroke:"stroke-orange-500",hex:"#f97316",text:"text-orange-500",border:"border-orange-500"},Number:{bg:"bg-green-600",stroke:"stroke-green-600",hex:"#16a34a",text:"text-green-600",border:"border-green-600"},Boolean:{bg:"bg-amber-600",stroke:"stroke-amber-600",hex:"#d97706",text:"text-amber-600",border:"border-amber-600"},SVG:{bg:"bg-lime-600",stroke:"stroke-lime-600",hex:"#65a30d",text:"text-lime-600",border:"border-lime-600"},Caption:{bg:"bg-rose-500",stroke:"stroke-rose-500",hex:"#f43f5e",text:"text-rose-500",border:"border-rose-500"},GIF:{bg:"bg-pink-500",stroke:"stroke-pink-500",hex:"#ec4899",text:"text-pink-500",border:"border-pink-500"},Lottie:{bg:"bg-indigo-500",stroke:"stroke-indigo-500",hex:"#6366f1",text:"text-indigo-500",border:"border-indigo-500"},Signal:{bg:"bg-fuchsia-500",stroke:"stroke-fuchsia-500",hex:"#d946ef",text:"text-fuchsia-500",border:"border-fuchsia-500"},LUT:{bg:"bg-cyan-600",stroke:"stroke-cyan-600",hex:"#0891b2",text:"text-cyan-600",border:"border-cyan-600"}};y();var mr={Image:"png",Video:"mp4",Audio:"mp3",Text:"txt",Number:"txt",Boolean:"txt",SVG:"svg",Caption:"srt",Lottie:"json",ThreeD:"glb",GIF:"gif",Signal:"txt",LUT:"cube"},fr={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",mp3:"audio/mpeg",wav:"audio/wav",ogg:"audio/ogg",pdf:"application/pdf",json:"application/json",txt:"text/plain",srt:"text/srt",aac:"audio/aac",flac:"audio/flac"},nn=["source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","copy","xor","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Tt=S.enum(nn),kt=class r{static schemas=new Map;static register(e,t){r.schemas.set(e,t)}static get(e){return r.schemas.get(e)}static clear(){r.schemas.clear()}};y();var pr={FONT_FAMILY:"Inter",FONT_SIZE:64,FILL:"#ffffff",LINE_HEIGHT:1.1,ALIGN:"left",VERTICAL_ALIGN:"top",LETTER_SPACING:0,STROKE_WIDTH:0,STROKE:"#000000",CORNER_RADIUS:0,PADDING:0};y();var rn=S.enum(["fade-in","fade-out","slide-in-left","slide-in-right","slide-in-top","slide-in-bottom","zoom-in","zoom-out","rotate-cw","rotate-ccw","bounce","shake"]),on=S.object({id:S.string(),type:rn,value:S.number()}),sn=S.object({x:S.number().default(0),y:S.number().default(0),width:S.number().optional(),height:S.number().optional(),rotation:S.number().default(0),scale:S.number().min(0).default(1),opacity:S.number().min(0).max(1).default(1),zIndex:S.number().int().optional(),blendMode:Tt.optional()}),an=S.object({startFrame:S.number().int().min(0).default(0),durationInMS:S.number().int().min(1).optional(),trimStart:S.number().int().min(0).optional(),trimEnd:S.number().int().min(0).optional(),speed:S.number().min(.25).max(4).optional()}),cn=S.object({text:S.string().optional(),fontSize:S.number().optional(),fontFamily:S.string().optional(),fontStyle:S.string().optional(),fontWeight:S.union([S.number(),S.string()]).optional(),fill:S.string().optional(),align:S.string().optional(),direction:S.enum(["ltr","rtl","auto"]).optional(),verticalAlign:S.string().optional(),letterSpacing:S.number().optional(),lineHeight:S.number().optional(),padding:S.number().optional(),stroke:S.string().optional(),strokeWidth:S.number().optional(),strokeAlign:S.enum(["inside","center","outside"]).optional(),textShadow:S.string().optional(),textBackgroundColor:S.string().optional(),shadows:S.array(S.object({color:S.string(),offset:S.object({x:S.number(),y:S.number()}).optional(),blurRadius:S.number().optional()})).optional(),textAnimation:S.any().optional(),bottomPadding:S.number().optional(),maxWidth:S.number().optional()}),ln=S.object({backgroundColor:S.string().optional(),borderColor:S.string().optional(),borderWidth:S.number().optional(),strokeRadius:S.number().optional(),autoDimensions:S.boolean().optional()}),De=S.enum(["Video","Image","Audio","Text","Caption","SVG","GIF","Lottie"]),St=sn.merge(an).merge(cn).merge(ln).extend({type:De.optional(),animations:S.array(on).optional()});y();y();var dn=S.enum(["none","crossfade","wipe-left","wipe-right","slide-up","slide-down"]),Be=S.object({type:dn,durationFrames:S.number().min(1)});var Or=St.extend({id:S.string(),name:S.string().optional(),type:De,virtualMedia:ot.optional(),transitionIn:Be.optional(),transitionOut:Be.optional(),durationInMS:S.number(),maxDurationInMS:S.number().optional(),src:S.string().optional(),volume:S.number().default(1),inputHandleId:S.string().optional(),isPlaceholder:S.boolean().optional(),lockAspect:S.boolean().optional(),lockRatio:S.boolean().optional(),zIndex:S.number().optional()}).strict();y();function _t(r,e){if(r===e||typeof r=="number"&&typeof e=="number"&&Number.isNaN(r)&&Number.isNaN(e))return!0;if(r&&e&&typeof r=="object"&&typeof e=="object"){if(r.constructor!==e.constructor)return!1;if(Array.isArray(r)){if(r.length!==e.length)return!1;for(let n=0;n<r.length;n++)if(!_t(r[n],e[n]))return!1;return!0}if(r instanceof Date)return r.getTime()===e.getTime();if(r instanceof RegExp)return r.toString()===e.toString();let t=Object.keys(r);if(t.length!==Object.keys(e).length)return!1;for(let n of t)if(!Object.hasOwn(e,n)||!_t(r[n],e[n]))return!1;return!0}return!1}y();function Ar(r,e){if(!r?.sourceFingerprint)return null;let t=je(e);return r.sourceFingerprint!==t?null:r}function Dr(r,e){return{...r,sourceFingerprint:je(e)}}y();function Ur(r){try{let t=r.toString("utf-8").match(/<svg[^>]*>/i);if(!t)return null;let n=t[0],s=a=>{let c=n.match(new RegExp(`${a}=["']([^"']+)["']`,"i"));if(!c)return null;let h=parseFloat(c[1].replace(/[a-z%]/gi,""));return isNaN(h)?null:h},o=s("width"),i=s("height"),m=n.match(/viewBox=["']([^"']+)["']/i);if(m){let a=m[1].split(/[\s,]+/).map(parseFloat);if(a.length>=4&&!isNaN(a[2])&&!isNaN(a[3])){let c=a[2],h=a[3];o==null&&i==null?(o=c,i=h):o!=null&&i==null?i=o*(h/c):i!=null&&o==null&&(o=i*(c/h))}}return o!=null&&i!=null&&o>0&&i>0?{w:o,h:i}:null}catch(e){return console.error("Error parsing SVG dimensions",e),null}}y();y();y();y();var se=(r,e,t)=>`https://huggingface.co/${r}/resolve/${e}/${t}`,Fe="tori29umai/rtmdet-ins-onnx-person-masks",Ue="e5218e8d47d7c50077f27f9893a28e0ef2ad5656",He="RTMDet-Ins (OpenMMLab mmdetection, Apache-2.0), mmdeploy ONNX export",ze="RTMO (OpenMMLab mmpose, Apache-2.0), ONNX export",wt="MediaPipe Selfie Segmenter (Google, Apache-2.0), ONNX export",oe={"rtmdet-ins-t":{key:"rtmdet-ins-t",family:"rtmdet-ins",filename:"rtmdet-ins-t.onnx",url:se(Fe,Ue,"models/tiny/rtmdet-ins_tiny_640x640.onnx"),bytes:24032356,sha256:"99ee670820c4493aa13e20578b6a8e39781c319846dc41796a77765734beac5c",input:[640,640],source:He},"rtmdet-ins-s":{key:"rtmdet-ins-s",family:"rtmdet-ins",filename:"rtmdet-ins-s.onnx",url:se(Fe,Ue,"models/s/rtmdet-ins_s_640x640.onnx"),bytes:43236976,sha256:"9cd1787fbf3eb2bd64cc2d8154f41c036f5484b85599e1cbe0227a2dc5a4a08b",input:[640,640],source:He},"rtmdet-ins-m":{key:"rtmdet-ins-m",family:"rtmdet-ins",filename:"rtmdet-ins-m.onnx",url:se(Fe,Ue,"models/m/rtmdet-ins_m_640x640.onnx"),bytes:115735979,sha256:"a003bce80316e03467c2c2b483df2d5c0398220c2357a44f9bf985929f7eb052",input:[640,640],source:He},"rtmo-t":{key:"rtmo-t",family:"rtmo",filename:"rtmo-t.onnx",url:se("Xenova/RTMO-t","f29d13ce5ee291fbe505e9d06a049992f05699dc","onnx/model.onnx"),bytes:27360569,sha256:"cb54dd042bf997df86d938721c94238940f2bff98ba8d2ccc834430de5c65c13",input:[416,416],source:ze},"rtmo-s":{key:"rtmo-s",family:"rtmo",filename:"rtmo-s.onnx",url:se("Xenova/RTMO-s","d8c526187f341d287753831c9c8b1ecc4855bba1","onnx/model.onnx"),bytes:39636400,sha256:"1cd6a3517658903233e9ccb78666554862f57f0944b6886e2048093594aef4e7",input:[640,640],source:ze},"rtmo-m":{key:"rtmo-m",family:"rtmo",filename:"rtmo-m.onnx",url:se("Xenova/RTMO-m","3aba1280472b98ee2bf663482e27e243038d23fe","onnx/model.onnx"),bytes:89291929,sha256:"76d82c45e5c4810baf587ecf2638d15cbf7ed196afb2055e977382532021b59e",input:[640,640],source:ze},"selfie-square":{key:"selfie-square",family:"selfie",filename:"selfie-square.onnx",url:se("onnx-community/mediapipe_selfie_segmentation","be49485c8e027524be38591817fc5cd31bd9d00e","onnx/model.onnx"),bytes:462352,sha256:"3241ac4ad8aa35bdaf33946776db29f7c283a413aa0b0dacb9483594b4531aad",input:[256,256],source:wt},"selfie-landscape":{key:"selfie-landscape",family:"selfie",filename:"selfie-landscape.onnx",url:se("onnx-community/mediapipe_selfie_segmentation_landscape","2497d5bec26c626c7b3c4edc6e1fefc21b64f6c3","onnx/model.onnx"),bytes:462338,sha256:"7a0adcfdb1715d3b0ff0f61486d8a181c33f4a208343a5abfccbc6540e872d24",input:[256,144],source:wt}};function vt(r,e="s",t=1){return r==="pose"?`rtmo-${e}`:r==="matte"?t>1.3?"selfie-landscape":"selfie-square":`rtmdet-ins-${e}`}var ke=["person","bicycle","car","motorcycle","airplane","bus","train","truck","boat","traffic light","fire hydrant","stop sign","parking meter","bench","bird","cat","dog","horse","sheep","cow","elephant","bear","zebra","giraffe","backpack","umbrella","handbag","tie","suitcase","frisbee","skis","snowboard","sports ball","kite","baseball bat","baseball glove","skateboard","surfboard","tennis racket","bottle","wine glass","cup","fork","knife","spoon","bowl","banana","apple","sandwich","orange","broccoli","carrot","hot dog","pizza","donut","cake","chair","couch","potted plant","bed","dining table","toilet","tv","laptop","mouse","remote","keyboard","cell phone","microwave","oven","toaster","sink","refrigerator","book","clock","vase","scissors","teddy bear","hair drier","toothbrush"];y();function ae(r,e){let t=Math.max(r.originX,e.originX),n=Math.max(r.originY,e.originY),s=Math.min(r.originX+r.width,e.originX+e.width),o=Math.min(r.originY+r.height,e.originY+e.height),i=Math.max(0,s-t),m=Math.max(0,o-n),a=i*m;if(a<=0)return 0;let c=r.width*r.height,h=e.width*e.height,l=c+h-a;return l>0?a/l:0}var ue=class{_nextTrackId=1;_tracks=[];_iouThreshold;_maxMissedFrames;_minHits;_positionSmoothing;_activeDuringCoast;constructor(e={}){this._iouThreshold=e.iouThreshold??.25,this._maxMissedFrames=e.maxMissedFrames??15,this._minHits=e.minHits??1,this._positionSmoothing=Math.max(.1,Math.min(1,e.positionSmoothing??.75)),this._activeDuringCoast=e.activeDuringCoast!==!1}update(e,t,n=24){let s=n>0?1/n:.0416;for(let a of this._tracks)if(a.age++,a.timeSinceUpdate++,a.timeSinceUpdate>0){let c=a.centerX+a.vx*s,h=a.centerY+a.vy*s;a.centerX=c,a.centerY=h;let l=a.box.width,p=a.box.height,T=a.box.normalizedWidth,j=a.box.normalizedHeight,P=a.box.normalizedX+T/2+a.vx*s/Math.max(1,a.box.width/T),E=a.box.normalizedY+j/2+a.vy*s/Math.max(1,a.box.height/j);a.box={originX:c-l/2,originY:h-p/2,width:l,height:p,normalizedX:P-T/2,normalizedY:E-j/2,normalizedWidth:T,normalizedHeight:j},a.vx*=.92,a.vy*=.92,a.isCoasting=!0}let o=new Set,i=new Set,m=[];for(let a=0;a<this._tracks.length;a++){let c=this._tracks[a];for(let h=0;h<e.length;h++){let l=e[h];if(c.category!==l.category)continue;let p=ae(c.box,l.boundingBox);p>=this._iouThreshold&&m.push({trackIdx:a,detIdx:h,iou:p})}}m.sort((a,c)=>c.iou-a.iou);for(let a of m){if(i.has(a.trackIdx)||o.has(a.detIdx))continue;i.add(a.trackIdx),o.add(a.detIdx);let c=this._tracks[a.trackIdx],h=e[a.detIdx],l=h.boundingBox,p=l.originX+l.width/2,T=l.originY+l.height/2,j=(p-c.centerX)/s,P=(T-c.centerY)/s;c.vx=c.vx*.4+j*.6,c.vy=c.vy*.4+P*.6;let E=this._positionSmoothing,g=c.box.width*(1-E)+l.width*E,_=c.box.height*(1-E)+l.height*E,b=c.centerX*(1-E)+p*E,V=c.centerY*(1-E)+T*E;c.centerX=b,c.centerY=V,c.score=h.score,c.timeSinceUpdate=0,c.hits++,c.isCoasting=!1,c.hits>=this._minHits&&(c.active=!0),c.box={originX:b-g/2,originY:V-_/2,width:g,height:_,normalizedX:l.normalizedX,normalizedY:l.normalizedY,normalizedWidth:l.normalizedWidth,normalizedHeight:l.normalizedHeight}}for(let a=0;a<e.length;a++){if(o.has(a))continue;let c=e[a],h=c.boundingBox,l=h.originX+h.width/2,p=h.originY+h.height/2;this._tracks.push({trackId:this._nextTrackId++,category:c.category,score:c.score,box:h,centerX:l,centerY:p,vx:0,vy:0,age:1,hits:1,timeSinceUpdate:0,active:this._minHits<=1,isCoasting:!1})}return this._tracks=this._tracks.filter(a=>a.timeSinceUpdate<=this._maxMissedFrames),this._tracks.filter(a=>a.active).map(a=>{let c=a.box.normalizedWidth,h=a.box.normalizedHeight,l=a.box.normalizedX+c/2,p=a.box.normalizedY+h/2,T=Math.sqrt(a.vx*a.vx+a.vy*a.vy);return{trackId:a.trackId,category:a.category,score:a.score,boundingBox:a.box,centerX:a.centerX,centerY:a.centerY,normalizedCenterX:l,normalizedCenterY:p,velocity:{vx:a.vx,vy:a.vy},speed:T,age:a.age,hits:a.hits,active:this._activeDuringCoast?!0:a.timeSinceUpdate===0,isCoasting:a.isCoasting}})}trackSequence(e,t,n=24){this.reset();let s=n>0?1/n:.0416,o=new Map;for(let a=0;a<t;a++){let c=e[a]??[],h=this.update(c,a,n);for(let l of h)o.has(l.trackId)||o.set(l.trackId,{category:l.category,observations:[]}),l.isCoasting||o.get(l.trackId).observations.push({frame:a,box:l.boundingBox,score:l.score})}let i=new Map;for(let[a,c]of o.entries()){let h=c.observations;if(h.length===0)continue;h.sort((g,_)=>g.frame-_.frame);let l=new Array(t).fill(null);for(let g of h)l[g.frame]={box:g.box,score:g.score};let p=h[0];for(let g=0;g<p.frame;g++)l[g]={box:{...p.box},score:p.score*.9};for(let g=0;g<h.length-1;g++){let _=h[g],b=h[g+1],V=b.frame-_.frame;if(!(V<=1))for(let f=_.frame+1;f<b.frame;f++){let d=(f-_.frame)/V,M=_.box.originX+(b.box.originX-_.box.originX)*d,x=_.box.originY+(b.box.originY-_.box.originY)*d,w=_.box.width+(b.box.width-_.box.width)*d,I=_.box.height+(b.box.height-_.box.height)*d,U=_.box.normalizedX+(b.box.normalizedX-_.box.normalizedX)*d,C=_.box.normalizedY+(b.box.normalizedY-_.box.normalizedY)*d,v=_.box.normalizedWidth+(b.box.normalizedWidth-_.box.normalizedWidth)*d,u=_.box.normalizedHeight+(b.box.normalizedHeight-_.box.normalizedHeight)*d;l[f]={box:{originX:M,originY:x,width:w,height:I,normalizedX:U,normalizedY:C,normalizedWidth:v,normalizedHeight:u},score:_.score*(1-d)+b.score*d}}}let T=h[h.length-1];for(let g=T.frame+1;g<t;g++)l[g]={box:{...T.box},score:T.score*.9};let j=[],P=2,E=[.06136,.24477,.38774,.24477,.06136];for(let g=0;g<t;g++){let _=0,b=0,V=0,f=0,d=0,M=0,x=0,w=0,I=0,U=0;for(let v=-P;v<=P;v++){let u=Math.max(0,Math.min(t-1,g+v)),R=l[u];if(R){let z=E[v+P];_+=z,b+=R.box.originX*z,V+=R.box.originY*z,f+=R.box.width*z,d+=R.box.height*z,M+=R.box.normalizedX*z,x+=R.box.normalizedY*z,w+=R.box.normalizedWidth*z,I+=R.box.normalizedHeight*z,U+=R.score*z}}let C=_>0?1/_:1;j.push({box:{originX:b*C,originY:V*C,width:f*C,height:d*C,normalizedX:M*C,normalizedY:x*C,normalizedWidth:w*C,normalizedHeight:I*C},score:U*C})}i.set(a,{category:c.category,frames:j})}let m=[];for(let a=0;a<t;a++){let c=[];for(let[h,l]of i.entries()){let p=l.frames[a];if(!p)continue;let T=l.frames[Math.max(0,a-1)]??p,j=l.frames[Math.min(t-1,a+1)]??p,P=p.box.originX+p.box.width/2,E=p.box.originY+p.box.height/2,g=T.box.originX+T.box.width/2,_=T.box.originY+T.box.height/2,b=j.box.originX+j.box.width/2,V=j.box.originY+j.box.height/2,f=a===0||a===t-1?s:2*s,d=(b-g)/f,M=(V-_)/f,x=Math.sqrt(d*d+M*M),w=p.box.normalizedWidth,I=p.box.normalizedHeight;c.push({trackId:h,category:l.category,score:p.score,boundingBox:p.box,centerX:P,centerY:E,normalizedCenterX:p.box.normalizedX+w/2,normalizedCenterY:p.box.normalizedY+I/2,velocity:{vx:d,vy:M},speed:x,age:a+1,hits:10,active:!0,isCoasting:!1})}m.push(c)}return m}reset(){this._tracks=[],this._nextTrackId=1}};var Mt=()=>typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now();async function Wr(r,e){let{runner:t}=e,n=e.fps??24,s=e.tasks&&e.tasks.length>0?e.tasks:["detect"],o=new Set(s),i=e.categories?new Set(e.categories.map(v=>v.toLowerCase())):null,m=e.includeMasks===!0&&o.has("segment"),a=o.has("detect")||o.has("segment"),c=[],h={},l=new Map,p=0,T=0,j=v=>!i||i.has(v.toLowerCase()),P=async(v,u,R)=>{let z=t.modelKeyFor(v,u.width/u.height),F=t.downloadStatus.get(z)==="ready",O=Mt(),D=await R(),$=Mt()-O;return p+=$,!F&&!h[z]&&(h[z]={bytes:oe[z].bytes,ms:$}),D},E=v=>{for(let u of v){if(!j(u.category))continue;let R=l.get(u.category)??{sum:0,count:0};R.sum+=u.coverage,R.count++,l.set(u.category,R)}};for await(let v of r){let u=[];if(m){let R=await P("segment",v,()=>t.segment(v));E(R.masks),u=R.detections}else a&&(u=await P("detect",v,()=>t.detect(v)));o.has("pose")&&await P("pose",v,()=>t.pose(v)),o.has("matte")&&await P("matte",v,()=>t.matte(v)),c.push(i?u.filter(R=>j(R.category)):u),T++}let g=T,b=new ue({iouThreshold:e.iouThreshold??.25,maxMissedFrames:e.maxMissedFrames??15}).trackSequence(c,g,n),V=e.pathStride??Math.max(1,Math.ceil(g/50)),f=new Map,d=new Map,M=new Map,x=new Map,w=(v,u,R)=>{let z=v.get(u);return z===void 0&&(z=R(),v.set(u,z)),z};for(let v=0;v<g;v++)for(let u of b[v]??[]){if(!j(u.category))continue;let R=f.get(u.trackId);R||(R={category:u.category,firstFrame:v,lastFrame:v,speedSum:0,speedCount:0,centers:[]},f.set(u.trackId,R)),R.lastFrame=v,Number.isFinite(u.speed)&&(R.speedSum+=u.speed,R.speedCount++),(v-R.firstFrame)%V===0&&R.centers.push({frame:v,x:u.centerX,y:u.centerY}),w(d,u.category,()=>new Set).add(v),M.set(u.category,Math.max(M.get(u.category)??0,u.score)),w(x,u.category,()=>new Set).add(u.trackId)}let I=Array.from(f.entries()).map(([v,u])=>({trackId:v,category:u.category,frames:[u.firstFrame,u.lastFrame],speedMeanPxS:u.speedCount>0?u.speedSum/u.speedCount:0,centerPath:u.centers.map(R=>[R.x,R.y])})).sort((v,u)=>v.trackId-u.trackId),U={};for(let[v,u]of d)U[v]={framesPresent:u.size,totalFrames:g,maxConfidence:M.get(v)??0,tracks:x.get(v)?.size??0};let C={};for(let[v,u]of l)C[v]={meanCoverage:u.count>0?u.sum/u.count:0};return{source:e.source??"frames",totalFrames:g,fps:n,durationSec:n>0?g/n:0,tasks:Array.from(o),modelDownloads:h,inferenceMs:p,trackCount:I.length,classes:U,tracks:I,masks:C}}y();var un=[103.53,116.28,123.675],mn=[57.375,57.12,58.395],fn={"rtmdet-ins":{fit:"topLeft",channels:"bgr",mean:un,std:mn,padValue:114},rtmo:{fit:"center",channels:"bgr",mean:[0,0,0],std:[1,1,1],padValue:114},selfie:{fit:"stretch",channels:"rgb",mean:[0,0,0],std:[255,255,255],padValue:0}};function Pt(r,e){return{...fn[r],width:e[0],height:e[1]}}function hn(r,e,t){if(t.fit==="stretch")return{scaleX:t.width/r,scaleY:t.height/e,offsetX:0,offsetY:0,inputWidth:t.width,inputHeight:t.height};let n=Math.min(t.width/r,t.height/e),s=Math.round(r*n),o=Math.round(e*n),i=t.fit==="center";return{scaleX:n,scaleY:n,offsetX:i?(t.width-s)/2:0,offsetY:i?(t.height-o)/2:0,inputWidth:t.width,inputHeight:t.height}}function ce(r,e,t){return{x:(r-t.offsetX)/t.scaleX,y:(e-t.offsetY)/t.scaleY}}function Rt(r,e,t){let{width:n,height:s,data:o}=r,{width:i,height:m}=e,a=hn(n,s,e),{scaleX:c,scaleY:h,offsetX:l,offsetY:p}=a,T=i*m;(!t||t.length<3*T)&&(t=new Float32Array(3*T));let j=e.channels==="bgr"?[2,1,0]:[0,1,2],[P,E,g]=e.mean,_=1/e.std[0],b=1/e.std[1],V=1/e.std[2],f=(e.padValue-P)*_,d=(e.padValue-E)*b,M=(e.padValue-g)*V,[x,w,I]=j,U=Math.ceil(l),C=Math.ceil(p),v=Math.min(i,Math.floor(l+n*c))-1,u=Math.min(m,Math.floor(p+s*h))-1;for(let R=0;R<m;R++){let z=R*i,F=R<C||R>u,O=Math.max(0,(R+.5-p)/h-.5),D=Math.min(s-1,Math.floor(O)),$=Math.min(s-1,D+1),N=O-D;for(let X=0;X<i;X++){let q=z+X;if(F||X<U||X>v){t[q]=f,t[T+q]=d,t[2*T+q]=M;continue}let K=Math.max(0,(X+.5-l)/c-.5),H=Math.min(n-1,Math.floor(K)),ne=Math.min(n-1,H+1),Q=K-H,Y=(D*n+H)*4,re=(D*n+ne)*4,B=($*n+H)*4,G=($*n+ne)*4,Z=(1-Q)*(1-N),J=Q*(1-N),ee=(1-Q)*N,W=Q*N;t[q]=(o[Y+x]*Z+o[re+x]*J+o[B+x]*ee+o[G+x]*W-P)*_,t[T+q]=(o[Y+w]*Z+o[re+w]*J+o[B+w]*ee+o[G+w]*W-E)*b,t[2*T+q]=(o[Y+I]*Z+o[re+I]*J+o[B+I]*ee+o[G+I]*W-g)*V}}return{tensor:t,transform:a}}y();var Te=8;function Ye(r,e){let{sourceWidth:t,sourceHeight:n,transform:s}=e,o=e.classes?new Set(e.classes.map(P=>P.toLowerCase())):null,i=[];for(let P=0;P<r.count;P++){let E=r.dets[P*5+4];if(!(E>=e.confidence))continue;let g=Number(r.labels[P]),_=e.classNames[g]??`class_${g}`;if(o&&!o.has(_.toLowerCase()))continue;let b=ce(r.dets[P*5],r.dets[P*5+1],s),V=ce(r.dets[P*5+2],r.dets[P*5+3],s),f=ie(b.x,0,t),d=ie(b.y,0,n),M=ie(V.x,0,t)-f,x=ie(V.y,0,n)-d;M<=0||x<=0||i.push({index:P,detection:{category:_,score:E,boundingBox:{originX:f,originY:d,width:M,height:x,normalizedX:f/t,normalizedY:d/n,normalizedWidth:M/t,normalizedHeight:x/n}}})}i.sort((P,E)=>E.detection.score-P.detection.score);let m=i.map(P=>P.detection),a=[];if(!r.masks)return{detections:m,masks:a};let c=Ne(e.maskThreshold??.5,e.featherRadius??.05),{maskWidth:h,maskHeight:l}=r,p=h*l,T=h/s.inputWidth,j=l/s.inputHeight;for(let P=0;P<i.length;P++){let{index:E,detection:g}=i[P],_=g.boundingBox,b=E*p,V=Math.max(0,Math.floor(_.originX)-Te),f=Math.max(0,Math.floor(_.originY)-Te),d=Math.min(t-1,Math.ceil(_.originX+_.width)+Te),M=Math.min(n-1,Math.ceil(_.originY+_.height)+Te),x=new Uint8Array(t*n),w=0;for(let I=f;I<=M;I++){let U=((I+.5)*s.scaleY+s.offsetY)*j-.5,C=ie(Math.floor(U),0,l-1),v=Math.min(l-1,C+1),u=ie(U-C,0,1),R=I*t;for(let z=V;z<=d;z++){let F=((z+.5)*s.scaleX+s.offsetX)*T-.5,O=ie(Math.floor(F),0,h-1),D=Math.min(h-1,O+1),$=ie(F-O,0,1),N=r.masks[b+C*h+O]*(1-$)*(1-u)+r.masks[b+C*h+D]*$*(1-u)+r.masks[b+v*h+O]*(1-$)*u+r.masks[b+v*h+D]*$*u,X=c(N);X>0&&(x[R+z]=X,w+=X/255)}}w=Math.round(w),w!==0&&a.push({category:g.category,mask:x,width:t,height:n,area:w,coverage:w/(t*n),detectionIndex:P})}return{detections:m,masks:a}}function Ne(r,e){if(e<=0)return s=>s>r?255:0;let t=r-e,n=255/(2*e);return s=>s<=t?0:s>=r+e?255:(s-t)*n}function ie(r,e,t){return r<e?e:r>t?t:r}y();var Ct=17,Xe=.3;function Ot(r,e){let{sourceWidth:t,sourceHeight:n,transform:s}=e,o=r.keypointStride,i=[];for(let c=0;c<r.count;c++){let h=r.dets[c*5+4];if(!(h>=e.confidence))continue;let l=ce(r.dets[c*5],r.dets[c*5+1],s),p=ce(r.dets[c*5+2],r.dets[c*5+3],s),T=le(l.x,0,t),j=le(l.y,0,n),P=le(p.x,0,t)-T,E=le(p.y,0,n)-j;if(P<=0||E<=0)continue;let g=[],_=c*Ct*o;for(let V=0;V<Ct;V++){let f=_+V*o,d=ce(r.keypoints[f],r.keypoints[f+1],s);g.push({x:le(d.x,0,t),y:le(d.y,0,n),visibility:le(r.keypoints[f+2],0,1)})}let b=0;for(let V of g)V.visibility>=Xe&&b++;b<(e.minVisibleKeypoints??3)||i.push({score:h,boundingBox:{originX:T,originY:j,width:P,height:E,normalizedX:T/t,normalizedY:j/n,normalizedWidth:P/t,normalizedHeight:E/n},keypoints:g})}i.sort((c,h)=>h.score-c.score);let m=e.iouThreshold??.6,a=[];for(let c of i)a.some(h=>gn(h,c,m))||a.push(c);return{people:a}}function le(r,e,t){return r<e?e:r>t?t:r}function gn(r,e,t){if(ae(r.boundingBox,e.boundingBox)>t)return!0;let n=Math.sqrt(r.boundingBox.width*r.boundingBox.height),s=0,o=0;for(let i=0;i<r.keypoints.length;i++){let m=r.keypoints[i],a=e.keypoints[i];m.visibility<Xe||a.visibility<Xe||(s+=Math.hypot(m.x-a.x,m.y-a.y),o++)}return o>=3&&s/o<.1*n}y();function It(r,e,t,n){let{sourceWidth:s,sourceHeight:o}=n,i=Ne(n.maskThreshold??.5,n.featherRadius??.2),m=new Uint8Array(s*o),a=e/s,c=t/o,h=0;for(let l=0;l<o;l++){let p=Math.max(0,(l+.5)*c-.5),T=Math.min(t-1,Math.floor(p)),j=Math.min(t-1,T+1),P=p-T;for(let E=0;E<s;E++){let g=Math.max(0,(E+.5)*a-.5),_=Math.min(e-1,Math.floor(g)),b=Math.min(e-1,_+1),V=g-_,f=r[T*e+_]*(1-V)*(1-P)+r[T*e+b]*V*(1-P)+r[j*e+_]*(1-V)*P+r[j*e+b]*V*P,d=i(f);m[l*s+E]=d,h+=d}}return{mask:m,width:s,height:o,coverage:s*o>0?h/(255*s*o):0}}y();y();y();var Lt=`
2
+ struct Bone {
3
+ start: vec2<f32>,
4
+ end: vec2<f32>,
5
+ color: vec4<f32>,
6
+ radius: f32,
7
+ enabled: f32,
8
+ pad: vec2<f32>,
9
+ };
10
+
11
+ struct SkeletonParams {
12
+ width: u32,
13
+ height: u32,
14
+ numBones: u32,
15
+ pad: u32,
16
+ bones: array<Bone, 24>,
17
+ };
18
+
19
+ @group(0) @binding(0) var outputTex: texture_storage_2d<rgba8unorm, write>;
20
+ @group(0) @binding(1) var<uniform> params: SkeletonParams;
21
+
22
+ @compute @workgroup_size(16, 16)
23
+ fn computePoseSkeleton(@builtin(global_invocation_id) id: vec3<u32>) {
24
+ if (id.x >= params.width || id.y >= params.height) {
25
+ return;
26
+ }
27
+
28
+ let p = vec2<f32>(f32(id.x) + 0.5, f32(id.y) + 0.5);
29
+ var outColor = vec4<f32>(0.0, 0.0, 0.0, 0.0);
30
+
31
+ let count = min(params.numBones, 24u);
32
+ for (var i = 0u; i < count; i = i + 1u) {
33
+ let bone = params.bones[i];
34
+ if (bone.enabled < 0.5) {
35
+ continue;
36
+ }
37
+
38
+ let ab = bone.end - bone.start;
39
+ let ap = p - bone.start;
40
+ let l2 = dot(ab, ab);
41
+
42
+ var t: f32 = 0.0;
43
+ if (l2 > 0.0001) {
44
+ t = clamp(dot(ap, ab) / l2, 0.0, 1.0);
45
+ }
46
+
47
+ let closest = bone.start + t * ab;
48
+ let dist = length(p - closest);
49
+
50
+ if (dist <= bone.radius) {
51
+ // Sub-pixel edge antialiasing
52
+ let edgeAlpha = clamp(bone.radius - dist + 0.5, 0.0, 1.0);
53
+ let a = edgeAlpha * bone.color.a;
54
+ outColor = vec4<f32>(mix(outColor.rgb, bone.color.rgb, a), max(outColor.a, a));
55
+ }
56
+ }
57
+
58
+ textureStore(outputTex, id.xy, outColor);
59
+ }
60
+ `;var pn=[{from:0,to:11,color:[0,1,1,1]},{from:0,to:12,color:[0,1,1,1]},{from:11,to:12,color:[1,0,0,1]},{from:11,to:13,color:[1,.333,0,1]},{from:13,to:15,color:[1,.667,0,1]},{from:12,to:14,color:[1,1,0,1]},{from:14,to:16,color:[.667,1,0,1]},{from:11,to:23,color:[.333,1,0,1]},{from:12,to:24,color:[0,1,0,1]},{from:23,to:24,color:[0,1,.333,1]},{from:23,to:25,color:[0,1,.667,1]},{from:25,to:27,color:[0,1,1,1]},{from:24,to:26,color:[0,.667,1,1]},{from:26,to:28,color:[0,.333,1,1]}],Se=class{constructor(e){this.device=e;let t=e.createShaderModule({label:"pose_skeleton.wgsl",code:Lt});this.computePipeline=e.createComputePipeline({label:"PoseSkeletonComputePipeline",layout:"auto",compute:{module:t,entryPoint:"computePoseSkeleton"}}),this.uniformBuffer=e.createBuffer({size:1280,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,label:"pose_skeleton_uniform_buffer"})}device;computePipeline;uniformBuffer;cachedOutputTexture;execute(e,t={},n){let s=n??pn,o=t.width??1024,i=t.height??1024,m=t.lineWidth??6,a=Math.max(1,m/2),c=1280,h=new ArrayBuffer(c),l=new Uint32Array(h),p=new Float32Array(h);l[0]=o,l[1]=i,l[2]=s.length,l[3]=0;let T=4;for(let g=0;g<s.length;g++){let _=s[g],b=e[_.from],V=e[_.to],f=T+g*12;if(!b||!V||(b.visibility??1)<.2||(V.visibility??1)<.2){p[f+9]=0;continue}p[f+0]=b.x*o,p[f+1]=b.y*i,p[f+2]=V.x*o,p[f+3]=V.y*i,p[f+4]=_.color[0],p[f+5]=_.color[1],p[f+6]=_.color[2],p[f+7]=_.color[3],p[f+8]=a,p[f+9]=1}this.device.queue.writeBuffer(this.uniformBuffer,0,h),(!this.cachedOutputTexture||this.cachedOutputTexture.width!==o||this.cachedOutputTexture.height!==i)&&(this.cachedOutputTexture?.destroy(),this.cachedOutputTexture=this.device.createTexture({label:"openpose_skeleton_texture",size:[o,i],format:"rgba8unorm",usage:GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC}));let j=this.device.createCommandEncoder({label:"pose_skeleton_command_encoder"}),P=this.device.createBindGroup({label:"pose_skeleton_bind_group",layout:this.computePipeline.getBindGroupLayout(0),entries:[{binding:0,resource:this.cachedOutputTexture.createView({label:"pose_skeleton_output_view"})},{binding:1,resource:{buffer:this.uniformBuffer}}]}),E=j.beginComputePass({label:"pose_skeleton_compute_pass"});return E.setPipeline(this.computePipeline),E.setBindGroup(0,P),E.dispatchWorkgroups(Math.ceil(o/16),Math.ceil(i/16),1),E.end(),this.device.queue.submit([j.finish()]),this.cachedOutputTexture}destroy(){this.cachedOutputTexture?.destroy(),this.cachedOutputTexture=void 0,this.uniformBuffer.destroy()}};y();var k={NOSE:0,LEFT_EYE:1,RIGHT_EYE:2,LEFT_EAR:3,RIGHT_EAR:4,LEFT_SHOULDER:5,RIGHT_SHOULDER:6,LEFT_ELBOW:7,RIGHT_ELBOW:8,LEFT_WRIST:9,RIGHT_WRIST:10,LEFT_HIP:11,RIGHT_HIP:12,LEFT_KNEE:13,RIGHT_KNEE:14,LEFT_ANKLE:15,RIGHT_ANKLE:16},Ge=["nose","leftEye","rightEye","leftEar","rightEar","leftShoulder","rightShoulder","leftElbow","rightElbow","leftWrist","rightWrist","leftHip","rightHip","leftKnee","rightKnee","leftAnkle","rightAnkle"],Et=[{from:k.NOSE,to:k.LEFT_SHOULDER,color:[0,1,1,1]},{from:k.NOSE,to:k.RIGHT_SHOULDER,color:[0,1,1,1]},{from:k.LEFT_SHOULDER,to:k.RIGHT_SHOULDER,color:[1,0,0,1]},{from:k.LEFT_SHOULDER,to:k.LEFT_ELBOW,color:[1,.333,0,1]},{from:k.LEFT_ELBOW,to:k.LEFT_WRIST,color:[1,.667,0,1]},{from:k.RIGHT_SHOULDER,to:k.RIGHT_ELBOW,color:[1,1,0,1]},{from:k.RIGHT_ELBOW,to:k.RIGHT_WRIST,color:[.667,1,0,1]},{from:k.LEFT_SHOULDER,to:k.LEFT_HIP,color:[.333,1,0,1]},{from:k.RIGHT_SHOULDER,to:k.RIGHT_HIP,color:[0,1,0,1]},{from:k.LEFT_HIP,to:k.RIGHT_HIP,color:[0,1,.333,1]},{from:k.LEFT_HIP,to:k.LEFT_KNEE,color:[0,1,.667,1]},{from:k.LEFT_KNEE,to:k.LEFT_ANKLE,color:[0,1,1,1]},{from:k.RIGHT_HIP,to:k.RIGHT_KNEE,color:[0,.667,1,1]},{from:k.RIGHT_KNEE,to:k.RIGHT_ANKLE,color:[0,.333,1,1]}];var _e=class{pipeline;constructor(e){this.pipeline=new Se(e)}renderToTexture(e,t,n=Et){return this.pipeline.execute(e,t,n)}destroy(){this.pipeline.destroy()}};y();var jt=class{device;pool=new Map;constructor(e){this.device=e}getOrCreateTexture(e,t){let n=this.pool.get(e);if(n&&n.width===t.width&&n.height===t.height)return n;n&&n.destroy();let s=t.format??"rgba8unorm",o=this.device.createTexture({label:t.label??`vision_segmentation_${e}`,size:[t.width,t.height,1],format:s,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT});return this.pool.set(e,o),o}uploadMask(e,t,n,s){let o=t.length>=n*s*4,i=o?"rgba8unorm":"r8unorm",m=this.getOrCreateTexture(e,{width:n,height:s,format:i}),a;if(t instanceof Float32Array){a=new Uint8Array(t.length);for(let T=0;T<t.length;T++)a[T]=Math.round(Math.max(0,Math.min(1,t[T]))*255)}else a=t;let h=n*(o?4:1),l=Math.ceil(h/256)*256,p;if(l===h)p=a;else{p=new Uint8Array(l*s);for(let T=0;T<s;T++)p.set(a.subarray(T*h,(T+1)*h),T*l)}return this.device.queue.writeTexture({texture:m},p.buffer,{offset:p.byteOffset,bytesPerRow:l,rowsPerImage:s},{width:n,height:s}),m}destroy(){for(let e of this.pool.values())e.destroy();this.pool.clear()}};y();var Dt=en(At(),1);function bn(){return A.env.FRAMEFIELDS_MODELS_DIR?xe(A.env.FRAMEFIELDS_MODELS_DIR):xe(mt(),".cache/framefields/models")}var ve=class{_modelsDir;_baseUrl;_timeoutMs;_retries;_retryDelayMs;_verify;_fetch;_onProgress;_inflight=new Map;_buffers=new Map;_status=new Map;constructor(e={}){this._modelsDir=e.modelsDir?xe(e.modelsDir):bn(),this._baseUrl=e.baseUrl??A.env.FRAMEFIELDS_MODELS_BASE_URL??void 0,this._timeoutMs=e.timeoutMs,this._retries=Math.max(0,e.retries??2),this._retryDelayMs=e.retryDelayMs??1e3,this._verify=e.verify!==!1,this._fetch=e.fetchImpl??globalThis.fetch,this._onProgress=e.onProgress}get modelsDir(){return this._modelsDir}pathFor(e){return ut(this._modelsDir,oe[e].filename)}descriptor(e){return oe[e]}urlFor(e){let t=oe[e];return this._baseUrl?`${this._baseUrl.replace(/\/+$/,"")}/${t.filename}`:t.url}has(e){let t=this.pathFor(e);if(!ye(t))return!1;try{let n=it(t).size;return this._verify?n===oe[e].bytes:n>0}catch{return!1}}async evict(e){this._buffers.delete(e),this._status.set(e,"pending"),await Ve(this.pathFor(e)).catch(()=>{})}status(e){return this._status.get(e)??"pending"}statuses(){return new Map(this._status)}isLoaded(e){return this._buffers.has(e)}async ensure(e){let t=this._buffers.get(e);if(t)return t;let n=this._inflight.get(e);if(n)return n;let s=this.load(e).finally(()=>this._inflight.delete(e));return this._inflight.set(e,s),s}async preload(e){await Promise.all([...new Set(e)].map(t=>this.ensure(t)))}async load(e){let t=this.pathFor(e);if(this.has(e))return this._status.set(e,"ready"),this.readBuffer(e,t);let n=this.urlFor(e);this._status.set(e,"downloading"),ye(Ae(t))||at(Ae(t),{recursive:!0});let s=`${t}.tmp.${Date.now()}`;try{let{buffer:o,totalBytes:i}=await this.download(e,n);if(o.byteLength===0)throw new Error(`Downloaded vision model '${e}' is empty (0 bytes).`);return this._verify&&this.verifyBytes(e,o,n),this._onProgress?.(e,o.byteLength,i||o.byteLength),await lt(s,o),await dt(s,t),this._buffers.set(e,o),this._status.set(e,"ready"),o}catch(o){throw this._status.set(e,"error"),ye(s)&&await Ve(s).catch(()=>{}),o}}async download(e,t){for(let n=0;;n++){let s;try{let o=await this._fetch(t,{signal:this._timeoutMs?AbortSignal.timeout(this._timeoutMs):void 0});if(o.ok){let m=Number(o.headers.get("content-length")??0);return{buffer:new Uint8Array(await o.arrayBuffer()),totalBytes:m}}let i=new Error(`Failed to download vision model '${e}' from ${t}: HTTP ${o.status} ${o.statusText}`);if(o.status!==429&&o.status<500)throw i;s=i}catch(o){if(!(o instanceof TypeError))throw o;s=o}if(n>=this._retries)throw new Error(`Failed to download vision model '${e}' from ${t} after ${n+1} attempts: ${String(s)}`,{cause:s});await new Promise(o=>setTimeout(o,this._retryDelayMs*2**n))}}verifyBytes(e,t,n){let s=oe[e];if(t.byteLength!==s.bytes)throw new Error(`Vision model '${e}' from ${n} is ${t.byteLength} bytes, expected ${s.bytes}.`);let o=(0,Dt.createHash)("sha256").update(t).digest("hex");if(o!==s.sha256)throw new Error(`Vision model '${e}' from ${n} failed its SHA-256 check (got ${o}, expected ${s.sha256}).`)}async readBuffer(e,t){let n=await ct(t),s=new Uint8Array(n.buffer,n.byteOffset,n.byteLength);return this._buffers.set(e,s),s}clearMemoryCache(){this._buffers.clear()}};y();function Bt(){return{objects:[],rawDetections:[]}}function Ft(){return{people:[]}}function Ut(){let r=[];for(let e=0;e<17;e++)r.push({x:.5,y:.5,z:0,visibility:0});return r}y();var yn=4,fe=class r{variant;confidence;classes;maskThreshold;featherRadius;_core;_ownsCore;constructor(e,t){this.variant=e.variant??"s",this.confidence=e.confidence??.3,this.classes=e.classes,this.maskThreshold=e.maskThreshold??.5,this.featherRadius=e.featherRadius,this._ownsCore=t===void 0,this._core=t??{store:e.store??new ve({modelsDir:e.modelsDir,baseUrl:e.baseUrl,timeoutMs:e.timeoutMs,onProgress:e.onProgress}),provider:e.provider??ft(),sessions:new Map,tensorScratch:new Map,runQueue:new Map,instancePasses:[]}}static create(e={}){return new r(e)}derive(e){return new r({variant:this.variant,confidence:e.confidence??this.confidence,classes:"classes"in e?e.classes:this.classes,maskThreshold:e.maskThreshold??this.maskThreshold,featherRadius:"featherRadius"in e?e.featherRadius:this.featherRadius},this._core)}get modelsDir(){return this._core.store.modelsDir}get downloadStatus(){let e=new Map;for(let t of Object.keys(oe))e.set(t,"pending");for(let[t,n]of this._core.store.statuses())e.set(t,n);return e}modelKeyFor(e,t=1){return vt(e,this.variant,t)}async preload(e=["detect"]){let t=new Set;for(let n of e)n==="matte"?(t.add("selfie-square"),t.add("selfie-landscape")):t.add(this.modelKeyFor(n));await this._core.store.preload([...t]),await Promise.all([...t].map(n=>this.session(n)))}async detect(e){let t=await this.instancePass(e);return Ye({...t.outputs,masks:void 0},this.instanceDecodeOptions(e,t.transform)).detections}async segment(e){let t=await this.instancePass(e);return Ye(t.outputs,this.instanceDecodeOptions(e,t.transform))}async pose(e){let t=this.modelKeyFor("pose"),{outputs:n,transform:s}=await this.infer(t,e),o=me(n,"dets",t),i=me(n,"keypoints",t);return Ot({dets:o.data,keypoints:i.data,count:o.dims[1]??0,keypointStride:i.dims[3]??3},{confidence:this.confidence,transform:s,sourceWidth:e.width,sourceHeight:e.height})}async matte(e){let t=this.modelKeyFor("matte",e.width/e.height),[n,s]=oe[t].input,{outputs:o}=await this.infer(t,e),i=me(o,"alphas",t);return It(i.data,n,s,{sourceWidth:e.width,sourceHeight:e.height,maskThreshold:this.maskThreshold,...this.featherRadius!==void 0?{featherRadius:this.featherRadius}:{}})}close(){if(!this._ownsCore)return;let e=this._core;for(let t of e.sessions.values())t.then(n=>n.release()).catch(()=>{});e.sessions.clear(),e.runQueue.clear(),e.instancePasses.length=0,e.store.clearMemoryCache()}instancePass(e){let t=this._core.instancePasses,n=xn(e),s=t.find(a=>a.content===n);if(s)return s.result;let o=this.modelKeyFor("segment"),i=this.infer(o,e).then(({outputs:a,transform:c})=>{let h=me(a,"dets",o),l=me(a,"masks",o);return{transform:c,outputs:{dets:h.data,labels:me(a,"labels",o).data,masks:l.data,count:h.dims[1]??0,maskHeight:l.dims[l.dims.length-2]??0,maskWidth:l.dims[l.dims.length-1]??0}}}),m={content:n,result:i};return t.push(m),t.length>yn&&t.shift(),i.catch(()=>{let a=t.indexOf(m);a>=0&&t.splice(a,1)}),i}instanceDecodeOptions(e,t){return{confidence:this.confidence,classes:this.classes,classNames:ke,transform:t,sourceWidth:e.width,sourceHeight:e.height,maskThreshold:this.maskThreshold,...this.featherRadius!==void 0?{featherRadius:this.featherRadius}:{}}}infer(e,t){let n=this._core.runQueue,o=(n.get(e)??Promise.resolve()).then(()=>this.inferNow(e,t),()=>this.inferNow(e,t)),i=o.catch(()=>{});return n.set(e,i),i.then(()=>{n.get(e)===i&&n.delete(e)}),o}async inferNow(e,t){let n=await this.session(e),s=oe[e],o=Pt(s.family,s.input),i=3*o.width*o.height,m=this._core.tensorScratch,a=m.get(e);(!a||a.length<i)&&(a=new Float32Array(i),m.set(e,a));let{tensor:c,transform:h}=Rt(t,o,a);return{outputs:await n.run({name:"input",data:c,dims:[1,3,o.height,o.width]}),transform:h}}session(e){let{sessions:t,store:n,provider:s}=this._core,o=t.get(e);return o||(o=n.ensure(e).then(i=>s.createSession(i)).catch(i=>{throw t.delete(e),n.evict(e),i}),t.set(e,o)),o}};function xn(r){let{data:e}=r,t=e.byteOffset%4===0?e.byteLength>>>2:0,n=new Uint32Array(e.buffer,e.byteOffset,t),s=2166136261,o=16777619^e.byteLength;for(let i=0;i<t;i++){let m=n[i];s=Math.imul(s^m,2654435761),o=Math.imul(o^m,2246822519)^s>>>15}for(let i=t*4;i<e.length;i++)s=Math.imul(s^e[i],2654435761);return`${r.width}x${r.height}:${(s>>>0).toString(36)}:${(o>>>0).toString(36)}`}function me(r,e,t){let n=r[e];if(!n)throw new Error(`Vision model '${t}' returned no '${e}' output (got: ${Object.keys(r).join(", ")||"none"}). Expected the ${oe[t].source}.`);return n}y();function $e(r){let e;for(let t of r){if(!e){e=t;continue}let n=Ht(t),s=Ht(e);n!==s?n&&(e=t):(n?t.area>e.area:t.detectionIndex<e.detectionIndex)&&(e=t)}return e}function Ht(r){return r.category.toLowerCase()==="person"}function Me(r){let{mask:e,width:t,height:n}=r,s=t,o=n,i=-1,m=-1;for(let a=0;a<n;a++){let c=a*t;for(let h=0;h<t;h++)e[c+h]!==0&&(h<s&&(s=h),h>i&&(i=h),a<o&&(o=a),a>m&&(m=a))}return i<0?null:{x0:s,y0:o,x1:i,y1:m}}function zt(r,e=.5,t=2){let n=$e(r);if(!n)return;let s=Me(n);if(!s)return n;let o=Pe(s),i=r.filter(c=>{if(c===n)return!1;let h=Me(c);return h!==null&&Pe(h)<=o*t&&kn(s,h)>=e});if(i.length===0)return n;let m=n.mask.slice();for(let c of i){let h=c.mask;for(let l=0;l<m.length;l++)h[l]>m[l]&&(m[l]=h[l])}let a=0;for(let c=0;c<m.length;c++)a+=m[c];return a=Math.round(a/255),{...n,mask:m,area:a,coverage:a/(n.width*n.height)}}function Pe(r){return(r.x1-r.x0+1)*(r.y1-r.y0+1)}function kn(r,e){let t=Math.min(r.x1,e.x1)-Math.max(r.x0,e.x0)+1,n=Math.min(r.y1,e.y1)-Math.max(r.y0,e.y0)+1;return t<=0||n<=0?0:t*n/Math.min(Pe(r),Pe(e))}y();y();var Re=class{width;height;fovRad;focalDistance;constructor(e){this.width=e.width,this.height=e.height;let t=e.fov??60;this.fovRad=t*Math.PI/180,this.focalDistance=e.cameraDistance??this.height/2/Math.tan(this.fovRad/2)}projectNormalizedLandmark(e,t=0){let n=e.x*this.width,s=e.y*this.height,o=e.z*this.width+t,i=Math.min(o,this.focalDistance-10),m=this.focalDistance/(this.focalDistance-i);return{x:n,y:s,z:o,scale:Math.max(.1,m)}}projectWorldLandmark(e,t=2,n=800){let s=this.width/2,o=this.height/2,i=e.x*n,m=e.y*n,a=(e.z+t)*n,c=Math.min(a,this.focalDistance-10),h=this.focalDistance/(this.focalDistance-c);return{x:s+i*h,y:o+m*h,z:a,scale:Math.max(.1,h)}}};y();function Ke(r){if(r.boundingBox&&r.boundingBox.width>0&&r.boundingBox.height>0)return{originX:r.boundingBox.originX,originY:r.boundingBox.originY,width:r.boundingBox.width,height:r.boundingBox.height};let e=1/0,t=1/0,n=-1/0,s=-1/0,o=0;for(let i of r.keypoints)i.visibility>.1&&(o++,i.x<e&&(e=i.x),i.y<t&&(t=i.y),i.x>n&&(n=i.x),i.y>s&&(s=i.y));return o===0||e>=n||t>=s?{originX:r.boundingBox?.originX??0,originY:r.boundingBox?.originY??0,width:r.boundingBox?.width??0,height:r.boundingBox?.height??0}:{originX:e,originY:t,width:n-e,height:s-t}}function Yt(r,e,t=.15){if(r.length===0)return[];let n=e.filter(a=>a.category.toLowerCase()==="person"&&a.active);if(n.length===0)return[...r];let s=[];for(let a=0;a<r.length;a++){let c=r[a];if(c.trackId!==void 0)continue;let h=Ke(c),l=h.width<=1.05&&h.height<=1.05;for(let p of n){let T=l&&p.boundingBox.normalizedWidth>0?{originX:p.boundingBox.normalizedX,originY:p.boundingBox.normalizedY,width:p.boundingBox.normalizedWidth,height:p.boundingBox.normalizedHeight}:p.boundingBox,j=ae(h,T);j>=t&&s.push({personIdx:a,trackId:p.trackId,iou:j})}}s.sort((a,c)=>c.iou-a.iou);let o=new Set,i=new Set,m=new Map;for(let a of s)o.has(a.personIdx)||i.has(a.trackId)||(o.add(a.personIdx),i.add(a.trackId),m.set(a.personIdx,a.trackId));return r.length===1&&n.length===1&&!m.has(0)&&r[0].trackId===void 0&&m.set(0,n[0].trackId),r.map((a,c)=>{if(a.trackId!==void 0)return a;let h=m.get(c);return h!==void 0?{...a,trackId:h}:a})}var Ce=class{objects;poseLandmarks;masks;segmentation;classes;poseLandmarksTensor;objectsTensor;masksTensor;histogramTensor;_totalFrames;_fps;_width;_height;_transformer;_stencilTexture;_poseCache=new Map;_objectCache=new Map;_maskCache=new Map;_matteCache=new Map;_poseLmCache=new Map;_trackCache=new Map;_categoryCache=new Map;_classCache=new Map;_maskTrackCache=new Map;_registeredSignals=new Set;constructor(e={}){this._totalFrames=e.totalFrames??120,this._fps=e.fps??24,this._width=e.width??1920,this._height=e.height??1080,this._transformer=new Re({width:this._width,height:this._height,fov:e.cameraFov??60});let t=this,n=(f,d)=>{let M=rt(f,d);return this._registeredSignals.add(M),M},s=f=>this.getPoseResult(f).people[0]?.keypoints??Ut(),o=(f,d)=>{let M=v=>s(v)[f]??{x:.5,y:.5,z:0},x=n(v=>M(v.frame).x,{fps:this._fps,label:`${d}_x`}),w=n(v=>M(v.frame).y,{fps:this._fps,label:`${d}_y`}),I=n(v=>M(v.frame).z??0,{fps:this._fps,label:`${d}_z`}),U=n(v=>this._transformer.projectNormalizedLandmark(M(v.frame)).x,{fps:this._fps,label:`${d}_screenX`}),C=n(v=>this._transformer.projectNormalizedLandmark(M(v.frame)).y,{fps:this._fps,label:`${d}_screenY`});return{x,y:w,z:I,screenX:U,screenY:C}},i=f=>{let d=this._poseLmCache.get(f);return d||(d=o(f,Ge[f]??`kpt_${f}`),this._poseLmCache.set(f,d)),d},m={nose:i(k.NOSE),leftEye:i(k.LEFT_EYE),rightEye:i(k.RIGHT_EYE),leftEar:i(k.LEFT_EAR),rightEar:i(k.RIGHT_EAR),shoulder:i(k.LEFT_SHOULDER),leftShoulder:i(k.LEFT_SHOULDER),rightShoulder:i(k.RIGHT_SHOULDER),leftElbow:i(k.LEFT_ELBOW),rightElbow:i(k.RIGHT_ELBOW),leftWrist:i(k.LEFT_WRIST),rightWrist:i(k.RIGHT_WRIST),leftHip:i(k.LEFT_HIP),rightHip:i(k.RIGHT_HIP),leftKnee:i(k.LEFT_KNEE),rightKnee:i(k.RIGHT_KNEE),leftAnkle:i(k.LEFT_ANKLE),rightAnkle:i(k.RIGHT_ANKLE),get:i};this.poseLandmarks=new Proxy(m,{get(f,d,M){return typeof d=="string"&&/^\d+$/.test(d)?f.get(Number(d)):typeof d=="number"?f.get(d):Reflect.get(f,d,M)}});let a=(f,d="unknown")=>({trackId:f,category:d,score:0,boundingBox:{originX:this._width/2,originY:this._height/2,width:0,height:0,normalizedX:.5,normalizedY:.5,normalizedWidth:0,normalizedHeight:0},centerX:this._width/2,centerY:this._height/2,normalizedCenterX:.5,normalizedCenterY:.5,velocity:{vx:0,vy:0},speed:0,age:0,hits:0,active:!1,isCoasting:!1}),c=(f,d)=>{let M=n(C=>f(C.frame).sx,{fps:this._fps,label:`${d}_screenX`}),x=n(C=>f(C.frame).sy,{fps:this._fps,label:`${d}_screenY`}),w=n(C=>this._width>0?f(C.frame).sx/this._width:0,{fps:this._fps,label:`${d}_x`}),I=n(C=>this._height>0?f(C.frame).sy/this._height:0,{fps:this._fps,label:`${d}_y`}),U=n(()=>0,{fps:this._fps,label:`${d}_z`});return{x:w,y:I,z:U,screenX:M,screenY:x}},h=(f,d,M)=>{let x=F=>{let O=t.getPoseResult(F);if(O.people.length===0)return;let D=f(F),$=M??D.trackId,N=O.people.find(K=>K.trackId===$);if(N)return N;if(!D.active&&O.people.length>1)return;if(O.people.length===1)return O.people[0];let X,q=.1;for(let K of O.people){let H=Ke(K),Q=H.width<=1.05&&H.height<=1.05&&D.boundingBox.normalizedWidth>0?{originX:D.boundingBox.normalizedX,originY:D.boundingBox.normalizedY,width:D.boundingBox.normalizedWidth,height:D.boundingBox.normalizedHeight}:D.boundingBox,Y=ae(H,Q);Y>q&&(q=Y,X=K)}return X},w=n(F=>x(F.frame)?1:0,{fps:this._fps,label:`${d}_hasPose`}),I=(F,O)=>{let D=H=>{let Q=x(H)?.keypoints[F];if(Q&&Q.visibility>.05)return{x:Q.x,y:Q.y,z:0};let Y=f(H);return{x:Y.normalizedCenterX,y:Y.normalizedCenterY,z:0}},$=n(H=>D(H.frame).x,{fps:this._fps,label:`${d}_${O}_x`}),N=n(H=>D(H.frame).y,{fps:this._fps,label:`${d}_${O}_y`}),X=n(H=>D(H.frame).z??0,{fps:this._fps,label:`${d}_${O}_z`}),q=n(H=>t._transformer.projectNormalizedLandmark(D(H.frame)).x,{fps:this._fps,label:`${d}_${O}_screenX`}),K=n(H=>t._transformer.projectNormalizedLandmark(D(H.frame)).y,{fps:this._fps,label:`${d}_${O}_screenY`});return{x:$,y:N,z:X,screenX:q,screenY:K}},U=new Map,C=F=>{let O=U.get(F);return O||(O=I(F,Ge[F]??`kpt_${F}`),U.set(F,O)),O},v=n(F=>{let O=F.frame,D=x(O);if(!D)return 0;let $=x(Math.max(0,O-1)),N=D.keypoints,X=$?.keypoints,q=N[k.RIGHT_WRIST],K=X?.[k.RIGHT_WRIST],H=0;if(q&&K&&q.visibility>.1&&K.visibility>.1){let re=(q.x-K.x)*this._width,B=(q.y-K.y)*this._height;H=Math.sqrt(re*re+B*B)*this._fps}let ne=N[k.LEFT_WRIST],Q=X?.[k.LEFT_WRIST],Y=0;if(ne&&Q&&ne.visibility>.1&&Q.visibility>.1){let re=(ne.x-Q.x)*this._width,B=(ne.y-Q.y)*this._height;Y=Math.sqrt(re*re+B*B)*this._fps}return Math.max(H,Y)},{fps:this._fps,label:`${d}_wristSpeed`}),u=n(F=>{let O=x(F.frame);if(!O)return 0;let D=O.keypoints,$=D[k.LEFT_WRIST],N=D[k.LEFT_SHOULDER],X=D[k.RIGHT_WRIST],q=D[k.RIGHT_SHOULDER],K=$&&N&&$.visibility>.1&&N.visibility>.1&&$.y<N.y,H=X&&q&&X.visibility>.1&&q.visibility>.1&&X.y<q.y;return K||H?1:0},{fps:this._fps,label:`${d}_handRaised`}),R=n(F=>{let O=x(F.frame);if(!O)return 0;let D=O.keypoints,$=D[k.LEFT_SHOULDER],N=D[k.RIGHT_SHOULDER],X=D[k.LEFT_HIP],q=D[k.RIGHT_HIP];if(!$||!N||!X||!q)return 0;let K=($.x+N.x)/2*this._width,H=($.y+N.y)/2*this._height,ne=(X.x+q.x)/2*this._width,Q=(X.y+q.y)/2*this._height,Y=K-ne,re=H-Q;return Y===0&&re===0?0:Math.atan2(Y,-re)},{fps:this._fps,label:`${d}_bodyTiltAngle`}),z={hasPose:w,wristSpeed:v,handRaised:u,bodyTiltAngle:R,nose:C(k.NOSE),leftEye:C(k.LEFT_EYE),rightEye:C(k.RIGHT_EYE),leftEar:C(k.LEFT_EAR),rightEar:C(k.RIGHT_EAR),shoulder:C(k.LEFT_SHOULDER),leftShoulder:C(k.LEFT_SHOULDER),rightShoulder:C(k.RIGHT_SHOULDER),leftElbow:C(k.LEFT_ELBOW),rightElbow:C(k.RIGHT_ELBOW),leftWrist:C(k.LEFT_WRIST),rightWrist:C(k.RIGHT_WRIST),leftHip:C(k.LEFT_HIP),rightHip:C(k.RIGHT_HIP),leftKnee:C(k.LEFT_KNEE),rightKnee:C(k.RIGHT_KNEE),leftAnkle:C(k.LEFT_ANKLE),rightAnkle:C(k.RIGHT_ANKLE),get:C};return new Proxy(z,{get(F,O,D){return typeof O=="string"&&/^\d+$/.test(O)?F.get(Number(O)):typeof O=="number"?F.get(O):Reflect.get(F,O,D)}})},l=(f,d,M,x)=>{let w=u=>f(u).boundingBox,I=h(f,`${d}_pose`,x),U=(u,R,z)=>c(F=>({sx:R(w(F)),sy:z(w(F))}),`${d}_${u}`),C=U("center",u=>u.originX+u.width/2,u=>u.originY+u.height/2),v=n(u=>f(u.frame).speed,{fps:this._fps,label:`${d}_speed`});return{get trackId(){return x??f(0).trackId},get category(){return M??f(0).category},bounds:{x:n(u=>w(u.frame).normalizedX,{fps:this._fps,label:`${d}_normX`}),y:n(u=>w(u.frame).normalizedY,{fps:this._fps,label:`${d}_normY`}),width:n(u=>w(u.frame).normalizedWidth,{fps:this._fps,label:`${d}_normWidth`}),height:n(u=>w(u.frame).normalizedHeight,{fps:this._fps,label:`${d}_normHeight`}),screenX:n(u=>w(u.frame).originX,{fps:this._fps,label:`${d}_screenX`}),screenY:n(u=>w(u.frame).originY,{fps:this._fps,label:`${d}_screenY`}),screenWidth:n(u=>w(u.frame).width,{fps:this._fps,label:`${d}_screenWidth`}),screenHeight:n(u=>w(u.frame).height,{fps:this._fps,label:`${d}_screenHeight`}),aspectRatio:n(u=>{let R=w(u.frame);return R.height>0?R.width/R.height:1},{fps:this._fps,label:`${d}_aspectRatio`}),area:n(u=>{let R=w(u.frame);return R.width*R.height},{fps:this._fps,label:`${d}_area`})},anchors:{topLeft:U("topLeft",u=>u.originX,u=>u.originY),topCenter:U("topCenter",u=>u.originX+u.width/2,u=>u.originY),topRight:U("topRight",u=>u.originX+u.width,u=>u.originY),centerLeft:U("centerLeft",u=>u.originX,u=>u.originY+u.height/2),center:C,centerRight:U("centerRight",u=>u.originX+u.width,u=>u.originY+u.height/2),bottomLeft:U("bottomLeft",u=>u.originX,u=>u.originY+u.height),bottomCenter:U("bottomCenter",u=>u.originX+u.width/2,u=>u.originY+u.height),bottomRight:U("bottomRight",u=>u.originX+u.width,u=>u.originY+u.height)},kinematics:{vx:n(u=>f(u.frame).velocity.vx,{fps:this._fps,label:`${d}_vx`}),vy:n(u=>f(u.frame).velocity.vy,{fps:this._fps,label:`${d}_vy`}),speed:v,acceleration:v.velocity(1),headingRad:n(u=>{let R=f(u.frame).velocity;return Math.atan2(R.vy,R.vx)},{fps:this._fps,label:`${d}_headingRad`}),headingDeg:n(u=>{let R=f(u.frame).velocity;return Math.atan2(R.vy,R.vx)*180/Math.PI},{fps:this._fps,label:`${d}_headingDeg`})},confidence:n(u=>f(u.frame).score,{fps:this._fps,label:`${d}_score`}),active:n(u=>f(u.frame).active?1:0,{fps:this._fps,label:`${d}_active`}),isCoasting:n(u=>f(u.frame).isCoasting?1:0,{fps:this._fps,label:`${d}_isCoasting`}),age:n(u=>f(u.frame).age,{fps:this._fps,label:`${d}_age`}),pose:I,center:C,topCenter:this.__pending,bottomCenter:C,topLeft:C,bottomLeft:C}},p=(f,d,M,x)=>{let w=l(f,d,M,x),I=w.anchors;return Object.assign(w,{topCenter:I.topCenter,bottomCenter:I.bottomCenter,topLeft:I.topLeft,bottomLeft:I.bottomLeft}),w},T=f=>{let d=this._trackCache.get(f);return d||(d=p(M=>this.getObjectResult(M).objects.find(x=>x.trackId===f)??a(f),`track_${f}`,void 0,f),this._trackCache.set(f,d)),d},j=(f,d=0)=>{let M=`${f.toLowerCase()}_${d}`,x=this._categoryCache.get(M);return x||(x=p(w=>this.getObjectResult(w).objects.filter(C=>C.category.toLowerCase()===f.toLowerCase()&&C.active)[d]??a(0,f),`cat_${f}_${d}`,f),this._categoryCache.set(M,x)),x},P=p(f=>{let d=this.getObjectResult(f);if(d.objects.length===0)return a(0);let M=d.objects[0];for(let x=1;x<d.objects.length;x++)d.objects[x].score>M.score&&(M=d.objects[x]);return M},"primary_object"),E=f=>{let d=new Set;for(let M of this.getObjectResult(f).objects)M.active&&d.add(M.category);return Array.from(d).sort()},g=f=>{let d=f.toLowerCase(),M=this._classCache.get(d);return M||(M={count:n(x=>this.getObjectResult(x.frame).objects.filter(w=>w.active&&w.category.toLowerCase()===d).length,{fps:this._fps,label:`class_${d}_count`}),maxConfidence:n(x=>{let w=0;for(let I of this.getObjectResult(x.frame).objects)I.active&&I.category.toLowerCase()===d&&I.score>w&&(w=I.score);return w},{fps:this._fps,label:`class_${d}_maxConf`}),present:n(x=>this.getObjectResult(x.frame).objects.some(w=>w.active&&w.category.toLowerCase()===d)?1:0,{fps:this._fps,label:`class_${d}_present`}),primary:j(f)},this._classCache.set(d,M),M)};this.classes={get:g,get names(){return E(te.value)},histogram:{get:f=>t.getClassHistogramTensor(f?.frame??te.value),get value(){return t.getClassHistogramTensor(te.value)}}},this.objects={get:T,byCategory:j,primary:P,count:n(f=>this.getObjectResult(f.frame).objects.filter(d=>d.active).length,{fps:this._fps,label:"tracked_objects_count"}),hasCategory:f=>g(f).present,getActiveTracks:f=>this.getObjectResult(f).objects.filter(d=>d.active),get detectedCategories(){return E(te.value)}};let _=(f,d)=>this.getMaskResult(f).find(M=>M.trackId===d),b=f=>$e(this.getMaskResult(f)),V=(f,d)=>{let M=x=>{let w=f(x);if(!(!w||w.trackId===void 0))return this.getObjectResult(x).objects.find(I=>I.trackId===w.trackId)};return{get trackId(){return f(te.value)?.trackId??0},get category(){return f(te.value)?.category??"unknown"},area:n(x=>f(x.frame)?.area??0,{fps:this._fps,label:`${d}_area`}),coverage:n(x=>f(x.frame)?.coverage??0,{fps:this._fps,label:`${d}_coverage`}),solidity:n(x=>{let w=f(x.frame),I=M(x.frame);if(!w||!I)return 0;let U=I.boundingBox.width*I.boundingBox.height;return U>0?w.area/U:0},{fps:this._fps,label:`${d}_solidity`}),bboxFill:n(x=>{let w=f(x.frame);if(!w||w.width*w.height===0)return 0;let I=M(x.frame);return I?I.boundingBox.width*I.boundingBox.height/(w.width*w.height):0},{fps:this._fps,label:`${d}_bboxFill`})}};this.masks={get:f=>{let d=this._maskTrackCache.get(f);return d||(d=V(M=>_(M,f),`mask_${f}`),this._maskTrackCache.set(f,d)),d},subject:V(b,"subject"),count:n(f=>new Set(this.getMaskResult(f.frame).map(d=>d.trackId??-1)).size,{fps:this._fps,label:"mask_count"})},this.segmentation={humanSilhouette:this.masks.subject,subject:this.masks.subject,instanceMasks:this.masks,matte:{coverage:n(f=>t.getMatteResult(f.frame)?.coverage??0,{fps:this._fps,label:"matte_coverage"}),at:f=>t.getMatteResult(f)},get stencilTexture(){return t._stencilTexture}},this.poseLandmarksTensor={get:f=>t.getPoseLandmarksTensor(f?.frame??te.value),get value(){return t.getPoseLandmarksTensor(te.value)}},this.objectsTensor={get:f=>t.getObjectsTensor(f?.frame??te.value),get value(){return t.getObjectsTensor(te.value)}},this.masksTensor={get:f=>t.getMasksTensor(f?.frame??te.value),get value(){return t.getMasksTensor(te.value)}},this.histogramTensor={get:f=>t.getClassHistogramTensor(f?.frame??te.value),get value(){return t.getClassHistogramTensor(te.value)}}}setStencilTexture(e){this._stencilTexture=e}get stencilTexture(){return this._stencilTexture}latestAtOrBefore(e,t,n=8){let s=this.clamp(t),o=Math.max(0,s-n);for(let i=s;i>=o;i--){let m=e.get(i);if(m!==void 0)return m}}invalidateSignals(){for(let e of this._registeredSignals)e.invalidate()}setPoseResult(e,t){this._poseCache.set(this.clamp(e),t),this.invalidateSignals()}getPoseResult(e){return this.latestAtOrBefore(this._poseCache,e)??Ft()}setObjectResult(e,t){let n="objects"in t?t:{objects:t,rawDetections:[]};this._objectCache.set(this.clamp(e),{objects:n.objects,rawDetections:n.rawDetections??[]}),this.invalidateSignals()}getObjectResult(e){return this.latestAtOrBefore(this._objectCache,e)??Bt()}setMaskResult(e,t){this._maskCache.set(this.clamp(e),t),this.invalidateSignals()}getMaskResult(e){return this.latestAtOrBefore(this._maskCache,e)??[]}setMatteResult(e,t){this._matteCache.set(this.clamp(e),t),this.invalidateSignals()}getMatteResult(e){return this.latestAtOrBefore(this._matteCache,e)}summary(e=te.value){let t=this.clamp(e),n=this.getObjectResult(t),s=n.objects.map(m=>({trackId:m.trackId,category:m.category,score:m.score,center:[m.centerX,m.centerY],speed:m.speed,active:m.active})),o=new Set;for(let m of n.objects)m.active&&o.add(m.category);let i={};for(let m of this.getMaskResult(t))i[m.category]=(i[m.category]??0)+1;return{frame:t,objects:s,classes:Array.from(o).sort(),masks:i}}getPoseLandmarksTensor(e){let n=this.getPoseResult(e).people[0]?.keypoints??[],s=new Float32Array(51);for(let o=0;o<17;o++)s[o*3]=n[o]?.x??.5,s[o*3+1]=n[o]?.y??.5,s[o*3+2]=n[o]?.visibility??0;return{data:s,shape:[17,3],dtype:"float32"}}getObjectsTensor(e,t=16){let n=this.getObjectResult(e),s=new Float32Array(t*8),o=Math.min(t,n.objects.length);for(let i=0;i<o;i++){let m=n.objects[i],a=i*8,c=0;for(let h=0;h<m.category.length;h++)c=c*31+m.category.charCodeAt(h)&65535;s[a]=m.active?1:0,s[a+1]=c,s[a+2]=m.centerX,s[a+3]=m.centerY,s[a+4]=m.boundingBox.width,s[a+5]=m.boundingBox.height,s[a+6]=m.velocity.vx,s[a+7]=m.velocity.vy}return{data:s,shape:[t,8],dtype:"float32"}}getMasksTensor(e,t=16){let n=this.getMaskResult(e),s=new Float32Array(t*2),o=Math.min(t,n.length);for(let i=0;i<o;i++){let m=n[i];s[i*2]=m.coverage;let a=this.getObjectResult(e).objects.find(h=>h.trackId===m.trackId),c=a?a.boundingBox.width*a.boundingBox.height:0;s[i*2+1]=c>0?m.area/c:0}return{data:s,shape:[t,2],dtype:"float32"}}getClassHistogramTensor(e,t=80){let n=new Float32Array(t);for(let s of this.getObjectResult(e).objects)if(s.active){let o=Tn.get(s.category.toLowerCase());o!==void 0&&(n[o]+=1)}return{data:n,shape:[t],dtype:"float32"}}clamp(e){return Math.max(0,Math.min(this._totalFrames-1,Math.round(e)))}};var Tn=new Map(ke.map((r,e)=>[r,e]));y();function Nt(r,e,t={}){let n=t.offsetX??0,s=t.offsetY??0,o=t.offsetZ??0;if(!e||typeof e!="object")return r;if("screenX"in e&&e.screenX&&typeof e.screenX=="object"){let i=e;r.x=n!==0?i.screenX.add(n):i.screenX,r.y=s!==0?i.screenY.add(s):i.screenY,r.z=o!==0?i.z.add(o):i.z}else if("x"in e&&typeof e.x=="object"&&e.x!==null){let i=e;r.x=n!==0?i.x.add(n):i.x,r.y=s!==0?i.y.add(s):i.y,r.z=o!==0?i.z.add(o):i.z}else{let i=e;r.x=(i.screenX??i.x)+n,r.y=(i.screenY??i.y)+s,r.z=(i.z??0)+o}return r}function as(r,e,t={}){if(!e||typeof e!="object")return r;if("anchors"in e&&e.anchors){let n=e,s=t.anchor??(t.matchWidth||t.matchHeight?"topLeft":"center"),o=n.anchors[s]??n.center,i=o;return t.smoothFrames&&t.smoothFrames>1&&(i={x:o.x.smooth(t.smoothFrames),y:o.y.smooth(t.smoothFrames),z:o.z,screenX:o.screenX.smooth(t.smoothFrames),screenY:o.screenY.smooth(t.smoothFrames)}),t.matchWidth&&(r.width=t.smoothFrames&&t.smoothFrames>1?n.bounds.screenWidth.smooth(t.smoothFrames):n.bounds.screenWidth),t.matchHeight&&(r.height=t.smoothFrames&&t.smoothFrames>1?n.bounds.screenHeight.smooth(t.smoothFrames):n.bounds.screenHeight),t.hideWhenLost&&(r.opacity=n.active),Nt(r,i,t)}return Nt(r,e,t)}y();function Sn(r){let e=[];return r.enableDetection===!0&&e.push("detect"),r.enableSegmentation===!0&&e.push("segment"),r.enablePose===!0&&e.push("pose"),r.enableMatte===!0&&e.push("matte"),e.length>0?e:["detect"]}var We=class r{id;kind="vision";source;config;vision;_runner;_runnerOptions;constructor(e,t={},n={},s={}){this.id=`vision-${Math.random().toString(36).slice(2,9)}`,this.source=e,this.config=t,this._runnerOptions=s,this.vision=new Ce({...n,config:t})}runner(){if(!this._runner){let{variant:e,confidence:t,classes:n,modelsDir:s,baseUrl:o,maskThreshold:i,featherRadius:m}=this.config;this._runner=fe.create({...this._runnerOptions,...e!==void 0?{variant:e}:{},...t!==void 0?{confidence:t}:{},...n!==void 0?{classes:n}:{},...s!==void 0?{modelsDir:s}:{},...o!==void 0?{baseUrl:o}:{},...i!==void 0?{maskThreshold:i}:{},...m!==void 0?{featherRadius:m}:{}})}return this._runner}async ready(){let e=this.runner();return await e.preload(Sn(this.config)),e}close(){this._runner?.close(),this._runner=void 0}static attach(e,t={},n={}){let s=new r(e,t,n),o=s.vision;return Object.defineProperties(o,{node:{value:s.toNode(),enumerable:!0},ready:{value:()=>s.ready()},runner:{value:()=>s.runner()},close:{value:()=>s.close()}}),o}toNode(){return{id:this.id,kind:"vision",source:this.source,config:this.config}}};y();var qe=new Uint8Array(0),Xt=new Uint32Array(0);function _n(r,e,t){qe.length<r.length&&(qe=new Uint8Array(r.length),Xt=new Uint32Array(r.length));let n=qe,s=Xt,o=0,i=0;for(let m=1;m<=r.length;m++)(m===r.length||r[m]!==r[i])&&(n[o]=r[i],s[o]=m-i,o++,i=m);return{width:e,height:t,values:n.slice(0,o),lengths:s.slice(0,o)}}function wn(r){let e=new Uint8Array(r.width*r.height),t=0;for(let n=0;n<r.values.length;n++){let s=t+r.lengths[n];r.values[n]!==0&&e.fill(r.values[n],t,s),t=s}return e}function Gt(r){return r.values.byteLength+r.lengths.byteLength}function Qe(r){let{mask:e,...t}=r;return{...t,rle:_n(e,r.width,r.height)}}function Je(r){let{rle:e,...t}=r;return{...t,mask:wn(e)}}function Ze(r){let e=512+r.detections.length*128+r.objects.length*256;for(let t of r.masks??[])e+=Gt(t.rle);return r.subject&&(e+=Gt(r.subject.mask.rle)),e}var Oe=class{constructor(e=256*1024*1024){this.maxBytes=e}maxBytes;entries=new Map;bytes=0;get(e,t){let n=`${e}#${t}`,s=this.entries.get(n);return s&&(this.entries.delete(n),this.entries.set(n,s)),s}set(e,t,n){let s=`${e}#${t}`,o=this.entries.get(s);o&&(this.bytes-=Ze(o),this.entries.delete(s)),this.entries.set(s,n),this.bytes+=Ze(n);for(let[i,m]of this.entries){if(this.bytes<=this.maxBytes)break;this.entries.delete(i),this.bytes-=Ze(m)}}clear(){this.entries.clear(),this.bytes=0}get size(){return this.entries.size}};y();var vn=`
61
+ struct Params {
62
+ mode: u32, // 0 matte, 1 mask, 2 crop
63
+ _pad: u32,
64
+ cropMin: vec2<f32>, // uv of the subject bounds (crop)
65
+ cropMax: vec2<f32>,
66
+ _pad2: vec2<f32>,
67
+ };
68
+
69
+ @group(0) @binding(0) var<uniform> params: Params;
70
+ @group(0) @binding(1) var picture: texture_2d<f32>;
71
+ @group(0) @binding(2) var mask: texture_2d<f32>;
72
+ @group(0) @binding(3) var samp: sampler;
73
+
74
+ struct VSOut {
75
+ @builtin(position) pos: vec4<f32>,
76
+ @location(0) uv: vec2<f32>,
77
+ };
78
+
79
+ @vertex fn vs(@builtin(vertex_index) i: u32) -> VSOut {
80
+ var p = array<vec2<f32>, 3>(vec2(-1.0, -1.0), vec2(3.0, -1.0), vec2(-1.0, 3.0));
81
+ var out: VSOut;
82
+ out.pos = vec4(p[i], 0.0, 1.0);
83
+ out.uv = vec2(p[i].x * 0.5 + 0.5, 0.5 - p[i].y * 0.5);
84
+ return out;
85
+ }
86
+
87
+ @fragment fn fs(in: VSOut) -> @location(0) vec4<f32> {
88
+ var uv = in.uv;
89
+ if (params.mode == 2u) {
90
+ uv = mix(params.cropMin, params.cropMax, uv);
91
+ }
92
+ let m = textureSampleLevel(mask, samp, uv, 0.0).r;
93
+ if (params.mode == 1u) {
94
+ return vec4(m, m, m, 1.0);
95
+ }
96
+ return textureSampleLevel(picture, samp, uv, 0.0) * m;
97
+ }
98
+ `,Ie=class{constructor(e,t){this.device=e;let n=e.createShaderModule({label:"vision_matte_composite",code:vn});this.pipeline=e.createRenderPipeline({label:"vision_matte_composite",layout:"auto",vertex:{module:n,entryPoint:"vs"},fragment:{module:n,entryPoint:"fs",targets:[{format:t}]},primitive:{topology:"triangle-list"}}),this.sampler=e.createSampler({magFilter:"linear",minFilter:"linear"})}device;pipeline;sampler;uniforms=[];uniformIndex=0;masks=new Map;uploadMask(e,t,n,s){let o=this.masks.get(e);(!o||o.width!==n||o.height!==s)&&(o?.destroy(),o=this.device.createTexture({label:`vision_mask_${e}`,size:[n,s],format:"r8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST}),this.masks.set(e,o));let i=Math.ceil(n/256)*256,m=t;if(i!==n){m=new Uint8Array(i*s);for(let a=0;a<s;a++)m.set(t.subarray(a*n,(a+1)*n),a*i)}return this.device.queue.writeTexture({texture:o},m.buffer,{offset:m.byteOffset,bytesPerRow:i,rowsPerImage:s},{width:n,height:s}),o}draw(e,t,n,s,o,i){let m=s.width,a=s.height,c=new Float32Array(8),h=new Uint32Array(c.buffer);h[0]=o==="matte"?0:o==="mask"?1:2,o==="crop"&&i?(c[2]=i.x0/m,c[3]=i.y0/a,c[4]=(i.x1+1)/m,c[5]=(i.y1+1)/a):(c[2]=0,c[3]=0,c[4]=1,c[5]=1,o==="crop"&&(h[0]=0)),this.uniformIndex>=this.uniforms.length&&this.uniforms.push(this.device.createBuffer({size:c.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}));let l=this.uniforms[this.uniformIndex];this.uniformIndex=(this.uniformIndex+1)%16,this.device.queue.writeBuffer(l,0,c);let p=this.device.createBindGroup({layout:this.pipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:l}},{binding:1,resource:n.createView()},{binding:2,resource:s.createView()},{binding:3,resource:this.sampler}]}),T=e.beginRenderPass({label:"vision_matte_composite",colorAttachments:[{view:t,loadOp:"clear",storeOp:"store",clearValue:{r:0,g:0,b:0,a:0}}]});T.setPipeline(this.pipeline),T.setBindGroup(0,p),T.draw(3),T.end()}};var pe=new Map,Mn=4,et=null,Le=null,$t=null,Kt=new Oe,Wt=new Map,Pn=new Map,Rn=new Map,qt=new Map,tt=new WeakMap,de=new Map,nt=new Map,Cn=3;function Zt(r,e,t,n,s,o){let i=r.get(t);return(!i||i.width!==n.width||i.height!==n.height||i.format!==n.format)&&(i?.destroy(),i=e.createTexture({size:[n.width,n.height],format:n.format,usage:s,label:o}),r.set(t,i)),i}var On=(r,e,t)=>Zt(Pn,r,e,t,GPUTextureUsage.COPY_DST|GPUTextureUsage.TEXTURE_BINDING,"vision_held_frame"),In=(r,e,t)=>Zt(Rn,r,e,t,GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC,"vision_matte");function Ln(r,e,t,n,s){let o=e;return JSON.stringify([r,o?.operation?.id??o?.id??null,n,s,t.mode??"passthrough",t.variant,t.confidence,t.classes,t.maskThreshold,t.featherRadius,t.matteSource,t.keyBackground===!0,t.maxMissedFrames])}function En(r,e,t){let n=r.backgroundKeyThreshold;return typeof n=="number"?n:typeof n?.get=="function"?Number(n.get({frame:e,fps:t})):typeof n?._value=="number"?Number(n._value):70}function jn(r,e,t){if(r)return nt.set(e,{mask:r,frame:t}),r;let n=nt.get(e);if(n&&t-n.frame<=Cn)return n.mask}function Vn(r){let e={variant:r.variant,modelsDir:r.modelsDir,baseUrl:r.baseUrl},t=JSON.stringify(e),n=pe.get(t);if(!n){if(pe.size>=Mn){let[m,a]=pe.entries().next().value;a.runner.close(),pe.delete(m)}n={runner:fe.create(e),derived:new Map},pe.set(t,n)}let s={confidence:r.confidence,classes:r.classes,maskThreshold:r.maskThreshold,featherRadius:r.featherRadius},o=JSON.stringify(s),i=n.derived.get(o);return i||(i=n.runner.derive(s),n.derived.set(o,i)),i}function An(r,e){let t=qt.get(r);return t||(t=new ue({maxMissedFrames:e.maxMissedFrames??15}),qt.set(r,t)),t}function Dn(r,e,t){return e<=0||t<=0?r:{people:r.people.map(n=>({...n,keypoints:n.keypoints.map(s=>({x:s.x/e,y:s.y/t,visibility:s.visibility}))}))}}function Bn(r,e){return r.map(t=>{let{cx:n,cy:s}=zn(t),o=null;for(let i of e){let m=i.centerX-n,a=i.centerY-s,c=m*m+a*a;(!o||c<o.distance)&&(o={trackId:i.trackId,distance:c})}return o?{...t,trackId:o.trackId}:t})}function Fn(r,e,t){let n=e*t,s=new Uint8Array(n),o=new Int32Array(n),i=0,m=c=>{s[c]||r[c]>0||(s[c]=1,o[i++]=c)};for(let c=0;c<e;c++)m(c),m((t-1)*e+c);for(let c=0;c<t;c++)m(c*e),m(c*e+e-1);let a=0;for(;a<i;){let c=o[a++],h=c%e,l=c+1;h+1<e&&!s[l]&&r[l]===0&&(s[l]=1,o[i++]=l),l=c-1,h>0&&!s[l]&&r[l]===0&&(s[l]=1,o[i++]=l),l=c+e,l<n&&!s[l]&&r[l]===0&&(s[l]=1,o[i++]=l),l=c-e,l>=0&&!s[l]&&r[l]===0&&(s[l]=1,o[i++]=l)}for(let c=0;c<n;c++)r[c]===0&&s[c]===0&&(r[c]=255)}function Un(r,e,t,n=2){if(n<=0)return r;let s=new Uint8Array(e*t),o=new Uint8Array(e*t),i=2*n+1;for(let a=0;a<t;a++){let c=a*e,h=0;for(let l=-n;l<=n;l++){let p=Math.max(0,Math.min(e-1,l));h+=r[c+p]}for(let l=0;l<e;l++){s[c+l]=Math.round(h/i);let p=Math.max(0,l-n),T=Math.min(e-1,l+n+1);h+=r[c+T]-r[c+p]}}let m=new Float64Array(e);for(let a=-n;a<=n;a++){let c=Math.max(0,Math.min(t-1,a))*e;for(let h=0;h<e;h++)m[h]+=s[c+h]}for(let a=0;a<t;a++){let c=a*e,h=Math.max(0,a-n)*e,l=Math.min(t-1,a+n+1)*e;for(let p=0;p<e;p++)o[c+p]=Math.round(m[p]/i),m[p]+=s[l+p]-s[h+p]}return o}function Hn(r,e,t,n,s,o){let i=0,m=0,a=0,c=0,h=(g,_)=>{let b=_*e+g;if(r[b])return;let V=b*4;i+=n[V],m+=n[V+1],a+=n[V+2],c++};for(let g=0;g<e;g+=4)h(g,0),h(g,t-1);for(let g=0;g<t;g+=4)h(0,g),h(e-1,g);if(c===0)return r;i/=c,m/=c,a/=c;let l=e*t,p=new Uint8Array(l);for(let g=0,_=0;g<l;g++,_+=4)p[g]=Math.max(Math.abs(n[_]-i),Math.abs(n[_+1]-m),Math.abs(n[_+2]-a))>s?1:0;let T=new Int32Array(l),j=0;for(let g=0;g<l;g++)r[g]>0&&(p[g]&&(r[g]=255),T[j++]=g);let P=0;for(;P<j;){let g=T[P++],_=g%e,b=g+1;_+1<e&&r[b]!==255&&p[b]&&(r[b]=255,T[j++]=b),b=g-1,_>0&&r[b]!==255&&p[b]&&(r[b]=255,T[j++]=b),b=g+e,b<l&&r[b]!==255&&p[b]&&(r[b]=255,T[j++]=b),b=g-e,b>=0&&r[b]!==255&&p[b]&&(r[b]=255,T[j++]=b)}Fn(r,e,t);let E=o!==void 0&&o>0?Math.max(1,Math.min(8,Math.round(o*50))):2;return Un(r,e,t,E)}function zn(r){let{mask:e,width:t,height:n}=r,s=0,o=0,i=0;for(let m=0;m<n;m++){let a=m*t;for(let c=0;c<t;c++)e[a+c]>0&&(s+=c,o+=m,i++)}return i===0?{cx:0,cy:0}:{cx:s/i,cy:o/i}}var Qt=async r=>{let{ctx:e,encoder:t,pass:n,targetView:s,targetWidth:o,targetHeight:i,props:m,drawChild:a}=r,{virtualMedia:c}=m,h=c?.operation;if(h?.op!=="Vision")return;let l=h;n.end();let p=c?.children?.[0];if(!p)return;let T=l.effect,j=T!=null,P=c?.id??h?.id??`${o}x${i}_${l.mode}_${l.variant}_${l.keyBackground}_${l.backgroundKeyThreshold}`,E=`vision-${P}`,g=j?tt.get(T):de.get(E);g&&(g.width!==o||g.height!==i)&&(g.destroy(),g=void 0,j?tt.delete(T):de.delete(E));let _=g!==void 0;if(!g&&(g=e.device.createTexture({size:[o,i],format:e.renderer.format,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC,label:"vision_child_persistent"}),j?tt.set(T,g):de.set(E,g),de.size>4)){let B=de.keys().next().value;B&&B!==E&&(de.get(B)?.destroy(),de.delete(B))}let b=m.frame??0,V=m.compositionFrame??b,f=m.fps??24,d=l.mode??"passthrough",M=d==="mask"||d==="matte"||d==="crop",x=l.visionBundle??c.visionBundle,w=l.enableDetection!==!1||d==="boxes"||d==="tracking",I=l.enableSegmentation===!0||M&&l.matteSource!=="selfie",U=l.enableMatte===!0||M&&l.matteSource==="selfie",C=l.enablePose===!0||d==="skeleton",v=!U&&!C&&(w||I),u=v?Ln(P,p,l,o,i):"",R=B=>l.keyBackground===!0?En(l,V-(b-B),f):void 0,z=B=>{if(!v||B===void 0)return;let G=Kt.get(u,B);if(!(!G||G.keyThreshold!==R(B))&&!(I&&x&&!G.masks))return G},F=_?Wt.get(P):void 0,O=z(b),D=O!==void 0;O||(O=z(F));let $;M&&_&&!D&&($=On(e.device,P,g),t.copyTextureToTexture({texture:g},{texture:$},[o,i,1]));let N=null;if(_&&!O){let G=o*4,Z=Math.ceil(G/256)*256,J=Z*i,ee=e.device.createBuffer({size:J,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ,label:"vision_frame_staging"}),W=e.device.createCommandEncoder({label:"vision_readback_encoder"});W.copyTextureToBuffer({texture:g},{buffer:ee,bytesPerRow:Z,rowsPerImage:i},[o,i,1]),e.device.queue.submit([W.finish()]),await ee.mapAsync(GPUMapMode.READ);let he=new Uint8Array(ee.getMappedRange());if(N=new Uint8ClampedArray(o*i*4),Z===G)N.set(he.subarray(0,N.length));else for(let ge=0;ge<i;ge++)N.set(he.subarray(ge*Z,ge*Z+G),ge*G);ee.unmap(),ee.destroy()}let X=g.createView();e.renderer.beginFrame(t,X,{r:0,g:0,b:0,a:0},o,i,"clear").end(),await a(p,{...m},X,g,o,i),Wt.set(P,b);let K=[],H=[],ne,Q,Y;if(O)K=O.objects,w&&x?.setObjectResult(b,{objects:O.objects,rawDetections:O.detections}),I&&x&&O.masks&&(H=O.masks.map(Je),x.setMaskResult(b,H)),O.subject&&(Y=Je(O.subject.mask),nt.set(P,{mask:Y,frame:b}));else if(N){let B=Vn(l),G={data:N,width:o,height:i},Z=[];if(w){Z=await B.detect(G);let J=An(P,l);b===0&&J.reset(),K=J.update(Z,b,f),x?.setObjectResult(b,{objects:K,rawDetections:Z})}if(I){let J=await B.segment(G);H=Bn(J.masks,K),x?.setMaskResult(b,H)}if(U&&(ne=await B.matte(G),x?.setMatteResult(b,ne)),C){let J=await B.pose(G),ee=Dn(J,G.width,G.height);Q={people:Yt(ee.people,K)},x?.setPoseResult(b,Q)}if(M){Y=jn(l.matteSource==="selfie"?Yn(ne):zt(H.length>0?H:x?.getMaskResult(b)??[]),P,b);let J=R(F??b);Y&&J!==void 0&&(Y={...Y,mask:Hn(Y.mask,Y.width,Y.height,N,J,l.featherRadius)})}v&&F!==void 0&&Kt.set(u,F,{detections:Z,objects:K,masks:x?H.map(Qe):null,subject:Y?{mask:Qe(Y)}:null,keyThreshold:R(F)})}if(M){let B=D?g:$;if(!Y||!B){e.renderer.beginFrame(t,s,{r:0,g:0,b:0,a:0},o,i,"clear").end();return}(!Le||$t!==e.renderer.format)&&(Le=new Ie(e.device,e.renderer.format),$t=e.renderer.format);let G=Le.uploadMask(P,Y.mask,Y.width,Y.height),Z=In(e.device,P,g);Le.draw(t,Z.createView(),B,G,d,d==="crop"?Me(Y)??void 0:void 0),x?.setStencilTexture(Z);let J=e.renderer.beginFrame(t,s,{r:0,g:0,b:0,a:0},o,i,"clear");e.renderer.drawTexture(J,Z,{x:0,y:0,width:o,height:i}),J.end();return}if(d==="skeleton"){et||(et=new _e(e.device));let G=(x?.getPoseResult(b)??Q)?.people[0];if(G&&G.keypoints.length>0){let Z=et.renderToTexture(G.keypoints,{width:o,height:i}),J=e.renderer.beginFrame(t,s,{r:0,g:0,b:0,a:0},o,i,"clear");e.renderer.drawTexture(J,Z,{x:0,y:0,width:o,height:i}),J.end();return}}if(d==="boxes"||d==="tracking"){let B=e.renderer.beginFrame(t,s,{r:0,g:0,b:0,a:0},o,i,"clear");e.renderer.drawTexture(B,g,{x:0,y:0,width:o,height:i});let G=K.length>0?K:x?.getObjectResult(b).objects??[];if(G.length>0){let Z="#38bdf8";for(let ee of G){if(!ee.active)continue;let W=ee.boundingBox;e.renderer.drawRect(B,{x:W.originX,y:W.originY,width:W.width,height:2},Z),e.renderer.drawRect(B,{x:W.originX,y:W.originY+W.height-2,width:W.width,height:2},Z),e.renderer.drawRect(B,{x:W.originX,y:W.originY,width:2,height:W.height},Z),e.renderer.drawRect(B,{x:W.originX+W.width-2,y:W.originY,width:2,height:W.height},Z);let he=Math.min(16,W.width/4,W.height/4);e.renderer.drawRect(B,{x:W.originX,y:W.originY,width:he,height:4},"#ffffff"),e.renderer.drawRect(B,{x:W.originX,y:W.originY,width:4,height:he},"#ffffff"),d==="tracking"&&e.renderer.drawRect(B,{x:ee.centerX-3,y:ee.centerY-3,width:6,height:6},"#ef4444",3)}}B.end();return}let re=e.renderer.beginFrame(t,s,{r:0,g:0,b:0,a:0},o,i,"clear");e.renderer.drawTexture(re,g,{x:0,y:0,width:o,height:i}),re.end()};function Yn(r){if(!r||r.coverage<=0)return;let e=Math.round(r.coverage*r.width*r.height);return{category:"person",mask:r.mask,width:r.width,height:r.height,area:e,coverage:r.coverage,detectionIndex:-1}}var Ws=st({WebGPURenderer:Qt});export{ht as a,gt as b,pt as c,tr as d,tn as e,sr as f,cr as g,mr as h,fr as i,nn as j,Tt as k,kt as l,pr as m,rn as n,on as o,sn as p,an as q,cn as r,ln as s,De as t,St as u,dn as v,Be as w,Or as x,_t as y,Ar as z,Dr as A,Ur as B,Se as C,ke as D,ue as E,Wr as F,k as G,Ge as H,Et as I,_e as J,jt as K,At as L,fe as M,Re as N,Ce as O,Nt as P,as as Q,We as R,Ws as S};
@@ -1,4 +1,4 @@
1
- import{a as ot}from"./chunk-LKYN3BM2.mjs";import{o as Ut,p as C,q as T,r as Mt}from"./chunk-RQLMW6MA.mjs";import{c as yt,d as xt,e as $}from"./chunk-VRGREB3V.mjs";import{a as St,b as it,d as wt,e as A}from"./chunk-XETMNJVV.mjs";import{a as vt,b as bt}from"./chunk-ATLWPS6N.mjs";import{e as O,s as G,t as M,v as Gt}from"./chunk-LQENNFBA.mjs";import{a as D,b as gt}from"./chunk-IQC2I5A5.mjs";import{d as Pt}from"./chunk-HYBAPT6I.mjs";import{e as x}from"./chunk-BVF64D6H.mjs";x();var E=class{constructor(t,e){this.url=t;this.isHeadless=e}url;isHeadless;input=null;initPromise=null;iterator=null;iteratorStartTimestamp=-1;currentFetchId=0;fetchLock=Promise.resolve();destroyed=!1;async init(){if(!this.input)return this.initPromise?this.initPromise:(this.destroyed=!1,this.initPromise=(async()=>{try{let t=await A.acquire(this.url);this.destroyed?A.release(this.url):this.input=t}catch(t){throw this.initPromise=null,t}})(),this.initPromise)}destroy(){this.destroyed=!0,this.iterator?.return(),this.input&&(A.release(this.url),this.input=null),this.initPromise=null,this.onDestroy()}},st=class extends E{canvasSink=null;videoSampleSink=null;currentFrame=null;nextFrame=null;currentSample=null;nextSample=null;headlessQueue=[];isDecoding=!1;decodeBuffer=null;nextRequest=null;pushHeadlessQueue(t){let e=this.headlessQueue.findIndex(r=>r.timestamp>t.timestamp);e===-1?this.headlessQueue.push(t):this.headlessQueue.splice(e,0,t)}async fillHeadlessQueue(t){if(this.iterator)for(;this.headlessQueue.length<2;){let e=await this.iterator.next();if(this.currentFetchId!==t){e.value?.close?.();return}if(e.done||!e.value)break;this.pushHeadlessQueue(e.value)}}async closeIterator(t){if(t)try{await t.return()}catch{}}resetSinks(){let t=this.iterator;if(this.iterator=null,t)try{t.return()}catch{}this.canvasSink=null,this.videoSampleSink=null,this.currentFrame=null,this.nextFrame=null,this.currentSample?.close(),this.currentSample=null,this.nextSample?.close(),this.nextSample=null;for(let e of this.headlessQueue)try{e.close()}catch{}this.headlessQueue=[],this.decodeBuffer=null,this.iteratorStartTimestamp=-1}onDestroy(){this.resetSinks()}async startIterator(t,e){if(!this.canvasSink)return;let r=Math.max(0,Number.isFinite(t)?t:0),i=this.iterator;if(this.iterator=null,await this.closeIterator(i),this.currentFetchId!==e||this.destroyed)return;this.iterator=this.canvasSink.canvases(r);let n=await this.iterator.next();if(this.currentFetchId!==e||this.destroyed)return;this.currentFrame=n.value??null;let s=await this.iterator.next();this.currentFetchId!==e||this.destroyed||(this.nextFrame=s.value??null,this.iteratorStartTimestamp=r)}async startIteratorHeadless(t,e){if(!this.videoSampleSink)return;let r=Math.max(0,Number.isFinite(t)?t:0),i=this.iterator;if(this.iterator=null,await this.closeIterator(i),this.currentFetchId!==e||this.destroyed)return;for(let s of this.headlessQueue)s.close();this.headlessQueue=[];let n=Math.max(0,r-.1);this.iterator=this.videoSampleSink.samples(n),await this.fillHeadlessQueue(e),!(this.currentFetchId!==e||this.destroyed)&&(this.iteratorStartTimestamp=r)}async getFrame(t){if(await this.init(),this.destroyed||!this.input)return null;let e=Math.max(0,Number.isFinite(t)?t:0);return this.isDecoding?(this.nextRequest&&this.nextRequest.resolve(null),new Promise((r,i)=>{this.nextRequest={timestampSec:e,resolve:r,reject:i}})):this.executeDecode(e)}async executeDecode(t){this.isDecoding=!0;try{return await this.performDecode(t)}finally{if(this.isDecoding=!1,this.nextRequest){let e=this.nextRequest;this.nextRequest=null,this.executeDecode(e.timestampSec).then(e.resolve).catch(e.reject)}}}async performDecodeHeadless(t,e){if(!this.videoSampleSink){if(this.destroyed||!this.input)return null;let h=await this.input.getPrimaryVideoTrack();if(!h)return null;this.videoSampleSink=new St(h)}let r=1e-4;if((!this.iterator||t<this.iteratorStartTimestamp-r||this.headlessQueue.length>0&&t<this.headlessQueue[0].timestamp-.01||this.headlessQueue.length>0&&t-this.headlessQueue[0].timestamp>1)&&(await this.startIteratorHeadless(t,e),this.currentFetchId!==e||this.destroyed||!this.input))return null;for(;;){if(await this.fillHeadlessQueue(e),this.currentFetchId!==e||this.destroyed||!this.input)return null;if(this.headlessQueue.length>=2&&this.headlessQueue[1].timestamp<=t+r){this.headlessQueue.shift()?.close();continue}break}let s=this.headlessQueue[0];if(!s)return null;let a=s.displayWidth,o=s.displayHeight,c=a*o*4,l=this.decodeBuffer;return(!l||l.length!==c)&&(l=new Uint8Array(c),this.decodeBuffer=l),await s.copyTo(l,{format:"RGBA"}),this.currentFetchId!==e||this.destroyed||!this.input?null:(gt(l),{width:a,height:o,buffer:l})}async performDecodeInternal(t){this.currentFetchId++;let e=this.currentFetchId;if(this.isHeadless)return this.performDecodeHeadless(t,e);if(!this.canvasSink){if(this.destroyed||!this.input)return null;let a=await this.input.getPrimaryVideoTrack();if(!a)return null;this.canvasSink=new it(a,{poolSize:3,alpha:!0})}let r=1e-4;if((!this.iterator||t<this.iteratorStartTimestamp-r||this.currentFrame&&t<this.currentFrame.timestamp-.01||this.currentFrame&&t-this.currentFrame.timestamp>1)&&(await this.startIterator(t,e),this.currentFetchId!==e||this.destroyed||!this.input))return null;for(;this.nextFrame&&this.nextFrame.timestamp<=t+r;)if(this.currentFrame=this.nextFrame,this.nextFrame=null,this.iterator){let a=await this.iterator.next();if(this.currentFetchId!==e||this.destroyed||!this.input)return null;this.nextFrame=a.value??null}if(!this.currentFrame)return null;let s=this.currentFrame.canvas;return{width:s.width,height:s.height,canvas:s}}async performDecode(t){let e=Math.max(0,Number.isFinite(t)?t:0);try{return await this.performDecodeInternal(e)}catch(r){let i=r;if(i?.name==="InputDisposedError"||i?.message?.includes("disposed")||this.destroyed||!this.input)return null;this.resetSinks();try{if(!this.isHeadless&&this.input&&!this.destroyed){let n=await this.input.getPrimaryVideoTrack();if(n&&!this.destroyed)return this.canvasSink=new it(n,{poolSize:3,alpha:!0,decoderOptions:{hardwareAcceleration:"prefer-software"}}),await this.performDecodeInternal(e)}}catch{}throw r}}},nt=class extends E{audioSink=null;onDestroy(){this.audioSink=null}async startIterator(t,e){this.audioSink&&(this.iterator?.return(),this.iterator=this.audioSink.buffers(t),this.iteratorStartTimestamp=t)}async*getBuffers(t){try{if(await this.init(),this.destroyed||!this.input)return;if(!this.audioSink){let i=await this.input.getPrimaryAudioTrack();if(!i)return;this.audioSink=new wt(i)}(!this.iterator||Math.abs(t-this.iteratorStartTimestamp)>.05)&&(this.currentFetchId++,await this.startIterator(t,this.currentFetchId));let r=this.currentFetchId;if(!this.iterator)return;for await(let i of this.iterator){if(this.currentFetchId!==r||this.destroyed||!this.input)break;this.iteratorStartTimestamp=i.timestamp+i.duration,yield i}}catch(e){let r=e;if(r?.name==="InputDisposedError"||r?.message?.includes("disposed")||this.destroyed||!this.input)return;throw e}finally{let e=this.currentFetchId;this.currentFetchId===e&&(this.iterator=null)}}},at=class{videoDecoders=new Map;audioDecoders=new Map;lastAccessed=new Map;touchKey(t){this.lastAccessed.set(t,Date.now())}destroy(){for(let t of this.videoDecoders.values())try{t.destroy()}catch{}this.videoDecoders.clear();for(let t of this.audioDecoders.values())try{t.destroy()}catch{}this.audioDecoders.clear(),this.lastAccessed.clear()}prune(t=3e5){let e=Date.now();for(let[r,i]of this.lastAccessed.entries())if(e-i>t){let n=this.videoDecoders.get(r);n&&(n.destroy(),this.videoDecoders.delete(r));let s=this.audioDecoders.get(r);s&&(s.destroy(),this.audioDecoders.delete(r)),this.lastAccessed.delete(r)}}getVideo(t,e,r){let i=`${t}-${e}-${r??"default"}`,n=this.videoDecoders.get(i);return n||(n=new st(t,e),this.videoDecoders.set(i,n)),this.touchKey(i),this.prune(),n}getAudio(t,e){let r=`${t}-${e??"default"}`,i=this.audioDecoders.get(r);return i||(i=new nt(t,!1),this.audioDecoders.set(r,i)),this.touchKey(r),this.prune(),i}clearNode(t){for(let[e,r]of this.videoDecoders)e.includes(t)&&(r.destroy(),this.videoDecoders.delete(e),this.lastAccessed.delete(e));for(let[e,r]of this.audioDecoders)e.includes(t)&&(r.destroy(),this.audioDecoders.delete(e),this.lastAccessed.delete(e))}},te=new at;x();x();var Bt=`
1
+ import{a as ot}from"./chunk-LKYN3BM2.mjs";import{o as Ut,p as C,q as T,r as Mt}from"./chunk-RQLMW6MA.mjs";import{c as yt,d as xt,e as $}from"./chunk-7OMK352W.mjs";import{a as St,b as it,d as wt,e as A}from"./chunk-XETMNJVV.mjs";import{a as vt,b as bt}from"./chunk-ATLWPS6N.mjs";import{e as O,s as G,t as M,v as Gt}from"./chunk-LQENNFBA.mjs";import{a as D,b as gt}from"./chunk-IQC2I5A5.mjs";import{d as Pt}from"./chunk-HYBAPT6I.mjs";import{e as x}from"./chunk-BVF64D6H.mjs";x();var E=class{constructor(t,e){this.url=t;this.isHeadless=e}url;isHeadless;input=null;initPromise=null;iterator=null;iteratorStartTimestamp=-1;currentFetchId=0;fetchLock=Promise.resolve();destroyed=!1;async init(){if(!this.input)return this.initPromise?this.initPromise:(this.destroyed=!1,this.initPromise=(async()=>{try{let t=await A.acquire(this.url);this.destroyed?A.release(this.url):this.input=t}catch(t){throw this.initPromise=null,t}})(),this.initPromise)}destroy(){this.destroyed=!0,this.iterator?.return(),this.input&&(A.release(this.url),this.input=null),this.initPromise=null,this.onDestroy()}},st=class extends E{canvasSink=null;videoSampleSink=null;currentFrame=null;nextFrame=null;currentSample=null;nextSample=null;headlessQueue=[];isDecoding=!1;decodeBuffer=null;nextRequest=null;pushHeadlessQueue(t){let e=this.headlessQueue.findIndex(r=>r.timestamp>t.timestamp);e===-1?this.headlessQueue.push(t):this.headlessQueue.splice(e,0,t)}async fillHeadlessQueue(t){if(this.iterator)for(;this.headlessQueue.length<2;){let e=await this.iterator.next();if(this.currentFetchId!==t){e.value?.close?.();return}if(e.done||!e.value)break;this.pushHeadlessQueue(e.value)}}async closeIterator(t){if(t)try{await t.return()}catch{}}resetSinks(){let t=this.iterator;if(this.iterator=null,t)try{t.return()}catch{}this.canvasSink=null,this.videoSampleSink=null,this.currentFrame=null,this.nextFrame=null,this.currentSample?.close(),this.currentSample=null,this.nextSample?.close(),this.nextSample=null;for(let e of this.headlessQueue)try{e.close()}catch{}this.headlessQueue=[],this.decodeBuffer=null,this.iteratorStartTimestamp=-1}onDestroy(){this.resetSinks()}async startIterator(t,e){if(!this.canvasSink)return;let r=Math.max(0,Number.isFinite(t)?t:0),i=this.iterator;if(this.iterator=null,await this.closeIterator(i),this.currentFetchId!==e||this.destroyed)return;this.iterator=this.canvasSink.canvases(r);let n=await this.iterator.next();if(this.currentFetchId!==e||this.destroyed)return;this.currentFrame=n.value??null;let s=await this.iterator.next();this.currentFetchId!==e||this.destroyed||(this.nextFrame=s.value??null,this.iteratorStartTimestamp=r)}async startIteratorHeadless(t,e){if(!this.videoSampleSink)return;let r=Math.max(0,Number.isFinite(t)?t:0),i=this.iterator;if(this.iterator=null,await this.closeIterator(i),this.currentFetchId!==e||this.destroyed)return;for(let s of this.headlessQueue)s.close();this.headlessQueue=[];let n=Math.max(0,r-.1);this.iterator=this.videoSampleSink.samples(n),await this.fillHeadlessQueue(e),!(this.currentFetchId!==e||this.destroyed)&&(this.iteratorStartTimestamp=r)}async getFrame(t){if(await this.init(),this.destroyed||!this.input)return null;let e=Math.max(0,Number.isFinite(t)?t:0);return this.isDecoding?(this.nextRequest&&this.nextRequest.resolve(null),new Promise((r,i)=>{this.nextRequest={timestampSec:e,resolve:r,reject:i}})):this.executeDecode(e)}async executeDecode(t){this.isDecoding=!0;try{return await this.performDecode(t)}finally{if(this.isDecoding=!1,this.nextRequest){let e=this.nextRequest;this.nextRequest=null,this.executeDecode(e.timestampSec).then(e.resolve).catch(e.reject)}}}async performDecodeHeadless(t,e){if(!this.videoSampleSink){if(this.destroyed||!this.input)return null;let h=await this.input.getPrimaryVideoTrack();if(!h)return null;this.videoSampleSink=new St(h)}let r=1e-4;if((!this.iterator||t<this.iteratorStartTimestamp-r||this.headlessQueue.length>0&&t<this.headlessQueue[0].timestamp-.01||this.headlessQueue.length>0&&t-this.headlessQueue[0].timestamp>1)&&(await this.startIteratorHeadless(t,e),this.currentFetchId!==e||this.destroyed||!this.input))return null;for(;;){if(await this.fillHeadlessQueue(e),this.currentFetchId!==e||this.destroyed||!this.input)return null;if(this.headlessQueue.length>=2&&this.headlessQueue[1].timestamp<=t+r){this.headlessQueue.shift()?.close();continue}break}let s=this.headlessQueue[0];if(!s)return null;let a=s.displayWidth,o=s.displayHeight,c=a*o*4,l=this.decodeBuffer;return(!l||l.length!==c)&&(l=new Uint8Array(c),this.decodeBuffer=l),await s.copyTo(l,{format:"RGBA"}),this.currentFetchId!==e||this.destroyed||!this.input?null:(gt(l),{width:a,height:o,buffer:l})}async performDecodeInternal(t){this.currentFetchId++;let e=this.currentFetchId;if(this.isHeadless)return this.performDecodeHeadless(t,e);if(!this.canvasSink){if(this.destroyed||!this.input)return null;let a=await this.input.getPrimaryVideoTrack();if(!a)return null;this.canvasSink=new it(a,{poolSize:3,alpha:!0})}let r=1e-4;if((!this.iterator||t<this.iteratorStartTimestamp-r||this.currentFrame&&t<this.currentFrame.timestamp-.01||this.currentFrame&&t-this.currentFrame.timestamp>1)&&(await this.startIterator(t,e),this.currentFetchId!==e||this.destroyed||!this.input))return null;for(;this.nextFrame&&this.nextFrame.timestamp<=t+r;)if(this.currentFrame=this.nextFrame,this.nextFrame=null,this.iterator){let a=await this.iterator.next();if(this.currentFetchId!==e||this.destroyed||!this.input)return null;this.nextFrame=a.value??null}if(!this.currentFrame)return null;let s=this.currentFrame.canvas;return{width:s.width,height:s.height,canvas:s}}async performDecode(t){let e=Math.max(0,Number.isFinite(t)?t:0);try{return await this.performDecodeInternal(e)}catch(r){let i=r;if(i?.name==="InputDisposedError"||i?.message?.includes("disposed")||this.destroyed||!this.input)return null;this.resetSinks();try{if(!this.isHeadless&&this.input&&!this.destroyed){let n=await this.input.getPrimaryVideoTrack();if(n&&!this.destroyed)return this.canvasSink=new it(n,{poolSize:3,alpha:!0,decoderOptions:{hardwareAcceleration:"prefer-software"}}),await this.performDecodeInternal(e)}}catch{}throw r}}},nt=class extends E{audioSink=null;onDestroy(){this.audioSink=null}async startIterator(t,e){this.audioSink&&(this.iterator?.return(),this.iterator=this.audioSink.buffers(t),this.iteratorStartTimestamp=t)}async*getBuffers(t){try{if(await this.init(),this.destroyed||!this.input)return;if(!this.audioSink){let i=await this.input.getPrimaryAudioTrack();if(!i)return;this.audioSink=new wt(i)}(!this.iterator||Math.abs(t-this.iteratorStartTimestamp)>.05)&&(this.currentFetchId++,await this.startIterator(t,this.currentFetchId));let r=this.currentFetchId;if(!this.iterator)return;for await(let i of this.iterator){if(this.currentFetchId!==r||this.destroyed||!this.input)break;this.iteratorStartTimestamp=i.timestamp+i.duration,yield i}}catch(e){let r=e;if(r?.name==="InputDisposedError"||r?.message?.includes("disposed")||this.destroyed||!this.input)return;throw e}finally{let e=this.currentFetchId;this.currentFetchId===e&&(this.iterator=null)}}},at=class{videoDecoders=new Map;audioDecoders=new Map;lastAccessed=new Map;touchKey(t){this.lastAccessed.set(t,Date.now())}destroy(){for(let t of this.videoDecoders.values())try{t.destroy()}catch{}this.videoDecoders.clear();for(let t of this.audioDecoders.values())try{t.destroy()}catch{}this.audioDecoders.clear(),this.lastAccessed.clear()}prune(t=3e5){let e=Date.now();for(let[r,i]of this.lastAccessed.entries())if(e-i>t){let n=this.videoDecoders.get(r);n&&(n.destroy(),this.videoDecoders.delete(r));let s=this.audioDecoders.get(r);s&&(s.destroy(),this.audioDecoders.delete(r)),this.lastAccessed.delete(r)}}getVideo(t,e,r){let i=`${t}-${e}-${r??"default"}`,n=this.videoDecoders.get(i);return n||(n=new st(t,e),this.videoDecoders.set(i,n)),this.touchKey(i),this.prune(),n}getAudio(t,e){let r=`${t}-${e??"default"}`,i=this.audioDecoders.get(r);return i||(i=new nt(t,!1),this.audioDecoders.set(r,i)),this.touchKey(r),this.prune(),i}clearNode(t){for(let[e,r]of this.videoDecoders)e.includes(t)&&(r.destroy(),this.videoDecoders.delete(e),this.lastAccessed.delete(e));for(let[e,r]of this.audioDecoders)e.includes(t)&&(r.destroy(),this.audioDecoders.delete(e),this.lastAccessed.delete(e))}},te=new at;x();x();var Bt=`
2
2
  struct CompositeUniforms {
3
3
  blendMode : u32,
4
4
  padding1 : u32,
@@ -1 +1 @@
1
- import{$ as Ga,A as fa,B as ga,C as ha,D as ia,E as ja,F as ka,G as la,H as ma,I as na,J as oa,K as pa,L as qa,M as ra,N as sa,O as ta,P as ua,Q as va,R as wa,S as xa,T as ya,U as za,V as Aa,W as Ba,X as Ca,Y as Da,Z as Ea,_ as Fa,a as H,aa as Ha,b as I,c as J,d as K,e as L,f as M,g as N,h as O,i as P,j as Q,k as R,l as S,m as T,n as U,o as V,p as W,q as X,r as Y,s as Z,t as _,u as $,v as aa,w as ba,x as ca,y as da,z as ea}from"./chunk-UKBUEM3G.mjs";import{a as D}from"./chunk-GSFN4WCH.mjs";import{a as E}from"./chunk-5W4AFQP7.mjs";import{a as F}from"./chunk-OKH2VU2U.mjs";import{S as G}from"./chunk-3GNP7TJH.mjs";import{b as y}from"./chunk-L3CHEZMZ.mjs";import{a as z}from"./chunk-E3HC4GRQ.mjs";import{a as A}from"./chunk-MOW55DX2.mjs";import{a as B}from"./chunk-7EPIRODI.mjs";import{b as C}from"./chunk-VXS5SIEC.mjs";import{b as r}from"./chunk-PAQNDZQB.mjs";import{b as s}from"./chunk-SZW5J72T.mjs";import{a as t}from"./chunk-PL4IH5V4.mjs";import{a as v}from"./chunk-WUKH7BD7.mjs";import{b as w}from"./chunk-YQZOGEPZ.mjs";import{b as x}from"./chunk-J2R5R7YY.mjs";import{a as j}from"./chunk-WSIURGP2.mjs";import{a as k}from"./chunk-WFGJXCZT.mjs";import{b as l}from"./chunk-RW2F3XLQ.mjs";import{a as m}from"./chunk-PXT52LEH.mjs";import{a as n}from"./chunk-FU7AIAMM.mjs";import{a as o}from"./chunk-OJ2PKBXE.mjs";import{a as p}from"./chunk-5AUB4Y3L.mjs";import{a as q}from"./chunk-SGPRLTNF.mjs";import"./chunk-YKMBRUAE.mjs";import{a as e}from"./chunk-WH5Q2NFN.mjs";import{a as f}from"./chunk-PEWYB6WP.mjs";import{b as g}from"./chunk-AXHB4J37.mjs";import{a as h}from"./chunk-RSMO7NPN.mjs";import"./chunk-N4LHIPHZ.mjs";import{a as i}from"./chunk-LBRVQ4GE.mjs";import"./chunk-VXUJWPIK.mjs";import{a as b}from"./chunk-AXQZX3TC.mjs";import"./chunk-XOEEGC4Z.mjs";import{b as c}from"./chunk-IUPDOATX.mjs";import{a as d}from"./chunk-2MZXSWVT.mjs";import{a}from"./chunk-3UPI4EPV.mjs";import"./chunk-XKO4RYKN.mjs";import"./chunk-VRGREB3V.mjs";import"./chunk-JAJOZG5P.mjs";import"./chunk-FJH5A2PV.mjs";import{a as u}from"./chunk-PFA427ZC.mjs";import"./chunk-FLPSWDX4.mjs";import"./chunk-NQZKBFC6.mjs";import"./chunk-ENKKLU7B.mjs";import"./chunk-VUFDQJ2B.mjs";import"./chunk-2W4BMOAZ.mjs";import"./chunk-37EFVZWT.mjs";import"./chunk-4VOHF3FF.mjs";import"./chunk-24P6DAB3.mjs";import"./chunk-XETMNJVV.mjs";import"./chunk-Q4Z54DQ7.mjs";import"./chunk-6YJP57MZ.mjs";import"./chunk-63SFBHEH.mjs";import"./chunk-4GEWSUX5.mjs";import"./chunk-MTJHQATU.mjs";import"./chunk-IQC2I5A5.mjs";import"./chunk-IQKIHFNZ.mjs";import"./chunk-HYBAPT6I.mjs";import"./chunk-YAQFFQPG.mjs";import"./chunk-BVF64D6H.mjs";export{ua as ApplyLUT,I as AudioCompressor,J as AudioDelay,K as AudioFade,L as AudioNoiseGate,M as AudioParametricEq,N as AudioReverb,pa as AudioSignalExtractor,ka as Blur,O as CameraParallax3D,P as ChannelMerger,Q as ChannelSplitter,R as ColorBalance,S as ColorKey,T as CornerPin,Da as Crop,qa as Curves,oa as CustomEffect,Ca as DepthOfField,U as DisplacementMap,V as ExtractLUT,na as FilmGrain,W as Flip,sa as GradientMap,xa as HalftoneScreen,wa as HighPass,X as KenBurns,Y as LayerStyle,ma as Levels,Z as Liquify,_ as MaskMath,$ as MeshWarp,Ha as Modulate,za as MotionBlur,aa as NoiseGenerator,Ba as PBRGlass,ba as Paint,ca as PatchHeal,da as ProceduralVFX,ea as RefineEdge,fa as RefractionCaustics3D,Fa as Relight3D,ga as ResizerScaler,ha as Rotate,Aa as SSAO,ra as SelectiveColor,ta as ShadowsHighlights,ia as StereoPanning,Ga as TemporalDeflicker,ya as TileOffset,va as UnsharpMask,ja as Vignette,Ea as Vision,a as applyLutRenderer,b as blurRenderer,c as colorBalanceRenderer,d as colorkeyRenderer,e as cornerPinRenderer,f as cropRenderer,g as curvesRenderer,h as deflickerRenderer,i as displacementMapRenderer,la as effectFactories,H as effectMeta,j as filmGrainRenderer,k as flipRenderer,l as gradientMapRenderer,m as halftoneScreenRenderer,n as highPassRenderer,o as kenBurnsRenderer,p as layerStyleRenderer,q as levelsRenderer,r as liquifyRenderer,s as maskMathRenderer,t as meshWarpRenderer,u as modulateRenderer,v as paintRenderer,w as patchHealRenderer,x as refineEdgeRenderer,y as refractionCausticsRenderer,z as relight3dRenderer,A as rotateRenderer,B as selectiveColorRenderer,C as shadowsHighlightsRenderer,D as tileOffsetRenderer,E as unsharpMaskRenderer,F as vignetteRenderer,G as visionRenderer};
1
+ import{$ as Ga,A as fa,B as ga,C as ha,D as ia,E as ja,F as ka,G as la,H as ma,I as na,J as oa,K as pa,L as qa,M as ra,N as sa,O as ta,P as ua,Q as va,R as wa,S as xa,T as ya,U as za,V as Aa,W as Ba,X as Ca,Y as Da,Z as Ea,_ as Fa,a as H,aa as Ha,b as I,c as J,d as K,e as L,f as M,g as N,h as O,i as P,j as Q,k as R,l as S,m as T,n as U,o as V,p as W,q as X,r as Y,s as Z,t as _,u as $,v as aa,w as ba,x as ca,y as da,z as ea}from"./chunk-HFUA47QH.mjs";import{a as D}from"./chunk-GSFN4WCH.mjs";import{a as E}from"./chunk-5W4AFQP7.mjs";import{a as F}from"./chunk-OKH2VU2U.mjs";import{S as G}from"./chunk-K7M5EIFC.mjs";import{b as y}from"./chunk-L3CHEZMZ.mjs";import{a as z}from"./chunk-E3HC4GRQ.mjs";import{a as A}from"./chunk-MOW55DX2.mjs";import{a as B}from"./chunk-7EPIRODI.mjs";import{b as C}from"./chunk-VXS5SIEC.mjs";import{b as r}from"./chunk-PAQNDZQB.mjs";import{b as s}from"./chunk-SZW5J72T.mjs";import{a as t}from"./chunk-PL4IH5V4.mjs";import{a as v}from"./chunk-WUKH7BD7.mjs";import{b as w}from"./chunk-YQZOGEPZ.mjs";import{b as x}from"./chunk-J2R5R7YY.mjs";import{a as j}from"./chunk-WSIURGP2.mjs";import{a as k}from"./chunk-WFGJXCZT.mjs";import{b as l}from"./chunk-RW2F3XLQ.mjs";import{a as m}from"./chunk-PXT52LEH.mjs";import{a as n}from"./chunk-FU7AIAMM.mjs";import{a as o}from"./chunk-OJ2PKBXE.mjs";import{a as p}from"./chunk-5AUB4Y3L.mjs";import{a as q}from"./chunk-SGPRLTNF.mjs";import"./chunk-YKMBRUAE.mjs";import{a as e}from"./chunk-WH5Q2NFN.mjs";import{a as f}from"./chunk-PEWYB6WP.mjs";import{b as g}from"./chunk-AXHB4J37.mjs";import{a as h}from"./chunk-RSMO7NPN.mjs";import"./chunk-N4LHIPHZ.mjs";import{a as i}from"./chunk-LBRVQ4GE.mjs";import"./chunk-VXUJWPIK.mjs";import{a as b}from"./chunk-AXQZX3TC.mjs";import"./chunk-XOEEGC4Z.mjs";import{b as c}from"./chunk-IUPDOATX.mjs";import{a as d}from"./chunk-2MZXSWVT.mjs";import{a}from"./chunk-3UPI4EPV.mjs";import"./chunk-XKO4RYKN.mjs";import"./chunk-7OMK352W.mjs";import"./chunk-JAJOZG5P.mjs";import"./chunk-FJH5A2PV.mjs";import{a as u}from"./chunk-PFA427ZC.mjs";import"./chunk-FLPSWDX4.mjs";import"./chunk-NQZKBFC6.mjs";import"./chunk-ENKKLU7B.mjs";import"./chunk-VUFDQJ2B.mjs";import"./chunk-2W4BMOAZ.mjs";import"./chunk-37EFVZWT.mjs";import"./chunk-4VOHF3FF.mjs";import"./chunk-24P6DAB3.mjs";import"./chunk-XETMNJVV.mjs";import"./chunk-Q4Z54DQ7.mjs";import"./chunk-6YJP57MZ.mjs";import"./chunk-63SFBHEH.mjs";import"./chunk-4GEWSUX5.mjs";import"./chunk-MTJHQATU.mjs";import"./chunk-IQC2I5A5.mjs";import"./chunk-IQKIHFNZ.mjs";import"./chunk-HYBAPT6I.mjs";import"./chunk-YAQFFQPG.mjs";import"./chunk-BVF64D6H.mjs";export{ua as ApplyLUT,I as AudioCompressor,J as AudioDelay,K as AudioFade,L as AudioNoiseGate,M as AudioParametricEq,N as AudioReverb,pa as AudioSignalExtractor,ka as Blur,O as CameraParallax3D,P as ChannelMerger,Q as ChannelSplitter,R as ColorBalance,S as ColorKey,T as CornerPin,Da as Crop,qa as Curves,oa as CustomEffect,Ca as DepthOfField,U as DisplacementMap,V as ExtractLUT,na as FilmGrain,W as Flip,sa as GradientMap,xa as HalftoneScreen,wa as HighPass,X as KenBurns,Y as LayerStyle,ma as Levels,Z as Liquify,_ as MaskMath,$ as MeshWarp,Ha as Modulate,za as MotionBlur,aa as NoiseGenerator,Ba as PBRGlass,ba as Paint,ca as PatchHeal,da as ProceduralVFX,ea as RefineEdge,fa as RefractionCaustics3D,Fa as Relight3D,ga as ResizerScaler,ha as Rotate,Aa as SSAO,ra as SelectiveColor,ta as ShadowsHighlights,ia as StereoPanning,Ga as TemporalDeflicker,ya as TileOffset,va as UnsharpMask,ja as Vignette,Ea as Vision,a as applyLutRenderer,b as blurRenderer,c as colorBalanceRenderer,d as colorkeyRenderer,e as cornerPinRenderer,f as cropRenderer,g as curvesRenderer,h as deflickerRenderer,i as displacementMapRenderer,la as effectFactories,H as effectMeta,j as filmGrainRenderer,k as flipRenderer,l as gradientMapRenderer,m as halftoneScreenRenderer,n as highPassRenderer,o as kenBurnsRenderer,p as layerStyleRenderer,q as levelsRenderer,r as liquifyRenderer,s as maskMathRenderer,t as meshWarpRenderer,u as modulateRenderer,v as paintRenderer,w as patchHealRenderer,x as refineEdgeRenderer,y as refractionCausticsRenderer,z as relight3dRenderer,A as rotateRenderer,B as selectiveColorRenderer,C as shadowsHighlightsRenderer,D as tileOffsetRenderer,E as unsharpMaskRenderer,F as vignetteRenderer,G as visionRenderer};