@pexip/media-processor 20.2.0 → 20.3.3

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.
@@ -38,7 +38,7 @@ var It=typeof self<"u"?self:{};function za(e,t){e=e.split(".");var r,n=It;for((e
38
38
  overlayColor = mix(defaultColor, overlayColor, overlayColor.a);
39
39
  gl_FragColor = mix(defaultColor, overlayColor, confidence);
40
40
  }
41
- `}C(){let e=this.g;e.activeTexture(e.TEXTURE1),this.j=Tt(this,e),e.activeTexture(e.TEXTURE2),this.B=Tt(this,e)}m(){super.m();let e=this.g;this.K=ge(e.getUniformLocation(this.h,"defaultTexture"),"Uniform location"),this.L=ge(e.getUniformLocation(this.h,"overlayTexture"),"Uniform location"),this.I=ge(e.getUniformLocation(this.h,"maskTexture"),"Uniform location")}l(){super.l();let e=this.g;e.uniform1i(this.I,0),e.uniform1i(this.K,1),e.uniform1i(this.L,2)}close(){this.j&&this.g.deleteTexture(this.j),this.B&&this.g.deleteTexture(this.B),super.close()}};function st(e,t){switch(t){case 0:return e.g.find(r=>r instanceof Uint8Array);case 1:return e.g.find(r=>r instanceof Float32Array);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function ho(e){var t=st(e,1);if(!t){if(t=st(e,0))t=new Float32Array(t).map(n=>n/255);else{t=new Float32Array(e.width*e.height);let n=Ht(e);var r=ds(e);if(Rn(r,n,Lc(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){r=new Float32Array(e.width*e.height*4),n.readPixels(0,0,e.width,e.height,n.RGBA,n.FLOAT,r);for(let o=0,s=0;o<t.length;++o,s+=4)t[o]=r[s]}else n.readPixels(0,0,e.width,e.height,n.RED,n.FLOAT,t)}e.g.push(t)}return t}function Lc(e){let t=st(e,2);if(!t){let r=Ht(e);t=Mc(e);let n=ho(e),o=Ic(e);r.texImage2D(r.TEXTURE_2D,0,o,e.width,e.height,0,r.RED,r.FLOAT,n),lo(e)}return t}function Ht(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return e.h||(e.h=ge(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Ic(e){if(e=Ht(e),!Pr)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Pr=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Pr=e.R16F}return Pr}function ds(e){return e.l||(e.l=new nr),e.l}function Mc(e){let t=Ht(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=st(e,2);return r||(r=Tt(ds(e),t,e.m?t.LINEAR:t.NEAREST),e.g.push(r),e.j=!0),t.bindTexture(t.TEXTURE_2D,r),r}function lo(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Pr,ae=class{constructor(e,t,r,n,o,s,a){this.g=e,this.m=t,this.j=r,this.canvas=n,this.l=o,this.width=s,this.height=a,this.j&&--Aa===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Ga(){return!!st(this,0)}ka(){return!!st(this,1)}R(){return!!st(this,2)}ja(){return(t=st(e=this,0))||(t=ho(e),t=new Uint8Array(t.map(r=>255*r)),e.g.push(t)),t;var e,t}ia(){return ho(this)}N(){return Lc(this)}clone(){let e=[];for(let t of this.g){let r;if(t instanceof Uint8Array)r=new Uint8Array(t);else if(t instanceof Float32Array)r=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{let n=Ht(this),o=ds(this);n.activeTexture(n.TEXTURE1),r=Tt(o,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);let s=Ic(this);n.texImage2D(n.TEXTURE_2D,0,s,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),Rn(o,n,r),Sr(o,n,!1,()=>{Mc(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),lo(this)}),ls(o),lo(this)}}e.push(r)}return new ae(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Ht(this).deleteTexture(st(this,2)),Aa=-1}};ae.prototype.close=ae.prototype.close,ae.prototype.clone=ae.prototype.clone,ae.prototype.getAsWebGLTexture=ae.prototype.N,ae.prototype.getAsFloat32Array=ae.prototype.ia,ae.prototype.getAsUint8Array=ae.prototype.ja,ae.prototype.hasWebGLTexture=ae.prototype.R,ae.prototype.hasFloat32Array=ae.prototype.ka,ae.prototype.hasUint8Array=ae.prototype.Ga;var Aa=250,U2={color:"white",lineWidth:4,radius:6};function zn(e){return{...U2,fillColor:(e=e||{}).color,...e}}function nt(e,t){return e instanceof Function?e(t):e}function Ra(e,t,r){return Math.max(Math.min(t,r),Math.min(Math.max(t,r),e))}function lr(e){if(!e.l)throw Error("CPU rendering requested but CanvasRenderingContext2D not provided.");return e.l}function Tr(e){if(!e.j)throw Error("GPU rendering requested but WebGL2RenderingContext not provided.");return e.j}function wa(e,t,r){if(t.R())r(t.N());else{let n=t.ka()?t.ia():t.ja();e.m=e.m??new nr;let o=Tr(e);r((e=new ae([n],t.m,!1,o.canvas,e.m,t.width,t.height)).N()),e.close()}}function ka(e,t,r,n){let o=function(i){return i.g||(i.g=new M2),i.g}(e),s=Tr(e),a=Array.isArray(r)?new ImageData(new Uint8ClampedArray(r),1,1):r;Sr(o,s,!0,()=>{(function(c,l,h,p){let d=c.g;if(d.activeTexture(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,l),d.activeTexture(d.TEXTURE1),d.bindTexture(d.TEXTURE_2D,c.B),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,h),c.I&&function(g,A){if(g!==A)return!1;g=g.entries(),A=A.entries();for(let[S,w]of g){g=S;let f=w;var R=A.next();if(R.done)return!1;let[y,b]=R.value;if(R=b,g!==y||f[0]!==R[0]||f[1]!==R[1]||f[2]!==R[2]||f[3]!==R[3])return!1}return!!A.next().done}(c.I,p))d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j);else{c.I=p;let g=Array(1024).fill(0);p.forEach((A,R)=>{if(A.length!==4)throw Error(`Color at index ${R} is not a four-channel value.`);g[4*R]=A[0],g[4*R+1]=A[1],g[4*R+2]=A[2],g[4*R+3]=A[3]}),d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,256,1,0,d.RGBA,d.UNSIGNED_BYTE,new Uint8Array(g))}})(o,t,a,n),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.drawArrays(s.TRIANGLE_FAN,0,4);let i=o.g;i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE2),i.bindTexture(i.TEXTURE_2D,null)})}function Sa(e,t,r,n){let o=Tr(e),s=function(c){return c.h||(c.h=new F2),c.h}(e),a=Array.isArray(r)?new ImageData(new Uint8ClampedArray(r),1,1):r,i=Array.isArray(n)?new ImageData(new Uint8ClampedArray(n),1,1):n;Sr(s,o,!0,()=>{var c=s.g;c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,t),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,s.j),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,a),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,s.B),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLE_FAN,0,4),o.bindTexture(o.TEXTURE_2D,null),(c=s.g).activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,null)})}var me=class{constructor(e,t){e instanceof CanvasRenderingContext2D||e instanceof OffscreenCanvasRenderingContext2D?(this.l=e,this.j=t):this.j=e}za(e,t){if(e){var r=lr(this);t=zn(t),r.save();var n=r.canvas,o=0;for(let s of e)r.fillStyle=nt(t.fillColor,{index:o,from:s}),r.strokeStyle=nt(t.color,{index:o,from:s}),r.lineWidth=nt(t.lineWidth,{index:o,from:s}),(e=new Path2D).arc(s.x*n.width,s.y*n.height,nt(t.radius,{index:o,from:s}),0,2*Math.PI),r.fill(e),r.stroke(e),++o;r.restore()}}ya(e,t,r){if(e&&t){var n=lr(this);r=zn(r),n.save();var o=n.canvas,s=0;for(let a of t){n.beginPath(),t=e[a.start];let i=e[a.end];t&&i&&(n.strokeStyle=nt(r.color,{index:s,from:t,to:i}),n.lineWidth=nt(r.lineWidth,{index:s,from:t,to:i}),n.moveTo(t.x*o.width,t.y*o.height),n.lineTo(i.x*o.width,i.y*o.height)),++s,n.stroke()}n.restore()}}va(e,t){let r=lr(this);t=zn(t),r.save(),r.beginPath(),r.lineWidth=nt(t.lineWidth,{}),r.strokeStyle=nt(t.color,{}),r.fillStyle=nt(t.fillColor,{}),r.moveTo(e.originX,e.originY),r.lineTo(e.originX+e.width,e.originY),r.lineTo(e.originX+e.width,e.originY+e.height),r.lineTo(e.originX,e.originY+e.height),r.lineTo(e.originX,e.originY),r.stroke(),r.fill(),r.restore()}wa(e,t,r=[0,0,0,255]){this.l?function(n,o,s,a){let i=Tr(n);wa(n,o,c=>{ka(n,c,s,a),(c=lr(n)).drawImage(i.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,e,r,t):ka(this,e.N(),r,t)}xa(e,t,r){this.l?function(n,o,s,a){let i=Tr(n);wa(n,o,c=>{Sa(n,c,s,a),(c=lr(n)).drawImage(i.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,e,t,r):Sa(this,e.N(),t,r)}close(){this.g?.close(),this.g=void 0,this.h?.close(),this.h=void 0,this.m?.close(),this.m=void 0}};function Ze(e,t){switch(t){case 0:return e.g.find(r=>r instanceof ImageData);case 1:return e.g.find(r=>typeof ImageBitmap<"u"&&r instanceof ImageBitmap);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function Fc(e){var t=Ze(e,0);if(!t){t=Yt(e);let r=wn(e),n=new Uint8Array(e.width*e.height*4);Rn(r,t,jr(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,n),ls(r),t=new ImageData(new Uint8ClampedArray(n.buffer),e.width,e.height),e.g.push(t)}return t}function jr(e){let t=Ze(e,2);if(!t){let r=Yt(e);t=Wr(e);let n=Ze(e,1)||Fc(e);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,n),fr(e)}return t}function Yt(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when iniitializing the image.");return e.h||(e.h=ge(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function wn(e){return e.l||(e.l=new nr),e.l}function Wr(e){let t=Yt(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=Ze(e,2);return r||(r=Tt(wn(e),t),e.g.push(r),e.m=!0),t.bindTexture(t.TEXTURE_2D,r),r}function fr(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function Ca(e){let t=Yt(e);return Sr(wn(e),t,!0,()=>function(r,n){let o=r.canvas;if(o.width===r.width&&o.height===r.height)return n();let s=o.width,a=o.height;return o.width=r.width,o.height=r.height,r=n(),o.width=s,o.height=a,r}(e,()=>{if(t.bindFramebuffer(t.FRAMEBUFFER,null),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),!(e.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return e.canvas.transferToImageBitmap()}))}me.prototype.close=me.prototype.close,me.prototype.drawConfidenceMask=me.prototype.xa,me.prototype.drawCategoryMask=me.prototype.wa,me.prototype.drawBoundingBox=me.prototype.va,me.prototype.drawConnectors=me.prototype.ya,me.prototype.drawLandmarks=me.prototype.za,me.lerp=function(e,t,r,n,o){return Ra(n*(1-(e-t)/(r-t))+o*(1-(r-e)/(r-t)),n,o)},me.clamp=Ra,za("DrawingUtils",me);var he=class{constructor(e,t,r,n,o,s,a){this.g=e,this.j=t,this.m=r,this.canvas=n,this.l=o,this.width=s,this.height=a,(this.j||this.m)&&--La===0&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}Fa(){return!!Ze(this,0)}la(){return!!Ze(this,1)}R(){return!!Ze(this,2)}Da(){return Fc(this)}Ca(){var e=Ze(this,1);return e||(jr(this),Wr(this),e=Ca(this),fr(this),this.g.push(e),this.j=!0),e}N(){return jr(this)}clone(){let e=[];for(let t of this.g){let r;if(t instanceof ImageData)r=new ImageData(t.data,this.width,this.height);else if(t instanceof WebGLTexture){let n=Yt(this),o=wn(this);n.activeTexture(n.TEXTURE1),r=Tt(o,n),n.bindTexture(n.TEXTURE_2D,r),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,this.width,this.height,0,n.RGBA,n.UNSIGNED_BYTE,null),n.bindTexture(n.TEXTURE_2D,null),Rn(o,n,r),Sr(o,n,!1,()=>{Wr(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),fr(this)}),ls(o),fr(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);jr(this),Wr(this),r=Ca(this),fr(this)}e.push(r)}return new he(e,this.la(),this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Ze(this,1).close(),this.m&&Yt(this).deleteTexture(Ze(this,2)),La=-1}};he.prototype.close=he.prototype.close,he.prototype.clone=he.prototype.clone,he.prototype.getAsWebGLTexture=he.prototype.N,he.prototype.getAsImageBitmap=he.prototype.Ca,he.prototype.getAsImageData=he.prototype.Da,he.prototype.hasWebGLTexture=he.prototype.R,he.prototype.hasImageBitmap=he.prototype.la,he.prototype.hasImageData=he.prototype.Fa;var La=250;function ze(...e){return e.map(([t,r])=>({start:t,end:r}))}var O2=function(e){return class extends e{La(){this.i._registerModelResourcesGraphService()}}}((Ia=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",t!==void 0?this.i.canvas=t:Sc()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(e){let t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){let r=e.length,n=this.i._malloc(r);this.i.HEAPU8.set(e,n),t?this.i._changeBinaryGraph(r,n):this.i._changeTextGraph(r,n),this.i._free(n)}configureAudio(e,t,r,n,o){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),E(this,n||"input_audio",s=>{E(this,o=o||"audio_header",a=>{this.i._configureAudio(s,a,e,t??0,r)})})}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}ea(e){qe(this,"__graph_config__",t=>{e(t)}),E(this,"__graph_config__",t=>{this.i._getGraphConfig(t,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,n,o){let s=4*e.length;this.h!==s&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(s),this.h=s),this.i.HEAPF32.set(e,this.g/4),E(this,n,a=>{this.i._addAudioToInputStream(this.g,t,r,a,o)})}addGpuBufferToStream(e,t,r){E(this,t,n=>{let[o,s]=va(this,e,n);this.i._addBoundTextureToStream(n,o,s,r)})}addBoolToStream(e,t,r){E(this,t,n=>{this.i._addBoolToInputStream(e,n,r)})}addDoubleToStream(e,t,r){E(this,t,n=>{this.i._addDoubleToInputStream(e,n,r)})}addFloatToStream(e,t,r){E(this,t,n=>{this.i._addFloatToInputStream(e,n,r)})}addIntToStream(e,t,r){E(this,t,n=>{this.i._addIntToInputStream(e,n,r)})}addUintToStream(e,t,r){E(this,t,n=>{this.i._addUintToInputStream(e,n,r)})}addStringToStream(e,t,r){E(this,t,n=>{E(this,e,o=>{this.i._addStringToInputStream(o,n,r)})})}addStringRecordToStream(e,t,r){E(this,t,n=>{Ea(this,Object.keys(e),o=>{Ea(this,Object.values(e),s=>{this.i._addFlatHashMapToInputStream(o,s,Object.keys(e).length,n,r)})})})}addProtoToStream(e,t,r,n){E(this,r,o=>{E(this,t,s=>{let a=this.i._malloc(e.length);this.i.HEAPU8.set(e,a),this.i._addProtoToInputStream(a,e.length,s,o,n),this.i._free(a)})})}addEmptyPacketToStream(e,t){E(this,e,r=>{this.i._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateBoolVector(e.length);if(!o)throw Error("Unable to allocate new bool vector on heap.");for(let s of e)this.i._addBoolVectorEntry(o,s);this.i._addBoolVectorToInputStream(o,n,r)})}addDoubleVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateDoubleVector(e.length);if(!o)throw Error("Unable to allocate new double vector on heap.");for(let s of e)this.i._addDoubleVectorEntry(o,s);this.i._addDoubleVectorToInputStream(o,n,r)})}addFloatVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateFloatVector(e.length);if(!o)throw Error("Unable to allocate new float vector on heap.");for(let s of e)this.i._addFloatVectorEntry(o,s);this.i._addFloatVectorToInputStream(o,n,r)})}addIntVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateIntVector(e.length);if(!o)throw Error("Unable to allocate new int vector on heap.");for(let s of e)this.i._addIntVectorEntry(o,s);this.i._addIntVectorToInputStream(o,n,r)})}addUintVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateUintVector(e.length);if(!o)throw Error("Unable to allocate new unsigned int vector on heap.");for(let s of e)this.i._addUintVectorEntry(o,s);this.i._addUintVectorToInputStream(o,n,r)})}addStringVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateStringVector(e.length);if(!o)throw Error("Unable to allocate new string vector on heap.");for(let s of e)E(this,s,a=>{this.i._addStringVectorEntry(o,a)});this.i._addStringVectorToInputStream(o,n,r)})}addBoolToInputSidePacket(e,t){E(this,t,r=>{this.i._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){E(this,t,r=>{this.i._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){E(this,t,r=>{this.i._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){E(this,t,r=>{this.i._addIntToInputSidePacket(e,r)})}addUintToInputSidePacket(e,t){E(this,t,r=>{this.i._addUintToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){E(this,t,r=>{E(this,e,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(e,t,r){E(this,r,n=>{E(this,t,o=>{let s=this.i._malloc(e.length);this.i.HEAPU8.set(e,s),this.i._addProtoToInputSidePacket(s,e.length,o,n),this.i._free(s)})})}addBoolVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let o of e)this.i._addBoolVectorEntry(n,o);this.i._addBoolVectorToInputSidePacket(n,r)})}addDoubleVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let o of e)this.i._addDoubleVectorEntry(n,o);this.i._addDoubleVectorToInputSidePacket(n,r)})}addFloatVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let o of e)this.i._addFloatVectorEntry(n,o);this.i._addFloatVectorToInputSidePacket(n,r)})}addIntVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let o of e)this.i._addIntVectorEntry(n,o);this.i._addIntVectorToInputSidePacket(n,r)})}addUintVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(let o of e)this.i._addUintVectorEntry(n,o);this.i._addUintVectorToInputSidePacket(n,r)})}addStringVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let o of e)E(this,o,s=>{this.i._addStringVectorEntry(n,s)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(e,t,r){qe(this,e,t),E(this,e,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(e,t,r){lt(this,e,t),E(this,e,n=>{this.i._attachProtoVectorListener(n,r||!1)})}attachAudioListener(e,t,r){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),qe(this,e,(n,o)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),t(n,o)}),E(this,e,n=>{this.i._attachAudioListener(n,r||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends Ia{get fa(){return this.i}ra(e,t,r){E(this,t,n=>{let[o,s]=va(this,e,n);this.fa._addBoundTextureAsImageToStream(n,o,s,r)})}V(e,t){qe(this,e,t),E(this,e,r=>{this.fa._attachImageListener(r)})}da(e,t){lt(this,e,t),E(this,e,r=>{this.fa._attachImageVectorListener(r)})}})),Ia,Be=class extends O2{};async function M(e,t,r){return async function(n,o,s,a){return I2(n,o,s,a)}(e,r.canvas??(Sc()?void 0:document.createElement("canvas")),t,r)}function Uc(e,t,r,n){if(e.U){let s=new nc;if(r?.regionOfInterest){if(!e.qa)throw Error("This task doesn't support region-of-interest.");var o=r.regionOfInterest;if(o.left>=o.right||o.top>=o.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(o.left<0||o.top<0||o.right>1||o.bottom>1)throw Error("Expected RectF values to be in [0,1].");v(s,1,(o.left+o.right)/2),v(s,2,(o.top+o.bottom)/2),v(s,4,o.right-o.left),v(s,3,o.bottom-o.top)}else v(s,1,.5),v(s,2,.5),v(s,4,1),v(s,3,1);if(r?.rotationDegrees){if(r?.rotationDegrees%90!=0)throw Error("Expected rotation to be a multiple of 90\xB0.");if(v(s,5,-Math.PI*r.rotationDegrees/180),r?.rotationDegrees%180!=0){let[a,i]=Cc(t);r=te(s,3)*i/a,o=te(s,4)*a/i,v(s,4,r),v(s,3,o)}}e.g.addProtoToStream(s.g(),"mediapipe.NormalizedRect",e.U,n)}e.g.ra(t,e.ba,n??performance.now()),e.finishProcessing()}function De(e,t,r){if(e.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");Uc(e,t,r,e.B+1)}function rt(e,t,r,n){if(!e.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");Uc(e,t,r,n)}function zt(e,t,r,n){var o=t.data;let s=t.width,a=s*(t=t.height);if((o instanceof Uint8Array||o instanceof Float32Array)&&o.length!==a)throw Error("Unsupported channel count: "+o.length/a);return e=new ae([o],r,!1,e.g.i.canvas,e.P,s,t),n?e.clone():e}var Ee=class extends Vr{constructor(e,t,r,n){super(e),this.g=e,this.ba=t,this.U=r,this.qa=n,this.P=new nr}l(e,t=!0){if("runningMode"in e&&Er(this.baseOptions,2,!!e.runningMode&&e.runningMode!=="IMAGE"),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};Ee.prototype.close=Ee.prototype.close;var Ie=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},T(e=this.h=new bn,0,1,t=new $),v(this.h,2,.5),v(this.h,3,.3)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&v(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&v(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}D(e,t){return this.j={detections:[]},De(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect_in"),P(e,"detections");let t=new ke;Xe(t,x2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect_in"),F(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(n,o)=>{for(let s of n)n=ec(s),this.j.detections.push(wc(n));m(this,o)}),this.g.attachEmptyPacketListener("detections",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ie.prototype.detectForVideo=Ie.prototype.F,Ie.prototype.detect=Ie.prototype.D,Ie.prototype.setOptions=Ie.prototype.o,Ie.createFromModelPath=async function(e,t){return M(Ie,e,{baseOptions:{modelAssetPath:t}})},Ie.createFromModelBuffer=function(e,t){return M(Ie,e,{baseOptions:{modelAssetBuffer:t}})},Ie.createFromOptions=function(e,t){return M(Ie,e,t)};var fs=ze([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),ps=ze([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),ms=ze([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Oc=ze([474,475],[475,476],[476,477],[477,474]),gs=ze([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),xs=ze([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Pc=ze([469,470],[470,471],[471,472],[472,469]),ys=ze([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),Bc=[...fs,...ps,...ms,...gs,...xs,...ys],Dc=ze([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function Ma(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Q=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,T(e=this.h=new cc,0,1,t=new $),this.v=new ic,T(this.h,0,3,this.v),this.s=new bn,T(this.h,0,2,this.s),tt(this.s,4,1),v(this.s,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numFaces"in e&&tt(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&v(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&v(this.v,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}D(e,t){return Ma(this),De(this,e,t),this.j}F(e,t,r){return Ma(this),rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"face_landmarks");let t=new ke;Xe(t,v2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"NORM_LANDMARKS:face_landmarks"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("face_landmarks",(n,o)=>{for(let s of n)n=kr(s),this.j.faceLandmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{m(this,n)}),this.outputFaceBlendshapes&&(P(e,"blendshapes"),F(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,o)=>{if(this.outputFaceBlendshapes)for(let s of n)n=En(s),this.j.faceBlendshapes.push(us(n.g()??[]));m(this,o)}),this.g.attachEmptyPacketListener("blendshapes",n=>{m(this,n)})),this.outputFacialTransformationMatrixes&&(P(e,"face_geometry"),F(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,o)=>{if(this.outputFacialTransformationMatrixes)for(let s of n)(n=O(y2(s),u2,2))&&this.j.facialTransformationMatrixes.push({rows:je(Oe(n,1),0)??0,columns:je(Oe(n,2),0)??0,data:Ct(n,3,At,St()).slice()??[]});m(this,o)}),this.g.attachEmptyPacketListener("face_geometry",n=>{m(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Q.prototype.detectForVideo=Q.prototype.F,Q.prototype.detect=Q.prototype.D,Q.prototype.setOptions=Q.prototype.o,Q.createFromModelPath=function(e,t){return M(Q,e,{baseOptions:{modelAssetPath:t}})},Q.createFromModelBuffer=function(e,t){return M(Q,e,{baseOptions:{modelAssetBuffer:t}})},Q.createFromOptions=function(e,t){return M(Q,e,t)},Q.FACE_LANDMARKS_LIPS=fs,Q.FACE_LANDMARKS_LEFT_EYE=ps,Q.FACE_LANDMARKS_LEFT_EYEBROW=ms,Q.FACE_LANDMARKS_LEFT_IRIS=Oc,Q.FACE_LANDMARKS_RIGHT_EYE=gs,Q.FACE_LANDMARKS_RIGHT_EYEBROW=xs,Q.FACE_LANDMARKS_RIGHT_IRIS=Pc,Q.FACE_LANDMARKS_FACE_OVAL=ys,Q.FACE_LANDMARKS_CONTOURS=Bc,Q.FACE_LANDMARKS_TESSELATION=Dc;var Je=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!0),T(e=this.j=new hc,0,1,t=new $)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){return super.l(e)}Oa(e,t,r){let n=typeof t!="function"?t:{};if(this.h=typeof t=="function"?t:r,De(this,e,n??{}),!this.h)return this.s}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"stylized_image");let t=new ke;Xe(t,E2,this.j);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"STYLIZED_IMAGE:stylized_image"),r.o(t),Le(e,r),this.g.V("stylized_image",(n,o)=>{var s=!this.h,a=n.data,i=n.width;let c=i*(n=n.height);if(a instanceof Uint8Array)if(a.length===3*c){let l=new Uint8ClampedArray(4*c);for(let h=0;h<c;++h)l[4*h]=a[3*h],l[4*h+1]=a[3*h+1],l[4*h+2]=a[3*h+2],l[4*h+3]=255;a=new ImageData(l,i,n)}else{if(a.length!==4*c)throw Error("Unsupported channel count: "+a.length/c);a=new ImageData(new Uint8ClampedArray(a.buffer,a.byteOffset,a.length),i,n)}else if(!(a instanceof WebGLTexture))throw Error(`Unsupported format: ${a.constructor.name}`);i=new he([a],!1,!1,this.g.i.canvas,this.P,i,n),this.s=s=s?i.clone():i,this.h&&this.h(s),m(this,o)}),this.g.attachEmptyPacketListener("stylized_image",n=>{this.s=null,this.h&&this.h(null),m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Je.prototype.stylize=Je.prototype.Oa,Je.prototype.setOptions=Je.prototype.o,Je.createFromModelPath=function(e,t){return M(Je,e,{baseOptions:{modelAssetPath:t}})},Je.createFromModelBuffer=function(e,t){return M(Je,e,{baseOptions:{modelAssetBuffer:t}})},Je.createFromOptions=function(e,t){return M(Je,e,t)};var vs=ze([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function Fa(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function Ua(e){return e.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function Oa(e,t=!0){let r=[];for(let o of e){var n=En(o);e=[];for(let s of n.g())n=t&&Oe(s,1)!=null?je(Oe(s,1),0):-1,e.push({score:te(s,2)??0,index:n,categoryName:et(s,3)??"",displayName:et(s,4)??""});r.push(e)}return r}var Te=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],T(e=this.j=new fc,0,1,t=new $),this.s=new ss,T(this.j,0,2,this.s),this.C=new os,T(this.s,0,3,this.C),this.v=new dc,T(this.s,0,2,this.v),this.h=new b2,T(this.j,0,3,this.h),v(this.v,2,.5),v(this.s,4,.5),v(this.C,2,.5)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){if(tt(this.v,3,e.numHands??1),"minHandDetectionConfidence"in e&&v(this.v,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.s,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&v(this.C,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new Ut,r=t,n=co(e.cannedGesturesClassifierOptions,O(this.h,Ut,3)?.h());T(r,0,2,n),T(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&O(this.h,Ut,3)?.g();return e.customGesturesClassifierOptions?(T(r=t=new Ut,0,2,n=co(e.customGesturesClassifierOptions,O(this.h,Ut,4)?.h())),T(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&O(this.h,Ut,4)?.g(),this.l(e)}Ja(e,t){return Fa(this),De(this,e,t),Ua(this)}Ka(e,t,r){return Fa(this),rt(this,e,r,t),Ua(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"hand_gestures"),P(e,"hand_landmarks"),P(e,"world_hand_landmarks"),P(e,"handedness");let t=new ke;Xe(t,T2,this.j);let r=new xe;Ce(r,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"HAND_GESTURES:hand_gestures"),F(r,"LANDMARKS:hand_landmarks"),F(r,"WORLD_LANDMARKS:world_hand_landmarks"),F(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(n,o)=>{for(let s of n){n=kr(s);let a=[];for(let i of ct(n,rc,1))a.push({x:te(i,1)??0,y:te(i,2)??0,z:te(i,3)??0,visibility:te(i,4)??0});this.landmarks.push(a)}m(this,o)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,o)=>{for(let s of n){n=Nt(s);let a=[];for(let i of ct(n,tc,1))a.push({x:te(i,1)??0,y:te(i,2)??0,z:te(i,3)??0,visibility:te(i,4)??0});this.worldLandmarks.push(a)}m(this,o)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,o)=>{this.gestures.push(...Oa(n,!1)),m(this,o)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{m(this,n)}),this.g.attachProtoVectorListener("handedness",(n,o)=>{this.handedness.push(...Oa(n)),m(this,o)}),this.g.attachEmptyPacketListener("handedness",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function Pa(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Te.prototype.recognizeForVideo=Te.prototype.Ka,Te.prototype.recognize=Te.prototype.Ja,Te.prototype.setOptions=Te.prototype.o,Te.createFromModelPath=function(e,t){return M(Te,e,{baseOptions:{modelAssetPath:t}})},Te.createFromModelBuffer=function(e,t){return M(Te,e,{baseOptions:{modelAssetBuffer:t}})},Te.createFromOptions=function(e,t){return M(Te,e,t)},Te.HAND_CONNECTIONS=vs;var _e=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],T(e=this.h=new ss,0,1,t=new $),this.s=new os,T(this.h,0,3,this.s),this.j=new dc,T(this.h,0,2,this.j),tt(this.j,3,1),v(this.j,2,.5),v(this.s,2,.5),v(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numHands"in e&&tt(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&v(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&v(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}D(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],De(this,e,t),Pa(this)}F(e,t,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],rt(this,e,r,t),Pa(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"hand_landmarks"),P(e,"world_hand_landmarks"),P(e,"handedness");let t=new ke;Xe(t,_2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"LANDMARKS:hand_landmarks"),F(r,"WORLD_LANDMARKS:world_hand_landmarks"),F(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(n,o)=>{for(let s of n)n=kr(s),this.landmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,o)=>{for(let s of n)n=Nt(s),this.worldLandmarks.push(xr(n));m(this,o)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("handedness",(n,o)=>{var s=this.handedness,a=s.push;let i=[];for(let c of n){n=En(c);let l=[];for(let h of n.g())l.push({score:te(h,2)??0,index:je(Oe(h,1),0)??-1,categoryName:et(h,3)??"",displayName:et(h,4)??""});i.push(l)}a.call(s,...i),m(this,o)}),this.g.attachEmptyPacketListener("handedness",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};_e.prototype.detectForVideo=_e.prototype.F,_e.prototype.detect=_e.prototype.D,_e.prototype.setOptions=_e.prototype.o,_e.createFromModelPath=function(e,t){return M(_e,e,{baseOptions:{modelAssetPath:t}})},_e.createFromModelBuffer=function(e,t){return M(_e,e,{baseOptions:{modelAssetBuffer:t}})},_e.createFromOptions=function(e,t){return M(_e,e,t)},_e.HAND_CONNECTIONS=vs;var Nc=ze([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function Ba(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function Da(e){try{if(!e.C)return e.h;e.C(e.h)}finally{An(e)}}function Br(e,t){e=kr(e),t.push(Tn(e))}var K=class extends Ee{constructor(e,t){super(new Be(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,T(e=this.j=new yc,0,1,t=new $),this.K=new os,T(this.j,0,2,this.K),this.aa=new A2,T(this.j,0,3,this.aa),this.s=new bn,T(this.j,0,4,this.s),this.I=new ic,T(this.j,0,5,this.I),this.v=new gc,T(this.j,0,6,this.v),this.L=new xc,T(this.j,0,7,this.L),v(this.s,2,.5),v(this.s,3,.3),v(this.I,2,.5),v(this.v,2,.5),v(this.v,3,.3),v(this.L,2,.5),v(this.K,2,.5)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&v(this.s,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&v(this.s,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&v(this.I,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&v(this.v,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&v(this.v,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&v(this.L,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&v(this.K,2,e.minHandLandmarksConfidence??.5),this.l(e)}D(e,t,r){let n=typeof t!="function"?t:{};return this.C=typeof t=="function"?t:r,Ba(this),De(this,e,n),Da(this)}F(e,t,r,n){let o=typeof r!="function"?r:{};return this.C=typeof r=="function"?r:n,Ba(this),rt(this,e,o,t),Da(this)}m(){var e=new be;Y(e,"input_frames_image"),P(e,"pose_landmarks"),P(e,"pose_world_landmarks"),P(e,"face_landmarks"),P(e,"left_hand_landmarks"),P(e,"left_hand_world_landmarks"),P(e,"right_hand_landmarks"),P(e,"right_hand_world_landmarks");let t=new ke,r=new na;to(r,1,Jt("type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),""),function(o,s){if(s!=null)if(Array.isArray(s))X(o,2,cn(s,Mo,void 0,void 0,!1));else{if(!(typeof s=="string"||s instanceof at||_r(s)))throw Error("invalid value in Any.value field: "+s+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");to(o,2,_o(s,!1),Mt())}}(r,this.j.g());let n=new xe;Ce(n,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),$r(n,8,na,r),H(n,"IMAGE:input_frames_image"),F(n,"POSE_LANDMARKS:pose_landmarks"),F(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),F(n,"FACE_LANDMARKS:face_landmarks"),F(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),F(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),F(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),F(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(t),Le(e,n),_n(this,e),this.g.attachProtoListener("pose_landmarks",(o,s)=>{Br(o,this.h.poseLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("pose_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("pose_world_landmarks",(o,s)=>{var a=this.h.poseWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("pose_world_landmarks",o=>{m(this,o)}),this.outputPoseSegmentationMasks&&(F(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Xt(this,"pose_segmentation_mask"),this.g.V("pose_segmentation_mask",(o,s)=>{this.h.poseSegmentationMasks=[zt(this,o,!0,!this.C)],m(this,s)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",o=>{this.h.poseSegmentationMasks=[],m(this,o)})),this.g.attachProtoListener("face_landmarks",(o,s)=>{Br(o,this.h.faceLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("face_landmarks",o=>{m(this,o)}),this.outputFaceBlendshapes&&(P(e,"extra_blendshapes"),F(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(o,s)=>{var a=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(o=En(o),a.push(us(o.g()??[]))),m(this,s)}),this.g.attachEmptyPacketListener("extra_blendshapes",o=>{m(this,o)})),this.g.attachProtoListener("left_hand_landmarks",(o,s)=>{Br(o,this.h.leftHandLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("left_hand_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("left_hand_world_landmarks",(o,s)=>{var a=this.h.leftHandWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("right_hand_landmarks",(o,s)=>{Br(o,this.h.rightHandLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("right_hand_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("right_hand_world_landmarks",(o,s)=>{var a=this.h.rightHandWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",o=>{m(this,o)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};K.prototype.detectForVideo=K.prototype.F,K.prototype.detect=K.prototype.D,K.prototype.setOptions=K.prototype.o,K.createFromModelPath=function(e,t){return M(K,e,{baseOptions:{modelAssetPath:t}})},K.createFromModelBuffer=function(e,t){return M(K,e,{baseOptions:{modelAssetBuffer:t}})},K.createFromOptions=function(e,t){return M(K,e,t)},K.HAND_CONNECTIONS=vs,K.POSE_CONNECTIONS=Nc,K.FACE_LANDMARKS_LIPS=fs,K.FACE_LANDMARKS_LEFT_EYE=ps,K.FACE_LANDMARKS_LEFT_EYEBROW=ms,K.FACE_LANDMARKS_LEFT_IRIS=Oc,K.FACE_LANDMARKS_RIGHT_EYE=gs,K.FACE_LANDMARKS_RIGHT_EYEBROW=xs,K.FACE_LANDMARKS_RIGHT_IRIS=Pc,K.FACE_LANDMARKS_FACE_OVAL=ys,K.FACE_LANDMARKS_CONTOURS=Bc,K.FACE_LANDMARKS_TESSELATION=Dc;var Me=class extends Ee{constructor(e,t){super(new Be(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},T(e=this.h=new vc,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return T(this.h,0,2,co(e,O(this.h,ts,2))),this.l(e)}ta(e,t){return this.j={classifications:[]},De(this,e,t),this.j}ua(e,t,r){return this.j={classifications:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"input_image"),Y(e,"norm_rect"),P(e,"classifications");let t=new ke;Xe(t,R2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),H(r,"IMAGE:input_image"),H(r,"NORM_RECT:norm_rect"),F(r,"CLASSIFICATIONS:classifications"),r.o(t),Le(e,r),this.g.attachProtoListener("classifications",(n,o)=>{this.j=function(s){let a={classifications:ct(s,l2,1).map(i=>us(O(i,Qi,4)?.g()??[],je(Oe(i,2),0),et(i,3)))};return zr(vt(s,2))!=null&&(a.timestampMs=je(zr(vt(s,2)),0)),a}(d2(n)),m(this,o)}),this.g.attachEmptyPacketListener("classifications",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Me.prototype.classifyForVideo=Me.prototype.ua,Me.prototype.classify=Me.prototype.ta,Me.prototype.setOptions=Me.prototype.o,Me.createFromModelPath=function(e,t){return M(Me,e,{baseOptions:{modelAssetPath:t}})},Me.createFromModelBuffer=function(e,t){return M(Me,e,{baseOptions:{modelAssetBuffer:t}})},Me.createFromOptions=function(e,t){return M(Me,e,t)};var Ae=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!0),this.h=new Ec,this.embeddings={embeddings:[]},T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){var t=this.h,r=O(this.h,da,2);return r=r?r.clone():new da,e.l2Normalize!==void 0?Er(r,1,e.l2Normalize):"l2Normalize"in e&&X(r,1),e.quantize!==void 0?Er(r,2,e.quantize):"quantize"in e&&X(r,2),T(t,0,2,r),this.l(e)}Aa(e,t){return De(this,e,t),this.embeddings}Ba(e,t,r){return rt(this,e,r,t),this.embeddings}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"embeddings_out");let t=new ke;Xe(t,w2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"EMBEDDINGS:embeddings_out"),r.o(t),Le(e,r),this.g.attachProtoListener("embeddings_out",(n,o)=>{n=m2(n),this.embeddings=function(s){return{embeddings:ct(s,p2,1).map(a=>{let i={headIndex:je(Oe(a,3),0)??-1,headName:et(a,4)??""};if(xi(a,la,Vn(a,1))!==void 0)a=Ct(a=O(a,la,Vn(a,1)),1,At,St()),i.floatEmbedding=a.slice();else{let c=new Uint8Array(0);i.quantizedEmbedding=O(a,f2,Vn(a,2))?.pa()?.h()??c}return i}),timestampMs:je(zr(vt(s,2)),0)}}(n),m(this,o)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ae.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=xa(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=xa(ga(e.quantizedEmbedding),ga(t.quantizedEmbedding))}return e},Ae.prototype.embedForVideo=Ae.prototype.Ba,Ae.prototype.embed=Ae.prototype.Aa,Ae.prototype.setOptions=Ae.prototype.o,Ae.createFromModelPath=function(e,t){return M(Ae,e,{baseOptions:{modelAssetPath:t}})},Ae.createFromModelBuffer=function(e,t){return M(Ae,e,{baseOptions:{modelAssetBuffer:t}})},Ae.createFromOptions=function(e,t){return M(Ae,e,t)};var fo=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){this.confidenceMasks?.forEach(e=>{e.close()}),this.categoryMask?.close()}};function Na(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function Ga(e){try{let t=new fo(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{An(e)}}fo.prototype.close=fo.prototype.close;var de=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new cs,this.v=new bc,T(this.h,0,3,this.v),T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?X(this.h,2,Jt(e.displayNamesLocale)):"displayNamesLocale"in e&&X(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}J(){(function(e){let t=ct(e.ea(),xe,1).filter(r=>et(r,1).includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(e.s=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(O(t[0],ke,7)?.l()?.g()??new Map).forEach((r,n)=>{e.s[Number(n)]=et(r,1)})})(this)}segment(e,t,r){let n=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:r,Na(this),De(this,e,n),Ga(this)}Ma(e,t,r,n){let o=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,Na(this),rt(this,e,o,t),Ga(this)}Ea(){return this.s}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect");let t=new ke;Xe(t,_c,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),r.o(t),Le(e,r),_n(this,e),this.outputConfidenceMasks&&(P(e,"confidence_masks"),F(r,"CONFIDENCE_MASKS:confidence_masks"),Xt(this,"confidence_masks"),this.g.da("confidence_masks",(n,o)=>{this.confidenceMasks=n.map(s=>zt(this,s,!0,!this.j)),m(this,o)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],m(this,n)})),this.outputCategoryMask&&(P(e,"category_mask"),F(r,"CATEGORY_MASK:category_mask"),Xt(this,"category_mask"),this.g.V("category_mask",(n,o)=>{this.categoryMask=zt(this,n,!1,!this.j),m(this,o)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,m(this,n)})),P(e,"quality_scores"),F(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,o)=>{this.qualityScores=n,m(this,o)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};de.prototype.getLabels=de.prototype.Ea,de.prototype.segmentForVideo=de.prototype.Ma,de.prototype.segment=de.prototype.segment,de.prototype.setOptions=de.prototype.o,de.createFromModelPath=function(e,t){return M(de,e,{baseOptions:{modelAssetPath:t}})},de.createFromModelBuffer=function(e,t){return M(de,e,{baseOptions:{modelAssetBuffer:t}})},de.createFromOptions=function(e,t){return M(de,e,t)};var po=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){this.confidenceMasks?.forEach(e=>{e.close()}),this.categoryMask?.close()}};po.prototype.close=po.prototype.close;var P2=class extends x{constructor(e){super(e)}},Ot=[0,ee,-2],en=[0,ot,-3,q,ot,-1],Va=[0,en],ja=[0,en,ee,-1],Kn=class extends x{constructor(e){super(e)}},Wa=[0,ot,-1,q],B2=class extends x{constructor(){super()}},Xa=class extends x{constructor(e){super(e)}},mo=[1,2,3,4,5,6,7,8,9,10,14,15],Gc=class extends x{constructor(){super()}};Gc.prototype.g=vn([0,ie,[0,mo,N,en,N,[0,en,Ot],N,Va,N,[0,Va,Ot],N,Wa,N,[0,ot,-3,q,We],N,[0,ot,-3,q],N,[0,D,ot,-2,q,ee,q,-1,2,ot,Ot],N,ja,N,[0,ja,Ot],ot,Ot,D,N,[0,ot,-3,q,Ot,-1],N,[0,ie,Wa]],D,[0,D,ee,-1,q]]);var Qe=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new cs,this.s=new bc,T(this.h,0,3,this.s),T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}segment(e,t,r,n){let o=typeof r!="function"?r:{};this.j=typeof r=="function"?r:n,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.B+1,n=new Gc;let s=new Xa;var a=new P2;if(tt(a,1,255),T(s,0,12,a),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var i=new Kn;Er(i,3,!0),v(i,1,t.keypoint.x),v(i,2,t.keypoint.y),mr(s,5,mo,i)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(i of(a=new B2,t.scribble))Er(t=new Kn,3,!0),v(t,1,i.x),v(t,2,i.y),$r(a,1,Kn,t);mr(s,15,mo,a)}$r(n,1,Xa,s),this.g.addProtoToStream(n.g(),"drishti.RenderData","roi_in",r),De(this,e,o);e:{try{let l=new po(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var c=l;break e}this.j(l)}finally{An(this)}c=void 0}return c}m(){var e=new be;Y(e,"image_in"),Y(e,"roi_in"),Y(e,"norm_rect_in");let t=new ke;Xe(t,_c,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),H(r,"IMAGE:image_in"),H(r,"ROI:roi_in"),H(r,"NORM_RECT:norm_rect_in"),r.o(t),Le(e,r),_n(this,e),this.outputConfidenceMasks&&(P(e,"confidence_masks"),F(r,"CONFIDENCE_MASKS:confidence_masks"),Xt(this,"confidence_masks"),this.g.da("confidence_masks",(n,o)=>{this.confidenceMasks=n.map(s=>zt(this,s,!0,!this.j)),m(this,o)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],m(this,n)})),this.outputCategoryMask&&(P(e,"category_mask"),F(r,"CATEGORY_MASK:category_mask"),Xt(this,"category_mask"),this.g.V("category_mask",(n,o)=>{this.categoryMask=zt(this,n,!1,!this.j),m(this,o)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,m(this,n)})),P(e,"quality_scores"),F(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,o)=>{this.qualityScores=n,m(this,o)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Qe.prototype.segment=Qe.prototype.segment,Qe.prototype.setOptions=Qe.prototype.o,Qe.createFromModelPath=function(e,t){return M(Qe,e,{baseOptions:{modelAssetPath:t}})},Qe.createFromModelBuffer=function(e,t){return M(Qe,e,{baseOptions:{modelAssetBuffer:t}})},Qe.createFromOptions=function(e,t){return M(Qe,e,t)};var Fe=class extends Ee{constructor(e,t){super(new Be(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},T(e=this.h=new Ac,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?X(this.h,2,Jt(e.displayNamesLocale)):"displayNamesLocale"in e&&X(this.h,2),e.maxResults!==void 0?tt(this.h,3,e.maxResults):"maxResults"in e&&X(this.h,3),e.scoreThreshold!==void 0?v(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&X(this.h,4),e.categoryAllowlist!==void 0?qr(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&X(this.h,5),e.categoryDenylist!==void 0?qr(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&X(this.h,6),this.l(e)}D(e,t){return this.j={detections:[]},De(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"input_frame_gpu"),Y(e,"norm_rect"),P(e,"detections");let t=new ke;Xe(t,S2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.ObjectDetectorGraph"),H(r,"IMAGE:input_frame_gpu"),H(r,"NORM_RECT:norm_rect"),F(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(n,o)=>{for(let s of n)n=ec(s),this.j.detections.push(wc(n));m(this,o)}),this.g.attachEmptyPacketListener("detections",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Fe.prototype.detectForVideo=Fe.prototype.F,Fe.prototype.detect=Fe.prototype.D,Fe.prototype.setOptions=Fe.prototype.o,Fe.createFromModelPath=async function(e,t){return M(Fe,e,{baseOptions:{modelAssetPath:t}})},Fe.createFromModelBuffer=function(e,t){return M(Fe,e,{baseOptions:{modelAssetBuffer:t}})},Fe.createFromOptions=function(e,t){return M(Fe,e,t)};var go=class{constructor(e,t,r){this.landmarks=e,this.worldLandmarks=t,this.segmentationMasks=r}close(){this.segmentationMasks?.forEach(e=>{e.close()})}};function Ha(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function Ya(e){try{let t=new go(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.s)return t;e.s(t)}finally{An(e)}}go.prototype.close=go.prototype.close;var Re=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,T(e=this.h=new Rc,0,1,t=new $),this.v=new xc,T(this.h,0,3,this.v),this.j=new gc,T(this.h,0,2,this.j),tt(this.j,4,1),v(this.j,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numPoses"in e&&tt(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&v(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&v(this.v,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}D(e,t,r){let n=typeof t!="function"?t:{};return this.s=typeof t=="function"?t:r,Ha(this),De(this,e,n),Ya(this)}F(e,t,r,n){let o=typeof r!="function"?r:{};return this.s=typeof r=="function"?r:n,Ha(this),rt(this,e,o,t),Ya(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"normalized_landmarks"),P(e,"world_landmarks"),P(e,"segmentation_masks");let t=new ke;Xe(t,C2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"NORM_LANDMARKS:normalized_landmarks"),F(r,"WORLD_LANDMARKS:world_landmarks"),r.o(t),Le(e,r),_n(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(n,o)=>{this.landmarks=[];for(let s of n)n=kr(s),this.landmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],m(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,o)=>{this.worldLandmarks=[];for(let s of n)n=Nt(s),this.worldLandmarks.push(xr(n));m(this,o)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],m(this,n)}),this.outputSegmentationMasks&&(F(r,"SEGMENTATION_MASK:segmentation_masks"),Xt(this,"segmentation_masks"),this.g.da("segmentation_masks",(n,o)=>{this.segmentationMasks=n.map(s=>zt(this,s,!0,!this.s)),m(this,o)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],m(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Re.prototype.detectForVideo=Re.prototype.F,Re.prototype.detect=Re.prototype.D,Re.prototype.setOptions=Re.prototype.o,Re.createFromModelPath=function(e,t){return M(Re,e,{baseOptions:{modelAssetPath:t}})},Re.createFromModelBuffer=function(e,t){return M(Re,e,{baseOptions:{modelAssetBuffer:t}})},Re.createFromOptions=function(e,t){return M(Re,e,t)},Re.POSE_CONNECTIONS=Nc;var _=(e,t="AssertError")=>{if(!e)throw new Error(t,{cause:e});return e};var Es=e=>e;var bs=(e,...t)=>{let r=t.reduce((n,o)=>s=>o(n(s)),Es);return(...n)=>r(e(...n))};var N2="utils/memoize/noValue",Ll=Symbol(N2);var G2=e=>`(${e})`;var Vc=e=>G2(`?:${e}`),V2=e=>`${Vc(e)}?`,j2=e=>`${Vc(e)}*`;var W2=e=>`^${e}`,X2=e=>`${e}$`,H2=e=>typeof e=="function",Y2=e=>t=>H2(t)?t(e):t;var z2=()=>e=>e,kn=(e,t=z2)=>r=>n=>bs(Y2(n),t(n),e)(r);var Fl=kn(e=>V2(e)),Ul=kn(e=>j2(e));var Ol=kn(e=>W2(e)),Pl=kn(e=>X2(e));var z={Closed:"closed",Closing:"closing",Destroyed:"destroyed",Destroying:"destroying",Error:"Error",Idle:"idle",New:"new",Opened:"opened",Opening:"opening",Processing:"processing",Updated:"updated",Updating:"updating"},jc={None:"none",Blur:"blur",Overlay:"overlay"},Wc={WebGL:"webgl",WebGPU:"webgpu"},C={ContextCreationError:"ContextCreationError",ContextLost:"ContextLost",ContextRestored:"ContextRestored",Error:"Error",ProcessorRestarted:"ProcessorRestarted",SamplingError:"SamplingError"};var K2=e=>!!(typeof e=="string"&&Object.values(C).includes(e)),Sn=e=>K2(e)?e:C.Error,Cn=e=>e instanceof Error?e.message:String(e),Ln=e=>{let t=new Set(Object.keys(e));return r=>{for(let n in r)t.has(n)&&typeof e[n]==typeof r[n]&&(e[n]=r[n])}},Xc=e=>{let t=new Map(e),r=new Set,n=async a=>{let c=await(await fetch(a)).blob();return await createImageBitmap(c)},o=async a=>{let i=t.get(a);if(!i){if(r.has(a))return null;r.add(a);let c=await n(a);return t.set(a,c),r.delete(a),c}return i},s=a=>(t.get(a)?.close(),t.delete(a));return{tryFetchingImage:o,setImage:(a,i)=>{t.has(a)&&s(a),t.set(a,i)},getImage:a=>t.get(a)??null,removeImage:s,clear:()=>{for(let a of t.values())a.close();t.clear()}}},In=(e,t)=>r=>Math.min(Math.max(r,e),t);var Hc=(e,t,r,n)=>{if(!e||!t||!r||!n||e*n===r*t)return{sx:0,sy:0,sw:e,sh:t,dx:0,dy:0,dw:r,dh:n};let o=e/t,s=r/n;if(o>s){let l=Math.ceil(e*s)/o,h=Math.abs(e-l);return{sx:Math.ceil(h/2),sy:0,sw:l,sh:t,dx:0,dy:0,dw:r,dh:n}}let a=Math.ceil(t*o)/s,i=Math.abs(t-a);return{sx:0,sy:Math.ceil(i/2),sw:e,sh:a,dx:0,dy:0,dw:r,dh:n}},or=e=>{let t={};return new Proxy(t,{get(r,n,o){return r[n]||(r[n]=e[n]?.(t)),Reflect.get(r,n,o)}})},Yc=(e,t,r)=>{let n=a=>{a.preventDefault(),r?.(),t.contextLost(a.statusMessage)},o=a=>{t.contextRestored(a.statusMessage)},s=a=>{t.contextCreationError(a.statusMessage)};return e.addEventListener("webglcontextlost",n),e.addEventListener("webglcontextrestored",o),e.addEventListener("webglcontextcreationerror",s),()=>{e.removeEventListener("webglcontextlost",n),e.removeEventListener("webglcontextrestored",o),e.removeEventListener("webglcontextcreationerror",s)}};var zc=(e,t,r)=>{let n=navigator.gpu.getPreferredCanvasFormat(),o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");o.configure({device:t,format:n});let s;return{render:a=>(_(!r(),C.ContextLost),s=t.createTexture({label:"Video Frame to Texture",format:"rgba8unorm",size:[a.width,a.height],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT}),t.queue.copyExternalImageToTexture({source:a.frame,flipY:!1},{texture:s},{width:a.width,height:a.height}),t.queue.submit([]),s),release:()=>{s?.destroy()}}};var Ts="@group(0)@binding(0)var mySampler:sampler;@group(0)@binding(1)var bgTexture:texture_2d<f32>;@group(0)@binding(2)var personTexture:texture_2d<f32>;@group(0)@binding(3)var maskTexture:texture_2d<f32>;struct VertexOutput{@builtin(position)Position:vec4f,@location(0)fragUV:vec2f,}@vertex fn vert_main(@builtin(vertex_index)VertexIndex:u32)->VertexOutput{const pos=array(vec2(1.0,1.0),vec2(1.0,-1.0),vec2(-1.0,-1.0),vec2(1.0,1.0),vec2(-1.0,-1.0),vec2(-1.0,1.0),);const uv=array(vec2(1.0,0.0),vec2(1.0,1.0),vec2(0.0,1.0),vec2(1.0,0.0),vec2(0.0,1.0),vec2(0.0,0.0),);var output:VertexOutput;output.Position=vec4(pos[VertexIndex],0.0,1.0);output.fragUV=uv[VertexIndex];return output;}@fragment fn frag_main(@location(0)fragUV:vec2f)->@location(0)vec4f{let bg=textureSample(bgTexture,mySampler,fragUV);let person=textureSample(personTexture,mySampler,fragUV);let mask=textureSample(maskTexture,mySampler,fragUV);var alpha=mask.r;if(alpha<0.5){alpha=0;}return mix(bg,person,alpha);}";var sr=[0,0,0,0];var Kc=(e,t,r,n)=>{let o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");return o.configure({device:t,format:r,alphaMode:"premultiplied"}),{render:(s,a,i)=>{_(!n(),C.ContextLost);let c=t.createRenderPipeline({label:"blender pipeline",layout:"auto",vertex:{module:t.createShaderModule({label:"blender vertex",code:Ts})},fragment:{module:t.createShaderModule({label:"blender fragment",code:Ts}),targets:[{format:r}]}}),l=t.createCommandEncoder({label:"blender encoder"}),h=l.beginRenderPass({label:"blender renderPass",colorAttachments:[{view:o.getCurrentTexture().createView(),clearValue:sr,loadOp:"clear",storeOp:"store"}]});h.setPipeline(c);let p=t.createSampler({addressModeU:"repeat",addressModeV:"repeat",magFilter:"nearest"}),d=t.createBindGroup({layout:c.getBindGroupLayout(0),entries:[{binding:0,resource:p},{binding:1,resource:a.createView()},{binding:2,resource:s.createView()},{binding:3,resource:i.createView()}]});h.setBindGroup(0,d),h.draw(6),h.end();let g=l.finish();t.queue.submit([g])},release:()=>{}}};var _s=e=>e.features.has("bgra8unorm-storage"),$c=async e=>await e?.requestDevice({requiredFeatures:_s(e)?["bgra8unorm-storage"]:[]});var qc="@group(0)@binding(0)var u_sampler:sampler;@group(0)@binding(1)var u_frame:texture_2d<f32>;@group(0)@binding(2)var<uniform> flip:Flip;struct Flip{value:u32,}struct VertexOutput{@builtin(position)Position:vec4f,@location(0)fragUV:vec2f,}fn Downsample(uv:vec2<f32>,halfpixel:vec2<f32>)->vec4<f32>{var sum=textureSample(u_frame,u_sampler,uv)*4.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y+halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y-halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y-halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y+halfpixel.y));return sum/8.0;}fn Upsample(uv:vec2<f32>,halfpixel:vec2<f32>)->vec4<f32>{var sum=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x*2.0,uv.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x*2.0,uv.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x,uv.y+halfpixel.y*2.0));sum+=textureSample(u_frame,u_sampler,vec2(uv.x,uv.y-halfpixel.y*2.0));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y+halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y+halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y-halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y-halfpixel.y))*2.0;return sum/12.0;}@fragment fn frag_main(@location(0)v_texCoord:vec2<f32>)->@location(0)vec4<f32>{let texSize=vec2<f32>(textureDimensions(u_frame));let texel_size=1.0/texSize;let halfpixel=texel_size*0.5;var color:vec4<f32>;if(flip.value!=1u){color=Downsample(v_texCoord,halfpixel);}else{color=Upsample(v_texCoord,halfpixel);}return color;}@vertex fn vert_main(@builtin(vertex_index)VertexIndex:u32)->VertexOutput{const pos=array(vec2(1.0,1.0),vec2(1.0,-1.0),vec2(-1.0,-1.0),vec2(1.0,1.0),vec2(-1.0,-1.0),vec2(-1.0,1.0),);const uv=array(vec2(1.0,0.0),vec2(1.0,1.0),vec2(0.0,1.0),vec2(1.0,0.0),vec2(0.0,1.0),vec2(0.0,0.0),);var output:VertexOutput;output.Position=vec4(pos[VertexIndex],0.0,1.0);output.fragUV=uv[VertexIndex];return output;}";var $2=In(1,9),Jc=(e,t,r,n)=>{let o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");o.configure({device:t,format:r,alphaMode:"premultiplied"});let s=(S,w)=>t.createTexture({format:r,size:[S,w],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),a=S=>{let w=t.createBuffer({size:4,mappedAtCreation:!0,usage:GPUBufferUsage.UNIFORM});return new Uint32Array(w.getMappedRange())[0]=S,w.unmap(),w},i=t.createSampler({magFilter:"linear",minFilter:"linear"}),c=t.createShaderModule({code:qc}),l=t.createRenderPipeline({label:"dual blur render pipeline",layout:"auto",vertex:{module:c,entryPoint:"vert_main",buffers:[]},fragment:{module:c,entryPoint:"frag_main",targets:[{format:r}]},primitive:{topology:"triangle-list"}}),h=[],p=-1,d=-1;function g(S,w,f){let y=$2(S+1),b=!1;if(h.length!==y||p!==w||d!==f){for(let L of h)L.texture.destroy();h=[];for(let L=0;L<y;L++){let I=Math.max(Math.trunc(w/2**L),1),k=Math.max(Math.trunc(f/2**L),1);h.push({texture:s(I,k),width:I,height:k})}p=w,d=f,b=!0}return b}let A=a(0),R=a(1);return{render:(S,w)=>{_(!n(),C.ContextLost),g(w,e.width,e.height);let f=h[0];_(f),t.queue.copyExternalImageToTexture({source:S.frame,flipY:!1},{texture:f.texture},{width:f.width,height:f.height});for(let k=1;k<h.length;k++){let B=h[k-1];_(B);let U=h[k];_(U);let j=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:B.texture.createView()},{binding:2,resource:{buffer:A}}]}),W=t.createCommandEncoder(),le=W.beginRenderPass({colorAttachments:[{view:U.texture.createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});le.setPipeline(l),le.setBindGroup(0,j),le.draw(6),le.end(),t.queue.submit([W.finish()])}for(let k=h.length-2;k>=0;k--){let B=h[k+1];_(B);let U=h[k];_(U);let j=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:B.texture.createView()},{binding:2,resource:{buffer:R}}]}),W=t.createCommandEncoder(),le=W.beginRenderPass({colorAttachments:[{view:U.texture.createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});le.setPipeline(l),le.setBindGroup(0,j),le.draw(6),le.end(),t.queue.submit([W.finish()])}let y=h[0];_(y);let b=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:y.texture.createView()},{binding:2,resource:{buffer:R}}]}),L=t.createCommandEncoder(),I=L.beginRenderPass({colorAttachments:[{view:o.getCurrentTexture().createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});return I.setPipeline(l),I.setBindGroup(0,b),I.draw(6),I.end(),t.queue.submit([L.finish()]),y.texture},release:()=>{for(let S of h)S.texture.destroy();h=[],A.destroy(),R.destroy()}}};var Qc="@group(0)@binding(1)var mask:texture_2d<f32>;@group(0)@binding(2)var prevMask:texture_2d<f32>;@group(0)@binding(3)var outputTex:texture_storage_2d<rgba8unorm,write>;struct Params{maskCombineRatio:f32,foregroundThreshold:f32,}@group(0)@binding(4)var<uniform> params:Params;fn smoothingMask(prevMask:texture_2d<f32>,mask:texture_2d<f32>,uv:vec2<u32>,ratio:f32)->f32{let prevMaskValue=textureLoad(prevMask,uv,0u).r;let currMaskValue=textureLoad(mask,uv,0u).r;let c1=5.68842;let c2=-0.748699;let c3=-57.8051;let c4=291.309;let c5=-624.717;let t=currMaskValue-0.5;let x=t*t;let uncertainty=1.0-min(1.0,x*(c1+x*(c2+x*(c3+x*(c4+x*c5)))));return currMaskValue+(prevMaskValue-currMaskValue)*(uncertainty*ratio);}@compute @workgroup_size(32,1,1)fn main(@builtin(workgroup_id)WorkGroupID:vec3u,@builtin(local_invocation_id)LocalInvocationID:vec3u){let blockDim:u32=128;let baseIndex=vec2i(WorkGroupID.xy*vec2(blockDim,4)+LocalInvocationID.xy*vec2(4,1));for(var r=0;r<4;r++){for(var c=0;c<4;c++){var uv=baseIndex+vec2(c,r);let maskAlpha=smoothingMask(prevMask,mask,vec2<u32>(uv),params.maskCombineRatio);var backgroundMask=maskAlpha;if backgroundMask<params.foregroundThreshold{backgroundMask=0.0;}textureStore(outputTex,uv,vec4<f32>(backgroundMask,backgroundMask,backgroundMask,backgroundMask));}}}";var Zc=(e,t,r)=>{let n=t.createTexture({label:"Smoothed Mask Texture",format:"rgba8unorm",size:[e.width,e.height],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC}),o=t.createBuffer({size:2*4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),s=a=>{t.queue.writeBuffer(o,0,new Float32Array([a.maskCombineRatio,a.foregroundThreshold]))};return{render:(a,i,c)=>{if(_(!r(),C.ContextLost),!i)return a;let l=t.createComputePipeline({label:"smoothing mask pipeline",layout:"auto",compute:{module:t.createShaderModule({label:"smoothing mask compute",code:Qc})}});s(c);let h=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:1,resource:a.createView()},{binding:2,resource:i.createView()},{binding:3,resource:n.createView()},{binding:4,resource:{buffer:o}}]}),p=t.createCommandEncoder({label:"smoothing mask encoder"}),d=p.beginComputePass({label:" smoothing mask compute pass"});d.setPipeline(l),d.setBindGroup(0,h),d.dispatchWorkgroups(Math.ceil(e.width/128),Math.ceil(e.height/4)),d.end();let g=p.finish();return t.queue.submit([g]),n},release:()=>{n.destroy(),o.destroy()}}};var eu=(e,t)=>{let r;return{render:n=>{_(!t(),C.ContextLost);let o=e.createCommandEncoder({label:"texture to texture encoder"});return r=e.createTexture({size:{width:n.width,height:n.height,depthOrArrayLayers:n.depthOrArrayLayers},format:"rgba8unorm",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST}),o.copyTextureToTexture({texture:n},{texture:r},{width:r.width,height:r.height,depthOrArrayLayers:r.depthOrArrayLayers}),e.queue.submit([o.finish()]),r},release:()=>{r?.destroy()}}};var tu=(e,t,r=new OffscreenCanvas(768,432))=>{let n={videoFrameRenderer:()=>{if(!s.device)throw new Error("No device.");return zc(r,s.device,h)},backgroundImageRenderer:()=>{if(!s.device)throw new Error("No device.");return Kc(r,s.device,s.presentationFormat,h)},blurRenderer:()=>{if(!s.device)throw new Error("No device.");return Jc(r,s.device,s.presentationFormat,h)},maskSmoothingRenderer:()=>{if(!s.device)throw new Error("No device.");return Zc(r,s.device,h)},prevMaskRenderer:()=>{if(!s.device)throw new Error("No device.");return eu(s.device,h)},release:p=>()=>{for(let d of Object.keys(p))d!=="release"&&p[d]?.release()}},o=or(n),s={canvas:r,presentationFormat:"rgba8unorm",backend:"webgpu",deviceLost:!1,get videoFrameRenderer(){return o.videoFrameRenderer},get blendRenderer(){return o.backgroundImageRenderer},get blurRenderer(){return o.blurRenderer},get maskSmoothingRenderer(){return o.maskSmoothingRenderer},get prevMaskRenderer(){return o.prevMaskRenderer}},a=Ln(s),i=async()=>{if(!navigator.gpu)throw Error("WebGPU not supported.");s.presentationFormat=_s(e)?navigator.gpu.getPreferredCanvasFormat():"rgba8unorm",s.device=await $c(e),s.device.lost.then(p=>{p.reason!=="destroyed"&&(s.deviceLost=!0,t.contextLost(p.message),t.contextRestored(p.message))})},c=(p,d,g)=>{g&&a(g);let A=s.videoFrameRenderer.render(d),R=s.videoFrameRenderer.render({frame:p,width:d.width,height:d.height,timestamp:d.timestamp}),S=s.maskSmoothingRenderer.render(R,s.prevMask,g);if(g.effects==="blur"){let w=s.blurRenderer.render(d,g.backgroundBlurAmount);s.blendRenderer.render(A,w,S)}else if(g.effects==="overlay"&&g.backgroundImage){let w=s.videoFrameRenderer.render({frame:g.backgroundImage,width:g.backgroundImage.width,height:g.backgroundImage.height,timestamp:d.timestamp});s.blendRenderer.render(A,w,S)}s.prevMask=s.prevMaskRenderer.render(S)},l=()=>{o.release(),s.deviceLost=!1,o=or(n)},h=()=>s.deviceLost;return{init:i,render:c,release:l,isContextLost:h}};var ue={projection:(e,t,r=-1)=>[2/e,0,0,0,2/t*r,0,-1,1*-r,1],translation:(e,t)=>[1,0,0,0,1,0,e,t,1],rotation:e=>{let t=Math.cos(e),r=Math.sin(e);return[t,-r,0,r,t,0,0,0,1]},scaling:(e,t)=>[e,0,0,0,t,0,0,0,1],multiply:(e,t)=>{let r=e[0],n=e[0*3+1],o=e[0*3+2],s=e[1*3+0],a=e[1*3+1],i=e[1*3+2],c=e[2*3+0],l=e[2*3+1],h=e[2*3+2],p=t[0*3+0],d=t[0*3+1],g=t[0*3+2],A=t[1*3+0],R=t[1*3+1],S=t[1*3+2],w=t[2*3+0],f=t[2*3+1],y=t[2*3+2];return[p*r+d*s+g*c,p*n+d*a+g*l,p*o+d*i+g*h,A*r+R*s+S*c,A*n+R*a+S*l,A*o+R*i+S*h,w*r+f*s+y*c,w*n+f*a+y*l,w*o+f*i+y*h]},translate:(e,t,r)=>ue.multiply(e,ue.translation(t,r)),rotate:(e,t)=>ue.multiply(e,ue.rotation(t)),scale:(e,t,r)=>ue.multiply(e,ue.scaling(t,r))};var Mn={VertexShader:WebGLRenderingContext.VERTEX_SHADER,FragmentShader:WebGLRenderingContext.FRAGMENT_SHADER},As={[Mn.VertexShader]:"VertexShader",[Mn.FragmentShader]:"FragmentShader"},q2=e=>typeof e=="string"?e.startsWith("#version 300 es"):!1,ru=e=>{if(!q2(e))throw new Error("Expecting GLSL ES 3.00 shader source")},J2=/ERROR:\s*\d+:(\d+)/gi;function su(e,t="",r=0){let n=[...t.matchAll(J2)],o=new Map(n.map((s,a)=>{if(!s[1]||s.index===void 0)return[0,t];let i=Number.parseInt(s[1],10),c=n[a+1],l=c?c.index:t.length,h=t.substring(s.index,l);return[i-1,h]}));return e.split(`
41
+ `}C(){let e=this.g;e.activeTexture(e.TEXTURE1),this.j=Tt(this,e),e.activeTexture(e.TEXTURE2),this.B=Tt(this,e)}m(){super.m();let e=this.g;this.K=ge(e.getUniformLocation(this.h,"defaultTexture"),"Uniform location"),this.L=ge(e.getUniformLocation(this.h,"overlayTexture"),"Uniform location"),this.I=ge(e.getUniformLocation(this.h,"maskTexture"),"Uniform location")}l(){super.l();let e=this.g;e.uniform1i(this.I,0),e.uniform1i(this.K,1),e.uniform1i(this.L,2)}close(){this.j&&this.g.deleteTexture(this.j),this.B&&this.g.deleteTexture(this.B),super.close()}};function st(e,t){switch(t){case 0:return e.g.find(r=>r instanceof Uint8Array);case 1:return e.g.find(r=>r instanceof Float32Array);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function ho(e){var t=st(e,1);if(!t){if(t=st(e,0))t=new Float32Array(t).map(n=>n/255);else{t=new Float32Array(e.width*e.height);let n=Ht(e);var r=ds(e);if(Rn(r,n,Lc(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"document"in self&&"ontouchend"in self.document){r=new Float32Array(e.width*e.height*4),n.readPixels(0,0,e.width,e.height,n.RGBA,n.FLOAT,r);for(let o=0,s=0;o<t.length;++o,s+=4)t[o]=r[s]}else n.readPixels(0,0,e.width,e.height,n.RED,n.FLOAT,t)}e.g.push(t)}return t}function Lc(e){let t=st(e,2);if(!t){let r=Ht(e);t=Mc(e);let n=ho(e),o=Ic(e);r.texImage2D(r.TEXTURE_2D,0,o,e.width,e.height,0,r.RED,r.FLOAT,n),lo(e)}return t}function Ht(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when initializing the image.");return e.h||(e.h=ge(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function Ic(e){if(e=Ht(e),!Pr)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))Pr=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");Pr=e.R16F}return Pr}function ds(e){return e.l||(e.l=new nr),e.l}function Mc(e){let t=Ht(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=st(e,2);return r||(r=Tt(ds(e),t,e.m?t.LINEAR:t.NEAREST),e.g.push(r),e.j=!0),t.bindTexture(t.TEXTURE_2D,r),r}function lo(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var Pr,ae=class{constructor(e,t,r,n,o,s,a){this.g=e,this.m=t,this.j=r,this.canvas=n,this.l=o,this.width=s,this.height=a,this.j&&--Aa===0&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}Ga(){return!!st(this,0)}ka(){return!!st(this,1)}R(){return!!st(this,2)}ja(){return(t=st(e=this,0))||(t=ho(e),t=new Uint8Array(t.map(r=>255*r)),e.g.push(t)),t;var e,t}ia(){return ho(this)}N(){return Lc(this)}clone(){let e=[];for(let t of this.g){let r;if(t instanceof Uint8Array)r=new Uint8Array(t);else if(t instanceof Float32Array)r=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{let n=Ht(this),o=ds(this);n.activeTexture(n.TEXTURE1),r=Tt(o,n,this.m?n.LINEAR:n.NEAREST),n.bindTexture(n.TEXTURE_2D,r);let s=Ic(this);n.texImage2D(n.TEXTURE_2D,0,s,this.width,this.height,0,n.RED,n.FLOAT,null),n.bindTexture(n.TEXTURE_2D,null),Rn(o,n,r),Sr(o,n,!1,()=>{Mc(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),lo(this)}),ls(o),lo(this)}}e.push(r)}return new ae(e,this.m,this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Ht(this).deleteTexture(st(this,2)),Aa=-1}};ae.prototype.close=ae.prototype.close,ae.prototype.clone=ae.prototype.clone,ae.prototype.getAsWebGLTexture=ae.prototype.N,ae.prototype.getAsFloat32Array=ae.prototype.ia,ae.prototype.getAsUint8Array=ae.prototype.ja,ae.prototype.hasWebGLTexture=ae.prototype.R,ae.prototype.hasFloat32Array=ae.prototype.ka,ae.prototype.hasUint8Array=ae.prototype.Ga;var Aa=250,U2={color:"white",lineWidth:4,radius:6};function zn(e){return{...U2,fillColor:(e=e||{}).color,...e}}function nt(e,t){return e instanceof Function?e(t):e}function Ra(e,t,r){return Math.max(Math.min(t,r),Math.min(Math.max(t,r),e))}function lr(e){if(!e.l)throw Error("CPU rendering requested but CanvasRenderingContext2D not provided.");return e.l}function Tr(e){if(!e.j)throw Error("GPU rendering requested but WebGL2RenderingContext not provided.");return e.j}function wa(e,t,r){if(t.R())r(t.N());else{let n=t.ka()?t.ia():t.ja();e.m=e.m??new nr;let o=Tr(e);r((e=new ae([n],t.m,!1,o.canvas,e.m,t.width,t.height)).N()),e.close()}}function ka(e,t,r,n){let o=function(i){return i.g||(i.g=new M2),i.g}(e),s=Tr(e),a=Array.isArray(r)?new ImageData(new Uint8ClampedArray(r),1,1):r;Sr(o,s,!0,()=>{(function(c,l,h,p){let d=c.g;if(d.activeTexture(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,l),d.activeTexture(d.TEXTURE1),d.bindTexture(d.TEXTURE_2D,c.B),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,h),c.I&&function(g,A){if(g!==A)return!1;g=g.entries(),A=A.entries();for(let[S,w]of g){g=S;let f=w;var R=A.next();if(R.done)return!1;let[y,b]=R.value;if(R=b,g!==y||f[0]!==R[0]||f[1]!==R[1]||f[2]!==R[2]||f[3]!==R[3])return!1}return!!A.next().done}(c.I,p))d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j);else{c.I=p;let g=Array(1024).fill(0);p.forEach((A,R)=>{if(A.length!==4)throw Error(`Color at index ${R} is not a four-channel value.`);g[4*R]=A[0],g[4*R+1]=A[1],g[4*R+2]=A[2],g[4*R+3]=A[3]}),d.activeTexture(d.TEXTURE2),d.bindTexture(d.TEXTURE_2D,c.j),d.texImage2D(d.TEXTURE_2D,0,d.RGBA,256,1,0,d.RGBA,d.UNSIGNED_BYTE,new Uint8Array(g))}})(o,t,a,n),s.clearColor(0,0,0,0),s.clear(s.COLOR_BUFFER_BIT),s.drawArrays(s.TRIANGLE_FAN,0,4);let i=o.g;i.activeTexture(i.TEXTURE0),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE1),i.bindTexture(i.TEXTURE_2D,null),i.activeTexture(i.TEXTURE2),i.bindTexture(i.TEXTURE_2D,null)})}function Sa(e,t,r,n){let o=Tr(e),s=function(c){return c.h||(c.h=new F2),c.h}(e),a=Array.isArray(r)?new ImageData(new Uint8ClampedArray(r),1,1):r,i=Array.isArray(n)?new ImageData(new Uint8ClampedArray(n),1,1):n;Sr(s,o,!0,()=>{var c=s.g;c.activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,t),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,s.j),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,a),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,s.B),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLE_FAN,0,4),o.bindTexture(o.TEXTURE_2D,null),(c=s.g).activeTexture(c.TEXTURE0),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE1),c.bindTexture(c.TEXTURE_2D,null),c.activeTexture(c.TEXTURE2),c.bindTexture(c.TEXTURE_2D,null)})}var me=class{constructor(e,t){e instanceof CanvasRenderingContext2D||e instanceof OffscreenCanvasRenderingContext2D?(this.l=e,this.j=t):this.j=e}za(e,t){if(e){var r=lr(this);t=zn(t),r.save();var n=r.canvas,o=0;for(let s of e)r.fillStyle=nt(t.fillColor,{index:o,from:s}),r.strokeStyle=nt(t.color,{index:o,from:s}),r.lineWidth=nt(t.lineWidth,{index:o,from:s}),(e=new Path2D).arc(s.x*n.width,s.y*n.height,nt(t.radius,{index:o,from:s}),0,2*Math.PI),r.fill(e),r.stroke(e),++o;r.restore()}}ya(e,t,r){if(e&&t){var n=lr(this);r=zn(r),n.save();var o=n.canvas,s=0;for(let a of t){n.beginPath(),t=e[a.start];let i=e[a.end];t&&i&&(n.strokeStyle=nt(r.color,{index:s,from:t,to:i}),n.lineWidth=nt(r.lineWidth,{index:s,from:t,to:i}),n.moveTo(t.x*o.width,t.y*o.height),n.lineTo(i.x*o.width,i.y*o.height)),++s,n.stroke()}n.restore()}}va(e,t){let r=lr(this);t=zn(t),r.save(),r.beginPath(),r.lineWidth=nt(t.lineWidth,{}),r.strokeStyle=nt(t.color,{}),r.fillStyle=nt(t.fillColor,{}),r.moveTo(e.originX,e.originY),r.lineTo(e.originX+e.width,e.originY),r.lineTo(e.originX+e.width,e.originY+e.height),r.lineTo(e.originX,e.originY+e.height),r.lineTo(e.originX,e.originY),r.stroke(),r.fill(),r.restore()}wa(e,t,r=[0,0,0,255]){this.l?function(n,o,s,a){let i=Tr(n);wa(n,o,c=>{ka(n,c,s,a),(c=lr(n)).drawImage(i.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,e,r,t):ka(this,e.N(),r,t)}xa(e,t,r){this.l?function(n,o,s,a){let i=Tr(n);wa(n,o,c=>{Sa(n,c,s,a),(c=lr(n)).drawImage(i.canvas,0,0,c.canvas.width,c.canvas.height)})}(this,e,t,r):Sa(this,e.N(),t,r)}close(){this.g?.close(),this.g=void 0,this.h?.close(),this.h=void 0,this.m?.close(),this.m=void 0}};function Ze(e,t){switch(t){case 0:return e.g.find(r=>r instanceof ImageData);case 1:return e.g.find(r=>typeof ImageBitmap<"u"&&r instanceof ImageBitmap);case 2:return e.g.find(r=>typeof WebGLTexture<"u"&&r instanceof WebGLTexture);default:throw Error(`Type is not supported: ${t}`)}}function Fc(e){var t=Ze(e,0);if(!t){t=Yt(e);let r=wn(e),n=new Uint8Array(e.width*e.height*4);Rn(r,t,jr(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,n),ls(r),t=new ImageData(new Uint8ClampedArray(n.buffer),e.width,e.height),e.g.push(t)}return t}function jr(e){let t=Ze(e,2);if(!t){let r=Yt(e);t=Wr(e);let n=Ze(e,1)||Fc(e);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,n),fr(e)}return t}function Yt(e){if(!e.canvas)throw Error("Conversion to different image formats require that a canvas is passed when iniitializing the image.");return e.h||(e.h=ge(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function wn(e){return e.l||(e.l=new nr),e.l}function Wr(e){let t=Yt(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let r=Ze(e,2);return r||(r=Tt(wn(e),t),e.g.push(r),e.m=!0),t.bindTexture(t.TEXTURE_2D,r),r}function fr(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function Ca(e){let t=Yt(e);return Sr(wn(e),t,!0,()=>function(r,n){let o=r.canvas;if(o.width===r.width&&o.height===r.height)return n();let s=o.width,a=o.height;return o.width=r.width,o.height=r.height,r=n(),o.width=s,o.height=a,r}(e,()=>{if(t.bindFramebuffer(t.FRAMEBUFFER,null),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.drawArrays(t.TRIANGLE_FAN,0,4),!(e.canvas instanceof OffscreenCanvas))throw Error("Conversion to ImageBitmap requires that the MediaPipe Tasks is initialized with an OffscreenCanvas");return e.canvas.transferToImageBitmap()}))}me.prototype.close=me.prototype.close,me.prototype.drawConfidenceMask=me.prototype.xa,me.prototype.drawCategoryMask=me.prototype.wa,me.prototype.drawBoundingBox=me.prototype.va,me.prototype.drawConnectors=me.prototype.ya,me.prototype.drawLandmarks=me.prototype.za,me.lerp=function(e,t,r,n,o){return Ra(n*(1-(e-t)/(r-t))+o*(1-(r-e)/(r-t)),n,o)},me.clamp=Ra,za("DrawingUtils",me);var he=class{constructor(e,t,r,n,o,s,a){this.g=e,this.j=t,this.m=r,this.canvas=n,this.l=o,this.width=s,this.height=a,(this.j||this.m)&&--La===0&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}Fa(){return!!Ze(this,0)}la(){return!!Ze(this,1)}R(){return!!Ze(this,2)}Da(){return Fc(this)}Ca(){var e=Ze(this,1);return e||(jr(this),Wr(this),e=Ca(this),fr(this),this.g.push(e),this.j=!0),e}N(){return jr(this)}clone(){let e=[];for(let t of this.g){let r;if(t instanceof ImageData)r=new ImageData(t.data,this.width,this.height);else if(t instanceof WebGLTexture){let n=Yt(this),o=wn(this);n.activeTexture(n.TEXTURE1),r=Tt(o,n),n.bindTexture(n.TEXTURE_2D,r),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,this.width,this.height,0,n.RGBA,n.UNSIGNED_BYTE,null),n.bindTexture(n.TEXTURE_2D,null),Rn(o,n,r),Sr(o,n,!1,()=>{Wr(this),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.drawArrays(n.TRIANGLE_FAN,0,4),fr(this)}),ls(o),fr(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);jr(this),Wr(this),r=Ca(this),fr(this)}e.push(r)}return new he(e,this.la(),this.R(),this.canvas,this.l,this.width,this.height)}close(){this.j&&Ze(this,1).close(),this.m&&Yt(this).deleteTexture(Ze(this,2)),La=-1}};he.prototype.close=he.prototype.close,he.prototype.clone=he.prototype.clone,he.prototype.getAsWebGLTexture=he.prototype.N,he.prototype.getAsImageBitmap=he.prototype.Ca,he.prototype.getAsImageData=he.prototype.Da,he.prototype.hasWebGLTexture=he.prototype.R,he.prototype.hasImageBitmap=he.prototype.la,he.prototype.hasImageData=he.prototype.Fa;var La=250;function ze(...e){return e.map(([t,r])=>({start:t,end:r}))}var O2=function(e){return class extends e{La(){this.i._registerModelResourcesGraphService()}}}((Ia=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m=typeof this.i._addIntToInputStream=="function",t!==void 0?this.i.canvas=t:Sc()?this.i.canvas=new OffscreenCanvas(1,1):(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas"))}async initializeGraph(e){let t=await(await fetch(e)).arrayBuffer();e=!(e.endsWith(".pbtxt")||e.endsWith(".textproto")),this.setGraph(new Uint8Array(t),e)}setGraphFromString(e){this.setGraph(new TextEncoder().encode(e),!1)}setGraph(e,t){let r=e.length,n=this.i._malloc(r);this.i.HEAPU8.set(e,n),t?this.i._changeBinaryGraph(r,n):this.i._changeTextGraph(r,n),this.i._free(n)}configureAudio(e,t,r,n,o){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),E(this,n||"input_audio",s=>{E(this,o=o||"audio_header",a=>{this.i._configureAudio(s,a,e,t??0,r)})})}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}ea(e){qe(this,"__graph_config__",t=>{e(t)}),E(this,"__graph_config__",t=>{this.i._getGraphConfig(t,void 0)}),delete this.i.simpleListeners.__graph_config__}attachErrorListener(e){this.i.errorListener=e}attachEmptyPacketListener(e,t){this.i.emptyPacketListeners=this.i.emptyPacketListeners||{},this.i.emptyPacketListeners[e]=t}addAudioToStream(e,t,r){this.addAudioToStreamWithShape(e,0,0,t,r)}addAudioToStreamWithShape(e,t,r,n,o){let s=4*e.length;this.h!==s&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(s),this.h=s),this.i.HEAPF32.set(e,this.g/4),E(this,n,a=>{this.i._addAudioToInputStream(this.g,t,r,a,o)})}addGpuBufferToStream(e,t,r){E(this,t,n=>{let[o,s]=va(this,e,n);this.i._addBoundTextureToStream(n,o,s,r)})}addBoolToStream(e,t,r){E(this,t,n=>{this.i._addBoolToInputStream(e,n,r)})}addDoubleToStream(e,t,r){E(this,t,n=>{this.i._addDoubleToInputStream(e,n,r)})}addFloatToStream(e,t,r){E(this,t,n=>{this.i._addFloatToInputStream(e,n,r)})}addIntToStream(e,t,r){E(this,t,n=>{this.i._addIntToInputStream(e,n,r)})}addUintToStream(e,t,r){E(this,t,n=>{this.i._addUintToInputStream(e,n,r)})}addStringToStream(e,t,r){E(this,t,n=>{E(this,e,o=>{this.i._addStringToInputStream(o,n,r)})})}addStringRecordToStream(e,t,r){E(this,t,n=>{Ea(this,Object.keys(e),o=>{Ea(this,Object.values(e),s=>{this.i._addFlatHashMapToInputStream(o,s,Object.keys(e).length,n,r)})})})}addProtoToStream(e,t,r,n){E(this,r,o=>{E(this,t,s=>{let a=this.i._malloc(e.length);this.i.HEAPU8.set(e,a),this.i._addProtoToInputStream(a,e.length,s,o,n),this.i._free(a)})})}addEmptyPacketToStream(e,t){E(this,e,r=>{this.i._addEmptyPacketToInputStream(r,t)})}addBoolVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateBoolVector(e.length);if(!o)throw Error("Unable to allocate new bool vector on heap.");for(let s of e)this.i._addBoolVectorEntry(o,s);this.i._addBoolVectorToInputStream(o,n,r)})}addDoubleVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateDoubleVector(e.length);if(!o)throw Error("Unable to allocate new double vector on heap.");for(let s of e)this.i._addDoubleVectorEntry(o,s);this.i._addDoubleVectorToInputStream(o,n,r)})}addFloatVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateFloatVector(e.length);if(!o)throw Error("Unable to allocate new float vector on heap.");for(let s of e)this.i._addFloatVectorEntry(o,s);this.i._addFloatVectorToInputStream(o,n,r)})}addIntVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateIntVector(e.length);if(!o)throw Error("Unable to allocate new int vector on heap.");for(let s of e)this.i._addIntVectorEntry(o,s);this.i._addIntVectorToInputStream(o,n,r)})}addUintVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateUintVector(e.length);if(!o)throw Error("Unable to allocate new unsigned int vector on heap.");for(let s of e)this.i._addUintVectorEntry(o,s);this.i._addUintVectorToInputStream(o,n,r)})}addStringVectorToStream(e,t,r){E(this,t,n=>{let o=this.i._allocateStringVector(e.length);if(!o)throw Error("Unable to allocate new string vector on heap.");for(let s of e)E(this,s,a=>{this.i._addStringVectorEntry(o,a)});this.i._addStringVectorToInputStream(o,n,r)})}addBoolToInputSidePacket(e,t){E(this,t,r=>{this.i._addBoolToInputSidePacket(e,r)})}addDoubleToInputSidePacket(e,t){E(this,t,r=>{this.i._addDoubleToInputSidePacket(e,r)})}addFloatToInputSidePacket(e,t){E(this,t,r=>{this.i._addFloatToInputSidePacket(e,r)})}addIntToInputSidePacket(e,t){E(this,t,r=>{this.i._addIntToInputSidePacket(e,r)})}addUintToInputSidePacket(e,t){E(this,t,r=>{this.i._addUintToInputSidePacket(e,r)})}addStringToInputSidePacket(e,t){E(this,t,r=>{E(this,e,n=>{this.i._addStringToInputSidePacket(n,r)})})}addProtoToInputSidePacket(e,t,r){E(this,r,n=>{E(this,t,o=>{let s=this.i._malloc(e.length);this.i.HEAPU8.set(e,s),this.i._addProtoToInputSidePacket(s,e.length,o,n),this.i._free(s)})})}addBoolVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateBoolVector(e.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let o of e)this.i._addBoolVectorEntry(n,o);this.i._addBoolVectorToInputSidePacket(n,r)})}addDoubleVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateDoubleVector(e.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let o of e)this.i._addDoubleVectorEntry(n,o);this.i._addDoubleVectorToInputSidePacket(n,r)})}addFloatVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateFloatVector(e.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let o of e)this.i._addFloatVectorEntry(n,o);this.i._addFloatVectorToInputSidePacket(n,r)})}addIntVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateIntVector(e.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let o of e)this.i._addIntVectorEntry(n,o);this.i._addIntVectorToInputSidePacket(n,r)})}addUintVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateUintVector(e.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(let o of e)this.i._addUintVectorEntry(n,o);this.i._addUintVectorToInputSidePacket(n,r)})}addStringVectorToInputSidePacket(e,t){E(this,t,r=>{let n=this.i._allocateStringVector(e.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let o of e)E(this,o,s=>{this.i._addStringVectorEntry(n,s)});this.i._addStringVectorToInputSidePacket(n,r)})}attachBoolListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachBoolListener(r)})}attachBoolVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachBoolVectorListener(r)})}attachIntListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachIntListener(r)})}attachIntVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachIntVectorListener(r)})}attachUintListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachUintListener(r)})}attachUintVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachUintVectorListener(r)})}attachDoubleListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachDoubleListener(r)})}attachDoubleVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachDoubleVectorListener(r)})}attachFloatListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachFloatListener(r)})}attachFloatVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachFloatVectorListener(r)})}attachStringListener(e,t){qe(this,e,t),E(this,e,r=>{this.i._attachStringListener(r)})}attachStringVectorListener(e,t){lt(this,e,t),E(this,e,r=>{this.i._attachStringVectorListener(r)})}attachProtoListener(e,t,r){qe(this,e,t),E(this,e,n=>{this.i._attachProtoListener(n,r||!1)})}attachProtoVectorListener(e,t,r){lt(this,e,t),E(this,e,n=>{this.i._attachProtoVectorListener(n,r||!1)})}attachAudioListener(e,t,r){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),qe(this,e,(n,o)=>{n=new Float32Array(n.buffer,n.byteOffset,n.length/4),t(n,o)}),E(this,e,n=>{this.i._attachAudioListener(n,r||!1)})}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends Ia{get fa(){return this.i}ra(e,t,r){E(this,t,n=>{let[o,s]=va(this,e,n);this.fa._addBoundTextureAsImageToStream(n,o,s,r)})}V(e,t){qe(this,e,t),E(this,e,r=>{this.fa._attachImageListener(r)})}da(e,t){lt(this,e,t),E(this,e,r=>{this.fa._attachImageVectorListener(r)})}})),Ia,Be=class extends O2{};async function M(e,t,r){return async function(n,o,s,a){return I2(n,o,s,a)}(e,r.canvas??(Sc()?void 0:document.createElement("canvas")),t,r)}function Uc(e,t,r,n){if(e.U){let s=new nc;if(r?.regionOfInterest){if(!e.qa)throw Error("This task doesn't support region-of-interest.");var o=r.regionOfInterest;if(o.left>=o.right||o.top>=o.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(o.left<0||o.top<0||o.right>1||o.bottom>1)throw Error("Expected RectF values to be in [0,1].");v(s,1,(o.left+o.right)/2),v(s,2,(o.top+o.bottom)/2),v(s,4,o.right-o.left),v(s,3,o.bottom-o.top)}else v(s,1,.5),v(s,2,.5),v(s,4,1),v(s,3,1);if(r?.rotationDegrees){if(r?.rotationDegrees%90!=0)throw Error("Expected rotation to be a multiple of 90\xB0.");if(v(s,5,-Math.PI*r.rotationDegrees/180),r?.rotationDegrees%180!=0){let[a,i]=Cc(t);r=te(s,3)*i/a,o=te(s,4)*a/i,v(s,4,r),v(s,3,o)}}e.g.addProtoToStream(s.g(),"mediapipe.NormalizedRect",e.U,n)}e.g.ra(t,e.ba,n??performance.now()),e.finishProcessing()}function De(e,t,r){if(e.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");Uc(e,t,r,e.B+1)}function rt(e,t,r,n){if(!e.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");Uc(e,t,r,n)}function zt(e,t,r,n){var o=t.data;let s=t.width,a=s*(t=t.height);if((o instanceof Uint8Array||o instanceof Float32Array)&&o.length!==a)throw Error("Unsupported channel count: "+o.length/a);return e=new ae([o],r,!1,e.g.i.canvas,e.P,s,t),n?e.clone():e}var Ee=class extends Vr{constructor(e,t,r,n){super(e),this.g=e,this.ba=t,this.U=r,this.qa=n,this.P=new nr}l(e,t=!0){if("runningMode"in e&&Er(this.baseOptions,2,!!e.runningMode&&e.runningMode!=="IMAGE"),e.canvas!==void 0&&this.g.i.canvas!==e.canvas)throw Error("You must create a new task to reset the canvas.");return super.l(e,t)}close(){this.P.close(),super.close()}};Ee.prototype.close=Ee.prototype.close;var Ie=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},T(e=this.h=new bn,0,1,t=new $),v(this.h,2,.5),v(this.h,3,.3)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&v(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&v(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}D(e,t){return this.j={detections:[]},De(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect_in"),P(e,"detections");let t=new ke;Xe(t,x2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect_in"),F(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(n,o)=>{for(let s of n)n=ec(s),this.j.detections.push(wc(n));m(this,o)}),this.g.attachEmptyPacketListener("detections",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ie.prototype.detectForVideo=Ie.prototype.F,Ie.prototype.detect=Ie.prototype.D,Ie.prototype.setOptions=Ie.prototype.o,Ie.createFromModelPath=async function(e,t){return M(Ie,e,{baseOptions:{modelAssetPath:t}})},Ie.createFromModelBuffer=function(e,t){return M(Ie,e,{baseOptions:{modelAssetBuffer:t}})},Ie.createFromOptions=function(e,t){return M(Ie,e,t)};var fs=ze([61,146],[146,91],[91,181],[181,84],[84,17],[17,314],[314,405],[405,321],[321,375],[375,291],[61,185],[185,40],[40,39],[39,37],[37,0],[0,267],[267,269],[269,270],[270,409],[409,291],[78,95],[95,88],[88,178],[178,87],[87,14],[14,317],[317,402],[402,318],[318,324],[324,308],[78,191],[191,80],[80,81],[81,82],[82,13],[13,312],[312,311],[311,310],[310,415],[415,308]),ps=ze([263,249],[249,390],[390,373],[373,374],[374,380],[380,381],[381,382],[382,362],[263,466],[466,388],[388,387],[387,386],[386,385],[385,384],[384,398],[398,362]),ms=ze([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),Oc=ze([474,475],[475,476],[476,477],[477,474]),gs=ze([33,7],[7,163],[163,144],[144,145],[145,153],[153,154],[154,155],[155,133],[33,246],[246,161],[161,160],[160,159],[159,158],[158,157],[157,173],[173,133]),xs=ze([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),Pc=ze([469,470],[470,471],[471,472],[472,469]),ys=ze([10,338],[338,297],[297,332],[332,284],[284,251],[251,389],[389,356],[356,454],[454,323],[323,361],[361,288],[288,397],[397,365],[365,379],[379,378],[378,400],[400,377],[377,152],[152,148],[148,176],[176,149],[149,150],[150,136],[136,172],[172,58],[58,132],[132,93],[93,234],[234,127],[127,162],[162,21],[21,54],[54,103],[103,67],[67,109],[109,10]),Bc=[...fs,...ps,...ms,...gs,...xs,...ys],Dc=ze([127,34],[34,139],[139,127],[11,0],[0,37],[37,11],[232,231],[231,120],[120,232],[72,37],[37,39],[39,72],[128,121],[121,47],[47,128],[232,121],[121,128],[128,232],[104,69],[69,67],[67,104],[175,171],[171,148],[148,175],[118,50],[50,101],[101,118],[73,39],[39,40],[40,73],[9,151],[151,108],[108,9],[48,115],[115,131],[131,48],[194,204],[204,211],[211,194],[74,40],[40,185],[185,74],[80,42],[42,183],[183,80],[40,92],[92,186],[186,40],[230,229],[229,118],[118,230],[202,212],[212,214],[214,202],[83,18],[18,17],[17,83],[76,61],[61,146],[146,76],[160,29],[29,30],[30,160],[56,157],[157,173],[173,56],[106,204],[204,194],[194,106],[135,214],[214,192],[192,135],[203,165],[165,98],[98,203],[21,71],[71,68],[68,21],[51,45],[45,4],[4,51],[144,24],[24,23],[23,144],[77,146],[146,91],[91,77],[205,50],[50,187],[187,205],[201,200],[200,18],[18,201],[91,106],[106,182],[182,91],[90,91],[91,181],[181,90],[85,84],[84,17],[17,85],[206,203],[203,36],[36,206],[148,171],[171,140],[140,148],[92,40],[40,39],[39,92],[193,189],[189,244],[244,193],[159,158],[158,28],[28,159],[247,246],[246,161],[161,247],[236,3],[3,196],[196,236],[54,68],[68,104],[104,54],[193,168],[168,8],[8,193],[117,228],[228,31],[31,117],[189,193],[193,55],[55,189],[98,97],[97,99],[99,98],[126,47],[47,100],[100,126],[166,79],[79,218],[218,166],[155,154],[154,26],[26,155],[209,49],[49,131],[131,209],[135,136],[136,150],[150,135],[47,126],[126,217],[217,47],[223,52],[52,53],[53,223],[45,51],[51,134],[134,45],[211,170],[170,140],[140,211],[67,69],[69,108],[108,67],[43,106],[106,91],[91,43],[230,119],[119,120],[120,230],[226,130],[130,247],[247,226],[63,53],[53,52],[52,63],[238,20],[20,242],[242,238],[46,70],[70,156],[156,46],[78,62],[62,96],[96,78],[46,53],[53,63],[63,46],[143,34],[34,227],[227,143],[123,117],[117,111],[111,123],[44,125],[125,19],[19,44],[236,134],[134,51],[51,236],[216,206],[206,205],[205,216],[154,153],[153,22],[22,154],[39,37],[37,167],[167,39],[200,201],[201,208],[208,200],[36,142],[142,100],[100,36],[57,212],[212,202],[202,57],[20,60],[60,99],[99,20],[28,158],[158,157],[157,28],[35,226],[226,113],[113,35],[160,159],[159,27],[27,160],[204,202],[202,210],[210,204],[113,225],[225,46],[46,113],[43,202],[202,204],[204,43],[62,76],[76,77],[77,62],[137,123],[123,116],[116,137],[41,38],[38,72],[72,41],[203,129],[129,142],[142,203],[64,98],[98,240],[240,64],[49,102],[102,64],[64,49],[41,73],[73,74],[74,41],[212,216],[216,207],[207,212],[42,74],[74,184],[184,42],[169,170],[170,211],[211,169],[170,149],[149,176],[176,170],[105,66],[66,69],[69,105],[122,6],[6,168],[168,122],[123,147],[147,187],[187,123],[96,77],[77,90],[90,96],[65,55],[55,107],[107,65],[89,90],[90,180],[180,89],[101,100],[100,120],[120,101],[63,105],[105,104],[104,63],[93,137],[137,227],[227,93],[15,86],[86,85],[85,15],[129,102],[102,49],[49,129],[14,87],[87,86],[86,14],[55,8],[8,9],[9,55],[100,47],[47,121],[121,100],[145,23],[23,22],[22,145],[88,89],[89,179],[179,88],[6,122],[122,196],[196,6],[88,95],[95,96],[96,88],[138,172],[172,136],[136,138],[215,58],[58,172],[172,215],[115,48],[48,219],[219,115],[42,80],[80,81],[81,42],[195,3],[3,51],[51,195],[43,146],[146,61],[61,43],[171,175],[175,199],[199,171],[81,82],[82,38],[38,81],[53,46],[46,225],[225,53],[144,163],[163,110],[110,144],[52,65],[65,66],[66,52],[229,228],[228,117],[117,229],[34,127],[127,234],[234,34],[107,108],[108,69],[69,107],[109,108],[108,151],[151,109],[48,64],[64,235],[235,48],[62,78],[78,191],[191,62],[129,209],[209,126],[126,129],[111,35],[35,143],[143,111],[117,123],[123,50],[50,117],[222,65],[65,52],[52,222],[19,125],[125,141],[141,19],[221,55],[55,65],[65,221],[3,195],[195,197],[197,3],[25,7],[7,33],[33,25],[220,237],[237,44],[44,220],[70,71],[71,139],[139,70],[122,193],[193,245],[245,122],[247,130],[130,33],[33,247],[71,21],[21,162],[162,71],[170,169],[169,150],[150,170],[188,174],[174,196],[196,188],[216,186],[186,92],[92,216],[2,97],[97,167],[167,2],[141,125],[125,241],[241,141],[164,167],[167,37],[37,164],[72,38],[38,12],[12,72],[38,82],[82,13],[13,38],[63,68],[68,71],[71,63],[226,35],[35,111],[111,226],[101,50],[50,205],[205,101],[206,92],[92,165],[165,206],[209,198],[198,217],[217,209],[165,167],[167,97],[97,165],[220,115],[115,218],[218,220],[133,112],[112,243],[243,133],[239,238],[238,241],[241,239],[214,135],[135,169],[169,214],[190,173],[173,133],[133,190],[171,208],[208,32],[32,171],[125,44],[44,237],[237,125],[86,87],[87,178],[178,86],[85,86],[86,179],[179,85],[84,85],[85,180],[180,84],[83,84],[84,181],[181,83],[201,83],[83,182],[182,201],[137,93],[93,132],[132,137],[76,62],[62,183],[183,76],[61,76],[76,184],[184,61],[57,61],[61,185],[185,57],[212,57],[57,186],[186,212],[214,207],[207,187],[187,214],[34,143],[143,156],[156,34],[79,239],[239,237],[237,79],[123,137],[137,177],[177,123],[44,1],[1,4],[4,44],[201,194],[194,32],[32,201],[64,102],[102,129],[129,64],[213,215],[215,138],[138,213],[59,166],[166,219],[219,59],[242,99],[99,97],[97,242],[2,94],[94,141],[141,2],[75,59],[59,235],[235,75],[24,110],[110,228],[228,24],[25,130],[130,226],[226,25],[23,24],[24,229],[229,23],[22,23],[23,230],[230,22],[26,22],[22,231],[231,26],[112,26],[26,232],[232,112],[189,190],[190,243],[243,189],[221,56],[56,190],[190,221],[28,56],[56,221],[221,28],[27,28],[28,222],[222,27],[29,27],[27,223],[223,29],[30,29],[29,224],[224,30],[247,30],[30,225],[225,247],[238,79],[79,20],[20,238],[166,59],[59,75],[75,166],[60,75],[75,240],[240,60],[147,177],[177,215],[215,147],[20,79],[79,166],[166,20],[187,147],[147,213],[213,187],[112,233],[233,244],[244,112],[233,128],[128,245],[245,233],[128,114],[114,188],[188,128],[114,217],[217,174],[174,114],[131,115],[115,220],[220,131],[217,198],[198,236],[236,217],[198,131],[131,134],[134,198],[177,132],[132,58],[58,177],[143,35],[35,124],[124,143],[110,163],[163,7],[7,110],[228,110],[110,25],[25,228],[356,389],[389,368],[368,356],[11,302],[302,267],[267,11],[452,350],[350,349],[349,452],[302,303],[303,269],[269,302],[357,343],[343,277],[277,357],[452,453],[453,357],[357,452],[333,332],[332,297],[297,333],[175,152],[152,377],[377,175],[347,348],[348,330],[330,347],[303,304],[304,270],[270,303],[9,336],[336,337],[337,9],[278,279],[279,360],[360,278],[418,262],[262,431],[431,418],[304,408],[408,409],[409,304],[310,415],[415,407],[407,310],[270,409],[409,410],[410,270],[450,348],[348,347],[347,450],[422,430],[430,434],[434,422],[313,314],[314,17],[17,313],[306,307],[307,375],[375,306],[387,388],[388,260],[260,387],[286,414],[414,398],[398,286],[335,406],[406,418],[418,335],[364,367],[367,416],[416,364],[423,358],[358,327],[327,423],[251,284],[284,298],[298,251],[281,5],[5,4],[4,281],[373,374],[374,253],[253,373],[307,320],[320,321],[321,307],[425,427],[427,411],[411,425],[421,313],[313,18],[18,421],[321,405],[405,406],[406,321],[320,404],[404,405],[405,320],[315,16],[16,17],[17,315],[426,425],[425,266],[266,426],[377,400],[400,369],[369,377],[322,391],[391,269],[269,322],[417,465],[465,464],[464,417],[386,257],[257,258],[258,386],[466,260],[260,388],[388,466],[456,399],[399,419],[419,456],[284,332],[332,333],[333,284],[417,285],[285,8],[8,417],[346,340],[340,261],[261,346],[413,441],[441,285],[285,413],[327,460],[460,328],[328,327],[355,371],[371,329],[329,355],[392,439],[439,438],[438,392],[382,341],[341,256],[256,382],[429,420],[420,360],[360,429],[364,394],[394,379],[379,364],[277,343],[343,437],[437,277],[443,444],[444,283],[283,443],[275,440],[440,363],[363,275],[431,262],[262,369],[369,431],[297,338],[338,337],[337,297],[273,375],[375,321],[321,273],[450,451],[451,349],[349,450],[446,342],[342,467],[467,446],[293,334],[334,282],[282,293],[458,461],[461,462],[462,458],[276,353],[353,383],[383,276],[308,324],[324,325],[325,308],[276,300],[300,293],[293,276],[372,345],[345,447],[447,372],[352,345],[345,340],[340,352],[274,1],[1,19],[19,274],[456,248],[248,281],[281,456],[436,427],[427,425],[425,436],[381,256],[256,252],[252,381],[269,391],[391,393],[393,269],[200,199],[199,428],[428,200],[266,330],[330,329],[329,266],[287,273],[273,422],[422,287],[250,462],[462,328],[328,250],[258,286],[286,384],[384,258],[265,353],[353,342],[342,265],[387,259],[259,257],[257,387],[424,431],[431,430],[430,424],[342,353],[353,276],[276,342],[273,335],[335,424],[424,273],[292,325],[325,307],[307,292],[366,447],[447,345],[345,366],[271,303],[303,302],[302,271],[423,266],[266,371],[371,423],[294,455],[455,460],[460,294],[279,278],[278,294],[294,279],[271,272],[272,304],[304,271],[432,434],[434,427],[427,432],[272,407],[407,408],[408,272],[394,430],[430,431],[431,394],[395,369],[369,400],[400,395],[334,333],[333,299],[299,334],[351,417],[417,168],[168,351],[352,280],[280,411],[411,352],[325,319],[319,320],[320,325],[295,296],[296,336],[336,295],[319,403],[403,404],[404,319],[330,348],[348,349],[349,330],[293,298],[298,333],[333,293],[323,454],[454,447],[447,323],[15,16],[16,315],[315,15],[358,429],[429,279],[279,358],[14,15],[15,316],[316,14],[285,336],[336,9],[9,285],[329,349],[349,350],[350,329],[374,380],[380,252],[252,374],[318,402],[402,403],[403,318],[6,197],[197,419],[419,6],[318,319],[319,325],[325,318],[367,364],[364,365],[365,367],[435,367],[367,397],[397,435],[344,438],[438,439],[439,344],[272,271],[271,311],[311,272],[195,5],[5,281],[281,195],[273,287],[287,291],[291,273],[396,428],[428,199],[199,396],[311,271],[271,268],[268,311],[283,444],[444,445],[445,283],[373,254],[254,339],[339,373],[282,334],[334,296],[296,282],[449,347],[347,346],[346,449],[264,447],[447,454],[454,264],[336,296],[296,299],[299,336],[338,10],[10,151],[151,338],[278,439],[439,455],[455,278],[292,407],[407,415],[415,292],[358,371],[371,355],[355,358],[340,345],[345,372],[372,340],[346,347],[347,280],[280,346],[442,443],[443,282],[282,442],[19,94],[94,370],[370,19],[441,442],[442,295],[295,441],[248,419],[419,197],[197,248],[263,255],[255,359],[359,263],[440,275],[275,274],[274,440],[300,383],[383,368],[368,300],[351,412],[412,465],[465,351],[263,467],[467,466],[466,263],[301,368],[368,389],[389,301],[395,378],[378,379],[379,395],[412,351],[351,419],[419,412],[436,426],[426,322],[322,436],[2,164],[164,393],[393,2],[370,462],[462,461],[461,370],[164,0],[0,267],[267,164],[302,11],[11,12],[12,302],[268,12],[12,13],[13,268],[293,300],[300,301],[301,293],[446,261],[261,340],[340,446],[330,266],[266,425],[425,330],[426,423],[423,391],[391,426],[429,355],[355,437],[437,429],[391,327],[327,326],[326,391],[440,457],[457,438],[438,440],[341,382],[382,362],[362,341],[459,457],[457,461],[461,459],[434,430],[430,394],[394,434],[414,463],[463,362],[362,414],[396,369],[369,262],[262,396],[354,461],[461,457],[457,354],[316,403],[403,402],[402,316],[315,404],[404,403],[403,315],[314,405],[405,404],[404,314],[313,406],[406,405],[405,313],[421,418],[418,406],[406,421],[366,401],[401,361],[361,366],[306,408],[408,407],[407,306],[291,409],[409,408],[408,291],[287,410],[410,409],[409,287],[432,436],[436,410],[410,432],[434,416],[416,411],[411,434],[264,368],[368,383],[383,264],[309,438],[438,457],[457,309],[352,376],[376,401],[401,352],[274,275],[275,4],[4,274],[421,428],[428,262],[262,421],[294,327],[327,358],[358,294],[433,416],[416,367],[367,433],[289,455],[455,439],[439,289],[462,370],[370,326],[326,462],[2,326],[326,370],[370,2],[305,460],[460,455],[455,305],[254,449],[449,448],[448,254],[255,261],[261,446],[446,255],[253,450],[450,449],[449,253],[252,451],[451,450],[450,252],[256,452],[452,451],[451,256],[341,453],[453,452],[452,341],[413,464],[464,463],[463,413],[441,413],[413,414],[414,441],[258,442],[442,441],[441,258],[257,443],[443,442],[442,257],[259,444],[444,443],[443,259],[260,445],[445,444],[444,260],[467,342],[342,445],[445,467],[459,458],[458,250],[250,459],[289,392],[392,290],[290,289],[290,328],[328,460],[460,290],[376,433],[433,435],[435,376],[250,290],[290,392],[392,250],[411,416],[416,433],[433,411],[341,463],[463,464],[464,341],[453,464],[464,465],[465,453],[357,465],[465,412],[412,357],[343,412],[412,399],[399,343],[360,363],[363,440],[440,360],[437,399],[399,456],[456,437],[420,456],[456,363],[363,420],[401,435],[435,288],[288,401],[372,383],[383,353],[353,372],[339,255],[255,249],[249,339],[448,261],[261,255],[255,448],[133,243],[243,190],[190,133],[133,155],[155,112],[112,133],[33,246],[246,247],[247,33],[33,130],[130,25],[25,33],[398,384],[384,286],[286,398],[362,398],[398,414],[414,362],[362,463],[463,341],[341,362],[263,359],[359,467],[467,263],[263,249],[249,255],[255,263],[466,467],[467,260],[260,466],[75,60],[60,166],[166,75],[238,239],[239,79],[79,238],[162,127],[127,139],[139,162],[72,11],[11,37],[37,72],[121,232],[232,120],[120,121],[73,72],[72,39],[39,73],[114,128],[128,47],[47,114],[233,232],[232,128],[128,233],[103,104],[104,67],[67,103],[152,175],[175,148],[148,152],[119,118],[118,101],[101,119],[74,73],[73,40],[40,74],[107,9],[9,108],[108,107],[49,48],[48,131],[131,49],[32,194],[194,211],[211,32],[184,74],[74,185],[185,184],[191,80],[80,183],[183,191],[185,40],[40,186],[186,185],[119,230],[230,118],[118,119],[210,202],[202,214],[214,210],[84,83],[83,17],[17,84],[77,76],[76,146],[146,77],[161,160],[160,30],[30,161],[190,56],[56,173],[173,190],[182,106],[106,194],[194,182],[138,135],[135,192],[192,138],[129,203],[203,98],[98,129],[54,21],[21,68],[68,54],[5,51],[51,4],[4,5],[145,144],[144,23],[23,145],[90,77],[77,91],[91,90],[207,205],[205,187],[187,207],[83,201],[201,18],[18,83],[181,91],[91,182],[182,181],[180,90],[90,181],[181,180],[16,85],[85,17],[17,16],[205,206],[206,36],[36,205],[176,148],[148,140],[140,176],[165,92],[92,39],[39,165],[245,193],[193,244],[244,245],[27,159],[159,28],[28,27],[30,247],[247,161],[161,30],[174,236],[236,196],[196,174],[103,54],[54,104],[104,103],[55,193],[193,8],[8,55],[111,117],[117,31],[31,111],[221,189],[189,55],[55,221],[240,98],[98,99],[99,240],[142,126],[126,100],[100,142],[219,166],[166,218],[218,219],[112,155],[155,26],[26,112],[198,209],[209,131],[131,198],[169,135],[135,150],[150,169],[114,47],[47,217],[217,114],[224,223],[223,53],[53,224],[220,45],[45,134],[134,220],[32,211],[211,140],[140,32],[109,67],[67,108],[108,109],[146,43],[43,91],[91,146],[231,230],[230,120],[120,231],[113,226],[226,247],[247,113],[105,63],[63,52],[52,105],[241,238],[238,242],[242,241],[124,46],[46,156],[156,124],[95,78],[78,96],[96,95],[70,46],[46,63],[63,70],[116,143],[143,227],[227,116],[116,123],[123,111],[111,116],[1,44],[44,19],[19,1],[3,236],[236,51],[51,3],[207,216],[216,205],[205,207],[26,154],[154,22],[22,26],[165,39],[39,167],[167,165],[199,200],[200,208],[208,199],[101,36],[36,100],[100,101],[43,57],[57,202],[202,43],[242,20],[20,99],[99,242],[56,28],[28,157],[157,56],[124,35],[35,113],[113,124],[29,160],[160,27],[27,29],[211,204],[204,210],[210,211],[124,113],[113,46],[46,124],[106,43],[43,204],[204,106],[96,62],[62,77],[77,96],[227,137],[137,116],[116,227],[73,41],[41,72],[72,73],[36,203],[203,142],[142,36],[235,64],[64,240],[240,235],[48,49],[49,64],[64,48],[42,41],[41,74],[74,42],[214,212],[212,207],[207,214],[183,42],[42,184],[184,183],[210,169],[169,211],[211,210],[140,170],[170,176],[176,140],[104,105],[105,69],[69,104],[193,122],[122,168],[168,193],[50,123],[123,187],[187,50],[89,96],[96,90],[90,89],[66,65],[65,107],[107,66],[179,89],[89,180],[180,179],[119,101],[101,120],[120,119],[68,63],[63,104],[104,68],[234,93],[93,227],[227,234],[16,15],[15,85],[85,16],[209,129],[129,49],[49,209],[15,14],[14,86],[86,15],[107,55],[55,9],[9,107],[120,100],[100,121],[121,120],[153,145],[145,22],[22,153],[178,88],[88,179],[179,178],[197,6],[6,196],[196,197],[89,88],[88,96],[96,89],[135,138],[138,136],[136,135],[138,215],[215,172],[172,138],[218,115],[115,219],[219,218],[41,42],[42,81],[81,41],[5,195],[195,51],[51,5],[57,43],[43,61],[61,57],[208,171],[171,199],[199,208],[41,81],[81,38],[38,41],[224,53],[53,225],[225,224],[24,144],[144,110],[110,24],[105,52],[52,66],[66,105],[118,229],[229,117],[117,118],[227,34],[34,234],[234,227],[66,107],[107,69],[69,66],[10,109],[109,151],[151,10],[219,48],[48,235],[235,219],[183,62],[62,191],[191,183],[142,129],[129,126],[126,142],[116,111],[111,143],[143,116],[118,117],[117,50],[50,118],[223,222],[222,52],[52,223],[94,19],[19,141],[141,94],[222,221],[221,65],[65,222],[196,3],[3,197],[197,196],[45,220],[220,44],[44,45],[156,70],[70,139],[139,156],[188,122],[122,245],[245,188],[139,71],[71,162],[162,139],[149,170],[170,150],[150,149],[122,188],[188,196],[196,122],[206,216],[216,92],[92,206],[164,2],[2,167],[167,164],[242,141],[141,241],[241,242],[0,164],[164,37],[37,0],[11,72],[72,12],[12,11],[12,38],[38,13],[13,12],[70,63],[63,71],[71,70],[31,226],[226,111],[111,31],[36,101],[101,205],[205,36],[203,206],[206,165],[165,203],[126,209],[209,217],[217,126],[98,165],[165,97],[97,98],[237,220],[220,218],[218,237],[237,239],[239,241],[241,237],[210,214],[214,169],[169,210],[140,171],[171,32],[32,140],[241,125],[125,237],[237,241],[179,86],[86,178],[178,179],[180,85],[85,179],[179,180],[181,84],[84,180],[180,181],[182,83],[83,181],[181,182],[194,201],[201,182],[182,194],[177,137],[137,132],[132,177],[184,76],[76,183],[183,184],[185,61],[61,184],[184,185],[186,57],[57,185],[185,186],[216,212],[212,186],[186,216],[192,214],[214,187],[187,192],[139,34],[34,156],[156,139],[218,79],[79,237],[237,218],[147,123],[123,177],[177,147],[45,44],[44,4],[4,45],[208,201],[201,32],[32,208],[98,64],[64,129],[129,98],[192,213],[213,138],[138,192],[235,59],[59,219],[219,235],[141,242],[242,97],[97,141],[97,2],[2,141],[141,97],[240,75],[75,235],[235,240],[229,24],[24,228],[228,229],[31,25],[25,226],[226,31],[230,23],[23,229],[229,230],[231,22],[22,230],[230,231],[232,26],[26,231],[231,232],[233,112],[112,232],[232,233],[244,189],[189,243],[243,244],[189,221],[221,190],[190,189],[222,28],[28,221],[221,222],[223,27],[27,222],[222,223],[224,29],[29,223],[223,224],[225,30],[30,224],[224,225],[113,247],[247,225],[225,113],[99,60],[60,240],[240,99],[213,147],[147,215],[215,213],[60,20],[20,166],[166,60],[192,187],[187,213],[213,192],[243,112],[112,244],[244,243],[244,233],[233,245],[245,244],[245,128],[128,188],[188,245],[188,114],[114,174],[174,188],[134,131],[131,220],[220,134],[174,217],[217,236],[236,174],[236,198],[198,134],[134,236],[215,177],[177,58],[58,215],[156,143],[143,124],[124,156],[25,110],[110,7],[7,25],[31,228],[228,25],[25,31],[264,356],[356,368],[368,264],[0,11],[11,267],[267,0],[451,452],[452,349],[349,451],[267,302],[302,269],[269,267],[350,357],[357,277],[277,350],[350,452],[452,357],[357,350],[299,333],[333,297],[297,299],[396,175],[175,377],[377,396],[280,347],[347,330],[330,280],[269,303],[303,270],[270,269],[151,9],[9,337],[337,151],[344,278],[278,360],[360,344],[424,418],[418,431],[431,424],[270,304],[304,409],[409,270],[272,310],[310,407],[407,272],[322,270],[270,410],[410,322],[449,450],[450,347],[347,449],[432,422],[422,434],[434,432],[18,313],[313,17],[17,18],[291,306],[306,375],[375,291],[259,387],[387,260],[260,259],[424,335],[335,418],[418,424],[434,364],[364,416],[416,434],[391,423],[423,327],[327,391],[301,251],[251,298],[298,301],[275,281],[281,4],[4,275],[254,373],[373,253],[253,254],[375,307],[307,321],[321,375],[280,425],[425,411],[411,280],[200,421],[421,18],[18,200],[335,321],[321,406],[406,335],[321,320],[320,405],[405,321],[314,315],[315,17],[17,314],[423,426],[426,266],[266,423],[396,377],[377,369],[369,396],[270,322],[322,269],[269,270],[413,417],[417,464],[464,413],[385,386],[386,258],[258,385],[248,456],[456,419],[419,248],[298,284],[284,333],[333,298],[168,417],[417,8],[8,168],[448,346],[346,261],[261,448],[417,413],[413,285],[285,417],[326,327],[327,328],[328,326],[277,355],[355,329],[329,277],[309,392],[392,438],[438,309],[381,382],[382,256],[256,381],[279,429],[429,360],[360,279],[365,364],[364,379],[379,365],[355,277],[277,437],[437,355],[282,443],[443,283],[283,282],[281,275],[275,363],[363,281],[395,431],[431,369],[369,395],[299,297],[297,337],[337,299],[335,273],[273,321],[321,335],[348,450],[450,349],[349,348],[359,446],[446,467],[467,359],[283,293],[293,282],[282,283],[250,458],[458,462],[462,250],[300,276],[276,383],[383,300],[292,308],[308,325],[325,292],[283,276],[276,293],[293,283],[264,372],[372,447],[447,264],[346,352],[352,340],[340,346],[354,274],[274,19],[19,354],[363,456],[456,281],[281,363],[426,436],[436,425],[425,426],[380,381],[381,252],[252,380],[267,269],[269,393],[393,267],[421,200],[200,428],[428,421],[371,266],[266,329],[329,371],[432,287],[287,422],[422,432],[290,250],[250,328],[328,290],[385,258],[258,384],[384,385],[446,265],[265,342],[342,446],[386,387],[387,257],[257,386],[422,424],[424,430],[430,422],[445,342],[342,276],[276,445],[422,273],[273,424],[424,422],[306,292],[292,307],[307,306],[352,366],[366,345],[345,352],[268,271],[271,302],[302,268],[358,423],[423,371],[371,358],[327,294],[294,460],[460,327],[331,279],[279,294],[294,331],[303,271],[271,304],[304,303],[436,432],[432,427],[427,436],[304,272],[272,408],[408,304],[395,394],[394,431],[431,395],[378,395],[395,400],[400,378],[296,334],[334,299],[299,296],[6,351],[351,168],[168,6],[376,352],[352,411],[411,376],[307,325],[325,320],[320,307],[285,295],[295,336],[336,285],[320,319],[319,404],[404,320],[329,330],[330,349],[349,329],[334,293],[293,333],[333,334],[366,323],[323,447],[447,366],[316,15],[15,315],[315,316],[331,358],[358,279],[279,331],[317,14],[14,316],[316,317],[8,285],[285,9],[9,8],[277,329],[329,350],[350,277],[253,374],[374,252],[252,253],[319,318],[318,403],[403,319],[351,6],[6,419],[419,351],[324,318],[318,325],[325,324],[397,367],[367,365],[365,397],[288,435],[435,397],[397,288],[278,344],[344,439],[439,278],[310,272],[272,311],[311,310],[248,195],[195,281],[281,248],[375,273],[273,291],[291,375],[175,396],[396,199],[199,175],[312,311],[311,268],[268,312],[276,283],[283,445],[445,276],[390,373],[373,339],[339,390],[295,282],[282,296],[296,295],[448,449],[449,346],[346,448],[356,264],[264,454],[454,356],[337,336],[336,299],[299,337],[337,338],[338,151],[151,337],[294,278],[278,455],[455,294],[308,292],[292,415],[415,308],[429,358],[358,355],[355,429],[265,340],[340,372],[372,265],[352,346],[346,280],[280,352],[295,442],[442,282],[282,295],[354,19],[19,370],[370,354],[285,441],[441,295],[295,285],[195,248],[248,197],[197,195],[457,440],[440,274],[274,457],[301,300],[300,368],[368,301],[417,351],[351,465],[465,417],[251,301],[301,389],[389,251],[394,395],[395,379],[379,394],[399,412],[412,419],[419,399],[410,436],[436,322],[322,410],[326,2],[2,393],[393,326],[354,370],[370,461],[461,354],[393,164],[164,267],[267,393],[268,302],[302,12],[12,268],[312,268],[268,13],[13,312],[298,293],[293,301],[301,298],[265,446],[446,340],[340,265],[280,330],[330,425],[425,280],[322,426],[426,391],[391,322],[420,429],[429,437],[437,420],[393,391],[391,326],[326,393],[344,440],[440,438],[438,344],[458,459],[459,461],[461,458],[364,434],[434,394],[394,364],[428,396],[396,262],[262,428],[274,354],[354,457],[457,274],[317,316],[316,402],[402,317],[316,315],[315,403],[403,316],[315,314],[314,404],[404,315],[314,313],[313,405],[405,314],[313,421],[421,406],[406,313],[323,366],[366,361],[361,323],[292,306],[306,407],[407,292],[306,291],[291,408],[408,306],[291,287],[287,409],[409,291],[287,432],[432,410],[410,287],[427,434],[434,411],[411,427],[372,264],[264,383],[383,372],[459,309],[309,457],[457,459],[366,352],[352,401],[401,366],[1,274],[274,4],[4,1],[418,421],[421,262],[262,418],[331,294],[294,358],[358,331],[435,433],[433,367],[367,435],[392,289],[289,439],[439,392],[328,462],[462,326],[326,328],[94,2],[2,370],[370,94],[289,305],[305,455],[455,289],[339,254],[254,448],[448,339],[359,255],[255,446],[446,359],[254,253],[253,449],[449,254],[253,252],[252,450],[450,253],[252,256],[256,451],[451,252],[256,341],[341,452],[452,256],[414,413],[413,463],[463,414],[286,441],[441,414],[414,286],[286,258],[258,441],[441,286],[258,257],[257,442],[442,258],[257,259],[259,443],[443,257],[259,260],[260,444],[444,259],[260,467],[467,445],[445,260],[309,459],[459,250],[250,309],[305,289],[289,290],[290,305],[305,290],[290,460],[460,305],[401,376],[376,435],[435,401],[309,250],[250,392],[392,309],[376,411],[411,433],[433,376],[453,341],[341,464],[464,453],[357,453],[453,465],[465,357],[343,357],[357,412],[412,343],[437,343],[343,399],[399,437],[344,360],[360,440],[440,344],[420,437],[437,456],[456,420],[360,420],[420,363],[363,360],[361,401],[401,288],[288,361],[265,372],[372,353],[353,265],[390,339],[339,249],[249,390],[339,448],[448,255],[255,339]);function Ma(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var Q=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,T(e=this.h=new cc,0,1,t=new $),this.v=new ic,T(this.h,0,3,this.v),this.s=new bn,T(this.h,0,2,this.s),tt(this.s,4,1),v(this.s,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numFaces"in e&&tt(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&v(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&v(this.v,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}D(e,t){return Ma(this),De(this,e,t),this.j}F(e,t,r){return Ma(this),rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"face_landmarks");let t=new ke;Xe(t,v2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"NORM_LANDMARKS:face_landmarks"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("face_landmarks",(n,o)=>{for(let s of n)n=kr(s),this.j.faceLandmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("face_landmarks",n=>{m(this,n)}),this.outputFaceBlendshapes&&(P(e,"blendshapes"),F(r,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",(n,o)=>{if(this.outputFaceBlendshapes)for(let s of n)n=En(s),this.j.faceBlendshapes.push(us(n.g()??[]));m(this,o)}),this.g.attachEmptyPacketListener("blendshapes",n=>{m(this,n)})),this.outputFacialTransformationMatrixes&&(P(e,"face_geometry"),F(r,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",(n,o)=>{if(this.outputFacialTransformationMatrixes)for(let s of n)(n=O(y2(s),u2,2))&&this.j.facialTransformationMatrixes.push({rows:je(Oe(n,1),0)??0,columns:je(Oe(n,2),0)??0,data:Ct(n,3,At,St()).slice()??[]});m(this,o)}),this.g.attachEmptyPacketListener("face_geometry",n=>{m(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Q.prototype.detectForVideo=Q.prototype.F,Q.prototype.detect=Q.prototype.D,Q.prototype.setOptions=Q.prototype.o,Q.createFromModelPath=function(e,t){return M(Q,e,{baseOptions:{modelAssetPath:t}})},Q.createFromModelBuffer=function(e,t){return M(Q,e,{baseOptions:{modelAssetBuffer:t}})},Q.createFromOptions=function(e,t){return M(Q,e,t)},Q.FACE_LANDMARKS_LIPS=fs,Q.FACE_LANDMARKS_LEFT_EYE=ps,Q.FACE_LANDMARKS_LEFT_EYEBROW=ms,Q.FACE_LANDMARKS_LEFT_IRIS=Oc,Q.FACE_LANDMARKS_RIGHT_EYE=gs,Q.FACE_LANDMARKS_RIGHT_EYEBROW=xs,Q.FACE_LANDMARKS_RIGHT_IRIS=Pc,Q.FACE_LANDMARKS_FACE_OVAL=ys,Q.FACE_LANDMARKS_CONTOURS=Bc,Q.FACE_LANDMARKS_TESSELATION=Dc;var Je=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!0),T(e=this.j=new hc,0,1,t=new $)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){return super.l(e)}Oa(e,t,r){let n=typeof t!="function"?t:{};if(this.h=typeof t=="function"?t:r,De(this,e,n??{}),!this.h)return this.s}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"stylized_image");let t=new ke;Xe(t,E2,this.j);let r=new xe;Ce(r,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"STYLIZED_IMAGE:stylized_image"),r.o(t),Le(e,r),this.g.V("stylized_image",(n,o)=>{var s=!this.h,a=n.data,i=n.width;let c=i*(n=n.height);if(a instanceof Uint8Array)if(a.length===3*c){let l=new Uint8ClampedArray(4*c);for(let h=0;h<c;++h)l[4*h]=a[3*h],l[4*h+1]=a[3*h+1],l[4*h+2]=a[3*h+2],l[4*h+3]=255;a=new ImageData(l,i,n)}else{if(a.length!==4*c)throw Error("Unsupported channel count: "+a.length/c);a=new ImageData(new Uint8ClampedArray(a.buffer,a.byteOffset,a.length),i,n)}else if(!(a instanceof WebGLTexture))throw Error(`Unsupported format: ${a.constructor.name}`);i=new he([a],!1,!1,this.g.i.canvas,this.P,i,n),this.s=s=s?i.clone():i,this.h&&this.h(s),m(this,o)}),this.g.attachEmptyPacketListener("stylized_image",n=>{this.s=null,this.h&&this.h(null),m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Je.prototype.stylize=Je.prototype.Oa,Je.prototype.setOptions=Je.prototype.o,Je.createFromModelPath=function(e,t){return M(Je,e,{baseOptions:{modelAssetPath:t}})},Je.createFromModelBuffer=function(e,t){return M(Je,e,{baseOptions:{modelAssetBuffer:t}})},Je.createFromOptions=function(e,t){return M(Je,e,t)};var vs=ze([0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]);function Fa(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function Ua(e){return e.gestures.length===0?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function Oa(e,t=!0){let r=[];for(let o of e){var n=En(o);e=[];for(let s of n.g())n=t&&Oe(s,1)!=null?je(Oe(s,1),0):-1,e.push({score:te(s,2)??0,index:n,categoryName:et(s,3)??"",displayName:et(s,4)??""});r.push(e)}return r}var Te=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],T(e=this.j=new fc,0,1,t=new $),this.s=new ss,T(this.j,0,2,this.s),this.C=new os,T(this.s,0,3,this.C),this.v=new dc,T(this.s,0,2,this.v),this.h=new b2,T(this.j,0,3,this.h),v(this.v,2,.5),v(this.s,4,.5),v(this.C,2,.5)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){if(tt(this.v,3,e.numHands??1),"minHandDetectionConfidence"in e&&v(this.v,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.s,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&v(this.C,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new Ut,r=t,n=co(e.cannedGesturesClassifierOptions,O(this.h,Ut,3)?.h());T(r,0,2,n),T(this.h,0,3,t)}else e.cannedGesturesClassifierOptions===void 0&&O(this.h,Ut,3)?.g();return e.customGesturesClassifierOptions?(T(r=t=new Ut,0,2,n=co(e.customGesturesClassifierOptions,O(this.h,Ut,4)?.h())),T(this.h,0,4,t)):e.customGesturesClassifierOptions===void 0&&O(this.h,Ut,4)?.g(),this.l(e)}Ja(e,t){return Fa(this),De(this,e,t),Ua(this)}Ka(e,t,r){return Fa(this),rt(this,e,r,t),Ua(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"hand_gestures"),P(e,"hand_landmarks"),P(e,"world_hand_landmarks"),P(e,"handedness");let t=new ke;Xe(t,T2,this.j);let r=new xe;Ce(r,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"HAND_GESTURES:hand_gestures"),F(r,"LANDMARKS:hand_landmarks"),F(r,"WORLD_LANDMARKS:world_hand_landmarks"),F(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(n,o)=>{for(let s of n){n=kr(s);let a=[];for(let i of ct(n,rc,1))a.push({x:te(i,1)??0,y:te(i,2)??0,z:te(i,3)??0,visibility:te(i,4)??0});this.landmarks.push(a)}m(this,o)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,o)=>{for(let s of n){n=Nt(s);let a=[];for(let i of ct(n,tc,1))a.push({x:te(i,1)??0,y:te(i,2)??0,z:te(i,3)??0,visibility:te(i,4)??0});this.worldLandmarks.push(a)}m(this,o)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("hand_gestures",(n,o)=>{this.gestures.push(...Oa(n,!1)),m(this,o)}),this.g.attachEmptyPacketListener("hand_gestures",n=>{m(this,n)}),this.g.attachProtoVectorListener("handedness",(n,o)=>{this.handedness.push(...Oa(n)),m(this,o)}),this.g.attachEmptyPacketListener("handedness",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function Pa(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}Te.prototype.recognizeForVideo=Te.prototype.Ka,Te.prototype.recognize=Te.prototype.Ja,Te.prototype.setOptions=Te.prototype.o,Te.createFromModelPath=function(e,t){return M(Te,e,{baseOptions:{modelAssetPath:t}})},Te.createFromModelBuffer=function(e,t){return M(Te,e,{baseOptions:{modelAssetBuffer:t}})},Te.createFromOptions=function(e,t){return M(Te,e,t)},Te.HAND_CONNECTIONS=vs;var _e=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],T(e=this.h=new ss,0,1,t=new $),this.s=new os,T(this.h,0,3,this.s),this.j=new dc,T(this.h,0,2,this.j),tt(this.j,3,1),v(this.j,2,.5),v(this.s,2,.5),v(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numHands"in e&&tt(this.j,3,e.numHands??1),"minHandDetectionConfidence"in e&&v(this.j,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&v(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}D(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],De(this,e,t),Pa(this)}F(e,t,r){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],rt(this,e,r,t),Pa(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"hand_landmarks"),P(e,"world_hand_landmarks"),P(e,"handedness");let t=new ke;Xe(t,_2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"LANDMARKS:hand_landmarks"),F(r,"WORLD_LANDMARKS:world_hand_landmarks"),F(r,"HANDEDNESS:handedness"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("hand_landmarks",(n,o)=>{for(let s of n)n=kr(s),this.landmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("world_hand_landmarks",(n,o)=>{for(let s of n)n=Nt(s),this.worldLandmarks.push(xr(n));m(this,o)}),this.g.attachEmptyPacketListener("world_hand_landmarks",n=>{m(this,n)}),this.g.attachProtoVectorListener("handedness",(n,o)=>{var s=this.handedness,a=s.push;let i=[];for(let c of n){n=En(c);let l=[];for(let h of n.g())l.push({score:te(h,2)??0,index:je(Oe(h,1),0)??-1,categoryName:et(h,3)??"",displayName:et(h,4)??""});i.push(l)}a.call(s,...i),m(this,o)}),this.g.attachEmptyPacketListener("handedness",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};_e.prototype.detectForVideo=_e.prototype.F,_e.prototype.detect=_e.prototype.D,_e.prototype.setOptions=_e.prototype.o,_e.createFromModelPath=function(e,t){return M(_e,e,{baseOptions:{modelAssetPath:t}})},_e.createFromModelBuffer=function(e,t){return M(_e,e,{baseOptions:{modelAssetBuffer:t}})},_e.createFromOptions=function(e,t){return M(_e,e,t)},_e.HAND_CONNECTIONS=vs;var Nc=ze([0,1],[1,2],[2,3],[3,7],[0,4],[4,5],[5,6],[6,8],[9,10],[11,12],[11,13],[13,15],[15,17],[15,19],[15,21],[17,19],[12,14],[14,16],[16,18],[16,20],[16,22],[18,20],[11,23],[12,24],[23,24],[23,25],[24,26],[25,27],[26,28],[27,29],[28,30],[29,31],[30,32],[27,31],[28,32]);function Ba(e){e.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]}}function Da(e){try{if(!e.C)return e.h;e.C(e.h)}finally{An(e)}}function Br(e,t){e=kr(e),t.push(Tn(e))}var K=class extends Ee{constructor(e,t){super(new Be(e,t),"input_frames_image",null,!1),this.h={faceLandmarks:[],faceBlendshapes:[],poseLandmarks:[],poseWorldLandmarks:[],poseSegmentationMasks:[],leftHandLandmarks:[],leftHandWorldLandmarks:[],rightHandLandmarks:[],rightHandWorldLandmarks:[]},this.outputPoseSegmentationMasks=this.outputFaceBlendshapes=!1,T(e=this.j=new yc,0,1,t=new $),this.K=new os,T(this.j,0,2,this.K),this.aa=new A2,T(this.j,0,3,this.aa),this.s=new bn,T(this.j,0,4,this.s),this.I=new ic,T(this.j,0,5,this.I),this.v=new gc,T(this.j,0,6,this.v),this.L=new xc,T(this.j,0,7,this.L),v(this.s,2,.5),v(this.s,3,.3),v(this.I,2,.5),v(this.v,2,.5),v(this.v,3,.3),v(this.L,2,.5),v(this.K,2,.5)}get baseOptions(){return O(this.j,$,1)}set baseOptions(e){T(this.j,0,1,e)}o(e){return"minFaceDetectionConfidence"in e&&v(this.s,2,e.minFaceDetectionConfidence??.5),"minFaceSuppressionThreshold"in e&&v(this.s,3,e.minFaceSuppressionThreshold??.3),"minFacePresenceConfidence"in e&&v(this.I,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"minPoseDetectionConfidence"in e&&v(this.v,2,e.minPoseDetectionConfidence??.5),"minPoseSuppressionThreshold"in e&&v(this.v,3,e.minPoseSuppressionThreshold??.3),"minPosePresenceConfidence"in e&&v(this.L,2,e.minPosePresenceConfidence??.5),"outputPoseSegmentationMasks"in e&&(this.outputPoseSegmentationMasks=!!e.outputPoseSegmentationMasks),"minHandLandmarksConfidence"in e&&v(this.K,2,e.minHandLandmarksConfidence??.5),this.l(e)}D(e,t,r){let n=typeof t!="function"?t:{};return this.C=typeof t=="function"?t:r,Ba(this),De(this,e,n),Da(this)}F(e,t,r,n){let o=typeof r!="function"?r:{};return this.C=typeof r=="function"?r:n,Ba(this),rt(this,e,o,t),Da(this)}m(){var e=new be;Y(e,"input_frames_image"),P(e,"pose_landmarks"),P(e,"pose_world_landmarks"),P(e,"face_landmarks"),P(e,"left_hand_landmarks"),P(e,"left_hand_world_landmarks"),P(e,"right_hand_landmarks"),P(e,"right_hand_world_landmarks");let t=new ke,r=new na;to(r,1,Jt("type.googleapis.com/mediapipe.tasks.vision.holistic_landmarker.proto.HolisticLandmarkerGraphOptions"),""),function(o,s){if(s!=null)if(Array.isArray(s))X(o,2,cn(s,Mo,void 0,void 0,!1));else{if(!(typeof s=="string"||s instanceof at||_r(s)))throw Error("invalid value in Any.value field: "+s+" expected a ByteString, a base64 encoded string, a Uint8Array or a jspb array");to(o,2,_o(s,!1),Mt())}}(r,this.j.g());let n=new xe;Ce(n,"mediapipe.tasks.vision.holistic_landmarker.HolisticLandmarkerGraph"),$r(n,8,na,r),H(n,"IMAGE:input_frames_image"),F(n,"POSE_LANDMARKS:pose_landmarks"),F(n,"POSE_WORLD_LANDMARKS:pose_world_landmarks"),F(n,"FACE_LANDMARKS:face_landmarks"),F(n,"LEFT_HAND_LANDMARKS:left_hand_landmarks"),F(n,"LEFT_HAND_WORLD_LANDMARKS:left_hand_world_landmarks"),F(n,"RIGHT_HAND_LANDMARKS:right_hand_landmarks"),F(n,"RIGHT_HAND_WORLD_LANDMARKS:right_hand_world_landmarks"),n.o(t),Le(e,n),_n(this,e),this.g.attachProtoListener("pose_landmarks",(o,s)=>{Br(o,this.h.poseLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("pose_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("pose_world_landmarks",(o,s)=>{var a=this.h.poseWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("pose_world_landmarks",o=>{m(this,o)}),this.outputPoseSegmentationMasks&&(F(n,"POSE_SEGMENTATION_MASK:pose_segmentation_mask"),Xt(this,"pose_segmentation_mask"),this.g.V("pose_segmentation_mask",(o,s)=>{this.h.poseSegmentationMasks=[zt(this,o,!0,!this.C)],m(this,s)}),this.g.attachEmptyPacketListener("pose_segmentation_mask",o=>{this.h.poseSegmentationMasks=[],m(this,o)})),this.g.attachProtoListener("face_landmarks",(o,s)=>{Br(o,this.h.faceLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("face_landmarks",o=>{m(this,o)}),this.outputFaceBlendshapes&&(P(e,"extra_blendshapes"),F(n,"FACE_BLENDSHAPES:extra_blendshapes"),this.g.attachProtoListener("extra_blendshapes",(o,s)=>{var a=this.h.faceBlendshapes;this.outputFaceBlendshapes&&(o=En(o),a.push(us(o.g()??[]))),m(this,s)}),this.g.attachEmptyPacketListener("extra_blendshapes",o=>{m(this,o)})),this.g.attachProtoListener("left_hand_landmarks",(o,s)=>{Br(o,this.h.leftHandLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("left_hand_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("left_hand_world_landmarks",(o,s)=>{var a=this.h.leftHandWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("left_hand_world_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("right_hand_landmarks",(o,s)=>{Br(o,this.h.rightHandLandmarks),m(this,s)}),this.g.attachEmptyPacketListener("right_hand_landmarks",o=>{m(this,o)}),this.g.attachProtoListener("right_hand_world_landmarks",(o,s)=>{var a=this.h.rightHandWorldLandmarks;o=Nt(o),a.push(xr(o)),m(this,s)}),this.g.attachEmptyPacketListener("right_hand_world_landmarks",o=>{m(this,o)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};K.prototype.detectForVideo=K.prototype.F,K.prototype.detect=K.prototype.D,K.prototype.setOptions=K.prototype.o,K.createFromModelPath=function(e,t){return M(K,e,{baseOptions:{modelAssetPath:t}})},K.createFromModelBuffer=function(e,t){return M(K,e,{baseOptions:{modelAssetBuffer:t}})},K.createFromOptions=function(e,t){return M(K,e,t)},K.HAND_CONNECTIONS=vs,K.POSE_CONNECTIONS=Nc,K.FACE_LANDMARKS_LIPS=fs,K.FACE_LANDMARKS_LEFT_EYE=ps,K.FACE_LANDMARKS_LEFT_EYEBROW=ms,K.FACE_LANDMARKS_LEFT_IRIS=Oc,K.FACE_LANDMARKS_RIGHT_EYE=gs,K.FACE_LANDMARKS_RIGHT_EYEBROW=xs,K.FACE_LANDMARKS_RIGHT_IRIS=Pc,K.FACE_LANDMARKS_FACE_OVAL=ys,K.FACE_LANDMARKS_CONTOURS=Bc,K.FACE_LANDMARKS_TESSELATION=Dc;var Me=class extends Ee{constructor(e,t){super(new Be(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},T(e=this.h=new vc,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return T(this.h,0,2,co(e,O(this.h,ts,2))),this.l(e)}ta(e,t){return this.j={classifications:[]},De(this,e,t),this.j}ua(e,t,r){return this.j={classifications:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"input_image"),Y(e,"norm_rect"),P(e,"classifications");let t=new ke;Xe(t,R2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),H(r,"IMAGE:input_image"),H(r,"NORM_RECT:norm_rect"),F(r,"CLASSIFICATIONS:classifications"),r.o(t),Le(e,r),this.g.attachProtoListener("classifications",(n,o)=>{this.j=function(s){let a={classifications:ct(s,l2,1).map(i=>us(O(i,Qi,4)?.g()??[],je(Oe(i,2),0),et(i,3)))};return zr(vt(s,2))!=null&&(a.timestampMs=je(zr(vt(s,2)),0)),a}(d2(n)),m(this,o)}),this.g.attachEmptyPacketListener("classifications",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Me.prototype.classifyForVideo=Me.prototype.ua,Me.prototype.classify=Me.prototype.ta,Me.prototype.setOptions=Me.prototype.o,Me.createFromModelPath=function(e,t){return M(Me,e,{baseOptions:{modelAssetPath:t}})},Me.createFromModelBuffer=function(e,t){return M(Me,e,{baseOptions:{modelAssetBuffer:t}})},Me.createFromOptions=function(e,t){return M(Me,e,t)};var Ae=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!0),this.h=new Ec,this.embeddings={embeddings:[]},T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){var t=this.h,r=O(this.h,da,2);return r=r?r.clone():new da,e.l2Normalize!==void 0?Er(r,1,e.l2Normalize):"l2Normalize"in e&&X(r,1),e.quantize!==void 0?Er(r,2,e.quantize):"quantize"in e&&X(r,2),T(t,0,2,r),this.l(e)}Aa(e,t){return De(this,e,t),this.embeddings}Ba(e,t,r){return rt(this,e,r,t),this.embeddings}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"embeddings_out");let t=new ke;Xe(t,w2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"EMBEDDINGS:embeddings_out"),r.o(t),Le(e,r),this.g.attachProtoListener("embeddings_out",(n,o)=>{n=m2(n),this.embeddings=function(s){return{embeddings:ct(s,p2,1).map(a=>{let i={headIndex:je(Oe(a,3),0)??-1,headName:et(a,4)??""};if(xi(a,la,Vn(a,1))!==void 0)a=Ct(a=O(a,la,Vn(a,1)),1,At,St()),i.floatEmbedding=a.slice();else{let c=new Uint8Array(0);i.quantizedEmbedding=O(a,f2,Vn(a,2))?.pa()?.h()??c}return i}),timestampMs:je(zr(vt(s,2)),0)}}(n),m(this,o)}),this.g.attachEmptyPacketListener("embeddings_out",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Ae.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=xa(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=xa(ga(e.quantizedEmbedding),ga(t.quantizedEmbedding))}return e},Ae.prototype.embedForVideo=Ae.prototype.Ba,Ae.prototype.embed=Ae.prototype.Aa,Ae.prototype.setOptions=Ae.prototype.o,Ae.createFromModelPath=function(e,t){return M(Ae,e,{baseOptions:{modelAssetPath:t}})},Ae.createFromModelBuffer=function(e,t){return M(Ae,e,{baseOptions:{modelAssetBuffer:t}})},Ae.createFromOptions=function(e,t){return M(Ae,e,t)};var fo=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){this.confidenceMasks?.forEach(e=>{e.close()}),this.categoryMask?.close()}};function Na(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function Ga(e){try{let t=new fo(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{An(e)}}fo.prototype.close=fo.prototype.close;var de=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new cs,this.v=new bc,T(this.h,0,3,this.v),T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?X(this.h,2,Jt(e.displayNamesLocale)):"displayNamesLocale"in e&&X(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}J(){(function(e){let t=ct(e.ea(),xe,1).filter(r=>et(r,1).includes("mediapipe.tasks.TensorsToSegmentationCalculator"));if(e.s=[],t.length>1)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");t.length===1&&(O(t[0],ke,7)?.l()?.g()??new Map).forEach((r,n)=>{e.s[Number(n)]=et(r,1)})})(this)}segment(e,t,r){let n=typeof t!="function"?t:{};return this.j=typeof t=="function"?t:r,Na(this),De(this,e,n),Ga(this)}Ma(e,t,r,n){let o=typeof r!="function"?r:{};return this.j=typeof r=="function"?r:n,Na(this),rt(this,e,o,t),Ga(this)}Ea(){return this.s}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect");let t=new ke;Xe(t,_c,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),r.o(t),Le(e,r),_n(this,e),this.outputConfidenceMasks&&(P(e,"confidence_masks"),F(r,"CONFIDENCE_MASKS:confidence_masks"),Xt(this,"confidence_masks"),this.g.da("confidence_masks",(n,o)=>{this.confidenceMasks=n.map(s=>zt(this,s,!0,!this.j)),m(this,o)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],m(this,n)})),this.outputCategoryMask&&(P(e,"category_mask"),F(r,"CATEGORY_MASK:category_mask"),Xt(this,"category_mask"),this.g.V("category_mask",(n,o)=>{this.categoryMask=zt(this,n,!1,!this.j),m(this,o)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,m(this,n)})),P(e,"quality_scores"),F(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,o)=>{this.qualityScores=n,m(this,o)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};de.prototype.getLabels=de.prototype.Ea,de.prototype.segmentForVideo=de.prototype.Ma,de.prototype.segment=de.prototype.segment,de.prototype.setOptions=de.prototype.o,de.createFromModelPath=function(e,t){return M(de,e,{baseOptions:{modelAssetPath:t}})},de.createFromModelBuffer=function(e,t){return M(de,e,{baseOptions:{modelAssetBuffer:t}})},de.createFromOptions=function(e,t){return M(de,e,t)};var po=class{constructor(e,t,r){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=r}close(){this.confidenceMasks?.forEach(e=>{e.close()}),this.categoryMask?.close()}};po.prototype.close=po.prototype.close;var P2=class extends x{constructor(e){super(e)}},Ot=[0,ee,-2],en=[0,ot,-3,q,ot,-1],Va=[0,en],ja=[0,en,ee,-1],Kn=class extends x{constructor(e){super(e)}},Wa=[0,ot,-1,q],B2=class extends x{constructor(){super()}},Xa=class extends x{constructor(e){super(e)}},mo=[1,2,3,4,5,6,7,8,9,10,14,15],Gc=class extends x{constructor(){super()}};Gc.prototype.g=vn([0,ie,[0,mo,N,en,N,[0,en,Ot],N,Va,N,[0,Va,Ot],N,Wa,N,[0,ot,-3,q,We],N,[0,ot,-3,q],N,[0,D,ot,-2,q,ee,q,-1,2,ot,Ot],N,ja,N,[0,ja,Ot],ot,Ot,D,N,[0,ot,-3,q,Ot,-1],N,[0,ie,Wa]],D,[0,D,ee,-1,q]]);var Qe=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new cs,this.s=new bc,T(this.h,0,3,this.s),T(e=this.h,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}segment(e,t,r,n){let o=typeof r!="function"?r:{};this.j=typeof r=="function"?r:n,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,r=this.B+1,n=new Gc;let s=new Xa;var a=new P2;if(tt(a,1,255),T(s,0,12,a),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var i=new Kn;Er(i,3,!0),v(i,1,t.keypoint.x),v(i,2,t.keypoint.y),mr(s,5,mo,i)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(i of(a=new B2,t.scribble))Er(t=new Kn,3,!0),v(t,1,i.x),v(t,2,i.y),$r(a,1,Kn,t);mr(s,15,mo,a)}$r(n,1,Xa,s),this.g.addProtoToStream(n.g(),"drishti.RenderData","roi_in",r),De(this,e,o);e:{try{let l=new po(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var c=l;break e}this.j(l)}finally{An(this)}c=void 0}return c}m(){var e=new be;Y(e,"image_in"),Y(e,"roi_in"),Y(e,"norm_rect_in");let t=new ke;Xe(t,_c,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),H(r,"IMAGE:image_in"),H(r,"ROI:roi_in"),H(r,"NORM_RECT:norm_rect_in"),r.o(t),Le(e,r),_n(this,e),this.outputConfidenceMasks&&(P(e,"confidence_masks"),F(r,"CONFIDENCE_MASKS:confidence_masks"),Xt(this,"confidence_masks"),this.g.da("confidence_masks",(n,o)=>{this.confidenceMasks=n.map(s=>zt(this,s,!0,!this.j)),m(this,o)}),this.g.attachEmptyPacketListener("confidence_masks",n=>{this.confidenceMasks=[],m(this,n)})),this.outputCategoryMask&&(P(e,"category_mask"),F(r,"CATEGORY_MASK:category_mask"),Xt(this,"category_mask"),this.g.V("category_mask",(n,o)=>{this.categoryMask=zt(this,n,!1,!this.j),m(this,o)}),this.g.attachEmptyPacketListener("category_mask",n=>{this.categoryMask=void 0,m(this,n)})),P(e,"quality_scores"),F(r,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",(n,o)=>{this.qualityScores=n,m(this,o)}),this.g.attachEmptyPacketListener("quality_scores",n=>{this.categoryMask=void 0,m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Qe.prototype.segment=Qe.prototype.segment,Qe.prototype.setOptions=Qe.prototype.o,Qe.createFromModelPath=function(e,t){return M(Qe,e,{baseOptions:{modelAssetPath:t}})},Qe.createFromModelBuffer=function(e,t){return M(Qe,e,{baseOptions:{modelAssetBuffer:t}})},Qe.createFromOptions=function(e,t){return M(Qe,e,t)};var Fe=class extends Ee{constructor(e,t){super(new Be(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},T(e=this.h=new Ac,0,1,t=new $)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return e.displayNamesLocale!==void 0?X(this.h,2,Jt(e.displayNamesLocale)):"displayNamesLocale"in e&&X(this.h,2),e.maxResults!==void 0?tt(this.h,3,e.maxResults):"maxResults"in e&&X(this.h,3),e.scoreThreshold!==void 0?v(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&X(this.h,4),e.categoryAllowlist!==void 0?qr(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&X(this.h,5),e.categoryDenylist!==void 0?qr(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&X(this.h,6),this.l(e)}D(e,t){return this.j={detections:[]},De(this,e,t),this.j}F(e,t,r){return this.j={detections:[]},rt(this,e,r,t),this.j}m(){var e=new be;Y(e,"input_frame_gpu"),Y(e,"norm_rect"),P(e,"detections");let t=new ke;Xe(t,S2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.ObjectDetectorGraph"),H(r,"IMAGE:input_frame_gpu"),H(r,"NORM_RECT:norm_rect"),F(r,"DETECTIONS:detections"),r.o(t),Le(e,r),this.g.attachProtoVectorListener("detections",(n,o)=>{for(let s of n)n=ec(s),this.j.detections.push(wc(n));m(this,o)}),this.g.attachEmptyPacketListener("detections",n=>{m(this,n)}),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Fe.prototype.detectForVideo=Fe.prototype.F,Fe.prototype.detect=Fe.prototype.D,Fe.prototype.setOptions=Fe.prototype.o,Fe.createFromModelPath=async function(e,t){return M(Fe,e,{baseOptions:{modelAssetPath:t}})},Fe.createFromModelBuffer=function(e,t){return M(Fe,e,{baseOptions:{modelAssetBuffer:t}})},Fe.createFromOptions=function(e,t){return M(Fe,e,t)};var go=class{constructor(e,t,r){this.landmarks=e,this.worldLandmarks=t,this.segmentationMasks=r}close(){this.segmentationMasks?.forEach(e=>{e.close()})}};function Ha(e){e.landmarks=[],e.worldLandmarks=[],e.segmentationMasks=void 0}function Ya(e){try{let t=new go(e.landmarks,e.worldLandmarks,e.segmentationMasks);if(!e.s)return t;e.s(t)}finally{An(e)}}go.prototype.close=go.prototype.close;var Re=class extends Ee{constructor(e,t){super(new Be(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,T(e=this.h=new Rc,0,1,t=new $),this.v=new xc,T(this.h,0,3,this.v),this.j=new gc,T(this.h,0,2,this.j),tt(this.j,4,1),v(this.j,2,.5),v(this.v,2,.5),v(this.h,4,.5)}get baseOptions(){return O(this.h,$,1)}set baseOptions(e){T(this.h,0,1,e)}o(e){return"numPoses"in e&&tt(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&v(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&v(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&v(this.v,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}D(e,t,r){let n=typeof t!="function"?t:{};return this.s=typeof t=="function"?t:r,Ha(this),De(this,e,n),Ya(this)}F(e,t,r,n){let o=typeof r!="function"?r:{};return this.s=typeof r=="function"?r:n,Ha(this),rt(this,e,o,t),Ya(this)}m(){var e=new be;Y(e,"image_in"),Y(e,"norm_rect"),P(e,"normalized_landmarks"),P(e,"world_landmarks"),P(e,"segmentation_masks");let t=new ke;Xe(t,C2,this.h);let r=new xe;Ce(r,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),H(r,"IMAGE:image_in"),H(r,"NORM_RECT:norm_rect"),F(r,"NORM_LANDMARKS:normalized_landmarks"),F(r,"WORLD_LANDMARKS:world_landmarks"),r.o(t),Le(e,r),_n(this,e),this.g.attachProtoVectorListener("normalized_landmarks",(n,o)=>{this.landmarks=[];for(let s of n)n=kr(s),this.landmarks.push(Tn(n));m(this,o)}),this.g.attachEmptyPacketListener("normalized_landmarks",n=>{this.landmarks=[],m(this,n)}),this.g.attachProtoVectorListener("world_landmarks",(n,o)=>{this.worldLandmarks=[];for(let s of n)n=Nt(s),this.worldLandmarks.push(xr(n));m(this,o)}),this.g.attachEmptyPacketListener("world_landmarks",n=>{this.worldLandmarks=[],m(this,n)}),this.outputSegmentationMasks&&(F(r,"SEGMENTATION_MASK:segmentation_masks"),Xt(this,"segmentation_masks"),this.g.da("segmentation_masks",(n,o)=>{this.segmentationMasks=n.map(s=>zt(this,s,!0,!this.s)),m(this,o)}),this.g.attachEmptyPacketListener("segmentation_masks",n=>{this.segmentationMasks=[],m(this,n)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};Re.prototype.detectForVideo=Re.prototype.F,Re.prototype.detect=Re.prototype.D,Re.prototype.setOptions=Re.prototype.o,Re.createFromModelPath=function(e,t){return M(Re,e,{baseOptions:{modelAssetPath:t}})},Re.createFromModelBuffer=function(e,t){return M(Re,e,{baseOptions:{modelAssetBuffer:t}})},Re.createFromOptions=function(e,t){return M(Re,e,t)},Re.POSE_CONNECTIONS=Nc;var _=(e,t="AssertError")=>{if(!e)throw new Error(t,{cause:e});return e};var Es=e=>e;var bs=(e,...t)=>{let r=t.reduce((n,o)=>s=>o(n(s)),Es);return(...n)=>r(e(...n))};var N2="utils/memoize/noValue",Ml=Symbol(N2);var G2=e=>`(${e})`;var Vc=e=>G2(`?:${e}`),V2=e=>`${Vc(e)}?`,j2=e=>`${Vc(e)}*`;var W2=e=>`^${e}`,X2=e=>`${e}$`,H2=e=>typeof e=="function",Y2=e=>t=>H2(t)?t(e):t;var z2=()=>e=>e,kn=(e,t=z2)=>r=>n=>bs(Y2(n),t(n),e)(r);var Ol=kn(e=>V2(e)),Pl=kn(e=>j2(e));var Bl=kn(e=>W2(e)),Dl=kn(e=>X2(e));var z={Closed:"closed",Closing:"closing",Destroyed:"destroyed",Destroying:"destroying",Error:"Error",Idle:"idle",New:"new",Opened:"opened",Opening:"opening",Processing:"processing",Updated:"updated",Updating:"updating"},jc={None:"none",Blur:"blur",Overlay:"overlay"},Wc={WebGL:"webgl",WebGPU:"webgpu"},C={ContextCreationError:"ContextCreationError",ContextLost:"ContextLost",ContextRestored:"ContextRestored",Error:"Error",ProcessorRestarted:"ProcessorRestarted",SamplingError:"SamplingError"};var K2=e=>!!(typeof e=="string"&&Object.values(C).includes(e)),Sn=e=>K2(e)?e:C.Error,Cn=e=>e instanceof Error?e.message:String(e),Ln=e=>{let t=new Set(Object.keys(e));return r=>{for(let n in r)t.has(n)&&typeof e[n]==typeof r[n]&&(e[n]=r[n])}},Xc=e=>{let t=new Map(e),r=new Set,n=async a=>{let c=await(await fetch(a)).blob();return await createImageBitmap(c)},o=async a=>{let i=t.get(a);if(!i){if(r.has(a))return null;r.add(a);let c=await n(a);return t.set(a,c),r.delete(a),c}return i},s=a=>(t.get(a)?.close(),t.delete(a));return{tryFetchingImage:o,setImage:(a,i)=>{t.has(a)&&s(a),t.set(a,i)},getImage:a=>t.get(a)??null,removeImage:s,clear:()=>{for(let a of t.values())a.close();t.clear()}}},In=(e,t)=>r=>Math.min(Math.max(r,e),t);var Hc=(e,t,r,n)=>{if(!e||!t||!r||!n||e*n===r*t)return{sx:0,sy:0,sw:e,sh:t,dx:0,dy:0,dw:r,dh:n};let o=e/t,s=r/n;if(o>s){let l=Math.ceil(e*s)/o,h=Math.abs(e-l);return{sx:Math.ceil(h/2),sy:0,sw:l,sh:t,dx:0,dy:0,dw:r,dh:n}}let a=Math.ceil(t*o)/s,i=Math.abs(t-a);return{sx:0,sy:Math.ceil(i/2),sw:e,sh:a,dx:0,dy:0,dw:r,dh:n}},or=e=>{let t={};return new Proxy(t,{get(r,n,o){return r[n]||(r[n]=e[n]?.(t)),Reflect.get(r,n,o)}})},Yc=(e,t,r)=>{let n=a=>{a.preventDefault(),r?.(),t.contextLost(a.statusMessage)},o=a=>{t.contextRestored(a.statusMessage)},s=a=>{t.contextCreationError(a.statusMessage)};return e.addEventListener("webglcontextlost",n),e.addEventListener("webglcontextrestored",o),e.addEventListener("webglcontextcreationerror",s),()=>{e.removeEventListener("webglcontextlost",n),e.removeEventListener("webglcontextrestored",o),e.removeEventListener("webglcontextcreationerror",s)}};var zc=(e,t,r)=>{let n=navigator.gpu.getPreferredCanvasFormat(),o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");o.configure({device:t,format:n});let s;return{render:a=>(_(!r(),C.ContextLost),s=t.createTexture({label:"Video Frame to Texture",format:"rgba8unorm",size:[a.width,a.height],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT}),t.queue.copyExternalImageToTexture({source:a.frame,flipY:!1},{texture:s},{width:a.width,height:a.height}),t.queue.submit([]),s),release:()=>{s?.destroy()}}};var Ts="@group(0)@binding(0)var mySampler:sampler;@group(0)@binding(1)var bgTexture:texture_2d<f32>;@group(0)@binding(2)var personTexture:texture_2d<f32>;@group(0)@binding(3)var maskTexture:texture_2d<f32>;struct VertexOutput{@builtin(position)Position:vec4f,@location(0)fragUV:vec2f,}@vertex fn vert_main(@builtin(vertex_index)VertexIndex:u32)->VertexOutput{const pos=array(vec2(1.0,1.0),vec2(1.0,-1.0),vec2(-1.0,-1.0),vec2(1.0,1.0),vec2(-1.0,-1.0),vec2(-1.0,1.0),);const uv=array(vec2(1.0,0.0),vec2(1.0,1.0),vec2(0.0,1.0),vec2(1.0,0.0),vec2(0.0,1.0),vec2(0.0,0.0),);var output:VertexOutput;output.Position=vec4(pos[VertexIndex],0.0,1.0);output.fragUV=uv[VertexIndex];return output;}@fragment fn frag_main(@location(0)fragUV:vec2f)->@location(0)vec4f{let bg=textureSample(bgTexture,mySampler,fragUV);let person=textureSample(personTexture,mySampler,fragUV);let mask=textureSample(maskTexture,mySampler,fragUV);var alpha=mask.r;if(alpha<0.5){alpha=0;}return mix(bg,person,alpha);}";var sr=[0,0,0,0];var Kc=(e,t,r,n)=>{let o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");return o.configure({device:t,format:r,alphaMode:"premultiplied"}),{render:(s,a,i)=>{_(!n(),C.ContextLost);let c=t.createRenderPipeline({label:"blender pipeline",layout:"auto",vertex:{module:t.createShaderModule({label:"blender vertex",code:Ts})},fragment:{module:t.createShaderModule({label:"blender fragment",code:Ts}),targets:[{format:r}]}}),l=t.createCommandEncoder({label:"blender encoder"}),h=l.beginRenderPass({label:"blender renderPass",colorAttachments:[{view:o.getCurrentTexture().createView(),clearValue:sr,loadOp:"clear",storeOp:"store"}]});h.setPipeline(c);let p=t.createSampler({addressModeU:"repeat",addressModeV:"repeat",magFilter:"nearest"}),d=t.createBindGroup({layout:c.getBindGroupLayout(0),entries:[{binding:0,resource:p},{binding:1,resource:a.createView()},{binding:2,resource:s.createView()},{binding:3,resource:i.createView()}]});h.setBindGroup(0,d),h.draw(6),h.end();let g=l.finish();t.queue.submit([g])},release:()=>{}}};var _s=e=>e.features.has("bgra8unorm-storage"),$c=async e=>await e?.requestDevice({requiredFeatures:_s(e)?["bgra8unorm-storage"]:[]});var qc="@group(0)@binding(0)var u_sampler:sampler;@group(0)@binding(1)var u_frame:texture_2d<f32>;@group(0)@binding(2)var<uniform> flip:Flip;struct Flip{value:u32,}struct VertexOutput{@builtin(position)Position:vec4f,@location(0)fragUV:vec2f,}fn Downsample(uv:vec2<f32>,halfpixel:vec2<f32>)->vec4<f32>{var sum=textureSample(u_frame,u_sampler,uv)*4.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y+halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y-halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y-halfpixel.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y+halfpixel.y));return sum/8.0;}fn Upsample(uv:vec2<f32>,halfpixel:vec2<f32>)->vec4<f32>{var sum=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x*2.0,uv.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x*2.0,uv.y));sum+=textureSample(u_frame,u_sampler,vec2(uv.x,uv.y+halfpixel.y*2.0));sum+=textureSample(u_frame,u_sampler,vec2(uv.x,uv.y-halfpixel.y*2.0));sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y+halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y+halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x+halfpixel.x,uv.y-halfpixel.y))*2.0;sum+=textureSample(u_frame,u_sampler,vec2(uv.x-halfpixel.x,uv.y-halfpixel.y))*2.0;return sum/12.0;}@fragment fn frag_main(@location(0)v_texCoord:vec2<f32>)->@location(0)vec4<f32>{let texSize=vec2<f32>(textureDimensions(u_frame));let texel_size=1.0/texSize;let halfpixel=texel_size*0.5;var color:vec4<f32>;if(flip.value!=1u){color=Downsample(v_texCoord,halfpixel);}else{color=Upsample(v_texCoord,halfpixel);}return color;}@vertex fn vert_main(@builtin(vertex_index)VertexIndex:u32)->VertexOutput{const pos=array(vec2(1.0,1.0),vec2(1.0,-1.0),vec2(-1.0,-1.0),vec2(1.0,1.0),vec2(-1.0,-1.0),vec2(-1.0,1.0),);const uv=array(vec2(1.0,0.0),vec2(1.0,1.0),vec2(0.0,1.0),vec2(1.0,0.0),vec2(0.0,1.0),vec2(0.0,0.0),);var output:VertexOutput;output.Position=vec4(pos[VertexIndex],0.0,1.0);output.fragUV=uv[VertexIndex];return output;}";var $2=In(1,9),Jc=(e,t,r,n)=>{let o=e.getContext("webgpu");if(!o)throw Error("WebGPU not supported on the canvas.");o.configure({device:t,format:r,alphaMode:"premultiplied"});let s=(S,w)=>t.createTexture({format:r,size:[S,w],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT}),a=S=>{let w=t.createBuffer({size:4,mappedAtCreation:!0,usage:GPUBufferUsage.UNIFORM});return new Uint32Array(w.getMappedRange())[0]=S,w.unmap(),w},i=t.createSampler({magFilter:"linear",minFilter:"linear"}),c=t.createShaderModule({code:qc}),l=t.createRenderPipeline({label:"dual blur render pipeline",layout:"auto",vertex:{module:c,entryPoint:"vert_main",buffers:[]},fragment:{module:c,entryPoint:"frag_main",targets:[{format:r}]},primitive:{topology:"triangle-list"}}),h=[],p=-1,d=-1;function g(S,w,f){let y=$2(S+1),b=!1;if(h.length!==y||p!==w||d!==f){for(let L of h)L.texture.destroy();h=[];for(let L=0;L<y;L++){let I=Math.max(Math.trunc(w/2**L),1),k=Math.max(Math.trunc(f/2**L),1);h.push({texture:s(I,k),width:I,height:k})}p=w,d=f,b=!0}return b}let A=a(0),R=a(1);return{render:(S,w)=>{_(!n(),C.ContextLost),g(w,e.width,e.height);let f=h[0];_(f),t.queue.copyExternalImageToTexture({source:S.frame,flipY:!1},{texture:f.texture},{width:f.width,height:f.height});for(let k=1;k<h.length;k++){let B=h[k-1];_(B);let U=h[k];_(U);let j=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:B.texture.createView()},{binding:2,resource:{buffer:A}}]}),W=t.createCommandEncoder(),le=W.beginRenderPass({colorAttachments:[{view:U.texture.createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});le.setPipeline(l),le.setBindGroup(0,j),le.draw(6),le.end(),t.queue.submit([W.finish()])}for(let k=h.length-2;k>=0;k--){let B=h[k+1];_(B);let U=h[k];_(U);let j=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:B.texture.createView()},{binding:2,resource:{buffer:R}}]}),W=t.createCommandEncoder(),le=W.beginRenderPass({colorAttachments:[{view:U.texture.createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});le.setPipeline(l),le.setBindGroup(0,j),le.draw(6),le.end(),t.queue.submit([W.finish()])}let y=h[0];_(y);let b=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:0,resource:i},{binding:1,resource:y.texture.createView()},{binding:2,resource:{buffer:R}}]}),L=t.createCommandEncoder(),I=L.beginRenderPass({colorAttachments:[{view:o.getCurrentTexture().createView(),loadOp:"clear",storeOp:"store",clearValue:sr}]});return I.setPipeline(l),I.setBindGroup(0,b),I.draw(6),I.end(),t.queue.submit([L.finish()]),y.texture},release:()=>{for(let S of h)S.texture.destroy();h=[],A.destroy(),R.destroy()}}};var Qc="@group(0)@binding(1)var mask:texture_2d<f32>;@group(0)@binding(2)var prevMask:texture_2d<f32>;@group(0)@binding(3)var outputTex:texture_storage_2d<rgba8unorm,write>;struct Params{maskCombineRatio:f32,foregroundThreshold:f32,}@group(0)@binding(4)var<uniform> params:Params;fn smoothingMask(prevMask:texture_2d<f32>,mask:texture_2d<f32>,uv:vec2<u32>,ratio:f32)->f32{let prevMaskValue=textureLoad(prevMask,uv,0u).r;let currMaskValue=textureLoad(mask,uv,0u).r;let c1=5.68842;let c2=-0.748699;let c3=-57.8051;let c4=291.309;let c5=-624.717;let t=currMaskValue-0.5;let x=t*t;let uncertainty=1.0-min(1.0,x*(c1+x*(c2+x*(c3+x*(c4+x*c5)))));return currMaskValue+(prevMaskValue-currMaskValue)*(uncertainty*ratio);}@compute @workgroup_size(32,1,1)fn main(@builtin(workgroup_id)WorkGroupID:vec3u,@builtin(local_invocation_id)LocalInvocationID:vec3u){let blockDim:u32=128;let baseIndex=vec2i(WorkGroupID.xy*vec2(blockDim,4)+LocalInvocationID.xy*vec2(4,1));for(var r=0;r<4;r++){for(var c=0;c<4;c++){var uv=baseIndex+vec2(c,r);let maskAlpha=smoothingMask(prevMask,mask,vec2<u32>(uv),params.maskCombineRatio);var backgroundMask=maskAlpha;if backgroundMask<params.foregroundThreshold{backgroundMask=0.0;}textureStore(outputTex,uv,vec4<f32>(backgroundMask,backgroundMask,backgroundMask,backgroundMask));}}}";var Zc=(e,t,r)=>{let n=t.createTexture({label:"Smoothed Mask Texture",format:"rgba8unorm",size:[e.width,e.height],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.STORAGE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC}),o=t.createBuffer({size:2*4,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),s=a=>{t.queue.writeBuffer(o,0,new Float32Array([a.maskCombineRatio,a.foregroundThreshold]))};return{render:(a,i,c)=>{if(_(!r(),C.ContextLost),!i)return a;let l=t.createComputePipeline({label:"smoothing mask pipeline",layout:"auto",compute:{module:t.createShaderModule({label:"smoothing mask compute",code:Qc})}});s(c);let h=t.createBindGroup({layout:l.getBindGroupLayout(0),entries:[{binding:1,resource:a.createView()},{binding:2,resource:i.createView()},{binding:3,resource:n.createView()},{binding:4,resource:{buffer:o}}]}),p=t.createCommandEncoder({label:"smoothing mask encoder"}),d=p.beginComputePass({label:" smoothing mask compute pass"});d.setPipeline(l),d.setBindGroup(0,h),d.dispatchWorkgroups(Math.ceil(e.width/128),Math.ceil(e.height/4)),d.end();let g=p.finish();return t.queue.submit([g]),n},release:()=>{n.destroy(),o.destroy()}}};var eu=(e,t)=>{let r;return{render:n=>{_(!t(),C.ContextLost);let o=e.createCommandEncoder({label:"texture to texture encoder"});return r=e.createTexture({size:{width:n.width,height:n.height,depthOrArrayLayers:n.depthOrArrayLayers},format:"rgba8unorm",usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST}),o.copyTextureToTexture({texture:n},{texture:r},{width:r.width,height:r.height,depthOrArrayLayers:r.depthOrArrayLayers}),e.queue.submit([o.finish()]),r},release:()=>{r?.destroy()}}};var tu=(e,t,r=new OffscreenCanvas(768,432))=>{let n={videoFrameRenderer:()=>{if(!s.device)throw new Error("No device.");return zc(r,s.device,h)},backgroundImageRenderer:()=>{if(!s.device)throw new Error("No device.");return Kc(r,s.device,s.presentationFormat,h)},blurRenderer:()=>{if(!s.device)throw new Error("No device.");return Jc(r,s.device,s.presentationFormat,h)},maskSmoothingRenderer:()=>{if(!s.device)throw new Error("No device.");return Zc(r,s.device,h)},prevMaskRenderer:()=>{if(!s.device)throw new Error("No device.");return eu(s.device,h)},release:p=>()=>{for(let d of Object.keys(p))d!=="release"&&p[d]?.release()}},o=or(n),s={canvas:r,presentationFormat:"rgba8unorm",backend:"webgpu",deviceLost:!1,get videoFrameRenderer(){return o.videoFrameRenderer},get blendRenderer(){return o.backgroundImageRenderer},get blurRenderer(){return o.blurRenderer},get maskSmoothingRenderer(){return o.maskSmoothingRenderer},get prevMaskRenderer(){return o.prevMaskRenderer}},a=Ln(s),i=async()=>{if(!navigator.gpu)throw Error("WebGPU not supported.");s.presentationFormat=_s(e)?navigator.gpu.getPreferredCanvasFormat():"rgba8unorm",s.device=await $c(e),s.device.lost.then(p=>{p.reason!=="destroyed"&&(s.deviceLost=!0,t.contextLost(p.message),t.contextRestored(p.message))})},c=(p,d,g)=>{g&&a(g);let A=s.videoFrameRenderer.render(d),R=s.videoFrameRenderer.render({frame:p,width:d.width,height:d.height,timestamp:d.timestamp}),S=s.maskSmoothingRenderer.render(R,s.prevMask,g);if(g.effects==="blur"){let w=s.blurRenderer.render(d,g.backgroundBlurAmount);s.blendRenderer.render(A,w,S)}else if(g.effects==="overlay"&&g.backgroundImage){let w=s.videoFrameRenderer.render({frame:g.backgroundImage,width:g.backgroundImage.width,height:g.backgroundImage.height,timestamp:d.timestamp});s.blendRenderer.render(A,w,S)}s.prevMask=s.prevMaskRenderer.render(S)},l=()=>{o.release(),s.deviceLost=!1,o=or(n)},h=()=>s.deviceLost;return{init:i,render:c,release:l,isContextLost:h}};var ue={projection:(e,t,r=-1)=>[2/e,0,0,0,2/t*r,0,-1,1*-r,1],translation:(e,t)=>[1,0,0,0,1,0,e,t,1],rotation:e=>{let t=Math.cos(e),r=Math.sin(e);return[t,-r,0,r,t,0,0,0,1]},scaling:(e,t)=>[e,0,0,0,t,0,0,0,1],multiply:(e,t)=>{let r=e[0],n=e[0*3+1],o=e[0*3+2],s=e[1*3+0],a=e[1*3+1],i=e[1*3+2],c=e[2*3+0],l=e[2*3+1],h=e[2*3+2],p=t[0*3+0],d=t[0*3+1],g=t[0*3+2],A=t[1*3+0],R=t[1*3+1],S=t[1*3+2],w=t[2*3+0],f=t[2*3+1],y=t[2*3+2];return[p*r+d*s+g*c,p*n+d*a+g*l,p*o+d*i+g*h,A*r+R*s+S*c,A*n+R*a+S*l,A*o+R*i+S*h,w*r+f*s+y*c,w*n+f*a+y*l,w*o+f*i+y*h]},translate:(e,t,r)=>ue.multiply(e,ue.translation(t,r)),rotate:(e,t)=>ue.multiply(e,ue.rotation(t)),scale:(e,t,r)=>ue.multiply(e,ue.scaling(t,r))};var Mn={VertexShader:WebGLRenderingContext.VERTEX_SHADER,FragmentShader:WebGLRenderingContext.FRAGMENT_SHADER},As={[Mn.VertexShader]:"VertexShader",[Mn.FragmentShader]:"FragmentShader"},q2=e=>typeof e=="string"?e.startsWith("#version 300 es"):!1,ru=e=>{if(!q2(e))throw new Error("Expecting GLSL ES 3.00 shader source")},J2=/ERROR:\s*\d+:(\d+)/gi;function su(e,t="",r=0){let n=[...t.matchAll(J2)],o=new Map(n.map((s,a)=>{if(!s[1]||s.index===void 0)return[0,t];let i=Number.parseInt(s[1],10),c=n[a+1],l=c?c.index:t.length,h=t.substring(s.index,l);return[i-1,h]}));return e.split(`
42
42
  `).map((s,a)=>{let i=o.get(a);return`${a+1+r}: ${s}${i?`
43
43
 
44
44
  ^^^ ${i}`:""}`}).join(`
@@ -46,7 +46,7 @@ var It=typeof self<"u"?self:{};function za(e,t){e=e.split(".");var r,n=It;for((e
46
46
  ${s?su(r,s):"no error message available"}`;throw new Error(a)}return n},Q2=(e,t,r,n)=>{let o=e.createProgram();if(!o)throw new Error("Unable to create WebGL program");for(let a of t)e.attachShader(o,a);if(r?.forEach((a,i)=>{let c=n?.[i]??i;e.bindAttribLocation(o,c,a)}),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS)){let a=e.getProgramInfoLog(o);throw e.deleteProgram(o),new Error(`Error in program linking: ${a??""}
47
47
  ${t.map(i=>{let c=su(e.getShaderSource(i)??""),l=e.getShaderParameter(i,e.SHADER_TYPE);return`${As[l]}:
48
48
  ${c}`}).join(`
49
- `)}`)}return[o,()=>{for(let a of t)e.detachShader(o,a),e.deleteShader(a);e.deleteProgram(o)}]},Z2=(e,[t,r],n,o)=>Q2(e,[nu(e,Mn.VertexShader,t),nu(e,Mn.FragmentShader,r)],n,o),Ke=e=>{let t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),t},ou=(e,t,r)=>Object.keys(r).reduce((n,o)=>{let a=r[o];return a&&Object.assign(n,{[o]:a.startsWith("u_")?e.getUniformLocation(t,a):e.getAttribLocation(t,a)}),n},{}),Ne=(e,{attribs:t,uniforms:r,vertexSrc:n,fragmentSrc:o})=>{let s=e.getContext("webgl2",{premultipliedAlpha:!1,powerPreference:"high-performance"});if(!s)throw new Error("WebGL2 is not supported");s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),ru(n),ru(o);let[a,i]=Z2(s,[n,o]);return{gl:s,program:a,attribLocations:ou(s,a,t),uniformLocations:ou(s,a,r),release:i}},au=e=>({texture:e.getAsWebGLTexture(),width:e.width,height:e.height});var Ge=`#version 300 es
49
+ `)}`)}return[o,()=>{for(let a of t)e.detachShader(o,a),e.deleteShader(a);e.deleteProgram(o)}]},Z2=(e,[t,r],n,o)=>Q2(e,[nu(e,Mn.VertexShader,t),nu(e,Mn.FragmentShader,r)],n,o),Ke=e=>{let t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),t},ou=(e,t,r)=>Object.keys(r).reduce((n,o)=>{let a=r[o];return a&&(n[o]=a.startsWith("u_")?e.getUniformLocation(t,a):e.getAttribLocation(t,a)),n},{}),Ne=(e,{attribs:t,uniforms:r,vertexSrc:n,fragmentSrc:o})=>{let s=e.getContext("webgl2",{premultipliedAlpha:!1,powerPreference:"high-performance"});if(!s)throw new Error("WebGL2 is not supported");s.enable(s.BLEND),s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),ru(n),ru(o);let[a,i]=Z2(s,[n,o]);return{gl:s,program:a,attribLocations:ou(s,a,t),uniformLocations:ou(s,a,r),release:i}},au=e=>({texture:e.getAsWebGLTexture(),width:e.width,height:e.height});var Ge=`#version 300 es
50
50
  // an attribute is an input (in) to a vertex shader.
51
51
  // It will receive data from a buffer
52
52
  in vec2 a_position;