deepar 5.4.2 → 5.4.3-chromeExtension

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/VERSION.txt +1 -1
  2. package/js/deepar.esm.js +1 -1
  3. package/js/deepar.js +1 -1
  4. package/js/types/version.d.ts +1 -1
  5. package/lib/LICENSE +1 -0
  6. package/lib/README.md +326 -0
  7. package/lib/VERSION.txt +1 -0
  8. package/lib/effects/background_blur.deepar +0 -0
  9. package/lib/effects/background_replacement.deepar +0 -0
  10. package/lib/js/deepar.esm.js +1 -0
  11. package/lib/js/deepar.js +1 -0
  12. package/lib/js/types/DeepAR.d.ts +387 -0
  13. package/lib/js/types/callbacks.d.ts +64 -0
  14. package/lib/js/types/canvasHelper.d.ts +18 -0
  15. package/lib/js/types/canvasTouchHelper.d.ts +13 -0
  16. package/lib/js/types/errors.d.ts +6 -0
  17. package/lib/js/types/faceData.d.ts +33 -0
  18. package/lib/js/types/footData.d.ts +9 -0
  19. package/lib/js/types/index.d.ts +10 -0
  20. package/lib/js/types/initParams.d.ts +236 -0
  21. package/lib/js/types/logType.d.ts +18 -0
  22. package/lib/js/types/mediaRecorderVideoRecording.d.ts +10 -0
  23. package/lib/js/types/scriptingApi.d.ts +107 -0
  24. package/lib/js/types/touchType.d.ts +34 -0
  25. package/lib/js/types/version.d.ts +5 -0
  26. package/lib/js/types/webCodecsVideoRecording.d.ts +11 -0
  27. package/lib/js/types/wristData.d.ts +13 -0
  28. package/lib/mediaPipe/segmentation/models/selfie_segmenter.tflite +0 -0
  29. package/lib/mediaPipe/segmentation/models/selfie_segmenter_landscape.tflite +0 -0
  30. package/lib/mediaPipe/segmentation/wasm/vision_wasm_internal.js +22 -0
  31. package/lib/mediaPipe/segmentation/wasm/vision_wasm_internal.wasm +0 -0
  32. package/lib/mediaPipe/segmentation/wasm/vision_wasm_nosimd_internal.js +22 -0
  33. package/lib/mediaPipe/segmentation/wasm/vision_wasm_nosimd_internal.wasm +0 -0
  34. package/lib/models/face/models-68-extreme.bin +0 -0
  35. package/lib/models/face-cnn/face-det.bin +0 -0
  36. package/lib/models/face-cnn/face-track-19.bin +0 -0
  37. package/lib/models/foot/foot-detection-96x96x6.bin +0 -0
  38. package/lib/models/foot/foot-model.obj +3965 -0
  39. package/lib/models/foot/foot-tracker-96x96x13-test.bin +0 -0
  40. package/lib/models/foot/foot-tracker-96x96x18-test.bin +0 -0
  41. package/lib/models/segmentation/segmentation-160x160-opt.bin +0 -0
  42. package/lib/models/wrist/wrist-base-2.obj +3815 -0
  43. package/lib/models/wrist/wrist-det-9.bin +0 -0
  44. package/lib/models/wrist/wrist-track.bin +0 -0
  45. package/lib/wasm/deepar.wasm +0 -0
  46. package/lib/wasm/libxzimgPoseEstimation.wasm +0 -0
  47. package/lib/wasm/tfjs-backend-wasm-simd.wasm +0 -0
  48. package/lib/wasm/tfjs-backend-wasm-threaded-simd.wasm +0 -0
  49. package/lib/wasm/tfjs-backend-wasm.wasm +0 -0
  50. package/package.json +1 -1
  51. package/wasm/deepar.wasm +0 -0
@@ -0,0 +1 @@
1
+ var e={795:function(e,t,n){var r;e=n.nmd(e),function(){var a={function:!0,object:!0},i=a[typeof window]&&window||this,s=a[typeof t]&&t,o=a.object&&e&&!e.nodeType&&e,u=s&&o&&"object"==typeof n.g&&n.g;!u||u.global!==u&&u.window!==u&&u.self!==u||(i=u);var l=Math.pow(2,53)-1,c=/\bOpera/,h=Object.prototype,p=h.hasOwnProperty,d=h.toString;function f(e){return(e=String(e)).charAt(0).toUpperCase()+e.slice(1)}function m(e){return e=w(e),/^(?:webOS|i(?:OS|P))/.test(e)?e:f(e)}function g(e,t){for(var n in e)p.call(e,n)&&t(e[n],n,e)}function y(e){return null==e?f(e):d.call(e).slice(8,-1)}function b(e){return String(e).replace(/([ -])(?!$)/g,"$1?")}function v(e,t){var n=null;return function(e,t){var n=-1,r=e?e.length:0;if("number"==typeof r&&r>-1&&r<=l)for(;++n<r;)t(e[n],n);else g(e,t)}(e,(function(r,a){n=t(n,r,a,e)})),n}function w(e){return String(e).replace(/^ +| +$/g,"")}var _=function e(t){var n=i,r=t&&"object"==typeof t&&"String"!=y(t);r&&(n=t,t=null);var a=n.navigator||{},s=a.userAgent||"";t||(t=s);var o,u,l,h,p,f=r?!!a.likeChrome:/\bChrome\b/.test(t)&&!/internal|\n/i.test(d.toString()),_="Object",x=r?_:"ScriptBridgingProxyObject",k=r?_:"Environment",T=r&&n.java?"JavaPackage":y(n.java),E=r?_:"RuntimeObject",S=/\bJava/.test(T)&&n.java,I=S&&y(n.environment)==k,A=S?"a":"α",C=S?"b":"β",N=n.document||{},R=n.operamini||n.opera,F=c.test(F=r&&R?R["[[Class]]"]:y(R))?F:R=null,O=t,M=[],$=null,D=t==s,P=D&&R&&"function"==typeof R.version&&R.version(),L=v([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"],(function(e,n){return e||RegExp("\\b"+(n.pattern||b(n))+"\\b","i").exec(t)&&(n.label||n)})),B=v(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"],(function(e,n){return e||RegExp("\\b"+(n.pattern||b(n))+"\\b","i").exec(t)&&(n.label||n)})),U=z([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),W=v({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}},(function(e,n,r){return e||(n[U]||n[/^[a-z]+(?: +[a-z]+\b)*/i.exec(U)]||RegExp("\\b"+b(r)+"(?:\\b|\\w*\\d)","i").exec(t))&&r})),V=v(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "],(function(e,n){var r=n.pattern||b(n);return!e&&(e=RegExp("\\b"+r+"(?:/[\\d.]+|[ \\w.]*)","i").exec(t))&&(e=function(e,t,n){var r={"10.0":"10",6.4:"10 Technical Preview",6.3:"8.1",6.2:"8",6.1:"Server 2008 R2 / 7","6.0":"Server 2008 / Vista",5.2:"Server 2003 / XP 64-bit",5.1:"XP",5.01:"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return t&&n&&/^Win/i.test(e)&&!/^Windows Phone /i.test(e)&&(r=r[/[\d.]+$/.exec(e)])&&(e="Windows "+r),e=String(e),t&&n&&(e=e.replace(RegExp(t,"i"),n)),m(e.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0])}(e,r,n.label||n)),e}));function z(e){return v(e,(function(e,n){var r=n.pattern||b(n);return!e&&(e=RegExp("\\b"+r+" *\\d+[.\\w_]*","i").exec(t)||RegExp("\\b"+r+" *\\w+-[\\w]*","i").exec(t)||RegExp("\\b"+r+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(t))&&((e=String(n.label&&!RegExp(r,"i").test(n.label)?n.label:e).split("/"))[1]&&!/[\d.]+/.test(e[0])&&(e[0]+=" "+e[1]),n=n.label||n,e=m(e[0].replace(RegExp(r,"i"),n).replace(RegExp("; *(?:"+n+"[_-])?","i")," ").replace(RegExp("("+n+")[-_.]?(\\w)","i"),"$1 $2"))),e}))}function j(e){return v(e,(function(e,n){return e||(RegExp(n+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(t)||0)[1]||null}))}if(L&&(L=[L]),/\bAndroid\b/.test(V)&&!U&&(o=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(t))&&(U=w(o[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),W&&!U?U=z([W]):W&&U&&(U=U.replace(RegExp("^("+b(W)+")[-_.\\s]","i"),W+" ").replace(RegExp("^("+b(W)+")[-_.]?(\\w)","i"),W+" $2")),(o=/\bGoogle TV\b/.exec(U))&&(U=o[0]),/\bSimulator\b/i.test(t)&&(U=(U?U+" ":"")+"Simulator"),"Opera Mini"==B&&/\bOPiOS\b/.test(t)&&M.push("running in Turbo/Uncompressed mode"),"IE"==B&&/\blike iPhone OS\b/.test(t)?(W=(o=e(t.replace(/like iPhone OS/,""))).manufacturer,U=o.product):/^iP/.test(U)?(B||(B="Safari"),V="iOS"+((o=/ OS ([\d_]+)/i.exec(t))?" "+o[1].replace(/_/g,"."):"")):"Konqueror"==B&&/^Linux\b/i.test(V)?V="Kubuntu":W&&"Google"!=W&&(/Chrome/.test(B)&&!/\bMobile Safari\b/i.test(t)||/\bVita\b/.test(U))||/\bAndroid\b/.test(V)&&/^Chrome/.test(B)&&/\bVersion\//i.test(t)?(B="Android Browser",V=/\bAndroid\b/.test(V)?V:"Android"):"Silk"==B?(/\bMobi/i.test(t)||(V="Android",M.unshift("desktop mode")),/Accelerated *= *true/i.test(t)&&M.unshift("accelerated")):"UC Browser"==B&&/\bUCWEB\b/.test(t)?M.push("speed mode"):"PaleMoon"==B&&(o=/\bFirefox\/([\d.]+)\b/.exec(t))?M.push("identifying as Firefox "+o[1]):"Firefox"==B&&(o=/\b(Mobile|Tablet|TV)\b/i.exec(t))?(V||(V="Firefox OS"),U||(U=o[1])):!B||(o=!/\bMinefield\b/i.test(t)&&/\b(?:Firefox|Safari)\b/.exec(B))?(B&&!U&&/[\/,]|^[^(]+?\)/.test(t.slice(t.indexOf(o+"/")+8))&&(B=null),(o=U||W||V)&&(U||W||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(V))&&(B=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(V)?V:o)+" Browser")):"Electron"==B&&(o=(/\bChrome\/([\d.]+)\b/.exec(t)||0)[1])&&M.push("Chromium "+o),P||(P=j(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",b(B),"(?:Firefox|Minefield|NetFront)"])),(o=("iCab"==L&&parseFloat(P)>3?"WebKit":/\bOpera\b/.test(B)&&(/\bOPR\b/.test(t)?"Blink":"Presto"))||/\b(?:Midori|Nook|Safari)\b/i.test(t)&&!/^(?:Trident|EdgeHTML)$/.test(L)&&"WebKit"||!L&&/\bMSIE\b/i.test(t)&&("Mac OS"==V?"Tasman":"Trident")||"WebKit"==L&&/\bPlayStation\b(?! Vita\b)/i.test(B)&&"NetFront")&&(L=[o]),"IE"==B&&(o=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(t)||0)[1])?(B+=" Mobile",V="Windows Phone "+(/\+$/.test(o)?o:o+".x"),M.unshift("desktop mode")):/\bWPDesktop\b/i.test(t)?(B="IE Mobile",V="Windows Phone 8.x",M.unshift("desktop mode"),P||(P=(/\brv:([\d.]+)/.exec(t)||0)[1])):"IE"!=B&&"Trident"==L&&(o=/\brv:([\d.]+)/.exec(t))&&(B&&M.push("identifying as "+B+(P?" "+P:"")),B="IE",P=o[1]),D){if(h="global",p=null!=(l=n)?typeof l[h]:"number",/^(?:boolean|number|string|undefined)$/.test(p)||"object"==p&&!l[h])y(o=n.runtime)==x?(B="Adobe AIR",V=o.flash.system.Capabilities.os):y(o=n.phantom)==E?(B="PhantomJS",P=(o=o.version||null)&&o.major+"."+o.minor+"."+o.patch):"number"==typeof N.documentMode&&(o=/\bTrident\/(\d+)/i.exec(t))?(P=[P,N.documentMode],(o=+o[1]+4)!=P[1]&&(M.push("IE "+P[1]+" mode"),L&&(L[1]=""),P[1]=o),P="IE"==B?String(P[1].toFixed(1)):P[0]):"number"==typeof N.documentMode&&/^(?:Chrome|Firefox)\b/.test(B)&&(M.push("masking as "+B+" "+P),B="IE",P="11.0",L=["Trident"],V="Windows");else if(S&&(O=(o=S.lang.System).getProperty("os.arch"),V=V||o.getProperty("os.name")+" "+o.getProperty("os.version")),I){try{P=n.require("ringo/engine").version.join("."),B="RingoJS"}catch(e){(o=n.system)&&o.global.system==n.system&&(B="Narwhal",V||(V=o[0].os||null))}B||(B="Rhino")}else"object"==typeof n.process&&!n.process.browser&&(o=n.process)&&("object"==typeof o.versions&&("string"==typeof o.versions.electron?(M.push("Node "+o.versions.node),B="Electron",P=o.versions.electron):"string"==typeof o.versions.nw&&(M.push("Chromium "+P,"Node "+o.versions.node),B="NW.js",P=o.versions.nw)),B||(B="Node.js",O=o.arch,V=o.platform,P=(P=/[\d.]+/.exec(o.version))?P[0]:null));V=V&&m(V)}if(P&&(o=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(P)||/(?:alpha|beta)(?: ?\d)?/i.exec(t+";"+(D&&a.appMinorVersion))||/\bMinefield\b/i.test(t)&&"a")&&($=/b/i.test(o)?"beta":"alpha",P=P.replace(RegExp(o+"\\+?$"),"")+("beta"==$?C:A)+(/\d+\+?/.exec(o)||"")),"Fennec"==B||"Firefox"==B&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(V))B="Firefox Mobile";else if("Maxthon"==B&&P)P=P.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(U))"Xbox 360"==U&&(V=null),"Xbox 360"==U&&/\bIEMobile\b/.test(t)&&M.unshift("mobile mode");else if(!/^(?:Chrome|IE|Opera)$/.test(B)&&(!B||U||/Browser|Mobi/.test(B))||"Windows CE"!=V&&!/Mobi/i.test(t))if("IE"==B&&D)try{null===n.external&&M.unshift("platform preview")}catch(e){M.unshift("embedded")}else(/\bBlackBerry\b/.test(U)||/\bBB10\b/.test(t))&&(o=(RegExp(U.replace(/ +/g," *")+"/([.\\d]+)","i").exec(t)||0)[1]||P)?(V=((o=[o,/BB10/.test(t)])[1]?(U=null,W="BlackBerry"):"Device Software")+" "+o[0],P=null):this!=g&&"Wii"!=U&&(D&&R||/Opera/.test(B)&&/\b(?:MSIE|Firefox)\b/i.test(t)||"Firefox"==B&&/\bOS X (?:\d+\.){2,}/.test(V)||"IE"==B&&(V&&!/^Win/.test(V)&&P>5.5||/\bWindows XP\b/.test(V)&&P>8||8==P&&!/\bTrident\b/.test(t)))&&!c.test(o=e.call(g,t.replace(c,"")+";"))&&o.name&&(o="ing as "+o.name+((o=o.version)?" "+o:""),c.test(B)?(/\bIE\b/.test(o)&&"Mac OS"==V&&(V=null),o="identify"+o):(o="mask"+o,B=F?m(F.replace(/([a-z])([A-Z])/g,"$1 $2")):"Opera",/\bIE\b/.test(o)&&(V=null),D||(P=null)),L=["Presto"],M.push(o));else B+=" Mobile";(o=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(t)||0)[1])&&(o=[parseFloat(o.replace(/\.(\d)$/,".0$1")),o],"Safari"==B&&"+"==o[1].slice(-1)?(B="WebKit Nightly",$="alpha",P=o[1].slice(0,-1)):P!=o[1]&&P!=(o[2]=(/\bSafari\/([\d.]+\+?)/i.exec(t)||0)[1])||(P=null),o[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(t)||0)[1],537.36==o[0]&&537.36==o[2]&&parseFloat(o[1])>=28&&"WebKit"==L&&(L=["Blink"]),D&&(f||o[1])?(L&&(L[1]="like Chrome"),o=o[1]||((o=o[0])<530?1:o<532?2:o<532.05?3:o<533?4:o<534.03?5:o<534.07?6:o<534.1?7:o<534.13?8:o<534.16?9:o<534.24?10:o<534.3?11:o<535.01?12:o<535.02?"13+":o<535.07?15:o<535.11?16:o<535.19?17:o<536.05?18:o<536.1?19:o<537.01?20:o<537.11?"21+":o<537.13?23:o<537.18?24:o<537.24?25:o<537.36?26:"Blink"!=L?"27":"28")):(L&&(L[1]="like Safari"),o=(o=o[0])<400?1:o<500?2:o<526?3:o<533?4:o<534?"4+":o<535?5:o<537?6:o<538?7:o<601?8:o<602?9:o<604?10:o<606?11:o<608?12:"12"),L&&(L[1]+=" "+(o+="number"==typeof o?".x":/[.+]/.test(o)?"":"+")),"Safari"==B&&(!P||parseInt(P)>45)?P=o:"Chrome"==B&&/\bHeadlessChrome/i.test(t)&&M.unshift("headless")),"Opera"==B&&(o=/\bzbov|zvav$/.exec(V))?(B+=" ",M.unshift("desktop mode"),"zvav"==o?(B+="Mini",P=null):B+="Mobile",V=V.replace(RegExp(" *"+o+"$"),"")):"Safari"==B&&/\bChrome\b/.exec(L&&L[1])?(M.unshift("desktop mode"),B="Chrome Mobile",P=null,/\bOS X\b/.test(V)?(W="Apple",V="iOS 4.3+"):V=null):/\bSRWare Iron\b/.test(B)&&!P&&(P=j("Chrome")),P&&0==P.indexOf(o=/[\d.]+$/.exec(V))&&t.indexOf("/"+o+"-")>-1&&(V=w(V.replace(o,""))),V&&-1!=V.indexOf(B)&&!RegExp(B+" OS").test(V)&&(V=V.replace(RegExp(" *"+b(B)+" *"),"")),L&&!/\b(?:Avant|Nook)\b/.test(B)&&(/Browser|Lunascape|Maxthon/.test(B)||"Safari"!=B&&/^iOS/.test(V)&&/\bSafari\b/.test(L[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(B)&&L[1])&&(o=L[L.length-1])&&M.push(o),M.length&&(M=["("+M.join("; ")+")"]),W&&U&&U.indexOf(W)<0&&M.push("on "+W),U&&M.push((/^on /.test(M[M.length-1])?"":"on ")+U),V&&(o=/ ([\d.+]+)$/.exec(V),u=o&&"/"==V.charAt(V.length-o[0].length-1),V={architecture:32,family:o&&!u?V.replace(o[0],""):V,version:o?o[1]:null,toString:function(){var e=this.version;return this.family+(e&&!u?" "+e:"")+(64==this.architecture?" 64-bit":"")}}),(o=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(O))&&!/\bi686\b/i.test(O)?(V&&(V.architecture=64,V.family=V.family.replace(RegExp(" *"+o),"")),B&&(/\bWOW64\b/i.test(t)||D&&/\w(?:86|32)$/.test(a.cpuClass||a.platform)&&!/\bWin64; x64\b/i.test(t))&&M.unshift("32-bit")):V&&/^OS X/.test(V.family)&&"Chrome"==B&&parseFloat(P)>=39&&(V.architecture=64),t||(t=null);var G={};return G.description=t,G.layout=L&&L[0],G.manufacturer=W,G.name=B,G.prerelease=$,G.product=U,G.ua=t,G.version=B&&P,G.os=V||{architecture:null,family:null,version:null,toString:function(){return"null"}},G.parse=e,G.toString=function(){return this.description||""},G.version&&M.unshift(P),G.name&&M.unshift(B),V&&B&&(V!=String(V).split(" ")[0]||V!=B.split(" ")[0]&&!U)&&M.push(U?"("+V+")":"on "+V),M.length&&(G.description=M.join(" ")),G}();i.platform=_,void 0===(r=function(){return _}.call(t,n,t,e))||(e.exports=r)}.call(this)},683:()=>{},345:()=>{}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);var r={};(()=>{n.d(r,{Ao:()=>yU,Gv:()=>PU,rQ:()=>iR,o:()=>tR,R0:()=>e,j2:()=>DU,i8:()=>a});var e={};n.r(e),n.d(e,{SwitchEffectCanceled:()=>aR});var t,a="5.4.3-chromeExtension",i=(t="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(e={}){var n,r,a;n||(n=void 0!==e?e:{}),n.ready=new Promise((function(e,t){r=e,a=t}));let i=null;const s=[];function o(){for(const e of s)e()}function u(){for(const e of s)e()}n.addPreRenderListener=function(e){s.push(e)},n.addPostRenderListener=function(e){s.push(e)};var l=null,c=null;let h=!1;const p=new ImageData(640,360);p.Ml=!0;let d,f,m,g,y,b,v,w,_,x,k,T,E,S,I,A,C,N,R=!1,F=null,O=null,M=null,$=null,D=null;function P(e){const t=n.Hk.length;return n.Hk[t]=e,t}n.Hk=[null],n.preinitializedWebGLContext=n.canvas.getContext("webgl2",{alpha:!1,antialias:!0,powerPreference:"high-performance"}),n.process=function(){};let L=new class{get Rk(){switch(this.type){case"Timer":return this.$k;case"RAF":return this.Zk;case"Oscillator":return this.Yk}}constructor(){this.Yk=this.Zk=this.$k=!1,this.type="RAF",this.al=1e3/33}add(e){this.Lk=e}start(){switch(this.type){case"Timer":if(!this.$k){this.$k=!0;const e=()=>{setTimeout((()=>{this.Lk&&this.Lk(),this.$k&&e()}),this.al)};e()}break;case"RAF":if(!this.Zk){this.Zk=!0;const e=t=>{requestAnimationFrame((n=>{n-t<=this.al?this.Zk&&e(t):this.Lk&&(this.Lk(),e(n))}))};e(-this.al-10)}break;case"Oscillator":if(!this.Yk){i=i||new AudioContext,this.Yk=!0;const e=i.createGain();let t;e.gain.value=0,e.connect(i.destination);const n=()=>{this.Lk&&this.Lk(),t&&t.disconnect(),this.ll=t=i.createOscillator(),t.connect(e),this.Yk&&(t.onended=n,t.start(),t.stop(i.currentTime+this.al/1e3))};n()}}}stop(){switch(this.type){case"Timer":this.$k=!1;break;case"RAF":this.Zk=!1;break;case"Oscillator":this.Yk=!1,this.ll&&(this.ll.onended=null,this.ll=void 0)}}};function B(){var e=n.Hk[0];if(e&&e.readyState===e.HAVE_ENOUGH_DATA)n._processFrameVideo(0,H),R=!0;else if(!R||0<Object.entries(z).length||null!=j||null!=G){e=d||p;var t=n._malloc(e.data.length);if(!t)return;se.set(e.data,t),n._processFrameRawPixels(t,e.width,e.height,e.Ml),R=!0,n._free(t)}o(),e=n.canvas.width,t=n.canvas.height,n.canvasWidth===e&&n.canvasHeight===t||(n.canvasWidth=e,n.canvasHeight=t,gi(e,t)),n._render(),u(),n.apiObject.__deeparRendered&&n.apiObject.__deeparRendered(ua),n.apiObject.__deeparRendered2&&n.apiObject.__deeparRendered2(ua)}function U(){B()}n.setFps=function(e){L.al=1e3/e},L.add(U),n.startLoop=function(){L.add(U),L.start()},n.endLoop=function(){L.Lk=void 0,L.stop()};var W=!1,V=null;n.takeScreenshot=function(e){if(W)throw Error("The last call to takeScreenshot is not finished yet. Wait for the screenshot to finish.");W=!0,V=e;try{mi(),L.Rk||(o(),n._render(),u())}catch(e){throw W=!1,V=null,e}},n.processFrameRawPixels=function(e,t,r,a){var i=n._malloc(e.length);i&&(se.set(e,i),n._processFrameRawPixels(i,t,r,a),d=new ImageData(new Uint8ClampedArray(e),t,r),d.Ml=a,R=!0,L.Rk||(o(),n._render(),u()),n._free(i))},n.initializeFootTracking=function(){$a(),bi()},n.isFootTrackingInitialized=function(){return Da()},n.initializeSegmentation=function(){h?za():ba()},n.isSegmentationInitialized=function(){return h?ja():!!ma},n.isWristTrackingInitialized=function(){return Za()};let z={},j=null,G=null;n.switchEffectByteArray=function(e,t,r,a,i){if(!F)throw Error("Error in internal API: __switchEffect is null!");const s=n._malloc(r.length);if(!s)throw Error("Cannot allocate buffer for switch effect.");se.set(r,s),z[t]&&z[t].error&&z[t].error(new n.customErrors.SwitchEffectCanceled(`Switch effect canceled by another switch effect to the same slot: ${t}.`)),z[t]={Qk:a,error:i};try{F(t,s,r.length,e),R=!1,L.Rk||B()}catch(e){throw delete z[t],e}},n.hasVar=function(e,t){return f(e,t)},n.getVarType=function(e,t){if(m(e,t))return w(e,t);throw Error("Variable named '"+e+"' does not exist.")},n.getBoolVar=function(e,t){if(g(e,t))return _(e,t);throw Error("Variable named '"+e+"' does not exist or is not a boolean.")},n.getIntVar=function(e,t){if(y(e,t))return x(e,t);throw Error("Variable named '"+e+"' does not exist or is not an integer.")},n.getDoubleVar=function(e,t){if(b(e,t))return k(e,t);throw Error("Variable named '"+e+"' does not exist or is not a double.")},n.getStringVar=function(e,t){if(v(e,t))return T(e,t);throw Error("Variable named '"+e+"' does not exist or is not a string.")},n.setBoolVar=function(e,t,n){return E(e,t,n)},n.setIntVar=function(e,t,n){return S(e,t,n)},n.setDoubleVar=function(e,t,n){return I(e,t,n)},n.setStringVar=function(e,t,n){return A(e,t,n)},n.deleteVar=function(e,t){return C(e,t)},n.clearVars=function(e){return N(e)},n.clearEffect=function(e){z[e]&&z[e].error&&(z[e].error(new n.customErrors.SwitchEffectCanceled(`Switch effect canceled by the call to clearEffect() on the same slot: ${e}.`)),delete z[e]),O&&(O(e),L.Rk||B())},n.moveGameObject=function(e,t){M&&(M(e,t),L.Rk||B())};let H=!0;n.setMirror=function(e){H=!!e};let K=!1;n.startCamera=function(e,t,r,a,i,s){n.stopVideo(),H=!!e;let o=document.createElement("video");o.setAttribute("playsinline","playsinline"),n.Hk[0]=o,t=t||!0,i&&i(),navigator.mediaDevices.getUserMedia({video:t}).then((function(e){s&&s(),o.srcObject=e,o.onloadedmetadata=()=>{o.play().then((()=>{r&&r()}))},K=!0})).catch((e=>{a&&a(e),console.error(`${e.name}: ${e.message}`)}))},n.shutdown=function(){n.stopVideo(),fi(),n.um()},n.setVideoElement=function(e,t){n.stopVideo(),H=!!t,n.Hk[0]=e},n.stopVideo=function(){n.Hk[0]&&(K&&(n.Hk[0].srcObject.getTracks().forEach((e=>{e.stop()})),n.Hk[0].srcObject=null,K=!1),n.Hk[0]=null)},n.touchOccurred=function(e){yi(e.x,e.y,e.type)},n.setOffscreenRenderingEnabled=function(e){!function(e){var t=L;if(t.type!==e){var n=t.$k|t.Yk|t.Zk;t.stop(),t.type=e,n&&t.start()}}(e?"Oscillator":"RAF")},n.backgroundReplacement=function(e,t,n,r){if(e){G&&G.error&&G.error(""),G={Qk:n,error:r};var a=new Image;a.onload=()=>{const t=document.createElement("canvas");var n=t.getContext("2d",{Jn:!0});t.width=a.width,t.height=a.height,n.drawImage(a,0,0),n=n.getImageData(0,0,t.width,t.height),n=new Uint8Array(n.data.buffer);const r=vi(n.length);se.set(n,r);try{D(e,r,n.length,t.width,t.height),R=!1,L.Rk||B()}catch(e){throw G=null,e}},a.src=t}else D(!1,null,0,0,0),n()},n.backgroundBlur=function(e,t,n,r){if(e){j&&j.error&&j.error(""),j={Qk:n,error:r};try{$(e,t),R=!1,L.Rk||B()}catch(e){throw j=null,e}}else $(!1,0),n()},n.lm=function(e,t,r,a){if(n.apiObject.onFaceTracked){var i=[];for(let c=0;c<a;c++){let a={detected:!1,translation:[],rotation:[],poseMatrix:[],landmarks:[],landmarks2d:[],faceRect:[]};var s=t+c*r,o=s+e.translationOffset;let h=s+e.rotationOffset;var u=s+e.poseMatrixOffset,l=s+e.landmarksOffset;let p=s+e.landmarks2DOffset,d=s+e.faceRectOffset;for(a.detected=!!n.HEAP32[s/Float32Array.BYTES_PER_ELEMENT],s=0;3>s;s++)a.translation.push(n.HEAPF32[o/Float32Array.BYTES_PER_ELEMENT+s]),a.rotation.push(n.HEAPF32[h/Float32Array.BYTES_PER_ELEMENT+s]);for(o=0;16>o;o++)a.poseMatrix.push(n.HEAPF32[u/Float32Array.BYTES_PER_ELEMENT+o]);for(u=0;204>u;u++)a.landmarks.push(n.HEAPF32[l/Float32Array.BYTES_PER_ELEMENT+u]),136>u&&a.landmarks2d.push(n.HEAPF32[p/Float32Array.BYTES_PER_ELEMENT+u]);for(l=0;4>l;l++)a.faceRect.push(n.HEAPF32[d/Float32Array.BYTES_PER_ELEMENT+l]);i.push(a)}n.apiObject.onFaceTracked(i)}},n.rn=function(){n.apiObject.onVideoStarted&&n.apiObject.onVideoStarted()},n.qm=function(){n.apiObject.onInitialize&&n.apiObject.onInitialize()},n.mm=function(e){n.apiObject.onFaceVisibilityChanged&&n.apiObject.onFaceVisibilityChanged(e)},n.pm=function(e){n.apiObject.onImageVisibilityChanged&&n.apiObject.onImageVisibilityChanged(e)},n.qn=function(){n.apiObject.onCameraPermissionGranted&&n.apiObject.onCameraPermissionGranted()},n.pn=function(){n.apiObject.onCameraPermissionDenied&&n.apiObject.onCameraPermissionDenied()},n.on=function(){n.apiObject.onCameraPermissionAsked&&n.apiObject.onCameraPermissionAsked()},n.sm=function(e,t,n){const r=document.createElement("canvas"),a=r.getContext("2d");r.width=t,r.height=n;const i=a.getImageData(0,0,r.width,r.height),s=i.data;for(let r=0;r<n;r++)for(let a=0;a<t;a++){const i=4*((n-r-1)*t+a),o=4*(r*t+a);s[o]=se[e+i+2],s[o+1]=se[e+i+1],s[o+2]=se[e+i+0],s[o+3]=se[e+i+3]}a.putImageData(i,0,0),W?(W=!1,V(r.toDataURL("image/png")),V=null):console.error("DeepAR screenshot taken but no registered callback.")},n.gm=function(e){n.apiObject.onAnimationTransitionedToState&&n.apiObject.onAnimationTransitionedToState(e)},n.km=function(e,t){"Error"===e?console.error(t):"Debug"===e?console.debug(t):"Info"===e?console.info(t):"Warning"===e?console.warn(t):console.log(t)},n.jm=function(e){z[e]&&z[e].Qk&&z[e].Qk(),delete z[e]},n.im=function(){G&&G.Qk&&G.Qk(),G={}},n.hm=function(){j&&j.Qk&&j.Qk(),j={}},n.rm=function(e){n.apiObject.onNumberOfFacesVisibleChanged&&n.apiObject.onNumberOfFacesVisibleChanged(e)},n.um=function(){n.apiObject.onShutdown&&n.apiObject.onShutdown()},n.om=function(){n.apiObject.onFootTrackingInitialized&&n.apiObject.onFootTrackingInitialized()},n.tm=function(){n.apiObject.onSegmentationInitialized&&n.apiObject.onSegmentationInitialized()},n.nm=function(e,t){n.apiObject.onFeetTracked&&n.apiObject.onFeetTracked(e,t)},n.wm=function(){n.apiObject.onWristTrackingInitialized&&n.apiObject.onWristTrackingInitialized()},n.vm=function(e){n.apiObject.onWristTracked&&n.apiObject.onWristTracked(e)},n.noInitialRun=!0,n.initializeDeepAR=function(){l=n.xzimg,c=n.mediaPipe,n.initializeML&&(n.initializeML.useXzimgWebSegmentation&&(h=!0),n.initializeML.faceModelsPredownload&&Y("face"),n.initializeML.segmentationInit&&(h?za():ba()),n.initializeML.footInit&&$a(),n.initializeML.segmentationModelsPredownload&&Y("segmentationXzimg"),n.initializeML.footModelsPredownload&&(Y("footDetector"),Y("footTracker"),Y("footObj")),n.initializeML.rigidFaceInit&&(Y("rigidFaceDetector"),Y("rigidFaceTracker"))),F=si("switchEffect",null,["string","number","number","number"]),O=si("clearEffect",null,["string"]),M=si("moveGameObject",null,["string","string"]),$=si("backgroundBlur",null,["boolean","number"]),D=si("backgroundReplacement",null,["boolean","number","number","number","number"]),f=si("hasVar","boolean",["string","string"]),m=si("getVarTypeStatus","boolean",["string","string"]),g=si("getBoolVarStatus","boolean",["string","string"]),y=si("getIntVarStatus","boolean",["string","string"]),b=si("getDoubleVarStatus","boolean",["string","string"]),v=si("getStringVarStatus","boolean",["string","string"]),w=si("getVarType","int",["string","string"]),_=si("getBoolVar","boolean",["string","string"]),x=si("getIntVar","int",["string","string"]),k=si("getDoubleVar","number",["string","string"]),T=si("getStringVar","string",["string","string"]),E=si("setBoolVar","boolean",["string","boolean","string"]),S=si("setIntVar","boolean",["string","int","string"]),I=si("setDoubleVar","boolean",["string","number","string"]),A=si("setStringVar","boolean",["string","string","string"]),C=si("deleteVar","boolean",["string","string"]),N=si("clearVars","boolean",["string"]),n.pushConsoleLog=si("pushConsoleLog","boolean",["string","int"]),n.changeParameterFloat=si("changeParameterFloat",null,["string","string","string","number"]),n.changeParameterVector=si("changeParameterVector",null,"string string string number number number number".split(" ")),n.changeParameterBool=si("changeParameterBool",null,["string","string","string","boolean"]),n.changeParameterTexture=si("changeParameterTexture",null,"string string string number number number number".split(" ")),n.fireTrigger=si("fireTrigger",null,["string"]),n.setFaceDetectionSensitivity=si("setFaceDetectionSensitivity",null,["number"]),n.showStats=si("showStats",null,["number"]),n.simulatePhysics=si("simulatePhysics",null,["number"]),n.showColliders=si("showColliders",null,["number"]),n.setLicenseKey=si("setLicenseKey",null,["string"]),n.muteSound=si("muteSound",null,["boolean"]),n.setLicenseKey(n.licenseKey),pi(n.canvasWidth,n.canvasHeight,n.initializeML&&n.initializeML.rigidFaceInit,h)};let q={};function X(e,t,n){q[e]={path:t,nl:!1,data:null,ml:!1,bl:[],Jl:n,Ul:function(n){n&&this.bl.push(n),this.data?this.bl.forEach((e=>{e.Qk(this.data)})):this.nl||(this.ml&&this.bl.forEach((e=>{e.error()})),this.path||(console.error(`The ${e} model was requested but the path to it is not defined.`),this.ml=!0,this.bl.forEach((e=>{e.error()}))),this.nl=!0,fetch(this.path).then((n=>{n.ok?n.arrayBuffer().then((n=>{this.data=n,this.nl=!1,this.ml=!0,async function(e){return e=await crypto.subtle.digest("SHA-256",e),Array.from(new Uint8Array(e)).map((e=>e.toString(16).padStart(2,"0"))).join("")}(n).then((n=>{this.Jl.some((e=>e===n))||console.warn(`The loaded ${e} model (${t}) does not pass the validity check. DeepAR may not function as expected or it might crash. Expected digests: ${this.Jl} but got this digest ${n}.`)})),this.bl.forEach((e=>{e.Qk(n)}))})).catch((t=>{console.error(t),console.error(`Error downloading the ${e} model (${this.path}), could not resolve the array buffer`),this.bl.forEach((e=>{e.error()}))})):(this.nl=!1,this.ml=!0,console.error(`Error downloading the ${e} model (${this.path}), response status = ${n.status}. Effects using ${e} will not work properly or at all.`),this.bl.forEach((e=>{e.error()})))})))},Em:function(){return this.data?this.data:this.ml||this.nl?null:void this.Ul()},Dm:async function(){return new Promise(((e,t)=>{this.Ul({Qk:e,error:t})}))}}}function Y(e){if(!q[e])throw Error(`No ML model with name ${e}.`);return q[e].Em()}function Q(e){if(!q[e])throw Error(`No ML model with name ${e}.`);return q[e].Dm()}X("face",n.faceTrackingModelPath,["d77b98c4cbe7f514b541ff79f79503bf23bc8f2b27046c8c785f2d89d2c3a44b"]),X("rigidFaceDetector",n.rigidFaceTrackingConfig.detectorPath,["8270514ae788bc6ee67db086c9400581d17a78c18de38c878f1148dcc3a8e480"]),X("rigidFaceTracker",n.rigidFaceTrackingConfig.trackerPath,["83ed5dae95a107733811b1ff3bfcce1cd94b9e652c52a8c9317156294f3c9c9a"]),X("segmentationXzimg",n.segmentationConfig.modelPath,["373cb9dd1fbf3972245665a81607ec7d33078ee0dae380c9d9e8bc03034dc09a"]),X("segmentationMediaPipe",n.segmentationConfig.mediaPipeConfig.modelPath,["191ac9529ae506ee0beefa6b2c945a172dab9d07d1e802a290a4e4038226658b","490e9ea734313e0de10fa0cd9e3c6133e36ea4db2b7a49bde9ef019f72796b8e"]),X("footDetector",n.footTrackingConfig.detectorPath,["2c6d4af14fbe42bdc37fba53526429ac7453e19971a4a070e64bae6460872ac3"]),X("footTracker",n.footTrackingConfig.trackerPath,["ddfc598f45ae5e5a8169518a9daecedc556df623cb3a1d676e7de0f85f14f337","f0ec050f034b9ade54711705213d2dd336b76452a7d81bd17ba2505a5293438a"]),X("footObj",n.footTrackingConfig.objPath,["689ec395dc4382e15af1304405546fcdcb677044d61bf73db0b2d6c163be35f2"]),X("wristDetector",n.wristTrackingConfig.detectorPath,["b4c14a6f4b7bed1bc1cb313bbad5e877c7958c25b8e47d12583404f9a611d7ff"]),X("wristTracker",n.wristTrackingConfig.trackerPath,["5f2e644d8217fe47f15c823e8419085e2544140706e88b453615749e7c5b7918"]),X("wristObj",n.wristTrackingConfig.objPath,["5c763303cac33e377bbfbc3bd13475c0b99ca6412f9774ecc7a65fe72ac01732"]),X("background_replacement.deepar",n.embeddedEffectConfig.backgroundReplacementPath,["40e3ea2148e50af361eabc79a27b7d5b5c1ad04c4d9c0b48a296acd29054f3c9"]),X("background_blur.deepar",n.embeddedEffectConfig.backgroundBlurPath,["27018fc27e24a68a5f7022ac270d17734967e2c2c650630b9b8ade1e0198d684"]);var J=Object.assign({},n),Z="";"undefined"!=typeof document&&document.currentScript&&(Z=document.currentScript.src),t&&(Z=t),Z=0!==Z.indexOf("blob:")?Z.substr(0,Z.replace(/[?#].*/,"").lastIndexOf("/")+1):"";var ee=console.log.bind(console),te=console.warn.bind(console);Object.assign(n,J),J=null;var ne=!1;"object"!=typeof WebAssembly&&Fe("no native wasm support detected");var re,ae,ie,se,oe,ue,le,ce,he,pe,de=!1,fe="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function me(e,t,n){var r=t+n;for(n=t;e[n]&&!(n>=r);)++n;if(16<n-t&&e.buffer&&fe)return fe.decode(e.subarray(t,n));for(r="";t<n;){var a=e[t++];if(128&a){var i=63&e[t++];if(192==(224&a))r+=String.fromCharCode((31&a)<<6|i);else{var s=63&e[t++];65536>(a=224==(240&a)?(15&a)<<12|i<<6|s:(7&a)<<18|i<<12|s<<6|63&e[t++])?r+=String.fromCharCode(a):(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else r+=String.fromCharCode(a)}return r}function ge(e,t){return e?me(se,e,t):""}function ye(e,t,n,r){if(!(0<r))return 0;var a=n;r=n+r-1;for(var i=0;i<e.length;++i){var s=e.charCodeAt(i);if(55296<=s&&57343>=s&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i)),127>=s){if(n>=r)break;t[n++]=s}else{if(2047>=s){if(n+1>=r)break;t[n++]=192|s>>6}else{if(65535>=s){if(n+2>=r)break;t[n++]=224|s>>12}else{if(n+3>=r)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63}t[n++]=128|s>>6&63}t[n++]=128|63&s}}return t[n]=0,n-a}function be(e,t,n){return ye(e,se,t,n)}function ve(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);127>=r?t++:2047>=r?t+=2:55296<=r&&57343>=r?(t+=4,++n):t+=3}return t}function we(){var e=re.buffer;n.HEAP8=ie=new Int8Array(e),n.HEAP16=oe=new Int16Array(e),n.HEAP32=le=new Int32Array(e),n.HEAPU8=se=new Uint8Array(e),n.HEAPU16=ue=new Uint16Array(e),n.HEAPU32=ce=new Uint32Array(e),n.HEAPF32=he=new Float32Array(e),n.HEAPF64=pe=new Float64Array(e)}var _e,xe,ke=[],Te=[],Ee=[],Se=[],Ie=!1,Ae=0,Ce=0,Ne=null,Re=null;function Fe(e){throw te(e="Aborted("+e+")"),de=!0,ae=1,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),a(e),e}function Oe(e){return e.startsWith("data:application/octet-stream;base64,")}if(!Oe(xe="deepar.wasm")){var Me=xe;xe=n.locateFile?n.locateFile(Me,Z):Z+Me}function $e(){try{throw"both async and sync fetching of the wasm failed"}catch(e){Fe(e)}}function De(e,t,n){return function(e){return"function"==typeof fetch?fetch(e,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((function(){return $e()})):Promise.resolve().then((function(){return $e()}))}(e).then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(n,(function(e){te("failed to asynchronously prepare wasm: "+e),Fe(e)}))}var Pe={979896:(e,t,n,r,a,i)=>{var s=document.createElement("canvas"),o=s.getContext("2d");s.width=t,s.height=n,e=new Uint8ClampedArray(se.subarray(e,e+s.width*s.height*4)),e=new ImageData(e,s.width,s.height),o.putImageData(e,0,0),e=(o=document.createElement("canvas")).getContext("2d"),o.width=a,o.height=i,e.drawImage(s,0,0,o.width,o.height),a=e.getImageData(0,0,o.width,o.height),a=new Uint8Array(a.data.buffer),se.set(a,r)},980750:(e,t,n,r,a,i)=>{var s=document.createElement("canvas"),o=s.getContext("2d");s.width=t,s.height=n,e=new Uint8ClampedArray(se.subarray(e,e+s.width*s.height*4)),e=new ImageData(e,s.width,s.height),o.putImageData(e,0,0),e=(o=document.createElement("canvas")).getContext("2d"),o.width=a,o.height=i,e.drawImage(s,0,0,o.width,o.height),a=e.getImageData(0,0,o.width,o.height),a=new Uint8Array(a.data.buffer),se.set(a,r)},981604:()=>{console.log("License key not valid")},981641:()=>{n.qm()},981665:(e,t,r)=>{n.sm(e,t,r)},981708:e=>{n.rm(e)},981755:e=>{n.jm(ge(e))},981799:(e,t,r,a,i,s,o,u,l)=>{n.lm({translationOffset:e,rotationOffset:t,poseMatrixOffset:r,landmarksOffset:a,landmarks2DOffset:i,faceRectOffset:s},o,u,l)},981983:(e,t)=>{n.km(ge(e),ge(t))},982040:()=>{n.hm()},982078:()=>{n.im()},982123:()=>{n.om()},982164:()=>{n.wm()},982206:(e,t)=>{n.nm({detected:!!e},{detected:!!t})},982277:(e,t)=>{n.vm({detected:!!e,isLeft:!!t})},982342:()=>{n.tm()},982383:e=>{n.mm(!!e)},982424:e=>{n.pm(!!e)},982468:(e,t)=>{e=ge(e,t),n.gm(e)},982549:()=>{alert("DeepAR license not valid")},982583:()=>{n.endLoop()},982604:()=>{let e=Y("face");if(!e)return 0;e=new Uint8Array(e);var t=vi(e.length);return se.set(e,t),t},982813:()=>{var e=Xr,t=ve(e)+1,n=vi(t);return be(e,n,t),n},982967:()=>{var e=Yr,t=ve(e)+1,n=vi(t);return be(e,n,t),n},983126:()=>{var e=Qr,t=ve(e)+1,n=vi(t);return be(e,n,t),n},983292:()=>{var e=Zr,t=ve(e)+1,n=vi(t);return be(e,n,t),n},983455:()=>{var e=ea,t=ve(e)+1,n=vi(t);return be(e,n,t),n},983623:()=>{var e=Jr,t=ve(e)+1,n=vi(t);return be(e,n,t),n},983788:()=>{var e=ta,t=ve(e)+1,n=vi(t);return be(e,n,t),n},983950:()=>{var e=na,t=ve(e)+1,n=vi(t);return be(e,n,t),n},984111:()=>{var e=ra,t=ve(e)+1,n=vi(t);return be(e,n,t),n}};function Le(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Be(e){for(;0<e.length;)e.shift()(n)}var Ue=[],We=0,Ve=0;function ze(e){return _e.get(e)}function je(e){this.ol=e,this.Fk=e-24,this.am=function(e){ce[this.Fk+4>>2]=e},this.Lk=function(){return ce[this.Fk+4>>2]},this.Yl=function(e){ce[this.Fk+8>>2]=e},this.Gm=function(){return ce[this.Fk+8>>2]},this.$l=function(){le[this.Fk>>2]=0},this.Dl=function(e){ie[this.Fk+12>>0]=e?1:0},this.$k=function(){return 0!=ie[this.Fk+12>>0]},this.El=function(e){ie[this.Fk+13>>0]=e?1:0},this.Ll=function(){return 0!=ie[this.Fk+13>>0]},this.ll=function(e,t){this.Rk(0),this.am(e),this.Yl(t),this.$l(),this.Dl(!1),this.El(!1)},this.Yk=function(){le[this.Fk>>2]+=1},this.Rm=function(){var e=le[this.Fk>>2];return le[this.Fk>>2]=e-1,1===e},this.Rk=function(e){ce[this.Fk+16>>2]=e},this.Zk=function(){return ce[this.Fk+16>>2]},this.al=function(){if(Ni(this.Lk()))return ce[this.ol>>2];var e=this.Zk();return 0!==e?e:this.ol}}function Ge(){var e=Ve;if(!e)return _i(0),0;var t=new je(e);t.Rk(e);var n=t.Lk();if(!n)return _i(0),e;for(var r=0;r<arguments.length;r++){var a=arguments[r];if(0===a||a===n)break;if(Ci(a,n,t.Fk+16))return _i(a),e}return _i(n),e}var He={};function Ke(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function qe(e){return this.fromWireType(le[e>>2])}var Xe={},Ye={},Qe={};function Je(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return 48<=t&&57>=t?"_"+e:e}function Ze(e,t){return{[e=Je(e)]:function(){return t.apply(this,arguments)}}[e]}function et(e){var t=Error,n=Ze(e,(function(t){this.name=e,this.message=t,void 0!==(t=Error(t).stack)&&(this.stack=this.toString()+"\n"+t.replace(/^Error(:[^\n]*)?\n/,""))}));return n.prototype=Object.create(t.prototype),n.prototype.constructor=n,n.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},n}var tt=void 0;function nt(e){throw new tt(e)}function rt(e,t,n){function r(t){(t=n(t)).length!==e.length&&nt("Mismatched type converter count");for(var r=0;r<e.length;++r)lt(e[r],t[r])}e.forEach((function(e){Qe[e]=t}));var a=Array(t.length),i=[],s=0;t.forEach(((e,t)=>{Ye.hasOwnProperty(e)?a[t]=Ye[e]:(i.push(e),Xe.hasOwnProperty(e)||(Xe[e]=[]),Xe[e].push((()=>{a[t]=Ye[e],++s===i.length&&r(a)})))})),0===i.length&&r(a)}function at(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+e)}}var it=void 0;function st(e){for(var t="";se[e];)t+=it[se[e++]];return t}var ot=void 0;function ut(e){throw new ot(e)}function lt(e,t,n={}){if(!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");var r=t.name;if(e||ut('type "'+r+'" must have a positive integer typeid pointer'),Ye.hasOwnProperty(e)){if(n.Lm)return;ut("Cannot register type '"+r+"' twice")}Ye[e]=t,delete Qe[e],Xe.hasOwnProperty(e)&&(t=Xe[e],delete Xe[e],t.forEach((e=>e())))}function ct(e){ut(e.Ek.Ik.Gk.name+" instance already deleted")}var ht=!1;function pt(){}function dt(e){--e.count.value,0===e.count.value&&(e.Nk?e.Pk.Xk(e.Nk):e.Ik.Gk.Xk(e.Fk))}function ft(e,t,n){return t===n?e:void 0===n.Sk||null===(e=ft(e,t,n.Sk))?null:n.zm(e)}var mt={},gt=[];function yt(){for(;gt.length;){var e=gt.pop();e.Ek.jl=!1,e.delete()}}var bt=void 0,vt={};function wt(e,t){return t.Ik&&t.Fk||nt("makeClassHandle requires ptr and ptrType"),!!t.Pk!=!!t.Nk&&nt("Both smartPtrType and smartPtr must be specified"),t.count={value:1},_t(Object.create(e,{Ek:{value:t}}))}function _t(e){return"undefined"==typeof FinalizationRegistry?(_t=e=>e,e):(ht=new FinalizationRegistry((e=>{dt(e.Ek)})),_t=e=>{var t=e.Ek;return t.Nk&&ht.register(e,{Ek:t},e),e},pt=e=>{ht.unregister(e)},_t(e))}function xt(){}function kt(e,t,n){if(void 0===e[t].Kk){var r=e[t];e[t]=function(){return e[t].Kk.hasOwnProperty(arguments.length)||ut("Function '"+n+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[t].Kk+")!"),e[t].Kk[arguments.length].apply(this,arguments)},e[t].Kk=[],e[t].Kk[r.rl]=r}}function Tt(e,t,r){n.hasOwnProperty(e)?((void 0===r||void 0!==n[e].Kk&&void 0!==n[e].Kk[r])&&ut("Cannot register public name '"+e+"' twice"),kt(n,e,e),n.hasOwnProperty(r)&&ut("Cannot register multiple overloads of a function with the same number of arguments ("+r+")!"),n[e].Kk[r]=t):(n[e]=t,void 0!==r&&(n[e].En=r))}function Et(e,t,n,r,a,i,s,o){this.name=e,this.constructor=t,this.kl=n,this.Xk=r,this.Sk=a,this.Cm=i,this.ql=s,this.zm=o,this.Om=[]}function St(e,t,n){for(;t!==n;)t.ql||ut("Expected null or instance of "+n.name+", got an instance of "+t.name),e=t.ql(e),t=t.Sk;return e}function It(e,t){return null===t?(this.zl&&ut("null is not a valid "+this.name),0):(t.Ek||ut('Cannot pass "'+Gt(t)+'" as a '+this.name),t.Ek.Fk||ut("Cannot pass deleted object as a pointer of type "+this.name),St(t.Ek.Fk,t.Ek.Ik.Gk,this.Gk))}function At(e,t){if(null===t){if(this.zl&&ut("null is not a valid "+this.name),this.tl){var n=this.Bl();return null!==e&&e.push(this.Xk,n),n}return 0}if(t.Ek||ut('Cannot pass "'+Gt(t)+'" as a '+this.name),t.Ek.Fk||ut("Cannot pass deleted object as a pointer of type "+this.name),!this.sl&&t.Ek.Ik.sl&&ut("Cannot convert argument of type "+(t.Ek.Pk?t.Ek.Pk.name:t.Ek.Ik.name)+" to parameter type "+this.name),n=St(t.Ek.Fk,t.Ek.Ik.Gk,this.Gk),this.tl)switch(void 0===t.Ek.Nk&&ut("Passing raw pointer to smart pointer is illegal"),this.Vm){case 0:t.Ek.Pk===this?n=t.Ek.Nk:ut("Cannot convert argument of type "+(t.Ek.Pk?t.Ek.Pk.name:t.Ek.Ik.name)+" to parameter type "+this.name);break;case 1:n=t.Ek.Nk;break;case 2:if(t.Ek.Pk===this)n=t.Ek.Nk;else{var r=t.clone();n=this.Qm(n,Vt((function(){r.delete()}))),null!==e&&e.push(this.Xk,n)}break;default:ut("Unsupporting sharing policy")}return n}function Ct(e,t){return null===t?(this.zl&&ut("null is not a valid "+this.name),0):(t.Ek||ut('Cannot pass "'+Gt(t)+'" as a '+this.name),t.Ek.Fk||ut("Cannot pass deleted object as a pointer of type "+this.name),t.Ek.Ik.sl&&ut("Cannot convert argument of type "+t.Ek.Ik.name+" to parameter type "+this.name),St(t.Ek.Fk,t.Ek.Ik.Gk,this.Gk))}function Nt(e,t,n,r){this.name=e,this.Gk=t,this.zl=n,this.sl=r,this.tl=!1,this.Xk=this.Qm=this.Bl=this.Pl=this.Vm=this.Nm=void 0,void 0!==t.Sk?this.toWireType=At:(this.toWireType=r?It:Ct,this.Ok=null)}function Rt(e,t,r){n.hasOwnProperty(e)||nt("Replacing nonexistant public symbol"),void 0!==n[e].Kk&&void 0!==r?n[e].Kk[r]=t:(n[e]=t,n[e].rl=r)}function Ft(e,t,r){return e.includes("j")?(e=n["dynCall_"+e],t=r&&r.length?e.apply(null,[t].concat(r)):e.call(null,t)):t=ze(t).apply(null,r),t}function Ot(e,t){var n=(e=st(e)).includes("j")?function(e,t){var n=[];return function(){return n.length=0,Object.assign(n,arguments),Ft(e,t,n)}}(e,t):ze(t);return"function"!=typeof n&&ut("unknown function pointer with signature "+e+": "+t),n}var Mt=void 0;function $t(e){var t=st(e=ki(e));return wi(e),t}function Dt(e,t){var n=[],r={};throw t.forEach((function e(t){r[t]||Ye[t]||(Qe[t]?Qe[t].forEach(e):(n.push(t),r[t]=!0))})),new Mt(e+": "+n.map($t).join([", "]))}function Pt(e,t){for(var n=[],r=0;r<e;r++)n.push(ce[t+4*r>>2]);return n}function Lt(e,t,n,r,a){var i=t.length;2>i&&ut("argTypes array size mismatch! Must at least get return value and 'this' types!");var s=null!==t[1]&&null!==n,o=!1;for(n=1;n<t.length;++n)if(null!==t[n]&&void 0===t[n].Ok){o=!0;break}var u="void"!==t[0].name,l=i-2,c=Array(l),h=[],p=[];return function(){if(arguments.length!==l&&ut("function "+e+" called with "+arguments.length+" arguments, expected "+l+" args!"),p.length=0,h.length=s?2:1,h[0]=a,s){var n=t[1].toWireType(p,this);h[1]=n}for(var i=0;i<l;++i)c[i]=t[i+2].toWireType(p,arguments[i]),h.push(c[i]);if(i=r.apply(null,h),o)Ke(p);else for(var d=s?1:2;d<t.length;d++){var f=1===d?n:c[d-2];null!==t[d].Ok&&t[d].Ok(f)}return u?t[0].fromWireType(i):void 0}}var Bt=[],Ut=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Wt(e){4<e&&0==--Ut[e].Cl&&(Ut[e]=void 0,Bt.push(e))}var Vt=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var t=Bt.length?Bt.pop():Ut.length;return Ut[t]={Cl:1,value:e},t}};function zt(e,t,n){switch(t){case 0:return function(e){return this.fromWireType((n?ie:se)[e])};case 1:return function(e){return this.fromWireType((n?oe:ue)[e>>1])};case 2:return function(e){return this.fromWireType((n?le:ce)[e>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function jt(e,t){var n=Ye[e];return void 0===n&&ut(t+" has unknown type "+$t(e)),n}function Gt(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function Ht(e,t){switch(t){case 2:return function(e){return this.fromWireType(he[e>>2])};case 3:return function(e){return this.fromWireType(pe[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Kt(e,t,n){switch(t){case 0:return n?function(e){return ie[e]}:function(e){return se[e]};case 1:return n?function(e){return oe[e>>1]}:function(e){return ue[e>>1]};case 2:return n?function(e){return le[e>>2]}:function(e){return ce[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var qt="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function Xt(e,t){for(var n=e>>1,r=n+t/2;!(n>=r)&&ue[n];)++n;if(32<(n<<=1)-e&&qt)return qt.decode(se.subarray(e,n));for(n="",r=0;!(r>=t/2);++r){var a=oe[e+2*r>>1];if(0==a)break;n+=String.fromCharCode(a)}return n}function Yt(e,t,n){if(void 0===n&&(n=2147483647),2>n)return 0;var r=t;n=(n-=2)<2*e.length?n/2:e.length;for(var a=0;a<n;++a)oe[t>>1]=e.charCodeAt(a),t+=2;return oe[t>>1]=0,t-r}function Qt(e){return 2*e.length}function Jt(e,t){for(var n=0,r="";!(n>=t/4);){var a=le[e+4*n>>2];if(0==a)break;++n,65536<=a?(a-=65536,r+=String.fromCharCode(55296|a>>10,56320|1023&a)):r+=String.fromCharCode(a)}return r}function Zt(e,t,n){if(void 0===n&&(n=2147483647),4>n)return 0;var r=t;n=r+n-4;for(var a=0;a<e.length;++a){var i=e.charCodeAt(a);if(55296<=i&&57343>=i&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++a)),le[t>>2]=i,(t+=4)+4>n)break}return le[t>>2]=0,t-r}function en(e){for(var t=0,n=0;n<e.length;++n){var r=e.charCodeAt(n);55296<=r&&57343>=r&&++n,t+=4}return t}function tn(e){return 0==e%4&&(0!=e%100||0==e%400)}var nn,rn=[0,31,60,91,121,152,182,213,244,274,305,335],an=[0,31,59,90,120,151,181,212,243,273,304,334];function sn(e){return(tn(e.getFullYear())?rn:an)[e.getMonth()]+e.getDate()-1}function on(e){var t=ve(e)+1,n=vi(t);return n&&ye(e,ie,n,t),n}function un(e,t){if(xn=e,kn=t,_n)if(bn||(Ae+=1,bn=!0),0==e)vn=function(){var e=0|Math.max(0,mn+t-nn());setTimeout(gn,e)};else if(1==e)vn=function(){$n(gn)};else if(2==e){if("undefined"==typeof setImmediate){var n=[];addEventListener("message",(e=>{"setimmediate"!==e.data&&"setimmediate"!==e.data.target||(e.stopPropagation(),n.shift()())}),!0),setImmediate=function(e){n.push(e),postMessage("setimmediate","*")}}vn=function(){setImmediate(gn)}}}function ln(e){throw ae=e,ne||0<Ae||(Ti(),Be(Ee),xi(0),Kr[1].length&&qr(1,10),Kr[2].length&&qr(2,10),Ie=!0),ae=e,ne||0<Ae||(de=!0),new Le(e)}function cn(e){if(!(e instanceof Le||"unwind"==e))throw e}function hn(){if(!(ne||0<Ae))try{ln(ae)}catch(e){cn(e)}}function pn(e){if(!Ie&&!de)try{e(),hn()}catch(e){cn(e)}}function dn(e){fn||(fn={}),fn[e]||(fn[e]=1,te(e))}nn=()=>performance.now();var fn,mn,gn,yn,bn=!1,vn=null,wn=0,_n=null,xn=0,kn=0,Tn=0,En=[],Sn={},In=!1,An=!1,Cn=[];var Nn=!1,Rn=void 0,Fn=void 0;function On(){return!!In&&((document.exitFullscreen||document.cancelFullScreen||document.mozCancelFullScreen||document.msExitFullscreen||document.webkitCancelFullScreen||function(){}).apply(document,[]),!0)}var Mn=0;function $n(e){if("function"==typeof requestAnimationFrame)requestAnimationFrame(e);else{var t=Date.now();if(0===Mn)Mn=t+1e3/60;else for(;t+2>=Mn;)Mn+=1e3/60;setTimeout(e,Math.max(Mn-t,0))}}function Dn(e){return{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",bmp:"image/bmp",ogg:"audio/ogg",wav:"audio/wav",mp3:"audio/mpeg"}[e.substr(e.lastIndexOf(".")+1)]}var Pn=[];function Ln(){var e=n.canvas;Pn.forEach((function(t){t(e.width,e.height)}))}function Bn(e,t,r){t&&r?(e.an=t,e.Km=r):(t=e.an,r=e.Km);var a=t,i=r;if(n.forcedAspectRatio&&0<n.forcedAspectRatio&&(a/i<n.forcedAspectRatio?a=Math.round(i*n.forcedAspectRatio):i=Math.round(a/n.forcedAspectRatio)),(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===e.parentNode&&"undefined"!=typeof screen){var s=Math.min(screen.width/a,screen.height/i);a=Math.round(a*s),i=Math.round(i*s)}Fn?(e.width!=a&&(e.width=a),e.height!=i&&(e.height=i),void 0!==e.style&&(e.style.removeProperty("width"),e.style.removeProperty("height"))):(e.width!=t&&(e.width=t),e.height!=r&&(e.height=r),void 0!==e.style&&(a!=t||i!=r?(e.style.setProperty("width",a+"px","important"),e.style.setProperty("height",i+"px","important")):(e.style.removeProperty("width"),e.style.removeProperty("height"))))}var Un,Wn,Vn,zn,jn,Gn=!1,Hn=0,Kn=0,qn=0,Xn={alpha:!1,depth:!1,stencil:!1,antialias:!1},Yn={},Qn=1,Jn=[],Zn=[],er=[],tr=[],nr=[],rr=[],ar=[],ir=[],sr=[],or=[],ur=[],lr=[],cr={},hr={};function pr(e){yr||(yr=e)}function dr(e){for(var t=Qn++,n=e.length;n<t;n++)e[n]=null;return t}function fr(e,t,n){for(var r="",a=0;a<e;++a){var i=n?le[n+4*a>>2]:-1;r+=ge(le[t+4*a>>2],0>i?void 0:i)}return r}function mr(e,t){if(n.preinitializedWebGLContext){var r=n.preinitializedWebGLContext;t.Al=Number(r.getParameter(r.VERSION).match(/^WebGL (\d+).\d+/)[1])}else e.Lk||(e.Lk=e.getContext,e.getContext=function(t,n){return"webgl"==t==(n=e.Lk(t,n))instanceof WebGLRenderingContext?n:null}),r=e.getContext("webgl2",t);return r?function(e,t){var n=dr(ir),r={xn:n,attributes:t,version:t.Al,il:e};return e.canvas&&(e.canvas.Xl=r),ir[n]=r,(void 0===t.Am||t.Am)&&function(e){if(e||(e=br),!e.Mm){e.Mm=!0;var t=e.il;t.un=t.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),t.An=t.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=e.version&&(t.Mk=t.getExtension("EXT_disjoint_timer_query_webgl2")),(2>e.version||!t.Mk)&&(t.Mk=t.getExtension("EXT_disjoint_timer_query")),t.Cn=t.getExtension("WEBGL_multi_draw"),(t.getSupportedExtensions()||[]).forEach((function(e){e.includes("lose_context")||e.includes("debug")||t.getExtension(e)}))}}(r),n}(r,t):0}function gr(e){br=ir[e],n.dl=li=br&&br.il}var yr,br,vr={},wr=[];function _r(e,t,n){var r;for(wr.length=0,n>>=2;r=se[t++];)n+=105!=r&n,wr.push(105==r?le[n]:pe[n++>>1]),++n;return Pe[e].apply(null,wr)}var xr={},kr=0,Tr=[];function Er(e,t,n,r){li.drawElements(e,t,n,r)}function Sr(e,t,n,r){for(var a=0;a<e;a++){var i=li[n](),s=i&&dr(r);i?(i.name=s,r[s]=i):pr(1282),le[t+4*a>>2]=s}}function Ir(e,t,n,r,a,i,s,o){t=Zn[t],(e=li[e](t,n))&&(r=o&&be(e.name,o,r),a&&(le[a>>2]=r),i&&(le[i>>2]=e.size),s&&(le[s>>2]=e.type))}function Ar(e,t){ce[e>>2]=t,ce[e+4>>2]=(t-ce[e>>2])/4294967296}function Cr(e,t,n){if(t){var r=void 0;switch(e){case 36346:r=1;break;case 36344:return void(0!=n&&1!=n&&pr(1280));case 34814:case 36345:r=0;break;case 34466:var a=li.getParameter(34467);r=a?a.length:0;break;case 33309:if(2>br.version)return void pr(1282);r=2*(li.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>br.version)return void pr(1280);r=33307==e?3:0}if(void 0===r)switch(a=li.getParameter(e),typeof a){case"number":r=a;break;case"boolean":r=a?1:0;break;case"string":return void pr(1280);case"object":if(null===a)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:r=0;break;default:return void pr(1280)}else{if(a instanceof Float32Array||a instanceof Uint32Array||a instanceof Int32Array||a instanceof Array){for(e=0;e<a.length;++e)switch(n){case 0:le[t+4*e>>2]=a[e];break;case 2:he[t+4*e>>2]=a[e];break;case 4:ie[t+e>>0]=a[e]?1:0}return}try{r=0|a.name}catch(t){return pr(1280),void te("GL_INVALID_ENUM in glGet"+n+"v: Unknown object returned from WebGL getParameter("+e+")! (error: "+t+")")}}break;default:return pr(1280),void te("GL_INVALID_ENUM in glGet"+n+"v: Native code calling glGet"+n+"v("+e+") and it returns "+a+" of type "+typeof a+"!")}switch(n){case 1:Ar(t,r);break;case 0:le[t>>2]=r;break;case 2:he[t>>2]=r;break;case 4:ie[t>>0]=r?1:0}}else pr(1281)}function Nr(e,t,n,r){if(n){switch(typeof(t=li.getIndexedParameter(e,t))){case"boolean":e=t?1:0;break;case"number":e=t;break;case"object":if(null===t)switch(e){case 35983:case 35368:e=0;break;default:return void pr(1280)}else{if(!(t instanceof WebGLBuffer))return void pr(1280);e=0|t.name}break;default:return void pr(1280)}switch(r){case 1:Ar(n,e);break;case 0:le[n>>2]=e;break;case 2:he[n>>2]=e;break;case 4:ie[n>>0]=e?1:0;break;default:throw"internal emscriptenWebGLGetIndexed() error, bad type: "+r}}else pr(1281)}function Rr(e){var t=ve(e)+1,n=vi(t);return be(e,n,t),n}function Fr(e){return"]"==e.slice(-1)&&e.lastIndexOf("[")}function Or(e){var t,n=e.hl,r=e.yl;if(!n)for(e.hl=n={},e.Vl={},t=0;t<li.getProgramParameter(e,35718);++t){var a=li.getActiveUniform(e,t),i=a.name;a=a.size;var s=Fr(i);s=0<s?i.slice(0,s):i;var o=e.xl;for(e.xl+=a,r[s]=[a,o],i=0;i<a;++i)n[o]=i,e.Vl[o++]=s}}function Mr(e){var t=li.Hl;if(t){var n=t.hl[e];return"number"==typeof n&&(t.hl[e]=n=li.getUniformLocation(t,t.Vl[e]+(0<n?"["+n+"]":""))),n}pr(1282)}function $r(e,t,n,r){if(n)if(Or(e=Zn[e]),"number"==typeof(e=li.getUniform(e,Mr(t)))||"boolean"==typeof e)switch(r){case 0:le[n>>2]=e;break;case 2:he[n>>2]=e}else for(t=0;t<e.length;t++)switch(r){case 0:le[n+4*t>>2]=e[t];break;case 2:he[n+4*t>>2]=e[t]}else pr(1281)}function Dr(e,t,n,r){if(n)if(e=li.getVertexAttrib(e,t),34975==t)le[n>>2]=e&&e.name;else if("number"==typeof e||"boolean"==typeof e)switch(r){case 0:le[n>>2]=e;break;case 2:he[n>>2]=e;break;case 5:le[n>>2]=Math.fround(e)}else for(t=0;t<e.length;t++)switch(r){case 0:le[n+4*t>>2]=e[t];break;case 2:he[n+4*t>>2]=e[t];break;case 5:le[n+4*t>>2]=Math.fround(e[t])}else pr(1281)}function Pr(e){return 0==(e-=5120)?ie:1==e?se:2==e?oe:4==e?le:6==e?he:5==e||28922==e||28520==e||30779==e||30782==e?ce:ue}function Lr(e){return 31-Math.clz32(e.BYTES_PER_ELEMENT)}function Br(e,t){if(0>=e)return e;var n=32>=t?Math.abs(1<<t-1):Math.pow(2,t-1);return e>=n&&(32>=t||e>n)&&(e=-2*n+e),e}function Ur(e,t){return 0<=e?e:32>=t?2*Math.abs(1<<t-1)+e:Math.pow(2,t)+e}function Wr(e){for(var t=e;se[t];)++t;return t-e}function Vr(e,t){var n=Array(ve(e)+1);return e=ye(e,n,0,n.length),t&&(n.length=e),n}function zr(e){if(!e||!e.callee||!e.callee.name)return[null,"",""];var t,n=e.callee.name,r="(",a=!0;for(t in e){var i=e[t];a||(r+=", "),a=!1,r="number"==typeof i||"string"==typeof i?r+i:r+"("+typeof i+")"}return r+=")",a&&(r=""),[e=(e=e.callee.caller)?e.arguments:[],n,r]}var jr={};function Gr(){if(!Hr){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:"./this.program"};for(e in jr)void 0===jr[e]?delete t[e]:t[e]=jr[e];var n=[];for(e in t)n.push(e+"="+t[e]);Hr=n}return Hr}var Hr,Kr=[null,[],[]];function qr(e,t){var n=Kr[e];0===t||10===t?((1===e?ee:te)(me(n,0)),n.length=0):n.push(t)}var Xr=null,Yr=null,Qr=null,Jr=null,Zr=null,ea=null,ta=null,na=null,ra=null,aa=null,ia=null,sa={},oa=!1,ua=null,la=null,ca=0,ha=null,pa=-1,da=-1,fa=null,ma=null,ga=!1;function ya(e,t){ma?ma.segmentForVideo(e,performance.now(),(e=>{0<e.confidenceMasks.length&&he.set(e.confidenceMasks[0].getAsFloat32Array(),t>>2)})):console.error("Trying to use mediaPipe segment but it is not initialized.")}async function ba(){if(!ma&&!ga){console.log("DeepAR MediaPipe segmentation initialize started"),ga=!0,fa||(fa=await c.FilesetResolver.forVisionTasks(n.segmentationConfig.mediaPipeConfig.wasmBasePath));var e=Y("segmentationMediaPipe");e||(e=await Q("segmentationMediaPipe")),ma=await c.ImageSegmenter.createFromOptions(fa,{runningMode:"VIDEO",baseOptions:{modelAssetBuffer:new Uint8Array(e)},outputConfidenceMasks:!0}),ga=!1,console.log("DeepAR MediaPipe segmentation initialized")}}var va=!1,wa=null,_a=null,xa=null,ka=null,Ta=null;function Ea(e){if(!va&&null!=wa&&wa.isInitialized()){var t=_a.getVideoCanvas();t.width=e.width,t.height=e.height,_a.preProcessWithBuffer(e);try{wa.trackSync()}catch(e){return console.log(e),void(xa=!1)}null!=(e=wa.getInterpolatedPose())&&wa.isDetected()?(Ta=e.t(),ka=e.R(),xa=!0):xa=!1}}var Sa=!1,Ia=null,Aa=null,Ca=null,Na=null,Ra=null,Fa=null,Oa=null,Ma=null;async function $a(){if(null==Ia&&(Ia=new l.Foot),null==Aa&&(Aa=new l.VideoManager(null)),!Ia.isInitialized()&&!Sa){Sa=!0,console.log("DeepAR FootTracking initialize started.");var e,t=Y("footDetector");t||(e=Q("footDetector"));var r,a=Y("footTracker");a||(r=Q("footTracker"));var i,s=Y("footObj");s||(i=Q("footObj")),t||(t=await e),a||(a=await r),s||(s=await i),await Ia.initialize(Aa,{poseEstimationWasmFilename:n.footTrackingConfig.poseEstimationWasmPath,modelFilename:t,featuresFilename:a,objFilename:s,fovY:50,detectScoreThs:.25,validTrackedKeypThs:.3,trackScoreThs:.3,footToDetect:"BOTH",wasmBackend:{enable:!0,tfjsBackendWasmPath:n.footTrackingConfig.tfjsBackendWasmPath,tfjsBackendWasmSimdPath:n.footTrackingConfig.tfjsBackendWasmSimdPath,tfjsBackendWasmThreadedPath:n.footTrackingConfig.tfjsBackendWasmThreadedSimdPath}}),Sa=!1,console.log("DeepAR FootTracking initialized!")}}function Da(){return null!=Ia&&Ia.isInitialized()}function Pa(e){if(!Sa&&null!=Ia&&Ia.isInitialized()){var t=Aa.getVideoCanvas();t.width=e.width,t.height=e.height,Aa.preProcessWithBuffer(e);try{Ia.trackSync()}catch(e){return console.log(e),void(Ma=Ra=!1)}e=Ia.getInterpolatedPose("LEFT_FOOT"),t=Ia.getInterpolatedPose("RIGHT_FOOT"),null!=e&&e.isDetected()?(Ca=e.t(),Na=e.R(),Ra=!0):Ra=!1,null!=t&&t.isDetected()?(Fa=t.t(),Oa=t.R(),Ma=!0):Ma=!1}}var La=null,Ba=null,Ua=null,Wa=!1;function Va(e,t){if(La.isInitialized()){var n=Ba.getVideoCanvas();n.width=e.width,n.height=e.height,Ba.preProcessWithBuffer(e),La.processSync(),Ua=La.getOutput(),Ba.postProcess(),he.set(Ua,t>>2)}}async function za(){if(null==La&&(La=new l.Segmentation),null==Ba&&(Ba=new l.VideoManager(null)),!La.isInitialized()&&!Wa){console.log("DeepAR segmentation initialize started"),Wa=!0;var e=Y("segmentationXzimg");e||(e=await Q("segmentationXzimg")),await La.initialize(Ba,{filename:e}),Wa=!1,console.log("DeepAR segmentation initialized")}}function ja(){return null!=La&&La.isInitialized()}var Ga=!1,Ha=null,Ka=null,qa=null,Xa=null,Ya=null,Qa=0,Ja=0;function Za(){return null!=Ha&&Ha.isInitialized()}function ei(e){if(Za()){var t=Ka.getVideoCanvas();t.width=e.width,t.height=e.height,Ka.preProcessWithBuffer(e);try{Ha.trackSync()}catch(e){return console.log(e),void(qa=!1)}e=!1,Ha.isDetected()?(++Qa>Ja&&(e=!0),(qa=e)&&(e=Ha.getInterpolatedPose(),Xa=e.t(),Ya=e.R())):(Qa=0,qa=!1)}}function ti(e,t){for(var n=0,r=0;r<=t;n+=e[r++]);return n}var ni=[31,29,31,30,31,30,31,31,30,31,30,31],ri=[31,28,31,30,31,30,31,31,30,31,30,31];function ai(e,t){for(e=new Date(e.getTime());0<t;){var n=e.getMonth(),r=(tn(e.getFullYear())?ni:ri)[n];if(!(t>r-e.getDate())){e.setDate(e.getDate()+t);break}t-=r-e.getDate()+1,e.setDate(1),11>n?e.setMonth(n+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return e}function ii(e,t,n,r){function a(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=n[0]+e;return e}function i(e,t){return a(e,t,"0")}function s(e,t){function n(e){return 0>e?-1:0<e?1:0}var r;return 0===(r=n(e.getFullYear()-t.getFullYear()))&&0===(r=n(e.getMonth()-t.getMonth()))&&(r=n(e.getDate()-t.getDate())),r}function o(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function u(e){e=ai(new Date(e.gl+1900,0,1),e.fl);var t=new Date(e.getFullYear()+1,0,4),n=o(new Date(e.getFullYear(),0,4));return t=o(t),0>=s(n,e)?0>=s(t,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var l=le[r+40>>2];for(var c in r={Ym:le[r>>2],Xm:le[r+4>>2],vl:le[r+8>>2],Fl:le[r+12>>2],wl:le[r+16>>2],gl:le[r+20>>2],Tk:le[r+24>>2],fl:le[r+28>>2],In:le[r+32>>2],Wm:le[r+36>>2],Zm:l?ge(l):""},n=ge(n),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(c,"g"),l[c]);var h="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),p="January February March April May June July August September October November December".split(" ");for(c in l={"%a":function(e){return h[e.Tk].substring(0,3)},"%A":function(e){return h[e.Tk]},"%b":function(e){return p[e.wl].substring(0,3)},"%B":function(e){return p[e.wl]},"%C":function(e){return i((e.gl+1900)/100|0,2)},"%d":function(e){return i(e.Fl,2)},"%e":function(e){return a(e.Fl,2," ")},"%g":function(e){return u(e).toString().substring(2)},"%G":function(e){return u(e)},"%H":function(e){return i(e.vl,2)},"%I":function(e){return 0==(e=e.vl)?e=12:12<e&&(e-=12),i(e,2)},"%j":function(e){return i(e.Fl+ti(tn(e.gl+1900)?ni:ri,e.wl-1),3)},"%m":function(e){return i(e.wl+1,2)},"%M":function(e){return i(e.Xm,2)},"%n":function(){return"\n"},"%p":function(e){return 0<=e.vl&&12>e.vl?"AM":"PM"},"%S":function(e){return i(e.Ym,2)},"%t":function(){return"\t"},"%u":function(e){return e.Tk||7},"%U":function(e){return i(Math.floor((e.fl+7-e.Tk)/7),2)},"%V":function(e){var t=Math.floor((e.fl+7-(e.Tk+6)%7)/7);if(2>=(e.Tk+371-e.fl-2)%7&&t++,t)53==t&&(4==(n=(e.Tk+371-e.fl)%7)||3==n&&tn(e.gl)||(t=1));else{t=52;var n=(e.Tk+7-e.fl-1)%7;(4==n||5==n&&tn(e.gl%400-1))&&t++}return i(t,2)},"%w":function(e){return e.Tk},"%W":function(e){return i(Math.floor((e.fl+7-(e.Tk+6)%7)/7),2)},"%y":function(e){return(e.gl+1900).toString().substring(2)},"%Y":function(e){return e.gl+1900},"%z":function(e){var t=0<=(e=e.Wm);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.Zm},"%%":function(){return"%"}},n=n.replace(/%%/g,"\0\0"),l)n.includes(c)&&(n=n.replace(new RegExp(c,"g"),l[c](r)));return(c=Vr(n=n.replace(/\0\0/g,"%"),!1)).length>t?0:(ie.set(c,e),c.length-1)}function si(e,t,r,a){var i=!r||r.every((e=>"number"===e||"boolean"===e));return"string"!==t&&i&&!a?n["_"+e]:function(){return function(e,t,r,a){var i={string:e=>{var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);be(e,t=Ai(n),n)}return t},array:e=>{var t=Ai(e.length);return ie.set(e,t),t}};e=n["_"+e];var s=[],o=0;if(a)for(var u=0;u<a.length;u++){var l=i[r[u]];l?(0===o&&(o=Si()),s[u]=l(a[u])):s[u]=a[u]}return function(e){return 0!==o&&Ii(o),"string"===t?ge(e):"boolean"===t?!!e:e}(r=e.apply(null,s))}(e,t,r,arguments)}}tt=n.InternalError=et("InternalError");for(var oi=Array(256),ui=0;256>ui;++ui)oi[ui]=String.fromCharCode(ui);it=oi,ot=n.BindingError=et("BindingError"),xt.prototype.isAliasOf=function(e){if(!(this instanceof xt&&e instanceof xt))return!1;var t=this.Ek.Ik.Gk,n=this.Ek.Fk,r=e.Ek.Ik.Gk;for(e=e.Ek.Fk;t.Sk;)n=t.ql(n),t=t.Sk;for(;r.Sk;)e=r.ql(e),r=r.Sk;return t===r&&n===e},xt.prototype.clone=function(){if(this.Ek.Fk||ct(this),this.Ek.pl)return this.Ek.count.value+=1,this;var e=_t,t=Object,n=t.create,r=Object.getPrototypeOf(this),a=this.Ek;return(e=e(n.call(t,r,{Ek:{value:{count:a.count,jl:a.jl,pl:a.pl,Fk:a.Fk,Ik:a.Ik,Nk:a.Nk,Pk:a.Pk}}}))).Ek.count.value+=1,e.Ek.jl=!1,e},xt.prototype.delete=function(){this.Ek.Fk||ct(this),this.Ek.jl&&!this.Ek.pl&&ut("Object already scheduled for deletion"),pt(this),dt(this.Ek),this.Ek.pl||(this.Ek.Nk=void 0,this.Ek.Fk=void 0)},xt.prototype.isDeleted=function(){return!this.Ek.Fk},xt.prototype.deleteLater=function(){return this.Ek.Fk||ct(this),this.Ek.jl&&!this.Ek.pl&&ut("Object already scheduled for deletion"),gt.push(this),1===gt.length&&bt&&bt(yt),this.Ek.jl=!0,this},n.getInheritedInstanceCount=function(){return Object.keys(vt).length},n.getLiveInheritedInstances=function(){var e,t=[];for(e in vt)vt.hasOwnProperty(e)&&t.push(vt[e]);return t},n.flushPendingDeletes=yt,n.setDelayFunction=function(e){bt=e,gt.length&&bt&&bt(yt)},Nt.prototype.Fm=function(e){return this.Pl&&(e=this.Pl(e)),e},Nt.prototype.Il=function(e){this.Xk&&this.Xk(e)},Nt.prototype.argPackAdvance=8,Nt.prototype.readValueFromPointer=qe,Nt.prototype.deleteObject=function(e){null!==e&&e.delete()},Nt.prototype.fromWireType=function(e){function t(){return this.tl?wt(this.Gk.kl,{Ik:this.Nm,Fk:n,Pk:this,Nk:e}):wt(this.Gk.kl,{Ik:this,Fk:e})}var n=this.Fm(e);if(!n)return this.Il(e),null;var r=function(e,t){for(void 0===t&&ut("ptr should not be undefined");e.Sk;)t=e.ql(t),e=e.Sk;return vt[t]}(this.Gk,n);if(void 0!==r)return 0===r.Ek.count.value?(r.Ek.Fk=n,r.Ek.Nk=e,r.clone()):(r=r.clone(),this.Il(e),r);if(r=this.Gk.Cm(n),!(r=mt[r]))return t.call(this);r=this.sl?r.ym:r.pointerType;var a=ft(n,this.Gk,r.Gk);return null===a?t.call(this):this.tl?wt(r.Gk.kl,{Ik:r,Fk:a,Pk:this,Nk:e}):wt(r.Gk.kl,{Ik:r,Fk:a})},Mt=n.UnboundTypeError=et("UnboundTypeError"),n.count_emval_handles=function(){for(var e=0,t=5;t<Ut.length;++t)void 0!==Ut[t]&&++e;return e},n.get_first_emval=function(){for(var e=5;e<Ut.length;++e)if(void 0!==Ut[e])return Ut[e];return null},n.requestFullscreen=function(e,t){!function(e,t){function r(){In=!1;var e=a.parentNode;(document.fullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||document.webkitFullscreenElement||document.webkitCurrentFullScreenElement)===e?(a.exitFullscreen=On,Rn&&a.requestPointerLock(),In=!0,Fn?("undefined"!=typeof SDL&&(le[SDL.screen>>2]=8388608|ce[SDL.screen>>2]),Bn(n.canvas),Ln()):Bn(a)):(e.parentNode.insertBefore(a,e),e.parentNode.removeChild(e),Fn?("undefined"!=typeof SDL&&(le[SDL.screen>>2]=-8388609&ce[SDL.screen>>2]),Bn(n.canvas),Ln()):Bn(a)),n.onFullScreen&&n.onFullScreen(In),n.onFullscreen&&n.onFullscreen(In)}void 0===(Rn=e)&&(Rn=!0),void 0===(Fn=t)&&(Fn=!1);var a=n.canvas;Nn||(Nn=!0,document.addEventListener("fullscreenchange",r,!1),document.addEventListener("mozfullscreenchange",r,!1),document.addEventListener("webkitfullscreenchange",r,!1),document.addEventListener("MSFullscreenChange",r,!1));var i=document.createElement("div");a.parentNode.insertBefore(i,a),i.appendChild(a),i.requestFullscreen=i.requestFullscreen||i.mozRequestFullScreen||i.msRequestFullscreen||(i.webkitRequestFullscreen?()=>i.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT):null)||(i.webkitRequestFullScreen?()=>i.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT):null),i.requestFullscreen()}(e,t)},n.requestAnimationFrame=function(e){$n(e)},n.setCanvasSize=function(e,t,r){Bn(n.canvas,e,t),r||Ln()},n.pauseMainLoop=function(){vn=null,wn++},n.resumeMainLoop=function(){wn++;var e=xn,t=kn,r=_n;_n=null,function(e){function t(){return!(r<wn&&(--Ae,hn(),1))}!_n||Fe("emscripten_set_main_loop: there can only be one main loop function at once: call emscripten_cancel_main_loop to cancel the previous one before setting a new one with different parameters."),_n=e;var r=wn;bn=!1,gn=function(){if(!de)if(0<En.length){var r=Date.now(),a=En.shift();if(a.wn(a.sn),yn){var i=yn,s=0==i%1?i-1:Math.floor(i);yn=a.tn?s:(8*i+(s+.5))/9}ee('main loop blocker "'+a.name+'" took '+(Date.now()-r)+" ms"),n.setStatus&&(r=n.statusMessage||"Please wait...",i=Sn.vn,(a=yn)?a<i?n.setStatus(r+" ("+(i-a)+"/"+i+")"):n.setStatus(r):n.setStatus("")),t()&&setTimeout(gn,0)}else t()&&(Tn=Tn+1|0,1==xn&&1<kn&&0!=Tn%kn?vn():(0==xn&&(mn=nn()),de||n.preMainLoop&&!1===n.preMainLoop()||(pn(e),n.postMainLoop&&n.postMainLoop()),t()&&("object"==typeof SDL&&SDL.audio&&SDL.audio.Pm&&SDL.audio.Pm(),vn())))}}(r),un(e,t),vn()},n.getUserMedia=function(){window.getUserMedia||(window.getUserMedia=navigator.getUserMedia||navigator.mozGetUserMedia),window.getUserMedia(void 0)},n.createContext=function(e,t,r,a){return function(e,t,r,a){if(t&&n.dl&&e==n.canvas)return n.dl;var i;if(t){var s={antialias:!1,alpha:!1,Al:2};if(a)for(var o in a)s[o]=a[o];if(void 0!==vr&&(i=mr(e,s)))var u=ir[i].il}else u=e.getContext("2d");return u?(r&&(t||void 0===li||Fe("cannot set in module if GLctx is used, but we are a non-GL context that would replace it"),n.dl=u,t&&gr(i),n.$m=t,Cn.forEach((function(e){e()})),function(){function e(){An=document.pointerLockElement===n.canvas||document.mozPointerLockElement===n.canvas||document.webkitPointerLockElement===n.canvas||document.msPointerLockElement===n.canvas}if(n.preloadPlugins||(n.preloadPlugins=[]),!Un){Un=!0;try{Wn=!0}catch(e){Wn=!1,te("warning: no blob constructor, cannot create blobs with mimetypes")}Vn="undefined"!=typeof MozBlobBuilder?MozBlobBuilder:"undefined"!=typeof WebKitBlobBuilder?WebKitBlobBuilder:Wn?null:te("warning: no BlobBuilder"),zn="undefined"!=typeof window?window.URL?window.URL:window.webkitURL:void 0,n.Nl||void 0!==zn||(te("warning: Browser does not support creating object URLs. Built-in browser image decoding will not be available."),n.Nl=!0),n.preloadPlugins.push({canHandle:function(e){return!n.Nl&&/\.(jpg|jpeg|png|bmp)$/i.test(e)},handle:function(e,t,n,r){var a=null;if(Wn)try{(a=new Blob([e],{type:Dn(t)})).size!==e.length&&(a=new Blob([new Uint8Array(e).buffer],{type:Dn(t)}))}catch(e){dn("Blob constructor present but fails: "+e+"; falling back to blob builder")}a||((a=new Vn).append(new Uint8Array(e).buffer),a=a.getBlob());var i=zn.createObjectURL(a),s=new Image;s.onload=()=>{s.complete||Fe("Image "+t+" could not be decoded");var r=document.createElement("canvas");r.width=s.width,r.height=s.height,r.getContext("2d").drawImage(s,0,0),zn.revokeObjectURL(i),n&&n(e)},s.onerror=()=>{ee("Image "+i+" could not be decoded"),r&&r()},s.src=i}}),n.preloadPlugins.push({canHandle:function(e){return!n.Dn&&e.substr(-4)in{".ogg":1,".wav":1,".mp3":1}},handle:function(e,t,n,r){function a(){s||(s=!0,n&&n(e))}function i(){s||(s=!0,new Audio,r&&r())}var s=!1;if(!Wn)return i();try{var o=new Blob([e],{type:Dn(t)})}catch(e){return i()}o=zn.createObjectURL(o);var u=new Audio;u.addEventListener("canplaythrough",(()=>a()),!1),u.onerror=function(){if(!s){te("warning: browser could not fully decode audio "+t+", trying slower base64 approach");for(var n="",r=0,i=0,o=0;o<e.length;o++)for(r=r<<8|e[o],i+=8;6<=i;){var l=r>>i-6&63;i-=6,n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[l]}2==i?(n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(3&r)<<4],n+="=="):4==i&&(n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(15&r)<<2],n+="="),u.src="data:audio/x-"+t.substr(-3)+";base64,"+n,a()}},u.src=o,function(e){Ae+=1,setTimeout((function(){--Ae,pn(e)}),1e4)}((function(){a()}))}});var t=n.canvas;t&&(t.requestPointerLock=t.requestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock||t.msRequestPointerLock||(()=>{}),t.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||document.msExitPointerLock||(()=>{}),t.exitPointerLock=t.exitPointerLock.bind(document),document.addEventListener("pointerlockchange",e,!1),document.addEventListener("mozpointerlockchange",e,!1),document.addEventListener("webkitpointerlockchange",e,!1),document.addEventListener("mspointerlockchange",e,!1),n.elementPointerLock&&t.addEventListener("click",(e=>{!An&&n.canvas.requestPointerLock&&(n.canvas.requestPointerLock(),e.preventDefault())}),!1))}}()),u):null}(e,t,r,a)};for(var li,ci=0;32>ci;++ci)Tr.push(Array(ci));(ua=document.createElement("canvas")).style.display="none",la=ua.getContext("2d",{willReadFrequently:!0,desynchronized:!0,alpha:!1});e:{if(!window.AudioContext){if(!window.webkitAudioContext){console.error("Audio playback is not supported!");break e}window.AudioContext=window.webkitAudioContext}aa=new AudioContext,(ia=aa.createGain()).connect(aa.destination),oa=!0}var hi={l:function(e,t,n,r){Fe("Assertion failed: "+ge(e)+", at: "+[t?ge(t):"unknown filename",n,r?ge(r):"unknown function"])},m:function(e){return(e=new je(e)).$k()||(e.Dl(!0),We--),e.El(!1),Ue.push(e),e.Yk(),e.al()},w:function(){Ei(0);var e=Ue.pop();if(e.Rm()&&!e.Ll()){var t=e.Gm();t&&ze(t)(e.ol),di(e.ol)}Ve=0},a:Ge,c:Ge,f:Ge,ba:Ge,mb:function(){var e=Ue.pop();e||Fe("no exception to throw");var t=e.ol;throw e.Ll()||(Ue.push(e),e.El(!0),e.Dl(!1),We++),Ve=t,t},I:function(e,t,n){throw new je(e).ll(t,n),Ve=e,We++,e},tc:function(){return We},e:function(e){throw Ve||(Ve=e),e},Ia:function(){return 0},Ac:function(){return 0},Bc:function(){},Mh:function(e){var t=He[e];delete He[e];var n=t.Bl,r=t.Xk,a=t.Kl,i=a.map((e=>e.Jm)).concat(a.map((e=>e.Tm)));rt([e],i,(e=>{var i={};return a.forEach(((t,n)=>{var r=e[n],s=t.Hm,o=t.Im,u=e[n+a.length],l=t.Sm,c=t.Um;i[t.Bm]={read:e=>r.fromWireType(s(o,e)),write:(e,t)=>{var n=[];l(c,e,u.toWireType(n,t)),Ke(n)}}})),[{name:t.name,fromWireType:function(e){var t,n={};for(t in i)n[t]=i[t].read(e);return r(e),n},toWireType:function(e,t){for(var a in i)if(!(a in t))throw new TypeError('Missing field: "'+a+'"');var s=n();for(a in i)i[a].write(s,t[a]);return null!==e&&e.push(r,s),s},argPackAdvance:8,readValueFromPointer:qe,Ok:r}]}))},hc:function(){},ei:function(e,t,n,r,a){var i=at(n);lt(e,{name:t=st(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?r:a},argPackAdvance:8,readValueFromPointer:function(e){if(1===n)var r=ie;else if(2===n)r=oe;else{if(4!==n)throw new TypeError("Unknown boolean type size: "+t);r=le}return this.fromWireType(r[e>>i])},Ok:null})},gh:function(e,t,n,r,a,i,s,o,u,l,c,h,p){c=st(c),i=Ot(a,i),o&&(o=Ot(s,o)),l&&(l=Ot(u,l)),p=Ot(h,p);var d=Je(c);Tt(d,(function(){Dt("Cannot construct "+c+" due to unbound types",[r])})),rt([e,t,n],r?[r]:[],(function(t){if(t=t[0],r)var n=t.Gk,a=n.kl;else a=xt.prototype;t=Ze(d,(function(){if(Object.getPrototypeOf(this)!==s)throw new ot("Use 'new' to construct "+c);if(void 0===u.cl)throw new ot(c+" has no accessible constructor");var e=u.cl[arguments.length];if(void 0===e)throw new ot("Tried to invoke ctor of "+c+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(u.cl).toString()+") parameters instead!");return e.apply(this,arguments)}));var s=Object.create(a,{constructor:{value:t}});t.prototype=s;var u=new Et(c,t,s,p,n,i,o,l);n=new Nt(c,u,!0,!1),a=new Nt(c+"*",u,!1,!1);var h=new Nt(c+" const*",u,!1,!0);return mt[e]={pointerType:a,ym:h},Rt(d,t),[n,a,h]}))},Xg:function(e,t,n,r,a,i){0<t||Fe();var s=Pt(t,n);a=Ot(r,a),rt([],[e],(function(e){var n="constructor "+(e=e[0]).name;if(void 0===e.Gk.cl&&(e.Gk.cl=[]),void 0!==e.Gk.cl[t-1])throw new ot("Cannot register multiple constructors with identical number of parameters ("+(t-1)+") for class '"+e.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return e.Gk.cl[t-1]=()=>{Dt("Cannot construct "+e.name+" due to unbound types",s)},rt([],s,(function(r){return r.splice(1,0,null),e.Gk.cl[t-1]=Lt(n,r,null,a,i),[]})),[]}))},_:function(e,t,n,r,a,i,s,o){var u=Pt(n,r);t=st(t),i=Ot(a,i),rt([],[e],(function(e){function r(){Dt("Cannot call "+a+" due to unbound types",u)}var a=(e=e[0]).name+"."+t;t.startsWith("@@")&&(t=Symbol[t.substring(2)]),o&&e.Gk.Om.push(t);var l=e.Gk.kl,c=l[t];return void 0===c||void 0===c.Kk&&c.className!==e.name&&c.rl===n-2?(r.rl=n-2,r.className=e.name,l[t]=r):(kt(l,t,a),l[t].Kk[n-2]=r),rt([],u,(function(r){return r=Lt(a,r,e,i,s),void 0===l[t].Kk?(r.rl=n-2,l[t]=r):l[t].Kk[n-2]=r,[]})),[]}))},di:function(e,t){lt(e,{name:t=st(t),fromWireType:function(e){e||ut("Cannot use deleted val. handle = "+e);var t=Ut[e].value;return Wt(e),t},toWireType:function(e,t){return Vt(t)},argPackAdvance:8,readValueFromPointer:qe,Ok:null})},ji:function(e,t,n,r){function a(){}n=at(n),t=st(t),a.values={},lt(e,{name:t,constructor:a,fromWireType:function(e){return this.constructor.values[e]},toWireType:function(e,t){return t.value},argPackAdvance:8,readValueFromPointer:zt(t,n,r),Ok:null}),Tt(t,a)},sa:function(e,t,n){var r=jt(e,"enum");t=st(t),e=r.constructor,r=Object.create(r.constructor.prototype,{value:{value:n},constructor:{value:Ze(r.name+"_"+t,(function(){}))}}),e.values[n]=r,e[t]=r},La:function(e,t,n){n=at(n),lt(e,{name:t=st(t),fromWireType:function(e){return e},toWireType:function(e,t){return t},argPackAdvance:8,readValueFromPointer:Ht(t,n),Ok:null})},Bh:function(e,t,n,r,a,i){var s=Pt(t,n);e=st(e),a=Ot(r,a),Tt(e,(function(){Dt("Cannot call "+e+" due to unbound types",s)}),t-1),rt([],s,(function(n){return Rt(e,Lt(e,[n[0],null].concat(n.slice(1)),null,a,i),t-1),[]}))},O:function(e,t,n,r,a){t=st(t),-1===a&&(a=4294967295),a=at(n);var i=e=>e;if(0===r){var s=32-8*n;i=e=>e<<s>>>s}n=t.includes("unsigned")?function(e,t){return t>>>0}:function(e,t){return t},lt(e,{name:t,fromWireType:i,toWireType:n,argPackAdvance:8,readValueFromPointer:Kt(t,a,0!==r),Ok:null})},G:function(e,t,n){function r(e){e>>=2;var t=ce;return new a(t.buffer,t[e+1],t[e])}var a=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];lt(e,{name:n=st(n),fromWireType:r,argPackAdvance:8,readValueFromPointer:r},{Lm:!0})},Ka:function(e,t){var n="std::string"===(t=st(t));lt(e,{name:t,fromWireType:function(e){var t=ce[e>>2],r=e+4;if(n)for(var a=r,i=0;i<=t;++i){var s=r+i;if(i==t||0==se[s]){if(a=ge(a,s-a),void 0===o)var o=a;else o+=String.fromCharCode(0),o+=a;a=s+1}}else{for(o=Array(t),i=0;i<t;++i)o[i]=String.fromCharCode(se[r+i]);o=o.join("")}return wi(e),o},toWireType:function(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var r,a="string"==typeof t;a||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||ut("Cannot pass non-string to std::string"),r=n&&a?ve(t):t.length;var i=vi(4+r+1),s=i+4;if(ce[i>>2]=r,n&&a)be(t,s,r+1);else if(a)for(a=0;a<r;++a){var o=t.charCodeAt(a);255<o&&(wi(s),ut("String has UTF-16 code units that do not fit in 8 bits")),se[s+a]=o}else for(a=0;a<r;++a)se[s+a]=t[a];return null!==e&&e.push(wi,i),i},argPackAdvance:8,readValueFromPointer:qe,Ok:function(e){wi(e)}})},ra:function(e,t,n){if(n=st(n),2===t)var r=Xt,a=Yt,i=Qt,s=()=>ue,o=1;else 4===t&&(r=Jt,a=Zt,i=en,s=()=>ce,o=2);lt(e,{name:n,fromWireType:function(e){for(var n,a=ce[e>>2],i=s(),u=e+4,l=0;l<=a;++l){var c=e+4+l*t;l!=a&&0!=i[c>>o]||(u=r(u,c-u),void 0===n?n=u:(n+=String.fromCharCode(0),n+=u),u=c+t)}return wi(e),n},toWireType:function(e,r){"string"!=typeof r&&ut("Cannot pass non-string to C++ string type "+n);var s=i(r),u=vi(4+s+t);return ce[u>>2]=s>>o,a(r,u+4,s+t),null!==e&&e.push(wi,u),u},argPackAdvance:8,readValueFromPointer:qe,Ok:function(e){wi(e)}})},Xh:function(e,t,n,r,a,i){He[e]={name:st(t),Bl:Ot(n,r),Xk:Ot(a,i),Kl:[]}},Ja:function(e,t,n,r,a,i,s,o,u,l){He[e].Kl.push({Bm:st(t),Jm:n,Hm:Ot(r,a),Im:i,Tm:s,Sm:Ot(o,u),Um:l})},fi:function(e,t){lt(e,{yn:!0,name:t=st(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Cc:function(){return!0},uc:function(){throw 1/0},gg:Wt,rg:function(e){4<e&&(Ut[e].Cl+=1)},Cg:function(e,t){return e=(e=jt(e,"_emval_take_value")).readValueFromPointer(t),Vt(e)},Ec:function(e,t){e=new Date(1e3*(ce[e>>2]+4294967296*le[e+4>>2])),le[t>>2]=e.getUTCSeconds(),le[t+4>>2]=e.getUTCMinutes(),le[t+8>>2]=e.getUTCHours(),le[t+12>>2]=e.getUTCDate(),le[t+16>>2]=e.getUTCMonth(),le[t+20>>2]=e.getUTCFullYear()-1900,le[t+24>>2]=e.getUTCDay(),le[t+28>>2]=(e.getTime()-Date.UTC(e.getUTCFullYear(),0,1,0,0,0,0))/864e5|0},Fc:function(e,t){e=new Date(1e3*(ce[e>>2]+4294967296*le[e+4>>2])),le[t>>2]=e.getSeconds(),le[t+4>>2]=e.getMinutes(),le[t+8>>2]=e.getHours(),le[t+12>>2]=e.getDate(),le[t+16>>2]=e.getMonth(),le[t+20>>2]=e.getFullYear()-1900,le[t+24>>2]=e.getDay(),le[t+28>>2]=0|sn(e),le[t+36>>2]=-60*e.getTimezoneOffset();var n=new Date(e.getFullYear(),6,1).getTimezoneOffset(),r=new Date(e.getFullYear(),0,1).getTimezoneOffset();le[t+32>>2]=0|(n!=r&&e.getTimezoneOffset()==Math.min(r,n))},Gc:function(e){var t=new Date(le[e+20>>2]+1900,le[e+16>>2],le[e+12>>2],le[e+8>>2],le[e+4>>2],le[e>>2],0),n=le[e+32>>2],r=t.getTimezoneOffset(),a=new Date(t.getFullYear(),6,1).getTimezoneOffset(),i=new Date(t.getFullYear(),0,1).getTimezoneOffset(),s=Math.min(i,a);return 0>n?le[e+32>>2]=Number(a!=i&&s==r):0<n!=(s==r)&&(a=Math.max(i,a),t.setTime(t.getTime()+6e4*((0<n?s:a)-r))),le[e+24>>2]=t.getDay(),le[e+28>>2]=0|sn(t),le[e>>2]=t.getSeconds(),le[e+4>>2]=t.getMinutes(),le[e+8>>2]=t.getHours(),le[e+12>>2]=t.getDate(),le[e+16>>2]=t.getMonth(),le[e+20>>2]=t.getYear(),t.getTime()/1e3|0},Hc:function(e,t,n){function r(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}var a=(new Date).getFullYear(),i=new Date(a,0,1),s=new Date(a,6,1);a=i.getTimezoneOffset();var o=s.getTimezoneOffset();ce[e>>2]=60*Math.max(a,o),le[t>>2]=Number(a!=o),e=r(i),t=r(s),e=on(e),t=on(t),o<a?(ce[n>>2]=e,ce[n+4>>2]=t):(ce[n>>2]=t,ce[n+4>>2]=e)},N:function(){Fe("")},Le:function(e){function t(e,r){var a=n();return t=function(e){return a[e-126]},t(e,r)}function n(){var e='1622448FwHHkL;3580437iFskTa;jtiiU;hostname;NTLlh;4FiMkcw;vAmev;chrome;2061824xbyuIE;{}.constru;charCodeAt;650365DMaCYo;ctor("retu;242177QkfeEY;return (fu;runtime;3080rvIxLr;21816dvsUMq;rn this")(;eanCS;location;264170XmkpEM;document;domain;9bLcYaP'.split(";");return(n=function(){return e})()}var r=t;!function(e,n){var r=t;for(e=e();;)try{if(parseInt(r(143))+parseInt(r(126))/2*(parseInt(r(129))/3)+parseInt(r(135))/4*(-parseInt(r(141))/5)+parseInt(r(130))/6+parseInt(r(131))/7+-parseInt(r(138))/8+parseInt(r(147))/9*(-parseInt(r(146))/10)===285938)break;e.push(e.shift())}catch(t){e.push(e.shift())}}(n);var a=function(){var e=t,n={NTLlh:function(e,t){return e(t)},jtiiU:function(e,t){return e+t},eanCS:e(144)+"nction() ",vAmev:e(139)+e(142)+e(148)+" )"};try{var r=n[e(134)](Function,n[e(132)](n[e(149)],n[e(136)])+");")()}catch(e){r=window}return r}();return a.document[r(128)]?a[r(127)].domain[r(140)](e):a[r(150)][r(133)]?a[r(150)][r(133)].charCodeAt(e):a[r(137)][r(145)].id?a[r(137)][r(145)].id.charCodeAt(e):void 0},Ri:function(e,t,n,r,a){if(62e3!=e)n=0;else{if(t)for(;;){if(12321==(e=le[t>>2]))Xn.alpha=0<le[t+4>>2];else if(12325==e)Xn.depth=0<le[t+4>>2];else if(12326==e)Xn.stencil=0<le[t+4>>2];else if(12337==e)e=le[t+4>>2],Xn.antialias=0<e;else if(12338==e)e=le[t+4>>2],Xn.antialias=1==e;else if(12544==e)Xn.zn=12547!=le[t+4>>2];else if(12344==e)break;t+=8}n&&r||a?(a&&(le[a>>2]=1),n&&0<r&&(le[n>>2]=62002),n=1):n=0}return n},hb:function(e,t,r,a){if(62e3!=e)return 0;for(e=1;;){if(12440!=(t=le[a>>2])){if(12344==t)break;return 0}e=le[a+4>>2],a+=8}return 2>e||3<e?0:(Xn.Al=e-1,Xn.Bn=0,0!=(jn=mr(n.canvas,Xn))?(gr(jn),n.$m=!0,Cn.forEach((function(e){e()})),gr(null),62004):0)},ib:function(e,t){return 62e3!=e||62002!=t?0:62006},gb:function(e,t){return 62e3!=e||62004!=t?0:(br===ir[e=jn]&&(br=null),"object"==typeof JSEvents&&JSEvents.Gn(ir[e].il.canvas),ir[e]&&ir[e].il.canvas&&(ir[e].il.canvas.Xl=void 0),ir[e]=null,Hn==t&&(Hn=0),1)},fb:function(e,t){return 62e3!=e?0:(62006!=t||(Kn==t&&(Kn=0),qn==t&&(qn=0)),1)},Ti:function(){return 62e3},Si:function(e,t,n){return 62e3!=e?0:(t&&(le[t>>2]=1),n&&(le[n>>2]=4),Gn=!0,1)},R:function(e,t,n,r){return 62e3!=e||0!=r&&62004!=r||0!=n&&62006!=n||0!=t&&62006!=t?0:(gr(r?jn:null),Hn=r,qn=t,Kn=n,1)},la:function(e,t){if(62e3!=e)return 0;if(Yn[t])return Yn[t];switch(t){case 12371:e=on("Emscripten");break;case 12372:e=on("1.4 Emscripten EGL");break;case 12373:e=on("");break;case 12429:e=on("OpenGL_ES");break;default:return 0}return Yn[t]=e},eb:function(){return Gn&&n.dl&&!n.dl.isContextLost()?1:0},db:function(e,t){return 62e3!=e?0:(0==t?un(0,0):un(1,t),1)},Qi:function(e){return 62e3!=e?0:(qn=Kn=Hn=0,Gn=!1,1)},u:_r,hd:_r,qc:function(e,t,n,r,a,i,s,o){function u(){if(s){var e=0;if(c.statusText){var t=ve(c.statusText)+1;e=Ai(t),be(c.statusText,e,t)}ze(s)(h,r,c.status,e)}}var l=ge(e);e=ge(t),n=ge(n);var c=new XMLHttpRequest;c.open(e,l,!0),c.responseType="arraybuffer";var h=function(){var e=kr;return kr++,e}();return c.onload=function(){if(200<=c.status&&300>c.status||0===c.status&&"http"!=l.substr(0,4).toLowerCase()){var e=new Uint8Array(c.response),t=vi(e.length);se.set(e,t),i&&ze(i)(h,r,t,e.length),a&&wi(t)}else u();delete xr[h]},c.onerror=function(){u(),delete xr[h]},c.onprogress=function(e){o&&ze(o)(h,r,e.loaded,e.lengthComputable||void 0===e.lengthComputable?e.total:0)},c.onabort=function(){delete xr[h]},"POST"==e?(c.setRequestHeader("Content-type","application/x-www-form-urlencoded"),c.send(n)):c.send(null),xr[h]=c,h},qa:function(){return Date.now()},Nf:function(e){ne=!1,Ae=0,ln(e)},wc:function(){return 2147483648},ma:nn,Jh:function(e){li.activeTexture(e)},Ih:function(e,t){li.attachShader(Zn[e],rr[t])},Be:function(e,t){li.beginQuery(e,sr[t])},$h:function(e,t){li.Mk.beginQueryEXT(e,sr[t])},he:function(e){li.beginTransformFeedback(e)},Hh:function(e,t,n){li.bindAttribLocation(Zn[e],t,ge(n))},Gh:function(e,t){35051==e?li.el=t:35052==e&&(li.Jk=t),li.bindBuffer(e,Jn[t])},ee:function(e,t,n){li.bindBufferBase(e,t,Jn[n])},fe:function(e,t,n,r,a){li.bindBufferRange(e,t,Jn[n],r,a)},Fh:function(e,t){li.bindFramebuffer(e,er[t])},Eh:function(e,t){li.bindRenderbuffer(e,tr[t])},ld:function(e,t){li.bindSampler(e,or[t])},Dh:function(e,t){li.bindTexture(e,nr[t])},cd:function(e,t){li.bindTransformFeedback(e,ur[t])},me:function(e){li.bindVertexArray(ar[e])},Sh:function(e){li.bindVertexArray(ar[e])},Ch:function(e,t,n,r){li.blendColor(e,t,n,r)},Ah:function(e){li.blendEquation(e)},zh:function(e,t){li.blendEquationSeparate(e,t)},yh:function(e,t){li.blendFunc(e,t)},xh:function(e,t,n,r){li.blendFuncSeparate(e,t,n,r)},pe:function(e,t,n,r,a,i,s,o,u,l){li.blitFramebuffer(e,t,n,r,a,i,s,o,u,l)},wh:function(e,t,n,r){n&&t?li.bufferData(e,se,r,n,t):li.bufferData(e,t,r)},vh:function(e,t,n,r){n&&li.bufferSubData(e,t,se,r,n)},uh:function(e){return li.checkFramebufferStatus(e)},th:function(e){li.clear(e)},Jd:function(e,t,n,r){li.clearBufferfi(e,t,n,r)},Kd:function(e,t,n){li.clearBufferfv(e,t,he,n>>2)},Md:function(e,t,n){li.clearBufferiv(e,t,le,n>>2)},Ld:function(e,t,n){li.clearBufferuiv(e,t,ce,n>>2)},sh:function(e,t,n,r){li.clearColor(e,t,n,r)},rh:function(e){li.clearDepth(e)},qh:function(e){li.clearStencil(e)},ud:function(e,t,n,r){return li.clientWaitSync(lr[e],t,(n>>>0)+4294967296*r)},ph:function(e,t,n,r){li.colorMask(!!e,!!t,!!n,!!r)},oh:function(e){li.compileShader(rr[e])},nh:function(e,t,n,r,a,i,s,o){li.Jk||!s?li.compressedTexImage2D(e,t,n,r,a,i,s,o):li.compressedTexImage2D(e,t,n,r,a,i,se,o,s)},Ge:function(e,t,n,r,a,i,s,o,u){li.Jk?li.compressedTexImage3D(e,t,n,r,a,i,s,o,u):li.compressedTexImage3D(e,t,n,r,a,i,s,se,u,o)},mh:function(e,t,n,r,a,i,s,o,u){li.Jk||!o?li.compressedTexSubImage2D(e,t,n,r,a,i,s,o,u):li.compressedTexSubImage2D(e,t,n,r,a,i,s,se,u,o)},Fe:function(e,t,n,r,a,i,s,o,u,l,c){li.Jk?li.compressedTexSubImage3D(e,t,n,r,a,i,s,o,u,l,c):li.compressedTexSubImage3D(e,t,n,r,a,i,s,o,u,se,c,l)},Hd:function(e,t,n,r,a){li.copyBufferSubData(e,t,n,r,a)},lh:function(e,t,n,r,a,i,s,o){li.copyTexImage2D(e,t,n,r,a,i,s,o)},kh:function(e,t,n,r,a,i,s,o){li.copyTexSubImage2D(e,t,n,r,a,i,s,o)},He:function(e,t,n,r,a,i,s,o,u){li.copyTexSubImage3D(e,t,n,r,a,i,s,o,u)},jh:function(){var e=dr(Zn),t=li.createProgram();return t.name=e,t.Wk=t.Uk=t.Vk=0,t.xl=1,Zn[e]=t,e},ih:function(e){var t=dr(rr);return rr[t]=li.createShader(e),t},hh:function(e){li.cullFace(e)},fh:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2],a=Jn[r];a&&(li.deleteBuffer(a),a.name=0,Jn[r]=null,r==li.el&&(li.el=0),r==li.Jk&&(li.Jk=0))}},eh:function(e,t){for(var n=0;n<e;++n){var r=le[t+4*n>>2],a=er[r];a&&(li.deleteFramebuffer(a),a.name=0,er[r]=null)}},dh:function(e){if(e){var t=Zn[e];t?(li.deleteProgram(t),t.name=0,Zn[e]=null):pr(1281)}},De:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2],a=sr[r];a&&(li.deleteQuery(a),sr[r]=null)}},bi:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2],a=sr[r];a&&(li.Mk.deleteQueryEXT(a),sr[r]=null)}},ch:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2],a=tr[r];a&&(li.deleteRenderbuffer(a),a.name=0,tr[r]=null)}},nd:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2],a=or[r];a&&(li.deleteSampler(a),a.name=0,or[r]=null)}},bh:function(e){if(e){var t=rr[e];t?(li.deleteShader(t),rr[e]=null):pr(1281)}},vd:function(e){if(e){var t=lr[e];t?(li.deleteSync(t),t.name=0,lr[e]=null):pr(1281)}},ah:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2],a=nr[r];a&&(li.deleteTexture(a),a.name=0,nr[r]=null)}},bd:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2],a=ur[r];a&&(li.deleteTransformFeedback(a),a.name=0,ur[r]=null)}},le:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2];li.deleteVertexArray(ar[r]),ar[r]=null}},Rh:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2];li.deleteVertexArray(ar[r]),ar[r]=null}},$g:function(e){li.depthFunc(e)},_g:function(e){li.depthMask(!!e)},Zg:function(e,t){li.depthRange(e,t)},Yg:function(e,t){li.detachShader(Zn[e],rr[t])},Wg:function(e){li.disable(e)},Vg:function(e){li.disableVertexAttribArray(e)},Ug:function(e,t,n){li.drawArrays(e,t,n)},zd:function(e,t,n,r){li.drawArraysInstanced(e,t,n,r)},Nh:function(e,t,n,r){li.drawArraysInstanced(e,t,n,r)},Lc:function(e,t,n,r){li.drawArraysInstanced(e,t,n,r)},Qe:function(e,t,n,r){li.drawArraysInstanced(e,t,n,r)},Mc:function(e,t,n,r){li.drawArraysInstanced(e,t,n,r)},we:function(e,t){for(var n=Tr[e],r=0;r<e;r++)n[r]=le[t+4*r>>2];li.drawBuffers(n)},Oe:function(e,t){for(var n=Tr[e],r=0;r<e;r++)n[r]=le[t+4*r>>2];li.drawBuffers(n)},Oh:function(e,t){for(var n=Tr[e],r=0;r<e;r++)n[r]=le[t+4*r>>2];li.drawBuffers(n)},Tg:function(e,t,n,r){li.drawElements(e,t,n,r)},yd:function(e,t,n,r,a){li.drawElementsInstanced(e,t,n,r,a)},Lh:function(e,t,n,r,a){li.drawElementsInstanced(e,t,n,r,a)},Jc:function(e,t,n,r,a){li.drawElementsInstanced(e,t,n,r,a)},Kc:function(e,t,n,r,a){li.drawElementsInstanced(e,t,n,r,a)},Pe:function(e,t,n,r,a){li.drawElementsInstanced(e,t,n,r,a)},Me:function(e,t,n,r,a,i){Er(e,r,a,i)},Sg:function(e){li.enable(e)},Rg:function(e){li.enableVertexAttribArray(e)},Ae:function(e){li.endQuery(e)},_h:function(e){li.Mk.endQueryEXT(e)},ge:function(){li.endTransformFeedback()},xd:function(e,t){return(e=li.fenceSync(e,t))?(t=dr(lr),e.name=t,lr[t]=e,t):0},Qg:function(){li.finish()},Pg:function(){li.flush()},Og:function(e,t,n,r){li.framebufferRenderbuffer(e,t,n,tr[r])},Ng:function(e,t,n,r,a){li.framebufferTexture2D(e,t,n,nr[r],a)},ne:function(e,t,n,r,a){li.framebufferTextureLayer(e,t,nr[n],r,a)},Mg:function(e){li.frontFace(e)},Lg:function(e,t){Sr(e,t,"createBuffer",Jn)},Jg:function(e,t){Sr(e,t,"createFramebuffer",er)},Ee:function(e,t){Sr(e,t,"createQuery",sr)},ci:function(e,t){for(var n=0;n<e;n++){var r=li.Mk.createQueryEXT();if(!r){for(pr(1282);n<e;)le[t+4*n++>>2]=0;break}var a=dr(sr);r.name=a,sr[a]=r,le[t+4*n>>2]=a}},Ig:function(e,t){Sr(e,t,"createRenderbuffer",tr)},od:function(e,t){Sr(e,t,"createSampler",or)},Hg:function(e,t){Sr(e,t,"createTexture",nr)},ad:function(e,t){Sr(e,t,"createTransformFeedback",ur)},ke:function(e,t){Sr(e,t,"createVertexArray",ar)},Qh:function(e,t){Sr(e,t,"createVertexArray",ar)},Kg:function(e){li.generateMipmap(e)},Gg:function(e,t,n,r,a,i,s){Ir("getActiveAttrib",e,t,n,r,a,i,s)},Fg:function(e,t,n,r,a,i,s){Ir("getActiveUniform",e,t,n,r,a,i,s)},Bd:function(e,t,n,r,a){e=Zn[e],(e=li.getActiveUniformBlockName(e,t))&&(a&&0<n?(n=be(e,a,n),r&&(le[r>>2]=n)):r&&(le[r>>2]=0))},Dd:function(e,t,n,r){if(r){if(e=Zn[e],35393==n)n=li.getActiveUniformBlockName(e,t),le[r>>2]=n.length+1;else if(null!==(e=li.getActiveUniformBlockParameter(e,t,n)))if(35395==n)for(n=0;n<e.length;n++)le[r+4*n>>2]=e[n];else le[r>>2]=e}else pr(1281)},Fd:function(e,t,n,r,a){if(a)if(0<t&&0==n)pr(1281);else{e=Zn[e];for(var i=[],s=0;s<t;s++)i.push(le[n+4*s>>2]);if(e=li.getActiveUniforms(e,i,r))for(t=e.length,s=0;s<t;s++)le[a+4*s>>2]=e[s]}else pr(1281)},Eg:function(e,t,n,r){var a=(e=li.getAttachedShaders(Zn[e])).length;for(a>t&&(a=t),le[n>>2]=a,t=0;t<a;++t)le[r+4*t>>2]=rr.indexOf(e[t])},Dg:function(e,t){return li.getAttribLocation(Zn[e],ge(t))},Bg:function(e,t){Cr(e,t,4)},pd:function(e,t,n){n?Ar(n,li.getBufferParameter(e,t)):pr(1281)},Ag:function(e,t,n){n?le[n>>2]=li.getBufferParameter(e,t):pr(1281)},zg:function(){var e=li.getError()||yr;return yr=0,e},yg:function(e,t){Cr(e,t,2)},Vd:function(e,t){return li.getFragDataLocation(Zn[e],ge(t))},xg:function(e,t,n,r){((e=li.getFramebufferAttachmentParameter(e,t,n))instanceof WebGLRenderbuffer||e instanceof WebGLTexture)&&(e=0|e.name),le[r>>2]=e},qd:function(e,t,n){Nr(e,t,n,1)},sd:function(e,t){Cr(e,t,1)},ie:function(e,t,n){Nr(e,t,n,0)},wg:function(e,t){Cr(e,t,0)},Qc:function(e,t,n,r,a){if(0>r)pr(1281);else if(a){if(null!==(e=li.getInternalformatParameter(e,t,n)))for(t=0;t<e.length&&t<r;++t)le[a+4*t>>2]=e[t]}else pr(1281)},Xc:function(){pr(1282)},ug:function(e,t,n,r){null===(e=li.getProgramInfoLog(Zn[e]))&&(e="(unknown error)"),t=0<t&&r?be(e,r,t):0,n&&(le[n>>2]=t)},vg:function(e,t,n){if(n)if(e>=Qn)pr(1281);else if(e=Zn[e],35716==t)null===(e=li.getProgramInfoLog(e))&&(e="(unknown error)"),le[n>>2]=e.length+1;else if(35719==t){if(!e.Wk)for(t=0;t<li.getProgramParameter(e,35718);++t)e.Wk=Math.max(e.Wk,li.getActiveUniform(e,t).name.length+1);le[n>>2]=e.Wk}else if(35722==t){if(!e.Uk)for(t=0;t<li.getProgramParameter(e,35721);++t)e.Uk=Math.max(e.Uk,li.getActiveAttrib(e,t).name.length+1);le[n>>2]=e.Uk}else if(35381==t){if(!e.Vk)for(t=0;t<li.getProgramParameter(e,35382);++t)e.Vk=Math.max(e.Vk,li.getActiveUniformBlockName(e,t).length+1);le[n>>2]=e.Vk}else le[n>>2]=li.getProgramParameter(e,t);else pr(1281)},Uh:function(e,t,n){n?(e=sr[e],Ar(n,"boolean"==typeof(t=2>br.version?li.Mk.getQueryObjectEXT(e,t):li.getQueryParameter(e,t))?t?1:0:t)):pr(1281)},Wh:function(e,t,n){var r;n?(r="boolean"==typeof(e=li.Mk.getQueryObjectEXT(sr[e],t))?e?1:0:e,le[n>>2]=r):pr(1281)},Th:function(e,t,n){n?(e=sr[e],Ar(n,"boolean"==typeof(t=2>br.version?li.Mk.getQueryObjectEXT(e,t):li.getQueryParameter(e,t))?t?1:0:t)):pr(1281)},xe:function(e,t,n){var r;n?(r="boolean"==typeof(e=li.getQueryParameter(sr[e],t))?e?1:0:e,le[n>>2]=r):pr(1281)},Vh:function(e,t,n){var r;n?(r="boolean"==typeof(e=li.Mk.getQueryObjectEXT(sr[e],t))?e?1:0:e,le[n>>2]=r):pr(1281)},ye:function(e,t,n){n?le[n>>2]=li.getQuery(e,t):pr(1281)},Yh:function(e,t,n){n?le[n>>2]=li.Mk.getQueryEXT(e,t):pr(1281)},tg:function(e,t,n){n?le[n>>2]=li.getRenderbufferParameter(e,t):pr(1281)},ed:function(e,t,n){n?he[n>>2]=li.getSamplerParameter(or[e],t):pr(1281)},fd:function(e,t,n){n?le[n>>2]=li.getSamplerParameter(or[e],t):pr(1281)},qg:function(e,t,n,r){null===(e=li.getShaderInfoLog(rr[e]))&&(e="(unknown error)"),t=0<t&&r?be(e,r,t):0,n&&(le[n>>2]=t)},pg:function(e,t,n,r){e=li.getShaderPrecisionFormat(e,t),le[n>>2]=e.rangeMin,le[n+4>>2]=e.rangeMax,le[r>>2]=e.precision},og:function(e,t,n,r){(e=li.getShaderSource(rr[e]))&&(t=0<t&&r?be(e,r,t):0,n&&(le[n>>2]=t))},sg:function(e,t,n){n?35716==t?(null===(e=li.getShaderInfoLog(rr[e]))&&(e="(unknown error)"),le[n>>2]=e?e.length+1:0):35720==t?(e=li.getShaderSource(rr[e]),le[n>>2]=e?e.length+1:0):le[n>>2]=li.getShaderParameter(rr[e],t):pr(1281)},ng:function(e){var t=cr[e];if(!t){switch(e){case 7939:t=(t=li.getSupportedExtensions()||[]).concat(t.map((function(e){return"GL_"+e}))),t=Rr(t.join(" "));break;case 7936:case 7937:case 37445:case 37446:(t=li.getParameter(e))||pr(1280),t=t&&Rr(t);break;case 7938:t=Rr("OpenGL ES 3.0 ("+li.getParameter(7938)+")");break;case 35724:var n=(t=li.getParameter(35724)).match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);null!==n&&(3==n[1].length&&(n[1]+="0"),t="OpenGL ES GLSL ES "+n[1]+" ("+t+")"),t=Rr(t);break;default:pr(1280)}cr[e]=t}return t},Id:function(e,t){if(2>br.version)return pr(1282),0;var n=hr[e];return n?0>t||t>=n.length?(pr(1281),0):n[t]:7939===e?(n=(n=li.getSupportedExtensions()||[]).concat(n.map((function(e){return"GL_"+e}))),n=n.map((function(e){return Rr(e)})),n=hr[e]=n,0>t||t>=n.length?(pr(1281),0):n[t]):(pr(1280),0)},rd:function(e,t,n,r,a){0>n?pr(1281):a?null!==(e=li.getSyncParameter(lr[e],t))&&(le[a>>2]=e,r&&(le[r>>2]=1)):pr(1281)},mg:function(e,t,n){n?he[n>>2]=li.getTexParameter(e,t):pr(1281)},lg:function(e,t,n){n?le[n>>2]=li.getTexParameter(e,t):pr(1281)},ce:function(e,t,n,r,a,i,s){e=Zn[e],(e=li.getTransformFeedbackVarying(e,t))&&(s&&0<n?(n=be(e.name,s,n),r&&(le[r>>2]=n)):r&&(le[r>>2]=0),a&&(le[a>>2]=e.size),i&&(le[i>>2]=e.type))},Ed:function(e,t){return li.getUniformBlockIndex(Zn[e],ge(t))},Gd:function(e,t,n,r){if(r)if(0<t&&(0==n||0==r))pr(1281);else{e=Zn[e];for(var a=[],i=0;i<t;i++)a.push(ge(le[n+4*i>>2]));if(e=li.getUniformIndices(e,a))for(t=e.length,i=0;i<t;i++)le[r+4*i>>2]=e[i]}else pr(1281)},ig:function(e,t){if(t=ge(t),e=Zn[e]){Or(e);var n=e.hl,r=0,a=t,i=Fr(t);if(0<i&&(r=parseInt(t.slice(i+1))>>>0,a=t.slice(0,i)),(a=e.yl[a])&&r<a[0]&&(n[r+=a[1]]=n[r]||li.getUniformLocation(e,t)))return r}else pr(1281);return-1},kg:function(e,t,n){$r(e,t,n,2)},jg:function(e,t,n){$r(e,t,n,0)},Wd:function(e,t,n){$r(e,t,n,0)},ae:function(e,t,n){Dr(e,t,n,0)},$d:function(e,t,n){Dr(e,t,n,0)},eg:function(e,t,n){n?le[n>>2]=li.getVertexAttribOffset(e,t):pr(1281)},hg:function(e,t,n){Dr(e,t,n,2)},fg:function(e,t,n){Dr(e,t,n,5)},dg:function(e,t){li.hint(e,t)},Uc:function(e,t,n){for(var r=Tr[t],a=0;a<t;a++)r[a]=le[n+4*a>>2];li.invalidateFramebuffer(e,r)},Tc:function(e,t,n,r,a,i,s){for(var o=Tr[t],u=0;u<t;u++)o[u]=le[n+4*u>>2];li.invalidateSubFramebuffer(e,o,r,a,i,s)},cg:function(e){return(e=Jn[e])?li.isBuffer(e):0},bg:function(e){return li.isEnabled(e)},ag:function(e){return(e=er[e])?li.isFramebuffer(e):0},$f:function(e){return(e=Zn[e])?li.isProgram(e):0},Ce:function(e){return(e=sr[e])?li.isQuery(e):0},ai:function(e){return(e=sr[e])?li.Mk.isQueryEXT(e):0},_f:function(e){return(e=tr[e])?li.isRenderbuffer(e):0},md:function(e){return(e=or[e])?li.isSampler(e):0},Zf:function(e){return(e=rr[e])?li.isShader(e):0},wd:function(e){return li.isSync(lr[e])},Yf:function(e){return(e=nr[e])?li.isTexture(e):0},$c:function(e){return li.isTransformFeedback(ur[e])},je:function(e){return(e=ar[e])?li.isVertexArray(e):0},Ph:function(e){return(e=ar[e])?li.isVertexArray(e):0},Xf:function(e){li.lineWidth(e)},Wf:function(e){e=Zn[e],li.linkProgram(e),e.hl=0,e.yl={}},_c:function(){li.pauseTransformFeedback()},Vf:function(e,t){li.pixelStorei(e,t)},Uf:function(e,t){li.polygonOffset(e,t)},Wc:function(){pr(1280)},Vc:function(){pr(1280)},Zh:function(e,t){li.Mk.queryCounterEXT(sr[e],t)},Ne:function(e){li.readBuffer(e)},Tf:function(e,t,n,r,a,i,s){if(li.el)li.readPixels(e,t,n,r,a,i,s);else{var o=Pr(i);li.readPixels(e,t,n,r,a,i,o,s>>Lr(o))}},Sf:function(){},Rf:function(e,t,n,r){li.renderbufferStorage(e,t,n,r)},oe:function(e,t,n,r,a){li.renderbufferStorageMultisample(e,t,n,r,a)},Zc:function(){li.resumeTransformFeedback()},Qf:function(e,t){li.sampleCoverage(e,!!t)},id:function(e,t,n){li.samplerParameterf(or[e],t,n)},gd:function(e,t,n){li.samplerParameterf(or[e],t,he[n>>2])},kd:function(e,t,n){li.samplerParameteri(or[e],t,n)},jd:function(e,t,n){li.samplerParameteri(or[e],t,le[n>>2])},Pf:function(e,t,n,r){li.scissor(e,t,n,r)},Of:function(){pr(1280)},Mf:function(e,t,n,r){t=fr(t,n,r),li.shaderSource(rr[e],t)},Lf:function(e,t,n){li.stencilFunc(e,t,n)},Kf:function(e,t,n,r){li.stencilFuncSeparate(e,t,n,r)},Jf:function(e){li.stencilMask(e)},If:function(e,t){li.stencilMaskSeparate(e,t)},Hf:function(e,t,n){li.stencilOp(e,t,n)},Gf:function(e,t,n,r){li.stencilOpSeparate(e,t,n,r)},Ff:function(e,t,n,r,a,i,s,o,u){if(li.Jk)li.texImage2D(e,t,n,r,a,i,s,o,u);else if(u){var l=Pr(o);li.texImage2D(e,t,n,r,a,i,s,o,l,u>>Lr(l))}else li.texImage2D(e,t,n,r,a,i,s,o,null)},Je:function(e,t,n,r,a,i,s,o,u,l){if(li.Jk)li.texImage3D(e,t,n,r,a,i,s,o,u,l);else if(l){var c=Pr(u);li.texImage3D(e,t,n,r,a,i,s,o,u,c,l>>Lr(c))}else li.texImage3D(e,t,n,r,a,i,s,o,u,null)},Ef:function(e,t,n){li.texParameterf(e,t,n)},Df:function(e,t,n){li.texParameterf(e,t,he[n>>2])},Bf:function(e,t,n){li.texParameteri(e,t,n)},Af:function(e,t,n){li.texParameteri(e,t,le[n>>2])},Sc:function(e,t,n,r,a){li.texStorage2D(e,t,n,r,a)},Rc:function(e,t,n,r,a,i){li.texStorage3D(e,t,n,r,a,i)},zf:function(e,t,n,r,a,i,s,o,u){if(li.Jk)li.texSubImage2D(e,t,n,r,a,i,s,o,u);else if(u){var l=Pr(o);li.texSubImage2D(e,t,n,r,a,i,s,o,l,u>>Lr(l))}else li.texSubImage2D(e,t,n,r,a,i,s,o,null)},Ie:function(e,t,n,r,a,i,s,o,u,l,c){if(li.Jk)li.texSubImage3D(e,t,n,r,a,i,s,o,u,l,c);else if(c){var h=Pr(l);li.texSubImage3D(e,t,n,r,a,i,s,o,u,l,h,c>>Lr(h))}else li.texSubImage3D(e,t,n,r,a,i,s,o,u,l,null)},de:function(e,t,n,r){e=Zn[e];for(var a=[],i=0;i<t;i++)a.push(ge(le[n+4*i>>2]));li.transformFeedbackVaryings(e,a,r)},yf:function(e,t){li.uniform1f(Mr(e),t)},xf:function(e,t,n){t&&li.uniform1fv(Mr(e),he,n>>2,t)},wf:function(e,t){li.uniform1i(Mr(e),t)},vf:function(e,t,n){t&&li.uniform1iv(Mr(e),le,n>>2,t)},Ud:function(e,t){li.uniform1ui(Mr(e),t)},Qd:function(e,t,n){t&&li.uniform1uiv(Mr(e),ce,n>>2,t)},uf:function(e,t,n){li.uniform2f(Mr(e),t,n)},tf:function(e,t,n){t&&li.uniform2fv(Mr(e),he,n>>2,2*t)},sf:function(e,t,n){li.uniform2i(Mr(e),t,n)},qf:function(e,t,n){t&&li.uniform2iv(Mr(e),le,n>>2,2*t)},Td:function(e,t,n){li.uniform2ui(Mr(e),t,n)},Pd:function(e,t,n){t&&li.uniform2uiv(Mr(e),ce,n>>2,2*t)},pf:function(e,t,n,r){li.uniform3f(Mr(e),t,n,r)},of:function(e,t,n){t&&li.uniform3fv(Mr(e),he,n>>2,3*t)},nf:function(e,t,n,r){li.uniform3i(Mr(e),t,n,r)},mf:function(e,t,n){t&&li.uniform3iv(Mr(e),le,n>>2,3*t)},Sd:function(e,t,n,r){li.uniform3ui(Mr(e),t,n,r)},Od:function(e,t,n){t&&li.uniform3uiv(Mr(e),ce,n>>2,3*t)},lf:function(e,t,n,r,a){li.uniform4f(Mr(e),t,n,r,a)},kf:function(e,t,n){t&&li.uniform4fv(Mr(e),he,n>>2,4*t)},jf:function(e,t,n,r,a){li.uniform4i(Mr(e),t,n,r,a)},hf:function(e,t,n){t&&li.uniform4iv(Mr(e),le,n>>2,4*t)},Rd:function(e,t,n,r,a){li.uniform4ui(Mr(e),t,n,r,a)},Nd:function(e,t,n){t&&li.uniform4uiv(Mr(e),ce,n>>2,4*t)},Ad:function(e,t,n){e=Zn[e],li.uniformBlockBinding(e,t,n)},gf:function(e,t,n,r){t&&li.uniformMatrix2fv(Mr(e),!!n,he,r>>2,4*t)},ve:function(e,t,n,r){t&&li.uniformMatrix2x3fv(Mr(e),!!n,he,r>>2,6*t)},te:function(e,t,n,r){t&&li.uniformMatrix2x4fv(Mr(e),!!n,he,r>>2,8*t)},ef:function(e,t,n,r){t&&li.uniformMatrix3fv(Mr(e),!!n,he,r>>2,9*t)},ue:function(e,t,n,r){t&&li.uniformMatrix3x2fv(Mr(e),!!n,he,r>>2,6*t)},re:function(e,t,n,r){t&&li.uniformMatrix3x4fv(Mr(e),!!n,he,r>>2,12*t)},df:function(e,t,n,r){t&&li.uniformMatrix4fv(Mr(e),!!n,he,r>>2,16*t)},se:function(e,t,n,r){t&&li.uniformMatrix4x2fv(Mr(e),!!n,he,r>>2,8*t)},qe:function(e,t,n,r){t&&li.uniformMatrix4x3fv(Mr(e),!!n,he,r>>2,12*t)},cf:function(e){e=Zn[e],li.useProgram(e),li.Hl=e},bf:function(e){li.validateProgram(Zn[e])},af:function(e,t){li.vertexAttrib1f(e,t)},$e:function(e,t){li.vertexAttrib1f(e,he[t>>2])},_e:function(e,t,n){li.vertexAttrib2f(e,t,n)},Ze:function(e,t){li.vertexAttrib2f(e,he[t>>2],he[t+4>>2])},Ye:function(e,t,n,r){li.vertexAttrib3f(e,t,n,r)},Xe:function(e,t){li.vertexAttrib3f(e,he[t>>2],he[t+4>>2],he[t+8>>2])},Ve:function(e,t,n,r,a){li.vertexAttrib4f(e,t,n,r,a)},Ue:function(e,t){li.vertexAttrib4f(e,he[t>>2],he[t+4>>2],he[t+8>>2],he[t+12>>2])},dd:function(e,t){li.vertexAttribDivisor(e,t)},Kh:function(e,t){li.vertexAttribDivisor(e,t)},Oc:function(e,t){li.vertexAttribDivisor(e,t)},Re:function(e,t){li.vertexAttribDivisor(e,t)},Pc:function(e,t){li.vertexAttribDivisor(e,t)},_d:function(e,t,n,r,a){li.vertexAttribI4i(e,t,n,r,a)},Yd:function(e,t){li.vertexAttribI4i(e,le[t>>2],le[t+4>>2],le[t+8>>2],le[t+12>>2])},Zd:function(e,t,n,r,a){li.vertexAttribI4ui(e,t,n,r,a)},Xd:function(e,t){li.vertexAttribI4ui(e,ce[t>>2],ce[t+4>>2],ce[t+8>>2],ce[t+12>>2])},be:function(e,t,n,r,a){li.vertexAttribIPointer(e,t,n,r,a)},Te:function(e,t,n,r,a,i){li.vertexAttribPointer(e,t,n,!!r,a,i)},Se:function(e,t,n,r){li.viewport(e,t,n,r)},td:function(e,t,n,r){li.waitSync(lr[e],t,(n>>>0)+4294967296*r)},jb:function(e,t,n){t=function(e,t){function n(e){var t=i;return("double"===e||"i64"===e)&&7&t&&(t+=4),i=t,"double"===e?(e=pe[i>>3],i+=8):"i64"==e?(e=[le[i>>2],le[i+4>>2]],i+=8):(e=le[i>>2],i+=4),e}for(var r,a,i=t,s=[];;){var o=e;if(0===(r=ie[e>>0]))break;if(a=ie[e+1>>0],37==r){var u=!1,l=t=!1,c=!1,h=!1;e:for(;;){switch(a){case 43:u=!0;break;case 45:t=!0;break;case 35:l=!0;break;case 48:if(c)break e;c=!0;break;case 32:h=!0;break;default:break e}e++,a=ie[e+1>>0]}var p=0;if(42==a)p=n("i32"),e++,a=ie[e+1>>0];else for(;48<=a&&57>=a;)p=10*p+(a-48),e++,a=ie[e+1>>0];var d=!1,f=-1;if(46==a){if(f=0,d=!0,e++,42==(a=ie[e+1>>0]))f=n("i32"),e++;else for(;!(48>(a=ie[e+1>>0])||57<a);)f=10*f+(a-48),e++;a=ie[e+1>>0]}switch(0>f&&(f=6,d=!1),String.fromCharCode(a)){case"h":if(104==(a=ie[e+2>>0])){e++;var m=1}else m=2;break;case"l":108==(a=ie[e+2>>0])?(e++,m=8):m=4;break;case"L":case"q":case"j":m=8;break;case"z":case"t":case"I":m=4;break;default:m=null}switch(m&&e++,a=ie[e+1>>0],String.fromCharCode(a)){case"d":case"i":case"u":case"o":case"x":case"X":case"p":o=100==a||105==a,r=n("i"+8*(m=m||4)),8==m&&(r=117==a?(r[0]>>>0)+4294967296*(r[1]>>>0):(r[0]>>>0)+4294967296*r[1]),4>=m&&(r=(o?Br:Ur)(r&Math.pow(256,m)-1,8*m));var g=Math.abs(r);if(o="",100==a||105==a)var y=Br(r,8*m).toString(10);else if(117==a)y=Ur(r,8*m).toString(10),r=Math.abs(r);else if(111==a)y=(l?"0":"")+g.toString(8);else if(120==a||88==a){if(o=l&&0!=r?"0x":"",0>r){for(r=-r,y=(g-1).toString(16),g=[],l=0;l<y.length;l++)g.push((15-parseInt(y[l],16)).toString(16));for(y=g.join("");y.length<2*m;)y="f"+y}else y=g.toString(16);88==a&&(o=o.toUpperCase(),y=y.toUpperCase())}else 112==a&&(0===g?y="(nil)":(o="0x",y=g.toString(16)));if(d)for(;y.length<f;)y="0"+y;for(0<=r&&(u?o="+"+o:h&&(o=" "+o)),"-"==y.charAt(0)&&(o="-"+o,y=y.substr(1));o.length+y.length<p;)t?y+=" ":c?y="0"+y:o=" "+o;(y=o+y).split("").forEach((function(e){s.push(e.charCodeAt(0))}));break;case"f":case"F":case"e":case"E":case"g":case"G":if(r=n("double"),isNaN(r))y="nan",c=!1;else if(isFinite(r)){if(d=!1,m=Math.min(f,20),103!=a&&71!=a||(d=!0,(f=f||1)>(m=parseInt(r.toExponential(m).split("e")[1],10))&&-4<=m?(a=(103==a?"f":"F").charCodeAt(0),f-=m+1):(a=(103==a?"e":"E").charCodeAt(0),f--),m=Math.min(f,20)),101==a||69==a?(y=r.toExponential(m),/[eE][-+]\d$/.test(y)&&(y=y.slice(0,-1)+"0"+y.slice(-1))):102!=a&&70!=a||(y=r.toFixed(m),0===r&&(0>r||0===r&&-1/0==1/r)&&(y="-"+y)),o=y.split("e"),d&&!l)for(;1<o[0].length&&o[0].includes(".")&&("0"==o[0].slice(-1)||"."==o[0].slice(-1));)o[0]=o[0].slice(0,-1);else for(l&&-1==y.indexOf(".")&&(o[0]+=".");f>m++;)o[0]+="0";y=o[0]+(1<o.length?"e"+o[1]:""),69==a&&(y=y.toUpperCase()),0<=r&&(u?y="+"+y:h&&(y=" "+y))}else y=(0>r?"-":"")+"inf",c=!1;for(;y.length<p;)y=t?y+" ":!c||"-"!=y[0]&&"+"!=y[0]?(c?"0":" ")+y:y[0]+"0"+y.slice(1);97>a&&(y=y.toUpperCase()),y.split("").forEach((function(e){s.push(e.charCodeAt(0))}));break;case"s":if(c=(u=n("i8*"))?Wr(u):6,d&&(c=Math.min(c,f)),!t)for(;c<p--;)s.push(32);if(u)for(l=0;l<c;l++)s.push(se[u++>>0]);else s=s.concat(Vr("(null)".substr(0,c),!0));if(t)for(;c<p--;)s.push(32);break;case"c":for(t&&s.push(n("i8"));0<--p;)s.push(32);t||s.push(n("i8"));break;case"n":t=n("i32*"),le[t>>2]=s.length;break;case"%":s.push(r);break;default:for(l=o;l<e+2;l++)s.push(ie[l>>0])}e+=2}else s.push(r),e+=1}return s}(t,n),t=me(t,0),24&e&&(t=t.replace(/\s+$/,""),t+=(0<t.length?"\n":"")+function(e){e:{var t=Error();if(!t.stack){try{throw Error()}catch(e){t=e}if(!t.stack){t="(no stack trace available)";break e}}t=t.stack.toString()}t=t.slice(t.indexOf("\n",Math.max(t.lastIndexOf("_emscripten_log"),t.lastIndexOf("_emscripten_get_callstack")))+1),32&e&&dn("EM_LOG_DEMANGLE is deprecated; ignoring"),8&e&&"undefined"==typeof emscripten_source_map&&(dn('Source map information is not available, emscripten_log with EM_LOG_C_STACK will be ignored. Build with "--pre-js $EMSCRIPTEN/src/emscripten-source-map.min.js" linker flag to add source map loading to code.'),e=8^e|16);var n=null;if(128&e)for(n=zr(arguments);n[1].includes("_emscripten_");)n=zr(n[0]);var r=t.split("\n");t="";var a,i=RegExp("\\s*(.*?)@(.*?):([0-9]+):([0-9]+)"),s=RegExp("\\s*(.*?)@(.*):(.*)(:(.*))?"),o=RegExp("\\s*at (.*?) \\((.*):(.*):(.*)\\)");for(a in r){var u,l=r[a];if((u=o.exec(l))&&5==u.length){l=u[1];var c=u[2],h=u[3];u=u[4]}else{if((u=i.exec(l))||(u=s.exec(l)),!(u&&4<=u.length)){t+=l+"\n";continue}l=u[1],c=u[2],h=u[3],u=0|u[4]}var p=!1;if(8&e){var d=emscripten_source_map.Fn({line:h,xm:u});(p=d&&d.source)&&(64&e&&(d.source=d.source.substring(d.source.replace(/\\/g,"/").lastIndexOf("/")+1)),t+=" at "+l+" ("+d.source+":"+d.line+":"+d.xm+")\n")}(16&e||!p)&&(64&e&&(c=c.substring(c.replace(/\\/g,"/").lastIndexOf("/")+1)),t+=(p?" = "+l:" at "+l)+" ("+c+":"+h+":"+u+")\n"),128&e&&n[0]&&(n[1]==l&&0<n[2].length&&(t=t.replace(/\s+$/,""),t+=" with values: "+n[1]+n[2]+"\n"),n=zr(n[0]))}return t.replace(/\s+$/,"")}(e)),1&e?4&e?console.error(t):2&e?console.warn(t):512&e?console.info(t):256&e?console.debug(t):console.log(t):6&e?te(t):ee(t)},Ic:function(e,t,n){se.copyWithin(e,t,t+n)},vc:function(e){var t=se.length;if(2147483648<(e>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);var a=Math,i=a.min;r=Math.max(e,r),r+=(65536-r%65536)%65536;e:{var s=re.buffer;try{re.grow(i.call(a,2147483648,r)-s.byteLength+65535>>>16),we();var o=1;break e}catch(e){}o=void 0}if(o)return!0}return!1},Pi:function(e,t){Bn(n.canvas,e,t),Ln()},xc:function(e,t){var n=0;return Gr().forEach((function(r,a){var i=t+n;for(a=ce[e+4*a>>2]=i,i=0;i<r.length;++i)ie[a++>>0]=r.charCodeAt(i);ie[a>>0]=0,n+=r.length+1})),0},yc:function(e,t){var n=Gr();ce[e>>2]=n.length;var r=0;return n.forEach((function(e){r+=e.length+1})),ce[t>>2]=r,0},ii:ln,Ga:function(){return 52},zc:function(){return 52},gc:function(){return 70},Ha:function(e,t,n,r){for(var a=0,i=0;i<n;i++){var s=ce[t>>2],o=ce[t+4>>2];t+=8;for(var u=0;u<o;u++)qr(e,se[s+u]);a+=o}return ce[r>>2]=a,0},Nc:async function(e,t){var n=Y("background_blur.deepar");n||(n=await Q("background_blur.deepar")),n=new Uint8Array(n);var r=vi(n.length);se.set(n,r),Ft("vii",e,[t,r])},Yc:async function(e,t){var n=Y("background_replacement.deepar");n||(n=await Q("background_replacement.deepar")),n=new Uint8Array(n);var r=vi(n.length);se.set(n,r),Ft("vii",e,[t,r])},rc:function e(t,n){e.Ol||(e.Ol=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return()=>(crypto.getRandomValues(e),e[0])}return()=>Fe("randomDevice")}());for(var r=0;r<n;r++)ie[t+r>>0]=e.Ol();return 0},Wa:function(e){li.activeTexture(e)},cb:function(e,t){li.attachShader(Zn[e],rr[t])},C:function(e,t){35051==e?li.el=t:35052==e&&(li.Jk=t),li.bindBuffer(e,Jn[t])},x:function(e,t){li.bindFramebuffer(e,er[t])},U:function(e,t){li.bindRenderbuffer(e,tr[t])},B:function(e,t){li.bindTexture(e,nr[t])},ti:function(e,t,n,r){li.blendColor(e,t,n,r)},ui:function(e,t){li.blendEquationSeparate(e,t)},vi:function(e,t,n,r){li.blendFuncSeparate(e,t,n,r)},Ma:function(e,t,n,r){n&&t?li.bufferData(e,se,r,n,t):li.bufferData(e,t,r)},Pa:function(e,t,n,r){n&&li.bufferSubData(e,t,se,r,n)},fa:function(e){return li.checkFramebufferStatus(e)},pi:function(e){li.clear(e)},Oa:function(e,t,n,r){li.clearColor(e,t,n,r)},ri:function(e){li.clearDepth(e)},qi:function(e){li.clearStencil(e)},ea:function(e,t,n,r){li.colorMask(!!e,!!t,!!n,!!r)},yi:function(e){li.compileShader(rr[e])},Ui:function(e,t,n,r,a,i,s,o){li.Jk||!s?li.compressedTexImage2D(e,t,n,r,a,i,s,o):li.compressedTexImage2D(e,t,n,r,a,i,se,o,s)},Ei:function(e,t,n,r,a,i,s,o,u){li.Jk||!o?li.compressedTexSubImage2D(e,t,n,r,a,i,s,o,u):li.compressedTexSubImage2D(e,t,n,r,a,i,s,se,u,o)},Mi:function(){var e=dr(Zn),t=li.createProgram();return t.name=e,t.Wk=t.Uk=t.Vk=0,t.xl=1,Zn[e]=t,e},Ai:function(e){var t=dr(rr);return rr[t]=li.createShader(e),t},Qa:function(e){li.cullFace(e)},ja:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2],a=Jn[r];a&&(li.deleteBuffer(a),a.name=0,Jn[r]=null,r==li.el&&(li.el=0),r==li.Jk&&(li.Jk=0))}},wa:function(e,t){for(var n=0;n<e;++n){var r=le[t+4*n>>2],a=er[r];a&&(li.deleteFramebuffer(a),a.name=0,er[r]=null)}},bb:function(e){if(e){var t=Zn[e];t?(li.deleteProgram(t),t.name=0,Zn[e]=null):pr(1281)}},ya:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2],a=tr[r];a&&(li.deleteRenderbuffer(a),a.name=0,tr[r]=null)}},Ua:function(e){if(e){var t=rr[e];t?(li.deleteShader(t),rr[e]=null):pr(1281)}},Bi:function(e){if(e){var t=lr[e];t?(li.deleteSync(t),t.name=0,lr[e]=null):pr(1281)}},T:function(e,t){for(var n=0;n<e;n++){var r=le[t+4*n>>2],a=nr[r];a&&(li.deleteTexture(a),a.name=0,nr[r]=null)}},aa:function(e){li.depthFunc(e)},ua:function(e){li.depthMask(!!e)},ab:function(e,t){li.detachShader(Zn[e],rr[t])},y:function(e){li.disable(e)},_a:function(e){li.disableVertexAttribArray(e)},oi:function(e,t,n){li.drawArrays(e,t,n)},ki:Er,H:function(e){li.enable(e)},Za:function(e){li.enableVertexAttribArray(e)},si:function(){li.flush()},xa:function(e,t,n,r){li.framebufferRenderbuffer(e,t,n,tr[r])},ga:function(e,t,n,r,a){li.framebufferTexture2D(e,t,n,nr[r],a)},Na:function(e,t){Sr(e,t,"createBuffer",Jn)},ha:function(e,t){Sr(e,t,"createFramebuffer",er)},za:function(e,t){Sr(e,t,"createRenderbuffer",tr)},Z:function(e,t){Sr(e,t,"createTexture",nr)},Va:function(e){li.generateMipmap(e)},Ji:function(e,t,n,r,a,i,s){Ir("getActiveAttrib",e,t,n,r,a,i,s)},Ii:function(e,t,n,r,a,i,s){Ir("getActiveUniform",e,t,n,r,a,i,s)},$a:function(e,t){return li.getAttribLocation(Zn[e],ge(t))},z:function(){var e=li.getError()||yr;return yr=0,e},Ni:function(e,t){Cr(e,t,2)},X:function(e,t){Cr(e,t,0)},Ki:function(e,t,n,r){null===(e=li.getProgramInfoLog(Zn[e]))&&(e="(unknown error)"),t=0<t&&r?be(e,r,t):0,n&&(le[n>>2]=t)},V:function(e,t,n){if(n)if(e>=Qn)pr(1281);else if(e=Zn[e],35716==t)null===(e=li.getProgramInfoLog(e))&&(e="(unknown error)"),le[n>>2]=e.length+1;else if(35719==t){if(!e.Wk)for(t=0;t<li.getProgramParameter(e,35718);++t)e.Wk=Math.max(e.Wk,li.getActiveUniform(e,t).name.length+1);le[n>>2]=e.Wk}else if(35722==t){if(!e.Uk)for(t=0;t<li.getProgramParameter(e,35721);++t)e.Uk=Math.max(e.Uk,li.getActiveAttrib(e,t).name.length+1);le[n>>2]=e.Uk}else if(35381==t){if(!e.Vk)for(t=0;t<li.getProgramParameter(e,35382);++t)e.Vk=Math.max(e.Vk,li.getActiveUniformBlockName(e,t).length+1);le[n>>2]=e.Vk}else le[n>>2]=li.getProgramParameter(e,t);else pr(1281)},wi:function(e,t,n,r){null===(e=li.getShaderInfoLog(rr[e]))&&(e="(unknown error)"),t=0<t&&r?be(e,r,t):0,n&&(le[n>>2]=t)},xi:function(e,t,n){n?35716==t?(null===(e=li.getShaderInfoLog(rr[e]))&&(e="(unknown error)"),le[n>>2]=e?e.length+1:0):35720==t?(e=li.getShaderSource(rr[e]),le[n>>2]=e?e.length+1:0):le[n>>2]=li.getShaderParameter(rr[e],t):pr(1281)},W:function(e){var t=cr[e];if(!t){switch(e){case 7939:t=(t=li.getSupportedExtensions()||[]).concat(t.map((function(e){return"GL_"+e}))),t=Rr(t.join(" "));break;case 7936:case 7937:case 37445:case 37446:(t=li.getParameter(e))||pr(1280),t=t&&Rr(t);break;case 7938:t=Rr("OpenGL ES 3.0 ("+li.getParameter(7938)+")");break;case 35724:var n=(t=li.getParameter(35724)).match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);null!==n&&(3==n[1].length&&(n[1]+="0"),t="OpenGL ES GLSL ES "+n[1]+" ("+t+")"),t=Rr(t);break;default:pr(1280)}cr[e]=t}return t},Hi:function(e,t){if(t=ge(t),e=Zn[e]){Or(e);var n=e.hl,r=0,a=t,i=Fr(t);if(0<i&&(r=parseInt(t.slice(i+1))>>>0,a=t.slice(0,i)),(a=e.yl[a])&&r<a[0]&&(n[r+=a[1]]=n[r]||li.getUniformLocation(e,t)))return r}else pr(1281);return-1},Ci:function(e){return li.isSync(lr[e])},Li:function(e){e=Zn[e],li.linkProgram(e),e.hl=0,e.yl={}},ia:function(e,t){li.pixelStorei(e,t)},ta:function(e,t,n,r,a,i,s){if(li.el)li.readPixels(e,t,n,r,a,i,s);else{var o=Pr(i);li.readPixels(e,t,n,r,a,i,o,s>>Lr(o))}},Xa:function(e,t,n,r){li.renderbufferStorage(e,t,n,r)},va:function(e,t,n,r){li.scissor(e,t,n,r)},zi:function(e,t,n,r){t=fr(t,n,r),li.shaderSource(rr[e],t)},Sa:function(e,t,n,r){li.stencilFuncSeparate(e,t,n,r)},Ra:function(e,t,n,r){li.stencilOpSeparate(e,t,n,r)},Oi:function(e,t,n,r,a,i,s,o,u){if(li.Jk)li.texImage2D(e,t,n,r,a,i,s,o,u);else if(u){var l=Pr(o);li.texImage2D(e,t,n,r,a,i,s,o,l,u>>Lr(l))}else li.texImage2D(e,t,n,r,a,i,s,o,null)},Fi:function(e,t,n){li.texParameterf(e,t,n)},Gi:function(e,t,n){li.texParameterf(e,t,he[n>>2])},J:function(e,t,n){li.texParameteri(e,t,n)},Di:function(e,t,n,r,a,i,s,o,u){if(li.Jk)li.texSubImage2D(e,t,n,r,a,i,s,o,u);else if(u){var l=Pr(o);li.texSubImage2D(e,t,n,r,a,i,s,o,l,u>>Lr(l))}else li.texSubImage2D(e,t,n,r,a,i,s,o,null)},li:function(e,t){li.uniform1i(Mr(e),t)},ni:function(e,t,n){t&&li.uniform1iv(Mr(e),le,n>>2,t)},$:function(e,t,n){t&&li.uniform4fv(Mr(e),he,n>>2,4*t)},mi:function(e,t,n,r){t&&li.uniformMatrix3fv(Mr(e),!!n,he,r>>2,9*t)},M:function(e,t,n,r){t&&li.uniformMatrix4fv(Mr(e),!!n,he,r>>2,16*t)},ka:function(e){e=Zn[e],li.useProgram(e),li.Hl=e},Ya:function(e,t,n,r,a,i){li.vertexAttribPointer(e,t,n,!!r,a,i)},Ta:function(e,t,n,r){li.viewport(e,t,n,r)},ic:function(e,t,n,r){li.waitSync(lr[e],t,(n>>>0)+4294967296*r)},v:function(e,t,n){var r=Si();try{return ze(e)(t,n)}catch(e){if(Ii(r),e!==e+0)throw e;Ei(1,0)}},lb:function(e,t,n,r){var a=Si();try{return ze(e)(t,n,r)}catch(e){if(Ii(a),e!==e+0)throw e;Ei(1,0)}},Aa:function(e,t){var n=Si();try{return ze(e)(t)}catch(e){if(Ii(n),e!==e+0)throw e;Ei(1,0)}},Ea:function(e,t,n,r){var a=Si();try{return ze(e)(t,n,r)}catch(e){if(Ii(a),e!==e+0)throw e;Ei(1,0)}},s:function(e){var t=Si();try{return ze(e)()}catch(e){if(Ii(t),e!==e+0)throw e;Ei(1,0)}},j:function(e,t){var n=Si();try{return ze(e)(t)}catch(e){if(Ii(n),e!==e+0)throw e;Ei(1,0)}},K:function(e,t,n){var r=Si();try{return ze(e)(t,n)}catch(e){if(Ii(r),e!==e+0)throw e;Ei(1,0)}},P:function(e,t,n){var r=Si();try{return ze(e)(t,n)}catch(e){if(Ii(r),e!==e+0)throw e;Ei(1,0)}},Vi:function(e,t,n,r,a){var i=Si();try{return ze(e)(t,n,r,a)}catch(e){if(Ii(i),e!==e+0)throw e;Ei(1,0)}},kb:function(e,t,n,r,a,i,s,o,u,l,c,h,p,d){var f=Si();try{return ze(e)(t,n,r,a,i,s,o,u,l,c,h,p,d)}catch(e){if(Ii(f),e!==e+0)throw e;Ei(1,0)}},_i:function(e,t,n,r,a){var i=Si();try{return ze(e)(t,n,r,a)}catch(e){if(Ii(i),e!==e+0)throw e;Ei(1,0)}},b:function(e,t,n){var r=Si();try{return ze(e)(t,n)}catch(e){if(Ii(r),e!==e+0)throw e;Ei(1,0)}},h:function(e,t,n,r){var a=Si();try{return ze(e)(t,n,r)}catch(e){if(Ii(a),e!==e+0)throw e;Ei(1,0)}},Wi:function(e,t,n,r,a,i,s,o,u){var l=Si();try{return ze(e)(t,n,r,a,i,s,o,u)}catch(e){if(Ii(l),e!==e+0)throw e;Ei(1,0)}},p:function(e,t,n,r,a){var i=Si();try{return ze(e)(t,n,r,a)}catch(e){if(Ii(i),e!==e+0)throw e;Ei(1,0)}},Fa:function(e,t,n,r,a,i){var s=Si();try{return ze(e)(t,n,r,a,i)}catch(e){if(Ii(s),e!==e+0)throw e;Ei(1,0)}},Xi:function(e,t,n,r,a,i,s,o,u,l){var c=Si();try{return ze(e)(t,n,r,a,i,s,o,u,l)}catch(e){if(Ii(c),e!==e+0)throw e;Ei(1,0)}},D:function(e,t,n,r,a,i){var s=Si();try{return ze(e)(t,n,r,a,i)}catch(e){if(Ii(s),e!==e+0)throw e;Ei(1,0)}},q:function(e,t,n,r,a,i,s){var o=Si();try{return ze(e)(t,n,r,a,i,s)}catch(e){if(Ii(o),e!==e+0)throw e;Ei(1,0)}},L:function(e,t,n,r,a,i,s,o){var u=Si();try{return ze(e)(t,n,r,a,i,s,o)}catch(e){if(Ii(u),e!==e+0)throw e;Ei(1,0)}},Da:function(e,t,n,r,a,i,s,o,u){var l=Si();try{return ze(e)(t,n,r,a,i,s,o,u)}catch(e){if(Ii(l),e!==e+0)throw e;Ei(1,0)}},Ca:function(e,t,n,r,a,i,s,o,u,l){var c=Si();try{return ze(e)(t,n,r,a,i,s,o,u,l)}catch(e){if(Ii(c),e!==e+0)throw e;Ei(1,0)}},da:function(e,t,n,r,a,i,s,o,u,l,c,h){var p=Si();try{return ze(e)(t,n,r,a,i,s,o,u,l,c,h)}catch(e){if(Ii(p),e!==e+0)throw e;Ei(1,0)}},ec:function(e,t,n,r,a,i,s){var o=Si();try{return Ui(e,t,n,r,a,i,s)}catch(e){if(Ii(o),e!==e+0)throw e;Ei(1,0)}},lc:function(e,t,n,r,a,i){var s=Si();try{return $i(e,t,n,r,a,i)}catch(e){if(Ii(s),e!==e+0)throw e;Ei(1,0)}},jc:function(e,t,n,r){var a=Si();try{return Mi(e,t,n,r)}catch(e){if(Ii(a),e!==e+0)throw e;Ei(1,0)}},pc:function(e){var t=Si();try{return Ri(e)}catch(e){if(Ii(t),e!==e+0)throw e;Ei(1,0)}},oc:function(e,t){var n=Si();try{return Fi(e,t)}catch(e){if(Ii(n),e!==e+0)throw e;Ei(1,0)}},dc:function(e,t,n,r,a){var i=Si();try{return Wi(e,t,n,r,a)}catch(e){if(Ii(i),e!==e+0)throw e;Ei(1,0)}},mc:function(e,t,n,r,a){var i=Si();try{return Pi(e,t,n,r,a)}catch(e){if(Ii(i),e!==e+0)throw e;Ei(1,0)}},k:function(e){var t=Si();try{ze(e)()}catch(e){if(Ii(t),e!==e+0)throw e;Ei(1,0)}},i:function(e,t){var n=Si();try{ze(e)(t)}catch(e){if(Ii(n),e!==e+0)throw e;Ei(1,0)}},E:function(e,t,n){var r=Si();try{ze(e)(t,n)}catch(e){if(Ii(r),e!==e+0)throw e;Ei(1,0)}},na:function(e,t,n){var r=Si();try{ze(e)(t,n)}catch(e){if(Ii(r),e!==e+0)throw e;Ei(1,0)}},Zi:function(e,t,n,r){var a=Si();try{ze(e)(t,n,r)}catch(e){if(Ii(a),e!==e+0)throw e;Ei(1,0)}},d:function(e,t,n){var r=Si();try{ze(e)(t,n)}catch(e){if(Ii(r),e!==e+0)throw e;Ei(1,0)}},rb:function(e,t,n,r){var a=Si();try{ze(e)(t,n,r)}catch(e){if(Ii(a),e!==e+0)throw e;Ei(1,0)}},ob:function(e,t,n,r,a){var i=Si();try{ze(e)(t,n,r,a)}catch(e){if(Ii(i),e!==e+0)throw e;Ei(1,0)}},A:function(e,t,n,r,a,i,s){var o=Si();try{ze(e)(t,n,r,a,i,s)}catch(e){if(Ii(o),e!==e+0)throw e;Ei(1,0)}},Y:function(e,t,n,r,a){var i=Si();try{ze(e)(t,n,r,a)}catch(e){if(Ii(i),e!==e+0)throw e;Ei(1,0)}},g:function(e,t,n,r){var a=Si();try{ze(e)(t,n,r)}catch(e){if(Ii(a),e!==e+0)throw e;Ei(1,0)}},o:function(e,t,n,r,a){var i=Si();try{ze(e)(t,n,r,a)}catch(e){if(Ii(i),e!==e+0)throw e;Ei(1,0)}},Yi:function(e,t,n,r,a,i){var s=Si();try{ze(e)(t,n,r,a,i)}catch(e){if(Ii(s),e!==e+0)throw e;Ei(1,0)}},r:function(e,t,n,r,a,i){var s=Si();try{ze(e)(t,n,r,a,i)}catch(e){if(Ii(s),e!==e+0)throw e;Ei(1,0)}},t:function(e,t,n,r,a,i,s){var o=Si();try{ze(e)(t,n,r,a,i,s)}catch(e){if(Ii(o),e!==e+0)throw e;Ei(1,0)}},F:function(e,t,n,r,a,i,s,o){var u=Si();try{ze(e)(t,n,r,a,i,s,o)}catch(e){if(Ii(u),e!==e+0)throw e;Ei(1,0)}},Q:function(e,t,n,r,a,i,s,o,u){var l=Si();try{ze(e)(t,n,r,a,i,s,o,u)}catch(e){if(Ii(l),e!==e+0)throw e;Ei(1,0)}},_b:function(e,t,n,r,a,i,s,o,u,l){var c=Si();try{ze(e)(t,n,r,a,i,s,o,u,l)}catch(e){if(Ii(c),e!==e+0)throw e;Ei(1,0)}},S:function(e,t,n,r,a,i,s,o,u,l,c){var h=Si();try{ze(e)(t,n,r,a,i,s,o,u,l,c)}catch(e){if(Ii(h),e!==e+0)throw e;Ei(1,0)}},nb:function(e,t,n,r,a,i,s,o,u,l,c,h,p){var d=Si();try{ze(e)(t,n,r,a,i,s,o,u,l,c,h,p)}catch(e){if(Ii(d),e!==e+0)throw e;Ei(1,0)}},ca:function(e,t,n,r,a,i,s,o,u,l,c,h,p,d,f,m){var g=Si();try{ze(e)(t,n,r,a,i,s,o,u,l,c,h,p,d,f,m)}catch(e){if(Ii(g),e!==e+0)throw e;Ei(1,0)}},fc:function(e,t,n,r,a,i,s){var o=Si();try{Bi(e,t,n,r,a,i,s)}catch(e){if(Ii(o),e!==e+0)throw e;Ei(1,0)}},nc:function(e,t,n,r){var a=Si();try{Oi(e,t,n,r)}catch(e){if(Ii(a),e!==e+0)throw e;Ei(1,0)}},kc:function(e,t,n,r){var a=Si();try{Di(e,t,n,r)}catch(e){if(Ii(a),e!==e+0)throw e;Ei(1,0)}},Dc:function(){let e=window.localStorage.getItem("k39d");e||(e=function(){let e=(new Date).getTime(),t=performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(n){let r=16*Math.random();return 0<e?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),("x"===n?r:3&r|8).toString(16)}))}(),window.localStorage.setItem("k39d",e));let t=document.title;t&&0!==t.length||(t="No title");let n=navigator.vendor;n&&0!==n.length||(n="N/A");let r=navigator.platform;r&&0!==r.length||(r="N/A"),Xr=e,Yr=navigator.userAgent,Qr=window.screen.width+"x"+window.screen.height,Jr=t,Zr=document.domain,ea="1.0.0",ta=n,ra=na=r},bj:function(){return-1},cj:function(){return-1},aj:function(e,t){if(!(e=n.Hk[e]))throw Error("Image is null.");ya(e,t)},$i:function(e,t,n,r){ya(e=new ImageData(new Uint8ClampedArray(se.subarray(e,e+t*n*4)),t,n),r)},dj:function(){return!1},ub:ba,tb:function(){return!!ma},ff:function(e,t){if(oa){var n=aa.createBufferSource();n.connect(ia),n.buffer=sa[e].Rl,n.loop=t,n.start(0),sa[e].ul=n,sa[e].Tl=!0}},rf:async function(e,t,n){if(oa){sa[e]={ul:null,Rl:null,Sl:!1,Hn:!1};var r=new ArrayBuffer(n);new Uint8Array(r).set(se.subarray(t,t+n)),sa[e].Rl=await aa.decodeAudioData(r),sa[e].Sl=!0}},We:function(e){oa&&(sa[e].ul.stop(),sa[e].Tl=!1,sa[e].ul.currentTime=0)},Cf:function(e){return!!oa&&sa[e].Sl},Ke:function(e){oa&&(sa[e].Tl&&sa[e].ul.stop(),delete sa[e])},ze:function(e){oa&&ia.gain.setValueAtTime(e,aa.currentTime)},sb:function(e){n.Hk[e]=null},qb:function(e,t,r){const a=(e=n.Hk[e]).canvas;return(e.Gl||pa!==t||da!==r)&&(ua.width===t&&ua.height===r||(ua.width=t,ua.height=r),la.drawImage(a,0,0,a.width,a.height,0,0,t,r),ha=la.getImageData(0,0,t,r),pa=t,da=r,e.Gl=!1),P(ha)},pb:function(e,t){if(!(e=n.Hk[e]))throw Error("Image data does not exist.");se.set(e.data,t)},ac:function(){if(!ca){const e=document.createElement("canvas"),t=e.getContext("2d",{alpha:!1,desynchronized:!0});ca=P({canvas:e,dl:t,Gl:!0})}return ca},bc:function(e){return n.Hk[e].videoHeight},cc:function(e){return n.Hk[e].videoWidth},Cd:function(e,t){if(({canvas:e}=n.Hk[e]),t=nr[t],!br||!t)return-1;li.bindTexture(li.TEXTURE_2D,t),li.texImage2D(li.TEXTURE_2D,0,li.RGBA,li.RGBA,li.UNSIGNED_BYTE,e)},$b:function(e,t){const r=(e=n.Hk[e]).canvas,a=e.dl;t=n.Hk[t],r.width===t.videoWidth&&r.height===t.videoHeight||(r.width=t.videoWidth,r.height=t.videoHeight),a.drawImage(t,0,0),e.Gl=!0},Ub:function(e){he.set(Ta,e>>2)},Tb:function(e){he.set(ka,e>>2)},Yb:async function(){if(console.log("Rigid face tracking init called"),null==wa&&(wa=new l.Geometry),null==_a&&(_a=new l.VideoManager(null)).setNbFramesDelay(0),!wa.isInitialized()&&!va){va=!0;var e,t=Y("rigidFaceDetector");t||(e=Q("rigidFaceDetector"));var r,a=Y("rigidFaceTracker");a||(r=Q("rigidFaceTracker")),t||(t=await e),a||(a=await r),await wa.initialize(_a,{poseEstimationWasmFilename:n.rigidFaceTrackingConfig.poseEstimationWasmPath,modelFilename:t,featuresFilename:a,fovY:50,geometryToDetect:"FACE",normMode:"eye_center",detectScoreThs:.2,trackScoreThs:.2,filteringShift:.2,filteringLevel:1,computePose:!0,wasmBackend:{enable:!0,tfjsBackendWasmPath:n.rigidFaceTrackingConfig.tfjsBackendWasmPath,tfjsBackendWasmSimdPath:n.rigidFaceTrackingConfig.tfjsBackendWasmSimdPath,tfjsBackendWasmThreadedPath:n.rigidFaceTrackingConfig.tfjsBackendWasmThreadedSimdPath}}),va=!1,console.log("DeepAR FaceTracking initialized!")}},Vb:function(){return xa},pa:function(){return null!=wa&&wa.isInitialized()},Zb:function(){return va},Xb:function(e){if(!(e=n.Hk[e]))throw Error("No image data.");Ea(e)},Wb:function(e,t,n){Ea(e=new ImageData(new Uint8ClampedArray(se.subarray(e,e+t*n*4)),t,n))},Nb:function(e){he.set(Ca,e>>2)},Mb:function(e){he.set(Na,e>>2)},Kb:function(e){he.set(Fa,e>>2)},Jb:function(e){he.set(Oa,e>>2)},Rb:$a,oa:Da,Sb:function(){return Sa},Ob:function(){return Ra},Lb:function(){return Ma},Qb:function(e){if(!(e=n.Hk[e]))throw Error("No image data.");Pa(e)},Pb:function(e,t,n){Pa(e=new ImageData(new Uint8ClampedArray(se.subarray(e,e+t*n*4)),t,n))},xb:function(){return La.getHeight()},yb:function(){return La.getWidth()},wb:function(e,t){if(!(e=n.Hk[e]))throw Error("Image is null.");Va(e,t)},vb:function(e,t,n,r){Va(e=new ImageData(new Uint8ClampedArray(se.subarray(e,e+t*n*4)),t,n),r)},zb:function(){return!0},Bb:za,Ab:ja,Db:function(e){he.set(Xa,e>>2)},Fb:function(e){he.set(Ya,e>>2)},Cb:async function(e,t){if(!Ga&&(null==Ha&&(Ha=new l.Geometry),null==Ka&&(Ka=new l.VideoManager(null),Ja=t,Ka.setNbFramesDelay(Ja)),!Ha.isInitialized())){var r;Ga=!0,console.log("DeepAR WristTracking initialize started."),(t=Y("wristDetector"))||(r=Q("wristDetector"));var a,i=Y("wristTracker");i||(a=Q("wristTracker"));var s,o=Y("wristObj");o||(s=Q("wristObj")),t||(t=await r),i||(i=await a),o||(o=await s),await Ha.initialize(Ka,{geometryToDetect:"WRIST",poseEstimationWasmFilename:n.wristTrackingConfig.poseEstimationWasmPath,modelFilename:t,featuresFilename:i,objFilename:o,fovY:e,detectScoreThs:.3,trackScoreThs:.4,validTrackedKeypThs:.4,filteringShift:.5,trackedNumKeypsThs:50,reprojThs:50,activeIds:[44,46,47,65,66,78,108,110,111,113,114,115,123,127,130,136,139,140,142,143,145,148,151,153,158,160,166,170,171,174,175,177,178],wasmBackend:{enable:!0,tfjsBackendWasmPath:n.wristTrackingConfig.tfjsBackendWasmPath,tfjsBackendWasmSimdPath:n.wristTrackingConfig.tfjsBackendWasmSimdPath,tfjsBackendWasmThreadedPath:n.wristTrackingConfig.tfjsBackendWasmThreadedSimdPath}}),Ga=!1,console.log("DeepAR WristTracking initialized!")}},Ba:Za,Eb:function(){return Ha.isMirrored()},Gb:function(){return qa},Ib:function(e){if(!(e=n.Hk[e]))throw Error("No image data.");ei(e)},Hb:function(e,t,n){ei(e=new ImageData(new Uint8ClampedArray(se.subarray(e,e+t*n*4)),t,n))},n:function(e){return e},hi:ii,sc:function(e,t,n,r){return ii(e,t,n,r)},gi:function(e,t,n){for(var r=ge(t),a=0;25>a;++a)r=r.replace(new RegExp("\\"+"\\!@#$^&*()+=-[]/{}|:<>?,."[a],"g"),"\\"+"\\!@#$^&*()+=-[]/{}|:<>?,."[a]);for(var i in t={"%A":"%a","%B":"%b","%c":"%a %b %d %H:%M:%S %Y","%D":"%m\\/%d\\/%y","%e":"%d","%F":"%Y-%m-%d","%h":"%b","%R":"%H\\:%M","%r":"%I\\:%M\\:%S\\s%p","%T":"%H\\:%M\\:%S","%x":"%m\\/%d\\/(?:%y|%Y)","%X":"%H\\:%M\\:%S"})r=r.replace(i,t[i]);a={"%a":"(?:Sun(?:day)?)|(?:Mon(?:day)?)|(?:Tue(?:sday)?)|(?:Wed(?:nesday)?)|(?:Thu(?:rsday)?)|(?:Fri(?:day)?)|(?:Sat(?:urday)?)","%b":"(?:Jan(?:uary)?)|(?:Feb(?:ruary)?)|(?:Mar(?:ch)?)|(?:Apr(?:il)?)|May|(?:Jun(?:e)?)|(?:Jul(?:y)?)|(?:Aug(?:ust)?)|(?:Sep(?:tember)?)|(?:Oct(?:ober)?)|(?:Nov(?:ember)?)|(?:Dec(?:ember)?)","%C":"\\d\\d","%d":"0[1-9]|[1-9](?!\\d)|1\\d|2\\d|30|31","%H":"\\d(?!\\d)|[0,1]\\d|20|21|22|23","%I":"\\d(?!\\d)|0\\d|10|11|12","%j":"00[1-9]|0?[1-9](?!\\d)|0?[1-9]\\d(?!\\d)|[1,2]\\d\\d|3[0-6]\\d","%m":"0[1-9]|[1-9](?!\\d)|10|11|12","%M":"0\\d|\\d(?!\\d)|[1-5]\\d","%n":"\\s","%p":"AM|am|PM|pm|A\\.M\\.|a\\.m\\.|P\\.M\\.|p\\.m\\.","%S":"0\\d|\\d(?!\\d)|[1-5]\\d|60","%U":"0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53","%W":"0\\d|\\d(?!\\d)|[1-4]\\d|50|51|52|53","%w":"[0-6]","%y":"\\d\\d","%Y":"\\d\\d\\d\\d","%%":"%","%t":"\\s"};var s={fn:0,en:1,jn:2,bn:3,kn:4,hn:5,gn:6,cn:7,nn:8,mn:9,ln:10,dn:11};for(var o in i={cm:0,Zl:1,em:2,fm:3,dm:4,Wl:5,bm:6},t={Zl:0,em:1,fm:2,dm:3,Wl:4,bm:5,cm:6},a)r=r.replace(o,"("+o+a[o]+")");var u=[];for(a=r.indexOf("%");0<=a;a=r.indexOf("%"))u.push(r[a+1]),r=r.replace(new RegExp("\\%"+r[a+1],"g"),"");var l=new RegExp("^"+r,"i").exec(ge(e));if(l){if(o=function(){function e(e,t,n){return"number"!=typeof e||isNaN(e)?t:e>=t?e<=n?e:n:t}return{year:e(le[n+20>>2]+1900,1970,9999),month:e(le[n+16>>2],0,11),day:e(le[n+12>>2],1,31),hour:e(le[n+8>>2],0,23),min:e(le[n+4>>2],0,59),Ql:e(le[n>>2],0,59)}}(),a=e=>{if(0<=(e=u.indexOf(e)))return l[e+1]},(r=a("S"))&&(o.Ql=parseInt(r)),(r=a("M"))&&(o.min=parseInt(r)),r=a("H"))o.hour=parseInt(r);else if(r=a("I")){var c=parseInt(r);(r=a("p"))&&(c+="P"===r.toUpperCase()[0]?12:0),o.hour=c}if((r=a("Y"))?o.year=parseInt(r):(r=a("y"))&&(c=parseInt(r),c=(r=a("C"))?c+100*parseInt(r):c+(69>c?2e3:1900),o.year=c),(r=a("m"))?o.month=parseInt(r)-1:(r=a("b"))&&(o.month=s[r.substring(0,3).toUpperCase()]||0),r=a("d"))o.day=parseInt(r);else if(r=a("j"))for(i=parseInt(r),t=tn(o.year),s=0;12>s;++s)i<=(r=ti(t?ni:ri,s-1))+(t?ni:ri)[s]&&(o.day=i-r);else(r=a("a"))&&(s=r.substring(0,3).toUpperCase(),(r=a("U"))?(i=i[s],t=parseInt(r),i=0===(s=new Date(o.year,0,1)).getDay()?ai(s,i+7*(t-1)):ai(s,7-s.getDay()+i+7*(t-1)),o.day=i.getDate(),o.month=i.getMonth()):(r=a("W"))&&(i=t[s],t=parseInt(r),i=1===(s=new Date(o.year,0,1)).getDay()?ai(s,i+7*(t-1)):ai(s,7-s.getDay()+1+i+7*(t-1)),o.day=i.getDate(),o.month=i.getMonth()));return o=new Date(o.year,o.month,o.day,o.hour,o.min,o.Ql,0),le[n>>2]=o.getSeconds(),le[n+4>>2]=o.getMinutes(),le[n+8>>2]=o.getHours(),le[n+12>>2]=o.getDate(),le[n+16>>2]=o.getMonth(),le[n+20>>2]=o.getFullYear()-1900,le[n+24>>2]=o.getDay(),le[n+28>>2]=ti(tn(o.getFullYear())?ni:ri,o.getMonth()-1)+o.getDate()-1,le[n+32>>2]=0,e+Vr(l[0]).length-1}return 0}};Ce++,function(e,t){var n=xe;return"function"!=typeof WebAssembly.instantiateStreaming||Oe(n)||"function"!=typeof fetch?De(n,e,t):fetch(n,{credentials:"same-origin"}).then((function(r){return WebAssembly.instantiateStreaming(r,e).then(t,(function(r){return te("wasm streaming compile failed: "+r),te("falling back to ArrayBuffer instantiation"),De(n,e,t)}))}))}({a:hi},(function(e){n.asm=e.instance.exports,re=n.asm.ej,we(),_e=n.asm.$j,Te.unshift(n.asm.fj),0==--Ce&&(null!==Ne&&(clearInterval(Ne),Ne=null),Re&&(e=Re,Re=null,e()))})).catch(a);var pi=n._initialize=function(){return(pi=n._initialize=n.asm.gj).apply(null,arguments)};function di(){return(di=n.asm.mj).apply(null,arguments)}n._setLicenseKey=function(){return(n._setLicenseKey=n.asm.hj).apply(null,arguments)},n._hasVar=function(){return(n._hasVar=n.asm.ij).apply(null,arguments)},n._getVarTypeStatus=function(){return(n._getVarTypeStatus=n.asm.jj).apply(null,arguments)},n._getVarType=function(){return(n._getVarType=n.asm.kj).apply(null,arguments)},n._getBoolVarStatus=function(){return(n._getBoolVarStatus=n.asm.lj).apply(null,arguments)},n._getBoolVar=function(){return(n._getBoolVar=n.asm.nj).apply(null,arguments)},n._getIntVarStatus=function(){return(n._getIntVarStatus=n.asm.oj).apply(null,arguments)},n._getIntVar=function(){return(n._getIntVar=n.asm.pj).apply(null,arguments)},n._getDoubleVarStatus=function(){return(n._getDoubleVarStatus=n.asm.qj).apply(null,arguments)},n._getDoubleVar=function(){return(n._getDoubleVar=n.asm.rj).apply(null,arguments)},n._getStringVarStatus=function(){return(n._getStringVarStatus=n.asm.sj).apply(null,arguments)},n._getStringVar=function(){return(n._getStringVar=n.asm.tj).apply(null,arguments)},n._setBoolVar=function(){return(n._setBoolVar=n.asm.uj).apply(null,arguments)},n._setIntVar=function(){return(n._setIntVar=n.asm.vj).apply(null,arguments)},n._setDoubleVar=function(){return(n._setDoubleVar=n.asm.wj).apply(null,arguments)},n._setStringVar=function(){return(n._setStringVar=n.asm.xj).apply(null,arguments)},n._deleteVar=function(){return(n._deleteVar=n.asm.yj).apply(null,arguments)},n._clearVars=function(){return(n._clearVars=n.asm.zj).apply(null,arguments)};var fi=n._shutdownEngine=function(){return(fi=n._shutdownEngine=n.asm.Aj).apply(null,arguments)};n._processFrameVideo=function(){return(n._processFrameVideo=n.asm.Bj).apply(null,arguments)},n._processFrameRawPixels=function(){return(n._processFrameRawPixels=n.asm.Cj).apply(null,arguments)};var mi=n._takeScreenshot=function(){return(mi=n._takeScreenshot=n.asm.Dj).apply(null,arguments)};n._switchEffect=function(){return(n._switchEffect=n.asm.Ej).apply(null,arguments)},n._clearEffect=function(){return(n._clearEffect=n.asm.Fj).apply(null,arguments)},n._showStats=function(){return(n._showStats=n.asm.Gj).apply(null,arguments)},n._simulatePhysics=function(){return(n._simulatePhysics=n.asm.Hj).apply(null,arguments)},n._showColliders=function(){return(n._showColliders=n.asm.Ij).apply(null,arguments)},n._render=function(){return(n._render=n.asm.Jj).apply(null,arguments)},n._fireTrigger=function(){return(n._fireTrigger=n.asm.Kj).apply(null,arguments)},n._setFaceDetectionSensitivity=function(){return(n._setFaceDetectionSensitivity=n.asm.Lj).apply(null,arguments)},n._changeParameterFloat=function(){return(n._changeParameterFloat=n.asm.Mj).apply(null,arguments)},n._changeParameterBool=function(){return(n._changeParameterBool=n.asm.Nj).apply(null,arguments)},n._changeParameterVector=function(){return(n._changeParameterVector=n.asm.Oj).apply(null,arguments)},n._changeParameterTexture=function(){return(n._changeParameterTexture=n.asm.Pj).apply(null,arguments)};var gi=n._reset=function(){return(gi=n._reset=n.asm.Qj).apply(null,arguments)};n._moveGameObject=function(){return(n._moveGameObject=n.asm.Rj).apply(null,arguments)};var yi=n._touchOccurred=function(){return(yi=n._touchOccurred=n.asm.Sj).apply(null,arguments)};n._pushConsoleLog=function(){return(n._pushConsoleLog=n.asm.Tj).apply(null,arguments)},n._enableAutoframing=function(){return(n._enableAutoframing=n.asm.Uj).apply(null,arguments)},n._muteSound=function(){return(n._muteSound=n.asm.Vj).apply(null,arguments)},n._backgroundBlur=function(){return(n._backgroundBlur=n.asm.Wj).apply(null,arguments)},n._backgroundReplacement=function(){return(n._backgroundReplacement=n.asm.Xj).apply(null,arguments)};var bi=n._initializeFootTracking=function(){return(bi=n._initializeFootTracking=n.asm.Yj).apply(null,arguments)};n._setZoom=function(){return(n._setZoom=n.asm.Zj).apply(null,arguments)};var vi=n._malloc=function(){return(vi=n._malloc=n.asm._j).apply(null,arguments)},wi=n._free=function(){return(wi=n._free=n.asm.ak).apply(null,arguments)};function _i(){return(_i=n.asm.bk).apply(null,arguments)}var xi=n._fflush=function(){return(xi=n._fflush=n.asm.ck).apply(null,arguments)},ki=n.___getTypeName=function(){return(ki=n.___getTypeName=n.asm.dk).apply(null,arguments)};function Ti(){return(Ti=n.asm.fk).apply(null,arguments)}function Ei(){return(Ei=n.asm.gk).apply(null,arguments)}function Si(){return(Si=n.asm.hk).apply(null,arguments)}function Ii(){return(Ii=n.asm.ik).apply(null,arguments)}function Ai(){return(Ai=n.asm.jk).apply(null,arguments)}function Ci(){return(Ci=n.asm.kk).apply(null,arguments)}function Ni(){return(Ni=n.asm.lk).apply(null,arguments)}n.__embind_initialize_bindings=function(){return(n.__embind_initialize_bindings=n.asm.ek).apply(null,arguments)},n.dynCall_viiiij=function(){return(n.dynCall_viiiij=n.asm.mk).apply(null,arguments)},n.dynCall_viiij=function(){return(n.dynCall_viiij=n.asm.nk).apply(null,arguments)},n.dynCall_vijiiii=function(){return(n.dynCall_vijiiii=n.asm.ok).apply(null,arguments)};var Ri=n.dynCall_j=function(){return(Ri=n.dynCall_j=n.asm.pk).apply(null,arguments)},Fi=n.dynCall_ji=function(){return(Fi=n.dynCall_ji=n.asm.qk).apply(null,arguments)},Oi=n.dynCall_vij=function(){return(Oi=n.dynCall_vij=n.asm.rk).apply(null,arguments)},Mi=n.dynCall_iij=function(){return(Mi=n.dynCall_iij=n.asm.sk).apply(null,arguments)};n.dynCall_iijii=function(){return(n.dynCall_iijii=n.asm.tk).apply(null,arguments)},n.dynCall_vijii=function(){return(n.dynCall_vijii=n.asm.uk).apply(null,arguments)};var $i=n.dynCall_iiiij=function(){return($i=n.dynCall_iiiij=n.asm.vk).apply(null,arguments)},Di=n.dynCall_vji=function(){return(Di=n.dynCall_vji=n.asm.wk).apply(null,arguments)},Pi=n.dynCall_jiji=function(){return(Pi=n.dynCall_jiji=n.asm.xk).apply(null,arguments)};n.dynCall_viij=function(){return(n.dynCall_viij=n.asm.yk).apply(null,arguments)};var Li,Bi=n.dynCall_viijii=function(){return(Bi=n.dynCall_viijii=n.asm.zk).apply(null,arguments)},Ui=n.dynCall_iiiiij=function(){return(Ui=n.dynCall_iiiiij=n.asm.Ak).apply(null,arguments)},Wi=n.dynCall_jiiii=function(){return(Wi=n.dynCall_jiiii=n.asm.Bk).apply(null,arguments)};function Vi(){0<Ce||(Be(ke),0<Ce||Li||(Li=!0,n.calledRun=!0,de))||(Be(Te),r(n),n.onRuntimeInitialized&&n.onRuntimeInitialized(),Be(Se))}return n.dynCall_iiiiijj=function(){return(n.dynCall_iiiiijj=n.asm.Ck).apply(null,arguments)},n.dynCall_iiiiiijj=function(){return(n.dynCall_iiiiiijj=n.asm.Dk).apply(null,arguments)},n.cwrap=si,Re=function e(){Li||Vi(),Li||(Re=e)},Vi(),e.ready});const s=i;function o(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}var u=function(){return u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},u.apply(this,arguments)};function l(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))}function c(e,t){var n,r,a,i,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(s=0)),s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}function h(e,t,n){if(n||2===arguments.length)for(var r,a=0,i=t.length;a<i;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}var p=function(){function e(e,t,n){this.NB_BUFFERS=5,this._videoFrames=[],this._nbFramesDelay=0,this._videoElement=e,this._videoCanvas=document.createElement("canvas"),this._videoCanvas.style.display="none",this._videoCanvasContext=this._videoCanvas.getContext("2d",{willReadFrequently:!0}),null!=t&&(this._videoCanvas.width=t),null!=n&&(this._videoCanvas.height=n)}return e.prototype.getNbFramesDelay=function(){return this._nbFramesDelay},e.prototype.setNbFramesDelay=function(e){e>=0&&e<this.NB_BUFFERS?this._nbFramesDelay=e:console.error("Invalid frames delay, delay must be less than ",this.NB_BUFFERS)},e.prototype.getVideoCanvas=function(){return this._videoCanvas},e.prototype.compare=function(e,t,n,r){var a=!0;return[1,50,100,1e3,2e3,3e3,5e3,9e3].forEach((function(i){i<n*r*3&&e.data[i]!=t.data[i]&&(a=!1)})),a},e.prototype.preProcessWithBuffer=function(e){for(var t=0;t<this._videoFrames.length;t++)if(this.compare(this._videoFrames[t],e,this._videoCanvas.width,this._videoCanvas.height))return!1;return this._videoFrames.length===this.NB_BUFFERS&&(this._videoFrames=this._videoFrames.slice(0,-1)),this._videoFrames=h([e],this._videoFrames,!0),!0},e.prototype.preProcess=function(){if(null==this._videoElement||0===this._videoElement.videoWidth||0===this._videoElement.videoHeight)return!1;this._videoCanvas.width===this._videoElement.videoWidth&&this._videoCanvas.height===this._videoElement.videoHeight||(this._videoFrames=[],this._videoCanvas.width=this._videoElement.videoWidth,this._videoCanvas.height=this._videoElement.videoHeight),this._videoCanvasContext.drawImage(this._videoElement,0,0,this._videoCanvas.width,this._videoCanvas.height);for(var e=this._videoCanvasContext.getImageData(0,0,this._videoCanvas.width,this._videoCanvas.height),t=0;t<this._videoFrames.length;t++)if(this.compare(this._videoFrames[t],e,this._videoCanvas.width,this._videoCanvas.height))return!1;return this._videoFrames.length===this.NB_BUFFERS&&(this._videoFrames=this._videoFrames.slice(0,-1)),this._videoFrames=h([e],this._videoFrames,!0),!0},e.prototype.postProcess=function(){if(this._nbFramesDelay>0&&this._videoFrames.length>0){var e=this._nbFramesDelay<this._videoFrames.length?this._videoFrames[this._nbFramesDelay]:this._videoFrames[this._videoFrames.length-1];this._videoCanvasContext.putImageData(e,0,0)}},e.prototype.getCameraFrame=function(){if(this._nbFramesDelay>0&&this._videoFrames.length>0)return this._nbFramesDelay<this._videoFrames.length?this._videoFrames[this._nbFramesDelay]:this._videoFrames[this._videoFrames.length-1]},e.prototype.updateDelay=function(e){e>=0&&e<this.NB_BUFFERS?this._nbFramesDelay=e:console.error("Invalid frames delay, delay must be less than ",this.NB_BUFFERS)},e.prototype.getLastBuffer=function(){return this._videoFrames.length>0?this._videoFrames[0]:null},e.prototype.setOverlapingImage=function(e){this._videoCanvasContext.putImageData(e,10,10)},e}(),d=function(e,t){return d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},d(e,t)};function f(e,t){function n(){this.constructor=e}d(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function m(e){return"function"==typeof e}var g=!1,y={Promise:void 0,set useDeprecatedSynchronousErrorHandling(e){e&&(new Error).stack,g=e},get useDeprecatedSynchronousErrorHandling(){return g}};function b(e){setTimeout((function(){throw e}),0)}var v={closed:!0,next:function(e){},error:function(e){if(y.useDeprecatedSynchronousErrorHandling)throw e;b(e)},complete:function(){}},w=Array.isArray||function(e){return e&&"number"==typeof e.length};function _(e){return null!==e&&"object"==typeof e}var x=function(){function e(e){return Error.call(this),this.message=e?e.length+" errors occurred during unsubscription:\n"+e.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=e,this}return e.prototype=Object.create(Error.prototype),e}(),k=x,T=function(){function e(e){this.closed=!1,this._parentOrParents=null,this._subscriptions=null,e&&(this._ctorUnsubscribe=!0,this._unsubscribe=e)}return e.prototype.unsubscribe=function(){var t;if(!this.closed){var n=this,r=n._parentOrParents,a=n._ctorUnsubscribe,i=n._unsubscribe,s=n._subscriptions;if(this.closed=!0,this._parentOrParents=null,this._subscriptions=null,r instanceof e)r.remove(this);else if(null!==r)for(var o=0;o<r.length;++o)r[o].remove(this);if(m(i)){a&&(this._unsubscribe=void 0);try{i.call(this)}catch(e){t=e instanceof k?E(e.errors):[e]}}if(w(s)){o=-1;for(var u=s.length;++o<u;){var l=s[o];if(_(l))try{l.unsubscribe()}catch(e){t=t||[],e instanceof k?t=t.concat(E(e.errors)):t.push(e)}}}if(t)throw new k(t)}},e.prototype.add=function(t){var n=t;if(!t)return e.EMPTY;switch(typeof t){case"function":n=new e(t);case"object":if(n===this||n.closed||"function"!=typeof n.unsubscribe)return n;if(this.closed)return n.unsubscribe(),n;if(!(n instanceof e)){var r=n;(n=new e)._subscriptions=[r]}break;default:throw new Error("unrecognized teardown "+t+" added to Subscription.")}var a=n._parentOrParents;if(null===a)n._parentOrParents=this;else if(a instanceof e){if(a===this)return n;n._parentOrParents=[a,this]}else{if(-1!==a.indexOf(this))return n;a.push(this)}var i=this._subscriptions;return null===i?this._subscriptions=[n]:i.push(n),n},e.prototype.remove=function(e){var t=this._subscriptions;if(t){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}},e.EMPTY=function(e){return e.closed=!0,e}(new e),e}();function E(e){return e.reduce((function(e,t){return e.concat(t instanceof k?t.errors:t)}),[])}var S="function"==typeof Symbol?Symbol("rxSubscriber"):"@@rxSubscriber_"+Math.random(),I=function(e){function t(n,r,a){var i=e.call(this)||this;switch(i.syncErrorValue=null,i.syncErrorThrown=!1,i.syncErrorThrowable=!1,i.isStopped=!1,arguments.length){case 0:i.destination=v;break;case 1:if(!n){i.destination=v;break}if("object"==typeof n){n instanceof t?(i.syncErrorThrowable=n.syncErrorThrowable,i.destination=n,n.add(i)):(i.syncErrorThrowable=!0,i.destination=new A(i,n));break}default:i.syncErrorThrowable=!0,i.destination=new A(i,n,r,a)}return i}return f(t,e),t.prototype[S]=function(){return this},t.create=function(e,n,r){var a=new t(e,n,r);return a.syncErrorThrowable=!1,a},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this))},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){this.destination.error(e),this.unsubscribe()},t.prototype._complete=function(){this.destination.complete(),this.unsubscribe()},t.prototype._unsubscribeAndRecycle=function(){var e=this._parentOrParents;return this._parentOrParents=null,this.unsubscribe(),this.closed=!1,this.isStopped=!1,this._parentOrParents=e,this},t}(T),A=function(e){function t(t,n,r,a){var i,s=e.call(this)||this;s._parentSubscriber=t;var o=s;return m(n)?i=n:n&&(i=n.next,r=n.error,a=n.complete,n!==v&&(m((o=Object.create(n)).unsubscribe)&&s.add(o.unsubscribe.bind(o)),o.unsubscribe=s.unsubscribe.bind(s))),s._context=o,s._next=i,s._error=r,s._complete=a,s}return f(t,e),t.prototype.next=function(e){if(!this.isStopped&&this._next){var t=this._parentSubscriber;y.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?this.__tryOrSetError(t,this._next,e)&&this.unsubscribe():this.__tryOrUnsub(this._next,e)}},t.prototype.error=function(e){if(!this.isStopped){var t=this._parentSubscriber,n=y.useDeprecatedSynchronousErrorHandling;if(this._error)n&&t.syncErrorThrowable?(this.__tryOrSetError(t,this._error,e),this.unsubscribe()):(this.__tryOrUnsub(this._error,e),this.unsubscribe());else if(t.syncErrorThrowable)n?(t.syncErrorValue=e,t.syncErrorThrown=!0):b(e),this.unsubscribe();else{if(this.unsubscribe(),n)throw e;b(e)}}},t.prototype.complete=function(){var e=this;if(!this.isStopped){var t=this._parentSubscriber;if(this._complete){var n=function(){return e._complete.call(e._context)};y.useDeprecatedSynchronousErrorHandling&&t.syncErrorThrowable?(this.__tryOrSetError(t,n),this.unsubscribe()):(this.__tryOrUnsub(n),this.unsubscribe())}else this.unsubscribe()}},t.prototype.__tryOrUnsub=function(e,t){try{e.call(this._context,t)}catch(e){if(this.unsubscribe(),y.useDeprecatedSynchronousErrorHandling)throw e;b(e)}},t.prototype.__tryOrSetError=function(e,t,n){if(!y.useDeprecatedSynchronousErrorHandling)throw new Error("bad call");try{t.call(this._context,n)}catch(t){return y.useDeprecatedSynchronousErrorHandling?(e.syncErrorValue=t,e.syncErrorThrown=!0,!0):(b(t),!0)}return!1},t.prototype._unsubscribe=function(){var e=this._parentSubscriber;this._context=null,this._parentSubscriber=null,e.unsubscribe()},t}(I),C="function"==typeof Symbol&&Symbol.observable||"@@observable";function N(e){return e}var R=function(){function e(e){this._isScalar=!1,e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this.operator,a=function(e,t,n){if(e){if(e instanceof I)return e;if(e[S])return e[S]()}return e||t||n?new I(e,t,n):new I(v)}(e,t,n);if(r?a.add(r.call(a,this.source)):a.add(this.source||y.useDeprecatedSynchronousErrorHandling&&!a.syncErrorThrowable?this._subscribe(a):this._trySubscribe(a)),y.useDeprecatedSynchronousErrorHandling&&a.syncErrorThrowable&&(a.syncErrorThrowable=!1,a.syncErrorThrown))throw a.syncErrorValue;return a},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){y.useDeprecatedSynchronousErrorHandling&&(e.syncErrorThrown=!0,e.syncErrorValue=t),function(e){for(;e;){var t=e,n=t.closed,r=t.destination,a=t.isStopped;if(n||a)return!1;e=r&&r instanceof I?r:null}return!0}(e)?e.error(t):console.warn(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=F(t))((function(t,r){var a;a=n.subscribe((function(t){try{e(t)}catch(e){r(e),a&&a.unsubscribe()}}),r,t)}))},e.prototype._subscribe=function(e){var t=this.source;return t&&t.subscribe(e)},e.prototype[C]=function(){return this},e.prototype.pipe=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return 0===t.length?this:(0===(e=t).length?N:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)})(this)},e.prototype.toPromise=function(e){var t=this;return new(e=F(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function F(e){if(e||(e=y.Promise||Promise),!e)throw new Error("no Promise impl found");return e}var O=function(e){return function(t){for(var n=0,r=e.length;n<r&&!t.closed;n++)t.next(e[n]);t.complete()}},M="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator",$=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function D(e){return!!e&&"function"!=typeof e.subscribe&&"function"==typeof e.then}var P=function(e){if(e&&"function"==typeof e[C])return r=e,function(e){var t=r[C]();if("function"!=typeof t.subscribe)throw new TypeError("Provided object does not correctly implement Symbol.observable");return t.subscribe(e)};if($(e))return O(e);if(D(e))return n=e,function(e){return n.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,b),e};if(e&&"function"==typeof e[M])return t=e,function(e){for(var n=t[M]();;){var r=void 0;try{r=n.next()}catch(t){return e.error(t),e}if(r.done){e.complete();break}if(e.next(r.value),e.closed)break}return"function"==typeof n.return&&e.add((function(){n.return&&n.return()})),e};var t,n,r,a=_(e)?"an invalid object":"'"+e+"'";throw new TypeError("You provided "+a+" where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.")},L=function(e){function t(t){var n=e.call(this)||this;return n.parent=t,n}return f(t,e),t.prototype._next=function(e){this.parent.notifyNext(e)},t.prototype._error=function(e){this.parent.notifyError(e),this.unsubscribe()},t.prototype._complete=function(){this.parent.notifyComplete(),this.unsubscribe()},t}(I),B=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return f(t,e),t.prototype.notifyNext=function(e){this.destination.next(e)},t.prototype.notifyError=function(e){this.destination.error(e)},t.prototype.notifyComplete=function(){this.destination.complete()},t}(I);function U(e){return e&&"function"==typeof e.schedule}var W=function(e){function t(t,n,r){var a=e.call(this)||this;return a.parent=t,a.outerValue=n,a.outerIndex=r,a.index=0,a}return f(t,e),t.prototype._next=function(e){this.parent.notifyNext(this.outerValue,e,this.outerIndex,this.index++,this)},t.prototype._error=function(e){this.parent.notifyError(e,this),this.unsubscribe()},t.prototype._complete=function(){this.parent.notifyComplete(this),this.unsubscribe()},t}(I);function V(e,t,n,r,a){if(void 0===a&&(a=new W(e,n,r)),!a.closed)return t instanceof R?t.subscribe(a):P(t)(a)}var z=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return f(t,e),t.prototype.notifyNext=function(e,t,n,r,a){this.destination.next(t)},t.prototype.notifyError=function(e,t){this.destination.error(e)},t.prototype.notifyComplete=function(e){this.destination.complete()},t}(I);function j(e,t){return new R((function(n){var r=new T,a=0;return r.add(t.schedule((function(){a!==e.length?(n.next(e[a++]),n.closed||r.add(this.schedule())):n.complete()}))),r}))}function G(e,t){return t?j(e,t):new R(O(e))}var H={};function K(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=void 0,r=void 0;return U(e[e.length-1])&&(r=e.pop()),"function"==typeof e[e.length-1]&&(n=e.pop()),1===e.length&&w(e[0])&&(e=e[0]),G(e,r).lift(new q(n))}var q=function(){function e(e){this.resultSelector=e}return e.prototype.call=function(e,t){return t.subscribe(new X(e,this.resultSelector))},e}(),X=function(e){function t(t,n){var r=e.call(this,t)||this;return r.resultSelector=n,r.active=0,r.values=[],r.observables=[],r}return f(t,e),t.prototype._next=function(e){this.values.push(H),this.observables.push(e)},t.prototype._complete=function(){var e=this.observables,t=e.length;if(0===t)this.destination.complete();else{this.active=t,this.toRespond=t;for(var n=0;n<t;n++){var r=e[n];this.add(V(this,r,void 0,n))}}},t.prototype.notifyComplete=function(e){0==(this.active-=1)&&this.destination.complete()},t.prototype.notifyNext=function(e,t,n){var r=this.values,a=r[n],i=this.toRespond?a===H?--this.toRespond:this.toRespond:0;r[n]=t,0===i&&(this.resultSelector?this._tryResultSelector(r):this.destination.next(r.slice()))},t.prototype._tryResultSelector=function(e){var t;try{t=this.resultSelector.apply(this,e)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(z);function Y(e,t){return t?function(e,t){if(null!=e){if(function(e){return e&&"function"==typeof e[C]}(e))return function(e,t){return new R((function(n){var r=new T;return r.add(t.schedule((function(){var a=e[C]();r.add(a.subscribe({next:function(e){r.add(t.schedule((function(){return n.next(e)})))},error:function(e){r.add(t.schedule((function(){return n.error(e)})))},complete:function(){r.add(t.schedule((function(){return n.complete()})))}}))}))),r}))}(e,t);if(D(e))return function(e,t){return new R((function(n){var r=new T;return r.add(t.schedule((function(){return e.then((function(e){r.add(t.schedule((function(){n.next(e),r.add(t.schedule((function(){return n.complete()})))})))}),(function(e){r.add(t.schedule((function(){return n.error(e)})))}))}))),r}))}(e,t);if($(e))return j(e,t);if(function(e){return e&&"function"==typeof e[M]}(e)||"string"==typeof e)return function(e,t){if(!e)throw new Error("Iterable cannot be null");return new R((function(n){var r,a=new T;return a.add((function(){r&&"function"==typeof r.return&&r.return()})),a.add(t.schedule((function(){r=e[M](),a.add(t.schedule((function(){if(!n.closed){var e,t;try{var a=r.next();e=a.value,t=a.done}catch(e){return void n.error(e)}t?n.complete():(n.next(e),this.schedule())}})))}))),a}))}(e,t)}throw new TypeError((null!==e&&typeof e||e)+" is not observable")}(e,t):e instanceof R?e:new R(P(e))}function Q(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e[e.length-1];return U(n)?(e.pop(),j(e,n)):G(e)}function J(e,t){return function(n){if("function"!=typeof e)throw new TypeError("argument is not a function. Are you looking for `mapTo()`?");return n.lift(new Z(e,t))}}var Z=function(){function e(e,t){this.project=e,this.thisArg=t}return e.prototype.call=function(e,t){return t.subscribe(new ee(e,this.project,this.thisArg))},e}(),ee=function(e){function t(t,n,r){var a=e.call(this,t)||this;return a.project=n,a.count=0,a.thisArg=r||a,a}return f(t,e),t.prototype._next=function(e){var t;try{t=this.project.call(this.thisArg,e,this.count++)}catch(e){return void this.destination.error(e)}this.destination.next(t)},t}(I),te=new R((function(e){return e.complete()}));function ne(e,t){return new R(t?function(n){return t.schedule(re,0,{error:e,subscriber:n})}:function(t){return t.error(e)})}function re(e){var t=e.error;e.subscriber.error(t)}function ae(e){return function(t){return t.lift(new ie(e))}}var ie=function(){function e(e){this.callback=e}return e.prototype.call=function(e,t){return t.subscribe(new se(e,this.callback))},e}(),se=function(e){function t(t,n){var r=e.call(this,t)||this;return r.add(new T(n)),r}return f(t,e),t}(I),oe=function(){function e(){return Error.call(this),this.message="object unsubscribed",this.name="ObjectUnsubscribedError",this}return e.prototype=Object.create(Error.prototype),e}(),ue=function(e){function t(t,n){var r=e.call(this)||this;return r.subject=t,r.subscriber=n,r.closed=!1,r}return f(t,e),t.prototype.unsubscribe=function(){if(!this.closed){this.closed=!0;var e=this.subject,t=e.observers;if(this.subject=null,t&&0!==t.length&&!e.isStopped&&!e.closed){var n=t.indexOf(this.subscriber);-1!==n&&t.splice(n,1)}}},t}(T),le=function(e){function t(t){var n=e.call(this,t)||this;return n.destination=t,n}return f(t,e),t}(I),ce=function(e){function t(){var t=e.call(this)||this;return t.observers=[],t.closed=!1,t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return f(t,e),t.prototype[S]=function(){return new le(this)},t.prototype.lift=function(e){var t=new he(this,this);return t.operator=e,t},t.prototype.next=function(e){if(this.closed)throw new oe;if(!this.isStopped)for(var t=this.observers,n=t.length,r=t.slice(),a=0;a<n;a++)r[a].next(e)},t.prototype.error=function(e){if(this.closed)throw new oe;this.hasError=!0,this.thrownError=e,this.isStopped=!0;for(var t=this.observers,n=t.length,r=t.slice(),a=0;a<n;a++)r[a].error(e);this.observers.length=0},t.prototype.complete=function(){if(this.closed)throw new oe;this.isStopped=!0;for(var e=this.observers,t=e.length,n=e.slice(),r=0;r<t;r++)n[r].complete();this.observers.length=0},t.prototype.unsubscribe=function(){this.isStopped=!0,this.closed=!0,this.observers=null},t.prototype._trySubscribe=function(t){if(this.closed)throw new oe;return e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){if(this.closed)throw new oe;return this.hasError?(e.error(this.thrownError),T.EMPTY):this.isStopped?(e.complete(),T.EMPTY):(this.observers.push(e),new ue(this,e))},t.prototype.asObservable=function(){var e=new R;return e.source=this,e},t.create=function(e,t){return new he(e,t)},t}(R),he=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return f(t,e),t.prototype.next=function(e){var t=this.destination;t&&t.next&&t.next(e)},t.prototype.error=function(e){var t=this.destination;t&&t.error&&this.destination.error(e)},t.prototype.complete=function(){var e=this.destination;e&&e.complete&&this.destination.complete()},t.prototype._subscribe=function(e){return this.source?this.source.subscribe(e):T.EMPTY},t}(ce),pe=function(e){function t(t){var n=e.call(this)||this;return n._value=t,n}return f(t,e),Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!0,configurable:!0}),t.prototype._subscribe=function(t){var n=e.prototype._subscribe.call(this,t);return n&&!n.closed&&t.next(this._value),n},t.prototype.getValue=function(){if(this.hasError)throw this.thrownError;if(this.closed)throw new oe;return this._value},t.prototype.next=function(t){e.prototype.next.call(this,this._value=t)},t}(ce);function de(e){return void 0===e&&(e=-1),function(t){return t.lift(new fe(e,t))}}var fe=function(){function e(e,t){this.count=e,this.source=t}return e.prototype.call=function(e,t){return t.subscribe(new me(e,this.count,this.source))},e}(),me=function(e){function t(t,n,r){var a=e.call(this,t)||this;return a.count=n,a.source=r,a}return f(t,e),t.prototype.error=function(t){if(!this.isStopped){var n=this.source,r=this.count;if(0===r)return e.prototype.error.call(this,t);r>-1&&(this.count=r-1),n.subscribe(this._unsubscribeAndRecycle())}},t}(I);function ge(e,t){return"function"==typeof t?function(n){return n.pipe(ge((function(n,r){return Y(e(n,r)).pipe(J((function(e,a){return t(n,e,r,a)})))})))}:function(t){return t.lift(new ye(e))}}var ye=function(){function e(e){this.project=e}return e.prototype.call=function(e,t){return t.subscribe(new be(e,this.project))},e}(),be=function(e){function t(t,n){var r=e.call(this,t)||this;return r.project=n,r.index=0,r}return f(t,e),t.prototype._next=function(e){var t,n=this.index++;try{t=this.project(e,n)}catch(e){return void this.destination.error(e)}this._innerSub(t)},t.prototype._innerSub=function(e){var t=this.innerSubscription;t&&t.unsubscribe();var n=new L(this),r=this.destination;r.add(n),this.innerSubscription=function(e,t){if(!t.closed){if(e instanceof R)return e.subscribe(t);var n;try{n=P(e)(t)}catch(e){t.error(e)}return n}}(e,n),this.innerSubscription!==n&&r.add(this.innerSubscription)},t.prototype._complete=function(){var t=this.innerSubscription;t&&!t.closed||e.prototype._complete.call(this),this.unsubscribe()},t.prototype._unsubscribe=function(){this.innerSubscription=void 0},t.prototype.notifyComplete=function(){this.innerSubscription=void 0,this.isStopped&&e.prototype._complete.call(this)},t.prototype.notifyNext=function(e){this.destination.next(e)},t}(B);function ve(){}function we(e,t,n){return function(r){return r.lift(new _e(e,t,n))}}var _e=function(){function e(e,t,n){this.nextOrObserver=e,this.error=t,this.complete=n}return e.prototype.call=function(e,t){return t.subscribe(new xe(e,this.nextOrObserver,this.error,this.complete))},e}(),xe=function(e){function t(t,n,r,a){var i=e.call(this,t)||this;return i._tapNext=ve,i._tapError=ve,i._tapComplete=ve,i._tapError=r||ve,i._tapComplete=a||ve,m(n)?(i._context=i,i._tapNext=n):n&&(i._context=n,i._tapNext=n.next||ve,i._tapError=n.error||ve,i._tapComplete=n.complete||ve),i}return f(t,e),t.prototype._next=function(e){try{this._tapNext.call(this._context,e)}catch(e){return void this.destination.error(e)}this.destination.next(e)},t.prototype._error=function(e){try{this._tapError.call(this._context,e)}catch(e){return void this.destination.error(e)}this.destination.error(e)},t.prototype._complete=function(){try{this._tapComplete.call(this._context)}catch(e){return void this.destination.error(e)}return this.destination.complete()},t}(I);function ke(e){return new R((function(t){var n;try{n=e()}catch(e){return void t.error(e)}return(n?Y(n):te).subscribe(t)}))}var Te=void 0!==n.g?n.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function Ee(){throw new Error("setTimeout has not been defined")}function Se(){throw new Error("clearTimeout has not been defined")}var Ie=Ee,Ae=Se;function Ce(e){if(Ie===setTimeout)return setTimeout(e,0);if((Ie===Ee||!Ie)&&setTimeout)return Ie=setTimeout,setTimeout(e,0);try{return Ie(e,0)}catch(t){try{return Ie.call(null,e,0)}catch(t){return Ie.call(this,e,0)}}}"function"==typeof Te.setTimeout&&(Ie=setTimeout),"function"==typeof Te.clearTimeout&&(Ae=clearTimeout);var Ne,Re=[],Fe=!1,Oe=-1;function Me(){Fe&&Ne&&(Fe=!1,Ne.length?Re=Ne.concat(Re):Oe=-1,Re.length&&$e())}function $e(){if(!Fe){var e=Ce(Me);Fe=!0;for(var t=Re.length;t;){for(Ne=Re,Re=[];++Oe<t;)Ne&&Ne[Oe].run();Oe=-1,t=Re.length}Ne=null,Fe=!1,function(e){if(Ae===clearTimeout)return clearTimeout(e);if((Ae===Se||!Ae)&&clearTimeout)return Ae=clearTimeout,clearTimeout(e);try{return Ae(e)}catch(t){try{return Ae.call(null,e)}catch(t){return Ae.call(this,e)}}}(e)}}function De(e,t){this.fun=e,this.array=t}function Pe(){}De.prototype.run=function(){this.fun.apply(null,this.array)};var Le=Pe,Be=Pe,Ue=Pe,We=Pe,Ve=Pe,ze=Pe,je=Pe,Ge=Te.performance||{},He=Ge.now||Ge.mozNow||Ge.msNow||Ge.oNow||Ge.webkitNow||function(){return(new Date).getTime()},Ke=new Date,qe={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];Re.push(new De(e,t)),1!==Re.length||Fe||Ce($e)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Le,addListener:Be,once:Ue,off:We,removeListener:Ve,removeAllListeners:ze,emit:je,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*He.call(Ge),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Ke)/1e3}},Xe=qe;class Ye{constructor(e,t){this.backend=e,this.dataMover=t,this.data=new WeakMap,this.dataIdsCount=0}get(e){return this.data.has(e)||this.dataMover.moveData(this.backend,e),this.data.get(e)}set(e,t){this.dataIdsCount++,this.data.set(e,t)}has(e){return this.data.has(e)}delete(e){return this.dataIdsCount--,this.data.delete(e)}numDataIds(){return this.dataIdsCount}}class Qe{refCount(e){return Je("refCount")}incRef(e){return Je("incRef")}timerAvailable(){return!0}time(e){return Je("time")}read(e){return Je("read")}readSync(e){return Je("readSync")}readToGPU(e,t){return Je("readToGPU")}numDataIds(){return Je("numDataIds")}disposeData(e,t){return Je("disposeData")}write(e,t,n){return Je("write")}move(e,t,n,r,a){return Je("move")}createTensorFromGPUData(e,t,n){return Je("createTensorFromGPUData")}memory(){return Je("memory")}floatPrecision(){return Je("floatPrecision")}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}dispose(){return Je("dispose")}}function Je(e){throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`)}function Ze(e,t,n){return Math.max(e,Math.min(t,n))}function et(e){return e%2==0?e:e+1}function tt(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function nt(e,t){if(!e)throw new Error("string"==typeof t?t:t())}function rt(e,t,n=""){nt(st(e,t),(()=>n+` Shapes ${e} and ${t} must match`))}function at(e){nt(null!=e,(()=>"The input to the tensor constructor must be a non-null value."))}function it(e){if(0===e.length)return 1;let t=e[0];for(let n=1;n<e.length;n++)t*=e[n];return t}function st(e,t){if(e===t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ot(e){return e%1==0}function ut(e){const t=Math.ceil(Math.sqrt(e));return[t,Math.ceil(e/t)]}function lt(e,t){return t<=e.length?e:e+" ".repeat(t-e.length)}function ct(e,t=(e=>0),n,r){return new Promise(((a,i)=>{let s=0;const o=()=>{if(e())return void a();s++;const u=t(s);null!=n&&s>=n?i():null!=r?r(o,u):setTimeout(o,u)};o()}))}function ht(e,t){let n=1,r=-1;for(let t=0;t<e.length;++t)if(e[t]>=0)n*=e[t];else if(-1===e[t]){if(-1!==r)throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${t}`);r=t}else if(e[t]<0)throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`);if(-1===r){if(t>0&&t!==n)throw Error(`Size(${t}) must match the product of shape ${e}`);return e}if(0===n)throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`);if(t%n!=0)throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`);const a=e.slice();return a[r]=t/n,a}function pt(e,t){const n=t.length;return nt((e=null==e?t.map(((e,t)=>t)):[].concat(e)).every((e=>e>=-n&&e<n)),(()=>`All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)),nt(e.every((e=>ot(e))),(()=>`All values in axis param must be integers but got axis ${e}`)),e.map((e=>e<0?n+e:e))}function dt(e,t){const n=[],r=[],a=null!=t&&Array.isArray(t)&&0===t.length,i=null==t||a?null:pt(t,e).sort();let s=0;for(let t=0;t<e.length;++t){if(null!=i){if(i[s]===t&&1!==e[t])throw new Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`);(null==i[s]||i[s]>t)&&1===e[t]&&(n.push(e[t]),r.push(t)),i[s]<=t&&s++}1!==e[t]&&(n.push(e[t]),r.push(t))}return{newShape:n,keptDims:r}}function ft(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else{if("bool"!==e)throw new Error(`Unknown data type ${e}`);n=new Uint8Array(t)}return n}function mt(e,t){let n=null;if(null==e||"float32"===e)n=new Float32Array(t);else if("int32"===e)n=new Int32Array(t);else if("bool"===e)n=new Uint8Array(t);else{if("string"!==e)throw new Error(`Unknown data type ${e}`);n=new Array(t)}return n}function gt(e,t){return!("complex64"===t||"float32"===t&&"complex64"!==e||"int32"===t&&"float32"!==e&&"complex64"!==e||"bool"===t&&"bool"===e)}function yt(e){if("float32"===e||"int32"===e)return 4;if("complex64"===e)return 8;if("bool"===e)return 1;throw new Error(`Unknown dtype ${e}`)}function bt(e){return"string"==typeof e||e instanceof String}function vt(e){return Array.isArray(e)?vt(e[0]):e instanceof Float32Array?"float32":e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray?"int32":"number"==typeof e?"float32":bt(e)?"string":function(e){return"boolean"==typeof e}(e)?"bool":"float32"}function wt(e){return!!(e&&e.constructor&&e.call&&e.apply)}function _t(e,t){for(let n=t;n<e;++n)if(e%n==0)return n;return e}function xt(e){const t=e.length;if(t<2)return[];const n=new Array(t-1);n[t-2]=e[t-1];for(let r=t-3;r>=0;--r)n[r]=n[r+1]*e[r+1];return n}function kt(e,t,n,r=!1){const a=new Array;if(1===t.length){const i=t[0]*(r?2:1);for(let t=0;t<i;t++)a[t]=n[e+t]}else{const i=t[0],s=t.slice(1),o=s.reduce(((e,t)=>e*t))*(r?2:1);for(let t=0;t<i;t++)a[t]=kt(e+t*o,s,n,r)}return a}function Tt(e,t,n=!1){if(0===e.length)return t[0];const r=e.reduce(((e,t)=>e*t))*(n?2:1);if(0===r)return[];if(r!==t.length)throw new Error(`[${e}] does not match the input size ${t.length}${n?" for a complex tensor":""}.`);return kt(0,e,t,n)}function Et(e,t){const n=St(e,t);for(let e=0;e<n.length;e++)n[e]=1;return n}function St(e,t){if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t)return new Uint8Array(e);throw new Error(`Unknown data type ${t}`)}function It(e){e.forEach((t=>{nt(Number.isInteger(t)&&t>=0,(()=>`Tensor must have a shape comprised of positive integers but got shape [${e}].`))}))}function At(e,t,n){if(0===t)return 0;if(1===t)return e[0];let r=e[e.length-1];for(let t=0;t<e.length-1;++t)r+=n[t]*e[t];return r}function Ct(e,t,n){if(0===t)return[];if(1===t)return[e];const r=new Array(t);for(let t=0;t<r.length-1;++t)r[t]=Math.floor(e/n[t]),e-=r[t]*n[t];return r[r.length-1]=e,r}function Nt(e){return e&&e.then&&"function"==typeof e.then}const Rt="tfjsflags";class Ft{constructor(e){this.global=e,this.flags={},this.flagRegistry={},this.urlFlags={},this.getQueryParams=Ot,this.populateURLFlags()}setPlatform(e,t){null!=this.platform&&(Mt().getBool("IS_TEST")||Mt().getBool("PROD")||console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)),this.platformName=e,this.platform=t}registerFlag(e,t,n){if(this.flagRegistry[e]={evaluationFn:t,setHook:n},null!=this.urlFlags[e]){const t=this.urlFlags[e];Mt().getBool("IS_TEST")||Mt().getBool("PROD")||console.warn(`Setting feature override from URL ${e}: ${t}.`),this.set(e,t)}}async getAsync(e){return e in this.flags||(this.flags[e]=await this.evaluateFlag(e)),this.flags[e]}get(e){if(e in this.flags)return this.flags[e];const t=this.evaluateFlag(e);if(Nt(t))throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`);return this.flags[e]=t,this.flags[e]}getNumber(e){return this.get(e)}getBool(e){return this.get(e)}getFlags(){return this.flags}get features(){return this.flags}set(e,t){if(null==this.flagRegistry[e])throw new Error(`Cannot set flag ${e} as it has not been registered.`);this.flags[e]=t,null!=this.flagRegistry[e].setHook&&this.flagRegistry[e].setHook(t)}evaluateFlag(e){if(null==this.flagRegistry[e])throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`);return this.flagRegistry[e].evaluationFn()}setFlags(e){this.flags=Object.assign({},e)}reset(){this.flags={},this.urlFlags={},this.populateURLFlags()}populateURLFlags(){if(void 0===this.global||void 0===this.global.location||void 0===this.global.location.search)return;const e=this.getQueryParams(this.global.location.search);Rt in e&&e[Rt].split(",").forEach((e=>{const[t,n]=e.split(":");this.urlFlags[t]=function(e,t){if("true"===(t=t.toLowerCase())||"false"===t)return"true"===t;if(""+ +t===t)return+t;throw new Error(`Could not parse value flag value ${t} for flag ${e}.`)}(t,n)}))}}function Ot(e){const t={};return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g,((e,...n)=>(function(e,t,n){e[decodeURIComponent(t)]=decodeURIComponent(n||"")}(t,n[0],n[1]),n.join("=")))),t}function Mt(){return Dt}let $t,Dt=null;function Pt(){if(null==$t){let e;if("undefined"!=typeof window)e=window;else if(void 0!==Te)e=Te;else if(void 0!==Xe)e=Xe;else{if("undefined"==typeof self)throw new Error("Could not find a global object");e=self}$t=e}return $t}function Lt(e,t){const n=function(){const e=Pt();return null==e._tfGlobals&&(e._tfGlobals=new Map),e._tfGlobals}();if(n.has(e))return n.get(e);{const r=t();return n.set(e,r),n.get(e)}}const Bt="Add",Ut="AddN",Wt="All",Vt="Any",zt="ArgMax",jt="AvgPool",Gt="BatchMatMul",Ht="BatchToSpaceND",Kt="Cast",qt="Ceil",Xt="ClipByValue",Yt="Concat",Qt="Conv2D",Jt="Conv2DBackpropInput",Zt="Cosh",en="Cumprod",tn="Cumsum",nn="CropAndResize",rn="DepthToSpace",an="DepthwiseConv2dNative",sn="RealDiv",on="Elu",un="Equal",ln="Exp",cn="ExpandDims",hn="Fill",pn="FlipLeftRight",dn="Floor",fn="FloorDiv",mn="FusedBatchNorm",gn="GatherV2",yn="GatherNd",bn="Greater",vn="GreaterEqual",wn="Identity",_n="IsNan",xn="LeakyRelu",kn="Less",Tn="LessEqual",En="LogicalAnd",Sn="LogicalNot",In="LogicalOr",An="Max",Cn="Maximum",Nn="MaxPool",Rn="Mean",Fn="Min",On="Minimum",Mn="MirrorPad",$n="Multiply",Dn="NotEqual",Pn="NonMaxSuppressionV3",Ln="NonMaxSuppressionV4",Bn="NonMaxSuppressionV5",Un="OnesLike",Wn="OneHot",Vn="Pack",zn="PadV2",jn="Prelu",Gn="Prod",Hn="Range",Kn="Reciprocal",qn="Relu",Xn="Reshape",Yn="ResizeNearestNeighbor",Qn="ResizeBilinear",Jn="Relu6",Zn="Reverse",er="Round",tr="Rsqrt",nr="ScatterNd",rr="Select",ar="Slice",ir="Sigmoid",sr="Sqrt",or="Sum",ur="SpaceToBatchND",lr="SplitV",cr="Softmax",hr="SparseFillEmptyRows",pr="SparseReshape",dr="SparseSegmentMean",fr="SparseSegmentSum",mr="SquaredDifference",gr="StridedSlice",yr="StringNGrams",br="StringSplit",vr="StringToHashBucketFast",wr="Sub",_r="Tanh",xr="Tile",kr="TopK",Tr="Transform",Er="Transpose",Sr="Unpack",Ir="ZerosLike",Ar="Step",Cr="FromPixels",Nr="RotateWithOffset",Rr="_FusedMatMul",Fr="FusedConv2D",Or="FusedDepthwiseConv2D";function Mr(...e){Mt().getBool("IS_TEST")||Mt().getBool("PROD")||console.warn(...e)}const $r=Lt("kernelRegistry",(()=>new Map)),Dr=Lt("gradRegistry",(()=>new Map));function Pr(e,t){const n=Wr(e,t);return $r.get(n)}function Lr(e){return Dr.get(e)}function Br(e){const t=$r.entries(),n=[];for(;;){const{done:r,value:a}=t.next();if(r)break;const[i,s]=a,[o]=i.split("_");o===e&&n.push(s)}return n}function Ur(e){const{kernelName:t,backendName:n}=e,r=Wr(t,n);$r.has(r)&&Mr(`The kernel '${t}' for backend '${n}' is already registered`),$r.set(r,e)}function Wr(e,t){return`${t}_${e}`}var Vr=jr,zr=null;try{zr=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch(o){}function jr(e,t,n){this.low=0|e,this.high=0|t,this.unsigned=!!n}function Gr(e){return!0===(e&&e.__isLong__)}jr.prototype.__isLong__,Object.defineProperty(jr.prototype,"__isLong__",{value:!0}),jr.isLong=Gr;var Hr={},Kr={};function qr(e,t){var n,r,a;return t?(a=0<=(e>>>=0)&&e<256)&&(r=Kr[e])?r:(n=Yr(e,(0|e)<0?-1:0,!0),a&&(Kr[e]=n),n):(a=-128<=(e|=0)&&e<128)&&(r=Hr[e])?r:(n=Yr(e,e<0?-1:0,!1),a&&(Hr[e]=n),n)}function Xr(e,t){if(isNaN(e))return t?ia:aa;if(t){if(e<0)return ia;if(e>=ta)return ca}else{if(e<=-na)return ha;if(e+1>=na)return la}return e<0?Xr(-e,t).neg():Yr(e%ea|0,e/ea|0,t)}function Yr(e,t,n){return new jr(e,t,n)}jr.fromInt=qr,jr.fromNumber=Xr,jr.fromBits=Yr;var Qr=Math.pow;function Jr(e,t,n){if(0===e.length)throw Error("empty string");if("NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return aa;if("number"==typeof t?(n=t,t=!1):t=!!t,(n=n||10)<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(0===r)return Jr(e.substring(1),t,n).neg();for(var a=Xr(Qr(n,8)),i=aa,s=0;s<e.length;s+=8){var o=Math.min(8,e.length-s),u=parseInt(e.substring(s,s+o),n);if(o<8){var l=Xr(Qr(n,o));i=i.mul(l).add(Xr(u))}else i=(i=i.mul(a)).add(Xr(u))}return i.unsigned=t,i}function Zr(e,t){return"number"==typeof e?Xr(e,t):"string"==typeof e?Jr(e,t):Yr(e.low,e.high,"boolean"==typeof t?t:e.unsigned)}jr.fromString=Jr,jr.fromValue=Zr;var ea=4294967296,ta=ea*ea,na=ta/2,ra=qr(1<<24),aa=qr(0);jr.ZERO=aa;var ia=qr(0,!0);jr.UZERO=ia;var sa=qr(1);jr.ONE=sa;var oa=qr(1,!0);jr.UONE=oa;var ua=qr(-1);jr.NEG_ONE=ua;var la=Yr(-1,2147483647,!1);jr.MAX_VALUE=la;var ca=Yr(-1,-1,!0);jr.MAX_UNSIGNED_VALUE=ca;var ha=Yr(0,-2147483648,!1);jr.MIN_VALUE=ha;var pa=jr.prototype;pa.toInt=function(){return this.unsigned?this.low>>>0:this.low},pa.toNumber=function(){return this.unsigned?(this.high>>>0)*ea+(this.low>>>0):this.high*ea+(this.low>>>0)},pa.toString=function(e){if((e=e||10)<2||36<e)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative()){if(this.eq(ha)){var t=Xr(e),n=this.div(t),r=n.mul(t).sub(this);return n.toString(e)+r.toInt().toString(e)}return"-"+this.neg().toString(e)}for(var a=Xr(Qr(e,6),this.unsigned),i=this,s="";;){var o=i.div(a),u=(i.sub(o.mul(a)).toInt()>>>0).toString(e);if((i=o).isZero())return u+s;for(;u.length<6;)u="0"+u;s=""+u+s}},pa.getHighBits=function(){return this.high},pa.getHighBitsUnsigned=function(){return this.high>>>0},pa.getLowBits=function(){return this.low},pa.getLowBitsUnsigned=function(){return this.low>>>0},pa.getNumBitsAbs=function(){if(this.isNegative())return this.eq(ha)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&0==(e&1<<t);t--);return 0!=this.high?t+33:t+1},pa.isZero=function(){return 0===this.high&&0===this.low},pa.eqz=pa.isZero,pa.isNegative=function(){return!this.unsigned&&this.high<0},pa.isPositive=function(){return this.unsigned||this.high>=0},pa.isOdd=function(){return 1==(1&this.low)},pa.isEven=function(){return 0==(1&this.low)},pa.equals=function(e){return Gr(e)||(e=Zr(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&this.high===e.high&&this.low===e.low},pa.eq=pa.equals,pa.notEquals=function(e){return!this.eq(e)},pa.neq=pa.notEquals,pa.ne=pa.notEquals,pa.lessThan=function(e){return this.comp(e)<0},pa.lt=pa.lessThan,pa.lessThanOrEqual=function(e){return this.comp(e)<=0},pa.lte=pa.lessThanOrEqual,pa.le=pa.lessThanOrEqual,pa.greaterThan=function(e){return this.comp(e)>0},pa.gt=pa.greaterThan,pa.greaterThanOrEqual=function(e){return this.comp(e)>=0},pa.gte=pa.greaterThanOrEqual,pa.ge=pa.greaterThanOrEqual,pa.compare=function(e){if(Gr(e)||(e=Zr(e)),this.eq(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},pa.comp=pa.compare,pa.negate=function(){return!this.unsigned&&this.eq(ha)?ha:this.not().add(sa)},pa.neg=pa.negate,pa.add=function(e){Gr(e)||(e=Zr(e));var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,a=65535&this.low,i=e.high>>>16,s=65535&e.high,o=e.low>>>16,u=0,l=0,c=0,h=0;return c+=(h+=a+(65535&e.low))>>>16,l+=(c+=r+o)>>>16,u+=(l+=n+s)>>>16,u+=t+i,Yr((c&=65535)<<16|(h&=65535),(u&=65535)<<16|(l&=65535),this.unsigned)},pa.subtract=function(e){return Gr(e)||(e=Zr(e)),this.add(e.neg())},pa.sub=pa.subtract,pa.multiply=function(e){if(this.isZero())return aa;if(Gr(e)||(e=Zr(e)),zr)return Yr(zr.mul(this.low,this.high,e.low,e.high),zr.get_high(),this.unsigned);if(e.isZero())return aa;if(this.eq(ha))return e.isOdd()?ha:aa;if(e.eq(ha))return this.isOdd()?ha:aa;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(ra)&&e.lt(ra))return Xr(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,n=65535&this.high,r=this.low>>>16,a=65535&this.low,i=e.high>>>16,s=65535&e.high,o=e.low>>>16,u=65535&e.low,l=0,c=0,h=0,p=0;return h+=(p+=a*u)>>>16,c+=(h+=r*u)>>>16,h&=65535,c+=(h+=a*o)>>>16,l+=(c+=n*u)>>>16,c&=65535,l+=(c+=r*o)>>>16,c&=65535,l+=(c+=a*s)>>>16,l+=t*u+n*o+r*s+a*i,Yr((h&=65535)<<16|(p&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},pa.mul=pa.multiply,pa.divide=function(e){if(Gr(e)||(e=Zr(e)),e.isZero())throw Error("division by zero");var t,n,r;if(zr)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?Yr((this.unsigned?zr.div_u:zr.div_s)(this.low,this.high,e.low,e.high),zr.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?ia:aa;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return ia;if(e.gt(this.shru(1)))return oa;r=ia}else{if(this.eq(ha))return e.eq(sa)||e.eq(ua)?ha:e.eq(ha)?sa:(t=this.shr(1).div(e).shl(1)).eq(aa)?e.isNegative()?sa:ua:(n=this.sub(e.mul(t)),r=t.add(n.div(e)));if(e.eq(ha))return this.unsigned?ia:aa;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=aa}for(n=this;n.gte(e);){t=Math.max(1,Math.floor(n.toNumber()/e.toNumber()));for(var a=Math.ceil(Math.log(t)/Math.LN2),i=a<=48?1:Qr(2,a-48),s=Xr(t),o=s.mul(e);o.isNegative()||o.gt(n);)o=(s=Xr(t-=i,this.unsigned)).mul(e);s.isZero()&&(s=sa),r=r.add(s),n=n.sub(o)}return r},pa.div=pa.divide,pa.modulo=function(e){return Gr(e)||(e=Zr(e)),zr?Yr((this.unsigned?zr.rem_u:zr.rem_s)(this.low,this.high,e.low,e.high),zr.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},pa.mod=pa.modulo,pa.rem=pa.modulo,pa.not=function(){return Yr(~this.low,~this.high,this.unsigned)},pa.and=function(e){return Gr(e)||(e=Zr(e)),Yr(this.low&e.low,this.high&e.high,this.unsigned)},pa.or=function(e){return Gr(e)||(e=Zr(e)),Yr(this.low|e.low,this.high|e.high,this.unsigned)},pa.xor=function(e){return Gr(e)||(e=Zr(e)),Yr(this.low^e.low,this.high^e.high,this.unsigned)},pa.shiftLeft=function(e){return Gr(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Yr(this.low<<e,this.high<<e|this.low>>>32-e,this.unsigned):Yr(0,this.low<<e-32,this.unsigned)},pa.shl=pa.shiftLeft,pa.shiftRight=function(e){return Gr(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Yr(this.low>>>e|this.high<<32-e,this.high>>e,this.unsigned):Yr(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},pa.shr=pa.shiftRight,pa.shiftRightUnsigned=function(e){if(Gr(e)&&(e=e.toInt()),0==(e&=63))return this;var t=this.high;return e<32?Yr(this.low>>>e|t<<32-e,t>>>e,this.unsigned):Yr(32===e?t:t>>>e-32,0,this.unsigned)},pa.shru=pa.shiftRightUnsigned,pa.shr_u=pa.shiftRightUnsigned,pa.toSigned=function(){return this.unsigned?Yr(this.low,this.high,!1):this},pa.toUnsigned=function(){return this.unsigned?this:Yr(this.low,this.high,!0)},pa.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},pa.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},pa.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},jr.fromBytes=function(e,t,n){return n?jr.fromBytesLE(e,t):jr.fromBytesBE(e,t)},jr.fromBytesLE=function(e,t){return new jr(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},jr.fromBytesBE=function(e,t){return new jr(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)};const da=Vr||o({__proto__:null,default:Vr},[Vr]);function fa(e){return da.fromString(e,!0,16)}const ma=fa("c3a5c85c97cb3127"),ga=fa("b492b66fbe98f273"),ya=fa("9ae16a3b2f90404f");function ba(e){return e.xor(e.shru(47))}function va(e,t,n){const r=e.slice(t,t+n);return da.fromBytes(Array.from(r),!0,!0)}function wa(e,t){return va(e,t,8)}function _a(e,t){return va(e,t,4)}function xa(e,t){return 0===t?e:e.shru(t).or(e.shl(64-t))}function ka(e,t,n=fa("9ddfea08eb382d69")){let r=e.xor(t).mul(n);r=r.xor(r.shru(47));let a=t.xor(r).mul(n);return a=a.xor(a.shru(47)),a=a.mul(n),a}function Ta(e,t,n,r){return function(e,t,n,r,a,i){a=a.add(e),i=xa(i.add(a).add(r),21);const s=a;return a=(a=a.add(t)).add(n),i=i.add(xa(a,44)),[a.add(r),i.add(s)]}(wa(e,t),wa(e,t+8),wa(e,t+16),wa(e,t+24),n,r)}function Ea(e,t=e.length){const n=da.fromNumber(81,!0);if(t<=32)return t<=16?function(e,t=e.length){if(t>=8){const n=ya.add(2*t),r=wa(e,0).add(ya),a=wa(e,t-8);return ka(xa(a,37).mul(n).add(r),xa(r,25).add(a).mul(n),n)}if(t>=4){const n=ya.add(2*t);return ka(_a(e,0).shl(3).add(t),_a(e,t-4),n)}if(t>0){const n=e[0]+(e[t>>1]<<8),r=t+(e[t-1]<<2);return ba(ya.mul(n).xor(ma.mul(r))).mul(ya)}return ya}(e,t):function(e,t=e.length){const n=ya.add(2*t),r=wa(e,0).mul(ga),a=wa(e,8),i=wa(e,t-8).mul(n),s=wa(e,t-16).mul(ya);return ka(xa(r.add(a),43).add(xa(i,30)).add(s),r.add(xa(a.add(ya),18)).add(i),n)}(e,t);if(t<=64)return function(e,t=e.length){const n=ya.add(2*t),r=wa(e,0).mul(ya),a=wa(e,8),i=wa(e,t-8).mul(n),s=wa(e,t-16).mul(ya),o=xa(r.add(a),43).add(xa(i,30)).add(s),u=ka(o,r.add(xa(a.add(ya),18)).add(i),n),l=wa(e,16).mul(n),c=wa(e,24),h=o.add(wa(e,t-32)).mul(n),p=u.add(wa(e,t-24)).mul(n);return ka(xa(l.add(c),43).add(xa(h,30)).add(p),l.add(xa(c.add(r),18)).add(h),n)}(e,t);let r=n,a=n.mul(ga).add(113),i=ba(a.mul(ya).add(113)).mul(ya),s=[da.UZERO,da.UZERO],o=[da.UZERO,da.UZERO];r=r.mul(ya).add(wa(e,0));let u=0;const l=64*(t-1>>6),c=l+(t-1&63)-63;do{r=xa(r.add(a).add(s[0]).add(wa(e,u+8)),37).mul(ga),a=xa(a.add(s[1]).add(wa(e,u+48)),42).mul(ga),r=r.xor(o[1]),a=a.add(s[0]).add(wa(e,u+40)),i=xa(i.add(o[0]),33).mul(ga),s=Ta(e,u,s[1].mul(ga),r.add(o[0])),o=Ta(e,u+32,i.add(o[1]),a.add(wa(e,u+16))),[i,r]=[r,i],u+=64}while(u!==l);const h=ga.add(i.and(255).shl(1));return u=c,o[0]=o[0].add(t-1&63),s[0]=s[0].add(o[0]),o[0]=o[0].add(s[0]),r=xa(r.add(a).add(s[0]).add(wa(e,u+8)),37).mul(h),a=xa(a.add(s[1]).add(wa(e,u+48)),42).mul(h),r=r.xor(o[1].mul(9)),a=a.add(s[0].mul(9).add(wa(e,u+40))),i=xa(i.add(o[0]),33).mul(h),s=Ta(e,u,s[1].mul(h),r.add(o[0])),o=Ta(e,u+32,i.add(o[1]),a.add(wa(e,u+16))),[i,r]=[r,i],ka(ka(s[0],o[0],h).add(ba(a).mul(ma)).add(i),ka(s[1],o[1],h).add(r),h)}function Sa(e,t){return"string"===t?Ca(e):Ia([e],t)}function Ia(e,t){if("string"===t)throw new Error("Cannot convert a string[] to a TypedArray");if(Array.isArray(e)&&(e=Fa(e)),Mt().getBool("DEBUG")&&function(e,t){for(let n=0;n<e.length;n++){const r=e[n];if(isNaN(r)||!isFinite(r))throw Error(`A tensor of type ${t} being uploaded contains ${r}.`)}}(e,t),function(e,t){return e instanceof Float32Array&&"float32"===t||e instanceof Int32Array&&"int32"===t||e instanceof Uint8Array&&"bool"===t}(e,t))return e;if(null==t||"float32"===t||"complex64"===t)return new Float32Array(e);if("int32"===t)return new Int32Array(e);if("bool"===t){const t=new Uint8Array(e.length);for(let n=0;n<t.length;++n)0!==Math.round(e[n])&&(t[n]=1);return t}throw new Error(`Unknown data type ${t}`)}function Aa(){return Mt().platform.now()}function Ca(e,t="utf-8"){return t=t||"utf-8",Mt().platform.encode(e,t)}function Na(e,t="utf-8"){return t=t||"utf-8",Mt().platform.decode(e,t)}function Ra(e){return Mt().platform.isTypedArray(e)}function Fa(e,t=[],n=!1){if(null==t&&(t=[]),"boolean"==typeof e||"number"==typeof e||"string"==typeof e||Nt(e)||null==e||Ra(e)&&n)t.push(e);else if(Array.isArray(e)||Ra(e))for(let r=0;r<e.length;++r)Fa(e[r],t,n);else{let r=-1;for(const t of Object.keys(e))/^([1-9]+[0-9]*|0)$/.test(t)&&(r=Math.max(r,Number(t)));for(let a=0;a<=r;a++)Fa(e[a],t,n)}return t}class Oa{constructor(e,t){this.backendTimer=e,this.logger=t,null==t&&(this.logger=new $a)}profileKernel(e,t,n){let r;const a=()=>{r=n()};let i;const s=Aa();if(this.backendTimer.timerAvailable())i=this.backendTimer.time(a);else{a();for(const e of r)e.dataSync();i=Promise.resolve({kernelMs:Aa()-s})}if(Mt().getBool("CHECK_COMPUTATION_FOR_ERRORS"))for(let t=0;t<r.length;t++){const n=r[t];n.data().then((t=>{Ma(t,n.dtype,e)}))}return{kernelName:e,outputs:r,inputs:t,timeMs:i.then((e=>e.kernelMs)),extraInfo:i.then((e=>null!=e.getExtraProfileInfo?e.getExtraProfileInfo():""))}}logKernelProfile(e){const{kernelName:t,outputs:n,timeMs:r,inputs:a,extraInfo:i}=e;n.forEach((e=>{Promise.all([e.data(),r,i]).then((n=>{this.logger.logKernelProfile(t,e,n[0],n[1],a,n[2])}))}))}}function Ma(e,t,n){if("float32"!==t)return!1;for(let t=0;t<e.length;t++){const r=e[t];if(isNaN(r)||!isFinite(r))return console.warn(`Found ${r} in the result of '${n}'`),!0}return!1}class $a{logKernelProfile(e,t,n,r,a,i){const s="number"==typeof r?lt(`${r}ms`,9):r.error,o=lt(e,25),u=t.rank,l=t.size,c=lt(t.shape.toString(),14);let h="";for(const e in a){const n=a[e];if(null!=n){const r=n.shape||t.shape,a=r.length;h+=`${e}: ${a}D ${a>0?r:""} `}}console.log(`%c${o}\t%c${s}\t%c${u}D ${c}\t%c${l}\t%c${h}\t%c${i}`,"font-weight:bold","color:red","color:blue","color: orange","color: green","color: steelblue")}}const Da=20,Pa=3,La=7;function Ba(e,t,n,r){const a=xt(t),i=function(e,t,n,r){const a=it(t),i=r[r.length-1],s=new Array(i).fill(0),o=t.length,u="complex64"===n?za(e):e;if(o>1)for(let e=0;e<a/i;e++){const t=e*i;for(let e=0;e<i;e++)s[e]=Math.max(s[e],Ua(u[t+e],0,n).length)}return s}(e,t,n,a),s=t.length,o=Va(e,t,n,a,i),u=["Tensor"];return r&&(u.push(` dtype: ${n}`),u.push(` rank: ${s}`),u.push(` shape: [${t}]`),u.push(" values:")),u.push(o.map((e=>" "+e)).join("\n")),u.join("\n")}function Ua(e,t,n){let r;return r=Array.isArray(e)?`${parseFloat(e[0].toFixed(La))} + ${parseFloat(e[1].toFixed(La))}j`:bt(e)?`'${e}'`:"bool"===n?Wa(e):parseFloat(e.toFixed(La)).toString(),lt(r,t)}function Wa(e){return 0===e?"false":"true"}function Va(e,t,n,r,a,i=!0){const s="complex64"===n?2:1,o=t[0],u=t.length;if(0===u)return"complex64"===n?[Ua(za(e)[0],0,n)]:"bool"===n?[Wa(e[0])]:[e[0].toString()];if(1===u){if(o>Da){const t=Pa*s;let r=Array.from(e.slice(0,t)),i=Array.from(e.slice((o-Pa)*s,o*s));return"complex64"===n&&(r=za(r),i=za(i)),["["+r.map(((e,t)=>Ua(e,a[t],n))).join(", ")+", ..., "+i.map(((e,t)=>Ua(e,a[o-Pa+t],n))).join(", ")+"]"]}return["["+("complex64"===n?za(e):Array.from(e)).map(((e,t)=>Ua(e,a[t],n))).join(", ")+"]"]}const l=t.slice(1),c=r.slice(1),h=r[0]*s,p=[];if(o>Da){for(let t=0;t<Pa;t++){const r=t*h,i=r+h;p.push(...Va(e.slice(r,i),l,n,c,a,!1))}p.push("...");for(let t=o-Pa;t<o;t++){const r=t*h,i=r+h;p.push(...Va(e.slice(r,i),l,n,c,a,t===o-1))}}else for(let t=0;t<o;t++){const r=t*h,i=r+h;p.push(...Va(e.slice(r,i),l,n,c,a,t===o-1))}const d=2===u?",":"";p[0]="["+(o>0?p[0]+d:"");for(let e=1;e<p.length-1;e++)p[e]=" "+p[e]+d;let f=",\n";for(let e=2;e<u;e++)f+="\n";return p[p.length-1]=" "+p[p.length-1]+"]"+(i?"":f),p}function za(e){const t=[];for(let n=0;n<e.length;n+=2)t.push([e[n],e[n+1]]);return t}class ja{constructor(e,t,n){if(this.dtype=t,this.shape=e.slice(),this.size=it(e),null!=n){const e=n.length;nt(e===this.size,(()=>`Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`))}if("complex64"===t)throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag).");this.values=n||mt(t,this.size),this.strides=xt(e)}set(e,...t){0===t.length&&(t=[0]),nt(t.length===this.rank,(()=>`The number of provided coordinates (${t.length}) must match the rank (${this.rank})`));const n=this.locToIndex(t);this.values[n]=e}get(...e){0===e.length&&(e=[0]);let t=0;for(const n of e){if(n<0||n>=this.shape[t]){const t=`Requested out of range element at ${e}. Buffer shape=${this.shape}`;throw new Error(t)}t++}let n=e[e.length-1];for(let t=0;t<e.length-1;++t)n+=this.strides[t]*e[t];return this.values[n]}locToIndex(e){if(0===this.rank)return 0;if(1===this.rank)return e[0];let t=e[e.length-1];for(let n=0;n<e.length-1;++n)t+=this.strides[n]*e[n];return t}indexToLoc(e){if(0===this.rank)return[];if(1===this.rank)return[e];const t=new Array(this.shape.length);for(let n=0;n<t.length-1;++n)t[n]=Math.floor(e/this.strides[n]),e-=t[n]*this.strides[n];return t[t.length-1]=e,t}get rank(){return this.shape.length}toTensor(){return Ga().makeTensor(this.values,this.shape,this.dtype)}}let Ga=null,Ha=null;class Ka{constructor(e,t,n,r){this.kept=!1,this.isDisposedInternal=!1,this.shape=e.slice(),this.dtype=t||"float32",this.size=it(e),this.strides=xt(e),this.dataId=n,this.id=r,this.rankType=this.rank<5?this.rank.toString():"higher"}get rank(){return this.shape.length}async buffer(){const e=await this.data();return Ha.buffer(this.shape,this.dtype,e)}bufferSync(){return Ha.buffer(this.shape,this.dtype,this.dataSync())}async array(){const e=await this.data();return Tt(this.shape,e,"complex64"===this.dtype)}arraySync(){return Tt(this.shape,this.dataSync(),"complex64"===this.dtype)}async data(){this.throwIfDisposed();const e=Ga().read(this.dataId);if("string"===this.dtype){const t=await e;try{return t.map((e=>Na(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}}return e}dataToGPU(e){return this.throwIfDisposed(),Ga().readToGPU(this.dataId,e)}dataSync(){this.throwIfDisposed();const e=Ga().readSync(this.dataId);if("string"===this.dtype)try{return e.map((e=>Na(e)))}catch(e){throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().")}return e}async bytes(){this.throwIfDisposed();const e=await Ga().read(this.dataId);return"string"===this.dtype?e:new Uint8Array(e.buffer)}dispose(){this.isDisposed||(Ga().disposeTensor(this),this.isDisposedInternal=!0)}get isDisposed(){return this.isDisposedInternal}throwIfDisposed(){if(this.isDisposed)throw new Error("Tensor is disposed.")}print(e=!1){return Ha.print(this,e)}clone(){return this.throwIfDisposed(),Ha.clone(this)}toString(e=!1){return Ba(this.dataSync(),this.shape,this.dtype,e)}cast(e){return this.throwIfDisposed(),Ha.cast(this,e)}variable(e=!0,t,n){return this.throwIfDisposed(),Ga().makeVariable(this,e,t,n)}}Object.defineProperty(Ka,Symbol.hasInstance,{value:e=>!!e&&null!=e.data&&null!=e.dataSync&&null!=e.throwIfDisposed}),Lt("Tensor",(()=>Ka));class qa extends Ka{constructor(e,t,n,r){super(e.shape,e.dtype,e.dataId,r),this.trainable=t,this.name=n}assign(e){if(e.dtype!==this.dtype)throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`);if(!st(e.shape,this.shape))throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`);Ga().disposeTensor(this),this.dataId=e.dataId,Ga().incRef(this,null)}dispose(){Ga().disposeVariable(this),this.isDisposedInternal=!0}}var Xa,Ya,Qa,Ja,Za;Object.defineProperty(qa,Symbol.hasInstance,{value:e=>e instanceof Ka&&null!=e.assign&&e.assign instanceof Function}),function(e){e.R0="R0",e.R1="R1",e.R2="R2",e.R3="R3",e.R4="R4",e.R5="R5",e.R6="R6"}(Xa||(Xa={})),function(e){e.float32="float32",e.int32="int32",e.bool="int32",e.complex64="complex64"}(Ya||(Ya={})),function(e){e.float32="float32",e.int32="int32",e.bool="bool",e.complex64="complex64"}(Qa||(Qa={})),function(e){e.float32="float32",e.int32="float32",e.bool="float32",e.complex64="complex64"}(Ja||(Ja={})),function(e){e.float32="complex64",e.int32="complex64",e.bool="complex64",e.complex64="complex64"}(Za||(Za={}));const ei={float32:Ja,int32:Ya,bool:Qa,complex64:Za};function ti(e,t){if("string"===e||"string"===t){if("string"===e&&"string"===t)return"string";throw new Error(`Can not upcast ${e} with ${t}`)}return ei[e][t]}function ni(e,t){if(e.dtype===t.dtype)return[e,t];const n=ti(e.dtype,t.dtype);return[e.cast(n),t.cast(n)]}function ri(e){const t=[];return ai(e,t,new Set),t}function ai(e,t,n){if(null==e)return;if(e instanceof Ka)return void t.push(e);if(r=e,!Array.isArray(r)&&"object"!=typeof r)return;var r;const a=e;for(const e in a){const r=a[e];n.has(r)||(n.add(r),ai(r,t,n))}}function ii(e){return null!=e.kernelName}class si{constructor(){this.registeredVariables={},this.nextTapeNodeId=0,this.numBytes=0,this.numTensors=0,this.numStringTensors=0,this.numDataBuffers=0,this.gradientDepth=0,this.kernelDepth=0,this.scopeStack=[],this.numDataMovesStack=[],this.nextScopeId=0,this.tensorInfo=new WeakMap,this.profiling=!1,this.activeProfile={newBytes:0,newTensors:0,peakBytes:0,kernels:[],result:null,get kernelNames(){return Array.from(new Set(this.kernels.map((e=>e.name))))}}}dispose(){for(const e in this.registeredVariables)this.registeredVariables[e].dispose()}}class oi{constructor(e){this.ENV=e,this.registry={},this.registryFactory={},this.pendingBackendInitId=0,this.state=new si}async ready(){if(null!=this.pendingBackendInit)return this.pendingBackendInit.then((()=>{}));if(null!=this.backendInstance)return;const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t];if(await this.initializeBackend(n).success)return void await this.setBackend(n)}throw new Error("Could not initialize any backends, all backend initializations failed.")}get backend(){if(null!=this.pendingBackendInit)throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);if(null==this.backendInstance){const{name:e,asyncInit:t}=this.initializeBackendsAndReturnBest();if(t)throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`);this.setBackend(e)}return this.backendInstance}backendNames(){return Object.keys(this.registryFactory)}findBackend(e){if(!(e in this.registry)){if(!(e in this.registryFactory))return null;{const{asyncInit:t}=this.initializeBackend(e);if(t)return null}}return this.registry[e]}findBackendFactory(e){return e in this.registryFactory?this.registryFactory[e].factory:null}registerBackend(e,t,n=1){return e in this.registryFactory?(Mr(`${e} backend was already registered. Reusing existing backend factory.`),!1):(this.registryFactory[e]={factory:t,priority:n},!0)}async setBackend(e){if(null==this.registryFactory[e])throw new Error(`Backend name '${e}' not found in registry`);if(this.backendName=e,null==this.registry[e]){this.backendInstance=null;const{success:t,asyncInit:n}=this.initializeBackend(e);if(!(n?await t:t))return!1}return this.backendInstance=this.registry[e],this.setupRegisteredKernels(),this.profiler=new Oa(this.backendInstance),!0}setupRegisteredKernels(){Br(this.backendName).forEach((e=>{null!=e.setupFunc&&e.setupFunc(this.backendInstance)}))}disposeRegisteredKernels(e){Br(e).forEach((t=>{null!=t.disposeFunc&&t.disposeFunc(this.registry[e])}))}initializeBackend(e){const t=this.registryFactory[e];if(null==t)throw new Error(`Cannot initialize backend ${e}, no registration found.`);try{const n=t.factory();if(!n||n instanceof Qe||"function"!=typeof n.then)return this.registry[e]=n,{success:!0,asyncInit:!1};{const t=++this.pendingBackendInitId,r=n.then((n=>!(t<this.pendingBackendInitId||(this.registry[e]=n,this.pendingBackendInit=null,0)))).catch((n=>(t<this.pendingBackendInitId||(this.pendingBackendInit=null,Mr(`Initialization of backend ${e} failed`),Mr(n.stack||n.message)),!1)));return this.pendingBackendInit=r,{success:r,asyncInit:!0}}}catch(t){return Mr(`Initialization of backend ${e} failed`),Mr(t.stack||t.message),{success:!1,asyncInit:!1}}}removeBackend(e){if(!(e in this.registryFactory))throw new Error(`${e} backend not found in registry`);this.backendName===e&&null!=this.pendingBackendInit&&this.pendingBackendInitId++,e in this.registry&&(this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e]),delete this.registryFactory[e],this.backendName===e&&(this.pendingBackendInit=null,this.backendName=null,this.backendInstance=null)}getSortedBackends(){if(0===Object.keys(this.registryFactory).length)throw new Error("No backend found in registry.");return Object.keys(this.registryFactory).sort(((e,t)=>this.registryFactory[t].priority-this.registryFactory[e].priority))}initializeBackendsAndReturnBest(){const e=this.getSortedBackends();for(let t=0;t<e.length;t++){const n=e[t],{success:r,asyncInit:a}=this.initializeBackend(n);if(a||r)return{name:n,asyncInit:a}}throw new Error("Could not initialize any backends, all backend initializations failed.")}moveData(e,t){const n=this.state.tensorInfo.get(t),r=n.backend,a=this.readSync(t),i=r.refCount(t);r.disposeData(t,!0),n.backend=e,e.move(t,a,n.shape,n.dtype,i),this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack[this.state.numDataMovesStack.length-1]++}tidy(e,t){let n,r=null;if(null==t){if("function"!=typeof e)throw new Error("Please provide a function to tidy()");t=e}else{if("string"!=typeof e&&!(e instanceof String))throw new Error("When calling with two arguments, the first argument to tidy() must be a string");if("function"!=typeof t)throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function");r=e}return this.scopedRun((()=>this.startScope(r)),(()=>this.endScope(n)),(()=>(n=t(),n instanceof Promise&&console.error("Cannot return a Promise inside of tidy."),n)))}scopedRun(e,t,n){e();try{const e=n();return t(),e}catch(e){throw t(),e}}nextTensorId(){return oi.nextTensorId++}nextVariableId(){return oi.nextVariableId++}clone(e){const t=li.runKernel(wn,{x:e}),n={x:e};return this.addTapeNode(this.state.activeScope.name,n,[t],(e=>({x:()=>{const t={x:e};return li.runKernel(Kt,t,{dtype:"float32"})}})),[],{}),t}runKernel(e,t,n){if(null==this.backendName&&this.backend,null==Pr(e,this.backendName))throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`);return this.runKernelFunc({kernelName:e,inputs:t,attrs:n})}shouldCheckForMemLeaks(){return this.ENV.getBool("IS_TEST")}checkKernelForMemLeak(e,t,n){const r=this.backend.numDataIds();let a=0;n.forEach((e=>{a+="complex64"===e.dtype?3:1}));const i=this.state.numDataMovesStack[this.state.numDataMovesStack.length-1],s=r-t-a-i;if(s>0)throw new Error(`Backend '${this.backendName}' has an internal memory leak (${s} data ids) after running '${e}'`)}runKernelFunc(e){let t,n=[];const r=this.isTapeOn(),a=this.state.numBytes,i=this.state.numTensors;let s,o;this.shouldCheckForMemLeaks()&&this.state.numDataMovesStack.push(0),null==this.backendName&&this.backend;const u=ii(e)?e.kernelName:null!=this.state.activeScope?this.state.activeScope.name:"";if(ii(e)){const{kernelName:t,inputs:a,attrs:i}=e;null==this.backendName&&this.backend;const u=Pr(t,this.backendName);nt(null!=u,(()=>`Cannot find registered kernel '${t}' for backend '${this.backendName}'`)),s=()=>{const e=this.backend.numDataIds();o=u.kernelFunc({inputs:a,attrs:i,backend:this.backend});const s=Array.isArray(o)?o:[o];this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(t,e,s);const l=s.map((e=>null!=e.rank?e:this.makeTensorFromTensorInfo(e)));if(r){const e=this.getTensorsForGradient(t,a,l);n=this.saveTensorsForBackwardMode(e)}return l}}else{const{forwardFunc:t}=e,a=e=>{r&&(n=e.map((e=>this.keep(this.clone(e)))))};s=()=>{const e=this.backend.numDataIds();o=this.tidy((()=>t(this.backend,a)));const n=Array.isArray(o)?o:[o];return this.shouldCheckForMemLeaks()&&this.checkKernelForMemLeak(u,e,n),n}}const{inputs:l,attrs:c}=e,h=ii(e)?null:e.backwardsFunc;let p;return this.scopedRun((()=>this.state.kernelDepth++),(()=>this.state.kernelDepth--),(()=>{this.ENV.getBool("DEBUG")||this.state.profiling?(p=this.profiler.profileKernel(u,l,(()=>s())),this.ENV.getBool("DEBUG")&&this.profiler.logKernelProfile(p),t=p.outputs):t=s()})),r&&this.addTapeNode(u,l,t,h,n,c),this.state.profiling&&this.state.activeProfile.kernels.push({name:u,bytesAdded:this.state.numBytes-a,totalBytesSnapshot:this.state.numBytes,tensorsAdded:this.state.numTensors-i,totalTensorsSnapshot:this.state.numTensors,inputShapes:Object.keys(l).map((e=>null!=l[e]?l[e].shape:null)),outputShapes:t.map((e=>e.shape)),kernelTimeMs:p.timeMs,extraInfo:p.extraInfo}),Array.isArray(o)?t:t[0]}saveTensorsForBackwardMode(e){return e.map((e=>this.keep(this.clone(e))))}getTensorsForGradient(e,t,n){const r=Lr(e);if(null!=r){const e=r.inputsToSave||[],a=r.outputsToSave||[];let i;r.saveAllInputs?(nt(Array.isArray(t),(()=>"saveAllInputs is true, expected inputs to be an array.")),i=Object.keys(t).map((e=>t[e]))):i=e.map((e=>t[e]));const s=n.filter(((e,t)=>a[t]));return i.concat(s)}return[]}makeTensor(e,t,n,r){if(null==e)throw new Error("Values passed to engine.makeTensor() are null");n=n||"float32",r=r||this.backend;let a=e;"string"===n&&bt(e[0])&&(a=e.map((e=>Ca(e))));const i=r.write(a,t,n),s=new Ka(t,n,i,this.nextTensorId());if(this.trackTensor(s,r),"string"===n){const e=this.state.tensorInfo.get(i),t=function(e){if(null==e)return 0;let t=0;return e.forEach((e=>t+=e.length)),t}(a);this.state.numBytes+=t-e.bytes,e.bytes=t}return s}makeTensorFromDataId(e,t,n,r){const a={dataId:e,shape:t,dtype:n=n||"float32"};return this.makeTensorFromTensorInfo(a,r)}makeTensorFromTensorInfo(e,t){const{dataId:n,shape:r,dtype:a}=e,i=new Ka(r,a,n,this.nextTensorId());return this.trackTensor(i,t),i}makeVariable(e,t=!0,n,r){n=n||this.nextVariableId().toString(),null!=r&&r!==e.dtype&&(e=e.cast(r));const a=new qa(e,t,n,this.nextTensorId());if(null!=this.state.registeredVariables[a.name])throw new Error(`Variable with name ${a.name} was already registered`);return this.state.registeredVariables[a.name]=a,this.incRef(a,this.backend),a}trackTensor(e,t){this.state.numTensors++,"string"===e.dtype&&this.state.numStringTensors++;let n=0;"complex64"!==e.dtype&&"string"!==e.dtype&&(n=e.size*yt(e.dtype)),this.state.numBytes+=n,this.state.tensorInfo.has(e.dataId)||(this.state.numDataBuffers++,this.state.tensorInfo.set(e.dataId,{backend:t||this.backend,dtype:e.dtype,shape:e.shape,bytes:n})),e instanceof qa||this.track(e)}incRef(e,t){this.trackTensor(e,t),this.backend.incRef(e.dataId)}removeDataId(e,t){this.state.tensorInfo.has(e)&&this.state.tensorInfo.get(e).backend===t&&(this.state.tensorInfo.delete(e),this.state.numDataBuffers--)}disposeTensor(e){if(!this.state.tensorInfo.has(e.dataId))return;const t=this.state.tensorInfo.get(e.dataId);if(this.state.numTensors--,"string"===e.dtype&&(this.state.numStringTensors--,this.state.numBytes-=t.bytes),"complex64"!==e.dtype&&"string"!==e.dtype){const t=e.size*yt(e.dtype);this.state.numBytes-=t}t.backend.disposeData(e.dataId)&&this.removeDataId(e.dataId,t.backend)}disposeVariables(){for(const e in this.state.registeredVariables){const t=this.state.registeredVariables[e];this.disposeVariable(t)}}disposeVariable(e){this.disposeTensor(e),null!=this.state.registeredVariables[e.name]&&delete this.state.registeredVariables[e.name]}memory(){const e=this.backend.memory();return e.numTensors=this.state.numTensors,e.numDataBuffers=this.state.numDataBuffers,e.numBytes=this.state.numBytes,this.state.numStringTensors>0&&(e.unreliable=!0,null==e.reasons&&(e.reasons=[]),e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")),e}async profile(e){this.state.profiling=!0;const t=this.state.numBytes,n=this.state.numTensors;this.state.activeProfile.kernels=[],this.state.activeProfile.result=await e(),this.state.profiling=!1,this.state.activeProfile.peakBytes=Math.max(...this.state.activeProfile.kernels.map((e=>e.totalBytesSnapshot))),this.state.activeProfile.newBytes=this.state.numBytes-t,this.state.activeProfile.newTensors=this.state.numTensors-n;for(const e of this.state.activeProfile.kernels)e.kernelTimeMs=await e.kernelTimeMs,e.extraInfo=await e.extraInfo;return this.state.activeProfile}isTapeOn(){return this.state.gradientDepth>0&&0===this.state.kernelDepth}addTapeNode(e,t,n,r,a,i){const s={id:this.state.nextTapeNodeId++,kernelName:e,inputs:t,outputs:n,saved:a},o=Lr(e);null!=o&&(r=o.gradFunc),null!=r&&(s.gradient=e=>(e=e.map(((e,t)=>{if(null==e){const e=n[t],r=St(e.size,e.dtype);return this.makeTensor(r,e.shape,e.dtype)}return e})),r(e.length>1?e:e[0],a,i))),this.state.activeTape.push(s)}keep(e){return e.kept=!0,e}startTape(){0===this.state.gradientDepth&&(this.state.activeTape=[]),this.state.gradientDepth++}endTape(){this.state.gradientDepth--}startScope(e){const t={track:[],name:"unnamed scope",id:this.state.nextScopeId++};e&&(t.name=e),this.state.scopeStack.push(t),this.state.activeScope=t}endScope(e){const t=ri(e),n=new Set(t.map((e=>e.id)));for(let e=0;e<this.state.activeScope.track.length;e++){const t=this.state.activeScope.track[e];t.kept||n.has(t.id)||t.dispose()}const r=this.state.scopeStack.pop();this.state.activeScope=0===this.state.scopeStack.length?null:this.state.scopeStack[this.state.scopeStack.length-1],t.forEach((e=>{e.kept||e.scopeId!==r.id||this.track(e)}))}gradients(e,t,n,r=!1){if(nt(t.length>0,(()=>"gradients() received an empty list of xs.")),null!=n&&"float32"!==n.dtype)throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`);const a=this.scopedRun((()=>this.startTape()),(()=>this.endTape()),(()=>this.tidy("forward",e)));nt(a instanceof Ka,(()=>"The result y returned by f() must be a tensor."));const i=function(e,t,n){const r={},a={};for(let e=0;e<t.length;e++)r[t[e].id]=!0;for(let n=0;n<e.length;n++){const i=e[n],s=i.inputs;for(const e in s){const n=s[e];let o=!1;for(let e=0;e<t.length;e++)if(r[n.id]){i.outputs.forEach((e=>r[e.id]=!0)),o=!0,a[i.id]=!0;break}if(o)break}}const i={};i[n.id]=!0;const s={};for(let t=e.length-1;t>=0;t--){const n=e[t],r=n.inputs;for(let e=0;e<n.outputs.length;e++)if(i[n.outputs[e].id]){for(const e in r)i[r[e].id]=!0,s[n.id]=!0;break}}const o=[];for(let t=0;t<e.length;t++){const n=e[t];if(a[n.id]&&s[n.id]){const e={};for(const t in n.inputs){const a=n.inputs[t];r[a.id]&&(e[t]=a)}const t=Object.assign({},n);t.inputs=e,t.outputs=n.outputs,o.push(t)}}return o}(this.state.activeTape,t,a);if(!r&&0===i.length&&t.length>0)throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.");return this.tidy("backward",(()=>{const e={};e[a.id]=null==n?function(e){const t=Et(it(e),"float32");return li.makeTensor(t,e,"float32")}(a.shape):n,function(e,t,n,r){for(let a=t.length-1;a>=0;a--){const i=t[a],s=[];if(i.outputs.forEach((t=>{const n=e[t.id];null!=n?s.push(n):s.push(null)})),null==i.gradient)throw new Error(`Cannot compute gradient: gradient function not found for ${i.kernelName}.`);const o=i.gradient(s);for(const t in i.inputs){if(!(t in o))throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(o)}.`);const a=n((()=>o[t]()));if("float32"!==a.dtype)throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${a.dtype}'`);const s=i.inputs[t];if(!st(a.shape,s.shape))throw new Error(`Error in gradient for op ${i.kernelName}. The gradient of input '${t}' has shape '${a.shape}', which does not match the shape of the input '${s.shape}'`);if(null==e[s.id])e[s.id]=a;else{const t=e[s.id];e[s.id]=r(t,a),t.dispose()}}}}(e,i,(e=>this.tidy(e)),ci);const r=t.map((t=>e[t.id]));return 0===this.state.gradientDepth&&(this.state.activeTape.forEach((e=>{for(const t of e.saved)t.dispose()})),this.state.activeTape=null),{value:a,grads:r}}))}customGrad(e){return nt(wt(e),(()=>"The f passed in customGrad(f) must be a function.")),(...t)=>{let n;nt(t.every((e=>e instanceof Ka)),(()=>"The args passed in customGrad(f)(x1, x2,...) must all be tensors"));const r={};return t.forEach(((e,t)=>{r[t]=e})),this.runKernelFunc({forwardFunc:(r,a)=>(n=e(...t,a),nt(n.value instanceof Ka,(()=>"The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")),nt(wt(n.gradFunc),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")),n.value),backwardsFunc:(e,r)=>{const a=n.gradFunc(e,r),i=Array.isArray(a)?a:[a];nt(i.length===t.length,(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).")),nt(i.every((e=>e instanceof Ka)),(()=>"The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors."));const s={};return i.forEach(((e,t)=>{s[t]=()=>e})),s},inputs:r})}}readSync(e){return this.state.tensorInfo.get(e).backend.readSync(e)}read(e){return this.state.tensorInfo.get(e).backend.read(e)}readToGPU(e,t){return this.state.tensorInfo.get(e).backend.readToGPU(e,t)}async time(e){const t=Aa(),n=await this.backend.time(e);return n.wallMs=Aa()-t,n}track(e){return null!=this.state.activeScope&&(e.scopeId=this.state.activeScope.id,this.state.activeScope.track.push(e)),e}get registeredVariables(){return this.state.registeredVariables}reset(){this.pendingBackendInitId++,this.state.dispose(),this.ENV.reset(),this.state=new si;for(const e in this.registry)this.disposeRegisteredKernels(e),this.registry[e].dispose(),delete this.registry[e];this.backendName=null,this.backendInstance=null,this.pendingBackendInit=null}}function ui(){const e=Pt();if(null==e._tfengine){const t=new Ft(e);e._tfengine=new oi(t)}var t;return t=e._tfengine.ENV,Dt=t,Ga=()=>e._tfengine,e._tfengine}oi.nextTensorId=0,oi.nextVariableId=0;const li=ui();function ci(e,t){const n={a:e,b:t};return li.runKernel(Bt,n)}function hi(e){if(e||"undefined"!=typeof navigator&&null!=navigator){if(e||(e=navigator),"ReactNative"===e.product)return!0;const t=e.userAgent||e.vendor||("undefined"!=typeof window?window.opera:"");if(!t){const t=e;return t.userAgentData&&t.userAgentData.mobile}return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4))}return!1}function pi(){return"undefined"!=typeof window&&null!=window.document||"undefined"!=typeof WorkerGlobalScope}const di=Mt();di.registerFlag("DEBUG",(()=>!1),(e=>{e&&console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.")})),di.registerFlag("IS_BROWSER",(()=>pi())),di.registerFlag("IS_NODE",(()=>void 0!==Xe&&void 0!==Xe.versions&&void 0!==Xe.versions.node)),di.registerFlag("IS_CHROME",(()=>"undefined"!=typeof navigator&&null!=navigator&&null!=navigator.userAgent&&/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor))),di.registerFlag("PROD",(()=>!1)),di.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY",(()=>di.getBool("DEBUG"))),di.registerFlag("DEPRECATION_WARNINGS_ENABLED",(()=>!0)),di.registerFlag("IS_TEST",(()=>!1)),di.registerFlag("CHECK_COMPUTATION_FOR_ERRORS",(()=>!0)),di.registerFlag("WRAP_TO_IMAGEBITMAP",(()=>!1)),di.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU",(()=>!1)),di.registerFlag("USE_SETTIMEOUTCUSTOM",(()=>!1));var fi=[],mi=[],gi="undefined"!=typeof Uint8Array?Uint8Array:Array,yi=!1;function bi(){yi=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)fi[t]=e[t],mi[e.charCodeAt(t)]=t;mi["-".charCodeAt(0)]=62,mi["_".charCodeAt(0)]=63}function vi(e,t,n){for(var r,a,i=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(fi[(a=r)>>18&63]+fi[a>>12&63]+fi[a>>6&63]+fi[63&a]);return i.join("")}function wi(e){var t;yi||bi();for(var n=e.length,r=n%3,a="",i=[],s=16383,o=0,u=n-r;o<u;o+=s)i.push(vi(e,o,o+s>u?u:o+s));return 1===r?(t=e[n-1],a+=fi[t>>2],a+=fi[t<<4&63],a+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],a+=fi[t>>10],a+=fi[t>>4&63],a+=fi[t<<2&63],a+="="),i.push(a),i.join("")}function _i(e,t,n,r,a){var i,s,o=8*a-r-1,u=(1<<o)-1,l=u>>1,c=-7,h=n?a-1:0,p=n?-1:1,d=e[t+h];for(h+=p,i=d&(1<<-c)-1,d>>=-c,c+=o;c>0;i=256*i+e[t+h],h+=p,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=r;c>0;s=256*s+e[t+h],h+=p,c-=8);if(0===i)i=1-l;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),i-=l}return(d?-1:1)*s*Math.pow(2,i-r)}function xi(e,t,n,r,a,i){var s,o,u,l=8*i-a-1,c=(1<<l)-1,h=c>>1,p=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+h>=1?p/u:p*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=c?(o=0,s=c):s+h>=1?(o=(t*u-1)*Math.pow(2,a),s+=h):(o=t*Math.pow(2,h-1)*Math.pow(2,a),s=0));a>=8;e[n+d]=255&o,d+=f,o/=256,a-=8);for(s=s<<a|o,l+=a;l>0;e[n+d]=255&s,d+=f,s/=256,l-=8);e[n+d-f]|=128*m}var ki={}.toString,Ti=Array.isArray||function(e){return"[object Array]"==ki.call(e)};function Ei(){return Ii.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Si(e,t){if(Ei()<t)throw new RangeError("Invalid typed array length");return Ii.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Ii.prototype:(null===e&&(e=new Ii(t)),e.length=t),e}function Ii(e,t,n){if(!(Ii.TYPED_ARRAY_SUPPORT||this instanceof Ii))return new Ii(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Ni(this,e)}return Ai(this,e,t,n)}function Ai(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),Ii.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Ii.prototype:e=Ri(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!Ii.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|Mi(t,n),a=(e=Si(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}(e,t,n):function(e,t){if(Oi(t)){var n=0|Fi(t.length);return 0===(e=Si(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?Si(e,0):Ri(e,t);if("Buffer"===t.type&&Ti(t.data))return Ri(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Ci(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Ni(e,t){if(Ci(t),e=Si(e,t<0?0:0|Fi(t)),!Ii.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Ri(e,t){var n=t.length<0?0:0|Fi(t.length);e=Si(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function Fi(e){if(e>=Ei())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ei().toString(16)+" bytes");return 0|e}function Oi(e){return!(null==e||!e._isBuffer)}function Mi(e,t){if(Oi(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return os(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return us(e).length;default:if(r)return os(e).length;t=(""+t).toLowerCase(),r=!0}}function $i(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Yi(this,t,n);case"utf8":case"utf-8":return Hi(this,t,n);case"ascii":return qi(this,t,n);case"latin1":case"binary":return Xi(this,t,n);case"base64":return Gi(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Qi(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Di(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Pi(e,t,n,r,a){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if("string"==typeof t&&(t=Ii.from(t,r)),Oi(t))return 0===t.length?-1:Li(e,t,n,r,a);if("number"==typeof t)return t&=255,Ii.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Li(e,[t],n,r,a);throw new TypeError("val must be string, number or Buffer")}function Li(e,t,n,r,a){var i,s=1,o=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,o/=2,u/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){var c=-1;for(i=n;i<o;i++)if(l(e,i)===l(t,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===u)return c*s}else-1!==c&&(i-=i-c),c=-1}else for(n+u>o&&(n=o-u),i=n;i>=0;i--){for(var h=!0,p=0;p<u;p++)if(l(e,i+p)!==l(t,p)){h=!1;break}if(h)return i}return-1}function Bi(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s<r;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[n+s]=o}return s}function Ui(e,t,n,r){return ls(os(t,e.length-n),e,n,r)}function Wi(e,t,n,r){return ls(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function Vi(e,t,n,r){return Wi(e,t,n,r)}function zi(e,t,n,r){return ls(us(t),e,n,r)}function ji(e,t,n,r){return ls(function(e,t){for(var n,r,a,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,a=n%256,i.push(a),i.push(r);return i}(t,e.length-n),e,n,r)}function Gi(e,t,n){return 0===t&&n===e.length?wi(e):wi(e.slice(t,n))}function Hi(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var i,s,o,u,l=e[a],c=null,h=l>239?4:l>223?3:l>191?2:1;if(a+h<=n)switch(h){case 1:l<128&&(c=l);break;case 2:128==(192&(i=e[a+1]))&&(u=(31&l)<<6|63&i)>127&&(c=u);break;case 3:i=e[a+1],s=e[a+2],128==(192&i)&&128==(192&s)&&(u=(15&l)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=e[a+1],s=e[a+2],o=e[a+3],128==(192&i)&&128==(192&s)&&128==(192&o)&&(u=(15&l)<<18|(63&i)<<12|(63&s)<<6|63&o)>65535&&u<1114112&&(c=u)}null===c?(c=65533,h=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),a+=h}return function(e){var t=e.length;if(t<=Ki)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Ki));return n}(r)}Ii.TYPED_ARRAY_SUPPORT=void 0===Te.TYPED_ARRAY_SUPPORT||Te.TYPED_ARRAY_SUPPORT,Ei(),Ii.poolSize=8192,Ii._augment=function(e){return e.__proto__=Ii.prototype,e},Ii.from=function(e,t,n){return Ai(null,e,t,n)},Ii.TYPED_ARRAY_SUPPORT&&(Ii.prototype.__proto__=Uint8Array.prototype,Ii.__proto__=Uint8Array),Ii.alloc=function(e,t,n){return function(e,t,n,r){return Ci(t),t<=0?Si(e,t):void 0!==n?"string"==typeof r?Si(e,t).fill(n,r):Si(e,t).fill(n):Si(e,t)}(null,e,t,n)},Ii.allocUnsafe=function(e){return Ni(null,e)},Ii.allocUnsafeSlow=function(e){return Ni(null,e)},Ii.isBuffer=function(e){return null!=e&&(!!e._isBuffer||cs(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&cs(e.slice(0,0))}(e))},Ii.compare=function(e,t){if(!Oi(e)||!Oi(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,a=0,i=Math.min(n,r);a<i;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},Ii.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Ii.concat=function(e,t){if(!Ti(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Ii.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=Ii.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var i=e[n];if(!Oi(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,a),a+=i.length}return r},Ii.byteLength=Mi,Ii.prototype._isBuffer=!0,Ii.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Di(this,t,t+1);return this},Ii.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Di(this,t,t+3),Di(this,t+1,t+2);return this},Ii.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Di(this,t,t+7),Di(this,t+1,t+6),Di(this,t+2,t+5),Di(this,t+3,t+4);return this},Ii.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Hi(this,0,e):$i.apply(this,arguments)},Ii.prototype.equals=function(e){if(!Oi(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Ii.compare(this,e)},Ii.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},Ii.prototype.compare=function(e,t,n,r,a){if(!Oi(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError("out of range index");if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(a>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),o=Math.min(i,s),u=this.slice(r,a),l=e.slice(t,n),c=0;c<o;++c)if(u[c]!==l[c]){i=u[c],s=l[c];break}return i<s?-1:s<i?1:0},Ii.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},Ii.prototype.indexOf=function(e,t,n){return Pi(this,e,t,n,!0)},Ii.prototype.lastIndexOf=function(e,t,n){return Pi(this,e,t,n,!1)},Ii.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return Bi(this,e,t,n);case"utf8":case"utf-8":return Ui(this,e,t,n);case"ascii":return Wi(this,e,t,n);case"latin1":case"binary":return Vi(this,e,t,n);case"base64":return zi(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ji(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},Ii.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Ki=4096;function qi(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function Xi(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function Yi(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a="",i=t;i<n;++i)a+=ss(e[i]);return a}function Qi(e,t,n){for(var r=e.slice(t,n),a="",i=0;i<r.length;i+=2)a+=String.fromCharCode(r[i]+256*r[i+1]);return a}function Ji(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function Zi(e,t,n,r,a,i){if(!Oi(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function es(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,i=Math.min(e.length-n,2);a<i;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function ts(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,i=Math.min(e.length-n,4);a<i;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function ns(e,t,n,r,a,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function rs(e,t,n,r,a){return a||ns(e,0,n,4),xi(e,t,n,r,23,4),n+4}function as(e,t,n,r,a){return a||ns(e,0,n,8),xi(e,t,n,r,52,8),n+8}Ii.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),Ii.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=Ii.prototype;else{var a=t-e;n=new Ii(a,void 0);for(var i=0;i<a;++i)n[i]=this[i+e]}return n},Ii.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||Ji(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r},Ii.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||Ji(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},Ii.prototype.readUInt8=function(e,t){return t||Ji(e,1,this.length),this[e]},Ii.prototype.readUInt16LE=function(e,t){return t||Ji(e,2,this.length),this[e]|this[e+1]<<8},Ii.prototype.readUInt16BE=function(e,t){return t||Ji(e,2,this.length),this[e]<<8|this[e+1]},Ii.prototype.readUInt32LE=function(e,t){return t||Ji(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Ii.prototype.readUInt32BE=function(e,t){return t||Ji(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Ii.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||Ji(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},Ii.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||Ji(e,t,this.length);for(var r=t,a=1,i=this[e+--r];r>0&&(a*=256);)i+=this[e+--r]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*t)),i},Ii.prototype.readInt8=function(e,t){return t||Ji(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Ii.prototype.readInt16LE=function(e,t){t||Ji(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},Ii.prototype.readInt16BE=function(e,t){t||Ji(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},Ii.prototype.readInt32LE=function(e,t){return t||Ji(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Ii.prototype.readInt32BE=function(e,t){return t||Ji(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Ii.prototype.readFloatLE=function(e,t){return t||Ji(e,4,this.length),_i(this,e,!0,23,4)},Ii.prototype.readFloatBE=function(e,t){return t||Ji(e,4,this.length),_i(this,e,!1,23,4)},Ii.prototype.readDoubleLE=function(e,t){return t||Ji(e,8,this.length),_i(this,e,!0,52,8)},Ii.prototype.readDoubleBE=function(e,t){return t||Ji(e,8,this.length),_i(this,e,!1,52,8)},Ii.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Zi(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,i=0;for(this[t]=255&e;++i<n&&(a*=256);)this[t+i]=e/a&255;return t+n},Ii.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Zi(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,i=1;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+n},Ii.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Zi(this,e,t,1,255,0),Ii.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Ii.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Zi(this,e,t,2,65535,0),Ii.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):es(this,e,t,!0),t+2},Ii.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Zi(this,e,t,2,65535,0),Ii.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):es(this,e,t,!1),t+2},Ii.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Zi(this,e,t,4,4294967295,0),Ii.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):ts(this,e,t,!0),t+4},Ii.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Zi(this,e,t,4,4294967295,0),Ii.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ts(this,e,t,!1),t+4},Ii.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Zi(this,e,t,n,a-1,-a)}var i=0,s=1,o=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},Ii.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Zi(this,e,t,n,a-1,-a)}var i=n-1,s=1,o=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},Ii.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Zi(this,e,t,1,127,-128),Ii.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Ii.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Zi(this,e,t,2,32767,-32768),Ii.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):es(this,e,t,!0),t+2},Ii.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Zi(this,e,t,2,32767,-32768),Ii.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):es(this,e,t,!1),t+2},Ii.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Zi(this,e,t,4,2147483647,-2147483648),Ii.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):ts(this,e,t,!0),t+4},Ii.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Zi(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Ii.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):ts(this,e,t,!1),t+4},Ii.prototype.writeFloatLE=function(e,t,n){return rs(this,e,t,!0,n)},Ii.prototype.writeFloatBE=function(e,t,n){return rs(this,e,t,!1,n)},Ii.prototype.writeDoubleLE=function(e,t,n){return as(this,e,t,!0,n)},Ii.prototype.writeDoubleBE=function(e,t,n){return as(this,e,t,!1,n)},Ii.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,i=r-n;if(this===e&&n<t&&t<r)for(a=i-1;a>=0;--a)e[a+t]=this[a+n];else if(i<1e3||!Ii.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},Ii.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!Ii.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=Oi(e)?e:os(new Ii(e,r).toString()),o=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%o]}return this};var is=/[^+\/0-9A-Za-z-_]/g;function ss(e){return e<16?"0"+e.toString(16):e.toString(16)}function os(e,t){var n;t=t||1/0;for(var r=e.length,a=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function us(e){return function(e){var t,n,r,a,i,s;yi||bi();var o=e.length;if(o%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===e[o-2]?2:"="===e[o-1]?1:0,s=new gi(3*o/4-i),r=i>0?o-4:o;var u=0;for(t=0,n=0;t<r;t+=4,n+=3)a=mi[e.charCodeAt(t)]<<18|mi[e.charCodeAt(t+1)]<<12|mi[e.charCodeAt(t+2)]<<6|mi[e.charCodeAt(t+3)],s[u++]=a>>16&255,s[u++]=a>>8&255,s[u++]=255&a;return 2===i?(a=mi[e.charCodeAt(t)]<<2|mi[e.charCodeAt(t+1)]>>4,s[u++]=255&a):1===i&&(a=mi[e.charCodeAt(t)]<<10|mi[e.charCodeAt(t+1)]<<4|mi[e.charCodeAt(t+2)]>>2,s[u++]=a>>8&255,s[u++]=255&a),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(is,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function ls(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}function cs(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function hs(e,t){let n=e;if(Ra(e))return"string"===t?[]:[e.length];if("object"==typeof e){if("texture"in e){const t=e.channels||"RGBA";return[e.height,e.width*t.length]}if("buffer"in e&&!(e.buffer instanceof ArrayBuffer))return[e.buffer.size/(null==t?4:yt(t))]}if(!Array.isArray(e))return[];const r=[];for(;Array.isArray(n)||Ra(n)&&"string"!==t;)r.push(n.length),n=n[0];return Array.isArray(e)&&Mt().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY")&&ps(e,r,[]),r}function ps(e,t,n){if(n=n||[],!Array.isArray(e)&&!Ra(e))return void nt(0===t.length,(()=>`Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`));nt(t.length>0,(()=>`Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)),nt(e.length===t[0],(()=>`Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`));const r=t.slice(1);for(let t=0;t<e.length;++t)ps(e[t],r,n.concat(t))}function ds(e,t,n,r){if("string_or_numeric"!==e){if(null==e)throw new Error("Expected dtype cannot be null.");if("numeric"!==e&&e!==t||"numeric"===e&&"string"===t)throw new Error(`Argument '${n}' passed to '${r}' must be ${e} tensor, but got ${t} tensor`)}}function fs(e,t,n,r="numeric"){if(e instanceof Ka)return ds(r,e.dtype,t,n),e;let a=vt(e);if("string"!==a&&["bool","int32","float32"].indexOf(r)>=0&&(a=r),ds(r,a,t,n),null==e||!Ra(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e){const r=null==e?"null":e.constructor.name;throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${r}'`)}const i=hs(e,a);Ra(e)||Array.isArray(e)||(e=[e]);const s="string"!==a?Ia(e,a):Fa(e,[],!0);return li.makeTensor(s,i,a)}function ms(e,t,n,r="numeric"){if(!Array.isArray(e))throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``);return e.map(((e,a)=>fs(e,`${t}[${a}]`,n,r)))}const gs="__op";function ys(e){const t=Object.keys(e);if(1!==t.length)throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`);let n=t[0];const r=e[n];n.endsWith("_")&&(n=n.substring(0,n.length-1)),n+=gs;const a=(...e)=>{li.startScope(n);try{const t=r(...e);return Nt(t)&&console.error("Cannot return a Promise inside of tidy."),li.endScope(t),t}catch(e){throw li.endScope(null),e}};return Object.defineProperty(a,"name",{value:n,configurable:!0}),a}const bs=ys({complex_:function(e,t){const n=fs(e,"real","complex"),r=fs(t,"imag","complex");rt(n.shape,r.shape,`real and imag shapes, ${n.shape} and ${r.shape}, must match in call to tf.complex().`);const a={real:n,imag:r};return li.runKernel("Complex",a)}});function vs(e,t,n,r){if(null==r)r=vt(e);else if("complex64"===r)throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag).");if("object"==typeof e&&("texture"in e||"buffer"in e&&!(e.buffer instanceof ArrayBuffer))){if("float32"!==r&&"int32"!==r)throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${r}.`);return li.backend.createTensorFromGPUData(e,t||n,r)}if(!Ra(e)&&!Array.isArray(e)&&"number"!=typeof e&&"boolean"!=typeof e&&"string"!=typeof e)throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray");if(null!=t){It(t);const e=it(t),r=it(n);nt(e===r,(()=>`Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`));for(let e=0;e<n.length;++e){const r=n[e],a=e!==n.length-1||r!==it(t.slice(e));nt(n[e]===t[e]||!a,(()=>`Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `))}}return Ra(e)||Array.isArray(e)||(e=[e]),t=t||n,e="string"!==r?Ia(e,r):Fa(e,[],!0),li.makeTensor(e,t,r)}function ws(e,t,n){return vs(e,t,hs(e,n),n)}const _s={float32:4,float16:2,int32:4,uint16:2,uint8:1,bool:1,complex64:8},xs=4;function ks(e,t){const n={};let r,a=0;for(const i of t){const t=i.name,s=i.dtype,o=i.shape,u=it(o);let l;if("quantization"in i){const n=i.quantization;if("uint8"===n.dtype||"uint16"===n.dtype){if(!("min"in n)||!("scale"in n))throw new Error(`Weight ${i.name} with quantization ${n.dtype} doesn't have corresponding metadata min and scale.`)}else{if("float16"!==n.dtype)throw new Error(`Weight ${i.name} has unknown quantization dtype ${n.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`);if("float32"!==s)throw new Error(`Weight ${i.name} is quantized with ${n.dtype} which only supports weights of type float32 not ${s}.`)}const o=_s[n.dtype],c=e.slice(a,a+u*o),h="uint8"===n.dtype?new Uint8Array(c):new Uint16Array(c);if("float32"===s)if("uint8"===n.dtype||"uint16"===n.dtype){l=new Float32Array(h.length);for(let e=0;e<h.length;e++){const t=h[e];l[e]=t*n.scale+n.min}}else{if("float16"!==n.dtype)throw new Error(`Unsupported quantization type ${n.dtype} for weight type float32.`);void 0===r&&(r=Ms()),l=r(h)}else{if("int32"!==s)throw new Error(`Unsupported dtype in weight '${t}': ${s}`);if("uint8"!==n.dtype&&"uint16"!==n.dtype)throw new Error(`Unsupported quantization type ${n.dtype} for weight type int32.`);l=new Int32Array(h.length);for(let e=0;e<h.length;e++){const t=h[e];l[e]=Math.round(t*n.scale+n.min)}}a+=u*o}else if("string"===s){const t=it(i.shape);l=[];for(let n=0;n<t;n++){const t=new Uint32Array(e.slice(a,a+xs))[0];a+=xs;const n=new Uint8Array(e.slice(a,a+t));l.push(n),a+=t}}else{const r=_s[s],i=e.slice(a,a+u*r);if("float32"===s)l=new Float32Array(i);else if("int32"===s)l=new Int32Array(i);else if("bool"===s)l=new Uint8Array(i);else{if("complex64"!==s)throw new Error(`Unsupported dtype in weight '${t}': ${s}`);{l=new Float32Array(i);const e=new Float32Array(l.length/2),r=new Float32Array(l.length/2);for(let t=0;t<e.length;t++)e[t]=l[2*t],r[t]=l[2*t+1];const a=ws(e,o,"float32"),s=ws(r,o,"float32");n[t]=bs(a,s),a.dispose(),s.dispose()}}a+=u*r}"complex64"!==s&&(n[t]=ws(l,o,s))}return n}function Ts(e){if(null===e)throw new Error(`Invalid input value: ${JSON.stringify(e)}`);let t=0;const n=[];e.forEach((e=>{if(t+=e.byteLength,n.push(e.byteLength===e.buffer.byteLength?e:new e.constructor(e)),!(e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array))throw new Error(`Unsupported TypedArray subtype: ${e.constructor.name}`)}));const r=new Uint8Array(t);let a=0;return n.forEach((e=>{r.set(new Uint8Array(e.buffer),a),a+=e.byteLength})),r.buffer}const Es=void 0!==Ii&&("undefined"==typeof Blob||"undefined"==typeof atob||"undefined"==typeof btoa);function Ss(e){return Es?Ii.byteLength(e):new Blob([e]).size}function Is(e){if(1===e.length)return e[0];let t=0;e.forEach((e=>{t+=e.byteLength}));const n=new Uint8Array(t);let r=0;return e.forEach((e=>{n.set(new Uint8Array(e),r),r+=e.byteLength})),n.buffer}function As(e){for(e=e.trim();e.endsWith("/");)e=e.slice(0,e.length-1);const t=e.split("/");return t[t.length-1]}function Cs(e,t){const n={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,weightsManifest:t};return null!=e.signature&&(n.signature=e.signature),null!=e.userDefinedMetadata&&(n.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(n.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(n.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(n.trainingConfig=e.trainingConfig),n}function Ns(e,t,n){const r={modelTopology:e.modelTopology,format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy};if(null!=e.trainingConfig&&(r.trainingConfig=e.trainingConfig),null!=e.weightsManifest){if(!t)throw new Error("modelJSON has weightsManifest but weightSpecs is null");if(!n)throw new Error("modelJSON has weightsManifest but weightData is null");r.weightSpecs=t,r.weightData=n}return null!=e.signature&&(r.signature=e.signature),null!=e.userDefinedMetadata&&(r.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(r.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(r.initializerSignature=e.initializerSignature),r}async function Rs(e,t){let n,r;return null!=e.weightsManifest&&([n,r]=await t(e.weightsManifest)),Ns(e,n,r)}function Fs(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("Expected JSON model topology, received ArrayBuffer.");return{dateSaved:new Date,modelTopologyType:"JSON",modelTopologyBytes:null==e.modelTopology?0:Ss(JSON.stringify(e.modelTopology)),weightSpecsBytes:null==e.weightSpecs?0:Ss(JSON.stringify(e.weightSpecs)),weightDataBytes:null==e.weightData?0:e.weightData.byteLength}}function Os(e){const t=[];for(const n of e)t.push(...n.weights);return t}function Ms(){const e=function(){const e=e=>{let t=e<<13,n=0;for(;0==(8388608&t);)n-=8388608,t<<=1;return t&=-8388609,n+=947912704,t|n},t=new Uint32Array(2048);t[0]=0;for(let n=1;n<1024;n++)t[n]=e(n);for(let e=1024;e<2048;e++)t[e]=939524096+(e-1024<<13);return t}(),t=function(){const e=new Uint32Array(64);e[0]=0,e[31]=1199570944,e[32]=2147483648,e[63]=3347054592;for(let t=1;t<31;t++)e[t]=t<<23;for(let t=33;t<63;t++)e[t]=2147483648+(t-32<<23);return e}(),n=function(){const e=new Uint32Array(64);for(let t=0;t<64;t++)e[t]=1024;return e[0]=e[32]=0,e}();return r=>{const a=new ArrayBuffer(4*r.length),i=new Uint32Array(a);for(let a=0;a<r.length;a++){const s=r[a],o=e[n[s>>10]+(1023&s)]+t[s>>10];i[a]=o}return new Float32Array(a)}}class $s{constructor(){this.saveRouters=[],this.loadRouters=[]}static getInstance(){return null==$s.instance&&($s.instance=new $s),$s.instance}static registerSaveRouter(e){$s.getInstance().saveRouters.push(e)}static registerLoadRouter(e){$s.getInstance().loadRouters.push(e)}static getSaveHandlers(e){return $s.getHandlers(e,"save")}static getLoadHandlers(e,t){return $s.getHandlers(e,"load",t)}static getHandlers(e,t,n){const r=[];return("load"===t?$s.getInstance().loadRouters:$s.getInstance().saveRouters).forEach((t=>{const a=t(e,n);null!==a&&r.push(a)})),r}}const Ds="tensorflowjs",Ps="models_store",Ls="model_info_store";function Bs(){if(!Mt().getBool("IS_BROWSER"))throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser.");const e="undefined"==typeof window?self:window,t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB||e.shimIndexedDB;if(null==t)throw new Error("The current browser does not appear to support IndexedDB.");return t}function Us(e){const t=e.result;t.createObjectStore(Ps,{keyPath:"modelPath"}),t.createObjectStore(Ls,{keyPath:"modelPath"})}class Ws{constructor(e){if(this.indexedDB=Bs(),null==e||!e)throw new Error("For IndexedDB, modelPath must not be null, undefined or empty.");this.modelPath=e}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");return this.databaseAction(this.modelPath,e)}async load(){return this.databaseAction(this.modelPath)}databaseAction(e,t){return new Promise(((e,n)=>{const r=this.indexedDB.open(Ds,1);r.onupgradeneeded=()=>Us(r),r.onsuccess=()=>{const a=r.result;if(null==t){const t=a.transaction(Ps,"readonly"),r=t.objectStore(Ps).get(this.modelPath);r.onsuccess=()=>{if(null==r.result)return a.close(),n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`));e(r.result.modelArtifacts)},r.onerror=e=>(a.close(),n(r.error)),t.oncomplete=()=>a.close()}else{const r=Fs(t),i=a.transaction(Ls,"readwrite");let s=i.objectStore(Ls);const o=s.put({modelPath:this.modelPath,modelArtifactsInfo:r});let u;o.onsuccess=()=>{u=a.transaction(Ps,"readwrite");const o=u.objectStore(Ps).put({modelPath:this.modelPath,modelArtifacts:t,modelArtifactsInfo:r});o.onsuccess=()=>e({modelArtifactsInfo:r}),o.onerror=e=>{s=i.objectStore(Ls);const t=s.delete(this.modelPath);t.onsuccess=()=>(a.close(),n(o.error)),t.onerror=e=>(a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}}},r.onerror=e=>n(r.error)}))}}Ws.URL_SCHEME="indexeddb://";const Vs=e=>{return Mt().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(Ws.URL_SCHEME)?(t=e.slice(Ws.URL_SCHEME.length),new Ws(t)):null;var t};$s.registerSaveRouter(Vs),$s.registerLoadRouter(Vs);class zs{constructor(){this.indexedDB=Bs()}async listModels(){return new Promise(((e,t)=>{const n=this.indexedDB.open(Ds,1);n.onupgradeneeded=()=>Us(n),n.onsuccess=()=>{const r=n.result,a=r.transaction(Ls,"readonly"),i=a.objectStore(Ls).getAll();i.onsuccess=()=>{const t={};for(const e of i.result)t[e.modelPath]=e.modelArtifactsInfo;e(t)},i.onerror=e=>(r.close(),t(i.error)),a.oncomplete=()=>r.close()},n.onerror=e=>t(n.error)}))}async removeModel(e){var t;return e=(t=e).startsWith(Ws.URL_SCHEME)?t.slice(Ws.URL_SCHEME.length):t,new Promise(((t,n)=>{const r=this.indexedDB.open(Ds,1);r.onupgradeneeded=()=>Us(r),r.onsuccess=()=>{const a=r.result,i=a.transaction(Ls,"readwrite"),s=i.objectStore(Ls),o=s.get(e);let u;o.onsuccess=()=>{if(null==o.result)return a.close(),n(new Error(`Cannot find model with path '${e}' in IndexedDB.`));{const r=s.delete(e),i=()=>{u=a.transaction(Ps,"readwrite");const r=u.objectStore(Ps).delete(e);r.onsuccess=()=>t(o.result.modelArtifactsInfo),r.onerror=e=>n(o.error)};r.onsuccess=i,r.onerror=e=>(i(),a.close(),n(o.error))}},o.onerror=e=>(a.close(),n(o.error)),i.oncomplete=()=>{null==u?a.close():u.oncomplete=()=>a.close()}},r.onerror=e=>n(r.error)}))}}const js="/",Gs="tensorflowjs_models",Hs="info",Ks="model_topology",qs="weight_specs",Xs="weight_data",Ys="model_metadata";function Qs(e){return{info:[Gs,e,Hs].join(js),topology:[Gs,e,Ks].join(js),weightSpecs:[Gs,e,qs].join(js),weightData:[Gs,e,Xs].join(js),modelMetadata:[Gs,e,Ys].join(js)}}function Js(e){for(const t of Object.values(e))window.localStorage.removeItem(t)}function Zs(e){const t=e.split(js);if(t.length<3)throw new Error(`Invalid key format: ${e}`);return t.slice(1,t.length-1).join(js)}class eo{constructor(e){if(!Mt().getBool("IS_BROWSER")||"undefined"==typeof window||void 0===window.localStorage)throw new Error("The current environment does not support local storage.");if(this.LS=window.localStorage,null==e||!e)throw new Error("For local storage, modelPath must not be null, undefined or empty.");this.modelPath=e,this.keys=Qs(this.modelPath)}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet.");{const t=JSON.stringify(e.modelTopology),n=JSON.stringify(e.weightSpecs),r=Fs(e);try{this.LS.setItem(this.keys.info,JSON.stringify(r)),this.LS.setItem(this.keys.topology,t),this.LS.setItem(this.keys.weightSpecs,n),this.LS.setItem(this.keys.weightData,function(e){if(Es)return Ii.from(e).toString("base64");const t=new Uint8Array(e);let n="";for(let e=0,r=t.length;e<r;e++)n+=String.fromCharCode(t[e]);return btoa(n)}(e.weightData));const a={format:e.format,generatedBy:e.generatedBy,convertedBy:e.convertedBy,signature:null!=e.signature?e.signature:void 0,userDefinedMetadata:null!=e.userDefinedMetadata?e.userDefinedMetadata:void 0,modelInitializer:null!=e.modelInitializer?e.modelInitializer:void 0,initializerSignature:null!=e.initializerSignature?e.initializerSignature:void 0,trainingConfig:null!=e.trainingConfig?e.trainingConfig:void 0};return this.LS.setItem(this.keys.modelMetadata,JSON.stringify(a)),{modelArtifactsInfo:r}}catch(e){throw Js(this.keys),new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`)}}}async load(){const e=JSON.parse(this.LS.getItem(this.keys.info));if(null==e)throw new Error(`In local storage, there is no model with name '${this.modelPath}'`);if("JSON"!==e.modelTopologyType)throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet.");const t={},n=JSON.parse(this.LS.getItem(this.keys.topology));if(null==n)throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`);t.modelTopology=n;const r=JSON.parse(this.LS.getItem(this.keys.weightSpecs));if(null==r)throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`);t.weightSpecs=r;const a=this.LS.getItem(this.keys.modelMetadata);if(null!=a){const e=JSON.parse(a);t.format=e.format,t.generatedBy=e.generatedBy,t.convertedBy=e.convertedBy,null!=e.signature&&(t.signature=e.signature),null!=e.userDefinedMetadata&&(t.userDefinedMetadata=e.userDefinedMetadata),null!=e.modelInitializer&&(t.modelInitializer=e.modelInitializer),null!=e.initializerSignature&&(t.initializerSignature=e.initializerSignature),null!=e.trainingConfig&&(t.trainingConfig=e.trainingConfig)}const i=this.LS.getItem(this.keys.weightData);if(null==i)throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`);return t.weightData=function(e){if(Es){const t=Ii.from(e,"base64");return t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength)}const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n.set([t.charCodeAt(e)],e);return n.buffer}(i),t}}eo.URL_SCHEME="localstorage://";const to=e=>{return Mt().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(eo.URL_SCHEME)?(t=e.slice(eo.URL_SCHEME.length),new eo(t)):null;var t};$s.registerSaveRouter(to),$s.registerLoadRouter(to);class no{constructor(){nt(Mt().getBool("IS_BROWSER"),(()=>"Current environment is not a web browser")),nt("undefined"==typeof window||void 0!==window.localStorage,(()=>"Current browser does not appear to support localStorage")),this.LS=window.localStorage}async listModels(){const e={},t=Gs+js,n=js+Hs;for(let r=0;r<this.LS.length;++r){const a=this.LS.key(r);a.startsWith(t)&&a.endsWith(n)&&(e[Zs(a)]=JSON.parse(this.LS.getItem(a)))}return e}async removeModel(e){var t;const n=Qs(e=(t=e).startsWith(eo.URL_SCHEME)?t.slice(eo.URL_SCHEME.length):t);if(null==this.LS.getItem(n.info))throw new Error(`Cannot find model at path '${e}'`);const r=JSON.parse(this.LS.getItem(n.info));return Js(n),r}}function ro(e){return new Promise((e=>setTimeout(e))).then(e)}class ao{constructor(e){if(!Mt().getBool("IS_BROWSER"))throw new Error("browserDownloads() cannot proceed because the current environment is not a browser.");e.startsWith(ao.URL_SCHEME)&&(e=e.slice(ao.URL_SCHEME.length)),null!=e&&0!==e.length||(e="model"),this.modelJsonFileName=e+".json",this.weightDataFileName=e+".weights.bin"}async save(e){if("undefined"==typeof document)throw new Error("Browser downloads are not supported in this environment since `document` is not present");const t=window.URL.createObjectURL(new Blob([e.weightData],{type:"application/octet-stream"}));if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet.");{const n=Cs(e,[{paths:["./"+this.weightDataFileName],weights:e.weightSpecs}]),r=window.URL.createObjectURL(new Blob([JSON.stringify(n)],{type:"application/json"})),a=null==this.modelJsonAnchor?document.createElement("a"):this.modelJsonAnchor;if(a.download=this.modelJsonFileName,a.href=r,await ro((()=>a.dispatchEvent(new MouseEvent("click")))),null!=e.weightData){const e=null==this.weightDataAnchor?document.createElement("a"):this.weightDataAnchor;e.download=this.weightDataFileName,e.href=t,await ro((()=>e.dispatchEvent(new MouseEvent("click"))))}return{modelArtifactsInfo:Fs(e)}}}}ao.URL_SCHEME="downloads://";class io{constructor(e){if(null==e||e.length<1)throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`);this.jsonFile=e[0],this.weightsFiles=e.slice(1)}async load(){return new Promise(((e,t)=>{const n=new FileReader;n.onload=n=>{const r=JSON.parse(n.target.result),a=r.modelTopology;if(null==a)return void t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`));if(null==r.weightsManifest)return void t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`));if(0===this.weightsFiles.length)return void e({modelTopology:a});const i=Rs(r,(e=>this.loadWeights(e)));e(i)},n.onerror=e=>t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`),n.readAsText(this.jsonFile)}))}loadWeights(e){const t=[],n=[];for(const r of e)t.push(...r.weights),n.push(...r.paths);const r=this.checkManifestAndWeightFiles(e),a=n.map((e=>this.loadWeightsFile(e,r[e])));return Promise.all(a).then((e=>[t,Is(e)]))}loadWeightsFile(e,t){return new Promise(((n,r)=>{const a=new FileReader;a.onload=e=>{const t=e.target.result;n(t)},a.onerror=t=>r(`Failed to weights data from file of path '${e}'.`),a.readAsArrayBuffer(t)}))}checkManifestAndWeightFiles(e){const t=[],n=this.weightsFiles.map((e=>As(e.name))),r={};for(const a of e)a.paths.forEach((e=>{const a=As(e);if(-1!==t.indexOf(a))throw new Error(`Duplicate file basename found in weights manifest: '${a}'`);if(t.push(a),-1===n.indexOf(a))throw new Error(`Weight file with basename '${a}' is not provided.`);r[e]=this.weightsFiles[n.indexOf(a)]}));if(t.length!==this.weightsFiles.length)throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`);return r}}function so(e,t,n,r){!function(e){nt(null!=e&&Array.isArray(e)&&e.length>0,(()=>"promises must be a none empty array"))}(e),function(e,t){nt(e>=0&&e<=1,(()=>`Progress fraction must be in range [0, 1], but got startFraction ${e}`)),nt(t>=0&&t<=1,(()=>`Progress fraction must be in range [0, 1], but got endFraction ${t}`)),nt(t>=e,(()=>`startFraction must be no more than endFraction, but got startFraction ${e} and endFraction ${t}`))}(n=null==n?0:n,r=null==r?1:r);let a=0;return Promise.all(e.map((i=>(i.then((i=>{const s=n+ ++a/e.length*(r-n);return t(s),i})),i))))}async function oo(e,t){null==t&&(t={});const n=null==t.fetchFunc?Mt().platform.fetch:t.fetchFunc,r=e.map((e=>n(e,t.requestInit,{isBinary:!0}))),a=(null==t.onProgress?await Promise.all(r):await so(r,t.onProgress,0,.5)).map((e=>e.arrayBuffer()));return null==t.onProgress?await Promise.all(a):await so(a,t.onProgress,.5,1)}function uo(e){return async(t,n="",r)=>{const a=t.map((()=>!1)),i={},s=null!=r?r.map((()=>!1)):[],o=[];if(t.forEach(((e,t)=>{let n=0;e.weights.forEach((e=>{const u="quantization"in e?e.quantization.dtype:e.dtype,l=_s[u]*it(e.shape),c=()=>{a[t]=!0,null==i[t]&&(i[t]=[]),i[t].push({manifestEntry:e,groupOffset:n,sizeBytes:l})};null!=r?r.forEach(((t,n)=>{t===e.name&&(c(),s[n]=!0)})):c(),o.push(e.name),n+=l}))})),!s.every((e=>e))){const e=r.filter(((e,t)=>!s[t]));throw new Error(`Could not find weights in manifest with names: ${e.join(", ")}. \nManifest JSON has weights with names: ${o.join(", ")}.`)}const u=a.reduce(((e,t,n)=>(t&&e.push(n),e)),[]),l=[];u.forEach((e=>{t[e].paths.forEach((e=>{const t=n+(n.endsWith("/")?"":"/")+e;l.push(t)}))}));const c=await e(l),h={};let p=0;return u.forEach((e=>{const n=t[e].paths.length;let r=0;for(let e=0;e<n;e++)r+=c[p+e].byteLength;const a=new ArrayBuffer(r),s=new Uint8Array(a);let o=0;for(let e=0;e<n;e++){const t=new Uint8Array(c[p+e]);s.set(t,o),o+=t.byteLength}i[e].forEach((e=>{const t=ks(a.slice(e.groupOffset,e.groupOffset+e.sizeBytes),[e.manifestEntry]);for(const e in t)h[e]=t[e]})),p+=n})),h}}$s.registerSaveRouter((e=>Mt().getBool("IS_BROWSER")&&!Array.isArray(e)&&e.startsWith(ao.URL_SCHEME)?function(e="model"){return new ao(e)}(e.slice(ao.URL_SCHEME.length)):null));class lo{constructor(e,t){if(this.DEFAULT_METHOD="POST",null==t&&(t={}),this.weightPathPrefix=t.weightPathPrefix,this.onProgress=t.onProgress,this.weightUrlConverter=t.weightUrlConverter,null!=t.fetchFunc?(nt("function"==typeof t.fetchFunc,(()=>"Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)")),this.fetch=t.fetchFunc):this.fetch=Mt().platform.fetch,nt(null!=e&&e.length>0,(()=>"URL path for http must not be null, undefined or empty.")),Array.isArray(e)&&nt(2===e.length,(()=>`URL paths for http must have a length of 2, (actual length is ${e.length}).`)),this.path=e,null!=t.requestInit&&null!=t.requestInit.body)throw new Error("requestInit is expected to have no pre-existing body, but has one.");this.requestInit=t.requestInit||{}}async save(e){if(e.modelTopology instanceof ArrayBuffer)throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet.");const t=Object.assign({method:this.DEFAULT_METHOD},this.requestInit);t.body=new FormData;const n=Cs(e,[{paths:["./model.weights.bin"],weights:e.weightSpecs}]);t.body.append("model.json",new Blob([JSON.stringify(n)],{type:"application/json"}),"model.json"),null!=e.weightData&&t.body.append("model.weights.bin",new Blob([e.weightData],{type:"application/octet-stream"}),"model.weights.bin");const r=await this.fetch(this.path,t);if(r.ok)return{modelArtifactsInfo:Fs(e),responses:[r]};throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${r.status}.`)}async load(){const e=await this.fetch(this.path,this.requestInit);if(!e.ok)throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`);let t;try{t=await e.json()}catch(e){let t=`Failed to parse model JSON of response from ${this.path}.`;throw this.path.endsWith(".pb")?t+=" Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository.":t+=" Please make sure the server is serving valid JSON for this request.",new Error(t)}const n=t.modelTopology,r=t.weightsManifest;if(null==n&&null==r)throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`);return Rs(t,(e=>this.loadWeights(e)))}async loadWeights(e){const t=Array.isArray(this.path)?this.path[1]:this.path,[n,r]=function(e){const t=e.lastIndexOf("/"),n=e.lastIndexOf("?");return[e.substring(0,t)+"/",n>t?e.substring(n):""]}(t),a=this.weightPathPrefix||n,i=Os(e),s=[],o=[];for(const t of e)for(const e of t.paths)null!=this.weightUrlConverter?o.push(this.weightUrlConverter(e)):s.push(a+e+r);return this.weightUrlConverter&&s.push(...await Promise.all(o)),[i,Is(await oo(s,{requestInit:this.requestInit,fetchFunc:this.fetch,onProgress:this.onProgress}))]}}function co(e){return null!=e.match(lo.URL_SCHEME_REGEX)}lo.URL_SCHEME_REGEX=/^https?:\/\//;const ho=(e,t)=>{if("undefined"==typeof fetch&&(null==t||null==t.fetchFunc))return null;{let n=!0;if(n=Array.isArray(e)?e.every((e=>co(e))):co(e),n)return po(e,t)}return null};function po(e,t){return new lo(e,t)}$s.registerSaveRouter(ho),$s.registerLoadRouter(ho);class fo{constructor(e){this.modelArtifacts=e}load(){return this.modelArtifacts}}class mo{constructor(e){this.saveHandler=e}save(e){return this.saveHandler(e)}}class go{constructor(e){e.load&&(this.load=()=>Promise.resolve(e.load())),e.save&&(this.save=t=>Promise.resolve(e.save(t)))}}function yo(e,t,n,r){return 1===arguments.length?null!=e.modelTopology||null!=e.weightSpecs?new fo(e):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new fo({modelTopology:e})):(console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."),new fo({modelTopology:e,weightSpecs:t,weightData:n,trainingConfig:r}))}const bo="://";class vo{constructor(){this.managers={}}static getInstance(){return null==vo.instance&&(vo.instance=new vo),vo.instance}static registerManager(e,t){nt(null!=e,(()=>"scheme must not be undefined or null.")),e.endsWith(bo)&&(e=e.slice(0,e.indexOf(bo))),nt(e.length>0,(()=>"scheme must not be an empty string."));const n=vo.getInstance();nt(null==n.managers[e],(()=>`A model store manager is already registered for scheme '${e}'.`)),n.managers[e]=t}static getManager(e){const t=vo.getInstance().managers[e];if(null==t)throw new Error(`Cannot find model manager for scheme '${e}'`);return t}static getSchemes(){return Object.keys(vo.getInstance().managers)}}function wo(e){if(-1===e.indexOf(bo))throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${vo.getSchemes().join(",")}`);return{scheme:e.split(bo)[0],path:e.split(bo)[1]}}async function _o(e,t,n=!1){nt(e!==t,(()=>`Old path and new path are the same: '${e}'`));const r=$s.getLoadHandlers(e);nt(r.length>0,(()=>`Copying failed because no load handler is found for source URL ${e}.`)),nt(r.length<2,(()=>`Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`));const a=r[0],i=$s.getSaveHandlers(t);nt(i.length>0,(()=>`Copying failed because no save handler is found for destination URL ${t}.`)),nt(i.length<2,(()=>`Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`));const s=i[0],o=wo(e).scheme,u=wo(e).path,l=o===wo(e).scheme,c=await a.load();n&&l&&await vo.getManager(o).removeModel(u);const h=await s.save(c);return n&&!l&&await vo.getManager(o).removeModel(u),h.modelArtifactsInfo}var xo=Object.freeze({__proto__:null,browserFiles:function(e){return new io(e)},browserHTTPRequest:function(e,t){return po(e,t)},concatenateArrayBuffers:Is,decodeWeights:ks,encodeWeights:async function(e,t){const n=[],r=[],a=Array.isArray(e)?e.map((e=>e.name)):Object.keys(e);for(let i=0;i<a.length;++i){const s=a[i],o=Array.isArray(e)?e[i].tensor:e[s];if("float32"!==o.dtype&&"int32"!==o.dtype&&"bool"!==o.dtype&&"string"!==o.dtype&&"complex64"!==o.dtype)throw new Error(`Unsupported dtype in weight '${s}': ${o.dtype}`);const u={name:s,shape:o.shape,dtype:o.dtype};if("string"===o.dtype){const e=new Promise((async e=>{const t=await o.bytes(),n=t.reduce(((e,t)=>e+t.length),0)+xs*t.length,r=new Uint8Array(n);let a=0;for(let e=0;e<t.length;e++){const n=t[e],i=new Uint8Array(new Uint32Array([n.length]).buffer);r.set(i,a),a+=xs,r.set(n,a),a+=n.length}e(r)}));r.push(e)}else r.push(o.data());null!=t&&(u.group=t),n.push(u)}return{data:Ts(await Promise.all(r)),specs:n}},fromMemory:function(e,t,n,r){return new go(yo(...arguments))},fromMemorySync:yo,getLoadHandlers:(e,t)=>$s.getLoadHandlers(e,t),getModelArtifactsForJSON:Rs,getModelArtifactsForJSONSync:Ns,getModelArtifactsInfoForJSON:Fs,getSaveHandlers:e=>$s.getSaveHandlers(e),getWeightSpecs:Os,http:po,isHTTPScheme:co,loadWeights:async function(e,t="",n,r){return uo((e=>oo(e,{requestInit:r})))(e,t,n)},registerLoadRouter:e=>$s.registerLoadRouter(e),registerSaveRouter:e=>$s.registerSaveRouter(e),weightsLoaderFactory:uo,withSaveHandler:function(e){return new mo(e)},withSaveHandlerSync:function(e){return new mo(e)},copyModel:async function(e,t){return _o(e,t,!1)},listModels:async function(){const e=vo.getSchemes(),t={};for(const n of e){const e=await vo.getManager(n).listModels();for(const r in e)t[n+bo+r]=e[r]}return t},moveModel:async function(e,t){return _o(e,t,!0)},removeModel:async function(e){const t=wo(e);return vo.getManager(t.scheme).removeModel(t.path)}});const ko=ys({cast_:function(e,t){const n=fs(e,"x","cast");if(!function(e){return"bool"===e||"complex64"===e||"float32"===e||"int32"===e||"string"===e}(t))throw new Error(`Failed to cast to unknown dtype ${t}`);if("string"===t&&"string"!==n.dtype||"string"!==t&&"string"===n.dtype)throw new Error("Only strings can be casted to strings");const r={x:n},a={dtype:t};return li.runKernel(Kt,r,a)}}),To=ys({matMul_:function(e,t,n=!1,r=!1){let a=fs(e,"a","matMul"),i=fs(t,"b","matMul");[a,i]=ni(a,i);const s={a,b:i},o={transposeA:n,transposeB:r};return li.runKernel(Gt,s,o)}}),Eo=ys({oneHot_:function(e,t,n=1,r=0,a="int32"){if(t<2)throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`);const i={indices:fs(e,"indices","oneHot","int32")},s={dtype:a,depth:t,onValue:n,offValue:r};return li.runKernel(Wn,i,s)}});function So(){return li}function Io(e,t){return li.tidy(e,t)}function Ao(e){ri(e).forEach((e=>e.dispose()))}function Co(e){return li.keep(e)}function No(e){return li.setBackend(e)}function Ro(){return li.backendName}function Fo(e,t,n=1){return li.registerBackend(e,t,n)}const Oo=ys({imag_:function(e){const t={input:fs(e,"input","imag")};return li.runKernel("Imag",t)}}),Mo=ys({neg_:function(e){const t={x:fs(e,"x","neg")};return li.runKernel("Neg",t)}}),$o=ys({real_:function(e){const t={input:fs(e,"input","real")};return li.runKernel("Real",t)}}),Do=ys({transpose_:function(e,t,n){const r=fs(e,"x","transpose");if(null==t&&(t=r.shape.map(((e,t)=>t)).reverse()),nt(r.rank===t.length,(()=>`Error in transpose: rank of input ${r.rank} must match length of perm ${t}.`)),t.forEach((e=>{nt(e>=0&&e<r.rank,(()=>"All entries in 'perm' must be between 0 and "+(r.rank-1)+` but got ${t}`))})),r.rank<=1)return r.clone();const a={x:r},i={perm:t};return"complex64"===r.dtype?Io((()=>{let e=$o(r),t=Oo(r);return e=li.runKernel(Er,{x:e},i),t=li.runKernel(Er,{x:t},i),n&&(t=Mo(t)),bs(e,t)})):li.runKernel(Er,a,i)}});function Po(e,t){const n=e.length,r=[];for(let a=0;a<n;a++){const i=n-1-a,s=e[i]||1;(t[t.length-1-a]||1)>1&&1===s&&r.unshift(i)}return r}function Lo(e,t){const n=[];for(let r=0;r<t.length;r++){const a=e[e.length-r-1],i=t.length-r-1,s=t[i];(null==a||1===a&&s>1)&&n.unshift(i)}return n}function Bo(e,t){const n=[],r=Math.max(e.length,t.length);for(let a=0;a<r;a++){let r=e[e.length-a-1];null==r&&(r=1);let i=t[t.length-a-1];if(null==i&&(i=1),1===r)n.unshift(i);else if(1===i)n.unshift(r);else{if(r!==i)throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`);n.unshift(r)}}return n}function Uo(e,t,n){if(at(e),null!=t&&3!==t.length)throw new Error("tensor3d() requires shape to have three numbers");const r=hs(e,n);if(3!==r.length&&1!==r.length)throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");return vs(e,t,r,n)}let Wo;const Vo=ys({fromPixels_:function(e,t=3){if(t>4)throw new Error("Cannot construct Tensor with more than 4 channels from pixels.");if(null==e)throw new Error("pixels passed to tf.browser.fromPixels() can not be null");let n=!1,r=!1,a=!1,i=!1,s=!1,o=!1;if(e.data instanceof Uint8Array)n=!0;else if("undefined"!=typeof ImageData&&e instanceof ImageData)r=!0;else if("undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement)a=!0;else if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement)i=!0;else if(null!=e.getContext)s=!0;else{if(!("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap))throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`);o=!0}if(null!=Pr(Cr,li.backendName)){const n={pixels:e},r={numChannels:t};return li.runKernel(Cr,n,r)}const[u,l]=a?[e.videoWidth,e.videoHeight]:[e.width,e.height];let c,h;if(s)c=e.getContext("2d").getImageData(0,0,u,l).data;else if(r||n)c=e.data;else if(i||a||o){if(null==Wo)if("undefined"==typeof document){if("undefined"==typeof OffscreenCanvas||"undefined"==typeof OffscreenCanvasRenderingContext2D)throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported.");Wo=new OffscreenCanvas(1,1).getContext("2d")}else Wo=document.createElement("canvas").getContext("2d",{willReadFrequently:!0});Wo.canvas.width=u,Wo.canvas.height=l,Wo.drawImage(e,0,0,u,l),c=Wo.getImageData(0,0,u,l).data}if(4===t)h=new Int32Array(c);else{const e=u*l;h=new Int32Array(e*t);for(let n=0;n<e;n++)for(let e=0;e<t;++e)h[n*t+e]=c[4*n+e]}return Uo(h,[l,u,t],"int32")}});function zo(e,t){const n=e.shape.length,r=t.shape.length;if(n<1)throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);if(r<1)throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);if("int32"!==t.dtype)throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);if(t.shape[r-1]>n)throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r-1]} vs. ${n}`);if(0===it(e.shape))throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);const a=t.shape,i=a[a.length-1];let s=1;for(let e=0;e<a.length-1;++e)s*=a[e];const o=e.shape,u=a.slice();u.pop();let l=1;for(let e=i;e<n;++e)l*=o[e],u.push(o[e]);const c=[...xt(e.shape).map((e=>e/l)),1].slice(0,i);return[u,s,l,c]}function jo(e,t,n){const r=t.rank>1?t.shape[t.rank-1]:1,a=t.rank>1?t.rank-1:1,i=`Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${a}.`;if(n.rank<a)throw new Error(i+` update.rank < ${a}. `);if(e.length<r+(n.rank-a))throw new Error(i+` Output shape length < ${r+(n.rank-a)}`);if(n.rank!==a+e.length-r)throw new Error(i+" update.rank != "+(a+e.length-r));for(let e=0;e<a;++e)if(n.shape[e]!==t.shape[e])throw new Error(i+` updates.shape[${e}] (${n.shape[e]}) != indices.shape[${e}] (${t.shape[e]}).`);for(let t=0;t<n.rank-a;++t)if(n.shape[t+a]!==e[t+r])throw new Error(i+` updates.shape[${t+a}] (${n.shape[t+a]}) != shape[${t+a}] (${e[t+a]})`)}function Go(e,t,n){if(t.rank<1)throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`);if(e.rank<1)throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${e.rank}.`);if("int32"!==t.dtype)throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`);if(n.length<1)throw new Error(`Output rank must be greater or equal to 1, but got shape: ${n}`);if(0===n.length){if(0===t.size)throw new Error(`Indices specified for empty output. indices shape: ${t.shape}`);if(0===e.size)throw new Error(`Updates specified for empty output. updates shape: ${e.shape}`)}jo(n,t,e)}function Ho(e,t,n){const r=t.shape.length,a=r>1?t.shape[r-1]:1,i=n.length;let s=1;for(let e=a;e<i;++e)s*=n[e];const o=a<1?1:a;return{sliceRank:a,numUpdates:it(t.shape)/o,sliceSize:s,strides:[...xt(n.slice(0,a)),1],outputSize:it(n)}}function Ko(e,t,n){const r=e.shape.length;nt(r===t.length,(()=>`Error in slice${r}D: Length of begin ${t} must match the rank of the array (${r}).`)),nt(r===n.length,(()=>`Error in slice${r}D: Length of size ${n} must match the rank of the array (${r}).`));for(let a=0;a<r;++a)nt(t[a]+n[a]<=e.shape[a],(()=>`Error in slice${r}D: begin[${a}] + size[${a}] (${t[a]+n[a]}) would overflow input.shape[${a}] (${e.shape[a]})`))}function qo(e,t,n){const r=[];for(let a=0;a<e.length;a++)r[a]=Math.ceil((t[a]-e[a])/n[a]);return r}function Xo(e,t,n,r){const a=[...e];for(let e=a.length;e<r.length;e++)a.push(1);for(let e=0;e<n;e++)0===e?a[t]=1:(a.splice(t,0,1),a.pop());return a}function Yo(e,t,n){return n<=e?n:n-(t-1)}function Qo(e,t){const n=[];for(let r=0;r<e;r++)n.push(t+r);return n}function Jo(e,t,n,r,a){const i=[...a],s=Qo(n,t);for(let a=0;a<i.length;a++)if(s.indexOf(a)>-1)i[a]=0;else{const s=Yo(t,n,a);let o=r[s];e&1<<s&&(o=0),i[a]=o}return i}function Zo(e,t,n,r,a){const i=[...a],s=Qo(n,t);for(let a=0;a<i.length;a++)if(s.indexOf(a)>-1)i[a]=Number.MAX_SAFE_INTEGER;else{const s=Yo(t,n,a);let o=r[s];e&1<<s&&(o=Number.MAX_SAFE_INTEGER),i[a]=o}for(let e=0;e<i.length;e++){const t=a[e];i[e]<0&&(i[e]+=t),i[e]=Ze(0,i[e],a[e])}return i}function eu(e,t,n){let r=e[t];return(n&1<<t||null==r)&&(r=1),r}function tu(e,t,n,r,a,i){let s=t[a];const o=n[a]||1;(e&1<<a||i&1<<a||null==s)&&(s=o>0?Number.MIN_SAFE_INTEGER:Number.MAX_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=Ze(0,s,u-1),s}function nu(e,t,n,r,a,i){let s=t[a];const o=n[a]||1;(e&1<<a||i&1<<a||null==s)&&(s=o>0?Number.MAX_SAFE_INTEGER:Number.MIN_SAFE_INTEGER);const u=r[a];return s<0&&(s+=u),s=o>0?Ze(0,s,u):Ze(-1,s,u-1),s}function ru(e,t,n){let r=n.length;for(let e=0;e<n.length;e++)if(n[e]>1){r=e;break}for(let a=r+1;a<n.length;a++)if(t[a]>0||n[a]!==e[a])return!1;return!0}function au(e,t){let n=e.length>0?e[e.length-1]:1;for(let r=0;r<e.length-1;r++)n+=e[r]*t[r];return n}function iu(e,t,n){let r;const a=e.shape.length;let i;return r="number"==typeof t?[t,...new Array(a-1).fill(0)]:t.length<a?t.concat(new Array(a-t.length).fill(0)):t.slice(),r.forEach((e=>{nt(-1!==e,(()=>"slice() does not support negative begin indexing."))})),i=null==n?new Array(a).fill(-1):"number"==typeof n?[n,...new Array(a-1).fill(-1)]:n.length<a?n.concat(new Array(a-n.length).fill(-1)):n,i=i.map(((t,n)=>t>=0?t:(nt(-1===t,(()=>`Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`)),e.shape[n]-r[n]))),[r,i]}function su(e,t,n,r,a,i,s,o,u){let l;if(null==r?(l=new Array(t.length),l.fill(1)):l=r,null!=s&&0!=(s&s-1))throw new Error("Multiple ellipses in slice is not allowed.");let c=!1;const h={dims:l.length,numAddAxisAfterEllipsis:0,begin:t.slice(),end:n.slice(),strides:l.slice(),beginMask:a,endMask:i,ellipsisMask:s,newAxisMask:o,shrinkAxisMask:u};for(let e=0;e<h.dims;e++)c&&0!=(1<<e&o)&&h.numAddAxisAfterEllipsis++,1<<e&s&&(c=!0);c||(h.ellipsisMask|=1<<h.dims,h.dims++);const p={dims:e.length,beginMask:0,endMask:0,beginValid:!1,endValid:!1};!function(e,t){t.beginMask=0,t.endMask=0,t.shrinkAxisMask=0;let n=0;t.beginValid=null!=e.begin,t.endValid=null!=e.end,t.begin=new Array(t.dims),t.end=new Array(t.dims),t.strides=new Array(t.dims),t.finalShapeGatherIndices=[],t.finalShapeGatherIndicesSparse=[],t.inputShapeGatherIndicesSparse=new Array(t.dims);for(let r=0;r<e.dims;r++)if(1<<r&e.ellipsisMask){const a=Math.min(t.dims-(e.dims-r)+1+e.numAddAxisAfterEllipsis,t.dims);for(;n<a;n++)t.begin[n]=0,t.end[n]=0,t.strides[n]=1,t.beginMask|=1<<n,t.endMask|=1<<n,t.finalShapeGatherIndices.push(n),t.finalShapeGatherIndicesSparse.push(-1),t.inputShapeGatherIndicesSparse[n]=r}else if(1<<r&e.newAxisMask)t.finalShapeGatherIndices.push(-2),t.finalShapeGatherIndicesSparse.push(-1);else{if(n===t.begin.length)throw Error(`Index out of range using input dim ${n}; input has only ${t.dims} dims, ${t.begin.length}.`);null!=e.begin&&(t.begin[n]=e.begin[r]),null!=e.end&&(t.end[n]=e.end[r]),t.strides[n]=e.strides[r],e.beginMask&1<<r&&(t.beginMask|=1<<n),e.endMask&1<<r&&(t.endMask|=1<<n),e.shrinkAxisMask&1<<r?(t.finalShapeGatherIndices.push(-1),t.finalShapeGatherIndicesSparse.push(-1),t.shrinkAxisMask|=1<<n):(t.finalShapeGatherIndices.push(n),t.finalShapeGatherIndicesSparse.push(r)),t.inputShapeGatherIndicesSparse[n]=r,n++}}(h,p);let d=!0,f=!0,m=!0;const g=[],y=[];for(let t=0;t<e.length;++t){if(0===p.strides[t])throw Error(`strides[${t}] must be non-zero`);const n=!!(p.shrinkAxisMask&1<<t),r=e[t];if(-1===r){g.push(n?1:-1);continue}const a=[p.beginMask&1<<t,p.endMask&1<<t],i=[p.strides[t]>0?0:-1,p.strides[t]>0?r:r-1];if(n&&p.strides[t]<=0)throw Error("only stride 1 allowed on non-range indexing.");m=m&&1===p.strides[t];const s=!!(p.beginMask&1<<t&&p.endMask&1<<t);if(p.beginValid&&p.endValid){if(n){const e=p.begin[t]<0?r+p.begin[t]:p.begin[t];if(p.begin[t]=e,p.end[t]=p.begin[t]+1,e<0||e>=r)throw Error(`slice index ${p.begin[t]} of dimension ${t} out of bounds.`)}else p.begin[t]=ou(p.begin[t],0,p.strides[t],r,a,i),p.end[t]=ou(p.end[t],1,p.strides[t],r,a,i);const e=1===p.strides[t]&&0===p.begin[t]&&p.end[t]===r;d=d&&e,f=f&&(0===t&&1===p.strides[t]||e)}else d=d&&1===p.strides[t]&&s,f=f&&(0===t&&1===p.strides[t]||s);let o,u=!1;if(p.beginValid&&p.endValid?(o=p.end[t]-p.begin[t],u=!0):n?(o=1,u=!0):s&&r>=0&&(o=p.strides[t]<0?-r:r,u=!0),u){let e;e=0===o||o<0!=p.strides[t]<0?0:Math.trunc(o/p.strides[t])+(o%p.strides[t]!=0?1:0),g.push(e)}else g.push(-1)}for(let e=0;e<p.finalShapeGatherIndices.length;++e){const t=p.finalShapeGatherIndices[e];t>=0?y.push(g[t]):-2===t&&y.push(1)}const b=y.filter(((e,t)=>-2!==p.finalShapeGatherIndices[t]));return{finalShapeSparse:b,finalShape:y,isIdentity:d,sliceDim0:f,isSimpleSlice:m,begin:p.begin,end:p.end,strides:p.strides}}function ou(e,t,n,r,a,i){if(a[t])return n>0?i[t]:i[t+1&1];{const t=e<0?r+e:e;return t<i[0]?i[0]:t>i[1]?i[1]:t}}var uu=Object.freeze({__proto__:null,assertParamsValid:Ko,maskToAxes:function(e){const t=[];let n=0;for(;e>0;)1&e&&t.push(n),e/=2,n++;return t},computeOutShape:qo,stridesWithElidedDims:Xo,getNormalizedAxes:function(e,t,n,r,a,i,s,o,u){const l=e.length;let c=new Array(l),h=new Array(l),p=new Array(l);if(t.length&&n>0){const u=t[0],l=n+1;c=Jo(s,u,l,r,e),h=Zo(o,u,l,a,e),p=Xo(i,u,l,e)}else for(let t=0;t<l;t++)c[t]=tu(s,r,i,e,t,u),h[t]=nu(o,a,i,e,t,u),p[t]=eu(i,t,u);return{begin:c,end:h,strides:p}},startIndicesWithElidedDims:Jo,stopIndicesWithElidedDims:Zo,stridesForAxis:eu,startForAxis:tu,stopForAxis:nu,isSliceContinous:ru,computeFlatOffset:au,parseSliceParams:iu,sliceInfo:su});const lu=ys({add_:function(e,t){let n=fs(e,"a","add"),r=fs(t,"b","add");[n,r]=ni(n,r);const a={a:n,b:r};return li.runKernel(Bt,a)}}),cu=ys({floorDiv_:function(e,t){let n=fs(e,"a","floorDiv"),r=fs(t,"b","floorDiv");[n,r]=ni(n,r);const a={a:n,b:r};return li.runKernel(fn,a)}}),hu=ys({div_:function(e,t){let n=fs(e,"a","div"),r=fs(t,"b","div");if([n,r]=ni(n,r),"int32"===n.dtype&&"int32"===r.dtype)return cu(n,r);const a={a:n,b:r};return li.runKernel(sn,a,{})}}),pu=ys({mul_:function(e,t){let n=fs(e,"a","mul"),r=fs(t,"b","mul");[n,r]=ni(n,r);const a={a:n,b:r};return li.runKernel($n,a)}}),du=ys({abs_:function(e){const t=fs(e,"x","abs");if("complex64"===t.dtype){const e={x:t};return li.runKernel("ComplexAbs",e)}{const e={x:t};return li.runKernel("Abs",e)}}}),fu=ys({acos_:function(e){const t={x:fs(e,"x","acos")};return li.runKernel("Acos",t)}}),mu=ys({acosh_:function(e){const t={x:fs(e,"x","acosh")};return li.runKernel("Acosh",t)}}),gu=ys({addN_:function(e){nt(Array.isArray(e),(()=>"The argument passed to tf.addN() must be a list of tensors")),nt(e.length>=1,(()=>`Must pass at least one tensor to tf.addN(), but got ${e.length}`));const t=e.map(((e,t)=>fs(e,`tensors${t}`,"addN"))),n=t[0];t.forEach((e=>{if(e.dtype!==n.dtype)throw new Error("All tensors passed to tf.addN() must have the same dtype")})),t.forEach((e=>{if(!st(e.shape,n.shape))throw new Error("All tensors passed to tf.addN() must have the same shape")}));const r=t;return li.runKernel(Ut,r)}}),yu=ys({all_:function(e,t=null,n=!1){const r={x:fs(e,"x","all","bool")},a={axis:t,keepDims:n};return li.runKernel(Wt,r,a)}}),bu=ys({any_:function(e,t=null,n=!1){const r={x:fs(e,"x","any","bool")},a={axis:t,keepDims:n};return li.runKernel(Vt,r,a)}}),vu=ys({argMax_:function(e,t=0){const n={x:fs(e,"x","argMax")},r={axis:t};return li.runKernel(zt,n,r)}}),wu=ys({argMin_:function(e,t=0){const n={x:fs(e,"x","argMin")},r={axis:t};return li.runKernel("ArgMin",n,r)}}),_u=ys({asin_:function(e){const t={x:fs(e,"x","asin")};return li.runKernel("Asin",t)}}),xu=ys({asinh_:function(e){const t={x:fs(e,"x","asinh")};return li.runKernel("Asinh",t)}}),ku=ys({atan_:function(e){const t={x:fs(e,"x","atan")};return li.runKernel("Atan",t)}}),Tu=ys({atan2_:function(e,t){let n=fs(e,"a","atan2"),r=fs(t,"b","atan2");[n,r]=ni(n,r);const a={a:n,b:r};return li.runKernel("Atan2",a)}}),Eu=ys({atanh_:function(e){const t={x:fs(e,"x","atanh")};return li.runKernel("Atanh",t)}});function Su(e,t,n,r,a,i,s="channelsLast"){const[o,u]=Nu(t);let l;if("channelsLast"===s)l=[o,u,e[3],e[3]];else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);l=[o,u,e[1],e[1]]}return Iu(e,l,n,r,a,i,!1,s)}function Iu(e,t,n,r,a,i,s=!1,o="channelsLast"){let[u,l,c,h]=[-1,-1,-1,-1];if("channelsLast"===o)[u,l,c,h]=e;else{if("channelsFirst"!==o)throw new Error(`Unknown dataFormat ${o}`);[u,h,l,c]=e}const[p,d,,f]=t,[m,g]=Nu(n),[y,b]=Nu(r),v=Fu(p,y),w=Fu(d,b),{padInfo:_,outHeight:x,outWidth:k}=function(e,t,n,r,a,i,s,o,u){let l,c,h;if("number"==typeof e){l={top:e,bottom:e,left:e,right:e,type:0===e?"VALID":"NUMBER"};const a=function(e,t,n,r,a){null==r&&(r=Cu(e,t,n));const i=e[1];return[Ou((e[0]-t+2*r)/n+1,a),Ou((i-t+2*r)/n+1,a)]}([t,n],i,r,e,o);c=a[0],h=a[1]}else if("same"===e){c=Math.ceil(t/r),h=Math.ceil(n/a);const e=Math.max(0,(c-1)*r+i-t),o=Math.max(0,(h-1)*a+s-n),u=Math.floor(e/2),p=e-u,d=Math.floor(o/2);l={top:u,bottom:p,left:d,right:o-d,type:"SAME"}}else if("valid"===e)l={top:0,bottom:0,left:0,right:0,type:"VALID"},c=Math.ceil((t-i+1)/r),h=Math.ceil((n-s+1)/a);else{if("object"!=typeof e)throw Error(`Unknown padding parameter: ${e}`);{const p="channelsLast"===u?e[1][0]:e[2][0],d="channelsLast"===u?e[1][1]:e[2][1],f="channelsLast"===u?e[2][0]:e[3][0],m="channelsLast"===u?e[2][1]:e[3][1];l={top:p,bottom:d,left:f,right:m,type:0===p&&0===d&&0===f&&0===m?"VALID":"EXPLICIT"},c=Ou((t-i+p+d)/r+1,o),h=Ou((n-s+f+m)/a+1,o)}}return{padInfo:l,outHeight:c,outWidth:h}}(a,l,c,m,g,v,w,i,o),T=s?f*h:f;let E;return"channelsFirst"===o?E=[u,T,x,k]:"channelsLast"===o&&(E=[u,x,k,T]),{batchSize:u,dataFormat:o,inHeight:l,inWidth:c,inChannels:h,outHeight:x,outWidth:k,outChannels:T,padInfo:_,strideHeight:m,strideWidth:g,filterHeight:p,filterWidth:d,effectiveFilterHeight:v,effectiveFilterWidth:w,dilationHeight:y,dilationWidth:b,inShape:e,outShape:E,filterShape:t}}function Au(e,t,n,r,a,i=!1,s="channelsLast",o){let[u,l,c,h,p]=[-1,-1,-1,-1,-1];if("channelsLast"===s)[u,l,c,h,p]=e;else{if("channelsFirst"!==s)throw new Error(`Unknown dataFormat ${s}`);[u,p,l,c,h]=e}const[d,f,m,,g]=t,[y,b,v]=Ru(n),[w,_,x]=Ru(r),k=Fu(d,w),T=Fu(f,_),E=Fu(m,x),{padInfo:S,outDepth:I,outHeight:A,outWidth:C}=function(e,t,n,r,a,i,s,o,u,l,c){let h,p,d,f;if("valid"===e&&(e=0),"number"==typeof e){h={top:e,bottom:e,left:e,right:e,front:e,back:e,type:0===e?"VALID":"NUMBER"};const m=function(e,t,n,r,a,i){null==a&&(a=Cu(e,t[0],r[0]));const s=[0,0,0,1];for(let n=0;n<3;n++)e[n]+2*a>=t[n]&&(s[n]=Ou((e[n]-t[n]+2*a)/r[n]+1,i));return s}([t,n,r,1],[o,u,l],0,[a,i,s],e,c);p=m[0],d=m[1],f=m[2]}else{if("same"!==e)throw Error(`Unknown padding parameter: ${e}`);{p=Math.ceil(t/a),d=Math.ceil(n/i),f=Math.ceil(r/s);const e=(p-1)*a+o-t,c=(d-1)*i+u-n,m=(f-1)*s+l-r,g=Math.floor(e/2),y=e-g,b=Math.floor(c/2),v=c-b,w=Math.floor(m/2);h={top:b,bottom:v,left:w,right:m-w,front:g,back:y,type:"SAME"}}}return{padInfo:h,outDepth:p,outHeight:d,outWidth:f}}(a,l,c,h,y,b,v,k,T,E,o),N=i?g*p:g;let R;return"channelsFirst"===s?R=[u,N,I,A,C]:"channelsLast"===s&&(R=[u,I,A,C,N]),{batchSize:u,dataFormat:s,inDepth:l,inHeight:c,inWidth:h,inChannels:p,outDepth:I,outHeight:A,outWidth:C,outChannels:N,padInfo:S,strideDepth:y,strideHeight:b,strideWidth:v,filterDepth:d,filterHeight:f,filterWidth:m,effectiveFilterDepth:k,effectiveFilterHeight:T,effectiveFilterWidth:E,dilationDepth:w,dilationHeight:_,dilationWidth:x,inShape:e,outShape:R,filterShape:t}}function Cu(e,t,n,r=1){const a=Fu(t,r);return Math.floor((e[0]*(n-1)-n+a)/2)}function Nu(e){return"number"==typeof e?[e,e,e]:2===e.length?[e[0],e[1],1]:e}function Ru(e){return"number"==typeof e?[e,e,e]:e}function Fu(e,t){return t<=1?e:e+(e-1)*(t-1)}function Ou(e,t){if(!t)return Math.trunc(e);switch(t){case"round":return Math.round(e);case"ceil":return Math.ceil(e);case"floor":return Math.floor(e);default:throw new Error(`Unknown roundingMode ${t}`)}}function Mu(e){const[t,n,r]=Nu(e);return 1===t&&1===n&&1===r}function $u(e,t){return Mu(e)||Mu(t)}function Du(e){return Nu(e).every((e=>e>0))}function Pu(e){if("NHWC"===e)return"channelsLast";if("NCHW"===e)return"channelsFirst";throw new Error(`Unknown dataFormat ${e}`)}function Lu(e,t,n){if(null!=n){if("string"==typeof t)throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);if("number"==typeof t)nt(ot(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`));else{if("object"!=typeof t)throw Error(`Error in ${e}: Unknown padding parameter: ${t}`);t.forEach((t=>{t.forEach((t=>{nt(ot(t),(()=>`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`))}))}))}}}const Bu=ys({reshape_:function(e,t){const n={x:fs(e,"x","reshape","string_or_numeric")},r={shape:t};return li.runKernel(Xn,n,r)}}),Uu=ys({avgPool_:function(e,t,n,r,a){const i=fs(e,"x","avgPool","float32");nt($u(n,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`));let s=i,o=!1;3===i.rank&&(o=!0,s=Bu(i,[1,i.shape[0],i.shape[1],i.shape[2]])),nt(4===s.rank,(()=>`Error in avgPool: x must be rank 4 but got rank ${s.rank}.`)),Lu("avgPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a};let c=li.runKernel(jt,u,l);return c=ko(c,i.dtype),o?Bu(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),Wu=ys({avgPool3d_:function(e,t,n,r,a,i="NDHWC"){const s=fs(e,"x","avgPool3d","float32");let o=s,u=!1;4===s.rank&&(u=!0,o=Bu(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),nt(5===o.rank,(()=>`Error in avgPool3d: x must be rank 5 but got rank ${o.rank}.`)),nt("NDHWC"===i,(()=>`Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${i}`)),nt("number"==typeof n&&n>0||Array.isArray(n)&&n[0]>0&&n[1]>0&&n[2]>0,(()=>`Error in avgPool3d: Stride must be > 0, but got '${n}'`)),Lu("avgPool3d",r,a);const l={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i};let h=li.runKernel("AvgPool3D",l,c);return h=ko(h,o.dtype),u?Bu(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}}),Vu=ys({clone_:function(e){const t={x:fs(e,"x","clone","string_or_numeric")};return li.runKernel(wn,t)}}),zu=ys({concat_:function(e,t=0){nt(e.length>=1,(()=>"Pass at least one tensor to concat"));const n=ms(e,"tensors","concat","string_or_numeric");if("complex64"===n[0].dtype&&n.forEach((e=>{if("complex64"!==e.dtype)throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${e.dtype}. `)})),1===n.length)return Vu(n[0]);const r=n,a={axis:t};return li.runKernel(Yt,r,a)}}),ju=ys({sigmoid_:function(e){const t={x:fs(e,"x","sigmoid","float32")};return li.runKernel(ir,t)}}),Gu=ys({slice_:function(e,t,n){const r=fs(e,"x","slice","string_or_numeric");if(0===r.rank)throw new Error("Slicing scalar is not possible");const a={x:r},i={begin:t,size:n};return li.runKernel(ar,a,i)}}),Hu=ys({tanh_:function(e){const t={x:fs(e,"x","tanh","float32")};return li.runKernel(_r,t)}}),Ku=ys({basicLSTMCell_:function(e,t,n,r,a,i){const s=fs(e,"forgetBias","basicLSTMCell"),o=fs(t,"lstmKernel","basicLSTMCell"),u=fs(n,"lstmBias","basicLSTMCell"),l=fs(r,"data","basicLSTMCell"),c=fs(a,"c","basicLSTMCell"),h=fs(i,"h","basicLSTMCell"),p=zu([l,h],1),d=To(p,o),f=lu(d,u),m=f.shape[0],g=f.shape[1]/4,y=[m,g],b=Gu(f,[0,0],y),v=Gu(f,[0,g],y),w=Gu(f,[0,2*g],y),_=Gu(f,[0,3*g],y),x=lu(pu(ju(b),Hu(v)),pu(c,ju(lu(s,w))));return[x,pu(Hu(x),ju(_))]}}),qu=ys({batchToSpaceND_:function(e,t,n){const r=fs(e,"x","batchToSpaceND"),a=t.reduce(((e,t)=>e*t));nt(r.rank>=1+t.length,(()=>`input rank is ${r.rank} but should be > than blockShape.length ${t.length}`)),nt(n.length===t.length,(()=>`crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`)),nt(r.shape[0]%a==0,(()=>`input tensor batch is ${r.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${a}`));const i={x:r},s={blockShape:t,crops:n};return li.runKernel(Ht,i,s)}}),Xu=ys({batchNorm_:function(e,t,n,r,a,i){null==i&&(i=.001);const s=fs(e,"x","batchNorm"),o=fs(t,"mean","batchNorm"),u=fs(n,"variance","batchNorm");let l,c;null!=a&&(l=fs(a,"scale","batchNorm")),null!=r&&(c=fs(r,"offset","batchNorm")),nt(o.rank===u.rank,(()=>"Batch normalization gradient requires mean and variance to have equal ranks.")),nt(null==c||o.rank===c.rank,(()=>"Batch normalization gradient requires mean and offset to have equal ranks.")),nt(null==l||o.rank===l.rank,(()=>"Batch normalization gradient requires mean and scale to have equal ranks."));const h=function(e){let t;return t=0===e.rank||1===e.rank?Bu(e,[1,1,1,e.size]):2===e.rank?Bu(e,[1,1,e.shape[0],e.shape[1]]):3===e.rank?Bu(e,[1,e.shape[0],e.shape[1],e.shape[2]]):e,t}(s),p={x:h,scale:l,offset:c,mean:o,variance:u},d={varianceEpsilon:i},f=li.runKernel(mn,p,d);return Bu(f,s.shape)}}),Yu=ys({batchNorm2d_:function(e,t,n,r,a,i){const s=fs(e,"x","batchNorm"),o=fs(t,"mean","batchNorm"),u=fs(n,"variance","batchNorm");let l,c;return null!=a&&(l=fs(a,"scale","batchNorm")),null!=r&&(c=fs(r,"offset","batchNorm")),nt(2===s.rank,(()=>`Error in batchNorm2D: x must be rank 2 but got rank ${s.rank}.`)),nt(2===o.rank||1===o.rank,(()=>`Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${o.rank}.`)),nt(2===u.rank||1===u.rank,(()=>`Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`)),null!=l&&nt(2===l.rank||1===l.rank,(()=>`Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`)),null!=c&&nt(2===c.rank||1===c.rank,(()=>`Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${c.rank}.`)),Xu(s,o,u,c,l,i)}}),Qu=ys({batchNorm3d_:function(e,t,n,r,a,i){const s=fs(e,"x","batchNorm"),o=fs(t,"mean","batchNorm"),u=fs(n,"variance","batchNorm");let l,c;return null!=a&&(l=fs(a,"scale","batchNorm")),null!=r&&(c=fs(r,"offset","batchNorm")),nt(3===s.rank,(()=>`Error in batchNorm3D: x must be rank 3 but got rank ${s.rank}.`)),nt(3===o.rank||1===o.rank,(()=>`Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${o.rank}.`)),nt(3===u.rank||1===u.rank,(()=>`Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`)),null!=l&&nt(3===l.rank||1===l.rank,(()=>`Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`)),null!=c&&nt(3===c.rank||1===c.rank,(()=>`Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${c.rank}.`)),Xu(s,o,u,c,l,i)}}),Ju=ys({batchNorm4d_:function(e,t,n,r,a,i){const s=fs(e,"x","batchNorm"),o=fs(t,"mean","batchNorm"),u=fs(n,"variance","batchNorm");let l,c;return null!=a&&(l=fs(a,"scale","batchNorm")),null!=r&&(c=fs(r,"offset","batchNorm")),nt(4===s.rank,(()=>`Error in batchNorm4D: x must be rank 4 but got rank ${s.rank}.`)),nt(4===o.rank||1===o.rank,(()=>`Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${o.rank}.`)),nt(4===u.rank||1===u.rank,(()=>`Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`)),null!=l&&nt(4===l.rank||1===l.rank,(()=>`Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`)),null!=c&&nt(4===c.rank||1===c.rank,(()=>`Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${c.rank}.`)),Xu(s,o,u,c,l,i)}}),Zu=ys({bincount_:function(e,t,n){const r=fs(e,"x","bincount"),a=fs(t,"weights","bincount");nt("int32"===r.dtype,(()=>`Error in bincount: input dtype must be int32, but got ${r.dtype}`)),nt(n>=0,(()=>`size must be non-negative, but got ${n}.`)),nt(a.size===r.size||0===a.size,(()=>`Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${a.shape}.`));const i={x:r,weights:a},s={size:n};return li.runKernel("Bincount",i,s)}}),el=ys({broadcastArgs_:function(e,t){const n=fs(e,"s0","broadcastArgs","int32"),r=fs(t,"s1","broadcastArgs","int32");if(1!==n.rank)throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`);if(1!==r.rank)throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${r.rank}`);const a={s0:n,s1:r};return li.runKernel("BroadcastArgs",a)}}),tl=ys({broadcastTo_:function(e,t){let n=fs(e,"broadcastTo","x");const r=n.shape;if(It(t),t.length<n.rank)throw new Error(`broadcastTo(): shape.length=${t.length} < input.rank=${n.rank}.`);if(t.length>n.rank){const e=n.shape.slice();for(;e.length<t.length;)e.unshift(1);n=Bu(n,e)}const a=n.shape,i=Array.from(t);for(let e=t.length-1;e>=0;e--)if(a[e]===t[e])i[e]=1;else if(1!==n.shape[e])throw new Error(`broadcastTo(): [${r}] cannot be broadcast to [${t}].`);const s=i.map(((e,t)=>e>1?t:-1)).filter((e=>e>=0));if(0===s.length)return Vu(n);const o={x:n},u={reps:i};return li.runKernel(xr,o,u)}});function nl(e,t="float32",n){return t=t||"float32",It(e),new ja(e,t,n)}const rl=ys({ceil_:function(e){const t={x:fs(e,"x","ceil","float32")};return li.runKernel(qt,t)}});function al(e,t,n){It(e);const r={shape:e,value:t,dtype:n};return li.runKernel(hn,{},r)}const il=ys({clipByValue_:function(e,t,n){const r=fs(e,"x","clipByValue");if(nt(t<=n,(()=>`Error in clip: min (${t}) must be less than or equal to max (${n}).`)),t===n)return al(r.shape,t,r.dtype);const a={x:r},i={clipValueMin:t,clipValueMax:n};return li.runKernel(Xt,a,i)}}),sl=ys({concat1d_:function(e){return zu(e,0)}}),ol=ys({concat2d_:function(e,t){return zu(e,t)}}),ul=ys({concat3d_:function(e,t){return zu(e,t)}}),ll=ys({concat4d_:function(e,t){return zu(e,t)}}),cl=ys({conv2d_:function(e,t,n,r,a="NHWC",i=[1,1],s){const o=fs(e,"x","conv2d","float32"),u=fs(t,"filter","conv2d","float32");let l=o,c=!1;3===o.rank&&(c=!0,l=Bu(o,[1,o.shape[0],o.shape[1],o.shape[2]])),nt(4===l.rank,(()=>`Error in conv2d: input must be rank 4, but got rank ${l.rank}.`)),nt(4===u.rank,(()=>`Error in conv2d: filter must be rank 4, but got rank ${u.rank}.`)),Lu("conv2d",r,s);const h="NHWC"===a?l.shape[3]:l.shape[1];nt(h===u.shape[2],(()=>`Error in conv2d: depth of input (${h}) must match input depth for filter ${u.shape[2]}.`)),nt($u(n,i),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`)),nt(Du(i),(()=>"Error in conv2D: Dilated rates should be larger than 0.")),nt(Du(n),(()=>"Error in conv2D: Strides should be larger than 0."));const p={x:l,filter:u},d={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s},f=li.runKernel(Qt,p,d);return c?Bu(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),hl=ys({conv1d_:function(e,t,n,r,a="NWC",i=1,s){const o=fs(e,"x","conv1d"),u=fs(t,"filter","conv1d");let l=o,c=!1;2===o.rank&&(c=!0,l=Bu(o,[1,o.shape[0],o.shape[1]])),nt(3===l.rank,(()=>`Error in conv1d: input must be rank 3, but got rank ${l.rank}.`)),nt(3===u.rank,(()=>`Error in conv1d: filter must be rank 3, but got rank ${u.rank}.`)),Lu("conv1d",r,s),nt(l.shape[2]===u.shape[1],(()=>`Error in conv1d: depth of input (${l.shape[2]}) must match input depth for filter ${u.shape[1]}.`)),nt($u(n,i),(()=>`Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${i}'`)),nt(Du(i),(()=>"Error in conv1D: Dilated rates should be larger than 0.")),nt(Du(n),(()=>"Error in conv1D: Stride should be larger than 0.")),nt("NWC"===a,(()=>`Error in conv1d: got dataFormat of ${a} but only NWC is currently supported.`));const h=Bu(u,[1,u.shape[0],u.shape[1],u.shape[2]]),p=Bu(l,[l.shape[0],1,l.shape[1],l.shape[2]]),d=cl(p,h,[1,n],r,"NHWC",[1,i],s);return Bu(d,c?[d.shape[2],d.shape[3]]:[d.shape[0],d.shape[2],d.shape[3]])}}),pl=ys({conv2DBackpropInput_:function(e,t,n,r,a,i="NHWC",s){nt(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let o=e,u=t,l=!1;3===t.rank&&(l=!0,u=Bu(t,[1,t.shape[0],t.shape[1],t.shape[2]]),o=[1,e[0],e[1],e[2]]),nt(4===o.length,(()=>`Error in conv2dDerInput: inShape must be length 4, but got length ${o.length}.`)),nt(4===u.rank,(()=>`Error in conv2dDerInput: dy must be rank 4, but got rank ${u.rank}`)),nt(4===n.rank,(()=>`Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`));const c="NHWC"===i?o[3]:o[1],h="NHWC"===i?u.shape[3]:u.shape[1];nt(c===n.shape[2],(()=>`Error in conv2dDerInput: depth of input (${c}) must match input depth for filter ${n.shape[2]}.`)),nt(h===n.shape[3],(()=>`Error in conv2dDerInput: depth of output (${h}) must match output depth for filter ${n.shape[3]}.`)),Lu("conv2dDerInput",a,s);const p={dy:u,filter:n},d={strides:r,pad:a,dataFormat:i,dimRoundingMode:s,inputShape:o},f=li.runKernel(Jt,p,d);return l?Bu(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),dl=ys({conv2dTranspose_:function(e,t,n,r,a,i){const s=fs(e,"x","conv2dTranspose"),o=fs(t,"filter","conv2dTranspose");return pl(n,s,o,r,a,"NHWC",i)}}),fl=ys({conv3d_:function(e,t,n,r,a="NDHWC",i=[1,1,1]){const s=fs(e,"x","conv3d"),o=fs(t,"filter","conv3d");let u=s,l=!1;4===s.rank&&(l=!0,u=Bu(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),nt(5===u.rank,(()=>`Error in conv3d: input must be rank 5, but got rank ${u.rank}.`)),nt(5===o.rank,(()=>`Error in conv3d: filter must be rank 5, but got rank ${o.rank}.`)),nt(u.shape[4]===o.shape[3],(()=>`Error in conv3d: depth of input (${u.shape[4]}) must match input depth for filter ${o.shape[3]}.`)),nt($u(n,i),(()=>`Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`)),nt("NDHWC"===a,(()=>`Error in conv3d: got dataFormat of ${a} but only NDHWC is currently supported.`)),nt(Du(i),(()=>"Error in conv3D: Dilated rates should be larger than 0.")),nt(Du(n),(()=>"Error in conv3D: Strides should be larger than 0."));const c={x:u,filter:o},h={strides:n,pad:r,dataFormat:a,dilations:i},p=li.runKernel("Conv3D",c,h);return l?Bu(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),ml=ys({conv3DBackpropInput_:function(e,t,n,r,a){nt(e.length===t.rank,(()=>`Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`));let i=e,s=t,o=!1;4===t.rank&&(o=!0,s=Bu(t,[1,t.shape[0],t.shape[1],t.shape[2],t.shape[3]]),i=[1,e[0],e[1],e[2],e[3]]);const u=i[4],l=s.shape[4];nt(5===i.length,(()=>`Error in conv3dDerInput: inShape must be length 5, but got length ${i.length}.`)),nt(5===s.rank,(()=>`Error in conv3dDerInput: dy must be rank 5, but got rank ${s.rank}`)),nt(5===n.rank,(()=>`Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)),nt(u===n.shape[3],(()=>`Error in conv3dDerInput: depth of input (${u}) must match input depth for filter ${n.shape[3]}.`)),nt(l===n.shape[4],(()=>`Error in conv3dDerInput: depth of output (${l}) must match output depth for filter ${n.shape[4]}.`));const c={dy:s,filter:n},h={pad:a,strides:r,inputShape:i},p=li.runKernel("Conv3DBackpropInputV2",c,h);return o?Bu(p,[p.shape[1],p.shape[2],p.shape[3],p.shape[4]]):p}}),gl=ys({conv3dTranspose_:function(e,t,n,r,a){const i=fs(e,"x","conv3dTranspose"),s=fs(t,"filter","conv3dTranspose");return ml(n,i,s,r,a)}}),yl=ys({cos_:function(e){const t={x:fs(e,"x","cos","float32")};return li.runKernel("Cos",t)}}),bl=ys({cosh_:function(e){const t={x:fs(e,"x","cosh","float32")};return li.runKernel(Zt,t)}}),vl=ys({cumprod_:function(e,t=0,n=!1,r=!1){const a={x:fs(e,"x","cumprod")},i={axis:t,exclusive:n,reverse:r};return li.runKernel(en,a,i)}}),wl=ys({cumsum_:function(e,t=0,n=!1,r=!1){const a={x:fs(e,"x","cumsum")},i={axis:t,exclusive:n,reverse:r};return li.runKernel(tn,a,i)}}),_l=ys({denseBincount_:function(e,t,n,r=!1){const a=fs(e,"x","denseBincount"),i=fs(t,"weights","denseBincount");nt("int32"===a.dtype,(()=>`Error in denseBincount: input dtype must be int32, but got ${a.dtype}`)),nt(a.rank<=2,(()=>`Error in denseBincount: input must be at most rank 2, but got rank ${a.rank}.`)),nt(n>=0,(()=>`size must be non-negative, but got ${n}.`)),nt(i.size===a.size||0===i.size,(()=>`Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${a.shape}, weights shape: ${i.shape}.`));const s={x:a,weights:i},o={size:n,binaryOutput:r};return li.runKernel("DenseBincount",s,o)}}),xl=ys({depthToSpace_:function(e,t,n="NHWC"){const r=fs(e,"x","depthToSpace","float32"),a="NHWC"===n?r.shape[1]:r.shape[2],i="NHWC"===n?r.shape[2]:r.shape[3],s="NHWC"===n?r.shape[3]:r.shape[1];nt(t>1,(()=>`blockSize should be > 1 for depthToSpace, but was: ${t}`)),nt(a*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${a} and ${t} for depthToSpace with input shape\n ${r.shape}`)),nt(i*t>=0,(()=>`Negative dimension size caused by overflow when multiplying\n ${i} and ${t} for depthToSpace with input shape\n ${r.shape}`)),nt(s%(t*t)==0,(()=>`Dimension size must be evenly divisible by ${t*t} but is ${s} for depthToSpace with input shape ${r.shape}`));const o={x:r},u={blockSize:t,dataFormat:n};return li.runKernel(rn,o,u)}}),kl=ys({depthwiseConv2d_:function(e,t,n,r,a="NHWC",i=[1,1],s){const o=fs(e,"x","depthwiseConv2d","float32"),u=fs(t,"filter","depthwiseConv2d","float32");let l=o,c=!1;3===o.rank&&(c=!0,l=Bu(o,[1,o.shape[0],o.shape[1],o.shape[2]])),nt(4===l.rank,(()=>`Error in depthwiseConv2d: input must be rank 4, but got rank ${l.rank}.`)),nt(4===u.rank,(()=>`Error in depthwiseConv2d: filter must be rank 4, but got rank ${u.rank}.`));const h="NHWC"===a?l.shape[3]:l.shape[1];nt(h===u.shape[2],(()=>`Error in depthwiseConv2d: number of input channels (${h}) must match the inChannels dimension in filter ${u.shape[2]}.`)),Lu("depthwiseConv2d",r,s);const p={x:l,filter:u},d={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s},f=li.runKernel(an,p,d);return c?Bu(f,[f.shape[1],f.shape[2],f.shape[3]]):f}}),Tl=ys({diag_:function(e){const t={x:fs(e,"x","diag")};return li.runKernel("Diag",t)}}),El=ys({dilation2d_:function(e,t,n,r,a=[1,1],i="NHWC"){const s=fs(e,"x","dilation2d"),o=fs(t,"filter","dilation2d");nt(3===s.rank||4===s.rank,(()=>`Error in dilation2d: input must be rank 3 or 4, but got rank ${s.rank}.`)),nt(3===o.rank,(()=>`Error in dilation2d: filter must be rank 3, but got rank ${o.rank}.`)),nt("NHWC"===i,(()=>`Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${i}`));let u=s,l=!1;3===s.rank&&(u=Bu(s,[1,s.shape[0],s.shape[1],s.shape[2]]),l=!0),nt(u.shape[3]===o.shape[2],(()=>`Error in dilation2d: input and filter must have the same depth: ${u.shape[3]} vs ${o.shape[2]}`));const c={x:u,filter:o},h={strides:n,pad:r,dilations:a},p=li.runKernel("Dilation2D",c,h);return l?Bu(p,[p.shape[1],p.shape[2],p.shape[3]]):p}}),Sl=ys({equal_:function(e,t){let n=fs(e,"a","equal","string_or_numeric"),r=fs(t,"b","equal","string_or_numeric");[n,r]=ni(n,r),Bo(n.shape,r.shape);const a={a:n,b:r};return li.runKernel(un,a)}}),Il=ys({where_:function(e,t,n){const r=fs(t,"a","where"),a=fs(n,"b","where"),i=fs(e,"condition","where","bool"),s=Bo(Bo(i.shape,r.shape),a.shape),o={condition:tl(i,s),t:tl(r,s),e:tl(a,s)};return li.runKernel(rr,o)}}),Al=ys({zerosLike_:function(e){const t={x:fs(e,"x","zerosLike")};return li.runKernel(Ir,t)}}),Cl=ys({divNoNan_:function(e,t){let n=fs(e,"a","div"),r=fs(t,"b","div");[n,r]=ni(n,r);const a=hu(n,r),i=Al(a),s=Sl(r,i);return Il(s,i,a)}}),Nl=ys({dot_:function(e,t){const n=fs(e,"t1","dot"),r=fs(t,"t2","dot");nt(!(1!==n.rank&&2!==n.rank||1!==r.rank&&2!==r.rank),(()=>`Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`));const a=1===n.rank?n.size:n.shape[1],i=1===r.rank?r.size:r.shape[0];if(nt(a===i,(()=>`Error in dot: inner dimensions of inputs must match, but got ${a} and ${i}.`)),1===n.rank&&1===r.rank){const e=Bu(n,[1,-1]),t=Bu(r,[-1,1]),a=To(e,t);return Bu(a,[])}if(1===n.rank&&2===r.rank){const e=Bu(n,[1,-1]),t=Bu(r,[r.shape[0],r.shape[1]]),a=To(e,t);return Bu(a,[a.size])}if(2===n.rank&&1===r.rank){const e=Bu(r,[-1,1]),t=To(n,e);return Bu(t,[t.size])}{const e=Bu(r,[r.shape[0],r.shape[1]]);return To(n,e)}}}),Rl=ys({einsum_:function(e,...t){const n=t.map(((e,t)=>fs(e,`tensors${t}`,"einsum"))),r={equation:e};return li.runKernel("Einsum",n,r)}}),Fl=ys({elu_:function(e){const t={x:fs(e,"x","elu","float32")};return li.runKernel(on,t)}}),Ol=ys({erf_:function(e){let t=fs(e,"x","erf");nt("int32"===t.dtype||"float32"===t.dtype,(()=>"Input dtype must be `int32` or `float32`.")),"int32"===t.dtype&&(t=ko(t,"float32"));const n={x:t};return li.runKernel("Erf",n)}});function Ml(e,t){for(let n=0;n<e.length;++n)if(e[e.length-n-1]!==t-1-n)return!1;return!0}function $l(e,t,n){const r=e.length+t.length,a=[];let i=0,s=0;for(let o=0;o<r;o++)-1===n.indexOf(o)?a.push(e[i++]):a.push(t[s++]);return a}function Dl(e,t){const n=[],r=e.length;for(let a=0;a<r;a++)-1===t.indexOf(a)&&n.push(e[a]);return[n,t.map((t=>e[t]))]}function Pl(e,t){return $l(e,t.map((e=>1)),t)}function Ll(e,t,n){nt(Ml(t,n),(()=>`${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`))}function Bl(e,t){if(Ml(e,t))return null;const n=[];for(let r=0;r<t;++r)-1===e.indexOf(r)&&n.push(r);return e.forEach((e=>n.push(e))),n}function Ul(e){return e.map(((e,t)=>[t,e])).sort(((e,t)=>e[1]-t[1])).map((e=>e[0]))}function Wl(e,t){const n=[];for(let r=t-e;r<t;++r)n.push(r);return n}const Vl=ys({max_:function(e,t=null,n=!1){const r={x:fs(e,"x","max")},a={reductionIndices:t,keepDims:n};return li.runKernel(An,r,a)}}),zl=ys({min_:function(e,t=null,n=!1){const r={x:fs(e,"x","min")},a={axis:t,keepDims:n};return li.runKernel(Fn,r,a)}}),jl=ys({pow_:function(e,t){let n=fs(e,"base","pow"),r=fs(t,"exp","pow");[n,r]=ni(n,r);const a={a:n,b:r};return li.runKernel("Pow",a)}});function Gl(e,t){if((Ra(e)&&"string"!==t||Array.isArray(e))&&"complex64"!==t)throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)");if("string"===t&&Ra(e)&&!(e instanceof Uint8Array))throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`.");return vs(e,[],[],t)}const Hl=ys({sqrt_:function(e){const t={x:fs(e,"x","sqrt","float32")};return li.runKernel(sr,t)}}),Kl=ys({square_:function(e){const t=fs(e,"x","square");return li.runKernel("Square",{x:t},{})}}),ql=ys({sum_:function(e,t=null,n=!1){let r=fs(e,"x","sum");"bool"===r.dtype&&(r=ko(r,"int32"));const a={x:r},i={axis:t,keepDims:n};return li.runKernel(or,a,i)}});function Xl(e,t,n=null){if(0===e.rank)return du(e);if(1!==e.rank&&null===n)return Xl(Bu(e,[-1]),t,n);if(1===e.rank||"number"==typeof n||Array.isArray(n)&&1===n.length){if(1===t)return ql(du(e),n);if(t===1/0)return Vl(du(e),n);if(t===-1/0)return zl(du(e),n);if("euclidean"===t||2===t)return Hl(ql(jl(du(e),Gl(2,"int32")),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}if(Array.isArray(n)&&2===n.length){if(1===t)return Vl(ql(du(e),n[0]),n[1]-1);if(t===1/0)return Vl(ql(du(e),n[1]),n[0]);if(t===-1/0)return zl(ql(du(e),n[1]),n[0]);if("fro"===t||"euclidean"===t)return Hl(ql(Kl(e),n));throw new Error(`Error in norm: invalid ord value: ${t}`)}throw new Error(`Error in norm: invalid axis: ${n}`)}const Yl=ys({norm_:function(e,t="euclidean",n=null,r=!1){const a=Xl(e=fs(e,"x","norm"),t,n);let i=a.shape;if(r){const t=pt(n,e.shape);i=Pl(a.shape,t)}return Bu(a,i)}}),Ql=ys({euclideanNorm_:function(e,t=null,n=!1){return Yl(e,"euclidean",t,n)}}),Jl=ys({exp_:function(e){const t={x:fs(e,"x","exp")};return li.runKernel(ln,t)}}),Zl=ys({expandDims_:function(e,t=0){const n=fs(e,"x","expandDims","string_or_numeric");nt(t<=n.rank,(()=>"Axis must be <= rank of the tensor"));const r={input:n},a={dim:t};return li.runKernel(cn,r,a)}}),ec=ys({expm1_:function(e){const t={x:fs(e,"x","expm1")};return li.runKernel("Expm1",t)}}),tc=ys({tile_:function(e,t){const n=fs(e,"x","tile","string_or_numeric");nt(n.rank===t.length,(()=>`Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`));const r={x:n},a={reps:t};return li.runKernel(xr,r,a)}}),nc=ys({eye_:function(e,t,n,r="float32"){null==t&&(t=e);const a=nl([e,t],r),i=e<=t?e:t;for(let e=0;e<i;++e)a.set(1,e,e);const s=Bu(a.toTensor(),[e,t]);if(null==n)return s;if(1===n.length)return tc(Zl(s,0),[n[0],1,1]);if(2===n.length)return tc(Zl(Zl(s,0),0),[n[0],n[1],1,1]);if(3===n.length)return tc(Zl(Zl(Zl(s,0),0),0),[n[0],n[1],n[2],1,1]);throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`)}}),rc=ys({floor_:function(e){const t={x:fs(e,"x","floor","float32")};return li.runKernel(dn,t)}}),ac=ys({gather_:function(e,t,n=0,r=0){const a={x:fs(e,"x","gather"),indices:fs(t,"indices","gather","int32")},i={axis:n,batchDims:r};return li.runKernel(gn,a,i)}}),ic=ys({greater_:function(e,t){let n=fs(e,"a","greater","string_or_numeric"),r=fs(t,"b","greater","string_or_numeric");[n,r]=ni(n,r),Bo(n.shape,r.shape);const a={a:n,b:r};return li.runKernel(bn,a)}}),sc=ys({greaterEqual_:function(e,t){let n=fs(e,"a","greaterEqual","string_or_numeric"),r=fs(t,"b","greaterEqual","string_or_numeric");[n,r]=ni(n,r),Bo(n.shape,r.shape);const a={a:n,b:r};return li.runKernel(vn,a)}}),oc=ys({isFinite_:function(e){const t={x:fs(e,"x","isFinite")};return li.runKernel("IsFinite",t)}}),uc=ys({isInf_:function(e){const t={x:fs(e,"x","isInf")};return li.runKernel("IsInf",t)}}),lc=ys({isNaN_:function(e){const t={x:fs(e,"x","isNaN")};return li.runKernel(_n,t)}}),cc=ys({leakyRelu_:function(e,t=.2){const n={x:fs(e,"x","leakyRelu")},r={alpha:t};return li.runKernel(xn,n,r)}}),hc=ys({less_:function(e,t){let n=fs(e,"a","less","string_or_numeric"),r=fs(t,"b","less","string_or_numeric");[n,r]=ni(n,r),Bo(n.shape,r.shape);const a={a:n,b:r};return li.runKernel(kn,a)}}),pc=ys({lessEqual_:function(e,t){let n=fs(e,"a","lessEqual","string_or_numeric"),r=fs(t,"b","lessEqual","string_or_numeric");[n,r]=ni(n,r),Bo(n.shape,r.shape);const a={a:n,b:r};return li.runKernel(Tn,a)}}),dc=ys({localResponseNormalization_:function(e,t=5,n=1,r=1,a=.5){const i=fs(e,"x","localResponseNormalization");nt(4===i.rank||3===i.rank,(()=>`Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${i.rank}.`)),nt(ot(t),(()=>`Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`));let s=i,o=!1;3===i.rank&&(o=!0,s=Bu(i,[1,i.shape[0],i.shape[1],i.shape[2]]));const u={x:s},l={depthRadius:t,bias:n,alpha:r,beta:a},c=li.runKernel("LRN",u,l);return o?Bu(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),fc=ys({log_:function(e){const t={x:fs(e,"x","log","float32")};return li.runKernel("Log",t)}}),mc=ys({log1p_:function(e){const t={x:fs(e,"x","log1p")};return li.runKernel("Log1p",t)}});function gc(e){return li.customGrad(e)}const yc=ys({softplus_:function(e){const t={x:fs(e,"x","softplus")};return li.runKernel("Softplus",t)}}),bc=ys({logSigmoid_:function(e){const t=fs(e,"x","logSigmoid"),n=gc((e=>({value:Mo(yc(Mo(e))),gradFunc:t=>pu(t,ju(Mo(e)))})));return n(t)}}),vc=ys({sub_:function(e,t){let n=fs(e,"a","sub"),r=fs(t,"b","sub");[n,r]=ni(n,r);const a={a:n,b:r};return li.runKernel(wr,a)}}),wc=ys({logSoftmax_:function(e,t=-1){const n=fs(e,"logits","logSoftmax");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${t}`);const r=gc(((e,n)=>{const r=Vl(e,t,!0),a=vc(e,r),i=vc(ko(a,"float32"),fc(ql(Jl(a),t,!0)));return n([i]),{value:i,gradFunc:(e,n)=>{const[r]=n,a=Jl(r);return vc(e,pu(ql(e,t,!0),a))}}}));return r(n)}}),_c=ys({logSumExp_:function(e,t=null,n=!1){const r=fs(e,"x","logSumExp"),a=pt(t,r.shape),i=Vl(r,a,!0),s=vc(r,i),o=Jl(s),u=ql(o,a),l=fc(u),c=lu(Bu(i,l.shape),l);if(n){const e=Pl(c.shape,a);return Bu(c,e)}return c}}),xc=ys({logicalAnd_:function(e,t){const n=fs(e,"a","logicalAnd","bool"),r=fs(t,"b","logicalAnd","bool");Bo(n.shape,r.shape);const a={a:n,b:r};return li.runKernel(En,a)}}),kc=ys({logicalNot_:function(e){const t={x:fs(e,"x","logicalNot","bool")};return li.runKernel(Sn,t)}}),Tc=ys({logicalOr_:function(e,t){const n=fs(e,"a","logicalOr","bool"),r=fs(t,"b","logicalOr","bool");Bo(n.shape,r.shape);const a={a:n,b:r};return li.runKernel(In,a)}}),Ec=ys({logicalXor_:function(e,t){const n=fs(e,"a","logicalXor","bool"),r=fs(t,"b","logicalXor","bool");return Bo(n.shape,r.shape),xc(Tc(e,t),kc(xc(e,t)))}}),Sc=2147483648,Ic=ys({searchSorted_:function(e,t,n="left"){const r=fs(e,"sortedSequence","searchSorted"),a=fs(t,"values","searchSorted"),i=r.shape[r.shape.length-1],s=a.shape[a.shape.length-1],o=Bu(r,[-1,i]),u=Bu(a,[-1,s]);if(o.rank<2)throw new Error("Sorted input argument must be at least 2-dimensional");if(o.shape[0]!==u.shape[0])throw new Error("Leading dimension of 'sortedSequence' and 'values' must match.");if(it(u.shape)>=Sc)throw new Error("values tensor size must less than 2147483648");if(o.shape[1]>=Sc)throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${o.shape[1]}`);const l={sortedSequence:o,values:u},c={side:n};return li.runKernel("SearchSorted",l,c)}}),Ac=ys({maxPool_:function(e,t,n,r,a){const i=fs(e,"x","maxPool");let s=i,o=!1;3===i.rank&&(o=!0,s=Bu(i,[1,i.shape[0],i.shape[1],i.shape[2]])),nt(4===s.rank,(()=>`Error in maxPool: input must be rank 4 but got rank ${s.rank}.`)),nt($u(n,1),(()=>`Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)),Lu("maxPool",r,a);const u={x:s},l={filterSize:t,strides:n,pad:r,dimRoundingMode:a},c=li.runKernel(Nn,u,l);return o?Bu(c,[c.shape[1],c.shape[2],c.shape[3]]):c}}),Cc=ys({maxPool3d_:function(e,t=[1,1,1],n,r,a,i="NDHWC"){const s=fs(e,"x","maxPool3d");let o=s,u=!1;4===s.rank&&(u=!0,o=Bu(s,[1,s.shape[0],s.shape[1],s.shape[2],s.shape[3]])),nt(5===o.rank,(()=>`Error in maxPool3d: x must be rank 5 but got rank ${o.rank}.`)),nt("NDHWC"===i,(()=>`Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${i}`)),Lu("maxPool3d",r,a);const l={x:o},c={filterSize:t,strides:n,pad:r,dimRoundingMode:a,dataFormat:i},h=li.runKernel("MaxPool3D",l,c);return u?Bu(h,[h.shape[1],h.shape[2],h.shape[3],h.shape[4]]):h}}),Nc=ys({maxPoolWithArgmax_:function(e,t,n,r,a=!1){const i={x:fs(e,"x","maxPoolWithArgmax")},s={filterSize:t,strides:n,pad:r,includeBatchInIndex:a},o=li.runKernel("MaxPoolWithArgmax",i,s);return{result:o[0],indexes:o[1]}}}),Rc=ys({maximum_:function(e,t){let n=fs(e,"a","maximum"),r=fs(t,"b","maximum");[n,r]=ni(n,r),"bool"===n.dtype&&(n=ko(n,"int32"),r=ko(r,"int32")),Bo(n.shape,r.shape);const a={a:n,b:r};return li.runKernel(Cn,a)}}),Fc=ys({mean_:function(e,t=null,n=!1){const r={x:fs(e,"x","mean")},a={axis:t,keepDims:n};return li.runKernel(Rn,r,a)}});function Oc(e,t="float32"){if(It(e),"complex64"===t){const t=Oc(e,"float32"),n=Oc(e,"float32");return bs(t,n)}const n=St(it(e),t);return li.makeTensor(n,e,t)}function Mc(e,t="float32"){if(It(e),"complex64"===t){const t=Mc(e,"float32"),n=Oc(e,"float32");return bs(t,n)}const n=Et(it(e),t);return li.makeTensor(n,e,t)}const $c=ys({minimum_:function(e,t){let n=fs(e,"a","minimum"),r=fs(t,"b","minimum");[n,r]=ni(n,r),"bool"===n.dtype&&(n=ko(n,"int32"),r=ko(r,"int32")),Bo(n.shape,r.shape);const a={a:n,b:r};return li.runKernel(On,a)}}),Dc=ys({mirrorPad_:function(e,t,n){nt("reflect"===n||"symmetric"===n,(()=>`Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`));const r=fs(e,"x","mirrorPad");if(0===r.rank)throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");nt(t.length===r.rank,(()=>`Padding doesn't match input. Must be ${r.rank}. Got ${t.length}.`));const a="reflect"===n?1:0;for(let e=0;e<r.rank;e++)nt(2===t[e].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),nt(t[e][0]>=0&&t[e][0]<=r.shape[e]-a&&t[e][1]>=0&&t[e][1]<=r.shape[e]-a,(()=>`Padding in dimension ${e} cannot be greater than or equal to ${r.shape[e]-a} or less than 0 for input of shape ${r.shape}`));const i={paddings:t,mode:n},s={x:r};return li.runKernel(Mn,s,i)}}),Pc=ys({mod_:function(e,t){let n=fs(e,"a","mod"),r=fs(t,"b","mod");[n,r]=ni(n,r);const a={a:n,b:r};return li.runKernel("Mod",a)}}),Lc=ys({moments_:function(e,t=null,n=!1){const r=pt(t,(e=fs(e,"x","moments")).shape),a=Fc(e,r,n);let i=a.shape;n||(i=Pl(a.shape,r));const s=Kl(vc(ko(e,"float32"),Bu(a,i)));return{mean:a,variance:Fc(s,r,n)}}}),Bc=ys({multiRNNCell_:function(e,t,n,r){const a=fs(t,"data","multiRNNCell"),i=ms(n,"c","multiRNNCell"),s=ms(r,"h","multiRNNCell");let o=a;const u=[];for(let t=0;t<e.length;t++){const n=e[t](o,i[t],s[t]);u.push(n[0]),u.push(n[1]),o=n[1]}const l=[],c=[];for(let e=0;e<u.length;e+=2)l.push(u[e]),c.push(u[e+1]);return[l,c]}}),Uc=ys({multinomial_:function(e,t,n,r=!1){const a=fs(e,"logits","multinomial"),i=a.size,s=a.rank;if(i<2)throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${i}.`);if(s>2)throw new Error(`Rank of probabilities must be 1 or 2, but is ${s}`);n=n||Math.random();const o={logits:1===s?Bu(a,[1,-1]):a},u={numSamples:t,seed:n,normalized:r},l=li.runKernel("Multinomial",o,u);return 1===s?Bu(l,[l.size]):l}}),Wc=ys({notEqual_:function(e,t){let n=fs(e,"a","notEqual","string_or_numeric"),r=fs(t,"b","notEqual","string_or_numeric");[n,r]=ni(n,r),Bo(n.shape,r.shape);const a={a:n,b:r};return li.runKernel(Dn,a)}}),Vc=ys({onesLike_:function(e){const t={x:fs(e,"x","onesLike")};return li.runKernel(Un,t)}}),zc=ys({outerProduct_:function(e,t){const n=fs(e,"v1","outerProduct"),r=fs(t,"v2","outerProduct");nt(1===n.rank&&1===r.rank,(()=>`Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`));const a=Bu(n,[-1,1]),i=Bu(r,[1,-1]);return To(a,i)}}),jc=ys({pad_:function(e,t,n=0){const r=fs(e,"x","pad");if(0===r.rank)throw new Error("pad(scalar) is not defined. Pass non-scalar to pad");const a={paddings:t,constantValue:n},i={x:r};return li.runKernel(zn,i,a)}}),Gc=ys({pad1d_:function(e,t,n=0){return nt(2===t.length,(()=>"Invalid number of paddings. Must be length of 2.")),jc(e,[t],n)}}),Hc=ys({pad2d_:function(e,t,n=0){return nt(2===t.length&&2===t[0].length&&2===t[1].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),jc(e,t,n)}}),Kc=ys({pad3d_:function(e,t,n=0){return nt(3===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),jc(e,t,n)}}),qc=ys({pad4d_:function(e,t,n=0){return nt(4===t.length&&2===t[0].length&&2===t[1].length&&2===t[2].length&&2===t[3].length,(()=>"Invalid number of paddings. Must be length of 2 each.")),jc(e,t,n)}}),Xc=ys({spaceToBatchND_:function(e,t,n){const r=fs(e,"x","spaceToBatchND");nt(r.rank>=1+t.length,(()=>`input rank ${r.rank} should be > than [blockShape] ${t.length}`)),nt(n.length===t.length,(()=>`paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`)),nt(r.shape.reduce(((e,r,a)=>a>0&&a<=t.length?e&&(r+n[a-1][0]+n[a-1][1])%t[a-1]==0:e),!0),(()=>`input spatial dimensions ${r.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`));const a={x:r},i={blockShape:t,paddings:n};return li.runKernel(ur,a,i)}}),Yc=ys({pool_:function(e,t,n,r,a,i,s){null==a&&(a=[1,1]),null==i&&(i=1),0===r&&(r="valid");const o=fs(e,"x","maxPool");let u=o,l=!1;3===o.rank&&(l=!0,u=Bu(o,[1,o.shape[0],o.shape[1],o.shape[2]])),nt($u(i,a),(()=>`Error in pool: Either strides or dilations must be 1. Got strides ${i} and dilations '${a}'`));const c=Su(u.shape,t,i,a,r),h=[c.dilationHeight,c.dilationWidth];let p;p="same"===r?function(e,t){const n=e.map(((e,n)=>e+(e-1)*(t[n]-1))).map((e=>e-1)),r=n.map((e=>Math.floor(e/2))),a=n.map(((e,t)=>e-r[t]));return n.map(((e,t)=>[r[t],a[t]]))}([c.filterHeight,c.filterWidth],h):[[0,0],[0,0]];const d=1===h[0]&&1===h[1],[f,m]=function(e,t,n){const r=n.map((e=>e[0])),a=n.map((e=>e[1])),i=e.concat(r,a),s=t.map(((e,t)=>(e-i[t]%e)%e)),o=a.map(((e,t)=>e+s[t]));return[t.map(((e,t)=>[r[t],o[t]])),t.map(((e,t)=>[0,s[t]]))]}([c.inHeight,c.inWidth],h,p),g=d?r:"valid",y=d?u:Xc(u,h,f),b=("avg"===n?()=>Uu(y,t,i,g,s):()=>Ac(y,t,i,g,s))(),v=d?b:qu(b,h,m);return l?Bu(v,[v.shape[1],v.shape[2],v.shape[3]]):v}}),Qc=ys({prelu_:function(e,t){const n={x:fs(e,"x","prelu"),alpha:fs(t,"alpha","prelu")};return li.runKernel(jn,n)}});function Jc(e,t=!1){console.log(e.toString(t))}const Zc=ys({prod_:function(e,t=null,n=!1){let r=fs(e,"x","prod");"bool"===r.dtype&&(r=ko(r,"int32"));const a={x:r},i={axis:t,keepDims:n};return li.runKernel(Gn,a,i)}}),eh=ys({raggedGather_:function(e,t,n,r){const a=e.map(((e,t)=>fs(e,`tensors${t}`,"raggedGather","int32"))),i={paramsNestedSplits:a,paramsDenseValues:fs(t,"paramsDenseValues","raggedGather"),indices:fs(n,"indices","raggedGather","int32")},s={outputRaggedRank:r},o=li.runKernel("RaggedGather",i,s);return{outputNestedSplits:o.slice(0,o.length-1),outputDenseValues:o[o.length-1]}}}),th=ys({raggedRange_:function(e,t,n){const r=fs(e,"starts","raggedRange"),a={starts:r,limits:fs(t,"limits","raggedRange",r.dtype),deltas:fs(n,"deltas","raggedRange",r.dtype)},i=li.runKernel("RaggedRange",a);return{rtNestedSplits:i[0],rtDenseValues:i[1]}}}),nh=ys({raggedTensorToTensor_:function(e,t,n,r,a){const i=fs(e,"shape","raggedTensorToTensor","int32"),s=fs(t,"values","raggedTensorToTensor"),o=fs(n,"defaultValue","raggedTensorToTensor",s.dtype),u=r.map(((e,t)=>fs(e,`tensors${t}`,"raggedTensorToTensor","int32"))),l={shape:i,values:s,defaultValue:o,rowPartitionTensors:u},c={rowPartitionTypes:a};return li.runKernel("RaggedTensorToTensor",l,c)}}),rh=ys({rand_:function(e,t,n){It(e);const r=it(e);let a=null;if(null==n||"float32"===n)a=new Float32Array(r);else if("int32"===n)a=new Int32Array(r);else{if("bool"!==n)throw new Error(`Unknown data type ${n}`);a=new Uint8Array(r)}for(let e=0;e<r;e++)a[e]=t();return li.makeTensor(a,e,n)}});var ah="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{};function ih(e){var t={exports:{}};return e(t,t.exports),t.exports}var sh=ih((function(e){!function(e,t,n){function r(e){var t=this,n=function(){var e=4022871197;return function(t){t=String(t);for(var n=0;n<t.length;n++){var r=.02519603282416938*(e+=t.charCodeAt(n));r-=e=r>>>0,e=(r*=e)>>>0,e+=4294967296*(r-=e)}return 2.3283064365386963e-10*(e>>>0)}}();t.next=function(){var e=2091639*t.s0+2.3283064365386963e-10*t.c;return t.s0=t.s1,t.s1=t.s2,t.s2=e-(t.c=0|e)},t.c=1,t.s0=n(" "),t.s1=n(" "),t.s2=n(" "),t.s0-=n(e),t.s0<0&&(t.s0+=1),t.s1-=n(e),t.s1<0&&(t.s1+=1),t.s2-=n(e),t.s2<0&&(t.s2+=1),n=null}function a(e,t){return t.c=e.c,t.s0=e.s0,t.s1=e.s1,t.s2=e.s2,t}function i(e,t){var n=new r(e),i=t&&t.state,s=n.next;return s.int32=function(){return 4294967296*n.next()|0},s.double=function(){return s()+11102230246251565e-32*(2097152*s()|0)},s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=i:this.alea=i}(0,e)})),oh=ih((function(e){!function(e,t,n){function r(e){var t=this,n="";t.x=0,t.y=0,t.z=0,t.w=0,t.next=function(){var e=t.x^t.x<<11;return t.x=t.y,t.y=t.z,t.z=t.w,t.w^=t.w>>>19^e^e>>>8},e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t}function i(e,t){var n=new r(e),i=t&&t.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},s.int32=n.next,s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=i:this.xor128=i}(0,e)})),uh=ih((function(e){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.x^t.x>>>2;return t.x=t.y,t.y=t.z,t.z=t.w,t.w=t.v,(t.d=t.d+362437|0)+(t.v=t.v^t.v<<4^e^e<<1)|0},t.x=0,t.y=0,t.z=0,t.w=0,t.v=0,e===(0|e)?t.x=e:n+=e;for(var r=0;r<n.length+64;r++)t.x^=0|n.charCodeAt(r),r==n.length&&(t.d=t.x<<10^t.x>>>4),t.next()}function a(e,t){return t.x=e.x,t.y=e.y,t.z=e.z,t.w=e.w,t.v=e.v,t.d=e.d,t}function i(e,t){var n=new r(e),i=t&&t.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},s.int32=n.next,s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=i:this.xorwow=i}(0,e)})),lh=ih((function(e){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.x,a=t.i;return e=r[a],n=(e^=e>>>7)^e<<24,n^=(e=r[a+1&7])^e>>>10,n^=(e=r[a+3&7])^e>>>3,n^=(e=r[a+4&7])^e<<7,e=r[a+7&7],n^=(e^=e<<13)^e<<9,r[a]=n,t.i=a+1&7,n},function(e,t){var n,r=[];if(t===(0|t))r[0]=t;else for(t=""+t,n=0;n<t.length;++n)r[7&n]=r[7&n]<<15^t.charCodeAt(n)+r[n+1&7]<<13;for(;r.length<8;)r.push(0);for(n=0;n<8&&0===r[n];++n);for(8==n?r[7]=-1:r[n],e.x=r,e.i=0,n=256;n>0;--n)e.next()}(t,e)}function a(e,t){return t.x=e.x.slice(),t.i=e.i,t}function i(e,t){null==e&&(e=+new Date);var n=new r(e),i=t&&t.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},s.int32=n.next,s.quick=s,i&&(i.x&&a(i,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=i:this.xorshift7=i}(0,e)})),ch=ih((function(e){!function(e,t,n){function r(e){var t=this;t.next=function(){var e,n,r=t.w,a=t.X,i=t.i;return t.w=r=r+1640531527|0,n=a[i+34&127],e=a[i=i+1&127],n^=n<<13,e^=e<<17,n^=n>>>15,e^=e>>>12,n=a[i]=n^e,t.i=i,n+(r^r>>>16)|0},function(e,t){var n,r,a,i,s,o=[],u=128;for(t===(0|t)?(r=t,t=null):(t+="\0",r=0,u=Math.max(u,t.length)),a=0,i=-32;i<u;++i)t&&(r^=t.charCodeAt((i+32)%t.length)),0===i&&(s=r),r^=r<<10,r^=r>>>15,r^=r<<4,r^=r>>>13,i>=0&&(s=s+1640531527|0,a=0==(n=o[127&i]^=r+s)?a+1:0);for(a>=128&&(o[127&(t&&t.length||0)]=-1),a=127,i=512;i>0;--i)r=o[a+34&127],n=o[a=a+1&127],r^=r<<13,n^=n<<17,r^=r>>>15,n^=n>>>12,o[a]=r^n;e.w=s,e.X=o,e.i=a}(t,e)}function a(e,t){return t.i=e.i,t.w=e.w,t.X=e.X.slice(),t}function i(e,t){null==e&&(e=+new Date);var n=new r(e),i=t&&t.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},s.int32=n.next,s.quick=s,i&&(i.X&&a(i,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=i:this.xor4096=i}(0,e)})),hh=ih((function(e){!function(e,t,n){function r(e){var t=this,n="";t.next=function(){var e=t.b,n=t.c,r=t.d,a=t.a;return e=e<<25^e>>>7^n,n=n-r|0,r=r<<24^r>>>8^a,a=a-e|0,t.b=e=e<<20^e>>>12^n,t.c=n=n-r|0,t.d=r<<16^n>>>16^a,t.a=a-e|0},t.a=0,t.b=0,t.c=-1640531527,t.d=1367130551,e===Math.floor(e)?(t.a=e/4294967296|0,t.b=0|e):n+=e;for(var r=0;r<n.length+20;r++)t.b^=0|n.charCodeAt(r),t.next()}function a(e,t){return t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t}function i(e,t){var n=new r(e),i=t&&t.state,s=function(){return(n.next()>>>0)/4294967296};return s.double=function(){do{var e=((n.next()>>>11)+(n.next()>>>0)/4294967296)/(1<<21)}while(0===e);return e},s.int32=n.next,s.quick=s,i&&("object"==typeof i&&a(i,n),s.state=function(){return a(n,{})}),s}t&&t.exports?t.exports=i:this.tychei=i}(0,e)})),ph=function(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})})),t}(Object.freeze({__proto__:null,default:{}})),dh=ih((function(e){!function(t,n,r){var a,i=256,s="random",o=r.pow(i,6),u=r.pow(2,52),l=2*u,c=i-1;function h(e,c,h){var y=[],b=m(f((c=1==c?{entropy:!0}:c||{}).entropy?[e,g(n)]:null==e?function(){try{var e;return a&&(e=a.randomBytes)?e=e(i):(e=new Uint8Array(i),(t.crypto||t.msCrypto).getRandomValues(e)),g(e)}catch(e){var r=t.navigator,s=r&&r.plugins;return[+new Date,t,s,t.screen,g(n)]}}():e,3),y),v=new p(y),w=function(){for(var e=v.g(6),t=o,n=0;e<u;)e=(e+n)*i,t*=i,n=v.g(1);for(;e>=l;)e/=2,t/=2,n>>>=1;return(e+n)/t};return w.int32=function(){return 0|v.g(4)},w.quick=function(){return v.g(4)/4294967296},w.double=w,m(g(v.S),n),(c.pass||h||function(e,t,n,a){return a&&(a.S&&d(a,v),e.state=function(){return d(v,{})}),n?(r[s]=e,t):e})(w,b,"global"in c?c.global:this==r,c.state)}function p(e){var t,n=e.length,r=this,a=0,s=r.i=r.j=0,o=r.S=[];for(n||(e=[n++]);a<i;)o[a]=a++;for(a=0;a<i;a++)o[a]=o[s=c&s+e[a%n]+(t=o[a])],o[s]=t;(r.g=function(e){for(var t,n=0,a=r.i,s=r.j,o=r.S;e--;)t=o[a=c&a+1],n=n*i+o[c&(o[a]=o[s=c&s+t])+(o[s]=t)];return r.i=a,r.j=s,n})(i)}function d(e,t){return t.i=e.i,t.j=e.j,t.S=e.S.slice(),t}function f(e,t){var n,r=[],a=typeof e;if(t&&"object"==a)for(n in e)try{r.push(f(e[n],t-1))}catch(e){}return r.length?r:"string"==a?e:e+"\0"}function m(e,t){for(var n,r=e+"",a=0;a<r.length;)t[c&a]=c&(n^=19*t[c&a])+r.charCodeAt(a++);return g(t)}function g(e){return String.fromCharCode.apply(0,e)}if(m(r.random(),n),e.exports){e.exports=h;try{a=ph}catch(e){}}else r["seed"+s]=h}("undefined"!=typeof self?self:ah,[],Math)}));dh.alea=sh,dh.xor128=oh,dh.xorwow=uh,dh.xorshift7=lh,dh.xor4096=ch,dh.tychei=hh;var fh=dh;class mh{constructor(e,t,n,r,a){this.mean=e,this.stdDev=t,this.dtype=n,this.nextVal=NaN,this.truncated=r,this.truncated&&(this.upper=this.mean+2*this.stdDev,this.lower=this.mean-2*this.stdDev);const i=a||Math.random();this.random=fh.alea(i.toString())}nextValue(){if(!isNaN(this.nextVal)){const e=this.nextVal;return this.nextVal=NaN,e}let e,t,n=!1;for(;!n;){let r,a,i;do{r=2*this.random()-1,a=2*this.random()-1,i=r*r+a*a}while(i>=1||0===i);const s=Math.sqrt(-2*Math.log(i)/i);e=this.mean+this.stdDev*r*s,t=this.mean+this.stdDev*a*s,this.truncated&&!this.isValidTruncated(e)||(n=!0)}return this.truncated&&!this.isValidTruncated(t)||(this.nextVal=this.convertValue(t)),this.convertValue(e)}convertValue(e){return null==this.dtype||"float32"===this.dtype?e:Math.round(e)}isValidTruncated(e){return e<=this.upper&&e>=this.lower}}class gh{constructor(e,t,n,r){this.alpha=e,this.beta=1/t,this.dtype=n;const a=r||Math.random();this.randu=fh.alea(a.toString()),this.randn=new mh(0,1,n,!1,this.randu()),this.d=e<1?e+2/3:e-1/3,this.c=1/Math.sqrt(9*this.d)}nextValue(){let e,t,n,r,a,i;for(;;){do{r=this.randn.nextValue(),i=1+this.c*r}while(i<=0);if(i*=i*i,e=r*r,t=1-.331*e*e,n=.5*e+this.d*(1-i+Math.log(i)),a=this.randu(),a<t||Math.log(a)<n)break}return i=1/this.beta*this.d*i,this.alpha<1&&(i*=Math.pow(this.randu(),1/this.alpha)),this.convertValue(i)}convertValue(e){return"float32"===this.dtype?e:Math.round(e)}}class yh{constructor(e=0,t=1,n,r){if(this.canReturnFloat=()=>null==this.dtype||"float32"===this.dtype,this.min=e,this.range=t-e,this.dtype=n,null==r&&(r=Math.random()),"number"==typeof r&&(r=r.toString()),!this.canReturnFloat()&&this.range<=1)throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);this.random=fh.alea(r)}convertValue(e){return this.canReturnFloat()?e:Math.round(e)}nextValue(){return this.convertValue(this.min+this.range*this.random())}}const bh=ys({randomGamma_:function(e,t,n=1,r="float32",a){if(It(e),null==n&&(n=1),null==r&&(r="float32"),"float32"!==r&&"int32"!==r)throw new Error(`Unsupported data type ${r}`);const i=new gh(t,n,r,a),s=nl(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=i.nextValue();return s.toTensor()}}),vh=ys({randomNormal_:function(e,t=0,n=1,r,a){if(It(e),null!=r&&"bool"===r)throw new Error(`Unsupported data type ${r}`);const i=new mh(t,n,r,!1,a),s=nl(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=i.nextValue();return s.toTensor()}}),wh=ys({randomStandardNormal_:function(e,t,n){if(null!=t&&"bool"===t)throw new Error(`Unsupported data type ${t}`);return vh(e,0,1,t,n)}}),_h=ys({randomUniform_:function(e,t=0,n=1,r="float32",a){It(e);const i=nl(e,r),s=new yh(t,n,null,a);for(let e=0;e<i.values.length;e++)i.values[e]=s.nextValue();return i.toTensor()}});function xh(e,t,n=1,r="float32"){if(0===n)throw new Error("Cannot have a step of zero");const a={start:e,stop:t,step:n,dtype:r};return li.runKernel(Hn,{},a)}const kh=ys({reciprocal_:function(e){const t={x:fs(e,"x","reciprocal")};return li.runKernel(Kn,t)}}),Th=ys({relu_:function(e){const t={x:fs(e,"x","relu")};return li.runKernel(qn,t)}}),Eh=ys({relu6_:function(e){const t={x:fs(e,"x","relu6")};return li.runKernel(Jn,t)}}),Sh=ys({reverse_:function(e,t){const n={x:fs(e,"x","reverse")},r={dims:t};return li.runKernel(Zn,n,r)}}),Ih=ys({reverse1d_:function(e){const t=fs(e,"x","reverse");return nt(1===t.rank,(()=>`Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`)),Sh(t,0)}}),Ah=ys({reverse2d_:function(e,t){const n=fs(e,"x","reverse");return nt(2===n.rank,(()=>`Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)),Sh(n,t)}}),Ch=ys({reverse3d_:function(e,t){const n=fs(e,"x","reverse");return nt(3===n.rank,(()=>`Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)),Sh(n,t)}}),Nh=ys({reverse4d_:function(e,t){const n=fs(e,"x","reverse");return nt(4===n.rank,(()=>`Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)),Sh(n,t)}}),Rh=ys({round_:function(e){const t={x:fs(e,"x","round")};return li.runKernel(er,t)}}),Fh=ys({rsqrt_:function(e){const t={x:fs(e,"x","rsqrt","float32")};return li.runKernel(tr,t)}}),Oh=ys({selu_:function(e){const t={x:fs(e,"x","selu")};return li.runKernel("Selu",t)}}),Mh=ys({separableConv2d_:function(e,t,n,r,a,i=[1,1],s="NHWC"){const o=fs(e,"x","separableConv2d"),u=fs(t,"depthwiseFilter","separableConv2d"),l=fs(n,"pointwiseFilter","separableConv2d");let c=o,h=!1;if(3===o.rank&&(h=!0,c=Bu(o,[1,o.shape[0],o.shape[1],o.shape[2]])),"NCHW"===s)throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported");nt(4===c.rank,(()=>`Error in separableConv2d: input must be rank 4, but got rank ${c.rank}.`)),nt(4===u.rank,(()=>`Error in separableConv2d: depthwise filter must be rank 4, but got rank ${u.rank}.`)),nt(4===l.rank,(()=>`Error in separableConv2d: pointwise filter must be rank 4, but got rank ${u.rank}.`)),nt(1===l.shape[0],(()=>`Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${l.shape[0]}.`)),nt(1===l.shape[1],(()=>`Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${l.shape[1]}.`));const p=u.shape[2],d=u.shape[3];nt(l.shape[2]===p*d,(()=>`Error in separableConv2d: the third dimension of pointwise filter must be ${p*d}, but got ${l.shape[2]}.`));const f=kl(c,u,r,a,s,i),m=cl(f,l,1,"valid",s);return h?Bu(m,[m.shape[1],m.shape[2],m.shape[3]]):m}}),$h=ys({sign_:function(e){const t={x:fs(e,"x","sign")};return li.runKernel("Sign",t)}}),Dh=ys({sin_:function(e){const t={x:fs(e,"x","sin","float32")};return li.runKernel("Sin",t)}}),Ph=ys({sinh_:function(e){const t={x:fs(e,"x","sinh")};return li.runKernel("Sinh",t)}}),Lh=ys({slice1d_:function(e,t,n){const r=fs(e,"x","slice1d");return nt(1===r.rank,(()=>`slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`)),Gu(r,[t],[n])}}),Bh=ys({slice2d_:function(e,t,n){const r=fs(e,"x","slice2d");return nt(2===r.rank,(()=>`slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`)),Gu(r,t,n)}}),Uh=ys({slice3d_:function(e,t,n){const r=fs(e,"x","slice3d");return nt(3===r.rank,(()=>`slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`)),Gu(r,t,n)}}),Wh=ys({slice4d_:function(e,t,n){const r=fs(e,"x","slice4d");return nt(4===r.rank,(()=>`slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`)),Gu(r,t,n)}}),Vh=ys({softmax_:function(e,t=-1){const n=fs(e,"logits","softmax","float32");if(-1===t&&(t=n.rank-1),t!==n.rank-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${t}`);const r={logits:n},a={dim:t};return li.runKernel(cr,r,a)}}),zh=ys({fft_:function(e){nt("complex64"===e.dtype,(()=>`The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`));const t={input:e};return li.runKernel("FFT",t)}}),jh=ys({ifft_:function(e){nt("complex64"===e.dtype,(()=>`The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`));const t={input:e};return li.runKernel("IFFT",t)}}),Gh=ys({irfft_:function(e){const t=e.shape[e.shape.length-1],n=e.size/t;let r;if(t<=2){const a=Bu(e,[n,t]);r=jh(a)}else{const a=[n,2*(t-1)],i=Bu($o(e),[n,t]),s=Bu(Oo(e),[n,t]),o=Sh(Gu(i,[0,1],[n,t-2]),1),u=pu(Sh(Gu(s,[0,1],[n,t-2]),1),Gl(-1)),l=zu([i,o],1),c=zu([s,u],1),h=Bu(bs(l,c),[a[0],a[1]]);r=jh(h)}if(r=$o(r),3===e.rank&&0!==e.shape[0]){const t=r,n=e.shape[0];r=Bu(r,[n,r.shape[0]/n,r.shape[1]]),t.dispose()}return r}}),Hh=ys({split_:function(e,t,n=0){const r={x:fs(e,"x","split")},a={numOrSizeSplits:t,axis:n};return li.runKernel(lr,r,a)}}),Kh=ys({rfft_:function(e,t){nt("float32"===e.dtype,(()=>`The dtype for rfft() must be real value but got ${e.dtype}`));let n=e.shape[e.shape.length-1];const r=e.size/n;let a;if(null!=t&&t<n){const r=e.shape.map((e=>0)),i=e.shape.map((e=>e));i[e.shape.length-1]=t,a=Gu(e,r,i),n=t}else if(null!=t&&t>n){const r=e.shape.map((e=>e));r[e.shape.length-1]=t-n,a=zu([e,Oc(r)],e.shape.length-1),n=t}else a=e;const i=Al(a),s=Bu(bs(a,i),[r,n]),o=zh(s),u=Math.floor(n/2)+1,l=$o(o),c=Oo(o),h=Hh(l,[u,n-u],l.shape.length-1),p=Hh(c,[u,n-u],c.shape.length-1),d=a.shape.slice();return d[a.shape.length-1]=u,Bu(bs(h[0],p[0]),d)}}),qh=ys({squaredDifference_:function(e,t){let n=fs(e,"a","squaredDifference"),r=fs(t,"b","squaredDifference");[n,r]=ni(n,r),Bo(n.shape,r.shape);const a={a:n,b:r};return li.runKernel(mr,a,{})}}),Xh=ys({squeeze_:function(e,t){const n=fs(e,"x","squeeze","string_or_numeric");return Bu(n,dt(n.shape,t).newShape)}}),Yh=ys({stack_:function(e,t=0){const n=ms(e,"tensors","stack","string_or_numeric");nt(n.length>=1,(()=>"Pass at least one tensor to tf.stack")),n.length>0&&nt(t<=n[0].rank,(()=>"Axis must be <= rank of the tensor"));const r=n,a={axis:t};return li.runKernel(Vn,r,a)}}),Qh=ys({step_:function(e,t=0){const n={x:fs(e,"x","step")},r={alpha:t};return li.runKernel(Ar,n,r)}}),Jh=ys({stridedSlice_:function(e,t,n,r,a=0,i=0,s=0,o=0,u=0){const l={x:fs(e,"x","stridedSlice","string_or_numeric")},c={begin:t,end:n,strides:r,beginMask:a,endMask:i,ellipsisMask:s,newAxisMask:o,shrinkAxisMask:u};return li.runKernel(gr,l,c)}}),Zh=ys({tan_:function(e){const t={x:fs(e,"x","tan","float32")};return li.runKernel("Tan",t)}});function ep(e,t){at(e);const n=hs(e,t);if(1!==n.length)throw new Error("tensor1d() requires values to be a flat/TypedArray");return vs(e,null,n,t)}function tp(e,t,n){if(at(e),null!=t&&2!==t.length)throw new Error("tensor2d() requires shape to have two numbers");const r=hs(e,n);if(2!==r.length&&1!==r.length)throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");return vs(e,t,r,n)}const np=ys({topk_:function(e,t=1,n=!0){const r=fs(e,"x","topk");if(0===r.rank)throw new Error("topk() expects the input to be of rank 1 or higher");const a=r.shape[r.shape.length-1];if(t<0)throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`);if(t>a)throw new Error(`'k' passed to topk() must be <= the last dimension (${a}) but got ${t}`);const i={x:r},s={k:t,sorted:n},[o,u]=li.runKernel(kr,i,s);return{values:o,indices:u}}}),rp=ys({truncatedNormal_:function(e,t=0,n=1,r,a){if(It(e),null!=r&&"bool"===r)throw new Error("Unsupported data type $ { dtype }");const i=new mh(t,n,r,!0,a),s=nl(e,r);for(let e=0;e<s.values.length;e++)s.values[e]=i.nextValue();return s.toTensor()}}),ap=ys({unique_:function(e,t=0){const n=fs(e,"x","unique","string_or_numeric");nt(n.rank>0,(()=>"The input tensor must be at least 1D"));const r={x:n},a={axis:t},[i,s]=li.runKernel("Unique",r,a);return{values:i,indices:s}}}),ip=ys({unsortedSegmentSum_:function(e,t,n){const r=fs(e,"x","unsortedSegmentSum"),a=fs(t,"segmentIds","unsortedSegmentSum","int32");nt(ot(n),(()=>"numSegments must be of dtype int"));const i={x:r,segmentIds:a},s={numSegments:n};return li.runKernel("UnsortedSegmentSum",i,s)}}),sp=ys({unstack_:function(e,t=0){const n=fs(e,"x","unstack","string_or_numeric");nt(t>=-n.shape.length&&t<n.shape.length,(()=>`Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`));const r={value:n},a={axis:t};return li.runKernel(Sr,r,a)}});function op(e,t){const n=[];for(let e=0;e<t.length;e++)t[e]&&n.push(e);const r=nl(e,"int32"),a=nl([n.length,e.length],"int32");for(let t=0;t<n.length;t++){const i=r.indexToLoc(n[t]),s=t*e.length;a.values.set(i,s)}return a.toTensor()}const up=async function(e){const t=fs(e,"condition","whereAsync","bool"),n=await t.data(),r=op(t.shape,n);return e!==t&&t.dispose(),r},lp=ys({movingAverage_:function(e,t,n,r,a=!0){const i=fs(e,"v","movingAverage"),s=fs(t,"x","movingAverage"),o=fs(n,"decay","movingAverage");var u,l;l=s,nt((u=i).dtype===l.dtype,(()=>`The dtypes of the first(${u.dtype}) and second(${l.dtype}) input must match`)),nt(st(i.shape,s.shape),(()=>"Shape mismatch in v and x"));const c=Gl(1),h=vc(c,o);let p=pu(vc(s,i),h);if(a){nt(null!=r,(()=>"When using zeroDebias: true, step is required."));const e=fs(r,"step","movingAverage");p=hu(p,vc(c,jl(o,e)))}return lu(i,p)}}),cp=ys({scatterND_:function(e,t,n){It(n);const r=fs(e,"indices","scatterND","int32"),a=fs(t,"updates","scatterND");Go(a,r,n);const i={indices:r,updates:a},s={shape:n};return li.runKernel(nr,i,s)}}),hp=ys({sparseToDense_:function(e,t,n,r=0){It(n);const a=fs(e,"sparseIndices","sparseToDense","int32"),i=fs(t,"sparseValues","sparseToDense","string_or_numeric"),s=fs(r,"defaultValue","sparseToDense",i.dtype);!function(e,t,n,r){if("int32"!==e.dtype)throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${e.dtype}.`);if(e.rank>2)throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${e.shape}.`);const a=e.rank>0?e.shape[0]:1,i=e.rank>1?e.shape[1]:1;if(n.length!==i)throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${i}.`);const s=t.size;if(0!==t.rank&&(1!==t.rank||s!==a))throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${a}]`);if(t.dtype!==r.dtype)throw new Error("sparseValues.dtype must match defaultValues.dtype")}(a,i,n,s);const o={sparseIndices:a,sparseValues:i,defaultValue:s},u={outputShape:n};return li.runKernel("SparseToDense",o,u)}}),pp=ys({gatherND_:function(e,t){const n=fs(t,"indices","gatherND","int32"),r={params:fs(e,"x","gatherND","string_or_numeric"),indices:n};return li.runKernel(yn,r)}}),dp=ys({dropout_:function(e,t,n,r){const a=fs(e,"x","dropout");if(nt("float32"===a.dtype,(()=>`x has to be a floating point tensor since it's going to be scaled, but got a ${a.dtype} tensor instead.`)),nt(t>=0&&t<1,(()=>`rate must be a float in the range [0, 1), but got ${t}.`)),0===t)return e instanceof Ka?a.clone():a;const i=function(e,t){if(null==t)return e.shape.slice();if(st(e.shape,t))return t;if(e.shape.length===t.length){const n=[];for(let r=0;r<e.shape.length;r++)null==t[r]&&null!=e.shape[r]?n.push(e.shape[r]):n.push(t[r]);return n}return t}(a,n),s=1-t,o=hu(rc(lu(_h(i,0,1,"float32",r),s)),s);return pu(a,o)}});function fp(e){return Math.floor(Math.pow(2,Math.ceil(Math.log(e)/Math.log(2))))}function mp(e,t,n){const r=1-e%2,a=new Float32Array(e);for(let i=0;i<e;++i){const s=2*Math.PI*i/(e+r-1);a[i]=t-n*Math.cos(s)}return ep(a,"float32")}const gp=ys({conv2DBackpropFilter_:function(e,t,n,r,a,i="NHWC",s){let o=e;3===e.rank&&(o=Bu(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let u=t;3===u.rank&&(u=Bu(t,[1,t.shape[0],t.shape[1],t.shape[2]])),nt(4===o.rank,(()=>`Error in conv2dDerFilter: input must be rank 4, but got shape ${o.shape}.`)),nt(4===u.rank,(()=>`Error in conv2dDerFilter: dy must be rank 4, but got shape ${u.shape}.`)),nt(4===n.length,(()=>`Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`));const l="NHWC"===i?o.shape[3]:o.shape[1],c="NHWC"===i?u.shape[3]:u.shape[1];nt(l===n[2],(()=>`Error in conv2dDerFilter: depth of input ${l}) must match input depth in filter (${n[2]}.`)),nt(c===n[3],(()=>`Error in conv2dDerFilter: depth of dy (${c}) must match output depth for filter (${n[3]}).`)),Lu("conv2dDerFilter",a,s);const h={x:o,dy:u},p={strides:r,pad:a,dataFormat:i,dimRoundingMode:s,filterShape:n};return li.runKernel("Conv2DBackpropFilter",h,p)}});function yp(e,t,n){if(null==n||"linear"===n)return e;if("relu"===n)return pu(e,Qh(t));throw new Error(`Cannot compute gradient for fused activation ${n}.`)}function bp(e,t){let n=t;const r=Lo(e.shape,t.shape);return r.length>0&&(n=ql(n,r)),Bu(n,e.shape)}function vp(e,t,n,r){if("linear"===t)return e;if("relu"===t)return Th(e);if("elu"===t)return Fl(e);if("relu6"===t)return Eh(e);if("prelu"===t)return Qc(e,n);if("leakyrelu"===t)return cc(e,r);if("sigmoid"===t)return ju(e);throw new Error(`Unknown fused activation ${t}.`)}const wp=(e,t)=>!(e>0)||"linear"===t,_p=ys({fusedConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:i=[1,1],dimRoundingMode:s,bias:o,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(u=u||"linear",!1===wp(li.state.gradientDepth,u)){nt("NHWC"===a,(()=>`Error in fused conv2d: got dataFormat of ${a} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`));let h=cl(e,t,n,r,a,i,s);return null!=o&&(h=lu(h,o)),vp(h,u,l,c)}const h=fs(e,"x","conv2d","float32"),p=fs(t,"filter","conv2d","float32");let d=h,f=!1;3===h.rank&&(f=!0,d=Bu(h,[1,h.shape[0],h.shape[1],h.shape[2]])),nt(4===d.rank,(()=>`Error in fused conv2d: input must be rank 4, but got rank ${d.rank}.`)),nt(4===p.rank,(()=>`Error in fused conv2d: filter must be rank 4, but got rank ${p.rank}.`)),Lu("fused conv2d",r,s);const m="NHWC"===a?d.shape[3]:d.shape[1];nt(p.shape[2]===m,(()=>`Error in conv2d: depth of input (${m}) must match input depth for filter ${p.shape[2]}.`)),nt($u(n,i),(()=>`Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`));const g=Iu(d.shape,p.shape,n,i,r,s);let y,b;if(null!=o&&(y=fs(o,"bias","fused conv2d"),[y]=ni(y,h),"NHWC"===a?Bo(g.outShape,y.shape):(nt(y.shape.length<=1,(()=>`Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${y.shape.length}.`)),nt(0===y.shape.length||y.shape[0]===g.outChannels||1===y.shape[0],(()=>`Error in fused conv2d: bias shape (${y.shape}) is not compatible with the number of output channels (${g.outChannels})`)))),null!=l){const e=l.shape;if(nt(e.length<=1||3===e.length,(()=>`Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}.`)),1===e.length)nt(1===e[0]||e[0]===g.outChannels,(()=>`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${g.outChannels}).`));else if(3===e.length)try{Bo(e,g.outShape)}catch(t){const n=`Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${g.outShape}).`;throw Error(n)}b=fs(l,"prelu weights","fused conv2d")}const v=(e,t)=>{nt("NHWC"===a,(()=>`Error in gradient of fused conv2D: got dataFormat of ${a} but only NHWC is currently supported.`));const[s,o,l,c]=t,h=yp(e,l,u);nt(Mu(i),(()=>`Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${i}'`));const p=[pl(o.shape,h,s,n,r),gp(o,h,s.shape,n,r)];if(null!=c){const e=bp(c,h);p.push(e)}return p},w={x:d,filter:p,bias:y,preluActivationWeights:b},_={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==o){const e=gc(((e,t,n)=>{let r=li.runKernel(Fr,w,_);return n([t,e,r]),f&&(r=Bu(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:v}}));return e(d,p)}{const e=gc(((e,t,n,r)=>{let a=li.runKernel(Fr,w,_);return r([t,e,a,n]),f&&(a=Bu(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:v}}));return e(d,p,y)}}}),xp=ys({depthwiseConv2dNativeBackpropFilter_:function(e,t,n,r,a,i=[1,1],s){let o=e;3===e.rank&&(o=Bu(e,[1,e.shape[0],e.shape[1],e.shape[2]]));let u=t;3===u.rank&&(u=Bu(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={x:o,dy:u},c={strides:r,pad:a,dimRoundingMode:s,dilations:i,filterShape:n};return li.runKernel("DepthwiseConv2dNativeBackpropFilter",l,c)}}),kp=ys({depthwiseConv2dNativeBackpropInput_:function(e,t,n,r,a,i=[1,1],s){let o=t,u=!1;3===t.rank&&(u=!0,o=Bu(t,[1,t.shape[0],t.shape[1],t.shape[2]]));const l={dy:o,filter:n},c={strides:r,pad:a,dimRoundingMode:s,dilations:i,inputShape:e},h=li.runKernel("DepthwiseConv2dNativeBackpropInput",l,c);return u?Bu(h,[h.shape[1],h.shape[2],h.shape[3]]):h}}),Tp=ys({fusedDepthwiseConv2d_:function({x:e,filter:t,strides:n,pad:r,dataFormat:a="NHWC",dilations:i=[1,1],dimRoundingMode:s,bias:o,activation:u="linear",preluActivationWeights:l,leakyreluAlpha:c}){if(!1===wp(li.state.gradientDepth,u)){let h=kl(e,t,n,r,a,i,s);return null!=o&&(h=lu(h,o)),vp(h,u,l,c)}const h=fs(e,"x","depthwiseConv2d","float32"),p=fs(t,"filter","depthwiseConv2d","float32");let d=h,f=!1;3===h.rank&&(f=!0,d=Bu(h,[1,h.shape[0],h.shape[1],h.shape[2]])),nt(4===d.rank,(()=>`Error in fused depthwiseConv2d: input must be rank 4, but got rank ${d.rank}.`)),nt(4===p.rank,(()=>`Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${p.rank}.`)),nt(d.shape[3]===p.shape[2],(()=>`Error in fused depthwiseConv2d: number of input channels (${d.shape[3]}) must match the inChannels dimension in filter ${p.shape[2]}.`)),null==i&&(i=[1,1]),nt($u(n,i),(()=>`Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${i}'`)),Lu("fused depthwiseConv2d",r,s);const m=Iu(d.shape,p.shape,n,i,r,s,!0);let g,y;null!=o&&(g=fs(o,"bias","fused conv2d"),[g]=ni(g,h),Bo(m.outShape,g.shape)),null!=l&&(y=fs(l,"prelu weights","fused depthwiseConv2d"));const b=(e,t)=>{nt(Mu(i),(()=>`Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${i}'`));const[a,o,l,c]=t,h=yp(e,l,u),p=kp(o.shape,h,a,n,r,i,s),d=xp(o,h,a.shape,n,r,i,s);return null!=c?[p,d,bp(g,h)]:[p,d]},v={x:d,filter:p,bias:g,preluActivationWeights:y},w={strides:n,pad:r,dataFormat:a,dilations:i,dimRoundingMode:s,activation:u,leakyreluAlpha:c};if(null==o){const e=gc(((e,t,n)=>{let r=li.runKernel(Or,v,w);return n([t,e,r]),f&&(r=Bu(r,[r.shape[1],r.shape[2],r.shape[3]])),{value:r,gradFunc:b}}));return e(d,p)}{const e=gc(((e,t,n,r)=>{let a=li.runKernel(Or,v,w);return r([t,e,a,n]),f&&(a=Bu(a,[a.shape[1],a.shape[2],a.shape[3]])),{value:a,gradFunc:b}}));return e(d,p,g)}}}),Ep=ys({fusedMatMul_:function({a:e,b:t,transposeA:n=!1,transposeB:r=!1,bias:a,activation:i="linear",preluActivationWeights:s,leakyreluAlpha:o=.2}){if(!1===wp(li.state.gradientDepth,i)){let u=To(e,t,n,r);return null!=a&&(u=lu(u,a)),vp(u,i,s,o)}let u=fs(e,"a","fused matMul"),l=fs(t,"b","fused matMul");[u,l]=ni(u,l);const c=n?u.shape[u.rank-2]:u.shape[u.rank-1],h=r?l.shape[l.rank-1]:l.shape[l.rank-2],p=n?u.shape[u.rank-1]:u.shape[u.rank-2],d=r?l.shape[l.rank-2]:l.shape[l.rank-1],f=u.shape.slice(0,-2),m=l.shape.slice(0,-2),g=it(f),y=it(m);nt(c===h,(()=>`Error in fused matMul: inner shapes (${c}) and (${h}) of Tensors with shapes ${u.shape} and ${l.shape} and transposeA=${n} and transposeB=${r} must match.`));const b=Bo(u.shape.slice(0,-2),l.shape.slice(0,-2)).concat([p,d]),v=Bu(u,n?[g,c,p]:[g,p,c]),w=Bu(l,r?[y,d,h]:[y,h,d]);let _,x;null!=a&&(_=fs(a,"bias","fused matMul"),[_]=ni(_,u),Bo(b,_.shape)),null!=s&&(x=fs(s,"prelu weights","fused matMul"));const k=(e,t)=>{const[s,o,u,l]=t,c=yp(Bu(e,u.shape),u,i);let h,p;return n||r?!n&&r?(h=To(c,o,!1,!1),p=To(c,s,!0,!1)):n&&!r?(h=To(o,c,!1,!0),p=To(s,c,!1,!1)):(h=To(o,c,!0,!0),p=To(c,s,!0,!0)):(h=To(c,o,!1,!0),p=To(s,c,!0,!1)),null!=a?[h,p,bp(l,c)]:[h,p]},T={a:v,b:w,bias:_,preluActivationWeights:x},E={transposeA:n,transposeB:r,activation:i,leakyreluAlpha:o};if(null==a){const e=gc(((e,t,n)=>{const r=li.runKernel(Rr,T,E);return n([e,t,r]),{value:Bu(r,b),gradFunc:k}}));return e(v,w)}{const e=gc(((e,t,n,r)=>{const a=li.runKernel(Rr,T,E);return r([e,t,a,n]),{value:Bu(a,b),gradFunc:k}}));return e(v,w,_)}}});var Sp=Object.freeze({__proto__:null,conv2d:_p,depthwiseConv2d:Tp,matMul:Ep});const Ip=ys({hammingWindow_:function(e){return mp(e,.54,.46)}}),Ap=ys({hannWindow_:function(e){return mp(e,.5,.5)}}),Cp=ys({frame_:function(e,t,n,r=!1,a=0){let i=0;const s=[];for(;i+t<=e.size;)s.push(Gu(e,i,t)),i+=n;if(r)for(;i<e.size;){const r=i+t-e.size,o=zu([Gu(e,i,t-r),al([r],a)]);s.push(o),i+=n}return 0===s.length?tp([],[0,t]):Bu(zu(s),[s.length,t])}}),Np=ys({stft_:function(e,t,n,r,a=Ap){null==r&&(r=fp(t));const i=Cp(e,t,n),s=pu(i,a(t));return Kh(s,r)}}),Rp=ys({cropAndResize_:function(e,t,n,r,a="bilinear",i=0){const s=fs(e,"image","cropAndResize"),o=fs(t,"boxes","cropAndResize","float32"),u=fs(n,"boxInd","cropAndResize","int32"),l=o.shape[0];nt(4===s.rank,(()=>`Error in cropAndResize: image must be rank 4,but got rank ${s.rank}.`)),nt(2===o.rank&&4===o.shape[1],(()=>`Error in cropAndResize: boxes must be have size [${l},4] but had shape ${o.shape}.`)),nt(1===u.rank&&u.shape[0]===l,(()=>`Error in cropAndResize: boxInd must be have size [${l}] but had shape ${o.shape}.`)),nt(2===r.length,(()=>`Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`)),nt(r[0]>=1&&r[1]>=1,(()=>`cropSize must be atleast [1,1], but was ${r}`)),nt("bilinear"===a||"nearest"===a,(()=>`method must be bilinear or nearest, but was ${a}`));const c={image:s,boxes:o,boxInd:u},h={method:a,extrapolationValue:i,cropSize:r};return li.runKernel(nn,c,h)}}),Fp=ys({flipLeftRight_:function(e){const t=fs(e,"image","flipLeftRight","float32");nt(4===t.rank,(()=>`Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`));const n={image:t};return li.runKernel(pn,n,{})}}),Op=ys({grayscaleToRGB_:function(e){const t=fs(e,"image","grayscaleToRGB"),n=t.rank-1,r=t.shape[n];nt(t.rank>=2,(()=>`Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`)),nt(1===r,(()=>`Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`));const a=new Array(t.rank);return a.fill(1,0,n),a[n]=3,tc(t,a)}}),Mp=ys({rotateWithOffset_:function(e,t,n=0,r=.5){const a=fs(e,"image","rotateWithOffset","float32");nt(4===a.rank,(()=>`Error in rotateWithOffset: image must be rank 4,but got rank ${a.rank}.`));const i={image:a},s={radians:t,fillValue:n,center:r};return li.runKernel(Nr,i,s)}});function $p(e,t,n,r,a,i){null==r&&(r=.5),null==a&&(a=Number.NEGATIVE_INFINITY),null==i&&(i=0);const s=e.shape[0];return n=Math.min(n,s),nt(0<=r&&r<=1,(()=>`iouThreshold must be in [0, 1], but was '${r}'`)),nt(2===e.rank,(()=>`boxes must be a 2D tensor, but was of rank '${e.rank}'`)),nt(4===e.shape[1],(()=>`boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`)),nt(1===t.rank,(()=>"scores must be a 1D tensor")),nt(t.shape[0]===s,(()=>`scores has incompatible shape with boxes. Expected ${s}, but was ${t.shape[0]}`)),nt(0<=i&&i<=1,(()=>`softNmsSigma must be in [0, 1], but was '${i}'`)),{maxOutputSize:n,iouThreshold:r,scoreThreshold:a,softNmsSigma:i}}const Dp=ys({nonMaxSuppression_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const i=fs(e,"boxes","nonMaxSuppression","float32"),s=fs(t,"scores","nonMaxSuppression","float32"),o=$p(i,s,n,r,a),u={maxOutputSize:n=o.maxOutputSize,iouThreshold:r=o.iouThreshold,scoreThreshold:a=o.scoreThreshold};return li.runKernel(Pn,{boxes:i,scores:s},u)}});function Pp(e,t,n){const r=function(e,t,n){return function(e,t,n){let r=0,a=e.length,i=0,s=!1;for(;r<a;){i=r+(a-r>>>1);const o=n(t,e[i]);o>0?r=i+1:(a=i,s=!o)}return s?r:-r-1}(e,t,n||Lp)}(e,t,n),a=r<0?-(r+1):r;e.splice(a,0,t)}function Lp(e,t){return e>t?1:e<t?-1:0}function Bp(e,t,n,r,a,i,s=!1,o=!1,u=!1){const l=[];for(let e=0;e<t.length;e++)t[e]>a&&l.push({score:t[e],boxIndex:e,suppressBeginIndex:0});l.sort(Vp);const c=i>0?-.5/i:0,h=[],p=[];for(;h.length<n&&l.length>0;){const t=l.pop(),{score:n,boxIndex:i,suppressBeginIndex:s}=t;if(n<a)break;let o=!1;for(let n=h.length-1;n>=s;--n){const s=Up(e,i,h[n]);if(s>=r){o=!0;break}if(t.score=t.score*Wp(r,c,s),t.score<=a)break}t.suppressBeginIndex=h.length,o||(t.score===n?(h.push(i),p.push(t.score)):t.score>a&&Pp(l,t,Vp))}const d=h.length,f=n-d;o&&f>0&&(h.push(...new Array(f).fill(0)),p.push(...new Array(f).fill(0)));const m={selectedIndices:h};return s&&(m.selectedScores=p),u&&(m.validOutputs=d),m}function Up(e,t,n){const r=e.subarray(4*t,4*t+4),a=e.subarray(4*n,4*n+4),i=Math.min(r[0],r[2]),s=Math.min(r[1],r[3]),o=Math.max(r[0],r[2]),u=Math.max(r[1],r[3]),l=Math.min(a[0],a[2]),c=Math.min(a[1],a[3]),h=Math.max(a[0],a[2]),p=Math.max(a[1],a[3]),d=(o-i)*(u-s),f=(h-l)*(p-c);if(d<=0||f<=0)return 0;const m=Math.max(i,l),g=Math.max(s,c),y=Math.min(o,h),b=Math.min(u,p),v=Math.max(y-m,0)*Math.max(b-g,0);return v/(d+f-v)}function Wp(e,t,n){const r=Math.exp(t*n*n);return n<=e?r:0}function Vp(e,t){return e.score-t.score||e.score===t.score&&t.boxIndex-e.boxIndex}const zp=ys({nonMaxSuppressionWithScore_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=0){const s=fs(e,"boxes","nonMaxSuppression"),o=fs(t,"scores","nonMaxSuppression"),u=$p(s,o,n,r,a,i),l={boxes:s,scores:o},c={maxOutputSize:n=u.maxOutputSize,iouThreshold:r=u.iouThreshold,scoreThreshold:a=u.scoreThreshold,softNmsSigma:i=u.softNmsSigma},h=li.runKernel(Bn,l,c);return{selectedIndices:h[0],selectedScores:h[1]}}}),jp=ys({nonMaxSuppressionPadded_:function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=!1){const s=fs(e,"boxes","nonMaxSuppression"),o=fs(t,"scores","nonMaxSuppression"),u=$p(s,o,n,r,a,null),l={boxes:s,scores:o},c={maxOutputSize:u.maxOutputSize,iouThreshold:u.iouThreshold,scoreThreshold:u.scoreThreshold,padToMaxOutputSize:i},h=li.runKernel(Ln,l,c);return{selectedIndices:h[0],validOutputs:h[1]}}}),Gp=ys({resizeBilinear_:function(e,t,n=!1,r=!1){const a=fs(e,"images","resizeBilinear");nt(3===a.rank||4===a.rank,(()=>`Error in resizeBilinear: x must be rank 3 or 4, but got rank ${a.rank}.`)),nt(2===t.length,(()=>`Error in resizeBilinear: new shape must 2D, but got shape ${t}.`)),nt(!1===r||!1===n,(()=>"Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false."));let i=a,s=!1;3===a.rank&&(s=!0,i=Bu(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const o={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=li.runKernel(Qn,o,u);return s?Bu(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),Hp=ys({resizeNearestNeighbor_:function(e,t,n=!1,r=!1){const a=fs(e,"images","resizeNearestNeighbor");nt(3===a.rank||4===a.rank,(()=>`Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${a.rank}.`)),nt(2===t.length,(()=>`Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`)),nt("float32"===a.dtype||"int32"===a.dtype,(()=>"`images` must have `int32` or `float32` as dtype")),nt(!1===r||!1===n,(()=>"Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false."));let i=a,s=!1;3===a.rank&&(s=!0,i=Bu(a,[1,a.shape[0],a.shape[1],a.shape[2]]));const o={images:i},u={alignCorners:n,halfPixelCenters:r,size:t},l=li.runKernel(Yn,o,u);return s?Bu(l,[l.shape[1],l.shape[2],l.shape[3]]):l}}),Kp=ys({threshold_:function(e,t="binary",n=!1,r=.5){const a=fs(e,"image","threshold"),i=a.shape[0]*a.shape[1];let s,o,u,l,c=pu(ep([r]),255);if(nt(3===a.rank,(()=>`Error in threshold: image must be rank 3,but got rank ${a.rank}.`)),nt(3===a.shape[2]||1===a.shape[2],(()=>`Error in threshold: image color channel must be equal to 3 or 1but got ${a.shape[2]}.`)),nt("int32"===a.dtype||"float32"===a.dtype,(()=>`Error in dtype: image dtype must be int32 or float32,but got dtype ${a.dtype}.`)),nt("otsu"===t||"binary"===t,(()=>`Method must be binary or otsu, but was ${t}`)),3===a.shape[2]){[s,o,u]=Hh(a,[1,1,1],-1);const e=pu(s,.2989),t=pu(o,.587),n=pu(u,.114);l=lu(lu(e,t),n)}else l=e;"otsu"===t&&(c=function(e,t){let n,r,a,i,s,o,u=ep([-1]),l=ep([0]),c=ep([0]);for(let h=0;h<e.size-1;h++){n=Gu(e,0,h+1),r=Gu(e,h+1),s=hu(ql(n),t),o=hu(ql(r),t);const p=ql(pu(n,xh(0,n.size)));a=hu(p,ql(n));const d=al(r.shape,n.size),f=lu(xh(0,r.size),d),m=pu(r,f);i=hu(ql(m),ql(r));const g=vc(a,i),y=vc(a,i),b=pu(s,o);c=pu(pu(b,g),y);const v=ic(c,l);l=Il(v,c,l),u=Il(v,ep([h]),u)}return u}(Zu(ko(Rh(l),"int32"),ws([]),256),i));const h=n?pc(l,c):ic(l,c);return ko(pu(h,255),"int32")}}),qp=ys({transform_:function(e,t,n="nearest",r="constant",a=0,i){const s=fs(e,"image","transform","float32"),o=fs(t,"transforms","transform","float32");nt(4===s.rank,(()=>`Error in transform: image must be rank 4,but got rank ${s.rank}.`)),nt(2===o.rank&&(o.shape[0]===s.shape[0]||1===o.shape[0])&&8===o.shape[1],(()=>"Error in transform: Input transform should be batch x 8 or 1 x 8")),nt(null==i||2===i.length,(()=>`Error in transform: outputShape must be [height, width] or null, but got ${i}.`));const u={image:s,transforms:o},l={interpolation:n,fillMode:r,fillValue:a,outputShape:i};return li.runKernel(Tr,u,l)}}),Xp=ys({bandPart_:function(e,t,n){nt(t%1==0,(()=>`bandPart(): numLower must be an integer, got ${t}.`)),nt(n%1==0,(()=>`bandPart(): numUpper must be an integer, got ${n}.`));const r=fs(e,"a","bandPart");nt(r.rank>=2,(()=>`bandPart(): Rank must be at least 2, got ${r.rank}.`));const a=r.shape,[i,s]=r.shape.slice(-2);if(!(t<=i))throw new Error(`bandPart(): numLower (${t}) must not be greater than the number of rows (${i}).`);if(!(n<=s))throw new Error(`bandPart(): numUpper (${n}) must not be greater than the number of columns (${s}).`);t<0&&(t=i),n<0&&(n=s);const o=Bu(xh(0,i,1,"int32"),[-1,1]),u=xh(0,s,1,"int32"),l=vc(o,u),c=xc(pc(l,Gl(+t,"int32")),sc(l,Gl(-n,"int32"))),h=Oc([i,s],r.dtype);return Bu(Yh(sp(Bu(r,[-1,i,s])).map((e=>Il(c,e,h)))),a)}}),Yp=ys({gramSchmidt_:function(e){let t;if(Array.isArray(e)){t=!1,nt(null!=e&&e.length>0,(()=>"Gram-Schmidt process: input must not be null, undefined, or empty"));const n=e[0].shape[0];for(let t=1;t<e.length;++t)nt(e[t].shape[0]===n,(()=>`Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`))}else t=!0,e=Hh(e,e.shape[0],0).map((e=>Xh(e,[0])));nt(e.length<=e[0].shape[0],(()=>`Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`));const n=[],r=e;for(let t=0;t<e.length;++t)n.push(li.tidy((()=>{let e=r[t];if(t>0)for(let r=0;r<t;++r){const t=pu(ql(pu(n[r],e)),n[r]);e=vc(e,t)}return hu(e,Yl(e,"euclidean"))})));return t?Yh(n,0):n}});function Qp(e,t=!1){return li.tidy((()=>{nt(2===e.shape.length,(()=>`qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`));const n=e.shape[0],r=e.shape[1];let a=nc(n),i=Vu(e);const s=tp([[1]],[1,1]);let o=Vu(s);const u=n>=r?r:n;for(let e=0;e<u;++e){const t=i,u=o,l=a;[o,i,a]=li.tidy((()=>{const t=Gu(i,[e,e],[n-e,1]),u=Yl(t),l=Gu(i,[e,e],[1,1]),c=Il(ic(l,0),tp([[-1]]),tp([[1]])),h=vc(l,pu(c,u)),p=hu(t,h);o=1===p.shape[0]?Vu(s):zu([s,Gu(p,[1,0],[p.shape[0]-1,p.shape[1]])],0);const d=Mo(hu(To(c,h),u)),f=Gu(i,[e,0],[n-e,r]),m=pu(d,o),g=Do(o);if(0===e)i=vc(f,To(m,To(g,f)));else{const t=vc(f,To(m,To(g,f)));i=zu([Gu(i,[0,0],[e,r]),t],0)}const y=Do(m),b=Gu(a,[0,e],[n,a.shape[1]-e]);if(0===e)a=vc(b,To(To(b,o),y));else{const t=vc(b,To(To(b,o),y));a=zu([Gu(a,[0,0],[n,e]),t],1)}return[o,i,a]})),Ao([t,u,l])}return!t&&n>r&&(a=Gu(a,[0,0],[n,r]),i=Gu(i,[0,0],[r,r])),[a,i]}))}const Jp=ys({qr_:function(e,t=!1){if(nt(e.rank>=2,(()=>`qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`)),2===e.rank)return Qp(e,t);{const n=e.shape.slice(0,e.shape.length-2).reduce(((e,t)=>e*t)),r=sp(Bu(e,[n,e.shape[e.shape.length-2],e.shape[e.shape.length-1]]),0),a=[],i=[];return r.forEach((e=>{const[n,r]=Qp(e,t);a.push(n),i.push(r)})),[Bu(Yh(a,0),e.shape),Bu(Yh(i,0),e.shape)]}}});var Zp;!function(e){e[e.NONE=0]="NONE",e[e.MEAN=1]="MEAN",e[e.SUM=2]="SUM",e[e.SUM_BY_NONZERO_WEIGHTS=3]="SUM_BY_NONZERO_WEIGHTS"}(Zp||(Zp={}));const ed=ys({computeWeightedLoss_:function(e,t,n=Zp.SUM_BY_NONZERO_WEIGHTS){const r=fs(e,"losses","computeWeightedLoss");let a=null;null!=t&&(a=fs(t,"weights","computeWeightedLoss"));const i=null==a?r:pu(r,a);if(n===Zp.NONE)return i;if(n===Zp.SUM)return ql(i);if(n===Zp.MEAN){if(null==a)return Fc(i);{const e=r.size/a.size,t=hu(ql(i),ql(a));return e>1?hu(t,Gl(e)):t}}if(n===Zp.SUM_BY_NONZERO_WEIGHTS){if(null==a)return hu(ql(i),Gl(r.size));{const e=pu(a,Mc(r.shape)),t=ko(ql(Wc(e,Gl(0))),"float32");return hu(ql(i),t)}}throw Error(`Unknown reduction: ${n}`)}}),td=ys({absoluteDifference_:function(e,t,n,r=Zp.SUM_BY_NONZERO_WEIGHTS){const a=fs(e,"labels","absoluteDifference"),i=fs(t,"predictions","absoluteDifference");let s=null;null!=n&&(s=fs(n,"weights","absoluteDifference")),rt(a.shape,i.shape,"Error in absoluteDifference: ");const o=du(vc(a,i));return ed(o,s,r)}}),nd=ys({cosineDistance_:function(e,t,n,r,a=Zp.SUM_BY_NONZERO_WEIGHTS){const i=fs(e,"labels","cosineDistance"),s=fs(t,"predictions","cosineDistance");let o=null;null!=r&&(o=fs(r,"weights","cosineDistance")),rt(i.shape,s.shape,"Error in cosineDistance: ");const u=Gl(1),l=vc(u,ql(pu(i,s),n,!0));return ed(l,o,a)}}),rd=ys({hingeLoss_:function(e,t,n,r=Zp.SUM_BY_NONZERO_WEIGHTS){let a=fs(e,"labels","hingeLoss");const i=fs(t,"predictions","hingeLoss");let s=null;null!=n&&(s=fs(n,"weights","hingeLoss")),rt(a.shape,i.shape,"Error in hingeLoss: ");const o=Gl(1);a=vc(pu(Gl(2),a),o);const u=Th(vc(o,pu(a,i)));return ed(u,s,r)}}),ad=ys({huberLoss_:function(e,t,n,r=1,a=Zp.SUM_BY_NONZERO_WEIGHTS){const i=fs(e,"labels","huberLoss"),s=fs(t,"predictions","huberLoss");let o=null;null!=n&&(o=fs(n,"weights","huberLoss")),rt(i.shape,s.shape,"Error in huberLoss: ");const u=Gl(r),l=du(vc(s,i)),c=$c(l,u),h=vc(l,c),p=lu(pu(Gl(.5),Kl(c)),pu(u,h));return ed(p,o,a)}}),id=ys({logLoss_:function(e,t,n,r=1e-7,a=Zp.SUM_BY_NONZERO_WEIGHTS){const i=fs(e,"labels","logLoss"),s=fs(t,"predictions","logLoss");let o=null;null!=n&&(o=fs(n,"weights","logLoss")),rt(i.shape,s.shape,"Error in logLoss: ");const u=Gl(1),l=Gl(r),c=Mo(pu(i,fc(lu(s,l)))),h=pu(vc(u,i),fc(lu(vc(u,s),l))),p=vc(c,h);return ed(p,o,a)}}),sd=ys({meanSquaredError_:function(e,t,n,r=Zp.SUM_BY_NONZERO_WEIGHTS){const a=fs(e,"labels","meanSquaredError"),i=fs(t,"predictions","meanSquaredError");let s=null;null!=n&&(s=fs(n,"weights","meanSquaredError")),rt(a.shape,i.shape,"Error in meanSquaredError: ");const o=qh(a,i);return ed(o,s,r)}}),od=ys({sigmoidCrossEntropy_:function(e,t,n,r=0,a=Zp.SUM_BY_NONZERO_WEIGHTS){let i=fs(e,"multiClassLabels","sigmoidCrossEntropy");const s=fs(t,"logits","sigmoidCrossEntropy");let o=null;if(null!=n&&(o=fs(n,"weights","sigmoidCrossEntropy")),rt(i.shape,s.shape,"Error in sigmoidCrossEntropy: "),r>0){const e=Gl(r),t=Gl(1),n=Gl(.5);i=lu(pu(i,vc(t,e)),pu(n,e))}const u=function(e,t){const n=fs(e,"labels","sigmoidCrossEntropyWithLogits"),r=fs(t,"logits","sigmoidCrossEntropyWithLogits");rt(n.shape,r.shape,"Error in sigmoidCrossEntropyWithLogits: ");const a=Th(r),i=pu(r,n),s=mc(Jl(Mo(du(r))));return lu(vc(a,i),s)}(i,s);return ed(u,o,a)}}),ud=ys({softmaxCrossEntropy_:function(e,t,n,r=0,a=Zp.SUM_BY_NONZERO_WEIGHTS){let i=fs(e,"onehotLabels","softmaxCrossEntropy");const s=fs(t,"logits","softmaxCrossEntropy");let o=null;if(null!=n&&(o=fs(n,"weights","softmaxCrossEntropy")),rt(i.shape,s.shape,"Error in softmaxCrossEntropy: "),r>0){const e=Gl(r),t=Gl(1),n=Gl(i.shape[1]);i=lu(pu(i,vc(t,e)),hu(e,n))}const u=function(e,t,n=-1){if(-1===n&&(n=t.rank-1),n!==t.rank-1)throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${t.rank} and dim was ${n}`);const r=gc(((e,t,r)=>{const a=_c(t,[n],!0),i=vc(ko(t,"float32"),a);r([e,i]);const s=Mo(pu(i,e));return{value:ql(s,[n]),gradFunc:(e,t)=>{const[r,a]=t,i=Pl(e.shape,[n]);return[pu(Bu(e,i),vc(ko(r,"float32"),Jl(a))),pu(Bu(e,i),vc(Jl(a),ko(r,"float32")))]}}}));return r(e,t)}(i,s);return ed(u,o,a)}}),ld=ys({sparseFillEmptyRows_:function(e,t,n,r){const a=fs(e,"indices","sparseFillEmptyRows","int32"),i=fs(t,"values","sparseFillEmptyRows"),s=fs(n,"denseShape","sparseFillEmptyRows","int32"),o=fs(r,"defaultValue","sparseFillEmptyRows",i.dtype);if(2!==a.rank)throw new Error(`Indices should be Tensor2D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Values should be Tensor1D but received shape ${i.shape}`);if(1!==s.rank)throw new Error(`Dense shape should be Tensor1D but received shape ${s.shape}`);if(0!==o.rank)throw new Error(`Default value should be a scalar but received shape ${o.shape}`);const u={indices:a,values:i,denseShape:s,defaultValue:o},l=li.runKernel(hr,u);return{outputIndices:l[0],outputValues:l[1],emptyRowIndicator:l[2],reverseIndexMap:l[3]}}}),cd=ys({sparseReshape_:function(e,t,n){const r=fs(e,"inputIndices","sparseReshape","int32"),a=fs(t,"inputShape","sparseReshape","int32"),i=fs(n,"newShape","sparseReshape","int32");if(2!==r.rank)throw new Error(`Input indices should be Tensor2D but received shape\n ${r.shape}`);if(1!==a.rank)throw new Error(`Input shape should be Tensor1D but received shape ${a.shape}`);if(1!==i.rank)throw new Error(`New shape should be Tensor1D but received shape ${i.shape}`);const s={inputIndices:r,inputShape:a,newShape:i},o=li.runKernel(pr,s);return{outputIndices:o[0],outputShape:o[1]}}}),hd=ys({sparseSegmentMean_:function(e,t,n){const r=fs(e,"data","sparseSegmentMean"),a=fs(t,"indices","sparseSegmentMean","int32"),i=fs(n,"segmentIds","sparseSegmentMean","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${i.shape}`);const s={data:r,indices:a,segmentIds:i};return li.runKernel(dr,s)}}),pd=ys({sparseSegmentSum_:function(e,t,n){const r=fs(e,"data","sparseSegmentSum"),a=fs(t,"indices","sparseSegmentSum","int32"),i=fs(n,"segmentIds","sparseSegmentSum","int32");if(r.rank<1)throw new Error("Data should be at least 1 dimensional but received scalar");if(1!==a.rank)throw new Error(`Indices should be Tensor1D but received shape\n ${a.shape}`);if(1!==i.rank)throw new Error(`Segment ids should be Tensor1D but received shape\n ${i.shape}`);const s={data:r,indices:a,segmentIds:i};return li.runKernel(fr,s)}}),dd=ys({stringNGrams_:function(e,t,n,r,a,i,s,o){const u=fs(e,"data","stringNGrams","string");if("string"!==u.dtype)throw new Error("Data must be of datatype string");if(1!==u.shape.length)throw new Error(`Data must be a vector, saw: ${u.shape}`);const l=fs(t,"dataSplits","stringNGrams");if("int32"!==l.dtype)throw new Error("Data splits must be of datatype int32");const c={separator:n,nGramWidths:r,leftPad:a,rightPad:i,padWidth:s,preserveShortSequences:o},h={data:u,dataSplits:l},p=li.runKernel(yr,h,c);return{nGrams:p[0],nGramsSplits:p[1]}}}),fd={fft:zh,ifft:jh,rfft:Kh,irfft:Gh},md={hammingWindow:Ip,hannWindow:Ap,frame:Cp,stft:Np},gd={flipLeftRight:Fp,grayscaleToRGB:Op,resizeNearestNeighbor:Hp,resizeBilinear:Gp,rotateWithOffset:Mp,cropAndResize:Rp,nonMaxSuppression:Dp,nonMaxSuppressionAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY){const i=fs(e,"boxes","nonMaxSuppressionAsync"),s=fs(t,"scores","nonMaxSuppressionAsync"),o=$p(i,s,n,r,a);n=o.maxOutputSize,r=o.iouThreshold,a=o.scoreThreshold;const u=await Promise.all([i.data(),s.data()]),l=u[0],c=u[1],{selectedIndices:h}=function(e,t,n,r,a){return Bp(e,t,n,r,a,0)}(l,c,n,r,a);return i!==e&&i.dispose(),s!==t&&s.dispose(),ep(h,"int32")},nonMaxSuppressionWithScore:zp,nonMaxSuppressionWithScoreAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=0){const s=fs(e,"boxes","nonMaxSuppressionAsync"),o=fs(t,"scores","nonMaxSuppressionAsync"),u=$p(s,o,n,r,a,i);n=u.maxOutputSize,r=u.iouThreshold,a=u.scoreThreshold,i=u.softNmsSigma;const l=await Promise.all([s.data(),o.data()]),c=l[0],h=l[1],{selectedIndices:p,selectedScores:d}=function(e,t,n,r,a,i){return Bp(e,t,n,r,a,i,!0)}(c,h,n,r,a,i);return s!==e&&s.dispose(),o!==t&&o.dispose(),{selectedIndices:ep(p,"int32"),selectedScores:ep(d)}},nonMaxSuppressionPadded:jp,nonMaxSuppressionPaddedAsync:async function(e,t,n,r=.5,a=Number.NEGATIVE_INFINITY,i=!1){const s=fs(e,"boxes","nonMaxSuppressionAsync"),o=fs(t,"scores","nonMaxSuppressionAsync"),u=$p(s,o,n,r,a,null),l=u.maxOutputSize,c=u.iouThreshold,h=u.scoreThreshold,[p,d]=await Promise.all([s.data(),o.data()]),{selectedIndices:f,validOutputs:m}=function(e,t,n,r,a,i){return Bp(e,t,n,r,a,0,!1,i,!0)}(p,d,l,c,h,i);return s!==e&&s.dispose(),o!==t&&o.dispose(),{selectedIndices:ep(f,"int32"),validOutputs:Gl(m,"int32")}},threshold:Kp,transform:qp},yd={bandPart:Xp,gramSchmidt:Yp,qr:Jp},bd={absoluteDifference:td,computeWeightedLoss:ed,cosineDistance:nd,hingeLoss:rd,huberLoss:ad,logLoss:id,meanSquaredError:sd,sigmoidCrossEntropy:od,softmaxCrossEntropy:ud},vd={sparseFillEmptyRows:ld,sparseReshape:cd,sparseSegmentMean:hd,sparseSegmentSum:pd},wd={stringNGrams:dd,stringSplit:ys({stringSplit_:function(e,t,n=!0){const r=fs(e,"input","stringSplit","string"),a=fs(t,"delimiter","stringSplit","string");if(1!==r.rank)throw new Error(`Input should be Tensor1D but received shape ${r.shape}`);if(0!==a.rank)throw new Error(`Delimiter should be a scalar but received shape ${a.shape}`);const i={skipEmpty:n},s={input:r,delimiter:a},o=li.runKernel(br,s,i);return{indices:o[0],values:o[1],shape:o[2]}}}),stringToHashBucketFast:ys({stringToHashBucketFast_:function(e,t){const n=fs(e,"input","stringToHashBucketFast","string"),r={numBuckets:t};if(t<=0)throw new Error("Number of buckets must be at least 1");const a={input:n};return li.runKernel(vr,a,r)}})},_d="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:"undefined"!=typeof setImmediate?setImmediate:e=>e();function xd(e,t){const n=e[0].length;e.forEach(((e,t)=>{nt(e.length===n,(()=>`Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`))})),nt(t>=0&&t<n,(()=>`Error in concat${n}D: axis must be between 0 and ${n-1}.`));const r=e[0];e.forEach(((e,a)=>{for(let i=0;i<n;i++)nt(i===t||e[i]===r[i],(()=>`Error in concat${n}D: Shape of tensors[${a}] (${e}) does not match the shape of the rest (${r}) along the non-concatenated axis ${a}.`))}))}function kd(e,t){const n=e[0].slice();for(let r=1;r<e.length;r++)n[t]+=e[r][t];return n}var Td;function Ed(e,t,n){let r=new Array;if(null==n&&null==t)return r;if(null==t)for(;r.length<e+n.length;)r.push(-1);else r=t.slice();if(null==n)return r;if(e+n.length!==r.length)throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.rank = ${e+n.length}, but shape.rank = ${r.length}`);for(let a=1;a<n.length;++a){const i=n[a],s=r[r.length-n.length+a],o=r[s];if(i>=0)if(o>=0){if(o!==i)throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.shape[${a+e}] = ${i} but shape[${a+e}] = ${o}`)}else r[s]=i}return r}function Sd(e){const t={FIRST_DIM_SIZE:Td.FIRST_DIM_SIZE,VALUE_ROWIDS:Td.VALUE_ROWIDS,ROW_LENGTHS:Td.ROW_LENGTHS,ROW_SPLITS:Td.ROW_SPLITS,ROW_LIMITS:Td.ROW_LIMITS,ROW_STARTS:Td.ROW_STARTS},n=[];for(const r of e){if(!(r in t))break;n.push(t[r])}return n}function Id(e){return 0===e.length?0:e[0]===Td.FIRST_DIM_SIZE?e.length-1:e.length}function Ad(e,t){if(null==e||null==t)return;const n=e.length,r=t.length;if(n>=r)throw new Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${t}, are incompatible: defaultValue.rank = ${n} must be less than ragged tensor input flatValues.rank = ${r})`);for(let a=0;a<Math.min(n,r-1);++a){const n=e[a],r=t[a+1];if(n>=0&&r>=0&&1!==n&&n!==r)throw new Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${t} are incompatible: defaultValue.shape[${a-e.length}] = ${n} but ragged tensor input.flatValues.shape[${a-e.length}] = ${r}`)}}!function(e){e[e.FIRST_DIM_SIZE=0]="FIRST_DIM_SIZE",e[e.VALUE_ROWIDS=1]="VALUE_ROWIDS",e[e.ROW_LENGTHS=2]="ROW_LENGTHS",e[e.ROW_SPLITS=3]="ROW_SPLITS",e[e.ROW_LIMITS=4]="ROW_LIMITS",e[e.ROW_STARTS=5]="ROW_STARTS"}(Td||(Td={}));const Cd=30;function Nd(e){return e<=Cd?e:_t(e,Math.floor(Math.sqrt(e)))}function Rd(e,t,n){return[n*("number"==typeof e?e:e[0]),t*("number"==typeof e?e:e[1])]}function Fd(e,t,n,r=!0){let a=[];if(r)a=a.concat(t.slice(0)),a.push(e[0]/n),a=a.concat(e.slice(1));else{a=a.concat(e[0]);const n=t.length;for(let r=0;r<n;++r)a=a.concat([e[r+1]/t[r],t[r]]);a=a.concat(e.slice(n+1))}return a}function Od(e,t,n=!0){const r=[];if(n){r.push(t);for(let n=t+1;n<e;++n)n<=2*t?(r.push(n),r.push(n-(t+1))):r.push(n)}else{const n=[],a=[];for(let r=1;r<e;++r)r>=2*t+1||r%2==1?a.push(r):n.push(r);r.push(...n),r.push(0),r.push(...a)}return r}function Md(e,t,n,r=!0){const a=[];r?a.push(e[0]/n):a.push(e[0]*n);for(let n=1;n<e.length;++n)n<=t.length?r?a.push(t[n-1]*e[n]):a.push(e[n]/t[n-1]):a.push(e[n]);return a}function $d(e,t){const n=[0];for(let r=0;r<t;++r)n.push(e[r][0]);return n}function Dd(e,t,n){const r=e.slice(0,1);for(let a=0;a<n;++a)r.push(e[a+1]-t[a][0]-t[a][1]);return r}function Pd(e,t){if(e.length!==t.length)throw new Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${t.length}.`);const n=new Float32Array(2*e.length);for(let r=0;r<n.length;r+=2)n[r]=e[r/2],n[r+1]=t[r/2];return n}const Ld=/->/g;function Bd(e,t){const n=[];for(let r=0;r<e.length;++r)0!==e[r].length&&-1===e[r].indexOf(t)&&-1!==t||n.push(r);return n}function Ud(e,t,n=0){let r=[];if("number"==typeof t)nt(e.shape[n]%t==0,(()=>"Number of splits must evenly divide the axis.")),r=new Array(t).fill(e.shape[n]/t);else{nt(t.reduce(((e,t)=>(-1===t&&(e+=1),e)),0)<=1,(()=>"There should be only one negative value in split array."));const a=t.indexOf(-1);if(-1!==a){const r=t.reduce(((e,t)=>t>0?e+t:e));t[a]=e.shape[n]-r}nt(e.shape[n]===t.reduce(((e,t)=>e+t)),(()=>"The sum of sizes must match the size of the axis dimension.")),r=t}return r}function Wd(e){return`Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${e}`}function Vd(e,t){return`indices(${e}, 0) is invalid: ${t} < 0`}function zd(e,t,n){return`indices(${e}, 0) is invalid: ${t} >= ${n}`}function jd(e,t){return`only one output dimension may be -1, not both ${e} and ${t}`}function Gd(e,t){return`size ${e} must be non-negative, not ${t}`}function Hd(e,t){return`Input to reshape is a SparseTensor with ${it(e)}\n dense values, but the requested shape requires a multiple of ${it(t)}. inputShape=${e} outputShape= ${t}`}function Kd(e,t){return`Input to reshape is a tensor with ${it(e)} dense values, but the requested shape has ${it(t)}. inputShape=${e} outputShape=${t}`}function qd(e,t){return`Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`}function Xd(e,t,n){return`Bad: indices[${e}] == ${t} out of range [0, ${n})`}function Yd(e,t,n,r){const a=t.shape.length,i=e.shape.length;if(0!==r&&(r<-a||r>a))throw new Error(`Expect batchDims in the range of [-${a}, ${a}], but got ${r}`);if(r<0&&(r+=a),r>i)throw new Error(`batchDims (${r}) must be less than rank(x) (\n ${i}).`);if(n<r)throw new Error(`batchDims (${r}) must be less than or equal to axis (${n}).`);for(let n=0;n<r;++n)if(e.shape[n]!==t.shape[n])throw new Error(`x.shape[${n}]: ${e.shape[n]} should be equal to indices.shape[${n}]: ${t.shape[n]}.`);const s=e.shape[n],o=[];let u=1,l=1,c=1;for(let t=0;t<r;++t)o.push(e.shape[t]),u*=e.shape[t];for(let t=r;t<n;t++)o.push(e.shape[t]),l*=e.shape[t];for(let e=r;e<a;e++)o.push(t.shape[e]);for(let t=n+1;t<i;t++)o.push(e.shape[t]),c*=e.shape[t];return{batchSize:u,sliceSize:c,outerSize:l,dimSize:s,outputShape:o}}var Qd=Object.freeze({__proto__:null,segOpComputeOptimalWindowSize:function(e,t){let n,r=!1;for(e<=Cd?(n=e,r=!0):n=_t(e,Math.floor(Math.sqrt(e)));!r;)n>t||n===e?r=!0:n=_t(e,n+1);return n},computeOutShape:function(e,t,n){const r=[],a=e.length;for(let i=0;i<a;i++)i!==t?r.push(e[i]):r.push(n);return r},collectGatherOpShapeInfo:Yd});function Jd(e){try{return e.map((e=>Na(e)))}catch(e){throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`)}}function Zd(e){return e.map((e=>Ca(e)))}var ef=Object.freeze({__proto__:null,slice_util:uu,segment_util:Qd,fromUint8ToStringArray:Jd,fromStringArrayToUint8:Zd,upcastType:ti,axesAreInnerMostDims:Ml,combineLocations:$l,computeOutAndReduceShapes:Dl,expandShapeToKeepDim:Pl,assertAxesAreInnerMostDims:Ll,getAxesPermutation:Bl,getUndoAxesPermutation:Ul,getInnerMostAxes:Wl,getBroadcastDims:Po,getReductionAxes:Lo,assertAndGetBroadcastShape:Bo,assertParamsConsistent:xd,computeOutShape:kd,computeDilation2DInfo:function(e,t,n,r,a="NHWC",i){return Iu(e,[...t,e[3]],n,i,r,null,null,Pu(a))},computePool2DInfo:Su,computePool3DInfo:function(e,t,n,r,a,i,s="NDHWC"){const[o,u,l]=Ru(t);let c,h;if("NDHWC"===s)h="channelsLast",c=[o,u,l,e[4],e[4]];else{if("NCDHW"!==s)throw new Error(`Unknown dataFormat ${s}`);h="channelsFirst",c=[o,u,l,e[1],e[1]]}return Au(e,c,n,r,a,!1,h,i)},computeConv2DInfo:Iu,computeConv3DInfo:Au,computeDefaultPad:Cu,tupleValuesAreOne:Mu,eitherStridesOrDilationsAreOne:$u,stridesOrDilationsArePositive:Du,convertConv2DDataFormat:Pu,checkPadOnDimRoundingMode:Lu,getFusedDyActivation:yp,getFusedBiasGradient:bp,applyActivation:vp,shouldFuse:wp,get RowPartitionType(){return Td},combineRaggedTensorToTensorShapes:Ed,getRowPartitionTypesHelper:Sd,getRaggedRank:Id,validateDefaultValueShape:Ad,PARALLELIZE_THRESHOLD:Cd,computeOptimalWindowSize:Nd,getImageCenter:Rd,getReshaped:Fd,getPermuted:Od,getReshapedPermuted:Md,getSliceBeginCoords:$d,getSliceSize:Dd,prepareAndValidate:zo,validateUpdateShape:jo,validateInput:Go,calculateShapes:Ho,SELU_SCALEALPHA:1.7580993408473768,SELU_SCALE:1.0507009873554805,ERF_P:.3275911,ERF_A1:.254829592,ERF_A2:-.284496736,ERF_A3:1.421413741,ERF_A4:-1.453152027,ERF_A5:1.061405429,warn:Mr,log:function(...e){Mt().getBool("IS_TEST")||Mt().getBool("PROD")||console.log(...e)},mergeRealAndImagArrays:Pd,splitRealAndImagArrays:function(e){const t=new Float32Array(e.length/2),n=new Float32Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=e[r],n[r/2]=e[r+1];return{real:t,imag:n}},complexWithEvenIndex:function(e){const t=Math.ceil(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let t=0;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],r[Math.floor(t/4)]=e[t+1];return{real:n,imag:r}},complexWithOddIndex:function(e){const t=Math.floor(e.length/4),n=new Float32Array(t),r=new Float32Array(t);for(let t=2;t<e.length;t+=4)n[Math.floor(t/4)]=e[t],r[Math.floor(t/4)]=e[t+1];return{real:n,imag:r}},getComplexWithIndex:function(e,t){return{real:e[2*t],imag:e[2*t+1]}},assignToTypedArray:function(e,t,n,r){e[2*r]=t,e[2*r+1]=n},exponents:function(e,t){const n=new Float32Array(e/2),r=new Float32Array(e/2);for(let a=0;a<Math.ceil(e/2);a++){const i=(t?2:-2)*Math.PI*(a/e);n[a]=Math.cos(i),r[a]=Math.sin(i)}return{real:n,imag:r}},exponent:function(e,t,n){const r=(n?2:-2)*Math.PI*(e/t);return{real:Math.cos(r),imag:Math.sin(r)}},decodeEinsumEquation:function(e,t){const n=((e=e.replace(/\s/g,"")).length-e.replace(Ld,"").length)/2;if(n<1)throw new Error("Equations without an arrow are not supported.");if(n>1)throw new Error('Equation must contain exactly one arrow ("->").');const[r,a]=e.split("->");nt(-1===r.indexOf("..."),(()=>'The ellipsis notation ("...") is not supported yet.'));const i=r.split(","),s=i.length;if(t!==s)throw new Error(`Expected ${s} input tensors, received ${t}`);if(s>2)throw new Error("Support for more than 2 input tensors is not implemented yet.");const o=[];for(let e=0;e<a.length;++e){const t=a[e];if(!i.some((e=>-1!==e.indexOf(t))))throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);-1===o.indexOf(t)&&o.push(t)}for(let e=0;e<r.length;++e){const t=r[e];-1===o.indexOf(t)&&","!==t&&o.push(t)}const u=new Array(i.length);for(let e=0;e<s;++e){if(new Set(i[e].split("")).size!==i[e].length)throw new Error(`Found duplicate axes in input component ${i[e]}. Support for duplicate axes in input is not implemented yet.`);u[e]=[];for(let t=0;t<i[e].length;++t)u[e].push(o.indexOf(i[e][t]))}const l=o.length,c=[];for(let e=a.length;e<l;++e)c.push(e);return{allDims:o,summedDims:c,idDims:u}},getEinsumPermutation:function(e,t){let n=new Array(e);n.fill(-1);for(let e=0;e<t.length;++e)n[t[e]]=e;const r=[];for(let t=0;t<e;++t)-1===n[t]&&r.push(t);return n=n.filter((e=>-1!==e)),{permutationIndices:n,expandDims:r}},checkEinsumDimSizes:function(e,t,n){const r=new Array(e);for(let e=0;e<n.length;++e){const a=n[e].shape;for(let n=0;n<t[e].length;++n)void 0===r[t[e][n]]?r[t[e][n]]=a[n]:nt(r[t[e][n]]===a[n],(()=>`Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(a)}, but got dimension ${a[n]}`))}},getEinsumComputePath:function(e,t){const n=e,r=[];let a=0;0===e.length&&n.push(-1),a=e.length+1;for(let e=0;e<a;++e)r.push([]);const i=[];for(let e=0;e<n.length;++e){const a=Bd(t,n[e]);for(const t of a)-1===i.indexOf(t)&&(r[e].push(t),i.push(t))}return{path:n,steps:r}},isIdentityPermutation:function(e){return e.every(((e,t)=>e===t))},prepareSplitSize:Ud,getSparseFillEmptyRowsIndicesDenseShapeMismatch:Wd,getSparseFillEmptyRowsNegativeIndexErrorMessage:Vd,getSparseFillEmptyRowsOutOfRangeIndexErrorMessage:zd,getSparseReshapeMultipleNegativeOneOutputDimErrorMessage:jd,getSparseReshapeNegativeOutputDimErrorMessage:Gd,getSparseReshapeEmptyTensorZeroOutputDimErrorMessage:function(){return"reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero"},getSparseReshapeInputOutputMultipleErrorMessage:Hd,getSparseReshapeInputOutputMismatchErrorMessage:Kd,getSparseSegmentReductionNegativeSegmentIdsErrorMessage:function(){return"segment ids must be >= 0"},getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage:function(){return"segment ids are not increasing"},getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage:qd,getSparseSegmentReductionIndicesOutOfRangeErrorMessage:Xd});class tf{constructor(){this.messageName="setTimeoutCustom",this.functionRefs=[],this.handledMessageCount=0,this.hasEventListener=!1}fetch(e,t){return fetch(e,t)}now(){return performance.now()}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Browser's encoder only supports utf-8, but got ${t}`);return null==this.textEncoder&&(this.textEncoder=new TextEncoder),this.textEncoder.encode(e)}decode(e,t){return new TextDecoder(t).decode(e)}setTimeoutCustom(e,t){"undefined"!=typeof window&&Mt().getBool("USE_SETTIMEOUTCUSTOM")?(this.functionRefs.push(e),setTimeout((()=>{window.postMessage({name:this.messageName,index:this.functionRefs.length-1},"*")}),t),this.hasEventListener||(this.hasEventListener=!0,window.addEventListener("message",(e=>{e.source===window&&e.data.name===this.messageName&&(e.stopPropagation(),(0,this.functionRefs[e.data.index])(),this.handledMessageCount++,this.handledMessageCount===this.functionRefs.length&&(this.functionRefs=[],this.handledMessageCount=0))}),!0))):setTimeout(e,t)}isTypedArray(e){return e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray}}if(Mt().get("IS_BROWSER")){Mt().setPlatform("browser",new tf);try{vo.registerManager(eo.URL_SCHEME,new no)}catch(o){}try{vo.registerManager(Ws.URL_SCHEME,new zs)}catch(o){}}let nf;var rf,af;Mt().get("IS_NODE")&&!Mt().get("IS_BROWSER")&&Mt().setPlatform("node",new class{constructor(){this.util=n(345),this.textEncoder=new this.util.TextEncoder}fetch(e,t){return null!=Mt().global.fetch?Mt().global.fetch(e,t):(null==nf&&(nf=n(683)),nf(e,t))}now(){const e=Xe.hrtime();return 1e3*e[0]+e[1]/1e6}encode(e,t){if("utf-8"!==t&&"utf8"!==t)throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`);return this.textEncoder.encode(e)}decode(e,t){return 0===e.length?"":new this.util.TextDecoder(t).decode(e)}isTypedArray(e){return this.util.types.isFloat32Array(e)||this.util.types.isInt32Array(e)||this.util.types.isUint8Array(e)||this.util.types.isUint8ClampedArray(e)}}),ui(),Ha={buffer:nl,cast:ko,clone:Vu,print:Jc},Mt().registerFlag("KEEP_INTERMEDIATE_TENSORS",(()=>!1),(e=>{e&&console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.")})),function(e){e[e.DT_INVALID=0]="DT_INVALID",e[e.DT_FLOAT=1]="DT_FLOAT",e[e.DT_DOUBLE=2]="DT_DOUBLE",e[e.DT_INT32=3]="DT_INT32",e[e.DT_UINT8=4]="DT_UINT8",e[e.DT_INT16=5]="DT_INT16",e[e.DT_INT8=6]="DT_INT8",e[e.DT_STRING=7]="DT_STRING",e[e.DT_COMPLEX64=8]="DT_COMPLEX64",e[e.DT_INT64=9]="DT_INT64",e[e.DT_BOOL=10]="DT_BOOL",e[e.DT_QINT8=11]="DT_QINT8",e[e.DT_QUINT8=12]="DT_QUINT8",e[e.DT_QINT32=13]="DT_QINT32",e[e.DT_BFLOAT16=14]="DT_BFLOAT16",e[e.DT_QINT16=15]="DT_QINT16",e[e.DT_QUINT16=16]="DT_QUINT16",e[e.DT_UINT16=17]="DT_UINT16",e[e.DT_COMPLEX128=18]="DT_COMPLEX128",e[e.DT_HALF=19]="DT_HALF",e[e.DT_RESOURCE=20]="DT_RESOURCE",e[e.DT_VARIANT=21]="DT_VARIANT",e[e.DT_UINT32=22]="DT_UINT32",e[e.DT_UINT64=23]="DT_UINT64",e[e.DT_FLOAT_REF=101]="DT_FLOAT_REF",e[e.DT_DOUBLE_REF=102]="DT_DOUBLE_REF",e[e.DT_INT32_REF=103]="DT_INT32_REF",e[e.DT_UINT8_REF=104]="DT_UINT8_REF",e[e.DT_INT16_REF=105]="DT_INT16_REF",e[e.DT_INT8_REF=106]="DT_INT8_REF",e[e.DT_STRING_REF=107]="DT_STRING_REF",e[e.DT_COMPLEX64_REF=108]="DT_COMPLEX64_REF",e[e.DT_INT64_REF=109]="DT_INT64_REF",e[e.DT_BOOL_REF=110]="DT_BOOL_REF",e[e.DT_QINT8_REF=111]="DT_QINT8_REF",e[e.DT_QUINT8_REF=112]="DT_QUINT8_REF",e[e.DT_QINT32_REF=113]="DT_QINT32_REF",e[e.DT_BFLOAT16_REF=114]="DT_BFLOAT16_REF",e[e.DT_QINT16_REF=115]="DT_QINT16_REF",e[e.DT_QUINT16_REF=116]="DT_QUINT16_REF",e[e.DT_UINT16_REF=117]="DT_UINT16_REF",e[e.DT_COMPLEX128_REF=118]="DT_COMPLEX128_REF",e[e.DT_HALF_REF=119]="DT_HALF_REF",e[e.DT_RESOURCE_REF=120]="DT_RESOURCE_REF",e[e.DT_VARIANT_REF=121]="DT_VARIANT_REF",e[e.DT_UINT32_REF=122]="DT_UINT32_REF",e[e.DT_UINT64_REF=123]="DT_UINT64_REF"}(rf||(rf={})),function(e){var t;(t=e.CheckpointFormatVersion||(e.CheckpointFormatVersion={}))[t.LEGACY=0]="LEGACY",t[t.V1=1]="V1",t[t.V2=2]="V2"}(af||(af={}));const sf={};function of(e){return sf[e]}function uf(e,t,n,r,a){const i=t.inputParams[e];if(i&&void 0!==i.inputIndexStart){const e=i.inputIndexStart,s=0===i.inputIndexEnd?void 0:void 0===i.inputIndexEnd?e+1:i.inputIndexEnd;if("tensor"===i.type)return lf(t.inputNames[i.inputIndexStart],n,r,a);if("tensors"===i.type)return t.inputNames.slice(e,s).map((e=>lf(e,n,r,a)));const o=lf(t.inputNames.slice(e)[0],n,r,a),u=o.dataSync();return"number"===i.type?u[0]:Tt(o.shape,u)}const s=t.attrParams[e];return s&&s.value}function lf(e,t,n,r){const[a,i]=pf(e);if(null!=r){const e=r.getHashTableHandleByName(a);if(null!=e)return e}const s=n.currentContextIds.find((e=>!!t[hf(a,e)]));return void 0!==s?t[hf(a,s)][i]:void 0}function cf(e,t){const[n,r,a]=pf(e);return[hf(n,t&&t.currentContextId),r,a]}function hf(e,t){return t?`${e}-${t}`:e}function pf(e){const t=e.split(":");if(1===t.length)return[e,0,void 0];const n=t[0],r=3===t.length?t[1]:void 0;return[n,Number(t[t.length-1]),r]}function df(e,t,n){let r=uf("pad",e,t,n);if("explicit"===r){r=uf("explicitPaddings",e,t,n);const a=[[0,0],[0,0],[0,0],[0,0]];for(let e=0;e<4;e++)a[e][0]=r[2*e],a[e][1]=r[2*e+1];return a}return r}function ff(e){return e.kept?e:Vu(e)}var mf=Object.freeze({__proto__:null,json:[{tfOpName:"Add",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddV2",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AddN",category:"arithmetic",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"BiasAdd",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"Sub",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"RealDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Div",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"DivNoNan",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorDiv",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mul",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Maximum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Minimum",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Pow",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SquaredDifference",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Mod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"FloorMod",category:"arithmetic",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),gf=Object.freeze({__proto__:null,json:[{tfOpName:"Abs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atan2",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Ceil",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ClipByValue",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"clipValueMin",type:"number"},{start:2,name:"clipValueMax",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Complex",category:"basic_math",inputs:[{start:0,name:"real",type:"tensor"},{start:1,name:"imag",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ComplexAbs",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cos",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Cosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Elu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Exp",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Floor",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Imag",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Neg",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Real",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"Tout",name:"outputType",type:"dtype",notSupported:!0}]},{tfOpName:"Prelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"alpha",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Relu6",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Selu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sigmoid",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sin",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Rsqrt",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Square",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Tanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Sign",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Round",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Expm1",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Log1p",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Reciprocal",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Softplus",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Asinh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Acosh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Atanh",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Erf",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Prod",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axes",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LeakyRelu",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"alpha",name:"alpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"IsNan",category:"basic_math",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),yf=Object.freeze({__proto__:null,json:[{tfOpName:"EmptyTensorList",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"maxNumElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"LoopCond",category:"control",inputs:[{start:0,name:"pred",type:"tensor"}]},{tfOpName:"Switch",category:"control",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"pred",type:"tensor"}]},{tfOpName:"Merge",category:"control",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}]},{tfOpName:"Enter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"frame_name",name:"frameName",type:"string"},{tfName:"is_constant",name:"isConstant",type:"bool"}]},{tfOpName:"Exit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NextIteration",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayV3",category:"control",inputs:[{start:0,name:"size",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"dynamic_size",name:"dynamicSize",type:"bool"},{tfName:"clear_after_read",name:"clearAfterRead",type:"bool"},{tfName:"identical_element_shapes",name:"identicalElementShapes",type:"bool"},{tfName:"tensor_array_name",name:"name",type:"string"}]},{tfOpName:"TensorArrayWriteV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayReadV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"TensorArrayGatherV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape",name:"elementShape",type:"shape"}]},{tfOpName:"TensorArrayScatterV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"tensor",type:"tensor"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArrayConcatV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"element_shape_except0",name:"elementShapeExcept0",type:"shape",notSupported:!0}]},{tfOpName:"TensorArraySplitV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"tensor",type:"tensor"},{start:2,name:"lengths",type:"number[]"},{start:3,name:"flowIn",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"TensorArraySizeV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"},{start:1,name:"flowIn",type:"number"}]},{tfOpName:"TensorArrayCloseV3",category:"control",inputs:[{start:0,name:"tensorArrayId",type:"tensor"}]},{tfOpName:"StatelessIf",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"If",category:"control",inputs:[{start:0,name:"cond",type:"tensor"},{start:1,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"then_branch",name:"thenBranch",type:"func"},{tfName:"else_branch",name:"elseBranch",type:"func"}]},{tfOpName:"StatelessWhile",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"While",category:"control",inputs:[{start:0,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"cond",name:"cond",type:"func"},{tfName:"body",name:"body",type:"func"}]},{tfOpName:"TensorListScatter",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListScatterV2",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"},{start:3,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGather",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"indices",type:"number[]"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListGetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListSetItem",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"index",type:"number"},{start:2,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListReserve",category:"control",inputs:[{start:0,name:"elementShape",type:"shape"},{start:1,name:"numElements",type:"number"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListFromTensor",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListStack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"},{tfName:"num_elements",name:"numElements",type:"dtype"}]},{tfOpName:"TensorListSplit",category:"control",inputs:[{start:0,name:"tensor",type:"tensor"},{start:1,name:"elementShape",type:"shape"},{start:2,name:"lengths",type:"number[]"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcat",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListConcatV2",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}],attrs:[{tfName:"element_shape",name:"elementShape",type:"shape"},{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPopBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"elementShape",type:"shape"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListPushBack",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"tensor",type:"tensor"}],attrs:[{tfName:"element_dtype",name:"elementDType",type:"dtype"}]},{tfOpName:"TensorListLength",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"}]},{tfOpName:"TensorListResize",category:"control",inputs:[{start:0,name:"tensorListId",type:"tensor"},{start:1,name:"size",type:"number"}]}]}),bf=Object.freeze({__proto__:null,json:[{tfOpName:"AvgPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[],notSupported:!0},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPoolWithArgmax",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"include_batch_in_index",name:"includeBatchInIndex",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"AvgPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MaxPool3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"ksize",name:"kernelSize",type:"number[]"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Conv1D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"stride",name:"stride",type:"number"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NWC"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"dilation",name:"dilation",type:"number",defaultValue:1}]},{tfOpName:"Conv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"useCudnnOnGpu",name:"useCudnnOnGpu",type:"bool"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"_FusedConv2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"use_cudnn_on_gpu",name:"useCudnnOnGpu",type:"bool",defaultValue:!0},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2}]},{tfOpName:"Conv2DBackpropInput",category:"convolution",inputs:[{start:2,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:0,name:"outputShape",type:"number[]"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]",notSupported:!0}]},{tfOpName:"DepthwiseConv2d",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"DepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"FusedDepthwiseConv2dNative",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]",defaultValue:[1,1,1,1]},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"explicit_paddings",name:"explicitPaddings",type:"number[]",defaultValue:[]}]},{tfOpName:"Conv3D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"padding",name:"pad",type:"string"},{tfName:"data_format",name:"dataFormat",type:"string",defaultValue:"NHWC"},{tfName:"dilations",name:"dilations",type:"number[]"}]},{tfOpName:"Dilation2D",category:"convolution",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"filter",type:"tensor"}],attrs:[{tfName:"strides",name:"strides",type:"number[]"},{tfName:"rates",name:"dilations",type:"number[]"},{tfName:"padding",name:"pad",type:"string"}]}]}),vf=Object.freeze({__proto__:null,json:[{tfOpName:"Fill",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"},{start:1,name:"value",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"LinSpace",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"num",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"OneHot",category:"creation",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"depth",type:"number"},{start:2,name:"onValue",type:"number",defaultValue:1},{start:3,name:"offValue",type:"number",defaultValue:0}],attrs:[{tfName:"axis",name:"axis",type:"number",notSupported:!0},{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Ones",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"OnesLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"RandomStandardNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"RandomUniform",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"minval",name:"minval",type:"number",defaultValue:0},{tfName:"maxval",name:"maxval",type:"number",defaultValue:1},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"seed",name:"seed",type:"number",defaultValue:0},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Range",category:"creation",inputs:[{start:0,name:"start",type:"number"},{start:1,name:"stop",type:"number"},{start:2,name:"step",type:"number",defaultValue:0}],attrs:[{tfName:"Tidx",name:"dtype",type:"dtype"}]},{tfOpName:"TruncatedNormal",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"means",name:"mean",type:"number",defaultValue:0},{tfName:"stddev",name:"stdDev",type:"number",defaultValue:1},{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number",defaultValue:0,notSupported:!0},{tfName:"dtype",name:"dtype",type:"dtype"},{tfName:"T",name:"T",type:"number",notSupported:!0}]},{tfOpName:"Zeros",category:"creation",inputs:[{start:0,name:"shape",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"ZerosLike",category:"creation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype"}]},{tfOpName:"Multinomial",category:"creation",inputs:[{start:0,name:"logits",type:"tensor"},{start:1,name:"numSamples",type:"number"}],attrs:[{tfName:"seed",name:"seed",type:"number"},{tfName:"seed2",name:"seed2",type:"number"},{tfName:"T",name:"dtype",type:"dtype"},{tfName:"output_dtype",name:"output_dtype",type:"dtype"}]}]}),wf=Object.freeze({__proto__:null,json:[{tfOpName:"NonMaxSuppressionV2",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV3",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}]},{tfOpName:"NonMaxSuppressionV4",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0},{tfName:"T_threshold",name:"threshold",type:"dtype",notSupported:!0},{tfName:"pad_to_max_output_size",name:"padToMaxOutputSize",type:"bool"}]},{tfOpName:"NonMaxSuppressionV5",category:"dynamic",inputs:[{start:0,name:"boxes",type:"tensor"},{start:1,name:"scores",type:"tensor"},{start:2,name:"maxOutputSize",type:"number"},{start:3,name:"iouThreshold",type:"number"},{start:4,name:"scoreThreshold",type:"number"},{start:5,name:"softNmsSigma",type:"number"}]},{tfOpName:"Where",category:"dynamic",inputs:[{start:0,name:"condition",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ListDiff",category:"dynamic",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"y",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),_f=Object.freeze({__proto__:null,json:[{tfOpName:"LowerBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"TopKV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"k",type:"number"}],attrs:[{tfName:"sorted",name:"sorted",type:"bool"}]},{tfOpName:"UpperBound",category:"evaluation",inputs:[{start:0,name:"sortedSequence",type:"tensor"},{start:1,name:"values",type:"tensor"}]},{tfOpName:"Unique",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"UniqueV2",category:"evaluation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]}]}),xf=Object.freeze({__proto__:null,json:[{tfOpName:"PlaceholderWithDefault",category:"graph",inputs:[{start:0,name:"default",type:"tensor"}],attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Placeholder",category:"graph",attrs:[{tfName:"shape",name:"shape",type:"shape"},{tfName:"dtype",name:"dtype",type:"dtype"}]},{tfOpName:"Const",category:"graph"},{tfOpName:"Identity",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IdentityN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Snapshot",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Rank",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Size",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"Shape",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"ShapeN",category:"graph",inputs:[{start:0,end:0,name:"x",type:"tensors"}]},{tfOpName:"Print",category:"graph",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"data",type:"tensors"}],attrs:[{tfName:"message",name:"message",type:"string"},{tfName:"first_n",name:"firstN",type:"number",notSupported:!0},{tfName:"summarize",name:"summarize",type:"number",defaultValue:3}]},{tfOpName:"NoOp",category:"graph",inputs:[]},{tfOpName:"StopGradient",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"FakeQuantWithMinMaxVars",category:"graph",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"min",name:"min",type:"number"},{tfName:"max",name:"max",type:"number"}]}]}),kf=Object.freeze({__proto__:null,json:[{tfOpName:"HashTable",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"HashTableV2",category:"hash_table",inputs:[],attrs:[{tfName:"shared_name",name:"sharedName",type:"string"},{tfName:"use_node_name_sharing",name:"useNodeNameSharing",type:"bool"},{tfName:"key_dtype",name:"keyDType",type:"dtype"},{tfName:"value_dtype",name:"valueDType",type:"dtype"}]},{tfOpName:"LookupTableImport",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableImportV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFind",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableFindV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"Tin",name:"tIn",type:"dtype",notSupported:!0},{tfName:"Tout",name:"tOut",type:"dtype",notSupported:!0}]},{tfOpName:"LookupTableSize",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"LookupTableSizeV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"}]},{tfOpName:"InitializeTable",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]},{tfOpName:"InitializeTableV2",category:"hash_table",inputs:[{start:0,name:"tableHandle",type:"tensor"},{start:1,name:"keys",type:"tensor"},{start:2,name:"values",type:"tensor"}]}]}),Tf=Object.freeze({__proto__:null,json:[{tfOpName:"ResizeBilinear",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"ResizeNearestNeighbor",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"size",type:"number[]"}],attrs:[{tfName:"align_corners",name:"alignCorners",type:"bool"},{tfName:"half_pixel_centers",name:"halfPixelCenters",type:"bool"},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"CropAndResize",category:"image",inputs:[{start:0,name:"image",type:"tensor"},{start:1,name:"boxes",type:"tensor"},{start:2,name:"boxInd",type:"tensor"},{start:3,name:"cropSize",type:"number[]"}],attrs:[{tfName:"method",name:"method",type:"string"},{tfName:"extrapolation_value",name:"extrapolationValue",type:"number"}]},{tfOpName:"ImageProjectiveTransformV3",category:"image",inputs:[{start:0,name:"images",type:"tensor"},{start:1,name:"transforms",type:"tensor"},{start:2,name:"outputShape",type:"number[]"},{start:3,name:"fillValue",type:"number"}],attrs:[{tfName:"interpolation",name:"interpolation",type:"string"},{tfName:"fill_mode",name:"fillMode",type:"string"}]}]}),Ef=Object.freeze({__proto__:null,json:[{tfOpName:"Equal",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"NotEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Greater",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"GreaterEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Less",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LessEqual",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalAnd",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalNot",category:"logical",inputs:[{start:0,name:"a",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"LogicalOr",category:"logical",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Select",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SelectV2",category:"logical",inputs:[{start:0,name:"condition",type:"tensor"},{start:1,name:"a",type:"tensor"},{start:2,name:"b",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]}]}),Sf=Object.freeze({__proto__:null,json:[{tfOpName:"_FusedMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"},{start:2,end:0,name:"args",type:"tensors"}],attrs:[{tfName:"num_args",name:"numArgs",type:"number"},{tfName:"fused_ops",name:"fusedOps",type:"string[]",defaultValue:[]},{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:1e-4},{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"leakyrelu_alpha",name:"leakyreluAlpha",type:"number",defaultValue:.2},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"MatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"transpose_a",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"transpose_b",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMul",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"BatchMatMulV2",category:"matrices",inputs:[{start:0,name:"a",type:"tensor"},{start:1,name:"b",type:"tensor"}],attrs:[{tfName:"adj_x",name:"transposeA",type:"bool",defaultValue:!1},{tfName:"adj_y",name:"transposeB",type:"bool",defaultValue:!1},{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Transpose",category:"matrices",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"perm",type:"number[]"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"Einsum",category:"matrices",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"equation",name:"equation",type:"string"},{tfName:"N",name:"n",type:"number",defaultValue:2},{tfName:"T",name:"dtype",type:"dtype"}]}]}),If=Object.freeze({__proto__:null,json:[{tfOpName:"EuclideanNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool",defaultValue:!1}]},{tfOpName:"FusedBatchNorm",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV2",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"FusedBatchNormV3",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"scale",type:"tensor"},{start:2,name:"offset",type:"tensor"},{start:3,name:"mean",type:"tensor"},{start:4,name:"variance",type:"tensor"}],attrs:[{tfName:"epsilon",name:"epsilon",type:"number",defaultValue:.001},{tfName:"data_format",name:"dataFormat",type:"string",notSupported:!0}]},{tfOpName:"LRN",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"depth_radius",name:"radius",type:"number",defaultValue:5},{tfName:"bias",name:"bias",type:"number",defaultValue:1},{tfName:"alpha",name:"alpha",type:"number",defaultValue:1},{tfName:"beta",name:"beta",type:"number",defaultValue:.5}]},{tfOpName:"Softmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"LogSoftmax",category:"normalization",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"SparseToDense",category:"normalization",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!0,notSupported:!0}]}]}),Af=Object.freeze({__proto__:null,json:[{tfOpName:"Bincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}]},{tfOpName:"DenseBincount",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"size",type:"number"},{start:2,name:"weights",type:"tensor"}],attrs:[{tfName:"binary_output",name:"binaryOutput",type:"bool"}]},{tfOpName:"Max",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Mean",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Min",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Sum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"All",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Any",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"ArgMax",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"ArgMin",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"Prod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}],attrs:[{tfName:"keep_dims",name:"keepDims",type:"bool"}]},{tfOpName:"Cumprod",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]},{tfOpName:"Cumsum",category:"reduction",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}],attrs:[{tfName:"exclusive",name:"exclusive",type:"bool"},{tfName:"reverse",name:"reverse",type:"bool"}]}]}),Cf=Object.freeze({__proto__:null,json:[{tfOpName:"ConcatV2",category:"slice_join",inputs:[{start:0,end:-1,name:"tensors",type:"tensors"},{start:-1,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"Concat",category:"slice_join",inputs:[{start:1,end:0,name:"tensors",type:"tensors"},{start:0,name:"axis",type:"number"}],attrs:[{tfName:"N",name:"n",type:"number",defaultValue:2}]},{tfOpName:"GatherV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"axis",type:"number",defaultValue:0}],attrs:[{tfName:"batch_dims",name:"batchDims",type:"number",defaultValue:0}]},{tfOpName:"Gather",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",notSupported:!0}]},{tfOpName:"Reverse",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"dims",type:"bool[]"}]},{tfOpName:"ReverseV2",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number[]"}]},{tfOpName:"Slice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"size",type:"number[]"}]},{tfOpName:"StridedSlice",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"begin",type:"number[]"},{start:2,name:"end",type:"number[]"},{start:3,name:"strides",type:"number[]"}],attrs:[{tfName:"begin_mask",name:"beginMask",type:"number",defaultValue:0},{tfName:"end_mask",name:"endMask",type:"number",defaultValue:0},{tfName:"new_axis_mask",name:"newAxisMask",type:"number",defaultValue:0},{tfName:"ellipsis_mask",name:"ellipsisMask",type:"number",defaultValue:0},{tfName:"shrink_axis_mask",name:"shrinkAxisMask",type:"number",defaultValue:0}]},{tfOpName:"Pack",category:"slice_join",inputs:[{start:0,end:0,name:"tensors",type:"tensors"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0}]},{tfOpName:"Unpack",category:"slice_join",inputs:[{start:0,name:"tensor",type:"tensor"}],attrs:[{tfName:"axis",name:"axis",type:"number",defaultValue:0},{tfName:"num",name:"num",type:"number",defaultValue:0,notSupported:!0}]},{tfOpName:"Tile",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"reps",type:"number[]"}]},{tfOpName:"Split",category:"slice_join",inputs:[{start:0,name:"axis",type:"number",defaultValue:0},{start:1,name:"x",type:"tensor"}],attrs:[{tfName:"num_split",name:"numOrSizeSplits",type:"number",defaultValue:1}]},{tfOpName:"SplitV",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"numOrSizeSplits",type:"number[]"},{start:2,name:"axis",type:"number",defaultValue:0}]},{tfOpName:"ScatterNd",category:"slice_join",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"shape",type:"number[]"}]},{tfOpName:"GatherNd",category:"slice_join",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"indices",type:"tensor"}]},{tfOpName:"SparseToDense",category:"slice_join",inputs:[{start:0,name:"sparseIndices",type:"tensor"},{start:1,name:"outputShape",type:"number[]"},{start:2,name:"sparseValues",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}],attrs:[{tfName:"validate_indices",name:"validateIndices",type:"bool",defaultValue:!1,notSupported:!0}]}]}),Nf=Object.freeze({__proto__:null,json:[{tfOpName:"SparseFillEmptyRows",category:"sparse",inputs:[{start:0,name:"indices",type:"tensor"},{start:1,name:"values",type:"tensor"},{start:2,name:"denseShape",type:"tensor"},{start:3,name:"defaultValue",type:"tensor"}]},{tfOpName:"SparseReshape",category:"sparse",inputs:[{start:0,name:"inputIndices",type:"tensor"},{start:1,name:"inputShape",type:"tensor"},{start:2,name:"newShape",type:"tensor"}],attrs:[{tfName:"T",name:"dtype",type:"dtype",notSupported:!0}]},{tfOpName:"SparseSegmentMean",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]},{tfOpName:"SparseSegmentSum",category:"sparse",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"indices",type:"tensor"},{start:2,name:"segmentIds",type:"tensor"}]}]}),Rf=Object.freeze({__proto__:null,json:[{tfOpName:"FFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"IFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"}]},{tfOpName:"RFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]},{tfOpName:"IRFFT",category:"spectral",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"fft_length",type:"number",notSupported:!0}]}]}),Ff=Object.freeze({__proto__:null,json:[{tfOpName:"StringNGrams",category:"string",inputs:[{start:0,name:"data",type:"tensor"},{start:1,name:"dataSplits",type:"tensor"}],attrs:[{tfName:"separator",name:"separator",type:"string"},{tfName:"ngram_widths",name:"nGramWidths",type:"number[]"},{tfName:"left_pad",name:"leftPad",type:"string"},{tfName:"right_pad",name:"rightPad",type:"string"},{tfName:"pad_width",name:"padWidth",type:"number"},{tfName:"preserve_short_sequences",name:"preserveShortSequences",type:"bool"}],outputs:["ngrams","ngrams_splits"]},{tfOpName:"StringSplit",category:"string",inputs:[{start:0,name:"input",type:"tensor"},{start:1,name:"delimiter",type:"tensor"}],attrs:[{tfName:"skip_empty",name:"skipEmpty",type:"bool"}],outputs:["indices","values","shape"]},{tfOpName:"StringToHashBucketFast",category:"string",inputs:[{start:0,name:"input",type:"tensor"}],attrs:[{tfName:"num_buckets",name:"numBuckets",type:"number"}]}]}),Of=Object.freeze({__proto__:null,json:[{tfOpName:"Cast",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"SrcT",name:"sdtype",type:"dtype",notSupported:!0},{tfName:"DstT",name:"dtype",type:"dtype"}]},{tfOpName:"ExpandDims",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"axis",type:"number"}]},{tfOpName:"MirrorPad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"mode",name:"mode",type:"string"}]},{tfOpName:"Pad",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"}],attrs:[{tfName:"constant_value",name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"PadV2",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"padding",type:"number[]"},{start:2,name:"constantValue",type:"number",defaultValue:0}]},{tfOpName:"Reshape",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}]},{tfOpName:"Squeeze",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"axis",tfDeprecatedName:"squeeze_dims",name:"axis",type:"number[]"}]},{tfOpName:"SpaceToBatchND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"paddings",type:"number[]"}]},{tfOpName:"BatchToSpaceND",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"blockShape",type:"number[]"},{start:2,name:"crops",type:"number[]"}]},{tfOpName:"DepthToSpace",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"}],attrs:[{tfName:"block_size",name:"blockSize",type:"number"},{tfName:"data_format",name:"dataFormat",type:"string"}]},{tfOpName:"BroadcastTo",category:"transformation",inputs:[{start:0,name:"x",type:"tensor"},{start:1,name:"shape",type:"number[]"}],attrs:[]},{tfOpName:"BroadcastArgs",category:"transformation",inputs:[{start:0,name:"s0",type:"tensor"},{start:1,name:"s1",type:"tensor"}],attrs:[]}]});class Mf{constructor(){const e=[].concat(...[mf,gf,yf,bf,vf,wf,_f,xf,kf,Tf,Ef,Sf,If,Af,Cf,Nf,Rf,Ff,Of].map((e=>e.json)));this.opMappers=e.reduce(((e,t)=>(e[t.tfOpName]=t,e)),{})}static get Instance(){return this._instance||(this._instance=new this)}transformGraph(e,t={}){const n=e.node,r=[],a=[],i=[],s=n.reduce(((e,t)=>(e[t.name]=this.mapNode(t),t.op.startsWith("Placeholder")?r.push(e[t.name]):"Const"===t.op?a.push(e[t.name]):null!=t.input&&0!==t.input.length||i.push(e[t.name]),e)),{});let o=[];const u=[];let l={},c={};null!=t&&(l=this.mapSignatureEntries(t.inputs),c=this.mapSignatureEntries(t.outputs));const h=Object.keys(s);h.forEach((e=>{const t=s[e];t.inputNames.forEach(((e,n)=>{const[r,,a]=cf(e),i=s[r];if(null!=i.outputs){const e=i.outputs.indexOf(a);if(-1!==e){const a=`${r}:${e}`;t.inputNames[n]=a}}t.inputs.push(i),i.children.push(t)}))})),0===Object.keys(c).length?h.forEach((e=>{const t=s[e];0===t.children.length&&u.push(t)})):Object.keys(c).forEach((e=>{const[t]=cf(e),n=s[t];null!=n&&(n.signatureKey=c[e],u.push(n))})),Object.keys(l).length>0?Object.keys(l).forEach((e=>{const[t]=cf(e),n=s[t];n&&(n.signatureKey=l[e],o.push(n))})):o=r;let p={};null!=e.library&&null!=e.library.function&&(p=e.library.function.reduce(((e,t)=>(e[t.signature.name]=this.mapFunction(t),e)),{}));const d={nodes:s,inputs:o,outputs:u,weights:a,placeholders:r,signature:t,functions:p};return i.length>0&&(d.initNodes=i),d}mapSignatureEntries(e){return Object.keys(e||{}).reduce(((t,n)=>(t[e[n].name]=n,t)),{})}mapNode(e){const t=of(e.op)||this.opMappers[e.op]||{};null==e.attr&&(e.attr={});const n={name:e.name,op:e.op,category:t.category,inputNames:(e.input||[]).map((e=>e.startsWith("^")?e.slice(1):e)),inputs:[],children:[],inputParams:{},attrParams:{},rawAttrs:e.attr,outputs:t.outputs};return null!=t.inputs&&(n.inputParams=t.inputs.reduce(((e,t)=>(e[t.name]={type:t.type,inputIndexStart:t.start,inputIndexEnd:t.end},e)),{})),null!=t.attrs&&(n.attrParams=t.attrs.reduce(((t,n)=>{const r=n.type;let a;switch(n.type){case"string":a=Df(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Df(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"string[]":a=Hf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Hf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number":a=Lf(e.attr,n.tfName,n.defaultValue||0),void 0===a&&n.tfDeprecatedName&&(a=Lf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"number[]":a=Gf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Gf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool":a=Pf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Pf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"bool[]":a=qf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=qf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape":a=jf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=jf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"shape[]":a=Kf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Kf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype":a=Wf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Wf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"dtype[]":a=Vf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Vf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"func":a=Uf(e.attr,n.tfName,n.defaultValue),void 0===a&&n.tfDeprecatedName&&(a=Uf(e.attr,n.tfDeprecatedName,n.defaultValue));break;case"tensor":case"tensors":break;default:throw new Error(`Unsupported param type: ${n.type} for op: ${e.op}`)}return t[n.name]={value:a,type:r},t}),{})),n}mapFunction(e){const t=e.nodeDef,n=[];let r={};null!=t&&(r=t.reduce(((e,t)=>(e[t.name]=this.mapNode(t),"Const"===t.op&&n.push(e[t.name]),e)),{}));const a=[],i=[];e.signature.inputArg.forEach((e=>{const[t]=cf(e.name),n={name:t,op:"Placeholder",inputs:[],inputNames:[],category:"graph",inputParams:{},attrParams:{dtype:{value:Bf(e.type),type:"dtype"}},children:[]};n.signatureKey=e.name,a.push(n),r[t]=n})),Object.keys(r).forEach((e=>{const t=r[e];t.inputNames.forEach(((e,n)=>{const[a,,i]=cf(e),s=r[a];if(null!=s.outputs){const e=s.outputs.indexOf(i);if(-1!==e){const r=`${a}:${e}`;t.inputNames[n]=r}}t.inputs.push(s),s.children.push(t)}))}));const s=e.ret;e.signature.outputArg.forEach((e=>{const[t,n]=cf(s[e.name]),a=r[t];null!=a&&(a.defaultOutput=n,i.push(a))}));const o=this.mapArgsToSignature(e);return{nodes:r,inputs:a,outputs:i,weights:n,placeholders:[],signature:o}}mapArgsToSignature(e){return{methodName:e.signature.name,inputs:e.signature.inputArg.reduce(((e,t)=>(e[t.name]=this.mapArgToTensorInfo(t),e)),{}),outputs:e.signature.outputArg.reduce(((t,n)=>(t[n.name]=this.mapArgToTensorInfo(n,e.ret),t)),{})}}mapArgToTensorInfo(e,t){let n=e.name;return null!=t&&(n=t[n]),{name:n,dtype:e.type}}}function $f(e,t){const n=Array.isArray(e)?String.fromCharCode.apply(null,e):function(e){const t=Mt().global;if(void 0!==t.atob)return t.atob(e);if(void 0!==Ii)return new Ii(e,"base64").toString();throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()")}(e);return t?n:n.toLowerCase()}function Df(e,t,n,r=!1){const a=e[t];return null!=a?$f(a.s,r):n}function Pf(e,t,n){const r=e[t];return r?r.b:n}function Lf(e,t,n){const r=e[t]||{},a=null!=r.i?r.i:null!=r.f?r.f:n;return"number"==typeof a?a:parseInt(a,10)}function Bf(e){switch("string"==typeof e&&(e=rf[e]),e){case rf.DT_FLOAT:case rf.DT_HALF:return"float32";case rf.DT_INT32:case rf.DT_INT64:case rf.DT_INT8:case rf.DT_UINT8:return"int32";case rf.DT_BOOL:return"bool";case rf.DT_DOUBLE:return"float32";case rf.DT_STRING:return"string";default:return null}}function Uf(e,t,n){const r=e[t];return r&&r.func?r.func.name:n}function Wf(e,t,n){const r=e[t];return r&&r.type?Bf(r.type):n}function Vf(e,t,n){const r=e[t];return r&&r.list&&r.list.type?r.list.type.map((e=>Bf(e))):n}function zf(e){if(!e.unknownRank)return null!=e.dim?e.dim.map((e=>"number"==typeof e.size?e.size:parseInt(e.size,10))):[]}function jf(e,t,n){const r=e[t];return r&&r.shape?zf(r.shape):n}function Gf(e,t,n){const r=e[t];return r?((r.list.f&&r.list.f.length?r.list.f:r.list.i)||[]).map((e=>"number"==typeof e?e:parseInt(e,10))):n}function Hf(e,t,n,r=!1){const a=e[t];return a&&a.list&&a.list.s?a.list.s.map((e=>$f(e,r))):n}function Kf(e,t,n){const r=e[t];return r&&r.list&&r.list.shape?r.list.shape.map((e=>zf(e))):n}function qf(e,t,n){const r=e[t];return r&&r.list&&r.list.b?r.list.b:n}class Xf{constructor(e,t,n){this.node=e,this.tensorMap=t,this.context=n,this.inputs=[],this.attrs={},this.inputs=e.inputNames.map((e=>this.getInput(e))),null!=e.rawAttrs&&(this.attrs=Object.keys(e.rawAttrs).reduce(((e,t)=>(e[t]=this.getAttr(t),e)),{}))}getInput(e){return lf(e,this.tensorMap,this.context)}getAttr(e,t){const n=this.node.rawAttrs[e];if(null!=n.tensor)return lf(e,this.tensorMap,this.context);if(null!=n.i||null!=n.f)return Lf(this.node.rawAttrs,e,t);if(null!=n.s)return Df(this.node.rawAttrs,e,t);if(null!=n.b)return Pf(this.node.rawAttrs,e,t);if(null!=n.shape)return jf(this.node.rawAttrs,e,t);if(null!=n.type)return Wf(this.node.rawAttrs,e,t);if(null!=n.list){if(null!=n.list.i||null!=n.list.f)return Gf(this.node.rawAttrs,e,t);if(null!=n.list.s)return Hf(this.node.rawAttrs,e,t);if(null!=n.list.shape)return Kf(this.node.rawAttrs,e,t);if(null!=n.list.b)return qf(this.node.rawAttrs,e,t);if(null!=n.list.type)return Vf(this.node.rawAttrs,e,t)}return t}}var Yf=Object.freeze({__proto__:null,abs:du,acos:fu,acosh:mu,add:lu,addN:gu,all:yu,any:bu,argMax:vu,argMin:wu,asin:_u,asinh:xu,atan:ku,atan2:Tu,atanh:Eu,avgPool:Uu,avgPool3d:Wu,basicLSTMCell:Ku,batchToSpaceND:qu,batchNorm:Xu,batchNorm2d:Yu,batchNorm3d:Qu,batchNorm4d:Ju,bincount:Zu,broadcastArgs:el,broadcastTo:tl,buffer:nl,cast:ko,ceil:rl,clipByValue:il,clone:Vu,complex:bs,concat:zu,concat1d:sl,concat2d:ol,concat3d:ul,concat4d:ll,conv1d:hl,conv2d:cl,conv2dTranspose:dl,conv3d:fl,conv3dTranspose:gl,cos:yl,cosh:bl,cumprod:vl,cumsum:wl,denseBincount:_l,depthToSpace:xl,depthwiseConv2d:kl,diag:Tl,dilation2d:El,div:hu,divNoNan:Cl,dot:Nl,einsum:Rl,elu:Fl,equal:Sl,erf:Ol,euclideanNorm:Ql,exp:Jl,expandDims:Zl,expm1:ec,eye:nc,fill:al,floor:rc,floorDiv:cu,gather:ac,greater:ic,greaterEqual:sc,imag:Oo,isFinite:oc,isInf:uc,isNaN:lc,leakyRelu:cc,less:hc,lessEqual:pc,linspace:function(e,t,n){if(n<=0)throw new Error("The number of values should be positive.");const r={start:e,stop:t,num:n};return li.runKernel("LinSpace",{},r)},localResponseNormalization:dc,log:fc,log1p:mc,logSigmoid:bc,logSoftmax:wc,logSumExp:_c,logicalAnd:xc,logicalNot:kc,logicalOr:Tc,logicalXor:Ec,lowerBound:function(e,t){return Ic(e,t,"left")},matMul:To,max:Vl,maxPool:Ac,maxPool3d:Cc,maxPoolWithArgmax:Nc,maximum:Rc,mean:Fc,meshgrid:function(e,t,{indexing:n="xy"}={}){if("xy"!==n&&"ij"!==n)throw new TypeError(`${n} is not a valid third argument to meshgrid`);if(void 0===e)return[];let r=fs(e,"x","meshgrid",e instanceof Ka?e.dtype:"float32");if(void 0===t)return[r];let a=fs(t,"y","meshgrid",t instanceof Ka?t.dtype:"float32");const i=it(r.shape),s=it(a.shape);return"xy"===n?(r=Bu(r,[1,-1]),a=Bu(a,[-1,1]),[To(Mc([s,1],r.dtype),r),To(a,Mc([1,i],a.dtype))]):(r=Bu(r,[-1,1]),a=Bu(a,[1,-1]),[To(r,Mc([1,s],r.dtype)),To(Mc([i,1],a.dtype),a)])},min:zl,minimum:$c,mirrorPad:Dc,mod:Pc,moments:Lc,mul:pu,multiRNNCell:Bc,multinomial:Uc,neg:Mo,notEqual:Wc,oneHot:Eo,ones:Mc,onesLike:Vc,outerProduct:zc,pad:jc,pad1d:Gc,pad2d:Hc,pad3d:Kc,pad4d:qc,pool:Yc,pow:jl,prelu:Qc,print:Jc,prod:Zc,raggedGather:eh,raggedRange:th,raggedTensorToTensor:nh,rand:rh,randomGamma:bh,randomNormal:vh,randomStandardNormal:wh,randomUniform:_h,range:xh,real:$o,reciprocal:kh,relu:Th,relu6:Eh,reshape:Bu,reverse:Sh,reverse1d:Ih,reverse2d:Ah,reverse3d:Ch,reverse4d:Nh,round:Rh,rsqrt:Fh,scalar:Gl,selu:Oh,separableConv2d:Mh,setdiff1dAsync:async function(e,t){const n=fs(e,"x","setdiff1d"),r=fs(t,"y","setdiff1d");nt(n.dtype===r.dtype,(()=>`x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`)),nt(1===n.rank,(()=>`x should be 1D tensor, but got x (${n.shape}).`)),nt(1===r.rank,(()=>`y should be 1D tensor, but got y (${r.shape}).`));const a=await n.data(),i=await r.data(),s=new Set(i);let o=0;for(let e=0;e<a.length;e++)s.has(a[e])||o++;const u=new ja([o],n.dtype),l=new ja([o],"int32");for(let e=0,t=0;e<a.length;e++)s.has(a[e])||(u.values[t]=a[e],l.values[t]=e,t++);return[u.toTensor(),l.toTensor()]},sigmoid:ju,sign:$h,sin:Dh,sinh:Ph,slice:Gu,slice1d:Lh,slice2d:Bh,slice3d:Uh,slice4d:Wh,softmax:Vh,softplus:yc,spaceToBatchND:Xc,fft:zh,ifft:jh,irfft:Gh,rfft:Kh,split:Hh,sqrt:Hl,square:Kl,squaredDifference:qh,squeeze:Xh,stack:Yh,step:Qh,stridedSlice:Jh,sub:vc,sum:ql,tan:Zh,tanh:Hu,tensor:ws,tensor1d:ep,tensor2d:tp,tensor3d:Uo,tensor4d:function(e,t,n){if(at(e),null!=t&&4!==t.length)throw new Error("tensor4d() requires shape to have four numbers");const r=hs(e,n);if(4!==r.length&&1!==r.length)throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");return vs(e,t,r,n)},tensor5d:function(e,t,n){if(at(e),null!=t&&5!==t.length)throw new Error("tensor5d() requires shape to have five numbers");const r=hs(e,n);if(5!==r.length&&1!==r.length)throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor5d() requires shape to be provided when `values` are a flat array");return vs(e,t,r,n)},tensor6d:function(e,t,n){if(at(e),null!=t&&6!==t.length)throw new Error("tensor6d() requires shape to have six numbers");const r=hs(e,n);if(6!==r.length&&1!==r.length)throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray");if(1===r.length&&null==t)throw new Error("tensor6d() requires shape to be provided when `values` are a flat array");return vs(e,t=t||r,r,n)},tile:tc,topk:np,truncatedNormal:rp,unique:ap,unsortedSegmentSum:ip,unstack:sp,upperBound:function(e,t){return Ic(e,t,"right")},variable:function(e,t=!0,n,r){return li.makeVariable(e,t,n,r)},where:Il,whereAsync:up,zeros:Oc,zerosLike:Al,op:ys,OP_SCOPE_SUFFIX:gs,booleanMaskAsync:async function(e,t,n){const r=fs(e,"tensor","boolMask"),a=fs(t,"mask","boolMask","bool"),i=null==n?0:n,s=a.rank,o=r.shape;nt(s>0,(()=>"mask cannot be scalar")),rt(o.slice(i,i+s),a.shape,"mask's shape must match the first K dimensions of tensor's shape,");let u=1;for(let e=i;e<i+s;e++)u*=o[e];const l=o.slice(0,i).concat([u],o.slice(i+s)),c=Bu(r,l),h=Bu(a,[-1]),p=await up(h),d=Xh(p,[1]),f=ac(c,d,i);return e!==r&&r.dispose(),t!==a&&a.dispose(),d.dispose(),c.dispose(),h.dispose(),p.dispose(),f},transpose:Do,norm:Yl,movingAverage:lp,scatterND:cp,searchSorted:Ic,sparseToDense:hp,gatherND:pp,dropout:dp,enclosingPowerOfTwo:fp,cosineWindow:mp,inTopKAsync:async function(e,t,n=1){const r=fs(e,"predictions","inTopK"),a=fs(t,"targets","inTopK");nt(r.rank>1,(()=>`inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`)),nt(r.rank-1===a.rank,(()=>`predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${a.rank}`)),rt(r.shape.slice(0,r.shape.length-1),a.shape,"predictions's shape should be align with the targets' shape, except the last dimension.");const i=r.shape[r.shape.length-1];nt(n>0&&n<=i,(()=>`'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${i}), but got ${n}`));const s=await r.data(),o=await a.data(),[u,l]=[s.length/i,i],c=ft("bool",u);for(let e=0;e<u;e++){const t=e*l,r=s.subarray(t,t+l),a=[];for(let e=0;e<r.length;e++)a.push({value:r[e],index:e});a.sort(((e,t)=>t.value-e.value)),c[e]=0;for(let t=0;t<n;t++)if(a[t].index===o[e]){c[e]=1;break}}return e!==r&&r.dispose(),t!==a&&a.dispose(),ws(c,a.shape,"bool")},image:gd,linalg:yd,losses:bd,spectral:fd,fused:Sp,signal:md,sparse:vd,string:wd});function Qf(e,t,n=""){if("number"!=typeof e&&"number"!=typeof t){nt(e.length===t.length,(()=>n+` Shapes ${e} and ${t} must match`));for(let r=0;r<e.length;r++){const a=e[r],i=t[r];nt(a<0||i<0||a===i,(()=>n+` Shapes ${e} and ${t} must match`))}}}function Jf(e){return"number"!=typeof e&&!e.some((e=>e<0))}function Zf(e,t,n){let r=em(e,n);const a=!Jf(r);if(a&&0===t.length)throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`);if(a&&t.forEach((e=>{r=em(e.shape,r)})),!Jf(r))throw new Error(`Non-fully-defined elementShape: ${r}`);return r}function em(e,t){if("number"==typeof e)return t;if("number"==typeof t)return e;if(e.length!==t.length)throw new Error(`Incompatible ranks during merge: ${e} vs. ${t}`);const n=[];for(let r=0;r<e.length;++r){const a=e[r],i=t[r];if(a>=0&&i>=0&&a!==i)throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`);n[r]=a>=0?a:i}return n}class tm{constructor(e,t,n,r,a,i,s){this.name=e,this.dtype=t,this.maxSize=n,this.elementShape=r,this.identicalElementShapes=a,this.dynamicSize=i,this.clearAfterRead=s,this.tensors=[],this.closed_=!1,this.idTensor=Gl(0),Co(this.idTensor)}get id(){return this.idTensor.id}get closed(){return this.closed_}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.tensor.id)||t.tensor.dispose()})),this.tensors=[],this.closed_=!0,this.idTensor.dispose()}size(){return this.tensors.length}read(e){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||e>=this.size())throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`);const t=this.tensors[e];if(t.cleared)throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`);return this.clearAfterRead&&(t.cleared=!0),t.read=!0,t.tensor}readMany(e){return e.map((e=>this.read(e)))}write(e,t){if(this.closed_)throw new Error(`TensorArray ${this.name} has already been closed.`);if(e<0||!this.dynamicSize&&e>=this.maxSize)throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`);const n=this.tensors[e]||{};if(t.dtype!==this.dtype)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},\n because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`);if(0!==this.size()||null!=this.elementShape&&0!==this.elementShape.length||(this.elementShape=t.shape),Qf(this.elementShape,t.shape,`TensorArray ${this.name}: Could not write to TensorArray index ${e}.`),n.read)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`);if(n.written)throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`);n.tensor=t,Co(t),n.written=!0,this.tensors[e]=n}writeMany(e,t){if(e.length!==t.length)throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`);e.forEach(((e,n)=>this.write(e,t[n])))}gather(e,t){if(t&&t!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`);if(e)e=e.slice(0,this.size());else{e=[];for(let t=0;t<this.size();t++)e.push(t)}if(0===e.length)return ws([],[0].concat(this.elementShape));const n=this.readMany(e);return Qf(this.elementShape,n[0].shape,"TensorArray shape mismatch: "),Yh(n,0)}concat(e){if(e&&e!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${e}`);if(0===this.size())return ws([],[0].concat(this.elementShape));const t=[];for(let e=0;e<this.size();e++)t.push(e);const n=this.readMany(t);return Qf(this.elementShape,n[0].shape,`TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`),zu(n,0)}scatter(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);if(e.length!==t.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t.shape[0]}`);const n=Math.max(...e);if(!this.dynamicSize&&n>=this.maxSize)throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`);this.writeMany(e,sp(t,0))}split(e,t){if(t.dtype!==this.dtype)throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`);let n=0;const r=e.map((e=>(n+=e,n)));if(n!==t.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${n}, and tensor's shape is: ${t.shape}`);if(!this.dynamicSize&&e.length!==this.maxSize)throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`);const a=0===n?0:t.size/n,i=[];Io((()=>{t=Bu(t,[1,n,a]);for(let n=0;n<e.length;++n){const s=[0,0===n?0:r[n-1],0],o=[1,e[n],a];i[n]=Bu(Gu(t,s,o),this.elementShape)}return i}));const s=[];for(let t=0;t<e.length;t++)s[t]=t;this.writeMany(s,i)}}class nm{constructor(e,t,n,r=-1){this.tensors=e,this.elementShape=t,this.elementDtype=n,null!=e&&e.forEach((e=>{if(n!==e.dtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${e.dtype}`);Qf(t,e.shape,"TensorList shape mismatch: "),Co(e)})),this.idTensor=Gl(0),this.maxNumElements=r,Co(this.idTensor)}get id(){return this.idTensor.id}copy(){return new nm([...this.tensors],this.elementShape,this.elementDtype)}clearAndClose(e){this.tensors.forEach((t=>{null!=e&&e.has(t.id)||t.dispose()})),this.tensors.length=0,this.idTensor.dispose()}size(){return this.tensors.length}stack(e,t,n=-1){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(-1!==n&&this.tensors.length!==n)throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`);Qf(e,this.elementShape,"TensorList shape mismatch: ");const r=Zf(this.elementShape,this.tensors,e);return Io((()=>{const e=this.tensors.map((e=>Bu(e,r)));return Yh(e,0)}))}popBack(e,t){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);if(0===this.size())throw new Error("Trying to pop from an empty list.");const n=Zf(this.elementShape,this.tensors,e),r=this.tensors.pop();return r.kept=!1,Qf(r.shape,e,"TensorList shape mismatch: "),Bu(r,n)}pushBack(e){if(e.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`);if(Qf(e.shape,this.elementShape,"TensorList shape mismatch: "),this.maxNumElements===this.size())throw new Error("Trying to push element into a full list.");Co(e),this.tensors.push(e)}resize(e){if(e<0)throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`);if(-1!==this.maxNumElements&&e>this.maxNumElements)throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`);const t=new nm([],this.elementShape,this.elementDtype,this.maxNumElements);t.tensors.length=e;for(let n=0;n<Math.min(this.tensors.length,e);++n)t.tensors[n]=this.tensors[n];return t}getItem(e,t,n){if(n!==this.elementDtype)throw new Error(`Invalid data types; op elements ${n}, but list elements ${this.elementDtype}`);if(e<0||e>this.tensors.length)throw new Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`);if(null==this.tensors[e])throw new Error(`element at index ${e} is null.`);Qf(this.tensors[e].shape,t,"TensorList shape mismatch: ");const r=Zf(this.elementShape,this.tensors,t);return Bu(this.tensors[e],r)}setItem(e,t){if(t.dtype!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`);if(e<0||-1!==this.maxNumElements&&e>=this.maxNumElements)throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`);Qf(this.elementShape,t.shape,"TensorList shape mismatch: "),Co(t),null!=this.tensors[e]&&(this.tensors[e].kept=!1),this.tensors[e]=t}gather(e,t,n){if(t!==this.elementDtype)throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`);Qf(this.elementShape,n,"TensorList shape mismatch: "),e=e.slice(0,this.size());const r=Zf(this.elementShape,this.tensors,n);return 0===e.length?ws([],[0].concat(r)):Io((()=>{const t=e.map((e=>Bu(this.tensors[e],r)));return Yh(t,0)}))}concat(e,t){if(e&&e!==this.elementDtype)throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`);Qf(this.elementShape,t,"TensorList shape mismatch: ");const n=Zf(this.elementShape,this.tensors,t);return 0===this.size()?ws([],[0].concat(n)):Io((()=>{const e=this.tensors.map((e=>Bu(e,n)));return zu(e,0)}))}}function rm(e,t,n){const[r,a]=uf("fusedOps",e,t,n),i="biasadd"===r,s=!i,o="prelu"===a,u="fusedbatchnorm"===r,l=uf("numArgs",e,t,n);if(i){if(o&&2!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&i&&1!==l)throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.")}if(u)throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported");const c=uf("strides",e,t,n),h=df(e,t,n),p=uf("dataFormat",e,t,n).toUpperCase(),d=uf("dilations",e,t,n);let[f,m]=uf("args",e,t,n);return s&&(m=f,f=void 0),{stride:c,pad:h,dataFormat:p,dilations:d,biasArg:f,preluArg:m,activationFunc:a,leakyreluAlpha:uf("leakyreluAlpha",e,t,n)}}function am(e,t,n){return{boxes:uf("boxes",e,t,n),scores:uf("scores",e,t,n),maxOutputSize:uf("maxOutputSize",e,t,n),iouThreshold:uf("iouThreshold",e,t,n),scoreThreshold:uf("scoreThreshold",e,t,n),softNmsSigma:uf("softNmsSigma",e,t,n)}}class im{constructor(e,t){this.keyDType=e,this.valueDType=t,this.handle=Gl(0),this.tensorMap=new Map,Co(this.handle)}get id(){return this.handle.id}clearAndClose(){this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),this.handle.dispose()}size(){return this.tensorMap.size}tensorSize(){return Gl(this.size(),"int32")}async import(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return this.tensorMap.forEach((e=>e.dispose())),this.tensorMap.clear(),Io((()=>{const e=sp(t),r=n.length,a=e.length;nt(r===a,(()=>`The number of elements doesn't match, keys has ${r} elements, the values has ${a} elements.`));for(let t=0;t<r;t++){const r=n[t],a=e[t];Co(a),this.tensorMap.set(r,a)}return this.handle}))}async find(e,t){this.checkKeyAndValueTensor(e,t);const n=await e.data();return Io((()=>{const e=[];for(let r=0;r<n.length;r++){const a=n[r],i=this.findWithDefault(a,t);e.push(i)}return Yh(e)}))}findWithDefault(e,t){const n=this.tensorMap.get(e);return null!=n?n:t}checkKeyAndValueTensor(e,t){if(e.dtype!==this.keyDType)throw new Error(`Expect key dtype ${this.keyDType}, but got ${e.dtype}`);if(t.dtype!==this.valueDType)throw new Error(`Expect value dtype ${this.valueDType}, but got ${t.dtype}`)}}function sm(e,t,n,r,a=Io){const i=((e,t,n)=>{switch(e.category){case"arithmetic":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"BiasAdd":case"AddV2":case"Add":return[r.add(uf("a",e,t,n),uf("b",e,t,n))];case"AddN":return[r.addN(uf("tensors",e,t,n))];case"FloorMod":case"Mod":return[r.mod(uf("a",e,t,n),uf("b",e,t,n))];case"Mul":return[r.mul(uf("a",e,t,n),uf("b",e,t,n))];case"RealDiv":case"Div":return[r.div(uf("a",e,t,n),uf("b",e,t,n))];case"DivNoNan":return[r.divNoNan(uf("a",e,t,n),uf("b",e,t,n))];case"FloorDiv":return[r.floorDiv(uf("a",e,t,n),uf("b",e,t,n))];case"Sub":return[r.sub(uf("a",e,t,n),uf("b",e,t,n))];case"Minimum":return[r.minimum(uf("a",e,t,n),uf("b",e,t,n))];case"Maximum":return[r.maximum(uf("a",e,t,n),uf("b",e,t,n))];case"Pow":return[r.pow(uf("a",e,t,n),uf("b",e,t,n))];case"SquaredDifference":return[r.squaredDifference(uf("a",e,t,n),uf("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"basic_math":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"Abs":case"ComplexAbs":return[r.abs(uf("x",e,t,n))];case"Acos":return[r.acos(uf("x",e,t,n))];case"Acosh":return[r.acosh(uf("x",e,t,n))];case"Asin":return[r.asin(uf("x",e,t,n))];case"Asinh":return[r.asinh(uf("x",e,t,n))];case"Atan":return[r.atan(uf("x",e,t,n))];case"Atan2":return[r.atan2(uf("x",e,t,n),uf("y",e,t,n))];case"Atanh":return[r.atanh(uf("x",e,t,n))];case"Ceil":return[r.ceil(uf("x",e,t,n))];case"Complex":return[r.complex(uf("real",e,t,n),uf("imag",e,t,n))];case"Cos":return[r.cos(uf("x",e,t,n))];case"Cosh":return[r.cosh(uf("x",e,t,n))];case"Elu":return[r.elu(uf("x",e,t,n))];case"Erf":return[r.erf(uf("x",e,t,n))];case"Exp":return[r.exp(uf("x",e,t,n))];case"Expm1":return[r.expm1(uf("x",e,t,n))];case"Floor":return[r.floor(uf("x",e,t,n))];case"Log":return[r.log(uf("x",e,t,n))];case"Log1p":return[r.log1p(uf("x",e,t,n))];case"Imag":return[r.imag(uf("x",e,t,n))];case"Neg":return[r.neg(uf("x",e,t,n))];case"Reciprocal":return[r.reciprocal(uf("x",e,t,n))];case"Real":return[r.real(uf("x",e,t,n))];case"Relu":return[r.relu(uf("x",e,t,n))];case"Round":return[r.round(uf("x",e,t,n))];case"Selu":return[r.selu(uf("x",e,t,n))];case"Sigmoid":return[r.sigmoid(uf("x",e,t,n))];case"Sin":return[r.sin(uf("x",e,t,n))];case"Sign":return[r.sign(uf("x",e,t,n))];case"Sinh":return[r.sinh(uf("x",e,t,n))];case"Softplus":return[r.softplus(uf("x",e,t,n))];case"Sqrt":return[r.sqrt(uf("x",e,t,n))];case"Square":return[r.square(uf("x",e,t,n))];case"Tanh":return[r.tanh(uf("x",e,t,n))];case"Tan":return[r.tan(uf("x",e,t,n))];case"ClipByValue":return[r.clipByValue(uf("x",e,t,n),uf("clipValueMin",e,t,n),uf("clipValueMax",e,t,n))];case"Relu6":return[r.relu6(uf("x",e,t,n))];case"Rsqrt":return[r.rsqrt(lf(e.inputNames[0],t,n))];case"Prod":return[r.prod(uf("x",e,t,n),uf("axes",e,t,n))];case"LeakyRelu":return[r.leakyRelu(uf("x",e,t,n),uf("alpha",e,t,n))];case"Prelu":return[r.prelu(uf("x",e,t,n),uf("alpha",e,t,n))];case"IsNan":return[r.isNaN(lf(e.inputNames[0],t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"control":return(async(e,t,n)=>{switch(e.op){case"If":case"StatelessIf":{const r=uf("thenBranch",e,t,n),a=uf("elseBranch",e,t,n),i=uf("cond",e,t,n),s=uf("args",e,t,n);return(await i.data())[0]?n.functionMap[r].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap):n.functionMap[a].executeFunctionAsync(s,n.tensorArrayMap,n.tensorListMap)}case"While":case"StatelessWhile":{const r=uf("body",e,t,n),a=uf("cond",e,t,n),i=uf("args",e,t,n),s=await n.functionMap[a].executeFunctionAsync(i,n.tensorArrayMap,n.tensorListMap),o=i.map((e=>e.id));let u=await s[0].data();s.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||e.dispose()}));let l=i;for(;u[0];){const e=l;l=await n.functionMap[r].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);const t=l.map((e=>e.id));e.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}));const i=await n.functionMap[a].executeFunctionAsync(l,n.tensorArrayMap,n.tensorListMap);u=await i[0].data(),i.forEach((e=>{e.kept||-1!==o.indexOf(e.id)||-1!==t.indexOf(e.id)||e.dispose()}))}return l}case"LoopCond":return[ff(uf("pred",e,t,n))];case"Switch":{const r=uf("pred",e,t,n);let a=uf("data",e,t,n);return a.kept||(a=ff(a)),(await r.data())[0]?[void 0,a]:[a,void 0]}case"Merge":{const r=e.inputNames.find((e=>void 0!==lf(e,t,n)));return r?[ff(lf(r,t,n))]:void 0}case"Enter":{const r=uf("frameName",e,t,n),a=uf("tensor",e,t,n);return n.enterFrame(r),[ff(a)]}case"Exit":{const r=uf("tensor",e,t,n);return n.exitFrame(),[ff(r)]}case"NextIteration":{const r=uf("tensor",e,t,n);return n.nextIteration(),[ff(r)]}case"TensorArrayV3":{const r=uf("size",e,t,n),a=uf("dtype",e,t,n),i=uf("elementShape",e,t,n),s=uf("dynamicSize",e,t,n),o=uf("clearAfterRead",e,t,n),u=uf("identicalElementShapes",e,t,n),l=uf("name",e,t,n),c=new tm(l,a,r,i,u,s,o);return n.addTensorArray(c),[c.idTensor,Gl(1)]}case"TensorArrayWriteV3":{const r=uf("tensorArrayId",e,t,n),a=uf("index",e,t,n),i=uf("tensor",e,t,n),s=n.getTensorArray(r.id);return s.write(a,i),[s.idTensor]}case"TensorArrayReadV3":{const r=uf("tensorArrayId",e,t,n),a=uf("index",e,t,n);return[n.getTensorArray(r.id).read(a)]}case"TensorArrayGatherV3":{const r=uf("tensorArrayId",e,t,n),a=uf("indices",e,t,n),i=uf("dtype",e,t,n);return[n.getTensorArray(r.id).gather(a,i)]}case"TensorArrayScatterV3":{const r=uf("tensorArrayId",e,t,n),a=uf("indices",e,t,n),i=uf("tensor",e,t,n),s=n.getTensorArray(r.id);return s.scatter(a,i),[s.idTensor]}case"TensorArrayConcatV3":{const r=uf("tensorArrayId",e,t,n),a=n.getTensorArray(r.id),i=uf("dtype",e,t,n);return[a.concat(i)]}case"TensorArraySplitV3":{const r=uf("tensorArrayId",e,t,n),a=uf("tensor",e,t,n),i=uf("lengths",e,t,n),s=n.getTensorArray(r.id);return s.split(i,a),[s.idTensor]}case"TensorArraySizeV3":{const r=uf("tensorArrayId",e,t,n);return[Gl(n.getTensorArray(r.id).size(),"int32")]}case"TensorArrayCloseV3":{const r=uf("tensorArrayId",e,t,n),a=n.getTensorArray(r.id);return a.clearAndClose(),[a.idTensor]}case"TensorListSetItem":{const r=uf("tensorListId",e,t,n),a=uf("index",e,t,n),i=uf("tensor",e,t,n),s=n.getTensorList(r.id);return s.setItem(a,i),[s.idTensor]}case"TensorListGetItem":{const r=uf("tensorListId",e,t,n),a=uf("index",e,t,n),i=uf("elementShape",e,t,n),s=uf("elementDType",e,t,n);return[n.getTensorList(r.id).getItem(a,i,s)]}case"TensorListScatterV2":case"TensorListScatter":{const r=uf("indices",e,t,n),a=function(e,t,n,r){if(t.length!==e.shape[0])throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`);const a=Math.max(...t);if(null!=r&&-1!==r&&a>=r)throw new Error(`Max index must be < array size (${a} vs. ${r})`);const i=new nm([],n,e.dtype,r),s=sp(e,0);return t.forEach(((e,t)=>{i.setItem(e,s[t])})),i}(uf("tensor",e,t,n),r,uf("elementShape",e,t,n),uf("numElements",e,t,n));return n.addTensorList(a),[a.idTensor]}case"TensorListReserve":case"EmptyTensorList":{const r=uf("elementShape",e,t,n),a=uf("elementDType",e,t,n);let i;i="TensorListReserve"===e.op?"numElements":"maxNumElements";const s=uf(i,e,t,n),o=function(e,t,n,r){return new nm([],e,t,r)}(r,a,0,"TensorListReserve"===e.op?-1:s);return n.addTensorList(o),[o.idTensor]}case"TensorListGather":{const r=uf("tensorListId",e,t,n),a=uf("indices",e,t,n),i=uf("elementShape",e,t,n),s=uf("elementDType",e,t,n);return[n.getTensorList(r.id).gather(a,s,i)]}case"TensorListStack":{const r=uf("tensorListId",e,t,n),a=uf("elementShape",e,t,n),i=uf("elementDType",e,t,n),s=uf("numElements",e,t,n);return[n.getTensorList(r.id).stack(a,i,s)]}case"TensorListFromTensor":{const r=function(e,t,n){const r=e.dtype;if(e.shape.length<1)throw new Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`);if(e.dtype!==n)throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${n}`);Qf(e.shape.slice(1),t,"TensorList shape mismatch: ");const a=sp(e);return new nm(a,t,r)}(uf("tensor",e,t,n),uf("elementShape",e,t,n),uf("elementDType",e,t,n));return n.addTensorList(r),[r.idTensor]}case"TensorListConcat":case"TensorListConcatV2":{const r=uf("tensorListId",e,t,n),a=n.getTensorList(r.id),i=uf("dtype",e,t,n),s=uf("elementShape",e,t,n);return[a.concat(i,s)]}case"TensorListPushBack":{const r=uf("tensorListId",e,t,n),a=uf("tensor",e,t,n),i=n.getTensorList(r.id);return i.pushBack(a),[i.idTensor]}case"TensorListPopBack":{const r=uf("tensorListId",e,t,n),a=uf("elementShape",e,t,n),i=uf("elementDType",e,t,n);return[n.getTensorList(r.id).popBack(a,i)]}case"TensorListSplit":{const r=uf("tensor",e,t,n),a=uf("elementShape",e,t,n),i=function(e,t,n){let r=0;const a=t.map((e=>(r+=e,r)));if(r!==e.shape[0])throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${r}, and tensor's shape is: ${e.shape}`);const i=em(e.shape.slice(1),n),s=0===r?0:e.size/r,o=Io((()=>{const n=[];e=Bu(e,[1,r,s]);for(let r=0;r<t.length;++r){const o=[0,0===r?0:a[r-1],0],u=[1,t[r],s];n[r]=Bu(Gu(e,o,u),i)}return e.dispose(),n})),u=new nm([],n,e.dtype,t.length);for(let e=0;e<o.length;e++)u.setItem(e,o[e]);return u}(r,uf("lengths",e,t,n),a);return n.addTensorList(i),[i.idTensor]}case"TensorListLength":{const r=uf("tensorListId",e,t,n);return[Gl(n.getTensorList(r.id).size(),"int32")]}case"TensorListResize":{const r=uf("tensorListId",e,t,n),a=uf("size",e,t,n),i=n.getTensorList(r.id).resize(a);return n.addTensorList(i),[i.idTensor]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"convolution":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"Conv1D":{const a=uf("stride",e,t,n),i=uf("pad",e,t,n),s=uf("dataFormat",e,t,n).toUpperCase(),o=uf("dilation",e,t,n);return[r.conv1d(uf("x",e,t,n),uf("filter",e,t,n),a,i,s,o)]}case"Conv2D":{const a=uf("strides",e,t,n),i=df(e,t,n),s=uf("dataFormat",e,t,n).toUpperCase(),o=uf("dilations",e,t,n);return[r.conv2d(uf("x",e,t,n),uf("filter",e,t,n),[a[1],a[2]],i,s,[o[1],o[2]])]}case"_FusedConv2D":{const{stride:a,pad:i,dataFormat:s,dilations:o,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:h}=rm(e,t,n);return[r.fused.conv2d({x:uf("x",e,t,n),filter:uf("filter",e,t,n),strides:[a[1],a[2]],pad:i,dataFormat:s,dilations:[o[1],o[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:h})]}case"FusedDepthwiseConv2dNative":{const{stride:a,pad:i,dataFormat:s,dilations:o,biasArg:u,preluArg:l,activationFunc:c,leakyreluAlpha:h}=rm(e,t,n);return[r.fused.depthwiseConv2d({x:uf("x",e,t,n),filter:uf("filter",e,t,n),strides:[a[1],a[2]],pad:i,dataFormat:s,dilations:[o[1],o[2]],bias:u,activation:c,preluActivationWeights:l,leakyreluAlpha:h})]}case"Conv2DBackpropInput":case"Conv2dTranspose":{const a=uf("outputShape",e,t,n),i=uf("strides",e,t,n),s=df(e,t,n);return[r.conv2dTranspose(uf("x",e,t,n),uf("filter",e,t,n),a,[i[1],i[2]],s)]}case"DepthwiseConv2dNative":case"DepthwiseConv2d":{const a=uf("strides",e,t,n),i=df(e,t,n),s=uf("dilations",e,t,n),o=uf("dataFormat",e,t,n).toUpperCase();return[r.depthwiseConv2d(uf("input",e,t,n),uf("filter",e,t,n),[a[1],a[2]],i,o,[s[1],s[2]])]}case"Conv3D":{const a=uf("strides",e,t,n),i=uf("pad",e,t,n),s=uf("dataFormat",e,t,n).toUpperCase(),o=uf("dilations",e,t,n);return[r.conv3d(uf("x",e,t,n),uf("filter",e,t,n),[a[1],a[2],a[3]],i,s,[o[1],o[2],o[3]])]}case"AvgPool":{const a=uf("strides",e,t,n),i=uf("pad",e,t,n),s=uf("kernelSize",e,t,n);return[r.avgPool(uf("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i)]}case"MaxPool":{const a=uf("strides",e,t,n),i=uf("pad",e,t,n),s=uf("kernelSize",e,t,n);return[r.maxPool(uf("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i)]}case"MaxPoolWithArgmax":{const a=uf("strides",e,t,n),i=uf("pad",e,t,n),s=uf("kernelSize",e,t,n),o=uf("includeBatchInIndex",e,t,n),{result:u,indexes:l}=r.maxPoolWithArgmax(uf("x",e,t,n),[s[1],s[2]],[a[1],a[2]],i,o);return[u,l]}case"AvgPool3D":{const a=uf("strides",e,t,n),i=uf("pad",e,t,n),s=uf("kernelSize",e,t,n);return[r.avgPool3d(uf("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],i)]}case"MaxPool3D":{const a=uf("strides",e,t,n),i=uf("pad",e,t,n),s=uf("kernelSize",e,t,n);return[r.maxPool3d(uf("x",e,t,n),[s[1],s[2],s[3]],[a[1],a[2],a[3]],i)]}case"Dilation2D":{const a=uf("strides",e,t,n),i=uf("pad",e,t,n),s=uf("dilations",e,t,n),o=a[1],u=a[2],l=s[1],c=s[2];return[r.dilation2d(uf("x",e,t,n),uf("filter",e,t,n),[o,u],i,[l,c],"NHWC")]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"creation":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"Fill":{const a=uf("shape",e,t,n),i=uf("dtype",e,t,n),s=uf("value",e,t,n);return[r.fill(a,s,i)]}case"LinSpace":{const a=uf("start",e,t,n),i=uf("stop",e,t,n),s=uf("num",e,t,n);return[r.linspace(a,i,s)]}case"Multinomial":{const a=uf("logits",e,t,n),i=uf("numSamples",e,t,n),s=uf("seed",e,t,n);return[r.multinomial(a,i,s)]}case"OneHot":{const a=uf("indices",e,t,n),i=uf("depth",e,t,n),s=uf("onValue",e,t,n),o=uf("offValue",e,t,n),u=uf("dtype",e,t,n);return[r.oneHot(a,i,s,o,u)]}case"Ones":return[r.ones(uf("shape",e,t,n),uf("dtype",e,t,n))];case"OnesLike":return[r.onesLike(uf("x",e,t,n))];case"RandomStandardNormal":return[r.randomStandardNormal(uf("shape",e,t,n),uf("dtype",e,t,n),uf("seed",e,t,n))];case"RandomUniform":return[r.randomUniform(uf("shape",e,t,n),uf("minval",e,t,n),uf("maxval",e,t,n),uf("dtype",e,t,n))];case"Range":{const a=uf("start",e,t,n),i=uf("stop",e,t,n),s=uf("step",e,t,n);return[r.range(a,i,s,uf("dtype",e,t,n))]}case"TruncatedNormal":{const a=uf("shape",e,t,n),i=uf("mean",e,t,n),s=uf("stdDev",e,t,n),o=uf("seed",e,t,n);return[r.truncatedNormal(a,i,s,uf("dtype",e,t,n),o)]}case"Zeros":return[r.zeros(uf("shape",e,t,n),uf("dtype",e,t,n))];case"ZerosLike":return[r.zerosLike(uf("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"dynamic":return(async(e,t,n,r,a=Yf)=>{switch(e.op){case"NonMaxSuppressionV5":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u,softNmsSigma:l}=am(e,t,n),c=await a.image.nonMaxSuppressionWithScoreAsync(r,i,s,o,u,l);return[c.selectedIndices,c.selectedScores]}case"NonMaxSuppressionV4":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=am(e,t,n),l=uf("padToMaxOutputSize",e,t,n),c=await a.image.nonMaxSuppressionPaddedAsync(r,i,s,o,u,l);return[c.selectedIndices,c.validOutputs]}case"NonMaxSuppressionV3":case"NonMaxSuppressionV2":{const{boxes:r,scores:i,maxOutputSize:s,iouThreshold:o,scoreThreshold:u}=am(e,t,n);return[await a.image.nonMaxSuppressionAsync(r,i,s,o,u)]}case"Where":{const r=a.cast(uf("condition",e,t,n),"bool"),i=[await a.whereAsync(r)];return r.dispose(),i}case"ListDiff":return a.setdiff1dAsync(uf("x",e,t,n),uf("y",e,t,n));default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n);case"evaluation":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"LowerBound":{const a=uf("sortedSequence",e,t,n),i=uf("values",e,t,n);return[r.lowerBound(a,i)]}case"TopKV2":{const a=uf("x",e,t,n),i=uf("k",e,t,n),s=uf("sorted",e,t,n),o=r.topk(a,i,s);return[o.values,o.indices]}case"UpperBound":{const a=uf("sortedSequence",e,t,n),i=uf("values",e,t,n);return[r.upperBound(a,i)]}case"Unique":{const a=uf("x",e,t,n),i=r.unique(a);return[i.values,i.indices]}case"UniqueV2":{const a=uf("x",e,t,n),i=uf("axis",e,t,n),s=r.unique(a,i);return[s.values,s.indices]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"image":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"ResizeBilinear":{const a=uf("images",e,t,n),i=uf("size",e,t,n),s=uf("alignCorners",e,t,n),o=uf("halfPixelCenters",e,t,n);return[r.image.resizeBilinear(a,[i[0],i[1]],s,o)]}case"ResizeNearestNeighbor":{const a=uf("images",e,t,n),i=uf("size",e,t,n),s=uf("alignCorners",e,t,n),o=uf("halfPixelCenters",e,t,n);return[r.image.resizeNearestNeighbor(a,[i[0],i[1]],s,o)]}case"CropAndResize":{const a=uf("image",e,t,n),i=uf("boxes",e,t,n),s=uf("boxInd",e,t,n),o=uf("cropSize",e,t,n),u=uf("method",e,t,n),l=uf("extrapolationValue",e,t,n);return[r.image.cropAndResize(a,i,s,o,u,l)]}case"ImageProjectiveTransformV3":{const a=uf("images",e,t,n),i=uf("transforms",e,t,n),s=uf("outputShape",e,t,n),o=uf("fillValue",e,t,n),u=uf("interpolation",e,t,n),l=uf("fillMode",e,t,n);return[r.image.transform(a,i,u.toLowerCase(),l.toLowerCase(),o,s)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"graph":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"Const":return t[e.name];case"PlaceholderWithDefault":const a=uf("default",e,t,n);return[lf(e.name,t,n)||a];case"Placeholder":return[lf(e.name,t,n)];case"Identity":case"StopGradient":case"FakeQuantWithMinMaxVars":case"Snapshot":return[ff(uf("x",e,t,n))];case"IdentityN":return uf("x",e,t,n).map((e=>ff(e)));case"Shape":return[r.tensor1d(uf("x",e,t,n).shape,"int32")];case"ShapeN":return uf("x",e,t,n).map((e=>r.tensor1d(e.shape)));case"Size":return[r.scalar(uf("x",e,t,n).size,"int32")];case"Rank":return[r.scalar(uf("x",e,t,n).rank,"int32")];case"NoOp":return[r.scalar(1)];case"Print":const i=uf("x",e,t,n),s=uf("data",e,t,n),o=uf("message",e,t,n),u=uf("summarize",e,t,n);console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."),console.log(o);for(let e=0;e<s.length;e++)console.log(Array.prototype.slice.call(s[e].dataSync()).slice(0,u));return[i];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"logical":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"Equal":return[r.equal(uf("a",e,t,n),uf("b",e,t,n))];case"NotEqual":return[r.notEqual(uf("a",e,t,n),uf("b",e,t,n))];case"Greater":return[r.greater(uf("a",e,t,n),uf("b",e,t,n))];case"GreaterEqual":return[r.greaterEqual(uf("a",e,t,n),uf("b",e,t,n))];case"Less":return[r.less(uf("a",e,t,n),uf("b",e,t,n))];case"LessEqual":return[r.lessEqual(uf("a",e,t,n),uf("b",e,t,n))];case"LogicalAnd":return[r.logicalAnd(uf("a",e,t,n),uf("b",e,t,n))];case"LogicalNot":return[r.logicalNot(uf("a",e,t,n))];case"LogicalOr":return[r.logicalOr(uf("a",e,t,n),uf("b",e,t,n))];case"Select":case"SelectV2":return[r.where(uf("condition",e,t,n),uf("a",e,t,n),uf("b",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"matrices":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"BatchMatMul":case"BatchMatMulV2":case"MatMul":return[r.matMul(uf("a",e,t,n),uf("b",e,t,n),uf("transposeA",e,t,n),uf("transposeB",e,t,n))];case"Einsum":return[r.einsum(uf("equation",e,t,n),...uf("tensors",e,t,n))];case"Transpose":return[r.transpose(uf("x",e,t,n),uf("perm",e,t,n))];case"_FusedMatMul":const[a,i]=uf("fusedOps",e,t,n),s="biasadd"===a,o="prelu"===i,u=uf("numArgs",e,t,n),l=uf("leakyreluAlpha",e,t,n);if(s){if(o&&2!==u)throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha.");if(!o&&1!==u)throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.")}const[c,h]=uf("args",e,t,n);return[r.fused.matMul({a:uf("a",e,t,n),b:uf("b",e,t,n),transposeA:uf("transposeA",e,t,n),transposeB:uf("transposeB",e,t,n),bias:c,activation:i,preluActivationWeights:h,leakyreluAlpha:l})];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"normalization":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"EuclideanNorm":return[r.euclideanNorm(uf("x",e,t,n),uf("axis",e,t,n),uf("keepDims",e,t,n))];case"FusedBatchNorm":case"FusedBatchNormV2":case"FusedBatchNormV3":return[r.batchNorm(uf("x",e,t,n),uf("mean",e,t,n),uf("variance",e,t,n),uf("offset",e,t,n),uf("scale",e,t,n),uf("epsilon",e,t,n))];case"LRN":return[r.localResponseNormalization(uf("x",e,t,n),uf("radius",e,t,n),uf("bias",e,t,n),uf("alpha",e,t,n),uf("beta",e,t,n))];case"Softmax":return[r.softmax(uf("x",e,t,n))];case"LogSoftmax":return[r.logSoftmax(uf("x",e,t,n))];case"SparseToDense":return[r.sparseToDense(uf("sparseIndices",e,t,n),uf("outputShape",e,t,n),uf("sparseValues",e,t,n),uf("defaultValue",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"ragged":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"RaggedGather":{const{outputNestedSplits:a,outputDenseValues:i}=r.raggedGather(uf("paramsNestedSplits",e,t,n),uf("paramsDenseValues",e,t,n),uf("indices",e,t,n),uf("outputRaggedRank",e,t,n));return a.concat(i)}case"RaggedRange":{const{rtNestedSplits:a,rtDenseValues:i}=r.raggedRange(uf("starts",e,t,n),uf("limits",e,t,n),uf("splits",e,t,n));return[a,i]}case"RaggedTensorToTensor":return[r.raggedTensorToTensor(uf("shape",e,t,n),uf("values",e,t,n),uf("defaultValue",e,t,n),uf("rowPartitionTensors",e,t,n),uf("rowPartitionTypes",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"reduction":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"Max":{const a=uf("axis",e,t,n),i=uf("keepDims",e,t,n);return[r.max(uf("x",e,t,n),a,i)]}case"Mean":{const a=uf("axis",e,t,n),i=uf("keepDims",e,t,n);return[r.mean(uf("x",e,t,n),a,i)]}case"Min":{const a=uf("axis",e,t,n),i=uf("keepDims",e,t,n);return[r.min(uf("x",e,t,n),a,i)]}case"Sum":{const a=uf("axis",e,t,n),i=uf("keepDims",e,t,n);return[r.sum(uf("x",e,t,n),a,i)]}case"All":{const a=uf("axis",e,t,n),i=uf("keepDims",e,t,n);return[r.all(uf("x",e,t,n),a,i)]}case"Any":{const a=uf("axis",e,t,n),i=uf("keepDims",e,t,n);return[r.any(uf("x",e,t,n),a,i)]}case"ArgMax":{const a=uf("axis",e,t,n);return[r.argMax(uf("x",e,t,n),a)]}case"ArgMin":{const a=uf("axis",e,t,n);return[r.argMin(uf("x",e,t,n),a)]}case"Prod":{const a=uf("axis",e,t,n),i=uf("keepDims",e,t,n);return[r.prod(uf("x",e,t,n),a,i)]}case"Cumprod":{const a=uf("axis",e,t,n),i=uf("exclusive",e,t,n),s=uf("reverse",e,t,n);return[r.cumprod(uf("x",e,t,n),a,i,s)]}case"Cumsum":{const a=uf("axis",e,t,n),i=uf("exclusive",e,t,n),s=uf("reverse",e,t,n);return[r.cumsum(uf("x",e,t,n),a,i,s)]}case"Bincount":const a=uf("x",e,t,n),i=uf("weights",e,t,n),s=uf("size",e,t,n);return[r.bincount(a,i,s)];case"DenseBincount":{const a=uf("x",e,t,n),i=uf("weights",e,t,n),s=uf("size",e,t,n),o=uf("binaryOutput",e,t,n);return[r.denseBincount(a,i,s,o)]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"slice_join":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"ConcatV2":case"Concat":{const a=uf("n",e,t,n),i=uf("axis",e,t,n);let s=uf("tensors",e,t,n);return s=s.slice(0,a),[r.concat(s,i)]}case"Gather":{const a=uf("x",e,t,n),i=uf("indices",e,t,n);return[r.gather(a,r.cast(i,"int32"),0)]}case"GatherV2":{const a=uf("axis",e,t,n),i=uf("batchDims",e,t,n),s=uf("x",e,t,n),o=uf("indices",e,t,n);return[r.gather(s,r.cast(o,"int32"),a,i)]}case"Reverse":{const a=uf("dims",e,t,n),i=[];for(let e=0;e<a.length;e++)a[e]&&i.push(e);const s=uf("x",e,t,n);return[r.reverse(s,i)]}case"ReverseV2":{const a=uf("axis",e,t,n),i=uf("x",e,t,n);return[r.reverse(i,a)]}case"Slice":{const a=uf("begin",e,t,n),i=uf("size",e,t,n);return[r.slice(uf("x",e,t,n),a,i)]}case"StridedSlice":{const a=uf("begin",e,t,n),i=uf("end",e,t,n),s=uf("strides",e,t,n),o=uf("beginMask",e,t,n),u=uf("endMask",e,t,n),l=uf("ellipsisMask",e,t,n),c=uf("newAxisMask",e,t,n),h=uf("shrinkAxisMask",e,t,n),p=uf("x",e,t,n);return[r.stridedSlice(p,a,i,s,o,u,l,c,h)]}case"Pack":return Io((()=>{const a=uf("axis",e,t,n),i=uf("tensors",e,t,n),s=i[0].shape,o=r.squeeze(i[0]).shape,u=i.map((e=>{const t=st(e.shape,s);if(!t&&!st(r.squeeze(e).shape,o))throw new Error("the input tensors shape does not match");return t?e:r.reshape(e,s)}));return[r.stack(u,a)]}));case"Unpack":{const a=uf("axis",e,t,n),i=uf("tensor",e,t,n);return r.unstack(i,a)}case"Tile":{const a=uf("reps",e,t,n);return[r.tile(uf("x",e,t,n),a)]}case"Split":case"SplitV":{const a=uf("axis",e,t,n),i=uf("numOrSizeSplits",e,t,n),s=uf("x",e,t,n);return r.split(s,i,a)}case"ScatterNd":{const a=uf("indices",e,t,n),i=uf("values",e,t,n),s=uf("shape",e,t,n);return[r.scatterND(a,i,s)]}case"GatherNd":{const a=uf("x",e,t,n),i=uf("indices",e,t,n);return[r.gatherND(a,i)]}case"SparseToDense":{const a=uf("sparseIndices",e,t,n),i=uf("outputShape",e,t,n),s=uf("sparseValues",e,t,n),o=uf("defaultValue",e,t,n);return[r.sparseToDense(a,s,i,s.dtype===o.dtype?o:r.cast(o,s.dtype))]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"sparse":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"SparseFillEmptyRows":{const{outputIndices:a,outputValues:i,emptyRowIndicator:s,reverseIndexMap:o}=r.sparse.sparseFillEmptyRows(uf("indices",e,t,n),uf("values",e,t,n),uf("denseShape",e,t,n),uf("defaultValue",e,t,n));return[a,i,s,o]}case"SparseReshape":{const{outputIndices:a,outputShape:i}=r.sparse.sparseReshape(uf("inputIndices",e,t,n),uf("inputShape",e,t,n),uf("newShape",e,t,n));return[a,i]}case"SparseSegmentMean":return[r.sparse.sparseSegmentMean(uf("data",e,t,n),uf("indices",e,t,n),uf("segmentIds",e,t,n))];case"SparseSegmentSum":return[r.sparse.sparseSegmentSum(uf("data",e,t,n),uf("indices",e,t,n),uf("segmentIds",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"spectral":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"FFT":return[r.fft(uf("x",e,t,n))];case"IFFT":return[r.ifft(uf("x",e,t,n))];case"RFFT":return[r.rfft(uf("x",e,t,n))];case"IRFFT":return[r.irfft(uf("x",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"string":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"StringNGrams":{const{nGrams:a,nGramsSplits:i}=r.string.stringNGrams(uf("data",e,t,n),uf("dataSplits",e,t,n),uf("separator",e,t,n),uf("nGramWidths",e,t,n),uf("leftPad",e,t,n),uf("rightPad",e,t,n),uf("padWidth",e,t,n),uf("preserveShortSequences",e,t,n));return[a,i]}case"StringSplit":{const{indices:a,values:i,shape:s}=r.string.stringSplit(uf("input",e,t,n),uf("delimiter",e,t,n),uf("skipEmpty",e,t,n));return[a,i,s]}case"StringToHashBucketFast":return[r.string.stringToHashBucketFast(uf("input",e,t,n),uf("numBuckets",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"transformation":return a((()=>((e,t,n,r=Yf)=>{switch(e.op){case"Cast":return[r.cast(uf("x",e,t,n),uf("dtype",e,t,n))];case"ExpandDims":{const a=uf("axis",e,t,n);return[r.expandDims(uf("x",e,t,n),a)]}case"Squeeze":{const a=uf("axis",e,t,n);return[r.squeeze(uf("x",e,t,n),a)]}case"Reshape":return[r.reshape(uf("x",e,t,n),uf("shape",e,t,n))];case"MirrorPad":return[r.mirrorPad(uf("x",e,t,n),uf("padding",e,t,n),uf("mode",e,t,n))];case"PadV2":case"Pad":return[r.pad(uf("x",e,t,n),uf("padding",e,t,n),uf("constantValue",e,t,n))];case"SpaceToBatchND":{const a=uf("blockShape",e,t,n),i=uf("paddings",e,t,n);return[r.spaceToBatchND(uf("x",e,t,n),a,i)]}case"BatchToSpaceND":{const a=uf("blockShape",e,t,n),i=uf("crops",e,t,n);return[r.batchToSpaceND(uf("x",e,t,n),a,i)]}case"DepthToSpace":{const a=uf("blockSize",e,t,n),i=uf("dataFormat",e,t,n).toUpperCase();return[r.depthToSpace(uf("x",e,t,n),a,i)]}case"BroadcastTo":return[r.broadcastTo(uf("x",e,t,n),uf("shape",e,t,n))];case"BroadcastArgs":return[r.broadcastArgs(uf("s0",e,t,n),uf("s1",e,t,n))];default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n)));case"hash_table":return(async(e,t,n,r)=>{switch(e.op){case"HashTable":case"HashTableV2":{const a=r.getHashTableHandleByName(e.name);if(null!=a)return[a];{const a=uf("keyDType",e,t,n),i=uf("valueDType",e,t,n),s=new im(a,i);return r.addHashTable(e.name,s),[s.handle]}}case"InitializeTable":case"InitializeTableV2":case"LookupTableImport":case"LookupTableImportV2":{const a=uf("tableHandle",e,t,n,r),i=uf("keys",e,t,n),s=uf("values",e,t,n),o=r.getHashTableById(a.id);return[await o.import(i,s)]}case"LookupTableFind":case"LookupTableFindV2":{const a=uf("tableHandle",e,t,n,r),i=uf("keys",e,t,n),s=uf("defaultValue",e,t,n),o=r.getHashTableById(a.id);return[await o.find(i,s)]}case"LookupTableSize":case"LookupTableSizeV2":{const a=uf("tableHandle",e,t,n,r);return[r.getHashTableById(a.id).tensorSize()]}default:throw TypeError(`Node type ${e.op} is not implemented`)}})(e,t,n,r);case"custom":const i=of(e.op);if(i&&i.customExecutor)return i.customExecutor(new Xf(e,t,n));throw TypeError(`Custom op ${e.op} is not registered.`);default:throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`)}})(e,t,n);return Nt(i)?i.then((e=>[].concat(e))):[].concat(i)}class om{constructor(e={},t={},n={},r={}){this.weightMap=e,this.tensorArrayMap=t,this.tensorListMap=n,this.functionMap=r,this.rootContext={id:0,frameName:"",iterationId:0},this.contexts=[this.rootContext],this.lastId=0,this.generateCurrentContextIds()}newFrame(e,t){return{id:e,frameName:t,iterationId:0}}set currentContext(e){this.contexts!==e&&(this.contexts=e,this.generateCurrentContextIds())}get currentContext(){return this.contexts}get currentContextId(){return this._currentContextIds[0]}get currentContextIds(){return this._currentContextIds}generateCurrentContextIds(){const e=[];for(let t=0;t<this.contexts.length-1;t++){const n=this.contexts.slice(0,this.contexts.length-t);e.push(this.contextIdforContexts(n))}e.push(""),this._currentContextIds=e}contextIdforContexts(e){return e?e.map((e=>0===e.id&&0===e.iterationId?"":`${e.frameName}-${e.iterationId}`)).join("/"):""}enterFrame(e){this.contexts&&(this.lastId++,this.contexts=this.contexts.slice(),this.contexts.push(this.newFrame(this.lastId,e)),this._currentContextIds.unshift(this.contextIdforContexts(this.contexts)))}exitFrame(){if(!(this.contexts&&this.contexts.length>1))throw new Error("Cannot exit frame, the context is empty");this.contexts=this.contexts.slice(),this.contexts.splice(-1),this.currentContextIds.shift()}nextIteration(){if(!(this.contexts&&this.contexts.length>0))throw new Error("Cannot increase frame iteration, the context is empty");{this.contexts=this.contexts.slice(),this.lastId++;const e=Object.assign({},this.contexts[this.contexts.length-1]);e.iterationId+=1,e.id=this.lastId,this.contexts.splice(-1,1,e),this._currentContextIds.splice(0,1,this.contextIdforContexts(this.contexts))}}getWeight(e){return this.weightMap[e]}addTensorArray(e){this.tensorArrayMap[e.id]=e}getTensorArray(e){return this.tensorArrayMap[e]}addTensorList(e){this.tensorListMap[e.id]=e}getTensorList(e){return this.tensorListMap[e]}dispose(e){for(const t in this.tensorArrayMap)this.tensorArrayMap[t].clearAndClose(e);for(const t in this.tensorListMap)this.tensorListMap[t].clearAndClose(e)}}function um(e,t,n,r){const a=new Set,i=[];let s=null,o=null;const u=new Set,l=Object.keys(e).map((e=>pf(e)[0]));let c=[];null!=r&&(c=r.map((e=>pf(e.name)[0])));const h=[...t];for(;h.length>0;){const e=h.pop();(pm(e)||dm(e)||fm(e))&&null==s&&(s=e,o=s.children.map((e=>e.name)).filter((e=>a.has(e)))),a.add(e.name),null==n[e.name]&&-1===l.indexOf(e.name)&&-1===c.indexOf(e.name)&&(0!==e.inputs.length?e.inputs.forEach((e=>{u.has(e.name)||(u.add(e.name),h.push(e))})):i.push(e.name))}return{inputs:e,outputs:t,usedNodes:a,missingInputs:i,dynamicNode:s,syncInputs:o}}const lm=["Switch","Merge","Enter","Exit","NextIteration","StatelessIf","StatelessWhile","if","While"],cm=["NonMaxSuppressionV2","NonMaxSuppressionV3","NonMaxSuppressionV5","Where"],hm=["HashTable","HashTableV2","LookupTableImport","LookupTableImportV2","LookupTableFind","LookupTableFindV2","LookupTableSize","LookupTableSizeV2"];function pm(e){return lm.indexOf(e.op)>=0}function dm(e){return cm.indexOf(e.op)>=0}function fm(e){return hm.indexOf(e.op)>=0}class mm{constructor(e,t){this.graph=e,this.parent=t,this.compiledMap=new Map,this._weightMap={},this.SEPERATOR=",",this._functions={},this._functionExecutorMap={},this.keepIntermediateTensors=!1,this._outputs=e.outputs,this._inputs=e.inputs,this._initNodes=e.initNodes,this._signature=e.signature,this._functions=e.functions,null!=e.functions&&Object.keys(e.functions).forEach((t=>{this._functionExecutorMap[t]=new mm(e.functions[t],this)}))}get weightIds(){return this.parent?this.parent.weightIds:this._weightIds}get functionExecutorMap(){return this.parent?this.parent.functionExecutorMap:this._functionExecutorMap}get weightMap(){return this.parent?this.parent.weightMap:this._weightMap}set weightMap(e){const t=Object.keys(e).map((t=>e[t].map((e=>e.id))));this._weightIds=[].concat(...t),this._weightMap=e}set resourceManager(e){this._resourceManager=e}get inputs(){return this._inputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get outputs(){return this._outputs.map((e=>({name:e.name,shape:e.attrParams.shape?e.attrParams.shape.value:void 0,dtype:e.attrParams.dtype?e.attrParams.dtype.value:void 0})))}get inputNodes(){return this._inputs.map((e=>e.signatureKey||e.name))}get outputNodes(){return this._outputs.map((e=>{const t=e.signatureKey||e.name;return e.defaultOutput?`${t}:${e.defaultOutput}`:t}))}get functions(){return Object.keys(this._functions).reduce(((e,t)=>(e[t]=this._functions[t].signature,e)),{})}getCompilationKey(e,t){const n=e.map((e=>e.name)).sort(),r=t.map((e=>e.name)).sort();return n.join(this.SEPERATOR)+"--"+r.join(this.SEPERATOR)}compile(e,t){const n=um(e,t,this.weightMap,this._initNodes),{missingInputs:r,dynamicNode:a,syncInputs:i}=n;if(null!=a)throw new Error(`This execution contains the node '${a.name}', which has the dynamic op '${a.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${i}]`);if(r.length>0){const n=t.map((e=>e.name)),a=Object.keys(e);throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${a}]. Missing the following inputs: [${r}]`)}return function(e,t,n){const{usedNodes:r,inputs:a}=n,i=[],s=Object.keys(a).map((e=>pf(e)[0])).map((t=>e.nodes[t])),o=e.initNodes;s.forEach((e=>{r.has(e.name)&&i.push(e)})),e.weights.forEach((e=>{r.has(e.name)&&i.push(e)})),null!=o&&o.forEach((e=>{r.has(e.name)&&i.push(e)}));const u=new Set,l=[];for(;i.length>0;){const e=i.pop();u.add(e.name),t[e.name]||l.push(e),e.children.forEach((e=>{!u.has(e.name)&&r.has(e.name)&&e.inputs.every((e=>u.has(e.name)))&&i.push(e)}))}return l}(this.graph,this.weightMap,n)}cloneAndKeepTensor(e){if(null==e)return null;const t=e.clone();return Co(t),t}cloneTensorList(e){return e?e.map((e=>this.cloneAndKeepTensor(e))):null}cloneTensorMap(e){return Object.fromEntries(Object.entries(e).map((([e,t])=>[e,this.cloneTensorList(t)])))}execute(e,t){this.disposeIntermediateTensors(),e=this.mapInputs(e);const n=Object.keys(e).sort();this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t);const r=n.map((e=>this.graph.nodes[pf(e)[0]])),a=t.map((e=>pf(e)[0]));let i=a.map((e=>this.graph.nodes[e]));0===i.length&&(i=this._outputs);const s=this.getCompilationKey(r,i);let o=this.compiledMap.get(s);null==o&&(o=this.compile(e,i),this.compiledMap.set(s,o));try{this.keepIntermediateTensors=Mt().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}const u={},l={};return Io((()=>{const n=new om(this.weightMap,u,l,this.functionExecutorMap),r=Object.assign({},this.weightMap);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap)),Object.keys(e).forEach((t=>{const[n,a]=pf(t),i=[];i[a]=e[t],r[n]=i,this.keepIntermediateTensors&&(this.clonedTensorsMap[n]=this.cloneTensorList(i))}));const i=this.getFrozenTensorIds(r),s={};for(let e=0;e<o.length;e++){const t=o[e];if(!r[t.name]){const e=sm(t,r,n,this._resourceManager);if(Nt(e))throw new Error(`The execution of the op '${t.op}' returned a promise. Please use model.executeAsync() instead.`);r[t.name]=e,this.keepIntermediateTensors&&(this.clonedTensorsMap[t.name]=this.cloneTensorList(e)),this.checkTensorForDisposal(t.name,t,r,n,i,a,s)}}return null==this.parent&&n.dispose(i),t.map((e=>lf(e,r,n)))}))}getFrozenTensorIds(e){const t=[].concat.apply([],Object.keys(e).map((t=>e[t])).map((e=>e.map((e=>e.id)))));return new Set(t)}checkTensorForDisposal(e,t,n,r,a,i,s){"control"!==t.category&&-1===i.indexOf(e)&&(n[e].forEach((e=>{null!=e&&(s[e.id]=(s[e.id]||0)+t.children.length)})),t.inputs.forEach((e=>{if("control"!==e.category){const t=function(e,t,n){return t[hf(e,n.currentContextId)]}(e.name,n,r);null!=t&&t.forEach((e=>{if(e&&!e.kept&&!a.has(e.id)){const t=s[e.id];1===t?(e.dispose(),delete s[e.id]):null!=t&&s[e.id]--}}))}})))}async executeAsync(e,t){return this._executeAsync(e,t)}disposeIntermediateTensors(){this.clonedTensorsMap&&(Object.values(this.clonedTensorsMap).forEach((e=>{for(const t of e)t&&!t.isDisposed&&t.dispose()})),this.clonedTensorsMap=null)}getIntermediateTensors(){return this.clonedTensorsMap}async _executeAsync(e,t,n=!1,r={},a={}){this.disposeIntermediateTensors(),n||(e=this.mapInputs(e),this.checkInputs(e),this.checkInputShapeAndType(e),t=this.mapOutputs(t),this.checkOutputs(t));try{this.keepIntermediateTensors=Mt().getBool("KEEP_INTERMEDIATE_TENSORS")}catch(e){this.keepIntermediateTensors=!1,console.warn(e.message)}const i=new om(this.weightMap,r,a,this.functionExecutorMap);this.keepIntermediateTensors&&(this.clonedTensorsMap=this.cloneTensorMap(this.weightMap));const s=await this.executeWithControlFlow(e,i,t,n),o=t.map((e=>lf(e,s,i))),u=o.map((e=>e.id)),l=Object.keys(e).map((t=>e[t].id)),c=new Set([...u,...l,...this.weightIds]);return Object.values(s).forEach((e=>{e.forEach((e=>{!e||e.isDisposed||c.has(e.id)||e.dispose()}))})),null==this.parent&&i.dispose(c),o}async executeFunctionAsync(e,t,n){const r=e.reduce(((e,t,n)=>(e[this.inputs[n].name]=t,e)),{});return this._executeAsync(r,this.outputNodes,!0,t,n)}async executeWithControlFlow(e,t,n,r){const a=Object.keys(e),i=a.map((e=>this.graph.nodes[pf(e)[0]])),s=n.map((e=>pf(e)[0]));let o=s.map((e=>this.graph.nodes[e]));0===o.length&&(o=this._outputs);const{usedNodes:u,missingInputs:l,dynamicNode:c,syncInputs:h}=um(e,o,this.weightMap,this._initNodes),p=[...i,...this.graph.weights,...this._initNodes||[]].map((e=>({node:e,contexts:t.currentContext}))),d=Object.assign({},this.weightMap);Object.keys(e).forEach((t=>{const[n,r]=pf(t),a=[];a[r]=e[t],d[n]=a}));const f={},m=this.getFrozenTensorIds(d),g={};for(;p.length>0;){const e=this.processStack(i,p,t,d,g,m,s,f,u);await Promise.all(e)}null!=c||r||console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead.");const y=o.filter((e=>!pm(e)&&!lf(e.name,d,t))).map((e=>e.name));if(y.length>0){let e="";throw null!=c&&(e=`Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${h}]`),new Error(`Cannot compute the outputs [${y}] from the provided inputs [${a}]. Consider providing the following inputs: [${l}]. ${e}`)}return d}processStack(e,t,n,r,a,i,s,o,u){const l=[];for(;t.length>0;){const e=t.pop();n.currentContext=e.contexts;let c="";if("Enter"===e.node.op&&uf("isConstant",e.node,r,n)&&([c]=cf(e.node.name,n)),null==r[e.node.name]){const h=sm(e.node,r,n,this._resourceManager);c||([c]=cf(e.node.name,n));const p=n.currentContext;Nt(h)?l.push(h.then((l=>(r[c]=l,this.keepIntermediateTensors&&(this.clonedTensorsMap[c]=this.cloneTensorList(l)),n.currentContext=p,this.checkTensorForDisposal(c,e.node,r,n,i,s,o),this.processChildNodes(e.node,t,n,r,a,u),l)))):(r[c]=h,this.keepIntermediateTensors&&(this.clonedTensorsMap[c]=this.cloneTensorList(h)),this.checkTensorForDisposal(c,e.node,r,n,i,s,o),this.processChildNodes(e.node,t,n,r,a,u))}else this.processChildNodes(e.node,t,n,r,a,u)}return l}processChildNodes(e,t,n,r,a,i){e.children.forEach((e=>{const[s]=cf(e.name,n);!a[s]&&i.has(e.name)&&("Merge"===e.op?e.inputNames.some((e=>!!lf(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})):e.inputNames.every((e=>!!lf(e,r,n)))&&(a[s]=!0,t.push({contexts:n.currentContext,node:e})))}))}dispose(){Object.keys(this.weightMap).forEach((e=>this.weightMap[e].forEach((e=>e.dispose()))))}checkInputShapeAndType(e){Object.keys(e).forEach((t=>{const n=e[t],[r]=pf(t),a=this.graph.nodes[r];if(a.attrParams.shape&&a.attrParams.shape.value){const e=a.attrParams.shape.value;nt(e.length===n.shape.length&&n.shape.every(((t,n)=>-1===e[n]||e[n]===t)),(()=>`The shape of dict['${a.name}'] provided in model.execute(dict) must be [${e}], but was [${n.shape}]`))}a.attrParams.dtype&&a.attrParams.dtype.value&&nt(n.dtype===a.attrParams.dtype.value,(()=>`The dtype of dict['${a.name}'] provided in model.execute(dict) must be ${a.attrParams.dtype.value}, but was ${n.dtype}`))}))}mapInputs(e){var t,n;const r={};for(const a in e){const i=null===(n=null===(t=this._signature)||void 0===t?void 0:t.inputs)||void 0===n?void 0:n[a];null!=i?r[i.name]=e[a]:r[a]=e[a]}return r}checkInputs(e){const t=Object.keys(e).filter((e=>{const[t]=pf(e);return null==this.graph.nodes[t]}));if(t.length>0)throw new Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`)}mapOutputs(e){return e.map((e=>{var t,n;const r=null===(n=null===(t=this._signature)||void 0===t?void 0:t.outputs)||void 0===n?void 0:n[e];return null!=r?r.name:e}),{})}checkOutputs(e){e.forEach((e=>{const[t]=pf(e);if(!this.graph.nodes[t])throw new Error(`The output '${e}' is not found in the graph`)}))}}class gm{constructor(e={},t={}){this.hashTableNameToHandle=e,this.hashTableMap=t}addHashTable(e,t){this.hashTableNameToHandle[e]=t.handle,this.hashTableMap[t.id]=t}getHashTableHandleByName(e){return this.hashTableNameToHandle[e]}getHashTableById(e){return this.hashTableMap[e]}dispose(){for(const e in this.hashTableMap)this.hashTableMap[e].clearAndClose(),delete this.hashTableMap[e];for(const e in this.hashTableNameToHandle)this.hashTableNameToHandle[e].dispose(),delete this.hashTableNameToHandle[e]}}const ym="?tfjs-format=file",bm="model.json";class vm{constructor(e,t={},n=xo){this.modelUrl=e,this.loadOptions=t,this.version="n/a",this.io=n,null==t&&(this.loadOptions={}),this.resourceManager=new gm}get modelVersion(){return this.version}get inputNodes(){return this.executor.inputNodes}get outputNodes(){return this.executor.outputNodes}get inputs(){return this.executor.inputs}get outputs(){return this.executor.outputs}get weights(){return this.executor.weightMap}get metadata(){return this.artifacts.userDefinedMetadata}get modelSignature(){return this.signature}get modelStructuredOutputKeys(){return this.structuredOutputKeys}findIOHandler(){const e=this.modelUrl;if(null!=e.load)this.handler=e;else if(null!=this.loadOptions.requestInit)this.handler=this.io.browserHTTPRequest(e,this.loadOptions);else{const t=this.io.getLoadHandlers(e,this.loadOptions);if(0===t.length)t.push(this.io.browserHTTPRequest(e,this.loadOptions));else if(t.length>1)throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`);this.handler=t[0]}}load(){if(this.findIOHandler(),null==this.handler.load)throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented.");const e=this.handler.load();return Nt(e)?e.then((e=>this.loadSync(e))):this.loadSync(e)}loadSync(e){this.artifacts=e;const t=this.artifacts.modelTopology;let n=this.artifacts.signature;if(null!=this.artifacts.userDefinedMetadata){const e=this.artifacts.userDefinedMetadata;null!=e.signature&&(n=e.signature),null!=e.structuredOutputKeys&&(this.structuredOutputKeys=e.structuredOutputKeys)}this.signature=n,this.version=`${t.versions.producer}.${t.versions.minConsumer}`;const r=this.io.decodeWeights(this.artifacts.weightData,this.artifacts.weightSpecs);if(this.executor=new mm(Mf.Instance.transformGraph(t,this.signature)),this.executor.weightMap=this.convertTensorMapToTensorsMap(r),this.executor.resourceManager=this.resourceManager,null!=e.modelInitializer&&null!=e.modelInitializer.node){const t=Mf.Instance.transformGraph(e.modelInitializer);this.initializer=new mm(t),this.initializer.weightMap=this.executor.weightMap,this.initializer.resourceManager=this.resourceManager,this.initializerSignature=e.initializerSignature}return!0}async save(e,t){if("string"==typeof e){const t=this.io.getSaveHandlers(e);if(0===t.length)throw new Error(`Cannot find any save handlers for URL '${e}'`);if(t.length>1)throw new Error(`Found more than one (${t.length}) save handlers for URL '${e}'`);e=t[0]}if(null==e.save)throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined.");return e.save(this.artifacts)}addStructuredOutputNames(e){if(this.structuredOutputKeys){const t={};return(e instanceof Ka?[e]:e).forEach(((e,n)=>t[this.structuredOutputKeys[n]]=e)),t}return e}predict(e,t){const n=this.execute(e,this.outputNodes);return this.addStructuredOutputNames(n)}async predictAsync(e,t){const n=await this.executeAsync(e,this.outputNodes);return this.addStructuredOutputNames(n)}normalizeInputs(e){var t;if(!(e instanceof Ka||Array.isArray(e))){const n=null===(t=this.signature)||void 0===t?void 0:t.inputs;if(null!=n)for(const t in n){const r=n[t];null!=r.resourceId&&(e[t]=this.resourceIdToCapturedInput[r.resourceId])}return e}e=Array.isArray(e)?e:[e];const n=Object.keys(this.resourceIdToCapturedInput).length;if(e.length+n!==this.inputNodes.length)throw new Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length-n} non-resource placeholders, while there are ${e.length} input tensors provided.`);let r=0;return this.inputNodes.reduce(((t,n)=>{var a,i,s;const o=null===(s=null===(i=null===(a=this.signature)||void 0===a?void 0:a.inputs)||void 0===i?void 0:i[n])||void 0===s?void 0:s.resourceId;return t[n]=null!=o?this.resourceIdToCapturedInput[o]:e[r++],t}),{})}normalizeOutputs(e){return e=e||this.outputNodes,Array.isArray(e)?e:[e]}executeInitializerGraph(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.execute({},[]):this.initializer.execute({},Object.keys(this.initializerSignature.outputs))}async executeInitializerGraphAsync(){return null==this.initializer?[]:null==this.initializerSignature?this.initializer.executeAsync({},[]):this.initializer.executeAsync({},Object.keys(this.initializerSignature.outputs))}setResourceIdToCapturedInput(e){if(this.resourceIdToCapturedInput={},this.initializerSignature){const t=this.initializerSignature.outputs,n=Object.keys(t);for(let r=0;r<n.length;r++){const a=t[n[r]];this.resourceIdToCapturedInput[a.resourceId]=e[r]}}}execute(e,t){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(this.executeInitializerGraph()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=this.executor.execute(e,t);return n.length>1?n:n[0]}async executeAsync(e,t){null==this.resourceIdToCapturedInput&&this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()),e=this.normalizeInputs(e),t=this.normalizeOutputs(t);const n=await this.executor.executeAsync(e,t);return n.length>1?n:n[0]}getIntermediateTensors(){return this.executor.getIntermediateTensors()}disposeIntermediateTensors(){this.executor.disposeIntermediateTensors()}convertTensorMapToTensorsMap(e){return Object.keys(e).reduce(((t,n)=>(t[n]=[e[n]],t)),{})}dispose(){this.executor.dispose(),this.initializer&&(this.initializer.dispose(),this.resourceIdToCapturedInput&&Ao(this.resourceIdToCapturedInput)),this.resourceManager.dispose()}}async function wm(e,t={},n=xo){if(null==e)throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model");null==t&&(t={}),t.fromTFHub&&"string"==typeof e&&(e=function(e){return e.endsWith("/")||(e+="/"),`${e}${bm}${ym}`}(e));const r=new vm(e,t,n);return await r.load(),r}function _m(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&nt("complex64"!==e.dtype,(()=>`${t} does not support complex64 tensors in the CPU backend.`))}))}const xm=op;class km extends Qe{constructor(){super(),this.blockSize=48,this.firstUse=!0,this.data=new Ye(this,So())}nextDataId(){return km.nextDataId++}write(e,t,n){this.firstUse&&(this.firstUse=!1,Mt().get("IS_NODE")&&Mr("\n============================\nHi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. \n============================"));const r={id:this.nextDataId()};return this.data.set(r,{values:e,dtype:n,refCount:1}),r}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&bt(n[0])){const a=n.map((e=>Ca(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return{dataId:r,shape:e,dtype:t}}refCount(e){return this.data.has(e)?this.data.get(e).refCount:0}incRef(e){this.data.get(e).refCount++}decRef(e){this.data.has(e)&&this.data.get(e).refCount--}move(e,t,n,r,a){this.data.set(e,{values:t,dtype:r,refCount:a})}numDataIds(){return this.data.numDataIds()}async read(e){return this.readSync(e)}readSync(e){const{dtype:t,complexTensorInfos:n}=this.data.get(e);return"complex64"===t?Pd(this.readSync(n.real.dataId),this.readSync(n.imag.dataId)):function(e,t){if(Array.isArray(e))return e;if("float32"===t)return e instanceof Float32Array?e:new Float32Array(e);if("int32"===t)return e instanceof Int32Array?e:new Int32Array(e);if("bool"===t||"string"===t)return Uint8Array.from(new Int32Array(e));throw new Error(`Unknown dtype ${t}`)}(this.data.get(e).values,t)}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Na(e)));return nl(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return nl(e.shape,e.dtype,t)}makeOutput(e,t,n){return So().makeTensorFromTensorInfo(this.makeTensorInfo(t,n,e),this)}disposeData(e,t=!1){if(this.data.has(e)){if(this.data.get(e).refCount--,!t&&this.data.get(e).refCount>0)return!1;const{complexTensorInfos:n}=this.data.get(e);null!=n&&(this.disposeData(n.real.dataId,!0),this.disposeData(n.imag.dataId,!0)),this.data.delete(e)}return!0}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}async time(e){const t=Aa();return e(),{kernelMs:Aa()-t}}memory(){return{unreliable:!0,reasons:["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."]}}where(e){_m([e],"where");const t=this.readSync(e.dataId);return xm(e.shape,t)}dispose(){}floatPrecision(){return 32}epsilon(){return super.epsilon()}}function Tm(e){return(t,n,r,a,i)=>{const s=Bo(t,n),o=s.length,u=xt(s),l=ft(i,it(s)),c=t.length,h=n.length,p=xt(t),d=xt(n),f=Po(t,s),m=Po(n,s);if(f.length+m.length===0)for(let t=0;t<l.length;++t)l[t]=e(r[t%r.length],a[t%a.length]);else for(let t=0;t<l.length;++t){const n=Ct(t,o,u),i=n.slice(-c);f.forEach((e=>i[e]=0));const s=At(i,c,p),g=n.slice(-h);m.forEach((e=>g[e]=0));const y=At(g,h,d);l[t]=e(r[s],a[y])}return[l,s]}}function Em(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,o=n.makeTensorInfo(r.shape,"complex64");return n.data.get(o.dataId).complexTensorInfos={real:n.makeTensorInfo(r.shape,"float32",i),imag:n.makeTensorInfo(a.shape,"float32",s)},o}function Sm(e,t,n="float32"){if("complex64"===n)return Em({inputs:{real:Sm(e,t,"float32"),imag:Sm(e,t,"float32")},backend:e});const r=St(it(t),n);return e.makeTensorInfo(t,n,r)}function Im(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}km.nextDataId=0;const Am={kernelName:wn,backendName:"cpu",kernelFunc:Im};function Cm(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.real,i=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,i)}function Nm(e,t,n,r){if("int32"===r)return[t,"int32",Int32Array.from(e)];if("bool"===r){const r=Ia([0],n),[a,i]=Tm(((e,t)=>e!==t?1:0))(t,[],e,r,"bool");return[i,"bool",a]}throw new Error(`Error in Cast: failed to cast ${n} to ${r}`)}function Rm(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dtype:i}=r;if("complex64"===i){if("complex64"===a.dtype)return Im({inputs:{x:a},backend:n});const e=Sm(n,a.shape,a.dtype),t=Rm({inputs:{x:a},backend:n,attrs:{dtype:"float32"}}),r=Em({inputs:{real:t,imag:e},backend:n});return n.disposeIntermediateTensorInfo(e),n.disposeIntermediateTensorInfo(t),r}if("complex64"===a.dtype){const e=Cm({inputs:{input:a},backend:n}),t=Rm({inputs:{x:e},backend:n,attrs:{dtype:i}});return n.disposeIntermediateTensorInfo(e),t}if(!gt(a.dtype,i)){const e=Im({inputs:{x:a},backend:n});return{dataId:e.dataId,shape:e.shape,dtype:i}}const s=n.data.get(a.dataId).values,[o,u,l]=Nm(s,a.shape,a.dtype,i);return n.makeTensorInfo(o,u,l)}const Fm={kernelName:Kt,backendName:"cpu",kernelFunc:Rm};function Om(e,t,n,r){return null==n?({inputs:n,backend:a})=>{const{a:i,b:s}=n,o=a;_m([i,s],e);const u=o.data.get(i.dataId).values,l=o.data.get(s.dataId).values,c="string"===i.dtype?Jd(u):u,h="string"===i.dtype?Jd(l):l,p=r||i.dtype,[d,f]=t(i.shape,s.shape,c,h,p);return o.makeTensorInfo(f,p,d)}:({inputs:e,backend:a})=>{const{a:i,b:s}=e,o=a;if("complex64"===i.dtype||"complex64"===s.dtype){const e=Rm({inputs:{x:i},backend:o,attrs:{dtype:"complex64"}}),t=o.data.get(e.dataId),r=t.complexTensorInfos.real,a=t.complexTensorInfos.imag,u=o.data.get(r.dataId).values,l=o.data.get(a.dataId).values,c=Rm({inputs:{x:s},backend:o,attrs:{dtype:"complex64"}}),h=o.data.get(c.dataId),p=h.complexTensorInfos.real,d=h.complexTensorInfos.imag,f=o.data.get(p.dataId).values,m=o.data.get(d.dataId).values,[g,y,b]=n(i.shape,s.shape,u,l,f,m),v=o.makeTensorInfo(b,"float32",g),w=o.makeTensorInfo(b,"float32",y),_=Em({inputs:{real:v,imag:w},backend:o});return o.disposeIntermediateTensorInfo(e),o.disposeIntermediateTensorInfo(c),o.disposeIntermediateTensorInfo(v),o.disposeIntermediateTensorInfo(w),_}{const e=o.data.get(i.dataId).values,n=o.data.get(s.dataId).values,a=r||i.dtype,[u,l]=t(i.shape,s.shape,e,n,a);return o.makeTensorInfo(l,a,u)}}}function Mm(e){return(t,n,r,a,i,s)=>{const o=Bo(t,n),u=it(o),l=o.length,c=xt(o),h=ft("float32",u),p=ft("float32",u),d=Po(t,o),f=Po(n,o),m=Pd(r,a),g=Pd(i,s),y=t.length,b=xt(t),v=n.length,w=xt(n);if(d.length+f.length===0)for(let t=0;t<h.length;t++){const n=t%m.length,r=t%g.length,a=e(m[2*n],m[2*n+1],g[2*r],g[2*r+1]);h[t]=a.real,p[t]=a.imag}else for(let t=0;t<h.length;t++){const n=Ct(t,l,c),r=n.slice(-y);d.forEach((e=>r[e]=0));const a=At(r,y,b),i=n.slice(-v);f.forEach((e=>i[e]=0));const s=At(i,v,w),o=e(m[2*a],m[2*a+1],g[2*s],g[2*s+1]);h[t]=o.real,p[t]=o.imag}return[h,p,o]}}const $m=Tm(((e,t)=>e+t)),Dm=Mm(((e,t,n,r)=>({real:e+n,imag:t+r}))),Pm=Om(Bt,$m,Dm),Lm={kernelName:Bt,backendName:"cpu",kernelFunc:Pm};function Bm(e){return(t,n,r)=>{const a=ft(n,t.length);for(let n=0;n<t.length;++n)a[n]=e(t[n],r);return a}}function Um(e,t,n){return({inputs:r,attrs:a,backend:i})=>{const{x:s}=r;if(_m(s,e),"string"===s.dtype||"string"===n)throw new Error("unaryKernelFunc does not support string input/output");const o=i,u=o.data.get(s.dataId).values,l=it(s.shape),c=n||s.dtype,h=mt(c,l);for(let e=0;e<l;++e)h[e]=t(u[e],a);return o.makeTensorInfo(s.shape,c,h)}}const Wm=Bm((e=>Math.ceil(e)));function Vm(e,t,n,r){const a=mt(n,it(t));if(r&&"string"!==n){let t=0;e.forEach((e=>{const n=it(e.shape);a.set(e.vals,t),t+=n}))}else{let r=0;e.forEach((e=>{const i="string"===n?Jd(e.vals):e.vals;let s=0;for(let n=0;n<e.shape[0];++n){const o=n*t[1]+r;for(let t=0;t<e.shape[1];++t)a[o+t]=i[s++]}r+=e.shape[1]}))}return a}const zm=Tm(((e,t)=>e===t?1:0)),jm=Bm((e=>Math.exp(e))),Gm=(Hm=ln,Km=jm,"float32",({inputs:e,attrs:t,backend:n})=>{const{x:r}=e;if(_m(r,Hm),"string"===r.dtype)throw new Error("unaryKernelFunc does not support string input/output");const a=n,i=a.data.get(r.dataId).values,s="float32",o=Km(i,s,t);return a.makeTensorInfo(r.shape,s,o)});var Hm,Km;const qm=Bm((e=>Math.expm1(e))),Xm=Bm((e=>Math.floor(e))),Ym=Tm(((e,t)=>e>t?1:0)),Qm=Tm(((e,t)=>e>=t?1:0)),Jm=Tm(((e,t)=>e<t?1:0)),Zm=Tm(((e,t)=>e<=t?1:0)),eg=Bm((e=>Math.log(e)));function tg(e,t,n,r){const a=ft(r,it(n));for(let n=0;n<a.length;++n){const r=n*t;let i=e[r];for(let n=0;n<t;++n){const t=e[r+n];(Number.isNaN(t)||t>i)&&(i=t)}a[n]=i}return a}const ng=Tm(((e,t)=>Math.max(e,t))),rg=Tm(((e,t)=>Math.min(e,t))),ag=Tm(((e,t)=>e*t)),ig=Mm(((e,t,n,r)=>({real:e*n-t*r,imag:e*r+t*n}))),sg=Om($n,ag,ig),og={kernelName:$n,backendName:"cpu",kernelFunc:sg},ug=Tm(((e,t)=>e!==t?1:0));function lg(e,t,n,r,a){const i=t.length,s=it(t),o=xt(t),u=xt(a),l=ft(n,it(a));for(let t=0;t<s;++t){const n=Ct(t,i,o),a=new Array(n.length);for(let e=0;e<a.length;e++)a[e]=n[r[e]];l[At(a,i,u)]=e[t]}return l}function cg(e){const{inputs:t,attrs:n,backend:r}=e,{x:a}=t,{perm:i}=n;_m(a,"transpose");const s=a.shape.length,o=new Array(s);for(let e=0;e<o.length;e++)o[e]=a.shape[i[e]];const u=lg(r.data.get(a.dataId).values,a.shape,a.dtype,i,o);return{dataId:r.write(u,o,a.dtype),shape:o,dtype:a.dtype}}function hg(e,t){const n=e.slice(0,t);for(;n.length<t;)n.push(1);for(let r=t;r<e.length;r++)n[t-1]*=e[r];return n}var pg=Td;class dg{constructor(e,t,n,r,a,i,s,o,u,l){this.shape=e,this.shapeShape=t,this.values=n,this.valuesShape=r,this.valuesDType=a,this.defaultValue=i,this.defaultValueShape=s,this.rowPartitionValues=o,this.rowPartitionValuesShapes=u,this.rowPartitionTypes=Sd(l),this.raggedRank=Id(this.rowPartitionTypes)}getRowPartitionTypeByDimension(e){return this.rowPartitionTypes[0]===pg.FIRST_DIM_SIZE?this.rowPartitionTypes[e+1]:this.rowPartitionTypes[e]}getRowPartitionTensor(e){return this.rowPartitionTypes[0]===pg.FIRST_DIM_SIZE?this.rowPartitionValues[e+1]:this.rowPartitionValues[e]}getMaxWidth(e){const t=this.getRowPartitionTensor(e-1);switch(this.getRowPartitionTypeByDimension(e-1)){case pg.VALUE_ROWIDS:return dg.getMaxWidthValueRowID(t);case pg.ROW_SPLITS:return dg.getMaxWidthRowSplit(t);default:throw new Error(`Cannot handle partition type ${pg[this.getRowPartitionTypeByDimension(e-1)]}`)}}static getMaxWidthRowSplit(e){const t=e.length;if(0===t||1===t)return 0;let n=0;for(let r=0;r<t-1;++r){const t=e[r+1]-e[r];t>n&&(n=t)}return n}static getMaxWidthValueRowID(e){const t=e.length;if(0===t)return 0;let n=0,r=e[0],a=0;for(let i=1;i<t;++i){const t=e[i];t!==r&&(r=t,a=Math.max(i-n,a),n=i)}return Math.max(t-n,a)}tensorShapeFromTensor(e,t,n=!0){if(0===t.length){if(-1===e[0])return[];throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.")}return mg(e,n)}calculateOutputSize(e){const t=this.valuesShape;Ad(this.defaultValueShape,t);const n=this.tensorShapeFromTensor(this.shape,this.shapeShape),r=Ed(this.raggedRank,n,t);r[0]<0&&(r[0]=e);for(let e=1;e<=this.raggedRank;++e)r[e]<0&&(r[e]=this.getMaxWidth(e));return r}calculateFirstParentOutputIndex(e,t,n){const r=Math.min(e,n),a=[];let i=0;for(let e=0;e<r;++e,i+=t)a.push(i);for(let t=r;t<e;++t)a.push(-1);return nt(a.length===e,(()=>"Final length of result must be equal to firstDimension.")),a}calculateOutputIndexRowSplit(e,t,n,r){const a=e.length,i=[];for(let s=0;s<a-1;++s){const a=e[s+1]-e[s];let o=Math.min(r,a),u=t[s];-1===u&&(o=0);for(let e=0;e<o;++e)i.push(u),u+=n;for(let e=0;e<a-o;++e)i.push(-1)}if(a>0&&i.length!==e[a-1])throw new Error("Invalid row split size.");return i}calculateOutputIndexValueRowID(e,t,n,r){const a=e.length,i=[];if(0===a)return[];let s=0,o=e[0];if(o>=t.length)throw new Error(`Got currentValueRowId=${o}, which is not less than ${t.length}`);let u=t[o];i.push(u);for(let l=1;l<a;++l){const a=e[l];if(a===o)u>=0&&(++s,s<r?u+=n:u=-1);else{if(s=0,o=a,a>=t.length)throw new Error(`Got nextValueRowId=${a} which is not less than ${t.length}`);u=t[a]}i.push(u)}if(i.length!==e.length)throw new Error("Invalid row ids.");return i}calculateOutputIndex(e,t,n,r){const a=this.getRowPartitionTensor(e),i=this.getRowPartitionTypeByDimension(e);switch(i){case pg.VALUE_ROWIDS:return this.calculateOutputIndexValueRowID(a,t,n,r);case pg.ROW_SPLITS:if(a.length-1>t.length)throw new Error(`Row partition size is greater than output size: ${a.length-1} > ${t.length}`);return this.calculateOutputIndexRowSplit(a,t,n,r);default:throw new Error(`Unsupported partition type: ${pg[i]}`)}}getFirstDimensionSize(){const e=this.rowPartitionValues[0];if(0===this.rowPartitionTypes.length)throw new Error("No row_partition_types given.");const t=this.rowPartitionTypes[0];switch(t){case pg.FIRST_DIM_SIZE:return e[0];case pg.VALUE_ROWIDS:throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");case pg.ROW_SPLITS:return this.rowPartitionValuesShapes[0][0]-1;default:throw new Error(`Cannot handle type ${pg[t]}`)}}compute(){if(this.rowPartitionValues[0].length<=0)throw new Error("Invalid first partition input. Tensor requires at least one element.");const e=this.getFirstDimensionSize(),t=this.calculateOutputSize(e),n=new Array(this.raggedRank+1);n[n.length-1]=1;for(let e=n.length-2;e>=0;--e)n[e]=n[e+1]*t[e+1];const r=mg(t,!1),a=mt(this.valuesDType,it(r));if(n[0]*t[0]>0){let i=this.calculateFirstParentOutputIndex(e,n[0],t[0]);for(let e=1;e<=this.raggedRank;++e)i=this.calculateOutputIndex(e-1,i,n[e],t[e]);this.setOutput(this.raggedRank,i,a,r)}return[r,a]}setOutput(e,t,n,r){if(0===n.length)return;const a=this.values,i=n;let s=r.slice();s=s.slice(e+1);const o=it(s),u=t.length;let l=this.defaultValue;if(l.length!==o&&1!==l.length){const e=this.defaultValueShape;Io((()=>{const t=Bu(l,e),n=tl(t,s);l=n.dataSync()}))}let c=0,h=0,p=0;for(let e=0;e<=u;++e){let r=e<u?t[e]:-1;if(r!==p){if(h<p){const e=a.subarray(c*o);fg(i.subarray(h*o),e,(p-h)*o)}if(e>=u){const e=n.length;r=Math.floor(e/o)}if(r>p)if(1===this.defaultValue.length)i.subarray(p*o,r*o).fill(this.defaultValue[0]),p=r;else for(;r>p;)fg(i.slice(p*o),l,o),++p;r<0?(c=e+1,h=p):(c=e,h=p,p=h+1)}else++p}}}function fg(e,t,n){for(let r=0;r<n;r++)e[r]=t[r]}function mg(e,t){const n=[];for(let r of e){if(r<0){if(!t)throw new Error(`Dimension ${r} must be >= 0`);if(r<-1)throw new Error(`Dimension ${r} must be >= -1`);r=-1}n.push(r)}return n}function gg(e,t,n,r){if(e===t||e<t&&n<0||t<e&&n>1)return St(0,r);const a=St(Math.abs(Math.ceil((t-e)/n)),r);t<e&&1===n&&(n=-1),a[0]=e;for(let e=1;e<a.length;e++)a[e]=a[e-1]+n;return a}const yg=Bm((e=>1/Math.sqrt(e))),bg=Bm((e=>1/(1+Math.exp(-e)))),vg=Um(ir,(e=>1/(1+Math.exp(-e)))),wg={kernelName:ir,backendName:"cpu",kernelFunc:vg};function _g(e,t,n,r,a){const i=ru(r,t,n),s=it(n),o=xt(r);if(i){const n=au(t,o);return"string"===a?e.slice(n,n+s):e.subarray(n,n+s)}const u=nl(r,a,"string"===a?Jd(e):e),l=nl(n,a);for(let e=0;e<l.size;++e){const n=l.indexToLoc(e),r=n.map(((e,n)=>e+t[n]));l.set(u.get(...r),...n)}return"string"===a?Zd(l.values):l.values}function xg(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,size:s}=r;_m(a,"slice");const[o,u]=iu(a,i,s);Ko(a,o,u);const l=_g(n.data.get(a.dataId).values,o,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,l)}const kg={kernelName:ar,backendName:"cpu",kernelFunc:xg},Tg=Bm((e=>Math.sqrt(e))),Eg=Tm(((e,t)=>{const n=e-t;return n*n}));function Sg(e,t,n,r){const a=nl(e,t.dtype);for(let e=0;e<a.size;e++){const i=a.indexToLoc(e),s=new Array(i.length);for(let e=0;e<s.length;e++)s[e]=i[e]*n[e]+r[e];a.set(t.get(...s),...i)}return a}class Ig{constructor(e,t,n,r,a,i){this.separator=Ca(e),this.nGramWidths=t,this.leftPad=Ca(n),this.rightPad=Ca(r),this.padWidth=a,this.preserveShort=i}getPadWidth(e){return Math.min(this.padWidth<0?e-1:this.padWidth,e-1)}getNumNGrams(e,t){const n=this.getPadWidth(t);return Math.max(0,e+2*n-t+1)}createNGrams(e,t,n,r,a,i){for(let s=0;s<a;++s){const o=this.getPadWidth(i),u=Math.max(0,o-s),l=Math.max(0,o-(a-(s+1))),c=i-(u+l),h=t+(u>0?0:s-o);let p=0;p+=u*this.leftPad.length;for(let t=0;t<c;++t)p+=e[h+t].length;p+=l*this.rightPad.length,p+=(u+l+c-1)*this.separator.length,n[r+s]=new Uint8Array(p);const d=n[r+s];let f=0;const m=e=>e.forEach((e=>d[f++]=e));for(let e=0;e<u;++e)m(this.leftPad),m(this.separator);for(let t=0;t<c-1;++t)m(e[h+t]),m(this.separator);if(c>0){m(e[h+c-1]);for(let e=0;e<l;++e)m(this.separator),m(this.rightPad)}else{for(let e=0;e<l-1;++e)m(this.rightPad),m(this.separator);m(this.rightPad)}}}compute(e,t){const n=e.length,r=t.length;if(r>0){let e=t[0];if(0!==e)throw new Error(`First split value must be 0, got ${e}`);for(let a=1;a<r;++a){let r=t[a]>=e;if(r=r&&t[a]<=n,!r)throw new Error(`Invalid split value ${t[a]}, must be in [${e}, ${n}]`);e=t[a]}if(e!==n)throw new Error(`Last split value must be data size. Expected ${n}, got ${e}`)}const a=r-1,i=mt("int32",r);if(0===n||0===r){const e=new Array(n);for(let e=0;e<=a;++e)i[e]=0;return[e,i]}i[0]=0;for(let e=1;e<=a;++e){const n=t[e]-t[e-1];let r=0;this.nGramWidths.forEach((e=>{r+=this.getNumNGrams(n,e)})),this.preserveShort&&n>0&&0===r&&(r=1),i[e]=i[e-1]+r}const s=new Array(i[a]);for(let n=0;n<a;++n){const r=t[n];let a=i[n];if(this.nGramWidths.forEach((i=>{const o=t[n+1]-t[n],u=this.getNumNGrams(o,i);this.createNGrams(e,r,s,a,u,i),a+=u})),this.preserveShort&&a===i[n]){const i=t[n+1]-t[n];if(0===i)continue;const o=i+2*this.padWidth,u=1;this.createNGrams(e,r,s,a,u,o)}}return[s,i]}}function Ag(e,t,n,r,a,i,s,o){return new Ig(n,r,a,i,s,o).compute(e,t)}function Cg(e,t,n,r){if(!e.length)return;if(0===t.length){for(let t=0;t<e.length;++t)r.push(e.subarray(t,t+1));return}if(1===t.length){const a=t[0];let i=e.indexOf(a);for(;-1!==i;){const t=e.subarray(0,i);n&&0===t.length||r.push(t),i=(e=e.subarray(i+1)).indexOf(a)}return void(n&&0===e.length||r.push(e))}let a=0;for(let i=0;i<e.length+1;i++)if(i===e.length||-1!==t.indexOf(e[i])){const t=e.subarray(a,i);n&&0===t.length||r.push(t),a=i+1}}function Ng(e,t,n){const r=e.length,a=[];let i=0,s=0;const o=new Array(r);for(let u=0;u<r;++u){const r=a.length;Cg(e[u],t,n,a);const l=a.length-r;o[u]=l,i+=l,s=Math.max(s,l)}const u=mt("int32",2*i),l=new Array(i),c=[r,s];let h=0;for(let e=0;e<r;++e)for(let t=0;t<o[e];++t)u[2*h]=e,u[2*h+1]=t,l[h]=a[h],++h;return[u,l,c]}function Rg(e,t){const n=mt("int32",e.length);for(let r=0;r<e.length;++r)n[r]=Ea(e[r]).modulo(t).getLowBitsUnsigned();return n}const Fg=Tm(((e,t)=>e-t)),Og=Mm(((e,t,n,r)=>({real:e-n,imag:t-r}))),Mg=Om(wr,Fg,Og),$g={kernelName:wr,backendName:"cpu",kernelFunc:Mg},Dg=(e,t)=>{const n=t.value-e.value;return 0===n?e.index-t.index:n};function Pg(e,t,n=0,r=e.length-1){for(;r>n;){if(r-n>600){const a=r-n+1,i=t-n+1,s=Math.log(a),o=.5*Math.exp(2*s/3),u=.5*Math.sqrt(s*o*(a-o)/a)*Math.sign(i-a/2);Pg(e,t,Math.max(n,Math.floor(t-i*o/a+u)),Math.min(r,Math.floor(t+(a-i)*o/a+u)))}const a=e[t];let i=n,s=r;for(tt(e,n,t),Dg(e[r],a)>0&&tt(e,n,r);i<s;){for(tt(e,i,s),i++,s--;Dg(e[i],a)<0;)i+=1;for(;Dg(e[s],a)>0;)s-=1}0===Dg(e[n],a)?tt(e,n,s):(s+=1,tt(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}var Lg=Object.freeze({__proto__:null,simpleAbsImpl:function(e){const t=new Float32Array(e.length);for(let n=0;n<e.length;++n)t[n]=Math.abs(e[n]);return t},addImpl:$m,bincountImpl:function(e,t,n,r,a){const i=it(r),s=St(a,n);for(let n=0;n<e.length;n++){const r=e[n];if(r<0)throw new Error("Input x must be non-negative!");r>=a||(s[r]+=i>0?t[n]:1)}return s},bincountReduceImpl:function(e,t,n,r=!1){const a=e.shape[0],i=e.shape[1],s=nl([a,n],t.dtype);for(let o=0;o<a;o++)for(let a=0;a<i;a++){const i=e.get(o,a);if(i<0)throw new Error("Input x must be non-negative!");i>=n||(r?s.set(1,o,i):t.size>0?s.set(s.get(o,i)+t.get(o,a),o,i):s.set(s.get(o,i)+1,o,i))}return s},castImpl:Nm,ceilImpl:Wm,concatImpl:Vm,equalImpl:zm,expImpl:jm,expm1Impl:qm,floorImpl:Xm,gatherNdImpl:function(e,t,n,r,a,i,s,o,u){const l=nl([r,i],n);for(let n=0;n<r;n++){const r=[];let c=0;for(let t=0;t<a;t++){const i=e[n*a+t];c+=i*s[t],r.push(i)}if(c<0||c>=u/i)throw new Error(`Invalid indices: ${r} does not index into ${o}`);for(let e=0;e<i;e++)l.values[n*i+e]=t.get(...t.indexToLoc(c*i+e))}return l},gatherV2Impl:function(e,t,n){const r=nl(n,e.dtype);for(let n=0;n<r.size;++n){const a=r.indexToLoc(n).slice(),i=a[0],s=a[2],o=t.locToIndex([i,s]);a[2]=t.values[o];const u=e.locToIndex(a);0<=u&&u<e.values.length&&(r.values[n]=e.values[u])}return r},greaterImpl:Ym,greaterEqualImpl:Qm,lessImpl:Jm,lessEqualImpl:Zm,linSpaceImpl:function(e,t,n){const r=(t-e)/(n-1),a=St(n,"float32");a[0]=e;for(let e=1;e<a.length;e++)a[e]=a[e-1]+r;return a},logImpl:eg,maxImpl:tg,maximumImpl:ng,minimumImpl:rg,multiplyImpl:ag,negImpl:function(e,t,n){const r=Sa(-1,n);return ag([],t,r,e,n)},notEqualImpl:ug,prodImpl:function(e,t,n,r){const[a,i]=Dl(e,r),s=ti(t,"int32"),o=St(it(a),s),u=it(i);for(let e=0;e<o.length;++e){const t=e*u;let r=1;for(let e=0;e<u;++e)r*=n[t+e];o[e]=r}return{outVals:o,outShape:a,outDtype:s}},raggedGatherImpl:function(e,t,n,r,a,i,s,o){if(0===e.length)throw new Error("paramsNestedSplits must be non empty");if(0===t[0].length)throw new Error("Split tensors must not be scalars");if(function(e,t,n){e.forEach(((e,r)=>{if(e<0||e>=n){const a=Ct(r,t.length,xt(t)).join(",");throw new Error(`indices[${a}] = ${e} is not in [0, ${n})`)}}))}(i,s,t[0][0]-1),0===r.length)throw new Error("params.rank must be nonzero");const u=r[0],{outSplits:l,valueSlices:c,numValues:h}=function(e,t,n,r){const a=[];let i=0;const s=t.length-1+n.length,o=new Array(s).fill(null).map((()=>[0]));!function(e,t){for(let n=0;n<e.length;++n){const r=e[n],a=n===e.length-1?t:e[n+1].length;if(0===r.length)throw new Error("Ragged splits may not be empty");if(r[0]<0)throw new Error("Ragged splits must be non-negative");if(r[r.length-1]>a)throw new Error("Ragged splits must not point past values");for(let e=1;e<r.length;++e)if(r[e-1]>r[e])throw new Error("Ragged splits must be sorted in ascending order")}}(n,r);let u=1;for(let e=0;e<t.length-1;++e){u*=t[e];const n=t[e+1];for(let t=1;t<u+1;++t)o[e].push(t*n)}for(let r=0;r<e.length;++r){let s=e[r],u=e[r]+1;for(let e=0;e<n.length;++e){const r=n[e],a=e+t.length-1;if(a>=0){const e=o[a],t=e[e.length-1]-r[s];for(let e=s;e<u;++e)o[a].push(r[e+1]+t)}s=r[s],u=r[u]}u!==s&&(a.push([s,u]),i+=u-s)}return{outSplits:o,valueSlices:a,numValues:i}}(i,s,e,u),p=function(e){const t=[];for(let n=0;n<e.length;++n){const r=mt("int32",e[n].length);t.push(r),e[n].forEach(((e,t)=>r[t]=e))}return t}(l),d=function(e,t,n,r,a){const i=t.slice();i[0]=a;const s=mt(n,it(i)),o=e.length;return function(e,t,n,r,a,i){const s=hg(t,2)[1],o=hg(i,2)[1];let u=0;for(const t of n)for(let n=t[0];n<t[1];++n){for(let t=0;t<r;++t)a[u*o+t]=e[n*s+t];++u}}(e,t,r,0===o?0:o/t[0],s,i),[s,i]}(n,r,a,c,h);return[p,d[0],d[1]]},raggedRangeImpl:function(e,t,n,r,a,i,s){if(t.length>1)throw new Error("starts must be a scalar or vector");if(a.length>1)throw new Error("limits must be a scalar or vector");if(s.length>1)throw new Error("deltas must be a scalar or vector");const o=0===t.length,u=0===a.length,l=0===s.length,c=[];o||c.push(t[0]),u||c.push(a[0]),l||c.push(s[0]);for(let e=1;e<c.length;++e)if(c[e]!==c[e-1])throw new Error("starts, limits, and deltas must have the same shape");const h=0===c.length?1:c[0],p=mt("int32",h+1);p[0]=0;for(let t=0;t<h;++t){const n=o?e[0]:e[t],a=u?r[0]:r[t],s=l?i[0]:i[t];if(0===s)throw new Error("Requires delta != 0");let c;if(s>0&&a<n||s<0&&a>n)c=0;else if(c=Math.ceil(Math.abs((a-n)/s)),c>2147483647)throw new Error("Requires ((limit - start) / delta) <= 2147483647");p[t+1]=p[t]+c}const d=mt(n,p[h]);let f=0;for(let t=0;t<h;++t){const n=p[t+1]-p[t];let r=o?e[0]:e[t];const a=l?i[0]:i[t];for(let e=0;e<n;++e)d[f++]=r,r+=a}return[p,d]},raggedTensorToTensorImpl:function(e,t,n,r,a,i,s,o,u,l){return new dg(e,t,n,r,a,i,s,o,u,l).compute()},rangeImpl:gg,rsqrtImpl:yg,scatterImpl:function(e,t,n,r,a,i,s,o,u,l){const c=[r/a,a],h=e.values,p=t.values;if(0===r)return nl(n,t.dtype);const d=nl(c,t.dtype);"string"==typeof u||"number"==typeof u?d.values.fill(u):"boolean"==typeof u&&d.values.fill(+u);for(let e=0;e<i;e++){const i=[];let u=0;for(let t=0;t<s;t++){const n=h[e*s+t];i.push(n),u+=n*o[t]}if(u<0||u>=r/a)throw new Error(`Invalid indices: ${i} does not index into ${n}`);for(let n=0;n<a;n++)l?d.values[u*a+n]+=p[e*a+n]:d.values[u*a+n]=0===t.rank?p[0]:p[e*a+n]}return d},sigmoidImpl:bg,sliceImpl:_g,sparseFillEmptyRowsImpl:function(e,t,n,r,a,i,s){const o=t[0],u=i[0],l=new Array(u),c=new Array(o),h=t[1];if(0===u){if(0!==o)throw new Error(Wd(o));return[mt(n,0),[0,h],mt(a,0),l,c]}let p=!0,d=0;const f=new Array(u).fill(0);for(let t=0;t<o;++t){const n=e[t*h];if(n<0)throw new Error(Vd(t,n));if(n>=u)throw new Error(zd(t,n,u));++f[n],p=p&&n>=d,d=n}let m=!0;for(let e=0;e<u;++e){const t=0===f[e];l[e]=t,m=m&&!t,f[e]=Math.max(f[e],1),e>0&&(f[e]+=f[e-1])}if(m&&p){const t=e,n=r;for(let e=0;e<o;++e)c[e]=e;return[t,[o,h],n,l,c]}{const t=f[u-1],i=mt(n,t*h),p=mt(a,t),d=new Array(u).fill(0);for(let t=0;t<o;++t){const n=e[t*h],a=d[n],s=(0===n?0:f[n-1])+a;d[n]++;for(let n=0;n<h;++n)i[s*h+n]=e[t*h+n];p[s]=r[t],c[t]=s}for(let e=0;e<u;++e)if(0===d[e]){const t=0===e?0:f[e-1];i[t*h+0]=e;for(let e=1;e<h;++e)i[t*h+e]=0;p[t]=s}return[i,[t,h],p,l,c]}},sparseReshapeImpl:function(e,t,n,r,a){const i=it(r),s=t[0],o=a.length,u=[];let l=1,c=-1;for(let e=0;e<o;++e){const t=a[e];if(-1===t){if(-1!==c)throw new Error(jd(c,e));c=e,u.push(1)}else{if(t<0)throw new Error(Gd(e,t));l*=t,u.push(t)}}if(-1!==c){if(l<=0)throw new Error("reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero");const e=Math.trunc(i/l);if(l*e!==i)throw new Error(Hd(r,u));u[c]=e}if(it(u)!==i)throw new Error(Kd(r,u));const h=r.length,p=[];if(h>0){p[h-1]=1;for(let e=h-2;e>=0;--e)p[e]=p[e+1]*r[e+1]}const d=[];if(o>0){d[o-1]=1;for(let e=o-2;e>=0;--e)d[e]=d[e+1]*u[e+1]}const f=mt(n,s*o);for(let t=0;t<s;++t){let n=0;for(let r=0;r<h;++r)n+=e[t*h+r]*p[r];for(let e=0;e<o;++e)f[t*o+e]=Math.trunc(n/d[e]),n%=d[e]}return[f,[s,o],u]},sparseSegmentReductionImpl:function(e,t,n,r,a,i=!1,s=0){const o=r.length,u=[t[0],e.length/t[0]],l=u[1],c=o>0?a[o-1]+1:0;if(c<0)throw new Error("segment ids must be >= 0");const h=t.slice();h[0]=c;const p=mt(n,h.reduce(((e,t)=>e*t),1));if(0===o)return c>0&&p.fill(s),[p,h];if(c<=0)throw new Error("segment ids must be >= 0");let d=0,f=1,m=0,g=a[d];for(;;){let t=0;if(f<o){if(t=a[f],g===t){++f;continue}if(g>=t)throw new Error("segment ids are not increasing")}if(g<0||g>=c)throw new Error(qd(g,c));g>m&&p.fill(s,m*l,g*l);for(let t=d;t<f;++t){const n=r[t];if(n<0||n>=u[0])throw new Error(Xd(t,r[t],u[0]));for(let t=0;t<l;t++)p[g*l+t]+=e[n*l+t]}if(i)for(let e=0;e<l;e++)p[g*l+e]/=f-d;if(d=f,++f,m=g+1,g=t,f>o)break}return m<c&&p.fill(s,m*l,c*l),[p,h]},sqrtImpl:Tg,squaredDifferenceImpl:Eg,stridedSliceImpl:Sg,stringNGramsImpl:Ag,stringSplitImpl:Ng,stringToHashBucketFastImpl:Rg,subImpl:Fg,tileImpl:function(e,t){const n=new Array(e.rank);for(let r=0;r<n.length;r++)n[r]=e.shape[r]*t[r];const r=nl(n,e.dtype);for(let t=0;t<r.values.length;++t){const n=r.indexToLoc(t),a=new Array(e.rank);for(let t=0;t<a.length;t++)a[t]=n[t]%e.shape[t];const i=e.locToIndex(a);r.values[t]=e.values[i]}return r},topKImpl:function(e,t,n,r,a){const i=t[t.length-1],[s,o]=[e.length/i,i],u=ft(n,s*r),l=ft("int32",s*r);for(let t=0;t<s;t++){const n=t*o,i=e.subarray(n,n+o);let s=new Array(i.length);i.forEach(((e,t)=>s[t]={value:e,index:t})),r<s.length&&(Pg(s,r),s=s.slice(0,r)),a&&s.sort(Dg);const c=t*r,h=u.subarray(c,c+r),p=l.subarray(c,c+r);for(let e=0;e<r;e++)h[e]=s[e].value,p[e]=s[e].index}const c=t.slice();return c[c.length-1]=r,[nl(c,n,u),nl(c,"int32",l)]},transposeImpl:lg,uniqueImpl:function(e,t,n,r){const a=pt(t,n)[0],i=[1,n[0],1];for(let e=0;e<a;e++)i[0]*=n[e];i[1]=n[a];for(let e=a+1;e<n.length;e++)i[2]*=n[e];const s={},o=new Int32Array(n[a]),u=new ja(i,r,e),l=[],c=1===i[0]&&1===i[2];for(let t=0;t<n[a];t++){let n;if(c)n=e[t].toString();else{const e=[];for(let n=0;n<i[0];n++)for(let r=0;r<i[2];r++)e.push(u.get(n,t,r));n=e.join(",")}if(void 0!==s[n])o[t]=s[n];else{const e=Object.keys(s).length;s[n]=e,o[t]=e,l.push(t)}}const h=i.slice();h[1]=Object.keys(s).length;const p=new ja(h,r);l.forEach(((e,t)=>{for(let n=0;n<i[0];n++)for(let r=0;r<i[2];r++)p.set(u.get(n,e,r),n,t,r)}));const d=n.slice();return d[a]=h[1],{outputValues:p.values,outputShape:d,indices:o}}});function Bg(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{shape:i}=r,s=it(a.shape),o=ht(i,s),u=it(o);nt(s===u,(()=>`The new shape (${o}) has ${u} elements and the old shape (${a.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`)),n.incRef(a.dataId);const l=n.data.get(a.dataId);if(null!=l.complexTensorInfos){const e=l.complexTensorInfos.real,t=l.complexTensorInfos.imag;e.shape=o,t.shape=o}return{dataId:a.dataId,shape:o,dtype:a.dtype}}Fo("cpu",(()=>new km),1);const Ug={kernelName:Xn,backendName:"cpu",kernelFunc:Bg},Wg={kernelName:Qn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r;_m(a,"resizeBilinear");const u=xt(a.shape),[l,c]=o,[h,p,d,f]=a.shape,m=n.data.get(a.dataId).values,g=new Float32Array(it([h,l,c,f])),y=[i&&l>1?p-1:p,i&&c>1?d-1:d],b=[i&&l>1?l-1:l,i&&c>1?c-1:c];let v=0;const w=y[0]/b[0],_=y[1]/b[1];for(let e=0;e<h;e++)for(let t=0;t<l;t++){let n;n=s?w*(t+.5)-.5:w*t;const r=Math.max(0,Math.floor(n)),a=n-r,i=Math.min(p-1,Math.ceil(n)),o=e*u[0]+r*u[1],l=e*u[0]+i*u[1];for(let e=0;e<c;e++){let t;t=s?_*(e+.5)-.5:_*e;const n=Math.max(0,Math.floor(t)),r=t-n,i=Math.min(d-1,Math.ceil(t)),c=o+n*u[2],h=l+n*u[2],p=o+i*u[2],y=l+i*u[2];for(let e=0;e<f;e++){const t=m[c+e],n=m[h+e],i=t+(m[p+e]-t)*r,s=i+(n+(m[y+e]-n)*r-i)*a;g[v++]=s}}}return n.makeTensorInfo([h,l,c,f],"float32",g)}},Vg=Tm(((e,t)=>e/t)),zg=Om(sn,Vg),jg={kernelName:sn,backendName:"cpu",kernelFunc:zg},Gg={kernelName:zn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,constantValue:s}=r;_m(a,"pad");const o=i.map(((e,t)=>e[0]+a.shape[t]+e[1])),u=i.map((e=>e[0])),l=n.data.get(a.dataId).values,c=it(a.shape),h=a.shape.length,p=xt(a.shape),d=it(o),f=o.length,m=xt(o),g=ft(a.dtype,d);0!==s&&g.fill(s);for(let e=0;e<c;e++)g[At(Ct(e,h,p).map(((e,t)=>e+u[t])),f,m)]=l[e];return{dataId:n.write(g,o,a.dtype),shape:o,dtype:a.dtype}}};function Hg(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dataFormat:u,dilations:l,dimRoundingMode:c}=r;_m([a,i],"conv2d");const h=Pu(u),p=Iu(a.shape,i.shape,s,l,o,c,!1,h),d=p.filterHeight,f=p.filterWidth,m=p.dilationHeight,g=p.dilationWidth,y=p.padInfo.left,b=p.padInfo.top,v="channelsLast"===p.dataFormat,w=new ja(p.outShape,a.dtype),_=xt(a.shape),x=xt(i.shape),k=_[0],T=v?_[1]:_[2],E=v?_[2]:1,S=v?1:_[1],I=w.strides[0],A=v?w.strides[1]:w.strides[2],C=v?w.strides[2]:1,N=v?1:w.strides[1],R=n.data.get(a.dataId).values,F=n.data.get(i.dataId).values,O=w.values;for(let e=0;e<p.batchSize;++e){const t=e*k,n=e*I;for(let e=0;e<p.outHeight;++e){const r=n+e*A,a=e*p.strideHeight-b;for(let e=0;e<d;++e){const n=a+e*m;if(n<0||n>=p.inHeight)continue;const i=e*x[0],s=t+n*T;for(let e=0;e<p.outWidth;++e){const t=r+e*C,n=e*p.strideWidth-y;for(let e=0;e<f;++e){const r=n+e*g;if(r<0||r>=p.inWidth)continue;const a=s+r*E;let o=i+e*x[1];for(let e=0;e<p.inChannels;++e){const n=R[a+e*S];for(let e=0;e<p.outChannels;++e)O[t+e*N]+=n*F[o+e];o+=p.outChannels}}}}}}return n.makeTensorInfo(w.shape,w.dtype,O)}const Kg={kernelName:Qt,backendName:"cpu",kernelFunc:Hg},qg=Um(on,(e=>e>=0?e:Math.exp(e)-1)),Xg=Tm(((e,t)=>e<0?t*e:e)),Yg=Um(qn,(e=>Math.max(0,e))),Qg={kernelName:qn,backendName:"cpu",kernelFunc:Yg},Jg=Um(Jn,(e=>Math.min(Math.max(0,e),6))),Zg={kernelName:Jn,backendName:"cpu",kernelFunc:Jg};function ey(e,t,n,r,a){if("linear"===n)return Im({inputs:{x:t},backend:e});if("relu"===n)return Yg({inputs:{x:t},backend:e});if("elu"===n)return qg({inputs:{x:t},backend:e});if("relu6"===n)return Jg({inputs:{x:t},backend:e});if("prelu"===n)return function(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t;_m([r,a],"prelu");const i=n.data.get(r.dataId).values,s=n.data.get(a.dataId).values,[o,u]=Xg(r.shape,a.shape,i,s,"float32");return n.makeTensorInfo(u,"float32",o)}({inputs:{x:t,alpha:r},backend:e});if("leakyrelu"===n)return function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{alpha:i}=r;_m([a],"leakyRelu");const s=it(a.shape),o=n.data.get(a.dataId).values,u=ft("float32",s);for(let e=0;e<o.length;e++)u[e]=o[e]<0?i*o[e]:o[e];return n.makeTensorInfo(a.shape,"float32",u)}({inputs:{x:t},backend:e,attrs:{alpha:a}});if("sigmoid"===n)return vg({inputs:{x:t},backend:e});throw new Error(`Activation ${n} has not been implemented for the CPU backend.`)}const ty={kernelName:Fr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:h,dimRoundingMode:p,activation:d,leakyreluAlpha:f}=r;let m=Hg({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:h,dimRoundingMode:p}});if(s){const e=m;if("NCHW"===c&&1===s.shape.length&&1!==s.shape[0]){const e=Bg({inputs:{x:s},backend:n,attrs:{shape:[s.shape[0],1,1]}});m=Pm({inputs:{a:m,b:e},backend:n}),n.disposeIntermediateTensorInfo(e)}else m=Pm({inputs:{a:m,b:s},backend:n});n.disposeIntermediateTensorInfo(e)}if(d){const e=m;if("NCHW"===c&&"prelu"===d&&1===o.shape.length&&1!==o.shape[0]){const e=Bg({inputs:{x:o},backend:n,attrs:{shape:[o.shape[0],1,1]}});m=ey(n,m,d,e,f),n.disposeIntermediateTensorInfo(e)}else m=ey(n,m,d,o,f);n.disposeIntermediateTensorInfo(e)}return m}};function ny(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dilations:u,dimRoundingMode:l}=r;_m([a,i],"depthwiseConv2DNative");const c=xt(a.shape),h=xt(i.shape);let p=u;null==p&&(p=[1,1]),nt($u(s,p),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${p}'`));const d=Iu(a.shape,i.shape,s,p,o,l,!0),{filterHeight:f,filterWidth:m,dilationHeight:g,dilationWidth:y,padInfo:b}=d,v=b.left,w=b.top,_=d.outChannels/d.inChannels,x=new ja(d.outShape,a.dtype),k=n.data.get(a.dataId).values,T=n.data.get(i.dataId).values,E=x.values;for(let e=0;e<d.batchSize;++e){const t=e*c[0],n=e*x.strides[0];for(let e=0;e<d.outHeight;++e){const r=n+e*x.strides[1],a=e*d.strideHeight-w;for(let e=0;e<f;++e){const n=a+e*g;if(n<0||n>=d.inHeight)continue;const i=e*h[0],s=t+n*c[1];for(let e=0;e<d.outWidth;++e){const t=r+e*x.strides[2],n=e*d.strideWidth-v;for(let e=0;e<m;++e){const r=n+e*y;if(r<0||r>=d.inWidth)continue;const a=i+e*h[1],o=s+r*d.inChannels;let u=t,l=a;for(let e=0;e<d.inChannels;++e){const t=k[o+e];for(let e=0;e<_;++e)E[u+e]+=t*T[l+e];u+=_,l+=_}}}}}}return n.makeTensorInfo(x.shape,x.dtype,x.values)}const ry={kernelName:an,backendName:"cpu",kernelFunc:ny},ay={kernelName:Or,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:h,dimRoundingMode:p,activation:d,leakyreluAlpha:f}=r;let m=ny({inputs:{x:a,filter:i},backend:n,attrs:{strides:u,pad:l,dataFormat:c,dilations:h,dimRoundingMode:p}});if(s){const e=m;m=Pm({inputs:{a:m,b:s},backend:n}),n.disposeIntermediateTensorInfo(e)}if(d){const e=m;m=ey(n,m,d,o,f),n.disposeIntermediateTensorInfo(e)}return m}},iy={kernelName:ur,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,paddings:s}=r;_m([a],"spaceToBatchND");const o=it(i),u=[[0,0]];u.push(...s);for(let e=1+i.length;e<a.shape.length;++e)u.push([0,0]);const l=Gg.kernelFunc({inputs:{x:a},backend:n,attrs:{paddings:u,constantValue:0}}),c=Fd(l.shape,i,o,!1),h=Od(c.length,i.length,!1),p=Md(l.shape,i,o,!1),d=Bg({inputs:{x:l},backend:n,attrs:{shape:c}}),f=cg({inputs:{x:d},backend:n,attrs:{perm:h}}),m=Bg({inputs:{x:f},backend:n,attrs:{shape:p}});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),m}},sy={kernelName:Ht,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,crops:s}=r;_m([a],"batchToSpaceND");const o=i.reduce(((e,t)=>e*t)),u=Fd(a.shape,i,o),l=Od(u.length,i.length),c=Md(a.shape,i,o),h=$d(s,i.length),p=Dd(c,s,i.length),d=Bg({inputs:{x:a},backend:n,attrs:{shape:u}}),f=cg({inputs:{x:d},backend:n,attrs:{perm:l}}),m=Bg({inputs:{x:f},backend:n,attrs:{shape:c}}),g=xg({inputs:{x:m},backend:n,attrs:{begin:h,size:p}});return n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}},oy={kernelName:gr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,end:s,strides:o,beginMask:u,endMask:l,ellipsisMask:c,newAxisMask:h,shrinkAxisMask:p}=r;_m(a,"stridedSlice");const{finalShapeSparse:d,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:y,begin:b,end:v,strides:w}=su(a.shape,i,s,o,u,l,c,h,p);let _;if(m)_=Bg({inputs:{x:a},backend:n,attrs:{shape:f}});else if(g||y){nt(a.shape.length>=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=qo(b,v,w),t=xg({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});_=Bg({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else{const e=Sg(d,n.bufferSync(a),w,b);_=n.makeTensorInfo(f,e.dtype,e.values)}return _}};function uy(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r,i=pt(a,t[0].shape)[0];xd(t.map((e=>e.shape)),i);let s=kd(t.map((e=>e.shape)),i);if(0===it(s))return n.makeTensorInfo(s,t[0].dtype,[]);const o=t.filter((e=>it(e.shape)>0));if(1===o.length)return Im({inputs:{x:o[0]},backend:n});if("complex64"===o[0].dtype){const e=o.map((e=>Cm({inputs:{input:e},backend:n}))),t=o.map((e=>function(e){const{inputs:t,backend:n}=e,{input:r}=t,a=n.data.get(r.dataId).complexTensorInfos.imag,i=n.data.get(a.dataId).values;return n.makeTensorInfo(a.shape,a.dtype,i)}({inputs:{input:e},backend:n}))),r=uy({inputs:e,backend:n,attrs:{axis:i}}),a=uy({inputs:t,backend:n,attrs:{axis:i}}),s=Em({inputs:{real:r,imag:a},backend:n});return e.forEach((e=>n.disposeIntermediateTensorInfo(e))),t.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(r),n.disposeIntermediateTensorInfo(a),s}const u=o.map((e=>{const t=it(e.shape.slice(i));return Bg({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),l=u.map((e=>({vals:n.data.get(e.dataId).values,shape:e.shape})));s=kd(u.map((e=>e.shape)),1);const c=1===u[0].shape[0],h=Vm(l,s,t[0].dtype,c),p=kd(o.map((e=>e.shape)),i),d=n.makeTensorInfo(p,t[0].dtype,h);return u.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}const ly={kernelName:Yt,backendName:"cpu",kernelFunc:uy};function cy(e){const{inputs:t,backend:n,attrs:r}=e,{input:a}=t,{dim:i}=r,s=a.shape.length,o=a.shape.slice();let u=i;return i<0&&(nt(-(s+1)<=i,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+i+1),o.splice(u,0,1),Bg({inputs:{x:a},backend:n,attrs:{shape:o}})}const hy={kernelName:Vn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(1===t.length)return cy({inputs:{input:t[0]},backend:n,attrs:{dim:a}});const i=t[0].shape,s=t[0].dtype;t.forEach((e=>{rt(i,e.shape,"All tensors passed to stack must have matching shapes"),nt(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],u=uy({inputs:t.map((e=>{const t=cy({inputs:{input:e},backend:n,attrs:{dim:a}});return o.push(t),t})),backend:n,attrs:{axis:a}});return o.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}},py={kernelName:Jt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{inputShape:s,strides:o,pad:u,dataFormat:l,dimRoundingMode:c}=r;_m([a,i],"conv2dBackpropInput");const h=xt(i.shape),p=xt(a.shape);let d=Pu(l);const f=Iu(s,i.shape,o,1,u,c,!1,d),m=new ja(f.inShape,"float32"),g=m.values,y=n.data.get(a.dataId).values,b=n.data.get(i.dataId).values,[v,w,_]=h,{batchSize:x,filterHeight:k,filterWidth:T,inChannels:E,inHeight:S,inWidth:I,outChannels:A,outHeight:C,outWidth:N,strideHeight:R,strideWidth:F}=f;d=f.dataFormat;const O=k-1-f.padInfo.top,M=T-1-f.padInfo.left,$="channelsLast"===d,D=m.strides[0],P=$?m.strides[1]:m.strides[2],L=$?m.strides[2]:1,B=$?1:m.strides[1],U=p[0],W=$?p[1]:p[2],V=$?p[2]:1,z=$?1:p[1];for(let e=0;e<x;++e)for(let t=0;t<E;++t)for(let n=0;n<S;++n){const r=n-O,a=Math.max(0,Math.ceil(r/R)),i=Math.min(C,(k+r)/R);for(let s=0;s<I;++s){const o=s-M,u=Math.max(0,Math.ceil(o/F)),l=Math.min(N,(T+o)/F);let c=0;for(let n=a;n<i;++n){const a=n*R-r;for(let r=u;r<l;++r){const i=U*e+W*n+V*r,s=v*(k-1-a)+w*(T-1-(r*F-o))+_*t;for(let e=0;e<A;++e)c+=y[i+z*e]*b[s+e]}}g[D*e+P*n+L*s+B*t]=c}}return n.makeTensorInfo(m.shape,m.dtype,m.values)}},dy={kernelName:nn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:i,boxInd:s}=t,{cropSize:o,method:u,extrapolationValue:l}=r,[c,h,p,d]=a.shape,f=i.shape[0],[m,g]=o,y=nl([f,m,g,d],"float32"),b=n.data.get(i.dataId).values,v=n.data.get(s.dataId).values,w=n.data.get(a.dataId).values,_=xt(a.shape),x=xt(y.shape);for(let e=0;e<f;e++){const t=4*e,n=b[t],r=b[t+1],a=b[t+2],i=b[t+3],s=v[e];if(s>=c)continue;const o=m>1?(a-n)*(h-1)/(m-1):0,f=g>1?(i-r)*(p-1)/(g-1):0;for(let t=0;t<m;t++){const c=m>1?n*(h-1)+t*o:.5*(n+a)*(h-1);if(c<0||c>h-1)for(let n=0;n<g;n++)for(let r=0;r<d;r++){const a=r+n*x[2]+t*x[1]+e*x[0];y.values[a]=l}else if("bilinear"===u){const n=Math.floor(c),a=Math.ceil(c),o=c-n;for(let u=0;u<g;u++){const c=g>1?r*(p-1)+u*f:.5*(r+i)*(p-1);if(c<0||c>p-1){for(let n=0;n<d;n++){const r=n+u*x[2]+t*x[1]+e*x[0];y.values[r]=l}continue}const h=Math.floor(c),m=Math.ceil(c),b=c-h;for(let r=0;r<d;r++){let i=r+h*_[2]+n*_[1]+s*_[0];const l=w[i];i=r+m*_[2]+n*_[1]+s*_[0];const c=w[i];i=r+h*_[2]+a*_[1]+s*_[0];const p=w[i];i=r+m*_[2]+a*_[1]+s*_[0];const d=l+(c-l)*b,f=p+(w[i]-p)*b;i=r+u*x[2]+t*x[1]+e*x[0],y.values[i]=d+(f-d)*o}}}else for(let n=0;n<g;++n){const a=g>1?r*(p-1)+n*f:.5*(r+i)*(p-1);if(a<0||a>p-1){for(let r=0;r<d;r++){const a=r+n*x[2]+t*x[1]+e*x[0];y.values[a]=l}continue}const o=Math.round(a),u=Math.round(c);for(let r=0;r<d;r++){const a=r+o*_[2]+u*_[1]+s*_[0],i=r+n*x[2]+t*x[1]+e*x[0];y.values[i]=w[a]}}}}return n.makeTensorInfo(y.shape,y.dtype,y.values)}},fy={kernelName:Zn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:i}=r;_m(a,"reverse");const s=a.shape.length,o=pt(i,a.shape);if(0===s)return Im({inputs:{x:a},backend:n});const u=new ja(a.shape,a.dtype),l=n.bufferSync(a);for(let e=0;e<u.size;e++){const t=u.indexToLoc(e),n=t.slice();o.forEach((e=>n[e]=a.shape[e]-1-n[e])),u.set(l.get(...n),...t)}return n.makeTensorInfo(u.shape,u.dtype,u.values)}},my={kernelName:Sr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:i}=r;i<0&&(i+=a.shape.length);const s=a.shape.length,o=a.shape[i],u=new Array(s-1);let l=0;for(let e=0;e<s;e++)e!==i&&(u[l++]=a.shape[e]);const c=new Array(s).fill(0),h=a.shape.slice();h[i]=1;const p=new Array(o);for(let e=0;e<p.length;e++){c[i]=e;const t=xg({inputs:{x:a},backend:n,attrs:{begin:c,size:h}});p[e]=Bg({inputs:{x:t},backend:n,attrs:{shape:u}}),n.disposeIntermediateTensorInfo(t)}return p}},gy={kernelName:zt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;_m(a,"argMax");let s=pt(i,a.shape);const o=Bl(s,a.shape.length);let u=a;const l=[];null!=o&&(u=cg({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=Wl(s.length,u.shape.length)),s=[s[0]],Ll("argMax",s,u.shape.length);const[c,h]=Dl(u.shape,s),p=St(it(c),"int32"),d=it(h),f=n.data.get(u.dataId).values;for(let e=0;e<p.length;++e){const t=e*d;let n=f[t],r=0;for(let e=0;e<d;++e){const a=f[t+e];a>n&&(n=a,r=e)}p[e]=r}return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.makeTensorInfo(c,"int32",p)}};function yy(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r;let o;_m(a,"sum"),o="bool"===a.dtype?Rm({inputs:{x:a},backend:n,attrs:{dtype:"int32"}}):Im({inputs:{x:a},backend:n});const u=o.shape.length,l=pt(i,o.shape),c=Bl(l,u);let h=l,p=o;null!=c&&(p=cg({inputs:{x:o},backend:n,attrs:{perm:c}}),h=Wl(h.length,u)),Ll("sum",h,p.shape.length);const[d,f]=Dl(p.shape,h);let m=Sm(n,d,ti(p.dtype,"int32"));const g=it(f),y=n.data.get(m.dataId).values,b=n.data.get(p.dataId).values;for(let e=0;e<y.length;++e){const t=e*g;let n=0;for(let e=0;e<g;++e)n+=b[t+e];y[e]=n}if(s){const e=m;m=Bg({inputs:{x:m},backend:n,attrs:{shape:Pl(m.shape,l)}}),n.disposeIntermediateTensorInfo(e)}return n.disposeIntermediateTensorInfo(o),null!=c&&n.disposeIntermediateTensorInfo(p),m}const by={kernelName:Rn,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r,o=pt(i,a.shape),u=it(Dl(a.shape,o)[1]),l=[],c=n.makeTensorInfo([],"float32",new Float32Array([u]));l.push(c);const h=Rm({inputs:{x:a},backend:n,attrs:{dtype:"float32"}});l.push(h);const p=zg({inputs:{a:h,b:c},backend:n});l.push(p);const d=yy({inputs:{x:p},backend:n,attrs:{axis:i,keepDims:s}});return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),d}},vy={kernelName:cr,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:i}=r,s=a.shape.length;let o=i;if(-1===o&&(o=s-1),o!==s-1)throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${s} and dim was ${o}`);const u=pt([o],a.shape),l=function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:i,keepDims:s}=r,o=n;let u=a.shape;const l=u.length,c=pt(i,u);let h=c;const p=Bl(h,l);let d=o.data.get(a.dataId).values;if(null!=p){const e=new Array(l);for(let t=0;t<e.length;t++)e[t]=u[p[t]];d=lg(d,u,a.dtype,p,e),h=Wl(h.length,l),u=e}_m(a,"max"),Ll("max",h,l);const[f,m]=Dl(u,h),g=tg(d,it(m),f,a.dtype),y=o.write(g,f,a.dtype);let b=f;return s&&(b=Pl(f,c)),{dataId:y,shape:b,dtype:a.dtype}}({inputs:{x:a},backend:n,attrs:{reductionIndices:u,keepDims:!1}}),c=Pl(l.shape,u),h=Bg({inputs:{x:l},backend:n,attrs:{shape:c}}),p=Mg({inputs:{a,b:h},backend:n}),d=Gm({inputs:{x:p},backend:n}),f=yy({inputs:{x:d},backend:n,attrs:{axis:u,keepDims:!1}}),m=Bg({inputs:{x:f},backend:n,attrs:{shape:c}}),g=zg({inputs:{a:d,b:m},backend:n});return n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d),n.disposeIntermediateTensorInfo(f),n.disposeIntermediateTensorInfo(m),g}},wy=Um(Xt,((e,t)=>{const n=t;return e>n.clipValueMax?n.clipValueMax:e<n.clipValueMin?n.clipValueMin:e})),_y={kernelName:Xt,backendName:"cpu",kernelFunc:wy},xy={kernelName:jt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;_m(a,"avgPool");const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;nt($u(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=Su(a.shape,i,s,1,o,u);let c;if(1===l.filterWidth&&1===l.filterHeight&&st(l.inShape,l.outShape))c=Im({inputs:{x:a},backend:n});else{const e=n.data.get(a.dataId).values,t=xt(a.shape),r=function(e,t,n,r,a,i){const s=a.strideHeight,o=a.strideWidth,u=a.dilationHeight,l=a.dilationWidth,c=a.effectiveFilterHeight,h=a.effectiveFilterWidth,p=a.padInfo.top,d=a.padInfo.left,f=Number.POSITIVE_INFINITY,m=nl(a.outShape,n),g=m.values,y=a.outShape[1]*a.outShape[2]*a.outShape[3],b=a.outShape[2]*a.outShape[3],v=a.outShape[3];for(let t=0;t<a.batchSize;++t){const n=t*y,i=t*r[0];for(let t=0;t<a.inChannels;++t)for(let m=0;m<a.outHeight;++m){const y=m*s-p,w=Math.max(0,y),_=Math.min(a.inHeight,c+y),x=n+m*b;for(let n=0;n<a.outWidth;++n){const s=n*o-d,c=Math.max(0,s),p=Math.min(a.inWidth,h+s);let m=f,y=0,b=0;for(let n=w;n<_;n+=u){const a=i+n*r[1];for(let n=c;n<p;n+=l){const i=e[a+n*r[2]+t];y+=i,b++}if(isNaN(m))break}g[x+n*v+t]=y/b}}}return m}(e,a.shape,a.dtype,t,l);c=n.makeTensorInfo(l.outShape,a.dtype,r.values)}return c}},ky={kernelName:Gt,backendName:"cpu",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i}=t,{transposeA:s,transposeB:o}=r;_m([a,i],"matMul");const u=a.shape.length,l=i.shape.length,c=s?a.shape[u-2]:a.shape[u-1],h=o?i.shape[l-1]:i.shape[l-2],p=s?a.shape[u-1]:a.shape[u-2],d=o?i.shape[l-2]:i.shape[l-1],f=a.shape.slice(0,-2),m=i.shape.slice(0,-2),g=it(f),y=it(m),b=Bo(a.shape.slice(0,-2),i.shape.slice(0,-2)).concat([p,d]);nt(c===h,(()=>`Error in matMul: inner shapes (${c}) and (${h}) of Tensors with shapes ${a.shape} and ${i.shape} and transposeA=${s} and transposeB=${o} must match.`));const v=o?[y,d,h]:[y,h,d],w=Bg({inputs:{x:a},backend:n,attrs:{shape:s?[g,c,p]:[g,p,c]}}),_=Bg({inputs:{x:i},backend:n,attrs:{shape:v}}),x=s?w.shape[1]:w.shape[2],k=s?w.shape[2]:w.shape[1],T=o?_.shape[1]:_.shape[2],E=Math.max(g,y),S=n.data.get(w.dataId).values,I=n.data.get(_.dataId).values,A=xt(w.shape),C=xt(_.shape),[N,R,F]=s?[A[0],1,A[1]]:[A[0],A[1],1],[O,M,$]=o?[1,C[1],C[0]]:[C[1],1,C[0]],D=k*T,P=nl([E,k,T],w.dtype),L=P.values,B=n.blockSize;for(let e=0;e<E;e++){const t=e%g,n=e%y;for(let r=0;r<k;r+=B){const a=Math.min(r+B,k);for(let i=0;i<T;i+=B){const s=Math.min(i+B,T);for(let o=0;o<x;o+=B){const u=Math.min(o+B,x);for(let l=r;l<a;l++)for(let r=i;r<s;r++){let a=0;for(let e=o;e<u;e++)a+=S[t*N+l*R+e*F]*I[e*O+r*M+n*$];L[e*D+(l*T+r)]+=a}}}}}return n.disposeIntermediateTensorInfo(w),n.disposeIntermediateTensorInfo(_),n.makeTensorInfo(b,P.dtype,P.values)}},Ty={},Ey={alpha:!1,antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1,depth:!1,stencil:!1,failIfMajorPerformanceCaveat:!0};function Sy(e,t){if(!(e in Ty)||null!=t){const n=function(e,t){if(1!==e&&2!==e)throw new Error("Cannot get WebGL rendering context, WebGL is disabled.");const n=null==t?function(e){if("undefined"!=typeof OffscreenCanvas&&2===e)return new OffscreenCanvas(300,150);if("undefined"!=typeof document)return document.createElement("canvas");throw new Error("Cannot create a canvas in this context")}(e):t;return n.addEventListener("webglcontextlost",(t=>{t.preventDefault(),delete Ty[e]}),!1),Mt().getBool("SOFTWARE_WEBGL_ENABLED")&&(Ey.failIfMajorPerformanceCaveat=!1),1===e?n.getContext("webgl",Ey)||n.getContext("experimental-webgl",Ey):n.getContext("webgl2",Ey)}(e,t);if(null===n)return console.log("Could not get context for WebGL version",e),null;Ty[e]=n}const n=Ty[e];return null==n||n.isContextLost()?(delete Ty[e],Sy(e)):(n.disable(n.DEPTH_TEST),n.disable(n.STENCIL_TEST),n.disable(n.BLEND),n.disable(n.DITHER),n.disable(n.POLYGON_OFFSET_FILL),n.disable(n.SAMPLE_COVERAGE),n.enable(n.SCISSOR_TEST),n.enable(n.CULL_FACE),n.cullFace(n.BACK),Ty[e])}var Iy,Ay,Cy;function Ny(e,t){return[t,e]}function Ry(e){const t=it(e);return ut(Math.ceil(t/4))}function Fy(e,t){return[Math.max(1,Math.ceil(t/2)),Math.max(1,Math.ceil(e/2))]}function Oy(e,t){const n=e;let r,a,i,s,o,u,l,c,h,p;return 2===Mt().getNumber("WEBGL_VERSION")?(r=n.R32F,a=n.R16F,i=n.RGBA16F,s=n.RGBA32F,o=n.RED,l=4,c=1,h=n.HALF_FLOAT,p=n.FLOAT,u=n.RGBA8):(r=e.RGBA,a=e.RGBA,i=e.RGBA,s=n.RGBA,o=e.RGBA,l=4,c=4,h=null!=t?t.HALF_FLOAT_OES:null,p=e.FLOAT,u=e.RGBA),{internalFormatFloat:r,internalFormatHalfFloat:a,internalFormatPackedHalfFloat:i,internalFormatPackedFloat:s,textureFormatFloat:o,downloadTextureFormat:u,downloadUnpackNumChannels:l,defaultNumChannels:c,textureTypeHalfFloat:h,textureTypeFloat:p}}function My(e,t){const n=t();return Mt().getBool("DEBUG")&&function(e){const t=e.getError();if(t!==e.NO_ERROR)throw new Error("WebGL Error: "+function(e,t){switch(t){case e.NO_ERROR:return"NO_ERROR";case e.INVALID_ENUM:return"INVALID_ENUM";case e.INVALID_VALUE:return"INVALID_VALUE";case e.INVALID_OPERATION:return"INVALID_OPERATION";case e.INVALID_FRAMEBUFFER_OPERATION:return"INVALID_FRAMEBUFFER_OPERATION";case e.OUT_OF_MEMORY:return"OUT_OF_MEMORY";case e.CONTEXT_LOST_WEBGL:return"CONTEXT_LOST_WEBGL";default:return`Unknown error code ${t}`}}(e,t))}(e),n}function $y(e){return!!(Mt().getBool("WEBGL_RENDER_FLOAT32_ENABLED")||0===e||5.96e-8<Math.abs(e)&&Math.abs(e)<65504)}function Dy(e,t){return jy(e,(()=>e.getExtension(t)),'Extension "'+t+'" not supported on this browser.')}!function(e){e[e.DENSE=0]="DENSE",e[e.SHARED_BATCH=1]="SHARED_BATCH"}(Iy||(Iy={})),function(e){e[e.RENDER=0]="RENDER",e[e.UPLOAD=1]="UPLOAD",e[e.PIXELS=2]="PIXELS",e[e.DOWNLOAD=3]="DOWNLOAD"}(Ay||(Ay={})),function(e){e[e.UNPACKED_FLOAT16=0]="UNPACKED_FLOAT16",e[e.UNPACKED_FLOAT32=1]="UNPACKED_FLOAT32",e[e.PACKED_4X1_UNSIGNED_BYTE=2]="PACKED_4X1_UNSIGNED_BYTE",e[e.PACKED_2X2_FLOAT32=3]="PACKED_2X2_FLOAT32",e[e.PACKED_2X2_FLOAT16=4]="PACKED_2X2_FLOAT16"}(Cy||(Cy={}));const Py=/ERROR: [0-9]+:([0-9]+):/g;function Ly(e,t){const n=Py.exec(t);if(null==n)return console.log(`Couldn't parse line number in error: ${t}`),void console.log(e);const r=+n[1],a=e.split("\n"),i=a.length.toString().length+2,s=a.map(((e,t)=>lt((t+1).toString(),i)+e));let o=0;for(let e=0;e<s.length;e++)o=Math.max(s[e].length,o);const u=s.slice(0,r-1),l=s.slice(r-1,r),c=s.slice(r);console.log(u.join("\n")),console.log(t.split("\n")[0]),console.log(`%c ${lt(l[0],o)}`,"border:1px solid red; background-color:#e3d2d2; color:#a61717"),console.log(c.join("\n"))}function By(e,t){if(My(e,(()=>e.validateProgram(t))),!1===e.getProgramParameter(t,e.VALIDATE_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Shader program validation failed.")}function Uy(e,t,n,r,a,i,s){const o=e.getAttribLocation(t,n);return-1!==o&&(My(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,r))),My(e,(()=>e.vertexAttribPointer(o,a,e.FLOAT,!1,i,s))),My(e,(()=>e.enableVertexAttribArray(o))),!0)}function Wy(e,t,n){My(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,n))),My(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0)))}function Vy(e,t){My(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,t))),My(e,(()=>e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,null,0)))}function zy(e){const t=e.checkFramebufferStatus(e.FRAMEBUFFER);if(t!==e.FRAMEBUFFER_COMPLETE)throw new Error("Error binding framebuffer: "+function(e,t){switch(t){case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:return"FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT";case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:return"FRAMEBUFFER_INCOMPLETE_DIMENSIONS";case e.FRAMEBUFFER_UNSUPPORTED:return"FRAMEBUFFER_UNSUPPORTED";default:return`unknown error ${t}`}}(e,t))}function jy(e,t,n){const r=My(e,(()=>t()));if(null==r)throw new Error(n);return r}function Gy(e,t=2){return it(e.slice(0,e.length-t))}function Hy(e){if(0===e.length)throw Error("Cannot get rows and columns of an empty shape array.");return[e.length>1?e[e.length-2]:1,e[e.length-1]]}function Ky(e){let t=[1,1,1];return 0===e.length||1===e.length&&1===e[0]||(t=[Gy(e),...Hy(e)]),t}function qy(e){return e%2==0}function Xy(e,t){if(st(e=e.slice(-2),t=t.slice(-2)))return!0;if(!e.length||!t.length)return!0;if(0===e[0]||0===e[1]||0===t[0]||0===t[1])return!0;if(e.length!==t.length){const n=e.slice(-1)[0],r=t.slice(-1)[0];if(n===r)return!0;if(qy(n)&&qy(r)&&(1===e[0]||1===t[0]))return!0}return e[1]===t[1]&&qy(e[0])&&qy(t[0])}let Yy,Qy;function Jy(e,t){return null!=e.getExtension(t)}function Zy(e){try{if(null!=Sy(e))return!0}catch(e){return console.log("Error when getting WebGL context: ",e),!1}return!1}function eb(e){const t=Oy(e),n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n),e.texImage2D(e.TEXTURE_2D,0,t.internalFormatFloat,1,1,0,t.textureFormatFloat,t.textureTypeFloat,null);const r=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,r),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0);const a=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(n),e.deleteFramebuffer(r),a}const tb=Mt();function nb(){let e,t,n,r,a,i,s,o,u,l;return 2===Mt().getNumber("WEBGL_VERSION")?(e="#version 300 es",t="in",n="out",r="in",a="texture",i="outputColor",s="out vec4 outputColor;",o=Mt().getBool("WEBGL2_ISNAN_CUSTOM")?"\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n ":"",u="",l="\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "):(e="",t="attribute",n="varying",r="varying",a="texture2D",i="gl_FragColor",s="",o="\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ",u="\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ",l="\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "),{version:e,attribute:t,varyingVs:n,varyingFs:r,texture2D:a,output:i,defineOutput:s,defineSpecialNaN:o,defineSpecialInf:u,defineRound:l}}function rb(e,t,n="index"){const r=xt(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / ${t}; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * ${t}`:`index -= ${e[a]} * ${t}`};`)).join("")}function ab(e,t,n="index"){const r=xt(t);return r.map(((t,a)=>`int ${e[a]} = ${n} / outShapeStrides[${a}]; ${a===r.length-1?`int ${e[a+1]} = ${n} - ${e[a]} * outShapeStrides[${a}]`:`index -= ${e[a]} * outShapeStrides[${a}]`};`)).join("")}function ib(e){const t=xt(e).map((e=>e.toString()));return`\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;\n }\n`}tb.registerFlag("HAS_WEBGL",(()=>tb.getNumber("WEBGL_VERSION")>0)),tb.registerFlag("WEBGL_VERSION",(()=>Zy(2)?2:Zy(1)?1:0)),tb.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS",(()=>!1)),tb.registerFlag("WEBGL_BUFFER_SUPPORTED",(()=>2===tb.get("WEBGL_VERSION"))),tb.registerFlag("WEBGL_CPU_FORWARD",(()=>!0)),tb.registerFlag("WEBGL_FORCE_F16_TEXTURES",(()=>!1)),tb.registerFlag("WEBGL_PACK",(()=>tb.getBool("HAS_WEBGL"))),tb.registerFlag("WEBGL_PACK_NORMALIZATION",(()=>tb.getBool("WEBGL_PACK"))),tb.registerFlag("WEBGL_PACK_CLIP",(()=>tb.getBool("WEBGL_PACK"))),tb.registerFlag("WEBGL_PACK_DEPTHWISECONV",(()=>tb.getBool("WEBGL_PACK"))),tb.registerFlag("WEBGL_PACK_BINARY_OPERATIONS",(()=>tb.getBool("WEBGL_PACK"))),tb.registerFlag("WEBGL_PACK_UNARY_OPERATIONS",(()=>tb.getBool("WEBGL_PACK"))),tb.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS",(()=>tb.getBool("WEBGL_PACK"))),tb.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS",(()=>tb.getBool("WEBGL_PACK"))),tb.registerFlag("WEBGL_PACK_REDUCE",(()=>tb.getBool("WEBGL_PACK"))),tb.registerFlag("WEBGL_LAZILY_UNPACK",(()=>tb.getBool("WEBGL_PACK"))),tb.registerFlag("WEBGL_CONV_IM2COL",(()=>tb.getBool("WEBGL_PACK"))),tb.registerFlag("WEBGL_MAX_TEXTURE_SIZE",(()=>function(e){if(null==Yy){const t=Sy(e);Yy=t.getParameter(t.MAX_TEXTURE_SIZE)}return Yy}(tb.getNumber("WEBGL_VERSION")))),tb.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER",(()=>function(e){if(null==Qy){const t=Sy(e);Qy=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS)}return Math.min(16,Qy)}(tb.getNumber("WEBGL_VERSION")))),tb.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION",(()=>{const e=tb.getNumber("WEBGL_VERSION");return 0===e?0:function(e){if(0===e)return 0;let t;const n=Sy(e);return t=Jy(n,"EXT_disjoint_timer_query_webgl2")&&2===e?2:Jy(n,"EXT_disjoint_timer_query")?1:0,t}(e)})),tb.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE",(()=>tb.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0&&!hi())),tb.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE",(()=>function(e){if(0===e)return!1;const t=Sy(e);if(1===e){if(!Jy(t,"OES_texture_float"))return!1}else if(!Jy(t,"EXT_color_buffer_float"))return!1;return eb(t)}(tb.getNumber("WEBGL_VERSION")))),tb.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED",(()=>!tb.getBool("WEBGL_FORCE_F16_TEXTURES")&&tb.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))),tb.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED",(()=>function(e){if(0===e)return!1;const t=Sy(e);if(1!==e){if(Jy(t,"EXT_color_buffer_float"))return eb(t);const e="EXT_color_buffer_half_float";if(Jy(t,e)){const n=t.getExtension(e);return function(e,t){const n=Oy(e,t),r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,n.internalFormatHalfFloat,1,1,0,n.textureFormatFloat,n.textureTypeHalfFloat,null);const a=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0);const i=e.checkFramebufferStatus(e.FRAMEBUFFER)===e.FRAMEBUFFER_COMPLETE;return e.bindTexture(e.TEXTURE_2D,null),e.bindFramebuffer(e.FRAMEBUFFER,null),e.deleteTexture(r),e.deleteFramebuffer(a),i}(t,n)}return!1}return!!Jy(t,"OES_texture_float")&&!!Jy(t,"WEBGL_color_buffer_float")&&eb(t)}(tb.getNumber("WEBGL_VERSION")))),tb.registerFlag("WEBGL_FENCE_API_ENABLED",(()=>{return 2===(e=tb.getNumber("WEBGL_VERSION"))&&null!=Sy(e).fenceSync;var e})),tb.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM",(()=>tb.getBool("WEBGL_RENDER_FLOAT32_ENABLED")?4:0)),tb.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD",(()=>-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`)})),tb.registerFlag("WEBGL_FLUSH_THRESHOLD",(()=>hi()?1:-1),(e=>{if(e<0&&-1!==e)throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`)})),tb.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD",(()=>128)),tb.registerFlag("WEBGL_USE_SHAPES_UNIFORMS",(()=>!1)),tb.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD",(()=>1e5)),tb.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD",(()=>128)),tb.registerFlag("WEBGL_EXP_CONV",(()=>!1)),tb.registerFlag("SOFTWARE_WEBGL_ENABLED",(()=>tb.getBool("IS_TEST"))),tb.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE",(()=>1/0)),tb.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE",(()=>!1)),tb.registerFlag("WEBGL2_ISNAN_CUSTOM",(()=>!1)),tb.registerFlag("ENGINE_COMPILE_ONLY",(()=>!1));const sb="\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n",{getBroadcastDims:ob}=ef;function ub(e,t,n){const r=[];if(e.forEach((e=>{const t=it(e.shapeInfo.logicalShape);if(e.shapeInfo.isUniform?r.push(`uniform float ${e.name}${t>1?`[${t}]`:""};`):(r.push(`uniform sampler2D ${e.name};`),r.push(`uniform int offset${e.name};`)),n.enableShapeUniforms){const{uniformShape:t}=bb(n.packedInputs,e.shapeInfo.logicalShape,e.shapeInfo.texShape);switch(t.length){case 1:r.push(`uniform int ${e.name}Shape;`);break;case 2:r.push(`uniform ivec2 ${e.name}Shape;`);break;case 3:r.push(`uniform ivec3 ${e.name}Shape;`);break;case 4:r.push(`uniform ivec4 ${e.name}Shape;`)}r.push(`uniform ivec2 ${e.name}TexShape;`)}})),n.enableShapeUniforms){switch(t.logicalShape.length){case 1:r.push("uniform int outShape;");break;case 2:r.push("uniform ivec2 outShape;"),r.push("uniform int outShapeStrides;");break;case 3:r.push("uniform ivec3 outShape;"),r.push("uniform ivec2 outShapeStrides;");break;case 4:r.push("uniform ivec4 outShape;"),r.push("uniform ivec3 outShapeStrides;")}r.push("uniform ivec2 outTexShape;")}n.customUniforms&&n.customUniforms.forEach((e=>{r.push(`uniform ${e.type} ${e.name}${e.arrayIndex?`[${e.arrayIndex}]`:""};`)}));const a=r.join("\n"),i=e.map((e=>function(e,t,n=!1,r){let a="";a+=n?cb(e,r):lb(e,r);const i=e.shapeInfo.logicalShape,s=t.logicalShape;return i.length<=s.length&&(a+=n?function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=e.shapeInfo.logicalShape.length,s=t.logicalShape.length,o=ob(e.shapeInfo.logicalShape,t.logicalShape),u=yb(s),l=s-i;let c;const h=["x","y","z","w","u","v"];c=0===i?"":s<2&&o.length>=1?"coords = 0;":o.map((e=>`coords.${h[e+l]} = 0;`)).join("\n");let p="";p=s<2&&i>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${h[t+l]}`)).join(", ");let d="return outputValue;";const f=1===it(e.shapeInfo.logicalShape),m=1===it(t.logicalShape);if(1!==i||f||m){if(f&&!m)d=1===s?"\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n ":"\n return vec4(outputValue.x);\n ";else if(o.length){const e=i-2,t=i-1;o.indexOf(e)>-1&&o.indexOf(t)>-1?d="return vec4(outputValue.x);":o.indexOf(e)>-1?d="return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);":o.indexOf(t)>-1&&(d="return vec4(outputValue.xx, outputValue.zz);")}}else d="\n return vec4(outputValue.xy, outputValue.xy);\n ";return`\n vec4 ${a}() {\n ${u} coords = getOutputCoords();\n ${c}\n vec4 outputValue = get${r}(${p});\n ${d}\n }\n `}(e,t):function(e,t){const n=e.name,r=n.charAt(0).toUpperCase()+n.slice(1),a="get"+r+"AtOutCoords",i=t.texShape,s=e.shapeInfo.texShape,o=e.shapeInfo.logicalShape.length,u=t.logicalShape.length;if(!e.shapeInfo.isUniform&&o===u&&null==e.shapeInfo.flatOffset&&st(s,i))return`\n float ${a}() {\n return sampleTexture(${n}, resultUV);\n }\n `;const l=yb(u),c=ob(e.shapeInfo.logicalShape,t.logicalShape),h=u-o;let p;const d=["x","y","z","w","u","v"];p=0===o?"":u<2&&c.length>=1?"coords = 0;":c.map((e=>`coords.${d[e+h]} = 0;`)).join("\n");let f="";return f=u<2&&o>0?"coords":e.shapeInfo.logicalShape.map(((e,t)=>`coords.${d[t+h]}`)).join(", "),`\n float ${a}() {\n ${l} coords = getOutputCoords();\n ${p}\n return get${r}(${f});\n }\n `}(e,t)),a}(e,t,n.packedInputs,n.enableShapeUniforms))).join("\n"),s=t.texShape,o=nb(),u=function(e){return`\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${e.texture2D}(textureSampler, uv).r;\n }\n `}(o);let l,c,h=function(e){return`${e.version}\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ${e.varyingFs} vec2 resultUV;\n ${e.defineOutput}\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n ${e.defineSpecialNaN}\n ${e.defineSpecialInf}\n ${e.defineRound}\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n ${hb}\n ${pb}\n ${db}\n `}(o);return t.isPacked?(l=function(e,t,n){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];return 1===r[0]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.x * ${r[1]}.0);\n }\n `:1===r[1]?n?"\n int getOutputCoords() {\n return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));\n }\n ":`\n int getOutputCoords() {\n return 2 * int(resultUV.y * ${r[0]}.0);\n }\n `:n?"\n int getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);\n }\n ":`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n return 2 * (resTexRC.x * ${r[1]} + resTexRC.y);\n }\n `}(0,t,n);case 2:return function(e,t,n){const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)];if(st(e,t))return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]}));\n }\n `;const a=Math.ceil(e[1]/2);return n?"\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec2(r, c);\n }\n `}(e,t,n);case 3:return function(e,t,n){if(n)return"\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[2]/2),i=a*Math.ceil(e[1]/2);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n int b = index / ${i};\n index -= b * ${i};\n\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec3(b, r, c);\n }\n `}(e,t,n);default:return function(e,t,n){if(n)return"\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n ";const r=[Math.ceil(t[0]/2),Math.ceil(t[1]/2)],a=Math.ceil(e[e.length-1]/2),i=a*Math.ceil(e[e.length-2]/2);let s=i,o="",u="b, r, c";for(let t=2;t<e.length-1;t++)s*=e[e.length-t-1],o=`\n int b${t} = index / ${s};\n index -= b${t} * ${s};\n `+o,u=`b${t}, `+u;return`\n ivec${e.length} getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n ${o}\n\n int b = index / ${i};\n index -= b * ${i};\n\n int r = 2 * (index / ${a});\n int c = imod(index, ${a}) * 2;\n\n return ivec${e.length}(${u});\n }\n `}(e,t,n)}}(t.logicalShape,s,n.enableShapeUniforms),c=function(e){return`\n void setOutput(vec4 val) {\n ${e.output} = val;\n }\n `}(o)):(l=function(e,t,n){switch(e.length){case 0:return"\n int getOutputCoords() {\n return 0;\n }\n ";case 1:return function(e,t,n){return 1===t[0]?n?"\n int getOutputCoords() {\n return int(resultUV.x * float(outTexShape[1]));\n }\n ":`\n int getOutputCoords() {\n return int(resultUV.x * ${t[1]}.0);\n }\n `:1===t[1]?n?"\n int getOutputCoords() {\n return int(resultUV.y * float(outTexShape[0]));\n }\n ":`\n int getOutputCoords() {\n return int(resultUV.y * ${t[0]}.0);\n }\n `:n?"\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n return resTexRC.x * outTexShape[1] + resTexRC.y;\n }\n ":`\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n return resTexRC.x * ${t[1]} + resTexRC.y;\n }\n `}(0,t,n);case 2:return function(e,t,n){return st(e,t)?n?"\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));\n }\n ":`\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));\n }\n `:1===e[1]?n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(index, 0);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(index, 0);\n }\n `:1===e[0]?n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(0, index);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(0, index);\n }\n `:n?"\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n int r = index / outShape[1];\n int c = index - r * outShape[1];\n return ivec2(r, c);\n }\n ":`\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n int r = index / ${e[1]};\n int c = index - r * ${e[1]};\n return ivec2(r, c);\n }\n `}(e,t,n);case 3:return function(e,t,n){if(n)return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${ab(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n`;const r=rb(["r","c","d"],e);return`\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${r}\n return ivec3(r, c, d);\n }\n `}(e,t,n);case 4:return function(e,t,n){if(n)return`\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${ab(["r","c","d","d2"],e)}\n return ivec4(r, c, d, d2);\n }\n `;const r=rb(["r","c","d","d2"],e);return`\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${r}\n return ivec4(r, c, d, d2);\n }\n `}(e,t,n);case 5:return function(e,t){const n=rb(["r","c","d","d2","d3"],e);return`\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(${t[0]},\n ${t[1]}));\n\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec5 outShape = ivec5(r, c, d, d2, d3);\n return outShape;\n }\n `}(e,t);case 6:return function(e,t){const n=rb(["r","c","d","d2","d3","d4"],e);return`\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec6 result = ivec6(r, c, d, d2, d3, d4);\n return result;\n }\n `}(e,t);default:throw new Error(`${e.length}-D output sampling is not yet supported`)}}(t.logicalShape,s,n.enableShapeUniforms),c=function(e){return`\n void setOutput(float val) {\n ${e.output} = vec4(val, 0, 0, 0);\n }\n `}(o)),n.packedInputs&&(h+=fb),[h,u,c,a,l,i,n.userCode].join("\n")}function lb(e,t=!1){const n=e.shapeInfo.logicalShape;switch(n.length){case 0:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`float ${r}() {return ${n};}`;const[a,i]=e.shapeInfo.texShape;if(1===a&&1===i)return`\n float ${r}() {\n return sampleTexture(${n}, halfCR);\n }\n `;const s=mb(n);if(t)return`\n float ${r}() {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${s});\n return sampleTexture(${n}, uv);\n }\n `;const[o,u]=e.shapeInfo.texShape;return`\n float ${r}() {\n vec2 uv = uvFromFlat(${o}, ${u}, ${s});\n return sampleTexture(${n}, uv);\n }\n `}(e,t);case 1:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1);if(e.shapeInfo.isUniform)return`\n float ${r}(int index) {\n ${gb(e)}\n }\n `;const a=e.shapeInfo.texShape,i=a[0],s=a[1];if(1===s&&1===i)return`\n float ${r}(int index) {\n return sampleTexture(${n}, halfCR);\n }\n `;const o=mb(n);return 1===s?t?`\n float ${r}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${o}) + 0.5) / float(${n}TexShape[0]));\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${o}) + 0.5) / ${i}.0);\n return sampleTexture(${n}, uv);\n }\n `:1===i?t?`\n float ${r}(int index) {\n vec2 uv = vec2((float(index + ${o}) + 0.5) / float(${n}TexShape[1]), 0.5);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int index) {\n vec2 uv = vec2((float(index + ${o}) + 0.5) / ${s}.0, 0.5);\n return sampleTexture(${n}, uv);\n }\n `:t?`\n float ${r}(int index) {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], index + ${o});\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int index) {\n vec2 uv = uvFromFlat(${i}, ${s}, index + ${o});\n return sampleTexture(${n}, uv);\n }\n `}(e,t);case 2:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=e.shapeInfo.texShape;if(null!=i&&st(n,i)){if(t)return`\n float ${a}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `;const e=i[0];return`\n float ${a}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${i[1]}.0, ${e}.0);\n return sampleTexture(${r}, uv);\n }\n `}const{newShape:s,keptDims:o}=dt(n),u=s;if(u.length<n.length){const n=["row","col"];return`\n ${lb(vb(e,u),t)}\n float ${a}(int row, int col) {\n return ${a}(${wb(n,o)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${a}(int row, int col) {\n int index = round(dot(vec2(row, col), vec2(${n[1]}, 1)));\n ${gb(e)}\n }\n `;const l=i[0],c=i[1],h=mb(r);return 1===c?t?`\n float ${a}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${r}Shape[1], 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / float(${r}TexShape[0]));\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / ${l}.0);\n return sampleTexture(${r}, uv);\n }\n `:1===l?t?`\n float ${a}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${r}Shape[1], 1, 1));\n vec2 uv = vec2((index + 0.5) / float(${r}TexShape[1]), 0.5);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2((index + 0.5) / ${c}.0, 0.5);\n return sampleTexture(${r}, uv);\n }\n `:t?`\n float ${a}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${r}Shape[1] + col + ${h};\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${n[1]} + col + ${h};\n vec2 uv = uvFromFlat(${l}, ${c}, index);\n return sampleTexture(${r}, uv);\n }\n`}(e,t);case 3:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=n[1]*n[2],s=n[2],{newShape:o,keptDims:u}=dt(n),l=o;if(l.length<n.length){const n=["row","col","depth"];return`\n ${lb(vb(e,l),t)}\n float ${a}(int row, int col, int depth) {\n return ${a}(${wb(n,u)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${a}(int row, int col, int depth) {\n int index = round(dot(vec3(row, col, depth),\n vec3(${i}, ${s}, 1)));\n ${gb(e)}\n }\n `;const c=e.shapeInfo.texShape,h=c[0],p=c[1],d=e.shapeInfo.flatOffset;if(p===i&&null==d)return t?`\n float ${a}(int row, int col, int depth) {\n int stride1 = ${r}Shape[2];\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(stride1, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth) {\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(${s}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${p}.0, ${h}.0);\n return sampleTexture(${r}, uv);\n }\n `;if(p===s&&null==d)return t?`\n float ${a}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${r}Shape[1], 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${n[1]}, 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${p}.0, ${h}.0);\n return sampleTexture(${r}, uv);\n }\n `;const f=mb(r);return t?`\n float ${a}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int stride0 = ${r}Shape[1] * ${r}Shape[2];\n int stride1 = ${r}Shape[2];\n int index = row * stride0 + col * stride1 + depth + ${f};\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${i} + col * ${s} + depth + ${f};\n vec2 uv = uvFromFlat(${h}, ${p}, index);\n return sampleTexture(${r}, uv);\n }\n `}(e,t);case 4:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=n[3],s=n[2]*i,o=n[1]*s,{newShape:u,keptDims:l}=dt(n);if(u.length<n.length){const n=["row","col","depth","depth2"];return`\n ${lb(vb(e,u),t)}\n float ${a}(int row, int col, int depth, int depth2) {\n return ${a}(${wb(n,l)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${a}(int row, int col, int depth, int depth2) {\n int index = round(dot(vec4(row, col, depth, depth2),\n vec4(${o}, ${s}, ${i}, 1)));\n ${gb(e)}\n }\n `;const c=e.shapeInfo.flatOffset,h=e.shapeInfo.texShape,p=h[0],d=h[1],f=`int stride2 = ${r}Shape[3];`,m=`int stride1 = ${r}Shape[2] * stride2;`,g=`int stride0 = ${r}Shape[1] * stride1;`;if(d===o&&null==c)return t?`\n float ${a}(int row, int col, int depth, int depth2) {\n ${f}\n ${m}\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(stride1, stride2, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth, int depth2) {\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(${s}, ${i}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${p}.0);\n return sampleTexture(${r}, uv);\n }\n `;if(d===i&&null==c)return t?`\n float ${a}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${r}Shape[1] * ${r}Shape[2], ${r}Shape[2], 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${n[1]*n[2]}, ${n[2]}, 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${p}.0);\n return sampleTexture(${r}, uv);\n }\n `;const y=mb(r);return t?`\n float ${a}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n ${f}\n ${m}\n ${g}\n int index = row * stride0 + col * stride1 +\n depth * stride2 + depth2;\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index + ${y});\n return sampleTexture(${r}, uv);\n }\n `:`\n float ${a}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${o} + col * ${s} +\n depth * ${i} + depth2;\n vec2 uv = uvFromFlat(${p}, ${d}, index + ${y});\n return sampleTexture(${r}, uv);\n }\n `}(e,t);case 5:return function(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=t[4],i=t[3]*a,s=t[2]*i,o=t[1]*s,{newShape:u,keptDims:l}=dt(t);if(u.length<t.length){const t=["row","col","depth","depth2","depth3"];return`\n ${lb(vb(e,u))}\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n return ${r}(${wb(t,l)});\n }\n `}if(e.shapeInfo.isUniform)return`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n float index = dot(\n vec4(row, col, depth, depth2),\n vec4(${o}, ${s}, ${i}, ${a})) +\n depth3;\n ${gb(e)}\n }\n `;const c=e.shapeInfo.flatOffset,h=e.shapeInfo.texShape,p=h[0],d=h[1];return d===o&&null==c?`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${s}, ${i}, ${a}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${p}.0);\n return sampleTexture(${n}, uv);\n }\n `:d===a&&null==c?`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n float texR = dot(\n vec4(row, col, depth, depth2),\n vec4(${t[1]*t[2]*t[3]},\n ${t[2]*t[3]}, ${t[3]}, 1));\n int texC = depth3;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${p}.0);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${o} + col * ${s} + depth * ${i} +\n depth2 * ${a} + depth3 + ${mb(n)};\n vec2 uv = uvFromFlat(${p}, ${d}, index);\n return sampleTexture(${n}, uv);\n }\n `}(e);case 6:return function(e){const t=e.shapeInfo.logicalShape,n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),{newShape:a,keptDims:i}=dt(t);if(a.length<t.length){const t=["row","col","depth","depth2","depth3","depth4"];return`\n ${lb(vb(e,a))}\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n return ${r}(${wb(t,i)});\n }\n `}const s=t[5],o=t[4]*s,u=t[3]*o,l=t[2]*u,c=t[1]*l;if(e.shapeInfo.isUniform)return`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int index = round(dot(\n vec4(row, col, depth, depth2),\n vec4(${c}, ${l}, ${u}, ${o})) +\n dot(\n vec2(depth3, depth4),\n vec2(${s}, 1)));\n ${gb(e)}\n }\n `;const h=e.shapeInfo.flatOffset,p=e.shapeInfo.texShape,d=p[0],f=p[1];return f===c&&null==h?`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${l}, ${u}, ${o}, ${s})) +\n float(depth4);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `:f===s&&null==h?`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n float texR = dot(vec4(row, col, depth, depth2),\n vec4(${t[1]*t[2]*t[3]*t[4]},\n ${t[2]*t[3]*t[4]},\n ${t[3]*t[4]},\n ${t[4]})) + float(depth3);\n int texC = depth4;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `:`\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${c} + col * ${l} + depth * ${u} +\n depth2 * ${o} + depth3 * ${s} + depth4 + ${mb(n)};\n vec2 uv = uvFromFlat(${d}, ${f}, index);\n return sampleTexture(${n}, uv);\n }\n `}(e);default:throw new Error(`${n.length}-D input sampling is not yet supported`)}}function cb(e,t){switch(e.shapeInfo.logicalShape.length){case 0:return function(e){const t=e.name;return`\n vec4 ${"get"+t.charAt(0).toUpperCase()+t.slice(1)}() {\n return ${nb().texture2D}(${t}, halfCR);\n }\n `}(e);case 1:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=e.shapeInfo.texShape,i=nb();if(t)return`\n vec4 ${r}(int index) {\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n vec2 uv = packedUVfrom1D(\n packedTexShape[0], packedTexShape[1], index);\n return ${i.texture2D}(${n}, uv);\n }\n `;const s=[Math.ceil(a[0]/2),Math.ceil(a[1]/2)];return`\n vec4 ${r}(int index) {\n vec2 uv = packedUVfrom1D(\n ${s[0]}, ${s[1]}, index);\n return ${i.texture2D}(${n}, uv);\n }\n `}(e,t);case 2:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=e.shapeInfo.texShape,s=i[0],o=i[1],u=nb();if(null!=i&&st(n,i))return t?`\n vec4 ${a}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n\n return ${u.texture2D}(${r}, uv);\n }\n `:`\n vec4 ${a}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${o}.0, ${s}.0);\n\n return ${u.texture2D}(${r}, uv);\n }\n `;if(t)return`\n vec4 ${a}(int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${r}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);\n return ${u.texture2D}(${r}, uv);\n }\n `;const l=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];return`\n vec4 ${a}(int row, int col) {\n vec2 uv = packedUVfrom2D(${Math.ceil(n[1]/2)}, ${l[0]}, ${l[1]}, row, col);\n return ${u.texture2D}(${r}, uv);\n }\n `}(e,t);case 3:return function(e,t){const n=e.shapeInfo.logicalShape,r=e.name,a="get"+r.charAt(0).toUpperCase()+r.slice(1),i=e.shapeInfo.texShape,s=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];if(1===n[0]){const r=[1,2],i=["b","row","col"];return`\n ${cb(vb(e,n.slice(1)),t)}\n vec4 ${a}(int b, int row, int col) {\n return ${a}(${wb(i,r)});\n }\n `}const o=nb();if(t)return`\n vec4 ${a}(int b, int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${r}Shape[2]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${r}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom3D(\n packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);\n return ${o.texture2D}(${r}, uv);\n }\n `;const u=s[0],l=s[1],c=Math.ceil(n[2]/2);return`\n vec4 ${a}(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n ${u}, ${l}, ${c*Math.ceil(n[1]/2)}, ${c}, b, row, col);\n return ${o.texture2D}(${r}, uv);\n }\n `}(e,t);default:return function(e,t){const n=e.name,r="get"+n.charAt(0).toUpperCase()+n.slice(1),a=nb();if(t)return`\n vec4 ${r}(int b2, int b, int row, int col) {\n int valuesPerRow = int(ceil(float(${n}Shape[3]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${n}Shape[2]) / 2.0));\n int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);\n texelsInBatch *= ${n}Shape[1];\n index = b2 * texelsInBatch + index;\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n int texR = index / packedTexShape[1];\n int texC = index - texR * packedTexShape[1];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${a.texture2D}(${n}, uv);\n }\n `;const i=e.shapeInfo.logicalShape,s=i.length,o=e.shapeInfo.texShape,u=[Math.ceil(o[0]/2),Math.ceil(o[1]/2)],l=u[0],c=u[1],h=Math.ceil(i[s-1]/2);let p=h*Math.ceil(i[s-2]/2),d="int b, int row, int col",f=`b * ${p} + (row / 2) * ${h} + (col / 2)`;for(let e=2;e<s-1;e++)d=`int b${e}, `+d,p*=i[s-e-1],f=`b${e} * ${p} + `+f;return`\n vec4 ${r}(${d}) {\n int index = ${f};\n int texR = index / ${c};\n int texC = index - texR * ${c};\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${c}, ${l});\n return ${a.texture2D}(${n}, uv);\n }\n `}(e,t)}}const hb="\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",pb="\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",db="\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n",fb="\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n";function mb(e){return`offset${e}`}function gb(e){const t=e.name,n=it(e.shapeInfo.logicalShape);return n<2?`return ${t};`:`\n for (int i = 0; i < ${n}; i++) {\n if (i == index) {\n return ${t}[i];\n }\n }\n `}function yb(e){if(e<=1)return"int";if(2===e)return"ivec2";if(3===e)return"ivec3";if(4===e)return"ivec4";if(5===e)return"ivec5";if(6===e)return"ivec6";throw Error(`GPU for rank ${e} is not yet supported`)}function bb(e,t,n){const{newShape:r,keptDims:a}=dt(t),i=t.length,s=e&&3===i&&1===t[0],o=s?t.slice(1):r,u=!e&&i>1&&!st(t,n)&&r.length<i||s;return{useSqueezeShape:u,uniformShape:u?o:t,keptDims:a}}function vb(e,t){const n=JSON.parse(JSON.stringify(e));return n.shapeInfo.logicalShape=t,n}function wb(e,t){return t.map((t=>e[t])).join(", ")}function _b(e,t,n){const r={},a={},i={},s=[];let o,u,l,c=null,h=null;h=e.getUniformLocation(n,"NAN",!1),1===Mt().getNumber("WEBGL_VERSION")&&(c=e.getUniformLocation(n,"INFINITY",!1));const p=!1;for(let s=0;s<t.variableNames.length;s++){const o=t.variableNames[s];r[o]=e.getUniformLocation(n,o,p),r[`offset${o}`]=e.getUniformLocation(n,`offset${o}`,p),t.enableShapeUniforms&&(a[`${o}Shape`]=e.getUniformLocation(n,`${o}Shape`,p),i[`${o}TexShape`]=e.getUniformLocation(n,`${o}TexShape`,p))}return t.enableShapeUniforms&&(o=e.getUniformLocation(n,"outShape",p),l=e.getUniformLocation(n,"outShapeStrides",p),u=e.getUniformLocation(n,"outTexShape",p)),t.customUniforms&&t.customUniforms.forEach(((t,r)=>{s[r]=e.getUniformLocation(n,t.name,p)})),{uniformLocations:r,customUniformLocations:s,infLoc:c,nanLoc:h,inShapesLocations:a,inTexShapesLocations:i,outShapeLocation:o,outShapeStridesLocation:l,outTexShapeLocation:u}}function xb(e,t){if(e.length!==t.length)throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);e.forEach(((e,n)=>{const r=e.logicalShape,a=t[n],i=a.shape;if(!st(r,i))throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${i} must match`);if(e.isUniform&&a.isUniform)return;const s=e.texShape,o=a.isUniform?null:a.texData.texShape;if(!st(s,o))throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${s} and ${o} must match`)}))}function kb(e){return Mt().getBool("WEBGL_USE_SHAPES_UNIFORMS")&&e<=4}class Tb{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outPackingScheme=Iy.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=nb();this.outputShape=e,this.enableShapeUniforms=kb(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?ab(["r","c","d"],e):rb(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n ${t.output} = result;\n }\n `}}class Eb{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outPackingScheme=Iy.DENSE,this.customUniforms=[{name:"texShape",type:"ivec2"}];const t=nb();this.outputShape=e,this.enableShapeUniforms=kb(this.outputShape.length),this.userCode=`\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms?ab(["r","c","d"],e):rb(["r","c","d"],e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n ${t.output} = result;\n }\n `}}class Sb{constructor(e){this.variableNames=["A"],this.outTexUsage=Ay.DOWNLOAD;const t=nb();this.outputShape=e,this.userCode=`\n ${sb}\n\n void main() {\n float x = getAAtOutCoords();\n ${t.output} = encode_float(x);\n }\n `}}class Ib{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outTexUsage=Ay.DOWNLOAD;const t=nb();this.outputShape=e,this.userCode=`\n ${sb}\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n ${t.output} = encode_float(x);\n }\n `}}const Ab={R:0,G:1,B:2,A:3};class Cb{constructor(e,t=!1,n="RGBA"){this.variableNames=["A"],this.customUniforms=[{name:"texShape",type:"ivec2"}];const r=nb();this.outputShape=e,this.enableShapeUniforms=kb(this.outputShape.length);let a="result";t&&(a="floor(result * 255. + 0.5)");let i="";for(let e=0;e<n.length;e++){const t=n[e];i+=`\n if(offset == ${e}) {\n result = values[${Ab[t]}];\n }`}this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":ib(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n int flatIndex = getFlatIndex(coords);\n float result = 0.;\n int offset = imod(flatIndex, ${n.length});\n\n flatIndex = idiv(flatIndex, ${n.length}, 1.);\n\n int r = flatIndex / texShape[1];\n if (r < texShape[0]) {\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n vec4 values = ${r.texture2D}(A, uv);\n ${i}\n }\n ${r.output} = vec4(${a}, 0., 0., 0.);\n }\n `}}class Nb{constructor(e,t=!1){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.customUniforms=[{name:"texShape",type:"ivec2"}];const n=nb();this.outputShape=e,this.enableShapeUniforms=kb(this.outputShape.length);let r="",a="result";t&&(a="floor(result * 255. + 0.5)");for(let t=0;t<=1;t++)for(let a=0;a<=1;a++){const i=2*t+a;r+=`\n localCoords = coords;\n if(localCoords[2] + ${a} < ${this.enableShapeUniforms?"outShape[2]":`${e[2]}`}) {\n localCoords[2] += ${a};\n if (localCoords[1] + ${t} < ${this.enableShapeUniforms?"outShape[1]":`${e[1]}`}) {\n localCoords[1] += ${t};\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n values = ${n.texture2D}(A, uv);\n\n if (offset == 0) {\n result[${i}] = values[0];\n } else if (offset == 1) {\n result[${i}] = values[1];\n } else if (offset == 2) {\n result[${i}] = values[2];\n } else {\n result[${i}] = values[3];\n }\n }\n }\n `}this.userCode=`\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":ib(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n ${r}\n\n ${n.output} = ${a};\n }\n `}}function Rb(e,t,n,r,a,i){!function(e,t){const n=Mt().getNumber("WEBGL_MAX_TEXTURE_SIZE");if(e<=0||t<=0)throw new Error(`Requested texture size [${e}x${t}] is invalid.`);if(e>n||t>n)throw new Error(`Requested texture size [${e}x${t}] greater than WebGL maximum on this browser / GPU [${n}x${n}].`)}(t,n);const s=function(e){return jy(e,(()=>e.createTexture()),"Unable to create WebGLTexture.")}(e),o=e.TEXTURE_2D;return My(e,(()=>e.bindTexture(o,s))),My(e,(()=>e.texParameteri(o,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE))),My(e,(()=>e.texParameteri(o,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE))),My(e,(()=>e.texParameteri(o,e.TEXTURE_MIN_FILTER,e.NEAREST))),My(e,(()=>e.texParameteri(o,e.TEXTURE_MAG_FILTER,e.NEAREST))),1===Mt().getNumber("WEBGL_VERSION")?My(e,(()=>e.texImage2D(o,0,r,t,n,0,a,i,null))):My(e,(()=>e.texStorage2D(o,1,r,t,n))),My(e,(()=>e.bindTexture(e.TEXTURE_2D,null))),{texture:s,texShape:[n,t]}}function Fb(e){return e.internalFormatFloat}function Ob(e){return e.internalFormatHalfFloat}function Mb(e){return e.downloadTextureFormat}function $b(e){return e.internalFormatPackedFloat}function Db(e){return e.internalFormatPackedHalfFloat}class Pb{constructor(e){this.outputTexture=null,this.program=null,this.disposed=!1,this.itemsToPoll=[];const t=Mt().getNumber("WEBGL_VERSION");if(null!=e?(this.gl=e,function(e,t){Ty[e]=t}(t,e)):this.gl=Sy(t),e=this.gl,2===Mt().getNumber("WEBGL_VERSION")){const t=e;this.createVertexArray=()=>My(t,(()=>t.createVertexArray())),this.bindVertexArray=e=>My(t,(()=>t.bindVertexArray(e))),this.deleteVertexArray=e=>My(t,(()=>t.deleteVertexArray(e))),this.getVertexArray=()=>My(t,(()=>t.getParameter(t.VERTEX_ARRAY_BINDING)))}else if(null!=e){const t=e.getExtension("OES_vertex_array_object");if(null==t)throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object.");this.createVertexArray=()=>My(e,(()=>t.createVertexArrayOES())),this.bindVertexArray=n=>My(e,(()=>t.bindVertexArrayOES(n))),this.deleteVertexArray=n=>My(e,(()=>t.deleteVertexArrayOES(n))),this.getVertexArray=()=>My(e,(()=>e.getParameter(t.VERTEX_ARRAY_BINDING_OES)))}let n="WEBGL_color_buffer_float";const r="EXT_color_buffer_half_float";if(this.parallelCompilationExtension=this.gl.getExtension("KHR_parallel_shader_compile"),1===Mt().getNumber("WEBGL_VERSION")){const e="OES_texture_float",t="OES_texture_half_float";if(this.textureFloatExtension=Dy(this.gl,e),Jy(this.gl,t))this.textureHalfFloatExtension=Dy(this.gl,t);else if(Mt().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.");if(this.colorBufferFloatExtension=this.gl.getExtension(n),Jy(this.gl,r))this.colorBufferHalfFloatExtension=Dy(this.gl,r);else if(Mt().get("WEBGL_FORCE_F16_TEXTURES"))throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.")}else if(n="EXT_color_buffer_float",Jy(this.gl,n))this.colorBufferFloatExtension=this.gl.getExtension(n);else{if(!Jy(this.gl,r))throw new Error("GL context does not support color renderable floats");this.colorBufferHalfFloatExtension=this.gl.getExtension(r)}this.vertexBuffer=function(e){return function(e,t){const n=jy(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return My(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),My(e,(()=>e.bufferData(e.ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,-1,0,1,0]))}(this.gl),this.indexBuffer=function(e){return function(e,t){const n=jy(e,(()=>e.createBuffer()),"Unable to create WebGLBuffer");return My(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n))),My(e,(()=>e.bufferData(e.ELEMENT_ARRAY_BUFFER,t,e.STATIC_DRAW))),n}(e,new Uint16Array([0,1,2,2,1,3]))}(this.gl),this.framebuffer=function(e){return jy(e,(()=>e.createFramebuffer()),"Unable to create WebGLFramebuffer.")}(this.gl),this.textureConfig=Oy(this.gl,this.textureHalfFloatExtension)}get debug(){return Mt().getBool("DEBUG")}dispose(){if(this.disposed)return;null!=this.program&&console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."),null!=this.outputTexture&&console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing.");const e=this.gl;My(e,(()=>e.finish())),My(e,(()=>e.bindFramebuffer(e.FRAMEBUFFER,null))),My(e,(()=>e.deleteFramebuffer(this.framebuffer))),My(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,null))),My(e,(()=>e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null))),My(e,(()=>e.deleteBuffer(this.indexBuffer))),this.disposed=!0}createFloat32MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=Ny(t,n);return Rb(e,a,i,Fb(r),r.textureFormatFloat,e.FLOAT)}(this.gl,e,t,this.textureConfig)}createFloat16MatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=Ny(t,n);return Rb(e,a,i,Ob(r),r.textureFormatFloat,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createUnsignedBytesMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=Ny(t,n);return Rb(e,a,i,Mb(r),e.RGBA,e.UNSIGNED_BYTE)}(this.gl,e,t,this.textureConfig)}uploadPixelDataToTexture(e,t){this.throwIfDisposed(),function(e,t,n){My(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),n.data instanceof Uint8Array?2===Mt().getNumber("WEBGL_VERSION")?My(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n.width,n.height,e.RGBA,e.UNSIGNED_BYTE,n.data))):My(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,n.width,n.height,0,e.RGBA,e.UNSIGNED_BYTE,n.data))):2===Mt().getNumber("WEBGL_VERSION")?My(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n))):My(e,(()=>e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n))),My(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t)}uploadDenseMatrixToTexture(e,t,n,r){this.throwIfDisposed(),function(e,t,n,r,a,i){let s,o,u;My(e,(()=>e.bindTexture(e.TEXTURE_2D,t))),a instanceof Uint8Array?(s=new Uint8Array(n*r*4),o=e.UNSIGNED_BYTE,u=e.RGBA):(s=new Float32Array(n*r*4),o=e.FLOAT,u=i.internalFormatPackedFloat),s.set(a),2===Mt().getNumber("WEBGL_VERSION")?My(e,(()=>e.texSubImage2D(e.TEXTURE_2D,0,0,0,n,r,e.RGBA,o,s))):My(e,(()=>e.texImage2D(e.TEXTURE_2D,0,u,n,r,0,e.RGBA,o,s))),My(e,(()=>e.bindTexture(e.TEXTURE_2D,null)))}(this.gl,e,t,n,r,this.textureConfig)}createFloat16PackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=Fy(t,n);return Rb(e,a,i,Db(r),e.RGBA,r.textureTypeHalfFloat)}(this.gl,e,t,this.textureConfig)}createPackedMatrixTexture(e,t){return this.throwIfDisposed(),function(e,t,n,r){const[a,i]=Fy(t,n);return Rb(e,a,i,$b(r),e.RGBA,e.FLOAT)}(this.gl,e,t,this.textureConfig)}deleteMatrixTexture(e){this.throwIfDisposed(),this.outputTexture===e&&(Vy(this.gl,this.framebuffer),this.outputTexture=null),My(this.gl,(()=>this.gl.deleteTexture(e)))}downloadByteEncodedFloatMatrixFromOutputTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n,r){const[a,i]=Ny(t,n),s=new Uint8Array(t*n*4);return My(e,(()=>e.readPixels(0,0,a,i,r.downloadTextureFormat,e.UNSIGNED_BYTE,s))),new Float32Array(s.buffer)}(this.gl,t,n,this.textureConfig)))}downloadPackedMatrixFromBuffer(e,t,n,r,a,i){return function(e,t,n,r,a,i,s,o){const u=e,l=new Float32Array(function(e,t){const[n,r]=Fy(e,t);return n*r*4}(i,s));return u.bindBuffer(u.PIXEL_PACK_BUFFER,t),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,l),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),l}(this.gl,e,0,0,0,a,i,this.textureConfig)}downloadFloat32MatrixFromBuffer(e,t){return function(e,t,n){const r=e,a=new Float32Array(n);return r.bindBuffer(r.PIXEL_PACK_BUFFER,t),r.getBufferSubData(r.PIXEL_PACK_BUFFER,0,a),r.bindBuffer(r.PIXEL_PACK_BUFFER,null),a}(this.gl,e,t)}createBufferFromTexture(e,t,n){this.bindTextureToFrameBuffer(e);const r=function(e,t,n,r){const a=e.createBuffer();My(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,a)));const i=16*t*n;return My(e,(()=>e.bufferData(e.PIXEL_PACK_BUFFER,i,e.STREAM_READ))),My(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,0))),My(e,(()=>e.bindBuffer(e.PIXEL_PACK_BUFFER,null))),a}(this.gl,t,n,this.textureConfig);return this.unbindTextureToFrameBuffer(),r}createAndWaitForFence(){const e=this.createFence(this.gl);return this.pollFence(e)}createFence(e){let t,n;if(Mt().getBool("WEBGL_FENCE_API_ENABLED")){const r=e,a=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);e.flush(),n=()=>{const e=r.clientWaitSync(a,0,0);return e===r.ALREADY_SIGNALED||e===r.CONDITION_SATISFIED},t=a}else Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")>0?(t=this.beginQuery(),this.endQuery(),n=()=>this.isQueryAvailable(t,Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))):n=()=>!0;return{query:t,isFencePassed:n}}downloadMatrixFromPackedTexture(e,t,n){return this.downloadMatrixDriver(e,(()=>function(e,t,n){const r=new Float32Array(t*n*4);return My(e,(()=>e.readPixels(0,0,n,t,e.RGBA,e.FLOAT,r))),r}(this.gl,t,n)))}createProgram(e){this.throwIfDisposed();const t=this.gl;null==this.vertexShader&&(this.vertexShader=function(e){const t=nb();return function(e,t){const n=jy(e,(()=>e.createShader(e.VERTEX_SHADER)),"Unable to create vertex WebGLShader.");if(My(e,(()=>e.shaderSource(n,t))),My(e,(()=>e.compileShader(n))),!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw console.log(e.getShaderInfoLog(n)),new Error("Failed to compile vertex shader.");return n}(e,`${t.version}\n precision highp float;\n ${t.attribute} vec3 clipSpacePos;\n ${t.attribute} vec2 uv;\n ${t.varyingVs} vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }`)}(t));const n=function(e){return jy(e,(()=>e.createProgram()),"Unable to create WebGLProgram.")}(t);let r;return My(t,(()=>t.attachShader(n,this.vertexShader))),My(t,(()=>t.attachShader(n,e))),function(e,t){if(My(e,(()=>e.linkProgram(t))),!Mt().get("ENGINE_COMPILE_ONLY")&&!1===e.getProgramParameter(t,e.LINK_STATUS))throw console.log(e.getProgramInfoLog(t)),new Error("Failed to link vertex and fragment shaders.")}(t,n),r=Object.assign(n,{vao:this.createVertexArray()}),this.bindVertexArray(r.vao),My(t,(()=>t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer))),console.assert(function(e,t,n){return My(e,(()=>e.bindBuffer(e.ARRAY_BUFFER,n))),Uy(e,t,"clipSpacePos",n,3,20,0)&&Uy(e,t,"uv",n,2,20,12)}(t,r,this.vertexBuffer),"gpgpu_util.bindVertexProgramAttributeStreams not fully successful."),this.debug&&By(t,r),this.setProgram(r),r}deleteProgram(e){this.throwIfDisposed(),e===this.program&&(this.program=null),null!=e&&(My(this.gl,(()=>this.gl.deleteProgram(e))),this.deleteVertexArray(e.vao))}setProgram(e){this.throwIfDisposed(),this.program=e,null!=this.program&&(this.bindVertexArray(this.program.vao),this.debug&&By(this.gl,this.program)),My(this.gl,(()=>this.gl.useProgram(e)))}getUniformLocation(e,t,n=!0){return this.throwIfDisposed(),n?function(e,t,n){return jy(e,(()=>e.getUniformLocation(t,n)),'uniform "'+n+'" not present in program.')}(this.gl,e,t):function(e,t,n){return e.getUniformLocation(t,n)}(this.gl,e,t)}getAttributeLocation(e,t){return this.throwIfDisposed(),My(this.gl,(()=>this.gl.getAttribLocation(e,t)))}getUniformLocationNoThrow(e,t){return this.throwIfDisposed(),this.gl.getUniformLocation(e,t)}setInputMatrixTexture(e,t,n){this.throwIfDisposed(),this.throwIfNoProgram(),function(e,t,n,r){My(e,(()=>function(e,t,n){!function(e,t){const n=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS-1,r=t+e.TEXTURE0;if(r<e.TEXTURE0||r>n)throw new Error(`textureUnit must be in [gl.TEXTURE0, gl.TEXTURE${n}].`)}(e,n),My(e,(()=>e.activeTexture(e.TEXTURE0+n))),My(e,(()=>e.bindTexture(e.TEXTURE_2D,t)))}(e,t,r))),My(e,(()=>e.uniform1i(n,r)))}(this.gl,e,t,n)}setOutputMatrixTexture(e,t,n){this.setOutputMatrixTextureDriver(e,n,t)}setOutputPackedMatrixTexture(e,t,n){this.throwIfDisposed();const[r,a]=Fy(t,n);this.setOutputMatrixTextureDriver(e,r,a)}setOutputMatrixWriteRegion(e,t,n,r){this.setOutputMatrixWriteRegionDriver(n,e,r,t)}setOutputPackedMatrixWriteRegion(e,t,n,r){throw new Error("setOutputPackedMatrixWriteRegion not implemented.")}debugValidate(){null!=this.program&&By(this.gl,this.program),zy(this.gl)}executeProgram(){this.throwIfDisposed(),this.throwIfNoProgram();const e=this.gl;if(this.debug){const e=this.getVertexArray();console.assert(e===this.program.vao,"VAO changed between setProgram and executeProgram!"),this.debugValidate()}My(e,(()=>e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)))}blockUntilAllProgramsCompleted(){this.throwIfDisposed(),My(this.gl,(()=>this.gl.finish()))}getQueryTimerExtension(){return null==this.disjointQueryTimerExtension&&(this.disjointQueryTimerExtension=Dy(this.gl,2===Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query")),this.disjointQueryTimerExtension}getQueryTimerExtensionWebGL2(){return this.getQueryTimerExtension()}getQueryTimerExtensionWebGL1(){return this.getQueryTimerExtension()}beginQuery(){if(2===Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2(),n=e.createQuery();return e.beginQuery(t.TIME_ELAPSED_EXT,n),n}const e=this.getQueryTimerExtensionWebGL1(),t=e.createQueryEXT();return e.beginQueryEXT(e.TIME_ELAPSED_EXT,t),t}endQuery(){if(2===Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")){const e=this.gl,t=this.getQueryTimerExtensionWebGL2();return void e.endQuery(t.TIME_ELAPSED_EXT)}const e=this.getQueryTimerExtensionWebGL1();e.endQueryEXT(e.TIME_ELAPSED_EXT)}async waitForQueryAndGetTime(e){return await ct((()=>this.disposed||this.isQueryAvailable(e,Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))),this.getQueryTime(e,Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))}getQueryTime(e,t){if(0===t)return null;if(2===t){const t=this.gl;return t.getQueryParameter(e,t.QUERY_RESULT)/1e6}{const t=this.getQueryTimerExtensionWebGL1();return t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT)/1e6}}isQueryAvailable(e,t){if(0===t)return!0;if(2===t){const t=this.gl,n=this.getQueryTimerExtensionWebGL2(),r=t.getQueryParameter(e,t.QUERY_RESULT_AVAILABLE);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(n.GPU_DISJOINT_EXT)),r&&!this.disjoint}{const t=this.getQueryTimerExtensionWebGL1(),n=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT);return null==this.disjoint&&(this.disjoint=this.gl.getParameter(t.GPU_DISJOINT_EXT)),n&&!this.disjoint}}pollFence(e){return new Promise((t=>{this.addItemToPoll((()=>e.isFencePassed()),(()=>t()))}))}pollItems(){const e=function(e){let t=0;for(;t<e.length&&e[t]();++t);return t-1}(this.itemsToPoll.map((e=>e.isDoneFn)));for(let t=0;t<=e;++t){const{resolveFn:e}=this.itemsToPoll[t];e()}this.itemsToPoll=this.itemsToPoll.slice(e+1)}addItemToPoll(e,t){if(this.itemsToPoll.push({isDoneFn:e,resolveFn:t}),this.itemsToPoll.length>1)return;let n;"setTimeoutCustom"in Mt().platform&&(n=Mt().platform.setTimeoutCustom.bind(Mt().platform)),ct((()=>(this.pollItems(),0===this.itemsToPoll.length)),(()=>0),null,n)}bindTextureToFrameBuffer(e){this.throwIfDisposed(),Wy(this.gl,e,this.framebuffer),this.debug&&zy(this.gl)}unbindTextureToFrameBuffer(){null!=this.outputTexture?(Wy(this.gl,this.outputTexture,this.framebuffer),this.debug&&zy(this.gl)):Vy(this.gl,this.framebuffer)}downloadMatrixDriver(e,t){this.bindTextureToFrameBuffer(e);const n=t();return this.unbindTextureToFrameBuffer(),n}setOutputMatrixTextureDriver(e,t,n){this.throwIfDisposed();const r=this.gl;Wy(r,e,this.framebuffer),this.debug&&zy(r),this.outputTexture=e,My(r,(()=>r.viewport(0,0,t,n))),My(r,(()=>r.scissor(0,0,t,n)))}setOutputMatrixWriteRegionDriver(e,t,n,r){this.throwIfDisposed(),My(this.gl,(()=>this.gl.scissor(e,t,n,r)))}throwIfDisposed(){if(this.disposed)throw new Error("Attempted to use disposed GPGPUContext.")}throwIfNoProgram(){if(null==this.program)throw new Error("No GPU program is currently set.")}}const{addImpl:Lb,bincountImpl:Bb,bincountReduceImpl:Ub,castImpl:Wb,ceilImpl:Vb,concatImpl:zb,equalImpl:jb,expImpl:Gb,expm1Impl:Hb,floorImpl:Kb,gatherNdImpl:qb,gatherV2Impl:Xb,greaterImpl:Yb,greaterEqualImpl:Qb,lessImpl:Jb,lessEqualImpl:Zb,linSpaceImpl:ev,logImpl:tv,maxImpl:nv,maximumImpl:rv,minimumImpl:av,multiplyImpl:iv,negImpl:sv,notEqualImpl:ov,prodImpl:uv,raggedGatherImpl:lv,raggedRangeImpl:cv,raggedTensorToTensorImpl:hv,rangeImpl:pv,rsqrtImpl:dv,scatterImpl:fv,sigmoidImpl:mv,simpleAbsImpl:gv,sliceImpl:yv,sparseFillEmptyRowsImpl:bv,sparseReshapeImpl:vv,sparseSegmentReductionImpl:wv,sqrtImpl:_v,stridedSliceImpl:xv,stringNGramsImpl:kv,stringSplitImpl:Tv,stringToHashBucketFastImpl:Ev,subImpl:Sv,tileImpl:Iv,topKImpl:Av,transposeImpl:Cv,uniqueImpl:Nv}=Lg;function Rv(e,t){return["x","y","z","w","u","v"].slice(0,t).map((t=>`${e}.${t}`))}function Fv(e,t){return 1===t?[e]:Rv(e,t)}class Ov{constructor(e){if(this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.enableShapeUniforms=kb(this.outputShape.length),0===this.rank)this.userCode="\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n ";else{const e=Fv("rc",this.rank),t=yb(this.rank),n=this.getOutOfBoundsCondition(e),r=this.getSetup(e),a=this.getOutput(e);this.userCode=`\n void main() {\n ${t} rc = getOutputCoords();\n\n if(${n}) {\n setOutput(vec4(0));\n } else {\n ${r}\n\n setOutput(vec4(${a}));\n }\n }\n `}}getSourceCoordsArr(e){const t=[];for(let n=0;n<=1;n++)for(let r=0;r<=1;r++){let a=`${0===n?"r":"rp1"}, ${0===r?"c":"cp1"}`;for(let t=2;t<this.rank;t++)a=`${e[e.length-1-t]},`+a;t.push(a)}return t}getOutOfBoundsCondition(e){if(1===this.rank)return`rc > ${this.enableShapeUniforms?"outShape":this.outputShape[0]}`;let t="";for(let n=this.rank-2;n<this.rank;n++)t+=`${e[n]} >= ${this.enableShapeUniforms?`outShape[${n}]`:this.outputShape[n]}`,n<this.rank-1&&(t+="||");return t}getSetup(e){if(1===this.rank)return"";const t=e.slice(-2),n=this.enableShapeUniforms?`outShape[${this.rank} - 1]`:this.outputShape[this.rank-1],r=this.enableShapeUniforms?`outShape[${this.rank} - 2]`:this.outputShape[this.rank-2];return`\n int r = ${t[0]};\n int c = ${t[1]};\n int rp1 = r + 1;\n int cp1 = c + 1;\n\n bool cEdge = cp1 >= ${n};\n bool rEdge = rp1 >= ${r};\n `}getOutput(e){const t=this.getSourceCoordsArr(e);return 1===this.rank?`getA(rc), (rc + 1 >= ${this.enableShapeUniforms?"outShape":this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0`:`getA(${t[0]}),\n cEdge ? 0. : getA(${t[1]}),\n rEdge ? 0. : getA(${t[2]}),\n rEdge || cEdge ? 0. : getA(${t[3]})`}}class Mv{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec3"}],this.outputShape=e,this.enableShapeUniforms=kb(this.outputShape.length);let n="";for(let e=0;e<4;e++){let t="thisRC = rc;";e%2==1&&(t+="thisRC.z += 1;"),e>1&&(t+="thisRC.y += 1;"),n+=`\n ${t}\n ${e>0?"if(thisRC.y < rows && thisRC.z < cols){":""}\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result[${e}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${e>0?"}":""}\n `}var r,a;this.userCode=`\n ${r=t,a=this.enableShapeUniforms,`\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${a?function(e,t,n="index"){const r=e.map(((e,t)=>t)),a=function(e,t){const n=e.length,r=e.map((e=>`${t}[${e}]`)),a=new Array(n-1);a[n-2]=r[n-1];for(let e=n-3;e>=0;--e)a[e]=`(${a[e+1]} * ${r[e+1]})`;return a}(r,t);return a.map(((t,r)=>`int ${e[r]} = ${n} / ${a[r]}; ${r===a.length-1?`int ${e[r+1]} = ${n} - ${e[r]} * ${a[r]}`:`index -= ${e[r]} * ${a[r]}`};`)).join("")}(["r","c","d"],"inputShape"):rb(["r","c","d"],r)}\n return ivec3(r, c, d);\n }\n `}\n ${this.enableShapeUniforms?"\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n":ib(e)}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ${this.enableShapeUniforms?"outShape[1]":e[1]};\n int cols = ${this.enableShapeUniforms?"outShape[2]":e[2]};\n\n ${n}\n\n setOutput(result);\n }\n `}}class $v{constructor(e){this.gpgpu=e,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0,this.freeTextures={},this.logEnabled=!1,this.usedTextures={}}acquireTexture(e,t,n){const r=Pv(t,n),a=Lv(e,r,n);a in this.freeTextures||(this.freeTextures[a]=[]),a in this.usedTextures||(this.usedTextures[a]=[]);const i=Dv(e,r,this.gpgpu.gl,this.gpgpu.textureConfig,n);if(this.freeTextures[a].length>0){this.numFreeTextures--,this.numUsedTextures++,this._numBytesFree-=i,this.log();const e=this.freeTextures[a].shift();return this.usedTextures[a].push(e),e}let s;return r===Cy.PACKED_2X2_FLOAT32?s=this.gpgpu.createPackedMatrixTexture(e[0],e[1]):r===Cy.PACKED_2X2_FLOAT16?s=this.gpgpu.createFloat16PackedMatrixTexture(e[0],e[1]):r===Cy.UNPACKED_FLOAT32?s=this.gpgpu.createFloat32MatrixTexture(e[0],e[1]):r===Cy.UNPACKED_FLOAT16?s=this.gpgpu.createFloat16MatrixTexture(e[0],e[1]):r===Cy.PACKED_4X1_UNSIGNED_BYTE&&(s=this.gpgpu.createUnsignedBytesMatrixTexture(e[0],e[1])),this.usedTextures[a].push(s),this.numUsedTextures++,this._numBytesAllocated+=i,this.log(),s}releaseTexture(e,t,n,r){if(null==this.freeTextures)return;const a=Pv(n,r),i=Lv(t,a,r);i in this.freeTextures||(this.freeTextures[i]=[]);const s=Dv(t,a,this.gpgpu.gl,this.gpgpu.textureConfig,r),o=Mt().get("WEBGL_DELETE_TEXTURE_THRESHOLD");-1!==o&&this._numBytesAllocated>o?(this.gpgpu.deleteMatrixTexture(e.texture),this._numBytesAllocated-=s):(this.freeTextures[i].push(e),this.numFreeTextures++,this._numBytesFree+=s),this.numUsedTextures--;const u=this.usedTextures[i],l=u.indexOf(e);if(l<0)throw new Error("Cannot release a texture that was never provided by this texture manager");u.splice(l,1),this.log()}log(){if(!this.logEnabled)return;const e=this.numFreeTextures+this.numUsedTextures;console.log("Free/Used",`${this.numFreeTextures} / ${this.numUsedTextures}`,`(${e})`);const t=this._numBytesFree/this._numBytesAllocated;console.log(`Bytes allocated: ${this._numBytesAllocated}`),console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100*t)}%)`)}get numBytesAllocated(){return this._numBytesAllocated}get numBytesFree(){return this._numBytesFree}getNumUsedTextures(){return this.numUsedTextures}getNumFreeTextures(){return this.numFreeTextures}dispose(){if(null!=this.freeTextures){for(const e in this.freeTextures)this.freeTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));for(const e in this.usedTextures)this.usedTextures[e].forEach((e=>{this.gpgpu.deleteMatrixTexture(e.texture)}));this.freeTextures=null,this.usedTextures=null,this.numUsedTextures=0,this.numFreeTextures=0,this._numBytesAllocated=0,this._numBytesFree=0}}}function Dv(e,t,n,r,a){const i=function(e,t){switch(e){case Cy.PACKED_2X2_FLOAT32:return $b(t);case Cy.PACKED_2X2_FLOAT16:return Db(t);case Cy.UNPACKED_FLOAT32:return Fb(t);case Cy.UNPACKED_FLOAT16:return Ob(t);case Cy.PACKED_4X1_UNSIGNED_BYTE:return Mb(t);default:throw new Error(`Unknown physical texture type ${e}`)}}(t,r);let s;if(a){const[t,n]=Fy(e[0],e[1]);s=t*n}else{const[t,n]=Ny(e[0],e[1]);s=t*n}const o=function(e,t){const n=e;if(t===n.R32F)return 4;if(t===n.R16F)return 2;if(t===n.RGBA32F)return 16;if(t===e.RGBA)return 16;if(t===n.RGBA16F)return 8;if(t===n.RGBA8)return 4;throw new Error(`Unknown internal format ${t}`)}(n,i);return s*o}function Pv(e,t){if(e===Ay.UPLOAD)return Cy.PACKED_2X2_FLOAT32;if(e===Ay.RENDER||null==e)return function(e){return Mt().getBool("WEBGL_RENDER_FLOAT32_ENABLED")?e?Cy.PACKED_2X2_FLOAT32:Cy.UNPACKED_FLOAT32:e?Cy.PACKED_2X2_FLOAT16:Cy.UNPACKED_FLOAT16}(t);if(e===Ay.DOWNLOAD||e===Ay.PIXELS)return Cy.PACKED_4X1_UNSIGNED_BYTE;throw new Error(`Unknown logical texture type ${e}`)}function Lv(e,t,n){return`${e[0]}_${e[1]}_${t}_${n}`}class Bv{constructor(e,t){this.variableNames=["A"],this.outputShape=e,this.enableShapeUniforms=kb(this.outputShape.length),this.userCode=`\n float unaryOperation(float x) {\n ${t}\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}const Uv="if (isnan(x)) return x;",Wv="return x;",Vv="return abs(x);",zv="return (x >= 0.0) ? x : (exp(x) - 1.0);",jv=Uv+"\n return (x < 0.0) ? 0.0 : x;\n",Gv=Uv+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",Hv="return x;",Kv="return 1.0 / (1.0 + exp(-1.0 * x));",qv="return x;",Xv="\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n",Yv="\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",Qv="\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",Jv="return 1.0 / (1.0 + exp(-1.0 * x));";class Zv{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.enableShapeUniforms=kb(this.outputShape.length),this.userCode=`\n vec4 unaryOperation(vec4 x) {\n ${t}\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n `}}class ew{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!1,this.outputShape=e,this.enableShapeUniforms=kb(this.outputShape.length);const t=e.length,n=Fv("rc",t),r=yb(t),a=function(e,t){if(1===e)return"rc";let n="";for(let r=0;r<e;r++)n+=t[r],r<e-1&&(n+=",");return n}(t,n),i=n.slice(-2),s=t<=1?"rc":`vec2(${i.join(",")})`;this.userCode=`\n void main() {\n ${r} rc = getOutputCoords();\n vec4 packedInput = getA(${a});\n\n setOutput(getChannel(packedInput, ${s}));\n }\n `}}const tw=op,nw={},rw=Mt().getNumber("CPU_HANDOFF_SIZE_THRESHOLD");class aw extends Qe{constructor(e){if(super(),this.pendingRead=new WeakMap,this.pendingDisposal=new WeakSet,this.dataRefCount=new WeakMap,this.numBytesInGPU=0,this.uploadWaitMs=0,this.downloadWaitMs=0,this.lastGlFlushTime=0,this.warnedAboutMemory=!1,this.pendingDeletes=0,this.disposed=!1,!Mt().getBool("HAS_WEBGL"))throw new Error("WebGL is not supported on this device");let t;if(null!=e){if(e instanceof Pb)t=e;else{const n=Sy(Mt().getNumber("WEBGL_VERSION"),e);t=new Pb(n)}this.binaryCache={},this.gpgpuCreatedLocally=!1}else{const e=Sy(Mt().getNumber("WEBGL_VERSION"));t=new Pb(e),this.binaryCache=((n=Mt().getNumber("WEBGL_VERSION"))in nw||(nw[n]={}),nw[n]),this.gpgpuCreatedLocally=!0}var n;this.gpgpu=t,this.canvas=this.gpgpu.gl.canvas,this.textureManager=new $v(this.gpgpu),this.numMBBeforeWarning=null==Mt().global.screen?1024:Mt().global.screen.height*Mt().global.screen.width*window.devicePixelRatio*600/1024/1024,this.texData=new Ye(this,So())}nextDataId(){return aw.nextDataId++}numDataIds(){return this.texData.numDataIds()-this.pendingDeletes}writeTexture(e,t,n,r,a,i){const s=this.makeTensorInfo(t,n),o=this.texData.get(s.dataId);o.isPacked=!1,o.texture={texture:e,texShape:[r,a]},o.texShape=[r,a];const u=Ky(t),l=new Cb(u,!1,i),c=this.runWebGLProgram(l,[s],n,[[r,a]]);return c.shape=t,o.texture=null,this.disposeIntermediateTensorInfo(s),c.dataId}write(e,t,n){if((Mt().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS")||Mt().getBool("DEBUG"))&&this.checkNumericalProblems(e),"complex64"===n&&null!=e)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");const r={id:this.nextDataId()};return this.texData.set(r,{shape:t,dtype:n,values:e,usage:Ay.UPLOAD,refCount:1}),r}refCount(e){return this.texData.has(e)?this.texData.get(e).refCount:0}incRef(e){this.texData.get(e).refCount++}decRef(e){this.texData.has(e)&&this.texData.get(e).refCount--}move(e,t,n,r,a){if(Mt().getBool("DEBUG")&&this.checkNumericalProblems(t),"complex64"===r)throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag).");this.texData.set(e,{shape:n,dtype:r,values:t,usage:Ay.UPLOAD,refCount:a})}disposeIntermediateTensorInfo(e){this.disposeData(e.dataId)}readSync(e){const t=this.texData.get(e),{values:n,dtype:r,complexTensorInfos:a,slice:i,shape:s,isPacked:o}=t;if(null!=i){let t;t=o?new Zv(s,Hv):new Bv(s,Hv);const n=this.runWebGLProgram(t,[{dataId:e,shape:s,dtype:r}],r),a=this.readSync(n.dataId);return this.disposeIntermediateTensorInfo(n),a}if(null!=n)return this.convertAndCacheOnCPU(e);if("string"===r)return n;const u=null!=this.activeTimers;let l,c;return u&&(l=Aa()),c="complex64"===r?Pd(this.readSync(a.real.dataId),this.readSync(a.imag.dataId)):this.getValuesFromTexture(e),u&&(this.downloadWaitMs+=Aa()-l),this.convertAndCacheOnCPU(e,c)}async read(e){if(this.pendingRead.has(e)){const t=this.pendingRead.get(e);return new Promise((e=>t.push(e)))}const t=this.texData.get(e),{values:n,shape:r,slice:a,dtype:i,complexTensorInfos:s,isPacked:o}=t;if(null!=a){let t;t=o?new Zv(r,Hv):new Bv(r,Hv);const n=this.runWebGLProgram(t,[{dataId:e,shape:r,dtype:i}],i),a=this.read(n.dataId);return this.disposeIntermediateTensorInfo(n),a}if(null!=n)return this.convertAndCacheOnCPU(e);if(Mt().getBool("DEBUG")&&!Mt().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")&&2===Mt().getNumber("WEBGL_VERSION"))throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported.");let u,l,c=null;if("complex64"!==i&&Mt().get("WEBGL_BUFFER_SUPPORTED")){u=this.decode(e);const t=this.texData.get(u.dataId);c=this.gpgpu.createBufferFromTexture(t.texture.texture,...Ry(r))}if(this.pendingRead.set(e,[]),"complex64"!==i&&await this.gpgpu.createAndWaitForFence(),"complex64"===i){const e=await Promise.all([this.read(s.real.dataId),this.read(s.imag.dataId)]);l=Pd(e[0],e[1])}else if(null==c)l=this.getValuesFromTexture(e);else{const e=it(r);l=this.gpgpu.downloadFloat32MatrixFromBuffer(c,e)}if(null!=u&&this.disposeIntermediateTensorInfo(u),null!=c){const e=this.gpgpu.gl;My(e,(()=>e.deleteBuffer(c)))}const h=this.convertAndCacheOnCPU(e,l),p=this.pendingRead.get(e);return this.pendingRead.delete(e),p.forEach((e=>e(h))),this.pendingDisposal.has(e)&&(this.pendingDisposal.delete(e),this.disposeData(e)&&So().removeDataId(e,this),this.pendingDeletes--),h}readToGPU(e,t={}){const n=this.texData.get(e),{values:r,shape:a,slice:i,dtype:s,isPacked:o,texture:u}=n;if("complex64"===s)throw new Error("Does not support reading texture for complex64 dtype.");if(null!=i){let n;n=o?new Zv(a,Hv):new Bv(a,Hv);const r=this.runWebGLProgram(n,[{dataId:e,shape:a,dtype:s}],s),i=this.readToGPU(r,t);return this.disposeIntermediateTensorInfo(r),i}if(null==u)throw null!=r?new Error("Data is not on GPU but on CPU."):new Error("There is no data on GPU or CPU.");const l=this.decode(e,t.customTexShape),c=So().makeTensorFromTensorInfo(l),h=this.texData.get(l.dataId);return Object.assign({tensorRef:c},h.texture)}bufferSync(e){const t=this.readSync(e.dataId);if("string"===e.dtype)try{const n=t.map((e=>Na(e)));return nl(e.shape,e.dtype,n)}catch(e){throw new Error("Failed to decode encoded string bytes into utf-8")}return nl(e.shape,e.dtype,t)}checkNumericalProblems(e){if(null!=e)for(let t=0;t<e.length;t++){const n=e[t];if(!$y(n)){if(Mt().getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))throw Error(`The value ${n} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`);throw Error(`The value ${n} cannot be represented on this device.`)}}}getValuesFromTexture(e){const{shape:t,dtype:n,isPacked:r}=this.texData.get(e),a=it(t);if(Mt().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")){const n=this.decode(e),r=this.texData.get(n.dataId),i=this.gpgpu.downloadMatrixFromPackedTexture(r.texture.texture,...Ry(t)).subarray(0,a);return this.disposeIntermediateTensorInfo(n),i}const i=Mt().getBool("WEBGL_PACK")&&!0===r,s=i?Ky(t):t,o=i?new Ib(s):new Sb(s),u=this.runWebGLProgram(o,[{shape:s,dtype:n,dataId:e}],"float32"),l=this.texData.get(u.dataId),c=this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(l.texture.texture,l.texShape[0],l.texShape[1]).subarray(0,a);return this.disposeIntermediateTensorInfo(u),c}timerAvailable(){return Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0}time(e){const t=this.activeTimers,n=[];let r=!1;null==this.programTimersStack?(this.programTimersStack=n,r=!0):this.activeTimers.push(n),this.activeTimers=n,e();const a=Fa(this.activeTimers.map((e=>e.query))).filter((e=>null!=e)),i=Fa(this.activeTimers.map((e=>e.name))).filter((e=>null!=e));this.activeTimers=t,r&&(this.programTimersStack=null);const s={uploadWaitMs:this.uploadWaitMs,downloadWaitMs:this.downloadWaitMs,kernelMs:null,wallMs:null};return(async()=>{if(Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0){const e=await Promise.all(a);s.kernelMs=function(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}(e),s.getExtraProfileInfo=()=>e.map(((e,t)=>({name:i[t],ms:e}))).map((e=>`${e.name}: ${e.ms}`)).join(", ")}else s.kernelMs={error:"WebGL query timers are not supported in this environment."};return this.uploadWaitMs=0,this.downloadWaitMs=0,s})()}memory(){return{unreliable:!1,numBytesInGPU:this.numBytesInGPU,numBytesInGPUAllocated:this.textureManager.numBytesAllocated,numBytesInGPUFree:this.textureManager.numBytesFree}}startTimer(){return Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?this.gpgpu.beginQuery():{startMs:Aa(),endMs:null}}endTimer(e){return Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0?(this.gpgpu.endQuery(),e):(e.endMs=Aa(),e)}async getQueryTime(e){if(Mt().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE")>0)return this.gpgpu.waitForQueryAndGetTime(e);const t=e;return t.endMs-t.startMs}disposeData(e,t=!1){if(this.pendingDisposal.has(e))return!1;if(!this.texData.has(e))return!0;if(t?this.texData.get(e).refCount=0:this.texData.get(e).refCount--,!t&&this.texData.get(e).refCount>0)return!1;if(this.pendingRead.has(e))return this.pendingDisposal.add(e),this.pendingDeletes++,!1;this.releaseGPUData(e);const{complexTensorInfos:n}=this.texData.get(e);return null!=n&&(this.disposeData(n.real.dataId,t),this.disposeData(n.imag.dataId,t)),this.texData.delete(e),!0}releaseGPUData(e){const{texture:t,dtype:n,texShape:r,usage:a,isPacked:i,slice:s}=this.texData.get(e),o=s&&s.origDataId||e,u=this.dataRefCount.get(o);u>1?this.dataRefCount.set(o,u-1):(this.dataRefCount.delete(o),null!=t&&(this.numBytesInGPU-=this.computeBytes(r,n),this.textureManager.releaseTexture(t,r,a,i)));const l=this.texData.get(e);l.texture=null,l.texShape=null,l.isPacked=!1,l.slice=null}getTexture(e){return this.uploadToGPU(e),this.texData.get(e).texture.texture}getDataInfo(e){return this.texData.get(e)}shouldExecuteOnCPU(e,t=rw){return Mt().getBool("WEBGL_CPU_FORWARD")&&e.every((e=>null==this.texData.get(e.dataId).texture&&it(e.shape)<t))}getGPGPUContext(){return this.gpgpu}where(e){Mr("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead");const t=e.dataSync();return tw(e.shape,t)}packedUnaryOp(e,t,n){const r=new Zv(e.shape,t),a=this.compileAndRun(r,[e],n);return So().makeTensorFromTensorInfo(a)}abs(e){if(this.shouldExecuteOnCPU([e])&&"complex64"!==e.dtype){const t=gv(this.texData.get(e.dataId).values);return this.makeOutput(e.shape,e.dtype,t)}if(Mt().getBool("WEBGL_PACK_UNARY_OPERATIONS"))return this.packedUnaryOp(e,Vv,e.dtype);const t=new Bv(e.shape,Vv),n=this.compileAndRun(t,[e]);return So().makeTensorFromTensorInfo(n)}makeTensorInfo(e,t,n){let r;if("string"===t&&null!=n&&n.length>0&&bt(n[0])){const a=n.map((e=>Ca(e)));r=this.write(a,e,t)}else r=this.write(n,e,t);return this.texData.get(r).usage=null,{dataId:r,shape:e,dtype:t}}makeOutput(e,t,n){return So().makeTensorFromTensorInfo(this.makeTensorInfo(e,t,n),this)}unpackTensor(e){const t=new ew(e.shape);return this.runWebGLProgram(t,[e],e.dtype)}packTensor(e){const t=new Ov(e.shape);return this.runWebGLProgram(t,[e],e.dtype,null,!0)}packedReshape(e,t){const n=[Gy(e.shape),...Hy(e.shape)],r={dtype:e.dtype,shape:n,dataId:e.dataId},a=[Gy(t),...Hy(t)],i=new Mv(a,n),s=[n],o=this.runWebGLProgram(i,[r],e.dtype,s,!0);return{dataId:o.dataId,shape:t,dtype:o.dtype}}decode(e,t){const n=this.texData.get(e),{isPacked:r,shape:a,dtype:i}=n;null!=t&&nt(it(a)<=t[0]*t[1]*4,(()=>"customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data."));const s=Ky(a);let o;o=r?new Eb(s):new Tb(s);const u=[null!=t?t:Ry(s)];return{dtype:i,shape:a,dataId:this.runWebGLProgram(o,[{shape:s,dtype:i,dataId:e}],i,u,!0,t).dataId}}runWebGLProgram(e,t,n,r,a=!1,i){const s=this.makeTensorInfo(e.outputShape,n),o=this.texData.get(s.dataId);if(e.packedOutput&&(o.isPacked=!0),e.outPackingScheme===Iy.DENSE){const t=null!=i?i:Ry(e.outputShape);o.texShape=t.map((e=>2*e))}if(null!=e.outTexUsage&&(o.usage=e.outTexUsage),0===it(s.shape))return o.values=ft(s.dtype,0),s;const u=[],l=t.map((t=>{if("complex64"===t.dtype)throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");let n=this.texData.get(t.dataId);if(null==n.texture){if(!e.packedInputs&&it(t.shape)<=Mt().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM"))return{shape:t.shape,texData:null,isUniform:!0,uniformValues:n.values};e.packedInputs&&(n.isPacked=!0,n.shape=t.shape)}if(this.uploadToGPU(t.dataId),!!n.isPacked!=!!e.packedInputs)t=n.isPacked?this.unpackTensor(t):this.packTensor(t),u.push(t),n=this.texData.get(t.dataId);else if(n.isPacked&&!Xy(n.shape,t.shape)){const e=t,r=t.shape;t.shape=n.shape,t=this.packedReshape(t,r),u.push(t),n=this.texData.get(t.dataId),e.shape=r}return{shape:t.shape,texData:n,isUniform:!1}}));this.uploadToGPU(s.dataId);const c={shape:s.shape,texData:o,isUniform:!1},h=function(e,t,n){let r="";t.concat(n).forEach((t=>{const a=null!=t.texData&&null!=t.texData.slice&&t.texData.slice.flatOffset>0;if(e.enableShapeUniforms&&!t.isUniform){const i=t.texData.texShape,{useSqueezeShape:s,uniformShape:o,keptDims:u}=bb(e.packedInputs,t.shape,i);let l="",c="",h="";if(1===o.length&&e.packedInputs){const e=[Math.ceil(i[0]/2),Math.ceil(i[1]/2)];l=`${e[0]>1}_${e[1]>1}`}else if(2!==o.length||e.packedInputs){if(o.length>2&&!e.packedInputs){const e=xt(o);h=`${e[0]===i[1]}_${e[e.length-1]===i[1]}`}}else c=`${o[0]>1}_${o[1]>1}`;const p=t.shape.length,d=2===o.length&&st(t.shape,i),f=1===it(t.shape),m=Po(t.shape,n.shape),g=!e.packedInputs&&p===n.shape.length&&st(i,n.texData.texShape),y=e.packedInputs||o.length>2?"":`${i[0]>1}_${i[1]>1}`;r+=`${p}_${g}_${s?u:""}_${o.length}_${f}_${m}_${d}_${l}_${c}_${h}_${y}_${a}`}else{const e=t.isUniform?"uniform":t.texData.texShape;r+=`${t.shape}_${e}_${a}`}}));const a=e.userCode;let i=e.constructor.name;return i+="_"+r+"_"+a+`${Mt().getNumber("WEBGL_VERSION")}`,i}(e,l,c),p=this.getAndSaveBinary(h,(()=>function(e,t,n,r){const a=n.map(((e,n)=>{const r={logicalShape:e.shape,texShape:e.isUniform?null:e.texData.texShape,isUniform:e.isUniform,isPacked:!e.isUniform&&e.texData.isPacked,flatOffset:null};return null!=e.texData&&null!=e.texData.slice&&e.texData.slice.flatOffset>0&&(r.flatOffset=e.texData.slice.flatOffset),{name:t.variableNames[n],shapeInfo:r}})),i=a.map((e=>e.shapeInfo)),s={logicalShape:r.shape,texShape:r.texData.texShape,isUniform:!1,isPacked:r.texData.isPacked,flatOffset:null},o=ub(a,s,t),u=function(e,t){const n=jy(e,(()=>e.createShader(e.FRAGMENT_SHADER)),"Unable to create fragment WebGLShader.");if(My(e,(()=>e.shaderSource(n,t))),My(e,(()=>e.compileShader(n))),Mt().get("ENGINE_COMPILE_ONLY"))return n;if(!1===e.getShaderParameter(n,e.COMPILE_STATUS))throw Ly(t,e.getShaderInfoLog(n)),new Error("Failed to compile fragment shader.");return n}(e.gl,o),l=e.createProgram(u);return Mt().get("ENGINE_COMPILE_ONLY")?{program:t,fragmentShader:u,source:o,webGLProgram:l,inShapeInfos:i,outShapeInfo:s,uniformLocations:null,customUniformLocations:null,infLoc:null,nanLoc:null,inShapesLocations:null,inTexShapesLocations:null,outShapeLocation:null,outShapeStridesLocation:null,outTexShapeLocation:null}:Object.assign({program:t,fragmentShader:u,source:o,webGLProgram:l,inShapeInfos:i,outShapeInfo:s},_b(e,t,l))}(this.gpgpu,e,l,c))),d=null!=this.activeTimers;let f;d&&(f=this.startTimer()),Mt().get("ENGINE_COMPILE_ONLY")||function(e,t,n,r,a){t.program.enableShapeUniforms||(xb(t.inShapeInfos,n),xb([t.outShapeInfo],[r]));const i=r.texData.texture,s=r.texData.texShape;r.texData.isPacked?e.setOutputPackedMatrixTexture(i.texture,s[0],s[1]):e.setOutputMatrixTexture(i.texture,s[0],s[1]),e.setProgram(t.webGLProgram),1===Mt().getNumber("WEBGL_VERSION")&&null!==t.infLoc&&e.gl.uniform1f(t.infLoc,1/0),null!==t.nanLoc&&e.gl.uniform1f(t.nanLoc,NaN),n.forEach(((n,r)=>{const a=t.program.variableNames[r],i=t.uniformLocations[a],s=t.uniformLocations[`offset${a}`],o=t.inShapesLocations[`${a}Shape`],u=t.inTexShapesLocations[`${a}TexShape`];if(o){const{uniformShape:r}=bb(t.program.packedInputs,n.shape,n.texData.texShape);switch(r.length){case 1:e.gl.uniform1iv(o,new Int32Array(r));break;case 2:e.gl.uniform2iv(o,new Int32Array(r));break;case 3:e.gl.uniform3iv(o,new Int32Array(r));break;case 4:e.gl.uniform4iv(o,new Int32Array(r))}}if(u&&e.gl.uniform2i(u,n.texData.texShape[0],n.texData.texShape[1]),null!=i)if(n.isUniform)if(it(n.shape)<2)e.gl.uniform1f(i,n.uniformValues[0]);else{let t=n.uniformValues;t instanceof Float32Array||(t=new Float32Array(t)),e.gl.uniform1fv(i,t)}else null!=n.texData.slice&&null!=s&&e.gl.uniform1i(s,n.texData.slice.flatOffset),e.setInputMatrixTexture(n.texData.texture.texture,i,r)}));const o=t.outShapeLocation;if(o)switch(r.shape.length){case 1:e.gl.uniform1iv(o,new Int32Array(r.shape));break;case 2:e.gl.uniform2iv(o,new Int32Array(r.shape));break;case 3:e.gl.uniform3iv(o,new Int32Array(r.shape));break;case 4:e.gl.uniform4iv(o,new Int32Array(r.shape))}if(t.outShapeStridesLocation){const n=xt(r.shape);switch(r.shape.length){case 2:e.gl.uniform1iv(t.outShapeStridesLocation,new Int32Array(n));break;case 3:e.gl.uniform2iv(t.outShapeStridesLocation,new Int32Array(n));break;case 4:e.gl.uniform3iv(t.outShapeStridesLocation,new Int32Array(n))}}t.outTexShapeLocation&&e.gl.uniform2i(t.outTexShapeLocation,r.texData.texShape[0],r.texData.texShape[1]),t.program.customUniforms&&a&&t.program.customUniforms.forEach(((n,r)=>{const i=t.customUniformLocations[r],s=a[r];if("float"===n.type)e.gl.uniform1fv(i,s);else if("vec2"===n.type)e.gl.uniform2fv(i,s);else if("vec3"===n.type)e.gl.uniform3fv(i,s);else if("vec4"===n.type)e.gl.uniform4fv(i,s);else if("int"===n.type)e.gl.uniform1iv(i,s);else if("ivec2"===n.type)e.gl.uniform2iv(i,s);else if("ivec3"===n.type)e.gl.uniform3iv(i,s);else{if("ivec4"!==n.type)throw Error(`uniform type ${n.type} is not supported yet.`);e.gl.uniform4iv(i,s)}})),e.executeProgram()}(this.gpgpu,p,l,c,r),u.forEach((e=>this.disposeIntermediateTensorInfo(e))),d&&(f=this.endTimer(f),this.activeTimers.push({name:e.constructor.name,query:this.getQueryTime(f)}));const m=Mt().get("WEBGL_FLUSH_THRESHOLD");if(m>0){const e=Aa();e-this.lastGlFlushTime>m&&(this.gpgpu.gl.flush(),this.lastGlFlushTime=e)}if(!Mt().getBool("WEBGL_LAZILY_UNPACK")&&o.isPacked&&!1===a){const e=this.unpackTensor(s);return this.disposeIntermediateTensorInfo(s),e}return s}compileAndRun(e,t,n,r,a=!1){return n=n||t[0].dtype,this.runWebGLProgram(e,t,n,r,a)}getAndSaveBinary(e,t){return e in this.binaryCache||(this.binaryCache[e]=t()),this.binaryCache[e]}getTextureManager(){return this.textureManager}dispose(){this.disposed||(Mt().getBool("IS_TEST")||Object.keys(this.binaryCache).forEach((e=>{this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram),delete this.binaryCache[e]})),this.textureManager.dispose(),null!=this.canvas&&"undefined"!=typeof HTMLCanvasElement&&this.canvas instanceof HTMLCanvasElement?this.canvas.remove():this.canvas=null,this.gpgpuCreatedLocally&&(this.gpgpu.program=null,this.gpgpu.dispose()),this.disposed=!0)}floatPrecision(){return null==this.floatPrecisionValue&&(this.floatPrecisionValue=Io((()=>{if(!Mt().get("WEBGL_RENDER_FLOAT32_ENABLED")){const e=Mt().getBool("DEBUG");Mt().set("DEBUG",!1);const t=this.abs(Gl(1e-8)).dataSync()[0];if(Mt().set("DEBUG",e),t>0)return 32}return 16}))),this.floatPrecisionValue}epsilon(){return 32===this.floatPrecision()?1e-7:1e-4}uploadToGPU(e){const t=this.texData.get(e),{shape:n,dtype:r,values:a,texture:i,usage:s,isPacked:o}=t;if(null!=i)return;const u=null!=this.activeTimers;let l;u&&(l=Aa());let c=t.texShape;if(null==c&&(c=function(e,t=!1){let n=Mt().getNumber("WEBGL_MAX_TEXTURE_SIZE"),r=Mt().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");if(r===1/0&&Mt().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE")&&(r=n/2),t&&(n*=2,r*=2,e=e.map(((t,n)=>n>=e.length-2?et(e[n]):e[n])),1===e.length&&(e=[2,e[0]])),2!==e.length){const t=dt(e);e=t.newShape}let a=it(e),i=null;e.length<=1&&a<=n?i=[1,a]:2===e.length&&e[0]<=n&&e[1]<=n?i=e:3===e.length&&e[0]*e[1]<=n&&e[2]<=n?i=[e[0]*e[1],e[2]]:3===e.length&&e[0]<=n&&e[1]*e[2]<=n?i=[e[0],e[1]*e[2]]:4===e.length&&e[0]*e[1]*e[2]<=n&&e[3]<=n?i=[e[0]*e[1]*e[2],e[3]]:4===e.length&&e[0]<=n&&e[1]*e[2]*e[3]<=n&&(i=[e[0],e[1]*e[2]*e[3]]);const s=null!=i&&Math.max(...i)>r&&Math.min(...i)<=(t?2:1)&&Math.min(...i)>0;if(null==i||s)if(t){const t=Gy(e);let n=2,r=2;e.length&&([n,r]=Hy(e)),a=t*(n/2)*(r/2),i=ut(a).map((e=>2*e))}else i=ut(a);return i}(n,o),t.texShape=c),null!=a){const e=Ky(n);let i,s=c[1],h=c[0];const p=a instanceof Uint8Array||a instanceof Uint8ClampedArray;!o&&p||([s,h]=Fy(c[0],c[1])),i=o?new Nb(e,p):new Cb(e,p);const d=p?[h,s]:c,f=this.makeTensorInfo(d,r),m=this.texData.get(f.dataId);m.usage=p?Ay.PIXELS:Ay.UPLOAD,m.texShape=d,this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(f.dataId),s,h,a);const g=[[h,s]],y=!0,b=this.runWebGLProgram(i,[f],r,g,y),v=this.texData.get(b.dataId);t.texShape=v.texShape,t.isPacked=v.isPacked,t.usage=v.usage,Mt().get("ENGINE_COMPILE_ONLY")?this.disposeData(b.dataId):(t.texture=v.texture,t.values=null,this.texData.delete(b.dataId)),this.disposeIntermediateTensorInfo(f),u&&(this.uploadWaitMs+=Aa()-l)}else{const e=this.acquireTexture(c,s,r,o);t.texture=e}}convertAndCacheOnCPU(e,t){const n=this.texData.get(e),{dtype:r}=n;return null!=t&&(n.values=function(e,t){if("float32"===t||"complex64"===t)return e;if("int32"===t||"bool"===t){const n="int32"===t?new Int32Array(e.length):new Uint8Array(e.length);for(let t=0;t<n.length;++t)n[t]=Math.round(e[t]);return n}throw new Error(`Unknown dtype ${t}`)}(t,r)),n.values}acquireTexture(e,t,n,r){if(this.numBytesInGPU+=this.computeBytes(e,n),!this.warnedAboutMemory&&this.numBytesInGPU>1024*this.numMBBeforeWarning*1024){const e=(this.numBytesInGPU/1024/1024).toFixed(2);this.warnedAboutMemory=!0,console.warn(`High memory usage in GPU: ${e} MB, most likely due to a memory leak`)}return this.textureManager.acquireTexture(e,t,r)}computeBytes(e,t){return e[0]*e[1]*yt(t)}checkCompileCompletion(){for(const[,e]of Object.entries(this.binaryCache))this.checkCompletion_(e)}async checkCompileCompletionAsync(){const e=[];if(this.gpgpu.parallelCompilationExtension){for(const[,t]of Object.entries(this.binaryCache))e.push(this.checkCompletionAsync_(t));return Promise.all(e)}for(const[,t]of Object.entries(this.binaryCache)){const n=new Promise((e=>{try{this.checkCompletion_(t),e(!0)}catch(e){throw e}}));e.push(n)}return Promise.all(e)}async checkCompletionAsync_(e){return this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR)?this.checkCompletion_(e):(await new Promise((e=>_d((()=>e())))),this.checkCompletionAsync_(e))}checkCompletion_(e){if(!1===this.gpgpu.gl.getProgramParameter(e.webGLProgram,this.gpgpu.gl.LINK_STATUS)){if(console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)),!1===this.gpgpu.gl.getShaderParameter(e.fragmentShader,this.gpgpu.gl.COMPILE_STATUS))throw Ly(e.source,this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)),new Error("Failed to compile fragment shader.");throw new Error("Failed to link vertex and fragment shaders.")}return!0}getUniformLocations(){for(const[,e]of Object.entries(this.binaryCache)){const{uniformLocations:t,customUniformLocations:n,infLoc:r,nanLoc:a,inShapesLocations:i,inTexShapesLocations:s,outShapeLocation:o,outShapeStridesLocation:u,outTexShapeLocation:l}=_b(this.gpgpu,e.program,e.webGLProgram);e.uniformLocations=t,e.customUniformLocations=n,e.infLoc=r,e.nanLoc=a,e.inShapesLocations=i,e.inTexShapesLocations=s,e.outShapeLocation=o,e.outShapeStridesLocation=u,e.outTexShapeLocation=l}}createTensorFromGPUData(e,t,n){e.channels=e.channels||"RGBA";const{texture:r,height:a,width:i,channels:s}=e,o=So().backend;if(!o.gpgpu.gl.isTexture(r))throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'.");const u=o.writeTexture(r,t,n,a,i,s);return So().makeTensorFromDataId(u,t,n,o)}}aw.nextDataId=0,pi()&&Fo("webgl",(()=>new aw),2);class iw{constructor(e){this.variableNames=["A"];const t=nb(),[n,r]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}.0, ${n}.0);\n\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n `}}class sw{constructor(e){this.variableNames=["A"],this.packedInputs=!1,this.packedOutput=!0;const t=nb(),[n,r]=e;this.outputShape=e,this.userCode=`\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}.0, ${n}.0);\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n ${t.output} = result;\n }\n `}}const ow={kernelName:Cr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e;let{pixels:a}=t;const{numChannels:i}=r,s="undefined"!=typeof HTMLVideoElement&&a instanceof HTMLVideoElement,o="undefined"!=typeof HTMLImageElement&&a instanceof HTMLImageElement,[u,l]=s?[a.videoWidth,a.videoHeight]:[a.width,a.height],c=[l,u],h=[l,u,i];if(o||s){const e=Mt().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");null!=uw&&e===lw||(lw=e,uw=document.createElement("canvas").getContext("2d",{willReadFrequently:lw})),uw.canvas.width=u,uw.canvas.height=l,uw.drawImage(a,0,0,u,l),a=uw.canvas}const p=n.makeTensorInfo(c,"int32");n.texData.get(p.dataId).usage=Ay.PIXELS,n.gpgpu.uploadPixelDataToTexture(n.getTexture(p.dataId),a);const d=Mt().getBool("WEBGL_PACK")?new sw(h):new iw(h),f=n.runWebGLProgram(d,[p],"int32");return n.disposeData(p.dataId),f}};let uw,lw=Mt().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU");function cw(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{shape:i}=r,s=n,o=it(a.shape),u=ht(i,o),l=it(u);nt(o===l,(()=>`The new shape (${u}) has ${l} elements and the old shape (${a.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`));const c=s.texData.get(a.dataId);return!c.isPacked||Xy(a.shape,u)||null!==c.texture&&Xy(c.shape,u)?(s.incRef(a.dataId),{dataId:a.dataId,shape:u,dtype:a.dtype}):function(e,t,n){const r=[Gy(e.shape),...Hy(e.shape)],a={dtype:e.dtype,shape:r,dataId:e.dataId},i=[Gy(t),...Hy(t)],s=new Mv(i,r),o=[r],u=n.runWebGLProgram(s,[a],e.dtype,o,!0);return{dataId:u.dataId,shape:t,dtype:u.dtype}}(a,u,s)}const hw={kernelName:Xn,backendName:"webgl",kernelFunc:cw};function pw(e){const{inputs:t,attrs:n,backend:r}=e,{dim:a}=n,{input:i}=t,s=i.shape.length,o=i.shape.slice();let u=a;return a<0&&(nt(-(s+1)<=a,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+a+1),o.splice(u,0,1),cw({inputs:{x:i},backend:r,attrs:{shape:o}})}const dw={kernelName:cn,backendName:"webgl",kernelFunc:pw};class fw{constructor(e,t,n,r,a){this.variableNames=["A"],this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let h;h=a?"(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)":"vec2(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0]/c[0]},\n ${l[1]/c[1]});\n const vec2 inputShapeRC = vec2(${s}.0, ${o}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${h};\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\n `}}class mw{constructor(e,t,n,r,a){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[];const[i,s,o,u]=e;this.outputShape=[i,t,n,u];const l=[r&&t>1?s-1:s,r&&n>1?o-1:o],c=[r&&t>1?t-1:t,r&&n>1?n-1:n];let h;h=a?"(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)":"vec3(yRC) * effectiveInputOverOutputRatioRC",this.userCode=`\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0]/c[0]},\n ${l[1]/c[1]},\n ${l[1]/c[1]});\n const vec3 inputShapeRC = vec3(${s}.0, ${o}.0,\n ${o}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${h};\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u-1};\n bool hasNextRow = coords.z < ${n-1};\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n `}}const gw={kernelName:Qn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{images:a}=t,{alignCorners:i,halfPixelCenters:s,size:o}=r,[u,l]=o,c=Mt().getBool("WEBGL_PACK_IMAGE_OPERATIONS")?new mw(a.shape,u,l,i,s):new fw(a.shape,u,l,i,s);return n.runWebGLProgram(c,[a],"float32")}};function yw(e){const{inputs:t,backend:n}=e,{x:r}=t;return n.incRef(r.dataId),{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}const bw={kernelName:wn,backendName:"webgl",kernelFunc:yw};function vw(e){const{inputs:t,backend:n}=e,{real:r,imag:a}=t,i=n.makeTensorInfo(r.shape,"complex64"),s=n.texData.get(i.dataId),o=yw({inputs:{x:r},backend:n}),u=yw({inputs:{x:a},backend:n});return s.complexTensorInfos={real:o,imag:u},i}class ww{constructor(e,t,n){this.variableNames=["A","B"],this.outputShape=Bo(t,n),this.enableShapeUniforms=kb(this.outputShape.length),this.userCode=`\n float binaryOperation(float a, float b) {\n ${e}\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n `}}class _w{constructor(e,t,n,r=!1){this.variableNames=["A","B"],this.supportsBroadcasting=!0,this.packedInputs=!0,this.packedOutput=!0,this.outputShape=Bo(t,n);const a=this.outputShape.length;this.enableShapeUniforms=kb(a);let i="";if(r)if(0===a||1===it(this.outputShape))i="\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n ";else if(i=`\n ${yb(a)} coords = getOutputCoords();\n `,1===a)this.enableShapeUniforms?i+="\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n ":i+=`\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `;else{const e=Fv("coords",a);this.enableShapeUniforms?i+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= outShape[${a} - 2];\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= outShape[${a} - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `:i+=`\n bool nextRowOutOfBounds =\n (${e[a-2]} + 1) >= ${this.outputShape[a-2]};\n bool nextColOutOfBounds =\n (${e[a-1]} + 1) >= ${this.outputShape[a-1]};\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n `}this.userCode=`\n vec4 binaryOperation(vec4 a, vec4 b) {\n ${e}\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n ${i}\n\n setOutput(result);\n }\n `}}const xw="return (a < 0.) ? b * a : a;",kw="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",Tw="return (a < 0.) ? b * a : a;",Ew="\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n",Sw="if (isnan(x)) return x;";function Iw({opSnippet:e,packedOpSnippet:t,cpuKernelImpl:n,dtype:r}){return({inputs:a,backend:i})=>{const{x:s}=a,o=i,u=r||s.dtype;if(o.shouldExecuteOnCPU([s])&&null!=n){const e=o.texData.get(s.dataId),t=n(e.values,u);return o.makeTensorInfo(s.shape,u,t)}let l;return l=Mt().getBool("WEBGL_PACK_UNARY_OPERATIONS")&&null!=t?new Zv(s.shape,t):new Bv(s.shape,e),o.runWebGLProgram(l,[s],u)}}function Aw({opSnippet:e,packedOpSnippet:t,checkOutOfBounds:n=!1,supportsComplex:r=!1,cpuKernelImpl:a,dtype:i}){return({inputs:s,backend:o})=>{const{a:u,b:l}=s,c=o;if(r&&"complex64"===u.dtype){const t=c.texData.get(u.dataId),n=c.texData.get(l.dataId),[r,a]=[[t.complexTensorInfos.real,n.complexTensorInfos.real],[t.complexTensorInfos.imag,n.complexTensorInfos.imag]].map((t=>{const[n,r]=t,a={dataId:n.dataId,dtype:n.dtype,shape:u.shape},i={dataId:r.dataId,dtype:r.dtype,shape:l.shape},s=new ww(e,u.shape,l.shape);return c.runWebGLProgram(s,[a,i],ti(n.dtype,r.dtype))})),i=vw({inputs:{real:r,imag:a},backend:c});return c.disposeIntermediateTensorInfo(r),c.disposeIntermediateTensorInfo(a),i}const h=i||ti(u.dtype,l.dtype);if(("string"===u.dtype||"string"===l.dtype||c.shouldExecuteOnCPU([u,l]))&&null!=a){const e=c.texData.get(u.dataId).values,t=c.texData.get(l.dataId).values,n="string"===u.dtype?Jd(e):e,r="string"===u.dtype?Jd(t):t,[i,s]=a(u.shape,l.shape,n,r,h),o=c.makeTensorInfo(s,h);return c.texData.get(o.dataId).values=i,o}let p;return p=Mt().getBool("WEBGL_PACK_BINARY_OPERATIONS")&&null!=t?new _w(t,u.shape,l.shape,n):new ww(e,u.shape,l.shape),c.runWebGLProgram(p,[u,l],h)}}function Cw(e,t=!1){if("linear"===e)return t?qv:Wv;if("relu"===e)return t?Yv:jv;if("elu"===e)return t?Xv:zv;if("relu6"===e)return t?Qv:Gv;if("prelu"===e)return t?Ew:Tw;if("leakyrelu"===e)return t?kw:xw;if("sigmoid"===e)return t?Jv:Kv;throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`)}const Nw=Aw({opSnippet:"return float(a != b);",cpuKernelImpl:ov,dtype:"bool"});function Rw(e){const{inputs:t,backend:n}=e,{input:r}=t;return yw({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.real},backend:n})}const Fw={kernelName:Kt,backendName:"webgl",kernelFunc:function e(t){const{inputs:n,backend:r,attrs:a}=t,{x:i}=n,{dtype:s}=a;if("complex64"===s){if("complex64"===i.dtype)return yw({inputs:{x:i},backend:r});const t=Oc(i.shape),n=e({inputs:{x:i},backend:r,attrs:{dtype:"float32"}}),a=vw({inputs:{real:n,imag:t},backend:r});return t.dispose(),r.disposeIntermediateTensorInfo(n),a}if("complex64"===i.dtype){const t=Rw({inputs:{input:i},backend:r}),n=e({inputs:{x:t},backend:r,attrs:{dtype:s}});return r.disposeIntermediateTensorInfo(t),n}if(!gt(i.dtype,s)){const e=yw({inputs:{x:i},backend:r});return{dataId:e.dataId,shape:e.shape,dtype:s}}if(r.shouldExecuteOnCPU([i])){const e=r.texData.get(i.dataId).values,[t,n,a]=Wb(e,i.shape,i.dtype,s);return r.makeTensorInfo(t,n,a)}if("int32"===s)return function(e,t){const n=new Bv(e.shape,"return float(int(x));"),r=t.runWebGLProgram(n,[e],"int32");return{dataId:r.dataId,shape:r.shape,dtype:r.dtype}}(i,r);if("bool"===s){const e=r.makeTensorInfo([],"bool",ft("bool",1)),t=Nw({inputs:{a:i,b:e},backend:r});return r.disposeIntermediateTensorInfo(e),t}throw new Error(`Error in Cast: failed to cast ${i.dtype} to ${s}`)}},Ow=Aw({opSnippet:"\nif (a == b) {\n return 1.0;\n};\nreturn a / b;",packedOpSnippet:"\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n",checkOutOfBounds:!0}),Mw={kernelName:sn,backendName:"webgl",kernelFunc:Ow};class $w{constructor(e,t,n){this.variableNames=["x"],this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=yb(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=["coords[0]","coords[1]","coords[2]","coords[3]"].slice(0,r);this.userCode=1!==r?`\n ${a} start = ${a}(${i});\n ${a} end = ${a}(${s});\n\n void main() {\n ${a} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${a} coords = outC - start;\n setOutput(getX(${o}));\n }\n }\n `:`\n int start = ${i};\n int end = ${s};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\n `}}class Dw{constructor(e,t,n){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"value",type:"float"}],this.outputShape=t.map(((t,n)=>t[0]+e[n]+t[1]));const r=e.length,a=yb(r),i=t.map((e=>e[0])).join(","),s=t.map(((t,n)=>t[0]+e[n])).join(","),o=Fv("rc",r),u=Fv("source",r),l=`${o[r-1]} < ${this.outputShape[r-1]}`,c=1===r?"source":`vec2(${u.slice(-2).join()})`,h=[`${a} rc = outputLoc;`,`${o[r-1]} += 1;\n if(${l}) {\n `,1===r?"":`}\n rc = outputLoc;\n ${o[r-2]} += 1;\n if(${o[r-2]} < ${this.outputShape[r-2]}) {`,1===r?"":` ${o[r-1]} += 1;\n if(${l}) {`],p=1===r?"rc < start || rc >= end":"any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))";let d="";for(let e=0,t=1===r?2:4;e<t;e++)d+=`\n ${h[e]}\n if (${p}) {\n result[${e}] = float(value);\n } else {\n ${a} source = rc - start;\n result[${e}] = getChannel(getX(${u.join()}), ${c});\n }\n `;d+=1===r?"} ":"}}",this.userCode=`\n const ${a} start = ${a}(${i});\n const ${a} end = ${a}(${s});\n\n void main() {\n ${a} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${d}\n setOutput(result);\n }\n `}}class Pw{constructor(e,t){this.outputShape=[],this.customUniforms=[{name:"value",type:"float"}],this.variableNames=["x"],this.outputShape=e,this.userCode="\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n "}}const Lw=e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{paddings:i,constantValue:s}=r;if(0===it(a.shape)){const e=i.map(((e,t)=>e[0]+a.shape[t]+e[1]));return function(e){const{backend:t,attrs:n}=e,{shape:r,value:a}=n;let{dtype:i}=n;if(i=i||vt(a),"string"===i){const e=mt(i,it(r));return e.fill(a),t.makeTensorInfo(r,i,e)}{const e=new Pw(r,a),n=[[a]];return t.runWebGLProgram(e,[],i,n)}}({backend:n,attrs:{shape:e,value:s,dtype:a.dtype}})}const o=Mt().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Dw(a.shape,i,s):new $w(a.shape,i,s),u=[[s]];return n.runWebGLProgram(o,[a],a.dtype,u)},Bw={kernelName:zn,backendName:"webgl",kernelFunc:Lw};class Uw{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.outputShape=e.outShape;const i=e.padInfo.top,s=e.padInfo.left,o=e.strideHeight,u=e.strideWidth,l=e.dilationHeight,c=e.dilationWidth,h=e.filterHeight,p=e.filterWidth,d=4*Math.floor(e.inChannels/4),f=e.inChannels%4,m="channelsLast"===e.dataFormat,g=m?1:2,y=m?2:3,b=m?3:1;let v="",w="";n&&(v=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,w="result = activation(result);");const _=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${v}\n\n const ivec2 strides = ivec2(${o}, ${u});\n const ivec2 pads = ivec2(${i}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${b}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${y}]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${h}; wR++) {\n int xR = xRCorner + wR * ${l};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${p}; wC++) {\n int xC = xCCorner + wC * ${c};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${d}; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if (${m}) {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if (${1===f}) {\n\n if (${m}) {\n dotProd +=\n getX(batch, xR, xC, ${d}) *\n getW(wR, wC, ${d}, d2);\n } else {\n dotProd +=\n getX(batch, ${d}, xR, xC) *\n getW(wR, wC, ${d}, d2);\n }\n\n } else if (${2===f}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${d}, d2),\n getW(wR, wC, ${d} + 1, d2)\n );\n\n if (${m}) {\n vec2 xValues = vec2(\n getX(batch, xR, xC, ${d}),\n getX(batch, xR, xC, ${d} + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, ${d}, xR, xC),\n getX(batch, ${d} + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if (${3===f}) {\n vec3 wValues = vec3(\n getW(wR, wC, ${d}, d2),\n getW(wR, wC, ${d} + 1, d2),\n getW(wR, wC, ${d} + 2, d2)\n );\n\n if (${m}) {\n vec3 xValues = vec3(\n getX(batch, xR, xC, ${d}),\n getX(batch, xR, xC, ${d} + 1),\n getX(batch, xR, xC, ${d} + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, ${d}, xR, xC),\n getX(batch, ${d} + 1, xR, xC),\n getX(batch, ${d} + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n ${_}\n ${w}\n setOutput(result);\n }\n `}}class Ww{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=kb(this.outputShape.length);const i=e.padInfo.left,s=e.strideWidth,o=e.dilationWidth,u=e.filterHeight,l=e.filterWidth,c=l;let h="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e<l;e++)h+=`\n vec4 xTexelC${2*e};\n int xTexelC${2*e}Ready;\n vec4 xTexelC${2*e+1};\n int xTexelC${2*e+1}Ready;\n vec4 xC${e};`;h+=`\n for (int r = 0; r < ${u}; r++) {\n for (int d1 = 0; d1 < ${e.inChannels}; d1 += 2) {\n `;for(let e=0;e<l;e++)h+=`\n xTexelC${2*e} = vec4(0.0);\n xTexelC${2*e}Ready = 0;\n xTexelC${2*e+1} = vec4(0.0);\n xTexelC${2*e+1}Ready = 0;\n xC${e} = vec4(0.0);`;h+="\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n ";for(let t=0;t<(c+1)/2;t++){const n=2*t;if(h+=`\n xC = xCCorner + ${n*o};\n `,1===s){if(n<l&&(i%2==1?(h+=`\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n `,h+=1===o&&n>0?`\n xC${n} = vec4(xTexelC${n-2}.zw, xTexelC${n}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${n} = vec4(previous.zw, xTexelC${n}.xy);\n } else {\n xC${n} = vec4(0.0, 0.0, xTexelC${n}.xy);\n }\n `):h+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xC${n} = xTexelC${n};\n `,n+1<l)){const e=i%2==0?et(o):o;o%2==0&&i%2==1||o%2!=0&&i%2!=1?(h+=`\n xCOffset = xC + imod(pads[1], 2) + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n `,h+=o>1?`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${n+1} = vec4(previous.zw, xTexelC${n+1}.xy);\n } else {\n xC${n+1} = vec4(0.0, 0.0, xTexelC${n+1}.xy);\n }\n `:`\n xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+1}.xy);\n `):h+=1===e?`\n xC${n+1} = xTexelC${n};\n `:`\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n+1} = xTexelC${n+1};\n `}}else n<l&&(i%2==1?(h+=`\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.0);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n} = vec4(xTexelC${n}.zw, xTexelC${n+1}.zw);\n `,n+1<l&&(h+=`\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${n+1} = vec4(xTexelC${n+1}.xy, final.xy);\n `)):(h+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n+1}Ready == 0) {\n xTexelC${n+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n+1}.zw = vec2(0.);\n }\n xTexelC${n+1}Ready = 1;\n }\n\n xC${n} = vec4(\n xTexelC${n}.xy, xTexelC${n+1}.xy);\n `,n+1<l&&(h+=`\n xC${n+1} = vec4(xTexelC${n}.zw, xTexelC${n+1}.zw);\n `)));n<l&&(h+=`\n wTexel = getW(r, ${n}, d1, d2);\n dotProd += xC${n}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${e.inChannels}) {\n dotProd += xC${n}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `,n+1<l&&(h+=`\n wTexel = getW(r, ${n+1}, d1, d2);\n dotProd += xC${n+1}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${e.inChannels}) {\n dotProd += xC${n+1}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `))}h+="\n }\n ",h+="\n }\n ",h+="\n }\n ";let p="",d="";n&&(p=r?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`vec4 activation(vec4 x) {\n ${n}\n }`,d="result = activation(result);");const f=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${p}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${h}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${f}\n ${d}\n setOutput(result);\n }\n `}}class Vw{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"inputShape",type:"ivec4"},{name:"pad",type:"ivec2"},{name:"stride",type:"ivec2"},{name:"dilation",type:"ivec2"},{name:"inChannels",type:"int"},{name:"itemsPerBlockRow",type:"int"},{name:"outWidth",type:"int"}],this.outputShape=e,this.enableShapeUniforms=kb(this.outputShape.length);const{dataFormat:n}=t,r=nb(),a="channelsLast"===n,i=a?1:2,s=a?2:3,o=this.enableShapeUniforms?"if(blockIndex < outShape[2] && pos < outShape[1]) {":`if(blockIndex < ${e[2]} && pos < ${e[1]}) {`;let u="";for(let e=0;e<=1;e++)for(let t=0;t<=1;t++)u+=`\n blockIndex = rc.z + ${t};\n pos = rc.y + ${e};\n\n ${o}\n offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];\n d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);\n\n if(d0 < inputShape[${i}] && d0 >= 0) {\n // Use custom imod instead mod. On Intel GPU, mod may generate\n // unexpected value.\n // https://github.com/tensorflow/tfjs/issues/5447\n offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];\n d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /\n inChannels);\n\n if(d1 < inputShape[${s}] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if (${a}) {\n innerDims = vec2(d1, ch);\n result[${2*e+t}] = getChannel(\n getA(rc.x, d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2*e+t}] = getChannel(\n getA(rc.x, ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n `;this.userCode=`\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n ${u}\n\n ${r.output} = result;\n }\n `}}class zw{constructor(e,t,n,r=!1,a=!1,i=!1,s=null,o=!1,u=!1){this.variableNames=["matrixA","matrixB"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=n,this.enableShapeUniforms=kb(this.outputShape.length);const l=r?e[1]:e[2],c=Math.ceil(l/2),h=r?"i * 2, rc.y":"rc.y, i * 2",p=a?"rc.z, i * 2":"i * 2, rc.z",d=r?["a.xxyy","a.zzww"]:["a.xxzz","a.yyww"],f=a?["b.xzxz","b.ywyw"]:["b.xyxy","b.zwzw"];let m="",g="";s&&(m=o?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${s}\n }`:u?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${s}\n }`:`vec4 activation(vec4 x) {\n ${s}\n }`,g="result = activation(result);");const y=i?"result += getBiasAtOutCoords();":"";i&&this.variableNames.push("bias"),o&&this.variableNames.push("preluActivationWeights"),u&&this.variableNames.push("leakyreluAlpha");let b="rc.x",v="rc.x";e[0]<t[0]?b=`imod(rc.x, ${e[0]})`:t[0]<e[0]&&(v=`imod(rc.x, ${t[0]})`),this.userCode=`\n ${m}\n // Don't use uniform for sharedDimensionPacked for performance.\n const float sharedDimension = ${c}.0;\n\n vec4 dot2x2ARowBCol(ivec3 rc) {\n vec4 result = vec4(0);\n int batchA = ${b};\n int batchB = ${v};\n for (int i = 0; i < ${c}; i++) {\n vec4 a = getMatrixA(batchA, ${h});\n vec4 b = getMatrixB(batchB, ${p});\n\n // These swizzled products need to be separately added.\n // See: https://github.com/tensorflow/tfjs/issues/1735\n result += (${d[0]} * ${f[0]});\n result += (${d[1]} * ${f[1]});\n }\n return result;\n }\n\n void main() {\n ivec3 rc = getOutputCoords();\n vec4 result = dot2x2ARowBCol(rc);\n\n ${y}\n\n ${g}\n\n setOutput(result);\n }\n `}}const jw={REAL:"return areal * breal - aimag * bimag;",IMAG:"return areal * bimag + aimag * breal;"};class Gw{constructor(e,t,n){this.variableNames=["AReal","AImag","BReal","BImag"],this.outputShape=Bo(t,n),this.userCode=`\n float binaryOpComplex(\n float areal, float aimag, float breal, float bimag) {\n ${e}\n }\n\n void main() {\n float areal = getARealAtOutCoords();\n float aimag = getAImagAtOutCoords();\n float breal = getBRealAtOutCoords();\n float bimag = getBImagAtOutCoords();\n setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n }\n `}}const Hw="return a * b;";function Kw(e){const{inputs:t,backend:n}=e,{a:r,b:a}=t,i=ti(r.dtype,a.dtype);if("complex64"===r.dtype){const e=n.texData.get(r.dataId),t=n.texData.get(a.dataId),i=new Gw(jw.REAL,r.shape,a.shape),s=new Gw(jw.IMAG,r.shape,a.shape),o=[{dataId:e.complexTensorInfos.real.dataId,dtype:e.complexTensorInfos.real.dtype,shape:r.shape},{dataId:e.complexTensorInfos.imag.dataId,dtype:e.complexTensorInfos.imag.dtype,shape:r.shape},{dataId:t.complexTensorInfos.real.dataId,dtype:t.complexTensorInfos.real.dtype,shape:a.shape},{dataId:t.complexTensorInfos.imag.dataId,dtype:t.complexTensorInfos.imag.dtype,shape:a.shape}],u=n.runWebGLProgram(i,o,"float32"),l=n.runWebGLProgram(s,o,"float32"),c=vw({inputs:{real:u,imag:l},backend:n});return n.disposeIntermediateTensorInfo(u),n.disposeIntermediateTensorInfo(l),c}if(n.shouldExecuteOnCPU([r,a])){const e=n.texData.get(r.dataId),t=n.texData.get(a.dataId),[s,o]=iv(r.shape,a.shape,e.values,t.values,i),u=n.makeTensorInfo(o,i);return n.texData.get(u.dataId).values=s,u}let s;return s=Mt().getBool("WEBGL_PACK_BINARY_OPERATIONS")?new _w(Hw,r.shape,a.shape):new ww(Hw,r.shape,a.shape),n.runWebGLProgram(s,[r,a],i)}const qw={kernelName:$n,backendName:"webgl",kernelFunc:Kw};class Xw{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:i}=e;this.outputShape=[r,i];const s=4*Math.floor(n/4),o=n%4;let u="sumValue += dot(values, ones);";if(null!=t){const e=1/t;u=`sumValue += dot(values * ${ot(e)?e.toPrecision(2):e}, ones);`}let l="";a%n>0&&(l=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return 0.0;\n }\n `),this.userCode=`\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${l}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${s}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${u}\n }\n\n int inIdx = inOffset + ${s};\n if (${1===o}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${u}\n } else if (${2===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${u}\n } else if (${3===o}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ${u}\n }\n setOutput(sumValue);\n }\n `}}class Yw{constructor(e,t){this.variableNames=["x"];const{windowSize:n,batchSize:r,inSize:a,outSize:i}=e;this.outputShape=[r,i];let s="0.0",o="";"prod"===t?s="1.0":"min"===t?(s="1.0 / 1e-20",o="min"):"max"===t&&(s="-1.0 / 1e-20",o="max");let u=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"sum"===t?u="sumValue":"prod"===t?u="prodValue":"all"===t?u="allValue":"any"===t&&(u="anyValue");const l=4*Math.floor(n/4),c=n%4;let h=`\n if (${"sum"===t}) {\n sumValue += dot(values, ones);\n } else if (${"prod"===t}) {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = ${o}(values, minMaxValue);\n if (${"min"===t} || ${"max"===t}) {\n minMaxValue = ${o}(values, minMaxValue);\n bvec4 isNaN = isnan(values);\n if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {\n minMaxValue = vec4(NAN);\n }\n }\n }\n `,p="vec4";"all"===t?(s="1.0",h="\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ",p="bvec4"):"any"===t&&(s="0.0",h="\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ",p="bvec4");let d="";a%n>0&&(d=`\n if (inIdx < 0 || inIdx >= ${a}) {\n return initializationValue;\n }\n `),this.userCode=`\n const float initializationValue = ${s};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${d}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n vec4 minMaxValue = vec4(${s});\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < ${l}; i += 4) {\n int inIdx = inOffset + i;\n ${p} values = ${p}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${h}\n }\n\n int inIdx = inOffset + ${l};\n if (${1===c}) {\n ${p} values = ${p}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${h}\n } else if (${2===c}) {\n ${p} values = ${p}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${h}\n } else if (${3===c}) {\n ${p} values = ${p}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${h}\n }\n setOutput(${u});\n }\n `}}function Qw(e,t,n,r){const a=function(e){const t=[];for(;0===t.length||1!==t[t.length-1].outSize;){const n=t.length?t[t.length-1].outSize:e[1],r=Nd(n);t.push({inSize:n,windowSize:r,outSize:Math.ceil(n/r)})}return t}(e.shape);let i=e;for(let s=0;s<a.length;s++){const{inSize:o,windowSize:u,outSize:l}=a[s];let c,h;c="mean"===n?0===s?new Xw({windowSize:u,inSize:o,batchSize:e.shape[0],outSize:l},o):new Xw({windowSize:u,inSize:o,batchSize:e.shape[0],outSize:l}):new Yw({windowSize:u,inSize:o,batchSize:e.shape[0],outSize:l},n),h=i,i=r.runWebGLProgram(c,[i],t),h.dataId!==e.dataId&&r.disposeIntermediateTensorInfo(h)}return i}class Jw{constructor(e,t){this.variableNames=["A"];const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];this.outputShape=n,this.rank=n.length;const r=yb(this.rank),a=function(e){const t=e.length;if(t>6)throw Error(`Transpose for rank ${t} is not yet supported`);const n=["resRC.x","resRC.y","resRC.z","resRC.w","resRC.u","resRC.v"],r=new Array(t);for(let t=0;t<e.length;t++)r[e[t]]=n[t];return r.join()}(t);this.userCode=`\n void main() {\n ${r} resRC = getOutputCoords();\n setOutput(getA(${a}));\n }\n `}}class Zw{constructor(e,t){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0;const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];if(this.outputShape=n,this.rank=n.length,this.rank>6)throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);const r=yb(this.rank),a=Rv("rc",this.rank),i=new Array(this.rank);for(let e=0;e<t.length;e++)i[t[e]]=a[e];const s=`vec2(${i.slice(-2).join()})`,o=`++${a[this.rank-1]} < ${n[this.rank-1]}`,u=`getChannel(getA(${i.join()}), ${s})`;this.userCode=`\n void main() {\n ${r} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result[0] = ${u};\n if(${o}) {\n result[1] = ${u};\n }\n --${a[this.rank-1]};\n if(++${a[this.rank-2]} < ${n[this.rank-2]}) {\n result[2] = ${u};\n if(${o}) {\n result[3] = ${u};\n }\n }\n setOutput(result);\n }\n `}}function e_(e,t,n){const r=Mt().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new Zw(e.shape,t):new Jw(e.shape,t);return n.runWebGLProgram(r,[e],e.dtype)}function t_(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,keepDims:s}=r;return function(e,t,n,r){const a=t,i=e.shape.length,s=pt(a,e.shape);let o=s;const u=Bl(o,i),l=null!=u;let c=e;l&&(c=e_(e,u,r),o=Wl(o.length,i)),Ll("sum",o,i);const[h,p]=Dl(c.shape,o);let d=h;n&&(d=Pl(h,s));const f=it(p),m=cw({inputs:{x:c},attrs:{shape:[it(e.shape)/f,f]},backend:r}),g=Qw(m,ti(e.dtype,"int32"),"sum",r),y=cw({inputs:{x:g},attrs:{shape:d},backend:r});return r.disposeIntermediateTensorInfo(m),r.disposeIntermediateTensorInfo(g),l&&r.disposeIntermediateTensorInfo(c),y}(a,i,s,n)}function n_(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{perm:i}=r,s=n,o=a.shape.length,u=new Array(o);for(let e=0;e<u.length;e++)u[e]=a.shape[i[e]];let l;if(s.shouldExecuteOnCPU([a])){const e=s.texData.get(a.dataId).values,t=Cv(e,a.shape,a.dtype,i,u);l=s.makeTensorInfo(u,a.dtype),s.texData.get(l.dataId).values=t}else l=e_(a,i,s);return l}const r_=1e3;function a_({a:e,b:t,transposeA:n,transposeB:r,backend:a,bias:i=null,preluActivationWeights:s=null,leakyreluAlpha:o=0,activation:u=null}){const l=e.shape.length,c=t.shape.length,h=n?e.shape[l-2]:e.shape[l-1],p=r?t.shape[c-1]:t.shape[c-2],d=n?e.shape[l-1]:e.shape[l-2],f=r?t.shape[c-2]:t.shape[c-1],m=e.shape.slice(0,-2),g=t.shape.slice(0,-2),y=it(m),b=it(g),v=Bo(e.shape.slice(0,-2),t.shape.slice(0,-2)).concat([d,f]);nt(h===p,(()=>`Error in matMul: inner shapes (${h}) and (${p}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`));const w=n?[y,h,d]:[y,d,h],_=r?[b,f,p]:[b,p,f],x=cw({inputs:{x:e},backend:a,attrs:{shape:w}}),k=cw({inputs:{x:t},backend:a,attrs:{shape:_}}),T=[x,k],E=Math.max(y,b),S=n?x.shape[1]:x.shape[2],I=null!=i,A=null!=s,C="leakyrelu"===u,N=null!=u?Cw(u,!0):null;let R;if((1===d||1===f)&&S>r_&&!1===(I||A||C||null!=N)){let e=x,t=k;n&&(e=n_({inputs:{x},backend:a,attrs:{perm:[0,2,1]}}),T.push(e)),r&&(t=n_({inputs:{x:k},backend:a,attrs:{perm:[0,2,1]}}),T.push(t));const i=1===f;let s=e;1!==f&&(s=cw({inputs:{x:e},backend:a,attrs:{shape:[E,S,1]}}),T.push(s));const o=1===f?2:1;let u=t;i&&(u=cw({inputs:{x:t},backend:a,attrs:{shape:[E,1,S]}}),T.push(u));const l=Kw({inputs:{a:s,b:u},backend:a});R=t_({inputs:{x:l},backend:a,attrs:{axis:o,keepDims:!0}}),T.push(l)}else{const u=ti(e.dtype,t.dtype),l=new zw(w,_,[E,d,f],n,r,I,N,A,C),c=[x,k];if(null!=i&&c.push(i),A&&c.push(s),C){const e=a.makeTensorInfo([],"float32",Sa(o,"float32"));c.push(e),T.push(e)}R=a.runWebGLProgram(l,c,u)}const F=cw({inputs:{x:R},backend:a,attrs:{shape:v}});T.push(R);for(const e of T)a.disposeIntermediateTensorInfo(e);return F}function i_(e,t){const n=e.length;return n>=3?t?[...e.slice(0,-3),e[n-3]*e[n-2],e[n-1]]:[...e.slice(0,-3),e[n-3],e[n-2]*e[n-1]]:!t&&1===n&&e[0]>1?[e[0],1]:null}function s_({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:s=0,activation:o=null}){const u=e.shape,l=r.texData.get(e.dataId),c=n.inChannels,h=u[0]*u[1]*u[2],p=n.outChannels,d="channelsLast"===n.dataFormat;let f;const m=[];if(null!=i){const e=i_(i.shape,d);null!=e&&(i=cw({inputs:{x:i},backend:r,attrs:{shape:e}}),m.push(i))}if(null!=a){const e=i_(a.shape,d);null!=e&&(a=cw({inputs:{x:a},backend:r,attrs:{shape:e}}),m.push(a))}if((1!==h&&1!==p||!(c>r_))&&l.isPacked&&d&&null!=l.texture&&u[2]%2!=0&&st(l.shape.slice(-3),u.slice(-3))){const c=u[0]*u[1]*(u[2]+1),h={dataId:e.dataId,shape:[1,c,n.inChannels],dtype:e.dtype},p=l.shape;l.shape=l.shape.slice(),l.shape[l.shape.length-2]++,nt(Xy(l.shape,h.shape),(()=>`packed reshape ${l.shape} to ${h.shape} isn't free`));const d=cw({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}});m.push(d);const g=a_({a:h,b:d,backend:r,transposeA:!1,transposeB:!1,bias:a,activation:o,preluActivationWeights:i,leakyreluAlpha:s}),y=r.texData.get(g.dataId);nt(y.isPacked,(()=>"batchMatMul result is expected to be packed")),l.shape=p,y.shape=n.outShape,f=yw({inputs:{x:g},backend:r}),f.shape=n.outShape,m.push(g)}else{const u=n.outHeight*n.outWidth,l=cw({inputs:{x:e},backend:r,attrs:{shape:d?[n.batchSize,u,n.inChannels]:[n.batchSize,n.inChannels,u]}}),c=cw({inputs:{x:t},backend:r,attrs:{shape:[1,n.inChannels,n.outChannels]}}),h=a_({a:d?l:c,b:d?c:l,transposeA:!d,transposeB:!1,backend:r,bias:a,activation:o,preluActivationWeights:i,leakyreluAlpha:s});f=cw({inputs:{x:h},backend:r,attrs:{shape:n.outShape}}),m.push(l),m.push(c),m.push(h)}for(const e of m)r.disposeIntermediateTensorInfo(e);return f}function o_({x:e,filter:t,convInfo:n,backend:r,bias:a=null,preluActivationWeights:i=null,leakyreluAlpha:s=0,activation:o=null}){const{filterWidth:u,filterHeight:l,inChannels:c,outWidth:h,outHeight:p,dataFormat:d}=n,f="channelsLast"===d,m=u*l*c,g=p*h,y=[n.batchSize,m,g],b=[];if(null!=i){const e=i_(i.shape,f);null!=e&&(i=cw({inputs:{x:i},backend:r,attrs:{shape:e}}),b.push(i))}if(null!=a){const e=i_(a.shape,f);null!=e&&(a=cw({inputs:{x:a},backend:r,attrs:{shape:e}}),b.push(a))}const v=cw({inputs:{x:t},backend:r,attrs:{shape:[1,m,it(t.shape)/m]}});b.push(v);const w=new Vw(y,n),_=[e.shape,[n.padInfo.top,n.padInfo.left],[n.strideHeight,n.strideWidth],[n.dilationHeight,n.dilationWidth],[n.inChannels],[n.filterWidth*n.inChannels],[n.outWidth]],x=r.runWebGLProgram(w,[e],"float32",_),k=cw({inputs:{x},backend:r,attrs:{shape:y}});b.push(x),b.push(k);const T=null!=a,E=null!=i,S="leakyrelu"===o,I=o?Cw(o,!0):null,A=new zw(f?k.shape:v.shape,f?v.shape:k.shape,f?[n.batchSize,g,n.outChannels]:[n.batchSize,n.outChannels,g],!0,!1,T,I,E,S),C=f?[k,v]:[v,k];if(a&&C.push(a),E&&C.push(i),S){const e=r.makeTensorInfo([],"float32",Sa(s,"float32"));C.push(e),b.push(e)}const N=r.runWebGLProgram(A,C,"float32"),R=cw({inputs:{x:N},backend:r,attrs:{shape:n.outShape}});b.push(N);for(const e of b)r.disposeIntermediateTensorInfo(e);return R}const u_={kernelName:Qt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dataFormat:u,dilations:l,dimRoundingMode:c}=r,h=Pu(u),p=Iu(a.shape,i.shape,s,l,o,c,!1,h);let d;if(1!==p.filterHeight||1!==p.filterWidth||1!==p.dilationHeight||1!==p.dilationWidth||1!==p.strideHeight||1!==p.strideWidth||"SAME"!==p.padInfo.type&&"VALID"!==p.padInfo.type)if(p.strideWidth<=2&&"channelsLast"===h&&Mt().getBool("WEBGL_EXP_CONV")){const e=new Ww(p),t=[[p.padInfo.top,p.padInfo.left],[p.strideHeight,p.strideWidth],[p.dilationHeight,p.dilationWidth],[p.inHeight,p.inWidth]];d=n.runWebGLProgram(e,[a,i],"float32",t)}else if(Mt().getBool("WEBGL_CONV_IM2COL"))d=o_({x:a,filter:i,convInfo:p,backend:n});else{const e=new Uw(p);d=n.runWebGLProgram(e,[a,i],"float32")}else d=s_({x:a,filter:i,convInfo:p,backend:n});const f=cw({inputs:{x:d},backend:n,attrs:{shape:p.outShape}});return n.disposeIntermediateTensorInfo(d),f}},l_={kernelName:Fr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dataFormat:c,dilations:h,dimRoundingMode:p,activation:d,leakyreluAlpha:f}=r,m=Pu(c),g=Iu(a.shape,i.shape,u,h,l,p,!1,m);let y;const b=[],v=null!=s,w=null!=o,_="leakyrelu"===d,x=()=>{const e=[a,i],t=(e,t)=>{if("NCHW"===t&&1===e.shape.length&&1!==e.shape[0]){const t=cw({inputs:{x:e},backend:n,attrs:{shape:[e.shape[0],1,1]}});return b.push(t),t}return e};if(v&&e.push(t(s,c)),w&&e.push(t(o,c)),_){const t=n.makeTensorInfo([],"float32",Sa(f,"float32"));e.push(t),b.push(t)}return e};if(1!==g.filterHeight||1!==g.filterWidth||1!==g.dilationHeight||1!==g.dilationWidth||1!==g.strideHeight||1!==g.strideWidth||"SAME"!==g.padInfo.type&&"VALID"!==g.padInfo.type)if(g.strideWidth<=2&&"channelsLast"===m&&Mt().getBool("WEBGL_EXP_CONV")){const e=d?Cw(d,!0):null,t=new Ww(g,v,e,w,_),r=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],a=x();y=n.runWebGLProgram(t,a,"float32",r)}else if(Mt().getBool("WEBGL_CONV_IM2COL"))y=o_({x:a,filter:i,convInfo:g,backend:n,bias:s,activation:d,preluActivationWeights:o,leakyreluAlpha:f});else{const e=d?Cw(d,!1):null,t=new Uw(g,v,e,w,_),r=x();y=n.runWebGLProgram(t,r,"float32")}else y=s_({x:a,filter:i,convInfo:g,backend:n,bias:s,activation:d,preluActivationWeights:o,leakyreluAlpha:f});const k=cw({inputs:{x:y},backend:n,attrs:{shape:g.outShape}});return b.push(y),b.forEach((e=>n.disposeIntermediateTensorInfo(e))),k}};class c_{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=kb(this.outputShape.length);const i=e.filterHeight,s=e.filterWidth,o=e.outChannels/e.inChannels;let u="",l="";n&&(u=r?`float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`\n float activation(float x) {\n ${n}\n }\n `,l="result = activation(result);");const c=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${u}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${o};\n int q = d2 - d1 * ${o};\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < ${i}; wR++) {\n int xR = xRCorner + wR * dilations[0];\n\n if (xR < 0 || xR >= inDims[0]) {\n continue;\n }\n\n for (int wC = 0; wC < ${s}; wC++) {\n int xC = xCCorner + wC * dilations[1];\n\n if (xC < 0 || xC >= inDims[1]) {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n ${c}\n ${l}\n setOutput(result);\n }\n `}}class h_{constructor(e,t=!1,n=null,r=!1,a=!1){this.variableNames=["x","W"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"pads",type:"ivec2"},{name:"strides",type:"ivec2"},{name:"dilations",type:"ivec2"},{name:"inDims",type:"ivec2"}],this.outputShape=e.outShape,this.enableShapeUniforms=kb(this.outputShape.length);const i=e.outChannels/e.inChannels,s=e.padInfo.left,o=e.strideWidth,u=e.dilationWidth,l=e.filterHeight,c=e.filterWidth,h=c;let p="\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;";for(let e=0;e<c;e++)p+=`\n vec4 xTexelC${2*e};\n int xTexelC${2*e}Ready;\n vec4 xTexelC${2*e+1};\n int xTexelC${2*e+1}Ready;\n vec4 xC${e};`;p+=`\n for (int r = 0; r < ${l}; r++) {\n `;for(let e=0;e<c;e++)p+=`\n xTexelC${2*e} = vec4(0.0);\n xTexelC${2*e}Ready = 0;\n xTexelC${2*e+1} = vec4(0.0);\n xTexelC${2*e+1}Ready = 0;\n xC${e} = vec4(0.0);`;p+="\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n ";for(let e=0;e<(h+1)/2;e++){const t=2*e;if(p+=`\n xC = xCCorner + ${t*u};\n `,1===o){if(t<c&&(s%2==1?(p+=`\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n `,p+=1===u&&t>0?`\n xC${t} = vec4(xTexelC${t-2}.zw, xTexelC${t}.xy);\n `:`\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${t} = vec4(previous.zw, xTexelC${t}.xy);\n } else {\n xC${t} = vec4(0.0, 0.0, xTexelC${t}.xy);\n }\n `):p+=`\n if (xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xC${t} = xTexelC${t};\n `,t+1<c)){const e=s%2==0?et(u):u;u%2==0&&s%2==1||u%2!=0&&s%2!=1?(p+=`\n xCOffset = xC + imod(pads[1], 2) + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n `,p+=u>1?`\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${t+1} = vec4(previous.zw, xTexelC${t+1}.xy);\n } else {\n xC${t+1} = vec4(0.0, 0.0, xTexelC${t+1}.xy);\n }\n `:`\n xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.xy);\n `):p+=1===e?`\n xC${t+1} = xTexelC${t};\n `:`\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t+1} = xTexelC${t+1};\n `}}else t<c&&(s%2==1?(p+=`\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.0);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw);\n `,t+1<c&&(p+=`\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${t+1} = vec4(xTexelC${t+1}.xy, final.xy);\n `)):(p+=`\n if(xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t+1}Ready == 0) {\n xTexelC${t+1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t+1}.zw = vec2(0.);\n }\n xTexelC${t+1}Ready = 1;\n }\n\n xC${t} = vec4(\n xTexelC${t}.xy, xTexelC${t+1}.xy);\n `,t+1<c&&(p+=`\n xC${t+1} = vec4(xTexelC${t}.zw, xTexelC${t+1}.zw);\n `)));t<c&&(p+=`\n wTexel = getW(r, ${t}, d1, q);\n dotProd += xC${t} * vec4(wTexel.xz, wTexel.xz);\n `,t+1<c&&(p+=`\n wTexel = getW(r, ${t+1}, d1, q);\n dotProd += xC${t+1} * vec4(wTexel.xz, wTexel.xz);\n `))}p+="\n }\n ",p+="\n }\n ";let d="",f="";n&&(d=r?`vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }`:a?`vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }`:`vec4 activation(vec4 x) {\n ${n}\n }`,f="result = activation(result);");const m=t?"result += getBiasAtOutCoords();":"";t&&this.variableNames.push("bias"),r&&this.variableNames.push("preluActivationWeights"),a&&this.variableNames.push("leakyreluAlpha"),this.userCode=`\n ${d}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${i};\n int q = d2 - d1 * ${i};\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${p}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${m}\n ${f}\n setOutput(result);\n }\n `}}const p_={kernelName:Or,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dilations:c,dimRoundingMode:h,activation:p,leakyreluAlpha:d}=r,f=[];let m=c;null==m&&(m=[1,1]),nt($u(u,m),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${m}'`));const g=Iu(a.shape,i.shape,u,m,l,h,!0),y=Mt().getBool("WEBGL_PACK_DEPTHWISECONV")&&g.strideWidth<=2&&g.outChannels/g.inChannels==1,b=p?Cw(p,y):null,v=[a,i],w=null!=s,_=null!=o,x="leakyrelu"===p;if(w&&v.push(s),_&&v.push(o),x){const e=n.makeTensorInfo([],"float32",Sa(d,"float32"));v.push(e),f.push(e)}let k;k=y?new h_(g,w,b,_,x):new c_(g,w,b,_,x);const T=[[g.padInfo.top,g.padInfo.left],[g.strideHeight,g.strideWidth],[g.dilationHeight,g.dilationWidth],[g.inHeight,g.inWidth]],E=n.runWebGLProgram(k,v,"float32",T);return f.forEach((e=>n.disposeIntermediateTensorInfo(e))),E}},d_="return a + b;",f_=Aw({opSnippet:d_,packedOpSnippet:d_,supportsComplex:!0,cpuKernelImpl:Lb}),m_={kernelName:Bt,backendName:"webgl",kernelFunc:f_},g_={kernelName:ur,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,paddings:s}=r;nt(a.shape.length<=4,(()=>"spaceToBatchND for rank > 4 with a WebGL backend not implemented yet"));const o=i.reduce(((e,t)=>e*t)),u=[[0,0]];u.push(...s);for(let e=1+i.length;e<a.shape.length;++e)u.push([0,0]);const l=[],c=Lw({inputs:{x:a},backend:n,attrs:{paddings:u,constantValue:0}}),h=Fd(c.shape,i,o,!1),p=Od(h.length,i.length,!1),d=Md(c.shape,i,o,!1),f=cw({inputs:{x:c},backend:n,attrs:{shape:h}}),m=n_({inputs:{x:f},backend:n,attrs:{perm:p}}),g=cw({inputs:{x:m},backend:n,attrs:{shape:d}});return l.push(c),l.push(f),l.push(m),l.forEach((e=>n.disposeIntermediateTensorInfo(e))),g}},y_={kernelName:an,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a,filter:i}=t,{strides:s,pad:o,dilations:u,dimRoundingMode:l}=r;let c=u;null==c&&(c=[1,1]),nt($u(s,c),(()=>`Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${s} and dilations '${c}'`));const h=Iu(a.shape,i.shape,s,c,o,l,!0);let p;p=Mt().getBool("WEBGL_PACK_DEPTHWISECONV")&&h.strideWidth<=2&&h.outChannels/h.inChannels==1?new h_(h):new c_(h);const d=[[h.padInfo.top,h.padInfo.left],[h.strideHeight,h.strideWidth],[h.dilationHeight,h.dilationWidth],[h.inHeight,h.inWidth]];return n.runWebGLProgram(p,[a,i],"float32",d)}};class b_{constructor(e){this.variableNames=["source"],this.outputShape=e,this.rank=e.length;const t=yb(this.rank);this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const n=function(e){if(1===e)return"sourceLoc";if(e<=6)return v_.slice(0,e).map((e=>"sourceLoc."+e)).join(",");throw Error(`Slicing for rank ${e} is not yet supported`)}(this.rank);let r;const a=e.map(((e,t)=>`sourceLoc.${v_[t]} = start[${t}] + coords.${v_[t]};`));r=`\n ${t} sourceLoc;\n ${t} coords = getOutputCoords();\n ${a.join("\n")}\n `,this.userCode=`\n void main() {\n ${r}\n setOutput(getSource(${n}));\n }\n `}}const v_=["x","y","z","w","u","v"];class w_{constructor(e){this.variableNames=["source"],this.packedInputs=!0,this.packedOutput=!0,this.outputShape=e,this.rank=e.length,this.customUniforms=[{name:"start",arrayIndex:this.rank,type:"int"}];const t=yb(this.rank),n=Fv("coords",this.rank),r=Fv("sourceLoc",this.rank),a=1===this.rank?"sourceLoc":`vec2(${r.slice(-2).join()})`,i=`getChannel(getSource(${r.join()}), ${a})`,s=`\n result.x = ${i};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.y = ${i};\n --${r[this.rank-1]};\n }\n `,o=1===this.rank?"":`\n --${n[this.rank-1]};\n if (++${n[this.rank-2]} < ${e[this.rank-2]}) {\n ++${r[this.rank-2]};\n result.z = ${i};\n if (++${n[this.rank-1]} < ${e[this.rank-1]}) {\n ++${r[this.rank-1]};\n result.w = ${i};\n }\n }\n `,u=this.rank<=4?`sourceLoc = coords +\n ${t}(${e.map(((e,t)=>`start[${t}]`)).join()});`:e.map(((e,t)=>`${r[t]} = ${n[t]} + start[${t}];`)).join("\n");this.userCode=`\n void main() {\n ${t} coords = getOutputCoords();\n ${t} sourceLoc;\n ${u}\n vec4 result = vec4(0.);\n ${s}\n ${o}\n setOutput(result);\n }\n `}}function __(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,size:s}=r,[o,u]=iu(a,i,s);if(Ko(a,o,u),0===it(u))return n.makeTensorInfo(u,a.dtype,[]);if(n.shouldExecuteOnCPU([a])||"string"===a.dtype){const e=n.texData.get(a.dataId),t=yv(e.values,o,u,a.shape,a.dtype);return n.makeTensorInfo(u,a.dtype,t)}const{isPacked:l}=n.texData.get(a.dataId),c=ru(a.shape,o,u);if(l||!c){const e=Mt().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new w_(u):new b_(u),t=[o];return n.runWebGLProgram(e,[a],a.dtype,t)}return n.uploadToGPU(a.dataId),function(e,t,n,r){const a=r.texData.get(e.dataId),i=r.makeTensorInfo(n,e.dtype),s=r.texData.get(i.dataId);Object.assign(s,a),s.refCount=1,s.shape=n,s.dtype=e.dtype;let o=au(t,xt(e.shape));a.slice&&(o+=a.slice.flatOffset),s.slice={flatOffset:o,origDataId:a.slice&&a.slice.origDataId||e.dataId};const u=r.dataRefCount.get(s.slice.origDataId)||1;return r.dataRefCount.set(s.slice.origDataId,u+1),i}(a,o,u,n)}const x_={kernelName:ar,backendName:"webgl",kernelFunc:__},k_={kernelName:Ht,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,crops:s}=r;nt(a.shape.length<=4,(()=>"batchToSpaceND for rank > 4 with a WebGL backend not implemented yet"));const o=i.reduce(((e,t)=>e*t)),u=Fd(a.shape,i,o),l=Od(u.length,i.length),c=Md(a.shape,i,o),h=$d(s,i.length),p=Dd(c,s,i.length),d=[],f=cw({inputs:{x:a},backend:n,attrs:{shape:u}}),m=n_({inputs:{x:f},backend:n,attrs:{perm:l}}),g=cw({inputs:{x:m},backend:n,attrs:{shape:c}}),y=__({inputs:{x:g},backend:n,attrs:{begin:h,size:p}});return d.push(f),d.push(m),d.push(g),d.forEach((e=>n.disposeIntermediateTensorInfo(e))),y}},T_=Iw({opSnippet:Uv+"\n return (x < 0.0) ? 0.0 : min(6.0, x);\n",packedOpSnippet:"\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),E_={kernelName:Jn,backendName:"webgl",kernelFunc:T_};class S_{constructor(e,t,n){this.variableNames=["x"],this.outputShape=n;const r=n.length,a=yb(n.length),i=yb(n.length);let s="";if(1===r)s="coords * strides + begin";else{let e=0;s=n.map(((t,r)=>(e++,1===n.length?`coords * strides[${r}] + begin[${r}]`:`coords[${e-1}] * strides[${r}] + begin[${r}]`))).join(",")}this.userCode=`\n ${a} begin = ${a}(${e});\n ${a} strides = ${a}(${t});\n\n void main() {\n ${i} coords = getOutputCoords();\n setOutput(getX(${s}));\n }\n `}}const I_={kernelName:gr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{begin:i,end:s,strides:o,beginMask:u,endMask:l,ellipsisMask:c,newAxisMask:h,shrinkAxisMask:p}=r,{finalShapeSparse:d,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:y,begin:b,end:v,strides:w}=su(a.shape,i,s,o,u,l,c,h,p);let _;if(m)_=cw({inputs:{x:a},backend:n,attrs:{shape:f}});else if(g||y){nt(a.shape.length>=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=qo(b,v,w),t=__({inputs:{x:a},backend:n,attrs:{begin:b,size:e}});_=cw({inputs:{x:t},backend:n,attrs:{shape:f}}),n.disposeIntermediateTensorInfo(t)}else if(n.shouldExecuteOnCPU([a])){const e=n.readSync(a.dataId),t=nl(a.shape,a.dtype,e),r=xv(d,t,w,b);_=n.makeTensorInfo(f,a.dtype,r.values)}else{const e=new S_(b,w,d);_=n.runWebGLProgram(e,[a],a.dtype)}const x=cw({inputs:{x:_},backend:n,attrs:{shape:f}});return n.disposeIntermediateTensorInfo(_),x}};class A_{constructor(e){this.outputShape=[],this.outputShape=kd(e,1),this.variableNames=e.map(((e,t)=>`T${t}`));const t=new Array(e.length-1);t[0]=e[0][1];for(let n=1;n<t.length;n++)t[n]=t[n-1]+e[n][1];const n=[`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`];for(let e=1;e<t.length;e++){const r=t[e-1];n.push(`else if (yC < ${t[e]}) setOutput(getT${e}(yR, yC-${r}));`)}const r=t.length,a=t[t.length-1];n.push(`else setOutput(getT${r}(yR, yC-${a}));`),this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int yR = coords.x;\n int yC = coords.y;\n\n ${n.join("\n ")}\n }\n `}}class C_{constructor(e,t){this.packedInputs=!0,this.packedOutput=!0,this.outputShape=[],this.outputShape=kd(e,t);const n=this.outputShape,r=n.length,a=yb(r),i=Fv("coords",r),s=["x","y","z","w","u","v"].slice(0,r);this.variableNames=e.map(((e,t)=>`T${t}`));const o=new Array(e.length-1);o[0]=e[0][t];for(let n=1;n<o.length;n++)o[n]=o[n-1]+e[n][t];const u=s[t],l=s.slice(-2),c=s.join();let h=`if (${u} < ${o[0]}) {\n return getChannel(\n getT0(${c}), vec2(${l.join()}));\n }`;for(let e=1;e<o.length;e++){const t=o[e-1];h+=`\n if (${u} < ${o[e]} && ${u} >= ${o[e-1]}) {\n return getChannel(\n getT${e}(${N_(s,u,t)}),\n vec2(${N_(l,u,t)}));\n }`}const p=o.length,d=o[o.length-1];h+=`\n return getChannel(\n getT${p}(${N_(s,u,d)}),\n vec2(${N_(l,u,d)}));`,this.userCode=`\n float getValue(${s.map((e=>"int "+e))}) {\n ${h}\n }\n\n void main() {\n ${a} coords = getOutputCoords();\n vec4 result = vec4(getValue(${i}), 0., 0., 0.);\n\n ${i[r-1]} = ${i[r-1]} + 1;\n if (${i[r-1]} < ${n[r-1]}) {\n result.g = getValue(${i});\n }\n\n ${i[r-2]} = ${i[r-2]} + 1;\n if (${i[r-2]} < ${n[r-2]}) {\n result.a = getValue(${i});\n }\n\n ${i[r-1]} = ${i[r-1]} - 1;\n if (${i[r-2]} < ${n[r-2]} &&\n ${i[r-1]} < ${n[r-1]}) {\n result.b = getValue(${i});\n }\n setOutput(result);\n }\n `}}function N_(e,t,n){const r=e.indexOf(t);return e.map(((e,t)=>t===r?`${e} - ${n}`:e)).join()}function R_(e,t,n){const r=e[0].dtype;if("complex64"===r){const r=e.map((e=>Rw({inputs:{input:e},backend:n}))),a=e.map((e=>function(e){const{inputs:t,backend:n}=e,{input:r}=t;return yw({inputs:{x:n.texData.get(r.dataId).complexTensorInfos.imag},backend:n})}({inputs:{input:e},backend:n}))),i=R_(r,t,n),s=R_(a,t,n),o=vw({inputs:{real:i,imag:s},backend:n});return r.forEach((e=>n.disposeIntermediateTensorInfo(e))),a.forEach((e=>n.disposeIntermediateTensorInfo(e))),n.disposeIntermediateTensorInfo(i),n.disposeIntermediateTensorInfo(s),o}let a=n.shouldExecuteOnCPU(e);if("string"===r&&(a=!0),a){const a=e.map((e=>{const r=it(e.shape.slice(t));return cw({inputs:{x:e},backend:n,attrs:{shape:[-1,r]}})})),i=a.map((e=>({vals:n.readSync(e.dataId),shape:e.shape}))),s=kd(a.map((e=>e.shape)),1),o=1===a[0].shape[0],u=zb(i,s,r,o),l=kd(e.map((e=>e.shape)),t),c=n.makeTensorInfo(l,r,u);return a.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}const i=e.filter((e=>it(e.shape)>0)),s=Mt().getBool("WEBGL_PACK_ARRAY_OPERATIONS")&&i[0].shape.length>1;if(1===i.length){const t=s?new Bv(e[0].shape,Hv):new Zv(e[0].shape,Hv);return n.runWebGLProgram(t,e,r)}const o=Mt().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER");if(i.length>o){const e=[];for(let r=0;r<i.length;r+=o){const a=i.slice(r,r+o);e.push(R_(a,t,n))}const r=R_(e,t,n);for(const t of e)n.disposeIntermediateTensorInfo(t);return r}if(s){const e=new C_(i.map((e=>e.shape)),t);return n.runWebGLProgram(e,i,r)}const{tensors2D:u,outShape:l}=function(e,t,n){const r=kd(e.map((e=>e.shape)),t),a=e.map((e=>cw({inputs:{x:e},attrs:{shape:[-1,it(e.shape.slice(t))]},backend:n})));return{tensors2D:a,outShape:r}}(i,t,n),c=new A_(u.map((e=>e.shape))),h=n.runWebGLProgram(c,u,r);u.forEach((e=>n.disposeIntermediateTensorInfo(e)));const p=cw({inputs:{x:h},attrs:{shape:l},backend:n});return n.disposeIntermediateTensorInfo(h),p}function F_(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r,i=pt(a,t[0].shape)[0];xd(t.map((e=>e.shape)),i);const s=kd(t.map((e=>e.shape)),i);if(0===it(s))return n.makeTensorInfo(s,t[0].dtype,[]);const o=t.filter((e=>it(e.shape)>0));return 1===o.length?yw({inputs:{x:o[0]},backend:n}):R_(o,i,n)}const O_={kernelName:Yt,backendName:"webgl",kernelFunc:F_},M_={kernelName:Vn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(1===t.length)return pw({inputs:{input:t[0]},backend:n,attrs:{dim:a}});const i=t[0].shape,s=t[0].dtype;t.forEach((e=>{rt(i,e.shape,"All tensors passed to stack must have matching shapes"),nt(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],u=F_({inputs:t.map((e=>{const t=pw({inputs:{input:e},backend:n,attrs:{dim:a}});return o.push(t),t})),backend:n,attrs:{axis:a}});return o.forEach((e=>n.disposeIntermediateTensorInfo(e))),u}};class $_{constructor(e){this.variableNames=["dy","W"],this.outputShape=e.inShape;const t=e.filterHeight,n=e.filterWidth,r=e.strideHeight,a=e.strideWidth,i="channelsLast"===e.dataFormat,s=t-1-e.padInfo.top,o=n-1-e.padInfo.left,u=i?1:2,l=i?2:3,c=i?3:1;this.userCode=`\n const ivec2 pads = ivec2(${s}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${c}];\n\n ivec2 dyCorner = ivec2(coords[${u}], coords[${l}]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${a}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n\n if (${i}) {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n `}}const D_={kernelName:Jt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{dy:a,filter:i}=t,{inputShape:s,strides:o,pad:u,dataFormat:l,dimRoundingMode:c}=r,h=Pu(l),p=Iu(s,i.shape,o,1,u,c,!1,h),d=new $_(p);return n.runWebGLProgram(d,[a,i],"float32")}},P_=Iw({opSnippet:Uv+"\n return (x < 0.0) ? 0.0 : x;\n",packedOpSnippet:"\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n"}),L_={kernelName:qn,backendName:"webgl",kernelFunc:P_},B_=Iw({opSnippet:Sw+"\n return 1.0 / (1.0 + exp(-1.0 * x));\n",packedOpSnippet:"\n vec4 result = 1.0 / (1.0 + exp(-1.0 * x));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:mv}),U_={kernelName:ir,backendName:"webgl",kernelFunc:B_};class W_{constructor(e,t,n,r,a){this.variableNames=["Image","Boxes","BoxInd"],this.outputShape=[];const[i,s,o,u]=e,[l]=t,[c,h]=n;this.outputShape=[l,c,h,u];const p="bilinear"===r?1:0,[d,f]=[s-1+".0",o-1+".0"],[m,g,y]=c>1?[""+(s-1)/(c-1),"(y2-y1) * height_ratio",`y1*${d} + float(y)*(height_scale)`]:["0.0","0.0",`0.5 * (y1+y2) * ${d}`],[b,v,w]=h>1?[""+(o-1)/(h-1),"(x2-x1) * width_ratio",`x1*${f} + float(x)*(width_scale)`]:["0.0","0.0",`0.5 * (x1+x2) * ${f}`];this.userCode=`\n const float height_ratio = float(${m});\n const float width_ratio = float(${b});\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= ${i}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${v};\n\n float in_y = ${y};\n if( in_y < 0.0 || in_y > ${d} ) {\n setOutput(float(${a}));\n return;\n }\n float in_x = ${w};\n if( in_x < 0.0 || in_x > ${f} ) {\n setOutput(float(${a}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${p} == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n `}}const V_={kernelName:nn,backendName:"webgl",kernelFunc:e=>{const{inputs:t,backend:n,attrs:r}=e,{image:a,boxes:i,boxInd:s}=t,{cropSize:o,method:u,extrapolationValue:l}=r,c=new W_(a.shape,i.shape,o,u,l);return n.runWebGLProgram(c,[a,i,s],"float32")}};class z_{constructor(e,t){this.variableNames=["x"];const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);if(this.outputShape=e,1===n)return void(this.userCode=`\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${e[0]} - coord - 1));\n }\n `);const r=e.map(((n,r)=>(n=>-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - coords[${n}] - 1`:`coords[${n}]`)(r))).join(","),a=yb(n);this.userCode=`\n void main() {\n ${a} coords = getOutputCoords();\n setOutput(getX(${r}));\n }\n `}}class j_{constructor(e,t){this.variableNames=["x"],this.packedInputs=!0,this.packedOutput=!0;const n=e.length;if(n>4)throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`);this.outputShape=e;const r=Fv("rc",n),a=`${r[n-1]} + 1 < ${this.outputShape[n-1]}`,i=`${r[n-2]} + 1 < ${this.outputShape[n-2]}`,s=yb(n);function o(n){const r=e.map(((r,a)=>function(n,r){return-1!==t.indexOf(n)&&1!==e[n]?`${e[n]} - ${r[n]} - 1`:`${r[n]}`}(a,n)));return`getChannel(getX(${r.join(",")}), vec2(${r.slice(-2).join(",")}))`}this.userCode=1===n?`\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX(${e[0]} - rc - 1),\n ${e[0]} - rc - 1);\n if(${a}){\n result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),\n ${e[0]} - (rc + 1) - 1);\n }\n setOutput(result);\n }\n `:`\n void main() {\n ${s} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${function(e){return o(e)}(r.slice())};\n if(${a}){\n result.g = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",o(e)}(r.slice())};\n }\n if(${i}) {\n result.b = ${function(e){return e[n-2]="("+e[n-2]+" + 1)",o(e)}(r.slice())};\n if(${a}) {\n result.a = ${function(e){return e[n-1]="("+e[n-1]+" + 1)",e[n-2]="("+e[n-2]+" + 1)",o(e)}(r.slice())};\n }\n }\n setOutput(result);\n }\n `}}const G_={kernelName:Zn,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:i}=r,s=a.shape.length,o=pt(i,a.shape);if(0===s)return yw({inputs:{x:a},backend:n});const u=Mt().getBool("WEBGL_PACK_ARRAY_OPERATIONS")?new j_(a.shape,o):new z_(a.shape,o);return n.runWebGLProgram(u,[a],a.dtype)}},H_="return a - b;",K_=Aw({opSnippet:H_,packedOpSnippet:H_,supportsComplex:!0,cpuKernelImpl:Sv}),q_={kernelName:wr,backendName:"webgl",kernelFunc:K_},X_={kernelName:Sr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:i}=r;i<0&&(i+=a.shape.length);const s=a,o=s.shape.length,u=a.shape[i],l=new Array(o-1);let c=0;for(let e=0;e<o;e++)e!==i&&(l[c++]=s.shape[e]);const h=[],p=new Array(o).fill(0),d=s.shape.slice();d[i]=1;const f=new Array(u);for(let e=0;e<f.length;e++){p[i]=e;const t=__({inputs:{x:s},backend:n,attrs:{begin:p,size:d}}),r=cw({inputs:{x:t},backend:n,attrs:{shape:l}});f[e]=r,h.push(t)}return h.forEach((e=>n.disposeIntermediateTensorInfo(e))),f}};class Y_{constructor(e,t,n){this.variableNames=["A"];const{windowSize:r,batchSize:a,outSize:i}=e;n||this.variableNames.push("bestIndicesA"),this.outputShape=[a,i];const s="max"===t?">":"<",o=n?"inOffset + i;":"round(getBestIndicesA(batch, inOffset + i));";this.userCode=`\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${r};\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < ${r}; i++) {\n int inIdx = ${o};\n float candidate = getA(batch, inIdx);\n if (candidate ${s} bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\n `}}class Q_{constructor(e,t,n,r){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,nt(e.length>2,(()=>`Packed arg${n.charAt(0).toUpperCase()+n.slice(1)} supports only inputs with rank above 2.`));const a=e[e.length-1],i=Math.ceil(a/t);this.outputShape=e.slice(0,-1),i>1&&this.outputShape.push(i),r||this.variableNames.push("bestIndicesA");const s=this.outputShape,o=s.length,u=yb(o),l=Fv("coords",o);let c,h;if(1===i){h=o+1;const e=yb(h);c=`\n ${e} sourceLocR = ${e}(${l.join()}, 0);\n ++${l[o-1]};\n ${e} sourceLocG = ${e}(${l.join()}, 0);\n ++${l[o-2]};\n ${e} sourceLocA = ${e}(${l.join()}, 0);\n --${l[o-1]};\n ${e} sourceLocB = ${e}(${l.join()}, 0);\n --${l[o-2]};`}else h=o,c=`\n ${u} sourceLocR = coords;\n ++${l[o-1]};\n ${u} sourceLocG = coords;\n ++${l[o-2]};\n ${u} sourceLocA = coords;\n --${l[o-1]};\n ${u} sourceLocB = coords;\n --${l[o-2]};`;const p=["x","y","z","w","u","v"].slice(0,h),d="."+p[h-1],f=p.map((e=>"int "+e)),m=Fv("sourceLocR",h-1).concat("inIdx.r"),g=Fv("sourceLocG",h-1).concat("inIdx.g"),y=Fv("sourceLocB",h-1).concat("inIdx.b"),b=Fv("sourceLocA",h-1).concat("inIdx.a"),v="max"===n?"greaterThan":"lessThan",w=r?"":`\n inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${y.join()}),\n getBestIndicesAChannel(${b.join()})));`,_=`vec4(\n getAChannel(${m.join()}),\n hasNextCol ? getAChannel(${g.join()}) : 0.,\n hasNextRow ? getAChannel(${y.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${b.join()}) : 0.)`,x=r?"":`\n float getBestIndicesAChannel(${f.join()}) {\n return getChannel(getBestIndicesA(${p.join()}),\n vec2(${p.slice(-2).join()}));\n }`;this.userCode=`\n float getAChannel(${f.join()}) {\n return getChannel(getA(${p.join()}),\n vec2(${p.slice(-2).join()}));\n }\n ${x}\n void main() {\n ${u} coords = getOutputCoords();\n bool hasNextCol = ${l[o-1]} < ${s[o-1]-1};\n bool hasNextRow = ${l[o-2]} < ${s[o-2]-1};\n ${c}\n ivec4 srcIdx = ivec4(sourceLocR${d}, sourceLocG${d},\n sourceLocB${d}, sourceLocA${d}) * ${t};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${_};\n\n for (int i = 0; i < ${t}; i++) {\n inIdx = srcIdx;\n ${w}\n vec4 candidate = ${_};\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4(${v}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n `}}function J_(e,t,n,r=null){let a=t.shape[0],i=t.shape[1];null!=r&&(a=r.shape[0],i=r.shape[1]);const s=Nd(i),o={windowSize:s,inSize:i,batchSize:a,outSize:Math.ceil(i/s)},u=new Y_(o,n,null==r),l=[t];null!=r&&l.push(r);const c=e.runWebGLProgram(u,l,"int32");if(1===c.shape[1])return c;const h=J_(e,t,n,c);return e.disposeIntermediateTensorInfo(c),h}function Z_(e,t,n,r=null){const a=null!=r?r.shape:t.shape,i=Nd(a[a.length-1]),s=new Q_(a,i,n,null==r),o=null==r?[t]:[t,r],u=e.runWebGLProgram(s,o,"int32");if(u.shape.length===t.shape.length){const r=Z_(e,t,n,u);return e.disposeIntermediateTensorInfo(u),r}return u}function ex(e,t,n,r){const a=[n];if(Ll("arg"+r.charAt(0).toUpperCase()+r.slice(1),a,t.shape.length),!Mt().getBool("WEBGL_PACK_REDUCE")||t.shape.length<=2){const n=[],i=e.texData.get(t.dataId);let s=t;null!==i&&i.isPacked&&(s=e.unpackTensor(t),n.push(s));const[o,u]=Dl(s.shape,a),l=it(u),c=cw({inputs:{x:s},backend:e,attrs:{shape:[-1,l]}});n.push(c);const h=J_(e,c,r);n.push(h);const p=cw({inputs:{x:h},backend:e,attrs:{shape:o}});return n.forEach((t=>e.disposeIntermediateTensorInfo(t))),p}return Z_(e,t,r)}const tx={kernelName:zt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i}=r;let s=pt(i,a.shape);const o=Bl(s,a.shape.length);let u=a;const l=[];null!=o&&(u=n_({inputs:{x:a},backend:n,attrs:{perm:o}}),l.push(u),s=Wl(s.length,u.shape.length)),Ll("argMax",[s[0]],u.shape.length);const c=ex(n,u,s[0],"max");return l.forEach((e=>n.disposeIntermediateTensorInfo(e))),c}},nx={kernelName:Rn,backendName:"webgl",kernelFunc:({inputs:e,attrs:t,backend:n})=>{const{x:r}=e,{keepDims:a,axis:i}=t,s=n,o=r.shape.length,u=pt(i,r.shape);let l=u;const c=Bl(l,o),h=null!=c,p=s.shouldExecuteOnCPU([r]),d=[];let f=r;if(h){if(p){const e=s.texData.get(f.dataId).values,t=new Array(o);for(let e=0;e<t.length;e++)t[e]=r.shape[c[e]];const n=Cv(e,r.shape,r.dtype,c,t);f=s.makeTensorInfo(t,r.dtype),s.texData.get(f.dataId).values=n}else f=e_(r,c,s);d.push(f),l=Wl(l.length,o)}Ll("sum",l,o);const[m,g]=Dl(f.shape,l);let y=m;a&&(y=Pl(m,u));const b=function(e,t,n,r){const a=it(t),i=cw({inputs:{x:e},attrs:{shape:[it(e.shape)/a,a]},backend:r}),s=Qw(i,"float32","mean",r),o=cw({inputs:{x:s},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(s),o}(f,g,y,s);for(const e of d)s.disposeIntermediateTensorInfo(e);return b}},rx=Iw({opSnippet:Sw+"\n return exp(x);\n",packedOpSnippet:"\n vec4 result = exp(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n",cpuKernelImpl:Gb,dtype:"float32"}),ax={kernelName:cr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{logits:a}=t,{dim:i}=r,s=pt([i],a.shape),o=function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{reductionIndices:i,keepDims:s}=r,o=a.shape.length,u=pt(i,a.shape);let l=u;const c=Bl(l,o),h=null!=c,p=n.shouldExecuteOnCPU([a]);let d=a;if(h){if(p){const e=n.texData.get(d.dataId).values,t=new Array(o);for(let e=0;e<t.length;e++)t[e]=a.shape[c[e]];const r=Cv(e,a.shape,a.dtype,c,t);d=n.makeTensorInfo(t,a.dtype),n.texData.get(d.dataId).values=r}else d=e_(a,c,n);l=Wl(l.length,o)}Ll("max",l,o);const[f,m]=Dl(d.shape,l);let g,y=f;if(s&&(y=Pl(f,u)),p){const e=n.texData.get(d.dataId).values,t=nv(e,it(m),y,a.dtype);g=n.makeTensorInfo(y,a.dtype),n.texData.get(g.dataId).values=t}else g=function(e,t,n,r){const a=it(t),i=cw({inputs:{x:e},attrs:{shape:[it(e.shape)/a,a]},backend:r}),s=Qw(i,e.dtype,"max",r),o=cw({inputs:{x:s},attrs:{shape:n},backend:r});return r.disposeIntermediateTensorInfo(i),r.disposeIntermediateTensorInfo(s),o}(d,m,y,n);return h&&n.disposeIntermediateTensorInfo(d),g}({inputs:{x:a},backend:n,attrs:{reductionIndices:s,keepDims:!1}}),u=Pl(o.shape,s),l=cw({inputs:{x:o},backend:n,attrs:{shape:u}}),c=K_({inputs:{a,b:l},backend:n}),h=rx({inputs:{x:c},backend:n}),p=t_({inputs:{x:h},backend:n,attrs:{axis:s,keepDims:!1}}),d=cw({inputs:{x:p},backend:n,attrs:{shape:u}}),f=Ow({inputs:{a:h,b:d},backend:n});return n.disposeIntermediateTensorInfo(o),n.disposeIntermediateTensorInfo(l),n.disposeIntermediateTensorInfo(c),n.disposeIntermediateTensorInfo(h),n.disposeIntermediateTensorInfo(p),n.disposeIntermediateTensorInfo(d),f}};class ix{constructor(e){this.variableNames=["A"],this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n "}}class sx{constructor(e){this.variableNames=["A"],this.packedInputs=!0,this.packedOutput=!0,this.customUniforms=[{name:"minVal",type:"float"},{name:"maxVal",type:"float"}],this.outputShape=e,this.userCode="\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n "}}const ox={kernelName:Xt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{clipValueMin:i,clipValueMax:s}=r;let o;o=Mt().getBool("WEBGL_PACK_CLIP")?new sx(a.shape):new ix(a.shape);const u=[[i],[s]];return n.runWebGLProgram(o,[a],a.dtype,u)}};class ux{constructor(e,t,n,r=!1,a=!1){if(this.variableNames=["x"],"avg"===t&&n)throw new Error("Cannot compute positions for average pool.");const i=e.filterWidth,s=e.strideHeight,o=e.strideWidth,u=e.dilationHeight,l=e.dilationWidth,c=e.effectiveFilterHeight,h=e.effectiveFilterWidth,p=e.padInfo.top,d=e.padInfo.left;this.outputShape=e.outShape;const f="avg"===t,m=`((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`,g=`(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`;let y="0.0";if(f||(y="-1.0 / 1e-20"),n){const t=">=";return void(this.userCode=`\n const ivec2 strides = ivec2(${s}, ${o});\n const ivec2 pads = ivec2(${p}, ${d});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${h};\n wC += ${l}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r?a?m:g:`wR * ${h} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `)}let b=`${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`;"avg"===t&&(b="avgValue / max(count, 1.0)");const v=4*Math.floor(i/4),w=i%4,_=`\n if (${f}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `;this.userCode=`\n const ivec2 strides = ivec2(${s}, ${o});\n const ivec2 pads = ivec2(${p}, ${d});\n const float initializationValue = ${y};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4(${y});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${v}; wC += 4) {\n int xC = xCCorner + wC * ${l};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n getValue(batch, xR, xC + 3 * ${l}, d)\n );\n\n ${_}\n }\n\n int xC = xCCorner + ${v};\n if (${1===w}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${_}\n } else if (${2===w}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n initializationValue,\n initializationValue\n );\n\n ${_}\n } else if (${3===w}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n initializationValue\n );\n\n ${_}\n }\n }\n setOutput(${b});\n }\n `}}const lx={kernelName:jt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t;!function(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>{null!=e&&nt("complex64"!==e.dtype,(()=>"avgPool does not support complex64 tensors in the WebGL backend."))}))}(a);const{filterSize:i,strides:s,pad:o,dimRoundingMode:u}=r;nt($u(s,1),(()=>`Error in avgPool: Either strides or dilations must be 1. Got strides ${s} and dilations '1'`));const l=Su(a.shape,i,s,1,o,u);if(1===l.filterWidth&&1===l.filterHeight&&st(l.inShape,l.outShape))return yw({inputs:{x:a},backend:n});const c=new ux(l,"avg",!1);return n.runWebGLProgram(c,[a],"float32")}},cx={kernelName:Gt,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i}=t,{transposeA:s,transposeB:o}=r;return a_({a,b:i,transposeA:s,transposeB:o,backend:n})}},hx={kernelName:Rr,backendName:"webgl",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i,bias:s,preluActivationWeights:o}=t,{transposeA:u,transposeB:l,activation:c,leakyreluAlpha:h}=r;return a_({a,b:i,transposeA:u,transposeB:l,backend:n,bias:s,preluActivationWeights:o,leakyreluAlpha:h,activation:c})}};Ur(Ug),Ur(Wg),Ur(Fm),Ur(jg),Ur(Gg),Ur(Kg),Ur(ty),Ur(ay),Ur(Lm),Ur(iy),Ur(ry),Ur(sy),Ur(og),Ur(Zg),Ur(oy),Ur(hy),Ur(py),Ur(Qg),Ur(wg),Ur(Am),Ur(dy),Ur(fy),Ur(ly),Ur($g),Ur(my),Ur(gy),Ur(by),Ur(kg),Ur(vy),Ur(_y),Ur(xy),Ur(ky),Ur(ow),Ur(hw),Ur(dw),Ur(gw),Ur(Fw),Ur(Mw),Ur(Bw),Ur(u_),Ur(l_),Ur(p_),Ur(m_),Ur(g_),Ur(y_),Ur(k_),Ur(qw),Ur(E_),Ur(I_),Ur(M_),Ur(D_),Ur(L_),Ur(U_),Ur(bw),Ur(V_),Ur(G_),Ur(O_),Ur(q_),Ur(X_),Ur(tx),Ur(nx),Ur(x_),Ur(ax),Ur(ox),Ur(lx),Ur(cx),Ur(hx);var px={filename:""};function dx(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(1===e.length){var n=e[0];if(w(n))return fx(n,null);if(_(n)&&Object.getPrototypeOf(n)===Object.prototype){var r=Object.keys(n);return fx(r.map((function(e){return n[e]})),r)}}if("function"==typeof e[e.length-1]){var a=e.pop();return fx(e=1===e.length&&w(e[0])?e[0]:e,null).pipe(J((function(e){return a.apply(void 0,e)})))}return fx(e,null)}function fx(e,t){return new R((function(n){var r=e.length;if(0!==r)for(var a=new Array(r),i=0,s=0,o=function(o){var u=Y(e[o]),l=!1;n.add(u.subscribe({next:function(e){l||(l=!0,s++),a[o]=e},error:function(e){return n.error(e)},complete:function(){++i!==r&&l||(s===r&&n.next(t?t.reduce((function(e,t,n){return e[t]=a[n],e}),{}):a),n.complete())}}))},u=0;u<r;u++)o(u);else n.complete()}))}var mx="undefined"!=typeof window&&window,gx="undefined"!=typeof self&&"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&self,yx=mx||void 0!==Te&&Te||gx;function bx(e,t){return void 0===t&&(t=null),new Ex({method:"GET",url:e,headers:t})}function vx(e,t,n){return new Ex({method:"POST",url:e,body:t,headers:n})}function wx(e,t){return new Ex({method:"DELETE",url:e,headers:t})}function _x(e,t,n){return new Ex({method:"PUT",url:e,body:t,headers:n})}function xx(e,t,n){return new Ex({method:"PATCH",url:e,body:t,headers:n})}var kx=J((function(e,t){return e.response}));function Tx(e,t){return kx(new Ex({method:"GET",url:e,responseType:"json",headers:t}))}var Ex=function(e){function t(t){var n=e.call(this)||this,r={async:!0,createXHR:function(){return this.crossDomain?function(){if(yx.XMLHttpRequest)return new yx.XMLHttpRequest;if(yx.XDomainRequest)return new yx.XDomainRequest;throw new Error("CORS is not supported by your browser")}():function(){if(yx.XMLHttpRequest)return new yx.XMLHttpRequest;var e=void 0;try{for(var t=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],n=0;n<3;n++)try{if(e=t[n],new yx.ActiveXObject(e))break}catch(e){}return new yx.ActiveXObject(e)}catch(e){throw new Error("XMLHttpRequest is not supported by your browser")}}()},crossDomain:!0,withCredentials:!1,headers:{},method:"GET",responseType:"json",timeout:0};if("string"==typeof t)r.url=t;else for(var a in t)t.hasOwnProperty(a)&&(r[a]=t[a]);return n.request=r,n}var n;return f(t,e),t.prototype._subscribe=function(e){return new Sx(e,this.request)},t.create=((n=function(e){return new t(e)}).get=bx,n.post=vx,n.delete=wx,n.put=_x,n.patch=xx,n.getJSON=Tx,n),t}(R),Sx=function(e){function t(t,n){var r=e.call(this,t)||this;r.request=n,r.done=!1;var a=n.headers=n.headers||{};return n.crossDomain||r.getHeader(a,"X-Requested-With")||(a["X-Requested-With"]="XMLHttpRequest"),r.getHeader(a,"Content-Type")||yx.FormData&&n.body instanceof yx.FormData||void 0===n.body||(a["Content-Type"]="application/x-www-form-urlencoded; charset=UTF-8"),n.body=r.serializeBody(n.body,r.getHeader(n.headers,"Content-Type")),r.send(),r}return f(t,e),t.prototype.next=function(e){this.done=!0;var t,n=this,r=n.xhr,a=n.request,i=n.destination;try{t=new Ix(e,r,a)}catch(e){return i.error(e)}i.next(t)},t.prototype.send=function(){var e=this.request,t=this.request,n=t.user,r=t.method,a=t.url,i=t.async,s=t.password,o=t.headers,u=t.body;try{var l=this.xhr=e.createXHR();this.setupEvents(l,e),n?l.open(r,a,i,n,s):l.open(r,a,i),i&&(l.timeout=e.timeout,l.responseType=e.responseType),"withCredentials"in l&&(l.withCredentials=!!e.withCredentials),this.setHeaders(l,o),u?l.send(u):l.send()}catch(e){this.error(e)}},t.prototype.serializeBody=function(e,t){if(!e||"string"==typeof e)return e;if(yx.FormData&&e instanceof yx.FormData)return e;if(t){var n=t.indexOf(";");-1!==n&&(t=t.substring(0,n))}switch(t){case"application/x-www-form-urlencoded":return Object.keys(e).map((function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])})).join("&");case"application/json":return JSON.stringify(e);default:return e}},t.prototype.setHeaders=function(e,t){for(var n in t)t.hasOwnProperty(n)&&e.setRequestHeader(n,t[n])},t.prototype.getHeader=function(e,t){for(var n in e)if(n.toLowerCase()===t.toLowerCase())return e[n]},t.prototype.setupEvents=function(e,t){var n,r,a=t.progressSubscriber;function i(e){var t,n=i,r=n.subscriber,a=n.progressSubscriber,s=n.request;a&&a.error(e);try{t=new Nx(this,s)}catch(e){t=e}r.error(t)}function s(e){}function o(e){var t=o,n=t.subscriber,r=t.progressSubscriber,a=t.request;if(4===this.readyState){var i=1223===this.status?204:this.status,s="text"===this.responseType?this.response||this.responseText:this.response;if(0===i&&(i=s?200:0),i<400)r&&r.complete(),n.next(e),n.complete();else{r&&r.error(e);var u=void 0;try{u=new Ax("ajax error "+i,this,a)}catch(e){u=e}n.error(u)}}}e.ontimeout=i,i.request=t,i.subscriber=this,i.progressSubscriber=a,e.upload&&"withCredentials"in e&&(a&&(n=function(e){n.progressSubscriber.next(e)},yx.XDomainRequest?e.onprogress=n:e.upload.onprogress=n,n.progressSubscriber=a),r=function(e){var t,n=r,a=n.progressSubscriber,i=n.subscriber,s=n.request;a&&a.error(e);try{t=new Ax("ajax error",this,s)}catch(e){t=e}i.error(t)},e.onerror=r,r.request=t,r.subscriber=this,r.progressSubscriber=a),e.onreadystatechange=s,s.subscriber=this,s.progressSubscriber=a,s.request=t,e.onload=o,o.subscriber=this,o.progressSubscriber=a,o.request=t},t.prototype.unsubscribe=function(){var t=this.done,n=this.xhr;!t&&n&&4!==n.readyState&&"function"==typeof n.abort&&n.abort(),e.prototype.unsubscribe.call(this)},t}(I),Ix=function(e,t,n){this.originalEvent=e,this.xhr=t,this.request=n,this.status=t.status,this.responseType=t.responseType||n.responseType,this.response=Cx(this.responseType,t)},Ax=function(){function e(e,t,n){return Error.call(this),this.message=e,this.name="AjaxError",this.xhr=t,this.request=n,this.status=t.status,this.responseType=t.responseType||n.responseType,this.response=Cx(this.responseType,t),this}return e.prototype=Object.create(Error.prototype),e}();function Cx(e,t){switch(e){case"json":return function(e){return"response"in e?e.responseType?e.response:JSON.parse(e.response||e.responseText||"null"):JSON.parse(e.responseText||"null")}(t);case"xml":return t.responseXML;default:return"response"in t?t.response:t.responseText}}var Nx=function(e,t){return Ax.call(this,"ajax timeout",e,t),this.name="AjaxTimeoutError",this},Rx=Ex.create,Fx=Uint8Array,Ox=Uint16Array,Mx=Uint32Array,$x=new Fx([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Dx=new Fx([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Px=new Fx([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Lx=function(e,t){for(var n=new Ox(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var a=new Mx(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)a[i]=i-n[r]<<5|r;return[n,a]},Bx=Lx($x,2),Ux=Bx[0],Wx=Bx[1];Ux[28]=258,Wx[258]=28;for(var Vx=Lx(Dx,0)[0],zx=new Ox(32768),jx=0;jx<32768;++jx){var Gx=(43690&jx)>>>1|(21845&jx)<<1;Gx=(61680&(Gx=(52428&Gx)>>>2|(13107&Gx)<<2))>>>4|(3855&Gx)<<4,zx[jx]=((65280&Gx)>>>8|(255&Gx)<<8)>>>1}var Hx=function(e,t,n){for(var r=e.length,a=0,i=new Ox(t);a<r;++a)++i[e[a]-1];var s,o=new Ox(t);for(a=0;a<t;++a)o[a]=o[a-1]+i[a-1]<<1;if(n){s=new Ox(1<<t);var u=15-t;for(a=0;a<r;++a)if(e[a])for(var l=a<<4|e[a],c=t-e[a],h=o[e[a]-1]++<<c,p=h|(1<<c)-1;h<=p;++h)s[zx[h]>>>u]=l}else for(s=new Ox(r),a=0;a<r;++a)e[a]&&(s[a]=zx[o[e[a]-1]++]>>>15-e[a]);return s},Kx=new Fx(288);for(jx=0;jx<144;++jx)Kx[jx]=8;for(jx=144;jx<256;++jx)Kx[jx]=9;for(jx=256;jx<280;++jx)Kx[jx]=7;for(jx=280;jx<288;++jx)Kx[jx]=8;var qx=new Fx(32);for(jx=0;jx<32;++jx)qx[jx]=5;var Xx=Hx(Kx,9,1),Yx=Hx(qx,5,1),Qx=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Jx=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},Zx=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},ek=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof Ox?Ox:e instanceof Mx?Mx:Fx)(n-t);return r.set(e.subarray(t,n)),r},tk=function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new Fx(0);var a=!t||n,i=!n||n.i;n||(n={}),t||(t=new Fx(3*r));var s,o=function(e){var n=t.length;if(e>n){var r=new Fx(Math.max(2*n,e));r.set(t),t=r}},u=n.f||0,l=n.p||0,c=n.b||0,h=n.l,p=n.d,d=n.m,f=n.n,m=8*r;do{if(!h){n.f=u=Jx(e,l,1);var g=Jx(e,l+1,3);if(l+=3,!g){var y=e[(A=((s=l)/8|0)+(7&s&&1)+4)-4]|e[A-3]<<8,b=A+y;if(b>r){if(i)throw"unexpected EOF";break}a&&o(c+y),t.set(e.subarray(A,b),c),n.b=c+=y,n.p=l=8*b;continue}if(1==g)h=Xx,p=Yx,d=9,f=5;else{if(2!=g)throw"invalid block type";var v=Jx(e,l,31)+257,w=Jx(e,l+10,15)+4,_=v+Jx(e,l+5,31)+1;l+=14;for(var x=new Fx(_),k=new Fx(19),T=0;T<w;++T)k[Px[T]]=Jx(e,l+3*T,7);l+=3*w;var E=Qx(k),S=(1<<E)-1,I=Hx(k,E,1);for(T=0;T<_;){var A,C=I[Jx(e,l,S)];if(l+=15&C,(A=C>>>4)<16)x[T++]=A;else{var N=0,R=0;for(16==A?(R=3+Jx(e,l,3),l+=2,N=x[T-1]):17==A?(R=3+Jx(e,l,7),l+=3):18==A&&(R=11+Jx(e,l,127),l+=7);R--;)x[T++]=N}}var F=x.subarray(0,v),O=x.subarray(v);d=Qx(F),f=Qx(O),h=Hx(F,d,1),p=Hx(O,f,1)}if(l>m){if(i)throw"unexpected EOF";break}}a&&o(c+131072);for(var M=(1<<d)-1,$=(1<<f)-1,D=l;;D=l){var P=(N=h[Zx(e,l)&M])>>>4;if((l+=15&N)>m){if(i)throw"unexpected EOF";break}if(!N)throw"invalid length/literal";if(P<256)t[c++]=P;else{if(256==P){D=l,h=null;break}var L=P-254;if(P>264){var B=$x[T=P-257];L=Jx(e,l,(1<<B)-1)+Ux[T],l+=B}var U=p[Zx(e,l)&$],W=U>>>4;if(!U)throw"invalid distance";if(l+=15&U,O=Vx[W],W>3&&(B=Dx[W],O+=Zx(e,l)&(1<<B)-1,l+=B),l>m){if(i)throw"unexpected EOF";break}a&&o(c+131072);for(var V=c+L;c<V;c+=4)t[c]=t[c-O],t[c+1]=t[c+1-O],t[c+2]=t[c+2-O],t[c+3]=t[c+3-O];c=V}}n.l=h,n.p=D,n.b=c,h&&(u=1,n.m=d,n.d=p,n.n=f)}while(!u);return c==t.length?t:ek(t,0,c)},nk=new Fx(0),rk=function(e,t){return e[t]|e[t+1]<<8},ak=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},ik=function(e,t){return ak(e,t)+4294967296*ak(e,t+4)};function sk(e,t){return tk(e,t)}var ok="undefined"!=typeof TextDecoder&&new TextDecoder;try{ok.decode(nk,{stream:!0})}catch(o){}var uk=function(e){for(var t="",n=0;;){var r=e[n++],a=(r>127)+(r>223)+(r>239);if(n+a>e.length)return[t,ek(e,n-1)];a?3==a?(r=((15&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=1&a?String.fromCharCode((31&r)<<6|63&e[n++]):String.fromCharCode((15&r)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(r)}};function lk(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(ok)return ok.decode(e);var a=uk(e),i=a[0];if(a[1].length)throw"invalid utf-8 data";return i}var ck=function(e,t){return t+30+rk(e,t+26)+rk(e,t+28)},hk=function(e,t,n){var r=rk(e,t+28),a=lk(e.subarray(t+46,t+46+r),!(2048&rk(e,t+8))),i=t+46+r,s=ak(e,t+20),o=n&&4294967295==s?pk(e,i):[s,ak(e,t+24),ak(e,t+42)],u=o[0],l=o[1],c=o[2];return[rk(e,t+10),u,l,a,i+rk(e,t+30)+rk(e,t+32),c]},pk=function(e,t){for(;1!=rk(e,t);t+=4+rk(e,t+2));return[ik(e,t+12),ik(e,t+4),ik(e,t+20)]};function dk(e){for(var t={},n=e.length-22;101010256!=ak(e,n);--n)if(!n||e.length-n>65558)throw"invalid zip file";var r=rk(e,n+8);if(!r)return{};var a=ak(e,n+16),i=4294967295==a;if(i){if(n=ak(e,n-12),101075792!=ak(e,n))throw"invalid zip file";r=ak(e,n+32),a=ak(e,n+48)}for(var s=0;s<r;++s){var o=hk(e,a,i),u=o[0],l=o[1],c=o[2],h=o[3],p=o[4],d=o[5],f=ck(e,d);if(a=p,u){if(8!=u)throw"unknown compression type "+u;t[h]=sk(e.subarray(f,f+l),new Fx(c))}else t[h]=ek(e,f,f+l)}return t}function fk(e){if(e)for(var t=0;t<e.length;t++)e[t]=~e[t];return e}var mk=function(){function e(e,t){this.jsonModel=e,this.weights=t}return e.prototype.load=function(){return l(this,void 0,void 0,(function(){var e,t,n,r;return c(this,(function(a){switch(a.label){case 0:return e={modelTopology:this.jsonModel.modelTopology,format:this.jsonModel.format,generatedBy:this.jsonModel.generatedBy,convertedBy:this.jsonModel.convertedBy},null==this.jsonModel.weightsManifest?[3,2]:[4,this.loadWeights()];case 1:t=a.sent(),n=t[0],r=t[1],e.weightSpecs=n,e.weightData=r,a.label=2;case 2:return null!=this.jsonModel.trainingConfig&&(e.trainingConfig=this.jsonModel.trainingConfig),null!=this.jsonModel.userDefinedMetadata&&(e.userDefinedMetadata=this.jsonModel.userDefinedMetadata),[2,e]}}))}))},e.prototype.loadWeights=function(){return l(this,void 0,void 0,(function(){var e,t,n,r,a,i,s,o;return c(this,(function(u){for(e=[],t=[],n=0,r=this.jsonModel.weightsManifest;n<r.length;n++){for(a=r[n],i=0,s=a.paths;i<s.length;i++){if(o=s[i],!this.weights[o])throw new Error("Error loading weights: cannot find ".concat(o));e.push(this.weights[o])}t.push.apply(t,a.weights)}return[2,[t,this.toArrayBuffer(e)]]}))}))},e.prototype.toArrayBuffer=function(e){if(Array.isArray(e)){for(var t=0,n=0,r=e;n<r.length;n++)t+=r[n].length;for(var a=new ArrayBuffer(t),i=new Uint8Array(a),s=0,o=0,u=e;o<u.length;o++)s+=u[o].copy(i,s);return a}return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)},e}(),gk=[],yk=[],bk="undefined"!=typeof Uint8Array?Uint8Array:Array,vk=!1;function wk(){vk=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)gk[t]=e[t],yk[e.charCodeAt(t)]=t;yk["-".charCodeAt(0)]=62,yk["_".charCodeAt(0)]=63}function _k(e,t,n){for(var r,a,i=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],i.push(gk[(a=r)>>18&63]+gk[a>>12&63]+gk[a>>6&63]+gk[63&a]);return i.join("")}function xk(e){var t;vk||wk();for(var n=e.length,r=n%3,a="",i=[],s=16383,o=0,u=n-r;o<u;o+=s)i.push(_k(e,o,o+s>u?u:o+s));return 1===r?(t=e[n-1],a+=gk[t>>2],a+=gk[t<<4&63],a+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],a+=gk[t>>10],a+=gk[t>>4&63],a+=gk[t<<2&63],a+="="),i.push(a),i.join("")}function kk(e,t,n,r,a){var i,s,o=8*a-r-1,u=(1<<o)-1,l=u>>1,c=-7,h=n?a-1:0,p=n?-1:1,d=e[t+h];for(h+=p,i=d&(1<<-c)-1,d>>=-c,c+=o;c>0;i=256*i+e[t+h],h+=p,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=r;c>0;s=256*s+e[t+h],h+=p,c-=8);if(0===i)i=1-l;else{if(i===u)return s?NaN:1/0*(d?-1:1);s+=Math.pow(2,r),i-=l}return(d?-1:1)*s*Math.pow(2,i-r)}function Tk(e,t,n,r,a,i){var s,o,u,l=8*i-a-1,c=(1<<l)-1,h=c>>1,p=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:i-1,f=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),(t+=s+h>=1?p/u:p*Math.pow(2,1-h))*u>=2&&(s++,u/=2),s+h>=c?(o=0,s=c):s+h>=1?(o=(t*u-1)*Math.pow(2,a),s+=h):(o=t*Math.pow(2,h-1)*Math.pow(2,a),s=0));a>=8;e[n+d]=255&o,d+=f,o/=256,a-=8);for(s=s<<a|o,l+=a;l>0;e[n+d]=255&s,d+=f,s/=256,l-=8);e[n+d-f]|=128*m}var Ek={}.toString,Sk=Array.isArray||function(e){return"[object Array]"==Ek.call(e)};function Ik(){return Ck.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Ak(e,t){if(Ik()<t)throw new RangeError("Invalid typed array length");return Ck.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=Ck.prototype:(null===e&&(e=new Ck(t)),e.length=t),e}function Ck(e,t,n){if(!(Ck.TYPED_ARRAY_SUPPORT||this instanceof Ck))return new Ck(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return Fk(this,e)}return Nk(this,e,t,n)}function Nk(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),Ck.TYPED_ARRAY_SUPPORT?(e=t).__proto__=Ck.prototype:e=Ok(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!Ck.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|Dk(t,n),a=(e=Ak(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}(e,t,n):function(e,t){if($k(t)){var n=0|Mk(t.length);return 0===(e=Ak(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?Ak(e,0):Ok(e,t);if("Buffer"===t.type&&Sk(t.data))return Ok(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function Rk(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function Fk(e,t){if(Rk(t),e=Ak(e,t<0?0:0|Mk(t)),!Ck.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function Ok(e,t){var n=t.length<0?0:0|Mk(t.length);e=Ak(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function Mk(e){if(e>=Ik())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Ik().toString(16)+" bytes");return 0|e}function $k(e){return!(null==e||!e._isBuffer)}function Dk(e,t){if($k(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return lT(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return cT(e).length;default:if(r)return lT(e).length;t=(""+t).toLowerCase(),r=!0}}function Pk(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Jk(this,t,n);case"utf8":case"utf-8":return qk(this,t,n);case"ascii":return Yk(this,t,n);case"latin1":case"binary":return Qk(this,t,n);case"base64":return Kk(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Zk(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Lk(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Bk(e,t,n,r,a){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if("string"==typeof t&&(t=Ck.from(t,r)),$k(t))return 0===t.length?-1:Uk(e,t,n,r,a);if("number"==typeof t)return t&=255,Ck.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Uk(e,[t],n,r,a);throw new TypeError("val must be string, number or Buffer")}function Uk(e,t,n,r,a){var i,s=1,o=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,o/=2,u/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(a){var c=-1;for(i=n;i<o;i++)if(l(e,i)===l(t,-1===c?0:i-c)){if(-1===c&&(c=i),i-c+1===u)return c*s}else-1!==c&&(i-=i-c),c=-1}else for(n+u>o&&(n=o-u),i=n;i>=0;i--){for(var h=!0,p=0;p<u;p++)if(l(e,i+p)!==l(t,p)){h=!1;break}if(h)return i}return-1}function Wk(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var s=0;s<r;++s){var o=parseInt(t.substr(2*s,2),16);if(isNaN(o))return s;e[n+s]=o}return s}function Vk(e,t,n,r){return hT(lT(t,e.length-n),e,n,r)}function zk(e,t,n,r){return hT(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function jk(e,t,n,r){return zk(e,t,n,r)}function Gk(e,t,n,r){return hT(cT(t),e,n,r)}function Hk(e,t,n,r){return hT(function(e,t){for(var n,r,a,i=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,a=n%256,i.push(a),i.push(r);return i}(t,e.length-n),e,n,r)}function Kk(e,t,n){return 0===t&&n===e.length?xk(e):xk(e.slice(t,n))}function qk(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var i,s,o,u,l=e[a],c=null,h=l>239?4:l>223?3:l>191?2:1;if(a+h<=n)switch(h){case 1:l<128&&(c=l);break;case 2:128==(192&(i=e[a+1]))&&(u=(31&l)<<6|63&i)>127&&(c=u);break;case 3:i=e[a+1],s=e[a+2],128==(192&i)&&128==(192&s)&&(u=(15&l)<<12|(63&i)<<6|63&s)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:i=e[a+1],s=e[a+2],o=e[a+3],128==(192&i)&&128==(192&s)&&128==(192&o)&&(u=(15&l)<<18|(63&i)<<12|(63&s)<<6|63&o)>65535&&u<1114112&&(c=u)}null===c?(c=65533,h=1):c>65535&&(c-=65536,r.push(c>>>10&1023|55296),c=56320|1023&c),r.push(c),a+=h}return function(e){var t=e.length;if(t<=Xk)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Xk));return n}(r)}Ck.TYPED_ARRAY_SUPPORT=void 0===Te.TYPED_ARRAY_SUPPORT||Te.TYPED_ARRAY_SUPPORT,Ik(),Ck.poolSize=8192,Ck._augment=function(e){return e.__proto__=Ck.prototype,e},Ck.from=function(e,t,n){return Nk(null,e,t,n)},Ck.TYPED_ARRAY_SUPPORT&&(Ck.prototype.__proto__=Uint8Array.prototype,Ck.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&Ck[Symbol.species]),Ck.alloc=function(e,t,n){return function(e,t,n,r){return Rk(t),t<=0?Ak(e,t):void 0!==n?"string"==typeof r?Ak(e,t).fill(n,r):Ak(e,t).fill(n):Ak(e,t)}(null,e,t,n)},Ck.allocUnsafe=function(e){return Fk(null,e)},Ck.allocUnsafeSlow=function(e){return Fk(null,e)},Ck.isBuffer=function(e){return null!=e&&(!!e._isBuffer||pT(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&pT(e.slice(0,0))}(e))},Ck.compare=function(e,t){if(!$k(e)||!$k(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,a=0,i=Math.min(n,r);a<i;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},Ck.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},Ck.concat=function(e,t){if(!Sk(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return Ck.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=Ck.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var i=e[n];if(!$k(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(r,a),a+=i.length}return r},Ck.byteLength=Dk,Ck.prototype._isBuffer=!0,Ck.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Lk(this,t,t+1);return this},Ck.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Lk(this,t,t+3),Lk(this,t+1,t+2);return this},Ck.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Lk(this,t,t+7),Lk(this,t+1,t+6),Lk(this,t+2,t+5),Lk(this,t+3,t+4);return this},Ck.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?qk(this,0,e):Pk.apply(this,arguments)},Ck.prototype.equals=function(e){if(!$k(e))throw new TypeError("Argument must be a Buffer");return this===e||0===Ck.compare(this,e)},Ck.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},Ck.prototype.compare=function(e,t,n,r,a){if(!$k(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError("out of range index");if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(this===e)return 0;for(var i=(a>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),o=Math.min(i,s),u=this.slice(r,a),l=e.slice(t,n),c=0;c<o;++c)if(u[c]!==l[c]){i=u[c],s=l[c];break}return i<s?-1:s<i?1:0},Ck.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},Ck.prototype.indexOf=function(e,t,n){return Bk(this,e,t,n,!0)},Ck.prototype.lastIndexOf=function(e,t,n){return Bk(this,e,t,n,!1)},Ck.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return Wk(this,e,t,n);case"utf8":case"utf-8":return Vk(this,e,t,n);case"ascii":return zk(this,e,t,n);case"latin1":case"binary":return jk(this,e,t,n);case"base64":return Gk(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Hk(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},Ck.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Xk=4096;function Yk(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function Qk(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function Jk(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a="",i=t;i<n;++i)a+=uT(e[i]);return a}function Zk(e,t,n){for(var r=e.slice(t,n),a="",i=0;i<r.length;i+=2)a+=String.fromCharCode(r[i]+256*r[i+1]);return a}function eT(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function tT(e,t,n,r,a,i){if(!$k(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<i)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function nT(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,i=Math.min(e.length-n,2);a<i;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function rT(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,i=Math.min(e.length-n,4);a<i;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function aT(e,t,n,r,a,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function iT(e,t,n,r,a){return a||aT(e,0,n,4),Tk(e,t,n,r,23,4),n+4}function sT(e,t,n,r,a){return a||aT(e,0,n,8),Tk(e,t,n,r,52,8),n+8}Ck.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),Ck.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=Ck.prototype;else{var a=t-e;n=new Ck(a,void 0);for(var i=0;i<a;++i)n[i]=this[i+e]}return n},Ck.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||eT(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r},Ck.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||eT(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},Ck.prototype.readUInt8=function(e,t){return t||eT(e,1,this.length),this[e]},Ck.prototype.readUInt16LE=function(e,t){return t||eT(e,2,this.length),this[e]|this[e+1]<<8},Ck.prototype.readUInt16BE=function(e,t){return t||eT(e,2,this.length),this[e]<<8|this[e+1]},Ck.prototype.readUInt32LE=function(e,t){return t||eT(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Ck.prototype.readUInt32BE=function(e,t){return t||eT(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Ck.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||eT(e,t,this.length);for(var r=this[e],a=1,i=0;++i<t&&(a*=256);)r+=this[e+i]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},Ck.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||eT(e,t,this.length);for(var r=t,a=1,i=this[e+--r];r>0&&(a*=256);)i+=this[e+--r]*a;return i>=(a*=128)&&(i-=Math.pow(2,8*t)),i},Ck.prototype.readInt8=function(e,t){return t||eT(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Ck.prototype.readInt16LE=function(e,t){t||eT(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},Ck.prototype.readInt16BE=function(e,t){t||eT(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},Ck.prototype.readInt32LE=function(e,t){return t||eT(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Ck.prototype.readInt32BE=function(e,t){return t||eT(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Ck.prototype.readFloatLE=function(e,t){return t||eT(e,4,this.length),kk(this,e,!0,23,4)},Ck.prototype.readFloatBE=function(e,t){return t||eT(e,4,this.length),kk(this,e,!1,23,4)},Ck.prototype.readDoubleLE=function(e,t){return t||eT(e,8,this.length),kk(this,e,!0,52,8)},Ck.prototype.readDoubleBE=function(e,t){return t||eT(e,8,this.length),kk(this,e,!1,52,8)},Ck.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||tT(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,i=0;for(this[t]=255&e;++i<n&&(a*=256);)this[t+i]=e/a&255;return t+n},Ck.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||tT(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,i=1;for(this[t+a]=255&e;--a>=0&&(i*=256);)this[t+a]=e/i&255;return t+n},Ck.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||tT(this,e,t,1,255,0),Ck.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Ck.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||tT(this,e,t,2,65535,0),Ck.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):nT(this,e,t,!0),t+2},Ck.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||tT(this,e,t,2,65535,0),Ck.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):nT(this,e,t,!1),t+2},Ck.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||tT(this,e,t,4,4294967295,0),Ck.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):rT(this,e,t,!0),t+4},Ck.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||tT(this,e,t,4,4294967295,0),Ck.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):rT(this,e,t,!1),t+4},Ck.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);tT(this,e,t,n,a-1,-a)}var i=0,s=1,o=0;for(this[t]=255&e;++i<n&&(s*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},Ck.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);tT(this,e,t,n,a-1,-a)}var i=n-1,s=1,o=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/s>>0)-o&255;return t+n},Ck.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||tT(this,e,t,1,127,-128),Ck.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Ck.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||tT(this,e,t,2,32767,-32768),Ck.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):nT(this,e,t,!0),t+2},Ck.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||tT(this,e,t,2,32767,-32768),Ck.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):nT(this,e,t,!1),t+2},Ck.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||tT(this,e,t,4,2147483647,-2147483648),Ck.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):rT(this,e,t,!0),t+4},Ck.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||tT(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Ck.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):rT(this,e,t,!1),t+4},Ck.prototype.writeFloatLE=function(e,t,n){return iT(this,e,t,!0,n)},Ck.prototype.writeFloatBE=function(e,t,n){return iT(this,e,t,!1,n)},Ck.prototype.writeDoubleLE=function(e,t,n){return sT(this,e,t,!0,n)},Ck.prototype.writeDoubleBE=function(e,t,n){return sT(this,e,t,!1,n)},Ck.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,i=r-n;if(this===e&&n<t&&t<r)for(a=i-1;a>=0;--a)e[a+t]=this[a+n];else if(i<1e3||!Ck.TYPED_ARRAY_SUPPORT)for(a=0;a<i;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+i),t);return i},Ck.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!Ck.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var i;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(i=t;i<n;++i)this[i]=e;else{var s=$k(e)?e:lT(new Ck(e,r).toString()),o=s.length;for(i=0;i<n-t;++i)this[i+t]=s[i%o]}return this};var oT=/[^+\/0-9A-Za-z-_]/g;function uT(e){return e<16?"0"+e.toString(16):e.toString(16)}function lT(e,t){var n;t=t||1/0;for(var r=e.length,a=null,i=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&i.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function cT(e){return function(e){var t,n,r,a,i,s;vk||wk();var o=e.length;if(o%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===e[o-2]?2:"="===e[o-1]?1:0,s=new bk(3*o/4-i),r=i>0?o-4:o;var u=0;for(t=0,n=0;t<r;t+=4,n+=3)a=yk[e.charCodeAt(t)]<<18|yk[e.charCodeAt(t+1)]<<12|yk[e.charCodeAt(t+2)]<<6|yk[e.charCodeAt(t+3)],s[u++]=a>>16&255,s[u++]=a>>8&255,s[u++]=255&a;return 2===i?(a=yk[e.charCodeAt(t)]<<2|yk[e.charCodeAt(t+1)]>>4,s[u++]=255&a):1===i&&(a=yk[e.charCodeAt(t)]<<10|yk[e.charCodeAt(t+1)]<<4|yk[e.charCodeAt(t+2)]>>2,s[u++]=a>>8&255,s[u++]=255&a),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(oT,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function hT(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}function pT(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function dT(e,t){var n=new pe(0),r=new pe(0),a=new pe(0),i=new pe(0),s=K([n,r,a,i]).pipe(J((function(e){return e.reduce((function(t,n){return t+n/e.length}),0)})));if("string"==typeof e){var o=function(e,t){return Rx({url:e,method:"GET",responseType:"arraybuffer",async:!0,progressSubscriber:new I((function(e){return t.next(e.loaded/e.total)}),(function(e){}),(function(){return t.next(1)}))}).pipe(de(2))}(e,n).pipe(ge((function(e){return fT(e.response)})),ge((function(e){return mT(e,t,r).pipe(J((function(t){return{jszip:e,config:t}})))})),ge((function(e){var t=e.jszip,n=e.config;return gT(t,n,a).pipe(J((function(e){return{jszip:t,config:n,jsonModel:e}})))})),ge((function(e){var t=e.jszip,n=e.config,r=e.jsonModel;return yT(t,r,i).pipe(J((function(e){return{config:n,jsonModel:r,weights:e}})))})),ge((function(e){var t=e.config,n=e.jsonModel,r=e.weights;return Y(wm(new mk(n,r))).pipe(J((function(e){return{config:t,graphModel:e}})))})));return{model$:o,progress$:s}}return o=fT(e).pipe(ge((function(e){return mT(e,t,r).pipe(J((function(t){return{jszip:e,config:t}})))})),ge((function(e){var t=e.jszip,n=e.config;return gT(t,n,a).pipe(J((function(e){return{jszip:t,config:n,jsonModel:e}})))})),ge((function(e){var t=e.jszip,n=e.config,r=e.jsonModel;return yT(t,r,i).pipe(J((function(e){return{config:n,jsonModel:r,weights:e}})))})),ge((function(e){var t=e.config,n=e.jsonModel,r=e.weights;return Y(wm(new mk(n,r))).pipe(J((function(e){return{config:t,graphModel:e}})))}))),{model$:o,progress$:s}}function fT(e){return Q(dk(new Uint8Array(e)))}function mT(e,t,n){return e[t]||(t=t.substring(0,t.lastIndexOf("."))+".json",e[t])?ke((function(){return n.next(1),t.includes(".bin")?Q(JSON.parse(lk(fk(e[t])))):Q(JSON.parse(lk(e[t])))})):ne("Unable to retrieve model config: ".concat(t," is missing"))}function gT(e,t,n){return t?e[t.filename]?ke((function(){return n.next(1),Q(JSON.parse(lk(fk(e[t.filename]))))})):ne("Error extracting model: ".concat(t.filename," is missing")):ne("Invalid model config")}function yT(e,t,n){if(!t)return ne("Unable to extract weights: model is undefined");if(!t.weightsManifest)return n.next(1),Q({});for(var r=0,a=0,i=t.weightsManifest;a<i.length;a++){var s=i[a];r+=s.paths.length}for(var o=new Array(r).fill(0),u={},l=0,c=0,h=t.weightsManifest;c<h.length;c++)for(var p=function(t){if(!e[t])return{value:ne("Error extracting weight: ".concat(t," is missing"))};u[t]=ke((function(){var a=e[t];return o[l]=1,n.next(o.reduce((function(e,t){return e+t}),0)/r),Q(fk(Ck.from(a,a.byteOffset,a.byteLength)))})),l++},d=0,f=(s=h[c]).paths;d<f.length;d++){var m=p(f[d]);if("object"==typeof m)return m.value}return dx(u)}Dt.set("DEPRECATION_WARNINGS_ENABLED",!1),Dt.global.Math=Math,Dt.global.Float32Array=Float32Array,Mt().set("WEBGL_FORCE_F16_TEXTURES",!0);var bT,vT,wT,_T=function(){function e(){this._initialized=!1}return e.prototype.getWidth=function(){return this._modelConfig?this._modelConfig.inWidth:0},e.prototype.getHeight=function(){return this._modelConfig?this._modelConfig.inHeight:0},e.prototype.isInitialized=function(){return this._initialized},e.prototype.getOutput=function(){return this._cnnOutputData},e.prototype.initialize=function(e,t,n){return l(this,void 0,void 0,(function(){var r,a,i,s,o=this;return c(this,(function(l){switch(l.label){case 0:if(null==e)throw"Invalid parameter";return this.release(),this._videoManager=e,this._config=t?u(u({},px),t):px,r=dT(this._config.filename,"config.json"),a=r.model$,i=r.progress$,s=i.pipe(J((function(e){return n&&n(e)}))).subscribe(),[4,a.pipe(J((function(e){var t=e.config,n=e.graphModel;o._modelConfig=t,o._model=n;var r=Oc([1,o._modelConfig.inHeight,o._modelConfig.inWidth,o._modelConfig.inChannels]),a=o._model.predict(r,{batchSize:1,verbose:!0});Array.isArray(a)?a.forEach((function(e){e.dispose()})):a.dispose(),o._cnnOutput=Oc([1,o._modelConfig.inHeight,o._modelConfig.inWidth,1]),r.dispose(),o._initialized=!0})),ae((function(){return s.unsubscribe()}))).toPromise()];case 1:return l.sent(),[2]}}))}))},e.prototype.processSync=function(){var e;if(this._initialized){var t=this._videoManager.getLastBuffer();if(null!=t){var n,r=Vo(t),a=gd.resizeBilinear(r,[this._modelConfig.inHeight,this._modelConfig.inWidth]),i=ko(a,"float32"),s=Bu(i,[1,this._modelConfig.inHeight,this._modelConfig.inWidth,3]),o=Gl(255);if(4==this._modelConfig.inChannels){var u=Bu(this._cnnOutput,[1,this._modelConfig.inHeight,this._modelConfig.inWidth,1]),l=hu(s,o);n=zu([l,u],3),l.dispose(),u.dispose()}else n=hu(s,o);var c,h=this._model.predict(n);c=Array.isArray(h)?h[2]:h,null===(e=this._cnnOutput)||void 0===e||e.dispose();var p=c.shape;if(p&&p[3]>1){var d=Vh(c);this._cnnOutput=Gu(d,[0,0,0,1],[-1,-1,-1,1]),d.dispose(),this._cnnOutputData=this._cnnOutput.dataSync()}else this._cnnOutput=il(c,0,1),this._cnnOutputData=this._cnnOutput.dataSync();Array.isArray(h)?h.forEach((function(e){e.dispose()})):h.dispose(),r.dispose(),a.dispose(),i.dispose(),s.dispose(),o.dispose(),n.dispose()}else console.error("No video frame to process")}else console.error("Foot must be initialized to track")},e.prototype.release=function(){var e,t;null===(e=this._cnnOutput)||void 0===e||e.dispose(),null===(t=this._model)||void 0===t||t.dispose(),this._initialized=!1},e}(),xT=(bT="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(e={}){var t,n,r;t||(t=void 0!==e?e:{}),t.ready=new Promise((function(e,t){n=e,r=t}));var a=Object.assign({},t),i="./this.program",s="";"undefined"!=typeof document&&document.currentScript&&(s=document.currentScript.src),bT&&(s=bT),s=0!==s.indexOf("blob:")?s.substr(0,s.replace(/[?#].*/,"").lastIndexOf("/")+1):"";var o,u=t.print||console.log.bind(console),l=t.printErr||console.warn.bind(console);Object.assign(t,a),a=null,t.thisProgram&&(i=t.thisProgram),t.wasmBinary&&(o=t.wasmBinary),t.noExitRuntime,"object"!=typeof WebAssembly&&O("no native wasm support detected");var c,h,p,d,f,m,g,y,b=!1,v="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function w(e,t){for(var n=t+NaN,r=t;e[r]&&!(r>=n);)++r;if(16<r-t&&e.buffer&&v)return v.decode(e.subarray(t,r));for(n="";t<r;){var a=e[t++];if(128&a){var i=63&e[t++];if(192==(224&a))n+=String.fromCharCode((31&a)<<6|i);else{var s=63&e[t++];65536>(a=224==(240&a)?(15&a)<<12|i<<6|s:(7&a)<<18|i<<12|s<<6|63&e[t++])?n+=String.fromCharCode(a):(a-=65536,n+=String.fromCharCode(55296|a>>10,56320|1023&a))}}else n+=String.fromCharCode(a)}return n}function _(e){return e?w(p,e):""}function x(e,t,n,r){if(!(0<r))return 0;var a=n;r=n+r-1;for(var i=0;i<e.length;++i){var s=e.charCodeAt(i);if(55296<=s&&57343>=s&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i)),127>=s){if(n>=r)break;t[n++]=s}else{if(2047>=s){if(n+1>=r)break;t[n++]=192|s>>6}else{if(65535>=s){if(n+2>=r)break;t[n++]=224|s>>12}else{if(n+3>=r)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63}t[n++]=128|s>>6&63}t[n++]=128|63&s}}return t[n]=0,n-a}function k(){var e=c.buffer;t.HEAP8=h=new Int8Array(e),t.HEAP16=d=new Int16Array(e),t.HEAP32=f=new Int32Array(e),t.HEAPU8=p=new Uint8Array(e),t.HEAPU16=new Uint16Array(e),t.HEAPU32=m=new Uint32Array(e),t.HEAPF32=g=new Float32Array(e),t.HEAPF64=y=new Float64Array(e)}var T=[],E=[],S=[];function I(){var e=t.preRun.shift();T.unshift(e)}var A,C,N,R=0,F=null;function O(e){throw t.onAbort&&t.onAbort(e),l(e="Aborted("+e+")"),b=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),r(e),e}function M(e){return e.startsWith("data:application/octet-stream;base64,")}if(!M(A="libxzimgPoseEstimation.wasm")){var $=A;A=t.locateFile?t.locateFile($,s):s+$}function D(e){try{if(e==A&&o)return new Uint8Array(o);throw"both async and sync fetching of the wasm failed"}catch(e){O(e)}}function P(e,t,n){return function(e){return o||"function"!=typeof fetch?Promise.resolve().then((function(){return D(e)})):fetch(e,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+e+"'";return t.arrayBuffer()})).catch((function(){return D(e)}))}(e).then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(n,(function(e){l("failed to asynchronously prepare wasm: "+e),O(e)}))}function L(e){for(;0<e.length;)e.shift()(t)}function B(e){this.F=e-24,this.ta=function(e){m[this.F+4>>2]=e},this.oa=function(e){m[this.F+8>>2]=e},this.pa=function(){f[this.F>>2]=0},this.ma=function(){h[this.F+12>>0]=0},this.qa=function(){h[this.F+13>>0]=0},this.I=function(e,t){this.la(),this.ta(e),this.oa(t),this.pa(),this.ma(),this.qa()},this.la=function(){m[this.F+16>>2]=0}}var U=(e,t)=>{for(var n=0,r=e.length-1;0<=r;r--){var a=e[r];"."===a?e.splice(r,1):".."===a?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n;n--)e.unshift("..");return e},W=e=>{var t="/"===e.charAt(0),n="/"===e.substr(-1);return(e=U(e.split("/").filter((e=>!!e)),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e},V=e=>{var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],e||t?(t&&(t=t.substr(0,t.length-1)),e+t):"."},z=e=>{if("/"===e)return"/";var t=(e=(e=W(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)};function j(){for(var e="",t=!1,n=arguments.length-1;-1<=n&&!t;n--){if("string"!=typeof(t=0<=n?arguments[n]:"/"))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";e=t+"/"+e,t="/"===t.charAt(0)}return(t?"/":"")+(e=U(e.split("/").filter((e=>!!e)),!t).join("/"))||"."}function G(e,t){for(var n=0,r=0;r<e.length;++r){var a=e.charCodeAt(r);127>=a?n++:2047>=a?n+=2:55296<=a&&57343>=a?(n+=4,++r):n+=3}return e=x(e,n=Array(n+1),0,n.length),t&&(n.length=e),n}var H=[];function K(e,t){H[e]={input:[],m:[],J:t},_e(e,J)}var q,X,Y,Q,J={open:function(e){var t=H[e.node.P];if(!t)throw new ue(43);e.l=t,e.seekable=!1},close:function(e){e.l.J.M(e.l)},M:function(e){e.l.J.M(e.l)},read:function(e,t,n,r){if(!e.l||!e.l.J.ca)throw new ue(60);for(var a=0,i=0;i<r;i++){try{var s=e.l.J.ca(e.l)}catch(e){throw new ue(29)}if(void 0===s&&0===a)throw new ue(6);if(null==s)break;a++,t[n+i]=s}return a&&(e.node.timestamp=Date.now()),a},write:function(e,t,n,r){if(!e.l||!e.l.J.V)throw new ue(60);try{for(var a=0;a<r;a++)e.l.J.V(e.l,t[n+a])}catch(e){throw new ue(29)}return r&&(e.node.timestamp=Date.now()),a}},Z={ca:function(e){if(!e.input.length){var t=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(t=window.prompt("Input: "))&&(t+="\n"):"function"==typeof readline&&null!==(t=readline())&&(t+="\n"),!t)return null;e.input=G(t,!0)}return e.input.shift()},V:function(e,t){null===t||10===t?(u(w(e.m,0)),e.m=[]):0!=t&&e.m.push(t)},M:function(e){e.m&&0<e.m.length&&(u(w(e.m,0)),e.m=[])}},ee={V:function(e,t){null===t||10===t?(l(w(e.m,0)),e.m=[]):0!=t&&e.m.push(t)},M:function(e){e.m&&0<e.m.length&&(l(w(e.m,0)),e.m=[])}},te={o:null,v:function(){return te.createNode(null,"/",16895,0)},createNode:function(e,t,n,r){if(24576==(61440&n)||4096==(61440&n))throw new ue(63);return te.o||(te.o={dir:{node:{B:te.h.B,s:te.h.s,K:te.h.K,N:te.h.N,ha:te.h.ha,ja:te.h.ja,ia:te.h.ia,ga:te.h.ga,R:te.h.R},stream:{D:te.i.D}},file:{node:{B:te.h.B,s:te.h.s},stream:{D:te.i.D,read:te.i.read,write:te.i.write,Y:te.i.Y,da:te.i.da,fa:te.i.fa}},link:{node:{B:te.h.B,s:te.h.s,L:te.h.L},stream:{}},Z:{node:{B:te.h.B,s:te.h.s},stream:we}}),16384==(61440&(n=fe(e,t,n,r)).mode)?(n.h=te.o.dir.node,n.i=te.o.dir.stream,n.g={}):32768==(61440&n.mode)?(n.h=te.o.file.node,n.i=te.o.file.stream,n.j=0,n.g=null):40960==(61440&n.mode)?(n.h=te.o.link.node,n.i=te.o.link.stream):8192==(61440&n.mode)&&(n.h=te.o.Z.node,n.i=te.o.Z.stream),n.timestamp=Date.now(),e&&(e.g[t]=n,e.timestamp=n.timestamp),n},Ga:function(e){return e.g?e.g.subarray?e.g.subarray(0,e.j):new Uint8Array(e.g):new Uint8Array(0)},$:function(e,t){var n=e.g?e.g.length:0;n>=t||(t=Math.max(t,n*(1048576>n?2:1.125)>>>0),0!=n&&(t=Math.max(t,256)),n=e.g,e.g=new Uint8Array(t),0<e.j&&e.g.set(n.subarray(0,e.j),0))},ua:function(e,t){if(e.j!=t)if(0==t)e.g=null,e.j=0;else{var n=e.g;e.g=new Uint8Array(t),n&&e.g.set(n.subarray(0,Math.min(t,e.j))),e.j=t}},h:{B:function(e){var t={};return t.Fa=8192==(61440&e.mode)?e.id:1,t.Ia=e.id,t.mode=e.mode,t.Ka=1,t.uid=0,t.Ha=0,t.P=e.P,16384==(61440&e.mode)?t.size=4096:32768==(61440&e.mode)?t.size=e.j:40960==(61440&e.mode)?t.size=e.link.length:t.size=0,t.Ca=new Date(e.timestamp),t.Ja=new Date(e.timestamp),t.Ea=new Date(e.timestamp),t.ka=4096,t.Da=Math.ceil(t.size/t.ka),t},s:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&te.ua(e,t.size)},K:function(){throw le[44]},N:function(e,t,n,r){return te.createNode(e,t,n,r)},ha:function(e,t,n){if(16384==(61440&e.mode)){try{var r=de(t,n)}catch(e){}if(r)for(var a in r.g)throw new ue(55)}delete e.parent.g[e.name],e.parent.timestamp=Date.now(),e.name=n,t.g[n]=e,t.timestamp=e.parent.timestamp,e.parent=t},ja:function(e,t){delete e.g[t],e.timestamp=Date.now()},ia:function(e,t){var n,r=de(e,t);for(n in r.g)throw new ue(55);delete e.g[t],e.timestamp=Date.now()},ga:function(e){var t,n=[".",".."];for(t in e.g)e.g.hasOwnProperty(t)&&n.push(t);return n},R:function(e,t,n){return(e=te.createNode(e,t,41471,0)).link=n,e},L:function(e){if(40960!=(61440&e.mode))throw new ue(28);return e.link}},i:{read:function(e,t,n,r,a){var i=e.node.g;if(a>=e.node.j)return 0;if(8<(e=Math.min(e.node.j-a,r))&&i.subarray)t.set(i.subarray(a,a+e),n);else for(r=0;r<e;r++)t[n+r]=i[a+r];return e},write:function(e,t,n,r,a,i){if(t.buffer===h.buffer&&(i=!1),!r)return 0;if((e=e.node).timestamp=Date.now(),t.subarray&&(!e.g||e.g.subarray)){if(i)return e.g=t.subarray(n,n+r),e.j=r;if(0===e.j&&0===a)return e.g=t.slice(n,n+r),e.j=r;if(a+r<=e.j)return e.g.set(t.subarray(n,n+r),a),r}if(te.$(e,a+r),e.g.subarray&&t.subarray)e.g.set(t.subarray(n,n+r),a);else for(i=0;i<r;i++)e.g[a+i]=t[n+i];return e.j=Math.max(e.j,a+r),r},D:function(e,t,n){if(1===n?t+=e.position:2===n&&32768==(61440&e.node.mode)&&(t+=e.node.j),0>t)throw new ue(28);return t},Y:function(e,t,n){te.$(e.node,t+n),e.node.j=Math.max(e.node.j,t+n)},da:function(e,t,n,r,a){if(32768!=(61440&e.node.mode))throw new ue(43);if(e=e.node.g,2&a||e.buffer!==h.buffer){if((0<n||n+t<e.length)&&(e=e.subarray?e.subarray(n,n+t):Array.prototype.slice.call(e,n,n+t)),n=!0,O(),!(t=void 0))throw new ue(48);h.set(e,t)}else n=!1,t=e.byteOffset;return{F:t,Ba:n}},fa:function(e,t,n,r){return te.i.write(e,t,0,r,n,!1),0}}},ne=null,re={},ae=[],ie=1,se=null,oe=!0,ue=null,le={},ce=(e,t={})=>{if(!(e=j(e)))return{path:"",node:null};if(8<(t=Object.assign({ba:!0,W:0},t)).W)throw new ue(32);e=e.split("/").filter((e=>!!e));for(var n=ne,r="/",a=0;a<e.length;a++){var i=a===e.length-1;if(i&&t.parent)break;if(n=de(n,e[a]),r=W(r+"/"+e[a]),n.O&&(!i||i&&t.ba)&&(n=n.O.root),!i||t.aa)for(i=0;40960==(61440&n.mode);)if(n=Se(r),r=j(V(r),n),n=ce(r,{W:t.W+1}).node,40<i++)throw new ue(32)}return{path:r,node:n}},he=e=>{for(var t;;){if(e===e.parent)return e=e.v.ea,t?"/"!==e[e.length-1]?e+"/"+t:e+t:e;t=t?e.name+"/"+t:e.name,e=e.parent}},pe=(e,t)=>{for(var n=0,r=0;r<t.length;r++)n=(n<<5)-n+t.charCodeAt(r)|0;return(e+n>>>0)%se.length},de=(e,t)=>{var n;if(n=(n=ye(e,"x"))?n:e.h.K?0:2)throw new ue(n,e);for(n=se[pe(e.id,t)];n;n=n.sa){var r=n.name;if(n.parent.id===e.id&&r===t)return n}return e.h.K(e,t)},fe=(e,t,n,r)=>(e=new Ve(e,t,n,r),t=pe(e.parent.id,e.name),e.sa=se[t],se[t]=e),me={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},ge=e=>{var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},ye=(e,t)=>oe?0:!t.includes("r")||292&e.mode?t.includes("w")&&!(146&e.mode)||t.includes("x")&&!(73&e.mode)?2:0:2,be=(e,t)=>{try{return de(e,t),20}catch(e){}return ye(e,"wx")},ve=(e,t)=>(Y||((Y=function(){this.I={}}).prototype={},Object.defineProperties(Y.prototype,{object:{get:function(){return this.node},set:function(e){this.node=e}},flags:{get:function(){return this.I.flags},set:function(e){this.I.flags=e}},position:{get:function(){return this.I.position},set:function(e){this.I.position=e}}})),e=Object.assign(new Y,e),t=((e=0)=>{for(;4096>=e;e++)if(!ae[e])return e;throw new ue(33)})(t),e.A=t,ae[t]=e),we={open:e=>{e.i=re[e.node.P].i,e.i.open&&e.i.open(e)},D:()=>{throw new ue(70)}},_e=(e,t)=>{re[e]={i:t}},xe=(e,t)=>{var n="/"===t,r=!t;if(n&&ne)throw new ue(10);if(!n&&!r){var a=ce(t,{ba:!1});if(t=a.path,(a=a.node).O)throw new ue(10);if(16384!=(61440&a.mode))throw new ue(54)}t={type:e,La:{},ea:t,ra:[]},(e=e.v(t)).v=t,t.root=e,n?ne=e:a&&(a.O=t,a.v&&a.v.ra.push(t))},ke=(e,t,n)=>{var r=ce(e,{parent:!0}).node;if(!(e=z(e))||"."===e||".."===e)throw new ue(28);var a=be(r,e);if(a)throw new ue(a);if(!r.h.N)throw new ue(63);return r.h.N(r,e,t,n)},Te=(e,t,n)=>{void 0===n&&(n=t,t=438),ke(e,8192|t,n)},Ee=(e,t)=>{if(!j(e))throw new ue(44);var n=ce(t,{parent:!0}).node;if(!n)throw new ue(44);t=z(t);var r=be(n,t);if(r)throw new ue(r);if(!n.h.R)throw new ue(63);n.h.R(n,t,e)},Se=e=>{if(!(e=ce(e).node))throw new ue(44);if(!e.h.L)throw new ue(28);return j(he(e.parent),e.h.L(e))},Ie=(e,n,r)=>{if(""===e)throw new ue(44);if("string"==typeof n){var a=me[n];if(void 0===a)throw Error("Unknown file open mode: "+n);n=a}if(r=64&n?4095&(void 0===r?438:r)|32768:0,"object"==typeof e)var i=e;else{e=W(e);try{i=ce(e,{aa:!(131072&n)}).node}catch(e){}}if(a=!1,64&n)if(i){if(128&n)throw new ue(20)}else i=ke(e,r,0),a=!0;if(!i)throw new ue(44);if(8192==(61440&i.mode)&&(n&=-513),65536&n&&16384!=(61440&i.mode))throw new ue(54);if(!a&&(r=i?40960==(61440&i.mode)?32:16384==(61440&i.mode)&&("r"!==ge(n)||512&n)?31:ye(i,ge(n)):44))throw new ue(r);if(512&n&&!a){if(!(r="string"==typeof(r=i)?ce(r,{aa:!0}).node:r).h.s)throw new ue(63);if(16384==(61440&r.mode))throw new ue(31);if(32768!=(61440&r.mode))throw new ue(28);if(a=ye(r,"w"))throw new ue(a);r.h.s(r,{size:0,timestamp:Date.now()})}return n&=-131713,(i=ve({node:i,path:he(i),flags:n,seekable:!0,position:0,i:i.i,Aa:[],error:!1})).i.open&&i.i.open(i),!t.logReadFiles||1&n||(Q||(Q={}),e in Q||(Q[e]=1)),i},Ae=(e,t,n)=>{if(null===e.A)throw new ue(8);if(!e.seekable||!e.i.D)throw new ue(70);if(0!=n&&1!=n&&2!=n)throw new ue(28);e.position=e.i.D(e,t,n),e.Aa=[]},Ce=()=>{ue||((ue=function(e,t){this.name="ErrnoError",this.node=t,this.va=function(e){this.C=e},this.va(e),this.message="FS error"}).prototype=Error(),ue.prototype.constructor=ue,[44].forEach((e=>{le[e]=new ue(e),le[e].stack="<generic error, no stack>"})))},Ne=(e,t,n)=>{e=W("/dev/"+e);var r=((e,t)=>{var n=0;return e&&(n|=365),t&&(n|=146),n})(!!t,!!n);X||(X=64);var a=X++<<8|0;_e(a,{open:e=>{e.seekable=!1},close:()=>{n&&n.buffer&&n.buffer.length&&n(10)},read:(e,n,r,a)=>{for(var i=0,s=0;s<a;s++){try{var o=t()}catch(e){throw new ue(29)}if(void 0===o&&0===i)throw new ue(6);if(null==o)break;i++,n[r+s]=o}return i&&(e.node.timestamp=Date.now()),i},write:(e,t,r,a)=>{for(var i=0;i<a;i++)try{n(t[r+i])}catch(e){throw new ue(29)}return a&&(e.node.timestamp=Date.now()),i}}),Te(e,r,a)},Re={},Fe=void 0;function Oe(){return f[(Fe+=4)-4>>2]}function Me(e){if(!(e=ae[e]))throw new ue(8);return e}var $e,De={};function Pe(){if(!$e){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:i||"./this.program"};for(e in De)void 0===De[e]?delete t[e]:t[e]=De[e];var n=[];for(e in t)n.push(e+"="+t[e]);$e=n}return $e}function Le(e){return 0==e%4&&(0!=e%100||0==e%400)}var Be=[31,29,31,30,31,30,31,31,30,31,30,31],Ue=[31,28,31,30,31,30,31,31,30,31,30,31];function We(e,n,r,a){var i={string:e=>{var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);t=qe(n),x(e,p,t,n)}return t},array:e=>{var t=qe(e.length);return h.set(e,t),t}};e=t["_"+e];var s,o=[],u=0;if(a)for(var l=0;l<a.length;l++){var c=i[r[l]];c?(0===u&&(u=He()),o[l]=c(a[l])):o[l]=a[l]}return s=r=e.apply(null,o),0!==u&&Ke(u),"string"===n?_(s):"boolean"===n?!!s:s}function Ve(e,t,n,r){e||(e=this),this.parent=e,this.v=e.v,this.O=null,this.id=ie++,this.name=t,this.mode=n,this.h={},this.i={},this.P=r}Object.defineProperties(Ve.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}}}),Ce(),se=Array(4096),xe(te,"/"),ke("/tmp",16895,0),ke("/home",16895,0),ke("/home/web_user",16895,0),(()=>{ke("/dev",16895,0),_e(259,{read:()=>0,write:(e,t,n,r)=>r}),Te("/dev/null",259),K(1280,Z),K(1536,ee),Te("/dev/tty",1280),Te("/dev/tty1",1536);var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return()=>(crypto.getRandomValues(e),e[0])}return()=>O("randomDevice")}();Ne("random",e),Ne("urandom",e),ke("/dev/shm",16895,0),ke("/dev/shm/tmp",16895,0)})(),(()=>{ke("/proc",16895,0);var e=ke("/proc/self",16895,0);ke("/proc/self/fd",16895,0),xe({v:()=>{var t=fe(e,"fd",16895,73);return t.h={K:(e,t)=>{var n=ae[+t];if(!n)throw new ue(8);return(e={parent:null,v:{ea:"fake"},h:{L:()=>n.path}}).parent=e}},t}},"/proc/self/fd")})();var ze,je={__assert_fail:function(e,t,n,r){O("Assertion failed: "+_(e)+", at: "+[t?_(t):"unknown filename",n,r?_(r):"unknown function"])},__cxa_throw:function(e,t,n){throw new B(e).I(t,n),e},__syscall_fcntl64:function(e,t,n){Fe=n;try{var r=Me(e);switch(t){case 0:var a=Oe();return 0>a?-28:ve(r,a).A;case 1:case 2:case 6:case 7:return 0;case 3:return r.flags;case 4:return a=Oe(),r.flags|=a,0;case 5:return a=Oe(),d[a+0>>1]=2,0;case 16:case 8:default:return-28;case 9:return f[Ge()>>2]=28,-1}}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return-e.C}},__syscall_ioctl:function(e,t,n){Fe=n;try{var r=Me(e);switch(t){case 21509:case 21505:case 21510:case 21511:case 21512:case 21506:case 21507:case 21508:case 21523:case 21524:return r.l?0:-59;case 21519:if(!r.l)return-59;var a=Oe();return f[a>>2]=0;case 21520:return r.l?-28:-59;case 21531:if(e=a=Oe(),!r.i.na)throw new ue(59);return r.i.na(r,t,e);default:return-28}}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return-e.C}},__syscall_openat:function(e,t,n,r){Fe=r;try{var a=t=_(t);if("/"===a.charAt(0))t=a;else{var i=-100===e?"/":Me(e).path;if(0==a.length)throw new ue(44);t=W(i+"/"+a)}var s=r?Oe():0;return Ie(t,n,s).A}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return-e.C}},abort:function(){O("")},emscripten_memcpy_big:function(e,t,n){p.copyWithin(e,t,t+n)},emscripten_resize_heap:function(e){var t=p.length;if(2147483648<(e>>>=0))return!1;for(var n=1;4>=n;n*=2){var r=t*(1+.2/n);r=Math.min(r,e+100663296);var a=Math,i=a.min;r=Math.max(e,r),r+=(65536-r%65536)%65536;e:{var s=c.buffer;try{c.grow(i.call(a,2147483648,r)-s.byteLength+65535>>>16),k();var o=1;break e}catch(e){}o=void 0}if(o)return!0}return!1},environ_get:function(e,t){var n=0;return Pe().forEach((function(r,a){var i=t+n;for(a=m[e+4*a>>2]=i,i=0;i<r.length;++i)h[a++>>0]=r.charCodeAt(i);h[a>>0]=0,n+=r.length+1})),0},environ_sizes_get:function(e,t){var n=Pe();m[e>>2]=n.length;var r=0;return n.forEach((function(e){r+=e.length+1})),m[t>>2]=r,0},fd_close:function(e){try{var t=Me(e);if(null===t.A)throw new ue(8);t.U&&(t.U=null);try{t.i.close&&t.i.close(t)}catch(e){throw e}finally{ae[t.A]=null}return t.A=null,0}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return e.C}},fd_read:function(e,t,n,r){try{e:{var a=Me(e);e=t;for(var i,s=t=0;s<n;s++){var o=m[e>>2],u=m[e+4>>2];e+=8;var l=a,c=o,p=u,d=i,f=h;if(0>p||0>d)throw new ue(28);if(null===l.A)throw new ue(8);if(1==(2097155&l.flags))throw new ue(8);if(16384==(61440&l.node.mode))throw new ue(31);if(!l.i.read)throw new ue(28);var g=void 0!==d;if(g){if(!l.seekable)throw new ue(70)}else d=l.position;var y=l.i.read(l,f,c,p,d);g||(l.position+=y);var b=y;if(0>b){var v=-1;break e}if(t+=b,b<u)break;void 0!==i&&(i+=b)}v=t}return m[r>>2]=v,0}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return e.C}},fd_seek:function(e,t,n,r,a){try{if(t=n+2097152>>>0<4194305-!!t?(t>>>0)+4294967296*n:NaN,isNaN(t))return 61;var i=Me(e);return Ae(i,t,r),N=[i.position>>>0,(C=i.position,1<=+Math.abs(C)?0<C?(0|Math.min(+Math.floor(C/4294967296),4294967295))>>>0:~~+Math.ceil((C-+(~~C>>>0))/4294967296)>>>0:0)],f[a>>2]=N[0],f[a+4>>2]=N[1],i.U&&0===t&&0===r&&(i.U=null),0}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return e.C}},fd_write:function(e,t,n,r){try{e:{var a=Me(e);e=t;for(var i,s=t=0;s<n;s++){var o=m[e>>2],u=m[e+4>>2];e+=8;var l=a,c=o,p=u,d=i,f=h;if(0>p||0>d)throw new ue(28);if(null===l.A)throw new ue(8);if(0==(2097155&l.flags))throw new ue(8);if(16384==(61440&l.node.mode))throw new ue(31);if(!l.i.write)throw new ue(28);l.seekable&&1024&l.flags&&Ae(l,0,2);var g=void 0!==d;if(g){if(!l.seekable)throw new ue(70)}else d=l.position;var y=l.i.write(l,f,c,p,d,void 0);g||(l.position+=y);var b=y;if(0>b){var v=-1;break e}t+=b,void 0!==i&&(i+=b)}v=t}return m[r>>2]=v,0}catch(e){if(void 0===Re||"ErrnoError"!==e.name)throw e;return e.C}},strftime_l:function(e,t,n,r){return function(e,t,n,r){function a(e,t,n){for(e="number"==typeof e?e.toString():e||"";e.length<t;)e=n[0]+e;return e}function i(e,t){return a(e,t,"0")}function s(e,t){function n(e){return 0>e?-1:0<e?1:0}var r;return 0===(r=n(e.getFullYear()-t.getFullYear()))&&0===(r=n(e.getMonth()-t.getMonth()))&&(r=n(e.getDate()-t.getDate())),r}function o(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function u(e){var t=e.G;for(e=new Date(new Date(e.H+1900,0,1).getTime());0<t;){var n=e.getMonth(),r=(Le(e.getFullYear())?Be:Ue)[n];if(!(t>r-e.getDate())){e.setDate(e.getDate()+t);break}t-=r-e.getDate()+1,e.setDate(1),11>n?e.setMonth(n+1):(e.setMonth(0),e.setFullYear(e.getFullYear()+1))}return n=new Date(e.getFullYear()+1,0,4),t=o(new Date(e.getFullYear(),0,4)),n=o(n),0>=s(t,e)?0>=s(n,e)?e.getFullYear()+1:e.getFullYear():e.getFullYear()-1}var l=f[r+40>>2];for(var c in r={ya:f[r>>2],xa:f[r+4>>2],S:f[r+8>>2],X:f[r+12>>2],T:f[r+16>>2],H:f[r+20>>2],u:f[r+24>>2],G:f[r+28>>2],Ma:f[r+32>>2],wa:f[r+36>>2],za:l?_(l):""},n=_(n),l={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"})n=n.replace(new RegExp(c,"g"),l[c]);var p="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),d="January February March April May June July August September October November December".split(" ");for(c in l={"%a":function(e){return p[e.u].substring(0,3)},"%A":function(e){return p[e.u]},"%b":function(e){return d[e.T].substring(0,3)},"%B":function(e){return d[e.T]},"%C":function(e){return i((e.H+1900)/100|0,2)},"%d":function(e){return i(e.X,2)},"%e":function(e){return a(e.X,2," ")},"%g":function(e){return u(e).toString().substring(2)},"%G":function(e){return u(e)},"%H":function(e){return i(e.S,2)},"%I":function(e){return 0==(e=e.S)?e=12:12<e&&(e-=12),i(e,2)},"%j":function(e){for(var t=0,n=0;n<=e.T-1;t+=(Le(e.H+1900)?Be:Ue)[n++]);return i(e.X+t,3)},"%m":function(e){return i(e.T+1,2)},"%M":function(e){return i(e.xa,2)},"%n":function(){return"\n"},"%p":function(e){return 0<=e.S&&12>e.S?"AM":"PM"},"%S":function(e){return i(e.ya,2)},"%t":function(){return"\t"},"%u":function(e){return e.u||7},"%U":function(e){return i(Math.floor((e.G+7-e.u)/7),2)},"%V":function(e){var t=Math.floor((e.G+7-(e.u+6)%7)/7);if(2>=(e.u+371-e.G-2)%7&&t++,t)53==t&&(4==(n=(e.u+371-e.G)%7)||3==n&&Le(e.H)||(t=1));else{t=52;var n=(e.u+7-e.G-1)%7;(4==n||5==n&&Le(e.H%400-1))&&t++}return i(t,2)},"%w":function(e){return e.u},"%W":function(e){return i(Math.floor((e.G+7-(e.u+6)%7)/7),2)},"%y":function(e){return(e.H+1900).toString().substring(2)},"%Y":function(e){return e.H+1900},"%z":function(e){var t=0<=(e=e.wa);return e=Math.abs(e)/60,(t?"+":"-")+String("0000"+(e/60*100+e%60)).slice(-4)},"%Z":function(e){return e.za},"%%":function(){return"%"}},n=n.replace(/%%/g,"\0\0"),l)n.includes(c)&&(n=n.replace(new RegExp(c,"g"),l[c](r)));return(c=G(n=n.replace(/\0\0/g,"%"),!1)).length>t?0:(h.set(c,e),c.length-1)}(e,t,n,r)}};function Ge(){return(Ge=t.asm.__errno_location).apply(null,arguments)}function He(){return(He=t.asm.stackSave).apply(null,arguments)}function Ke(){return(Ke=t.asm.stackRestore).apply(null,arguments)}function qe(){return(qe=t.asm.stackAlloc).apply(null,arguments)}function Xe(){function e(){if(!ze&&(ze=!0,t.calledRun=!0,!b)){if(t.noFSInit||q||(q=!0,Ce(),t.stdin=t.stdin,t.stdout=t.stdout,t.stderr=t.stderr,t.stdin?Ne("stdin",t.stdin):Ee("/dev/tty","/dev/stdin"),t.stdout?Ne("stdout",null,t.stdout):Ee("/dev/tty","/dev/stdout"),t.stderr?Ne("stderr",null,t.stderr):Ee("/dev/tty1","/dev/stderr"),Ie("/dev/stdin",0),Ie("/dev/stdout",1),Ie("/dev/stderr",1)),oe=!1,L(E),n(t),t.onRuntimeInitialized&&t.onRuntimeInitialized(),t.postRun)for("function"==typeof t.postRun&&(t.postRun=[t.postRun]);t.postRun.length;){var e=t.postRun.shift();S.unshift(e)}L(S)}}if(!(0<R)){if(t.preRun)for("function"==typeof t.preRun&&(t.preRun=[t.preRun]);t.preRun.length;)I();L(T),0<R||(t.setStatus?(t.setStatus("Running..."),setTimeout((function(){setTimeout((function(){t.setStatus("")}),1),e()}),1)):e())}}if(function(){function e(e){if(e=e.exports,t.asm=e,c=t.asm.memory,k(),E.unshift(t.asm.__wasm_call_ctors),R--,t.monitorRunDependencies&&t.monitorRunDependencies(R),0==R&&F){var n=F;F=null,n()}return e}var n={env:je,wasi_snapshot_preview1:je};if(R++,t.monitorRunDependencies&&t.monitorRunDependencies(R),t.instantiateWasm)try{return t.instantiateWasm(n,e)}catch(e){l("Module.instantiateWasm callback failed with error: "+e),r(e)}(function(e,t){var n=A;return o||"function"!=typeof WebAssembly.instantiateStreaming||M(n)||"function"!=typeof fetch?P(n,e,t):fetch(n,{credentials:"same-origin"}).then((function(r){return WebAssembly.instantiateStreaming(r,e).then(t,(function(r){return l("wasm streaming compile failed: "+r),l("falling back to ArrayBuffer instantiation"),P(n,e,t)}))}))})(n,(function(t){e(t.instance)})).catch(r)}(),t._malloc=function(){return(t._malloc=t.asm.malloc).apply(null,arguments)},t._free=function(){return(t._free=t.asm.free).apply(null,arguments)},t._xzimgInitializeCamera=function(){return(t._xzimgInitializeCamera=t.asm.xzimgInitializeCamera).apply(null,arguments)},t._xzimgPoseEstimationInitializeFacePose=function(){return(t._xzimgPoseEstimationInitializeFacePose=t.asm.xzimgPoseEstimationInitializeFacePose).apply(null,arguments)},t._xzimgPoseEstimationInitialize=function(){return(t._xzimgPoseEstimationInitialize=t.asm.xzimgPoseEstimationInitialize).apply(null,arguments)},t._xzimgPoseEstimationRelease=function(){return(t._xzimgPoseEstimationRelease=t.asm.xzimgPoseEstimationRelease).apply(null,arguments)},t._xzimgPoseEstimationPrepareCrop=function(){return(t._xzimgPoseEstimationPrepareCrop=t.asm.xzimgPoseEstimationPrepareCrop).apply(null,arguments)},t._xzimgPoseEstimationEstimateFacePose=function(){return(t._xzimgPoseEstimationEstimateFacePose=t.asm.xzimgPoseEstimationEstimateFacePose).apply(null,arguments)},t._xzimgGetHeatmapsLocations=function(){return(t._xzimgGetHeatmapsLocations=t.asm.xzimgGetHeatmapsLocations).apply(null,arguments)},t._xzimgEstimateRigidPose=function(){return(t._xzimgEstimateRigidPose=t.asm.xzimgEstimateRigidPose).apply(null,arguments)},t._xzimgEstimateGetSimilarity=function(){return(t._xzimgEstimateGetSimilarity=t.asm.xzimgEstimateGetSimilarity).apply(null,arguments)},t._xzimgWarpAffine=function(){return(t._xzimgWarpAffine=t.asm.xzimgWarpAffine).apply(null,arguments)},t._xzimgMatchRecKeypsInit=function(){return(t._xzimgMatchRecKeypsInit=t.asm.xzimgMatchRecKeypsInit).apply(null,arguments)},t._xzimgMatchRecKeyps=function(){return(t._xzimgMatchRecKeyps=t.asm.xzimgMatchRecKeyps).apply(null,arguments)},t._xzimgEstimateInitNonRigidPose=function(){return(t._xzimgEstimateInitNonRigidPose=t.asm.xzimgEstimateInitNonRigidPose).apply(null,arguments)},t._xzimgEstimateNonRigidPose=function(){return(t._xzimgEstimateNonRigidPose=t.asm.xzimgEstimateNonRigidPose).apply(null,arguments)},t._xzimgEstimateBodyNonRigidPose=function(){return(t._xzimgEstimateBodyNonRigidPose=t.asm.xzimgEstimateBodyNonRigidPose).apply(null,arguments)},t._xzimgEstimateNonRigidPoseBase=function(){return(t._xzimgEstimateNonRigidPoseBase=t.asm.xzimgEstimateNonRigidPoseBase).apply(null,arguments)},t._xzimgEstimateGetNumVertices=function(){return(t._xzimgEstimateGetNumVertices=t.asm.xzimgEstimateGetNumVertices).apply(null,arguments)},t._xzimgEstimateGetDenseVertices=function(){return(t._xzimgEstimateGetDenseVertices=t.asm.xzimgEstimateGetDenseVertices).apply(null,arguments)},t.dynCall_jiji=function(){return(t.dynCall_jiji=t.asm.dynCall_jiji).apply(null,arguments)},t.dynCall_viijii=function(){return(t.dynCall_viijii=t.asm.dynCall_viijii).apply(null,arguments)},t.dynCall_iiiiij=function(){return(t.dynCall_iiiiij=t.asm.dynCall_iiiiij).apply(null,arguments)},t.dynCall_iiiiijj=function(){return(t.dynCall_iiiiijj=t.asm.dynCall_iiiiijj).apply(null,arguments)},t.dynCall_iiiiiijj=function(){return(t.dynCall_iiiiiijj=t.asm.dynCall_iiiiiijj).apply(null,arguments)},t.ccall=We,t.cwrap=function(e,n,r,a){var i=!r||r.every((e=>"number"===e||"boolean"===e));return"string"!==n&&i&&!a?t["_"+e]:function(){return We(e,n,r,arguments)}},t.setValue=function(e,t,n="i8"){switch(n.endsWith("*")&&(n="*"),n){case"i1":case"i8":h[e>>0]=t;break;case"i16":d[e>>1]=t;break;case"i32":f[e>>2]=t;break;case"i64":N=[t>>>0,(C=t,1<=+Math.abs(C)?0<C?(0|Math.min(+Math.floor(C/4294967296),4294967295))>>>0:~~+Math.ceil((C-+(~~C>>>0))/4294967296)>>>0:0)],f[e>>2]=N[0],f[e+4>>2]=N[1];break;case"float":g[e>>2]=t;break;case"double":y[e>>3]=t;break;case"*":m[e>>2]=t;break;default:O("invalid type for setValue: "+n)}},t.getValue=function(e,t="i8"){switch(t.endsWith("*")&&(t="*"),t){case"i1":case"i8":return h[e>>0];case"i16":return d[e>>1];case"i32":case"i64":return f[e>>2];case"float":return g[e>>2];case"double":return y[e>>3];case"*":return m[e>>2];default:O("invalid type for getValue: "+t)}},F=function e(){ze||Xe(),ze||(F=e)},t.preInit)for("function"==typeof t.preInit&&(t.preInit=[t.preInit]);0<t.preInit.length;)t.preInit.pop()();return Xe(),e.ready});let kT;!function(e){e[e.float32=0]="float32",e[e.int32=1]="int32",e[e.bool=2]="bool",e[e.string=3]="string",e[e.complex64=4]="complex64"}(vT||(vT={})),function(e){e[e.linear=0]="linear",e[e.relu=1]="relu",e[e.relu6=2]="relu6",e[e.prelu=3]="prelu",e[e.leakyrelu=4]="leakyrelu",e[e.sigmoid=5]="sigmoid",e[e.elu=6]="elu"}(wT||(wT={}));const TT={kernelName:Rr,backendName:"wasm",setupFunc:function(e){kT=e.wasm.cwrap(Rr,null,["number","array","number","number","array","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i,bias:s,preluActivationWeights:o}=t;if("float32"!==a.dtype||"float32"!==i.dtype)throw new Error("_FusedMatMul for non non-float32 tensors not yet supported.");const{transposeA:u,transposeB:l,activation:c,leakyreluAlpha:h}=r,p=n.dataIdMap.get(a.dataId).id,d=n.dataIdMap.get(i.dataId).id;let f=0;if(null!=s){const e=n.dataIdMap.get(s.dataId);if(1!==e.shape.length)throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${e.shape.length}.`);f=e.id}const m=null==o?0:n.dataIdMap.get(o.dataId).id,g=wT[c];if(null==g)throw new Error(`${c} activation not yet supported for FusedConv2D in the wasm backend.`);const y=u?a.shape[2]:a.shape[1],b=l?i.shape[1]:i.shape[2],v=Bo(a.shape.slice(0,-2),i.shape.slice(0,-2)),w=n.makeOutput([...v,y,b],a.dtype),_=n.dataIdMap.get(w.dataId).id,x=new Uint8Array(new Int32Array(a.shape).buffer),k=new Uint8Array(new Int32Array(i.shape).buffer);return kT(p,x,a.shape.length,d,k,i.shape.length,u,l,g,f,m,h||0,_),w}};function ET(e,t){let n;return{kernelName:e,backendName:"wasm",setupFunc:function(t){n=t.wasm.cwrap(e,null,["number","number","number"])},kernelFunc:function(e){const{backend:r,inputs:{x:a}}=e,i=r.dataIdMap.get(a.dataId).id,s=r.makeOutput(a.shape,t||a.dtype),o=r.dataIdMap.get(s.dataId).id;return 0===it(s.shape)||n(i,vT[a.dtype],o),s}}}const ST=ET("Abs");function IT(e,t,n){let r;return{kernelName:e,backendName:"wasm",setupFunc:function(t){r=t.wasm.cwrap(e,null,["number","array","number","number","array","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:a}=e,{a:i,b:s}=a,o=t.dataIdMap.get(i.dataId).id,u=t.dataIdMap.get(s.dataId).id,l=null!=n?n:i.dtype,c=Bo(i.shape,s.shape),h=t.makeOutput(c,l);if(0===it(c))return h;const p=new Uint8Array(new Int32Array(i.shape).buffer),d=new Uint8Array(new Int32Array(s.shape).buffer),f=t.dataIdMap.get(h.dataId).id;return r(o,p,i.shape.length,u,d,s.shape.length,vT[i.dtype],f),h}}}const AT=IT(Bt);let CT;const NT={kernelName:Ut,backendName:"wasm",setupFunc:function(e){CT=e.wasm.cwrap(Ut,null,["array","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n}=e,r=n.makeOutput(t[0].shape,t[0].dtype);if(0===it(r.shape))return r;const a=t.map((e=>n.dataIdMap.get(e.dataId).id)),i=new Uint8Array(new Int32Array(a).buffer),s=n.dataIdMap.get(r.dataId).id;return CT(i,a.length,vT[r.dtype],s),r}};function RT(e){const{inputs:{x:t},backend:n}=e;if("string"===t.dtype)return ws(n.readSync(t.dataId),t.shape,t.dtype);const r=n.makeOutput(t.shape,t.dtype),a=n.typedArrayFromHeap(t);return n.typedArrayFromHeap(r).set(a),r}const FT={kernelName:wn,backendName:"wasm",kernelFunc:RT};let OT;function MT(e){const{inputs:t,backend:n,attrs:r}=e,[a,i]=function(e,t){const n=[],r=[];for(let a=0;a<e.length;++a)1!==e[a]&&n.push(e[a]),1!==e[t[a]]&&r.push(t[a]);for(let e=0;e<r.length;++e){let t=-1;for(let n=0;n<r.length;++n)r[n]>=e&&(-1===t||r[t]>r[n])&&(t=n);r[t]=e}return[n,r]}(t.x.shape,r.perm);let s=!0;for(let e=0;e<i.length;e++)i[e]!==e&&(s=!1);const o=function(e,t){const n=new Array(e.length);for(let r=0;r<n.length;r++)n[r]=e[t[r]];return n}(t.x.shape,r.perm),u={dataId:t.x.dataId,shape:a,dtype:t.x.dtype};if(s){const e=RT({inputs:t,backend:n});return e.shape=o,e}const l=n.makeOutput(o,u.dtype),c=n.dataIdMap.get(u.dataId).id,h=n.dataIdMap.get(l.dataId).id,p=new Uint8Array(new Int32Array(i).buffer),d=new Uint8Array(new Int32Array(u.shape).buffer);return OT(c,d,u.shape.length,vT[u.dtype],h,p,i.length),l}const $T={kernelName:Er,backendName:"wasm",kernelFunc:MT,setupFunc:function(e){OT=e.wasm.cwrap(Er,null,["number","array","number","number","number","array","number"])}};function DT(e,t,n){const r=e.shape,a=e.shape.length,i=pt(t,r);let s=i;const o=Bl(s,a);let u=null,l=!1;if(null!=o){const t=new Array(a);for(let e=0;e<t.length;e++)t[e]=r[o[e]];s=Wl(s.length,a),u=MT({inputs:{x:e},attrs:{perm:o},backend:n});const i=n.dataIdMap.get(e.dataId).id;n.dataIdMap.get(u.dataId).id!==i&&(l=!0)}return{transposed:u,originalAxes:i,axes:s,inputWasTransposed:l}}let PT;const LT={kernelName:Wt,backendName:"wasm",setupFunc:function(e){PT=e.wasm.cwrap(Wt,null,["number, number, number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:i}=r,{x:s}=n;let o=t.dataIdMap.get(s.dataId).id,u=s;const{transposed:l,axes:c,originalAxes:h,inputWasTransposed:p}=DT(s,a,t);p&&(u=l,o=t.dataIdMap.get(l.dataId).id),Ll("all",c,u.shape.length);const[d,f]=Dl(u.shape,c),m=it(f),g=t.makeOutput(d,s.dtype);if(0!==it(u.shape)){const e=t.dataIdMap.get(g.dataId).id;PT(o,m,e)}if(p&&t.disposeData(l.dataId),i){const e=Pl(g.shape,h);g.shape=e}return g}};let BT;const UT={kernelName:Vt,backendName:"wasm",setupFunc:function(e){BT=e.wasm.cwrap(Vt,null,["number, number, number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:i}=r,{x:s}=n;let o=t.dataIdMap.get(s.dataId).id,u=s;const{transposed:l,axes:c,originalAxes:h,inputWasTransposed:p}=DT(s,a,t);p&&(u=l,o=t.dataIdMap.get(l.dataId).id),Ll("any",c,u.shape.length);const[d,f]=Dl(u.shape,c),m=it(f),g=t.makeOutput(d,s.dtype);if(0!==it(u.shape)){const e=t.dataIdMap.get(g.dataId).id;BT(o,m,e)}if(p&&t.disposeData(l.dataId),i){const e=Pl(g.shape,h);g.shape=e}return g}};let WT;const VT={kernelName:zt,backendName:"wasm",kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a}=r,{x:i}=n,s=t.dataIdMap.get(i.dataId).id;let o=s,u=i;const{transposed:l,axes:c,inputWasTransposed:h}=DT(i,a,t);if(h){const e=t.dataIdMap.get(l.dataId).id;e!==s&&(u=l,o=e)}const p=u.shape.slice(0,-1),d=t.makeOutput(p,"int32"),f=t.dataIdMap.get(d.dataId).id,m=it(d.shape),g=u.shape[c[0]];return WT(o,vT[u.dtype],m,g,f),h&&t.disposeData(l.dataId),d},setupFunc:function(e){WT=e.wasm.cwrap(zt,null,["number","number","number","number","number"])}};let zT;const jT={kernelName:jt,backendName:"wasm",setupFunc:function(e){zT=e.wasm.cwrap(jt,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,a=t.x,i=r.dataIdMap.get(a.dataId).id,{filterSize:s,strides:o,pad:u,dimRoundingMode:l}=n,c=Su(a.shape,s,o,1,u,l),h=c.filterHeight,p=c.filterWidth,d=c.padInfo.top,f=c.padInfo.right,m=c.padInfo.bottom,g=c.padInfo.left,y=c.strideHeight,b=c.strideWidth,v=c.inChannels;if("channelsLast"!==c.dataFormat)throw new Error(`wasm backend does not support dataFormat:'${c.dataFormat}'. Please use 'channelsLast'.`);if(1!==c.dilationWidth||1!==c.dilationHeight)throw new Error(`was backend only supports average pooling with dilation = [1, 1], got [${c.dilationHeight}, ${c.dilationWidth}].`);const w=r.makeOutput(c.outShape,"float32"),_=r.dataIdMap.get(w.dataId).id;return zT(i,a.shape[0],a.shape[1],a.shape[2],h,p,d,f,m,g,y,b,v,_),w}};function GT(e){const{inputs:t,attrs:n}=e,{x:r}=t,{shape:a}=n,i=it(r.shape),s=ht(a,i);return nt(i===it(s),(()=>`new shape: ${s}, old shape: ${r.shape}. New shape and old shape must have the same number of elements.`)),e.backend.incRef(r.dataId),{dataId:r.dataId,shape:s,dtype:r.dtype}}const HT={kernelName:Xn,backendName:"wasm",kernelFunc:GT};let KT;const qT={kernelName:Gt,backendName:"wasm",setupFunc:function(e){KT=e.wasm.cwrap(Gt,null,["number","array","number","number","array","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{a,b:i}=t,{transposeA:s,transposeB:o}=r;if("float32"!==a.dtype||"float32"!==i.dtype)throw new Error("BatchMatMul for non non-float32 tensors not yet supported.");const u=a.shape.length,l=i.shape.length,c=s?a.shape[u-2]:a.shape[u-1],h=o?i.shape[l-1]:i.shape[l-2],p=s?a.shape[u-1]:a.shape[u-2],d=o?i.shape[l-2]:i.shape[l-1],f=a.shape.slice(0,-2),m=i.shape.slice(0,-2),g=it(f),y=it(m),b=Bo(a.shape.slice(0,-2),i.shape.slice(0,-2)).concat([p,d]);nt(c===h,(()=>`Error in matMul: inner shapes (${c}) and (${h}) of Tensors with shapes ${a.shape} and ${i.shape} and transposeA=${s} and transposeB=${o} must match.`));const v=o?[y,d,h]:[y,h,d],w=GT({inputs:{x:a},backend:n,attrs:{shape:s?[g,c,p]:[g,p,c]}}),_=GT({inputs:{x:i},backend:n,attrs:{shape:v}}),x=n.dataIdMap.get(w.dataId).id,k=n.dataIdMap.get(_.dataId).id,T=s?w.shape[2]:w.shape[1],E=o?_.shape[1]:_.shape[2],S=Math.max(g,y),I=n.makeOutput([S,T,E],w.dtype),A=n.dataIdMap.get(I.dataId).id,C=new Uint8Array(new Int32Array(w.shape).buffer),N=new Uint8Array(new Int32Array(_.shape).buffer);return KT(x,C,w.shape.length,k,N,_.shape.length,s,o,A),n.disposeData(w.dataId),n.disposeData(_.dataId),I.shape=b,I}};function XT(e){const{inputs:{x:t},attrs:{begin:n,size:r},backend:a}=e,[i,s]=iu(t,n,r),o=ru(t.shape,i,s),u=a.readSync(t.dataId),l=a.makeOutput(s,t.dtype),c=xt(t.shape),h=a.dataIdMap.get(l.dataId);if(o){const e=au(i,c);return"string"===t.dtype?h.stringBytes=u.slice(e,e+it(s)):a.typedArrayFromHeap(l).set(u.subarray(e,e+it(s))),l}if("string"===t.dtype){const e=_g(u,i,s,t.shape,t.dtype);return h.stringBytes=e,l}const p=a.typedArrayFromHeap(l),d=t.shape.length;if(2===d)!function(e,t,n,r,a){let i=0;const s=r[0],o=r[1],u=s+a[0];for(let r=s;r<u;r++){const s=r*t+o;n.set(e.subarray(s,s+a[1]),i),i+=a[1]}}(u,c[0],p,i,s);else if(3===d)!function(e,t,n,r,a,i){let s=0;const o=a[0],u=a[1],l=a[2],c=o+i[0],h=u+i[1];for(let a=o;a<c;a++)for(let o=u;o<h;o++){const u=a*t+o*n+l;r.set(e.subarray(u,u+i[2]),s),s+=i[2]}}(u,c[0],c[1],p,i,s);else if(4===d)!function(e,t,n,r,a,i,s){let o=0;const u=i[0],l=i[1],c=i[2],h=u+s[0],p=l+s[1],d=c+s[2],f=i[3];for(let i=u;i<h;i++)for(let u=l;u<p;u++)for(let l=c;l<d;l++){const c=i*t+u*n+l*r+f;a.set(e.subarray(c,c+s[3]),o),o+=s[3]}}(u,c[0],c[1],c[2],p,i,s);else{const e=_g(u,i,s,t.shape,t.dtype);p.set(e)}return l}const YT={kernelName:ar,backendName:"wasm",kernelFunc:XT},QT={kernelName:Ht,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,crops:s}=r,o=i.reduce(((e,t)=>e*t)),u=Fd(a.shape,i,o),l=Od(u.length,i.length),c=Md(a.shape,i,o),h=$d(s,i.length),p=Dd(c,s,i.length),d=GT({inputs:{x:a},backend:n,attrs:{shape:u}}),f=MT({inputs:{x:d},backend:n,attrs:{perm:l}}),m=XT({inputs:{x:GT({inputs:{x:f},backend:n,attrs:{shape:c}})},backend:n,attrs:{begin:h,size:p}});return n.disposeData(d.dataId),n.disposeData(f.dataId),n.disposeData(d.dataId),m}};function JT(e){const{inputs:{x:t},attrs:{dtype:n},backend:r}=e,a=r.makeOutput(t.shape,n),i=r.typedArrayFromHeap(t);return r.typedArrayFromHeap(a).set(i),a}const ZT={kernelName:Kt,backendName:"wasm",kernelFunc:JT},eE=ET(qt);let tE;const nE={kernelName:Xt,backendName:"wasm",setupFunc:function(e){tE=e.wasm.cwrap(Xt,null,["number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{clipValueMin:i,clipValueMax:s}=r,o=n.dataIdMap.get(a.dataId).id,u=n.makeOutput(a.shape,a.dtype),l=n.dataIdMap.get(u.dataId).id;return tE(o,i,s,l),u}};function rE(e){const{inputs:t,backend:n}=e,r=pt(e.attrs.axis,t[0].shape)[0];xd(t.map((e=>e.shape)),r);let a=kd(t.map((e=>e.shape)),r);const i=t.filter((e=>it(e.shape)>0));if(1===i.length)return RT({inputs:{x:i[0]},backend:n});const s=n.makeOutput(a,t[0].dtype);if(0===it(a))return s;if("string"===i[0].dtype){const e=i.map((e=>{const t=it(e.shape.slice(r));return GT({inputs:{x:e},backend:n,attrs:{shape:[-1,t]}})})),o=e.map((e=>({vals:n.readSync(e.dataId),shape:e.shape})));a=kd(e.map((e=>e.shape)),1);const u=1===e[0].shape[0],l=Vm(o,a,t[0].dtype,u),c=kd(i.map((e=>e.shape)),r);return s.shape=c,n.dataIdMap.get(s.dataId).stringBytes=Zd(l),e.forEach((e=>n.disposeData(e.dataId))),s}const o=it(i[0].shape.slice(0,r));let u=0;const l=i.map((e=>{const t=it(e.shape.slice(r));return u+=t,t})),c=i.map((e=>n.typedArrayFromHeap(e))),h=n.typedArrayFromHeap(s);for(let e=0;e<o;e++){let t=e*u;for(let n=0;n<c.length;n++){const r=l[n],a=e*r,i=c[n].subarray(a,a+r);h.set(i,t),t+=r}}return s}const aE={kernelName:Yt,backendName:"wasm",kernelFunc:rE};let iE;const sE={kernelName:Qt,backendName:"wasm",setupFunc:function(e){iE=e.wasm.cwrap(Qt,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a,filter:i}=t,s=r.dataIdMap.get(a.dataId).id,o=r.dataIdMap.get(i.dataId).id,{strides:u,dilations:l,pad:c,dimRoundingMode:h,dataFormat:p}=n,d=Pu(p),f=Iu(a.shape,i.shape,u,l,c,h,!1,d),m=f.filterHeight,g=f.filterWidth,y=f.padInfo.top,b=f.padInfo.right,v=f.padInfo.bottom,w=f.padInfo.left,_=f.dilationHeight,x=f.dilationWidth,k=f.strideHeight,T=f.strideWidth,E=f.inChannels,S=f.outChannels,I="SAME"===f.padInfo.type?1:0;if("channelsLast"!==f.dataFormat)throw new Error(`wasm backend Conv2D does not support dataFormat:'${f.dataFormat}'. Please use 'channelsLast'.`);const A=r.makeOutput(f.outShape,"float32"),C=r.dataIdMap.get(A.dataId).id;return iE(s,a.shape[0],a.shape[1],a.shape[2],o,m,g,y,b,v,w,I,_,x,k,T,E,S,C),A}};let oE;const uE={kernelName:Jt,backendName:"wasm",setupFunc:function(e){oE=e.wasm.cwrap(Jt,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{dy:a,filter:i}=n,{strides:s,pad:o,dataFormat:u,dimRoundingMode:l,inputShape:c}=r,h=Pu(u),p=Iu(c,i.shape,s,1,o,l,!1,h),{batchSize:d,filterHeight:f,filterWidth:m,inChannels:g,inHeight:y,inWidth:b,outChannels:v,outHeight:w,outWidth:_,strideHeight:x,strideWidth:k}=p,T=f-1-p.padInfo.top,E=m-1-p.padInfo.left,S="channelsLast"===p.dataFormat,I=xt(p.inShape),A=xt(a.shape),[C,N,R]=xt(i.shape),F=I[0],O=S?I[1]:I[2],M=S?I[2]:1,$=S?1:I[1],D=A[0],P=S?A[1]:A[2],L=S?A[2]:1,B=S?1:A[1],U=t.makeOutput(p.inShape,"float32"),W=t.dataIdMap.get(U.dataId).id,V=t.dataIdMap.get(a.dataId).id,z=t.dataIdMap.get(i.dataId).id;return oE(V,z,d,f,m,y,b,g,w,_,v,x,k,T,E,C,N,R,F,O,M,$,D,P,L,B,W),U}},lE=ET("Cos"),cE=ET(Zt);var hE;let pE;!function(e){e[e.bilinear=0]="bilinear",e[e.nearest=1]="nearest"}(hE||(hE={}));const dE={kernelName:nn,backendName:"wasm",setupFunc:function(e){pE=e.wasm.cwrap(nn,null,["number","number","number","number","array","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{method:a,extrapolationValue:i,cropSize:s}=r,{image:o,boxes:u,boxInd:l}=n,c=u.shape[0],[h,p]=s,d=[c,h,p,o.shape[3]];let f,m=t.dataIdMap.get(o.dataId);"float32"!==o.dtype&&(f=JT({backend:t,inputs:{x:o},attrs:{dtype:"float32"}}),m=t.dataIdMap.get(f.dataId));const g=m.id,y=t.dataIdMap.get(u.dataId).id,b=t.dataIdMap.get(l.dataId).id,v=t.makeOutput(d,"float32"),w=t.dataIdMap.get(v.dataId).id,_=new Uint8Array(new Int32Array(o.shape).buffer);return pE(g,y,b,c,_,h,p,hE[a],i,w),null!=f&&t.disposeData(f.dataId),v}};let fE;const mE={kernelName:en,backendName:"wasm",setupFunc:function(e){fE=e.wasm.cwrap(en,null,["number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,exclusive:s,reverse:o}=r,u=a.shape.length;nt("float32"===a.dtype||"int32"===a.dtype,(()=>`cumprod does not support ${a.dtype} tensors in the WASM backend`));const l=Bl([i],u);let c=a;null!==l&&(c=MT({inputs:{x:a},attrs:{perm:l},backend:n}));const h=Wl(1,u)[0];Ll("cumprod",[h],u);const p=n.makeOutput(c.shape,c.dtype),d=c.shape[h],f=n.dataIdMap.get(c.dataId).id,m=n.dataIdMap.get(p.dataId).id;fE(f,s?1:0,o?1:0,d,m,vT[a.dtype]);let g=p;return null!==l&&(g=MT({inputs:{x:p},attrs:{perm:Ul(l)},backend:n}),n.disposeData(c.dataId),n.disposeData(p.dataId)),g}};let gE;const yE={kernelName:tn,backendName:"wasm",setupFunc:function(e){gE=e.wasm.cwrap(tn,null,["number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{axis:i,exclusive:s,reverse:o}=r,u=a.shape.length;nt("float32"===a.dtype||"int32"===a.dtype,(()=>`cumsum does not support ${a.dtype} tensors in the WASM backend`));const l=Bl([i],u);let c=a;null!==l&&(c=MT({inputs:{x:a},attrs:{perm:l},backend:n}));const h=Wl(1,u)[0];Ll("cumsum",[h],u);const p=n.makeOutput(c.shape,c.dtype),d=c.shape[h],f=n.dataIdMap.get(c.dataId).id,m=n.dataIdMap.get(p.dataId).id;gE(f,s?1:0,o?1:0,d,m,vT[a.dtype]);let g=p;return null!==l&&(g=MT({inputs:{x:p},attrs:{perm:Ul(l)},backend:n}),n.disposeData(c.dataId),n.disposeData(p.dataId)),g}};let bE;const vE={kernelName:rn,backendName:"wasm",setupFunc:function(e){bE=e.wasm.cwrap(rn,null,["number","number","number","array","number","array","array","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{x:a}=n,{blockSize:i,dataFormat:s}=r,o=a.shape[0],u=("NHWC"===s?a.shape[1]:a.shape[2])*i,l=("NHWC"===s?a.shape[2]:a.shape[3])*i,c=("NHWC"===s?a.shape[3]:a.shape[1])/(i*i),h="NHWC"===s?[o,u,l,c]:[o,c,u,l],p=t.makeOutput(h,"float32"),d=t.dataIdMap.get(a.dataId).id,f=new Uint8Array(new Int32Array(xt(a.shape)).buffer),m=new Uint8Array(new Int32Array(h).buffer),g=new Uint8Array(new Int32Array(xt(h)).buffer),y=t.dataIdMap.get(p.dataId).id;return bE(d,i,"NHWC"===s?1:0,f,a.shape.length-1,m,g,h.length,y),p}};let wE;const _E={kernelName:an,backendName:"wasm",setupFunc:function(e){wE=e.wasm.cwrap(an,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a,filter:i}=t,s=r.dataIdMap.get(a.dataId).id,o=r.dataIdMap.get(i.dataId).id,{strides:u,dilations:l,pad:c,dimRoundingMode:h}=n,p=null==l?[1,1]:l,d=Iu(a.shape,i.shape,u,p,c,h,!0),f=d.filterHeight,m=d.filterWidth,g=d.padInfo.top,y=d.padInfo.right,b=d.padInfo.bottom,v=d.padInfo.left,w=d.dilationHeight,_=d.dilationWidth,x=d.strideHeight,k=d.strideWidth,T=d.inChannels,E=d.outChannels,S="SAME"===d.padInfo.type?1:0;if("channelsLast"!==d.dataFormat)throw new Error(`wasm backend DepthwiseConv2dNative does not support dataFormat:'${d.dataFormat}'. Please use 'channelsLast'.`);const I=r.makeOutput(d.outShape,"float32"),A=r.dataIdMap.get(I.dataId).id;return wE(s,a.shape[0],a.shape[1],a.shape[2],o,f,m,g,y,b,v,S,w,_,x,k,T,E,A),I}},xE=ET(on),kE=IT(un,0,"bool"),TE=ET(ln,"float32");function EE(e){const{inputs:t,attrs:n,backend:r}=e,{input:a}=t,{dim:i}=n,s=a.shape.length,o=a.shape.slice();let u=i;return i<0&&(nt(-(s+1)<=i,(()=>`Axis must be in the interval [${-(s+1)}, ${s}]`)),u=s+i+1),o.splice(u,0,1),GT({inputs:{x:a},backend:r,attrs:{shape:o}})}const SE={kernelName:cn,backendName:"wasm",kernelFunc:EE};function IE(e){const{attrs:{shape:t,value:n,dtype:r},backend:a}=e,i=a.makeOutput(t,r);return a.typedArrayFromHeap(i).fill(n),i}const AE={kernelName:hn,backendName:"wasm",kernelFunc:IE};let CE;const NE={kernelName:pn,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n}=e,{image:r}=t,a=n.makeOutput(r.shape,r.dtype),i=n.dataIdMap.get(r.dataId).id,s=n.dataIdMap.get(a.dataId).id,[o,u,l,c]=r.shape;return CE(i,o,u,l,c,s),a},setupFunc:function(e){CE=e.wasm.cwrap(pn,null,["number","number","number","number","number","number"])}},RE=ET(dn),FE=IT(fn);let OE;const ME={kernelName:mn,backendName:"wasm",setupFunc:function(e){OE=e.wasm.cwrap(mn,null,["number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{varianceEpsilon:a}=r,{x:i,mean:s,variance:o,offset:u,scale:l}=n,c=t.dataIdMap.get(i.dataId).id,h=t.dataIdMap.get(s.dataId).id,p=t.dataIdMap.get(o.dataId).id,d=null!=u?t.dataIdMap.get(u.dataId).id:0,f=null!=l?t.dataIdMap.get(l.dataId).id:0,m=t.makeOutput(i.shape,i.dtype);if(0===it(i.shape))return m;const g=t.dataIdMap.get(m.dataId).id;return OE(c,h,p,d,f,a,g),m}};let $E;const DE={kernelName:Fr,backendName:"wasm",setupFunc:function(e){$E=e.wasm.cwrap(Fr,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dilations:c,dataFormat:h,dimRoundingMode:p,activation:d,leakyreluAlpha:f}=n,m=Iu(a.shape,i.shape,u,c,l,p),g=wT[d];if(null==g)throw new Error(`${d} activation not yet supported for FusedConv2D in the wasm backend.`);const y=r.dataIdMap.get(a.dataId).id,b=r.dataIdMap.get(i.dataId).id,v=m.outChannels;let w=0;if(null!=s){const e=r.dataIdMap.get(s.dataId);if(1!==e.shape.length)throw new Error(`FusedConv2D only supports rank-1 bias but got rank ${e.shape.length}.`);if(e.shape[0]!==v)throw new Error(`FusedConv2D bias shape (${e.shape}) does not match the number of output channels (${v})`);w=e.id}const _=m.filterHeight,x=m.filterWidth,k=m.padInfo.top,T=m.padInfo.right,E=m.padInfo.bottom,S=m.padInfo.left,I=m.dilationHeight,A=m.dilationWidth,C=m.strideHeight,N=m.strideWidth,R=m.inChannels,F="SAME"===m.padInfo.type?1:0,O=m.batchSize,M=m.inHeight,$=m.inWidth;if("NHWC"!==h)throw new Error(`wasm backend FusedConv2D does not support dataFormat:'${h}'. Please use 'NHWC'.`);const D=r.makeOutput(m.outShape,"float32"),P=r.dataIdMap.get(D.dataId).id,L=null==o?0:r.dataIdMap.get(o.dataId).id;return $E(y,O,M,$,b,_,x,w,k,T,E,S,F,I,A,C,N,R,v,g,L,f||0,P),D}};let PE;const LE={kernelName:Or,backendName:"wasm",setupFunc:function(e){PE=e.wasm.cwrap(Or,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a,filter:i,bias:s,preluActivationWeights:o}=t,{strides:u,pad:l,dilations:c,dataFormat:h,dimRoundingMode:p,activation:d,leakyreluAlpha:f}=n,m=Iu(a.shape,i.shape,u,c,l,p,!0),g=wT[d];if(null==g)throw new Error(`${d} activation not yet supported for FusedDepthwiseConv2D in the wasm backend.`);const y=r.dataIdMap.get(a.dataId).id,b=r.dataIdMap.get(i.dataId).id,v=m.outChannels;let w=0;if(null!=s){const e=r.dataIdMap.get(s.dataId);if(1!==e.shape.length)throw new Error(`FusedDepthwiseConv2D only supports rank-1 bias but got rank ${e.shape.length}.`);if(e.shape[0]!==v)throw new Error(`FusedDepthwiseConv2D bias shape (${e.shape}) does not match the number of output channels (${v})`);w=e.id}const _=m.filterHeight,x=m.filterWidth,k=m.padInfo.top,T=m.padInfo.right,E=m.padInfo.bottom,S=m.padInfo.left,I=m.dilationHeight,A=m.dilationWidth,C=m.strideHeight,N=m.strideWidth,R=m.inChannels,F="SAME"===m.padInfo.type?1:0,O=m.batchSize,M=m.inHeight,$=m.inWidth;if("NHWC"!==h)throw new Error(`wasm backend FusedDepthwiseConv2D does not support dataFormat:'${h}'. Please use 'NHWC'.`);const D=r.makeOutput(m.outShape,"float32"),P=r.dataIdMap.get(D.dataId).id,L=null==o?0:r.dataIdMap.get(o.dataId).id;return PE(y,O,M,$,b,_,x,w,k,T,E,S,F,I,A,C,N,R,v,g,L,f||0,P),D}};let BE;const UE={kernelName:yn,backendName:"wasm",setupFunc:function(e){BE=e.wasm.cwrap(yn,null,["number","number","number","number","number","number","array","number"])},kernelFunc:function(e){const{backend:t,inputs:n}=e,{params:r,indices:a}=n,[i,s,o,u]=zo(r,a),l=t.makeOutput(i,r.dtype);if(0===s)return l;const c=a.shape,h=c[c.length-1],p=t.dataIdMap.get(r.dataId).id,d=t.dataIdMap.get(a.dataId).id,f=new Uint8Array(new Int32Array(u).buffer),m=t.dataIdMap.get(l.dataId).id;return BE(p,vT[r.dtype],d,s,h,o,f,m),l}};let WE;const VE={kernelName:gn,backendName:"wasm",setupFunc:function(e){WE=e.wasm.cwrap("Gather",null,["number","number","array","number","number","number","array","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{x:a,indices:i}=n,{axis:s,batchDims:o}=r,u=pt(s,a.shape)[0],l=t.readSync(i.dataId),c=a.shape[u];for(let e=0;e<l.length;++e){const t=l[e];nt(t<=c-1&&t>=0,(()=>`GatherV2: the index value ${t} is not in [0, ${c-1}]`))}const h=Yd(a,i,u,o),p=GT({inputs:{x:a},attrs:{shape:[h.batchSize,h.outerSize,h.dimSize,h.sliceSize]},backend:t}),d=it(i.shape),f=GT({inputs:{x:i},attrs:{shape:[h.batchSize,d/h.batchSize]},backend:t}),m=[h.batchSize,h.outerSize,d/h.batchSize,h.sliceSize],g=t.makeOutput(m,a.dtype);if(0===it(a.shape))return g;const y=p.shape.length-1,b=t.dataIdMap.get(p.dataId).id,v=t.dataIdMap.get(f.dataId).id,w=t.dataIdMap.get(g.dataId).id,_=new Uint8Array(new Int32Array(xt(p.shape)).buffer),x=new Uint8Array(new Int32Array(xt(m)).buffer);return WE(b,vT[a.dtype],_,y,v,h.batchSize,x,w),t.disposeData(p.dataId),t.disposeData(f.dataId),g.shape=h.outputShape,g}},zE=IT(bn,0,"bool"),jE=IT(vn,0,"bool"),GE=ET(_n,"bool");let HE;const KE={kernelName:xn,backendName:"wasm",setupFunc:function(e){HE=e.wasm.cwrap(xn,null,["number","number","number","number"])},kernelFunc:function(e){const{inputs:{x:t},attrs:{alpha:n},backend:r}=e,a=r.dataIdMap.get(t.dataId).id,i=r.makeOutput(t.shape,"float32");if(0!==it(t.shape)){const e=r.dataIdMap.get(i.dataId).id;HE(a,vT[t.dtype],n,e)}return i}},qE=IT(kn,0,"bool"),XE=IT(Tn,0,"bool"),YE=ET("Log"),QE=IT(En,0,"bool"),JE=ET(Sn),ZE=IT(In,0,"bool"),eS=IT("LogicalXor",0,"bool");let tS;const nS={kernelName:An,backendName:"wasm",setupFunc:function(e){tS=e.wasm.cwrap(An,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{reductionIndices:a,keepDims:i}=r,{x:s}=n;let o=t.dataIdMap.get(s.dataId).id,u=s;const{transposed:l,axes:c,originalAxes:h,inputWasTransposed:p}=DT(s,a,t);p&&(u=l,o=t.dataIdMap.get(l.dataId).id),Ll("max",c,u.shape.length);const[d,f]=Dl(u.shape,c),m=it(f),g=t.makeOutput(d,s.dtype);if(0!==it(u.shape)){const e=t.dataIdMap.get(g.dataId).id;tS(o,vT[s.dtype],m,e)}if(p&&t.disposeData(l.dataId),i){const e=Pl(g.shape,h);g.shape=e}return g}},rS=IT(Cn);let aS;const iS={kernelName:Nn,backendName:"wasm",setupFunc:function(e){aS=e.wasm.cwrap(Nn,null,["number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,a=t.x,i=r.dataIdMap.get(a.dataId).id;nt("float32"===a.dtype,(()=>`Error in MaxPool: only float32 input is supported. Got ${a.dtype}.`));const{filterSize:s,strides:o,pad:u,dimRoundingMode:l}=n,c=Su(a.shape,s,o,1,u,l),h=c.filterHeight,p=c.filterWidth,d=c.padInfo.top,f=c.padInfo.right,m=c.padInfo.bottom,g=c.padInfo.left,y=c.dilationHeight,b=c.dilationWidth,v=c.strideHeight,w=c.strideWidth,_=c.inChannels,x=c.outChannels;if("channelsLast"!==c.dataFormat)throw new Error(`wasm backend does not support dataFormat:'${c.dataFormat}'. Please use 'channelsLast'.`);const k=r.makeOutput(c.outShape,"float32"),T=r.dataIdMap.get(k.dataId).id;return aS(i,a.shape[0],a.shape[1],a.shape[2],h,p,d,f,m,g,y,b,v,w,_,x,T),k}};let sS;const oS={kernelName:Rn,backendName:"wasm",setupFunc:function(e){sS=e.wasm.cwrap(Rn,null,["number, number, number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:i}=r,{x:s}=n,o=t.dataIdMap.get(s.dataId).id;let u=o,l=s;const{transposed:c,axes:h,originalAxes:p,inputWasTransposed:d}=DT(s,a,t);let f=h;if(d){const e=t.dataIdMap.get(c.dataId).id;e!==o&&(l=c,u=e,f=Wl(f.length,l.shape.length))}Ll("mean",f,l.shape.length);const[m,g]=Dl(l.shape,f),y=it(g);let b=l;"float32"!==l.dtype&&(b=JT({backend:t,inputs:{x:l},attrs:{dtype:"float32"}}),u=t.dataIdMap.get(b.dataId).id);const v=t.makeOutput(m,"float32");if(0!==it(l.shape)){const e=t.dataIdMap.get(v.dataId).id;sS(u,y,e)}if(d&&t.disposeData(c.dataId),i){const e=Pl(v.shape,p);v.shape=e}return"float32"!==l.dtype&&t.disposeData(b.dataId),v}};let uS;const lS={kernelName:Fn,backendName:"wasm",setupFunc:function(e){uS=e.wasm.cwrap(Fn,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:i}=r,{x:s}=n,o=t.dataIdMap.get(s.dataId).id;let u=o,l=s;const{transposed:c,axes:h,originalAxes:p,inputWasTransposed:d}=DT(s,a,t);if(d){const e=t.dataIdMap.get(c.dataId).id;e!==o&&(l=c,u=e)}Ll("min",h,l.shape.length);const[f,m]=Dl(l.shape,h),g=it(m),y=t.makeOutput(f,l.dtype);if(0!==it(l.shape)){const e=t.dataIdMap.get(y.dataId).id;uS(u,vT[s.dtype],g,e)}if(d&&t.disposeData(c.dataId),i){const e=Pl(y.shape,p);y.shape=e}return y}},cS=IT(On);var hS;let pS;!function(e){e[e.reflect=0]="reflect",e[e.symmetric=1]="symmetric"}(hS||(hS={}));const dS={kernelName:Mn,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n,attrs:{paddings:r,mode:a}}=e,i=r.map(((e,n)=>e[0]+t.shape[n]+e[1])),s=n.dataIdMap.get(t.dataId).id,o=n.makeOutput(i,t.dtype),u=n.dataIdMap.get(o.dataId).id,l=new Uint8Array(new Int32Array(t.shape).buffer),c=r.map((e=>e[0])),h=r.map((e=>e[1])),p=new Uint8Array(new Int32Array(c).buffer),d=new Uint8Array(new Int32Array(h).buffer);return pS(s,l,t.shape.length,vT[t.dtype],p,d,hS[a],u),o},setupFunc:function(e){pS=e.wasm.cwrap(Mn,null,["number","array","number","number","array","array","number","number"])}},fS=IT($n),mS=ET("Neg");function gS(e,t){const n=new Int32Array(e.wasm.HEAPU8.buffer,t,4),r=n[0],a=n[1],i=n[2],s=n[3];return e.wasm._free(t),{pSelectedIndices:r,selectedSize:a,pSelectedScores:i,pValidOutputs:s}}let yS;const bS={kernelName:Pn,backendName:"wasm",setupFunc:function(e){yS=e.wasm.cwrap(Pn,"number",["number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{iouThreshold:a,maxOutputSize:i,scoreThreshold:s}=r,{boxes:o,scores:u}=n,l=t.dataIdMap.get(o.dataId).id,c=t.dataIdMap.get(u.dataId).id,h=yS(l,c,i,a,s),{pSelectedIndices:p,selectedSize:d,pSelectedScores:f,pValidOutputs:m}=gS(t,h);return t.wasm._free(f),t.wasm._free(m),t.makeOutput([d],"int32",p)}};let vS;const wS={kernelName:Ln,backendName:"wasm",setupFunc:function(e){vS=e.wasm.cwrap(Ln,"number",["number","number","number","number","number","bool"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{iouThreshold:a,maxOutputSize:i,scoreThreshold:s,padToMaxOutputSize:o}=r,{boxes:u,scores:l}=n,c=t.dataIdMap.get(u.dataId).id,h=t.dataIdMap.get(l.dataId).id,p=vS(c,h,i,a,s,o),{pSelectedIndices:d,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=gS(t,p);return t.wasm._free(m),[t.makeOutput([f],"int32",d),t.makeOutput([],"int32",g)]}};let _S;const xS={kernelName:Bn,backendName:"wasm",setupFunc:function(e){_S=e.wasm.cwrap(Bn,"number",["number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{iouThreshold:a,maxOutputSize:i,scoreThreshold:s,softNmsSigma:o}=r,{boxes:u,scores:l}=n,c=t.dataIdMap.get(u.dataId).id,h=t.dataIdMap.get(l.dataId).id,p=_S(c,h,i,a,s,o),{pSelectedIndices:d,selectedSize:f,pSelectedScores:m,pValidOutputs:g}=gS(t,p);return t.wasm._free(g),[t.makeOutput([f],"int32",d),t.makeOutput([f],"float32",m)]}},kS=IT(Dn,0,"bool");let TS;const ES={kernelName:Wn,backendName:"wasm",setupFunc:function(e){TS=e.wasm.cwrap(Wn,null,["number","number","number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{indices:a}=t,{dtype:i,depth:s,onValue:o,offValue:u}=r,l=n.makeOutput([...a.shape,s],i),c=n.dataIdMap.get(l.dataId).id,h=n.dataIdMap.get(a.dataId).id;return TS(h,s,o,u,c),l}},SS={kernelName:Un,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(r).fill(1),r}},IS={kernelName:Vn,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{axis:a}=r;if(1===t.length)return EE({inputs:{input:t[0]},backend:n,attrs:{dim:a}});const i=t[0].shape,s=t[0].dtype;t.forEach((e=>{rt(i,e.shape,"All tensors passed to stack must have matching shapes"),nt(s===e.dtype,(()=>"All tensors passed to stack must have matching dtypes"))}));const o=[],u=rE({inputs:t.map((e=>{const t=EE({inputs:{input:e},backend:n,attrs:{dim:a}});return o.push(t),t})),backend:n,attrs:{axis:a}});return o.forEach((e=>n.disposeData(e.dataId))),u}};let AS;const CS={kernelName:zn,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n,attrs:{paddings:r,constantValue:a}}=e,i=r.map(((e,n)=>e[0]+t.shape[n]+e[1]));if(0===it(t.shape))return IE({backend:n,attrs:{shape:i,value:a,dtype:t.dtype}});const s=n.dataIdMap.get(t.dataId).id,o=n.makeOutput(i,t.dtype),u=n.dataIdMap.get(o.dataId).id,l=new Uint8Array(new Int32Array(t.shape).buffer),c=r.map((e=>e[0])),h=r.map((e=>e[1])),p=new Uint8Array(new Int32Array(c).buffer),d=new Uint8Array(new Int32Array(h).buffer);return AS(s,l,t.shape.length,vT[t.dtype],p,d,a,u),o},setupFunc:function(e){AS=e.wasm.cwrap(zn,null,["number","array","number","number","array","array","number","number"])}},NS=IT("Pow");let RS;const FS={kernelName:jn,backendName:"wasm",setupFunc:function(e){RS=e.wasm.cwrap(jn,null,["number","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n}=e,{x:r,alpha:a}=t,i=n.dataIdMap.get(r.dataId).id,s=n.dataIdMap.get(a.dataId).id;let o=i;const u=r;let l=u;"float32"!==u.dtype&&(l=JT({backend:n,inputs:{x:r},attrs:{dtype:"float32"}}),o=n.dataIdMap.get(l.dataId).id);const c=n.makeOutput(r.shape,"float32"),h=n.dataIdMap.get(c.dataId).id;return RS(o,s,h),"float32"!==u.dtype&&n.disposeData(l.dataId),c}};let OS;const MS={kernelName:Gn,backendName:"wasm",setupFunc:function(e){OS=e.wasm.cwrap(Gn,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:i}=r,{x:s}=n,o=t.dataIdMap.get(s.dataId).id;let u=o,l=s;const{transposed:c,axes:h,originalAxes:p,inputWasTransposed:d}=DT(s,a,t);let f=h;if(d){const e=t.dataIdMap.get(c.dataId).id;e!==o&&(l=c,u=e,f=Wl(f.length,l.shape.length))}Ll("prod",f,l.shape.length);const[m,g]=Dl(l.shape,f),y=it(g),b=t.makeOutput(m,l.dtype);if(0!==it(l.shape)){const e=t.dataIdMap.get(b.dataId).id;OS(u,y,vT[b.dtype],e)}if(d&&t.disposeData(c.dataId),i){const e=Pl(b.shape,p);b.shape=e}return b}},$S={kernelName:Hn,backendName:"wasm",kernelFunc:e=>{const{backend:t,attrs:n}=e,{start:r,stop:a,step:i,dtype:s}=n,o=gg(r,a,i,s),u=t.makeOutput([o.length],s);return t.typedArrayFromHeap(u).set(o),u}},DS=IT(sn),PS=ET(Kn),LS=ET(qn),BS=ET(Jn);let US;const WS={kernelName:Qn,backendName:"wasm",setupFunc:function(e){US=e.wasm.cwrap(Qn,null,["number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{images:a}=n,{alignCorners:i,halfPixelCenters:s,size:o}=r,[u,l]=o,[c,h,p,d]=a.shape,f=[c,u,l,d];let m,g=t.dataIdMap.get(a.dataId);"float32"!==g.dtype&&(m=JT({backend:t,inputs:{x:a},attrs:{dtype:"float32"}}),g=t.dataIdMap.get(m.dataId));const y=g.id,b=t.makeOutput(f,"float32");if(0===it(a.shape))return b;const v=t.dataIdMap.get(b.dataId).id;return US(y,c,h,p,d,u,l,i?1:0,s?1:0,v),null!=m&&t.disposeData(m.dataId),b}};let VS;const zS={kernelName:Yn,backendName:"wasm",setupFunc:function(e){VS=e.wasm.cwrap(Yn,null,["number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{images:a}=n,{alignCorners:i,halfPixelCenters:s,size:o}=r,[u,l]=o,[c,h,p,d]=a.shape,f=[c,u,l,d],m=t.makeOutput(f,"float32");if(0===it(a.shape))return m;let g,y=t.dataIdMap.get(a.dataId);"float32"!==y.dtype&&(g=JT({backend:t,inputs:{x:a},attrs:{dtype:"float32"}}),y=t.dataIdMap.get(g.dataId));const b=y.id,v=t.dataIdMap.get(m.dataId).id;return VS(b,c,h,p,d,u,l,i?1:0,s?1:0,v),null!=g&&t.disposeData(g.dataId),m}};let jS;const GS={kernelName:Zn,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{dims:i}=r,s=pt(i,a.shape);if(0===a.shape.length)return RT({inputs:{x:a},backend:n});const o=n.makeOutput(a.shape,a.dtype),u=n.dataIdMap.get(a.dataId).id,l=n.dataIdMap.get(o.dataId).id,c=new Uint8Array(new Int32Array(s).buffer),h=new Uint8Array(new Int32Array(a.shape).buffer);jS(u,c,s.length,h,a.shape.length,l);const p=GT({inputs:{x:o},attrs:{shape:a.shape},backend:n});return n.disposeData(o.dataId),p},setupFunc:function(e){jS=e.wasm.cwrap(Zn,null,["number","array","number","array","number","number"])}};let HS;const KS={kernelName:Nr,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{image:a}=t,{radians:i,fillValue:s,center:o}=r,u=n.makeOutput(a.shape,a.dtype),l=n.dataIdMap.get(a.dataId).id,c=n.dataIdMap.get(u.dataId).id,[h,p,d,f]=a.shape,[m,g]=Rd(o,p,d),y="number"==typeof s?[s,s,s,0===s?0:255]:[...s,255],b=new Uint8Array(new Int32Array(y).buffer);return HS(l,h,p,d,f,i,m,g,b,y.length,c),u},setupFunc:function(e){HS=e.wasm.cwrap(Nr,null,["number","number","number","number","number","number","number","number","array","number","number"])}},qS=ET(er),XS=ET(tr);let YS;const QS={kernelName:nr,backendName:"wasm",setupFunc:function(e){YS=e.wasm.cwrap(nr,null,["number","number","number","number","number","number","array","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{indices:a,updates:i}=n,{shape:s}=r,o=t.makeOutput(s,i.dtype);if(0===it(s))return o;const{sliceRank:u,numUpdates:l,sliceSize:c,strides:h,outputSize:p}=Ho(0,a,s),d=t.dataIdMap.get(a.dataId).id,f=t.dataIdMap.get(i.dataId).id,m=new Uint8Array(new Int32Array(h).buffer),g=t.dataIdMap.get(o.dataId).id;return YS(d,f,vT[i.dtype],u,l,c,m,p,g),o}};let JS;const ZS={kernelName:rr,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n}=e,{condition:r,t:a,e:i}=t,s=n.dataIdMap.get(r.dataId).id,o=n.dataIdMap.get(a.dataId).id,u=n.dataIdMap.get(i.dataId).id,l=n.makeOutput(a.shape,a.dtype),c=n.dataIdMap.get(l.dataId).id,h=r.shape.length,p=a.shape.length,d=0===h||h>1||1===p?1:it(a.shape.slice(1));return JS(s,o,u,d,c),l},setupFunc:function(e){JS=e.wasm.cwrap("SelectV2",null,["number","number","number","number","number"])}};let eI;const tI={kernelName:"Sigmoid",backendName:"wasm",setupFunc:function(e){eI=e.wasm.cwrap(ir,null,["number","number"])},kernelFunc:function(e){const{backend:t,inputs:{x:n}}=e,r=t.dataIdMap.get(n.dataId).id,a=t.makeOutput(n.shape,n.dtype),i=t.dataIdMap.get(a.dataId).id;return 0===it(a.shape)||eI(r,i),a}},nI=ET("Sin");let rI;const aI={kernelName:cr,backendName:"wasm",setupFunc:function(e){rI=e.wasm.cwrap(cr,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:{logits:n},attrs:{dim:r}}=e,a=t.dataIdMap.get(n.dataId).id,i=t.makeOutput(n.shape,n.dtype),s=t.dataIdMap.get(i.dataId).id,o=n.shape[r],u=it(n.shape)/o;return 0===it(i.shape)||rI(a,s,o,u),i}},iI={kernelName:ur,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,{blockShape:i,paddings:s}=r,o=it(i),u=[[0,0]];u.push(...s);for(let e=1+i.length;e<a.shape.length;++e)u.push([0,0]);const l=CS.kernelFunc({inputs:{x:a},backend:n,attrs:{paddings:u,constantValue:0}}),c=Fd(l.shape,i,o,!1),h=Od(c.length,i.length,!1),p=Md(l.shape,i,o,!1),d=GT({inputs:{x:l},backend:n,attrs:{shape:c}}),f=MT({inputs:{x:d},backend:n,attrs:{perm:h}}),m=GT({inputs:{x:f},backend:n,attrs:{shape:p}});return n.disposeData(l.dataId),n.disposeData(d.dataId),n.disposeData(f.dataId),m}};let sI;const oI={kernelName:hr,backendName:"wasm",setupFunc:function(e){sI=e.wasm.cwrap("SparseFillEmptyRows","number",["number","number","number","number","number","number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n}=e,{indices:r,values:a,denseShape:i,defaultValue:s}=n,o=r.shape[0],u=r.shape[1],l=t.readSync(i.dataId)[0],c=[o+l,u],h=t.dataIdMap.get(r.dataId).id,p=t.dataIdMap.get(a.dataId).id,d=t.dataIdMap.get(s.dataId).id,f=t.makeOutput(c,r.dtype),m=t.dataIdMap.get(f.dataId).id,g=t.makeOutput(c.slice(0,1),a.dtype),y=t.dataIdMap.get(g.dataId).id,b=t.makeOutput([l],"bool"),v=t.dataIdMap.get(b.dataId).id,w=t.makeOutput([o],r.dtype),_=t.dataIdMap.get(w.dataId).id,x=t.makeOutput([4],"int32"),k=t.dataIdMap.get(x.dataId).id,T=sI(h,p,vT[a.dtype],o,l,u,d,m,y,v,_,k),E=t.readSync(x.dataId);let S;switch(E[0]){case 1:S=Wd(E[1]);break;case 2:S=Vd(E[1],E[2]);break;case 3:S=zd(E[1],E[2],E[3]);break;default:S=""}if(t.disposeData(x.dataId),S)throw t.disposeData(f.dataId),t.disposeData(g.dataId),t.disposeData(b.dataId),t.disposeData(w.dataId),new Error(S);let I=f,A=g;return T!==c[0]&&(I=XT({inputs:{x:f},attrs:{begin:0,size:[T,u]},backend:t}),A=XT({inputs:{x:g},attrs:{begin:0,size:T},backend:t}),t.disposeData(f.dataId),t.disposeData(g.dataId)),[I,A,b,w]}};let uI;const lI={kernelName:pr,backendName:"wasm",setupFunc:function(e){uI=e.wasm.cwrap(pr,null,["number","number","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n}=e,{inputIndices:r,inputShape:a,newShape:i}=n;if(2!==r.shape.length)throw new Error(`Input indices should be a matrix but received shape\n ${r.shape}`);if(1!==a.shape.length)throw new Error(`Input shape should be a vector but received shape\n ${a.shape}`);if(1!==i.shape.length)throw new Error(`Target shape should be a vector but received shape ${i.shape}`);const s=t.dataIdMap.get(r.dataId).id,o=t.dataIdMap.get(a.dataId).id,u=t.dataIdMap.get(i.dataId).id,l=r.shape[0],c=it(i.shape),h=t.makeOutput([l,c],r.dtype),p=t.dataIdMap.get(h.dataId).id,d=t.makeOutput([c],i.dtype),f=t.dataIdMap.get(d.dataId).id,m=t.makeOutput([3],"int32"),g=t.dataIdMap.get(m.dataId).id;uI(s,o,u,l,p,f,g);const y=t.readSync(m.dataId);let b;switch(y[0]){case 0:b=jd(y[1],y[2]);break;case 1:b=Gd(y[1],y[2]);break;case 2:b="reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero";break;case 3:b=Hd(Array.from(t.readSync(a.dataId)),Array.from(t.readSync(d.dataId)));break;case 4:b=Kd(Array.from(t.readSync(a.dataId)),Array.from(t.readSync(d.dataId)));break;default:b=""}if(t.disposeData(m.dataId),b)throw t.disposeData(h.dataId),t.disposeData(d.dataId),new Error(b);return[h,d]}};let cI;function hI(e){cI=e.wasm.cwrap("SparseSegmentReduction",null,["number","number","number","number","number","number","number","number","number"])}function pI(e,t){const{backend:n,inputs:r}=e,{data:a,indices:i,segmentIds:s}=r,o=i.shape[0],u=n.readSync(s.dataId,o-1,o)[0],l=o>0?u+1:0;if(l<0)throw new Error("segment ids must be >= 0");const c=a.shape.slice();c[0]=l;const h=n.dataIdMap.get(a.dataId).id,p=n.dataIdMap.get(i.dataId).id,d=n.dataIdMap.get(s.dataId).id,f=n.makeOutput(c,a.dtype),m=n.dataIdMap.get(f.dataId).id,g=n.makeOutput([4],"int32"),y=n.dataIdMap.get(g.dataId).id;cI(h,vT[a.dtype],a.shape[0],p,d,m,y,t,0);const b=n.readSync(g.dataId);let v;switch(b[0]){case 0:v="segment ids must be >= 0";break;case 1:v="segment ids are not increasing";break;case 2:v=qd(b[1],b[2]);break;case 3:v=Xd(b[1],b[2],b[3]);break;default:v=""}if(n.disposeData(g.dataId),v)throw n.disposeData(f.dataId),new Error(v);return f}const dI={kernelName:dr,backendName:"wasm",setupFunc:hI,kernelFunc:function(e){return pI(e,!0)}},fI={kernelName:fr,backendName:"wasm",setupFunc:hI,kernelFunc:function(e){return pI(e,!1)}},mI={kernelName:lr,backendName:"wasm",kernelFunc:function(e){const{inputs:t,attrs:n,backend:r}=e,{x:a}=t,{numOrSizeSplits:i,axis:s}=n,o=pt(s,a.shape)[0],u=Ud(a,i,o),l=new Array(a.shape.length).fill(0),c=a.shape.slice();return u.map((e=>{const t=[...c];t[o]=e;const n=XT({inputs:{x:a},attrs:{begin:l,size:t},backend:r});return l[o]+=e,n}))}},gI=ET(sr),yI=ET("Square"),bI=IT(mr);let vI;const wI={kernelName:Ar,backendName:"wasm",setupFunc:function(e){vI=e.wasm.cwrap(Ar,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{alpha:a}=r,{x:i}=n,s=t.dataIdMap.get(i.dataId).id,o=t.makeOutput(i.shape,i.dtype),u=t.dataIdMap.get(o.dataId).id;return vI(s,a,vT[i.dtype],u),o}};let _I;const xI={kernelName:gr,backendName:"wasm",setupFunc:function(e){_I=e.wasm.cwrap(gr,null,["number","array","number","array","array","array","array","array","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{x:a}=n,{begin:i,end:s,strides:o,beginMask:u,endMask:l,ellipsisMask:c,newAxisMask:h,shrinkAxisMask:p}=r,{finalShapeSparse:d,finalShape:f,isIdentity:m,sliceDim0:g,isSimpleSlice:y,begin:b,end:v,strides:w}=su(a.shape,i,s,o,u,l,c,h,p);let _;if(m)_=GT({inputs:{x:a},backend:t,attrs:{shape:f}});else if(g||y){nt(a.shape.length>=1,(()=>`Input must have rank at least 1, got: ${a.shape.length}`));const e=qo(b,v,w),n=XT({inputs:{x:a},backend:t,attrs:{begin:b,size:e}});_=GT({inputs:{x:n},backend:t,attrs:{shape:f}}),t.disposeData(n.dataId)}else{const e=t.makeOutput(d,"float32"),n=t.dataIdMap.get(a.dataId).id,r=new Uint8Array(new Int32Array(xt(a.shape)).buffer),i=new Uint8Array(new Int32Array(b).buffer),s=new Uint8Array(new Int32Array(v).buffer),o=new Uint8Array(new Int32Array(w).buffer),u=new Uint8Array(new Int32Array(d).buffer),l=new Uint8Array(new Int32Array(xt(d)).buffer),c=t.dataIdMap.get(e.dataId).id;_I(n,r,a.shape.length,i,s,o,u,l,d.length,c),_=GT({inputs:{x:e},backend:t,attrs:{shape:f}}),t.disposeData(e.dataId)}return _}},kI={kernelName:yr,backendName:"wasm",kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{data:a,dataSplits:i}=n,{separator:s,nGramWidths:o,leftPad:u,rightPad:l,padWidth:c,preserveShortSequences:h}=r,p=t.readSync(a.dataId),d=t.readSync(i.dataId),[f,m]=Ag(p,d,s,o,u,l,c,h),g=t.makeOutput([f.length],"string");t.dataIdMap.get(g.dataId).stringBytes=f;const y=t.makeOutput(i.shape,"int32");return t.typedArrayFromHeap(y).set(m),[g,y]}},TI={kernelName:br,backendName:"wasm",kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{input:a,delimiter:i}=n,{skipEmpty:s}=r,o=t.readSync(a.dataId),u=t.readSync(i.dataId),[l,c,h]=Ng(o,u[0],s),p=c.length,d=t.makeOutput([p,2],"int32");t.typedArrayFromHeap(d).set(l);const f=t.makeOutput([p],"string");t.dataIdMap.get(f.dataId).stringBytes=c;const m=t.makeOutput([2],"int32");return t.typedArrayFromHeap(m).set(h),[d,f,m]}},EI={kernelName:vr,backendName:"wasm",kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{input:a}=n,{numBuckets:i}=r,s=Rg(t.readSync(a.dataId),i),o=t.makeOutput(a.shape,"int32");return t.typedArrayFromHeap(o).set(s),o}},SI=IT(wr);let II;const AI={kernelName:or,backendName:"wasm",setupFunc:function(e){II=e.wasm.cwrap(or,null,["number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{axis:a,keepDims:i}=r,{x:s}=n,o=t.dataIdMap.get(s.dataId).id;let u=o,l=s;const{transposed:c,axes:h,originalAxes:p,inputWasTransposed:d}=DT(s,a,t);let f=h;if(d){const e=t.dataIdMap.get(c.dataId).id;e!==o&&(l=c,u=e,f=Wl(f.length,l.shape.length))}Ll("sum",f,l.shape.length);const[m,g]=Dl(l.shape,f),y=it(g),b=t.makeOutput(m,l.dtype);if(0!==it(l.shape)){const e=t.dataIdMap.get(b.dataId).id;II(u,y,vT[b.dtype],e)}if(d&&t.disposeData(c.dataId),i){const e=Pl(b.shape,p);b.shape=e}return b}},CI=ET("Tan"),NI=ET(_r);let RI;const FI={kernelName:xr,backendName:"wasm",setupFunc:function(e){RI=e.wasm.cwrap(xr,null,["number","array","number","array","number","number"])},kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{x:a}=t,i=n.dataIdMap.get(a.dataId).id,{reps:s}=r,o=new Array(a.shape.length);for(let e=0;e<o.length;e++)o[e]=a.shape[e]*s[e];const u=new Uint8Array(new Int32Array(a.shape).buffer),l=new Uint8Array(new Int32Array(o).buffer),c=n.makeOutput(o,a.dtype),h=n.dataIdMap.get(c.dataId).id;return RI(i,u,a.shape.length,l,o.length,vT[c.dtype],h),c}};let OI;const MI={kernelName:kr,backendName:"wasm",setupFunc:function(e){OI=e.wasm.cwrap(kr,null,["number","array","number","number","number","bool","number","number"])},kernelFunc:({inputs:e,backend:t,attrs:n})=>{const{x:r}=e,{k:a,sorted:i}=n,s=t.dataIdMap.get(r.dataId).id,o=new Uint8Array(new Int32Array(r.shape).buffer),u=r.shape.slice();u[u.length-1]=a;const l=t.makeOutput(u,r.dtype),c=t.dataIdMap.get(l.dataId).id,h=t.makeOutput(u,"int32"),p=t.dataIdMap.get(h.dataId).id;return OI(s,o,r.shape.length,vT[r.dtype],a,i,c,p),[l,h]}};let $I;const DI={kernelName:Tr,backendName:"wasm",setupFunc:function(e){$I=e.wasm.cwrap(Tr,null,["number","number","bool","number","number","number","number","number","number","array","number","array","number","number","number","number","number"])},kernelFunc:function(e){const{backend:t,inputs:n,attrs:r}=e,{image:a,transforms:i}=n,{interpolation:s,fillMode:o,fillValue:u,outputShape:l}=r,[c,h,p,d]=a.shape,[f,m]=null!=l?l:[h,p],g=[c,f,m,d],y=new Uint8Array(new Int32Array(xt(a.shape)).buffer),b=new Uint8Array(new Int32Array(xt(g)).buffer),v=t.makeOutput(g,a.dtype),w=t.dataIdMap.get(v.dataId).id,_=t.dataIdMap.get(a.dataId).id,x=t.dataIdMap.get(i.dataId).id,k="nearest"===s?1:2;let T;switch(o){case"constant":default:T=1;break;case"reflect":T=2;break;case"wrap":T=3;break;case"nearest":T=4}return $I(_,x,i.shape[0]>1,c,f,m,d,p,h,y,a.shape.length-1,b,g.length-1,k,T,u,w),v}},PI={kernelName:Sr,backendName:"wasm",kernelFunc:function(e){const{inputs:t,backend:n,attrs:r}=e,{value:a}=t;let{axis:i}=r;i<0&&(i+=a.shape.length);const s=a.shape[i],o=a.shape.length,u=new Array(o-1);let l=0;for(let e=0;e<o;e++)e!==i&&(u[l++]=a.shape[e]);const c=new Array(s),h=new Array(o).fill(0),p=a.shape.slice();p[i]=1;for(let e=0;e<c.length;e++)h[i]=e,c[e]=XT({inputs:{x:a},attrs:{begin:h,size:p},backend:n});return c.map((({dataId:e,dtype:t})=>({dataId:e,dtype:t,shape:u})))}},LI={kernelName:Ir,backendName:"wasm",kernelFunc:function(e){const{inputs:{x:t},backend:n}=e,r=n.makeOutput(t.shape,t.dtype);return n.typedArrayFromHeap(r).fill(0),r}},BI=[TT,ST,AT,NT,LT,UT,VT,jT,qT,QT,ZT,eE,nE,aE,sE,uE,lE,cE,dE,mE,yE,vE,_E,xE,kE,TE,SE,AE,NE,RE,FE,ME,DE,LE,UE,VE,zE,jE,FT,GE,KE,qE,XE,YE,QE,JE,ZE,eS,nS,rS,iS,oS,lS,cS,dS,fS,mS,bS,wS,xS,kS,ES,SS,IS,CS,NS,FS,MS,$S,DS,PS,LS,BS,HT,WS,zS,GS,KS,qS,XS,QS,ZS,tI,nI,YT,aI,iI,oI,lI,dI,fI,mI,gI,yI,bI,wI,xI,kI,TI,EI,SI,AI,CI,NI,FI,MI,DI,$T,PI,LI];for(const e of BI)Ur(e);const UI=Mt();UI.registerFlag("WASM_HAS_SIMD_SUPPORT",(async()=>{try{return WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,9,1,7,0,65,0,253,15,26,11]))}catch(e){return!1}})),UI.registerFlag("WASM_HAS_MULTITHREAD_SUPPORT",(async()=>{if(UI.get("IS_NODE"))return!1;try{return(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]))}catch(e){return!1}}));var WI=ih((function(e,t){var n=(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;return e=e||"/Users/djanekovic/Code/xzimg-web-sdk/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out",function(t){function n(){return A.buffer!=F&&W(A.buffer),M}function r(){return A.buffer!=F&&W(A.buffer),$}function a(){return A.buffer!=F&&W(A.buffer),D}function i(){return A.buffer!=F&&W(A.buffer),P}var s,o,u,l=void 0!==(t=t||{})?t:{};l.ready=new Promise((function(e,t){s=e,o=t})),void 0!==Xe&&Xe.listeners&&(u={uncaughtException:Xe.listeners("uncaughtException"),unhandledRejection:Xe.listeners("unhandledRejection")});var c,h,p,d=Object.assign({},l),f=(e,t)=>{throw t},m="object"==typeof window,g="function"==typeof importScripts,y="object"==typeof Xe&&"object"==typeof Xe.versions&&"string"==typeof Xe.versions.node,b=l.ENVIRONMENT_IS_PTHREAD||!1,v="";function w(e){return l.locateFile?l.locateFile(e,v):v+e}if(y){var _=ph,x=ph;let e;v=g?x.dirname(v)+"/":"/Users/djanekovic/Code/xzimg-web-sdk/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/",c=(e,t)=>(e=ee(e)?new URL(e):x.normalize(e),_.readFileSync(e,t?void 0:"utf8")),p=e=>{var t=c(e,!0);return t.buffer||(t=new Uint8Array(t)),t},h=(e,t,n)=>{e=ee(e)?new URL(e):x.normalize(e),_.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},Xe.argv.length>1&&Xe.argv[1].replace(/\\/g,"/"),Xe.argv.slice(2),Xe.on("uncaughtException",(function(e){if(!(e instanceof re))throw e})),Xe.on("unhandledRejection",(function(e){throw e})),f=(e,t)=>{if(K())throw Xe.exitCode=e,t;!function(e){e instanceof re||I("exiting due to exception: "+e)}(t),Xe.exit(e)},l.inspect=function(){return"[Emscripten Module object]"};try{e=ph}catch(e){throw console.error('The "worker_threads" module is not supported in this node.js build - perhaps a newer version is needed?'),e}ah.Worker=e.Worker}else(m||g)&&(g?v=self.location.href:"undefined"!=typeof document&&document.currentScript&&(v=document.currentScript.src),void 0!==e&&e&&(v=e),v=0!==v.indexOf("blob:")?v.substr(0,v.replace(/[?#].*/,"").lastIndexOf("/")+1):"",y||(c=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},g&&(p=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),h=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)}));y&&"undefined"==typeof performance&&(ah.performance=ph.performance);var k=console.log.bind(console),T=console.warn.bind(console);y&&(k=e=>_.writeSync(1,e+"\n"),T=e=>_.writeSync(2,e+"\n"));var E,S=l.print||k,I=l.printErr||T;Object.assign(l,d),d=null,l.arguments&&l.arguments,l.thisProgram&&l.thisProgram,l.quit&&(f=l.quit),l.wasmBinary&&(E=l.wasmBinary);var A,C,N=l.noExitRuntime||!0;"object"!=typeof WebAssembly&&J("no native wasm support detected");var R,F,O,M,$,D,P,L=!1,B="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function U(e,t,n){for(var r=t+n,a=t;e[a]&&!(a>=r);)++a;if(a-t>16&&e.buffer&&B)return B.decode(e.buffer instanceof SharedArrayBuffer?e.slice(t,a):e.subarray(t,a));for(var i="";t<a;){var s=e[t++];if(128&s){var o=63&e[t++];if(192!=(224&s)){var u=63&e[t++];if((s=224==(240&s)?(15&s)<<12|o<<6|u:(7&s)<<18|o<<12|u<<6|63&e[t++])<65536)i+=String.fromCharCode(s);else{var l=s-65536;i+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else i+=String.fromCharCode((31&s)<<6|o)}else i+=String.fromCharCode(s)}return i}function W(e){F=e,l.HEAP8=O=new Int8Array(e),l.HEAP16=new Int16Array(e),l.HEAP32=$=new Int32Array(e),l.HEAPU8=M=new Uint8Array(e),l.HEAPU16=new Uint16Array(e),l.HEAPU32=D=new Uint32Array(e),l.HEAPF32=new Float32Array(e),l.HEAPF64=P=new Float64Array(e)}b&&(F=l.buffer);var V,z=l.INITIAL_MEMORY||16777216;if(b)A=l.wasmMemory,F=l.buffer;else if(l.wasmMemory)A=l.wasmMemory;else if(!((A=new WebAssembly.Memory({initial:z/65536,maximum:32768,shared:!0})).buffer instanceof SharedArrayBuffer))throw I("requested a shared WebAssembly.Memory but the returned buffer is not a SharedArrayBuffer, indicating that while the browser has SharedArrayBuffer it does not have WebAssembly threads support - you may need to set a flag"),y&&I("(on node you may need: --experimental-wasm-threads --experimental-wasm-bulk-memory and/or recent version)"),Error("bad memory");A&&(F=A.buffer),z=F.byteLength,W(F);var j=[],G=[],H=[];function K(){return N}function q(){b||le(G)}var X,Y=0,Q=null;function J(e){l.onAbort&&l.onAbort(e),I(e="Aborted("+e+")"),L=!0,R=1,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw o(t),t}function Z(e){return e.startsWith("data:application/octet-stream;base64,")}function ee(e){return e.startsWith("file://")}function te(e){try{if(e==X&&E)return new Uint8Array(E);if(p)return p(e);throw"both async and sync fetching of the wasm failed"}catch(e){J(e)}}Z(X="tfjs-backend-wasm-threaded-simd.wasm")||(X=w(X));var ne={};function re(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function ae(e){var t=ue.pthreads[e];t||J(void 0),ue.returnWorkerToPool(t)}function ie(e){var t=ue.getNewWorker();if(!t)return 6;ue.runningWorkers.push(t),ue.pthreads[e.pthread_ptr]=t,t.pthread_ptr=e.pthread_ptr;var n={cmd:"run",start_routine:e.startRoutine,arg:e.arg,pthread_ptr:e.pthread_ptr};return t.runPthread=()=>{y&&t.ref(),t.postMessage(n,e.transferList),delete t.runPthread},t.loaded&&t.runPthread(),0}function se(e){if(b)return ye(1,1,e);R=e,K()||(ue.terminateAllThreads(),l.onExit&&l.onExit(e),L=!0),f(e,new re(e))}var oe=function(e,t){if(R=e,!t&&b)throw ce(e),"unwind";se(e)},ue={unusedWorkers:[],runningWorkers:[],tlsInitFunctions:[],pthreads:{},init:function(){b?ue.initWorker():ue.initMainThread()},initMainThread:function(){for(var e=8;e--;)ue.allocateUnusedWorker()},initWorker:function(){N=!1},setExitStatus:function(e){R=e},terminateAllThreads:function(){for(var e of Object.values(ue.pthreads))ue.returnWorkerToPool(e);for(var e of ue.unusedWorkers)e.terminate();ue.unusedWorkers=[]},returnWorkerToPool:function(e){var t=e.pthread_ptr;delete ue.pthreads[t],ue.unusedWorkers.push(e),ue.runningWorkers.splice(ue.runningWorkers.indexOf(e),1),e.pthread_ptr=0,y&&e.unref(),De(t)},receiveObjectTransfer:function(e){},threadInitTLS:function(){ue.tlsInitFunctions.forEach((e=>e()))},loadWasmModuleToWorker:function(t,n){t.onmessage=e=>{var r,a=e.data,i=a.cmd;if(t.pthread_ptr&&(ue.currentProxiedOperationCallerThread=t.pthread_ptr),a.targetThread&&a.targetThread!=Ce()){var s=ue.pthreads[a.targetThread];return s?s.postMessage(a,a.transferList):I('Internal error! Worker sent a message "'+i+'" to target pthread '+a.targetThread+", but that thread no longer exists!"),void(ue.currentProxiedOperationCallerThread=void 0)}"processProxyingQueue"===i?me(a.queue):"spawnThread"===i?ie(a):"cleanupThread"===i?ae(a.thread):"killThread"===i?function(e){var t=ue.pthreads[e];delete ue.pthreads[e],t.terminate(),De(e),ue.runningWorkers.splice(ue.runningWorkers.indexOf(t),1),t.pthread_ptr=0}(a.thread):"cancelThread"===i?(r=a.thread,ue.pthreads[r].postMessage({cmd:"cancel"})):"loaded"===i?(t.loaded=!0,y&&t.unref(),n&&n(t),t.runPthread&&t.runPthread()):"print"===i?S("Thread "+a.threadId+": "+a.text):"printErr"===i?I("Thread "+a.threadId+": "+a.text):"alert"===i?alert("Thread "+a.threadId+": "+a.text):"setimmediate"===a.target?t.postMessage(a):"callHandler"===i?l[a.handler](...a.args):i&&I("worker sent an unknown command "+i),ue.currentProxiedOperationCallerThread=void 0},t.onerror=e=>{throw I("worker sent an error! "+e.filename+":"+e.lineno+": "+e.message),e},y&&(t.on("message",(function(e){t.onmessage({data:e})})),t.on("error",(function(e){t.onerror(e)})),t.on("detachedExit",(function(){})));var r=[];for(var a of["onExit","onAbort","print","printErr"])l.hasOwnProperty(a)&&r.push(a);t.postMessage({cmd:"load",handlers:r,urlOrBlob:l.mainScriptUrlOrBlob||e,wasmMemory:A,wasmModule:C})},allocateUnusedWorker:function(){var e,t=w("tfjs-backend-wasm-threaded-simd.worker.js");e=new Worker(t),ue.unusedWorkers.push(e)},getNewWorker:function(){return 0==ue.unusedWorkers.length&&(ue.allocateUnusedWorker(),ue.loadWasmModuleToWorker(ue.unusedWorkers[0])),ue.unusedWorkers.pop()}};function le(e){for(;e.length>0;)e.shift()(l)}function ce(e){if(b)return ye(2,0,e);try{oe(e)}catch(e){!function(e){if(e instanceof re||"unwind"==e)return R;f(1,e)}(e)}}l.PThread=ue,l.establishStackSpace=function(){var e=Ce(),t=r()[e+52>>2],n=r()[e+56>>2];Le(t,t-n),Ue(t)};var he,pe=[];function de(e,t,n,r){return b?ye(3,1,e,t,n,r):fe(e,t,n,r)}function fe(e,t,n,r){if("undefined"==typeof SharedArrayBuffer)return I("Current environment does not support SharedArrayBuffer, pthreads are not available!"),6;var a=[];if(b&&0===a.length)return de(e,t,n,r);var i={startRoutine:n,pthread_ptr:e,arg:r,transferList:a};return b?(i.cmd="spawnThread",postMessage(i,a),0):ie(i)}function me(e){Atomics.store(r(),e>>2,1),Ce()&&$e(e),Atomics.compareExchange(r(),e>>2,1,0)}function ge(e){ge.shown||(ge.shown={}),ge.shown[e]||(ge.shown[e]=1,y&&(e="warning: "+e),I(e))}function ye(e,t){var n=arguments.length-2,r=arguments;return function(e){var t=Be(),n=e();return Ue(t),n}((()=>{for(var a=n,s=We(8*a),o=s>>3,u=0;u<n;u++){var l=r[2+u];i()[o+u]=l}return Re(e,a,s,t)}))}l.invokeEntryPoint=function(e,t){var n,r,a=((r=pe[n=e])||(n>=pe.length&&(pe.length=n+1),pe[n]=r=V.get(n)),r)(t);K()?ue.setExitStatus(a):Pe(a)},l.executeNotifiedProxyingQueue=me,he=y?()=>{var e=Xe.hrtime();return 1e3*e[0]+e[1]/1e6}:()=>performance.timeOrigin+performance.now();var be=[];function ve(e){try{return A.grow(e-F.byteLength+65535>>>16),W(A.buffer),1}catch(e){}}function we(e){return b?ye(4,1,e):52}function _e(e,t,n,r,a){return b?ye(5,1,e,t,n,r,a):70}var xe=[null,[],[]];function ke(e,t){var n=xe[e];0===t||10===t?((1===e?S:I)(U(n,0)),n.length=0):n.push(t)}function Te(e,t,r,i){if(b)return ye(6,1,e,t,r,i);for(var s=0,o=0;o<r;o++){var u=a()[t>>2],l=a()[t+4>>2];t+=8;for(var c=0;c<l;c++)ke(e,n()[u+c]);s+=l}return a()[i>>2]=s,0}function Ee(e){return l["_"+e]}function Se(e,t,r,a,i){var s={string:e=>{var t=0;if(null!=e&&0!==e){var r=1+(e.length<<2);!function(e,t,r){!function(e,t,n,r){if(!(r>0))return 0;for(var a=n+r-1,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i)),s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}t[n]=0}(e,n(),t,r)}(e,t=We(r),r)}return t},array:e=>{var t=We(e.length);return function(e,t){(A.buffer!=F&&W(A.buffer),O).set(e,t)}(e,t),t}},o=Ee(e),u=[],l=0;if(a)for(var c=0;c<a.length;c++){var h=s[r[c]];h?(0===l&&(l=Be()),u[c]=h(a[c])):u[c]=a[c]}return function(e){return 0!==l&&Ue(l),function(e){return"string"===t?(r=e)?U(n(),r,void 0):"":"boolean"===t?Boolean(e):e;var r}(e)}(o.apply(null,u))}ue.init();var Ie=[null,se,ce,de,we,_e,Te],Ae={__emscripten_init_main_thread_js:function(e){Ne(e,!g,1,!m),ue.threadInitTLS()},__emscripten_thread_cleanup:function(e){b?postMessage({cmd:"cleanupThread",thread:e}):ae(e)},__pthread_create_js:fe,_emscripten_default_pthread_stack_size:function(){return 65536},_emscripten_get_now_is_monotonic:function(){return!0},_emscripten_notify_task_queue:function(e,t,n,r){if(e==t)setTimeout((()=>me(r)));else if(b)postMessage({targetThread:e,cmd:"processProxyingQueue",queue:r});else{var a=ue.pthreads[e];if(!a)return;a.postMessage({cmd:"processProxyingQueue",queue:r})}return 1},_emscripten_set_offscreencanvas_size:function(e,t,n){return-1},abort:function(){J("")},emscripten_check_blocking_allowed:function(){y||g||ge("Blocking on the main thread is very dangerous, see https://emscripten.org/docs/porting/pthreads.html#blocking-on-the-main-browser-thread")},emscripten_date_now:function(){return Date.now()},emscripten_get_heap_max:function(){return 2147483648},emscripten_get_now:he,emscripten_memcpy_big:function(e,t,r){n().copyWithin(e,t,t+r)},emscripten_num_logical_cores:function(){return y?ph.cpus().length:navigator.hardwareConcurrency},emscripten_receive_on_main_thread_js:function(e,t,n){be.length=t;for(var r=n>>3,a=0;a<t;a++)be[a]=i()[r+a];return(e<0?ne[-e-1]:Ie[e]).apply(null,be)},emscripten_resize_heap:function(e){var t=n().length;if((e>>>=0)<=t)return!1;var r=2147483648;if(e>r)return!1;let a=(e,t)=>e+(t-e%t)%t;for(var i=1;i<=4;i*=2){var s=t*(1+.2/i);if(s=Math.min(s,e+100663296),ve(Math.min(r,a(Math.max(e,s),65536))))return!0}return!1},emscripten_unwind_to_js_event_loop:function(){throw"unwind"},exit:oe,fd_close:we,fd_seek:_e,fd_write:Te,memory:A||l.wasmMemory};!function(){var e={env:Ae,wasi_snapshot_preview1:Ae};function t(e,t){var n,r,a=e.exports;if(l.asm=a,n=l.asm._emscripten_tls_init,ue.tlsInitFunctions.push(n),V=l.asm.__indirect_function_table,r=l.asm.__wasm_call_ctors,G.unshift(r),C=t,!b){var i=ue.unusedWorkers.length;ue.unusedWorkers.forEach((function(e){ue.loadWasmModuleToWorker(e,(function(){--i||function(e){if(Y--,l.monitorRunDependencies&&l.monitorRunDependencies(Y),0==Y&&Q){var t=Q;Q=null,t()}}()}))}))}}function n(e){t(e.instance,e.module)}function r(t){return function(){if(!E&&(m||g)){if("function"==typeof fetch&&!ee(X))return fetch(X,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+X+"'";return e.arrayBuffer()})).catch((function(){return te(X)}));if(h)return new Promise((function(e,t){h(X,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return te(X)}))}().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){I("failed to asynchronously prepare wasm: "+e),J(e)}))}if(b||(Y++,l.monitorRunDependencies&&l.monitorRunDependencies(Y)),l.instantiateWasm)try{return l.instantiateWasm(e,t)}catch(e){I("Module.instantiateWasm callback failed with error: "+e),o(e)}(E||"function"!=typeof WebAssembly.instantiateStreaming||Z(X)||ee(X)||y||"function"!=typeof fetch?r(n):fetch(X,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(e){return I("wasm streaming compile failed: "+e),I("falling back to ArrayBuffer instantiation"),r(n)}))}))).catch(o)}(),l.___wasm_call_ctors=function(){return(l.___wasm_call_ctors=l.asm.__wasm_call_ctors).apply(null,arguments)},l._init=function(){return(l._init=l.asm.init).apply(null,arguments)},l._init_with_threads_count=function(){return(l._init_with_threads_count=l.asm.init_with_threads_count).apply(null,arguments)},l._get_threads_count=function(){return(l._get_threads_count=l.asm.get_threads_count).apply(null,arguments)},l._register_tensor=function(){return(l._register_tensor=l.asm.register_tensor).apply(null,arguments)},l._dispose_data=function(){return(l._dispose_data=l.asm.dispose_data).apply(null,arguments)},l._dispose=function(){return(l._dispose=l.asm.dispose).apply(null,arguments)},l._Abs=function(){return(l._Abs=l.asm.Abs).apply(null,arguments)},l._Add=function(){return(l._Add=l.asm.Add).apply(null,arguments)},l._AddN=function(){return(l._AddN=l.asm.AddN).apply(null,arguments)},l._All=function(){return(l._All=l.asm.All).apply(null,arguments)},l._Any=function(){return(l._Any=l.asm.Any).apply(null,arguments)},l._ArgMax=function(){return(l._ArgMax=l.asm.ArgMax).apply(null,arguments)},l._AvgPool=function(){return(l._AvgPool=l.asm.AvgPool).apply(null,arguments)},l._BatchMatMul=function(){return(l._BatchMatMul=l.asm.BatchMatMul).apply(null,arguments)},l._Ceil=function(){return(l._Ceil=l.asm.Ceil).apply(null,arguments)},l._ClipByValue=function(){return(l._ClipByValue=l.asm.ClipByValue).apply(null,arguments)},l._Conv2D=function(){return(l._Conv2D=l.asm.Conv2D).apply(null,arguments)},l._Conv2DBackpropInput=function(){return(l._Conv2DBackpropInput=l.asm.Conv2DBackpropInput).apply(null,arguments)},l._Cos=function(){return(l._Cos=l.asm.Cos).apply(null,arguments)},l._Cosh=function(){return(l._Cosh=l.asm.Cosh).apply(null,arguments)},l._CropAndResize=function(){return(l._CropAndResize=l.asm.CropAndResize).apply(null,arguments)},l._Cumprod=function(){return(l._Cumprod=l.asm.Cumprod).apply(null,arguments)},l._Cumsum=function(){return(l._Cumsum=l.asm.Cumsum).apply(null,arguments)},l._DepthToSpace=function(){return(l._DepthToSpace=l.asm.DepthToSpace).apply(null,arguments)},l._DepthwiseConv2dNative=function(){return(l._DepthwiseConv2dNative=l.asm.DepthwiseConv2dNative).apply(null,arguments)},l._Elu=function(){return(l._Elu=l.asm.Elu).apply(null,arguments)},l._Equal=function(){return(l._Equal=l.asm.Equal).apply(null,arguments)},l._Exp=function(){return(l._Exp=l.asm.Exp).apply(null,arguments)},l._FlipLeftRight=function(){return(l._FlipLeftRight=l.asm.FlipLeftRight).apply(null,arguments)},l._Floor=function(){return(l._Floor=l.asm.Floor).apply(null,arguments)},l._FloorDiv=function(){return(l._FloorDiv=l.asm.FloorDiv).apply(null,arguments)},l._FusedBatchNorm=function(){return(l._FusedBatchNorm=l.asm.FusedBatchNorm).apply(null,arguments)},l._FusedConv2D=function(){return(l._FusedConv2D=l.asm.FusedConv2D).apply(null,arguments)},l._FusedDepthwiseConv2D=function(){return(l._FusedDepthwiseConv2D=l.asm.FusedDepthwiseConv2D).apply(null,arguments)},l._Gather=function(){return(l._Gather=l.asm.Gather).apply(null,arguments)},l._GatherNd=function(){return(l._GatherNd=l.asm.GatherNd).apply(null,arguments)},l._Greater=function(){return(l._Greater=l.asm.Greater).apply(null,arguments)},l._GreaterEqual=function(){return(l._GreaterEqual=l.asm.GreaterEqual).apply(null,arguments)},l._IsNan=function(){return(l._IsNan=l.asm.IsNan).apply(null,arguments)},l._LeakyRelu=function(){return(l._LeakyRelu=l.asm.LeakyRelu).apply(null,arguments)},l._Less=function(){return(l._Less=l.asm.Less).apply(null,arguments)},l._LessEqual=function(){return(l._LessEqual=l.asm.LessEqual).apply(null,arguments)},l._Log=function(){return(l._Log=l.asm.Log).apply(null,arguments)},l._LogicalAnd=function(){return(l._LogicalAnd=l.asm.LogicalAnd).apply(null,arguments)},l._LogicalNot=function(){return(l._LogicalNot=l.asm.LogicalNot).apply(null,arguments)},l._LogicalOr=function(){return(l._LogicalOr=l.asm.LogicalOr).apply(null,arguments)},l._LogicalXor=function(){return(l._LogicalXor=l.asm.LogicalXor).apply(null,arguments)},l._Max=function(){return(l._Max=l.asm.Max).apply(null,arguments)},l._MaxPool=function(){return(l._MaxPool=l.asm.MaxPool).apply(null,arguments)},l._Maximum=function(){return(l._Maximum=l.asm.Maximum).apply(null,arguments)},l._Mean=function(){return(l._Mean=l.asm.Mean).apply(null,arguments)},l._Min=function(){return(l._Min=l.asm.Min).apply(null,arguments)},l._Minimum=function(){return(l._Minimum=l.asm.Minimum).apply(null,arguments)},l._MirrorPad=function(){return(l._MirrorPad=l.asm.MirrorPad).apply(null,arguments)},l._Multiply=function(){return(l._Multiply=l.asm.Multiply).apply(null,arguments)},l._Neg=function(){return(l._Neg=l.asm.Neg).apply(null,arguments)},l._NonMaxSuppressionV3=function(){return(l._NonMaxSuppressionV3=l.asm.NonMaxSuppressionV3).apply(null,arguments)},l._NonMaxSuppressionV4=function(){return(l._NonMaxSuppressionV4=l.asm.NonMaxSuppressionV4).apply(null,arguments)},l._NonMaxSuppressionV5=function(){return(l._NonMaxSuppressionV5=l.asm.NonMaxSuppressionV5).apply(null,arguments)},l._NotEqual=function(){return(l._NotEqual=l.asm.NotEqual).apply(null,arguments)},l._OneHot=function(){return(l._OneHot=l.asm.OneHot).apply(null,arguments)},l._PadV2=function(){return(l._PadV2=l.asm.PadV2).apply(null,arguments)},l._Pow=function(){return(l._Pow=l.asm.Pow).apply(null,arguments)},l._Prelu=function(){return(l._Prelu=l.asm.Prelu).apply(null,arguments)},l._Prod=function(){return(l._Prod=l.asm.Prod).apply(null,arguments)},l._RealDiv=function(){return(l._RealDiv=l.asm.RealDiv).apply(null,arguments)},l._Reciprocal=function(){return(l._Reciprocal=l.asm.Reciprocal).apply(null,arguments)},l._Relu=function(){return(l._Relu=l.asm.Relu).apply(null,arguments)},l._Relu6=function(){return(l._Relu6=l.asm.Relu6).apply(null,arguments)},l._ResizeBilinear=function(){return(l._ResizeBilinear=l.asm.ResizeBilinear).apply(null,arguments)},l._ResizeNearestNeighbor=function(){return(l._ResizeNearestNeighbor=l.asm.ResizeNearestNeighbor).apply(null,arguments)},l._Reverse=function(){return(l._Reverse=l.asm.Reverse).apply(null,arguments)},l._RotateWithOffset=function(){return(l._RotateWithOffset=l.asm.RotateWithOffset).apply(null,arguments)},l._Round=function(){return(l._Round=l.asm.Round).apply(null,arguments)},l._Rsqrt=function(){return(l._Rsqrt=l.asm.Rsqrt).apply(null,arguments)},l._ScatterNd=function(){return(l._ScatterNd=l.asm.ScatterNd).apply(null,arguments)},l._SelectV2=function(){return(l._SelectV2=l.asm.SelectV2).apply(null,arguments)},l._Sigmoid=function(){return(l._Sigmoid=l.asm.Sigmoid).apply(null,arguments)},l._Sin=function(){return(l._Sin=l.asm.Sin).apply(null,arguments)},l._Softmax=function(){return(l._Softmax=l.asm.Softmax).apply(null,arguments)},l._SparseFillEmptyRows=function(){return(l._SparseFillEmptyRows=l.asm.SparseFillEmptyRows).apply(null,arguments)},l._SparseReshape=function(){return(l._SparseReshape=l.asm.SparseReshape).apply(null,arguments)},l._SparseSegmentReduction=function(){return(l._SparseSegmentReduction=l.asm.SparseSegmentReduction).apply(null,arguments)},l._Sqrt=function(){return(l._Sqrt=l.asm.Sqrt).apply(null,arguments)},l._Square=function(){return(l._Square=l.asm.Square).apply(null,arguments)},l._SquaredDifference=function(){return(l._SquaredDifference=l.asm.SquaredDifference).apply(null,arguments)},l._Step=function(){return(l._Step=l.asm.Step).apply(null,arguments)},l._StridedSlice=function(){return(l._StridedSlice=l.asm.StridedSlice).apply(null,arguments)},l._Sub=function(){return(l._Sub=l.asm.Sub).apply(null,arguments)},l._Sum=function(){return(l._Sum=l.asm.Sum).apply(null,arguments)},l._Tan=function(){return(l._Tan=l.asm.Tan).apply(null,arguments)},l._Tanh=function(){return(l._Tanh=l.asm.Tanh).apply(null,arguments)},l._Tile=function(){return(l._Tile=l.asm.Tile).apply(null,arguments)},l._TopK=function(){return(l._TopK=l.asm.TopK).apply(null,arguments)},l._Transform=function(){return(l._Transform=l.asm.Transform).apply(null,arguments)},l._Transpose=function(){return(l._Transpose=l.asm.Transpose).apply(null,arguments)},l.__FusedMatMul=function(){return(l.__FusedMatMul=l.asm._FusedMatMul).apply(null,arguments)},l._malloc=function(){return(l._malloc=l.asm.malloc).apply(null,arguments)},l._free=function(){return(l._free=l.asm.free).apply(null,arguments)},l.__emscripten_tls_init=function(){return(l.__emscripten_tls_init=l.asm._emscripten_tls_init).apply(null,arguments)};var Ce=l._pthread_self=function(){return(Ce=l._pthread_self=l.asm.pthread_self).apply(null,arguments)};l.___errno_location=function(){return(l.___errno_location=l.asm.__errno_location).apply(null,arguments)};var Ne=l.__emscripten_thread_init=function(){return(Ne=l.__emscripten_thread_init=l.asm._emscripten_thread_init).apply(null,arguments)};l.__emscripten_thread_crashed=function(){return(l.__emscripten_thread_crashed=l.asm._emscripten_thread_crashed).apply(null,arguments)},l._emscripten_main_thread_process_queued_calls=function(){return(l._emscripten_main_thread_process_queued_calls=l.asm.emscripten_main_thread_process_queued_calls).apply(null,arguments)},l._emscripten_main_browser_thread_id=function(){return(l._emscripten_main_browser_thread_id=l.asm.emscripten_main_browser_thread_id).apply(null,arguments)};var Re=l._emscripten_run_in_main_runtime_thread_js=function(){return(Re=l._emscripten_run_in_main_runtime_thread_js=l.asm.emscripten_run_in_main_runtime_thread_js).apply(null,arguments)};l._emscripten_dispatch_to_thread_=function(){return(l._emscripten_dispatch_to_thread_=l.asm.emscripten_dispatch_to_thread_).apply(null,arguments)};var Fe,Oe,Me,$e=l.__emscripten_proxy_execute_task_queue=function(){return($e=l.__emscripten_proxy_execute_task_queue=l.asm._emscripten_proxy_execute_task_queue).apply(null,arguments)},De=l.__emscripten_thread_free_data=function(){return(De=l.__emscripten_thread_free_data=l.asm._emscripten_thread_free_data).apply(null,arguments)},Pe=l.__emscripten_thread_exit=function(){return(Pe=l.__emscripten_thread_exit=l.asm._emscripten_thread_exit).apply(null,arguments)},Le=l._emscripten_stack_set_limits=function(){return(Le=l._emscripten_stack_set_limits=l.asm.emscripten_stack_set_limits).apply(null,arguments)},Be=l.stackSave=function(){return(Be=l.stackSave=l.asm.stackSave).apply(null,arguments)},Ue=l.stackRestore=function(){return(Ue=l.stackRestore=l.asm.stackRestore).apply(null,arguments)},We=l.stackAlloc=function(){return(We=l.stackAlloc=l.asm.stackAlloc).apply(null,arguments)};function Ve(e){if(!(Y>0)){if(b)return s(l),q(),void startWorker(l);!function(){if(l.preRun)for("function"==typeof l.preRun&&(l.preRun=[l.preRun]);l.preRun.length;)e=l.preRun.shift(),j.unshift(e);var e;le(j)}(),Y>0||(l.setStatus?(l.setStatus("Running..."),setTimeout((function(){setTimeout((function(){l.setStatus("")}),1),t()}),1)):t())}function t(){Fe||(Fe=!0,l.calledRun=!0,L||(q(),s(l),l.onRuntimeInitialized&&l.onRuntimeInitialized(),function(){if(!b){if(l.postRun)for("function"==typeof l.postRun&&(l.postRun=[l.postRun]);l.postRun.length;)e=l.postRun.shift(),H.unshift(e);var e;le(H)}}()))}}if(l.dynCall_iijjiiii=function(){return(l.dynCall_iijjiiii=l.asm.dynCall_iijjiiii).apply(null,arguments)},l.dynCall_jiji=function(){return(l.dynCall_jiji=l.asm.dynCall_jiji).apply(null,arguments)},l.keepRuntimeAlive=K,l.wasmMemory=A,l.cwrap=function(e,t,n,r){var a=(n=n||[]).every((e=>"number"===e||"boolean"===e));return"string"!==t&&a&&!r?Ee(e):function(){return Se(e,t,n,arguments)}},l.ExitStatus=re,l.PThread=ue,Q=function e(){Fe||Ve(),Fe||(Q=e)},l.preInit)for("function"==typeof l.preInit&&(l.preInit=[l.preInit]);l.preInit.length>0;)l.preInit.pop()();if(Ve(),u&&(Oe={uncaughtException:Xe.listeners("uncaughtException").filter((function(e){return!u.uncaughtException.indexOf(e)>-1})),unhandledRejection:Xe.listeners("unhandledRejection").filter((function(e){return!u.unhandledRejection.indexOf(e)>-1}))}),"undefined"!=typeof WasmBackendModule)Me=WasmBackendModule;else{if(void 0===t)throw new Error("Could not find wasm module in post.js");Me=t}if(Oe){var ze=Me._dispose;Me._dispose=function(){ze(),Oe.uncaughtException.forEach((function(e){Xe.removeListener("uncaughtException",e)})),Oe.unhandledRejection.forEach((function(e){Xe.removeListener("unhandledRejection",e)}))}}return t.ready}})();e.exports=n})),VI=o({__proto__:null,default:WI},[WI]),zI=ih((function(e,t){var n=(()=>{var e="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0;return e=e||"/Users/djanekovic/Code/xzimg-web-sdk/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out",function(t){var n,r,a,i=void 0!==(t=t||{})?t:{};i.ready=new Promise((function(e,t){n=e,r=t})),void 0!==Xe&&Xe.listeners&&(a={uncaughtException:Xe.listeners("uncaughtException"),unhandledRejection:Xe.listeners("unhandledRejection")});var s,o,u,l=Object.assign({},i),c="object"==typeof window,h="function"==typeof importScripts,p="object"==typeof Xe&&"object"==typeof Xe.versions&&"string"==typeof Xe.versions.node,d="";if(p){var f=ph,m=ph;d=h?m.dirname(d)+"/":"/Users/djanekovic/Code/xzimg-web-sdk/node_modules/@tensorflow/tfjs-backend-wasm/wasm-out/",s=(e,t)=>(e=P(e)?new URL(e):m.normalize(e),f.readFileSync(e,t?void 0:"utf8")),u=e=>{var t=s(e,!0);return t.buffer||(t=new Uint8Array(t)),t},o=(e,t,n)=>{e=P(e)?new URL(e):m.normalize(e),f.readFile(e,(function(e,r){e?n(e):t(r.buffer)}))},Xe.argv.length>1&&Xe.argv[1].replace(/\\/g,"/"),Xe.argv.slice(2),Xe.on("uncaughtException",(function(e){if(!(e instanceof B))throw e})),Xe.on("unhandledRejection",(function(e){throw e})),i.inspect=function(){return"[Emscripten Module object]"}}else(c||h)&&(h?d=self.location.href:"undefined"!=typeof document&&document.currentScript&&(d=document.currentScript.src),e&&(d=e),d=0!==d.indexOf("blob:")?d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):"",s=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},h&&(u=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),o=(e,t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?t(r.response):n()},r.onerror=n,r.send(null)});var g,y,b=i.print||console.log.bind(console),v=i.printErr||console.warn.bind(console);Object.assign(i,l),l=null,i.arguments&&i.arguments,i.thisProgram&&i.thisProgram,i.quit&&i.quit,i.wasmBinary&&(g=i.wasmBinary),i.noExitRuntime,"object"!=typeof WebAssembly&&$("no native wasm support detected");var w,_,x,k,T=!1,E="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function S(e,t,n){for(var r=t+n,a=t;e[a]&&!(a>=r);)++a;if(a-t>16&&e.buffer&&E)return E.decode(e.subarray(t,a));for(var i="";t<a;){var s=e[t++];if(128&s){var o=63&e[t++];if(192!=(224&s)){var u=63&e[t++];if((s=224==(240&s)?(15&s)<<12|o<<6|u:(7&s)<<18|o<<12|u<<6|63&e[t++])<65536)i+=String.fromCharCode(s);else{var l=s-65536;i+=String.fromCharCode(55296|l>>10,56320|1023&l)}}else i+=String.fromCharCode((31&s)<<6|o)}else i+=String.fromCharCode(s)}return i}function I(e){w=e,i.HEAP8=_=new Int8Array(e),i.HEAP16=new Int16Array(e),i.HEAP32=new Int32Array(e),i.HEAPU8=x=new Uint8Array(e),i.HEAPU16=new Uint16Array(e),i.HEAPU32=k=new Uint32Array(e),i.HEAPF32=new Float32Array(e),i.HEAPF64=new Float64Array(e)}i.INITIAL_MEMORY;var A,C,N=[],R=[],F=[],O=0,M=null;function $(e){i.onAbort&&i.onAbort(e),v(e="Aborted("+e+")"),T=!0,e+=". Build with -sASSERTIONS for more info.";var t=new WebAssembly.RuntimeError(e);throw r(t),t}function D(e){return e.startsWith("data:application/octet-stream;base64,")}function P(e){return e.startsWith("file://")}function L(e){try{if(e==A&&g)return new Uint8Array(g);if(u)return u(e);throw"both async and sync fetching of the wasm failed"}catch(e){$(e)}}function B(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function U(e){for(;e.length>0;)e.shift()(i)}function W(e){try{return y.grow(e-w.byteLength+65535>>>16),I(y.buffer),1}catch(e){}}D(A="tfjs-backend-wasm.wasm")||(C=A,A=i.locateFile?i.locateFile(C,d):d+C);var V=[null,[],[]];function z(e,t){var n=V[e];0===t||10===t?((1===e?b:v)(S(n,0)),n.length=0):n.push(t)}function j(e){return i["_"+e]}var G={abort:function(){$("")},emscripten_get_heap_max:function(){return 2147483648},emscripten_memcpy_big:function(e,t,n){x.copyWithin(e,t,t+n)},emscripten_resize_heap:function(e){var t=x.length,n=2147483648;if((e>>>=0)>n)return!1;let r=(e,t)=>e+(t-e%t)%t;for(var a=1;a<=4;a*=2){var i=t*(1+.2/a);if(i=Math.min(i,e+100663296),W(Math.min(n,r(Math.max(e,i),65536))))return!0}return!1},fd_close:function(e){return 52},fd_seek:function(e,t,n,r,a){return 70},fd_write:function(e,t,n,r){for(var a=0,i=0;i<n;i++){var s=k[t>>2],o=k[t+4>>2];t+=8;for(var u=0;u<o;u++)z(e,x[s+u]);a+=o}return k[r>>2]=a,0}};!function(){var e={env:G,wasi_snapshot_preview1:G};function t(e,t){var n,r=e.exports;i.asm=r,I((y=i.asm.memory).buffer),i.asm.__indirect_function_table,n=i.asm.__wasm_call_ctors,R.unshift(n),function(e){if(O--,i.monitorRunDependencies&&i.monitorRunDependencies(O),0==O&&M){var t=M;M=null,t()}}()}function n(e){t(e.instance)}function a(t){return function(){if(!g&&(c||h)){if("function"==typeof fetch&&!P(A))return fetch(A,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+A+"'";return e.arrayBuffer()})).catch((function(){return L(A)}));if(o)return new Promise((function(e,t){o(A,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return L(A)}))}().then((function(t){return WebAssembly.instantiate(t,e)})).then((function(e){return e})).then(t,(function(e){v("failed to asynchronously prepare wasm: "+e),$(e)}))}if(O++,i.monitorRunDependencies&&i.monitorRunDependencies(O),i.instantiateWasm)try{return i.instantiateWasm(e,t)}catch(e){v("Module.instantiateWasm callback failed with error: "+e),r(e)}(g||"function"!=typeof WebAssembly.instantiateStreaming||D(A)||P(A)||p||"function"!=typeof fetch?a(n):fetch(A,{credentials:"same-origin"}).then((function(t){return WebAssembly.instantiateStreaming(t,e).then(n,(function(e){return v("wasm streaming compile failed: "+e),v("falling back to ArrayBuffer instantiation"),a(n)}))}))).catch(r)}(),i.___wasm_call_ctors=function(){return(i.___wasm_call_ctors=i.asm.__wasm_call_ctors).apply(null,arguments)},i._init=function(){return(i._init=i.asm.init).apply(null,arguments)},i._init_with_threads_count=function(){return(i._init_with_threads_count=i.asm.init_with_threads_count).apply(null,arguments)},i._get_threads_count=function(){return(i._get_threads_count=i.asm.get_threads_count).apply(null,arguments)},i._register_tensor=function(){return(i._register_tensor=i.asm.register_tensor).apply(null,arguments)},i._dispose_data=function(){return(i._dispose_data=i.asm.dispose_data).apply(null,arguments)},i._dispose=function(){return(i._dispose=i.asm.dispose).apply(null,arguments)},i._Abs=function(){return(i._Abs=i.asm.Abs).apply(null,arguments)},i._Add=function(){return(i._Add=i.asm.Add).apply(null,arguments)},i._AddN=function(){return(i._AddN=i.asm.AddN).apply(null,arguments)},i._All=function(){return(i._All=i.asm.All).apply(null,arguments)},i._Any=function(){return(i._Any=i.asm.Any).apply(null,arguments)},i._ArgMax=function(){return(i._ArgMax=i.asm.ArgMax).apply(null,arguments)},i._AvgPool=function(){return(i._AvgPool=i.asm.AvgPool).apply(null,arguments)},i._BatchMatMul=function(){return(i._BatchMatMul=i.asm.BatchMatMul).apply(null,arguments)},i._Ceil=function(){return(i._Ceil=i.asm.Ceil).apply(null,arguments)},i._ClipByValue=function(){return(i._ClipByValue=i.asm.ClipByValue).apply(null,arguments)},i._Conv2D=function(){return(i._Conv2D=i.asm.Conv2D).apply(null,arguments)},i._Conv2DBackpropInput=function(){return(i._Conv2DBackpropInput=i.asm.Conv2DBackpropInput).apply(null,arguments)},i._Cos=function(){return(i._Cos=i.asm.Cos).apply(null,arguments)},i._Cosh=function(){return(i._Cosh=i.asm.Cosh).apply(null,arguments)},i._CropAndResize=function(){return(i._CropAndResize=i.asm.CropAndResize).apply(null,arguments)},i._Cumprod=function(){return(i._Cumprod=i.asm.Cumprod).apply(null,arguments)},i._Cumsum=function(){return(i._Cumsum=i.asm.Cumsum).apply(null,arguments)},i._DepthToSpace=function(){return(i._DepthToSpace=i.asm.DepthToSpace).apply(null,arguments)},i._DepthwiseConv2dNative=function(){return(i._DepthwiseConv2dNative=i.asm.DepthwiseConv2dNative).apply(null,arguments)},i._Elu=function(){return(i._Elu=i.asm.Elu).apply(null,arguments)},i._Equal=function(){return(i._Equal=i.asm.Equal).apply(null,arguments)},i._Exp=function(){return(i._Exp=i.asm.Exp).apply(null,arguments)},i._FlipLeftRight=function(){return(i._FlipLeftRight=i.asm.FlipLeftRight).apply(null,arguments)},i._Floor=function(){return(i._Floor=i.asm.Floor).apply(null,arguments)},i._FloorDiv=function(){return(i._FloorDiv=i.asm.FloorDiv).apply(null,arguments)},i._FusedBatchNorm=function(){return(i._FusedBatchNorm=i.asm.FusedBatchNorm).apply(null,arguments)},i._FusedConv2D=function(){return(i._FusedConv2D=i.asm.FusedConv2D).apply(null,arguments)},i._FusedDepthwiseConv2D=function(){return(i._FusedDepthwiseConv2D=i.asm.FusedDepthwiseConv2D).apply(null,arguments)},i._Gather=function(){return(i._Gather=i.asm.Gather).apply(null,arguments)},i._GatherNd=function(){return(i._GatherNd=i.asm.GatherNd).apply(null,arguments)},i._Greater=function(){return(i._Greater=i.asm.Greater).apply(null,arguments)},i._GreaterEqual=function(){return(i._GreaterEqual=i.asm.GreaterEqual).apply(null,arguments)},i._IsNan=function(){return(i._IsNan=i.asm.IsNan).apply(null,arguments)},i._LeakyRelu=function(){return(i._LeakyRelu=i.asm.LeakyRelu).apply(null,arguments)},i._Less=function(){return(i._Less=i.asm.Less).apply(null,arguments)},i._LessEqual=function(){return(i._LessEqual=i.asm.LessEqual).apply(null,arguments)},i._Log=function(){return(i._Log=i.asm.Log).apply(null,arguments)},i._LogicalAnd=function(){return(i._LogicalAnd=i.asm.LogicalAnd).apply(null,arguments)},i._LogicalNot=function(){return(i._LogicalNot=i.asm.LogicalNot).apply(null,arguments)},i._LogicalOr=function(){return(i._LogicalOr=i.asm.LogicalOr).apply(null,arguments)},i._LogicalXor=function(){return(i._LogicalXor=i.asm.LogicalXor).apply(null,arguments)},i._Max=function(){return(i._Max=i.asm.Max).apply(null,arguments)},i._MaxPool=function(){return(i._MaxPool=i.asm.MaxPool).apply(null,arguments)},i._Maximum=function(){return(i._Maximum=i.asm.Maximum).apply(null,arguments)},i._Mean=function(){return(i._Mean=i.asm.Mean).apply(null,arguments)},i._Min=function(){return(i._Min=i.asm.Min).apply(null,arguments)},i._Minimum=function(){return(i._Minimum=i.asm.Minimum).apply(null,arguments)},i._MirrorPad=function(){return(i._MirrorPad=i.asm.MirrorPad).apply(null,arguments)},i._Multiply=function(){return(i._Multiply=i.asm.Multiply).apply(null,arguments)},i._Neg=function(){return(i._Neg=i.asm.Neg).apply(null,arguments)},i._NonMaxSuppressionV3=function(){return(i._NonMaxSuppressionV3=i.asm.NonMaxSuppressionV3).apply(null,arguments)},i._NonMaxSuppressionV4=function(){return(i._NonMaxSuppressionV4=i.asm.NonMaxSuppressionV4).apply(null,arguments)},i._NonMaxSuppressionV5=function(){return(i._NonMaxSuppressionV5=i.asm.NonMaxSuppressionV5).apply(null,arguments)},i._NotEqual=function(){return(i._NotEqual=i.asm.NotEqual).apply(null,arguments)},i._OneHot=function(){return(i._OneHot=i.asm.OneHot).apply(null,arguments)},i._PadV2=function(){return(i._PadV2=i.asm.PadV2).apply(null,arguments)},i._Pow=function(){return(i._Pow=i.asm.Pow).apply(null,arguments)},i._Prelu=function(){return(i._Prelu=i.asm.Prelu).apply(null,arguments)},i._Prod=function(){return(i._Prod=i.asm.Prod).apply(null,arguments)},i._RealDiv=function(){return(i._RealDiv=i.asm.RealDiv).apply(null,arguments)},i._Reciprocal=function(){return(i._Reciprocal=i.asm.Reciprocal).apply(null,arguments)},i._Relu=function(){return(i._Relu=i.asm.Relu).apply(null,arguments)},i._Relu6=function(){return(i._Relu6=i.asm.Relu6).apply(null,arguments)},i._ResizeBilinear=function(){return(i._ResizeBilinear=i.asm.ResizeBilinear).apply(null,arguments)},i._ResizeNearestNeighbor=function(){return(i._ResizeNearestNeighbor=i.asm.ResizeNearestNeighbor).apply(null,arguments)},i._Reverse=function(){return(i._Reverse=i.asm.Reverse).apply(null,arguments)},i._RotateWithOffset=function(){return(i._RotateWithOffset=i.asm.RotateWithOffset).apply(null,arguments)},i._Round=function(){return(i._Round=i.asm.Round).apply(null,arguments)},i._Rsqrt=function(){return(i._Rsqrt=i.asm.Rsqrt).apply(null,arguments)},i._ScatterNd=function(){return(i._ScatterNd=i.asm.ScatterNd).apply(null,arguments)},i._SelectV2=function(){return(i._SelectV2=i.asm.SelectV2).apply(null,arguments)},i._Sigmoid=function(){return(i._Sigmoid=i.asm.Sigmoid).apply(null,arguments)},i._Sin=function(){return(i._Sin=i.asm.Sin).apply(null,arguments)},i._Softmax=function(){return(i._Softmax=i.asm.Softmax).apply(null,arguments)},i._SparseFillEmptyRows=function(){return(i._SparseFillEmptyRows=i.asm.SparseFillEmptyRows).apply(null,arguments)},i._SparseReshape=function(){return(i._SparseReshape=i.asm.SparseReshape).apply(null,arguments)},i._SparseSegmentReduction=function(){return(i._SparseSegmentReduction=i.asm.SparseSegmentReduction).apply(null,arguments)},i._Sqrt=function(){return(i._Sqrt=i.asm.Sqrt).apply(null,arguments)},i._Square=function(){return(i._Square=i.asm.Square).apply(null,arguments)},i._SquaredDifference=function(){return(i._SquaredDifference=i.asm.SquaredDifference).apply(null,arguments)},i._Step=function(){return(i._Step=i.asm.Step).apply(null,arguments)},i._StridedSlice=function(){return(i._StridedSlice=i.asm.StridedSlice).apply(null,arguments)},i._Sub=function(){return(i._Sub=i.asm.Sub).apply(null,arguments)},i._Sum=function(){return(i._Sum=i.asm.Sum).apply(null,arguments)},i._Tan=function(){return(i._Tan=i.asm.Tan).apply(null,arguments)},i._Tanh=function(){return(i._Tanh=i.asm.Tanh).apply(null,arguments)},i._Tile=function(){return(i._Tile=i.asm.Tile).apply(null,arguments)},i._TopK=function(){return(i._TopK=i.asm.TopK).apply(null,arguments)},i._Transform=function(){return(i._Transform=i.asm.Transform).apply(null,arguments)},i._Transpose=function(){return(i._Transpose=i.asm.Transpose).apply(null,arguments)},i.__FusedMatMul=function(){return(i.__FusedMatMul=i.asm._FusedMatMul).apply(null,arguments)},i._malloc=function(){return(i._malloc=i.asm.malloc).apply(null,arguments)},i._free=function(){return(i._free=i.asm.free).apply(null,arguments)},i.___errno_location=function(){return(i.___errno_location=i.asm.__errno_location).apply(null,arguments)};var H,K,q,X=i.stackSave=function(){return(X=i.stackSave=i.asm.stackSave).apply(null,arguments)},Y=i.stackRestore=function(){return(Y=i.stackRestore=i.asm.stackRestore).apply(null,arguments)},Q=i.stackAlloc=function(){return(Q=i.stackAlloc=i.asm.stackAlloc).apply(null,arguments)};function J(e){function t(){H||(H=!0,i.calledRun=!0,T||(U(R),n(i),i.onRuntimeInitialized&&i.onRuntimeInitialized(),function(){if(i.postRun)for("function"==typeof i.postRun&&(i.postRun=[i.postRun]);i.postRun.length;)e=i.postRun.shift(),F.unshift(e);var e;U(F)}()))}O>0||(function(){if(i.preRun)for("function"==typeof i.preRun&&(i.preRun=[i.preRun]);i.preRun.length;)e=i.preRun.shift(),N.unshift(e);var e;U(N)}(),O>0||(i.setStatus?(i.setStatus("Running..."),setTimeout((function(){setTimeout((function(){i.setStatus("")}),1),t()}),1)):t()))}if(i.dynCall_iijjiiii=function(){return(i.dynCall_iijjiiii=i.asm.dynCall_iijjiiii).apply(null,arguments)},i.dynCall_jiji=function(){return(i.dynCall_jiji=i.asm.dynCall_jiji).apply(null,arguments)},i.cwrap=function(e,t,n,r){var a=(n=n||[]).every((e=>"number"===e||"boolean"===e));return"string"!==t&&a&&!r?j(e):function(){return function(e,t,n,r,a){var i={string:e=>{var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);!function(e,t,n){!function(e,t,n,r){if(!(r>0))return 0;for(var a=n+r-1,i=0;i<e.length;++i){var s=e.charCodeAt(i);if(s>=55296&&s<=57343&&(s=65536+((1023&s)<<10)|1023&e.charCodeAt(++i)),s<=127){if(n>=a)break;t[n++]=s}else if(s<=2047){if(n+1>=a)break;t[n++]=192|s>>6,t[n++]=128|63&s}else if(s<=65535){if(n+2>=a)break;t[n++]=224|s>>12,t[n++]=128|s>>6&63,t[n++]=128|63&s}else{if(n+3>=a)break;t[n++]=240|s>>18,t[n++]=128|s>>12&63,t[n++]=128|s>>6&63,t[n++]=128|63&s}}t[n]=0}(e,x,t,n)}(e,t=Q(n),n)}return t},array:e=>{var t=Q(e.length);return function(e,t){_.set(e,t)}(e,t),t}},s=j(e),o=[],u=0;if(r)for(var l=0;l<r.length;l++){var c=i[n[l]];c?(0===u&&(u=X()),o[l]=c(r[l])):o[l]=r[l]}return function(e){return 0!==u&&Y(u),function(e){return"string"===t?(n=e)?S(x,n,void 0):"":"boolean"===t?Boolean(e):e;var n}(e)}(s.apply(null,o))}(e,t,n,arguments)}},M=function e(){H||J(),H||(M=e)},i.preInit)for("function"==typeof i.preInit&&(i.preInit=[i.preInit]);i.preInit.length>0;)i.preInit.pop()();if(J(),a&&(K={uncaughtException:Xe.listeners("uncaughtException").filter((function(e){return!a.uncaughtException.indexOf(e)>-1})),unhandledRejection:Xe.listeners("unhandledRejection").filter((function(e){return!a.unhandledRejection.indexOf(e)>-1}))}),void 0!==t)q=t;else{if("undefined"==typeof WasmBackendModuleThreadedSimd)throw new Error("Could not find wasm module in post.js");q=WasmBackendModuleThreadedSimd}if(K){var Z=q._dispose;q._dispose=function(){Z(),K.uncaughtException.forEach((function(e){Xe.removeListener("uncaughtException",e)})),K.unhandledRejection.forEach((function(e){Xe.removeListener("unhandledRejection",e)}))}}return t.ready}})();e.exports=n}));const jI=WI||VI,GI=zI||o({__proto__:null,default:zI},[zI]);class HI extends Qe{constructor(e){super(),this.wasm=e,this.dataIdNextNumber=1,this.wasm.tfjs.initWithThreadsCount(eA),tA=this.wasm.tfjs.getThreadsCount(),this.dataIdMap=new Ye(this,So())}write(e,t,n){const r={id:this.dataIdNextNumber++};return this.move(r,e,t,n,1),r}numDataIds(){return this.dataIdMap.numDataIds()}async time(e){const t=Aa();return e(),{kernelMs:Aa()-t}}move(e,t,n,r,a){const i=this.dataIdNextNumber++;if("string"===r){const s=t;return void this.dataIdMap.set(e,{id:i,stringBytes:s,shape:n,dtype:r,memoryOffset:null,refCount:a})}const s=it(n),o=s*yt(r),u=this.wasm._malloc(o);this.dataIdMap.set(e,{id:i,memoryOffset:u,shape:n,dtype:r,refCount:a}),this.wasm.tfjs.registerTensor(i,s,u),null!=t&&this.wasm.HEAPU8.set(new Uint8Array(t.buffer,t.byteOffset,o),u)}async read(e){return this.readSync(e)}readSync(e,t,n){const{memoryOffset:r,dtype:a,shape:i,stringBytes:s}=this.dataIdMap.get(e);if("string"===a)return null!=t&&0!==t||!(null==n||n>=s.length)?s.slice(t,n):s;t=t||0,n=n||it(i);const o=yt(a);return function(e,t){switch(t){case"float32":return new Float32Array(e);case"int32":return new Int32Array(e);case"bool":return new Uint8Array(e);default:throw new Error(`Unknown dtype ${t}`)}}(this.wasm.HEAPU8.slice(r+t*o,r+n*o).buffer,a)}disposeData(e,t=!1){if(this.dataIdMap.has(e)){const n=this.dataIdMap.get(e);if(n.refCount--,!t&&n.refCount>0)return!1;this.wasm._free(n.memoryOffset),this.wasm.tfjs.disposeData(n.id),this.dataIdMap.delete(e)}return!0}refCount(e){return this.dataIdMap.has(e)?this.dataIdMap.get(e).refCount:0}incRef(e){const t=this.dataIdMap.get(e);null!=t&&t.refCount++}floatPrecision(){return 32}getMemoryOffset(e){return this.dataIdMap.get(e).memoryOffset}dispose(){this.wasm.tfjs.dispose(),"PThread"in this.wasm&&this.wasm.PThread.terminateAllThreads(),this.wasm=null}memory(){return{unreliable:!1}}makeOutput(e,t,n){let r;if(null==n)r=this.write(null,e,t);else{const a=this.dataIdNextNumber++;r={id:a},this.dataIdMap.set(r,{id:a,memoryOffset:n,shape:e,dtype:t,refCount:1});const i=it(e);this.wasm.tfjs.registerTensor(a,i,n)}return{dataId:r,shape:e,dtype:t}}typedArrayFromHeap({shape:e,dtype:t,dataId:n}){const r=this.wasm.HEAPU8.buffer,{memoryOffset:a}=this.dataIdMap.get(n),i=it(e);switch(t){case"float32":return new Float32Array(r,a,i);case"int32":return new Int32Array(r,a,i);case"bool":return new Uint8Array(r,a,i);default:throw new Error(`Unknown dtype ${t}`)}}}function KI(e,t,n){let r="tfjs-backend-wasm.wasm";return e&&t?r="tfjs-backend-wasm-threaded-simd.wasm":e&&(r="tfjs-backend-wasm-simd.wasm"),null!=YI&&null!=YI[r]?YI[r]:n+r}const qI=["tfjs-backend-wasm.wasm","tfjs-backend-wasm-simd.wasm","tfjs-backend-wasm-threaded-simd.wasm"];let XI=null,YI={},QI=!1,JI=!1;function ZI(e,t=!1){if(QI)throw new Error("The WASM backend was already initialized. Make sure you call `setWasmPaths()` before you call `tf.setBackend()` or `tf.ready()`");if("string"==typeof e)XI=e;else{YI=e;const t=qI.filter((e=>null==YI[e]));if(t.length>0)throw new Error(`There were no entries found for the following binaries: ${t.join(",")}. Please either call setWasmPaths with a map providing a path for each binary, or with a string indicating the directory where all the binaries can be found.`)}JI=t}let eA=-1,tA=null;Fo("wasm",(async()=>{const{wasm:e}=await async function(){const[e,t]=await Promise.all([Mt().getAsync("WASM_HAS_SIMD_SUPPORT"),Mt().getAsync("WASM_HAS_MULTITHREAD_SUPPORT")]);return new Promise(((n,r)=>{const a={locateFile:(n,r)=>{if(n.endsWith(".worker.js")){const e='"use strict";var Module={};var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";if(ENVIRONMENT_IS_NODE){var nodeWorkerThreads=require("worker_threads");var parentPort=nodeWorkerThreads.parentPort;parentPort.on("message",data=>onmessage({data:data}));var fs=require("fs");Object.assign(global,{self:global,require:require,Module:Module,location:{href:__filename},Worker:nodeWorkerThreads.Worker,importScripts:function(f){(0,eval)(fs.readFileSync(f,"utf8")+"//# sourceURL="+f)},postMessage:function(msg){parentPort.postMessage(msg)},performance:global.performance||{now:function(){return Date.now()}}})}var initializedJS=false;var pendingNotifiedProxyingQueues=[];function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");if(ENVIRONMENT_IS_NODE){fs.writeSync(2,text+"\n");return}console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=(info,receiveInstance)=>{var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};self.onunhandledrejection=e=>{throw e.reason??e};self.startWorker=instance=>{Module=instance;postMessage({"cmd":"loaded"})};self.onmessage=e=>{try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;for(const handler of e.data.handlers){Module[handler]=function(){postMessage({cmd:"callHandler",handler:handler,args:[...arguments]})}}Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob=="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}WasmBackendModuleThreadedSimd(Module)}else if(e.data.cmd==="run"){Module["__emscripten_thread_init"](e.data.pthread_ptr,0,0,1);Module["establishStackSpace"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInitTLS();if(!initializedJS){pendingNotifiedProxyingQueues.forEach(queue=>{Module["executeNotifiedProxyingQueue"](queue)});pendingNotifiedProxyingQueues=[];initializedJS=true}try{Module["invokeEntryPoint"](e.data.start_routine,e.data.arg)}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processProxyingQueue"){if(initializedJS){Module["executeNotifiedProxyingQueue"](e.data.queue)}else{pendingNotifiedProxyingQueues.push(e.data.queue)}}else if(e.data.cmd){err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){if(Module["__emscripten_thread_crashed"]){Module["__emscripten_thread_crashed"]()}throw ex}};'.replace(/\n/g,"\\n"),t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}return n.endsWith(".wasm")?KI(e,t,null!=XI?XI:r):r+n}};JI&&(a.instantiateWasm=function(e){return(t,n)=>(function(e,t){return Mt().platform.fetch(e,{credentials:"same-origin"})}(e).then((r=>{r.ok||t.env.a(`failed to load wasm binary file at '${e}'`),r.arrayBuffer().then((e=>{WebAssembly.instantiate(e,t).then((e=>{n(e.instance,e.module)}))}))})),{})}(KI(e,t,null!=XI?XI:"")));let i,s=!1;a.onAbort=()=>{s||QI||(QI=!0,r({message:"Make sure the server can serve the `.wasm` file relative to the bundled js file. For more details see https://github.com/tensorflow/tfjs/blob/master/tfjs-backend-wasm/README.md#using-bundlers"}))},t&&e?(a.mainScriptUrlOrBlob=new Blob(["var WasmBackendModuleThreadedSimd = "+jI.toString()],{type:"text/javascript"}),i=jI(a)):i=GI(a),i.then((e=>{s=!0,QI=!1,e.tfjs={init:e.cwrap("init",null,[]),initWithThreadsCount:e.cwrap("init_with_threads_count",null,["number"]),getThreadsCount:e.cwrap("get_threads_count","number",[]),registerTensor:e.cwrap("register_tensor",null,["number","number","number"]),disposeData:e.cwrap("dispose_data",null,["number"]),dispose:e.cwrap("dispose",null,[])},n({wasm:e})})).catch(r)}))}();return new HI(e)}),2);var nA={modelFilename:"",featuresFilename:"",objFilename:"",fovY:50,detectScoreThs:.2,trackScoreThs:.4,footToDetect:"RIGHT_FOOT",filteringLevel:2,filteringShift:.5,validTrackedKeypThs:.2,trackedNumKeypsThs:3,activeIds:new Int32Array};function rA(e){return!!(void 0===e.outputNames||e.outputNames.length<1||e.outputNames.includes("heatmaps"))}function aA(e,t){for(var n=1e4,r=1e4,a=-1e4,i=-1e4,s=0;s<t;s++){var o=e[s],u=e[t+s];o>a&&(a=o),u>i&&(i=u),o<n&&(n=o),u<r&&(r=u)}return[Math.floor(n),Math.floor(a+1),Math.floor(r),Math.floor(i+1)]}function iA(e,t,n){for(var r=1e4,a=1e4,i=-1e4,s=-1e4,o=0;o<n;o++)if(t[o]>0){var u=e[o],l=e[n+o];u>i&&(i=u),l>s&&(s=l),u<r&&(r=u),l<a&&(a=l)}return[Math.floor(r),Math.floor(i+1),Math.floor(a),Math.floor(s+1)]}function sA(e,t){void 0===t&&(t=.1);for(var n=e.length,r=0,a=0,i=new Int32Array(n),s=0;s<n;s++)e[s]>t?(a+=1,i[s]=1,r+=e[s]):i[s]=0;return a>0?r/=a:r=0,{globalScore:r,visibilty:i,totalVisible:a}}function oA(e,t){void 0===t&&(t=.1);for(var n=e.length,r=new Int32Array(n),a=0;a<n;a++)e[a]>t?r[a]=1:r[a]=0;return r}function uA(e,t,n,r){for(var a=new Uint8ClampedArray(e*t*4),i=e*t,s=0;s<i;s++){var o=s*n,u=4*s;a[u+0]=1*r[o+0],a[u+1]=1*r[o+1],a[u+2]=1*r[o+2],a[u+3]=255}return new ImageData(a,t,e)}function lA(e,t,n,r){var a=Float32Array.from(e),i=e.length/2;if(n)for(var s=0;s<i;s++)a[s+i]=r-1-a[s+i];for(s=0;s<i;s++){var o=a[s],u=a[s+i];a[s]=t[0]*o+t[1]*u+t[2],a[s+i]=t[3]*o+t[4]*u+t[5]}return a}function cA(e,t){if("UPPER-BODY"==e){if(15==t)return[13,14]}else if("FULL-BODY"==e){if(19==t)return[17,18]}else if("FACE"==e){if(68==t)return[36,45];if(19==t)return[8,13];if(21==t)return[10,15]}else{if(5==t)return[1,2];if(14==t)return[1,7];if(20==t)return[2,12];if(7==t)return[0,6];if(19==t)return[10,15];if(9==t)return[1,6];if(23==t)return[0,14];if(181==t)return[30,163];if(21==t)return[0,9];if(10==t)return[7,8];if(8==t)return[5,6];if(11==t)return[7,8]}return console.time("==> (E) Incorrect number of vertices"),[0,1]}function hA(e,t){var n=t.length/2,r=cA(e,n),a=r[0],i=r[1],s=[t[a],t[a+n]],o=[t[i],t[i+n]],u=[(s[0]+o[0])/2,(s[1]+o[1])/2],l=-Math.atan2(s[1]-o[1],o[0]-s[0]);return[u[0],u[1],l]}var pA,dA=function(){function e(e,t){this.x=e,this.y=t}return e.prototype.Dist=function(e){return Math.sqrt((e.x-this.x)*(e.x-this.x)+(e.y-this.y)*(e.y-this.y))},e}(),fA=function(){function e(e,t){this.x=e,this.y=t}return e.prototype.Dist=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.CreateFromPoints=function(t,n){return new e(n.x-t.x,n.y-t.y)},e}(),mA=function(){function e(e,t,n,r){this.x=e,this.y=t,this.w=n,this.h=r}return e.prototype.Centre=function(){return new dA(this.x+this.w/2,this.y+this.h/2)},e.prototype.isPointInside=function(e){return e.x>=this.x&&e.x>=this.x&&e.x<this.x+this.w&&e.y<this.y+this.h},e}();function gA(e,t,n,r,a){void 0===a&&(a=.5);for(var i=e.length/2,s=iA(e,t,i),o=Math.max(s[1]-s[0],s[3]-s[2])/6,u=0;u<i;u++)if(t[u]<=0&&r[u]>0)e[u]=n[u],e[u+i]=n[u+i];else if(t[u]>0&&r[u]<=0);else if(t[u]>0&&r[u]>0){var l=Math.sqrt((n[u]-e[u])*(n[u]-e[u])+(n[u+i]-e[u+i])*(n[u+i]-e[u+i])),c=(1-a)*Math.exp(-.5*l*l/o);e[u]=c*n[u]+(1-c)*e[u],e[u+i]=c*n[u+i]+(1-c)*e[u+i]}return e}function yA(e,t){e.length;var n=function(e,t){var n=e.length/2,r=wA(n,t),a=r[0],i=r[1],s=[e[a],e[a+n]],o=[e[i],e[i+n]],u=[(s[0]+o[0])/2,(s[1]+o[1])/2],l=-Math.atan2(s[1]-o[1],o[0]-s[0]),c=Math.sqrt((s[0]-o[0])*(s[0]-o[0])+(s[1]-o[1])*(s[1]-o[1]));return[u[0],u[1],l,c]}(e,t),r=n[0],a=n[1],i=n[2],s=n[3],o=[Math.cos(i),Math.sin(i)],u=[-o[1],o[0]],l=s/1,c=s/2;return[r+o[0]*l+u[0]*c,a+o[1]*l+u[1]*c,r+o[0]*l-u[0]*c,a+o[1]*l-u[1]*c,r-o[0]*l-u[0]*c,a-o[1]*l-u[1]*c,r-o[0]*l+u[0]*c,a-o[1]*l+u[1]*c]}function bA(e,t,n){if(void 0===n&&(n=.1),6==e.length){for(var r=0,a=new Int32Array(3),i=0,s="RIGHT_FOOT"==t?3:0,o=s;o<s+3;o++)r+=e[o],e[o]>n&&(i+=1,a[o]=1);return{globalScore:r/=3,visibilty:a,totalVisible:i}}return sA(e,n)}function vA(e,t,n,r){var a=Float32Array.from(e),i=e.length/2;if(n)for(var s=0;s<i;s++)a[s+i]=r-1-a[s+i];for(s=0;s<i;s++){var o=a[s],u=a[s+i];a[s]=t[0]*o+t[1]*u+t[2],a[s+i]=t[3]*o+t[4]*u+t[5]}return a}function wA(e,t){if(void 0===t&&(t="face"),"face"==t){if(5==e)return[0,1];if(19==e)return[6,11];if(21==e)return[17,20];if(51==e)return[19,28];if(68==e)return[36,45];if(16==e)return[6,9]}return"eye"==t?[0,1]:6==e&&"RIGHT_FOOT"==t?[3,5]:6==e&&"LEFT_FOOT"==t?[0,2]:18!=e||"RIGHT_FOOT"!=t&&"LEFT_FOOT"!=t?13!=e||"RIGHT_FOOT"!=t&&"LEFT_FOOT"!=t?593!=e||"RIGHT_FOOT"!=t&&"LEFT_FOOT"!=t?200!=e||"RIGHT_FOOT"!=t&&"LEFT_FOOT"!=t?(console.error("no type or number of feature match"),[0,1]):[115,167]:[210,78]:[0,6]:[0,9]}function _A(e,t){var n=e.length/2,r=wA(n,t),a=r[0],i=r[1],s=[e[a],e[a+n]],o=[e[i],e[i+n]],u=[(s[0]+o[0])/2,(s[1]+o[1])/2],l=-Math.atan2(s[1]-o[1],o[0]-s[0]);return[u[0],u[1],l]}function xA(e,t,n){for(var r=n[0],a=n[1],i=n[2],s=n[3],o=n[4],u=n[5],l=e.width,c=e.height,h=4*e.width,p=t.width,d=t.height,f=4*t.width,m=0;m<d;m++)for(var g=a*m+i,y=o*m+u,b=m*f,v=0;v<p;v++){var w=4*v,_=Math.floor(g),x=Math.floor(y),k=g-_,T=y-x,E=void 0,S=void 0;if(_>0&&_<l-1&&x>0&&x<c-1){for(var I=x*h+4*_,A=0;A<3;A++,I++){var C=e.data[I];E=C+k*(e.data[I+4]-C),S=e.data[I+h]+k*(e.data[I+h+4]-e.data[I+h]),t.data[b+w+A]=E+T*(S-E)}t.data[b+w+3]=255}else{for(A=0;A<3;A++)t.data[b+w+A]=0;t.data[b+w+3]=255}g+=r,y+=s}return t}function kA(e,t,n,r,a,i){var s,o,u=e.length/2,l=0,c=0,h=0;6==u?(c=(s=_A(e,i))[0],l=s[1],h=s[2],aA("RIGHT_FOOT"==i?[e[3],e[4],e[5],e[3+u],e[4+u],e[5+u]]:[e[0],e[1],e[2],e[0+u],e[1+u],e[2+u]],3)):(c=(o=_A(e,i))[0],l=o[1],h=o[2],iA(e,t,u));var p=Math.cos(h),d=Math.sin(h),f=wA(u,i),m=f[0],g=f[1],y=[e[m],e[m+u]],b=[e[g],e[g+u]],v=Math.sqrt((y[0]-b[0])*(y[0]-b[0])+(y[1]-b[1])*(y[1]-b[1])),w=(v+=.5*v)/Math.max(r,n),_=(n-1)/2,x=(r-1)/2,k=c-(p*w*_-d*w*x),T=l-(d*w*_+p*w*x);if(null!=a){var E=Math.sqrt((k-a[2])*(k-a[2])+(T-a[5])*(T-a[5])),S=1;E>20&&(S=.1),E>=10&&E<=20&&(S=1-.09*(E-5)),k=(1-S)*k+S*a[2],T=(1-S)*T+S*a[5],h=Math.abs(h-a[6])>1?(1-S)*h-S*a[6]:(1-S)*h+S*a[6],w=(1-S)*w+S*a[7],p=Math.cos(h),d=Math.sin(h)}return[p*w,-d*w,k,d*w,p*w,T,h,w]}function TA(e,t){var n=t.length,r=e._malloc(4*n),a=r/4;return e.HEAPF32.subarray(a,a+n).set(t),r}function EA(e,t){var n=e._malloc(4*t.length);return e.HEAPF32.set(t,n/4),n}function SA(e,t,n){var r=new Float32Array(n),a=t/4;return r.set(e.HEAPF32.subarray(a,a+n)),r.slice()}function IA(e,t,n){var r=new Uint32Array(t.data.buffer),a=r.length,i=n/4;e.HEAPU32.subarray(i,i+a).set(r)}function AA(e,t,n,r){var a=e._malloc(28);return e.setValue(a,n,"i32"),e.setValue(a+4,r,"i32"),e.setValue(a+8,t,"i32"),e.setValue(a+12,0,"i32"),e.setValue(a+16,4,"i32"),e.setValue(a+20,0,"i32"),e.setValue(a+24,0,"i32"),a}function CA(e,t,n,r,a){var i=e.cwrap("xzimgMatchRecKeyps","number",["number","number","number","number","number"]),s=r.length/2;IA(e,t,n);for(var o=AA(e,n,t.width,t.height),u=EA(e,r),l=EA(e,r.slice()),c=e._malloc(4*s),h=0;h<s;h++)e.setValue(c+4*h,1,"float"),a.length>h&&0==a[h]&&e.setValue(c+4*h,-1,"float");var p=e._malloc(16);i(o,u,l,s,c,p);var d=SA(e,c,s),f=SA(e,l,r.length),m=SA(e,p,4);for(h=0;h<s;h++)0==d[h]&&(f[h]=r[h],f[h+s]=r[h+s]);return e._free(o),e._free(u),e._free(l),e._free(c),e._free(p),[f,m,d]}function NA(e,t,n,r){var a=EA(e,t),i=EA(e,n),s=e._malloc(16);e.cwrap("xzimgEstimateGetSimilarity","number",["number","number","number","number"])(a,i,t.length/2,s);var o=SA(e,s,4);return e._free(a),e._free(i),e._free(s),o}function RA(e,t,n){void 0===n&&(n=null);for(var r=new Float32Array(2),a=e.length/2,i=0,s=0;s<a;s++)(null==n||n[s]>0)&&(r[0]+=t[s]-e[s],r[1]+=t[s+a]-e[s+a],i+=1);return i>0&&(r[0]/=i,r[1]/=i),r}function FA(e,t,n){var r,a,i,s,o;void 0===n&&(n=!0);var u=n?1:2;return r=function(e,t,n,r,a){void 0===a&&(a=1);var i=new Float32Array(r).fill(0),s=new Float32Array(2*r);if(1==a)for(var o=t*n,u=0;u<o;u++)for(var l=0;l<r;l++)(p=e[u*r+l])>i[l]&&(i[l]=p,s[l]=u%n,s[r+l]=Math.floor(u/n));else{var c=n*a;for(u=a;u<t;u+=a,c+=n*a)for(var h=a;h<n;h+=a)for(l=0;l<r;l++){var p;(p=e[(c+h)*r+l])>i[l]&&(i[l]=p,s[l]=h,s[r+l]=u)}}return[s,i]}(e,t[1],t[2],t[3],u),i=r[0],o=r[1],n?(a=function(e,t,n,r,a){for(var i=[-r*a-a,-r*a,-r*a+a,-a,0,a,r*a-a,r*a,r*a+a],s=new Float32Array(a),o=new Float32Array(2*a),u=0;u<a;u++){var l=t[u],c=t[a+u];o[u]=l,o[a+u]=c;var h=c*r*a+l*a+u,p=0;p=0;for(var d=0;d<9;d++)p+=e[h+i[d]];p/=9,s[u]=p;var f=Math.min(l+2,r-1),m=Math.max(l-2,0),g=Math.min(c+2,n-1),y=Math.max(c-2,0),b=0,v=0,w=c*r*a+m*a+u,_=c*r*a+f*a+u;for(d=0;d<9;d++)b+=e[w+i[d]],v+=e[_+i[d]];var x=2*(2*p-((b/=9)+(v/=9)));if(Math.abs(x)>1e-5){var k=2*(v-b)/x;o[u]+=k}var T=0,E=0,S=y*r*a+l*a+u,I=g*r*a+l*a+u;for(d=0;d<9;d++)T+=e[S+i[d]],E+=e[I+i[d]];x=2*(2*p-((T/=9)+(E/=9))),Math.abs(x)>1e-5&&(k=2*(E-T)/x,o[a+u]+=k)}return[o,s]}(e,i,t[1],t[2],t[3]),s=a[0],o=a[1]):s=i,[s,o]}function OA(e,t,n,r,a,i){var s=e.cwrap("xzimgGetHeatmapsLocations","number",["number","number","number","number","number","number","number","number"]),o=t[1]*t[2]*t[3],u=r/4;return e.HEAPF32.subarray(u,u+o).set(n),s(r,t[1],t[2],t[3],0,1,a,i),[new Float32Array(e.HEAPF32.buffer,a,2*t[3]),new Float32Array(e.HEAPF32.buffer,i,t[3])]}function MA(e,t){var n=new pe(0),r=n.asObservable();if("string"==typeof e)return{model$:a=Rx({url:e,method:"GET",responseType:"text",async:!0,progressSubscriber:new I((function(e){return n.next(e.loaded/e.total)}),(function(e){}),(function(){return n.next(1)}))}).pipe(de(2),J((function(e){return $A(e.response,t)}))),progress$:r};var a=ke((function(){return n.next(1),Q($A(function(e){var t,n,r="",a=0,i=new Uint8Array(e);for(a=0;a<i.length;a++)if(i[a]<128)r+=String.fromCharCode(i[a]);else{i[a]<224?(t=(63&i[a])<<6,n=a+1):i[a]<240?(t=(31&i[a])<<12,n=a+2):i[a]<248?(t=(15&i[a])<<18,n=a+3):i[a]<252?(t=(7&i[a])<<24,n=a+4):(t=(3&i[a])<<30,n=a+5);do{t|=(127&i[++a])<<6*(n-a)}while(a!=n);r+=String.fromCharCode(t)}return r}(e),t))}));return{model$:a,progress$:r}}function $A(e,t){var n,r,a,i,s={vertices:new Float32Array,uvs:new Float32Array,faces:new Uint16Array},o=e.match(/^v\s+(-?\d+(?:\.\d+)?\s+){2}-?\d+(?:\.\d+)?$/gm);if(o){var u=o.map((function(e){var t=e.split(" ");return t.shift(),t.map((function(e){return+e}))})),l=(n=[]).concat.apply(n,u);s.vertices=new Float32Array(l)}var c=e.match(/^vt( -?\d+(\.\d+)?){2}$/gm);if(c){var h=c.map((function(e){var t=e.split(" ");return t.shift(),t.map((function(e){return+e}))})),p=(r=[]).concat.apply(r,h);s.uvs=new Float32Array(p)}var d=e.match(/^f( \d+\/\d*\/\d*){3}$/gm);if(d){var f=d.map((function(e){var t=e.split(" ");return t.shift(),[+t[0].split("/")[0]-1,+t[1].split("/")[0]-1,+t[2].split("/")[0]-1]})),m=(a=[]).concat.apply(a,f);if(s.faces=new Uint16Array(m),t){var g=d.map((function(e){var t=e.split(" ");return t.shift(),[+t[0].split("/")[1]-1,+t[1].split("/")[1]-1,+t[2].split("/")[1]-1]})),y=new Uint16Array((i=[]).concat.apply(i,g)),b=s.uvs;s.uvs=new Float32Array(b.length);for(var v=0;v<y.length;v++){var w=y[v],_=b[2*w],x=b[2*w+1],k=s.faces[v];s.uvs[2*k]=_,s.uvs[2*k+1]=x}}}if(t){for(v=0;v<s.faces.length;v+=3){var T=s.faces[v];s.faces[v]=s.faces[v+1],s.faces[v+1]=T}for(v=0;v<s.vertices.length;v+=3)s.vertices[v]=-s.vertices[v]}return s}!function(e){e.Detection="DETECTION",e.Detected="DETECTED",e.Tracking="TRACKING"}(pA||(pA={}));var DA,PA=function(){function e(e,t){this._trackingState=pA.Detection,this._type=0,this._R=Float32Array.from(e),this._t=Float32Array.from(t),this._trackingState=pA.Detection}return e.prototype.setTrackingState=function(e){this._trackingState=e},e.prototype.getTrackingState=function(){return this._trackingState},e.prototype.isDetected=function(){return this._trackingState==pA.Tracking},Object.defineProperty(e.prototype,"type",{get:function(){return this._type},set:function(e){this._type=e},enumerable:!1,configurable:!0}),e.prototype.setRt=function(e,t){this._R=e.slice(0),this._t=t.slice(0)},e.prototype.setR=function(e){this._R=e.slice(0)},e.prototype.R=function(){return this._R},e.prototype.t=function(){return this._t},e.prototype.getPosition=function(){return[this._t[0],this._t[1],this._t[2]]},e.prototype.getRotation=function(){return[[this._R[0],this._R[1],this._R[2]],[this._R[3],this._R[4],this._R[5]],[this._R[6],this._R[7],this._R[8]]]},e.prototype.getRot=function(){return this._R},e.prototype.updateRotation=function(e){this._R=Float32Array.from(e)},e.prototype.translate=function(e,t,n){this._t[0]+=e,this._t[1]+=t,this._t[2]+=n},e.prototype.reset=function(){this._R=new Float32Array([1,0,0,0,-1,0,0,0,-1]),this._t=new Float32Array([0,0,0])},e.prototype.det=function(){return this._R[0]*(this._R[4]*this._R[8]-this._R[7]*this._R[5])-this._R[3]*(this._R[1]*this._R[8]-this._R[7]*this._R[2])+this._R[6]*(this._R[1]*this._R[5]-this._R[4]*this._R[2])},e.convert3x3Mat=function(e){return new Float32Array([e[0][0],e[0][1],e[0][2],e[1][0],e[1][1],e[1][2],e[2][0],e[2][1],e[2][2]])},e.convert3x3Mat_t=function(e){return new Float32Array([e[0][0],e[1][0],e[2][0],e[0][1],e[1][1],e[2][1],e[0][2],e[1][3],e[2][2]])},e.getQuatFromRotMat=function(e){var t=new Float32Array(4);return t[0]=Math.sqrt(Math.max(0,1+e[0]+e[4]+e[8]))/2,t[1]=Math.sqrt(Math.max(0,1+e[0]-e[4]-e[8]))/2,t[2]=Math.sqrt(Math.max(0,1-e[0]+e[4]-e[8]))/2,t[3]=Math.sqrt(Math.max(0,1-e[0]-e[4]+e[8]))/2,t[1]=e[7]-e[5]<0?-Math.abs(t[1]):Math.abs(t[1]),t[2]=e[2]-e[6]<0?-Math.abs(t[2]):Math.abs(t[2]),t[3]=e[3]-e[1]<0?-Math.abs(t[3]):Math.abs(t[3]),t},e.getRotMatFromQuat=function(e){var t=new Float32Array(9);return t[0]=1-2*e[2]*e[2]-2*e[3]*e[3],t[1]=2*e[1]*e[2]-2*e[3]*e[0],t[2]=2*e[1]*e[3]+2*e[2]*e[0],t[3]=2*e[1]*e[2]+2*e[3]*e[0],t[4]=1-2*e[1]*e[1]-2*e[3]*e[3],t[5]=2*e[2]*e[3]-2*e[1]*e[0],t[6]=2*e[1]*e[3]-2*e[2]*e[0],t[7]=2*e[2]*e[3]+2*e[1]*e[0],t[8]=1-2*e[1]*e[1]-2*e[2]*e[2],t},e.slerp=function(e,t,n){var r,a,i=new Float32Array(4),s=e[1]*t[1]+e[2]*t[2]+e[3]*t[3]+e[0]*t[0],o=Math.abs(s);if(o>=.99999)r=1-n,a=n;else{var u=Math.acos(o),l=Math.sin(u);r=Math.sin((1-n)*u)/l,a=Math.sin(n*u)/l}return s<0&&(a=-a),i[1]=r*e[1]+a*t[1],i[2]=r*e[2]+a*t[2],i[3]=r*e[3]+a*t[3],i[0]=r*e[0]+a*t[0],i},e.getCameraMat=function(e,t,n){var r=n/2/Math.tan(e*Math.PI/180/2),a=r,i=(t-1)/2,s=(n-1)/2,o=new Float32Array(9);return o[0]=a,o[2]=i,o[4]=r,o[5]=s,o[8]=1,o},e.getCameraParams=function(e,t,n){var r=n/2/Math.tan(e*Math.PI/180/2);return[r,r,(t-1)/2,(n-1)/2]},e.MatMultVec=function(e,t){var n=new Float32Array(3);return n[0]=e[0]*t[0]+e[1]*t[1]+e[2]*t[2],n[1]=e[3]*t[0]+e[4]*t[1]+e[5]*t[2],n[2]=e[6]*t[0]+e[7]*t[1]+e[8]*t[2],n},e.MatMult=function(e,t){var n=new Float32Array(9);return n[0]=e[0]*t[0]+e[1]*t[3]+e[2]*t[6],n[1]=e[0]*t[1]+e[1]*t[4]+e[2]*t[7],n[2]=e[0]*t[2]+e[1]*t[5]+e[2]*t[8],n[3]=e[3]*t[0]+e[4]*t[3]+e[5]*t[6],n[4]=e[3]*t[1]+e[4]*t[4]+e[5]*t[7],n[5]=e[3]*t[2]+e[4]*t[5]+e[5]*t[8],n[6]=e[6]*t[0]+e[7]*t[3]+e[8]*t[6],n[7]=e[6]*t[1]+e[7]*t[4]+e[8]*t[7],n[8]=e[6]*t[2]+e[7]*t[5]+e[8]*t[8],n},e.prototype.project=function(t,n){for(var r=new Float32Array(t.length/3*2),a=0;a<t.length/3;a++){var i=e.MatMultVec(this._R,new Float32Array([t[3*a],t[3*a+1],t[3*a+2]])),s=new Float32Array(3);s[0]=i[0]+this._t[0],s[1]=i[1]+this._t[1],s[2]=i[2]+this._t[2];var o=n[6]*s[0]+n[7]*s[1]+n[8]*s[2];r[2*a]=(n[0]*s[0]+n[1]*s[1]+n[2]*s[2])/o,r[2*a+1]=(n[3]*s[0]+n[4]*s[1]+n[5]*s[2])/o}return r},e.prototype.transform=function(t,n){for(var r=new Float32Array(t.length/3*2),a=0;a<t.length/3;a++){var i=e.MatMultVec(this._R,new Float32Array([t[3*a],t[3*a+1],t[3*a+2]]));r[3*a+0]=i[0]+this._t[0],r[3*a+1]=i[1]+this._t[1],r[3*a+2]=i[2]+this._t[2]}return r},e}(),LA=function(){function e(e){this.NB_BUFFERS=6,this._poses=[],this._nbFramesDelay=0,this._interpolation=0,this._filteringLevel=2,this._filterThreshold=-1,e>=0&&e<this.NB_BUFFERS?this._nbFramesDelay=this._nbFramesDelay:console.error("Invalid frames delay, delay must be less than ",this.NB_BUFFERS)}return e.prototype.setNbFramesDelay=function(e){this._nbFramesDelay=e},e.prototype.setInterpolation=function(e){this._interpolation=e},e.prototype.setFilteringLevel=function(e){this._filteringLevel=e},e.prototype.setFilterThreshold=function(e){this._filterThreshold=e},e.prototype.reset=function(){this._poses=[]},e.prototype.setPose=function(e){this._poses.length===this.NB_BUFFERS&&(this._poses=this._poses.slice(0,-1)),this._poses=h([e],this._poses,!0)},e.prototype.getPose=function(){return this._poses.length>0?this._nbFramesDelay<this._poses.length?this._poses[this._nbFramesDelay]:this._poses[this._poses.length-1]:null},e.prototype.getInterpolatedPoseAtDelay=function(e){if(e>0&&e+1<this._poses.length){var t=this._poses[e-1],n=this._poses[e],r=this._poses[e+1];if(t.getTrackingState()!==pA.Tracking||r.getTrackingState()!==pA.Tracking)return n;for(var a=PA.getQuatFromRotMat(t.R()),i=PA.getQuatFromRotMat(r.R()),s=PA.slerp(a,i,.5),o=PA.getRotMatFromQuat(s),u=t.t(),l=r.t(),c=new Float32Array(3),h=0;h<3;h++)c[h]=.5*u[h]+.5*l[h];var p=new PA(o,c);return p.setTrackingState(n.getTrackingState()),p.type=n.type,p}return this._poses.length>0?this.getPose():this.getLastPose()},e.prototype.dst=function(e,t){return Math.sqrt((e[0]-t[0])*(e[0]-t[0])+(e[1]-t[1])*(e[1]-t[1])+(e[2]-t[2])*(e[2]-t[2]))},e.prototype.mvts=function(e,t,n){return(this.dst(e,t)+this.dst(t,n))/2},e.prototype.getInterpolatedPose=function(){if(1==this._filteringLevel)return this.getInterpolatedPoseAtDelay(this._nbFramesDelay);if(2==this._filteringLevel){var e=this.getInterpolatedPoseAtDelay(this._nbFramesDelay-1),t=this.getInterpolatedPoseAtDelay(this._nbFramesDelay+1);if(null==e||null==t)return this.getInterpolatedPoseAtDelay(this._nbFramesDelay);if(e.getTrackingState()!==pA.Tracking||t.getTrackingState()!==pA.Tracking)return this.getInterpolatedPoseAtDelay(this._nbFramesDelay);var n=this._poses[this._nbFramesDelay],r=e.t(),a=t.t();if(this._filterThreshold>0){var i=this.dst(r,n.t()),s=this.dst(a,n.t());if(i>this._filterThreshold||s>this._filterThreshold)return n}for(var o=PA.getQuatFromRotMat(e.R()),u=PA.getQuatFromRotMat(t.R()),l=PA.slerp(o,u,this._interpolation),c=PA.getRotMatFromQuat(l),h=new Float32Array(3),p=0;p<3;p++)h[p]=(1-this._interpolation)*r[p]+this._interpolation*a[p];var d=new PA(c,h);return d.setTrackingState(n.getTrackingState()),d.type=n.type,d}return this.getLastPose()},e.prototype.updateDelay=function(e){e!=this._nbFramesDelay&&(e>=0&&e<this.NB_BUFFERS?this._nbFramesDelay=e:console.error("Invalid frames delay, delay must be less than ",this.NB_BUFFERS))},e.prototype.getLastPose=function(){return this._poses.length>0?this._poses[0]:null},e}();!function(e){e.Left="LEFT_FOOT",e.Right="RIGHT_FOOT",e.Both="BOTH_FOOT",e.Single="SINGLE_FOOT"}(DA||(DA={}));var BA,UA="config.bin",WA=function(){function e(){this._initialized=!1,this._currentWidth=0,this._currentHeight=0,this._trackingState=pA.Detection,this._useWasmForHeatmaps=!1,this._float_size=4,this._bufferHeatmaps=null,this._bufferKeypsDet=null,this._bufferFeatureScores=null,this._bufKeyps3D_R=null,this._bufKeyps3D_L=null,this._footToDetect=DA.Right,this._leftFootState=pA.Detection,this._rightFootState=pA.Detection,this._bufferKeypsTrack_L=null,this._bufferKeypsTrack_R=null,this._bufferHeatmaps_L=null,this._bufferHeatmaps_R=null,this._fastMovements_L=!1,this._fastMovements_R=!1,this._cnnOutputDataInvMask=null,this._trackHasHeatmaps=!0,this._debug=!1,this._debugInitialized=!1,this._reproj_t=15,this._reproj_fast_t=30,this._isDetected=!1}return e.prototype.getDebugImage=function(){return this._debugInitialized?this._debugImage:null},e.prototype.isDetected=function(){return this._isDetected},e.prototype.getPosition=function(e){void 0===e&&(e=DA.Right);var t=null;return(t=e==DA.Right?this._poseManager_R.getInterpolatedPose():this._poseManager_L.getInterpolatedPose())?t.getPosition():null},e.prototype.getRotation=function(e){void 0===e&&(e=DA.Right);var t=null;return(t=e==DA.Right?this._poseManager_R.getInterpolatedPose():this._poseManager_L.getInterpolatedPose())?t.getRotation():null},e.prototype.getPose=function(e){return void 0===e&&(e=DA.Right),e==DA.Right?this._pose_L:this._pose_R},e.prototype.getInterpolatedPose=function(e){return void 0===e&&(e=DA.Right),e==DA.Right?this._poseManager_R.getInterpolatedPose():this._poseManager_L.getInterpolatedPose()},e.prototype.isInitialized=function(){return this._initialized},e.prototype.initialize=function(e,t,n){var r,a,i,s;return l(this,void 0,void 0,(function(){var o,l,h,p,d,f,m,g,y,b,v,w,_=this;return c(this,(function(c){switch(c.label){case 0:if(null==e)throw"Invalid parameter";return(null===(r=null==t?void 0:t.wasmBackend)||void 0===r?void 0:r.enable)?(ZI({"tfjs-backend-wasm.wasm":null===(a=t.wasmBackend)||void 0===a?void 0:a.tfjsBackendWasmPath,"tfjs-backend-wasm-simd.wasm":null===(i=t.wasmBackend)||void 0===i?void 0:i.tfjsBackendWasmSimdPath,"tfjs-backend-wasm-threaded-simd.wasm":null===(s=t.wasmBackend)||void 0===s?void 0:s.tfjsBackendWasmThreadedPath}),[4,No("wasm")]):[3,2];case 1:c.sent(),c.label=2;case 2:return this.release(),this._videoManager=e,this._config=t?u(u({},nA),t):nA,"BOTH"!==this._config.footToDetect&&"BOTH_FEET"!==this._config.footToDetect||(this._footToDetect=DA.Both),this._poseManager_R=new LA(this._videoManager.getNbFramesDelay()),this._poseManager_R.setInterpolation(this._config.filteringShift),this._poseManager_R.setFilteringLevel(this._config.filteringLevel),this._poseManager_R.setFilterThreshold(.1),this._poseManager_L=new LA(this._videoManager.getNbFramesDelay()),this._poseManager_L.setInterpolation(this._config.filteringShift),this._poseManager_L.setFilteringLevel(this._config.filteringLevel),this._poseManager_L.setFilterThreshold(.1),o=new pe(0),l=Y(xT({locateFile:function(e,t){return _._config.poseEstimationWasmFilename||t+e}})).pipe(we((function(){return o.next(1)}))),h=dT(this._config.modelFilename,UA),p=h.model$,d=h.progress$,f=dT(this._config.featuresFilename,UA),m=f.model$,g=f.progress$,y=MA(this._config.objFilename,!1),b=y.model$,v=y.progress$,w=K([o,d,g,v]).pipe(J((function(e){return e.reduce((function(t,n){return t+n/e.length}),0)})),J((function(e){return n&&n(e)}))).subscribe(),[4,dx({poseModule:l,model:p,features:m,footObjModel:b}).pipe(J((function(e){var t;_._poseModule=e.poseModule,_._footObjModel=e.footObjModel,_._tfFootDetector=e.model.graphModel,_._footDetectorConfig=e.model.config,_._tfFootFeatures=e.features.graphModel,_._footFeaturesConfig=e.features.config,_._activeIds=_._config.activeIds,console.log(_._footFeaturesConfig),console.log(e.model.config),console.log(e.features.config),console.log("(DEBUG) XZIMG BACKEND",Ro());var n=Oc([1,_._footDetectorConfig.inHeight,_._footDetectorConfig.inWidth,3]),r=_._tfFootDetector.predict(n);_._footDetectorShape=r.shape,r.dataSync(),r.dispose(),n.dispose();var a=_._footDetectorConfig.outChannels;n=Oc([1,_._footFeaturesConfig.inHeight,_._footFeaturesConfig.inWidth,3]),(r=_._tfFootFeatures.predict(n))instanceof Array?r.forEach((function(e){return e.dispose()})):r.dispose(),n.dispose(),n=Oc([2,_._footFeaturesConfig.inHeight,_._footFeaturesConfig.inWidth,3]),(r=_._tfFootFeatures.predict(n))instanceof Array?r.forEach((function(e){return e.dispose()})):r.dispose(),n.dispose();var i=_._footFeaturesConfig.outChannels;if(_._footFeaturesConfig.outputNames&&_._footFeaturesConfig.numOutputs&&_._footFeaturesConfig.numOutputs>1)for(var s=0,o=0,u=_._footFeaturesConfig.outputNames;o<u.length;o++){var l=u[o];"heatmaps"==l?i=_._footFeaturesConfig.outputDims[3*s+2]:"coordinates"==l&&(i=_._footFeaturesConfig.outputDims[3*s+2]/2),s+=1}if(t=function(e,t){var n=Array.from(Array(t).keys());13==t&&(n=[54,210,295,415,416,425,463,582,644,721,726,730,813]),18==t&&(n=[54,210,295,406,415,416,417,423,425,463,518,582,644,657,721,726,730,813]);for(var r=n.length,a=new Float32Array(3*r),i=0;i<r;i++){var s=n[i];a[3*i]=e[3*s],a[3*i+1]=e[3*s+1],a[3*i+2]=e[3*s+2]}var o=new Float32Array(3*r);for(i=0;i<r;i++)o[3*i]=-a[3*i],o[3*i+1]=a[3*i+1],o[3*i+2]=a[3*i+2];return[a,o]}(_._footObjModel.vertices,i),_._rightKeyps3D=t[0],_._leftKeyps3D=t[1],_._bufKeyps3D_R=_._poseModule._malloc(_._rightKeyps3D.length*_._float_size),_._poseModule.HEAPF32.set(_._rightKeyps3D,_._bufKeyps3D_R/4),_._bufKeyps3D_L=_._poseModule._malloc(_._leftKeyps3D.length*_._float_size),_._poseModule.HEAPF32.set(_._leftKeyps3D,_._bufKeyps3D_L/4),_._footDetectorConfig.outWidth>1&&_._footDetectorConfig.outHeight>1){var c=a*_._footDetectorConfig.outWidth*_._footDetectorConfig.outHeight;_._bufferHeatmaps=_._poseModule._malloc(c*_._float_size)}_._footFeaturesConfig.outWidth>1&&_._footFeaturesConfig.outHeight>1&&(c=i*_._footFeaturesConfig.outWidth*_._footFeaturesConfig.outHeight,_._bufferHeatmaps_L=_._poseModule._malloc(c*_._float_size),_._bufferHeatmaps_R=_._poseModule._malloc(c*_._float_size)),_._bufferKeypsDet=_._poseModule._malloc(2*a*_._float_size),_._bufferKeypsTrack_L=_._poseModule._malloc(2*i*_._float_size),_._bufferKeypsTrack_R=_._poseModule._malloc(2*i*_._float_size),_._bufferFeatureScores=_._poseModule._malloc(i*_._float_size),_._pose_R=new PA(new Float32Array([1,0,0,0,-1,0,0,0,-1]),new Float32Array([0,0,0])),_._pose_L=new PA(new Float32Array([1,0,0,0,-1,0,0,0,-1]),new Float32Array([0,0,0])),_._trackHasHeatmaps=rA(_._footFeaturesConfig),_._initialized=!0})),ae((function(){return w.unsubscribe()}))).toPromise()];case 3:return c.sent(),[2]}}))}))},e.prototype.release=function(){this._initialized&&(this._poseModule._free(this._bufferHeatmaps),this._bufferHeatmaps_L&&this._poseModule._free(this._bufferHeatmaps_L),this._bufferHeatmaps_R&&this._poseModule._free(this._bufferHeatmaps_R),this._bufferKeypsDet&&this._poseModule._free(this._bufferKeypsDet),this._poseModule._free(this._bufferKeypsTrack_L),this._poseModule._free(this._bufferKeypsTrack_R),this._poseModule._free(this._bufferFeatureScores),this._poseModule._free(this._bufKeyps3D_R),this._poseModule._free(this._bufKeyps3D_L),this._hptrImageBuffer&&this._poseModule._free(this._hptrImageBuffer))},e.prototype.trackSync=function(e){var t;if(this._initialized){var n=this._videoManager.getVideoCanvas();n.width===this._currentWidth&&n.height===this._currentHeight||(this._currentWidth=n.width,this._currentHeight=n.height,t=PA.getCameraParams(this._config.fovY,this._currentWidth,this._currentHeight),this._fx=t[0],this._fy=t[1],this._cx=t[2],this._cy=t[3],this._poseModule.cwrap("xzimgInitializeCamera","number",["number","number","number"])(this._config.fovY,this._currentWidth,this._currentHeight)),this._poseManager_L.setNbFramesDelay(this._videoManager.getNbFramesDelay()),this._poseManager_R.setNbFramesDelay(this._videoManager.getNbFramesDelay());var r=e;null==e&&(r=this._videoManager.getLastBuffer()),null!=r?this.trackBothFeetSync(r):console.error("No video frame to process")}else console.error("Foot must be initialized to track")},e.prototype.trackBothFeetSync=function(e){var t=-1;if(this._rightFootState!=pA.Detection&&this._leftFootState!=pA.Detection){var n=this.trackBothFeetFeaturesSync(e,this._leftFootState,this._rightFootState,this._leftFootState==pA.Detected?this._initShape:this._leftFootRecShape,this._rightFootState==pA.Detected?this._initShape:this._rightFootRecShape,this._leftFootVis,this._rightFootVis,this._leftFootOcclusions,this._rightFootOcclusions),r=bA(n.scores_R,"RIGHT_FOOT",this._config.validTrackedKeypThs);this._rightFootRecShape=n.refinedFeatures_R,this._rightFootOcclusions=n.occlusions_R,this._rightFootVis=r.visibilty;var a=bA(n.scores_L,"LEFT_FOOT",this._config.validTrackedKeypThs);this._leftFootRecShape=n.refinedFeatures_L,this._leftFootOcclusions=n.occlusions_L,this._leftFootVis=a.visibilty;var i=this._config.trackScoreThs,s=this._reproj_t;this._fastMovements_R&&(s=this._reproj_fast_t);var o=this._rightFootRecShape.length/2,u=wA(o,"RIGHT_FOOT"),l=new mA(0,0,e.width,e.height),c=new dA((this._rightFootRecShape[u[0]]+this._rightFootRecShape[u[1]])/2,(this._rightFootRecShape[u[0]+o]+this._rightFootRecShape[u[1]+o])/2);l.isPointInside(c)&&this._rightFootVis[u[0]]&&this._rightFootVis[u[1]]&&r.globalScore>=i&&r.totalVisible>=this._config.trackedNumKeypsThs?(t=this.computePoseSync(this._rightFootState,"RIGHT_FOOT"),this._rightFootState=pA.Tracking,t>s&&(this._rightFootState=pA.Detection)):this._rightFootState=pA.Detection,i=this._config.trackScoreThs,this._fastMovements_L&&(i=.1),s=this._reproj_t,this._fastMovements_L&&(s=this._reproj_fast_t),u=wA(o,"LEFT_FOOT");var h=new dA((this._leftFootRecShape[u[0]]+this._leftFootRecShape[u[1]])/2,(this._leftFootRecShape[u[0]+o]+this._leftFootRecShape[u[1]+o])/2);l.isPointInside(h)&&this._leftFootVis[u[0]]&&this._leftFootVis[u[1]]&&a.globalScore>=i&&a.totalVisible>=this._config.trackedNumKeypsThs?(t=this.computePoseSync(this._leftFootState,"LEFT_FOOT"),this._leftFootState=pA.Tracking,t>s&&(this._leftFootState=pA.Detection)):this._leftFootState=pA.Detection,this._leftFootState==pA.Tracking&&this._rightFootState==pA.Tracking&&this.bothFeetSamePlace()&&(this._leftFootState=pA.Detection,this._rightFootState=pA.Detection)}else if(this._rightFootState!==pA.Detection&&this._leftFootState===pA.Detection){var p=this.trackFootFeaturesSync(e,this._rightFootState,this._rightFootState==pA.Detected?this._initShape:this._rightFootRecShape,this._rightFootVis,this._rightFootOcclusions,"RIGHT_FOOT");this._rightFootRecShape=p.refinedFeatures,this._rightFootOcclusions=p.occlusions,r=bA(p.scores,"RIGHT_FOOT",this._config.validTrackedKeypThs),this._rightFootVis=r.visibilty,i=this._config.trackScoreThs,s=this._reproj_t,this._fastMovements_R&&(s=this._reproj_fast_t),u=wA(this._rightFootRecShape.length/2,"RIGHT_FOOT"),this._rightFootVis[u[0]]&&this._rightFootVis[u[1]]&&r.globalScore>=i&&r.totalVisible>=this._config.trackedNumKeypsThs?(t=this.computePoseSync(this._rightFootState,"RIGHT_FOOT"),this._rightFootState=pA.Tracking,t>s&&(this._rightFootState=pA.Detection)):this._rightFootState=pA.Detection;var d=this.detectFeetSync(e);this._initShape=d.refinedFeatures,a=bA(d.scores,"LEFT_FOOT",this._config.detectScoreThs),r=bA(d.scores,"RIGHT_FOOT",this._config.detectScoreThs);var f=!1;if(!this._fastMovements_R&&null!=this._cnnOutputDataInvMask){var m=FA(this._cnnOutputDataInvMask,this._footDetectorShape,!1);m[0];var g=bA(v=m[1],"LEFT_FOOT",this._config.detectScoreThs),y=bA(v,"RIGHT_FOOT",this._config.detectScoreThs);r.globalScore>a.globalScore&&r.globalScore>y.globalScore+.1&&g.globalScore>y.globalScore&&(f=!0)}f&&r.globalScore>this._config.detectScoreThs?(this.invertFoot(),this._rightFootRecShape=d.refinedFeatures,this._rightFootState=pA.Detected):a.globalScore>=this._config.detectScoreThs&&(this._leftFootRecShape=d.refinedFeatures,this._leftFootState=pA.Detected)}else if(this._leftFootState!==pA.Detection&&this._rightFootState===pA.Detection){var b=this.trackFootFeaturesSync(e,this._leftFootState,this._leftFootState==pA.Detected?this._initShape:this._leftFootRecShape,this._leftFootVis,this._leftFootOcclusions,"LEFT_FOOT");if(this._leftFootRecShape=b.refinedFeatures,this._leftFootOcclusions=b.occlusions,a=bA(b.scores,"LEFT_FOOT",this._config.validTrackedKeypThs),this._leftFootVis=a.visibilty,i=this._config.trackScoreThs,s=this._reproj_t,this._fastMovements_L&&(s=this._reproj_fast_t),u=wA(this._leftFootRecShape.length/2,"LEFT_FOOT"),this._leftFootVis[u[0]]&&this._leftFootVis[u[1]]&&a.globalScore>=i&&a.totalVisible>=this._config.trackedNumKeypsThs?(t=this.computePoseSync(this._leftFootState,"LEFT_FOOT"),this._leftFootState=pA.Tracking,t>s&&(this._leftFootState=pA.Detection)):this._leftFootState=pA.Detection,d=this.detectFeetSync(e),this._initShape=d.refinedFeatures,r=bA(d.scores,"RIGHT_FOOT",this._config.detectScoreThs),a=bA(d.scores,"LEFT_FOOT",this._config.detectScoreThs),f=!1,!this._fastMovements_L&&null!=this._cnnOutputDataInvMask){var v,w=FA(this._cnnOutputDataInvMask,this._footDetectorShape,!1);w[0],g=bA(v=w[1],"LEFT_FOOT",this._config.detectScoreThs),y=bA(v,"RIGHT_FOOT",this._config.detectScoreThs),a.globalScore>r.globalScore&&a.globalScore>g.globalScore+.1&&y.globalScore>g.globalScore&&(f=!0)}f&&a.globalScore>this._config.detectScoreThs?(this.invertFoot(),this._leftFootRecShape=d.refinedFeatures,this._leftFootState=pA.Detected):r.globalScore>=this._config.detectScoreThs&&(this._rightFootRecShape=d.refinedFeatures,this._rightFootState=pA.Detected)}else if(this._leftFootState===pA.Detection||this._rightFootState===pA.Detection){var _=this.detectFeetSync(e);if(this._initShape=_.refinedFeatures,a=bA(_.scores,"LEFT_FOOT",this._config.detectScoreThs),r=bA(_.scores,"RIGHT_FOOT",this._config.detectScoreThs),a.globalScore>=this._config.detectScoreThs&&(this._leftFootState=pA.Detected),r.globalScore>=this._config.detectScoreThs&&(this._rightFootState=pA.Detected),this._rightFootState!=pA.Detection&&this._leftFootState!=pA.Detection&&this.bothFeetSamePlaceInit()&&(this._rightFootState==pA.Detected?this._rightFootState=pA.Detection:this._leftFootState=pA.Detection),this._leftFootState==pA.Detected||this._rightFootState==pA.Detected){this._fastMovements_L=!0,this._fastMovements_R=!0;var x=this._poseModule.cwrap("xzimgMatchRecKeypsInit","number",["number"]);null==this._hptrImageBuffer&&(this._hptrImageBuffer=this._poseModule._malloc(e.width*e.height*4)),IA(this._poseModule,e,this._hptrImageBuffer);var k=AA(this._poseModule,this._hptrImageBuffer,e.width,e.height);x(k),this._poseModule._free(k)}}this._leftFootState===pA.Detection&&(this._pose_L=new PA(new Float32Array([1,0,0,0,-1,0,0,0,-1]),new Float32Array([0,0,0]))),this._rightFootState==pA.Detection&&(this._pose_R=new PA(new Float32Array([1,0,0,0,-1,0,0,0,-1]),new Float32Array([0,0,0]))),this._pose_R.setTrackingState(this._rightFootState),this._pose_R.type=0,this._poseManager_R.setPose(this._pose_R),this._pose_L.setTrackingState(this._leftFootState),this._pose_L.type=1,this._poseManager_L.setPose(this._pose_L)},e.prototype.detectFeetSync=function(e){var t,n,r,a,i=function(e,t){var n,r;return{crop:e>t?[(r=0)/t,(n=(e-t)/2)/e,1,(e-n)/e]:[(r=(t-e)/2)/t,(n=0)/e,(t-r)/t,1],deltaY:r,deltaX:n}}(this._currentWidth,this._currentHeight),s=i.crop,o=i.deltaY,u=i.deltaX,l=Vo(e),c=ko(l,"float32"),h=Bu(c,[1,this._currentHeight,this._currentWidth,3]),p=gd.cropAndResize(h,[s],[0],[this._footDetectorConfig.inHeight,this._footDetectorConfig.inWidth]),d=Gl(255),f=hu(p,d),m=null;if(this._footToDetect==DA.Both&&(this._leftFootState===pA.Tracking||this._rightFootState===pA.Tracking)){var g=function(e,t,n,r,a,i,s,o){for(var u=e.length/2,l=new Float32Array(2*u),c=0;c<u;c++)l[c]=(e[c]-a)/s,l[c+u]=(e[c+u]-r)/i;for(var h=yA(l,o),p=h[0],d=h[1],f=h[2]-p,m=h[3]-d,g=h[6]-p,y=h[7]-d,b=f*f+m*m,v=g*g+y*y,w=new Float32Array(n*t),_=0;_<t;_++)for(var x=0;x<n;x++){var k=x-p,T=_-d,E=k*f+T*m,S=k*g+T*y;E>0&&S>0&&E<b&&S<v||(w[_*n+x]=1)}return w}(this._leftFootState===pA.Tracking?this._leftFootRecShape:this._rightFootRecShape,this._footDetectorConfig.inHeight,this._footDetectorConfig.inWidth,o,u,(this._currentHeight-2*o)/this._footDetectorConfig.inWidth,(this._currentWidth-2*u)/this._footDetectorConfig.inHeight,this._leftFootState===pA.Tracking?"LEFT_FOOT":"RIGHT_FOOT"),y=ep(g,"float32");m=Bu(y,[1,this._footDetectorConfig.inHeight,this._footDetectorConfig.inWidth,1]),y.dispose()}var b=this._tfFootDetector.predict(f);if(null!=m){var v=vc(1,m),w=pu(b,v);this._cnnOutputDataInvMask=w.dataSync(),v.dispose(),w.dispose();var _=pu(b,m);b.dispose(),b=_,m.dispose()}var x,k,T=null!==(n=null==b?void 0:b.shape[3])&&void 0!==n?n:this._footDetectorConfig.outChannels,E=null!==(r=null==b?void 0:b.shape[1])&&void 0!==r?r:this._footDetectorConfig.outHeight,S=null!==(a=null==b?void 0:b.shape[2])&&void 0!==a?a:this._footDetectorConfig.outWidth;x=(t=FA(b.dataSync(),[1,E,S,T],!1))[0],k=t[1];var I=this._bufferKeypsDet/4;this._poseModule.HEAPF32.subarray(I,I+2*T).set(x),l.dispose(),c.dispose(),d.dispose(),p.dispose(),f.dispose(),h.dispose(),b.dispose();var A=Math.min(this._currentWidth,this._currentHeight),C=A/this._footDetectorConfig.inWidth,N=A/this._footDetectorConfig.inHeight;return this._simToImage_Det=function(e,t,n,r){var a=new Float32Array(6);return a[0]=r,a[1]=0,a[2]=t,a[3]=0,a[4]=n,a[5]=e,a}(o,u,N,C),{refinedFeatures:vA(x,this._simToImage_Det,!1,b.shape[1]),scores:k}},e.prototype.trackFootFeaturesSync=function(e,t,n,r,a,i){var s,o,u,l,c="LEFT_FOOT"==i?this._simToImage_L:this._simToImage_R;if(t!=pA.Detected){var h=Int32Array.from(r);this._activeIds.length>0&&(h.forEach((function(e,t){h[t]=0})),this._activeIds.forEach((function(e){h[e]=1})),r.forEach((function(e,t){0==e&&(h[t]=0)})),a&&a.forEach((function(e,t){e>0&&(r[t]=0)}))),o=(s=CA(this._poseModule,e,this._hptrImageBuffer,n,h))[0],u=s[1],l=s[2],Math.sqrt(u[2]*u[2]+u[3]*u[3])>10?"LEFT_FOOT"==i?this._fastMovements_L=!0:this._fastMovements_R=!0:"LEFT_FOOT"==i?this._fastMovements_L=!1:this._fastMovements_R=!1;var p=RA(n,o,l);"LEFT_FOOT"==i?this._pose_L.translate(p[0]*this._pose_L.t()[2]/this._fx,p[1]*this._pose_L.t()[2]/this._fy,0):"RIGHT_FOOT"==i&&this._pose_R.translate(p[0]*this._pose_R.t()[2]/this._fx,p[1]*this._pose_R.t()[2]/this._fy,0);for(var d=o.length/2,f=0;f<d;f++)o[f]=n[f]+p[0],o[f+d]=n[f+d]+p[1]}else o=n;c=kA(o,r,this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight,null,i);var m=new ImageData(this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight);m=xA(e,m,c),this._debug&&(this._debugInitialized=!0,this._debugImage=m,uA(this._footFeaturesConfig.inHeight,this._footFeaturesConfig.inWidth,4,m));var g=this.detectKeypointsSync([m],[i]),y=vA(g.coordinates[0],c,"LEFT_FOOT"==i,this._footFeaturesConfig.outHeight);return"LEFT_FOOT"==i?this._simToImage_L=c:this._simToImage_R=c,{refinedFeatures:y,scores:g.scores[0],occlusions:g.occlusions[0]}},e.prototype.detectKeypointsSync=function(e,t){for(var n=[],r=[],a=[],i=[],s=0,o=null,u=0,l=e;u<l.length;u++){var c=l[u],h=Vo(c);i.push(h);var p=ko(h,"float32");i.push(p);var d=Bu(p,[1,this._footFeaturesConfig.inHeight,this._footFeaturesConfig.inWidth,3]);i.push(d);var f=Gl(255),m=hu(d,f);i.push(m),"LEFT_FOOT"==t[s]&&(m=Sh(m,1),i.push(m)),o?(o=zu([o,m]),i.push(o)):o=m,s+=1}if(null!=o){var g=[];if(this._footFeaturesConfig.numOutputs&&1!=this._footFeaturesConfig.numOutputs)for(var y=0,b=g=this._tfFootFeatures.predict(o);y<b.length;y++){var v=b[y];i.push(v)}else{var w=this._tfFootFeatures.predict(o);i.push(w),g.push(w)}for(var _=0,x=0,k=g;x<k.length;x++){w=k[x];for(var T=[],E=[],S=0,I=sp(w,0);S<I.length;S++){var A=I[S];i.push(A);var C=Zl(A,0);i.push(C),T.push(A.dataSync()),E.push(C.shape)}if(this._footFeaturesConfig.outputNames&&"heatmaps"!=this._footFeaturesConfig.outputNames[_]){if(this._footFeaturesConfig.outputNames&&"coordinates"==this._footFeaturesConfig.outputNames[_])for(L=0;L<T.length;L++){for(var N=E[L][1]/2,R=new Float32Array(2*N),F=this._footFeaturesConfig.inHeight/2,O=this._footFeaturesConfig.inWidth/2,M=0;M<N;M++)R[M]=(T[L][M]+1)*O,R[M+N]=(T[L][M+N]+1)*F;n.push(R)}else if(this._footFeaturesConfig.outputNames&&"scores"==this._footFeaturesConfig.outputNames[_])for(L=0;L<T.length;L++){var $=E[L][1],D=new Float32Array($);for(M=0;M<$;M++)D[M]=1/(1+Math.exp(-T[L][M]));r.push(D)}else if(this._footFeaturesConfig.outputNames&&"occlusions"==this._footFeaturesConfig.outputNames[_])for(L=0;L<T.length;L++){$=E[L][1];var P=new Float32Array($);for(M=0;M<$;M++)P[M]=1/(1+Math.exp(-T[L][M]));a.push(P)}}else for(var L=0;L<T.length;L++){var B;B=this._useWasmForHeatmaps?OA(this._poseModule,E[L],T[L],"LEFT_FOOT"==t[L]?this._bufferHeatmaps_L:this._bufferHeatmaps_R,"LEFT_FOOT"==t[L]?this._bufferKeypsTrack_L:this._bufferKeypsTrack_R,this._bufferFeatureScores):FA(T[L],E[L],!1),n.push(B[0]),r.push(B[1]);var U=E[L][1]*E[L][2]*E[L][3],W="LEFT_FOOT"==t[L]?this._bufferHeatmaps_L/4:this._bufferHeatmaps_R/4;this._poseModule.HEAPF32.subarray(W,W+U).set(T[L])}_+=1}for(L=0;L<n.length;L++)N=n[L].length,W="LEFT_FOOT"==t[L]?this._bufferKeypsTrack_L/4:this._bufferKeypsTrack_R/4,this._poseModule.HEAPF32.subarray(W,W+2*N).set(n[L])}return i.forEach((function(e){return e.dispose()})),{coordinates:n,scores:r,occlusions:a}},e.prototype.trackBothFeetFeaturesSync=function(e,t,n,r,a,i,s,o,u){var l,c,h;if(t!=pA.Detected&&n!=pA.Detected){var p=r.length/2,d=new Int32Array(2*p);d.set(i),d.set(s,p);var f=null;o&&u&&((f=new Float32Array(2*p)).set(o),f.set(u,p));var m=Int32Array.from(d);this._activeIds.length>0&&(m.forEach((function(e,t){m[t]=0})),this._activeIds.forEach((function(e){m[e]=1,m[e+p]=1})),d.forEach((function(e,t){0==e&&(m[t]=0)})),f&&f.forEach((function(e,t){e>0&&(d[t]=0)})));var g=CA(this._poseModule,e,this._hptrImageBuffer,function(e,t){for(var n=e.length/2,r=t.length/2,a=n+r,i=new Float32Array(e.length+t.length),s=0;s<n;s++)i[s]=e[s],i[s+a]=e[s+n];for(s=0;s<r;s++)i[s+n]=t[s],i[s+a+n]=t[s+r];return i}(r,a),m),y=g[0];g[1];var b=g[2];l=function(e,t,n){var r=new Float32Array(2*t),a=new Float32Array(2*n),i=e.length/2;t+n!=i&&console.log("ERROR (separateShapes): shapes not correct dims");for(var s=0;s<t;s++)r[s]=e[s],r[s+t]=e[s+i];for(s=0;s<n;s++)a[s]=e[s+t],a[s+n]=e[s+i+t];return[r,a]}(y,p,p),c=l[0],h=l[1];var v=b.slice(0,p),w=b.slice(p,2*p),_=NA(this._poseModule,r,c),x=NA(this._poseModule,a,h);Math.sqrt(_[2]*_[2]+_[3]*_[3])>10?this._fastMovements_L=!0:this._fastMovements_L=!1,Math.sqrt(x[2]*x[2]+x[3]*x[3])>10?this._fastMovements_R=!0:this._fastMovements_R=!1;var k=RA(r,c,v);this._pose_L.translate(k[0]*this._pose_L.t()[2]/this._fx,k[1]*this._pose_L.t()[2]/this._fy,0);var T=RA(a,h,w);this._pose_R.translate(T[0]*this._pose_R.t()[2]/this._fx,T[1]*this._pose_R.t()[2]/this._fy,0);for(var E=h.length/2,S=0;S<E;S++)h[S]=a[S]+T[0],h[S+E]=a[S+E]+T[1],c[S]=r[S]+k[0],c[S+E]=r[S+E]+k[1]}else c=r,h=a;this._simToImage_L=kA(c,i,this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight,null,"LEFT_FOOT");var I=new ImageData(this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight);I=xA(e,I,this._simToImage_L),this._simToImage_R=kA(h,s,this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight,null,"RIGHT_FOOT");var A=new ImageData(this._footFeaturesConfig.inWidth,this._footFeaturesConfig.inHeight);A=xA(e,A,this._simToImage_R);var C=this.detectKeypointsSync([I,A],["LEFT_FOOT","RIGHT_FOOT"]),N=vA(C.coordinates[0],this._simToImage_L,!0,this._footFeaturesConfig.outHeight),R=vA(C.coordinates[1],this._simToImage_R,!1,this._footFeaturesConfig.outHeight);return t!=pA.Detected&&(N=gA(N,oA(C.scores[0],this._config.validTrackedKeypThs),c,i,.2)),n!=pA.Detected&&(R=gA(R,oA(C.scores[1],this._config.validTrackedKeypThs),h,s,.2)),{refinedFeatures_L:N,refinedFeatures_R:R,scores_L:C.scores[0],scores_R:C.scores[1],occlusions_L:C.occlusions[0],occlusions_R:C.occlusions[1]}},e.prototype.computePoseSync=function(e,t){var n=this,r=-1,a=this._poseModule.cwrap("xzimgEstimateRigidPose","number",["number","number","number","number","number","number","number","number","number","number","number","number"]);if(e==pA.Detected||e==pA.Tracking){var i=1;e==pA.Detected&&(i=0);var s=1;this._trackHasHeatmaps&&(s=3);var o=3;"LEFT_FOOT"!=t||this._fastMovements_L||(o=1),"RIGHT_FOOT"!=t||this._fastMovements_R||(o=1);var u=new Float32Array(18);"LEFT_FOOT"==t?(u.set(this._pose_L.R()),u.set(this._pose_L.t(),9)):(u.set(this._pose_R.R()),u.set(this._pose_R.t(),9));var l=TA(this._poseModule,u),c="LEFT_FOOT"==t?this._simToImage_L:this._simToImage_R,h=Float32Array.from([1,0,0,0,1,0]);this._trackHasHeatmaps&&(h=Float32Array.from(c.slice(0,6)),"LEFT_FOOT"==t&&(h[2]+=h[1]*(this._footFeaturesConfig.outWidth-1),h[5]+=h[4]*(this._footFeaturesConfig.outHeight-1),h[1]=-h[1],h[4]=-h[4]));var p=TA(this._poseModule,h),d=null,f=null,m=new Float32Array(2*this._activeIds.length),g=new Float32Array(3*this._activeIds.length),y="LEFT_FOOT"==t?this._leftFootRecShape:this._rightFootRecShape,b="LEFT_FOOT"==t?this._leftKeyps3D:this._rightKeyps3D,v=y.length/2;this._activeIds.length>0?(this._activeIds.forEach((function(e,t){m[t]=y[e],m[t+n._activeIds.length]=y[e+v]})),d=TA(this._poseModule,m),this._activeIds.forEach((function(e,t){g[3*t]=b[3*e],g[3*t+1]=b[3*e+1],g[3*t+2]=b[3*e+2]})),f=TA(this._poseModule,g),v=this._activeIds.length):(d=this._trackHasHeatmaps?"LEFT_FOOT"==t?this._bufferKeypsTrack_L:this._bufferKeypsTrack_R:TA(this._poseModule,y),f=TA(this._poseModule,"LEFT_FOOT"==t?this._leftKeyps3D:this._rightKeyps3D)),-1==(r=a("LEFT_FOOT"==t?this._bufferHeatmaps_L:this._bufferHeatmaps_R,this._footFeaturesConfig.outHeight,this._footFeaturesConfig.outWidth,v,0,p,d,f,i,s,o,l))&&(r=1e4),"LEFT_FOOT"==t?this._pose_L=new PA(new Float32Array(this._poseModule.HEAPF32.buffer,l,9),new Float32Array(this._poseModule.HEAPF32.buffer,l+9*this._float_size,3)):this._pose_R=new PA(new Float32Array(this._poseModule.HEAPF32.buffer,l,9),new Float32Array(this._poseModule.HEAPF32.buffer,l+9*this._float_size,3)),p&&this._poseModule._free(p),d&&!this._trackHasHeatmaps&&this._poseModule._free(d),f&&this._activeIds.length>0&&this._poseModule._free(f)}return r},e.prototype.invertFoot=function(){var e,t,n,r,a,i,s;e=[this._rightFootRecShape,this._leftFootRecShape],this._rightFootRecShape=e[0],this._rightFootRecShape=e[1],t=[this._pose_L,this._pose_R],this._pose_R=t[0],this._pose_L=t[1],n=[this._poseManager_L,this._poseManager_R],this._poseManager_R=n[0],this._poseManager_L=n[1],r=[this._simToImage_R,this._simToImage_L],this._simToImage_L=r[0],this._simToImage_R=r[1],a=[this._rightFootState,this._leftFootState],this._leftFootState=a[0],this._rightFootState=a[1],i=[this._rightFootVis,this._leftFootVis],this._leftFootVis=i[0],this._rightFootVis=i[1],s=[this._bufferHeatmaps_L,this._bufferHeatmaps_R],this._bufferHeatmaps_R=s[0],this._bufferHeatmaps_L=s[1]},e.prototype.dst=function(e,t,n,r){return Math.sqrt((e-n)*(e-n)+(t-r)*(t-r))},e.prototype.bothFeetSamePlaceInit=function(){var e=this._initShape.length/2,t=0;return t+=this.dst(this._initShape[0],this._initShape[e],this._initShape[4],this._initShape[4+e]),t+=this.dst(this._initShape[1],this._initShape[1+e],this._initShape[3],this._initShape[3+e]),(t+=this.dst(this._initShape[2],this._initShape[2+e],this._initShape[5],this._initShape[5+e]))/3<this.dst(this._initShape[0],this._initShape[e],this._initShape[2],this._initShape[2+e])/5},e.prototype.bothFeetSamePlace=function(){var e=yA(this._leftFootRecShape,"LEFT_FOOT"),t=e[0],n=e[1],r=e[2],a=e[3],i=e[4],s=e[5],o=e[6],u=e[7],l=yA(this._rightFootRecShape,"RIGHT_FOOT"),c=l[0],h=l[1],p=l[2],d=l[3],f=l[4],m=l[5],g=l[6],y=l[7],b=this.dst(t,n,o,u)/8;return this.dst(t,n,c,h)<b&&this.dst(r,a,p,d)<b&&this.dst(i,s,f,m)<b&&this.dst(o,u,g,y)<b},e.prototype.getKeypoints_L=function(){return this._leftFootRecShape},e.prototype.getKeypoints_R=function(){return this._rightFootRecShape},e.prototype.getScores_L=function(){return this._leftFootVis},e.prototype.getScores_R=function(){return this._rightFootVis},e.prototype.getOcclusion_L=function(){return this._leftFootOcclusions},e.prototype.getOcclusion_R=function(){return this._rightFootOcclusions},e}(),VA={modelFilename:"",featuresFilename:"",objFilename:"",fovY:50,detectScoreThs:.2,trackScoreThs:.4,geometryToDetect:"LAMBORGHINI",filteringLevel:2,filteringShift:.5,validDetectedKeypThs:.2,validTrackedKeypThs:.2,detectNumKeypsThs:3,trackedNumKeypsThs:3,normMode:"",reprojThs:25,activeIds:new Int32Array,computePose:!0,useWasm:!0},zA=function(){function e(e,t){this.x=e,this.y=t}return e.prototype.Dist=function(e){return Math.sqrt((e.x-this.x)*(e.x-this.x)+(e.y-this.y)*(e.y-this.y))},e}();function jA(e){return e==BA.UpperBody||e==BA.FullBody}!function(e){e.Lamborghini="LAMBORGHINI",e.Horse="HORSE",e.WatsonCan="WATSON-CAN",e.MartellBottle="MARTELL-BOTTLE",e.Necklace="NECKLACE",e.Wrist="WRIST",e.Hand="HAND",e.UpperBody="UPPER-BODY",e.FullBody="FULL-BODY",e.CanKivisense="CAN-KIVISENSE",e.ToyTruck="TOY-TRUCK",e.Chivas="CHIVAS",e.ChivasLarge="CHIVAS-LARGE",e.Lion="LION",e.Bartender="BARTENDER",e.Wcbottle="WCBOTTLE",e.EQA="EQA",e.Face="FACE"}(BA||(BA={}));var GA,HA,KA,qA,XA,YA,QA,JA="config.json",ZA=function(){function e(){this._initialized=!1,this._nonRigidInitialized=!1,this._currentWidth=0,this._currentHeight=0,this._trackingState=pA.Detection,this._denseVertices=new Float32Array(0),this._geometryType=BA.Lamborghini,this._resetPose=!1,this._float_size=4,this._int_size=4,this._bufferHeatmaps=null,this._bufferKeypsDet=null,this._bufferFeatureScores=null,this._bufInOutPose=null,this._bufKeyps3D=null,this._bufMirroredKeyps3D=null,this._bufferKeypsTrack=null,this._bufferPdmModel=null,this._bufDenseVertices3D=null,this._reprojError=0,this._hptrImageBuffer=null,this._fastMvt=!1,this._mirrored=!1,this._debug=!1,this._debugInitialized=!1}return e.prototype.getDebugImage=function(){return this._debugInitialized?this._debugImage:null},e.prototype.isDetected=function(){return this._trackingState===pA.Tracking},e.prototype.getStatus=function(){return this._trackingState},e.prototype.getPosition=function(){var e=this._poseManager.getInterpolatedPose();return e?e.getPosition():null},e.prototype.getRotation=function(){var e=this._poseManager.getInterpolatedPose();return e?e.getRotation():null},e.prototype.getPose=function(){return this._pose},e.prototype.getVisibility=function(){return this._visibility},e.prototype.getKeypoints=function(){return this._keyps2D},e.prototype.getReprojKeypoints=function(){return this._reprojKeyps2D},e.prototype.getKeypoints3D=function(){return this._keyps3D},e.prototype.getDenseKeypoints3D=function(){return this._denseVertices},e.prototype.getInterpolatedPose=function(){return this._poseManager.getInterpolatedPose()},e.prototype.isInitialized=function(){return this._initialized},e.prototype.isMirrored=function(){return this._mirrored},e.prototype.getReprojError=function(){return this._reprojError},e.prototype.initialize=function(e,t,n){var r,a,i,s,o;return l(this,void 0,void 0,(function(){var l,h,p,d,f,m,g,y,b,v,w,_,x,k,T,E,S,A=this;return c(this,(function(c){switch(c.label){case 0:if(null==e)throw"Invalid parameter";return this._config=t?u(u({},VA),t):VA,(null===(r=null==t?void 0:t.wasmBackend)||void 0===r?void 0:r.enable)?(ZI({"tfjs-backend-wasm.wasm":null===(a=t.wasmBackend)||void 0===a?void 0:a.tfjsBackendWasmPath,"tfjs-backend-wasm-simd.wasm":null===(i=t.wasmBackend)||void 0===i?void 0:i.tfjsBackendWasmSimdPath,"tfjs-backend-wasm-threaded-simd.wasm":null===(s=t.wasmBackend)||void 0===s?void 0:s.tfjsBackendWasmThreadedPath}),[4,No("wasm")]):[3,2];case 1:c.sent(),c.label=2;case 2:return this.release(),this._videoManager=e,this._poseManager=new LA(this._videoManager.getNbFramesDelay()),this._poseManager.setInterpolation(this._config.filteringShift),this._poseManager.setFilteringLevel(this._config.filteringLevel),this._geometryType=function(e){if(e){if("LAMBORGHINI"===e)return BA.Lamborghini;if("HORSE"===e)return BA.Horse;if("WATSON-CAN"===e)return BA.WatsonCan;if("MARTELL-BOTTLE"===e)return BA.MartellBottle;if("NECKLACE"===e)return BA.Necklace;if("WRIST"===e)return BA.Wrist;if("HAND"===e)return BA.Hand;if("UPPER-BODY"===e)return BA.UpperBody;if("FULL-BODY"===e)return BA.FullBody;if("CAN-KIVISENSE"===e)return BA.CanKivisense;if("TOY-TRUCK"===e)return BA.ToyTruck;if("CHIVAS"===e)return BA.Chivas;if("CHIVAS-LARGE"===e)return BA.ChivasLarge;if("LION"===e)return BA.Lion;if("BARTENDER"===e)return BA.Bartender;if("WCBOTTLE"===e)return BA.Wcbottle;if("EQA"===e)return BA.EQA;if("FACE"===e)return BA.Face}return BA.Lamborghini}(this._config.geometryToDetect),l=new pe(0),h=Y(xT({locateFile:function(e,t){return A._config.poseEstimationWasmFilename||t+e}})).pipe(we((function(){return l.next(1)}))),p=dT(this._config.modelFilename,JA),d=p.model$,f=p.progress$,m=dT(this._config.featuresFilename,JA),g=m.model$,y=m.progress$,b=MA(this._config.objFilename,!1),v=b.model$,w=b.progress$,_=new pe(0),k="upper-body-pdm",this._config.pdmContainer?(T=this._config.pdmContainer,"string"==typeof this._config.pdmContainer&&(E=null===(o=this._config.pdmContainer)||void 0===o?void 0:o.replace(/\\/g,"/"),k=null==E?void 0:E.substring(E.lastIndexOf("/")+1,E.lastIndexOf("."))),x=function(e,t,n){return"string"==typeof e?Rx({url:e,method:"GET",responseType:"arraybuffer",async:!0,progressSubscriber:new I((function(e){return n.next(.5*e.loaded/e.total)}),(function(e){}),(function(){return n.next(.5)}))}).pipe(de(2),ge((function(e){return Q(dk(new Uint8Array(e.response)))})),ge((function(r){return r[t]?(n.next(1),Q(r[t])):ne("File ".concat(t," not found in ").concat(e))}))):Q(dk(new Uint8Array(e))).pipe(ge((function(e){return e[t]?(n.next(1),Q(e[t])):ne("File ".concat(t," not found"))})))}(T,this._config.pdmName?this._config.pdmName:k+".bin",_)):(_.next(1),x=Q(null)),S=K([l,f,_,y,w]).pipe(J((function(e){return e.reduce((function(t,n){return t+n/e.length}),0)})),J((function(e){return n&&n(e)}))).subscribe(),[4,dx({poseModule:h,detectorModel:d,pdmModel:x,trackerModel:g,geometryObjModel:v}).pipe(J((function(e){var t;A._poseModule=e.poseModule,A._geometryObjModel=e.geometryObjModel,A._tfKeypointsDetector=e.detectorModel.graphModel,A._detectorConfig=e.detectorModel.config,A._tfKeypointsTracker=e.trackerModel.graphModel,A._trackerConfig=e.trackerModel.config;var n=Oc([1,A._detectorConfig.inHeight,A._detectorConfig.inWidth,3]),r=A._tfKeypointsDetector.predict(n);A._detectorOutDims=r.shape,r.dispose(),A._detectorConfig.inHeight===A._trackerConfig.inHeight&&A._detectorConfig.inWidth===A._trackerConfig.inWidth||(n.dispose(),n=Oc([1,A._trackerConfig.inHeight,A._trackerConfig.inWidth,3])),(r=A._tfKeypointsTracker.predict(n))instanceof Array?(r.forEach((function(e){return e.dispose()})),A._trackerOutDims=[1,A._trackerConfig.outHeight,A._trackerConfig.outWidth,A._trackerConfig.outChannels]):(A._trackerOutDims=r.shape,r.dispose()),n.dispose(),A._debug&&(console.log(A._detectorConfig),console.log(A._trackerConfig),console.log("(DEBUG) XZIMG BACKEND",Ro()),console.log("_trackerOutDims",A._trackerOutDims)),A._activeIds=A._config.activeIds,A._trackHasHeatmaps=rA(A._trackerConfig),t=function(e,t){if("NECKLACE"==t)return[n=new Float32Array([-1.982586,1.762905,-1.256474,-1.4803,.73489,-.059477,-.863695,.091572,.505433,-179e-6,-.518833,.632376,.863894,.089272,.503284,1.479377,.729931,-.063135,1.981941,1.7644,-1.255762]),new Float32Array([-1.982586,1.762905,-1.256474,1.981941,1.7644,-1.255762])];if("CAN-KIVISENSE"==t)return[n=new Float32Array([.11749199777841568,.3616040050983429,-.5216580033302307,.3387719988822937,.1726129949092865,-.5216580033302307,.059477999806404114,-.37553098797798157,-.5216580033302307,-.1752689927816391,-.3439840078353882,.5761319994926453,.3802120089530945,-0,-.3024890124797821,.3387719988822937,-.1726129949092865,-.3024890124797821,-.1726129949092865,-.3387719988822937,-.3024890124797821,-.3616029918193817,-.11749199777841568,-.3024890124797821,-.11749199777841568,.3616040050983429,-.3024890124797821,.3802120089530945,-0,-.08331900089979172,.22348299622535706,-.3075979948043823,-.08331900089979172,-.3075979948043823,-.22348299622535706,-.08331900089979172,.37553098797798157,-.059477999806404114,.1358499974012375,-0,-.3802120089530945,.1358499974012375,-.37553098797798157,-.059477999806404114,.1358499974012375,.059477999806404114,.37553098797798157,.1358499974012375,.3616040050983429,.11749199777841568,.3550190031528473,-.3616029918193817,-.11749199777841568,.3550190031528473,-.3616029918193817,.11749199777841568,.3550190031528473,-.11749199777841568,.3616029918193817,.3550190031528473]),new Float32Array([0,0,-.5991089940071106,0,-0,.6023629903793335])];if("TOY-TRUCK"==t)return[n=new Float32Array([-.11474676430225372,.06819115579128265,.12616248428821564,-3.9706208099232754e-7,-.14720511436462402,.28020843863487244,5.515660461696825e-8,-.3098587989807129,.08606547862291336,-.18071073293685913,-.27267926931381226,-.012890318408608437,3.1216436013892235e-7,.39625027775764465,.03189631924033165,.23052667081356049,.24702677130699158,.002463694429025054,.1103515625,.2759860157966614,.15902937948703766,.18071091175079346,-.27267909049987793,-.012890467420220375,-.23046159744262695,-.11318685114383698,.0017448731232434511,.23046180605888367,-.1131867840886116,.0017446735873818398,-.1103513240814209,.275985985994339,.15902943909168243,.22978469729423523,.383583128452301,-.09141343832015991,-.22978472709655762,.38358309864997864,-.09141325950622559,-.23052656650543213,.247026726603508,.002463878598064184,.11429085582494736,.06870604306459427,.12790152430534363,.11895161867141724,-.05556913837790489,.37969091534614563,.11927806586027145,.1806230992078781,.373945027589798,-.1189512312412262,-.05556917190551758,.3796910345554352,-.11927773058414459,.18062305450439453,.3739452064037323]),new Float32Array([5.515660461696825e-8,-.3098587989807129,.08606547862291336,3.1216436013892235e-7,.39625027775764465,.03189631924033165])];if("CHIVAS"==t)return[n=new Float32Array([-3.1930644239785977e-10,-15140265077207005e-22,5.86190128326416,0,-.9621832966804504,1.9865937232971191,1.1873104572296143,-.9285097718238831,.9833493232727051,1.1932897567749023,-.9253148436546326,-1.3412771224975586,0,.9153332114219666,2.9489502906799316,-1.5160919427871704,.8744217157363892,.3604915142059326,-3.4059355336069075e-9,.9318456053733826,.3808324337005615,0,.9403911828994751,1.5472331047058105,.8038088083267212,-.9315917491912842,-.4920954704284668,1.5160919427871704,.8744216561317444,.3604915142059326,-2.058072090148926,-.06387438625097275,-2.1172304153442383,2.0580718517303467,-.06387437880039215,-2.1172304153442383,1.1926252841949463,.9239217042922974,-.5218658447265625,-4.4702903601034905e-9,-.9262475371360779,2.8632278442382812,-.02674211747944355,-1.5987444257348216e-8,-3.3316898345947266,-1.3472687005996704,-.9158325791358948,.9859023094177246,1.6359063386917114,-.8202042579650879,-2.4852395057678223,-1.6359063386917114,-.8202041983604431,-2.4852395057678223,-1.2821598052978516,-.9170172810554504,-1.34637451171875,-1.2809302806854248,-.9167184233665466,-.529242992401123,-2.0578272342681885,-.06386483460664749,1.5451469421386719,1.6359063386917114,.8202039003372192,-2.485239267349243,-1.5809047222137451,.8463804721832275,-2.4669992923736572,.7743757367134094,-.04055686667561531,3.7609105110168457,-1.099993348121643,.9303679466247559,-1.3362138271331787,1.0999937057495117,.9303681254386902,-1.3362138271331787,-1.2809303998947144,.9167175889015198,-.529242753982544,-.7743757367134094,-.040556877851486206,3.760910987854004,2.0578272342681885,-.06386483460664749,1.5451469421386719]),new Float32Array([-.02674211747944355,-1.5987444257348216e-8,-3.3316898345947266,-3.1930644239785977e-10,-15140265077207005e-22,5.86190128326416])];if("CHIVAS-LARGE"==t)return[n=new Float32Array([-.7353339195251465,-9.039938504429301e-7,2.8790359497070312,.7353339195251465,-9.039938504429301e-7,2.8790359497070312,-1.0241641998291016,-1.0241650342941284,2.1618540287017822,1.1196224689483643,-.9188478589057922,2.1618540287017822,.14197710156440735,-1.4414118528366089,2.1618540287017822,-.14197710156440735,1.4414103031158447,2.1618545055389404,-.5879112482070923,.057907234877347946,4.713740348815918,.5879112482070923,.057907234877347946,4.713740348815918,.06999345868825912,.0023226356133818626,-2.3130407333374023,0,-.07499408721923828,6.051614284515381,.0008376236073672771,1.707755446434021,-1.6613836288452148,-1.3236799240112305,1.0878145694732666,-.10835576057434082,-1.086346983909607,-1.323068618774414,-.10257232189178467,1.3245174884796143,1.0878145694732666,-.10835576057434082,1.2116090059280396,-1.2100292444229126,-.10835611820220947,.8094201683998108,1.5145108699798584,.6681584119796753,-.953505277633667,1.427893042564392,.6681584119796753,-1.0888724327087402,-1.3264672756195068,.6710498332977295,1.2140388488769531,-1.2132492065429688,.6681579351425171,.49678289890289307,-1.6338136196136475,-.8848701119422913,.00010470295092090964,1.7187724113464355,1.0564154386520386,1.0838285684585571,-1.3177416324615479,-1.2731270790100098,1.0838285684585571,1.3218059539794922,-1.2731266021728516,-1.0823626518249512,1.3218059539794922,-1.2731266021728516,-.9479852914810181,-1.4177916049957275,-1.2630056142807007,.3440423905849457,-.6436600685119629,3.901371479034424,-.46299880743026733,-.5641732215881348,3.901371479034424]),new Float32Array([.06999345868825912,.0023226356133818626,-2.3130407333374023,0,-.07499408721923828,6.051614284515381])];if("LION"==t)return[n=new Float32Array([-.0022359604481607676,-.951945424079895,2.026939868927002,-.448139488697052,-.6012729406356812,-1.6381982564926147,-.5041450262069702,.4640916585922241,-1.7428531646728516,.5572898387908936,.4562094509601593,-1.7489975690841675,.4558115005493164,-.6014943718910217,-1.639726161956787,-.5527711510658264,-.9193709492683411,3.0056838989257812,.5723921656608582,-.9076480865478516,3.0084033012390137,.5884838104248047,.0083160400390625,1.280758261680603,-.6188563108444214,-.009009452536702156,1.2967206239700317,.030467068776488304,.4174400866031647,-.521793007850647,-1.5193467140197754,.0034290971234440804,-.37409281730651855,1.5193467140197754,.0034290971234440804,-.37409281730651855,.012890640646219254,-.8310151696205139,2.4351325035095215,1.5662710666656494,.9279237985610962,3.319540500640869,-1.5894092321395874,.8687598705291748,3.289144515991211,.3409583568572998,-.5160142183303833,1.274591088294983,-.3600188195705414,-.5107225775718689,1.2790225744247437,-1.097593903541565,.11527538299560547,-1.0057109594345093,1.1363357305526733,-.5465875864028931,-.971623957157135,.8704371452331543,.5547775626182556,.3597971200942993,3.982757734721787e-10,.5748654007911682,.7409988641738892,1.0960721969604492,.12153985351324081,-.9948496222496033,-1.1377226114273071,-.5433639287948608,-.9926916360855103,-.8704371452331543,.5547775626182556,.3597968816757202,0,-.5633412003517151,-.9722840189933777,0,-.5655208826065063,.37440025806427]),new Float32Array([.012890640646219254,-.8310151696205139,2.4351325035095215,0,-.5633412003517151,-.9722840189933777])];if("BARTENDER"==t)return[n=new Float32Array([-.20026133954524994,-.9737697839736938,2.17860746383667,.19603070616722107,-.9857503771781921,2.1616086959838867,.3260974586009979,.7099164128303528,.10108458995819092,-.37390175461769104,-.42527586221694946,1.0039399862289429,.3709491193294525,-.42527586221694946,1.0039399862289429,8438758959528059e-20,-1.101210594177246,1.7955349683761597,2949934116831766e-31,-.04326578229665756,-.5318827629089355,.4412812888622284,-.2815903127193451,-1.3385579586029053,.45793405175209045,.37141913175582886,-1.6536355018615723,-.4412812888622284,-.2815903127193451,-1.3385579586029053,-.45793405175209045,.37141913175582886,-1.6536355018615723,6788047923913078e-31,-.8192819952964783,.4206336736679077,-.9793461561203003,-.015334106981754303,1.7865675687789917,.9793461561203003,-.015334106981754303,1.7865675687789917,1.4873708486557007,.04833114147186279,-.3768104314804077,.4768085777759552,.1994880586862564,.9495226144790649,.7653667330741882,-.3627835810184479,.15018165111541748,.308129221200943,-.6489158868789673,.557608962059021,-.0002116243413183838,.49473923444747925,1.0336977243423462,-.5404940247535706,.19043265283107758,.8128713369369507,-.7657899260520935,-.3627835810184479,.15018165111541748,1.4484371035905497e-7,.3663712441921234,3.387472629547119,-1.2087160348892212,-.6443189978599548,3.0043344497680664,1.2087161540985107,-.6443195343017578,3.0043344497680664,6141737432960813e-31,-.8464082479476929,.10243535041809082,-.3249528408050537,.7104986310005188,.10016584396362305,-.303207665681839,-.9462416172027588,.5075775384902954,-.37667226791381836,-1.0658020973205566,.9869986772537231]),new Float32Array([2949934116831766e-31,-.04326578229665756,-.5318827629089355,1.4484371035905497e-7,.3663712441921234,3.387472629547119])];if("WCBOTTLE"==t)return[n=new Float32Array([-.013366899453103542,-2.9939471346551727e-7,-2.511009931564331,.6493963599205017,-.7673797011375427,-2.4501447677612305,.7540126442909241,.6627629399299622,-2.4501450061798096,-.9611459970474243,-.36033540964126587,-2.4501450061798096,.1477278769016266,.9964179992675781,1.9307010173797607,-.9568377137184143,-.35869666934013367,1.9307011365890503,-.01336702425032854,3.722930728145002e-7,2.314748764038086,.9344120025634766,.3603347837924957,.22589847445487976,-.027811311185359955,1.0138630867004395,1.6714674234390259,-.9710267186164856,.3331884741783142,1.0331839323043823,.627266526222229,.7859488129615784,1.035000205039978,-.6761305332183838,.7673797011375427,.22936050593852997,-.02781102992594242,1.0138623714447021,-1.587138056755066,-.027811311185359955,1.0138630867004395,.45858100056648254,-.9372201561927795,-.4008185565471649,-.006537972949445248,.5878132581710815,-.8109326958656311,-.27440735697746277,-.3465554714202881,-.9576587677001953,1.3840690851211548,.34696754813194275,-.9477792978286743,-.5884990096092224,-.8841753602027893,-.519440233707428,-.5891181230545044,-.346555233001709,-.9576594829559326,.418072372674942]),new Float32Array([-.013366899453103542,-2.9939471346551727e-7,-2.511009931564331,-.01336702425032854,3.722930728145002e-7,2.314748764038086])];if("EQA"==t)return[n=new Float32Array([-3.7749502658843994,-.9271571040153503,.04594746232032776,-3.777569055557251,.92264324426651,.04048970341682434,-3.7703702449798584,-1.2227396965026855,-.9106809496879578,-3.7990496158599854,1.1855655908584595,-.9073726534843445,3.811656951904297,1.3718937635421753,-.7763562798500061,3.8001205921173096,-1.3779062032699585,-.7809855341911316,-.4568534791469574,-1.0891674757003784,1.2122516632080078,-.4568534791469574,1.08638596534729,1.2122514247894287,2.6531293392181396,-.925976037979126,1.2379950284957886,2.648271083831787,.9270637631416321,1.2376376390457153,3.459774971008301,-1.3973642587661743,.466232568025589,3.459774971008301,1.3945828676223755,.46623218059539795,-.9480692744255066,.0011375703616067767,1.0669147968292236,-4.019203186035156,-.0013908070977777243,-.24615326523780823,3.3231399059295654,-.0013906551757827401,1.151373267173767,3.907538652420044,-.0012724152766168118,.11990431696176529,.35528019070625305,-1.5870187282562256,.2603841722011566,.5474950671195984,-1.151407241821289,1.2155274152755737,-1.341339349746704,-1.5719798803329468,-.9050094485282898,-1.420742154121399,-1.4566854238510132,.4212491512298584,.35528019070625305,1.5842370986938477,.2603837251663208,.5482162833213806,1.1495895385742188,1.2244428396224976,-1.341339349746704,1.5691980123519897,-.9050098657608032,-1.420742154121399,1.4539037942886353,.42124876379966736,2.0402863025665283,-1.592824101448059,.3434940576553345,1.582544207572937,-1.5713834762573242,-.836898148059845,2.047945737838745,1.584236979484558,.3409099578857422,1.582544207572937,1.5686016082763672,-.8368985652923584]),new Float32Array([-4.019203186035156,-.0013908070977777243,-.24615326523780823,3.907538652420044,-.0012724152766168118,.11990431696176529])];if("FACE"==t)return[n=new Float32Array([-9.037608623504639,2.355806514620781,-8.28516685962677,-8.81279444694519,-.11831151321530342,-7.542072296142578,-8.38990831375122,-2.418052017688751,-7.253487825393677,8.400188446044922,-2.424757957458496,-7.240226984024048,8.831642150878906,-.11823836714029312,-7.535887956619263,9.061289668083191,2.362936556339264,-8.284585356712341,-1.901270106434822,6.1033472418785095,1.311941035091877,1.9072290509939194,6.117302238941193,1.3117250353097916,-.0015033446252346039,4.03810042142868,1.5223239958286285,.0047621168196201324,2.571689784526825,2.513868987560272,.004333397373557091,1.2499050498008728,3.5467670559883118,-.0007506050169467926,-.2351544015109539,4.379635065793991,-1.5987120568752289,-1.6273340582847595,1.7652730643749237,.013800747692584991,-1.9495649933815002,2.5874924659729004,1.6161270439624786,-1.629391998052597,1.7741851210594177,-5.2972798347473145,3.732409954071045,-.8603600263595581,-2.2803800106048584,3.479170083999634,-.39132800698280334,2.189579963684082,3.4696600437164307,-.3517009913921356,5.284249782562256,3.7591500282287598,-.8421319723129272]),new Float32Array([])];if("HAND"==t){for(var n,r=((n=new Float32Array([3.57,6.02,0,6.68,8.76,.75,8.51,9.69,.75,10.68,6.14,0,13.29,5.55,.01,10.19,4.74,0,12.84,4.16,.01,9.27,3.56,0,11.75,2.81,.01,8.04,2.58,0,9.9,1.71,.01]))[21]+n[24])/2,a=(n[22]+n[25])/2,i=(n[23]+n[26])/2,s=0;s<n.length/3;s++)n[3*s]-=r,n[3*s+1]-=a,n[3*s+2]-=i;return[n,new Float32Array([9.27,3.56,0,11.75,2.81,-.01])]}var o=[],u=[];"LAMBORGHINI"==t?o=[85,131,198,203,320,391,401,404,791,886,891,1008,1075,1085]:"HORSE"==t?o=[12,15,264,352,360,845,1119,1316,1498,1872,2065,3146,4269,4273,4590,4593,7671,8034,8756,9119]:"WATSON-CAN"==t?(o=[335,1290,1330,2591,2669,2700,2822,3488,3613,5569,5574,5613,5639,5679,5685],u=[871,482]):"MARTELL-BOTTLE"==t?(o=[11,24,38,83,85,151,182,200,207,222,893,1646,1971,2013,2221,2229,2271,2309,2376,2444,2459,2725,2787,2792],u=[24,893]):"NECKLACE"==t?(o=[670,42,48,551,160,155,762],u=[640,762]):"CAN-KIVISENSE"==t?(o=[38,53,89,981,1006,1009,1019,1024,1034,1046,1052,1062,1087,1096,1105,1117,1124,1144,1148,1154],u=[1914,2725]):"TOY-TRUCK"==t?(o=[],u=[]):"WRIST"==t&&(o=[2,15,24,33,42,56,65,74,83,92,213,321,338,360,393,416,472,481,487,576,622,746,804,838,896,905,913,922,931,940,949,958,977,986,996,1005,1010,1019,1028,1037,1046,1055,1077,1086,1092,1101,1164,1173,1182,1267,1311,1321,1323,1346,1354,1372,1428,1451,1460,1468,1478,1503,1513,1554,1588,1597,1605,1641,1649,1692,1709,1735,1738,1762,1772,1789,1793,1819,1840,1850,1876,1894,1899,1921,1926,1935,1948,1953,1962,1971,1980,1989,2002,2007,2016,2025,2038,2056,2061,2083,2170,2435,2459,2513,2530,2594,2674,2718,2745,2748,2753,2772,2775,2791,2797,2803,2899,2905,2947,3003,3034,3084,3093,3109,3112,3128,3129,3136,3168,3175,3205,3208,3305,3323,3324,3331,3365,3368,3371,3374,3378,3386,3389,3392,3395,3398,3414,3418,3434,3437,3440,3443,3446,3462,3496,3509,3512,3689,3690,3691,3692,3693,3747,3748,3760,3764,3777,3778,3782,3783,3784,3787,3788,3792,3793,3797,3799,3800,3804,3805,3809],u=[]);var l=o.length,c=new Float32Array(3*l);o.forEach((function(t,n){c[3*n]=e[3*t],c[3*n+1]=e[3*t+1],c[3*n+2]=e[3*t+2]}));var h=new Float32Array(3*u.length);return u.forEach((function(t,n){h[3*n]=e[3*t],h[3*n+1]=e[3*t+1],h[3*n+2]=e[3*t+2]})),[c,h]}(A._geometryObjModel.vertices,A._geometryType),A._keypsVts=t[0],A._refKeypsVts=t[1];var a=Math.max(A._detectorOutDims[1]*A._detectorOutDims[2]*A._detectorOutDims[3]);A._trackHasHeatmaps&&(a=Math.max(A._detectorOutDims[1]*A._detectorOutDims[2]*A._detectorOutDims[3],A._trackerOutDims[1]*A._trackerOutDims[2]*A._trackerOutDims[3]));var i=Math.max(A._detectorOutDims[3],A._trackerOutDims[3]);if(A._bufferHeatmaps=A._poseModule._malloc(a*A._float_size),A._bufferKeypsDet=A._poseModule._malloc(2*A._detectorOutDims[3]*A._float_size),A._bufferKeypsTrack=A._poseModule._malloc(2*A._trackerOutDims[3]*A._float_size),A._bufferFeatureScores=A._poseModule._malloc(i*A._float_size),A._bufInOutPose=A._poseModule._malloc(21*A._float_size),e.pdmModel){var s=new Uint8Array(e.pdmModel);A._bufferPdmModel=A._poseModule._malloc(s.byteLength),A._poseModule.HEAPU8.set(s,A._bufferPdmModel);var o={rigid_pose:0,num_iterations:1,filter_strength:5,reg_w:10,fovy_d:50,width:640,height:480,num_features:A._geometryType==BA.Face?A._trackerOutDims[3]:-1,modelContent:A._bufferPdmModel,modelContentSize:s.byteLength,modelEncoding:A._geometryType==BA.Face?2:1},u=A._poseModule._malloc(44);A._poseModule.setValue(u+0,o.rigid_pose,"i32"),A._poseModule.setValue(u+4,o.num_iterations,"i32"),A._poseModule.setValue(u+8,o.filter_strength,"i32"),A._poseModule.setValue(u+12,o.reg_w,"float"),A._poseModule.setValue(u+16,o.fovy_d,"float"),A._poseModule.setValue(u+20,o.width,"i32"),A._poseModule.setValue(u+24,o.height,"i32"),A._poseModule.setValue(u+28,o.num_features,"i32"),A._poseModule.setValue(u+32,o.modelContent,"*"),A._poseModule.setValue(u+36,o.modelContentSize,"i32"),A._poseModule.setValue(u+40,o.modelEncoding,"i32");var l=A._poseModule.cwrap("xzimgPoseEstimationInitialize","number",["number"])(u);A._debug&&console.log("PDM initialisation: ",l),A._poseModule._free(u),A._poseModule._free(A._bufferPdmModel),A._nonRigidInitialized=!0}else if(null==A._bufKeyps3D){A._bufKeyps3D=A._poseModule._malloc(A._keypsVts.length*A._float_size),A._poseModule.HEAPF32.set(A._keypsVts,A._bufKeyps3D/4);var c=Array.from(A._keypsVts);c.forEach((function(e,t){t%3==0&&(c[t]=-c[t])})),A._bufMirroredKeyps3D=A._poseModule._malloc(c.length*A._float_size),A._poseModule.HEAPF32.set(A._keypsVts,A._bufMirroredKeyps3D/4)}A._initialized=!0})),ae((function(){return S.unsubscribe()}))).toPromise()];case 3:return c.sent(),[2]}}))}))},e.prototype.release=function(){this._initialized&&(this._tfKeypointsDetector.dispose(),this._tfKeypointsTracker.dispose(),null!=this._bufferHeatmaps&&this._poseModule._free(this._bufferHeatmaps),this._bufferHeatmaps=null,null!=this._bufferKeypsDet&&this._poseModule._free(this._bufferKeypsDet),this._bufferKeypsDet=null,null!=this._bufferKeypsTrack&&this._poseModule._free(this._bufferKeypsTrack),this._bufferKeypsTrack=null,null!=this._bufferFeatureScores&&this._poseModule._free(this._bufferFeatureScores),this._bufferFeatureScores=null,null!=this._bufInOutPose&&this._poseModule._free(this._bufInOutPose),this._bufInOutPose=null,null!=this._bufKeyps3D&&this._poseModule._free(this._bufKeyps3D),this._bufKeyps3D=null,null!=this._bufMirroredKeyps3D&&this._poseModule._free(this._bufMirroredKeyps3D),this._bufMirroredKeyps3D=null,null!=this._hptrImageBuffer&&this._poseModule._free(this._hptrImageBuffer),this._hptrImageBuffer=null,this._bufDenseVertices3D&&this._poseModule._free(this._bufDenseVertices3D),this._bufDenseVertices3D=null,this._poseModule.cwrap("xzimgPoseEstimationRelease")(),this._currentWidth=0,this._currentHeight=0,this._initialized=!1,this._nonRigidInitialized=!1,this._trackingState=pA.Detection)},e.prototype.trackSync=function(e){var t;if(this._initialized){var n=this._videoManager.getVideoCanvas();n.width===this._currentWidth&&n.height===this._currentHeight||(this._currentWidth=n.width,this._currentHeight=n.height,t=PA.getCameraParams(this._config.fovY,this._currentWidth,this._currentHeight),this._fx=t[0],this._fy=t[1],this._cx=t[2],this._cy=t[3],this._poseModule.cwrap("xzimgInitializeCamera","number",["number","number","number"])(this._config.fovY,this._currentWidth,this._currentHeight)),this._poseManager.setNbFramesDelay(this._videoManager.getNbFramesDelay());var r=e;null==e&&(r=this._videoManager.getLastBuffer()),null!=r?this.trackGeometrySync(r):console.error("No video frame to process")}else console.error("Geometry must be initialized to track")},e.prototype.trackGeometrySync=function(e){var t,n,r=jA(this._geometryType)||this._geometryType==BA.Wrist||this._geometryType==BA.Hand||this._geometryType==BA.Face;if(this._trackingState===pA.Detection){var a=this._poseModule.cwrap("xzimgMatchRecKeypsInit","number",["number"]);null==this._hptrImageBuffer&&(this._hptrImageBuffer=this._poseModule._malloc(e.width*e.height*4)),IA(this._poseModule,e,this._hptrImageBuffer);var i=AA(this._poseModule,this._hptrImageBuffer,e.width,e.height);a(i),this._poseModule._free(i);var s=this.detectGeometrySync(e),o=s.refinedFeatures,u=s.scores;this._keyps2D=o;var l=sA(u,this._config.validDetectedKeypThs);if(this._visibility=l.visibilty,this._trackingState=pA.Detection,l.totalVisible>=this._config.detectNumKeypsThs&&l.globalScore>=this._config.detectScoreThs){if(this._geometryType==BA.Wrist){this._mirrored=!1;var c=(t=this._keyps2D,n=l.visibilty,(9==t.length/2?n[0]&&n[1]?fA.CreateFromPoints(new dA(t[0],t[9]),new dA(t[1],t[10])):fA.CreateFromPoints(new dA(t[1],t[10]),new dA(t[6],t[15])):fA.CreateFromPoints(new dA(t[30],t[211]),new dA(t[163],t[344]))).x>0?"left":"right");this._mirrored="left"==c}r?this._trackingState=pA.Detected:(this._reprojError=this.computePoseSync(this._trackingState,this._geometryType),this._reprojError>0&&this._reprojError<this._config.reprojThs&&(this._trackingState=pA.Detected))}}else{var h=this.trackGeometryFeaturesSync(e,this._trackingState,this._keyps2D,this._visibility,this._geometryType);this._keyps2D=h.imageFilteredKeyps,this._cropKeyps2D=h.cropKeyps,l=sA(h.scores,this._config.validTrackedKeypThs),this._visibility=l.visibilty;var p=cA(this._geometryType,this._keyps2D.length/2);this._visibility[p[0]]&&this._visibility[p[1]]&&l.totalVisible>=this._config.trackedNumKeypsThs&&l.globalScore>=this._config.trackScoreThs?this._config.computePose?(this._reprojError=this.computePoseSync(this._trackingState,this._geometryType),this._reprojError<=0||this._reprojError>this._config.reprojThs?this._trackingState=pA.Detection:this._trackingState=pA.Tracking):this._trackingState=pA.Tracking:this._trackingState=pA.Detection}(this._trackingState===pA.Detection||this._trackingState===pA.Detected&&r)&&(this._pose=new PA(new Float32Array([1,0,0,0,-1,0,0,0,-1]),new Float32Array([0,0,0])),this._pose.setTrackingState(pA.Detection)),this._pose.setTrackingState(this._trackingState),this._poseManager.setPose(this._pose)},e.prototype.detectGeometrySync=function(e){var t,n,r,a=function(e,t){var n,r;return{crop:e>t?[(r=0)/t,(n=(e-t)/2)/e,1,(e-n)/e]:[(r=(t-e)/2)/t,(n=0)/e,(t-r)/t,1],deltaY:r,deltaX:n}}(this._currentWidth,this._currentHeight),i=a.crop,s=a.deltaY,o=a.deltaX,u=Vo(e),l=ko(u,"float32"),c=Bu(l,[1,this._currentHeight,this._currentWidth,3]),h=gd.cropAndResize(c,[i],[0],[this._detectorConfig.inHeight,this._detectorConfig.inWidth]),p=Gl(255),d=hu(h,p),f=this._tfKeypointsDetector.predict(d),m=f.dataSync(),g=this._poseModule.cwrap("xzimgGetHeatmapsLocations","number",["number","number","number","number","number","number","number","number"]),y=null!==(t=null==f?void 0:f.shape[3])&&void 0!==t?t:this._detectorConfig.outChannels,b=null!==(n=null==f?void 0:f.shape[1])&&void 0!==n?n:this._detectorConfig.outHeight,v=null!==(r=null==f?void 0:f.shape[2])&&void 0!==r?r:this._detectorConfig.outWidth,w=y*b*v,_=this._bufferHeatmaps/4;this._poseModule.HEAPF32.subarray(_,_+w).set(m),g(this._bufferHeatmaps,b,v,y,0,1,this._bufferKeypsDet,this._bufferFeatureScores);var x=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufferKeypsDet,2*y),k=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufferFeatureScores,y);u.dispose(),l.dispose(),p.dispose(),h.dispose(),d.dispose(),c.dispose(),f.dispose();var T=Math.min(this._currentWidth,this._currentHeight),E=T/this._detectorConfig.inWidth,S=T/this._detectorConfig.inHeight;return this._simCropToImage=function(e,t,n,r){var a=new Float32Array(6);return a[0]=r,a[1]=0,a[2]=t,a[3]=0,a[4]=n,a[5]=e,a}(s,o,S,E),{refinedFeatures:lA(x,this._simCropToImage,!1,f.shape[1]),scores:k}},e.prototype.trackGeometryFeaturesSync=function(e,t,n,r,a){var i,s,o,u,l=Int32Array.from(r);this._activeIds.length>0&&(l.forEach((function(e,t){l[t]=0})),this._activeIds.forEach((function(e){l[e]=1})),r.forEach((function(e,t){0==e&&(l[t]=0)})));var c,h,p=new Float32Array([0,0]);if(t!=pA.Detected){if(s=(i=CA(this._poseModule,e,this._hptrImageBuffer,n,l))[0],o=i[1],u=i[2],Math.sqrt(o[2]*o[2]+o[3]*o[3])>10?this._fastMvt=!0:this._fastMvt=!1,a==BA.FullBody?[7,8,9,10,13,14,15,16].forEach((function(e){u[e]=0})):a==BA.UpperBody?[7,8,9,10].forEach((function(e){u[e]=0})):a==BA.Necklace?[1,2,3,4,5].forEach((function(e){u[e]=0})):this._activeIds.length>0&&this._activeIds.forEach((function(e){u[e]=0})),p=function(e,t,n,r,a,i,s){void 0===a&&(a=null);for(var o=new Float32Array(2),u=n.length/2,l=0,c=0;c<u;c++)(null==a||a[c]>0)&&(o[0]+=r[c]-n[c],o[1]+=r[c+u]-n[c+u],l+=1);l>0&&(o[0]/=l,o[1]/=l);var h=t/4,p=new Float32Array(18);return p.set(e.HEAPF32.subarray(h,h+18)),p[9]+=o[0]*p[11]/i,p[10]+=o[1]*p[11]/s,e.HEAPF32.set(p,t/4),o}(this._poseModule,this._bufInOutPose,n,s,u,this._fx,this._fy),a==BA.Necklace)for(var d=s.length/2,f=0;f<d;f++)s[f]=n[f]+p[0],s[f+d]=n[f+d]+p[1]}else s=n;if("WATSON-CAN"==a||"CAN-KIVISENSE"==a||"TOY-TRUCK"==a||"CHIVAS"==a||"CHIVAS-LARGE"==a||"LION"==a||"BARTENDER"==a||"WCBOTTLE"==a||"EQA"==a||"MARTELL-BOTTLE"==a){var m=this._pose.project(this._refKeypsVts,PA.getCameraMat(this._config.fovY,this._currentWidth,this._currentHeight));c=-Math.atan2(m[1]-m[3],m[2]-m[0]),"EQA"==a&&(c=0);var g=this._pose.project(this._keypsVts,PA.getCameraMat(this._config.fovY,this._currentWidth,this._currentHeight));for(h=new Float32Array(g.length),f=0;f<h.length/2;f++)h[f]=g[2*f],h[f+h.length/2]=g[2*f+1]}var y=Float32Array.from(n),b=s.length/2;for(f=0;f<b;f++)y[f]+=p[0],y[f+b]+=p[1];jA(a)?this._simCropToImage=function(e,t,n,r,a){var i,s,o,u=t.length/2,l=Array(5),c=new Array(5);if(7==u)l[0]=n[0]>0?1:0,c[0]=new zA(t[0],t[u]),l[1]=n[3]>0&&n[4]>0?1:0,c[1]=new zA((t[3]+t[4])/2,(t[3+u]+t[4+u])/2),l[2]=n[5]>0&&n[6]>0?1:0,c[2]=new zA((t[5]+t[6])/2,(t[5+u]+t[6+u])/2),l[3]=n[1]>0?1:0,c[3]=new zA(t[1],t[1+u]),l[4]=n[2]>0?1:0,c[4]=new zA(t[2],t[2+u]);else{var h=15==u?13:17,p=15==u?14:18;l[0]=n[0]>0?1:0,c[0]=new zA(t[0],t[u]),l[1]=n[h]>=0?1:0,c[1]=new zA(t[h],t[h+u]),l[2]=n[p]>=0?1:0,c[2]=new zA(t[p],t[p+u]),l[3]=n[1]>0?1:0,c[3]=new zA(t[1],t[1+u]),l[4]=n[2]>0?1:0,c[4]=new zA(t[2],t[2+u])}if("FULL-BODY"==e)if(l[1]>0&&l[2]>0)i=c[2],s=-Math.atan2(c[2].y-c[1].y,c[1].x-c[2].x),s+=Math.PI/2,o=2*c[2].Dist(c[1])*2.35;else if(l[0]>0&&l[1]>0)(i=c[1]).y+=2.24*(c[1].y-c[0].y),s=-Math.atan2(c[1].y-c[0].y,c[0].x-c[1].x),s+=Math.PI/2,o=2*c[0].Dist(c[1])*5.3;else if(l[0]>0&&l[2]>0)i=c[2],s=-Math.atan2(c[2].y-c[0].y,c[0].x-c[2].x),s+=Math.PI/2,o=2*c[0].Dist(c[2])*1.64;else{if(!(l[0]>0&&l[3]>0&&l[4]>0))return 0;var d=c[3].Dist(c[4]);(i=c[0]).y+=3*d,s=-Math.atan2(c[4].y-c[3].y,c[3].x-c[4].x),o=2*d*14}else if(console.log(l),l[1]>0&&l[2]>0)i=c[1],s=-Math.atan2(c[2].y-c[1].y,c[1].x-c[2].x),s+=Math.PI/2,o=2*c[2].Dist(c[1])*1.2;else if(l[0]>0&&l[1]>0)i=c[1],s=-Math.atan2(c[1].y-c[0].y,c[0].x-c[1].x),s+=Math.PI/2,o=2*c[0].Dist(c[1])*2.6;else if(l[0]>0&&l[2]>0)i=new zA(c[2].x+.75*(c[0].x-c[2].x),c[2].y+.75*(c[0].y-c[2].y)),s=-Math.atan2(c[2].y-c[0].y,c[0].x-c[2].x),s+=Math.PI/2,o=2*c[0].Dist(c[2])*.8;else{if(!(l[0]>0&&l[3]>0&&l[4]>0))return 0;d=c[3].Dist(c[4]),(i=c[0]).y+=5.5*d,s=-Math.atan2(c[4].y-c[3].y,c[3].x-c[4].x),o=2*d*11}for(var f=0,m=0;m<u;m++){var g=new zA(t[m],t[m+u]).Dist(i);n[m]>0&&g>f&&(f=g)}o=Math.max(o,2*f);var y=Math.cos(s),b=Math.sin(s),v=(o+.1*o)/Math.max(r[0],r[1]),w=(r[1]-1)/2,_=(r[0]-1)/2,x=i.x-(y*v*w-b*v*_),k=i.y-(b*v*w+y*v*_);if(null!=a){var T=.8;v=(1-T)*v+T*a[7],x=(1-T)*x+T*a[2],k=(1-T)*k+T*a[5],s=(1-T)*s+T*a[6],y=Math.cos(s),b=Math.sin(s)}return[y*v,-b*v,x,b*v,y*v,k,s,v]}(a,void 0===h?s:h,r,[this._trackerConfig.inWidth,this._trackerConfig.inHeight],t==pA.Detected||this._fastMvt?null:this._simCropToImage):a==BA.Face?this._simCropToImage=function(e,t,n,r,a){var i=e.length/2,s=iA(e,t,i),o=new dA((s[0]+s[1])/2,(s[2]+s[3])/2),u=0,l=0,c=.35;if(19==i||21==i){var h=[15,16,17,18];21==i&&(h=[17,18,19,20]),0!=t[17]&&0!=t[20]||(h=[18,19]),0!=t[18]&&0!=t[19]||(h=[17,20]),o=new dA(0,0),h.forEach((function(t){o.x+=e[t],o.y+=e[t+i]})),o.x/=h.length,o.y/=h.length;var p=new dA(e[8],e[8+i]),d=new dA(e[13],e[13+i]);21==i&&(p=new dA(e[10],e[10+i]),d=new dA(e[15],e[15+i])),l=1.57075-Math.atan2(d.y-p.y,p.x-d.x);for(var f=0;f<i;f++){var m=new dA(e[f],e[f+i]).Dist(o);t[f]>0&&m>u&&(u=m)}u*=2,c=.2}else{var g=27,y=62,b=66;22==i&&(g=9,y=18,b=20),24==i&&(g=9,y=20,b=22);var v=void 0;5==i?(v=new dA(.5*(e[0]+e[1]),.5*(e[0+i]+e[1+i])),y=3,b=4):v=new dA(e[g],e[g+i]);var w=new dA(.5*(e[y]+e[b]),.5*(e[y+i]+e[b+i]));if(l=1.57075-Math.atan2(w.y-v.y,v.x-w.x),u=s[1]-s[0],a&&"face_center"==a){o=new dA((v.x+w.x)/2,(v.y+w.y)/2);var _=0;for(f=0;f<i;f++)m=new dA(e[f],e[f+i]).Dist(o),t[f]>0&&m>_&&(_=m);u=2*_}5==i&&(u=2*(s[1]-s[0])),22==i&&(c=.15)}var x=new mA(o.x-u/2,o.y-u/2,u,u),k=Math.cos(l),T=Math.sin(l),E=(x.w+c*x.w)/Math.max(n[0],n[1]),S=n[1]/2,I=n[0]/2,A=o.x-(k*E*S-T*E*I),C=o.y-(T*E*S+k*E*I);if(null!=r){var N=.8;A=N*A+(1-N)*r[2],C=N*C+(1-N)*r[5],E=.3*E+.7*r[7],Math.abs(l-r[6])<1&&(l=.3*l+.7*r[6]),k=Math.cos(l),T=Math.sin(l)}return[k*E,-T*E,A,T*E,k*E,C,l,E]}(void 0===h?y:h,r,[this._trackerConfig.inWidth,this._trackerConfig.inHeight],t==pA.Detected||this._fastMvt?null:this._simCropToImage,this._config.normMode):a==BA.Wrist?this._simCropToImage=function(e,t,n,r,a){var i=e.length/2,s=iA(e,t,i),o=hA("WRIST",e),u=o[0],l=o[1],c=o[2],h=Math.max(s[1]-s[0],s[3]-s[2]);u=(s[1]+s[0])/2,l=(s[3]+s[2])/2,9==i&&!t[0]&&t[1]&&t[6]&&(u=e[1],l=e[10],h=2*Math.sqrt(Math.pow(e[6]-u,2)+Math.pow(e[15]-u,2)));var p=Math.cos(c),d=Math.sin(c),f=(h+=.7*h)/Math.max(n[0],n[1]),m=n[1]/2,g=n[0]/2,y=u-(p*f*m-d*f*g),b=l-(d*f*m+p*f*g);return null!=r&&(y=.5*y+.5*r[2],b=.5*b+.5*r[5],f=.5*f+.5*r[7],p=Math.cos(c),d=Math.sin(c)),[p*f,-d*f,y,d*f,p*f,b,c,f]}(void 0===h?s:h,r,[this._trackerConfig.inWidth,this._trackerConfig.inHeight],t==pA.Detected||this._fastMvt?null:this._simCropToImage,this._config.normMode):a==BA.Hand?this._simCropToImage=function(e,t,n,r,a){var i=e.length/2,s=iA(e,t,i),o=Math.max(s[1]-s[0],s[3]-s[2]),u=hA("HAND",e),l=u[0],c=u[1],h=u[2];if(9==i)t[3]&&t[6]&&(l=.5*(e[3]+e[6]),c=.5*(e[3+i]+e[6+i]),t[1]&&(o=2*Math.sqrt(Math.pow(e[1]-l,2)+Math.pow(e[1+i]-l,2))));else{var p=cA("HAND",i),d=p[0],f=p[1],m=new dA(e[d],e[d+i]),g=new dA(e[f],e[f+i]);if(o=5*m.Dist(g),t[0]){var y=new dA(e[0],e[0+i]),b=2*m.Dist(y);o=Math.max(o,b)}l=m.x,c=m.y}var v=Math.cos(h),w=Math.sin(h),_=(o+=.2*o)/Math.max(n[0],n[1]),x=n[1]/2,k=n[0]/2,T=l-(v*_*x-w*_*k),E=c-(w*_*x+v*_*k);if(null!=r){var S=.9;T=S*T+(1-S)*r[2],E=S*E+(1-S)*r[5],_=.3*_+.7*r[7],Math.abs(h-r[6])<1&&(h=.3*h+.7*r[6]),v=Math.cos(h),w=Math.sin(h)}return[v*_,-w*_,T,w*_,v*_,E,h,_]}(void 0===h?s:h,r,[this._trackerConfig.inWidth,this._trackerConfig.inHeight],t==pA.Detected||this._fastMvt?null:this._simCropToImage,this._config.normMode):this._simCropToImage=function(e,t,n,r,a,i){var s,o,u=e.length/2;void 0===i&&((s=hA(a,e))[0],s[1],i=s[2]),o=aA(e,u);var l=Math.cos(i),c=Math.sin(i),h=Math.sqrt((o[1]-o[0])*(o[1]-o[0])+(o[3]-o[2])*(o[3]-o[2])),p=.3;"NECKLACE"==a&&(p=.5),"MARTEL-BOTTLE"==a&&(p=.2),"EQA"==a&&(p=.2),"BARTENDER"==a&&(p=.2);var d=(h+=p*h)/Math.max(n,t),f=(t-1)/2,m=(n-1)/2,g=(o[0]+o[1])/2-(l*d*f-c*d*m),y=(o[2]+o[3])/2-(c*d*f+l*d*m);if(null!=r){if("NECKLACE"==a){var b=.9;g=b*g+(1-b)*r[2],y=b*y+(1-b)*r[5],d=.3*d+.7*r[7],Math.abs(i-r[6])<1&&(i=.3*i+.7*r[6])}else{var v=Math.sqrt((g-r[2])*(g-r[2])+(y-r[5])*(y-r[5])),w=1;v>20&&(w=.1),v>=10&&v<=20&&(w=1-.09*(v-5)),g=(1-w)*g+w*r[2],y=(1-w)*y+w*r[5],i=Math.abs(i-r[6])>1?(1-w)*i-w*r[6]:(1-w)*i+w*r[6],d=(1-w)*d+w*r[7]}l=Math.cos(i),c=Math.sin(i)}return[l*d,-c*d,g,c*d,l*d,y,i,d]}(void 0===h?s:h,this._trackerConfig.inWidth,this._trackerConfig.inHeight,t==pA.Detected||this._fastMvt?null:this._simCropToImage,a,c);var v=new ImageData(this._trackerConfig.inWidth,this._trackerConfig.inHeight);v=function(e,t,n){for(var r=n[0],a=n[1],i=n[2],s=n[3],o=n[4],u=n[5],l=e.width,c=e.height,h=4*e.width,p=t.width,d=t.height,f=4*t.width,m=0;m<d;m++)for(var g=a*m+i,y=o*m+u,b=m*f,v=0;v<p;v++){var w=4*v,_=Math.floor(g),x=Math.floor(y),k=g-_,T=y-x,E=void 0,S=void 0;if(_>0&&_<l-1&&x>0&&x<c-1){for(var I=x*h+4*_,A=0;A<3;A++,I++){var C=e.data[I];E=C+k*(e.data[I+4]-C),S=e.data[I+h]+k*(e.data[I+h+4]-e.data[I+h]),t.data[b+w+A]=E+T*(S-E)}t.data[b+w+3]=255}else{for(A=0;A<3;A++)t.data[b+w+A]=0;t.data[b+w+3]=255}g+=r,y+=s}return t}(e,v,this._simCropToImage),this._debug&&(this._debugInitialized=!0,this._debugImage=v,uA(this._trackerConfig.inHeight,this._trackerConfig.inWidth,4,v));var w=function(e,t,n,r,a,i,s,o){for(var u=[],l=[],c=[],h=[],p=0,d=null,f=0,m=s;f<m.length;f++){var g=Vo(m[f]);h.push(g);var y=ko(g,"float32");h.push(y);var b=Bu(y,[1,t.inHeight,t.inWidth,3]);h.push(b);var v=Gl(255),w=hu(b,v);h.push(w),o[p]&&(w=Sh(w,1),h.push(w)),d?(d=zu([d,w]),h.push(d)):d=w,p+=1}if(null!=d){var _=[];if(t.numOutputs&&1!=t.numOutputs)for(var x=0,k=_=e.predict(d);x<k.length;x++){var T=k[x];h.push(T)}else{var E=e.predict(d);h.push(E),_.push(E)}for(var S=0,I=0,A=_;I<A.length;I++){E=A[I];for(var C=[],N=[],R=0,F=sp(E,0);R<F.length;R++){var O=F[R];h.push(O);var M=Zl(O,0);h.push(M),C.push(O.dataSync()),N.push(M.shape)}if(t.outputNames&&"heatmaps"!=t.outputNames[S]){if(t.outputNames&&"coordinates"==t.outputNames[S])for(z=0;z<C.length;z++){for(var $=N[z][1]/2,D=new Float32Array(2*$),P=t.inHeight/2,L=t.inWidth/2,B=0;B<$;B++)D[B]=(C[z][B]+1)*L,D[B+$]=(C[z][B+$]+1)*P;u.push(D)}else if(t.outputNames&&"scores"==t.outputNames[S])for(z=0;z<C.length;z++){var U=N[z][1],W=new Float32Array(U);for(B=0;B<U;B++)W[B]=1/(1+Math.exp(-C[z][B]));l.push(W)}else if(t.outputNames&&"occlusions"==t.outputNames[S])for(z=0;z<C.length;z++){U=N[z][1];var V=new Float32Array(U);for(B=0;B<U;B++)V[B]=1/(1+Math.exp(-C[z][B]));c.push(V)}}else for(var z=0;z<C.length;z++){var j;j=n?OA(n,N[z],C[z],r[z],a[z],i[z]):FA(C[z],N[z],!0),u.push(j[0]),l.push(j[1])}S+=1}}return h.forEach((function(e){return e.dispose()})),{coordinates:u,scores:l,occlusions:c}}(this._tfKeypointsTracker,this._trackerConfig,this._poseModule,[this._bufferHeatmaps],[this._bufferKeypsTrack],[this._bufferFeatureScores],[v],[this._mirrored]),_=lA(w.coordinates[0],this._simCropToImage,this._mirrored,this._trackerConfig.outHeight);if(t!=pA.Detected){var x=oA(w.scores[0],this._config.validTrackedKeypThs);if(a==BA.Face&&!this._nonRigidInitialized){var k=this._pose.project(this._keypsVts,PA.getCameraMat(this._config.fovY,this._currentWidth,this._currentHeight)),T=_.length/2;for(f=0;f<T;f++)0==x[f]&&(x[f]=1,_[f]=k[2*f],_[f+T]=k[2*f+1])}_=gA(_,x,s,r,.1)}return{imageFilteredKeyps:_,cropKeyps:w.coordinates[0],scores:w.scores[0]}},e.prototype.computePoseSync=function(e,t){return this._nonRigidInitialized&&(jA(t)||t==BA.Wrist||t==BA.Face)?this.computeNonRigidPoseSync(e,t):this.computeRigidPoseSync(e,t)},e.prototype.computeRigidPoseSync=function(e,t){var n=this,r=-1,a=this._poseModule.cwrap("xzimgEstimateRigidPose","number",["number","number","number","number","number","number","number","number","number","number","number","number"]);if(e==pA.Detection){var i=0,s=0,o=t==BA.Necklace?3:0,u=1,l=[1,0,0,0,1,0],c=(p=this._poseModule._malloc(6*this._float_size))/4,h=this._poseModule.HEAPF32.subarray(c,c+6);return this._trackHasHeatmaps?h.set(this._simCropToImage.slice(0,6)):h.set(l),r=a(this._bufferHeatmaps,this._detectorOutDims[1],this._detectorOutDims[2],this._detectorOutDims[3],i,p,this._bufferKeypsDet,this._mirrored?this._bufMirroredKeyps3D:this._bufKeyps3D,s,o,u,this._bufInOutPose),this._pose=new PA(new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose,9),new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose+9*this._float_size,3)),r}if(e==pA.Detected||e==pA.Tracking){i=0,s=e!=pA.Tracking||this._resetPose?0:1,this._resetPose=!1,o=t==BA.Hand||t==BA.Necklace||t==BA.Lamborghini?3:1,u=t==BA.Hand||t==BA.Necklace||t==BA.Lamborghini?3:1,c=(p=this._poseModule._malloc(6*this._float_size))/4;var p,d=this._poseModule.HEAPF32.subarray(c,c+6);this._trackHasHeatmaps&&3==o?d.set(this._simCropToImage.slice(0,6)):(l=[1,0,0,0,1,0],d.set(l));var f=null,m=null,g=new Float32Array(2*this._activeIds.length),y=new Float32Array(3*this._activeIds.length),b=this._keyps2D.length/2;this._activeIds.length>0?(this._activeIds.forEach((function(e,t){g[t]=n._keyps2D[e],g[t+n._activeIds.length]=n._keyps2D[e+b]})),c=(f=this._poseModule._malloc(this._activeIds.length*this._float_size*2))/4,(d=this._poseModule.HEAPF32.subarray(c,c+2*this._activeIds.length)).set(g),this._activeIds.forEach((function(e,t){y[3*t]=n._keypsVts[3*e],n._mirrored&&(y[3*t]=-y[3*t]),y[3*t+1]=n._keypsVts[3*e+1],y[3*t+2]=n._keypsVts[3*e+2]})),c=(m=this._poseModule._malloc(this._activeIds.length*this._float_size*3))/4,(d=this._poseModule.HEAPF32.subarray(c,c+3*this._activeIds.length)).set(y),b=this._activeIds.length):(c=(f=this._poseModule._malloc(this._keyps2D.length*this._float_size))/4,(d=this._poseModule.HEAPF32.subarray(c,c+this._keyps2D.length)).set(this._keyps2D),2!=o&&3!=o||d.set(this._cropKeyps2D),m=this._mirrored?this._bufMirroredKeyps3D:this._bufKeyps3D),r=a(2==o||3==o?this._bufferHeatmaps:null,this._trackerOutDims[1],this._trackerOutDims[2],b,i,p,f,m,s,o,u,this._bufInOutPose);var v=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose,9),w=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose+9*this._float_size,3);this._pose=new PA(v,w);var _=this._pose.project(this._keypsVts,PA.getCameraMat(this._config.fovY,this._currentWidth,this._currentHeight));this._reprojKeyps2D=new Float32Array(_.length);for(var x=0;x<_.length/2;x++)this._reprojKeyps2D[x]=_[2*x],this._reprojKeyps2D[x+this._reprojKeyps2D.length/2]=_[2*x+1];if(t==BA.Necklace){var k=this._pose.getRot();k[5]>.35&&(console.log(k[2],k[5],k[8]),k[2]=0,k[5]=0,k[8]=-1,this._pose.updateRotation(k))}return this._keyps3D=this._pose.transform(this._keypsVts),f&&this._poseModule._free(f),m&&this._activeIds.length>0&&this._poseModule._free(m),p&&this._poseModule._free(p),r}return-1},e.prototype.computeNonRigidPoseSync=function(e,t){var n;n=jA(t)?this._poseModule.cwrap("xzimgEstimateBodyNonRigidPose","number",["number","number","number","number","number","number","number","number","number","number","number"]):this._poseModule.cwrap("xzimgEstimateNonRigidPoseBase","number",["number","number","number","number","number","number","number","number","number","number","number"]);var r,a=e==pA.Detected?1:0,i=this._trackerOutDims[3],s=(r=this._poseModule._malloc(this._keyps2D.length*this._float_size))/4;this._poseModule.HEAPF32.subarray(s,s+this._keyps2D.length).set(this._keyps2D);var o=this._poseModule._malloc(i*this._int_size),u=o/4;this._poseModule.HEAPF32.subarray(u,u+i).set(this._visibility),null==this._bufKeyps3D&&(this._bufKeyps3D=this._poseModule._malloc(i*this._float_size*3));var l=1e3;t==BA.Face&&(l=10),t==BA.Wrist&&(l=100);var c=n(a,r,i,o,1,l,this._config.reprojThs,.5,.75,.95,this._bufInOutPose,this._bufKeyps3D),h=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose,9),p=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufInOutPose+9*this._float_size,3);this._pose=new PA(h,p),this._keyps3D=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufKeyps3D,3*i),this._poseModule._free(r),this._poseModule._free(o);var d=this._poseModule.cwrap("xzimgEstimateGetNumVertices","number"),f=this._poseModule.cwrap("xzimgEstimateGetDenseVertices","number"),m=d();return m>0&&(null==this._bufDenseVertices3D&&(this._bufDenseVertices3D=this._poseModule._malloc(m*this._float_size*3)),f(this._bufDenseVertices3D),this._denseVertices=new Float32Array(this._poseModule.HEAPF32.buffer,this._bufDenseVertices3D,3*m)),c},e}(),eC=Object.defineProperty,tC=Object.getOwnPropertySymbols,nC=Object.prototype.hasOwnProperty,rC=Object.prototype.propertyIsEnumerable,aC=Math.pow,iC=(e,t,n)=>t in e?eC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sC=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},oC=(e,t,n)=>(sC(e,t,"read from private field"),n?n.call(e):t.get(e)),uC=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},lC=(e,t,n,r)=>(sC(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),cC=(e,t,n)=>(sC(e,t,"access private method"),n),hC=new Uint8Array(8),pC=new DataView(hC.buffer),dC=e=>[(e%256+256)%256],fC=e=>(pC.setUint16(0,e,!1),[hC[0],hC[1]]),mC=e=>(pC.setUint32(0,e,!1),[hC[1],hC[2],hC[3]]),gC=e=>(pC.setUint32(0,e,!1),[hC[0],hC[1],hC[2],hC[3]]),yC=e=>(pC.setUint8(0,e),pC.setUint8(1,e<<8),[hC[0],hC[1]]),bC=e=>(pC.setUint16(0,e,!1),pC.setUint16(2,e<<16,!1),[hC[0],hC[1],hC[2],hC[3]]),vC=(e,t=!1)=>{let n=Array(e.length).fill(null).map(((t,n)=>e.charCodeAt(n)));return t&&n.push(0),n},wC=e=>e&&e[e.length-1],_C=(e,t,n=!0)=>{let r=e*t;return n?Math.round(r):r},xC=[65536,0,0,0,65536,0,0,0,1073741824].map(gC),kC=(e,t,n)=>({type:e,contents:t&&new Uint8Array(t.flat(10)),children:n}),TC=(e,t,n,r,a)=>kC(e,[dC(t),mC(n),null!=r?r:[]],a),EC=(e,t)=>{let n=_C(Math.max(0,...t.filter((e=>e.samples.length>0)).map((e=>wC(e.samples).timestamp+wC(e.samples).duration))),VN),r=Math.max(...t.map((e=>e.id)))+1;return TC("mvhd",0,0,[gC(e),gC(e),gC(VN),gC(n),bC(1),yC(1),Array(10).fill(0),xC,Array(24).fill(0),gC(r)])},SC=(e,t)=>{let n=wC(e.samples),r=_C(n?n.timestamp+n.duration:0,VN);return TC("tkhd",0,3,[gC(t),gC(t),gC(e.id),gC(0),gC(r),Array(8).fill(0),fC(0),fC(0),yC("audio"===e.info.type?1:0),fC(0),xC,bC("video"===e.info.type?e.info.width:0),bC("video"===e.info.type?e.info.height:0)])},IC=(e,t)=>kC("mdia",null,[AC(e,t),CC("video"===e.info.type?"vide":"soun"),NC(e)]),AC=(e,t)=>{let n=wC(e.samples),r=_C(n?n.timestamp+n.duration:0,e.timescale);return TC("mdhd",0,0,[gC(t),gC(t),gC(e.timescale),gC(r),fC(21956),fC(0)])},CC=e=>TC("hdlr",0,0,[vC("mhlr"),vC(e),gC(0),gC(0),gC(0),vC("mp4-muxer-hdlr")]),NC=e=>kC("minf",null,["video"===e.info.type?RC():FC(),OC(),DC(e)]),RC=()=>TC("vmhd",0,1,[fC(0),fC(0),fC(0),fC(0)]),FC=()=>TC("smhd",0,0,[fC(0),fC(0)]),OC=()=>kC("dinf",null,[MC()]),MC=()=>TC("dref",0,0,[gC(1)],[$C()]),$C=()=>TC("url ",0,1),DC=e=>kC("stbl",null,[PC(e),UC(e),WC(e),VC(e),zC(e),jC(e)]),PC=e=>TC("stsd",0,0,[gC(1)],["video"===e.info.type?LC(GC[e.info.codec],e):BC(KC[e.info.codec],e)]),LC=(e,t)=>kC(e,[Array(6).fill(0),fC(1),fC(0),fC(0),Array(12).fill(0),fC(t.info.width),fC(t.info.height),gC(4718592),gC(4718592),gC(0),fC(1),Array(32).fill(0),fC(24),(65535,pC.setInt16(0,65535,!1),[hC[0],hC[1]])],[HC[t.info.codec](t)]),BC=(e,t)=>kC(e,[Array(6).fill(0),fC(1),fC(0),fC(0),gC(0),fC(t.info.numberOfChannels),fC(16),fC(0),fC(0),bC(t.info.sampleRate)],[qC[t.info.codec](t)]),UC=e=>TC("stts",0,0,[gC(e.timeToSampleTable.length),e.timeToSampleTable.map((e=>[gC(e.sampleCount),gC(e.sampleDelta)]))]),WC=e=>{if(e.samples.every((e=>"key"===e.type)))return null;let t=[...e.samples.entries()].filter((([,e])=>"key"===e.type));return TC("stss",0,0,[gC(t.length),t.map((([e])=>gC(e+1)))])},VC=e=>TC("stsc",0,0,[gC(e.compactlyCodedChunkTable.length),e.compactlyCodedChunkTable.map((e=>[gC(e.firstChunk),gC(e.samplesPerChunk),gC(1)]))]),zC=e=>TC("stsz",0,0,[gC(0),gC(e.samples.length),e.samples.map((e=>gC(e.size)))]),jC=e=>e.writtenChunks.length>0&&wC(e.writtenChunks).offset>=aC(2,32)?TC("co64",0,0,[gC(e.writtenChunks.length),e.writtenChunks.map((e=>{return t=e.offset,pC.setUint32(0,Math.floor(t/aC(2,32)),!1),pC.setUint32(4,t,!1),[hC[0],hC[1],hC[2],hC[3],hC[4],hC[5],hC[6],hC[7]];var t}))]):TC("stco",0,0,[gC(e.writtenChunks.length),e.writtenChunks.map((e=>gC(e.offset)))]),GC={avc:"avc1",hevc:"hvc1",vp9:"vp09",av1:"av01"},HC={avc:e=>e.codecPrivate&&kC("avcC",[...e.codecPrivate]),hevc:e=>e.codecPrivate&&kC("hvcC",[...e.codecPrivate]),vp9:e=>e.codecPrivate&&kC("vpcC",[...e.codecPrivate]),av1:e=>e.codecPrivate&&kC("av1C",[...e.codecPrivate])},KC={aac:"mp4a",opus:"opus"},qC={aac:e=>TC("esds",0,0,[gC(58753152),dC(32+e.codecPrivate.byteLength),fC(1),dC(0),gC(75530368),dC(18+e.codecPrivate.byteLength),dC(64),dC(21),mC(0),gC(130071),gC(130071),gC(92307584),dC(e.codecPrivate.byteLength),...e.codecPrivate,gC(109084800),dC(1),dC(2)]),opus:e=>kC("dOps",[dC(0),dC(e.info.numberOfChannels),fC(3840),gC(e.info.sampleRate),yC(0),dC(0)])},XC=class{constructor(){this.buffer=null}},YC=class{constructor(e,t,n){this.onData=e,this.onDone=t,this.options=n}},QC=class{constructor(e,t){this.stream=e,this.options=t}},JC=class{constructor(){this.pos=0,uC(this,GA,new Uint8Array(8)),uC(this,HA,new DataView(oC(this,GA).buffer)),this.offsets=new WeakMap}seek(e){this.pos=e}writeU32(e){oC(this,HA).setUint32(0,e,!1),this.write(oC(this,GA).subarray(0,4))}writeU64(e){oC(this,HA).setUint32(0,Math.floor(e/aC(2,32)),!1),oC(this,HA).setUint32(4,e,!1),this.write(oC(this,GA).subarray(0,8))}writeAscii(e){for(let t=0;t<e.length;t++)oC(this,HA).setUint8(t%8,e.charCodeAt(t)),t%8==7&&this.write(oC(this,GA));e.length%8!=0&&this.write(oC(this,GA).subarray(0,e.length%8))}writeBox(e){var t,n;if(this.offsets.set(e,this.pos),e.contents&&!e.children)this.writeBoxHeader(e,null!=(t=e.size)?t:e.contents.byteLength+8),this.write(e.contents);else{let t=this.pos;if(this.writeBoxHeader(e,0),e.contents&&this.write(e.contents),e.children)for(let t of e.children)t&&this.writeBox(t);let r=this.pos,a=null!=(n=e.size)?n:r-t;this.seek(t),this.writeBoxHeader(e,a),this.seek(r)}}writeBoxHeader(e,t){this.writeU32(e.largeSize?1:t),this.writeAscii(e.type),e.largeSize&&this.writeU64(t)}patchBox(e){let t=this.pos;this.seek(this.offsets.get(e)),this.writeBox(e),this.seek(t)}};GA=new WeakMap,HA=new WeakMap;var ZC,eN,tN=class extends JC{constructor(e){super(),uC(this,YA),uC(this,KA,void 0),uC(this,qA,new ArrayBuffer(aC(2,16))),uC(this,XA,new Uint8Array(oC(this,qA))),lC(this,KA,e)}write(e){cC(this,YA,QA).call(this,this.pos+e.byteLength),oC(this,XA).set(e,this.pos),this.pos+=e.byteLength}finalize(){cC(this,YA,QA).call(this,this.pos),oC(this,KA).buffer=oC(this,qA).slice(0,this.pos)}};KA=new WeakMap,qA=new WeakMap,XA=new WeakMap,YA=new WeakSet,QA=function(e){let t=oC(this,qA).byteLength;for(;t<e;)t*=2;if(t===oC(this,qA).byteLength)return;let n=new ArrayBuffer(t),r=new Uint8Array(n);r.set(oC(this,XA),0),lC(this,qA,n),lC(this,XA,r)};var nN=class extends JC{constructor(e){super(),uC(this,ZC,void 0),uC(this,eN,[]),lC(this,ZC,e)}write(e){oC(this,eN).push({data:e.slice(),start:this.pos}),this.pos+=e.byteLength}flush(){if(0===oC(this,eN).length)return;let e=[],t=[...oC(this,eN)].sort(((e,t)=>e.start-t.start));e.push({start:t[0].start,size:t[0].data.byteLength});for(let n=1;n<t.length;n++){let r=e[e.length-1],a=t[n];a.start<=r.start+r.size?r.size=Math.max(r.size,a.start+a.data.byteLength-r.start):e.push({start:a.start,size:a.data.byteLength})}for(let t of e){t.data=new Uint8Array(t.size);for(let e of oC(this,eN))t.start<=e.start&&e.start<t.start+t.size&&t.data.set(e.data,e.start-t.start);oC(this,ZC).onData(t.data,t.start)}oC(this,eN).length=0}finalize(){var e,t;null==(t=(e=oC(this,ZC)).onDone)||t.call(e)}};ZC=new WeakMap,eN=new WeakMap;var rN,aN,iN,sN,oN,uN,lN,cN,hN,pN,dN,fN=aC(2,24),mN=class extends JC{constructor(e){var t,n;if(super(),uC(this,sN),uC(this,uN),uC(this,cN),uC(this,pN),uC(this,rN,void 0),uC(this,aN,void 0),uC(this,iN,[]),lC(this,rN,e),lC(this,aN,null!=(n=null==(t=e.options)?void 0:t.chunkSize)?n:fN),!Number.isInteger(oC(this,aN))||oC(this,aN)<aC(2,10))throw new Error("Invalid StreamTarget options: chunkSize must be an integer not smaller than 1024.")}write(e){cC(this,sN,oN).call(this,e,this.pos),cC(this,pN,dN).call(this),this.pos+=e.byteLength}finalize(){var e,t;cC(this,pN,dN).call(this,!0),null==(t=(e=oC(this,rN)).onDone)||t.call(e)}};rN=new WeakMap,aN=new WeakMap,iN=new WeakMap,sN=new WeakSet,oN=function(e,t){let n=oC(this,iN).findIndex((e=>e.start<=t&&t<e.start+oC(this,aN)));-1===n&&(n=cC(this,cN,hN).call(this,t));let r=oC(this,iN)[n],a=t-r.start,i=e.subarray(0,Math.min(oC(this,aN)-a,e.byteLength));r.data.set(i,a);let s={start:a,end:a+i.byteLength};if(cC(this,uN,lN).call(this,r,s),0===r.written[0].start&&r.written[0].end===oC(this,aN)&&(r.shouldFlush=!0),oC(this,iN).length>2){for(let e=0;e<oC(this,iN).length-1;e++)oC(this,iN)[e].shouldFlush=!0;cC(this,pN,dN).call(this)}i.byteLength<e.byteLength&&cC(this,sN,oN).call(this,e.subarray(i.byteLength),t+i.byteLength)},uN=new WeakSet,lN=function(e,t){let n=0,r=e.written.length-1,a=-1;for(;n<=r;){let i=Math.floor(n+(r-n+1)/2);e.written[i].start<=t.start?(n=i+1,a=i):r=i-1}for(e.written.splice(a+1,0,t),(-1===a||e.written[a].end<t.start)&&a++;a<e.written.length-1&&e.written[a].end>=e.written[a+1].start;)e.written[a].end=Math.max(e.written[a].end,e.written[a+1].end),e.written.splice(a+1,1)},cN=new WeakSet,hN=function(e){let t={start:Math.floor(e/oC(this,aN))*oC(this,aN),data:new Uint8Array(oC(this,aN)),written:[],shouldFlush:!1};return oC(this,iN).push(t),oC(this,iN).sort(((e,t)=>e.start-t.start)),oC(this,iN).indexOf(t)},pN=new WeakSet,dN=function(e=!1){for(let t=0;t<oC(this,iN).length;t++){let n=oC(this,iN)[t];if(n.shouldFlush||e){for(let e of n.written)oC(this,rN).onData(n.data.subarray(e.start,e.end),n.start+e.start);oC(this,iN).splice(t--,1)}}};var gN,yN,bN,vN,wN,_N,xN,kN,TN,EN,SN,IN,AN,CN,NN,RN,FN,ON,MN,$N,DN,PN,LN,BN,UN,WN=class extends mN{constructor(e){var t;super(new YC(((t,n)=>e.stream.write({type:"write",data:t,position:n})),void 0,{chunkSize:null==(t=e.options)?void 0:t.chunkSize}))}},VN=1e3,zN=["avc","hevc","vp9","av1"],jN=["aac","opus"],GN=["strict","offset"],HN=class{constructor(e){var t;if(uC(this,kN),uC(this,EN),uC(this,IN),uC(this,CN),uC(this,RN),uC(this,ON),uC(this,$N),uC(this,PN),uC(this,BN),uC(this,gN,void 0),uC(this,yN,void 0),uC(this,bN,void 0),uC(this,vN,null),uC(this,wN,null),uC(this,_N,Math.floor(Date.now()/1e3)+2082844800),uC(this,xN,!1),cC(this,kN,TN).call(this,e),this.target=e.target,lC(this,gN,((e,t)=>{for(var n in t||={})nC.call(t,n)&&iC(e,n,t[n]);if(tC)for(var n of tC(t))rC.call(t,n)&&iC(e,n,t[n]);return e})({firstTimestampBehavior:"strict"},e)),e.target instanceof XC)lC(this,yN,new tN(e.target));else if(e.target instanceof YC)lC(this,yN,(null==(t=e.target.options)?void 0:t.chunked)?new mN(e.target):new nN(e.target));else{if(!(e.target instanceof QC))throw new Error(`Invalid target: ${e.target}`);lC(this,yN,new WN(e.target))}cC(this,EN,SN).call(this),cC(this,IN,AN).call(this)}addVideoChunk(e,t,n){let r=new Uint8Array(e.byteLength);e.copyTo(r),this.addVideoChunkRaw(r,e.type,null!=n?n:e.timestamp,e.duration,t)}addVideoChunkRaw(e,t,n,r,a){if(cC(this,BN,UN).call(this),!oC(this,gN).video)throw new Error("No video track declared.");cC(this,RN,FN).call(this,oC(this,vN),e,t,n,r,a)}addAudioChunk(e,t,n){let r=new Uint8Array(e.byteLength);e.copyTo(r),this.addAudioChunkRaw(r,e.type,null!=n?n:e.timestamp,e.duration,t)}addAudioChunkRaw(e,t,n,r,a){if(cC(this,BN,UN).call(this),!oC(this,gN).audio)throw new Error("No audio track declared.");cC(this,RN,FN).call(this,oC(this,wN),e,t,n,r,a)}finalize(){oC(this,vN)&&cC(this,$N,DN).call(this,oC(this,vN)),oC(this,wN)&&cC(this,$N,DN).call(this,oC(this,wN));let e=oC(this,yN).offsets.get(oC(this,bN)),t=oC(this,yN).pos-e;oC(this,bN).size=t,oC(this,yN).patchBox(oC(this,bN));let n=(r=[oC(this,vN),oC(this,wN)].filter(Boolean),a=oC(this,_N),kC("moov",null,[EC(a,r),...r.map((e=>((e,t)=>kC("trak",null,[SC(e,t),IC(e,t)]))(e,a)))]));var r,a;oC(this,yN).writeBox(n),cC(this,PN,LN).call(this),oC(this,yN).finalize(),lC(this,xN,!0)}};gN=new WeakMap,yN=new WeakMap,bN=new WeakMap,vN=new WeakMap,wN=new WeakMap,_N=new WeakMap,xN=new WeakMap,kN=new WeakSet,TN=function(e){if(e.video&&!zN.includes(e.video.codec))throw new Error(`Unsupported video codec: ${e.video.codec}`);if(e.audio&&!jN.includes(e.audio.codec))throw new Error(`Unsupported audio codec: ${e.audio.codec}`);if(e.firstTimestampBehavior&&!GN.includes(e.firstTimestampBehavior))throw new Error(`Invalid first timestamp behavior: ${e.firstTimestampBehavior}`)},EN=new WeakSet,SN=function(){var e;let t="hevc"===(null==(e=oC(this,gN).video)?void 0:e.codec);oC(this,yN).writeBox((e=>kC("ftyp",e?[vC("isom"),gC(0),vC("iso4"),vC("hvc1")]:[vC("isom"),gC(0),vC("isom"),vC("avc1"),vC("mp41")]))(t)),lC(this,bN,{type:"mdat",largeSize:!0}),oC(this,yN).writeBox(oC(this,bN)),cC(this,PN,LN).call(this)},IN=new WeakSet,AN=function(){if(oC(this,gN).video&&lC(this,vN,{id:1,info:{type:"video",codec:oC(this,gN).video.codec,width:oC(this,gN).video.width,height:oC(this,gN).video.height},timescale:720,codecPrivate:new Uint8Array(0),samples:[],writtenChunks:[],currentChunk:null,firstTimestamp:void 0,lastTimestamp:-1,timeToSampleTable:[],lastTimescaleUnits:null,compactlyCodedChunkTable:[]}),oC(this,gN).audio){let e=cC(this,CN,NN).call(this,2,oC(this,gN).audio.sampleRate,oC(this,gN).audio.numberOfChannels);lC(this,wN,{id:oC(this,gN).video?2:1,info:{type:"audio",codec:oC(this,gN).audio.codec,numberOfChannels:oC(this,gN).audio.numberOfChannels,sampleRate:oC(this,gN).audio.sampleRate},timescale:oC(this,gN).audio.sampleRate,codecPrivate:e,samples:[],writtenChunks:[],currentChunk:null,firstTimestamp:void 0,lastTimestamp:-1,timeToSampleTable:[],lastTimescaleUnits:null,compactlyCodedChunkTable:[]})}},CN=new WeakSet,NN=function(e,t,n){let r=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350].indexOf(t),a=n,i="";i+=e.toString(2).padStart(5,"0"),i+=r.toString(2).padStart(4,"0"),15===r&&(i+=t.toString(2).padStart(24,"0")),i+=a.toString(2).padStart(4,"0");let s=8*Math.ceil(i.length/8);i=i.padEnd(s,"0");let o=new Uint8Array(i.length/8);for(let e=0;e<i.length;e+=8)o[e/8]=parseInt(i.slice(e,e+8),2);return o},RN=new WeakSet,FN=function(e,t,n,r,a,i){var s;let o=r/1e6,u=a/1e6;if(void 0===e.firstTimestamp&&(e.firstTimestamp=o),o=cC(this,ON,MN).call(this,o,e),e.lastTimestamp=o,(!e.currentChunk||o-e.currentChunk.startTimestamp>=.5)&&(e.currentChunk&&cC(this,$N,DN).call(this,e),e.currentChunk={startTimestamp:o,sampleData:[],sampleCount:0}),e.currentChunk.sampleData.push(t),e.currentChunk.sampleCount++,(null==(s=null==i?void 0:i.decoderConfig)?void 0:s.description)&&(e.codecPrivate=new Uint8Array(i.decoderConfig.description)),e.samples.push({timestamp:o,duration:u,size:t.byteLength,type:n}),null!==e.lastTimescaleUnits){let t=_C(o,e.timescale,!1),n=Math.round(t-e.lastTimescaleUnits);e.lastTimescaleUnits+=n;let r=wC(e.timeToSampleTable);1===r.sampleCount?(r.sampleDelta=n,r.sampleCount++):r.sampleDelta===n?r.sampleCount++:(r.sampleCount--,e.timeToSampleTable.push({sampleCount:2,sampleDelta:n}))}else e.lastTimescaleUnits=0,e.timeToSampleTable.push({sampleCount:1,sampleDelta:_C(u,e.timescale)})},ON=new WeakSet,MN=function(e,t){if("strict"===oC(this,gN).firstTimestampBehavior&&-1===t.lastTimestamp&&0!==e)throw new Error(`The first chunk for your media track must have a timestamp of 0 (received ${e}). Non-zero first timestamps are often caused by directly piping frames or audio data from a MediaStreamTrack into the encoder. Their timestamps are typically relative to the age of the document, which is probably what you want.\n\nIf you want to offset all timestamps of a track such that the first one is zero, set firstTimestampBehavior: 'offset' in the options.\n`);if("offset"===oC(this,gN).firstTimestampBehavior&&(e-=t.firstTimestamp),e<t.lastTimestamp)throw new Error(`Timestamps must be monotonically increasing (went from ${1e6*t.lastTimestamp} to ${1e6*e}).`);return e},$N=new WeakSet,DN=function(e){if(e.currentChunk){e.currentChunk.offset=oC(this,yN).pos;for(let t of e.currentChunk.sampleData)oC(this,yN).write(t);e.currentChunk.sampleData=null,0!==e.compactlyCodedChunkTable.length&&wC(e.compactlyCodedChunkTable).samplesPerChunk===e.currentChunk.sampleCount||e.compactlyCodedChunkTable.push({firstChunk:e.writtenChunks.length+1,samplesPerChunk:e.currentChunk.sampleCount}),e.writtenChunks.push(e.currentChunk),cC(this,PN,LN).call(this)}},PN=new WeakSet,LN=function(){oC(this,yN)instanceof nN&&oC(this,yN).flush()},BN=new WeakSet,UN=function(){if(oC(this,xN))throw new Error("Cannot add new video or audio chunks after the file has been finalized.")};var KN=function(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))},qN=function(e,t){var n,r,a,i,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(s=0)),s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},XN={isRecording:!1,muxer:null,videoEncoder:null,audioEncoder:null,audioTrack:null};function YN(e,t,n){return KN(this,void 0,void 0,(function(){var r,a,i,s,o,u,l,c,h,p,d,f,m;return qN(this,(function(g){switch(g.label){case 0:if(!("VideoEncoder"in window))throw new Error("VideoEncoder API not available in this browser.");if("undefined"==typeof AudioEncoder&&n.audioTrack)throw new Error("Audio can't be recorded because AudioEncoder is not supported. Turn off audio recording and try again.");return r=e.width,a=e.height,i=960,r>a?(s=1,r>i&&(s=i/r,r=i,a=Math.round(a*s))):a>r&&(s=1,a>i&&(s=i/a,a=i,r=Math.round(r*s))),r=r%2==0?r:r-1,a=a%2==0?a:a-1,XN.audioTrack=n.audioTrack,XN.muxer=new HN({target:new XC,video:{codec:"avc",width:r,height:a},audio:XN.audioTrack?{codec:"aac",sampleRate:n.audioSampleRate,numberOfChannels:1}:void 0,firstTimestampBehavior:"offset"}),XN.audioTrack&&(XN.audioEncoder=new AudioEncoder({output:function(e,t){return XN.muxer.addAudioChunk(e,t)},error:function(e){return console.error(e)}}),o={codec:"mp4a.40.2",numberOfChannels:1,sampleRate:n.audioSampleRate,bitrate:n.audioBitRate},XN.audioEncoder.configure(o),u=new MediaStreamTrackProcessor({track:XN.audioTrack}),l=new WritableStream({write:function(e){XN.isRecording&&(XN.audioEncoder.encode(e),e.close())}}),u.readable.pipeTo(l)),c={error:function(e){console.error(e)},output:function(e,t){XN.muxer.addVideoChunk(e,t)}},h={codec:"avc1.4d002a",width:r,height:a,bitrate:n.videoBitRate,framerate:n.videoFrameRate},[4,VideoEncoder.isConfigSupported(h)];case 1:if(!g.sent().supported)throw console.log("config:"),console.log(h),new Error("Encoder config not supported.");return XN.videoEncoder=new VideoEncoder(c),XN.videoEncoder.configure(h),console.log("Video resolution will be ".concat(r,"x").concat(a,".")),p=performance.now(),d=e,f=0,m=0,XN.isRecording=!0,t.__deeparRendered2=function(){var e=performance.now(),t=e-p;if(p=e,XN.isRecording){var n=m+1e3*t,r=new VideoFrame(d,{timestamp:n});f++,m=n;var a=f%300==0;XN.videoEncoder.encode(r,{keyFrame:a}),r.close()}},[2]}}))}))}function QN(e){var t;return KN(this,void 0,void 0,(function(){var n;return qN(this,(function(r){switch(r.label){case 0:if(!XN.isRecording)throw new Error("Cannot finish video recording because recording was not started!");return XN.isRecording=!1,null===(t=XN.audioTrack)||void 0===t||t.stop(),[4,XN.videoEncoder.flush()];case 1:return r.sent(),XN.audioEncoder?[4,XN.audioEncoder.flush()]:[3,3];case 2:r.sent(),r.label=3;case 3:return XN.muxer.finalize(),e.__deeparRendered2=void 0,n=new Blob([XN.muxer.target.buffer],{type:"video/mp4"}),XN.muxer=null,XN.videoEncoder=null,XN.audioEncoder=null,XN.audioTrack=null,[2,n]}}))}))}var JN={isRecording:!1,mediaRecorder:null,chunks:[],mimeType:""};function ZN(){if(!JN.isRecording)throw new Error("Video recording not started!");return new Promise((function(e){JN.mediaRecorder.onstop=function(t){e(new Blob(JN.chunks,{type:JN.mimeType})),JN.chunks=[],JN.isRecording=!1},JN.mediaRecorder.stop()}))}var eR,tR,nR=n(795),rR=(eR=function(e,t){return eR=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},eR(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}eR(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),aR=function(e){function t(t){var n=e.call(this,t)||this;return n.name="SwitchEffectCanceled",n}return rR(t,e),t}(Error);!function(e){e[e.Bool=0]="Bool",e[e.Int=1]="Int",e[e.Double=2]="Double",e[e.String=3]="String"}(tR||(tR={}));var iR=function(){function e(e){this.module=e}return e.prototype.hasVar=function(e,t){return this.module.hasVar(e,t)},e.prototype.getVarType=function(e,t){return this.module.getVarType(e,t)},e.prototype.getBoolVar=function(e,t){return this.module.getBoolVar(e,t)},e.prototype.getIntVar=function(e,t){return this.module.getIntVar(e,t)},e.prototype.getDoubleVar=function(e,t){return this.module.getDoubleVar(e,t)},e.prototype.getStringVar=function(e,t){return void 0===t&&(t=0),this.module.getStringVar(e,t)},e.prototype.setBoolVar=function(e,t,n){return this.module.setBoolVar(e,t,n)},e.prototype.setIntVar=function(e,t,n){return this.module.setIntVar(e,t,n)},e.prototype.setDoubleVar=function(e,t,n){return this.module.setDoubleVar(e,t,n)},e.prototype.setStringVar=function(e,t,n){return this.module.setStringVar(e,t,n)},e.prototype.deleteVar=function(e,t){return this.module.deleteVar(e,t)},e.prototype.clearVars=function(e){return this.module.clearVars(e)},e}(),sR=self;function oR(e,t){e=e.split(".");var n,r=sR;e[0]in r||void 0===r.execScript||r.execScript("var "+e[0]);for(;e.length&&(n=e.shift());)e.length||void 0===t?r=r[n]&&r[n]!==Object.prototype[n]?r[n]:r[n]={}:r[n]=t}function uR(e){return e}function lR(){throw Error("Invalid UTF8")}function cR(e,t){return t=String.fromCharCode.apply(null,t),null==e?t:e+t}let hR,pR;const dR="undefined"!=typeof TextDecoder;let fR;const mR="undefined"!=typeof TextEncoder;function gR(e){if(mR)e=(fR||=new TextEncoder).encode(e);else{let n=0;const r=new Uint8Array(3*e.length);for(let a=0;a<e.length;a++){var t=e.charCodeAt(a);if(128>t)r[n++]=t;else{if(2048>t)r[n++]=t>>6|192;else{if(55296<=t&&57343>=t){if(56319>=t&&a<e.length){const i=e.charCodeAt(++a);if(56320<=i&&57343>=i){t=1024*(t-55296)+i-56320+65536,r[n++]=t>>18|240,r[n++]=t>>12&63|128,r[n++]=t>>6&63|128,r[n++]=63&t|128;continue}a--}t=65533}r[n++]=t>>12|224,r[n++]=t>>6&63|128}r[n++]=63&t|128}}e=n===r.length?r:r.subarray(0,n)}return e}var yR,bR;e:{for(var vR=["CLOSURE_FLAGS"],wR=sR,_R=0;_R<vR.length;_R++)if(null==(wR=wR[vR[_R]])){bR=null;break e}bR=wR}var xR,kR=bR&&bR[610401301];yR=null!=kR&&kR;const TR=sR.navigator;function ER(e){return!!yR&&!!xR&&xR.brands.some((({brand:t})=>t&&-1!=t.indexOf(e)))}function SR(e){var t;return(t=sR.navigator)&&(t=t.userAgent)||(t=""),-1!=t.indexOf(e)}function IR(){return!!yR&&!!xR&&0<xR.brands.length}function AR(){return IR()?ER("Chromium"):(SR("Chrome")||SR("CriOS"))&&!(!IR()&&SR("Edge"))||SR("Silk")}xR=TR&&TR.userAgentData||null;var CR=!IR()&&(SR("Trident")||SR("MSIE"));!SR("Android")||AR(),AR(),SR("Safari")&&(AR()||!IR()&&SR("Coast")||!IR()&&SR("Opera")||!IR()&&SR("Edge")||(IR()?ER("Microsoft Edge"):SR("Edg/"))||IR()&&ER("Opera"));var NR={},RR=null;function FR(){if(!RR){RR={};for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),t=["+/=","+/","-_=","-_.","-_"],n=0;5>n;n++){var r=e.concat(t[n].split(""));NR[n]=r;for(var a=0;a<r.length;a++){var i=r[a];void 0===RR[i]&&(RR[i]=a)}}}}var OR="undefined"!=typeof Uint8Array,MR=!CR&&"function"==typeof btoa;function $R(e){if(!MR){var t;void 0===t&&(t=0),FR(),t=NR[t];var n=Array(Math.floor(e.length/3)),r=t[64]||"";let u=0,l=0;for(;u<e.length-2;u+=3){var a=e[u],i=e[u+1],s=e[u+2],o=t[a>>2];a=t[(3&a)<<4|i>>4],i=t[(15&i)<<2|s>>6],s=t[63&s],n[l++]=o+a+i+s}switch(o=0,s=r,e.length-u){case 2:s=t[(15&(o=e[u+1]))<<2]||r;case 1:e=e[u],n[l]=t[e>>2]+t[(3&e)<<4|o>>4]+s+r}return n.join("")}for(t="",n=0,r=e.length-10240;n<r;)t+=String.fromCharCode.apply(null,e.subarray(n,n+=10240));return t+=String.fromCharCode.apply(null,n?e.subarray(n):e),btoa(t)}const DR=/[-_.]/g,PR={"-":"+",_:"/",".":"="};function LR(e){return PR[e]||""}function BR(e){if(!MR)return function(e){var t=e.length,n=3*t/4;n%3?n=Math.floor(n):-1!="=.".indexOf(e[t-1])&&(n=-1!="=.".indexOf(e[t-2])?n-2:n-1);var r=new Uint8Array(n),a=0;return function(e,t){function n(t){for(;r<e.length;){var n=e.charAt(r++),a=RR[n];if(null!=a)return a;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return t}FR();for(var r=0;;){var a=n(-1),i=n(0),s=n(64),o=n(64);if(64===o&&-1===a)break;t(a<<2|i>>4),64!=s&&(t(i<<4&240|s>>2),64!=o&&t(s<<6&192|o))}}(e,(function(e){r[a++]=e})),a!==n?r.subarray(0,a):r}(e);DR.test(e)&&(e=e.replace(DR,LR)),e=atob(e);const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}function UR(e){return OR&&null!=e&&e instanceof Uint8Array}let WR;function VR(){return WR||=new Uint8Array(0)}var zR={};let jR;function GR(e){if(e!==zR)throw Error("illegal external caller")}function HR(){return jR||=new qR(null,zR)}function KR(e){GR(zR);var t=e.L;return null==(t=null==t||UR(t)?t:"string"==typeof t?BR(t):null)?t:e.L=t}var qR=class{constructor(e,t){if(GR(t),this.L=e,null!=e&&0===e.length)throw Error("ByteString should be constructed with non-empty values")}fa(){const e=KR(this);return e?new Uint8Array(e):VR()}};function XR(e,t){return Error(`Invalid wire type: ${e} (at position ${t})`)}function YR(){return Error("Failed to read varint, encoding is invalid.")}function QR(e,t){return Error(`Tried to read past the end of the data ${t} > ${e}`)}function JR(e){return 0==e.length?HR():new qR(e,zR)}function ZR(e){if("string"==typeof e)return{buffer:BR(e),G:!1};if(Array.isArray(e))return{buffer:new Uint8Array(e),G:!1};if(e.constructor===Uint8Array)return{buffer:e,G:!1};if(e.constructor===ArrayBuffer)return{buffer:new Uint8Array(e),G:!1};if(e.constructor===qR)return{buffer:KR(e)||VR(),G:!0};if(e instanceof Uint8Array)return{buffer:new Uint8Array(e.buffer,e.byteOffset,e.byteLength),G:!1};throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers")}const eF="function"==typeof Uint8Array.prototype.slice;let tF,nF=0,rF=0;function aF(e){const t=0>e;let n=(e=Math.abs(e))>>>0;if(e=Math.floor((e-n)/4294967296),t){const[t,r]=lF(n,e);e=r,n=t}nF=n>>>0,rF=e>>>0}function iF(e){const t=tF||=new DataView(new ArrayBuffer(8));t.setFloat32(0,+e,!0),rF=0,nF=t.getUint32(0,!0)}function sF(e,t){return 4294967296*t+(e>>>0)}function oF(e,t){const n=2147483648&t;return n&&(t=~t>>>0,0==(e=1+~e>>>0)&&(t=t+1>>>0)),e=sF(e,t),n?-e:e}function uF(e){if(16>e.length)aF(Number(e));else if("function"==typeof BigInt)e=BigInt(e),nF=Number(e&BigInt(4294967295))>>>0,rF=Number(e>>BigInt(32)&BigInt(4294967295));else{const t=+("-"===e[0]);rF=nF=0;const n=e.length;for(let r=t,a=(n-t)%6+t;a<=n;r=a,a+=6){const t=Number(e.slice(r,a));rF*=1e6,nF=1e6*nF+t,4294967296<=nF&&(rF+=Math.trunc(nF/4294967296),rF>>>=0,nF>>>=0)}if(t){const[e,t]=lF(nF,rF);nF=e,rF=t}}}function lF(e,t){return t=~t,e?e=1+~e:t+=1,[e,t]}function cF(e,t,{O:n=!1}={}){e.O=n,t&&(t=ZR(t),e.h=t.buffer,e.s=t.G,e.v=0,e.l=e.h.length,e.g=e.v)}function hF(e,t){if(e.g=t,t>e.l)throw QR(e.l,t)}function pF(e,t){let n,r=0,a=0,i=0;const s=e.h;let o=e.g;do{n=s[o++],r|=(127&n)<<i,i+=7}while(32>i&&128&n);for(32<i&&(a|=(127&n)>>4),i=3;32>i&&128&n;i+=7)n=s[o++],a|=(127&n)<<i;if(hF(e,o),128>n)return t(r>>>0,a>>>0);throw YR()}function dF(e){let t=0,n=e.g;const r=n+10,a=e.h;for(;n<r;){const r=a[n++];if(t|=r,0==(128&r))return hF(e,n),!!(127&t)}throw YR()}function fF(e){var t=e.h;const n=e.g,r=t[n],a=t[n+1],i=t[n+2];return t=t[n+3],hF(e,e.g+4),(r<<0|a<<8|i<<16|t<<24)>>>0}function mF(e,t){if(0>t)throw Error(`Tried to read a negative byte length: ${t}`);const n=e.g,r=n+t;if(r>e.l)throw QR(t,e.l-n);return e.g=r,n}function gF(e,t){if(0==t)return HR();var n=mF(e,t);return e.O&&e.s?n=e.h.subarray(n,n+t):(e=e.h,n=n===(t=n+t)?VR():eF?e.slice(n,t):new Uint8Array(e.subarray(n,t))),JR(n)}var yF=class{constructor(e,t){this.h=null,this.s=!1,this.g=this.l=this.v=0,cF(this,e,t)}m(){const e=this.h;let t=this.g,n=e[t++],r=127&n;if(128&n&&(n=e[t++],r|=(127&n)<<7,128&n&&(n=e[t++],r|=(127&n)<<14,128&n&&(n=e[t++],r|=(127&n)<<21,128&n&&(n=e[t++],r|=n<<28,128&n&&128&e[t++]&&128&e[t++]&&128&e[t++]&&128&e[t++]&&128&e[t++])))))throw YR();return hF(this,t),r}j(){return this.m()>>>0}A(){var e=fF(this);const t=2*(e>>31)+1,n=e>>>23&255;return e&=8388607,255==n?e?NaN:1/0*t:0==n?t*Math.pow(2,-149)*e:t*Math.pow(2,n-150)*(e+Math.pow(2,23))}C(){return this.m()}},bF=[];function vF(e){var t=e.g;if(t.g==t.l)return!1;e.l=e.g.g;var n=e.g.j();if(t=n>>>3,!(0<=(n&=7)&&5>=n))throw XR(n,e.l);if(1>t)throw Error(`Invalid field number: ${t} (at position ${e.l})`);return e.m=t,e.h=n,!0}function wF(e){switch(e.h){case 0:0!=e.h?wF(e):dF(e.g);break;case 1:hF(e=e.g,e.g+8);break;case 2:if(2!=e.h)wF(e);else{var t=e.g.j();hF(e=e.g,e.g+t)}break;case 5:hF(e=e.g,e.g+4);break;case 3:for(t=e.m;;){if(!vF(e))throw Error("Unmatched start-group tag: stream EOF");if(4==e.h){if(e.m!=t)throw Error("Unmatched end-group tag");break}wF(e)}break;default:throw XR(e.h,e.l)}}function _F(e,t,n){const r=e.g.l,a=e.g.j(),i=e.g.g+a;let s=i-r;if(0>=s&&(e.g.l=i,n(t,e,void 0,void 0,void 0),s=i-e.g.g),s)throw Error(`Message parsing ended unexpectedly. Expected to read ${a} bytes, instead read ${a-s} bytes, either the data ended unexpectedly or the message misreported its own length`);return e.g.g=i,e.g.l=r,t}function xF(e){var t=e.g.j(),n=mF(e=e.g,t);if(e=e.h,dR){var r,a=e;(r=pR)||(r=pR=new TextDecoder("utf-8",{fatal:!0})),e=n+t,a=0===n&&e===a.length?a:a.subarray(n,e);try{var i=r.decode(a)}catch(e){if(void 0===hR){try{r.decode(new Uint8Array([128]))}catch(e){}try{r.decode(new Uint8Array([97])),hR=!0}catch(e){hR=!1}}throw!hR&&(pR=void 0),e}}else{t=(i=n)+t,n=[];let o,u=null;for(;i<t;){var s=e[i++];128>s?n.push(s):224>s?i>=t?lR():(o=e[i++],194>s||128!=(192&o)?(i--,lR()):n.push((31&s)<<6|63&o)):240>s?i>=t-1?lR():(o=e[i++],128!=(192&o)||224===s&&160>o||237===s&&160<=o||128!=(192&(a=e[i++]))?(i--,lR()):n.push((15&s)<<12|(63&o)<<6|63&a)):244>=s?i>=t-2?lR():(o=e[i++],128!=(192&o)||0!=o-144+(s<<28)>>30||128!=(192&(a=e[i++]))||128!=(192&(r=e[i++]))?(i--,lR()):(s=(7&s)<<18|(63&o)<<12|(63&a)<<6|63&r,s-=65536,n.push(55296+(s>>10&1023),56320+(1023&s)))):lR(),8192<=n.length&&(u=cR(u,n),n.length=0)}i=cR(u,n)}return i}function kF(e){const t=e.g.j();return gF(e.g,t)}function TF(e,t,n){var r=e.g.j();for(r=e.g.g+r;e.g.g<r;)n.push(t.call(e.g))}var EF=[];function SF(e){return e?/^\d+$/.test(e)?(uF(e),new IF(nF,rF)):null:AF||=new IF(0,0)}var IF=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let AF;function CF(e){return e?/^-?\d+$/.test(e)?(uF(e),new NF(nF,rF)):null:RF||=new NF(0,0)}var NF=class{constructor(e,t){this.h=e>>>0,this.g=t>>>0}};let RF;function FF(e,t,n){for(;0<n||127<t;)e.g.push(127&t|128),t=(t>>>7|n<<25)>>>0,n>>>=7;e.g.push(t)}function OF(e,t){for(;127<t;)e.g.push(127&t|128),t>>>=7;e.g.push(t)}function MF(e,t){if(0<=t)OF(e,t);else{for(let n=0;9>n;n++)e.g.push(127&t|128),t>>=7;e.g.push(1)}}function $F(e,t){e.g.push(t>>>0&255),e.g.push(t>>>8&255),e.g.push(t>>>16&255),e.g.push(t>>>24&255)}function DF(e,t){0!==t.length&&(e.l.push(t),e.h+=t.length)}function PF(e,t,n){OF(e.g,8*t+n)}function LF(e,t){return PF(e,t,2),t=e.g.end(),DF(e,t),t.push(e.h),t}function BF(e,t){var n=t.pop();for(n=e.h+e.g.length()-n;127<n;)t.push(127&n|128),n>>>=7,e.h++;t.push(n),e.h++}function UF(e,t,n){PF(e,t,2),OF(e.g,n.length),DF(e,e.g.end()),DF(e,n)}function WF(e,t,n,r){null!=n&&(t=LF(e,t),r(n,e),BF(e,t))}class VF{constructor(e,t,n){this.g=e,this.h=t,this.l=n}}function zF(e){return Array.prototype.slice.call(e)}const jF="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():void 0;var GF=jF?(e,t)=>{e[jF]|=t}:(e,t)=>{void 0!==e.g?e.g|=t:Object.defineProperties(e,{g:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function HF(e){const t=qF(e);1!=(1&t)&&(Object.isFrozen(e)&&(e=zF(e)),YF(e,1|t))}var KF=jF?(e,t)=>{e[jF]&=~t}:(e,t)=>{void 0!==e.g&&(e.g&=~t)},qF=jF?e=>0|e[jF]:e=>0|e.g,XF=jF?e=>e[jF]:e=>e.g,YF=jF?(e,t)=>{e[jF]=t}:(e,t)=>{void 0!==e.g?e.g=t:Object.defineProperties(e,{g:{value:t,configurable:!0,writable:!0,enumerable:!1}})};function QF(e){return GF(e,1),e}function JF(e){return GF(e,34),e}function ZF(e,t){YF(t,-255&(0|e))}function eO(e,t){YF(t,-221&(34|e))}function tO(e){return 0==(e=e>>11&1023)?536870912:e}var nO,rO={};function aO(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)&&e.constructor===Object}function iO(e,t,n){if(null!=e)if("string"==typeof e)e=e?new qR(e,zR):HR();else if(e.constructor!==qR)if(UR(e))e=n?JR(e):e.length?new qR(new Uint8Array(e),zR):HR();else{if(!t)throw Error();e=void 0}return e}const sO=[];function oO(e){if(2&e)throw Error()}YF(sO,39),nO=Object.freeze(sO);class uO{constructor(e,t,n){this.l=0,this.g=e,this.h=t,this.m=n}next(){if(this.l<this.g.length){const e=this.g[this.l++];return{done:!1,value:this.h?this.h.call(this.m,e):e}}return{done:!0,value:void 0}}[Symbol.iterator](){return new uO(this.g,this.h,this.m)}}var lO={};let cO,hO;function pO(e,t){(t=cO?t[cO]:void 0)&&(e[cO]=zF(t))}function dO(e,t){e.__closure__error__context__984382||(e.__closure__error__context__984382={}),e.__closure__error__context__984382.severity=t}function fO(e){return null==e?e:"number"==typeof e||"NaN"===e||"Infinity"===e||"-Infinity"===e?Number(e):void 0}function mO(e){return null==e?e:"boolean"==typeof e||"number"==typeof e?!!e:void 0}function gO(e){return"number"==typeof e&&Number.isFinite(e)||!!e&&"string"==typeof e&&isFinite(e)}function yO(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function bO(e){if(null==e)return e;if("string"==typeof e){if(!e)return;e=+e}return"number"==typeof e?e:void 0}function vO(e){if("string"!=typeof e)throw Error();return e}function wO(e){if(null!=e&&"string"!=typeof e)throw Error();return e}function _O(e){return null==e||"string"==typeof e?e:void 0}function xO(e,t,n,r){var a=!1;return null==e||"object"!=typeof e||(a=Array.isArray(e))||e.K!==rO?a?(0===(a=n=qF(e))&&(a|=32&r),(a|=2&r)!==n&&YF(e,a),new t(e)):(n?2&r?(e=t[kO])?t=e:(JF((e=new t).u),t=t[kO]=e):t=new t:t=void 0,t):e}const kO="function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():"di";function TO(e){return e}function EO(e,t,n){return"string"==typeof(e="number"==(t=typeof e)||"string"===t?e:n?0:void 0)&&(n=+e,Number.isSafeInteger(n))?n:e}let SO,IO;function AO(e){switch(typeof e){case"number":return 0<e?void 0:0===e?IO||=[0,void 0]:[-e,void 0];case"string":return[0,e];case"object":return e}}function CO(e,t){return NO(e,t[0],t[1])}function NO(e,t,n){if(null==e&&(e=SO),SO=void 0,null==e){var r=96;n?(e=[n],r|=512):e=[],t&&(r=-2095105&r|(1023&t)<<11)}else{if(!Array.isArray(e))throw Error();if(64&(r=qF(e)))return hO&&delete e[hO],e;if(r|=64,n&&(r|=512,n!==e[0]))throw Error();e:{var a=(n=e).length;if(a){const e=a-1;var i=n[e];if(aO(i)){1024<=(a=e-(t=+!!(512&(r|=256))-1))&&(RO(n,t,i),a=1023),r=-2095105&r|(1023&a)<<11;break e}}t&&(i=+!!(512&r)-1,1024<(t=Math.max(t,a-i))&&(RO(n,i,{}),r|=256,t=1023),r=-2095105&r|(1023&t)<<11)}}return YF(e,r),e}function RO(e,t,n){const r=1023+t,a=e.length;for(let i=r;i<a;i++){const r=e[i];null!=r&&r!==n&&(n[i-t]=r)}e.length=r+1,e[r]=n}function FO(e){if(2&e.g)throw Error("Cannot mutate an immutable Map")}var OO=class extends Map{constructor(e,t,n=TO,r=TO){super();let a=qF(e);a|=64,YF(e,a),this.g=a,this.l=t,this.h=n||TO,this.j=this.l?MO:r||TO;for(let i=0;i<e.length;i++){const s=e[i],o=n(s[0],!1,!0);let u=s[1];t?void 0===u&&(u=null):u=r(s[1],!1,!0,void 0,void 0,a),super.set(o,u)}}s(e=$O){return this.m(e)}m(e=$O){const t=[],n=super.entries();for(var r;!(r=n.next()).done;)(r=r.value)[0]=e(r[0]),r[1]=e(r[1]),t.push(r);return t}clear(){FO(this),super.clear()}delete(e){return FO(this),super.delete(this.h(e,!0,!1))}entries(){var e=this.A();return new uO(e,DO,this)}keys(){return this.C()}values(){var e=this.A();return new uO(e,OO.prototype.get,this)}forEach(e,t){super.forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))}set(e,t){return FO(this),null==(e=this.h(e,!0,!1))?this:null==t?(super.delete(e),this):super.set(e,this.j(t,!0,!0,this.l,!1,this.g))}H(e){const t=this.h(e[0],!1,!0);e=e[1],e=this.l?void 0===e?null:e:this.j(e,!1,!0,void 0,!1,this.g),super.set(t,e)}has(e){return super.has(this.h(e,!1,!1))}get(e){e=this.h(e,!1,!1);const t=super.get(e);if(void 0!==t){var n=this.l;return n?((n=this.j(t,!1,!0,n,this.v,this.g))!==t&&super.set(e,n),n):t}}A(){return Array.from(super.keys())}C(){return super.keys()}[Symbol.iterator](){return this.entries()}};function MO(e,t,n,r,a,i){return e=xO(e,r,n,i),a&&(e=jO(e)),e}function $O(e){return e}function DO(e){return[e,this.get(e)]}function PO(e,t,n,r,a,i){if(null!=e){if(Array.isArray(e))e=a&&0==e.length&&1&qF(e)?void 0:i&&2&qF(e)?e:LO(e,t,n,void 0!==r,a,i);else if(aO(e)){const s={};for(let o in e)s[o]=PO(e[o],t,n,r,a,i);e=s}else e=t(e,r);return e}}function LO(e,t,n,r,a,i){const s=r||n?qF(e):0;r=r?!!(32&s):void 0;const o=zF(e);for(let e=0;e<o.length;e++)o[e]=PO(o[e],t,n,r,a,i);return n&&(pO(o,e),n(s,o)),o}function BO(e){return PO(e,UO,void 0,void 0,!1,!1)}function UO(e){return e.K===rO?e.toJSON():e instanceof OO?e.s(BO):function(e){switch(typeof e){case"number":return isFinite(e)?e:String(e);case"boolean":return e?1:0;case"object":if(e&&!Array.isArray(e)){if(UR(e))return $R(e);if(e instanceof qR){const t=e.L;return null==t?"":"string"==typeof t?t:e.L=$R(t)}if(e instanceof OO)return e.s()}}return e}(e)}function WO(e,t,n=eO){if(null!=e){if(OR&&e instanceof Uint8Array)return t?e:new Uint8Array(e);if(Array.isArray(e)){const r=qF(e);return 2&r?e:!t||68&r||!(32&r||0===r)?LO(e,WO,4&r?eO:n,!0,!1,!0):(YF(e,34|r),e)}return e.K===rO?(t=e.u,e=2&(n=XF(t))?e:VO(e,t,n,!0)):e instanceof OO&&(t=JF(e.m(WO)),e=new OO(t,e.l,e.h,e.j)),e}}function VO(e,t,n,r){return e=e.constructor,SO=t=zO(t,n,r),t=new e(t),SO=void 0,t}function zO(e,t,n){const r=n||2&t?eO:ZF,a=!!(32&t);return e=function(e,t,n){const r=zF(e);var a=r.length;const i=256&t?r[a-1]:void 0;for(a+=i?-1:0,t=512&t?1:0;t<a;t++)r[t]=n(r[t]);if(i){t=r[t]={};for(const e in i)t[e]=n(i[e])}return pO(r,e),r}(e,t,(e=>WO(e,a,r))),GF(e,32|(n?2:0)),e}function jO(e){const t=e.u,n=XF(t);return 2&n?VO(e,t,n,!1):e}function GO(e,t){return HO(e=e.u,XF(e),t)}function HO(e,t,n,r){if(-1===n)return null;if(n>=tO(t)){if(256&t)return e[e.length-1][n]}else{var a=e.length;if(r&&256&t&&null!=(r=e[a-1][n]))return r;if((t=n+(+!!(512&t)-1))<a)return e[t]}}function KO(e,t,n,r){const a=e.u,i=XF(a);return oO(i),qO(a,i,t,n,r),e}function qO(e,t,n,r,a){var i=tO(t);if(n>=i||a){if(a=t,256&t)i=e[e.length-1];else{if(null==r)return;i=e[i+(+!!(512&t)-1)]={},a|=256}i[n]=r,a!==t&&YF(e,a)}else e[n+(+!!(512&t)-1)]=r,256&t&&n in(e=e[e.length-1])&&delete e[n]}function XO(e,t,n,r,a){var i=2&t;let s=HO(e,t,n,a);Array.isArray(s)||(s=nO);const o=qF(s);if(1&o||QF(s),i)2&o||JF(s),1&r||Object.freeze(s);else{i=!(2&r);const u=2&o;1&r||!u?i&&32&o&&!u&&KF(s,32):(s=QF(zF(s)),qO(e,t,n,s,a))}return s}function YO(e,t){e=e.u;const n=XF(e),r=HO(e,n,t),a=fO(r);return null!=a&&a!==r&&qO(e,n,t,a),a}function QO(e){e=e.u;const t=XF(e),n=HO(e,t,1),r=iO(n,!0,!!(34&t));return null!=r&&r!==n&&qO(e,t,1,r),r}function JO(e,t,n){e=e.u;const r=XF(e),a=2&r;let i=XO(e,r,t,1),s=qF(i);if(!(4&s)){Object.isFrozen(i)&&(s=0,i=zF(i),qO(e,r,t,i));let o=0,u=0;for(;o<i.length;o++){const e=n(i[o]);null!=e&&(i[u++]=e)}u<o&&(i.length=u),s|=5,a&&(s|=34),YF(i,s),2&s&&Object.freeze(i)}return!a&&(2&s||Object.isFrozen(i))&&(i=zF(i),GF(i,5),qO(e,r,t,i)),i}let ZO;function eM(){return ZO??=new OO(JF([]),void 0,void 0,void 0,lO)}function tM(e){e=zF(e);for(let t=0;t<e.length;t++){const n=e[t]=zF(e[t]);Array.isArray(n[1])&&(n[1]=JF(n[1]))}return e}function nM(e,t,n){{e=e.u;const r=XF(e);if(oO(r),null==n)qO(e,r,t);else{if(!(4&qF(n))){Object.isFrozen(n)&&(n=zF(n));for(let e=0;e<n.length;e++)n[e]=vO(n[e]);YF(n,5)}qO(e,r,t,n)}}}function rM(e,t){return aM(e=e.u,XF(e),jD)===t?t:-1}function aM(e,t,n){let r=0;for(let a=0;a<n.length;a++){const i=n[a];null!=HO(e,t,i)&&(0!==r&&qO(e,t,r),r=i)}return r}function iM(e,t,n,r){const a=XF(e);oO(a);const i=HO(e,a,n,r);let s;if(null!=i&&i.K===rO)return(t=jO(i))!==i&&qO(e,a,n,t,r),t.u;if(Array.isArray(i)){const e=qF(i);s=2&e?zO(i,e,!1):i,s=CO(s,t)}else s=CO(void 0,t);return s!==i&&qO(e,a,n,s,r),s}function sM(e,t,n,r){e=e.u;const a=XF(e),i=HO(e,a,n,r);return(t=xO(i,t,!1,a))!==i&&null!=t&&qO(e,a,n,t,r),t}function oM(e,t,n,r=!1){if(null==(t=sM(e,t,n,r)))return t;e=e.u;const a=XF(e);if(!(2&a)){const i=jO(t);i!==t&&qO(e,a,n,t=i,r)}return t}function uM(e,t,n,r,a){var i=!!(2&t),s=XO(e,t,r,1);if(s===nO||!(4&qF(s))){var o=s;s=!!(2&t);var u=!!(2&qF(o));i=o,!s&&u&&(o=zF(o));var l=t|(u?2:0);u=u||void 0;let c=0,h=0;for(;c<o.length;c++){const e=xO(o[c],n,!1,l);void 0!==e&&(u=u||2&XF(e.u),o[h++]=e)}return h<c&&(o.length=h),l=5|(o=qF(n=o)),o!=(u=u?-9&l:8|l)&&(Object.isFrozen(n)&&(n=zF(n)),YF(n,u)),i!==(o=n)&&qO(e,t,r,o),(s&&2!==a||1===a)&&Object.freeze(o),o}return 3===a||(i?2===a&&(a=qF(s),s=zF(s),YF(s,a),qO(e,t,r,s)):(i=Object.isFrozen(s),1===a?i||Object.freeze(s):(n=-35&(a=qF(s)),i&&(a=0,qO(e,t,r,s=zF(s))),a!==n&&YF(s,n)))),s}function lM(e,t,n){var r=e.u;const a=XF(r);if(t=uM(r,a,t,n,(e=!!(2&a))?1:2),!(e||8&qF(t))){for(n=0;n<t.length;n++)(e=t[n])!==(r=jO(e))&&(t[n]=r);GF(t,8)}return t}function cM(e,t,n,r,a){return null==r&&(r=void 0),KO(e,n,r,a)}function hM(e,t,n,r){null==r&&(r=void 0),e=e.u;const a=XF(e);oO(a),(n=aM(e,a,n))&&n!==t&&null!=r&&qO(e,a,n),qO(e,a,t,r)}function pM(e,t,n){e=e.u;const r=XF(e);oO(r),e=uM(e,r,t,1,2),t=null!=n?n:new t,e.push(t),t.G()&&KF(e,8)}function dM(e,t){return yO(GO(e,t))}function fM(e){return null==(e=GO(e,2))||gO(e)?e:void 0}function mM(e,t){return _O(GO(e,t))}function gM(e){return e??0}function yM(e,t){return gM(YO(e,t))}function bM(e,t,n){if(null!=n){if("boolean"!=typeof n)throw e=typeof n,Error(`Expected boolean but got ${"object"!=e?e:n?Array.isArray(n)?"array":e:"null"}: ${n}`);n=!!n}KO(e,t,n)}function vM(e,t,n){if(null!=n){if("number"!=typeof n)throw dO(e=Error(),"warning"),e;if(!Number.isFinite(n)){const e=Error();dO(e,"incident"),function(e){sR.setTimeout((()=>{throw e}),0)}(e)}}KO(e,t,n)}function wM(e,t,n){if(null!=n&&"number"!=typeof n)throw Error(`Value of float/double field must be a number, found ${typeof n}: ${n}`);KO(e,t,n)}function _M(e,t,n){n=vO(n),e=e.u;const r=XF(e);oO(r),XO(e,r,t,2).push(n)}function xM(e,t,n){t.g?t.m(e,t.g,t.h,n,!0):t.m(e,t.h,n,!0)}OO.prototype.toJSON=void 0;var kM=class{constructor(e,t){this.u=NO(e,t)}toJSON(){return TM(this,LO(this.u,UO,void 0,void 0,!1,!1),!0)}l(){var e=UP;return e.g?e.l(this,e.g,e.h,!0):e.l(this,e.h,e.defaultValue,!0)}clone(){const e=this.u;return VO(this,e,XF(e),!1)}G(){return!!(2&qF(this.u))}};function TM(e,t,n){var r=e.constructor.B,a=tO(XF(n?e.u:t)),i=!1;if(r){if(!n){var s;if((t=zF(t)).length&&aO(s=t[t.length-1]))for(i=0;i<r.length;i++)if(r[i]>=a){Object.assign(t[t.length-1]={},s);break}i=!0}var o;a=t,n=!n,e=tO(s=XF(e.u)),s=+!!(512&s)-1;for(let t=0;t<r.length;t++){var u=r[t];if(u<e){var l=a[u+=s];null==l?a[u]=n?nO:QF([]):n&&l!==nO&&HF(l)}else{if(!o){var c=void 0;a.length&&aO(c=a[a.length-1])?o=c:a.push(o={})}l=o[u],null==o[u]?o[u]=n?nO:QF([]):n&&l!==nO&&HF(l)}}}if(!(r=t.length))return t;let h,p;if(aO(o=t[r-1])){e:{var d=o;c={},a=!1;for(let e in d)n=d[e],Array.isArray(n)&&n!=n&&(a=!0),null!=n?c[e]=n:a=!0;if(a){for(let e in c){d=c;break e}d=null}}d!=o&&(h=!0),r--}for(;0<r&&null==(o=t[r-1]);r--)p=!0;return h||p?(t=i?t:Array.prototype.slice.call(t,0,r),i&&(t.length=r),d&&t.push(d),t):t}function EM(e){return{aa:m$,S:e}}function SM(e,t){if(Array.isArray(t)){var n=qF(t);if(4&n)return t;for(var r=0,a=0;r<t.length;r++){const n=e(t[r]);null!=n&&(t[a++]=n)}return a<r&&(t.length=a),YF(t,5|n),2&n&&Object.freeze(t),t}}kM.prototype.K=rO,kM.prototype.toString=function(){return TM(this,this.u,!1).toString()};const IM=Symbol();function AM(e){let t=e[IM];if(!t){const n=UM(e),r=n.m;t=r?(e,t)=>r(e,t,n):(e,t)=>{for(;vF(t)&&4!=t.h;){var r=t.m,a=n[r];if(!a){var i=n.h;i&&(i=i[r])&&(a=n[r]=CM(i))}a&&a(t,e,r)||(r=(a=t).l,wF(a),a.Y?a=void 0:(i=a.g.g-r,a.g.g=r,a=gF(a.g,i)),r=e,a&&(cO||=Symbol(),(i=r[cO])?i.push(a):r[cO]=[a]))}(t=n.l)&&(e[hO||=Symbol()]=t)},e[IM]=t}return t}function CM(e){const t=function(e){if(e=e.S)return AM(e)}(e),n=e.aa.g;if(t){const r=UM(e.S).g;return(e,a,i)=>n(e,a,i,r,t)}return(e,t,r)=>n(e,t,r)}function NM(e,t,n,r){t.g=AO(e[0]);let a=1;if(e.length>a&&!(e[a]instanceof VF)){var i=e[a++];if(Array.isArray(i))return t.m=i[0],t.h=i[1],t;t.h=i}for(i=0;a<e.length;){const c=e[a++];var s=e[a];for("number"==typeof s?(a++,i+=s):i++,c.l&&((s=t.l)||(t.l=s=[]),s.push(i)),s=a;s<e.length&&!(e[s]instanceof VF);)s++;if(s-=a){var o=e,u=a,l=o[u];if("function"==typeof l&&(l=l(),o[u]=l),(o=Array.isArray(l))&&!(o=PM in l||OM in l)&&(o=0<l.length)){const e=AO(u=(o=l)[0]);null!=e&&e!==u&&(o[0]=e),o=null!=e}(l=o?l:void 0)?(a++,t[i]=1===s?r(c,l):r(c,l,e[a++])):t[i]=n(c,e[a++])}else t[i]=n(c)}return t}const RM=Symbol();function FM(e){let t=e[RM];if(!t){const n=DM(e);t=(e,t)=>VM(e,t,n),e[RM]=t}return t}const OM=Symbol();function MM(e){return e.h}function $M(e,t){let n,r;const a=e.h;return(e,i,s)=>a(e,i,s,r||=DM(t).g,n||=FM(t))}function DM(e){let t=e[OM];return t||(t=NM(e,e[OM]={},MM,$M),PM in e&&OM in e&&(e.length=0),t)}const PM=Symbol();function LM(e,t){const n=e.g;return t?(e,r,a)=>n(e,r,a,t):n}function BM(e,t,n){const r=e.g;let a,i;return(e,s,o)=>r(e,s,o,i||=UM(t).g,a||=AM(t),n)}function UM(e){let t=e[PM];return t||(t=NM(e,e[PM]={},LM,BM),PM in e&&OM in e&&(e.length=0),t)}function WM(e,t){var n=e[t];if(n)return n;if((n=e.h)&&(n=n[t])){var r=n.S,a=n.aa.h;if(r){const e=FM(r),t=DM(r).g;n=(n,r,i)=>a(n,r,i,t,e)}else n=a;return e[t]=n}}function VM(e,t,n){for(var r=XF(e),a=+!!(512&r)-1,i=e.length,s=512&r?1:0,o=i+(256&r?-1:0);s<o;s++){const r=e[s];if(null==r)continue;const i=s-a,o=WM(n,i);o&&o(t,r,i)}if(256&r){r=e[i-1];for(let e in r)a=+e,Number.isNaN(a)||null!=(i=r[e])&&(o=WM(n,a))&&o(t,i,a)}if(e=cO?e[cO]:void 0)for(DF(t,t.g.end()),n=0;n<e.length;n++)DF(t,KR(e[n])||VR())}function zM(e,t){return new VF(e,t,!1)}function jM(e,t){return new VF(e,t,!0)}function GM(e,t,n){qO(e,XF(e),t,n)}var HM=zM((function(e,t,n,r,a){return 2===e.h&&(e=_F(e,CO([void 0,void 0],r),a),oO(r=XF(t)),(a=HO(t,r,n))instanceof OO?0!=(2&a.g)?((a=a.m()).push(e),qO(t,r,n,a)):a.H(e):Array.isArray(a)?(2&qF(a)&&qO(t,r,n,a=tM(a)),a.push(e)):qO(t,r,n,[e]),!0)}),(function(e,t,n,r,a){if(t instanceof OO)t.forEach(((t,i)=>{WF(e,n,CO([i,t],r),a)}));else if(Array.isArray(t))for(let i=0;i<t.length;i++){const s=t[i];Array.isArray(s)&&WF(e,n,CO(s,r),a)}}));function KM(e,t,n){e:if(null!=t){if(gO(t)){if("string"==typeof t)break e;if("number"==typeof t)break e}t=void 0}null!=t&&("string"==typeof t&&CF(t),null!=t&&(PF(e,n,0),"number"==typeof t?(e=e.g,aF(t),FF(e,nF,rF)):(n=CF(t),FF(e.g,n.h,n.g))))}function qM(e,t,n){null!=(t=yO(t))&&null!=t&&(PF(e,n,0),MF(e.g,t))}function XM(e,t,n){null!=(t=mO(t))&&(PF(e,n,0),e.g.g.push(t?1:0))}function YM(e,t,n){null!=(t=_O(t))&&UF(e,n,gR(t))}function QM(e,t,n,r,a){WF(e,n,t instanceof kM?t.u:Array.isArray(t)?CO(t,r):void 0,a)}function JM(e,t,n){null!=(t=null==t||"string"==typeof t||UR(t)||t instanceof qR?t:void 0)&&UF(e,n,ZR(t).buffer)}function ZM(e,t,n){return(5===e.h||2===e.h)&&(t=XO(t,XF(t),n,2,!1),2==e.h?TF(e,yF.prototype.A,t):t.push(e.g.A()),!0)}var e$=zM((function(e,t,n){if(1!==e.h)return!1;var r=e.g;e=fF(r);const a=fF(r);r=2*(a>>31)+1;const i=a>>>20&2047;return e=4294967296*(1048575&a)+e,GM(t,n,2047==i?e?NaN:1/0*r:0==i?r*Math.pow(2,-1074)*e:r*Math.pow(2,i-1075)*(e+4503599627370496)),!0}),(function(e,t,n){null!=(t=fO(t))&&(PF(e,n,1),e=e.g,(n=tF||=new DataView(new ArrayBuffer(8))).setFloat64(0,+t,!0),nF=n.getUint32(0,!0),rF=n.getUint32(4,!0),$F(e,nF),$F(e,rF))})),t$=zM((function(e,t,n){return 5===e.h&&(GM(t,n,e.g.A()),!0)}),(function(e,t,n){null!=(t=fO(t))&&(PF(e,n,5),e=e.g,iF(t),$F(e,nF))})),n$=jM(ZM,(function(e,t,n){if(null!=(t=SM(fO,t)))for(let i=0;i<t.length;i++){var r=e,a=t[i];null!=a&&(PF(r,n,5),r=r.g,iF(a),$F(r,nF))}})),r$=jM(ZM,(function(e,t,n){if(null!=(t=SM(fO,t))&&t.length){PF(e,n,2),OF(e.g,4*t.length);for(let r=0;r<t.length;r++)n=e.g,iF(t[r]),$F(n,nF)}})),a$=zM((function(e,t,n){return 0===e.h&&(GM(t,n,pF(e.g,oF)),!0)}),KM),i$=zM((function(e,t,n){return 0===e.h&&(GM(t,n,0===(e=pF(e.g,oF))?void 0:e),!0)}),KM),s$=zM((function(e,t,n){return 0===e.h&&(GM(t,n,pF(e.g,sF)),!0)}),(function(e,t,n){e:if(null!=t){if(gO(t)){if("string"==typeof t)break e;if("number"==typeof t)break e}t=void 0}null!=t&&("string"==typeof t&&SF(t),null!=t&&(PF(e,n,0),"number"==typeof t?(e=e.g,aF(t),FF(e,nF,rF)):(n=SF(t),FF(e.g,n.h,n.g))))})),o$=zM((function(e,t,n){return 0===e.h&&(GM(t,n,e.g.m()),!0)}),qM),u$=jM((function(e,t,n){return(0===e.h||2===e.h)&&(t=XO(t,XF(t),n,2,!1),2==e.h?TF(e,yF.prototype.m,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=SM(yO,t))&&t.length){n=LF(e,n);for(let n=0;n<t.length;n++)MF(e.g,t[n]);BF(e,n)}})),l$=zM((function(e,t,n){return 0===e.h&&(GM(t,n,0===(e=e.g.m())?void 0:e),!0)}),qM),c$=zM((function(e,t,n){return 0===e.h&&(GM(t,n,dF(e.g)),!0)}),XM),h$=zM((function(e,t,n){return 0===e.h&&(GM(t,n,!1===(e=dF(e.g))?void 0:e),!0)}),XM),p$=jM((function(e,t,n){if(2!==e.h)return!1;e=xF(e);const r=XF(t);return oO(r),XO(t,r,n,2).push(e),!0}),(function(e,t,n){if(null!=(t=SM(_O,t)))for(let a=0;a<t.length;a++){var r=t[a];null!=r&&UF(e,n,gR(r))}})),d$=zM((function(e,t,n){return 2===e.h&&(GM(t,n,""===(e=xF(e))?void 0:e),!0)}),YM),f$=zM((function(e,t,n){return 2===e.h&&(GM(t,n,xF(e)),!0)}),YM),m$=zM((function(e,t,n,r,a){return 2===e.h&&(_F(e,iM(t,r,n,!0),a),!0)}),QM),g$=zM((function(e,t,n,r,a){return 2===e.h&&(_F(e,iM(t,r,n),a),!0)}),QM),y$=jM((function(e,t,n,r,a){if(2!==e.h)return!1;r=CO(void 0,r);const i=XF(t);oO(i);let s=XO(t,i,n,3);return(Object.isFrozen(s)||4&qF(s))&&(s=zF(s),qO(t,i,n,s)),s.push(r),_F(e,r,a),!0}),(function(e,t,n,r,a){if(Array.isArray(t))for(let i=0;i<t.length;i++)QM(e,t[i],n,r,a)})),b$=zM((function(e,t,n,r,a,i){if(2!==e.h)return!1;const s=XF(t);return oO(s),(i=aM(t,s,i))&&n!==i&&qO(t,s,i),_F(e,t=iM(t,r,n),a),!0}),QM),v$=zM((function(e,t,n){return 2===e.h&&(GM(t,n,kF(e)),!0)}),JM),w$=jM((function(e,t,n){return(0===e.h||2===e.h)&&(t=XO(t,XF(t),n,2,!1),2==e.h?TF(e,yF.prototype.j,t):t.push(e.g.j()),!0)}),(function(e,t,n){if(null!=(t=SM(bO,t)))for(let i=0;i<t.length;i++){var r=e,a=t[i];null!=a&&(PF(r,n,0),OF(r.g,a))}})),_$=zM((function(e,t,n){return 0===e.h&&(GM(t,n,e.g.m()),!0)}),(function(e,t,n){null!=(t=yO(t))&&(t=parseInt(t,10),PF(e,n,0),MF(e.g,t))})),x$=jM((function(e,t,n){return(0===e.h||2===e.h)&&(t=XO(t,XF(t),n,2,!1),2==e.h?TF(e,yF.prototype.C,t):t.push(e.g.m()),!0)}),(function(e,t,n){if(null!=(t=SM(yO,t))&&t.length){n=LF(e,n);for(let n=0;n<t.length;n++)MF(e.g,t[n]);BF(e,n)}}));class k${constructor(e,t){this.h=e,this.g=t,this.l=oM,this.m=cM,this.defaultValue=void 0}}function T$(e,t){return new k$(e,t)}function E$(e,t){return(n,r)=>{e:{if(EF.length){const e=EF.pop();e.o(r),cF(e.g,n,r),n=e}else n=new class{constructor(e,t){if(bF.length){const n=bF.pop();cF(n,e,t),e=n}else e=new yF(e,t);this.g=e,this.l=this.g.g,this.h=this.m=-1,this.o(t)}o({Y:e=!1}={}){this.Y=e}}(n,r);try{var a=new e;const r=a.u;AM(t)(r,n),hO&&delete r[hO];var i=a;break e}finally{(a=n.g).h=null,a.s=!1,a.v=0,a.l=0,a.g=0,a.O=!1,n.m=-1,n.h=-1,100>EF.length&&EF.push(n)}i=void 0}return i}}function S$(e){return function(){const t=new class{constructor(){this.l=[],this.h=0,this.g=new class{constructor(){this.g=[]}length(){return this.g.length}end(){const e=this.g;return this.g=[],e}}}};VM(this.u,t,DM(e)),DF(t,t.g.end());const n=new Uint8Array(t.h),r=t.l,a=r.length;let i=0;for(let e=0;e<a;e++){const t=r[e];n.set(t,i),i+=t.length}return t.l=[n],n}}var I$,A$=[0,d$,zM((function(e,t,n){return 2===e.h&&(GM(t,n,(e=kF(e))===HR()?void 0:e),!0)}),(function(e,t,n){if(null!=t){if(t instanceof kM){const r=t.Aa;return void(r&&(t=r(t),null!=t&&UF(e,n,ZR(t).buffer)))}if(Array.isArray(t))return}JM(e,t,n)}))];function C$(e){if(void 0===I$){var t=null,n=sR.trustedTypes;if(n&&n.createPolicy){try{t=n.createPolicy("goog#html",{createHTML:uR,createScript:uR,createScriptURL:uR})}catch(e){sR.console&&sR.console.error(e.message)}I$=t}else I$=t}return e=(t=I$)?t.createScriptURL(e):e,new class{constructor(e){this.g=e}toString(){return this.g+""}}(e)}var N$=[0,f$],R$=[0,o$,_$,c$,c$,u$,_$,_$],F$=[0,c$,c$],O$=class extends kM{constructor(){super()}};O$.B=[6];var M$=[0,c$,f$,c$,_$,_$,x$,f$,f$,g$,F$,_$],$$=[0,f$,f$,f$],D$=class extends kM{constructor(){super()}},P$=[0],L$=[0,o$],B$=[1,2,3,4,5],U$=class extends kM{constructor(e){super(e,2)}},W$={},V$=[-2,W$,c$];W$[336783863]=EM([0,f$,c$,c$,o$,g$,[0,b$,P$,B$,b$,M$,B$,b$,$$,B$,b$,L$,B$,b$,R$,B$],g$,N$]);var z$=[0,d$,h$],j$=[0,i$,i$,h$,h$,h$,h$,i$,u$,d$,l$,i$,i$,h$,l$,h$,h$,h$,d$],G$=[-1,{}],H$=[0,f$,g$,2,G$],K$=[0,f$,p$,g$,G$];function q$(e,t){t=wO(t),e=e.u;const n=XF(e);oO(n),qO(e,n,2,""===t?void 0:t)}function X$(e,t){_M(e,3,t)}function Y$(e,t){_M(e,4,t)}var Q$=class extends kM{constructor(e){super(e,500)}o(e){return cM(this,0,7,e)}};Q$.B=[3,4,5,6,8,13,17,1005];var J$=[-500,d$,d$,p$,p$,p$,p$,g$,V$,y$,A$,l$,l$,g$,H$,g$,K$,y$,z$,d$,g$,j$,l$,p$,p$,988],Z$=[0,d$,d$,g$,G$],eD=[-500,f$,f$,g$,[-1,{}],f$,999],tD=[-500,f$,p$,p$,g$,[-2,{},c$],p$,998,p$],nD=[-500,f$,p$,g$,G$,p$,999];function rD(e,t){pM(e,Q$,t)}function aD(e,t){_M(e,10,t)}function iD(e,t){_M(e,15,t)}var sD=class extends kM{constructor(e){super(e,500)}o(e){return cM(this,0,1001,e)}};sD.B=[1,6,7,9,10,15,16,17,14,1002];var oD=[-500,y$,J$,y$,5,eD,y$,tD,l$,y$,nD,p$,l$,g$,H$,g$,K$,y$,Z$,p$,p$,p$,g$,j$,d$,d$,h$,g$,980,G$,y$,A$],uD=E$(sD,oD);sD.prototype.g=S$(oD);var lD=[0,y$,[0,o$,o$,o$]],cD=class extends kM{constructor(e){super(e)}},hD=[0,o$,t$,f$,f$],pD=class extends kM{constructor(e){super(e)}g(){return lM(this,cD,1)}};pD.B=[1];var dD=[0,y$,hD],fD=E$(pD,dD),mD=[0,o$,t$],gD=[0,o$,o$,g$,lD],yD=class extends kM{constructor(e){super(e)}},bD=[0,o$,o$,o$,o$],vD=[0,t$,t$,t$,t$],wD=class extends kM{constructor(e){super(e)}},_D=[0,t$,t$,f$,t$],xD=class extends kM{constructor(e){super(e)}h(){return oM(this,yD,2)}g(){return lM(this,wD,5)}};xD.B=[5];var kD=[0,_$,g$,bD,g$,vD,g$,gD,y$,_D],TD=class extends kM{constructor(e){super(e)}};TD.B=[1,2,3,8,9];var ED=E$(TD,[0,p$,u$,r$,g$,kD,f$,f$,a$,y$,mD,p$,a$]),SD=class extends kM{constructor(e){super(e)}},ID=[0,t$,t$,t$,t$,t$],AD=class extends kM{constructor(e){super(e)}};AD.B=[1];var CD=E$(AD,[0,y$,ID]),ND=class extends kM{constructor(e){super(e)}},RD=[0,t$,t$,t$,t$,t$],FD=class extends kM{constructor(e){super(e)}};FD.B=[1];var OD=E$(FD,[0,y$,RD]),MD=class extends kM{constructor(e){super(e)}};MD.B=[3];var $D=[0,o$,o$,r$,_$],DD=class extends kM{constructor(){super()}};DD.prototype.g=S$([0,t$,t$,t$,t$,t$,a$]);var PD=class extends kM{constructor(e){super(e)}},LD=[0,o$,2,f$,g$,dD],BD=class extends kM{constructor(e){super(e)}};BD.B=[1];var UD=E$(BD,[0,y$,LD,a$]),WD=class extends kM{constructor(e){super(e)}};WD.B=[1];var VD=class extends kM{constructor(e){super(e)}da(){const e=QO(this);return null==e?HR():e}},zD=class extends kM{constructor(e){super(e)}},jD=[1,2],GD=[0,b$,[0,r$],jD,b$,[0,v$],jD,o$,f$],HD=class extends kM{constructor(e){super(e)}};HD.B=[1];var KD=E$(HD,[0,y$,GD,a$]),qD=class extends kM{constructor(e){super(e)}};qD.B=[4,5];var XD=[0,f$,o$,t$,p$,p$],YD=class extends kM{constructor(e){super(e)}},QD=[0,c$,c$],JD=class extends kM{constructor(e){super(e)}},ZD=[1,2,3,4,5],eP=class extends kM{constructor(e){super(e)}g(){return null!=QO(this)}h(){return null!=mM(this,2)}},tP=[0,v$,f$,g$,[0,o$,a$,a$],g$,[0,s$,a$]],nP=class extends kM{constructor(e){super(e)}g(){return mO(GO(this,2))??!1}},rP=[0,g$,tP,c$,g$,[0,b$,L$,ZD,b$,M$,ZD,b$,R$,ZD,b$,P$,ZD,b$,$$,ZD]],aP=class extends kM{constructor(e){super(e)}},iP=[0,g$,rP,t$,t$,o$],sP=T$(502141897,aP);W$[502141897]=EM(iP);var oP=[0,g$,tP];W$[512499200]=EM(oP);var uP=[0,g$,oP];W$[515723506]=EM(uP);var lP=E$(class extends kM{constructor(e){super(e)}},[0,g$,[0,_$,_$,n$,w$],g$,$D]),cP=[0,g$,rP];W$[508981768]=EM(cP);var hP=class extends kM{constructor(e){super(e)}},pP=[0,g$,rP,t$,g$,cP,c$],dP=class extends kM{constructor(e){super(e)}},fP=[0,g$,rP,g$,iP,g$,pP,t$,g$,uP];W$[508968149]=EM(pP);var mP=T$(508968150,dP);W$[508968150]=EM(fP);var gP=class extends kM{constructor(e){super(e)}},yP=T$(513916220,gP);W$[513916220]=EM([0,g$,rP,g$,fP,o$]);var bP=class extends kM{constructor(e){super(e)}h(){return oM(this,qD,2)}g(){KO(this,2)}},vP=[0,g$,rP,g$,XD];W$[478825465]=EM(vP);var wP=[0,g$,rP];W$[478825422]=EM(wP);var _P=class extends kM{constructor(e){super(e)}},xP=[0,g$,rP,g$,wP,g$,vP,g$,vP],kP=class extends kM{constructor(e){super(e)}},TP=[0,g$,rP,t$,o$],EP=class extends kM{constructor(e){super(e)}},SP=[0,g$,rP,t$],IP=class extends kM{constructor(e){super(e)}},AP=[0,g$,rP,g$,TP,g$,SP,t$],CP=class extends kM{constructor(e){super(e)}},NP=[0,g$,rP,g$,AP,g$,xP];W$[463370452]=EM(xP),W$[464864288]=EM(TP),W$[474472470]=EM(SP);var RP=T$(462713202,IP);W$[462713202]=EM(AP);var FP=T$(479097054,CP);W$[479097054]=EM(NP);var OP=class extends kM{constructor(e){super(e)}},MP=T$(456383383,OP);W$[456383383]=EM([0,g$,rP,g$,XD]);var $P=class extends kM{constructor(e){super(e)}},DP=T$(476348187,$P);W$[476348187]=EM([0,g$,rP,g$,QD]);var PP=class extends kM{constructor(e){super(e)}},LP=[0,_$,_$],BP=class extends kM{constructor(e){super(e)}};BP.B=[3];var UP=T$(458105876,class extends kM{constructor(e){super(e)}g(){var e=this.u;const t=XF(e);var n=2&t;return e=function(e,t,n){var r=BP;const a=2&t;let i=!1;if(null==n){if(a)return eM();n=[]}else if(n.constructor===OO){if(0==(2&n.g)||a)return n;n=n.m()}else Array.isArray(n)?i=!!(2&qF(n)):n=[];if(a){if(!n.length)return eM();i||(i=!0,JF(n))}else i&&(i=!1,n=tM(n));return i||(64&qF(n)?KF(n,32):32&t&&GF(n,32)),qO(e,t,2,r=new OO(n,r,EO,void 0),!1),r}(e,t,HO(e,t,2)),null==e||!n&&BP&&(e.v=!0),e}});W$[458105876]=EM([0,g$,LP,HM,[0,a$,g$,[0,f$,f$,p$]]]);var WP=class extends kM{constructor(e){super(e)}},VP=T$(458105758,WP);W$[458105758]=EM([0,g$,rP,f$,g$,LP]);var zP=class extends kM{constructor(e){super(e)}};zP.B=[5,6];var jP=T$(443442058,zP);W$[443442058]=EM([0,g$,rP,f$,o$,t$,p$,p$]);var GP=class extends kM{constructor(e){super(e)}},HP=[0,g$,rP,t$,t$,o$];W$[514774813]=EM(HP);var KP=class extends kM{constructor(e){super(e)}},qP=[0,g$,rP,t$],XP=class extends kM{constructor(e){super(e)}},YP=[0,g$,rP,g$,HP,g$,qP,t$];W$[518928384]=EM(qP);var QP=T$(516587230,XP);function JP(e,t){return t=t?t.clone():new qD,void 0!==e.displayNamesLocale?KO(t,1,wO(e.displayNamesLocale)):void 0===e.displayNamesLocale&&KO(t,1),void 0!==e.maxResults?vM(t,2,e.maxResults):"maxResults"in e&&KO(t,2),void 0!==e.scoreThreshold?wM(t,3,e.scoreThreshold):"scoreThreshold"in e&&KO(t,3),void 0!==e.categoryAllowlist?nM(t,4,e.categoryAllowlist):"categoryAllowlist"in e&&KO(t,4),void 0!==e.categoryDenylist?nM(t,5,e.categoryDenylist):"categoryDenylist"in e&&KO(t,5),t}function ZP(e,t=-1,n=""){return{categories:e.map((e=>({index:gM(dM(e,1))??-1,score:yM(e,2)??0,categoryName:mM(e,3)??""??"",displayName:mM(e,4)??""??""}))),headIndex:t,headName:n}}function eL(e){var t=JO(e,3,fO),n=JO(e,2,yO);const r=JO(e,1,_O),a=JO(e,9,_O),i={categories:[],keypoints:[]};for(let e=0;e<t.length;e++)i.categories.push({score:t[e],index:n[e]??-1,categoryName:r[e]??"",displayName:a[e]??""});if((t=oM(e,xD,4)?.h())&&(i.boundingBox={originX:dM(t,1)??0,originY:dM(t,2)??0,width:dM(t,3)??0,height:dM(t,4)??0,angle:0}),oM(e,xD,4)?.g().length)for(const t of oM(e,xD,4).g())i.keypoints.push({x:YO(t,1)??0,y:YO(t,2)??0,score:YO(t,4)??0,label:mM(t,3)??""});return i}function tL(e){const t=[];for(const n of lM(e,ND,1))t.push({x:yM(n,1)??0,y:yM(n,2)??0,z:yM(n,3)??0});return t}function nL(e){const t=[];for(const n of lM(e,SD,1))t.push({x:yM(n,1)??0,y:yM(n,2)??0,z:yM(n,3)??0});return t}function rL(e){return Array.from(e,(e=>127<e?e-256:e))}function aL(e,t){if(e.length!==t.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${e.length} vs. ${t.length}).`);let n=0,r=0,a=0;for(let i=0;i<e.length;i++)n+=e[i]*t[i],r+=e[i]*e[i],a+=t[i]*t[i];if(0>=r||0>=a)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return n/Math.sqrt(r*a)}let iL;W$[516587230]=EM(YP);const sL=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function oL(){if(void 0===iL)try{await WebAssembly.instantiate(sL),iL=!0}catch{iL=!1}return iL}async function uL(e,t){const n=await oL()?"wasm_internal":"wasm_nosimd_internal";return void 0!==t?{wasmLoaderPath:`${t}/${e}_${n}.js`,wasmBinaryPath:`${t}/${e}_${n}.wasm`}:{wasmLoaderPath:C$(`./${encodeURIComponent(e)}_${encodeURIComponent(n)}.js`),wasmBinaryPath:C$(`./${encodeURIComponent(e)}_${encodeURIComponent(n)}.wasm`)}}var lL=class{};function cL(){const e=navigator.userAgent;return e.includes("Safari")&&!e.includes("Chrome")}async function hL(e){if("function"!=typeof importScripts){const t=document.createElement("script");return t.src=e.toString(),t.crossOrigin="anonymous",new Promise(((e,n)=>{t.addEventListener("load",(()=>{e()}),!1),t.addEventListener("error",(e=>{n(e)}),!1),document.body.appendChild(t)}))}importScripts(e.toString())}function pL(e,t,n){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(t=e.i.stringToNewUTF8(t)),e.i._free(t)}function dL(e,t,n){if(!e.i.canvas)throw Error("No OpenGL canvas configured.");if(n?e.i._bindTextureToStream(n):e.i._bindTextureToCanvas(),!(n=e.i.canvas.getContext("webgl2")||e.i.canvas.getContext("webgl")))throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");return e.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!0),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,t),e.i.gpuOriginForWebTexturesIsBottomLeft&&n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),t.videoWidth?(n=t.videoWidth,t=t.videoHeight):t.naturalWidth?(n=t.naturalWidth,t=t.naturalHeight):(n=t.width,t=t.height),!e.l||n===e.i.canvas.width&&t===e.i.canvas.height||(e.i.canvas.width=n,e.i.canvas.height=t),[n,t]}function fL(e,t,n){e.m||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const r=new Uint32Array(t.length);for(let n=0;n<t.length;n++)r[n]=e.i.stringToNewUTF8(t[n]);t=e.i._malloc(4*r.length),e.i.HEAPU32.set(r,t>>2),n(t);for(const t of r)e.i._free(t);e.i._free(t)}function mL(e,t,n){e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=n}function gL(e,t,n){let r=[];e.i.simpleListeners=e.i.simpleListeners||{},e.i.simpleListeners[t]=(e,t,a)=>{t?(n(r,a),r=[]):r.push(e)}}function yL(e,t){const n=oM(e.baseOptions,eP,1)||new eP;"string"==typeof t?(KO(n,2,wO(t)),KO(n,1)):t instanceof Uint8Array&&(KO(n,1,iO(t,!1,!1)),KO(n,2)),cM(e.baseOptions,0,1,n)}function bL(e){try{const t=e.I.length;if(1===t)throw Error(e.I[0].message);if(1<t)throw Error("Encountered multiple errors: "+e.I.map((e=>e.message)).join(", "))}finally{e.I=[]}}function vL(e,t){e.H=Math.max(e.H,t)}function wL(e,t){e.A=new Q$,q$(e.A,"PassThroughCalculator"),X$(e.A,"free_memory"),Y$(e.A,"free_memory_unused_out"),aD(t,"free_memory"),rD(t,e.A)}function _L(e,t){X$(e.A,t),Y$(e.A,t+"_unused_out")}function xL(e){e.g.addBoolToStream(!0,"free_memory",e.H)}lL.forVisionTasks=function(e=""){return uL("vision",e)},lL.forTextTasks=function(e=""){return uL("text",e)},lL.forAudioTasks=function(e=""){return uL("audio",e)},lL.isSimdSupported=function(){return oL()};var kL=class{constructor(e){this.g=e,this.I=[],this.H=0,this.g.setAutoRenderToScreen(!1)}l(e,t=!0){if(t){const t=e.baseOptions||{};if(e.baseOptions?.modelAssetBuffer&&e.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(oM(this.baseOptions,eP,1)?.g()||oM(this.baseOptions,eP,1)?.h()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(e,t){let n=oM(e.baseOptions,JD,3);if(!n){var r=n=new JD,a=new D$;hM(r,4,ZD,a)}"delegate"in t&&("GPU"===t.delegate?(t=n,r=new O$,hM(t,2,ZD,r)):(t=n,r=new D$,hM(t,4,ZD,r))),cM(e.baseOptions,0,3,n)}(this,t),t.modelAssetPath)return fetch(t.modelAssetPath.toString()).then((e=>{if(e.ok)return e.arrayBuffer();throw Error(`Failed to fetch model: ${t.modelAssetPath} (${e.status})`)})).then((e=>{try{this.g.i.FS_unlink("/model.dat")}catch{}this.g.i.FS_createDataFile("/","model.dat",new Uint8Array(e),!0,!1,!1),yL(this,"/model.dat"),this.m(),this.N()}));yL(this,t.modelAssetBuffer)}return this.m(),this.N(),Promise.resolve()}N(){}U(){let e;if(this.g.U((t=>{e=uD(t)})),!e)throw Error("Failed to retrieve CalculatorGraphConfig");return e}setGraph(e,t){this.g.attachErrorListener(((e,t)=>{this.I.push(Error(t))})),this.g.xa(),this.g.setGraph(e,t),this.A=void 0,bL(this)}finishProcessing(){this.g.finishProcessing(),bL(this)}close(){this.A=void 0,this.g.closeGraph()}};kL.prototype.close=kL.prototype.close;const TL={color:"white",lineWidth:4,radius:6};function EL(e){return{...TL,fillColor:(e=e||{}).color,...e}}function SL(e,t){return e instanceof Function?e(t):e}function IL(e,t,n){return Math.max(Math.min(t,n),Math.min(Math.max(t,n),e))}var AL=class{constructor(e){this.g=e}ka(e,t){if(e){var n=this.g;t=EL(t),n.save();var r=n.canvas,a=0;for(const i of e)n.fillStyle=SL(t.fillColor,{index:a,from:i}),n.strokeStyle=SL(t.color,{index:a,from:i}),n.lineWidth=SL(t.lineWidth,{index:a,from:i}),(e=new Path2D).arc(i.x*r.width,i.y*r.height,SL(t.radius,{index:a,from:i}),0,2*Math.PI),n.fill(e),n.stroke(e),++a;n.restore()}}ja(e,t,n){if(e&&t){var r=this.g;n=EL(n),r.save();var a=r.canvas,i=0;for(const s of t){r.beginPath(),t=e[s.start];const o=e[s.end];t&&o&&(r.strokeStyle=SL(n.color,{index:i,from:t,to:o}),r.lineWidth=SL(n.lineWidth,{index:i,from:t,to:o}),r.moveTo(t.x*a.width,t.y*a.height),r.lineTo(o.x*a.width,o.y*a.height)),++i,r.stroke()}r.restore()}}ia(e,t){const n=this.g;t=EL(t),n.save(),n.beginPath(),n.lineWidth=SL(t.lineWidth,{}),n.strokeStyle=SL(t.color,{}),n.fillStyle=SL(t.fillColor,{}),n.moveTo(e.originX,e.originY),n.lineTo(e.originX+e.width,e.originY),n.lineTo(e.originX+e.width,e.originY+e.height),n.lineTo(e.originX,e.originY+e.height),n.lineTo(e.originX,e.originY),n.stroke(),n.fill(),n.restore()}};function CL(e,t){if(null===e)throw Error(`Unable to obtain required WebGL resource: ${t}`);return e}AL.prototype.drawBoundingBox=AL.prototype.ia,AL.prototype.drawConnectors=AL.prototype.ja,AL.prototype.drawLandmarks=AL.prototype.ka,AL.lerp=function(e,t,n,r,a){return IL(r*(1-(e-t)/(n-t))+a*(1-(n-e)/(n-t)),r,a)},AL.clamp=IL;class NL{constructor(e,t,n,r){this.g=e,this.h=t,this.m=n,this.l=r}bind(){this.g.bindVertexArray(this.h)}close(){this.g.deleteVertexArray(this.h),this.g.deleteBuffer(this.m),this.g.deleteBuffer(this.l)}}function RL(e,t,n){const r=e.h;if(n=CL(r.createShader(n),"Failed to create WebGL shader"),r.shaderSource(n,t),r.compileShader(n),!r.getShaderParameter(n,r.COMPILE_STATUS))throw Error(`Could not compile WebGL shader: ${r.getShaderInfoLog(n)}`);return r.attachShader(e.g,n),n}function FL(e,t){const n=e.h,r=CL(n.createVertexArray(),"Failed to create vertex array");n.bindVertexArray(r);const a=CL(n.createBuffer(),"Failed to create buffer");n.bindBuffer(n.ARRAY_BUFFER,a),n.enableVertexAttribArray(e.s),n.vertexAttribPointer(e.s,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,-1,1,1,1,1,-1]),n.STATIC_DRAW);const i=CL(n.createBuffer(),"Failed to create buffer");return n.bindBuffer(n.ARRAY_BUFFER,i),n.enableVertexAttribArray(e.A),n.vertexAttribPointer(e.A,2,n.FLOAT,!1,0,0),n.bufferData(n.ARRAY_BUFFER,new Float32Array(t?[0,1,0,0,1,0,1,1]:[0,0,0,1,1,1,1,0]),n.STATIC_DRAW),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindVertexArray(null),new NL(n,r,a,i)}function OL(e,t){if(e.h){if(t!==e.h)throw Error("Cannot change GL context once initialized")}else e.h=t}function ML(e,t,n,r){if(OL(e,t),!e.g){const t=e.h;if(e.g=CL(t.createProgram(),"Failed to create WebGL program"),e.C=RL(e,"\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }",t.VERTEX_SHADER),e.v=RL(e,"\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D inputTexture;\n void main() {\n gl_FragColor = texture2D(inputTexture, vTex);\n }\n ",t.FRAGMENT_SHADER),t.linkProgram(e.g),!t.getProgramParameter(e.g,t.LINK_STATUS))throw Error(`Error during program linking: ${t.getProgramInfoLog(e.g)}`);e.s=t.getAttribLocation(e.g,"aVertex"),e.A=t.getAttribLocation(e.g,"aTex")}return n?(e.m||(e.m=FL(e,!0)),n=e.m):(e.j||(e.j=FL(e,!1)),n=e.j),t.useProgram(e.g),n.bind(),e=r(),n.g.bindVertexArray(null),e}function $L(e,t,n){OL(e,t),e.l||(e.l=CL(t.createFramebuffer(),"Failed to create framebuffe.")),t.bindFramebuffer(t.FRAMEBUFFER,e.l),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,0)}function DL(e){e.h?.bindFramebuffer(e.h.FRAMEBUFFER,null)}var PL=class{close(){if(this.g){const e=this.h;e.deleteProgram(this.g),e.deleteShader(this.C),e.deleteShader(this.v)}this.l&&this.h.deleteFramebuffer(this.l),this.j&&this.j.close(),this.m&&this.m.close()}};function LL(e,t){switch(t){case 0:return e.g.find((e=>e instanceof ImageData));case 1:return e.g.find((e=>"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap));case 2:return e.g.find((e=>"undefined"!=typeof WebGLTexture&&e instanceof WebGLTexture));default:throw Error(`Type is not supported: ${t}`)}}function BL(e){var t=LL(e,0);if(!t){t=WL(e);const n=VL(e),r=new Uint8Array(e.width*e.height*4);$L(n,t,UL(e)),t.readPixels(0,0,e.width,e.height,t.RGBA,t.UNSIGNED_BYTE,r),DL(n),t=new ImageData(new Uint8ClampedArray(r.buffer),e.width,e.height),e.g.push(t)}return t}function UL(e){let t=LL(e,2);if(!t){const n=WL(e);t=jL(e);const r=LL(e,1)||BL(e);n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,r),GL(e)}return t}function WL(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=CL(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function VL(e){return e.l||(e.l=new PL),e.l}function zL(e){(e=WL(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.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR)}function jL(e){const t=WL(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=LL(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=CL(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),zL(e)),n}function GL(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}function HL(e){const t=WL(e);return ML(VL(e),t,!0,(()=>function(e,t){const n=e.canvas;if(n.width===e.width&&n.height===e.height)return t();const r=n.width,a=n.height;return n.width=e.width,n.height=e.height,e=t(),n.width=r,n.height=a,e}(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()}))))}var KL=class{constructor(e,t,n,r,a,i,s){this.g=e,this.j=t,this.m=n,this.canvas=r,this.l=a,this.width=i,this.height=s,(this.j||this.m)&&0==--qL&&console.error("You seem to be creating MPImage instances without invoking .close(). This leaks resources.")}ta(){return!!LL(this,0)}Z(){return!!LL(this,1)}J(){return!!LL(this,2)}pa(){return BL(this)}oa(){var e=LL(this,1);return e||(UL(this),jL(this),e=HL(this),GL(this),this.g.push(e),this.j=!0),e}T(){return UL(this)}clone(){const e=[];for(const t of this.g){let n;if(t instanceof ImageData)n=new ImageData(t.data,this.width,this.height);else if(t instanceof WebGLTexture){const e=WL(this),t=VL(this);e.activeTexture(e.TEXTURE1),n=CL(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),zL(this),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,this.width,this.height,0,e.RGBA,e.UNSIGNED_BYTE,null),e.bindTexture(e.TEXTURE_2D,null),$L(t,e,n),ML(t,e,!1,(()=>{jL(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),GL(this)})),DL(t),GL(this)}else{if(!(t instanceof ImageBitmap))throw Error(`Type is not supported: ${t}`);UL(this),jL(this),n=HL(this),GL(this)}e.push(n)}return new KL(e,this.Z(),this.J(),this.canvas,this.l,this.width,this.height)}close(){this.j&&LL(this,1).close(),this.m&&WL(this).deleteTexture(LL(this,2)),qL=-1}};KL.prototype.close=KL.prototype.close,KL.prototype.clone=KL.prototype.clone,KL.prototype.getAsWebGLTexture=KL.prototype.T,KL.prototype.getAsImageBitmap=KL.prototype.oa,KL.prototype.getAsImageData=KL.prototype.pa,KL.prototype.hasWebGLTexture=KL.prototype.J,KL.prototype.hasImageBitmap=KL.prototype.Z,KL.prototype.hasImageData=KL.prototype.ta;var qL=250;function XL(e,t){switch(t){case 0:return e.g.find((e=>e instanceof Uint8Array));case 1:return e.g.find((e=>e instanceof Float32Array));case 2:return e.g.find((e=>"undefined"!=typeof WebGLTexture&&e instanceof WebGLTexture));default:throw Error(`Type is not supported: ${t}`)}}function YL(e){var t=XL(e,1);if(!t){if(t=XL(e,0))t=new Float32Array(t).map((e=>e/255));else{t=new Float32Array(e.width*e.height);const r=JL(e);var n=eB(e);if($L(n,r,QL(e)),"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document){n=new Float32Array(e.width*e.height*4),r.readPixels(0,0,e.width,e.height,r.RGBA,r.FLOAT,n);for(let e=0,r=0;e<t.length;++e,r+=4)t[e]=n[r]}else r.readPixels(0,0,e.width,e.height,r.RED,r.FLOAT,t)}e.g.push(t)}return t}function QL(e){let t=XL(e,2);if(!t){const n=JL(e);t=nB(e);const r=YL(e),a=ZL(e);n.texImage2D(n.TEXTURE_2D,0,a,e.width,e.height,0,n.RED,n.FLOAT,r),rB(e)}return t}function JL(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=CL(e.canvas.getContext("webgl2"),"You cannot use a canvas that is already bound to a different type of rendering context.")),e.h}function ZL(e){if(e=JL(e),!aB)if(e.getExtension("EXT_color_buffer_float")&&e.getExtension("OES_texture_float_linear")&&e.getExtension("EXT_float_blend"))aB=e.R32F;else{if(!e.getExtension("EXT_color_buffer_half_float"))throw Error("GPU does not fully support 4-channel float32 or float16 formats");aB=e.R16F}return aB}function eB(e){return e.l||(e.l=new PL),e.l}function tB(e){(e=JL(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)}function nB(e){const t=JL(e);t.viewport(0,0,e.width,e.height),t.activeTexture(t.TEXTURE0);let n=XL(e,2);return n?t.bindTexture(t.TEXTURE_2D,n):(n=CL(t.createTexture(),"Failed to create texture"),e.g.push(n),e.m=!0,t.bindTexture(t.TEXTURE_2D,n),tB(e)),n}function rB(e){e.h.bindTexture(e.h.TEXTURE_2D,null)}var aB,iB=class{constructor(e,t,n,r,a,i){this.g=e,this.m=t,this.canvas=n,this.l=r,this.width=a,this.height=i,this.m&&0==--sB&&console.error("You seem to be creating MPMask instances without invoking .close(). This leaks resources.")}ua(){return!!XL(this,0)}sa(){return!!XL(this,1)}J(){return!!XL(this,2)}qa(){return(e=XL(this,0))||(e=YL(this),e=new Uint8Array(e.map((e=>255*e))),this.g.push(e)),e;var e}na(){return YL(this)}T(){return QL(this)}clone(){const e=[];for(const t of this.g){let n;if(t instanceof Uint8Array)n=new Uint8Array(t);else if(t instanceof Float32Array)n=new Float32Array(t);else{if(!(t instanceof WebGLTexture))throw Error(`Type is not supported: ${t}`);{const e=JL(this),t=eB(this);e.activeTexture(e.TEXTURE1),n=CL(e.createTexture(),"Failed to create texture"),e.bindTexture(e.TEXTURE_2D,n),tB(this);const r=ZL(this);e.texImage2D(e.TEXTURE_2D,0,r,this.width,this.height,0,e.RED,e.FLOAT,null),e.bindTexture(e.TEXTURE_2D,null),$L(t,e,n),ML(t,e,!1,(()=>{nB(this),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.drawArrays(e.TRIANGLE_FAN,0,4),rB(this)})),DL(t),rB(this)}}e.push(n)}return new iB(e,this.J(),this.canvas,this.l,this.width,this.height)}close(){this.m&&JL(this).deleteTexture(XL(this,2)),sB=-1}};iB.prototype.close=iB.prototype.close,iB.prototype.clone=iB.prototype.clone,iB.prototype.getAsWebGLTexture=iB.prototype.T,iB.prototype.getAsFloat32Array=iB.prototype.na,iB.prototype.getAsUint8Array=iB.prototype.qa,iB.prototype.hasWebGLTexture=iB.prototype.J,iB.prototype.hasFloat32Array=iB.prototype.sa,iB.prototype.hasUint8Array=iB.prototype.ua;var sB=250;function oB(...e){return e.map((([e,t])=>({start:e,end:t})))}const uB=function(e){return class extends e{xa(){this.i._registerModelResourcesGraphService()}}}((lB=class{constructor(e,t){this.l=!0,this.i=e,this.g=null,this.h=0,this.m="function"==typeof this.i._addIntToInputStream,void 0!==t?this.i.canvas=t:"undefined"==typeof OffscreenCanvas||cL()?(console.warn("OffscreenCanvas not supported and GraphRunner constructor glCanvas parameter is undefined. Creating backup canvas."),this.i.canvas=document.createElement("canvas")):this.i.canvas=new OffscreenCanvas(1,1)}async initializeGraph(e){const 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){const n=e.length,r=this.i._malloc(n);this.i.HEAPU8.set(e,r),t?this.i._changeBinaryGraph(n,r):this.i._changeTextGraph(n,r),this.i._free(r)}configureAudio(e,t,n,r,a){this.i._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),pL(this,r||"input_audio",(r=>{pL(this,a=a||"audio_header",(a=>{this.i._configureAudio(r,a,e,t,n)}))}))}setAutoResizeCanvas(e){this.l=e}setAutoRenderToScreen(e){this.i._setAutoRenderToScreen(e)}setGpuBufferVerticalFlip(e){this.i.gpuOriginForWebTexturesIsBottomLeft=e}U(e){mL(this,"__graph_config__",(t=>{e(t)})),pL(this,"__graph_config__",(e=>{this.i._getGraphConfig(e,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,n){this.addAudioToStreamWithShape(e,0,0,t,n)}addAudioToStreamWithShape(e,t,n,r,a){const i=4*e.length;this.h!==i&&(this.g&&this.i._free(this.g),this.g=this.i._malloc(i),this.h=i),this.i.HEAPF32.set(e,this.g/4),pL(this,r,(e=>{this.i._addAudioToInputStream(this.g,t,n,e,a)}))}addGpuBufferToStream(e,t,n){pL(this,t,(t=>{const[r,a]=dL(this,e,t);this.i._addBoundTextureToStream(t,r,a,n)}))}addBoolToStream(e,t,n){pL(this,t,(t=>{this.i._addBoolToInputStream(e,t,n)}))}addDoubleToStream(e,t,n){pL(this,t,(t=>{this.i._addDoubleToInputStream(e,t,n)}))}addFloatToStream(e,t,n){pL(this,t,(t=>{this.i._addFloatToInputStream(e,t,n)}))}addIntToStream(e,t,n){pL(this,t,(t=>{this.i._addIntToInputStream(e,t,n)}))}addStringToStream(e,t,n){pL(this,t,(t=>{pL(this,e,(e=>{this.i._addStringToInputStream(e,t,n)}))}))}addStringRecordToStream(e,t,n){pL(this,t,(t=>{fL(this,Object.keys(e),(r=>{fL(this,Object.values(e),(a=>{this.i._addFlatHashMapToInputStream(r,a,Object.keys(e).length,t,n)}))}))}))}addProtoToStream(e,t,n,r){pL(this,n,(n=>{pL(this,t,(t=>{const a=this.i._malloc(e.length);this.i.HEAPU8.set(e,a),this.i._addProtoToInputStream(a,e.length,t,n,r),this.i._free(a)}))}))}addEmptyPacketToStream(e,t){pL(this,e,(e=>{this.i._addEmptyPacketToInputStream(e,t)}))}addBoolToInputSidePacket(e,t){pL(this,t,(t=>{this.i._addBoolToInputSidePacket(e,t)}))}addDoubleToInputSidePacket(e,t){pL(this,t,(t=>{this.i._addDoubleToInputSidePacket(e,t)}))}addFloatToInputSidePacket(e,t){pL(this,t,(t=>{this.i._addFloatToInputSidePacket(e,t)}))}addIntToInputSidePacket(e,t){pL(this,t,(t=>{this.i._addIntToInputSidePacket(e,t)}))}addStringToInputSidePacket(e,t){pL(this,t,(t=>{pL(this,e,(e=>{this.i._addStringToInputSidePacket(e,t)}))}))}addProtoToInputSidePacket(e,t,n){pL(this,n,(n=>{pL(this,t,(t=>{const r=this.i._malloc(e.length);this.i.HEAPU8.set(e,r),this.i._addProtoToInputSidePacket(r,e.length,t,n),this.i._free(r)}))}))}attachBoolListener(e,t){mL(this,e,t),pL(this,e,(e=>{this.i._attachBoolListener(e)}))}attachBoolVectorListener(e,t){gL(this,e,t),pL(this,e,(e=>{this.i._attachBoolVectorListener(e)}))}attachIntListener(e,t){mL(this,e,t),pL(this,e,(e=>{this.i._attachIntListener(e)}))}attachIntVectorListener(e,t){gL(this,e,t),pL(this,e,(e=>{this.i._attachIntVectorListener(e)}))}attachDoubleListener(e,t){mL(this,e,t),pL(this,e,(e=>{this.i._attachDoubleListener(e)}))}attachDoubleVectorListener(e,t){gL(this,e,t),pL(this,e,(e=>{this.i._attachDoubleVectorListener(e)}))}attachFloatListener(e,t){mL(this,e,t),pL(this,e,(e=>{this.i._attachFloatListener(e)}))}attachFloatVectorListener(e,t){gL(this,e,t),pL(this,e,(e=>{this.i._attachFloatVectorListener(e)}))}attachStringListener(e,t){mL(this,e,t),pL(this,e,(e=>{this.i._attachStringListener(e)}))}attachStringVectorListener(e,t){gL(this,e,t),pL(this,e,(e=>{this.i._attachStringVectorListener(e)}))}attachProtoListener(e,t,n){mL(this,e,t),pL(this,e,(e=>{this.i._attachProtoListener(e,n||!1)}))}attachProtoVectorListener(e,t,n){gL(this,e,t),pL(this,e,(e=>{this.i._attachProtoVectorListener(e,n||!1)}))}attachAudioListener(e,t,n){this.i._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),mL(this,e,((e,n)=>{e=new Float32Array(e.buffer,e.byteOffset,e.length/4),t(e,n)})),pL(this,e,(e=>{this.i._attachAudioListener(e,n||!1)}))}finishProcessing(){this.i._waitUntilIdle()}closeGraph(){this.i._closeGraph(),this.i.simpleListeners=void 0,this.i.emptyPacketListeners=void 0}},class extends lB{get W(){return this.i}ea(e,t,n){pL(this,t,(t=>{const[r,a]=dL(this,e,t);this.W._addBoundTextureAsImageToStream(t,r,a,n)}))}P(e,t){mL(this,e,t),pL(this,e,(e=>{this.W._attachImageListener(e)}))}R(e,t){gL(this,e,t),pL(this,e,(e=>{this.W._attachImageVectorListener(e)}))}}));var lB,cB=class extends uB{};async function hB(e,t,n){return async function(e,t,n,r){return async function(e,t,n,r){return e=await(async(e,t,n,r,a)=>{if(t&&await hL(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(n&&(await hL(n),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&a&&((t=self.Module).locateFile=a.locateFile,a.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=a.mainScriptUrlOrBlob)),a=await self.ModuleFactory(self.Module||a),self.ModuleFactory=self.Module=void 0,new e(a,r)})(e,n.wasmLoaderPath,n.assetLoaderPath,t,{locateFile(e){var t=n.wasmBinaryPath.toString();return t.includes(e)?t:(t=n.assetBinaryPath?.toString(),t?.includes(e)?t:e)}}),await e.o(r),e}(e,t,n,r)}(e,n.canvas??("undefined"==typeof OffscreenCanvas||cL()?document.createElement("canvas"):void 0),t,n)}function pB(e,t,n,r){if(e.X){const i=new DD;if(n?.regionOfInterest){if(!e.ca)throw Error("This task doesn't support region-of-interest.");var a=n.regionOfInterest;if(a.left>=a.right||a.top>=a.bottom)throw Error("Expected RectF with left < right and top < bottom.");if(0>a.left||0>a.top||1<a.right||1<a.bottom)throw Error("Expected RectF values to be in [0,1].");wM(i,1,(a.left+a.right)/2),wM(i,2,(a.top+a.bottom)/2),wM(i,4,a.right-a.left),wM(i,3,a.bottom-a.top)}else wM(i,1,.5),wM(i,2,.5),wM(i,4,1),wM(i,3,1);if(n?.rotationDegrees){if(0!=n?.rotationDegrees%90)throw Error("Expected rotation to be a multiple of 90°.");if(wM(i,5,-Math.PI*n.rotationDegrees/180),0!=n?.rotationDegrees%180){const[e,r]=void 0!==t.videoWidth?[t.videoWidth,t.videoHeight]:void 0!==t.naturalWidth?[t.naturalWidth,t.naturalHeight]:[t.width,t.height];n=yM(i,3)*r/e,a=yM(i,4)*e/r,wM(i,4,n),wM(i,3,a)}}e.g.addProtoToStream(i.g(),"mediapipe.NormalizedRect",e.X,r)}e.g.ea(t,e.ba,r??performance.now()),e.finishProcessing()}function dB(e,t,n){if(e.baseOptions?.g())throw Error("Task is not initialized with image mode. 'runningMode' must be set to 'IMAGE'.");pB(e,t,n,e.H+1)}function fB(e,t,n,r){if(!e.baseOptions?.g())throw Error("Task is not initialized with video mode. 'runningMode' must be set to 'VIDEO'.");pB(e,t,n,r)}function mB(e,t,n){var r=t.data;const a=t.width,i=a*(t=t.height);if((r instanceof Uint8Array||r instanceof Float32Array)&&r.length!==i)throw Error("Unsupported channel count: "+r.length/i);return e=new iB([r],!1,e.g.i.canvas,e.M,a,t),n?e.clone():e}var gB=class extends kL{constructor(e,t,n,r){super(e),this.g=e,this.ba=t,this.X=n,this.ca=r,this.M=new PL}l(e,t=!0){if("runningMode"in e&&bM(this.baseOptions,2,!!e.runningMode&&"IMAGE"!==e.runningMode),void 0!==e.canvas&&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.M.close(),super.close()}};gB.prototype.close=gB.prototype.close;var yB=class extends gB{constructor(e,t){super(new cB(e,t),"image_in","norm_rect_in",!1),this.j={detections:[]},this.h=new aP,e=new nP,cM(this.h,0,1,e),wM(this.h,2,.5),wM(this.h,3,.3)}get baseOptions(){return oM(this.h,nP,1)}set baseOptions(e){cM(this.h,0,1,e)}o(e){return"minDetectionConfidence"in e&&wM(this.h,2,e.minDetectionConfidence??.5),"minSuppressionThreshold"in e&&wM(this.h,3,e.minSuppressionThreshold??.3),this.l(e)}F(e,t){return this.j={detections:[]},dB(this,e,t),this.j}D(e,t,n){return this.j={detections:[]},fB(this,e,n,t),this.j}m(){var e=new sD;aD(e,"image_in"),aD(e,"norm_rect_in"),iD(e,"detections");const t=new U$;xM(t,sP,this.h);const n=new Q$;q$(n,"mediapipe.tasks.vision.face_detector.FaceDetectorGraph"),X$(n,"IMAGE:image_in"),X$(n,"NORM_RECT:norm_rect_in"),Y$(n,"DETECTIONS:detections"),n.o(t),rD(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=ED(t),this.j.detections.push(eL(e));vL(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{vL(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};yB.prototype.detectForVideo=yB.prototype.D,yB.prototype.setOptions=yB.prototype.o,yB.createFromModelPath=async function(e,t){return hB(yB,e,{baseOptions:{modelAssetPath:t}})},yB.createFromModelBuffer=function(e,t){return hB(yB,e,{baseOptions:{modelAssetBuffer:t}})},yB.createFromOptions=function(e,t){return hB(yB,e,t)};var bB=oB([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]),vB=oB([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]),wB=oB([276,283],[283,282],[282,295],[295,285],[300,293],[293,334],[334,296],[296,336]),_B=oB([474,475],[475,476],[476,477],[477,474]),xB=oB([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]),kB=oB([46,53],[53,52],[52,65],[65,55],[70,63],[63,105],[105,66],[66,107]),TB=oB([469,470],[470,471],[471,472],[472,469]),EB=oB([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]),SB=[...bB,...vB,...wB,...xB,...kB,...EB],IB=oB([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 AB(e){e.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]}}var CB=class extends gB{constructor(e,t){super(new cB(e,t),"image_in","norm_rect",!1),this.j={faceLandmarks:[],faceBlendshapes:[],facialTransformationMatrixes:[]},this.outputFacialTransformationMatrixes=this.outputFaceBlendshapes=!1,this.h=new dP,e=new nP,cM(this.h,0,1,e),this.v=new hP,cM(this.h,0,3,this.v),this.s=new aP,cM(this.h,0,2,this.s),vM(this.s,4,1),wM(this.s,2,.5),wM(this.v,2,.5),wM(this.h,4,.5)}get baseOptions(){return oM(this.h,nP,1)}set baseOptions(e){cM(this.h,0,1,e)}o(e){return"numFaces"in e&&vM(this.s,4,e.numFaces??1),"minFaceDetectionConfidence"in e&&wM(this.s,2,e.minFaceDetectionConfidence??.5),"minTrackingConfidence"in e&&wM(this.h,4,e.minTrackingConfidence??.5),"minFacePresenceConfidence"in e&&wM(this.v,2,e.minFacePresenceConfidence??.5),"outputFaceBlendshapes"in e&&(this.outputFaceBlendshapes=!!e.outputFaceBlendshapes),"outputFacialTransformationMatrixes"in e&&(this.outputFacialTransformationMatrixes=!!e.outputFacialTransformationMatrixes),this.l(e)}F(e,t){return AB(this),dB(this,e,t),this.j}D(e,t,n){return AB(this),fB(this,e,n,t),this.j}m(){var e=new sD;aD(e,"image_in"),aD(e,"norm_rect"),iD(e,"face_landmarks");const t=new U$;xM(t,mP,this.h);const n=new Q$;q$(n,"mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"),X$(n,"IMAGE:image_in"),X$(n,"NORM_RECT:norm_rect"),Y$(n,"NORM_LANDMARKS:face_landmarks"),n.o(t),rD(e,n),this.g.attachProtoVectorListener("face_landmarks",((e,t)=>{for(const t of e)e=OD(t),this.j.faceLandmarks.push(tL(e));vL(this,t)})),this.g.attachEmptyPacketListener("face_landmarks",(e=>{vL(this,e)})),this.outputFaceBlendshapes&&(iD(e,"blendshapes"),Y$(n,"BLENDSHAPES:blendshapes"),this.g.attachProtoVectorListener("blendshapes",((e,t)=>{if(this.outputFaceBlendshapes)for(const t of e)e=fD(t),this.j.faceBlendshapes.push(ZP(e.g()??[]));vL(this,t)})),this.g.attachEmptyPacketListener("blendshapes",(e=>{vL(this,e)}))),this.outputFacialTransformationMatrixes&&(iD(e,"face_geometry"),Y$(n,"FACE_GEOMETRY:face_geometry"),this.g.attachProtoVectorListener("face_geometry",((e,t)=>{if(this.outputFacialTransformationMatrixes)for(const t of e)(e=oM(lP(t),MD,2))&&this.j.facialTransformationMatrixes.push({rows:gM(dM(e,1))??0,columns:gM(dM(e,2))??0,data:JO(e,3,fO)??[]});vL(this,t)})),this.g.attachEmptyPacketListener("face_geometry",(e=>{vL(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};CB.prototype.detectForVideo=CB.prototype.D,CB.prototype.detect=CB.prototype.F,CB.prototype.setOptions=CB.prototype.o,CB.createFromModelPath=function(e,t){return hB(CB,e,{baseOptions:{modelAssetPath:t}})},CB.createFromModelBuffer=function(e,t){return hB(CB,e,{baseOptions:{modelAssetBuffer:t}})},CB.createFromOptions=function(e,t){return hB(CB,e,t)},CB.FACE_LANDMARKS_LIPS=bB,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LIPS",CB.FACE_LANDMARKS_LIPS),CB.FACE_LANDMARKS_LEFT_EYE=vB,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_EYE",CB.FACE_LANDMARKS_LEFT_EYE),CB.FACE_LANDMARKS_LEFT_EYEBROW=wB,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_EYEBROW",CB.FACE_LANDMARKS_LEFT_EYEBROW),CB.FACE_LANDMARKS_LEFT_IRIS=_B,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_LEFT_IRIS",CB.FACE_LANDMARKS_LEFT_IRIS),CB.FACE_LANDMARKS_RIGHT_EYE=xB,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_EYE",CB.FACE_LANDMARKS_RIGHT_EYE),CB.FACE_LANDMARKS_RIGHT_EYEBROW=kB,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_EYEBROW",CB.FACE_LANDMARKS_RIGHT_EYEBROW),CB.FACE_LANDMARKS_RIGHT_IRIS=TB,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_RIGHT_IRIS",CB.FACE_LANDMARKS_RIGHT_IRIS),CB.FACE_LANDMARKS_FACE_OVAL=EB,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_FACE_OVAL",CB.FACE_LANDMARKS_FACE_OVAL),CB.FACE_LANDMARKS_CONTOURS=SB,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_CONTOURS",CB.FACE_LANDMARKS_CONTOURS),CB.FACE_LANDMARKS_TESSELATION=IB,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$face_landmarker$face_landmarker.FaceLandmarker.FACE_LANDMARKS_TESSELATION",CB.FACE_LANDMARKS_TESSELATION);var NB=class extends gB{constructor(e,t){super(new cB(e,t),"image_in","norm_rect",!0),this.j=new gP,e=new nP,cM(this.j,0,1,e)}get baseOptions(){return oM(this.j,nP,1)}set baseOptions(e){cM(this.j,0,1,e)}o(e){return super.l(e)}za(e,t,n){const r="function"!=typeof t?t:{};if(this.h="function"==typeof t?t:n,dB(this,e,r??{}),!this.h)return this.s}m(){var e=new sD;aD(e,"image_in"),aD(e,"norm_rect"),iD(e,"stylized_image");const t=new U$;xM(t,yP,this.j);const n=new Q$;q$(n,"mediapipe.tasks.vision.face_stylizer.FaceStylizerGraph"),X$(n,"IMAGE:image_in"),X$(n,"NORM_RECT:norm_rect"),Y$(n,"STYLIZED_IMAGE:stylized_image"),n.o(t),rD(e,n),this.g.P("stylized_image",((e,t)=>{var n=!this.h,r=e.data,a=e.width;const i=a*(e=e.height);if(r instanceof Uint8Array)if(r.length===3*i){const t=new Uint8ClampedArray(4*i);for(let e=0;e<i;++e)t[4*e]=r[3*e],t[4*e+1]=r[3*e+1],t[4*e+2]=r[3*e+2],t[4*e+3]=255;r=new ImageData(t,a,e)}else{if(r.length!==4*i)throw Error("Unsupported channel count: "+r.length/i);r=new ImageData(new Uint8ClampedArray(r.buffer,r.byteOffset,r.length),a,e)}else if(!(r instanceof WebGLTexture))throw Error(`Unsupported format: ${r.constructor.name}`);a=new KL([r],!1,!1,this.g.i.canvas,this.M,a,e),this.s=n=n?a.clone():a,this.h&&this.h(n),vL(this,t)})),this.g.attachEmptyPacketListener("stylized_image",(e=>{this.s=null,this.h&&this.h(null),vL(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};NB.prototype.stylize=NB.prototype.za,NB.prototype.setOptions=NB.prototype.o,NB.createFromModelPath=function(e,t){return hB(NB,e,{baseOptions:{modelAssetPath:t}})},NB.createFromModelBuffer=function(e,t){return hB(NB,e,{baseOptions:{modelAssetBuffer:t}})},NB.createFromOptions=function(e,t){return hB(NB,e,t)};var RB=oB([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 FB(e){e.gestures=[],e.landmarks=[],e.worldLandmarks=[],e.handedness=[]}function OB(e){return 0===e.gestures.length?{gestures:[],landmarks:[],worldLandmarks:[],handedness:[],handednesses:[]}:{gestures:e.gestures,landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handedness:e.handedness,handednesses:e.handedness}}function MB(e,t=!0){const n=[];for(const a of e){var r=fD(a);e=[];for(const n of r.g())r=t&&null!=dM(n,1)?gM(dM(n,1)):-1,e.push({score:yM(n,2)??0,index:r,categoryName:mM(n,3)??""??"",displayName:mM(n,4)??""??""});n.push(e)}return n}var $B=class extends gB{constructor(e,t){super(new cB(e,t),"image_in","norm_rect",!1),this.gestures=[],this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.v=new CP,e=new nP,cM(this.v,0,1,e),this.C=new IP,cM(this.v,0,2,this.C),this.s=new EP,cM(this.C,0,3,this.s),this.h=new kP,cM(this.C,0,2,this.h),this.j=new _P,cM(this.v,0,3,this.j),wM(this.h,2,.5),wM(this.C,4,.5),wM(this.s,2,.5)}get baseOptions(){return oM(this.v,nP,1)}set baseOptions(e){cM(this.v,0,1,e)}o(e){if(vM(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&wM(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&wM(this.C,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&wM(this.s,2,e.minHandPresenceConfidence??.5),e.cannedGesturesClassifierOptions){var t=new bP,n=JP(e.cannedGesturesClassifierOptions,oM(this.j,bP,3)?.h());cM(t,0,2,n),cM(this.j,0,3,t)}else void 0===e.cannedGesturesClassifierOptions&&oM(this.j,bP,3)?.g();return e.customGesturesClassifierOptions?(cM(t=new bP,0,2,n=JP(e.customGesturesClassifierOptions,oM(this.j,bP,4)?.h())),cM(this.j,0,4,t)):void 0===e.customGesturesClassifierOptions&&oM(this.j,bP,4)?.g(),this.l(e)}va(e,t){return FB(this),dB(this,e,t),OB(this)}wa(e,t,n){return FB(this),fB(this,e,n,t),OB(this)}m(){var e=new sD;aD(e,"image_in"),aD(e,"norm_rect"),iD(e,"hand_gestures"),iD(e,"hand_landmarks"),iD(e,"world_hand_landmarks"),iD(e,"handedness");const t=new U$;xM(t,FP,this.v);const n=new Q$;q$(n,"mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"),X$(n,"IMAGE:image_in"),X$(n,"NORM_RECT:norm_rect"),Y$(n,"HAND_GESTURES:hand_gestures"),Y$(n,"LANDMARKS:hand_landmarks"),Y$(n,"WORLD_LANDMARKS:world_hand_landmarks"),Y$(n,"HANDEDNESS:handedness"),n.o(t),rD(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e){e=OD(t);const n=[];for(const t of lM(e,ND,1))n.push({x:yM(t,1)??0,y:yM(t,2)??0,z:yM(t,3)??0});this.landmarks.push(n)}vL(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{vL(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e){e=CD(t);const n=[];for(const t of lM(e,SD,1))n.push({x:yM(t,1)??0,y:yM(t,2)??0,z:yM(t,3)??0});this.worldLandmarks.push(n)}vL(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{vL(this,e)})),this.g.attachProtoVectorListener("hand_gestures",((e,t)=>{this.gestures.push(...MB(e,!1)),vL(this,t)})),this.g.attachEmptyPacketListener("hand_gestures",(e=>{vL(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{this.handedness.push(...MB(e)),vL(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{vL(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function DB(e){return{landmarks:e.landmarks,worldLandmarks:e.worldLandmarks,handednesses:e.handedness,handedness:e.handedness}}$B.prototype.recognizeForVideo=$B.prototype.wa,$B.prototype.recognize=$B.prototype.va,$B.prototype.setOptions=$B.prototype.o,$B.createFromModelPath=function(e,t){return hB($B,e,{baseOptions:{modelAssetPath:t}})},$B.createFromModelBuffer=function(e,t){return hB($B,e,{baseOptions:{modelAssetBuffer:t}})},$B.createFromOptions=function(e,t){return hB($B,e,t)},$B.HAND_CONNECTIONS=RB,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$gesture_recognizer$gesture_recognizer.GestureRecognizer.HAND_CONNECTIONS",$B.HAND_CONNECTIONS);var PB=class extends gB{constructor(e,t){super(new cB(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.handedness=[],this.j=new IP,e=new nP,cM(this.j,0,1,e),this.s=new EP,cM(this.j,0,3,this.s),this.h=new kP,cM(this.j,0,2,this.h),vM(this.h,3,1),wM(this.h,2,.5),wM(this.s,2,.5),wM(this.j,4,.5)}get baseOptions(){return oM(this.j,nP,1)}set baseOptions(e){cM(this.j,0,1,e)}o(e){return"numHands"in e&&vM(this.h,3,e.numHands??1),"minHandDetectionConfidence"in e&&wM(this.h,2,e.minHandDetectionConfidence??.5),"minTrackingConfidence"in e&&wM(this.j,4,e.minTrackingConfidence??.5),"minHandPresenceConfidence"in e&&wM(this.s,2,e.minHandPresenceConfidence??.5),this.l(e)}F(e,t){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],dB(this,e,t),DB(this)}D(e,t,n){return this.landmarks=[],this.worldLandmarks=[],this.handedness=[],fB(this,e,n,t),DB(this)}m(){var e=new sD;aD(e,"image_in"),aD(e,"norm_rect"),iD(e,"hand_landmarks"),iD(e,"world_hand_landmarks"),iD(e,"handedness");const t=new U$;xM(t,RP,this.j);const n=new Q$;q$(n,"mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"),X$(n,"IMAGE:image_in"),X$(n,"NORM_RECT:norm_rect"),Y$(n,"LANDMARKS:hand_landmarks"),Y$(n,"WORLD_LANDMARKS:world_hand_landmarks"),Y$(n,"HANDEDNESS:handedness"),n.o(t),rD(e,n),this.g.attachProtoVectorListener("hand_landmarks",((e,t)=>{for(const t of e)e=OD(t),this.landmarks.push(tL(e));vL(this,t)})),this.g.attachEmptyPacketListener("hand_landmarks",(e=>{vL(this,e)})),this.g.attachProtoVectorListener("world_hand_landmarks",((e,t)=>{for(const t of e)e=CD(t),this.worldLandmarks.push(nL(e));vL(this,t)})),this.g.attachEmptyPacketListener("world_hand_landmarks",(e=>{vL(this,e)})),this.g.attachProtoVectorListener("handedness",((e,t)=>{var n=this.handedness,r=n.push;const a=[];for(const t of e){e=fD(t);const n=[];for(const t of e.g())n.push({score:yM(t,2)??0,index:gM(dM(t,1))??-1,categoryName:mM(t,3)??""??"",displayName:mM(t,4)??""??""});a.push(n)}r.call(n,...a),vL(this,t)})),this.g.attachEmptyPacketListener("handedness",(e=>{vL(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};PB.prototype.detectForVideo=PB.prototype.D,PB.prototype.detect=PB.prototype.F,PB.prototype.setOptions=PB.prototype.o,PB.createFromModelPath=function(e,t){return hB(PB,e,{baseOptions:{modelAssetPath:t}})},PB.createFromModelBuffer=function(e,t){return hB(PB,e,{baseOptions:{modelAssetBuffer:t}})},PB.createFromOptions=function(e,t){return hB(PB,e,t)},PB.HAND_CONNECTIONS=RB,oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$hand_landmarker$hand_landmarker.HandLandmarker.HAND_CONNECTIONS",PB.HAND_CONNECTIONS);var LB=class extends gB{constructor(e,t){super(new cB(e,t),"input_image","norm_rect",!0),this.j={classifications:[]},this.h=new OP,e=new nP,cM(this.h,0,1,e)}get baseOptions(){return oM(this.h,nP,1)}set baseOptions(e){cM(this.h,0,1,e)}o(e){var t=JP(e,oM(this.h,qD,2));return cM(this.h,0,2,t),this.l(e)}ga(e,t){return this.j={classifications:[]},dB(this,e,t),this.j}ha(e,t,n){return this.j={classifications:[]},fB(this,e,n,t),this.j}m(){var e=new sD;aD(e,"input_image"),aD(e,"norm_rect"),iD(e,"classifications");const t=new U$;xM(t,MP,this.h);const n=new Q$;q$(n,"mediapipe.tasks.vision.image_classifier.ImageClassifierGraph"),X$(n,"IMAGE:input_image"),X$(n,"NORM_RECT:norm_rect"),Y$(n,"CLASSIFICATIONS:classifications"),n.o(t),rD(e,n),this.g.attachProtoListener("classifications",((e,t)=>{this.j=function(e){const t={classifications:lM(e,PD,1).map((e=>ZP(oM(e,pD,4)?.g()??[],gM(dM(e,2)),mM(e,3)??"")))};return null!=fM(e)&&(t.timestampMs=gM(fM(e))),t}(UD(e)),vL(this,t)})),this.g.attachEmptyPacketListener("classifications",(e=>{vL(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};LB.prototype.classifyForVideo=LB.prototype.ha,LB.prototype.classify=LB.prototype.ga,LB.prototype.setOptions=LB.prototype.o,LB.createFromModelPath=function(e,t){return hB(LB,e,{baseOptions:{modelAssetPath:t}})},LB.createFromModelBuffer=function(e,t){return hB(LB,e,{baseOptions:{modelAssetBuffer:t}})},LB.createFromOptions=function(e,t){return hB(LB,e,t)};var BB=class extends gB{constructor(e,t){super(new cB(e,t),"image_in","norm_rect",!0),this.h=new $P,this.embeddings={embeddings:[]},e=new nP,cM(this.h,0,1,e)}get baseOptions(){return oM(this.h,nP,1)}set baseOptions(e){cM(this.h,0,1,e)}o(e){var t=this.h,n=oM(this.h,YD,2);return n=n?n.clone():new YD,void 0!==e.l2Normalize?bM(n,1,e.l2Normalize):"l2Normalize"in e&&KO(n,1),void 0!==e.quantize?bM(n,2,e.quantize):"quantize"in e&&KO(n,2),cM(t,0,2,n),this.l(e)}la(e,t){return dB(this,e,t),this.embeddings}ma(e,t,n){return fB(this,e,n,t),this.embeddings}m(){var e=new sD;aD(e,"image_in"),aD(e,"norm_rect"),iD(e,"embeddings_out");const t=new U$;xM(t,DP,this.h);const n=new Q$;q$(n,"mediapipe.tasks.vision.image_embedder.ImageEmbedderGraph"),X$(n,"IMAGE:image_in"),X$(n,"NORM_RECT:norm_rect"),Y$(n,"EMBEDDINGS:embeddings_out"),n.o(t),rD(e,n),this.g.attachProtoListener("embeddings_out",((e,t)=>{e=KD(e),this.embeddings=function(e){return{embeddings:lM(e,zD,1).map((e=>{const t={headIndex:gM(dM(e,3))??-1,headName:mM(e,4)??""??""};if(void 0!==sM(e,WD,rM(e,1)))e=JO(e=oM(e,WD,rM(e,1)),1,fO),t.floatEmbedding=e;else{const n=new Uint8Array(0);t.quantizedEmbedding=oM(e,VD,rM(e,2))?.da()?.fa()??n}return t})),timestampMs:gM(fM(e))}}(e),vL(this,t)})),this.g.attachEmptyPacketListener("embeddings_out",(e=>{vL(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};BB.cosineSimilarity=function(e,t){if(e.floatEmbedding&&t.floatEmbedding)e=aL(e.floatEmbedding,t.floatEmbedding);else{if(!e.quantizedEmbedding||!t.quantizedEmbedding)throw Error("Cannot compute cosine similarity between quantized and float embeddings.");e=aL(rL(e.quantizedEmbedding),rL(t.quantizedEmbedding))}return e},BB.prototype.embedForVideo=BB.prototype.ma,BB.prototype.embed=BB.prototype.la,BB.prototype.setOptions=BB.prototype.o,BB.createFromModelPath=function(e,t){return hB(BB,e,{baseOptions:{modelAssetPath:t}})},BB.createFromModelBuffer=function(e,t){return hB(BB,e,{baseOptions:{modelAssetBuffer:t}})},BB.createFromOptions=function(e,t){return hB(BB,e,t)};var UB=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){this.confidenceMasks?.forEach((e=>{e.close()})),this.categoryMask?.close()}};function WB(e){e.categoryMask=void 0,e.confidenceMasks=void 0,e.qualityScores=void 0}function VB(e){try{const t=new UB(e.confidenceMasks,e.categoryMask,e.qualityScores);if(!e.j)return t;e.j(t)}finally{xL(e)}}UB.prototype.close=UB.prototype.close;var zB=class extends gB{constructor(e,t){super(new cB(e,t),"image_in","norm_rect",!1),this.s=[],this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new WP,this.v=new PP,cM(this.h,0,3,this.v),e=new nP,cM(this.h,0,1,e)}get baseOptions(){return oM(this.h,nP,1)}set baseOptions(e){cM(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?KO(this.h,2,wO(e.displayNamesLocale)):"displayNamesLocale"in e&&KO(this.h,2),"outputCategoryMask"in e&&(this.outputCategoryMask=e.outputCategoryMask??!1),"outputConfidenceMasks"in e&&(this.outputConfidenceMasks=e.outputConfidenceMasks??!0),super.l(e)}N(){!function(e){const t=lM(e.U(),Q$,1).filter((e=>(mM(e,1)??"").includes("mediapipe.tasks.TensorsToSegmentationCalculator")));if(e.s=[],1<t.length)throw Error("The graph has more than one mediapipe.tasks.TensorsToSegmentationCalculator.");1===t.length&&(oM(t[0],U$,7)?.l()?.g()??new Map).forEach(((t,n)=>{e.s[Number(n)]=mM(t,1)??""}))}(this)}V(e,t,n){const r="function"!=typeof t?t:{};return this.j="function"==typeof t?t:n,WB(this),dB(this,e,r),VB(this)}ya(e,t,n,r){const a="function"!=typeof n?n:{};return this.j="function"==typeof n?n:r,WB(this),fB(this,e,a,t),VB(this)}ra(){return this.s}m(){var e=new sD;aD(e,"image_in"),aD(e,"norm_rect");const t=new U$;xM(t,VP,this.h);const n=new Q$;q$(n,"mediapipe.tasks.vision.image_segmenter.ImageSegmenterGraph"),X$(n,"IMAGE:image_in"),X$(n,"NORM_RECT:norm_rect"),n.o(t),rD(e,n),wL(this,e),this.outputConfidenceMasks&&(iD(e,"confidence_masks"),Y$(n,"CONFIDENCE_MASKS:confidence_masks"),_L(this,"confidence_masks"),this.g.R("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>mB(this,e,!this.j))),vL(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],vL(this,e)}))),this.outputCategoryMask&&(iD(e,"category_mask"),Y$(n,"CATEGORY_MASK:category_mask"),_L(this,"category_mask"),this.g.P("category_mask",((e,t)=>{this.categoryMask=mB(this,e,!this.j),vL(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,vL(this,e)}))),iD(e,"quality_scores"),Y$(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,vL(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,vL(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};zB.prototype.getLabels=zB.prototype.ra,zB.prototype.segmentForVideo=zB.prototype.ya,zB.prototype.segment=zB.prototype.V,zB.prototype.setOptions=zB.prototype.o,zB.createFromModelPath=function(e,t){return hB(zB,e,{baseOptions:{modelAssetPath:t}})},zB.createFromModelBuffer=function(e,t){return hB(zB,e,{baseOptions:{modelAssetBuffer:t}})},zB.createFromOptions=function(e,t){return hB(zB,e,t)};var jB=class{constructor(e,t,n){this.confidenceMasks=e,this.categoryMask=t,this.qualityScores=n}close(){this.confidenceMasks?.forEach((e=>{e.close()})),this.categoryMask?.close()}};jB.prototype.close=jB.prototype.close;var GB=class extends kM{constructor(e){super(e)}},HB=[0,o$,o$,o$],KB=[0,e$,e$,e$,e$,c$],qB=[0,e$,e$,e$,e$,c$,e$,e$],XB=[0,g$,qB],YB=[0,g$,XB,g$,HB],QB=[0,g$,qB,g$,HB],JB=[0,g$,qB,o$,o$],ZB=[0,g$,JB,g$,HB],eU=[0,e$,e$,e$,e$,c$,g$,HB,g$,HB],tU=[0,e$,e$,e$,e$,c$,_$],nU=class extends kM{constructor(e){super(e)}},rU=[0,e$,e$,c$],aU=class extends kM{constructor(){super()}};aU.B=[1];var iU=class extends kM{constructor(e){super(e)}},sU=[1,2,3,4,5,6,7,8,9,10,14,15],oU=[0,b$,qB,sU,b$,QB,sU,b$,XB,sU,b$,YB,sU,b$,rU,sU,b$,tU,sU,b$,KB,sU,b$,[0,f$,e$,e$,e$,c$,o$,c$,c$,e$,3,g$,HB],sU,b$,JB,sU,b$,ZB,sU,e$,g$,HB,f$,b$,eU,sU,b$,[0,y$,rU],sU],uU=[0,f$,o$,o$,c$],lU=class extends kM{constructor(){super()}};lU.B=[1],lU.prototype.g=S$([0,y$,oU,f$,g$,uU]);var cU=class extends gB{constructor(e,t){super(new cB(e,t),"image_in","norm_rect_in",!1),this.outputCategoryMask=!1,this.outputConfidenceMasks=!0,this.h=new WP,this.v=new PP,cM(this.h,0,3,this.v),e=new nP,cM(this.h,0,1,e)}get baseOptions(){return oM(this.h,nP,1)}set baseOptions(e){cM(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)}V(e,t,n,r){const a="function"!=typeof n?n:{};this.j="function"==typeof n?n:r,this.qualityScores=this.categoryMask=this.confidenceMasks=void 0,n=this.H+1,r=new lU;const i=new iU;var s=new GB;if(vM(s,1,255),cM(i,0,12,s),t.keypoint&&t.scribble)throw Error("Cannot provide both keypoint and scribble.");if(t.keypoint){var o=new nU;bM(o,3,!0),wM(o,1,t.keypoint.x),wM(o,2,t.keypoint.y),hM(i,5,sU,o)}else{if(!t.scribble)throw Error("Must provide either a keypoint or a scribble.");for(o of(s=new aU,t.scribble))bM(t=new nU,3,!0),wM(t,1,o.x),wM(t,2,o.y),pM(s,nU,t);hM(i,15,sU,s)}pM(r,iU,i),this.g.addProtoToStream(r.g(),"drishti.RenderData","roi_in",n),dB(this,e,a);e:{try{const e=new jB(this.confidenceMasks,this.categoryMask,this.qualityScores);if(!this.j){var u=e;break e}this.j(e)}finally{xL(this)}u=void 0}return u}m(){var e=new sD;aD(e,"image_in"),aD(e,"roi_in"),aD(e,"norm_rect_in");const t=new U$;xM(t,VP,this.h);const n=new Q$;q$(n,"mediapipe.tasks.vision.interactive_segmenter.InteractiveSegmenterGraph"),X$(n,"IMAGE:image_in"),X$(n,"ROI:roi_in"),X$(n,"NORM_RECT:norm_rect_in"),n.o(t),rD(e,n),wL(this,e),this.outputConfidenceMasks&&(iD(e,"confidence_masks"),Y$(n,"CONFIDENCE_MASKS:confidence_masks"),_L(this,"confidence_masks"),this.g.R("confidence_masks",((e,t)=>{this.confidenceMasks=e.map((e=>mB(this,e,!this.j))),vL(this,t)})),this.g.attachEmptyPacketListener("confidence_masks",(e=>{this.confidenceMasks=[],vL(this,e)}))),this.outputCategoryMask&&(iD(e,"category_mask"),Y$(n,"CATEGORY_MASK:category_mask"),_L(this,"category_mask"),this.g.P("category_mask",((e,t)=>{this.categoryMask=mB(this,e,!this.j),vL(this,t)})),this.g.attachEmptyPacketListener("category_mask",(e=>{this.categoryMask=void 0,vL(this,e)}))),iD(e,"quality_scores"),Y$(n,"QUALITY_SCORES:quality_scores"),this.g.attachFloatVectorListener("quality_scores",((e,t)=>{this.qualityScores=e,vL(this,t)})),this.g.attachEmptyPacketListener("quality_scores",(e=>{this.categoryMask=void 0,vL(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};cU.prototype.segment=cU.prototype.V,cU.prototype.setOptions=cU.prototype.o,cU.createFromModelPath=function(e,t){return hB(cU,e,{baseOptions:{modelAssetPath:t}})},cU.createFromModelBuffer=function(e,t){return hB(cU,e,{baseOptions:{modelAssetBuffer:t}})},cU.createFromOptions=function(e,t){return hB(cU,e,t)};var hU=class extends gB{constructor(e,t){super(new cB(e,t),"input_frame_gpu","norm_rect",!1),this.j={detections:[]},this.h=new zP,e=new nP,cM(this.h,0,1,e)}get baseOptions(){return oM(this.h,nP,1)}set baseOptions(e){cM(this.h,0,1,e)}o(e){return void 0!==e.displayNamesLocale?KO(this.h,2,wO(e.displayNamesLocale)):"displayNamesLocale"in e&&KO(this.h,2),void 0!==e.maxResults?vM(this.h,3,e.maxResults):"maxResults"in e&&KO(this.h,3),void 0!==e.scoreThreshold?wM(this.h,4,e.scoreThreshold):"scoreThreshold"in e&&KO(this.h,4),void 0!==e.categoryAllowlist?nM(this.h,5,e.categoryAllowlist):"categoryAllowlist"in e&&KO(this.h,5),void 0!==e.categoryDenylist?nM(this.h,6,e.categoryDenylist):"categoryDenylist"in e&&KO(this.h,6),this.l(e)}F(e,t){return this.j={detections:[]},dB(this,e,t),this.j}D(e,t,n){return this.j={detections:[]},fB(this,e,n,t),this.j}m(){var e=new sD;aD(e,"input_frame_gpu"),aD(e,"norm_rect"),iD(e,"detections");const t=new U$;xM(t,jP,this.h);const n=new Q$;q$(n,"mediapipe.tasks.vision.ObjectDetectorGraph"),X$(n,"IMAGE:input_frame_gpu"),X$(n,"NORM_RECT:norm_rect"),Y$(n,"DETECTIONS:detections"),n.o(t),rD(e,n),this.g.attachProtoVectorListener("detections",((e,t)=>{for(const t of e)e=ED(t),this.j.detections.push(eL(e));vL(this,t)})),this.g.attachEmptyPacketListener("detections",(e=>{vL(this,e)})),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function pU(e){e.landmarks=[],e.worldLandmarks=[],e.v=void 0}function dU(e){try{const t=new class{constructor(e,t,n){this.landmarks=e,this.worldLandmarks=t,this.g=n}close(){this.g?.forEach((e=>{e.close()}))}}(e.landmarks,e.worldLandmarks,e.v);if(!e.s)return t;e.s(t)}finally{xL(e)}}hU.prototype.detectForVideo=hU.prototype.D,hU.prototype.detect=hU.prototype.F,hU.prototype.setOptions=hU.prototype.o,hU.createFromModelPath=async function(e,t){return hB(hU,e,{baseOptions:{modelAssetPath:t}})},hU.createFromModelBuffer=function(e,t){return hB(hU,e,{baseOptions:{modelAssetBuffer:t}})},hU.createFromOptions=function(e,t){return hB(hU,e,t)};var fU,mU=class extends gB{constructor(e,t){super(new cB(e,t),"image_in","norm_rect",!1),this.landmarks=[],this.worldLandmarks=[],this.outputSegmentationMasks=!1,this.h=new XP,e=new nP,cM(this.h,0,1,e),this.C=new KP,cM(this.h,0,3,this.C),this.j=new GP,cM(this.h,0,2,this.j),vM(this.j,4,1),wM(this.j,2,.5),wM(this.C,2,.5),wM(this.h,4,.5)}get baseOptions(){return oM(this.h,nP,1)}set baseOptions(e){cM(this.h,0,1,e)}o(e){return"numPoses"in e&&vM(this.j,4,e.numPoses??1),"minPoseDetectionConfidence"in e&&wM(this.j,2,e.minPoseDetectionConfidence??.5),"minTrackingConfidence"in e&&wM(this.h,4,e.minTrackingConfidence??.5),"minPosePresenceConfidence"in e&&wM(this.C,2,e.minPosePresenceConfidence??.5),"outputSegmentationMasks"in e&&(this.outputSegmentationMasks=e.outputSegmentationMasks??!1),this.l(e)}F(e,t,n){const r="function"!=typeof t?t:{};return this.s="function"==typeof t?t:n,pU(this),dB(this,e,r),dU(this)}D(e,t,n,r){const a="function"!=typeof n?n:{};return this.s="function"==typeof n?n:r,pU(this),fB(this,e,a,t),dU(this)}m(){var e=new sD;aD(e,"image_in"),aD(e,"norm_rect"),iD(e,"normalized_landmarks"),iD(e,"world_landmarks"),iD(e,"segmentation_masks");const t=new U$;xM(t,QP,this.h);const n=new Q$;q$(n,"mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"),X$(n,"IMAGE:image_in"),X$(n,"NORM_RECT:norm_rect"),Y$(n,"NORM_LANDMARKS:normalized_landmarks"),Y$(n,"WORLD_LANDMARKS:world_landmarks"),n.o(t),rD(e,n),wL(this,e),this.g.attachProtoVectorListener("normalized_landmarks",((e,t)=>{this.landmarks=[];for(const t of e)e=OD(t),this.landmarks.push(tL(e));vL(this,t)})),this.g.attachEmptyPacketListener("normalized_landmarks",(e=>{this.landmarks=[],vL(this,e)})),this.g.attachProtoVectorListener("world_landmarks",((e,t)=>{this.worldLandmarks=[];for(const t of e)e=CD(t),this.worldLandmarks.push(nL(e));vL(this,t)})),this.g.attachEmptyPacketListener("world_landmarks",(e=>{this.worldLandmarks=[],vL(this,e)})),this.outputSegmentationMasks&&(Y$(n,"SEGMENTATION_MASK:segmentation_masks"),_L(this,"segmentation_masks"),this.g.R("segmentation_masks",((e,t)=>{this.v=e.map((e=>mB(this,e,!this.s))),vL(this,t)})),this.g.attachEmptyPacketListener("segmentation_masks",(e=>{this.v=[],vL(this,e)}))),e=e.g(),this.setGraph(new Uint8Array(e),!0)}};function gU(e,t,n,r){e.width=t*r,e.height=n*r}mU.prototype.detectForVideo=mU.prototype.D,mU.prototype.detect=mU.prototype.F,mU.prototype.setOptions=mU.prototype.o,mU.createFromModelPath=function(e,t){return hB(mU,e,{baseOptions:{modelAssetPath:t}})},mU.createFromModelBuffer=function(e,t){return hB(mU,e,{baseOptions:{modelAssetBuffer:t}})},mU.createFromOptions=function(e,t){return hB(mU,e,t)},mU.POSE_CONNECTIONS=oB([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]),oR("module$exports$google3$third_party$mediapipe$tasks$web$vision$pose_landmarker$pose_landmarker.PoseLandmarker.POSE_CONNECTIONS",mU.POSE_CONNECTIONS);var yU,bU=function(){var e=parseFloat(fU.computedStyle.width||"0"),t=parseFloat(fU.computedStyle.height||"0"),n=window.devicePixelRatio;e===fU.cssWidth&&t===fU.cssHeight&&n===fU.devicePixelRatio||(fU.cssWidth=e,fU.cssHeight=t,fU.devicePixelRatio=n,gU(fU.canvas,e,t,n))},vU=function(){fU.canvas.style.width="100%",fU.canvas.style.height="100%"};!function(e){e[e.Start=0]="Start",e[e.Move=1]="Move",e[e.End=2]="End"}(yU||(yU={}));var wU,_U=function(){function e(e,t){var n=this;this.canvasListeners=[],this.touchOccurring=!1,this.touchListeners=[],this.canvas=e,this.touchListeners.push(t),this.registerCanvasListener("mousedown",(function(e){n.touchOccurring||(n.touchOccurred(n.touchInfo(e,yU.Start)),n.touchOccurring=!0)})),this.registerCanvasListener("touchstart",(function(e){n.touchOccurring||(n.touchOccurred(n.touchInfo(e,yU.Start)),n.touchOccurring=!0)})),this.registerCanvasListener("mousemove",(function(e){n.touchOccurring&&n.touchOccurred(n.touchInfo(e,yU.Move))})),this.registerCanvasListener("touchmove",(function(e){n.touchOccurring&&(e.preventDefault(),n.touchOccurred(n.touchInfo(e,yU.Move)))})),this.registerCanvasListener("mouseup",(function(e){n.touchOccurring&&(n.touchOccurred(n.touchInfo(e,yU.End)),n.touchOccurring=!1)})),this.registerCanvasListener("mouseout",(function(e){n.touchOccurring&&(n.touchOccurred(n.touchInfo(e,yU.End)),n.touchOccurring=!1)})),this.registerCanvasListener("touchend",(function(e){n.touchOccurring&&(n.touchOccurred(n.touchInfo(e,yU.End)),n.touchOccurring=!1)}))}return e.prototype.cleanUpCanvasListeners=function(){var e=this;this.canvasListeners.forEach((function(t){var n=t.type,r=t.listener;e.canvas.removeEventListener(n,r)})),this.canvasListeners=[]},e.prototype.addTouchListener=function(e){this.touchListeners.push(e)},e.prototype.touchOccurred=function(e){for(var t=0,n=this.touchListeners;t<n.length;t++)(0,n[t])(e)},e.prototype.registerCanvasListener=function(e,t){this.canvas.addEventListener(e,t),this.canvasListeners.push({type:e,listener:t})},e.prototype.touchInfo=function(e,t){var n=this.canvas.getBoundingClientRect(),r=this.canvas.width/n.width,a=this.canvas.height/n.height;return e instanceof MouseEvent?{x:(e.clientX-n.left)*r,y:(e.clientY-n.top)*a,touchType:t}:t==yU.End?{x:(e.changedTouches[0].clientX-n.left)*r,y:(e.changedTouches[0].clientY-n.top)*a,touchType:t}:{x:(e.touches[0].clientX-n.left)*r,y:(e.touches[0].clientY-n.top)*a,touchType:t}},e}(),xU=function(e,t,n,r){return new(n||(n=Promise))((function(a,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function o(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}u((r=r.apply(e,t||[])).next())}))},kU=function(e,t){var n,r,a,i,s={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(s=0)),s;)try{if(n=1,r&&(a=2&o[0]?r.return:o[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,o[1])).done)return a;switch(r=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((a=(a=s.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){s.label=o[1];break}if(6===o[0]&&s.label<a[1]){s.label=a[1],a=o;break}if(a&&s.label<a[2]){s.label=a[2],s.ops.push(o);break}a[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}},TU="https://cdn.jsdelivr.net/npm/deepar@".concat(a,"/"),EU={video:{facingMode:"user",frameRate:{ideal:30},width:{ideal:640},height:{ideal:360}}},SU="DEFAULT_SLOT";function IU(e){var t,n,r,a,i,s,o,u,l;return l={modelPath:null,mediaPipeConfig:{wasmBasePath:null,modelPath:null}},e.rootPath&&(l.modelPath=e.rootPath+"models/segmentation/segmentation-160x160-opt.bin",l.mediaPipeConfig.modelPath=e.rootPath+"mediaPipe/segmentation/models/selfie_segmenter.tflite",l.mediaPipeConfig.wasmBasePath=e.rootPath+"mediaPipe/segmentation/wasm"),(null===(n=null===(t=null==e?void 0:e.additionalOptions)||void 0===t?void 0:t.segmentationConfig)||void 0===n?void 0:n.modelPath)&&(l.modelPath=e.additionalOptions.segmentationConfig.modelPath),(null===(i=null===(a=null===(r=null==e?void 0:e.additionalOptions)||void 0===r?void 0:r.segmentationConfig)||void 0===a?void 0:a.mediaPipeConfig)||void 0===i?void 0:i.modelPath)&&(l.mediaPipeConfig.modelPath=e.additionalOptions.segmentationConfig.mediaPipeConfig.modelPath),(null===(u=null===(o=null===(s=null==e?void 0:e.additionalOptions)||void 0===s?void 0:s.segmentationConfig)||void 0===o?void 0:o.mediaPipeConfig)||void 0===u?void 0:u.wasmBasePath)&&(l.mediaPipeConfig.wasmBasePath=e.additionalOptions.segmentationConfig.mediaPipeConfig.wasmBasePath),l}function AU(e){return e.additionalOptions&&e.additionalOptions.faceTrackingConfig&&e.additionalOptions.faceTrackingConfig.modelPath?e.additionalOptions.faceTrackingConfig.modelPath:e.rootPath?e.rootPath+"models/face/models-68-extreme.bin":null}function CU(e){var t={poseEstimationWasmPath:"",detectorPath:"",trackerPath:"",tfjsBackendWasmPath:"",tfjsBackendWasmSimdPath:"",tfjsBackendWasmThreadedSimdPath:""};return e.rootPath&&(t.poseEstimationWasmPath=e.rootPath+"wasm/libxzimgPoseEstimation.wasm",t.detectorPath=e.rootPath+"models/face-cnn/face-det.bin",t.trackerPath=e.rootPath+"models/face-cnn/face-track-19.bin",t.tfjsBackendWasmPath=e.rootPath+"wasm/tfjs-backend-wasm.wasm",t.tfjsBackendWasmSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-simd.wasm",t.tfjsBackendWasmThreadedSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-threaded-simd.wasm"),e.additionalOptions&&e.additionalOptions.rigidFaceTrackingConfig&&(e.additionalOptions.rigidFaceTrackingConfig.poseEstimationWasmPath&&(t.poseEstimationWasmPath=e.additionalOptions.rigidFaceTrackingConfig.poseEstimationWasmPath),e.additionalOptions.rigidFaceTrackingConfig.detectorPath&&(t.detectorPath=e.additionalOptions.rigidFaceTrackingConfig.detectorPath),e.additionalOptions.rigidFaceTrackingConfig.trackerPath&&(t.trackerPath=e.additionalOptions.rigidFaceTrackingConfig.trackerPath),e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmPath&&(t.tfjsBackendWasmPath=e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmPath),e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmSimdPath&&(t.tfjsBackendWasmSimdPath=e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmSimdPath),e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmThreadedSimdPath&&(t.tfjsBackendWasmThreadedSimdPath=e.additionalOptions.rigidFaceTrackingConfig.tfjsBackendWasmThreadedSimdPath)),t}function NU(e){var t={poseEstimationWasmPath:"",detectorPath:"",trackerPath:"",objPath:"",tfjsBackendWasmPath:"",tfjsBackendWasmSimdPath:"",tfjsBackendWasmThreadedSimdPath:""};return e.rootPath&&(t.poseEstimationWasmPath=e.rootPath+"wasm/libxzimgPoseEstimation.wasm",t.objPath=e.rootPath+"models/foot/foot-model.obj",t.detectorPath=e.rootPath+"models/foot/foot-detection-96x96x6.bin",t.trackerPath=e.rootPath+"models/foot/foot-tracker-96x96x18-test.bin",t.tfjsBackendWasmPath=e.rootPath+"wasm/tfjs-backend-wasm.wasm",t.tfjsBackendWasmSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-simd.wasm",t.tfjsBackendWasmThreadedSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-threaded-simd.wasm"),e.additionalOptions&&e.additionalOptions.footTrackingConfig&&(e.additionalOptions.footTrackingConfig.poseEstimationWasmPath&&(t.poseEstimationWasmPath=e.additionalOptions.footTrackingConfig.poseEstimationWasmPath),e.additionalOptions.footTrackingConfig.detectorPath&&(t.detectorPath=e.additionalOptions.footTrackingConfig.detectorPath),e.additionalOptions.footTrackingConfig.trackerPath&&(t.trackerPath=e.additionalOptions.footTrackingConfig.trackerPath),e.additionalOptions.footTrackingConfig.objPath&&(t.objPath=e.additionalOptions.footTrackingConfig.objPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath&&(t.tfjsBackendWasmPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath&&(t.tfjsBackendWasmSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath&&(t.tfjsBackendWasmThreadedSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath)),t}function RU(e){var t={poseEstimationWasmPath:"",detectorPath:"",trackerPath:"",objPath:"",tfjsBackendWasmPath:"",tfjsBackendWasmSimdPath:"",tfjsBackendWasmThreadedSimdPath:""};return e.rootPath&&(t.poseEstimationWasmPath=e.rootPath+"wasm/libxzimgPoseEstimation.wasm",t.objPath=e.rootPath+"models/wrist/wrist-base-2.obj",t.detectorPath=e.rootPath+"models/wrist/wrist-det-9.bin",t.trackerPath=e.rootPath+"models/wrist/wrist-track.bin",t.tfjsBackendWasmPath=e.rootPath+"wasm/tfjs-backend-wasm.wasm",t.tfjsBackendWasmSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-simd.wasm",t.tfjsBackendWasmThreadedSimdPath=e.rootPath+"wasm/tfjs-backend-wasm-threaded-simd.wasm"),e.additionalOptions&&e.additionalOptions.wristTrackingConfig&&(e.additionalOptions.footTrackingConfig.poseEstimationWasmPath&&(t.poseEstimationWasmPath=e.additionalOptions.footTrackingConfig.poseEstimationWasmPath),e.additionalOptions.wristTrackingConfig.poseEstimationWasmPath&&(t.poseEstimationWasmPath=e.additionalOptions.wristTrackingConfig.poseEstimationWasmPath),e.additionalOptions.wristTrackingConfig.detectorPath&&(t.detectorPath=e.additionalOptions.wristTrackingConfig.detectorPath),e.additionalOptions.wristTrackingConfig.trackerPath&&(t.trackerPath=e.additionalOptions.wristTrackingConfig.trackerPath),e.additionalOptions.wristTrackingConfig.objPath&&(t.objPath=e.additionalOptions.wristTrackingConfig.objPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath&&(t.tfjsBackendWasmPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmPath),e.additionalOptions.wristTrackingConfig.tfjsBackendWasmPath&&(t.tfjsBackendWasmPath=e.additionalOptions.wristTrackingConfig.tfjsBackendWasmPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath&&(t.tfjsBackendWasmSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmSimdPath),e.additionalOptions.wristTrackingConfig.tfjsBackendWasmSimdPath&&(t.tfjsBackendWasmSimdPath=e.additionalOptions.wristTrackingConfig.tfjsBackendWasmSimdPath),e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath&&(t.tfjsBackendWasmThreadedSimdPath=e.additionalOptions.footTrackingConfig.tfjsBackendWasmThreadedSimdPath),e.additionalOptions.wristTrackingConfig.tfjsBackendWasmThreadedSimdPath&&(t.tfjsBackendWasmThreadedSimdPath=e.additionalOptions.wristTrackingConfig.tfjsBackendWasmThreadedSimdPath)),t}function FU(e){var t={backgroundBlurPath:"",backgroundReplacementPath:""};return e.rootPath&&(t.backgroundBlurPath=e.rootPath+"effects/background_blur.deepar",t.backgroundReplacementPath=e.rootPath+"effects/background_replacement.deepar"),t}function OU(e,t){return!(!e.additionalOptions||!e.additionalOptions.hint)&&("string"==typeof e.additionalOptions.hint?e.additionalOptions.hint===t:!!Array.isArray(e.additionalOptions.hint)&&e.additionalOptions.hint.some((function(e){return e===t})))}function MU(){return"mediaDevices"in navigator&&"getUserMedia"in navigator.mediaDevices}var $U=!1;function DU(t){var n,r,a;return xU(this,void 0,void 0,(function(){var i,o,u,l,c,h,d,f,m,g,y,b=this;return kU(this,(function(v){switch(v.label){case 0:if($U)throw new Error("DeepAR is already initialized. You cannot have multiple instances of DeepAR object. Call DeepAR.shutdown() first.");if(t.licenseKey){if("string"!=typeof t.licenseKey)throw new Error("Given licenseKey parameter is not a string.")}else{if(!t.licenceKey)throw new Error("No licenseKey parameter is passed in. You need to se the licenseKey string.");if("string"!=typeof t.licenceKey)throw new Error("Given licenseKey parameter is not a string.");t.licenseKey=t.licenceKey}if(!t.canvas&&!t.previewElement)throw new Error("No previewElement or canvas provided.");if(t.canvas&&t.previewElement)throw new Error("previewElement and canvas cannot be both provided at the same time. Use one or the other. previewElement is preferred.");if(t.canvas){if(!(t.canvas instanceof HTMLCanvasElement))throw new Error("The provided previewElement parameter is not a valid HTMLElement object. Please ensure you're passing an instance of an HTMLElement, such as a <div>, <span>, <p>, <a>, etc.")}else{if(!(t.previewElement instanceof HTMLElement))throw new Error("The given previewElement parameter is not an HTMLElement object.");t.canvas=function(e){if(fU)throw new Error("Canvas is already created. Call invalidate() first.");var t=document.createElement("canvas");t.style.display="block",t.style.maxWidth="100%",t.style.maxHeight="100%";var n=getComputedStyle(e);return gU(t,(fU={computedStyle:n,cssWidth:parseFloat(n.width||"0"),cssHeight:parseFloat(n.height||"0"),devicePixelRatio:window.devicePixelRatio||1,previewElement:e,canvas:t}).cssWidth,fU.cssHeight,fU.devicePixelRatio),e.append(t),t}(t.previewElement)}if(t.rootPath=(w=t.rootPath)?w.endsWith("/")?w:w+"/":TU,t.rootPath!=TU&&console.warn("Using non-default root path (".concat(t.rootPath,"). Root path is used to fetch additional DeepAR files like ML models for face tracking. Root path must be the root directory of a DeepAR SDK downloaded from the https://developer.deepar.ai/downloads. The file structure must not be changed! It is also important that the version of the root path SDK and version of the running DeepAR SDK are the same.")),i={licenseKey:t.licenseKey,canvasWidth:t.canvas.width,canvasHeight:t.canvas.height,canvas:t.canvas,faceTrackingModelPath:AU(t),segmentationConfig:IU(t),rigidFaceTrackingConfig:CU(t),footTrackingConfig:NU(t),wristTrackingConfig:RU(t),embeddedEffectConfig:FU(t),apiObject:{onInitialize:function(){}},initializeML:{faceModelsPredownload:OU(t,"faceModelsPredownload"),segmentationModelsPredownload:OU(t,"segmentationModelsPredownload"),footModelsPredownload:OU(t,"footModelsPredownload"),segmentationInit:OU(t,"segmentationInit"),footInit:OU(t,"footInit"),rigidFaceInit:OU(t,"rigidFaceTrackingInit"),useXzimgWebSegmentation:OU(t,"useXzimgWebSegmentation")},xzimg:{Segmentation:_T,VideoManager:p,Foot:WA,Geometry:ZA},mediaPipe:{FilesetResolver:lL,ImageSegmenter:zB},customErrors:e,locateFile:function(e,n){return t.additionalOptions&&t.additionalOptions.deeparWasmPath?t.additionalOptions.deeparWasmPath:t.rootPath?t.rootPath+"wasm/deepar.wasm":n+e}},o=!0,u=EU,l=!0,t.additionalOptions&&t.additionalOptions.cameraConfig&&(t.additionalOptions.cameraConfig.disableDefaultCamera&&(l=!1),t.additionalOptions.cameraConfig.facingMode&&"environment"==t.additionalOptions.cameraConfig.facingMode&&(u.video.facingMode="environment",o=!1)),l){if(!MU())throw new Error("No camera available!");null===(a=null===(r=null===(n=null==t?void 0:t.additionalOptions)||void 0===n?void 0:n.cameraConfig)||void 0===r?void 0:r.cameraPermissionAsked)||void 0===a||a.call(r),c=navigator.mediaDevices.getUserMedia(u)}return h=!1,t.effect&&(h=!0,d=fetch(t.effect)),[4,s(i)];case 1:if((f=v.sent()).initializeDeepAR(),$U=!0,f.startLoop(),t.previewElement&&(f.addPreRenderListener(bU),f.addPostRenderListener(vU)),m=new PU(f),g=[],l&&g.push(xU(b,void 0,void 0,(function(){var e,n,r,a;return kU(this,(function(i){switch(i.label){case 0:return(wU=document.createElement("video")).setAttribute("playsinline","playsinline"),e=wU,[4,c];case 1:return e.srcObject=i.sent(),null===(a=null===(r=null===(n=null==t?void 0:t.additionalOptions)||void 0===n?void 0:n.cameraConfig)||void 0===r?void 0:r.cameraPermissionGranted)||void 0===a||a.call(r),[2,new Promise((function(e){wU.onloadedmetadata=function(){wU.play().then((function(){f.setVideoElement(wU,o),e()}))}}))]}}))}))),h&&g.push(xU(b,void 0,void 0,(function(){var e,n,r;return kU(this,(function(a){switch(a.label){case 0:return[4,d];case 1:if((e=a.sent()).ok)return[3,2];throw new Error("Failed to fetch ".concat(t.effect,". HTTP status: ").concat(e.status," (").concat(e.statusText,")."));case 2:return r=(n=m).switchEffect,[4,e.arrayBuffer()];case 3:return[4,r.apply(n,[a.sent()])];case 4:a.sent(),a.label=5;case 5:return[2]}}))}))),!(g.length>0))return[3,5];v.label=2;case 2:return v.trys.push([2,4,,5]),[4,Promise.all(g)];case 3:return v.sent(),[3,5];case 4:throw y=v.sent(),m.shutdown(),y;case 5:return[2,m]}var w}))}))}var PU=function(){function e(e){var t=this;this.module=null,this.callbacks={},e.apiObject=this.callbacks,this.module=e,this.ScriptingAPI=new iR(e),this.canvasTouchHelper=new _U(e.canvas,(function(e){return t.touchOccurred(e)}))}return e.prototype.switchEffect=function(e,t){return xU(this,void 0,void 0,(function(){var n,r,a,i,s,o,u=this;return kU(this,(function(l){switch(l.label){case 0:if(t&&(n="face"in t&&"number"==typeof t.face,r="slot"in t&&"string"==typeof t.slot,n&&!r))throw new Error("Slot is not defined. When using switchEffect with a face parameter, you need to specify the slot also.");if(a=(null==t?void 0:t.face)?t.face:0,i=(null==t?void 0:t.slot)?t.slot:SU,a<0||a>3)throw new Error("Face value is ".concat(a," but should be 0, 1, 2 or 3"));return"string"!=typeof e?[3,3]:[4,fetch(e)];case 1:if(!(o=l.sent()).ok)throw new Error("Failed to fetch ".concat(e,". HTTP status: ").concat(o.status," (").concat(o.statusText,")."));return[4,o.arrayBuffer()];case 2:return s=l.sent(),[3,4];case 3:if(!(e instanceof ArrayBuffer))throw new Error("The first parameter in switchEffect is not string or ArrayBuffer.");s=e,l.label=4;case 4:return[2,new Promise((function(e,t){u.module.switchEffectByteArray(a,i,new Uint8Array(s),e,t)}))]}}))}))},e.prototype.clearEffect=function(e){this.module.clearEffect(e||SU)},e.prototype.takeScreenshot=function(){return xU(this,void 0,void 0,(function(){var e=this;return kU(this,(function(t){return[2,new Promise((function(t){e.module.takeScreenshot(t)}))]}))}))},e.prototype.startVideoRecording=function(e){var t,n,r,a,i,s;return xU(this,void 0,void 0,(function(){var o,u,l;return kU(this,(function(c){switch(c.label){case 0:return o=nR.name.toLowerCase(),(u={recordAudio:null!==(t=null==e?void 0:e.recordAudio)&&void 0!==t&&t,audioTrack:null!==(n=null==e?void 0:e.audioTrack)&&void 0!==n?n:void 0,audioSampleRate:48e3,audioBitRate:null!==(r=null==e?void 0:e.audioBitRate)&&void 0!==r?r:128e3,videoBitRate:null!==(a=null==e?void 0:e.videoBitRate)&&void 0!==a?a:4e6,videoFrameRate:null!==(i=null==e?void 0:e.videoFrameRate)&&void 0!==i?i:30,mimeType:"firefox"===o?"video/webm":"video/mp4"}).audioTrack||!u.recordAudio?[3,2]:[4,navigator.mediaDevices.getUserMedia({video:!1,audio:!0})];case 1:l=c.sent(),u.audioTrack=l.getAudioTracks()[0],c.label=2;case 2:return"firefox"!==o&&(u.audioTrack?u.audioSampleRate=null!==(s=null==e?void 0:e.audioSampleRate)&&void 0!==s?s:u.audioTrack.getCapabilities().sampleRate.max:u.audioSampleRate=void 0),"safari"!==o&&"firefox"!==o&&"iOS"!==nR.os.family?[3,3]:(function(e,t){if(JN.isRecording)throw new Error("Video recording already started!");JN.isRecording=!0,JN.mimeType=t.mimeType;var n={videoBitsPerSecond:t.videoBitRate,mimeType:t.mimeType},r=e.captureStream();t.audioTrack&&(r.addTrack(t.audioTrack),n.audioBitsPerSecond=t.audioBitRate),JN.mediaRecorder=new MediaRecorder(r,n),JN.mediaRecorder.ondataavailable=function(e){JN.chunks.push(e.data)},JN.mediaRecorder.start()}(this.module.canvas,u),[3,5]);case 3:return"Android"===nR.os.family&&u.audioTrack&&console.warn("Sound recording is currently not supported on Android"),[4,YN(this.module.canvas,this.callbacks,u)];case 4:c.sent(),c.label=5;case 5:return[2]}}))}))},e.prototype.finishVideoRecording=function(){return xU(this,void 0,void 0,(function(){var e,t;return kU(this,(function(n){switch(n.label){case 0:return"safari"!==(t=nR.name.toLowerCase())&&"firefox"!==t&&"iOS"!==nR.os.family?[3,2]:[4,ZN()];case 1:return e=n.sent(),[3,4];case 2:return[4,QN(this.callbacks)];case 3:e=n.sent(),n.label=4;case 4:return[2,e]}}))}))},e.prototype.backgroundBlur=function(e,t){return xU(this,void 0,void 0,(function(){var n=this;return kU(this,(function(r){if(e&&!t)throw new Error("backgroundBlur expected second argument: blur strength, a integer number in range 1-10");return[2,new Promise((function(r,a){n.module.backgroundBlur(e,t,r,a)}))]}))}))},e.prototype.backgroundReplacement=function(e,t){return xU(this,void 0,void 0,(function(){var n=this;return kU(this,(function(r){if(e&&!t)throw new Error("backgroundReplacement expected second argument: url of the image to be used as the background");return[2,new Promise((function(r,a){n.module.backgroundReplacement(e,t,r,a)}))]}))}))},e.prototype.startCamera=function(e){return xU(this,void 0,void 0,(function(){var t=this;return kU(this,(function(n){if(!MU())throw new Error("No camera available!");return[2,new Promise((function(n,r){var a,i;t.module.startCamera(null===(a=null==e?void 0:e.mirror)||void 0===a||a,null!==(i=null==e?void 0:e.mediaStreamConstraints)&&void 0!==i?i:EU,n,r,null==e?void 0:e.cameraPermissionAsked,null==e?void 0:e.cameraPermissionGranted),t.module.startLoop()}))]}))}))},e.prototype.stopCamera=function(){this.stopVideo()},e.prototype.stopVideo=function(){wU&&(wU.srcObject.getTracks().forEach((function(e){e.stop()})),wU=null),this.module.stopVideo()},e.prototype.setVideoElement=function(e,t){if(!e)throw new Error("No video element provided.");this.stopVideo(),this.module.setVideoElement(e,t),this.module.startLoop()},e.prototype.shutdown=function(){this.canvasTouchHelper.cleanUpCanvasListeners(),this.module.shutdown(),fU&&(fU.canvas.remove(),fU=null),$U=!1,this.module=void 0},e.prototype.muteSound=function(e){null==e?(console.warn("muteSound called without arguments, assuming you meant to say muteSound(true)"),console.trace(),this.module.muteSound(!0)):this.module.muteSound(e)},e.prototype.processFrame=function(e,t,n,r){this.module.processFrameRawPixels(e,t,n,r)},e.prototype.processImage=function(e){var t=document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});t.width=e.width,t.height=e.height,n.drawImage(e,0,0);var r=n.getImageData(0,0,t.width,t.height),a=new Uint8Array(r.data.buffer);this.processFrame(a,e.width,e.height,!1)},e.prototype.setPaused=function(e){e?this.module.endLoop():this.module.startLoop()},e.prototype.changeParameterFloat=function(e,t,n,r){this.module.changeParameterFloat(e,null==t?"":t,n,r)},e.prototype.changeParameterBool=function(e,t,n,r){this.module.changeParameterBool(e,null==t?"":t,n,r)},e.prototype.changeParameterVector=function(e,t,n,r,a,i,s){this.module.changeParameterVector(e,null==t?"":t,n,r,a,i,s)},e.prototype.changeParameterTexture=function(e,t,n,r){var a=this,i=new Image;i.onload=function(){var r=document.createElement("canvas"),s=r.getContext("2d",{willReadFrequently:!0});r.width=i.width,r.height=i.height,s.drawImage(i,0,0);var o=s.getImageData(0,0,r.width,r.height),u=new Uint8Array(o.data.buffer),l=a.module._malloc(u.length);a.module.HEAPU8.set(u,l),a.module.changeParameterTexture(e,null==t?"":t,n,l,u.length,r.width,r.height)},i.src=r},e.prototype.fireTrigger=function(e){this.module.fireTrigger(e)},e.prototype.setFaceDetectionSensitivity=function(e){this.module.setFaceDetectionSensitivity(e)},e.prototype.setOffscreenRenderingEnabled=function(e){this.module.setOffscreenRenderingEnabled(e)},e.prototype.getCanvas=function(){return this.module.canvas},e.prototype.setFps=function(e){this.module.setFps(e)},e.prototype.initializeFootTracking=function(){this.module.initializeFootTracking()},e.prototype.isFootTrackingInitialized=function(){return this.module.isFootTrackingInitialized()},e.prototype.initializeSegmentation=function(){this.module.initializeSegmentation()},e.prototype.isSegmentationInitialized=function(){return this.module.isSegmentationInitialized()},e.prototype.isWristTrackingInitialized=function(){return this.module.isWristTrackingInitialized()},e.prototype.showStats=function(e){this.module.showStats(e)},e.prototype.simulatePhysics=function(e){this.module.simulatePhysics(e)},e.prototype.moveGameObject=function(e,t){this.module.moveGameObject(e,t)},e.prototype.touchOccurred=function(e){e.x/=this.module.canvasWidth,e.y/=this.module.canvasHeight,this.module.touchOccurred(e)},e.prototype.enableAutoframing=function(e){this.module._enableAutoframing(e)},e.prototype.getConsoleLogs=function(){return this.module.getConsoleLogs()},e.prototype.pushConsoleLog=function(e,t){return this.module.pushConsoleLog(e,t)},e.prototype.showColliders=function(e){this.module.showColliders(e)},e.prototype.setZoom=function(e){this.module._setZoom(e)},e}()})();var a=r.Ao,i=r.Gv,s=r.rQ,o=r.o,u=r.R0,l=r.j2,c=r.i8;export{a as ARTouchType,i as DeepAR,s as ScriptingAPI,o as VarType,u as errors,l as initialize,c as version};